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 : : #ifndef INCLUDED_OOXML_FAST_CONTEXT_HANDLER_HXX
21 : : #define INCLUDED_OOXML_FAST_CONTEXT_HANDLER_HXX
22 : :
23 : : #include <com/sun/star/xml/sax/XFastShapeContextHandler.hpp>
24 : :
25 : : #include <string>
26 : : #include <set>
27 : : #include "sal/config.h"
28 : : #include "com/sun/star/uno/XComponentContext.hpp"
29 : : #include "cppuhelper/implbase1.hxx"
30 : : #include "com/sun/star/xml/sax/XFastContextHandler.hpp"
31 : : #include "OOXMLParserState.hxx"
32 : : #include "OOXMLPropertySetImpl.hxx"
33 : : #include "OOXMLDocumentImpl.hxx"
34 : : #include "RefAndPointer.hxx"
35 : : #include <ooxml/OOXMLFastTokens.hxx>
36 : : #include <svtools/embedhlp.hxx>
37 : :
38 : : #include <oox/mathml/import.hxx>
39 : : #include <oox/mathml/importutils.hxx>
40 : :
41 : : namespace writerfilter {
42 : : namespace ooxml
43 : : {
44 : : using namespace ::std;
45 : : using namespace ::com::sun::star;
46 : : using namespace ::com::sun::star::xml::sax;
47 : :
48 : : typedef boost::shared_ptr<Stream> StreamPointer_t;
49 : :
50 [ + - ]: 9 : class OOXMLFastContextHandler:
51 : : public ::cppu::WeakImplHelper1<
52 : : xml::sax::XFastContextHandler>
53 : : {
54 : : public:
55 : : typedef RefAndPointer<XFastContextHandler, OOXMLFastContextHandler>
56 : : RefAndPointer_t;
57 : : typedef boost::shared_ptr<OOXMLFastContextHandler> Pointer_t;
58 : :
59 : : enum ResourceEnum_t { UNKNOWN, STREAM, PROPERTIES, TABLE, SHAPE };
60 : :
61 : : OOXMLFastContextHandler();
62 : : explicit OOXMLFastContextHandler
63 : : (uno::Reference< uno::XComponentContext > const & context);
64 : :
65 : : explicit OOXMLFastContextHandler
66 : : (OOXMLFastContextHandler * pContext);
67 : :
68 : : virtual ~OOXMLFastContextHandler();
69 : :
70 : : // ::com::sun::star::xml::sax::XFastContextHandler:
71 : : virtual void SAL_CALL startFastElement
72 : : (Token_t Element,
73 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
74 : : throw (uno::RuntimeException, xml::sax::SAXException);
75 : :
76 : : virtual void SAL_CALL startUnknownElement
77 : : (const OUString & Namespace,
78 : : const OUString & Name,
79 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
80 : : throw (uno::RuntimeException, xml::sax::SAXException);
81 : :
82 : : virtual void SAL_CALL endFastElement(Token_t Element)
83 : : throw (uno::RuntimeException, xml::sax::SAXException);
84 : :
85 : : virtual void SAL_CALL endUnknownElement
86 : : (const OUString & Namespace, const OUString & Name)
87 : : throw (uno::RuntimeException, xml::sax::SAXException);
88 : :
89 : : virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
90 : : createFastChildContext
91 : : (Token_t Element,
92 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
93 : : throw (uno::RuntimeException, xml::sax::SAXException);
94 : :
95 : : virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
96 : : createUnknownChildContext
97 : : (const OUString & Namespace,
98 : : const OUString & Name,
99 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
100 : : throw (uno::RuntimeException, xml::sax::SAXException);
101 : :
102 : : virtual void SAL_CALL characters(const OUString & aChars)
103 : : throw (uno::RuntimeException, xml::sax::SAXException);
104 : :
105 : : static const uno::Sequence< sal_Int8 > & getUnoTunnelId();
106 : : virtual sal_Int64 SAL_CALL getSomething(const uno::Sequence<sal_Int8> & rId)
107 : : throw (uno::RuntimeException);
108 : :
109 : : // local
110 : :
111 : : void setStream(Stream * pStream);
112 : :
113 : : /**
114 : : Return value of this context(element).
115 : :
116 : : @return the value
117 : : */
118 : : virtual OOXMLValue::Pointer_t getValue() const;
119 : :
120 : : /**
121 : : Returns a string describing the type of the context.
122 : :
123 : : This is the name of the define normally.
124 : :
125 : : @return type string
126 : : */
127 [ # # ]: 0 : virtual string getType() const { return "??"; }
128 : :
129 : 480 : virtual ResourceEnum_t getResource() const { return STREAM; }
130 : :
131 : : virtual void attributes
132 : : (const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
133 : : throw (uno::RuntimeException, xml::sax::SAXException);
134 : :
135 : : virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal);
136 : : virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
137 : : virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
138 : :
139 : : virtual void setToken(Token_t nToken);
140 : : virtual Token_t getToken() const;
141 : :
142 : : void mark(const Id & rId, OOXMLValue::Pointer_t pVal);
143 : :
144 : : void resolveFootnote(const sal_Int32 nId);
145 : : void resolveEndnote(const sal_Int32 nId);
146 : : void resolveComment(const sal_Int32 nId);
147 : : void resolvePicture(const OUString & rId);
148 : : void resolveHeader(const sal_Int32 type,
149 : : const OUString & rId);
150 : : void resolveFooter(const sal_Int32 type,
151 : : const OUString & rId);
152 : : void resolveOLE(const OUString & rId);
153 : :
154 : : OUString getTargetForId(const OUString & rId);
155 : :
156 : : uno::Reference < xml::sax::XFastContextHandler >
157 : : createFromStart
158 : : (Token_t Element,
159 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs);
160 : :
161 : : void setDocument(OOXMLDocument * pDocument);
162 : : OOXMLDocument * getDocument();
163 : : void setXNoteId(OOXMLValue::Pointer_t pValue);
164 : : void setXNoteId(const sal_Int32 nId);
165 : : sal_Int32 getXNoteId() const;
166 : : void setForwardEvents(bool bForwardEvents);
167 : : bool isForwardEvents() const;
168 : : virtual void setParent(OOXMLFastContextHandler * pParent);
169 : : virtual void setId(Id nId);
170 : : virtual Id getId() const;
171 : :
172 : : void setDefine(Id nDefine);
173 : : Id getDefine() const;
174 : :
175 : : OOXMLParserState::Pointer_t getParserState() const;
176 : :
177 : : void sendTableDepth() const;
178 : : void setHandle();
179 : :
180 : : void startSectionGroup();
181 : : void setLastParagraphInSection();
182 : : void endSectionGroup();
183 : : void startParagraphGroup();
184 : : void endParagraphGroup();
185 : : void startCharacterGroup();
186 : : void endCharacterGroup();
187 : :
188 : : void startField();
189 : : void fieldSeparator();
190 : : void endField();
191 : : void ftnednref();
192 : : void ftnedncont();
193 : : void ftnednsep();
194 : : void pgNum();
195 : : void tab();
196 : : void cr();
197 : : void noBreakHyphen();
198 : : void softHyphen();
199 : : void handleLastParagraphInSection();
200 : : void endOfParagraph();
201 : : void text(const OUString & sText);
202 : : void positionOffset(const OUString & sText);
203 : : void alignH(const OUString & sText);
204 : : void alignV(const OUString & sText);
205 : : void startTxbxContent();
206 : : void endTxbxContent();
207 : : virtual void propagateCharacterProperties();
208 : : virtual void propagateCharacterPropertiesAsSet(const Id & rId);
209 : : virtual void propagateTableProperties();
210 : : virtual void propagateRowProperties();
211 : : virtual void propagateCellProperties();
212 : : virtual bool propagatesProperties() const;
213 : : void sendPropertiesWithId(const Id & rId);
214 : : void sendPropertiesToParent();
215 : : void sendCellProperties();
216 : : void sendRowProperties();
217 : : void sendTableProperties();
218 : : void clearTableProps();
219 : : void clearProps();
220 : :
221 : : virtual void setDefaultBooleanValue();
222 : : virtual void setDefaultIntegerValue();
223 : : virtual void setDefaultHexValue();
224 : : virtual void setDefaultStringValue();
225 : :
226 : : void sendPropertyToParent();
227 : :
228 : : #if OSL_DEBUG_LEVEL > 1
229 : : virtual void dumpXml( const TagLogger::Pointer_t pLogger ) const;
230 : : #endif
231 : :
232 : : sal_uInt32 getInstanceNumber() { return mnInstanceNumber; }
233 : : protected:
234 : : OOXMLFastContextHandler * mpParent;
235 : : Id mId;
236 : : Id mnDefine;
237 : : Token_t mnToken;
238 : :
239 : : #ifdef DEBUG_CONTEXT_HANDLER
240 : : string msTokenString;
241 : : #endif
242 : :
243 : : // the stream to send the stream events to.
244 : : Stream * mpStream;
245 : :
246 : : // the current global parser state
247 : : OOXMLParserState::Pointer_t mpParserState;
248 : :
249 : : // the table depth of this context
250 : : unsigned int mnTableDepth;
251 : :
252 : : virtual void lcl_startFastElement
253 : : (Token_t Element,
254 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
255 : : throw (uno::RuntimeException, xml::sax::SAXException);
256 : :
257 : : virtual void lcl_endFastElement(Token_t Element)
258 : : throw (uno::RuntimeException, xml::sax::SAXException);
259 : :
260 : : virtual uno::Reference< xml::sax::XFastContextHandler >
261 : : lcl_createFastChildContext
262 : : (Token_t Element,
263 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
264 : : throw (uno::RuntimeException, xml::sax::SAXException);
265 : :
266 : : virtual void lcl_characters(const OUString & aChars)
267 : : throw (uno::RuntimeException, xml::sax::SAXException);
268 : :
269 : : void startAction(Token_t Element);
270 : : virtual void lcl_startAction(Token_t Element);
271 : : void endAction(Token_t Element);
272 : : virtual void lcl_endAction(Token_t Element);
273 : :
274 : :
275 : : virtual OOXMLPropertySet * getPicturePropSet
276 : : (const OUString & rId);
277 : : virtual void resolvePropertySetAttrs();
278 : :
279 : : uno::Reference< uno::XComponentContext > getComponentContext();
280 : :
281 : : sal_uInt32 mnInstanceNumber;
282 : : sal_uInt32 mnRefCount;
283 : :
284 : : bool inPositionV;
285 : :
286 : : private:
287 : : void operator =(OOXMLFastContextHandler &); // not defined
288 : :
289 : : uno::Reference< uno::XComponentContext > m_xContext;
290 : :
291 : : static sal_uInt32 mnInstanceCount;
292 : :
293 : : };
294 : :
295 : : class OOXMLFastContextHandlerStream : public OOXMLFastContextHandler
296 : : {
297 : : public:
298 : : OOXMLFastContextHandlerStream(OOXMLFastContextHandler * pContext);
299 : : virtual ~OOXMLFastContextHandlerStream();
300 : :
301 : 1378 : virtual ResourceEnum_t getResource() const { return STREAM; }
302 : :
303 : : OOXMLPropertySet::Pointer_t getPropertySetAttrs() const;
304 : :
305 : : virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal);
306 : : virtual void sendProperty(Id nId);
307 : : virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
308 : :
309 : : void handleHyperlink();
310 : :
311 : : protected:
312 : : virtual void resolvePropertySetAttrs();
313 : :
314 : : private:
315 : : mutable OOXMLPropertySet::Pointer_t mpPropertySetAttrs;
316 : : };
317 : :
318 : : class OOXMLFastContextHandlerProperties : public OOXMLFastContextHandler
319 : : {
320 : : public:
321 : : OOXMLFastContextHandlerProperties(OOXMLFastContextHandler * pContext);
322 : : virtual ~OOXMLFastContextHandlerProperties();
323 : :
324 : : virtual OOXMLValue::Pointer_t getValue() const;
325 : 21964 : virtual ResourceEnum_t getResource() const { return PROPERTIES; }
326 : :
327 : : virtual void newProperty(const Id & nId, OOXMLValue::Pointer_t pVal);
328 : :
329 : : void handleXNotes();
330 : : void handleHdrFtr();
331 : : void handleComment();
332 : : void handlePicture();
333 : : void handleBreak();
334 : : void handleOLE();
335 : :
336 : : virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
337 : : virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
338 : :
339 : : #if OSL_DEBUG_LEVEL > 1
340 : : virtual void dumpXml( const TagLogger::Pointer_t pLogger ) const;
341 : : #endif
342 : :
343 : : protected:
344 : : /// the properties
345 : : OOXMLPropertySet::Pointer_t mpPropertySet;
346 : :
347 : : virtual void lcl_endFastElement(Token_t Element)
348 : : throw (uno::RuntimeException, xml::sax::SAXException);
349 : : virtual void setParent(OOXMLFastContextHandler * pParent);
350 : :
351 : : private:
352 : :
353 : : bool mbResolve;
354 : : };
355 : :
356 : : class OOXMLFastContextHandlerPropertyTable :
357 : : public OOXMLFastContextHandlerProperties
358 : : {
359 : : public:
360 : : OOXMLFastContextHandlerPropertyTable(OOXMLFastContextHandler * pContext);
361 : : virtual ~OOXMLFastContextHandlerPropertyTable();
362 : :
363 : : protected:
364 : : OOXMLTableImpl mTable;
365 : :
366 : : virtual void lcl_endFastElement(Token_t Element)
367 : : throw (uno::RuntimeException, xml::sax::SAXException);
368 : : };
369 : :
370 : : class OOXMLFastContextHandlerValue :
371 : : public OOXMLFastContextHandler
372 : : {
373 : : public:
374 : : OOXMLFastContextHandlerValue
375 : : (OOXMLFastContextHandler * pContext);
376 : : virtual ~OOXMLFastContextHandlerValue();
377 : :
378 : : virtual void setValue(OOXMLValue::Pointer_t pValue);
379 : : virtual OOXMLValue::Pointer_t getValue() const;
380 : :
381 : : virtual void lcl_endFastElement(Token_t Element)
382 : : throw (uno::RuntimeException, xml::sax::SAXException);
383 : :
384 [ # # ]: 0 : virtual string getType() const { return "Value"; }
385 : :
386 : : virtual void setDefaultBooleanValue();
387 : : virtual void setDefaultIntegerValue();
388 : : virtual void setDefaultHexValue();
389 : : virtual void setDefaultStringValue();
390 : :
391 : : protected:
392 : : OOXMLValue::Pointer_t mpValue;
393 : : };
394 : :
395 : : class OOXMLFastContextHandlerTable : public OOXMLFastContextHandler
396 : : {
397 : : public:
398 : : OOXMLFastContextHandlerTable(OOXMLFastContextHandler * pContext);
399 : : virtual ~OOXMLFastContextHandlerTable();
400 : :
401 : : virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
402 : : createFastChildContext
403 : : (Token_t Element,
404 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
405 : : throw (uno::RuntimeException, xml::sax::SAXException);
406 : :
407 : : virtual void newPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
408 : : protected:
409 : : OOXMLTableImpl mTable;
410 : :
411 : : RefAndPointer_t mCurrentChild;
412 : :
413 : : virtual void lcl_endFastElement(Token_t Element)
414 : : throw (uno::RuntimeException, xml::sax::SAXException);
415 : :
416 : 2346 : virtual ResourceEnum_t getResource() const { return TABLE; }
417 : :
418 [ # # ]: 0 : virtual string getType() const { return "Table"; }
419 : :
420 : : void addCurrentChild();
421 : : };
422 : :
423 : : class OOXMLFastContextHandlerXNote : public OOXMLFastContextHandlerProperties
424 : : {
425 : : public:
426 : : OOXMLFastContextHandlerXNote(OOXMLFastContextHandler * pContext);
427 : : virtual ~OOXMLFastContextHandlerXNote();
428 : :
429 : : void checkId(OOXMLValue::Pointer_t pValue);
430 : :
431 [ # # ]: 0 : virtual string getType() const { return "XNote"; }
432 : :
433 : : private:
434 : : bool mbForwardEventsSaved;
435 : : sal_Int32 mnMyXNoteId;
436 : :
437 : : virtual void lcl_startFastElement
438 : : (Token_t Element,
439 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
440 : : throw (uno::RuntimeException, xml::sax::SAXException);
441 : :
442 : : virtual void lcl_endFastElement(Token_t Element)
443 : : throw (uno::RuntimeException, xml::sax::SAXException);
444 : :
445 : 0 : virtual ResourceEnum_t getResource() const { return STREAM; }
446 : : };
447 : :
448 : : class OOXMLFastContextHandlerTextTableCell : public OOXMLFastContextHandler
449 : : {
450 : : public:
451 : : OOXMLFastContextHandlerTextTableCell
452 : : (OOXMLFastContextHandler * pContext);
453 : : virtual ~OOXMLFastContextHandlerTextTableCell();
454 : :
455 [ # # ]: 0 : virtual string getType() const { return "TextTableCell"; }
456 : :
457 : : void startCell();
458 : : void endCell();
459 : : };
460 : :
461 : : class OOXMLFastContextHandlerTextTableRow : public OOXMLFastContextHandler
462 : : {
463 : : public:
464 : : OOXMLFastContextHandlerTextTableRow
465 : : (OOXMLFastContextHandler * pContext);
466 : : virtual ~OOXMLFastContextHandlerTextTableRow();
467 : :
468 [ # # ]: 0 : virtual string getType() const { return "TextTableRow"; }
469 : :
470 : : void startRow();
471 : : void endRow();
472 : : };
473 : :
474 : : class OOXMLFastContextHandlerTextTable : public OOXMLFastContextHandler
475 : : {
476 : : public:
477 : : OOXMLFastContextHandlerTextTable
478 : : (OOXMLFastContextHandler * pContext);
479 : :
480 : : virtual ~OOXMLFastContextHandlerTextTable();
481 : :
482 [ # # ]: 0 : virtual string getType() const { return "TextTable"; }
483 : :
484 : : protected:
485 : : virtual void lcl_startFastElement
486 : : (Token_t Element,
487 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
488 : : throw (uno::RuntimeException, xml::sax::SAXException);
489 : :
490 : : virtual void lcl_endFastElement(Token_t Element)
491 : : throw (uno::RuntimeException, xml::sax::SAXException);
492 : : };
493 : :
494 : : class OOXMLFastContextHandlerShape: public OOXMLFastContextHandlerProperties
495 : : {
496 : : private:
497 : : bool m_bShapeSent;
498 : : bool m_bShapeStarted;
499 : :
500 : : public:
501 : : explicit OOXMLFastContextHandlerShape
502 : : (OOXMLFastContextHandler * pContext);
503 : : virtual ~OOXMLFastContextHandlerShape();
504 : :
505 [ # # ]: 0 : virtual string getType() const { return "Shape"; }
506 : :
507 : : // ::com::sun::star::xml::sax::XFastContextHandler:
508 : : virtual void SAL_CALL startUnknownElement
509 : : (const OUString & Namespace,
510 : : const OUString & Name,
511 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
512 : : throw (uno::RuntimeException, xml::sax::SAXException);
513 : :
514 : : virtual void SAL_CALL endUnknownElement
515 : : (const OUString & Namespace,
516 : : const OUString & Name)
517 : : throw (uno::RuntimeException, xml::sax::SAXException);
518 : :
519 : : virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
520 : : createUnknownChildContext
521 : : (const OUString & Namespace,
522 : : const OUString & Name,
523 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
524 : : throw (uno::RuntimeException, xml::sax::SAXException);
525 : :
526 : : virtual void setToken(Token_t nToken);
527 : :
528 : 0 : virtual ResourceEnum_t getResource() const { return SHAPE; }
529 : :
530 : : void sendShape( Token_t Element );
531 : :
532 : : protected:
533 : : typedef uno::Reference<XFastShapeContextHandler> ShapeContextRef;
534 : : ShapeContextRef mrShapeContext;
535 : :
536 : : virtual void lcl_startFastElement
537 : : (Token_t Element,
538 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
539 : : throw (uno::RuntimeException, xml::sax::SAXException);
540 : :
541 : : virtual void lcl_endFastElement(Token_t Element)
542 : : throw (uno::RuntimeException, xml::sax::SAXException);
543 : :
544 : : virtual uno::Reference< xml::sax::XFastContextHandler >
545 : : lcl_createFastChildContext
546 : : (Token_t Element,
547 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
548 : : throw (uno::RuntimeException, xml::sax::SAXException);
549 : :
550 : : virtual void lcl_characters(const OUString & aChars)
551 : : throw (uno::RuntimeException, xml::sax::SAXException);
552 : :
553 : : };
554 : :
555 : : /**
556 : : OOXMLFastContextHandlerWrapper wraps an OOXMLFastContextHandler.
557 : :
558 : : The method calls for the interface
559 : : ::com::sun::star::xml::sax::XFastContextHandler are forwarded to the wrapped
560 : : OOXMLFastContextHandler.
561 : : */
562 : : class OOXMLFastContextHandlerWrapper : public OOXMLFastContextHandler
563 : : {
564 : : public:
565 : : explicit OOXMLFastContextHandlerWrapper
566 : : (OOXMLFastContextHandler * pParent,
567 : : uno::Reference<XFastContextHandler> xContext);
568 : : virtual ~OOXMLFastContextHandlerWrapper();
569 : :
570 : : // ::com::sun::star::xml::sax::XFastContextHandler:
571 : : virtual void SAL_CALL startUnknownElement
572 : : (const OUString & Namespace,
573 : : const OUString & Name,
574 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
575 : : throw (uno::RuntimeException, xml::sax::SAXException);
576 : :
577 : : virtual void SAL_CALL endUnknownElement
578 : : (const OUString & Namespace,
579 : : const OUString & Name)
580 : : throw (uno::RuntimeException, xml::sax::SAXException);
581 : :
582 : : virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
583 : : createUnknownChildContext
584 : : (const OUString & Namespace,
585 : : const OUString & Name,
586 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
587 : : throw (uno::RuntimeException, xml::sax::SAXException);
588 : :
589 : : virtual void attributes
590 : : (const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
591 : : throw (uno::RuntimeException, xml::sax::SAXException);
592 : :
593 : : virtual ResourceEnum_t getResource() const;
594 : :
595 : : void addNamespace(const Id & nId);
596 : : void addToken( Token_t Element );
597 : :
598 : : virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal);
599 : : virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
600 : : virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
601 : :
602 : : virtual string getType() const;
603 : :
604 : : protected:
605 : : virtual void lcl_startFastElement
606 : : (Token_t Element,
607 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
608 : : throw (uno::RuntimeException, xml::sax::SAXException);
609 : :
610 : : virtual void lcl_endFastElement(Token_t Element)
611 : : throw (uno::RuntimeException, xml::sax::SAXException);
612 : :
613 : : virtual uno::Reference< xml::sax::XFastContextHandler >
614 : : lcl_createFastChildContext
615 : : (Token_t Element,
616 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
617 : : throw (uno::RuntimeException, xml::sax::SAXException);
618 : :
619 : : virtual void lcl_characters(const OUString & aChars)
620 : : throw (uno::RuntimeException, xml::sax::SAXException);
621 : :
622 : : virtual void setId(Id nId);
623 : : virtual Id getId() const;
624 : :
625 : : virtual void setToken(Token_t nToken);
626 : : virtual Token_t getToken() const;
627 : :
628 : : private:
629 : : uno::Reference<XFastContextHandler> mxContext;
630 : : set<Id> mMyNamespaces;
631 : : set<Token_t> mMyTokens;
632 : : OOXMLPropertySet::Pointer_t mpPropertySet;
633 : :
634 : : OOXMLFastContextHandler * getFastContextHandler() const;
635 : : };
636 : :
637 : : /**
638 : : A class that converts from XFastParser/XFastContextHandler usage to a liner XML stream of data.
639 : :
640 : : The purpose of this class is to convert the rather complex XFastContextHandler-based XML
641 : : processing that requires context subclasses, callbacks, etc. into a linear stream of XML tokens
642 : : that can be handled simply by reading the tokens one by one and directly processing them.
643 : : See the oox::formulaimport::XmlStream class documentation for more information.
644 : :
645 : : Usage: Create a subclass of OOXMLFastContextHandlerLinear, reimplemented getType() to provide
646 : : type of the subclass and process() to actually process the XML stream. Also make sure to
647 : : add a line like the following to model.xml (for class OOXMLFastContextHandlerMath):
648 : :
649 : : <resource name="CT_OMath" resource="Math"/>
650 : :
651 : : @since 3.5
652 : : */
653 [ - + ]: 255 : class OOXMLFastContextHandlerLinear: public OOXMLFastContextHandlerProperties
654 : : {
655 : : public:
656 : : explicit OOXMLFastContextHandlerLinear(OOXMLFastContextHandler * pContext);
657 : : /**
658 : : Return the type of the class, as written in model.xml .
659 : : */
660 : : virtual string getType() const = 0;
661 : :
662 : : protected:
663 : : /**
664 : : Called when the tokens for the element, its content and sub-elements have been linearized
665 : : and should be processed. The data member @ref buffer contains the converted data.
666 : : */
667 : : virtual void process() = 0;
668 : :
669 : : virtual void lcl_startFastElement(Token_t Element, const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
670 : : throw (uno::RuntimeException, xml::sax::SAXException);
671 : :
672 : : virtual void lcl_endFastElement(Token_t Element) throw (uno::RuntimeException, xml::sax::SAXException);
673 : :
674 : : virtual uno::Reference< xml::sax::XFastContextHandler > lcl_createFastChildContext(Token_t Element,
675 : : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
676 : : throw (uno::RuntimeException, xml::sax::SAXException);
677 : :
678 : : virtual void lcl_characters(const OUString & aChars) throw (uno::RuntimeException, xml::sax::SAXException);
679 : :
680 : : // should be private, but not much point in making deep copies of it
681 : : oox::formulaimport::XmlStreamBuilder buffer;
682 : :
683 : : private:
684 : : int depthCount;
685 : : };
686 : :
687 [ - + ]: 510 : class OOXMLFastContextHandlerMath: public OOXMLFastContextHandlerLinear
688 : : {
689 : : public:
690 : : explicit OOXMLFastContextHandlerMath(OOXMLFastContextHandler * pContext);
691 [ # # ]: 0 : virtual string getType() const { return "Math"; }
692 : : protected:
693 : : virtual void process();
694 : : };
695 : :
696 : : }}
697 : : #endif // INCLUDED_OOXML_FAST_CONTEXT_HANDLER_HXX
698 : :
699 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|