[Libreoffice-commits] core.git: 4 commits - editeng/source oox/source sw/qa sw/source writerfilter/source

Miklos Vajna vmiklos at suse.cz
Fri Aug 23 07:13:49 PDT 2013


 editeng/source/items/frmitems.cxx                     |    3 --
 oox/source/vml/vmlshape.cxx                           |   13 ++++++---
 sw/qa/extras/ooxmlexport/data/transparent-shadow.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx              |   16 ++++++++++++
 sw/source/core/layout/paintfrm.cxx                    |    2 -
 sw/source/filter/ww8/docxattributeoutput.cxx          |   24 ++++++++++++++++--
 writerfilter/source/dmapper/GraphicImport.cxx         |    4 ++-
 7 files changed, 52 insertions(+), 10 deletions(-)

New commits:
commit df06e968f6edfa812effe99a320c4ce14f036289
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Aug 23 15:15:45 2013 +0200

    DOCX export of picture shadow transparency
    
    Change-Id: If84da3cd020485b1895c572b8e24998266d9be31

diff --git a/sw/qa/extras/ooxmlexport/data/transparent-shadow.docx b/sw/qa/extras/ooxmlexport/data/transparent-shadow.docx
new file mode 100755
index 0000000..267eb1a
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/transparent-shadow.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index a307044..d5cb1cb 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 521369a..563c419 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 );
     }
commit d6e80921f6bdd8ae21f44677aa978e80fe7ee54b
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Aug 23 14:39:33 2013 +0200

    DOCX import of picture shadow transparency
    
    Change-Id: I15e09017eccc3f0e5ed8cab9c3de3677c8a580fa

diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 3ff2176..af55e26 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -1364,11 +1364,13 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b
             {
                 // Shadow width is approximated by average of X and Y
                 table::ShadowFormat aShadow;
-                sal_Int32 nShadowColor = m_pImpl->nShadowColor;
+                sal_uInt32 nShadowColor = m_pImpl->nShadowColor & 0x00FFFFFF; // The shadow color we get is RGB only.
                 sal_Int32 nShadowWidth = (abs(m_pImpl->nShadowXDistance)
                                           + abs(m_pImpl->nShadowYDistance)) / 2;
 
                 aShadow.ShadowWidth = nShadowWidth;
+                sal_uInt8 nShadowTransparence = float(m_pImpl->nShadowTransparence) * 2.55;
+                nShadowColor |= (nShadowTransparence << 24); // Add transparence to the color.
                 aShadow.Color = nShadowColor;
                 // Distances -ve for top and right, +ve for bottom and left
                 if (m_pImpl->nShadowXDistance > 0)
commit c35898696f9d6157472e78426ae511bc83f3eb74
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Aug 23 12:48:56 2013 +0200

    SvxShadowItem: allow setting transparency other than 0% or 100%
    
    Also adjust SwFrm::PaintShadow(), seems that can't deal with
    transparency ATM (always paints white in case of even minimal
    transparency).
    
    Change-Id: I88baea732d6ef01b2e516af562bc424775c38f84

diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index 987c888..5e93f61 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -1313,7 +1313,7 @@ bool SvxShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
     aShadow.Location = eSet;
     aShadow.ShadowWidth =   bConvert ? TWIP_TO_MM100_UNSIGNED(nWidth) : nWidth;
     aShadow.IsTransparent = aShadowColor.GetTransparency() > 0;
-    aShadow.Color = aShadowColor.GetRGBColor();
+    aShadow.Color = aShadowColor.GetColor();
 
     switch ( nMemberId )
     {
@@ -1372,7 +1372,6 @@ bool SvxShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
 
         nWidth = bConvert ? MM100_TO_TWIP(aShadow.ShadowWidth) : aShadow.ShadowWidth;
         Color aSet(aShadow.Color);
-        aSet.SetTransparency(aShadow.IsTransparent ? 0xff : 0);
         aShadowColor = aSet;
     }
 
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 8b87220..1d5a712 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -4319,7 +4319,7 @@ void SwFrm::PaintShadow( const SwRect& rRect, SwRect& rOutRect,
     OutputDevice *pOut = pGlobalShell->GetOut();
 
     sal_uLong nOldDrawMode = pOut->GetDrawMode();
-    Color aShadowColor( rShadow.GetColor() );
+    Color aShadowColor( rShadow.GetColor().GetRGBColor() );
     if( !aRegion.empty() && pGlobalShell->GetWin() &&
         Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
     {
commit b6a4247ea5eec433493672770e3023fb9ae7880a
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Aug 23 10:45:58 2013 +0200

    VML import: fix default value of mso-wrap-distance-left/right
    
    Change-Id: I2168358076d9c5ce3271b21cd5a541e51aa502f9

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index e5eb017..186bd50 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -520,14 +520,19 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
     convertShapeProperties( xShape );
 
     // Handle left/right/top/bottom wrap distance.
+    // Default value of mso-wrap-distance-left/right is supposed to be 0 (see
+    // 19.1.2.19 of the VML spec), but Word implements a non-zero value.
+    // [MS-ODRAW] says the below default value in 2.3.4.9.
     const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
-    sal_Int32 nWrapDistanceLeft = 0;
+    OUString aWrapDistanceLeft = OUString::number(0x0001BE7C);
     if (!maTypeModel.maWrapDistanceLeft.isEmpty())
-        nWrapDistanceLeft = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maWrapDistanceLeft, 0, true, true);
+        aWrapDistanceLeft = maTypeModel.maWrapDistanceLeft;
+    sal_Int32 nWrapDistanceLeft = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, aWrapDistanceLeft, 0, true, false);
     PropertySet(xShape).setAnyProperty(PROP_LeftMargin, uno::makeAny(nWrapDistanceLeft));
-    sal_Int32 nWrapDistanceRight = 0;
+    OUString aWrapDistanceRight = OUString::number(0x0001BE7C);
     if (!maTypeModel.maWrapDistanceRight.isEmpty())
-        nWrapDistanceRight = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maWrapDistanceRight, 0, true, true);
+        aWrapDistanceRight = maTypeModel.maWrapDistanceRight;
+    sal_Int32 nWrapDistanceRight = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, aWrapDistanceRight, 0, true, false);
     PropertySet(xShape).setAnyProperty(PROP_RightMargin, uno::makeAny(nWrapDistanceRight));
     sal_Int32 nWrapDistanceTop = 0;
     if (!maTypeModel.maWrapDistanceTop.isEmpty())
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index d938671..a307044 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -684,6 +684,11 @@ void Test::testTextframeGradient()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aGradient.StartColor);
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x666666), aGradient.EndColor);
     CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
+
+    // Left / right margin was incorrect: the attribute was missing and we
+    // didn't have the right default (had 0 instead of the below one).
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(318), getProperty<sal_Int32>(xFrame, "LeftMargin"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(318), getProperty<sal_Int32>(xFrame, "RightMargin"));
 }
 
 void Test::testCellBtlr()


More information about the Libreoffice-commits mailing list