Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <editeng/pbinitem.hxx>
30 : : #include <editeng/ulspitem.hxx>
31 : : #include <editeng/boxitem.hxx>
32 : : #include <editeng/brshitem.hxx>
33 : : #include <editeng/shaditem.hxx>
34 : : #include "editeng/frmdiritem.hxx"
35 : : #include <fmtclds.hxx>
36 : : #include <fmtfsize.hxx>
37 : : #include <pagefrm.hxx>
38 : : #include <pagedesc.hxx>
39 : : #include <swtable.hxx>
40 : : #include <frmtool.hxx>
41 : : #include <doc.hxx> // for GetAttrPool
42 : : #include <poolfmt.hxx>
43 : : #include <switerator.hxx>
44 : :
45 : :
46 : : using namespace ::com::sun::star;
47 : :
48 : : /*************************************************************************
49 : : |*
50 : : |* SwPageDesc::SwPageDesc()
51 : : |*
52 : : |*************************************************************************/
53 : :
54 : :
55 : :
56 : 1891 : SwPageDesc::SwPageDesc( const String& rName, SwFrmFmt *pFmt, SwDoc *pDc ) :
57 : : SwModify( 0 ),
58 : : aDescName( rName ),
59 : 1891 : aMaster( pDc->GetAttrPool(), rName, pFmt ),
60 : 1891 : aLeft( pDc->GetAttrPool(), rName, pFmt ),
61 : 1891 : aFirst( pDc->GetAttrPool(), rName, pFmt ),
62 : : aDepend( this, 0 ),
63 : : pFollow( this ),
64 : : nRegHeight( 0 ),
65 : : nRegAscent( 0 ),
66 : : eUse( (UseOnPage)(nsUseOnPage::PD_ALL | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE | nsUseOnPage::PD_FIRSTSHARE ) ),
67 : : bLandscape( sal_False ),
68 [ + - ][ + - : 7564 : aFtnInfo()
+ - + - +
- ][ + - ]
[ + - ]
69 : : {
70 : 1891 : }
71 : :
72 : 993 : SwPageDesc::SwPageDesc( const SwPageDesc &rCpy ) :
73 : : SwModify( 0 ),
74 : 993 : aDescName( rCpy.GetName() ),
75 : 993 : aNumType( rCpy.GetNumType() ),
76 : 993 : aMaster( rCpy.GetMaster() ),
77 : 993 : aLeft( rCpy.GetLeft() ),
78 : 993 : aFirst( rCpy.GetFirst() ),
79 : 993 : aDepend( this, (SwModify*)rCpy.aDepend.GetRegisteredIn() ),
80 : : pFollow( rCpy.pFollow ),
81 : 993 : nRegHeight( rCpy.GetRegHeight() ),
82 : 993 : nRegAscent( rCpy.GetRegAscent() ),
83 : 993 : eUse( rCpy.ReadUseOn() ),
84 : 993 : bLandscape( rCpy.GetLandscape() ),
85 [ + - + - : 7944 : aFtnInfo( rCpy.GetFtnInfo() )
+ - + - +
- + - +
- ]
86 : : {
87 : 993 : }
88 : :
89 : 20 : SwPageDesc & SwPageDesc::operator = (const SwPageDesc & rSrc)
90 : : {
91 : 20 : aDescName = rSrc.aDescName;
92 : 20 : aNumType = rSrc.aNumType;
93 : 20 : aMaster = rSrc.aMaster;
94 : 20 : aLeft = rSrc.aLeft;
95 : 20 : aFirst = rSrc.aFirst;
96 : :
97 [ + + ]: 20 : if (rSrc.pFollow == &rSrc)
98 : 6 : pFollow = this;
99 : : else
100 : 14 : pFollow = rSrc.pFollow;
101 : :
102 : 20 : nRegHeight = rSrc.nRegHeight;
103 : 20 : nRegAscent = rSrc.nRegAscent;
104 : 20 : eUse = rSrc.eUse;
105 : 20 : bLandscape = rSrc.bLandscape;
106 : 20 : return *this;
107 : : }
108 : :
109 [ + - ][ + - ]: 2748 : SwPageDesc::~SwPageDesc()
[ + - ][ + - ]
[ + - ][ + - ]
110 : : {
111 [ - + ]: 5456 : }
112 : :
113 : : /*************************************************************************
114 : : |*
115 : : |* SwPageDesc::Mirror()
116 : : |*
117 : : |* Description Only the margin is mirrored.
118 : : |* Attributes like borders and so on are copied 1:1.
119 : : |*
120 : : |*************************************************************************/
121 : :
122 : :
123 : :
124 : 0 : void SwPageDesc::Mirror()
125 : : {
126 : : //Only the margins are mirrored, all other values are just copied.
127 [ # # ]: 0 : SvxLRSpaceItem aLR( RES_LR_SPACE );
128 [ # # ]: 0 : const SvxLRSpaceItem &rLR = aMaster.GetLRSpace();
129 : 0 : aLR.SetLeft( rLR.GetRight() );
130 : 0 : aLR.SetRight( rLR.GetLeft() );
131 : :
132 : 0 : SfxItemSet aSet( *aMaster.GetAttrSet().GetPool(),
133 [ # # ]: 0 : aMaster.GetAttrSet().GetRanges() );
134 [ # # ]: 0 : aSet.Put( aLR );
135 [ # # ][ # # ]: 0 : aSet.Put( aMaster.GetFrmSize() );
136 [ # # ][ # # ]: 0 : aSet.Put( aMaster.GetPaperBin() );
137 [ # # ][ # # ]: 0 : aSet.Put( aMaster.GetULSpace() );
138 [ # # ][ # # ]: 0 : aSet.Put( aMaster.GetBox() );
139 [ # # ][ # # ]: 0 : aSet.Put( aMaster.GetBackground() );
140 [ # # ][ # # ]: 0 : aSet.Put( aMaster.GetShadow() );
141 [ # # ][ # # ]: 0 : aSet.Put( aMaster.GetCol() );
142 [ # # ][ # # ]: 0 : aSet.Put( aMaster.GetFrmDir() ); // #112217#
143 [ # # ][ # # ]: 0 : aLeft.SetFmtAttr( aSet );
[ # # ]
144 : 0 : }
145 : :
146 : 121 : void SwPageDesc::ResetAllAttr( sal_Bool bLeft )
147 : : {
148 [ - + ]: 121 : SwFrmFmt& rFmt = bLeft ? GetLeft() : GetMaster();
149 : :
150 : : // #i73790# - method renamed
151 : 121 : rFmt.ResetAllFmtAttr();
152 [ + - ]: 121 : rFmt.SetFmtAttr( SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR) );
153 : 121 : }
154 : :
155 : : /*************************************************************************
156 : : |*
157 : : |* SwPageDesc::GetInfo()
158 : : |*
159 : : |* Description retrieves information
160 : : |*
161 : : *************************************************************************/
162 : :
163 : :
164 : : // gets information from Modify
165 : 0 : sal_Bool SwPageDesc::GetInfo( SfxPoolItem & rInfo ) const
166 : : {
167 [ # # ]: 0 : if( !aMaster.GetInfo( rInfo ) )
168 : 0 : return sal_False; // found
169 : 0 : return aLeft.GetInfo( rInfo );
170 : : }
171 : :
172 : : /*************************************************************************
173 : : |*
174 : : |* SwPageDesc::SetRegisterFmtColl()
175 : : |*
176 : : |* Description sets the style for the grid alignment
177 : : |*
178 : : *************************************************************************/
179 : :
180 : :
181 : 2251 : void SwPageDesc::SetRegisterFmtColl( const SwTxtFmtColl* pFmt )
182 : : {
183 [ - + ]: 2251 : if( pFmt != GetRegisterFmtColl() )
184 : : {
185 [ # # ]: 0 : if( pFmt )
186 : 0 : ((SwTxtFmtColl*)pFmt)->Add( &aDepend );
187 : : else
188 : 0 : ((SwTxtFmtColl*)GetRegisterFmtColl())->Remove( &aDepend );
189 : :
190 : 0 : RegisterChange();
191 : : }
192 : 2251 : }
193 : :
194 : : /*************************************************************************
195 : : |*
196 : : |* SwPageDesc::GetRegisterFmtColl()
197 : : |*
198 : : |* Description retrieves the style for the grid alignment
199 : : |*
200 : : *************************************************************************/
201 : :
202 : :
203 : 6381 : const SwTxtFmtColl* SwPageDesc::GetRegisterFmtColl() const
204 : : {
205 : 6381 : const SwModify* pReg = aDepend.GetRegisteredIn();
206 : 6381 : return (SwTxtFmtColl*)pReg;
207 : : }
208 : :
209 : : /*************************************************************************
210 : : |*
211 : : |* SwPageDesc::RegisterChange()
212 : : |*
213 : : |* Description notifies all affected page frames
214 : : |*
215 : : *************************************************************************/
216 : :
217 : :
218 : 0 : void SwPageDesc::RegisterChange()
219 : : {
220 : : // #117072# - During destruction of the document <SwDoc>
221 : : // the page description is modified. Thus, do nothing, if the document
222 : : // is in destruction respectively if no viewshell exists.
223 : 0 : SwDoc* pDoc = GetMaster().GetDoc();
224 [ # # ][ # # ]: 0 : if ( !pDoc || pDoc->IsInDtor() )
[ # # ]
225 : : {
226 : : return;
227 : : }
228 : 0 : ViewShell* pSh = 0L;
229 [ # # ]: 0 : pDoc->GetEditShell( &pSh );
230 [ # # ]: 0 : if ( !pSh )
231 : : {
232 : : return;
233 : : }
234 : :
235 : 0 : nRegHeight = 0;
236 : : {
237 [ # # ]: 0 : SwIterator<SwFrm,SwFmt> aIter( GetMaster() );
238 [ # # ][ # # ]: 0 : for( SwFrm* pLast = aIter.First(); pLast; pLast = aIter.Next() )
[ # # ]
239 : : {
240 [ # # ]: 0 : if( pLast->IsPageFrm() )
241 [ # # ]: 0 : ((SwPageFrm*)pLast)->PrepareRegisterChg();
242 [ # # ]: 0 : }
243 : : }
244 : : {
245 [ # # ]: 0 : SwIterator<SwFrm,SwFmt> aIter( GetLeft() );
246 [ # # ][ # # ]: 0 : for( SwFrm* pLast = aIter.First(); pLast; pLast = aIter.Next() )
[ # # ]
247 : : {
248 [ # # ]: 0 : if( pLast->IsPageFrm() )
249 [ # # ]: 0 : ((SwPageFrm*)pLast)->PrepareRegisterChg();
250 [ # # ]: 0 : }
251 : : }
252 : : {
253 [ # # ]: 0 : SwIterator<SwFrm,SwFmt> aIter( GetFirst() );
254 [ # # ][ # # ]: 0 : for( SwFrm* pLast = aIter.First(); pLast; pLast = aIter.Next() )
[ # # ]
255 : : {
256 [ # # ]: 0 : if( pLast->IsPageFrm() )
257 [ # # ]: 0 : ((SwPageFrm*)pLast)->PrepareRegisterChg();
258 [ # # ]: 0 : }
259 : : }
260 : : }
261 : :
262 : : /*************************************************************************
263 : : |*
264 : : |* SwPageDesc::Modify()
265 : : |*
266 : : |* special handling if the style of the grid alignment changes
267 : : |*
268 : : *************************************************************************/
269 : :
270 : :
271 : 0 : void SwPageDesc::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
272 : : {
273 [ # # ][ # # ]: 0 : const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
274 : 0 : NotifyClients( pOld, pNew );
275 : :
276 [ # # # # ]: 0 : if ( (RES_ATTRSET_CHG == nWhich) || (RES_FMT_CHG == nWhich)
[ # # ][ # # ]
[ # # ]
277 : 0 : || isCHRATR(nWhich) || (RES_PARATR_LINESPACING == nWhich) )
278 : : {
279 : 0 : RegisterChange();
280 : : }
281 : 0 : }
282 : :
283 : 0 : static const SwFrm* lcl_GetFrmOfNode( const SwNode& rNd )
284 : : {
285 : : SwModify* pMod;
286 : 0 : sal_uInt16 nFrmType = FRM_CNTNT;
287 : :
288 [ # # ]: 0 : if( rNd.IsCntntNode() )
289 : : {
290 : 0 : pMod = &(SwCntntNode&)rNd;
291 : : }
292 [ # # ]: 0 : else if( rNd.IsTableNode() )
293 : : {
294 : 0 : pMod = ((SwTableNode&)rNd).GetTable().GetFrmFmt();
295 : 0 : nFrmType = FRM_TAB;
296 : : }
297 : : else
298 : 0 : pMod = 0;
299 : :
300 : 0 : Point aNullPt;
301 : 0 : return pMod ? ::GetFrmOfModify( 0, *pMod, nFrmType, &aNullPt, 0, sal_False )
302 [ # # ][ # # ]: 0 : : 0;
303 : : }
304 : :
305 : 0 : const SwPageDesc* SwPageDesc::GetPageDescOfNode(const SwNode& rNd)
306 : : {
307 : 0 : const SwPageDesc* pRet = 0;
308 : 0 : const SwFrm* pChkFrm = lcl_GetFrmOfNode( rNd );
309 [ # # ][ # # ]: 0 : if (pChkFrm && 0 != (pChkFrm = pChkFrm->FindPageFrm()))
[ # # ]
310 : 0 : pRet = ((const SwPageFrm*)pChkFrm)->GetPageDesc();
311 : 0 : return pRet;
312 : : }
313 : :
314 : 0 : const SwFrmFmt* SwPageDesc::GetPageFmtOfNode( const SwNode& rNd,
315 : : sal_Bool bCheckForThisPgDc ) const
316 : : {
317 : : // which PageDescFormat is valid for this node?
318 : : const SwFrmFmt* pRet;
319 : 0 : const SwFrm* pChkFrm = lcl_GetFrmOfNode( rNd );
320 : :
321 [ # # ][ # # ]: 0 : if( pChkFrm && 0 != ( pChkFrm = pChkFrm->FindPageFrm() ))
[ # # ]
322 : : {
323 : : const SwPageDesc* pPd = bCheckForThisPgDc ? this :
324 [ # # ]: 0 : ((SwPageFrm*)pChkFrm)->GetPageDesc();
325 : 0 : pRet = &pPd->GetMaster();
326 : : OSL_ENSURE( ((SwPageFrm*)pChkFrm)->GetPageDesc() == pPd, "Wrong node for detection of page format!" );
327 : : // this page is assigned to which format?
328 [ # # ]: 0 : if( !pChkFrm->KnowsFormat(*pRet) )
329 : : {
330 : 0 : pRet = &pPd->GetLeft();
331 : : OSL_ENSURE( pChkFrm->KnowsFormat(*pRet), "Wrong node for detection of page format!" );
332 : : }
333 : : }
334 : : else
335 : 0 : pRet = &GetMaster();
336 : 0 : return pRet;
337 : : }
338 : :
339 : 0 : sal_Bool SwPageDesc::IsFollowNextPageOfNode( const SwNode& rNd ) const
340 : : {
341 : 0 : sal_Bool bRet = sal_False;
342 [ # # ][ # # ]: 0 : if( GetFollow() && this != GetFollow() )
[ # # ]
343 : : {
344 : 0 : const SwFrm* pChkFrm = lcl_GetFrmOfNode( rNd );
345 [ # # # # : 0 : if( pChkFrm && 0 != ( pChkFrm = pChkFrm->FindPageFrm() ) &&
# # # # ]
[ # # ][ # # ]
346 : 0 : pChkFrm->IsPageFrm() &&
347 : 0 : ( !pChkFrm->GetNext() || GetFollow() ==
348 : 0 : ((SwPageFrm*)pChkFrm->GetNext())->GetPageDesc() ))
349 : : // the page on which the follow points was found
350 : 0 : bRet = sal_True;
351 : : }
352 : 0 : return bRet;
353 : : }
354 : :
355 : 7839 : sal_Bool SwPageDesc::IsFirstShared() const
356 : : {
357 [ + + ]: 7839 : return eUse & nsUseOnPage::PD_FIRSTSHARE ? sal_True : sal_False;
358 : : }
359 : :
360 : 1422 : void SwPageDesc::ChgFirstShare( sal_Bool bNew )
361 : : {
362 [ + + ]: 1422 : if ( bNew )
363 : 487 : eUse = (UseOnPage) (eUse | nsUseOnPage::PD_FIRSTSHARE);
364 : : else
365 : 935 : eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOFIRSTSHARE);
366 : 1422 : }
367 : :
368 : : /*************************************************************************
369 : : |*
370 : : |* SwPageFtnInfo::SwPageFtnInfo()
371 : : |*
372 : : |*************************************************************************/
373 : :
374 : :
375 : :
376 : 1891 : SwPageFtnInfo::SwPageFtnInfo() :
377 : : nMaxHeight( 0 ),
378 : : nLineWidth(10),
379 : : eLineStyle( table::BorderLineStyle::SOLID ),
380 : : aWidth( 25, 100 ),
381 : : nTopDist( 57 ), //1mm
382 : 1891 : nBottomDist( 57 )
383 : : {
384 : 1891 : eAdj = FRMDIR_HORI_RIGHT_TOP == GetDefaultFrameDirection(GetAppLanguage()) ?
385 : : FTNADJ_RIGHT :
386 [ - + ]: 1891 : FTNADJ_LEFT;
387 : 1891 : }
388 : :
389 : :
390 : :
391 : 9917 : SwPageFtnInfo::SwPageFtnInfo( const SwPageFtnInfo &rCpy ) :
392 : 9917 : nMaxHeight( rCpy.GetHeight() ),
393 : : nLineWidth(rCpy.nLineWidth),
394 : : eLineStyle(rCpy.eLineStyle),
395 : : aLineColor(rCpy.aLineColor),
396 : 9917 : aWidth( rCpy.GetWidth() ),
397 : 9917 : eAdj( rCpy.GetAdj() ),
398 : 9917 : nTopDist( rCpy.GetTopDist() ),
399 : 19834 : nBottomDist( rCpy.GetBottomDist() )
400 : : {
401 : 9917 : }
402 : :
403 : : /*************************************************************************
404 : : |*
405 : : |* SwPageFtnInfo::operator=
406 : : |*
407 : : |*************************************************************************/
408 : :
409 : :
410 : :
411 : 1027 : SwPageFtnInfo &SwPageFtnInfo::operator=( const SwPageFtnInfo& rCpy )
412 : : {
413 : 1027 : nMaxHeight = rCpy.GetHeight();
414 : 1027 : nLineWidth = rCpy.nLineWidth;
415 : 1027 : eLineStyle = rCpy.eLineStyle;
416 : 1027 : aLineColor = rCpy.aLineColor;
417 : 1027 : aWidth = rCpy.GetWidth();
418 : 1027 : eAdj = rCpy.GetAdj();
419 : 1027 : nTopDist = rCpy.GetTopDist();
420 : 1027 : nBottomDist = rCpy.GetBottomDist();
421 : 1027 : return *this;
422 : : }
423 : : /*************************************************************************
424 : : |*
425 : : |* SwPageFtnInfo::operator==
426 : : |*
427 : : |*************************************************************************/
428 : :
429 : :
430 : :
431 : 3211 : sal_Bool SwPageFtnInfo::operator==( const SwPageFtnInfo& rCmp ) const
432 : : {
433 : 3211 : return ( nMaxHeight == rCmp.GetHeight() &&
434 : : nLineWidth == rCmp.nLineWidth &&
435 : : eLineStyle == rCmp.eLineStyle &&
436 : 2971 : aLineColor == rCmp.aLineColor &&
437 : 2971 : aWidth == rCmp.GetWidth() &&
438 : 2971 : eAdj == rCmp.GetAdj() &&
439 : 2971 : nTopDist == rCmp.GetTopDist() &&
440 [ + + ][ + + : 15095 : nBottomDist== rCmp.GetBottomDist() );
+ - + - +
- + - ]
[ + - ][ + - ]
441 : : }
442 : :
443 : 20 : SwPageDescExt::SwPageDescExt(const SwPageDesc & rPageDesc, SwDoc * _pDoc)
444 [ + - ]: 20 : : aPageDesc(rPageDesc), pDoc(_pDoc)
445 : : {
446 [ + - ]: 20 : SetPageDesc(rPageDesc);
447 : 20 : }
448 : :
449 : 0 : SwPageDescExt::SwPageDescExt(const SwPageDescExt & rSrc)
450 [ # # ]: 0 : : aPageDesc(rSrc.aPageDesc), pDoc(rSrc.pDoc)
451 : : {
452 [ # # ]: 0 : SetPageDesc(rSrc.aPageDesc);
453 : 0 : }
454 : :
455 [ + - ]: 20 : SwPageDescExt::~SwPageDescExt()
456 : : {
457 : 20 : }
458 : :
459 : 32 : const String & SwPageDescExt::GetName() const
460 : : {
461 : 32 : return aPageDesc.GetName();
462 : : }
463 : :
464 : 20 : void SwPageDescExt::SetPageDesc(const SwPageDesc & _aPageDesc)
465 : : {
466 : 20 : aPageDesc = _aPageDesc;
467 : :
468 [ + - ]: 20 : if (aPageDesc.GetFollow())
469 : 20 : sFollow = aPageDesc.GetFollow()->GetName();
470 : 20 : }
471 : :
472 : 0 : SwPageDescExt & SwPageDescExt::operator = (const SwPageDesc & rSrc)
473 : : {
474 : 0 : SetPageDesc(rSrc);
475 : :
476 : 0 : return *this;
477 : : }
478 : :
479 : 0 : SwPageDescExt & SwPageDescExt::operator = (const SwPageDescExt & rSrc)
480 : : {
481 : 0 : SetPageDesc(rSrc.aPageDesc);
482 : :
483 : 0 : return *this;
484 : : }
485 : :
486 : 0 : SwPageDescExt::operator SwPageDesc() const
487 : : {
488 : 0 : SwPageDesc aResult(aPageDesc);
489 : :
490 [ # # ]: 0 : SwPageDesc * pPageDesc = pDoc->GetPageDesc(sFollow);
491 : :
492 [ # # ]: 0 : if ( 0 != pPageDesc )
493 : 0 : aResult.SetFollow(pPageDesc);
494 : :
495 : 0 : return aResult;
496 : : }
497 : :
498 : 1458 : SwPageDescs::~SwPageDescs()
499 : : {
500 [ + - ][ # # ]: 1458 : for(const_iterator it = begin(); it != end(); ++it)
[ + - ][ - + ]
501 [ # # ][ # # ]: 0 : delete *it;
[ # # ]
502 : 1458 : }
503 : :
504 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|