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

convert HyperLinkPageType to scoped enum

Change-Id: I9554cdee56c7079ed8633ffb16074c99d5ab144e
Reviewed-on: https://gerrit.libreoffice.org/46588Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 0045ee9b
...@@ -102,16 +102,16 @@ SvxHpLinkDlg::SvxHpLinkDlg (vcl::Window* pParent, SfxBindings* pBindings) ...@@ -102,16 +102,16 @@ SvxHpLinkDlg::SvxHpLinkDlg (vcl::Window* pParent, SfxBindings* pBindings)
aImage = Image(aBitmap); aImage = Image(aBitmap);
} }
aStrTitle = CuiResId( RID_SVXSTR_HYPERDLG_HLINETTP ); aStrTitle = CuiResId( RID_SVXSTR_HYPERDLG_HLINETTP );
pEntry = AddTabPage ( HyperLinkPageType::INTERNET, aStrTitle, imgVector[0], SvxHyperlinkInternetTp::Create ); pEntry = AddTabPage ( HyperLinkPageType::Internet, aStrTitle, imgVector[0], SvxHyperlinkInternetTp::Create );
pEntry->SetQuickHelpText( CuiResId( RID_SVXSTR_HYPERDLG_HLINETTP_HELP ) ); pEntry->SetQuickHelpText( CuiResId( RID_SVXSTR_HYPERDLG_HLINETTP_HELP ) );
aStrTitle = CuiResId( RID_SVXSTR_HYPERDLG_HLMAILTP ); aStrTitle = CuiResId( RID_SVXSTR_HYPERDLG_HLMAILTP );
pEntry = AddTabPage ( HyperLinkPageType::MAIL, aStrTitle, imgVector[1], SvxHyperlinkMailTp::Create ); pEntry = AddTabPage ( HyperLinkPageType::Mail, aStrTitle, imgVector[1], SvxHyperlinkMailTp::Create );
pEntry->SetQuickHelpText( CuiResId( RID_SVXSTR_HYPERDLG_HLMAILTP_HELP ) ); pEntry->SetQuickHelpText( CuiResId( RID_SVXSTR_HYPERDLG_HLMAILTP_HELP ) );
aStrTitle = CuiResId( RID_SVXSTR_HYPERDLG_HLDOCTP ); aStrTitle = CuiResId( RID_SVXSTR_HYPERDLG_HLDOCTP );
pEntry = AddTabPage ( HyperLinkPageType::DOCUMENT, aStrTitle, imgVector[2], SvxHyperlinkDocTp::Create ); pEntry = AddTabPage ( HyperLinkPageType::Document, aStrTitle, imgVector[2], SvxHyperlinkDocTp::Create );
pEntry->SetQuickHelpText( CuiResId( RID_SVXSTR_HYPERDLG_HLDOCTP_HELP ) ); pEntry->SetQuickHelpText( CuiResId( RID_SVXSTR_HYPERDLG_HLDOCTP_HELP ) );
aStrTitle = CuiResId( RID_SVXSTR_HYPERDLG_HLDOCNTP ); aStrTitle = CuiResId( RID_SVXSTR_HYPERDLG_HLDOCNTP );
pEntry = AddTabPage ( HyperLinkPageType::NEWDOCUMENT, aStrTitle, imgVector[3], SvxHyperlinkNewDocTp::Create ); pEntry = AddTabPage ( HyperLinkPageType::NewDocument, aStrTitle, imgVector[3], SvxHyperlinkNewDocTp::Create );
pEntry->SetQuickHelpText( CuiResId( RID_SVXSTR_HYPERDLG_HLDOCNTP_HELP ) ); pEntry->SetQuickHelpText( CuiResId( RID_SVXSTR_HYPERDLG_HLDOCNTP_HELP ) );
// set OK/Cancel - button // set OK/Cancel - button
...@@ -127,25 +127,25 @@ SvxHpLinkDlg::SvxHpLinkDlg (vcl::Window* pParent, SfxBindings* pBindings) ...@@ -127,25 +127,25 @@ SvxHpLinkDlg::SvxHpLinkDlg (vcl::Window* pParent, SfxBindings* pBindings)
SetInputSet (mpItemSet.get()); SetInputSet (mpItemSet.get());
//loop through the pages and get their max bounds and lock that down //loop through the pages and get their max bounds and lock that down
ShowPage(HyperLinkPageType::NEWDOCUMENT); ShowPage(HyperLinkPageType::NewDocument);
VclBox *pBox = get_content_area(); VclBox *pBox = get_content_area();
Size aMaxPrefSize(pBox->get_preferred_size()); Size aMaxPrefSize(pBox->get_preferred_size());
ShowPage(HyperLinkPageType::DOCUMENT); ShowPage(HyperLinkPageType::Document);
Size aSize(pBox->get_preferred_size()); Size aSize(pBox->get_preferred_size());
aMaxPrefSize.Width() = std::max(aMaxPrefSize.Width(), aSize.Width()); aMaxPrefSize.Width() = std::max(aMaxPrefSize.Width(), aSize.Width());
aMaxPrefSize.Height() = std::max(aMaxPrefSize.Height(), aSize.Height()); aMaxPrefSize.Height() = std::max(aMaxPrefSize.Height(), aSize.Height());
ShowPage(HyperLinkPageType::MAIL); ShowPage(HyperLinkPageType::Mail);
aSize = pBox->get_preferred_size(); aSize = pBox->get_preferred_size();
aMaxPrefSize.Width() = std::max(aMaxPrefSize.Width(), aSize.Width()); aMaxPrefSize.Width() = std::max(aMaxPrefSize.Width(), aSize.Width());
aMaxPrefSize.Height() = std::max(aMaxPrefSize.Height(), aSize.Height()); aMaxPrefSize.Height() = std::max(aMaxPrefSize.Height(), aSize.Height());
ShowPage(HyperLinkPageType::INTERNET); ShowPage(HyperLinkPageType::Internet);
aSize = pBox->get_preferred_size(); aSize = pBox->get_preferred_size();
aMaxPrefSize.Width() = std::max(aMaxPrefSize.Width(), aSize.Width()); aMaxPrefSize.Width() = std::max(aMaxPrefSize.Width(), aSize.Width());
aMaxPrefSize.Height() = std::max(aMaxPrefSize.Height(), aSize.Height()); aMaxPrefSize.Height() = std::max(aMaxPrefSize.Height(), aSize.Height());
pBox->set_width_request(aMaxPrefSize.Width()); pBox->set_width_request(aMaxPrefSize.Width());
pBox->set_height_request(aMaxPrefSize.Height()); pBox->set_height_request(aMaxPrefSize.Height());
SetCurPageId(HyperLinkPageType::INTERNET); SetCurPageId(HyperLinkPageType::Internet);
// Init Dialog // Init Dialog
Start(); Start();
...@@ -301,7 +301,7 @@ IMPL_LINK_NOARG(SvxHpLinkDlg, ClickCloseHdl_Impl, Button*, void) ...@@ -301,7 +301,7 @@ IMPL_LINK_NOARG(SvxHpLinkDlg, ClickCloseHdl_Impl, Button*, void)
void SvxHpLinkDlg::SetPage ( SvxHyperlinkItem const * pItem ) void SvxHpLinkDlg::SetPage ( SvxHyperlinkItem const * pItem )
{ {
sal_uInt16 nPageId = HyperLinkPageType::INTERNET; HyperLinkPageType nPageId = HyperLinkPageType::Internet;
OUString aStrURL(pItem->GetURL()); OUString aStrURL(pItem->GetURL());
INetURLObject aURL(aStrURL); INetURLObject aURL(aStrURL);
...@@ -311,17 +311,17 @@ void SvxHpLinkDlg::SetPage ( SvxHyperlinkItem const * pItem ) ...@@ -311,17 +311,17 @@ void SvxHpLinkDlg::SetPage ( SvxHyperlinkItem const * pItem )
{ {
case INetProtocol::Http : case INetProtocol::Http :
case INetProtocol::Ftp : case INetProtocol::Ftp :
nPageId = HyperLinkPageType::INTERNET; nPageId = HyperLinkPageType::Internet;
break; break;
case INetProtocol::File : case INetProtocol::File :
nPageId = HyperLinkPageType::DOCUMENT; nPageId = HyperLinkPageType::Document;
break; break;
case INetProtocol::Mailto : case INetProtocol::Mailto :
nPageId = HyperLinkPageType::MAIL; nPageId = HyperLinkPageType::Mail;
break; break;
default : default :
if (aStrURL.startsWith("#")) if (aStrURL.startsWith("#"))
nPageId = HyperLinkPageType::DOCUMENT; nPageId = HyperLinkPageType::Document;
else else
{ {
// not valid // not valid
...@@ -371,7 +371,7 @@ void SvxHpLinkDlg::SetReadOnlyMode( bool bRdOnly ) ...@@ -371,7 +371,7 @@ void SvxHpLinkDlg::SetReadOnlyMode( bool bRdOnly )
|* |*
|************************************************************************/ |************************************************************************/
void SvxHpLinkDlg::PageCreated( sal_uInt16 /*nId*/, IconChoicePage& rPage ) void SvxHpLinkDlg::PageCreated( HyperLinkPageType /*nId*/, IconChoicePage& rPage )
{ {
SvxHyperlinkTabPageBase& rHyperlinkPage = dynamic_cast< SvxHyperlinkTabPageBase& >( rPage ); SvxHyperlinkTabPageBase& rHyperlinkPage = dynamic_cast< SvxHyperlinkTabPageBase& >( rPage );
Reference< XFrame > xDocumentFrame; Reference< XFrame > xDocumentFrame;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <dialmgr.hxx> #include <dialmgr.hxx>
#include <iconcdlg.hxx> #include <iconcdlg.hxx>
#include <cuihyperdlg.hxx>
#include <helpids.h> #include <helpids.h>
#include <unotools/viewoptions.hxx> #include <unotools/viewoptions.hxx>
...@@ -148,7 +149,7 @@ VCL_BUILDER_FACTORY_ARGS(SvtIconChoiceCtrl, ...@@ -148,7 +149,7 @@ VCL_BUILDER_FACTORY_ARGS(SvtIconChoiceCtrl,
IconChoiceDialog::IconChoiceDialog ( vcl::Window* pParent, const OUString& rID, IconChoiceDialog::IconChoiceDialog ( vcl::Window* pParent, const OUString& rID,
const OUString& rUIXMLDescription ) const OUString& rUIXMLDescription )
: SfxModalDialog ( pParent, rID, rUIXMLDescription ), : SfxModalDialog ( pParent, rID, rUIXMLDescription ),
mnCurrentPageId ( USHRT_MAX ), mnCurrentPageId ( HyperLinkPageType::NONE ),
pSet ( nullptr ), pSet ( nullptr ),
pOutSet ( nullptr ), pOutSet ( nullptr ),
...@@ -255,7 +256,7 @@ void IconChoiceDialog::dispose() ...@@ -255,7 +256,7 @@ void IconChoiceDialog::dispose()
\**********************************************************************/ \**********************************************************************/
SvxIconChoiceCtrlEntry* IconChoiceDialog::AddTabPage( SvxIconChoiceCtrlEntry* IconChoiceDialog::AddTabPage(
sal_uInt16 nId, HyperLinkPageType nId,
const OUString& rIconText, const OUString& rIconText,
const Image& rChoiceIcon, const Image& rChoiceIcon,
CreatePage pCreateFunc /* != 0 */ CreatePage pCreateFunc /* != 0 */
...@@ -264,9 +265,8 @@ SvxIconChoiceCtrlEntry* IconChoiceDialog::AddTabPage( ...@@ -264,9 +265,8 @@ SvxIconChoiceCtrlEntry* IconChoiceDialog::AddTabPage(
IconChoicePageData* pData = new IconChoicePageData ( nId, pCreateFunc ); IconChoicePageData* pData = new IconChoicePageData ( nId, pCreateFunc );
maPageList.push_back( pData ); maPageList.push_back( pData );
sal_uInt16 *pId = new sal_uInt16 ( nId );
SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->InsertEntry( rIconText, rChoiceIcon ); SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->InsertEntry( rIconText, rChoiceIcon );
pEntry->SetUserData ( static_cast<void*>(pId) ); pEntry->SetUserData ( reinterpret_cast<void*>(nId) );
return pEntry; return pEntry;
} }
...@@ -296,9 +296,9 @@ void IconChoiceDialog::HidePageImpl ( IconChoicePageData const * pData ) ...@@ -296,9 +296,9 @@ void IconChoiceDialog::HidePageImpl ( IconChoicePageData const * pData )
pData->pPage->Hide(); pData->pPage->Hide();
} }
void IconChoiceDialog::ShowPage(sal_uInt16 nId) void IconChoiceDialog::ShowPage(HyperLinkPageType nId)
{ {
sal_uInt16 nOldPageId = GetCurPageId(); HyperLinkPageType nOldPageId = GetCurPageId();
bool bInvalidate = nOldPageId != nId; bool bInvalidate = nOldPageId != nId;
if (bInvalidate) if (bInvalidate)
{ {
...@@ -329,11 +329,11 @@ IMPL_LINK_NOARG(IconChoiceDialog , ChosePageHdl_Impl, SvtIconChoiceCtrl*, void) ...@@ -329,11 +329,11 @@ IMPL_LINK_NOARG(IconChoiceDialog , ChosePageHdl_Impl, SvtIconChoiceCtrl*, void)
if ( !pEntry ) if ( !pEntry )
pEntry = m_pIconCtrl->GetCursor( ); pEntry = m_pIconCtrl->GetCursor( );
sal_uInt16 *pId = static_cast<sal_uInt16*>(pEntry->GetUserData()); HyperLinkPageType nId = static_cast<HyperLinkPageType>(reinterpret_cast<sal_uIntPtr>(pEntry->GetUserData()));
if( *pId != mnCurrentPageId ) if( nId != mnCurrentPageId )
{ {
ShowPage(*pId); ShowPage(nId);
} }
} }
...@@ -536,7 +536,7 @@ void IconChoiceDialog::SetInputSet( const SfxItemSet* pInSet ) ...@@ -536,7 +536,7 @@ void IconChoiceDialog::SetInputSet( const SfxItemSet* pInSet )
} }
void IconChoiceDialog::PageCreated( sal_uInt16 /*nId*/, IconChoicePage& /*rPage*/ ) void IconChoiceDialog::PageCreated( HyperLinkPageType /*nId*/, IconChoicePage& /*rPage*/ )
{ {
// not interested in // not interested in
} }
...@@ -593,7 +593,7 @@ void IconChoiceDialog::Start_Impl() ...@@ -593,7 +593,7 @@ void IconChoiceDialog::Start_Impl()
| |
\**********************************************************************/ \**********************************************************************/
IconChoicePageData* IconChoiceDialog::GetPageData ( sal_uInt16 nId ) IconChoicePageData* IconChoiceDialog::GetPageData ( HyperLinkPageType nId )
{ {
IconChoicePageData *pRet = nullptr; IconChoicePageData *pRet = nullptr;
for (IconChoicePageData* pData : maPageList) for (IconChoicePageData* pData : maPageList)
...@@ -656,7 +656,7 @@ void IconChoiceDialog::Ok() ...@@ -656,7 +656,7 @@ void IconChoiceDialog::Ok()
for ( size_t i = 0, nCount = maPageList.size(); i < nCount; ++i ) for ( size_t i = 0, nCount = maPageList.size(); i < nCount; ++i )
{ {
IconChoicePageData* pData = GetPageData ( i ); IconChoicePageData* pData = GetPageData ( maPageList[i]->nId );
IconChoicePage* pPage = pData->pPage; IconChoicePage* pPage = pData->pPage;
...@@ -677,15 +677,15 @@ void IconChoiceDialog::Ok() ...@@ -677,15 +677,15 @@ void IconChoiceDialog::Ok()
} }
} }
void IconChoiceDialog::FocusOnIcon( sal_uInt16 nId ) void IconChoiceDialog::FocusOnIcon( HyperLinkPageType nId )
{ {
// set focus to icon for the current visible page // set focus to icon for the current visible page
for ( sal_Int32 i=0; i<m_pIconCtrl->GetEntryCount(); i++) for ( sal_Int32 i=0; i<m_pIconCtrl->GetEntryCount(); i++)
{ {
SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry ( i ); SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry ( i );
sal_uInt16* pUserData = static_cast<sal_uInt16*>(pEntry->GetUserData()); HyperLinkPageType nUserData = static_cast<HyperLinkPageType>(reinterpret_cast<sal_uIntPtr>(pEntry->GetUserData()));
if ( pUserData && *pUserData == nId ) if ( nUserData == nId )
{ {
m_pIconCtrl->SetCursor( pEntry ); m_pIconCtrl->SetCursor( pEntry );
break; break;
......
...@@ -33,12 +33,13 @@ ...@@ -33,12 +33,13 @@
#include "iconcdlg.hxx" #include "iconcdlg.hxx"
// hyperlink dialog // hyperlink dialog
enum HyperLinkPageType enum class HyperLinkPageType
{ {
INTERNET, Internet,
MAIL, Mail,
DOCUMENT, Document,
NEWDOCUMENT NewDocument,
NONE = USHRT_MAX
}; };
/************************************************************************* /*************************************************************************
...@@ -94,7 +95,7 @@ public: ...@@ -94,7 +95,7 @@ public:
virtual ~SvxHpLinkDlg () override; virtual ~SvxHpLinkDlg () override;
virtual void dispose() override; virtual void dispose() override;
virtual void PageCreated( sal_uInt16 nId, IconChoicePage& rPage ) override; virtual void PageCreated( HyperLinkPageType nId, IconChoicePage& rPage ) override;
void SetPage( SvxHyperlinkItem const * pItem ); void SetPage( SvxHyperlinkItem const * pItem );
void SetReadOnlyMode( bool bReadOnly ); void SetReadOnlyMode( bool bReadOnly );
......
...@@ -37,6 +37,7 @@ class IconChoiceDialog; ...@@ -37,6 +37,7 @@ class IconChoiceDialog;
class IconChoicePage; class IconChoicePage;
class SfxItemPool; class SfxItemPool;
class SfxItemSet; class SfxItemSet;
enum class HyperLinkPageType;
// Create-Function // Create-Function
typedef VclPtr<IconChoicePage> (*CreatePage)(vcl::Window *pParent, IconChoiceDialog* pDlg, const SfxItemSet* pAttrSet); typedef VclPtr<IconChoicePage> (*CreatePage)(vcl::Window *pParent, IconChoiceDialog* pDlg, const SfxItemSet* pAttrSet);
...@@ -44,13 +45,13 @@ typedef VclPtr<IconChoicePage> (*CreatePage)(vcl::Window *pParent, IconChoiceDia ...@@ -44,13 +45,13 @@ typedef VclPtr<IconChoicePage> (*CreatePage)(vcl::Window *pParent, IconChoiceDia
/// Data-structure for pages in dialog /// Data-structure for pages in dialog
struct IconChoicePageData struct IconChoicePageData
{ {
sal_uInt16 nId; HyperLinkPageType nId;
CreatePage fnCreatePage; ///< pointer to the factory CreatePage fnCreatePage; ///< pointer to the factory
VclPtr<IconChoicePage> pPage; ///< the TabPage itself VclPtr<IconChoicePage> pPage; ///< the TabPage itself
bool bRefresh; ///< Flag: page has to be newly initialized bool bRefresh; ///< Flag: page has to be newly initialized
// constructor // constructor
IconChoicePageData( sal_uInt16 Id, CreatePage fnPage ) IconChoicePageData( HyperLinkPageType Id, CreatePage fnPage )
: nId ( Id ), : nId ( Id ),
fnCreatePage ( fnPage ), fnCreatePage ( fnPage ),
pPage ( nullptr ), pPage ( nullptr ),
...@@ -102,7 +103,7 @@ private: ...@@ -102,7 +103,7 @@ private:
VclPtr<SvtIconChoiceCtrl> m_pIconCtrl; VclPtr<SvtIconChoiceCtrl> m_pIconCtrl;
sal_uInt16 mnCurrentPageId; HyperLinkPageType mnCurrentPageId;
// Buttons // Buttons
VclPtr<OKButton> m_pOKBtn; VclPtr<OKButton> m_pOKBtn;
...@@ -123,18 +124,18 @@ private: ...@@ -123,18 +124,18 @@ private:
DECL_LINK( ResetHdl, Button*, void) ; DECL_LINK( ResetHdl, Button*, void) ;
DECL_LINK( CancelHdl, Button*, void ); DECL_LINK( CancelHdl, Button*, void );
IconChoicePageData* GetPageData ( sal_uInt16 nId ); IconChoicePageData* GetPageData ( HyperLinkPageType nId );
void Start_Impl(); void Start_Impl();
bool OK_Impl(); bool OK_Impl();
void FocusOnIcon ( sal_uInt16 nId ); void FocusOnIcon ( HyperLinkPageType nId );
protected: protected:
static void ShowPageImpl ( IconChoicePageData const * pData ); static void ShowPageImpl ( IconChoicePageData const * pData );
static void HidePageImpl ( IconChoicePageData const * pData ); static void HidePageImpl ( IconChoicePageData const * pData );
virtual void PageCreated( sal_uInt16 nId, IconChoicePage& rPage ); virtual void PageCreated( HyperLinkPageType nId, IconChoicePage& rPage );
IconChoicePage* GetTabPage( sal_uInt16 nPageId ) IconChoicePage* GetTabPage( HyperLinkPageType nPageId )
{ return ( GetPageData (nPageId)->pPage ? GetPageData (nPageId)->pPage.get() : nullptr); } { return ( GetPageData (nPageId)->pPage ? GetPageData (nPageId)->pPage.get() : nullptr); }
void ActivatePageImpl (); void ActivatePageImpl ();
...@@ -152,12 +153,12 @@ public: ...@@ -152,12 +153,12 @@ public:
// interface // interface
SvxIconChoiceCtrlEntry* AddTabPage( SvxIconChoiceCtrlEntry* AddTabPage(
sal_uInt16 nId, const OUString& rIconText, const Image& rChoiceIcon, HyperLinkPageType nId, const OUString& rIconText, const Image& rChoiceIcon,
CreatePage pCreateFunc /* != NULL */ ); CreatePage pCreateFunc /* != NULL */ );
void SetCurPageId( sal_uInt16 nId ) { mnCurrentPageId = nId; FocusOnIcon( nId ); } void SetCurPageId( HyperLinkPageType nId ) { mnCurrentPageId = nId; FocusOnIcon( nId ); }
sal_uInt16 GetCurPageId() const { return mnCurrentPageId; } HyperLinkPageType GetCurPageId() const { return mnCurrentPageId; }
void ShowPage( sal_uInt16 nId ); void ShowPage( HyperLinkPageType nId );
/// gives via map converted local slots if applicable /// gives via map converted local slots if applicable
const sal_uInt16* GetInputRanges( const SfxItemPool& ); const sal_uInt16* GetInputRanges( const SfxItemPool& );
......
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