Related: fdo#79142 make SetName default to Reindexing

Change-Id: I408042bc7bf1a5a955203d65d2c68ebf9527b9b5
This commit is contained in:
Caolán McNamara
2014-05-28 13:23:52 +01:00
parent 7b9b57b419
commit 05e2fd162e
12 changed files with 29 additions and 34 deletions

View File

@@ -54,7 +54,6 @@ class SfxManageStyleSheetPage : public SfxTabPage
SfxStyleSheetBase *pStyle; SfxStyleSheetBase *pStyle;
SfxStyleFamilies *pFamilies; SfxStyleFamilies *pFamilies;
SfxStyleSheetBasePool *pPool;
const SfxStyleFamilyItem *pItem; const SfxStyleFamilyItem *pItem;
OUString aBuf; OUString aBuf;
bool bModified; bool bModified;

View File

@@ -105,8 +105,13 @@ public:
// returns the internal name of this style // returns the internal name of this style
virtual const OUString& GetName() const; virtual const OUString& GetName() const;
// sets the internal name of this style // sets the internal name of this style.
virtual bool SetName( const OUString& ); //
// 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. /** 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. */ If the display name is empty, this method returns the internal name. */

View File

@@ -57,7 +57,7 @@ public:
virtual const OUString& GetParent() const SAL_OVERRIDE; virtual const OUString& GetParent() const SAL_OVERRIDE;
virtual const OUString& GetFollow() 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 void SetUsage( ScStyleSheet::Usage eUse ) const
{ eUsage = eUse; } { eUsage = eUse; }

View File

@@ -303,13 +303,13 @@ const OUString& ScStyleSheet::GetFollow() const
//! Flag gesetzt und abgefragt werden. //! Flag gesetzt und abgefragt werden.
//! Die ganze Abfrage muss raus, wenn fuer eine neue Datei-Version die Namens-Umsetzung wegfaellt. //! 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); OUString aFileStdName = OUString(STRING_STANDARD);
if ( rNew == aFileStdName && aFileStdName != ScGlobal::GetRscString(STR_STYLENAME_STANDARD) ) if ( rNew == aFileStdName && aFileStdName != ScGlobal::GetRscString(STR_STYLENAME_STANDARD) )
return false; return false;
else else
return SfxStyleSheet::SetName( rNew ); return SfxStyleSheet::SetName(rNew, bReindexNow);
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -60,7 +60,7 @@ public:
virtual bool HasFollowSupport() const SAL_OVERRIDE; virtual bool HasFollowSupport() const SAL_OVERRIDE;
virtual bool HasParentSupport() const SAL_OVERRIDE; virtual bool HasParentSupport() const SAL_OVERRIDE;
virtual bool HasClearParentSupport() 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; virtual void SetHelpId( const OUString& r, sal_uLong nId ) SAL_OVERRIDE;
void AdjustToFontHeight(SfxItemSet& rSet, bool bOnlyMissingItems = true); void AdjustToFontHeight(SfxItemSet& rSet, bool bOnlyMissingItems = true);

View File

@@ -1103,7 +1103,6 @@ void SdDrawDocument::RenameLayoutTemplate(const OUString& rOldLayoutName, const
aReplList.push_back(aReplData); aReplList.push_back(aReplData);
pSheet->SetName(aSheetName); pSheet->SetName(aSheetName);
mxStyleSheetPool.get()->Reindex();
} }
pSheet = aIter.Next(); pSheet = aIter.Next();

View File

@@ -1038,16 +1038,18 @@ void SdStyleSheetPool::UpdateStdNames()
// Sheet does exist: old sheet has to be removed // Sheet does exist: old sheet has to be removed
aEraseList.push_back( pStyle ); aEraseList.push_back( pStyle );
} }
Reindex();
} }
} }
} }
} }
// styles that could not be renamed, must be removed if (!aEraseList.empty())
for ( size_t i = 0, n = aEraseList.size(); i < n; ++i ) {
Remove( aEraseList[ i ] ); // styles that could not be renamed, must be removed
Reindex(); for ( size_t i = 0, n = aEraseList.size(); i < n; ++i )
Remove( aEraseList[ i ] );
Reindex();
}
} }
// Set new SvxNumBulletItem for the respective style sheet // Set new SvxNumBulletItem for the respective style sheet

View File

