[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Oct 27 04:49:22 PDT 2014


 sw/qa/extras/htmlexport/htmlexport.cxx        |    4 +--
 sw/qa/extras/rtfimport/data/fdo85179.rtf      |   33 ++++++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx          |    7 +++++
 writerfilter/source/dmapper/GraphicImport.cxx |   32 +++++++++++++++++++------
 writerfilter/source/dmapper/GraphicImport.hxx |    2 -
 5 files changed, 68 insertions(+), 10 deletions(-)

New commits:
commit 07f36a421461217a78e61d97e86760738acabbe6
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Oct 23 17:09:25 2014 +0200

    fdo#85179 RTF filter: import image border
    
    Also adjust CppunitTest_sw_htmlexport that implicitly tested that there
    is no color around the image.
    
    (cherry picked from commit 01a32b7d074511bed24044dc94e1159aea62722b)
    
    Conflicts:
    	writerfilter/source/dmapper/GraphicImport.cxx
    
    Change-Id: I8e14dfa7e7be80c4f8c492999071decae6a492e8
    Reviewed-on: https://gerrit.libreoffice.org/12092
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index a59515e..faa3d4f 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -122,7 +122,7 @@ DECLARE_HTMLEXPORT_TEST(testExportOfImages, "textAndImage.docx")
     CPPUNIT_ASSERT(pDoc);
 
     assertXPath(pDoc, "/html/body", 1);
-    assertXPath(pDoc, "/html/body/p/img", 1);
+    assertXPath(pDoc, "/html/body/p/font/img", 1);
 }
 
 DECLARE_HTMLEXPORT_TEST(testExportOfImagesWithSkipImageEnabled, "textAndImage.docx")
@@ -131,7 +131,7 @@ DECLARE_HTMLEXPORT_TEST(testExportOfImagesWithSkipImageEnabled, "textAndImage.do
     CPPUNIT_ASSERT(pDoc);
 
     assertXPath(pDoc, "/html/body", 1);
-    assertXPath(pDoc, "/html/body/p/img", 0);
+    assertXPath(pDoc, "/html/body/p/font/img", 0);
 }
 
 DECLARE_HTMLEXPORT_TEST(testSkipImageEmbedded, "skipimage-embedded.doc")
diff --git a/sw/qa/extras/rtfimport/data/fdo85179.rtf b/sw/qa/extras/rtfimport/data/fdo85179.rtf
new file mode 100644
index 0000000..fb9bcfa
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo85179.rtf
@@ -0,0 +1,33 @@
+{\rtf1
+\pard\plain
+{\*\shppict
+{\pict
+{\*\picprop\shplid1025
+{\sp
+{\sn shapeType}
+{\sv 75}
+}
+{\sp
+{\sn lineColor}
+{\sv 65535}
+}
+{\sp
+{\sn lineWidth}
+{\sv 50800}
+}
+}
+\picscalex100\picscaley100\piccropl0\piccropr0\piccropt0\piccropb0\picw1806\pich1806\picwgoal1024\pichgoal1024\pngblip
+89504e470d0a1a0a0000000d49484452000000400000004008040000000060b9550000000467414d410000b18f0bfc6105000000017352474200aece1ce90000
+00206348524d00007a26000080840000fa00000080e8000075300000ea6000003a98000017709cba513c00000002624b47440000aa8d2332000000096f464673
+0000000600000000000c7355d3000000097048597300000dd700000dd70142289b7800000009767041670000004c00000040009d31381b000001cd4944415468
+deedd93d4fc24018c0f17f89c6cdc44940e3e222be2c0e7e0417e3a8113571707632514012a320c6f84d34be2c2ec2b750f40be8e6e4a00113cfe14a5b69b108
+f4589ee71652eefafce0b9f42e3d7063822aaac3f641d173a75d3efee85b6582c0c8749c5eb7332cfb4e6f213d336ed29807304477b1c7a94db80ae9e9c934d0
+fcdd12e7ffcefcc9168f9a0059143b8cb0d2de581f609854073fbecc220f60b18722479d0d14abed8c8cb5d3293ce2949903b0d8a7047cb1c98541008cba840c
+a736e1d2200046b967567f740961d3b197008873cf74835002eaac7363100009ca0d4296121675d2dc1a0440d2256428625163ed2f42cf011e8245d621b42c44
+0400485261a699706d1000092fa100d4490713220240dc25e438b1090185880ca09f8ece5c28d9843b009e82471ca25069d5cb785529bd007fdbfb8541b65b2f
+531100947a51530d42c1d92f9829818e31ca4ce9421c70e427440e80712a7a89b7c8fb0906003046a5311df31cf501a01f4d0ee1b80f00bd4c398558ee0340ff
+0b939a30df17002459f05d330a080a0108400002108000042000010840000210800004200001f8ce0ddf798e30dd7b38e0ce7ea16d2abc25a819cbda225337c7
+f7ff69bf8eef7f0084e08d42bdf8a03e00000025744558746372656174652d6461746500323031302d31322d32305431373a30383a33362b30313a30307ae51b1c00000025744558746d6f646966792d6461746500323031302d31322d32305431373a30383a33372b30313a30308323669c0000000049454e44ae4260820a}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 24afe98..d4cb897 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1907,6 +1907,13 @@ DECLARE_RTFIMPORT_TEST(testFdo83464, "fdo83464.rtf")
     CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), getProperty<OUString>(getRun(getParagraphOfText(1, xFrameText->getText()), 1), "CharFontName"));
 }
 
