summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/edit.hxx1
-rw-r--r--starmath/inc/node.hxx17
-rw-r--r--starmath/inc/unomodel.hxx14
-rw-r--r--starmath/inc/view.hxx3
-rw-r--r--starmath/prj/build.lst2
-rw-r--r--starmath/sdi/makefile.mk3
-rw-r--r--starmath/sdi/smath.sdi20
-rw-r--r--starmath/source/accessibility.cxx46
-rw-r--r--starmath/source/accessibility.hxx2
-rw-r--r--starmath/source/cfgitem.cxx29
-rw-r--r--starmath/source/cfgitem.hxx4
-rw-r--r--starmath/source/commands.src1
-rw-r--r--starmath/source/document.cxx129
-rw-r--r--starmath/source/edit.cxx13
-rw-r--r--starmath/source/makefile.mk10
-rw-r--r--starmath/source/mathmlexport.cxx1568
-rw-r--r--starmath/source/mathmlexport.hxx146
-rw-r--r--starmath/source/mathmlimport.cxx (renamed from starmath/source/mathml.cxx)7653
-rw-r--r--starmath/source/mathmlimport.hxx (renamed from starmath/source/mathml.hxx)791
-rw-r--r--starmath/source/mathtype.cxx4
-rw-r--r--starmath/source/node.cxx42
-rw-r--r--starmath/source/parse.cxx60
-rw-r--r--starmath/source/smdetect.cxx4
-rw-r--r--starmath/source/smres.src4
-rw-r--r--starmath/source/types.cxx3
-rw-r--r--starmath/source/unomodel.cxx37
-rw-r--r--starmath/source/view.cxx90
-rw-r--r--starmath/source/viewhdl.cxx170
-rw-r--r--starmath/util/makefile.mk1
29 files changed, 5515 insertions, 5352 deletions
diff --git a/starmath/inc/edit.hxx b/starmath/inc/edit.hxx
index fe3b61a96485..d453fc6216e5 100644
--- a/starmath/inc/edit.hxx
+++ b/starmath/inc/edit.hxx
@@ -99,6 +99,7 @@ class SmEditWindow : public Window, public DropTargetHelper
Rectangle AdjustScrollBars();
void SetScrollBarRanges();
void InitScrollBars();
+ void InvalidateSlots();
public:
SmEditWindow( SmCmdBoxWindow &rMyCmdBoxWin );
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index c70d75242e36..867c9508a074 100644
--- a/starmath/inc/node.hxx
+++ b/starmath/inc/node.hxx
@@ -33,7 +33,7 @@
#define NODE_HXX
-#include <tools/dynary.hxx>
+#include <vector>
#include "parse.hxx"
#include "types.hxx"
@@ -63,9 +63,12 @@
extern SmFormat *pActiveFormat;
class SmDocShell;
-
class SmNode;
-DECLARE_DYNARRAY(SmNodeArray, SmNode *)
+class SmStructureNode;
+
+typedef std::vector< SmNode * > SmNodeArray;
+typedef std::vector< SmStructureNode * > SmStructureNodeArray;
+
////////////////////////////////////////////////////////////////////////////////
@@ -185,9 +188,6 @@ public:
////////////////////////////////////////////////////////////////////////////////
-class SmStructureNode;
-
-DECLARE_DYNARRAY(SmStructureNodeArray, SmStructureNode *)
class SmStructureNode : public SmNode
{
@@ -205,12 +205,11 @@ public:
virtual BOOL IsVisible() const;
virtual USHORT GetNumSubNodes() const;
- void SetNumSubNodes(USHORT nSize) { aSubNodes.SetSize(nSize); }
+ void SetNumSubNodes(USHORT nSize) { aSubNodes.resize(nSize); }
using SmNode::GetSubNode;
virtual SmNode * GetSubNode(USHORT nIndex);
- void SetSubNodes(SmNode *pFirst, SmNode *pSecond,
- SmNode *pThird = NULL);
+ void SetSubNodes(SmNode *pFirst, SmNode *pSecond, SmNode *pThird = NULL);
void SetSubNodes(const SmNodeArray &rNodeArray);
virtual SmStructureNode & operator = ( const SmStructureNode &rNode );
diff --git a/starmath/inc/unomodel.hxx b/starmath/inc/unomodel.hxx
index 2b3808ae4ca4..50cdc372d593 100644
--- a/starmath/inc/unomodel.hxx
+++ b/starmath/inc/unomodel.hxx
@@ -40,6 +40,8 @@
class SmFormat;
+#define A2OU(pText) rtl::OUString::createFromAscii(pText)
+
//-----------------------------------------------------------------------------
class SmModel : public SfxBaseModel,
public comphelper::PropertySetHelper,
@@ -74,15 +76,11 @@ public:
virtual void SAL_CALL render( sal_Int32 nRenderer, const ::com::sun::star::uno::Any& rSelection, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rxOptions ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
//XServiceInfo
- virtual rtl::OUString SAL_CALL getImplementationName(void)
- throw( ::com::sun::star::uno::RuntimeException );
- virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName)
- throw( ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void)
- throw( ::com::sun::star::uno::RuntimeException );
+ virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
- 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 );
+ 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 );
static ::com::sun::star::uno::Sequence< rtl::OUString > getSupportedServiceNames_Static();
static ::rtl::OUString getImplementationName_Static();
diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx
index 305f5ac873d8..8c89d9517898 100644
--- a/starmath/inc/view.hxx
+++ b/starmath/inc/view.hxx
@@ -228,9 +228,8 @@ class SmViewShell: public SfxViewShell
SmViewShell_Impl* pImpl;
BOOL bPasteState;
- void AddRemoveClipboardListener( BOOL bAdd );
-
DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
protected:
diff --git a/starmath/prj/build.lst b/starmath/prj/build.lst
index 1f9be53b5b2e..cb6fd9358454 100644
--- a/starmath/prj/build.lst
+++ b/starmath/prj/build.lst
@@ -1,4 +1,4 @@
-sm starmath : svx NULL
+sm starmath : l10n svx NULL
sm starmath usr1 - all sm_mkout NULL
sm starmath\inc nmake - all sm_inc NULL
sm starmath\prj get - all sm_prj NULL
diff --git a/starmath/sdi/makefile.mk b/starmath/sdi/makefile.mk
index a10a81adaec9..768280af9747 100644
--- a/starmath/sdi/makefile.mk
+++ b/starmath/sdi/makefile.mk
@@ -39,7 +39,7 @@ SVSDIINC=$(PRJ)$/inc
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
-
+.IF "$(L10N_framework)"==""
# --- Files --------------------------------------------------------
@@ -52,6 +52,7 @@ SVSDI1DEPEND= \
$(SVSDIINC)$/starmath.hrc
# --- Targets -------------------------------------------------------
+.ENDIF
.INCLUDE : target.mk
diff --git a/starmath/sdi/smath.sdi b/starmath/sdi/smath.sdi
index c3d10fe5e104..04c061359ada 100644
--- a/starmath/sdi/smath.sdi
+++ b/starmath/sdi/smath.sdi
@@ -32,7 +32,7 @@ SfxVoidItem Adjust SID_ADJUST
[
/* flags: */
AutoUpdate = FALSE,
- Cachable = Volatile,
+ Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
@@ -259,7 +259,7 @@ SfxVoidItem Draw SID_DRAW
[
/* flags: */
AutoUpdate = FALSE,
- Cachable = Volatile,
+ Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
@@ -488,7 +488,7 @@ SfxVoidItem NextError SID_NEXTERR
[
/* flags: */
AutoUpdate = FALSE,
- Cachable = Volatile,
+ Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
@@ -513,7 +513,7 @@ SfxVoidItem NextMark SID_NEXTMARK
[
/* flags: */
AutoUpdate = FALSE,
- Cachable = Volatile,
+ Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
@@ -563,7 +563,7 @@ SfxVoidItem PrevError SID_PREVERR
[
/* flags: */
AutoUpdate = FALSE,
- Cachable = Volatile,
+ Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
@@ -588,7 +588,7 @@ SfxVoidItem PrevMark SID_PREVMARK
[
/* flags: */
AutoUpdate = FALSE,
- Cachable = Volatile,
+ Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
@@ -612,8 +612,8 @@ SfxBoolItem RedrawAutomatic SID_AUTO_REDRAW
[
/* flags: */
- AutoUpdate = FALSE,
- Cachable = Volatile,
+ AutoUpdate = TRUE,
+ Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
@@ -740,7 +740,7 @@ SfxBoolItem Textmode SID_TEXTMODE
[
/* flags: */
AutoUpdate = TRUE,
- Cachable = Volatile,
+ Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
@@ -819,7 +819,7 @@ SfxBoolItem ToolBox SID_TOOLBOX
[
/* flags: */
AutoUpdate = FALSE,
- Cachable = Volatile,
+ Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index 42bb5015b55f..f258d7f31176 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -72,7 +72,7 @@ using namespace com::sun::star::lang;
using namespace com::sun::star::uno;
using namespace com::sun::star::accessibility;
-#define C2U(cChar) rtl::OUString::createFromAscii(cChar)
+#define A2OU(cChar) rtl::OUString::createFromAscii(cChar)
//////////////////////////////////////////////////////////////////////
@@ -824,7 +824,7 @@ OUString SAL_CALL SmGraphicAccessible::getImplementationName()
throw (RuntimeException)
{
//vos::OGuard aGuard(Application::GetSolarMutex());
- return C2U("SmGraphicAccessible");
+ return A2OU("SmGraphicAccessible");
}
sal_Bool SAL_CALL SmGraphicAccessible::supportsService(
@@ -832,10 +832,10 @@ sal_Bool SAL_CALL SmGraphicAccessible::supportsService(
throw (RuntimeException)
{
//vos::OGuard aGuard(Application::GetSolarMutex());
- return rServiceName == C2U( "com::sun::star::accessibility::Accessible" ) ||
- rServiceName == C2U( "com::sun::star::accessibility::AccessibleComponent" ) ||
- rServiceName == C2U( "com::sun::star::accessibility::AccessibleContext" ) ||
- rServiceName == C2U( "com::sun::star::accessibility::AccessibleText" );
+ return rServiceName == A2OU( "com::sun::star::accessibility::Accessible" ) ||
+ rServiceName == A2OU( "com::sun::star::accessibility::AccessibleComponent" ) ||
+ rServiceName == A2OU( "com::sun::star::accessibility::AccessibleContext" ) ||
+ rServiceName == A2OU( "com::sun::star::accessibility::AccessibleText" );
}
Sequence< OUString > SAL_CALL SmGraphicAccessible::getSupportedServiceNames()
@@ -844,10 +844,10 @@ Sequence< OUString > SAL_CALL SmGraphicAccessible::getSupportedServiceNames()
//vos::OGuard aGuard(Application::GetSolarMutex());
Sequence< OUString > aNames(4);
OUString *pNames = aNames.getArray();
- pNames[0] = C2U( "com::sun::star::accessibility::Accessible" );
- pNames[1] = C2U( "com::sun::star::accessibility::AccessibleComponent" );
- pNames[2] = C2U( "com::sun::star::accessibility::AccessibleContext" );
- pNames[3] = C2U( "com::sun::star::accessibility::AccessibleText" );
+ pNames[0] = A2OU( "com::sun::star::accessibility::Accessible" );
+ pNames[1] = A2OU( "com::sun::star::accessibility::AccessibleComponent" );
+ pNames[2] = A2OU( "com::sun::star::accessibility::AccessibleContext" );
+ pNames[3] = A2OU( "com::sun::star::accessibility::AccessibleText" );
return aNames;
}
@@ -1444,6 +1444,18 @@ USHORT SmTextForwarder::GetLineLen( USHORT nPara, USHORT nLine ) const
return pEditEngine ? pEditEngine->GetLineLen(nPara, nLine) : 0;
}
+void SmTextForwarder::GetLineBoundaries( /*out*/USHORT &rStart, /*out*/USHORT &rEnd, USHORT nPara, USHORT nLine ) const
+{
+ EditEngine *pEditEngine = rEditAcc.GetEditEngine();
+ pEditEngine->GetLineBoundaries(rStart, rEnd, nPara, nLine);
+}
+
+USHORT SmTextForwarder::GetLineNumberAtIndex( USHORT nPara, USHORT nIndex ) const
+{
+ EditEngine *pEditEngine = rEditAcc.GetEditEngine();
+ return pEditEngine ? pEditEngine->GetLineNumberAtIndex(nPara, nIndex) : 0;
+}
+
sal_Bool SmTextForwarder::QuickFormatDoc( BOOL /*bFull*/ )
{
sal_Bool bRes = sal_False;
@@ -2026,7 +2038,7 @@ OUString SAL_CALL SmEditAccessible::getImplementationName()
throw (RuntimeException)
{
//vos::OGuard aGuard(Application::GetSolarMutex());
- return C2U("SmEditAccessible");
+ return A2OU("SmEditAccessible");
}
sal_Bool SAL_CALL SmEditAccessible::supportsService(
@@ -2034,9 +2046,9 @@ sal_Bool SAL_CALL SmEditAccessible::supportsService(
throw (RuntimeException)
{
//vos::OGuard aGuard(Application::GetSolarMutex());
- return rServiceName == C2U( "com::sun::star::accessibility::Accessible" ) ||
- rServiceName == C2U( "com::sun::star::accessibility::AccessibleComponent" ) ||
- rServiceName == C2U( "com::sun::star::accessibility::AccessibleContext" );
+ return rServiceName == A2OU( "com::sun::star::accessibility::Accessible" ) ||
+ rServiceName == A2OU( "com::sun::star::accessibility::AccessibleComponent" ) ||
+ rServiceName == A2OU( "com::sun::star::accessibility::AccessibleContext" );
}
Sequence< OUString > SAL_CALL SmEditAccessible::getSupportedServiceNames()
@@ -2045,9 +2057,9 @@ Sequence< OUString > SAL_CALL SmEditAccessible::getSupportedServiceNames()
//vos::OGuard aGuard(Application::GetSolarMutex());
Sequence< OUString > aNames(3);
OUString *pNames = aNames.getArray();
- pNames[0] = C2U( "com::sun::star::accessibility::Accessible" );
- pNames[1] = C2U( "com::sun::star::accessibility::AccessibleComponent" );
- pNames[2] = C2U( "com::sun::star::accessibility::AccessibleContext" );
+ pNames[0] = A2OU( "com::sun::star::accessibility::Accessible" );
+ pNames[1] = A2OU( "com::sun::star::accessibility::AccessibleComponent" );
+ pNames[2] = A2OU( "com::sun::star::accessibility::AccessibleContext" );
return aNames;
}
diff --git a/starmath/source/accessibility.hxx b/starmath/source/accessibility.hxx
index 3fcda91bd05c..7199583dd4ff 100644
--- a/starmath/source/accessibility.hxx
+++ b/starmath/source/accessibility.hxx
@@ -254,6 +254,8 @@ public:
virtual sal_Bool GetAttributeRun( USHORT& nStartIndex, USHORT& nEndIndex, USHORT nPara, USHORT nIndex ) const;
virtual USHORT GetLineCount( USHORT nPara ) const;
virtual USHORT GetLineLen( USHORT nPara, USHORT nLine ) const;
+ virtual void GetLineBoundaries( /*out*/USHORT &rStart, /*out*/USHORT &rEnd, USHORT nParagraph, USHORT nLine ) const;
+ virtual USHORT GetLineNumberAtIndex( USHORT nPara, USHORT nLine ) const;
virtual sal_Bool Delete( const ESelection& );
virtual sal_Bool InsertText( const String&, const ESelection& );
virtual sal_Bool QuickFormatDoc( BOOL bFull=FALSE );
diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx
index e6b540a9d092..175c41c173eb 100644
--- a/starmath/source/cfgitem.cxx
+++ b/starmath/source/cfgitem.cxx
@@ -580,19 +580,6 @@ void SmMathConfig::Save()
SaveFontFormatList();
}
-
-USHORT SmMathConfig::GetSymbolCount() const
-{
- return ((SmMathConfig *) this)->GetSymSetManager().GetSymbolCount();
-}
-
-
-const SmSym * SmMathConfig::GetSymbol( USHORT nIndex ) const
-{
- return ((SmMathConfig *) this)->GetSymSetManager().GetSymbolByPos( nIndex );
-}
-
-
void SmMathConfig::GetSymbols( std::vector< SmSym > &rSymbols ) const
{
Sequence< OUString > aNodes( ((SmMathConfig*) this)->GetNodeNames( A2OU( SYMBOL_LIST ) ) );
@@ -1261,22 +1248,6 @@ void SmMathConfig::SetIgnoreSpacesRight( BOOL bVal )
}
-BOOL SmMathConfig::IsToolboxVisible() const
-{
- if (!pOther)
- ((SmMathConfig *) this)->LoadOther();
- return pOther->bToolboxVisible;
-}
-
-
-void SmMathConfig::SetToolboxVisible( BOOL bVal )
-{
- if (!pOther)
- LoadOther();
- SetOtherIfNotEqual( pOther->bToolboxVisible, bVal );
-}
-
-
BOOL SmMathConfig::IsAutoRedraw() const
{
if (!pOther)
diff --git a/starmath/source/cfgitem.hxx b/starmath/source/cfgitem.hxx
index a6a82c65425a..4c028039ea5e 100644
--- a/starmath/source/cfgitem.hxx
+++ b/starmath/source/cfgitem.hxx
@@ -188,8 +188,6 @@ public:
SmSymSetManager & GetSymSetManager();
void GetSymbols( std::vector< SmSym > &rSymbols ) const;
void SetSymbols( const std::vector< SmSym > &rNewSymbols );
- USHORT GetSymbolCount() const;
- const SmSym * GetSymbol( USHORT nIndex ) const;
const SmFormat & GetStandardFormat() const;
void SetStandardFormat( const SmFormat &rFormat, BOOL bSaveFontFormatList = FALSE );
@@ -207,8 +205,6 @@ public:
BOOL IsIgnoreSpacesRight() const;
void SetIgnoreSpacesRight( BOOL bVal );
- BOOL IsToolboxVisible() const;
- void SetToolboxVisible( BOOL bVal );
BOOL IsAutoRedraw() const;
void SetAutoRedraw( BOOL bVal );
BOOL IsShowFormulaCursor() const;
diff --git a/starmath/source/commands.src b/starmath/source/commands.src
index 16e02a68f807..a154139160ab 100644
--- a/starmath/source/commands.src
+++ b/starmath/source/commands.src
@@ -35,7 +35,6 @@
////////////////////////////////////////////////////////////
-
String RID_PLUSX { Text = "+<?> " ; };
String RID_MINUSX { Text = "-<?> " ; };
String RID_PLUSMINUSX { Text = "+-<?> " ; };
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 546af49b2df1..ab467fc034e3 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -33,84 +33,79 @@
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/uno/Any.h>
+
+#include <comphelper/accessibletexthelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/storagehelper.hxx>
#include <rtl/logfile.hxx>
#include <rtl/ustring.hxx>
-#include <ucbhelper/content.hxx>
-#include <sot/formats.hxx>
-#include <sot/storage.hxx>
-#include <svtools/linguprops.hxx>
-#include <svtools/lingucfg.hxx>
-#include <svtools/smplhint.hxx>
-#include <svtools/pathoptions.hxx>
-#ifndef _SO_CLSIDS_HXX //autogen
+#include <sfx2/app.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/msg.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
#include <sot/clsids.hxx>
-#endif
#include <sot/exchange.hxx>
-#include <vcl/msgbox.hxx>
-
-#include <vcl/mapunit.hxx>
-#include <vcl/mapmod.hxx>
-#include <comphelper/storagehelper.hxx>
-#include <comphelper/processfactory.hxx>
-#include <comphelper/accessibletexthelper.hxx>
+#include <sot/formats.hxx>
+#include <sot/storage.hxx>
#include <svtools/eitem.hxx>
-#include <svtools/whiter.hxx>
+#include <svtools/fstathelper.hxx>
#include <svtools/intitem.hxx>
-#include <svtools/stritem.hxx>
+#include <svtools/itempool.hxx>
+#include <svtools/lingucfg.hxx>
+#include <svtools/linguprops.hxx>
+#include <svtools/pathoptions.hxx>
#include <svtools/ptitem.hxx>
+#include <svtools/sfxecode.hxx>
+#include <svtools/slstitm.hxx>
+#include <svtools/smplhint.hxx>
+#include <svtools/stritem.hxx>
+#include <svtools/transfer.hxx>
#include <svtools/undo.hxx>
-#include <svtools/itempool.hxx>
#include <svtools/urihelper.hxx>
-#include <svtools/fstathelper.hxx>
-#include <svtools/transfer.hxx>
-#include <sfx2/dispatch.hxx>
-#include <sfx2/docfile.hxx>
-#include <sfx2/app.hxx>
-#include <sfx2/request.hxx>
-#include <sfx2/viewfrm.hxx>
-#include <svtools/sfxecode.hxx>
-#include <sfx2/printer.hxx>
-#include <sfx2/docfilt.hxx>
-#include <svtools/itempool.hxx>
+#include <svtools/whiter.hxx>
#include <svx/editeng.hxx>
-#include <svx/eeitem.hxx>
#include <svx/editstat.hxx>
-#include <svx/fontitem.hxx>
+#include <svx/eeitem.hxx>
#include <svx/fhgtitem.hxx>
+#include <svx/fontitem.hxx>
#include <svx/unolingu.hxx>
-#include <svtools/slstitm.hxx>
-#include <com/sun/star/uno/Any.h>
-#include <com/sun/star/lang/Locale.hpp>
+#include <ucbhelper/content.hxx>
+#include <vcl/mapmod.hxx>
+#include <vcl/mapunit.hxx>
+#include <vcl/msgbox.hxx>
-#ifndef STARMATH_HRC
-#include <starmath.hrc>
-#endif
#include <document.hxx>
-#include <unomodel.hxx>
+#include <action.hxx>
#include <config.hxx>
+#include <dialog.hxx>
+#include <format.hxx>
+#include <smdll.hxx>
+#include <starmath.hrc>
#include <symbol.hxx>
#include <toolbox.hxx>
-#include <dialog.hxx>
-#include <action.hxx>
-#include <view.hxx>
+#include <unomodel.hxx>
#include <utility.hxx>
-#include <format.hxx>
-#include <mathtype.hxx>
-#include <mathml.hxx>
+#include <view.hxx>
+#include "mathtype.hxx"
+#include "mathmlimport.hxx"
+#include "mathmlexport.hxx"
-#include <smdll.hxx>
-#include <sfx2/fcontnr.hxx>
-#include <sfx2/msg.hxx>
-#include <sfx2/objface.hxx>
using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::ucb;
using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::accessibility;
-#define A2OU(x) rtl::OUString::createFromAscii( x )
#define DOCUMENT_BUFFER_SIZE (USHORT)32768
@@ -266,7 +261,7 @@ void SmDocShell::ArrangeFormula()
if (IsFormulaArranged())
return;
- //! Nur fr die Dauer der Existenz dieses Objekts sind am Drucker die
+ //! Nur f�r die Dauer der Existenz dieses Objekts sind am Drucker die
//! richtigen Einstellungen garantiert.
SmPrinterAccess aPrtAcc(*this);
// OutputDevice *pOutDev = aPrtAcc.GetPrinter();
@@ -279,7 +274,7 @@ void SmDocShell::ArrangeFormula()
#endif
}
- // falls ntig ein anderes OutputDevice holen fr das formatiert wird
+ // falls n�tig ein anderes OutputDevice holen f�r das formatiert wird
if (!pOutDev)
{
SmViewShell *pView = SmGetActiveView();
@@ -761,7 +756,7 @@ BOOL SmDocShell::ConvertFrom(SfxMedium &rMedium)
pTree = 0;
}
Reference<com::sun::star::frame::XModel> xModel(GetModel());
- SmXMLWrapper aEquation(xModel);
+ SmXMLImportWrapper aEquation(xModel);
bSuccess = 0 == aEquation.Import(rMedium);
}
else
@@ -820,7 +815,7 @@ BOOL SmDocShell::Load( SfxMedium& rMedium )
BOOL bRet = FALSE;
if( SfxObjectShell::Load( rMedium ))
{
- uno::Reference < embed::XStorage > xStorage = pMedium->GetStorage();
+ uno::Reference < embed::XStorage > xStorage = GetMedium()->GetStorage();
uno::Reference < container::XNameAccess > xAccess (xStorage, uno::UNO_QUERY);
if (
(
@@ -835,10 +830,10 @@ BOOL SmDocShell::Load( SfxMedium& rMedium )
{
// is this a fabulous math package ?
Reference<com::sun::star::frame::XModel> xModel(GetModel());
- SmXMLWrapper aEquation(xModel);
+ SmXMLImportWrapper aEquation(xModel);
ULONG nError = aEquation.Import(rMedium);
bRet = 0 == nError;
- SetError( nError );
+ SetError( nError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
}
}
@@ -870,7 +865,7 @@ BOOL SmDocShell::Save()
ArrangeFormula();
Reference<com::sun::star::frame::XModel> xModel(GetModel());
- SmXMLWrapper aEquation(xModel);
+ SmXMLExportWrapper aEquation(xModel);
aEquation.SetFlat(sal_False);
return aEquation.Export(*GetMedium());
}
@@ -943,7 +938,7 @@ BOOL SmDocShell::SaveAs( SfxMedium& rMedium )
ArrangeFormula();
Reference<com::sun::star::frame::XModel> xModel(GetModel());
- SmXMLWrapper aEquation(xModel);
+ SmXMLExportWrapper aEquation(xModel);
aEquation.SetFlat(sal_False);
bRet = aEquation.Export(rMedium);
}
@@ -967,14 +962,14 @@ BOOL SmDocShell::ConvertTo( SfxMedium &rMedium )
if(rFltName.EqualsAscii( STAROFFICE_XML ))
{
Reference<com::sun::star::frame::XModel> xModel(GetModel());
- SmXMLWrapper aEquation(xModel);
+ SmXMLExportWrapper aEquation(xModel);
aEquation.SetFlat(sal_False);
bRet = aEquation.Export(rMedium);
}
else if(rFltName.EqualsAscii( MATHML_XML ))
{
Reference<com::sun::star::frame::XModel> xModel(GetModel());
- SmXMLWrapper aEquation(xModel);
+ SmXMLExportWrapper aEquation(xModel);
aEquation.SetFlat(sal_True);
bRet = aEquation.Export(rMedium);
}
@@ -1181,9 +1176,21 @@ void SmDocShell::Execute(SfxRequest& rReq)
(pTmpUndoMgr->*fnDo)( 0 );
}
Repaint();
+ SfxViewFrame* pFrm = SfxViewFrame::GetFirst( this );
+ while( pFrm )
+ {
+ SfxBindings& rBind = pFrm->GetBindings();
+ rBind.Invalidate(SID_UNDO);
+ rBind.Invalidate(SID_REDO);
+ rBind.Invalidate(SID_REPEAT);
+ rBind.Invalidate(SID_CLEARHISTORY);
+ pFrm = SfxViewFrame::GetNext( *pFrm, this );
+ }
}
break;
}
+
+ rReq.Done();
}
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index d9c333611071..8435b7b5f35a 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -60,7 +60,7 @@
#include <svx/lrspitem.hxx>
#include <svtools/itemset.hxx>
#include <svx/fontitem.hxx>
-
+#include <sfx2/viewfrm.hxx>
#include "edit.hxx"
#include "view.hxx"
@@ -163,6 +163,13 @@ SmEditWindow::~SmEditWindow()
delete pScrollBox;
}
+void SmEditWindow::InvalidateSlots()
+{
+ SfxBindings& rBind = GetView()->GetViewFrame()->GetBindings();
+ rBind.Invalidate(SID_COPY);
+ rBind.Invalidate(SID_CUT);
+ rBind.Invalidate(SID_DELETE);
+}
SmViewShell * SmEditWindow::GetView()
{
@@ -317,6 +324,7 @@ void SmEditWindow::MouseButtonUp(const MouseEvent &rEvt)
// ggf FormulaCursor neu positionieren
CursorMoveTimerHdl(&aCursorMoveTimer);
+ InvalidateSlots();
}
void SmEditWindow::MouseButtonDown(const MouseEvent &rEvt)
@@ -460,6 +468,8 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt)
aModifyTimer.Start();
}
+
+ InvalidateSlots();
}
}
@@ -855,6 +865,7 @@ void SmEditWindow::SetSelection(const ESelection &rSel)
DBG_ASSERT( pEditView, "NULL pointer" );
if (pEditView)
pEditView->SetSelection(rSel);
+ InvalidateSlots();
}
BOOL SmEditWindow::IsEmpty() const
diff --git a/starmath/source/makefile.mk b/starmath/source/makefile.mk
index bb7d99a30ddb..53f6569dcf9c 100644
--- a/starmath/source/makefile.mk
+++ b/starmath/source/makefile.mk
@@ -63,7 +63,8 @@ SLO1FILES = \
$(SLO)$/dialog.obj \
$(SLO)$/document.obj \
$(SLO)$/mathtype.obj \
- $(SLO)$/mathml.obj \
+ $(SLO)$/mathmlimport.obj \
+ $(SLO)$/mathmlexport.obj \
$(SLO)$/format.obj \
$(SLO)$/node.obj \
$(SLO)$/parse.obj \
@@ -72,7 +73,6 @@ SLO1FILES = \
$(SLO)$/smmod.obj \
$(SLO)$/types.obj \
$(SLO)$/view.obj \
- $(SLO)$/viewhdl.obj \
$(SLO)$/edit.obj \
$(SLO)$/rect.obj \
$(SLO)$/unomodel.obj \
@@ -92,10 +92,12 @@ EXCEPTIONSFILES = \
$(SLO)$/accessibility.obj \
$(SLO)$/cfgitem.obj \
$(SLO)$/document.obj \
- $(SLO)$/mathml.obj \
+ $(SLO)$/node.obj \
+ $(SLO)$/parse.obj \
+ $(SLO)$/mathmlimport.obj \
+ $(SLO)$/mathmlexport.obj \
$(SLO)$/mathtype.obj \
$(SLO)$/view.obj \
- $(SLO)$/viewhdl.obj \
$(SLO)$/unomodel.obj \
$(SLO)$/smdetect.obj \
$(SLO)$/symbol.obj \
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
new file mode 100644
index 000000000000..9ddabab9c325
--- /dev/null
+++ b/starmath/source/mathmlexport.cxx
@@ -0,0 +1,1568 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: x $
+ * $Revision: 1.00 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_starmath.hxx"
+
+/*
+ Warning: The SvXMLElementExport helper class creates the beginning and
+ closing tags of xml elements in its constructor and destructor, so theres
+ hidden stuff going on, on occasion the ordering of these classes declarations
+ may be significant
+*/
+
+
+#include <com/sun/star/xml/sax/XErrorHandler.hpp>
+#include <com/sun/star/xml/sax/XEntityResolver.hpp>
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/xml/sax/XDTDHandler.hpp>
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XActiveDataControl.hpp>
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/packages/zip/ZipIOException.hpp>
+#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/uno/Any.h>
+
+#include <rtl/math.hxx>
+#include <sfx2/frame.hxx>
+#include <sfx2/docfile.hxx>
+#include <tools/debug.hxx>
+#include <tools/urlobj.hxx>
+#include <svtools/sfxecode.hxx>
+#include <svtools/saveopt.hxx>
+#include <svtools/stritem.hxx>
+#include <svtools/itemprop.hxx>
+#include <unotools/processfactory.hxx>
+#include <unotools/streamwrap.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/attrlist.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/xmlmetai.hxx>
+#include <osl/mutex.hxx>
+#include <comphelper/genericpropertyset.hxx>
+
+#include <memory>
+
+#include "mathmlexport.hxx"
+#include "mathtype.hxx"
+#include <starmath.hrc>
+#include <unomodel.hxx>
+#include <document.hxx>
+#include <utility.hxx>
+
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+using namespace ::xmloff::token;
+
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+#define EXPORT_SVC_NAME RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLExportFilter")
+
+#undef WANTEXCEPT
+
+
+////////////////////////////////////////////////////////////
+
+sal_Bool SmXMLExportWrapper::Export(SfxMedium &rMedium)
+{
+ sal_Bool bRet=sal_True;
+ uno::Reference<lang::XMultiServiceFactory>
+ xServiceFactory(utl::getProcessServiceFactory());
+ DBG_ASSERT(xServiceFactory.is(),"got no service manager");
+
+ //Get model
+ uno::Reference< lang::XComponent > xModelComp(xModel, uno::UNO_QUERY );
+
+ sal_Bool bEmbedded = sal_False;
+ uno::Reference <lang::XUnoTunnel> xTunnel;
+ xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
+ SmModel *pModel = reinterpret_cast<SmModel *>
+ (xTunnel->getSomething(SmModel::getUnoTunnelId()));
+
+ SmDocShell *pDocShell = pModel ?
+ static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0;
+ if ( pDocShell &&
+ SFX_CREATE_MODE_EMBEDDED == pDocShell->GetCreateMode() )
+ bEmbedded = sal_True;
+
+ uno::Reference<task::XStatusIndicator> xStatusIndicator;
+ if (!bEmbedded)
+ {
+ if (pDocShell /*&& pDocShell->GetMedium()*/)
+ {
+ DBG_ASSERT( pDocShell->GetMedium() == &rMedium,
+ "different SfxMedium found" );
+
+ SfxItemSet* pSet = rMedium.GetItemSet();
+ if (pSet)
+ {
+ const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(
+ pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
+ if (pItem)
+ pItem->GetValue() >>= xStatusIndicator;
+ }
+ }
+
+ // set progress range and start status indicator
+ if (xStatusIndicator.is())
+ {
+ sal_Int32 nProgressRange = bFlat ? 1 : 3;
+ xStatusIndicator->start(String(SmResId(STR_STATSTR_WRITING)),
+ nProgressRange);
+ }
+ }
+
+
+ // create XPropertySet with three properties for status indicator
+ comphelper::PropertyMapEntry aInfoMap[] =
+ {
+ { "UsePrettyPrinting", sizeof("UsePrettyPrinting")-1, 0,
+ &::getBooleanCppuType(),
+ beans::PropertyAttribute::MAYBEVOID, 0},
+ { "BaseURI", sizeof("BaseURI")-1, 0,
+ &::getCppuType( (OUString *)0 ),
+ beans::PropertyAttribute::MAYBEVOID, 0 },
+ { "StreamRelPath", sizeof("StreamRelPath")-1, 0,
+ &::getCppuType( (OUString *)0 ),
+ beans::PropertyAttribute::MAYBEVOID, 0 },
+ { "StreamName", sizeof("StreamName")-1, 0,
+ &::getCppuType( (OUString *)0 ),
+ beans::PropertyAttribute::MAYBEVOID, 0 },
+ { NULL, 0, 0, NULL, 0, 0 }
+ };
+ uno::Reference< beans::XPropertySet > xInfoSet(
+ comphelper::GenericPropertySet_CreateInstance(
+ new comphelper::PropertySetInfo( aInfoMap ) ) );
+
+ SvtSaveOptions aSaveOpt;
+ OUString sUsePrettyPrinting(RTL_CONSTASCII_USTRINGPARAM("UsePrettyPrinting"));
+ sal_Bool bUsePrettyPrinting( bFlat || aSaveOpt.IsPrettyPrinting() );
+ Any aAny;
+ aAny.setValue( &bUsePrettyPrinting, ::getBooleanCppuType() );
+ xInfoSet->setPropertyValue( sUsePrettyPrinting, aAny );
+
+ // Set base URI
+ OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("BaseURI") );
+ xInfoSet->setPropertyValue( sPropName, makeAny( rMedium.GetBaseURL( true ) ) );
+
+ sal_Int32 nSteps=0;
+ if (xStatusIndicator.is())
+ xStatusIndicator->setValue(nSteps++);
+ if (!bFlat) //Storage (Package) of Stream
+ {
+ uno::Reference < embed::XStorage > xStg = rMedium.GetOutputStorage();
+ sal_Bool bOASIS = ( SotStorage::GetVersion( xStg ) > SOFFICE_FILEFORMAT_60 );
+
+ // TODO/LATER: handle the case of embedded links gracefully
+ if ( bEmbedded ) //&& !pStg->IsRoot() )
+ {
+ OUString aName;
+ if ( rMedium.GetItemSet() )
+ {
+ const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
+ rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
+ if ( pDocHierarchItem )
+ aName = pDocHierarchItem->GetValue();
+ }
+
+ if ( aName.getLength() )
+ {
+ sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath"));
+ xInfoSet->setPropertyValue( sPropName, makeAny( aName ) );
+ }
+ }
+
+ if ( !bEmbedded )
+ {
+ if (xStatusIndicator.is())
+ xStatusIndicator->setValue(nSteps++);
+
+ bRet = WriteThroughComponent(
+ xStg, xModelComp, "meta.xml", xServiceFactory, xInfoSet,
+ (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaExporter"
+ : "com.sun.star.comp.Math.XMLMetaExporter"),
+ sal_False);
+ }
+ if ( bRet )
+ {
+ if (xStatusIndicator.is())
+ xStatusIndicator->setValue(nSteps++);
+
+ bRet = WriteThroughComponent(
+ xStg, xModelComp, "content.xml", xServiceFactory, xInfoSet,
+ "com.sun.star.comp.Math.XMLContentExporter");
+ }
+
+ if ( bRet )
+ {
+ if (xStatusIndicator.is())
+ xStatusIndicator->setValue(nSteps++);
+
+ bRet = WriteThroughComponent(
+ xStg, xModelComp, "settings.xml", xServiceFactory, xInfoSet,
+ (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsExporter"
+ : "com.sun.star.comp.Math.XMLSettingsExporter") );
+ }
+ }
+ else
+ {
+ SvStream *pStream = rMedium.GetOutStream();
+ uno::Reference<io::XOutputStream> xOut(
+ new utl::OOutputStreamWrapper(*pStream) );
+
+ if (xStatusIndicator.is())
+ xStatusIndicator->setValue(nSteps++);
+
+ bRet = WriteThroughComponent(
+ xOut, xModelComp, xServiceFactory, xInfoSet,
+ "com.sun.star.comp.Math.XMLContentExporter");
+ }
+
+ if (xStatusIndicator.is())
+ xStatusIndicator->end();
+
+ return bRet;
+}
+
+
+/// export through an XML exporter component (output stream version)
+sal_Bool SmXMLExportWrapper::WriteThroughComponent(
+ Reference<io::XOutputStream> xOutputStream,
+ Reference<XComponent> xComponent,
+ Reference<lang::XMultiServiceFactory> & rFactory,
+ Reference<beans::XPropertySet> & rPropSet,
+ const sal_Char* pComponentName )
+{
+ DBG_ASSERT(xOutputStream.is(), "I really need an output stream!");
+ DBG_ASSERT(xComponent.is(), "Need component!");
+ DBG_ASSERT(NULL != pComponentName, "Need component name!");
+
+ // get component
+ Reference< io::XActiveDataSource > xSaxWriter(
+ rFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.xml.sax.Writer") ),
+ UNO_QUERY );
+ DBG_ASSERT( xSaxWriter.is(), "can't instantiate XML writer" );
+ if (!xSaxWriter.is())
+ return sal_False;
+
+ // connect XML writer to output stream
+ xSaxWriter->setOutputStream( xOutputStream );
+
+ // prepare arguments (prepend doc handler to given arguments)
+ Reference<xml::sax::XDocumentHandler> xDocHandler( xSaxWriter,UNO_QUERY);
+
+ Sequence<Any> aArgs( 2 );
+ aArgs[0] <<= xDocHandler;
+ aArgs[1] <<= rPropSet;
+
+ // get filter component
+ Reference< document::XExporter > xExporter(
+ rFactory->createInstanceWithArguments(
+ OUString::createFromAscii(pComponentName), aArgs), UNO_QUERY);
+ DBG_ASSERT( xExporter.is(),
+ "can't instantiate export filter component" );
+ if ( !xExporter.is() )
+ return sal_False;
+
+
+ // connect model and filter
+ xExporter->setSourceDocument( xComponent );
+
+ // filter!
+ Reference < XFilter > xFilter( xExporter, UNO_QUERY );
+ uno::Sequence< PropertyValue > aProps(0);
+ xFilter->filter( aProps );
+
+ uno::Reference<lang::XUnoTunnel> xFilterTunnel;
+ xFilterTunnel = uno::Reference<lang::XUnoTunnel>
+ ( xFilter, uno::UNO_QUERY );
+ SmXMLExport *pFilter = reinterpret_cast< SmXMLExport * >(
+ sal::static_int_cast< sal_uIntPtr >(
+ xFilterTunnel->getSomething( SmXMLExport::getUnoTunnelId() )));
+ return pFilter ? pFilter->GetSuccess() : sal_True;
+}
+
+
+/// export through an XML exporter component (storage version)
+sal_Bool SmXMLExportWrapper::WriteThroughComponent(
+ const Reference < embed::XStorage >& xStorage,
+ Reference<XComponent> xComponent,
+ const sal_Char* pStreamName,
+ Reference<lang::XMultiServiceFactory> & rFactory,
+ Reference<beans::XPropertySet> & rPropSet,
+ const sal_Char* pComponentName,
+ sal_Bool bCompress
+ )
+{
+ DBG_ASSERT(xStorage.is(), "Need storage!");
+ DBG_ASSERT(NULL != pStreamName, "Need stream name!");
+
+ // open stream
+ Reference < io::XStream > xStream;
+ OUString sStreamName = OUString::createFromAscii(pStreamName);
+ try
+ {
+ xStream = xStorage->openStreamElement( sStreamName,
+ embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
+ }
+ catch ( uno::Exception& )
+ {
+ DBG_ERROR( "Can't create output stream in package!" );
+ return sal_False;
+ }
+
+ String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) );
+ OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") );
+ uno::Any aAny;
+ aAny <<= aMime;
+
+ uno::Reference < beans::XPropertySet > xSet( xStream, uno::UNO_QUERY );
+ xSet->setPropertyValue( aPropName, aAny );
+
+ if ( !bCompress )
+ {
+ aPropName = String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("Compressed") );
+ sal_Bool bFalse = sal_False;
+ aAny.setValue( &bFalse, ::getBooleanCppuType() );
+ xSet->setPropertyValue( aPropName, aAny );
+ }
+
+ // even plain stream must be encrypted in encrypted document
+ OUString aTmpPropName( RTL_CONSTASCII_USTRINGPARAM("UseCommonStoragePasswordEncryption") );
+ sal_Bool bTrue = sal_True;
+ aAny.setValue( &bTrue, ::getBooleanCppuType() );
+ xSet->setPropertyValue( aTmpPropName, aAny );
+
+ // set Base URL
+ if ( rPropSet.is() )
+ {
+ OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("StreamName") );
+ rPropSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
+ }
+
+ // write the stuff
+ sal_Bool bRet = WriteThroughComponent( xStream->getOutputStream(), xComponent, rFactory,
+ rPropSet, pComponentName );
+
+ // stream is closed by SAX parser
+ //if ( bRet )
+ // xStream->getOutputStream()->closeOutput();
+
+ return bRet;
+}
+
+////////////////////////////////////////////////////////////
+
+// #110680#
+SmXMLExport::SmXMLExport(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
+ sal_uInt16 nExportFlags)
+: SvXMLExport( xServiceFactory, MAP_INCH, XML_MATH, nExportFlags ) ,
+ pTree(0) ,
+ bSuccess(sal_False)
+{
+}
+
+sal_Int64 SAL_CALL SmXMLExport::getSomething(
+ const uno::Sequence< sal_Int8 >& rId )
+throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this));
+
+ return SvXMLExport::getSomething( rId );
+}
+
+const uno::Sequence< sal_Int8 > & SmXMLExport::getUnoTunnelId() throw()
+{
+ static uno::Sequence< sal_Int8 > * pSeq = 0;
+ if ( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+OUString SAL_CALL SmXMLExport_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLExporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SmXMLExport_getSupportedServiceNames()
+ throw()
+{
+ const OUString aServiceName( EXPORT_SVC_NAME );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SmXMLExport_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+ throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_ALL );
+ // EXPORT_OASIS is required here allthough there is no differrence between
+ // OOo and OASIS, because without the flag, a transformation to OOo would
+ // be chained in.
+ return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_ALL );
+}
+
+////////////////////////////////////////////////////////////
+
+OUString SAL_CALL SmXMLExportMetaOOO_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLMetaExporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SmXMLExportMetaOOO_getSupportedServiceNames()
+ throw()
+{
+ const OUString aServiceName( EXPORT_SVC_NAME );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SmXMLExportMetaOOO_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_META );
+ return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_META );
+}
+
+////////////////////////////////////////////////////////////
+
+OUString SAL_CALL SmXMLExportMeta_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisMetaExporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SmXMLExportMeta_getSupportedServiceNames()
+throw()
+{
+ const OUString aServiceName( EXPORT_SVC_NAME );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SmXMLExportMeta_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_META );
+ return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_META );
+}
+
+////////////////////////////////////////////////////////////
+
+OUString SAL_CALL SmXMLExportSettingsOOO_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLSettingsExporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SmXMLExportSettingsOOO_getSupportedServiceNames()
+throw()
+{
+ const OUString aServiceName( EXPORT_SVC_NAME );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SmXMLExportSettingsOOO_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_SETTINGS );
+ return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_SETTINGS );
+}
+
+////////////////////////////////////////////////////////////
+
+OUString SAL_CALL SmXMLExportSettings_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisSettingsExporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SmXMLExportSettings_getSupportedServiceNames()
+throw()
+{
+ const OUString aServiceName( EXPORT_SVC_NAME );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SmXMLExportSettings_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_SETTINGS );
+ return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_SETTINGS );
+}
+
+////////////////////////////////////////////////////////////
+
+OUString SAL_CALL SmXMLExportContent_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLContentExporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SmXMLExportContent_getSupportedServiceNames()
+ throw()
+{
+ const OUString aServiceName( EXPORT_SVC_NAME );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SmXMLExportContent_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_CONTENT );
+ // The EXPORT_OASIS flag is only required to avoid that a transformer is
+ // chanied in
+ return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_CONTENT );
+}
+
+////////////////////////////////////////////////////////////
+
+// XServiceInfo
+// override empty method from parent class
+rtl::OUString SAL_CALL SmXMLExport::getImplementationName()
+throw(uno::RuntimeException)
+{
+ OUString aTxt;
+ switch( getExportFlags() )
+ {
+ case EXPORT_META:
+ aTxt = SmXMLExportMeta_getImplementationName();
+ break;
+ case EXPORT_SETTINGS:
+ aTxt = SmXMLExportSettings_getImplementationName();
+ break;
+ case EXPORT_CONTENT:
+ aTxt = SmXMLExportContent_getImplementationName();
+ break;
+ case EXPORT_ALL:
+ default:
+ aTxt = SmXMLExport_getImplementationName();
+ break;
+ }
+ return aTxt;
+}
+
+sal_uInt32 SmXMLExport::exportDoc(enum XMLTokenEnum eClass)
+{
+ if ( (getExportFlags() & EXPORT_CONTENT) == 0 )
+ {
+ SvXMLExport::exportDoc( eClass );
+ }
+ else
+ {
+ uno::Reference <frame::XModel> xModel = GetModel();
+ uno::Reference <lang::XUnoTunnel> xTunnel;
+ xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
+ SmModel *pModel = reinterpret_cast<SmModel *>
+ (xTunnel->getSomething(SmModel::getUnoTunnelId()));
+
+ if (pModel)
+ {
+ SmDocShell *pDocShell =
+ static_cast<SmDocShell*>(pModel->GetObjectShell());
+ pTree = pDocShell->GetFormulaTree();
+ aText = pDocShell->GetText();
+ }
+
+ GetDocHandler()->startDocument();
+
+ /*Add xmlns line*/
+ SvXMLAttributeList &rList = GetAttrList();
+
+ // make use of a default namespace
+ ResetNamespaceMap(); // Math doesn't need namespaces from xmloff, since it now uses default namespaces (because that is common with current MathML usage in the web)
+ _GetNamespaceMap().Add( OUString::createFromAscii(""), GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH );
+
+ rList.AddAttribute(GetNamespaceMap().GetAttrNameByKey(XML_NAMESPACE_MATH_IDX),
+ GetNamespaceMap().GetNameByKey( XML_NAMESPACE_MATH_IDX));
+
+ //I think we need something like ImplExportEntities();
+ _ExportContent();
+ GetDocHandler()->endDocument();
+ }
+
+ bSuccess=sal_True;
+ return 0;
+}
+
+void SmXMLExport::_ExportContent()
+{
+ SvXMLElementExport aEquation(*this, XML_NAMESPACE_MATH, XML_MATH, sal_True, sal_True);
+ SvXMLElementExport *pSemantics=0;
+
+ if (aText.Len())
+ {
+ pSemantics = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
+ XML_SEMANTICS, sal_True, sal_True);
+ }
+
+ ExportNodes(pTree, 0);
+
+ if (aText.Len())
+ {
+ // Convert symbol names
+ uno::Reference <frame::XModel> xModel = GetModel();
+ uno::Reference <lang::XUnoTunnel> xTunnel;
+ xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
+ SmModel *pModel = reinterpret_cast<SmModel *>
+ (xTunnel->getSomething(SmModel::getUnoTunnelId()));
+ SmDocShell *pDocShell = pModel ?
+ static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0;
+ DBG_ASSERT( pDocShell, "doc shell missing" );
+ if (pDocShell)
+ {
+ SmParser &rParser = pDocShell->GetParser();
+ BOOL bVal = rParser.IsExportSymbolNames();
+ rParser.SetExportSymbolNames( TRUE );
+ SmNode *pTmpTree = rParser.Parse( aText );
+ aText = rParser.GetText();
+ delete pTmpTree;
+ rParser.SetExportSymbolNames( bVal );
+ }
+
+ AddAttribute(XML_NAMESPACE_MATH, XML_ENCODING,
+ OUString(RTL_CONSTASCII_USTRINGPARAM("StarMath 5.0")));
+ SvXMLElementExport aAnnotation(*this, XML_NAMESPACE_MATH,
+ XML_ANNOTATION, sal_True, sal_False);
+ GetDocHandler()->characters(OUString( aText ));
+ }
+ delete pSemantics;
+}
+
+void SmXMLExport::GetViewSettings( Sequence < PropertyValue >& aProps)
+{
+ uno::Reference <frame::XModel> xModel = GetModel();
+ if ( !xModel.is() )
+ return;
+
+ uno::Reference <lang::XUnoTunnel> xTunnel;
+ xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
+ SmModel *pModel = reinterpret_cast<SmModel *>
+ (xTunnel->getSomething(SmModel::getUnoTunnelId()));
+
+ if ( !pModel )
+ return;
+
+ SmDocShell *pDocShell =
+ static_cast<SmDocShell*>(pModel->GetObjectShell());
+ if ( !pDocShell )
+ return;
+
+ aProps.realloc( 4 );
+ PropertyValue *pValue = aProps.getArray();
+ sal_Int32 nIndex = 0;
+
+ Rectangle aRect( pDocShell->GetVisArea() );
+
+ pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaTop") );
+ pValue[nIndex++].Value <<= aRect.Top();
+
+ pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaLeft") );
+ pValue[nIndex++].Value <<= aRect.Left();
+
+ pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaWidth") );
+ pValue[nIndex++].Value <<= aRect.GetWidth();
+
+ pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaHeight") );
+ pValue[nIndex++].Value <<= aRect.GetHeight();
+}
+
+void SmXMLExport::GetConfigurationSettings( Sequence < PropertyValue > & rProps)
+{
+ Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY );
+ if ( xProps.is() )
+ {
+ Reference< XPropertySetInfo > xPropertySetInfo = xProps->getPropertySetInfo();
+ if (xPropertySetInfo.is())
+ {
+ Sequence< Property > aProps = xPropertySetInfo->getProperties();
+ sal_Int32 nCount(aProps.getLength());
+ if (nCount > 0)
+ {
+ rProps.realloc(nCount);
+ PropertyValue* pProps = rProps.getArray();
+ if (pProps)
+ {
+ const OUString sFormula ( RTL_CONSTASCII_USTRINGPARAM ( "Formula" ) );
+ const OUString sBasicLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "BasicLibraries" ) );
+ const OUString sDialogLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "DialogLibraries" ) );
+ const OUString sRuntimeUID ( RTL_CONSTASCII_USTRINGPARAM ( "RuntimeUID" ) );
+ for (sal_Int32 i = 0; i < nCount; i++, pProps++)
+ {
+ const OUString &rPropName = aProps[i].Name;
+ if (rPropName != sFormula &&
+ rPropName != sBasicLibraries &&
+ rPropName != sDialogLibraries &&
+ rPropName != sRuntimeUID)
+ {
+ pProps->Name = rPropName;
+ pProps->Value = xProps->getPropertyValue(rPropName);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void SmXMLExport::ExportLine(const SmNode *pNode, int nLevel)
+{
+ ExportExpression(pNode, nLevel);
+}
+
+void SmXMLExport::ExportBinaryHorizontal(const SmNode *pNode, int nLevel)
+{
+ ExportExpression(pNode, nLevel);
+}
+
+void SmXMLExport::ExportUnaryHorizontal(const SmNode *pNode, int nLevel)
+{
+ ExportExpression(pNode, nLevel);
+}
+
+void SmXMLExport::ExportExpression(const SmNode *pNode, int nLevel)
+{
+ SvXMLElementExport *pRow=0;
+ ULONG nSize = pNode->GetNumSubNodes();
+
+ if (nSize > 1)
+ pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW, sal_True, sal_True);
+
+ //if (nSize)
+ //{
+ for (USHORT i = 0; i < nSize; i++)
+ if (const SmNode *pTemp = pNode->GetSubNode(i))
+ ExportNodes(pTemp, nLevel+1);
+ //}
+#if 0
+ else
+ {
+ //This saves us from situations like "a newline" where the
+ //lack of a term following the newline would otherwise create
+ //a incorrect token like <mtr/>
+ SvXMLElementExport aDummy(*this, XML_NAMESPACE_MATH, XML_MI, sal_True, sal_False);
+ sal_Unicode nArse[2] = {'\n','\0'};
+ GetDocHandler()->characters(nArse);
+ }
+#endif
+
+ delete pRow;
+}
+
+void SmXMLExport::ExportBinaryVertical(const SmNode *pNode, int nLevel)
+{
+ DBG_ASSERT(pNode->GetNumSubNodes()==3,"Bad Fraction");
+ SvXMLElementExport aFraction(*this, XML_NAMESPACE_MATH, XML_MFRAC, sal_True, sal_True);
+ ExportNodes(pNode->GetSubNode(0), nLevel);
+ ExportNodes(pNode->GetSubNode(2), nLevel);
+}
+
+void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel)
+{
+ SvXMLElementExport *pTable=0;
+
+ USHORT nSize = pNode->GetNumSubNodes();
+
+ //If the list ends in newline then the last entry has
+ //no subnodes, the newline is superfulous so we just drop
+ //the last node, inclusion would create a bad MathML
+ //table
+ if (nSize >= 1 && pNode->GetSubNode(nSize-1)->GetNumSubNodes() == 0)
+ --nSize;
+
+ // try to avoid creating a mtable element when the formula consists only
+ // of a single output line
+ if (nLevel || (nSize >1))
+ pTable = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTABLE, sal_True, sal_True);
+
+ for (USHORT i = 0; i < nSize; i++)
+ if (const SmNode *pTemp = pNode->GetSubNode(i))
+ {
+ SvXMLElementExport *pRow=0;
+ SvXMLElementExport *pCell=0;
+ if (pTable)
+ {
+ pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTR, sal_True, sal_True);
+ pCell = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTD, sal_True, sal_True);
+ }
+ ExportNodes(pTemp, nLevel+1);
+ delete pCell;
+ delete pRow;
+ }
+
+ delete pTable;
+}
+
+void SmXMLExport::ExportMath(const SmNode *pNode, int /*nLevel*/)
+{
+ const SmMathSymbolNode *pTemp = static_cast<const SmMathSymbolNode *>(pNode);
+ SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO, sal_True, sal_False);
+ sal_Unicode nArse[2];
+ nArse[0] = pTemp->GetText().GetChar(0);
+ sal_Unicode cTmp = ConvertMathToMathML( nArse[0] );
+ if (cTmp != 0)
+ nArse[0] = cTmp;
+ DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol");
+ nArse[1] = 0;
+ GetDocHandler()->characters(nArse);
+}
+
+void SmXMLExport::ExportText(const SmNode *pNode, int /*nLevel*/)
+{
+ SvXMLElementExport *pText;
+ const SmTextNode *pTemp = static_cast<const SmTextNode *>(pNode);
+ switch (pNode->GetToken().eType)
+ {
+ default:
+ case TIDENT:
+ {
+ //Note that we change the fontstyle to italic for strings that
+ //are italic and longer than a single character.
+ sal_Bool bIsItalic = IsItalic( pTemp->GetFont() );
+ if ((pTemp->GetText().Len() > 1) && bIsItalic)
+ AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, XML_ITALIC);
+ else if ((pTemp->GetText().Len() == 1) && !bIsItalic)
+ AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, XML_NORMAL);
+ pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MI,sal_True,sal_False);
+ break;
+ }
+ case TNUMBER:
+ pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MN,sal_True,sal_False);
+ break;
+ case TTEXT:
+ pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTEXT,sal_True,sal_False);
+ break;
+ }
+ GetDocHandler()->characters(OUString(pTemp->GetText().GetBuffer()));
+ delete pText;
+}
+
+void SmXMLExport::ExportBlank(const SmNode * /*pNode*/, int /*nLevel*/)
+{
+ //!! exports an empty <mi> tag since for example "~_~" is allowed in
+ //!! Math (so it has no sense at all) but must not result in an empty
+ //!! <msub> tag in MathML !!
+
+ SvXMLElementExport *pText;
+ //const SmBlankNode *pTemp = static_cast<const SmBlankNode *>(pNode);
+
+ pText = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MI, sal_True, sal_False);
+
+ GetDocHandler()->characters( OUString() );
+ delete pText;
+}
+
+void SmXMLExport::ExportSubSupScript(const SmNode *pNode, int nLevel)
+{
+ const SmNode *pSub = 0;
+ const SmNode *pSup = 0;
+ const SmNode *pCSub = 0;
+ const SmNode *pCSup = 0;
+ const SmNode *pLSub = 0;
+ const SmNode *pLSup = 0;
+ SvXMLElementExport *pThing = 0, *pThing2 = 0;
+
+ //if we have prescripts at all then we must use the tensor notation
+
+ //This is one of those excellent locations where scope is vital to
+ //arrange the construction and destruction of the element helper
+ //classes correctly
+ pLSub = pNode->GetSubNode(LSUB+1);
+ pLSup = pNode->GetSubNode(LSUP+1);
+ if (pLSub || pLSup)
+ {
+ SvXMLElementExport aMultiScripts(*this, XML_NAMESPACE_MATH,
+ XML_MMULTISCRIPTS, sal_True, sal_True);
+
+
+ if (NULL != (pCSub = pNode->GetSubNode(CSUB+1))
+ && NULL != (pCSup = pNode->GetSubNode(CSUP+1)))
+ {
+ pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
+ XML_MUNDEROVER, sal_True,sal_True);
+ }
+ else if (NULL != (pCSub = pNode->GetSubNode(CSUB+1)))
+ {
+ pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
+ XML_MUNDER, sal_True,sal_True);
+ }
+ else if (NULL != (pCSup = pNode->GetSubNode(CSUP+1)))
+ {
+ pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
+ XML_MOVER, sal_True,sal_True);
+ }
+
+ ExportNodes(pNode->GetSubNode(0), nLevel+1); //Main Term
+
+ if (pCSub)
+ ExportNodes(pCSub, nLevel+1);
+ if (pCSup)
+ ExportNodes(pCSup, nLevel+1);
+ delete pThing2;
+
+ pSub = pNode->GetSubNode(RSUB+1);
+ pSup = pNode->GetSubNode(RSUP+1);
+ if (pSub || pSup)
+ {
+ if (pSub)
+ ExportNodes(pSub, nLevel+1);
+ else
+ {
+ SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE,sal_True,sal_True);
+ }
+ if (pSup)
+ ExportNodes(pSup, nLevel+1);
+ else
+ {
+ SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE,sal_True,sal_True);
+ }
+ }
+
+ //Seperator element between suffix and prefix sub/sup pairs
+ {
+ SvXMLElementExport aPrescripts(*this, XML_NAMESPACE_MATH,
+ XML_MPRESCRIPTS, sal_True,sal_True);
+ }
+
+ if (pLSub)
+ ExportNodes(pLSub, nLevel+1);
+ else
+ {
+ SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE,
+ sal_True,sal_True);
+
+ }
+ if (pLSup)
+ ExportNodes(pLSup, nLevel+1);
+ else
+ {
+ SvXMLElementExport aNone(*this, XML_NAMESPACE_MATH, XML_NONE,
+ sal_True,sal_True);
+
+ }
+ }
+ else
+ {
+ if (NULL != (pSub = pNode->GetSubNode(RSUB+1)) &&
+ NULL != (pSup = pNode->GetSubNode(RSUP+1)))
+ {
+ pThing = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
+ XML_MSUBSUP, sal_True,sal_True);
+ }
+ else if (NULL != (pSub = pNode->GetSubNode(RSUB+1)))
+ {
+ pThing = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MSUB,
+ sal_True,sal_True);
+ }
+ else if (NULL != (pSup = pNode->GetSubNode(RSUP+1)))
+ {
+ pThing = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MSUP,
+ sal_True,sal_True);
+ }
+
+ if (NULL != (pCSub = pNode->GetSubNode(CSUB+1))
+ && NULL != (pCSup=pNode->GetSubNode(CSUP+1)))
+ {
+ pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
+ XML_MUNDEROVER, sal_True,sal_True);
+ }
+ else if (NULL != (pCSub = pNode->GetSubNode(CSUB+1)))
+ {
+ pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
+ XML_MUNDER, sal_True,sal_True);
+ }
+ else if (NULL != (pCSup = pNode->GetSubNode(CSUP+1)))
+ {
+ pThing2 = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
+ XML_MOVER, sal_True,sal_True);
+ }
+ ExportNodes(pNode->GetSubNode(0), nLevel+1); //Main Term
+
+ if (pCSub)
+ ExportNodes(pCSub, nLevel+1);
+ if (pCSup)
+ ExportNodes(pCSup, nLevel+1);
+ delete pThing2;
+
+ if (pSub)
+ ExportNodes(pSub, nLevel+1);
+ if (pSup)
+ ExportNodes(pSup, nLevel+1);
+ delete pThing;
+ }
+}
+
+void SmXMLExport::ExportBrace(const SmNode *pNode, int nLevel)
+{
+ const SmNode *pTemp;
+ const SmNode *pLeft=pNode->GetSubNode(0);
+ const SmNode *pRight=pNode->GetSubNode(2);
+ SvXMLElementExport *pFences=0,*pRow=0;
+ if ( ((pLeft) && (pLeft->GetToken().eType != TNONE)) &&
+ ((pRight) && (pRight->GetToken().eType != TNONE)) &&
+ (pNode->GetScaleMode() == SCALE_HEIGHT))
+ {
+ sal_Unicode nArse[2];
+ nArse[1] = 0;
+ nArse[0] = static_cast<
+ const SmMathSymbolNode* >(pLeft)->GetText().GetChar(0);
+ DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol");
+ AddAttribute(XML_NAMESPACE_MATH, XML_OPEN,nArse);
+ nArse[0] = static_cast<
+ const SmMathSymbolNode* >(pRight)->GetText().GetChar(0);
+ DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol");
+ AddAttribute(XML_NAMESPACE_MATH, XML_CLOSE,nArse);
+ pFences = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MFENCED,
+ sal_True,sal_True);
+ }
+ else if (pLeft && (pLeft->GetToken().eType != TNONE))
+ {
+ pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW,
+ sal_True, sal_True);
+ if (pNode->GetScaleMode() == SCALE_HEIGHT)
+ AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE);
+ else
+ AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE);
+ ExportNodes(pLeft, nLevel+1);
+ }
+ else
+ pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW,
+ sal_True, sal_True);
+
+ if (NULL != (pTemp = pNode->GetSubNode(1)))
+ ExportNodes(pTemp, nLevel+1);
+ if (pFences)
+ delete pFences;
+ else if (pRight && (pRight->GetToken().eType != TNONE))
+ {
+ if (pNode->GetScaleMode() == SCALE_HEIGHT)
+ AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE);
+ else
+ AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE);
+ ExportNodes(pRight, nLevel+1);
+ }
+ delete pRow;
+}
+
+void SmXMLExport::ExportRoot(const SmNode *pNode, int nLevel)
+{
+ if (pNode->GetSubNode(0))
+ {
+ SvXMLElementExport aRoot(*this, XML_NAMESPACE_MATH, XML_MROOT,sal_True,
+ sal_True);
+ ExportNodes(pNode->GetSubNode(2), nLevel+1);
+ ExportNodes(pNode->GetSubNode(0), nLevel+1);
+ }
+ else
+ {
+ SvXMLElementExport aSqrt(*this, XML_NAMESPACE_MATH, XML_MSQRT,sal_True,
+ sal_True);
+ ExportNodes(pNode->GetSubNode(2), nLevel+1);
+ }
+}
+
+void SmXMLExport::ExportOperator(const SmNode *pNode, int nLevel)
+{
+ /*we need to either use content or font and size attributes
+ *here*/
+#if 0
+ {
+ SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO,
+ sal_True,sal_False);
+ SmTextNode *pTemp = (SmTextNode *)pNode->GetSubNode(0);
+ GetDocHandler()->characters(pTemp->GetText());
+ }
+#endif
+ SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MROW,
+ sal_True, sal_True);
+ ExportNodes(pNode->GetSubNode(0), nLevel+1);
+ ExportNodes(pNode->GetSubNode(1), nLevel+1);
+}
+
+void SmXMLExport::ExportAttributes(const SmNode *pNode, int nLevel)
+{
+ SvXMLElementExport *pElement=0;
+
+ if (pNode->GetToken().eType == TUNDERLINE)
+ {
+ AddAttribute(XML_NAMESPACE_MATH, XML_ACCENTUNDER,
+ XML_TRUE);
+ pElement = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MUNDER,
+ sal_True,sal_True);
+ }
+ else if (pNode->GetToken().eType != TOVERSTRIKE)
+ {
+ AddAttribute(XML_NAMESPACE_MATH, XML_ACCENT,
+ XML_TRUE);
+ pElement = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MOVER,
+ sal_True,sal_True);
+ }
+
+ ExportNodes(pNode->GetSubNode(1), nLevel+1);
+ switch (pNode->GetToken().eType)
+ {
+ case TOVERLINE:
+ {
+ //proper entity support required
+ SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO,
+ sal_True,sal_True);
+#if 0
+ GetDocHandler()->characters(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("&overbar;")));
+#else
+ sal_Unicode nArse[2] = {0xAF,0x00};
+#endif
+ GetDocHandler()->characters(nArse);
+ }
+ break;
+ case TUNDERLINE:
+ {
+ //proper entity support required
+ SvXMLElementExport aMath(*this, XML_NAMESPACE_MATH, XML_MO,
+ sal_True,sal_True);
+#if 0
+ GetDocHandler()->characters(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("&underbar;")));
+#else
+ sal_Unicode nArse[2] = {0x0332,0x00};
+#endif
+ GetDocHandler()->characters(nArse);
+ }
+ break;
+ case TOVERSTRIKE:
+ break;
+ default:
+ ExportNodes(pNode->GetSubNode(0), nLevel+1);
+ break;
+ }
+ delete pElement;
+}
+
+static bool lcl_HasEffectOnMathvariant( const SmTokenType eType )
+{
+ return eType == TBOLD || eType == TNBOLD ||
+ eType == TITALIC || eType == TNBOLD ||
+ eType == TSANS || eType == TSERIF || eType == TFIXED;
+}
+
+void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel)
+{
+ SvXMLElementExport *pElement = 0;
+
+ //
+ // gather the mathvariant attribut relevant data from all
+ // successively following SmFontNodes...
+ //
+ int nBold = -1; // for the following variables: -1 = yet undefined; 0 = false; 1 = true;
+ int nItalic = -1; // for the following variables: -1 = yet undefined; 0 = false; 1 = true;
+ int nSansSerifFixed = -1;
+ SmTokenType eNodeType = TUNKNOWN;
+ while (lcl_HasEffectOnMathvariant( (eNodeType = pNode->GetToken().eType) ))
+ {
+ switch (eNodeType)
+ {
+ case TBOLD : nBold = 1; break;
+ case TNBOLD : nBold = 0; break;
+ case TITALIC : nItalic = 1; break;
+ case TNITALIC : nItalic = 0; break;
+ case TSANS : nSansSerifFixed = 0; break;
+ case TSERIF : nSansSerifFixed = 1; break;
+ case TFIXED : nSansSerifFixed = 2; break;
+ default:
+ DBG_ASSERT( 0, "unexpected case" );
+ }
+ // According to the parser every node that is to be evaluated heres
+ // has a single non-zero subnode at index 1!! Thus we only need to check
+ // that single node for follow-up nodes that have an effect on the attribute.
+ if (pNode->GetNumSubNodes() > 1 && pNode->GetSubNode(1) &&
+ lcl_HasEffectOnMathvariant( pNode->GetSubNode(1)->GetToken().eType))
+ {
+ pNode = pNode->GetSubNode(1);
+ }
+ else
+ break;
+ }
+
+ switch (pNode->GetToken().eType)
+ {
+ //wrap a phantom element around everything*/
+ case TPHANTOM:
+ pElement = new SvXMLElementExport(*this, XML_NAMESPACE_MATH,
+ XML_MPHANTOM, sal_True,sal_True);
+ break;
+ case TBLACK:
+ AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_BLACK);
+ break;
+ case TWHITE:
+ AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_WHITE);
+ break;
+ case TRED:
+ AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_RED);
+ break;
+ case TGREEN:
+ AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_GREEN);
+ break;
+ case TBLUE:
+ AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_BLUE);
+ break;
+ case TCYAN:
+ AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_AQUA);
+ break;
+ case TMAGENTA:
+ AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_FUCHSIA);
+ break;
+ case TYELLOW:
+ AddAttribute(XML_NAMESPACE_MATH, XML_COLOR, XML_YELLOW);
+ break;
+ case TSIZE:
+ {
+ const SmFontNode *pFontNode = static_cast<const SmFontNode *>(pNode);
+ const Fraction &aFrac = pFontNode->GetSizeParameter();
+
+ OUStringBuffer sStrBuf;
+ switch(pFontNode->GetSizeType())
+ {
+ case FNTSIZ_MULTIPLY:
+ SvXMLUnitConverter::convertDouble(sStrBuf,
+ static_cast<double>(aFrac*Fraction(100.00)));
+ sStrBuf.append(static_cast<sal_Unicode>('%'));
+ break;
+ case FNTSIZ_DIVIDE:
+ SvXMLUnitConverter::convertDouble(sStrBuf,
+ static_cast<double>(Fraction(100.00)/aFrac));
+ sStrBuf.append(static_cast<sal_Unicode>('%'));
+ break;
+ case FNTSIZ_ABSOLUT:
+ SvXMLUnitConverter::convertDouble(sStrBuf,
+ static_cast<double>(aFrac));
+ sStrBuf.append(
+ GetXMLToken(XML_UNIT_PT));
+ break;
+ default:
+ {
+ //The problem here is that the wheels fall off because
+ //font size is stored in 100th's of a mm not pts, and
+ //rounding errors take their toll on the original
+ //value specified in points.
+
+ //Must fix StarMath to retain the original pt values
+ Fraction aTemp = Sm100th_mmToPts(pFontNode->GetFont().
+ GetSize().Height());
+
+ if (pFontNode->GetSizeType() == FNTSIZ_MINUS)
+ aTemp-=aFrac;
+ else
+ aTemp+=aFrac;
+
+ double mytest = static_cast<double>(aTemp);
+
+ mytest = ::rtl::math::round(mytest,1);
+ SvXMLUnitConverter::convertDouble(sStrBuf,mytest);
+ sStrBuf.append(GetXMLToken(XML_UNIT_PT));
+ }
+ break;
+ }
+
+ OUString sStr(sStrBuf.makeStringAndClear());
+ AddAttribute(XML_NAMESPACE_MATH, XML_MATHSIZE, sStr);
+ }
+ break;
+ case TBOLD:
+ case TITALIC:
+ case TNBOLD:
+ case TNITALIC:
+ case TFIXED:
+ case TSANS:
+ case TSERIF:
+ {
+ // nBold: -1 = yet undefined; 0 = false; 1 = true;
+ // nItalic: -1 = yet undefined; 0 = false; 1 = true;
+ // nSansSerifFixed: -1 = undefined; 0 = sans; 1 = serif; 2 = fixed;
+ const sal_Char *pText = "normal";
+ if (nSansSerifFixed == -1 || nSansSerifFixed == 1)
+ {
+ pText = "normal";
+ if (nBold == 1 && nItalic != 1)
+ pText = "bold";
+ else if (nBold != 1 && nItalic == 1)
+ pText = "italic";
+ else if (nBold == 1 && nItalic == 1)
+ pText = "bold-italic";
+ }
+ else if (nSansSerifFixed == 0)
+ {
+ pText = "sans-serif";
+ if (nBold == 1 && nItalic != 1)
+ pText = "bold-sans-serif";
+ else if (nBold != 1 && nItalic == 1)
+ pText = "sans-serif-italic";
+ else if (nBold == 1 && nItalic == 1)
+ pText = "sans-serif-bold-italic";
+ }
+ else if (nSansSerifFixed == 2)
+ pText = "monospace"; // no modifiers allowed for monospace ...
+ else
+ {
+ DBG_ASSERT( 0, "unexpected case" );
+ }
+ AddAttribute(XML_NAMESPACE_MATH, XML_MATHVARIANT, A2OU(pText));
+ }
+ break;
+ default:
+ break;
+
+ }
+#if 0
+ if (pNode->GetNumSubNodes() > 1) //or in the future is a node that
+ //cannot take the currently supported
+ //properties
+#endif
+ //for now we will just always export with a style and not worry about
+ //anyone else for the moment.
+ {
+ //wrap a style around it
+ SvXMLElementExport aStyle(*this, XML_NAMESPACE_MATH, XML_MSTYLE, sal_True,sal_True);
+ ExportExpression(pNode, nLevel);
+ }
+#if 0
+ else
+ ExportNodes(pNode->GetSubNode(0), nLevel+1);
+#endif
+
+ delete pElement;
+}
+
+
+void SmXMLExport::ExportVerticalBrace(const SmNode *pNode, int nLevel)
+{
+ //Place the overbrace value OVER a vertical brace and then place that
+ //expression OVER the overbrace value, If someone can find a
+ //dedicated term in MathML to handle this overbrace/underbrace concept
+ //let me know. C.
+ XMLTokenEnum which;
+
+ switch (pNode->GetToken().eType)
+ {
+ case TOVERBRACE:
+ default:
+ which = XML_MOVER;
+ break;
+ case TUNDERBRACE:
+ which = XML_MUNDER;
+ break;
+ }
+
+ DBG_ASSERT(pNode->GetNumSubNodes()==3,"Bad Vertical Brace");
+ SvXMLElementExport aOver1(*this, XML_NAMESPACE_MATH,which, sal_True, sal_True);
+ {//Scoping
+ // using accents will draw the over-/underbraces too close to the base
+ // see http://www.w3.org/TR/MathML2/chapter3.html#id.3.4.5.2
+ // also XML_ACCENT is illegal with XML_MUNDER. Thus no XML_ACCENT attribut here!
+// AddAttribute(XML_NAMESPACE_MATH, XML_ACCENT, XML_TRUE);
+ SvXMLElementExport aOver2(*this, XML_NAMESPACE_MATH,which, sal_True, sal_True);
+ ExportNodes(pNode->GetSubNode(0), nLevel);
+ ExportNodes(pNode->GetSubNode(1), nLevel);
+ }
+ ExportNodes(pNode->GetSubNode(2), nLevel);
+}
+
+void SmXMLExport::ExportMatrix(const SmNode *pNode, int nLevel)
+{
+ SvXMLElementExport aTable(*this, XML_NAMESPACE_MATH, XML_MTABLE, sal_True, sal_True);
+ const SmMatrixNode *pMatrix = static_cast<const SmMatrixNode *>(pNode);
+ USHORT i=0;
+ for (ULONG y = 0; y < pMatrix->GetNumRows(); y++)
+ {
+ SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MTR, sal_True, sal_True);
+ for (ULONG x = 0; x < pMatrix->GetNumCols(); x++)
+ if (const SmNode *pTemp = pNode->GetSubNode(i++))
+ {
+ SvXMLElementExport aCell(*this, XML_NAMESPACE_MATH, XML_MTD, sal_True, sal_True);
+ ExportNodes(pTemp, nLevel+1);
+ }
+ }
+}
+
+void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel)
+{
+ if (!pNode)
+ return;
+ switch(pNode->GetType())
+ {
+ case NTABLE:
+ ExportTable(pNode, nLevel);
+ break;
+ case NALIGN:
+ case NBRACEBODY:
+ case NEXPRESSION:
+ ExportExpression(pNode, nLevel);
+ break;
+ case NLINE:
+ ExportLine(pNode, nLevel);
+ break;
+ case NTEXT:
+ ExportText(pNode, nLevel);
+ break;
+ case NSPECIAL: //NSPECIAL requires some sort of Entity preservation in the XML engine.
+ case NGLYPH_SPECIAL:
+ case NMATH:
+ {
+ sal_Unicode cTmp = 0;
+ const SmTextNode *pTemp = static_cast< const SmTextNode * >(pNode);
+ if (pTemp->GetText().Len() > 0)
+ cTmp = ConvertMathToMathML( pTemp->GetText().GetChar(0) );
+ if (cTmp == 0)
+ {
+ // no conversion to MathML implemented -> export it as text
+ // thus at least it will not vanish into nothing
+ ExportText(pNode, nLevel);
+ }
+ else
+ {
+ //To fully handle generic MathML we need to implement the full
+ //operator dictionary, we will generate MathML with explicit
+ //stretchiness for now.
+ sal_Int16 nLength = GetAttrList().getLength();
+ sal_Bool bAddStretch=sal_True;
+ for ( sal_Int16 i = 0; i < nLength; i++ )
+ {
+ OUString sLocalName;
+ sal_uInt16 nPrefix = GetNamespaceMap().GetKeyByAttrName(
+ GetAttrList().getNameByIndex(i), &sLocalName );
+
+ if ( ( XML_NAMESPACE_MATH == nPrefix ) &&
+ IsXMLToken(sLocalName, XML_STRETCHY) )
+ {
+ bAddStretch = sal_False;
+ break;
+ }
+ }
+ if (bAddStretch)
+ {
+ AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_FALSE);
+ }
+ ExportMath(pNode, nLevel);
+ }
+ }
+ break;
+ case NPLACE:
+ ExportMath(pNode, nLevel);
+ break;
+ case NBINHOR:
+ ExportBinaryHorizontal(pNode, nLevel);
+ break;
+ case NUNHOR:
+ ExportUnaryHorizontal(pNode, nLevel);
+ break;
+ case NBRACE:
+ ExportBrace(pNode, nLevel);
+ break;
+ case NBINVER:
+ ExportBinaryVertical(pNode, nLevel);
+ break;
+ case NSUBSUP:
+ ExportSubSupScript(pNode, nLevel);
+ break;
+ case NROOT:
+ ExportRoot(pNode, nLevel);
+ break;
+ case NOPER:
+ ExportOperator(pNode, nLevel);
+ break;
+ case NATTRIBUT:
+ ExportAttributes(pNode, nLevel);
+ break;
+ case NFONT:
+ ExportFont(pNode, nLevel);
+ break;
+ case NVERTICAL_BRACE:
+ ExportVerticalBrace(pNode, nLevel);
+ break;
+ case NMATRIX:
+ ExportMatrix(pNode, nLevel);
+ break;
+ case NBLANK:
+ ExportBlank(pNode, nLevel);
+ break;
+ default:
+ DBG_ASSERT( 0, "Warning: failed to export a node?" );
+ break;
+
+#if 0
+ default:
+ {
+ ULONG nSize = pNode->GetNumSubNodes();
+ for (ULONG i = 0; i < nSize; i++)
+ if (SmNode *pTemp = pNode->GetSubNode(i))
+ ExportNodes(pTemp, nLevel+1);
+ }
+ break;
+#endif
+ }
+}
+
+////////////////////////////////////////////////////////////
+
diff --git a/starmath/source/mathmlexport.hxx b/starmath/source/mathmlexport.hxx
new file mode 100644
index 000000000000..fa76076e6616
--- /dev/null
+++ b/starmath/source/mathmlexport.hxx
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: x $
+ * $Revision: 1.00 $
+ *
+ * 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 _MATHMLEXPORT_HXX_
+#define _MATHMLEXPORT_HXX_
+
+#include <xmloff/xmlimp.hxx>
+#include <xmloff/xmlexp.hxx>
+#include <xmloff/DocumentSettingsContext.hxx>
+#include <xmloff/xmltoken.hxx>
+
+#include <node.hxx>
+
+class SfxMedium;
+namespace com { namespace sun { namespace star {
+ namespace io {
+ class XInputStream;
+ class XOutputStream; }
+ namespace beans {
+ class XPropertySet; }
+} } }
+
+
+////////////////////////////////////////////////////////////
+
+class SmXMLExportWrapper
+{
+ com::sun::star::uno::Reference<com::sun::star::frame::XModel> xModel;
+ sal_Bool bFlat; //set true for export to flat .mml, set false for
+ //export to a .sxm (or whatever) package
+public:
+ SmXMLExportWrapper(com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rRef)
+ : xModel(rRef), bFlat(sal_True) {}
+
+ sal_Bool Export(SfxMedium &rMedium);
+ void SetFlat(sal_Bool bIn) {bFlat = bIn;}
+
+ sal_Bool WriteThroughComponent(
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
+ xOutputStream,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ xComponent,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & rPropSet,
+ const sal_Char* pComponentName );
+
+ sal_Bool WriteThroughComponent(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStor,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ xComponent,
+ const sal_Char* pStreamName,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & rPropSet,
+ const sal_Char* pComponentName,
+ sal_Bool bCompress=sal_True );
+};
+
+////////////////////////////////////////////////////////////
+
+class SmXMLExport : public SvXMLExport
+{
+ const SmNode * pTree;
+ String aText;
+ sal_Bool bSuccess;
+
+protected:
+ void ExportNodes(const SmNode *pNode, int nLevel);
+ void ExportTable(const SmNode *pNode, int nLevel);
+ void ExportLine(const SmNode *pNode, int nLevel);
+ void ExportExpression(const SmNode *pNode, int nLevel);
+ void ExportText(const SmNode *pNode, int nLevel);
+ void ExportMath(const SmNode *pNode, int nLevel);
+ void ExportPolygon(const SmNode *pNode, int nLevel);
+ void ExportBinaryHorizontal(const SmNode *pNode, int nLevel);
+ void ExportUnaryHorizontal(const SmNode *pNode, int nLevel);
+ void ExportBrace(const SmNode *pNode, int nLevel);
+ void ExportBinaryVertical(const SmNode *pNode, int nLevel);
+ void ExportSubSupScript(const SmNode *pNode, int nLevel);
+ void ExportRoot(const SmNode *pNode, int nLevel);
+ void ExportOperator(const SmNode *pNode, int nLevel);
+ void ExportAttributes(const SmNode *pNode, int nLevel);
+ void ExportFont(const SmNode *pNode, int nLevel);
+ void ExportVerticalBrace(const SmNode *pNode, int nLevel);
+ void ExportMatrix(const SmNode *pNode, int nLevel);
+ void ExportBlank(const SmNode *pNode, int nLevel);
+
+public:
+ // #110680#
+ SmXMLExport(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
+ sal_uInt16 nExportFlags=EXPORT_ALL);
+ virtual ~SmXMLExport() {};
+
+ // XServiceInfo (override parent method)
+ ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+
+ // XUnoTunnel
+ sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException);
+ static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
+
+ void _ExportAutoStyles() {}
+ void _ExportMasterStyles() {}
+ void _ExportContent();
+ sal_uInt32 exportDoc(enum ::xmloff::token::XMLTokenEnum eClass);
+
+ virtual void GetViewSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps);
+ virtual void GetConfigurationSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps);
+
+ sal_Bool GetSuccess() {return bSuccess;}
+};
+
+////////////////////////////////////////////////////////////
+
+#endif
+
diff --git a/starmath/source/mathml.cxx b/starmath/source/mathmlimport.cxx
index dc3e153d3613..1f7336db6d3c 100644
--- a/starmath/source/mathml.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -1,4464 +1,3189 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: mathml.cxx,v $
- * $Revision: 1.88 $
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_starmath.hxx"
-
-/*
- Warning: The SvXMLElementExport helper class creates the beginning and
- closing tags of xml elements in its constructor and destructor, so theres
- hidden stuff going on, on occasion the ordering of these classes declarations
- may be significant
-*/
-
-/*todo: Change characters and tcharacters to accumulate the characters together
-into one string, xml parser hands them to us line by line rather than all in
-one go*/
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/embed/ElementModes.hpp>
-
-#ifndef _TOOLS_DEBUG_H
-#include <tools/debug.hxx>
-#endif
-#include <tools/urlobj.hxx>
-#include <rtl/math.hxx>
-#include <svtools/sfxecode.hxx>
-#include <svtools/saveopt.hxx>
-#include <sfx2/docfile.hxx>
-#include <svtools/stritem.hxx>
-#include <unomodel.hxx>
-#include <mathml.hxx>
-#include <document.hxx>
-#include <utility.hxx>
-#include <osl/mutex.hxx>
-#include <com/sun/star/uno/Any.h>
-#include <xmloff/xmlnmspe.hxx>
-#include <xmloff/xmltoken.hxx>
-#include <xmloff/nmspmap.hxx>
-#include <xmloff/attrlist.hxx>
-#include <xmloff/xmluconv.hxx>
-#include <xmloff/xmlmetai.hxx>
-#include <unotools/processfactory.hxx>
-#include <unotools/streamwrap.hxx>
-
-#include <com/sun/star/xml/sax/XErrorHandler.hpp>
-#include <com/sun/star/xml/sax/XEntityResolver.hpp>
-#include <com/sun/star/xml/sax/InputSource.hpp>
-#include <com/sun/star/xml/sax/XDTDHandler.hpp>
-#include <com/sun/star/xml/sax/XParser.hpp>
-#include <com/sun/star/io/XActiveDataSource.hpp>
-#include <com/sun/star/io/XActiveDataControl.hpp>
-#include <com/sun/star/document/XDocumentProperties.hpp>
-#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
-#include <com/sun/star/packages/zip/ZipIOException.hpp>
-#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
-#include <com/sun/star/beans/PropertyAttribute.hpp>
-#include <comphelper/genericpropertyset.hxx>
-#include <svtools/itemprop.hxx>
-
-#include <sfx2/frame.hxx>
-
-using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::document;
-using namespace com::sun::star::container;
-using namespace com::sun::star::beans;
-using namespace com::sun::star;
-using namespace ::xmloff::token;
-using ::rtl::OUString;
-using ::rtl::OUStringBuffer;
-#include "mathtype.hxx"
-
-#ifndef STARMATH_HRC
-#include <starmath.hrc>
-#endif
-#ifndef PARSE_HXX
-#include <parser.hxx>
-#endif
-
-#define IMPORT_SVC_NAME RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLImportFilter")
-#define EXPORT_SVC_NAME RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLExportFilter")
-
-#undef WANTEXCEPT
-
-/// read a component (file + filter version)
-ULONG SmXMLWrapper::ReadThroughComponent(
- Reference<io::XInputStream> xInputStream,
- Reference<XComponent> xModelComponent,
- Reference<lang::XMultiServiceFactory> & rFactory,
- Reference<beans::XPropertySet> & rPropSet,
- const sal_Char* pFilterName,
- sal_Bool bEncrypted )
-{
- ULONG nError = ERRCODE_SFX_DOLOADFAILED;
- DBG_ASSERT(xInputStream.is(), "input stream missing");
- DBG_ASSERT(xModelComponent.is(), "document missing");
- DBG_ASSERT(rFactory.is(), "factory missing");
- DBG_ASSERT(NULL != pFilterName,"I need a service name for the component!");
-
- // prepare ParserInputSrouce
- xml::sax::InputSource aParserInput;
- aParserInput.aInputStream = xInputStream;
-
- // get parser
- Reference< xml::sax::XParser > xParser(
- rFactory->createInstance(
- OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
- UNO_QUERY );
- DBG_ASSERT( xParser.is(), "Can't create parser" );
- if( !xParser.is() )
- return nError;
-
- Sequence<Any> aArgs( 1 );
- aArgs[0] <<= rPropSet;
-
- // get filter
- Reference< xml::sax::XDocumentHandler > xFilter(
- rFactory->createInstanceWithArguments(
- OUString::createFromAscii(pFilterName), aArgs ),
- UNO_QUERY );
- DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." );
- if( !xFilter.is() )
- return nError;
-
- // connect parser and filter
- xParser->setDocumentHandler( xFilter );
-
- // connect model and filter
- Reference < XImporter > xImporter( xFilter, UNO_QUERY );
- xImporter->setTargetDocument( xModelComponent );
-
- // finally, parser the stream
- try
- {
- xParser->parseStream( aParserInput );
-
- uno::Reference<lang::XUnoTunnel> xFilterTunnel;
- xFilterTunnel = uno::Reference<lang::XUnoTunnel>
- ( xFilter, uno::UNO_QUERY );
- SmXMLImport *pFilter = reinterpret_cast< SmXMLImport * >(
- sal::static_int_cast< sal_uIntPtr >(
- xFilterTunnel->getSomething( SmXMLImport::getUnoTunnelId() )));
- if( pFilter && pFilter->GetSuccess() )
- nError = 0;
- }
- catch( xml::sax::SAXParseException& )
- {
- if( bEncrypted )
- nError = ERRCODE_SFX_WRONGPASSWORD;
- }
- catch( xml::sax::SAXException& )
- {
- if( bEncrypted )
- nError = ERRCODE_SFX_WRONGPASSWORD;
- }
- catch( packages::zip::ZipIOException& )
- {
- nError = ERRCODE_IO_BROKENPACKAGE;
- }
- catch( io::IOException& )
- {
- }
-
- return nError;
-}
-
-ULONG SmXMLWrapper::ReadThroughComponent(
- const uno::Reference< embed::XStorage >& xStorage,
- Reference<XComponent> xModelComponent,
- const sal_Char* pStreamName,
- const sal_Char* pCompatibilityStreamName,
- Reference<lang::XMultiServiceFactory> & rFactory,
- Reference<beans::XPropertySet> & rPropSet,
- const sal_Char* pFilterName )
-{
- DBG_ASSERT(xStorage.is(), "Need storage!");
- DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!");
-
- // open stream (and set parser input)
- OUString sStreamName = OUString::createFromAscii(pStreamName);
- uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY );
- if ( !xAccess->hasByName(sStreamName) || !xStorage->isStreamElement(sStreamName) )
- {
- // stream name not found! Then try the compatibility name.
- // do we even have an alternative name?
- if ( pCompatibilityStreamName )
- sStreamName = OUString::createFromAscii(pCompatibilityStreamName);
- }
-
- // get input stream
- try
- {
- uno::Reference < io::XStream > xEventsStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
-
- // determine if stream is encrypted or not
- uno::Reference < beans::XPropertySet > xProps( xEventsStream, uno::UNO_QUERY );
- Any aAny = xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ) );
- sal_Bool bEncrypted = sal_False;
- if ( aAny.getValueType() == ::getBooleanCppuType() )
- aAny >>= bEncrypted;
-
- // set Base URL
- if( rPropSet.is() )
- {
- OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("StreamName") );
- rPropSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
- }
-
-
- Reference < io::XInputStream > xStream = xEventsStream->getInputStream();
- return ReadThroughComponent( xStream, xModelComponent, rFactory, rPropSet, pFilterName, bEncrypted );
- }
- catch ( packages::WrongPasswordException& )
- {
- return ERRCODE_SFX_WRONGPASSWORD;
- }
- catch( packages::zip::ZipIOException& )
- {
- return ERRCODE_IO_BROKENPACKAGE;
- }
- catch ( uno::Exception& )
- {
- }
-
- return ERRCODE_SFX_DOLOADFAILED;
-}
-
-ULONG SmXMLWrapper::Import(SfxMedium &rMedium)
-{
- ULONG nError = ERRCODE_SFX_DOLOADFAILED;
-
- uno::Reference<lang::XMultiServiceFactory> xServiceFactory(
- utl::getProcessServiceFactory());
- DBG_ASSERT(xServiceFactory.is(), "XMLReader::Read: got no service manager");
- if( !xServiceFactory.is() )
- return nError;
-
- //Make a model component from our SmModel
- uno::Reference< lang::XComponent > xModelComp( xModel, uno::UNO_QUERY );
- DBG_ASSERT( xModelComp.is(), "XMLReader::Read: got no model" );
-
- // try to get an XStatusIndicator from the Medium
- uno::Reference<task::XStatusIndicator> xStatusIndicator;
-
- sal_Bool bEmbedded = sal_False;
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-
- SmDocShell *pDocShell = pModel ?
- static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0;
- if (pDocShell)
- {
-// if (pDocShell->GetMedium())
- {
- DBG_ASSERT( pDocShell->GetMedium() == &rMedium,
- "different SfxMedium found" );
-
- SfxItemSet* pSet = rMedium.GetItemSet();
- if (pSet)
- {
- const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(
- pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
- if (pItem)
- pItem->GetValue() >>= xStatusIndicator;
- }
- }
-
- if( SFX_CREATE_MODE_EMBEDDED == pDocShell->GetCreateMode() )
- bEmbedded = sal_True;
- }
-
- comphelper::PropertyMapEntry aInfoMap[] =
- {
- { "PrivateData", sizeof("PrivateData")-1, 0,
- &::getCppuType( (Reference<XInterface> *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { "BaseURI", sizeof("BaseURI")-1, 0,
- &::getCppuType( (OUString *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { "StreamRelPath", sizeof("StreamRelPath")-1, 0,
- &::getCppuType( (OUString *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { "StreamName", sizeof("StreamName")-1, 0,
- &::getCppuType( (OUString *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { NULL, 0, 0, NULL, 0, 0 }
- };
- uno::Reference< beans::XPropertySet > xInfoSet(
- comphelper::GenericPropertySet_CreateInstance(
- new comphelper::PropertySetInfo( aInfoMap ) ) );
-
- // Set base URI
- OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("BaseURI") );
- xInfoSet->setPropertyValue( sPropName, makeAny( rMedium.GetBaseURL() ) );
-
- sal_Int32 nSteps=3;
- if( !(rMedium.IsStorage()))
- nSteps = 1;
-
- sal_Int32 nProgressRange(nSteps);
- if (xStatusIndicator.is())
- {
- xStatusIndicator->start(String(SmResId(STR_STATSTR_READING)),
- nProgressRange);
- }
-
- nSteps=0;
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- if( rMedium.IsStorage())
- {
- // TODO/LATER: handle the case of embedded links gracefully
- if( bEmbedded ) // && !rMedium.GetStorage()->IsRoot() )
- {
- OUString aName( RTL_CONSTASCII_USTRINGPARAM( "dummyObjName" ) );
- if ( rMedium.GetItemSet() )
- {
- const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
- rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
- if ( pDocHierarchItem )
- aName = pDocHierarchItem->GetValue();
- }
-
- if( aName.getLength() )
- {
- sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath"));
- xInfoSet->setPropertyValue( sPropName, makeAny( aName ) );
- }
- }
-
- sal_Bool bOASIS = ( SotStorage::GetVersion( rMedium.GetStorage() ) > SOFFICE_FILEFORMAT_60 );
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- ULONG nWarn = ReadThroughComponent(
- rMedium.GetStorage(), xModelComp, "meta.xml", "Meta.xml",
- xServiceFactory, xInfoSet,
- (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaImporter"
- : "com.sun.star.comp.Math.XMLMetaImporter") );
-
- if ( nWarn != ERRCODE_IO_BROKENPACKAGE )
- {
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- nWarn = ReadThroughComponent(
- rMedium.GetStorage(), xModelComp, "settings.xml", 0,
- xServiceFactory, xInfoSet,
- (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsImporter"
- : "com.sun.star.comp.Math.XMLSettingsImporter" ) );
-
- if ( nWarn != ERRCODE_IO_BROKENPACKAGE )
- {
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- nError = ReadThroughComponent(
- rMedium.GetStorage(), xModelComp, "content.xml", "Content.xml",
- xServiceFactory, xInfoSet, "com.sun.star.comp.Math.XMLImporter" );
- }
- else
- nError = ERRCODE_IO_BROKENPACKAGE;
- }
- else
- nError = ERRCODE_IO_BROKENPACKAGE;
- }
- else
- {
- Reference<io::XInputStream> xInputStream =
- new utl::OInputStreamWrapper(rMedium.GetInStream());
-
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- nError = ReadThroughComponent( xInputStream, xModelComp,
- xServiceFactory, xInfoSet, "com.sun.star.comp.Math.XMLImporter", FALSE );
- }
-
- if (xStatusIndicator.is())
- xStatusIndicator->end();
- return nError;
-}
-
-SmXMLImport::SmXMLImport(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
- sal_uInt16 nImportFlags)
-: SvXMLImport( xServiceFactory, nImportFlags ),
- pPresLayoutElemTokenMap(0),
- pPresLayoutAttrTokenMap(0),
- pFencedAttrTokenMap(0),
- pOperatorAttrTokenMap(0),
- pAnnotationAttrTokenMap(0),
- pPresElemTokenMap(0),
- pPresScriptEmptyElemTokenMap(0),
- pPresTableElemTokenMap(0),
- pColorTokenMap(0),
- bSuccess(sal_False)
-{
-}
-
-#ifdef TL_NOT_USED_YET
-SmXMLImport::SmXMLImport(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
- com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel,
- const rtl::OUString & /*rFileName*/ )
-: SvXMLImport( xServiceFactory, rModel ) ,
- pPresLayoutElemTokenMap(0),
- pPresLayoutAttrTokenMap(0),
- pFencedAttrTokenMap(0),
- pOperatorAttrTokenMap(0),
- pAnnotationAttrTokenMap(0),
- pPresElemTokenMap(0),
- pPresScriptEmptyElemTokenMap(0),
- pPresTableElemTokenMap(0),
- pColorTokenMap(0),
- bSuccess(sal_False)
-{
-}
-#endif //TL_NOT_USED_YET
-
-const uno::Sequence< sal_Int8 > & SmXMLImport::getUnoTunnelId() throw()
-{
- static uno::Sequence< sal_Int8 > * pSeq = 0;
- if( !pSeq )
- {
- osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
- if( !pSeq )
- {
- static uno::Sequence< sal_Int8 > aSeq( 16 );
- rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
- pSeq = &aSeq;
- }
- }
- return *pSeq;
-}
-
-// #110680#
-SmXMLExport::SmXMLExport(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
- sal_uInt16 nExportFlags)
-: SvXMLExport( xServiceFactory, MAP_INCH, XML_MATH, nExportFlags ) ,
- pTree(0) ,
- bSuccess(sal_False)
-{
-}
-
-#ifdef TL_NOT_USED_YET
-// #110680#
-SmXMLExport::SmXMLExport(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
- const SmNode *pIn,
- const rtl::OUString &rFileName,
- com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler> &rHandler)
-: SvXMLExport( xServiceFactory, rFileName, rHandler ),
- pTree(pIn),
- bSuccess(sal_False)
-{
-}
-#endif //TL_NOT_USED_YET
-
-const uno::Sequence< sal_Int8 > & SmXMLExport::getUnoTunnelId() throw()
-{
- static uno::Sequence< sal_Int8 > * pSeq = 0;
- if( !pSeq )
- {
- osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
- if( !pSeq )
- {
- static uno::Sequence< sal_Int8 > aSeq( 16 );
- rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
- pSeq = &aSeq;
- }
- }
- return *pSeq;
-}
-
-//------------------------------------------------------------------------------
-
-OUString SAL_CALL SmXMLImport_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLImporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLImport_getSupportedServiceNames()
- throw()
-{
- const OUString aServiceName( IMPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLImport_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
- throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLImport(IMPORT_ALL);
- return (cppu::OWeakObject*)new SmXMLImport(rSMgr, IMPORT_ALL);
-}
-
-//------------------------------------------------------------------------------
-
-OUString SAL_CALL SmXMLExport_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLExporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLExport_getSupportedServiceNames()
- throw()
-{
- const OUString aServiceName( EXPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLExport_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
- throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_ALL );
- // EXPORT_OASIS is required here allthough there is no differrence between
- // OOo and OASIS, because without the flag, a transformation to OOo would
- // be chained in.
- return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_ALL );
-}
-
-//------------------------------------------------------------------------------
-
-OUString SAL_CALL SmXMLImportMeta_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisMetaImporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLImportMeta_getSupportedServiceNames()
- throw()
-{
- const OUString aServiceName( IMPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLImportMeta_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
- throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLImport( IMPORT_META );
- return (cppu::OWeakObject*)new SmXMLImport( rSMgr, IMPORT_META );
-}
-
-//------------------------------------------------------------------------------
-
-OUString SAL_CALL SmXMLExportMetaOOO_getImplementationName() throw()
-{
-return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLMetaExporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLExportMetaOOO_getSupportedServiceNames()
- throw()
-{
-const OUString aServiceName( EXPORT_SVC_NAME );
-const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLExportMetaOOO_createInstance(
-const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
-throw( uno::Exception )
-{
-// #110680#
-// return (cppu::OWeakObject*)new SmXMLExport( EXPORT_META );
-return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_META );
-}
-
-//------------------------------------------------------------------------------
-
-OUString SAL_CALL SmXMLExportMeta_getImplementationName() throw()
-{
-return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisMetaExporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLExportMeta_getSupportedServiceNames()
- throw()
-{
-const OUString aServiceName( EXPORT_SVC_NAME );
-const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLExportMeta_createInstance(
-const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
-throw( uno::Exception )
-{
-// #110680#
-// return (cppu::OWeakObject*)new SmXMLExport( EXPORT_META );
-return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_META );
-}
-
-//------------------------------------------------------------------------------
-
-OUString SAL_CALL SmXMLImportSettings_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisSettingsImporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLImportSettings_getSupportedServiceNames()
- throw()
-{
- const OUString aServiceName( IMPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLImportSettings_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
- throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLImport( IMPORT_SETTINGS );
- return (cppu::OWeakObject*)new SmXMLImport( rSMgr, IMPORT_SETTINGS );
-}
-
-//------------------------------------------------------------------------------
-
-OUString SAL_CALL SmXMLExportSettingsOOO_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLSettingsExporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLExportSettingsOOO_getSupportedServiceNames()
- throw()
-{
- const OUString aServiceName( EXPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLExportSettingsOOO_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
- throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_SETTINGS );
- return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_SETTINGS );
-}
-
-//------------------------------------------------------------------------------
-
-OUString SAL_CALL SmXMLExportSettings_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisSettingsExporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLExportSettings_getSupportedServiceNames()
- throw()
-{
- const OUString aServiceName( EXPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLExportSettings_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
- throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_SETTINGS );
- return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_SETTINGS );
-}
-
-
-//------------------------------------------------------------------------------
-
-OUString SAL_CALL SmXMLExportContent_getImplementationName() throw()
-{
- return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLContentExporter" ) );
-}
-
-uno::Sequence< OUString > SAL_CALL SmXMLExportContent_getSupportedServiceNames()
- throw()
-{
- const OUString aServiceName( EXPORT_SVC_NAME );
- const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
- return aSeq;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL SmXMLExportContent_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
- throw( uno::Exception )
-{
- // #110680#
- // return (cppu::OWeakObject*)new SmXMLExport( EXPORT_CONTENT );
- // The EXPORT_OASIS flag is only required to avoid that a transformer is
- // chanied in
- return (cppu::OWeakObject*)new SmXMLExport( rSMgr, EXPORT_OASIS|EXPORT_CONTENT );
-}
-
-//------------------------------------------------------------------------------
-
-// XServiceInfo
-// override empty method from parent class
-rtl::OUString SAL_CALL SmXMLExport::getImplementationName()
- throw(uno::RuntimeException)
-{
- OUString aTxt;
- switch( getExportFlags() )
- {
- case EXPORT_META:
- aTxt = SmXMLExportMeta_getImplementationName();
- break;
- case EXPORT_SETTINGS:
- aTxt = SmXMLExportSettings_getImplementationName();
- break;
- case EXPORT_CONTENT:
- aTxt = SmXMLExportContent_getImplementationName();
- break;
- case EXPORT_ALL:
- default:
- aTxt = SmXMLExport_getImplementationName();
- break;
- }
- return aTxt;
-}
-
-// XServiceInfo
-// override empty method from parent class
-rtl::OUString SAL_CALL SmXMLImport::getImplementationName()
- throw(uno::RuntimeException)
-{
- OUString aTxt;
- switch( getImportFlags() )
- {
- case IMPORT_META:
- aTxt = SmXMLImportMeta_getImplementationName();
- break;
- case IMPORT_SETTINGS:
- aTxt = SmXMLImportSettings_getImplementationName();
- break;
- case IMPORT_ALL:
- default:
- aTxt = SmXMLImport_getImplementationName();
- break;
- }
- return aTxt;
-}
-
-
-sal_Int64 SAL_CALL SmXMLImport::getSomething( const uno::Sequence< sal_Int8 >&
- rId ) throw(uno::RuntimeException)
-{
- if( rId.getLength() == 16 &&
- 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
- rId.getConstArray(), 16 ) )
- return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this));
-
- return SvXMLImport::getSomething( rId );
-}
-
-sal_Int64 SAL_CALL SmXMLExport::getSomething( const uno::Sequence< sal_Int8 >&
- rId ) throw(uno::RuntimeException)
-{
- if( rId.getLength() == 16 &&
- 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
- rId.getConstArray(), 16 ) )
- return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this));
-
- return SvXMLExport::getSomething( rId );
-}
-
-
-void SmXMLImport::endDocument(void)
- throw(xml::sax::SAXException, uno::RuntimeException)
-{
- //Set the resulted tree into the SmDocShell where it belongs
- SmNode *pTree;
- if (NULL != (pTree = GetTree()))
- {
- uno::Reference <frame::XModel> xModel = GetModel();
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-
- if (pModel)
- {
- SmDocShell *pDocShell =
- static_cast<SmDocShell*>(pModel->GetObjectShell());
- pDocShell->SetFormulaTree(pTree);
- if (0 == aText.Len()) //If we picked up no annotation text
- {
- //Make up some editable text
- aText = pDocShell->GetText();
- pTree->CreateTextFromNode(aText);
- aText.EraseTrailingChars();
- if((aText.GetChar(0) == '{') &&
- (aText.GetChar(aText.Len()-1) == '}'))
- {
- aText.Erase(0,1);
- aText.Erase(aText.Len()-1,1);
- }
- }
- pDocShell->SetText( String() );
-
- // Convert symbol names
- SmParser &rParser = pDocShell->GetParser();
- BOOL bVal = rParser.IsImportSymbolNames();
- rParser.SetImportSymbolNames( TRUE );
- SmNode *pTmpTree = rParser.Parse( aText );
- aText = rParser.GetText();
- delete pTmpTree;
- rParser.SetImportSymbolNames( bVal );
-
- pDocShell->SetText( aText );
- }
- DBG_ASSERT(pModel,"So there *was* a uno problem after all");
-
- bSuccess = sal_True;
- }
-
- SvXMLImport::endDocument();
-}
-
-/// export through an XML exporter component (output stream version)
-sal_Bool SmXMLWrapper::WriteThroughComponent(
- Reference<io::XOutputStream> xOutputStream,
- Reference<XComponent> xComponent,
- Reference<lang::XMultiServiceFactory> & rFactory,
- Reference<beans::XPropertySet> & rPropSet,
- const sal_Char* pComponentName )
-{
- DBG_ASSERT(xOutputStream.is(), "I really need an output stream!");
- DBG_ASSERT(xComponent.is(), "Need component!");
- DBG_ASSERT(NULL != pComponentName, "Need component name!");
-
- // get component
- Reference< io::XActiveDataSource > xSaxWriter(
- rFactory->createInstance(
- OUString::createFromAscii("com.sun.star.xml.sax.Writer") ),
- UNO_QUERY );
- DBG_ASSERT( xSaxWriter.is(), "can't instantiate XML writer" );
- if(!xSaxWriter.is())
- return sal_False;
-
- // connect XML writer to output stream
- xSaxWriter->setOutputStream( xOutputStream );
-
- // prepare arguments (prepend doc handler to given arguments)
- Reference<xml::sax::XDocumentHandler> xDocHandler( xSaxWriter,UNO_QUERY);
-
- Sequence<Any> aArgs( 2 );
- aArgs[0] <<= xDocHandler;
- aArgs[1] <<= rPropSet;
-
- // get filter component
- Reference< document::XExporter > xExporter(
- rFactory->createInstanceWithArguments(
- OUString::createFromAscii(pComponentName), aArgs), UNO_QUERY);
- DBG_ASSERT( xExporter.is(),
- "can't instantiate export filter component" );
- if( !xExporter.is() )
- return sal_False;
-
-
- // connect model and filter
- xExporter->setSourceDocument( xComponent );
-
- // filter!
- Reference < XFilter > xFilter( xExporter, UNO_QUERY );
- uno::Sequence< PropertyValue > aProps(0);
- xFilter->filter( aProps );
-
- uno::Reference<lang::XUnoTunnel> xFilterTunnel;
- xFilterTunnel = uno::Reference<lang::XUnoTunnel>
- ( xFilter, uno::UNO_QUERY );
- SmXMLExport *pFilter = reinterpret_cast< SmXMLExport * >(
- sal::static_int_cast< sal_uIntPtr >(
- xFilterTunnel->getSomething( SmXMLExport::getUnoTunnelId() )));
- return pFilter ? pFilter->GetSuccess() : sal_True;
-}
-
-/// export through an XML exporter component (storage version)
-sal_Bool SmXMLWrapper::WriteThroughComponent(
- const Reference < embed::XStorage >& xStorage,
- Reference<XComponent> xComponent,
- const sal_Char* pStreamName,
- Reference<lang::XMultiServiceFactory> & rFactory,
- Reference<beans::XPropertySet> & rPropSet,
- const sal_Char* pComponentName,
- sal_Bool bCompress
- )
-{
- DBG_ASSERT(xStorage.is(), "Need storage!");
- DBG_ASSERT(NULL != pStreamName, "Need stream name!");
-
- // open stream
- Reference < io::XStream > xStream;
- OUString sStreamName = OUString::createFromAscii(pStreamName);
- try
- {
- xStream = xStorage->openStreamElement( sStreamName,
- embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
- }
- catch ( uno::Exception& )
- {
- DBG_ERROR( "Can't create output stream in package!" );
- return sal_False;
- }
-
- String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) );
- OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") );
- uno::Any aAny;
- aAny <<= aMime;
-
- uno::Reference < beans::XPropertySet > xSet( xStream, uno::UNO_QUERY );
- xSet->setPropertyValue( aPropName, aAny );
-
- if( !bCompress )
- {
- aPropName = String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("Compressed") );
- sal_Bool bFalse = sal_False;
- aAny.setValue( &bFalse, ::getBooleanCppuType() );
- xSet->setPropertyValue( aPropName, aAny );
- }
-
- // even plain stream must be encrypted in encrypted document
- OUString aTmpPropName( RTL_CONSTASCII_USTRINGPARAM("UseCommonStoragePasswordEncryption") );
- sal_Bool bTrue = sal_True;
- aAny.setValue( &bTrue, ::getBooleanCppuType() );
- xSet->setPropertyValue( aTmpPropName, aAny );
-
- // set Base URL
- if( rPropSet.is() )
- {
- OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("StreamName") );
- rPropSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
- }
-
- // write the stuff
- sal_Bool bRet = WriteThroughComponent( xStream->getOutputStream(), xComponent, rFactory,
- rPropSet, pComponentName );
-
- // stream is closed by SAX parser
- //if( bRet )
- // xStream->getOutputStream()->closeOutput();
-
- return bRet;
-}
-
-sal_Bool SmXMLWrapper::Export(SfxMedium &rMedium)
-{
- sal_Bool bRet=sal_True;
- uno::Reference<lang::XMultiServiceFactory>
- xServiceFactory(utl::getProcessServiceFactory());
- DBG_ASSERT(xServiceFactory.is(),"got no service manager");
-
- //Get model
- uno::Reference< lang::XComponent > xModelComp(xModel, uno::UNO_QUERY );
-
- sal_Bool bEmbedded = sal_False;
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-
- SmDocShell *pDocShell = pModel ?
- static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0;
- if( pDocShell &&
- SFX_CREATE_MODE_EMBEDDED == pDocShell->GetCreateMode() )
- bEmbedded = sal_True;
-
- uno::Reference<task::XStatusIndicator> xStatusIndicator;
- if (!bEmbedded)
- {
- if (pDocShell /*&& pDocShell->GetMedium()*/)
- {
- DBG_ASSERT( pDocShell->GetMedium() == &rMedium,
- "different SfxMedium found" );
-
- SfxItemSet* pSet = rMedium.GetItemSet();
- if (pSet)
- {
- const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(
- pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
- if (pItem)
- pItem->GetValue() >>= xStatusIndicator;
- }
- }
-
- // set progress range and start status indicator
- if (xStatusIndicator.is())
- {
- sal_Int32 nProgressRange = bFlat ? 1 : 3;
- xStatusIndicator->start(String(SmResId(STR_STATSTR_WRITING)),
- nProgressRange);
- }
- }
-
-
- // create XPropertySet with three properties for status indicator
- comphelper::PropertyMapEntry aInfoMap[] =
- {
- { "UsePrettyPrinting", sizeof("UsePrettyPrinting")-1, 0,
- &::getBooleanCppuType(),
- beans::PropertyAttribute::MAYBEVOID, 0},
- { "BaseURI", sizeof("BaseURI")-1, 0,
- &::getCppuType( (OUString *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { "StreamRelPath", sizeof("StreamRelPath")-1, 0,
- &::getCppuType( (OUString *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { "StreamName", sizeof("StreamName")-1, 0,
- &::getCppuType( (OUString *)0 ),
- beans::PropertyAttribute::MAYBEVOID, 0 },
- { NULL, 0, 0, NULL, 0, 0 }
- };
- uno::Reference< beans::XPropertySet > xInfoSet(
- comphelper::GenericPropertySet_CreateInstance(
- new comphelper::PropertySetInfo( aInfoMap ) ) );
-
- SvtSaveOptions aSaveOpt;
- OUString sUsePrettyPrinting(RTL_CONSTASCII_USTRINGPARAM("UsePrettyPrinting"));
- sal_Bool bUsePrettyPrinting( bFlat || aSaveOpt.IsPrettyPrinting() );
- Any aAny;
- aAny.setValue( &bUsePrettyPrinting, ::getBooleanCppuType() );
- xInfoSet->setPropertyValue( sUsePrettyPrinting, aAny );
-
- // Set base URI
- OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("BaseURI") );
- xInfoSet->setPropertyValue( sPropName, makeAny( rMedium.GetBaseURL( true ) ) );
-
- sal_Int32 nSteps=0;
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
- if (!bFlat) //Storage (Package) of Stream
- {
- uno::Reference < embed::XStorage > xStg = rMedium.GetOutputStorage();
- sal_Bool bOASIS = ( SotStorage::GetVersion( xStg ) > SOFFICE_FILEFORMAT_60 );
-
- // TODO/LATER: handle the case of embedded links gracefully
- if( bEmbedded ) //&& !pStg->IsRoot() )
- {
- OUString aName;
- if ( rMedium.GetItemSet() )
- {
- const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
- rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
- if ( pDocHierarchItem )
- aName = pDocHierarchItem->GetValue();
- }
-
- if( aName.getLength() )
- {
- sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath"));
- xInfoSet->setPropertyValue( sPropName, makeAny( aName ) );
- }
- }
-
- if( !bEmbedded )
- {
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- bRet = WriteThroughComponent(
- xStg, xModelComp, "meta.xml", xServiceFactory, xInfoSet,
- (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaExporter"
- : "com.sun.star.comp.Math.XMLMetaExporter"),
- sal_False);
- }
- if( bRet )
- {
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- bRet = WriteThroughComponent(
- xStg, xModelComp, "content.xml", xServiceFactory, xInfoSet,
- "com.sun.star.comp.Math.XMLContentExporter");
- }
-
- if( bRet )
- {
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- bRet = WriteThroughComponent(
- xStg, xModelComp, "settings.xml", xServiceFactory, xInfoSet,
- (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsExporter"
- : "com.sun.star.comp.Math.XMLSettingsExporter") );
- }
- }
- else
- {
- SvStream *pStream = rMedium.GetOutStream();
- uno::Reference<io::XOutputStream> xOut(
- new utl::OOutputStreamWrapper(*pStream) );
-
- if (xStatusIndicator.is())
- xStatusIndicator->setValue(nSteps++);
-
- bRet = WriteThroughComponent(
- xOut, xModelComp, xServiceFactory, xInfoSet,
- "com.sun.star.comp.Math.XMLContentExporter");
- }
-
- if (xStatusIndicator.is())
- xStatusIndicator->end();
-
- return bRet;
-}
-
-sal_uInt32 SmXMLExport::exportDoc(enum XMLTokenEnum eClass)
-{
- if( (getExportFlags() & EXPORT_CONTENT) == 0 )
- {
- SvXMLExport::exportDoc( eClass );
- }
- else
- {
- uno::Reference <frame::XModel> xModel = GetModel();
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-
- if (pModel)
- {
- SmDocShell *pDocShell =
- static_cast<SmDocShell*>(pModel->GetObjectShell());
- pTree = pDocShell->GetFormulaTree();
- aText = pDocShell->GetText();
- }
-
- GetDocHandler()->startDocument();
-
- if( (getExportFlags() & EXPORT_NODOCTYPE) == 0 &&
- GetExtDocHandler().is() )
- {
- OUString aDocType( RTL_CONSTASCII_USTRINGPARAM( "<!DOCTYPE math:math PUBLIC \"-//OpenOffice.org//DTD Modified W3C MathML 1.01//EN\" \"math.dtd\">" ) );
- GetExtDocHandler()->unknown( aDocType );
- }
-
- /*Add xmlns line*/
- SvXMLAttributeList &rList = GetAttrList();
- rList.AddAttribute(GetNamespaceMap().GetAttrNameByKey(
- XML_NAMESPACE_MATH_IDX),GetNamespaceMap().GetNameByKey(
- XML_NAMESPACE_MATH_IDX));
-
- //I think we need something like ImplExportEntities();
- _ExportContent();
- GetDocHandler()->endDocument();
- }
-
- bSuccess=sal_True;
- return 0;
-}
-
-class SmXMLImportContext: public SvXMLImportContext
-{
-public:
- SmXMLImportContext( SmXMLImport &rImport, sal_uInt16 nPrfx,
- const OUString& rLName)
- : SvXMLImportContext(rImport, nPrfx, rLName) {}
- const SmXMLImport& GetSmImport() const
- {
- return (const SmXMLImport&)GetImport();
- }
- SmXMLImport& GetSmImport()
- {
- return (SmXMLImport&)GetImport();
- }
- virtual void TCharacters(const OUString & /*rChars*/) {}
- virtual void Characters(const OUString &rChars)
- {
- /*
- Whitespace occurring within the content of token elements is "trimmed"
- from the ends (i.e. all whitespace at the beginning and end of the
- content is removed), and "collapsed" internally (i.e. each sequence of
- 1 or more whitespace characters is replaced with one blank character).
- */
- //collapsing not done yet!
- const OUString &rChars2 = rChars.trim();
- if (rChars2.getLength())
- TCharacters(rChars2/*.collapse()*/);
- }
- virtual SvXMLImportContext *CreateChildContext(sal_uInt16 /*nPrefix*/,
- const OUString& /*rLocalName*/,
- const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/) {return 0;}
-};
-
-class SmXMLDocContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLDocContext_Impl( SmXMLImport &rImport, sal_uInt16 nPrfx,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrfx,rLName) {}
- virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > &xAttrList);
- void EndElement();
-};
-
-
-/*avert thy gaze from the proginator*/
-class SmXMLRowContext_Impl : public SmXMLDocContext_Impl
-{
-public:
- SmXMLRowContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLDocContext_Impl(rImport,nPrefix,rLName)
- { nElementCount = GetSmImport().GetNodeStack().Count(); }
- virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > &xAttrList);
- SvXMLImportContext *StrictCreateChildContext(sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > &xAttrList);
- void EndElement();
-protected:
- ULONG nElementCount;
-};
-
-class SmXMLFracContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLFracContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
- void EndElement();
-};
-
-class SmXMLSqrtContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLSqrtContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
- void EndElement();
-};
-
-class SmXMLRootContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLRootContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
- void EndElement();
-};
-
-struct SmXMLContext_Helper
-{
- SmXMLContext_Helper(SmXMLImportContext &rImport) :
- nIsBold(-1), nIsItalic(-1),nFontSize(0.0), rContext(rImport) {}
-
- void RetrieveAttrs(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
- void ApplyAttrs();
-
- sal_Int8 nIsBold;
- sal_Int8 nIsItalic;
- double nFontSize;
- sal_Bool bFontNodeNeeded;
- OUString sFontFamily;
- OUString sColor;
-
- SmXMLImportContext rContext;
-};
-
-void SmXMLContext_Helper::RetrieveAttrs(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
- sal_Int8 nOldIsBold=nIsBold;
- sal_Int8 nOldIsItalic=nIsItalic;
- double nOldFontSize=nFontSize;
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- OUString sOldFontFamily = sFontFamily;
- for (sal_Int16 i=0;i<nAttrCount;i++)
- {
- OUString sAttrName = xAttrList->getNameByIndex(i);
- OUString aLocalName;
- sal_uInt16 nPrefix = rContext.GetSmImport().GetNamespaceMap().
- GetKeyByAttrName(sAttrName,&aLocalName);
- OUString sValue = xAttrList->getValueByIndex(i);
- const SvXMLTokenMap &rAttrTokenMap =
- rContext.GetSmImport().GetPresLayoutAttrTokenMap();
- switch(rAttrTokenMap.Get(nPrefix,aLocalName))
- {
- case XML_TOK_FONTWEIGHT:
- nIsBold = sValue.equals(GetXMLToken(XML_BOLD));
- break;
- case XML_TOK_FONTSTYLE:
- nIsItalic = sValue.equals(GetXMLToken(XML_ITALIC));
- break;
- case XML_TOK_FONTSIZE:
- SvXMLUnitConverter::convertDouble(nFontSize,sValue);
- rContext.GetSmImport().GetMM100UnitConverter().
- setXMLMeasureUnit(MAP_POINT);
- if (-1 == sValue.indexOf(GetXMLToken(XML_UNIT_PT)))
- {
- if (-1 == sValue.indexOf('%'))
- nFontSize=0.0;
- else
- {
- rContext.GetSmImport().GetMM100UnitConverter().
- setXMLMeasureUnit(MAP_RELATIVE);
- }
- }
- break;
- case XML_TOK_FONTFAMILY:
- sFontFamily = sValue;
- break;
- case XML_TOK_COLOR:
- sColor = sValue;
- break;
- default:
- break;
- }
- }
-
- if ((nOldIsBold!=nIsBold) || (nOldIsItalic!=nIsItalic) ||
- (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily)
- || sColor.getLength())
- bFontNodeNeeded=sal_True;
- else
- bFontNodeNeeded=sal_False;
-}
-
-void SmXMLContext_Helper::ApplyAttrs()
-{
- SmNodeStack &rNodeStack = rContext.GetSmImport().GetNodeStack();
-
- if (bFontNodeNeeded)
- {
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
-
- if (nIsBold != -1)
- {
- if (nIsBold)
- aToken.eType = TBOLD;
- else
- aToken.eType = TNBOLD;
- SmStructureNode *pFontNode = static_cast<SmStructureNode *>
- (new SmFontNode(aToken));
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (nIsItalic != -1)
- {
- if (nIsItalic)
- aToken.eType = TITALIC;
- else
- aToken.eType = TNITALIC;
- SmStructureNode *pFontNode = static_cast<SmStructureNode *>
- (new SmFontNode(aToken));
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (nFontSize != 0.0)
- {
- aToken.eType = TSIZE;
- SmFontNode *pFontNode = new SmFontNode(aToken);
-
- if (MAP_RELATIVE == rContext.GetSmImport().GetMM100UnitConverter().
- getXMLMeasureUnit())
- {
- if (nFontSize < 100.00)
- pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
- FNTSIZ_DIVIDE);
- else
- pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
- FNTSIZ_MULTIPLY);
- }
- else
- pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
-
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (sFontFamily.getLength())
- {
- if (sFontFamily.equalsIgnoreAsciiCase(GetXMLToken(XML_FIXED)))
- aToken.eType = TFIXED;
- else if (sFontFamily.equalsIgnoreAsciiCase(OUString(
- RTL_CONSTASCII_USTRINGPARAM("sans"))))
- aToken.eType = TSANS;
- else if (sFontFamily.equalsIgnoreAsciiCase(OUString(
- RTL_CONSTASCII_USTRINGPARAM("serif"))))
- aToken.eType = TSERIF;
- else //Just give up, we need to extend our font mechanism to be
- //more general
- return;
-
- aToken.aText = sFontFamily;
- SmFontNode *pFontNode = new SmFontNode(aToken);
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (sColor.getLength())
- {
- //Again we can only handle a small set of colours in
- //StarMath for now.
- const SvXMLTokenMap& rTokenMap =
- rContext.GetSmImport().GetColorTokenMap();
- aToken.eType = static_cast<SmTokenType>(rTokenMap.Get(
- XML_NAMESPACE_MATH, sColor));
- if (aToken.eType != -1)
- {
- SmFontNode *pFontNode = new SmFontNode(aToken);
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- }
-
- }
-}
-
-class SmXMLStyleContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- /*Right now the style tag is completely ignored*/
- SmXMLStyleContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) : SmXMLRowContext_Impl(rImport,nPrefix,rLName),
- aStyleHelper(*this) {}
- void EndElement();
- void StartElement(const uno::Reference< xml::sax::XAttributeList > &
- xAttrList );
-protected:
- SmXMLContext_Helper aStyleHelper;
-};
-
-void SmXMLStyleContext_Impl::StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
-#if 1
- aStyleHelper.RetrieveAttrs(xAttrList);
-#else
- sal_Int8 nOldIsBold=nIsBold;
- sal_Int8 nOldIsItalic=nIsItalic;
- double nOldFontSize=nFontSize;
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- OUString sOldFontFamily = sFontFamily;
- for (sal_Int16 i=0;i<nAttrCount;i++)
- {
- OUString sAttrName = xAttrList->getNameByIndex(i);
- OUString aLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName(sAttrName,&aLocalName);
- OUString sValue = xAttrList->getValueByIndex(i);
- const SvXMLTokenMap &rAttrTokenMap =
- GetSmImport().GetPresLayoutAttrTokenMap();
- switch(rAttrTokenMap.Get(nPrefix,aLocalName))
- {
- case XML_TOK_FONTWEIGHT:
- nIsBold = sValue.equals(GetXMLToken(XML_BOLD));
- break;
- case XML_TOK_FONTSTYLE:
- nIsItalic = sValue.equals(GetXMLToken(XML_ITALIC));
- break;
- case XML_TOK_FONTSIZE:
- SvXMLUnitConverter::convertDouble(nFontSize,sValue);
- GetSmImport().GetMM100UnitConverter().
- setXMLMeasureUnit(MAP_POINT);
- if (-1 == sValue.indexOf(GetXMLToken(XML_UNIT_PT)))
- if (-1 == sValue.indexOf('%'))
- nFontSize=0.0;
- else
- {
- GetSmImport().GetMM100UnitConverter().
- setXMLMeasureUnit(MAP_RELATIVE);
- }
- break;
- case XML_TOK_FONTFAMILY:
- sFontFamily = sValue;
- break;
- case XML_TOK_COLOR:
- sColor = sValue;
- break;
- default:
- break;
- }
- }
-
- if ((nOldIsBold!=nIsBold) || (nOldIsItalic!=nIsItalic) ||
- (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily)
- || sColor.getLength())
- bFontNodeNeeded=sal_True;
- else
- bFontNodeNeeded=sal_False;
-#endif
-}
-
-
-void SmXMLStyleContext_Impl::EndElement()
-{
- /*
- <mstyle> accepts any number of arguments; if this number is not 1, its
- contents are treated as a single "inferred <mrow>" containing its
- arguments
- */
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- if (rNodeStack.Count() - nElementCount > 1)
- SmXMLRowContext_Impl::EndElement();
-#if 1
- aStyleHelper.ApplyAttrs();
-#else
- if (bFontNodeNeeded)
- {
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
-
- if (nIsBold != -1)
- {
- if (nIsBold)
- aToken.eType = TBOLD;
- else
- aToken.eType = TNBOLD;
- SmStructureNode *pFontNode = static_cast<SmStructureNode *>
- (new SmFontNode(aToken));
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (nIsItalic != -1)
- {
- if (nIsItalic)
- aToken.eType = TITALIC;
- else
- aToken.eType = TNITALIC;
- SmStructureNode *pFontNode = static_cast<SmStructureNode *>
- (new SmFontNode(aToken));
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (nFontSize != 0.0)
- {
- aToken.eType = TSIZE;
- SmFontNode *pFontNode = new SmFontNode(aToken);
-
- if (MAP_RELATIVE == GetSmImport().GetMM100UnitConverter().
- getXMLMeasureUnit())
- {
- if (nFontSize < 100.00)
- pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
- FNTSIZ_DIVIDE);
- else
- pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
- FNTSIZ_MULTIPLY);
- }
- else
- pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
-
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (sFontFamily.getLength())
- {
- if (sFontFamily.equalsIgnoreCase(GetXMLToken(XML_FIXED)))
- aToken.eType = TFIXED;
- else if (sFontFamily.equalsIgnoreCase(OUString(
- RTL_CONSTASCII_USTRINGPARAM("sans"))))
- aToken.eType = TSANS;
- else if (sFontFamily.equalsIgnoreCase(OUString(
- RTL_CONSTASCII_USTRINGPARAM("serif"))))
- aToken.eType = TSERIF;
- else //Just give up, we need to extend our font mechanism to be
- //more general
- return;
-
- aToken.aText = sFontFamily;
- SmFontNode *pFontNode = new SmFontNode(aToken);
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- if (sColor.getLength())
- {
- //Again we can only handle a small set of colours in
- //StarMath for now.
- const SvXMLTokenMap& rTokenMap =
- GetSmImport().GetColorTokenMap();
- aToken.eType = static_cast<SmTokenType>(rTokenMap.Get(
- XML_NAMESPACE_MATH, sColor));
- if (aToken.eType != -1)
- {
- SmFontNode *pFontNode = new SmFontNode(aToken);
- pFontNode->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pFontNode);
- }
- }
-
- }
-#endif
-}
-
-class SmXMLPaddedContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- /*Right now the style tag is completely ignored*/
- SmXMLPaddedContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
- void EndElement();
-};
-
-void SmXMLPaddedContext_Impl::EndElement()
-{
- /*
- <mpadded> accepts any number of arguments; if this number is not 1, its
- contents are treated as a single "inferred <mrow>" containing its
- arguments
- */
- if (GetSmImport().GetNodeStack().Count() - nElementCount > 1)
- SmXMLRowContext_Impl::EndElement();
-}
-
-class SmXMLPhantomContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- /*Right now the style tag is completely ignored*/
- SmXMLPhantomContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
- void EndElement();
-};
-
-void SmXMLPhantomContext_Impl::EndElement()
-{
- /*
- <mphantom> accepts any number of arguments; if this number is not 1, its
- contents are treated as a single "inferred <mrow>" containing its
- arguments
- */
- if (GetSmImport().GetNodeStack().Count() - nElementCount > 1)
- SmXMLRowContext_Impl::EndElement();
-
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
- aToken.eType = TPHANTOM;
-
- SmStructureNode *pPhantom = static_cast<SmStructureNode *>
- (new SmFontNode(aToken));
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- pPhantom->SetSubNodes(0,rNodeStack.Pop());
- rNodeStack.Push(pPhantom);
-}
-
-class SmXMLFencedContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLFencedContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName),
- cBegin('('), cEnd(')') {}
- void StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList );
- void EndElement();
-protected:
- sal_Unicode cBegin;
- sal_Unicode cEnd;
-};
-
-
-void SmXMLFencedContext_Impl::StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for (sal_Int16 i=0;i<nAttrCount;i++)
- {
- OUString sAttrName = xAttrList->getNameByIndex(i);
- OUString aLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName(sAttrName,&aLocalName);
- OUString sValue = xAttrList->getValueByIndex(i);
- const SvXMLTokenMap &rAttrTokenMap =
- GetSmImport().GetFencedAttrTokenMap();
- switch(rAttrTokenMap.Get(nPrefix,aLocalName))
- {
- //temp, starmath cannot handle multichar brackets (I think)
- case XML_TOK_OPEN:
- cBegin = sValue[0];
- break;
- case XML_TOK_CLOSE:
- cEnd = sValue[0];
- break;
- default:
- /*Go to superclass*/
- break;
- }
- }
-}
-
-
-void SmXMLFencedContext_Impl::EndElement()
-{
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.aText = ',';
- aToken.eType = TLEFT;
- aToken.nLevel = 5;
-
- aToken.eType = TLPARENT;
- aToken.cMathChar = cBegin;
- SmStructureNode *pSNode = new SmBraceNode(aToken);
- SmNode *pLeft = new SmMathSymbolNode(aToken);
-
- aToken.cMathChar = cEnd;
- aToken.eType = TRPARENT;
- SmNode *pRight = new SmMathSymbolNode(aToken);
-
- SmNodeArray aRelationArray;
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
-
- aToken.cMathChar = '\0';
- aToken.aText = ',';
- aToken.eType = TIDENT;
-
- ULONG i=rNodeStack.Count()-nElementCount;
- if (rNodeStack.Count()-nElementCount > 1)
- i+=rNodeStack.Count()-1-nElementCount;
- aRelationArray.SetSize(i);
- while(rNodeStack.Count() > nElementCount)
- {
- aRelationArray.Put(--i,rNodeStack.Pop());
- if (rNodeStack.Count() > 1)
- aRelationArray.Put(--i,new SmGlyphSpecialNode(aToken));
- }
-
- SmToken aDummy;
- SmStructureNode *pBody = new SmExpressionNode(aDummy);
- pBody->SetSubNodes(aRelationArray);
-
-
- pSNode->SetSubNodes(pLeft,pBody,pRight);
- pSNode->SetScaleMode(SCALE_HEIGHT);
- GetSmImport().GetNodeStack().Push(pSNode);
-}
-
-
-class SmXMLErrorContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLErrorContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
- void EndElement();
-};
-
-void SmXMLErrorContext_Impl::EndElement()
-{
- /*Right now the error tag is completely ignored, what
- can I do with it in starmath, ?, maybe we need a
- report window ourselves, do a test for validity of
- the xml input, use merrors, and then generate
- the markup inside the merror with a big red colour
- of something. For now just throw them all away.
- */
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- while(rNodeStack.Count() > nElementCount)
- {
- SmNode *pNode = rNodeStack.Pop();
- delete pNode;
- }
-}
-
-class SmXMLNumberContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLNumberContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName)
- {
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
- aToken.eType = TNUMBER;
- }
- virtual void TCharacters(const OUString &rChars);
- void EndElement();
-protected:
- SmToken aToken;
-};
-
-void SmXMLNumberContext_Impl::TCharacters(const OUString &rChars)
-{
- aToken.aText = rChars;
-}
-
-void SmXMLNumberContext_Impl::EndElement()
-{
- GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_NUMBER));
-}
-
-class SmXMLAnnotationContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLAnnotationContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName), bIsStarMath(sal_False) {}
- virtual void Characters(const OUString &rChars);
- void StartElement(const uno::Reference<xml::sax::XAttributeList > &
- xAttrList );
-private:
- sal_Bool bIsStarMath;
-};
-
-void SmXMLAnnotationContext_Impl::StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for (sal_Int16 i=0;i<nAttrCount;i++)
- {
- OUString sAttrName = xAttrList->getNameByIndex(i);
- OUString aLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName(sAttrName,&aLocalName);
-
- OUString sValue = xAttrList->getValueByIndex(i);
- const SvXMLTokenMap &rAttrTokenMap =
- GetSmImport().GetAnnotationAttrTokenMap();
- switch(rAttrTokenMap.Get(nPrefix,aLocalName))
- {
- case XML_TOK_ENCODING:
- bIsStarMath= sValue.equals(
- OUString(RTL_CONSTASCII_USTRINGPARAM("StarMath 5.0")));
- break;
- default:
- break;
- }
- }
-}
-
-void SmXMLAnnotationContext_Impl::Characters(const OUString &rChars)
-{
- if (bIsStarMath)
- GetSmImport().GetText().Append(String(rChars));
-}
-
-class SmXMLTextContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLTextContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName)
- {
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
- aToken.eType = TTEXT;
- }
- virtual void TCharacters(const OUString &rChars);
- void EndElement();
-protected:
- SmToken aToken;
-};
-
-void SmXMLTextContext_Impl::TCharacters(const OUString &rChars)
-{
- aToken.aText = rChars;
-}
-
-void SmXMLTextContext_Impl::EndElement()
-{
- GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_TEXT));
-}
-
-class SmXMLStringContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLStringContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName)
- {
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
- aToken.eType = TTEXT;
- }
- virtual void TCharacters(const OUString &rChars);
- void EndElement();
-protected:
- SmToken aToken;
-};
-
-void SmXMLStringContext_Impl::TCharacters(const OUString &rChars)
-{
- /*
- The content of <ms> elements should be rendered with visible "escaping" of
- certain characters in the content, including at least "double quote"
- itself, and preferably whitespace other than individual blanks. The intent
- is for the viewer to see that the expression is a string literal, and to
- see exactly which characters form its content. For example, <ms>double
- quote is "</ms> might be rendered as "double quote is \"".
-
- Obviously this isn't fully done here.
- */
- aToken.aText.Erase();
- aToken.aText += '\"';
- aToken.aText += String(rChars);
- aToken.aText += '\"';
-}
-
-void SmXMLStringContext_Impl::EndElement()
-{
- GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_FIXED));
-}
-
-class SmXMLIdentifierContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLIdentifierContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName),aStyleHelper(*this)
- {
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
- aToken.eType = TIDENT;
- }
- void TCharacters(const OUString &rChars);
- void StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList ) {aStyleHelper.RetrieveAttrs(xAttrList);};
- void EndElement();
-protected:
- SmXMLContext_Helper aStyleHelper;
- SmToken aToken;
-};
-
-void SmXMLIdentifierContext_Impl::EndElement()
-{
- SmTextNode *pNode = 0;
- //we will handle identifier italic/normal here instead of with a standalone
- //font node
- if (((aStyleHelper.nIsItalic == -1) && (aToken.aText.Len() > 1))
- || ((aStyleHelper.nIsItalic == 0) && (aToken.aText.Len() == 1)))
- {
- pNode = new SmTextNode(aToken,FNT_FUNCTION);
- pNode->GetFont().SetItalic(ITALIC_NONE);
- aStyleHelper.nIsItalic = -1;
- }
- else
- pNode = new SmTextNode(aToken,FNT_VARIABLE);
- if (aStyleHelper.bFontNodeNeeded && aStyleHelper.nIsItalic != -1)
- {
- if (aStyleHelper.nIsItalic)
- pNode->GetFont().SetItalic(ITALIC_NORMAL);
- else
- pNode->GetFont().SetItalic(ITALIC_NONE);
- }
-
- if ((-1!=aStyleHelper.nIsBold) || (0.0!=aStyleHelper.nFontSize) ||
- (aStyleHelper.sFontFamily.getLength()) ||
- aStyleHelper.sColor.getLength())
- aStyleHelper.bFontNodeNeeded=sal_True;
- else
- aStyleHelper.bFontNodeNeeded=sal_False;
- if (aStyleHelper.bFontNodeNeeded)
- aStyleHelper.ApplyAttrs();
- GetSmImport().GetNodeStack().Push(pNode);
-}
-
-void SmXMLIdentifierContext_Impl::TCharacters(const OUString &rChars)
-{
- aToken.aText = rChars;
-}
-
-class SmXMLOperatorContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLOperatorContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName), bIsStretchy(sal_False)
- {
- aToken.nGroup = 0;
- aToken.eType = TSPECIAL;
- aToken.nLevel = 5;
- }
- void TCharacters(const OUString &rChars);
- void StartElement(const uno::Reference<
- xml::sax::XAttributeList > &xAttrList );
- void EndElement();
-protected:
- SmToken aToken;
-private:
- sal_Bool bIsStretchy;
-};
-
-void SmXMLOperatorContext_Impl::TCharacters(const OUString &rChars)
-{
- aToken.cMathChar = rChars[0];
-}
-
-void SmXMLOperatorContext_Impl::EndElement()
-{
- SmMathSymbolNode *pNode = new SmMathSymbolNode(aToken);
- //For stretchy scaling the scaling must be retrieved from this node
- //and applied to the expression itself so as to get the expression
- //to scale the operator to the height of the expression itself
- if (bIsStretchy)
- pNode->SetScaleMode(SCALE_HEIGHT);
- GetSmImport().GetNodeStack().Push(pNode);
-}
-
-
-
-void SmXMLOperatorContext_Impl::StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for (sal_Int16 i=0;i<nAttrCount;i++)
- {
- OUString sAttrName = xAttrList->getNameByIndex(i);
- OUString aLocalName;
- sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
- GetKeyByAttrName(sAttrName,&aLocalName);
-
- OUString sValue = xAttrList->getValueByIndex(i);
- const SvXMLTokenMap &rAttrTokenMap =
- GetSmImport().GetOperatorAttrTokenMap();
- switch(rAttrTokenMap.Get(nPrefix,aLocalName))
- {
- case XML_TOK_STRETCHY:
- bIsStretchy = sValue.equals(
- GetXMLToken(XML_TRUE));
- break;
- default:
- break;
- }
- }
-}
-
-
-class SmXMLSpaceContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLSpaceContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName) {}
- void StartElement(const uno::Reference<
- xml::sax::XAttributeList >& xAttrList );
-};
-
-void SmXMLSpaceContext_Impl::StartElement(
- const uno::Reference<xml::sax::XAttributeList > & /*xAttrList*/ )
-{
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.eType = TBLANK;
- aToken.nLevel = 5;
- SmBlankNode *pBlank = new SmBlankNode(aToken);
- pBlank->IncreaseBy(aToken);
- GetSmImport().GetNodeStack().Push(pBlank);
-}
-
-class SmXMLSubContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLSubContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
- void EndElement() { GenericEndElement(TRSUB,RSUB); }
-protected:
- void GenericEndElement(SmTokenType eType,SmSubSup aSubSup);
-};
-
-
-void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType,SmSubSup aSubSup)
-{
- /*The <msub> element requires exactly 2 arguments.*/
- DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
- "Sub has not two arguments");
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = eType;
- SmSubSupNode *pNode = new SmSubSupNode(aToken);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
-
- // initialize subnodes array
- SmNodeArray aSubNodes;
- aSubNodes.SetSize(1 + SUBSUP_NUM_ENTRIES);
- for (ULONG i = 1; i < aSubNodes.GetSize(); i++)
- aSubNodes.Put(i, NULL);
-
- aSubNodes.Put(aSubSup+1,rNodeStack.Pop());
- aSubNodes.Put(0, rNodeStack.Pop());
- pNode->SetSubNodes(aSubNodes);
- rNodeStack.Push(pNode);
-}
-
-class SmXMLSupContext_Impl : public SmXMLSubContext_Impl
-{
-public:
- SmXMLSupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLSubContext_Impl(rImport,nPrefix,rLName) {}
- void EndElement() {GenericEndElement(TRSUP,RSUP);}
-};
-
-class SmXMLSubSupContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLSubSupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
- void EndElement() { GenericEndElement(TRSUB,RSUB,RSUP); }
-protected:
- void GenericEndElement(SmTokenType eType,
- SmSubSup aSub,SmSubSup aSup);
-
-};
-
-void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType,
- SmSubSup aSub,SmSubSup aSup)
-{
- /*The <msub> element requires exactly 3 arguments.*/
- DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 3,
- "SubSup has not three arguments");
-
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = eType;
- SmSubSupNode *pNode = new SmSubSupNode(aToken);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
-
- // initialize subnodes array
- SmNodeArray aSubNodes;
- aSubNodes.SetSize(1 + SUBSUP_NUM_ENTRIES);
- for (ULONG i = 1; i < aSubNodes.GetSize(); i++)
- aSubNodes.Put(i, NULL);
-
- aSubNodes.Put(aSup+1,rNodeStack.Pop());
- aSubNodes.Put(aSub+1,rNodeStack.Pop());
- aSubNodes.Put(0, rNodeStack.Pop());
- pNode->SetSubNodes(aSubNodes);
- rNodeStack.Push(pNode);
-}
-
-class SmXMLUnderContext_Impl : public SmXMLSubContext_Impl
-{
-public:
- SmXMLUnderContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLSubContext_Impl(rImport,nPrefix,rLName) {}
- void StartElement(const uno::Reference< xml::sax::XAttributeList > &
- xAttrList );
- void EndElement();
- void HandleAccent();
-protected:
- sal_Int16 nAttrCount;
-};
-
-void SmXMLUnderContext_Impl::StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
- nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-}
-
-void SmXMLUnderContext_Impl::HandleAccent()
-{
- DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
- "Sub has not two arguments");
-
- /*Just one special case for the underline thing*/
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- SmNode *pTest = rNodeStack.Pop();
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TUNDERLINE;
-
-
- SmNodeArray aSubNodes;
- aSubNodes.SetSize(2);
-
- SmStructureNode *pNode = new SmAttributNode(aToken);
- if ((pTest->GetToken().cMathChar & 0x0FFF) == 0x0332)
- {
- aSubNodes.Put(0, new SmRectangleNode(aToken));
- delete pTest;
- }
- else
- aSubNodes.Put(0, pTest);
-
- aSubNodes.Put(1, rNodeStack.Pop());
- pNode->SetSubNodes(aSubNodes);
- pNode->SetScaleMode(SCALE_WIDTH);
- rNodeStack.Push(pNode);
-}
-
-
-void SmXMLUnderContext_Impl::EndElement()
-{
- if (!nAttrCount)
- GenericEndElement(TCSUB,CSUB);
- else
- HandleAccent();
-#if 0
- //UnderBrace trick
- SmStructureNode *pNode = rNodeStack.Pop();
- if (pNode->GetSubNode(1)->GetToken().cMathChar == (0x0332|0xf000))
- if (pNode->GetSubNode(0)->GetToken().cMathChar == (0x0332|0xf000))
-#endif
-}
-
-class SmXMLOverContext_Impl : public SmXMLSubContext_Impl
-{
-public:
- SmXMLOverContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLSubContext_Impl(rImport,nPrefix,rLName), nAttrCount(0) {}
- void EndElement();
- void StartElement(const uno::Reference< xml::sax::XAttributeList > &
- xAttrList );
- void HandleAccent();
-protected:
- sal_Int16 nAttrCount;
-};
-
-
-void SmXMLOverContext_Impl::StartElement(const uno::Reference<
- xml::sax::XAttributeList > & xAttrList )
-{
- nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-}
-
-
-void SmXMLOverContext_Impl::EndElement()
-{
- if (!nAttrCount)
- GenericEndElement(TCSUP,CSUP);
- else
- HandleAccent();
-}
-
-
-void SmXMLOverContext_Impl::HandleAccent()
-{
- DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
- "Sub has not two arguments");
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TACUTE;
-
- SmAttributNode *pNode = new SmAttributNode(aToken);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
-
- SmNodeArray aSubNodes;
- aSubNodes.SetSize(2);
- aSubNodes.Put(0, rNodeStack.Pop());
- aSubNodes.Put(1, rNodeStack.Pop());
- pNode->SetSubNodes(aSubNodes);
- pNode->SetScaleMode(SCALE_WIDTH);
- rNodeStack.Push(pNode);
-
-}
-
-class SmXMLUnderOverContext_Impl : public SmXMLSubSupContext_Impl
-{
-public:
- SmXMLUnderOverContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLSubSupContext_Impl(rImport,nPrefix,rLName) {}
- void EndElement() { GenericEndElement(TCSUB,CSUB,CSUP); }
-};
-
-class SmXMLMultiScriptsContext_Impl : public SmXMLSubSupContext_Impl
-{
-public:
- SmXMLMultiScriptsContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) :
- SmXMLSubSupContext_Impl(rImport,nPrefix,rLName),
- bHasPrescripts(FALSE) {}
- void EndElement();
- void MiddleElement();
- SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > &xAttrList);
-private:
- sal_Bool bHasPrescripts;
-};
-
-class SmXMLNoneContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLNoneContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName) {}
- void EndElement();
-};
-
-
-void SmXMLNoneContext_Impl::EndElement(void)
-{
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.aText.Erase();
- aToken.nLevel = 5;
- aToken.eType = TIDENT;
- GetSmImport().GetNodeStack().Push(
- new SmTextNode(aToken,FNT_VARIABLE));
-}
-
-class SmXMLPrescriptsContext_Impl : public SmXMLImportContext
-{
-public:
- SmXMLPrescriptsContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName)
- : SmXMLImportContext(rImport,nPrefix,rLName) {}
-};
-
-class SmXMLTableRowContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLTableRowContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) :
- SmXMLRowContext_Impl(rImport,nPrefix,rLName)
- {}
- SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > &xAttrList);
-};
-
-
-class SmXMLTableContext_Impl : public SmXMLTableRowContext_Impl
-{
-public:
- SmXMLTableContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) :
- SmXMLTableRowContext_Impl(rImport,nPrefix,rLName)
- {}
- void EndElement();
- SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > &xAttrList);
-};
-
-
-class SmXMLTableCellContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLTableCellContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) :
- SmXMLRowContext_Impl(rImport,nPrefix,rLName)
- {}
-};
-
-class SmXMLAlignGroupContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLAlignGroupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) :
- SmXMLRowContext_Impl(rImport,nPrefix,rLName)
- {}
- /*Don't do anything with alignment for now*/
- void EndElement() {}
-};
-
-class SmXMLActionContext_Impl : public SmXMLRowContext_Impl
-{
-public:
- SmXMLActionContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
- const OUString& rLName) :
- SmXMLRowContext_Impl(rImport,nPrefix,rLName)
- {}
- void EndElement();
-};
-
-// NB: virtually inherit so we can multiply inherit properly
-// in SmXMLFlatDocContext_Impl
-class SmXMLOfficeContext_Impl : public virtual SvXMLImportContext
-{
-public:
- SmXMLOfficeContext_Impl( SmXMLImport &rImport, sal_uInt16 nPrfx,
- const OUString& rLName)
- : SvXMLImportContext(rImport,nPrfx,rLName) {}
- virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > &xAttrList);
-};
-
-SvXMLImportContext *SmXMLOfficeContext_Impl::CreateChildContext(sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference< xml::sax::XAttributeList > &xAttrList)
-{
- SvXMLImportContext *pContext = 0;
- if( XML_NAMESPACE_OFFICE == nPrefix &&
- rLocalName == GetXMLToken(XML_META) ) {
- DBG_WARNING("XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
- } else if( XML_NAMESPACE_OFFICE == nPrefix &&
- rLocalName == GetXMLToken(XML_SETTINGS) )
- pContext = new XMLDocumentSettingsContext( GetImport(),
- XML_NAMESPACE_OFFICE, rLocalName,
- xAttrList );
- else
- pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
-
- return pContext;
-}
-
-// context for flat file xml format
-class SmXMLFlatDocContext_Impl
- : public SmXMLOfficeContext_Impl, public SvXMLMetaDocumentContext
-{
-public:
- SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport,
- USHORT i_nPrefix, const OUString & i_rLName,
- const uno::Reference<document::XDocumentProperties>& i_xDocProps,
- const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder);
-
- virtual ~SmXMLFlatDocContext_Impl();
-
- virtual SvXMLImportContext *CreateChildContext(
- USHORT i_nPrefix, const OUString& i_rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& i_xAttrList);
-};
-
-SmXMLFlatDocContext_Impl::SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport,
- USHORT i_nPrefix, const OUString & i_rLName,
- const uno::Reference<document::XDocumentProperties>& i_xDocProps,
- const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder) :
- SvXMLImportContext(i_rImport, i_nPrefix, i_rLName),
- SmXMLOfficeContext_Impl(i_rImport, i_nPrefix, i_rLName),
- SvXMLMetaDocumentContext(i_rImport, i_nPrefix, i_rLName,
- i_xDocProps, i_xDocBuilder)
-{
-}
-
-SmXMLFlatDocContext_Impl::~SmXMLFlatDocContext_Impl() { }
-
-
-SvXMLImportContext *SmXMLFlatDocContext_Impl::CreateChildContext(
- USHORT i_nPrefix, const OUString& i_rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& i_xAttrList)
-{
- // behave like meta base class iff we encounter office:meta
- if( XML_NAMESPACE_OFFICE == i_nPrefix &&
- i_rLocalName == GetXMLToken(XML_META) ) {
- return SvXMLMetaDocumentContext::CreateChildContext(
- i_nPrefix, i_rLocalName, i_xAttrList );
- } else {
- return SmXMLOfficeContext_Impl::CreateChildContext(
- i_nPrefix, i_rLocalName, i_xAttrList );
- }
-}
-
-static __FAR_DATA SvXMLTokenMapEntry aPresLayoutElemTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_SEMANTICS, XML_TOK_SEMANTICS },
- { XML_NAMESPACE_MATH, XML_MATH, XML_TOK_MATH },
- { XML_NAMESPACE_MATH, XML_MSTYLE, XML_TOK_MSTYLE },
- { XML_NAMESPACE_MATH, XML_MERROR, XML_TOK_MERROR },
- { XML_NAMESPACE_MATH, XML_MPHANTOM, XML_TOK_MPHANTOM },
- { XML_NAMESPACE_MATH, XML_MROW, XML_TOK_MROW },
- { XML_NAMESPACE_MATH, XML_MFRAC, XML_TOK_MFRAC },
- { XML_NAMESPACE_MATH, XML_MSQRT, XML_TOK_MSQRT },
- { XML_NAMESPACE_MATH, XML_MROOT, XML_TOK_MROOT },
- { XML_NAMESPACE_MATH, XML_MSUB, XML_TOK_MSUB },
- { XML_NAMESPACE_MATH, XML_MSUP, XML_TOK_MSUP },
- { XML_NAMESPACE_MATH, XML_MSUBSUP, XML_TOK_MSUBSUP },
- { XML_NAMESPACE_MATH, XML_MUNDER, XML_TOK_MUNDER },
- { XML_NAMESPACE_MATH, XML_MOVER, XML_TOK_MOVER },
- { XML_NAMESPACE_MATH, XML_MUNDEROVER, XML_TOK_MUNDEROVER },
- { XML_NAMESPACE_MATH, XML_MMULTISCRIPTS, XML_TOK_MMULTISCRIPTS },
- { XML_NAMESPACE_MATH, XML_MTABLE, XML_TOK_MTABLE },
- { XML_NAMESPACE_MATH, XML_MACTION, XML_TOK_MACTION },
- { XML_NAMESPACE_MATH, XML_MFENCED, XML_TOK_MFENCED },
- { XML_NAMESPACE_MATH, XML_MPADDED, XML_TOK_MPADDED },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aPresLayoutAttrTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_FONTWEIGHT, XML_TOK_FONTWEIGHT },
- { XML_NAMESPACE_MATH, XML_FONTSTYLE, XML_TOK_FONTSTYLE },
- { XML_NAMESPACE_MATH, XML_FONTSIZE, XML_TOK_FONTSIZE },
- { XML_NAMESPACE_MATH, XML_FONTFAMILY, XML_TOK_FONTFAMILY },
- { XML_NAMESPACE_MATH, XML_COLOR, XML_TOK_COLOR },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aFencedAttrTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_OPEN, XML_TOK_OPEN },
- { XML_NAMESPACE_MATH, XML_CLOSE, XML_TOK_CLOSE },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aOperatorAttrTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_STRETCHY, XML_TOK_STRETCHY },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aAnnotationAttrTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_ENCODING, XML_TOK_ENCODING },
- XML_TOKEN_MAP_END
-};
-
-
-static __FAR_DATA SvXMLTokenMapEntry aPresElemTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_ANNOTATION, XML_TOK_ANNOTATION },
- { XML_NAMESPACE_MATH, XML_MI, XML_TOK_MI },
- { XML_NAMESPACE_MATH, XML_MN, XML_TOK_MN },
- { XML_NAMESPACE_MATH, XML_MO, XML_TOK_MO },
- { XML_NAMESPACE_MATH, XML_MTEXT, XML_TOK_MTEXT },
- { XML_NAMESPACE_MATH, XML_MSPACE,XML_TOK_MSPACE },
- { XML_NAMESPACE_MATH, XML_MS, XML_TOK_MS },
- { XML_NAMESPACE_MATH, XML_MALIGNGROUP, XML_TOK_MALIGNGROUP },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aPresScriptEmptyElemTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_MPRESCRIPTS, XML_TOK_MPRESCRIPTS },
- { XML_NAMESPACE_MATH, XML_NONE, XML_TOK_NONE },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aPresTableElemTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_MTR, XML_TOK_MTR },
- { XML_NAMESPACE_MATH, XML_MTD, XML_TOK_MTD },
- XML_TOKEN_MAP_END
-};
-
-static __FAR_DATA SvXMLTokenMapEntry aColorTokenMap[] =
-{
- { XML_NAMESPACE_MATH, XML_BLACK, TBLACK},
- { XML_NAMESPACE_MATH, XML_WHITE, TWHITE},
- { XML_NAMESPACE_MATH, XML_RED, TRED},
- { XML_NAMESPACE_MATH, XML_GREEN, TGREEN},
- { XML_NAMESPACE_MATH, XML_BLUE, TBLUE},
- { XML_NAMESPACE_MATH, XML_AQUA, TCYAN},
- { XML_NAMESPACE_MATH, XML_FUCHSIA, TMAGENTA},
- { XML_NAMESPACE_MATH, XML_YELLOW, TYELLOW},
- XML_TOKEN_MAP_END
-};
-
-
-const SvXMLTokenMap& SmXMLImport::GetPresLayoutElemTokenMap()
-{
- if(!pPresLayoutElemTokenMap)
- pPresLayoutElemTokenMap = new SvXMLTokenMap(aPresLayoutElemTokenMap);
- return *pPresLayoutElemTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetPresLayoutAttrTokenMap()
-{
- if(!pPresLayoutAttrTokenMap)
- pPresLayoutAttrTokenMap = new SvXMLTokenMap(aPresLayoutAttrTokenMap);
- return *pPresLayoutAttrTokenMap;
-}
-
-
-const SvXMLTokenMap& SmXMLImport::GetFencedAttrTokenMap()
-{
- if(!pFencedAttrTokenMap)
- pFencedAttrTokenMap = new SvXMLTokenMap(aFencedAttrTokenMap);
- return *pFencedAttrTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetOperatorAttrTokenMap()
-{
- if(!pOperatorAttrTokenMap)
- pOperatorAttrTokenMap = new SvXMLTokenMap(aOperatorAttrTokenMap);
- return *pOperatorAttrTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetAnnotationAttrTokenMap()
-{
- if(!pAnnotationAttrTokenMap)
- pAnnotationAttrTokenMap = new SvXMLTokenMap(aAnnotationAttrTokenMap);
- return *pAnnotationAttrTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetPresElemTokenMap()
-{
- if(!pPresElemTokenMap)
- pPresElemTokenMap = new SvXMLTokenMap(aPresElemTokenMap);
- return *pPresElemTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetPresScriptEmptyElemTokenMap()
-{
- if(!pPresScriptEmptyElemTokenMap)
- pPresScriptEmptyElemTokenMap = new
- SvXMLTokenMap(aPresScriptEmptyElemTokenMap);
- return *pPresScriptEmptyElemTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetPresTableElemTokenMap()
-{
- if(!pPresTableElemTokenMap)
- pPresTableElemTokenMap = new SvXMLTokenMap(aPresTableElemTokenMap);
- return *pPresTableElemTokenMap;
-}
-
-const SvXMLTokenMap& SmXMLImport::GetColorTokenMap()
-{
- if(!pColorTokenMap)
- pColorTokenMap = new SvXMLTokenMap(aColorTokenMap);
- return *pColorTokenMap;
-}
-
-SvXMLImportContext *SmXMLDocContext_Impl::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList)
-{
- SvXMLImportContext* pContext = 0L;
-
- const SvXMLTokenMap& rTokenMap = GetSmImport().GetPresLayoutElemTokenMap();
-
- //UINT32 nTest = rTokenMap.Get(nPrefix, rLocalName);
-
- switch(rTokenMap.Get(nPrefix, rLocalName))
- {
- //Consider semantics a dummy except for any starmath annotations
- case XML_TOK_SEMANTICS:
- pContext = GetSmImport().CreateRowContext(nPrefix,rLocalName,
- xAttrList);
- break;
- /*General Layout Schemata*/
- case XML_TOK_MROW:
- pContext = GetSmImport().CreateRowContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MFRAC:
- pContext = GetSmImport().CreateFracContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MSQRT:
- pContext = GetSmImport().CreateSqrtContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MROOT:
- pContext = GetSmImport().CreateRootContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MSTYLE:
- pContext = GetSmImport().CreateStyleContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MERROR:
- pContext = GetSmImport().CreateErrorContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MPADDED:
- pContext = GetSmImport().CreatePaddedContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MPHANTOM:
- pContext = GetSmImport().CreatePhantomContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MFENCED:
- pContext = GetSmImport().CreateFencedContext(nPrefix,rLocalName,
- xAttrList);
- break;
- /*Script and Limit Schemata*/
- case XML_TOK_MSUB:
- pContext = GetSmImport().CreateSubContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MSUP:
- pContext = GetSmImport().CreateSupContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MSUBSUP:
- pContext = GetSmImport().CreateSubSupContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MUNDER:
- pContext = GetSmImport().CreateUnderContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MOVER:
- pContext = GetSmImport().CreateOverContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MUNDEROVER:
- pContext = GetSmImport().CreateUnderOverContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MMULTISCRIPTS:
- pContext = GetSmImport().CreateMultiScriptsContext(nPrefix,
- rLocalName, xAttrList);
- break;
- case XML_TOK_MTABLE:
- pContext = GetSmImport().CreateTableContext(nPrefix,
- rLocalName, xAttrList);
- break;
- case XML_TOK_MACTION:
- pContext = GetSmImport().CreateActionContext(nPrefix,
- rLocalName, xAttrList);
- break;
- default:
- /*Basically theres an implicit mrow around certain bare
- *elements, use a RowContext to see if this is one of
- *those ones*/
- SmXMLRowContext_Impl aTempContext(GetSmImport(),nPrefix,
- GetXMLToken(XML_MROW));
-
- pContext = aTempContext.StrictCreateChildContext(nPrefix,
- rLocalName, xAttrList);
- break;
- }
- return pContext;
-}
-
-void SmXMLDocContext_Impl::EndElement()
-{
- SmNodeArray ContextArray;
- ContextArray.SetSize(1);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
-
- for(ULONG i=0;i< 1;i++)
- ContextArray.Put(i, rNodeStack.Pop());
-
- SmToken aDummy;
- SmStructureNode *pSNode = new SmLineNode(aDummy);
- pSNode->SetSubNodes(ContextArray);
- rNodeStack.Push(pSNode);
-
- SmNodeArray LineArray;
- ULONG n = rNodeStack.Count();
- LineArray.SetSize(n);
- for (ULONG j = 0; j < n; j++)
- LineArray.Put(n - (j + 1), rNodeStack.Pop());
- SmStructureNode *pSNode2 = new SmTableNode(aDummy);
- pSNode2->SetSubNodes(LineArray);
- rNodeStack.Push(pSNode2);
-}
-
-void SmXMLFracContext_Impl::EndElement()
-{
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TOVER;
- SmStructureNode *pSNode = new SmBinVerNode(aToken);
- SmNode *pOper = new SmRectangleNode(aToken);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- DBG_ASSERT(rNodeStack.Count() - nElementCount == 2,
- "Fraction (mfrac) tag is missing component");
-
- if (rNodeStack.Count() - nElementCount == 2)
- {
- SmNode *pSecond = rNodeStack.Pop();
- SmNode *pFirst = rNodeStack.Pop();
- pSNode->SetSubNodes(pFirst,pOper,pSecond);
- rNodeStack.Push(pSNode);
- }
-}
-
-void SmXMLRootContext_Impl::EndElement()
-{
- /*The <mroot> element requires exactly 2 arguments.*/
- DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
- "Root tag is missing component");
-
- SmToken aToken;
- aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TNROOT;
- SmStructureNode *pSNode = new SmRootNode(aToken);
- SmNode *pOper = new SmRootSymbolNode(aToken);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- SmNode *pIndex = rNodeStack.Pop();
- SmNode *pBase = rNodeStack.Pop();
- pSNode->SetSubNodes(pIndex,pOper,pBase);
- rNodeStack.Push(pSNode);
-}
-
-void SmXMLSqrtContext_Impl::EndElement()
-{
- /*
- <msqrt> accepts any number of arguments; if this number is not 1, its
- contents are treated as a single "inferred <mrow>" containing its
- arguments
- */
- if (GetSmImport().GetNodeStack().Count() - nElementCount > 1)
- SmXMLRowContext_Impl::EndElement();
-
- SmToken aToken;
- aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TSQRT;
- SmStructureNode *pSNode = new SmRootNode(aToken);
- SmNode *pOper = new SmRootSymbolNode(aToken);
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- pSNode->SetSubNodes(0,pOper,rNodeStack.Pop());
- rNodeStack.Push(pSNode);
-}
-
-void SmXMLRowContext_Impl::EndElement()
-{
- SmNodeArray aRelationArray;
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- ULONG nSize = rNodeStack.Count()-nElementCount;
-
- if (nSize)
- {
- aRelationArray.SetSize(nSize);
- for(ULONG j=rNodeStack.Count()-nElementCount;j > 0;j--)
- aRelationArray.Put(j-1,rNodeStack.Pop());
-
-
- //If the first or last element is an operator with stretchyness
- //set then we must create a brace node here from those elements,
- //removing the stretchness from the operators and applying it to
- //ourselves, and creating the appropiate dummy StarMath none bracket
- //to balance the arrangement
- if (((aRelationArray.Get(0)->GetScaleMode() == SCALE_HEIGHT)
- && (aRelationArray.Get(0)->GetType() == NMATH))
- || ((aRelationArray.Get(nSize-1)->GetScaleMode() == SCALE_HEIGHT)
- && (aRelationArray.Get(nSize-1)->GetType() == NMATH)))
- {
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
-
- int nLeft=0,nRight=0;
- if ((aRelationArray.Get(0)->GetScaleMode() == SCALE_HEIGHT)
- && (aRelationArray.Get(0)->GetType() == NMATH))
- {
- aToken = aRelationArray.Get(0)->GetToken();
- nLeft=1;
- }
- else
- aToken.cMathChar = '\0';
-
- aToken.eType = TLPARENT;
- SmNode *pLeft = new SmMathSymbolNode(aToken);
-
- if ((aRelationArray.Get(nSize-1)->GetScaleMode() == SCALE_HEIGHT)
- && (aRelationArray.Get(nSize-1)->GetType() == NMATH))
- {
- aToken = aRelationArray.Get(nSize-1)->GetToken();
- nRight=1;
- }
- else
- aToken.cMathChar = '\0';
-
- aToken.eType = TRPARENT;
- SmNode *pRight = new SmMathSymbolNode(aToken);
-
- SmNodeArray aRelationArray2;
-
- //!! nSize-nLeft-nRight may be < 0 !!
- int nRelArrSize = nSize-nLeft-nRight;
- if (nRelArrSize > 0)
- {
- aRelationArray2.SetSize(nRelArrSize);
- for(int i=0;i < nRelArrSize;i++)
- aRelationArray2.Put(i,aRelationArray.Get(i+nLeft));
- }
-
- SmToken aDummy;
- SmStructureNode *pSNode = new SmBraceNode(aToken);
- SmStructureNode *pBody = new SmExpressionNode(aDummy);
- pBody->SetSubNodes(aRelationArray2);
-
- pSNode->SetSubNodes(pLeft,pBody,pRight);
- pSNode->SetScaleMode(SCALE_HEIGHT);
- rNodeStack.Push(pSNode);
- return;
- }
- }
- else //Multiple newlines result in empty row elements
- {
- aRelationArray.SetSize(1);
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 5;
- aToken.eType = TNEWLINE;
- aRelationArray.Put(0,new SmLineNode(aToken));
- }
-
- SmToken aDummy;
- SmStructureNode *pSNode = new SmExpressionNode(aDummy);
- pSNode->SetSubNodes(aRelationArray);
- rNodeStack.Push(pSNode);
-}
-
-
-
-
-
-SvXMLImportContext *SmXMLRowContext_Impl::StrictCreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList)
-{
- SvXMLImportContext* pContext = 0L;
-
- const SvXMLTokenMap& rTokenMap = GetSmImport().GetPresElemTokenMap();
- switch(rTokenMap.Get(nPrefix, rLocalName))
- {
- /*Note that these should accept malignmark subelements, but do not*/
- case XML_TOK_MN:
- pContext = GetSmImport().CreateNumberContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MI:
- pContext = GetSmImport().CreateIdentifierContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MO:
- pContext = GetSmImport().CreateOperatorContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MTEXT:
- pContext = GetSmImport().CreateTextContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MSPACE:
- pContext = GetSmImport().CreateSpaceContext(nPrefix,rLocalName,
- xAttrList);
- break;
- case XML_TOK_MS:
- pContext = GetSmImport().CreateStringContext(nPrefix,rLocalName,
- xAttrList);
- break;
-
- /*Note: The maligngroup should only be seen when the row
- * (or decendants) are in a table*/
- case XML_TOK_MALIGNGROUP:
- pContext = GetSmImport().CreateAlignGroupContext(nPrefix,rLocalName,
- xAttrList);
- break;
-
- case XML_TOK_ANNOTATION:
- pContext = GetSmImport().CreateAnnotationContext(nPrefix,rLocalName,
- xAttrList);
- break;
-
- default:
- break;
- }
- return pContext;
-}
-
-
-
-SvXMLImportContext *SmXMLRowContext_Impl::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList)
-{
- SvXMLImportContext* pContext = StrictCreateChildContext(nPrefix,
- rLocalName, xAttrList);
-
- if (!pContext)
- {
- //Hmm, unrecognized for this level, check to see if its
- //an element that can have an implicit schema around it
- pContext = SmXMLDocContext_Impl::CreateChildContext(nPrefix,
- rLocalName,xAttrList);
- }
- return pContext;
-}
-
-
-SvXMLImportContext *SmXMLMultiScriptsContext_Impl::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList)
-{
- SvXMLImportContext* pContext = 0L;
-
- const SvXMLTokenMap& rTokenMap = GetSmImport().
- GetPresScriptEmptyElemTokenMap();
- switch(rTokenMap.Get(nPrefix, rLocalName))
- {
- case XML_TOK_MPRESCRIPTS:
- MiddleElement();
- pContext = GetSmImport().CreatePrescriptsContext(nPrefix,
- rLocalName, xAttrList);
- break;
- case XML_TOK_NONE:
- pContext = GetSmImport().CreateNoneContext(nPrefix,rLocalName,
- xAttrList);
- break;
- default:
- pContext = SmXMLRowContext_Impl::CreateChildContext(nPrefix,
- rLocalName,xAttrList);
- break;
- }
- return pContext;
-}
-
-void SmXMLMultiScriptsContext_Impl::MiddleElement()
-{
- bHasPrescripts=sal_True;
-
- DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount > 0,
- "Sub has no arguments");
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- if (rNodeStack.Count()-nElementCount > 1)
- {
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TRSUB;
- ULONG nFinalCount = rNodeStack.Count()-nElementCount-1;
-
- SmNodeStack aReverseStack;
- while (rNodeStack.Count()-nElementCount)
- {
- SmNode *pThing = rNodeStack.Pop();
- aReverseStack.Push(pThing);
- }
-
- for (ULONG nCount=0;nCount < nFinalCount;nCount+=2)
- {
- SmSubSupNode *pNode = new SmSubSupNode(aToken);
-
- // initialize subnodes array
- SmNodeArray aSubNodes;
- aSubNodes.SetSize(1 + SUBSUP_NUM_ENTRIES);
- for (ULONG i = 1; i < aSubNodes.GetSize(); i++)
- aSubNodes.Put(i, NULL);
-
- /*On each loop the base and its sub sup pair becomes the
- base for the next loop to which the next sub sup pair is
- attached, i.e. wheels within wheels*/
- //if (nCount == 0)
- aSubNodes.Put(0, aReverseStack.Pop());
-
- SmNode *pScriptNode = aReverseStack.Pop();
-
- if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) ||
- (pScriptNode->GetToken().aText.Len())))
- aSubNodes.Put(RSUB+1,pScriptNode);
- pScriptNode = aReverseStack.Pop();
- if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) ||
- (pScriptNode->GetToken().aText.Len())))
- aSubNodes.Put(RSUP+1,pScriptNode);
-
- pNode->SetSubNodes(aSubNodes);
- aReverseStack.Push(pNode);
- }
- rNodeStack.Push(aReverseStack.Pop());
- }
-}
-
-
-void SmXMLTableContext_Impl::EndElement()
-{
- SmNodeArray aExpressionArray;
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- SmNodeStack aReverseStack;
- aExpressionArray.SetSize(rNodeStack.Count()-nElementCount);
-
- ULONG nRows = rNodeStack.Count()-nElementCount;
- USHORT nCols = 0;
-
- SmStructureNode *pArray;
- for(ULONG i=rNodeStack.Count()-nElementCount;i > 0;i--)
- {
- pArray = (SmStructureNode *)rNodeStack.Pop();
- if (pArray->GetNumSubNodes() == 0)
- {
- //This is a little tricky, it is possible that there was
- //be elements that were not inside a <mtd> pair, in which
- //case they will not be in a row, i.e. they will not have
- //SubNodes, so we have to wait until here before we can
- //resolve the situation. Implicitsurrounding tags are
- //surprisingly difficult to get right within this
- //architecture
-
- SmNodeArray aRelationArray;
- aRelationArray.SetSize(1);
- aRelationArray.Put(0,pArray);
- SmToken aDummy;
- pArray = new SmExpressionNode(aDummy);
- pArray->SetSubNodes(aRelationArray);
- }
-
- if (pArray->GetNumSubNodes() > nCols)
- nCols = pArray->GetNumSubNodes();
- aReverseStack.Push(pArray);
- }
- aExpressionArray.SetSize(nCols*nRows);
- ULONG j=0;
- while (aReverseStack.Count())
- {
- pArray = (SmStructureNode *)aReverseStack.Pop();
- for (USHORT i=0;i<pArray->GetNumSubNodes();i++)
- aExpressionArray.Put(j++,pArray->GetSubNode(i));
- }
-
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = TRGROUP;
- aToken.nLevel = 0;
- aToken.eType = TMATRIX;
- SmMatrixNode *pSNode = new SmMatrixNode(aToken);
- pSNode->SetSubNodes(aExpressionArray);
- pSNode->SetRowCol(static_cast<USHORT>(nRows),nCols);
- rNodeStack.Push(pSNode);
-}
-
-SvXMLImportContext *SmXMLTableRowContext_Impl::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList)
-{
- SvXMLImportContext* pContext = 0L;
-
- const SvXMLTokenMap& rTokenMap = GetSmImport().
- GetPresTableElemTokenMap();
- switch(rTokenMap.Get(nPrefix, rLocalName))
- {
- case XML_TOK_MTD:
- pContext = GetSmImport().CreateTableCellContext(nPrefix,
- rLocalName, xAttrList);
- break;
- default:
- pContext = SmXMLRowContext_Impl::CreateChildContext(nPrefix,
- rLocalName,xAttrList);
- break;
- }
- return pContext;
-}
-
-SvXMLImportContext *SmXMLTableContext_Impl::CreateChildContext(
- sal_uInt16 nPrefix,
- const OUString& rLocalName,
- const uno::Reference<xml::sax::XAttributeList>& xAttrList)
-{
- SvXMLImportContext* pContext = 0L;
-
- const SvXMLTokenMap& rTokenMap = GetSmImport().
- GetPresTableElemTokenMap();
- switch(rTokenMap.Get(nPrefix, rLocalName))
- {
- case XML_TOK_MTR:
- pContext = GetSmImport().CreateTableRowContext(nPrefix,rLocalName,
- xAttrList);
- break;
- default:
- pContext = SmXMLTableRowContext_Impl::CreateChildContext(nPrefix,
- rLocalName,xAttrList);
- break;
- }
- return pContext;
-}
-
-void SmXMLMultiScriptsContext_Impl::EndElement()
-{
- if (!bHasPrescripts)
- MiddleElement();
-
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- if (rNodeStack.Count()-nElementCount > 1)
- {
- SmToken aToken;
- aToken.cMathChar = '\0';
- aToken.nGroup = 0;
- aToken.nLevel = 0;
- aToken.eType = TLSUB;
- ULONG nFinalCount = rNodeStack.Count()-nElementCount-1;
-
- SmNodeStack aReverseStack;
- while (rNodeStack.Count()-nElementCount)
- aReverseStack.Push(rNodeStack.Pop());
- for (ULONG nCount=0;nCount < nFinalCount;nCount+=2)
- {
- SmSubSupNode *pNode = new SmSubSupNode(aToken);
-
- // initialize subnodes array
- SmNodeArray aSubNodes;
- aSubNodes.SetSize(1 + SUBSUP_NUM_ENTRIES);
- for (ULONG i = 1; i < aSubNodes.GetSize(); i++)
- aSubNodes.Put(i, NULL);
-
- /*On each loop the base and its sub sup pair becomes the
- base for the next loop to which the next sub sup pair is
- attached, i.e. wheels within wheels*/
- //if (nCount == 0)
- aSubNodes.Put(0, aReverseStack.Pop());
-
- SmNode *pScriptNode = aReverseStack.Pop();
- if (pScriptNode->GetToken().aText.Len())
- aSubNodes.Put(LSUB+1,pScriptNode);
- pScriptNode = aReverseStack.Pop();
- if (pScriptNode->GetToken().aText.Len())
- aSubNodes.Put(LSUP+1,pScriptNode);
-
- pNode->SetSubNodes(aSubNodes);
- aReverseStack.Push(pNode);
- }
- rNodeStack.Push(aReverseStack.Pop());
- }
-
-}
-void SmXMLActionContext_Impl::EndElement()
-{
- /*For now we will just assume that the
- selected attribute is one, and then just display
- that expression alone, i.e. remove all expect the
- first pushed one*/
-
- SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- for(ULONG i=rNodeStack.Count()-nElementCount;i > 1;i--)
- {
- delete rNodeStack.Pop();
- }
-}
-
-SvXMLImportContext *SmXMLImport::CreateContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- if( XML_NAMESPACE_OFFICE == nPrefix ) {
- if ( (IsXMLToken(rLocalName, XML_DOCUMENT) ||
- IsXMLToken(rLocalName, XML_DOCUMENT_META))) {
- uno::Reference<xml::sax::XDocumentHandler> xDocBuilder(
- mxServiceFactory->createInstance(
- ::rtl::OUString::createFromAscii(
- "com.sun.star.xml.dom.SAXDocumentBuilder")),
- uno::UNO_QUERY_THROW);
- uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
- GetModel(), uno::UNO_QUERY_THROW);
- return IsXMLToken(rLocalName, XML_DOCUMENT_META)
- ? new SvXMLMetaDocumentContext(*this,
- XML_NAMESPACE_OFFICE, rLocalName,
- xDPS->getDocumentProperties(), xDocBuilder)
- // flat OpenDocument file format -- this has not been tested...
- : new SmXMLFlatDocContext_Impl( *this, nPrefix, rLocalName,
- xDPS->getDocumentProperties(), xDocBuilder);
- } else {
- return new SmXMLOfficeContext_Impl( *this,nPrefix,rLocalName);
- }
- } else
- return new SmXMLDocContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateRowContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLRowContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateTextContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLTextContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateAnnotationContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLAnnotationContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateStringContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLStringContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateNumberContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLNumberContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateIdentifierContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLIdentifierContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateOperatorContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLOperatorContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateSpaceContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLSpaceContext_Impl(*this,nPrefix,rLocalName);
-}
-
-
-SvXMLImportContext *SmXMLImport::CreateFracContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLFracContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateSqrtContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLSqrtContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateRootContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLRootContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateStyleContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLStyleContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreatePaddedContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLPaddedContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreatePhantomContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLPhantomContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateFencedContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLFencedContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateErrorContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLErrorContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateSubContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLSubContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateSubSupContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLSubSupContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateSupContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLSupContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateUnderContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLUnderContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateOverContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLOverContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateUnderOverContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLUnderOverContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateMultiScriptsContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLMultiScriptsContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateTableContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLTableContext_Impl(*this,nPrefix,rLocalName);
-}
-SvXMLImportContext *SmXMLImport::CreateTableRowContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLTableRowContext_Impl(*this,nPrefix,rLocalName);
-}
-SvXMLImportContext *SmXMLImport::CreateTableCellContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLTableCellContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateNoneContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLNoneContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreatePrescriptsContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLPrescriptsContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateAlignGroupContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLAlignGroupContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SvXMLImportContext *SmXMLImport::CreateActionContext(sal_uInt16 nPrefix,
- const OUString &rLocalName,
- const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
-{
- return new SmXMLActionContext_Impl(*this,nPrefix,rLocalName);
-}
-
-SmXMLImport::~SmXMLImport() throw ()
-{
- delete pPresLayoutElemTokenMap;
- delete pPresElemTokenMap;
- delete pPresScriptEmptyElemTokenMap;
- delete pPresTableElemTokenMap;
- delete pPresLayoutAttrTokenMap;
- delete pFencedAttrTokenMap;
- delete pColorTokenMap;
- delete pOperatorAttrTokenMap;
- delete pAnnotationAttrTokenMap;
-}
-
-void SmXMLImport::SetViewSettings(const Sequence<PropertyValue>& aViewProps)
-{
- uno::Reference <frame::XModel> xModel = GetModel();
- if( !xModel.is() )
- return;
-
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-
- if( !pModel )
- return;
-
- SmDocShell *pDocShell =
- static_cast<SmDocShell*>(pModel->GetObjectShell());
- if( !pDocShell )
- return;
-
- Rectangle aRect( pDocShell->GetVisArea() );
-
- sal_Int32 nCount = aViewProps.getLength();
- const PropertyValue *pValue = aViewProps.getConstArray();
-
- long nTmp = 0;
- //sal_Bool bShowDeletes = sal_False, bShowInserts = sal_False, bShowFooter = sal_False, bShowHeader = sal_False;
-
- for (sal_Int32 i = 0; i < nCount ; i++)
- {
- if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaTop" ) ) )
- {
- pValue->Value >>= nTmp;
- aRect.setY( nTmp );
- }
- else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaLeft" ) ) )
- {
- pValue->Value >>= nTmp;
- aRect.setX( nTmp );
- }
- else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaWidth" ) ) )
- {
- pValue->Value >>= nTmp;
- Size aSize( aRect.GetSize() );
- aSize.Width() = nTmp;
- aRect.SetSize( aSize );
- }
- else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaHeight" ) ) )
- {
- pValue->Value >>= nTmp;
- Size aSize( aRect.GetSize() );
- aSize.Height() = nTmp;
- aRect.SetSize( aSize );
- }
- pValue++;
- }
-
- pDocShell->SetVisArea ( aRect );
-}
-
-void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfProps)
-{
- uno::Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY );
- if ( xProps.is() )
- {
- Reference < XPropertySetInfo > xInfo ( xProps->getPropertySetInfo() );
- if (xInfo.is() )
- {
- sal_Int32 nCount = aConfProps.getLength();
- const PropertyValue* pValues = aConfProps.getConstArray();
-
- const OUString sFormula ( RTL_CONSTASCII_USTRINGPARAM ( "Formula" ) );
- const OUString sBasicLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "BasicLibraries" ) );
- const OUString sDialogLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "DialogLibraries" ) );
- while( nCount-- )
- {
- if (pValues->Name != sFormula &&
- pValues->Name != sBasicLibraries &&
- pValues->Name != sDialogLibraries)
- {
- try
- {
- if( xInfo->hasPropertyByName( pValues->Name ) )
- xProps->setPropertyValue( pValues->Name, pValues->Value );
- }
- catch( Exception& )
- {
- DBG_ERROR( "SmXMLImport::SetConfigurationSettings: Exception!" );
- }
- }
-
- pValues++;
- }
- }
- }
-}
-void SmXMLExport::_ExportContent()
-{
- SvXMLElementExport aEquation(*this,XML_NAMESPACE_MATH,XML_MATH, sal_True,
- sal_True);
- SvXMLElementExport *pSemantics=0;
-
- if (aText.Len())
- {
- pSemantics = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
- XML_SEMANTICS, sal_True, sal_True);
- }
-
- ExportNodes(pTree,0);
-
- if (aText.Len())
- {
- // Convert symbol names
- uno::Reference <frame::XModel> xModel = GetModel();
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
- SmDocShell *pDocShell = pModel ?
- static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0;
- DBG_ASSERT( pDocShell, "doc shell missing" );
- if (pDocShell)
- {
- SmParser &rParser = pDocShell->GetParser();
- BOOL bVal = rParser.IsExportSymbolNames();
- rParser.SetExportSymbolNames( TRUE );
- SmNode *pTmpTree = rParser.Parse( aText );
- aText = rParser.GetText();
- delete pTmpTree;
- rParser.SetExportSymbolNames( bVal );
- }
-
- AddAttribute(XML_NAMESPACE_MATH,XML_ENCODING,
- OUString(RTL_CONSTASCII_USTRINGPARAM("StarMath 5.0")));
- SvXMLElementExport aAnnotation(*this,XML_NAMESPACE_MATH,
- XML_ANNOTATION,sal_True, sal_False);
- GetDocHandler()->characters(OUString( aText ));
- }
- delete pSemantics;
-}
-
-void SmXMLExport::GetViewSettings( Sequence < PropertyValue >& aProps)
-{
- uno::Reference <frame::XModel> xModel = GetModel();
- if( !xModel.is() )
- return;
-
- uno::Reference <lang::XUnoTunnel> xTunnel;
- xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
- SmModel *pModel = reinterpret_cast<SmModel *>
- (xTunnel->getSomething(SmModel::getUnoTunnelId()));
-
- if( !pModel )
- return;
-
- SmDocShell *pDocShell =
- static_cast<SmDocShell*>(pModel->GetObjectShell());
- if( !pDocShell )
- return;
-
- aProps.realloc( 4 );
- PropertyValue *pValue = aProps.getArray();
- sal_Int32 nIndex = 0;
-
- Rectangle aRect( pDocShell->GetVisArea() );
-
- pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaTop") );
- pValue[nIndex++].Value <<= aRect.Top();
-
- pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaLeft") );
- pValue[nIndex++].Value <<= aRect.Left();
-
- pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaWidth") );
- pValue[nIndex++].Value <<= aRect.GetWidth();
-
- pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "ViewAreaHeight") );
- pValue[nIndex++].Value <<= aRect.GetHeight();
-}
-
-void SmXMLExport::GetConfigurationSettings( Sequence < PropertyValue > & rProps)
-{
- Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY );
- if ( xProps.is() )
- {
- Reference< XPropertySetInfo > xPropertySetInfo = xProps->getPropertySetInfo();
- if (xPropertySetInfo.is())
- {
- Sequence< Property > aProps = xPropertySetInfo->getProperties();
- sal_Int32 nCount(aProps.getLength());
- if (nCount)
- {
- rProps.realloc(nCount);
- PropertyValue* pProps = rProps.getArray();
- if (pProps)
- {
- const OUString sFormula ( RTL_CONSTASCII_USTRINGPARAM ( "Formula" ) );
- const OUString sBasicLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "BasicLibraries" ) );
- const OUString sDialogLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "DialogLibraries" ) );
- const OUString sRuntimeUID ( RTL_CONSTASCII_USTRINGPARAM ( "RuntimeUID" ) );
- for (sal_Int32 i = 0; i < nCount; i++, pProps++)
- {
- const OUString &rPropName = aProps[i].Name;
- if (rPropName != sFormula &&
- rPropName != sBasicLibraries &&
- rPropName != sDialogLibraries &&
- rPropName != sRuntimeUID)
- {
- pProps->Name = rPropName;
- pProps->Value = xProps->getPropertyValue(rPropName);
- }
- }
- }
- }
- }
- }
-}
-
-void SmXMLExport::ExportLine(const SmNode *pNode,int nLevel)
-{
- ExportExpression(pNode,nLevel);
-}
-
-void SmXMLExport::ExportBinaryHorizontal(const SmNode *pNode,int nLevel)
-{
- ExportExpression(pNode,nLevel);
-}
-
-void SmXMLExport::ExportUnaryHorizontal(const SmNode *pNode,int nLevel)
-{
- ExportExpression(pNode,nLevel);
-}
-
-void SmXMLExport::ExportExpression(const SmNode *pNode,int nLevel)
-{
- SvXMLElementExport *pRow=0;
- ULONG nSize = pNode->GetNumSubNodes();
-
- if (nSize > 1)
- pRow = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,XML_MROW,
- sal_True, sal_True);
-
- //if (nSize)
- //{
- for (USHORT i = 0; i < nSize; i++)
- if (const SmNode *pTemp = pNode->GetSubNode(i))
- ExportNodes(pTemp,nLevel+1);
- //}
-#if 0
- else
- {
- //This saves us from situations like "a newline" where the
- //lack of a term following the newline would otherwise create
- //a incorrect token like <mtr/>
- SvXMLElementExport aDummy(*this,XML_NAMESPACE_MATH,XML_MI,
- sal_True,sal_True);
- sal_Unicode nArse[2] = {'\n','\0'};
- GetDocHandler()->characters(nArse);
- }
-#endif
-
- delete pRow;
-}
-
-void SmXMLExport::ExportBinaryVertical(const SmNode *pNode,int nLevel)
-{
- DBG_ASSERT(pNode->GetNumSubNodes()==3,"Bad Fraction");
- SvXMLElementExport aFraction(*this,XML_NAMESPACE_MATH,XML_MFRAC, sal_True,
- sal_True);
- ExportNodes(pNode->GetSubNode(0),nLevel);
- ExportNodes(pNode->GetSubNode(2),nLevel);
-}
-
-void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel)
-{
- SvXMLElementExport *pTable=0;
-
- USHORT nSize = pNode->GetNumSubNodes();
-
- //If the list ends in newline then the last entry has
- //no subnodes, the newline is superfulous so we just drop
- //the last node, inclusion would create a bad MathML
- //table
- if (pNode->GetSubNode(nSize-1)->GetNumSubNodes() == 0)
- nSize--;
-
- if ( nLevel || (nSize >1))
- pTable = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,XML_MTABLE,
- sal_True, sal_True);
-
- for (USHORT i = 0; i < nSize; i++)
- if (const SmNode *pTemp = pNode->GetSubNode(i))
- {
- SvXMLElementExport *pRow=0;
- if (pTable)
- pRow = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
- XML_MTR, sal_True, sal_True);
- ExportNodes(pTemp,nLevel+1);
- delete pRow;
- }
-
- delete pTable;
-}
-
-void SmXMLExport::ExportMath(const SmNode *pNode, int /*nLevel*/)
-{
- const SmMathSymbolNode *pTemp = static_cast<const SmMathSymbolNode *>
- (pNode);
- SvXMLElementExport aMath(*this,XML_NAMESPACE_MATH,XML_MO,
- sal_True,sal_False);
- sal_Unicode nArse[2];
- nArse[0] = pTemp->GetText().GetChar(0);
- sal_Unicode cTmp = ConvertMathToMathML( nArse[0] );
- if (cTmp != 0)
- nArse[0] = cTmp;
- DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol");
- nArse[1] = 0;
- GetDocHandler()->characters(nArse);
-}
-
-void SmXMLExport::ExportText(const SmNode *pNode, int /*nLevel*/)
-{
- SvXMLElementExport *pText;
- const SmTextNode *pTemp = static_cast<const SmTextNode *>(pNode);
- switch (pNode->GetToken().eType)
- {
- default:
- case TIDENT:
- {
- //Note that we change the fontstyle to italic for strings that
- //are italic and longer than a single character.
- sal_Bool bIsItalic = IsItalic( pTemp->GetFont() );
- if ((pTemp->GetText().Len() > 1) && bIsItalic)
- AddAttribute(XML_NAMESPACE_MATH,XML_FONTSTYLE,
- XML_ITALIC);
- else if ((pTemp->GetText().Len() == 1) && !bIsItalic)
- AddAttribute(XML_NAMESPACE_MATH,XML_FONTSTYLE,
- XML_NORMAL);
- pText = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,XML_MI,
- sal_True,sal_False);
- break;
- }
- case TNUMBER:
- pText = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,XML_MN,
- sal_True,sal_False);
- break;
- case TTEXT:
- pText = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,XML_MTEXT,
- sal_True,sal_False);
- break;
- }
- GetDocHandler()->characters(OUString(pTemp->GetText().GetBuffer()));
- delete pText;
-}
-
-void SmXMLExport::ExportBlank(const SmNode * /*pNode*/, int /*nLevel*/)
-{
- //!! exports an empty <mi> tag since for example "~_~" is allowed in
- //!! Math (so it has no sense at all) but must not result in an empty
- //!! <msub> tag in MathML !!
-
- SvXMLElementExport *pText;
- //const SmBlankNode *pTemp = static_cast<const SmBlankNode *>(pNode);
-
- pText = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,XML_MI,
- sal_True,sal_False);
-
- GetDocHandler()->characters( OUString() );
- delete pText;
-}
-
-void SmXMLExport::ExportSubSupScript(const SmNode *pNode,int nLevel)
-{
- const SmNode *pSub = 0;
- const SmNode *pSup = 0;
- const SmNode *pCSub = 0;
- const SmNode *pCSup = 0;
- const SmNode *pLSub = 0;
- const SmNode *pLSup = 0;
- SvXMLElementExport *pThing = 0, *pThing2 = 0;
-
- //if we have prescripts at all then we must use the tensor notation
-
- //This is one of those excellent locations where scope is vital to
- //arrange the construction and destruction of the element helper
- //classes correctly
- pLSub = pNode->GetSubNode(LSUB+1);
- pLSup = pNode->GetSubNode(LSUP+1);
- if (pLSub || pLSup)
- {
- SvXMLElementExport aMultiScripts(*this,XML_NAMESPACE_MATH,
- XML_MMULTISCRIPTS, sal_True, sal_True);
-
-
- if (NULL != (pCSub = pNode->GetSubNode(CSUB+1))
- && NULL != (pCSup = pNode->GetSubNode(CSUP+1)))
- {
- pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
- XML_MUNDEROVER, sal_True,sal_True);
- }
- else if (NULL != (pCSub = pNode->GetSubNode(CSUB+1)))
- {
- pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
- XML_MUNDER, sal_True,sal_True);
- }
- else if (NULL != (pCSup = pNode->GetSubNode(CSUP+1)))
- {
- pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
- XML_MOVER, sal_True,sal_True);
- }
-
- ExportNodes(pNode->GetSubNode(0), nLevel+1); //Main Term
-
- if (pCSub)
- ExportNodes(pCSub, nLevel+1);
- if (pCSup)
- ExportNodes(pCSup, nLevel+1);
- delete pThing2;
-
- pSub = pNode->GetSubNode(RSUB+1);
- pSup = pNode->GetSubNode(RSUP+1);
- if (pSub || pSup)
- {
- if (pSub)
- ExportNodes(pSub, nLevel+1);
- else
- {
- SvXMLElementExport aNone(*this,XML_NAMESPACE_MATH, XML_NONE,
- sal_True,sal_True);
- }
- if (pSup)
- ExportNodes(pSup, nLevel+1);
- else
- {
- SvXMLElementExport aNone(*this,XML_NAMESPACE_MATH, XML_NONE,
- sal_True,sal_True);
- }
- }
-
- //Seperator element between suffix and prefix sub/sup pairs
- {
- SvXMLElementExport aPrescripts(*this,XML_NAMESPACE_MATH,
- XML_MPRESCRIPTS, sal_True,sal_True);
- }
-
- if (pLSub)
- ExportNodes(pLSub, nLevel+1);
- else
- {
- SvXMLElementExport aNone(*this,XML_NAMESPACE_MATH, XML_NONE,
- sal_True,sal_True);
-
- }
- if (pLSup)
- ExportNodes(pLSup, nLevel+1);
- else
- {
- SvXMLElementExport aNone(*this,XML_NAMESPACE_MATH, XML_NONE,
- sal_True,sal_True);
-
- }
- }
- else
- {
- if (NULL != (pSub = pNode->GetSubNode(RSUB+1)) &&
- NULL != (pSup = pNode->GetSubNode(RSUP+1)))
- {
- pThing = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
- XML_MSUBSUP, sal_True,sal_True);
- }
- else if (NULL != (pSub = pNode->GetSubNode(RSUB+1)))
- {
- pThing = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,XML_MSUB,
- sal_True,sal_True);
- }
- else if (NULL != (pSup = pNode->GetSubNode(RSUP+1)))
- {
- pThing = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,XML_MSUP,
- sal_True,sal_True);
- }
-
- if (NULL != (pCSub = pNode->GetSubNode(CSUB+1))
- && NULL != (pCSup=pNode->GetSubNode(CSUP+1)))
- {
- pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
- XML_MUNDEROVER, sal_True,sal_True);
- }
- else if (NULL != (pCSub = pNode->GetSubNode(CSUB+1)))
- {
- pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
- XML_MUNDER, sal_True,sal_True);
- }
- else if (NULL != (pCSup = pNode->GetSubNode(CSUP+1)))
- {
- pThing2 = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
- XML_MOVER, sal_True,sal_True);
- }
- ExportNodes(pNode->GetSubNode(0), nLevel+1); //Main Term
-
- if (pCSub)
- ExportNodes(pCSub, nLevel+1);
- if (pCSup)
- ExportNodes(pCSup, nLevel+1);
- delete pThing2;
-
- if (pSub)
- ExportNodes(pSub, nLevel+1);
- if (pSup)
- ExportNodes(pSup, nLevel+1);
- delete pThing;
- }
-}
-
-void SmXMLExport::ExportBrace(const SmNode *pNode, int nLevel)
-{
- const SmNode *pTemp;
- const SmNode *pLeft=pNode->GetSubNode(0);
- const SmNode *pRight=pNode->GetSubNode(2);
- SvXMLElementExport *pFences=0,*pRow=0;
- if ( ((pLeft) && (pLeft->GetToken().eType != TNONE)) &&
- ((pRight) && (pRight->GetToken().eType != TNONE)) &&
- (pNode->GetScaleMode() == SCALE_HEIGHT))
- {
- sal_Unicode nArse[2];
- nArse[1] = 0;
- nArse[0] = static_cast<
- const SmMathSymbolNode* >(pLeft)->GetText().GetChar(0);
- DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol");
- AddAttribute(XML_NAMESPACE_MATH,XML_OPEN,nArse);
- nArse[0] = static_cast<
- const SmMathSymbolNode* >(pRight)->GetText().GetChar(0);
- DBG_ASSERT(nArse[0] != 0xffff,"Non existant symbol");
- AddAttribute(XML_NAMESPACE_MATH,XML_CLOSE,nArse);
- pFences = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,XML_MFENCED,
- sal_True,sal_True);
- }
- else if (pLeft && (pLeft->GetToken().eType != TNONE))
- {
- pRow = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,XML_MROW,
- sal_True, sal_True);
- if (pNode->GetScaleMode() == SCALE_HEIGHT)
- AddAttribute(XML_NAMESPACE_MATH,XML_STRETCHY,XML_TRUE);
- else
- AddAttribute(XML_NAMESPACE_MATH,XML_STRETCHY,XML_FALSE);
- ExportNodes(pLeft,nLevel+1);
- }
- else
- pRow = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,XML_MROW,
- sal_True, sal_True);
-
- if (NULL != (pTemp = pNode->GetSubNode(1)))
- ExportNodes(pTemp,nLevel+1);
- if (pFences)
- delete pFences;
- else if (pRight && (pRight->GetToken().eType != TNONE))
- {
- if (pNode->GetScaleMode() == SCALE_HEIGHT)
- AddAttribute(XML_NAMESPACE_MATH,XML_STRETCHY,XML_TRUE);
- else
- AddAttribute(XML_NAMESPACE_MATH,XML_STRETCHY,XML_FALSE);
- ExportNodes(pRight,nLevel+1);
- }
- delete pRow;
-}
-
-void SmXMLExport::ExportRoot(const SmNode *pNode, int nLevel)
-{
- if (pNode->GetSubNode(0))
- {
- SvXMLElementExport aRoot(*this,XML_NAMESPACE_MATH,XML_MROOT,sal_True,
- sal_True);
- ExportNodes(pNode->GetSubNode(2),nLevel+1);
- ExportNodes(pNode->GetSubNode(0),nLevel+1);
- }
- else
- {
- SvXMLElementExport aSqrt(*this,XML_NAMESPACE_MATH,XML_MSQRT,sal_True,
- sal_True);
- ExportNodes(pNode->GetSubNode(2),nLevel+1);
- }
-}
-
-void SmXMLExport::ExportOperator(const SmNode *pNode, int nLevel)
-{
- /*we need to either use content or font and size attributes
- *here*/
-#if 0
- {
- SvXMLElementExport aMath(*this,XML_NAMESPACE_MATH,XML_MO,
- sal_True,sal_False);
- SmTextNode *pTemp = (SmTextNode *)pNode->GetSubNode(0);
- GetDocHandler()->characters(pTemp->GetText());
- }
-#endif
- SvXMLElementExport aRow(*this,XML_NAMESPACE_MATH,XML_MROW,
- sal_True, sal_True);
- ExportNodes(pNode->GetSubNode(0),nLevel+1);
- ExportNodes(pNode->GetSubNode(1),nLevel+1);
-}
-
-void SmXMLExport::ExportAttributes(const SmNode *pNode, int nLevel)
-{
- SvXMLElementExport *pElement=0;
-
- if (pNode->GetToken().eType == TUNDERLINE)
- {
- AddAttribute(XML_NAMESPACE_MATH,XML_ACCENTUNDER,
- XML_TRUE);
- pElement = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,XML_MUNDER,
- sal_True,sal_True);
- }
- else if (pNode->GetToken().eType != TOVERSTRIKE)
- {
- AddAttribute(XML_NAMESPACE_MATH,XML_ACCENT,
- XML_TRUE);
- pElement = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,XML_MOVER,
- sal_True,sal_True);
- }
-
- ExportNodes(pNode->GetSubNode(1),nLevel+1);
- switch (pNode->GetToken().eType)
- {
- case TOVERLINE:
- {
- //proper entity support required
- SvXMLElementExport aMath(*this,XML_NAMESPACE_MATH,XML_MO,
- sal_True,sal_False);
-#if 0
- GetDocHandler()->characters(
- OUString(RTL_CONSTASCII_USTRINGPARAM("&overbar;")));
-#else
- sal_Unicode nArse[2] = {0xAF,0x00};
-#endif
- GetDocHandler()->characters(nArse);
- }
- break;
- case TUNDERLINE:
- {
- //proper entity support required
- SvXMLElementExport aMath(*this,XML_NAMESPACE_MATH,XML_MO,
- sal_True,sal_False);
-#if 0
- GetDocHandler()->characters(
- OUString(RTL_CONSTASCII_USTRINGPARAM("&underbar;")));
-#else
- sal_Unicode nArse[2] = {0x0332,0x00};
-#endif
- GetDocHandler()->characters(nArse);
- }
- break;
- case TOVERSTRIKE:
- break;
- default:
- ExportNodes(pNode->GetSubNode(0),nLevel+1);
- break;
- }
- delete pElement;
-}
-
-void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel)
-{
- SvXMLElementExport *pElement=0;
- switch (pNode->GetToken().eType)
- {
- //wrap a phantom element around everything*/
- case TPHANTOM:
- pElement = new SvXMLElementExport(*this,XML_NAMESPACE_MATH,
- XML_MPHANTOM, sal_True,sal_True);
- break;
- case TBOLD:
- AddAttribute(XML_NAMESPACE_MATH,XML_FONTWEIGHT,
- XML_BOLD);
- break;
- case TITALIC:
- AddAttribute(XML_NAMESPACE_MATH,XML_FONTSTYLE,
- XML_ITALIC);
- break;
- case TNBOLD:
- AddAttribute(XML_NAMESPACE_MATH,XML_FONTWEIGHT,
- XML_WEIGHT_NORMAL);
- break;
- case TNITALIC:
- AddAttribute(XML_NAMESPACE_MATH,XML_FONTSTYLE,
- XML_WEIGHT_NORMAL);
- break;
- case TBLACK:
- AddAttribute(XML_NAMESPACE_MATH,XML_COLOR,
- XML_BLACK);
- break;
- case TWHITE:
- AddAttribute(XML_NAMESPACE_MATH,XML_COLOR,
- XML_WHITE);
- break;
- case TRED:
- AddAttribute(XML_NAMESPACE_MATH,XML_COLOR,
- XML_RED);
- break;
- case TGREEN:
- AddAttribute(XML_NAMESPACE_MATH,XML_COLOR,
- XML_GREEN);
- break;
- case TBLUE:
- AddAttribute(XML_NAMESPACE_MATH,XML_COLOR,
- XML_BLUE);
- break;
- case TCYAN:
- AddAttribute(XML_NAMESPACE_MATH,XML_COLOR,
- XML_AQUA);
- break;
- case TMAGENTA:
- AddAttribute(XML_NAMESPACE_MATH,XML_COLOR,
- XML_FUCHSIA);
- break;
- case TYELLOW:
- AddAttribute(XML_NAMESPACE_MATH,XML_COLOR,
- XML_YELLOW);
- break;
- case TSIZE:
- {
- const SmFontNode *pFontNode = static_cast<const SmFontNode *>
- (pNode);
- const Fraction &aFrac = pFontNode->GetSizeParameter();
-
- OUStringBuffer sStrBuf;
- switch(pFontNode->GetSizeType())
- {
- case FNTSIZ_MULTIPLY:
- SvXMLUnitConverter::convertDouble(sStrBuf,
- static_cast<double>(aFrac*Fraction(100.00)));
- sStrBuf.append(static_cast<sal_Unicode>('%'));
- break;
- case FNTSIZ_DIVIDE:
- SvXMLUnitConverter::convertDouble(sStrBuf,
- static_cast<double>(Fraction(100.00)/aFrac));
- sStrBuf.append(static_cast<sal_Unicode>('%'));
- break;
- case FNTSIZ_ABSOLUT:
- SvXMLUnitConverter::convertDouble(sStrBuf,
- static_cast<double>(aFrac));
- sStrBuf.append(
- GetXMLToken(XML_UNIT_PT));
- break;
- default:
- {
- //The problem here is that the wheels fall off because
- //font size is stored in 100th's of a mm not pts, and
- //rounding errors take their toll on the original
- //value specified in points.
-
- //Must fix StarMath to retain the original pt values
- Fraction aTemp = Sm100th_mmToPts(pFontNode->GetFont().
- GetSize().Height());
-
- if (pFontNode->GetSizeType() == FNTSIZ_MINUS)
- aTemp-=aFrac;
- else
- aTemp+=aFrac;
-
- double mytest = static_cast<double>(aTemp);
-
- mytest = ::rtl::math::round(mytest,1);
- SvXMLUnitConverter::convertDouble(sStrBuf,mytest);
- sStrBuf.append(GetXMLToken(XML_UNIT_PT));
- }
- break;
- }
-
- OUString sStr(sStrBuf.makeStringAndClear());
- AddAttribute(XML_NAMESPACE_MATH,XML_FONTSIZE,sStr);
- }
- break;
- case TFIXED:
- case TSANS:
- case TSERIF:
- AddAttribute(XML_NAMESPACE_MATH,XML_FONTFAMILY,
- OUString(pNode->GetToken().aText.GetBuffer()));
- break;
- default:
- break;
-
- }
-#if 0
- if (pNode->GetNumSubNodes() > 1) //or in the future is a node that
- //cannot take the currently supported
- //properties
-#endif
- //for now we will just always export with a style and not worry about
- //anyone else for the moment.
- {
- //wrap a style around it
- SvXMLElementExport aStyle(*this,XML_NAMESPACE_MATH,
- XML_MSTYLE, sal_True,sal_True);
- ExportExpression(pNode,nLevel);
- }
-#if 0
- else
- ExportNodes(pNode->GetSubNode(0),nLevel+1);
-#endif
-
- delete pElement;
-}
-
-
-void SmXMLExport::ExportVerticalBrace(const SmNode *pNode, int nLevel)
-{
- //Place the overbrace value OVER a vertical brace and then place that
- //expression OVER the overbrace value, If someone can find a
- //dedicated term in MathML to handle this overbrace/underbrace concept
- //let me know. C.
- XMLTokenEnum which;
-
- switch (pNode->GetToken().eType)
- {
- case TOVERBRACE:
- default:
- which = XML_MOVER;
- break;
- case TUNDERBRACE:
- which = XML_MUNDER;
- break;
- }
-
- DBG_ASSERT(pNode->GetNumSubNodes()==3,"Bad Vertical Brace");
- SvXMLElementExport aOver1(*this,XML_NAMESPACE_MATH,which, sal_True,
- sal_True);
- {//Scoping
- AddAttribute(XML_NAMESPACE_MATH,XML_ACCENT,XML_TRUE);
- SvXMLElementExport aOver2(*this,XML_NAMESPACE_MATH,which, sal_True,
- sal_True);
- ExportNodes(pNode->GetSubNode(0),nLevel);
- ExportNodes(pNode->GetSubNode(1),nLevel);
- }
- ExportNodes(pNode->GetSubNode(2),nLevel);
-}
-
-void SmXMLExport::ExportMatrix(const SmNode *pNode, int nLevel)
-{
- SvXMLElementExport aTable(*this,XML_NAMESPACE_MATH,XML_MTABLE,
- sal_True, sal_True);
- const SmMatrixNode *pMatrix = static_cast<const SmMatrixNode *>(pNode);
- USHORT i=0;
- for (ULONG y = 0; y < pMatrix->GetNumRows(); y++)
- {
- SvXMLElementExport aRow(*this,XML_NAMESPACE_MATH,XML_MTR,
- sal_True, sal_True);
- for (ULONG x = 0; x < pMatrix->GetNumCols(); x++)
- if (const SmNode *pTemp = pNode->GetSubNode(i++))
- {
- SvXMLElementExport aCell(*this,XML_NAMESPACE_MATH,
- XML_MTD, sal_True, sal_True);
- ExportNodes(pTemp,nLevel+1);
- }
- }
-}
-
-void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel)
-{
- if (!pNode)
- return;
- switch(pNode->GetType())
- {
- case NTABLE:
- ExportTable(pNode,nLevel);
- break;
- case NALIGN:
- case NBRACEBODY:
- case NEXPRESSION:
- ExportExpression(pNode,nLevel);
- break;
- case NLINE:
- ExportLine(pNode,nLevel);
- break;
- case NTEXT:
- ExportText(pNode,nLevel);
- break;
- case NSPECIAL: //NSPECIAL requires some sort of Entity preservation in
- //the XML engine.
- case NMATH:
- {
- //To fully handle generic MathML we need to implement the full
- //operator dictionary, we will generate MathML with explicit
- //stretchiness for now.
- sal_Int16 nLength = GetAttrList().getLength();
- sal_Bool bAddStretch=sal_True;
- for( sal_Int16 i = 0; i < nLength; i++ )
- {
- OUString sLocalName;
- sal_uInt16 nPrefix = GetNamespaceMap().GetKeyByAttrName(
- GetAttrList().getNameByIndex(i), &sLocalName );
-
- if ( ( XML_NAMESPACE_MATH == nPrefix ) &&
- IsXMLToken(sLocalName, XML_STRETCHY) )
- {
- bAddStretch = sal_False;
- break;
- }
- }
- if (bAddStretch)
- {
- AddAttribute(XML_NAMESPACE_MATH,XML_STRETCHY,XML_FALSE);
- }
- ExportMath(pNode,nLevel);
- }
- break;
- case NBINHOR:
- ExportBinaryHorizontal(pNode,nLevel);
- break;
- case NUNHOR:
- ExportUnaryHorizontal(pNode,nLevel);
- break;
- case NBRACE:
- ExportBrace(pNode,nLevel);
- break;
- case NBINVER:
- ExportBinaryVertical(pNode,nLevel);
- break;
- case NSUBSUP:
- ExportSubSupScript(pNode,nLevel);
- break;
- case NROOT:
- ExportRoot(pNode,nLevel);
- break;
- case NOPER:
- ExportOperator(pNode,nLevel);
- break;
- case NATTRIBUT:
- ExportAttributes(pNode,nLevel);
- break;
- case NFONT:
- ExportFont(pNode,nLevel);
- break;
- case NVERTICAL_BRACE:
- ExportVerticalBrace(pNode,nLevel);
- break;
- case NMATRIX:
- ExportMatrix(pNode,nLevel);
- break;
- case NBLANK:
- ExportBlank(pNode,nLevel);
- break;
- default:
- break;
-
-#if 0
- default:
- {
- ULONG nSize = pNode->GetNumSubNodes();
- for (ULONG i = 0; i < nSize; i++)
- if (SmNode *pTemp = pNode->GetSubNode(i))
- ExportNodes(pTemp,nLevel+1);
- }
- break;
-#endif
- }
-}
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: x $
+ * $Revision: 1.00 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_starmath.hxx"
+
+/*todo: Change characters and tcharacters to accumulate the characters together
+into one string, xml parser hands them to us line by line rather than all in
+one go*/
+
+#include <com/sun/star/xml/sax/XErrorHandler.hpp>
+#include <com/sun/star/xml/sax/XEntityResolver.hpp>
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/xml/sax/XDTDHandler.hpp>
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XActiveDataControl.hpp>
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/packages/zip/ZipIOException.hpp>
+#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/uno/Any.h>
+
+#include <rtl/math.hxx>
+#include <sfx2/frame.hxx>
+#include <sfx2/docfile.hxx>
+#include <tools/debug.hxx>
+#include <tools/urlobj.hxx>
+#include <svtools/sfxecode.hxx>
+#include <svtools/saveopt.hxx>
+#include <svtools/stritem.hxx>
+#include <svtools/itemprop.hxx>
+#include <unotools/processfactory.hxx>
+#include <unotools/streamwrap.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/attrlist.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <xmloff/xmlmetai.hxx>
+#include <osl/mutex.hxx>
+#include <comphelper/genericpropertyset.hxx>
+
+#include <memory>
+
+#include "mathmlimport.hxx"
+#include "mathtype.hxx"
+#include <starmath.hrc>
+#include <unomodel.hxx>
+#include <document.hxx>
+#include <utility.hxx>
+
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+using namespace ::xmloff::token;
+
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+#define IMPORT_SVC_NAME RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLImportFilter")
+
+#undef WANTEXCEPT
+
+////////////////////////////////////////////////////////////
+
+ULONG SmXMLImportWrapper::Import(SfxMedium &rMedium)
+{
+ ULONG nError = ERRCODE_SFX_DOLOADFAILED;
+
+ uno::Reference<lang::XMultiServiceFactory> xServiceFactory(
+ utl::getProcessServiceFactory());
+ DBG_ASSERT(xServiceFactory.is(), "XMLReader::Read: got no service manager");
+ if ( !xServiceFactory.is() )
+ return nError;
+
+ //Make a model component from our SmModel
+ uno::Reference< lang::XComponent > xModelComp( xModel, uno::UNO_QUERY );
+ DBG_ASSERT( xModelComp.is(), "XMLReader::Read: got no model" );
+
+ // try to get an XStatusIndicator from the Medium
+ uno::Reference<task::XStatusIndicator> xStatusIndicator;
+
+ sal_Bool bEmbedded = sal_False;
+ uno::Reference <lang::XUnoTunnel> xTunnel;
+ xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
+ SmModel *pModel = reinterpret_cast<SmModel *>
+ (xTunnel->getSomething(SmModel::getUnoTunnelId()));
+
+ SmDocShell *pDocShell = pModel ?
+ static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0;
+ if (pDocShell)
+ {
+// if (pDocShell->GetMedium())
+ {
+ DBG_ASSERT( pDocShell->GetMedium() == &rMedium,
+ "different SfxMedium found" );
+
+ SfxItemSet* pSet = rMedium.GetItemSet();
+ if (pSet)
+ {
+ const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(
+ pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
+ if (pItem)
+ pItem->GetValue() >>= xStatusIndicator;
+ }
+ }
+
+ if ( SFX_CREATE_MODE_EMBEDDED == pDocShell->GetCreateMode() )
+ bEmbedded = sal_True;
+ }
+
+ comphelper::PropertyMapEntry aInfoMap[] =
+ {
+ { "PrivateData", sizeof("PrivateData")-1, 0,
+ &::getCppuType( (Reference<XInterface> *)0 ),
+ beans::PropertyAttribute::MAYBEVOID, 0 },
+ { "BaseURI", sizeof("BaseURI")-1, 0,
+ &::getCppuType( (OUString *)0 ),
+ beans::PropertyAttribute::MAYBEVOID, 0 },
+ { "StreamRelPath", sizeof("StreamRelPath")-1, 0,
+ &::getCppuType( (OUString *)0 ),
+ beans::PropertyAttribute::MAYBEVOID, 0 },
+ { "StreamName", sizeof("StreamName")-1, 0,
+ &::getCppuType( (OUString *)0 ),
+ beans::PropertyAttribute::MAYBEVOID, 0 },
+ { NULL, 0, 0, NULL, 0, 0 }
+ };
+ uno::Reference< beans::XPropertySet > xInfoSet(
+ comphelper::GenericPropertySet_CreateInstance(
+ new comphelper::PropertySetInfo( aInfoMap ) ) );
+
+ // Set base URI
+ OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("BaseURI") );
+ xInfoSet->setPropertyValue( sPropName, makeAny( rMedium.GetBaseURL() ) );
+
+ sal_Int32 nSteps=3;
+ if ( !(rMedium.IsStorage()))
+ nSteps = 1;
+
+ sal_Int32 nProgressRange(nSteps);
+ if (xStatusIndicator.is())
+ {
+ xStatusIndicator->start(String(SmResId(STR_STATSTR_READING)),
+ nProgressRange);
+ }
+
+ nSteps=0;
+ if (xStatusIndicator.is())
+ xStatusIndicator->setValue(nSteps++);
+
+ if ( rMedium.IsStorage())
+ {
+ // TODO/LATER: handle the case of embedded links gracefully
+ if ( bEmbedded ) // && !rMedium.GetStorage()->IsRoot() )
+ {
+ OUString aName( RTL_CONSTASCII_USTRINGPARAM( "dummyObjName" ) );
+ if ( rMedium.GetItemSet() )
+ {
+ const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
+ rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
+ if ( pDocHierarchItem )
+ aName = pDocHierarchItem->GetValue();
+ }
+
+ if ( aName.getLength() )
+ {
+ sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath"));
+ xInfoSet->setPropertyValue( sPropName, makeAny( aName ) );
+ }
+ }
+
+ sal_Bool bOASIS = ( SotStorage::GetVersion( rMedium.GetStorage() ) > SOFFICE_FILEFORMAT_60 );
+ if (xStatusIndicator.is())
+ xStatusIndicator->setValue(nSteps++);
+
+ ULONG nWarn = ReadThroughComponent(
+ rMedium.GetStorage(), xModelComp, "meta.xml", "Meta.xml",
+ xServiceFactory, xInfoSet,
+ (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaImporter"
+ : "com.sun.star.comp.Math.XMLMetaImporter") );
+
+ if ( nWarn != ERRCODE_IO_BROKENPACKAGE )
+ {
+ if (xStatusIndicator.is())
+ xStatusIndicator->setValue(nSteps++);
+
+ nWarn = ReadThroughComponent(
+ rMedium.GetStorage(), xModelComp, "settings.xml", 0,
+ xServiceFactory, xInfoSet,
+ (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsImporter"
+ : "com.sun.star.comp.Math.XMLSettingsImporter" ) );
+
+ if ( nWarn != ERRCODE_IO_BROKENPACKAGE )
+ {
+ if (xStatusIndicator.is())
+ xStatusIndicator->setValue(nSteps++);
+
+ nError = ReadThroughComponent(
+ rMedium.GetStorage(), xModelComp, "content.xml", "Content.xml",
+ xServiceFactory, xInfoSet, "com.sun.star.comp.Math.XMLImporter" );
+ }
+ else
+ nError = ERRCODE_IO_BROKENPACKAGE;
+ }
+ else
+ nError = ERRCODE_IO_BROKENPACKAGE;
+ }
+ else
+ {
+ Reference<io::XInputStream> xInputStream =
+ new utl::OInputStreamWrapper(rMedium.GetInStream());
+
+ if (xStatusIndicator.is())
+ xStatusIndicator->setValue(nSteps++);
+
+ nError = ReadThroughComponent( xInputStream, xModelComp,
+ xServiceFactory, xInfoSet, "com.sun.star.comp.Math.XMLImporter", FALSE );
+ }
+
+ if (xStatusIndicator.is())
+ xStatusIndicator->end();
+ return nError;
+}
+
+
+/// read a component (file + filter version)
+ULONG SmXMLImportWrapper::ReadThroughComponent(
+ Reference<io::XInputStream> xInputStream,
+ Reference<XComponent> xModelComponent,
+ Reference<lang::XMultiServiceFactory> & rFactory,
+ Reference<beans::XPropertySet> & rPropSet,
+ const sal_Char* pFilterName,
+ sal_Bool bEncrypted )
+{
+ ULONG nError = ERRCODE_SFX_DOLOADFAILED;
+ DBG_ASSERT(xInputStream.is(), "input stream missing");
+ DBG_ASSERT(xModelComponent.is(), "document missing");
+ DBG_ASSERT(rFactory.is(), "factory missing");
+ DBG_ASSERT(NULL != pFilterName,"I need a service name for the component!");
+
+ // prepare ParserInputSrouce
+ xml::sax::InputSource aParserInput;
+ aParserInput.aInputStream = xInputStream;
+
+ // get parser
+ Reference< xml::sax::XParser > xParser(
+ rFactory->createInstance(
+ OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
+ UNO_QUERY );
+ DBG_ASSERT( xParser.is(), "Can't create parser" );
+ if ( !xParser.is() )
+ return nError;
+
+ Sequence<Any> aArgs( 1 );
+ aArgs[0] <<= rPropSet;
+
+ // get filter
+ Reference< xml::sax::XDocumentHandler > xFilter(
+ rFactory->createInstanceWithArguments(
+ OUString::createFromAscii(pFilterName), aArgs ),
+ UNO_QUERY );
+ DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." );
+ if ( !xFilter.is() )
+ return nError;
+
+ // connect parser and filter
+ xParser->setDocumentHandler( xFilter );
+
+ // connect model and filter
+ Reference < XImporter > xImporter( xFilter, UNO_QUERY );
+ xImporter->setTargetDocument( xModelComponent );
+
+ // finally, parser the stream
+ try
+ {
+ xParser->parseStream( aParserInput );
+
+ uno::Reference<lang::XUnoTunnel> xFilterTunnel;
+ xFilterTunnel = uno::Reference<lang::XUnoTunnel>
+ ( xFilter, uno::UNO_QUERY );
+ SmXMLImport *pFilter = reinterpret_cast< SmXMLImport * >(
+ sal::static_int_cast< sal_uIntPtr >(
+ xFilterTunnel->getSomething( SmXMLImport::getUnoTunnelId() )));
+ if ( pFilter && pFilter->GetSuccess() )
+ nError = 0;
+ }
+ catch( xml::sax::SAXParseException& r )
+ {
+ // sax parser sends wrapped exceptions,
+ // try to find the original one
+ xml::sax::SAXException aSaxEx = *(xml::sax::SAXException*)(&r);
+ sal_Bool bTryChild = sal_True;
+
+ while( bTryChild )
+ {
+ xml::sax::SAXException aTmp;
+ if ( aSaxEx.WrappedException >>= aTmp )
+ aSaxEx = aTmp;
+ else
+ bTryChild = sal_False;
+ }
+
+ packages::zip::ZipIOException aBrokenPackage;
+ if ( aSaxEx.WrappedException >>= aBrokenPackage )
+ return ERRCODE_IO_BROKENPACKAGE;
+
+ if ( bEncrypted )
+ nError = ERRCODE_SFX_WRONGPASSWORD;
+ }
+ catch( xml::sax::SAXException& r )
+ {
+ packages::zip::ZipIOException aBrokenPackage;
+ if ( r.WrappedException >>= aBrokenPackage )
+ return ERRCODE_IO_BROKENPACKAGE;
+
+ if ( bEncrypted )
+ nError = ERRCODE_SFX_WRONGPASSWORD;
+ }
+ catch( packages::zip::ZipIOException& )
+ {
+ nError = ERRCODE_IO_BROKENPACKAGE;
+ }
+ catch( io::IOException& )
+ {
+ }
+
+ return nError;
+}
+
+
+ULONG SmXMLImportWrapper::ReadThroughComponent(
+ const uno::Reference< embed::XStorage >& xStorage,
+ Reference<XComponent> xModelComponent,
+ const sal_Char* pStreamName,
+ const sal_Char* pCompatibilityStreamName,
+ Reference<lang::XMultiServiceFactory> & rFactory,
+ Reference<beans::XPropertySet> & rPropSet,
+ const sal_Char* pFilterName )
+{
+ DBG_ASSERT(xStorage.is(), "Need storage!");
+ DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!");
+
+ // open stream (and set parser input)
+ OUString sStreamName = OUString::createFromAscii(pStreamName);
+ uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY );
+ if ( !xAccess->hasByName(sStreamName) || !xStorage->isStreamElement(sStreamName) )
+ {
+ // stream name not found! Then try the compatibility name.
+ // do we even have an alternative name?
+ if ( pCompatibilityStreamName )
+ sStreamName = OUString::createFromAscii(pCompatibilityStreamName);
+ }
+
+ // get input stream
+ try
+ {
+ uno::Reference < io::XStream > xEventsStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
+
+ // determine if stream is encrypted or not
+ uno::Reference < beans::XPropertySet > xProps( xEventsStream, uno::UNO_QUERY );
+ Any aAny = xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ) );
+ sal_Bool bEncrypted = sal_False;
+ if ( aAny.getValueType() == ::getBooleanCppuType() )
+ aAny >>= bEncrypted;
+
+ // set Base URL
+ if ( rPropSet.is() )
+ {
+ OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("StreamName") );
+ rPropSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
+ }
+
+
+ Reference < io::XInputStream > xStream = xEventsStream->getInputStream();
+ return ReadThroughComponent( xStream, xModelComponent, rFactory, rPropSet, pFilterName, bEncrypted );
+ }
+ catch ( packages::WrongPasswordException& )
+ {
+ return ERRCODE_SFX_WRONGPASSWORD;
+ }
+ catch( packages::zip::ZipIOException& )
+ {
+ return ERRCODE_IO_BROKENPACKAGE;
+ }
+ catch ( uno::Exception& )
+ {
+ }
+
+ return ERRCODE_SFX_DOLOADFAILED;
+}
+
+////////////////////////////////////////////////////////////
+
+SmXMLImport::SmXMLImport(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
+ sal_uInt16 nImportFlags)
+: SvXMLImport( xServiceFactory, nImportFlags ),
+ pPresLayoutElemTokenMap(0),
+ pPresLayoutAttrTokenMap(0),
+ pFencedAttrTokenMap(0),
+ pOperatorAttrTokenMap(0),
+ pAnnotationAttrTokenMap(0),
+ pPresElemTokenMap(0),
+ pPresScriptEmptyElemTokenMap(0),
+ pPresTableElemTokenMap(0),
+ pColorTokenMap(0),
+ bSuccess(sal_False)
+{
+}
+
+const uno::Sequence< sal_Int8 > & SmXMLImport::getUnoTunnelId() throw()
+{
+ static uno::Sequence< sal_Int8 > * pSeq = 0;
+ if ( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if ( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+OUString SAL_CALL SmXMLImport_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLImporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SmXMLImport_getSupportedServiceNames()
+ throw()
+{
+ const OUString aServiceName( IMPORT_SVC_NAME );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SmXMLImport_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+ throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SmXMLImport(IMPORT_ALL);
+ return (cppu::OWeakObject*)new SmXMLImport(rSMgr, IMPORT_ALL);
+}
+
+////////////////////////////////////////////////////////////
+
+OUString SAL_CALL SmXMLImportMeta_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisMetaImporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SmXMLImportMeta_getSupportedServiceNames()
+throw()
+{
+ const OUString aServiceName( IMPORT_SVC_NAME );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SmXMLImportMeta_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SmXMLImport( IMPORT_META );
+ return (cppu::OWeakObject*)new SmXMLImport( rSMgr, IMPORT_META );
+}
+
+////////////////////////////////////////////////////////////
+
+OUString SAL_CALL SmXMLImportSettings_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisSettingsImporter" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SmXMLImportSettings_getSupportedServiceNames()
+ throw()
+{
+ const OUString aServiceName( IMPORT_SVC_NAME );
+ const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SmXMLImportSettings_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
+ throw( uno::Exception )
+{
+ // #110680#
+ // return (cppu::OWeakObject*)new SmXMLImport( IMPORT_SETTINGS );
+ return (cppu::OWeakObject*)new SmXMLImport( rSMgr, IMPORT_SETTINGS );
+}
+
+////////////////////////////////////////////////////////////
+
+// XServiceInfo
+// override empty method from parent class
+rtl::OUString SAL_CALL SmXMLImport::getImplementationName()
+ throw(uno::RuntimeException)
+{
+ OUString aTxt;
+ switch( getImportFlags() )
+ {
+ case IMPORT_META:
+ aTxt = SmXMLImportMeta_getImplementationName();
+ break;
+ case IMPORT_SETTINGS:
+ aTxt = SmXMLImportSettings_getImplementationName();
+ break;
+ case IMPORT_ALL:
+ default:
+ aTxt = SmXMLImport_getImplementationName();
+ break;
+ }
+ return aTxt;
+}
+
+
+sal_Int64 SAL_CALL SmXMLImport::getSomething(
+ const uno::Sequence< sal_Int8 >&rId )
+throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this));
+
+ return SvXMLImport::getSomething( rId );
+}
+
+void SmXMLImport::endDocument(void)
+ throw(xml::sax::SAXException, uno::RuntimeException)
+{
+ //Set the resulted tree into the SmDocShell where it belongs
+ SmNode *pTree;
+ if (NULL != (pTree = GetTree()))
+ {
+ uno::Reference <frame::XModel> xModel = GetModel();
+ uno::Reference <lang::XUnoTunnel> xTunnel;
+ xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
+ SmModel *pModel = reinterpret_cast<SmModel *>
+ (xTunnel->getSomething(SmModel::getUnoTunnelId()));
+
+ if (pModel)
+ {
+ SmDocShell *pDocShell =
+ static_cast<SmDocShell*>(pModel->GetObjectShell());
+ pDocShell->SetFormulaTree(pTree);
+ if (0 == aText.Len()) //If we picked up no annotation text
+ {
+ //Make up some editable text
+ aText = pDocShell->GetText();
+ pTree->CreateTextFromNode(aText);
+ aText.EraseTrailingChars();
+ if ((aText.GetChar(0) == '{') &&
+ (aText.GetChar(aText.Len()-1) == '}'))
+ {
+ aText.Erase(0,1);
+ aText.Erase(aText.Len()-1,1);
+ }
+ }
+ pDocShell->SetText( String() );
+
+ // Convert symbol names
+ SmParser &rParser = pDocShell->GetParser();
+ BOOL bVal = rParser.IsImportSymbolNames();
+ rParser.SetImportSymbolNames( TRUE );
+ SmNode *pTmpTree = rParser.Parse( aText );
+ aText = rParser.GetText();
+ delete pTmpTree;
+ rParser.SetImportSymbolNames( bVal );
+
+ pDocShell->SetText( aText );
+ }
+ DBG_ASSERT(pModel,"So there *was* a uno problem after all");
+
+ bSuccess = sal_True;
+ }
+
+ SvXMLImport::endDocument();
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLImportContext: public SvXMLImportContext
+{
+public:
+ SmXMLImportContext( SmXMLImport &rImport, sal_uInt16 nPrfx,
+ const OUString& rLName)
+ : SvXMLImportContext(rImport, nPrfx, rLName) {}
+
+ const SmXMLImport& GetSmImport() const
+ {
+ return (const SmXMLImport&)GetImport();
+ }
+
+ SmXMLImport& GetSmImport()
+ {
+ return (SmXMLImport&)GetImport();
+ }
+
+ virtual void TCharacters(const OUString & /*rChars*/);
+ virtual void Characters(const OUString &rChars);
+ virtual SvXMLImportContext *CreateChildContext(sal_uInt16 /*nPrefix*/, const OUString& /*rLocalName*/, const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/);
+};
+
+void SmXMLImportContext::TCharacters(const OUString & /*rChars*/)
+{
+}
+
+void SmXMLImportContext::Characters(const OUString &rChars)
+{
+ /*
+ Whitespace occurring within the content of token elements is "trimmed"
+ from the ends (i.e. all whitespace at the beginning and end of the
+ content is removed), and "collapsed" internally (i.e. each sequence of
+ 1 or more whitespace characters is replaced with one blank character).
+ */
+ //collapsing not done yet!
+ const OUString &rChars2 = rChars.trim();
+ if (rChars2.getLength())
+ TCharacters(rChars2/*.collapse()*/);
+}
+
+SvXMLImportContext * SmXMLImportContext::CreateChildContext(sal_uInt16 /*nPrefix*/,
+ const OUString& /*rLocalName*/,
+ const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/)
+{
+ return 0;
+}
+
+////////////////////////////////////////////////////////////
+
+struct SmXMLContext_Helper
+{
+ sal_Int8 nIsBold;
+ sal_Int8 nIsItalic;
+ double nFontSize;
+ sal_Bool bFontNodeNeeded;
+ OUString sFontFamily;
+ OUString sColor;
+
+ SmXMLImportContext rContext;
+
+ SmXMLContext_Helper(SmXMLImportContext &rImport) :
+ nIsBold(-1), nIsItalic(-1), nFontSize(0.0), rContext(rImport) {}
+
+ void RetrieveAttrs(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
+ void ApplyAttrs();
+};
+
+void SmXMLContext_Helper::RetrieveAttrs(const uno::Reference<
+ xml::sax::XAttributeList > & xAttrList )
+{
+ sal_Int8 nOldIsBold=nIsBold;
+ sal_Int8 nOldIsItalic=nIsItalic;
+ double nOldFontSize=nFontSize;
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ OUString sOldFontFamily = sFontFamily;
+ for (sal_Int16 i=0;i<nAttrCount;i++)
+ {
+ OUString sAttrName = xAttrList->getNameByIndex(i);
+ OUString aLocalName;
+ sal_uInt16 nPrefix = rContext.GetSmImport().GetNamespaceMap().
+ GetKeyByAttrName(sAttrName,&aLocalName);
+ OUString sValue = xAttrList->getValueByIndex(i);
+ const SvXMLTokenMap &rAttrTokenMap =
+ rContext.GetSmImport().GetPresLayoutAttrTokenMap();
+ switch(rAttrTokenMap.Get(nPrefix,aLocalName))
+ {
+ case XML_TOK_FONTWEIGHT:
+ nIsBold = sValue.equals(GetXMLToken(XML_BOLD));
+ break;
+ case XML_TOK_FONTSTYLE:
+ nIsItalic = sValue.equals(GetXMLToken(XML_ITALIC));
+ break;
+ case XML_TOK_FONTSIZE:
+ SvXMLUnitConverter::convertDouble(nFontSize,sValue);
+ rContext.GetSmImport().GetMM100UnitConverter().
+ setXMLMeasureUnit(MAP_POINT);
+ if (-1 == sValue.indexOf(GetXMLToken(XML_UNIT_PT)))
+ {
+ if (-1 == sValue.indexOf('%'))
+ nFontSize=0.0;
+ else
+ {
+ rContext.GetSmImport().GetMM100UnitConverter().
+ setXMLMeasureUnit(MAP_RELATIVE);
+ }
+ }
+ break;
+ case XML_TOK_FONTFAMILY:
+ sFontFamily = sValue;
+ break;
+ case XML_TOK_COLOR:
+ sColor = sValue;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if ((nOldIsBold!=nIsBold) || (nOldIsItalic!=nIsItalic) ||
+ (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily)
+ || sColor.getLength())
+ bFontNodeNeeded=sal_True;
+ else
+ bFontNodeNeeded=sal_False;
+}
+
+void SmXMLContext_Helper::ApplyAttrs()
+{
+ SmNodeStack &rNodeStack = rContext.GetSmImport().GetNodeStack();
+
+ if (bFontNodeNeeded)
+ {
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 5;
+
+ if (nIsBold != -1)
+ {
+ if (nIsBold)
+ aToken.eType = TBOLD;
+ else
+ aToken.eType = TNBOLD;
+ SmStructureNode *pFontNode = static_cast<SmStructureNode *>
+ (new SmFontNode(aToken));
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ if (nIsItalic != -1)
+ {
+ if (nIsItalic)
+ aToken.eType = TITALIC;
+ else
+ aToken.eType = TNITALIC;
+ SmStructureNode *pFontNode = static_cast<SmStructureNode *>
+ (new SmFontNode(aToken));
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ if (nFontSize != 0.0)
+ {
+ aToken.eType = TSIZE;
+ SmFontNode *pFontNode = new SmFontNode(aToken);
+
+ if (MAP_RELATIVE == rContext.GetSmImport().GetMM100UnitConverter().
+ getXMLMeasureUnit())
+ {
+ if (nFontSize < 100.00)
+ pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
+ FNTSIZ_DIVIDE);
+ else
+ pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
+ FNTSIZ_MULTIPLY);
+ }
+ else
+ pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
+
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ if (sFontFamily.getLength())
+ {
+ if (sFontFamily.equalsIgnoreAsciiCase(GetXMLToken(XML_FIXED)))
+ aToken.eType = TFIXED;
+ else if (sFontFamily.equalsIgnoreAsciiCase(OUString(
+ RTL_CONSTASCII_USTRINGPARAM("sans"))))
+ aToken.eType = TSANS;
+ else if (sFontFamily.equalsIgnoreAsciiCase(OUString(
+ RTL_CONSTASCII_USTRINGPARAM("serif"))))
+ aToken.eType = TSERIF;
+ else //Just give up, we need to extend our font mechanism to be
+ //more general
+ return;
+
+ aToken.aText = sFontFamily;
+ SmFontNode *pFontNode = new SmFontNode(aToken);
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ if (sColor.getLength())
+ {
+ //Again we can only handle a small set of colours in
+ //StarMath for now.
+ const SvXMLTokenMap& rTokenMap =
+ rContext.GetSmImport().GetColorTokenMap();
+ aToken.eType = static_cast<SmTokenType>(rTokenMap.Get(
+ XML_NAMESPACE_MATH, sColor));
+ if (aToken.eType != -1)
+ {
+ SmFontNode *pFontNode = new SmFontNode(aToken);
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ }
+
+ }
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLDocContext_Impl : public SmXMLImportContext
+{
+public:
+ SmXMLDocContext_Impl( SmXMLImport &rImport, sal_uInt16 nPrfx,
+ const OUString& rLName)
+ : SmXMLImportContext(rImport,nPrfx,rLName) {}
+
+ virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList);
+
+ void EndElement();
+};
+
+////////////////////////////////////////////////////////////
+
+/*avert thy gaze from the proginator*/
+class SmXMLRowContext_Impl : public SmXMLDocContext_Impl
+{
+protected:
+ ULONG nElementCount;
+
+public:
+ SmXMLRowContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLDocContext_Impl(rImport,nPrefix,rLName)
+ { nElementCount = GetSmImport().GetNodeStack().Count(); }
+
+ virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList);
+
+ SvXMLImportContext *StrictCreateChildContext(sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > &xAttrList);
+
+ void EndElement();
+};
+
+////////////////////////////////////////////////////////////
+
+class SmXMLFracContext_Impl : public SmXMLRowContext_Impl
+{
+public:
+ SmXMLFracContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
+
+ void EndElement();
+};
+
+////////////////////////////////////////////////////////////
+
+class SmXMLSqrtContext_Impl : public SmXMLRowContext_Impl
+{
+public:
+ SmXMLSqrtContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
+
+ void EndElement();
+};
+
+////////////////////////////////////////////////////////////
+
+class SmXMLRootContext_Impl : public SmXMLRowContext_Impl
+{
+public:
+ SmXMLRootContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
+
+ void EndElement();
+};
+
+////////////////////////////////////////////////////////////
+
+class SmXMLStyleContext_Impl : public SmXMLRowContext_Impl
+{
+protected:
+ SmXMLContext_Helper aStyleHelper;
+
+public:
+ /*Right now the style tag is completely ignored*/
+ SmXMLStyleContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName) : SmXMLRowContext_Impl(rImport,nPrefix,rLName),
+ aStyleHelper(*this) {}
+
+ void EndElement();
+ void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
+};
+
+void SmXMLStyleContext_Impl::StartElement(const uno::Reference<
+ xml::sax::XAttributeList > & xAttrList )
+{
+#if 1
+ aStyleHelper.RetrieveAttrs(xAttrList);
+#else
+ sal_Int8 nOldIsBold=nIsBold;
+ sal_Int8 nOldIsItalic=nIsItalic;
+ double nOldFontSize=nFontSize;
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ OUString sOldFontFamily = sFontFamily;
+ for (sal_Int16 i=0;i<nAttrCount;i++)
+ {
+ OUString sAttrName = xAttrList->getNameByIndex(i);
+ OUString aLocalName;
+ sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
+ GetKeyByAttrName(sAttrName,&aLocalName);
+ OUString sValue = xAttrList->getValueByIndex(i);
+ const SvXMLTokenMap &rAttrTokenMap =
+ GetSmImport().GetPresLayoutAttrTokenMap();
+ switch(rAttrTokenMap.Get(nPrefix,aLocalName))
+ {
+ case XML_TOK_FONTWEIGHT:
+ nIsBold = sValue.equals(GetXMLToken(XML_BOLD));
+ break;
+ case XML_TOK_FONTSTYLE:
+ nIsItalic = sValue.equals(GetXMLToken(XML_ITALIC));
+ break;
+ case XML_TOK_FONTSIZE:
+ SvXMLUnitConverter::convertDouble(nFontSize,sValue);
+ GetSmImport().GetMM100UnitConverter().
+ setXMLMeasureUnit(MAP_POINT);
+ if (-1 == sValue.indexOf(GetXMLToken(XML_UNIT_PT)))
+ if (-1 == sValue.indexOf('%'))
+ nFontSize=0.0;
+ else
+ {
+ GetSmImport().GetMM100UnitConverter().
+ setXMLMeasureUnit(MAP_RELATIVE);
+ }
+ break;
+ case XML_TOK_FONTFAMILY:
+ sFontFamily = sValue;
+ break;
+ case XML_TOK_COLOR:
+ sColor = sValue;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if ((nOldIsBold!=nIsBold) || (nOldIsItalic!=nIsItalic) ||
+ (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily)
+ || sColor.getLength())
+ bFontNodeNeeded=sal_True;
+ else
+ bFontNodeNeeded=sal_False;
+#endif
+}
+
+
+void SmXMLStyleContext_Impl::EndElement()
+{
+ /*
+ <mstyle> accepts any number of arguments; if this number is not 1, its
+ contents are treated as a single "inferred <mrow>" containing its
+ arguments
+ */
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+ if (rNodeStack.Count() - nElementCount > 1)
+ SmXMLRowContext_Impl::EndElement();
+#if 1
+ aStyleHelper.ApplyAttrs();
+#else
+ if (bFontNodeNeeded)
+ {
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 5;
+
+ if (nIsBold != -1)
+ {
+ if (nIsBold)
+ aToken.eType = TBOLD;
+ else
+ aToken.eType = TNBOLD;
+ SmStructureNode *pFontNode = static_cast<SmStructureNode *>
+ (new SmFontNode(aToken));
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ if (nIsItalic != -1)
+ {
+ if (nIsItalic)
+ aToken.eType = TITALIC;
+ else
+ aToken.eType = TNITALIC;
+ SmStructureNode *pFontNode = static_cast<SmStructureNode *>
+ (new SmFontNode(aToken));
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ if (nFontSize != 0.0)
+ {
+ aToken.eType = TSIZE;
+ SmFontNode *pFontNode = new SmFontNode(aToken);
+
+ if (MAP_RELATIVE == GetSmImport().GetMM100UnitConverter().
+ getXMLMeasureUnit())
+ {
+ if (nFontSize < 100.00)
+ pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
+ FNTSIZ_DIVIDE);
+ else
+ pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
+ FNTSIZ_MULTIPLY);
+ }
+ else
+ pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
+
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ if (sFontFamily.getLength())
+ {
+ if (sFontFamily.equalsIgnoreCase(GetXMLToken(XML_FIXED)))
+ aToken.eType = TFIXED;
+ else if (sFontFamily.equalsIgnoreCase(OUString(
+ RTL_CONSTASCII_USTRINGPARAM("sans"))))
+ aToken.eType = TSANS;
+ else if (sFontFamily.equalsIgnoreCase(OUString(
+ RTL_CONSTASCII_USTRINGPARAM("serif"))))
+ aToken.eType = TSERIF;
+ else //Just give up, we need to extend our font mechanism to be
+ //more general
+ return;
+
+ aToken.aText = sFontFamily;
+ SmFontNode *pFontNode = new SmFontNode(aToken);
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ if (sColor.getLength())
+ {
+ //Again we can only handle a small set of colours in
+ //StarMath for now.
+ const SvXMLTokenMap& rTokenMap =
+ GetSmImport().GetColorTokenMap();
+ aToken.eType = static_cast<SmTokenType>(rTokenMap.Get(
+ XML_NAMESPACE_MATH, sColor));
+ if (aToken.eType != -1)
+ {
+ SmFontNode *pFontNode = new SmFontNode(aToken);
+ pFontNode->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pFontNode);
+ }
+ }
+
+ }
+#endif
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLPaddedContext_Impl : public SmXMLRowContext_Impl
+{
+public:
+ /*Right now the style tag is completely ignored*/
+ SmXMLPaddedContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
+
+ void EndElement();
+};
+
+void SmXMLPaddedContext_Impl::EndElement()
+{
+ /*
+ <mpadded> accepts any number of arguments; if this number is not 1, its
+ contents are treated as a single "inferred <mrow>" containing its
+ arguments
+ */
+ if (GetSmImport().GetNodeStack().Count() - nElementCount > 1)
+ SmXMLRowContext_Impl::EndElement();
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLPhantomContext_Impl : public SmXMLRowContext_Impl
+{
+public:
+ /*Right now the style tag is completely ignored*/
+ SmXMLPhantomContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
+
+ void EndElement();
+};
+
+void SmXMLPhantomContext_Impl::EndElement()
+{
+ /*
+ <mphantom> accepts any number of arguments; if this number is not 1, its
+ contents are treated as a single "inferred <mrow>" containing its
+ arguments
+ */
+ if (GetSmImport().GetNodeStack().Count() - nElementCount > 1)
+ SmXMLRowContext_Impl::EndElement();
+
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 5;
+ aToken.eType = TPHANTOM;
+
+ SmStructureNode *pPhantom = static_cast<SmStructureNode *>
+ (new SmFontNode(aToken));
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+ pPhantom->SetSubNodes(0,rNodeStack.Pop());
+ rNodeStack.Push(pPhantom);
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLFencedContext_Impl : public SmXMLRowContext_Impl
+{
+protected:
+ sal_Unicode cBegin;
+ sal_Unicode cEnd;
+
+public:
+ SmXMLFencedContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLRowContext_Impl(rImport,nPrefix,rLName),
+ cBegin('('), cEnd(')') {}
+
+ void StartElement(const uno::Reference< xml::sax::XAttributeList > & xAttrList );
+ void EndElement();
+};
+
+
+void SmXMLFencedContext_Impl::StartElement(const uno::Reference<
+ xml::sax::XAttributeList > & xAttrList )
+{
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for (sal_Int16 i=0;i<nAttrCount;i++)
+ {
+ OUString sAttrName = xAttrList->getNameByIndex(i);
+ OUString aLocalName;
+ sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
+ GetKeyByAttrName(sAttrName,&aLocalName);
+ OUString sValue = xAttrList->getValueByIndex(i);
+ const SvXMLTokenMap &rAttrTokenMap =
+ GetSmImport().GetFencedAttrTokenMap();
+ switch(rAttrTokenMap.Get(nPrefix,aLocalName))
+ {
+ //temp, starmath cannot handle multichar brackets (I think)
+ case XML_TOK_OPEN:
+ cBegin = sValue[0];
+ break;
+ case XML_TOK_CLOSE:
+ cEnd = sValue[0];
+ break;
+ default:
+ /*Go to superclass*/
+ break;
+ }
+ }
+}
+
+
+void SmXMLFencedContext_Impl::EndElement()
+{
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.aText = ',';
+ aToken.eType = TLEFT;
+ aToken.nLevel = 5;
+
+ aToken.eType = TLPARENT;
+ aToken.cMathChar = cBegin;
+ SmStructureNode *pSNode = new SmBraceNode(aToken);
+ SmNode *pLeft = new SmMathSymbolNode(aToken);
+
+ aToken.cMathChar = cEnd;
+ aToken.eType = TRPARENT;
+ SmNode *pRight = new SmMathSymbolNode(aToken);
+
+ SmNodeArray aRelationArray;
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+
+ aToken.cMathChar = '\0';
+ aToken.aText = ',';
+ aToken.eType = TIDENT;
+
+ ULONG i = rNodeStack.Count() - nElementCount;
+ if (rNodeStack.Count() - nElementCount > 1)
+ i += rNodeStack.Count() - 1 - nElementCount;
+ aRelationArray.resize(i);
+ while (rNodeStack.Count() > nElementCount)
+ {
+ aRelationArray[--i] = rNodeStack.Pop();
+ if (i > 1 && rNodeStack.Count() > 1)
+ aRelationArray[--i] = new SmGlyphSpecialNode(aToken);
+ }
+
+ SmToken aDummy;
+ SmStructureNode *pBody = new SmExpressionNode(aDummy);
+ pBody->SetSubNodes(aRelationArray);
+
+
+ pSNode->SetSubNodes(pLeft,pBody,pRight);
+ pSNode->SetScaleMode(SCALE_HEIGHT);
+ GetSmImport().GetNodeStack().Push(pSNode);
+}
+
+
+////////////////////////////////////////////////////////////
+
+class SmXMLErrorContext_Impl : public SmXMLRowContext_Impl
+{
+public:
+ SmXMLErrorContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
+
+ void EndElement();
+};
+
+void SmXMLErrorContext_Impl::EndElement()
+{
+ /*Right now the error tag is completely ignored, what
+ can I do with it in starmath, ?, maybe we need a
+ report window ourselves, do a test for validity of
+ the xml input, use merrors, and then generate
+ the markup inside the merror with a big red colour
+ of something. For now just throw them all away.
+ */
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+ while (rNodeStack.Count() > nElementCount)
+ {
+ SmNode *pNode = rNodeStack.Pop();
+ delete pNode;
+ }
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLNumberContext_Impl : public SmXMLImportContext
+{
+protected:
+ SmToken aToken;
+
+public:
+ SmXMLNumberContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLImportContext(rImport,nPrefix,rLName)
+ {
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 5;
+ aToken.eType = TNUMBER;
+ }
+
+ virtual void TCharacters(const OUString &rChars);
+
+ void EndElement();
+};
+
+void SmXMLNumberContext_Impl::TCharacters(const OUString &rChars)
+{
+ aToken.aText = rChars;
+}
+
+void SmXMLNumberContext_Impl::EndElement()
+{
+ GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_NUMBER));
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLAnnotationContext_Impl : public SmXMLImportContext
+{
+ sal_Bool bIsStarMath;
+
+public:
+ SmXMLAnnotationContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLImportContext(rImport,nPrefix,rLName), bIsStarMath(sal_False) {}
+
+ virtual void Characters(const OUString &rChars);
+
+ void StartElement(const uno::Reference<xml::sax::XAttributeList > & xAttrList );
+};
+
+void SmXMLAnnotationContext_Impl::StartElement(const uno::Reference<
+ xml::sax::XAttributeList > & xAttrList )
+{
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for (sal_Int16 i=0;i<nAttrCount;i++)
+ {
+ OUString sAttrName = xAttrList->getNameByIndex(i);
+ OUString aLocalName;
+ sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
+ GetKeyByAttrName(sAttrName,&aLocalName);
+
+ OUString sValue = xAttrList->getValueByIndex(i);
+ const SvXMLTokenMap &rAttrTokenMap =
+ GetSmImport().GetAnnotationAttrTokenMap();
+ switch(rAttrTokenMap.Get(nPrefix,aLocalName))
+ {
+ case XML_TOK_ENCODING:
+ bIsStarMath= sValue.equals(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("StarMath 5.0")));
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+void SmXMLAnnotationContext_Impl::Characters(const OUString &rChars)
+{
+ if (bIsStarMath)
+ GetSmImport().GetText().Append(String(rChars));
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLTextContext_Impl : public SmXMLImportContext
+{
+protected:
+ SmToken aToken;
+
+public:
+ SmXMLTextContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLImportContext(rImport,nPrefix,rLName)
+ {
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 5;
+ aToken.eType = TTEXT;
+ }
+
+ virtual void TCharacters(const OUString &rChars);
+
+ void EndElement();
+};
+
+void SmXMLTextContext_Impl::TCharacters(const OUString &rChars)
+{
+ aToken.aText = rChars;
+}
+
+void SmXMLTextContext_Impl::EndElement()
+{
+ GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_TEXT));
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLStringContext_Impl : public SmXMLImportContext
+{
+protected:
+ SmToken aToken;
+
+public:
+ SmXMLStringContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLImportContext(rImport,nPrefix,rLName)
+ {
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 5;
+ aToken.eType = TTEXT;
+ }
+
+ virtual void TCharacters(const OUString &rChars);
+
+ void EndElement();
+};
+
+void SmXMLStringContext_Impl::TCharacters(const OUString &rChars)
+{
+ /*
+ The content of <ms> elements should be rendered with visible "escaping" of
+ certain characters in the content, including at least "double quote"
+ itself, and preferably whitespace other than individual blanks. The intent
+ is for the viewer to see that the expression is a string literal, and to
+ see exactly which characters form its content. For example, <ms>double
+ quote is "</ms> might be rendered as "double quote is \"".
+
+ Obviously this isn't fully done here.
+ */
+ aToken.aText.Erase();
+ aToken.aText += '\"';
+ aToken.aText += String(rChars);
+ aToken.aText += '\"';
+}
+
+void SmXMLStringContext_Impl::EndElement()
+{
+ GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_FIXED));
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLIdentifierContext_Impl : public SmXMLImportContext
+{
+protected:
+ SmXMLContext_Helper aStyleHelper;
+ SmToken aToken;
+
+public:
+ SmXMLIdentifierContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLImportContext(rImport,nPrefix,rLName),aStyleHelper(*this)
+ {
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 5;
+ aToken.eType = TIDENT;
+ }
+
+ void TCharacters(const OUString &rChars);
+ void StartElement(const uno::Reference< xml::sax::XAttributeList > & xAttrList )
+ {
+ aStyleHelper.RetrieveAttrs(xAttrList);
+ };
+ void EndElement();
+};
+
+void SmXMLIdentifierContext_Impl::EndElement()
+{
+ SmTextNode *pNode = 0;
+ //we will handle identifier italic/normal here instead of with a standalone
+ //font node
+ if (((aStyleHelper.nIsItalic == -1) && (aToken.aText.Len() > 1))
+ || ((aStyleHelper.nIsItalic == 0) && (aToken.aText.Len() == 1)))
+ {
+ pNode = new SmTextNode(aToken,FNT_FUNCTION);
+ pNode->GetFont().SetItalic(ITALIC_NONE);
+ aStyleHelper.nIsItalic = -1;
+ }
+ else
+ pNode = new SmTextNode(aToken,FNT_VARIABLE);
+ if (aStyleHelper.bFontNodeNeeded && aStyleHelper.nIsItalic != -1)
+ {
+ if (aStyleHelper.nIsItalic)
+ pNode->GetFont().SetItalic(ITALIC_NORMAL);
+ else
+ pNode->GetFont().SetItalic(ITALIC_NONE);
+ }
+
+ if ((-1!=aStyleHelper.nIsBold) || (0.0!=aStyleHelper.nFontSize) ||
+ (aStyleHelper.sFontFamily.getLength()) ||
+ aStyleHelper.sColor.getLength())
+ aStyleHelper.bFontNodeNeeded=sal_True;
+ else
+ aStyleHelper.bFontNodeNeeded=sal_False;
+ if (aStyleHelper.bFontNodeNeeded)
+ aStyleHelper.ApplyAttrs();
+ GetSmImport().GetNodeStack().Push(pNode);
+}
+
+void SmXMLIdentifierContext_Impl::TCharacters(const OUString &rChars)
+{
+ aToken.aText = rChars;
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLOperatorContext_Impl : public SmXMLImportContext
+{
+ sal_Bool bIsStretchy;
+
+protected:
+ SmToken aToken;
+
+public:
+ SmXMLOperatorContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLImportContext(rImport,nPrefix,rLName), bIsStretchy(sal_False)
+ {
+ aToken.nGroup = 0;
+ aToken.eType = TSPECIAL;
+ aToken.nLevel = 5;
+ }
+
+ void TCharacters(const OUString &rChars);
+ void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
+ void EndElement();
+};
+
+void SmXMLOperatorContext_Impl::TCharacters(const OUString &rChars)
+{
+ aToken.cMathChar = rChars[0];
+}
+
+void SmXMLOperatorContext_Impl::EndElement()
+{
+ SmMathSymbolNode *pNode = new SmMathSymbolNode(aToken);
+ //For stretchy scaling the scaling must be retrieved from this node
+ //and applied to the expression itself so as to get the expression
+ //to scale the operator to the height of the expression itself
+ if (bIsStretchy)
+ pNode->SetScaleMode(SCALE_HEIGHT);
+ GetSmImport().GetNodeStack().Push(pNode);
+}
+
+
+
+void SmXMLOperatorContext_Impl::StartElement(const uno::Reference<
+ xml::sax::XAttributeList > & xAttrList )
+{
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for (sal_Int16 i=0;i<nAttrCount;i++)
+ {
+ OUString sAttrName = xAttrList->getNameByIndex(i);
+ OUString aLocalName;
+ sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
+ GetKeyByAttrName(sAttrName,&aLocalName);
+
+ OUString sValue = xAttrList->getValueByIndex(i);
+ const SvXMLTokenMap &rAttrTokenMap =
+ GetSmImport().GetOperatorAttrTokenMap();
+ switch(rAttrTokenMap.Get(nPrefix,aLocalName))
+ {
+ case XML_TOK_STRETCHY:
+ bIsStretchy = sValue.equals(
+ GetXMLToken(XML_TRUE));
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+
+////////////////////////////////////////////////////////////
+
+class SmXMLSpaceContext_Impl : public SmXMLImportContext
+{
+public:
+ SmXMLSpaceContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLImportContext(rImport,nPrefix,rLName) {}
+
+ void StartElement(const uno::Reference< xml::sax::XAttributeList >& xAttrList );
+};
+
+void SmXMLSpaceContext_Impl::StartElement(
+ const uno::Reference<xml::sax::XAttributeList > & /*xAttrList*/ )
+{
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.eType = TBLANK;
+ aToken.nLevel = 5;
+ SmBlankNode *pBlank = new SmBlankNode(aToken);
+ pBlank->IncreaseBy(aToken);
+ GetSmImport().GetNodeStack().Push(pBlank);
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLSubContext_Impl : public SmXMLRowContext_Impl
+{
+protected:
+ void GenericEndElement(SmTokenType eType,SmSubSup aSubSup);
+
+public:
+ SmXMLSubContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
+
+ void EndElement()
+ {
+ GenericEndElement(TRSUB,RSUB);
+ }
+};
+
+
+void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup eSubSup)
+{
+ /*The <msub> element requires exactly 2 arguments.*/
+ DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
+ "Sub has not two arguments");
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 0;
+ aToken.eType = eType;
+ SmSubSupNode *pNode = new SmSubSupNode(aToken);
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+
+ // initialize subnodes array
+ SmNodeArray aSubNodes;
+ aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
+ for (ULONG i = 1; i < aSubNodes.size(); i++)
+ aSubNodes[i] = NULL;
+
+ aSubNodes[eSubSup+1] = rNodeStack.Pop();
+ aSubNodes[0] = rNodeStack.Pop();
+ pNode->SetSubNodes(aSubNodes);
+ rNodeStack.Push(pNode);
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLSupContext_Impl : public SmXMLSubContext_Impl
+{
+public:
+ SmXMLSupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLSubContext_Impl(rImport,nPrefix,rLName) {}
+
+ void EndElement()
+ {
+ GenericEndElement(TRSUP,RSUP);
+ }
+};
+
+////////////////////////////////////////////////////////////
+
+class SmXMLSubSupContext_Impl : public SmXMLRowContext_Impl
+{
+protected:
+ void GenericEndElement(SmTokenType eType, SmSubSup aSub,SmSubSup aSup);
+
+public:
+ SmXMLSubSupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
+
+ void EndElement()
+ {
+ GenericEndElement(TRSUB,RSUB,RSUP);
+ }
+};
+
+void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType,
+ SmSubSup aSub,SmSubSup aSup)
+{
+ /*The <msub> element requires exactly 3 arguments.*/
+ DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 3,
+ "SubSup has not three arguments");
+
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 0;
+ aToken.eType = eType;
+ SmSubSupNode *pNode = new SmSubSupNode(aToken);
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+
+ // initialize subnodes array
+ SmNodeArray aSubNodes;
+ aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
+ for (ULONG i = 1; i < aSubNodes.size(); i++)
+ aSubNodes[i] = NULL;
+
+ aSubNodes[aSup+1] = rNodeStack.Pop();
+ aSubNodes[aSub+1] = rNodeStack.Pop();
+ aSubNodes[0] = rNodeStack.Pop();
+ pNode->SetSubNodes(aSubNodes);
+ rNodeStack.Push(pNode);
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLUnderContext_Impl : public SmXMLSubContext_Impl
+{
+protected:
+ sal_Int16 nAttrCount;
+
+public:
+ SmXMLUnderContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLSubContext_Impl(rImport,nPrefix,rLName) {}
+
+ void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
+ void EndElement();
+ void HandleAccent();
+};
+
+void SmXMLUnderContext_Impl::StartElement(const uno::Reference<
+ xml::sax::XAttributeList > & xAttrList )
+{
+ nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+}
+
+void SmXMLUnderContext_Impl::HandleAccent()
+{
+ DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
+ "Sub has not two arguments");
+
+ /*Just one special case for the underline thing*/
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+ SmNode *pTest = rNodeStack.Pop();
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 0;
+ aToken.eType = TUNDERLINE;
+
+
+ SmNodeArray aSubNodes;
+ aSubNodes.resize(2);
+
+ SmStructureNode *pNode = new SmAttributNode(aToken);
+ if ((pTest->GetToken().cMathChar & 0x0FFF) == 0x0332)
+ {
+ aSubNodes[0] = new SmRectangleNode(aToken);
+ delete pTest;
+ }
+ else
+ aSubNodes[0] = pTest;
+
+ aSubNodes[1] = rNodeStack.Pop();
+ pNode->SetSubNodes(aSubNodes);
+ pNode->SetScaleMode(SCALE_WIDTH);
+ rNodeStack.Push(pNode);
+}
+
+
+void SmXMLUnderContext_Impl::EndElement()
+{
+ if (!nAttrCount)
+ GenericEndElement(TCSUB,CSUB);
+ else
+ HandleAccent();
+#if 0
+ //UnderBrace trick
+ SmStructureNode *pNode = rNodeStack.Pop();
+ if (pNode->GetSubNode(1)->GetToken().cMathChar == (0x0332|0xf000))
+ if (pNode->GetSubNode(0)->GetToken().cMathChar == (0x0332|0xf000))
+#endif
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLOverContext_Impl : public SmXMLSubContext_Impl
+{
+protected:
+ sal_Int16 nAttrCount;
+
+public:
+ SmXMLOverContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLSubContext_Impl(rImport,nPrefix,rLName), nAttrCount(0) {}
+
+ void EndElement();
+ void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
+ void HandleAccent();
+};
+
+
+void SmXMLOverContext_Impl::StartElement(const uno::Reference<
+ xml::sax::XAttributeList > & xAttrList )
+{
+ nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+}
+
+
+void SmXMLOverContext_Impl::EndElement()
+{
+ if (!nAttrCount)
+ GenericEndElement(TCSUP,CSUP);
+ else
+ HandleAccent();
+}
+
+
+void SmXMLOverContext_Impl::HandleAccent()
+{
+ DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
+ "Sub has not two arguments");
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 0;
+ aToken.eType = TACUTE;
+
+ SmAttributNode *pNode = new SmAttributNode(aToken);
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+
+ SmNodeArray aSubNodes;
+ aSubNodes.resize(2);
+ aSubNodes[0] = rNodeStack.Pop();
+ aSubNodes[1] = rNodeStack.Pop();
+ pNode->SetSubNodes(aSubNodes);
+ pNode->SetScaleMode(SCALE_WIDTH);
+ rNodeStack.Push(pNode);
+
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLUnderOverContext_Impl : public SmXMLSubSupContext_Impl
+{
+public:
+ SmXMLUnderOverContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLSubSupContext_Impl(rImport,nPrefix,rLName) {}
+
+ void EndElement()
+ {
+ GenericEndElement(TCSUB,CSUB,CSUP);
+ }
+};
+
+////////////////////////////////////////////////////////////
+
+class SmXMLMultiScriptsContext_Impl : public SmXMLSubSupContext_Impl
+{
+ sal_Bool bHasPrescripts;
+
+public:
+ SmXMLMultiScriptsContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName) :
+ SmXMLSubSupContext_Impl(rImport,nPrefix,rLName),
+ bHasPrescripts(FALSE) {}
+
+ void EndElement();
+ void MiddleElement();
+ SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > &xAttrList);
+};
+
+////////////////////////////////////////////////////////////
+
+class SmXMLNoneContext_Impl : public SmXMLImportContext
+{
+public:
+ SmXMLNoneContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLImportContext(rImport,nPrefix,rLName) {}
+
+ void EndElement();
+};
+
+
+void SmXMLNoneContext_Impl::EndElement(void)
+{
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.aText.Erase();
+ aToken.nLevel = 5;
+ aToken.eType = TIDENT;
+ GetSmImport().GetNodeStack().Push(
+ new SmTextNode(aToken,FNT_VARIABLE));
+}
+
+////////////////////////////////////////////////////////////
+
+class SmXMLPrescriptsContext_Impl : public SmXMLImportContext
+{
+public:
+ SmXMLPrescriptsContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName)
+ : SmXMLImportContext(rImport,nPrefix,rLName) {}
+};
+
+////////////////////////////////////////////////////////////
+
+class SmXMLTableRowContext_Impl : public SmXMLRowContext_Impl
+{
+public:
+ SmXMLTableRowContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName) :
+ SmXMLRowContext_Impl(rImport,nPrefix,rLName)
+ {}
+
+ SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > &xAttrList);
+};
+
+
+////////////////////////////////////////////////////////////
+
+class SmXMLTableContext_Impl : public SmXMLTableRowContext_Impl
+{
+public:
+ SmXMLTableContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName) :
+ SmXMLTableRowContext_Impl(rImport,nPrefix,rLName)
+ {}
+
+ void EndElement();
+ SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > &xAttrList);
+};
+
+
+////////////////////////////////////////////////////////////
+
+class SmXMLTableCellContext_Impl : public SmXMLRowContext_Impl
+{
+public:
+ SmXMLTableCellContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName) :
+ SmXMLRowContext_Impl(rImport,nPrefix,rLName)
+ {}
+};
+
+////////////////////////////////////////////////////////////
+
+class SmXMLAlignGroupContext_Impl : public SmXMLRowContext_Impl
+{
+public:
+ SmXMLAlignGroupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName) :
+ SmXMLRowContext_Impl(rImport,nPrefix,rLName)
+ {}
+
+ /*Don't do anything with alignment for now*/
+ void EndElement()
+ {
+ }
+};
+
+////////////////////////////////////////////////////////////
+
+class SmXMLActionContext_Impl : public SmXMLRowContext_Impl
+{
+public:
+ SmXMLActionContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
+ const OUString& rLName) :
+ SmXMLRowContext_Impl(rImport,nPrefix,rLName)
+ {}
+
+ void EndElement();
+};
+
+////////////////////////////////////////////////////////////
+
+// NB: virtually inherit so we can multiply inherit properly
+// in SmXMLFlatDocContext_Impl
+class SmXMLOfficeContext_Impl : public virtual SvXMLImportContext
+{
+public:
+ SmXMLOfficeContext_Impl( SmXMLImport &rImport, sal_uInt16 nPrfx,
+ const OUString& rLName)
+ : SvXMLImportContext(rImport,nPrfx,rLName) {}
+
+ virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList);
+};
+
+SvXMLImportContext *SmXMLOfficeContext_Impl::CreateChildContext(sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference< xml::sax::XAttributeList > &xAttrList)
+{
+ SvXMLImportContext *pContext = 0;
+ if ( XML_NAMESPACE_OFFICE == nPrefix &&
+ rLocalName == GetXMLToken(XML_META) )
+ {
+ DBG_WARNING("XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
+ }
+ else if ( XML_NAMESPACE_OFFICE == nPrefix &&
+ rLocalName == GetXMLToken(XML_SETTINGS) )
+ {
+ pContext = new XMLDocumentSettingsContext( GetImport(),
+ XML_NAMESPACE_OFFICE, rLocalName,
+ xAttrList );
+ }
+ else
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+
+ return pContext;
+}
+
+////////////////////////////////////////////////////////////
+
+// context for flat file xml format
+class SmXMLFlatDocContext_Impl
+ : public SmXMLOfficeContext_Impl, public SvXMLMetaDocumentContext
+{
+public:
+ SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport,
+ USHORT i_nPrefix, const OUString & i_rLName,
+ const uno::Reference<document::XDocumentProperties>& i_xDocProps,
+ const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder);
+
+ virtual ~SmXMLFlatDocContext_Impl();
+
+ virtual SvXMLImportContext *CreateChildContext(USHORT i_nPrefix, const OUString& i_rLocalName, const uno::Reference<xml::sax::XAttributeList>& i_xAttrList);
+};
+
+SmXMLFlatDocContext_Impl::SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport,
+ USHORT i_nPrefix, const OUString & i_rLName,
+ const uno::Reference<document::XDocumentProperties>& i_xDocProps,
+ const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder) :
+ SvXMLImportContext(i_rImport, i_nPrefix, i_rLName),
+ SmXMLOfficeContext_Impl(i_rImport, i_nPrefix, i_rLName),
+ SvXMLMetaDocumentContext(i_rImport, i_nPrefix, i_rLName,
+ i_xDocProps, i_xDocBuilder)
+{
+}
+
+SmXMLFlatDocContext_Impl::~SmXMLFlatDocContext_Impl()
+{
+}
+
+SvXMLImportContext *SmXMLFlatDocContext_Impl::CreateChildContext(
+ USHORT i_nPrefix, const OUString& i_rLocalName,
+ const uno::Reference<xml::sax::XAttributeList>& i_xAttrList)
+{
+ // behave like meta base class iff we encounter office:meta
+ if ( XML_NAMESPACE_OFFICE == i_nPrefix &&
+ i_rLocalName == GetXMLToken(XML_META) )
+ {
+ return SvXMLMetaDocumentContext::CreateChildContext(
+ i_nPrefix, i_rLocalName, i_xAttrList );
+ }
+ else
+ {
+ return SmXMLOfficeContext_Impl::CreateChildContext(
+ i_nPrefix, i_rLocalName, i_xAttrList );
+ }
+}
+
+////////////////////////////////////////////////////////////
+
+static __FAR_DATA SvXMLTokenMapEntry aPresLayoutElemTokenMap[] =
+{
+ { XML_NAMESPACE_MATH, XML_SEMANTICS, XML_TOK_SEMANTICS },
+ { XML_NAMESPACE_MATH, XML_MATH, XML_TOK_MATH },
+ { XML_NAMESPACE_MATH, XML_MSTYLE, XML_TOK_MSTYLE },
+ { XML_NAMESPACE_MATH, XML_MERROR, XML_TOK_MERROR },
+ { XML_NAMESPACE_MATH, XML_MPHANTOM, XML_TOK_MPHANTOM },
+ { XML_NAMESPACE_MATH, XML_MROW, XML_TOK_MROW },
+ { XML_NAMESPACE_MATH, XML_MFRAC, XML_TOK_MFRAC },
+ { XML_NAMESPACE_MATH, XML_MSQRT, XML_TOK_MSQRT },
+ { XML_NAMESPACE_MATH, XML_MROOT, XML_TOK_MROOT },
+ { XML_NAMESPACE_MATH, XML_MSUB, XML_TOK_MSUB },
+ { XML_NAMESPACE_MATH, XML_MSUP, XML_TOK_MSUP },
+ { XML_NAMESPACE_MATH, XML_MSUBSUP, XML_TOK_MSUBSUP },
+ { XML_NAMESPACE_MATH, XML_MUNDER, XML_TOK_MUNDER },
+ { XML_NAMESPACE_MATH, XML_MOVER, XML_TOK_MOVER },
+ { XML_NAMESPACE_MATH, XML_MUNDEROVER, XML_TOK_MUNDEROVER },
+ { XML_NAMESPACE_MATH, XML_MMULTISCRIPTS, XML_TOK_MMULTISCRIPTS },
+ { XML_NAMESPACE_MATH, XML_MTABLE, XML_TOK_MTABLE },
+ { XML_NAMESPACE_MATH, XML_MACTION, XML_TOK_MACTION },
+ { XML_NAMESPACE_MATH, XML_MFENCED, XML_TOK_MFENCED },
+ { XML_NAMESPACE_MATH, XML_MPADDED, XML_TOK_MPADDED },
+ XML_TOKEN_MAP_END
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aPresLayoutAttrTokenMap[] =
+{
+ { XML_NAMESPACE_MATH, XML_FONTWEIGHT, XML_TOK_FONTWEIGHT },
+ { XML_NAMESPACE_MATH, XML_FONTSTYLE, XML_TOK_FONTSTYLE },
+ { XML_NAMESPACE_MATH, XML_FONTSIZE, XML_TOK_FONTSIZE },
+ { XML_NAMESPACE_MATH, XML_FONTFAMILY, XML_TOK_FONTFAMILY },
+ { XML_NAMESPACE_MATH, XML_COLOR, XML_TOK_COLOR },
+ XML_TOKEN_MAP_END
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aFencedAttrTokenMap[] =
+{
+ { XML_NAMESPACE_MATH, XML_OPEN, XML_TOK_OPEN },
+ { XML_NAMESPACE_MATH, XML_CLOSE, XML_TOK_CLOSE },
+ XML_TOKEN_MAP_END
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aOperatorAttrTokenMap[] =
+{
+ { XML_NAMESPACE_MATH, XML_STRETCHY, XML_TOK_STRETCHY },
+ XML_TOKEN_MAP_END
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aAnnotationAttrTokenMap[] =
+{
+ { XML_NAMESPACE_MATH, XML_ENCODING, XML_TOK_ENCODING },
+ XML_TOKEN_MAP_END
+};
+
+
+static __FAR_DATA SvXMLTokenMapEntry aPresElemTokenMap[] =
+{
+ { XML_NAMESPACE_MATH, XML_ANNOTATION, XML_TOK_ANNOTATION },
+ { XML_NAMESPACE_MATH, XML_MI, XML_TOK_MI },
+ { XML_NAMESPACE_MATH, XML_MN, XML_TOK_MN },
+ { XML_NAMESPACE_MATH, XML_MO, XML_TOK_MO },
+ { XML_NAMESPACE_MATH, XML_MTEXT, XML_TOK_MTEXT },
+ { XML_NAMESPACE_MATH, XML_MSPACE,XML_TOK_MSPACE },
+ { XML_NAMESPACE_MATH, XML_MS, XML_TOK_MS },
+ { XML_NAMESPACE_MATH, XML_MALIGNGROUP, XML_TOK_MALIGNGROUP },
+ XML_TOKEN_MAP_END
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aPresScriptEmptyElemTokenMap[] =
+{
+ { XML_NAMESPACE_MATH, XML_MPRESCRIPTS, XML_TOK_MPRESCRIPTS },
+ { XML_NAMESPACE_MATH, XML_NONE, XML_TOK_NONE },
+ XML_TOKEN_MAP_END
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aPresTableElemTokenMap[] =
+{
+ { XML_NAMESPACE_MATH, XML_MTR, XML_TOK_MTR },
+ { XML_NAMESPACE_MATH, XML_MTD, XML_TOK_MTD },
+ XML_TOKEN_MAP_END
+};
+
+static __FAR_DATA SvXMLTokenMapEntry aColorTokenMap[] =
+{
+ { XML_NAMESPACE_MATH, XML_BLACK, TBLACK},
+ { XML_NAMESPACE_MATH, XML_WHITE, TWHITE},
+ { XML_NAMESPACE_MATH, XML_RED, TRED},
+ { XML_NAMESPACE_MATH, XML_GREEN, TGREEN},
+ { XML_NAMESPACE_MATH, XML_BLUE, TBLUE},
+ { XML_NAMESPACE_MATH, XML_AQUA, TCYAN},
+ { XML_NAMESPACE_MATH, XML_FUCHSIA, TMAGENTA},
+ { XML_NAMESPACE_MATH, XML_YELLOW, TYELLOW},
+ XML_TOKEN_MAP_END
+};
+
+
+////////////////////////////////////////////////////////////
+
+const SvXMLTokenMap& SmXMLImport::GetPresLayoutElemTokenMap()
+{
+ if (!pPresLayoutElemTokenMap)
+ pPresLayoutElemTokenMap = new SvXMLTokenMap(aPresLayoutElemTokenMap);
+ return *pPresLayoutElemTokenMap;
+}
+
+const SvXMLTokenMap& SmXMLImport::GetPresLayoutAttrTokenMap()
+{
+ if (!pPresLayoutAttrTokenMap)
+ pPresLayoutAttrTokenMap = new SvXMLTokenMap(aPresLayoutAttrTokenMap);
+ return *pPresLayoutAttrTokenMap;
+}
+
+
+const SvXMLTokenMap& SmXMLImport::GetFencedAttrTokenMap()
+{
+ if (!pFencedAttrTokenMap)
+ pFencedAttrTokenMap = new SvXMLTokenMap(aFencedAttrTokenMap);
+ return *pFencedAttrTokenMap;
+}
+
+const SvXMLTokenMap& SmXMLImport::GetOperatorAttrTokenMap()
+{
+ if (!pOperatorAttrTokenMap)
+ pOperatorAttrTokenMap = new SvXMLTokenMap(aOperatorAttrTokenMap);
+ return *pOperatorAttrTokenMap;
+}
+
+const SvXMLTokenMap& SmXMLImport::GetAnnotationAttrTokenMap()
+{
+ if (!pAnnotationAttrTokenMap)
+ pAnnotationAttrTokenMap = new SvXMLTokenMap(aAnnotationAttrTokenMap);
+ return *pAnnotationAttrTokenMap;
+}
+
+const SvXMLTokenMap& SmXMLImport::GetPresElemTokenMap()
+{
+ if (!pPresElemTokenMap)
+ pPresElemTokenMap = new SvXMLTokenMap(aPresElemTokenMap);
+ return *pPresElemTokenMap;
+}
+
+const SvXMLTokenMap& SmXMLImport::GetPresScriptEmptyElemTokenMap()
+{
+ if (!pPresScriptEmptyElemTokenMap)
+ pPresScriptEmptyElemTokenMap = new
+ SvXMLTokenMap(aPresScriptEmptyElemTokenMap);
+ return *pPresScriptEmptyElemTokenMap;
+}
+
+const SvXMLTokenMap& SmXMLImport::GetPresTableElemTokenMap()
+{
+ if (!pPresTableElemTokenMap)
+ pPresTableElemTokenMap = new SvXMLTokenMap(aPresTableElemTokenMap);
+ return *pPresTableElemTokenMap;
+}
+
+const SvXMLTokenMap& SmXMLImport::GetColorTokenMap()
+{
+ if (!pColorTokenMap)
+ pColorTokenMap = new SvXMLTokenMap(aColorTokenMap);
+ return *pColorTokenMap;
+}
+
+////////////////////////////////////////////////////////////
+
+SvXMLImportContext *SmXMLDocContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference<xml::sax::XAttributeList>& xAttrList)
+{
+ SvXMLImportContext* pContext = 0L;
+
+ const SvXMLTokenMap& rTokenMap = GetSmImport().GetPresLayoutElemTokenMap();
+
+ //UINT32 nTest = rTokenMap.Get(nPrefix, rLocalName);
+
+ switch(rTokenMap.Get(nPrefix, rLocalName))
+ {
+ //Consider semantics a dummy except for any starmath annotations
+ case XML_TOK_SEMANTICS:
+ pContext = GetSmImport().CreateRowContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ /*General Layout Schemata*/
+ case XML_TOK_MROW:
+ pContext = GetSmImport().CreateRowContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MFRAC:
+ pContext = GetSmImport().CreateFracContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MSQRT:
+ pContext = GetSmImport().CreateSqrtContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MROOT:
+ pContext = GetSmImport().CreateRootContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MSTYLE:
+ pContext = GetSmImport().CreateStyleContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MERROR:
+ pContext = GetSmImport().CreateErrorContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MPADDED:
+ pContext = GetSmImport().CreatePaddedContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MPHANTOM:
+ pContext = GetSmImport().CreatePhantomContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MFENCED:
+ pContext = GetSmImport().CreateFencedContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ /*Script and Limit Schemata*/
+ case XML_TOK_MSUB:
+ pContext = GetSmImport().CreateSubContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MSUP:
+ pContext = GetSmImport().CreateSupContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MSUBSUP:
+ pContext = GetSmImport().CreateSubSupContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MUNDER:
+ pContext = GetSmImport().CreateUnderContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MOVER:
+ pContext = GetSmImport().CreateOverContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MUNDEROVER:
+ pContext = GetSmImport().CreateUnderOverContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MMULTISCRIPTS:
+ pContext = GetSmImport().CreateMultiScriptsContext(nPrefix,
+ rLocalName, xAttrList);
+ break;
+ case XML_TOK_MTABLE:
+ pContext = GetSmImport().CreateTableContext(nPrefix,
+ rLocalName, xAttrList);
+ break;
+ case XML_TOK_MACTION:
+ pContext = GetSmImport().CreateActionContext(nPrefix,
+ rLocalName, xAttrList);
+ break;
+ default:
+ /*Basically theres an implicit mrow around certain bare
+ *elements, use a RowContext to see if this is one of
+ *those ones*/
+ SmXMLRowContext_Impl aTempContext(GetSmImport(),nPrefix,
+ GetXMLToken(XML_MROW));
+
+ pContext = aTempContext.StrictCreateChildContext(nPrefix,
+ rLocalName, xAttrList);
+ break;
+ }
+ return pContext;
+}
+
+void SmXMLDocContext_Impl::EndElement()
+{
+ SmNodeArray ContextArray;
+ ContextArray.resize(1);
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+
+ for (ULONG i=0;i< 1;i++)
+ ContextArray[i] = rNodeStack.Pop();
+
+ SmToken aDummy;
+ SmStructureNode *pSNode = new SmLineNode(aDummy);
+ pSNode->SetSubNodes(ContextArray);
+ rNodeStack.Push(pSNode);
+
+ SmNodeArray LineArray;
+ ULONG n = rNodeStack.Count();
+ LineArray.resize(n);
+ for (ULONG j = 0; j < n; j++)
+ LineArray[n - (j + 1)] = rNodeStack.Pop();
+ SmStructureNode *pSNode2 = new SmTableNode(aDummy);
+ pSNode2->SetSubNodes(LineArray);
+ rNodeStack.Push(pSNode2);
+}
+
+void SmXMLFracContext_Impl::EndElement()
+{
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 0;
+ aToken.eType = TOVER;
+ SmStructureNode *pSNode = new SmBinVerNode(aToken);
+ SmNode *pOper = new SmRectangleNode(aToken);
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+ DBG_ASSERT(rNodeStack.Count() - nElementCount == 2,
+ "Fraction (mfrac) tag is missing component");
+ if (rNodeStack.Count() - nElementCount == 2)
+ {
+ SmNode *pSecond = rNodeStack.Pop();
+ SmNode *pFirst = rNodeStack.Pop();
+ pSNode->SetSubNodes(pFirst,pOper,pSecond);
+ rNodeStack.Push(pSNode);
+ }
+}
+
+void SmXMLRootContext_Impl::EndElement()
+{
+ /*The <mroot> element requires exactly 2 arguments.*/
+ DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
+ "Root tag is missing component");
+
+ SmToken aToken;
+ aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font
+ aToken.nGroup = 0;
+ aToken.nLevel = 0;
+ aToken.eType = TNROOT;
+ SmStructureNode *pSNode = new SmRootNode(aToken);
+ SmNode *pOper = new SmRootSymbolNode(aToken);
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+ SmNode *pIndex = rNodeStack.Pop();
+ SmNode *pBase = rNodeStack.Pop();
+ pSNode->SetSubNodes(pIndex,pOper,pBase);
+ rNodeStack.Push(pSNode);
+}
+
+void SmXMLSqrtContext_Impl::EndElement()
+{
+ /*
+ <msqrt> accepts any number of arguments; if this number is not 1, its
+ contents are treated as a single "inferred <mrow>" containing its
+ arguments
+ */
+ if (GetSmImport().GetNodeStack().Count() - nElementCount > 1)
+ SmXMLRowContext_Impl::EndElement();
+
+ SmToken aToken;
+ aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font
+ aToken.nGroup = 0;
+ aToken.nLevel = 0;
+ aToken.eType = TSQRT;
+ SmStructureNode *pSNode = new SmRootNode(aToken);
+ SmNode *pOper = new SmRootSymbolNode(aToken);
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+ pSNode->SetSubNodes(0,pOper,rNodeStack.Pop());
+ rNodeStack.Push(pSNode);
+}
+
+void SmXMLRowContext_Impl::EndElement()
+{
+ SmNodeArray aRelationArray;
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+ ULONG nSize = rNodeStack.Count()-nElementCount;
+
+ if (nSize > 0)
+ {
+ aRelationArray.resize(nSize);
+ for (ULONG j=rNodeStack.Count()-nElementCount;j > 0;j--)
+ aRelationArray[j-1] = rNodeStack.Pop();
+
+
+ //If the first or last element is an operator with stretchyness
+ //set then we must create a brace node here from those elements,
+ //removing the stretchness from the operators and applying it to
+ //ourselves, and creating the appropiate dummy StarMath none bracket
+ //to balance the arrangement
+ if (((aRelationArray[0]->GetScaleMode() == SCALE_HEIGHT)
+ && (aRelationArray[0]->GetType() == NMATH))
+ || ((aRelationArray[nSize-1]->GetScaleMode() == SCALE_HEIGHT)
+ && (aRelationArray[nSize-1]->GetType() == NMATH)))
+ {
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 5;
+
+ int nLeft=0,nRight=0;
+ if ((aRelationArray[0]->GetScaleMode() == SCALE_HEIGHT)
+ && (aRelationArray[0]->GetType() == NMATH))
+ {
+ aToken = aRelationArray[0]->GetToken();
+ nLeft=1;
+ }
+ else
+ aToken.cMathChar = '\0';
+
+ aToken.eType = TLPARENT;
+ SmNode *pLeft = new SmMathSymbolNode(aToken);
+
+ if ((aRelationArray[nSize-1]->GetScaleMode() == SCALE_HEIGHT)
+ && (aRelationArray[nSize-1]->GetType() == NMATH))
+ {
+ aToken = aRelationArray[nSize-1]->GetToken();
+ nRight=1;
+ }
+ else
+ aToken.cMathChar = '\0';
+
+ aToken.eType = TRPARENT;
+ SmNode *pRight = new SmMathSymbolNode(aToken);
+
+ SmNodeArray aRelationArray2;
+
+ //!! nSize-nLeft-nRight may be < 0 !!
+ int nRelArrSize = nSize-nLeft-nRight;
+ if (nRelArrSize > 0)
+ {
+ aRelationArray2.resize(nRelArrSize);
+ for (int i=0;i < nRelArrSize;i++)
+ aRelationArray2[i] = aRelationArray[i+nLeft];
+ }
+
+ SmToken aDummy;
+ SmStructureNode *pSNode = new SmBraceNode(aToken);
+ SmStructureNode *pBody = new SmExpressionNode(aDummy);
+ pBody->SetSubNodes(aRelationArray2);
+
+ pSNode->SetSubNodes(pLeft,pBody,pRight);
+ pSNode->SetScaleMode(SCALE_HEIGHT);
+ rNodeStack.Push(pSNode);
+ return;
+ }
+ }
+ else //Multiple newlines result in empty row elements
+ {
+ aRelationArray.resize(1);
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 5;
+ aToken.eType = TNEWLINE;
+ aRelationArray[0] = new SmLineNode(aToken);
+ }
+
+ SmToken aDummy;
+ SmStructureNode *pSNode = new SmExpressionNode(aDummy);
+ pSNode->SetSubNodes(aRelationArray);
+ rNodeStack.Push(pSNode);
+}
+
+
+SvXMLImportContext *SmXMLRowContext_Impl::StrictCreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference<xml::sax::XAttributeList>& xAttrList)
+{
+ SvXMLImportContext* pContext = 0L;
+
+ const SvXMLTokenMap& rTokenMap = GetSmImport().GetPresElemTokenMap();
+ switch(rTokenMap.Get(nPrefix, rLocalName))
+ {
+ /*Note that these should accept malignmark subelements, but do not*/
+ case XML_TOK_MN:
+ pContext = GetSmImport().CreateNumberContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MI:
+ pContext = GetSmImport().CreateIdentifierContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MO:
+ pContext = GetSmImport().CreateOperatorContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MTEXT:
+ pContext = GetSmImport().CreateTextContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MSPACE:
+ pContext = GetSmImport().CreateSpaceContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ case XML_TOK_MS:
+ pContext = GetSmImport().CreateStringContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+
+ /*Note: The maligngroup should only be seen when the row
+ * (or decendants) are in a table*/
+ case XML_TOK_MALIGNGROUP:
+ pContext = GetSmImport().CreateAlignGroupContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+
+ case XML_TOK_ANNOTATION:
+ pContext = GetSmImport().CreateAnnotationContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+
+ default:
+ break;
+ }
+ return pContext;
+}
+
+
+SvXMLImportContext *SmXMLRowContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference<xml::sax::XAttributeList>& xAttrList)
+{
+ SvXMLImportContext* pContext = StrictCreateChildContext(nPrefix,
+ rLocalName, xAttrList);
+
+ if (!pContext)
+ {
+ //Hmm, unrecognized for this level, check to see if its
+ //an element that can have an implicit schema around it
+ pContext = SmXMLDocContext_Impl::CreateChildContext(nPrefix,
+ rLocalName,xAttrList);
+ }
+ return pContext;
+}
+
+
+SvXMLImportContext *SmXMLMultiScriptsContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference<xml::sax::XAttributeList>& xAttrList)
+{
+ SvXMLImportContext* pContext = 0L;
+
+ const SvXMLTokenMap& rTokenMap = GetSmImport().
+ GetPresScriptEmptyElemTokenMap();
+ switch(rTokenMap.Get(nPrefix, rLocalName))
+ {
+ case XML_TOK_MPRESCRIPTS:
+ MiddleElement();
+ pContext = GetSmImport().CreatePrescriptsContext(nPrefix,
+ rLocalName, xAttrList);
+ break;
+ case XML_TOK_NONE:
+ pContext = GetSmImport().CreateNoneContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ default:
+ pContext = SmXMLRowContext_Impl::CreateChildContext(nPrefix,
+ rLocalName,xAttrList);
+ break;
+ }
+ return pContext;
+}
+
+void SmXMLMultiScriptsContext_Impl::MiddleElement()
+{
+ bHasPrescripts=sal_True;
+
+ DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount > 0,
+ "Sub has no arguments");
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+ if (rNodeStack.Count()-nElementCount > 1)
+ {
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 0;
+ aToken.eType = TRSUB;
+ ULONG nFinalCount = rNodeStack.Count()-nElementCount-1;
+
+ SmNodeStack aReverseStack;
+ while (rNodeStack.Count()-nElementCount)
+ {
+ SmNode *pThing = rNodeStack.Pop();
+ aReverseStack.Push(pThing);
+ }
+
+ for (ULONG nCount=0;nCount < nFinalCount;nCount+=2)
+ {
+ SmSubSupNode *pNode = new SmSubSupNode(aToken);
+
+ // initialize subnodes array
+ SmNodeArray aSubNodes;
+ aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
+ for (ULONG i = 1; i < aSubNodes.size(); i++)
+ aSubNodes[i] = NULL;
+
+ /*On each loop the base and its sub sup pair becomes the
+ base for the next loop to which the next sub sup pair is
+ attached, i.e. wheels within wheels*/
+ //if (nCount == 0)
+ aSubNodes[0] = aReverseStack.Pop();
+
+ SmNode *pScriptNode = aReverseStack.Pop();
+
+ if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) ||
+ (pScriptNode->GetToken().aText.Len())))
+ aSubNodes[RSUB+1] = pScriptNode;
+ pScriptNode = aReverseStack.Pop();
+ if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) ||
+ (pScriptNode->GetToken().aText.Len())))
+ aSubNodes[RSUP+1] = pScriptNode;
+
+ pNode->SetSubNodes(aSubNodes);
+ aReverseStack.Push(pNode);
+ }
+ rNodeStack.Push(aReverseStack.Pop());
+ }
+}
+
+
+void SmXMLTableContext_Impl::EndElement()
+{
+ SmNodeArray aExpressionArray;
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+ SmNodeStack aReverseStack;
+ aExpressionArray.resize(rNodeStack.Count()-nElementCount);
+
+ ULONG nRows = rNodeStack.Count()-nElementCount;
+ USHORT nCols = 0;
+
+ SmStructureNode *pArray;
+ for (ULONG i=rNodeStack.Count()-nElementCount;i > 0;i--)
+ {
+ pArray = (SmStructureNode *)rNodeStack.Pop();
+ if (pArray->GetNumSubNodes() == 0)
+ {
+ //This is a little tricky, it is possible that there was
+ //be elements that were not inside a <mtd> pair, in which
+ //case they will not be in a row, i.e. they will not have
+ //SubNodes, so we have to wait until here before we can
+ //resolve the situation. Implicitsurrounding tags are
+ //surprisingly difficult to get right within this
+ //architecture
+
+ SmNodeArray aRelationArray;
+ aRelationArray.resize(1);
+ aRelationArray[0] = pArray;
+ SmToken aDummy;
+ pArray = new SmExpressionNode(aDummy);
+ pArray->SetSubNodes(aRelationArray);
+ }
+
+ if (pArray->GetNumSubNodes() > nCols)
+ nCols = pArray->GetNumSubNodes();
+ aReverseStack.Push(pArray);
+ }
+ aExpressionArray.resize(nCols*nRows);
+ ULONG j=0;
+ while (aReverseStack.Count())
+ {
+ pArray = (SmStructureNode *)aReverseStack.Pop();
+ for (USHORT i=0;i<pArray->GetNumSubNodes();i++)
+ aExpressionArray[j++] = pArray->GetSubNode(i);
+ }
+
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = TRGROUP;
+ aToken.nLevel = 0;
+ aToken.eType = TMATRIX;
+ SmMatrixNode *pSNode = new SmMatrixNode(aToken);
+ pSNode->SetSubNodes(aExpressionArray);
+ pSNode->SetRowCol(static_cast<USHORT>(nRows),nCols);
+ rNodeStack.Push(pSNode);
+}
+
+SvXMLImportContext *SmXMLTableRowContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference<xml::sax::XAttributeList>& xAttrList)
+{
+ SvXMLImportContext* pContext = 0L;
+
+ const SvXMLTokenMap& rTokenMap = GetSmImport().
+ GetPresTableElemTokenMap();
+ switch(rTokenMap.Get(nPrefix, rLocalName))
+ {
+ case XML_TOK_MTD:
+ pContext = GetSmImport().CreateTableCellContext(nPrefix,
+ rLocalName, xAttrList);
+ break;
+ default:
+ pContext = SmXMLRowContext_Impl::CreateChildContext(nPrefix,
+ rLocalName,xAttrList);
+ break;
+ }
+ return pContext;
+}
+
+SvXMLImportContext *SmXMLTableContext_Impl::CreateChildContext(
+ sal_uInt16 nPrefix,
+ const OUString& rLocalName,
+ const uno::Reference<xml::sax::XAttributeList>& xAttrList)
+{
+ SvXMLImportContext* pContext = 0L;
+
+ const SvXMLTokenMap& rTokenMap = GetSmImport().
+ GetPresTableElemTokenMap();
+ switch(rTokenMap.Get(nPrefix, rLocalName))
+ {
+ case XML_TOK_MTR:
+ pContext = GetSmImport().CreateTableRowContext(nPrefix,rLocalName,
+ xAttrList);
+ break;
+ default:
+ pContext = SmXMLTableRowContext_Impl::CreateChildContext(nPrefix,
+ rLocalName,xAttrList);
+ break;
+ }
+ return pContext;
+}
+
+void SmXMLMultiScriptsContext_Impl::EndElement()
+{
+ if (!bHasPrescripts)
+ MiddleElement();
+
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+ if (rNodeStack.Count()-nElementCount > 1)
+ {
+ SmToken aToken;
+ aToken.cMathChar = '\0';
+ aToken.nGroup = 0;
+ aToken.nLevel = 0;
+ aToken.eType = TLSUB;
+ ULONG nFinalCount = rNodeStack.Count()-nElementCount-1;
+
+ SmNodeStack aReverseStack;
+ while (rNodeStack.Count()-nElementCount)
+ aReverseStack.Push(rNodeStack.Pop());
+ for (ULONG nCount=0;nCount < nFinalCount;nCount+=2)
+ {
+ SmSubSupNode *pNode = new SmSubSupNode(aToken);
+
+ // initialize subnodes array
+ SmNodeArray aSubNodes;
+ aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
+ for (ULONG i = 1; i < aSubNodes.size(); i++)
+ aSubNodes[i] = NULL;
+
+ /*On each loop the base and its sub sup pair becomes the
+ base for the next loop to which the next sub sup pair is
+ attached, i.e. wheels within wheels*/
+ //if (nCount == 0)
+ aSubNodes[0] = aReverseStack.Pop();
+
+ SmNode *pScriptNode = aReverseStack.Pop();
+ if (pScriptNode->GetToken().aText.Len())
+ aSubNodes[LSUB+1] = pScriptNode;
+ pScriptNode = aReverseStack.Pop();
+ if (pScriptNode->GetToken().aText.Len())
+ aSubNodes[LSUP+1] = pScriptNode;
+
+ pNode->SetSubNodes(aSubNodes);
+ aReverseStack.Push(pNode);
+ }
+ rNodeStack.Push(aReverseStack.Pop());
+ }
+
+}
+void SmXMLActionContext_Impl::EndElement()
+{
+ /*For now we will just assume that the
+ selected attribute is one, and then just display
+ that expression alone, i.e. remove all expect the
+ first pushed one*/
+
+ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
+ for (ULONG i=rNodeStack.Count()-nElementCount;i > 1;i--)
+ {
+ delete rNodeStack.Pop();
+ }
+}
+
+SvXMLImportContext *SmXMLImport::CreateContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ if ( XML_NAMESPACE_OFFICE == nPrefix )
+ {
+ if ( (IsXMLToken(rLocalName, XML_DOCUMENT) ||
+ IsXMLToken(rLocalName, XML_DOCUMENT_META)))
+ {
+ uno::Reference<xml::sax::XDocumentHandler> xDocBuilder(
+ mxServiceFactory->createInstance(
+ ::rtl::OUString::createFromAscii(
+ "com.sun.star.xml.dom.SAXDocumentBuilder")),
+ uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
+ GetModel(), uno::UNO_QUERY_THROW);
+ return IsXMLToken(rLocalName, XML_DOCUMENT_META)
+ ? new SvXMLMetaDocumentContext(*this,
+ XML_NAMESPACE_OFFICE, rLocalName,
+ xDPS->getDocumentProperties(), xDocBuilder)
+ // flat OpenDocument file format -- this has not been tested...
+ : new SmXMLFlatDocContext_Impl( *this, nPrefix, rLocalName,
+ xDPS->getDocumentProperties(), xDocBuilder);
+ }
+ else
+ {
+ return new SmXMLOfficeContext_Impl( *this,nPrefix,rLocalName);
+ }
+ }
+ else
+ return new SmXMLDocContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateRowContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLRowContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateTextContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLTextContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateAnnotationContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLAnnotationContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateStringContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLStringContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateNumberContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLNumberContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateIdentifierContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLIdentifierContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateOperatorContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLOperatorContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateSpaceContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLSpaceContext_Impl(*this,nPrefix,rLocalName);
+}
+
+
+SvXMLImportContext *SmXMLImport::CreateFracContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLFracContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateSqrtContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLSqrtContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateRootContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLRootContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateStyleContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLStyleContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreatePaddedContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLPaddedContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreatePhantomContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLPhantomContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateFencedContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLFencedContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateErrorContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLErrorContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateSubContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLSubContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateSubSupContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLSubSupContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateSupContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLSupContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateUnderContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLUnderContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateOverContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLOverContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateUnderOverContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLUnderOverContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateMultiScriptsContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLMultiScriptsContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateTableContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLTableContext_Impl(*this,nPrefix,rLocalName);
+}
+SvXMLImportContext *SmXMLImport::CreateTableRowContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLTableRowContext_Impl(*this,nPrefix,rLocalName);
+}
+SvXMLImportContext *SmXMLImport::CreateTableCellContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLTableCellContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateNoneContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLNoneContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreatePrescriptsContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLPrescriptsContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateAlignGroupContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLAlignGroupContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SvXMLImportContext *SmXMLImport::CreateActionContext(sal_uInt16 nPrefix,
+ const OUString &rLocalName,
+ const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
+{
+ return new SmXMLActionContext_Impl(*this,nPrefix,rLocalName);
+}
+
+SmXMLImport::~SmXMLImport() throw ()
+{
+ delete pPresLayoutElemTokenMap;
+ delete pPresElemTokenMap;
+ delete pPresScriptEmptyElemTokenMap;
+ delete pPresTableElemTokenMap;
+ delete pPresLayoutAttrTokenMap;
+ delete pFencedAttrTokenMap;
+ delete pColorTokenMap;
+ delete pOperatorAttrTokenMap;
+ delete pAnnotationAttrTokenMap;
+}
+
+void SmXMLImport::SetViewSettings(const Sequence<PropertyValue>& aViewProps)
+{
+ uno::Reference <frame::XModel> xModel = GetModel();
+ if ( !xModel.is() )
+ return;
+
+ uno::Reference <lang::XUnoTunnel> xTunnel;
+ xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
+ SmModel *pModel = reinterpret_cast<SmModel *>
+ (xTunnel->getSomething(SmModel::getUnoTunnelId()));
+
+ if ( !pModel )
+ return;
+
+ SmDocShell *pDocShell =
+ static_cast<SmDocShell*>(pModel->GetObjectShell());
+ if ( !pDocShell )
+ return;
+
+ Rectangle aRect( pDocShell->GetVisArea() );
+
+ sal_Int32 nCount = aViewProps.getLength();
+ const PropertyValue *pValue = aViewProps.getConstArray();
+
+ long nTmp = 0;
+ //sal_Bool bShowDeletes = sal_False, bShowInserts = sal_False, bShowFooter = sal_False, bShowHeader = sal_False;
+
+ for (sal_Int32 i = 0; i < nCount ; i++)
+ {
+ if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaTop" ) ) )
+ {
+ pValue->Value >>= nTmp;
+ aRect.setY( nTmp );
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaLeft" ) ) )
+ {
+ pValue->Value >>= nTmp;
+ aRect.setX( nTmp );
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaWidth" ) ) )
+ {
+ pValue->Value >>= nTmp;
+ Size aSize( aRect.GetSize() );
+ aSize.Width() = nTmp;
+ aRect.SetSize( aSize );
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaHeight" ) ) )
+ {
+ pValue->Value >>= nTmp;
+ Size aSize( aRect.GetSize() );
+ aSize.Height() = nTmp;
+ aRect.SetSize( aSize );
+ }
+ pValue++;
+ }
+
+ pDocShell->SetVisArea ( aRect );
+}
+
+void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfProps)
+{
+ uno::Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY );
+ if ( xProps.is() )
+ {
+ Reference < XPropertySetInfo > xInfo ( xProps->getPropertySetInfo() );
+ if (xInfo.is() )
+ {
+ sal_Int32 nCount = aConfProps.getLength();
+ const PropertyValue* pValues = aConfProps.getConstArray();
+
+ const OUString sFormula ( RTL_CONSTASCII_USTRINGPARAM ( "Formula" ) );
+ const OUString sBasicLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "BasicLibraries" ) );
+ const OUString sDialogLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "DialogLibraries" ) );
+ while ( nCount-- )
+ {
+ if (pValues->Name != sFormula &&
+ pValues->Name != sBasicLibraries &&
+ pValues->Name != sDialogLibraries)
+ {
+ try
+ {
+ if ( xInfo->hasPropertyByName( pValues->Name ) )
+ xProps->setPropertyValue( pValues->Name, pValues->Value );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "SmXMLImport::SetConfigurationSettings: Exception!" );
+ }
+ }
+
+ pValues++;
+ }
+ }
+ }
+}
+
+
+////////////////////////////////////////////////////////////
+
diff --git a/starmath/source/mathml.hxx b/starmath/source/mathmlimport.hxx
index ed53029c6e7f..ed46efa823fc 100644
--- a/starmath/source/mathml.hxx
+++ b/starmath/source/mathmlimport.hxx
@@ -1,441 +1,350 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: mathml.hxx,v $
- * $Revision: 1.30 $
- *
- * 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 MATHML_HXX
-#define MATHML_HXX
-#ifndef _SDXMLIMP_HXX
-#include <xmloff/xmlimp.hxx>
-#endif
-#ifndef _SDXMLEXP_HXX
-#include <xmloff/xmlexp.hxx>
-#endif
-#include <xmloff/DocumentSettingsContext.hxx>
-#include <xmloff/xmltoken.hxx>
-#include <node.hxx>
-
-class SfxMedium;
-namespace com { namespace sun { namespace star {
- namespace io {
- class XInputStream;
- class XOutputStream; }
- namespace beans {
- class XPropertySet; }
-} } }
-
-
-class SmXMLWrapper
-{
-public:
- SmXMLWrapper(com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rRef)
- : xModel(rRef), bFlat(sal_True) {}
- ULONG Import(SfxMedium &rMedium);
- sal_Bool Export(SfxMedium &rMedium);
- void SetFlat(sal_Bool bIn) {bFlat = bIn;}
-private:
- com::sun::star::uno::Reference<com::sun::star::frame::XModel> xModel;
- sal_Bool bFlat; //set true for export to flat .mml, set false for
- //export to a .sxm (or whatever) package
-
- ULONG ReadThroughComponent(
- ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInputStream,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySet > & rPropSet,
- const sal_Char* pFilterName,
- sal_Bool bEncrypted );
-
- ULONG ReadThroughComponent(
- const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent,
- const sal_Char* pStreamName,
- const sal_Char* pCompatibilityStreamName,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySet > & rPropSet,
- const sal_Char* pFilterName );
-
- sal_Bool WriteThroughComponent(
- ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
- xOutputStream,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
- xComponent,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySet > & rPropSet,
- const sal_Char* pComponentName );
- sal_Bool WriteThroughComponent(
- const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStor,
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
- xComponent,
- const sal_Char* pStreamName,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySet > & rPropSet,
- const sal_Char* pComponentName,
- sal_Bool bCompress=sal_True );
-};
-
-
-class SmXMLImport : public SvXMLImport
-{
-public:
- // #110680#
- SmXMLImport(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
- sal_uInt16 nImportFlags=IMPORT_ALL);
-
-#ifdef TL_NOT_USED_YET
- // #110680#
- SmXMLImport(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
- com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel,
- const rtl::OUString &rFileName);
-#endif //TL_NOT_USED_YET
-
- // XServiceInfo (override parent method)
- ::rtl::OUString SAL_CALL getImplementationName()
- throw( ::com::sun::star::uno::RuntimeException );
-
- void SAL_CALL endDocument(void)
- throw( ::com::sun::star::xml::sax::SAXException,
- ::com::sun::star::uno::RuntimeException );
- sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
- sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException);
- static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId()
- throw();
- SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateMathContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateRowContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateFracContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateNumberContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateTextContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateAnnotationContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateStringContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateIdentifierContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateOperatorContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateSpaceContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateSqrtContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateRootContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateStyleContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreatePaddedContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreatePhantomContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateFencedContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateErrorContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateSubContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateSupContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateSubSupContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateUnderContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateOverContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateUnderOverContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateMultiScriptsContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateNoneContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreatePrescriptsContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateTableContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateTableRowContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateTableCellContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateAlignGroupContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
- SvXMLImportContext *CreateActionContext(sal_uInt16 nPrefix,
- const rtl::OUString &rLocalName,
- const com::sun::star::uno::Reference <
- com::sun::star::xml::sax::XAttributeList> &xAttrList);
-
- const SvXMLTokenMap &GetPresLayoutElemTokenMap();
- const SvXMLTokenMap &GetPresLayoutAttrTokenMap();
- const SvXMLTokenMap &GetFencedAttrTokenMap();
- const SvXMLTokenMap &GetOperatorAttrTokenMap();
- const SvXMLTokenMap &GetAnnotationAttrTokenMap();
- const SvXMLTokenMap &GetPresElemTokenMap();
- const SvXMLTokenMap &GetPresScriptEmptyElemTokenMap();
- const SvXMLTokenMap &GetPresTableElemTokenMap();
- const SvXMLTokenMap &GetColorTokenMap();
- virtual ~SmXMLImport() throw ();
- SmNodeStack & GetNodeStack() {return aNodeStack;}
- SmNode *GetTree() { return aNodeStack.Pop();}
- sal_Bool GetSuccess() { return bSuccess; }
- String &GetText() { return aText;}
-
- virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
- virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
-
-private:
- SvXMLTokenMap *pPresLayoutElemTokenMap;
- SvXMLTokenMap *pPresLayoutAttrTokenMap;
- SvXMLTokenMap *pFencedAttrTokenMap;
- SvXMLTokenMap *pOperatorAttrTokenMap;
- SvXMLTokenMap *pAnnotationAttrTokenMap;
- SvXMLTokenMap *pPresElemTokenMap;
- SvXMLTokenMap *pPresScriptEmptyElemTokenMap;
- SvXMLTokenMap *pPresTableElemTokenMap;
- SvXMLTokenMap *pColorTokenMap;
-
- SmNodeStack aNodeStack;
- sal_Bool bSuccess;
- String aText;
-};
-
-enum SmXMLMathElemTokenMap
-{
- XML_TOK_MATH
-};
-
-enum SmXMLPresLayoutElemTokenMap
-{
- XML_TOK_SEMANTICS,
- XML_TOK_MSTYLE,
- XML_TOK_MERROR,
- XML_TOK_MPHANTOM,
- XML_TOK_MROW,
- XML_TOK_MFRAC,
- XML_TOK_MSQRT,
- XML_TOK_MROOT,
- XML_TOK_MSUB,
- XML_TOK_MSUP,
- XML_TOK_MSUBSUP,
- XML_TOK_MMULTISCRIPTS,
- XML_TOK_MUNDER,
- XML_TOK_MOVER,
- XML_TOK_MUNDEROVER,
- XML_TOK_MTABLE,
- XML_TOK_MACTION,
- XML_TOK_MFENCED,
- XML_TOK_MPADDED
-};
-
-enum SmXMLPresLayoutAttrTokenMap
-{
- XML_TOK_FONTWEIGHT,
- XML_TOK_FONTSTYLE,
- XML_TOK_FONTSIZE,
- XML_TOK_FONTFAMILY,
- XML_TOK_COLOR
-};
-
-
-enum SmXMLFencedAttrTokenMap
-{
- XML_TOK_OPEN,
- XML_TOK_CLOSE
-};
-
-
-enum SmXMLPresTableElemTokenMap
-{
- XML_TOK_MTR,
- XML_TOK_MTD
-};
-
-enum SmXMLPresElemTokenMap
-{
- XML_TOK_ANNOTATION,
- XML_TOK_MI,
- XML_TOK_MN,
- XML_TOK_MO,
- XML_TOK_MTEXT,
- XML_TOK_MSPACE,
- XML_TOK_MS,
- XML_TOK_MALIGNGROUP
-};
-
-enum SmXMLPresScriptEmptyElemTokenMap
-{
- XML_TOK_MPRESCRIPTS,
- XML_TOK_NONE
-};
-
-enum SmXMLOperatorAttrTokenMap
-{
- XML_TOK_STRETCHY
-};
-
-enum SmXMLAnnotationAttrTokenMap
-{
- XML_TOK_ENCODING
-};
-
-
-class SmXMLExport : public SvXMLExport
-{
-public:
- // #110680#
- SmXMLExport(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
- sal_uInt16 nExportFlags=EXPORT_ALL);
-
-#ifdef TL_NOT_USED_YET
- // #110680#
- SmXMLExport(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
- const SmNode *pIn,
- const rtl::OUString &rFileName,
- com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler> &rHandler);
-#endif //TL_NOT_USED_YET
-
- virtual ~SmXMLExport() {};
-
- // XServiceInfo (override parent method)
- ::rtl::OUString SAL_CALL getImplementationName()
- throw( ::com::sun::star::uno::RuntimeException );
-
- void _ExportAutoStyles() {}
- void _ExportMasterStyles() {}
- void _ExportContent();
- sal_uInt32 exportDoc(enum ::xmloff::token::XMLTokenEnum eClass);
-
- virtual void GetViewSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps);
- virtual void GetConfigurationSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps);
-
- sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
- sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException);
- static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId()
- throw();
-
- sal_Bool GetSuccess() {return bSuccess;}
-
-protected:
- void ExportNodes(const SmNode *pIn,int nLevel);
- void ExportTable(const SmNode *pIn,int nLevel);
- void ExportLine(const SmNode *pNode,int nLevel);
- void ExportExpression(const SmNode *pNode,int nLevel);
- void ExportText(const SmNode *pNode, int nLevel);
- void ExportMath(const SmNode *pNode, int nLevel);
- void ExportPolygon(const SmNode *pNode, int nLevel);
- void ExportBinaryHorizontal(const SmNode *pNode,int nLevel);
- void ExportUnaryHorizontal(const SmNode *pNode,int nLevel);
- void ExportBrace(const SmNode *pNode, int nLevel);
- void ExportBinaryVertical(const SmNode *pNode,int nLevel);
- void ExportSubSupScript(const SmNode *pNode,int nLevel);
- void ExportRoot(const SmNode *pNode, int nLevel);
- void ExportOperator(const SmNode *pNode, int nLevel);
- void ExportAttributes(const SmNode *pNode, int nLevel);
- void ExportFont(const SmNode *pNode, int nLevel);
- void ExportVerticalBrace(const SmNode *pNode, int nLevel);
- void ExportMatrix(const SmNode *pNode, int nLevel);
- void ExportBlank(const SmNode *pNode, int nLevel);
-private:
- const SmNode *pTree;
- String aText;
- sal_Bool bSuccess;
-};
-#endif
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: x $
+ * $Revision: 1.00 $
+ *
+ * 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 _MATHMLIMPORT_HXX_
+#define _MATHMLIMPORT_HXX_
+
+#include <xmloff/xmlimp.hxx>
+#include <xmloff/xmlexp.hxx>
+#include <xmloff/DocumentSettingsContext.hxx>
+#include <xmloff/xmltoken.hxx>
+
+#include <node.hxx>
+
+class SfxMedium;
+namespace com { namespace sun { namespace star {
+ namespace io {
+ class XInputStream;
+ class XOutputStream; }
+ namespace beans {
+ class XPropertySet; }
+} } }
+
+////////////////////////////////////////////////////////////
+
+class SmXMLImportWrapper
+{
+ com::sun::star::uno::Reference<com::sun::star::frame::XModel> xModel;
+
+public:
+ SmXMLImportWrapper(com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rRef)
+ : xModel(rRef) {}
+
+ ULONG Import(SfxMedium &rMedium);
+
+ ULONG ReadThroughComponent(
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInputStream,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & rPropSet,
+ const sal_Char* pFilterName,
+ sal_Bool bEncrypted );
+
+ ULONG ReadThroughComponent(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModelComponent,
+ const sal_Char* pStreamName,
+ const sal_Char* pCompatibilityStreamName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rFactory,
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & rPropSet,
+ const sal_Char* pFilterName );
+};
+
+////////////////////////////////////////////////////////////
+
+class SmXMLImport : public SvXMLImport
+{
+ SvXMLTokenMap *pPresLayoutElemTokenMap;
+ SvXMLTokenMap *pPresLayoutAttrTokenMap;
+ SvXMLTokenMap *pFencedAttrTokenMap;
+ SvXMLTokenMap *pOperatorAttrTokenMap;
+ SvXMLTokenMap *pAnnotationAttrTokenMap;
+ SvXMLTokenMap *pPresElemTokenMap;
+ SvXMLTokenMap *pPresScriptEmptyElemTokenMap;
+ SvXMLTokenMap *pPresTableElemTokenMap;
+ SvXMLTokenMap *pColorTokenMap;
+
+ SmNodeStack aNodeStack;
+ sal_Bool bSuccess;
+ String aText;
+
+public:
+ // #110680#
+ SmXMLImport(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
+ sal_uInt16 nImportFlags=IMPORT_ALL);
+ virtual ~SmXMLImport() throw ();
+
+ // XServiceInfo (override parent method)
+ ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+
+ // XUnoTunnel
+ sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException);
+ static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
+
+ void SAL_CALL endDocument(void)
+ throw( ::com::sun::star::xml::sax::SAXException,
+ ::com::sun::star::uno::RuntimeException );
+
+ SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateMathContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateRowContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateFracContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateNumberContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateTextContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateAnnotationContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateStringContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateIdentifierContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateOperatorContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateSpaceContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateSqrtContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateRootContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateStyleContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreatePaddedContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreatePhantomContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateFencedContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateErrorContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateSubContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateSupContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateSubSupContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateUnderContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateOverContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateUnderOverContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateMultiScriptsContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateNoneContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreatePrescriptsContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateTableContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateTableRowContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateTableCellContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateAlignGroupContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+ SvXMLImportContext *CreateActionContext(sal_uInt16 nPrefix,
+ const rtl::OUString &rLocalName,
+ const com::sun::star::uno::Reference <
+ com::sun::star::xml::sax::XAttributeList> &xAttrList);
+
+ const SvXMLTokenMap &GetPresLayoutElemTokenMap();
+ const SvXMLTokenMap &GetPresLayoutAttrTokenMap();
+ const SvXMLTokenMap &GetFencedAttrTokenMap();
+ const SvXMLTokenMap &GetOperatorAttrTokenMap();
+ const SvXMLTokenMap &GetAnnotationAttrTokenMap();
+ const SvXMLTokenMap &GetPresElemTokenMap();
+ const SvXMLTokenMap &GetPresScriptEmptyElemTokenMap();
+ const SvXMLTokenMap &GetPresTableElemTokenMap();
+ const SvXMLTokenMap &GetColorTokenMap();
+
+ SmNodeStack & GetNodeStack() {return aNodeStack;}
+ SmNode *GetTree() { return aNodeStack.Pop();}
+ sal_Bool GetSuccess() { return bSuccess; }
+ String &GetText() { return aText;}
+
+ virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
+ virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
+};
+
+////////////////////////////////////////////////////////////
+
+enum SmXMLMathElemTokenMap
+{
+ XML_TOK_MATH
+};
+
+enum SmXMLPresLayoutElemTokenMap
+{
+ XML_TOK_SEMANTICS,
+ XML_TOK_MSTYLE,
+ XML_TOK_MERROR,
+ XML_TOK_MPHANTOM,
+ XML_TOK_MROW,
+ XML_TOK_MFRAC,
+ XML_TOK_MSQRT,
+ XML_TOK_MROOT,
+ XML_TOK_MSUB,
+ XML_TOK_MSUP,
+ XML_TOK_MSUBSUP,
+ XML_TOK_MMULTISCRIPTS,
+ XML_TOK_MUNDER,
+ XML_TOK_MOVER,
+ XML_TOK_MUNDEROVER,
+ XML_TOK_MTABLE,
+ XML_TOK_MACTION,
+ XML_TOK_MFENCED,
+ XML_TOK_MPADDED
+};
+
+enum SmXMLPresLayoutAttrTokenMap
+{
+ XML_TOK_FONTWEIGHT,
+ XML_TOK_FONTSTYLE,
+ XML_TOK_FONTSIZE,
+ XML_TOK_FONTFAMILY,
+ XML_TOK_COLOR
+};
+
+
+enum SmXMLFencedAttrTokenMap
+{
+ XML_TOK_OPEN,
+ XML_TOK_CLOSE
+};
+
+
+enum SmXMLPresTableElemTokenMap
+{
+ XML_TOK_MTR,
+ XML_TOK_MTD
+};
+
+enum SmXMLPresElemTokenMap
+{
+ XML_TOK_ANNOTATION,
+ XML_TOK_MI,
+ XML_TOK_MN,
+ XML_TOK_MO,
+ XML_TOK_MTEXT,
+ XML_TOK_MSPACE,
+ XML_TOK_MS,
+ XML_TOK_MALIGNGROUP
+};
+
+enum SmXMLPresScriptEmptyElemTokenMap
+{
+ XML_TOK_MPRESCRIPTS,
+ XML_TOK_NONE
+};
+
+enum SmXMLOperatorAttrTokenMap
+{
+ XML_TOK_STRETCHY
+};
+
+enum SmXMLAnnotationAttrTokenMap
+{
+ XML_TOK_ENCODING
+};
+
+////////////////////////////////////////////////////////////
+
+#endif
+
diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx
index 3e672225cc98..3f122d5c3e0a 100644
--- a/starmath/source/mathtype.cxx
+++ b/starmath/source/mathtype.cxx
@@ -1801,8 +1801,8 @@ int MathType::HandleRecords(int nLevel,sal_uInt8 nSelector,
rRet.Erase();
newline--;
}
- else if ((nPart == 2) || (((nPart == 1) &&
- (nVariation == 0) || (nVariation == 1))))
+ else if ((nPart == 2) || ((((nPart == 1) &&
+ (nVariation == 0)) || (nVariation == 1))))
{
sPush+=rRet;
rRet = sPush;
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 114d6437bb62..ad3987549c0f 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -579,16 +579,16 @@ SmStructureNode::SmStructureNode( const SmStructureNode &rNode ) :
SmNode( rNode.GetType(), rNode.GetToken() )
{
ULONG i;
- for (i = 0; i < aSubNodes.GetSize(); i++)
- delete aSubNodes.Get(i);
- aSubNodes.Clear();
+ for (i = 0; i < aSubNodes.size(); i++)
+ delete aSubNodes[i];
+ aSubNodes.resize(0);
- ULONG nSize = rNode.aSubNodes.GetSize();
- aSubNodes.SetSize( nSize );
+ ULONG nSize = rNode.aSubNodes.size();
+ aSubNodes.resize( nSize );
for (i = 0; i < nSize; ++i)
{
- SmNode *pNode = rNode.aSubNodes.Get(i);
- aSubNodes.Put( i, pNode ? new SmNode( *pNode ) : 0 );
+ SmNode *pNode = rNode.aSubNodes[i];
+ aSubNodes[i] = pNode ? new SmNode( *pNode ) : 0;
}
}
@@ -608,16 +608,16 @@ SmStructureNode & SmStructureNode::operator = ( const SmStructureNode &rNode )
SmNode::operator = ( rNode );
ULONG i;
- for (i = 0; i < aSubNodes.GetSize(); i++)
- delete aSubNodes.Get(i);
- aSubNodes.Clear();
+ for (i = 0; i < aSubNodes.size(); i++)
+ delete aSubNodes[i];
+ aSubNodes.resize(0);
- ULONG nSize = rNode.aSubNodes.GetSize();
- aSubNodes.SetSize( nSize );
+ ULONG nSize = rNode.aSubNodes.size();
+ aSubNodes.resize( nSize );
for (i = 0; i < nSize; ++i)
{
- SmNode *pNode = rNode.aSubNodes.Get(i);
- aSubNodes.Put( i, pNode ? new SmNode( *pNode ) : 0 );
+ SmNode *pNode = rNode.aSubNodes[i];
+ aSubNodes[i] = pNode ? new SmNode( *pNode ) : 0;
}
return *this;
@@ -626,12 +626,14 @@ SmStructureNode & SmStructureNode::operator = ( const SmStructureNode &rNode )
void SmStructureNode::SetSubNodes(SmNode *pFirst, SmNode *pSecond, SmNode *pThird)
{
+ size_t nSize = pThird ? 3 : (pSecond ? 2 : (pFirst ? 1 : 0));
+ aSubNodes.resize( nSize );
if (pFirst)
- aSubNodes.Put(0, pFirst);
+ aSubNodes[0] = pFirst;
if (pSecond)
- aSubNodes.Put(1, pSecond);
+ aSubNodes[1] = pSecond;
if (pThird)
- aSubNodes.Put(2, pThird);
+ aSubNodes[2] = pThird;
}
@@ -649,13 +651,13 @@ BOOL SmStructureNode::IsVisible() const
USHORT SmStructureNode::GetNumSubNodes() const
{
- return (USHORT) aSubNodes.GetSize();
+ return (USHORT) aSubNodes.size();
}
SmNode * SmStructureNode::GetSubNode(USHORT nIndex)
{
- return aSubNodes.Get(nIndex);
+ return aSubNodes[nIndex];
}
@@ -857,8 +859,6 @@ void SmLineNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
void SmExpressionNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
// as 'SmLineNode::Arrange' but keeps alignment of leftmost subnode
{
- DBG_ASSERT(GetNumSubNodes() > 0, "Sm: keine subnodes");
-
SmLineNode::Arrange(rDev, rFormat);
// copy alignment of leftmost subnode if any
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 4404cdb25cdf..83662e50b123 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -1037,10 +1037,10 @@ void SmParser::Table()
ULONG n = NodeStack.Count();
- LineArray.SetSize(n);
+ LineArray.resize(n);
for (ULONG i = 0; i < n; i++)
- LineArray.Put(n - (i + 1), NodeStack.Pop());
+ LineArray[n - (i + 1)] = NodeStack.Pop();
SmStructureNode *pSNode = new SmTableNode(CurToken);
pSNode->SetSubNodes(LineArray);
@@ -1107,15 +1107,15 @@ void SmParser::Line()
USHORT n = 0;
SmNodeArray ExpressionArray;
- ExpressionArray.SetSize(n);
+ ExpressionArray.resize(n);
// start with single expression that may have an alignment statement
// (and go on with expressions that must not have alignment
// statements in 'while' loop below. See also 'Expression()'.)
if (CurToken.eType != TEND && CurToken.eType != TNEWLINE)
{ Align();
- ExpressionArray.SetSize(++n);
- ExpressionArray.Put(n - 1, NodeStack.Pop());
+ ExpressionArray.resize(++n);
+ ExpressionArray[n - 1] = NodeStack.Pop();
}
while (CurToken.eType != TEND && CurToken.eType != TNEWLINE)
@@ -1123,8 +1123,8 @@ void SmParser::Line()
Expression();
else
Align();
- ExpressionArray.SetSize(++n);
- ExpressionArray.Put(n - 1, NodeStack.Pop());
+ ExpressionArray.resize(++n);
+ ExpressionArray[n - 1] = NodeStack.Pop();
}
SmStructureNode *pSNode = new SmLineNode(CurToken);
@@ -1138,16 +1138,16 @@ void SmParser::Expression()
USHORT n = 0;
SmNodeArray RelationArray;
- RelationArray.SetSize(n);
+ RelationArray.resize(n);
Relation();
- RelationArray.SetSize(++n);
- RelationArray.Put(n - 1, NodeStack.Pop());
+ RelationArray.resize(++n);
+ RelationArray[n - 1] = NodeStack.Pop();
while (CurToken.nLevel >= 4)
{ Relation();
- RelationArray.SetSize(++n);
- RelationArray.Put(n - 1, NodeStack.Pop());
+ RelationArray.resize(++n);
+ RelationArray[n - 1] = NodeStack.Pop();
}
SmStructureNode *pSNode = new SmExpressionNode(CurToken);
@@ -1282,10 +1282,10 @@ void SmParser::SubSup(ULONG nActiveGroup)
// initialize subnodes array
SmNodeArray aSubNodes;
- aSubNodes.SetSize(1 + SUBSUP_NUM_ENTRIES);
- aSubNodes.Put(0, NodeStack.Pop());
- for (USHORT i = 1; i < aSubNodes.GetSize(); i++)
- aSubNodes.Put(i, NULL);
+ aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
+ aSubNodes[0] = NodeStack.Pop();
+ for (USHORT i = 1; i < aSubNodes.size(); i++)
+ aSubNodes[i] = NULL;
// process all sub-/supscripts
int nIndex = 0;
@@ -1321,9 +1321,9 @@ void SmParser::SubSup(ULONG nActiveGroup)
"SmParser::Power() : sub-/supscript index falsch");
// set sub-/supscript if not already done
- if (aSubNodes.Get(nIndex) != NULL)
+ if (aSubNodes[nIndex] != NULL)
Error(PE_DOUBLE_SUBSUPSCRIPT);
- aSubNodes.Put(nIndex, NodeStack.Pop());
+ aSubNodes[nIndex] = NodeStack.Pop();
}
pNode->SetSubNodes(aSubNodes);
@@ -1501,7 +1501,7 @@ void SmParser::Term()
USHORT n = 0;
while (TRUE == (bIsAttr = TokenInGroup(TGATTRIBUT))
|| TokenInGroup(TGFONTATTR))
- { aArray.SetSize(n + 1);
+ { aArray.resize(n + 1);
if (bIsAttr)
Attribut();
@@ -1511,7 +1511,7 @@ void SmParser::Term()
// check if casting in following line is ok
DBG_ASSERT(!NodeStack.Top()->IsVisible(), "Sm : Ooops...");
- aArray.Put(n, (SmStructureNode *) NodeStack.Pop());
+ aArray[n] = (SmStructureNode *) NodeStack.Pop();
n++;
}
@@ -1519,8 +1519,8 @@ void SmParser::Term()
SmNode *pFirstNode = NodeStack.Pop();
while (n > 0)
- { aArray.Get(n - 1)->SetSubNodes(0, pFirstNode);
- pFirstNode = aArray.Get(n - 1);
+ { aArray[n - 1]->SetSubNodes(0, pFirstNode);
+ pFirstNode = aArray[n - 1];
n--;
}
NodeStack.Push(pFirstNode);
@@ -2113,9 +2113,9 @@ void SmParser::Bracebody(BOOL bIsLeftRight)
}
// build argument vector in parsing order
- aNodes.SetSize(nNum);
+ aNodes.resize(nNum);
for (USHORT i = 0; i < nNum; i++)
- aNodes.Put(nNum - 1 - i, NodeStack.Pop());
+ aNodes[nNum - 1 - i] = NodeStack.Pop();
pBody->SetSubNodes(aNodes);
pBody->SetScaleMode(bIsLeftRight ? SCALE_HEIGHT : SCALE_NONE);
@@ -2170,10 +2170,10 @@ void SmParser::Binom()
Sum();
Sum();
- ExpressionArray.SetSize(2);
+ ExpressionArray.resize(2);
for (int i = 0; i < 2; i++)
- ExpressionArray.Put(2 - (i + 1), NodeStack.Pop());
+ ExpressionArray[2 - (i + 1)] = NodeStack.Pop();
pSNode->SetSubNodes(ExpressionArray);
NodeStack.Push(pSNode);
@@ -2196,10 +2196,10 @@ void SmParser::Stack()
}
while (CurToken.eType == TPOUND);
- ExpressionArray.SetSize(n);
+ ExpressionArray.resize(n);
for (USHORT i = 0; i < n; i++)
- ExpressionArray.Put(n - (i + 1), NodeStack.Pop());
+ ExpressionArray[n - (i + 1)] = NodeStack.Pop();
if (CurToken.eType != TRGROUP)
Error(PE_RGROUP_EXPECTED);
@@ -2256,10 +2256,10 @@ void SmParser::Matrix()
long nRC = r * c;
- ExpressionArray.SetSize(nRC);
+ ExpressionArray.resize(nRC);
for (USHORT i = 0; i < (nRC); i++)
- ExpressionArray.Put((nRC) - (i + 1), NodeStack.Pop());
+ ExpressionArray[(nRC) - (i + 1)] = NodeStack.Pop();
if (CurToken.eType != TRGROUP)
Error(PE_RGROUP_EXPECTED);
diff --git a/starmath/source/smdetect.cxx b/starmath/source/smdetect.cxx
index b9c6bc2e913e..f65b7fcdc764 100644
--- a/starmath/source/smdetect.cxx
+++ b/starmath/source/smdetect.cxx
@@ -220,13 +220,13 @@ SmFilterDetect::~SmFilterDetect()
if ( bIsStorage )
{
//TODO/LATER: factor this out!
- uno::Reference < embed::XStorage > xStorage = aMedium.GetStorage();
+ uno::Reference < embed::XStorage > xStorage = aMedium.GetStorage( sal_False );
if ( aMedium.GetLastStorageCreationState() != ERRCODE_NONE )
{
// error during storage creation means _here_ that the medium
// is broken, but we can not handle it in medium since unpossibility
// to create a storage does not _always_ means that the medium is broken
- aMedium.SetError( aMedium.GetLastStorageCreationState() );
+ aMedium.SetError( aMedium.GetLastStorageCreationState(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
if ( xInteraction.is() )
{
OUString empty;
diff --git a/starmath/source/smres.src b/starmath/source/smres.src
index 023fc1a483ce..eee43aace130 100644
--- a/starmath/source/smres.src
+++ b/starmath/source/smres.src
@@ -29,8 +29,6 @@
************************************************************************/
-
-
#include <sfx2/sfx.hrc>
#include <svx/globlmn.hrc>
#include "starmath.hrc"
@@ -1576,7 +1574,7 @@ FloatingWindow RID_TOOLBOXWINDOW
OutputSize = TRUE ;
SVLook = TRUE ;
Size = MAP_APPFONT ( 0 , 0 ) ;
- Text [ en-US ] = "Selection" ;
+ Text [ en-US ] = "Formula Elements" ;
ToolBox 1
{
diff --git a/starmath/source/types.cxx b/starmath/source/types.cxx
index fe3ddd521de3..6a4fe919ae95 100644
--- a/starmath/source/types.cxx
+++ b/starmath/source/types.cxx
@@ -80,6 +80,7 @@ static MathConversionEntry aMathConvTbl[] =
{ MS_LEFTARROW, 0x2190, 0 },
{ MS_UPARROW, 0x2191, 0 },
{ MS_DOWNARROW, 0x2193, 0 },
+ { MS_PLACE, 0x2751, 0 },
// predefined-user-defined symbols
// (code-points on the left as defined in 'officecfg' for SO8,
@@ -201,7 +202,6 @@ sal_Unicode ConvertMathToMathType( sal_Unicode cChar )
}
return cRes;
}
-#endif //TL_NOT_YET_USED
sal_Unicode ConvertMathTypeToMath( sal_Unicode cChar )
{
@@ -217,6 +217,7 @@ sal_Unicode ConvertMathTypeToMath( sal_Unicode cChar )
}
return cRes;
}
+#endif //TL_NOT_YET_USED
sal_Unicode ConvertMathToMathML( sal_Unicode cChar )
{
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 8fc038f48e1a..ed6e5b6bd23f 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -78,7 +78,6 @@ using namespace ::com::sun::star::script;
#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
#define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
-#define C2U(cChar) rtl::OUString::createFromAscii(cChar)
////////////////////////////////////////
//
@@ -359,8 +358,8 @@ OUString SmModel::getImplementationName(void) throw( uno::RuntimeException )
sal_Bool SmModel::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
{
return (
- rServiceName == C2U("com.sun.star.document.OfficeDocument" ) ||
- rServiceName == C2U("com.sun.star.formula.FormulaProperties")
+ rServiceName == A2OU("com.sun.star.document.OfficeDocument" ) ||
+ rServiceName == A2OU("com.sun.star.formula.FormulaProperties")
);
}
/*-- 20.01.04 11:21:00---------------------------------------------------
@@ -377,8 +376,8 @@ uno::Sequence< OUString > SmModel::getSupportedServiceNames_Static(void)
uno::Sequence< OUString > aRet(2);
OUString* pArray = aRet.getArray();
- pArray[0] = C2U("com.sun.star.document.OfficeDocument");
- pArray[1] = C2U("com.sun.star.formula.FormulaProperties");
+ pArray[0] = A2OU("com.sun.star.document.OfficeDocument");
+ pArray[1] = A2OU("com.sun.star.formula.FormulaProperties");
return aRet;
}
@@ -863,30 +862,6 @@ sal_Int32 SAL_CALL SmModel::getRendererCount(
return 1;
}
-
-static Size lcl_GuessPaperSize()
-{
- Size aRes;
- Reference< XMultiServiceFactory > xMgr( getProcessServiceFactory() );
- LocaleDataWrapper aLocWrp( xMgr, AllSettings().GetLocale() );
- if( MEASURE_METRIC == aLocWrp.getMeasurementSystemEnum() )
- {
- // in Twip
- aRes.Width() = lA4Width;
- aRes.Height() = lA4Height;
- }
- else
- {
- // in Twip
- aRes.Width() = lLetterWidth;
- aRes.Height() = lLetterHeight;
- }
- aRes = OutputDevice::LogicToLogic( aRes, MapMode(MAP_TWIP),
- MapMode(MAP_100TH_MM) );
- return aRes;
-}
-
-
uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer(
sal_Int32 nRenderer,
const uno::Any& /*rSelection*/,
@@ -910,7 +885,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer(
// if paper size is 0 (usually if no 'real' printer is found),
// guess the paper size
if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0)
- aPrtPaperSize = lcl_GuessPaperSize();
+ aPrtPaperSize = SvxPaperInfo::GetDefaultPaperSize(MAP_100TH_MM);
awt::Size aPageSize( aPrtPaperSize.Width(), aPrtPaperSize.Height() );
uno::Sequence< beans::PropertyValue > aRenderer(1);
@@ -979,7 +954,7 @@ void SAL_CALL SmModel::render(
// no real printer ??
if (aPrtPaperSize.Height() == 0 || aPrtPaperSize.Width() == 0)
{
- aPrtPaperSize = lcl_GuessPaperSize();
+ aPrtPaperSize = SvxPaperInfo::GetDefaultPaperSize(MAP_100TH_MM);
// factors from Windows DIN A4
aOutputSize = Size( (long)(aPrtPaperSize.Width() * 0.941),
(long)(aPrtPaperSize.Height() * 0.961));
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 4ff1904ffb0d..5492553e46fe 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -32,50 +32,50 @@
#include "precompiled_starmath.hxx"
-#include <com/sun/star/accessibility/XAccessible.hpp>
-#include <com/sun/star/accessibility/AccessibleEventObject.hpp>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleEventObject.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/XAccessible.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/storagehelper.hxx>
#include <rtl/logfile.hxx>
-#include <vcl/menu.hxx>
-#include <vcl/decoview.hxx>
-#include <vcl/msgbox.hxx>
-#include <svtools/whiter.hxx>
-#include <svtools/undo.hxx>
-#include <svtools/intitem.hxx>
-#include <svtools/ptitem.hxx>
-#include <svtools/stritem.hxx>
-#include <svtools/eitem.hxx>
-#include <svtools/itemset.hxx>
-#include <svtools/poolitem.hxx>
-#include <sfx2/msg.hxx>
-#include <sfx2/dispatch.hxx>
#include <sfx2/app.hxx>
-#include <sfx2/printer.hxx>
-#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/docinsert.hxx>
#include <sfx2/filedlghelper.hxx>
-#include <svx/zoomitem.hxx>
+#include <sfx2/msg.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/request.hxx>
+#include <svtools/eitem.hxx>
+#include <svtools/intitem.hxx>
+#include <svtools/itemset.hxx>
+#include <svtools/poolitem.hxx>
+#include <svtools/ptitem.hxx>
+#include <svtools/stritem.hxx>
+#include <svtools/transfer.hxx>
+#include <svtools/undo.hxx>
+#include <svtools/whiter.hxx>
+#include <svx/dialogs.hrc>
#include <svx/editeng.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/zoomitem.hxx>
+#include <vcl/decoview.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/msgbox.hxx>
#include <vcl/wrkwin.hxx>
-#include <svtools/transfer.hxx>
-#include <comphelper/storagehelper.hxx>
-#include <comphelper/processfactory.hxx>
-
-#include <sfx2/objface.hxx>
-#include <mathml.hxx>
#include "view.hxx"
-#include "document.hxx"
#include "config.hxx"
-#include "toolbox.hxx"
#include "dialog.hxx"
-#ifndef _STARMATH_HRC
+#include "document.hxx"
#include "starmath.hrc"
-#endif
+#include "toolbox.hxx"
+#include "mathmlimport.hxx"
#define MINWIDTH 200
@@ -89,12 +89,10 @@
#define SmViewShell
#include "smslots.hxx"
-#include <svx/svxdlg.hxx> //CHINA001
-#include <svx/dialogs.hrc> //CHINA001
-using namespace com::sun::star::accessibility;
using namespace com::sun::star;
+using namespace com::sun::star::accessibility;
using namespace com::sun::star::uno;
//////////////////////////////////////////////////////////////////////
@@ -1213,6 +1211,9 @@ SfxPrinter* SmViewShell::GetPrinter(BOOL bCreate)
USHORT SmViewShell::SetPrinter(SfxPrinter *pNewPrinter, USHORT nDiffFlags, bool )
{
RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::SetPrinter" );
+ SfxPrinter *pOld = GetDoc()->GetPrinter();
+ if ( pOld && pOld->IsPrinting() )
+ return SFX_PRINTERROR_BUSY;
if ((nDiffFlags & SFX_PRINTER_PRINTER) == SFX_PRINTER_PRINTER)
GetDoc()->SetPrinter( pNewPrinter );
@@ -1318,7 +1319,7 @@ BOOL SmViewShell::Insert( SfxMedium& rMedium )
bChkOldVersion = FALSE;
// is this a fabulous math package ?
Reference<com::sun::star::frame::XModel> xModel(pDoc->GetModel());
- SmXMLWrapper aEquation(xModel); //!! modifies the result of pDoc->GetText() !!
+ SmXMLImportWrapper aEquation(xModel); //!! modifies the result of pDoc->GetText() !!
bRet = 0 == aEquation.Import(rMedium);
}
}
@@ -1363,7 +1364,7 @@ BOOL SmViewShell::InsertFrom(SfxMedium &rMedium)
if ( rFltName.EqualsAscii(MATHML_XML) )
{
Reference<com::sun::star::frame::XModel> xModel( pDoc->GetModel() );
- SmXMLWrapper aEquation(xModel); //!! modifies the result of pDoc->GetText() !!
+ SmXMLImportWrapper aEquation(xModel); //!! modifies the result of pDoc->GetText() !!
bSuccess = 0 == aEquation.Import(rMedium);
}
else
@@ -1588,7 +1589,7 @@ void SmViewShell::Execute(SfxRequest& rReq)
pImpl->pDocInserter =
new ::sfx2::DocumentInserter( 0, GetDoc()->GetFactory().GetFactoryName(), 0 );
pImpl->pDocInserter->StartExecuteModal( LINK( this, SmViewShell, DialogClosedHdl ) );
- return;
+ break;
}
case SID_NEXTERR:
@@ -1716,8 +1717,6 @@ void SmViewShell::Execute(SfxRequest& rReq)
SmSymbolDialog( NULL, pDev, pp->GetSymSetManager(), *this ).Execute();
}
break;
-
-
}
rReq.Done();
}
@@ -1744,7 +1743,6 @@ void SmViewShell::GetState(SfxItemSet &rSet)
case SID_PASTE:
if( !xClipEvtLstnr.is() && pEditWin)
{
- AddRemoveClipboardListener( TRUE );
TransferableDataHelper aDataHelper(
TransferableDataHelper::CreateFromSystemClipboard(
pEditWin) );
@@ -1834,8 +1832,6 @@ SmViewShell::~SmViewShell()
{
RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::~SmViewShell" );
- AddRemoveClipboardListener( FALSE );
-
//!! this view shell is not active anymore !!
// Thus 'SmGetActiveView' will give a 0 pointer.
// Thus we need to supply this view as argument
@@ -1912,3 +1908,19 @@ IMPL_LINK( SmViewShell, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
return 0;
}
+void SmViewShell::Notify( SfxBroadcaster& , const SfxHint& rHint )
+{
+ if ( rHint.IsA(TYPE(SfxSimpleHint)) )
+ {
+ switch( ( (SfxSimpleHint&) rHint ).GetId() )
+ {
+ case SFX_HINT_MODECHANGED:
+ case SFX_HINT_DOCCHANGED:
+ GetViewFrame()->GetBindings().InvalidateAll(FALSE);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
diff --git a/starmath/source/viewhdl.cxx b/starmath/source/viewhdl.cxx
deleted file mode 100644
index b99b2f320cf9..000000000000
--- a/starmath/source/viewhdl.cxx
+++ /dev/null
@@ -1,170 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: viewhdl.cxx,v $
- * $Revision: 1.10 $
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_starmath.hxx"
-
-
-#include <view.hxx>
-#include <comphelper/processfactory.hxx>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp>
-#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
-#include <vos/mutex.hxx>
-#include <cppuhelper/implbase1.hxx>
-#include <svtools/transfer.hxx>
-#include <sfx2/bindings.hxx>
-#include <sfx2/sfxsids.hrc>
-
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::datatransfer::clipboard;
-
-// --------------------------- Clipboard EventListener ------------------
-
-class SmClipboardChangeListener : public ::cppu::WeakImplHelper1<
- ::com::sun::star::datatransfer::clipboard::XClipboardListener >
-{
- SmViewShell* pView;
-
- // XEventListener
- virtual void SAL_CALL disposing(
- const lang::EventObject& rEventObject ) throw ( ::com::sun::star::uno::RuntimeException)
-;// throw( UNO_NMSPC::RuntimeException );
-
- // XClipboardListener
- virtual void SAL_CALL changedContents(
- const datatransfer::clipboard::ClipboardEvent& rEventObject ) throw ( ::com::sun::star::uno::RuntimeException)
-;// throw( UNO_NMSPC::RuntimeException );
-
-public:
- SmClipboardChangeListener( SmViewShell& rView ) : pView( &rView ) {}
- virtual ~SmClipboardChangeListener();
-
- void ViewDestroyed() { pView = 0; }
-
- void AddRemoveListener( BOOL bAdd );
-};
-
-
-
-// ------------------------- SmClipboardChangeListener ---------------------
-
-SmClipboardChangeListener::~SmClipboardChangeListener()
-{
-}
-
-void SAL_CALL SmClipboardChangeListener::disposing(
- const lang::EventObject& /*rEventObject*/ ) throw ( ::com::sun::star::uno::RuntimeException)
-{
-}
-
-void SAL_CALL SmClipboardChangeListener::changedContents(
- const ClipboardEvent& rEventObject ) throw ( ::com::sun::star::uno::RuntimeException)
-{
- const ::vos::OGuard aGuard( Application::GetSolarMutex() );
-
- if( pView )
- {
- {
- TransferableDataHelper aDataHelper( rEventObject.Contents );
- sal_Bool bHasTransferable = aDataHelper.GetTransferable().is();
-
- //! according to CD the above call to GetTransferable may create a (new)
- //! message loop and thus result in re-entrant code.
- //! Thus it was suggested to check 'pView' here again.
- if (pView)
- {
- pView->bPasteState = bHasTransferable &&
- ( aDataHelper.HasFormat( FORMAT_STRING ) ||
- aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ ) ||
- (aDataHelper.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR )
- && aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE )));
- }
- }
-
- if (pView)
- {
- SfxBindings& rBind = pView->GetViewFrame()->GetBindings();
- rBind.Invalidate( SID_PASTE );
- }
- }
-}
-
-void SmClipboardChangeListener::AddRemoveListener( BOOL bAdd )
-{
- try
- {
- do {
- Window* pW;
- Reference< XClipboard > xClipboard;
- if( pView && 0 != ( pW = pView->GetEditWindow()) )
- xClipboard = pW->GetClipboard();
- if( !xClipboard.is() )
- break;
-
- Reference< XClipboardNotifier > xClpbrdNtfr( xClipboard, UNO_QUERY );
- if( xClpbrdNtfr.is() )
- {
- Reference< XClipboardListener > xClipEvtLstnr( this );
- if( bAdd )
- xClpbrdNtfr->addClipboardListener( xClipEvtLstnr );
- else
- xClpbrdNtfr->removeClipboardListener( xClipEvtLstnr );
- }
- } while ( FALSE );
- }
- catch( const ::com::sun::star::uno::Exception& )
- {
- }
-}
-
-// ------------------------- SmViewShell ---------------------
-
-void SmViewShell::AddRemoveClipboardListener( BOOL bAdd )
-{
- // AddRemoveListener and ViewDestroyed below should be an
- // atomic operation and must not be 'interrupted' by other code
- const ::vos::OGuard aGuard( Application::GetSolarMutex() );
-
- if( bAdd && !xClipEvtLstnr.is() )
- {
- xClipEvtLstnr = pClipEvtLstnr = new SmClipboardChangeListener( *this );
- pClipEvtLstnr->AddRemoveListener( TRUE );
- }
- else if( !bAdd && xClipEvtLstnr.is() )
- {
- pClipEvtLstnr->AddRemoveListener( FALSE );
- pClipEvtLstnr->ViewDestroyed();
- }
-}
-
-
-
diff --git a/starmath/util/makefile.mk b/starmath/util/makefile.mk
index 86218d98b6f7..978cb6cff40c 100644
--- a/starmath/util/makefile.mk
+++ b/starmath/util/makefile.mk
@@ -57,6 +57,7 @@ SHL1DEF=$(MISC)$/$(SHL1TARGET).def
DEF1NAME= $(SHL1TARGET)
SHL1STDLIBS= \
+ $(SVXCORELIB) \
$(SVXLIB) \
$(SFX2LIB) \
$(XMLOFFLIB) \