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 bTogglePos;
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( tools::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  bool mbBidiChanged; // For Simulating Default-LTR
109 
110  void ImportSprms(std::size_t nPosFc, short nLen, bool bPap);
111  void ImportSprms(sal_uInt8 *pSprms, short nLen, bool bPap);
112  void ImportGrupx(short nLen, bool bPara, bool bOdd);
113  short ImportUPX(short nLen, bool bPAP, bool bOdd);
114 
115  void Set1StyleDefaults();
116  void Import1Style(sal_uInt16 nNr);
117  void RecursiveReg(sal_uInt16 nNr);
118 
119  void ImportNewFormatStyles();
120  void ScanStyles();
121  void ImportOldFormatStyles();
122 
123  bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle);
124  void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp);
125 
126  WW8RStyle(const WW8RStyle&) = delete;
127  WW8RStyle& operator=(const WW8RStyle&) = delete;
128 public:
129  WW8RStyle( WW8Fib& rFib, SwWW8ImplReader* pI );
130  void Import();
131  void PostProcessStyles();
132  SprmResult HasParaSprm(sal_uInt16 nId) const;
133 };
134 
135 class WW8FlySet: public SfxItemSet
136 {
137 private:
138  const WW8FlySet& operator=(const WW8FlySet&) = delete;
139  void Init(const SwWW8ImplReader& rReader, const SwPaM* pPaM);
140 public:
141  WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW,
142  const WW8SwFlyPara* pFS, bool bGraf);
143  WW8FlySet(SwWW8ImplReader& rReader, const SwPaM* pPaM, const WW8_PIC& rPic,
144  tools::Long nWidth, tools::Long nHeight);
145 };
146 
147 // Gets filled in WW8TabDesc::MergeCells().
148 // Algorithm must ensure proper row and column order in WW8SelBoxInfo!
150 {
151 private:
152  std::vector<std::vector<SwTableBox*> > m_vRows;
153 
154  WW8SelBoxInfo(WW8SelBoxInfo const&) = delete;
155  WW8SelBoxInfo& operator=(WW8SelBoxInfo const&) = delete;
156 
157 public:
159  short nGroupWidth;
161 
162  WW8SelBoxInfo(short nXCenter, short nWidth)
163  : nGroupXStart( nXCenter ), nGroupWidth( nWidth ), bGroupLocked(false)
164  {}
165 
166  size_t size() const
167  {
168  size_t nResult = 0;
169  for (auto& it : m_vRows)
170  nResult += it.size();
171  return nResult;
172  }
173 
174  size_t rowsCount() const { return m_vRows.size(); }
175 
176  const std::vector<SwTableBox*>& row( size_t nIndex ) { return m_vRows[nIndex]; }
177 
178  void push_back( SwTableBox* pBox )
179  {
180  bool bDone = false;
181  for (auto& iRow : m_vRows)
182  if (iRow[0]->GetUpper() == pBox->GetUpper())
183  {
184  iRow.push_back(pBox);
185  bDone = true;
186  break;
187  }
188  if (!bDone)
189  {
190  const size_t sz = m_vRows.size();
191  m_vRows.resize(sz+1);
192  m_vRows[sz].push_back(pBox);
193  }
194  }
195 };
196 
198 {
199  std::vector<OUString> m_aNumRuleNames;
200  std::unique_ptr<sw::util::RedlineStack> mxOldRedlineStack;
201 
203 
206 
207  std::unique_ptr<SwPosition> m_xTmpPos;
208 
209  SwTableNode* m_pTableNd; // table node
210  const SwTableLines* m_pTabLines; // row array of node
211  SwTableLine* m_pTabLine; // current row
212  SwTableBoxes* m_pTabBoxes; // boxes array in current row
213  SwTableBox* m_pTabBox; // current cell
214 
215  std::vector<std::unique_ptr<WW8SelBoxInfo>> m_MergeGroups; // list of all cells to be merged
216 
218 
219  short m_nRows;
221  short m_nBands;
222  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_nMinLeft; }
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: */
bool bTogglePos
Definition: ww8par2.hxx:72
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:3012
void CalcDefaults()
Definition: ww8par2.cxx:2143
bool mbBidiChanged
Definition: ww8par2.hxx:108
void MergeCells()
Definition: ww8par2.cxx:2574
sw::util::RedlineStack * getOldRedlineStack()
Definition: ww8par2.hxx:289
void Init(const SwWW8ImplReader &rReader, const SwPaM *pPaM)
Definition: ww8par6.cxx:2232
long Long
sal_uInt16 mnSprmsLen
Definition: ww8par2.hxx:97
Definition: doc.hxx:187
css::text::WrapTextMode eSurround
Definition: ww8par2.hxx:63
std::unique_ptr< sw::util::RedlineStack > mxOldRedlineStack
Definition: ww8par2.hxx:200
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:3067
SwTableLine is one table row in the document model.
Definition: swtable.hxx:351
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:1880
tools::Long nNewNetWidth
Definition: ww8par2.hxx:68
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:3120
WW8TabBandDesc * m_pActBand
Definition: ww8par2.hxx:205
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:204
const SwTableLines * m_pTabLines
Definition: ww8par2.hxx:210
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:2893
SvStream * mpStStrm
Definition: ww8par2.hxx:92
bool mbCJKFontChanged
Definition: ww8par2.hxx:103
std::vector< std::vector< SwTableBox * > > m_vRows
Definition: ww8par2.hxx:152
SfxItemSet aParSet
Definition: ww8par2.hxx:42
sal_Int16 nHeight
Definition: ww8par2.hxx:53
short m_nBands
Definition: ww8par2.hxx:221
void Insert(const SwPosition &rPos)
Definition: ww8par6.cxx:2276
SwTableBoxes * m_pTabBoxes
Definition: ww8par2.hxx:212
void Import()
Definition: ww8par2.cxx:4474
void MoveOutsideTable()
Definition: ww8par2.cxx:2745
std::unique_ptr< SwWW8FltAnchorStack > xOldAnchorStck
Definition: ww8par2.hxx:84
bool IsValidCell(short nCol) const
Definition: ww8par2.cxx:2871
sal_uInt16 nLineSpace
Definition: ww8par2.hxx:70
void ImportGrupx(short nLen, bool bPara, bool bOdd)
Definition: ww8par2.cxx:3698
short nGroupXStart
Definition: ww8par2.hxx:158
sal_Int16 nRiMgn
Definition: ww8par2.hxx:51
WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStack)
Definition: ww8par6.cxx:2250
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:3156
void ImportNewFormatStyles()
Definition: ww8par2.cxx:4465
Style of a layout element.
Definition: frmfmt.hxx:58
void UpdateTableMergeGroup(WW8_TCell const &rCell, WW8SelBoxInfo *pActGroup, SwTableBox *pActBox, sal_uInt16 nCol)
Definition: ww8par2.cxx:3301
void SetNumRuleName(const OUString &rName)
Definition: ww8par2.cxx:3359
sal_uInt8 * mpParaSprms
Definition: ww8par2.hxx:96
short m_nRows
Definition: ww8par2.hxx:219
bool mbFSizeChanged
Definition: ww8par2.hxx:105
sal_Int16 nWidth
Definition: ww8par2.hxx:53
void FinishSwTable()
Definition: ww8par2.cxx:2752
short m_nDefaultSwCols
Definition: ww8par2.hxx:220
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:3336
short nGroupWidth
Definition: ww8par2.hxx:159
void CreateSwTable()
Definition: ww8par2.cxx:2365
sti
Definition: wwstyles.hxx:27
SwFrameSize
Definition: fmtfsize.hxx:35
const WW8FlySet & operator=(const WW8FlySet &)=delete
SwWW8ImplReader * m_pIo
Definition: ww8par2.hxx:202
SwTableLine * m_pTabLine
Definition: ww8par2.hxx:211
std::unique_ptr< SwPosition > m_xTmpPos
Definition: ww8par2.hxx:207
sal_Int16 m_eOri
Definition: ww8par2.hxx:230
size_t rowsCount() const
Definition: ww8par2.hxx:174
bool mbTextColChanged
Definition: ww8par2.hxx:101
WW8SelBoxInfo(short nXCenter, short nWidth)
Definition: ww8par2.hxx:162
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:111
size_t size() const
Definition: ww8par2.hxx:166
bool mbFontChanged
Definition: ww8par2.hxx:102
std::vector< std::unique_ptr< WW8SelBoxInfo > > m_MergeGroups
Definition: ww8par2.hxx:215
void ScanStyles()
Definition: ww8par2.cxx:3999
std::vector< OUString > m_aNumRuleNames
Definition: ww8par2.hxx:199
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:160
wwSprmParser maSprmParser
Definition: ww8par2.hxx:90
SprmResult HasParaSprm(sal_uInt16 nId) const
Definition: ww8par2.cxx:3588
bool bAutoWidth
Definition: ww8par2.hxx:71
short ImportUPX(short nLen, bool bPAP, bool bOdd)
Definition: ww8par2.cxx:3654
std::vector< SwTableBox * > SwTableBoxes
Definition: swtable.hxx:104
bool m_bClaimLineFormat
Definition: ww8par2.hxx:229
SwTableNode * m_pTableNd
Definition: ww8par2.hxx:209
const std::vector< SwTableBox * > & row(size_t nIndex)
Definition: ww8par2.hxx:176
bool InFirstParaInCell() const
Definition: ww8par2.cxx:2878
void BoxUpWidth(tools::Long nWidth)
Definition: ww8par6.cxx:2134
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:112
WW8_TCell * m_pCurrentWWCell
Definition: ww8par2.hxx:217
sal_Int16 nXPos
Definition: ww8par2.hxx:50
bool m_bOk
Definition: ww8par2.hxx:228
SwTableBox * m_pTabBox
Definition: ww8par2.hxx:213
void TableCellEnd()
Definition: ww8par2.cxx:3247
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:392
FIB - the File Information Block.
Definition: ww8scan.hxx:1103
WW8LvlType GetNumType(sal_uInt8 nWwLevelNo)
Definition: ww8par2.cxx:876
void ParkPaM()
Definition: ww8par2.cxx:2710
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:3128
void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp)
Definition: ww8par2.cxx:3867
void ImportSprms(std::size_t nPosFc, short nLen, bool bPap)
Definition: ww8par2.cxx:3621
OUString GetNumRuleName() const
Definition: ww8par2.cxx:3351
RndStdIds
sal_uInt8 mnWwNumLevel
Definition: ww8par2.hxx:99
SwWW8ImplReader * mpIo
Definition: ww8par2.hxx:91
void SetSizePosition(SwFrameFormat *pFrameFormat)
Definition: ww8par2.cxx:2339
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:222
sal_Int16 nLoMgn
Definition: ww8par2.hxx:52
void PostProcessStyles()
Definition: ww8par2.cxx:3969
void UseSwTable()
Definition: ww8par2.cxx:2545
SwTableLine * GetUpper()
Definition: swtable.hxx:427
void Set1StyleDefaults()
Definition: ww8par2.cxx:3733
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:178
WW8SelBoxInfo * FindMergeGroup(short nX1, short nWidth, bool bExact)
Definition: ww8par2.cxx:2818
short m_nCurrentRow
Definition: ww8par2.hxx:233
WW8FlySet(SwWW8ImplReader &rReader, const WW8FlyPara *pFW, const WW8SwFlyPara *pFS, bool bGraf)
Definition: ww8par6.cxx:2143
WW8DupProperties & operator=(const WW8DupProperties &)=delete
void InsertCells(short nIns)
Definition: ww8par2.cxx:3000
WW8RStyle(const WW8RStyle &)=delete
sal_Int16 nNetWidth
Definition: ww8par2.hxx:54