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 3 : 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 362 : 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 resolveData(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 : void startSdt();
188 : void endSdt();
189 :
190 : void startField();
191 : void fieldSeparator();
192 : void endField();
193 : void ftnednref();
194 : void ftnedncont();
195 : void ftnednsep();
196 : void pgNum();
197 : void tab();
198 : void cr();
199 : void noBreakHyphen();
200 : void softHyphen();
201 : void handleLastParagraphInSection();
202 : void endOfParagraph();
203 : void text(const OUString & sText);
204 : void positionOffset(const OUString & sText);
205 : void alignH(const OUString & sText);
206 : void alignV(const OUString & sText);
207 : void startTxbxContent();
208 : void endTxbxContent();
209 : virtual void propagateCharacterProperties();
210 : virtual void propagateCharacterPropertiesAsSet(const Id & rId);
211 : virtual void propagateTableProperties();
212 : virtual void propagateRowProperties();
213 : virtual void propagateCellProperties();
214 : virtual bool propagatesProperties() const;
215 : void sendPropertiesWithId(const Id & rId);
216 : void sendPropertiesToParent();
217 : void sendCellProperties();
218 : void sendRowProperties();
219 : void sendTableProperties();
220 : void clearTableProps();
221 : void clearProps();
222 :
223 : virtual void setDefaultBooleanValue();
224 : virtual void setDefaultIntegerValue();
225 : virtual void setDefaultHexValue();
226 : virtual void setDefaultStringValue();
227 :
228 : void sendPropertyToParent();
229 :
230 : #if OSL_DEBUG_LEVEL > 1
231 : virtual void dumpXml( const TagLogger::Pointer_t pLogger ) const;
232 : #endif
233 :
234 : sal_uInt32 getInstanceNumber() { return mnInstanceNumber; }
235 : protected:
236 : OOXMLFastContextHandler * mpParent;
237 : Id mId;
238 : Id mnDefine;
239 : Token_t mnToken;
240 :
241 : #ifdef DEBUG_CONTEXT_HANDLER
242 : string msTokenString;
243 : #endif
244 :
245 : // the stream to send the stream events to.
246 : Stream * mpStream;
247 :
248 : // the current global parser state
249 : OOXMLParserState::Pointer_t mpParserState;
250 :
251 : // the table depth of this context
252 : unsigned int mnTableDepth;
253 :
254 : virtual void lcl_startFastElement
255 : (Token_t Element,
256 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
257 : throw (uno::RuntimeException, xml::sax::SAXException);
258 :
259 : virtual void lcl_endFastElement(Token_t Element)
260 : throw (uno::RuntimeException, xml::sax::SAXException);
261 :
262 : virtual uno::Reference< xml::sax::XFastContextHandler >
263 : lcl_createFastChildContext
264 : (Token_t Element,
265 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
266 : throw (uno::RuntimeException, xml::sax::SAXException);
267 :
268 : virtual void lcl_characters(const OUString & aChars)
269 : throw (uno::RuntimeException, xml::sax::SAXException);
270 :
271 : void startAction(Token_t Element);
272 : virtual void lcl_startAction(Token_t Element);
273 : void endAction(Token_t Element);
274 : virtual void lcl_endAction(Token_t Element);
275 :
276 :
277 : virtual OOXMLPropertySet * getPicturePropSet
278 : (const OUString & rId);
279 : virtual void resolvePropertySetAttrs();
280 :
281 : uno::Reference< uno::XComponentContext > getComponentContext();
282 :
283 : sal_uInt32 mnInstanceNumber;
284 : sal_uInt32 mnRefCount;
285 :
286 : bool inPositionV;
287 :
288 : private:
289 : void operator =(OOXMLFastContextHandler &); // not defined
290 :
291 : uno::Reference< uno::XComponentContext > m_xContext;
292 :
293 : static sal_uInt32 mnInstanceCount;
294 :
295 : };
296 :
297 : class OOXMLFastContextHandlerStream : public OOXMLFastContextHandler
298 : {
299 : public:
300 : OOXMLFastContextHandlerStream(OOXMLFastContextHandler * pContext);
301 : virtual ~OOXMLFastContextHandlerStream();
302 :
303 736 : virtual ResourceEnum_t getResource() const { return STREAM; }
304 :
305 : OOXMLPropertySet::Pointer_t getPropertySetAttrs() const;
306 :
307 : virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal);
308 : virtual void sendProperty(Id nId);
309 : virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
310 :
311 : void handleHyperlink();
312 :
313 : protected:
314 : virtual void resolvePropertySetAttrs();
315 :
316 : private:
317 : mutable OOXMLPropertySet::Pointer_t mpPropertySetAttrs;
318 : };
319 :
320 : class OOXMLFastContextHandlerProperties : public OOXMLFastContextHandler
321 : {
322 : public:
323 : OOXMLFastContextHandlerProperties(OOXMLFastContextHandler * pContext);
324 : virtual ~OOXMLFastContextHandlerProperties();
325 :
326 : virtual OOXMLValue::Pointer_t getValue() const;
327 12625 : virtual ResourceEnum_t getResource() const { return PROPERTIES; }
328 :
329 : virtual void newProperty(const Id & nId, OOXMLValue::Pointer_t pVal);
330 :
331 : void handleXNotes();
332 : void handleHdrFtr();
333 : void handleComment();
334 : void handlePicture();
335 : void handleBreak();
336 : void handleOLE();
337 : void handleFontRel();
338 :
339 : virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
340 : virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
341 :
342 : #if OSL_DEBUG_LEVEL > 1
343 : virtual void dumpXml( const TagLogger::Pointer_t pLogger ) const;
344 : #endif
345 :
346 : protected:
347 : /// the properties
348 : OOXMLPropertySet::Pointer_t mpPropertySet;
349 :
350 : virtual void lcl_endFastElement(Token_t Element)
351 : throw (uno::RuntimeException, xml::sax::SAXException);
352 : virtual void setParent(OOXMLFastContextHandler * pParent);
353 :
354 : private:
355 :
356 : bool mbResolve;
357 : };
358 :
359 : class OOXMLFastContextHandlerPropertyTable :
360 : public OOXMLFastContextHandlerProperties
361 : {
362 : public:
363 : OOXMLFastContextHandlerPropertyTable(OOXMLFastContextHandler * pContext);
364 : virtual ~OOXMLFastContextHandlerPropertyTable();
365 :
366 : protected:
367 : OOXMLTableImpl mTable;
368 :
369 : virtual void lcl_endFastElement(Token_t Element)
370 : throw (uno::RuntimeException, xml::sax::SAXException);
371 : };
372 :
373 : class OOXMLFastContextHandlerValue :
374 : public OOXMLFastContextHandler
375 : {
376 : public:
377 : OOXMLFastContextHandlerValue
378 : (OOXMLFastContextHandler * pContext);
379 : virtual ~OOXMLFastContextHandlerValue();
380 :
381 : virtual void setValue(OOXMLValue::Pointer_t pValue);
382 : virtual OOXMLValue::Pointer_t getValue() const;
383 :
384 : virtual void lcl_endFastElement(Token_t Element)
385 : throw (uno::RuntimeException, xml::sax::SAXException);
386 :
387 0 : virtual string getType() const { return "Value"; }
388 :
389 : virtual void setDefaultBooleanValue();
390 : virtual void setDefaultIntegerValue();
391 : virtual void setDefaultHexValue();
392 : virtual void setDefaultStringValue();
393 :
394 : protected:
395 : OOXMLValue::Pointer_t mpValue;
396 : };
397 :
398 : class OOXMLFastContextHandlerTable : public OOXMLFastContextHandler
399 : {
400 : public:
401 : OOXMLFastContextHandlerTable(OOXMLFastContextHandler * pContext);
402 : virtual ~OOXMLFastContextHandlerTable();
403 :
404 : virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
405 : createFastChildContext
406 : (Token_t Element,
407 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
408 : throw (uno::RuntimeException, xml::sax::SAXException);
409 :
410 : virtual void newPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
411 : protected:
412 : OOXMLTableImpl mTable;
413 :
414 : RefAndPointer_t mCurrentChild;
415 :
416 : virtual void lcl_endFastElement(Token_t Element)
417 : throw (uno::RuntimeException, xml::sax::SAXException);
418 :
419 1308 : virtual ResourceEnum_t getResource() const { return TABLE; }
420 :
421 0 : virtual string getType() const { return "Table"; }
422 :
423 : void addCurrentChild();
424 : };
425 :
426 : class OOXMLFastContextHandlerXNote : public OOXMLFastContextHandlerProperties
427 : {
428 : public:
429 : OOXMLFastContextHandlerXNote(OOXMLFastContextHandler * pContext);
430 : virtual ~OOXMLFastContextHandlerXNote();
431 :
432 : void checkId(OOXMLValue::Pointer_t pValue);
433 :
434 0 : virtual string getType() const { return "XNote"; }
435 :
436 : private:
437 : bool mbForwardEventsSaved;
438 : sal_Int32 mnMyXNoteId;
439 :
440 : virtual void lcl_startFastElement
441 : (Token_t Element,
442 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
443 : throw (uno::RuntimeException, xml::sax::SAXException);
444 :
445 : virtual void lcl_endFastElement(Token_t Element)
446 : throw (uno::RuntimeException, xml::sax::SAXException);
447 :
448 0 : virtual ResourceEnum_t getResource() const { return STREAM; }
449 : };
450 :
451 : class OOXMLFastContextHandlerTextTableCell : public OOXMLFastContextHandler
452 : {
453 : public:
454 : OOXMLFastContextHandlerTextTableCell
455 : (OOXMLFastContextHandler * pContext);
456 : virtual ~OOXMLFastContextHandlerTextTableCell();
457 :
458 0 : virtual string getType() const { return "TextTableCell"; }
459 :
460 : void startCell();
461 : void endCell();
462 : };
463 :
464 : class OOXMLFastContextHandlerTextTableRow : public OOXMLFastContextHandler
465 : {
466 : public:
467 : OOXMLFastContextHandlerTextTableRow
468 : (OOXMLFastContextHandler * pContext);
469 : virtual ~OOXMLFastContextHandlerTextTableRow();
470 :
471 0 : virtual string getType() const { return "TextTableRow"; }
472 :
473 : void startRow();
474 : void endRow();
475 : };
476 :
477 : class OOXMLFastContextHandlerTextTable : public OOXMLFastContextHandler
478 : {
479 : public:
480 : OOXMLFastContextHandlerTextTable
481 : (OOXMLFastContextHandler * pContext);
482 :
483 : virtual ~OOXMLFastContextHandlerTextTable();
484 :
485 0 : virtual string getType() const { return "TextTable"; }
486 :
487 : protected:
488 : virtual void lcl_startFastElement
489 : (Token_t Element,
490 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
491 : throw (uno::RuntimeException, xml::sax::SAXException);
492 :
493 : virtual void lcl_endFastElement(Token_t Element)
494 : throw (uno::RuntimeException, xml::sax::SAXException);
495 : };
496 :
497 : class OOXMLFastContextHandlerShape: public OOXMLFastContextHandlerProperties
498 : {
499 : private:
500 : bool m_bShapeSent;
501 : bool m_bShapeStarted;
502 :
503 : public:
504 : explicit OOXMLFastContextHandlerShape
505 : (OOXMLFastContextHandler * pContext);
506 : virtual ~OOXMLFastContextHandlerShape();
507 :
508 0 : virtual string getType() const { return "Shape"; }
509 :
510 : // ::com::sun::star::xml::sax::XFastContextHandler:
511 : virtual void SAL_CALL startUnknownElement
512 : (const OUString & Namespace,
513 : const OUString & Name,
514 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
515 : throw (uno::RuntimeException, xml::sax::SAXException);
516 :
517 : virtual void SAL_CALL endUnknownElement
518 : (const OUString & Namespace,
519 : const OUString & Name)
520 : throw (uno::RuntimeException, xml::sax::SAXException);
521 :
522 : virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
523 : createUnknownChildContext
524 : (const OUString & Namespace,
525 : const OUString & Name,
526 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
527 : throw (uno::RuntimeException, xml::sax::SAXException);
528 :
529 : virtual void setToken(Token_t nToken);
530 :
531 1 : virtual ResourceEnum_t getResource() const { return SHAPE; }
532 :
533 : void sendShape( Token_t Element );
534 :
535 : protected:
536 : typedef uno::Reference<XFastShapeContextHandler> ShapeContextRef;
537 : ShapeContextRef mrShapeContext;
538 :
539 : virtual void lcl_startFastElement
540 : (Token_t Element,
541 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
542 : throw (uno::RuntimeException, xml::sax::SAXException);
543 :
544 : virtual void lcl_endFastElement(Token_t Element)
545 : throw (uno::RuntimeException, xml::sax::SAXException);
546 :
547 : virtual uno::Reference< xml::sax::XFastContextHandler >
548 : lcl_createFastChildContext
549 : (Token_t Element,
550 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
551 : throw (uno::RuntimeException, xml::sax::SAXException);
552 :
553 : virtual void lcl_characters(const OUString & aChars)
554 : throw (uno::RuntimeException, xml::sax::SAXException);
555 :
556 : };
557 :
558 : /**
559 : OOXMLFastContextHandlerWrapper wraps an OOXMLFastContextHandler.
560 :
561 : The method calls for the interface
562 : ::com::sun::star::xml::sax::XFastContextHandler are forwarded to the wrapped
563 : OOXMLFastContextHandler.
564 : */
565 : class OOXMLFastContextHandlerWrapper : public OOXMLFastContextHandler
566 : {
567 : public:
568 : explicit OOXMLFastContextHandlerWrapper
569 : (OOXMLFastContextHandler * pParent,
570 : uno::Reference<XFastContextHandler> xContext);
571 : virtual ~OOXMLFastContextHandlerWrapper();
572 :
573 : // ::com::sun::star::xml::sax::XFastContextHandler:
574 : virtual void SAL_CALL startUnknownElement
575 : (const OUString & Namespace,
576 : const OUString & Name,
577 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
578 : throw (uno::RuntimeException, xml::sax::SAXException);
579 :
580 : virtual void SAL_CALL endUnknownElement
581 : (const OUString & Namespace,
582 : const OUString & Name)
583 : throw (uno::RuntimeException, xml::sax::SAXException);
584 :
585 : virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
586 : createUnknownChildContext
587 : (const OUString & Namespace,
588 : const OUString & Name,
589 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
590 : throw (uno::RuntimeException, xml::sax::SAXException);
591 :
592 : virtual void attributes
593 : (const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
594 : throw (uno::RuntimeException, xml::sax::SAXException);
595 :
596 : virtual ResourceEnum_t getResource() const;
597 :
598 : void addNamespace(const Id & nId);
599 : void addToken( Token_t Element );
600 :
601 : virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal);
602 : virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
603 : virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
604 :
605 : virtual string getType() const;
606 :
607 : protected:
608 : virtual void lcl_startFastElement
609 : (Token_t Element,
610 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
611 : throw (uno::RuntimeException, xml::sax::SAXException);
612 :
613 : virtual void lcl_endFastElement(Token_t Element)
614 : throw (uno::RuntimeException, xml::sax::SAXException);
615 :
616 : virtual uno::Reference< xml::sax::XFastContextHandler >
617 : lcl_createFastChildContext
618 : (Token_t Element,
619 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
620 : throw (uno::RuntimeException, xml::sax::SAXException);
621 :
622 : virtual void lcl_characters(const OUString & aChars)
623 : throw (uno::RuntimeException, xml::sax::SAXException);
624 :
625 : virtual void setId(Id nId);
626 : virtual Id getId() const;
627 :
628 : virtual void setToken(Token_t nToken);
629 : virtual Token_t getToken() const;
630 :
631 : private:
632 : uno::Reference<XFastContextHandler> mxContext;
633 : set<Id> mMyNamespaces;
634 : set<Token_t> mMyTokens;
635 : OOXMLPropertySet::Pointer_t mpPropertySet;
636 :
637 : OOXMLFastContextHandler * getFastContextHandler() const;
638 : };
639 :
640 : /**
641 : A class that converts from XFastParser/XFastContextHandler usage to a liner XML stream of data.
642 :
643 : The purpose of this class is to convert the rather complex XFastContextHandler-based XML
644 : processing that requires context subclasses, callbacks, etc. into a linear stream of XML tokens
645 : that can be handled simply by reading the tokens one by one and directly processing them.
646 : See the oox::formulaimport::XmlStream class documentation for more information.
647 :
648 : Usage: Create a subclass of OOXMLFastContextHandlerLinear, reimplemented getType() to provide
649 : type of the subclass and process() to actually process the XML stream. Also make sure to
650 : add a line like the following to model.xml (for class OOXMLFastContextHandlerMath):
651 :
652 : <resource name="CT_OMath" resource="Math"/>
653 :
654 : @since 3.5
655 : */
656 85 : class OOXMLFastContextHandlerLinear: public OOXMLFastContextHandlerProperties
657 : {
658 : public:
659 : explicit OOXMLFastContextHandlerLinear(OOXMLFastContextHandler * pContext);
660 : /**
661 : Return the type of the class, as written in model.xml .
662 : */
663 : virtual string getType() const = 0;
664 :
665 : protected:
666 : /**
667 : Called when the tokens for the element, its content and sub-elements have been linearized
668 : and should be processed. The data member @ref buffer contains the converted data.
669 : */
670 : virtual void process() = 0;
671 :
672 : virtual void lcl_startFastElement(Token_t Element, const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
673 : throw (uno::RuntimeException, xml::sax::SAXException);
674 :
675 : virtual void lcl_endFastElement(Token_t Element) throw (uno::RuntimeException, xml::sax::SAXException);
676 :
677 : virtual uno::Reference< xml::sax::XFastContextHandler > lcl_createFastChildContext(Token_t Element,
678 : const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
679 : throw (uno::RuntimeException, xml::sax::SAXException);
680 :
681 : virtual void lcl_characters(const OUString & aChars) throw (uno::RuntimeException, xml::sax::SAXException);
682 :
683 : // should be private, but not much point in making deep copies of it
684 : oox::formulaimport::XmlStreamBuilder buffer;
685 :
686 : private:
687 : int depthCount;
688 : };
689 :
690 170 : class OOXMLFastContextHandlerMath: public OOXMLFastContextHandlerLinear
691 : {
692 : public:
693 : explicit OOXMLFastContextHandlerMath(OOXMLFastContextHandler * pContext);
694 0 : virtual string getType() const { return "Math"; }
695 : protected:
696 : virtual void process();
697 : };
698 :
699 : }}
700 : #endif // INCLUDED_OOXML_FAST_CONTEXT_HANDLER_HXX
701 :
702 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|