diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-08-23 15:15:45 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-08-23 16:13:11 +0200 |
commit | df06e968f6edfa812effe99a320c4ce14f036289 (patch) | |
tree | 0f7de59900cca5f2a4a1609e33eeaa4621bed587 /sw | |
parent | d6e80921f6bdd8ae21f44677aa978e80fe7ee54b (diff) |
DOCX export of picture shadow transparency
Change-Id: If84da3cd020485b1895c572b8e24998266d9be31
Diffstat (limited to 'sw')
-rwxr-xr-x | sw/qa/extras/ooxmlexport/data/transparent-shadow.docx | bin | 0 -> 14091 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 11 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 24 |
3 files changed, 33 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/transparent-shadow.docx b/sw/qa/extras/ooxmlexport/data/transparent-shadow.docx Binary files differnew file mode 100755 index 000000000000..267eb1a8633d --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/transparent-shadow.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index a307044a599a..d5cb1cb0003d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -111,6 +111,7 @@ public: void testTableFloatingMargins(); void testFdo44689_start_page_7(); void testFdo67737(); + void testTransparentShadow(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -198,6 +199,7 @@ void Test::run() {"table-floating-margins.docx", &Test::testTableFloatingMargins}, {"fdo44689_start_page_7.docx", &Test::testFdo44689_start_page_7}, {"fdo67737.docx", &Test::testFdo67737}, + {"transparent-shadow.docx", &Test::testTransparentShadow}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -1222,6 +1224,15 @@ void Test::testFdo67737() CPPUNIT_FAIL("Did not find MirroredY=true property"); } +void Test::testTransparentShadow() +{ + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XShape> xPicture(xDrawPage->getByIndex(0), uno::UNO_QUERY); + table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xPicture, "ShadowFormat"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x7f808080), aShadow.Color); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 521369a9daf0..563c41958b08 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2294,6 +2294,18 @@ void DocxAttributeOutput::DefaultStyle( sal_uInt16 nStyle ) #endif } +// Converts ARGB transparency (0..255) to drawingml alpha (opposite, and 0..100000) +OString lcl_ConvertTransparency(const Color& rColor) +{ + if (rColor.GetTransparency() > 0) + { + sal_Int32 nTransparencyPercent = 100 - float(rColor.GetTransparency()) / 2.55; + return OString::number(nTransparencyPercent * oox::drawingml::PER_PERCENT); + } + else + return OString(""); +} + void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size& rSize, const SwFlyFrmFmt* pOLEFrmFmt, SwOLENode* pOLENode ) { OSL_TRACE( "TODO DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size& rSize, const SwFlyFrmFmt* pOLEFrmFmt, SwOLENode* pOLENode ) - some stuff still missing" ); @@ -2653,6 +2665,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size double nShadowDist = sqrt((aShadowItem.GetWidth()*aShadowItem.GetWidth())*2.0); OString aShadowDist( OString::number( TwipsToEMU( nShadowDist ) ) ); OString aShadowColor = msfilter::util::ConvertColor( aShadowItem.GetColor() ); + OString aShadowAlpha = lcl_ConvertTransparency(aShadowItem.GetColor()); sal_uInt32 nShadowDir = 0; switch ( aShadowItem.GetLocation() ) { @@ -2670,8 +2683,15 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size m_pSerializer->startElementNS( XML_a, XML_outerShdw, XML_dist, aShadowDist.getStr(), XML_dir, aShadowDir.getStr(), FSEND ); - m_pSerializer->singleElementNS( XML_a, XML_srgbClr, - XML_val, aShadowColor.getStr(), FSEND ); + if (aShadowAlpha.isEmpty()) + m_pSerializer->singleElementNS( XML_a, XML_srgbClr, + XML_val, aShadowColor.getStr(), FSEND ); + else + { + m_pSerializer->startElementNS(XML_a, XML_srgbClr, XML_val, aShadowColor.getStr(), FSEND); + m_pSerializer->singleElementNS(XML_a, XML_alpha, XML_val, aShadowAlpha.getStr(), FSEND); + m_pSerializer->endElementNS(XML_a, XML_srgbClr); + } m_pSerializer->endElementNS( XML_a, XML_outerShdw ); m_pSerializer->endElementNS( XML_a, XML_effectLst ); } |