update dev300-m58
[ooovba.git] / starmath / source / mathmlimport.cxx
blobbf719d661dada3cf65ef2b207bcf311b1d913c4f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: x $
10 * $Revision: 1.00 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_starmath.hxx"
34 /*todo: Change characters and tcharacters to accumulate the characters together
35 into one string, xml parser hands them to us line by line rather than all in
36 one go*/
38 #include <com/sun/star/xml/sax/XErrorHandler.hpp>
39 #include <com/sun/star/xml/sax/XEntityResolver.hpp>
40 #include <com/sun/star/xml/sax/InputSource.hpp>
41 #include <com/sun/star/xml/sax/XDTDHandler.hpp>
42 #include <com/sun/star/xml/sax/XParser.hpp>
43 #include <com/sun/star/io/XActiveDataSource.hpp>
44 #include <com/sun/star/io/XActiveDataControl.hpp>
45 #include <com/sun/star/document/XDocumentProperties.hpp>
46 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
47 #include <com/sun/star/packages/zip/ZipIOException.hpp>
48 #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
49 #include <com/sun/star/beans/PropertyAttribute.hpp>
50 #include <com/sun/star/container/XNameAccess.hpp>
51 #include <com/sun/star/embed/ElementModes.hpp>
52 #include <com/sun/star/uno/Any.h>
54 #include <rtl/math.hxx>
55 #include <sfx2/frame.hxx>
56 #include <sfx2/docfile.hxx>
57 #include <tools/debug.hxx>
58 #include <tools/urlobj.hxx>
59 #include <svtools/sfxecode.hxx>
60 #include <svtools/saveopt.hxx>
61 #include <svtools/stritem.hxx>
62 #include <svtools/itemprop.hxx>
63 #include <unotools/processfactory.hxx>
64 #include <unotools/streamwrap.hxx>
65 #include <xmloff/xmlnmspe.hxx>
66 #include <xmloff/xmltoken.hxx>
67 #include <xmloff/nmspmap.hxx>
68 #include <xmloff/attrlist.hxx>
69 #include <xmloff/xmluconv.hxx>
70 #include <xmloff/xmlmetai.hxx>
71 #include <osl/mutex.hxx>
72 #include <comphelper/genericpropertyset.hxx>
74 #include <memory>
76 #include "mathmlimport.hxx"
77 #include "mathtype.hxx"
78 #include <starmath.hrc>
79 #include <unomodel.hxx>
80 #include <document.hxx>
81 #include <utility.hxx>
83 using namespace ::com::sun::star::beans;
84 using namespace ::com::sun::star::container;
85 using namespace ::com::sun::star::document;
86 using namespace ::com::sun::star::lang;
87 using namespace ::com::sun::star::uno;
88 using namespace ::com::sun::star;
89 using namespace ::xmloff::token;
91 using ::rtl::OUString;
92 using ::rtl::OUStringBuffer;
94 #define IMPORT_SVC_NAME RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.XMLImportFilter")
96 #undef WANTEXCEPT
98 ////////////////////////////////////////////////////////////
100 ULONG SmXMLImportWrapper::Import(SfxMedium &rMedium)
102 ULONG nError = ERRCODE_SFX_DOLOADFAILED;
104 uno::Reference<lang::XMultiServiceFactory> xServiceFactory(
105 utl::getProcessServiceFactory());
106 DBG_ASSERT(xServiceFactory.is(), "XMLReader::Read: got no service manager");
107 if ( !xServiceFactory.is() )
108 return nError;
110 //Make a model component from our SmModel
111 uno::Reference< lang::XComponent > xModelComp( xModel, uno::UNO_QUERY );
112 DBG_ASSERT( xModelComp.is(), "XMLReader::Read: got no model" );
114 // try to get an XStatusIndicator from the Medium
115 uno::Reference<task::XStatusIndicator> xStatusIndicator;
117 sal_Bool bEmbedded = sal_False;
118 uno::Reference <lang::XUnoTunnel> xTunnel;
119 xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
120 SmModel *pModel = reinterpret_cast<SmModel *>
121 (xTunnel->getSomething(SmModel::getUnoTunnelId()));
123 SmDocShell *pDocShell = pModel ?
124 static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0;
125 if (pDocShell)
127 // if (pDocShell->GetMedium())
129 DBG_ASSERT( pDocShell->GetMedium() == &rMedium,
130 "different SfxMedium found" );
132 SfxItemSet* pSet = rMedium.GetItemSet();
133 if (pSet)
135 const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(
136 pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
137 if (pItem)
138 pItem->GetValue() >>= xStatusIndicator;
142 if ( SFX_CREATE_MODE_EMBEDDED == pDocShell->GetCreateMode() )
143 bEmbedded = sal_True;
146 comphelper::PropertyMapEntry aInfoMap[] =
148 { "PrivateData", sizeof("PrivateData")-1, 0,
149 &::getCppuType( (Reference<XInterface> *)0 ),
150 beans::PropertyAttribute::MAYBEVOID, 0 },
151 { "BaseURI", sizeof("BaseURI")-1, 0,
152 &::getCppuType( (OUString *)0 ),
153 beans::PropertyAttribute::MAYBEVOID, 0 },
154 { "StreamRelPath", sizeof("StreamRelPath")-1, 0,
155 &::getCppuType( (OUString *)0 ),
156 beans::PropertyAttribute::MAYBEVOID, 0 },
157 { "StreamName", sizeof("StreamName")-1, 0,
158 &::getCppuType( (OUString *)0 ),
159 beans::PropertyAttribute::MAYBEVOID, 0 },
160 { NULL, 0, 0, NULL, 0, 0 }
162 uno::Reference< beans::XPropertySet > xInfoSet(
163 comphelper::GenericPropertySet_CreateInstance(
164 new comphelper::PropertySetInfo( aInfoMap ) ) );
166 // Set base URI
167 OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("BaseURI") );
168 xInfoSet->setPropertyValue( sPropName, makeAny( rMedium.GetBaseURL() ) );
170 sal_Int32 nSteps=3;
171 if ( !(rMedium.IsStorage()))
172 nSteps = 1;
174 sal_Int32 nProgressRange(nSteps);
175 if (xStatusIndicator.is())
177 xStatusIndicator->start(String(SmResId(STR_STATSTR_READING)),
178 nProgressRange);
181 nSteps=0;
182 if (xStatusIndicator.is())
183 xStatusIndicator->setValue(nSteps++);
185 if ( rMedium.IsStorage())
187 // TODO/LATER: handle the case of embedded links gracefully
188 if ( bEmbedded ) // && !rMedium.GetStorage()->IsRoot() )
190 OUString aName( RTL_CONSTASCII_USTRINGPARAM( "dummyObjName" ) );
191 if ( rMedium.GetItemSet() )
193 const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
194 rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
195 if ( pDocHierarchItem )
196 aName = pDocHierarchItem->GetValue();
199 if ( aName.getLength() )
201 sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath"));
202 xInfoSet->setPropertyValue( sPropName, makeAny( aName ) );
206 sal_Bool bOASIS = ( SotStorage::GetVersion( rMedium.GetStorage() ) > SOFFICE_FILEFORMAT_60 );
207 if (xStatusIndicator.is())
208 xStatusIndicator->setValue(nSteps++);
210 ULONG nWarn = ReadThroughComponent(
211 rMedium.GetStorage(), xModelComp, "meta.xml", "Meta.xml",
212 xServiceFactory, xInfoSet,
213 (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaImporter"
214 : "com.sun.star.comp.Math.XMLMetaImporter") );
216 if ( nWarn != ERRCODE_IO_BROKENPACKAGE )
218 if (xStatusIndicator.is())
219 xStatusIndicator->setValue(nSteps++);
221 nWarn = ReadThroughComponent(
222 rMedium.GetStorage(), xModelComp, "settings.xml", 0,
223 xServiceFactory, xInfoSet,
224 (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsImporter"
225 : "com.sun.star.comp.Math.XMLSettingsImporter" ) );
227 if ( nWarn != ERRCODE_IO_BROKENPACKAGE )
229 if (xStatusIndicator.is())
230 xStatusIndicator->setValue(nSteps++);
232 nError = ReadThroughComponent(
233 rMedium.GetStorage(), xModelComp, "content.xml", "Content.xml",
234 xServiceFactory, xInfoSet, "com.sun.star.comp.Math.XMLImporter" );
236 else
237 nError = ERRCODE_IO_BROKENPACKAGE;
239 else
240 nError = ERRCODE_IO_BROKENPACKAGE;
242 else
244 Reference<io::XInputStream> xInputStream =
245 new utl::OInputStreamWrapper(rMedium.GetInStream());
247 if (xStatusIndicator.is())
248 xStatusIndicator->setValue(nSteps++);
250 nError = ReadThroughComponent( xInputStream, xModelComp,
251 xServiceFactory, xInfoSet, "com.sun.star.comp.Math.XMLImporter", FALSE );
254 if (xStatusIndicator.is())
255 xStatusIndicator->end();
256 return nError;
260 /// read a component (file + filter version)
261 ULONG SmXMLImportWrapper::ReadThroughComponent(
262 Reference<io::XInputStream> xInputStream,
263 Reference<XComponent> xModelComponent,
264 Reference<lang::XMultiServiceFactory> & rFactory,
265 Reference<beans::XPropertySet> & rPropSet,
266 const sal_Char* pFilterName,
267 sal_Bool bEncrypted )
269 ULONG nError = ERRCODE_SFX_DOLOADFAILED;
270 DBG_ASSERT(xInputStream.is(), "input stream missing");
271 DBG_ASSERT(xModelComponent.is(), "document missing");
272 DBG_ASSERT(rFactory.is(), "factory missing");
273 DBG_ASSERT(NULL != pFilterName,"I need a service name for the component!");
275 // prepare ParserInputSrouce
276 xml::sax::InputSource aParserInput;
277 aParserInput.aInputStream = xInputStream;
279 // get parser
280 Reference< xml::sax::XParser > xParser(
281 rFactory->createInstance(
282 OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
283 UNO_QUERY );
284 DBG_ASSERT( xParser.is(), "Can't create parser" );
285 if ( !xParser.is() )
286 return nError;
288 Sequence<Any> aArgs( 1 );
289 aArgs[0] <<= rPropSet;
291 // get filter
292 Reference< xml::sax::XDocumentHandler > xFilter(
293 rFactory->createInstanceWithArguments(
294 OUString::createFromAscii(pFilterName), aArgs ),
295 UNO_QUERY );
296 DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." );
297 if ( !xFilter.is() )
298 return nError;
300 // connect parser and filter
301 xParser->setDocumentHandler( xFilter );
303 // connect model and filter
304 Reference < XImporter > xImporter( xFilter, UNO_QUERY );
305 xImporter->setTargetDocument( xModelComponent );
307 // finally, parser the stream
310 xParser->parseStream( aParserInput );
312 uno::Reference<lang::XUnoTunnel> xFilterTunnel;
313 xFilterTunnel = uno::Reference<lang::XUnoTunnel>
314 ( xFilter, uno::UNO_QUERY );
315 SmXMLImport *pFilter = reinterpret_cast< SmXMLImport * >(
316 sal::static_int_cast< sal_uIntPtr >(
317 xFilterTunnel->getSomething( SmXMLImport::getUnoTunnelId() )));
318 if ( pFilter && pFilter->GetSuccess() )
319 nError = 0;
321 catch( xml::sax::SAXParseException& )
323 if ( bEncrypted )
324 nError = ERRCODE_SFX_WRONGPASSWORD;
326 catch( xml::sax::SAXException& )
328 if ( bEncrypted )
329 nError = ERRCODE_SFX_WRONGPASSWORD;
331 catch( packages::zip::ZipIOException& )
333 nError = ERRCODE_IO_BROKENPACKAGE;
335 catch( io::IOException& )
339 return nError;
343 ULONG SmXMLImportWrapper::ReadThroughComponent(
344 const uno::Reference< embed::XStorage >& xStorage,
345 Reference<XComponent> xModelComponent,
346 const sal_Char* pStreamName,
347 const sal_Char* pCompatibilityStreamName,
348 Reference<lang::XMultiServiceFactory> & rFactory,
349 Reference<beans::XPropertySet> & rPropSet,
350 const sal_Char* pFilterName )
352 DBG_ASSERT(xStorage.is(), "Need storage!");
353 DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!");
355 // open stream (and set parser input)
356 OUString sStreamName = OUString::createFromAscii(pStreamName);
357 uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY );
358 if ( !xAccess->hasByName(sStreamName) || !xStorage->isStreamElement(sStreamName) )
360 // stream name not found! Then try the compatibility name.
361 // do we even have an alternative name?
362 if ( pCompatibilityStreamName )
363 sStreamName = OUString::createFromAscii(pCompatibilityStreamName);
366 // get input stream
369 uno::Reference < io::XStream > xEventsStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
371 // determine if stream is encrypted or not
372 uno::Reference < beans::XPropertySet > xProps( xEventsStream, uno::UNO_QUERY );
373 Any aAny = xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ) );
374 sal_Bool bEncrypted = sal_False;
375 if ( aAny.getValueType() == ::getBooleanCppuType() )
376 aAny >>= bEncrypted;
378 // set Base URL
379 if ( rPropSet.is() )
381 OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("StreamName") );
382 rPropSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
386 Reference < io::XInputStream > xStream = xEventsStream->getInputStream();
387 return ReadThroughComponent( xStream, xModelComponent, rFactory, rPropSet, pFilterName, bEncrypted );
389 catch ( packages::WrongPasswordException& )
391 return ERRCODE_SFX_WRONGPASSWORD;
393 catch( packages::zip::ZipIOException& )
395 return ERRCODE_IO_BROKENPACKAGE;
397 catch ( uno::Exception& )
401 return ERRCODE_SFX_DOLOADFAILED;
404 ////////////////////////////////////////////////////////////
406 SmXMLImport::SmXMLImport(
407 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
408 sal_uInt16 nImportFlags)
409 : SvXMLImport( xServiceFactory, nImportFlags ),
410 pPresLayoutElemTokenMap(0),
411 pPresLayoutAttrTokenMap(0),
412 pFencedAttrTokenMap(0),
413 pOperatorAttrTokenMap(0),
414 pAnnotationAttrTokenMap(0),
415 pPresElemTokenMap(0),
416 pPresScriptEmptyElemTokenMap(0),
417 pPresTableElemTokenMap(0),
418 pColorTokenMap(0),
419 bSuccess(sal_False)
423 const uno::Sequence< sal_Int8 > & SmXMLImport::getUnoTunnelId() throw()
425 static uno::Sequence< sal_Int8 > * pSeq = 0;
426 if ( !pSeq )
428 osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
429 if ( !pSeq )
431 static uno::Sequence< sal_Int8 > aSeq( 16 );
432 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
433 pSeq = &aSeq;
436 return *pSeq;
439 OUString SAL_CALL SmXMLImport_getImplementationName() throw()
441 return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLImporter" ) );
444 uno::Sequence< OUString > SAL_CALL SmXMLImport_getSupportedServiceNames()
445 throw()
447 const OUString aServiceName( IMPORT_SVC_NAME );
448 const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
449 return aSeq;
452 uno::Reference< uno::XInterface > SAL_CALL SmXMLImport_createInstance(
453 const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
454 throw( uno::Exception )
456 // #110680#
457 // return (cppu::OWeakObject*)new SmXMLImport(IMPORT_ALL);
458 return (cppu::OWeakObject*)new SmXMLImport(rSMgr, IMPORT_ALL);
461 ////////////////////////////////////////////////////////////
463 OUString SAL_CALL SmXMLImportMeta_getImplementationName() throw()
465 return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisMetaImporter" ) );
468 uno::Sequence< OUString > SAL_CALL SmXMLImportMeta_getSupportedServiceNames()
469 throw()
471 const OUString aServiceName( IMPORT_SVC_NAME );
472 const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
473 return aSeq;
476 uno::Reference< uno::XInterface > SAL_CALL SmXMLImportMeta_createInstance(
477 const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
478 throw( uno::Exception )
480 // #110680#
481 // return (cppu::OWeakObject*)new SmXMLImport( IMPORT_META );
482 return (cppu::OWeakObject*)new SmXMLImport( rSMgr, IMPORT_META );
485 ////////////////////////////////////////////////////////////
487 OUString SAL_CALL SmXMLImportSettings_getImplementationName() throw()
489 return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Math.XMLOasisSettingsImporter" ) );
492 uno::Sequence< OUString > SAL_CALL SmXMLImportSettings_getSupportedServiceNames()
493 throw()
495 const OUString aServiceName( IMPORT_SVC_NAME );
496 const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
497 return aSeq;
500 uno::Reference< uno::XInterface > SAL_CALL SmXMLImportSettings_createInstance(
501 const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
502 throw( uno::Exception )
504 // #110680#
505 // return (cppu::OWeakObject*)new SmXMLImport( IMPORT_SETTINGS );
506 return (cppu::OWeakObject*)new SmXMLImport( rSMgr, IMPORT_SETTINGS );
509 ////////////////////////////////////////////////////////////
511 // XServiceInfo
512 // override empty method from parent class
513 rtl::OUString SAL_CALL SmXMLImport::getImplementationName()
514 throw(uno::RuntimeException)
516 OUString aTxt;
517 switch( getImportFlags() )
519 case IMPORT_META:
520 aTxt = SmXMLImportMeta_getImplementationName();
521 break;
522 case IMPORT_SETTINGS:
523 aTxt = SmXMLImportSettings_getImplementationName();
524 break;
525 case IMPORT_ALL:
526 default:
527 aTxt = SmXMLImport_getImplementationName();
528 break;
530 return aTxt;
534 sal_Int64 SAL_CALL SmXMLImport::getSomething(
535 const uno::Sequence< sal_Int8 >&rId )
536 throw(uno::RuntimeException)
538 if ( rId.getLength() == 16 &&
539 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
540 rId.getConstArray(), 16 ) )
541 return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this));
543 return SvXMLImport::getSomething( rId );
546 void SmXMLImport::endDocument(void)
547 throw(xml::sax::SAXException, uno::RuntimeException)
549 //Set the resulted tree into the SmDocShell where it belongs
550 SmNode *pTree;
551 if (NULL != (pTree = GetTree()))
553 uno::Reference <frame::XModel> xModel = GetModel();
554 uno::Reference <lang::XUnoTunnel> xTunnel;
555 xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
556 SmModel *pModel = reinterpret_cast<SmModel *>
557 (xTunnel->getSomething(SmModel::getUnoTunnelId()));
559 if (pModel)
561 SmDocShell *pDocShell =
562 static_cast<SmDocShell*>(pModel->GetObjectShell());
563 pDocShell->SetFormulaTree(pTree);
564 if (0 == aText.Len()) //If we picked up no annotation text
566 //Make up some editable text
567 aText = pDocShell->GetText();
568 pTree->CreateTextFromNode(aText);
569 aText.EraseTrailingChars();
570 if ((aText.GetChar(0) == '{') &&
571 (aText.GetChar(aText.Len()-1) == '}'))
573 aText.Erase(0,1);
574 aText.Erase(aText.Len()-1,1);
577 pDocShell->SetText( String() );
579 // Convert symbol names
580 SmParser &rParser = pDocShell->GetParser();
581 BOOL bVal = rParser.IsImportSymbolNames();
582 rParser.SetImportSymbolNames( TRUE );
583 SmNode *pTmpTree = rParser.Parse( aText );
584 aText = rParser.GetText();
585 delete pTmpTree;
586 rParser.SetImportSymbolNames( bVal );
588 pDocShell->SetText( aText );
590 DBG_ASSERT(pModel,"So there *was* a uno problem after all");
592 bSuccess = sal_True;
595 SvXMLImport::endDocument();
598 ////////////////////////////////////////////////////////////
600 class SmXMLImportContext: public SvXMLImportContext
602 public:
603 SmXMLImportContext( SmXMLImport &rImport, sal_uInt16 nPrfx,
604 const OUString& rLName)
605 : SvXMLImportContext(rImport, nPrfx, rLName) {}
607 const SmXMLImport& GetSmImport() const
609 return (const SmXMLImport&)GetImport();
612 SmXMLImport& GetSmImport()
614 return (SmXMLImport&)GetImport();
617 virtual void TCharacters(const OUString & /*rChars*/);
618 virtual void Characters(const OUString &rChars);
619 virtual SvXMLImportContext *CreateChildContext(sal_uInt16 /*nPrefix*/, const OUString& /*rLocalName*/, const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/);
622 void SmXMLImportContext::TCharacters(const OUString & /*rChars*/)
626 void SmXMLImportContext::Characters(const OUString &rChars)
629 Whitespace occurring within the content of token elements is "trimmed"
630 from the ends (i.e. all whitespace at the beginning and end of the
631 content is removed), and "collapsed" internally (i.e. each sequence of
632 1 or more whitespace characters is replaced with one blank character).
634 //collapsing not done yet!
635 const OUString &rChars2 = rChars.trim();
636 if (rChars2.getLength())
637 TCharacters(rChars2/*.collapse()*/);
640 SvXMLImportContext * SmXMLImportContext::CreateChildContext(sal_uInt16 /*nPrefix*/,
641 const OUString& /*rLocalName*/,
642 const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/)
644 return 0;
647 ////////////////////////////////////////////////////////////
649 struct SmXMLContext_Helper
651 sal_Int8 nIsBold;
652 sal_Int8 nIsItalic;
653 double nFontSize;
654 sal_Bool bFontNodeNeeded;
655 OUString sFontFamily;
656 OUString sColor;
658 SmXMLImportContext rContext;
660 SmXMLContext_Helper(SmXMLImportContext &rImport) :
661 nIsBold(-1), nIsItalic(-1), nFontSize(0.0), rContext(rImport) {}
663 void RetrieveAttrs(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
664 void ApplyAttrs();
667 void SmXMLContext_Helper::RetrieveAttrs(const uno::Reference<
668 xml::sax::XAttributeList > & xAttrList )
670 sal_Int8 nOldIsBold=nIsBold;
671 sal_Int8 nOldIsItalic=nIsItalic;
672 double nOldFontSize=nFontSize;
673 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
674 OUString sOldFontFamily = sFontFamily;
675 for (sal_Int16 i=0;i<nAttrCount;i++)
677 OUString sAttrName = xAttrList->getNameByIndex(i);
678 OUString aLocalName;
679 sal_uInt16 nPrefix = rContext.GetSmImport().GetNamespaceMap().
680 GetKeyByAttrName(sAttrName,&aLocalName);
681 OUString sValue = xAttrList->getValueByIndex(i);
682 const SvXMLTokenMap &rAttrTokenMap =
683 rContext.GetSmImport().GetPresLayoutAttrTokenMap();
684 switch(rAttrTokenMap.Get(nPrefix,aLocalName))
686 case XML_TOK_FONTWEIGHT:
687 nIsBold = sValue.equals(GetXMLToken(XML_BOLD));
688 break;
689 case XML_TOK_FONTSTYLE:
690 nIsItalic = sValue.equals(GetXMLToken(XML_ITALIC));
691 break;
692 case XML_TOK_FONTSIZE:
693 SvXMLUnitConverter::convertDouble(nFontSize,sValue);
694 rContext.GetSmImport().GetMM100UnitConverter().
695 setXMLMeasureUnit(MAP_POINT);
696 if (-1 == sValue.indexOf(GetXMLToken(XML_UNIT_PT)))
698 if (-1 == sValue.indexOf('%'))
699 nFontSize=0.0;
700 else
702 rContext.GetSmImport().GetMM100UnitConverter().
703 setXMLMeasureUnit(MAP_RELATIVE);
706 break;
707 case XML_TOK_FONTFAMILY:
708 sFontFamily = sValue;
709 break;
710 case XML_TOK_COLOR:
711 sColor = sValue;
712 break;
713 default:
714 break;
718 if ((nOldIsBold!=nIsBold) || (nOldIsItalic!=nIsItalic) ||
719 (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily)
720 || sColor.getLength())
721 bFontNodeNeeded=sal_True;
722 else
723 bFontNodeNeeded=sal_False;
726 void SmXMLContext_Helper::ApplyAttrs()
728 SmNodeStack &rNodeStack = rContext.GetSmImport().GetNodeStack();
730 if (bFontNodeNeeded)
732 SmToken aToken;
733 aToken.cMathChar = '\0';
734 aToken.nGroup = 0;
735 aToken.nLevel = 5;
737 if (nIsBold != -1)
739 if (nIsBold)
740 aToken.eType = TBOLD;
741 else
742 aToken.eType = TNBOLD;
743 SmStructureNode *pFontNode = static_cast<SmStructureNode *>
744 (new SmFontNode(aToken));
745 pFontNode->SetSubNodes(0,rNodeStack.Pop());
746 rNodeStack.Push(pFontNode);
748 if (nIsItalic != -1)
750 if (nIsItalic)
751 aToken.eType = TITALIC;
752 else
753 aToken.eType = TNITALIC;
754 SmStructureNode *pFontNode = static_cast<SmStructureNode *>
755 (new SmFontNode(aToken));
756 pFontNode->SetSubNodes(0,rNodeStack.Pop());
757 rNodeStack.Push(pFontNode);
759 if (nFontSize != 0.0)
761 aToken.eType = TSIZE;
762 SmFontNode *pFontNode = new SmFontNode(aToken);
764 if (MAP_RELATIVE == rContext.GetSmImport().GetMM100UnitConverter().
765 getXMLMeasureUnit())
767 if (nFontSize < 100.00)
768 pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
769 FNTSIZ_DIVIDE);
770 else
771 pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
772 FNTSIZ_MULTIPLY);
774 else
775 pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
777 pFontNode->SetSubNodes(0,rNodeStack.Pop());
778 rNodeStack.Push(pFontNode);
780 if (sFontFamily.getLength())
782 if (sFontFamily.equalsIgnoreAsciiCase(GetXMLToken(XML_FIXED)))
783 aToken.eType = TFIXED;
784 else if (sFontFamily.equalsIgnoreAsciiCase(OUString(
785 RTL_CONSTASCII_USTRINGPARAM("sans"))))
786 aToken.eType = TSANS;
787 else if (sFontFamily.equalsIgnoreAsciiCase(OUString(
788 RTL_CONSTASCII_USTRINGPARAM("serif"))))
789 aToken.eType = TSERIF;
790 else //Just give up, we need to extend our font mechanism to be
791 //more general
792 return;
794 aToken.aText = sFontFamily;
795 SmFontNode *pFontNode = new SmFontNode(aToken);
796 pFontNode->SetSubNodes(0,rNodeStack.Pop());
797 rNodeStack.Push(pFontNode);
799 if (sColor.getLength())
801 //Again we can only handle a small set of colours in
802 //StarMath for now.
803 const SvXMLTokenMap& rTokenMap =
804 rContext.GetSmImport().GetColorTokenMap();
805 aToken.eType = static_cast<SmTokenType>(rTokenMap.Get(
806 XML_NAMESPACE_MATH, sColor));
807 if (aToken.eType != -1)
809 SmFontNode *pFontNode = new SmFontNode(aToken);
810 pFontNode->SetSubNodes(0,rNodeStack.Pop());
811 rNodeStack.Push(pFontNode);
818 ////////////////////////////////////////////////////////////
820 class SmXMLDocContext_Impl : public SmXMLImportContext
822 public:
823 SmXMLDocContext_Impl( SmXMLImport &rImport, sal_uInt16 nPrfx,
824 const OUString& rLName)
825 : SmXMLImportContext(rImport,nPrfx,rLName) {}
827 virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList);
829 void EndElement();
832 ////////////////////////////////////////////////////////////
834 /*avert thy gaze from the proginator*/
835 class SmXMLRowContext_Impl : public SmXMLDocContext_Impl
837 protected:
838 ULONG nElementCount;
840 public:
841 SmXMLRowContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
842 const OUString& rLName)
843 : SmXMLDocContext_Impl(rImport,nPrefix,rLName)
844 { nElementCount = GetSmImport().GetNodeStack().Count(); }
846 virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList);
848 SvXMLImportContext *StrictCreateChildContext(sal_uInt16 nPrefix,
849 const OUString& rLocalName,
850 const uno::Reference< xml::sax::XAttributeList > &xAttrList);
852 void EndElement();
855 ////////////////////////////////////////////////////////////
857 class SmXMLFracContext_Impl : public SmXMLRowContext_Impl
859 public:
860 SmXMLFracContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
861 const OUString& rLName)
862 : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
864 void EndElement();
867 ////////////////////////////////////////////////////////////
869 class SmXMLSqrtContext_Impl : public SmXMLRowContext_Impl
871 public:
872 SmXMLSqrtContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
873 const OUString& rLName)
874 : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
876 void EndElement();
879 ////////////////////////////////////////////////////////////
881 class SmXMLRootContext_Impl : public SmXMLRowContext_Impl
883 public:
884 SmXMLRootContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
885 const OUString& rLName)
886 : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
888 void EndElement();
891 ////////////////////////////////////////////////////////////
893 class SmXMLStyleContext_Impl : public SmXMLRowContext_Impl
895 protected:
896 SmXMLContext_Helper aStyleHelper;
898 public:
899 /*Right now the style tag is completely ignored*/
900 SmXMLStyleContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
901 const OUString& rLName) : SmXMLRowContext_Impl(rImport,nPrefix,rLName),
902 aStyleHelper(*this) {}
904 void EndElement();
905 void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
908 void SmXMLStyleContext_Impl::StartElement(const uno::Reference<
909 xml::sax::XAttributeList > & xAttrList )
911 #if 1
912 aStyleHelper.RetrieveAttrs(xAttrList);
913 #else
914 sal_Int8 nOldIsBold=nIsBold;
915 sal_Int8 nOldIsItalic=nIsItalic;
916 double nOldFontSize=nFontSize;
917 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
918 OUString sOldFontFamily = sFontFamily;
919 for (sal_Int16 i=0;i<nAttrCount;i++)
921 OUString sAttrName = xAttrList->getNameByIndex(i);
922 OUString aLocalName;
923 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
924 GetKeyByAttrName(sAttrName,&aLocalName);
925 OUString sValue = xAttrList->getValueByIndex(i);
926 const SvXMLTokenMap &rAttrTokenMap =
927 GetSmImport().GetPresLayoutAttrTokenMap();
928 switch(rAttrTokenMap.Get(nPrefix,aLocalName))
930 case XML_TOK_FONTWEIGHT:
931 nIsBold = sValue.equals(GetXMLToken(XML_BOLD));
932 break;
933 case XML_TOK_FONTSTYLE:
934 nIsItalic = sValue.equals(GetXMLToken(XML_ITALIC));
935 break;
936 case XML_TOK_FONTSIZE:
937 SvXMLUnitConverter::convertDouble(nFontSize,sValue);
938 GetSmImport().GetMM100UnitConverter().
939 setXMLMeasureUnit(MAP_POINT);
940 if (-1 == sValue.indexOf(GetXMLToken(XML_UNIT_PT)))
941 if (-1 == sValue.indexOf('%'))
942 nFontSize=0.0;
943 else
945 GetSmImport().GetMM100UnitConverter().
946 setXMLMeasureUnit(MAP_RELATIVE);
948 break;
949 case XML_TOK_FONTFAMILY:
950 sFontFamily = sValue;
951 break;
952 case XML_TOK_COLOR:
953 sColor = sValue;
954 break;
955 default:
956 break;
960 if ((nOldIsBold!=nIsBold) || (nOldIsItalic!=nIsItalic) ||
961 (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily)
962 || sColor.getLength())
963 bFontNodeNeeded=sal_True;
964 else
965 bFontNodeNeeded=sal_False;
966 #endif
970 void SmXMLStyleContext_Impl::EndElement()
973 <mstyle> accepts any number of arguments; if this number is not 1, its
974 contents are treated as a single "inferred <mrow>" containing its
975 arguments
977 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
978 if (rNodeStack.Count() - nElementCount > 1)
979 SmXMLRowContext_Impl::EndElement();
980 #if 1
981 aStyleHelper.ApplyAttrs();
982 #else
983 if (bFontNodeNeeded)
985 SmToken aToken;
986 aToken.cMathChar = '\0';
987 aToken.nGroup = 0;
988 aToken.nLevel = 5;
990 if (nIsBold != -1)
992 if (nIsBold)
993 aToken.eType = TBOLD;
994 else
995 aToken.eType = TNBOLD;
996 SmStructureNode *pFontNode = static_cast<SmStructureNode *>
997 (new SmFontNode(aToken));
998 pFontNode->SetSubNodes(0,rNodeStack.Pop());
999 rNodeStack.Push(pFontNode);
1001 if (nIsItalic != -1)
1003 if (nIsItalic)
1004 aToken.eType = TITALIC;
1005 else
1006 aToken.eType = TNITALIC;
1007 SmStructureNode *pFontNode = static_cast<SmStructureNode *>
1008 (new SmFontNode(aToken));
1009 pFontNode->SetSubNodes(0,rNodeStack.Pop());
1010 rNodeStack.Push(pFontNode);
1012 if (nFontSize != 0.0)
1014 aToken.eType = TSIZE;
1015 SmFontNode *pFontNode = new SmFontNode(aToken);
1017 if (MAP_RELATIVE == GetSmImport().GetMM100UnitConverter().
1018 getXMLMeasureUnit())
1020 if (nFontSize < 100.00)
1021 pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
1022 FNTSIZ_DIVIDE);
1023 else
1024 pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
1025 FNTSIZ_MULTIPLY);
1027 else
1028 pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
1030 pFontNode->SetSubNodes(0,rNodeStack.Pop());
1031 rNodeStack.Push(pFontNode);
1033 if (sFontFamily.getLength())
1035 if (sFontFamily.equalsIgnoreCase(GetXMLToken(XML_FIXED)))
1036 aToken.eType = TFIXED;
1037 else if (sFontFamily.equalsIgnoreCase(OUString(
1038 RTL_CONSTASCII_USTRINGPARAM("sans"))))
1039 aToken.eType = TSANS;
1040 else if (sFontFamily.equalsIgnoreCase(OUString(
1041 RTL_CONSTASCII_USTRINGPARAM("serif"))))
1042 aToken.eType = TSERIF;
1043 else //Just give up, we need to extend our font mechanism to be
1044 //more general
1045 return;
1047 aToken.aText = sFontFamily;
1048 SmFontNode *pFontNode = new SmFontNode(aToken);
1049 pFontNode->SetSubNodes(0,rNodeStack.Pop());
1050 rNodeStack.Push(pFontNode);
1052 if (sColor.getLength())
1054 //Again we can only handle a small set of colours in
1055 //StarMath for now.
1056 const SvXMLTokenMap& rTokenMap =
1057 GetSmImport().GetColorTokenMap();
1058 aToken.eType = static_cast<SmTokenType>(rTokenMap.Get(
1059 XML_NAMESPACE_MATH, sColor));
1060 if (aToken.eType != -1)
1062 SmFontNode *pFontNode = new SmFontNode(aToken);
1063 pFontNode->SetSubNodes(0,rNodeStack.Pop());
1064 rNodeStack.Push(pFontNode);
1069 #endif
1072 ////////////////////////////////////////////////////////////
1074 class SmXMLPaddedContext_Impl : public SmXMLRowContext_Impl
1076 public:
1077 /*Right now the style tag is completely ignored*/
1078 SmXMLPaddedContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1079 const OUString& rLName)
1080 : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
1082 void EndElement();
1085 void SmXMLPaddedContext_Impl::EndElement()
1088 <mpadded> accepts any number of arguments; if this number is not 1, its
1089 contents are treated as a single "inferred <mrow>" containing its
1090 arguments
1092 if (GetSmImport().GetNodeStack().Count() - nElementCount > 1)
1093 SmXMLRowContext_Impl::EndElement();
1096 ////////////////////////////////////////////////////////////
1098 class SmXMLPhantomContext_Impl : public SmXMLRowContext_Impl
1100 public:
1101 /*Right now the style tag is completely ignored*/
1102 SmXMLPhantomContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1103 const OUString& rLName)
1104 : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
1106 void EndElement();
1109 void SmXMLPhantomContext_Impl::EndElement()
1112 <mphantom> accepts any number of arguments; if this number is not 1, its
1113 contents are treated as a single "inferred <mrow>" containing its
1114 arguments
1116 if (GetSmImport().GetNodeStack().Count() - nElementCount > 1)
1117 SmXMLRowContext_Impl::EndElement();
1119 SmToken aToken;
1120 aToken.cMathChar = '\0';
1121 aToken.nGroup = 0;
1122 aToken.nLevel = 5;
1123 aToken.eType = TPHANTOM;
1125 SmStructureNode *pPhantom = static_cast<SmStructureNode *>
1126 (new SmFontNode(aToken));
1127 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
1128 pPhantom->SetSubNodes(0,rNodeStack.Pop());
1129 rNodeStack.Push(pPhantom);
1132 ////////////////////////////////////////////////////////////
1134 class SmXMLFencedContext_Impl : public SmXMLRowContext_Impl
1136 protected:
1137 sal_Unicode cBegin;
1138 sal_Unicode cEnd;
1140 public:
1141 SmXMLFencedContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1142 const OUString& rLName)
1143 : SmXMLRowContext_Impl(rImport,nPrefix,rLName),
1144 cBegin('('), cEnd(')') {}
1146 void StartElement(const uno::Reference< xml::sax::XAttributeList > & xAttrList );
1147 void EndElement();
1151 void SmXMLFencedContext_Impl::StartElement(const uno::Reference<
1152 xml::sax::XAttributeList > & xAttrList )
1154 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1155 for (sal_Int16 i=0;i<nAttrCount;i++)
1157 OUString sAttrName = xAttrList->getNameByIndex(i);
1158 OUString aLocalName;
1159 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
1160 GetKeyByAttrName(sAttrName,&aLocalName);
1161 OUString sValue = xAttrList->getValueByIndex(i);
1162 const SvXMLTokenMap &rAttrTokenMap =
1163 GetSmImport().GetFencedAttrTokenMap();
1164 switch(rAttrTokenMap.Get(nPrefix,aLocalName))
1166 //temp, starmath cannot handle multichar brackets (I think)
1167 case XML_TOK_OPEN:
1168 cBegin = sValue[0];
1169 break;
1170 case XML_TOK_CLOSE:
1171 cEnd = sValue[0];
1172 break;
1173 default:
1174 /*Go to superclass*/
1175 break;
1181 void SmXMLFencedContext_Impl::EndElement()
1183 SmToken aToken;
1184 aToken.cMathChar = '\0';
1185 aToken.nGroup = 0;
1186 aToken.aText = ',';
1187 aToken.eType = TLEFT;
1188 aToken.nLevel = 5;
1190 aToken.eType = TLPARENT;
1191 aToken.cMathChar = cBegin;
1192 SmStructureNode *pSNode = new SmBraceNode(aToken);
1193 SmNode *pLeft = new SmMathSymbolNode(aToken);
1195 aToken.cMathChar = cEnd;
1196 aToken.eType = TRPARENT;
1197 SmNode *pRight = new SmMathSymbolNode(aToken);
1199 SmNodeArray aRelationArray;
1200 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
1202 aToken.cMathChar = '\0';
1203 aToken.aText = ',';
1204 aToken.eType = TIDENT;
1206 ULONG i = rNodeStack.Count() - nElementCount;
1207 if (rNodeStack.Count() - nElementCount > 1)
1208 i += rNodeStack.Count() - 1 - nElementCount;
1209 aRelationArray.resize(i);
1210 while (rNodeStack.Count() > nElementCount)
1212 aRelationArray[--i] = rNodeStack.Pop();
1213 if (i > 1 && rNodeStack.Count() > 1)
1214 aRelationArray[--i] = new SmGlyphSpecialNode(aToken);
1217 SmToken aDummy;
1218 SmStructureNode *pBody = new SmExpressionNode(aDummy);
1219 pBody->SetSubNodes(aRelationArray);
1222 pSNode->SetSubNodes(pLeft,pBody,pRight);
1223 pSNode->SetScaleMode(SCALE_HEIGHT);
1224 GetSmImport().GetNodeStack().Push(pSNode);
1228 ////////////////////////////////////////////////////////////
1230 class SmXMLErrorContext_Impl : public SmXMLRowContext_Impl
1232 public:
1233 SmXMLErrorContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1234 const OUString& rLName)
1235 : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
1237 void EndElement();
1240 void SmXMLErrorContext_Impl::EndElement()
1242 /*Right now the error tag is completely ignored, what
1243 can I do with it in starmath, ?, maybe we need a
1244 report window ourselves, do a test for validity of
1245 the xml input, use merrors, and then generate
1246 the markup inside the merror with a big red colour
1247 of something. For now just throw them all away.
1249 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
1250 while (rNodeStack.Count() > nElementCount)
1252 SmNode *pNode = rNodeStack.Pop();
1253 delete pNode;
1257 ////////////////////////////////////////////////////////////
1259 class SmXMLNumberContext_Impl : public SmXMLImportContext
1261 protected:
1262 SmToken aToken;
1264 public:
1265 SmXMLNumberContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1266 const OUString& rLName)
1267 : SmXMLImportContext(rImport,nPrefix,rLName)
1269 aToken.cMathChar = '\0';
1270 aToken.nGroup = 0;
1271 aToken.nLevel = 5;
1272 aToken.eType = TNUMBER;
1275 virtual void TCharacters(const OUString &rChars);
1277 void EndElement();
1280 void SmXMLNumberContext_Impl::TCharacters(const OUString &rChars)
1282 aToken.aText = rChars;
1285 void SmXMLNumberContext_Impl::EndElement()
1287 GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_NUMBER));
1290 ////////////////////////////////////////////////////////////
1292 class SmXMLAnnotationContext_Impl : public SmXMLImportContext
1294 sal_Bool bIsStarMath;
1296 public:
1297 SmXMLAnnotationContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1298 const OUString& rLName)
1299 : SmXMLImportContext(rImport,nPrefix,rLName), bIsStarMath(sal_False) {}
1301 virtual void Characters(const OUString &rChars);
1303 void StartElement(const uno::Reference<xml::sax::XAttributeList > & xAttrList );
1306 void SmXMLAnnotationContext_Impl::StartElement(const uno::Reference<
1307 xml::sax::XAttributeList > & xAttrList )
1309 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1310 for (sal_Int16 i=0;i<nAttrCount;i++)
1312 OUString sAttrName = xAttrList->getNameByIndex(i);
1313 OUString aLocalName;
1314 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
1315 GetKeyByAttrName(sAttrName,&aLocalName);
1317 OUString sValue = xAttrList->getValueByIndex(i);
1318 const SvXMLTokenMap &rAttrTokenMap =
1319 GetSmImport().GetAnnotationAttrTokenMap();
1320 switch(rAttrTokenMap.Get(nPrefix,aLocalName))
1322 case XML_TOK_ENCODING:
1323 bIsStarMath= sValue.equals(
1324 OUString(RTL_CONSTASCII_USTRINGPARAM("StarMath 5.0")));
1325 break;
1326 default:
1327 break;
1332 void SmXMLAnnotationContext_Impl::Characters(const OUString &rChars)
1334 if (bIsStarMath)
1335 GetSmImport().GetText().Append(String(rChars));
1338 ////////////////////////////////////////////////////////////
1340 class SmXMLTextContext_Impl : public SmXMLImportContext
1342 protected:
1343 SmToken aToken;
1345 public:
1346 SmXMLTextContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1347 const OUString& rLName)
1348 : SmXMLImportContext(rImport,nPrefix,rLName)
1350 aToken.cMathChar = '\0';
1351 aToken.nGroup = 0;
1352 aToken.nLevel = 5;
1353 aToken.eType = TTEXT;
1356 virtual void TCharacters(const OUString &rChars);
1358 void EndElement();
1361 void SmXMLTextContext_Impl::TCharacters(const OUString &rChars)
1363 aToken.aText = rChars;
1366 void SmXMLTextContext_Impl::EndElement()
1368 GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_TEXT));
1371 ////////////////////////////////////////////////////////////
1373 class SmXMLStringContext_Impl : public SmXMLImportContext
1375 protected:
1376 SmToken aToken;
1378 public:
1379 SmXMLStringContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1380 const OUString& rLName)
1381 : SmXMLImportContext(rImport,nPrefix,rLName)
1383 aToken.cMathChar = '\0';
1384 aToken.nGroup = 0;
1385 aToken.nLevel = 5;
1386 aToken.eType = TTEXT;
1389 virtual void TCharacters(const OUString &rChars);
1391 void EndElement();
1394 void SmXMLStringContext_Impl::TCharacters(const OUString &rChars)
1397 The content of <ms> elements should be rendered with visible "escaping" of
1398 certain characters in the content, including at least "double quote"
1399 itself, and preferably whitespace other than individual blanks. The intent
1400 is for the viewer to see that the expression is a string literal, and to
1401 see exactly which characters form its content. For example, <ms>double
1402 quote is "</ms> might be rendered as "double quote is \"".
1404 Obviously this isn't fully done here.
1406 aToken.aText.Erase();
1407 aToken.aText += '\"';
1408 aToken.aText += String(rChars);
1409 aToken.aText += '\"';
1412 void SmXMLStringContext_Impl::EndElement()
1414 GetSmImport().GetNodeStack().Push(new SmTextNode(aToken,FNT_FIXED));
1417 ////////////////////////////////////////////////////////////
1419 class SmXMLIdentifierContext_Impl : public SmXMLImportContext
1421 protected:
1422 SmXMLContext_Helper aStyleHelper;
1423 SmToken aToken;
1425 public:
1426 SmXMLIdentifierContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1427 const OUString& rLName)
1428 : SmXMLImportContext(rImport,nPrefix,rLName),aStyleHelper(*this)
1430 aToken.cMathChar = '\0';
1431 aToken.nGroup = 0;
1432 aToken.nLevel = 5;
1433 aToken.eType = TIDENT;
1436 void TCharacters(const OUString &rChars);
1437 void StartElement(const uno::Reference< xml::sax::XAttributeList > & xAttrList )
1439 aStyleHelper.RetrieveAttrs(xAttrList);
1441 void EndElement();
1444 void SmXMLIdentifierContext_Impl::EndElement()
1446 SmTextNode *pNode = 0;
1447 //we will handle identifier italic/normal here instead of with a standalone
1448 //font node
1449 if (((aStyleHelper.nIsItalic == -1) && (aToken.aText.Len() > 1))
1450 || ((aStyleHelper.nIsItalic == 0) && (aToken.aText.Len() == 1)))
1452 pNode = new SmTextNode(aToken,FNT_FUNCTION);
1453 pNode->GetFont().SetItalic(ITALIC_NONE);
1454 aStyleHelper.nIsItalic = -1;
1456 else
1457 pNode = new SmTextNode(aToken,FNT_VARIABLE);
1458 if (aStyleHelper.bFontNodeNeeded && aStyleHelper.nIsItalic != -1)
1460 if (aStyleHelper.nIsItalic)
1461 pNode->GetFont().SetItalic(ITALIC_NORMAL);
1462 else
1463 pNode->GetFont().SetItalic(ITALIC_NONE);
1466 if ((-1!=aStyleHelper.nIsBold) || (0.0!=aStyleHelper.nFontSize) ||
1467 (aStyleHelper.sFontFamily.getLength()) ||
1468 aStyleHelper.sColor.getLength())
1469 aStyleHelper.bFontNodeNeeded=sal_True;
1470 else
1471 aStyleHelper.bFontNodeNeeded=sal_False;
1472 if (aStyleHelper.bFontNodeNeeded)
1473 aStyleHelper.ApplyAttrs();
1474 GetSmImport().GetNodeStack().Push(pNode);
1477 void SmXMLIdentifierContext_Impl::TCharacters(const OUString &rChars)
1479 aToken.aText = rChars;
1482 ////////////////////////////////////////////////////////////
1484 class SmXMLOperatorContext_Impl : public SmXMLImportContext
1486 sal_Bool bIsStretchy;
1488 protected:
1489 SmToken aToken;
1491 public:
1492 SmXMLOperatorContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1493 const OUString& rLName)
1494 : SmXMLImportContext(rImport,nPrefix,rLName), bIsStretchy(sal_False)
1496 aToken.nGroup = 0;
1497 aToken.eType = TSPECIAL;
1498 aToken.nLevel = 5;
1501 void TCharacters(const OUString &rChars);
1502 void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
1503 void EndElement();
1506 void SmXMLOperatorContext_Impl::TCharacters(const OUString &rChars)
1508 aToken.cMathChar = rChars[0];
1511 void SmXMLOperatorContext_Impl::EndElement()
1513 SmMathSymbolNode *pNode = new SmMathSymbolNode(aToken);
1514 //For stretchy scaling the scaling must be retrieved from this node
1515 //and applied to the expression itself so as to get the expression
1516 //to scale the operator to the height of the expression itself
1517 if (bIsStretchy)
1518 pNode->SetScaleMode(SCALE_HEIGHT);
1519 GetSmImport().GetNodeStack().Push(pNode);
1524 void SmXMLOperatorContext_Impl::StartElement(const uno::Reference<
1525 xml::sax::XAttributeList > & xAttrList )
1527 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1528 for (sal_Int16 i=0;i<nAttrCount;i++)
1530 OUString sAttrName = xAttrList->getNameByIndex(i);
1531 OUString aLocalName;
1532 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
1533 GetKeyByAttrName(sAttrName,&aLocalName);
1535 OUString sValue = xAttrList->getValueByIndex(i);
1536 const SvXMLTokenMap &rAttrTokenMap =
1537 GetSmImport().GetOperatorAttrTokenMap();
1538 switch(rAttrTokenMap.Get(nPrefix,aLocalName))
1540 case XML_TOK_STRETCHY:
1541 bIsStretchy = sValue.equals(
1542 GetXMLToken(XML_TRUE));
1543 break;
1544 default:
1545 break;
1551 ////////////////////////////////////////////////////////////
1553 class SmXMLSpaceContext_Impl : public SmXMLImportContext
1555 public:
1556 SmXMLSpaceContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1557 const OUString& rLName)
1558 : SmXMLImportContext(rImport,nPrefix,rLName) {}
1560 void StartElement(const uno::Reference< xml::sax::XAttributeList >& xAttrList );
1563 void SmXMLSpaceContext_Impl::StartElement(
1564 const uno::Reference<xml::sax::XAttributeList > & /*xAttrList*/ )
1566 SmToken aToken;
1567 aToken.cMathChar = '\0';
1568 aToken.nGroup = 0;
1569 aToken.eType = TBLANK;
1570 aToken.nLevel = 5;
1571 SmBlankNode *pBlank = new SmBlankNode(aToken);
1572 pBlank->IncreaseBy(aToken);
1573 GetSmImport().GetNodeStack().Push(pBlank);
1576 ////////////////////////////////////////////////////////////
1578 class SmXMLSubContext_Impl : public SmXMLRowContext_Impl
1580 protected:
1581 void GenericEndElement(SmTokenType eType,SmSubSup aSubSup);
1583 public:
1584 SmXMLSubContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1585 const OUString& rLName)
1586 : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
1588 void EndElement()
1590 GenericEndElement(TRSUB,RSUB);
1595 void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup eSubSup)
1597 /*The <msub> element requires exactly 2 arguments.*/
1598 DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
1599 "Sub has not two arguments");
1600 SmToken aToken;
1601 aToken.cMathChar = '\0';
1602 aToken.nGroup = 0;
1603 aToken.nLevel = 0;
1604 aToken.eType = eType;
1605 SmSubSupNode *pNode = new SmSubSupNode(aToken);
1606 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
1608 // initialize subnodes array
1609 SmNodeArray aSubNodes;
1610 aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
1611 for (ULONG i = 1; i < aSubNodes.size(); i++)
1612 aSubNodes[i] = NULL;
1614 aSubNodes[eSubSup+1] = rNodeStack.Pop();
1615 aSubNodes[0] = rNodeStack.Pop();
1616 pNode->SetSubNodes(aSubNodes);
1617 rNodeStack.Push(pNode);
1620 ////////////////////////////////////////////////////////////
1622 class SmXMLSupContext_Impl : public SmXMLSubContext_Impl
1624 public:
1625 SmXMLSupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1626 const OUString& rLName)
1627 : SmXMLSubContext_Impl(rImport,nPrefix,rLName) {}
1629 void EndElement()
1631 GenericEndElement(TRSUP,RSUP);
1635 ////////////////////////////////////////////////////////////
1637 class SmXMLSubSupContext_Impl : public SmXMLRowContext_Impl
1639 protected:
1640 void GenericEndElement(SmTokenType eType, SmSubSup aSub,SmSubSup aSup);
1642 public:
1643 SmXMLSubSupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1644 const OUString& rLName)
1645 : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
1647 void EndElement()
1649 GenericEndElement(TRSUB,RSUB,RSUP);
1653 void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType,
1654 SmSubSup aSub,SmSubSup aSup)
1656 /*The <msub> element requires exactly 3 arguments.*/
1657 DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 3,
1658 "SubSup has not three arguments");
1660 SmToken aToken;
1661 aToken.cMathChar = '\0';
1662 aToken.nGroup = 0;
1663 aToken.nLevel = 0;
1664 aToken.eType = eType;
1665 SmSubSupNode *pNode = new SmSubSupNode(aToken);
1666 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
1668 // initialize subnodes array
1669 SmNodeArray aSubNodes;
1670 aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
1671 for (ULONG i = 1; i < aSubNodes.size(); i++)
1672 aSubNodes[i] = NULL;
1674 aSubNodes[aSup+1] = rNodeStack.Pop();
1675 aSubNodes[aSub+1] = rNodeStack.Pop();
1676 aSubNodes[0] = rNodeStack.Pop();
1677 pNode->SetSubNodes(aSubNodes);
1678 rNodeStack.Push(pNode);
1681 ////////////////////////////////////////////////////////////
1683 class SmXMLUnderContext_Impl : public SmXMLSubContext_Impl
1685 protected:
1686 sal_Int16 nAttrCount;
1688 public:
1689 SmXMLUnderContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1690 const OUString& rLName)
1691 : SmXMLSubContext_Impl(rImport,nPrefix,rLName) {}
1693 void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
1694 void EndElement();
1695 void HandleAccent();
1698 void SmXMLUnderContext_Impl::StartElement(const uno::Reference<
1699 xml::sax::XAttributeList > & xAttrList )
1701 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1704 void SmXMLUnderContext_Impl::HandleAccent()
1706 DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
1707 "Sub has not two arguments");
1709 /*Just one special case for the underline thing*/
1710 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
1711 SmNode *pTest = rNodeStack.Pop();
1712 SmToken aToken;
1713 aToken.cMathChar = '\0';
1714 aToken.nGroup = 0;
1715 aToken.nLevel = 0;
1716 aToken.eType = TUNDERLINE;
1719 SmNodeArray aSubNodes;
1720 aSubNodes.resize(2);
1722 SmStructureNode *pNode = new SmAttributNode(aToken);
1723 if ((pTest->GetToken().cMathChar & 0x0FFF) == 0x0332)
1725 aSubNodes[0] = new SmRectangleNode(aToken);
1726 delete pTest;
1728 else
1729 aSubNodes[0] = pTest;
1731 aSubNodes[1] = rNodeStack.Pop();
1732 pNode->SetSubNodes(aSubNodes);
1733 pNode->SetScaleMode(SCALE_WIDTH);
1734 rNodeStack.Push(pNode);
1738 void SmXMLUnderContext_Impl::EndElement()
1740 if (!nAttrCount)
1741 GenericEndElement(TCSUB,CSUB);
1742 else
1743 HandleAccent();
1744 #if 0
1745 //UnderBrace trick
1746 SmStructureNode *pNode = rNodeStack.Pop();
1747 if (pNode->GetSubNode(1)->GetToken().cMathChar == (0x0332|0xf000))
1748 if (pNode->GetSubNode(0)->GetToken().cMathChar == (0x0332|0xf000))
1749 #endif
1752 ////////////////////////////////////////////////////////////
1754 class SmXMLOverContext_Impl : public SmXMLSubContext_Impl
1756 protected:
1757 sal_Int16 nAttrCount;
1759 public:
1760 SmXMLOverContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1761 const OUString& rLName)
1762 : SmXMLSubContext_Impl(rImport,nPrefix,rLName), nAttrCount(0) {}
1764 void EndElement();
1765 void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
1766 void HandleAccent();
1770 void SmXMLOverContext_Impl::StartElement(const uno::Reference<
1771 xml::sax::XAttributeList > & xAttrList )
1773 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1777 void SmXMLOverContext_Impl::EndElement()
1779 if (!nAttrCount)
1780 GenericEndElement(TCSUP,CSUP);
1781 else
1782 HandleAccent();
1786 void SmXMLOverContext_Impl::HandleAccent()
1788 DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
1789 "Sub has not two arguments");
1790 SmToken aToken;
1791 aToken.cMathChar = '\0';
1792 aToken.nGroup = 0;
1793 aToken.nLevel = 0;
1794 aToken.eType = TACUTE;
1796 SmAttributNode *pNode = new SmAttributNode(aToken);
1797 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
1799 SmNodeArray aSubNodes;
1800 aSubNodes.resize(2);
1801 aSubNodes[0] = rNodeStack.Pop();
1802 aSubNodes[1] = rNodeStack.Pop();
1803 pNode->SetSubNodes(aSubNodes);
1804 pNode->SetScaleMode(SCALE_WIDTH);
1805 rNodeStack.Push(pNode);
1809 ////////////////////////////////////////////////////////////
1811 class SmXMLUnderOverContext_Impl : public SmXMLSubSupContext_Impl
1813 public:
1814 SmXMLUnderOverContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1815 const OUString& rLName)
1816 : SmXMLSubSupContext_Impl(rImport,nPrefix,rLName) {}
1818 void EndElement()
1820 GenericEndElement(TCSUB,CSUB,CSUP);
1824 ////////////////////////////////////////////////////////////
1826 class SmXMLMultiScriptsContext_Impl : public SmXMLSubSupContext_Impl
1828 sal_Bool bHasPrescripts;
1830 public:
1831 SmXMLMultiScriptsContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1832 const OUString& rLName) :
1833 SmXMLSubSupContext_Impl(rImport,nPrefix,rLName),
1834 bHasPrescripts(FALSE) {}
1836 void EndElement();
1837 void MiddleElement();
1838 SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
1839 const OUString& rLocalName,
1840 const uno::Reference< xml::sax::XAttributeList > &xAttrList);
1843 ////////////////////////////////////////////////////////////
1845 class SmXMLNoneContext_Impl : public SmXMLImportContext
1847 public:
1848 SmXMLNoneContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1849 const OUString& rLName)
1850 : SmXMLImportContext(rImport,nPrefix,rLName) {}
1852 void EndElement();
1856 void SmXMLNoneContext_Impl::EndElement(void)
1858 SmToken aToken;
1859 aToken.cMathChar = '\0';
1860 aToken.nGroup = 0;
1861 aToken.aText.Erase();
1862 aToken.nLevel = 5;
1863 aToken.eType = TIDENT;
1864 GetSmImport().GetNodeStack().Push(
1865 new SmTextNode(aToken,FNT_VARIABLE));
1868 ////////////////////////////////////////////////////////////
1870 class SmXMLPrescriptsContext_Impl : public SmXMLImportContext
1872 public:
1873 SmXMLPrescriptsContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1874 const OUString& rLName)
1875 : SmXMLImportContext(rImport,nPrefix,rLName) {}
1878 ////////////////////////////////////////////////////////////
1880 class SmXMLTableRowContext_Impl : public SmXMLRowContext_Impl
1882 public:
1883 SmXMLTableRowContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1884 const OUString& rLName) :
1885 SmXMLRowContext_Impl(rImport,nPrefix,rLName)
1888 SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
1889 const OUString& rLocalName,
1890 const uno::Reference< xml::sax::XAttributeList > &xAttrList);
1894 ////////////////////////////////////////////////////////////
1896 class SmXMLTableContext_Impl : public SmXMLTableRowContext_Impl
1898 public:
1899 SmXMLTableContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1900 const OUString& rLName) :
1901 SmXMLTableRowContext_Impl(rImport,nPrefix,rLName)
1904 void EndElement();
1905 SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
1906 const OUString& rLocalName,
1907 const uno::Reference< xml::sax::XAttributeList > &xAttrList);
1911 ////////////////////////////////////////////////////////////
1913 class SmXMLTableCellContext_Impl : public SmXMLRowContext_Impl
1915 public:
1916 SmXMLTableCellContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1917 const OUString& rLName) :
1918 SmXMLRowContext_Impl(rImport,nPrefix,rLName)
1922 ////////////////////////////////////////////////////////////
1924 class SmXMLAlignGroupContext_Impl : public SmXMLRowContext_Impl
1926 public:
1927 SmXMLAlignGroupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1928 const OUString& rLName) :
1929 SmXMLRowContext_Impl(rImport,nPrefix,rLName)
1932 /*Don't do anything with alignment for now*/
1933 void EndElement()
1938 ////////////////////////////////////////////////////////////
1940 class SmXMLActionContext_Impl : public SmXMLRowContext_Impl
1942 public:
1943 SmXMLActionContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1944 const OUString& rLName) :
1945 SmXMLRowContext_Impl(rImport,nPrefix,rLName)
1948 void EndElement();
1951 ////////////////////////////////////////////////////////////
1953 // NB: virtually inherit so we can multiply inherit properly
1954 // in SmXMLFlatDocContext_Impl
1955 class SmXMLOfficeContext_Impl : public virtual SvXMLImportContext
1957 public:
1958 SmXMLOfficeContext_Impl( SmXMLImport &rImport, sal_uInt16 nPrfx,
1959 const OUString& rLName)
1960 : SvXMLImportContext(rImport,nPrfx,rLName) {}
1962 virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList);
1965 SvXMLImportContext *SmXMLOfficeContext_Impl::CreateChildContext(sal_uInt16 nPrefix,
1966 const OUString& rLocalName,
1967 const uno::Reference< xml::sax::XAttributeList > &xAttrList)
1969 SvXMLImportContext *pContext = 0;
1970 if ( XML_NAMESPACE_OFFICE == nPrefix &&
1971 rLocalName == GetXMLToken(XML_META) )
1973 DBG_WARNING("XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
1975 else if ( XML_NAMESPACE_OFFICE == nPrefix &&
1976 rLocalName == GetXMLToken(XML_SETTINGS) )
1978 pContext = new XMLDocumentSettingsContext( GetImport(),
1979 XML_NAMESPACE_OFFICE, rLocalName,
1980 xAttrList );
1982 else
1983 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1985 return pContext;
1988 ////////////////////////////////////////////////////////////
1990 // context for flat file xml format
1991 class SmXMLFlatDocContext_Impl
1992 : public SmXMLOfficeContext_Impl, public SvXMLMetaDocumentContext
1994 public:
1995 SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport,
1996 USHORT i_nPrefix, const OUString & i_rLName,
1997 const uno::Reference<document::XDocumentProperties>& i_xDocProps,
1998 const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder);
2000 virtual ~SmXMLFlatDocContext_Impl();
2002 virtual SvXMLImportContext *CreateChildContext(USHORT i_nPrefix, const OUString& i_rLocalName, const uno::Reference<xml::sax::XAttributeList>& i_xAttrList);
2005 SmXMLFlatDocContext_Impl::SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport,
2006 USHORT i_nPrefix, const OUString & i_rLName,
2007 const uno::Reference<document::XDocumentProperties>& i_xDocProps,
2008 const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder) :
2009 SvXMLImportContext(i_rImport, i_nPrefix, i_rLName),
2010 SmXMLOfficeContext_Impl(i_rImport, i_nPrefix, i_rLName),
2011 SvXMLMetaDocumentContext(i_rImport, i_nPrefix, i_rLName,
2012 i_xDocProps, i_xDocBuilder)
2016 SmXMLFlatDocContext_Impl::~SmXMLFlatDocContext_Impl()
2020 SvXMLImportContext *SmXMLFlatDocContext_Impl::CreateChildContext(
2021 USHORT i_nPrefix, const OUString& i_rLocalName,
2022 const uno::Reference<xml::sax::XAttributeList>& i_xAttrList)
2024 // behave like meta base class iff we encounter office:meta
2025 if ( XML_NAMESPACE_OFFICE == i_nPrefix &&
2026 i_rLocalName == GetXMLToken(XML_META) )
2028 return SvXMLMetaDocumentContext::CreateChildContext(
2029 i_nPrefix, i_rLocalName, i_xAttrList );
2031 else
2033 return SmXMLOfficeContext_Impl::CreateChildContext(
2034 i_nPrefix, i_rLocalName, i_xAttrList );
2038 ////////////////////////////////////////////////////////////
2040 static __FAR_DATA SvXMLTokenMapEntry aPresLayoutElemTokenMap[] =
2042 { XML_NAMESPACE_MATH, XML_SEMANTICS, XML_TOK_SEMANTICS },
2043 { XML_NAMESPACE_MATH, XML_MATH, XML_TOK_MATH },
2044 { XML_NAMESPACE_MATH, XML_MSTYLE, XML_TOK_MSTYLE },
2045 { XML_NAMESPACE_MATH, XML_MERROR, XML_TOK_MERROR },
2046 { XML_NAMESPACE_MATH, XML_MPHANTOM, XML_TOK_MPHANTOM },
2047 { XML_NAMESPACE_MATH, XML_MROW, XML_TOK_MROW },
2048 { XML_NAMESPACE_MATH, XML_MFRAC, XML_TOK_MFRAC },
2049 { XML_NAMESPACE_MATH, XML_MSQRT, XML_TOK_MSQRT },
2050 { XML_NAMESPACE_MATH, XML_MROOT, XML_TOK_MROOT },
2051 { XML_NAMESPACE_MATH, XML_MSUB, XML_TOK_MSUB },
2052 { XML_NAMESPACE_MATH, XML_MSUP, XML_TOK_MSUP },
2053 { XML_NAMESPACE_MATH, XML_MSUBSUP, XML_TOK_MSUBSUP },
2054 { XML_NAMESPACE_MATH, XML_MUNDER, XML_TOK_MUNDER },
2055 { XML_NAMESPACE_MATH, XML_MOVER, XML_TOK_MOVER },
2056 { XML_NAMESPACE_MATH, XML_MUNDEROVER, XML_TOK_MUNDEROVER },
2057 { XML_NAMESPACE_MATH, XML_MMULTISCRIPTS, XML_TOK_MMULTISCRIPTS },
2058 { XML_NAMESPACE_MATH, XML_MTABLE, XML_TOK_MTABLE },
2059 { XML_NAMESPACE_MATH, XML_MACTION, XML_TOK_MACTION },
2060 { XML_NAMESPACE_MATH, XML_MFENCED, XML_TOK_MFENCED },
2061 { XML_NAMESPACE_MATH, XML_MPADDED, XML_TOK_MPADDED },
2062 XML_TOKEN_MAP_END
2065 static __FAR_DATA SvXMLTokenMapEntry aPresLayoutAttrTokenMap[] =
2067 { XML_NAMESPACE_MATH, XML_FONTWEIGHT, XML_TOK_FONTWEIGHT },
2068 { XML_NAMESPACE_MATH, XML_FONTSTYLE, XML_TOK_FONTSTYLE },
2069 { XML_NAMESPACE_MATH, XML_FONTSIZE, XML_TOK_FONTSIZE },
2070 { XML_NAMESPACE_MATH, XML_FONTFAMILY, XML_TOK_FONTFAMILY },
2071 { XML_NAMESPACE_MATH, XML_COLOR, XML_TOK_COLOR },
2072 XML_TOKEN_MAP_END
2075 static __FAR_DATA SvXMLTokenMapEntry aFencedAttrTokenMap[] =
2077 { XML_NAMESPACE_MATH, XML_OPEN, XML_TOK_OPEN },
2078 { XML_NAMESPACE_MATH, XML_CLOSE, XML_TOK_CLOSE },
2079 XML_TOKEN_MAP_END
2082 static __FAR_DATA SvXMLTokenMapEntry aOperatorAttrTokenMap[] =
2084 { XML_NAMESPACE_MATH, XML_STRETCHY, XML_TOK_STRETCHY },
2085 XML_TOKEN_MAP_END
2088 static __FAR_DATA SvXMLTokenMapEntry aAnnotationAttrTokenMap[] =
2090 { XML_NAMESPACE_MATH, XML_ENCODING, XML_TOK_ENCODING },
2091 XML_TOKEN_MAP_END
2095 static __FAR_DATA SvXMLTokenMapEntry aPresElemTokenMap[] =
2097 { XML_NAMESPACE_MATH, XML_ANNOTATION, XML_TOK_ANNOTATION },
2098 { XML_NAMESPACE_MATH, XML_MI, XML_TOK_MI },
2099 { XML_NAMESPACE_MATH, XML_MN, XML_TOK_MN },
2100 { XML_NAMESPACE_MATH, XML_MO, XML_TOK_MO },
2101 { XML_NAMESPACE_MATH, XML_MTEXT, XML_TOK_MTEXT },
2102 { XML_NAMESPACE_MATH, XML_MSPACE,XML_TOK_MSPACE },
2103 { XML_NAMESPACE_MATH, XML_MS, XML_TOK_MS },
2104 { XML_NAMESPACE_MATH, XML_MALIGNGROUP, XML_TOK_MALIGNGROUP },
2105 XML_TOKEN_MAP_END
2108 static __FAR_DATA SvXMLTokenMapEntry aPresScriptEmptyElemTokenMap[] =
2110 { XML_NAMESPACE_MATH, XML_MPRESCRIPTS, XML_TOK_MPRESCRIPTS },
2111 { XML_NAMESPACE_MATH, XML_NONE, XML_TOK_NONE },
2112 XML_TOKEN_MAP_END
2115 static __FAR_DATA SvXMLTokenMapEntry aPresTableElemTokenMap[] =
2117 { XML_NAMESPACE_MATH, XML_MTR, XML_TOK_MTR },
2118 { XML_NAMESPACE_MATH, XML_MTD, XML_TOK_MTD },
2119 XML_TOKEN_MAP_END
2122 static __FAR_DATA SvXMLTokenMapEntry aColorTokenMap[] =
2124 { XML_NAMESPACE_MATH, XML_BLACK, TBLACK},
2125 { XML_NAMESPACE_MATH, XML_WHITE, TWHITE},
2126 { XML_NAMESPACE_MATH, XML_RED, TRED},
2127 { XML_NAMESPACE_MATH, XML_GREEN, TGREEN},
2128 { XML_NAMESPACE_MATH, XML_BLUE, TBLUE},
2129 { XML_NAMESPACE_MATH, XML_AQUA, TCYAN},
2130 { XML_NAMESPACE_MATH, XML_FUCHSIA, TMAGENTA},
2131 { XML_NAMESPACE_MATH, XML_YELLOW, TYELLOW},
2132 XML_TOKEN_MAP_END
2136 ////////////////////////////////////////////////////////////
2138 const SvXMLTokenMap& SmXMLImport::GetPresLayoutElemTokenMap()
2140 if (!pPresLayoutElemTokenMap)
2141 pPresLayoutElemTokenMap = new SvXMLTokenMap(aPresLayoutElemTokenMap);
2142 return *pPresLayoutElemTokenMap;
2145 const SvXMLTokenMap& SmXMLImport::GetPresLayoutAttrTokenMap()
2147 if (!pPresLayoutAttrTokenMap)
2148 pPresLayoutAttrTokenMap = new SvXMLTokenMap(aPresLayoutAttrTokenMap);
2149 return *pPresLayoutAttrTokenMap;
2153 const SvXMLTokenMap& SmXMLImport::GetFencedAttrTokenMap()
2155 if (!pFencedAttrTokenMap)
2156 pFencedAttrTokenMap = new SvXMLTokenMap(aFencedAttrTokenMap);
2157 return *pFencedAttrTokenMap;
2160 const SvXMLTokenMap& SmXMLImport::GetOperatorAttrTokenMap()
2162 if (!pOperatorAttrTokenMap)
2163 pOperatorAttrTokenMap = new SvXMLTokenMap(aOperatorAttrTokenMap);
2164 return *pOperatorAttrTokenMap;
2167 const SvXMLTokenMap& SmXMLImport::GetAnnotationAttrTokenMap()
2169 if (!pAnnotationAttrTokenMap)
2170 pAnnotationAttrTokenMap = new SvXMLTokenMap(aAnnotationAttrTokenMap);
2171 return *pAnnotationAttrTokenMap;
2174 const SvXMLTokenMap& SmXMLImport::GetPresElemTokenMap()
2176 if (!pPresElemTokenMap)
2177 pPresElemTokenMap = new SvXMLTokenMap(aPresElemTokenMap);
2178 return *pPresElemTokenMap;
2181 const SvXMLTokenMap& SmXMLImport::GetPresScriptEmptyElemTokenMap()
2183 if (!pPresScriptEmptyElemTokenMap)
2184 pPresScriptEmptyElemTokenMap = new
2185 SvXMLTokenMap(aPresScriptEmptyElemTokenMap);
2186 return *pPresScriptEmptyElemTokenMap;
2189 const SvXMLTokenMap& SmXMLImport::GetPresTableElemTokenMap()
2191 if (!pPresTableElemTokenMap)
2192 pPresTableElemTokenMap = new SvXMLTokenMap(aPresTableElemTokenMap);
2193 return *pPresTableElemTokenMap;
2196 const SvXMLTokenMap& SmXMLImport::GetColorTokenMap()
2198 if (!pColorTokenMap)
2199 pColorTokenMap = new SvXMLTokenMap(aColorTokenMap);
2200 return *pColorTokenMap;
2203 ////////////////////////////////////////////////////////////
2205 SvXMLImportContext *SmXMLDocContext_Impl::CreateChildContext(
2206 sal_uInt16 nPrefix,
2207 const OUString& rLocalName,
2208 const uno::Reference<xml::sax::XAttributeList>& xAttrList)
2210 SvXMLImportContext* pContext = 0L;
2212 const SvXMLTokenMap& rTokenMap = GetSmImport().GetPresLayoutElemTokenMap();
2214 //UINT32 nTest = rTokenMap.Get(nPrefix, rLocalName);
2216 switch(rTokenMap.Get(nPrefix, rLocalName))
2218 //Consider semantics a dummy except for any starmath annotations
2219 case XML_TOK_SEMANTICS:
2220 pContext = GetSmImport().CreateRowContext(nPrefix,rLocalName,
2221 xAttrList);
2222 break;
2223 /*General Layout Schemata*/
2224 case XML_TOK_MROW:
2225 pContext = GetSmImport().CreateRowContext(nPrefix,rLocalName,
2226 xAttrList);
2227 break;
2228 case XML_TOK_MFRAC:
2229 pContext = GetSmImport().CreateFracContext(nPrefix,rLocalName,
2230 xAttrList);
2231 break;
2232 case XML_TOK_MSQRT:
2233 pContext = GetSmImport().CreateSqrtContext(nPrefix,rLocalName,
2234 xAttrList);
2235 break;
2236 case XML_TOK_MROOT:
2237 pContext = GetSmImport().CreateRootContext(nPrefix,rLocalName,
2238 xAttrList);
2239 break;
2240 case XML_TOK_MSTYLE:
2241 pContext = GetSmImport().CreateStyleContext(nPrefix,rLocalName,
2242 xAttrList);
2243 break;
2244 case XML_TOK_MERROR:
2245 pContext = GetSmImport().CreateErrorContext(nPrefix,rLocalName,
2246 xAttrList);
2247 break;
2248 case XML_TOK_MPADDED:
2249 pContext = GetSmImport().CreatePaddedContext(nPrefix,rLocalName,
2250 xAttrList);
2251 break;
2252 case XML_TOK_MPHANTOM:
2253 pContext = GetSmImport().CreatePhantomContext(nPrefix,rLocalName,
2254 xAttrList);
2255 break;
2256 case XML_TOK_MFENCED:
2257 pContext = GetSmImport().CreateFencedContext(nPrefix,rLocalName,
2258 xAttrList);
2259 break;
2260 /*Script and Limit Schemata*/
2261 case XML_TOK_MSUB:
2262 pContext = GetSmImport().CreateSubContext(nPrefix,rLocalName,
2263 xAttrList);
2264 break;
2265 case XML_TOK_MSUP:
2266 pContext = GetSmImport().CreateSupContext(nPrefix,rLocalName,
2267 xAttrList);
2268 break;
2269 case XML_TOK_MSUBSUP:
2270 pContext = GetSmImport().CreateSubSupContext(nPrefix,rLocalName,
2271 xAttrList);
2272 break;
2273 case XML_TOK_MUNDER:
2274 pContext = GetSmImport().CreateUnderContext(nPrefix,rLocalName,
2275 xAttrList);
2276 break;
2277 case XML_TOK_MOVER:
2278 pContext = GetSmImport().CreateOverContext(nPrefix,rLocalName,
2279 xAttrList);
2280 break;
2281 case XML_TOK_MUNDEROVER:
2282 pContext = GetSmImport().CreateUnderOverContext(nPrefix,rLocalName,
2283 xAttrList);
2284 break;
2285 case XML_TOK_MMULTISCRIPTS:
2286 pContext = GetSmImport().CreateMultiScriptsContext(nPrefix,
2287 rLocalName, xAttrList);
2288 break;
2289 case XML_TOK_MTABLE:
2290 pContext = GetSmImport().CreateTableContext(nPrefix,
2291 rLocalName, xAttrList);
2292 break;
2293 case XML_TOK_MACTION:
2294 pContext = GetSmImport().CreateActionContext(nPrefix,
2295 rLocalName, xAttrList);
2296 break;
2297 default:
2298 /*Basically theres an implicit mrow around certain bare
2299 *elements, use a RowContext to see if this is one of
2300 *those ones*/
2301 SmXMLRowContext_Impl aTempContext(GetSmImport(),nPrefix,
2302 GetXMLToken(XML_MROW));
2304 pContext = aTempContext.StrictCreateChildContext(nPrefix,
2305 rLocalName, xAttrList);
2306 break;
2308 return pContext;
2311 void SmXMLDocContext_Impl::EndElement()
2313 SmNodeArray ContextArray;
2314 ContextArray.resize(1);
2315 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2317 for (ULONG i=0;i< 1;i++)
2318 ContextArray[i] = rNodeStack.Pop();
2320 SmToken aDummy;
2321 SmStructureNode *pSNode = new SmLineNode(aDummy);
2322 pSNode->SetSubNodes(ContextArray);
2323 rNodeStack.Push(pSNode);
2325 SmNodeArray LineArray;
2326 ULONG n = rNodeStack.Count();
2327 LineArray.resize(n);
2328 for (ULONG j = 0; j < n; j++)
2329 LineArray[n - (j + 1)] = rNodeStack.Pop();
2330 SmStructureNode *pSNode2 = new SmTableNode(aDummy);
2331 pSNode2->SetSubNodes(LineArray);
2332 rNodeStack.Push(pSNode2);
2335 void SmXMLFracContext_Impl::EndElement()
2337 SmToken aToken;
2338 aToken.cMathChar = '\0';
2339 aToken.nGroup = 0;
2340 aToken.nLevel = 0;
2341 aToken.eType = TOVER;
2342 SmStructureNode *pSNode = new SmBinVerNode(aToken);
2343 SmNode *pOper = new SmRectangleNode(aToken);
2344 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2345 DBG_ASSERT(rNodeStack.Count() - nElementCount == 2,
2346 "Fraction (mfrac) tag is missing component");
2347 if (rNodeStack.Count() - nElementCount == 2)
2349 SmNode *pSecond = rNodeStack.Pop();
2350 SmNode *pFirst = rNodeStack.Pop();
2351 pSNode->SetSubNodes(pFirst,pOper,pSecond);
2352 rNodeStack.Push(pSNode);
2356 void SmXMLRootContext_Impl::EndElement()
2358 /*The <mroot> element requires exactly 2 arguments.*/
2359 DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2,
2360 "Root tag is missing component");
2362 SmToken aToken;
2363 aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font
2364 aToken.nGroup = 0;
2365 aToken.nLevel = 0;
2366 aToken.eType = TNROOT;
2367 SmStructureNode *pSNode = new SmRootNode(aToken);
2368 SmNode *pOper = new SmRootSymbolNode(aToken);
2369 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2370 SmNode *pIndex = rNodeStack.Pop();
2371 SmNode *pBase = rNodeStack.Pop();
2372 pSNode->SetSubNodes(pIndex,pOper,pBase);
2373 rNodeStack.Push(pSNode);
2376 void SmXMLSqrtContext_Impl::EndElement()
2379 <msqrt> accepts any number of arguments; if this number is not 1, its
2380 contents are treated as a single "inferred <mrow>" containing its
2381 arguments
2383 if (GetSmImport().GetNodeStack().Count() - nElementCount > 1)
2384 SmXMLRowContext_Impl::EndElement();
2386 SmToken aToken;
2387 aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font
2388 aToken.nGroup = 0;
2389 aToken.nLevel = 0;
2390 aToken.eType = TSQRT;
2391 SmStructureNode *pSNode = new SmRootNode(aToken);
2392 SmNode *pOper = new SmRootSymbolNode(aToken);
2393 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2394 pSNode->SetSubNodes(0,pOper,rNodeStack.Pop());
2395 rNodeStack.Push(pSNode);
2398 void SmXMLRowContext_Impl::EndElement()
2400 SmNodeArray aRelationArray;
2401 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2402 ULONG nSize = rNodeStack.Count()-nElementCount;
2404 if (nSize > 0)
2406 aRelationArray.resize(nSize);
2407 for (ULONG j=rNodeStack.Count()-nElementCount;j > 0;j--)
2408 aRelationArray[j-1] = rNodeStack.Pop();
2411 //If the first or last element is an operator with stretchyness
2412 //set then we must create a brace node here from those elements,
2413 //removing the stretchness from the operators and applying it to
2414 //ourselves, and creating the appropiate dummy StarMath none bracket
2415 //to balance the arrangement
2416 if (((aRelationArray[0]->GetScaleMode() == SCALE_HEIGHT)
2417 && (aRelationArray[0]->GetType() == NMATH))
2418 || ((aRelationArray[nSize-1]->GetScaleMode() == SCALE_HEIGHT)
2419 && (aRelationArray[nSize-1]->GetType() == NMATH)))
2421 SmToken aToken;
2422 aToken.cMathChar = '\0';
2423 aToken.nGroup = 0;
2424 aToken.nLevel = 5;
2426 int nLeft=0,nRight=0;
2427 if ((aRelationArray[0]->GetScaleMode() == SCALE_HEIGHT)
2428 && (aRelationArray[0]->GetType() == NMATH))
2430 aToken = aRelationArray[0]->GetToken();
2431 nLeft=1;
2433 else
2434 aToken.cMathChar = '\0';
2436 aToken.eType = TLPARENT;
2437 SmNode *pLeft = new SmMathSymbolNode(aToken);
2439 if ((aRelationArray[nSize-1]->GetScaleMode() == SCALE_HEIGHT)
2440 && (aRelationArray[nSize-1]->GetType() == NMATH))
2442 aToken = aRelationArray[nSize-1]->GetToken();
2443 nRight=1;
2445 else
2446 aToken.cMathChar = '\0';
2448 aToken.eType = TRPARENT;
2449 SmNode *pRight = new SmMathSymbolNode(aToken);
2451 SmNodeArray aRelationArray2;
2453 //!! nSize-nLeft-nRight may be < 0 !!
2454 int nRelArrSize = nSize-nLeft-nRight;
2455 if (nRelArrSize > 0)
2457 aRelationArray2.resize(nRelArrSize);
2458 for (int i=0;i < nRelArrSize;i++)
2459 aRelationArray2[i] = aRelationArray[i+nLeft];
2462 SmToken aDummy;
2463 SmStructureNode *pSNode = new SmBraceNode(aToken);
2464 SmStructureNode *pBody = new SmExpressionNode(aDummy);
2465 pBody->SetSubNodes(aRelationArray2);
2467 pSNode->SetSubNodes(pLeft,pBody,pRight);
2468 pSNode->SetScaleMode(SCALE_HEIGHT);
2469 rNodeStack.Push(pSNode);
2470 return;
2473 else //Multiple newlines result in empty row elements
2475 aRelationArray.resize(1);
2476 SmToken aToken;
2477 aToken.cMathChar = '\0';
2478 aToken.nGroup = 0;
2479 aToken.nLevel = 5;
2480 aToken.eType = TNEWLINE;
2481 aRelationArray[0] = new SmLineNode(aToken);
2484 SmToken aDummy;
2485 SmStructureNode *pSNode = new SmExpressionNode(aDummy);
2486 pSNode->SetSubNodes(aRelationArray);
2487 rNodeStack.Push(pSNode);
2491 SvXMLImportContext *SmXMLRowContext_Impl::StrictCreateChildContext(
2492 sal_uInt16 nPrefix,
2493 const OUString& rLocalName,
2494 const uno::Reference<xml::sax::XAttributeList>& xAttrList)
2496 SvXMLImportContext* pContext = 0L;
2498 const SvXMLTokenMap& rTokenMap = GetSmImport().GetPresElemTokenMap();
2499 switch(rTokenMap.Get(nPrefix, rLocalName))
2501 /*Note that these should accept malignmark subelements, but do not*/
2502 case XML_TOK_MN:
2503 pContext = GetSmImport().CreateNumberContext(nPrefix,rLocalName,
2504 xAttrList);
2505 break;
2506 case XML_TOK_MI:
2507 pContext = GetSmImport().CreateIdentifierContext(nPrefix,rLocalName,
2508 xAttrList);
2509 break;
2510 case XML_TOK_MO:
2511 pContext = GetSmImport().CreateOperatorContext(nPrefix,rLocalName,
2512 xAttrList);
2513 break;
2514 case XML_TOK_MTEXT:
2515 pContext = GetSmImport().CreateTextContext(nPrefix,rLocalName,
2516 xAttrList);
2517 break;
2518 case XML_TOK_MSPACE:
2519 pContext = GetSmImport().CreateSpaceContext(nPrefix,rLocalName,
2520 xAttrList);
2521 break;
2522 case XML_TOK_MS:
2523 pContext = GetSmImport().CreateStringContext(nPrefix,rLocalName,
2524 xAttrList);
2525 break;
2527 /*Note: The maligngroup should only be seen when the row
2528 * (or decendants) are in a table*/
2529 case XML_TOK_MALIGNGROUP:
2530 pContext = GetSmImport().CreateAlignGroupContext(nPrefix,rLocalName,
2531 xAttrList);
2532 break;
2534 case XML_TOK_ANNOTATION:
2535 pContext = GetSmImport().CreateAnnotationContext(nPrefix,rLocalName,
2536 xAttrList);
2537 break;
2539 default:
2540 break;
2542 return pContext;
2546 SvXMLImportContext *SmXMLRowContext_Impl::CreateChildContext(
2547 sal_uInt16 nPrefix,
2548 const OUString& rLocalName,
2549 const uno::Reference<xml::sax::XAttributeList>& xAttrList)
2551 SvXMLImportContext* pContext = StrictCreateChildContext(nPrefix,
2552 rLocalName, xAttrList);
2554 if (!pContext)
2556 //Hmm, unrecognized for this level, check to see if its
2557 //an element that can have an implicit schema around it
2558 pContext = SmXMLDocContext_Impl::CreateChildContext(nPrefix,
2559 rLocalName,xAttrList);
2561 return pContext;
2565 SvXMLImportContext *SmXMLMultiScriptsContext_Impl::CreateChildContext(
2566 sal_uInt16 nPrefix,
2567 const OUString& rLocalName,
2568 const uno::Reference<xml::sax::XAttributeList>& xAttrList)
2570 SvXMLImportContext* pContext = 0L;
2572 const SvXMLTokenMap& rTokenMap = GetSmImport().
2573 GetPresScriptEmptyElemTokenMap();
2574 switch(rTokenMap.Get(nPrefix, rLocalName))
2576 case XML_TOK_MPRESCRIPTS:
2577 MiddleElement();
2578 pContext = GetSmImport().CreatePrescriptsContext(nPrefix,
2579 rLocalName, xAttrList);
2580 break;
2581 case XML_TOK_NONE:
2582 pContext = GetSmImport().CreateNoneContext(nPrefix,rLocalName,
2583 xAttrList);
2584 break;
2585 default:
2586 pContext = SmXMLRowContext_Impl::CreateChildContext(nPrefix,
2587 rLocalName,xAttrList);
2588 break;
2590 return pContext;
2593 void SmXMLMultiScriptsContext_Impl::MiddleElement()
2595 bHasPrescripts=sal_True;
2597 DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount > 0,
2598 "Sub has no arguments");
2599 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2600 if (rNodeStack.Count()-nElementCount > 1)
2602 SmToken aToken;
2603 aToken.cMathChar = '\0';
2604 aToken.nGroup = 0;
2605 aToken.nLevel = 0;
2606 aToken.eType = TRSUB;
2607 ULONG nFinalCount = rNodeStack.Count()-nElementCount-1;
2609 SmNodeStack aReverseStack;
2610 while (rNodeStack.Count()-nElementCount)
2612 SmNode *pThing = rNodeStack.Pop();
2613 aReverseStack.Push(pThing);
2616 for (ULONG nCount=0;nCount < nFinalCount;nCount+=2)
2618 SmSubSupNode *pNode = new SmSubSupNode(aToken);
2620 // initialize subnodes array
2621 SmNodeArray aSubNodes;
2622 aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
2623 for (ULONG i = 1; i < aSubNodes.size(); i++)
2624 aSubNodes[i] = NULL;
2626 /*On each loop the base and its sub sup pair becomes the
2627 base for the next loop to which the next sub sup pair is
2628 attached, i.e. wheels within wheels*/
2629 //if (nCount == 0)
2630 aSubNodes[0] = aReverseStack.Pop();
2632 SmNode *pScriptNode = aReverseStack.Pop();
2634 if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) ||
2635 (pScriptNode->GetToken().aText.Len())))
2636 aSubNodes[RSUB+1] = pScriptNode;
2637 pScriptNode = aReverseStack.Pop();
2638 if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) ||
2639 (pScriptNode->GetToken().aText.Len())))
2640 aSubNodes[RSUP+1] = pScriptNode;
2642 pNode->SetSubNodes(aSubNodes);
2643 aReverseStack.Push(pNode);
2645 rNodeStack.Push(aReverseStack.Pop());
2650 void SmXMLTableContext_Impl::EndElement()
2652 SmNodeArray aExpressionArray;
2653 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2654 SmNodeStack aReverseStack;
2655 aExpressionArray.resize(rNodeStack.Count()-nElementCount);
2657 ULONG nRows = rNodeStack.Count()-nElementCount;
2658 USHORT nCols = 0;
2660 SmStructureNode *pArray;
2661 for (ULONG i=rNodeStack.Count()-nElementCount;i > 0;i--)
2663 pArray = (SmStructureNode *)rNodeStack.Pop();
2664 if (pArray->GetNumSubNodes() == 0)
2666 //This is a little tricky, it is possible that there was
2667 //be elements that were not inside a <mtd> pair, in which
2668 //case they will not be in a row, i.e. they will not have
2669 //SubNodes, so we have to wait until here before we can
2670 //resolve the situation. Implicitsurrounding tags are
2671 //surprisingly difficult to get right within this
2672 //architecture
2674 SmNodeArray aRelationArray;
2675 aRelationArray.resize(1);
2676 aRelationArray[0] = pArray;
2677 SmToken aDummy;
2678 pArray = new SmExpressionNode(aDummy);
2679 pArray->SetSubNodes(aRelationArray);
2682 if (pArray->GetNumSubNodes() > nCols)
2683 nCols = pArray->GetNumSubNodes();
2684 aReverseStack.Push(pArray);
2686 aExpressionArray.resize(nCols*nRows);
2687 ULONG j=0;
2688 while (aReverseStack.Count())
2690 pArray = (SmStructureNode *)aReverseStack.Pop();
2691 for (USHORT i=0;i<pArray->GetNumSubNodes();i++)
2692 aExpressionArray[j++] = pArray->GetSubNode(i);
2695 SmToken aToken;
2696 aToken.cMathChar = '\0';
2697 aToken.nGroup = TRGROUP;
2698 aToken.nLevel = 0;
2699 aToken.eType = TMATRIX;
2700 SmMatrixNode *pSNode = new SmMatrixNode(aToken);
2701 pSNode->SetSubNodes(aExpressionArray);
2702 pSNode->SetRowCol(static_cast<USHORT>(nRows),nCols);
2703 rNodeStack.Push(pSNode);
2706 SvXMLImportContext *SmXMLTableRowContext_Impl::CreateChildContext(
2707 sal_uInt16 nPrefix,
2708 const OUString& rLocalName,
2709 const uno::Reference<xml::sax::XAttributeList>& xAttrList)
2711 SvXMLImportContext* pContext = 0L;
2713 const SvXMLTokenMap& rTokenMap = GetSmImport().
2714 GetPresTableElemTokenMap();
2715 switch(rTokenMap.Get(nPrefix, rLocalName))
2717 case XML_TOK_MTD:
2718 pContext = GetSmImport().CreateTableCellContext(nPrefix,
2719 rLocalName, xAttrList);
2720 break;
2721 default:
2722 pContext = SmXMLRowContext_Impl::CreateChildContext(nPrefix,
2723 rLocalName,xAttrList);
2724 break;
2726 return pContext;
2729 SvXMLImportContext *SmXMLTableContext_Impl::CreateChildContext(
2730 sal_uInt16 nPrefix,
2731 const OUString& rLocalName,
2732 const uno::Reference<xml::sax::XAttributeList>& xAttrList)
2734 SvXMLImportContext* pContext = 0L;
2736 const SvXMLTokenMap& rTokenMap = GetSmImport().
2737 GetPresTableElemTokenMap();
2738 switch(rTokenMap.Get(nPrefix, rLocalName))
2740 case XML_TOK_MTR:
2741 pContext = GetSmImport().CreateTableRowContext(nPrefix,rLocalName,
2742 xAttrList);
2743 break;
2744 default:
2745 pContext = SmXMLTableRowContext_Impl::CreateChildContext(nPrefix,
2746 rLocalName,xAttrList);
2747 break;
2749 return pContext;
2752 void SmXMLMultiScriptsContext_Impl::EndElement()
2754 if (!bHasPrescripts)
2755 MiddleElement();
2757 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2758 if (rNodeStack.Count()-nElementCount > 1)
2760 SmToken aToken;
2761 aToken.cMathChar = '\0';
2762 aToken.nGroup = 0;
2763 aToken.nLevel = 0;
2764 aToken.eType = TLSUB;
2765 ULONG nFinalCount = rNodeStack.Count()-nElementCount-1;
2767 SmNodeStack aReverseStack;
2768 while (rNodeStack.Count()-nElementCount)
2769 aReverseStack.Push(rNodeStack.Pop());
2770 for (ULONG nCount=0;nCount < nFinalCount;nCount+=2)
2772 SmSubSupNode *pNode = new SmSubSupNode(aToken);
2774 // initialize subnodes array
2775 SmNodeArray aSubNodes;
2776 aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
2777 for (ULONG i = 1; i < aSubNodes.size(); i++)
2778 aSubNodes[i] = NULL;
2780 /*On each loop the base and its sub sup pair becomes the
2781 base for the next loop to which the next sub sup pair is
2782 attached, i.e. wheels within wheels*/
2783 //if (nCount == 0)
2784 aSubNodes[0] = aReverseStack.Pop();
2786 SmNode *pScriptNode = aReverseStack.Pop();
2787 if (pScriptNode->GetToken().aText.Len())
2788 aSubNodes[LSUB+1] = pScriptNode;
2789 pScriptNode = aReverseStack.Pop();
2790 if (pScriptNode->GetToken().aText.Len())
2791 aSubNodes[LSUP+1] = pScriptNode;
2793 pNode->SetSubNodes(aSubNodes);
2794 aReverseStack.Push(pNode);
2796 rNodeStack.Push(aReverseStack.Pop());
2800 void SmXMLActionContext_Impl::EndElement()
2802 /*For now we will just assume that the
2803 selected attribute is one, and then just display
2804 that expression alone, i.e. remove all expect the
2805 first pushed one*/
2807 SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2808 for (ULONG i=rNodeStack.Count()-nElementCount;i > 1;i--)
2810 delete rNodeStack.Pop();
2814 SvXMLImportContext *SmXMLImport::CreateContext(sal_uInt16 nPrefix,
2815 const OUString &rLocalName,
2816 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2818 if ( XML_NAMESPACE_OFFICE == nPrefix )
2820 if ( (IsXMLToken(rLocalName, XML_DOCUMENT) ||
2821 IsXMLToken(rLocalName, XML_DOCUMENT_META)))
2823 uno::Reference<xml::sax::XDocumentHandler> xDocBuilder(
2824 mxServiceFactory->createInstance(
2825 ::rtl::OUString::createFromAscii(
2826 "com.sun.star.xml.dom.SAXDocumentBuilder")),
2827 uno::UNO_QUERY_THROW);
2828 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
2829 GetModel(), uno::UNO_QUERY_THROW);
2830 return IsXMLToken(rLocalName, XML_DOCUMENT_META)
2831 ? new SvXMLMetaDocumentContext(*this,
2832 XML_NAMESPACE_OFFICE, rLocalName,
2833 xDPS->getDocumentProperties(), xDocBuilder)
2834 // flat OpenDocument file format -- this has not been tested...
2835 : new SmXMLFlatDocContext_Impl( *this, nPrefix, rLocalName,
2836 xDPS->getDocumentProperties(), xDocBuilder);
2838 else
2840 return new SmXMLOfficeContext_Impl( *this,nPrefix,rLocalName);
2843 else
2844 return new SmXMLDocContext_Impl(*this,nPrefix,rLocalName);
2847 SvXMLImportContext *SmXMLImport::CreateRowContext(sal_uInt16 nPrefix,
2848 const OUString &rLocalName,
2849 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2851 return new SmXMLRowContext_Impl(*this,nPrefix,rLocalName);
2854 SvXMLImportContext *SmXMLImport::CreateTextContext(sal_uInt16 nPrefix,
2855 const OUString &rLocalName,
2856 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2858 return new SmXMLTextContext_Impl(*this,nPrefix,rLocalName);
2861 SvXMLImportContext *SmXMLImport::CreateAnnotationContext(sal_uInt16 nPrefix,
2862 const OUString &rLocalName,
2863 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2865 return new SmXMLAnnotationContext_Impl(*this,nPrefix,rLocalName);
2868 SvXMLImportContext *SmXMLImport::CreateStringContext(sal_uInt16 nPrefix,
2869 const OUString &rLocalName,
2870 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2872 return new SmXMLStringContext_Impl(*this,nPrefix,rLocalName);
2875 SvXMLImportContext *SmXMLImport::CreateNumberContext(sal_uInt16 nPrefix,
2876 const OUString &rLocalName,
2877 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2879 return new SmXMLNumberContext_Impl(*this,nPrefix,rLocalName);
2882 SvXMLImportContext *SmXMLImport::CreateIdentifierContext(sal_uInt16 nPrefix,
2883 const OUString &rLocalName,
2884 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2886 return new SmXMLIdentifierContext_Impl(*this,nPrefix,rLocalName);
2889 SvXMLImportContext *SmXMLImport::CreateOperatorContext(sal_uInt16 nPrefix,
2890 const OUString &rLocalName,
2891 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2893 return new SmXMLOperatorContext_Impl(*this,nPrefix,rLocalName);
2896 SvXMLImportContext *SmXMLImport::CreateSpaceContext(sal_uInt16 nPrefix,
2897 const OUString &rLocalName,
2898 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2900 return new SmXMLSpaceContext_Impl(*this,nPrefix,rLocalName);
2904 SvXMLImportContext *SmXMLImport::CreateFracContext(sal_uInt16 nPrefix,
2905 const OUString &rLocalName,
2906 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2908 return new SmXMLFracContext_Impl(*this,nPrefix,rLocalName);
2911 SvXMLImportContext *SmXMLImport::CreateSqrtContext(sal_uInt16 nPrefix,
2912 const OUString &rLocalName,
2913 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2915 return new SmXMLSqrtContext_Impl(*this,nPrefix,rLocalName);
2918 SvXMLImportContext *SmXMLImport::CreateRootContext(sal_uInt16 nPrefix,
2919 const OUString &rLocalName,
2920 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2922 return new SmXMLRootContext_Impl(*this,nPrefix,rLocalName);
2925 SvXMLImportContext *SmXMLImport::CreateStyleContext(sal_uInt16 nPrefix,
2926 const OUString &rLocalName,
2927 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2929 return new SmXMLStyleContext_Impl(*this,nPrefix,rLocalName);
2932 SvXMLImportContext *SmXMLImport::CreatePaddedContext(sal_uInt16 nPrefix,
2933 const OUString &rLocalName,
2934 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2936 return new SmXMLPaddedContext_Impl(*this,nPrefix,rLocalName);
2939 SvXMLImportContext *SmXMLImport::CreatePhantomContext(sal_uInt16 nPrefix,
2940 const OUString &rLocalName,
2941 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2943 return new SmXMLPhantomContext_Impl(*this,nPrefix,rLocalName);
2946 SvXMLImportContext *SmXMLImport::CreateFencedContext(sal_uInt16 nPrefix,
2947 const OUString &rLocalName,
2948 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2950 return new SmXMLFencedContext_Impl(*this,nPrefix,rLocalName);
2953 SvXMLImportContext *SmXMLImport::CreateErrorContext(sal_uInt16 nPrefix,
2954 const OUString &rLocalName,
2955 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2957 return new SmXMLErrorContext_Impl(*this,nPrefix,rLocalName);
2960 SvXMLImportContext *SmXMLImport::CreateSubContext(sal_uInt16 nPrefix,
2961 const OUString &rLocalName,
2962 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2964 return new SmXMLSubContext_Impl(*this,nPrefix,rLocalName);
2967 SvXMLImportContext *SmXMLImport::CreateSubSupContext(sal_uInt16 nPrefix,
2968 const OUString &rLocalName,
2969 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2971 return new SmXMLSubSupContext_Impl(*this,nPrefix,rLocalName);
2974 SvXMLImportContext *SmXMLImport::CreateSupContext(sal_uInt16 nPrefix,
2975 const OUString &rLocalName,
2976 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2978 return new SmXMLSupContext_Impl(*this,nPrefix,rLocalName);
2981 SvXMLImportContext *SmXMLImport::CreateUnderContext(sal_uInt16 nPrefix,
2982 const OUString &rLocalName,
2983 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2985 return new SmXMLUnderContext_Impl(*this,nPrefix,rLocalName);
2988 SvXMLImportContext *SmXMLImport::CreateOverContext(sal_uInt16 nPrefix,
2989 const OUString &rLocalName,
2990 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2992 return new SmXMLOverContext_Impl(*this,nPrefix,rLocalName);
2995 SvXMLImportContext *SmXMLImport::CreateUnderOverContext(sal_uInt16 nPrefix,
2996 const OUString &rLocalName,
2997 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2999 return new SmXMLUnderOverContext_Impl(*this,nPrefix,rLocalName);
3002 SvXMLImportContext *SmXMLImport::CreateMultiScriptsContext(sal_uInt16 nPrefix,
3003 const OUString &rLocalName,
3004 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
3006 return new SmXMLMultiScriptsContext_Impl(*this,nPrefix,rLocalName);
3009 SvXMLImportContext *SmXMLImport::CreateTableContext(sal_uInt16 nPrefix,
3010 const OUString &rLocalName,
3011 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
3013 return new SmXMLTableContext_Impl(*this,nPrefix,rLocalName);
3015 SvXMLImportContext *SmXMLImport::CreateTableRowContext(sal_uInt16 nPrefix,
3016 const OUString &rLocalName,
3017 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
3019 return new SmXMLTableRowContext_Impl(*this,nPrefix,rLocalName);
3021 SvXMLImportContext *SmXMLImport::CreateTableCellContext(sal_uInt16 nPrefix,
3022 const OUString &rLocalName,
3023 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
3025 return new SmXMLTableCellContext_Impl(*this,nPrefix,rLocalName);
3028 SvXMLImportContext *SmXMLImport::CreateNoneContext(sal_uInt16 nPrefix,
3029 const OUString &rLocalName,
3030 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
3032 return new SmXMLNoneContext_Impl(*this,nPrefix,rLocalName);
3035 SvXMLImportContext *SmXMLImport::CreatePrescriptsContext(sal_uInt16 nPrefix,
3036 const OUString &rLocalName,
3037 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
3039 return new SmXMLPrescriptsContext_Impl(*this,nPrefix,rLocalName);
3042 SvXMLImportContext *SmXMLImport::CreateAlignGroupContext(sal_uInt16 nPrefix,
3043 const OUString &rLocalName,
3044 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
3046 return new SmXMLAlignGroupContext_Impl(*this,nPrefix,rLocalName);
3049 SvXMLImportContext *SmXMLImport::CreateActionContext(sal_uInt16 nPrefix,
3050 const OUString &rLocalName,
3051 const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
3053 return new SmXMLActionContext_Impl(*this,nPrefix,rLocalName);
3056 SmXMLImport::~SmXMLImport() throw ()
3058 delete pPresLayoutElemTokenMap;
3059 delete pPresElemTokenMap;
3060 delete pPresScriptEmptyElemTokenMap;
3061 delete pPresTableElemTokenMap;
3062 delete pPresLayoutAttrTokenMap;
3063 delete pFencedAttrTokenMap;
3064 delete pColorTokenMap;
3065 delete pOperatorAttrTokenMap;
3066 delete pAnnotationAttrTokenMap;
3069 void SmXMLImport::SetViewSettings(const Sequence<PropertyValue>& aViewProps)
3071 uno::Reference <frame::XModel> xModel = GetModel();
3072 if ( !xModel.is() )
3073 return;
3075 uno::Reference <lang::XUnoTunnel> xTunnel;
3076 xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
3077 SmModel *pModel = reinterpret_cast<SmModel *>
3078 (xTunnel->getSomething(SmModel::getUnoTunnelId()));
3080 if ( !pModel )
3081 return;
3083 SmDocShell *pDocShell =
3084 static_cast<SmDocShell*>(pModel->GetObjectShell());
3085 if ( !pDocShell )
3086 return;
3088 Rectangle aRect( pDocShell->GetVisArea() );
3090 sal_Int32 nCount = aViewProps.getLength();
3091 const PropertyValue *pValue = aViewProps.getConstArray();
3093 long nTmp = 0;
3094 //sal_Bool bShowDeletes = sal_False, bShowInserts = sal_False, bShowFooter = sal_False, bShowHeader = sal_False;
3096 for (sal_Int32 i = 0; i < nCount ; i++)
3098 if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaTop" ) ) )
3100 pValue->Value >>= nTmp;
3101 aRect.setY( nTmp );
3103 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaLeft" ) ) )
3105 pValue->Value >>= nTmp;
3106 aRect.setX( nTmp );
3108 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaWidth" ) ) )
3110 pValue->Value >>= nTmp;
3111 Size aSize( aRect.GetSize() );
3112 aSize.Width() = nTmp;
3113 aRect.SetSize( aSize );
3115 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ViewAreaHeight" ) ) )
3117 pValue->Value >>= nTmp;
3118 Size aSize( aRect.GetSize() );
3119 aSize.Height() = nTmp;
3120 aRect.SetSize( aSize );
3122 pValue++;
3125 pDocShell->SetVisArea ( aRect );
3128 void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfProps)
3130 uno::Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY );
3131 if ( xProps.is() )
3133 Reference < XPropertySetInfo > xInfo ( xProps->getPropertySetInfo() );
3134 if (xInfo.is() )
3136 sal_Int32 nCount = aConfProps.getLength();
3137 const PropertyValue* pValues = aConfProps.getConstArray();
3139 const OUString sFormula ( RTL_CONSTASCII_USTRINGPARAM ( "Formula" ) );
3140 const OUString sBasicLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "BasicLibraries" ) );
3141 const OUString sDialogLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "DialogLibraries" ) );
3142 while ( nCount-- )
3144 if (pValues->Name != sFormula &&
3145 pValues->Name != sBasicLibraries &&
3146 pValues->Name != sDialogLibraries)
3150 if ( xInfo->hasPropertyByName( pValues->Name ) )
3151 xProps->setPropertyValue( pValues->Name, pValues->Value );
3153 catch( Exception& )
3155 DBG_ERROR( "SmXMLImport::SetConfigurationSettings: Exception!" );
3159 pValues++;
3166 ////////////////////////////////////////////////////////////