oox/source/token/properties.txt              |    1 
 oox/source/vml/vmlshape.cxx                  |    6 +++
 sw/qa/extras/ooxmlexport/data/fdo66688.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |   12 ++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   50 +++++++++++++++++++++++----
 5 files changed, 63 insertions(+), 6 deletions(-)

New commits:
commit 728f10576807970b3356eb0d5ad01722bdddd977
Author: Adam Co <rattles2...@gmail.com>
Date:   Tue Jul 9 10:18:05 2013 +0300

    fdo#66688: fix for crash on exit and opacity issue
    
    Conflicts:
        sw/qa/extras/ooxmlexport/ooxmlexport.cxx
    
    Change-Id: I32db54e2c49b40bf41005baeba380a4f631d615a
    Reviewed-on: https://gerrit.libreoffice.org/4780

diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 0acfe06..d89ae44 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 efd5d75..bcf93b6 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
new file mode 100644
index 0000000..300b915
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo66688.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 7230a4c..6b65c90 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 6bd05a4..5a0f8a0 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
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to