summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat@free.fr>2012-11-25 15:24:42 +0100
committerCédric Bosdonnat <cedric.bosdonnat@free.fr>2012-11-30 18:07:12 +0100
commit2fd9c2bf9af0c50dae3af3dbe5e22965ccdb4ae7 (patch)
tree2a0438c371fbb51a3d2e919793802d6827e07fbd /sfx2
parent36b7794d832dbc87c250ef02eee643c4ce68f87a (diff)
Allow to hide styles in the "Styles & Formating" dialog
In its current state, the feature only hides the styles. Things to sort out are: + Add some automatic filter to show hidden styles + Make the visibility persist in the file format Change-Id: I5904f41bb567add7b6bf501c6c5297f9f149a915
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/sfx2/sfxsids.hrc1
-rw-r--r--sfx2/inc/sfx2/tplpitem.hxx3
-rw-r--r--sfx2/sdi/sfx.sdi25
-rw-r--r--sfx2/source/dialog/dialog.hrc1
-rw-r--r--sfx2/source/dialog/dialog.src5
-rw-r--r--sfx2/source/dialog/templdlg.cxx56
-rw-r--r--sfx2/source/dialog/tplcitem.cxx3
-rw-r--r--sfx2/source/doc/objcont.cxx2
-rw-r--r--sfx2/source/inc/templdgi.hxx6
9 files changed, 87 insertions, 15 deletions
diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc
index 0998c65b53f4..34bc07f10d27 100644
--- a/sfx2/inc/sfx2/sfxsids.hrc
+++ b/sfx2/inc/sfx2/sfxsids.hrc
@@ -359,6 +359,7 @@
#define SID_STYLE_UPDATE_BY_EXAMPLE (SID_SFX_START + 556)
#define SID_STYLE_DRAGHIERARCHIE (SID_SFX_START + 565)
#define SID_STYLE_MASK (SID_SFX_START + 562)
+#define SID_STYLE_HIDE (SID_SFX_START + 1603)
#define SID_STYLE_UPD_BY_EX_NAME (SID_SFX_START + 1585)
#define SID_STYLE_REFERENCE (SID_SFX_START + 1602)
diff --git a/sfx2/inc/sfx2/tplpitem.hxx b/sfx2/inc/sfx2/tplpitem.hxx
index 71cfba4924ef..58f0618443ae 100644
--- a/sfx2/inc/sfx2/tplpitem.hxx
+++ b/sfx2/inc/sfx2/tplpitem.hxx
@@ -24,6 +24,7 @@
#include <tools/string.hxx>
#include <tools/rtti.hxx>
#include <svl/flagitem.hxx>
+#include <svl/style.hrc>
class SFX2_DLLPUBLIC SfxTemplateItem: public SfxFlagItem
{
@@ -33,7 +34,7 @@ public:
SfxTemplateItem();
SfxTemplateItem( sal_uInt16 nWhich,
const String &rStyle,
- sal_uInt16 nMask = 0xffff );
+ sal_uInt16 nMask = SFXSTYLEBIT_ALL );
SfxTemplateItem( const SfxTemplateItem& );
const String& GetStyleName() const { return aStyle; }
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index a7468cef6a2c..c269dea1e34f 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -1661,6 +1661,31 @@ SfxUInt16Item EditStyle SID_STYLE_EDIT
]
//--------------------------------------------------------------------------
+SfxUInt16Item HideStyle SID_STYLE_HIDE
+(SfxStringItem Param SID_STYLE_HIDE,SfxUInt16Item Family SID_STYLE_FAMILY)
+[
+ /* flags: */
+ AutoUpdate = FALSE,
+ Cachable = Cachable,
+ FastCall = FALSE,
+ HasCoreId = FALSE,
+ HasDialog = FALSE,
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Synchron;
+
+ /* config: */
+ AccelConfig = FALSE,
+ MenuConfig = FALSE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = FALSE,
+ GroupId = GID_TEMPLATE;
+]
+
+//--------------------------------------------------------------------------
SfxVoidItem ExecuteSearch FID_SEARCH_NOW
(SvxSearchItem SearchItem SID_SEARCH_ITEM, SfxBoolItem Quiet SID_SEARCH_QUIET )
[
diff --git a/sfx2/source/dialog/dialog.hrc b/sfx2/source/dialog/dialog.hrc
index e27579d17cb2..80e04d87adf2 100644
--- a/sfx2/source/dialog/dialog.hrc
+++ b/sfx2/source/dialog/dialog.hrc
@@ -26,6 +26,7 @@
#define ID_NEW 1
#define ID_EDIT 2
#define ID_DELETE 3
+#define ID_HIDE 4
#define RC_DIALOG_BEGIN RID_SFX_DIALOG_START
diff --git a/sfx2/source/dialog/dialog.src b/sfx2/source/dialog/dialog.src
index 725d519012cc..4bcd140ce007 100644
--- a/sfx2/source/dialog/dialog.src
+++ b/sfx2/source/dialog/dialog.src
@@ -81,6 +81,11 @@ Menu MN_CONTEXT_TEMPLDLG
};
MenuItem
{
+ Identifier = ID_HIDE ;
+ Text [ en-US ] = "Hide..." ;
+ };
+ MenuItem
+ {
Identifier = ID_DELETE ;
Text [ en-US ] = "Delete..." ;
HelpId = HID_STYLIST_DELETE ;
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index a4d9c9cb1d2e..25ea1ba1ff33 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -763,6 +763,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, Sfx
bCanEdit ( sal_False ),
bCanDel ( sal_False ),
bCanNew ( sal_True ),
+ bCanHide ( sal_True ),
bWaterDisabled ( sal_False ),
bNewByExampleDisabled ( sal_False ),
bUpdateByExampleDisabled( sal_False ),
@@ -808,6 +809,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, Mod
bCanEdit ( sal_False ),
bCanDel ( sal_False ),
bCanNew ( sal_True ),
+ bCanHide ( sal_True ),
bWaterDisabled ( sal_False ),
bNewByExampleDisabled ( sal_False ),
bUpdateByExampleDisabled( sal_False ),
@@ -856,8 +858,8 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
else
pStyleFamilies = new SfxStyleFamilies( aFamId );
- nActFilter = pCurObjShell ? static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pCurObjShell ) ) : 0xFFFF;
- if ( pCurObjShell && 0xFFFF == nActFilter )
+ nActFilter = pCurObjShell ? static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pCurObjShell ) ) : SFXSTYLEBIT_ALL;
+ if ( pCurObjShell && SFXSTYLEBIT_ALL == nActFilter )
nActFilter = pCurObjShell->GetAutoStyleFilterIndex();
// Paste in the toolbox
@@ -1062,11 +1064,18 @@ void SfxCommonTemplateDialog_Impl::SelectStyle(const String &rStr)
if ( !pItem )
return;
const SfxStyleFamily eFam = pItem->GetFamily();
- SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( rStr, eFam, SFXSTYLEBIT_ALL );
+ SfxStyleSheetBase* pStyle = pStyleSheetPool->Find( rStr, eFam, SFXSTYLEBIT_ALL | SFXSTYLEBIT_HIDDEN );
if( pStyle )
- EnableEdit( !(pStyle->GetMask() & SFXSTYLEBIT_READONLY) );
+ {
+ bool bReadWrite = !(pStyle->GetMask() & SFXSTYLEBIT_READONLY);
+ EnableEdit( bReadWrite );
+ EnableHide( bReadWrite && !pStyle->IsHidden( ) && !pStyle->IsUsed( ) );
+ }
else
- EnableEdit(sal_False);
+ {
+ EnableEdit( sal_False );
+ EnableHide( sal_False );
+ }
if ( pTreeBox )
{
@@ -1110,6 +1119,7 @@ void SfxCommonTemplateDialog_Impl::SelectStyle(const String &rStr)
{
aFmtLb.SelectAll( sal_False );
EnableEdit(sal_False);
+ EnableHide( sal_False );
}
}
}
@@ -1477,7 +1487,7 @@ void SfxCommonTemplateDialog_Impl::Update_Impl()
// other DocShell -> all new
CheckItem( nActFamily, sal_True );
nActFilter = static_cast< sal_uInt16 >( LoadFactoryStyleFilter( pDocShell ) );
- if ( 0xFFFF == nActFilter )
+ if ( SFXSTYLEBIT_ALL == nActFilter )
nActFilter = pDocShell->GetAutoStyleFilterIndex();
nAppFilter = pItem->GetValue();
@@ -1579,12 +1589,18 @@ void SfxCommonTemplateDialog_Impl::Notify(SfxBroadcaster& /*rBC*/, const SfxHint
const SfxStyleFamily eFam = pItem->GetFamily();
SfxStyleSheetBase *pStyle =
pStyleSheetPool->Find(
- aStr, eFam, SFXSTYLEBIT_ALL );
+ aStr, eFam, SFXSTYLEBIT_ALL | SFXSTYLEBIT_HIDDEN );
if( pStyle )
- EnableEdit(
- !(pStyle->GetMask() & SFXSTYLEBIT_READONLY) );
+ {
+ bool bReadWrite = !(pStyle->GetMask() & SFXSTYLEBIT_READONLY);
+ EnableEdit( bReadWrite );
+ EnableHide( bReadWrite && !pStyle->IsUsed( ) && !pStyle->IsHidden( ) );
+ }
else
+ {
EnableEdit(sal_False);
+ EnableHide(sal_False);
+ }
}
}
break;
@@ -1834,7 +1850,7 @@ void SfxCommonTemplateDialog_Impl::ActionSelect(sal_uInt16 nEntry)
const SfxStyleFamily eFam=GetFamilyItem_Impl()->GetFamily();
const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
sal_uInt16 nFilter;
- if( pItem && nActFilter != 0xffff )
+ if( pItem && nActFilter != SFXSTYLEBIT_ALL )
{
nFilter = pItem->GetFilterList()[ nActFilter ]->nFlags;
if(!nFilter) // automatisch
@@ -1956,7 +1972,7 @@ void SfxCommonTemplateDialog_Impl::NewHdl(void *)
const SfxStyleFamilyItem *pItem = GetFamilyItem_Impl();
const SfxStyleFamily eFam=pItem->GetFamily();
sal_uInt16 nMask;
- if( pItem && nActFilter != 0xffff )
+ if( pItem && nActFilter != SFXSTYLEBIT_ALL )
{
nMask = pItem->GetFilterList()[ nActFilter ]->nFlags;
if(!nMask) // automatic
@@ -2044,6 +2060,20 @@ void SfxCommonTemplateDialog_Impl::DeleteHdl(void *)
}
}
+void SfxCommonTemplateDialog_Impl::HideHdl(void *)
+{
+ if ( IsInitialized() && HasSelectedStyle() )
+ {
+ const String aTemplName( GetSelectedEntry() );
+ SfxStyleSheetBase* pStyle = GetSelectedStyle();
+ if ( pStyle )
+ {
+ Execute_Impl( SID_STYLE_HIDE, aTemplName,
+ String(), (sal_uInt16)GetFamilyItem_Impl()->GetFamily() );
+ }
+ }
+}
+
//-------------------------------------------------------------------------
void SfxCommonTemplateDialog_Impl::EnableDelete()
@@ -2060,7 +2090,7 @@ void SfxCommonTemplateDialog_Impl::EnableDelete()
if(!nFilter) // automatic
nFilter = nAppFilter;
const SfxStyleSheetBase *pStyle =
- pStyleSheetPool->Find(aTemplName,eFam, pTreeBox? SFXSTYLEBIT_ALL: nFilter);
+ pStyleSheetPool->Find(aTemplName,eFam, pTreeBox? SFXSTYLEBIT_ALL | SFXSTYLEBIT_HIDDEN : nFilter);
OSL_ENSURE(pStyle, "Style ot found");
if(pStyle && pStyle->IsUserDefined())
@@ -2160,6 +2190,7 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, MenuSelectHdl, Menu *, pMenu )
case ID_NEW: NewHdl(0); break;
case ID_EDIT: EditHdl(0); break;
case ID_DELETE: DeleteHdl(0); break;
+ case ID_HIDE: HideHdl(0); break;
default: return sal_False;
}
return sal_True;
@@ -2218,6 +2249,7 @@ PopupMenu* SfxCommonTemplateDialog_Impl::CreateContextMenu( void )
pMenu->EnableItem( ID_EDIT, bCanEdit );
pMenu->EnableItem( ID_DELETE, bCanDel );
pMenu->EnableItem( ID_NEW, bCanNew );
+ pMenu->EnableItem( ID_HIDE, bCanHide );
return pMenu;
}
diff --git a/sfx2/source/dialog/tplcitem.cxx b/sfx2/source/dialog/tplcitem.cxx
index 420f9b3529a6..314a39a09c33 100644
--- a/sfx2/source/dialog/tplcitem.cxx
+++ b/sfx2/source/dialog/tplcitem.cxx
@@ -118,6 +118,9 @@ void SfxTemplateControllerItem::StateChanged( sal_uInt16 nSID, SfxItemState eSta
case SID_STYLE_DELETE:
rTemplateDlg.EnableDel( SFX_ITEM_DISABLED != eState );
break;
+ case SID_STYLE_HIDE:
+ rTemplateDlg.EnableHide( SFX_ITEM_DISABLED != eState );
+ break;
case SID_STYLE_NEW_BY_EXAMPLE:
rTemplateDlg.EnableExample_Impl(
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index af77983aef47..c532a312efbc 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -793,7 +793,7 @@ void SfxObjectShell::LoadStyles
DBG_ASSERT(pSourcePool, "Source-DocumentShell ohne StyleSheetPool");
SfxStyleSheetBasePool *pMyPool = GetStyleSheetPool();
DBG_ASSERT(pMyPool, "Dest-DocumentShell ohne StyleSheetPool");
- pSourcePool->SetSearchMask(SFX_STYLE_FAMILY_ALL, 0xffff);
+ pSourcePool->SetSearchMask(SFX_STYLE_FAMILY_ALL, SFXSTYLEBIT_ALL);
Styles_Impl *pFound = new Styles_Impl[pSourcePool->Count()];
sal_uInt16 nFound = 0;
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index 12fe31533776..821695a1db81 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -158,6 +158,7 @@ protected:
bCanEdit :1,
bCanDel :1,
bCanNew :1,
+ bCanHide :1,
bWaterDisabled :1,
bNewByExampleDisabled :1,
bUpdateByExampleDisabled:1,
@@ -183,9 +184,10 @@ protected:
virtual void ClearFamilyList() = 0;
virtual void ReplaceUpdateButtonByMenu();
- void NewHdl( void* );
+ void NewHdl( void* );
void EditHdl( void* );
void DeleteHdl( void* );
+ void HideHdl( void* );
sal_Bool Execute_Impl( sal_uInt16 nId, const String& rStr, const String& rRefStr,
sal_uInt16 nFamily, sal_uInt16 nMask = 0,
@@ -234,6 +236,7 @@ public:
virtual void EnableEdit( sal_Bool b = sal_True ) { bCanEdit = b; }
virtual void EnableDel( sal_Bool b = sal_True ) { bCanDel = b; }
virtual void EnableNew( sal_Bool b = sal_True ) { bCanNew = b; }
+ virtual void EnableHide( sal_Bool b = sal_True ) { bCanHide = b; }
ISfxTemplateCommon* GetISfxTemplateCommon() { return &aISfxTemplateCommon; }
Window* GetWindow() { return pWindow; }
@@ -250,6 +253,7 @@ public:
inline sal_Bool CanEdit( void ) const { return bCanEdit; }
inline sal_Bool CanDel( void ) const { return bCanDel; }
inline sal_Bool CanNew( void ) const { return bCanNew; }
+ inline sal_Bool CanHide( void ) const { return bCanHide; }
// normaly for derivates from SvTreeListBoxes, but in this case the dialog handles context menus
virtual PopupMenu* CreateContextMenu( void );