/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
bool SwPageDesc::SetName( const UIName& rNewName )
{ bool renamed = true; if (m_pdList) {
SwPageDescs::iterator it = m_pdList->find_( m_StyleName ); if( m_pdList->end() == it ) {
SAL_WARN( "sw", "SwPageDesc not found in expected m_pdList" ); returnfalse;
}
renamed = m_pdList->m_PosIndex.modify( it,
change_name( rNewName ), change_name( m_StyleName ) );
} else
m_StyleName = rNewName; return renamed;
}
/// Only the margin is mirrored. /// Attributes like borders and so on are copied 1:1. void SwPageDesc::Mirror()
{ //Only the margins are mirrored, all other values are just copied.
SvxLRSpaceItem aLR( RES_LR_SPACE ); const SvxLRSpaceItem &rLR = m_Master.GetLRSpace();
aLR.SetLeft(rLR.GetRight());
aLR.SetRight(rLR.GetLeft());
aLR.SetRightGutterMargin(rLR.GetGutterMargin());
// gets information from Modify bool SwPageDesc::GetInfo( SwFindNearestNode & rInfo ) const
{ if (!m_Master.GetInfo(rInfo)) returnfalse; // found if (!m_Left.GetInfo(rInfo)) returnfalse ; if ( !m_FirstMaster.GetInfo( rInfo ) ) returnfalse; return m_FirstLeft.GetInfo( rInfo );
}
/// set the style for the grid alignment void SwPageDesc::SetRegisterFormatColl(const SwTextFormatColl* pFormat)
{ if(pFormat != m_pTextFormatColl)
{
m_aDepends.EndListeningAll();
m_pTextFormatColl = pFormat;
m_aDepends.StartListening(const_cast<SwTextFormatColl*>(m_pTextFormatColl));
RegisterChange();
}
}
/// retrieve the style for the grid alignment const SwTextFormatColl* SwPageDesc::GetRegisterFormatColl() const
{ if (!m_aDepends.IsListeningTo(m_pTextFormatColl))
m_pTextFormatColl = nullptr; return m_pTextFormatColl;
}
/// notify all affected page frames void SwPageDesc::RegisterChange()
{ // #117072# - During destruction of the document <SwDoc> // the page description is modified. Thus, do nothing, if the document // is in destruction respectively if no viewshell exists.
SwDoc& rDoc = GetMaster().GetDoc(); if ( rDoc.IsInDtor() )
{ return;
}
SwViewShell* pSh = rDoc.getIDocumentLayoutAccess().GetCurrentViewShell(); if ( !pSh )
{ return;
}
if (pFormat)
{
pFormat->emplace(rFormat);
} else
{
SAL_WARN( "sw", "SwPageDesc::StashFrameFormat: Stashing the right page header/footer is pointless.");
}
}
if (pFormat)
{ return pFormat->has_value() ? &**pFormat : nullptr;
} else
{
SAL_WARN("sw", "SwPageDesc::GetStashedFrameFormat: Right page format is never stashed."); return nullptr;
}
}
bool SwPageDesc::HasStashedFormat(bool bHeader, bool bLeft, bool bFirst) const
{ if (bHeader)
{ if (bLeft && !bFirst)
{ return m_aStashedHeader.m_oStashedLeft.has_value();
} elseif (!bLeft && bFirst)
{ return m_aStashedHeader.m_oStashedFirst.has_value();
} elseif (bLeft && bFirst)
{ return m_aStashedHeader.m_oStashedFirstLeft.has_value();
} else
{
SAL_WARN("sw", "SwPageDesc::HasStashedFormat: Right page format is never stashed."); returnfalse;
}
} else
{ if (bLeft && !bFirst)
{ return m_aStashedFooter.m_oStashedLeft.has_value();
} elseif (!bLeft && bFirst)
{ return m_aStashedFooter.m_oStashedFirst.has_value();
} elseif (bLeft && bFirst)
{ return m_aStashedFooter.m_oStashedFirstLeft.has_value();
} else
{
SAL_WARN("sw", "SwPageDesc::HasStashedFormat: Right page format is never stashed."); returnfalse;
}
}
}
void SwPageDesc::RemoveStashedFormat(bool bHeader, bool bLeft, bool bFirst)
{ if (bHeader)
{ if (bLeft && !bFirst)
{
m_aStashedHeader.m_oStashedLeft.reset();
} elseif (!bLeft && bFirst)
{
m_aStashedHeader.m_oStashedFirst.reset();
} elseif (bLeft && bFirst)
{
m_aStashedHeader.m_oStashedFirstLeft.reset();
} else
{
SAL_WARN("sw", "SwPageDesc::RemoveStashedFormat: Right page format is never stashed.");
}
} else
{ if (bLeft && !bFirst)
{
m_aStashedFooter.m_oStashedLeft.reset();
} elseif (!bLeft && bFirst)
{
m_aStashedFooter.m_oStashedFirst.reset();
} elseif (bLeft && bFirst)
{
m_aStashedFooter.m_oStashedFirstLeft.reset();
} else
{
SAL_WARN("sw", "SwPageDesc::RemoveStashedFormat: Right page format is never stashed.");
}
}
}
SwPageDescs::~SwPageDescs()
{ for(const_iterator it = begin(); it != end(); ++it) delete *it;
}
SwPageDescs::iterator SwPageDescs::find_(const UIName &name) const
{
ByName::iterator it = m_NameIndex.find( name ); return m_Array.iterator_to( *it );
}
std::pair<SwPageDescs::const_iterator,bool> SwPageDescs::push_back( const value_type& x )
{ // SwPageDesc is not already in a SwPageDescs list!
assert( x->m_pdList == nullptr );
std::pair<iterator,bool> res = m_PosIndex.push_back( x ); if( res.second )
x->m_pdList = this; return res;
}
void SwPageDescs::erase( const value_type& x )
{ // SwPageDesc is not in this SwPageDescs list!
assert( x->m_pdList == this );
iterator const ret = find_( x->GetName() ); if (ret != end())
m_PosIndex.erase( ret ); else
SAL_WARN( "sw", "SwPageDesc is not in SwPageDescs m_pdList!" );
x->m_pdList = nullptr;
}
void SwPageDescs::erase( const_iterator const& position )
{ // SwPageDesc is not in this SwPageDescs list!
assert( (*position)->m_pdList == this );
(*position)->m_pdList = nullptr;
m_PosIndex.erase( position );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.