Kaydet (Commit) aa8b2689 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: fdo#79142 When Creating Styles - The 2nd One Always Replaces the 1st

regression from 0c17ccc4

I think it might actually make more sense for SetName to always Reindex
and have another SetNameNoReindex for selective use where its known
safe to get away with it

Change-Id: I6bf7e1f45130f741954ab525b838f3ac5ff61a89
üst 72827968
...@@ -54,6 +54,7 @@ class SfxManageStyleSheetPage : public SfxTabPage ...@@ -54,6 +54,7 @@ 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;
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
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())
...@@ -78,7 +79,6 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS ...@@ -78,7 +79,6 @@ 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,6 +105,7 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS ...@@ -105,6 +105,7 @@ 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();
...@@ -419,7 +420,11 @@ void SfxManageStyleSheetPage::Reset( const SfxItemSet& /*rAttrSet*/ ) ...@@ -419,7 +420,11 @@ 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 ) );
...@@ -542,7 +547,8 @@ int SfxManageStyleSheetPage::DeactivatePage( SfxItemSet* pItemSet ) ...@@ -542,7 +547,8 @@ int SfxManageStyleSheetPage::DeactivatePage( SfxItemSet* pItemSet )
if ( m_pNameRw->HasFocus() ) if ( m_pNameRw->HasFocus() )
LoseFocusHdl( m_pNameRw ); LoseFocusHdl( m_pNameRw );
if (!pStyle->SetName(comphelper::string::stripStart(m_pNameRw->GetText(), ' '))) bool bOk = 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();
...@@ -550,6 +556,8 @@ int SfxManageStyleSheetPage::DeactivatePage( SfxItemSet* pItemSet ) ...@@ -550,6 +556,8 @@ 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;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment