[Libreoffice-commits] .: 5 commits - writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Oct 27 04:02:58 PDT 2012


 writerfilter/source/filter/RtfFilter.cxx       |   13 +++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   58 +++++++++++++++++++++----
 2 files changed, 64 insertions(+), 7 deletions(-)

New commits:
commit beffbd826a74f3751bd34d7747e401de7d836457
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sat Oct 27 12:39:10 2012 +0200

    fix top/left/right/bottom margin of RTF imported inline images
    
    This is similar to 3d7e168a2a43c2414b0633379102ddb29437e75b, but for RTF
    (Word default is 0, Writer is something larger).
    
    Change-Id: Ibb429eed5d3c1d09777db88ba2a98503c8ed0ed8

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 7950e29..1fab293 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -744,6 +744,10 @@ int RTFDocumentImpl::resolvePict(bool bInline)
     if (bInline)
     {
         RTFSprms aInlineAttributes;
+        aInlineAttributes.set(NS_ooxml::LN_CT_Inline_distT, RTFValue::Pointer_t(new RTFValue(0)));
+        aInlineAttributes.set(NS_ooxml::LN_CT_Inline_distB, RTFValue::Pointer_t(new RTFValue(0)));
+        aInlineAttributes.set(NS_ooxml::LN_CT_Inline_distL, RTFValue::Pointer_t(new RTFValue(0)));
+        aInlineAttributes.set(NS_ooxml::LN_CT_Inline_distR, RTFValue::Pointer_t(new RTFValue(0)));
         RTFSprms aInlineSprms;
         aInlineSprms.set(NS_ooxml::LN_CT_Inline_extent, pExtentValue);
         aInlineSprms.set(NS_ooxml::LN_CT_Inline_docPr, pDocprValue);
commit 7b60f3f1335ddf105b77e2cd5c6743a7419d985c
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sat Oct 27 12:31:04 2012 +0200

    fdo#42407 fix RTF import of WMF images inside textframes
    
    Since commit f4f4a899, we send the external header of WMF images to the
    importer, but that seems to be cause problems with this document. To be
    on the safe side, revert this only for pictures inside textframes.
    
    Change-Id: I7e443beb9ca4261abf3e3a1257270d6c70b85918

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 66313f6..7950e29 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -641,7 +641,11 @@ int RTFDocumentImpl::resolvePict(bool bInline)
     aExtHeader.mapMode = m_aStates.top().aPicture.eWMetafile;
     aExtHeader.xExt = m_aStates.top().aPicture.nWidth;
     aExtHeader.yExt = m_aStates.top().aPicture.nHeight;
-    OUString aGraphicUrl = m_pGraphicHelper->importGraphicObject(xInputStream, &aExtHeader);
+    WMF_EXTERNALHEADER* pExtHeader = &aExtHeader;
+    uno::Reference<lang::XServiceInfo> xServiceInfo(m_aStates.top().aDrawingObject.xShape, uno::UNO_QUERY);
+    if (xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
+        pExtHeader = 0;
+    OUString aGraphicUrl = m_pGraphicHelper->importGraphicObject(xInputStream, pExtHeader);
 
     if (m_aStates.top().aPicture.nStyle == BMPSTYLE_PNG)
     {
commit a7cc5039769838924c7b07da0e7532d84f79d302
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sat Oct 27 12:27:09 2012 +0200

    ignore spaces while reading RTF image data
    
    Change-Id: I6a1af0cd98ed832204d4485e135da6e56e575b4a

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 064c879..66313f6 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -610,7 +610,7 @@ int RTFDocumentImpl::resolvePict(bool bInline)
         for (int i = 0; i < aStr.getLength(); ++i)
         {
             char ch = str[i];
-            if (ch != 0x0d && ch != 0x0a)
+            if (ch != 0x0d && ch != 0x0a && ch != 0x20)
             {
                 b = b << 4;
                 sal_Int8 parsed = m_pTokenizer->asHex(ch);
commit 5944eba64a8679cb6db7b54709169175d82224de
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sat Oct 27 12:25:26 2012 +0200

    writerfilter: make it easy to debug the old RTF filter
    
    Change-Id: Ifc1d6b78f55e7f202f5cc391f1401de5b65ed395

diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx
index f80d1b0..27373a4 100644
--- a/writerfilter/source/filter/RtfFilter.cxx
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -103,6 +103,18 @@ sal_Bool RtfFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescri
         uno::Reference<frame::XFrame> xFrame = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_FRAME(),
                 uno::Reference<frame::XFrame>());
 
+#ifdef DBG_OLDFILTER
+        uno::Reference< lang::XMultiServiceFactory > xMSF(m_xContext->getServiceManager(), uno::UNO_QUERY_THROW);
+        uno::Reference< uno::XInterface > xIfc( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.RtfImport" ))), uno::UNO_QUERY_THROW);
+        if (!xIfc.is())
+            return sal_False;
+        uno::Reference< document::XImporter > xImprtr(xIfc, uno::UNO_QUERY_THROW);
+        uno::Reference< document::XFilter > xFltr(xIfc, uno::UNO_QUERY_THROW);
+        if (!xImprtr.is() || !xFltr.is())
+            return sal_False;
+        xImprtr->setTargetDocument(m_xDstDoc);
+        bResult = xFltr->filter(aDescriptor);
+#else
         xStatusIndicator = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_STATUSINDICATOR(),
                 uno::Reference<task::XStatusIndicator>());
 
@@ -115,6 +127,7 @@ sal_Bool RtfFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescri
 #ifdef DEBUG_IMPORT
         dmapperLogger->endDocument();
 #endif
+#endif
         sal_uInt32 nEndTime = osl_getGlobalTimer();
         SAL_INFO("writerfilter.profile", OSL_THIS_FUNC << " finished in " << nEndTime - nStartTime << " ms");
     }
commit 4a5701183dcec827a14aff5305744cb25b11cdcb
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Oct 26 13:42:30 2012 +0200

    use textframes for importing RTF_DPTXBX
    
    This allows inline pictures on shapes later, plus matches what the
    DOC/DOCX filter does.
    
    Change-Id: I5da56ccf59a26cc9657925dec94fb58f97692bb8

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 9010b51..064c879 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
 #include <com/sun/star/graphic/GraphicProvider.hpp>
 #include <com/sun/star/io/UnexpectedEOFException.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/text/XTextFrame.hpp>
 #include <com/sun/star/text/SizeType.hpp>
 #include <com/sun/star/text/HoriOrientation.hpp>
@@ -2292,7 +2293,32 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                             nType = ESCHER_ShpInst_Ellipse;
                             break;
                         case RTF_DPTXBX:
-                            nType = ESCHER_ShpInst_TextBox;
+                            {
+                                m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance("com.sun.star.text.TextFrame"), uno::UNO_QUERY);
+                                // These are the default in Word, but not in Writer
+                                beans::PropertyValue aPropertyValue;
+                                aPropertyValue.Name = "HoriOrient";
+                                aPropertyValue.Value <<= text::HoriOrientation::NONE;
+                                m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
+                                aPropertyValue.Name = "VertOrient";
+                                aPropertyValue.Value <<= text::VertOrientation::NONE;
+                                m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
+                                aPropertyValue.Name = "BackColorTransparency";
+                                aPropertyValue.Value <<= sal_Int32(100);
+                                m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
+                                aPropertyValue.Name = "LeftBorderDistance";
+                                aPropertyValue.Value <<= sal_Int32(0);
+                                m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
+                                aPropertyValue.Name = "RightBorderDistance";
+                                aPropertyValue.Value <<= sal_Int32(0);
+                                m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
+                                aPropertyValue.Name = "TopBorderDistance";
+                                aPropertyValue.Value <<= sal_Int32(0);
+                                m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
+                                aPropertyValue.Name = "BottomBorderDistance";
+                                aPropertyValue.Value <<= sal_Int32(0);
+                                m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
+                            }
                             break;
                         default:
                             break;
@@ -2303,7 +2329,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                     if (xDrawSupplier.is())
                     {
                         uno::Reference<drawing::XShapes> xShapes(xDrawSupplier->getDrawPage(), uno::UNO_QUERY);
-                        if (xShapes.is())
+                        if (xShapes.is() && nKeyword != RTF_DPTXBX)
                             xShapes->add(m_aStates.top().aDrawingObject.xShape);
                     }
                     if (nType)
@@ -3706,15 +3732,25 @@ int RTFDocumentImpl::popState()
     {
         RTFDrawingObject& rDrawing = m_aStates.top().aDrawingObject;
         uno::Reference<drawing::XShape> xShape(rDrawing.xShape);
-        xShape->setPosition(awt::Point(rDrawing.nLeft, rDrawing.nTop));
-        xShape->setSize(awt::Size(rDrawing.nRight, rDrawing.nBottom));
         uno::Reference<beans::XPropertySet> xPropertySet(rDrawing.xPropertySet);
 
+        uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY);
+        bool bTextFrame = xServiceInfo->supportsService("com.sun.star.text.TextFrame");
+
+        if (bTextFrame)
+        {
+            xPropertySet->setPropertyValue("HoriOrientPosition", uno::makeAny(rDrawing.nLeft));
+            xPropertySet->setPropertyValue("VertOrientPosition", uno::makeAny(rDrawing.nTop));
+        }
+        else
+            xShape->setPosition(awt::Point(rDrawing.nLeft, rDrawing.nTop));
+        xShape->setSize(awt::Size(rDrawing.nRight, rDrawing.nBottom));
+
         if (rDrawing.bHasLineColor)
             xPropertySet->setPropertyValue("LineColor", uno::makeAny(sal_uInt32((rDrawing.nLineColorR<<16) + (rDrawing.nLineColorG<<8) + rDrawing.nLineColorB)));
         if (rDrawing.bHasFillColor)
             xPropertySet->setPropertyValue("FillColor", uno::makeAny(sal_uInt32((rDrawing.nFillColorR<<16) + (rDrawing.nFillColorG<<8) + rDrawing.nFillColorB)));
-        else
+        else if (!bTextFrame)
             // If there is no fill, the Word default is 100% transparency.
             xPropertySet->setPropertyValue("FillTransparence", uno::makeAny(sal_Int32(100)));
 


More information about the Libreoffice-commits mailing list