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

Miklos Vajna vmiklos at kemper.freedesktop.org
Tue Feb 21 08:31:21 PST 2012


 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   59 +++++++++++++++++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |   13 +++++
 2 files changed, 71 insertions(+), 1 deletion(-)

New commits:
commit fa9e867a342a37d84f02f7e801962761cc1d2b6f
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue Feb 21 16:40:57 2012 +0100

    implement import of RTF_DOB{X,Y}{MARGIN,PAGE}

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 9bc8caf..806b43f 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1985,8 +1985,31 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
         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);
+                {
+                    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);
+                    std::vector<beans::PropertyValue>& rPendingProperties = m_aStates.top().aDrawingObject.aPendingProperties;
+                    for (std::vector<beans::PropertyValue>::iterator i = rPendingProperties.begin(); i != rPendingProperties.end(); ++i)
+                        m_aStates.top().aDrawingObject.xPropertySet->setPropertyValue(i->Name, i->Value);
+                }
+                break;
+        case RTF_DOBXMARGIN:
+        case RTF_DOBYMARGIN:
+                {
+                    beans::PropertyValue aPropertyValue;
+                    aPropertyValue.Name = OUString(RTL_CONSTASCII_USTRINGPARAM((nKeyword == RTF_DOBXMARGIN ? "HoriOrientRelation" : "VertOrientRelation")));
+                    aPropertyValue.Value <<= text::RelOrientation::PAGE_PRINT_AREA;
+                    m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
+                }
+                break;
+        case RTF_DOBXPAGE:
+        case RTF_DOBYPAGE:
+                {
+                    beans::PropertyValue aPropertyValue;
+                    aPropertyValue.Name = OUString(RTL_CONSTASCII_USTRINGPARAM((nKeyword == RTF_DOBXPAGE ? "HoriOrientRelation" : "VertOrientRelation")));
+                    aPropertyValue.Value <<= text::RelOrientation::PAGE_FRAME;
+                    m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
+                }
                 break;
         default:
             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle flag '" << lcl_RtfToString(nKeyword) << "'");
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index d5cdedc..a6c0995 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -187,6 +187,7 @@ namespace writerfilter {
             public:
                 uno::Reference<drawing::XShape> xShape;
                 uno::Reference<beans::XPropertySet> xPropertySet;
+                std::vector<beans::PropertyValue> aPendingProperties;
         };
 
         /// Stores the properties of a picture.
commit bbef8b4a93ff840fa6306cc6e41e1e2dd3e6c8fa
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue Feb 21 15:15:08 2012 +0100

    implement import of RTF_DPLINE

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 4c39947..9bc8caf 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1291,6 +1291,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:
             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle destination '" << lcl_RtfToString(nKeyword) << "'");
             // Make sure we skip destinations (even without \*) till we don't handle them
@@ -1981,6 +1984,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:
             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle flag '" << lcl_RtfToString(nKeyword) << "'");
             aSkip.setParsed(false);
@@ -2627,6 +2634,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:
             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle value '" << lcl_RtfToString(nKeyword) << "'");
             aSkip.setParsed(false);
@@ -3177,6 +3196,22 @@ int RTFDocumentImpl::popState()
         aFrame = m_aStates.top().aFrame;
         bPopFrame = true;
     }
+    else if (m_aStates.top().nDestinationState == DESTINATION_DRAWINGOBJECT)
+    {
+        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);
@@ -3342,6 +3377,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 6242973..d5cdedc 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.


More information about the Libreoffice-commits mailing list