[Libreoffice-commits] core.git: 2 commits - sw/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Dec 19 02:52:44 PST 2013


 sw/source/filter/ww8/docxattributeoutput.cxx |   57 ++---------------------
 sw/source/filter/ww8/docxsdrexport.cxx       |   65 +++++++++++++++++++++++++++
 sw/source/filter/ww8/docxsdrexport.hxx       |    2 
 3 files changed, 74 insertions(+), 50 deletions(-)

New commits:
commit 9794a0db73b49f3c8b9e4b8348fe7dc9108d3435
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Dec 19 11:37:08 2013 +0100

    DocxAttributeOutput::WriteDMLTextFrame: write effect list
    
    We already had code for this, but only for pictures, factor out the
    relevant code into its own method and call it here as well.
    
    CppunitTest_sw_ooxmlexport's testTextFrameBorders is a reproducer for
    this problem.
    
    Change-Id: I3b71e64512a65c42a2f3859b4912a4408944e697

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 6bcf8e6..ce985b8 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -465,6 +465,7 @@ void DocxAttributeOutput::WriteDMLTextFrame(sw::Frame* pParentFrame)
     m_pBodyPrAttrList = m_pSerializer->createAttrList();
     m_rExport.OutputFormat( pParentFrame->GetFrmFmt(), false, false, true );
     m_bDMLTextFrameSyntax = false;
+    m_rExport.SdrExporter().writeDMLEffectLst(rFrmFmt);
     m_pSerializer->endElementNS(XML_wps, XML_spPr);
 
     m_rExport.mpParentFrame = NULL;
@@ -2922,18 +2923,6 @@ 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("");
-}
-
 /* Writes <a:srcRect> tag back to document.xml if a file conatins a cropped image.
 *  NOTE : Tested on images of type JPEG,EMF/WMF,BMP, PNG and GIF.
 */
@@ -3132,44 +3121,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
             FSEND );
     m_pSerializer->endElementNS( XML_a, XML_ln );
 
-    // Output effects
-    SvxShadowItem aShadowItem = pFrmFmt->GetShadow();
-    if ( aShadowItem.GetLocation() != SVX_SHADOW_NONE )
-    {
-        // Distance is measured diagonally from corner
-        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() )
-        {
-            case SVX_SHADOW_TOPLEFT: nShadowDir = 13500000; break;
-            case SVX_SHADOW_TOPRIGHT: nShadowDir = 18900000; break;
-            case SVX_SHADOW_BOTTOMLEFT: nShadowDir = 8100000; break;
-            case SVX_SHADOW_BOTTOMRIGHT: nShadowDir = 2700000; break;
-            case SVX_SHADOW_NONE:
-            case SVX_SHADOW_END:
-                break;
-        }
-        OString aShadowDir( OString::number( nShadowDir ) );
-
-        m_pSerializer->startElementNS( XML_a, XML_effectLst, FSEND );
-        m_pSerializer->startElementNS( XML_a, XML_outerShdw,
-                                       XML_dist, aShadowDist.getStr(),
-                                       XML_dir, aShadowDir.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 );
-    }
+    m_rExport.SdrExporter().writeDMLEffectLst(*pFrmFmt);
 
     m_pSerializer->endElementNS( XML_pic, XML_spPr );
 
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index f04d653..e030a81 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -21,6 +21,7 @@
 #include <svx/svdogrp.hxx>
 #include <oox/token/tokens.hxx>
 #include <oox/export/drawingml.hxx>
+#include <oox/drawingml/drawingmltypes.hxx>
 #include <oox/export/utils.hxx>
 #include <oox/export/vmlexport.hxx>
 
@@ -383,6 +384,70 @@ void DocxSdrExport::writeDMLAndVMLDrawing(const SdrObject* sdrObj, const SwFrmFm
         writeVMLDrawing(sdrObj, rFrmFmt, rNdTopLeft);
 }
 
