summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-03-01 12:39:54 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-03-01 16:32:22 +0000
commita5104f575a5acf8aea957cb79aa0fd67bc74f141 (patch)
treef80a014968cebee3ac894e472c22d3dfd3ac4c0c
parente9fd3674fe783df2c905c3d9b29d0a2bec0cfa00 (diff)
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 (cherry picked from commit d36fa0589ab822dc617c65b4d0d3bf68c092ad37) Reviewed-on: https://gerrit.libreoffice.org/34745 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--cui/source/inc/paragrph.hxx3
-rw-r--r--cui/source/tabpages/paragrph.cxx85
-rw-r--r--cui/uiconfig/ui/textflowpage.ui10
-rw-r--r--sw/source/uibase/utlui/uitool.cxx21
4 files changed, 90 insertions, 29 deletions
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<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;
};
diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx
index 2f630444a9c7..5a26a659bfa1 100644
--- a/cui/source/tabpages/paragrph.cxx
+++ b/cui/source/tabpages/paragrph.cxx
@@ -1402,18 +1402,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
@@ -1605,11 +1614,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 )
@@ -1665,7 +1697,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 )
@@ -1698,6 +1730,7 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet )
if(!_bEnable)
{
m_pApplyCollBox->Enable(_bEnable);
+ m_pPageNumBox->Enable(false);
m_pPagenumEdit->Enable(_bEnable);
}
@@ -1845,6 +1878,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();
@@ -1870,6 +1904,7 @@ void SvxExtParagraphTabPage::DisablePageBreak()
m_pBreakPositionLB->Enable(false);
m_pApplyCollBtn->Enable(false);
m_pApplyCollBox->Enable(false);
+ m_pPageNumBox->Enable(false);
m_pPagenumEdit->Enable(false);
}
@@ -1898,7 +1933,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");
@@ -1923,6 +1958,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 )
@@ -1954,7 +1990,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);
@@ -1982,7 +2018,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();
@@ -2015,8 +2051,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;
@@ -2026,7 +2062,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);
@@ -2116,8 +2152,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);
}
}
@@ -2133,8 +2169,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() )
@@ -2142,7 +2178,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);
}
}
@@ -2156,13 +2192,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);
diff --git a/cui/uiconfig/ui/textflowpage.ui b/cui/uiconfig/ui/textflowpage.ui
index 6a0d14d78584..8ce7a43b9100 100644
--- a/cui/uiconfig/ui/textflowpage.ui
+++ b/cui/uiconfig/ui/textflowpage.ui
@@ -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>
@@ -243,6 +244,9 @@
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
<property name="adjustment">adjustment3</property>
+ <accessibility>
+ <relation type="labelled-by" target="labelPageNum"/>
+ </accessibility>
</object>
<packing>
<property name="left_attach">4</property>
@@ -250,13 +254,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>
diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx
index d40e71ce6fa7..9783a63998da 100644
--- a/sw/source/uibase/utlui/uitool.cxx
+++ b/sw/source/uibase/utlui/uitool.cxx
@@ -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 ))
{