[PATCH] fdo#46718 Delete multiple styles at once
Joren De Cuyper (via Code Review)
gerrit at gerrit.libreoffice.org
Thu Jan 17 06:31:19 PST 2013
Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/1737
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/37/1737/1
fdo#46718 Delete multiple styles at once
Change-Id: I5f5982b2a2768d021f24693a285274544e07e40f
---
M sfx2/source/dialog/templdlg.cxx
1 file changed, 49 insertions(+), 18 deletions(-)
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index b315453..8831f3e 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -911,6 +911,7 @@
aFilterLb.SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FilterSelectHdl ) );
aFmtLb.SetDoubleClickHdl( LINK( this, SfxCommonTemplateDialog_Impl, ApplyHdl ) );
aFmtLb.SetSelectHdl( LINK( this, SfxCommonTemplateDialog_Impl, FmtSelectHdl ) );
+ aFmtLb.SetSelectionMode(MULTIPLE_SELECTION);
aFilterLb.Show();
aFmtLb.Show();
@@ -1046,7 +1047,7 @@
{
aFmtLb.MakeVisible( pEntry );
aFmtLb.Select( pEntry );
- bWaterDisabled = !HasSelectedStyle();
+ bWaterDisabled = (aFmtLb.GetSelectionCount() <=1 ? sal_False : sal_True);
FmtSelectHdl( NULL );
}
}
@@ -1306,7 +1307,8 @@
bWaterDisabled = pItem == 0;
if(!bWaterDisabled)
- bWaterDisabled = !HasSelectedStyle();
+ //make sure the watercan is only activated when there is (only) one selection
+ bWaterDisabled = (aFmtLb.GetSelectionCount() <=1 ? sal_False : sal_True);
if(pItem && !bWaterDisabled)
{
@@ -1644,6 +1646,7 @@
aUpdName.SetValue(aTemplName);
pItems[ nCount++ ] = &aUpdName;
}
+
if ( rRefStr.Len() )
pItems[ nCount++ ] = &aRefName;
@@ -1660,7 +1663,7 @@
if ( !pItem || aDeleted )
return sal_False;
- if ( nId == SID_STYLE_NEW || SID_STYLE_EDIT == nId )
+ if ( (nId == SID_STYLE_NEW || SID_STYLE_EDIT == nId) && (aFmtLb.GetSelectionCount() <= 1) )
{
SfxUInt16Item *pFilterItem = PTR_CAST(SfxUInt16Item, pItem);
OSL_ENSURE(pFilterItem, "SfxUINT16Item expected");
@@ -1899,7 +1902,7 @@
void SfxCommonTemplateDialog_Impl::NewHdl(void *)
{
String aEmpty;
- if ( nActFamily != 0xffff )
+ if ( nActFamily != 0xffff && (aFmtLb.GetSelectionCount() <= 1))
{
Window* pTmp;
pTmp = Application::GetDefDialogParent();
@@ -1963,10 +1966,35 @@
{
if ( IsInitialized() && HasSelectedStyle() )
{
- const String aTemplName( GetSelectedEntry() );
- SfxStyleSheetBase* pStyle = GetSelectedStyle();
- if ( pStyle )
+ sal_uLong SelectionCount = 0;
+ String aRet;
+
+ SelectionCount = aFmtLb.GetSelectionCount();
+ std::vector<SvTreeListEntry*> aList;
+
+ SvTreeListEntry* pEntry = aFmtLb.FirstSelected();
+
+ 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)
+ {
+ if (pTreeBox)
+ aRet = pTreeBox->GetEntryText( *it );
+ else
+ aRet = aFmtLb.GetEntryText( *it );
+ const String aTemplName( aRet );
+
+ const SfxStyleFamilyItem* pItem = GetFamilyItem_Impl();
+
+ SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( aTemplName, pItem->GetFamily(), SFXSTYLEBIT_ALL );
+
String aMsg;
if ( pStyle->IsUsed() )
aMsg = SfxResId(STR_DELETE_STYLE_USED).toString();
@@ -1981,21 +2009,21 @@
{
PrepareDeleteAction();
- if ( pTreeBox ) // To prevent the Treelistbox to shut down while
- // deleting.
- {
- bDontUpdate = sal_True;
- }
+ 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( pTreeBox->FirstSelected() );
+ 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
}
}
@@ -2045,7 +2073,7 @@
const SfxStyleSheetBase *pStyle =
pStyleSheetPool->Find(aTemplName,eFam, pTreeBox? SFXSTYLEBIT_ALL : nFilter);
- OSL_ENSURE(pStyle, "Style ot found");
+ OSL_ENSURE(pStyle, "Style not found");
if(pStyle && pStyle->IsUserDefined())
{
EnableDel(sal_True);
@@ -2107,7 +2135,7 @@
if ( IsInitialized() &&
IsCheckedItem(SID_STYLE_WATERCAN) &&
// only if that region is allowed
- 0 != pFamilyState[nActFamily-1] )
+ 0 != pFamilyState[nActFamily-1] && (aFmtLb.GetSelectionCount() <= 1) )
{
String aEmpty;
Execute_Impl(SID_STYLE_WATERCAN,
@@ -2176,9 +2204,12 @@
void SfxCommonTemplateDialog_Impl::EnableExample_Impl(sal_uInt16 nId, sal_Bool bEnable)
{
if( nId == SID_STYLE_NEW_BY_EXAMPLE )
- bNewByExampleDisabled = !bEnable;
+ {
+ bNewByExampleDisabled = (aFmtLb.GetSelectionCount() <=1 ? !bEnable : sal_True);
+ }
else if( nId == SID_STYLE_UPDATE_BY_EXAMPLE )
- bUpdateByExampleDisabled = !bEnable;
+ bUpdateByExampleDisabled = (aFmtLb.GetSelectionCount() <=1 ? !bEnable : sal_True);
+
EnableItem(nId, bEnable);
}
@@ -2603,7 +2634,7 @@
}
bWaterDisabled = sal_False;
- bCanNew = sal_True;
+ bCanNew = (aFmtLb.GetSelectionCount() <=1 ? sal_True : sal_False);
bTreeDrag = sal_True;
bUpdateByExampleDisabled = sal_False;
--
To view, visit https://gerrit.libreoffice.org/1737
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f5982b2a2768d021f24693a285274544e07e40f
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Joren De Cuyper <joren.libreoffice at telenet.be>
More information about the LibreOffice
mailing list