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

convert HANDLE_FLAGS constants to scoped enum

Change-Id: Ie6751bc97914e4b8ac1fe00aae41c02fff2773d9
üst b49e10f9
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
#include <svx/EnhancedCustomShapeFunctionParser.hxx> #include <svx/EnhancedCustomShapeFunctionParser.hxx>
#include <tools/gen.hxx> #include <tools/gen.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <memory> #include <memory>
#include <vector> #include <vector>
...@@ -45,20 +46,28 @@ struct SvxMSDffVertPair; ...@@ -45,20 +46,28 @@ struct SvxMSDffVertPair;
struct SvxMSDffCalculationData; struct SvxMSDffCalculationData;
struct SvxMSDffTextRectangles; struct SvxMSDffTextRectangles;
#define HANDLE_FLAGS_MIRRORED_X 0x0001 enum class HandleFlags
#define HANDLE_FLAGS_MIRRORED_Y 0x0002 {
#define HANDLE_FLAGS_SWITCHED 0x0004 NONE = 0x0000,
#define HANDLE_FLAGS_POLAR 0x0008 MIRRORED_X = 0x0001,
#define HANDLE_FLAGS_RANGE_X_MINIMUM 0x0020 MIRRORED_Y = 0x0002,
#define HANDLE_FLAGS_RANGE_X_MAXIMUM 0x0040 SWITCHED = 0x0004,
#define HANDLE_FLAGS_RANGE_Y_MINIMUM 0x0080 POLAR = 0x0008,
#define HANDLE_FLAGS_RANGE_Y_MAXIMUM 0x0100 RANGE_X_MINIMUM = 0x0020,
#define HANDLE_FLAGS_RADIUS_RANGE_MINIMUM 0x0200 RANGE_X_MAXIMUM = 0x0040,
#define HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM 0x0400 RANGE_Y_MINIMUM = 0x0080,
#define HANDLE_FLAGS_REFX 0x0800 RANGE_Y_MAXIMUM = 0x0100,
#define HANDLE_FLAGS_REFY 0x1000 RADIUS_RANGE_MINIMUM = 0x0200,
#define HANDLE_FLAGS_REFANGLE 0x2000 RADIUS_RANGE_MAXIMUM = 0x0400,
#define HANDLE_FLAGS_REFR 0x4000 REFX = 0x0800,
REFY = 0x1000,
REFANGLE = 0x2000,
REFR = 0x4000,
};
namespace o3tl
{
template<> struct typed_flags<HandleFlags> : is_typed_flags<HandleFlags, 0x7fef> {};
}
// MSDFF_HANDLE_FLAGS_RANGE_Y seems to be not defined in // MSDFF_HANDLE_FLAGS_RANGE_Y seems to be not defined in
// escher, but we are using it internally in to differentiate // escher, but we are using it internally in to differentiate
...@@ -139,7 +148,7 @@ class SVX_DLLPUBLIC EnhancedCustomShape2d : public SfxItemSet ...@@ -139,7 +148,7 @@ class SVX_DLLPUBLIC EnhancedCustomShape2d : public SfxItemSet
struct SAL_DLLPRIVATE Handle struct SAL_DLLPRIVATE Handle
{ {
sal_uInt32 nFlags; HandleFlags nFlags;
bool bMirroredX; bool bMirroredX;
bool bMirroredY; bool bMirroredY;
...@@ -161,7 +170,7 @@ class SVX_DLLPUBLIC EnhancedCustomShape2d : public SfxItemSet ...@@ -161,7 +170,7 @@ class SVX_DLLPUBLIC EnhancedCustomShape2d : public SfxItemSet
com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMaximum; com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMaximum;
Handle() Handle()
: nFlags(0) : nFlags(HandleFlags::NONE)
, bMirroredX ( false ) , bMirroredX ( false )
, bMirroredY ( false ) , bMirroredY ( false )
, bSwitched( false ) , bSwitched( false )
......
...@@ -438,7 +438,7 @@ bool EnhancedCustomShape2d::ConvertSequenceToEnhancedCustomShape2dHandle( ...@@ -438,7 +438,7 @@ bool EnhancedCustomShape2d::ConvertSequenceToEnhancedCustomShape2dHandle(
sal_uInt32 i, nProperties = rHandleProperties.getLength(); sal_uInt32 i, nProperties = rHandleProperties.getLength();
if ( nProperties ) if ( nProperties )
{ {
rDestinationHandle.nFlags = 0; rDestinationHandle.nFlags = HandleFlags::NONE;
for ( i = 0; i < nProperties; i++ ) for ( i = 0; i < nProperties; i++ )
{ {
const com::sun::star::beans::PropertyValue& rPropVal = rHandleProperties[ i ]; const com::sun::star::beans::PropertyValue& rPropVal = rHandleProperties[ i ];
...@@ -454,7 +454,7 @@ bool EnhancedCustomShape2d::ConvertSequenceToEnhancedCustomShape2dHandle( ...@@ -454,7 +454,7 @@ bool EnhancedCustomShape2d::ConvertSequenceToEnhancedCustomShape2dHandle(
if ( rPropVal.Value >>= bMirroredX ) if ( rPropVal.Value >>= bMirroredX )
{ {
if ( bMirroredX ) if ( bMirroredX )
rDestinationHandle.nFlags |= HANDLE_FLAGS_MIRRORED_X; rDestinationHandle.nFlags |= HandleFlags::MIRRORED_X;
} }
} }
else if ( rPropVal.Name == "MirroredY" ) else if ( rPropVal.Name == "MirroredY" )
...@@ -463,7 +463,7 @@ bool EnhancedCustomShape2d::ConvertSequenceToEnhancedCustomShape2dHandle( ...@@ -463,7 +463,7 @@ bool EnhancedCustomShape2d::ConvertSequenceToEnhancedCustomShape2dHandle(
if ( rPropVal.Value >>= bMirroredY ) if ( rPropVal.Value >>= bMirroredY )
{ {
if ( bMirroredY ) if ( bMirroredY )
rDestinationHandle.nFlags |= HANDLE_FLAGS_MIRRORED_Y; rDestinationHandle.nFlags |= HandleFlags::MIRRORED_Y;
} }
} }
else if ( rPropVal.Name == "Switched" ) else if ( rPropVal.Name == "Switched" )
...@@ -472,63 +472,63 @@ bool EnhancedCustomShape2d::ConvertSequenceToEnhancedCustomShape2dHandle( ...@@ -472,63 +472,63 @@ bool EnhancedCustomShape2d::ConvertSequenceToEnhancedCustomShape2dHandle(
if ( rPropVal.Value >>= bSwitched ) if ( rPropVal.Value >>= bSwitched )
{ {
if ( bSwitched ) if ( bSwitched )
rDestinationHandle.nFlags |= HANDLE_FLAGS_SWITCHED; rDestinationHandle.nFlags |= HandleFlags::SWITCHED;
} }
} }
else if ( rPropVal.Name == "Polar" ) else if ( rPropVal.Name == "Polar" )
{ {
if ( rPropVal.Value >>= rDestinationHandle.aPolar ) if ( rPropVal.Value >>= rDestinationHandle.aPolar )
rDestinationHandle.nFlags |= HANDLE_FLAGS_POLAR; rDestinationHandle.nFlags |= HandleFlags::POLAR;
} }
else if ( rPropVal.Name == "RefX" ) else if ( rPropVal.Name == "RefX" )
{ {
if ( rPropVal.Value >>= rDestinationHandle.nRefX ) if ( rPropVal.Value >>= rDestinationHandle.nRefX )
rDestinationHandle.nFlags |= HANDLE_FLAGS_REFX; rDestinationHandle.nFlags |= HandleFlags::REFX;
} }
else if ( rPropVal.Name == "RefY" ) else if ( rPropVal.Name == "RefY" )
{ {
if ( rPropVal.Value >>= rDestinationHandle.nRefY ) if ( rPropVal.Value >>= rDestinationHandle.nRefY )
rDestinationHandle.nFlags |= HANDLE_FLAGS_REFY; rDestinationHandle.nFlags |= HandleFlags::REFY;
} }
else if ( rPropVal.Name == "RefAngle" ) else if ( rPropVal.Name == "RefAngle" )
{ {
if ( rPropVal.Value >>= rDestinationHandle.nRefAngle ) if ( rPropVal.Value >>= rDestinationHandle.nRefAngle )
rDestinationHandle.nFlags |= HANDLE_FLAGS_REFANGLE; rDestinationHandle.nFlags |= HandleFlags::REFANGLE;
} }
else if ( rPropVal.Name == "RefR" ) else if ( rPropVal.Name == "RefR" )
{ {
if ( rPropVal.Value >>= rDestinationHandle.nRefR ) if ( rPropVal.Value >>= rDestinationHandle.nRefR )
rDestinationHandle.nFlags |= HANDLE_FLAGS_REFR; rDestinationHandle.nFlags |= HandleFlags::REFR;
} }
else if ( rPropVal.Name == "RadiusRangeMinimum" ) else if ( rPropVal.Name == "RadiusRangeMinimum" )
{ {
if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMinimum ) if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMinimum )
rDestinationHandle.nFlags |= HANDLE_FLAGS_RADIUS_RANGE_MINIMUM; rDestinationHandle.nFlags |= HandleFlags::RADIUS_RANGE_MINIMUM;
} }
else if ( rPropVal.Name == "RadiusRangeMaximum" ) else if ( rPropVal.Name == "RadiusRangeMaximum" )
{ {
if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMaximum ) if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMaximum )
rDestinationHandle.nFlags |= HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM; rDestinationHandle.nFlags |= HandleFlags::RADIUS_RANGE_MAXIMUM;
} }
else if ( rPropVal.Name == "RangeXMinimum" ) else if ( rPropVal.Name == "RangeXMinimum" )
{ {
if ( rPropVal.Value >>= rDestinationHandle.aXRangeMinimum ) if ( rPropVal.Value >>= rDestinationHandle.aXRangeMinimum )
rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_X_MINIMUM; rDestinationHandle.nFlags |= HandleFlags::RANGE_X_MINIMUM;
} }
else if ( rPropVal.Name == "RangeXMaximum" ) else if ( rPropVal.Name == "RangeXMaximum" )
{ {
if ( rPropVal.Value >>= rDestinationHandle.aXRangeMaximum ) if ( rPropVal.Value >>= rDestinationHandle.aXRangeMaximum )
rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_X_MAXIMUM; rDestinationHandle.nFlags |= HandleFlags::RANGE_X_MAXIMUM;
} }
else if ( rPropVal.Name == "RangeYMinimum" ) else if ( rPropVal.Name == "RangeYMinimum" )
{ {
if ( rPropVal.Value >>= rDestinationHandle.aYRangeMinimum ) if ( rPropVal.Value >>= rDestinationHandle.aYRangeMinimum )
rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_Y_MINIMUM; rDestinationHandle.nFlags |= HandleFlags::RANGE_Y_MINIMUM;
} }
else if ( rPropVal.Name == "RangeYMaximum" ) else if ( rPropVal.Name == "RangeYMaximum" )
{ {
if ( rPropVal.Value >>= rDestinationHandle.aYRangeMaximum ) if ( rPropVal.Value >>= rDestinationHandle.aYRangeMaximum )
rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_Y_MAXIMUM; rDestinationHandle.nFlags |= HandleFlags::RANGE_Y_MAXIMUM;
} }
} }
} }
...@@ -1143,7 +1143,7 @@ bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Point& r ...@@ -1143,7 +1143,7 @@ bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Point& r
Handle aHandle; Handle aHandle;
if ( ConvertSequenceToEnhancedCustomShape2dHandle( seqHandles[ nIndex ], aHandle ) ) if ( ConvertSequenceToEnhancedCustomShape2dHandle( seqHandles[ nIndex ], aHandle ) )
{ {
if ( aHandle.nFlags & HANDLE_FLAGS_POLAR ) if ( aHandle.nFlags & HandleFlags::POLAR )
{ {
Point aReferencePoint( GetPoint( aHandle.aPolar, true, false ) ); Point aReferencePoint( GetPoint( aHandle.aPolar, true, false ) );
...@@ -1164,7 +1164,7 @@ bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Point& r ...@@ -1164,7 +1164,7 @@ bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Point& r
} }
else else
{ {
if ( aHandle.nFlags & HANDLE_FLAGS_SWITCHED ) if ( aHandle.nFlags & HandleFlags::SWITCHED )
{ {
if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() ) if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() )
{ {
...@@ -1235,7 +1235,7 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex ...@@ -1235,7 +1235,7 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex
fPos1 /= fXScale; fPos1 /= fXScale;
fPos2 /= fYScale; fPos2 /= fYScale;
if ( aHandle.nFlags & HANDLE_FLAGS_SWITCHED ) if ( aHandle.nFlags & HandleFlags::SWITCHED )
{ {
if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() ) if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() )
{ {
...@@ -1253,7 +1253,7 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex ...@@ -1253,7 +1253,7 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex
if ( aHandle.aPosition.Second.Type == EnhancedCustomShapeParameterType::ADJUSTMENT ) if ( aHandle.aPosition.Second.Type == EnhancedCustomShapeParameterType::ADJUSTMENT )
aHandle.aPosition.Second.Value>>= nSecondAdjustmentValue; aHandle.aPosition.Second.Value>>= nSecondAdjustmentValue;
if ( aHandle.nFlags & HANDLE_FLAGS_POLAR ) if ( aHandle.nFlags & HandleFlags::POLAR )
{ {
double fXRef, fYRef, fAngle; double fXRef, fYRef, fAngle;
GetParameter( fXRef, aHandle.aPolar.First, false, false ); GetParameter( fXRef, aHandle.aPolar.First, false, false );
...@@ -1263,14 +1263,14 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex ...@@ -1263,14 +1263,14 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex
double fX = ( fPos1 - fXRef ); double fX = ( fPos1 - fXRef );
double fY = ( fPos2 - fYRef ); double fY = ( fPos2 - fYRef );
double fRadius = sqrt( fX * fX + fY * fY ); double fRadius = sqrt( fX * fX + fY * fY );
if ( aHandle.nFlags & HANDLE_FLAGS_RADIUS_RANGE_MINIMUM ) if ( aHandle.nFlags & HandleFlags::RADIUS_RANGE_MINIMUM )
{ {
double fMin; double fMin;
GetParameter( fMin, aHandle.aRadiusRangeMinimum, false, false ); GetParameter( fMin, aHandle.aRadiusRangeMinimum, false, false );
if ( fRadius < fMin ) if ( fRadius < fMin )
fRadius = fMin; fRadius = fMin;
} }
if ( aHandle.nFlags & HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM ) if ( aHandle.nFlags & HandleFlags::RADIUS_RANGE_MAXIMUM )
{ {
double fMax; double fMax;
GetParameter( fMax, aHandle.aRadiusRangeMaximum, false, false ); GetParameter( fMax, aHandle.aRadiusRangeMaximum, false, false );
...@@ -1284,13 +1284,13 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex ...@@ -1284,13 +1284,13 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex
} }
else else
{ {
if ( aHandle.nFlags & HANDLE_FLAGS_REFX ) if ( aHandle.nFlags & HandleFlags::REFX )
{ {
nFirstAdjustmentValue = aHandle.nRefX; nFirstAdjustmentValue = aHandle.nRefX;
fPos1 *= 100000.0; fPos1 *= 100000.0;
fPos1 /= nCoordWidth; fPos1 /= nCoordWidth;
} }
if ( aHandle.nFlags & HANDLE_FLAGS_REFY ) if ( aHandle.nFlags & HandleFlags::REFY )
{ {
nSecondAdjustmentValue = aHandle.nRefY; nSecondAdjustmentValue = aHandle.nRefY;
fPos2 *= 100000.0; fPos2 *= 100000.0;
...@@ -1298,14 +1298,14 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex ...@@ -1298,14 +1298,14 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex
} }
if ( nFirstAdjustmentValue >= 0 ) if ( nFirstAdjustmentValue >= 0 )
{ {
if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_X_MINIMUM ) // check if horizontal handle needs to be within a range if ( aHandle.nFlags & HandleFlags::RANGE_X_MINIMUM ) // check if horizontal handle needs to be within a range
{ {
double fXMin; double fXMin;
GetParameter( fXMin, aHandle.aXRangeMinimum, false, false ); GetParameter( fXMin, aHandle.aXRangeMinimum, false, false );
if ( fPos1 < fXMin ) if ( fPos1 < fXMin )
fPos1 = fXMin; fPos1 = fXMin;
} }
if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_X_MAXIMUM ) // check if horizontal handle needs to be within a range if ( aHandle.nFlags & HandleFlags::RANGE_X_MAXIMUM ) // check if horizontal handle needs to be within a range
{ {
double fXMax; double fXMax;
GetParameter( fXMax, aHandle.aXRangeMaximum, false, false ); GetParameter( fXMax, aHandle.aXRangeMaximum, false, false );
...@@ -1316,14 +1316,14 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex ...@@ -1316,14 +1316,14 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex
} }
if ( nSecondAdjustmentValue >= 0 ) if ( nSecondAdjustmentValue >= 0 )
{ {
if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_Y_MINIMUM ) // check if vertical handle needs to be within a range if ( aHandle.nFlags & HandleFlags::RANGE_Y_MINIMUM ) // check if vertical handle needs to be within a range
{ {
double fYMin; double fYMin;
GetParameter( fYMin, aHandle.aYRangeMinimum, false, false ); GetParameter( fYMin, aHandle.aYRangeMinimum, false, false );
if ( fPos2 < fYMin ) if ( fPos2 < fYMin )
fPos2 = fYMin; fPos2 = fYMin;
} }
if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_Y_MAXIMUM ) // check if vertical handle needs to be within a range if ( aHandle.nFlags & HandleFlags::RANGE_Y_MAXIMUM ) // check if vertical handle needs to be within a range
{ {
double fYMax; double fYMax;
GetParameter( fYMax, aHandle.aYRangeMaximum, false, false ); GetParameter( fYMax, aHandle.aYRangeMaximum, false, false );
......
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