include/svx/compatflags.hxx                             |   18 ++++
 include/svx/svdmodel.hxx                                |   15 +---
 sc/source/ui/docshell/docsh.cxx                         |   14 ++-
 sd/source/ui/docshell/docshel4.cxx                      |    9 +-
 svx/source/customshapes/EnhancedCustomShapeFontWork.cxx |    4 -
 svx/source/svdraw/svdmodel.cxx                          |   59 ++++++++--------
 svx/source/svdraw/svdoedge.cxx                          |    5 -
 svx/source/svdraw/svdotextdecomposition.cxx             |    5 -
 sw/source/uibase/app/docshini.cxx                       |    7 +
 9 files changed, 82 insertions(+), 54 deletions(-)

New commits:
commit 19622bf3749531bb66cd190c11ebfdca70b034db
Author:     Sarper Akdemir <sarper.akde...@collabora.com>
AuthorDate: Tue Feb 21 02:33:01 2023 +0300
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Sun Mar 12 21:43:32 2023 +0000

    related tdf#148966: rework sdr compatibility flags
    
    Rework access/set methods for sdr compatibility flags so it
    is possible to address a compatibility flag without directly
    interfacing with SdrModel.
    
    (preliminary work for exposing compatibility flags to
    editeng)
    
    Change-Id: I2fab219f9e125151916228300be2d9d88156d8a6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147407
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148315
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>
    Tested-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/include/svx/compatflags.hxx b/include/svx/compatflags.hxx
new file mode 100644
index 000000000000..6a53c756ebd8
--- /dev/null
+++ b/include/svx/compatflags.hxx
@@ -0,0 +1,18 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+/// SdrCompatibilityFlags that are implemented in SdrModelImpl
+enum class SdrCompatibilityFlag
+{
+    AnchoredTextOverflowLegacy, ///< for tdf#99729
+    LegacySingleLineFontwork, ///< for tdf#148000
+    ConnectorUseSnapRect, ///< for tdf#149756
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index 1617942c848d..d87c9def5893 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -77,6 +77,7 @@ class SdrUndoFactory;
 class ImageMap;
 class TextChain;
 enum class CharCompressType;
+enum class SdrCompatibilityFlag;
 namespace comphelper
 {
     class IEmbeddedHelper;
@@ -571,17 +572,9 @@ public:
     void SetAddExtLeading( bool bEnabled );
     bool IsAddExtLeading() const { return mbAddExtLeading; }
 
-    // tdf#99729 compatibility flag
-    void SetAnchoredTextOverflowLegacy(bool bEnabled);
-    bool IsAnchoredTextOverflowLegacy() const;
-
-    // tdf#148000 compatibility flag
-    void SetLegacySingleLineFontwork(bool bEnabled);
-    bool IsLegacySingleLineFontwork() const;
-
-    // tdf#149756 compatibility flag
-    void SetConnectorUseSnapRect(bool bEnabled);
-    bool IsConnectorUseSnapRect() const;
+    void SetCompatibilityFlag(SdrCompatibilityFlag eFlag, bool bEnabled);
+    /// @returns state of the SdrCompatibilityFlag
+    bool GetCompatibilityFlag(SdrCompatibilityFlag eFlag) const;
 
     void ReformatAllTextObjects();
 
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 9a5b5968d9ec..f049f3c55b38 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -77,6 +77,7 @@
 
 #include <scabstdlg.hxx>
 #include <sot/formats.hxx>
+#include <svx/compatflags.hxx>
 #include <svx/dialogs.hrc>
 
 #include <formulacell.hxx>
@@ -585,13 +586,16 @@ bool ScDocShell::Load( SfxMedium& rMedium )
     InitOptions(true);
 
     // If this is an ODF file being loaded, then by default, use legacy 
processing
-    // for tdf#99729 (if required, it will be overridden in 
*::ReadUserDataSequence())
+    // (if required, it will be overridden in *::ReadUserDataSequence())
     if (IsOwnStorageFormat(rMedium))
     {
-        if (m_pDocument->GetDrawLayer())
-            m_pDocument->GetDrawLayer()->SetAnchoredTextOverflowLegacy(true);
-        if (m_pDocument->GetDrawLayer())
-            m_pDocument->GetDrawLayer()->SetLegacySingleLineFontwork(true); 
//for tdf#148000
+        if (ScDrawLayer* pDrawLayer = m_pDocument->GetDrawLayer())
+        {
+            
pDrawLayer->SetCompatibilityFlag(SdrCompatibilityFlag::AnchoredTextOverflowLegacy,
+                                             true); // for tdf#99729
+            
pDrawLayer->SetCompatibilityFlag(SdrCompatibilityFlag::LegacySingleLineFontwork,
+                                             true); // for tdf#148000
+        }
     }
 
     GetUndoManager()->Clear();
diff --git a/sd/source/ui/docshell/docshel4.cxx 
b/sd/source/ui/docshell/docshel4.cxx
index afe322d7a959..2c1b87f9979c 100644
--- a/sd/source/ui/docshell/docshel4.cxx
+++ b/sd/source/ui/docshell/docshel4.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
 #include <editeng/outlobj.hxx>
 #include <tools/urlobj.hxx>
+#include <svx/compatflags.hxx>
 #include <svx/svxids.hrc>
 #include <editeng/editeng.hxx>
 #include <editeng/editstat.hxx>
@@ -265,11 +266,11 @@ bool DrawDocShell::InitNew( const css::uno::Reference< 
css::embed::XStorage >& x
 bool DrawDocShell::Load( SfxMedium& rMedium )
 {
     // If this is an ODF file being loaded, then by default, use legacy 
processing
-    // for tdf#99729 (if required, it will be overridden in 
*::ReadUserDataSequence())
+    // (if required, it will be overridden in *::ReadUserDataSequence())
     if (IsOwnStorageFormat(rMedium))
     {
-        mpDoc->SetAnchoredTextOverflowLegacy(true);
-        mpDoc->SetLegacySingleLineFontwork(true); //for tdf#148000
+        
mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::AnchoredTextOverflowLegacy, 
true); // for tdf#99729
+        
mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::LegacySingleLineFontwork, 
true); // for tdf#148000
     }
 
     bool       bRet = false;
