android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / layout / pagedesc.cxx
blobd93b47517e5b2a425174b57081076d43f0893f4a
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_pStashedFirst = rCpy.m_aStashedHeader.m_pStashedFirst;
87 m_aStashedHeader.m_pStashedLeft = rCpy.m_aStashedHeader.m_pStashedLeft;
88 m_aStashedHeader.m_pStashedFirstLeft = rCpy.m_aStashedHeader.m_pStashedFirstLeft;
90 m_aStashedFooter.m_pStashedFirst = rCpy.m_aStashedFooter.m_pStashedFirst;
91 m_aStashedFooter.m_pStashedLeft = rCpy.m_aStashedFooter.m_pStashedLeft;
92 m_aStashedFooter.m_pStashedFirstLeft = rCpy.m_aStashedFooter.m_pStashedFirstLeft;
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_pStashedFirst = rSrc.m_aStashedHeader.m_pStashedFirst;
114 m_aStashedHeader.m_pStashedLeft = rSrc.m_aStashedHeader.m_pStashedLeft;
115 m_aStashedHeader.m_pStashedFirstLeft = rSrc.m_aStashedHeader.m_pStashedFirstLeft;
117 m_aStashedFooter.m_pStashedFirst = rSrc.m_aStashedFooter.m_pStashedFirst;
118 m_aStashedFooter.m_pStashedLeft = rSrc.m_aStashedFooter.m_pStashedLeft;
119 m_aStashedFooter.m_pStashedFirstLeft = rSrc.m_aStashedFooter.m_pStashedFirstLeft;
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::SetName( const OUString& rNewName )
149 bool renamed = true;
150 if (m_pdList) {
151 SwPageDescs::iterator it = m_pdList->find_( m_StyleName );
152 if( m_pdList->end() == it ) {
153 SAL_WARN( "sw", "SwPageDesc not found in expected m_pdList" );
154 return false;
156 renamed = m_pdList->m_PosIndex.modify( it,
157 change_name( rNewName ), change_name( m_StyleName ) );
159 else
160 m_StyleName = rNewName;
161 return renamed;
164 /// Only the margin is mirrored.
165 /// Attributes like borders and so on are copied 1:1.
166 void SwPageDesc::Mirror()
168 //Only the margins are mirrored, all other values are just copied.
169 SvxLRSpaceItem aLR( RES_LR_SPACE );
170 const SvxLRSpaceItem &rLR = m_Master.GetLRSpace();
171 aLR.SetLeft( rLR.GetRight() );
172 aLR.SetRight( rLR.GetLeft() );
173 aLR.SetRightGutterMargin(rLR.GetGutterMargin());
175 SfxItemSet aSet( *m_Master.GetAttrSet().GetPool(),
176 m_Master.GetAttrSet().GetRanges() );
177 aSet.Put( aLR );
178 aSet.Put( m_Master.GetFrameSize() );
179 aSet.Put( m_Master.GetPaperBin() );
180 aSet.Put( m_Master.GetULSpace() );
181 aSet.Put( m_Master.GetBox() );
182 aSet.Put( m_Master.makeBackgroundBrushItem() );
183 aSet.Put( m_Master.GetShadow() );
184 aSet.Put( m_Master.GetCol() );
185 aSet.Put( m_Master.GetFrameDir() );
186 m_Left.SetFormatAttr( aSet );
189 void SwPageDesc::ResetAllAttr()
191 SwFrameFormat& rFormat = GetMaster();
193 // #i73790# - method renamed
194 rFormat.ResetAllFormatAttr();
195 rFormat.SetFormatAttr( SvxFrameDirectionItem(SvxFrameDirection::Horizontal_LR_TB, RES_FRAMEDIR) );
198 // gets information from Modify
199 bool SwPageDesc::GetInfo( SfxPoolItem & rInfo ) const
201 if (!m_Master.GetInfo(rInfo))
202 return false; // found
203 if (!m_Left.GetInfo(rInfo))
204 return false ;
205 if ( !m_FirstMaster.GetInfo( rInfo ) )
206 return false;
207 return m_FirstLeft.GetInfo( rInfo );
210 /// set the style for the grid alignment
211 void SwPageDesc::SetRegisterFormatColl(const SwTextFormatColl* pFormat)
213 if(pFormat != m_pTextFormatColl)
215 m_aDepends.EndListeningAll();
216 m_pTextFormatColl = pFormat;
217 m_aDepends.StartListening(const_cast<SwTextFormatColl*>(m_pTextFormatColl));
218 RegisterChange();
222 /// retrieve the style for the grid alignment
223 const SwTextFormatColl* SwPageDesc::GetRegisterFormatColl() const
225 if (!m_aDepends.IsListeningTo(m_pTextFormatColl))
226 m_pTextFormatColl = nullptr;
227 return m_pTextFormatColl;
230 /// notify all affected page frames
231 void SwPageDesc::RegisterChange()
233 // #117072# - During destruction of the document <SwDoc>
234 // the page description is modified. Thus, do nothing, if the document
235 // is in destruction respectively if no viewshell exists.
236 SwDoc* pDoc = GetMaster().GetDoc();
237 if ( !pDoc || pDoc->IsInDtor() )
239 return;
241 SwViewShell* pSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
242 if ( !pSh )
244 return;
247 m_nRegHeight = 0;
249 SwIterator<SwFrame,SwFormat> aIter( GetMaster() );
250 for( SwFrame* pLast = aIter.First(); pLast; pLast = aIter.Next() )
252 if( pLast->IsPageFrame() )
253 static_cast<SwPageFrame*>(pLast)->PrepareRegisterChg();
257 SwIterator<SwFrame,SwFormat> aIter( GetLeft() );
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( GetFirstMaster() );
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( GetFirstLeft() );
274 for( SwFrame* pLast = aIter.First(); pLast; pLast = aIter.Next() )
276 if( pLast->IsPageFrame() )
277 static_cast<SwPageFrame*>(pLast)->PrepareRegisterChg();
282 /// special handling if the style of the grid alignment changes
283 void SwPageDesc::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
285 if (rHint.GetId() == SfxHintId::SwLegacyModify)
287 auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&rHint);
288 const sal_uInt16 nWhich = pLegacyHint->m_pOld
289 ? pLegacyHint->m_pOld->Which()
290 : pLegacyHint->m_pNew
291 ? pLegacyHint->m_pNew->Which()
292 : 0;
293 CallSwClientNotify(rHint);
294 if((RES_ATTRSET_CHG == nWhich)
295 || (RES_FMT_CHG == nWhich)
296 || isCHRATR(nWhich)
297 || (RES_PARATR_LINESPACING == nWhich))
298 RegisterChange();
300 else if (auto pModifyChangedHint = dynamic_cast<const sw::ModifyChangedHint*>(&rHint))
302 if(m_pTextFormatColl == &rModify)
303 m_pTextFormatColl = static_cast<const SwTextFormatColl*>(pModifyChangedHint->m_pNew);
304 else
305 assert(false);
309 static const SwFrame* lcl_GetFrameOfNode( const SwNode& rNd )
311 const sw::BroadcastingModify* pMod;
312 SwFrameType nFrameType = FRM_CNTNT;
314 if( rNd.IsContentNode() )
316 pMod = &static_cast<const SwContentNode&>(rNd);
318 else if( rNd.IsTableNode() )
320 pMod = static_cast<const SwTableNode&>(rNd).GetTable().GetFrameFormat();
321 nFrameType = SwFrameType::Tab;
323 else
324 pMod = nullptr;
326 Point aNullPt;
327 std::pair<Point, bool> const tmp(aNullPt, false);
328 return pMod ? ::GetFrameOfModify(nullptr, *pMod, nFrameType, nullptr, &tmp)
329 : nullptr;
332 const SwPageDesc* SwPageDesc::GetPageDescOfNode(const SwNode& rNd)
334 const SwPageDesc* pRet = nullptr;
335 const SwFrame* pChkFrame = lcl_GetFrameOfNode( rNd );
336 if (pChkFrame && nullptr != (pChkFrame = pChkFrame->FindPageFrame()))
337 pRet = static_cast<const SwPageFrame*>(pChkFrame)->GetPageDesc();
338 return pRet;
341 const SwFrameFormat* SwPageDesc::GetPageFormatOfNode( const SwNode& rNd,
342 bool bCheckForThisPgDc ) const
344 // which PageDescFormat is valid for this node?
345 const SwFrameFormat* pRet;
346 const SwFrame* pChkFrame = lcl_GetFrameOfNode( rNd );
348 if( pChkFrame && nullptr != ( pChkFrame = pChkFrame->FindPageFrame() ))
350 const SwPageDesc* pPd = bCheckForThisPgDc ? this :
351 static_cast<const SwPageFrame*>(pChkFrame)->GetPageDesc();
352 pRet = &pPd->GetMaster();
353 OSL_ENSURE( static_cast<const SwPageFrame*>(pChkFrame)->GetPageDesc() == pPd, "Wrong node for detection of page format!" );
354 // this page is assigned to which format?
355 if( !pChkFrame->KnowsFormat(*pRet) )
357 pRet = &pPd->GetLeft();
358 OSL_ENSURE( pChkFrame->KnowsFormat(*pRet), "Wrong node for detection of page format!" );
361 else
362 pRet = &GetMaster();
363 return pRet;
366 bool SwPageDesc::IsFollowNextPageOfNode( const SwNode& rNd ) const
368 bool bRet = false;
369 if( GetFollow() && this != GetFollow() )
371 const SwFrame* pChkFrame = lcl_GetFrameOfNode( rNd );
372 if( pChkFrame && nullptr != ( pChkFrame = pChkFrame->FindPageFrame() ) &&
373 pChkFrame->IsPageFrame() &&
374 ( !pChkFrame->GetNext() || GetFollow() ==
375 static_cast<const SwPageFrame*>(pChkFrame->GetNext())->GetPageDesc() ))
376 // the page on which the follow points was found
377 bRet = true;
379 return bRet;
382 SwFrameFormat *SwPageDesc::GetLeftFormat(bool const bFirst)
384 return (UseOnPage::Left & m_eUse)
385 ? (bFirst ? &m_FirstLeft : &m_Left)
386 : nullptr;
389 SwFrameFormat *SwPageDesc::GetRightFormat(bool const bFirst)
391 return (UseOnPage::Right & m_eUse)
392 ? (bFirst ? &m_FirstMaster : &m_Master)
393 : nullptr;
396 bool SwPageDesc::IsFirstShared() const
398 return bool(m_eUse & UseOnPage::FirstShare);
401 void SwPageDesc::ChgFirstShare( bool bNew )
403 if ( bNew )
404 m_eUse |= UseOnPage::FirstShare;
405 else
406 m_eUse &= UseOnPage::NoFirstShare;
409 void SwPageDesc::StashFrameFormat(const SwFrameFormat& rFormat, bool bHeader, bool bLeft, bool bFirst)
411 assert(rFormat.GetRegisteredIn());
412 std::shared_ptr<SwFrameFormat>* pFormat = nullptr;
414 if (bHeader)
416 if (bLeft && !bFirst)
417 pFormat = &m_aStashedHeader.m_pStashedLeft;
418 else if (!bLeft && bFirst)
419 pFormat = &m_aStashedHeader.m_pStashedFirst;
420 else if (bLeft && bFirst)
421 pFormat = &m_aStashedHeader.m_pStashedFirstLeft;
423 else
425 if (bLeft && !bFirst)
426 pFormat = &m_aStashedFooter.m_pStashedLeft;
427 else if (!bLeft && bFirst)
428 pFormat = &m_aStashedFooter.m_pStashedFirst;
429 else if (bLeft && bFirst)
430 pFormat = &m_aStashedFooter.m_pStashedFirstLeft;
433 if (pFormat)
435 *pFormat = std::make_shared<SwFrameFormat>(rFormat);
437 else
439 SAL_WARN(
440 "sw",
441 "SwPageDesc::StashFrameFormat: Stashing the right page header/footer is pointless.");
445 const SwFrameFormat* SwPageDesc::GetStashedFrameFormat(bool bHeader, bool bLeft, bool bFirst) const
447 std::shared_ptr<SwFrameFormat>* pFormat = nullptr;
449 if (bLeft && !bFirst)
451 pFormat = bHeader ? &m_aStashedHeader.m_pStashedLeft : &m_aStashedFooter.m_pStashedLeft;
453 else if (!bLeft && bFirst)
455 pFormat = bHeader ? &m_aStashedHeader.m_pStashedFirst : &m_aStashedFooter.m_pStashedFirst;
457 else if (bLeft && bFirst)
459 pFormat = bHeader ? &m_aStashedHeader.m_pStashedFirstLeft : &m_aStashedFooter.m_pStashedFirstLeft;
462 if (pFormat)
464 return pFormat->get();
466 else
468 SAL_WARN("sw", "SwPageDesc::GetStashedFrameFormat: Right page format is never stashed.");
469 return nullptr;
473 bool SwPageDesc::HasStashedFormat(bool bHeader, bool bLeft, bool bFirst)
475 if (bHeader)
477 if (bLeft && !bFirst)
479 return m_aStashedHeader.m_pStashedLeft != nullptr;
481 else if (!bLeft && bFirst)
483 return m_aStashedHeader.m_pStashedFirst != nullptr;
485 else if (bLeft && bFirst)
487 return m_aStashedHeader.m_pStashedFirstLeft != nullptr;
489 else
491 SAL_WARN("sw", "SwPageDesc::HasStashedFormat: Right page format is never stashed.");
492 return false;
495 else
497 if (bLeft && !bFirst)
499 return m_aStashedFooter.m_pStashedLeft != nullptr;
501 else if (!bLeft && bFirst)
503 return m_aStashedFooter.m_pStashedFirst != nullptr;
505 else if (bLeft && bFirst)
507 return m_aStashedFooter.m_pStashedFirstLeft != nullptr;
509 else
511 SAL_WARN("sw", "SwPageDesc::HasStashedFormat: Right page format is never stashed.");
512 return false;
517 void SwPageDesc::RemoveStashedFormat(bool bHeader, bool bLeft, bool bFirst)
519 if (bHeader)
521 if (bLeft && !bFirst)
523 m_aStashedHeader.m_pStashedLeft.reset();
525 else if (!bLeft && bFirst)
527 m_aStashedHeader.m_pStashedFirst.reset();
529 else if (bLeft && bFirst)
531 m_aStashedHeader.m_pStashedFirstLeft.reset();
533 else
535 SAL_WARN("sw", "SwPageDesc::RemoveStashedFormat: Right page format is never stashed.");
538 else
540 if (bLeft && !bFirst)
542 m_aStashedFooter.m_pStashedLeft.reset();
544 else if (!bLeft && bFirst)
546 m_aStashedFooter.m_pStashedFirst.reset();
548 else if (bLeft && bFirst)
550 m_aStashedFooter.m_pStashedFirstLeft.reset();
552 else
554 SAL_WARN("sw", "SwPageDesc::RemoveStashedFormat: Right page format is never stashed.");
559 // Page styles
560 const TranslateId STR_POOLPAGE[] =
562 STR_POOLPAGE_STANDARD,
563 STR_POOLPAGE_FIRST,
564 STR_POOLPAGE_LEFT,
565 STR_POOLPAGE_RIGHT,
566 STR_POOLPAGE_ENVELOPE,
567 STR_POOLPAGE_REGISTER,
568 STR_POOLPAGE_HTML,
569 STR_POOLPAGE_FOOTNOTE,
570 STR_POOLPAGE_ENDNOTE,
571 STR_POOLPAGE_LANDSCAPE
574 SwPageDesc* SwPageDesc::GetByName(SwDoc& rDoc, std::u16string_view rName)
576 const size_t nDCount = rDoc.GetPageDescCnt();
578 for( size_t i = 0; i < nDCount; i++ )
580 SwPageDesc* pDsc = &rDoc.GetPageDesc( i );
581 if(pDsc->GetName() == rName)
583 return pDsc;
587 for (size_t i = 0; i < SAL_N_ELEMENTS(STR_POOLPAGE); ++i)
589 if (rName == SwResId(STR_POOLPAGE[i]))
591 return rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool( static_cast< sal_uInt16 >(
592 i + RES_POOLPAGE_BEGIN) );
596 return nullptr;
599 void SwPageDesc::dumpAsXml(xmlTextWriterPtr pWriter) const
601 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwPageDesc"));
602 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
603 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("m_StyleName"), "%s",
604 BAD_CAST(m_StyleName.toUtf8().getStr()));
605 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("m_pFollow"), "%p", m_pFollow);
606 (void)xmlTextWriterWriteFormatAttribute(
607 pWriter, BAD_CAST("m_eUse"), "0x%s",
608 BAD_CAST(OString::number(static_cast<int>(m_eUse), 16).getStr()));
610 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_Master"));
611 m_Master.dumpAsXml(pWriter);
612 (void)xmlTextWriterEndElement(pWriter);
614 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_Left"));
615 m_Left.dumpAsXml(pWriter);
616 (void)xmlTextWriterEndElement(pWriter);
618 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_FirstMaster"));
619 m_FirstMaster.dumpAsXml(pWriter);
620 (void)xmlTextWriterEndElement(pWriter);
622 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_FirstLeft"));
623 m_FirstLeft.dumpAsXml(pWriter);
624 (void)xmlTextWriterEndElement(pWriter);
626 (void)xmlTextWriterEndElement(pWriter);
629 SwPageFootnoteInfo::SwPageFootnoteInfo()
630 : m_nMaxHeight( 0 )
631 , m_nLineWidth(10)
632 , m_eLineStyle( SvxBorderLineStyle::SOLID )
633 , m_Width( 25, 100 )
634 , m_nTopDist( 57 ) //1mm
635 , m_nBottomDist( 57 )
637 m_eAdjust = SvxFrameDirection::Horizontal_RL_TB == GetDefaultFrameDirection(GetAppLanguage()) ?
638 css::text::HorizontalAdjust_RIGHT :
639 css::text::HorizontalAdjust_LEFT;
642 SwPageFootnoteInfo::SwPageFootnoteInfo( const SwPageFootnoteInfo &rCpy )
643 : m_nMaxHeight(rCpy.GetHeight())
644 , m_nLineWidth(rCpy.m_nLineWidth)
645 , m_eLineStyle(rCpy.m_eLineStyle)
646 , m_LineColor(rCpy.m_LineColor)
647 , m_Width(rCpy.GetWidth())
648 , m_eAdjust(rCpy.GetAdj())
649 , m_nTopDist(rCpy.GetTopDist())
650 , m_nBottomDist(rCpy.GetBottomDist())
654 SwPageFootnoteInfo &SwPageFootnoteInfo::operator=( const SwPageFootnoteInfo& rCpy )
656 m_nMaxHeight = rCpy.GetHeight();
657 m_nLineWidth = rCpy.m_nLineWidth;
658 m_eLineStyle = rCpy.m_eLineStyle;
659 m_LineColor = rCpy.m_LineColor;
660 m_Width = rCpy.GetWidth();
661 m_eAdjust = rCpy.GetAdj();
662 m_nTopDist = rCpy.GetTopDist();
663 m_nBottomDist = rCpy.GetBottomDist();
664 return *this;
667 bool SwPageFootnoteInfo::operator==( const SwPageFootnoteInfo& rCmp ) const
669 return m_nMaxHeight == rCmp.GetHeight()
670 && m_nLineWidth == rCmp.m_nLineWidth
671 && m_eLineStyle == rCmp.m_eLineStyle
672 && m_LineColor == rCmp.m_LineColor
673 && m_Width == rCmp.GetWidth()
674 && m_eAdjust == rCmp.GetAdj()
675 && m_nTopDist == rCmp.GetTopDist()
676 && m_nBottomDist== rCmp.GetBottomDist();
679 SwPageDescExt::SwPageDescExt(const SwPageDesc & rPageDesc, SwDoc *const pDoc)
680 : m_PageDesc(rPageDesc)
681 , m_pDoc(pDoc)
683 SetPageDesc(rPageDesc);
686 SwPageDescExt::SwPageDescExt(const SwPageDescExt & rSrc)
687 : m_PageDesc(rSrc.m_PageDesc)
688 , m_pDoc(rSrc.m_pDoc)
690 SetPageDesc(rSrc.m_PageDesc);
693 SwPageDescExt::~SwPageDescExt()
697 OUString const & SwPageDescExt::GetName() const
699 return m_PageDesc.GetName();
702 void SwPageDescExt::SetPageDesc(const SwPageDesc & rPageDesc)
704 m_PageDesc = rPageDesc;
706 if (m_PageDesc.GetFollow())
707 m_sFollow = m_PageDesc.GetFollow()->GetName();
710 SwPageDescExt & SwPageDescExt::operator = (const SwPageDesc & rSrc)
712 SetPageDesc(rSrc);
714 return *this;
717 SwPageDescExt & SwPageDescExt::operator = (const SwPageDescExt & rSrc)
719 operator=(rSrc.m_PageDesc);
720 return *this;
723 SwPageDescExt::operator SwPageDesc() const
725 SwPageDesc aResult(m_PageDesc);
727 SwPageDesc * pPageDesc = m_pDoc->FindPageDesc(m_sFollow);
729 if ( nullptr != pPageDesc )
730 aResult.SetFollow(pPageDesc);
732 return aResult;
735 SwPageDescs::SwPageDescs()
736 : m_PosIndex( m_Array.get<0>() )
737 , m_NameIndex( m_Array.get<1>() )
741 SwPageDescs::~SwPageDescs()
743 for(const_iterator it = begin(); it != end(); ++it)
744 delete *it;
747 SwPageDescs::iterator SwPageDescs::find_(const OUString &name) const
749 ByName::iterator it = m_NameIndex.find( name );
750 return m_Array.iterator_to( *it );
753 std::pair<SwPageDescs::const_iterator,bool> SwPageDescs::push_back( const value_type& x )
755 // SwPageDesc is not already in a SwPageDescs list!
756 assert( x->m_pdList == nullptr );
758 std::pair<iterator,bool> res = m_PosIndex.push_back( x );
759 if( res.second )
760 x->m_pdList = this;
761 return res;
764 void SwPageDescs::erase( const value_type& x )
766 // SwPageDesc is not in this SwPageDescs list!
767 assert( x->m_pdList == this );
769 iterator const ret = find_( x->GetName() );
770 if (ret != end())
771 m_PosIndex.erase( ret );
772 else
773 SAL_WARN( "sw", "SwPageDesc is not in SwPageDescs m_pdList!" );
774 x->m_pdList = nullptr;
777 void SwPageDescs::erase( const_iterator const& position )
779 // SwPageDesc is not in this SwPageDescs list!
780 assert( (*position)->m_pdList == this );
782 (*position)->m_pdList = nullptr;
783 m_PosIndex.erase( position );
786 void SwPageDescs::erase( size_type index_ )
788 erase( begin() + index_ );
791 void SwPageDescs::dumpAsXml(xmlTextWriterPtr pWriter) const
793 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwPageDescs"));
795 for (const auto& pPageDesc : m_PosIndex)
797 pPageDesc->dumpAsXml(pWriter);
800 (void)xmlTextWriterEndElement(pWriter);
803 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */