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 {
47 private:
48  std::unique_ptr<FrameDeleteWatch> m_xFlyFormat;
49 public:
50  // part 1: directly derived Sw attributes
51  sal_Int16 nXPos, nYPos; // Position
52  sal_Int16 nLeMgn, nRiMgn; // borders
53  sal_Int16 nUpMgn, nLoMgn; // borders
54  sal_Int16 nWidth, nHeight; // size
55  sal_Int16 nNetWidth;
56 
57  SwFrameSize eHeightFix; // height fixed or min
58  static constexpr RndStdIds eAnchor = RndStdIds::FLY_AT_PARA; // binding
59  short eHRel; // page or page border
60  short eVRel; // page or page border
61  sal_Int16 eVAlign; // up, down, centered
62  sal_Int16 eHAlign; // left, right, centered
63  css::text::WrapTextMode
64  eSurround; // wrap mode
65 
66  sal_uInt8 nXBind, nYBind; // bound relative to what
67 
68  // part 2: changes found during reading
70  std::shared_ptr<SwUnoCursor> xMainTextPos; // to return to main text after apo
71  sal_uInt16 nLineSpace; // line space in tw for graf apos
72  bool bAutoWidth;
73  bool bTogglePos;
74 
75  // add parameter <nWWPgTop> - WW8's page top margin
76  WW8SwFlyPara( SwPaM& rPaM,
77  SwWW8ImplReader& rIo,
78  WW8FlyPara& rWW,
79  const sal_uInt32 nWWPgTop,
80  const sal_uInt32 nPgWidth,
81  const sal_Int32 nIniFlyDx,
82  const sal_Int32 nIniFlyDy );
83 
84  void BoxUpWidth( tools::Long nWidth );
86  void SetFlyFormat(SwFlyFrameFormat* pNewFlyFormat);
87 
88  std::unique_ptr<SwWW8FltAnchorStack> xOldAnchorStck;
89 };
90 
91 class WW8RStyle: public WW8Style
92 {
93 friend class SwWW8ImplReader;
95  SwWW8ImplReader* mpIo; // parser class
96  SvStream* mpStStrm; // input file
97 
98  SwNumRule* mpStyRule; // bullets and enumerations in styles
99 
100  sal_uInt8* mpParaSprms; // all ParaSprms of the UPX if UPX.Papx
101  sal_uInt16 mnSprmsLen; // its length
102 
103  sal_uInt8 mnWwNumLevel; // for bullets and enumerations in styles
104 
106  bool mbFontChanged; // For Simulating Default-Font
107  bool mbCJKFontChanged; // For Simulating Default-CJK Font
108  bool mbCTLFontChanged; // For Simulating Default-CTL Font
109  bool mbFSizeChanged; // For Simulating Default-FontSize
110  bool mbFCTLSizeChanged; // For Simulating Default-CTL FontSize
111  bool mbWidowsChanged; // For Simulating Default-Widows / Orphans
112  bool mbBidiChanged; // For Simulating Default-LTR
113 
114  void ImportSprms(std::size_t nPosFc, short nLen, bool bPap);
115  void ImportSprms(sal_uInt8 *pSprms, short nLen, bool bPap);
116  void ImportGrupx(short nLen, bool bPara, bool bOdd);
117  short ImportUPX(short nLen, bool bPAP, bool bOdd);
118 
119  void Set1StyleDefaults();
120  void Import1Style(sal_uInt16 nNr);
121  void RecursiveReg(sal_uInt16 nNr);
122 
123  void ImportNewFormatStyles();
124  void ScanStyles();
125  void ImportOldFormatStyles();
126 
127  bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle);
128  void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp);
129 
130  WW8RStyle(const WW8RStyle&) = delete;
131  WW8RStyle& operator=(const WW8RStyle&) = delete;
132 public:
133  WW8RStyle( WW8Fib& rFib, SwWW8ImplReader* pI );
134  void Import();
135  void PostProcessStyles();
136  SprmResult HasParaSprm(sal_uInt16 nId) const;
137 };
138 
139 class WW8FlySet: public SfxItemSetFixed<RES_FRMATR_BEGIN,RES_FRMATR_END-1>
140 {
141 private:
142  const WW8FlySet& operator=(const WW8FlySet&) = delete;
143  void Init(const SwWW8ImplReader& rReader, const SwPaM* pPaM);
144 public:
145  WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW,
146  const WW8SwFlyPara* pFS, bool bGraf);
147  WW8FlySet(SwWW8ImplReader& rReader, const SwPaM* pPaM, const WW8_PIC& rPic,
148  tools::Long nWidth, tools::Long nHeight);
149 };
150 
151 // Gets filled in WW8TabDesc::MergeCells().
152 // Algorithm must ensure proper row and column order in WW8SelBoxInfo!
154 {
155 private:
156  std::vector<std::vector<SwTableBox*> > m_vRows;
157 
158  WW8SelBoxInfo(WW8SelBoxInfo const&) = delete;
159  WW8SelBoxInfo& operator=(WW8SelBoxInfo const&) = delete;
160 
161 public:
163  short nGroupWidth;
165 
166  WW8SelBoxInfo(short nXCenter, short nWidth)
167  : nGroupXStart( nXCenter ), nGroupWidth( nWidth ), bGroupLocked(false)
168  {}
169 
170  size_t size() const
171  {
172  size_t nResult = 0;
173  for (auto& it : m_vRows)
174  nResult += it.size();
175  return nResult;
176  }
177 
178  size_t rowsCount() const { return m_vRows.size(); }
179 
180  const std::vector<SwTableBox*>& row( size_t nIndex ) { return m_vRows[nIndex]; }
181 
182  void push_back( SwTableBox* pBox )
183  {
184  bool bDone = false;
185  for (auto& iRow : m_vRows)
186  if (iRow[0]->GetUpper() == pBox->GetUpper())
187  {
188  iRow.push_back(pBox);
189  bDone = true;
190  break;
191  }
192  if (!bDone)
193  {
194  const size_t sz = m_vRows.size();
195  m_vRows.resize(sz+1);
196  m_vRows[sz].push_back(pBox);
197  }
198  }
199 };
200 
202 {
203  std::vector<OUString> m_aNumRuleNames;
204  std::unique_ptr<sw::util::RedlineStack> mxOldRedlineStack;
205 
207 
210 
211  std::shared_ptr<SwUnoCursor> m_xTmpPos;
212 
213  SwTableNode* m_pTableNd; // table node
214  const SwTableLines* m_pTabLines; // row array of node
215  SwTableLine* m_pTabLine; // current row
216  SwTableBoxes* m_pTabBoxes; // boxes array in current row
217  SwTableBox* m_pTabBox; // current cell
218 
219  std::vector<std::unique_ptr<WW8SelBoxInfo>> m_MergeGroups; // list of all cells to be merged
220 
222 
223  short m_nRows;
225  short m_nBands;
226  short m_nMinLeft;
227  short m_nMaxRight;
228  short m_nSwWidth;
231 
232  bool m_bOk;
234  sal_Int16 m_eOri;
235  bool m_bIsBiDi;
236  // 2. common admin info
238  short m_nCurrentBandRow; // SW: row of current band
239  // 3. admin info for writer
241 
242  sal_uInt16 m_nRowsToRepeat;
243 
244  // 4. methods
245 
246  sal_uInt16 GetLogicalWWCol() const;
247  void SetTabBorders( SwTableBox* pBox, short nIdx );
248  void SetTabShades( SwTableBox* pBox, short nWwIdx );
249  void SetTabVertAlign( SwTableBox* pBox, short nWwIdx );
250  void SetTabDirection( SwTableBox* pBox, short nWwIdx );
251  void CalcDefaults();
252  void SetPamInCell(short nWwCol, bool bPam);
253  void InsertCells( short nIns );
254  void AdjustNewBand();
255 
256  WW8SelBoxInfo* FindMergeGroup(short nX1, short nWidth, bool bExact);
257 
258  // single box - maybe used in a merge group
259  // (the merge groups are processed later at once)
260  void UpdateTableMergeGroup(WW8_TCell const & rCell,
261  WW8SelBoxInfo* pActGroup, SwTableBox* pActBox, sal_uInt16 nCol );
262 
263  WW8TabDesc(WW8TabDesc const&) = delete;
264  WW8TabDesc& operator=(WW8TabDesc const&) = delete;
265 
266 public:
267  const SwTable* m_pTable; // table
271  bool IsValidCell(short nCol) const;
272  bool InFirstParaInCell() const;
273 
274  WW8TabDesc( SwWW8ImplReader* pIoClass, WW8_CP nStartCp );
275  bool Ok() const { return m_bOk; }
276  void CreateSwTable();
277  void UseSwTable();
278  void SetSizePosition(SwFrameFormat* pFrameFormat);
279  void TableCellEnd();
280  void MoveOutsideTable();
281  void ParkPaM();
282  void FinishSwTable();
283  void MergeCells();
284  short GetMinLeft() const { return m_nMinLeft; }
285  ~WW8TabDesc();
286 
287  const WW8_TCell* GetCurrentWWCell() const { return m_pCurrentWWCell; }
288  short GetCurrentCol() const { return m_nCurrentCol; }
289  // find name of numrule valid for current WW-COL
290  OUString GetNumRuleName() const;
291  void SetNumRuleName( const OUString& rName );
292 
293  sw::util::RedlineStack* getOldRedlineStack() { return mxOldRedlineStack.get(); }
294 };
295 
297 
298 WW8LvlType GetNumType(sal_uInt8 nWwLevelNo);
299 #endif
300 
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool bTogglePos
Definition: ww8par2.hxx:73
std::shared_ptr< SwUnoCursor > xMainTextPos
Definition: ww8par2.hxx:70
static constexpr RndStdIds eAnchor
Definition: ww8par2.hxx:58
Marks a position in the document model.
Definition: pam.hxx:36
short m_nPreferredWidth
Definition: ww8par2.hxx:229
short m_nCurrentBandRow
Definition: ww8par2.hxx:238
sal_Int16 nYPos
Definition: ww8par2.hxx:51
void SetTabBorders(SwTableBox *pBox, short nIdx)
Definition: ww8par2.cxx:3030
void CalcDefaults()
Definition: ww8par2.cxx:2149
bool mbBidiChanged
Definition: ww8par2.hxx:112
void MergeCells()
Definition: ww8par2.cxx:2579
sw::util::RedlineStack * getOldRedlineStack()
Definition: ww8par2.hxx:293
void Init(const SwWW8ImplReader &rReader, const SwPaM *pPaM)
Definition: ww8par6.cxx:2258
long Long
sal_uInt16 mnSprmsLen
Definition: ww8par2.hxx:101
Definition: doc.hxx:187
css::text::WrapTextMode eSurround
Definition: ww8par2.hxx:64
std::unique_ptr< sw::util::RedlineStack > mxOldRedlineStack
Definition: ww8par2.hxx:204
WW8SelBoxInfo & operator=(WW8SelBoxInfo const &)=delete
SwFlyFrameFormat * m_pFlyFormat
Definition: ww8par2.hxx:269
WW8RStyle & operator=(const WW8RStyle &)=delete
void SetTabShades(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3085
SwTableLine is one table row in the document model.
Definition: swtable.hxx:357
WW8LvlType
Definition: ww8par2.hxx:296
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:1892
tools::Long nNewNetWidth
Definition: ww8par2.hxx:69
SfxItemSetFixed< RES_CHRATR_BEGIN, RES_CHRATR_END-1 > aChrSet
Definition: ww8par2.hxx:42
sal_uInt8 nYBind
Definition: ww8par2.hxx:66
bool Ok() const
Definition: ww8par2.hxx:275
SwWW8FltControlStack * pCtrlStck
Definition: ww8par2.hxx:41
void SetTabDirection(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3138
WW8TabBandDesc * m_pActBand
Definition: ww8par2.hxx:209
bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle)
Definition: ww8par2.cxx:3802
void SetFlyFormat(SwFlyFrameFormat *pNewFlyFormat)
Definition: ww8par6.cxx:2158
void ImportOldFormatStyles()
Definition: ww8par2.cxx:4302
sal_Int16 eHAlign
Definition: ww8par2.hxx:62
sal_Int16 nLeMgn
Definition: ww8par2.hxx:52
WW8TabBandDesc * m_pFirstBand
Definition: ww8par2.hxx:208
const SwTableLines * m_pTabLines
Definition: ww8par2.hxx:214
WW8TabDesc & operator=(WW8TabDesc const &)=delete
const SwTable * m_pTable
Definition: ww8par2.hxx:267
short m_nMaxRight
Definition: ww8par2.hxx:227
SwFlyFrameFormat * GetFlyFormat() const
Definition: ww8par6.cxx:2151
short GetCurrentCol() const
Definition: ww8par2.hxx:288
WW8TabDesc(WW8TabDesc const &)=delete
void SetPamInCell(short nWwCol, bool bPam)
Definition: ww8par2.cxx:2911
SfxItemSetFixed< RES_CHRATR_BEGIN, RES_CHRATR_END-1 > aParSet
Definition: ww8par2.hxx:42
SvStream * mpStStrm
Definition: ww8par2.hxx:96
bool mbCJKFontChanged
Definition: ww8par2.hxx:107
std::vector< std::vector< SwTableBox * > > m_vRows
Definition: ww8par2.hxx:156
sal_Int16 nHeight
Definition: ww8par2.hxx:54
short m_nBands
Definition: ww8par2.hxx:225
void Insert(const SwPosition &rPos)
Definition: ww8par6.cxx:2302
SwTableBoxes * m_pTabBoxes
Definition: ww8par2.hxx:216
void Import()
Definition: ww8par2.cxx:4518
void MoveOutsideTable()
Definition: ww8par2.cxx:2750
std::unique_ptr< SwWW8FltAnchorStack > xOldAnchorStck
Definition: ww8par2.hxx:88
bool IsValidCell(short nCol) const
Definition: ww8par2.cxx:2889
sal_uInt16 nLineSpace
Definition: ww8par2.hxx:71
void ImportGrupx(short nLen, bool bPara, bool bOdd)
Definition: ww8par2.cxx:3715
short nGroupXStart
Definition: ww8par2.hxx:162
sal_Int16 nRiMgn
Definition: ww8par2.hxx:52
WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStack)
Definition: ww8par6.cxx:2276
bool m_bIsBiDi
Definition: ww8par2.hxx:235
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
SwFrameSize eHeightFix
Definition: ww8par2.hxx:57
void AdjustNewBand()
Definition: ww8par2.cxx:3174
void ImportNewFormatStyles()
Definition: ww8par2.cxx:4509
Style of a layout element.
Definition: frmfmt.hxx:59
void UpdateTableMergeGroup(WW8_TCell const &rCell, WW8SelBoxInfo *pActGroup, SwTableBox *pActBox, sal_uInt16 nCol)
Definition: ww8par2.cxx:3319
void SetNumRuleName(const OUString &rName)
Definition: ww8par2.cxx:3377
sal_uInt8 * mpParaSprms
Definition: ww8par2.hxx:100
short m_nRows
Definition: ww8par2.hxx:223
bool mbFSizeChanged
Definition: ww8par2.hxx:109
sal_Int16 nWidth
Definition: ww8par2.hxx:54
void FinishSwTable()
Definition: ww8par2.cxx:2757
short m_nDefaultSwCols
Definition: ww8par2.hxx:224
short m_nPercentWidth
Definition: ww8par2.hxx:230
sal_uInt8 nXBind
Definition: ww8par2.hxx:66
WW8SelBoxInfo(WW8SelBoxInfo const &)=delete
sal_uInt16 GetLogicalWWCol() const
Definition: ww8par2.cxx:3354
short nGroupWidth
Definition: ww8par2.hxx:163
void CreateSwTable()
Definition: ww8par2.cxx:2371
SwFrameSize
Definition: fmtfsize.hxx:35
const WW8FlySet & operator=(const WW8FlySet &)=delete
SwWW8ImplReader * m_pIo
Definition: ww8par2.hxx:206
SwTableLine * m_pTabLine
Definition: ww8par2.hxx:215
sal_Int16 m_eOri
Definition: ww8par2.hxx:234
size_t rowsCount() const
Definition: ww8par2.hxx:178
bool mbTextColChanged
Definition: ww8par2.hxx:105
WW8SelBoxInfo(short nXCenter, short nWidth)
Definition: ww8par2.hxx:166
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:112
size_t size() const
Definition: ww8par2.hxx:170
bool mbFontChanged
Definition: ww8par2.hxx:106
std::vector< std::unique_ptr< WW8SelBoxInfo > > m_MergeGroups
Definition: ww8par2.hxx:219
void ScanStyles()
Definition: ww8par2.cxx:4016
std::vector< OUString > m_aNumRuleNames
Definition: ww8par2.hxx:203
sal_Int32 WW8_CP
Definition: ww8struc.hxx:153
bool mbCTLFontChanged
Definition: ww8par2.hxx:108
bool bGroupLocked
Definition: ww8par2.hxx:164
wwSprmParser maSprmParser
Definition: ww8par2.hxx:94
SprmResult HasParaSprm(sal_uInt16 nId) const
Definition: ww8par2.cxx:3605
bool bAutoWidth
Definition: ww8par2.hxx:72
short ImportUPX(short nLen, bool bPAP, bool bOdd)
Definition: ww8par2.cxx:3671
std::vector< SwTableBox * > SwTableBoxes
Definition: swtable.hxx:105
bool m_bClaimLineFormat
Definition: ww8par2.hxx:233
SwTableNode * m_pTableNd
Definition: ww8par2.hxx:213
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
const std::vector< SwTableBox * > & row(size_t nIndex)
Definition: ww8par2.hxx:180
bool InFirstParaInCell() const
Definition: ww8par2.cxx:2896
void BoxUpWidth(tools::Long nWidth)
Definition: ww8par6.cxx:2145
unsigned char sal_uInt8
sal_Int16 eVAlign
Definition: ww8par2.hxx:61
short m_nSwWidth
Definition: ww8par2.hxx:228
SwNumRule * mpStyRule
Definition: ww8par2.hxx:98
short GetMinLeft() const
Definition: ww8par2.hxx:284
SfxItemSet m_aItemSet
Definition: ww8par2.hxx:270
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:221
sal_Int16 nXPos
Definition: ww8par2.hxx:51
bool m_bOk
Definition: ww8par2.hxx:232
SwTableBox * m_pTabBox
Definition: ww8par2.hxx:217
void TableCellEnd()
Definition: ww8par2.cxx:3265
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:418
FIB - the File Information Block.
Definition: ww8scan.hxx:1104
WW8LvlType GetNumType(sal_uInt8 nWwLevelNo)
Definition: ww8par2.cxx:887
void ParkPaM()
Definition: ww8par2.cxx:2715
sal_uInt16 m_nRowsToRepeat
Definition: ww8par2.hxx:242
bool mbFCTLSizeChanged
Definition: ww8par2.hxx:110
sal_Int16 nUpMgn
Definition: ww8par2.hxx:53
constexpr sal_uInt16 RES_CHRATR_END(46)
SwPosition * m_pParentPos
Definition: ww8par2.hxx:268
void Import1Style(sal_uInt16 nNr)
Definition: ww8par2.cxx:3908
void SetTabVertAlign(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3146
void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp)
Definition: ww8par2.cxx:3884
void ImportSprms(std::size_t nPosFc, short nLen, bool bPap)
Definition: ww8par2.cxx:3638
OUString GetNumRuleName() const
Definition: ww8par2.cxx:3369
RndStdIds
sal_uInt8 mnWwNumLevel
Definition: ww8par2.hxx:103
SwWW8ImplReader * mpIo
Definition: ww8par2.hxx:95
void SetSizePosition(SwFrameFormat *pFrameFormat)
Definition: ww8par2.cxx:2345
short eHRel
Definition: ww8par2.hxx:59
const WW8_TCell * GetCurrentWWCell() const
Definition: ww8par2.hxx:287
void RecursiveReg(sal_uInt16 nNr)
Definition: ww8par2.cxx:3963
short m_nMinLeft
Definition: ww8par2.hxx:226
sal_Int16 nLoMgn
Definition: ww8par2.hxx:53
void PostProcessStyles()
Definition: ww8par2.cxx:3986
void UseSwTable()
Definition: ww8par2.cxx:2550
SwTableLine * GetUpper()
Definition: swtable.hxx:453
void Set1StyleDefaults()
Definition: ww8par2.cxx:3750
short eVRel
Definition: ww8par2.hxx:60
std::shared_ptr< SwUnoCursor > m_xTmpPos
Definition: ww8par2.hxx:211
bool mbWidowsChanged
Definition: ww8par2.hxx:111
short m_nCurrentCol
Definition: ww8par2.hxx:240
void push_back(SwTableBox *pBox)
Definition: ww8par2.hxx:182
WW8SelBoxInfo * FindMergeGroup(short nX1, short nWidth, bool bExact)
Definition: ww8par2.cxx:2836
short m_nCurrentRow
Definition: ww8par2.hxx:237
WW8FlySet(SwWW8ImplReader &rReader, const WW8FlyPara *pFW, const WW8SwFlyPara *pFS, bool bGraf)
Definition: ww8par6.cxx:2169
WW8DupProperties & operator=(const WW8DupProperties &)=delete
void InsertCells(short nIns)
Definition: ww8par2.cxx:3018
WW8RStyle(const WW8RStyle &)=delete
sal_Int16 nNetWidth
Definition: ww8par2.hxx:55
bool m_bDetectedRangeSegmentation false
std::unique_ptr< FrameDeleteWatch > m_xFlyFormat
Definition: ww8par2.hxx:48
sti
Definition: wwstyles.hxx:27