summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-09-14 09:10:04 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-09-17 08:07:08 +0000
commit3c2927e3f6dcd83ecac39b6a3bb3774d3faa0e22 (patch)
treec0dbed71eafd831119bb0e4b6015a7256253af48
parent6e271506158d01f8730f745510a18b04e8902740 (diff)
tdf#92586 xmloff: fix import of stretched background image
The bug document has: <style:page-layout-properties ... style:repeat="no-repeat"> <style:background-image ... style:repeat="stretch"/> </style:page-layout-properties> When a stretched background image is set on a page style using the Writer UI, then these two style:repeat attributes always match, but not in the bugdoc. The later used to have priority, till commit 7d9bb549d498d6beed2c4050c402d09643febdfa (Related: #i124638# Second step of DrawingLayer FillAttributes..., 2014-06-02). Fix the problem by extending XMLBackgroundImageContext::EndElement(): if we know that the <style:page-layout-properties> sets the FillBitmapMode property, then don't blindly set BackGraphicLocation, but try to overwrite the exiting FillBitmapMode one. (cherry picked from commit 6621da38b3cd217314c2d2295fd1e71be7e1875e) Change-Id: I64ab4363b20cc95003d35acd63ea421472b1c071 Reviewed-on: https://gerrit.libreoffice.org/18606 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/xmloff/PageMasterStyleMap.hxx1
-rw-r--r--sw/qa/extras/odfimport/data/tdf92586.odtbin0 -> 10517 bytes
-rw-r--r--sw/qa/extras/odfimport/odfimport.cxx7
-rw-r--r--xmloff/inc/XMLBackgroundImageContext.hxx2
-rw-r--r--xmloff/source/style/PageMasterStyleMap.cxx2
-rw-r--r--xmloff/source/style/PagePropertySetContext.cxx1
-rw-r--r--xmloff/source/style/XMLBackgroundImageContext.cxx38
-rw-r--r--xmloff/source/text/XMLTextPropertySetContext.cxx1
-rw-r--r--xmloff/source/text/XMLTextShapeStyleContext.cxx1
9 files changed, 51 insertions, 2 deletions
diff --git a/include/xmloff/PageMasterStyleMap.hxx b/include/xmloff/PageMasterStyleMap.hxx
index 859f3e0e6e84..59f04df2abd9 100644
--- a/include/xmloff/PageMasterStyleMap.hxx
+++ b/include/xmloff/PageMasterStyleMap.hxx
@@ -96,6 +96,7 @@
#define CTF_PM_FILLHATCHNAME (XML_PM_CTF_START + 0x0040)
#define CTF_PM_FILLBITMAPNAME (XML_PM_CTF_START + 0x0041)
#define CTF_PM_FILLTRANSNAME (XML_PM_CTF_START + 0x0042)
+#define CTF_PM_FILLBITMAPMODE (XML_PM_CTF_START + 0x0043)
#define CTF_PM_SCALETO (XML_PM_CTF_START + 0x0051) // calc specific
#define CTF_PM_SCALETOPAGES (XML_PM_CTF_START + 0x0052)
diff --git a/sw/qa/extras/odfimport/data/tdf92586.odt b/sw/qa/extras/odfimport/data/tdf92586.odt
new file mode 100644
index 000000000000..894571b628bf
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/tdf92586.odt
Binary files differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 1dfef14fceb8..0c41a312ef3a 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -595,6 +595,13 @@ DECLARE_ODFIMPORT_TEST(testBnc800714, "bnc800714.fodt")
CPPUNIT_ASSERT(getProperty<bool>(getParagraph(2), "ParaKeepTogether"));
}
+DECLARE_ODFIMPORT_TEST(testTdf92586, "tdf92586.odt")
+{
+ uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
+ // This was BitmapMode_NO_REPEAT.
+ CPPUNIT_ASSERT_EQUAL(drawing::BitmapMode_STRETCH, getProperty<drawing::BitmapMode>(xPageStyle, "FillBitmapMode"));
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/xmloff/inc/XMLBackgroundImageContext.hxx b/xmloff/inc/XMLBackgroundImageContext.hxx
index 3fb3ca15f4ce..36f68fe224b1 100644
--- a/xmloff/inc/XMLBackgroundImageContext.hxx
+++ b/xmloff/inc/XMLBackgroundImageContext.hxx
@@ -30,6 +30,7 @@ namespace com { namespace sun { namespace star {
class XMLBackgroundImageContext : public XMLElementPropertyContext
{
XMLPropertyState aPosProp;
+ sal_Int32 m_nBitmapModeIdx;
XMLPropertyState aFilterProp;
XMLPropertyState aTransparencyProp;
@@ -58,6 +59,7 @@ public:
sal_Int32 nPosIdx,
sal_Int32 nFilterIdx,
sal_Int32 nTransparencyIdx,
+ sal_Int32 nBitmapModeIdx,
::std::vector< XMLPropertyState > &rProps );
virtual ~XMLBackgroundImageContext();
diff --git a/xmloff/source/style/PageMasterStyleMap.cxx b/xmloff/source/style/PageMasterStyleMap.cxx
index da1308b50865..15bf89ea98be 100644
--- a/xmloff/source/style/PageMasterStyleMap.cxx
+++ b/xmloff/source/style/PageMasterStyleMap.cxx
@@ -138,7 +138,7 @@ const XMLPropertyMapEntry aXMLPageMasterStyleMap[] =
PLMAP( "FillBitmapLogicalSize", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_WIDTH, XML_SW_TYPE_LOGICAL_SIZE|MID_FLAG_MULTI_PROPERTY, 0 ),
PLMAP( "FillBitmapSizeY", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_HEIGHT, XML_SW_TYPE_FILLBITMAPSIZE|MID_FLAG_MULTI_PROPERTY, 0 ),
PLMAP( "FillBitmapLogicalSize", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_HEIGHT, XML_SW_TYPE_LOGICAL_SIZE|MID_FLAG_MULTI_PROPERTY, 0 ),
- PLMAP( "FillBitmapMode", XML_NAMESPACE_STYLE, XML_REPEAT, XML_SW_TYPE_BITMAP_MODE|MID_FLAG_MULTI_PROPERTY, 0 ),
+ PLMAP( "FillBitmapMode", XML_NAMESPACE_STYLE, XML_REPEAT, XML_SW_TYPE_BITMAP_MODE|MID_FLAG_MULTI_PROPERTY, CTF_PM_FILLBITMAPMODE ),
PLMAP( "FillBitmapPositionOffsetX", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_REF_POINT_X, XML_TYPE_PERCENT, 0 ),
PLMAP( "FillBitmapPositionOffsetY", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_REF_POINT_Y, XML_TYPE_PERCENT, 0 ),
PLMAP( "FillBitmapRectanglePoint", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_REF_POINT, XML_SW_TYPE_BITMAP_REFPOINT, 0 ),
diff --git a/xmloff/source/style/PagePropertySetContext.cxx b/xmloff/source/style/PagePropertySetContext.cxx
index c8d6e4dec8cf..9fa55fb4c47c 100644
--- a/xmloff/source/style/PagePropertySetContext.cxx
+++ b/xmloff/source/style/PagePropertySetContext.cxx
@@ -96,6 +96,7 @@ SvXMLImportContext *PagePropertySetContext::CreateChildContext(
rProp.mnIndex-2,
rProp.mnIndex-1,
-1,
+ mxMapper->getPropertySetMapper()->FindEntryIndex(CTF_PM_FILLBITMAPMODE),
rProperties );
break;
diff --git a/xmloff/source/style/XMLBackgroundImageContext.cxx b/xmloff/source/style/XMLBackgroundImageContext.cxx
index 5acd95109076..a0ee84b2b7de 100644
--- a/xmloff/source/style/XMLBackgroundImageContext.cxx
+++ b/xmloff/source/style/XMLBackgroundImageContext.cxx
@@ -19,6 +19,7 @@
#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/drawing/BitmapMode.hpp>
#include <tools/debug.hxx>
@@ -332,9 +333,11 @@ XMLBackgroundImageContext::XMLBackgroundImageContext(
sal_Int32 nPosIdx,
sal_Int32 nFilterIdx,
sal_Int32 nTransparencyIdx,
+ sal_Int32 nBitmapModeIdx,
::std::vector< XMLPropertyState > &rProps ) :
XMLElementPropertyContext( rImport, nPrfx, rLName, rProp, rProps ),
aPosProp( nPosIdx ),
+ m_nBitmapModeIdx(nBitmapModeIdx),
aFilterProp( nFilterIdx ),
aTransparencyProp( nTransparencyIdx ),
nTransparency( 0 )
@@ -399,7 +402,40 @@ void XMLBackgroundImageContext::EndElement()
XMLElementPropertyContext::EndElement();
if( -1 != aPosProp.mnIndex )
- rProperties.push_back( aPosProp );
+ {
+ // See if a FillBitmapMode property is already set, in that case
+ // BackGraphicLocation will be ignored.
+ bool bFound = false;
+ if (m_nBitmapModeIdx != -1)
+ {
+ for (XMLPropertyState& rProperty : rProperties)
+ {
+ if (rProperty.mnIndex == m_nBitmapModeIdx)
+ {
+ bFound = true;
+
+ // Found, so map the old property to the new one.
+ switch (ePos)
+ {
+ case GraphicLocation_TILED:
+ rProperty.maValue <<= drawing::BitmapMode_REPEAT;
+ break;
+ case GraphicLocation_AREA:
+ rProperty.maValue <<= drawing::BitmapMode_STRETCH;
+ break;
+ case GraphicLocation_MIDDLE_MIDDLE:
+ rProperty.maValue <<= drawing::BitmapMode_NO_REPEAT;
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ }
+ }
+ if (!bFound)
+ rProperties.push_back( aPosProp );
+ }
if( -1 != aFilterProp.mnIndex )
rProperties.push_back( aFilterProp );
if( -1 != aTransparencyProp.mnIndex )
diff --git a/xmloff/source/text/XMLTextPropertySetContext.cxx b/xmloff/source/text/XMLTextPropertySetContext.cxx
index 2afbd9635c24..308451e6a6f3 100644
--- a/xmloff/source/text/XMLTextPropertySetContext.cxx
+++ b/xmloff/source/text/XMLTextPropertySetContext.cxx
@@ -114,6 +114,7 @@ SvXMLImportContext *XMLTextPropertySetContext::CreateChildContext(
rProp.mnIndex-2,
rProp.mnIndex-1,
nTranspIndex,
+ -1,
rProperties );
}
break;
diff --git a/xmloff/source/text/XMLTextShapeStyleContext.cxx b/xmloff/source/text/XMLTextShapeStyleContext.cxx
index a59f200c2d68..5f75bdb88f7c 100644
--- a/xmloff/source/text/XMLTextShapeStyleContext.cxx
+++ b/xmloff/source/text/XMLTextShapeStyleContext.cxx
@@ -111,6 +111,7 @@ SvXMLImportContext *XMLTextShapePropertySetContext_Impl::CreateChildContext(
rProp.mnIndex-2,
rProp.mnIndex-1,
rProp.mnIndex-3,
+ -1,
rProperties );
break;
}