[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - include/xmloff sw/qa xmloff/inc xmloff/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Sep 15 07:16:08 PDT 2015
include/xmloff/PageMasterStyleMap.hxx | 1
sw/qa/extras/odfimport/data/tdf92586.odt |binary
sw/qa/extras/odfimport/odfimport.cxx | 7 ++++
xmloff/inc/XMLBackgroundImageContext.hxx | 2 +
xmloff/source/style/PageMasterStyleMap.cxx | 2 -
xmloff/source/style/PagePropertySetContext.cxx | 1
xmloff/source/style/XMLBackgroundImageContext.cxx | 38 +++++++++++++++++++++-
xmloff/source/text/XMLTextPropertySetContext.cxx | 1
xmloff/source/text/XMLTextShapeStyleContext.cxx | 1
9 files changed, 51 insertions(+), 2 deletions(-)
New commits:
commit a5df43611bb27491961f97b758b1c7fc0b3158b0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Sep 14 09:10:04 2015 +0200
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.
Change-Id: I64ab4363b20cc95003d35acd63ea421472b1c071
(cherry picked from commit 6621da38b3cd217314c2d2295fd1e71be7e1875e)
Reviewed-on: https://gerrit.libreoffice.org/18582
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/xmloff/PageMasterStyleMap.hxx b/include/xmloff/PageMasterStyleMap.hxx
index 859f3e0..59f04df 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 0000000..894571b
Binary files /dev/null and b/sw/qa/extras/odfimport/data/tdf92586.odt differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 4ed43af..105e046 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -606,6 +606,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 3fb3ca1..36f68fe 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 092e694..02c248d5 100644
--- a/xmloff/source/style/PageMasterStyleMap.cxx
+++ b/xmloff/source/style/PageMasterStyleMap.cxx
@@ -140,7 +140,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 c8d6e4d..9fa55fb 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 5acd951..a0ee84b 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 2afbd96..308451e 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 59351c5..19c38ba 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;
}
More information about the Libreoffice-commits
mailing list