diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2015-09-22 09:15:50 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-09-22 18:48:43 +0000 |
commit | 2ea92be9973e6892727eae37ae958863702b3658 (patch) | |
tree | 31a3e6bb3e43b67dd8ddfcfc37875956666f5dd9 /sc/source/ui | |
parent | 015eb39d963acf534bd5beaf9331a6d37af2acd6 (diff) |
convert SC_CONVERT constants to scoped enum
Change-Id: Ic81052e86ea6c2ea41357bde83ffd4df73afcb01
Reviewed-on: https://gerrit.libreoffice.org/18768
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/inc/content.hxx | 62 | ||||
-rw-r--r-- | sc/source/ui/inc/navsett.hxx | 16 | ||||
-rw-r--r-- | sc/source/ui/navipi/content.cxx | 265 | ||||
-rw-r--r-- | sc/source/ui/navipi/navipi.cxx | 31 | ||||
-rw-r--r-- | sc/source/ui/unoobj/targuno.cxx | 12 |
5 files changed, 189 insertions, 197 deletions
diff --git a/sc/source/ui/inc/content.hxx b/sc/source/ui/inc/content.hxx index 9a01602c7d30..8da6b700e994 100644 --- a/sc/source/ui/inc/content.hxx +++ b/sc/source/ui/inc/content.hxx @@ -24,6 +24,7 @@ #include "global.hxx" #include "address.hxx" #include <tools/solar.h> +#include <o3tl/enumarray.hxx> class ScNavigatorDlg; class ScDocument; @@ -31,44 +32,39 @@ class ScDocShell; class ScAreaLink; class SdrPage; -#define SC_CONTENT_ROOT 0 -#define SC_CONTENT_TABLE 1 -#define SC_CONTENT_RANGENAME 2 -#define SC_CONTENT_DBAREA 3 -#define SC_CONTENT_GRAPHIC 4 -#define SC_CONTENT_OLEOBJECT 5 -#define SC_CONTENT_NOTE 6 -#define SC_CONTENT_AREALINK 7 -#define SC_CONTENT_DRAWING 8 -#define SC_CONTENT_COUNT 9 +enum class ScContentId { + ROOT, TABLE, RANGENAME, DBAREA, + GRAPHIC, OLEOBJECT, NOTE, AREALINK, + DRAWING, LAST = DRAWING +}; const sal_uLong SC_CONTENT_NOCHILD = ~0UL; class ScContentTree : public SvTreeListBox { VclPtr<ScNavigatorDlg> pParentWindow; - ImageList aEntryImages; - SvTreeListEntry* pRootNodes[SC_CONTENT_COUNT]; - sal_uInt16 nRootType; // set as Root - OUString aManualDoc; // Switched in Navigator (Title) - bool bHiddenDoc; // Hidden active? - OUString aHiddenName; // URL to load - OUString aHiddenTitle; // for display - ScDocument* pHiddenDocument; // temporary - bool bisInNavigatoeDlg; - OUString sKeyString; - - sal_uInt16 pPosList[SC_CONTENT_COUNT]; // for the sequence + ImageList aEntryImages; + o3tl::enumarray<ScContentId, SvTreeListEntry*> pRootNodes; + ScContentId nRootType; // set as Root + OUString aManualDoc; // Switched in Navigator (Title) + bool bHiddenDoc; // Hidden active? + OUString aHiddenName; // URL to load + OUString aHiddenTitle; // for display + ScDocument* pHiddenDocument; // temporary + bool bisInNavigatoeDlg; + OUString sKeyString; + + o3tl::enumarray<ScContentId, sal_uInt16> pPosList; // for the sequence static bool bIsInDrag; // static, if the Navigator is deleted in ExecuteDrag ScDocShell* GetManualOrCurrent(); - void InitRoot(sal_uInt16 nType); - void ClearType(sal_uInt16 nType); + void InitRoot(ScContentId nType); + void ClearType(ScContentId nType); void ClearAll(); - void InsertContent( sal_uInt16 nType, const OUString& rValue ); - void GetDrawNames( sal_uInt16 nType ); + void InsertContent( ScContentId nType, const OUString& rValue ); + void GetDrawNames( ScContentId nType ); void GetTableNames(); void GetAreaNames(); @@ -79,9 +75,9 @@ class ScContentTree : public SvTreeListBox void GetDrawingNames(); void GetNoteStrings(); - static bool IsPartOfType( sal_uInt16 nContentType, sal_uInt16 nObjIdentifier ); + static bool IsPartOfType( ScContentId nContentType, sal_uInt16 nObjIdentifier ); - bool DrawNamesChanged( sal_uInt16 nType ); + bool DrawNamesChanged( ScContentId nType ); bool NoteStringsChanged(); ScAddress GetNotePos( sal_uLong nIndex ); @@ -91,7 +87,7 @@ class ScContentTree : public SvTreeListBox @param rnRootIndex Root index of specified entry is returned. @param rnChildIndex Index of the entry inside its root is returned (or SC_CONTENT_NOCHILD if entry is root). @param pEntry The entry to examine. */ - void GetEntryIndexes( sal_uInt16& rnRootIndex, sal_uLong& rnChildIndex, SvTreeListEntry* pEntry ) const; + void GetEntryIndexes( ScContentId& rnRootIndex, sal_uLong& rnChildIndex, SvTreeListEntry* pEntry ) const; /** Returns the child index of the specified listbox entry. @param pEntry The entry to examine or NULL for the selected entry. @@ -130,18 +126,18 @@ public: OUString GetEntryAltText( SvTreeListEntry* pEntry ) const SAL_OVERRIDE; OUString GetEntryLongDescription( SvTreeListEntry* pEntry ) const SAL_OVERRIDE; - void ObjectFresh( sal_uInt16 nType, SvTreeListEntry* pEntry = NULL); + void ObjectFresh( ScContentId nType, SvTreeListEntry* pEntry = NULL); bool SetNavigatorDlgFlag(bool isInNavigatoeDlg){ return bisInNavigatoeDlg=isInNavigatoeDlg;}; virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE; virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE; void InitWindowBits( bool bButtons ); - void Refresh( sal_uInt16 nType = 0 ); + void Refresh( ScContentId nType = ScContentId::ROOT ); void ToggleRoot(); - void SetRootType( sal_uInt16 nNew ); - sal_uInt16 GetRootType() const { return nRootType; } + void SetRootType( ScContentId nNew ); + ScContentId GetRootType() const { return nRootType; } void ActiveDocChanged(); void ResetManualDoc(); diff --git a/sc/source/ui/inc/navsett.hxx b/sc/source/ui/inc/navsett.hxx index 66d307af759b..f0236c21df09 100644 --- a/sc/source/ui/inc/navsett.hxx +++ b/sc/source/ui/inc/navsett.hxx @@ -23,27 +23,29 @@ #include <tools/solar.h> #include <vector> +#include <o3tl/enumarray.hxx> +#include <content.hxx> /** Contains settings of the navigator listbox. This includes the expand state of each listbox entry and the index of the selected entry and sub entry. */ class ScNavigatorSettings { private: - ::std::vector< bool > maExpandedVec; /// Array of Booleans for expand state. - sal_uInt16 mnRootSelected; /// Index of selected root entry. + o3tl::enumarray<ScContentId,bool> maExpandedVec; /// Array of Booleans for expand state. + ScContentId mnRootSelected; /// Index of selected root entry. sal_uLong mnChildSelected; /// Index of selected child entry. public: ScNavigatorSettings(); - inline void SetExpanded( sal_uInt16 nIndex, bool bExpand ) { maExpandedVec[ nIndex ] = bExpand; } - inline bool IsExpanded( sal_uInt16 nIndex ) const { return maExpandedVec[ nIndex ]; } + inline void SetExpanded( ScContentId nIndex, bool bExpand ) { maExpandedVec[ nIndex ] = bExpand; } + inline bool IsExpanded( ScContentId nIndex ) const { return maExpandedVec[ nIndex ]; } - inline void SetRootSelected( sal_uInt16 nIndex ) { mnRootSelected = nIndex; } - inline sal_uInt16 GetRootSelected() const { return mnRootSelected; } + inline void SetRootSelected( ScContentId nIndex ) { mnRootSelected = nIndex; } + inline ScContentId GetRootSelected() const { return mnRootSelected; } inline void SetChildSelected( sal_uLong nIndex ) { mnChildSelected = nIndex; } - inline sal_uLong GetChildSelected() const { return mnChildSelected; } + inline sal_uLong GetChildSelected() const { return mnChildSelected; } }; #endif // INCLUDED_SC_SOURCE_UI_INC_NAVSETT_HXX diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index c85f30516256..b6c79df9dafb 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -65,17 +65,17 @@ using namespace com::sun::star; // Reihenfolge der Kategorien im Navigator ------------------------------------- -static const sal_uInt16 pTypeList[SC_CONTENT_COUNT] = +static const ScContentId pTypeList[(int)ScContentId::LAST + 1] = { - SC_CONTENT_ROOT, // ROOT (0) muss vorne stehen - SC_CONTENT_TABLE, - SC_CONTENT_RANGENAME, - SC_CONTENT_DBAREA, - SC_CONTENT_AREALINK, - SC_CONTENT_GRAPHIC, - SC_CONTENT_OLEOBJECT, - SC_CONTENT_NOTE, - SC_CONTENT_DRAWING + ScContentId::ROOT, // ROOT (0) muss vorne stehen + ScContentId::TABLE, + ScContentId::RANGENAME, + ScContentId::DBAREA, + ScContentId::AREALINK, + ScContentId::GRAPHIC, + ScContentId::OLEOBJECT, + ScContentId::NOTE, + ScContentId::DRAWING }; bool ScContentTree::bIsInDrag = false; @@ -115,20 +115,20 @@ ScDocShell* ScContentTree::GetManualOrCurrent() ScContentTree::ScContentTree( vcl::Window* pParent, const ResId& rResId ) : SvTreeListBox ( pParent, rResId ), aEntryImages ( ScResId( RID_IMAGELIST_NAVCONT ) ), - nRootType ( SC_CONTENT_ROOT ), + nRootType ( ScContentId::ROOT ), bHiddenDoc ( false ), pHiddenDocument ( NULL ), bisInNavigatoeDlg ( false ) { sal_uInt16 i; - for (i=0; i<SC_CONTENT_COUNT; i++) + for (i=0; i<=(int)ScContentId::LAST; i++) pPosList[pTypeList[i]] = i; // invers zum suchen pParentWindow = static_cast<ScNavigatorDlg*>(pParent); - pRootNodes[0] = NULL; - for (i=1; i<SC_CONTENT_COUNT; i++) - InitRoot(i); + pRootNodes[ScContentId::ROOT] = NULL; + for (i=1; i<(int)ScContentId::LAST; i++) + InitRoot((ScContentId)i); SetNodeDefaultImages(); @@ -155,18 +155,18 @@ void ScContentTree::dispose() OUString ScContentTree::getAltLongDescText( SvTreeListEntry* pEntry, bool isAltText) const { - sal_uInt16 nType; + ScContentId nType; sal_uLong nChild; GetEntryIndexes( nType, nChild, pEntry ); switch( nType ) { - case SC_CONTENT_OLEOBJECT: - case SC_CONTENT_GRAPHIC: - case SC_CONTENT_DRAWING: + case ScContentId::OLEOBJECT: + case ScContentId::GRAPHIC: + case ScContentId::DRAWING: { SdrObject* pFound = NULL; ScDocument* pDoc = ( const_cast< ScContentTree* >(this) )->GetSourceDocument(); - SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS; + SdrIterMode eIter = ( nType == ScContentId::DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS; ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); SfxObjectShell* pShell = pDoc->GetDocumentShell(); if (pDrawLayer && pShell) @@ -201,6 +201,7 @@ OUString ScContentTree::getAltLongDescText( SvTreeListEntry* pEntry, bool isAltT } } break; + default: break; } return OUString(); } @@ -215,21 +216,21 @@ OUString ScContentTree::GetEntryLongDescription( SvTreeListEntry* pEntry ) const return getAltLongDescText( pEntry, false ); } -void ScContentTree::InitRoot( sal_uInt16 nType ) +void ScContentTree::InitRoot( ScContentId nType ) { - if ( !nType ) + if ( nType == ScContentId::ROOT ) return; - if ( nRootType && nRootType != nType ) // ausgeblendet ? + if ( nRootType != ScContentId::ROOT && nRootType != nType ) // ausgeblendet ? { pRootNodes[nType] = NULL; return; } - const Image& rImage = aEntryImages.GetImage( nType ); - OUString aName( ScResId( SCSTR_CONTENT_ROOT + nType ) ); + const Image& rImage = aEntryImages.GetImage( (int) nType ); + OUString aName( ScResId( SCSTR_CONTENT_ROOT + (int)nType ) ); // wieder an die richtige Position: - sal_uInt16 nPos = nRootType ? 0 : pPosList[nType]-1; + sal_uInt16 nPos = nRootType != ScContentId::ROOT ? 0 : pPosList[nType]-1; SvTreeListEntry* pNew = InsertEntry( aName, rImage, rImage, NULL, false, nPos ); pRootNodes[nType] = pNew; @@ -246,13 +247,13 @@ void ScContentTree::ClearAll() Control::SetUpdateMode(false); Clear(); Control::SetUpdateMode(bOldUpdate); - for (sal_uInt16 i=1; i<SC_CONTENT_COUNT; i++) - InitRoot(i); + for (sal_uInt16 i=1; i<=(int)ScContentId::LAST; i++) + InitRoot((ScContentId)i); } -void ScContentTree::ClearType(sal_uInt16 nType) +void ScContentTree::ClearType(ScContentId nType) { - if (!nType) + if (nType == ScContentId::ROOT) ClearAll(); else { @@ -266,14 +267,8 @@ void ScContentTree::ClearType(sal_uInt16 nType) } } -void ScContentTree::InsertContent( sal_uInt16 nType, const OUString& rValue ) +void ScContentTree::InsertContent( ScContentId nType, const OUString& rValue ) { - if (nType >= SC_CONTENT_COUNT) - { - OSL_FAIL("ScContentTree::InsertContent mit falschem Typ"); - return; - } - SvTreeListEntry* pParent = pRootNodes[nType]; if (pParent) InsertEntry( rValue, pParent ); @@ -283,9 +278,9 @@ void ScContentTree::InsertContent( sal_uInt16 nType, const OUString& rValue ) } } -void ScContentTree::GetEntryIndexes( sal_uInt16& rnRootIndex, sal_uLong& rnChildIndex, SvTreeListEntry* pEntry ) const +void ScContentTree::GetEntryIndexes( ScContentId& rnRootIndex, sal_uLong& rnChildIndex, SvTreeListEntry* pEntry ) const { - rnRootIndex = SC_CONTENT_ROOT; + rnRootIndex = ScContentId::ROOT; rnChildIndex = SC_CONTENT_NOCHILD; if( !pEntry ) @@ -293,8 +288,9 @@ void ScContentTree::GetEntryIndexes( sal_uInt16& rnRootIndex, sal_uLong& rnChild SvTreeListEntry* pParent = GetParent( pEntry ); bool bFound = false; - for( sal_uInt16 nRoot = 1; !bFound && (nRoot < SC_CONTENT_COUNT); ++nRoot ) + for( int i = 1; !bFound && (i <= (int)ScContentId::LAST); ++i ) { + ScContentId nRoot = (ScContentId)i; if( pEntry == pRootNodes[ nRoot ] ) { rnRootIndex = nRoot; @@ -326,7 +322,7 @@ void ScContentTree::GetEntryIndexes( sal_uInt16& rnRootIndex, sal_uLong& rnChild sal_uLong ScContentTree::GetChildIndex( SvTreeListEntry* pEntry ) const { - sal_uInt16 nRoot; + ScContentId nRoot; sal_uLong nChild; GetEntryIndexes( nRoot, nChild, pEntry ); return nChild; @@ -351,12 +347,12 @@ static OUString lcl_GetDBAreaRange( ScDocument* pDoc, const OUString& rDBName ) IMPL_LINK_NOARG_TYPED(ScContentTree, ContentDoubleClickHdl, SvTreeListBox*, bool) { - sal_uInt16 nType; + ScContentId nType; sal_uLong nChild; SvTreeListEntry* pEntry = GetCurEntry(); GetEntryIndexes( nType, nChild, pEntry ); - if( pEntry && (nType != SC_CONTENT_ROOT) && (nChild != SC_CONTENT_NOCHILD) ) + if( pEntry && (nType != ScContentId::ROOT) && (nChild != SC_CONTENT_NOCHILD) ) { if ( bHiddenDoc ) return false; //! spaeter... @@ -368,15 +364,15 @@ IMPL_LINK_NOARG_TYPED(ScContentTree, ContentDoubleClickHdl, SvTreeListBox*, bool switch( nType ) { - case SC_CONTENT_TABLE: + case ScContentId::TABLE: pParentWindow->SetCurrentTableStr( aText ); break; - case SC_CONTENT_RANGENAME: + case ScContentId::RANGENAME: pParentWindow->SetCurrentCellStr( aText ); break; - case SC_CONTENT_DBAREA: + case ScContentId::DBAREA: { // Wenn gleiche Bereichs- und DB-Namen existieren, wird // bei SID_CURRENTCELL der Bereichsname genommen. @@ -388,13 +384,13 @@ IMPL_LINK_NOARG_TYPED(ScContentTree, ContentDoubleClickHdl, SvTreeListBox*, bool } break; - case SC_CONTENT_OLEOBJECT: - case SC_CONTENT_GRAPHIC: - case SC_CONTENT_DRAWING: + case ScContentId::OLEOBJECT: + case ScContentId::GRAPHIC: + case ScContentId::DRAWING: pParentWindow->SetCurrentObject( aText ); break; - case SC_CONTENT_NOTE: + case ScContentId::NOTE: { ScAddress aPos = GetNotePos( nChild ); pParentWindow->SetCurrentTable( aPos.Tab() ); @@ -402,7 +398,7 @@ IMPL_LINK_NOARG_TYPED(ScContentTree, ContentDoubleClickHdl, SvTreeListBox*, bool } break; - case SC_CONTENT_AREALINK: + case ScContentId::AREALINK: { const ScAreaLink* pLink = GetLink( nChild ); if( pLink ) @@ -414,6 +410,7 @@ IMPL_LINK_NOARG_TYPED(ScContentTree, ContentDoubleClickHdl, SvTreeListBox*, bool } } break; + default: break; } ScNavigatorDlg::ReleaseFocus(); // set focus into document @@ -446,11 +443,11 @@ void ScContentTree::KeyInput( const KeyEvent& rKEvt ) SvTreeListEntry* pEntry = GetCurEntry(); if( pEntry ) { - sal_uInt16 nType; + ScContentId nType; sal_uLong nChild; GetEntryIndexes( nType, nChild, pEntry ); - if( (nType != SC_CONTENT_ROOT) && (nChild == SC_CONTENT_NOCHILD) ) + if( (nType != ScContentId::ROOT) && (nChild == SC_CONTENT_NOCHILD) ) { if ( IsExpanded( pEntry ) ) Collapse( pEntry ); @@ -472,11 +469,11 @@ void ScContentTree::KeyInput( const KeyEvent& rKEvt ) if(aCode.GetCode() == KEY_SPACE ) { bUsed = true; - sal_uInt16 nType; + ScContentId nType; sal_uLong nChild; SvTreeListEntry* pEntry = GetCurEntry(); GetEntryIndexes( nType, nChild, pEntry ); - if( pEntry && (nType != SC_CONTENT_ROOT) && (nChild != SC_CONTENT_NOCHILD) ) + if( pEntry && (nType != ScContentId::ROOT) && (nChild != SC_CONTENT_NOCHILD) ) { if ( bHiddenDoc ) return ; //! spaeter... @@ -486,9 +483,9 @@ void ScContentTree::KeyInput( const KeyEvent& rKEvt ) pParentWindow->SetCurrentDoc( aManualDoc ); switch( nType ) { - case SC_CONTENT_OLEOBJECT: - case SC_CONTENT_GRAPHIC: - case SC_CONTENT_DRAWING: + case ScContentId::OLEOBJECT: + case ScContentId::GRAPHIC: + case ScContentId::DRAWING: { vcl::Window* pWindow=reinterpret_cast<vcl::Window*>(GetParent(pEntry)); ScNavigatorDlg* pScNavigatorDlg = static_cast<ScNavigatorDlg*>(pWindow); @@ -522,6 +519,7 @@ void ScContentTree::KeyInput( const KeyEvent& rKEvt ) } } break; + default: break; } } } @@ -673,12 +671,12 @@ void ScContentTree::RequestHelp( const HelpEvent& rHEvt ) " " + GetEntryText(pEntry); bRet = true; } - else if ( pParent == pRootNodes[SC_CONTENT_NOTE] ) + else if ( pParent == pRootNodes[ScContentId::NOTE] ) { aHelpText = GetEntryText(pEntry); // Notizen als Help-Text bRet = true; } - else if ( pParent == pRootNodes[SC_CONTENT_AREALINK] ) + else if ( pParent == pRootNodes[ScContentId::AREALINK] ) { sal_uLong nIndex = GetChildIndex(pEntry); if( nIndex != SC_CONTENT_NOCHILD ) @@ -729,11 +727,11 @@ ScDocument* ScContentTree::GetSourceDocument() } //Move along and draw "*" sign . -void ScContentTree::ObjectFresh( sal_uInt16 nType, SvTreeListEntry* pEntry ) +void ScContentTree::ObjectFresh( ScContentId nType, SvTreeListEntry* pEntry ) { if ( bHiddenDoc && !pHiddenDocument ) return; // anderes Dokument angezeigt - if(nType ==SC_CONTENT_GRAPHIC||nType ==SC_CONTENT_OLEOBJECT||nType ==SC_CONTENT_DRAWING) + if(nType ==ScContentId::GRAPHIC||nType ==ScContentId::OLEOBJECT||nType ==ScContentId::DRAWING) { SetUpdateMode(false); ClearType( nType ); @@ -767,45 +765,45 @@ void ScContentTree::ObjectFresh( sal_uInt16 nType, SvTreeListEntry* pEntry ) } } -void ScContentTree::Refresh( sal_uInt16 nType ) +void ScContentTree::Refresh( ScContentId nType ) { if ( bHiddenDoc && !pHiddenDocument ) return; // anderes Dokument angezeigt // wenn sich nichts geaendert hat, gleich abbrechen (gegen Geflacker) - if ( nType == SC_CONTENT_NOTE ) + if ( nType == ScContentId::NOTE ) if (!NoteStringsChanged()) return; - if ( nType == SC_CONTENT_GRAPHIC ) - if (!DrawNamesChanged(SC_CONTENT_GRAPHIC)) + if ( nType == ScContentId::GRAPHIC ) + if (!DrawNamesChanged(ScContentId::GRAPHIC)) return; - if ( nType == SC_CONTENT_OLEOBJECT ) - if (!DrawNamesChanged(SC_CONTENT_OLEOBJECT)) + if ( nType == ScContentId::OLEOBJECT ) + if (!DrawNamesChanged(ScContentId::OLEOBJECT)) return; - if ( nType == SC_CONTENT_DRAWING ) - if (!DrawNamesChanged(SC_CONTENT_DRAWING)) + if ( nType == ScContentId::DRAWING ) + if (!DrawNamesChanged(ScContentId::DRAWING)) return; SetUpdateMode(false); ClearType( nType ); - if ( !nType || nType == SC_CONTENT_TABLE ) + if ( nType == ScContentId::ROOT || nType == ScContentId::TABLE ) GetTableNames(); - if ( !nType || nType == SC_CONTENT_RANGENAME ) + if ( nType == ScContentId::ROOT || nType == ScContentId::RANGENAME ) GetAreaNames(); - if ( !nType || nType == SC_CONTENT_DBAREA ) + if ( nType == ScContentId::ROOT || nType == ScContentId::DBAREA ) GetDbNames(); - if ( !nType || nType == SC_CONTENT_GRAPHIC ) + if ( nType == ScContentId::ROOT || nType == ScContentId::GRAPHIC ) GetGraphicNames(); - if ( !nType || nType == SC_CONTENT_OLEOBJECT ) + if ( nType == ScContentId::ROOT || nType == ScContentId::OLEOBJECT ) GetOleNames(); - if ( !nType || nType == SC_CONTENT_DRAWING ) + if ( nType == ScContentId::ROOT || nType == ScContentId::DRAWING ) GetDrawingNames(); - if ( !nType || nType == SC_CONTENT_NOTE ) + if ( nType == ScContentId::ROOT || nType == ScContentId::NOTE ) GetNoteStrings(); - if ( !nType || nType == SC_CONTENT_AREALINK ) + if ( nType == ScContentId::ROOT || nType == ScContentId::AREALINK ) GetLinkNames(); ApplyNavigatorSettings(); @@ -814,7 +812,7 @@ void ScContentTree::Refresh( sal_uInt16 nType ) void ScContentTree::GetTableNames() { - if ( nRootType && nRootType != SC_CONTENT_TABLE ) // ausgeblendet ? + if ( nRootType != ScContentId::ROOT && nRootType != ScContentId::TABLE ) // ausgeblendet ? return; ScDocument* pDoc = GetSourceDocument(); @@ -826,7 +824,7 @@ void ScContentTree::GetTableNames() for ( SCTAB i=0; i<nCount; i++ ) { pDoc->GetName( i, aName ); - InsertContent( SC_CONTENT_TABLE, aName ); + InsertContent( ScContentId::TABLE, aName ); } } @@ -844,7 +842,7 @@ OUString createLocalRangeName(const OUString& rName, const OUString& rTableName) void ScContentTree::GetAreaNames() { - if ( nRootType && nRootType != SC_CONTENT_RANGENAME ) // ausgeblendet ? + if ( nRootType != ScContentId::ROOT && nRootType != ScContentId::RANGENAME ) // ausgeblendet ? return; ScDocument* pDoc = GetSourceDocument(); @@ -883,14 +881,14 @@ void ScContentTree::GetAreaNames() for (std::set<OUString>::iterator itr = aSet.begin(); itr != aSet.end(); ++itr) { - InsertContent(SC_CONTENT_RANGENAME, *itr); + InsertContent(ScContentId::RANGENAME, *itr); } } } void ScContentTree::GetDbNames() { - if ( nRootType && nRootType != SC_CONTENT_DBAREA ) // ausgeblendet ? + if ( nRootType != ScContentId::ROOT && nRootType != ScContentId::DBAREA ) // ausgeblendet ? return; ScDocument* pDoc = GetSourceDocument(); @@ -903,22 +901,22 @@ void ScContentTree::GetDbNames() for (; itr != itrEnd; ++itr) { const OUString& aStrName = (*itr)->GetName(); - InsertContent(SC_CONTENT_DBAREA, aStrName); + InsertContent(ScContentId::DBAREA, aStrName); } } -bool ScContentTree::IsPartOfType( sal_uInt16 nContentType, sal_uInt16 nObjIdentifier ) +bool ScContentTree::IsPartOfType( ScContentId nContentType, sal_uInt16 nObjIdentifier ) { bool bRet = false; switch ( nContentType ) { - case SC_CONTENT_GRAPHIC: + case ScContentId::GRAPHIC: bRet = ( nObjIdentifier == OBJ_GRAF ); break; - case SC_CONTENT_OLEOBJECT: + case ScContentId::OLEOBJECT: bRet = ( nObjIdentifier == OBJ_OLE2 ); break; - case SC_CONTENT_DRAWING: + case ScContentId::DRAWING: bRet = ( nObjIdentifier != OBJ_GRAF && nObjIdentifier != OBJ_OLE2 ); // everything else break; default: @@ -927,9 +925,9 @@ bool ScContentTree::IsPartOfType( sal_uInt16 nContentType, sal_uInt16 nObjIdenti return bRet; } -void ScContentTree::GetDrawNames( sal_uInt16 nType ) +void ScContentTree::GetDrawNames( ScContentId nType ) { - if ( nRootType && nRootType != nType ) // ausgeblendet ? + if ( nRootType != ScContentId::ROOT && nRootType != nType ) // ausgeblendet ? return; ScDocument* pDoc = GetSourceDocument(); @@ -937,7 +935,7 @@ void ScContentTree::GetDrawNames( sal_uInt16 nType ) return; // iterate in flat mode for groups - SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS; + SdrIterMode eIter = ( nType == ScContentId::DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS; ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); SfxObjectShell* pShell = pDoc->GetDocumentShell(); @@ -961,12 +959,6 @@ void ScContentTree::GetDrawNames( sal_uInt16 nType ) { if( bisInNavigatoeDlg ) { - if (nType >= SC_CONTENT_COUNT) - { - SAL_WARN("sc", "ScContentTree::InsertContent mit falschem Typ"); - return; - } - SvTreeListEntry* pParent = pRootNodes[nType]; if (pParent) { @@ -1007,22 +999,22 @@ void ScContentTree::GetDrawNames( sal_uInt16 nType ) void ScContentTree::GetGraphicNames() { - GetDrawNames( SC_CONTENT_GRAPHIC ); + GetDrawNames( ScContentId::GRAPHIC ); } void ScContentTree::GetOleNames() { - GetDrawNames( SC_CONTENT_OLEOBJECT ); + GetDrawNames( ScContentId::OLEOBJECT ); } void ScContentTree::GetDrawingNames() { - GetDrawNames( SC_CONTENT_DRAWING ); + GetDrawNames( ScContentId::DRAWING ); } void ScContentTree::GetLinkNames() { - if ( nRootType && nRootType != SC_CONTENT_AREALINK ) // ausgeblendet ? + if ( nRootType != ScContentId::ROOT && nRootType != ScContentId::AREALINK ) // ausgeblendet ? return; ScDocument* pDoc = GetSourceDocument(); @@ -1037,7 +1029,7 @@ void ScContentTree::GetLinkNames() { ::sfx2::SvBaseLink* pBase = *rLinks[i]; if (pBase->ISA(ScAreaLink)) - InsertContent( SC_CONTENT_AREALINK, static_cast<ScAreaLink*>(pBase)->GetSource() ); + InsertContent( ScContentId::AREALINK, static_cast<ScAreaLink*>(pBase)->GetSource() ); // in der Liste die Namen der Quellbereiche } @@ -1080,7 +1072,7 @@ static OUString lcl_NoteString( const ScPostIt& rNote ) void ScContentTree::GetNoteStrings() { - if ( nRootType && nRootType != SC_CONTENT_NOTE ) // ausgeblendet ? + if ( nRootType != ScContentId::ROOT && nRootType != ScContentId::NOTE ) // ausgeblendet ? return; ScDocument* pDoc = GetSourceDocument(); @@ -1092,7 +1084,7 @@ void ScContentTree::GetNoteStrings() pDoc->GetAllNoteEntries(aEntries); std::vector<sc::NoteEntry>::const_iterator it = aEntries.begin(), itEnd = aEntries.end(); for (; it != itEnd; ++it) - InsertContent(SC_CONTENT_NOTE, lcl_NoteString(*it->mpNote)); + InsertContent(ScContentId::NOTE, lcl_NoteString(*it->mpNote)); } ScAddress ScContentTree::GetNotePos( sal_uLong nIndex ) @@ -1110,7 +1102,7 @@ bool ScContentTree::NoteStringsChanged() if (!pDoc) return false; - SvTreeListEntry* pParent = pRootNodes[SC_CONTENT_NOTE]; + SvTreeListEntry* pParent = pRootNodes[ScContentId::NOTE]; if (!pParent) return false; @@ -1137,7 +1129,7 @@ bool ScContentTree::NoteStringsChanged() return false; } -bool ScContentTree::DrawNamesChanged( sal_uInt16 nType ) +bool ScContentTree::DrawNamesChanged( ScContentId nType ) { ScDocument* pDoc = GetSourceDocument(); if (!pDoc) @@ -1150,7 +1142,7 @@ bool ScContentTree::DrawNamesChanged( sal_uInt16 nType ) SvTreeListEntry* pEntry = FirstChild( pParent ); // iterate in flat mode for groups - SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS; + SdrIterMode eIter = ( nType == ScContentId::DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS; bool bEqual = true; ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); @@ -1192,11 +1184,11 @@ bool ScContentTree::DrawNamesChanged( sal_uInt16 nType ) return !bEqual; } -static bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const OUString& rName, ScRange& rRange ) +static bool lcl_GetRange( ScDocument* pDoc, ScContentId nType, const OUString& rName, ScRange& rRange ) { bool bFound = false; - if ( nType == SC_CONTENT_RANGENAME ) + if ( nType == ScContentId::RANGENAME ) { ScRangeName* pList = pDoc->GetRangeName(); if (pList) @@ -1206,7 +1198,7 @@ static bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const OUString& rN bFound = true; } } - else if ( nType == SC_CONTENT_DBAREA ) + else if ( nType == ScContentId::DBAREA ) { ScDBCollection* pList = pDoc->GetDBCollection(); if (pList) @@ -1227,14 +1219,14 @@ static bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const OUString& rN return bFound; } -static void lcl_DoDragObject( ScDocShell* pSrcShell, const OUString& rName, sal_uInt16 nType, vcl::Window* pWin ) +static void lcl_DoDragObject( ScDocShell* pSrcShell, const OUString& rName, ScContentId nType, vcl::Window* pWin ) { ScDocument& rSrcDoc = pSrcShell->GetDocument(); ScDrawLayer* pModel = rSrcDoc.GetDrawLayer(); if (pModel) { - bool bOle = ( nType == SC_CONTENT_OLEOBJECT ); - bool bGraf = ( nType == SC_CONTENT_GRAPHIC ); + bool bOle = ( nType == ScContentId::OLEOBJECT ); + bool bGraf = ( nType == ScContentId::GRAPHIC ); sal_uInt16 nDrawId = sal::static_int_cast<sal_uInt16>( bOle ? OBJ_OLE2 : ( bGraf ? OBJ_GRAF : OBJ_GRUP ) ); SCTAB nTab = 0; SdrObject* pObject = pModel->GetNamedObject( rName, nDrawId, nTab ); @@ -1305,16 +1297,16 @@ void ScContentTree::DoDrag() ScModule* pScMod = SC_MOD(); - sal_uInt16 nType; + ScContentId nType; sal_uLong nChild; SvTreeListEntry* pEntry = GetCurEntry(); GetEntryIndexes( nType, nChild, pEntry ); if( pEntry && (nChild != SC_CONTENT_NOCHILD) && - (nType != SC_CONTENT_ROOT) && - (nType != SC_CONTENT_NOTE) && - (nType != SC_CONTENT_AREALINK) ) + (nType != ScContentId::ROOT) && + (nType != ScContentId::NOTE) && + (nType != ScContentId::AREALINK) ) { OUString aText( GetEntryText( pEntry ) ); @@ -1366,17 +1358,18 @@ void ScContentTree::DoDrag() switch ( nType ) { - case SC_CONTENT_TABLE: + case ScContentId::TABLE: pScMod->SetDragLink( aDocName, aText, EMPTY_OUSTRING ); bDoLinkTrans = true; break; - case SC_CONTENT_RANGENAME: - case SC_CONTENT_DBAREA: + case ScContentId::RANGENAME: + case ScContentId::DBAREA: pScMod->SetDragLink( aDocName, EMPTY_OUSTRING, aText ); bDoLinkTrans = true; break; // other types cannot be linked + default: break; } } } @@ -1398,7 +1391,7 @@ void ScContentTree::DoDrag() if ( pSrcShell ) { ScDocument& rSrcDoc = pSrcShell->GetDocument(); - if ( nType == SC_CONTENT_RANGENAME || nType == SC_CONTENT_DBAREA ) + if ( nType == ScContentId::RANGENAME || nType == ScContentId::DBAREA ) { ScRange aRange; if ( lcl_GetRange( &rSrcDoc, nType, aText, aRange ) ) @@ -1406,7 +1399,7 @@ void ScContentTree::DoDrag() lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR, this ); } } - else if ( nType == SC_CONTENT_TABLE ) + else if ( nType == ScContentId::TABLE ) { SCTAB nTab; if ( rSrcDoc.GetTable( aText, nTab ) ) @@ -1415,8 +1408,8 @@ void ScContentTree::DoDrag() lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR | SC_DROP_TABLE, this ); } } - else if ( nType == SC_CONTENT_GRAPHIC || nType == SC_CONTENT_OLEOBJECT || - nType == SC_CONTENT_DRAWING ) + else if ( nType == ScContentId::GRAPHIC || nType == ScContentId::OLEOBJECT || + nType == ScContentId::DRAWING ) { lcl_DoDragObject( pSrcShell, aText, nType, this ); @@ -1495,12 +1488,12 @@ void ScContentTree::InitWindowBits( bool bButtons ) SetStyle( nFlags ); } -void ScContentTree::SetRootType( sal_uInt16 nNew ) +void ScContentTree::SetRootType( ScContentId nNew ) { if ( nNew != nRootType ) { nRootType = nNew; - InitWindowBits( nNew == 0 ); + InitWindowBits( nNew == ScContentId::ROOT ); Refresh(); ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg(); @@ -1510,16 +1503,16 @@ void ScContentTree::SetRootType( sal_uInt16 nNew ) void ScContentTree::ToggleRoot() // nach Selektion { - sal_uInt16 nNew = SC_CONTENT_ROOT; - if ( nRootType == SC_CONTENT_ROOT ) + ScContentId nNew = ScContentId::ROOT; + if ( nRootType == ScContentId::ROOT ) { SvTreeListEntry* pEntry = GetCurEntry(); if (pEntry) { SvTreeListEntry* pParent = GetParent(pEntry); - for (sal_uInt16 i=1; i<SC_CONTENT_COUNT; i++) - if ( pEntry == pRootNodes[i] || pParent == pRootNodes[i] ) - nNew = i; + for (sal_uInt16 i=1; i<=(int)ScContentId::LAST; i++) + if ( pEntry == pRootNodes[(ScContentId)i] || pParent == pRootNodes[(ScContentId)i] ) + nNew = (ScContentId)i; } } @@ -1626,11 +1619,12 @@ void ScContentTree::ApplyNavigatorSettings() const ScNavigatorSettings* pSettings = ScNavigatorDlg::GetNavigatorSettings(); if( pSettings ) { - sal_uInt16 nRootSel = pSettings->GetRootSelected(); + ScContentId nRootSel = pSettings->GetRootSelected(); sal_uLong nChildSel = pSettings->GetChildSelected(); - for( sal_uInt16 nEntry = 1; nEntry < SC_CONTENT_COUNT; ++nEntry ) + for( int i = 1; i <= (int)ScContentId::LAST; ++i ) { + ScContentId nEntry = (ScContentId)i; if( pRootNodes[ nEntry ] ) { // expand @@ -1661,12 +1655,13 @@ void ScContentTree::StoreNavigatorSettings() const ScNavigatorSettings* pSettings = ScNavigatorDlg::GetNavigatorSettings(); if( pSettings ) { - for( sal_uInt16 nEntry = 1; nEntry < SC_CONTENT_COUNT; ++nEntry ) + for( int i = 1; i <= (int)ScContentId::LAST; ++i ) { + ScContentId nEntry = (ScContentId)i; bool bExp = pRootNodes[ nEntry ] && IsExpanded( pRootNodes[ nEntry ] ); pSettings->SetExpanded( nEntry, bExp ); } - sal_uInt16 nRoot; + ScContentId nRoot; sal_uLong nChild; GetEntryIndexes( nRoot, nChild, GetCurEntry() ); pSettings->SetRootSelected( nRoot ); diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx index e865dfcc6e8a..6618057df009 100644 --- a/sc/source/ui/navipi/navipi.cxx +++ b/sc/source/ui/navipi/navipi.cxx @@ -422,7 +422,7 @@ void CommandToolBox::UpdateButtons() else { EnableItem( IID_CHANGEROOT ); - bool bRootSet = rDlg.aLbEntries->GetRootType() != SC_CONTENT_ROOT; + bool bRootSet = rDlg.aLbEntries->GetRootType() != ScContentId::ROOT; CheckItem( IID_CHANGEROOT, bRootSet ); } @@ -464,8 +464,7 @@ void CommandToolBox::DataChanged( const DataChangedEvent& rDCEvt ) // class ScNavigatorSettings ScNavigatorSettings::ScNavigatorSettings() : - maExpandedVec( SC_CONTENT_COUNT, false ), - mnRootSelected( SC_CONTENT_ROOT ), + mnRootSelected( ScContentId::ROOT ), mnChildSelected( SC_CONTENT_NOCHILD ) { } @@ -638,8 +637,8 @@ ScNavigatorDlg::ScNavigatorDlg( SfxBindings* pB, SfxChildWindowContext* pCW, vcl DragDropMode::ENABLE_TOP ); // was a category chosen as root? - sal_uInt16 nLastRoot = rCfg.GetRootType(); - if ( nLastRoot ) + ScContentId nLastRoot = rCfg.GetRootType(); + if ( nLastRoot != ScContentId::ROOT ) aLbEntries->SetRootType( nLastRoot ); aLbEntries->Refresh(); @@ -839,25 +838,25 @@ void ScNavigatorDlg::Notify( SfxBroadcaster&, const SfxHint& rHint ) switch ( nHintId ) { case SC_HINT_TABLES_CHANGED: - aLbEntries->Refresh( SC_CONTENT_TABLE ); + aLbEntries->Refresh( ScContentId::TABLE ); break; case SC_HINT_DBAREAS_CHANGED: - aLbEntries->Refresh( SC_CONTENT_DBAREA ); + aLbEntries->Refresh( ScContentId::DBAREA ); break; case SC_HINT_AREAS_CHANGED: - aLbEntries->Refresh( SC_CONTENT_RANGENAME ); + aLbEntries->Refresh( ScContentId::RANGENAME ); break; case SC_HINT_DRAW_CHANGED: - aLbEntries->Refresh( SC_CONTENT_GRAPHIC ); - aLbEntries->Refresh( SC_CONTENT_OLEOBJECT ); - aLbEntries->Refresh( SC_CONTENT_DRAWING ); + aLbEntries->Refresh( ScContentId::GRAPHIC ); + aLbEntries->Refresh( ScContentId::OLEOBJECT ); + aLbEntries->Refresh( ScContentId::DRAWING ); break; case SC_HINT_AREALINKS_CHANGED: - aLbEntries->Refresh( SC_CONTENT_AREALINK ); + aLbEntries->Refresh( ScContentId::AREALINK ); break; // SFX_HINT_DOCCHANGED not only at document change @@ -871,9 +870,9 @@ void ScNavigatorDlg::Notify( SfxBroadcaster&, const SfxHint& rHint ) aContentIdle.Start(); // Do not search notes immediately break; case FID_KILLEDITVIEW: - aLbEntries->ObjectFresh( SC_CONTENT_OLEOBJECT ); - aLbEntries->ObjectFresh( SC_CONTENT_DRAWING ); - aLbEntries->ObjectFresh( SC_CONTENT_GRAPHIC ); + aLbEntries->ObjectFresh( ScContentId::OLEOBJECT ); + aLbEntries->ObjectFresh( ScContentId::DRAWING ); + aLbEntries->ObjectFresh( ScContentId::GRAPHIC ); break; default: break; @@ -896,7 +895,7 @@ IMPL_LINK_TYPED( ScNavigatorDlg, TimeHdl, Idle*, pIdle, void ) if ( pIdle != &aContentIdle ) return; - aLbEntries->Refresh( SC_CONTENT_NOTE ); + aLbEntries->Refresh( ScContentId::NOTE ); } void ScNavigatorDlg::SetDropMode(sal_uInt16 nNew) diff --git a/sc/source/ui/unoobj/targuno.cxx b/sc/source/ui/unoobj/targuno.cxx index 09dce6220125..d4032eb5fd6b 100644 --- a/sc/source/ui/unoobj/targuno.cxx +++ b/sc/source/ui/unoobj/targuno.cxx @@ -211,23 +211,23 @@ void SAL_CALL ScLinkTargetTypeObj::setPropertyValue(const OUString& /* aProperty void ScLinkTargetTypeObj::SetLinkTargetBitmap( uno::Any& rRet, sal_uInt16 nType ) { - sal_uInt16 nImgId = 0; + ScContentId nImgId = ScContentId::ROOT; switch ( nType ) { case SC_LINKTARGETTYPE_SHEET: - nImgId = SC_CONTENT_TABLE; + nImgId = ScContentId::TABLE; break; case SC_LINKTARGETTYPE_RANGENAME: - nImgId = SC_CONTENT_RANGENAME; + nImgId = ScContentId::RANGENAME; break; case SC_LINKTARGETTYPE_DBAREA: - nImgId = SC_CONTENT_DBAREA; + nImgId = ScContentId::DBAREA; break; } - if (nImgId) + if (nImgId != ScContentId::ROOT) { ImageList aEntryImages( ScResId( RID_IMAGELIST_NAVCONT ) ); - const Image& rImage = aEntryImages.GetImage( nImgId ); + const Image& rImage = aEntryImages.GetImage( (sal_uInt16)nImgId ); rRet <<= uno::Reference< awt::XBitmap > (VCLUnoHelper::CreateBitmap( rImage.GetBitmapEx() )); } } |