[Libreoffice-commits] .: 2 commits - oox/inc oox/Library_oox.mk oox/source sw/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Mon Aug 13 08:42:49 PDT 2012


 oox/Library_oox.mk                           |    1 
 oox/inc/oox/export/vmlexport.hxx             |   21 +++++++++++-
 oox/source/export/vmlexport.cxx              |   42 ++++++++++++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   46 ++++++++++++++++++++++++++-
 sw/source/filter/ww8/docxattributeoutput.hxx |    6 ++-
 sw/source/filter/ww8/docxexport.cxx          |    2 -
 6 files changed, 112 insertions(+), 6 deletions(-)

New commits:
commit 9c374a17fd440865ecceb1867c4142adf3d7fbd3
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Aug 13 17:37:46 2012 +0200

    fdo#53113 docx export: initial shape text support
    
    Text is written, but paragraph and character properties are not yet
    handled.
    
    Change-Id: I828f8b6096bde000347066b23925376f6f945dbc

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 8a93e1d..da3c926 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -36,7 +36,6 @@
 #include <oox/token/tokens.hxx>
 #include <oox/export/drawingml.hxx>
 #include <oox/export/utils.hxx>
-#include <oox/export/vmlexport.hxx>
 #include <oox/mathml/export.hxx>
 
 #include <i18npool/mslangid.hxx>
@@ -85,6 +84,7 @@
 #include <editeng/blnkitem.hxx>
 #include <editeng/charhiddenitem.hxx>
 #include <editeng/opaqitem.hxx>
+#include <editeng/editobj.hxx>
 #include <svx/svdmodel.hxx>
 #include <svx/svdobj.hxx>
 
@@ -2368,6 +2368,50 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Po
     m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_POSTPONE );
 }
 
+void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj)
+{
+    const EditTextObject& rEditObj = rParaObj.GetTextObject();
+    MSWord_SdrAttrIter aAttrIter( m_rExport, rEditObj, TXT_HFTXTBOX );
+
+    sal_uInt16 nPara = rEditObj.GetParagraphCount();
+
+    m_pSerializer->startElementNS( XML_w, XML_textbox, FSEND );
+    m_pSerializer->startElementNS( XML_w, XML_txbxContent, FSEND );
+    for (sal_uInt16 n = 0; n < nPara; ++n)
+    {
+        if( n )
+            aAttrIter.NextPara( n );
+
+        String aStr( rEditObj.GetText( n ));
+        xub_StrLen nAktPos = 0;
+        xub_StrLen nEnd = aStr.Len();
+
+        m_pSerializer->startElementNS( XML_w, XML_p, FSEND );
+        do {
+            xub_StrLen nNextAttr = aAttrIter.WhereNext();
+            if( nNextAttr > nEnd )
+                nNextAttr = nEnd;
+
+            m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
+            bool bTxtAtr = aAttrIter.IsTxtAttr( nAktPos );
+            if( !bTxtAtr )
+            {
+                String aOut( aStr.Copy( nAktPos, nNextAttr - nAktPos ) );
+                RunText(aOut);
+            }
+
+            m_pSerializer->endElementNS( XML_w, XML_r );
+
+            nAktPos = nNextAttr;
+            aAttrIter.NextPos();
+        }
+        while( nAktPos < nEnd );
+        m_pSerializer->endElementNS( XML_w, XML_p );
+    }
+    m_pSerializer->endElementNS( XML_w, XML_txbxContent );
+    m_pSerializer->endElementNS( XML_w, XML_textbox );
+}
+
 void DocxAttributeOutput::StartStyle( const String& rName, bool bPapFmt,
         sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 /*nWwId*/, sal_uInt16 nId, bool bAutoUpdate )
 {
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 1761009..f549784 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -33,6 +33,7 @@
 
 #include <vector>
 #include <boost/scoped_ptr.hpp>
+#include <oox/export/vmlexport.hxx>
 
 class SwGrfNode;
 class SdrObject;
@@ -59,7 +60,7 @@ enum DocxColBreakStatus
 };
 
 /// The class that has handlers for various resource types when exporting as DOCX.
-class DocxAttributeOutput : public AttributeOutputBase
+class DocxAttributeOutput : public AttributeOutputBase, public oox::vml::VMLTextExport
 {
 public:
     /// Export the state of RTL/CJK.
@@ -633,6 +634,9 @@ public:
 
     bool HasPostitFields() const;
     void WritePostitFields();
+
+    /// VMLTextExport
+    virtual void WriteOutliner(const OutlinerParaObject& rParaObj);
 };
 
 #endif // _DOCXATTRIBUTEOUTPUT_HXX_
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 79ab70e..b19b47b 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -813,7 +813,7 @@ DocxExport::DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCur
     m_pAttrOutput = new DocxAttributeOutput( *this, m_pDocumentFS, m_pDrawingML );
 
     // the related VMLExport
-    m_pVMLExport = new VMLExport( m_pDocumentFS );
+    m_pVMLExport = new VMLExport( m_pDocumentFS, m_pAttrOutput );
 }
 
 DocxExport::~DocxExport()
commit 7fd28f4de77d12acb68a6b7f5fb578fedd8b76bb
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Aug 13 17:36:50 2012 +0200

    fdo#53113 oox::VMLExport: allow a callback to be registered for shape text
    
    Change-Id: I1df58fa067287a37b0f62b0b05b0567da73d03b0

diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index 5fba3f2..dee336a 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -61,6 +61,7 @@ $(eval $(call gb_Library_use_libraries,oox,\
     comphelper \
     cppu \
     cppuhelper \
+    editeng \
     msfilter \
     sal \
     sax \
diff --git a/oox/inc/oox/export/vmlexport.hxx b/oox/inc/oox/export/vmlexport.hxx
index 6685f09..ec5a4d9 100644
--- a/oox/inc/oox/export/vmlexport.hxx
+++ b/oox/inc/oox/export/vmlexport.hxx
@@ -23,6 +23,7 @@
 #include <oox/dllapi.h>
 #include <sax/fshelper.hxx>
 #include <filter/msfilter/escherex.hxx>
+#include <editeng/outlobj.hxx>
 
 namespace rtl {
     class OString;
@@ -33,11 +34,27 @@ namespace oox {
 
 namespace vml {
 
+/// Interface to be implemented by the parent exporter that knows how to handle shape text.
+class OOX_DLLPUBLIC VMLTextExport
+{
+public:
+    virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
+protected:
+    VMLTextExport() {}
+    virtual ~VMLTextExport() {}
+};
+
 class OOX_DLLPUBLIC VMLExport : public EscherEx
 {
     /// Fast serializer to output the data
     ::sax_fastparser::FSHelperPtr m_pSerializer;
 
+    /// Parent exporter, used for text callback.
+    VMLTextExport* m_pTextExport;
+
+    /// The object we're exporting.
+    const SdrObject* m_pSdrObject;
+
     /// Fill the shape attributes as they come.
     ::sax_fastparser::FastAttributeList *m_pShapeAttrList;
 
@@ -54,7 +71,7 @@ class OOX_DLLPUBLIC VMLExport : public EscherEx
     bool *m_pShapeTypeWritten;
 
 public:
-                        VMLExport( ::sax_fastparser::FSHelperPtr pSerializer );
+                        VMLExport( ::sax_fastparser::FSHelperPtr pSerializer, VMLTextExport* pTextExport = 0 );
     virtual             ~VMLExport();
 
     ::sax_fastparser::FSHelperPtr
@@ -63,7 +80,7 @@ public:
     /// Export the sdr object as VML.
     ///
     /// Call this when you need to export the object as VML.
-    using EscherEx::AddSdrObject;
+    sal_uInt32 AddSdrObject( const SdrObject& rObj );
 
 protected:
     /// Add an attribute to the generated <v:shape/> element.
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 17ff426..08aac17 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -25,6 +25,7 @@
 #include <rtl/ustring.hxx>
 
 #include <tools/stream.hxx>
+#include <svx/svdotext.hxx>
 
 #include <cstdio>
 
@@ -36,9 +37,11 @@ using rtl::OUStringBuffer;
 using namespace sax_fastparser;
 using namespace oox::vml;
 
-VMLExport::VMLExport( ::sax_fastparser::FSHelperPtr pSerializer )
+VMLExport::VMLExport( ::sax_fastparser::FSHelperPtr pSerializer, VMLTextExport* pTextExport )
     : EscherEx( EscherExGlobalRef(new EscherExGlobal(0)), 0 ),
       m_pSerializer( pSerializer ),
+      m_pTextExport( pTextExport ),
+      m_pSdrObject( 0 ),
       m_pShapeAttrList( NULL ),
       m_nShapeType( ESCHER_ShpInst_Nil ),
       m_pShapeStyle( new OStringBuffer( 200 ) ),
@@ -824,6 +827,37 @@ sal_Int32 VMLExport::StartShape()
         m_pSerializer->startElementNS( XML_v, nShapeElement, XFastAttributeListRef( m_pShapeAttrList ) );
     }
 
+    // now check if we have some text and we have a text exporter registered
+    const SdrTextObj* pTxtObj = PTR_CAST(SdrTextObj, m_pSdrObject);
+    if (pTxtObj && m_pTextExport)
+    {
+        const OutlinerParaObject* pParaObj = 0;
+        bool bOwnParaObj = false;
+
+        /*
+        #i13885#
+        When the object is actively being edited, that text is not set into
+        the objects normal text object, but lives in a seperate object.
+        */
+        if (pTxtObj->IsTextEditActive())
+        {
+            pParaObj = pTxtObj->GetEditOutlinerParaObject();
+            bOwnParaObj = true;
+        }
+        else
+        {
+            pParaObj = pTxtObj->GetOutlinerParaObject();
+        }
+
+        if( pParaObj )
+        {
+            // this is reached only in case some text is attached to the shape
+            m_pTextExport->WriteOutliner(*pParaObj);
+            if( bOwnParaObj )
+                delete pParaObj;
+        }
+    }
+
     return nShapeElement;
 }
 
@@ -836,4 +870,10 @@ void VMLExport::EndShape( sal_Int32 nShapeElement )
     }
 }
 
+sal_uInt32 VMLExport::AddSdrObject( const SdrObject& rObj )
+{
+    m_pSdrObject = &rObj;
+    return EscherEx::AddSdrObject(rObj);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list