/* -*- 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 .
*/
void Notify(SfxBroadcaster&, const SfxHint& rHint) override
{ auto nId = rHint.GetId(); if (nId != SfxHintId::StyleSheetModified && nId != SfxHintId::StyleSheetModifiedExtended
&& nId != SfxHintId::StyleSheetErased) return; auto pHint = static_cast<const SfxStyleSheetHint*>(&rHint);
auto pDocStyleSheet = pHint->GetStyleSheet(); const SfxStyleSheetModifiedHint* pExtendedHint = nullptr; if (nId == SfxHintId::StyleSheetModifiedExtended)
pExtendedHint = static_cast<const SfxStyleSheetModifiedHint*>(&rHint); const OUString aName = pExtendedHint ? pExtendedHint->GetOldName() : pDocStyleSheet->GetName(); auto pStyleSheet = SfxStyleSheetPool::Find(aName, pDocStyleSheet->GetFamily()); if (!pStyleSheet) return;
if (nId == SfxHintId::StyleSheetModified || nId == SfxHintId::StyleSheetModifiedExtended)
{
pStyleSheet->SetName(pDocStyleSheet->GetName());
UpdateStyleHierarchyFrom(pStyleSheet, pDocStyleSheet); static_cast<SfxStyleSheet*>(pStyleSheet)->Broadcast(SfxHint(SfxHintId::DataChanged));
} elseif (nId == SfxHintId::StyleSheetErased)
Remove(pStyleSheet);
}
// Remember now, as the next calls will invalidate pDocStyleSheet. const OUString aParent = pDocStyleSheet->GetParent(); const OUString aFollow = pDocStyleSheet->GetFollow();
if (pStyleSheet->GetParent() != aParent)
pStyleSheet->SetParent(aParent);
if (pStyleSheet->GetFollow() != aFollow)
pStyleSheet->SetFollow(aFollow);
}
// assumption: this seldom occurs, the iterator is built, then emptied.
rehash();
assert (maImpl.size() == maUnique.size());
}
// Add Strings to the list of templates void SwStyleSheetIterator::SwPoolFormatList::Append( SfxStyleFamily eFam, const UIName& rStr )
{
UniqueHash::const_iterator it = maUnique.find(std::pair<SfxStyleFamily,UIName>{eFam, rStr}); if (it != maUnique.end()) return;
if( bChg )
{ // calling pPool->First() here would be quite slow... dynamic_cast<SwDocStyleSheetPool&>(*m_pPool).InvalidateIterator(); // internal list has to be updated
m_pPool->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified, *this ) ); if (SwEditShell* pSh = m_rDoc.GetEditShell())
pSh->CallChgLnk();
}
}
// What Linkage is possible bool SwDocStyleSheet::HasFollowSupport() const
{ switch(nFamily)
{ case SfxStyleFamily::Para : case SfxStyleFamily::Page : returntrue; case SfxStyleFamily::Frame: case SfxStyleFamily::Char : case SfxStyleFamily::Pseudo: returnfalse; default:
OSL_ENSURE(false, "unknown style family");
} returnfalse;
}
// Get currently used FillStyle and remember, also need the XFillFloatTransparenceItem // to decide if gradient transparence is used const drawing::FillStyle eFillStyle(pSet->Get(XATTR_FILLSTYLE).GetValue()); constbool bUseFloatTransparence(pSet->Get(XATTR_FILLFLOATTRANSPARENCE).IsEnabled());
for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
{ if(!IsInvalidItem(pItem))
{ switch ( pItem->Which() )
{ case SID_ATTR_AUTO_STYLE_UPDATE: case RES_PAGEDESC: break; default:
{
OUString aItemPresentation; if ( !IsInvalidItem( pItem ) &&
m_pPool->GetPool().GetPresentation(
*pItem, eUnit, aItemPresentation, aIntlWrapper ) )
{ bool bIsDefault = false; switch ( pItem->Which() )
{ case XATTR_FILLCOLOR:
{ // only use active FillStyle information
bIsDefault = (drawing::FillStyle_SOLID == eFillStyle); break;
} case XATTR_FILLGRADIENT:
{ // only use active FillStyle information
bIsDefault = (drawing::FillStyle_GRADIENT == eFillStyle); break;
} case XATTR_FILLHATCH:
{ // only use active FillStyle information
bIsDefault = (drawing::FillStyle_HATCH == eFillStyle); break;
} case XATTR_FILLBITMAP:
{ // only use active FillStyle information
bIsDefault = (drawing::FillStyle_BITMAP == eFillStyle); break;
} case XATTR_FILLTRANSPARENCE:
{ // only active when not FloatTransparence
bIsDefault = !bUseFloatTransparence; break;
} case XATTR_FILLFLOATTRANSPARENCE:
{ // only active when FloatTransparence
bIsDefault = bUseFloatTransparence; break;
}
case SID_ATTR_PARA_PAGENUM:
sPageNum = aItemPresentation; break; case SID_ATTR_PARA_MODEL:
sModel = aItemPresentation; break; case RES_BREAK:
sBreak = aItemPresentation; break; case RES_CHRATR_CJK_FONT: case RES_CHRATR_CJK_FONTSIZE: case RES_CHRATR_CJK_LANGUAGE: case RES_CHRATR_CJK_POSTURE: case RES_CHRATR_CJK_WEIGHT: if(SvtCJKOptions::IsCJKFontEnabled())
bIsDefault = true; if(!bHasCJKFontPrefix)
{
aItemPresentation = SwResId(STR_CJK_FONT) + aItemPresentation;
bHasCJKFontPrefix = true;
} break; case RES_CHRATR_CTL_FONT: case RES_CHRATR_CTL_FONTSIZE: case RES_CHRATR_CTL_LANGUAGE: case RES_CHRATR_CTL_POSTURE: case RES_CHRATR_CTL_WEIGHT: if(SvtCTLOptions::IsCTLFontEnabled())
bIsDefault = true; if(!bHasCTLFontPrefix)
{
aItemPresentation = SwResId(STR_CTL_FONT) + aItemPresentation;
bHasCTLFontPrefix = true;
} break; case RES_CHRATR_FONT: case RES_CHRATR_FONTSIZE: case RES_CHRATR_LANGUAGE: case RES_CHRATR_POSTURE: case RES_CHRATR_WEIGHT: if(!bHasWesternFontPrefix)
{
aItemPresentation = SwResId(STR_WESTERN_FONT) + aItemPresentation;
bHasWesternFontPrefix = true;
}
[[fallthrough]]; default:
bIsDefault = true;
} if(bIsDefault)
{ if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
aDesc.append(sPlus);
aDesc.append(aItemPresentation);
}
}
}
}
}
} // Special treatment for Break, Page template and Site offset if (!sModel.isEmpty())
{ if (!aDesc.isEmpty())
aDesc.append(sPlus);
aDesc.append(SwResId(STR_PAGEBREAK) + sPlus + sModel); if (sPageNum != "0")
{
aDesc.append(sPlus + SwResId(STR_PAGEOFFSET) + sPageNum);
}
} elseif (!sBreak.isEmpty()) // Break can be valid only when NO Model
{ if (!aDesc.isEmpty())
aDesc.append(sPlus);
aDesc.append(sBreak);
} return aDesc.makeStringAndClear();
}
bChg = true;
} break;
} case SfxStyleFamily::Page :
OSL_ENSURE(m_pDesc, "PageDesc missing!"); if( m_pDesc && m_pDesc->GetName() != rStr )
{ // Set PageDesc - copy with earlier one - probably not // necessary for setting the name. So here we allow a // cast.
SwPageDesc aPageDesc(*const_cast<SwPageDesc*>(m_pDesc)); const UIName aOldName(aPageDesc.GetName());
m_pColl->SetNextTextFormatColl(*pFollow);
} break;
} case SfxStyleFamily::Page :
{
OSL_ENSURE(m_pDesc, "PageDesc missing!"); if( m_pDesc )
{ const SwPageDesc* pFollowDesc = !rStr.isEmpty()
? lcl_FindPageDesc(m_rDoc, UIName(rStr))
: nullptr;
size_t nId = 0; if (pFollowDesc != m_pDesc->GetFollow() && m_rDoc.FindPageDesc(m_pDesc->GetName(), &nId))
{
SwPageDesc aDesc( *m_pDesc );
aDesc.SetFollow( pFollowDesc );
m_rDoc.ChgPageDesc( nId, aDesc );
m_pDesc = &m_rDoc.GetPageDesc( nId );
}
} break;
} case SfxStyleFamily::Char: case SfxStyleFamily::Frame: case SfxStyleFamily::Pseudo: break; default:
OSL_ENSURE(false, "unknown style family");
}
returntrue;
}
static void lcl_SwFormatToFlatItemSet(SwFormat const *const pFormat, std::optional<SfxItemSet>& pRet)
{ // note: we don't add the odd items that GetItemSet() would add // because they don't seem relevant for preview
std::vector<SfxItemSet const*> sets;
sets.push_back(&pFormat->GetAttrSet()); while (SfxItemSet const*const pParent = sets.back()->GetParent())
{
sets.push_back(pParent);
} // start by copying top-level parent set
pRet.emplace(*sets.back());
sets.pop_back(); for (auto iter = sets.rbegin(); iter != sets.rend(); ++iter)
{ // in reverse so child overrides parent
pRet->Put(**iter);
}
}
std::optional<SfxItemSet> SwDocStyleSheet::GetItemSetForPreview()
{ if (SfxStyleFamily::Page == nFamily || SfxStyleFamily::Pseudo == nFamily || SfxStyleFamily::Table == nFamily)
{
SAL_INFO("sw.ui", "GetItemSetForPreview not implemented for page or number or table style"); return std::optional<SfxItemSet>();
} if (!m_bPhysical)
{ // because not only this style, but also any number of its parents // (or follow style) may not actually exist in the document at this // time, return one "flattened" item set that contains all items from // all parents.
std::optional<SfxItemSet> pRet;
switch(nFamily)
{ case SfxStyleFamily::Char: case SfxStyleFamily::Para: case SfxStyleFamily::Frame:
{
SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
aBoxInfo.SetTable( false );
aBoxInfo.SetDist( true ); // always show gap field
aBoxInfo.SetMinDist( true );// set minimum size in tables and paragraphs
aBoxInfo.SetDefDist( MIN_BORDER_DIST );// always set Default-Gap // Single lines can only have DontCare-Status in tables
aBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISABLE );
// create needed items for XPropertyList entries from the DrawModel so that // the Area TabPage can access them const SwDrawModel* pDrawModel = m_rDoc.getIDocumentDrawModelAccess().GetDrawModel();
case SfxStyleFamily::Page :
{ // set correct parent to get the drawing::FillStyle_NONE FillStyle as needed if(!m_aCoreSet.GetParent())
{
m_aCoreSet.SetParent(&m_rDoc.GetDfltFrameFormat()->GetAttrSet());
}
assert(m_pDesc && "No PageDescriptor");
::PageDescToItemSet(*const_cast<SwPageDesc*>(m_pDesc), m_aCoreSet);
} break;
case SfxStyleFamily::Pseudo:
{
assert(m_pNumRule && "No NumRule");
SvxNumRule aRule = m_pNumRule->MakeSvxNumRule();
m_aCoreSet.Put(SvxNumBulletItem(std::move(aRule)));
} break;
default:
OSL_ENSURE(false, "unknown style family");
} // Member of Baseclass
pSet = &m_aCoreSet;
OSL_ENSURE( m_pColl->GetItemState( RES_PARATR_NUMRULE ) == SfxItemState::SET, " - list level indents are applicable at paragraph style, but no list style found. Serious defect." ); const UIName sNumRule = m_pColl->GetNumRule().GetValue(); if (sNumRule.isEmpty()) return;
// #i56252: If a standard numbering style is assigned to a standard paragraph style // we have to create a physical instance of the numbering style. If we do not and // neither the paragraph style nor the numbering style is used in the document // the numbering style will not be saved with the document and the assignment got lost. if( const SfxPoolItem* pNumRuleItem = rSet.GetItemIfSet( RES_PARATR_NUMRULE, false ) )
{ // Setting a numbering rule? const UIName sNumRule = static_cast<const SwNumRuleItem*>(pNumRuleItem)->GetValue(); if (!sNumRule.isEmpty())
{
SwNumRule* pRule = m_rDoc.FindNumRulePtr( sNumRule ); if( !pRule )
{ // Numbering rule not in use yet.
sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sNumRule, SwGetPoolIdFromName::NumRule ); if( USHRT_MAX != nPoolId ) // It's a standard numbering rule
{
m_rDoc.getIDocumentStylePoolAccess().GetNumRuleFromPool( nPoolId ); // Create numbering rule (physical)
}
}
}
}
pFormat = m_pColl;
sal_uInt16 nId = m_pColl->GetPoolFormatId() &
~ ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID ); switch( GetMask() & ( static_cast<SfxStyleSearchBits>(0x0fff) & ~SfxStyleSearchBits::SwCondColl ) )
{ case SfxStyleSearchBits::SwText:
nId |= COLL_TEXT_BITS; break; case SfxStyleSearchBits::SwChapter:
nId |= COLL_DOC_BITS; break; case SfxStyleSearchBits::SwList:
nId |= COLL_LISTS_BITS; break; case SfxStyleSearchBits::SwIndex:
nId |= COLL_REGISTER_BITS; break; case SfxStyleSearchBits::SwExtra:
nId |= COLL_EXTRA_BITS; break; case SfxStyleSearchBits::SwHtml:
nId |= COLL_HTML_BITS; break; default: break;
}
m_pColl->SetPoolFormatId( nId ); break;
} case SfxStyleFamily::Frame:
{
OSL_ENSURE(m_pFrameFormat, "Where's FrameFormat");
case SfxStyleFamily::Page :
{
OSL_ENSURE(m_pDesc, "Where's PageDescriptor");
if (m_rDoc.FindPageDesc(m_pDesc->GetName(), &nPgDscPos))
{
pNewDsc.reset( new SwPageDesc( *m_pDesc ) ); // #i48949# - no undo actions for the // copy of the page style
::sw::UndoGuard const ug(m_rDoc.GetIDocumentUndoRedo());
m_rDoc.CopyPageDesc(*m_pDesc, *pNewDsc); // #i7983#
pFormat = &pNewDsc->GetMaster();
// tdf#134166: Changing page style can affect toolbar button state. if (SwEditShell* pSh = m_rDoc.GetEditShell())
pSh->CallChgLnk();
}
} break;
case SfxStyleFamily::Pseudo:
{
OSL_ENSURE(m_pNumRule, "Where's NumRule");
if (!m_pNumRule) break;
const SfxPoolItem* pItem; switch( rSet.GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem ))
{ case SfxItemState::SET:
{
SvxNumRule& rSetRule = const_cast<SvxNumRule&>(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
rSetRule.UnLinkGraphics();
SwNumRule aSetRule(*m_pNumRule);
aSetRule.SetSvxRule(rSetRule, &m_rDoc);
m_rDoc.ChgNumRuleFormats( aSetRule );
} break; case SfxItemState::INVALID: // set NumRule to default values // what are the default values?
{
SwNumRule aRule( m_pNumRule->GetName(), // #i89178#
numfunc::GetDefaultPositionAndSpaceMode() );
m_rDoc.ChgNumRuleFormats( aRule );
} break; default: break;
}
} break;
if( pFormat && rSet.Count())
{
{ // Own scope for SfxItemIter needed to have it registered at rSet as short as possible // due to m_aCoreSet.ClearItem() below - rSet *is* equal to m_aCoreSet here sometimes. // This should *not* be the case (see OSL_ENSURE &rSet != &m_aCoreSet at the beginning // of this method) but happens because lcl_setLineNumbering calls GetItemSet/SetItemSet // at the *same* xStyleSheet. You can see that SwDocStyleSheet::GetItemSet() above // does return m_aCoreSet. I guess that lcl_setLineNumbering should not do that...
SfxItemIter aIter( rSet ); const SfxPoolItem* pItem = aIter.GetCurItem(); do
{ if( IsInvalidItem( pItem ) ) // Clear
{
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5
¤ Dauer der Verarbeitung: 0.68 Sekunden
(vorverarbeitet)
¤
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.