convert SC_CELL_SHIFT_DISABLE to o3tl::typed_flags enum

Change-Id: Iae4358828edc6bad26ef5c769a8ff42fe63ade7b
Reviewed-on: https://gerrit.libreoffice.org/35556
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2017-03-22 14:36:53 +02:00
parent 88ec24a23a
commit a61c4ae9ce
7 changed files with 22 additions and 15 deletions

View File

@@ -49,6 +49,7 @@ class ScTabViewShell;
class ScConditionalFormat; class ScConditionalFormat;
class ScConditionalFormatList; class ScConditionalFormatList;
enum class CreateNameFlags; enum class CreateNameFlags;
enum class CellShiftDisabledFlags;
namespace com { namespace sun { namespace star { namespace sheet { namespace com { namespace sun { namespace star { namespace sheet {
struct DataPilotFieldReference; struct DataPilotFieldReference;
@@ -195,7 +196,7 @@ public:
virtual void SetOtherDoc( bool bSet ) = 0; virtual void SetOtherDoc( bool bSet ) = 0;
virtual bool IsTranspose() const = 0; virtual bool IsTranspose() const = 0;
virtual void SetChangeTrack( bool bSet ) = 0; virtual void SetChangeTrack( bool bSet ) = 0;
virtual void SetCellShiftDisabled( int nDisable ) = 0; virtual void SetCellShiftDisabled( CellShiftDisabledFlags nDisable ) = 0;
virtual InsCellCmd GetMoveMode() = 0; virtual InsCellCmd GetMoveMode() = 0;
}; };

View File

@@ -335,7 +335,7 @@ void AbstractScInsertContentsDlg_Impl::SetChangeTrack( bool bSet )
pDlg->SetChangeTrack( bSet ); pDlg->SetChangeTrack( bSet );
} }
void AbstractScInsertContentsDlg_Impl::SetCellShiftDisabled( int nDisable ) void AbstractScInsertContentsDlg_Impl::SetCellShiftDisabled( CellShiftDisabledFlags nDisable )
{ {
pDlg->SetCellShiftDisabled( nDisable ); pDlg->SetCellShiftDisabled( nDisable );
} }

View File

@@ -233,7 +233,7 @@ class AbstractScInsertContentsDlg_Impl : public AbstractScInsertContentsDlg
virtual void SetOtherDoc( bool bSet ) override; virtual void SetOtherDoc( bool bSet ) override;
virtual bool IsTranspose() const override; virtual bool IsTranspose() const override;
virtual void SetChangeTrack( bool bSet ) override; virtual void SetChangeTrack( bool bSet ) override;
virtual void SetCellShiftDisabled( int nDisable ) override; virtual void SetCellShiftDisabled( CellShiftDisabledFlags nDisable ) override;
virtual InsCellCmd GetMoveMode() override; virtual InsCellCmd GetMoveMode() override;
}; };

View File

@@ -46,7 +46,7 @@ public:
void SetOtherDoc( bool bSet ); void SetOtherDoc( bool bSet );
void SetFillMode( bool bSet ); void SetFillMode( bool bSet );
void SetChangeTrack( bool bSet ); void SetChangeTrack( bool bSet );
void SetCellShiftDisabled( int nDisable ); void SetCellShiftDisabled( CellShiftDisabledFlags nDisable );
private: private:
VclPtr<CheckBox> mpBtnInsAll; VclPtr<CheckBox> mpBtnInsAll;

View File

@@ -39,8 +39,14 @@ namespace o3tl {
template<> struct typed_flags<InsertContentsFlags> : is_typed_flags<InsertContentsFlags, 0x07> {}; template<> struct typed_flags<InsertContentsFlags> : is_typed_flags<InsertContentsFlags, 0x07> {};
} }
#define SC_CELL_SHIFT_DISABLE_DOWN 0x01 //from inscodlg.hxx enum class CellShiftDisabledFlags {
#define SC_CELL_SHIFT_DISABLE_RIGHT 0x02 //from inscodlg.hxx NONE = 0x00,
Down = 0x01, //from inscodlg.hxx
Right = 0x02 //from inscodlg.hxx
};
namespace o3tl {
template<> struct typed_flags<CellShiftDisabledFlags> : is_typed_flags<CellShiftDisabledFlags, 0x3> {};
}
enum class CreateNameFlags { enum class CreateNameFlags {
NONE = 0, NONE = 0,

View File

@@ -287,10 +287,10 @@ void ScInsertContentsDlg::SetChangeTrack( bool bSet )
} }
} }
void ScInsertContentsDlg::SetCellShiftDisabled( int nDisable ) void ScInsertContentsDlg::SetCellShiftDisabled( CellShiftDisabledFlags nDisable )
{ {
bool bDown = ((nDisable & SC_CELL_SHIFT_DISABLE_DOWN) != 0); bool bDown(nDisable & CellShiftDisabledFlags::Down);
bool bRight = ((nDisable & SC_CELL_SHIFT_DISABLE_RIGHT) != 0); bool bRight(nDisable & CellShiftDisabledFlags::Right);
if ( bDown != bMoveDownDisabled || bRight != bMoveRightDisabled ) if ( bDown != bMoveDownDisabled || bRight != bMoveRightDisabled )
{ {
bMoveDownDisabled = bDown; bMoveDownDisabled = bDown;

View File

@@ -1435,28 +1435,28 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
ScRange aDest( nStartX, nStartY, nStartTab, ScRange aDest( nStartX, nStartY, nStartTab,
nStartX + nRangeSizeX, nStartY + nRangeSizeY, nStartTab ); nStartX + nRangeSizeX, nStartY + nRangeSizeY, nStartTab );
if ( pOwnClip->GetDocument()->IsCutMode() && aSource.Intersects( aDest ) ) if ( pOwnClip->GetDocument()->IsCutMode() && aSource.Intersects( aDest ) )
pDlg->SetCellShiftDisabled( SC_CELL_SHIFT_DISABLE_DOWN | SC_CELL_SHIFT_DISABLE_RIGHT ); pDlg->SetCellShiftDisabled( CellShiftDisabledFlags::Down | CellShiftDisabledFlags::Right );
else else
{ {
//no conflict with intersecting ranges, //no conflict with intersecting ranges,
//check if paste plus shift will fit on sheet //check if paste plus shift will fit on sheet
//and disable shift-option if no fit //and disable shift-option if no fit
int nDisableShiftX = 0; CellShiftDisabledFlags nDisableShiftX = CellShiftDisabledFlags::NONE;
int nDisableShiftY = 0; CellShiftDisabledFlags nDisableShiftY = CellShiftDisabledFlags::NONE;
//check if horizontal shift will fit //check if horizontal shift will fit
if ( !pData->GetDocument()->IsBlockEmpty( nStartTab, if ( !pData->GetDocument()->IsBlockEmpty( nStartTab,
MAXCOL - nRangeSizeX, nStartY, MAXCOL - nRangeSizeX, nStartY,
MAXCOL, nStartY + nRangeSizeY ) ) MAXCOL, nStartY + nRangeSizeY ) )
nDisableShiftX = SC_CELL_SHIFT_DISABLE_RIGHT; nDisableShiftX = CellShiftDisabledFlags::Right;
//check if vertical shift will fit //check if vertical shift will fit
if ( !pData->GetDocument()->IsBlockEmpty( nStartTab, if ( !pData->GetDocument()->IsBlockEmpty( nStartTab,
nStartX, MAXROW - nRangeSizeY, nStartX, MAXROW - nRangeSizeY,
nStartX + nRangeSizeX, MAXROW ) ) nStartX + nRangeSizeX, MAXROW ) )
nDisableShiftY = SC_CELL_SHIFT_DISABLE_DOWN; nDisableShiftY = CellShiftDisabledFlags::Down;
if ( nDisableShiftX || nDisableShiftY ) if ( nDisableShiftX != CellShiftDisabledFlags::NONE || nDisableShiftY != CellShiftDisabledFlags::NONE)
pDlg->SetCellShiftDisabled( nDisableShiftX | nDisableShiftY ); pDlg->SetCellShiftDisabled( nDisableShiftX | nDisableShiftY );
} }
} }