summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-03-12 20:13:53 +0300
committerMiklos Vajna <vmiklos@collabora.com>2020-03-13 09:59:00 +0100
commit6bc01f234de9a3c5abc00253fed8dc691320fd3b (patch)
treefbd2397a071be2f7ebd9db3dac5eceacd159ecdd /sw
parent7ba168173addd286fef11c0d5634fb3a1eb73fee (diff)
tdf#131304 writerfilter: cache Word compatibilityMode
GetWordCompatibilityMode() is an expensive call that is called at least for every table row. Caching will soon be even more beneficial when LO also starts writing out this value and thus quickly caches a non-negative result. Anything created by MS Word since at least 2010 specifies this optional setting, so most .docx files specify this value - and thus will benefit from the cache. One difference that I ignored is that Word replaces a "number greater than what I know" with its own compatibilityMode value. (tested in Word 2010 and 2016.) That is probably only a concern at export time anyway... Change-Id: I0ee71d34150c5f3d9858adb678814a10c7fe8959 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90434 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index dc840a227e38..1810a8d595f7 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3721,11 +3721,13 @@ OString lcl_padStartToLength(OString const & aString, sal_Int32 nLen, char cFill
return aString;
}
+//Keep this function in-sync with the one in writerfilter/.../SettingsTable.cxx
sal_Int32 lcl_getWordCompatibilityMode( const SwDoc& rDoc )
{
uno::Reference< beans::XPropertySet > xPropSet( rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
+ sal_Int32 nWordCompatibilityMode = -1;
if ( xPropSetInfo->hasPropertyByName( UNO_NAME_MISC_OBJ_INTEROPGRABBAG ) )
{
uno::Sequence< beans::PropertyValue > propList;
@@ -3756,14 +3758,18 @@ sal_Int32 lcl_getWordCompatibilityMode( const SwDoc& rDoc )
if ( sName == "compatibilityMode" && sUri == "http://schemas.microsoft.com/office/word" )
{
- return sVal.toInt32();
+ const sal_Int32 nValidMode = sVal.toInt32();
+ // if repeated, highest mode wins in MS Word. 11 is the first valid mode.
+ if ( nValidMode > 10 && nValidMode > nWordCompatibilityMode )
+ nWordCompatibilityMode = nValidMode;
+
}
}
}
}
}
- return -1; // Word compatibility mode not found
+ return nWordCompatibilityMode;
}
}