summaryrefslogtreecommitdiff
path: root/svx/source/svdraw/svdmodel.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2016-06-28 19:13:22 +1000
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-06-28 17:27:28 +0000
commit0cb200d000fad8ba31c7400e08cd031823f27308 (patch)
treecfe441bb41ad09c86bc60d4cbe18d83982c0bf90 /svx/source/svdraw/svdmodel.cxx
parentc1ab6613ae7b45f2d90aafd6c6a829a471ceca55 (diff)
tdf#99729: fix text alignment (no autofit & no full width)
If TextBox contained text that is larger than the box, and autofit was off, and autosize was off, and full width was off, then text always aligned to box's left top corner, regardless of text anchor setting. Related problem (i103454) was fixed in 2009 by Armin Le Grand, but only for full width text. This patch extends the scope of that fix to correctly process other cases. The fix introduces a new compatibility flag: AnchoredTextOverflowLegacy If it is true, then old behaviour is retained. It is always false for new documents and imported documents. When opening existing ODF documents, it's true by default, unless it is explicitly set in settings.xml. Unfortunately, I couldn't find a way to access the document model from any of SfxBaseModel::load() or SfxObjectShell::DoLoad, where it could enable setting the compatibility flag universally when loading own format. Instead, I had to do it individually in each of SfxObjectShell::Load() implementations. Unit test is included. Change-Id: Ifad79d546739daafff59fb6c7fb0dce51babc53d Reviewed-on: https://gerrit.libreoffice.org/26737 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'svx/source/svdraw/svdmodel.cxx')
-rw-r--r--svx/source/svdraw/svdmodel.cxx33
1 files changed, 29 insertions, 4 deletions
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 5c662896f6f1..8d970297d779 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -103,6 +103,8 @@ struct SdrModelImpl
{
SfxUndoManager* mpUndoManager;
SdrUndoFactory* mpUndoFactory;
+
+ bool mbAnchoredTextOverflowLegacy; // tdf#99729 compatibility flag
};
@@ -112,6 +114,7 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe
mpImpl.reset(new SdrModelImpl);
mpImpl->mpUndoManager=nullptr;
mpImpl->mpUndoFactory=nullptr;
+ mpImpl->mbAnchoredTextOverflowLegacy = false;
mbInDestruction = false;
aObjUnit=SdrEngineDefaults::GetMapFraction();
eObjUnit=SdrEngineDefaults::GetMapUnit();
@@ -1886,6 +1889,16 @@ void SdrModel::SetAddExtLeading( bool bEnabled )
}
}
+void SdrModel::SetAnchoredTextOverflowLegacy(bool bEnabled)
+{
+ mpImpl->mbAnchoredTextOverflowLegacy = bEnabled;
+}
+
+bool SdrModel::IsAnchoredTextOverflowLegacy() const
+{
+ return mpImpl->mbAnchoredTextOverflowLegacy;
+}
+
void SdrModel::ReformatAllTextObjects()
{
ImpReformatAllTextObjects();
@@ -1925,16 +1938,28 @@ SvxNumType SdrModel::GetPageNumType() const
return SVX_ARABIC;
}
-void SdrModel::ReadUserDataSequenceValue(const css::beans::PropertyValue* /*pValue*/)
+void SdrModel::ReadUserDataSequenceValue(const css::beans::PropertyValue* pValue)
+{
+ bool bBool = false;
+ if (pValue->Name == "AnchoredTextOverflowLegacy")
+ {
+ if (pValue->Value >>= bBool)
+ {
+ mpImpl->mbAnchoredTextOverflowLegacy = bBool;
+ }
+ }
+}
+
+template <typename T>
+inline void addPair(std::vector< std::pair< OUString, Any > >& aUserData, const OUString& name, const T val)
{
- (void) this; // TODO: Read common model-level values
+ aUserData.push_back(std::pair< OUString, Any >(name, css::uno::makeAny(val)));
}
void SdrModel::WriteUserDataSequence(css::uno::Sequence < css::beans::PropertyValue >& rValues, bool /*bBrowse*/)
{
std::vector< std::pair< OUString, Any > > aUserData;
- (void) this;
- // TODO: Write common model-level properties (e.g. to settings.xml)
+ addPair(aUserData, "AnchoredTextOverflowLegacy", IsAnchoredTextOverflowLegacy());
const sal_Int32 nOldLength = rValues.getLength();
rValues.realloc(nOldLength + aUserData.size());