Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


On Wed, Feb 29, 2012 at 05:05:01PM +0100, Miklos Vajna <vmiklos@suse.cz> wrote:
http://cgit.freedesktop.org/libreoffice/core/commit/?id=bbef8b4 and

As Michael Stahl pointed out on IRC, a null pointer check was missing in
popState(), fixed with 456a59b in master, I'm attaching an amended
patch, which should be picked to -3-5 instead. (It did not cause a crash
in its current form, but with little tweaking of the input doc, it can.)

http://cgit.freedesktop.org/libreoffice/core/commit/?id=fa9e867

Thanks,

Miklos
From c953f5298a8057d850e4481165fa15895ec3d94a Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@suse.cz>
Date: Tue, 21 Feb 2012 15:15:08 +0100
Subject: [PATCH] implement import of RTF_DPLINE, regression from LO 3.4

(cherry picked from commits bbef8b4a93ff840fa6306cc6e41e1e2dd3e6c8fa and
456a59b24d4ba5ac341f76b4302e82b687e97f69)
---
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   36 ++++++++++++++++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |   12 +++++++-
 2 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 7f1569e..a5f3578 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1285,6 +1285,9 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
             // This destination should be ignored by readers that support nested tables.
             m_aStates.top().nDestinationState = DESTINATION_SKIP;
             break;
+        case RTF_DO:
+            m_aStates.top().nDestinationState = DESTINATION_DRAWINGOBJECT;
+            break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle destination '%s'", OSL_THIS_FUNC, 
lcl_RtfToString(nKeyword));
@@ -1963,6 +1966,10 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
         case RTF_POSXL: m_aStates.top().aFrame.nHoriAlign = 
NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_left; break;
         case RTF_POSXR: m_aStates.top().aFrame.nHoriAlign = 
NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_right; break;
 
+        case RTF_DPLINE:
+                
m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.LineShape"))),
 uno::UNO_QUERY);
+                
m_aStates.top().aDrawingObject.xPropertySet.set(m_aStates.top().aDrawingObject.xShape, 
uno::UNO_QUERY);
+                break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle flag '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
@@ -2610,6 +2617,18 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             lcl_putNestedAttribute(m_aStates.top().aParagraphSprms,
                     NS_ooxml::LN_CT_PPrBase_spacing, NS_ooxml::LN_CT_Spacing_after, pIntValue);
             break;
+        case RTF_DPX:
+            m_aStates.top().aDrawingObject.nLeft = TWIP_TO_MM100(nParam);
+            break;
+        case RTF_DPY:
+            m_aStates.top().aDrawingObject.nTop = TWIP_TO_MM100(nParam);
+            break;
+        case RTF_DPXSIZE:
+            m_aStates.top().aDrawingObject.nRight = TWIP_TO_MM100(nParam);
+            break;
+        case RTF_DPYSIZE:
+            m_aStates.top().aDrawingObject.nBottom = TWIP_TO_MM100(nParam);
+            break;
         default:
 #if OSL_DEBUG_LEVEL > 1
             OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword));
@@ -3163,6 +3182,22 @@ int RTFDocumentImpl::popState()
         aFrame = m_aStates.top().aFrame;
         bPopFrame = true;
     }
+    else if (m_aStates.top().nDestinationState == DESTINATION_DRAWINGOBJECT && 
m_aStates.top().aDrawingObject.xShape.is())
+    {
+        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<drawing::XDrawPageSupplier> xDrawSupplier( m_xDstDoc, uno::UNO_QUERY);
+        if ( xDrawSupplier.is() )
+        {
+            uno::Reference< drawing::XShapes > xShapes( xDrawSupplier->getDrawPage(), 
uno::UNO_QUERY );
+            if ( xShapes.is() )
+                xShapes->add( xShape );
+        }
+        Mapper().startShape(xShape);
+        Mapper().endShape();
+    }
 
     // See if we need to end a track change
     RTFValue::Pointer_t pTrackchange = 
m_aStates.top().aCharacterSprms.find(NS_ooxml::LN_trackchange);
@@ -3323,6 +3358,7 @@ RTFParserState::RTFParserState()
     aLevelNumbers(),
     aPicture(),
     aShape(),
+    aDrawingObject(),
     aFrame(),
     nCellX(0),
     nCells(0),
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 90ecc98..98fa57c 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -108,7 +108,8 @@ namespace writerfilter {
             DESTINATION_ANNOTATIONDATE,
             DESTINATION_ANNOTATIONAUTHOR,
             DESTINATION_FALT,
-            DESTINATION_FLYMAINCONTENT
+            DESTINATION_FLYMAINCONTENT,
+            DESTINATION_DRAWINGOBJECT
         };
 
         enum RTFBorderState
@@ -180,6 +181,14 @@ namespace writerfilter {
                 int nBottom;
         };
 
+        /// Stores the properties of a drawing object.
+        class RTFDrawingObject : public RTFShape
+        {
+            public:
+                uno::Reference<drawing::XShape> xShape;
+                uno::Reference<beans::XPropertySet> xPropertySet;
+        };
+
         /// Stores the properties of a picture.
         class RTFPicture
         {
@@ -262,6 +271,7 @@ namespace writerfilter {
 
                 RTFPicture aPicture;
                 RTFShape aShape;
+                RTFDrawingObject aDrawingObject;
                 RTFFrame aFrame;
 
                 /// Current cellx value.
-- 
1.7.7


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.