lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / writerfilter / source / rtftok / rtfdocumentimpl.hxx
blob0ecf59aae42a616e9f2e2531f411c437205de71b
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/.
8 */
10 #ifndef INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFDOCUMENTIMPL_HXX
11 #define INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFDOCUMENTIMPL_HXX
13 #include <queue>
14 #include <tuple>
15 #include <vector>
16 #include <boost/optional.hpp>
18 #include <com/sun/star/text/WrapTextMode.hpp>
19 #include <oox/mathml/importutils.hxx>
20 #include <rtl/strbuf.hxx>
21 #include <rtl/ustrbuf.hxx>
22 #include <tools/color.hxx>
24 #include <rtftok/RTFDocument.hxx>
25 #include "rtfreferencetable.hxx"
26 #include "rtfsprm.hxx"
27 #include "rtflistener.hxx"
29 class SvStream;
30 namespace oox
32 class GraphicHelper;
34 namespace com
36 namespace sun
38 namespace star
40 namespace beans
42 class XPropertySet;
44 namespace document
46 class XDocumentProperties;
48 namespace lang
50 class XMultiServiceFactory;
56 namespace writerfilter
58 namespace rtftok
60 class RTFParserState;
61 class RTFDocumentImpl;
62 class RTFTokenizer;
63 class RTFSdrImport;
64 struct TableRowBuffer;
66 enum class RTFBorderState
68 NONE,
69 PARAGRAPH,
70 PARAGRAPH_BOX,
71 CELL,
72 PAGE,
73 CHARACTER
76 /// Different kind of buffers for table cell contents.
77 enum RTFBufferTypes
79 BUFFER_SETSTYLE,
80 /// Stores properties, should be created only in bufferProperties().
81 BUFFER_PROPS,
82 BUFFER_NESTROW,
83 BUFFER_CELLEND,
84 BUFFER_STARTRUN,
85 BUFFER_TEXT,
86 BUFFER_UTEXT,
87 BUFFER_ENDRUN,
88 BUFFER_PAR,
89 BUFFER_STARTSHAPE,
90 /// Imports a shape.
91 BUFFER_RESOLVESHAPE,
92 BUFFER_ENDSHAPE,
93 BUFFER_RESOLVESUBSTREAM,
94 /// Restores RTFParserState::aPicture.
95 BUFFER_PICTURE
98 /// Form field types
99 enum class RTFFormFieldType
101 NONE,
102 TEXT,
103 CHECKBOX,
104 LIST
107 enum class RTFBmpStyle
109 NONE,
110 PNG,
111 JPEG,
112 DIBITMAP
115 enum class RTFFieldStatus
117 NONE,
118 INSTRUCTION,
119 RESULT
122 /// A buffer storing dmapper calls.
123 using Buf_t = std::tuple<RTFBufferTypes, RTFValue::Pointer_t, tools::SvRef<TableRowBuffer>>;
124 using RTFBuffer_t = std::deque<Buf_t>;
126 /// holds one nested table row
127 struct TableRowBuffer : public virtual SvRefBase
129 RTFBuffer_t buffer;
130 ::std::deque<RTFSprms> cellsSprms;
131 ::std::deque<RTFSprms> cellsAttributes;
132 int const nCells;
133 writerfilter::Reference<Properties>::Pointer_t pParaProperties;
134 writerfilter::Reference<Properties>::Pointer_t pFrameProperties;
135 writerfilter::Reference<Properties>::Pointer_t pRowProperties;
137 TableRowBuffer(RTFBuffer_t aBuffer, std::deque<RTFSprms> aSprms,
138 std::deque<RTFSprms> aAttributes, int const i_nCells)
139 : buffer(std::move(aBuffer))
140 , cellsSprms(std::move(aSprms))
141 , cellsAttributes(std::move(aAttributes))
142 , nCells(i_nCells)
147 /// An entry in the color table.
148 class RTFColorTableEntry
150 public:
151 void SetRed(sal_uInt8 nRed)
153 m_bAuto = false;
154 m_nR = nRed;
156 void SetGreen(sal_uInt8 nGreen)
158 m_bAuto = false;
159 m_nG = nGreen;
161 void SetBlue(sal_uInt8 nBlue)
163 m_bAuto = false;
164 m_nB = nBlue;
166 Color GetColor() const { return m_bAuto ? COL_AUTO : Color(m_nR, m_nG, m_nB); }
168 private:
169 bool m_bAuto = true;
170 sal_uInt8 m_nR = 0;
171 sal_uInt8 m_nG = 0;
172 sal_uInt8 m_nB = 0;
175 /// Stores the properties of a shape.
176 class RTFShape : public virtual SvRefBase
178 public:
179 RTFShape();
180 std::vector<std::pair<OUString, OUString>> aProperties; ///< Properties of a single shape.
181 std::vector<std::pair<OUString, OUString>>
182 aGroupProperties; ///< Properties applied on the groupshape.
183 sal_Int32 nLeft = 0;
184 sal_Int32 nTop = 0;
185 sal_Int32 nRight = 0;
186 sal_Int32 nBottom = 0;
187 boost::optional<sal_Int32> oZ; ///< Z-Order of the shape.
188 sal_Int16 nHoriOrientRelation = 0; ///< Horizontal text::RelOrientation for drawinglayer shapes.
189 sal_Int16 nVertOrientRelation = 0; ///< Vertical text::RelOrientation for drawinglayer shapes.
190 sal_uInt32 nHoriOrientRelationToken = 0; ///< Horizontal dmapper token for Writer pictures.
191 sal_uInt32 nVertOrientRelationToken = 0; ///< Vertical dmapper token for Writer pictures.
192 css::text::WrapTextMode nWrap = css::text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE;
193 /// If shape is below text (true) or text is below shape (false).
194 bool bInBackground = false;
195 /// Wrap polygon, written by RTFSdrImport::resolve(), read by RTFDocumentImpl::resolvePict().
196 RTFSprms aWrapPolygonSprms;
197 /// Anchor attributes like wrap distance, written by RTFSdrImport::resolve(), read by RTFDocumentImpl::resolvePict().
198 RTFSprms aAnchorAttributes;
199 /// Wrap type, written by RTFDocumentImpl::popState(), read by RTFDocumentImpl::resolvePict().
200 std::pair<Id, RTFValue::Pointer_t> aWrapSprm{ 0, nullptr };
203 /// Stores the properties of a drawing object.
204 class RTFDrawingObject : public RTFShape
206 public:
207 RTFDrawingObject();
208 css::uno::Reference<css::drawing::XShape> xShape;
209 css::uno::Reference<css::beans::XPropertySet> xPropertySet;
210 std::vector<css::beans::PropertyValue> aPendingProperties;
211 sal_uInt8 nLineColorR = 0;
212 sal_uInt8 nLineColorG = 0;
213 sal_uInt8 nLineColorB = 0;
214 bool bHasLineColor = false;
215 sal_uInt8 nFillColorR = 0;
216 sal_uInt8 nFillColorG = 0;
217 sal_uInt8 nFillColorB = 0;
218 bool bHasFillColor = false;
219 sal_Int32 nDhgt = 0;
220 sal_Int32 nFLine = -1;
221 sal_Int32 nPolyLineCount = 0;
222 std::vector<css::awt::Point> aPolyLinePoints;
223 bool bHadShapeText = false;
226 /// Stores the properties of a picture.
227 class RTFPicture : public virtual SvRefBase
229 public:
230 RTFPicture();
231 sal_Int32 nWidth = 0;
232 sal_Int32 nHeight = 0;
233 sal_Int32 nGoalWidth = 0;
234 sal_Int32 nGoalHeight = 0;
235 sal_uInt16 nScaleX = 100;
236 sal_uInt16 nScaleY = 100;
237 short nCropT = 0;
238 short nCropB = 0;
239 short nCropL = 0;
240 short nCropR = 0;
241 sal_uInt16 eWMetafile = 0;
242 RTFBmpStyle eStyle = RTFBmpStyle::NONE;
245 /// Stores the properties of a frame
246 class RTFFrame
248 private:
249 RTFDocumentImpl* m_pDocumentImpl;
250 sal_Int32 m_nX, m_nY, m_nW, m_nH;
251 sal_Int32 m_nHoriPadding, m_nVertPadding;
252 sal_Int32 m_nHoriAlign, m_nHoriAnchor, m_nVertAlign, m_nVertAnchor;
253 Id m_nHRule;
254 boost::optional<Id> m_oWrap;
256 public:
257 explicit RTFFrame(RTFParserState* pParserState);
259 /// Convert the stored properties to Sprms
260 RTFSprms getSprms();
261 /// Store a property
262 void setSprm(Id nId, Id nValue);
263 bool hasProperties();
264 /// If we got tokens indicating we're in a frame.
265 bool inFrame();
268 /// State of the parser, which gets saved / restored when changing groups.
269 class RTFParserState
271 public:
272 explicit RTFParserState(RTFDocumentImpl* pDocumentImpl);
274 RTFDocumentImpl* m_pDocumentImpl;
275 RTFInternalState nInternalState;
276 Destination eDestination;
277 RTFFieldStatus eFieldStatus;
278 RTFBorderState nBorderState;
279 // font table, stylesheet table
280 RTFSprms aTableSprms;
281 RTFSprms aTableAttributes;
282 // reset by plain
283 RTFSprms aCharacterSprms;
284 RTFSprms aCharacterAttributes;
285 // reset by pard
286 RTFSprms aParagraphSprms;
287 RTFSprms aParagraphAttributes;
288 // reset by sectd
289 RTFSprms aSectionSprms;
290 RTFSprms aSectionAttributes;
291 // reset by trowd
292 RTFSprms aTableRowSprms;
293 RTFSprms aTableRowAttributes;
294 // reset by cellx
295 RTFSprms aTableCellSprms;
296 RTFSprms aTableCellAttributes;
297 // reset by tx
298 RTFSprms aTabAttributes;
300 RTFColorTableEntry aCurrentColor;
302 rtl_TextEncoding nCurrentEncoding;
304 /// Current \uc value.
305 int nUc;
306 /// Characters to skip, set to nUc by \u.
307 int nCharsToSkip;
308 /// Characters to read, once in binary mode.
309 int nBinaryToRead;
311 /// Next list level index to use when parsing list table.
312 int nListLevelNum;
313 /// List level entries, which will form a list entry later.
314 RTFSprms aListLevelEntries;
316 /// List of character positions in leveltext to replace.
317 std::vector<sal_Int32> aLevelNumbers;
318 /// If aLevelNumbers should be read at all.
319 bool bLevelNumbersValid;
321 RTFPicture aPicture;
322 RTFShape aShape;
323 RTFDrawingObject aDrawingObject;
324 RTFFrame aFrame;
326 /// Maps to OOXML's ascii, cs or eastAsia.
327 enum class RunType
329 LOCH,
330 HICH,
331 DBCH
333 RunType eRunType;
334 /// ltrch or rtlch
335 bool isRightToLeft;
337 // Info group.
338 sal_Int16 nYear;
339 sal_uInt16 nMonth;
340 sal_uInt16 nDay;
341 sal_uInt16 nHour;
342 sal_uInt16 nMinute;
344 /// Text from special destinations.
345 OUStringBuffer aDestinationText;
346 /// point to the buffer of the current destination
347 OUStringBuffer* pDestinationText;
349 void appendDestinationText(const OUString& rString)
351 if (pDestinationText)
352 pDestinationText->append(rString);
355 /// Index of the current style.
356 int nCurrentStyleIndex;
357 /// Index of the current character style.
358 int nCurrentCharacterStyleIndex;
359 /// Current listid, points to a listtable entry.
360 int nCurrentListIndex = -1;
361 /// Current ls, points to a listoverridetable entry.
362 int nCurrentListOverrideIndex = -1;
364 /// Points to the active buffer, if there is one.
365 RTFBuffer_t* pCurrentBuffer;
367 /// If we're inside a \listpicture group.
368 bool bInListpicture;
370 /// If we're inside a \background group.
371 bool bInBackground;
373 bool bHadShapeText;
374 bool bInShapeGroup; ///< If we're inside a \shpgrp group.
375 bool bInShape; ///< If we're inside a \shp group.
376 bool bCreatedShapeGroup; ///< A GroupShape was created and pushed to the parent stack.
377 bool bStartedTrackchange; ///< Track change is started, need to end it before popping.
379 /// User-defined property: key name.
380 OUString aPropName;
381 /// User-defined property: value type.
382 css::uno::Type aPropType;
384 /// Width of invisible cell at the end of the row.
385 int nTableRowWidthAfter;
388 /// An RTF stack is similar to std::stack, except that it has an operator[].
389 struct RTFStack
391 private:
392 std::deque<RTFParserState> m_Impl;
394 public:
395 RTFParserState& top()
397 if (m_Impl.empty())
398 throw std::out_of_range("empty rtf state stack");
399 return m_Impl.back();
401 void pop()
403 if (m_Impl.empty())
404 throw std::out_of_range("empty rtf state stack");
405 return m_Impl.pop_back();
407 void push(RTFParserState const& rState) { return m_Impl.push_back(rState); }
408 bool empty() const { return m_Impl.empty(); }
409 size_t size() const { return m_Impl.size(); }
410 const RTFParserState& operator[](size_t nIndex) const { return m_Impl[nIndex]; }
411 RTFParserState& operator[](size_t nIndex) { return m_Impl[nIndex]; }
414 void putBorderProperty(RTFStack& aStates, Id nId, const RTFValue::Pointer_t& pValue);
415 void putNestedSprm(RTFSprms& rSprms, Id nParent, Id nId, const RTFValue::Pointer_t& pValue,
416 RTFOverwrite eOverwrite = RTFOverwrite::NO_APPEND);
417 Id getParagraphBorder(sal_uInt32 nIndex);
418 void putNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId, const RTFValue::Pointer_t& pValue,
419 RTFOverwrite eOverwrite = RTFOverwrite::YES, bool bAttribute = true);
420 bool eraseNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId);
422 /// Looks up the nParent then the nested nId attribute in rSprms.
423 RTFValue::Pointer_t getNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId);
425 /// Looks up the nParent then the nested nId sprm in rSprms.
426 RTFValue::Pointer_t getNestedSprm(RTFSprms& rSprms, Id nParent, Id nId);
428 /// Checks if rName is contained at least once in rProperties as a key.
429 bool findPropertyName(const std::vector<css::beans::PropertyValue>& rProperties,
430 const OUString& rName);
431 RTFSprms& getLastAttributes(RTFSprms& rSprms, Id nId);
432 OString DTTM22OString(long nDTTM);
434 /// Implementation of the RTFDocument interface.
435 class RTFDocumentImpl : public RTFDocument, public RTFListener
437 public:
438 using Pointer_t = tools::SvRef<RTFDocumentImpl>;
439 RTFDocumentImpl(css::uno::Reference<css::uno::XComponentContext> const& xContext,
440 css::uno::Reference<css::io::XInputStream> const& xInputStream,
441 css::uno::Reference<css::lang::XComponent> const& xDstDoc,
442 css::uno::Reference<css::frame::XFrame> const& xFrame,
443 css::uno::Reference<css::task::XStatusIndicator> const& xStatusIndicator,
444 const utl::MediaDescriptor& rMediaDescriptor);
445 ~RTFDocumentImpl() override;
447 // RTFDocument
448 void resolve(Stream& rMapper) override;
450 // RTFListener
451 RTFError dispatchDestination(RTFKeyword nKeyword) override;
452 RTFError dispatchFlag(RTFKeyword nKeyword) override;
453 RTFError dispatchSymbol(RTFKeyword nKeyword) override;
454 RTFError dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam) override;
455 RTFError dispatchValue(RTFKeyword nKeyword, int nParam) override;
456 RTFError resolveChars(char ch) override;
457 RTFError pushState() override;
458 RTFError popState() override;
459 Destination getDestination() override;
460 void setDestination(Destination eDestination) override;
461 RTFInternalState getInternalState() override;
462 void setInternalState(RTFInternalState nInternalState) override;
463 bool getSkipUnknown() override;
464 void setSkipUnknown(bool bSkipUnknown) override;
465 void finishSubstream() override;
466 bool isSubstream() const override;
468 Stream& Mapper() { return *m_pMapperStream; }
469 void setSuperstream(RTFDocumentImpl* pSuperstream);
470 const css::uno::Reference<css::lang::XMultiServiceFactory>& getModelFactory()
472 return m_xModelFactory;
474 bool isInBackground();
475 void setDestinationText(OUString const& rString);
476 /// Resolve a picture: If not inline, then anchored.
477 void resolvePict(bool bInline, css::uno::Reference<css::drawing::XShape> const& rShape);
479 /// If this is the first run of the document, starts the initial paragraph.
480 void checkFirstRun();
481 /// Send NS_ooxml::LN_settings_settings to dmapper.
482 void outputSettingsTable();
483 /// If the initial paragraph is started.
484 bool getFirstRun() { return m_bFirstRun; }
485 /// If we need to add a dummy paragraph before a section break.
486 void setNeedPar(bool bNeedPar);
487 /// Return the dmapper index of an RTF index for fonts.
488 int getFontIndex(int nIndex);
489 /// Return the name of the font, based on a dmapper index.
490 OUString getFontName(int nIndex);
491 /// Return the style name of an RTF style index.
492 OUString getStyleName(int nIndex);
493 /// Return the style type of an RTF style index.
494 Id getStyleType(int nIndex);
495 /// Return the encoding associated with a font index.
496 rtl_TextEncoding getEncoding(int nFontIndex);
497 /// Get the default parser state.
498 RTFParserState& getDefaultState();
499 oox::GraphicHelper& getGraphicHelper();
500 /// Are we inside the stylesheet table?
501 bool isStyleSheetImport();
502 /// Resets m_aStates.top().aFrame.
503 void resetFrame();
504 /// Buffers properties to be sent later.
505 void bufferProperties(RTFBuffer_t& rBuffer, const RTFValue::Pointer_t& pValue,
506 const tools::SvRef<TableRowBuffer>& pTableProperties);
507 /// implement non-obvious RTF specific style inheritance
508 RTFReferenceTable::Entries_t deduplicateStyleTable();
510 private:
511 SvStream& Strm();
512 Color getColorTable(sal_uInt32 nIndex);
513 writerfilter::Reference<Properties>::Pointer_t createStyleProperties();
514 void resetSprms();
515 void resetAttributes();
516 void resolveSubstream(std::size_t nPos, Id nId);
517 void resolveSubstream(std::size_t nPos, Id nId, OUString const& rIgnoreFirst);
519 void text(OUString& rString);
520 // Sends a single character to dmapper, taking care of buffering.
521 void singleChar(sal_uInt8 nValue, bool bRunProps = false);
522 // Sends run properties to dmapper, taking care of buffering.
523 void runProps();
524 void runBreak();
525 void parBreak();
526 void tableBreak();
527 writerfilter::Reference<Properties>::Pointer_t
528 getProperties(RTFSprms& rAttributes, RTFSprms const& rSprms, Id nStyleType);
529 void checkNeedPap();
530 void sectBreak(bool bFinal = false);
531 void prepareProperties(RTFParserState& rState,
532 writerfilter::Reference<Properties>::Pointer_t& o_rpParagraphProperties,
533 writerfilter::Reference<Properties>::Pointer_t& o_rpFrameProperties,
534 writerfilter::Reference<Properties>::Pointer_t& o_rpTableRowProperties,
535 int nCells, int nCurrentCellX);
536 /// Send the passed properties to dmapper.
537 void sendProperties(writerfilter::Reference<Properties>::Pointer_t const& pParagraphProperties,
538 writerfilter::Reference<Properties>::Pointer_t const& pFrameProperties,
539 writerfilter::Reference<Properties>::Pointer_t const& pTableRowProperties);
540 void replayRowBuffer(RTFBuffer_t& rBuffer, ::std::deque<RTFSprms>& rCellsSrpms,
541 ::std::deque<RTFSprms>& rCellsAttributes, int nCells);
542 void replayBuffer(RTFBuffer_t& rBuffer, RTFSprms* pSprms, RTFSprms const* pAttributes);
543 /// If we have some unicode or hex characters to send.
544 void checkUnicode(bool bUnicode, bool bHex);
545 /// If we need a final section break at the end of the document.
546 void setNeedSect(bool bNeedSect);
547 void resetTableRowProperties();
548 void backupTableRowProperties();
549 void restoreTableRowProperties();
550 /// Turns the destination text into an input stream of the current OLE attributes.
551 RTFError handleEmbeddedObject();
553 css::uno::Reference<css::uno::XComponentContext> const& m_xContext;
554 css::uno::Reference<css::io::XInputStream> const& m_xInputStream;
555 css::uno::Reference<css::lang::XComponent> const& m_xDstDoc;
556 css::uno::Reference<css::frame::XFrame> const& m_xFrame;
557 css::uno::Reference<css::task::XStatusIndicator> const& m_xStatusIndicator;
558 css::uno::Reference<css::lang::XMultiServiceFactory> m_xModelFactory;
559 css::uno::Reference<css::document::XDocumentProperties> m_xDocumentProperties;
560 std::shared_ptr<SvStream> m_pInStream;
561 Stream* m_pMapperStream;
562 tools::SvRef<RTFSdrImport> m_pSdrImport;
563 tools::SvRef<RTFTokenizer> m_pTokenizer;
564 RTFStack m_aStates;
565 /// Read by RTF_PARD.
566 RTFParserState m_aDefaultState;
567 bool m_bSkipUnknown;
568 /// Font index <-> encoding map, *not* part of the parser state
569 std::map<int, rtl_TextEncoding> m_aFontEncodings;
570 /// Font index <-> name map.
571 std::map<int, OUString> m_aFontNames;
572 /// Maps the non-continuous font indexes to the continuous dmapper indexes.
573 std::vector<int> m_aFontIndexes;
574 /// Maps style indexes to style names.
575 std::map<int, OUString> m_aStyleNames;
576 /// Maps style indexes to style types.
577 std::map<int, Id> m_aStyleTypes;
578 /// Color index <-> RGB color value map
579 std::vector<Color> m_aColorTable;
580 /// to start initial paragraph / section after font/style tables
581 bool m_bFirstRun;
582 /// except in the case of tables in initial multicolumn section (global for assertion)
583 bool m_bFirstRunException;
584 /// If paragraph properties should be emitted on next run.
585 bool m_bNeedPap;
586 /// If we need to emit a CR at the end of substream.
587 bool m_bNeedCr;
588 /// Original value of m_bNeedCr -- saved/restored before/after textframes.
589 bool m_bNeedCrOrig;
590 bool m_bNeedPar;
591 /// If set, an empty paragraph will be added at the end of the document.
592 bool m_bNeedFinalPar;
593 /// The list table and list override table combined.
594 RTFSprms m_aListTableSprms;
595 /// Maps between listoverridetable and listtable indexes.
596 std::map<int, int> m_aListOverrideTable;
597 /// Maps listtable indexes to listtable entries.
598 std::map<int, RTFValue::Pointer_t> m_aListTable;
599 /// Index of the current list level in a list table entry.
600 int m_nListLevel = -1;
601 /// Maps List level indexes to removed values in the current list entry.
602 std::map<int, int> m_aInvalidListLevelFirstIndents;
603 /// Maps list table indexes to levels (and their removed values).
604 std::map<int, std::map<int, int>> m_aInvalidListTableFirstIndents;
605 /// The settings table attributes.
606 RTFSprms m_aSettingsTableAttributes;
607 /// The settings table sprms.
608 RTFSprms m_aSettingsTableSprms;
610 std::shared_ptr<oox::GraphicHelper> m_pGraphicHelper;
612 /// cell props buffer for nested tables, reset by \nestrow
613 /// the \nesttableprops is a destination and must follow the
614 /// nested cells, so it should be sufficient to store the
615 /// currently active one, no need for a stack of them
616 int m_nNestedCells;
617 std::deque<RTFSprms> m_aNestedTableCellsSprms;
618 std::deque<RTFSprms> m_aNestedTableCellsAttributes;
619 /// cell props buffer for top-level table, reset by \row
620 int m_nTopLevelCells;
621 std::deque<RTFSprms> m_aTopLevelTableCellsSprms;
622 std::deque<RTFSprms> m_aTopLevelTableCellsAttributes;
623 /// backup of top-level props, to support inheriting cell props
624 int m_nInheritingCells;
625 std::deque<RTFSprms> m_aTableInheritingCellsSprms;
626 std::deque<RTFSprms> m_aTableInheritingCellsAttributes;
628 // Left row margin (for nested and top-level rows)
629 int m_nNestedTRLeft;
630 int m_nTopLevelTRLeft;
632 /// Current cellx value (nested table)
633 int m_nNestedCurrentCellX;
634 /// Current cellx value (top-level table)
635 int m_nTopLevelCurrentCellX;
637 // Backup of what \trowd clears, to work around invalid input.
638 RTFSprms m_aBackupTableRowSprms;
639 RTFSprms m_aBackupTableRowAttributes;
640 int m_nBackupTopLevelCurrentCellX;
642 /// Buffered table cells, till cell definitions are not reached.
643 /// for nested table, one buffer per table level
644 std::deque<RTFBuffer_t> m_aTableBufferStack;
645 /// Buffered superscript, till footnote is reached (or not).
646 RTFBuffer_t m_aSuperBuffer;
648 /// Superstream of this substream.
649 RTFDocumentImpl* m_pSuperstream;
650 /// Type of the stream: header, footer, footnote, etc.
651 Id m_nStreamType;
652 std::queue<std::pair<Id, std::size_t>> m_nHeaderFooterPositions;
653 std::size_t m_nGroupStartPos;
654 /// Ignore the first occurrence of this text.
655 OUString m_aIgnoreFirst;
656 /// Bookmark name <-> index map.
657 std::map<OUString, int> m_aBookmarks;
658 /// Revision index <-> author map.
659 std::map<int, OUString> m_aAuthors;
660 /// Annotation author of the next annotation.
661 OUString m_aAuthor;
662 /// Initials of author of the next annotation.
663 OUString m_aAuthorInitials;
665 RTFSprms m_aFormfieldSprms;
666 RTFSprms m_aFormfieldAttributes;
667 RTFFormFieldType m_nFormFieldType;
669 /// OLE attributes are attributes of the ooxml:OLEObject_OLEObject sprm.
670 RTFSprms m_aOLEAttributes;
671 RTFSprms m_aObjectAttributes;
672 /** If we are in an object group and if the we use its
673 * \objdata element.
674 * (if we don't use the \objdata we use the \result element)*/
675 bool m_bObject;
676 /// If the data for a picture is a binary one, it's stored here.
677 std::shared_ptr<SvStream> m_pBinaryData;
679 RTFReferenceTable::Entries_t m_aFontTableEntries;
680 int m_nCurrentFontIndex;
681 /// Used only during font table parsing till we don't know the font name.
682 int m_nCurrentEncoding;
683 /// Raw default font index, use getFont() on it to get a real one.
684 int m_nDefaultFontIndex;
686 RTFReferenceTable::Entries_t m_aStyleTableEntries;
687 int m_nCurrentStyleIndex;
688 bool m_bFormField;
689 /// For the INCLUDEPICTURE field's argument.
690 OUString m_aPicturePath;
691 // Unicode characters are collected here so we don't have to send them one by one.
692 OUStringBuffer m_aUnicodeBuffer;
693 /// Same for hex characters.
694 OStringBuffer m_aHexBuffer;
695 /// Formula import.
696 oox::formulaimport::XmlStreamBuilder m_aMathBuffer;
697 /// Normal text property, that is math italic and math spacing are not applied to the current run.
698 bool m_bMathNor;
699 /// If the next continuous section break should be ignored.
700 bool m_bIgnoreNextContSectBreak;
701 /// clean up a synthetic page break, see RTF_PAGE
702 /// if inactive value is -1, otherwise the RTF_SKB* to restore
703 RTFKeyword m_nResetBreakOnSectBreak;
704 /// If a section break is needed before the end of the doc (false right after a section break).
705 bool m_bNeedSect;
706 /// If aFrame.inFrame() was true in the previous state.
707 bool m_bWasInFrame;
708 /// A picture was seen in the current paragraph.
709 bool m_bHadPicture;
710 /// The document has multiple sections.
711 bool m_bHadSect;
712 /// Max width of the rows in the current table.
713 int m_nCellxMax;
714 /// ID of the next \listlevel picture.
715 int m_nListPictureId;
717 /// New document means not pasting into an existing one.
718 bool const m_bIsNewDoc;
719 /// The media descriptor contains e.g. the base URL of the document.
720 const utl::MediaDescriptor& m_rMediaDescriptor;
722 /// Flags for ensuring that only one header and footer is added per section
723 bool m_hasRHeader;
724 bool m_hasFHeader;
725 bool m_hasRFooter;
726 bool m_hasFFooter;
728 /// Are we after a \cell, but before a \row?
729 bool m_bAfterCellBeforeRow;
731 } // namespace rtftok
732 } // namespace writerfilter
734 #endif // INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFDOCUMENTIMPL_HXX
736 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */