summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-06-07 21:18:46 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-06-08 08:44:07 +0200
commit46cc1c79485f81f2e657c226de44d68cec752e6f (patch)
tree13b8cef05cba1781d13fd10825b216b624e19c3b
parent2881b2fa25bfe1933857738b0b551ebb6c687bdc (diff)
tdf#141805 sw: hide rtl gutter UI for ODF documents
ODF doesn't track RTLness of the gutter explicitly, it infers this setting from the writing direction. This means that in case the UI is used to set it explicitly to a custom value, it'll be lost after export + import. Fix the problem by hiding the widget in the ODF case, so it doesn't confuse users; it's still visible for Word formats which store this explicitly. Change-Id: I1316dcf461429af72498957c9b3eebcbdac794bb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116799 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sw/source/uibase/utlui/uitool.cxx35
1 files changed, 32 insertions, 3 deletions
diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx
index b971dc95bb2c..7f6432dbbf1d 100644
--- a/sw/source/uibase/utlui/uitool.cxx
+++ b/sw/source/uibase/utlui/uitool.cxx
@@ -43,6 +43,8 @@
#include <com/sun/star/util/XURLTransformer.hpp>
#include <comphelper/processfactory.hxx>
#include <sfx2/viewfrm.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
#include <fmtornt.hxx>
#include <tabcol.hxx>
#include <fmtfsize.hxx>
@@ -282,7 +284,8 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc )
{
rMaster.SetFormatAttr(SfxBoolItem(RES_BACKGROUND_FULL_SIZE, bValue));
}
- if (pGrabBag->GetGrabBag().find("RtlGutter")->second >>= bValue)
+ auto it = pGrabBag->GetGrabBag().find("RtlGutter");
+ if (it != pGrabBag->GetGrabBag().end() && (it->second >>= bValue))
{
rMaster.SetFormatAttr(SfxBoolItem(RES_RTL_GUTTER, bValue));
}
@@ -425,6 +428,27 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc )
}
}
+namespace
+{
+bool IsOwnFormat(const SwDoc& rDoc)
+{
+ const SwDocShell* pDocShell = rDoc.GetDocShell();
+ SfxMedium* pMedium = pDocShell->GetMedium();
+ if (!pMedium)
+ {
+ return false;
+ }
+
+ std::shared_ptr<const SfxFilter> pFilter = pMedium->GetFilter();
+ if (!pFilter)
+ {
+ return false;
+ }
+
+ return pFilter->IsOwnFormat();
+}
+}
+
void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet)
{
const SwFrameFormat& rMaster = rPageDesc.GetMaster();
@@ -597,8 +621,13 @@ void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet)
}
oGrabBag->GetGrabBag()["BackgroundFullSize"] <<=
rMaster.GetAttrSet().GetItem<SfxBoolItem>(RES_BACKGROUND_FULL_SIZE)->GetValue();
- oGrabBag->GetGrabBag()["RtlGutter"] <<=
- rMaster.GetAttrSet().GetItem<SfxBoolItem>(RES_RTL_GUTTER)->GetValue();
+
+ if (IsOwnFormat(*rMaster.GetDoc()))
+ {
+ oGrabBag->GetGrabBag()["RtlGutter"]
+ <<= rMaster.GetAttrSet().GetItem<SfxBoolItem>(RES_RTL_GUTTER)->GetValue();
+ }
+
rSet.Put(*oGrabBag);
}