summaryrefslogtreecommitdiff
path: root/sfx2/source/dialog
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-07-24 11:55:46 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-07-24 12:46:57 +0100
commite904562af54545684b32d2042ded6bdb9459edca (patch)
tree1fa0f2d0b195647e601a72fe926b085ccdc23b8d /sfx2/source/dialog
parent965b2059cb6965df643d5245eb318c087bc251c4 (diff)
Related: fdo#81641 create new styles with an initial name
instead of creating with a blank name and changing it later this way undo of a style creation is initialized with its name and so create a style followed by deleting a style and undoing all those steps doesn't crash Change-Id: Ida7a34410d5d7b05edcb86950aabb3c672b82c8f
Diffstat (limited to 'sfx2/source/dialog')
-rw-r--r--sfx2/source/dialog/mgetempl.cxx11
-rw-r--r--sfx2/source/dialog/styledlg.cxx14
2 files changed, 15 insertions, 10 deletions
diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx
index 61a59365fb1f..2a7aff7f29cb 100644
--- a/sfx2/source/dialog/mgetempl.cxx
+++ b/sfx2/source/dialog/mgetempl.cxx
@@ -96,16 +96,7 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS
if ( pStyle->GetName().isEmpty() && pPool )
{
// NullString as Name -> generate Name
- OUString aNoName( SfxResId(STR_NONAME).toString() );
- sal_uInt16 nNo = 1;
- OUString aNo( aNoName );
- aNoName += OUString::number( nNo );
- while ( pPool->Find( aNoName ) )
- {
- ++nNo;
- aNoName = aNo;
- aNoName += OUString::number( nNo );
- }
+ OUString aNoName(SfxStyleDialog::GenerateUnusedName(*pPool));
pStyle->SetName( aNoName );
aName = aNoName;
aFollow = pStyle->GetFollow();
diff --git a/sfx2/source/dialog/styledlg.cxx b/sfx2/source/dialog/styledlg.cxx
index c9231d4549c9..664468a769d5 100644
--- a/sfx2/source/dialog/styledlg.cxx
+++ b/sfx2/source/dialog/styledlg.cxx
@@ -147,5 +147,19 @@ IMPL_LINK( SfxStyleDialog, CancelHdl, Button *, pButton )
return 0;
}
+OUString SfxStyleDialog::GenerateUnusedName(SfxStyleSheetBasePool &rPool)
+{
+ OUString aNoName(SfxResId(STR_NONAME).toString());
+ sal_uInt16 nNo = 1;
+ OUString aNo(aNoName);
+ aNoName += OUString::number(nNo);
+ while (rPool.Find(aNoName))
+ {
+ ++nNo;
+ aNoName = aNo;
+ aNoName += OUString::number(nNo);
+ }
+ return aNoName;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */