Kaydet (Commit) 664a56b3 authored tarafından Zolnai Tamás's avatar Zolnai Tamás

PPTX import: fix import of shape line properties defined by theme

See also:
81cd386f

Change-Id: Ibb21d3e5b52a4d4996202acd4a989910fa223632
üst 81cd386f
...@@ -246,6 +246,7 @@ protected: ...@@ -246,6 +246,7 @@ protected:
TextBodyPtr mpTextBody; TextBodyPtr mpTextBody;
LinePropertiesPtr mpLinePropertiesPtr; LinePropertiesPtr mpLinePropertiesPtr;
LinePropertiesPtr mpShapeRefLinePropPtr;
FillPropertiesPtr mpFillPropertiesPtr; FillPropertiesPtr mpFillPropertiesPtr;
FillPropertiesPtr mpShapeRefFillPropPtr; FillPropertiesPtr mpShapeRefFillPropPtr;
GraphicPropertiesPtr mpGraphicPropertiesPtr; GraphicPropertiesPtr mpGraphicPropertiesPtr;
......
...@@ -95,6 +95,7 @@ namespace oox { namespace drawingml { ...@@ -95,6 +95,7 @@ namespace oox { namespace drawingml {
Shape::Shape( const sal_Char* pServiceName, bool bDefaultHeight ) Shape::Shape( const sal_Char* pServiceName, bool bDefaultHeight )
: mbIsChild( false ) : mbIsChild( false )
, mpLinePropertiesPtr( new LineProperties ) , mpLinePropertiesPtr( new LineProperties )
, mpShapeRefLinePropPtr( new LineProperties )
, mpFillPropertiesPtr( new FillProperties ) , mpFillPropertiesPtr( new FillProperties )
, mpShapeRefFillPropPtr( new FillProperties ) , mpShapeRefFillPropPtr( new FillProperties )
, mpGraphicPropertiesPtr( new GraphicProperties ) , mpGraphicPropertiesPtr( new GraphicProperties )
...@@ -125,6 +126,7 @@ Shape::Shape( const ShapePtr& pSourceShape ) ...@@ -125,6 +126,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
, mbIsChild( pSourceShape->mbIsChild ) , mbIsChild( pSourceShape->mbIsChild )
, mpTextBody(pSourceShape->mpTextBody) , mpTextBody(pSourceShape->mpTextBody)
, mpLinePropertiesPtr( pSourceShape->mpLinePropertiesPtr ) , mpLinePropertiesPtr( pSourceShape->mpLinePropertiesPtr )
, mpShapeRefLinePropPtr( pSourceShape->mpShapeRefLinePropPtr )
, mpFillPropertiesPtr( pSourceShape->mpFillPropertiesPtr ) , mpFillPropertiesPtr( pSourceShape->mpFillPropertiesPtr )
, mpShapeRefFillPropPtr( pSourceShape->mpShapeRefFillPropPtr ) , mpShapeRefFillPropPtr( pSourceShape->mpShapeRefFillPropPtr )
, mpGraphicPropertiesPtr( pSourceShape->mpGraphicPropertiesPtr ) , mpGraphicPropertiesPtr( pSourceShape->mpGraphicPropertiesPtr )
...@@ -293,7 +295,7 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText ) ...@@ -293,7 +295,7 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
else else
mpTextBody.reset(); mpTextBody.reset();
maShapeProperties = rReferencedShape.maShapeProperties; maShapeProperties = rReferencedShape.maShapeProperties;
mpLinePropertiesPtr = LinePropertiesPtr( new LineProperties( *rReferencedShape.mpLinePropertiesPtr.get() ) ); mpShapeRefLinePropPtr = LinePropertiesPtr( new LineProperties( *rReferencedShape.mpLinePropertiesPtr.get() ) );
mpShapeRefFillPropPtr = FillPropertiesPtr( new FillProperties( *rReferencedShape.mpFillPropertiesPtr.get() ) ); mpShapeRefFillPropPtr = FillPropertiesPtr( new FillProperties( *rReferencedShape.mpFillPropertiesPtr.get() ) );
mpCustomShapePropertiesPtr = CustomShapePropertiesPtr( new CustomShapeProperties( *rReferencedShape.mpCustomShapePropertiesPtr.get() ) ); mpCustomShapePropertiesPtr = CustomShapePropertiesPtr( new CustomShapeProperties( *rReferencedShape.mpCustomShapePropertiesPtr.get() ) );
mpTablePropertiesPtr = table::TablePropertiesPtr( rReferencedShape.mpTablePropertiesPtr.get() ? new table::TableProperties( *rReferencedShape.mpTablePropertiesPtr.get() ) : NULL ); mpTablePropertiesPtr = table::TablePropertiesPtr( rReferencedShape.mpTablePropertiesPtr.get() ? new table::TableProperties( *rReferencedShape.mpTablePropertiesPtr.get() ) : NULL );
...@@ -579,6 +581,7 @@ Reference< XShape > Shape::createAndInsert( ...@@ -579,6 +581,7 @@ Reference< XShape > Shape::createAndInsert(
// First apply reference shape's properties (shape on the master slide) // First apply reference shape's properties (shape on the master slide)
aFillProperties.assignUsed( *mpShapeRefFillPropPtr ); aFillProperties.assignUsed( *mpShapeRefFillPropPtr );
aLineProperties.assignUsed( *mpShapeRefLinePropPtr );
if( pTheme ) if( pTheme )
{ {
......
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
#include <svx/svdoole2.hxx> #include <svx/svdoole2.hxx>
#include <svx/svdotable.hxx> #include <svx/svdotable.hxx>
#include <svx/xflclit.hxx> #include <svx/xflclit.hxx>
#include <svx/xlineit0.hxx>
#include <svx/xlnclit.hxx>
#include <svx/xlnwtit.hxx>
#include <animations/animationnodehelper.hxx> #include <animations/animationnodehelper.hxx>
#include <sax/tools/converter.hxx> #include <sax/tools/converter.hxx>
...@@ -85,6 +88,7 @@ public: ...@@ -85,6 +88,7 @@ public:
void testBnc584721_3(); void testBnc584721_3();
void testBnc584721_4(); void testBnc584721_4();
void testBnc904423(); void testBnc904423();
void testShapeLineStyle();
CPPUNIT_TEST_SUITE(SdImportTest); CPPUNIT_TEST_SUITE(SdImportTest);
CPPUNIT_TEST(testDocumentLayout); CPPUNIT_TEST(testDocumentLayout);
...@@ -113,6 +117,7 @@ public: ...@@ -113,6 +117,7 @@ public:
CPPUNIT_TEST(testBnc584721_3); CPPUNIT_TEST(testBnc584721_3);
CPPUNIT_TEST(testBnc584721_4); CPPUNIT_TEST(testBnc584721_4);
CPPUNIT_TEST(testBnc904423); CPPUNIT_TEST(testBnc904423);
CPPUNIT_TEST(testShapeLineStyle);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -920,6 +925,74 @@ void SdImportTest::testBnc904423() ...@@ -920,6 +925,74 @@ void SdImportTest::testBnc904423()
xDocShRef->DoClose(); xDocShRef->DoClose();
} }
void SdImportTest::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"), 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(drawing::LineStyle_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(drawing::LineStyle_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(drawing::LineStyle_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(SdImportTest); CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
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