enable spotlight subset in kit mode
[LibreOffice.git] / sw / source / core / layout / pagedesc.cxx
blobf2a80346785140567d9931da219a187d0bd79e4e
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::SwFormatChange || rHint.GetId() == SfxHintId::SwAttrSetChange)
295 CallSwClientNotify(rHint);
296 RegisterChange();
298 else if (rHint.GetId() == SfxHintId::SwObjectDying
299 || rHint.GetId() == SfxHintId::SwUpdateAttr)
301 CallSwClientNotify(rHint);
303 else if (rHint.GetId() == SfxHintId::SwLegacyModify)
305 auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
306 const sal_uInt16 nWhich = pLegacyHint->m_pOld
307 ? pLegacyHint->m_pOld->Which()
308 : pLegacyHint->m_pNew
309 ? pLegacyHint->m_pNew->Which()
310 : 0;
311 CallSwClientNotify(rHint);
312 if(isCHRATR(nWhich)
313 || (RES_PARATR_LINESPACING == nWhich))
314 RegisterChange();
316 else if(rHint.GetId() == SfxHintId::SwModifyChanged)
318 auto pModifyChangedHint = static_cast<const sw::ModifyChangedHint*>(&rHint);
319 if(m_pTextFormatColl == &rModify)
320 m_pTextFormatColl = static_cast<const SwTextFormatColl*>(pModifyChangedHint->m_pNew);
321 else
322 assert(false);
326 static const SwFrame* lcl_GetFrameOfNode( const SwNode& rNd )
328 const sw::BroadcastingModify* pMod;
329 SwFrameType nFrameType = FRM_CNTNT;
331 if( rNd.IsContentNode() )
333 pMod = &static_cast<const SwContentNode&>(rNd);
335 else if( rNd.IsTableNode() )
337 pMod = static_cast<const SwTableNode&>(rNd).GetTable().GetFrameFormat();
338 nFrameType = SwFrameType::Tab;
340 else
341 pMod = nullptr;
343 Point aNullPt;
344 std::pair<Point, bool> const tmp(aNullPt, false);
345 return pMod ? ::GetFrameOfModify(nullptr, *pMod, nFrameType, nullptr, &tmp)
346 : nullptr;
349 const SwPageDesc* SwPageDesc::GetPageDescOfNode(const SwNode& rNd)
351 const SwPageDesc* pRet = nullptr;
352 const SwFrame* pChkFrame = lcl_GetFrameOfNode( rNd );
353 if (pChkFrame && nullptr != (pChkFrame = pChkFrame->FindPageFrame()))
354 pRet = static_cast<const SwPageFrame*>(pChkFrame)->GetPageDesc();
355 return pRet;
358 const SwFrameFormat* SwPageDesc::GetPageFormatOfNode( const SwNode& rNd,
359 bool bCheckForThisPgDc ) const
361 // which PageDescFormat is valid for this node?
362 const SwFrameFormat* pRet;
363 const SwFrame* pChkFrame = lcl_GetFrameOfNode( rNd );
365 if( pChkFrame && nullptr != ( pChkFrame = pChkFrame->FindPageFrame() ))
367 const SwPageDesc* pPd = bCheckForThisPgDc ? this :
368 static_cast<const SwPageFrame*>(pChkFrame)->GetPageDesc();
369 pRet = &pPd->GetMaster();
370 OSL_ENSURE( static_cast<const SwPageFrame*>(pChkFrame)->GetPageDesc() == pPd, "Wrong node for detection of page format!" );
371 // this page is assigned to which format?
372 if( !pChkFrame->KnowsFormat(*pRet) )
374 pRet = &pPd->GetLeft();
375 OSL_ENSURE( pChkFrame->KnowsFormat(*pRet), "Wrong node for detection of page format!" );
378 else
379 pRet = &GetMaster();
380 return pRet;
383 bool SwPageDesc::IsFollowNextPageOfNode( const SwNode& rNd ) const
385 bool bRet = false;
386 if( GetFollow() && this != GetFollow() )
388 const SwFrame* pChkFrame = lcl_GetFrameOfNode( rNd );
389 if( pChkFrame && nullptr != ( pChkFrame = pChkFrame->FindPageFrame() ) &&
390 pChkFrame->IsPageFrame() &&
391 ( !pChkFrame->GetNext() || GetFollow() ==
392 static_cast<const SwPageFrame*>(pChkFrame->GetNext())->GetPageDesc() ))
393 // the page on which the follow points was found
394 bRet = true;
396 return bRet;
399 SwFrameFormat *SwPageDesc::GetLeftFormat(bool const bFirst)
401 return (UseOnPage::Left & m_eUse)
402 ? (bFirst ? &m_FirstLeft : &m_Left)
403 : nullptr;
406 SwFrameFormat *SwPageDesc::GetRightFormat(bool const bFirst)
408 return (UseOnPage::Right & m_eUse)
409 ? (bFirst ? &m_FirstMaster : &m_Master)
410 : nullptr;
413 bool SwPageDesc::IsFirstShared() const
415 return bool(m_eUse & UseOnPage::FirstShare);
418 void SwPageDesc::ChgFirstShare( bool bNew )
420 if ( bNew )
421 m_eUse |= UseOnPage::FirstShare;
422 else
423 m_eUse &= UseOnPage::NoFirstShare;
426 void SwPageDesc::StashFrameFormat(const SwFrameFormat& rFormat, bool bHeader, bool bLeft, bool bFirst)
428 assert(rFormat.GetRegisteredIn());
429 std::optional<SwFrameFormat>* pFormat = nullptr;
431 if (bHeader)
433 if (bLeft && !bFirst)
434 pFormat = &m_aStashedHeader.m_oStashedLeft;
435 else if (!bLeft && bFirst)
436 pFormat = &m_aStashedHeader.m_oStashedFirst;
437 else if (bLeft && bFirst)
438 pFormat = &m_aStashedHeader.m_oStashedFirstLeft;
440 else
442 if (bLeft && !bFirst)
443 pFormat = &m_aStashedFooter.m_oStashedLeft;
444 else if (!bLeft && bFirst)
445 pFormat = &m_aStashedFooter.m_oStashedFirst;
446 else if (bLeft && bFirst)
447 pFormat = &m_aStashedFooter.m_oStashedFirstLeft;
450 if (pFormat)
452 pFormat->emplace(rFormat);
454 else
456 SAL_WARN(
457 "sw",
458 "SwPageDesc::StashFrameFormat: Stashing the right page header/footer is pointless.");
462 const SwFrameFormat* SwPageDesc::GetStashedFrameFormat(bool bHeader, bool bLeft, bool bFirst) const
464 std::optional<SwFrameFormat>* pFormat = nullptr;
466 if (bLeft && !bFirst)
468 pFormat = bHeader ? &m_aStashedHeader.m_oStashedLeft : &m_aStashedFooter.m_oStashedLeft;
470 else if (!bLeft && bFirst)
472 pFormat = bHeader ? &m_aStashedHeader.m_oStashedFirst : &m_aStashedFooter.m_oStashedFirst;
474 else if (bLeft && bFirst)
476 pFormat = bHeader ? &m_aStashedHeader.m_oStashedFirstLeft : &m_aStashedFooter.m_oStashedFirstLeft;
479 if (pFormat)
481 return pFormat->has_value() ? &**pFormat : nullptr;
483 else
485 SAL_WARN("sw", "SwPageDesc::GetStashedFrameFormat: Right page format is never stashed.");
486 return nullptr;
490 bool SwPageDesc::HasStashedFormat(bool bHeader, bool bLeft, bool bFirst) const
492 if (bHeader)
494 if (bLeft && !bFirst)
496 return m_aStashedHeader.m_oStashedLeft.has_value();
498 else if (!bLeft && bFirst)
500 return m_aStashedHeader.m_oStashedFirst.has_value();
502 else if (bLeft && bFirst)
504 return m_aStashedHeader.m_oStashedFirstLeft.has_value();
506 else
508 SAL_WARN("sw", "SwPageDesc::HasStashedFormat: Right page format is never stashed.");
509 return false;
512 else
514 if (bLeft && !bFirst)
516 return m_aStashedFooter.m_oStashedLeft.has_value();
518 else if (!bLeft && bFirst)
520 return m_aStashedFooter.m_oStashedFirst.has_value();
522 else if (bLeft && bFirst)
524 return m_aStashedFooter.m_oStashedFirstLeft.has_value();
526 else
528 SAL_WARN("sw", "SwPageDesc::HasStashedFormat: Right page format is never stashed.");
529 return false;
534 void SwPageDesc::RemoveStashedFormat(bool bHeader, bool bLeft, bool bFirst)
536 if (bHeader)
538 if (bLeft && !bFirst)
540 m_aStashedHeader.m_oStashedLeft.reset();
542 else if (!bLeft && bFirst)
544 m_aStashedHeader.m_oStashedFirst.reset();
546 else if (bLeft && bFirst)
548 m_aStashedHeader.m_oStashedFirstLeft.reset();
550 else
552 SAL_WARN("sw", "SwPageDesc::RemoveStashedFormat: Right page format is never stashed.");
555 else
557 if (bLeft && !bFirst)
559 m_aStashedFooter.m_oStashedLeft.reset();
561 else if (!bLeft && bFirst)
563 m_aStashedFooter.m_oStashedFirst.reset();
565 else if (bLeft && bFirst)
567 m_aStashedFooter.m_oStashedFirstLeft.reset();
569 else
571 SAL_WARN("sw", "SwPageDesc::RemoveStashedFormat: Right page format is never stashed.");
576 // Page styles
577 const TranslateId STR_POOLPAGE[] =
579 STR_POOLPAGE_STANDARD,
580 STR_POOLPAGE_FIRST,
581 STR_POOLPAGE_LEFT,
582 STR_POOLPAGE_RIGHT,
583 STR_POOLPAGE_ENVELOPE,
584 STR_POOLPAGE_REGISTER,
585 STR_POOLPAGE_HTML,
586 STR_POOLPAGE_FOOTNOTE,
587 STR_POOLPAGE_ENDNOTE,
588 STR_POOLPAGE_LANDSCAPE
591 SwPageDesc* SwPageDesc::GetByName(SwDoc& rDoc, std::u16string_view rName)
593 const size_t nDCount = rDoc.GetPageDescCnt();
595 for( size_t i = 0; i < nDCount; i++ )
597 SwPageDesc* pDsc = &rDoc.GetPageDesc( i );
598 if(pDsc->GetName() == rName)
600 return pDsc;
604 for (size_t i = 0; i < SAL_N_ELEMENTS(STR_POOLPAGE); ++i)
606 if (rName == SwResId(STR_POOLPAGE[i]))
608 return rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool( static_cast< sal_uInt16 >(
609 i + RES_POOLPAGE_BEGIN) );
613 return nullptr;
616 void SwPageDesc::dumpAsXml(xmlTextWriterPtr pWriter) const
618 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwPageDesc"));
619 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
620 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("m_StyleName"), "%s",
621 BAD_CAST(m_StyleName.toUtf8().getStr()));
622 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("m_pFollow"), "%p", m_pFollow);
623 (void)xmlTextWriterWriteFormatAttribute(
624 pWriter, BAD_CAST("m_eUse"), "0x%s",
625 BAD_CAST(OString::number(static_cast<int>(m_eUse), 16).getStr()));
627 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_Master"));
628 m_Master.dumpAsXml(pWriter);
629 (void)xmlTextWriterEndElement(pWriter);
631 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_Left"));
632 m_Left.dumpAsXml(pWriter);
633 (void)xmlTextWriterEndElement(pWriter);
635 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_FirstMaster"));
636 m_FirstMaster.dumpAsXml(pWriter);
637 (void)xmlTextWriterEndElement(pWriter);
639 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_FirstLeft"));
640 m_FirstLeft.dumpAsXml(pWriter);
641 (void)xmlTextWriterEndElement(pWriter);
643 (void)xmlTextWriterEndElement(pWriter);
646 SwPageFootnoteInfo::SwPageFootnoteInfo()
647 : m_nMaxHeight( 0 )
648 , m_nLineWidth(10)
649 , m_eLineStyle( SvxBorderLineStyle::SOLID )
650 , m_Width( 25, 100 )
651 , m_nTopDist( 57 ) //1mm
652 , m_nBottomDist( 57 )
654 m_eAdjust = SvxFrameDirection::Horizontal_RL_TB == GetDefaultFrameDirection(GetAppLanguage()) ?
655 css::text::HorizontalAdjust_RIGHT :
656 css::text::HorizontalAdjust_LEFT;
659 SwPageFootnoteInfo::SwPageFootnoteInfo( const SwPageFootnoteInfo &rCpy )
660 : m_nMaxHeight(rCpy.GetHeight())
661 , m_nLineWidth(rCpy.m_nLineWidth)
662 , m_eLineStyle(rCpy.m_eLineStyle)
663 , m_LineColor(rCpy.m_LineColor)
664 , m_Width(rCpy.GetWidth())
665 , m_eAdjust(rCpy.GetAdj())
666 , m_nTopDist(rCpy.GetTopDist())
667 , m_nBottomDist(rCpy.GetBottomDist())
671 SwPageFootnoteInfo &SwPageFootnoteInfo::operator=( const SwPageFootnoteInfo& rCpy )
673 m_nMaxHeight = rCpy.GetHeight();
674 m_nLineWidth = rCpy.m_nLineWidth;
675 m_eLineStyle = rCpy.m_eLineStyle;
676 m_LineColor = rCpy.m_LineColor;
677 m_Width = rCpy.GetWidth();
678 m_eAdjust = rCpy.GetAdj();
679 m_nTopDist = rCpy.GetTopDist();
680 m_nBottomDist = rCpy.GetBottomDist();
681 return *this;
684 bool SwPageFootnoteInfo::operator==( const SwPageFootnoteInfo& rCmp ) const
686 return m_nMaxHeight == rCmp.GetHeight()
687 && m_nLineWidth == rCmp.m_nLineWidth
688 && m_eLineStyle == rCmp.m_eLineStyle
689 && m_LineColor == rCmp.m_LineColor
690 && m_Width == rCmp.GetWidth()
691 && m_eAdjust == rCmp.GetAdj()
692 && m_nTopDist == rCmp.GetTopDist()
693 && m_nBottomDist== rCmp.GetBottomDist();
696 SwPageDescExt::SwPageDescExt(const SwPageDesc & rPageDesc, SwDoc *const pDoc)
697 : m_PageDesc(rPageDesc)
698 , m_pDoc(pDoc)
700 SetPageDesc(rPageDesc);
703 SwPageDescExt::SwPageDescExt(const SwPageDescExt & rSrc)
704 : m_PageDesc(rSrc.m_PageDesc)
705 , m_pDoc(rSrc.m_pDoc)
707 SetPageDesc(rSrc.m_PageDesc);
710 SwPageDescExt::~SwPageDescExt()
714 OUString const & SwPageDescExt::GetName() const
716 return m_PageDesc.GetName();
719 void SwPageDescExt::SetPageDesc(const SwPageDesc & rPageDesc)
721 m_PageDesc = rPageDesc;
723 if (m_PageDesc.GetFollow())
724 m_sFollow = m_PageDesc.GetFollow()->GetName();
727 SwPageDescExt & SwPageDescExt::operator = (const SwPageDesc & rSrc)
729 SetPageDesc(rSrc);
731 return *this;
734 SwPageDescExt & SwPageDescExt::operator = (const SwPageDescExt & rSrc)
736 operator=(rSrc.m_PageDesc);
737 return *this;
740 SwPageDescExt::operator SwPageDesc() const
742 SwPageDesc aResult(m_PageDesc);
744 SwPageDesc * pPageDesc = m_pDoc->FindPageDesc(m_sFollow);
746 if ( nullptr != pPageDesc )
747 aResult.SetFollow(pPageDesc);
749 return aResult;
752 SwPageDescs::SwPageDescs()
753 : m_PosIndex( m_Array.get<0>() )
754 , m_NameIndex( m_Array.get<1>() )
758 SwPageDescs::~SwPageDescs()
760 for(const_iterator it = begin(); it != end(); ++it)
761 delete *it;
764 SwPageDescs::iterator SwPageDescs::find_(const OUString &name) const
766 ByName::iterator it = m_NameIndex.find( name );
767 return m_Array.iterator_to( *it );
770 std::pair<SwPageDescs::const_iterator,bool> SwPageDescs::push_back( const value_type& x )
772 // SwPageDesc is not already in a SwPageDescs list!
773 assert( x->m_pdList == nullptr );
775 std::pair<iterator,bool> res = m_PosIndex.push_back( x );
776 if( res.second )
777 x->m_pdList = this;
778 return res;
781 void SwPageDescs::erase( const value_type& x )
783 // SwPageDesc is not in this SwPageDescs list!
784 assert( x->m_pdList == this );
786 iterator const ret = find_( x->GetName() );
787 if (ret != end())
788 m_PosIndex.erase( ret );
789 else
790 SAL_WARN( "sw", "SwPageDesc is not in SwPageDescs m_pdList!" );
791 x->m_pdList = nullptr;
794 void SwPageDescs::erase( const_iterator const& position )
796 // SwPageDesc is not in this SwPageDescs list!
797 assert( (*position)->m_pdList == this );
799 (*position)->m_pdList = nullptr;
800 m_PosIndex.erase( position );
803 void SwPageDescs::erase( size_type index_ )
805 erase( begin() + index_ );
808 void SwPageDescs::dumpAsXml(xmlTextWriterPtr pWriter) const
810 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwPageDescs"));
812 for (const auto& pPageDesc : m_PosIndex)
814 pPageDesc->dumpAsXml(pWriter);
817 (void)xmlTextWriterEndElement(pWriter);
820 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */