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