Bump version to 4.3-4
[LibreOffice.git] / writerfilter / source / ooxml / OOXMLFastContextHandler.hxx
blobf56f5e9a6c3e19f64adfa41ae197625ab1fe8c78
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLFASTCONTEXTHANDLER_HXX
21 #define INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLFASTCONTEXTHANDLER_HXX
23 #include <com/sun/star/xml/sax/XFastShapeContextHandler.hpp>
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>
38 #include <oox/mathml/import.hxx>
39 #include <oox/mathml/importutils.hxx>
41 namespace writerfilter {
42 namespace ooxml
45 typedef boost::shared_ptr<Stream> StreamPointer_t;
47 /**
48 * Struct to store our 'alternate state'. If multiple mc:AlternateContent
49 * elements arrive, then while the inner ones are active, the original state is
50 * saved away, and once they inner goes out of scope, the original state is
51 * restored.
53 struct SavedAlternateState
55 bool m_bDiscardChildren;
56 bool m_bTookChoice; ///< Did we take the Choice or want Fallback instead?
59 class OOXMLFastContextHandler:
60 public ::cppu::WeakImplHelper1<
61 xml::sax::XFastContextHandler>
63 public:
64 typedef RefAndPointer<XFastContextHandler, OOXMLFastContextHandler>
65 RefAndPointer_t;
66 typedef boost::shared_ptr<OOXMLFastContextHandler> Pointer_t;
68 enum ResourceEnum_t { UNKNOWN, STREAM, PROPERTIES, TABLE, SHAPE };
70 OOXMLFastContextHandler();
71 explicit OOXMLFastContextHandler
72 (uno::Reference< uno::XComponentContext > const & context);
74 explicit OOXMLFastContextHandler
75 (OOXMLFastContextHandler * pContext);
77 virtual ~OOXMLFastContextHandler();
79 // ::com::sun::star::xml::sax::XFastContextHandler:
80 virtual void SAL_CALL startFastElement
81 (Token_t Element,
82 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
83 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
85 virtual void SAL_CALL startUnknownElement
86 (const OUString & Namespace,
87 const OUString & Name,
88 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
89 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
91 virtual void SAL_CALL endFastElement(Token_t Element)
92 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
94 virtual void SAL_CALL endUnknownElement
95 (const OUString & Namespace, const OUString & Name)
96 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
98 virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
99 createFastChildContext
100 (Token_t Element,
101 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
102 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
104 virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
105 createUnknownChildContext
106 (const OUString & Namespace,
107 const OUString & Name,
108 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
109 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
111 virtual void SAL_CALL characters(const OUString & aChars)
112 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
114 static const uno::Sequence< sal_Int8 > & getUnoTunnelId();
115 virtual sal_Int64 SAL_CALL getSomething(const uno::Sequence<sal_Int8> & rId)
116 throw (uno::RuntimeException);
118 // local
120 void setStream(Stream * pStream);
123 Return value of this context(element).
125 @return the value
127 virtual OOXMLValue::Pointer_t getValue() const;
130 Returns a string describing the type of the context.
132 This is the name of the define normally.
134 @return type string
136 virtual string getType() const { return "??"; }
138 virtual ResourceEnum_t getResource() const { return STREAM; }
140 virtual void attributes
141 (const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
142 throw (uno::RuntimeException, xml::sax::SAXException);
144 virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal);
145 virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
146 virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
148 virtual void setToken(Token_t nToken);
149 virtual Token_t getToken() const;
151 void resolveFootnote(const sal_Int32 nId);
152 void resolveEndnote(const sal_Int32 nId);
153 void resolveComment(const sal_Int32 nId);
154 void resolvePicture(const OUString & rId);
155 void resolveHeader(const sal_Int32 type,
156 const OUString & rId);
157 void resolveFooter(const sal_Int32 type,
158 const OUString & rId);
159 void resolveData(const OUString & rId);
161 OUString getTargetForId(const OUString & rId);
163 uno::Reference < xml::sax::XFastContextHandler >
164 createFromStart
165 (Token_t Element,
166 const uno::Reference< xml::sax::XFastAttributeList > & Attribs);
168 void setDocument(OOXMLDocumentImpl* pDocument);
169 OOXMLDocumentImpl* getDocument();
170 void setXNoteId(OOXMLValue::Pointer_t pValue);
171 void setXNoteId(const sal_Int32 nId);
172 sal_Int32 getXNoteId() const;
173 void setForwardEvents(bool bForwardEvents);
174 bool isForwardEvents() const;
175 virtual void setParent(OOXMLFastContextHandler * pParent);
176 virtual void setId(Id nId);
177 virtual Id getId() const;
179 void setDefine(Id nDefine);
180 Id getDefine() const;
182 OOXMLParserState::Pointer_t getParserState() const;
184 void sendTableDepth() const;
185 void setHandle();
187 void startSectionGroup();
188 void setLastParagraphInSection();
189 void setLastSectionGroup();
190 void endSectionGroup();
191 void startParagraphGroup();
192 void endParagraphGroup();
193 void startCharacterGroup();
194 void endCharacterGroup();
195 void startSdt();
196 void endSdt();
198 void startField();
199 void fieldSeparator();
200 void endField();
201 void ftnednref();
202 void ftnedncont();
203 void ftnednsep();
204 void pgNum();
205 void tab();
206 void cr();
207 void noBreakHyphen();
208 void softHyphen();
209 void handleLastParagraphInSection();
210 void endOfParagraph();
211 void text(const OUString & sText);
212 void positionOffset(const OUString & sText);
213 void alignH(const OUString & sText);
214 void alignV(const OUString & sText);
215 void positivePercentage(const OUString& rText);
216 void startTxbxContent();
217 void endTxbxContent();
218 virtual void propagateCharacterProperties();
219 virtual void propagateCharacterPropertiesAsSet(const Id & rId);
220 virtual void propagateTableProperties();
221 virtual void propagateRowProperties();
222 virtual void propagateCellProperties();
223 virtual bool propagatesProperties() const;
224 void sendPropertiesWithId(const Id & rId);
225 void sendPropertiesToParent();
226 void sendCellProperties();
227 void sendRowProperties();
228 void sendTableProperties();
229 void clearTableProps();
230 void clearProps();
232 virtual void setDefaultBooleanValue();
233 virtual void setDefaultIntegerValue();
234 virtual void setDefaultHexValue();
235 virtual void setDefaultStringValue();
237 void sendPropertyToParent();
239 #if OSL_DEBUG_LEVEL > 1
240 virtual void dumpXml( const TagLogger::Pointer_t pLogger ) const;
241 #endif
243 sal_uInt32 getInstanceNumber() { return mnInstanceNumber; }
244 protected:
245 OOXMLFastContextHandler * mpParent;
246 Id mId;
247 Id mnDefine;
248 Token_t mnToken;
250 #ifdef DEBUG_CONTEXT_HANDLER
251 string msTokenString;
252 #endif
254 // the stream to send the stream events to.
255 Stream * mpStream;
257 // the current global parser state
258 OOXMLParserState::Pointer_t mpParserState;
260 // the table depth of this context
261 unsigned int mnTableDepth;
263 virtual void lcl_startFastElement
264 (Token_t Element,
265 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
266 throw (uno::RuntimeException, xml::sax::SAXException);
268 virtual void lcl_endFastElement(Token_t Element)
269 throw (uno::RuntimeException, xml::sax::SAXException);
271 virtual uno::Reference< xml::sax::XFastContextHandler >
272 lcl_createFastChildContext
273 (Token_t Element,
274 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
275 throw (uno::RuntimeException, xml::sax::SAXException);
277 virtual void lcl_characters(const OUString & aChars)
278 throw (uno::RuntimeException, xml::sax::SAXException);
280 void startAction(Token_t Element);
281 virtual void lcl_startAction(Token_t Element);
282 void endAction(Token_t Element);
283 virtual void lcl_endAction(Token_t Element);
286 virtual OOXMLPropertySet * getPicturePropSet
287 (const OUString & rId);
288 virtual void resolvePropertySetAttrs();
290 uno::Reference< uno::XComponentContext > getComponentContext();
292 sal_uInt32 mnInstanceNumber;
294 bool inPositionV;
296 private:
297 void operator =(OOXMLFastContextHandler &); // not defined
298 /// Handles AlternateContent. Returns true, if children of the current element should be ignored.
299 bool prepareMceContext(Token_t nElement, const uno::Reference<xml::sax::XFastAttributeList>& Attribs);
301 uno::Reference< uno::XComponentContext > m_xContext;
302 bool m_bDiscardChildren;
303 bool m_bTookChoice; ///< Did we take the Choice or want Fallback instead?
304 std::vector<SavedAlternateState> m_aSavedAlternateStates;
306 static sal_uInt32 mnInstanceCount;
310 class OOXMLFastContextHandlerStream : public OOXMLFastContextHandler
312 public:
313 OOXMLFastContextHandlerStream(OOXMLFastContextHandler * pContext);
314 virtual ~OOXMLFastContextHandlerStream();
316 virtual ResourceEnum_t getResource() const SAL_OVERRIDE { return STREAM; }
318 OOXMLPropertySet::Pointer_t getPropertySetAttrs() const;
320 virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal) SAL_OVERRIDE;
321 virtual void sendProperty(Id nId);
322 virtual OOXMLPropertySet::Pointer_t getPropertySet() const SAL_OVERRIDE;
324 void handleHyperlink();
326 protected:
327 virtual void resolvePropertySetAttrs() SAL_OVERRIDE;
329 private:
330 mutable OOXMLPropertySet::Pointer_t mpPropertySetAttrs;
333 class OOXMLFastContextHandlerProperties : public OOXMLFastContextHandler
335 public:
336 OOXMLFastContextHandlerProperties(OOXMLFastContextHandler * pContext);
337 virtual ~OOXMLFastContextHandlerProperties();
339 virtual OOXMLValue::Pointer_t getValue() const SAL_OVERRIDE;
340 virtual ResourceEnum_t getResource() const SAL_OVERRIDE { return PROPERTIES; }
342 virtual void newProperty(const Id & nId, OOXMLValue::Pointer_t pVal) SAL_OVERRIDE;
344 void handleXNotes();
345 void handleHdrFtr();
346 void handleComment();
347 void handlePicture();
348 void handleBreak();
349 void handleOLE();
350 void handleFontRel();
352 virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet) SAL_OVERRIDE;
353 virtual OOXMLPropertySet::Pointer_t getPropertySet() const SAL_OVERRIDE;
355 #if OSL_DEBUG_LEVEL > 1
356 virtual void dumpXml( const TagLogger::Pointer_t pLogger ) const;
357 #endif
359 protected:
360 /// the properties
361 OOXMLPropertySet::Pointer_t mpPropertySet;
363 virtual void lcl_endFastElement(Token_t Element)
364 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
365 virtual void setParent(OOXMLFastContextHandler * pParent) SAL_OVERRIDE;
367 private:
369 bool mbResolve;
372 class OOXMLFastContextHandlerPropertyTable :
373 public OOXMLFastContextHandlerProperties
375 public:
376 OOXMLFastContextHandlerPropertyTable(OOXMLFastContextHandler * pContext);
377 virtual ~OOXMLFastContextHandlerPropertyTable();
379 protected:
380 OOXMLTableImpl mTable;
382 virtual void lcl_endFastElement(Token_t Element)
383 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
386 class OOXMLFastContextHandlerValue :
387 public OOXMLFastContextHandler
389 public:
390 OOXMLFastContextHandlerValue
391 (OOXMLFastContextHandler * pContext);
392 virtual ~OOXMLFastContextHandlerValue();
394 virtual void setValue(OOXMLValue::Pointer_t pValue);
395 virtual OOXMLValue::Pointer_t getValue() const SAL_OVERRIDE;
397 virtual void lcl_endFastElement(Token_t Element)
398 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
400 virtual string getType() const SAL_OVERRIDE { return "Value"; }
402 virtual void setDefaultBooleanValue() SAL_OVERRIDE;
403 virtual void setDefaultIntegerValue() SAL_OVERRIDE;
404 virtual void setDefaultHexValue() SAL_OVERRIDE;
405 virtual void setDefaultStringValue() SAL_OVERRIDE;
407 protected:
408 OOXMLValue::Pointer_t mpValue;
411 class OOXMLFastContextHandlerTable : public OOXMLFastContextHandler
413 public:
414 OOXMLFastContextHandlerTable(OOXMLFastContextHandler * pContext);
415 virtual ~OOXMLFastContextHandlerTable();
417 virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
418 createFastChildContext
419 (Token_t Element,
420 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
421 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
423 virtual void newPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
424 protected:
425 OOXMLTableImpl mTable;
427 RefAndPointer_t mCurrentChild;
429 virtual void lcl_endFastElement(Token_t Element)
430 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
432 virtual ResourceEnum_t getResource() const SAL_OVERRIDE { return TABLE; }
434 virtual string getType() const SAL_OVERRIDE { return "Table"; }
436 void addCurrentChild();
439 class OOXMLFastContextHandlerXNote : public OOXMLFastContextHandlerProperties
441 public:
442 OOXMLFastContextHandlerXNote(OOXMLFastContextHandler * pContext);
443 virtual ~OOXMLFastContextHandlerXNote();
445 void checkId(OOXMLValue::Pointer_t pValue);
447 void checkType(OOXMLValue::Pointer_t pValue);
449 virtual string getType() const SAL_OVERRIDE { return "XNote"; }
451 private:
452 bool mbForwardEventsSaved;
453 sal_Int32 mnMyXNoteId;
454 sal_Int32 mnMyXNoteType;
456 virtual void lcl_startFastElement
457 (Token_t Element,
458 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
459 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
461 virtual void lcl_endFastElement(Token_t Element)
462 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
464 virtual ResourceEnum_t getResource() const SAL_OVERRIDE { return STREAM; }
467 class OOXMLFastContextHandlerTextTableCell : public OOXMLFastContextHandler
469 public:
470 OOXMLFastContextHandlerTextTableCell
471 (OOXMLFastContextHandler * pContext);
472 virtual ~OOXMLFastContextHandlerTextTableCell();
474 virtual string getType() const SAL_OVERRIDE { return "TextTableCell"; }
476 void startCell();
477 void endCell();
480 class OOXMLFastContextHandlerTextTableRow : public OOXMLFastContextHandler
482 public:
483 OOXMLFastContextHandlerTextTableRow
484 (OOXMLFastContextHandler * pContext);
485 virtual ~OOXMLFastContextHandlerTextTableRow();
487 virtual string getType() const SAL_OVERRIDE { return "TextTableRow"; }
489 void startRow();
490 void endRow();
491 void handleGridBefore( OOXMLValue::Pointer_t val );
492 private:
493 OOXMLProperty::Pointer_t fakeNoBorder( Id id );
496 class OOXMLFastContextHandlerTextTable : public OOXMLFastContextHandler
498 public:
499 OOXMLFastContextHandlerTextTable
500 (OOXMLFastContextHandler * pContext);
502 virtual ~OOXMLFastContextHandlerTextTable();
504 virtual string getType() const SAL_OVERRIDE { return "TextTable"; }
506 protected:
507 virtual void lcl_startFastElement
508 (Token_t Element,
509 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
510 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
512 virtual void lcl_endFastElement(Token_t Element)
513 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
516 class OOXMLFastContextHandlerShape: public OOXMLFastContextHandlerProperties
518 private:
519 bool m_bShapeSent;
520 bool m_bShapeStarted;
522 public:
523 explicit OOXMLFastContextHandlerShape
524 (OOXMLFastContextHandler * pContext);
525 virtual ~OOXMLFastContextHandlerShape();
527 virtual string getType() const SAL_OVERRIDE { return "Shape"; }
529 // ::com::sun::star::xml::sax::XFastContextHandler:
530 virtual void SAL_CALL startUnknownElement
531 (const OUString & Namespace,
532 const OUString & Name,
533 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
534 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
536 virtual void SAL_CALL endUnknownElement
537 (const OUString & Namespace,
538 const OUString & Name)
539 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
541 virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
542 createUnknownChildContext
543 (const OUString & Namespace,
544 const OUString & Name,
545 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
546 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
548 virtual void setToken(Token_t nToken) SAL_OVERRIDE;
550 virtual ResourceEnum_t getResource() const SAL_OVERRIDE { return SHAPE; }
552 void sendShape( Token_t Element );
553 bool isShapeSent( ) { return m_bShapeSent; }
555 protected:
556 typedef css::uno::Reference<css::xml::sax::XFastShapeContextHandler> ShapeContextRef;
557 ShapeContextRef mrShapeContext;
559 virtual void lcl_startFastElement
560 (Token_t Element,
561 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
562 throw (css::uno::RuntimeException, css::xml::sax::SAXException) SAL_OVERRIDE;
564 virtual void lcl_endFastElement(Token_t Element)
565 throw (css::uno::RuntimeException, css::xml::sax::SAXException) SAL_OVERRIDE;
567 virtual uno::Reference< xml::sax::XFastContextHandler >
568 lcl_createFastChildContext
569 (Token_t Element,
570 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
571 throw (css::uno::RuntimeException, css::xml::sax::SAXException) SAL_OVERRIDE;
573 virtual void lcl_characters(const OUString & aChars)
574 throw (css::uno::RuntimeException, css::xml::sax::SAXException) SAL_OVERRIDE;
579 OOXMLFastContextHandlerWrapper wraps an OOXMLFastContextHandler.
581 The method calls for the interface
582 ::com::sun::star::xml::sax::XFastContextHandler are forwarded to the wrapped
583 OOXMLFastContextHandler.
585 class OOXMLFastContextHandlerWrapper : public OOXMLFastContextHandler
587 public:
588 explicit OOXMLFastContextHandlerWrapper
589 (OOXMLFastContextHandler * pParent,
590 uno::Reference<XFastContextHandler> xContext);
591 virtual ~OOXMLFastContextHandlerWrapper();
593 // ::com::sun::star::xml::sax::XFastContextHandler:
594 virtual void SAL_CALL startUnknownElement
595 (const OUString & Namespace,
596 const OUString & Name,
597 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
598 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
600 virtual void SAL_CALL endUnknownElement
601 (const OUString & Namespace,
602 const OUString & Name)
603 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
605 virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
606 createUnknownChildContext
607 (const OUString & Namespace,
608 const OUString & Name,
609 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
610 throw (uno::RuntimeException, xml::sax::SAXException, std::exception) SAL_OVERRIDE;
612 virtual void attributes
613 (const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
614 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
616 virtual ResourceEnum_t getResource() const SAL_OVERRIDE;
618 void addNamespace(const Id & nId);
619 void addToken( Token_t Element );
621 virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal) SAL_OVERRIDE;
622 virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet) SAL_OVERRIDE;
623 virtual OOXMLPropertySet::Pointer_t getPropertySet() const SAL_OVERRIDE;
625 virtual string getType() const SAL_OVERRIDE;
627 protected:
628 virtual void lcl_startFastElement
629 (Token_t Element,
630 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
631 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
633 virtual void lcl_endFastElement(Token_t Element)
634 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
636 virtual uno::Reference< xml::sax::XFastContextHandler >
637 lcl_createFastChildContext
638 (Token_t Element,
639 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
640 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
642 virtual void lcl_characters(const OUString & aChars)
643 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
645 virtual void setId(Id nId) SAL_OVERRIDE;
646 virtual Id getId() const SAL_OVERRIDE;
648 virtual void setToken(Token_t nToken) SAL_OVERRIDE;
649 virtual Token_t getToken() const SAL_OVERRIDE;
651 private:
652 uno::Reference<XFastContextHandler> mxContext;
653 set<Id> mMyNamespaces;
654 set<Token_t> mMyTokens;
655 OOXMLPropertySet::Pointer_t mpPropertySet;
657 OOXMLFastContextHandler * getFastContextHandler() const;
661 A class that converts from XFastParser/XFastContextHandler usage to a liner XML stream of data.
663 The purpose of this class is to convert the rather complex XFastContextHandler-based XML
664 processing that requires context subclasses, callbacks, etc. into a linear stream of XML tokens
665 that can be handled simply by reading the tokens one by one and directly processing them.
666 See the oox::formulaimport::XmlStream class documentation for more information.
668 Usage: Create a subclass of OOXMLFastContextHandlerLinear, reimplemented getType() to provide
669 type of the subclass and process() to actually process the XML stream. Also make sure to
670 add a line like the following to model.xml (for class OOXMLFastContextHandlerMath):
672 <resource name="CT_OMath" resource="Math"/>
674 @since 3.5
676 class OOXMLFastContextHandlerLinear: public OOXMLFastContextHandlerProperties
678 public:
679 explicit OOXMLFastContextHandlerLinear(OOXMLFastContextHandler * pContext);
681 Return the type of the class, as written in model.xml .
683 virtual string getType() const SAL_OVERRIDE = 0;
685 protected:
687 Called when the tokens for the element, its content and sub-elements have been linearized
688 and should be processed. The data member @ref buffer contains the converted data.
690 virtual void process() = 0;
692 virtual void lcl_startFastElement(Token_t Element, const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
693 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
695 virtual void lcl_endFastElement(Token_t Element) throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
697 virtual uno::Reference< xml::sax::XFastContextHandler > lcl_createFastChildContext(Token_t Element,
698 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
699 throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
701 virtual void lcl_characters(const OUString & aChars) throw (uno::RuntimeException, xml::sax::SAXException) SAL_OVERRIDE;
703 // should be private, but not much point in making deep copies of it
704 oox::formulaimport::XmlStreamBuilder buffer;
706 private:
707 int depthCount;
710 class OOXMLFastContextHandlerMath: public OOXMLFastContextHandlerLinear
712 public:
713 explicit OOXMLFastContextHandlerMath(OOXMLFastContextHandler * pContext);
714 virtual string getType() const SAL_OVERRIDE { return "Math"; }
715 protected:
716 virtual void process() SAL_OVERRIDE;
720 #endif // INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLFASTCONTEXTHANDLER_HXX
722 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */