[Libreoffice-commits] core.git: sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 8 06:44:45 UTC 2021


 sw/source/uibase/utlui/uitool.cxx |   35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

New commits:
commit 46cc1c79485f81f2e657c226de44d68cec752e6f
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Jun 7 21:18:46 2021 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Jun 8 08:44:07 2021 +0200

    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 at collabora.com>

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);
 }
 


More information about the Libreoffice-commits mailing list