LibreOffice Module sw (master)  1
ww8par2.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_SW_SOURCE_FILTER_WW8_WW8PAR2_HXX
21 #define INCLUDED_SW_SOURCE_FILTER_WW8_WW8PAR2_HXX
22 
23 #include <fmtfsize.hxx>
24 #include <svl/itemset.hxx>
25 #include <svx/swframetypes.hxx>
26 #include <swtable.hxx>
27 
28 #include "ww8scan.hxx"
29 #include "ww8par.hxx"
30 
31 class WW8RStyle;
32 
34 {
35 public:
37  void Insert(const SwPosition &rPos);
38 private:
39  WW8DupProperties(const WW8DupProperties&) = delete;
43 };
44 
46 {
48 
49  // part 1: directly derived Sw attributes
50  sal_Int16 nXPos, nYPos; // Position
51  sal_Int16 nLeMgn, nRiMgn; // borders
52  sal_Int16 nUpMgn, nLoMgn; // borders
53  sal_Int16 nWidth, nHeight; // size
54  sal_Int16 nNetWidth;
55 
56  SwFrameSize eHeightFix; // height fixed or min
57  static constexpr RndStdIds eAnchor = RndStdIds::FLY_AT_PARA; // binding
58  short eHRel; // page or page border
59  short eVRel; // page or page border
60  sal_Int16 eVAlign; // up, down, centered
61  sal_Int16 eHAlign; // left, right, centered
62  css::text::WrapTextMode
63  eSurround; // wrap mode
64 
65  sal_uInt8 nXBind, nYBind; // bound relative to what
66 
67  // part 2: changes found during reading
69  std::unique_ptr<SwPosition> xMainTextPos; // to return to main text after apo
70  sal_uInt16 nLineSpace; // line space in tw for graf apos
71  bool bAutoWidth;
72  bool bToggelPos;
73 
74  // add parameter <nWWPgTop> - WW8's page top margin
75  WW8SwFlyPara( SwPaM& rPaM,
76  SwWW8ImplReader& rIo,
77  WW8FlyPara& rWW,
78  const sal_uInt32 nWWPgTop,
79  const sal_uInt32 nPgWidth,
80  const sal_Int32 nIniFlyDx,
81  const sal_Int32 nIniFlyDy );
82 
83  void BoxUpWidth( long nWidth );
84  std::unique_ptr<SwWW8FltAnchorStack> xOldAnchorStck;
85 };
86 
87 class WW8RStyle: public WW8Style
88 {
89 friend class SwWW8ImplReader;
91  SwWW8ImplReader* mpIo; // parser class
92  SvStream* mpStStrm; // input file
93 
94  SwNumRule* mpStyRule; // bullets and enumerations in styles
95 
96  sal_uInt8* mpParaSprms; // all ParaSprms of the UPX if UPX.Papx
97  sal_uInt16 mnSprmsLen; // its length
98 
99  sal_uInt8 mnWwNumLevel; // for bullets and enumerations in styles
100 
102  bool mbFontChanged; // For Simulating Default-Font
103  bool mbCJKFontChanged; // For Simulating Default-CJK Font
104  bool mbCTLFontChanged; // For Simulating Default-CTL Font
105  bool mbFSizeChanged; // For Simulating Default-FontSize
106  bool mbFCTLSizeChanged; // For Simulating Default-CTL FontSize
107  bool mbWidowsChanged; // For Simulating Default-Widows / Orphans
108 
109  void ImportSprms(std::size_t nPosFc, short nLen, bool bPap);
110  void ImportSprms(sal_uInt8 *pSprms, short nLen, bool bPap);
111  void ImportGrupx(short nLen, bool bPara, bool bOdd);
112  short ImportUPX(short nLen, bool bPAP, bool bOdd);
113 
114  void Set1StyleDefaults();
115  void Import1Style(sal_uInt16 nNr);
116  void RecursiveReg(sal_uInt16 nNr);
117 
118  void ImportNewFormatStyles();
119  void ScanStyles();
120  void ImportOldFormatStyles();
121 
122  bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle);
123  void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp);
124 
125  WW8RStyle(const WW8RStyle&) = delete;
126  WW8RStyle& operator=(const WW8RStyle&) = delete;
127 public:
128  WW8RStyle( WW8Fib& rFib, SwWW8ImplReader* pI );
129  void Import();
130  void PostProcessStyles();
131  SprmResult HasParaSprm(sal_uInt16 nId) const;
132 };
133 
134 class WW8FlySet: public SfxItemSet
135 {
136 private:
137  const WW8FlySet& operator=(const WW8FlySet&) = delete;
138  void Init(const SwWW8ImplReader& rReader, const SwPaM* pPaM);
139 public:
140  WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW,
141  const WW8SwFlyPara* pFS, bool bGraf);
142  WW8FlySet(SwWW8ImplReader& rReader, const SwPaM* pPaM, const WW8_PIC& rPic,
143  long nWidth, long nHeight);
144 };
145 
146 // Gets filled in WW8TabDesc::MergeCells().
147 // Algorithm must ensure proper row and column order in WW8SelBoxInfo!
149 {
150 private:
151  std::vector<std::vector<SwTableBox*> > m_vRows;
152 
153  WW8SelBoxInfo(WW8SelBoxInfo const&) = delete;
154  WW8SelBoxInfo& operator=(WW8SelBoxInfo const&) = delete;
155 
156 public:
158  short nGroupWidth;
160 
161  WW8SelBoxInfo(short nXCenter, short nWidth)
162  : nGroupXStart( nXCenter ), nGroupWidth( nWidth ), bGroupLocked(false)
163  {}
164 
165  size_t size() const
166  {
167  size_t nResult = 0;
168  for (auto& it : m_vRows)
169  nResult += it.size();
170  return nResult;
171  }
172 
173  size_t rowsCount() const { return m_vRows.size(); }
174 
175  const std::vector<SwTableBox*>& row( size_t nIndex ) { return m_vRows[nIndex]; }
176 
177  void push_back( SwTableBox* pBox )
178  {
179  bool bDone = false;
180  for (auto& iRow : m_vRows)
181  if (iRow[0]->GetUpper() == pBox->GetUpper())
182  {
183  iRow.push_back(pBox);
184  bDone = true;
185  break;
186  }
187  if (!bDone)
188  {
189  const size_t sz = m_vRows.size();
190  m_vRows.resize(sz+1);
191  m_vRows[sz].push_back(pBox);
192  }
193  }
194 };
195 
197 {
198  std::vector<OUString> m_aNumRuleNames;
199  std::unique_ptr<sw::util::RedlineStack> mxOldRedlineStack;
200 
202 
205 
206  std::unique_ptr<SwPosition> m_xTmpPos;
207 
208  SwTableNode* m_pTableNd; // table node
209  const SwTableLines* m_pTabLines; // row array of node
210  SwTableLine* m_pTabLine; // current row
211  SwTableBoxes* m_pTabBoxes; // boxes array in current row
212  SwTableBox* m_pTabBox; // current cell
213 
214  std::vector<std::unique_ptr<WW8SelBoxInfo>> m_MergeGroups; // list of all cells to be merged
215 
217 
218  short m_nRows;
220  short m_nBands;
221  short m_nMinLeft;
223  short m_nMaxRight;
224  short m_nSwWidth;
227 
228  bool m_bOk;
230  sal_Int16 m_eOri;
231  bool m_bIsBiDi;
232  // 2. common admin info
234  short m_nCurrentBandRow; // SW: row of current band
235  // 3. admin info for writer
237 
238  sal_uInt16 m_nRowsToRepeat;
239 
240  // 4. methods
241 
242  sal_uInt16 GetLogicalWWCol() const;
243  void SetTabBorders( SwTableBox* pBox, short nIdx );
244  void SetTabShades( SwTableBox* pBox, short nWwIdx );
245  void SetTabVertAlign( SwTableBox* pBox, short nWwIdx );
246  void SetTabDirection( SwTableBox* pBox, short nWwIdx );
247  void CalcDefaults();
248  void SetPamInCell(short nWwCol, bool bPam);
249  void InsertCells( short nIns );
250  void AdjustNewBand();
251 
252  WW8SelBoxInfo* FindMergeGroup(short nX1, short nWidth, bool bExact);
253 
254  // single box - maybe used in a merge group
255  // (the merge groups are processed later at once)
256  void UpdateTableMergeGroup(WW8_TCell const & rCell,
257  WW8SelBoxInfo* pActGroup, SwTableBox* pActBox, sal_uInt16 nCol );
258 
259  WW8TabDesc(WW8TabDesc const&) = delete;
260  WW8TabDesc& operator=(WW8TabDesc const&) = delete;
261 
262 public:
263  const SwTable* m_pTable; // table
267  bool IsValidCell(short nCol) const;
268  bool InFirstParaInCell() const;
269 
270  WW8TabDesc( SwWW8ImplReader* pIoClass, WW8_CP nStartCp );
271  bool Ok() const { return m_bOk; }
272  void CreateSwTable();
273  void UseSwTable();
274  void SetSizePosition(SwFrameFormat* pFrameFormat);
275  void TableCellEnd();
276  void MoveOutsideTable();
277  void ParkPaM();
278  void FinishSwTable();
279  void MergeCells();
280  short GetMinLeft() const { return m_nConvertedLeft; }
281  ~WW8TabDesc();
282 
283  const WW8_TCell* GetCurrentWWCell() const { return m_pCurrentWWCell; }
284  short GetCurrentCol() const { return m_nCurrentCol; }
285  // find name of numrule valid for current WW-COL
286  OUString GetNumRuleName() const;
287  void SetNumRuleName( const OUString& rName );
288 
289  sw::util::RedlineStack* getOldRedlineStack() { return mxOldRedlineStack.get(); }
290 };
291 
293 
294 WW8LvlType GetNumType(sal_uInt8 nWwLevelNo);
295 #endif
296 
297 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static constexpr RndStdIds eAnchor
Definition: ww8par2.hxx:57
Marks a position in the document model.
Definition: pam.hxx:35
short m_nPreferredWidth
Definition: ww8par2.hxx:225
short m_nCurrentBandRow
Definition: ww8par2.hxx:234
sal_Int16 nYPos
Definition: ww8par2.hxx:50
void SetTabBorders(SwTableBox *pBox, short nIdx)
Definition: ww8par2.cxx:3006
void CalcDefaults()
Definition: ww8par2.cxx:2125
void MergeCells()
Definition: ww8par2.cxx:2569
sw::util::RedlineStack * getOldRedlineStack()
Definition: ww8par2.hxx:289
void Init(const SwWW8ImplReader &rReader, const SwPaM *pPaM)
Definition: ww8par6.cxx:2213
sal_uInt16 mnSprmsLen
Definition: ww8par2.hxx:97
Definition: doc.hxx:185
css::text::WrapTextMode eSurround
Definition: ww8par2.hxx:63
std::unique_ptr< sw::util::RedlineStack > mxOldRedlineStack
Definition: ww8par2.hxx:199
SfxItemSet aChrSet
Definition: ww8par2.hxx:42
WW8SelBoxInfo & operator=(WW8SelBoxInfo const &)=delete
SwFlyFrameFormat * m_pFlyFormat
Definition: ww8par2.hxx:265
WW8RStyle & operator=(const WW8RStyle &)=delete
void SetTabShades(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3061
SwTableLine is one table row in the document model.
Definition: swtable.hxx:344
WW8LvlType
Definition: ww8par2.hxx:292
WW8SwFlyPara(SwPaM &rPaM, SwWW8ImplReader &rIo, WW8FlyPara &rWW, const sal_uInt32 nWWPgTop, const sal_uInt32 nPgWidth, const sal_Int32 nIniFlyDx, const sal_Int32 nIniFlyDy)
Definition: ww8par6.cxx:1861
sal_uInt8 nYBind
Definition: ww8par2.hxx:65
bool Ok() const
Definition: ww8par2.hxx:271
SwWW8FltControlStack * pCtrlStck
Definition: ww8par2.hxx:41
void SetTabDirection(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3114
WW8TabBandDesc * m_pActBand
Definition: ww8par2.hxx:204
bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle)
Definition: ww8par2.cxx:3785
void ImportOldFormatStyles()
Definition: ww8par2.cxx:4258
sal_Int16 eHAlign
Definition: ww8par2.hxx:61
sal_Int16 nLeMgn
Definition: ww8par2.hxx:51
WW8TabBandDesc * m_pFirstBand
Definition: ww8par2.hxx:203
const SwTableLines * m_pTabLines
Definition: ww8par2.hxx:209
WW8TabDesc & operator=(WW8TabDesc const &)=delete
const SwTable * m_pTable
Definition: ww8par2.hxx:263
short m_nMaxRight
Definition: ww8par2.hxx:223
short GetCurrentCol() const
Definition: ww8par2.hxx:284
SwFlyFrameFormat * pFlyFormat
Definition: ww8par2.hxx:47
WW8TabDesc(WW8TabDesc const &)=delete
void SetPamInCell(short nWwCol, bool bPam)
Definition: ww8par2.cxx:2888
SvStream * mpStStrm
Definition: ww8par2.hxx:92
bool mbCJKFontChanged
Definition: ww8par2.hxx:103
std::vector< std::vector< SwTableBox * > > m_vRows
Definition: ww8par2.hxx:151
SfxItemSet aParSet
Definition: ww8par2.hxx:42
sal_Int16 nHeight
Definition: ww8par2.hxx:53
short m_nBands
Definition: ww8par2.hxx:220
void Insert(const SwPosition &rPos)
Definition: ww8par6.cxx:2257
SwTableBoxes * m_pTabBoxes
Definition: ww8par2.hxx:211
void Import()
Definition: ww8par2.cxx:4474
void MoveOutsideTable()
Definition: ww8par2.cxx:2740
std::unique_ptr< SwWW8FltAnchorStack > xOldAnchorStck
Definition: ww8par2.hxx:84
bool IsValidCell(short nCol) const
Definition: ww8par2.cxx:2866
sal_uInt16 nLineSpace
Definition: ww8par2.hxx:70
void ImportGrupx(short nLen, bool bPara, bool bOdd)
Definition: ww8par2.cxx:3707
short nGroupXStart
Definition: ww8par2.hxx:157
short m_nConvertedLeft
Definition: ww8par2.hxx:222
sal_Int16 nRiMgn
Definition: ww8par2.hxx:51
WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStack)
Definition: ww8par6.cxx:2231
bool m_bIsBiDi
Definition: ww8par2.hxx:231
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
SwFrameSize eHeightFix
Definition: ww8par2.hxx:56
void AdjustNewBand()
Definition: ww8par2.cxx:3150
void ImportNewFormatStyles()
Definition: ww8par2.cxx:4465
Style of a layout element.
Definition: frmfmt.hxx:57
void UpdateTableMergeGroup(WW8_TCell const &rCell, WW8SelBoxInfo *pActGroup, SwTableBox *pActBox, sal_uInt16 nCol)
Definition: ww8par2.cxx:3309
void SetNumRuleName(const OUString &rName)
Definition: ww8par2.cxx:3367
sal_uInt8 * mpParaSprms
Definition: ww8par2.hxx:96
short m_nRows
Definition: ww8par2.hxx:218
bool mbFSizeChanged
Definition: ww8par2.hxx:105
sal_Int16 nWidth
Definition: ww8par2.hxx:53
void FinishSwTable()
Definition: ww8par2.cxx:2747
short m_nDefaultSwCols
Definition: ww8par2.hxx:219
short m_nPercentWidth
Definition: ww8par2.hxx:226
sal_uInt8 nXBind
Definition: ww8par2.hxx:65
WW8SelBoxInfo(WW8SelBoxInfo const &)=delete
sal_uInt16 GetLogicalWWCol() const
Definition: ww8par2.cxx:3344
short nGroupWidth
Definition: ww8par2.hxx:158
void CreateSwTable()
Definition: ww8par2.cxx:2388
sti
Definition: wwstyles.hxx:27
SwFrameSize
Definition: fmtfsize.hxx:35
bool bToggelPos
Definition: ww8par2.hxx:72
const WW8FlySet & operator=(const WW8FlySet &)=delete
SwWW8ImplReader * m_pIo
Definition: ww8par2.hxx:201
SwTableLine * m_pTabLine
Definition: ww8par2.hxx:210
std::unique_ptr< SwPosition > m_xTmpPos
Definition: ww8par2.hxx:206
sal_Int16 m_eOri
Definition: ww8par2.hxx:230
size_t rowsCount() const
Definition: ww8par2.hxx:173
bool mbTextColChanged
Definition: ww8par2.hxx:101
WW8SelBoxInfo(short nXCenter, short nWidth)
Definition: ww8par2.hxx:161
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:110
size_t size() const
Definition: ww8par2.hxx:165
bool mbFontChanged
Definition: ww8par2.hxx:102
std::vector< std::unique_ptr< WW8SelBoxInfo > > m_MergeGroups
Definition: ww8par2.hxx:214
void ScanStyles()
Definition: ww8par2.cxx:3999
std::vector< OUString > m_aNumRuleNames
Definition: ww8par2.hxx:198
sal_Int32 WW8_CP
Definition: ww8struc.hxx:153
bool mbCTLFontChanged
Definition: ww8par2.hxx:104
std::unique_ptr< SwPosition > xMainTextPos
Definition: ww8par2.hxx:69
bool bGroupLocked
Definition: ww8par2.hxx:159
wwSprmParser maSprmParser
Definition: ww8par2.hxx:90
SprmResult HasParaSprm(sal_uInt16 nId) const
Definition: ww8par2.cxx:3597
bool bAutoWidth
Definition: ww8par2.hxx:71
short ImportUPX(short nLen, bool bPAP, bool bOdd)
Definition: ww8par2.cxx:3663
std::vector< SwTableBox * > SwTableBoxes
Definition: swtable.hxx:103
bool m_bClaimLineFormat
Definition: ww8par2.hxx:229
SwTableNode * m_pTableNd
Definition: ww8par2.hxx:208
const std::vector< SwTableBox * > & row(size_t nIndex)
Definition: ww8par2.hxx:175
bool InFirstParaInCell() const
Definition: ww8par2.cxx:2873
unsigned char sal_uInt8
sal_Int16 eVAlign
Definition: ww8par2.hxx:60
short m_nSwWidth
Definition: ww8par2.hxx:224
SwNumRule * mpStyRule
Definition: ww8par2.hxx:94
short GetMinLeft() const
Definition: ww8par2.hxx:280
SfxItemSet m_aItemSet
Definition: ww8par2.hxx:266
wwSprmParser knows how to take a sequence of bytes and split it up into sprms and their arguments ...
Definition: ww8scan.hxx:113
WW8_TCell * m_pCurrentWWCell
Definition: ww8par2.hxx:216
sal_Int16 nXPos
Definition: ww8par2.hxx:50
bool m_bOk
Definition: ww8par2.hxx:228
SwTableBox * m_pTabBox
Definition: ww8par2.hxx:212
void TableCellEnd()
Definition: ww8par2.cxx:3255
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
FIB - the File Information Block.
Definition: ww8scan.hxx:1096
WW8LvlType GetNumType(sal_uInt8 nWwLevelNo)
Definition: ww8par2.cxx:874
void ParkPaM()
Definition: ww8par2.cxx:2705
sal_uInt16 m_nRowsToRepeat
Definition: ww8par2.hxx:238
bool mbFCTLSizeChanged
Definition: ww8par2.hxx:106
sal_Int16 nUpMgn
Definition: ww8par2.hxx:52
SwPosition * m_pParentPos
Definition: ww8par2.hxx:264
void Import1Style(sal_uInt16 nNr)
Definition: ww8par2.cxx:3891
void SetTabVertAlign(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3122
long nNewNetWidth
Definition: ww8par2.hxx:68
void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp)
Definition: ww8par2.cxx:3867
void ImportSprms(std::size_t nPosFc, short nLen, bool bPap)
Definition: ww8par2.cxx:3630
OUString GetNumRuleName() const
Definition: ww8par2.cxx:3359
RndStdIds
sal_uInt8 mnWwNumLevel
Definition: ww8par2.hxx:99
SwWW8ImplReader * mpIo
Definition: ww8par2.hxx:91
void BoxUpWidth(long nWidth)
Definition: ww8par6.cxx:2115
void SetSizePosition(SwFrameFormat *pFrameFormat)
Definition: ww8par2.cxx:2362
short eHRel
Definition: ww8par2.hxx:58
const WW8_TCell * GetCurrentWWCell() const
Definition: ww8par2.hxx:283
void RecursiveReg(sal_uInt16 nNr)
Definition: ww8par2.cxx:3946
short m_nMinLeft
Definition: ww8par2.hxx:221
sal_Int16 nLoMgn
Definition: ww8par2.hxx:52
void PostProcessStyles()
Definition: ww8par2.cxx:3969
void UseSwTable()
Definition: ww8par2.cxx:2540
SwTableLine * GetUpper()
Definition: swtable.hxx:421
void Set1StyleDefaults()
Definition: ww8par2.cxx:3741
short eVRel
Definition: ww8par2.hxx:59
bool mbWidowsChanged
Definition: ww8par2.hxx:107
short m_nCurrentCol
Definition: ww8par2.hxx:236
void push_back(SwTableBox *pBox)
Definition: ww8par2.hxx:177
WW8SelBoxInfo * FindMergeGroup(short nX1, short nWidth, bool bExact)
Definition: ww8par2.cxx:2813
short m_nCurrentRow
Definition: ww8par2.hxx:233
WW8FlySet(SwWW8ImplReader &rReader, const WW8FlyPara *pFW, const WW8SwFlyPara *pFS, bool bGraf)
Definition: ww8par6.cxx:2124
WW8DupProperties & operator=(const WW8DupProperties &)=delete
void InsertCells(short nIns)
Definition: ww8par2.cxx:2994
WW8RStyle(const WW8RStyle &)=delete
sal_Int16 nNetWidth
Definition: ww8par2.hxx:54