tdf#143148 Use pragma once instead of include guards
[LibreOffice.git] / sw / source / core / layout / pagedesc.cxx
blobfa408703e8bdc20a110dc7f18fcd518959c3f4de
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <libxml/xmlwriter.h>
22 #include <editeng/pbinitem.hxx>
23 #include <editeng/ulspitem.hxx>
24 #include <editeng/boxitem.hxx>
25 #include <editeng/shaditem.hxx>
26 #include <editeng/frmdiritem.hxx>
27 #include <osl/diagnose.h>
28 #include <sal/log.hxx>
29 #include <fmtclds.hxx>
30 #include <fmtfsize.hxx>
31 #include <pagefrm.hxx>
32 #include <pagedesc.hxx>
33 #include <swtable.hxx>
34 #include <frmatr.hxx>
35 #include <frmtool.hxx>
36 #include <doc.hxx>
37 #include <node.hxx>
38 #include <strings.hrc>
39 #include <IDocumentLayoutAccess.hxx>
40 #include <IDocumentStylePoolAccess.hxx>
41 #include <poolfmt.hxx>
42 #include <calbck.hxx>
44 SwPageDesc::SwPageDesc(const OUString& rName, SwFrameFormat *pFormat, SwDoc *const pDoc)
45 : sw::BroadcastingModify()
46 , m_StyleName( rName )
47 , m_Master( pDoc->GetAttrPool(), rName, pFormat )
48 , m_Left( pDoc->GetAttrPool(), rName, pFormat )
49 , m_FirstMaster( pDoc->GetAttrPool(), rName, pFormat )
50 , m_FirstLeft( pDoc->GetAttrPool(), rName, pFormat )
51 , m_aStashedHeader()
52 , m_aStashedFooter()
53 , m_aDepends(*this)
54 , m_pTextFormatColl(nullptr)
55 , m_pFollow( this )
56 , m_nRegHeight( 0 )
57 , m_nRegAscent( 0 )
58 , m_nVerticalAdjustment( drawing::TextVerticalAdjust_TOP )
59 , m_eUse( UseOnPage::All | UseOnPage::HeaderShare | UseOnPage::FooterShare | UseOnPage::FirstShare )
60 , m_IsLandscape( false )
61 , m_IsHidden( false )
62 , m_pdList( nullptr )
66 SwPageDesc::SwPageDesc( const SwPageDesc &rCpy )
67 : sw::BroadcastingModify()
68 , m_StyleName( rCpy.GetName() )
69 , m_NumType( rCpy.GetNumType() )
70 , m_Master( rCpy.GetMaster() )
71 , m_Left( rCpy.GetLeft() )
72 , m_FirstMaster( rCpy.GetFirstMaster() )
73 , m_FirstLeft( rCpy.GetFirstLeft() )
74 , m_aDepends(*this)
75 , m_pTextFormatColl(nullptr)
76 , m_pFollow( rCpy.m_pFollow )
77 , m_nRegHeight( rCpy.GetRegHeight() )
78 , m_nRegAscent( rCpy.GetRegAscent() )
79 , m_nVerticalAdjustment( rCpy.GetVerticalAdjustment() )
80 , m_eUse( rCpy.ReadUseOn() )
81 , m_IsLandscape( rCpy.GetLandscape() )
82 , m_IsHidden( rCpy.IsHidden() )
83 , m_FootnoteInfo( rCpy.GetFootnoteInfo() )
84 , m_pdList( nullptr )
86 m_aStashedHeader.m_oStashedFirst = rCpy.m_aStashedHeader.m_oStashedFirst;
87 m_aStashedHeader.m_oStashedLeft = rCpy.m_aStashedHeader.m_oStashedLeft;
88 m_aStashedHeader.m_oStashedFirstLeft = rCpy.m_aStashedHeader.m_oStashedFirstLeft;
90 m_aStashedFooter.m_oStashedFirst = rCpy.m_aStashedFooter.m_oStashedFirst;
91 m_aStashedFooter.m_oStashedLeft = rCpy.m_aStashedFooter.m_oStashedLeft;
92 m_aStashedFooter.m_oStashedFirstLeft = rCpy.m_aStashedFooter.m_oStashedFirstLeft;
94 if (rCpy.m_pTextFormatColl && rCpy.m_aDepends.IsListeningTo(rCpy.m_pTextFormatColl))
96 m_pTextFormatColl = rCpy.m_pTextFormatColl;
97 m_aDepends.StartListening(const_cast<SwTextFormatColl*>(m_pTextFormatColl));
101 SwPageDesc & SwPageDesc::operator = (const SwPageDesc & rSrc)
103 if(this == &rSrc)
104 return *this;
106 m_StyleName = rSrc.m_StyleName;
107 m_NumType = rSrc.m_NumType;
108 m_Master = rSrc.m_Master;
109 m_Left = rSrc.m_Left;
110 m_FirstMaster = rSrc.m_FirstMaster;
111 m_FirstLeft = rSrc.m_FirstLeft;
113 m_aStashedHeader.m_oStashedFirst = rSrc.m_aStashedHeader.m_oStashedFirst;
114 m_aStashedHeader.m_oStashedLeft = rSrc.m_aStashedHeader.m_oStashedLeft;
115 m_aStashedHeader.m_oStashedFirstLeft = rSrc.m_aStashedHeader.m_oStashedFirstLeft;
117 m_aStashedFooter.m_oStashedFirst = rSrc.m_aStashedFooter.m_oStashedFirst;
118 m_aStashedFooter.m_oStashedLeft = rSrc.m_aStashedFooter.m_oStashedLeft;
119 m_aStashedFooter.m_oStashedFirstLeft = rSrc.m_aStashedFooter.m_oStashedFirstLeft;
121 m_aDepends.EndListeningAll();
122 if (rSrc.m_pTextFormatColl && rSrc.m_aDepends.IsListeningTo(rSrc.m_pTextFormatColl))
124 m_pTextFormatColl = rSrc.m_pTextFormatColl;
125 m_aDepends.StartListening(const_cast<SwTextFormatColl*>(m_pTextFormatColl));
127 else
128 m_pTextFormatColl = nullptr;
130 if (rSrc.m_pFollow == &rSrc)
131 m_pFollow = this;
132 else
133 m_pFollow = rSrc.m_pFollow;
135 m_nRegHeight = rSrc.m_nRegHeight;
136 m_nRegAscent = rSrc.m_nRegAscent;
137 m_nVerticalAdjustment = rSrc.m_nVerticalAdjustment;
138 m_eUse = rSrc.m_eUse;
139 m_IsLandscape = rSrc.m_IsLandscape;
140 return *this;
143 SwPageDesc::~SwPageDesc()
147 bool SwPageDesc::IsUsed() const
149 for(const auto pFrameFormat: { &GetMaster(), &GetLeft(), &GetFirstMaster(), &GetFirstLeft() })
150 if(pFrameFormat->IsUsed())
151 return true;
152 return false;
155 bool SwPageDesc::SetName( const OUString& rNewName )
157 bool renamed = true;
158 if (m_pdList) {
159 SwPageDescs::iterator it = m_pdList->find_( m_StyleName );
160 if( m_pdList->end() == it ) {
161 SAL_WARN( "sw", "SwPageDesc not found in expected m_pdList" );
162 return false;
164 renamed = m_pdList->m_PosIndex.modify( it,
165 change_name( rNewName ), change_name( m_StyleName ) );
167 else
168 m_StyleName = rNewName;
169 return renamed;
172 /// Only the margin is mirrored.
173 /// Attributes like borders and so on are copied 1:1.
174 void SwPageDesc::Mirror()
176 //Only the margins are mirrored, all other values are just copied.
177 SvxLRSpaceItem aLR( RES_LR_SPACE );
178 const SvxLRSpaceItem &rLR = m_Master.GetLRSpace();
179 aLR.SetLeft( rLR.GetRight() );
180 aLR.SetRight( rLR.GetLeft() );
181 aLR.SetRightGutterMargin(rLR.GetGutterMargin());
183 SfxItemSet aSet( *m_Master.GetAttrSet().GetPool(),
184 m_Master.GetAttrSet().GetRanges() );
185 aSet.Put( aLR );
186 aSet.Put( m_Master.GetFrameSize() );
187 aSet.Put( m_Master.GetPaperBin() );
188 aSet.Put( m_Master.GetULSpace() );
189 aSet.Put( m_Master.GetBox() );
190 aSet.Put( m_Master.makeBackgroundBrushItem() );
191 aSet.Put( m_Master.GetShadow() );
192 aSet.Put( m_Master.GetCol() );
193 aSet.Put( m_Master.GetFrameDir() );
194 m_Left.SetFormatAttr( aSet );
197 void SwPageDesc::ResetAllAttr()
199 SwFrameFormat& rFormat = GetMaster();
201 // #i73790# - method renamed
202 rFormat.ResetAllFormatAttr();
203 rFormat.SetFormatAttr( SvxFrameDirectionItem(SvxFrameDirection::Horizontal_LR_TB, RES_FRAMEDIR) );
206 // gets information from Modify
207 bool SwPageDesc::GetInfo( SwFindNearestNode & rInfo ) const
209 if (!m_Master.GetInfo(rInfo))
210 return false; // found
211 if (!m_Left.GetInfo(rInfo))
212 return false ;
213 if ( !m_FirstMaster.GetInfo( rInfo ) )
214 return false;
215 return m_FirstLeft.GetInfo( rInfo );
218 /// set the style for the grid alignment
219 void SwPageDesc::SetRegisterFormatColl(const SwTextFormatColl* pFormat)
221 if(pFormat != m_pTextFormatColl)
223 m_aDepends.EndListeningAll();
224 m_pTextFormatColl = pFormat;
225 m_aDepends.StartListening(const_cast<SwTextFormatColl*>(m_pTextFormatColl));
226 RegisterChange();
230 /// retrieve the style for the grid alignment
231 const SwTextFormatColl* SwPageDesc::GetRegisterFormatColl() const
233 if (!m_aDepends.IsListeningTo(m_pTextFormatColl))
234 m_pTextFormatColl = nullptr;
235 return m_pTextFormatColl;
238 /// notify all affected page frames
239 void SwPageDesc::RegisterChange()
241 // #117072# - During destruction of the document <SwDoc>
242 // the page description is modified. Thus, do nothing, if the document
243 // is in destruction respectively if no viewshell exists.
244 SwDoc* pDoc = GetMaster().GetDoc();
245 if ( !pDoc || pDoc->IsInDtor() )
247 return;
249 SwViewShell* pSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
250 if ( !pSh )
252 return;
255 m_nRegHeight = 0;
257 SwIterator<SwFrame,SwFormat> aIter( GetMaster() );
258 for( SwFrame* pLast = aIter.First(); pLast; pLast = aIter.Next() )
260 if( pLast->IsPageFrame() )
261 static_cast<SwPageFrame*>(pLast)->PrepareRegisterChg();
265 SwIterator<SwFrame,SwFormat> aIter( GetLeft() );
266 for( SwFrame* pLast = aIter.First(); pLast; pLast = aIter.Next() )
268 if( pLast->IsPageFrame() )
269 static_cast<SwPageFrame*>(pLast)->PrepareRegisterChg();
273 SwIterator<SwFrame,SwFormat> aIter( GetFirstMaster() );
274 for( SwFrame* pLast = aIter.First(); pLast; pLast = aIter.Next() )
276 if( pLast->IsPageFrame() )
277 static_cast<SwPageFrame*>(pLast)->PrepareRegisterChg();
281 SwIterator<SwFrame,SwFormat> aIter( GetFirstLeft() );
282 for( SwFrame* pLast = aIter.First(); pLast; pLast = aIter.Next() )
284 if( pLast->IsPageFrame() )
285 static_cast<SwPageFrame*>(pLast)->PrepareRegisterChg();
290 /// special handling if the style of the grid alignment changes
291 void SwPageDesc::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
293 if (rHint.GetId() == SfxHintId::SwLegacyModify)
295 auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
296 const sal_uInt16 nWhich = pLegacyHint->m_pOld
297 ? pLegacyHint->m_pOld->Which()
298 : pLegacyHint->m_pNew
299 ? pLegacyHint->m_pNew->Which()
300 : 0;
301 CallSwClientNotify(rHint);
302 if((RES_ATTRSET_CHG == nWhich)
303 || (RES_FMT_CHG == nWhich)
304 || isCHRATR(nWhich)
305 || (RES_PARATR_LINESPACING == nWhich))
306 RegisterChange();
308 else if(rHint.GetId() == SfxHintId::SwModifyChanged)
310 auto pModifyChangedHint = static_cast<const sw::ModifyChangedHint*>(&rHint);
311 if(m_pTextFormatColl == &rModify)
312 m_pTextFormatColl = static_cast<const SwTextFormatColl*>(pModifyChangedHint->m_pNew);
313 else
314 assert(false);
318 static const SwFrame* lcl_GetFrameOfNode( const SwNode& rNd )
320 const sw::BroadcastingModify* pMod;
321 SwFrameType nFrameType = FRM_CNTNT;
323 if( rNd.IsContentNode() )
325 pMod = &static_cast<const SwContentNode&>(rNd);
327 else if( rNd.IsTableNode() )
329 pMod = static_cast<const SwTableNode&>(rNd).GetTable().GetFrameFormat();
330 nFrameType = SwFrameType::Tab;
332 else
333 pMod = nullptr;
335 Point aNullPt;
336 std::pair<Point, bool> const tmp(aNullPt, false);
337 return pMod ? ::GetFrameOfModify(nullptr, *pMod, nFrameType, nullptr, &tmp)
338 : nullptr;
341 const SwPageDesc* SwPageDesc::GetPageDescOfNode(const SwNode& rNd)
343 const SwPageDesc* pRet = nullptr;
344 const SwFrame* pChkFrame = lcl_GetFrameOfNode( rNd );
345 if (pChkFrame && nullptr != (pChkFrame = pChkFrame->FindPageFrame()))
346 pRet = static_cast<const SwPageFrame*>(pChkFrame)->GetPageDesc();
347 return pRet;
350 const SwFrameFormat* SwPageDesc::GetPageFormatOfNode( const SwNode& rNd,
351 bool bCheckForThisPgDc ) const
353 // which PageDescFormat is valid for this node?
354 const SwFrameFormat* pRet;
355 const SwFrame* pChkFrame = lcl_GetFrameOfNode( rNd );
357 if( pChkFrame && nullptr != ( pChkFrame = pChkFrame->FindPageFrame() ))
359 const SwPageDesc* pPd = bCheckForThisPgDc ? this :
360 static_cast<const SwPageFrame*>(pChkFrame)->GetPageDesc();
361 pRet = &pPd->GetMaster();
362 OSL_ENSURE( static_cast<const SwPageFrame*>(pChkFrame)->GetPageDesc() == pPd, "Wrong node for detection of page format!" );
363 // this page is assigned to which format?
364 if( !pChkFrame->KnowsFormat(*pRet) )
366 pRet = &pPd->GetLeft();
367 OSL_ENSURE( pChkFrame->KnowsFormat(*pRet), "Wrong node for detection of page format!" );
370 else
371 pRet = &GetMaster();
372 return pRet;
375 bool SwPageDesc::IsFollowNextPageOfNode( const SwNode& rNd ) const
377 bool bRet = false;
378 if( GetFollow() && this != GetFollow() )
380 const SwFrame* pChkFrame = lcl_GetFrameOfNode( rNd );
381 if( pChkFrame && nullptr != ( pChkFrame = pChkFrame->FindPageFrame() ) &&
382 pChkFrame->IsPageFrame() &&
383 ( !pChkFrame->GetNext() || GetFollow() ==
384 static_cast<const SwPageFrame*>(pChkFrame->GetNext())->GetPageDesc() ))
385 // the page on which the follow points was found
386 bRet = true;
388 return bRet;
391 SwFrameFormat *SwPageDesc::GetLeftFormat(bool const bFirst)
393 return (UseOnPage::Left & m_eUse)
394 ? (bFirst ? &m_FirstLeft : &m_Left)
395 : nullptr;
398 SwFrameFormat *SwPageDesc::GetRightFormat(bool const bFirst)
400 return (UseOnPage::Right & m_eUse)
401 ? (bFirst ? &m_FirstMaster : &m_Master)
402 : nullptr;
405 bool SwPageDesc::IsFirstShared() const
407 return bool(m_eUse & UseOnPage::FirstShare);
410 void SwPageDesc::ChgFirstShare( bool bNew )
412 if ( bNew )
413 m_eUse |= UseOnPage::FirstShare;
414 else
415 m_eUse &= UseOnPage::NoFirstShare;
418 void SwPageDesc::StashFrameFormat(const SwFrameFormat& rFormat, bool bHeader, bool bLeft, bool bFirst)
420 assert(rFormat.GetRegisteredIn());
421 std::optional<SwFrameFormat>* pFormat = nullptr;
423 if (bHeader)
425 if (bLeft && !bFirst)
426 pFormat = &m_aStashedHeader.m_oStashedLeft;
427 else if (!bLeft && bFirst)
428 pFormat = &m_aStashedHeader.m_oStashedFirst;
429 else if (bLeft && bFirst)
430 pFormat = &m_aStashedHeader.m_oStashedFirstLeft;
432 else
434 if (bLeft && !bFirst)
435 pFormat = &m_aStashedFooter.m_oStashedLeft;
436 else if (!bLeft && bFirst)
437 pFormat = &m_aStashedFooter.m_oStashedFirst;
438 else if (bLeft && bFirst)
439 pFormat = &m_aStashedFooter.m_oStashedFirstLeft;
442 if (pFormat)
444 pFormat->emplace(rFormat);
446 else
448 SAL_WARN(
449 "sw",
450 "SwPageDesc::StashFrameFormat: Stashing the right page header/footer is pointless.");
454 const SwFrameFormat* SwPageDesc::GetStashedFrameFormat(bool bHeader, bool bLeft, bool bFirst) const
456 std::optional<SwFrameFormat>* pFormat = nullptr;
458 if (bLeft && !bFirst)
460 pFormat = bHeader ? &m_aStashedHeader.m_oStashedLeft : &m_aStashedFooter.m_oStashedLeft;
462 else if (!bLeft && bFirst)
464 pFormat = bHeader ? &m_aStashedHeader.m_oStashedFirst : &m_aStashedFooter.m_oStashedFirst;
466 else if (bLeft && bFirst)
468 pFormat = bHeader ? &m_aStashedHeader.m_oStashedFirstLeft : &m_aStashedFooter.m_oStashedFirstLeft;
471 if (pFormat)
473 return pFormat->has_value() ? &**pFormat : nullptr;
475 else
477 SAL_WARN("sw", "SwPageDesc::GetStashedFrameFormat: Right page format is never stashed.");
478 return nullptr;
482 bool SwPageDesc::HasStashedFormat(bool bHeader, bool bLeft, bool bFirst) const
484 if (bHeader)
486 if (bLeft && !bFirst)
488 return m_aStashedHeader.m_oStashedLeft.has_value();
490 else if (!bLeft && bFirst)
492 return m_aStashedHeader.m_oStashedFirst.has_value();
494 else if (bLeft && bFirst)
496 return m_aStashedHeader.m_oStashedFirstLeft.has_value();
498 else
500 SAL_WARN("sw", "SwPageDesc::HasStashedFormat: Right page format is never stashed.");
501 return false;
504 else
506 if (bLeft && !bFirst)
508 return m_aStashedFooter.m_oStashedLeft.has_value();
510 else if (!bLeft && bFirst)
512 return m_aStashedFooter.m_oStashedFirst.has_value();
514 else if (bLeft && bFirst)
516 return m_aStashedFooter.m_oStashedFirstLeft.has_value();
518 else
520 SAL_WARN("sw", "SwPageDesc::HasStashedFormat: Right page format is never stashed.");
521 return false;
526 void SwPageDesc::RemoveStashedFormat(bool bHeader, bool bLeft, bool bFirst)
528 if (bHeader)
530 if (bLeft && !bFirst)
532 m_aStashedHeader.m_oStashedLeft.reset();
534 else if (!bLeft && bFirst)
536 m_aStashedHeader.m_oStashedFirst.reset();
538 else if (bLeft && bFirst)
540 m_aStashedHeader.m_oStashedFirstLeft.reset();
542 else
544 SAL_WARN("sw", "SwPageDesc::RemoveStashedFormat: Right page format is never stashed.");
547 else
549 if (bLeft && !bFirst)
551 m_aStashedFooter.m_oStashedLeft.reset();
553 else if (!bLeft && bFirst)
555 m_aStashedFooter.m_oStashedFirst.reset();
557 else if (bLeft && bFirst)
559 m_aStashedFooter.m_oStashedFirstLeft.reset();
561 else
563 SAL_WARN("sw", "SwPageDesc::RemoveStashedFormat: Right page format is never stashed.");
568 // Page styles
569 const TranslateId STR_POOLPAGE[] =
571 STR_POOLPAGE_STANDARD,
572 STR_POOLPAGE_FIRST,
573 STR_POOLPAGE_LEFT,
574 STR_POOLPAGE_RIGHT,
575 STR_POOLPAGE_ENVELOPE,
576 STR_POOLPAGE_REGISTER,
577 STR_POOLPAGE_HTML,
578 STR_POOLPAGE_FOOTNOTE,
579 STR_POOLPAGE_ENDNOTE,
580 STR_POOLPAGE_LANDSCAPE
583 SwPageDesc* SwPageDesc::GetByName(SwDoc& rDoc, std::u16string_view rName)
585 const size_t nDCount = rDoc.GetPageDescCnt();
587 for( size_t i = 0; i < nDCount; i++ )
589 SwPageDesc* pDsc = &rDoc.GetPageDesc( i );
590 if(pDsc->GetName() == rName)
592 return pDsc;
596 for (size_t i = 0; i < SAL_N_ELEMENTS(STR_POOLPAGE); ++i)
598 if (rName == SwResId(STR_POOLPAGE[i]))
600 return rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool( static_cast< sal_uInt16 >(
601 i + RES_POOLPAGE_BEGIN) );
605 return nullptr;
608 void SwPageDesc::dumpAsXml(xmlTextWriterPtr pWriter) const
610 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwPageDesc"));
611 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
612 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("m_StyleName"), "%s",
613 BAD_CAST(m_StyleName.toUtf8().getStr()));
614 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("m_pFollow"), "%p", m_pFollow);
615 (void)xmlTextWriterWriteFormatAttribute(
616 pWriter, BAD_CAST("m_eUse"), "0x%s",
617 BAD_CAST(OString::number(static_cast<int>(m_eUse), 16).getStr()));
619 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_Master"));
620 m_Master.dumpAsXml(pWriter);
621 (void)xmlTextWriterEndElement(pWriter);
623 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_Left"));
624 m_Left.dumpAsXml(pWriter);
625 (void)xmlTextWriterEndElement(pWriter);
627 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_FirstMaster"));
628 m_FirstMaster.dumpAsXml(pWriter);
629 (void)xmlTextWriterEndElement(pWriter);
631 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_FirstLeft"));
632 m_FirstLeft.dumpAsXml(pWriter);
633 (void)xmlTextWriterEndElement(pWriter);
635 (void)xmlTextWriterEndElement(pWriter);
638 SwPageFootnoteInfo::SwPageFootnoteInfo()
639 : m_nMaxHeight( 0 )
640 , m_nLineWidth(10)
641 , m_eLineStyle( SvxBorderLineStyle::SOLID )
642 , m_Width( 25, 100 )
643 , m_nTopDist( 57 ) //1mm
644 , m_nBottomDist( 57 )
646 m_eAdjust = SvxFrameDirection::Horizontal_RL_TB == GetDefaultFrameDirection(GetAppLanguage()) ?
647 css::text::HorizontalAdjust_RIGHT :
648 css::text::HorizontalAdjust_LEFT;
651 SwPageFootnoteInfo::SwPageFootnoteInfo( const SwPageFootnoteInfo &rCpy )
652 : m_nMaxHeight(rCpy.GetHeight())
653 , m_nLineWidth(rCpy.m_nLineWidth)
654 , m_eLineStyle(rCpy.m_eLineStyle)
655 , m_LineColor(rCpy.m_LineColor)
656 , m_Width(rCpy.GetWidth())
657 , m_eAdjust(rCpy.GetAdj())
658 , m_nTopDist(rCpy.GetTopDist())
659 , m_nBottomDist(rCpy.GetBottomDist())
663 SwPageFootnoteInfo &SwPageFootnoteInfo::operator=( const SwPageFootnoteInfo& rCpy )
665 m_nMaxHeight = rCpy.GetHeight();
666 m_nLineWidth = rCpy.m_nLineWidth;
667 m_eLineStyle = rCpy.m_eLineStyle;
668 m_LineColor = rCpy.m_LineColor;
669 m_Width = rCpy.GetWidth();
670 m_eAdjust = rCpy.GetAdj();
671 m_nTopDist = rCpy.GetTopDist();
672 m_nBottomDist = rCpy.GetBottomDist();
673 return *this;
676 bool SwPageFootnoteInfo::operator==( const SwPageFootnoteInfo& rCmp ) const
678 return m_nMaxHeight == rCmp.GetHeight()
679 && m_nLineWidth == rCmp.m_nLineWidth
680 && m_eLineStyle == rCmp.m_eLineStyle
681 && m_LineColor == rCmp.m_LineColor
682 && m_Width == rCmp.GetWidth()
683 && m_eAdjust == rCmp.GetAdj()
684 && m_nTopDist == rCmp.GetTopDist()
685 && m_nBottomDist== rCmp.GetBottomDist();
688 SwPageDescExt::SwPageDescExt(const SwPageDesc & rPageDesc, SwDoc *const pDoc)
689 : m_PageDesc(rPageDesc)
690 , m_pDoc(pDoc)
692 SetPageDesc(rPageDesc);
695 SwPageDescExt::SwPageDescExt(const SwPageDescExt & rSrc)
696 : m_PageDesc(rSrc.m_PageDesc)
697 , m_pDoc(rSrc.m_pDoc)
699 SetPageDesc(rSrc.m_PageDesc);
702 SwPageDescExt::~SwPageDescExt()
706 OUString const & SwPageDescExt::GetName() const
708 return m_PageDesc.GetName();
711 void SwPageDescExt::SetPageDesc(const SwPageDesc & rPageDesc)
713 m_PageDesc = rPageDesc;
715 if (m_PageDesc.GetFollow())
716 m_sFollow = m_PageDesc.GetFollow()->GetName();
719 SwPageDescExt & SwPageDescExt::operator = (const SwPageDesc & rSrc)
721 SetPageDesc(rSrc);
723 return *this;
726 SwPageDescExt & SwPageDescExt::operator = (const SwPageDescExt & rSrc)
728 operator=(rSrc.m_PageDesc);
729 return *this;
732 SwPageDescExt::operator SwPageDesc() const
734 SwPageDesc aResult(m_PageDesc);
736 SwPageDesc * pPageDesc = m_pDoc->FindPageDesc(m_sFollow);
738 if ( nullptr != pPageDesc )
739 aResult.SetFollow(pPageDesc);
741 return aResult;
744 SwPageDescs::SwPageDescs()
745 : m_PosIndex( m_Array.get<0>() )
746 , m_NameIndex( m_Array.get<1>() )
750 SwPageDescs::~SwPageDescs()
752 for(const_iterator it = begin(); it != end(); ++it)
753 delete *it;
756 SwPageDescs::iterator SwPageDescs::find_(const OUString &name) const
758 ByName::iterator it = m_NameIndex.find( name );
759 return m_Array.iterator_to( *it );
762 std::pair<SwPageDescs::const_iterator,bool> SwPageDescs::push_back( const value_type& x )
764 // SwPageDesc is not already in a SwPageDescs list!
765 assert( x->m_pdList == nullptr );
767 std::pair<iterator,bool> res = m_PosIndex.push_back( x );
768 if( res.second )
769 x->m_pdList = this;
770 return res;
773 void SwPageDescs::erase( const value_type& x )
775 // SwPageDesc is not in this SwPageDescs list!
776 assert( x->m_pdList == this );
778 iterator const ret = find_( x->GetName() );
779 if (ret != end())
780 m_PosIndex.erase( ret );
781 else
782 SAL_WARN( "sw", "SwPageDesc is not in SwPageDescs m_pdList!" );
783 x->m_pdList = nullptr;
786 void SwPageDescs::erase( const_iterator const& position )
788 // SwPageDesc is not in this SwPageDescs list!
789 assert( (*position)->m_pdList == this );
791 (*position)->m_pdList = nullptr;
792 m_PosIndex.erase( position );
795 void SwPageDescs::erase( size_type index_ )
797 erase( begin() + index_ );
800 void SwPageDescs::dumpAsXml(xmlTextWriterPtr pWriter) const
802 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwPageDescs"));
804 for (const auto& pPageDesc : m_PosIndex)
806 pPageDesc->dumpAsXml(pWriter);
809 (void)xmlTextWriterEndElement(pWriter);
812 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */