[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - cui/source cui/uiconfig include/svtools sw/qa sw/source writerfilter/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Wed Feb 10 11:12:24 UTC 2021
cui/source/inc/page.hxx | 3
cui/source/tabpages/page.cxx | 77 ++++++++++++++++++++-
cui/uiconfig/ui/pageformatpage.ui | 90 ++++++++++++++++---------
include/svtools/rtfkeywd.hxx | 1
sw/qa/extras/rtfexport/data/gutter-top.rtf | 4 +
sw/qa/extras/rtfexport/rtfexport4.cxx | 14 +++
sw/source/filter/ww8/rtfexport.cxx | 7 +
sw/source/uibase/app/docst.cxx | 30 ++++++++
sw/source/uibase/app/docstyle.cxx | 2
writerfilter/source/rtftok/rtfdispatchflag.cxx | 3
10 files changed, 196 insertions(+), 35 deletions(-)
New commits:
commit 9dc25ec68f3342f257ac0b0a6ed2f7165473ed3d
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Feb 8 09:46:50 2021 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Feb 10 12:12:02 2021 +0100
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
[ And in this branch, fix a silent merge conflict that mis-positioned
labelGutterMargin in the .ui file. ]
(cherry picked from commit 63d3bf99101e2138a21a74a3d717d4f25d3d242f)
Conflicts:
cui/uiconfig/ui/pageformatpage.ui
sw/source/core/doc/DocumentSettingManager.cxx
Change-Id: I05ef864bf7ac18f4c6829d78312044560e6402d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110671
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/cui/source/inc/page.hxx b/cui/source/inc/page.hxx
index a2d2dcf5dda4..6c7e4ce64d87 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 7a46f0fa2ae5..73a88428ce70 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<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 );
@@ -488,6 +514,8 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet )
m_xGutterMarginLbl->hide();
m_xGutterMarginEdit->hide();
+ m_xGutterPositionFT->hide();
+ m_xGutterPositionLB->hide();
break;
}
@@ -506,6 +534,8 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet )
m_xGutterMarginLbl->hide();
m_xGutterMarginEdit->hide();
+ m_xGutterPositionFT->hide();
+ m_xGutterPositionLB->hide();
break;
}
@@ -540,6 +570,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 );
@@ -625,6 +656,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())
@@ -826,6 +880,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
@@ -1031,10 +1090,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;
+ 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));
+ 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 3e6b46452f25..328eb10e066e 100644
--- a/cui/uiconfig/ui/pageformatpage.ui
+++ b/cui/uiconfig/ui/pageformatpage.ui
@@ -461,39 +461,39 @@
<property name="top_attach">3</property>
</packing>
</child>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="labelGutterMargin">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes" context="pageformatpage|labelGutterMargin">Gutter:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">spinMargBot</property>
- <property name="xalign">0</property>
- <accessibility>
- <relation type="label-for" target="spinMargGut"/>
- </accessibility>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="spinMargGut">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
+ <child>
+ <object class="GtkLabel" id="labelGutterMargin">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="pageformatpage|labelGutterMargin">Gutter:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">spinMargBot</property>
+ <property name="xalign">0</property>
+ <accessibility>
+ <relation type="label-for" target="spinMargGut"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="spinMargGut">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
<property name="activates_default">True</property>
- <property name="truncate_multiline">True</property>
- <accessibility>
- <relation type="labelled-by" target="labelGutterMargin"/>
- </accessibility>
+ <property name="truncate_multiline">True</property>
+ <accessibility>
+ <relation type="labelled-by" target="labelGutterMargin"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">4</property>
- </packing>
</child>
</object>
</child>
@@ -616,6 +616,34 @@
<property name="position">1</property>
</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>
</object>
</child>
</object>
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index cb580785e8a8..b2656c925620 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -88,6 +88,7 @@
#include <paratr.hxx>
#include <tblafmt.hxx>
#include <sfx2/watermarkitem.hxx>
+#include <svl/grabbagitem.hxx>
#include <SwUndoFmt.hxx>
#include <strings.hrc>
@@ -616,6 +617,29 @@ IMPL_LINK_NOARG(ApplyStyle, ApplyHdl, LinkParamNone*, void)
if( aTmpSet.GetItemState( m_rDocSh.GetPool().GetTrueWhich( SID_ATTR_FRAMEDIRECTION, false ) , true, &pItem ) == SfxItemState::SET )
SwChartHelper::DoUpdateAllCharts( pDoc );
}
+
+ if (m_nFamily == SfxStyleFamily::Page)
+ {
+ const SfxPoolItem* pItem = nullptr;
+ if (aTmpSet.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;
+ }
+ bool bOldGutterAtTop
+ = pDoc->getIDocumentSettingAccess().get(DocumentSettingId::GUTTER_AT_TOP);
+ if (bOldGutterAtTop != bGutterAtTop)
+ {
+ pDoc->getIDocumentSettingAccess().set(DocumentSettingId::GUTTER_AT_TOP,
+ bGutterAtTop);
+ pWrtShell->InvalidateLayout(/*bSizeChanged=*/true);
+ }
+ }
+ }
}
if(m_bNew)
@@ -879,6 +903,12 @@ void SwDocShell::Edit(
rSet.Put(SvxHatchListItem(pDrawModel->GetHatchList(), SID_HATCH_LIST));
rSet.Put(SvxBitmapListItem(pDrawModel->GetBitmapList(), SID_BITMAP_LIST));
rSet.Put(SvxPatternListItem(pDrawModel->GetPatternList(), SID_PATTERN_LIST));
+
+ SfxGrabBagItem aGrabBag(SID_ATTR_CHAR_GRABBAG);
+ bool bGutterAtTop
+ = GetDoc()->getIDocumentSettingAccess().get(DocumentSettingId::GUTTER_AT_TOP);
+ aGrabBag.GetGrabBag()["GutterAtTop"] <<= bGutterAtTop;
+ rSet.Put(aGrabBag);
}
if (!bBasic)
diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx
index 040178acac86..b21c1d6d8da5 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -69,6 +69,7 @@
#include <svx/xflftrit.hxx>
#include <svx/svdmodel.hxx>
#include <svx/drawitem.hxx>
+#include <editeng/eeitem.hxx>
// The Format names in the list of all names have the
// following family as their first character:
@@ -482,6 +483,7 @@ SwDocStyleSheet::SwDocStyleSheet( SwDoc& rDocument,
SID_SWREGISTER_MODE, SID_SWREGISTER_MODE,
SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR,
SID_ATTR_NUMBERING_RULE, SID_ATTR_NUMBERING_RULE,
+ SID_ATTR_CHAR_GRABBAG, SID_ATTR_CHAR_GRABBAG,
SID_ATTR_AUTO_STYLE_UPDATE, SID_ATTR_AUTO_STYLE_UPDATE,
FN_PARAM_FTN_INFO, FN_PARAM_FTN_INFO,
FN_COND_COLL, FN_COND_COLL>{}),
commit 4165dd0f8acb3fe95542056f45e861f4a156807a
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Feb 5 17:27:26 2021 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Feb 10 12:11:47 2021 +0100
tdf#91920 sw page gutter margin, from top: add RTF export
The documentation for \gutterprl is "Parallel gutter.", but it seems
that's what Word use to convert between RTF and DOCX's <w:gutterAtTop/>.
(cherry picked from commit faf0635def4ef603563f7288cb29d24e3f2ce1e3)
Change-Id: I06d80f234c6f52950db8a047bfc88910b808977d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110670
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/include/svtools/rtfkeywd.hxx b/include/svtools/rtfkeywd.hxx
index fa297843e6be..bf2eed1f2c5c 100644
--- a/include/svtools/rtfkeywd.hxx
+++ b/include/svtools/rtfkeywd.hxx
@@ -1224,6 +1224,7 @@
#define LO_STRING_SVTOOLS_RTF_SBAUTO "\\sbauto"
#define LO_STRING_SVTOOLS_RTF_SAAUTO "\\saauto"
#define LO_STRING_SVTOOLS_RTF_HTMAUTSP "\\htmautsp"
+#define LO_STRING_SVTOOLS_RTF_GUTTERPRL "\\gutterprl"
#endif // INCLUDED_SVTOOLS_RTFKEYWD_HXX
diff --git a/sw/qa/extras/rtfexport/data/gutter-top.rtf b/sw/qa/extras/rtfexport/data/gutter-top.rtf
new file mode 100644
index 000000000000..9c9a78ce2d03
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/gutter-top.rtf
@@ -0,0 +1,4 @@
+{\rtf1
+\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\gutter720\gutterprl
+\pard\plain Half inch gutter on the top\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx
index a1b5d5e599b8..c5159522f7e9 100644
--- a/sw/qa/extras/rtfexport/rtfexport4.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport4.cxx
@@ -310,6 +310,20 @@ CPPUNIT_TEST_FIXTURE(Test, testGutterLeft)
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), nGutterMargin);
}
+CPPUNIT_TEST_FIXTURE(Test, testGutterTop)
+{
+ load(mpTestDocumentPath, "gutter-top.rtf");
+ reload(mpFilter, "gutter-left.rtf");
+ uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xSettings(
+ xFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY);
+ bool bGutterAtTop{};
+ xSettings->getPropertyValue("GutterAtTop") >>= bGutterAtTop;
+ // Without the accompanying fix in place, this test would have failed, becase the gutter was
+ // at the left.
+ CPPUNIT_ASSERT(bGutterAtTop);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index 81550b420f0f..58457aebda82 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -728,6 +728,13 @@ ErrCode RtfExport::ExportDocument_Impl()
// Mirror margins?
if ((UseOnPage::Mirror & m_pDoc->GetPageDesc(0).ReadUseOn()) == UseOnPage::Mirror)
Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_MARGMIRROR);
+
+ // Gutter at top?
+ if (m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::GUTTER_AT_TOP))
+ {
+ Strm().WriteCharPtr(LO_STRING_SVTOOLS_RTF_GUTTERPRL);
+ }
+
// Init sections
m_pSections = new MSWordSections(*this);
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index 35fe4b381283..a35e4593f2f1 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -1226,6 +1226,9 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_longerSpaceSequence,
new RTFValue(0));
break;
+ case RTF_GUTTERPRL:
+ m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_gutterAtTop, new RTFValue(1));
+ break;
default:
{
SAL_INFO("writerfilter", "TODO handle flag '" << keywordToString(nKeyword) << "'");
More information about the Libreoffice-commits
mailing list