summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorJoren De Cuyper <joren.libreoffice@telenet.be>2013-03-09 20:30:30 +0100
committerFridrich Strba <fridrich@documentfoundation.org>2013-03-11 09:14:18 +0000
commit31d1748d6db7ca4da6302f3b09d2586ee2192d05 (patch)
treea32f0aff6c62328648b994a4712582811bc6bf7b /sfx2
parente047a967b0db8c61dc977b52f3876fc4e385ad77 (diff)
Minor improvements and UX-advice related to fdo#46718 delete multi style
UX advice see: http://lists.freedesktop.org/archives/libreoffice-ux-advise/2013-February/001816.html Summary: only show a dialog when the user is trying to delete an used style. Also warn him this change can only be partly undone (for now). Change-Id: Ib95143fcd4c7543f518e0d7fd4ff46a127efca2a Reviewed-on: https://gerrit.libreoffice.org/2618 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/dialog/dialog.src8
-rw-r--r--sfx2/source/dialog/templdlg.cxx86
2 files changed, 47 insertions, 47 deletions
diff --git a/sfx2/source/dialog/dialog.src b/sfx2/source/dialog/dialog.src
index f23deb150829..92b30f7b1f6e 100644
--- a/sfx2/source/dialog/dialog.src
+++ b/sfx2/source/dialog/dialog.src
@@ -56,13 +56,13 @@ InfoBox MSG_POOL_STYLE_NAME
{
Message [ en-US ] = "Name already exists as a default Style.\nPlease choose another name." ;
};
-String STR_DELETE_STYLE
+String STR_DELETE_STYLE_USED
{
- Text [ en-US ] = "Do you really want to delete Style $1?" ;
+ Text [ en-US ] = "One or more of the selected styles is in use in this document.\nIf you delete these styles, text will revert to the parent style.\n" ;
};
-String STR_DELETE_STYLE_USED
+String STR_DELETE_STYLE
{
- Text [ en-US ] = "You are deleting an applied Style!\n" ;
+ Text [ en-US ] = "Styles in use: " ;
};
Menu MN_CONTEXT_TEMPLDLG
{
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 404f0c9bc442..b3032bc3e725 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -1970,67 +1970,68 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl(void *)
{
if ( IsInitialized() && HasSelectedStyle() )
{
- sal_uLong SelectionCount = 0;
- sal_Bool bChecked = 0;
+ bool bUsedStyle = 0; // one of the selected styles are used in the document?
String aRet;
- SelectionCount = aFmtLb.GetSelectionCount();
std::vector<SvTreeListEntry*> aList;
-
SvTreeListEntry* pEntry = aFmtLb.FirstSelected();
+ const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
+
+ String aMsg = SfxResId(STR_DELETE_STYLE_USED).toString();
+ aMsg += SfxResId(STR_DELETE_STYLE).toString();
while (pEntry)
{
aList.push_back( pEntry );
- pEntry = aFmtLb.NextSelected( pEntry );
- SelectionCount++;
- }
-
- std::vector<SvTreeListEntry*>::const_iterator it = aList.begin(), itEnd = aList.end();
-
- for (; it != itEnd; ++it)
- {
+ // check the style is used or not
if (pTreeBox)
- aRet = pTreeBox->GetEntryText( *it );
+ aRet = pTreeBox->GetEntryText( pEntry );
else
- aRet = aFmtLb.GetEntryText( *it );
- const String aTemplName( aRet );
+ aRet = aFmtLb.GetEntryText( pEntry );
- const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
+ const String aTemplName( aRet );
SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( aTemplName, pItem->GetFamily(), SFXSTYLEBIT_ALL );
- bool bUsedStyle = pStyle->IsUsed();
- bool approve;
-
- if ( bChecked == 0 )
+ if ( pStyle->IsUsed() ) // pStyle is in use in the document?
{
- String aMsg;
- if ( bUsedStyle )
- aMsg = SfxResId(STR_DELETE_STYLE_USED).toString();
- aMsg += SfxResId(STR_DELETE_STYLE).toString();
- aMsg.SearchAndReplaceAscii( "$1", aTemplName );
- #if defined UNX
+ if (bUsedStyle) // add a seperator for the second and later styles
+ aMsg += ", ";
+ aMsg += aTemplName;
+ bUsedStyle = 1;
+ }
+
+ pEntry = aFmtLb.NextSelected( pEntry );
+ }
+
+ bool aApproved = 0;
+
+ // we only want to show the dialog once and if we want to delete a style in use (UX-advice)
+ if ( bUsedStyle )
+ {
+ #if defined UNX
QueryBox aBox( SFX_APP()->GetTopWindow(), WB_YES_NO | WB_DEF_NO, aMsg );
- #else
+ #else
QueryBox aBox( GetWindow(), WB_YES_NO | WB_DEF_NO , aMsg );
- #endif
- if (SelectionCount > 1) //show only when there are multiple styles selected/to be deleted
- aBox.SetDefaultCheckBoxText();
- approve = aBox.Execute() == RET_YES;
- bChecked = aBox.GetCheckBoxState();
- if ( approve == 0 && bChecked == 1)
- break;
- }
- else //if checkbox was selected previous time, don't ask again
- approve = 1;
+ #endif
+ aApproved = aBox.Execute() == RET_YES;
+ }
- if ( approve )
+ // if there are no used styles selected or the user approved the changes
+ if ( !bUsedStyle || aApproved )
+ {
+ std::vector<SvTreeListEntry*>::const_iterator it = aList.begin(), itEnd = aList.end();
+
+ for (; it != itEnd; ++it)
{
- PrepareDeleteAction();
+ if (pTreeBox)
+ aRet = pTreeBox->GetEntryText( *it );
+ else
+ aRet = aFmtLb.GetEntryText( *it );
+ const String aTemplName( aRet );
+ PrepareDeleteAction();
bDontUpdate = sal_True; // To prevent the Treelistbox to shut down while deleting
-
Execute_Impl( SID_STYLE_DELETE, aTemplName,
String(), (sal_uInt16)GetFamilyItem_Impl()->GetFamily() );
@@ -2040,10 +2041,9 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl(void *)
bDontUpdate = sal_False;
}
}
- --SelectionCount;
+ bDontUpdate = sal_False; //if everything is deleted set bDontUpdate back to false
+ UpdateStyles_Impl(UPDATE_FAMILY_LIST); //and force-update the list
}
- bDontUpdate = sal_False; //if everything is deleted set bDontUpdate back to false
- UpdateStyles_Impl(UPDATE_FAMILY_LIST); //and force-update the list
}
}