Kaydet (Commit) 6999e63a authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Andras Timar

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
7d9bb549 (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 6621da38)
Reviewed-on: https://gerrit.libreoffice.org/18582Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 02619530
......@@ -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)
......
......@@ -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();
......
......@@ -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();
......
......@@ -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 ),
......
......@@ -96,6 +96,7 @@ SvXMLImportContext *PagePropertySetContext::CreateChildContext(
rProp.mnIndex-2,
rProp.mnIndex-1,
-1,
mxMapper->getPropertySetMapper()->FindEntryIndex(CTF_PM_FILLBITMAPMODE),
rProperties );
break;
......
......@@ -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 )
{
// 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 )
......
......@@ -114,6 +114,7 @@ SvXMLImportContext *XMLTextPropertySetContext::CreateChildContext(
rProp.mnIndex-2,
rProp.mnIndex-1,
nTranspIndex,
-1,
rProperties );
}
break;
......
......@@ -111,6 +111,7 @@ SvXMLImportContext *XMLTextShapePropertySetContext_Impl::CreateChildContext(
rProp.mnIndex-2,
rProp.mnIndex-1,
rProp.mnIndex-3,
-1,
rProperties );
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment