Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2618

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/18/2618/1

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
---
M sfx2/source/dialog/dialog.src
M sfx2/source/dialog/templdlg.cxx
2 files changed, 40 insertions(+), 53 deletions(-)



diff --git a/sfx2/source/dialog/dialog.src b/sfx2/source/dialog/dialog.src
index f23deb1..c430d1a 100644
--- a/sfx2/source/dialog/dialog.src
+++ b/sfx2/source/dialog/dialog.src
@@ -56,13 +56,9 @@
 {
     Message [ en-US ] = "Name already exists as a default Style.\nPlease choose another name." ;
 };
-String STR_DELETE_STYLE
-{
-    Text [ en-US ] = "Do you really want to delete Style $1?" ;
-};
 String STR_DELETE_STYLE_USED
 {
-    Text [ en-US ] = "You are deleting an applied Style!\n" ;
+    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.\nThis operation may not be undone." ;
 };
 Menu MN_CONTEXT_TEMPLDLG
 {
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 404f0c9..10ac8b6 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -1970,77 +1970,68 @@
 {
     if ( IsInitialized() && HasSelectedStyle() )
     {
-        sal_uLong SelectionCount = 0;
-        sal_Bool bChecked = 0;
+        bool aApprove = 0;      // use to skip the dialog
+        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();
 
         while (pEntry)
         {
             aList.push_back( pEntry );
+            // check the style is used or not
+            if (pTreeBox)
+                aRet = pTreeBox->GetEntryText( pEntry );
+            else
+                aRet = aFmtLb.GetEntryText( pEntry );
+
+            const String aTemplName( aRet );
+            SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( aTemplName, pItem->GetFamily(), 
SFXSTYLEBIT_ALL );
+
+            if ( !bUsedStyle && pStyle->IsUsed() )  // pStyle is in use in the document?
+                bUsedStyle = 1;
+
             pEntry = aFmtLb.NextSelected( pEntry );
-            SelectionCount++;
         }
 
         std::vector<SvTreeListEntry*>::const_iterator it = aList.begin(), itEnd = aList.end();
 
         for (; it != itEnd; ++it)
         {
+            // we only want to show the dialog once and if we want to delete a style in use 
(UX-advice)
+            if ( bUsedStyle && !aApprove )
+            {
+                String aMsg = SfxResId(STR_DELETE_STYLE_USED).toString();
+                #if defined UNX
+                QueryBox aBox( SFX_APP()->GetTopWindow(), WB_YES_NO | WB_DEF_NO, aMsg );
+                #else
+                QueryBox aBox( GetWindow(), WB_YES_NO | WB_DEF_NO , aMsg );
+                #endif
+                aApprove = aBox.Execute() == RET_YES;
+                if ( aApprove == 0 )
+                    break;
+            }
+            else
+                aApprove = 1;
+
             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() );
 
-            const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
-
-            SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( aTemplName, pItem->GetFamily(), 
SFXSTYLEBIT_ALL );
-
-            bool bUsedStyle = pStyle->IsUsed();
-            bool approve;
-
-            if ( bChecked == 0 )
+            if ( pTreeBox )
             {
-                String aMsg;
-                if ( bUsedStyle )
-                    aMsg = SfxResId(STR_DELETE_STYLE_USED).toString();
-                aMsg += SfxResId(STR_DELETE_STYLE).toString();
-                aMsg.SearchAndReplaceAscii( "$1", aTemplName );
-    #if defined UNX
-                QueryBox aBox( SFX_APP()->GetTopWindow(), WB_YES_NO | WB_DEF_NO, aMsg );
-    #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;
+                pTreeBox->RemoveParentKeepChildren( *it );
+                bDontUpdate = sal_False;
             }
-            else //if checkbox was selected previous time, don't ask again
-                approve = 1;
-
-            if ( approve )
-            {
-                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() );
-
-                if ( pTreeBox )
-                {
-                    pTreeBox->RemoveParentKeepChildren( *it );
-                    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

-- 
To view, visit https://gerrit.libreoffice.org/2618
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib95143fcd4c7543f518e0d7fd4ff46a127efca2a
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Joren De Cuyper <joren.libreoffice@telenet.be>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.