summaryrefslogtreecommitdiff
path: root/writerfilter/source
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-03-17 15:57:21 +0300
committerMiklos Vajna <vmiklos@collabora.com>2020-03-20 09:15:04 +0100
commit65bea6cbe772ef2ab840d507307396b74e8d031e (patch)
tree3c6dbba593fcdca3d12f449540219abf19139112 /writerfilter/source
parentfaddef755d5fe2a6937bbffa6633e3f8b6260c72 (diff)
tdf#118812 writerfilter: overrideTableStyleFontSizeAndJustification
Surprisingly, there are NO uses of these compatibility options. Apparently we have a lot of work to do... MS Word finally throws away a goofy exception clause that must have caused them countless grief. And LO finally adds support for that goofy clause now that it should rarely be needed... I modified my previous unit test slightly to increase the difficulty level. A fontsize was changed to 11, and justify was added. Change-Id: I0c4997324e8ee745bac8316a45e837c5de137509 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90625 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter/source')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx27
-rw-r--r--writerfilter/source/dmapper/SettingsTable.cxx55
-rw-r--r--writerfilter/source/dmapper/SettingsTable.hxx1
3 files changed, 67 insertions, 16 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 0e5a0cfdfd61..b5a737d626b7 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -19,6 +19,7 @@
#include "DomainMapperTableHandler.hxx"
#include "DomainMapper_Impl.hxx"
#include "StyleSheetTable.hxx"
+#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <com/sun/star/table/TableBorderDistances.hpp>
#include <com/sun/star/table/TableBorder.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
@@ -1119,11 +1120,29 @@ void DomainMapperTableHandler::ApplyParagraphPropertiesFromTableStyle(TableParag
rParaProp.m_rPropertySet->getPropertyValue("ParaStyleName") >>= sParaStyleName;
StyleSheetEntryPtr pEntry = m_rDMapper_Impl.GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(sParaStyleName);
uno::Any aParaStyle = m_rDMapper_Impl.GetPropertyFromStyleSheet(eId, pEntry, true, true, &bDocDefault);
+ // A very strange compatibility rule says that the DEFAULT style's specified fontsize of 11 or 12
+ // or a specified left justify will always be overridden by the table-style.
+ // Normally this rule is applied, so always do this unless a compatSetting indicates otherwise.
+ bool bCompatOverride = false;
+ if ( (eId == PROP_CHAR_HEIGHT || eId == PROP_PARA_ADJUST) && sParaStyleName == m_rDMapper_Impl.GetDefaultParaStyleName() )
+ {
+ if ( eId == PROP_CHAR_HEIGHT )
+ bCompatOverride = aParaStyle == uno::Any(double(11)) || aParaStyle == uno::Any(double(12));
+ else if ( eId == PROP_PARA_ADJUST )
+ {
+ style::ParagraphAdjust eAdjust(style::ParagraphAdjust_CENTER);
+ aParaStyle >>= eAdjust;
+ bCompatOverride = eAdjust == style::ParagraphAdjust_LEFT;
+ }
+
+ // The wording is confusing here. Normally, the paragraph style DOES override the table-style.
+ // But for these two special situations, do not override the table-style. So the default is false.
+ // If false, then "CompatOverride" the normal behaviour, and apply the table-style's value.
+ bCompatOverride &= !m_rDMapper_Impl.GetSettingsTable()->GetCompatSettingValue("overrideTableStyleFontSizeAndJustification");
+ }
+
// use table style when no paragraph style setting or a docDefault value is applied instead of it
- if ( aParaStyle == uno::Any() || bDocDefault ||
- // set default behaviour of MSO ("overrideTableStyleFontSizeAndJustification" exception):
- // if Normal style defines 11 pt or 12 pt font heights, table style overrides its font size
- (eId == PROP_CHAR_HEIGHT && sParaStyleName == "Standard" && (aParaStyle == uno::Any(double(11)) || aParaStyle == uno::Any(double(12))))) try
+ if ( aParaStyle == uno::Any() || bDocDefault || bCompatOverride ) try
{
// check property state of paragraph
uno::Reference<text::XParagraphCursor> xParagraph(
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx
index 824c627f436c..e8a921ff0934 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -767,6 +767,36 @@ void SettingsTable::ApplyProperties(uno::Reference<text::XTextDocument> const& x
}
}
+bool SettingsTable::GetCompatSettingValue( const OUString& sCompatName ) const
+{
+ bool bRet = false;
+ for (const auto& rProp : m_pImpl->m_aCompatSettings)
+ {
+ if (rProp.Name == "compatSetting") //always true
+ {
+ css::uno::Sequence<css::beans::PropertyValue> aCurrentCompatSettings;
+ rProp.Value >>= aCurrentCompatSettings;
+
+ OUString sName;
+ aCurrentCompatSettings[0].Value >>= sName;
+ if ( sName != sCompatName )
+ continue;
+
+ OUString sUri;
+ aCurrentCompatSettings[1].Value >>= sUri;
+ if ( sUri != "http://schemas.microsoft.com/office/word" )
+ continue;
+
+ OUString sVal;
+ aCurrentCompatSettings[2].Value >>= sVal;
+ // if repeated, what happens? Last one wins
+ bRet = sVal.toBoolean();
+ }
+ }
+
+ return bRet;
+}
+
//Keep this function in-sync with the one in sw/.../docxattributeoutput.cxx
sal_Int32 SettingsTable::GetWordCompatibilityMode() const
{
@@ -775,26 +805,27 @@ sal_Int32 SettingsTable::GetWordCompatibilityMode() const
for (const auto& rProp : m_pImpl->m_aCompatSettings)
{
- if (rProp.Name == "compatSetting")
+ if (rProp.Name == "compatSetting") //always true
{
css::uno::Sequence<css::beans::PropertyValue> aCurrentCompatSettings;
rProp.Value >>= aCurrentCompatSettings;
OUString sName;
- OUString sUri;
- OUString sVal;
-
aCurrentCompatSettings[0].Value >>= sName;
+ if ( sName != "compatibilityMode" )
+ continue;
+
+ OUString sUri;
aCurrentCompatSettings[1].Value >>= sUri;
- aCurrentCompatSettings[2].Value >>= sVal;
+ if ( sUri != "http://schemas.microsoft.com/office/word" )
+ continue;
- if (sName == "compatibilityMode" && sUri == "http://schemas.microsoft.com/office/word")
- {
- const sal_Int32 nValidMode = sVal.toInt32();
- // if repeated, highest mode wins in MS Word. 11 is the first valid mode.
- if ( nValidMode > 10 && nValidMode > m_pImpl->m_nWordCompatibilityMode )
- m_pImpl->m_nWordCompatibilityMode = nValidMode;
- }
+ OUString sVal;
+ aCurrentCompatSettings[2].Value >>= sVal;
+ const sal_Int32 nValidMode = sVal.toInt32();
+ // if repeated, highest mode wins in MS Word. 11 is the first valid mode.
+ if ( nValidMode > 10 && nValidMode > m_pImpl->m_nWordCompatibilityMode )
+ m_pImpl->m_nWordCompatibilityMode = nValidMode;
}
}
diff --git a/writerfilter/source/dmapper/SettingsTable.hxx b/writerfilter/source/dmapper/SettingsTable.hxx
index d8473e423041..3489cf0ac34b 100644
--- a/writerfilter/source/dmapper/SettingsTable.hxx
+++ b/writerfilter/source/dmapper/SettingsTable.hxx
@@ -87,6 +87,7 @@ class SettingsTable : public LoggedProperties, public LoggedTable
void ApplyProperties(css::uno::Reference<css::text::XTextDocument> const& xDoc);
+ bool GetCompatSettingValue( const OUString& sCompatName ) const;
sal_Int32 GetWordCompatibilityMode() const;
const OUString & GetCurrentDatabaseDataSource() const;