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
OUString sSingleContentTypeName; // name of content type, singular
OUString sTypeToken; // attachment for URL
size_t nMemberCount; // content count
sal_uInt16 nContentType; // content type's Id
ContentTypeId nContentType; // content type's Id
sal_uInt8 nOutlineLevel;
bool bDataValid : 1;
bool bEdit: 1; // can this type be edited?
......@@ -164,14 +164,14 @@ class SwContentType : public SwTypeNumber
protected:
static OUString RemoveNewline(const OUString&);
public:
SwContentType(SwWrtShell* pParent, sal_uInt16 nType, sal_uInt8 nLevel );
SwContentType(SwWrtShell* pParent, ContentTypeId nType, sal_uInt8 nLevel );
virtual ~SwContentType();
void Init(bool* pbInvalidateWindow = 0);
void FillMemberList(bool* pbLevelChanged = NULL);
size_t GetMemberCount() const
{return nMemberCount;};
sal_uInt16 GetType() const {return nContentType;}
ContentTypeId GetType() const {return nContentType;}
const SwContent* GetMember(size_t nIndex);
const OUString& GetName() {return sContentTypeName;}
const OUString& GetSingleName() const {return sSingleContentTypeName;}
......
......@@ -25,6 +25,7 @@
#include "swcont.hxx"
#include <map>
#include <o3tl/enumarray.hxx>
class SwWrtShell;
class SwContentType;
......@@ -52,8 +53,8 @@ class SwContentTree
OUString sSpace;
AutoTimer aUpdTimer;
SwContentType* aActiveContentArr[CONTENT_TYPE_MAX];
SwContentType* aHiddenContentArr[CONTENT_TYPE_MAX];
o3tl::enumarray<ContentTypeId,SwContentType*> aActiveContentArr;
o3tl::enumarray<ContentTypeId,SwContentType*> aHiddenContentArr;
OUString aContextStrings[CONTEXT_COUNT + 1];
OUString sRemoveIdx;
OUString sUpdateIdx;
......@@ -73,9 +74,9 @@ class SwContentTree
sal_Int32 nActiveBlock;
sal_Int32 nHiddenBlock;
sal_uInt16 nRootType;
sal_uInt16 nLastSelType;
sal_uInt8 nOutlineLevel;
ContentTypeId nRootType;
ContentTypeId nLastSelType;
sal_uInt8 nOutlineLevel;
bool bIsActive :1;
bool bIsConstant :1;
......@@ -150,7 +151,7 @@ public:
SdrObject* GetDrawingObjectsByContent(const SwContent *pCnt);
bool ToggleToRoot();
void SetRootType(sal_uInt16 nType);
void SetRootType(ContentTypeId nType);
void Display( bool bActiveView );
void Clear();
void SetHiddenShell(SwWrtShell* pSh);
......
......@@ -22,16 +22,17 @@
#include <unotools/configitem.hxx>
enum class RegionMode;
enum class ContentTypeId;
class SwNavigationConfig : public utl::ConfigItem
{
sal_Int32 nRootType; //RootType
sal_Int32 nSelectedPos; //SelectedPosition
sal_Int32 nOutlineLevel; //OutlineLevel
RegionMode nRegionMode; //InsertMode
sal_Int32 nActiveBlock; //ActiveBlock//Expand/CollapsState
bool bIsSmall; //ShowListBox
bool bIsGlobalActive; //GlobalDocMode// global view for GlobalDoc valid?
ContentTypeId nRootType; //RootType
sal_Int32 nSelectedPos; //SelectedPosition
sal_Int32 nOutlineLevel; //OutlineLevel
RegionMode nRegionMode; //InsertMode
sal_Int32 nActiveBlock; //ActiveBlock//Expand/CollapsState
bool bIsSmall; //ShowListBox
bool bIsGlobalActive; //GlobalDocMode// global view for GlobalDoc valid?
static com::sun::star::uno::Sequence<OUString> GetPropertyNames();
......@@ -43,8 +44,8 @@ public:
virtual void Notify( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames ) SAL_OVERRIDE;
sal_Int32 GetRootType()const {return nRootType;}
void SetRootType(sal_Int32 nSet){
ContentTypeId GetRootType()const {return nRootType;}
void SetRootType(ContentTypeId nSet){
if(nRootType != nSet)
{
SetModified();
......
......@@ -26,19 +26,23 @@
class SwContentType;
// synchronize order and number with ResIds!!
#define CONTENT_TYPE_OUTLINE 0
#define CONTENT_TYPE_TABLE 1
#define CONTENT_TYPE_FRAME 2
#define CONTENT_TYPE_GRAPHIC 3
#define CONTENT_TYPE_OLE 4
#define CONTENT_TYPE_BOOKMARK 5
#define CONTENT_TYPE_REGION 6
#define CONTENT_TYPE_URLFIELD 7
#define CONTENT_TYPE_REFERENCE 8
#define CONTENT_TYPE_INDEX 9
#define CONTENT_TYPE_POSTIT 10
#define CONTENT_TYPE_DRAWOBJECT 11
#define CONTENT_TYPE_MAX CONTENT_TYPE_DRAWOBJECT +1
enum class ContentTypeId
{
OUTLINE = 0,
TABLE = 1,
FRAME = 2,
GRAPHIC = 3,
OLE = 4,
BOOKMARK = 5,
REGION = 6,
URLFIELD = 7,
REFERENCE = 8,
INDEX = 9,
POSTIT = 10,
DRAWOBJECT = 11,
LAST = DRAWOBJECT,
UNKNOWN = USHRT_MAX
};
// strings for context menus
#define CONTEXT_COUNT 12
......
......@@ -3972,27 +3972,29 @@ static Any lcl_GetDisplayBitmap(const OUString& _sLinkSuffix)
OUString sLinkSuffix = _sLinkSuffix;
if(!sLinkSuffix.isEmpty())
sLinkSuffix = sLinkSuffix.copy(1);
sal_uInt16 nImgId = USHRT_MAX;
ContentTypeId nImgId;
bool bNotFound = false;
if(sLinkSuffix == "outline")
nImgId = CONTENT_TYPE_OUTLINE;
nImgId = ContentTypeId::OUTLINE;
else if(sLinkSuffix == "table")
nImgId = CONTENT_TYPE_TABLE;
nImgId = ContentTypeId::TABLE;
else if(sLinkSuffix == "frame")
nImgId = CONTENT_TYPE_FRAME;
nImgId = ContentTypeId::FRAME;
else if(sLinkSuffix == "graphic")
nImgId = CONTENT_TYPE_GRAPHIC;
nImgId = ContentTypeId::GRAPHIC;
else if(sLinkSuffix == "region")
nImgId = CONTENT_TYPE_REGION;
nImgId = ContentTypeId::REGION;
else if(sLinkSuffix == "ole")
nImgId = CONTENT_TYPE_OLE;
nImgId = ContentTypeId::OLE;
else if(sLinkSuffix.isEmpty())
nImgId = CONTENT_TYPE_BOOKMARK;
if(USHRT_MAX != nImgId)
nImgId = ContentTypeId::BOOKMARK;
else
bNotFound = true;
if(!bNotFound)
{
nImgId += 20000;
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() );
Reference<awt::XBitmap> xBmp = VCLUnoHelper::CreateBitmap( aBitmap );
aRet.setValue( &xBmp, cppu::UnoType<awt::XBitmap>::get());
......
......@@ -681,14 +681,14 @@ void SwGlobalTree::Display(bool bOnlyUpdateUserData)
{
const SwTOXBase* pBase = pCont->GetTOX();
sEntry = pBase->GetTitle();
aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_INDEX);
aImage = aEntryImages.GetImage(SID_SW_START + (int)ContentTypeId::INDEX);
}
break;
case GLBLDOC_SECTION:
{
const SwSection* pSect = pCont->GetSection();
sEntry = pSect->GetSectionName();
aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_REGION);
aImage = aEntryImages.GetImage(SID_SW_START + (int)ContentTypeId::REGION);
}
break;
}
......
......@@ -53,7 +53,7 @@ Sequence<OUString> SwNavigationConfig::GetPropertyNames()
SwNavigationConfig::SwNavigationConfig() :
utl::ConfigItem("Office.Writer/Navigator"),
nRootType(0xffff),
nRootType(ContentTypeId::UNKNOWN),
nSelectedPos(0),
nOutlineLevel(MAXLEVEL),
nRegionMode(RegionMode::NONE),
......@@ -73,7 +73,13 @@ SwNavigationConfig::SwNavigationConfig() :
{
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 2: pValues[nProp] >>= nOutlineLevel; break;
case 3:
......@@ -106,7 +112,7 @@ void SwNavigationConfig::ImplCommit()
{
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 2: pValues[nProp] <<= nOutlineLevel; break;
case 3: pValues[nProp] <<= static_cast<sal_uInt16>(nRegionMode); break;
......
......@@ -1294,8 +1294,8 @@ SwNavigationChild::SwNavigationChild( vcl::Window* pParent,
SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig();
const sal_uInt16 nRootType = static_cast< sal_uInt16 >( pNaviConfig->GetRootType() );
if( nRootType < CONTENT_TYPE_MAX )
const ContentTypeId nRootType = pNaviConfig->GetRootType();
if( nRootType <= ContentTypeId::LAST )
{
pNavi->aContentTree->SetRootType(nRootType);
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