+// 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 DocxSdrExport::writeDMLEffectLst(const SwFrmFmt& rFrmFmt)
+{
+    SvxShadowItem aShadowItem = rFrmFmt.GetShadow();
+
+    // Output effects
+    if (aShadowItem.GetLocation() != SVX_SHADOW_NONE)
+    {
+        // Distance is measured diagonally from corner
+        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())
+        {
+        case SVX_SHADOW_TOPLEFT:
+            nShadowDir = 13500000;
+            break;
+        case SVX_SHADOW_TOPRIGHT:
+            nShadowDir = 18900000;
+            break;
+        case SVX_SHADOW_BOTTOMLEFT:
+            nShadowDir = 8100000;
+            break;
+        case SVX_SHADOW_BOTTOMRIGHT:
+            nShadowDir = 2700000;
+            break;
+        case SVX_SHADOW_NONE:
+        case SVX_SHADOW_END:
+            break;
+        }
+        OString aShadowDir(OString::number(nShadowDir));
+
+        m_pImpl->m_pSerializer->startElementNS(XML_a, XML_effectLst, FSEND);
+        m_pImpl->m_pSerializer->startElementNS(XML_a, XML_outerShdw,
+                                               XML_dist, aShadowDist.getStr(),
+                                               XML_dir, aShadowDir.getStr(), FSEND);
+        if (aShadowAlpha.isEmpty())
+            m_pImpl->m_pSerializer->singleElementNS(XML_a, XML_srgbClr,
+                                                    XML_val, aShadowColor.getStr(), FSEND);
+        else
+        {
+            m_pImpl->m_pSerializer->startElementNS(XML_a, XML_srgbClr, XML_val, aShadowColor.getStr(), FSEND);
+            m_pImpl->m_pSerializer->singleElementNS(XML_a, XML_alpha, XML_val, aShadowAlpha.getStr(), FSEND);
+            m_pImpl->m_pSerializer->endElementNS(XML_a, XML_srgbClr);
+        }
+        m_pImpl->m_pSerializer->endElementNS(XML_a, XML_outerShdw);
+        m_pImpl->m_pSerializer->endElementNS(XML_a, XML_effectLst);
+    }
+
+}
+
 void DocxSdrExport::writeDiagram(const SdrObject* sdrObject, const Size& size)
 {
     sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer;
diff --git a/sw/source/filter/ww8/docxsdrexport.hxx b/sw/source/filter/ww8/docxsdrexport.hxx
index 02e0c52..069a98c 100644
--- a/sw/source/filter/ww8/docxsdrexport.hxx
+++ b/sw/source/filter/ww8/docxsdrexport.hxx
@@ -47,6 +47,8 @@ public:
     void writeDMLAndVMLDrawing(const SdrObject* sdrObj, const SwFrmFmt& rFrmFmt,const Point& rNdTopLeft, int nAnchorId);
     /// Writes a diagram (smartart).
     void writeDiagram(const SdrObject* sdrObject, const Size& size);
+    /// Write <a:effectLst>, the effect list.
+    void writeDMLEffectLst(const SwFrmFmt& rFrmFmt);
 };
 
 #endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXSDREXPORT_HXX
commit 3eeb60687aa2476b02d1862390441fc0c1f1b7e7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Dec 19 11:14:03 2013 +0100

    DocxAttributeOutput::FormatBackground: handle dml syntax
    
    CppunitTest_sw_ooxmlexport's testTextFrameBorders is a reproducer for
    this problem.
    
    Change-Id: I52e93ff09c67222caec789fc93bc19c257cdee05

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 725a579..6bcf8e6 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5779,6 +5779,11 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
     }
     else if (m_bDMLTextFrameSyntax)
     {
+        m_pSerializer->startElementNS(XML_a, XML_solidFill, FSEND);
+        m_pSerializer->singleElementNS(XML_a, XML_srgbClr,
+                                       XML_val, sColor,
+                                       FSEND);
+        m_pSerializer->endElementNS(XML_a, XML_solidFill);
     }
     else if ( !m_rExport.bOutPageDescs )
     {


More information about the Libreoffice-commits mailing list