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
31class WW8RStyle;
32
34{
35public:
37 void Insert(const SwPosition &rPos);
38private:
43};
44
46{
47private:
48 std::unique_ptr<FrameDeleteWatch> m_xFlyFormat;
49public:
50 // part 1: directly derived Sw attributes
51 sal_Int16 nXPos, nYPos; // Position
52 sal_Int16 nLeftMargin, nRightMargin; // borders
53 sal_Int16 nUpperMargin, nLowerMargin; // 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
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
86 void SetFlyFormat(SwFlyFrameFormat* pNewFlyFormat);
87
88 std::unique_ptr<SwWW8FltAnchorStack> xOldAnchorStck;
89};
90
91class WW8RStyle: public WW8Style
92{
93friend 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 std::map<OUString, sal_Int32>& rParaCollisions,
122 std::map<OUString, sal_Int32>& rCharCollisions);
123 void RecursiveReg(sal_uInt16 nNr);
124
126 void ScanStyles();
128
129 bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle,
130 std::map<OUString, sal_Int32>& rParaCollisions,
131 std::map<OUString, sal_Int32>& rCharCollisions);
132 void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp);
133
134 WW8RStyle(const WW8RStyle&) = delete;
135 WW8RStyle& operator=(const WW8RStyle&) = delete;
136public:
137 WW8RStyle( WW8Fib& rFib, SwWW8ImplReader* pI );
138 void Import();
139 void PostProcessStyles();
140 SprmResult HasParaSprm(sal_uInt16 nId) const;
141};
142
143class WW8FlySet: public SfxItemSetFixed<RES_FRMATR_BEGIN,RES_FRMATR_END-1>
144{
145private:
146 const WW8FlySet& operator=(const WW8FlySet&) = delete;
147 void Init(const SwWW8ImplReader& rReader, const SwPaM* pPaM);
148public:
149 WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW,
150 const WW8SwFlyPara* pFS, bool bGraf);
151 WW8FlySet(SwWW8ImplReader& rReader, const SwPaM* pPaM, const WW8_PIC& rPic,
152 tools::Long nWidth, tools::Long nHeight);
153};
154
155// Gets filled in WW8TabDesc::MergeCells().
156// Algorithm must ensure proper row and column order in WW8SelBoxInfo!
158{
159private:
160 std::vector<std::vector<SwTableBox*> > m_vRows;
161
162 WW8SelBoxInfo(WW8SelBoxInfo const&) = delete;
164
165public:
169
170 WW8SelBoxInfo(short nXCenter, short nWidth)
171 : m_nGroupXStart( nXCenter ), m_nGroupWidth( nWidth ), m_bGroupLocked(false)
172 {}
173
174 size_t size() const
175 {
176 size_t nResult = 0;
177 for (auto& it : m_vRows)
178 nResult += it.size();
179 return nResult;
180 }
181
182 size_t rowsCount() const { return m_vRows.size(); }
183
184 const std::vector<SwTableBox*>& row( size_t nIndex ) { return m_vRows[nIndex]; }
185
186 void push_back( SwTableBox* pBox )
187 {
188 bool bDone = false;
189 for (auto& iRow : m_vRows)
190 if (iRow[0]->GetUpper() == pBox->GetUpper())
191 {
192 iRow.push_back(pBox);
193 bDone = true;
194 break;
195 }
196 if (!bDone)
197 {
198 const size_t sz = m_vRows.size();
199 m_vRows.resize(sz+1);
200 m_vRows[sz].push_back(pBox);
201 }
202 }
203};
204
206{
207 std::vector<OUString> m_aNumRuleNames;
208 std::unique_ptr<sw::util::RedlineStack> mxOldRedlineStack;
209
211
214
215 std::shared_ptr<SwUnoCursor> m_xTmpPos;
216
217 SwTableNode* m_pTableNd; // table node
218 const SwTableLines* m_pTabLines; // row array of node
219 SwTableLine* m_pTabLine; // current row
220 SwTableBoxes* m_pTabBoxes; // boxes array in current row
221 SwTableBox* m_pTabBox; // current cell
222
223 std::vector<std::unique_ptr<WW8SelBoxInfo>> m_MergeGroups; // list of all cells to be merged
224
226
227 short m_nRows;
229 short m_nBands;
235
236 bool m_bOk;
238 sal_Int16 m_eOri;
240 // 2. common admin info
242 short m_nCurrentBandRow; // SW: row of current band
243 // 3. admin info for writer
245
246 sal_uInt16 m_nRowsToRepeat;
247
248 // 4. methods
249
250 sal_uInt16 GetLogicalWWCol() const;
251 void SetTabBorders( SwTableBox* pBox, short nIdx );
252 void SetTabShades( SwTableBox* pBox, short nWwIdx );
253 void SetTabVertAlign( SwTableBox* pBox, short nWwIdx );
254 void SetTabDirection( SwTableBox* pBox, short nWwIdx );
255 void CalcDefaults();
256 void SetPamInCell(short nWwCol, bool bPam);
257 void InsertCells( short nIns );
258 void AdjustNewBand();
259
260 WW8SelBoxInfo* FindMergeGroup(short nX1, short nWidth, bool bExact);
261
262 // single box - maybe used in a merge group
263 // (the merge groups are processed later at once)
264 void UpdateTableMergeGroup(WW8_TCell const & rCell,
265 WW8SelBoxInfo* pActGroup, SwTableBox* pActBox, sal_uInt16 nCol );
266
267 WW8TabDesc(WW8TabDesc const&) = delete;
268 WW8TabDesc& operator=(WW8TabDesc const&) = delete;
269
270public:
271 const SwTable* m_pTable; // table
275 bool IsValidCell(short nCol) const;
276 bool InFirstParaInCell() const;
277
278 WW8TabDesc( SwWW8ImplReader* pIoClass, WW8_CP nStartCp );
279 bool Ok() const { return m_bOk; }
280 void CreateSwTable();
281 void UseSwTable();
282 void SetSizePosition(SwFrameFormat* pFrameFormat);
283 void TableCellEnd();
284 void MoveOutsideTable();
285 void ParkPaM();
286 void FinishSwTable();
287 void MergeCells();
288 short GetMinLeft() const { return m_nMinLeft; }
289 ~WW8TabDesc();
290
291 const WW8_TCell* GetCurrentWWCell() const { return m_pCurrentWWCell; }
292 short GetCurrentCol() const { return m_nCurrentCol; }
293 // find name of numrule valid for current WW-COL
294 OUString GetNumRuleName() const;
295 void SetNumRuleName( const OUString& rName );
296
298};
299
301
303#endif
304
305/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: doc.hxx:197
Style of a layout element.
Definition: frmfmt.hxx:72
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:443
SwTableLine * GetUpper()
Definition: swtable.hxx:477
SwTableLine is one table row in the document model.
Definition: swtable.hxx:376
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:113
SfxItemSetFixed< RES_CHRATR_BEGIN, RES_CHRATR_END - 1 > m_aChrSet
Definition: ww8par2.hxx:42
SfxItemSetFixed< RES_CHRATR_BEGIN, RES_CHRATR_END - 1 > m_aParSet
Definition: ww8par2.hxx:42
WW8DupProperties & operator=(const WW8DupProperties &)=delete
WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStack)
Definition: ww8par6.cxx:2298
void Insert(const SwPosition &rPos)
Definition: ww8par6.cxx:2324
WW8DupProperties(const WW8DupProperties &)=delete
SwWW8FltControlStack * m_pCtrlStck
Definition: ww8par2.hxx:41
FIB - the File Information Block.
Definition: ww8scan.hxx:1106
WW8FlySet(SwWW8ImplReader &rReader, const WW8FlyPara *pFW, const WW8SwFlyPara *pFS, bool bGraf)
Definition: ww8par6.cxx:2191
const WW8FlySet & operator=(const WW8FlySet &)=delete
void Init(const SwWW8ImplReader &rReader, const SwPaM *pPaM)
Definition: ww8par6.cxx:2280
void ImportSprms(std::size_t nPosFc, short nLen, bool bPap)
Definition: ww8par2.cxx:3603
bool mbCTLFontChanged
Definition: ww8par2.hxx:108
WW8RStyle(const WW8RStyle &)=delete
sal_uInt16 mnSprmsLen
Definition: ww8par2.hxx:101
wwSprmParser maSprmParser
Definition: ww8par2.hxx:94
void ImportGrupx(short nLen, bool bPara, bool bOdd)
Definition: ww8par2.cxx:3680
void ScanStyles()
Definition: ww8par2.cxx:3988
bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle, std::map< OUString, sal_Int32 > &rParaCollisions, std::map< OUString, sal_Int32 > &rCharCollisions)
Definition: ww8par2.cxx:3767
void ImportNewFormatStyles()
Definition: ww8par2.cxx:4486
sal_uInt8 * mpParaSprms
Definition: ww8par2.hxx:100
void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp)
Definition: ww8par2.cxx:3852
void RecursiveReg(sal_uInt16 nNr)
Definition: ww8par2.cxx:3935
SwWW8ImplReader * mpIo
Definition: ww8par2.hxx:95
SwNumRule * mpStyRule
Definition: ww8par2.hxx:98
bool mbWidowsChanged
Definition: ww8par2.hxx:111
bool mbBidiChanged
Definition: ww8par2.hxx:112
void Set1StyleDefaults()
Definition: ww8par2.cxx:3715
bool mbCJKFontChanged
Definition: ww8par2.hxx:107
bool mbFontChanged
Definition: ww8par2.hxx:106
SprmResult HasParaSprm(sal_uInt16 nId) const
Definition: ww8par2.cxx:3570
short ImportUPX(short nLen, bool bPAP, bool bOdd)
Definition: ww8par2.cxx:3636
bool mbFCTLSizeChanged
Definition: ww8par2.hxx:110
void PostProcessStyles()
Definition: ww8par2.cxx:3958
bool mbFSizeChanged
Definition: ww8par2.hxx:109
void ImportOldFormatStyles()
Definition: ww8par2.cxx:4274
bool mbTextColChanged
Definition: ww8par2.hxx:105
SvStream * mpStStrm
Definition: ww8par2.hxx:96
void Import1Style(sal_uInt16 nNr, std::map< OUString, sal_Int32 > &rParaCollisions, std::map< OUString, sal_Int32 > &rCharCollisions)
Definition: ww8par2.cxx:3876
void Import()
Definition: ww8par2.cxx:4498
WW8RStyle & operator=(const WW8RStyle &)=delete
sal_uInt8 mnWwNumLevel
Definition: ww8par2.hxx:103
size_t rowsCount() const
Definition: ww8par2.hxx:182
std::vector< std::vector< SwTableBox * > > m_vRows
Definition: ww8par2.hxx:160
void push_back(SwTableBox *pBox)
Definition: ww8par2.hxx:186
WW8SelBoxInfo & operator=(WW8SelBoxInfo const &)=delete
WW8SelBoxInfo(WW8SelBoxInfo const &)=delete
bool m_bGroupLocked
Definition: ww8par2.hxx:168
const std::vector< SwTableBox * > & row(size_t nIndex)
Definition: ww8par2.hxx:184
size_t size() const
Definition: ww8par2.hxx:174
WW8SelBoxInfo(short nXCenter, short nWidth)
Definition: ww8par2.hxx:170
short m_nGroupWidth
Definition: ww8par2.hxx:167
short m_nGroupXStart
Definition: ww8par2.hxx:166
bool m_bIsBiDi
Definition: ww8par2.hxx:239
bool IsValidCell(short nCol) const
Definition: ww8par2.cxx:2855
bool m_bOk
Definition: ww8par2.hxx:236
short m_nCurrentBandRow
Definition: ww8par2.hxx:242
void CreateSwTable()
Definition: ww8par2.cxx:2337
void SetTabDirection(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3103
void MoveOutsideTable()
Definition: ww8par2.cxx:2716
void UseSwTable()
Definition: ww8par2.cxx:2516
short m_nCurrentRow
Definition: ww8par2.hxx:241
void SetPamInCell(short nWwCol, bool bPam)
Definition: ww8par2.cxx:2877
const SwTableLines * m_pTabLines
Definition: ww8par2.hxx:218
SwTableLine * m_pTabLine
Definition: ww8par2.hxx:219
OUString GetNumRuleName() const
Definition: ww8par2.cxx:3334
void AdjustNewBand()
Definition: ww8par2.cxx:3139
std::vector< OUString > m_aNumRuleNames
Definition: ww8par2.hxx:207
short m_nRows
Definition: ww8par2.hxx:227
SwPosition * m_pParentPos
Definition: ww8par2.hxx:272
const SwTable * m_pTable
Definition: ww8par2.hxx:271
void SetTabShades(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3050
void FinishSwTable()
Definition: ww8par2.cxx:2723
void SetTabVertAlign(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3111
void SetSizePosition(SwFrameFormat *pFrameFormat)
Definition: ww8par2.cxx:2311
void MergeCells()
Definition: ww8par2.cxx:2545
sal_uInt16 GetLogicalWWCol() const
Definition: ww8par2.cxx:3319
short m_nBands
Definition: ww8par2.hxx:229
sal_Int16 m_eOri
Definition: ww8par2.hxx:238
sal_uInt16 m_nRowsToRepeat
Definition: ww8par2.hxx:246
std::shared_ptr< SwUnoCursor > m_xTmpPos
Definition: ww8par2.hxx:215
short m_nPreferredWidth
Definition: ww8par2.hxx:233
const WW8_TCell * GetCurrentWWCell() const
Definition: ww8par2.hxx:291
SwFlyFrameFormat * m_pFlyFormat
Definition: ww8par2.hxx:273
short m_nMinLeft
Definition: ww8par2.hxx:230
WW8TabBandDesc * m_pFirstBand
Definition: ww8par2.hxx:212
bool InFirstParaInCell() const
Definition: ww8par2.cxx:2862
short m_nMaxRight
Definition: ww8par2.hxx:231
WW8TabDesc(WW8TabDesc const &)=delete
bool m_bClaimLineFormat
Definition: ww8par2.hxx:237
WW8_TCell * m_pCurrentWWCell
Definition: ww8par2.hxx:225
void CalcDefaults()
Definition: ww8par2.cxx:2115
SwWW8ImplReader * m_pIo
Definition: ww8par2.hxx:210
SfxItemSet m_aItemSet
Definition: ww8par2.hxx:274
WW8TabDesc & operator=(WW8TabDesc const &)=delete
void UpdateTableMergeGroup(WW8_TCell const &rCell, WW8SelBoxInfo *pActGroup, SwTableBox *pActBox, sal_uInt16 nCol)
Definition: ww8par2.cxx:3284
void TableCellEnd()
Definition: ww8par2.cxx:3230
SwTableNode * m_pTableNd
Definition: ww8par2.hxx:217
void SetTabBorders(SwTableBox *pBox, short nIdx)
Definition: ww8par2.cxx:2995
short m_nCurrentCol
Definition: ww8par2.hxx:244
void InsertCells(short nIns)
Definition: ww8par2.cxx:2983
short GetCurrentCol() const
Definition: ww8par2.hxx:292
short m_nDefaultSwCols
Definition: ww8par2.hxx:228
WW8TabBandDesc * m_pActBand
Definition: ww8par2.hxx:213
std::vector< std::unique_ptr< WW8SelBoxInfo > > m_MergeGroups
Definition: ww8par2.hxx:223
void ParkPaM()
Definition: ww8par2.cxx:2681
bool Ok() const
Definition: ww8par2.hxx:279
short m_nPercentWidth
Definition: ww8par2.hxx:234
short m_nSwWidth
Definition: ww8par2.hxx:232
short GetMinLeft() const
Definition: ww8par2.hxx:288
void SetNumRuleName(const OUString &rName)
Definition: ww8par2.cxx:3342
WW8SelBoxInfo * FindMergeGroup(short nX1, short nWidth, bool bExact)
Definition: ww8par2.cxx:2802
SwTableBoxes * m_pTabBoxes
Definition: ww8par2.hxx:220
SwTableBox * m_pTabBox
Definition: ww8par2.hxx:221
sw::util::RedlineStack * getOldRedlineStack()
Definition: ww8par2.hxx:297
std::unique_ptr< sw::util::RedlineStack > mxOldRedlineStack
Definition: ww8par2.hxx:208
wwSprmParser knows how to take a sequence of bytes and split it up into sprms and their arguments
Definition: ww8scan.hxx:114
SwFrameSize
Definition: fmtfsize.hxx:36
constexpr sal_uInt16 RES_CHRATR_END(46)
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
sal_Int32 nIndex
long Long
sti
Definition: wwstyles.hxx:29
Marks a position in the document model.
Definition: pam.hxx:38
sal_Int16 nWidth
Definition: ww8par2.hxx:54
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:1895
sal_Int16 nRightMargin
Definition: ww8par2.hxx:52
sal_Int16 eVAlign
Definition: ww8par2.hxx:61
static constexpr RndStdIds eAnchor
Definition: ww8par2.hxx:58
sal_uInt16 nLineSpace
Definition: ww8par2.hxx:71
sal_Int16 nXPos
Definition: ww8par2.hxx:51
sal_Int16 nNetWidth
Definition: ww8par2.hxx:55
sal_uInt8 nXBind
Definition: ww8par2.hxx:66
SwFlyFrameFormat * GetFlyFormat() const
Definition: ww8par6.cxx:2173
void SetFlyFormat(SwFlyFrameFormat *pNewFlyFormat)
Definition: ww8par6.cxx:2180
short eVRel
Definition: ww8par2.hxx:60
sal_Int16 eHAlign
Definition: ww8par2.hxx:62
sal_Int16 nHeight
Definition: ww8par2.hxx:54
css::text::WrapTextMode eSurround
Definition: ww8par2.hxx:64
void BoxUpWidth(tools::Long nWidth)
Definition: ww8par6.cxx:2167
sal_Int16 nLowerMargin
Definition: ww8par2.hxx:53
sal_Int16 nLeftMargin
Definition: ww8par2.hxx:52
tools::Long nNewNetWidth
Definition: ww8par2.hxx:69
SwFrameSize eHeightFix
Definition: ww8par2.hxx:57
std::shared_ptr< SwUnoCursor > xMainTextPos
Definition: ww8par2.hxx:70
sal_Int16 nYPos
Definition: ww8par2.hxx:51
bool bAutoWidth
Definition: ww8par2.hxx:72
std::unique_ptr< SwWW8FltAnchorStack > xOldAnchorStck
Definition: ww8par2.hxx:88
std::unique_ptr< FrameDeleteWatch > m_xFlyFormat
Definition: ww8par2.hxx:48
short eHRel
Definition: ww8par2.hxx:59
sal_uInt8 nYBind
Definition: ww8par2.hxx:66
bool bTogglePos
Definition: ww8par2.hxx:73
sal_Int16 nUpperMargin
Definition: ww8par2.hxx:53
RndStdIds
std::vector< SwTableBox * > SwTableBoxes
Definition: swtable.hxx:105
unsigned char sal_uInt8
WW8LvlType
Definition: ww8par2.hxx:300
@ WW8_Outline
Definition: ww8par2.hxx:300
@ WW8_Numbering
Definition: ww8par2.hxx:300
@ WW8_Sequence
Definition: ww8par2.hxx:300
@ WW8_None
Definition: ww8par2.hxx:300
@ WW8_Pause
Definition: ww8par2.hxx:300
WW8LvlType GetNumType(sal_uInt8 nWwLevelNo)
Definition: ww8par2.cxx:853
sal_Int32 WW8_CP
Definition: ww8struc.hxx:153