+DECLARE_RTFIMPORT_TEST(testFdo85179, "fdo85179.rtf")
+{
+    // This was 0, border around the picture was ignored on import.
+    // 360: EMU -> MM100
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(50800/360), getProperty<table::BorderLine2>(getShape(1), "TopBorder").LineWidth);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 4c68904..f53f7f3 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -176,6 +176,11 @@ struct GraphicBorderLine
         ,bHasShadow(false)
         {}
 
+    bool isEmpty()
+    {
+        return nLineWidth == 0 && nLineColor == 0 && bHasShadow == false;
+    }
+
 };
 
 class GraphicImport_Impl
@@ -679,7 +684,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
 
                         // fdo#70457: transform XShape into a SwXTextGraphicObject only if there's no rotation
                         if ( nRotation == 0 && !bContainsEffects )
-                            m_xGraphicObject = createGraphicObject( aMediaProperties );
+                            m_xGraphicObject = createGraphicObject( aMediaProperties, xShapeProps );
 
                         bUseShape = !m_xGraphicObject.is( );
 
@@ -1089,7 +1094,7 @@ void lcl_CalcCrop( sal_Int32& nCrop, sal_Int32 nRef )
        + (((nCrop & 0xffff) * nRef ) >> 16);
 }
 
-uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const beans::PropertyValues& aMediaProperties )
+uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const beans::PropertyValues& aMediaProperties, const uno::Reference<beans::XPropertySet>& xShapeProps )
 {
     uno::Reference< text::XTextContent > xGraphicObject;
     try
@@ -1117,10 +1122,22 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b
             {
                 if( m_pImpl->eGraphicImportType == IMPORT_AS_GRAPHIC || !nBorder )
                 {
-                    aBorderLine.Color = m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder) ].nLineColor;
-                    aBorderLine.InnerLineWidth = 0;
-                    aBorderLine.OuterLineWidth = (sal_Int16)m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder) ].nLineWidth;
-                    aBorderLine.LineDistance = 0;
+                    GraphicBorderLine& rBorderLine = m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder)];
+                    if (rBorderLine.isEmpty() && xShapeProps.is())
+                    {
+                        // In case we got no border tokens and we have the
+                        // original shape, then use its line properties as the
+                        // border.
+                        aBorderLine.Color = xShapeProps->getPropertyValue("LineColor").get<sal_Int32>();
+                        aBorderLine.LineWidth = xShapeProps->getPropertyValue("LineWidth").get<sal_Int32>();
+                    }
+                    else
+                    {
+                        aBorderLine.Color = m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder) ].nLineColor;
+                        aBorderLine.InnerLineWidth = 0;
+                        aBorderLine.OuterLineWidth = (sal_Int16)m_pImpl->aBorders[m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE ? BORDER_TOP : static_cast<BorderPosition>(nBorder) ].nLineWidth;
+                        aBorderLine.LineDistance = 0;
+                    }
                 }
                 PropertyIds aBorderProps[4] =
                 {
@@ -1350,7 +1367,8 @@ void GraphicImport::data(const sal_uInt8* buf, size_t len, writerfilter::Referen
         uno::Reference< io::XInputStream > xIStream = new XInputStreamHelper( buf, len, m_pImpl->bIsBitmap );
         aMediaProperties[0].Value <<= xIStream;
 
-        m_xGraphicObject = createGraphicObject( aMediaProperties );
+        uno::Reference<beans::XPropertySet> xPropertySet;
+        m_xGraphicObject = createGraphicObject( aMediaProperties, xPropertySet );
 }
 
 
diff --git a/writerfilter/source/dmapper/GraphicImport.hxx b/writerfilter/source/dmapper/GraphicImport.hxx
index 21612c0..dd0d000 100644
--- a/writerfilter/source/dmapper/GraphicImport.hxx
+++ b/writerfilter/source/dmapper/GraphicImport.hxx
@@ -76,7 +76,7 @@ class GraphicImport : public LoggedProperties, public LoggedTable
     css::uno::Reference<css::drawing::XShape> m_xShape;
     void ProcessShapeOptions(Value & val);
 
-    css::uno::Reference<css::text::XTextContent > createGraphicObject(const css::beans::PropertyValues& aMediaProperties );
+    css::uno::Reference<css::text::XTextContent > createGraphicObject(const css::beans::PropertyValues& aMediaProperties, const css::uno::Reference<css::beans::XPropertySet>& xShapeProps);
 
     void putPropertyToFrameGrabBag( const OUString& sPropertyName, const css::uno::Any& aPropertyValue );
 


More information about the Libreoffice-commits mailing list