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)
aImage = Image(aBitmap);
}
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 ) );
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 ) );
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 ) );
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 ) );
// set OK/Cancel - button
......@@ -127,25 +127,25 @@ SvxHpLinkDlg::SvxHpLinkDlg (vcl::Window* pParent, SfxBindings* pBindings)
SetInputSet (mpItemSet.get());
//loop through the pages and get their max bounds and lock that down
ShowPage(HyperLinkPageType::NEWDOCUMENT);
ShowPage(HyperLinkPageType::NewDocument);
VclBox *pBox = get_content_area();
Size aMaxPrefSize(pBox->get_preferred_size());
ShowPage(HyperLinkPageType::DOCUMENT);
ShowPage(HyperLinkPageType::Document);
Size aSize(pBox->get_preferred_size());
aMaxPrefSize.Width() = std::max(aMaxPrefSize.Width(), aSize.Width());
aMaxPrefSize.Height() = std::max(aMaxPrefSize.Height(), aSize.Height());
ShowPage(HyperLinkPageType::MAIL);
ShowPage(HyperLinkPageType::Mail);
aSize = pBox->get_preferred_size();
aMaxPrefSize.Width() = std::max(aMaxPrefSize.Width(), aSize.Width());
aMaxPrefSize.Height() = std::max(aMaxPrefSize.Height(), aSize.Height());
ShowPage(HyperLinkPageType::INTERNET);
ShowPage(HyperLinkPageType::Internet);
aSize = pBox->get_preferred_size();
aMaxPrefSize.Width() = std::max(aMaxPrefSize.Width(), aSize.Width());
aMaxPrefSize.Height() = std::max(aMaxPrefSize.Height(), aSize.Height());
pBox->set_width_request(aMaxPrefSize.Width());
pBox->set_height_request(aMaxPrefSize.Height());
SetCurPageId(HyperLinkPageType::INTERNET);
SetCurPageId(HyperLinkPageType::Internet);
// Init Dialog
Start();
......@@ -301,7 +301,7 @@ IMPL_LINK_NOARG(SvxHpLinkDlg, ClickCloseHdl_Impl, Button*, void)
void SvxHpLinkDlg::SetPage ( SvxHyperlinkItem const * pItem )
{
sal_uInt16 nPageId = HyperLinkPageType::INTERNET;
HyperLinkPageType nPageId = HyperLinkPageType::Internet;
OUString aStrURL(pItem->GetURL());
INetURLObject aURL(aStrURL);
......@@ -311,17 +311,17 @@ void SvxHpLinkDlg::SetPage ( SvxHyperlinkItem const * pItem )
{
case INetProtocol::Http :
case INetProtocol::Ftp :
nPageId = HyperLinkPageType::INTERNET;
nPageId = HyperLinkPageType::Internet;
break;
case INetProtocol::File :
nPageId = HyperLinkPageType::DOCUMENT;
nPageId = HyperLinkPageType::Document;
break;
case INetProtocol::Mailto :
nPageId = HyperLinkPageType::MAIL;
nPageId = HyperLinkPageType::Mail;
break;
default :
if (aStrURL.startsWith("#"))
nPageId = HyperLinkPageType::DOCUMENT;
nPageId = HyperLinkPageType::Document;
else
{
// not valid
......@@ -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 );
Reference< XFrame > xDocumentFrame;
......
......@@ -22,6 +22,7 @@
#include <dialmgr.hxx>
#include <iconcdlg.hxx>
#include <cuihyperdlg.hxx>
#include <helpids.h>
#include <unotools/viewoptions.hxx>
......@@ -148,7 +149,7 @@ VCL_BUILDER_FACTORY_ARGS(SvtIconChoiceCtrl,
IconChoiceDialog::IconChoiceDialog ( vcl::Window* pParent, const OUString& rID,
const OUString& rUIXMLDescription )
: SfxModalDialog ( pParent, rID, rUIXMLDescription ),
mnCurrentPageId ( USHRT_MAX ),
mnCurrentPageId ( HyperLinkPageType::NONE ),
pSet ( nullptr ),
pOutSet ( nullptr ),
......@@ -255,7 +256,7 @@ void IconChoiceDialog::dispose()
\**********************************************************************/
SvxIconChoiceCtrlEntry* IconChoiceDialog::AddTabPage(
sal_uInt16 nId,
HyperLinkPageType nId,
const OUString& rIconText,
const Image& rChoiceIcon,
CreatePage pCreateFunc /* != 0 */
......@@ -264,9 +265,8 @@ SvxIconChoiceCtrlEntry* IconChoiceDialog::AddTabPage(
IconChoicePageData* pData = new IconChoicePageData ( nId, pCreateFunc );
maPageList.push_back( pData );
sal_uInt16 *pId = new sal_uInt16 ( nId );
SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->InsertEntry( rIconText, rChoiceIcon );
pEntry->SetUserData ( static_cast<void*>(pId) );
pEntry->SetUserData ( reinterpret_cast<void*>(nId) );
return pEntry;
}
......@@ -296,9 +296,9 @@ void IconChoiceDialog::HidePageImpl ( IconChoicePageData const * pData )
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;
if (bInvalidate)
{
......@@ -329,11 +329,11 @@ IMPL_LINK_NOARG(IconChoiceDialog , ChosePageHdl_Impl, SvtIconChoiceCtrl*, void)
if ( !pEntry )
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 )
}
void IconChoiceDialog::PageCreated( sal_uInt16 /*nId*/, IconChoicePage& /*rPage*/ )
void IconChoiceDialog::PageCreated( HyperLinkPageType /*nId*/, IconChoicePage& /*rPage*/ )
{
// not interested in
}
......@@ -593,7 +593,7 @@ void IconChoiceDialog::Start_Impl()
|
\**********************************************************************/
IconChoicePageData* IconChoiceDialog::GetPageData ( sal_uInt16 nId )
IconChoicePageData* IconChoiceDialog::GetPageData ( HyperLinkPageType nId )
{
IconChoicePageData *pRet = nullptr;
for (IconChoicePageData* pData : maPageList)
......@@ -656,7 +656,7 @@ void IconChoiceDialog::Ok()
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;
......@@ -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
for ( sal_Int32 i=0; i<m_pIconCtrl->GetEntryCount(); 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 );
break;
......
......@@ -33,12 +33,13 @@
#include "iconcdlg.hxx"
// hyperlink dialog
enum HyperLinkPageType
enum class HyperLinkPageType
{
INTERNET,
MAIL,
DOCUMENT,
NEWDOCUMENT
Internet,
Mail,
Document,
NewDocument,
NONE = USHRT_MAX
};
/*************************************************************************
......@@ -94,7 +95,7 @@ public:
virtual ~SvxHpLinkDlg () 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 SetReadOnlyMode( bool bReadOnly );
......
......@@ -37,6 +37,7 @@ class IconChoiceDialog;
class IconChoicePage;
class SfxItemPool;
class SfxItemSet;
enum class HyperLinkPageType;
// Create-Function
typedef VclPtr<IconChoicePage> (*CreatePage)(vcl::Window *pParent, IconChoiceDialog* pDlg, const SfxItemSet* pAttrSet);
......@@ -44,13 +45,13 @@ typedef VclPtr<IconChoicePage> (*CreatePage)(vcl::Window *pParent, IconChoiceDia
/// Data-structure for pages in dialog
struct IconChoicePageData
{
sal_uInt16 nId;
HyperLinkPageType nId;
CreatePage fnCreatePage; ///< pointer to the factory
VclPtr<IconChoicePage> pPage; ///< the TabPage itself
bool bRefresh; ///< Flag: page has to be newly initialized
// constructor
IconChoicePageData( sal_uInt16 Id, CreatePage fnPage )
IconChoicePageData( HyperLinkPageType Id, CreatePage fnPage )
: nId ( Id ),
fnCreatePage ( fnPage ),
pPage ( nullptr ),
......@@ -102,7 +103,7 @@ private:
VclPtr<SvtIconChoiceCtrl> m_pIconCtrl;
sal_uInt16 mnCurrentPageId;
HyperLinkPageType mnCurrentPageId;
// Buttons
VclPtr<OKButton> m_pOKBtn;
......@@ -123,18 +124,18 @@ private:
DECL_LINK( ResetHdl, Button*, void) ;
DECL_LINK( CancelHdl, Button*, void );
IconChoicePageData* GetPageData ( sal_uInt16 nId );
IconChoicePageData* GetPageData ( HyperLinkPageType nId );
void Start_Impl();
bool OK_Impl();
void FocusOnIcon ( sal_uInt16 nId );
void FocusOnIcon ( HyperLinkPageType nId );
protected:
static void ShowPageImpl ( IconChoicePageData const * pData );
static void HidePageImpl ( IconChoicePageData const * pData );
virtual void PageCreated( sal_uInt16 nId, IconChoicePage& rPage );
IconChoicePage* GetTabPage( sal_uInt16 nPageId )
virtual void PageCreated( HyperLinkPageType nId, IconChoicePage& rPage );
IconChoicePage* GetTabPage( HyperLinkPageType nPageId )
{ return ( GetPageData (nPageId)->pPage ? GetPageData (nPageId)->pPage.get() : nullptr); }
void ActivatePageImpl ();
......@@ -152,12 +153,12 @@ public:
// interface
SvxIconChoiceCtrlEntry* AddTabPage(
sal_uInt16 nId, const OUString& rIconText, const Image& rChoiceIcon,
HyperLinkPageType nId, const OUString& rIconText, const Image& rChoiceIcon,
CreatePage pCreateFunc /* != NULL */ );
void SetCurPageId( sal_uInt16 nId ) { mnCurrentPageId = nId; FocusOnIcon( nId ); }
sal_uInt16 GetCurPageId() const { return mnCurrentPageId; }
void ShowPage( sal_uInt16 nId );
void SetCurPageId( HyperLinkPageType nId ) { mnCurrentPageId = nId; FocusOnIcon( nId ); }
HyperLinkPageType GetCurPageId() const { return mnCurrentPageId; }
void ShowPage( HyperLinkPageType nId );
/// gives via map converted local slots if applicable
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