@@ -625,15 +625,11 @@ bool SdStyleSheet::HasClearParentSupport() const
return true; return true;
} }
bool SdStyleSheet::SetName(const OUString& rName, bool bReindexNow)
bool SdStyleSheet::SetName( const OUString& rName )
{ {
return SfxStyleSheet::SetName( rName ); return SfxStyleSheet::SetName(rName, bReindexNow);
} }
void SdStyleSheet::SetHelpId( const OUString& r, sal_uLong nId ) void SdStyleSheet::SetHelpId( const OUString& r, sal_uLong nId )
{ {
SfxStyleSheet::SetHelpId( r, nId ); SfxStyleSheet::SetHelpId( r, nId );

View File

@@ -45,7 +45,6 @@
SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemSet& rAttrSet) SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemSet& rAttrSet)
: SfxTabPage(pParent, "ManageStylePage", "sfx/ui/managestylepage.ui", rAttrSet) : SfxTabPage(pParent, "ManageStylePage", "sfx/ui/managestylepage.ui", rAttrSet)
, pStyle(&((SfxStyleDialog*)GetParentDialog())->GetStyleSheet()) , pStyle(&((SfxStyleDialog*)GetParentDialog())->GetStyleSheet())
, pPool(NULL)
, pItem(0) , pItem(0)
, bModified(false) , bModified(false)
, aName(pStyle->GetName()) , aName(pStyle->GetName())
@@ -79,6 +78,7 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS
OSL_ENSURE( pResMgr, "No ResMgr in Module" ); OSL_ENSURE( pResMgr, "No ResMgr in Module" );
pFamilies = new SfxStyleFamilies( ResId( DLG_STYLE_DESIGNER, *pResMgr ) ); pFamilies = new SfxStyleFamilies( ResId( DLG_STYLE_DESIGNER, *pResMgr ) );
SfxStyleSheetBasePool* pPool = 0;
SfxObjectShell* pDocShell = SfxObjectShell::Current(); SfxObjectShell* pDocShell = SfxObjectShell::Current();
if ( pDocShell ) if ( pDocShell )
@@ -105,7 +105,6 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS
aNoName += OUString::number( nNo ); aNoName += OUString::number( nNo );
} }
pStyle->SetName( aNoName ); pStyle->SetName( aNoName );
pPool->Reindex();
aName = aNoName; aName = aNoName;
aFollow = pStyle->GetFollow(); aFollow = pStyle->GetFollow();
aParent = pStyle->GetParent(); aParent = pStyle->GetParent();
@@ -420,11 +419,7 @@ void SfxManageStyleSheetPage::Reset( const SfxItemSet& /*rAttrSet*/ )
OUString sCmp( pStyle->GetName() ); OUString sCmp( pStyle->GetName() );
if ( sCmp != aName ) if ( sCmp != aName )
{ pStyle->SetName( aName );
pStyle->SetName(aName);
if (pPool)
pPool->Reindex();
}
m_pNameRw->SetText( aName ); m_pNameRw->SetText( aName );
m_pNameRw->SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); m_pNameRw->SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
@@ -547,8 +542,7 @@ int SfxManageStyleSheetPage::DeactivatePage( SfxItemSet* pItemSet )
if ( m_pNameRw->HasFocus() ) if ( m_pNameRw->HasFocus() )
LoseFocusHdl( m_pNameRw ); LoseFocusHdl( m_pNameRw );
bool bOk = pStyle->SetName(comphelper::string::stripStart(m_pNameRw->GetText(), ' ')); if (!pStyle->SetName(comphelper::string::stripStart(m_pNameRw->GetText(), ' ')))
if (!bOk)
{ {
InfoBox aBox( this, SfxResId( MSG_TABPAGE_INVALIDNAME ) ); InfoBox aBox( this, SfxResId( MSG_TABPAGE_INVALIDNAME ) );
aBox.Execute(); aBox.Execute();
@@ -556,8 +550,6 @@ int SfxManageStyleSheetPage::DeactivatePage( SfxItemSet* pItemSet )
m_pNameRw->SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); m_pNameRw->SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
return SfxTabPage::KEEP_PAGE; return SfxTabPage::KEEP_PAGE;
} }
else if (pPool)
pPool->Reindex();
bModified = true; bModified = true;
} }

View File

@@ -155,7 +155,7 @@ const OUString& SfxStyleSheetBase::GetName() const
return aName; return aName;
} }
bool SfxStyleSheetBase::SetName( const OUString& rName ) bool SfxStyleSheetBase::SetName(const OUString& rName, bool bReIndexNow)
{ {
if(rName.isEmpty()) if(rName.isEmpty())
return false; return false;
@@ -178,6 +178,8 @@ bool SfxStyleSheetBase::SetName( const OUString& rName )
if ( aFollow == aName ) if ( aFollow == aName )
aFollow = rName; aFollow = rName;
aName = rName; aName = rName;
if (bReIndexNow)
pPool->Reindex();
pPool->SetSearchMask(eTmpFam, nTmpMask); pPool->SetSearchMask(eTmpFam, nTmpMask);
pPool->Broadcast( SfxStyleSheetHintExtended( pPool->Broadcast( SfxStyleSheetHintExtended(
SFX_STYLESHEET_MODIFIED, aOldName, *this ) ); SFX_STYLESHEET_MODIFIED, aOldName, *this ) );

View File

@@ -123,7 +123,7 @@ public:
void PresetParent(const OUString& rName){ aParent = rName; } void PresetParent(const OUString& rName){ aParent = rName; }
void PresetFollow(const OUString& rName){ aFollow = 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 SetParent( const OUString& rStr) SAL_OVERRIDE;
virtual bool SetFollow( const OUString& rStr) SAL_OVERRIDE; virtual bool SetFollow( const OUString& rStr) SAL_OVERRIDE;

View File

@@ -869,14 +869,14 @@ OUString SwDocStyleSheet::GetDescription()
} }
// Set names // Set names
bool SwDocStyleSheet::SetName( const OUString& rStr) bool SwDocStyleSheet::SetName(const OUString& rStr, bool bReindexNow)
{ {
if( rStr.isEmpty() ) if( rStr.isEmpty() )
return false; return false;
if( aName != rStr ) if( aName != rStr )
{ {
if( !SfxStyleSheetBase::SetName( rStr )) if( !SfxStyleSheetBase::SetName(rStr, bReindexNow))
return false; return false;
} }
else if(!bPhysical) else if(!bPhysical)