Kaydet (Commit) d36fa058 authored tarafından Michael Stahl's avatar Michael Stahl

tdf#77111 cui,sw: fix page number offset on paragraph dialog "Text Flow"

Commit c2ccd20c introduced 0 as a valid
value for page number offset in sw core.

Unfortunately the paragraph dialog was not changed then; previously
page number 0 would do automatic numbering, but since then 0 was set as
the offset, and once you have a 0 offset there's no easy way to remove
it, you have to remove the whole page break.

* change the label before the text number edit widget to a checkbox
  that disables the edit widget

* keep the id "labelPageNum" so that translations still work

* adapt SfxToSwPageDescAttr so it can not just set but also clear the
  page number

* set initial value to 1; 0 is a really bad default since we can't
  export it to ODF (see tdf#91306)

Change-Id: Ic4ca9e2562bb65ac359b305a2202f782e8598307
üst 86463ec5
......@@ -234,7 +234,7 @@ private:
VclPtr<ListBox> m_pBreakPositionLB;
VclPtr<TriStateBox> m_pApplyCollBtn;
VclPtr<ListBox> m_pApplyCollBox;
VclPtr<FixedText> m_pPagenumText;
VclPtr<TriStateBox> m_pPageNumBox;
VclPtr<NumericField> m_pPagenumEdit;
// paragraph division
......@@ -262,6 +262,7 @@ private:
DECL_LINK(ApplyCollClickHdl_Impl, Button*, void);
DECL_LINK( PageBreakPosHdl_Impl, ListBox&, void );
DECL_LINK( PageBreakTypeHdl_Impl, ListBox&, void );
DECL_LINK(PageNumBoxClickHdl_Impl, Button*, void);
virtual void PageCreated(const SfxAllItemSet& aSet) override;
};
......
......@@ -1401,18 +1401,27 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
}
}
if (m_pPagenumEdit->IsEnabled() && m_pPagenumEdit->IsValueModified())
if (m_pPageNumBox->IsEnabled()
&& (m_pPageNumBox->IsValueChangedFromSaved() || m_pPagenumEdit->IsValueModified()))
{
SfxUInt16Item aPageNum( SID_ATTR_PARA_PAGENUM,
(sal_uInt16)m_pPagenumEdit->GetValue() );
pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_PAGENUM );
if ( !pOld || static_cast<const SfxUInt16Item*>(pOld)->GetValue() != aPageNum.GetValue() )
if (TRISTATE_TRUE == m_pPageNumBox->GetState()
&& (!pOld || IsInvalidItem(pOld)
|| static_cast<const SfxUInt16Item*>(pOld)->GetValue() != m_pPagenumEdit->GetValue()))
{
SfxUInt16Item aPageNum(SID_ATTR_PARA_PAGENUM,
static_cast<sal_uInt16>(m_pPagenumEdit->GetValue()));
rOutSet->Put( aPageNum );
bModified = true;
}
else if (TRISTATE_FALSE == m_pPageNumBox->GetState()
&& (pOld || IsInvalidItem(pOld)))
{
// need to tell sw to remove the item
rOutSet->DisableItem(SID_ATTR_PARA_PAGENUM);
bModified = true;
}
}
// pagebreak
......@@ -1604,11 +1613,34 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet )
_nWhich = GetWhich( SID_ATTR_PARA_PAGENUM );
if (rSet->GetItemState(_nWhich) >= SfxItemState::SET)
switch (rSet->GetItemState(_nWhich))
{
const sal_uInt16 nPageNum =
static_cast<const SfxUInt16Item&>(rSet->Get( _nWhich ) ).GetValue();
m_pPagenumEdit->SetValue( nPageNum );
case SfxItemState::SET:
{
m_pPageNumBox->EnableTriState(false);
m_pPageNumBox->SetState(TRISTATE_TRUE);
SfxUInt16Item const*const pItem(static_cast<const SfxUInt16Item*>(rSet->GetItem(_nWhich)));
const sal_uInt16 nPageNum(pItem->GetValue());
m_pPagenumEdit->SetValue( nPageNum );
break;
}
case SfxItemState::DONTCARE:
{
m_pPageNumBox->EnableTriState();
m_pPageNumBox->SetState(TRISTATE_INDET);
break;
}
case SfxItemState::UNKNOWN:
case SfxItemState::DEFAULT:
case SfxItemState::DISABLED:
{
m_pPageNumBox->EnableTriState(false);
m_pPageNumBox->SetState(TRISTATE_FALSE);
break;
}
default:
assert(false); // unexpected
break;
}
if ( bPageBreak )
......@@ -1664,7 +1696,7 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet )
m_pApplyCollBtn->Enable(false);
m_pApplyCollBox->Enable(false);
m_pPagenumEdit->Enable(false);
m_pPagenumText->Enable(false);
m_pPageNumBox->Enable(false);
}
if ( !bIsPageModel )
......@@ -1697,6 +1729,7 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet )
if(!_bEnable)
{
m_pApplyCollBox->Enable(_bEnable);
m_pPageNumBox->Enable(false);
m_pPagenumEdit->Enable(_bEnable);
}
......@@ -1844,6 +1877,7 @@ void SvxExtParagraphTabPage::ChangesApplied()
m_pBreakTypeLB->SaveValue();
m_pApplyCollBtn->SaveValue();
m_pApplyCollBox->SaveValue();
m_pPageNumBox->SaveValue();
m_pPagenumEdit->SaveValue();
m_pKeepTogetherBox->SaveValue();
m_pKeepParaBox->SaveValue();
......@@ -1869,6 +1903,7 @@ void SvxExtParagraphTabPage::DisablePageBreak()
m_pBreakPositionLB->Enable(false);
m_pApplyCollBtn->Enable(false);
m_pApplyCollBox->Enable(false);
m_pPageNumBox->Enable(false);
m_pPagenumEdit->Enable(false);
}
......@@ -1897,7 +1932,7 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage( vcl::Window* pParent, const SfxI
get(m_pPagenumEdit,"spinPageNumber");
get(m_pBreakTypeFT,"labelType");
get(m_pBreakPositionFT,"labelPosition");
get(m_pPagenumText,"labelPageNum");
get(m_pPageNumBox,"labelPageNum");
// Options
get(m_pKeepTogetherBox,"checkSplitPara");
......@@ -1922,6 +1957,7 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage( vcl::Window* pParent, const SfxI
m_pApplyCollBtn->SetClickHdl( LINK( this, SvxExtParagraphTabPage, ApplyCollClickHdl_Impl ) );
m_pBreakTypeLB->SetSelectHdl( LINK( this, SvxExtParagraphTabPage, PageBreakTypeHdl_Impl ) );
m_pBreakPositionLB->SetSelectHdl( LINK( this, SvxExtParagraphTabPage, PageBreakPosHdl_Impl ) );
m_pPageNumBox->SetClickHdl( LINK( this, SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl ) );
SfxObjectShell* pSh = SfxObjectShell::Current();
if ( pSh )
......@@ -1953,7 +1989,7 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage( vcl::Window* pParent, const SfxI
m_pExtHyphenAfterBox ->Enable(false);
m_pMaxHyphenLabel ->Enable(false);
m_pMaxHyphenEdit ->Enable(false);
m_pPagenumText ->Enable(false);
m_pPageNumBox ->Enable(false);
m_pPagenumEdit ->Enable(false);
// no column break in HTML
m_pBreakTypeLB->RemoveEntry(1);
......@@ -1981,7 +2017,7 @@ void SvxExtParagraphTabPage::dispose()
m_pBreakPositionLB.clear();
m_pApplyCollBtn.clear();
m_pApplyCollBox.clear();
m_pPagenumText.clear();
m_pPageNumBox.clear();
m_pPagenumEdit.clear();
m_pKeepTogetherBox.clear();
m_pKeepParaBox.clear();
......@@ -2014,8 +2050,8 @@ IMPL_LINK_NOARG(SvxExtParagraphTabPage, PageBreakHdl_Impl, Button*, void)
m_pApplyCollBox->Enable(bEnable);
if(!bHtmlMode)
{
m_pPagenumText->Enable(bEnable);
m_pPagenumEdit->Enable(bEnable);
m_pPageNumBox->Enable(bEnable);
m_pPagenumEdit->Enable(bEnable && m_pPageNumBox->GetState() == TRISTATE_TRUE);
}
}
break;
......@@ -2025,7 +2061,7 @@ IMPL_LINK_NOARG(SvxExtParagraphTabPage, PageBreakHdl_Impl, Button*, void)
m_pApplyCollBtn->SetState( TRISTATE_FALSE );
m_pApplyCollBtn->Enable(false);
m_pApplyCollBox->Enable(false);
m_pPagenumText->Enable(false);
m_pPageNumBox->Enable(false);
m_pPagenumEdit->Enable(false);
m_pBreakTypeFT->Enable(false);
m_pBreakTypeLB->Enable(false);
......@@ -2115,8 +2151,8 @@ IMPL_LINK_NOARG(SvxExtParagraphTabPage, ApplyCollClickHdl_Impl, Button*, void)
m_pApplyCollBox->Enable(bEnable);
if(!bHtmlMode)
{
m_pPagenumText->Enable(bEnable);
m_pPagenumEdit->Enable(bEnable);
m_pPageNumBox->Enable(bEnable);
m_pPagenumEdit->Enable(bEnable && m_pPageNumBox->GetState() == TRISTATE_TRUE);
}
}
......@@ -2132,8 +2168,8 @@ IMPL_LINK( SvxExtParagraphTabPage, PageBreakPosHdl_Impl, ListBox&, rListBox, voi
m_pApplyCollBox->Enable(bEnable);
if(!bHtmlMode)
{
m_pPagenumText->Enable(bEnable);
m_pPagenumEdit->Enable(bEnable);
m_pPageNumBox->Enable(bEnable);
m_pPagenumEdit->Enable(bEnable && m_pPageNumBox->GetState() == TRISTATE_TRUE);
}
}
else if ( 1 == rListBox.GetSelectEntryPos() )
......@@ -2141,7 +2177,7 @@ IMPL_LINK( SvxExtParagraphTabPage, PageBreakPosHdl_Impl, ListBox&, rListBox, voi
m_pApplyCollBtn->SetState( TRISTATE_FALSE );
m_pApplyCollBtn->Enable(false);
m_pApplyCollBox->Enable(false);
m_pPagenumText->Enable(false);
m_pPageNumBox->Enable(false);
m_pPagenumEdit->Enable(false);
}
}
......@@ -2155,13 +2191,18 @@ IMPL_LINK( SvxExtParagraphTabPage, PageBreakTypeHdl_Impl, ListBox&, rListBox, vo
m_pApplyCollBtn->SetState( TRISTATE_FALSE );
m_pApplyCollBtn->Enable(false);
m_pApplyCollBox->Enable(false);
m_pPagenumText->Enable(false);
m_pPageNumBox->Enable(false);
m_pPagenumEdit->Enable(false);
}
else
PageBreakPosHdl_Impl( *m_pBreakPositionLB );
}
IMPL_LINK_NOARG(SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl, Button*, void)
{
m_pPagenumEdit->Enable(m_pPageNumBox->GetState() == TRISTATE_TRUE);
}
void SvxExtParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
{
const SfxBoolItem* pDisablePageBreakItem = aSet.GetItem<SfxBoolItem>(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK, false);
......
......@@ -18,6 +18,7 @@
<property name="upper">9999</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
<property name="value">1</property>
</object>
<object class="GtkGrid" id="TextFlowPage">
<property name="visible">True</property>
......@@ -250,13 +251,13 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="labelPageNum">
<object class="GtkCheckButton" id="labelPageNum">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Page _number:</property>
<property name="use_underline">True</property>
<property name="inconsistent">True</property>
<property name="justify">right</property>
<property name="mnemonic_widget">spinPageNumber</property>
<property name="xalign">1</property>
</object>
<packing>
......
......@@ -600,10 +600,25 @@ void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet )
bool bChanged = false;
// Page number
if(SfxItemState::SET == rSet.GetItemState(SID_ATTR_PARA_PAGENUM, false, &pItem))
switch (rSet.GetItemState(SID_ATTR_PARA_PAGENUM, false, &pItem))
{
aPgDesc.SetNumOffset(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
bChanged = true;
case SfxItemState::SET:
{
aPgDesc.SetNumOffset(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
bChanged = true;
break;
}
case SfxItemState::DISABLED:
{
bChanged = true; // default initialised aPgDesc clears the number
break;
}
case SfxItemState::UNKNOWN:
case SfxItemState::DEFAULT:
break;
default:
assert(false); // unexpected
break;
}
if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_PARA_MODEL, false, &pItem ))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment