diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-07-24 11:55:46 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-07-24 12:46:57 +0100 |
commit | e904562af54545684b32d2042ded6bdb9459edca (patch) | |
tree | 1fa0f2d0b195647e601a72fe926b085ccdc23b8d | |
parent | 965b2059cb6965df643d5245eb318c087bc251c4 (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
-rw-r--r-- | include/sfx2/styledlg.hxx | 3 | ||||
-rw-r--r-- | sfx2/source/dialog/mgetempl.cxx | 11 | ||||
-rw-r--r-- | sfx2/source/dialog/styledlg.cxx | 14 | ||||
-rw-r--r-- | sw/source/uibase/app/docst.cxx | 4 |
4 files changed, 22 insertions, 10 deletions
diff --git a/include/sfx2/styledlg.hxx b/include/sfx2/styledlg.hxx index eb6d15205409..41a90204a538 100644 --- a/include/sfx2/styledlg.hxx +++ b/include/sfx2/styledlg.hxx @@ -25,6 +25,7 @@ #include <sfx2/tabdlg.hxx> class SfxStyleSheetBase; +class SfxStyleSheetBasePool; class SFX2_DLLPUBLIC SfxStyleDialog: public SfxTabDialog { @@ -45,6 +46,8 @@ public: const SfxStyleSheetBase& GetStyleSheet() const { return *pStyle; } virtual short Ok() SAL_OVERRIDE; + + static OUString GenerateUnusedName(SfxStyleSheetBasePool &rPool); }; #endif 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: */ diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index 929919c5aa27..b9c27d8973f7 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -25,6 +25,7 @@ #include <hintids.hxx> #include <sfx2/app.hxx> +#include <sfx2/styledlg.hxx> #include <svl/whiter.hxx> #include <sfx2/templdlg.hxx> #include <sfx2/tplpitem.hxx> @@ -291,6 +292,9 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) false, &pItem )) sParent = ((const SfxStringItem*)pItem)->GetValue(); + if (sName.isEmpty() && mxBasePool.get()) + sName = SfxStyleDialog::GenerateUnusedName(*mxBasePool); + nRet = Edit( sName, sParent, nFamily, nMask, true, OString(), 0, rReq.IsAPI() ); } break; |