summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2011-11-15 13:47:36 +0100
committerLuboš Luňák <l.lunak@suse.cz>2011-11-24 18:43:56 +0100
commit1acdbe4dfe0de152080992110efbb67e0639912d (patch)
tree134a06931453bb795ae48946750edcae12d159a0
parent49e4c3e5e139f0443e5432d99d6514038b62ce84 (diff)
initial (very hacky) work on mathml ooxml import
This commit needs to be generally reworked for upstream, but it more or less works.
-rw-r--r--oox/Package_inc.mk1
-rw-r--r--oox/inc/oox/export/starmathimport.hxx44
-rw-r--r--oox/source/export/ooxmlexport.cxx5
-rw-r--r--sw/CppunitTest_sw_swdoc_test.mk1
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/inc/docsh.hxx2
-rw-r--r--sw/inc/unotxdoc.hxx6
-rw-r--r--sw/source/core/unocore/unoframe.cxx33
-rw-r--r--sw/source/core/unocore/unomap.cxx2
-rw-r--r--sw/source/ui/app/docsh2.cxx12
-rw-r--r--sw/source/ui/uno/unotxdoc.cxx5
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx8
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx43
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx1
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx4
-rw-r--r--writerfilter/source/dmapper/OLEHandler.cxx4
-rw-r--r--writerfilter/source/dmapper/PropertyIds.cxx1
-rw-r--r--writerfilter/source/dmapper/PropertyIds.hxx1
-rw-r--r--writerfilter/source/ooxml/OOXMLFactory.hxx1
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx64
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.hxx25
-rw-r--r--writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx29
-rw-r--r--writerfilter/source/ooxml/OOXMLPropertySetImpl.hxx14
-rw-r--r--writerfilter/source/ooxml/model.xml2
24 files changed, 303 insertions, 6 deletions
diff --git a/oox/Package_inc.mk b/oox/Package_inc.mk
index 10f2b4cbebd9..396c24cc5820 100644
--- a/oox/Package_inc.mk
+++ b/oox/Package_inc.mk
@@ -42,6 +42,7 @@ $(eval $(call gb_Package_add_file,oox_inc,inc/oox/export/shapes.hxx,oox/export/s
$(eval $(call gb_Package_add_file,oox_inc,inc/oox/export/utils.hxx,oox/export/utils.hxx))
$(eval $(call gb_Package_add_file,oox_inc,inc/oox/export/vmlexport.hxx,oox/export/vmlexport.hxx))
$(eval $(call gb_Package_add_file,oox_inc,inc/oox/export/ooxmlexport.hxx,oox/export/ooxmlexport.hxx))
+$(eval $(call gb_Package_add_file,oox_inc,inc/oox/export/starmathimport.hxx,oox/export/starmathimport.hxx))
$(eval $(call gb_Package_add_file,oox_inc,inc/oox/helper/binarystreambase.hxx,oox/helper/binarystreambase.hxx))
$(eval $(call gb_Package_add_file,oox_inc,inc/oox/helper/containerhelper.hxx,oox/helper/containerhelper.hxx))
$(eval $(call gb_Package_add_file,oox_inc,inc/oox/helper/graphichelper.hxx,oox/helper/graphichelper.hxx))
diff --git a/oox/inc/oox/export/starmathimport.hxx b/oox/inc/oox/export/starmathimport.hxx
new file mode 100644
index 000000000000..712efc94845a
--- /dev/null
+++ b/oox/inc/oox/export/starmathimport.hxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Lubos Lunak <l.lunak@suse.cz> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#ifndef _STARMATHIMPORT_HXX
+#define _STARMATHIMPORT_HXX
+
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+
+#include <oox/dllapi.h>
+
+class OOX_DLLPUBLIC OoxmlFormulaImportBase
+{
+public:
+ OoxmlFormulaImportBase();
+ virtual void addFormula( com::sun::star::uno::Reference< com::sun::star::embed::XEmbeddedObject > ) = 0;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/export/ooxmlexport.cxx b/oox/source/export/ooxmlexport.cxx
index 30d13a93b138..b4e541cc3a1d 100644
--- a/oox/source/export/ooxmlexport.cxx
+++ b/oox/source/export/ooxmlexport.cxx
@@ -27,9 +27,14 @@
*/
#include <oox/export/ooxmlexport.hxx>
+#include <oox/export/starmathimport.hxx>
OoxmlFormulaExportBase::OoxmlFormulaExportBase()
{
}
+OoxmlFormulaImportBase::OoxmlFormulaImportBase()
+{
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/CppunitTest_sw_swdoc_test.mk b/sw/CppunitTest_sw_swdoc_test.mk
index f3f44bbf736a..6006b7fa04bd 100644
--- a/sw/CppunitTest_sw_swdoc_test.mk
+++ b/sw/CppunitTest_sw_swdoc_test.mk
@@ -48,6 +48,7 @@ $(eval $(call gb_CppunitTest_add_linked_libs,sw_swdoc_test, \
i18nisolang1 \
i18nutil \
lng \
+ oox \
sal \
salhelper \
sax \
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index a8ee38387d4b..60a510137fb4 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -66,6 +66,7 @@ $(eval $(call gb_Library_add_linked_libs,sw,\
i18nisolang1 \
i18nutil \
lng \
+ oox \
sal \
salhelper \
sax \
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index 96a1eaa9f3a4..e62699abf896 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -143,6 +143,8 @@ protected:
public:
using SotObject::GetInterface;
+ void addFormula( com::sun::star::uno::Reference< com::sun::star::embed::XEmbeddedObject > p);
+
// but we implement this ourselves.
SFX_DECL_INTERFACE(SW_DOCSHELL)
SFX_DECL_OBJECTFACTORY()
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index bc21cf3350f3..a821e38cc6c3 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -78,6 +78,7 @@
#include <cppuhelper/implbase2.hxx> // helper for implementations
#include <cppuhelper/implbase4.hxx> // helper for implementations
#include <RefreshListenerContainer.hxx>
+#include <oox/export/starmathimport.hxx>
#include <viewopt.hxx>
@@ -180,7 +181,8 @@ SwXTextDocumentBaseClass;
class SW_DLLPUBLIC SwXTextDocument : public SwXTextDocumentBaseClass,
public SvxFmMSFactory,
- public SfxBaseModel
+ public SfxBaseModel,
+ public OoxmlFormulaImportBase
{
ActionContextArr aActionArr;
SwRefreshListenerContainer aRefreshCont;
@@ -252,6 +254,8 @@ public:
virtual void SAL_CALL acquire( ) throw();
virtual void SAL_CALL release( ) throw();
+ virtual void addFormula( com::sun::star::uno::Reference< com::sun::star::embed::XEmbeddedObject > p );
+
//XWeak
virtual css::uno::Reference< css::uno::XAdapter > SAL_CALL queryAdapter( ) throw(css::uno::RuntimeException);
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index e91984570447..91e2152847ba 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -695,7 +695,8 @@ bool SwOLEProperties_Impl::AnyToItemSet(
SwDoc* pDoc, SfxItemSet& rFrmSet, SfxItemSet& rSet, bool& rSizeFound)
{
const ::uno::Any* pTemp;
- if(!GetProperty(FN_UNO_CLSID, 0, pTemp) && !GetProperty(FN_UNO_STREAM_NAME, 0, pTemp) )
+ if(!GetProperty(FN_UNO_CLSID, 0, pTemp) && !GetProperty(FN_UNO_STREAM_NAME, 0, pTemp)
+ && !GetProperty(FN_EMBEDDED_OBJECT, 0, pTemp) )
return sal_False;
SwFrameProperties_Impl::AnyToItemSet( pDoc, rFrmSet, rSet, rSizeFound);
//
@@ -1364,7 +1365,7 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno::
pFmt->GetDoc()->SetFlyFrmAttr( *pFmt, aSet );
}
- else if(FN_UNO_CLSID == pEntry->nWID || FN_UNO_STREAM_NAME == pEntry->nWID)
+ else if(FN_UNO_CLSID == pEntry->nWID || FN_UNO_STREAM_NAME == pEntry->nWID || FN_EMBEDDED_OBJECT == pEntry->nWID)
{
throw lang::IllegalArgumentException();
}
@@ -1642,6 +1643,10 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName)
{
aAny <<= ::rtl::OUString(pOleNode->GetOLEObj().GetCurrentPersistName());
}
+ else if(FN_EMBEDDED_OBJECT == pEntry->nWID)
+ {
+ aAny <<= pOleNode->GetOLEObj().GetOleRef();
+ }
}
else if(WID_LAYOUT_SIZE == pEntry->nWID)
{
@@ -2200,7 +2205,10 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
{
const ::uno::Any* pCLSID = 0;
const ::uno::Any* pStreamName = 0;
- if(!pProps->GetProperty(FN_UNO_CLSID, 0, pCLSID) && !pProps->GetProperty( FN_UNO_STREAM_NAME, 0, pStreamName ))
+ const ::uno::Any* pEmbeddedObject = 0;
+ if(!pProps->GetProperty(FN_UNO_CLSID, 0, pCLSID)
+ && !pProps->GetProperty( FN_UNO_STREAM_NAME, 0, pStreamName )
+ && !pProps->GetProperty( FN_EMBEDDED_OBJECT, 0, pEmbeddedObject ))
throw uno::RuntimeException();
if(pCLSID)
{
@@ -2281,7 +2289,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt2, sName);
}
}
- else if( pStreamName )
+ else if( pStreamName && false )
{
::rtl::OUString sStreamName;
(*pStreamName) >>= sStreamName;
@@ -2294,6 +2302,23 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
if(sName.Len())
pDoc->SetFlyName((SwFlyFrmFmt&)*pFrmFmt, sName);
}
+ else if( pEmbeddedObject || pStreamName )
+ {
+ uno::Reference< embed::XEmbeddedObject > obj;
+// (*pEmbeddedObject) >>= obj;
+ (*pStreamName) >>= obj;
+ svt::EmbeddedObjectRef xObj;
+ xObj.Assign( obj, embed::Aspects::MSOLE_CONTENT );
+
+ pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
+
+ SwFlyFrmFmt* pFrmFmt = 0;
+ pFrmFmt = pDoc->Insert( aPam, xObj, &aFrmSet, NULL, NULL );
+ pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
+ pFrmFmt->Add(this);
+ if(sName.Len())
+ pDoc->SetFlyName((SwFlyFrmFmt&)*pFrmFmt, sName);
+ }
}
if( pFmt && pDoc->GetDrawModel() )
GetOrCreateSdrObject( pFmt );
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index f7c7f4cc0ef3..cdaac5806655 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -1118,7 +1118,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
{ SW_PROP_NMID(UNO_NAME_GRAPHIC_URL), FN_UNO_REPLACEMENT_GRAPHIC_URL, CPPU_E2T(CPPUTYPE_OUSTRING), PropertyAttribute::MAYBEVOID, 0 },
{ SW_PROP_NMID(UNO_NAME_GRAPHIC), FN_UNO_REPLACEMENT_GRAPHIC, CPPU_E2T(CPPUTYPE_REFXGRAPHIC), PropertyAttribute::MAYBEVOID, 0 },
{ SW_PROP_NMID(UNO_NAME_COMPONENT),FN_UNO_COMPONENT, CPPU_E2T(CPPUTYPE_REFCOMPONENT), PropertyAttribute::READONLY, 0},
- { SW_PROP_NMID(UNO_NAME_EMBEDDED_OBJECT),FN_EMBEDDED_OBJECT, CPPU_E2T(CPPUTPYE_REFEMBEDDEDOBJECT), PropertyAttribute::READONLY, 0},
+ { SW_PROP_NMID(UNO_NAME_EMBEDDED_OBJECT),FN_EMBEDDED_OBJECT, CPPU_E2T(CPPUTPYE_REFEMBEDDEDOBJECT), PROPERTY_NONE, 0},
{0,0,0,0,0,0}
};
aMapEntriesArr[nPropertyId] = aEmbeddedPropertyMap_Impl;
diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx
index 1c649e1ef7c1..aa1d5d1c5c98 100644
--- a/sw/source/ui/app/docsh2.cxx
+++ b/sw/source/ui/app/docsh2.cxx
@@ -157,6 +157,18 @@ SfxDocumentInfoDialog* SwDocShell::CreateDocumentInfoDialog(
return pDlg;
}
+void SwDocShell::addFormula( uno::Reference< embed::XEmbeddedObject > p )
+{
+ SfxObjectShell& mrPers = *GetDoc()->GetPersist();
+ uno::Reference < container::XChild > xChild( p, uno::UNO_QUERY );
+ if ( xChild.is() )
+ xChild->setParent( mrPers.GetModel() );
+ ::rtl::OUString rName;
+ bool bSuccess = mrPers.GetEmbeddedObjectContainer().InsertEmbeddedObject( p, rName );
+ if (bSuccess)
+ {}
+}
+
// Disable "multiple layout"
void SwDocShell::ToggleBrowserMode(sal_Bool bSet, SwView* _pView )
diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
index b55cc3f4f463..4b57686d48a3 100644
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -409,6 +409,11 @@ SwXTextDocument::~SwXTextDocument()
delete m_pRenderData;
}
+void SwXTextDocument::addFormula( uno::Reference< embed::XEmbeddedObject > p )
+{
+ pDocShell->addFormula(p);
+}
+
SwXDocumentPropertyHelper * SwXTextDocument::GetPropertyHelper ()
{
if(!xPropertyHelper.is())
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index f7ede2a85c39..59d05155f84f 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -76,6 +76,7 @@
#include <com/sun/star/text/WritingMode2.hpp>
#include <com/sun/star/text/XFootnote.hpp>
#include <com/sun/star/style/NumberingType.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <comphelper/types.hxx>
#include <comphelper/storagehelper.hxx>
@@ -1195,12 +1196,19 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
case NS_rtf::LN_blip: // contains the binary graphic
case NS_ooxml::LN_shape:
{
+ fprintf(stderr,"SHAPE3\n");
//looks a bit like a hack - and it is. The graphic import is split into the inline_inline part and
//afterwards the adding of the binary data.
m_pImpl->GetGraphicImport( IMPORT_AS_DETECTED_INLINE )->attribute(nName, val);
m_pImpl->ImportGraphic( val.getProperties(), IMPORT_AS_DETECTED_INLINE );
}
break;
+ case NS_ooxml::LN_starmath:
+ {
+ fprintf(stderr,"STARMATH3\n");
+ m_pImpl->appendStarMath( val );
+ break;
+ }
case NS_ooxml::LN_CT_FramePr_dropCap:
case NS_ooxml::LN_CT_FramePr_lines:
case NS_ooxml::LN_CT_FramePr_hAnchor:
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index a77d838f96e4..f358ea13d1fd 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -25,6 +25,9 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
+
+#include <oox/export/starmathimport.hxx>
+
#include <DomainMapper_Impl.hxx>
#include <ConversionHelper.hxx>
#include <DomainMapperTableHandler.hxx>
@@ -70,6 +73,7 @@
#include <com/sun/star/util/DateTime.hpp>
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
#include <com/sun/star/util/XNumberFormats.hpp>
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <rtl/ustrbuf.hxx>
#include <rtl/string.h>
#include "FieldTypes.hxx"
@@ -1086,6 +1090,45 @@ void DomainMapper_Impl::appendOLE( const ::rtl::OUString& rStreamName, OLEHandle
}
}
+void DomainMapper_Impl::appendStarMath( const Value& val )
+{
+ fprintf(stderr,"SM 1 %s\n", typeid(*GetTextDocument().get()).name());
+ uno::Reference< embed::XEmbeddedObject > formula;
+ val.getAny() >>= formula;
+ if( formula.is() )
+ {
+ if( OoxmlFormulaImportBase* import = dynamic_cast< OoxmlFormulaImportBase* >( GetTextDocument().get()))
+ {
+ fprintf( stderr,"SM 3 %p\n", import );
+ import->addFormula( formula );
+ }
+ static const rtl::OUString sEmbeddedService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextEmbeddedObject"));
+ try
+ {
+ uno::Reference< text::XTextContent > xOLE( m_xTextFactory->createInstance(sEmbeddedService), uno::UNO_QUERY_THROW );
+ fprintf(stderr,"SM4\n");
+ uno::Reference< beans::XPropertySet > xOLEProperties(xOLE, uno::UNO_QUERY_THROW);
+ fprintf(stderr,"SM5\n");
+
+ sleep(10);
+ xOLEProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_STREAM_NAME ),
+ val.getAny());
+ fprintf(stderr,"SM6\n");
+ // mimic the treatment of graphics here.. it seems anchoring as character
+ // gives a better ( visually ) result
+ xOLEProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_ANCHOR_TYPE ), uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ) );
+ fprintf(stderr,"SM7\n");
+ appendTextContent( xOLE, uno::Sequence< beans::PropertyValue >() );
+ fprintf(stderr,"SM8\n");
+
+ }
+ catch( const uno::Exception& rEx )
+ {
+ (void)rEx;
+ OSL_FAIL( "Exception in creation of OLE object" );
+ }
+ }
+}
uno::Reference< beans::XPropertySet > DomainMapper_Impl::appendTextSectionAfter(
uno::Reference< text::XTextRange >& xBefore )
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index e3b3fa11e800..926caeacebcc 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -408,6 +408,7 @@ public:
void appendTextContent( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >,
const uno::Sequence< beans::PropertyValue > );
void appendOLE( const ::rtl::OUString& rStreamName, OLEHandlerPtr pOleHandler );
+ void appendStarMath( const Value& v );
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > appendTextSectionAfter(
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xBefore );
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 744361dfc494..4e9446b49a44 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -874,6 +874,7 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
break;
case NS_ooxml::LN_shape:
{
+ fprintf(stderr,"SHAPE2\n");
uno::Reference< drawing::XShape> xShape;
val.getAny( ) >>= xShape;
@@ -950,6 +951,9 @@ void GraphicImport::lcl_attribute(Id nName, Value & val)
}
}
break;
+ case NS_ooxml::LN_starmath:
+ fprintf(stderr,"STARMATH2\n");
+ break;
case NS_ooxml::LN_CT_Inline_distT:
case NS_ooxml::LN_CT_Inline_distB:
case NS_ooxml::LN_CT_Inline_distL:
diff --git a/writerfilter/source/dmapper/OLEHandler.cxx b/writerfilter/source/dmapper/OLEHandler.cxx
index 907e4a760b86..6e9cbbdaa0f3 100644
--- a/writerfilter/source/dmapper/OLEHandler.cxx
+++ b/writerfilter/source/dmapper/OLEHandler.cxx
@@ -102,6 +102,7 @@ void OLEHandler::lcl_attribute(Id rName, Value & rVal)
break;
case NS_ooxml::LN_shape:
{
+ fprintf(stderr,"SHAPE1\n");
uno::Reference< drawing::XShape > xTempShape;
rVal.getAny() >>= xTempShape;
if( xTempShape.is() )
@@ -134,6 +135,9 @@ void OLEHandler::lcl_attribute(Id rName, Value & rVal)
}
}
break;
+ case NS_ooxml::LN_starmath:
+ fprintf(stderr,"STARMATH1\n");
+ break;
default:
OSL_FAIL( "unknown attribute");
}
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index d87d17106815..173be40f5a61 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -317,6 +317,7 @@ const rtl::OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_HELP: sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Help")); break;
case PROP_HEADING_STYLE_NAME: sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeadingStyleName")); break;
case PROP_FRM_DIRECTION: sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FRMDirection")); break;
+ case PROP_EMBEDDED_OBJECT : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EmbeddedObject")); break;
}
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index 81afa294752c..dd20f065f11b 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -290,6 +290,7 @@ enum PropertyIds
,PROP_WIDTH_TYPE
,PROP_WRITING_MODE
/*253*/ ,PROP_FRM_DIRECTION
+ ,PROP_EMBEDDED_OBJECT
};
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier
diff --git a/writerfilter/source/ooxml/OOXMLFactory.hxx b/writerfilter/source/ooxml/OOXMLFactory.hxx
index 28dda006ec43..ce892b457cf2 100644
--- a/writerfilter/source/ooxml/OOXMLFactory.hxx
+++ b/writerfilter/source/ooxml/OOXMLFactory.hxx
@@ -62,6 +62,7 @@ enum ResourceType_t {
RT_TextTableRow,
RT_TextTable,
RT_PropertyTable,
+ RT_Math,
RT_Any
};
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index b38da42943a1..10a0331d6668 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -39,6 +39,9 @@
#include <ooxml/OOXMLnamespaceids.hxx>
#include <dmapper/DomainMapper.hxx>
#include <GraphicHelpers.hxx>
+#include <comphelper/embeddedobjectcontainer.hxx>
+#include <tools/globname.hxx>
+#include <comphelper/classids.hxx>
#include "OOXMLFastContextHandler.hxx"
#include "OOXMLFactory.hxx"
#include "Handler.hxx"
@@ -1902,6 +1905,7 @@ OOXMLFastContextHandlerShape::OOXMLFastContextHandlerShape
(RTL_CONSTASCII_USTRINGPARAM
("com.sun.star.xml.sax.FastShapeContextHandler")), xContext),
uno::UNO_QUERY);
+ fprintf(stderr," XXX %s\n", typeid(*mrShapeContext.get()).name());
getDocument()->setShapeContext( mrShapeContext );
}
@@ -2361,6 +2365,66 @@ Token_t OOXMLFastContextHandlerWrapper::getToken() const
return nResult;
}
+
+/*
+ class OOXMLFastContextHandlerMath
+ */
+
+OOXMLFastContextHandlerMath::OOXMLFastContextHandlerMath(OOXMLFastContextHandler* pContext)
+ : OOXMLFastContextHandlerProperties(pContext)
+{
+ fprintf( stderr, "MMM ctor\n" );
+}
+
+OOXMLFastContextHandlerMath::~OOXMLFastContextHandlerMath()
+{
+ fprintf( stderr, "MMM dtor\n" );
+ SvGlobalName name( SO3_SM_CLASSID );
+ comphelper::EmbeddedObjectContainer container;
+ rtl::OUString aName; // TODO?
+ uno::Reference< embed::XEmbeddedObject > ref = container.CreateEmbeddedObject( name.GetByteSequence(), aName );
+ if (isForwardEvents())
+ {
+ OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
+ OOXMLValue::Pointer_t pVal( new OOXMLStarMathValue( ref ));
+ OOXMLProperty::Pointer_t pProp( new OOXMLPropertyImpl( NS_ooxml::LN_starmath, pVal, OOXMLPropertyImpl::ATTRIBUTE ));
+ pProps->add( pProp );
+ mpStream->props( writerfilter::Reference< Properties >::Pointer_t( pProps ));
+ }
+}
+
+void OOXMLFastContextHandlerMath::lcl_startFastElement(Token_t Element,
+ const uno::Reference< xml::sax::XFastAttributeList >& Attribs)
+ throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ fprintf( stderr, "MMM start %d\n", Element );
+}
+
+void OOXMLFastContextHandlerMath::lcl_endFastElement(Token_t Element)
+ throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ fprintf( stderr, "MMM end %d\n", Element );
+ OOXMLFastContextHandlerProperties::lcl_endFastElement( Element );
+}
+
+uno::Reference< xml::sax::XFastContextHandler >
+OOXMLFastContextHandlerMath::lcl_createFastChildContext(Token_t Element,
+ const uno::Reference< xml::sax::XFastAttributeList >& Attribs)
+ throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ fprintf( stderr, "MMM child %d\n", Element );
+ uno::Reference< xml::sax::XFastContextHandler > xContextHandler;
+ xContextHandler.set( this );
+ return xContextHandler;
+}
+
+void OOXMLFastContextHandlerMath::lcl_characters(const ::rtl::OUString& aChars)
+ throw (uno::RuntimeException, xml::sax::SAXException)
+{
+ fprintf( stderr, "MMM chars %s\n", rtl::OUStringToOString( aChars, RTL_TEXTENCODING_UTF8 ).getStr());
+}
+
+
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index b2f82c80fbe1..9f7c082c98ac 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -42,6 +42,7 @@
#include "OOXMLDocumentImpl.hxx"
#include "RefAndPointer.hxx"
#include <ooxml/OOXMLFastTokens.hxx>
+#include <svtools/embedhlp.hxx>
namespace writerfilter {
namespace ooxml
@@ -636,6 +637,30 @@ private:
OOXMLFastContextHandler * getFastContextHandler() const;
};
+
+
+class OOXMLFastContextHandlerMath: public OOXMLFastContextHandlerProperties
+{
+public:
+ explicit OOXMLFastContextHandlerMath(OOXMLFastContextHandler * pContext);
+ virtual ~OOXMLFastContextHandlerMath();
+
+ virtual string getType() const { return "Math"; }
+
+protected:
+ virtual void lcl_startFastElement(Token_t Element, const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
+ throw (uno::RuntimeException, xml::sax::SAXException);
+
+ virtual void lcl_endFastElement(Token_t Element) throw (uno::RuntimeException, xml::sax::SAXException);
+
+ virtual uno::Reference< xml::sax::XFastContextHandler > lcl_createFastChildContext(Token_t Element,
+ const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
+ throw (uno::RuntimeException, xml::sax::SAXException);
+
+ virtual void lcl_characters(const ::rtl::OUString & aChars) throw (uno::RuntimeException, xml::sax::SAXException);
+};
+
+
}}
#endif // INCLUDED_OOXML_FAST_CONTEXT_HANDLER_HXX
diff --git a/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx b/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx
index 384ab9ca4652..52dd4b7f1abf 100644
--- a/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx
@@ -690,6 +690,35 @@ OOXMLValue * OOXMLShapeValue::clone() const
}
/*
+ class OOXMLStarMathValue
+ */
+
+
+OOXMLStarMathValue::OOXMLStarMathValue( uno::Reference< embed::XEmbeddedObject > c )
+: component(c)
+{
+}
+
+OOXMLStarMathValue::~OOXMLStarMathValue()
+{
+}
+
+uno::Any OOXMLStarMathValue::getAny() const
+{
+ return uno::Any(component);
+}
+
+string OOXMLStarMathValue::toString() const
+{
+ return "StarMath";
+}
+
+OOXMLValue * OOXMLStarMathValue::clone() const
+{
+ return new OOXMLStarMathValue( component );
+}
+
+/*
class OOXMLTableImpl
*/
diff --git a/writerfilter/source/ooxml/OOXMLPropertySetImpl.hxx b/writerfilter/source/ooxml/OOXMLPropertySetImpl.hxx
index 34824101431d..84ecb930caed 100644
--- a/writerfilter/source/ooxml/OOXMLPropertySetImpl.hxx
+++ b/writerfilter/source/ooxml/OOXMLPropertySetImpl.hxx
@@ -31,6 +31,7 @@
#include <vector>
#include "OOXMLPropertySet.hxx"
#include "OOXMLBinaryObjectReference.hxx"
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
namespace com {
namespace sun {
@@ -235,6 +236,19 @@ public:
virtual OOXMLValue * clone() const;
};
+class OOXMLStarMathValue : public OOXMLValue
+{
+protected:
+ uno::Reference< embed::XEmbeddedObject > component;
+public:
+ explicit OOXMLStarMathValue( uno::Reference< embed::XEmbeddedObject > component );
+ virtual ~OOXMLStarMathValue();
+
+ virtual uno::Any getAny() const;
+ virtual string toString() const;
+ virtual OOXMLValue * clone() const;
+};
+
class OOXMLTableImpl : public OOXMLTable
{
public:
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 81d7794074b5..0a1d77a8b065 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -20,6 +20,7 @@
<token tokenid="ooxml:object"/>
<token tokenid="ooxml:tblStart"/>
<token tokenid="ooxml:ffdata"/>
+ <token tokenid="ooxml:starmath"/>
<namespace name="dml-stylesheet" url="http://schemas.openxmlformats.org/drawingml/2006/main" file="dml-stylesheet.rng">
<start name="theme"/>
<start name="themeOverride"/>
@@ -23622,5 +23623,6 @@
<resource name="document" resource="Stream" tag="content"/>
<resource name="glossaryDocument" resource="Stream" tag="content"/>
<resource name="CT_TxbxContent" resource="Stream" tag="shape"/>
+ <resource name="CT_OMath" resource="Math" tag="math"/>
</namespace>
</model>