@@ -407,7 +408,7 @@ bool DrawDocShell::ImportFrom(SfxMedium &rMedium,
         // This is a "MS Compact" mode for connectors.
         // The Libreoffice uses bounding rectangle of connected shapes but
         // MSO uses snap rectangle when calculate the edge track.
-        mpDoc->SetConnectorUseSnapRect(true);
+        
mpDoc->SetCompatibilityFlag(SdrCompatibilityFlag::ConnectorUseSnapRect, true);
     }
 
     if (aFilterName == "Impress MS PowerPoint 2007 XML" ||
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx 
b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
index 672cd28fbc8e..648e5cfa56f3 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -19,6 +19,7 @@
 
 #include "EnhancedCustomShapeFontWork.hxx"
 #include <svl/itemset.hxx>
+#include <svx/compatflags.hxx>
 #include <svx/svddef.hxx>
 #include <svx/svdopath.hxx>
 #include <vcl/kernarray.hxx>
@@ -133,7 +134,8 @@ static bool InitializeFontWorkData(
                 do
                 {
                     // search line break.
-                    if 
(!rSdrObjCustomShape.getSdrModelFromSdrObject().IsLegacySingleLineFontwork())
+                    if 
(!rSdrObjCustomShape.getSdrModelFromSdrObject().GetCompatibilityFlag(
+                            SdrCompatibilityFlag::LegacySingleLineFontwork))
                         nPos = aParaText[nPara].indexOf(sal_Unicode(u'\1'), 
nPrevPos);
                     else
                         nPos = -1; // tdf#148000: ignore line breaks in legacy 
fontworks
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index c286e0c76f24..7b72fad64c66 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -29,6 +29,7 @@
 #include <unotools/pathoptions.hxx>
 #include <svl/whiter.hxx>
 #include <svl/asiancfg.hxx>
+#include <svx/compatflags.hxx>
 #include <svx/xbtmpit.hxx>
 #include <svx/xlndsit.hxx>
 #include <svx/xlnedit.hxx>
@@ -1715,34 +1716,35 @@ void SdrModel::SetAddExtLeading( bool bEnabled )
     }
 }
 
-void SdrModel::SetAnchoredTextOverflowLegacy(bool bEnabled)
+void SdrModel::SetCompatibilityFlag(SdrCompatibilityFlag eFlag, bool bEnabled)
 {
-    mpImpl->mbAnchoredTextOverflowLegacy = bEnabled;
-}
-
-bool SdrModel::IsAnchoredTextOverflowLegacy() const
-{
-    return mpImpl->mbAnchoredTextOverflowLegacy;
-}
-
-void SdrModel::SetLegacySingleLineFontwork(bool bEnabled)
-{
-    mpImpl->mbLegacySingleLineFontwork = bEnabled;
-}
-
-bool SdrModel::IsLegacySingleLineFontwork() const
-{
-    return mpImpl->mbLegacySingleLineFontwork;
-}
-
-void SdrModel::SetConnectorUseSnapRect(bool bEnabled)
-{
-    mpImpl->mbConnectorUseSnapRect = bEnabled;
+    switch (eFlag)
+    {
+        case SdrCompatibilityFlag::AnchoredTextOverflowLegacy:
+            mpImpl->mbAnchoredTextOverflowLegacy = bEnabled;
+            break;
+        case SdrCompatibilityFlag::LegacySingleLineFontwork:
+            mpImpl->mbLegacySingleLineFontwork = bEnabled;
+            break;
+        case SdrCompatibilityFlag::ConnectorUseSnapRect:
+            mpImpl->mbConnectorUseSnapRect = bEnabled;
+            break;
+    }
 }
 
-bool SdrModel::IsConnectorUseSnapRect() const
+bool SdrModel::GetCompatibilityFlag(SdrCompatibilityFlag eFlag) const
 {
-    return mpImpl->mbConnectorUseSnapRect;
+    switch (eFlag)
+    {
+        case SdrCompatibilityFlag::AnchoredTextOverflowLegacy:
+            return mpImpl->mbAnchoredTextOverflowLegacy;
+        case SdrCompatibilityFlag::LegacySingleLineFontwork:
+            return mpImpl->mbLegacySingleLineFontwork;
+        case SdrCompatibilityFlag::ConnectorUseSnapRect:
+            return mpImpl->mbConnectorUseSnapRect;
+        default:
+            return false;
+    }
 }
 
 void SdrModel::ReformatAllTextObjects()
@@ -1833,9 +1835,12 @@ static void addPair(std::vector< std::pair< OUString, 
uno::Any > >& aUserData, c
 void SdrModel::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& 
rValues)
 {
     std::vector< std::pair< OUString, uno::Any > > aUserData;
-    addPair(aUserData, "AnchoredTextOverflowLegacy", 
IsAnchoredTextOverflowLegacy());
-    addPair(aUserData, "LegacySingleLineFontwork", 
IsLegacySingleLineFontwork());
-    addPair(aUserData, "ConnectorUseSnapRect", IsConnectorUseSnapRect());
+    addPair(aUserData, "AnchoredTextOverflowLegacy",
+            
GetCompatibilityFlag(SdrCompatibilityFlag::AnchoredTextOverflowLegacy));
+    addPair(aUserData, "LegacySingleLineFontwork",
+            
GetCompatibilityFlag(SdrCompatibilityFlag::LegacySingleLineFontwork));
+    addPair(aUserData, "ConnectorUseSnapRect",
+            GetCompatibilityFlag(SdrCompatibilityFlag::ConnectorUseSnapRect));
 
     const sal_Int32 nOldLength = rValues.getLength();
     rValues.realloc(nOldLength + aUserData.size());
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
index 15d507679789..20cec97a77b5 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -27,6 +27,7 @@
 
 #include <sdr/contact/viewcontactofsdredgeobj.hxx>
 #include <sdr/properties/connectorproperties.hxx>
+#include <svx/compatflags.hxx>
 #include <svx/sdrhittesthelper.hxx>
 #include <svx/svddrag.hxx>
 #include <svx/svddrgmt.hxx>
@@ -753,7 +754,7 @@ XPolygon SdrEdgeObj::ImpCalcEdgeTrack(const XPolygon& 
rTrack0, SdrObjConnection&
         }
         else
         {
-            if (getSdrModelFromSdrObject().IsConnectorUseSnapRect())
+            if 
(getSdrModelFromSdrObject().GetCompatibilityFlag(SdrCompatibilityFlag::ConnectorUseSnapRect))
                 aBoundRect1 = rCon1.pObj->GetSnapRect();
             else
                 aBoundRect1 = rCon1.pObj->GetCurrentBoundRect();
@@ -783,7 +784,7 @@ XPolygon SdrEdgeObj::ImpCalcEdgeTrack(const XPolygon& 
rTrack0, SdrObjConnection&
         }
         else
         {
-            if (getSdrModelFromSdrObject().IsConnectorUseSnapRect())
+            if 
(getSdrModelFromSdrObject().GetCompatibilityFlag(SdrCompatibilityFlag::ConnectorUseSnapRect))
                 aBoundRect2 = rCon2.pObj->GetSnapRect();
             else
                 aBoundRect2 = rCon2.pObj->GetCurrentBoundRect();
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx 
b/svx/source/svdraw/svdotextdecomposition.cxx
index e526c44edc68..ad6edb104e01 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -17,7 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
+#include <svx/compatflags.hxx>
 #include <svx/svdetc.hxx>
 #include <svx/svdoutl.hxx>
 #include <svx/svdpage.hxx>
@@ -1021,7 +1021,8 @@ void SdrTextObj::impDecomposeBlockTextPrimitive(
             bool bAllowGrowHorizontal = bVerticalWriting;
 
             // Compatibility mode for tdf#99729
-            if (getSdrModelFromSdrObject().IsAnchoredTextOverflowLegacy())
+            if (getSdrModelFromSdrObject().GetCompatibilityFlag(
+                    SdrCompatibilityFlag::AnchoredTextOverflowLegacy))
             {
                 bAllowGrowVertical = bHorizontalIsBlock;
                 bAllowGrowHorizontal = bVerticalIsBlock;
diff --git a/sw/source/uibase/app/docshini.cxx 
b/sw/source/uibase/app/docshini.cxx
index 72e630ac02b2..5c629ebd3d54 100644
--- a/sw/source/uibase/app/docshini.cxx
+++ b/sw/source/uibase/app/docshini.cxx
@@ -35,6 +35,7 @@
 #include <editeng/autokernitem.hxx>
 #include <com/sun/star/document/UpdateDocMode.hpp>
 #include <com/sun/star/i18n/ScriptType.hpp>
+#include <svx/compatflags.hxx>
 #include <svx/svxids.hrc>
 #include <editeng/fhgtitem.hxx>
 #include <editeng/fontitem.hxx>
@@ -479,8 +480,10 @@ bool  SwDocShell::Load( SfxMedium& rMedium )
             SwDrawModel* pDrawModel = 
m_xDoc->getIDocumentDrawModelAccess().GetDrawModel();
             if (pDrawModel)
             {
-                pDrawModel->SetAnchoredTextOverflowLegacy(true); // legacy 
processing for tdf#99729
-                pDrawModel->SetLegacySingleLineFontwork(true); // legacy 
processing for tdf#148000
+                
pDrawModel->SetCompatibilityFlag(SdrCompatibilityFlag::AnchoredTextOverflowLegacy,
+                                                 true); // legacy processing 
for tdf#99729
+                
pDrawModel->SetCompatibilityFlag(SdrCompatibilityFlag::LegacySingleLineFontwork,
+                                                 true); // legacy processing 
for tdf#148000
             }
         }
 

Reply via email to