// create SfxItemPool and EditEngine pool and add these in a chain. These // belong us and will be removed/destroyed in removeAndDeleteSecondaryPools() used from // the destructor
rtl::Reference<SfxItemPool> pSdrPool = new SdrItemPool(this);
// #75371# change DefaultItems for the SdrEdgeObj distance items // to TWIPS.
constexpr tools::Long nDefEdgeDist
= o3tl::convert(500, o3tl::Length::mm100, o3tl::Length::twip);
// first delete the items, then break the linking
pSdrPool->sendShutdownHint();
SetSecondaryPool(nullptr);
}
/// Notification callback void SwAttrSet::Changed(const SfxPoolItem* pOld, const SfxPoolItem* pNew) const
{ // when neither pOld nor pNew is set, no need to do anything so return if (nullptr == m_pOldSet && nullptr == m_pNewSet) return;
// at least one SfxPoolItem has to be provided, else this is an error
assert(nullptr != pOld || nullptr != pNew);
sal_uInt16 nWhich(0);
if (nullptr != pOld)
{ // do not handle if an invalid or disabled item is involved if (IsInvalidItem(pOld) || IsDisabledItem(pOld)) return;
// get WhichID from pOld
nWhich = pOld->Which();
}
if (nullptr != pNew)
{ // do not handle if an invalid or disabled item is involved if (IsInvalidItem(pNew) || IsDisabledItem(pNew)) return;
if (0 == nWhich)
{ // get WhichID from pNew
nWhich = pNew->Which();
}
}
// all given items are valid. If we got no WhichID != 0 then // pOld == pNew == nullptr or IsDisabledItem and we have no // valid input. Also not needed if !IsWhich (aka > SFX_WHICH_MAX) if (0 == nWhich || !SfxItemPool::IsWhich(nWhich)) return;
if(m_pOldSet)
{ // old state shall be saved if (nullptr == pOld)
{ // no old value given, generate default from WhichID const SfxItemSet* pParent(GetParent());
m_pOldSet->PutImpl(nullptr != pParent
? pParent->Get(nWhich)
: GetPool()->GetUserOrPoolDefaultItem(nWhich), false);
} elseif (!IsInvalidItem(pOld))
{ // set/remember old value
m_pOldSet->PutImpl(*pOld, false);
}
}
if(m_pNewSet)
{ // old state shall be saved if (nullptr == pNew)
{ // no new value given, generate default from WhichID const SfxItemSet* pParent(GetParent());
m_pNewSet->PutImpl(nullptr != pParent
? pParent->Get(nWhich)
: GetPool()->GetUserOrPoolDefaultItem(nWhich), false);
} elseif (!IsInvalidItem(pNew))
{ // set/remember new value
m_pNewSet->PutImpl(*pNew, false);
}
}
}
if(SwFormatDrop* pFormatDrop = const_cast<SwFormatDrop*>(GetItemIfSet( RES_PARATR_DROP, false )))
{ auto pDropDefiner = dynamic_cast<const sw::FormatDropDefiner*>(pModify); // If CharFormat is set and it is set in different attribute pools then // the CharFormat has to be copied.
SwCharFormat* pCharFormat = pFormatDrop->GetCharFormat(); if(pCharFormat && GetPool() != pCharFormat->GetAttrSet().GetPool())
{
pCharFormat = GetDoc().CopyCharFormat(*pCharFormat);
pFormatDrop->SetCharFormat(pCharFormat);
}
pFormatDrop->ChgDefinedIn(pDropDefiner);
bSet = true;
}
// Does the NumRule has to be copied? const SwNumRuleItem* pNumRuleItem; if( &rSrcDoc != &rDstDoc &&
(pNumRuleItem = GetItemIfSet( RES_PARATR_NUMRULE, false )) )
{
UIName aNm(pNumRuleItem->GetValue()); if( !aNm.isEmpty() )
{
SwNumRule* pDestRule = rDstDoc.FindNumRulePtr( aNm ); if( pDestRule )
pDestRule->Invalidate(); else
rDstDoc.MakeNumRule( aNm, rSrcDoc.FindNumRulePtr( aNm ) );
}
}
// copy list and if needed also the corresponding list style // for text nodes const SfxStringItem* pStrItem; if ( &rSrcDoc != &rDstDoc &&
pCNd && pCNd->IsTextNode() &&
(pStrItem = GetItemIfSet( RES_PARATR_LIST_ID, false )) )
{ const OUString& sListId = pStrItem->GetValue(); if ( !sListId.isEmpty() &&
!rDstDoc.getIDocumentListsAccess().getListByName( sListId ) )
{ const SwList* pList = rSrcDoc.getIDocumentListsAccess().getListByName( sListId ); // copy list style, if needed const UIName& sDefaultListStyleName =
pList->GetDefaultListStyleName(); // #i92811# const SwNumRule* pDstDocNumRule =
rDstDoc.FindNumRulePtr( sDefaultListStyleName ); if ( !pDstDocNumRule )
{
rDstDoc.MakeNumRule( sDefaultListStyleName,
rSrcDoc.FindNumRulePtr( sDefaultListStyleName ) );
} else
{ const SwNumRule* pSrcDocNumRule =
rSrcDoc.FindNumRulePtr( sDefaultListStyleName ); // If list id of text node equals the list style's // default list id in the source document, the same // should be hold in the destination document. // Thus, create new list id item. if (pSrcDocNumRule && sListId == pSrcDocNumRule->GetDefaultListId())
{
pNewListIdItem.reset(new SfxStringItem (
RES_PARATR_LIST_ID,
pDstDocNumRule->GetDefaultListId() ));
}
} // check again, if list exist, because <SwDoc::MakeNumRule(..)> // could have also created it. if ( pNewListIdItem == nullptr &&
!rDstDoc.getIDocumentListsAccess().getListByName( sListId ) )
{ // copy list
rDstDoc.getIDocumentListsAccess().createList( sListId, sDefaultListStyleName );
}
}
}
const SwFormatAnchor* pAnchorItem; if( &rSrcDoc != &rDstDoc && (pAnchorItem = GetItemIfSet( RES_ANCHOR, false ))
&& pAnchorItem->GetAnchorNode() != nullptr )
{ if( !tmpSet )
tmpSet.emplace( *this ); // Anchors at any node position cannot be copied to another document, because the SwPosition // would still point to the old document. It needs to be fixed up explicitly.
tmpSet->ClearItem( RES_ANCHOR );
}
// fix up character style, it contains pointers to rSrcDoc if (const SwFormatCharFormat* pCharFormatItem = pNewSet->GetItemIfSet(RES_TXTATR_CHARFMT, false))
{
SwCharFormat *const pCopy(rDstDoc.CopyCharFormat(*pCharFormatItem->GetCharFormat())); const_cast<SwFormatCharFormat&>(*pCharFormatItem).SetCharFormat(pCopy);
}
SwFormatAutoFormat item(RES_PARATR_LIST_AUTOFMT); // TODO: for ODF export we'd need to add it to the autostyle pool
item.SetStyleHandle(pNewSet); if (!tmpSet)
{
tmpSet.emplace(*this);
}
tmpSet->Put(item);
}
/// check if ID is in range of attribute set IDs bool IsInRange( const WhichRangesContainer& pRange, const sal_uInt16 nId )
{ for(constauto& rPair : pRange)
{ if( rPair.first <= nId && nId <= rPair.second ) returntrue;
} returnfalse;
}
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.