diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-07-14 19:50:18 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-07-16 18:48:46 +0200 |
commit | 86c0f58b6f9f392865196606173d1b98a6897f32 (patch) | |
tree | 740c02474529d6a4c7cb4b52e234068c1b28c227 /xmloff/source/text/txtstyli.cxx | |
parent | 4461e14d08c7d1c1c43b136a5a8e3acb868c0b51 (diff) |
tdf#92796 ODF import: remove unused bitmap fills
With CWS impress64 a partial fix for this was implemented to drop
unreferenced named items including all non-color fills after ODF import,
but this is only done in sd so move the code that does that to svx and
call it from sc and sw as well.
Implement some UNO interface for this, it's at least better than a magic
string, and not obvious how a better solution would look like since it's
known only at the end of the import if a bitmap is used or not.
Another problem: when the Area tab is used to change to a different kind
of fill, the items with the details for the previous fill aren't
cleared, and so they are written to ODF files. Hence bitmaps in the
file can be referenced even if they aren't actually used, and bloat up
the files.
Fix this by dropping all unused draw:fill-image-name attributes in ODF
import.
Also do the same for Gradient and Hatch fills; Transparency gradients
can be combined with anything so leave them as they are.
Change-Id: I0b591fd9f963d974d0c3e7208b99621ad61dd93c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118950
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'xmloff/source/text/txtstyli.cxx')
-rw-r--r-- | xmloff/source/text/txtstyli.cxx | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/xmloff/source/text/txtstyli.cxx b/xmloff/source/text/txtstyli.cxx index 701136e98fb2..5aa600c25c00 100644 --- a/xmloff/source/text/txtstyli.cxx +++ b/xmloff/source/text/txtstyli.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/document/XEventsSupplier.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/style/ParagraphStyleCategory.hpp> @@ -380,21 +381,21 @@ void XMLTextStyleContext::FillPropertySet( // intelligent solution. struct ContextID_Index_Pair aContextIDs[] = { - { CTF_COMBINED_CHARACTERS_FIELD, -1 }, - { CTF_KEEP_TOGETHER, -1 }, - { CTF_BORDER_MODEL, -1 }, - { CTF_TEXT_DISPLAY, -1 }, - { CTF_FONTFAMILYNAME, -1 }, - { CTF_FONTFAMILYNAME_CJK, -1 }, - { CTF_FONTFAMILYNAME_CTL, -1 }, + { CTF_COMBINED_CHARACTERS_FIELD, -1, drawing::FillStyle::FillStyle_MAKE_FIXED_SIZE }, + { CTF_KEEP_TOGETHER, -1, drawing::FillStyle::FillStyle_MAKE_FIXED_SIZE }, + { CTF_BORDER_MODEL, -1, drawing::FillStyle::FillStyle_MAKE_FIXED_SIZE }, + { CTF_TEXT_DISPLAY, -1, drawing::FillStyle::FillStyle_MAKE_FIXED_SIZE }, + { CTF_FONTFAMILYNAME, -1, drawing::FillStyle::FillStyle_MAKE_FIXED_SIZE }, + { CTF_FONTFAMILYNAME_CJK, -1, drawing::FillStyle::FillStyle_MAKE_FIXED_SIZE }, + { CTF_FONTFAMILYNAME_CTL, -1, drawing::FillStyle::FillStyle_MAKE_FIXED_SIZE }, //UUU need special handling for DrawingLayer FillStyle names - { CTF_FILLGRADIENTNAME, -1 }, - { CTF_FILLTRANSNAME, -1 }, - { CTF_FILLHATCHNAME, -1 }, - { CTF_FILLBITMAPNAME, -1 }, + { CTF_FILLGRADIENTNAME, -1, drawing::FillStyle::FillStyle_GRADIENT }, + { CTF_FILLTRANSNAME, -1, drawing::FillStyle::FillStyle_MAKE_FIXED_SIZE }, + { CTF_FILLHATCHNAME, -1, drawing::FillStyle::FillStyle_HATCH }, + { CTF_FILLBITMAPNAME, -1, drawing::FillStyle::FillStyle_BITMAP }, - { -1, -1 } + { -1, -1, drawing::FillStyle::FillStyle_MAKE_FIXED_SIZE } }; // the style families associated with the same index modulo 4 @@ -532,6 +533,12 @@ void XMLTextStyleContext::FillPropertySet( break; } + if (::xmloff::IsIgnoreFillStyleNamedItem(rPropSet, aContextIDs[i].nExpectedFillStyle)) + { + SAL_INFO("xmloff.style", "XMLTextStyleContext: dropping fill named item: " << sStyleName); + break; // ignore it, it's not used + } + // Still needed if it's not an AutomaticStyle (!) try { |