diff --git a/include/sfx2/mgetempl.hxx b/include/sfx2/mgetempl.hxx index 085da933ed2e..6082fbe370b3 100644 --- a/include/sfx2/mgetempl.hxx +++ b/include/sfx2/mgetempl.hxx @@ -54,7 +54,6 @@ class SfxManageStyleSheetPage : public SfxTabPage SfxStyleSheetBase *pStyle; SfxStyleFamilies *pFamilies; - SfxStyleSheetBasePool *pPool; const SfxStyleFamilyItem *pItem; OUString aBuf; bool bModified; diff --git a/include/svl/style.hxx b/include/svl/style.hxx index 493ba24004d3..f82d14266fb3 100644 --- a/include/svl/style.hxx +++ b/include/svl/style.hxx @@ -105,8 +105,13 @@ public: // returns the internal name of this style virtual const OUString& GetName() const; - // sets the internal name of this style - virtual bool SetName( const OUString& ); + // sets the internal name of this style. + // + // If the name of a style is changed, then the styles container needs to be + // reindexed (see IndexedStyleSheets). If you set bReindexNow to false to + // defer that indexing, then you must call the Reindex manually on the + // SfxStyleSheetBasePool parent. + virtual bool SetName(const OUString& rNewName, bool bReindexNow = true); /** returns the display name of this style, it is used at the user interface. If the display name is empty, this method returns the internal name. */ diff --git a/sc/inc/stlsheet.hxx b/sc/inc/stlsheet.hxx index 71e6a4b4c684..f242535685f3 100644 --- a/sc/inc/stlsheet.hxx +++ b/sc/inc/stlsheet.hxx @@ -57,7 +57,7 @@ public: virtual const OUString& GetParent() const SAL_OVERRIDE; virtual const OUString& GetFollow() const SAL_OVERRIDE; - virtual bool SetName( const OUString& ) SAL_OVERRIDE; + virtual bool SetName(const OUString& rNewName, bool bReindexNow = true) SAL_OVERRIDE; void SetUsage( ScStyleSheet::Usage eUse ) const { eUsage = eUse; } diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx index 0e7fd7ca172f..cac09e9d085a 100644 --- a/sc/source/core/data/stlsheet.cxx +++ b/sc/source/core/data/stlsheet.cxx @@ -303,13 +303,13 @@ const OUString& ScStyleSheet::GetFollow() const //! Flag gesetzt und abgefragt werden. //! Die ganze Abfrage muss raus, wenn fuer eine neue Datei-Version die Namens-Umsetzung wegfaellt. -bool ScStyleSheet::SetName( const OUString& rNew ) +bool ScStyleSheet::SetName(const OUString& rNew, bool bReindexNow) { OUString aFileStdName = OUString(STRING_STANDARD); if ( rNew == aFileStdName && aFileStdName != ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ) return false; else - return SfxStyleSheet::SetName( rNew ); + return SfxStyleSheet::SetName(rNew, bReindexNow); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/inc/stlsheet.hxx b/sd/inc/stlsheet.hxx index cad63a7d5163..0811142fa1d2 100644 --- a/sd/inc/stlsheet.hxx +++ b/sd/inc/stlsheet.hxx @@ -60,7 +60,7 @@ public: virtual bool HasFollowSupport() const SAL_OVERRIDE; virtual bool HasParentSupport() const SAL_OVERRIDE; virtual bool HasClearParentSupport() const SAL_OVERRIDE; - virtual bool SetName( const OUString& ) SAL_OVERRIDE; + virtual bool SetName(const OUString& rNewName, bool bReindexNow = true) SAL_OVERRIDE; virtual void SetHelpId( const OUString& r, sal_uLong nId ) SAL_OVERRIDE; void AdjustToFontHeight(SfxItemSet& rSet, bool bOnlyMissingItems = true); diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index 061ac8d4cc04..c2e5f57466ab 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -1103,7 +1103,6 @@ void SdDrawDocument::RenameLayoutTemplate(const OUString& rOldLayoutName, const aReplList.push_back(aReplData); pSheet->SetName(aSheetName); - mxStyleSheetPool.get()->Reindex(); } pSheet = aIter.Next(); diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx index 0c7fff4a7d01..3d1ee5627b1f 100644 --- a/sd/source/core/stlpool.cxx +++ b/sd/source/core/stlpool.cxx @@ -1038,16 +1038,18 @@ void SdStyleSheetPool::UpdateStdNames() // Sheet does exist: old sheet has to be removed aEraseList.push_back( pStyle ); } - Reindex(); } } } } - // styles that could not be renamed, must be removed - for ( size_t i = 0, n = aEraseList.size(); i < n; ++i ) - Remove( aEraseList[ i ] ); - Reindex(); + if (!aEraseList.empty()) + { + // styles that could not be renamed, must be removed + for ( size_t i = 0, n = aEraseList.size(); i < n; ++i ) + Remove( aEraseList[ i ] ); + Reindex(); + } } // Set new SvxNumBulletItem for the respective style sheet diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx index c19cba34dd75..eb7862fa50fa 100644 --- a/sd/source/core/stlsheet.cxx +++ b/sd/source/core/stlsheet.cxx @@ -625,15 +625,11 @@ bool SdStyleSheet::HasClearParentSupport() const return true; } - - -bool SdStyleSheet::SetName( const OUString& rName ) +bool SdStyleSheet::SetName(const OUString& rName, bool bReindexNow) { - return SfxStyleSheet::SetName( rName ); + return SfxStyleSheet::SetName(rName, bReindexNow); } - - void SdStyleSheet::SetHelpId( const OUString& r, sal_uLong nId ) { SfxStyleSheet::SetHelpId( r, nId ); diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx index 07e7b1d49569..733abce27130 100644 --- a/sfx2/source/dialog/mgetempl.cxx +++ b/sfx2/source/dialog/mgetempl.cxx @@ -45,7 +45,6 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemSet& rAttrSet) : SfxTabPage(pParent, "ManageStylePage", "sfx/ui/managestylepage.ui", rAttrSet) , pStyle(&((SfxStyleDialog*)GetParentDialog())->GetStyleSheet()) - , pPool(NULL) , pItem(0) , bModified(false) , aName(pStyle->GetName()) @@ -79,6 +78,7 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS OSL_ENSURE( pResMgr, "No ResMgr in Module" ); pFamilies = new SfxStyleFamilies( ResId( DLG_STYLE_DESIGNER, *pResMgr ) ); + SfxStyleSheetBasePool* pPool = 0; SfxObjectShell* pDocShell = SfxObjectShell::Current(); if ( pDocShell ) @@ -105,7 +105,6 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS aNoName += OUString::number( nNo ); } pStyle->SetName( aNoName ); - pPool->Reindex(); aName = aNoName; aFollow = pStyle->GetFollow(); aParent = pStyle->GetParent(); @@ -420,11 +419,7 @@ void SfxManageStyleSheetPage::Reset( const SfxItemSet& /*rAttrSet*/ ) OUString sCmp( pStyle->GetName() ); if ( sCmp != aName ) - { - pStyle->SetName(aName); - if (pPool) - pPool->Reindex(); - } + pStyle->SetName( aName ); m_pNameRw->SetText( aName ); m_pNameRw->SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); @@ -547,8 +542,7 @@ int SfxManageStyleSheetPage::DeactivatePage( SfxItemSet* pItemSet ) if ( m_pNameRw->HasFocus() ) LoseFocusHdl( m_pNameRw ); - bool bOk = pStyle->SetName(comphelper::string::stripStart(m_pNameRw->GetText(), ' ')); - if (!bOk) + if (!pStyle->SetName(comphelper::string::stripStart(m_pNameRw->GetText(), ' '))) { InfoBox aBox( this, SfxResId( MSG_TABPAGE_INVALIDNAME ) ); aBox.Execute(); @@ -556,8 +550,6 @@ int SfxManageStyleSheetPage::DeactivatePage( SfxItemSet* pItemSet ) m_pNameRw->SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); return SfxTabPage::KEEP_PAGE; } - else if (pPool) - pPool->Reindex(); bModified = true; } diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx index 175f7ceee101..40e8eeec207f 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -155,7 +155,7 @@ const OUString& SfxStyleSheetBase::GetName() const return aName; } -bool SfxStyleSheetBase::SetName( const OUString& rName ) +bool SfxStyleSheetBase::SetName(const OUString& rName, bool bReIndexNow) { if(rName.isEmpty()) return false; @@ -178,6 +178,8 @@ bool SfxStyleSheetBase::SetName( const OUString& rName ) if ( aFollow == aName ) aFollow = rName; aName = rName; + if (bReIndexNow) + pPool->Reindex(); pPool->SetSearchMask(eTmpFam, nTmpMask); pPool->Broadcast( SfxStyleSheetHintExtended( SFX_STYLESHEET_MODIFIED, aOldName, *this ) ); diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx index c93984daedee..957be859dc69 100644 --- a/sw/inc/docstyle.hxx +++ b/sw/inc/docstyle.hxx @@ -123,7 +123,7 @@ public: void PresetParent(const OUString& rName){ aParent = rName; } void PresetFollow(const OUString& rName){ aFollow = rName; } - virtual bool SetName( const OUString& rStr) SAL_OVERRIDE; + virtual bool SetName(const OUString& rNewName, bool bReindexNow = true) SAL_OVERRIDE; virtual bool SetParent( const OUString& rStr) SAL_OVERRIDE; virtual bool SetFollow( const OUString& rStr) SAL_OVERRIDE; diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx index 4a6d6860093c..4aaeb10a7c80 100644 --- a/sw/source/uibase/app/docstyle.cxx +++ b/sw/source/uibase/app/docstyle.cxx @@ -869,14 +869,14 @@ OUString SwDocStyleSheet::GetDescription() } // Set names -bool SwDocStyleSheet::SetName( const OUString& rStr) +bool SwDocStyleSheet::SetName(const OUString& rStr, bool bReindexNow) { if( rStr.isEmpty() ) return false; if( aName != rStr ) { - if( !SfxStyleSheetBase::SetName( rStr )) + if( !SfxStyleSheetBase::SetName(rStr, bReindexNow)) return false; } else if(!bPhysical)