[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - 2 commits - include/oox oox/source sd/qa
Zolnai Tamás
tamas.zolnai at collabora.com
Mon Dec 1 00:15:47 PST 2014
include/oox/drawingml/shape.hxx | 2
oox/source/drawingml/shape.cxx | 12 ++
sd/qa/unit/data/pptx/ShapeLineProperties.pptx |binary
sd/qa/unit/data/pptx/bnc904423.pptx |binary
sd/qa/unit/import-tests.cxx | 128 ++++++++++++++++++++++++++
5 files changed, 140 insertions(+), 2 deletions(-)
New commits:
commit 79146230f00822ffff75dee361644524cccd1ab4
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date: Sun Nov 30 18:53:48 2014 +0100
PPTX import: fix import of shape line properties defined by theme
See also:
81cd386facedfbb15be6dffc10351262abf733f3
(cherry picked from commit 664a56b3c81503bdf199edf1806676f0a35b956f)
Conflicts:
sd/qa/unit/import-tests.cxx
Change-Id: Ibb21d3e5b52a4d4996202acd4a989910fa223632
diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index f711228..6d8b70c 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -228,6 +228,7 @@ protected:
TextBodyPtr mpTextBody;
LinePropertiesPtr mpLinePropertiesPtr;
+ LinePropertiesPtr mpShapeRefLinePropPtr;
FillPropertiesPtr mpFillPropertiesPtr;
FillPropertiesPtr mpShapeRefFillPropPtr;
GraphicPropertiesPtr mpGraphicPropertiesPtr;
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 843de0c..28b93b1 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -88,6 +88,7 @@ namespace oox { namespace drawingml {
Shape::Shape( const sal_Char* pServiceName )
: mbIsChild( false )
, mpLinePropertiesPtr( new LineProperties )
+, mpShapeRefLinePropPtr( new LineProperties )
, mpFillPropertiesPtr( new FillProperties )
, mpShapeRefFillPropPtr( new FillProperties )
, mpGraphicPropertiesPtr( new GraphicProperties )
@@ -114,6 +115,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
, mbIsChild( pSourceShape->mbIsChild )
, mpTextBody(pSourceShape->mpTextBody)
, mpLinePropertiesPtr( pSourceShape->mpLinePropertiesPtr )
+, mpShapeRefLinePropPtr( pSourceShape->mpShapeRefLinePropPtr )
, mpFillPropertiesPtr( pSourceShape->mpFillPropertiesPtr )
, mpShapeRefFillPropPtr( pSourceShape->mpShapeRefFillPropPtr )
, mpGraphicPropertiesPtr( pSourceShape->mpGraphicPropertiesPtr )
@@ -275,7 +277,7 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
else
mpTextBody.reset();
maShapeProperties = rReferencedShape.maShapeProperties;
- mpLinePropertiesPtr = LinePropertiesPtr( new LineProperties( *rReferencedShape.mpLinePropertiesPtr.get() ) );
+ mpShapeRefLinePropPtr = LinePropertiesPtr( new LineProperties( *rReferencedShape.mpLinePropertiesPtr.get() ) );
mpShapeRefFillPropPtr = FillPropertiesPtr( new FillProperties( *rReferencedShape.mpFillPropertiesPtr.get() ) );
mpCustomShapePropertiesPtr = CustomShapePropertiesPtr( new CustomShapeProperties( *rReferencedShape.mpCustomShapePropertiesPtr.get() ) );
mpTablePropertiesPtr = table::TablePropertiesPtr( rReferencedShape.mpTablePropertiesPtr.get() ? new table::TableProperties( *rReferencedShape.mpTablePropertiesPtr.get() ) : NULL );
@@ -539,6 +541,7 @@ Reference< XShape > Shape::createAndInsert(
// First apply reference shape's properties (shape on the master slide)
aFillProperties.assignUsed( *mpShapeRefFillPropPtr );
+ aLineProperties.assignUsed( *mpShapeRefLinePropPtr );
if( pTheme )
{
diff --git a/sd/qa/unit/data/pptx/ShapeLineProperties.pptx b/sd/qa/unit/data/pptx/ShapeLineProperties.pptx
new file mode 100644
index 0000000..36ece8c
Binary files /dev/null and b/sd/qa/unit/data/pptx/ShapeLineProperties.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 774d6b8..70be8e5 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -26,6 +26,9 @@
#include <svx/svdoole2.hxx>
#include <svx/svdotable.hxx>
#include <svx/xflclit.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xlnwtit.hxx>
#include <animations/animationnodehelper.hxx>
#include <sax/tools/converter.hxx>
@@ -70,6 +73,7 @@ public:
void testCreationDate();
void testBnc584721_4();
void testBnc904423();
+ void testShapeLineStyle();
CPPUNIT_TEST_SUITE(SdFiltersTest);
CPPUNIT_TEST(testDocumentLayout);
@@ -90,6 +94,7 @@ public:
CPPUNIT_TEST(testCreationDate);
CPPUNIT_TEST(testBnc584721_4);
CPPUNIT_TEST(testBnc904423);
+ CPPUNIT_TEST(testShapeLineStyle);
CPPUNIT_TEST_SUITE_END();
};
@@ -787,6 +792,74 @@ void SdFiltersTest::testBnc904423()
xDocShRef->DoClose();
}
+void SdFiltersTest::testShapeLineStyle()
+{
+ // Here the problem was that different line properties were applied in wrong order on the shape
+ // Right order: 1) master slide line style, 2) theme, 3) direct formatting
+ ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("sd/qa/unit/data/pptx/ShapeLineProperties.pptx"));
+
+ SdDrawDocument *pDoc = xDocShRef->GetDoc();
+ CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+ const SdrPage *pPage = pDoc->GetPage(1);
+ CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
+
+ // First shape's line style is defined on master slide
+ {
+ SdrObject *const pObj = pPage->GetObj(0);
+ CPPUNIT_ASSERT(pObj);
+
+ const XLineStyleItem& rStyleItem = dynamic_cast<const XLineStyleItem&>(
+ pObj->GetMergedItem(XATTR_LINESTYLE));
+ CPPUNIT_ASSERT_EQUAL(XLINE_DASH, rStyleItem.GetValue());
+
+ const XLineColorItem& rColorItem = dynamic_cast<const XLineColorItem&>(
+ pObj->GetMergedItem(XATTR_LINECOLOR));
+ CPPUNIT_ASSERT_EQUAL(ColorData(0xFF0000), rColorItem.GetColorValue().GetColor());
+
+ const XLineWidthItem& rWidthItem = dynamic_cast<const XLineWidthItem&>(
+ pObj->GetMergedItem(XATTR_LINEWIDTH));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(132), rWidthItem.GetValue());
+ }
+
+ // Second shape's line style is defined by theme
+ {
+ SdrObject *const pObj = pPage->GetObj(1);
+ CPPUNIT_ASSERT(pObj);
+
+ const XLineStyleItem& rStyleItem = dynamic_cast<const XLineStyleItem&>(
+ pObj->GetMergedItem(XATTR_LINESTYLE));
+ CPPUNIT_ASSERT_EQUAL(XLINE_SOLID, rStyleItem.GetValue());
+
+ const XLineColorItem& rColorItem = dynamic_cast<const XLineColorItem&>(
+ pObj->GetMergedItem(XATTR_LINECOLOR));
+ CPPUNIT_ASSERT_EQUAL(ColorData(0x3333CC), rColorItem.GetColorValue().GetColor());
+
+ const XLineWidthItem& rWidthItem = dynamic_cast<const XLineWidthItem&>(
+ pObj->GetMergedItem(XATTR_LINEWIDTH));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(35), rWidthItem.GetValue());
+ }
+
+ // Third shape's line style is defined by direct formatting
+ {
+ SdrObject *const pObj = pPage->GetObj(2);
+ CPPUNIT_ASSERT(pObj);
+
+ const XLineStyleItem& rStyleItem = dynamic_cast<const XLineStyleItem&>(
+ pObj->GetMergedItem(XATTR_LINESTYLE));
+ CPPUNIT_ASSERT_EQUAL(XLINE_SOLID, rStyleItem.GetValue());
+
+ const XLineColorItem& rColorItem = dynamic_cast<const XLineColorItem&>(
+ pObj->GetMergedItem(XATTR_LINECOLOR));
+ CPPUNIT_ASSERT_EQUAL(ColorData(0x7030A0), rColorItem.GetColorValue().GetColor());
+
+ const XLineWidthItem& rWidthItem = dynamic_cast<const XLineWidthItem&>(
+ pObj->GetMergedItem(XATTR_LINEWIDTH));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(176), rWidthItem.GetValue());
+ }
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
CPPUNIT_PLUGIN_IMPLEMENT();
commit 2fc3f16e3ce13044c6024c80513f4b4a0a4baa90
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date: Mon Dec 1 09:09:19 2014 +0100
bnc#904423: Text(box) is rendered white on white when it is not
The problem was that the background color defined by theme
was not imported correctly, because the different fill
style comes from different sources (master slide, theme,
direct formatting) were applied on the shape in wrong order.
To solve this we need to store master slide defined fill style
in a different variable so theme style can be applied after master
slide defined style but before direct formatting.
(cherry picked from commit 81cd386facedfbb15be6dffc10351262abf733f3)
Conflicts:
sd/qa/unit/import-tests.cxx
Change-Id: I99ea981858b9fa391915570187c8ddfdf2be1f7a
diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 0811a91..f711228 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -229,6 +229,7 @@ protected:
TextBodyPtr mpTextBody;
LinePropertiesPtr mpLinePropertiesPtr;
FillPropertiesPtr mpFillPropertiesPtr;
+ FillPropertiesPtr mpShapeRefFillPropPtr;
GraphicPropertiesPtr mpGraphicPropertiesPtr;
CustomShapePropertiesPtr mpCustomShapePropertiesPtr;
table::TablePropertiesPtr mpTablePropertiesPtr;
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index b567e1c..843de0c 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -89,6 +89,7 @@ Shape::Shape( const sal_Char* pServiceName )
: mbIsChild( false )
, mpLinePropertiesPtr( new LineProperties )
, mpFillPropertiesPtr( new FillProperties )
+, mpShapeRefFillPropPtr( new FillProperties )
, mpGraphicPropertiesPtr( new GraphicProperties )
, mpCustomShapePropertiesPtr( new CustomShapeProperties )
, mpEffectPropertiesPtr( new EffectProperties )
@@ -114,6 +115,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
, mpTextBody(pSourceShape->mpTextBody)
, mpLinePropertiesPtr( pSourceShape->mpLinePropertiesPtr )
, mpFillPropertiesPtr( pSourceShape->mpFillPropertiesPtr )
+, mpShapeRefFillPropPtr( pSourceShape->mpShapeRefFillPropPtr )
, mpGraphicPropertiesPtr( pSourceShape->mpGraphicPropertiesPtr )
, mpCustomShapePropertiesPtr( pSourceShape->mpCustomShapePropertiesPtr )
, mpTablePropertiesPtr( pSourceShape->mpTablePropertiesPtr )
@@ -274,7 +276,7 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
mpTextBody.reset();
maShapeProperties = rReferencedShape.maShapeProperties;
mpLinePropertiesPtr = LinePropertiesPtr( new LineProperties( *rReferencedShape.mpLinePropertiesPtr.get() ) );
- mpFillPropertiesPtr = FillPropertiesPtr( new FillProperties( *rReferencedShape.mpFillPropertiesPtr.get() ) );
+ mpShapeRefFillPropPtr = FillPropertiesPtr( new FillProperties( *rReferencedShape.mpFillPropertiesPtr.get() ) );
mpCustomShapePropertiesPtr = CustomShapePropertiesPtr( new CustomShapeProperties( *rReferencedShape.mpCustomShapePropertiesPtr.get() ) );
mpTablePropertiesPtr = table::TablePropertiesPtr( rReferencedShape.mpTablePropertiesPtr.get() ? new table::TableProperties( *rReferencedShape.mpTablePropertiesPtr.get() ) : NULL );
mpEffectPropertiesPtr = EffectPropertiesPtr( new EffectProperties( *rReferencedShape.mpEffectPropertiesPtr.get() ) );
@@ -535,6 +537,9 @@ Reference< XShape > Shape::createAndInsert(
// TODO: use ph color when applying effect properties
//sal_Int32 nEffectPhClr = -1;
+ // First apply reference shape's properties (shape on the master slide)
+ aFillProperties.assignUsed( *mpShapeRefFillPropPtr );
+
if( pTheme )
{
if( const ShapeStyleRef* pLineRef = getShapeStyleRef( XML_lnRef ) )
diff --git a/sd/qa/unit/data/pptx/bnc904423.pptx b/sd/qa/unit/data/pptx/bnc904423.pptx
new file mode 100644
index 0000000..618ad1b
Binary files /dev/null and b/sd/qa/unit/data/pptx/bnc904423.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index ffaa259..774d6b8 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -69,6 +69,7 @@ public:
void testBnc480256();
void testCreationDate();
void testBnc584721_4();
+ void testBnc904423();
CPPUNIT_TEST_SUITE(SdFiltersTest);
CPPUNIT_TEST(testDocumentLayout);
@@ -88,6 +89,7 @@ public:
CPPUNIT_TEST(testBnc480256);
CPPUNIT_TEST(testCreationDate);
CPPUNIT_TEST(testBnc584721_4);
+ CPPUNIT_TEST(testBnc904423);
CPPUNIT_TEST_SUITE_END();
};
@@ -732,6 +734,59 @@ void SdFiltersTest::testBnc584721_4()
xDocShRef->DoClose();
}
+void SdFiltersTest::testBnc904423()
+{
+ // Here the problem was that different fill properties were applied in wrong order on the shape
+ // Right order: 1) master slide fill style, 2) theme, 3) direct formatting
+ ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("sd/qa/unit/data/pptx/bnc904423.pptx"));
+
+ SdDrawDocument *pDoc = xDocShRef->GetDoc();
+ CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+ const SdrPage *pPage = pDoc->GetPage(1);
+ CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
+
+ // First shape's background color is defined on master slide
+ {
+ SdrObject *const pObj = pPage->GetObj(0);
+ CPPUNIT_ASSERT(pObj);
+
+ const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
+ pObj->GetMergedItem(XATTR_FILLSTYLE));
+ CPPUNIT_ASSERT_EQUAL(XFILL_SOLID, rStyleItem.GetValue());
+ const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
+ pObj->GetMergedItem(XATTR_FILLCOLOR));
+ CPPUNIT_ASSERT_EQUAL(ColorData(0x00CC99), rColorItem.GetColorValue().GetColor());
+ }
+
+ // Second shape's background color is defined by theme
+ {
+ SdrObject *const pObj = pPage->GetObj(1);
+ CPPUNIT_ASSERT(pObj);
+
+ const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
+ pObj->GetMergedItem(XATTR_FILLSTYLE));
+ CPPUNIT_ASSERT_EQUAL(XFILL_SOLID, rStyleItem.GetValue());
+ const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
+ pObj->GetMergedItem(XATTR_FILLCOLOR));
+ CPPUNIT_ASSERT_EQUAL(ColorData(0x3333CC), rColorItem.GetColorValue().GetColor());
+ }
+
+ // Third shape's background color is defined by direct formatting
+ {
+ SdrObject *const pObj = pPage->GetObj(2);
+ CPPUNIT_ASSERT(pObj);
+
+ const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
+ pObj->GetMergedItem(XATTR_FILLSTYLE));
+ CPPUNIT_ASSERT_EQUAL(XFILL_SOLID, rStyleItem.GetValue());
+ const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
+ pObj->GetMergedItem(XATTR_FILLCOLOR));
+ CPPUNIT_ASSERT_EQUAL(ColorData(0xFF0000), rColorItem.GetColorValue().GetColor());
+ }
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list