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

convert RegionMode to scoped enum

Change-Id: I07041ce4d6571ac384390443293543368f11b7d6
Reviewed-on: https://gerrit.libreoffice.org/18535Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
Tested-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 912c9dd0
...@@ -1400,9 +1400,9 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData, ...@@ -1400,9 +1400,9 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
{ {
switch(aBkmk.GetDefaultDragType()) switch(aBkmk.GetDefaultDragType())
{ {
case REGION_MODE_NONE: nClearedAction = EXCHG_IN_ACTION_COPY; break; case RegionMode::NONE: nClearedAction = EXCHG_IN_ACTION_COPY; break;
case REGION_MODE_EMBEDDED: nClearedAction = EXCHG_IN_ACTION_MOVE; break; case RegionMode::EMBEDDED: nClearedAction = EXCHG_IN_ACTION_MOVE; break;
case REGION_MODE_LINK: nClearedAction = EXCHG_IN_ACTION_LINK; break; case RegionMode::LINK: nClearedAction = EXCHG_IN_ACTION_LINK; break;
} }
} }
rSh.NavigatorPaste( aBkmk, nClearedAction ); rSh.NavigatorPaste( aBkmk, nClearedAction );
......
...@@ -21,12 +21,14 @@ ...@@ -21,12 +21,14 @@
#include <unotools/configitem.hxx> #include <unotools/configitem.hxx>
enum class RegionMode;
class SwNavigationConfig : public utl::ConfigItem class SwNavigationConfig : public utl::ConfigItem
{ {
sal_Int32 nRootType; //RootType sal_Int32 nRootType; //RootType
sal_Int32 nSelectedPos; //SelectedPosition sal_Int32 nSelectedPos; //SelectedPosition
sal_Int32 nOutlineLevel; //OutlineLevel sal_Int32 nOutlineLevel; //OutlineLevel
sal_Int32 nRegionMode; //InsertMode RegionMode nRegionMode; //InsertMode
sal_Int32 nActiveBlock; //ActiveBlock//Expand/CollapsState sal_Int32 nActiveBlock; //ActiveBlock//Expand/CollapsState
bool bIsSmall; //ShowListBox bool bIsSmall; //ShowListBox
bool bIsGlobalActive; //GlobalDocMode// global view for GlobalDoc valid? bool bIsGlobalActive; //GlobalDocMode// global view for GlobalDoc valid?
...@@ -59,8 +61,8 @@ public: ...@@ -59,8 +61,8 @@ public:
} }
} }
sal_Int32 GetRegionMode()const {return nRegionMode;} RegionMode GetRegionMode()const {return nRegionMode;}
void SetRegionMode(sal_Int32 nSet){ void SetRegionMode(RegionMode nSet){
if(nRegionMode != nSet) if(nRegionMode != nSet)
{ {
SetModified(); SetModified();
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
class SwDocShell; class SwDocShell;
class TransferDataContainer; class TransferDataContainer;
class TransferableDataHelper; class TransferableDataHelper;
enum class RegionMode;
/* /*
navigator bookmark for distinct identification in Sw navigator bookmark for distinct identification in Sw
...@@ -35,16 +36,16 @@ class NaviContentBookmark ...@@ -35,16 +36,16 @@ class NaviContentBookmark
OUString aUrl; // URL including jump mark OUString aUrl; // URL including jump mark
OUString aDescr; // description OUString aDescr; // description
long nDocSh; // address of DocShell long nDocSh; // address of DocShell
sal_uInt16 nDefDrag; // description contains defaultDragType RegionMode nDefDrag; // description contains defaultDragType
public: public:
NaviContentBookmark(); NaviContentBookmark();
NaviContentBookmark( const OUString &rUrl, const OUString& rDesc, NaviContentBookmark( const OUString &rUrl, const OUString& rDesc,
sal_uInt16 nDragType, const SwDocShell* ); RegionMode nDragType, const SwDocShell* );
const OUString& GetURL() const { return aUrl; } const OUString& GetURL() const { return aUrl; }
const OUString& GetDescription() const { return aDescr; } const OUString& GetDescription() const { return aDescr; }
sal_uInt16 GetDefaultDragType() const { return nDefDrag; } RegionMode GetDefaultDragType() const { return nDefDrag; }
void Copy( TransferDataContainer& rData ) const; void Copy( TransferDataContainer& rData ) const;
bool Paste( TransferableDataHelper& rData ); bool Paste( TransferableDataHelper& rData );
}; };
......
...@@ -39,6 +39,7 @@ class SwNavigationConfig; ...@@ -39,6 +39,7 @@ class SwNavigationConfig;
class SfxObjectShellLock; class SfxObjectShellLock;
class SfxChildWindowContext; class SfxChildWindowContext;
class SwNavigationPI; class SwNavigationPI;
enum class RegionMode;
class SwNavHelpToolBox : public SwHelpToolBox class SwNavHelpToolBox : public SwHelpToolBox
{ {
...@@ -83,7 +84,7 @@ class SwNavigationPI : public vcl::Window, ...@@ -83,7 +84,7 @@ class SwNavigationPI : public vcl::Window,
long nDocLBIniHeight; long nDocLBIniHeight;
long nWishWidth; long nWishWidth;
sal_uInt16 nAutoMarkIdx; sal_uInt16 nAutoMarkIdx;
sal_uInt16 nRegionMode; // 0 - URL, 1 - region with link 2 - region without link RegionMode nRegionMode; // 0 - URL, 1 - region with link 2 - region without link
short nZoomIn; short nZoomIn;
short nZoomOutInit; short nZoomOutInit;
short nZoomOut; short nZoomOut;
...@@ -149,8 +150,8 @@ public: ...@@ -149,8 +150,8 @@ public:
static OUString CreateDropFileName( TransferableDataHelper& rData ); static OUString CreateDropFileName( TransferableDataHelper& rData );
static OUString CleanEntry(const OUString& rEntry); static OUString CleanEntry(const OUString& rEntry);
sal_uInt16 GetRegionDropMode() const {return nRegionMode;} RegionMode GetRegionDropMode() const {return nRegionMode;}
void SetRegionDropMode(sal_uInt16 nNewMode); void SetRegionDropMode(RegionMode nNewMode);
sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
......
...@@ -45,9 +45,12 @@ class SwContentType; ...@@ -45,9 +45,12 @@ class SwContentType;
#define GLOBAL_CONTEXT_COUNT 14 #define GLOBAL_CONTEXT_COUNT 14
// modes for Drag 'n Drop // modes for Drag 'n Drop
#define REGION_MODE_NONE 0 enum class RegionMode
#define REGION_MODE_LINK 1 {
#define REGION_MODE_EMBEDDED 2 NONE = 0,
LINK = 1,
EMBEDDED = 2
};
//mini rtti //mini rtti
class SwTypeNumber class SwTypeNumber
......
...@@ -1129,7 +1129,7 @@ PopupMenu* SwContentTree::CreateContextMenu() ...@@ -1129,7 +1129,7 @@ PopupMenu* SwContentTree::CreateContextMenu()
ST_HYPERLINK - ST_CONTEXT_FIRST + i]); ST_HYPERLINK - ST_CONTEXT_FIRST + i]);
} }
pSubPop2->CheckItem( 201 + pSubPop2->CheckItem( 201 +
GetParentWindow()->GetRegionDropMode()); static_cast<int>(GetParentWindow()->GetRegionDropMode()));
// Insert the list of the open files // Insert the list of the open files
sal_uInt16 nId = 301; sal_uInt16 nId = 301;
const SwView* pActiveView = ::GetActiveView(); const SwView* pActiveView = ::GetActiveView();
...@@ -1813,7 +1813,7 @@ bool SwContentTree::FillTransferData( TransferDataContainer& rTransfer, ...@@ -1813,7 +1813,7 @@ bool SwContentTree::FillTransferData( TransferDataContainer& rTransfer,
// no break; // no break;
case CONTENT_TYPE_OLE: case CONTENT_TYPE_OLE:
case CONTENT_TYPE_GRAPHIC: case CONTENT_TYPE_GRAPHIC:
if(GetParentWindow()->GetRegionDropMode() != REGION_MODE_NONE) if(GetParentWindow()->GetRegionDropMode() != RegionMode::NONE)
break; break;
else else
rDragMode &= ~( DND_ACTION_MOVE | DND_ACTION_LINK ); rDragMode &= ~( DND_ACTION_MOVE | DND_ACTION_LINK );
...@@ -1850,7 +1850,7 @@ bool SwContentTree::FillTransferData( TransferDataContainer& rTransfer, ...@@ -1850,7 +1850,7 @@ bool SwContentTree::FillTransferData( TransferDataContainer& rTransfer,
} }
else else
{ {
bRet = GetParentWindow()->GetRegionDropMode() == REGION_MODE_NONE; bRet = GetParentWindow()->GetRegionDropMode() == RegionMode::NONE;
rDragMode = DND_ACTION_MOVE; rDragMode = DND_ACTION_MOVE;
} }
...@@ -2911,7 +2911,7 @@ void SwContentTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ...@@ -2911,7 +2911,7 @@ void SwContentTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry
case 201: case 201:
case 202: case 202:
case 203: case 203:
GetParentWindow()->SetRegionDropMode(nSelectedPopupEntry - 201); GetParentWindow()->SetRegionDropMode(static_cast<RegionMode>(nSelectedPopupEntry - 201));
break; break;
case 401: case 401:
case 402: case 402:
...@@ -3401,13 +3401,13 @@ void SwContentTree::GotoContent(SwContent* pCnt) ...@@ -3401,13 +3401,13 @@ void SwContentTree::GotoContent(SwContent* pCnt)
NaviContentBookmark::NaviContentBookmark() NaviContentBookmark::NaviContentBookmark()
: :
nDocSh(0), nDocSh(0),
nDefDrag( REGION_MODE_NONE ) nDefDrag( RegionMode::NONE )
{ {
} }
NaviContentBookmark::NaviContentBookmark( const OUString &rUrl, NaviContentBookmark::NaviContentBookmark( const OUString &rUrl,
const OUString& rDesc, const OUString& rDesc,
sal_uInt16 nDragType, RegionMode nDragType,
const SwDocShell* pDocSh ) : const SwDocShell* pDocSh ) :
aUrl( rUrl ), aUrl( rUrl ),
aDescr(rDesc), aDescr(rDesc),
...@@ -3422,7 +3422,7 @@ void NaviContentBookmark::Copy( TransferDataContainer& rData ) const ...@@ -3422,7 +3422,7 @@ void NaviContentBookmark::Copy( TransferDataContainer& rData ) const
OString sStrBuf(OUStringToOString(aUrl, eSysCSet) + OString(NAVI_BOOKMARK_DELIM) + OString sStrBuf(OUStringToOString(aUrl, eSysCSet) + OString(NAVI_BOOKMARK_DELIM) +
OUStringToOString(aDescr, eSysCSet) + OString(NAVI_BOOKMARK_DELIM) + OUStringToOString(aDescr, eSysCSet) + OString(NAVI_BOOKMARK_DELIM) +
OString::number(nDefDrag) + OString(NAVI_BOOKMARK_DELIM) + OString::number((int)nDefDrag) + OString(NAVI_BOOKMARK_DELIM) +
OString::number(nDocSh)); OString::number(nDocSh));
rData.CopyByteString(SotClipboardFormatId::SONLK, sStrBuf); rData.CopyByteString(SotClipboardFormatId::SONLK, sStrBuf);
} }
...@@ -3436,7 +3436,7 @@ bool NaviContentBookmark::Paste( TransferableDataHelper& rData ) ...@@ -3436,7 +3436,7 @@ bool NaviContentBookmark::Paste( TransferableDataHelper& rData )
sal_Int32 nPos = 0; sal_Int32 nPos = 0;
aUrl = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ); aUrl = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos );
aDescr = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ); aDescr = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos );
nDefDrag= (sal_uInt16)sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ).toInt32(); nDefDrag= static_cast<RegionMode>( sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ).toInt32() );
nDocSh = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ).toInt32(); nDocSh = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ).toInt32();
} }
return bRet; return bRet;
......
...@@ -56,7 +56,7 @@ SwNavigationConfig::SwNavigationConfig() : ...@@ -56,7 +56,7 @@ SwNavigationConfig::SwNavigationConfig() :
nRootType(0xffff), nRootType(0xffff),
nSelectedPos(0), nSelectedPos(0),
nOutlineLevel(MAXLEVEL), nOutlineLevel(MAXLEVEL),
nRegionMode(REGION_MODE_NONE), nRegionMode(RegionMode::NONE),
nActiveBlock(0), nActiveBlock(0),
bIsSmall(false), bIsSmall(false),
bIsGlobalActive(true) bIsGlobalActive(true)
...@@ -76,7 +76,13 @@ SwNavigationConfig::SwNavigationConfig() : ...@@ -76,7 +76,13 @@ SwNavigationConfig::SwNavigationConfig() :
case 0: pValues[nProp] >>= nRootType; break; case 0: pValues[nProp] >>= 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] >>= nRegionMode; break; case 3:
{
sal_uInt16 nTmp;
if (pValues[nProp] >>= nTmp)
nRegionMode = static_cast<RegionMode>(nTmp);
break;
}
case 4: pValues[nProp] >>= nActiveBlock; break; case 4: pValues[nProp] >>= nActiveBlock; break;
case 5: bIsSmall = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; case 5: bIsSmall = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break;
case 6: bIsGlobalActive = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; case 6: bIsGlobalActive = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break;
...@@ -103,7 +109,7 @@ void SwNavigationConfig::ImplCommit() ...@@ -103,7 +109,7 @@ void SwNavigationConfig::ImplCommit()
case 0: pValues[nProp] <<= nRootType; break; case 0: pValues[nProp] <<= 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] <<= nRegionMode; break; case 3: pValues[nProp] <<= static_cast<sal_uInt16>(nRegionMode); break;
case 4: pValues[nProp] <<= nActiveBlock; break; case 4: pValues[nProp] <<= nActiveBlock; break;
case 5: pValues[nProp] <<= bIsSmall; break; case 5: pValues[nProp] <<= bIsSmall; break;
case 6: pValues[nProp] <<= bIsGlobalActive; break; case 6: pValues[nProp] <<= bIsGlobalActive; break;
......
...@@ -368,12 +368,12 @@ IMPL_LINK_TYPED( SwNavigationPI, ToolBoxDropdownClickHdl, ToolBox*, pBox, void ) ...@@ -368,12 +368,12 @@ IMPL_LINK_TYPED( SwNavigationPI, ToolBoxDropdownClickHdl, ToolBox*, pBox, void )
HID_NAVI_DRAG_COPY, HID_NAVI_DRAG_COPY,
}; };
boost::scoped_ptr<PopupMenu> pMenu(new PopupMenu); boost::scoped_ptr<PopupMenu> pMenu(new PopupMenu);
for (sal_uInt16 i = 0; i <= REGION_MODE_EMBEDDED; i++) for (sal_uInt16 i = 0; i <= static_cast<sal_uInt16>(RegionMode::EMBEDDED); i++)
{ {
pMenu->InsertItem( i + 1, aContextArr[i] ); pMenu->InsertItem( i + 1, aContextArr[i] );
pMenu->SetHelpId(i + 1, aHIDs[i]); pMenu->SetHelpId(i + 1, aHIDs[i]);
} }
pMenu->CheckItem( nRegionMode + 1 ); pMenu->CheckItem( static_cast<int>(nRegionMode) + 1 );
pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl)); pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl));
pBox->SetItemDown( nCurrItemId, true ); pBox->SetItemDown( nCurrItemId, true );
pMenu->Execute( pBox, pMenu->Execute( pBox,
...@@ -664,7 +664,7 @@ SwNavigationPI::SwNavigationPI( SfxBindings* _pBindings, ...@@ -664,7 +664,7 @@ SwNavigationPI::SwNavigationPI( SfxBindings* _pBindings,
nWishWidth(0), nWishWidth(0),
nAutoMarkIdx(1), nAutoMarkIdx(1),
nRegionMode(REGION_MODE_NONE), nRegionMode(RegionMode::NONE),
bSmallMode(false), bSmallMode(false),
bIsZoomedIn(false), bIsZoomedIn(false),
...@@ -706,7 +706,7 @@ SwNavigationPI::SwNavigationPI( SfxBindings* _pBindings, ...@@ -706,7 +706,7 @@ SwNavigationPI::SwNavigationPI( SfxBindings* _pBindings,
aContentToolBox->SetHelpId(FN_PAGENUMBER, HID_NAVI_TBX16); aContentToolBox->SetHelpId(FN_PAGENUMBER, HID_NAVI_TBX16);
aContentToolBox->ShowItem( FN_PAGENUMBER ); aContentToolBox->ShowItem( FN_PAGENUMBER );
for( sal_uInt16 i = 0; i <= REGION_MODE_EMBEDDED; i++ ) for( sal_uInt16 i = 0; i <= static_cast<sal_uInt16>(RegionMode::EMBEDDED); i++ )
{ {
aContextArr[i] = SW_RESSTR(ST_HYPERLINK + i); aContextArr[i] = SW_RESSTR(ST_HYPERLINK + i);
aStatusArr[i] = SW_RESSTR(ST_STATUS_FIRST + i); aStatusArr[i] = SW_RESSTR(ST_STATUS_FIRST + i);
...@@ -999,7 +999,7 @@ IMPL_LINK_TYPED( SwNavigationPI, MenuSelectHdl, Menu *, pMenu, bool ) ...@@ -999,7 +999,7 @@ IMPL_LINK_TYPED( SwNavigationPI, MenuSelectHdl, Menu *, pMenu, bool )
if(nMenuId != USHRT_MAX) if(nMenuId != USHRT_MAX)
{ {
if(nMenuId < 100) if(nMenuId < 100)
SetRegionDropMode( --nMenuId); SetRegionDropMode( static_cast<RegionMode>(--nMenuId));
else else
aContentTree->SetOutlineLevel( static_cast< sal_uInt8 >(nMenuId - 100) ); aContentTree->SetOutlineLevel( static_cast< sal_uInt8 >(nMenuId - 100) );
} }
...@@ -1185,15 +1185,15 @@ sal_Int8 SwNavigationPI::ExecuteDrop( const ExecuteDropEvent& rEvt ) ...@@ -1185,15 +1185,15 @@ sal_Int8 SwNavigationPI::ExecuteDrop( const ExecuteDropEvent& rEvt )
return nRet; return nRet;
} }
void SwNavigationPI::SetRegionDropMode(sal_uInt16 nNewMode) void SwNavigationPI::SetRegionDropMode(RegionMode nNewMode)
{ {
nRegionMode = nNewMode; nRegionMode = nNewMode;
pConfig->SetRegionMode( nRegionMode ); pConfig->SetRegionMode( nRegionMode );
sal_uInt16 nDropId = FN_DROP_REGION; sal_uInt16 nDropId = FN_DROP_REGION;
if(nRegionMode == REGION_MODE_LINK) if(nRegionMode == RegionMode::LINK)
nDropId = FN_DROP_REGION_LINK; nDropId = FN_DROP_REGION_LINK;
else if(nRegionMode == REGION_MODE_EMBEDDED) else if(nRegionMode == RegionMode::EMBEDDED)
nDropId = FN_DROP_REGION_COPY; nDropId = FN_DROP_REGION_COPY;
ImageList& rImgLst = aContentImageList; ImageList& rImgLst = aContentImageList;
...@@ -1301,7 +1301,7 @@ SwNavigationChild::SwNavigationChild( vcl::Window* pParent, ...@@ -1301,7 +1301,7 @@ SwNavigationChild::SwNavigationChild( vcl::Window* pParent,
pNavi->aContentToolBox->CheckItem(FN_SHOW_ROOT); pNavi->aContentToolBox->CheckItem(FN_SHOW_ROOT);
} }
pNavi->aContentTree->SetOutlineLevel( static_cast< sal_uInt8 >( pNaviConfig->GetOutlineLevel() ) ); pNavi->aContentTree->SetOutlineLevel( static_cast< sal_uInt8 >( pNaviConfig->GetOutlineLevel() ) );
pNavi->SetRegionDropMode( static_cast< sal_uInt16 >( pNaviConfig->GetRegionMode() ) ); pNavi->SetRegionDropMode( pNaviConfig->GetRegionMode() );
if(GetFloatingWindow() && pNaviConfig->IsSmall()) if(GetFloatingWindow() && pNaviConfig->IsSmall())
{ {
...@@ -1335,9 +1335,9 @@ void SwNavigationPI::InitImageList() ...@@ -1335,9 +1335,9 @@ void SwNavigationPI::InitImageList()
rImgLst.GetImage(aGlobalToolBox->GetItemId(k))); rImgLst.GetImage(aGlobalToolBox->GetItemId(k)));
sal_uInt16 nDropId = FN_DROP_REGION; sal_uInt16 nDropId = FN_DROP_REGION;
if(nRegionMode == REGION_MODE_LINK) if(nRegionMode == RegionMode::LINK)
nDropId = FN_DROP_REGION_LINK; nDropId = FN_DROP_REGION_LINK;
else if(nRegionMode == REGION_MODE_EMBEDDED) else if(nRegionMode == RegionMode::EMBEDDED)
nDropId = FN_DROP_REGION_COPY; nDropId = FN_DROP_REGION_COPY;
aContentToolBox->SetItemImage( FN_DROP_REGION, aContentToolBox->SetItemImage( FN_DROP_REGION,
rImgLst.GetImage(nDropId)); rImgLst.GetImage(nDropId));
......
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