Kaydet (Commit) cb45d0d4 authored tarafından Noel Grandin's avatar Noel Grandin

convert CONTENT_TYPE to scoped enum

Change-Id: I84b6d595f3997207385355f2bb3a9b64e6c9977b
Reviewed-on: https://gerrit.libreoffice.org/18536Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 2c93e16d
...@@ -156,7 +156,7 @@ class SwContentType : public SwTypeNumber ...@@ -156,7 +156,7 @@ class SwContentType : public SwTypeNumber
OUString sSingleContentTypeName; // name of content type, singular OUString sSingleContentTypeName; // name of content type, singular
OUString sTypeToken; // attachment for URL OUString sTypeToken; // attachment for URL
size_t nMemberCount; // content count size_t nMemberCount; // content count
sal_uInt16 nContentType; // content type's Id ContentTypeId nContentType; // content type's Id
sal_uInt8 nOutlineLevel; sal_uInt8 nOutlineLevel;
bool bDataValid : 1; bool bDataValid : 1;
bool bEdit: 1; // can this type be edited? bool bEdit: 1; // can this type be edited?
...@@ -164,14 +164,14 @@ class SwContentType : public SwTypeNumber ...@@ -164,14 +164,14 @@ class SwContentType : public SwTypeNumber
protected: protected:
static OUString RemoveNewline(const OUString&); static OUString RemoveNewline(const OUString&);
public: public:
SwContentType(SwWrtShell* pParent, sal_uInt16 nType, sal_uInt8 nLevel ); SwContentType(SwWrtShell* pParent, ContentTypeId nType, sal_uInt8 nLevel );
virtual ~SwContentType(); virtual ~SwContentType();
void Init(bool* pbInvalidateWindow = 0); void Init(bool* pbInvalidateWindow = 0);
void FillMemberList(bool* pbLevelChanged = NULL); void FillMemberList(bool* pbLevelChanged = NULL);
size_t GetMemberCount() const size_t GetMemberCount() const
{return nMemberCount;}; {return nMemberCount;};
sal_uInt16 GetType() const {return nContentType;} ContentTypeId GetType() const {return nContentType;}
const SwContent* GetMember(size_t nIndex); const SwContent* GetMember(size_t nIndex);
const OUString& GetName() {return sContentTypeName;} const OUString& GetName() {return sContentTypeName;}
const OUString& GetSingleName() const {return sSingleContentTypeName;} const OUString& GetSingleName() const {return sSingleContentTypeName;}
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "swcont.hxx" #include "swcont.hxx"
#include <map> #include <map>
#include <o3tl/enumarray.hxx>
class SwWrtShell; class SwWrtShell;
class SwContentType; class SwContentType;
...@@ -52,8 +53,8 @@ class SwContentTree ...@@ -52,8 +53,8 @@ class SwContentTree
OUString sSpace; OUString sSpace;
AutoTimer aUpdTimer; AutoTimer aUpdTimer;
SwContentType* aActiveContentArr[CONTENT_TYPE_MAX]; o3tl::enumarray<ContentTypeId,SwContentType*> aActiveContentArr;
SwContentType* aHiddenContentArr[CONTENT_TYPE_MAX]; o3tl::enumarray<ContentTypeId,SwContentType*> aHiddenContentArr;
OUString aContextStrings[CONTEXT_COUNT + 1]; OUString aContextStrings[CONTEXT_COUNT + 1];
OUString sRemoveIdx; OUString sRemoveIdx;
OUString sUpdateIdx; OUString sUpdateIdx;
...@@ -73,8 +74,8 @@ class SwContentTree ...@@ -73,8 +74,8 @@ class SwContentTree
sal_Int32 nActiveBlock; sal_Int32 nActiveBlock;
sal_Int32 nHiddenBlock; sal_Int32 nHiddenBlock;
sal_uInt16 nRootType; ContentTypeId nRootType;
sal_uInt16 nLastSelType; ContentTypeId nLastSelType;
sal_uInt8 nOutlineLevel; sal_uInt8 nOutlineLevel;
bool bIsActive :1; bool bIsActive :1;
...@@ -150,7 +151,7 @@ public: ...@@ -150,7 +151,7 @@ public:
SdrObject* GetDrawingObjectsByContent(const SwContent *pCnt); SdrObject* GetDrawingObjectsByContent(const SwContent *pCnt);
bool ToggleToRoot(); bool ToggleToRoot();
void SetRootType(sal_uInt16 nType); void SetRootType(ContentTypeId nType);
void Display( bool bActiveView ); void Display( bool bActiveView );
void Clear(); void Clear();
void SetHiddenShell(SwWrtShell* pSh); void SetHiddenShell(SwWrtShell* pSh);
......
...@@ -22,10 +22,11 @@ ...@@ -22,10 +22,11 @@
#include <unotools/configitem.hxx> #include <unotools/configitem.hxx>
enum class RegionMode; enum class RegionMode;
enum class ContentTypeId;
class SwNavigationConfig : public utl::ConfigItem class SwNavigationConfig : public utl::ConfigItem
{ {
sal_Int32 nRootType; //RootType ContentTypeId nRootType; //RootType
sal_Int32 nSelectedPos; //SelectedPosition sal_Int32 nSelectedPos; //SelectedPosition
sal_Int32 nOutlineLevel; //OutlineLevel sal_Int32 nOutlineLevel; //OutlineLevel
RegionMode nRegionMode; //InsertMode RegionMode nRegionMode; //InsertMode
...@@ -43,8 +44,8 @@ public: ...@@ -43,8 +44,8 @@ public:
virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames ) SAL_OVERRIDE; virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames ) SAL_OVERRIDE;
sal_Int32 GetRootType()const {return nRootType;} ContentTypeId GetRootType()const {return nRootType;}
void SetRootType(sal_Int32 nSet){ void SetRootType(ContentTypeId nSet){
if(nRootType != nSet) if(nRootType != nSet)
{ {
SetModified(); SetModified();
......
...@@ -26,19 +26,23 @@ ...@@ -26,19 +26,23 @@
class SwContentType; class SwContentType;
// synchronize order and number with ResIds!! // synchronize order and number with ResIds!!
#define CONTENT_TYPE_OUTLINE 0 enum class ContentTypeId
#define CONTENT_TYPE_TABLE 1 {
#define CONTENT_TYPE_FRAME 2 OUTLINE = 0,
#define CONTENT_TYPE_GRAPHIC 3 TABLE = 1,
#define CONTENT_TYPE_OLE 4 FRAME = 2,
#define CONTENT_TYPE_BOOKMARK 5 GRAPHIC = 3,
#define CONTENT_TYPE_REGION 6 OLE = 4,
#define CONTENT_TYPE_URLFIELD 7 BOOKMARK = 5,
#define CONTENT_TYPE_REFERENCE 8 REGION = 6,
#define CONTENT_TYPE_INDEX 9 URLFIELD = 7,
#define CONTENT_TYPE_POSTIT 10 REFERENCE = 8,
#define CONTENT_TYPE_DRAWOBJECT 11 INDEX = 9,
#define CONTENT_TYPE_MAX CONTENT_TYPE_DRAWOBJECT +1 POSTIT = 10,
DRAWOBJECT = 11,
LAST = DRAWOBJECT,
UNKNOWN = USHRT_MAX
};
// strings for context menus // strings for context menus
#define CONTEXT_COUNT 12 #define CONTEXT_COUNT 12
......
...@@ -3972,27 +3972,29 @@ static Any lcl_GetDisplayBitmap(const OUString& _sLinkSuffix) ...@@ -3972,27 +3972,29 @@ static Any lcl_GetDisplayBitmap(const OUString& _sLinkSuffix)
OUString sLinkSuffix = _sLinkSuffix; OUString sLinkSuffix = _sLinkSuffix;
if(!sLinkSuffix.isEmpty()) if(!sLinkSuffix.isEmpty())
sLinkSuffix = sLinkSuffix.copy(1); sLinkSuffix = sLinkSuffix.copy(1);
sal_uInt16 nImgId = USHRT_MAX; ContentTypeId nImgId;
bool bNotFound = false;
if(sLinkSuffix == "outline") if(sLinkSuffix == "outline")
nImgId = CONTENT_TYPE_OUTLINE; nImgId = ContentTypeId::OUTLINE;
else if(sLinkSuffix == "table") else if(sLinkSuffix == "table")
nImgId = CONTENT_TYPE_TABLE; nImgId = ContentTypeId::TABLE;
else if(sLinkSuffix == "frame") else if(sLinkSuffix == "frame")
nImgId = CONTENT_TYPE_FRAME; nImgId = ContentTypeId::FRAME;
else if(sLinkSuffix == "graphic") else if(sLinkSuffix == "graphic")
nImgId = CONTENT_TYPE_GRAPHIC; nImgId = ContentTypeId::GRAPHIC;
else if(sLinkSuffix == "region") else if(sLinkSuffix == "region")
nImgId = CONTENT_TYPE_REGION; nImgId = ContentTypeId::REGION;
else if(sLinkSuffix == "ole") else if(sLinkSuffix == "ole")
nImgId = CONTENT_TYPE_OLE; nImgId = ContentTypeId::OLE;
else if(sLinkSuffix.isEmpty()) else if(sLinkSuffix.isEmpty())
nImgId = CONTENT_TYPE_BOOKMARK; nImgId = ContentTypeId::BOOKMARK;
if(USHRT_MAX != nImgId) else
bNotFound = true;
if(!bNotFound)
{ {
nImgId += 20000;
ImageList aEntryImages( SW_RES(IMG_NAVI_ENTRYBMP) ); ImageList aEntryImages( SW_RES(IMG_NAVI_ENTRYBMP) );
const Image& rImage = aEntryImages.GetImage( nImgId ); const Image& rImage = aEntryImages.GetImage( (int)nImgId + 2000 );
Bitmap aBitmap( rImage.GetBitmapEx().GetBitmap() ); Bitmap aBitmap( rImage.GetBitmapEx().GetBitmap() );
Reference<awt::XBitmap> xBmp = VCLUnoHelper::CreateBitmap( aBitmap ); Reference<awt::XBitmap> xBmp = VCLUnoHelper::CreateBitmap( aBitmap );
aRet.setValue( &xBmp, cppu::UnoType<awt::XBitmap>::get()); aRet.setValue( &xBmp, cppu::UnoType<awt::XBitmap>::get());
......
...@@ -681,14 +681,14 @@ void SwGlobalTree::Display(bool bOnlyUpdateUserData) ...@@ -681,14 +681,14 @@ void SwGlobalTree::Display(bool bOnlyUpdateUserData)
{ {
const SwTOXBase* pBase = pCont->GetTOX(); const SwTOXBase* pBase = pCont->GetTOX();
sEntry = pBase->GetTitle(); sEntry = pBase->GetTitle();
aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_INDEX); aImage = aEntryImages.GetImage(SID_SW_START + (int)ContentTypeId::INDEX);
} }
break; break;
case GLBLDOC_SECTION: case GLBLDOC_SECTION:
{ {
const SwSection* pSect = pCont->GetSection(); const SwSection* pSect = pCont->GetSection();
sEntry = pSect->GetSectionName(); sEntry = pSect->GetSectionName();
aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_REGION); aImage = aEntryImages.GetImage(SID_SW_START + (int)ContentTypeId::REGION);
} }
break; break;
} }
......
...@@ -53,7 +53,7 @@ Sequence<OUString> SwNavigationConfig::GetPropertyNames() ...@@ -53,7 +53,7 @@ Sequence<OUString> SwNavigationConfig::GetPropertyNames()
SwNavigationConfig::SwNavigationConfig() : SwNavigationConfig::SwNavigationConfig() :
utl::ConfigItem("Office.Writer/Navigator"), utl::ConfigItem("Office.Writer/Navigator"),
nRootType(0xffff), nRootType(ContentTypeId::UNKNOWN),
nSelectedPos(0), nSelectedPos(0),
nOutlineLevel(MAXLEVEL), nOutlineLevel(MAXLEVEL),
nRegionMode(RegionMode::NONE), nRegionMode(RegionMode::NONE),
...@@ -73,7 +73,13 @@ SwNavigationConfig::SwNavigationConfig() : ...@@ -73,7 +73,13 @@ SwNavigationConfig::SwNavigationConfig() :
{ {
switch(nProp) switch(nProp)
{ {
case 0: pValues[nProp] >>= nRootType; break; case 0:
{
sal_uInt32 nTmp;
if (pValues[nProp] >>= nTmp)
nRootType = static_cast<ContentTypeId>(nTmp);
break;
}
case 1: pValues[nProp] >>= nSelectedPos; break; case 1: pValues[nProp] >>= nSelectedPos; break;
case 2: pValues[nProp] >>= nOutlineLevel; break; case 2: pValues[nProp] >>= nOutlineLevel; break;
case 3: case 3:
...@@ -106,7 +112,7 @@ void SwNavigationConfig::ImplCommit() ...@@ -106,7 +112,7 @@ void SwNavigationConfig::ImplCommit()
{ {
switch(nProp) switch(nProp)
{ {
case 0: pValues[nProp] <<= nRootType; break; case 0: pValues[nProp] <<= static_cast<sal_uInt32>(nRootType); break;
case 1: pValues[nProp] <<= nSelectedPos; break; case 1: pValues[nProp] <<= nSelectedPos; break;
case 2: pValues[nProp] <<= nOutlineLevel; break; case 2: pValues[nProp] <<= nOutlineLevel; break;
case 3: pValues[nProp] <<= static_cast<sal_uInt16>(nRegionMode); break; case 3: pValues[nProp] <<= static_cast<sal_uInt16>(nRegionMode); break;
......
...@@ -1294,8 +1294,8 @@ SwNavigationChild::SwNavigationChild( vcl::Window* pParent, ...@@ -1294,8 +1294,8 @@ SwNavigationChild::SwNavigationChild( vcl::Window* pParent,
SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig(); SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig();
const sal_uInt16 nRootType = static_cast< sal_uInt16 >( pNaviConfig->GetRootType() ); const ContentTypeId nRootType = pNaviConfig->GetRootType();
if( nRootType < CONTENT_TYPE_MAX ) if( nRootType <= ContentTypeId::LAST )
{ {
pNavi->aContentTree->SetRootType(nRootType); pNavi->aContentTree->SetRootType(nRootType);
pNavi->aContentToolBox->CheckItem(FN_SHOW_ROOT); pNavi->aContentToolBox->CheckItem(FN_SHOW_ROOT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment