Kaydet (Commit) b82791e3 authored tarafından Michael Stahl's avatar Michael Stahl

tdf#89478: svx: ODF import: SvxBrushItem Graphics should override Color

The bugdoc has:

<style:page-layout-properties fo:background-color="#007f7f" >
    <style:background-image
     xlink:href="Pictures/2000003900002FA3000055F455EC9F63.svm"/>
</style:page-layout-properties>

In this case it's clearly better to prefer the Graphics.

The old code could actually store both in the model but the UI only
allows setting either Color or Graphic, so this should be good enough.

(regression from 7d9bb549)

Change-Id: Id33231ad90815d9791f90289fb0b55455d334c14
üst ea8db4ad
...@@ -50,19 +50,8 @@ void setSvxBrushItemAsFillAttributesToTargetSet(const SvxBrushItem& rBrush, SfxI ...@@ -50,19 +50,8 @@ void setSvxBrushItemAsFillAttributesToTargetSet(const SvxBrushItem& rBrush, SfxI
const sal_uInt8 nTransparency(rBrush.GetColor().GetTransparency()); const sal_uInt8 nTransparency(rBrush.GetColor().GetTransparency());
if(0xff != nTransparency) // tdf#89478 check for image first
{ if (GPOS_NONE != rBrush.GetGraphicPos())
// we have a color fill
const Color aColor(rBrush.GetColor().GetRGBColor());
rToSet.Put(XFillStyleItem(drawing::FillStyle_SOLID));
rToSet.Put(XFillColorItem(OUString(), aColor));
// #125189# nTransparency is in range [0..254], convert to [0..100] which is used in
// XFillTransparenceItem (caution with the range which is in an *item-specific* range)
rToSet.Put(XFillTransparenceItem((((sal_Int32)nTransparency * 100) + 127) / 254));
}
else if(GPOS_NONE != rBrush.GetGraphicPos())
{ {
// we have a graphic fill, set fill style // we have a graphic fill, set fill style
rToSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP)); rToSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP));
...@@ -131,6 +120,18 @@ void setSvxBrushItemAsFillAttributesToTargetSet(const SvxBrushItem& rBrush, SfxI ...@@ -131,6 +120,18 @@ void setSvxBrushItemAsFillAttributesToTargetSet(const SvxBrushItem& rBrush, SfxI
rToSet.Put(XFillTransparenceItem(nGraphicTransparency)); rToSet.Put(XFillTransparenceItem(nGraphicTransparency));
} }
} }
else if (0xff != nTransparency)
{
// we have a color fill
const Color aColor(rBrush.GetColor().GetRGBColor());
rToSet.Put(XFillStyleItem(drawing::FillStyle_SOLID));
rToSet.Put(XFillColorItem(OUString(), aColor));
// #125189# nTransparency is in range [0..254], convert to [0..100] which is used in
// XFillTransparenceItem (caution with the range which is in an *item-specific* range)
rToSet.Put(XFillTransparenceItem((((sal_Int32)nTransparency * 100) + 127) / 254));
}
else else
{ {
// GPOS_NONE == rBrush.GetGraphicPos() && 0xff == rBrush.GetColor().GetTransparency(), // GPOS_NONE == rBrush.GetGraphicPos() && 0xff == rBrush.GetColor().GetTransparency(),
......
...@@ -316,6 +316,12 @@ DECLARE_ODFIMPORT_TEST(testPageBackground, "PageBackground.odt") ...@@ -316,6 +316,12 @@ DECLARE_ODFIMPORT_TEST(testPageBackground, "PageBackground.odt")
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xPropertySet, "FillStyle")); CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xPropertySet, "FillStyle"));
CPPUNIT_ASSERT_EQUAL(OUString("Sky"), getProperty<OUString>(xPropertySet, "FillBitmapName")); CPPUNIT_ASSERT_EQUAL(OUString("Sky"), getProperty<OUString>(xPropertySet, "FillBitmapName"));
CPPUNIT_ASSERT_EQUAL(drawing::BitmapMode_REPEAT, getProperty<drawing::BitmapMode>(xPropertySet, "FillBitmapMode")); CPPUNIT_ASSERT_EQUAL(drawing::BitmapMode_REPEAT, getProperty<drawing::BitmapMode>(xPropertySet, "FillBitmapMode"));
uno::Reference<beans::XPropertySet> xPropertySetOld(getStyles("PageStyles")->getByName("OldStandard"), uno::UNO_QUERY);
// The background image was overridden by color
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xPropertySetOld, "FillStyle"));
CPPUNIT_ASSERT_EQUAL(OUString("Sky"), getProperty<OUString>(xPropertySetOld, "FillBitmapName"));
CPPUNIT_ASSERT_EQUAL(drawing::BitmapMode_REPEAT, getProperty<drawing::BitmapMode>(xPropertySetOld, "FillBitmapMode"));
} }
DECLARE_ODFIMPORT_TEST(testFdo56272, "fdo56272.odt") DECLARE_ODFIMPORT_TEST(testFdo56272, "fdo56272.odt")
......
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