cui/source/inc/page.hxx | 2 + cui/source/tabpages/page.cxx | 24 +++++++++++++++++- cui/uiconfig/ui/pageformatpage.ui | 32 ++++++++++++++++++++++++ sw/qa/extras/rtfexport/data/gutter-left.rtf | 4 +++ sw/qa/extras/rtfexport/rtfexport4.cxx | 15 +++++++++++ sw/source/filter/ww8/rtfattributeoutput.cxx | 5 +++ writerfilter/source/rtftok/rtfdispatchvalue.cxx | 5 +++ 7 files changed, 86 insertions(+), 1 deletion(-)
New commits: commit 3739a08653fbdb2c9268f7386dfccfad052aca82 Author: Miklos Vajna <[email protected]> AuthorDate: Thu Feb 4 14:07:21 2021 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Feb 9 17:08:50 2021 +0100 tdf#91920 sw page gutter margin: add UI Also update the preview widget and hide the new UI in Calc/Impress. (cherry picked from commit e1d7242341ec148b631a96e6d63697bce6a497c9) Change-Id: Ic5c0ba100f6e886651d83c04961e9f0566a4202c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110638 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/cui/source/inc/page.hxx b/cui/source/inc/page.hxx index 1019a9fbc214..a2d2dcf5dda4 100644 --- a/cui/source/inc/page.hxx +++ b/cui/source/inc/page.hxx @@ -106,6 +106,8 @@ private: std::unique_ptr<weld::MetricSpinButton> m_xRightMarginEdit; std::unique_ptr<weld::MetricSpinButton> m_xTopMarginEdit; std::unique_ptr<weld::MetricSpinButton> m_xBottomMarginEdit; + std::unique_ptr<weld::Label> m_xGutterMarginLbl; + std::unique_ptr<weld::MetricSpinButton> m_xGutterMarginEdit; // layout settings std::unique_ptr<weld::Label> m_xPageText; std::unique_ptr<weld::ComboBox> m_xLayoutBox; diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx index 508984bf882b..7a46f0fa2ae5 100644 --- a/cui/source/tabpages/page.cxx +++ b/cui/source/tabpages/page.cxx @@ -162,6 +162,8 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController* , m_xRightMarginEdit(m_xBuilder->weld_metric_spin_button("spinMargRight", FieldUnit::CM)) , m_xTopMarginEdit(m_xBuilder->weld_metric_spin_button("spinMargTop", FieldUnit::CM)) , m_xBottomMarginEdit(m_xBuilder->weld_metric_spin_button("spinMargBot", FieldUnit::CM)) + , m_xGutterMarginLbl(m_xBuilder->weld_label("labelGutterMargin")) + , m_xGutterMarginEdit(m_xBuilder->weld_metric_spin_button("spinMargGut", FieldUnit::CM)) , m_xPageText(m_xBuilder->weld_label("labelPageLayout")) , m_xLayoutBox(m_xBuilder->weld_combo_box("comboPageLayout")) , m_xNumberFormatText(m_xBuilder->weld_label("labelPageNumbers")) @@ -231,6 +233,7 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController* SetFieldUnit( *m_xRightMarginEdit, eFUnit ); SetFieldUnit( *m_xTopMarginEdit, eFUnit ); SetFieldUnit( *m_xBottomMarginEdit, eFUnit ); + SetFieldUnit(*m_xGutterMarginEdit, eFUnit); SetFieldUnit( *m_xPaperWidthEdit, eFUnit ); SetFieldUnit( *m_xPaperHeightEdit, eFUnit ); @@ -281,6 +284,9 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController* m_xRightMarginEdit->set_max(m_xRightMarginEdit->normalize(aDrawinglayerOpt.GetMaximumPaperRightMargin()), FieldUnit::MM); m_xTopMarginEdit->set_max(m_xTopMarginEdit->normalize(aDrawinglayerOpt.GetMaximumPaperTopMargin()), FieldUnit::MM); m_xBottomMarginEdit->set_max(m_xBottomMarginEdit->normalize(aDrawinglayerOpt.GetMaximumPaperBottomMargin()), FieldUnit::MM); + m_xGutterMarginEdit->set_max( + m_xGutterMarginEdit->normalize(aDrawinglayerOpt.GetMaximumPaperLeftMargin()), + FieldUnit::MM); // Get the i18n framework numberings and add them to the listbox. SvxNumOptionsTabPageHelper::GetI18nNumbering(m_xNumberFormatBox->get_widget(), std::numeric_limits<sal_uInt16>::max()); @@ -311,6 +317,7 @@ void SvxPageDescPage::Init_Impl() m_xRightMarginEdit->connect_value_changed(aLink); m_xTopMarginEdit->connect_value_changed(aLink); m_xBottomMarginEdit->connect_value_changed(aLink); + m_xGutterMarginEdit->connect_value_changed(aLink); m_xHorzBox->connect_toggled(LINK(this, SvxPageDescPage, CenterHdl_Impl)); m_xVertBox->connect_toggled(LINK(this, SvxPageDescPage, CenterHdl_Impl)); @@ -329,6 +336,7 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) { const SvxLRSpaceItem& rLRSpace = static_cast<const SvxLRSpaceItem&>(*pItem); SetMetricValue( *m_xLeftMarginEdit, rLRSpace.GetLeft(), eUnit ); + SetMetricValue(*m_xGutterMarginEdit, rLRSpace.GetGutterMargin(), eUnit); m_aBspWin.SetLeft( static_cast<sal_uInt16>(ConvertLong_Impl( rLRSpace.GetLeft(), eUnit )) ); SetMetricValue( *m_xRightMarginEdit, rLRSpace.GetRight(), eUnit ); @@ -478,6 +486,9 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) m_aBspWin.SetHorz(m_xHorzBox->get_active()); m_aBspWin.SetVert(m_xVertBox->get_active()); + m_xGutterMarginLbl->hide(); + m_xGutterMarginEdit->hide(); + break; } @@ -493,6 +504,9 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) m_xLayoutBox->hide(); m_xPageText->hide(); + m_xGutterMarginLbl->hide(); + m_xGutterMarginEdit->hide(); + break; } default: ;//prevent warning @@ -514,6 +528,7 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) m_xRightMarginEdit->save_value(); m_xTopMarginEdit->save_value(); m_xBottomMarginEdit->save_value(); + m_xGutterMarginEdit->save_value(); m_xLayoutBox->save_value(); m_xNumberFormatBox->save_value(); m_xPaperSizeBox->save_value(); @@ -593,6 +608,12 @@ bool SvxPageDescPage::FillItemSet( SfxItemSet* rSet ) bModified = true; } + if (m_xGutterMarginEdit->get_value_changed_from_saved()) + { + aMargin.SetGutterMargin(static_cast<sal_uInt16>(GetCoreValue(*m_xGutterMarginEdit, eUnit))); + bModified = true; + } + // set left and right margins if (bModified) { @@ -1012,7 +1033,8 @@ void SvxPageDescPage::UpdateExample_Impl( bool bResetbackground ) // Margins m_aBspWin.SetTop( GetCoreValue( *m_xTopMarginEdit, MapUnit::MapTwip ) ); m_aBspWin.SetBottom( GetCoreValue( *m_xBottomMarginEdit, MapUnit::MapTwip ) ); - m_aBspWin.SetLeft( GetCoreValue( *m_xLeftMarginEdit, MapUnit::MapTwip ) ); + m_aBspWin.SetLeft(GetCoreValue(*m_xLeftMarginEdit, MapUnit::MapTwip) + + GetCoreValue(*m_xGutterMarginEdit, MapUnit::MapTwip)); m_aBspWin.SetRight( GetCoreValue( *m_xRightMarginEdit, MapUnit::MapTwip ) ); // Layout diff --git a/cui/uiconfig/ui/pageformatpage.ui b/cui/uiconfig/ui/pageformatpage.ui index 0135d61e7457..3e6b46452f25 100644 --- a/cui/uiconfig/ui/pageformatpage.ui +++ b/cui/uiconfig/ui/pageformatpage.ui @@ -463,6 +463,38 @@ </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> + <property name="activates_default">True</property> + <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> </child> <child type="label"> commit 7a55bce5effb2ca89a0a386182a1dbabfac0c889 Author: Miklos Vajna <[email protected]> AuthorDate: Thu Feb 4 09:31:11 2021 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Feb 9 17:08:37 2021 +0100 tdf#91920 sw page gutter margin: add RTF filter Map between \gutter and SvxLRSpaceItem::m_nGutterMargin. (cherry picked from commit 113e7c1be4ca87f936738270cf763800e8ec5832) Change-Id: I40303f87f59d18e04beb016869dc2a8f3c7da755 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110637 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/rtfexport/data/gutter-left.rtf b/sw/qa/extras/rtfexport/data/gutter-left.rtf new file mode 100644 index 000000000000..66016045c9d1 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/gutter-left.rtf @@ -0,0 +1,4 @@ +{\rtf1 +\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\gutter720 +\pard\plain Half in gutter on the left\par +} diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx index fdfdc07c8979..a1b5d5e599b8 100644 --- a/sw/qa/extras/rtfexport/rtfexport4.cxx +++ b/sw/qa/extras/rtfexport/rtfexport4.cxx @@ -295,6 +295,21 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf126309) static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraph(1), "ParaAdjust"))); } +CPPUNIT_TEST_FIXTURE(Test, testGutterLeft) +{ + load(mpTestDocumentPath, "gutter-left.rtf"); + reload(mpFilter, "gutter-left.rtf"); + uno::Reference<beans::XPropertySet> xPageStyle; + getStyles("PageStyles")->getByName("Standard") >>= xPageStyle; + sal_Int32 nGutterMargin{}; + xPageStyle->getPropertyValue("GutterMargin") >>= nGutterMargin; + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1270 + // - Actual : 0 + // i.e. gutter margin was lost. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1270), nGutterMargin); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 9f174bd6d14d..53fffd032a17 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -3152,6 +3152,11 @@ void RtfAttributeOutput::FormatLRSpace(const SvxLRSpaceItem& rLRSpace) m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGRSXN); m_aSectionBreaks.append(static_cast<sal_Int32>(rLRSpace.GetRight())); } + if (rLRSpace.GetGutterMargin()) + { + m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_GUTTER); + m_aSectionBreaks.append(static_cast<sal_Int32>(rLRSpace.GetGutterMargin())); + } if (!m_bBufferSectionBreaks) m_rExport.Strm().WriteOString(m_aSectionBreaks.makeStringAndClear()); } diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx index 7f458bf5ca94..e769eb9deef8 100644 --- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx +++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx @@ -1070,6 +1070,11 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) NS_ooxml::LN_EG_SectPrContents_pgMar, NS_ooxml::LN_CT_PageMar_footer, pIntValue); break; + case RTF_GUTTER: + putNestedAttribute(m_aStates.top().getSectionSprms(), + NS_ooxml::LN_EG_SectPrContents_pgMar, NS_ooxml::LN_CT_PageMar_gutter, + pIntValue); + break; case RTF_DEFTAB: m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_defaultTabStop, pIntValue); break; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
