diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-11-25 15:24:42 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-11-30 18:07:12 +0100 |
commit | 2fd9c2bf9af0c50dae3af3dbe5e22965ccdb4ae7 (patch) | |
tree | 2a0438c371fbb51a3d2e919793802d6827e07fbd | |
parent | 36b7794d832dbc87c250ef02eee643c4ce68f87a (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
36 files changed, 430 insertions, 89 deletions
diff --git a/sc/inc/stlpool.hxx b/sc/inc/stlpool.hxx index 5cbca39e8fee..f2a025536835 100644 --- a/sc/inc/stlpool.hxx +++ b/sc/inc/stlpool.hxx @@ -54,7 +54,7 @@ public: const String* GetForceStdName() const { return pForceStdName; } virtual SfxStyleSheetBase& Make( const String&, SfxStyleFamily eFam, - sal_uInt16 nMask = 0xffff, sal_uInt16 nPos = 0xffff ); + sal_uInt16 nMask = SFXSTYLEBIT_ALL, sal_uInt16 nPos = 0xffff ); protected: virtual ~ScStyleSheetPool(); diff --git a/sc/sdi/drawsh.sdi b/sc/sdi/drawsh.sdi index 98fe422cc7b5..d7e3c1a34aba 100644 --- a/sc/sdi/drawsh.sdi +++ b/sc/sdi/drawsh.sdi @@ -57,6 +57,7 @@ interface TableDraw SID_STYLE_NEW [ StateMethod = StateDisableItems; Export = FALSE; ] SID_STYLE_EDIT [ StateMethod = StateDisableItems; Export = FALSE; ] SID_STYLE_DELETE [ StateMethod = StateDisableItems; Export = FALSE; ] + SID_STYLE_HIDE [ StateMethod = StateDisableItems; Export = FALSE; ] //---------------------------------------------------------------------------- SID_TEXT_STANDARD [ ExecMethod = ExecDrawAttr; StateMethod = NoState; Export = FALSE; ] diff --git a/sc/sdi/drtxtob.sdi b/sc/sdi/drtxtob.sdi index dce59dc2588f..d17d285ec927 100644 --- a/sc/sdi/drtxtob.sdi +++ b/sc/sdi/drtxtob.sdi @@ -54,6 +54,7 @@ interface TableDrawText SID_STYLE_NEW [ StateMethod = StateDisableItems; Export = FALSE; ] SID_STYLE_EDIT [ StateMethod = StateDisableItems; Export = FALSE; ] SID_STYLE_DELETE [ StateMethod = StateDisableItems; Export = FALSE; ] + SID_STYLE_HIDE [ StateMethod = StateDisableItems; Export = FALSE; ] //---------------------------------------------------------------------------- SID_CUT [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] diff --git a/sc/sdi/formatsh.sdi b/sc/sdi/formatsh.sdi index 8b84a7b730c6..0304f61e2283 100644 --- a/sc/sdi/formatsh.sdi +++ b/sc/sdi/formatsh.sdi @@ -67,6 +67,7 @@ interface FormatForSelection SID_STYLE_FAMILY4 [ ExecMethod = ExecuteStyle; StateMethod = GetStyleState; ] SID_STYLE_EDIT [ ExecMethod = ExecuteStyle; StateMethod = GetStyleState; ] SID_STYLE_DELETE [ ExecMethod = ExecuteStyle; StateMethod = GetStyleState; ] + SID_STYLE_HIDE [ ExecMethod = ExecuteStyle; StateMethod = GetStyleState; ] // } Slot's die in der DrawShell disabled werden. SID_ATTR_ALIGN_HOR_JUSTIFY [ ExecMethod = ExecuteAlignment; StateMethod = GetAttrState; ] diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx index 47315b3aed52..b9268ddf4fa8 100644 --- a/sc/source/ui/docshell/docsh6.cxx +++ b/sc/source/ui/docshell/docsh6.cxx @@ -241,7 +241,7 @@ SfxStyleSheetBasePool* ScDocShell::GetStyleSheetPool() static void lcl_AdjustPool( SfxStyleSheetBasePool* pStylePool ) { - pStylePool->SetSearchMask(SFX_STYLE_FAMILY_PAGE, 0xffff); + pStylePool->SetSearchMask(SFX_STYLE_FAMILY_PAGE, SFXSTYLEBIT_ALL); SfxStyleSheetBase *pStyle = pStylePool->First(); while ( pStyle ) { diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx index 7d98e4514f3e..305e44b7e9da 100644 --- a/sc/source/ui/view/formatsh.cxx +++ b/sc/source/ui/view/formatsh.cxx @@ -233,6 +233,7 @@ void ScFormatShell::GetStyleState( SfxItemSet& rSet ) case SID_STYLE_EDIT: case SID_STYLE_DELETE: + case SID_STYLE_HIDE: { ISfxTemplateCommon* pDesigner = SFX_APP()-> GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings()); @@ -278,6 +279,7 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq ) if ( (nSlotId == SID_STYLE_NEW) || (nSlotId == SID_STYLE_EDIT) || (nSlotId == SID_STYLE_DELETE) + || (nSlotId == SID_STYLE_HIDE) || (nSlotId == SID_STYLE_APPLY) || (nSlotId == SID_STYLE_WATERCAN) || (nSlotId == SID_STYLE_FAMILY) @@ -362,6 +364,7 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq ) } case SID_STYLE_EDIT: case SID_STYLE_DELETE: + case SID_STYLE_HIDE: case SID_STYLE_NEW_BY_EXAMPLE: { const SfxPoolItem* pNameItem; @@ -445,6 +448,19 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq ) } break; + case SID_STYLE_HIDE: + { + if ( pStyleSheet ) + { + pStyleSheet->SetHidden( true ); + pTabViewShell->InvalidateAttribs(); + rReq.Done(); + } + else + nRetMask = false; + } + break; + case SID_STYLE_APPLY: { if ( pStyleSheet && !pScMod->GetIsWaterCan() ) @@ -602,6 +618,19 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq ) } break; + case SID_STYLE_HIDE: + { + nRetMask = ( NULL != pStyleSheet ); + if ( pStyleSheet ) + { + pStyleSheet->SetHidden( true ); + rBindings.Invalidate( SID_STYLE_FAMILY4 ); + pDocSh->SetDocumentModified(); + rReq.Done(); + } + } + break; + case SID_STYLE_APPLY: { nRetMask = ( NULL != pStyleSheet ); diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi index fc2f01eb9da7..0fabae44e060 100644 --- a/sd/sdi/_drvwsh.sdi +++ b/sd/sdi/_drvwsh.sdi @@ -1366,6 +1366,13 @@ interface DrawView GroupId = GID_DOCUMENT ; Cachable ; ] + SID_STYLE_HIDE + [ + ExecMethod = FuTemporary ; + StateMethod = GetAttrState ; + GroupId = GID_DOCUMENT ; + Cachable ; + ] SID_STYLE_APPLY // ole : no, status : ? [ ExecMethod = FuTemporary ; diff --git a/sd/sdi/outlnvsh.sdi b/sd/sdi/outlnvsh.sdi index ec06d37e6994..6632f09f6feb 100644 --- a/sd/sdi/outlnvsh.sdi +++ b/sd/sdi/outlnvsh.sdi @@ -326,6 +326,13 @@ interface OutlineView GroupId = GID_DOCUMENT ; Cachable ; ] + SID_STYLE_HIDE + [ + ExecMethod = FuTemporary ; + StateMethod = GetAttrState ; + GroupId = GID_DOCUMENT ; + Cachable ; + ] SID_AUTOSPELL_CHECK // ole : no, status : play rec [ ExecMethod = FuSupport ; diff --git a/sd/source/ui/func/futempl.cxx b/sd/source/ui/func/futempl.cxx index 1326e5102576..f1d9feae1487 100644 --- a/sd/source/ui/func/futempl.cxx +++ b/sd/source/ui/func/futempl.cxx @@ -128,13 +128,14 @@ void FuTemplate::DoExecute( SfxRequest& rReq ) } String aStyleName; - sal_uInt16 nRetMask = 0xffff; + sal_uInt16 nRetMask = SFXSTYLEBIT_ALL; switch( nSId ) { case SID_STYLE_APPLY: case SID_STYLE_EDIT: case SID_STYLE_DELETE: + case SID_STYLE_HIDE: case SID_STYLE_FAMILY: case SID_STYLE_NEW_BY_EXAMPLE: { @@ -225,6 +226,12 @@ void FuTemplate::DoExecute( SfxRequest& rReq ) } break; + case SID_STYLE_HIDE: + pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily); + pStyleSheet->SetHidden( true ); + nRetMask = sal_True; + break; + case SID_STYLE_APPLY: // Anwenden der Vorlage auf das Dokument pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily); @@ -666,7 +673,7 @@ void FuTemplate::DoExecute( SfxRequest& rReq ) break; } - if( nRetMask != 0xffff ) + if( nRetMask != SFXSTYLEBIT_ALL ) rReq.SetReturnValue( SfxUInt16Item( nSId, nRetMask ) ); } diff --git a/sd/source/ui/view/drviewsc.cxx b/sd/source/ui/view/drviewsc.cxx index cfecc20f072b..9074fc2fa502 100644 --- a/sd/source/ui/view/drviewsc.cxx +++ b/sd/source/ui/view/drviewsc.cxx @@ -539,6 +539,7 @@ void DrawViewShell::FuTemp03(SfxRequest& rReq) case SID_STYLE_APPLY: case SID_STYLE_EDIT: case SID_STYLE_DELETE: + case SID_STYLE_HIDE: case SID_STYLE_FAMILY: case SID_STYLE_WATERCAN: case SID_STYLE_UPDATE_BY_EXAMPLE: diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx index 2b52207e13fa..881722dbd3ee 100644 --- a/sd/source/ui/view/outlnvsh.cxx +++ b/sd/source/ui/view/outlnvsh.cxx @@ -1518,6 +1518,7 @@ sal_Bool OutlineViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin) Invalidate(SID_STYLE_EDIT); Invalidate(SID_STYLE_NEW); Invalidate(SID_STYLE_DELETE); + Invalidate(SID_STYLE_HIDE); Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE); Invalidate(SID_STYLE_NEW_BY_EXAMPLE); Invalidate(SID_STYLE_WATERCAN); @@ -1710,6 +1711,7 @@ void OutlineViewShell::GetAttrState( SfxItemSet& rSet ) case SID_STYLE_NEW: case SID_STYLE_DELETE: + case SID_STYLE_HIDE: case SID_STYLE_NEW_BY_EXAMPLE: case SID_STYLE_WATERCAN: { @@ -1740,6 +1742,7 @@ void OutlineViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin Invalidate(SID_STYLE_EDIT); Invalidate(SID_STYLE_NEW); Invalidate(SID_STYLE_DELETE); + Invalidate(SID_STYLE_HIDE); Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE); Invalidate(SID_STYLE_NEW_BY_EXAMPLE); Invalidate(SID_STYLE_WATERCAN); 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 ); diff --git a/svl/inc/svl/style.hrc b/svl/inc/svl/style.hrc index a4fea6d042c8..ae08df4c2c76 100644 --- a/svl/inc/svl/style.hrc +++ b/svl/inc/svl/style.hrc @@ -20,9 +20,10 @@ #define _SFX_STYLE_HRC #define SFXSTYLEBIT_AUTO 0x0000 // automatisch; Flags kommen von der Applikation +#define SFXSTYLEBIT_HIDDEN 0x0200 // benutzte Vorlage (als Suchmaske) #define SFXSTYLEBIT_READONLY 0x2000 // benutzte Vorlage (als Suchmaske) #define SFXSTYLEBIT_USED 0x4000 // benutzte Vorlage (als Suchmaske) #define SFXSTYLEBIT_USERDEF 0x8000 // benutzerdefinierte Vorlage -#define SFXSTYLEBIT_ALL 0xFFFF // alle Vorlagen +#define SFXSTYLEBIT_ALL 0xFDFF // alle Vorlagen #endif diff --git a/svl/inc/svl/style.hxx b/svl/inc/svl/style.hxx index f0878c46967a..48557c5457d8 100644 --- a/svl/inc/svl/style.hxx +++ b/svl/inc/svl/style.hxx @@ -90,6 +90,7 @@ protected: sal_uLong nHelpId; // Hilfe-ID bool bMySet; // sal_True: Set loeschen im dtor + bool bHidden; SfxStyleSheetBase( const UniString&, SfxStyleSheetBasePool*, SfxStyleFamily eFam, sal_uInt16 mask ); SfxStyleSheetBase( const SfxStyleSheetBase& ); @@ -133,6 +134,9 @@ public: bool IsUserDefined() const { return ( nMask & SFXSTYLEBIT_USERDEF) != 0; } + virtual sal_Bool IsHidden() const { return bHidden; } + virtual void SetHidden( sal_Bool bValue ); + virtual sal_uLong GetHelpId( String& rFile ); virtual void SetHelpId( const String& r, sal_uLong nId ); @@ -157,7 +161,7 @@ class SVL_DLLPUBLIC SfxStyleSheetIterator { public: SfxStyleSheetIterator(SfxStyleSheetBasePool *pBase, - SfxStyleFamily eFam, sal_uInt16 n=0xFFFF ); + SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL ); virtual sal_uInt16 GetSearchMask() const; virtual SfxStyleFamily GetSearchFamily() const; virtual sal_uInt16 Count(); @@ -229,7 +233,7 @@ public: virtual SfxStyleSheetBase& Make(const UniString&, SfxStyleFamily eFam, - sal_uInt16 nMask = 0xffff , + sal_uInt16 nMask = SFXSTYLEBIT_ALL , sal_uInt16 nPos = 0xffff); virtual void Replace( @@ -246,7 +250,7 @@ public: const SfxStyles& GetStyles(); virtual SfxStyleSheetBase* First(); virtual SfxStyleSheetBase* Next(); - virtual SfxStyleSheetBase* Find( const UniString&, SfxStyleFamily eFam, sal_uInt16 n=0xFFFF ); + virtual SfxStyleSheetBase* Find( const UniString&, SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL ); virtual bool SetParent(SfxStyleFamily eFam, const UniString &rStyle, @@ -255,7 +259,7 @@ public: SfxStyleSheetBase* Find(const UniString& rStr) { return Find(rStr, nSearchFamily, nMask); } - void SetSearchMask(SfxStyleFamily eFam, sal_uInt16 n=0xFFFF ); + void SetSearchMask(SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL ); sal_uInt16 GetSearchMask() const; SfxStyleFamily GetSearchFamily() const { return nSearchFamily; } }; diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx index 3c1f9b78cdbb..15deda60bdc8 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -89,7 +89,6 @@ SfxStyleSheetHint::SfxStyleSheetHint class SfxStyleSheetBasePool_Impl { public: - SfxStyles aStyles; SfxStyleSheetIterator *pIter; SfxStyleSheetBasePool_Impl() : pIter(0){} ~SfxStyleSheetBasePool_Impl(){delete pIter;} @@ -110,6 +109,7 @@ SfxStyleSheetBase::SfxStyleSheetBase( const XubString& rName, SfxStyleSheetBaseP , nMask(mask) , nHelpId( 0 ) , bMySet( sal_False ) + , bHidden( sal_False ) { #ifdef DBG_UTIL aDbgStyleSheetReferences.mnStyles++; @@ -127,6 +127,7 @@ SfxStyleSheetBase::SfxStyleSheetBase( const SfxStyleSheetBase& r ) , nMask( r.nMask ) , nHelpId( r.nHelpId ) , bMySet( r.bMySet ) + , bHidden( r.bHidden ) { #ifdef DBG_UTIL aDbgStyleSheetReferences.mnStyles++; @@ -241,6 +242,12 @@ bool SfxStyleSheetBase::SetParent( const XubString& rName ) return true; } +void SfxStyleSheetBase::SetHidden( sal_Bool hidden ) +{ + bHidden = hidden; + pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) ); +} + // Follow aendern const XubString& SfxStyleSheetBase::GetFollow() const @@ -362,16 +369,21 @@ SfxStyleFamily SfxStyleSheetIterator::GetSearchFamily() const inline bool SfxStyleSheetIterator::IsTrivialSearch() { - return nMask == 0xFFFF && GetSearchFamily() == SFX_STYLE_FAMILY_ALL; + return nMask == SFXSTYLEBIT_ALL && GetSearchFamily() == SFX_STYLE_FAMILY_ALL; } bool SfxStyleSheetIterator::DoesStyleMatch(SfxStyleSheetBase *pStyle) { - return ((GetSearchFamily() == SFX_STYLE_FAMILY_ALL) || + bool bSearchHidden = ( GetSearchMask() & SFXSTYLEBIT_HIDDEN ); + bool bMatchVisibility = bSearchHidden || !pStyle->IsHidden(); + + bool bMatches = ((GetSearchFamily() == SFX_STYLE_FAMILY_ALL) || ( pStyle->GetFamily() == GetSearchFamily() )) && (( pStyle->GetMask() & ( GetSearchMask() & ~SFXSTYLEBIT_USED )) || ( bSearchUsed ? pStyle->IsUsed() : false ) || - GetSearchMask() == SFXSTYLEBIT_ALL ); + GetSearchMask() == SFXSTYLEBIT_ALL ) + && bMatchVisibility; + return bMatches; } @@ -544,7 +556,7 @@ SfxStyleSheetBasePool::SfxStyleSheetBasePool( SfxItemPool& r ) : aAppName(r.GetName()) , rPool(r) , nSearchFamily(SFX_STYLE_FAMILY_PARA) - , nMask(0xFFFF) + , nMask(SFXSTYLEBIT_ALL) { #ifdef DBG_UTIL aDbgStyleSheetReferences.mnPools++; @@ -808,7 +820,7 @@ void SfxStyleSheetBasePool::ChangeParent(const XubString& rOld, bool bVirtual) { const sal_uInt16 nTmpMask = GetSearchMask(); - SetSearchMask(GetSearchFamily(), 0xffff); + SetSearchMask(GetSearchFamily(), SFXSTYLEBIT_ALL); for( SfxStyleSheetBase* p = First(); p; p = Next() ) { if( p->GetParent().Equals( rOld ) ) @@ -872,14 +884,14 @@ bool SfxStyleSheet::SetParent( const XubString& rName ) // aus der Benachrichtigungskette des alten // Parents gfs. austragen if(aOldParent.Len()) { - SfxStyleSheet *pParent = (SfxStyleSheet *)pPool->Find(aOldParent, nFamily, 0xffff); + SfxStyleSheet *pParent = (SfxStyleSheet *)pPool->Find(aOldParent, nFamily, SFXSTYLEBIT_ALL); if(pParent) EndListening(*pParent); } // in die Benachrichtigungskette des neuen // Parents eintragen if(aParent.Len()) { - SfxStyleSheet *pParent = (SfxStyleSheet *)pPool->Find(aParent, nFamily, 0xffff); + SfxStyleSheet *pParent = (SfxStyleSheet *)pPool->Find(aParent, nFamily, SFXSTYLEBIT_ALL); if(pParent) StartListening(*pParent); } diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index 6016890098fc..4d660e5c75e7 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -107,6 +107,7 @@ class SW_DLLPUBLIC SwDocShell: public SfxObjectShell, public SfxListener SwWrtShell* pActShell = 0, sal_Bool bBasic = sal_False ); SW_DLLPRIVATE sal_uInt16 Delete(const String &rName, sal_uInt16 nFamily); + SW_DLLPRIVATE sal_uInt16 Hide(const String &rName, sal_uInt16 nFamily, bool bHidden); SW_DLLPRIVATE sal_uInt16 ApplyStyles(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0, sal_uInt16 nMode = 0 ); SW_DLLPRIVATE sal_uInt16 DoWaterCan( const String &rName, sal_uInt16 nFamily); diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx index 3385650a6e71..9c05f541b34d 100644 --- a/sw/inc/docstyle.hxx +++ b/sw/inc/docstyle.hxx @@ -97,6 +97,9 @@ public: sal_Bool IsPhysical() const { return bPhysical; } void SetPhysical(sal_Bool bPhys); + virtual void SetHidden( sal_Bool bHidden ); + virtual sal_Bool IsHidden( ) const; + /** add optional parameter <bResetIndentAttrsAtParagraphStyle>, default value sal_False, which indicates that the indent attributes at a paragraph style should be reset in case that a list style is applied to the paragraph style and @@ -155,12 +158,13 @@ class SwStyleSheetIterator : public SfxStyleSheetIterator, public SfxListener void AppendStyleList(const boost::ptr_vector<String>& rLst, sal_Bool bUsed, + sal_Bool bTestHidden, sal_uInt16 nSection, char cType); public: SwStyleSheetIterator( SwDocStyleSheetPool* pBase, - SfxStyleFamily eFam, sal_uInt16 n=0xFFFF ); + SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL ); virtual ~SwStyleSheetIterator(); virtual sal_uInt16 Count(); @@ -193,7 +197,7 @@ public: virtual SfxStyleSheetBase& Make(const String&, SfxStyleFamily, sal_uInt16 nMask, sal_uInt16 nPos = 0xffff); virtual SfxStyleSheetBase* Find( const String&, SfxStyleFamily eFam, - sal_uInt16 n=0xFFFF ); + sal_uInt16 n=SFXSTYLEBIT_ALL ); virtual bool SetParent( SfxStyleFamily eFam, const String &rStyle, const String &rParent ); diff --git a/sw/inc/format.hxx b/sw/inc/format.hxx index 3fd0a355fa18..1f178cb713f5 100644 --- a/sw/inc/format.hxx +++ b/sw/inc/format.hxx @@ -52,6 +52,7 @@ class SW_DLLPUBLIC SwFmt : public SwModify to recognize this in FmtChg-message!! */ sal_Bool bAutoUpdateFmt : 1;/**< TRUE: Set attributes of a whole paragraph at format (UI-side!). */ + bool bHidden : 1; protected: SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm, @@ -155,6 +156,9 @@ public: bool IsAuto() const { return bAutoFmt; } void SetAuto( bool bNew = false ) { bAutoFmt = bNew; } + bool IsHidden() const { return bHidden; } + void SetHidden( bool bValue = false ) { bHidden = bValue; } + /// Query / set bAutoUpdateFmt-flag. sal_Bool IsAutoUpdateFmt() const { return bAutoUpdateFmt; } void SetAutoUpdateFmt( sal_Bool bNew = sal_True ) { bAutoUpdateFmt = bNew; } diff --git a/sw/inc/numrule.hxx b/sw/inc/numrule.hxx index 03f281d6a596..1fe43ba6eece 100644 --- a/sw/inc/numrule.hxx +++ b/sw/inc/numrule.hxx @@ -132,6 +132,7 @@ private: sal_Bool bInvalidRuleFlag : 1; sal_Bool bContinusNum : 1; ///< Continuous numbering without levels. sal_Bool bAbsSpaces : 1; ///< Levels represent absolute indents. + sal_Bool bHidden : 1; ///< Is the numering rule to be hidden in the UI? bool mbCountPhantoms; const SvxNumberFormat::SvxNumPositionAndSpaceMode meDefaultNumberFormatPositionAndSpaceMode; @@ -154,6 +155,9 @@ public: const SwNumFmt* GetNumFmt( sal_uInt16 i ) const; const SwNumFmt& Get( sal_uInt16 i ) const; + sal_Bool IsHidden( ) const { return bHidden; } + void SetHidden( sal_Bool bValue ) { bHidden = bValue; } + void Set( sal_uInt16 i, const SwNumFmt* ); void Set( sal_uInt16 i, const SwNumFmt& ); String MakeNumString( const SwNodeNum&, sal_Bool bInclStrings = sal_True, diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index 76a68097f6b2..b6c40a8873eb 100644 --- a/sw/inc/pagedesc.hxx +++ b/sw/inc/pagedesc.hxx @@ -144,6 +144,7 @@ class SW_DLLPUBLIC SwPageDesc : public SwModify sal_uInt16 nRegAscent; ///< For grid alignment (Registerhaltigkeit). UseOnPage eUse; sal_Bool bLandscape; + sal_Bool bHidden; /// Footnote information. SwPageFtnInfo aFtnInfo; @@ -180,6 +181,9 @@ public: sal_Bool IsFirstShared() const; void ChgFirstShare( sal_Bool bNew ); + sal_Bool IsHidden( ) const { return bHidden; } + void SetHidden( sal_Bool bValue ) { bHidden = bValue; } + inline void SetUseOn( UseOnPage eNew ); inline UseOnPage GetUseOn() const; diff --git a/sw/sdi/_docsh.sdi b/sw/sdi/_docsh.sdi index e1f0ae9a60e6..cfc333719ca3 100644 --- a/sw/sdi/_docsh.sdi +++ b/sw/sdi/_docsh.sdi @@ -50,6 +50,12 @@ interface BaseTextDocument StateMethod = NoState ; ] + SID_STYLE_HIDE + [ + ExecMethod = ExecStyleSheet ; + StateMethod = NoState ; + ] + SID_TEMPLATE_LOAD [ ExecMethod = Execute ; diff --git a/sw/sdi/annotsh.sdi b/sw/sdi/annotsh.sdi index ed99f70a35b7..9e566b2b6287 100644 --- a/sw/sdi/annotsh.sdi +++ b/sw/sdi/annotsh.sdi @@ -346,6 +346,11 @@ interface Annotation : _Annotation [ StateMethod = StateDisableItems ; ] + + SID_STYLE_HIDE + [ + StateMethod = StateDisableItems ; + ] FN_STAT_SELMODE [ StateMethod = StateStatusLine ; diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx index 78d3c36ac1e0..4524937d020c 100644 --- a/sw/source/core/attr/format.cxx +++ b/sw/source/core/attr/format.cxx @@ -43,6 +43,7 @@ SwFmt::SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm, aFmtName.AssignAscii( pFmtNm ); bWritten = bFmtInDTOR = bAutoUpdateFmt = sal_False; // LAYER_IMPL bAutoFmt = sal_True; + bHidden = false; if( pDrvdFrm ) aSet.SetParent( &pDrvdFrm->aSet ); @@ -62,6 +63,7 @@ SwFmt::SwFmt( SwAttrPool& rPool, const String& rFmtNm, { bWritten = bFmtInDTOR = bAutoUpdateFmt = sal_False; // LAYER_IMPL bAutoFmt = sal_True; + bHidden = false; if( pDrvdFrm ) aSet.SetParent( &pDrvdFrm->aSet ); @@ -79,6 +81,7 @@ SwFmt::SwFmt( const SwFmt& rFmt ) { bWritten = bFmtInDTOR = sal_False; // LAYER_IMPL bAutoFmt = rFmt.bAutoFmt; + bHidden = rFmt.bHidden; bAutoUpdateFmt = rFmt.bAutoUpdateFmt; if( rFmt.DerivedFrom() ) @@ -133,6 +136,7 @@ SwFmt &SwFmt::operator=(const SwFmt& rFmt) } } bAutoFmt = rFmt.bAutoFmt; + bHidden = rFmt.bHidden; bAutoUpdateFmt = rFmt.bAutoUpdateFmt; return *this; } diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index 97061d551012..91b822b3de15 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -398,6 +398,7 @@ SwNumRule::SwNumRule( const String& rNm, bInvalidRuleFlag( sal_True ), bContinusNum( sal_False ), bAbsSpaces( sal_False ), + bHidden( sal_False ), mbCountPhantoms( true ), meDefaultNumberFormatPositionAndSpaceMode( eDefaultNumberFormatPositionAndSpaceMode ), msDefaultListId() @@ -496,6 +497,7 @@ SwNumRule::SwNumRule( const SwNumRule& rNumRule ) bInvalidRuleFlag( sal_True ), bContinusNum( rNumRule.bContinusNum ), bAbsSpaces( rNumRule.bAbsSpaces ), + bHidden( rNumRule.bHidden ), mbCountPhantoms( true ), meDefaultNumberFormatPositionAndSpaceMode( rNumRule.meDefaultNumberFormatPositionAndSpaceMode ), msDefaultListId( rNumRule.msDefaultListId ) @@ -569,6 +571,7 @@ SwNumRule& SwNumRule::operator=( const SwNumRule& rNumRule ) bInvalidRuleFlag = sal_True; bContinusNum = rNumRule.bContinusNum; bAbsSpaces = rNumRule.bAbsSpaces; + bHidden = rNumRule.bHidden; nPoolFmtId = rNumRule.GetPoolFmtId(); nPoolHelpId = rNumRule.GetPoolHelpId(); nPoolHlpFileId = rNumRule.GetPoolHlpFileId(); diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx index 73141302906f..37a8d9b9168d 100644 --- a/sw/source/core/layout/pagedesc.cxx +++ b/sw/source/core/layout/pagedesc.cxx @@ -56,6 +56,7 @@ SwPageDesc::SwPageDesc( const String& rName, SwFrmFmt *pFmt, SwDoc *pDc ) : nRegAscent( 0 ), eUse( (UseOnPage)(nsUseOnPage::PD_ALL | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE | nsUseOnPage::PD_FIRSTSHARE ) ), bLandscape( sal_False ), + bHidden( sal_False ), aFtnInfo() { } @@ -73,6 +74,7 @@ SwPageDesc::SwPageDesc( const SwPageDesc &rCpy ) : nRegAscent( rCpy.GetRegAscent() ), eUse( rCpy.ReadUseOn() ), bLandscape( rCpy.GetLandscape() ), + bHidden( rCpy.IsHidden() ), aFtnInfo( rCpy.GetFtnInfo() ) { } diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index d04a95f3db9d..5e6f87fa81cf 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -785,7 +785,7 @@ uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::Runt uno::Sequence< OUString > aRet; if(pBasePool) { - SfxStyleSheetIterator* pIterator = pBasePool->CreateIterator(eFamily, 0xffff); + SfxStyleSheetIterator* pIterator = pBasePool->CreateIterator(eFamily, SFXSTYLEBIT_ALL); sal_uInt16 nCount = pIterator->Count(); aRet.realloc(nCount); OUString* pArray = aRet.getArray(); @@ -867,7 +867,7 @@ void SwXStyleFamily::insertByName(const OUString& rName, const uno::Any& rElemen throw lang::IllegalArgumentException(); if(pNewStyle) { - sal_uInt16 nMask = 0xffff; + sal_uInt16 nMask = SFXSTYLEBIT_ALL; if(eFamily == SFX_STYLE_FAMILY_PARA && !pNewStyle->IsConditional()) nMask &= ~SWSTYLEBIT_CONDCOLL; #if OSL_DEBUG_LEVEL > 1 diff --git a/sw/source/ui/app/docst.cxx b/sw/source/ui/app/docst.cxx index 8923077e4746..14144c2b250a 100644 --- a/sw/source/ui/app/docst.cxx +++ b/sw/source/ui/app/docst.cxx @@ -258,7 +258,7 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh) void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) { sal_uInt16 nSlot = rReq.GetSlot(); - sal_uInt16 nRet = 0xffff; + sal_uInt16 nRet = SFXSTYLEBIT_ALL; const SfxItemSet* pArgs = rReq.GetArgs(); const SfxPoolItem* pItem; @@ -325,6 +325,7 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) case SID_STYLE_EDIT: case SID_STYLE_DELETE: + case SID_STYLE_HIDE: case SID_STYLE_WATERCAN: case SID_STYLE_FAMILY: case SID_STYLE_UPDATE_BY_EXAMPLE: @@ -450,6 +451,9 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq ) case SID_STYLE_DELETE: nRet = Delete(aParam, nFamily); break; + case SID_STYLE_HIDE: + nRet = Hide(aParam, nFamily, true); + break; case SID_STYLE_APPLY: // Shell-switch in ApplyStyles nRet = ApplyStyles(aParam, nFamily, pActShell, rReq.GetModifier() ); @@ -820,6 +824,24 @@ sal_uInt16 SwDocShell::Delete(const String &rName, sal_uInt16 nFamily) return sal_False; } +sal_uInt16 SwDocShell::Hide(const String &rName, sal_uInt16 nFamily, bool bHidden) +{ + SfxStyleSheetBase *pStyle = mxBasePool->Find(rName, (SfxStyleFamily)nFamily); + + if(pStyle) + { + OSL_ENSURE(GetWrtShell(), "No Shell, no Styles"); + + GetWrtShell()->StartAllAction(); + rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *(SwDocStyleSheet*)pStyle ) ); + xTmp->SetHidden( bHidden ); + GetWrtShell()->EndAllAction(); + + return sal_True; + } + return sal_False; +} + /*-------------------------------------------------------------------- Description: apply template --------------------------------------------------------------------*/ diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx index fa38da7c538a..e881cb1f4ac8 100644 --- a/sw/source/ui/app/docstyle.cxx +++ b/sw/source/ui/app/docstyle.cxx @@ -450,6 +450,116 @@ void SwDocStyleSheet::Reset() Description: virtual methods --------------------------------------------------------------------*/ +void SwDocStyleSheet::SetHidden( sal_Bool bValue ) +{ + bool bChg = false; + if(!bPhysical) + FillStyleSheet( FillPhysical ); + + SwFmt* pFmt = 0; + switch(nFamily) + { + case SFX_STYLE_FAMILY_CHAR: + pFmt = rDoc.FindCharFmtByName( aName ); + if ( pFmt ) + { + pFmt->SetHidden( bValue ); + bChg = true; + } + break; + + case SFX_STYLE_FAMILY_PARA: + pFmt = rDoc.FindTxtFmtCollByName( aName ); + if ( pFmt ) + { + pFmt->SetHidden( bValue ); + bChg = true; + } + break; + + case SFX_STYLE_FAMILY_FRAME: + pFmt = rDoc.FindFrmFmtByName( aName ); + if ( pFmt ) + { + pFmt->SetHidden( bValue ); + bChg = true; + } + break; + + case SFX_STYLE_FAMILY_PAGE: + { + SwPageDesc* pPgDesc = rDoc.FindPageDescByName( aName ); + if ( pPgDesc ) + { + pPgDesc->SetHidden( bValue ); + bChg = true; + } + } + break; + + case SFX_STYLE_FAMILY_PSEUDO: + { + SwNumRule* pRule = rDoc.FindNumRulePtr( aName ); + if ( pRule ) + { + pRule->SetHidden( bValue ); + bChg = true; + } + } + default:; + } + + if( bChg ) + { + pPool->First(); // internal list has to be updated + pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) ); + SwEditShell* pSh = rDoc.GetEditShell(); + if( pSh ) + pSh->CallChgLnk(); + } +} + +sal_Bool SwDocStyleSheet::IsHidden( ) const +{ + sal_Bool bRet = sal_False; + + if(!bPhysical) + { + SwFmt* pFmt = 0; + switch(nFamily) + { + case SFX_STYLE_FAMILY_CHAR: + pFmt = rDoc.FindCharFmtByName( aName ); + bRet = pFmt && pFmt->IsHidden( ); + break; + + case SFX_STYLE_FAMILY_PARA: + pFmt = rDoc.FindTxtFmtCollByName( aName ); + bRet = pFmt && pFmt->IsHidden( ); + break; + + case SFX_STYLE_FAMILY_FRAME: + pFmt = rDoc.FindFrmFmtByName( aName ); + bRet = pFmt && pFmt->IsHidden( ); + break; + + case SFX_STYLE_FAMILY_PAGE: + { + SwPageDesc* pPgDesc = rDoc.FindPageDescByName( aName ); + bRet = pPgDesc && pPgDesc->IsHidden( ); + } + break; + case SFX_STYLE_FAMILY_PSEUDO: + { + SwNumRule* pRule = rDoc.FindNumRulePtr( aName ); + bRet = pRule && pRule->IsHidden( ); + } + default:; + } + } + + return bRet; +} const String& SwDocStyleSheet::GetParent() const { @@ -2325,7 +2435,7 @@ SfxStyleSheetBase* SwDocStyleSheetPool::Find( const String& rName, { const SwNumRule* pRule = mxStyleSheet->GetNumRule(); if( pRule && - !(bSearchUsed && (bOrganizer || rDoc.IsUsed(*pRule)) ) && + !bSearchUsed && (( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF ? !(pRule->GetPoolFmtId() & USER_FMT) // searched for used and found none @@ -2340,7 +2450,7 @@ SfxStyleSheetBase* SwDocStyleSheetPool::Find( const String& rName, } // then evaluate the mask: - if( pMod && !(bSearchUsed && (bOrganizer || rDoc.IsUsed(*pMod)) ) ) + if( pMod && !bSearchUsed ) { const sal_uInt16 nId = SFX_STYLE_FAMILY_PAGE == eFam ? ((SwPageDesc*)pMod)->GetPoolFmtId() @@ -2366,7 +2476,7 @@ SwStyleSheetIterator::SwStyleSheetIterator( SwDocStyleSheetPool* pBase, StartListening( *pBase ); } - SwStyleSheetIterator::~SwStyleSheetIterator() +SwStyleSheetIterator::~SwStyleSheetIterator() { EndListening( mxIterSheet->GetPool() ); } @@ -2405,6 +2515,8 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() const sal_uInt16 nSrchMask = nMask; const sal_Bool bIsSearchUsed = SearchUsed(); + bool bSearchHidden = ( nMask & SFXSTYLEBIT_HIDDEN ); + const sal_Bool bOrganizer = ((SwDocStyleSheetPool*)pBasePool)->IsOrganizerMode(); if( nSearchFamily == SFX_STYLE_FAMILY_CHAR @@ -2414,10 +2526,11 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() for( sal_uInt16 i = 0; i < nArrLen; i++ ) { SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ]; - if( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() ) - continue; const bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(*pFmt)); + if( ( !bSearchHidden && pFmt->IsHidden() && !bUsed ) || ( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() ) ) + continue; + if( !bUsed ) { // Standard is no User template @@ -2452,7 +2565,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() { if( !rDoc.get(IDocumentSettingAccess::HTML_MODE) ) AppendStyleList(SwStyleNameMapper::GetChrFmtUINameArray(), - bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR); + bIsSearchUsed, bSearchHidden, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR); else { aLst.Append( cCHAR, SwStyleNameMapper::GetChrFmtUINameArray()[ @@ -2465,7 +2578,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() RES_POOLCHR_FOOTNOTE - RES_POOLCHR_BEGIN ] ); } AppendStyleList(SwStyleNameMapper::GetHTMLChrFmtUINameArray(), - bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR); + bIsSearchUsed, bSearchHidden, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR); } } @@ -2476,7 +2589,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() if( rDoc.get(IDocumentSettingAccess::HTML_MODE) ) { // then only HTML-Template are of interest - if( USHRT_MAX == nSMask ) + if( SFXSTYLEBIT_ALL == nSMask ) nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED; else @@ -2491,10 +2604,10 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() { SwTxtFmtColl* pColl = (*rDoc.GetTxtFmtColls())[ i ]; - if(pColl->IsDefault()) + const bool bUsed = bOrganizer || rDoc.IsUsed(*pColl); + if ( ( !bSearchHidden && pColl->IsHidden( ) && !bUsed ) || pColl->IsDefault() ) continue; - const bool bUsed = bOrganizer || rDoc.IsUsed(*pColl); if( !(bIsSearchUsed && bUsed )) { const sal_uInt16 nId = pColl->GetPoolFmtId(); @@ -2565,19 +2678,19 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() const sal_Bool bAll = nSMask == SFXSTYLEBIT_ALL; if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_TEXT ) AppendStyleList(SwStyleNameMapper::GetTextUINameArray(), - bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ); + bIsSearchUsed, bSearchHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ); if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CHAPTER ) AppendStyleList(SwStyleNameMapper::GetDocUINameArray(), - bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; + bIsSearchUsed, bSearchHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_LIST ) AppendStyleList(SwStyleNameMapper::GetListsUINameArray(), - bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; + bIsSearchUsed, bSearchHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_IDX ) AppendStyleList(SwStyleNameMapper::GetRegisterUINameArray(), - bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; + bIsSearchUsed, bSearchHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_EXTRA ) AppendStyleList(SwStyleNameMapper::GetExtraUINameArray(), - bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; + bIsSearchUsed, bSearchHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CONDCOLL ) { if( !bIsSearchUsed || @@ -2591,7 +2704,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() (SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF) ) { AppendStyleList(SwStyleNameMapper::GetHTMLUINameArray(), - bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; + bIsSearchUsed, bSearchHidden, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ; if( !bAll ) { // then also the ones, that we are mapping: @@ -2634,13 +2747,13 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() { SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ]; - if(pFmt->IsDefault() || pFmt->IsAuto()) + bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(*pFmt)); + if( ( !bSearchHidden && pFmt->IsHidden( ) && !bUsed ) || pFmt->IsDefault() || pFmt->IsAuto() ) { continue; } const sal_uInt16 nId = pFmt->GetPoolFmtId(); - bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(*pFmt)); if( !bUsed ) { if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF @@ -2659,7 +2772,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() // if ( nSrchMask == SFXSTYLEBIT_ALL ) AppendStyleList(SwStyleNameMapper::GetFrmFmtUINameArray(), - bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, cFRAME); + bIsSearchUsed, bSearchHidden, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, cFRAME); } if( nSearchFamily == SFX_STYLE_FAMILY_PAGE || @@ -2673,10 +2786,11 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rDesc)); if( !bUsed ) { - if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF + if ( ( !bSearchHidden && rDesc.IsHidden() ) || + ( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF ? !(nId & USER_FMT) // searched for used and found none - : bIsSearchUsed ) + : bIsSearchUsed ) ) continue; } @@ -2684,7 +2798,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() } if ( nSrchMask == SFXSTYLEBIT_ALL ) AppendStyleList(SwStyleNameMapper::GetPageDescUINameArray(), - bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, cPAGE); + bIsSearchUsed, bSearchHidden, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, cPAGE); } if( nSearchFamily == SFX_STYLE_FAMILY_PSEUDO || @@ -2699,10 +2813,11 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rRule) ); if( !bUsed ) { - if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF + if( ( !bSearchHidden && rRule.IsHidden() ) || + ( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF ? !(rRule.GetPoolFmtId() & USER_FMT) // searched for used and found none - : bIsSearchUsed ) + : bIsSearchUsed ) ) continue; } @@ -2711,7 +2826,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() } if ( nSrchMask == SFXSTYLEBIT_ALL ) AppendStyleList(SwStyleNameMapper::GetNumRuleUINameArray(), - bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, cNUMRULE); + bIsSearchUsed, bSearchHidden, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, cNUMRULE); } if(!aLst.empty()) @@ -2762,39 +2877,60 @@ SfxStyleSheetBase* SwStyleSheetIterator::Find(const rtl::OUString& rName) } void SwStyleSheetIterator::AppendStyleList(const boost::ptr_vector<String>& rList, - sal_Bool bTestUsed, + sal_Bool bTestUsed, sal_Bool bTestHidden, sal_uInt16 nSection, char cType ) { - if( bTestUsed ) + SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc(); + sal_Bool bUsed = sal_False; + for ( sal_uInt16 i=0; i < rList.size(); ++i ) { - SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc(); - for ( sal_uInt16 i=0; i < rList.size(); ++i ) + sal_Bool bHidden = sal_False; + sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rList[i], (SwGetPoolIdFromName)nSection); + switch ( nSection ) { - sal_Bool bUsed = sal_False; - sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rList[i], (SwGetPoolIdFromName)nSection); - switch ( nSection ) - { - case nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL: - bUsed = rDoc.IsPoolTxtCollUsed( nId ); - break; - case nsSwGetPoolIdFromName::GET_POOLID_CHRFMT: - bUsed = rDoc.IsPoolFmtUsed( nId ); - break; - case nsSwGetPoolIdFromName::GET_POOLID_FRMFMT: - bUsed = rDoc.IsPoolFmtUsed( nId ); - case nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC: - bUsed = rDoc.IsPoolPageDescUsed( nId ); - break; - default: - OSL_ENSURE( !this, "unknown PoolFmt-Id" ); - } - if ( bUsed ) - aLst.Append( cType, rList[i] ); + case nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL: + { + bUsed = rDoc.IsPoolTxtCollUsed( nId ); + SwFmt* pFmt = rDoc.FindTxtFmtCollByName( rList[i] ); + bHidden = pFmt && pFmt->IsHidden( ); + } + break; + case nsSwGetPoolIdFromName::GET_POOLID_CHRFMT: + { + bUsed = rDoc.IsPoolFmtUsed( nId ); + SwFmt* pFmt = rDoc.FindCharFmtByName( rList[i] ); + bHidden = pFmt && pFmt->IsHidden( ); + } + break; + case nsSwGetPoolIdFromName::GET_POOLID_FRMFMT: + { + bUsed = rDoc.IsPoolFmtUsed( nId ); + SwFmt* pFmt = rDoc.FindFrmFmtByName( rList[i] ); + bHidden = pFmt && pFmt->IsHidden( ); + } + break; + case nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC: + { + bUsed = rDoc.IsPoolPageDescUsed( nId ); + SwPageDesc* pPgDesc = rDoc.FindPageDescByName( rList[i] ); + bHidden = pPgDesc && pPgDesc->IsHidden( ); + } + break; + case nsSwGetPoolIdFromName::GET_POOLID_NUMRULE: + { + SwNumRule* pRule = rDoc.FindNumRulePtr( rList[i] ); + bUsed = pRule && rDoc.IsUsed( *pRule ); + bHidden = pRule && pRule->IsHidden( ); + } + break; + default: + OSL_ENSURE( !this, "unknown PoolFmt-Id" ); } - } - else - for ( sal_uInt16 i=0; i < rList.size(); ++i ) + + bool bMatchHidden = ( bTestHidden && bHidden ) || ( !bTestHidden && ( !bHidden || bUsed ) ); + if ( ( !bTestUsed && bMatchHidden ) || ( bTestUsed && bUsed ) ) aLst.Append( cType, rList[i] ); + } } void SwStyleSheetIterator::Notify( SfxBroadcaster&, const SfxHint& rHint ) |