diff options
-rw-r--r-- | oox/source/token/properties.txt | 1 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 6 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo66688.docx | bin | 0 -> 24042 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 50 |
5 files changed, 63 insertions, 6 deletions
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 0acfe069fccf..d89ae44a3792 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -20,6 +20,7 @@ AutoFilter AutoShowInfo Autocomplete BackColor +BackColorTransparency BackGraphicLocation BackGraphicURL Background diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index efd5d750f219..bcf93b6bf3c0 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -390,6 +390,12 @@ void ShapeBase::convertShapeProperties( const Reference< XShape >& rxShape ) con aPropMap.setProperty(PROP_BackColor, aPropMap[PROP_FillColor]); aPropMap.erase(PROP_FillColor); } + // TextFrames have BackColorTransparency, not FillTransparence + if (aPropMap.hasProperty(PROP_FillTransparence)) + { + aPropMap.setProperty(PROP_BackColorTransparency, aPropMap[PROP_FillTransparence]); + aPropMap.erase(PROP_FillTransparence); + } // And no LineColor property; individual borders can have colors and widths boost::optional<sal_Int32> oLineWidth; if (maTypeModel.maStrokeModel.moWeight.has()) diff --git a/sw/qa/extras/ooxmlexport/data/fdo66688.docx b/sw/qa/extras/ooxmlexport/data/fdo66688.docx Binary files differnew file mode 100644 index 000000000000..300b915044af --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo66688.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 7230a4c7b409..6b65c901c15f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -89,6 +89,7 @@ public: void testFdo65400(); void testFdo66543(); void testN822175(); + void testFdo66688(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -150,6 +151,7 @@ void Test::run() {"fdo65400.docx", &Test::testFdo65400}, {"fdo66543.docx", &Test::testFdo66543}, {"n822175.odt", &Test::testN822175}, + {"fdo66688.docx", &Test::testFdo66688}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -902,6 +904,16 @@ void Test::testN822175() CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_PARALLEL, getProperty<text::WrapTextMode>(xFrame, "Surround")); } +void Test::testFdo66688() +{ + // The problem was that TextFrame imported and exported the wrong value for transparency + // (was stored as 'FillTransparence' instead of 'BackColorTransparency' + uno::Reference<text::XTextFramesSupplier> xFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xFramesSupplier->getTextFrames(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 80 ), getProperty< sal_Int32 >( xFrame, "BackColorTransparency" ) ); +} + 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 6bd05a4558e2..5a0f8a09686d 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -32,6 +32,7 @@ #include <oox/token/tokens.hxx> #include <oox/export/utils.hxx> #include <oox/mathml/export.hxx> +#include <oox/drawingml/drawingmltypes.hxx> #include <i18nlangtag/languagetag.hxx> @@ -4857,7 +4858,32 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush ) { OString sColor = msfilter::util::ConvertColor( rBrush.GetColor( ) ); if (m_bTextFrameSyntax) + { + // Handle 'Opacity' + sal_Int32 nTransparency = rBrush.GetColor().GetTransparency(); + if (nTransparency) + { + // Convert transparency to percent + // Consider editeng/source/items/frmitems.cxx : lcl_TransparencyToPercent() function. + sal_Int8 nTransparencyPercent = (sal_Int8)((nTransparency * 100 + 127) / 254); + + // Calculate alpha value + // Consider oox/source/drawingml/color.cxx : getTransparency() function. + sal_Int32 nAlpha = (::oox::drawingml::MAX_PERCENT - ( ::oox::drawingml::PER_PERCENT * nTransparencyPercent ) ); + + // Calculate opacity value + // Consider oox/source/vml/vmlformatting.cxx : decodeColor() function. + double fOpacity = (double)nAlpha * 65535 / ::oox::drawingml::MAX_PERCENT; + OUString sOpacity = OUString::valueOf(fOpacity); + + if ( !m_pFlyFillAttrList ) + m_pFlyFillAttrList = m_pSerializer->createAttrList(); + + m_pFlyFillAttrList->add(XML_opacity, OUStringToOString(sOpacity, RTL_TEXTENCODING_UTF8) + "f"); + } + m_pFlyAttrList->add(XML_fillcolor, "#" + sColor); + } else if ( !m_rExport.bOutPageDescs ) { m_pSerializer->singleElementNS( XML_w, XML_shd, @@ -4876,7 +4902,9 @@ void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGrad { if (*m_oFillStyle == XFILL_GRADIENT) { - m_pFlyFillAttrList = m_pSerializer->createAttrList(); + if ( !m_pFlyFillAttrList ) + m_pFlyFillAttrList = m_pSerializer->createAttrList(); + m_pFlyFillAttrList->add(XML_type, "gradient"); const XGradient& rGradient = rFillGradient.GetGradientValue(); @@ -4911,12 +4939,22 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox ) if (pLeft && pRight && pTop && pBottom && *pLeft == *pRight && *pLeft == *pTop && *pLeft == *pBottom) { - OString sColor("#" + msfilter::util::ConvertColor(pTop->GetColor())); - m_pFlyAttrList->add(XML_strokecolor, sColor); + // Check border style + editeng::SvxBorderStyle eBorderStyle = pTop->GetBorderLineStyle(); + if (eBorderStyle == table::BorderLineStyle::NONE) + { + m_pFlyAttrList->add(XML_stroked, "f"); + m_pFlyAttrList->add(XML_strokeweight, "0pt"); + } + else + { + OString sColor("#" + msfilter::util::ConvertColor(pTop->GetColor())); + m_pFlyAttrList->add(XML_strokecolor, sColor); - double const fConverted(editeng::ConvertBorderWidthToWord(pTop->GetBorderLineStyle(), pTop->GetWidth())); - sal_Int32 nWidth = sal_Int32(fConverted / 20); - m_pFlyAttrList->add(XML_strokeweight, OString::valueOf(nWidth) + "pt"); + double const fConverted(editeng::ConvertBorderWidthToWord(pTop->GetBorderLineStyle(), pTop->GetWidth())); + sal_Int32 nWidth = sal_Int32(fConverted / 20); + m_pFlyAttrList->add(XML_strokeweight, OString::valueOf(nWidth) + "pt"); + } } // v:textbox's inset attribute: inner margin values for textbox text |