Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : :
21 : : /*todo: Change characters and tcharacters to accumulate the characters together
22 : : into one string, xml parser hands them to us line by line rather than all in
23 : : one go*/
24 : :
25 : : #include <com/sun/star/xml/sax/XErrorHandler.hpp>
26 : : #include <com/sun/star/xml/sax/XEntityResolver.hpp>
27 : : #include <com/sun/star/xml/sax/InputSource.hpp>
28 : : #include <com/sun/star/xml/sax/XDTDHandler.hpp>
29 : : #include <com/sun/star/xml/sax/XParser.hpp>
30 : : #include <com/sun/star/io/XActiveDataSource.hpp>
31 : : #include <com/sun/star/io/XActiveDataControl.hpp>
32 : : #include <com/sun/star/document/XDocumentProperties.hpp>
33 : : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
34 : : #include <com/sun/star/packages/zip/ZipIOException.hpp>
35 : : #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
36 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
37 : : #include <com/sun/star/container/XNameAccess.hpp>
38 : : #include <com/sun/star/embed/ElementModes.hpp>
39 : : #include <com/sun/star/uno/Any.h>
40 : :
41 : : #include <comphelper/genericpropertyset.hxx>
42 : : #include <comphelper/processfactory.hxx>
43 : : #include <comphelper/servicehelper.hxx>
44 : : #include <comphelper/string.hxx>
45 : : #include <rtl/math.hxx>
46 : : #include <sfx2/frame.hxx>
47 : : #include <sfx2/docfile.hxx>
48 : : #include <osl/diagnose.h>
49 : : #include <svtools/sfxecode.hxx>
50 : : #include <unotools/saveopt.hxx>
51 : : #include <svl/stritem.hxx>
52 : : #include <svl/itemprop.hxx>
53 : : #include <unotools/streamwrap.hxx>
54 : : #include <sax/tools/converter.hxx>
55 : : #include <xmloff/xmlnmspe.hxx>
56 : : #include <xmloff/xmltoken.hxx>
57 : : #include <xmloff/nmspmap.hxx>
58 : : #include <xmloff/attrlist.hxx>
59 : : #include <xmloff/xmluconv.hxx>
60 : : #include <xmloff/xmlmetai.hxx>
61 : : #include <osl/mutex.hxx>
62 : :
63 : : #include <memory>
64 : :
65 : : #include "mathmlimport.hxx"
66 : : #include <starmath.hrc>
67 : : #include <unomodel.hxx>
68 : : #include <document.hxx>
69 : : #include <utility.hxx>
70 : :
71 : : using namespace ::com::sun::star::beans;
72 : : using namespace ::com::sun::star::container;
73 : : using namespace ::com::sun::star::document;
74 : : using namespace ::com::sun::star::lang;
75 : : using namespace ::com::sun::star::uno;
76 : : using namespace ::com::sun::star;
77 : : using namespace ::xmloff::token;
78 : :
79 : : using ::rtl::OUString;
80 : : using ::rtl::OUStringBuffer;
81 : :
82 : : #define IMPORT_SVC_NAME "com.sun.star.xml.XMLImportFilter"
83 : :
84 : : #undef WANTEXCEPT
85 : :
86 : : ////////////////////////////////////////////////////////////
87 : :
88 : : namespace {
89 : : template < typename T >
90 : 0 : T* lcl_popOrZero( ::std::stack<T*> & rStack )
91 : : {
92 [ # # ]: 0 : if (rStack.empty())
93 : 0 : return 0;
94 : 0 : T* pTmp = rStack.top();
95 : 0 : rStack.pop();
96 : 0 : return pTmp;
97 : : }
98 : : }
99 : :
100 : 0 : sal_uLong SmXMLImportWrapper::Import(SfxMedium &rMedium)
101 : : {
102 : 0 : sal_uLong nError = ERRCODE_SFX_DOLOADFAILED;
103 : :
104 : : uno::Reference<lang::XMultiServiceFactory> xServiceFactory(
105 [ # # ]: 0 : comphelper::getProcessServiceFactory());
106 : : OSL_ENSURE(xServiceFactory.is(), "XMLReader::Read: got no service manager");
107 [ # # ]: 0 : if ( !xServiceFactory.is() )
108 : 0 : return nError;
109 : :
110 : : //Make a model component from our SmModel
111 [ # # ]: 0 : uno::Reference< lang::XComponent > xModelComp( xModel, uno::UNO_QUERY );
112 : : OSL_ENSURE( xModelComp.is(), "XMLReader::Read: got no model" );
113 : :
114 : : // try to get an XStatusIndicator from the Medium
115 : 0 : uno::Reference<task::XStatusIndicator> xStatusIndicator;
116 : :
117 : 0 : sal_Bool bEmbedded = sal_False;
118 : 0 : uno::Reference <lang::XUnoTunnel> xTunnel;
119 [ # # ][ # # ]: 0 : xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
120 : : SmModel *pModel = reinterpret_cast<SmModel *>
121 [ # # ][ # # ]: 0 : (xTunnel->getSomething(SmModel::getUnoTunnelId()));
[ # # ]
122 : :
123 : : SmDocShell *pDocShell = pModel ?
124 [ # # ][ # # ]: 0 : static_cast<SmDocShell*>(pModel->GetObjectShell()) : 0;
125 [ # # ]: 0 : if (pDocShell)
126 : : {
127 : : OSL_ENSURE( pDocShell->GetMedium() == &rMedium,
128 : : "different SfxMedium found" );
129 : :
130 [ # # ]: 0 : SfxItemSet* pSet = rMedium.GetItemSet();
131 [ # # ]: 0 : if (pSet)
132 : : {
133 : : const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(
134 [ # # ]: 0 : pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
135 [ # # ]: 0 : if (pItem)
136 [ # # ]: 0 : pItem->GetValue() >>= xStatusIndicator;
137 : : }
138 : :
139 [ # # ]: 0 : if ( SFX_CREATE_MODE_EMBEDDED == pDocShell->GetCreateMode() )
140 : 0 : bEmbedded = sal_True;
141 : : }
142 : :
143 : : comphelper::PropertyMapEntry aInfoMap[] =
144 : : {
145 : : { "PrivateData", sizeof("PrivateData")-1, 0,
146 [ # # ]: 0 : &::getCppuType( (Reference<XInterface> *)0 ),
147 : : beans::PropertyAttribute::MAYBEVOID, 0 },
148 : : { "BaseURI", sizeof("BaseURI")-1, 0,
149 [ # # ]: 0 : &::getCppuType( (OUString *)0 ),
150 : : beans::PropertyAttribute::MAYBEVOID, 0 },
151 : : { "StreamRelPath", sizeof("StreamRelPath")-1, 0,
152 [ # # ]: 0 : &::getCppuType( (OUString *)0 ),
153 : : beans::PropertyAttribute::MAYBEVOID, 0 },
154 : : { "StreamName", sizeof("StreamName")-1, 0,
155 [ # # ]: 0 : &::getCppuType( (OUString *)0 ),
156 : : beans::PropertyAttribute::MAYBEVOID, 0 },
157 : : { NULL, 0, 0, NULL, 0, 0 }
158 : 0 : };
159 : : uno::Reference< beans::XPropertySet > xInfoSet(
160 : : comphelper::GenericPropertySet_CreateInstance(
161 [ # # ]: 0 : new comphelper::PropertySetInfo( aInfoMap ) ) );
162 : :
163 : : // Set base URI
164 : 0 : OUString sPropName( "BaseURI" );
165 [ # # ][ # # ]: 0 : xInfoSet->setPropertyValue( sPropName, makeAny( rMedium.GetBaseURL() ) );
[ # # ][ # # ]
166 : :
167 : 0 : sal_Int32 nSteps=3;
168 [ # # ][ # # ]: 0 : if ( !(rMedium.IsStorage()))
169 : 0 : nSteps = 1;
170 : :
171 : 0 : sal_Int32 nProgressRange(nSteps);
172 [ # # ]: 0 : if (xStatusIndicator.is())
173 : : {
174 [ # # ]: 0 : xStatusIndicator->start(String(SmResId(STR_STATSTR_READING)),
175 [ # # ][ # # ]: 0 : nProgressRange);
[ # # ][ # # ]
[ # # ]
176 : : }
177 : :
178 : 0 : nSteps=0;
179 [ # # ]: 0 : if (xStatusIndicator.is())
180 [ # # ][ # # ]: 0 : xStatusIndicator->setValue(nSteps++);
181 : :
182 [ # # ][ # # ]: 0 : if ( rMedium.IsStorage())
183 : : {
184 : : // TODO/LATER: handle the case of embedded links gracefully
185 [ # # ]: 0 : if ( bEmbedded ) // && !rMedium.GetStorage()->IsRoot() )
186 : : {
187 : 0 : OUString aName( "dummyObjName" );
188 [ # # ][ # # ]: 0 : if ( rMedium.GetItemSet() )
189 : : {
190 : : const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
191 [ # # ][ # # ]: 0 : rMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
192 [ # # ]: 0 : if ( pDocHierarchItem )
193 [ # # ]: 0 : aName = pDocHierarchItem->GetValue();
194 : : }
195 : :
196 [ # # ]: 0 : if ( !aName.isEmpty() )
197 : : {
198 : 0 : sPropName = "StreamRelPath";
199 [ # # ][ # # ]: 0 : xInfoSet->setPropertyValue( sPropName, makeAny( aName ) );
[ # # ]
200 : 0 : }
201 : : }
202 : :
203 [ # # ][ # # ]: 0 : sal_Bool bOASIS = ( SotStorage::GetVersion( rMedium.GetStorage() ) > SOFFICE_FILEFORMAT_60 );
204 [ # # ]: 0 : if (xStatusIndicator.is())
205 [ # # ][ # # ]: 0 : xStatusIndicator->setValue(nSteps++);
206 : :
207 : : sal_uLong nWarn = ReadThroughComponent(
208 : : rMedium.GetStorage(), xModelComp, "meta.xml", "Meta.xml",
209 : : xServiceFactory, xInfoSet,
210 : : (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaImporter"
211 [ # # ][ # # ]: 0 : : "com.sun.star.comp.Math.XMLMetaImporter") );
[ # # ]
212 : :
213 [ # # ]: 0 : if ( nWarn != ERRCODE_IO_BROKENPACKAGE )
214 : : {
215 [ # # ]: 0 : if (xStatusIndicator.is())
216 [ # # ][ # # ]: 0 : xStatusIndicator->setValue(nSteps++);
217 : :
218 : : nWarn = ReadThroughComponent(
219 : : rMedium.GetStorage(), xModelComp, "settings.xml", 0,
220 : : xServiceFactory, xInfoSet,
221 : : (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsImporter"
222 [ # # ][ # # ]: 0 : : "com.sun.star.comp.Math.XMLSettingsImporter" ) );
[ # # ]
223 : :
224 [ # # ]: 0 : if ( nWarn != ERRCODE_IO_BROKENPACKAGE )
225 : : {
226 [ # # ]: 0 : if (xStatusIndicator.is())
227 [ # # ][ # # ]: 0 : xStatusIndicator->setValue(nSteps++);
228 : :
229 : : nError = ReadThroughComponent(
230 : : rMedium.GetStorage(), xModelComp, "content.xml", "Content.xml",
231 [ # # ][ # # ]: 0 : xServiceFactory, xInfoSet, "com.sun.star.comp.Math.XMLImporter" );
232 : : }
233 : : else
234 : 0 : nError = ERRCODE_IO_BROKENPACKAGE;
235 : : }
236 : : else
237 : 0 : nError = ERRCODE_IO_BROKENPACKAGE;
238 : : }
239 : : else
240 : : {
241 : : Reference<io::XInputStream> xInputStream =
242 [ # # ][ # # ]: 0 : new utl::OInputStreamWrapper(rMedium.GetInStream());
[ # # ][ # # ]
243 : :
244 [ # # ]: 0 : if (xStatusIndicator.is())
245 [ # # ][ # # ]: 0 : xStatusIndicator->setValue(nSteps++);
246 : :
247 : : nError = ReadThroughComponent( xInputStream, xModelComp,
248 [ # # ]: 0 : xServiceFactory, xInfoSet, "com.sun.star.comp.Math.XMLImporter", false );
249 : : }
250 : :
251 [ # # ]: 0 : if (xStatusIndicator.is())
252 [ # # ][ # # ]: 0 : xStatusIndicator->end();
253 : 0 : return nError;
254 : : }
255 : :
256 : :
257 : : /// read a component (file + filter version)
258 : 0 : sal_uLong SmXMLImportWrapper::ReadThroughComponent(
259 : : Reference<io::XInputStream> xInputStream,
260 : : Reference<XComponent> xModelComponent,
261 : : Reference<lang::XMultiServiceFactory> & rFactory,
262 : : Reference<beans::XPropertySet> & rPropSet,
263 : : const sal_Char* pFilterName,
264 : : sal_Bool bEncrypted )
265 : : {
266 : 0 : sal_uLong nError = ERRCODE_SFX_DOLOADFAILED;
267 : : OSL_ENSURE(xInputStream.is(), "input stream missing");
268 : : OSL_ENSURE(xModelComponent.is(), "document missing");
269 : : OSL_ENSURE(rFactory.is(), "factory missing");
270 : : OSL_ENSURE(NULL != pFilterName,"I need a service name for the component!");
271 : :
272 : : // prepare ParserInputSrouce
273 [ # # ]: 0 : xml::sax::InputSource aParserInput;
274 [ # # ]: 0 : aParserInput.aInputStream = xInputStream;
275 : :
276 : : // get parser
277 : : Reference< xml::sax::XParser > xParser(
278 [ # # ]: 0 : rFactory->createInstance(
279 : 0 : "com.sun.star.xml.sax.Parser"),
280 [ # # ][ # # ]: 0 : UNO_QUERY );
281 : : OSL_ENSURE( xParser.is(), "Can't create parser" );
282 [ # # ]: 0 : if ( !xParser.is() )
283 : 0 : return nError;
284 : :
285 [ # # ]: 0 : Sequence<Any> aArgs( 1 );
286 [ # # ][ # # ]: 0 : aArgs[0] <<= rPropSet;
287 : :
288 : : // get filter
289 : : Reference< xml::sax::XDocumentHandler > xFilter(
290 [ # # ]: 0 : rFactory->createInstanceWithArguments(
291 : 0 : OUString::createFromAscii(pFilterName), aArgs ),
292 [ # # ][ # # ]: 0 : UNO_QUERY );
293 : : OSL_ENSURE( xFilter.is(), "Can't instantiate filter component." );
294 [ # # ]: 0 : if ( !xFilter.is() )
295 : 0 : return nError;
296 : :
297 : : // connect parser and filter
298 [ # # ][ # # ]: 0 : xParser->setDocumentHandler( xFilter );
299 : :
300 : : // connect model and filter
301 [ # # ]: 0 : Reference < XImporter > xImporter( xFilter, UNO_QUERY );
302 [ # # ][ # # ]: 0 : xImporter->setTargetDocument( xModelComponent );
303 : :
304 : : // finally, parser the stream
305 : : try
306 : : {
307 [ # # ][ # # ]: 0 : xParser->parseStream( aParserInput );
308 : :
309 : 0 : uno::Reference<lang::XUnoTunnel> xFilterTunnel;
310 : : xFilterTunnel = uno::Reference<lang::XUnoTunnel>
311 [ # # ][ # # ]: 0 : ( xFilter, uno::UNO_QUERY );
312 : : SmXMLImport *pFilter = reinterpret_cast< SmXMLImport * >(
313 : : sal::static_int_cast< sal_uIntPtr >(
314 [ # # ][ # # ]: 0 : xFilterTunnel->getSomething( SmXMLImport::getUnoTunnelId() )));
315 [ # # ][ # # ]: 0 : if ( pFilter && pFilter->GetSuccess() )
[ # # ]
316 : 0 : nError = 0;
317 : : }
318 [ # # # # ]: 0 : catch( xml::sax::SAXParseException& r )
319 : : {
320 : : // sax parser sends wrapped exceptions,
321 : : // try to find the original one
322 [ # # ]: 0 : xml::sax::SAXException aSaxEx = *(xml::sax::SAXException*)(&r);
323 : 0 : sal_Bool bTryChild = sal_True;
324 : :
325 [ # # ]: 0 : while( bTryChild )
326 : : {
327 [ # # ]: 0 : xml::sax::SAXException aTmp;
328 [ # # # # ]: 0 : if ( aSaxEx.WrappedException >>= aTmp )
329 [ # # ]: 0 : aSaxEx = aTmp;
330 : : else
331 : 0 : bTryChild = sal_False;
332 [ # # ]: 0 : }
333 : :
334 [ # # ]: 0 : packages::zip::ZipIOException aBrokenPackage;
335 [ # # # # ]: 0 : if ( aSaxEx.WrappedException >>= aBrokenPackage )
336 : 0 : return ERRCODE_IO_BROKENPACKAGE;
337 : :
338 [ # # ]: 0 : if ( bEncrypted )
339 [ # # # # : 0 : nError = ERRCODE_SFX_WRONGPASSWORD;
# # # # ]
340 : : }
341 [ # # # # : 0 : catch( const xml::sax::SAXException& r )
# # # #
# ]
342 : : {
343 [ # # ]: 0 : packages::zip::ZipIOException aBrokenPackage;
344 [ # # # # ]: 0 : if ( r.WrappedException >>= aBrokenPackage )
345 : 0 : return ERRCODE_IO_BROKENPACKAGE;
346 : :
347 [ # # ]: 0 : if ( bEncrypted )
348 [ # # # # ]: 0 : nError = ERRCODE_SFX_WRONGPASSWORD;
349 : : }
350 [ # # ]: 0 : catch( packages::zip::ZipIOException& )
351 : : {
352 : 0 : nError = ERRCODE_IO_BROKENPACKAGE;
353 : : }
354 [ # # ]: 0 : catch( io::IOException& )
355 : : {
356 : : }
357 : :
358 [ # # ][ # # ]: 0 : return nError;
359 : : }
360 : :
361 : :
362 : 0 : sal_uLong SmXMLImportWrapper::ReadThroughComponent(
363 : : const uno::Reference< embed::XStorage >& xStorage,
364 : : Reference<XComponent> xModelComponent,
365 : : const sal_Char* pStreamName,
366 : : const sal_Char* pCompatibilityStreamName,
367 : : Reference<lang::XMultiServiceFactory> & rFactory,
368 : : Reference<beans::XPropertySet> & rPropSet,
369 : : const sal_Char* pFilterName )
370 : : {
371 : : OSL_ENSURE(xStorage.is(), "Need storage!");
372 : : OSL_ENSURE(NULL != pStreamName, "Please, please, give me a name!");
373 : :
374 : : // open stream (and set parser input)
375 : 0 : OUString sStreamName = OUString::createFromAscii(pStreamName);
376 [ # # ]: 0 : uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY );
377 [ # # ][ # # ]: 0 : if ( !xAccess->hasByName(sStreamName) || !xStorage->isStreamElement(sStreamName) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
378 : : {
379 : : // stream name not found! Then try the compatibility name.
380 : : // do we even have an alternative name?
381 [ # # ]: 0 : if ( pCompatibilityStreamName )
382 : 0 : sStreamName = OUString::createFromAscii(pCompatibilityStreamName);
383 : : }
384 : :
385 : : // get input stream
386 : : try
387 : : {
388 [ # # ][ # # ]: 0 : uno::Reference < io::XStream > xEventsStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
389 : :
390 : : // determine if stream is encrypted or not
391 [ # # ]: 0 : uno::Reference < beans::XPropertySet > xProps( xEventsStream, uno::UNO_QUERY );
392 [ # # ][ # # ]: 0 : Any aAny = xProps->getPropertyValue( "Encrypted" );
393 : 0 : sal_Bool bEncrypted = sal_False;
394 [ # # ][ # # ]: 0 : if ( aAny.getValueType() == ::getBooleanCppuType() )
395 : 0 : aAny >>= bEncrypted;
396 : :
397 : : // set Base URL
398 [ # # ]: 0 : if ( rPropSet.is() )
399 : : {
400 : 0 : OUString sPropName( "StreamName");
401 [ # # ][ # # ]: 0 : rPropSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
[ # # ]
402 : : }
403 : :
404 : :
405 [ # # ][ # # ]: 0 : Reference < io::XInputStream > xStream = xEventsStream->getInputStream();
406 [ # # ]: 0 : return ReadThroughComponent( xStream, xModelComponent, rFactory, rPropSet, pFilterName, bEncrypted );
[ # # # # ]
407 : : }
408 [ # # ]: 0 : catch ( packages::WrongPasswordException& )
409 : : {
410 : 0 : return ERRCODE_SFX_WRONGPASSWORD;
411 : : }
412 [ # # ]: 0 : catch( packages::zip::ZipIOException& )
413 : : {
414 : 0 : return ERRCODE_IO_BROKENPACKAGE;
415 : : }
416 [ # # ]: 0 : catch ( uno::Exception& )
417 : : {
418 : : }
419 : :
420 : 0 : return ERRCODE_SFX_DOLOADFAILED;
421 : : }
422 : :
423 : : ////////////////////////////////////////////////////////////
424 : :
425 : 12 : SmXMLImport::SmXMLImport(
426 : : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
427 : : sal_uInt16 nImportFlags)
428 : : : SvXMLImport( xServiceFactory, nImportFlags ),
429 : : pPresLayoutElemTokenMap(0),
430 : : pPresLayoutAttrTokenMap(0),
431 : : pFencedAttrTokenMap(0),
432 : : pOperatorAttrTokenMap(0),
433 : : pAnnotationAttrTokenMap(0),
434 : : pPresElemTokenMap(0),
435 : : pPresScriptEmptyElemTokenMap(0),
436 : : pPresTableElemTokenMap(0),
437 : : pColorTokenMap(0),
438 [ + - ][ + - ]: 12 : bSuccess(sal_False)
[ + - ]
439 : : {
440 : 12 : }
441 : :
442 : : namespace
443 : : {
444 : : class theSmXMLImportUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSmXMLImportUnoTunnelId> {};
445 : : }
446 : :
447 : 0 : const uno::Sequence< sal_Int8 > & SmXMLImport::getUnoTunnelId() throw()
448 : : {
449 : 0 : return theSmXMLImportUnoTunnelId::get().getSeq();
450 : : }
451 : :
452 : 36 : OUString SAL_CALL SmXMLImport_getImplementationName() throw()
453 : : {
454 : 36 : return OUString( "com.sun.star.comp.Math.XMLImporter" );
455 : : }
456 : :
457 : 2 : uno::Sequence< OUString > SAL_CALL SmXMLImport_getSupportedServiceNames()
458 : : throw()
459 : : {
460 : 2 : const OUString aServiceName( IMPORT_SVC_NAME );
461 [ + - ]: 2 : const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
462 : 2 : return aSeq;
463 : : }
464 : :
465 : 4 : uno::Reference< uno::XInterface > SAL_CALL SmXMLImport_createInstance(
466 : : const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
467 : : throw( uno::Exception )
468 : : {
469 [ + - ][ + - ]: 4 : return (cppu::OWeakObject*)new SmXMLImport(rSMgr, IMPORT_ALL);
470 : : }
471 : :
472 : : ////////////////////////////////////////////////////////////
473 : :
474 : 32 : OUString SAL_CALL SmXMLImportMeta_getImplementationName() throw()
475 : : {
476 : 32 : return OUString( "com.sun.star.comp.Math.XMLOasisMetaImporter" );
477 : : }
478 : :
479 : 2 : uno::Sequence< OUString > SAL_CALL SmXMLImportMeta_getSupportedServiceNames()
480 : : throw()
481 : : {
482 : 2 : const OUString aServiceName( IMPORT_SVC_NAME );
483 [ + - ]: 2 : const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
484 : 2 : return aSeq;
485 : : }
486 : :
487 : 4 : uno::Reference< uno::XInterface > SAL_CALL SmXMLImportMeta_createInstance(
488 : : const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
489 : : throw( uno::Exception )
490 : : {
491 [ + - ][ + - ]: 4 : return (cppu::OWeakObject*)new SmXMLImport( rSMgr, IMPORT_META );
492 : : }
493 : :
494 : : ////////////////////////////////////////////////////////////
495 : :
496 : 28 : OUString SAL_CALL SmXMLImportSettings_getImplementationName() throw()
497 : : {
498 : 28 : return OUString( "com.sun.star.comp.Math.XMLOasisSettingsImporter" );
499 : : }
500 : :
501 : 2 : uno::Sequence< OUString > SAL_CALL SmXMLImportSettings_getSupportedServiceNames()
502 : : throw()
503 : : {
504 : 2 : const OUString aServiceName( IMPORT_SVC_NAME );
505 [ + - ]: 2 : const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
506 : 2 : return aSeq;
507 : : }
508 : :
509 : 4 : uno::Reference< uno::XInterface > SAL_CALL SmXMLImportSettings_createInstance(
510 : : const uno::Reference< lang::XMultiServiceFactory > & rSMgr)
511 : : throw( uno::Exception )
512 : : {
513 [ + - ][ + - ]: 4 : return (cppu::OWeakObject*)new SmXMLImport( rSMgr, IMPORT_SETTINGS );
514 : : }
515 : :
516 : : ////////////////////////////////////////////////////////////
517 : :
518 : : // XServiceInfo
519 : : // override empty method from parent class
520 : 0 : rtl::OUString SAL_CALL SmXMLImport::getImplementationName()
521 : : throw(uno::RuntimeException)
522 : : {
523 : 0 : OUString aTxt;
524 [ # # # ]: 0 : switch( getImportFlags() )
525 : : {
526 : : case IMPORT_META:
527 : 0 : aTxt = SmXMLImportMeta_getImplementationName();
528 : 0 : break;
529 : : case IMPORT_SETTINGS:
530 : 0 : aTxt = SmXMLImportSettings_getImplementationName();
531 : 0 : break;
532 : : case IMPORT_ALL:
533 : : default:
534 : 0 : aTxt = SmXMLImport_getImplementationName();
535 : 0 : break;
536 : : }
537 : 0 : return aTxt;
538 : : }
539 : :
540 : :
541 : 0 : sal_Int64 SAL_CALL SmXMLImport::getSomething(
542 : : const uno::Sequence< sal_Int8 >&rId )
543 : : throw(uno::RuntimeException)
544 : : {
545 [ # # # # ]: 0 : if ( rId.getLength() == 16 &&
[ # # ]
546 : 0 : 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
547 : 0 : rId.getConstArray(), 16 ) )
548 : 0 : return sal::static_int_cast< sal_Int64 >(reinterpret_cast< sal_uIntPtr >(this));
549 : :
550 : 0 : return SvXMLImport::getSomething( rId );
551 : : }
552 : :
553 : 0 : void SmXMLImport::endDocument(void)
554 : : throw(xml::sax::SAXException, uno::RuntimeException)
555 : : {
556 : : //Set the resulted tree into the SmDocShell where it belongs
557 : : SmNode *pTree;
558 [ # # ][ # # ]: 0 : if (NULL != (pTree = GetTree()))
559 : : {
560 : 0 : uno::Reference <frame::XModel> xModel = GetModel();
561 : 0 : uno::Reference <lang::XUnoTunnel> xTunnel;
562 [ # # ][ # # ]: 0 : xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
563 : : SmModel *pModel = reinterpret_cast<SmModel *>
564 [ # # ][ # # ]: 0 : (xTunnel->getSomething(SmModel::getUnoTunnelId()));
[ # # ]
565 : :
566 [ # # ]: 0 : if (pModel)
567 : : {
568 : : SmDocShell *pDocShell =
569 [ # # ]: 0 : static_cast<SmDocShell*>(pModel->GetObjectShell());
570 : 0 : pDocShell->SetFormulaTree(pTree);
571 [ # # ]: 0 : if (0 == aText.Len()) //If we picked up no annotation text
572 : : {
573 : : //Make up some editable text
574 [ # # ]: 0 : aText = pDocShell->GetText();
575 [ # # ]: 0 : pTree->CreateTextFromNode(aText);
576 [ # # ][ # # ]: 0 : aText = comphelper::string::stripEnd(aText, ' ');
[ # # ]
577 : : }
578 [ # # ][ # # ]: 0 : pDocShell->SetText( String() );
[ # # ]
579 : :
580 : : // Convert symbol names
581 : 0 : SmParser &rParser = pDocShell->GetParser();
582 : 0 : bool bVal = rParser.IsImportSymbolNames();
583 : 0 : rParser.SetImportSymbolNames( true );
584 [ # # ]: 0 : SmNode *pTmpTree = rParser.Parse( aText );
585 [ # # ]: 0 : aText = rParser.GetText();
586 [ # # ][ # # ]: 0 : delete pTmpTree;
587 : 0 : rParser.SetImportSymbolNames( bVal );
588 : :
589 [ # # ]: 0 : pDocShell->SetText( aText );
590 : : }
591 : : OSL_ENSURE(pModel,"So there *was* a uno problem after all");
592 : :
593 : 0 : bSuccess = sal_True;
594 : : }
595 : :
596 [ # # ]: 0 : SvXMLImport::endDocument();
597 : 0 : }
598 : :
599 : : ////////////////////////////////////////////////////////////
600 : :
601 [ # # ]: 0 : class SmXMLImportContext: public SvXMLImportContext
602 : : {
603 : : public:
604 : 0 : SmXMLImportContext( SmXMLImport &rImport, sal_uInt16 nPrfx,
605 : : const OUString& rLName)
606 : 0 : : SvXMLImportContext(rImport, nPrfx, rLName) {}
607 : :
608 : : const SmXMLImport& GetSmImport() const
609 : : {
610 : : return (const SmXMLImport&)GetImport();
611 : : }
612 : :
613 : 0 : SmXMLImport& GetSmImport()
614 : : {
615 : 0 : return (SmXMLImport&)GetImport();
616 : : }
617 : :
618 : : virtual void TCharacters(const OUString & /*rChars*/);
619 : : virtual void Characters(const OUString &rChars);
620 : : virtual SvXMLImportContext *CreateChildContext(sal_uInt16 /*nPrefix*/, const OUString& /*rLocalName*/, const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/);
621 : : };
622 : :
623 : 0 : void SmXMLImportContext::TCharacters(const OUString & /*rChars*/)
624 : : {
625 : 0 : }
626 : :
627 : 0 : void SmXMLImportContext::Characters(const OUString &rChars)
628 : : {
629 : : /*
630 : : Whitespace occurring within the content of token elements is "trimmed"
631 : : from the ends (i.e. all whitespace at the beginning and end of the
632 : : content is removed), and "collapsed" internally (i.e. each sequence of
633 : : 1 or more whitespace characters is replaced with one blank character).
634 : : */
635 : : //collapsing not done yet!
636 : 0 : const OUString &rChars2 = rChars.trim();
637 [ # # ]: 0 : if (!rChars2.isEmpty())
638 [ # # ]: 0 : TCharacters(rChars2/*.collapse()*/);
639 : 0 : }
640 : :
641 : 0 : SvXMLImportContext * SmXMLImportContext::CreateChildContext(sal_uInt16 /*nPrefix*/,
642 : : const OUString& /*rLocalName*/,
643 : : const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/)
644 : : {
645 : 0 : return 0;
646 : : }
647 : :
648 : : ////////////////////////////////////////////////////////////
649 : :
650 [ # # ]: 0 : struct SmXMLContext_Helper
651 : : {
652 : : sal_Int8 nIsBold;
653 : : sal_Int8 nIsItalic;
654 : : double nFontSize;
655 : : sal_Bool bFontNodeNeeded;
656 : : OUString sFontFamily;
657 : : OUString sColor;
658 : :
659 : : SmXMLImportContext rContext;
660 : :
661 : 0 : SmXMLContext_Helper(SmXMLImportContext &rImport) :
662 [ # # ]: 0 : nIsBold(-1), nIsItalic(-1), nFontSize(0.0), rContext(rImport) {}
663 : :
664 : : void RetrieveAttrs(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
665 : : void ApplyAttrs();
666 : : };
667 : :
668 : 0 : void SmXMLContext_Helper::RetrieveAttrs(const uno::Reference<
669 : : xml::sax::XAttributeList > & xAttrList )
670 : : {
671 : 0 : sal_Int8 nOldIsBold=nIsBold;
672 : 0 : sal_Int8 nOldIsItalic=nIsItalic;
673 : 0 : double nOldFontSize=nFontSize;
674 [ # # ][ # # ]: 0 : sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
[ # # ]
675 : 0 : OUString sOldFontFamily = sFontFamily;
676 [ # # ]: 0 : for (sal_Int16 i=0;i<nAttrCount;i++)
677 : : {
678 [ # # ][ # # ]: 0 : OUString sAttrName = xAttrList->getNameByIndex(i);
679 : 0 : OUString aLocalName;
680 : 0 : sal_uInt16 nPrefix = rContext.GetSmImport().GetNamespaceMap().
681 [ # # ]: 0 : GetKeyByAttrName(sAttrName,&aLocalName);
682 [ # # ][ # # ]: 0 : OUString sValue = xAttrList->getValueByIndex(i);
683 : : const SvXMLTokenMap &rAttrTokenMap =
684 [ # # ]: 0 : rContext.GetSmImport().GetPresLayoutAttrTokenMap();
685 [ # # ][ # # : 0 : switch(rAttrTokenMap.Get(nPrefix,aLocalName))
# # # # ]
686 : : {
687 : : case XML_TOK_FONTWEIGHT:
688 [ # # ]: 0 : nIsBold = sValue.equals(GetXMLToken(XML_BOLD));
689 : 0 : break;
690 : : case XML_TOK_FONTSTYLE:
691 [ # # ]: 0 : nIsItalic = sValue.equals(GetXMLToken(XML_ITALIC));
692 : 0 : break;
693 : : case XML_TOK_FONTSIZE:
694 [ # # ]: 0 : ::sax::Converter::convertDouble(nFontSize, sValue);
695 : 0 : rContext.GetSmImport().GetMM100UnitConverter().
696 [ # # ]: 0 : SetXMLMeasureUnit(util::MeasureUnit::POINT);
697 [ # # ][ # # ]: 0 : if (-1 == sValue.indexOf(GetXMLToken(XML_UNIT_PT)))
698 : : {
699 [ # # ]: 0 : if (-1 == sValue.indexOf('%'))
700 : 0 : nFontSize=0.0;
701 : : else
702 : : {
703 : 0 : rContext.GetSmImport().GetMM100UnitConverter().
704 [ # # ]: 0 : SetXMLMeasureUnit(util::MeasureUnit::PERCENT);
705 : : }
706 : : }
707 : 0 : break;
708 : : case XML_TOK_FONTFAMILY:
709 : 0 : sFontFamily = sValue;
710 : 0 : break;
711 : : case XML_TOK_COLOR:
712 : 0 : sColor = sValue;
713 : 0 : break;
714 : : default:
715 : 0 : break;
716 : : }
717 : 0 : }
718 : :
719 [ # # ][ # # ]: 0 : if ((nOldIsBold!=nIsBold) || (nOldIsItalic!=nIsItalic) ||
[ # # # #
# # ][ # # ]
720 : 0 : (nOldFontSize!=nFontSize) || (sOldFontFamily!=sFontFamily)
721 : 0 : || !sColor.isEmpty())
722 : 0 : bFontNodeNeeded=sal_True;
723 : : else
724 : 0 : bFontNodeNeeded=sal_False;
725 : 0 : }
726 : :
727 : 0 : void SmXMLContext_Helper::ApplyAttrs()
728 : : {
729 : 0 : SmNodeStack &rNodeStack = rContext.GetSmImport().GetNodeStack();
730 : :
731 [ # # ]: 0 : if (bFontNodeNeeded)
732 : : {
733 [ # # ]: 0 : SmToken aToken;
734 : 0 : aToken.cMathChar = '\0';
735 : 0 : aToken.nGroup = 0;
736 : 0 : aToken.nLevel = 5;
737 : :
738 [ # # ]: 0 : if (nIsBold != -1)
739 : : {
740 [ # # ]: 0 : if (nIsBold)
741 : 0 : aToken.eType = TBOLD;
742 : : else
743 : 0 : aToken.eType = TNBOLD;
744 : : SmStructureNode *pFontNode = static_cast<SmStructureNode *>
745 [ # # ][ # # ]: 0 : (new SmFontNode(aToken));
746 [ # # ][ # # ]: 0 : pFontNode->SetSubNodes(0,lcl_popOrZero(rNodeStack));
747 [ # # ]: 0 : rNodeStack.push(pFontNode);
748 : : }
749 [ # # ]: 0 : if (nIsItalic != -1)
750 : : {
751 [ # # ]: 0 : if (nIsItalic)
752 : 0 : aToken.eType = TITALIC;
753 : : else
754 : 0 : aToken.eType = TNITALIC;
755 : : SmStructureNode *pFontNode = static_cast<SmStructureNode *>
756 [ # # ][ # # ]: 0 : (new SmFontNode(aToken));
757 [ # # ][ # # ]: 0 : pFontNode->SetSubNodes(0,lcl_popOrZero(rNodeStack));
758 [ # # ]: 0 : rNodeStack.push(pFontNode);
759 : : }
760 [ # # ]: 0 : if (nFontSize != 0.0)
761 : : {
762 : 0 : aToken.eType = TSIZE;
763 [ # # ][ # # ]: 0 : SmFontNode *pFontNode = new SmFontNode(aToken);
764 : :
765 [ # # ]: 0 : if (util::MeasureUnit::PERCENT == rContext.GetSmImport()
766 [ # # ]: 0 : .GetMM100UnitConverter().GetXMLMeasureUnit())
767 : : {
768 [ # # ]: 0 : if (nFontSize < 100.00)
769 : : pFontNode->SetSizeParameter(Fraction(100.00/nFontSize),
770 [ # # ][ # # ]: 0 : FNTSIZ_DIVIDE);
771 : : else
772 : : pFontNode->SetSizeParameter(Fraction(nFontSize/100.00),
773 [ # # ][ # # ]: 0 : FNTSIZ_MULTIPLY);
774 : : }
775 : : else
776 [ # # ][ # # ]: 0 : pFontNode->SetSizeParameter(Fraction(nFontSize),FNTSIZ_ABSOLUT);
777 : :
778 [ # # ][ # # ]: 0 : pFontNode->SetSubNodes(0,lcl_popOrZero(rNodeStack));
779 [ # # ]: 0 : rNodeStack.push(pFontNode);
780 : : }
781 [ # # ]: 0 : if (!sFontFamily.isEmpty())
782 : : {
783 [ # # ][ # # ]: 0 : if (sFontFamily.equalsIgnoreAsciiCase(GetXMLToken(XML_FIXED)))
784 : 0 : aToken.eType = TFIXED;
785 [ # # ]: 0 : else if (sFontFamily.equalsIgnoreAsciiCase("sans"))
786 : 0 : aToken.eType = TSANS;
787 [ # # ]: 0 : else if (sFontFamily.equalsIgnoreAsciiCase("serif"))
788 : 0 : aToken.eType = TSERIF;
789 : : else //Just give up, we need to extend our font mechanism to be
790 : : //more general
791 : 0 : return;
792 : :
793 [ # # ]: 0 : aToken.aText = sFontFamily;
794 [ # # ][ # # ]: 0 : SmFontNode *pFontNode = new SmFontNode(aToken);
795 [ # # ][ # # ]: 0 : pFontNode->SetSubNodes(0,lcl_popOrZero(rNodeStack));
796 [ # # ]: 0 : rNodeStack.push(pFontNode);
797 : : }
798 [ # # ]: 0 : if (!sColor.isEmpty())
799 : : {
800 : : //Again we can only handle a small set of colours in
801 : : //StarMath for now.
802 : : const SvXMLTokenMap& rTokenMap =
803 [ # # ]: 0 : rContext.GetSmImport().GetColorTokenMap();
804 : : aToken.eType = static_cast<SmTokenType>(rTokenMap.Get(
805 [ # # ]: 0 : XML_NAMESPACE_MATH, sColor));
806 [ # # ]: 0 : if (aToken.eType != -1)
807 : : {
808 [ # # ][ # # ]: 0 : SmFontNode *pFontNode = new SmFontNode(aToken);
809 [ # # ][ # # ]: 0 : pFontNode->SetSubNodes(0,lcl_popOrZero(rNodeStack));
810 [ # # ]: 0 : rNodeStack.push(pFontNode);
811 : : }
812 [ # # ][ # # ]: 0 : }
813 : :
814 : : }
815 : : }
816 : :
817 : : ////////////////////////////////////////////////////////////
818 : :
819 [ # # ]: 0 : class SmXMLDocContext_Impl : public SmXMLImportContext
820 : : {
821 : : public:
822 : 0 : SmXMLDocContext_Impl( SmXMLImport &rImport, sal_uInt16 nPrfx,
823 : : const OUString& rLName)
824 : 0 : : SmXMLImportContext(rImport,nPrfx,rLName) {}
825 : :
826 : : virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList);
827 : :
828 : : void EndElement();
829 : : };
830 : :
831 : : ////////////////////////////////////////////////////////////
832 : :
833 : : /*avert thy gaze from the proginator*/
834 [ # # ]: 0 : class SmXMLRowContext_Impl : public SmXMLDocContext_Impl
835 : : {
836 : : protected:
837 : : sal_uLong nElementCount;
838 : :
839 : : public:
840 : 0 : SmXMLRowContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
841 : : const OUString& rLName)
842 : 0 : : SmXMLDocContext_Impl(rImport,nPrefix,rLName)
843 : 0 : { nElementCount = GetSmImport().GetNodeStack().size(); }
844 : :
845 : : virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList);
846 : :
847 : : SvXMLImportContext *StrictCreateChildContext(sal_uInt16 nPrefix,
848 : : const OUString& rLocalName,
849 : : const uno::Reference< xml::sax::XAttributeList > &xAttrList);
850 : :
851 : : void EndElement();
852 : : };
853 : :
854 : : ////////////////////////////////////////////////////////////
855 : :
856 [ # # ]: 0 : class SmXMLFracContext_Impl : public SmXMLRowContext_Impl
857 : : {
858 : : public:
859 : 0 : SmXMLFracContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
860 : : const OUString& rLName)
861 : 0 : : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
862 : :
863 : : void EndElement();
864 : : };
865 : :
866 : : ////////////////////////////////////////////////////////////
867 : :
868 [ # # ]: 0 : class SmXMLSqrtContext_Impl : public SmXMLRowContext_Impl
869 : : {
870 : : public:
871 : 0 : SmXMLSqrtContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
872 : : const OUString& rLName)
873 : 0 : : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
874 : :
875 : : void EndElement();
876 : : };
877 : :
878 : : ////////////////////////////////////////////////////////////
879 : :
880 [ # # ]: 0 : class SmXMLRootContext_Impl : public SmXMLRowContext_Impl
881 : : {
882 : : public:
883 : 0 : SmXMLRootContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
884 : : const OUString& rLName)
885 : 0 : : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
886 : :
887 : : void EndElement();
888 : : };
889 : :
890 : : ////////////////////////////////////////////////////////////
891 : :
892 [ # # ][ # # ]: 0 : class SmXMLStyleContext_Impl : public SmXMLRowContext_Impl
893 : : {
894 : : protected:
895 : : SmXMLContext_Helper aStyleHelper;
896 : :
897 : : public:
898 : : /*Right now the style tag is completely ignored*/
899 : 0 : SmXMLStyleContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
900 : : const OUString& rLName) : SmXMLRowContext_Impl(rImport,nPrefix,rLName),
901 [ # # ]: 0 : aStyleHelper(*this) {}
902 : :
903 : : void EndElement();
904 : : void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
905 : : };
906 : :
907 : 0 : void SmXMLStyleContext_Impl::StartElement(const uno::Reference<
908 : : xml::sax::XAttributeList > & xAttrList )
909 : : {
910 : 0 : aStyleHelper.RetrieveAttrs(xAttrList);
911 : 0 : }
912 : :
913 : :
914 : 0 : void SmXMLStyleContext_Impl::EndElement()
915 : : {
916 : : /*
917 : : <mstyle> accepts any number of arguments; if this number is not 1, its
918 : : contents are treated as a single "inferred <mrow>" containing its
919 : : arguments
920 : : */
921 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
922 [ # # ]: 0 : if (rNodeStack.size() - nElementCount > 1)
923 : 0 : SmXMLRowContext_Impl::EndElement();
924 : 0 : aStyleHelper.ApplyAttrs();
925 : 0 : }
926 : :
927 : : ////////////////////////////////////////////////////////////
928 : :
929 [ # # ]: 0 : class SmXMLPaddedContext_Impl : public SmXMLRowContext_Impl
930 : : {
931 : : public:
932 : : /*Right now the style tag is completely ignored*/
933 : 0 : SmXMLPaddedContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
934 : : const OUString& rLName)
935 : 0 : : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
936 : :
937 : : void EndElement();
938 : : };
939 : :
940 : 0 : void SmXMLPaddedContext_Impl::EndElement()
941 : : {
942 : : /*
943 : : <mpadded> accepts any number of arguments; if this number is not 1, its
944 : : contents are treated as a single "inferred <mrow>" containing its
945 : : arguments
946 : : */
947 [ # # ]: 0 : if (GetSmImport().GetNodeStack().size() - nElementCount > 1)
948 : 0 : SmXMLRowContext_Impl::EndElement();
949 : 0 : }
950 : :
951 : : ////////////////////////////////////////////////////////////
952 : :
953 [ # # ]: 0 : class SmXMLPhantomContext_Impl : public SmXMLRowContext_Impl
954 : : {
955 : : public:
956 : : /*Right now the style tag is completely ignored*/
957 : 0 : SmXMLPhantomContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
958 : : const OUString& rLName)
959 : 0 : : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
960 : :
961 : : void EndElement();
962 : : };
963 : :
964 : 0 : void SmXMLPhantomContext_Impl::EndElement()
965 : : {
966 : : /*
967 : : <mphantom> accepts any number of arguments; if this number is not 1, its
968 : : contents are treated as a single "inferred <mrow>" containing its
969 : : arguments
970 : : */
971 [ # # ]: 0 : if (GetSmImport().GetNodeStack().size() - nElementCount > 1)
972 [ # # ]: 0 : SmXMLRowContext_Impl::EndElement();
973 : :
974 [ # # ]: 0 : SmToken aToken;
975 : 0 : aToken.cMathChar = '\0';
976 : 0 : aToken.nGroup = 0;
977 : 0 : aToken.nLevel = 5;
978 : 0 : aToken.eType = TPHANTOM;
979 : :
980 : : SmStructureNode *pPhantom = static_cast<SmStructureNode *>
981 [ # # ][ # # ]: 0 : (new SmFontNode(aToken));
982 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
983 [ # # ][ # # ]: 0 : pPhantom->SetSubNodes(0,lcl_popOrZero(rNodeStack));
984 [ # # ][ # # ]: 0 : rNodeStack.push(pPhantom);
985 : 0 : }
986 : :
987 : : ////////////////////////////////////////////////////////////
988 : :
989 [ # # ]: 0 : class SmXMLFencedContext_Impl : public SmXMLRowContext_Impl
990 : : {
991 : : protected:
992 : : sal_Unicode cBegin;
993 : : sal_Unicode cEnd;
994 : :
995 : : public:
996 : 0 : SmXMLFencedContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
997 : : const OUString& rLName)
998 : : : SmXMLRowContext_Impl(rImport,nPrefix,rLName),
999 : 0 : cBegin('('), cEnd(')') {}
1000 : :
1001 : : void StartElement(const uno::Reference< xml::sax::XAttributeList > & xAttrList );
1002 : : void EndElement();
1003 : : };
1004 : :
1005 : :
1006 : 0 : void SmXMLFencedContext_Impl::StartElement(const uno::Reference<
1007 : : xml::sax::XAttributeList > & xAttrList )
1008 : : {
1009 [ # # ]: 0 : sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1010 [ # # ]: 0 : for (sal_Int16 i=0;i<nAttrCount;i++)
1011 : : {
1012 [ # # ][ # # ]: 0 : OUString sAttrName = xAttrList->getNameByIndex(i);
1013 : 0 : OUString aLocalName;
1014 : 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
1015 [ # # ]: 0 : GetKeyByAttrName(sAttrName,&aLocalName);
1016 [ # # ][ # # ]: 0 : OUString sValue = xAttrList->getValueByIndex(i);
1017 : : const SvXMLTokenMap &rAttrTokenMap =
1018 [ # # ]: 0 : GetSmImport().GetFencedAttrTokenMap();
1019 [ # # ]: 0 : switch(rAttrTokenMap.Get(nPrefix,aLocalName))
[ # # # ]
1020 : : {
1021 : : //temp, starmath cannot handle multichar brackets (I think)
1022 : : case XML_TOK_OPEN:
1023 : 0 : cBegin = sValue[0];
1024 : 0 : break;
1025 : : case XML_TOK_CLOSE:
1026 : 0 : cEnd = sValue[0];
1027 : 0 : break;
1028 : : default:
1029 : : /*Go to superclass*/
1030 : 0 : break;
1031 : : }
1032 : 0 : }
1033 : 0 : }
1034 : :
1035 : :
1036 : 0 : void SmXMLFencedContext_Impl::EndElement()
1037 : : {
1038 [ # # ]: 0 : SmToken aToken;
1039 : 0 : aToken.cMathChar = '\0';
1040 : 0 : aToken.nGroup = 0;
1041 [ # # ]: 0 : aToken.aText = ',';
1042 : 0 : aToken.eType = TLEFT;
1043 : 0 : aToken.nLevel = 5;
1044 : :
1045 : 0 : aToken.eType = TLPARENT;
1046 : 0 : aToken.cMathChar = cBegin;
1047 [ # # ][ # # ]: 0 : SmStructureNode *pSNode = new SmBraceNode(aToken);
1048 [ # # ][ # # ]: 0 : SmNode *pLeft = new SmMathSymbolNode(aToken);
1049 : :
1050 : 0 : aToken.cMathChar = cEnd;
1051 : 0 : aToken.eType = TRPARENT;
1052 [ # # ][ # # ]: 0 : SmNode *pRight = new SmMathSymbolNode(aToken);
1053 : :
1054 [ # # ]: 0 : SmNodeArray aRelationArray;
1055 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
1056 : :
1057 : 0 : aToken.cMathChar = '\0';
1058 [ # # ]: 0 : aToken.aText = ',';
1059 : 0 : aToken.eType = TIDENT;
1060 : :
1061 : 0 : sal_uLong i = rNodeStack.size() - nElementCount;
1062 [ # # ]: 0 : if (rNodeStack.size() - nElementCount > 1)
1063 : 0 : i += rNodeStack.size() - 1 - nElementCount;
1064 [ # # ]: 0 : aRelationArray.resize(i);
1065 [ # # ]: 0 : while (rNodeStack.size() > nElementCount)
1066 : : {
1067 [ # # ]: 0 : aRelationArray[--i] = rNodeStack.top();
1068 [ # # ]: 0 : rNodeStack.pop();
1069 [ # # ][ # # ]: 0 : if (i > 1 && rNodeStack.size() > 1)
[ # # ]
1070 [ # # ][ # # ]: 0 : aRelationArray[--i] = new SmGlyphSpecialNode(aToken);
1071 : : }
1072 : :
1073 [ # # ]: 0 : SmToken aDummy;
1074 [ # # ][ # # ]: 0 : SmStructureNode *pBody = new SmExpressionNode(aDummy);
1075 [ # # ]: 0 : pBody->SetSubNodes(aRelationArray);
1076 : :
1077 : :
1078 [ # # ]: 0 : pSNode->SetSubNodes(pLeft,pBody,pRight);
1079 : 0 : pSNode->SetScaleMode(SCALE_HEIGHT);
1080 [ # # ][ # # ]: 0 : GetSmImport().GetNodeStack().push(pSNode);
[ # # ]
1081 : 0 : }
1082 : :
1083 : :
1084 : : ////////////////////////////////////////////////////////////
1085 : :
1086 [ # # ]: 0 : class SmXMLErrorContext_Impl : public SmXMLRowContext_Impl
1087 : : {
1088 : : public:
1089 : 0 : SmXMLErrorContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1090 : : const OUString& rLName)
1091 : 0 : : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
1092 : :
1093 : : void EndElement();
1094 : : };
1095 : :
1096 : 0 : void SmXMLErrorContext_Impl::EndElement()
1097 : : {
1098 : : /*Right now the error tag is completely ignored, what
1099 : : can I do with it in starmath, ?, maybe we need a
1100 : : report window ourselves, do a test for validity of
1101 : : the xml input, use merrors, and then generate
1102 : : the markup inside the merror with a big red colour
1103 : : of something. For now just throw them all away.
1104 : : */
1105 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
1106 [ # # ]: 0 : while (rNodeStack.size() > nElementCount)
1107 : : {
1108 [ # # ]: 0 : delete rNodeStack.top();
1109 : 0 : rNodeStack.pop();
1110 : : }
1111 : 0 : }
1112 : :
1113 : : ////////////////////////////////////////////////////////////
1114 : :
1115 [ # # ][ # # ]: 0 : class SmXMLNumberContext_Impl : public SmXMLImportContext
1116 : : {
1117 : : protected:
1118 : : SmToken aToken;
1119 : :
1120 : : public:
1121 : 0 : SmXMLNumberContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1122 : : const OUString& rLName)
1123 [ # # ]: 0 : : SmXMLImportContext(rImport,nPrefix,rLName)
1124 : : {
1125 : 0 : aToken.cMathChar = '\0';
1126 : 0 : aToken.nGroup = 0;
1127 : 0 : aToken.nLevel = 5;
1128 : 0 : aToken.eType = TNUMBER;
1129 : 0 : }
1130 : :
1131 : : virtual void TCharacters(const OUString &rChars);
1132 : :
1133 : : void EndElement();
1134 : : };
1135 : :
1136 : 0 : void SmXMLNumberContext_Impl::TCharacters(const OUString &rChars)
1137 : : {
1138 : 0 : aToken.aText = rChars;
1139 : 0 : }
1140 : :
1141 : 0 : void SmXMLNumberContext_Impl::EndElement()
1142 : : {
1143 [ # # ][ # # ]: 0 : GetSmImport().GetNodeStack().push(new SmTextNode(aToken,FNT_NUMBER));
1144 : 0 : }
1145 : :
1146 : : ////////////////////////////////////////////////////////////
1147 : :
1148 [ # # ]: 0 : class SmXMLAnnotationContext_Impl : public SmXMLImportContext
1149 : : {
1150 : : sal_Bool bIsStarMath;
1151 : :
1152 : : public:
1153 : 0 : SmXMLAnnotationContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1154 : : const OUString& rLName)
1155 : 0 : : SmXMLImportContext(rImport,nPrefix,rLName), bIsStarMath(sal_False) {}
1156 : :
1157 : : virtual void Characters(const OUString &rChars);
1158 : :
1159 : : void StartElement(const uno::Reference<xml::sax::XAttributeList > & xAttrList );
1160 : : };
1161 : :
1162 : 0 : void SmXMLAnnotationContext_Impl::StartElement(const uno::Reference<
1163 : : xml::sax::XAttributeList > & xAttrList )
1164 : : {
1165 [ # # ]: 0 : sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1166 [ # # ]: 0 : for (sal_Int16 i=0;i<nAttrCount;i++)
1167 : : {
1168 [ # # ][ # # ]: 0 : OUString sAttrName = xAttrList->getNameByIndex(i);
1169 : 0 : OUString aLocalName;
1170 : 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
1171 [ # # ]: 0 : GetKeyByAttrName(sAttrName,&aLocalName);
1172 : :
1173 [ # # ][ # # ]: 0 : OUString sValue = xAttrList->getValueByIndex(i);
1174 : : const SvXMLTokenMap &rAttrTokenMap =
1175 [ # # ]: 0 : GetSmImport().GetAnnotationAttrTokenMap();
1176 [ # # ][ # # ]: 0 : switch(rAttrTokenMap.Get(nPrefix,aLocalName))
1177 : : {
1178 : : case XML_TOK_ENCODING:
1179 : 0 : bIsStarMath= sValue == "StarMath 5.0";
1180 : 0 : break;
1181 : : default:
1182 : 0 : break;
1183 : : }
1184 : 0 : }
1185 : 0 : }
1186 : :
1187 : 0 : void SmXMLAnnotationContext_Impl::Characters(const OUString &rChars)
1188 : : {
1189 [ # # ]: 0 : if (bIsStarMath)
1190 [ # # ]: 0 : GetSmImport().GetText().Append(String(rChars));
1191 : 0 : }
1192 : :
1193 : : ////////////////////////////////////////////////////////////
1194 : :
1195 [ # # ][ # # ]: 0 : class SmXMLTextContext_Impl : public SmXMLImportContext
1196 : : {
1197 : : protected:
1198 : : SmToken aToken;
1199 : :
1200 : : public:
1201 : 0 : SmXMLTextContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1202 : : const OUString& rLName)
1203 [ # # ]: 0 : : SmXMLImportContext(rImport,nPrefix,rLName)
1204 : : {
1205 : 0 : aToken.cMathChar = '\0';
1206 : 0 : aToken.nGroup = 0;
1207 : 0 : aToken.nLevel = 5;
1208 : 0 : aToken.eType = TTEXT;
1209 : 0 : }
1210 : :
1211 : : virtual void TCharacters(const OUString &rChars);
1212 : :
1213 : : void EndElement();
1214 : : };
1215 : :
1216 : 0 : void SmXMLTextContext_Impl::TCharacters(const OUString &rChars)
1217 : : {
1218 : 0 : aToken.aText = rChars;
1219 : 0 : }
1220 : :
1221 : 0 : void SmXMLTextContext_Impl::EndElement()
1222 : : {
1223 [ # # ][ # # ]: 0 : GetSmImport().GetNodeStack().push(new SmTextNode(aToken,FNT_TEXT));
1224 : 0 : }
1225 : :
1226 : : ////////////////////////////////////////////////////////////
1227 : :
1228 [ # # ][ # # ]: 0 : class SmXMLStringContext_Impl : public SmXMLImportContext
1229 : : {
1230 : : protected:
1231 : : SmToken aToken;
1232 : :
1233 : : public:
1234 : 0 : SmXMLStringContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1235 : : const OUString& rLName)
1236 [ # # ]: 0 : : SmXMLImportContext(rImport,nPrefix,rLName)
1237 : : {
1238 : 0 : aToken.cMathChar = '\0';
1239 : 0 : aToken.nGroup = 0;
1240 : 0 : aToken.nLevel = 5;
1241 : 0 : aToken.eType = TTEXT;
1242 : 0 : }
1243 : :
1244 : : virtual void TCharacters(const OUString &rChars);
1245 : :
1246 : : void EndElement();
1247 : : };
1248 : :
1249 : 0 : void SmXMLStringContext_Impl::TCharacters(const OUString &rChars)
1250 : : {
1251 : : /*
1252 : : The content of <ms> elements should be rendered with visible "escaping" of
1253 : : certain characters in the content, including at least "double quote"
1254 : : itself, and preferably whitespace other than individual blanks. The intent
1255 : : is for the viewer to see that the expression is a string literal, and to
1256 : : see exactly which characters form its content. For example, <ms>double
1257 : : quote is "</ms> might be rendered as "double quote is \"".
1258 : :
1259 : : Obviously this isn't fully done here.
1260 : : */
1261 : 0 : aToken.aText.Erase();
1262 : 0 : aToken.aText += '\"';
1263 [ # # ]: 0 : aToken.aText += String(rChars);
1264 : 0 : aToken.aText += '\"';
1265 : 0 : }
1266 : :
1267 : 0 : void SmXMLStringContext_Impl::EndElement()
1268 : : {
1269 [ # # ][ # # ]: 0 : GetSmImport().GetNodeStack().push(new SmTextNode(aToken,FNT_FIXED));
1270 : 0 : }
1271 : :
1272 : : ////////////////////////////////////////////////////////////
1273 : :
1274 [ # # ][ # # ]: 0 : class SmXMLIdentifierContext_Impl : public SmXMLImportContext
[ # # ]
1275 : : {
1276 : : protected:
1277 : : SmXMLContext_Helper aStyleHelper;
1278 : : SmToken aToken;
1279 : :
1280 : : public:
1281 : 0 : SmXMLIdentifierContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1282 : : const OUString& rLName)
1283 [ # # ][ # # ]: 0 : : SmXMLImportContext(rImport,nPrefix,rLName),aStyleHelper(*this)
1284 : : {
1285 : 0 : aToken.cMathChar = '\0';
1286 : 0 : aToken.nGroup = 0;
1287 : 0 : aToken.nLevel = 5;
1288 : 0 : aToken.eType = TIDENT;
1289 : 0 : }
1290 : :
1291 : : void TCharacters(const OUString &rChars);
1292 : 0 : void StartElement(const uno::Reference< xml::sax::XAttributeList > & xAttrList )
1293 : : {
1294 : 0 : aStyleHelper.RetrieveAttrs(xAttrList);
1295 : 0 : };
1296 : : void EndElement();
1297 : : };
1298 : :
1299 : 0 : void SmXMLIdentifierContext_Impl::EndElement()
1300 : : {
1301 : 0 : SmTextNode *pNode = 0;
1302 : : //we will handle identifier italic/normal here instead of with a standalone
1303 : : //font node
1304 [ # # ][ # # ]: 0 : if (((aStyleHelper.nIsItalic == -1) && (aToken.aText.Len() > 1))
[ # # # # ]
[ # # ]
1305 : 0 : || ((aStyleHelper.nIsItalic == 0) && (aToken.aText.Len() == 1)))
1306 : : {
1307 [ # # ]: 0 : pNode = new SmTextNode(aToken,FNT_FUNCTION);
1308 : 0 : pNode->GetFont().SetItalic(ITALIC_NONE);
1309 : 0 : aStyleHelper.nIsItalic = -1;
1310 : : }
1311 : : else
1312 [ # # ]: 0 : pNode = new SmTextNode(aToken,FNT_VARIABLE);
1313 [ # # ][ # # ]: 0 : if (aStyleHelper.bFontNodeNeeded && aStyleHelper.nIsItalic != -1)
1314 : : {
1315 [ # # ]: 0 : if (aStyleHelper.nIsItalic)
1316 : 0 : pNode->GetFont().SetItalic(ITALIC_NORMAL);
1317 : : else
1318 : 0 : pNode->GetFont().SetItalic(ITALIC_NONE);
1319 : : }
1320 : :
1321 [ # # ][ # # : 0 : if ((-1!=aStyleHelper.nIsBold) || (0.0!=aStyleHelper.nFontSize) ||
# # # # ]
[ # # ]
1322 : 0 : (!aStyleHelper.sFontFamily.isEmpty()) ||
1323 : 0 : !aStyleHelper.sColor.isEmpty())
1324 : 0 : aStyleHelper.bFontNodeNeeded=sal_True;
1325 : : else
1326 : 0 : aStyleHelper.bFontNodeNeeded=sal_False;
1327 [ # # ]: 0 : if (aStyleHelper.bFontNodeNeeded)
1328 : 0 : aStyleHelper.ApplyAttrs();
1329 [ # # ]: 0 : GetSmImport().GetNodeStack().push(pNode);
1330 : 0 : }
1331 : :
1332 : 0 : void SmXMLIdentifierContext_Impl::TCharacters(const OUString &rChars)
1333 : : {
1334 : 0 : aToken.aText = rChars;
1335 : 0 : }
1336 : :
1337 : : ////////////////////////////////////////////////////////////
1338 : :
1339 [ # # ][ # # ]: 0 : class SmXMLOperatorContext_Impl : public SmXMLImportContext
1340 : : {
1341 : : sal_Bool bIsStretchy;
1342 : :
1343 : : protected:
1344 : : SmToken aToken;
1345 : :
1346 : : public:
1347 : 0 : SmXMLOperatorContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1348 : : const OUString& rLName)
1349 [ # # ]: 0 : : SmXMLImportContext(rImport,nPrefix,rLName), bIsStretchy(sal_False)
1350 : : {
1351 : 0 : aToken.nGroup = 0;
1352 : 0 : aToken.eType = TSPECIAL;
1353 : 0 : aToken.nLevel = 5;
1354 : 0 : }
1355 : :
1356 : : void TCharacters(const OUString &rChars);
1357 : : void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
1358 : : void EndElement();
1359 : : };
1360 : :
1361 : 0 : void SmXMLOperatorContext_Impl::TCharacters(const OUString &rChars)
1362 : : {
1363 : 0 : aToken.cMathChar = rChars[0];
1364 : 0 : }
1365 : :
1366 : 0 : void SmXMLOperatorContext_Impl::EndElement()
1367 : : {
1368 [ # # ]: 0 : SmMathSymbolNode *pNode = new SmMathSymbolNode(aToken);
1369 : : //For stretchy scaling the scaling must be retrieved from this node
1370 : : //and applied to the expression itself so as to get the expression
1371 : : //to scale the operator to the height of the expression itself
1372 [ # # ]: 0 : if (bIsStretchy)
1373 : 0 : pNode->SetScaleMode(SCALE_HEIGHT);
1374 [ # # ]: 0 : GetSmImport().GetNodeStack().push(pNode);
1375 : 0 : }
1376 : :
1377 : :
1378 : :
1379 : 0 : void SmXMLOperatorContext_Impl::StartElement(const uno::Reference<
1380 : : xml::sax::XAttributeList > & xAttrList )
1381 : : {
1382 [ # # ]: 0 : sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1383 [ # # ]: 0 : for (sal_Int16 i=0;i<nAttrCount;i++)
1384 : : {
1385 [ # # ][ # # ]: 0 : OUString sAttrName = xAttrList->getNameByIndex(i);
1386 : 0 : OUString aLocalName;
1387 : 0 : sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
1388 [ # # ]: 0 : GetKeyByAttrName(sAttrName,&aLocalName);
1389 : :
1390 [ # # ][ # # ]: 0 : OUString sValue = xAttrList->getValueByIndex(i);
1391 : : const SvXMLTokenMap &rAttrTokenMap =
1392 [ # # ]: 0 : GetSmImport().GetOperatorAttrTokenMap();
1393 [ # # ][ # # ]: 0 : switch(rAttrTokenMap.Get(nPrefix,aLocalName))
1394 : : {
1395 : : case XML_TOK_STRETCHY:
1396 : : bIsStretchy = sValue.equals(
1397 [ # # ]: 0 : GetXMLToken(XML_TRUE));
1398 : 0 : break;
1399 : : default:
1400 : 0 : break;
1401 : : }
1402 : 0 : }
1403 : 0 : }
1404 : :
1405 : :
1406 : : ////////////////////////////////////////////////////////////
1407 : :
1408 [ # # ]: 0 : class SmXMLSpaceContext_Impl : public SmXMLImportContext
1409 : : {
1410 : : public:
1411 : 0 : SmXMLSpaceContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1412 : : const OUString& rLName)
1413 : 0 : : SmXMLImportContext(rImport,nPrefix,rLName) {}
1414 : :
1415 : : void StartElement(const uno::Reference< xml::sax::XAttributeList >& xAttrList );
1416 : : };
1417 : :
1418 : 0 : void SmXMLSpaceContext_Impl::StartElement(
1419 : : const uno::Reference<xml::sax::XAttributeList > & /*xAttrList*/ )
1420 : : {
1421 [ # # ]: 0 : SmToken aToken;
1422 : 0 : aToken.cMathChar = '\0';
1423 : 0 : aToken.nGroup = 0;
1424 : 0 : aToken.eType = TBLANK;
1425 : 0 : aToken.nLevel = 5;
1426 [ # # ][ # # ]: 0 : SmBlankNode *pBlank = new SmBlankNode(aToken);
1427 [ # # ]: 0 : pBlank->IncreaseBy(aToken);
1428 [ # # ][ # # ]: 0 : GetSmImport().GetNodeStack().push(pBlank);
1429 : 0 : }
1430 : :
1431 : : ////////////////////////////////////////////////////////////
1432 : :
1433 [ # # ]: 0 : class SmXMLSubContext_Impl : public SmXMLRowContext_Impl
1434 : : {
1435 : : protected:
1436 : : void GenericEndElement(SmTokenType eType,SmSubSup aSubSup);
1437 : :
1438 : : public:
1439 : 0 : SmXMLSubContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1440 : : const OUString& rLName)
1441 : 0 : : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
1442 : :
1443 : 0 : void EndElement()
1444 : : {
1445 : 0 : GenericEndElement(TRSUB,RSUB);
1446 : 0 : }
1447 : : };
1448 : :
1449 : :
1450 : 0 : void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup eSubSup)
1451 : : {
1452 : : /*The <msub> element requires exactly 2 arguments.*/
1453 : 0 : const bool bNodeCheck = GetSmImport().GetNodeStack().size() - nElementCount == 2;
1454 : : OSL_ENSURE( bNodeCheck, "Sub has not two arguments" );
1455 [ # # ]: 0 : if (!bNodeCheck)
1456 : 0 : return;
1457 : :
1458 [ # # ]: 0 : SmToken aToken;
1459 : 0 : aToken.cMathChar = '\0';
1460 : 0 : aToken.nGroup = 0;
1461 : 0 : aToken.nLevel = 0;
1462 : 0 : aToken.eType = eType;
1463 [ # # ][ # # ]: 0 : SmSubSupNode *pNode = new SmSubSupNode(aToken);
1464 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
1465 : :
1466 : : // initialize subnodes array
1467 [ # # ]: 0 : SmNodeArray aSubNodes;
1468 [ # # ]: 0 : aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
1469 [ # # ]: 0 : for (sal_uLong i = 1; i < aSubNodes.size(); i++)
1470 : 0 : aSubNodes[i] = NULL;
1471 : :
1472 [ # # ]: 0 : aSubNodes[eSubSup+1] = lcl_popOrZero(rNodeStack);
1473 [ # # ]: 0 : aSubNodes[0] = lcl_popOrZero(rNodeStack);
1474 [ # # ]: 0 : pNode->SetSubNodes(aSubNodes);
1475 [ # # ][ # # ]: 0 : rNodeStack.push(pNode);
1476 : : }
1477 : :
1478 : : ////////////////////////////////////////////////////////////
1479 : :
1480 [ # # ]: 0 : class SmXMLSupContext_Impl : public SmXMLSubContext_Impl
1481 : : {
1482 : : public:
1483 : 0 : SmXMLSupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1484 : : const OUString& rLName)
1485 : 0 : : SmXMLSubContext_Impl(rImport,nPrefix,rLName) {}
1486 : :
1487 : 0 : void EndElement()
1488 : : {
1489 : 0 : GenericEndElement(TRSUP,RSUP);
1490 : 0 : }
1491 : : };
1492 : :
1493 : : ////////////////////////////////////////////////////////////
1494 : :
1495 [ # # ]: 0 : class SmXMLSubSupContext_Impl : public SmXMLRowContext_Impl
1496 : : {
1497 : : protected:
1498 : : void GenericEndElement(SmTokenType eType, SmSubSup aSub,SmSubSup aSup);
1499 : :
1500 : : public:
1501 : 0 : SmXMLSubSupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1502 : : const OUString& rLName)
1503 : 0 : : SmXMLRowContext_Impl(rImport,nPrefix,rLName) {}
1504 : :
1505 : 0 : void EndElement()
1506 : : {
1507 : 0 : GenericEndElement(TRSUB,RSUB,RSUP);
1508 : 0 : }
1509 : : };
1510 : :
1511 : 0 : void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType,
1512 : : SmSubSup aSub,SmSubSup aSup)
1513 : : {
1514 : : /*The <msub> element requires exactly 3 arguments.*/
1515 : 0 : const bool bNodeCheck = GetSmImport().GetNodeStack().size() - nElementCount == 3;
1516 : : OSL_ENSURE( bNodeCheck, "SubSup has not three arguments" );
1517 [ # # ]: 0 : if (!bNodeCheck)
1518 : 0 : return;
1519 : :
1520 [ # # ]: 0 : SmToken aToken;
1521 : 0 : aToken.cMathChar = '\0';
1522 : 0 : aToken.nGroup = 0;
1523 : 0 : aToken.nLevel = 0;
1524 : 0 : aToken.eType = eType;
1525 [ # # ][ # # ]: 0 : SmSubSupNode *pNode = new SmSubSupNode(aToken);
1526 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
1527 : :
1528 : : // initialize subnodes array
1529 [ # # ]: 0 : SmNodeArray aSubNodes;
1530 [ # # ]: 0 : aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES);
1531 [ # # ]: 0 : for (sal_uLong i = 1; i < aSubNodes.size(); i++)
1532 : 0 : aSubNodes[i] = NULL;
1533 : :
1534 [ # # ]: 0 : aSubNodes[aSup+1] = lcl_popOrZero(rNodeStack);
1535 [ # # ]: 0 : aSubNodes[aSub+1] = lcl_popOrZero(rNodeStack);
1536 [ # # ]: 0 : aSubNodes[0] = lcl_popOrZero(rNodeStack);
1537 [ # # ]: 0 : pNode->SetSubNodes(aSubNodes);
1538 [ # # ][ # # ]: 0 : rNodeStack.push(pNode);
1539 : : }
1540 : :
1541 : : ////////////////////////////////////////////////////////////
1542 : :
1543 [ # # ]: 0 : class SmXMLUnderContext_Impl : public SmXMLSubContext_Impl
1544 : : {
1545 : : protected:
1546 : : sal_Int16 nAttrCount;
1547 : :
1548 : : public:
1549 : 0 : SmXMLUnderContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1550 : : const OUString& rLName)
1551 : 0 : : SmXMLSubContext_Impl(rImport,nPrefix,rLName) {}
1552 : :
1553 : : void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
1554 : : void EndElement();
1555 : : void HandleAccent();
1556 : : };
1557 : :
1558 : 0 : void SmXMLUnderContext_Impl::StartElement(const uno::Reference<
1559 : : xml::sax::XAttributeList > & xAttrList )
1560 : : {
1561 [ # # ]: 0 : nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1562 : 0 : }
1563 : :
1564 : 0 : void SmXMLUnderContext_Impl::HandleAccent()
1565 : : {
1566 : 0 : const bool bNodeCheck = GetSmImport().GetNodeStack().size() - nElementCount == 2;
1567 : : OSL_ENSURE( bNodeCheck, "Sub has not two arguments" );
1568 [ # # ]: 0 : if (!bNodeCheck)
1569 : 0 : return;
1570 : :
1571 : : /*Just one special case for the underline thing*/
1572 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
1573 [ # # ]: 0 : SmNode *pTest = lcl_popOrZero(rNodeStack);
1574 [ # # ]: 0 : SmToken aToken;
1575 : 0 : aToken.cMathChar = '\0';
1576 : 0 : aToken.nGroup = 0;
1577 : 0 : aToken.nLevel = 0;
1578 : 0 : aToken.eType = TUNDERLINE;
1579 : :
1580 : :
1581 [ # # ]: 0 : SmNodeArray aSubNodes;
1582 [ # # ]: 0 : aSubNodes.resize(2);
1583 : :
1584 [ # # ][ # # ]: 0 : SmStructureNode *pNode = new SmAttributNode(aToken);
1585 [ # # ]: 0 : if ((pTest->GetToken().cMathChar & 0x0FFF) == 0x0332)
1586 : : {
1587 [ # # ][ # # ]: 0 : aSubNodes[0] = new SmRectangleNode(aToken);
1588 [ # # ][ # # ]: 0 : delete pTest;
1589 : : }
1590 : : else
1591 : 0 : aSubNodes[0] = pTest;
1592 : :
1593 [ # # ]: 0 : aSubNodes[1] = lcl_popOrZero(rNodeStack);
1594 [ # # ]: 0 : pNode->SetSubNodes(aSubNodes);
1595 : 0 : pNode->SetScaleMode(SCALE_WIDTH);
1596 [ # # ][ # # ]: 0 : rNodeStack.push(pNode);
1597 : : }
1598 : :
1599 : :
1600 : 0 : void SmXMLUnderContext_Impl::EndElement()
1601 : : {
1602 [ # # ]: 0 : if (!nAttrCount)
1603 : 0 : GenericEndElement(TCSUB,CSUB);
1604 : : else
1605 : 0 : HandleAccent();
1606 : 0 : }
1607 : :
1608 : : ////////////////////////////////////////////////////////////
1609 : :
1610 [ # # ]: 0 : class SmXMLOverContext_Impl : public SmXMLSubContext_Impl
1611 : : {
1612 : : protected:
1613 : : sal_Int16 nAttrCount;
1614 : :
1615 : : public:
1616 : 0 : SmXMLOverContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1617 : : const OUString& rLName)
1618 : 0 : : SmXMLSubContext_Impl(rImport,nPrefix,rLName), nAttrCount(0) {}
1619 : :
1620 : : void EndElement();
1621 : : void StartElement(const uno::Reference< xml::sax::XAttributeList > &xAttrList );
1622 : : void HandleAccent();
1623 : : };
1624 : :
1625 : :
1626 : 0 : void SmXMLOverContext_Impl::StartElement(const uno::Reference<
1627 : : xml::sax::XAttributeList > & xAttrList )
1628 : : {
1629 [ # # ]: 0 : nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1630 : 0 : }
1631 : :
1632 : :
1633 : 0 : void SmXMLOverContext_Impl::EndElement()
1634 : : {
1635 [ # # ]: 0 : if (!nAttrCount)
1636 : 0 : GenericEndElement(TCSUP,CSUP);
1637 : : else
1638 : 0 : HandleAccent();
1639 : 0 : }
1640 : :
1641 : :
1642 : 0 : void SmXMLOverContext_Impl::HandleAccent()
1643 : : {
1644 : 0 : const bool bNodeCheck = GetSmImport().GetNodeStack().size() - nElementCount == 2;
1645 : : OSL_ENSURE (bNodeCheck, "Sub has not two arguments");
1646 [ # # ]: 0 : if (!bNodeCheck)
1647 : 0 : return;
1648 : :
1649 [ # # ]: 0 : SmToken aToken;
1650 : 0 : aToken.cMathChar = '\0';
1651 : 0 : aToken.nGroup = 0;
1652 : 0 : aToken.nLevel = 0;
1653 : 0 : aToken.eType = TACUTE;
1654 : :
1655 [ # # ][ # # ]: 0 : SmAttributNode *pNode = new SmAttributNode(aToken);
1656 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
1657 : :
1658 [ # # ]: 0 : SmNodeArray aSubNodes;
1659 [ # # ]: 0 : aSubNodes.resize(2);
1660 [ # # ]: 0 : aSubNodes[0] = lcl_popOrZero(rNodeStack);
1661 [ # # ]: 0 : aSubNodes[1] = lcl_popOrZero(rNodeStack);
1662 [ # # ]: 0 : pNode->SetSubNodes(aSubNodes);
1663 : 0 : pNode->SetScaleMode(SCALE_WIDTH);
1664 [ # # ][ # # ]: 0 : rNodeStack.push(pNode);
1665 : :
1666 : : }
1667 : :
1668 : : ////////////////////////////////////////////////////////////
1669 : :
1670 [ # # ]: 0 : class SmXMLUnderOverContext_Impl : public SmXMLSubSupContext_Impl
1671 : : {
1672 : : public:
1673 : 0 : SmXMLUnderOverContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1674 : : const OUString& rLName)
1675 : 0 : : SmXMLSubSupContext_Impl(rImport,nPrefix,rLName) {}
1676 : :
1677 : 0 : void EndElement()
1678 : : {
1679 : 0 : GenericEndElement(TCSUB,CSUB,CSUP);
1680 : 0 : }
1681 : : };
1682 : :
1683 : : ////////////////////////////////////////////////////////////
1684 : :
1685 [ # # ]: 0 : class SmXMLMultiScriptsContext_Impl : public SmXMLSubSupContext_Impl
1686 : : {
1687 : : bool bHasPrescripts;
1688 : :
1689 : : void ProcessSubSupPairs(bool bIsPrescript);
1690 : :
1691 : : public:
1692 : 0 : SmXMLMultiScriptsContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1693 : : const OUString& rLName) :
1694 : : SmXMLSubSupContext_Impl(rImport,nPrefix,rLName),
1695 : 0 : bHasPrescripts(false) {}
1696 : :
1697 : : void EndElement();
1698 : : SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
1699 : : const OUString& rLocalName,
1700 : : const uno::Reference< xml::sax::XAttributeList > &xAttrList);
1701 : : };
1702 : :
1703 : : ////////////////////////////////////////////////////////////
1704 : :
1705 [ # # ]: 0 : class SmXMLNoneContext_Impl : public SmXMLImportContext
1706 : : {
1707 : : public:
1708 : 0 : SmXMLNoneContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1709 : : const OUString& rLName)
1710 : 0 : : SmXMLImportContext(rImport,nPrefix,rLName) {}
1711 : :
1712 : : void EndElement();
1713 : : };
1714 : :
1715 : :
1716 : 0 : void SmXMLNoneContext_Impl::EndElement(void)
1717 : : {
1718 [ # # ]: 0 : SmToken aToken;
1719 : 0 : aToken.cMathChar = '\0';
1720 : 0 : aToken.nGroup = 0;
1721 [ # # ]: 0 : aToken.aText.Erase();
1722 : 0 : aToken.nLevel = 5;
1723 : 0 : aToken.eType = TIDENT;
1724 : 0 : GetSmImport().GetNodeStack().push(
1725 [ # # ]: 0 : new SmTextNode(aToken,FNT_VARIABLE));
[ # # # # ]
[ # # ]
1726 : 0 : }
1727 : :
1728 : : ////////////////////////////////////////////////////////////
1729 : :
1730 [ # # ]: 0 : class SmXMLPrescriptsContext_Impl : public SmXMLImportContext
1731 : : {
1732 : : public:
1733 : 0 : SmXMLPrescriptsContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1734 : : const OUString& rLName)
1735 : 0 : : SmXMLImportContext(rImport,nPrefix,rLName) {}
1736 : : };
1737 : :
1738 : : ////////////////////////////////////////////////////////////
1739 : :
1740 [ # # ]: 0 : class SmXMLTableRowContext_Impl : public SmXMLRowContext_Impl
1741 : : {
1742 : : public:
1743 : 0 : SmXMLTableRowContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1744 : : const OUString& rLName) :
1745 : 0 : SmXMLRowContext_Impl(rImport,nPrefix,rLName)
1746 : 0 : {}
1747 : :
1748 : : SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
1749 : : const OUString& rLocalName,
1750 : : const uno::Reference< xml::sax::XAttributeList > &xAttrList);
1751 : : };
1752 : :
1753 : :
1754 : : ////////////////////////////////////////////////////////////
1755 : :
1756 [ # # ]: 0 : class SmXMLTableContext_Impl : public SmXMLTableRowContext_Impl
1757 : : {
1758 : : public:
1759 : 0 : SmXMLTableContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1760 : : const OUString& rLName) :
1761 : 0 : SmXMLTableRowContext_Impl(rImport,nPrefix,rLName)
1762 : 0 : {}
1763 : :
1764 : : void EndElement();
1765 : : SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix,
1766 : : const OUString& rLocalName,
1767 : : const uno::Reference< xml::sax::XAttributeList > &xAttrList);
1768 : : };
1769 : :
1770 : :
1771 : : ////////////////////////////////////////////////////////////
1772 : :
1773 [ # # ]: 0 : class SmXMLTableCellContext_Impl : public SmXMLRowContext_Impl
1774 : : {
1775 : : public:
1776 : 0 : SmXMLTableCellContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1777 : : const OUString& rLName) :
1778 : 0 : SmXMLRowContext_Impl(rImport,nPrefix,rLName)
1779 : 0 : {}
1780 : : };
1781 : :
1782 : : ////////////////////////////////////////////////////////////
1783 : :
1784 [ # # ]: 0 : class SmXMLAlignGroupContext_Impl : public SmXMLRowContext_Impl
1785 : : {
1786 : : public:
1787 : 0 : SmXMLAlignGroupContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1788 : : const OUString& rLName) :
1789 : 0 : SmXMLRowContext_Impl(rImport,nPrefix,rLName)
1790 : 0 : {}
1791 : :
1792 : : /*Don't do anything with alignment for now*/
1793 : 0 : void EndElement()
1794 : : {
1795 : 0 : }
1796 : : };
1797 : :
1798 : : ////////////////////////////////////////////////////////////
1799 : :
1800 [ # # ]: 0 : class SmXMLActionContext_Impl : public SmXMLRowContext_Impl
1801 : : {
1802 : : public:
1803 : 0 : SmXMLActionContext_Impl(SmXMLImport &rImport,sal_uInt16 nPrefix,
1804 : : const OUString& rLName) :
1805 : 0 : SmXMLRowContext_Impl(rImport,nPrefix,rLName)
1806 : 0 : {}
1807 : :
1808 : : void EndElement();
1809 : : };
1810 : :
1811 : : ////////////////////////////////////////////////////////////
1812 : :
1813 : : // NB: virtually inherit so we can multiply inherit properly
1814 : : // in SmXMLFlatDocContext_Impl
1815 [ # # ][ # # ]: 0 : class SmXMLOfficeContext_Impl : public virtual SvXMLImportContext
[ # # ][ # # ]
1816 : : {
1817 : : public:
1818 : 0 : SmXMLOfficeContext_Impl( SmXMLImport &rImport, sal_uInt16 nPrfx,
1819 : : const OUString& rLName)
1820 : 0 : : SvXMLImportContext(rImport,nPrfx,rLName) {}
1821 : :
1822 : : virtual SvXMLImportContext *CreateChildContext(sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > &xAttrList);
1823 : : };
1824 : :
1825 : 0 : SvXMLImportContext *SmXMLOfficeContext_Impl::CreateChildContext(sal_uInt16 nPrefix,
1826 : : const OUString& rLocalName,
1827 : : const uno::Reference< xml::sax::XAttributeList > &xAttrList)
1828 : : {
1829 : 0 : SvXMLImportContext *pContext = 0;
1830 [ # # # # ]: 0 : if ( XML_NAMESPACE_OFFICE == nPrefix &&
[ # # ]
1831 : 0 : rLocalName == GetXMLToken(XML_META) )
1832 : : {
1833 : : OSL_FAIL("XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
1834 : : }
1835 [ # # # # ]: 0 : else if ( XML_NAMESPACE_OFFICE == nPrefix &&
[ # # ]
1836 : 0 : rLocalName == GetXMLToken(XML_SETTINGS) )
1837 : : {
1838 : 0 : pContext = new XMLDocumentSettingsContext( GetImport(),
1839 : : XML_NAMESPACE_OFFICE, rLocalName,
1840 [ # # ]: 0 : xAttrList );
1841 : : }
1842 : : else
1843 [ # # ]: 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1844 : :
1845 : 0 : return pContext;
1846 : : }
1847 : :
1848 : : ////////////////////////////////////////////////////////////
1849 : :
1850 : : // context for flat file xml format
1851 : : class SmXMLFlatDocContext_Impl
1852 : : : public SmXMLOfficeContext_Impl, public SvXMLMetaDocumentContext
1853 : : {
1854 : : public:
1855 : : SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport,
1856 : : sal_uInt16 i_nPrefix, const OUString & i_rLName,
1857 : : const uno::Reference<document::XDocumentProperties>& i_xDocProps,
1858 : : const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder);
1859 : :
1860 : : virtual ~SmXMLFlatDocContext_Impl();
1861 : :
1862 : : virtual SvXMLImportContext *CreateChildContext(sal_uInt16 i_nPrefix, const OUString& i_rLocalName, const uno::Reference<xml::sax::XAttributeList>& i_xAttrList);
1863 : : };
1864 : :
1865 : 0 : SmXMLFlatDocContext_Impl::SmXMLFlatDocContext_Impl( SmXMLImport& i_rImport,
1866 : : sal_uInt16 i_nPrefix, const OUString & i_rLName,
1867 : : const uno::Reference<document::XDocumentProperties>& i_xDocProps,
1868 : : const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder) :
1869 : : SvXMLImportContext(i_rImport, i_nPrefix, i_rLName),
1870 : : SmXMLOfficeContext_Impl(i_rImport, i_nPrefix, i_rLName),
1871 : : SvXMLMetaDocumentContext(i_rImport, i_nPrefix, i_rLName,
1872 [ # # ][ # # ]: 0 : i_xDocProps, i_xDocBuilder)
[ # # ][ # # ]
1873 : : {
1874 : 0 : }
1875 : :
1876 [ # # ][ # # ]: 0 : SmXMLFlatDocContext_Impl::~SmXMLFlatDocContext_Impl()
[ # # ][ # # ]
1877 : : {
1878 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ][ # # ]
1879 : :
1880 : 0 : SvXMLImportContext *SmXMLFlatDocContext_Impl::CreateChildContext(
1881 : : sal_uInt16 i_nPrefix, const OUString& i_rLocalName,
1882 : : const uno::Reference<xml::sax::XAttributeList>& i_xAttrList)
1883 : : {
1884 : : // behave like meta base class iff we encounter office:meta
1885 [ # # # # ]: 0 : if ( XML_NAMESPACE_OFFICE == i_nPrefix &&
[ # # ]
1886 : 0 : i_rLocalName == GetXMLToken(XML_META) )
1887 : : {
1888 : : return SvXMLMetaDocumentContext::CreateChildContext(
1889 : 0 : i_nPrefix, i_rLocalName, i_xAttrList );
1890 : : }
1891 : : else
1892 : : {
1893 : : return SmXMLOfficeContext_Impl::CreateChildContext(
1894 : 0 : i_nPrefix, i_rLocalName, i_xAttrList );
1895 : : }
1896 : : }
1897 : :
1898 : : ////////////////////////////////////////////////////////////
1899 : :
1900 : : static SvXMLTokenMapEntry aPresLayoutElemTokenMap[] =
1901 : : {
1902 : : { XML_NAMESPACE_MATH, XML_SEMANTICS, XML_TOK_SEMANTICS },
1903 : : { XML_NAMESPACE_MATH, XML_MATH, XML_TOK_MATH },
1904 : : { XML_NAMESPACE_MATH, XML_MSTYLE, XML_TOK_MSTYLE },
1905 : : { XML_NAMESPACE_MATH, XML_MERROR, XML_TOK_MERROR },
1906 : : { XML_NAMESPACE_MATH, XML_MPHANTOM, XML_TOK_MPHANTOM },
1907 : : { XML_NAMESPACE_MATH, XML_MROW, XML_TOK_MROW },
1908 : : { XML_NAMESPACE_MATH, XML_MFRAC, XML_TOK_MFRAC },
1909 : : { XML_NAMESPACE_MATH, XML_MSQRT, XML_TOK_MSQRT },
1910 : : { XML_NAMESPACE_MATH, XML_MROOT, XML_TOK_MROOT },
1911 : : { XML_NAMESPACE_MATH, XML_MSUB, XML_TOK_MSUB },
1912 : : { XML_NAMESPACE_MATH, XML_MSUP, XML_TOK_MSUP },
1913 : : { XML_NAMESPACE_MATH, XML_MSUBSUP, XML_TOK_MSUBSUP },
1914 : : { XML_NAMESPACE_MATH, XML_MUNDER, XML_TOK_MUNDER },
1915 : : { XML_NAMESPACE_MATH, XML_MOVER, XML_TOK_MOVER },
1916 : : { XML_NAMESPACE_MATH, XML_MUNDEROVER, XML_TOK_MUNDEROVER },
1917 : : { XML_NAMESPACE_MATH, XML_MMULTISCRIPTS, XML_TOK_MMULTISCRIPTS },
1918 : : { XML_NAMESPACE_MATH, XML_MTABLE, XML_TOK_MTABLE },
1919 : : { XML_NAMESPACE_MATH, XML_MACTION, XML_TOK_MACTION },
1920 : : { XML_NAMESPACE_MATH, XML_MFENCED, XML_TOK_MFENCED },
1921 : : { XML_NAMESPACE_MATH, XML_MPADDED, XML_TOK_MPADDED },
1922 : : XML_TOKEN_MAP_END
1923 : : };
1924 : :
1925 : : static SvXMLTokenMapEntry aPresLayoutAttrTokenMap[] =
1926 : : {
1927 : : { XML_NAMESPACE_MATH, XML_FONTWEIGHT, XML_TOK_FONTWEIGHT },
1928 : : { XML_NAMESPACE_MATH, XML_FONTSTYLE, XML_TOK_FONTSTYLE },
1929 : : { XML_NAMESPACE_MATH, XML_FONTSIZE, XML_TOK_FONTSIZE },
1930 : : { XML_NAMESPACE_MATH, XML_FONTFAMILY, XML_TOK_FONTFAMILY },
1931 : : { XML_NAMESPACE_MATH, XML_COLOR, XML_TOK_COLOR },
1932 : : XML_TOKEN_MAP_END
1933 : : };
1934 : :
1935 : : static SvXMLTokenMapEntry aFencedAttrTokenMap[] =
1936 : : {
1937 : : { XML_NAMESPACE_MATH, XML_OPEN, XML_TOK_OPEN },
1938 : : { XML_NAMESPACE_MATH, XML_CLOSE, XML_TOK_CLOSE },
1939 : : XML_TOKEN_MAP_END
1940 : : };
1941 : :
1942 : : static SvXMLTokenMapEntry aOperatorAttrTokenMap[] =
1943 : : {
1944 : : { XML_NAMESPACE_MATH, XML_STRETCHY, XML_TOK_STRETCHY },
1945 : : XML_TOKEN_MAP_END
1946 : : };
1947 : :
1948 : : static SvXMLTokenMapEntry aAnnotationAttrTokenMap[] =
1949 : : {
1950 : : { XML_NAMESPACE_MATH, XML_ENCODING, XML_TOK_ENCODING },
1951 : : XML_TOKEN_MAP_END
1952 : : };
1953 : :
1954 : :
1955 : : static SvXMLTokenMapEntry aPresElemTokenMap[] =
1956 : : {
1957 : : { XML_NAMESPACE_MATH, XML_ANNOTATION, XML_TOK_ANNOTATION },
1958 : : { XML_NAMESPACE_MATH, XML_MI, XML_TOK_MI },
1959 : : { XML_NAMESPACE_MATH, XML_MN, XML_TOK_MN },
1960 : : { XML_NAMESPACE_MATH, XML_MO, XML_TOK_MO },
1961 : : { XML_NAMESPACE_MATH, XML_MTEXT, XML_TOK_MTEXT },
1962 : : { XML_NAMESPACE_MATH, XML_MSPACE,XML_TOK_MSPACE },
1963 : : { XML_NAMESPACE_MATH, XML_MS, XML_TOK_MS },
1964 : : { XML_NAMESPACE_MATH, XML_MALIGNGROUP, XML_TOK_MALIGNGROUP },
1965 : : XML_TOKEN_MAP_END
1966 : : };
1967 : :
1968 : : static SvXMLTokenMapEntry aPresScriptEmptyElemTokenMap[] =
1969 : : {
1970 : : { XML_NAMESPACE_MATH, XML_MPRESCRIPTS, XML_TOK_MPRESCRIPTS },
1971 : : { XML_NAMESPACE_MATH, XML_NONE, XML_TOK_NONE },
1972 : : XML_TOKEN_MAP_END
1973 : : };
1974 : :
1975 : : static SvXMLTokenMapEntry aPresTableElemTokenMap[] =
1976 : : {
1977 : : { XML_NAMESPACE_MATH, XML_MTR, XML_TOK_MTR },
1978 : : { XML_NAMESPACE_MATH, XML_MTD, XML_TOK_MTD },
1979 : : XML_TOKEN_MAP_END
1980 : : };
1981 : :
1982 : : static SvXMLTokenMapEntry aColorTokenMap[] =
1983 : : {
1984 : : { XML_NAMESPACE_MATH, XML_BLACK, TBLACK},
1985 : : { XML_NAMESPACE_MATH, XML_WHITE, TWHITE},
1986 : : { XML_NAMESPACE_MATH, XML_RED, TRED},
1987 : : { XML_NAMESPACE_MATH, XML_GREEN, TGREEN},
1988 : : { XML_NAMESPACE_MATH, XML_BLUE, TBLUE},
1989 : : { XML_NAMESPACE_MATH, XML_AQUA, TCYAN},
1990 : : { XML_NAMESPACE_MATH, XML_FUCHSIA, TMAGENTA},
1991 : : { XML_NAMESPACE_MATH, XML_YELLOW, TYELLOW},
1992 : : XML_TOKEN_MAP_END
1993 : : };
1994 : :
1995 : :
1996 : : ////////////////////////////////////////////////////////////
1997 : :
1998 : 0 : const SvXMLTokenMap& SmXMLImport::GetPresLayoutElemTokenMap()
1999 : : {
2000 [ # # ]: 0 : if (!pPresLayoutElemTokenMap)
2001 [ # # ]: 0 : pPresLayoutElemTokenMap = new SvXMLTokenMap(aPresLayoutElemTokenMap);
2002 : 0 : return *pPresLayoutElemTokenMap;
2003 : : }
2004 : :
2005 : 0 : const SvXMLTokenMap& SmXMLImport::GetPresLayoutAttrTokenMap()
2006 : : {
2007 [ # # ]: 0 : if (!pPresLayoutAttrTokenMap)
2008 [ # # ]: 0 : pPresLayoutAttrTokenMap = new SvXMLTokenMap(aPresLayoutAttrTokenMap);
2009 : 0 : return *pPresLayoutAttrTokenMap;
2010 : : }
2011 : :
2012 : :
2013 : 0 : const SvXMLTokenMap& SmXMLImport::GetFencedAttrTokenMap()
2014 : : {
2015 [ # # ]: 0 : if (!pFencedAttrTokenMap)
2016 [ # # ]: 0 : pFencedAttrTokenMap = new SvXMLTokenMap(aFencedAttrTokenMap);
2017 : 0 : return *pFencedAttrTokenMap;
2018 : : }
2019 : :
2020 : 0 : const SvXMLTokenMap& SmXMLImport::GetOperatorAttrTokenMap()
2021 : : {
2022 [ # # ]: 0 : if (!pOperatorAttrTokenMap)
2023 [ # # ]: 0 : pOperatorAttrTokenMap = new SvXMLTokenMap(aOperatorAttrTokenMap);
2024 : 0 : return *pOperatorAttrTokenMap;
2025 : : }
2026 : :
2027 : 0 : const SvXMLTokenMap& SmXMLImport::GetAnnotationAttrTokenMap()
2028 : : {
2029 [ # # ]: 0 : if (!pAnnotationAttrTokenMap)
2030 [ # # ]: 0 : pAnnotationAttrTokenMap = new SvXMLTokenMap(aAnnotationAttrTokenMap);
2031 : 0 : return *pAnnotationAttrTokenMap;
2032 : : }
2033 : :
2034 : 0 : const SvXMLTokenMap& SmXMLImport::GetPresElemTokenMap()
2035 : : {
2036 [ # # ]: 0 : if (!pPresElemTokenMap)
2037 [ # # ]: 0 : pPresElemTokenMap = new SvXMLTokenMap(aPresElemTokenMap);
2038 : 0 : return *pPresElemTokenMap;
2039 : : }
2040 : :
2041 : 0 : const SvXMLTokenMap& SmXMLImport::GetPresScriptEmptyElemTokenMap()
2042 : : {
2043 [ # # ]: 0 : if (!pPresScriptEmptyElemTokenMap)
2044 : : pPresScriptEmptyElemTokenMap = new
2045 [ # # ]: 0 : SvXMLTokenMap(aPresScriptEmptyElemTokenMap);
2046 : 0 : return *pPresScriptEmptyElemTokenMap;
2047 : : }
2048 : :
2049 : 0 : const SvXMLTokenMap& SmXMLImport::GetPresTableElemTokenMap()
2050 : : {
2051 [ # # ]: 0 : if (!pPresTableElemTokenMap)
2052 [ # # ]: 0 : pPresTableElemTokenMap = new SvXMLTokenMap(aPresTableElemTokenMap);
2053 : 0 : return *pPresTableElemTokenMap;
2054 : : }
2055 : :
2056 : 0 : const SvXMLTokenMap& SmXMLImport::GetColorTokenMap()
2057 : : {
2058 [ # # ]: 0 : if (!pColorTokenMap)
2059 [ # # ]: 0 : pColorTokenMap = new SvXMLTokenMap(aColorTokenMap);
2060 : 0 : return *pColorTokenMap;
2061 : : }
2062 : :
2063 : : ////////////////////////////////////////////////////////////
2064 : :
2065 : 0 : SvXMLImportContext *SmXMLDocContext_Impl::CreateChildContext(
2066 : : sal_uInt16 nPrefix,
2067 : : const OUString& rLocalName,
2068 : : const uno::Reference<xml::sax::XAttributeList>& xAttrList)
2069 : : {
2070 : 0 : SvXMLImportContext* pContext = 0L;
2071 : :
2072 : 0 : const SvXMLTokenMap& rTokenMap = GetSmImport().GetPresLayoutElemTokenMap();
2073 : :
2074 [ # # # # : 0 : switch(rTokenMap.Get(nPrefix, rLocalName))
# # # # #
# # # # #
# # # # #
# ]
2075 : : {
2076 : : //Consider semantics a dummy except for any starmath annotations
2077 : : case XML_TOK_SEMANTICS:
2078 : 0 : pContext = GetSmImport().CreateRowContext(nPrefix,rLocalName,
2079 [ # # ]: 0 : xAttrList);
2080 : : break;
2081 : : /*General Layout Schemata*/
2082 : : case XML_TOK_MROW:
2083 : 0 : pContext = GetSmImport().CreateRowContext(nPrefix,rLocalName,
2084 [ # # ]: 0 : xAttrList);
2085 : : break;
2086 : : case XML_TOK_MFRAC:
2087 : 0 : pContext = GetSmImport().CreateFracContext(nPrefix,rLocalName,
2088 [ # # ]: 0 : xAttrList);
2089 : : break;
2090 : : case XML_TOK_MSQRT:
2091 : 0 : pContext = GetSmImport().CreateSqrtContext(nPrefix,rLocalName,
2092 [ # # ]: 0 : xAttrList);
2093 : : break;
2094 : : case XML_TOK_MROOT:
2095 : 0 : pContext = GetSmImport().CreateRootContext(nPrefix,rLocalName,
2096 [ # # ]: 0 : xAttrList);
2097 : : break;
2098 : : case XML_TOK_MSTYLE:
2099 : 0 : pContext = GetSmImport().CreateStyleContext(nPrefix,rLocalName,
2100 [ # # ]: 0 : xAttrList);
2101 : : break;
2102 : : case XML_TOK_MERROR:
2103 : 0 : pContext = GetSmImport().CreateErrorContext(nPrefix,rLocalName,
2104 [ # # ]: 0 : xAttrList);
2105 : : break;
2106 : : case XML_TOK_MPADDED:
2107 : 0 : pContext = GetSmImport().CreatePaddedContext(nPrefix,rLocalName,
2108 [ # # ]: 0 : xAttrList);
2109 : : break;
2110 : : case XML_TOK_MPHANTOM:
2111 : 0 : pContext = GetSmImport().CreatePhantomContext(nPrefix,rLocalName,
2112 [ # # ]: 0 : xAttrList);
2113 : : break;
2114 : : case XML_TOK_MFENCED:
2115 : 0 : pContext = GetSmImport().CreateFencedContext(nPrefix,rLocalName,
2116 [ # # ]: 0 : xAttrList);
2117 : : break;
2118 : : /*Script and Limit Schemata*/
2119 : : case XML_TOK_MSUB:
2120 : 0 : pContext = GetSmImport().CreateSubContext(nPrefix,rLocalName,
2121 [ # # ]: 0 : xAttrList);
2122 : : break;
2123 : : case XML_TOK_MSUP:
2124 : 0 : pContext = GetSmImport().CreateSupContext(nPrefix,rLocalName,
2125 [ # # ]: 0 : xAttrList);
2126 : : break;
2127 : : case XML_TOK_MSUBSUP:
2128 : 0 : pContext = GetSmImport().CreateSubSupContext(nPrefix,rLocalName,
2129 [ # # ]: 0 : xAttrList);
2130 : : break;
2131 : : case XML_TOK_MUNDER:
2132 : 0 : pContext = GetSmImport().CreateUnderContext(nPrefix,rLocalName,
2133 [ # # ]: 0 : xAttrList);
2134 : : break;
2135 : : case XML_TOK_MOVER:
2136 : 0 : pContext = GetSmImport().CreateOverContext(nPrefix,rLocalName,
2137 [ # # ]: 0 : xAttrList);
2138 : : break;
2139 : : case XML_TOK_MUNDEROVER:
2140 : 0 : pContext = GetSmImport().CreateUnderOverContext(nPrefix,rLocalName,
2141 [ # # ]: 0 : xAttrList);
2142 : : break;
2143 : : case XML_TOK_MMULTISCRIPTS:
2144 : 0 : pContext = GetSmImport().CreateMultiScriptsContext(nPrefix,
2145 [ # # ]: 0 : rLocalName, xAttrList);
2146 : : break;
2147 : : case XML_TOK_MTABLE:
2148 : 0 : pContext = GetSmImport().CreateTableContext(nPrefix,
2149 [ # # ]: 0 : rLocalName, xAttrList);
2150 : : break;
2151 : : case XML_TOK_MACTION:
2152 : 0 : pContext = GetSmImport().CreateActionContext(nPrefix,
2153 [ # # ]: 0 : rLocalName, xAttrList);
2154 : : break;
2155 : : default:
2156 : : /*Basically theres an implicit mrow around certain bare
2157 : : *elements, use a RowContext to see if this is one of
2158 : : *those ones*/
2159 : 0 : SmXMLRowContext_Impl aTempContext(GetSmImport(),nPrefix,
2160 [ # # # # ]: 0 : GetXMLToken(XML_MROW));
2161 : :
2162 : : pContext = aTempContext.StrictCreateChildContext(nPrefix,
2163 [ # # ]: 0 : rLocalName, xAttrList);
2164 [ # # ]: 0 : break;
2165 : : }
2166 : 0 : return pContext;
2167 : : }
2168 : :
2169 : 0 : void SmXMLDocContext_Impl::EndElement()
2170 : : {
2171 [ # # ]: 0 : SmNodeArray ContextArray;
2172 [ # # ]: 0 : ContextArray.resize(1);
2173 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2174 : :
2175 [ # # ]: 0 : ContextArray[0] = lcl_popOrZero(rNodeStack);
2176 : :
2177 [ # # ]: 0 : SmToken aDummy;
2178 [ # # ][ # # ]: 0 : SmStructureNode *pSNode = new SmLineNode(aDummy);
2179 [ # # ]: 0 : pSNode->SetSubNodes(ContextArray);
2180 [ # # ]: 0 : rNodeStack.push(pSNode);
2181 : :
2182 [ # # ]: 0 : SmNodeArray LineArray;
2183 : 0 : sal_uLong n = rNodeStack.size();
2184 [ # # ]: 0 : LineArray.resize(n);
2185 [ # # ]: 0 : for (sal_uLong j = 0; j < n; j++)
2186 : : {
2187 [ # # ]: 0 : LineArray[n - (j + 1)] = rNodeStack.top();
2188 [ # # ]: 0 : rNodeStack.pop();
2189 : : }
2190 [ # # ][ # # ]: 0 : SmStructureNode *pSNode2 = new SmTableNode(aDummy);
2191 [ # # ]: 0 : pSNode2->SetSubNodes(LineArray);
2192 [ # # ][ # # ]: 0 : rNodeStack.push(pSNode2);
2193 : 0 : }
2194 : :
2195 : 0 : void SmXMLFracContext_Impl::EndElement()
2196 : : {
2197 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2198 : 0 : const bool bNodeCheck = rNodeStack.size() - nElementCount == 2;
2199 : : OSL_ENSURE( bNodeCheck, "Fraction (mfrac) tag is missing component" );
2200 [ # # ]: 0 : if (!bNodeCheck)
2201 : 0 : return;
2202 : :
2203 [ # # ]: 0 : SmToken aToken;
2204 : 0 : aToken.cMathChar = '\0';
2205 : 0 : aToken.nGroup = 0;
2206 : 0 : aToken.nLevel = 0;
2207 : 0 : aToken.eType = TOVER;
2208 [ # # ][ # # ]: 0 : SmStructureNode *pSNode = new SmBinVerNode(aToken);
2209 [ # # ][ # # ]: 0 : SmNode *pOper = new SmRectangleNode(aToken);
2210 [ # # ]: 0 : SmNode *pSecond = lcl_popOrZero(rNodeStack);
2211 [ # # ]: 0 : SmNode *pFirst = lcl_popOrZero(rNodeStack);
2212 [ # # ]: 0 : pSNode->SetSubNodes(pFirst,pOper,pSecond);
2213 [ # # ][ # # ]: 0 : rNodeStack.push(pSNode);
2214 : : }
2215 : :
2216 : 0 : void SmXMLRootContext_Impl::EndElement()
2217 : : {
2218 : : /*The <mroot> element requires exactly 2 arguments.*/
2219 : 0 : const bool bNodeCheck = GetSmImport().GetNodeStack().size() - nElementCount == 2;
2220 : : OSL_ENSURE( bNodeCheck, "Root tag is missing component");
2221 [ # # ]: 0 : if (!bNodeCheck)
2222 : 0 : return;
2223 : :
2224 [ # # ]: 0 : SmToken aToken;
2225 : 0 : aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font
2226 : 0 : aToken.nGroup = 0;
2227 : 0 : aToken.nLevel = 0;
2228 : 0 : aToken.eType = TNROOT;
2229 [ # # ][ # # ]: 0 : SmStructureNode *pSNode = new SmRootNode(aToken);
2230 [ # # ][ # # ]: 0 : SmNode *pOper = new SmRootSymbolNode(aToken);
2231 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2232 [ # # ]: 0 : SmNode *pIndex = lcl_popOrZero(rNodeStack);
2233 [ # # ]: 0 : SmNode *pBase = lcl_popOrZero(rNodeStack);
2234 [ # # ]: 0 : pSNode->SetSubNodes(pIndex,pOper,pBase);
2235 [ # # ][ # # ]: 0 : rNodeStack.push(pSNode);
2236 : : }
2237 : :
2238 : 0 : void SmXMLSqrtContext_Impl::EndElement()
2239 : : {
2240 : : /*
2241 : : <msqrt> accepts any number of arguments; if this number is not 1, its
2242 : : contents are treated as a single "inferred <mrow>" containing its
2243 : : arguments
2244 : : */
2245 [ # # ]: 0 : if (GetSmImport().GetNodeStack().size() - nElementCount > 1)
2246 [ # # ]: 0 : SmXMLRowContext_Impl::EndElement();
2247 : :
2248 [ # # ]: 0 : SmToken aToken;
2249 : 0 : aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font
2250 : 0 : aToken.nGroup = 0;
2251 : 0 : aToken.nLevel = 0;
2252 : 0 : aToken.eType = TSQRT;
2253 [ # # ][ # # ]: 0 : SmStructureNode *pSNode = new SmRootNode(aToken);
2254 [ # # ][ # # ]: 0 : SmNode *pOper = new SmRootSymbolNode(aToken);
2255 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2256 [ # # ][ # # ]: 0 : pSNode->SetSubNodes(0,pOper,lcl_popOrZero(rNodeStack));
2257 [ # # ][ # # ]: 0 : rNodeStack.push(pSNode);
2258 : 0 : }
2259 : :
2260 : 0 : void SmXMLRowContext_Impl::EndElement()
2261 : : {
2262 [ # # ]: 0 : SmNodeArray aRelationArray;
2263 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2264 : 0 : sal_uLong nSize = rNodeStack.size()-nElementCount;
2265 : :
2266 [ # # ]: 0 : if (nSize > 0)
2267 : : {
2268 [ # # ]: 0 : aRelationArray.resize(nSize);
2269 [ # # ]: 0 : for (sal_uLong j=nSize;j > 0;j--)
2270 : : {
2271 [ # # ]: 0 : aRelationArray[j-1] = rNodeStack.top();
2272 [ # # ]: 0 : rNodeStack.pop();
2273 : : }
2274 : :
2275 : : //If the first or last element is an operator with stretchyness
2276 : : //set then we must create a brace node here from those elements,
2277 : : //removing the stretchness from the operators and applying it to
2278 : : //ourselves, and creating the appropriate dummy StarMath none bracket
2279 : : //to balance the arrangement
2280 [ # # # # : 0 : if (((aRelationArray[0]->GetScaleMode() == SCALE_HEIGHT)
# # # # ]
[ # # ]
2281 : 0 : && (aRelationArray[0]->GetType() == NMATH))
2282 : 0 : || ((aRelationArray[nSize-1]->GetScaleMode() == SCALE_HEIGHT)
2283 : 0 : && (aRelationArray[nSize-1]->GetType() == NMATH)))
2284 : : {
2285 [ # # ]: 0 : SmToken aToken;
2286 : 0 : aToken.cMathChar = '\0';
2287 : 0 : aToken.nGroup = 0;
2288 : 0 : aToken.nLevel = 5;
2289 : :
2290 : 0 : int nLeft=0,nRight=0;
2291 [ # # # # ]: 0 : if ((aRelationArray[0]->GetScaleMode() == SCALE_HEIGHT)
[ # # ]
2292 : 0 : && (aRelationArray[0]->GetType() == NMATH))
2293 : : {
2294 [ # # ]: 0 : aToken = aRelationArray[0]->GetToken();
2295 : 0 : nLeft=1;
2296 : : }
2297 : : else
2298 : 0 : aToken.cMathChar = '\0';
2299 : :
2300 : 0 : aToken.eType = TLPARENT;
2301 [ # # ][ # # ]: 0 : SmNode *pLeft = new SmMathSymbolNode(aToken);
2302 : :
2303 [ # # # # ]: 0 : if ((aRelationArray[nSize-1]->GetScaleMode() == SCALE_HEIGHT)
[ # # ]
2304 : 0 : && (aRelationArray[nSize-1]->GetType() == NMATH))
2305 : : {
2306 [ # # ]: 0 : aToken = aRelationArray[nSize-1]->GetToken();
2307 : 0 : nRight=1;
2308 : : }
2309 : : else
2310 : 0 : aToken.cMathChar = '\0';
2311 : :
2312 : 0 : aToken.eType = TRPARENT;
2313 [ # # ][ # # ]: 0 : SmNode *pRight = new SmMathSymbolNode(aToken);
2314 : :
2315 [ # # ]: 0 : SmNodeArray aRelationArray2;
2316 : :
2317 : : //!! nSize-nLeft-nRight may be < 0 !!
2318 : 0 : int nRelArrSize = nSize-nLeft-nRight;
2319 [ # # ]: 0 : if (nRelArrSize > 0)
2320 : : {
2321 [ # # ]: 0 : aRelationArray2.resize(nRelArrSize);
2322 [ # # ]: 0 : for (int i=0;i < nRelArrSize;i++)
2323 : 0 : aRelationArray2[i] = aRelationArray[i+nLeft];
2324 : : }
2325 : :
2326 [ # # ]: 0 : SmToken aDummy;
2327 [ # # ][ # # ]: 0 : SmStructureNode *pSNode = new SmBraceNode(aToken);
2328 [ # # ][ # # ]: 0 : SmStructureNode *pBody = new SmExpressionNode(aDummy);
2329 [ # # ]: 0 : pBody->SetSubNodes(aRelationArray2);
2330 : :
2331 [ # # ]: 0 : pSNode->SetSubNodes(pLeft,pBody,pRight);
2332 : 0 : pSNode->SetScaleMode(SCALE_HEIGHT);
2333 [ # # ]: 0 : rNodeStack.push(pSNode);
2334 [ # # ][ # # ]: 0 : return;
2335 : : }
2336 : : }
2337 : : else //Multiple newlines result in empty row elements
2338 : : {
2339 [ # # ]: 0 : aRelationArray.resize(1);
2340 [ # # ]: 0 : SmToken aToken;
2341 : 0 : aToken.cMathChar = '\0';
2342 : 0 : aToken.nGroup = 0;
2343 : 0 : aToken.nLevel = 5;
2344 : 0 : aToken.eType = TNEWLINE;
2345 [ # # ][ # # ]: 0 : aRelationArray[0] = new SmLineNode(aToken);
[ # # ]
2346 : : }
2347 : :
2348 [ # # ]: 0 : SmToken aDummy;
2349 [ # # ][ # # ]: 0 : SmStructureNode *pSNode = new SmExpressionNode(aDummy);
2350 [ # # ]: 0 : pSNode->SetSubNodes(aRelationArray);
2351 [ # # ][ # # ]: 0 : rNodeStack.push(pSNode);
[ # # ]
2352 : : }
2353 : :
2354 : :
2355 : 0 : SvXMLImportContext *SmXMLRowContext_Impl::StrictCreateChildContext(
2356 : : sal_uInt16 nPrefix,
2357 : : const OUString& rLocalName,
2358 : : const uno::Reference<xml::sax::XAttributeList>& xAttrList)
2359 : : {
2360 : 0 : SvXMLImportContext* pContext = 0L;
2361 : :
2362 : 0 : const SvXMLTokenMap& rTokenMap = GetSmImport().GetPresElemTokenMap();
2363 [ # # # # : 0 : switch(rTokenMap.Get(nPrefix, rLocalName))
# # # #
# ]
2364 : : {
2365 : : /*Note that these should accept malignmark subelements, but do not*/
2366 : : case XML_TOK_MN:
2367 : 0 : pContext = GetSmImport().CreateNumberContext(nPrefix,rLocalName,
2368 : 0 : xAttrList);
2369 : 0 : break;
2370 : : case XML_TOK_MI:
2371 : 0 : pContext = GetSmImport().CreateIdentifierContext(nPrefix,rLocalName,
2372 : 0 : xAttrList);
2373 : 0 : break;
2374 : : case XML_TOK_MO:
2375 : 0 : pContext = GetSmImport().CreateOperatorContext(nPrefix,rLocalName,
2376 : 0 : xAttrList);
2377 : 0 : break;
2378 : : case XML_TOK_MTEXT:
2379 : 0 : pContext = GetSmImport().CreateTextContext(nPrefix,rLocalName,
2380 : 0 : xAttrList);
2381 : 0 : break;
2382 : : case XML_TOK_MSPACE:
2383 : 0 : pContext = GetSmImport().CreateSpaceContext(nPrefix,rLocalName,
2384 : 0 : xAttrList);
2385 : 0 : break;
2386 : : case XML_TOK_MS:
2387 : 0 : pContext = GetSmImport().CreateStringContext(nPrefix,rLocalName,
2388 : 0 : xAttrList);
2389 : 0 : break;
2390 : :
2391 : : /*Note: The maligngroup should only be seen when the row
2392 : : * (or decendants) are in a table*/
2393 : : case XML_TOK_MALIGNGROUP:
2394 : 0 : pContext = GetSmImport().CreateAlignGroupContext(nPrefix,rLocalName,
2395 : 0 : xAttrList);
2396 : 0 : break;
2397 : :
2398 : : case XML_TOK_ANNOTATION:
2399 : 0 : pContext = GetSmImport().CreateAnnotationContext(nPrefix,rLocalName,
2400 : 0 : xAttrList);
2401 : 0 : break;
2402 : :
2403 : : default:
2404 : 0 : break;
2405 : : }
2406 : 0 : return pContext;
2407 : : }
2408 : :
2409 : :
2410 : 0 : SvXMLImportContext *SmXMLRowContext_Impl::CreateChildContext(
2411 : : sal_uInt16 nPrefix,
2412 : : const OUString& rLocalName,
2413 : : const uno::Reference<xml::sax::XAttributeList>& xAttrList)
2414 : : {
2415 : : SvXMLImportContext* pContext = StrictCreateChildContext(nPrefix,
2416 : 0 : rLocalName, xAttrList);
2417 : :
2418 [ # # ]: 0 : if (!pContext)
2419 : : {
2420 : : //Hmm, unrecognized for this level, check to see if its
2421 : : //an element that can have an implicit schema around it
2422 : : pContext = SmXMLDocContext_Impl::CreateChildContext(nPrefix,
2423 : 0 : rLocalName,xAttrList);
2424 : : }
2425 : 0 : return pContext;
2426 : : }
2427 : :
2428 : :
2429 : 0 : SvXMLImportContext *SmXMLMultiScriptsContext_Impl::CreateChildContext(
2430 : : sal_uInt16 nPrefix,
2431 : : const OUString& rLocalName,
2432 : : const uno::Reference<xml::sax::XAttributeList>& xAttrList)
2433 : : {
2434 : 0 : SvXMLImportContext* pContext = 0L;
2435 : :
2436 : 0 : const SvXMLTokenMap& rTokenMap = GetSmImport().
2437 : 0 : GetPresScriptEmptyElemTokenMap();
2438 [ # # # ]: 0 : switch(rTokenMap.Get(nPrefix, rLocalName))
2439 : : {
2440 : : case XML_TOK_MPRESCRIPTS:
2441 : 0 : bHasPrescripts = true;
2442 : 0 : ProcessSubSupPairs(false);
2443 : 0 : pContext = GetSmImport().CreatePrescriptsContext(nPrefix,
2444 : 0 : rLocalName, xAttrList);
2445 : 0 : break;
2446 : : case XML_TOK_NONE:
2447 : 0 : pContext = GetSmImport().CreateNoneContext(nPrefix,rLocalName,
2448 : 0 : xAttrList);
2449 : 0 : break;
2450 : : default:
2451 : : pContext = SmXMLRowContext_Impl::CreateChildContext(nPrefix,
2452 : 0 : rLocalName,xAttrList);
2453 : 0 : break;
2454 : : }
2455 : 0 : return pContext;
2456 : : }
2457 : :
2458 : 0 : void SmXMLMultiScriptsContext_Impl::ProcessSubSupPairs(bool bIsPrescript)
2459 : : {
2460 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2461 : :
2462 [ # # ]: 0 : if (rNodeStack.size() <= nElementCount)
2463 : 0 : return;
2464 : :
2465 : 0 : sal_uLong nCount = rNodeStack.size() - nElementCount - 1;
2466 [ # # ]: 0 : if (nCount == 0)
2467 : 0 : return;
2468 : :
2469 [ # # ]: 0 : if (nCount % 2 == 0)
2470 : : {
2471 [ # # ]: 0 : SmToken aToken;
2472 : 0 : aToken.cMathChar = '\0';
2473 : 0 : aToken.nGroup = 0;
2474 : 0 : aToken.nLevel = 0;
2475 [ # # ]: 0 : aToken.eType = bIsPrescript ? TLSUB : TRSUB;
2476 : :
2477 [ # # ][ # # ]: 0 : SmNodeStack aReverseStack;
2478 [ # # ]: 0 : for (sal_uLong i = 0; i < nCount + 1; i++)
2479 : : {
2480 [ # # ][ # # ]: 0 : aReverseStack.push(rNodeStack.top());
2481 [ # # ]: 0 : rNodeStack.pop();
2482 : : }
2483 : :
2484 [ # # ]: 0 : SmSubSup eSub = bIsPrescript ? LSUB : RSUB;
2485 [ # # ]: 0 : SmSubSup eSup = bIsPrescript ? LSUP : RSUP;
2486 : :
2487 [ # # ]: 0 : for (sal_uLong i = 0; i < nCount; i += 2)
2488 : : {
2489 [ # # ][ # # ]: 0 : SmSubSupNode *pNode = new SmSubSupNode(aToken);
2490 : :
2491 : : // initialize subnodes array
2492 [ # # ]: 0 : SmNodeArray aSubNodes(1 + SUBSUP_NUM_ENTRIES);
2493 : :
2494 : : /*On each loop the base and its sub sup pair becomes the
2495 : : base for the next loop to which the next sub sup pair is
2496 : : attached, i.e. wheels within wheels*/
2497 [ # # ]: 0 : aSubNodes[0] = lcl_popOrZero(aReverseStack);
2498 : :
2499 [ # # ]: 0 : SmNode *pScriptNode = lcl_popOrZero(aReverseStack);
2500 : :
2501 [ # # ]: 0 : if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) ||
[ # # # # ]
[ # # ]
2502 : 0 : (pScriptNode->GetToken().aText.Len())))
2503 : 0 : aSubNodes[eSub+1] = pScriptNode;
2504 [ # # ]: 0 : pScriptNode = lcl_popOrZero(aReverseStack);
2505 [ # # ]: 0 : if (pScriptNode && ((pScriptNode->GetToken().eType != TIDENT) ||
[ # # # # ]
[ # # ]
2506 : 0 : (pScriptNode->GetToken().aText.Len())))
2507 : 0 : aSubNodes[eSup+1] = pScriptNode;
2508 : :
2509 [ # # ]: 0 : pNode->SetSubNodes(aSubNodes);
2510 [ # # ]: 0 : aReverseStack.push(pNode);
2511 : 0 : }
2512 [ # # ][ # # ]: 0 : rNodeStack.push(lcl_popOrZero(aReverseStack));
[ # # ]
2513 : : }
2514 : : else
2515 : : {
2516 : : // Ignore odd number of elements.
2517 [ # # ]: 0 : for (sal_uLong i = 0; i < nCount; i++)
2518 : : {
2519 [ # # ]: 0 : delete rNodeStack.top();
2520 : 0 : rNodeStack.pop();
2521 : : }
2522 : : }
2523 : : }
2524 : :
2525 : :
2526 : 0 : void SmXMLTableContext_Impl::EndElement()
2527 : : {
2528 [ # # ]: 0 : SmNodeArray aExpressionArray;
2529 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2530 [ # # ][ # # ]: 0 : SmNodeStack aReverseStack;
2531 [ # # ]: 0 : aExpressionArray.resize(rNodeStack.size()-nElementCount);
2532 : :
2533 : 0 : sal_uLong nRows = rNodeStack.size()-nElementCount;
2534 : 0 : sal_uInt16 nCols = 0;
2535 : :
2536 : : SmStructureNode *pArray;
2537 [ # # ]: 0 : for (sal_uLong i=nRows;i > 0;i--)
2538 : : {
2539 [ # # ]: 0 : pArray = (SmStructureNode *)rNodeStack.top();
2540 [ # # ]: 0 : rNodeStack.pop();
2541 [ # # ][ # # ]: 0 : if (pArray->GetNumSubNodes() == 0)
2542 : : {
2543 : : //This is a little tricky, it is possible that there was
2544 : : //be elements that were not inside a <mtd> pair, in which
2545 : : //case they will not be in a row, i.e. they will not have
2546 : : //SubNodes, so we have to wait until here before we can
2547 : : //resolve the situation. Implicitsurrounding tags are
2548 : : //surprisingly difficult to get right within this
2549 : : //architecture
2550 : :
2551 [ # # ]: 0 : SmNodeArray aRelationArray;
2552 [ # # ]: 0 : aRelationArray.resize(1);
2553 : 0 : aRelationArray[0] = pArray;
2554 [ # # ]: 0 : SmToken aDummy;
2555 [ # # ][ # # ]: 0 : pArray = new SmExpressionNode(aDummy);
2556 [ # # ][ # # ]: 0 : pArray->SetSubNodes(aRelationArray);
2557 : : }
2558 : :
2559 [ # # ][ # # ]: 0 : if (pArray->GetNumSubNodes() > nCols)
2560 [ # # ]: 0 : nCols = pArray->GetNumSubNodes();
2561 [ # # ]: 0 : aReverseStack.push(pArray);
2562 : : }
2563 [ # # ]: 0 : aExpressionArray.resize(nCols*nRows);
2564 : 0 : sal_uLong j=0;
2565 [ # # ]: 0 : while ( !aReverseStack.empty() )
2566 : : {
2567 [ # # ]: 0 : pArray = (SmStructureNode *)aReverseStack.top();
2568 [ # # ]: 0 : aReverseStack.pop();
2569 [ # # ][ # # ]: 0 : for (sal_uInt16 i=0;i<pArray->GetNumSubNodes();i++)
2570 [ # # ]: 0 : aExpressionArray[j++] = pArray->GetSubNode(i);
2571 : : }
2572 : :
2573 [ # # ]: 0 : SmToken aToken;
2574 : 0 : aToken.cMathChar = '\0';
2575 : 0 : aToken.nGroup = TRGROUP;
2576 : 0 : aToken.nLevel = 0;
2577 : 0 : aToken.eType = TMATRIX;
2578 [ # # ][ # # ]: 0 : SmMatrixNode *pSNode = new SmMatrixNode(aToken);
2579 [ # # ]: 0 : pSNode->SetSubNodes(aExpressionArray);
2580 [ # # ]: 0 : pSNode->SetRowCol(static_cast<sal_uInt16>(nRows),nCols);
2581 [ # # ][ # # ]: 0 : rNodeStack.push(pSNode);
2582 : 0 : }
2583 : :
2584 : 0 : SvXMLImportContext *SmXMLTableRowContext_Impl::CreateChildContext(
2585 : : sal_uInt16 nPrefix,
2586 : : const OUString& rLocalName,
2587 : : const uno::Reference<xml::sax::XAttributeList>& xAttrList)
2588 : : {
2589 : 0 : SvXMLImportContext* pContext = 0L;
2590 : :
2591 : 0 : const SvXMLTokenMap& rTokenMap = GetSmImport().
2592 : 0 : GetPresTableElemTokenMap();
2593 [ # # ]: 0 : switch(rTokenMap.Get(nPrefix, rLocalName))
2594 : : {
2595 : : case XML_TOK_MTD:
2596 : 0 : pContext = GetSmImport().CreateTableCellContext(nPrefix,
2597 : 0 : rLocalName, xAttrList);
2598 : 0 : break;
2599 : : default:
2600 : : pContext = SmXMLRowContext_Impl::CreateChildContext(nPrefix,
2601 : 0 : rLocalName,xAttrList);
2602 : 0 : break;
2603 : : }
2604 : 0 : return pContext;
2605 : : }
2606 : :
2607 : 0 : SvXMLImportContext *SmXMLTableContext_Impl::CreateChildContext(
2608 : : sal_uInt16 nPrefix,
2609 : : const OUString& rLocalName,
2610 : : const uno::Reference<xml::sax::XAttributeList>& xAttrList)
2611 : : {
2612 : 0 : SvXMLImportContext* pContext = 0L;
2613 : :
2614 : 0 : const SvXMLTokenMap& rTokenMap = GetSmImport().
2615 : 0 : GetPresTableElemTokenMap();
2616 [ # # ]: 0 : switch(rTokenMap.Get(nPrefix, rLocalName))
2617 : : {
2618 : : case XML_TOK_MTR:
2619 : 0 : pContext = GetSmImport().CreateTableRowContext(nPrefix,rLocalName,
2620 : 0 : xAttrList);
2621 : 0 : break;
2622 : : default:
2623 : : pContext = SmXMLTableRowContext_Impl::CreateChildContext(nPrefix,
2624 : 0 : rLocalName,xAttrList);
2625 : 0 : break;
2626 : : }
2627 : 0 : return pContext;
2628 : : }
2629 : :
2630 : 0 : void SmXMLMultiScriptsContext_Impl::EndElement()
2631 : : {
2632 : 0 : ProcessSubSupPairs(bHasPrescripts);
2633 : 0 : }
2634 : :
2635 : 0 : void SmXMLActionContext_Impl::EndElement()
2636 : : {
2637 : : /*For now we will just assume that the
2638 : : selected attribute is one, and then just display
2639 : : that expression alone, i.e. remove all expect the
2640 : : first pushed one*/
2641 : :
2642 : 0 : SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
2643 [ # # ]: 0 : for (sal_uLong i=rNodeStack.size()-nElementCount;i > 1;i--)
2644 : : {
2645 [ # # ]: 0 : delete rNodeStack.top();
2646 : 0 : rNodeStack.pop();
2647 : : }
2648 : 0 : }
2649 : :
2650 : 0 : SvXMLImportContext *SmXMLImport::CreateContext(sal_uInt16 nPrefix,
2651 : : const OUString &rLocalName,
2652 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2653 : : {
2654 [ # # ]: 0 : if ( XML_NAMESPACE_OFFICE == nPrefix )
2655 : : {
2656 [ # # # # ]: 0 : if ( (IsXMLToken(rLocalName, XML_DOCUMENT) ||
[ # # ]
2657 : 0 : IsXMLToken(rLocalName, XML_DOCUMENT_META)))
2658 : : {
2659 : : uno::Reference<xml::sax::XDocumentHandler> xDocBuilder(
2660 [ # # ]: 0 : mxServiceFactory->createInstance(
2661 : 0 : "com.sun.star.xml.dom.SAXDocumentBuilder"),
2662 [ # # ][ # # ]: 0 : uno::UNO_QUERY_THROW);
2663 : : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
2664 [ # # ]: 0 : GetModel(), uno::UNO_QUERY_THROW);
2665 [ # # ]: 0 : return IsXMLToken(rLocalName, XML_DOCUMENT_META)
2666 : : ? new SvXMLMetaDocumentContext(*this,
2667 : : XML_NAMESPACE_OFFICE, rLocalName,
2668 [ # # ][ # # ]: 0 : xDPS->getDocumentProperties(), xDocBuilder)
2669 : : // flat OpenDocument file format -- this has not been tested...
2670 : : : new SmXMLFlatDocContext_Impl( *this, nPrefix, rLocalName,
2671 [ # # ][ # # ]: 0 : xDPS->getDocumentProperties(), xDocBuilder);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
2672 : : }
2673 : : else
2674 : : {
2675 [ # # ][ # # ]: 0 : return new SmXMLOfficeContext_Impl( *this,nPrefix,rLocalName);
2676 : : }
2677 : : }
2678 : : else
2679 [ # # ]: 0 : return new SmXMLDocContext_Impl(*this,nPrefix,rLocalName);
2680 : : }
2681 : :
2682 : 0 : SvXMLImportContext *SmXMLImport::CreateRowContext(sal_uInt16 nPrefix,
2683 : : const OUString &rLocalName,
2684 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2685 : : {
2686 [ # # ]: 0 : return new SmXMLRowContext_Impl(*this,nPrefix,rLocalName);
2687 : : }
2688 : :
2689 : 0 : SvXMLImportContext *SmXMLImport::CreateTextContext(sal_uInt16 nPrefix,
2690 : : const OUString &rLocalName,
2691 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2692 : : {
2693 [ # # ]: 0 : return new SmXMLTextContext_Impl(*this,nPrefix,rLocalName);
2694 : : }
2695 : :
2696 : 0 : SvXMLImportContext *SmXMLImport::CreateAnnotationContext(sal_uInt16 nPrefix,
2697 : : const OUString &rLocalName,
2698 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2699 : : {
2700 [ # # ]: 0 : return new SmXMLAnnotationContext_Impl(*this,nPrefix,rLocalName);
2701 : : }
2702 : :
2703 : 0 : SvXMLImportContext *SmXMLImport::CreateStringContext(sal_uInt16 nPrefix,
2704 : : const OUString &rLocalName,
2705 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2706 : : {
2707 [ # # ]: 0 : return new SmXMLStringContext_Impl(*this,nPrefix,rLocalName);
2708 : : }
2709 : :
2710 : 0 : SvXMLImportContext *SmXMLImport::CreateNumberContext(sal_uInt16 nPrefix,
2711 : : const OUString &rLocalName,
2712 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2713 : : {
2714 [ # # ]: 0 : return new SmXMLNumberContext_Impl(*this,nPrefix,rLocalName);
2715 : : }
2716 : :
2717 : 0 : SvXMLImportContext *SmXMLImport::CreateIdentifierContext(sal_uInt16 nPrefix,
2718 : : const OUString &rLocalName,
2719 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2720 : : {
2721 [ # # ]: 0 : return new SmXMLIdentifierContext_Impl(*this,nPrefix,rLocalName);
2722 : : }
2723 : :
2724 : 0 : SvXMLImportContext *SmXMLImport::CreateOperatorContext(sal_uInt16 nPrefix,
2725 : : const OUString &rLocalName,
2726 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2727 : : {
2728 [ # # ]: 0 : return new SmXMLOperatorContext_Impl(*this,nPrefix,rLocalName);
2729 : : }
2730 : :
2731 : 0 : SvXMLImportContext *SmXMLImport::CreateSpaceContext(sal_uInt16 nPrefix,
2732 : : const OUString &rLocalName,
2733 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2734 : : {
2735 [ # # ]: 0 : return new SmXMLSpaceContext_Impl(*this,nPrefix,rLocalName);
2736 : : }
2737 : :
2738 : :
2739 : 0 : SvXMLImportContext *SmXMLImport::CreateFracContext(sal_uInt16 nPrefix,
2740 : : const OUString &rLocalName,
2741 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2742 : : {
2743 [ # # ]: 0 : return new SmXMLFracContext_Impl(*this,nPrefix,rLocalName);
2744 : : }
2745 : :
2746 : 0 : SvXMLImportContext *SmXMLImport::CreateSqrtContext(sal_uInt16 nPrefix,
2747 : : const OUString &rLocalName,
2748 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2749 : : {
2750 [ # # ]: 0 : return new SmXMLSqrtContext_Impl(*this,nPrefix,rLocalName);
2751 : : }
2752 : :
2753 : 0 : SvXMLImportContext *SmXMLImport::CreateRootContext(sal_uInt16 nPrefix,
2754 : : const OUString &rLocalName,
2755 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2756 : : {
2757 [ # # ]: 0 : return new SmXMLRootContext_Impl(*this,nPrefix,rLocalName);
2758 : : }
2759 : :
2760 : 0 : SvXMLImportContext *SmXMLImport::CreateStyleContext(sal_uInt16 nPrefix,
2761 : : const OUString &rLocalName,
2762 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2763 : : {
2764 [ # # ]: 0 : return new SmXMLStyleContext_Impl(*this,nPrefix,rLocalName);
2765 : : }
2766 : :
2767 : 0 : SvXMLImportContext *SmXMLImport::CreatePaddedContext(sal_uInt16 nPrefix,
2768 : : const OUString &rLocalName,
2769 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2770 : : {
2771 [ # # ]: 0 : return new SmXMLPaddedContext_Impl(*this,nPrefix,rLocalName);
2772 : : }
2773 : :
2774 : 0 : SvXMLImportContext *SmXMLImport::CreatePhantomContext(sal_uInt16 nPrefix,
2775 : : const OUString &rLocalName,
2776 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2777 : : {
2778 [ # # ]: 0 : return new SmXMLPhantomContext_Impl(*this,nPrefix,rLocalName);
2779 : : }
2780 : :
2781 : 0 : SvXMLImportContext *SmXMLImport::CreateFencedContext(sal_uInt16 nPrefix,
2782 : : const OUString &rLocalName,
2783 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2784 : : {
2785 [ # # ]: 0 : return new SmXMLFencedContext_Impl(*this,nPrefix,rLocalName);
2786 : : }
2787 : :
2788 : 0 : SvXMLImportContext *SmXMLImport::CreateErrorContext(sal_uInt16 nPrefix,
2789 : : const OUString &rLocalName,
2790 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2791 : : {
2792 [ # # ]: 0 : return new SmXMLErrorContext_Impl(*this,nPrefix,rLocalName);
2793 : : }
2794 : :
2795 : 0 : SvXMLImportContext *SmXMLImport::CreateSubContext(sal_uInt16 nPrefix,
2796 : : const OUString &rLocalName,
2797 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2798 : : {
2799 [ # # ]: 0 : return new SmXMLSubContext_Impl(*this,nPrefix,rLocalName);
2800 : : }
2801 : :
2802 : 0 : SvXMLImportContext *SmXMLImport::CreateSubSupContext(sal_uInt16 nPrefix,
2803 : : const OUString &rLocalName,
2804 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2805 : : {
2806 [ # # ]: 0 : return new SmXMLSubSupContext_Impl(*this,nPrefix,rLocalName);
2807 : : }
2808 : :
2809 : 0 : SvXMLImportContext *SmXMLImport::CreateSupContext(sal_uInt16 nPrefix,
2810 : : const OUString &rLocalName,
2811 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2812 : : {
2813 [ # # ]: 0 : return new SmXMLSupContext_Impl(*this,nPrefix,rLocalName);
2814 : : }
2815 : :
2816 : 0 : SvXMLImportContext *SmXMLImport::CreateUnderContext(sal_uInt16 nPrefix,
2817 : : const OUString &rLocalName,
2818 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2819 : : {
2820 [ # # ]: 0 : return new SmXMLUnderContext_Impl(*this,nPrefix,rLocalName);
2821 : : }
2822 : :
2823 : 0 : SvXMLImportContext *SmXMLImport::CreateOverContext(sal_uInt16 nPrefix,
2824 : : const OUString &rLocalName,
2825 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2826 : : {
2827 [ # # ]: 0 : return new SmXMLOverContext_Impl(*this,nPrefix,rLocalName);
2828 : : }
2829 : :
2830 : 0 : SvXMLImportContext *SmXMLImport::CreateUnderOverContext(sal_uInt16 nPrefix,
2831 : : const OUString &rLocalName,
2832 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2833 : : {
2834 [ # # ]: 0 : return new SmXMLUnderOverContext_Impl(*this,nPrefix,rLocalName);
2835 : : }
2836 : :
2837 : 0 : SvXMLImportContext *SmXMLImport::CreateMultiScriptsContext(sal_uInt16 nPrefix,
2838 : : const OUString &rLocalName,
2839 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2840 : : {
2841 [ # # ]: 0 : return new SmXMLMultiScriptsContext_Impl(*this,nPrefix,rLocalName);
2842 : : }
2843 : :
2844 : 0 : SvXMLImportContext *SmXMLImport::CreateTableContext(sal_uInt16 nPrefix,
2845 : : const OUString &rLocalName,
2846 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2847 : : {
2848 [ # # ]: 0 : return new SmXMLTableContext_Impl(*this,nPrefix,rLocalName);
2849 : : }
2850 : 0 : SvXMLImportContext *SmXMLImport::CreateTableRowContext(sal_uInt16 nPrefix,
2851 : : const OUString &rLocalName,
2852 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2853 : : {
2854 [ # # ]: 0 : return new SmXMLTableRowContext_Impl(*this,nPrefix,rLocalName);
2855 : : }
2856 : 0 : SvXMLImportContext *SmXMLImport::CreateTableCellContext(sal_uInt16 nPrefix,
2857 : : const OUString &rLocalName,
2858 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2859 : : {
2860 [ # # ]: 0 : return new SmXMLTableCellContext_Impl(*this,nPrefix,rLocalName);
2861 : : }
2862 : :
2863 : 0 : SvXMLImportContext *SmXMLImport::CreateNoneContext(sal_uInt16 nPrefix,
2864 : : const OUString &rLocalName,
2865 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2866 : : {
2867 [ # # ]: 0 : return new SmXMLNoneContext_Impl(*this,nPrefix,rLocalName);
2868 : : }
2869 : :
2870 : 0 : SvXMLImportContext *SmXMLImport::CreatePrescriptsContext(sal_uInt16 nPrefix,
2871 : : const OUString &rLocalName,
2872 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2873 : : {
2874 [ # # ]: 0 : return new SmXMLPrescriptsContext_Impl(*this,nPrefix,rLocalName);
2875 : : }
2876 : :
2877 : 0 : SvXMLImportContext *SmXMLImport::CreateAlignGroupContext(sal_uInt16 nPrefix,
2878 : : const OUString &rLocalName,
2879 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2880 : : {
2881 [ # # ]: 0 : return new SmXMLAlignGroupContext_Impl(*this,nPrefix,rLocalName);
2882 : : }
2883 : :
2884 : 0 : SvXMLImportContext *SmXMLImport::CreateActionContext(sal_uInt16 nPrefix,
2885 : : const OUString &rLocalName,
2886 : : const uno::Reference <xml::sax::XAttributeList> & /*xAttrList*/)
2887 : : {
2888 [ # # ]: 0 : return new SmXMLActionContext_Impl(*this,nPrefix,rLocalName);
2889 : : }
2890 : :
2891 [ + - ]: 12 : SmXMLImport::~SmXMLImport() throw ()
2892 : : {
2893 [ - + ][ # # ]: 12 : delete pPresLayoutElemTokenMap;
2894 [ - + ][ # # ]: 12 : delete pPresElemTokenMap;
2895 [ - + ][ # # ]: 12 : delete pPresScriptEmptyElemTokenMap;
2896 [ - + ][ # # ]: 12 : delete pPresTableElemTokenMap;
2897 [ - + ][ # # ]: 12 : delete pPresLayoutAttrTokenMap;
2898 [ - + ][ # # ]: 12 : delete pFencedAttrTokenMap;
2899 [ - + ][ # # ]: 12 : delete pColorTokenMap;
2900 [ - + ][ # # ]: 12 : delete pOperatorAttrTokenMap;
2901 [ - + ][ # # ]: 12 : delete pAnnotationAttrTokenMap;
2902 [ - + ]: 24 : }
2903 : :
2904 : 0 : void SmXMLImport::SetViewSettings(const Sequence<PropertyValue>& aViewProps)
2905 : : {
2906 : 0 : uno::Reference <frame::XModel> xModel = GetModel();
2907 [ # # ]: 0 : if ( !xModel.is() )
2908 : : return;
2909 : :
2910 : 0 : uno::Reference <lang::XUnoTunnel> xTunnel;
2911 [ # # ][ # # ]: 0 : xTunnel = uno::Reference <lang::XUnoTunnel> (xModel,uno::UNO_QUERY);
2912 : : SmModel *pModel = reinterpret_cast<SmModel *>
2913 [ # # ][ # # ]: 0 : (xTunnel->getSomething(SmModel::getUnoTunnelId()));
[ # # ]
2914 : :
2915 [ # # ]: 0 : if ( !pModel )
2916 : : return;
2917 : :
2918 : : SmDocShell *pDocShell =
2919 [ # # ]: 0 : static_cast<SmDocShell*>(pModel->GetObjectShell());
2920 [ # # ]: 0 : if ( !pDocShell )
2921 : : return;
2922 : :
2923 [ # # ]: 0 : Rectangle aRect( pDocShell->GetVisArea() );
2924 : :
2925 : 0 : sal_Int32 nCount = aViewProps.getLength();
2926 : 0 : const PropertyValue *pValue = aViewProps.getConstArray();
2927 : :
2928 : 0 : long nTmp = 0;
2929 : :
2930 [ # # ]: 0 : for (sal_Int32 i = 0; i < nCount ; i++)
2931 : : {
2932 [ # # ]: 0 : if (pValue->Name == "ViewAreaTop" )
2933 : : {
2934 : 0 : pValue->Value >>= nTmp;
2935 : 0 : aRect.setY( nTmp );
2936 : : }
2937 [ # # ]: 0 : else if (pValue->Name == "ViewAreaLeft" )
2938 : : {
2939 : 0 : pValue->Value >>= nTmp;
2940 : 0 : aRect.setX( nTmp );
2941 : : }
2942 [ # # ]: 0 : else if (pValue->Name == "ViewAreaWidth" )
2943 : : {
2944 : 0 : pValue->Value >>= nTmp;
2945 [ # # ]: 0 : Size aSize( aRect.GetSize() );
2946 : 0 : aSize.Width() = nTmp;
2947 [ # # ]: 0 : aRect.SetSize( aSize );
2948 : : }
2949 [ # # ]: 0 : else if (pValue->Name == "ViewAreaHeight" )
2950 : : {
2951 : 0 : pValue->Value >>= nTmp;
2952 [ # # ]: 0 : Size aSize( aRect.GetSize() );
2953 : 0 : aSize.Height() = nTmp;
2954 [ # # ]: 0 : aRect.SetSize( aSize );
2955 : : }
2956 : 0 : pValue++;
2957 : : }
2958 : :
2959 [ # # ][ # # ]: 0 : pDocShell->SetVisArea ( aRect );
[ # # ]
2960 : : }
2961 : :
2962 : 0 : void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfProps)
2963 : : {
2964 [ # # ]: 0 : uno::Reference < XPropertySet > xProps ( GetModel(), UNO_QUERY );
2965 [ # # ]: 0 : if ( xProps.is() )
2966 : : {
2967 [ # # ][ # # ]: 0 : Reference < XPropertySetInfo > xInfo ( xProps->getPropertySetInfo() );
2968 [ # # ]: 0 : if (xInfo.is() )
2969 : : {
2970 : 0 : sal_Int32 nCount = aConfProps.getLength();
2971 : 0 : const PropertyValue* pValues = aConfProps.getConstArray();
2972 : :
2973 : 0 : const OUString sFormula ( "Formula" );
2974 : 0 : const OUString sBasicLibraries ( "BasicLibraries" );
2975 : 0 : const OUString sDialogLibraries ( "DialogLibraries" );
2976 [ # # ]: 0 : while ( nCount-- )
2977 : : {
2978 [ # # # # : 0 : if (pValues->Name != sFormula &&
# # ][ # # ]
2979 : 0 : pValues->Name != sBasicLibraries &&
2980 : 0 : pValues->Name != sDialogLibraries)
2981 : : {
2982 : : try
2983 : : {
2984 [ # # ][ # # ]: 0 : if ( xInfo->hasPropertyByName( pValues->Name ) )
[ # # ]
2985 [ # # ][ # # ]: 0 : xProps->setPropertyValue( pValues->Name, pValues->Value );
2986 : : }
2987 [ # # ]: 0 : catch (const beans::PropertyVetoException &)
2988 : : {
2989 : : // dealing with read-only properties here. Nothing to do...
2990 : : }
2991 [ # # ]: 0 : catch( Exception& )
2992 : : {
2993 : : OSL_FAIL( "SmXMLImport::SetConfigurationSettings: Exception!" );
2994 : : }
2995 : : }
2996 : :
2997 : 0 : pValues++;
2998 : 0 : }
2999 : 0 : }
3000 : 0 : }
3001 [ + - ][ + - ]: 30 : }
[ # # # ]
3002 : :
3003 : :
3004 : : ////////////////////////////////////////////////////////////
3005 : :
3006 : :
3007 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|