summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-03-22 14:24:39 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-03-23 09:39:06 +0000
commit88ec24a23a10af771879421360fe4330cbf174b0 (patch)
treed5622e99b476f3d9986f9f627f023d5410dc25a2
parent275f777e824f56881184b8c4463c3766064c2335 (diff)
convert NAME constants to CreateNameFlags o3tl::typed_flags enum
Change-Id: I6265c76067402808454184f1318feeb78a140617 Reviewed-on: https://gerrit.libreoffice.org/35555 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/inc/scabstdlg.hxx5
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.cxx4
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.hxx4
-rw-r--r--sc/source/ui/docshell/docfunc.cxx16
-rw-r--r--sc/source/ui/inc/docfunc.hxx4
-rw-r--r--sc/source/ui/inc/namecrea.hxx4
-rw-r--r--sc/source/ui/inc/scui_def.hxx16
-rw-r--r--sc/source/ui/inc/viewfunc.hxx5
-rw-r--r--sc/source/ui/miscdlgs/namecrea.cxx26
-rw-r--r--sc/source/ui/unoobj/nameuno.cxx12
-rw-r--r--sc/source/ui/view/cellsh1.cxx5
-rw-r--r--sc/source/ui/view/viewfunc.cxx18
12 files changed, 66 insertions, 53 deletions
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 728dae7c0014..3370b5d58e70 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -48,6 +48,7 @@ class ScSortWarningDlg;
class ScTabViewShell;
class ScConditionalFormat;
class ScConditionalFormatList;
+enum class CreateNameFlags;
namespace com { namespace sun { namespace star { namespace sheet {
struct DataPilotFieldReference;
@@ -263,7 +264,7 @@ class AbstractScNameCreateDlg : public VclAbstractDialog // Manage Name Dialog
protected:
virtual ~AbstractScNameCreateDlg() override = default;
public:
- virtual sal_uInt16 GetFlags() const = 0;
+ virtual CreateNameFlags GetFlags() const = 0;
};
class AbstractScNamePasteDlg : public VclAbstractDialog
@@ -466,7 +467,7 @@ public:
const OUString& rDefault) = 0;
virtual VclPtr<AbstractScNameCreateDlg> CreateScNameCreateDlg(vcl::Window * pParent,
- sal_uInt16 nFlags) = 0;
+ CreateNameFlags nFlags) = 0;
virtual VclPtr<AbstractScNamePasteDlg> CreateScNamePasteDlg ( vcl::Window * pParent, ScDocShell* pShell, bool bInsList=true ) = 0;
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 8898312ef35c..872f9a4aeed6 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -477,7 +477,7 @@ void AbstractScMoveTableDlg_Impl::EnableRenameTable(bool bFlag)
return pDlg->EnableRenameTable( bFlag);
}
-sal_uInt16 AbstractScNameCreateDlg_Impl::GetFlags() const
+CreateNameFlags AbstractScNameCreateDlg_Impl::GetFlags() const
{
return pDlg->GetFlags();
}
@@ -755,7 +755,7 @@ VclPtr<AbstractScMoveTableDlg> ScAbstractDialogFactory_Impl::CreateScMoveTableDl
return VclPtr<AbstractScMoveTableDlg_Impl>::Create( pDlg );
}
-VclPtr<AbstractScNameCreateDlg> ScAbstractDialogFactory_Impl::CreateScNameCreateDlg(vcl::Window * pParent, sal_uInt16 nFlags)
+VclPtr<AbstractScNameCreateDlg> ScAbstractDialogFactory_Impl::CreateScNameCreateDlg(vcl::Window * pParent, CreateNameFlags nFlags)
{
VclPtr<ScNameCreateDlg> pDlg = VclPtr<ScNameCreateDlg>::Create( pParent, nFlags );
return VclPtr<AbstractScNameCreateDlg_Impl>::Create( pDlg );
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 30e69a2aab1e..f7db969cbdca 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -291,7 +291,7 @@ class AbstractScMoveTableDlg_Impl : public AbstractScMoveTableDlg
class AbstractScNameCreateDlg_Impl : public AbstractScNameCreateDlg
{
DECL_ABSTDLG_BASE( AbstractScNameCreateDlg_Impl, ScNameCreateDlg)
- virtual sal_uInt16 GetFlags() const override;
+ virtual CreateNameFlags GetFlags() const override;
};
class AbstractScNamePasteDlg_Impl : public AbstractScNamePasteDlg
@@ -481,7 +481,7 @@ public:
const OUString& rDefault) override;
virtual VclPtr<AbstractScNameCreateDlg> CreateScNameCreateDlg(vcl::Window * pParent,
- sal_uInt16 nFlags) override;
+ CreateNameFlags nFlags) override;
virtual VclPtr<AbstractScNamePasteDlg> CreateScNamePasteDlg ( vcl::Window * pParent, ScDocShell* pShell, bool bInsList=true ) override;
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 3b8ed04a2790..64e3f2192c23 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5059,9 +5059,9 @@ void ScDocFunc::CreateOneName( ScRangeName& rList,
}
}
-bool ScDocFunc::CreateNames( const ScRange& rRange, sal_uInt16 nFlags, bool bApi, SCTAB aTab )
+bool ScDocFunc::CreateNames( const ScRange& rRange, CreateNameFlags nFlags, bool bApi, SCTAB aTab )
{
- if (!nFlags)
+ if (nFlags == CreateNameFlags::NONE)
return false; // war nix
ScDocShellModificator aModificator( rDocShell );
@@ -5075,10 +5075,10 @@ bool ScDocFunc::CreateNames( const ScRange& rRange, sal_uInt16 nFlags, bool bApi
OSL_ENSURE(rRange.aEnd.Tab() == nTab, "CreateNames: mehrere Tabellen geht nicht");
bool bValid = true;
- if ( nFlags & ( NAME_TOP | NAME_BOTTOM ) )
+ if ( nFlags & ( CreateNameFlags::Top | CreateNameFlags::Bottom ) )
if ( nStartRow == nEndRow )
bValid = false;
- if ( nFlags & ( NAME_LEFT | NAME_RIGHT ) )
+ if ( nFlags & ( CreateNameFlags::Left | CreateNameFlags::Right ) )
if ( nStartCol == nEndCol )
bValid = false;
@@ -5095,10 +5095,10 @@ bool ScDocFunc::CreateNames( const ScRange& rRange, sal_uInt16 nFlags, bool bApi
return false; // shouldn't happen
ScRangeName aNewRanges( *pNames );
- bool bTop = ( ( nFlags & NAME_TOP ) != 0 );
- bool bLeft = ( ( nFlags & NAME_LEFT ) != 0 );
- bool bBottom = ( ( nFlags & NAME_BOTTOM ) != 0 );
- bool bRight = ( ( nFlags & NAME_RIGHT ) != 0 );
+ bool bTop ( nFlags & CreateNameFlags::Top );
+ bool bLeft ( nFlags & CreateNameFlags::Left );
+ bool bBottom( nFlags & CreateNameFlags::Bottom );
+ bool bRight ( nFlags & CreateNameFlags::Right );
SCCOL nContX1 = nStartCol;
SCROW nContY1 = nStartRow;
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index d3ec7e935ef1..7574e26ae630 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -47,7 +47,7 @@ class ScConditionalFormat;
class ScConditionalFormatList;
class ScUndoRemoveMerge;
enum class TransliterationFlags;
-
+enum class CreateNameFlags;
namespace sc {
struct ColRowSpan;
}
@@ -202,7 +202,7 @@ public:
*/
void ModifyAllRangeNames(const std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap);
- bool CreateNames( const ScRange& rRange, sal_uInt16 nFlags, bool bApi, SCTAB nTab = -1 ); // -1 for global range names
+ bool CreateNames( const ScRange& rRange, CreateNameFlags nFlags, bool bApi, SCTAB nTab = -1 ); // -1 for global range names
bool InsertNameList( const ScAddress& rStartPos, bool bApi );
void InsertAreaLink( const OUString& rFile, const OUString& rFilter,
diff --git a/sc/source/ui/inc/namecrea.hxx b/sc/source/ui/inc/namecrea.hxx
index 87f1864c2a9a..dc9a23ba9bca 100644
--- a/sc/source/ui/inc/namecrea.hxx
+++ b/sc/source/ui/inc/namecrea.hxx
@@ -33,10 +33,10 @@ protected:
VclPtr<CheckBox> m_pBottomBox;
VclPtr<CheckBox> m_pRightBox;
public:
- ScNameCreateDlg( vcl::Window * pParent, sal_uInt16 nFlags );
+ ScNameCreateDlg( vcl::Window * pParent, CreateNameFlags nFlags );
virtual ~ScNameCreateDlg() override;
virtual void dispose() override;
- sal_uInt16 GetFlags() const;
+ CreateNameFlags GetFlags() const;
};
#endif // INCLUDED_SC_SOURCE_UI_INC_NAMECREA_HXX
diff --git a/sc/source/ui/inc/scui_def.hxx b/sc/source/ui/inc/scui_def.hxx
index 96261bd3fd3d..d2507a81eaac 100644
--- a/sc/source/ui/inc/scui_def.hxx
+++ b/sc/source/ui/inc/scui_def.hxx
@@ -20,6 +20,8 @@
#ifndef INCLUDED_SC_SOURCE_UI_INC_SCUI_DEF_HXX
#define INCLUDED_SC_SOURCE_UI_INC_SCUI_DEF_HXX
+#include <o3tl/typed_flags_set.hxx>
+
#define SCRET_COLS 0x42
#define SCRET_ROWS 0x43
@@ -40,10 +42,16 @@ namespace o3tl {
#define SC_CELL_SHIFT_DISABLE_DOWN 0x01 //from inscodlg.hxx
#define SC_CELL_SHIFT_DISABLE_RIGHT 0x02 //from inscodlg.hxx
-#define NAME_TOP 1 //from namecrea.hxx
-#define NAME_LEFT 2 //from namecrea.hxx
-#define NAME_BOTTOM 4 //from namecrea.hxx
-#define NAME_RIGHT 8 //from namecrea.hxx
+enum class CreateNameFlags {
+ NONE = 0,
+ Top = 1, //from namecrea.hxx
+ Left = 2, //from namecrea.hxx
+ Bottom = 4, //from namecrea.hxx
+ Right = 8, //from namecrea.hxx
+};
+namespace o3tl {
+ template<> struct typed_flags<CreateNameFlags> : is_typed_flags<CreateNameFlags, 0xf> {};
+}
#define BTN_PASTE_NAME 100 // from namepast.hxx
#define BTN_PASTE_LIST 101 // from namepast.hxx
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 57f9a277d369..de5ff455069f 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -48,6 +48,7 @@ class ScRangeList;
class SvxHyperlinkItem;
class ScTransferObj;
class ScTableProtection;
+enum class CreateNameFlags;
namespace editeng { class SvxBorderLine; }
@@ -151,8 +152,8 @@ public:
bool LinkBlock( const ScRange& rSource, const ScAddress& rDestPos );
- void CreateNames( sal_uInt16 nFlags );
- sal_uInt16 GetCreateNameFlags();
+ void CreateNames( CreateNameFlags nFlags );
+ CreateNameFlags GetCreateNameFlags();
void InsertNameList();
bool InsertName( const OUString& rName, const OUString& rSymbol,
const OUString& rType );
diff --git a/sc/source/ui/miscdlgs/namecrea.cxx b/sc/source/ui/miscdlgs/namecrea.cxx
index 09c821c1c75d..3535ea5d0603 100644
--- a/sc/source/ui/miscdlgs/namecrea.cxx
+++ b/sc/source/ui/miscdlgs/namecrea.cxx
@@ -22,17 +22,17 @@
#include "namecrea.hxx"
#include "scresid.hxx"
-ScNameCreateDlg::ScNameCreateDlg( vcl::Window * pParent, sal_uInt16 nFlags )
+ScNameCreateDlg::ScNameCreateDlg( vcl::Window * pParent, CreateNameFlags nFlags )
: ModalDialog(pParent, "CreateNamesDialog", "modules/scalc/ui/createnamesdialog.ui")
{
get(m_pTopBox, "top");
get(m_pLeftBox, "left");
get(m_pBottomBox, "bottom");
get(m_pRightBox, "right");
- m_pTopBox->Check ( (nFlags & NAME_TOP) != 0 );
- m_pLeftBox->Check ( (nFlags & NAME_LEFT) != 0 );
- m_pBottomBox->Check( (nFlags & NAME_BOTTOM) != 0 );
- m_pRightBox->Check ( (nFlags & NAME_RIGHT) != 0 );
+ m_pTopBox->Check ( bool(nFlags & CreateNameFlags::Top) );
+ m_pLeftBox->Check ( bool(nFlags & CreateNameFlags::Left) );
+ m_pBottomBox->Check( bool(nFlags & CreateNameFlags::Bottom) );
+ m_pRightBox->Check ( bool(nFlags & CreateNameFlags::Right) );
}
ScNameCreateDlg::~ScNameCreateDlg()
@@ -49,14 +49,18 @@ void ScNameCreateDlg::dispose()
ModalDialog::dispose();
}
-sal_uInt16 ScNameCreateDlg::GetFlags() const
+CreateNameFlags ScNameCreateDlg::GetFlags() const
{
- sal_uInt16 nResult = 0;
+ CreateNameFlags nResult = CreateNameFlags::NONE;
- nResult |= m_pTopBox->IsChecked() ? NAME_TOP: 0 ;
- nResult |= m_pLeftBox->IsChecked() ? NAME_LEFT: 0 ;
- nResult |= m_pBottomBox->IsChecked() ? NAME_BOTTOM: 0 ;
- nResult |= m_pRightBox->IsChecked() ? NAME_RIGHT: 0 ;
+ if (m_pTopBox->IsChecked())
+ nResult |= CreateNameFlags::Top;
+ if (m_pLeftBox->IsChecked())
+ nResult |= CreateNameFlags::Left;
+ if (m_pBottomBox->IsChecked())
+ nResult |= CreateNameFlags::Bottom;
+ if (m_pRightBox->IsChecked())
+ nResult |= CreateNameFlags::Right;
return nResult;
}
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index 051b879bf800..3fb3667e7f02 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -527,13 +527,13 @@ void SAL_CALL ScNamedRangesObj::addNewFromTitles( const table::CellRangeAddress&
ScRange aRange;
ScUnoConversion::FillScRange( aRange, aSource );
- sal_uInt16 nFlags = 0;
- if (bTop) nFlags |= NAME_TOP;
- if (bLeft) nFlags |= NAME_LEFT;
- if (bBottom) nFlags |= NAME_BOTTOM;
- if (bRight) nFlags |= NAME_RIGHT;
+ CreateNameFlags nFlags = CreateNameFlags::NONE;
+ if (bTop) nFlags |= CreateNameFlags::Top;
+ if (bLeft) nFlags |= CreateNameFlags::Left;
+ if (bBottom) nFlags |= CreateNameFlags::Bottom;
+ if (bRight) nFlags |= CreateNameFlags::Right;
- if (nFlags)
+ if (nFlags != CreateNameFlags::NONE)
pDocShell->GetDocFunc().CreateNames( aRange, nFlags, true, GetTab_Impl() );
}
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 6f34b75b5f4c..b718994db6ae 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1826,7 +1826,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
case FID_USE_NAME:
{
- sal_uInt16 nFlags = pTabViewShell->GetCreateNameFlags();
+ CreateNameFlags nFlags = pTabViewShell->GetCreateNameFlags();
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
@@ -1836,8 +1836,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
if( pDlg->Execute() )
{
- nFlags = pDlg->GetFlags();
- pTabViewShell->CreateNames(nFlags);
+ pTabViewShell->CreateNames(pDlg->GetFlags());
rReq.Done();
}
}
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index a577cece2781..3ab243850a20 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -2705,7 +2705,7 @@ bool ScViewFunc::InsertName( const OUString& rName, const OUString& rSymbol,
return bOk;
}
-void ScViewFunc::CreateNames( sal_uInt16 nFlags )
+void ScViewFunc::CreateNames( CreateNameFlags nFlags )
{
bool bDone = false;
ScRange aRange;
@@ -2716,9 +2716,9 @@ void ScViewFunc::CreateNames( sal_uInt16 nFlags )
ErrorMessage(STR_CREATENAME_MARKERR);
}
-sal_uInt16 ScViewFunc::GetCreateNameFlags()
+CreateNameFlags ScViewFunc::GetCreateNameFlags()
{
- sal_uInt16 nFlags = 0;
+ CreateNameFlags nFlags = CreateNameFlags::NONE;
SCCOL nStartCol, nEndCol;
SCROW nStartRow, nEndRow;
@@ -2739,7 +2739,7 @@ sal_uInt16 ScViewFunc::GetCreateNameFlags()
if (!pDoc->HasStringData( i,nStartRow,nTab ))
bOk = false;
if (bOk)
- nFlags |= NAME_TOP;
+ nFlags |= CreateNameFlags::Top;
else // Bottom only if not Top
{
bOk = true;
@@ -2747,7 +2747,7 @@ sal_uInt16 ScViewFunc::GetCreateNameFlags()
if (!pDoc->HasStringData( i,nEndRow,nTab ))
bOk = false;
if (bOk)
- nFlags |= NAME_BOTTOM;
+ nFlags |= CreateNameFlags::Bottom;
}
bOk = true;
@@ -2758,7 +2758,7 @@ sal_uInt16 ScViewFunc::GetCreateNameFlags()
if (!pDoc->HasStringData( nStartCol,j,nTab ))
bOk = false;
if (bOk)
- nFlags |= NAME_LEFT;
+ nFlags |= CreateNameFlags::Left;
else // Right only if not Left
{
bOk = true;
@@ -2766,14 +2766,14 @@ sal_uInt16 ScViewFunc::GetCreateNameFlags()
if (!pDoc->HasStringData( nEndCol,j,nTab ))
bOk = false;
if (bOk)
- nFlags |= NAME_RIGHT;
+ nFlags |= CreateNameFlags::Right;
}
}
if (nStartCol == nEndCol)
- nFlags &= ~( NAME_LEFT | NAME_RIGHT );
+ nFlags &= ~CreateNameFlags( CreateNameFlags::Left | CreateNameFlags::Right );
if (nStartRow == nEndRow)
- nFlags &= ~( NAME_TOP | NAME_BOTTOM );
+ nFlags &= ~CreateNameFlags( CreateNameFlags::Top | CreateNameFlags::Bottom );
return nFlags;
}