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 #pragma once
21 
22 #include <set>
23 #include <cppuhelper/implbase.hxx>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <com/sun/star/xml/sax/XFastContextHandler.hpp>
26 #include <com/sun/star/xml/sax/XFastShapeContextHandler.hpp>
27 #include <oox/mathml/importutils.hxx>
28 #include <rtl/ref.hxx>
29 #include "OOXMLParserState.hxx"
30 #include "OOXMLPropertySet.hxx"
31 
32 namespace writerfilter::ooxml
33 {
34 class OOXMLDocumentImpl;
35 
36 class OOXMLFastContextHandler: public ::cppu::WeakImplHelper<css::xml::sax::XFastContextHandler>
37 {
38 public:
39     typedef tools::SvRef<OOXMLFastContextHandler> Pointer_t;
40 
41     enum ResourceEnum_t { UNKNOWN, STREAM, PROPERTIES, TABLE, SHAPE };
42 
43     explicit OOXMLFastContextHandler(css::uno::Reference< css::uno::XComponentContext > const & context);
44 
45     explicit OOXMLFastContextHandler(OOXMLFastContextHandler * pContext);
46 
47     OOXMLFastContextHandler(OOXMLFastContextHandler const &) = default;
48 
49     virtual ~OOXMLFastContextHandler() override;
50 
51     // css::xml::sax::XFastContextHandler:
52     virtual void SAL_CALL startFastElement (sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList >& Attribs) override final;
53 
54     virtual void SAL_CALL startUnknownElement(const OUString & Namespace, const OUString & Name, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
55 
56     virtual void SAL_CALL endFastElement(sal_Int32 Element) override;
57 
58     virtual void SAL_CALL endUnknownElement(const OUString & Namespace, const OUString & Name) override;
59 
60     virtual css::uno::Reference<css::xml::sax::XFastContextHandler> SAL_CALL createFastChildContext(sal_Int32 Element,
61         const css::uno::Reference<css::xml::sax::XFastAttributeList>& Attribs) override;
62 
63     virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext(const OUString & Namespace, const OUString & Name,
64         const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
65 
66     virtual void SAL_CALL characters(const OUString & aChars) override;
67 
68     // local
69 
70     void setStream(Stream * pStream);
71 
72     /**
73        Return value of this context(element).
74 
75        @return  the value
76      */
77     virtual OOXMLValue::Pointer_t getValue() const;
78 
79     /**
80        Returns a string describing the type of the context.
81 
82        This is the name of the define normally.
83 
84        @return type string
85      */
getType() const86     virtual std::string getType() const { return "??"; }
87 
getResource() const88     virtual ResourceEnum_t getResource() const { return STREAM; }
89 
90     /// @throws css::uno::RuntimeException
91     /// @throws css::xml::sax::SAXException
92     virtual void attributes(const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs);
93 
94     virtual void newProperty(Id aId, const OOXMLValue::Pointer_t& pVal);
95     virtual void setPropertySet(const OOXMLPropertySet::Pointer_t& pPropertySet);
96     virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
97 
98     virtual void setToken(Token_t nToken);
99     virtual Token_t getToken() const;
100 
101     void resolveFootnote(const sal_Int32 nId);
102     void resolveEndnote(const sal_Int32 nId);
103     void resolveComment(const sal_Int32 nId);
104     void resolvePicture(const OUString & rId);
105     void resolveHeader(const sal_Int32 type,
106                                 const OUString & rId);
107     void resolveFooter(const sal_Int32 type,
108                                 const OUString & rId);
109     void resolveData(const OUString & rId);
110 
111     OUString getTargetForId(const OUString & rId);
112 
113     void setDocument(OOXMLDocumentImpl* pDocument);
114     OOXMLDocumentImpl* getDocument();
115     void setXNoteId(const OOXMLValue::Pointer_t& pValue);
116     void setXNoteId(const sal_Int32 nId);
117     sal_Int32 getXNoteId() const;
118     void setForwardEvents(bool bForwardEvents);
119     bool isForwardEvents() const;
120     virtual void setId(Id nId);
121     virtual Id getId() const;
122 
123     void setDefine(Id nDefine);
getDefine() const124     Id getDefine() const { return mnDefine;}
125 
getParserState() const126     const OOXMLParserState::Pointer_t& getParserState() const { return mpParserState;}
127 
128     void sendTableDepth() const;
129     void setHandle();
130 
131     void startSectionGroup();
132     void setLastParagraphInSection();
133     void setLastSectionGroup();
134     void endSectionGroup();
135     void startParagraphGroup();
136     void endParagraphGroup();
137     void startCharacterGroup();
138     void endCharacterGroup();
139     virtual void pushBiDiEmbedLevel();
140     virtual void popBiDiEmbedLevel();
141     void startSdt();
142     void endSdt();
143 
144     void startField();
145     void fieldSeparator();
146     void endField();
147     void lockField();
148     void ftnednref();
149     void ftnedncont();
150     void ftnednsep();
151     void pgNum();
152     void tab();
153     void symbol();
154     void cr();
155     void noBreakHyphen();
156     void softHyphen();
157     void handleLastParagraphInSection();
158     void endOfParagraph();
159     void text(const OUString & sText);
160     void positionOffset(const OUString & sText);
161     static void ignore();
162     void alignH(const OUString & sText);
163     void alignV(const OUString & sText);
164     void positivePercentage(const OUString& rText);
165     void startGlossaryEntry();
166     void endGlossaryEntry();
167     void startTxbxContent();
168     void endTxbxContent();
169     void propagateCharacterProperties();
170     void propagateTableProperties();
171     void propagateRowProperties();
172     void propagateCellProperties();
173     void sendPropertiesWithId(Id nId);
174     void sendPropertiesToParent();
175     void sendCellProperties();
176     void sendRowProperties();
177     void sendTableProperties();
178     void clearTableProps();
179     void clearProps();
180 
181     virtual void setDefaultBooleanValue();
182     virtual void setDefaultIntegerValue();
183     virtual void setDefaultHexValue();
184     virtual void setDefaultStringValue();
185 
186     void sendPropertyToParent();
getParent() const187     OOXMLFastContextHandler* getParent() const { return mpParent; }
setGridAfter(const OOXMLValue::Pointer_t & pGridAfter)188     void setGridAfter(const OOXMLValue::Pointer_t& pGridAfter) { mpGridAfter = pGridAfter; }
189 
190 protected:
191     OOXMLFastContextHandler * mpParent;
192     Id mId;
193     Id mnDefine;
194     Token_t mnToken;
195 
196     // the formula insertion mode: inline/newline(left, center, right)
197     sal_Int8 mnMathJcVal;
198     bool mbIsMathPara;
199     enum eMathParaJc
200     {
201         INLINE, //The equation is anchored as inline to the text
202         CENTER, //The equation is center aligned
203         LEFT,   //The equation is left aligned
204         RIGHT  //The equation is right aligned
205     };
206     // the stream to send the stream events to.
207     Stream * mpStream;
208 
209     // the current global parser state
210     OOXMLParserState::Pointer_t mpParserState;
211 
212     // the table depth of this context
213     unsigned int mnTableDepth;
214 
215     /// @throws css::uno::RuntimeException
216     /// @throws css::xml::sax::SAXException
217     virtual void lcl_startFastElement(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs);
218 
219     /// @throws css::uno::RuntimeException
220     /// @throws css::xml::sax::SAXException
221     virtual void lcl_endFastElement(Token_t Element);
222 
223     /// @throws css::uno::RuntimeException
224     /// @throws css::xml::sax::SAXException
225     virtual css::uno::Reference< css::xml::sax::XFastContextHandler > lcl_createFastChildContext(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs);
226 
227     /// @throws css::uno::RuntimeException
228     /// @throws css::xml::sax::SAXException
229     virtual void lcl_characters(const OUString & aChars);
230 
231     void startAction();
232     void endAction();
233 
getComponentContext() const234     const css::uno::Reference< css::uno::XComponentContext >& getComponentContext() const { return m_xContext;}
235 
236     bool inPositionV;
237     bool mbAllowInCell; // o:allowincell
238     bool mbIsVMLfound;
239     OOXMLValue::Pointer_t mpGridAfter;
240 
241 private:
242     void operator =(OOXMLFastContextHandler const &) = delete;
243     /// Handles AlternateContent. Returns true, if children of the current element should be ignored.
244     bool prepareMceContext(Token_t nElement, const css::uno::Reference<css::xml::sax::XFastAttributeList>& Attribs);
245 
246     // 2.10 of XML 1.0 specification
247     bool IsPreserveSpace() const;
248 
249     css::uno::Reference< css::uno::XComponentContext > m_xContext;
250     bool m_bDiscardChildren;
251     bool m_bTookChoice; ///< Did we take the Choice or want Fallback instead?
252     bool mbPreserveSpace = false;
253     bool mbPreserveSpaceSet = false;
254 
255 };
256 
257 class OOXMLFastContextHandlerStream : public OOXMLFastContextHandler
258 {
259 public:
260     explicit OOXMLFastContextHandlerStream(OOXMLFastContextHandler * pContext);
261     virtual ~OOXMLFastContextHandlerStream() override;
262 
getResource() const263     virtual ResourceEnum_t getResource() const override { return STREAM; }
264 
getPropertySetAttrs() const265     const OOXMLPropertySet::Pointer_t& getPropertySetAttrs() const { return mpPropertySetAttrs;}
266 
267     virtual void newProperty(Id aId, const OOXMLValue::Pointer_t& pVal) override;
268     void sendProperty(Id nId);
269     virtual OOXMLPropertySet::Pointer_t getPropertySet() const override;
270 
271     void handleHyperlink();
272 
273 private:
274     mutable OOXMLPropertySet::Pointer_t mpPropertySetAttrs;
275 };
276 
277 class OOXMLFastContextHandlerProperties : public OOXMLFastContextHandler
278 {
279 public:
280     explicit OOXMLFastContextHandlerProperties(OOXMLFastContextHandler * pContext);
281     virtual ~OOXMLFastContextHandlerProperties() override;
282 
283     virtual OOXMLValue::Pointer_t getValue() const override;
getResource() const284     virtual ResourceEnum_t getResource() const override { return PROPERTIES; }
285 
286     virtual void newProperty(Id nId, const OOXMLValue::Pointer_t& pVal) override;
287 
288     void handleXNotes();
289     void handleHdrFtr();
290     void handleComment();
291     void handlePicture();
292     void handleBreak();
293     void handleOutOfOrderBreak();
294     void handleOLE();
295     void handleFontRel();
296     void handleHyperlinkURL();
297     void handleAltChunk();
298 
299     virtual void setPropertySet(const OOXMLPropertySet::Pointer_t& pPropertySet) override;
300     virtual OOXMLPropertySet::Pointer_t getPropertySet() const override;
301 
302 protected:
303     /// the properties
304     OOXMLPropertySet::Pointer_t mpPropertySet;
305 
306     virtual void lcl_endFastElement(Token_t Element) override;
307 
308 private:
309 
310     bool mbResolve;
311 };
312 
313 class OOXMLFastContextHandlerPropertyTable :
314     public OOXMLFastContextHandlerProperties
315 {
316 public:
317     explicit OOXMLFastContextHandlerPropertyTable(OOXMLFastContextHandler * pContext);
318     virtual ~OOXMLFastContextHandlerPropertyTable() override;
319 
320 private:
321     OOXMLTable mTable;
322 
323     virtual void lcl_endFastElement(Token_t Element) override;
324 };
325 
326 class OOXMLFastContextHandlerValue :
327     public OOXMLFastContextHandler
328 {
329 public:
330     explicit OOXMLFastContextHandlerValue(OOXMLFastContextHandler * pContext);
331     virtual ~OOXMLFastContextHandlerValue() override;
332 
333     void setValue(const OOXMLValue::Pointer_t& pValue);
334     virtual OOXMLValue::Pointer_t getValue() const override;
335 
336     virtual void lcl_endFastElement(Token_t Element) override;
337 
getType() const338     virtual std::string getType() const override { return "Value"; }
339 
340     virtual void setDefaultBooleanValue() override;
341     virtual void setDefaultIntegerValue() override;
342     virtual void setDefaultHexValue() override;
343     virtual void setDefaultStringValue() override;
344 
345     virtual void pushBiDiEmbedLevel() override;
346     virtual void popBiDiEmbedLevel() override;
347 
348     void handleGridAfter();
349 
350 private:
351     OOXMLValue::Pointer_t mpValue;
352 };
353 
354 class OOXMLFastContextHandlerTable : public OOXMLFastContextHandler
355 {
356 public:
357     explicit OOXMLFastContextHandlerTable(OOXMLFastContextHandler * pContext);
358     virtual ~OOXMLFastContextHandlerTable() override;
359 
360     virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext (sal_Int32 Element,
361         const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
362 
363 private:
364     OOXMLTable mTable;
365 
366     css::uno::Reference<css::xml::sax::XFastContextHandler> mCurrentChild;
367 
368     virtual void lcl_endFastElement(Token_t Element) override;
369 
getResource() const370     virtual ResourceEnum_t getResource() const override { return TABLE; }
371 
getType() const372     virtual std::string getType() const override { return "Table"; }
373 
374     void addCurrentChild();
375 };
376 
377 class OOXMLFastContextHandlerXNote : public OOXMLFastContextHandlerProperties
378 {
379 public:
380     explicit OOXMLFastContextHandlerXNote(OOXMLFastContextHandler * pContext);
381     virtual ~OOXMLFastContextHandlerXNote() override;
382 
383     void checkId(const OOXMLValue::Pointer_t& pValue);
384 
385     void checkType(const OOXMLValue::Pointer_t& pValue);
386 
getType() const387     virtual std::string getType() const override { return "XNote"; }
388 
389 private:
390     bool mbForwardEventsSaved;
391     sal_Int32 mnMyXNoteId;
392     sal_Int32 mnMyXNoteType;
393 
394     virtual void lcl_startFastElement(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
395 
396     virtual void lcl_endFastElement(Token_t Element) override;
397 
getResource() const398     virtual ResourceEnum_t getResource() const override { return STREAM; }
399 };
400 
401 class OOXMLFastContextHandlerTextTableCell : public OOXMLFastContextHandler
402 {
403 public:
404     explicit OOXMLFastContextHandlerTextTableCell(OOXMLFastContextHandler * pContext);
405     virtual ~OOXMLFastContextHandlerTextTableCell() override;
406 
getType() const407     virtual std::string getType() const override { return "TextTableCell"; }
408 
409     void startCell();
410     void endCell();
411 };
412 
413 class OOXMLFastContextHandlerTextTableRow : public OOXMLFastContextHandler
414 {
415 public:
416     explicit OOXMLFastContextHandlerTextTableRow(OOXMLFastContextHandler * pContext);
417     virtual ~OOXMLFastContextHandlerTextTableRow() override;
418 
getType() const419     virtual std::string getType() const override { return "TextTableRow"; }
420 
421     static void startRow();
422     void endRow();
423     void handleGridBefore( const OOXMLValue::Pointer_t& val );
424 };
425 
426 class OOXMLFastContextHandlerTextTable : public OOXMLFastContextHandler
427 {
428 public:
429     explicit OOXMLFastContextHandlerTextTable(OOXMLFastContextHandler * pContext);
430 
431     virtual ~OOXMLFastContextHandlerTextTable() override;
432 
getType() const433     virtual std::string getType() const override { return "TextTable"; }
434 
435     // tdf#111550
436     // when <w:tbl> appears as direct child of <w:p>, we need to rearrange this paragraph
437     // to merge with the table's first paragraph (that's what Word does in this case)
438     void start_P_Tbl();
439 protected:
440     virtual void lcl_startFastElement(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
441 
442     virtual void lcl_endFastElement(Token_t Element) override;
443 };
444 
445 class OOXMLFastContextHandlerShape: public OOXMLFastContextHandlerProperties
446 {
447     bool m_bShapeSent;
448     bool m_bShapeStarted;
449     /// Is it necessary to pop the stack in the dtor?
450     bool m_bShapeContextPushed;
451     css::uno::Reference<css::xml::sax::XFastShapeContextHandler> mrShapeContext;
452 
453 public:
454     explicit OOXMLFastContextHandlerShape(OOXMLFastContextHandler * pContext);
455     virtual ~OOXMLFastContextHandlerShape() override;
456 
getType() const457     virtual std::string getType() const override { return "Shape"; }
458 
459     // css::xml::sax::XFastContextHandler:
460     virtual void SAL_CALL startUnknownElement (const OUString & Namespace, const OUString & Name, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
461 
462     virtual void SAL_CALL endUnknownElement(const OUString & Namespace, const OUString & Name) override;
463 
464     virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext(const OUString & Namespace, const OUString & Name,
465         const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
466 
467     virtual void setToken(Token_t nToken) override;
468 
getResource() const469     virtual ResourceEnum_t getResource() const override { return SHAPE; }
470 
471     void sendShape( Token_t Element );
isShapeSent() const472     bool isShapeSent( ) const { return m_bShapeSent; }
473 
474 protected:
475     virtual void lcl_startFastElement(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
476 
477     virtual void lcl_endFastElement(Token_t Element) override;
478 
479     virtual css::uno::Reference< css::xml::sax::XFastContextHandler > lcl_createFastChildContext (Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
480 
481     virtual void lcl_characters(const OUString & aChars) override;
482 
483 };
484 
485 /**
486    OOXMLFastContextHandlerWrapper wraps an OOXMLFastContextHandler.
487 
488    The method calls for the interface css::xml::sax::XFastContextHandler are
489    forwarded to the wrapped OOXMLFastContextHandler.
490  */
491 class OOXMLFastContextHandlerWrapper : public OOXMLFastContextHandler
492 {
493 public:
494     OOXMLFastContextHandlerWrapper(OOXMLFastContextHandler * pParent,
495                                    css::uno::Reference<css::xml::sax::XFastContextHandler> const & xContext,
496             rtl::Reference<OOXMLFastContextHandlerShape> const & xShapeHandler);
497     virtual ~OOXMLFastContextHandlerWrapper() override;
498 
499     // css::xml::sax::XFastContextHandler:
500     virtual void SAL_CALL startUnknownElement(const OUString & Namespace, const OUString & Name, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
501 
502     virtual void SAL_CALL endUnknownElement(const OUString & Namespace, const OUString & Name) override;
503 
504     virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createUnknownChildContext (const OUString & Namespace, const OUString & Name,
505         const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
506 
507     virtual void attributes(const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
508 
509     virtual ResourceEnum_t getResource() const override;
510 
511     void addNamespace(Id nId);
512     void addToken( Token_t Element );
513 
514     virtual void newProperty(Id nId, const OOXMLValue::Pointer_t& pVal) override;
515     virtual void setPropertySet(const OOXMLPropertySet::Pointer_t& pPropertySet) override;
516     virtual OOXMLPropertySet::Pointer_t getPropertySet() const override;
517 
518     virtual std::string getType() const override;
519 
520 protected:
521     virtual void lcl_startFastElement(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
522 
523     virtual void lcl_endFastElement(Token_t Element) override;
524 
525     virtual css::uno::Reference< css::xml::sax::XFastContextHandler > lcl_createFastChildContext(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
526 
527     virtual void lcl_characters(const OUString & aChars) override;
528 
529     virtual void setId(Id nId) override;
530     virtual Id getId() const override;
531 
532     virtual void setToken(Token_t nToken) override;
533     virtual Token_t getToken() const override;
534 
535 private:
536     css::uno::Reference<css::xml::sax::XFastContextHandler> mxWrappedContext;
537     rtl::Reference<OOXMLFastContextHandlerShape> mxShapeHandler;
538     std::set<Id> mMyNamespaces;
539     std::set<Token_t> mMyTokens;
540     OOXMLPropertySet::Pointer_t mpPropertySet;
541 
542     OOXMLFastContextHandler * getFastContextHandler() const;
543 };
544 
545 /**
546  A class that converts from XFastParser/XFastContextHandler usage to a liner XML stream of data.
547 
548  The purpose of this class is to convert the rather complex XFastContextHandler-based XML
549  processing that requires context subclasses, callbacks, etc. into a linear stream of XML tokens
550  that can be handled simply by reading the tokens one by one and directly processing them.
551  See the oox::formulaimport::XmlStream class documentation for more information.
552 
553  Usage: Create a subclass of OOXMLFastContextHandlerLinear, reimplemented getType() to provide
554  type of the subclass and process() to actually process the XML stream. Also make sure to
555  add a line like the following to model.xml (for class OOXMLFastContextHandlerMath):
556 
557  <resource name="CT_OMath" resource="Math"/>
558 
559  @since 3.5
560 */
561 class OOXMLFastContextHandlerLinear: public OOXMLFastContextHandlerProperties
562 {
563 public:
564     explicit OOXMLFastContextHandlerLinear(OOXMLFastContextHandler * pContext);
565     /**
566      Return the type of the class, as written in model.xml .
567      */
568     virtual std::string getType() const override = 0;
569 
570 protected:
571     /**
572      Called when the tokens for the element, its content and sub-elements have been linearized
573      and should be processed. The data member @ref buffer contains the converted data.
574     */
575     virtual void process() = 0;
576 
577     virtual void lcl_startFastElement(Token_t Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
578 
579     virtual void lcl_endFastElement(Token_t Element) override;
580 
581     virtual css::uno::Reference< css::xml::sax::XFastContextHandler > lcl_createFastChildContext(Token_t Element,
582         const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
583 
584     virtual void lcl_characters(const OUString & aChars) override;
585 
586     // should be private, but not much point in making deep copies of it
587     oox::formulaimport::XmlStreamBuilder buffer;
588 
589 private:
590     int depthCount;
591 };
592 
593 class OOXMLFastContextHandlerMath: public OOXMLFastContextHandlerLinear
594 {
595 public:
596     explicit OOXMLFastContextHandlerMath(OOXMLFastContextHandler * pContext);
getType() const597     virtual std::string getType() const override { return "Math"; }
598 protected:
599     virtual void process() override;
600 };
601 
602 /**
603  A class that reads individual w15:commentEx elements from commentsExtended stream [MS-DOCX].
604 
605  It is used to pre-populate the extended comment properties in domain mapper. The stream
606  contains information about resolved state of the comments ("done" attribute) and the parent
607  comment (the one that this comment answers to).
608 
609  Note that the data is linked to paraId identifiers (also introduced in [MS-DOCX]), which
610  correspond to paragraphs, not directly to comment ids.
611 
612  @since 7.2
613 */
614 class OOXMLFastContextHandlerCommentEx : public OOXMLFastContextHandler
615 {
616 public:
617     explicit OOXMLFastContextHandlerCommentEx(OOXMLFastContextHandler* pContext);
618 
getType() const619     virtual std::string getType() const override { return "CommentEx"; }
620     virtual void lcl_endFastElement(Token_t Element) override;
621 
622     void att_paraId(const OOXMLValue::Pointer_t& pValue);
623     void att_done(const OOXMLValue::Pointer_t& pValue);
624 
625 private:
626     OUString m_sParaId;
627     bool m_bDone = false;
628 };
629 
630 }
631 
632 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
633