[Libreoffice-commits] core.git: include/oox oox/source sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Dec 12 01:27:39 PST 2013
include/oox/export/drawingml.hxx | 17 +++++++++++++-
include/oox/export/shapes.hxx | 2 -
oox/source/export/drawingml.cxx | 31 +++++++++++++++++++++++++++
oox/source/export/shapes.cxx | 4 +--
oox/source/export/vmlexport.cxx | 2 +
sw/source/filter/ww8/docxattributeoutput.cxx | 2 -
sw/source/filter/ww8/docxattributeoutput.hxx | 3 +-
sw/source/filter/ww8/docxexport.cxx | 2 -
8 files changed, 55 insertions(+), 8 deletions(-)
New commits:
commit 2440d0ba34d6cbc9eae6d2cb196a964840f084e4
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Dec 12 10:24:10 2013 +0100
oox: allow a callback to be registered for shape text DML export
Change-Id: Ice4dea8da117f61d947ad14ebbfccae0d2ed94df
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index bba93cd..67feca1 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -53,6 +53,8 @@ namespace io {
}
}}}
+class OutlinerParaObject;
+
namespace oox {
namespace core {
class XmlFilterBase;
@@ -60,6 +62,16 @@ namespace core {
namespace drawingml {
+/// Interface to be implemented by the parent exporter that knows how to handle shape text.
+class OOX_DLLPUBLIC DMLTextExport
+{
+public:
+ virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
+protected:
+ DMLTextExport() {}
+ virtual ~DMLTextExport() {}
+};
+
class OOX_DLLPUBLIC DrawingML {
public:
enum DocumentType { DOCUMENT_DOCX, DOCUMENT_PPTX, DOCUMENT_XLSX };
@@ -69,6 +81,8 @@ private:
/// To specify where write eg. the images to (like 'ppt', or 'word' - according to the OPC).
DocumentType meDocumentType;
+ /// Parent exporter, used for text callback.
+ DMLTextExport* mpTextExport;
protected:
::com::sun::star::uno::Any mAny;
@@ -87,7 +101,8 @@ protected:
const char* GetRelationCompPrefix();
public:
- DrawingML( ::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB = NULL, DocumentType eDocumentType = DOCUMENT_PPTX ) : meDocumentType( eDocumentType ), mpFS( pFS ), mpFB( pFB ) {}
+ DrawingML( ::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB = NULL, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = 0 )
+ : meDocumentType( eDocumentType ), mpTextExport(pTextExport), mpFS( pFS ), mpFB( pFB ) {}
void SetFS( ::sax_fastparser::FSHelperPtr pFS ) { mpFS = pFS; }
::sax_fastparser::FSHelperPtr GetFS() { return mpFS; }
::oox::core::XmlFilterBase* GetFB() { return mpFB; }
diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx
index 750d74f..65fafc9 100644
--- a/include/oox/export/shapes.hxx
+++ b/include/oox/export/shapes.hxx
@@ -76,7 +76,7 @@ private:
public:
- ShapeExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS, ShapeHashMap* pShapeMap = NULL, ::oox::core::XmlFilterBase* pFB = NULL, DocumentType eDocumentType = DOCUMENT_PPTX );
+ ShapeExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS, ShapeHashMap* pShapeMap = NULL, ::oox::core::XmlFilterBase* pFB = NULL, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = 0 );
virtual ~ShapeExport() {}
static sal_Bool NonEmptyText( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xIface );
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 5109309..e542df8 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -66,6 +66,7 @@
#include <svl/languageoptions.hxx>
#include <filter/msfilter/escherex.hxx>
#include <filter/msfilter/util.hxx>
+#include <editeng/outlobj.hxx>
#include <editeng/svxenum.hxx>
#include <svx/unoapi.hxx>
#include <svx/svdoashp.hxx>
@@ -1345,6 +1346,36 @@ void DrawingML::WriteText( Reference< XInterface > rXIface, bool bBodyPr, bool b
if( !enumeration.is() )
return;
+ SdrObject* pSdrObject = GetSdrObjectFromXShape(uno::Reference<drawing::XShape>(rXIface, uno::UNO_QUERY_THROW));
+ const SdrTextObj* pTxtObj = PTR_CAST(SdrTextObj, pSdrObject);
+ if (pTxtObj && mpTextExport)
+ {
+ 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 separate 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
+ mpTextExport->WriteOutliner(*pParaObj);
+ if (bOwnParaObj)
+ delete pParaObj;
+ }
+ return;
+ }
+
while( enumeration->hasMoreElements() ) {
Reference< XTextContent > paragraph;
Any any ( enumeration->nextElement() );
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 2c69810..5689215 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -123,8 +123,8 @@ namespace oox { namespace drawingml {
// not thread safe
int ShapeExport::mnSpreadsheetCounter = 1;
-ShapeExport::ShapeExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, ShapeHashMap* pShapeMap, XmlFilterBase* pFB, DocumentType eDocumentType )
- : DrawingML( pFS, pFB, eDocumentType )
+ShapeExport::ShapeExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, ShapeHashMap* pShapeMap, XmlFilterBase* pFB, DocumentType eDocumentType, DMLTextExport* pTextExport )
+ : DrawingML( pFS, pFB, eDocumentType, pTextExport )
, mnShapeIdMax( 1 )
, mnPictureIdMax( 1 )
, mnXmlNamespace( nXmlNamespace )
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index f65ce8a..842ad27 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -1030,7 +1030,9 @@ sal_Int32 VMLExport::StartShape()
if( pParaObj )
{
// this is reached only in case some text is attached to the shape
+ m_pSerializer->startElementNS(XML_v, XML_textbox, FSEND);
m_pTextExport->WriteOutliner(*pParaObj);
+ m_pSerializer->endElementNS(XML_v, XML_textbox);
if( bOwnParaObj )
delete pParaObj;
}
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 77d11e7..b30604d 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3800,7 +3800,6 @@ void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj)
sal_Int32 nPara = rEditObj.GetParagraphCount();
- m_pSerializer->startElementNS( XML_v, XML_textbox, FSEND );
m_pSerializer->startElementNS( XML_w, XML_txbxContent, FSEND );
for (sal_Int32 n = 0; n < nPara; ++n)
{
@@ -3844,7 +3843,6 @@ void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj)
m_pSerializer->endElementNS( XML_w, XML_p );
}
m_pSerializer->endElementNS( XML_w, XML_txbxContent );
- m_pSerializer->endElementNS( XML_v, XML_textbox );
}
oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML()
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 29b1718..958300d 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -36,6 +36,7 @@
#include <boost/scoped_ptr.hpp>
#include <boost/optional.hpp>
#include <oox/export/vmlexport.hxx>
+#include <oox/export/drawingml.hxx>
#include <docxtablestyleexport.hxx>
class SwGrfNode;
@@ -100,7 +101,7 @@ struct PageMargins
};
/// The class that has handlers for various resource types when exporting as DOCX.
-class DocxAttributeOutput : public AttributeOutputBase, public oox::vml::VMLTextExport
+class DocxAttributeOutput : public AttributeOutputBase, public oox::vml::VMLTextExport, public oox::drawingml::DMLTextExport
{
public:
/// Export the state of RTL/CJK.
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index f825819..17cf70f 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -331,7 +331,7 @@ OString DocxExport::OutputChart( uno::Reference< frame::XModel >& xModel, sal_In
void DocxExport::OutputDML(uno::Reference<drawing::XShape>& xShape)
{
- oox::drawingml::ShapeExport aExport(XML_wps, m_pDocumentFS, 0, m_pFilter, oox::drawingml::DrawingML::DOCUMENT_DOCX);
+ oox::drawingml::ShapeExport aExport(XML_wps, m_pDocumentFS, 0, m_pFilter, oox::drawingml::DrawingML::DOCUMENT_DOCX, m_pAttrOutput);
aExport.WriteShape(xShape);
}
More information about the Libreoffice-commits
mailing list