update emoji autocorrect entries from po-files
[LibreOffice.git] / writerfilter / source / ooxml / OOXMLFastContextHandler.hxx
blob0eb22e8e5399d55a841273a7aac8cd6763e7bc16
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/implbase.hxx"
30 #include "com/sun/star/xml/sax/XFastContextHandler.hpp"
31 #include "OOXMLParserState.hxx"
32 #include "OOXMLPropertySetImpl.hxx"
33 #include "OOXMLDocumentImpl.hxx"
34 #include <oox/token/tokens.hxx>
35 #include <svtools/embedhlp.hxx>
37 #include <oox/mathml/import.hxx>
38 #include <oox/mathml/importutils.hxx>
40 namespace writerfilter {
41 namespace ooxml
45 class OOXMLFastContextHandler: public ::cppu::WeakImplHelper<css::xml::sax::XFastContextHandler>
47 public:
48 typedef std::shared_ptr<OOXMLFastContextHandler> Pointer_t;
50 enum ResourceEnum_t { UNKNOWN, STREAM, PROPERTIES, TABLE, SHAPE };
52 OOXMLFastContextHandler();
53 explicit OOXMLFastContextHandler(css::uno::Reference< css::uno::XComponentContext > const & context);
55 explicit OOXMLFastContextHandler(OOXMLFastContextHandler * pContext);
57 virtual ~OOXMLFastContextHandler();
59 // css::xml::sax::XFastContextHandler:
60 virtual void SAL_CALL startFastElement (Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs)
61 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
63 virtual void SAL_CALL startUnknownElement(const OUString & Namespace, const OUString & Name, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
64 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
66 virtual void SAL_CALL endFastElement(Token_t Element)
67 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
69 virtual void SAL_CALL endUnknownElement(const OUString & Namespace, const OUString & Name)
70 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
72 virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext(Token_t Element,
73 const css::uno::Reference<css::xml::sax::XFastAttributeList>& Attribs)
74 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
76 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext(const OUString & Namespace, const OUString & Name,
77 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
78 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
80 virtual void SAL_CALL characters(const OUString & aChars)
81 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
83 // local
85 void setStream(Stream * pStream);
87 /**
88 Return value of this context(element).
90 @return the value
92 virtual OOXMLValue::Pointer_t getValue() const;
94 /**
95 Returns a string describing the type of the context.
97 This is the name of the define normally.
99 @return type string
101 virtual std::string getType() const { return "??"; }
103 virtual ResourceEnum_t getResource() const { return STREAM; }
105 virtual void attributes(const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) throw (css::uno::RuntimeException, css::xml::sax::SAXException);
107 virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal);
108 virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
109 virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
111 virtual void setToken(Token_t nToken);
112 virtual Token_t getToken() const;
114 void resolveFootnote(const sal_Int32 nId);
115 void resolveEndnote(const sal_Int32 nId);
116 void resolveComment(const sal_Int32 nId);
117 void resolvePicture(const OUString & rId);
118 void resolveHeader(const sal_Int32 type,
119 const OUString & rId);
120 void resolveFooter(const sal_Int32 type,
121 const OUString & rId);
122 void resolveData(const OUString & rId);
124 OUString getTargetForId(const OUString & rId);
126 css::uno::Reference < css::xml::sax::XFastContextHandler > createFromStart(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs);
128 void setDocument(OOXMLDocumentImpl* pDocument);
129 OOXMLDocumentImpl* getDocument();
130 void setXNoteId(OOXMLValue::Pointer_t pValue);
131 void setXNoteId(const sal_Int32 nId);
132 sal_Int32 getXNoteId() const;
133 void setForwardEvents(bool bForwardEvents);
134 bool isForwardEvents() const;
135 virtual void setParent(OOXMLFastContextHandler * pParent);
136 virtual void setId(Id nId);
137 virtual Id getId() const;
139 void setDefine(Id nDefine);
140 Id getDefine() const { return mnDefine;}
142 OOXMLParserState::Pointer_t getParserState() const { return mpParserState;}
144 void sendTableDepth() const;
145 void setHandle();
147 void startSectionGroup();
148 void setLastParagraphInSection();
149 void setLastSectionGroup();
150 void endSectionGroup();
151 void startParagraphGroup();
152 void endParagraphGroup();
153 void startCharacterGroup();
154 void endCharacterGroup();
155 void startSdt();
156 void endSdt();
158 void startField();
159 void fieldSeparator();
160 void endField();
161 void lockField();
162 void ftnednref();
163 void ftnedncont();
164 void ftnednsep();
165 void pgNum();
166 void tab();
167 void cr();
168 void noBreakHyphen();
169 void softHyphen();
170 void handleLastParagraphInSection();
171 void endOfParagraph();
172 void text(const OUString & sText);
173 void positionOffset(const OUString & sText);
174 static void ignore();
175 void alignH(const OUString & sText);
176 void alignV(const OUString & sText);
177 void positivePercentage(const OUString& rText);
178 void startTxbxContent();
179 void endTxbxContent();
180 void propagateCharacterProperties();
181 void propagateCharacterPropertiesAsSet(const Id & rId);
182 void propagateTableProperties();
183 void propagateRowProperties();
184 void propagateCellProperties();
185 void sendPropertiesWithId(const Id & rId);
186 void sendPropertiesToParent();
187 void sendCellProperties();
188 void sendRowProperties();
189 void sendTableProperties();
190 void clearTableProps();
191 void clearProps();
193 virtual void setDefaultBooleanValue();
194 virtual void setDefaultIntegerValue();
195 virtual void setDefaultHexValue();
196 virtual void setDefaultStringValue();
198 void sendPropertyToParent();
200 sal_uInt32 getInstanceNumber() { return mnInstanceNumber; }
201 protected:
202 OOXMLFastContextHandler * mpParent;
203 Id mId;
204 Id mnDefine;
205 Token_t mnToken;
207 // the stream to send the stream events to.
208 Stream * mpStream;
210 // the current global parser state
211 OOXMLParserState::Pointer_t mpParserState;
213 // the table depth of this context
214 unsigned int mnTableDepth;
216 virtual void lcl_startFastElement(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
217 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception);
219 virtual void lcl_endFastElement(Token_t Element)
220 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception);
222 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > lcl_createFastChildContext(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
223 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception);
225 virtual void lcl_characters(const OUString & aChars)
226 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception);
228 void startAction(Token_t Element);
229 void endAction(Token_t Element);
231 virtual void resolvePropertySetAttrs();
233 css::uno::Reference< css::uno::XComponentContext > getComponentContext() { return m_xContext;}
235 sal_uInt32 mnInstanceNumber;
237 bool inPositionV;
239 private:
240 void operator =(OOXMLFastContextHandler &) SAL_DELETED_FUNCTION;
241 /// Handles AlternateContent. Returns true, if children of the current element should be ignored.
242 bool prepareMceContext(Token_t nElement, const css::uno::Reference<css::xml::sax::XFastAttributeList>& Attribs);
244 css::uno::Reference< css::uno::XComponentContext > m_xContext;
245 bool m_bDiscardChildren;
246 bool m_bTookChoice; ///< Did we take the Choice or want Fallback instead?
248 static sal_uInt32 mnInstanceCount;
252 class OOXMLFastContextHandlerStream : public OOXMLFastContextHandler
254 public:
255 explicit OOXMLFastContextHandlerStream(OOXMLFastContextHandler * pContext);
256 virtual ~OOXMLFastContextHandlerStream();
258 virtual ResourceEnum_t getResource() const SAL_OVERRIDE { return STREAM; }
260 OOXMLPropertySet::Pointer_t getPropertySetAttrs() const { return mpPropertySetAttrs;}
262 virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal) SAL_OVERRIDE;
263 void sendProperty(Id nId);
264 virtual OOXMLPropertySet::Pointer_t getPropertySet() const SAL_OVERRIDE;
266 void handleHyperlink();
268 protected:
269 virtual void resolvePropertySetAttrs() SAL_OVERRIDE;
271 private:
272 mutable OOXMLPropertySet::Pointer_t mpPropertySetAttrs;
275 class OOXMLFastContextHandlerProperties : public OOXMLFastContextHandler
277 public:
278 explicit OOXMLFastContextHandlerProperties(OOXMLFastContextHandler * pContext);
279 virtual ~OOXMLFastContextHandlerProperties();
281 virtual OOXMLValue::Pointer_t getValue() const SAL_OVERRIDE;
282 virtual ResourceEnum_t getResource() const SAL_OVERRIDE { return PROPERTIES; }
284 virtual void newProperty(const Id & nId, OOXMLValue::Pointer_t pVal) SAL_OVERRIDE;
286 void handleXNotes();
287 void handleHdrFtr();
288 void handleComment();
289 void handlePicture();
290 void handleBreak();
291 void handleOLE();
292 void handleFontRel();
294 virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet) SAL_OVERRIDE;
295 virtual OOXMLPropertySet::Pointer_t getPropertySet() const SAL_OVERRIDE;
297 protected:
298 /// the properties
299 OOXMLPropertySet::Pointer_t mpPropertySet;
301 virtual void lcl_endFastElement(Token_t Element)
302 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
303 virtual void setParent(OOXMLFastContextHandler * pParent) SAL_OVERRIDE;
305 private:
307 bool mbResolve;
310 class OOXMLFastContextHandlerPropertyTable :
311 public OOXMLFastContextHandlerProperties
313 public:
314 explicit OOXMLFastContextHandlerPropertyTable(OOXMLFastContextHandler * pContext);
315 virtual ~OOXMLFastContextHandlerPropertyTable();
317 protected:
318 OOXMLTableImpl mTable;
320 virtual void lcl_endFastElement(Token_t Element)
321 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
324 class OOXMLFastContextHandlerValue :
325 public OOXMLFastContextHandler
327 public:
328 explicit OOXMLFastContextHandlerValue(OOXMLFastContextHandler * pContext);
329 virtual ~OOXMLFastContextHandlerValue();
331 void setValue(OOXMLValue::Pointer_t pValue);
332 virtual OOXMLValue::Pointer_t getValue() const SAL_OVERRIDE;
334 virtual void lcl_endFastElement(Token_t Element)
335 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
337 virtual std::string getType() const SAL_OVERRIDE { return "Value"; }
339 virtual void setDefaultBooleanValue() SAL_OVERRIDE;
340 virtual void setDefaultIntegerValue() SAL_OVERRIDE;
341 virtual void setDefaultHexValue() SAL_OVERRIDE;
342 virtual void setDefaultStringValue() SAL_OVERRIDE;
344 protected:
345 OOXMLValue::Pointer_t mpValue;
348 class OOXMLFastContextHandlerTable : public OOXMLFastContextHandler
350 public:
351 explicit OOXMLFastContextHandlerTable(OOXMLFastContextHandler * pContext);
352 virtual ~OOXMLFastContextHandlerTable();
354 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext (Token_t Element,
355 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
356 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
358 protected:
359 OOXMLTableImpl mTable;
361 css::uno::Reference<css::xml::sax::XFastContextHandler> mCurrentChild;
363 virtual void lcl_endFastElement(Token_t Element)
364 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
366 virtual ResourceEnum_t getResource() const SAL_OVERRIDE { return TABLE; }
368 virtual std::string getType() const SAL_OVERRIDE { return "Table"; }
370 void addCurrentChild();
373 class OOXMLFastContextHandlerXNote : public OOXMLFastContextHandlerProperties
375 public:
376 explicit OOXMLFastContextHandlerXNote(OOXMLFastContextHandler * pContext);
377 virtual ~OOXMLFastContextHandlerXNote();
379 void checkId(OOXMLValue::Pointer_t pValue);
381 void checkType(OOXMLValue::Pointer_t pValue);
383 virtual std::string getType() const SAL_OVERRIDE { return "XNote"; }
385 private:
386 bool mbForwardEventsSaved;
387 sal_Int32 mnMyXNoteId;
388 sal_Int32 mnMyXNoteType;
390 virtual void lcl_startFastElement(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
391 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
393 virtual void lcl_endFastElement(Token_t Element)
394 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
396 virtual ResourceEnum_t getResource() const SAL_OVERRIDE { return STREAM; }
399 class OOXMLFastContextHandlerTextTableCell : public OOXMLFastContextHandler
401 public:
402 explicit OOXMLFastContextHandlerTextTableCell(OOXMLFastContextHandler * pContext);
403 virtual ~OOXMLFastContextHandlerTextTableCell();
405 virtual std::string getType() const SAL_OVERRIDE { return "TextTableCell"; }
407 static void startCell();
408 void endCell();
411 class OOXMLFastContextHandlerTextTableRow : public OOXMLFastContextHandler
413 public:
414 explicit OOXMLFastContextHandlerTextTableRow(OOXMLFastContextHandler * pContext);
415 virtual ~OOXMLFastContextHandlerTextTableRow();
417 virtual std::string getType() const SAL_OVERRIDE { return "TextTableRow"; }
419 static void startRow();
420 void endRow();
421 void handleGridBefore( OOXMLValue::Pointer_t val );
422 private:
423 static OOXMLProperty::Pointer_t fakeNoBorder( Id id );
426 class OOXMLFastContextHandlerTextTable : public OOXMLFastContextHandler
428 public:
429 explicit OOXMLFastContextHandlerTextTable(OOXMLFastContextHandler * pContext);
431 virtual ~OOXMLFastContextHandlerTextTable();
433 virtual std::string getType() const SAL_OVERRIDE { return "TextTable"; }
435 protected:
436 virtual void lcl_startFastElement(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
437 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
439 virtual void lcl_endFastElement(Token_t Element)
440 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
443 class OOXMLFastContextHandlerShape: public OOXMLFastContextHandlerProperties
445 private:
446 bool m_bShapeSent;
447 bool m_bShapeStarted;
449 public:
450 explicit OOXMLFastContextHandlerShape(OOXMLFastContextHandler * pContext);
451 virtual ~OOXMLFastContextHandlerShape();
453 virtual std::string getType() const SAL_OVERRIDE { return "Shape"; }
455 // css::xml::sax::XFastContextHandler:
456 virtual void SAL_CALL startUnknownElement (const OUString & Namespace, const OUString & Name, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
457 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
459 virtual void SAL_CALL endUnknownElement(const OUString & Namespace, const OUString & Name)
460 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
462 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext(const OUString & Namespace, const OUString & Name,
463 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
464 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
466 virtual void setToken(Token_t nToken) SAL_OVERRIDE;
468 virtual ResourceEnum_t getResource() const SAL_OVERRIDE { return SHAPE; }
470 void sendShape( Token_t Element );
471 bool isShapeSent( ) { return m_bShapeSent; }
473 protected:
474 typedef css::uno::Reference<css::xml::sax::XFastShapeContextHandler> ShapeContextRef;
475 ShapeContextRef mrShapeContext;
477 virtual void lcl_startFastElement(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
478 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
480 virtual void lcl_endFastElement(Token_t Element)
481 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
483 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > lcl_createFastChildContext (Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
484 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
486 virtual void lcl_characters(const OUString & aChars)
487 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
492 OOXMLFastContextHandlerWrapper wraps an OOXMLFastContextHandler.
494 The method calls for the interface css::xml::sax::XFastContextHandler are
495 forwarded to the wrapped OOXMLFastContextHandler.
497 class OOXMLFastContextHandlerWrapper : public OOXMLFastContextHandler
499 public:
500 explicit OOXMLFastContextHandlerWrapper(OOXMLFastContextHandler * pParent, css::uno::Reference<css::xml::sax::XFastContextHandler> xContext);
501 virtual ~OOXMLFastContextHandlerWrapper();
503 // css::xml::sax::XFastContextHandler:
504 virtual void SAL_CALL startUnknownElement(const OUString & Namespace, const OUString & Name, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
505 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
507 virtual void SAL_CALL endUnknownElement(const OUString & Namespace, const OUString & Name)
508 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
510 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext (const OUString & Namespace, const OUString & Name,
511 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
512 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
514 virtual void attributes(const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
515 throw (css::uno::RuntimeException, css::xml::sax::SAXException) SAL_OVERRIDE;
517 virtual ResourceEnum_t getResource() const SAL_OVERRIDE;
519 void addNamespace(const Id & nId);
520 void addToken( Token_t Element );
522 virtual void newProperty(const Id & rId, OOXMLValue::Pointer_t pVal) SAL_OVERRIDE;
523 virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet) SAL_OVERRIDE;
524 virtual OOXMLPropertySet::Pointer_t getPropertySet() const SAL_OVERRIDE;
526 virtual std::string getType() const SAL_OVERRIDE;
528 protected:
529 virtual void lcl_startFastElement(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
530 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
532 virtual void lcl_endFastElement(Token_t Element)
533 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
535 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > lcl_createFastChildContext(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
536 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
538 virtual void lcl_characters(const OUString & aChars)
539 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
541 virtual void setId(Id nId) SAL_OVERRIDE;
542 virtual Id getId() const SAL_OVERRIDE;
544 virtual void setToken(Token_t nToken) SAL_OVERRIDE;
545 virtual Token_t getToken() const SAL_OVERRIDE;
547 private:
548 css::uno::Reference<css::xml::sax::XFastContextHandler> mxContext;
549 std::set<Id> mMyNamespaces;
550 std::set<Token_t> mMyTokens;
551 OOXMLPropertySet::Pointer_t mpPropertySet;
553 OOXMLFastContextHandler * getFastContextHandler() const;
557 A class that converts from XFastParser/XFastContextHandler usage to a liner XML stream of data.
559 The purpose of this class is to convert the rather complex XFastContextHandler-based XML
560 processing that requires context subclasses, callbacks, etc. into a linear stream of XML tokens
561 that can be handled simply by reading the tokens one by one and directly processing them.
562 See the oox::formulaimport::XmlStream class documentation for more information.
564 Usage: Create a subclass of OOXMLFastContextHandlerLinear, reimplemented getType() to provide
565 type of the subclass and process() to actually process the XML stream. Also make sure to
566 add a line like the following to model.xml (for class OOXMLFastContextHandlerMath):
568 <resource name="CT_OMath" resource="Math"/>
570 @since 3.5
572 class OOXMLFastContextHandlerLinear: public OOXMLFastContextHandlerProperties
574 public:
575 explicit OOXMLFastContextHandlerLinear(OOXMLFastContextHandler * pContext);
577 Return the type of the class, as written in model.xml .
579 virtual std::string getType() const SAL_OVERRIDE = 0;
581 protected:
583 Called when the tokens for the element, its content and sub-elements have been linearized
584 and should be processed. The data member @ref buffer contains the converted data.
586 virtual void process() = 0;
588 virtual void lcl_startFastElement(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
589 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
591 virtual void lcl_endFastElement(Token_t Element) throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
593 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > lcl_createFastChildContext(Token_t Element,
594 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs)
595 throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
597 virtual void lcl_characters(const OUString & aChars) throw (css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE;
599 // should be private, but not much point in making deep copies of it
600 oox::formulaimport::XmlStreamBuilder buffer;
602 private:
603 int depthCount;
606 class OOXMLFastContextHandlerMath: public OOXMLFastContextHandlerLinear
608 public:
609 explicit OOXMLFastContextHandlerMath(OOXMLFastContextHandler * pContext);
610 virtual std::string getType() const SAL_OVERRIDE { return "Math"; }
611 protected:
612 virtual void process() SAL_OVERRIDE;
616 #endif // INCLUDED_WRITERFILTER_SOURCE_OOXML_OOXMLFASTCONTEXTHANDLER_HXX
618 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */