From b54d8d2410617eec56507ba9419abbf2f356c7ff Mon Sep 17 00:00:00 2001 From: Zolnai Tamás Date: Fri, 6 Jun 2014 10:16:39 +0200 Subject: 2nd part of bnc#870233: import font color from color fragment for SmartArts SmartArt import ignores some fragments during import if drawing fragment exists, which seems to be not complete. In this case font style is blank (white) in data (and drawing) fragment and the real value is defined in the ignored color fragment. So first make color fragment parsing work, then apply font color of "node0" style on nodes of the SmartArt. Actually, it's a workaround, because "node0" style label is hardcoded, for a proper solution layout fragment should be parsed too to get the right style label, but it interferes with the drawing fragment by now. Change-Id: I7db89176a07eee928563d42d3896fbd02190dfa8 (cherry picked from commit 639571d52b1b7e4cf912803642ca245c5dd86839) --- sd/qa/unit/data/pptx/bnc870233_2.pptx | Bin 0 -> 55758 bytes sd/qa/unit/import-tests.cxx | 68 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 sd/qa/unit/data/pptx/bnc870233_2.pptx (limited to 'sd/qa/unit') diff --git a/sd/qa/unit/data/pptx/bnc870233_2.pptx b/sd/qa/unit/data/pptx/bnc870233_2.pptx new file mode 100644 index 000000000000..7f4fc715aab4 Binary files /dev/null and b/sd/qa/unit/data/pptx/bnc870233_2.pptx differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index b9418b4d99ca..ce0d9d17c220 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -76,6 +76,7 @@ public: void testMediaEmbedding(); void testBnc870237(); void testBnc870233_1(); + void testBnc870233_2(); CPPUNIT_TEST_SUITE(SdFiltersTest); CPPUNIT_TEST(testDocumentLayout); @@ -102,6 +103,7 @@ public: CPPUNIT_TEST(testMediaEmbedding); CPPUNIT_TEST(testBnc870237); CPPUNIT_TEST(testBnc870233_1); + CPPUNIT_TEST(testBnc870233_2); CPPUNIT_TEST_SUITE_END(); }; @@ -832,6 +834,72 @@ void SdFiltersTest::testBnc870233_1() xDocShRef->DoClose(); } +void SdFiltersTest::testBnc870233_2() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_2.pptx")); + xDocShRef = saveAndReload( xDocShRef, 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 ); + + // The problem was in some SmartArts font color was wrong + + // First smart art has blue font color (direct formatting) + { + const SdrTextObj *pObj = dynamic_cast( pPage->GetObj( 0 ) ); + CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); + const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject(); + std::vector rLst; + aEdit.GetCharAttribs(0, rLst); + for( std::vector::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) + { + const SvxColorItem *pCharColor = dynamic_cast((*it).pAttr); + if( pCharColor ) + { + CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x0000ff), pCharColor->GetValue().GetColor()); + } + } + } + + // Second smart art has "dk2" font color (style) + { + const SdrTextObj *pObj = dynamic_cast( pPage->GetObj( 1 ) ); + CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); + const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject(); + std::vector rLst; + aEdit.GetCharAttribs(0, rLst); + for( std::vector::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) + { + const SvxColorItem *pCharColor = dynamic_cast((*it).pAttr); + if( pCharColor ) + { + CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x1F497D), pCharColor->GetValue().GetColor()); + } + } + } + + // Third smart art has white font color (style) + { + const SdrTextObj *pObj = dynamic_cast( pPage->GetObj( 2 ) ); + CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL); + const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject(); + std::vector rLst; + aEdit.GetCharAttribs(0, rLst); + for( std::vector::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it) + { + const SvxColorItem *pCharColor = dynamic_cast((*it).pAttr); + if( pCharColor ) + { + CPPUNIT_ASSERT_EQUAL( sal_uInt32(0xffffff), pCharColor->GetValue().GetColor()); + } + } + } + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest); -- cgit v1.2.3