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 <vmiklos@collabora.com>
diff --git a/include/svx/compatflags.hxx b/include/svx/compatflags.hxx
new file mode 100644
index 0000000..6a53c75
--- /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 6d130df..63cc3bc 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;
@@ -566,17 +567,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 4bf9343..f5fad1f 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>
@@ -584,13 +585,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 aeac2a5..058e57e 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 f0e5697..d40d22e 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 99a18c9..8862522 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>
@@ -1690,34 +1691,35 @@ void SdrModel::SetAddExtLeading( bool bEnabled )
}
}
void SdrModel::SetAnchoredTextOverflowLegacy(bool bEnabled)
void SdrModel::SetCompatibilityFlag(SdrCompatibilityFlag eFlag, bool bEnabled)
{
mpImpl->mbAnchoredTextOverflowLegacy = 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::IsAnchoredTextOverflowLegacy() const
bool SdrModel::GetCompatibilityFlag(SdrCompatibilityFlag eFlag) 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;
}
bool SdrModel::IsConnectorUseSnapRect() 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()
@@ -1808,9 +1810,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 15d5076..20cec97 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 e526c44..ad6edb1 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 72e630ac..5c629eb 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
}
}