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

tdf#77111 sw: fix page number offset on table dialog "Text Flow"

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

Unfortunately the table 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 "pagenoft" so that translations still work
* set initial value to 1; 0 is a really bad default since we can't
  export it to ODF
* add a little bit of left margin so the line is indented below the
  upper line

Change-Id: I70cf5a66d4191acd2c19b3d0a83609e2b348a886
üst 6c9aa14c
......@@ -1282,7 +1282,7 @@ SwTextFlowPage::SwTextFlowPage(vcl::Window* pParent, const SfxItemSet& rSet)
get(m_pPageCollCB, "pagestyle");
get(m_pPageCollLB, "pagestylelb");
get(m_pPageNoFT, "pagenoft");
get(m_pPageNoCB, "pagenoft");
get(m_pPageNoNF, "pagenonf");
get(m_pSplitCB, "split");
......@@ -1307,6 +1307,8 @@ SwTextFlowPage::SwTextFlowPage(vcl::Window* pParent, const SfxItemSet& rSet)
LINK( this, SwTextFlowPage, PageBreakTypeHdl_Impl ) );
m_pPgBrkRB->SetClickHdl(
LINK( this, SwTextFlowPage, PageBreakTypeHdl_Impl ) );
m_pPageNoCB->SetClickHdl(
LINK(this, SwTextFlowPage, PageNoClickHdl_Impl));
m_pSplitCB->SetClickHdl(
LINK( this, SwTextFlowPage, SplitHdl_Impl));
m_pSplitRowCB->SetClickHdl(
......@@ -1341,7 +1343,7 @@ void SwTextFlowPage::dispose()
m_pPgBrkAfterRB.clear();
m_pPageCollCB.clear();
m_pPageCollLB.clear();
m_pPageNoFT.clear();
m_pPageNoCB.clear();
m_pPageNoNF.clear();
m_pSplitCB.clear();
m_pSplitRowCB.clear();
......@@ -1387,10 +1389,10 @@ bool SwTextFlowPage::FillItemSet( SfxItemSet* rSet )
//If we have a page style, then there's no break
bool bPageItemPut = false;
if ( bState != (m_pPageCollCB->GetSavedValue() == 1) ||
( bState &&
m_pPageCollLB->IsValueChangedFromSaved() )
|| (m_pPageNoNF->IsEnabled() && m_pPageNoNF->IsValueModified()) )
if ( bState != (m_pPageCollCB->GetSavedValue() == TRISTATE_TRUE)
|| (bState && m_pPageCollLB->IsValueChangedFromSaved())
|| (m_pPageNoCB->IsEnabled() && m_pPageNoCB->IsValueChangedFromSaved())
|| (m_pPageNoNF->IsEnabled() && m_pPageNoNF->IsValueModified()))
{
OUString sPage;
......@@ -1399,12 +1401,15 @@ bool SwTextFlowPage::FillItemSet( SfxItemSet* rSet )
sPage = m_pPageCollLB->GetSelectEntry();
}
sal_uInt16 nPgNum = static_cast< sal_uInt16 >(m_pPageNoNF->GetValue());
if ( !pDesc || !pDesc->GetPageDesc() ||
( pDesc->GetPageDesc() && ((pDesc->GetPageDesc()->GetName() != sPage) ||
!comphelper::string::equals(m_pPageNoNF->GetSavedValue(), nPgNum))))
bool const usePageNo(bState && m_pPageNoCB->IsChecked());
boost::optional<sal_uInt16> const oPageNum(
(usePageNo) ? nPgNum : boost::optional<sal_Int16>());
if (!pDesc || !pDesc->GetPageDesc()
|| (pDesc->GetPageDesc()->GetName() != sPage)
|| (pDesc->GetNumOffset() != oPageNum))
{
SwFormatPageDesc aFormat( pShell->FindPageDescByName( sPage, true ) );
aFormat.SetNumOffset(bState ? nPgNum : 0);
aFormat.SetNumOffset(oPageNum);
bModified |= nullptr != rSet->Put( aFormat );
bPageItemPut = bState;
}
......@@ -1526,12 +1531,18 @@ void SwTextFlowPage::Reset( const SfxItemSet* rSet )
OUString sPageDesc;
const SwPageDesc* pDesc = static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc();
//m_pPageNoNF->SetValue(static_cast<const SwFormatPageDesc*>(pItem)->GetNumOffset());
::boost::optional<sal_uInt16> oNumOffset = static_cast<const SwFormatPageDesc*>(pItem)->GetNumOffset();
if (oNumOffset)
{
m_pPageNoCB->Check();
m_pPageNoNF->Enable(true);
m_pPageNoNF->SetValue(oNumOffset.get());
}
else
{
m_pPageNoCB->Check(false);
m_pPageNoNF->Enable(false);
}
if(pDesc)
sPageDesc = pDesc->GetName();
......@@ -1571,7 +1582,7 @@ void SwTextFlowPage::Reset( const SfxItemSet* rSet )
m_pPgBrkCB->Check();
m_pPageCollCB->Enable(false);
m_pPageCollLB->Enable(false);
m_pPageNoFT->Enable(false);
m_pPageNoCB->Enable(false);
m_pPageNoNF->Enable(false);
}
switch ( eBreak )
......@@ -1659,6 +1670,7 @@ void SwTextFlowPage::Reset( const SfxItemSet* rSet )
m_pColBrkRB->SaveValue();
m_pPgBrkBeforeRB->SaveValue();
m_pPgBrkAfterRB->SaveValue();
m_pPageNoCB->SaveValue();
m_pPageNoNF->SaveValue();
m_pTextDirectionLB->SaveValue();
m_pVertOrientLB->SaveValue();
......@@ -1673,7 +1685,7 @@ void SwTextFlowPage::SetShell(SwWrtShell* pSh)
if(bHtmlMode)
{
m_pPageNoNF->Enable(false);
m_pPageNoFT->Enable(false);
m_pPageNoCB->Enable(false);
}
}
......@@ -1695,8 +1707,8 @@ IMPL_LINK_NOARG(SwTextFlowPage, PageBreakHdl_Impl, Button*, void)
m_pPageCollLB->Enable(bEnable);
if(!bHtmlMode)
{
m_pPageNoFT->Enable(bEnable);
m_pPageNoNF->Enable(bEnable);
m_pPageNoCB->Enable(bEnable);
m_pPageNoNF->Enable(bEnable && m_pPageNoCB->IsChecked());
}
}
}
......@@ -1705,7 +1717,7 @@ IMPL_LINK_NOARG(SwTextFlowPage, PageBreakHdl_Impl, Button*, void)
m_pPageCollCB->Check( false );
m_pPageCollCB->Enable(false);
m_pPageCollLB->Enable(false);
m_pPageNoFT->Enable(false);
m_pPageNoCB->Enable(false);
m_pPageNoNF->Enable(false);
m_pPgBrkRB-> Enable(false);
m_pColBrkRB-> Enable(false);
......@@ -1730,8 +1742,8 @@ IMPL_LINK_NOARG(SwTextFlowPage, ApplyCollClickHdl_Impl, Button*, void)
m_pPageCollLB->Enable(bEnable);
if(!bHtmlMode)
{
m_pPageNoFT->Enable(bEnable);
m_pPageNoNF->Enable(bEnable);
m_pPageNoCB->Enable(bEnable);
m_pPageNoNF->Enable(bEnable && m_pPageNoCB->IsChecked());
}
}
......@@ -1749,8 +1761,8 @@ IMPL_LINK( SwTextFlowPage, PageBreakPosHdl_Impl, Button*, pBtn, void )
m_pPageCollLB->Enable(bEnable);
if(!bHtmlMode)
{
m_pPageNoFT->Enable(bEnable);
m_pPageNoNF->Enable(bEnable);
m_pPageNoCB->Enable(bEnable);
m_pPageNoNF->Enable(bEnable && m_pPageNoCB->IsChecked());
}
}
else if (pBtn == m_pPgBrkAfterRB)
......@@ -1758,7 +1770,7 @@ IMPL_LINK( SwTextFlowPage, PageBreakPosHdl_Impl, Button*, pBtn, void )
m_pPageCollCB->Check( false );
m_pPageCollCB->Enable(false);
m_pPageCollLB->Enable(false);
m_pPageNoFT->Enable(false);
m_pPageNoCB->Enable(false);
m_pPageNoNF->Enable(false);
}
}
......@@ -1771,13 +1783,18 @@ IMPL_LINK( SwTextFlowPage, PageBreakTypeHdl_Impl, Button*, pBtn, void )
m_pPageCollCB->Check(false);
m_pPageCollCB->Enable(false);
m_pPageCollLB->Enable(false);
m_pPageNoFT->Enable(false);
m_pPageNoCB->Enable(false);
m_pPageNoNF->Enable(false);
}
else if ( m_pPgBrkBeforeRB->IsChecked() )
PageBreakPosHdl_Impl(m_pPgBrkBeforeRB);
}
IMPL_LINK_NOARG(SwTextFlowPage, PageNoClickHdl_Impl, Button*, void)
{
m_pPageNoNF->Enable(m_pPageNoCB->IsChecked());
}
IMPL_LINK( SwTextFlowPage, SplitHdl_Impl, Button*, pBox, void )
{
m_pSplitRowCB->Enable(static_cast<CheckBox*>(pBox)->IsChecked());
......@@ -1804,7 +1821,7 @@ void SwTextFlowPage::DisablePageBreak()
m_pPgBrkAfterRB->Disable();
m_pPageCollCB->Disable();
m_pPageCollLB->Disable();
m_pPageNoFT->Disable();
m_pPageNoCB->Disable();
m_pPageNoNF->Disable();
}
......
......@@ -155,7 +155,7 @@ class SwTextFlowPage : public SfxTabPage
VclPtr<CheckBox> m_pPageCollCB;
VclPtr<ListBox> m_pPageCollLB;
VclPtr<FixedText> m_pPageNoFT;
VclPtr<CheckBox> m_pPageNoCB;
VclPtr<NumericField> m_pPageNoNF;
VclPtr<CheckBox> m_pSplitCB;
VclPtr<TriStateBox> m_pSplitRowCB;
......@@ -176,6 +176,7 @@ class SwTextFlowPage : public SfxTabPage
DECL_LINK(ApplyCollClickHdl_Impl, Button*, void);
DECL_LINK( PageBreakPosHdl_Impl, Button*, void );
DECL_LINK( PageBreakTypeHdl_Impl, Button*, void );
DECL_LINK(PageNoClickHdl_Impl, Button*, void);
DECL_LINK( SplitHdl_Impl, Button*, void );
DECL_STATIC_LINK( SwTextFlowPage, SplitRowHdl_Impl, Button*, void );
DECL_LINK( HeadLineCBClickHdl, Button* = nullptr, void );
......
......@@ -6,6 +6,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="GtkAdjustment" id="adjustment2">
<property name="upper">100</property>
......@@ -203,6 +204,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_left">22</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
......@@ -216,12 +218,11 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="pagenoft">
<object class="GtkCheckButton" id="pagenoft">
<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="mnemonic_widget">pagenonf</property>
</object>
<packing>
<property name="left_attach">2</property>
......@@ -234,6 +235,9 @@
<property name="can_focus">True</property>
<property name="invisible_char"></property>
<property name="adjustment">adjustment1</property>
<accessibility>
<relation type="labelled-by" target="pagenoft"/>
</accessibility>
</object>
<packing>
<property name="left_attach">3</property>
......
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