From d36fa0589ab822dc617c65b4d0d3bf68c092ad37 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 1 Mar 2017 12:39:54 +0100 Subject: tdf#77111 cui,sw: fix page number offset on paragraph dialog "Text Flow" Commit c2ccd20c0fd92bddfff76447754541705e3eb8f3 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 --- cui/source/inc/paragrph.hxx | 3 +- cui/source/tabpages/paragrph.cxx | 85 +++++++++++++++++++++++++++++----------- cui/uiconfig/ui/textflowpage.ui | 7 ++-- 3 files changed, 69 insertions(+), 26 deletions(-) (limited to 'cui') diff --git a/cui/source/inc/paragrph.hxx b/cui/source/inc/paragrph.hxx index c38f65a88b1f..abe414a4f24c 100644 --- a/cui/source/inc/paragrph.hxx +++ b/cui/source/inc/paragrph.hxx @@ -234,7 +234,7 @@ private: VclPtr m_pBreakPositionLB; VclPtr m_pApplyCollBtn; VclPtr m_pApplyCollBox; - VclPtr m_pPagenumText; + VclPtr m_pPageNumBox; VclPtr 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; }; diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx index 97edb56375a9..3c283573a607 100644 --- a/cui/source/tabpages/paragrph.cxx +++ b/cui/source/tabpages/paragrph.cxx @@ -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(pOld)->GetValue() != aPageNum.GetValue() ) + if (TRISTATE_TRUE == m_pPageNumBox->GetState() + && (!pOld || IsInvalidItem(pOld) + || static_cast(pOld)->GetValue() != m_pPagenumEdit->GetValue())) { + SfxUInt16Item aPageNum(SID_ATTR_PARA_PAGENUM, + static_cast(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(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(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(SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK, false); diff --git a/cui/uiconfig/ui/textflowpage.ui b/cui/uiconfig/ui/textflowpage.ui index 6a0d14d78584..644fb3f47e52 100644 --- a/cui/uiconfig/ui/textflowpage.ui +++ b/cui/uiconfig/ui/textflowpage.ui @@ -18,6 +18,7 @@ 9999 1 10 + 1 True @@ -250,13 +251,13 @@ - + True - False + True Page _number: True + True right - spinPageNumber 1 -- cgit