summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-02-08 09:46:50 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-02-08 11:01:43 +0100
commit63d3bf99101e2138a21a74a3d717d4f25d3d242f (patch)
tree6833dd8ff7f5217bddad9a1d3714e1f980f1b7c9 /cui
parent449920770449d7bf1379e2e8da6d634b90e8bace (diff)
tdf#91920 sw page gutter margin, from top: add UI
- read from sw::DocumentSettingManager::mbGutterAtTop - improve the preview widget to take gutter position into account - also change it when the gutter position widget changes - write it back to sw::DocumentSettingManager::mbGutterAtTop on modification - always check if the dialog's input item set has SID_ATTR_CHAR_GRABBAG, otherwise do nothing to keep Calc/Impress unchanged Change-Id: I05ef864bf7ac18f4c6829d78312044560e6402d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110488 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'cui')
-rw-r--r--cui/source/inc/page.hxx3
-rw-r--r--cui/source/tabpages/page.cxx77
-rw-r--r--cui/uiconfig/ui/pageformatpage.ui28
3 files changed, 104 insertions, 4 deletions
diff --git a/cui/source/inc/page.hxx b/cui/source/inc/page.hxx
index d4a39f9b68e3..1a2e8fb506c4 100644
--- a/cui/source/inc/page.hxx
+++ b/cui/source/inc/page.hxx
@@ -123,6 +123,8 @@ private:
std::unique_ptr<weld::CheckButton> m_xRegisterCB;
std::unique_ptr<weld::Label> m_xRegisterFT;
std::unique_ptr<weld::ComboBox> m_xRegisterLB;
+ std::unique_ptr<weld::Label> m_xGutterPositionFT;
+ std::unique_ptr<weld::ComboBox> m_xGutterPositionLB;
std::unique_ptr<weld::Label> m_xInsideLbl;
std::unique_ptr<weld::Label> m_xOutsideLbl;
std::unique_ptr<weld::Label> m_xPrintRangeQueryText;
@@ -130,6 +132,7 @@ private:
void Init_Impl();
DECL_LINK(LayoutHdl_Impl, weld::ComboBox&, void);
+ DECL_LINK(GutterPositionHdl_Impl, weld::ComboBox&, void);
DECL_LINK(PaperBinHdl_Impl, weld::Widget&, void);
DECL_LINK(SwapOrientation_Impl, weld::Button&, void);
void SwapFirstValues_Impl( bool bSet );
diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx
index 9a4ee5003f59..cc3cbcff0bb2 100644
--- a/cui/source/tabpages/page.cxx
+++ b/cui/source/tabpages/page.cxx
@@ -52,6 +52,8 @@
#include <svx/xdef.hxx>
#include <svx/unobrushitemhelper.hxx>
#include <svx/SvxNumOptionsTabPageHelper.hxx>
+#include <sal/log.hxx>
+#include <svl/grabbagitem.hxx>
// static ----------------------------------------------------------------
@@ -175,6 +177,8 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController*
, m_xRegisterCB(m_xBuilder->weld_check_button("checkRegisterTrue"))
, m_xRegisterFT(m_xBuilder->weld_label("labelRegisterStyle"))
, m_xRegisterLB(m_xBuilder->weld_combo_box("comboRegisterStyle"))
+ , m_xGutterPositionFT(m_xBuilder->weld_label("labelGutterPosition"))
+ , m_xGutterPositionLB(m_xBuilder->weld_combo_box("comboGutterPosition"))
// Strings stored in UI
, m_xInsideLbl(m_xBuilder->weld_label("labelInner"))
, m_xOutsideLbl(m_xBuilder->weld_label("labelOuter"))
@@ -305,6 +309,7 @@ void SvxPageDescPage::Init_Impl()
{
// adjust the handler
m_xLayoutBox->connect_changed(LINK(this, SvxPageDescPage, LayoutHdl_Impl));
+ m_xGutterPositionLB->connect_changed(LINK(this, SvxPageDescPage, GutterPositionHdl_Impl));
m_xPaperSizeBox->connect_changed(LINK(this, SvxPageDescPage, PaperSizeSelect_Impl));
m_xPaperWidthEdit->connect_value_changed( LINK(this, SvxPageDescPage, PaperSizeModify_Impl));
@@ -326,7 +331,7 @@ void SvxPageDescPage::Init_Impl()
void SvxPageDescPage::Reset( const SfxItemSet* rSet )
{
SfxItemPool* pPool = rSet->GetPool();
- DBG_ASSERT( pPool, "Where is the pool?" );
+ SAL_WARN_IF(!pPool, "cui.tabpages", "Where is the pool?");
MapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) );
// adjust margins (right/left)
@@ -358,6 +363,27 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet )
static_cast<sal_uInt16>(ConvertLong_Impl( static_cast<tools::Long>(rULSpace.GetLower()), eUnit )) );
}
+ if (rSet->HasItem(SID_ATTR_CHAR_GRABBAG, &pItem))
+ {
+ const auto& rGrabBagItem = static_cast<const SfxGrabBagItem&>(*pItem);
+ bool bGutterAtTop{};
+ auto it = rGrabBagItem.GetGrabBag().find("GutterAtTop");
+ if (it != rGrabBagItem.GetGrabBag().end())
+ {
+ it->second >>= bGutterAtTop;
+ }
+
+ if (bGutterAtTop)
+ {
+ m_xGutterPositionLB->set_active(1);
+ }
+ else
+ {
+ // Left.
+ m_xGutterPositionLB->set_active(0);
+ }
+ }
+
// general page data
SvxNumType eNumType = SVX_NUM_ARABIC;
bLandscape = ( mpDefPrinter->GetOrientation() == Orientation::Landscape );
@@ -480,6 +506,8 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet )
m_xGutterMarginLbl->hide();
m_xGutterMarginEdit->hide();
+ m_xGutterPositionFT->hide();
+ m_xGutterPositionLB->hide();
break;
}
@@ -498,6 +526,8 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet )
m_xGutterMarginLbl->hide();
m_xGutterMarginEdit->hide();
+ m_xGutterPositionFT->hide();
+ m_xGutterPositionLB->hide();
break;
}
@@ -532,6 +562,7 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet )
m_xVertBox->save_state();
m_xHorzBox->save_state();
m_xAdaptBox->save_state();
+ m_xGutterPositionLB->save_value();
CheckMarginEdits( true );
@@ -617,6 +648,29 @@ bool SvxPageDescPage::FillItemSet( SfxItemSet* rSet )
bModified = false;
}
+ if (rOldSet.HasItem(SID_ATTR_CHAR_GRABBAG))
+ {
+ // Set gutter position.
+ SfxGrabBagItem aGrabBagItem(
+ static_cast<const SfxGrabBagItem&>(rOldSet.Get(SID_ATTR_CHAR_GRABBAG)));
+ if (m_xGutterPositionLB->get_value_changed_from_saved())
+ {
+ bool bGutterAtTop = m_xGutterPositionLB->get_active() == 1;
+ aGrabBagItem.GetGrabBag()["GutterAtTop"] <<= bGutterAtTop;
+ bModified = true;
+ }
+
+ if (bModified)
+ {
+ pOld = rOldSet.GetItem(SID_ATTR_CHAR_GRABBAG);
+
+ if (!pOld || static_cast<const SfxGrabBagItem&>(*pOld) != aGrabBagItem)
+ rSet->Put(aGrabBagItem);
+ else
+ bModified = false;
+ }
+ }
+
bool bMod = false;
if (m_xTopMarginEdit->get_value_changed_from_saved())
@@ -817,6 +871,11 @@ IMPL_LINK_NOARG(SvxPageDescPage, LayoutHdl_Impl, weld::ComboBox&, void)
UpdateExample_Impl( true );
}
+IMPL_LINK_NOARG(SvxPageDescPage, GutterPositionHdl_Impl, weld::ComboBox&, void)
+{
+ UpdateExample_Impl(true);
+}
+
IMPL_LINK_NOARG(SvxPageDescPage, PaperBinHdl_Impl, weld::Widget&, void)
{
// tdf#124226 disconnect so not called again, unless Reset occurs
@@ -1022,10 +1081,20 @@ void SvxPageDescPage::UpdateExample_Impl( bool bResetbackground )
m_aBspWin.SetSize( aSize );
// Margins
- m_aBspWin.SetTop( GetCoreValue( *m_xTopMarginEdit, MapUnit::MapTwip ) );
+ bool bGutterAtTop = m_xGutterPositionLB->get_active() == 1;
+ tools::Long nTop = GetCoreValue(*m_xTopMarginEdit, MapUnit::MapTwip);
+ if (bGutterAtTop)
+ {
+ nTop += GetCoreValue(*m_xGutterMarginEdit, MapUnit::MapTwip);
+ }
+ m_aBspWin.SetTop(nTop);
m_aBspWin.SetBottom( GetCoreValue( *m_xBottomMarginEdit, MapUnit::MapTwip ) );
- m_aBspWin.SetLeft(GetCoreValue(*m_xLeftMarginEdit, MapUnit::MapTwip)
- + GetCoreValue(*m_xGutterMarginEdit, MapUnit::MapTwip));
+ tools::Long nLeft = GetCoreValue(*m_xLeftMarginEdit, MapUnit::MapTwip);
+ if (!bGutterAtTop)
+ {
+ nLeft += GetCoreValue(*m_xGutterMarginEdit, MapUnit::MapTwip);
+ }
+ m_aBspWin.SetLeft(nLeft);
m_aBspWin.SetRight( GetCoreValue( *m_xRightMarginEdit, MapUnit::MapTwip ) );
// Layout
diff --git a/cui/uiconfig/ui/pageformatpage.ui b/cui/uiconfig/ui/pageformatpage.ui
index cc8bef5433b3..e7aa3f01f6e0 100644
--- a/cui/uiconfig/ui/pageformatpage.ui
+++ b/cui/uiconfig/ui/pageformatpage.ui
@@ -673,6 +673,34 @@
</packing>
</child>
<child>
+ <object class="GtkLabel" id="labelGutterPosition">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="pageformatpage|labelGutterPosition">Gutter position:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">comboGutterPosition</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">7</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="comboGutterPosition">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <items>
+ <item translatable="yes" context="pageformatpage|liststoreGutterPosition">Left</item>
+ <item translatable="yes" context="pageformatpage|liststoreGutterPosition">Top</item>
+ </items>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">7</property>
+ </packing>
+ </child>
+ <child>
<placeholder/>
</child>
<child>