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


On Tuesday 16 of August 2011, Caolán McNamara wrote:
On Mon, 2011-08-15 at 17:16 +0200, Lubos Lunak wrote:
I already have a pointer to SmModel and SmDocShell (I can get it the same
way the .doc code does) and just need to call their method, passing the
XML serializer object as an argument, that's it.

Probably matters what the destination format is like ? Is it a
standalone thing and/or exists in a substorage/folder of the parent
format where it doesn't care about what it is inside ? i.e. I'd sort of
expect to basically just add another export filter to starmath for
whatever that format is, add it to SmDocShell::ConvertTo and call that
directly/indirectly. And have a save as... entry for the format if it
makes sense to have it standalone ?

 The destination format is OOXML, and the formula is a part of one .xml file. 
It is standalone in the way that the whole formula is stored by starmath 
using Sm* classes and the XML subtree can be written out independently on the 
rest of the file. It is not standalone in the way that is it part of the .xml 
file and needs to be positioned inside the proper XML elements of the writer 
document.

 So using private streams is either not possible or only a complication 
depending on whether two sax_fastparser::FastSerializerHelper objects can be 
nested (I don't feel like trying, for these reasons). A standalone export 
file also wouldn't be right, as the formula needs to be inside a valid 
document.

That's not going to work if the destination format needs hooks back into
its surrounding container. Is that the problem ?

 No, starmath doesn't need to call back to writer. The problem is that this is 
still needlessly complicated. How about the attached patch?

-- 
 Lubos Lunak
 l.lunak@suse.cz
diff --git a/filter/inc/filter/msfilter/ooxmlexport.hxx b/filter/inc/filter/msfilter/ooxmlexport.hxx
new file mode 100644
index 0000000..6ec0594
--- /dev/null
+++ b/filter/inc/filter/msfilter/ooxmlexport.hxx
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _OOXMLEXPORT_HXX
+#define _OOXMLEXPORT_HXX
+
+#include <sax/fshelper.hxx>
+#include "filter/msfilter/msfilterdllapi.h"
+
+/**
+ Interface class, StarMath will implement writeFormulaOoxml() to write out OOXML
+ representing the formula.
+ */
+class MSFILTER_DLLPUBLIC OoxmlFormulaExportBase
+{
+public:
+    virtual void writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer ) = 0;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk
index 034bf60..ce22bc5 100644
--- a/starmath/Library_sm.mk
+++ b/starmath/Library_sm.mk
@@ -47,7 +47,9 @@ $(eval $(call gb_Library_add_linked_libs,sm,\
         cppuhelper \
         editeng \
        i18npaper \
+        msfilter \
         sal \
+        sax \
         sfx \
         sot \
         svl \
diff --git a/starmath/inc/unomodel.hxx b/starmath/inc/unomodel.hxx
index 693ea3b..15ada7b 100644
--- a/starmath/inc/unomodel.hxx
+++ b/starmath/inc/unomodel.hxx
@@ -37,6 +37,7 @@
 #include <sfx2/sfxbasemodel.hxx>
 #include <comphelper/propertysethelper.hxx>
 #include <vcl/print.hxx>
+#include <filter/msfilter/ooxmlexport.hxx>
 
 class SmFormat;
 
@@ -63,7 +64,8 @@ public:
 class SmModel : public SfxBaseModel,
                 public comphelper::PropertySetHelper,
                 public com::sun::star::lang::XServiceInfo,
-                public com::sun::star::view::XRenderable
+                public com::sun::star::view::XRenderable,
+                public OoxmlFormulaExportBase
 {
     SmPrintUIOptions* m_pPrintUIOptions;
 protected:
@@ -100,6 +102,9 @@ public:
 
     virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< 
::com::sun::star::uno::XInterface >& xParent ) throw( ::com::sun::star::lang::NoSupportException, 
::com::sun::star::uno::RuntimeException );
 
+    // OoxmlFormulaExportBase
+    virtual void writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer );
+
     static ::com::sun::star::uno::Sequence< rtl::OUString > getSupportedServiceNames_Static();
     static ::rtl::OUString getImplementationName_Static();
 };
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 8ee267e..d44485a 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -1132,4 +1132,9 @@ void SAL_CALL SmModel::setParent( const uno::Reference< uno::XInterface >& 
xPare
     }
 }
 
+void SmModel::writeFormulaOoxml( ::sax_fastparser::FSHelperPtr m_pSerializer )
+{
+    static_cast< SmDocShell* >( GetObjectShell())->writeFormulaOoxml( m_pSerializer );
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index b2c4391..fcd303a 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -45,6 +45,7 @@
 #include <oox/export/drawingml.hxx>
 #include <oox/export/utils.hxx>
 #include <oox/export/vmlexport.hxx>
+#include <filter/msfilter/ooxmlexport.hxx>
 
 #include <i18npool/mslangid.hxx>
 
@@ -2301,7 +2302,11 @@ bool DocxAttributeOutput::WriteOLEMath( const SdrObject*, const SwOLENode& 
rOLEN
 
     if( !SotExchange::IsMath(aObjName) )
         return false;
-    // TODO
+    uno::Reference< uno::XInterface > xInterface( aObjRef->getComponent(), uno::UNO_QUERY );
+    OoxmlFormulaExportBase* formulaexport = dynamic_cast< OoxmlFormulaExportBase* >( 
xInterface.get());
+    if( formulaexport == NULL )
+        return false;
+    formulaexport->writeFormulaOoxml( m_pSerializer );
     return true;
 }
 

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.