Hi,
I've found two duplicate code with simian and moved it into two new
methods which saves 229 lines of code. It would be nice if someone could
review the patch and at least suggest better names for the methods...
Thank you,
Christina
From 1b304979a3f0f50130b5e23af8a04f343afb8d2e Mon Sep 17 00:00:00 2001
From: Christina Rossmanith <ChrRossmanith@web.de>
Date: Mon, 2 May 2011 16:44:54 +0200
Subject: [PATCH] Moved duplicate code into methods
---
svx/source/svdraw/svdoashp.cxx | 737 ++++++++++++++--------------------------
1 files changed, 255 insertions(+), 482 deletions(-)
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 5fdd50c..85f1082 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -104,6 +104,118 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::drawing;
+
+void rSegInfo_nSDat_method (EnhancedCustomShapeSegment& rSegInfo, sal_uInt16 nSDat)
+{
+ switch( nSDat >> 8 )
+ {
+ case 0x00 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::LINETO;
+ rSegInfo.Count = nSDat & 0xff;
+ if ( !rSegInfo.Count )
+ rSegInfo.Count = 1;
+ }
+ break;
+ case 0x20 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CURVETO;
+ rSegInfo.Count = nSDat & 0xff;
+ if ( !rSegInfo.Count )
+ rSegInfo.Count = 1;
+ }
+ break;
+ case 0x40 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::MOVETO;
+ rSegInfo.Count = nSDat & 0xff;
+ if ( !rSegInfo.Count )
+ rSegInfo.Count = 1;
+ }
+ break;
+ case 0x60 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
+ rSegInfo.Count = 0;
+ }
+ break;
+ case 0x80 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
+ rSegInfo.Count = 0;
+ }
+ break;
+ case 0xa1 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO;
+ rSegInfo.Count = ( nSDat & 0xff ) / 3;
+ }
+ break;
+ case 0xa2 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE;
+ rSegInfo.Count = ( nSDat & 0xff ) / 3;
+ }
+ break;
+ case 0xa3 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARCTO;
+ rSegInfo.Count = ( nSDat & 0xff ) >> 2;
+ }
+ break;
+ case 0xa4 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARC;
+ rSegInfo.Count = ( nSDat & 0xff ) >> 2;
+ }
+ break;
+ case 0xa5 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO;
+ rSegInfo.Count = ( nSDat & 0xff ) >> 2;
+ }
+ break;
+ case 0xa6 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARC;
+ rSegInfo.Count = ( nSDat & 0xff ) >> 2;
+ }
+ break;
+ case 0xa7 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX;
+ rSegInfo.Count = nSDat & 0xff;
+ }
+ break;
+ case 0xa8 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY;
+ rSegInfo.Count = nSDat & 0xff;
+ }
+ break;
+ case 0xaa :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOFILL;
+ rSegInfo.Count = 0;
+ }
+ break;
+ case 0xab :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOSTROKE;
+ rSegInfo.Count = 0;
+ }
+ break;
+ default:
+ case 0xf8 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::UNKNOWN;
+ rSegInfo.Count = nSDat;
+ }
+ break;
+ }
+ return;
+}
+
static MSO_SPT ImpGetCustomShapeType( const SdrObjCustomShape& rCustoShape )
{
MSO_SPT eRetValue = mso_sptNil;
@@ -620,6 +732,139 @@ std::vector< SdrCustomShapeInteraction >
SdrObjCustomShape::GetInteractionHandle
#define DEFAULT_MINIMUM_SIGNED_COMPARE ((sal_Int32)0x80000000)
#define DEFAULT_MAXIMUM_SIGNED_COMPARE ((sal_Int32)0x7fffffff)
+sal_Int32 GetNumberOfProperties ( const SvxMSDffHandle* pData )
+{
+ sal_Int32 nPropertiesNeeded=1; // position is always needed
+ sal_Int32 nFlags = pData->nFlags;
+
+ if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
+ nPropertiesNeeded++;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
+ nPropertiesNeeded++;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
+ nPropertiesNeeded++;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
+ {
+ nPropertiesNeeded++;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
+ {
+ if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ }
+ }
+ else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
+ {
+ if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ }
+
+ return nPropertiesNeeded;
+}
+
+void SetProperties (const SvxMSDffHandle* pData, com::sun::star::beans::PropertyValues&
rPropValues)
+{
+ sal_Int32 nFlags = pData->nFlags, n=0;
+
+ // POSITION
+ {
+ const rtl::OUString sPosition( RTL_CONSTASCII_USTRINGPARAM ( "Position" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.First,
pData->nPositionX, sal_True, sal_True );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.Second,
pData->nPositionY, sal_True, sal_False );
+ rPropValues[ n ].Name = sPosition;
+ rPropValues[ n++ ].Value <<= aPosition;
+ }
+ if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X ) {
+ const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
+ sal_Bool bMirroredX = sal_True;
+ rPropValues[ n ].Name = sMirroredX;
+ rPropValues[ n++ ].Value <<= bMirroredX;
+ }
+ if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y ) {
+ const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
+ sal_Bool bMirroredY = sal_True;
+ rPropValues[ n ].Name = sMirroredY;
+ rPropValues[ n++ ].Value <<= bMirroredY;
+ }
+ if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED ) {
+ const rtl::OUString sSwitched( RTL_CONSTASCII_USTRINGPARAM ( "Switched" ) );
+ sal_Bool bSwitched = sal_True;
+ rPropValues[ n ].Name = sSwitched;
+ rPropValues[ n++ ].Value <<= bSwitched;
+ }
+ if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR ) {
+ const rtl::OUString sPolar( RTL_CONSTASCII_USTRINGPARAM ( "Polar" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aCenter;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.First,
pData->nCenterX,
+ ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_X_IS_SPECIAL ) != 0, sal_True );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.Second,
pData->nCenterY,
+ ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_Y_IS_SPECIAL ) != 0, sal_False );
+ rPropValues[ n ].Name = sPolar;
+ rPropValues[ n++ ].Value <<= aCenter;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE ) {
+ if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) {
+ const rtl::OUString sRadiusRangeMinimum( RTL_CONSTASCII_USTRINGPARAM (
"RadiusRangeMinimum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMinimum,
pData->nRangeXMin,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True
);
+ rPropValues[ n ].Name = sRadiusRangeMinimum;
+ rPropValues[ n++ ].Value <<= aRadiusRangeMinimum;
+ }
+ if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) {
+ const rtl::OUString sRadiusRangeMaximum( RTL_CONSTASCII_USTRINGPARAM (
"RadiusRangeMaximum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMaximum,
pData->nRangeXMax,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False
);
+ rPropValues[ n ].Name = sRadiusRangeMaximum;
+ rPropValues[ n++ ].Value <<= aRadiusRangeMaximum;
+ }
+ }
+ }
+ else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE ) {
+ if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) {
+ const rtl::OUString sRangeXMinimum( RTL_CONSTASCII_USTRINGPARAM (
"RangeXMinimum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMinimum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMinimum,
pData->nRangeXMin,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True
);
+ rPropValues[ n ].Name = sRangeXMinimum;
+ rPropValues[ n++ ].Value <<= aRangeXMinimum;
+ }
+ if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) {
+ const rtl::OUString sRangeXMaximum( RTL_CONSTASCII_USTRINGPARAM (
"RangeXMaximum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMaximum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMaximum,
pData->nRangeXMax,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False
);
+ rPropValues[ n ].Name = sRangeXMaximum;
+ rPropValues[ n++ ].Value <<= aRangeXMaximum;
+ }
+ if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE ) {
+ const rtl::OUString sRangeYMinimum( RTL_CONSTASCII_USTRINGPARAM (
"RangeYMinimum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMinimum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMinimum,
pData->nRangeYMin,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL ) != 0, sal_True
);
+ rPropValues[ n ].Name = sRangeYMinimum;
+ rPropValues[ n++ ].Value <<= aRangeYMinimum;
+ }
+ if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE ) {
+ const rtl::OUString sRangeYMaximum( RTL_CONSTASCII_USTRINGPARAM (
"RangeYMaximum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMaximum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMaximum,
pData->nRangeYMax,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL ) != 0,
sal_False );
+ rPropValues[ n ].Name = sRangeYMaximum;
+ rPropValues[ n++ ].Value <<= aRangeYMaximum;
+ }
+ }
+ return;
+}
+
sdr::properties::BaseProperties* SdrObjCustomShape::CreateObjectSpecificProperties()
{
return new sdr::properties::CustomShapeProperties(*this);
@@ -787,112 +1032,7 @@ void SdrObjCustomShape::MergeDefaultAttributes( const rtl::OUString* pType )
{
EnhancedCustomShapeSegment& rSegInfo = seqSegments[ i ];
sal_uInt16 nSDat = pDefCustomShape->pElements[ i ];
- switch( nSDat >> 8 )
- {
- case 0x00 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::LINETO;
- rSegInfo.Count = nSDat & 0xff;
- if ( !rSegInfo.Count )
- rSegInfo.Count = 1;
- }
- break;
- case 0x20 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CURVETO;
- rSegInfo.Count = nSDat & 0xff;
- if ( !rSegInfo.Count )
- rSegInfo.Count = 1;
- }
- break;
- case 0x40 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::MOVETO;
- rSegInfo.Count = nSDat & 0xff;
- if ( !rSegInfo.Count )
- rSegInfo.Count = 1;
- }
- break;
- case 0x60 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
- rSegInfo.Count = 0;
- }
- break;
- case 0x80 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
- rSegInfo.Count = 0;
- }
- break;
- case 0xa1 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO;
- rSegInfo.Count = ( nSDat & 0xff ) / 3;
- }
- break;
- case 0xa2 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE;
- rSegInfo.Count = ( nSDat & 0xff ) / 3;
- }
- break;
- case 0xa3 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARCTO;
- rSegInfo.Count = ( nSDat & 0xff ) >> 2;
- }
- break;
- case 0xa4 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARC;
- rSegInfo.Count = ( nSDat & 0xff ) >> 2;
- }
- break;
- case 0xa5 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO;
- rSegInfo.Count = ( nSDat & 0xff ) >> 2;
- }
- break;
- case 0xa6 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARC;
- rSegInfo.Count = ( nSDat & 0xff ) >> 2;
- }
- break;
- case 0xa7 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX;
- rSegInfo.Count = nSDat & 0xff;
- }
- break;
- case 0xa8 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY;
- rSegInfo.Count = nSDat & 0xff;
- }
- break;
- case 0xaa :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOFILL;
- rSegInfo.Count = 0;
- }
- break;
- case 0xab :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOSTROKE;
- rSegInfo.Count = 0;
- }
- break;
- default:
- case 0xf8 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::UNKNOWN;
- rSegInfo.Count = nSDat;
- }
- break;
- }
+ rSegInfo_nSDat_method (rSegInfo, nSDat);
}
aPropVal.Name = sSegments;
aPropVal.Value <<= seqSegments;
@@ -983,147 +1123,16 @@ void SdrObjCustomShape::MergeDefaultAttributes( const rtl::OUString* pType )
{
com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles;
- sal_Int32 i, n, nCount = pDefCustomShape->nHandles;
+ sal_Int32 i, nCount = pDefCustomShape->nHandles;
const SvxMSDffHandle* pData = pDefCustomShape->pHandles;
seqHandles.realloc( nCount );
for ( i = 0; i < nCount; i++, pData++ )
{
- sal_Int32 nPropertiesNeeded = 1; // position is always needed
- sal_Int32 nFlags = pData->nFlags;
- if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
- nPropertiesNeeded++;
- if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
- nPropertiesNeeded++;
- if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
- nPropertiesNeeded++;
- if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
- {
- nPropertiesNeeded++;
- if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
- {
- if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
- nPropertiesNeeded++;
- if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
- nPropertiesNeeded++;
- }
- }
- else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
- {
- if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
- nPropertiesNeeded++;
- if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
- nPropertiesNeeded++;
- if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
- nPropertiesNeeded++;
- if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
- nPropertiesNeeded++;
- }
-
- n = 0;
+ sal_Int32 nPropertiesNeeded;
com::sun::star::beans::PropertyValues& rPropValues = seqHandles[ i ];
+ nPropertiesNeeded = GetNumberOfProperties ( pData );
rPropValues.realloc( nPropertiesNeeded );
-
- // POSITION
- {
- const rtl::OUString sPosition( RTL_CONSTASCII_USTRINGPARAM ( "Position" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.First,
pData->nPositionX, sal_True, sal_True );
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.Second,
pData->nPositionY, sal_True, sal_False );
- rPropValues[ n ].Name = sPosition;
- rPropValues[ n++ ].Value <<= aPosition;
- }
- if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
- {
- const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
- sal_Bool bMirroredX = sal_True;
- rPropValues[ n ].Name = sMirroredX;
- rPropValues[ n++ ].Value <<= bMirroredX;
- }
- if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
- {
- const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
- sal_Bool bMirroredY = sal_True;
- rPropValues[ n ].Name = sMirroredY;
- rPropValues[ n++ ].Value <<= bMirroredY;
- }
- if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
- {
- const rtl::OUString sSwitched( RTL_CONSTASCII_USTRINGPARAM ( "Switched" ) );
- sal_Bool bSwitched = sal_True;
- rPropValues[ n ].Name = sSwitched;
- rPropValues[ n++ ].Value <<= bSwitched;
- }
- if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
- {
- const rtl::OUString sPolar( RTL_CONSTASCII_USTRINGPARAM ( "Polar" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aCenter;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.First,
pData->nCenterX,
- ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_X_IS_SPECIAL ) != 0, sal_True );
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.Second,
pData->nCenterY,
- ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_Y_IS_SPECIAL ) != 0, sal_False );
- rPropValues[ n ].Name = sPolar;
- rPropValues[ n++ ].Value <<= aCenter;
- if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
- {
- if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
- {
- const rtl::OUString sRadiusRangeMinimum( RTL_CONSTASCII_USTRINGPARAM (
"RadiusRangeMinimum" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameter
aRadiusRangeMinimum;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter(
aRadiusRangeMinimum, pData->nRangeXMin,
- ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True
);
- rPropValues[ n ].Name = sRadiusRangeMinimum;
- rPropValues[ n++ ].Value <<= aRadiusRangeMinimum;
- }
- if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
- {
- const rtl::OUString sRadiusRangeMaximum( RTL_CONSTASCII_USTRINGPARAM (
"RadiusRangeMaximum" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameter
aRadiusRangeMaximum;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter(
aRadiusRangeMaximum, pData->nRangeXMax,
- ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False
);
- rPropValues[ n ].Name = sRadiusRangeMaximum;
- rPropValues[ n++ ].Value <<= aRadiusRangeMaximum;
- }
- }
- }
- else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
- {
- if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
- {
- const rtl::OUString sRangeXMinimum( RTL_CONSTASCII_USTRINGPARAM (
"RangeXMinimum" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMinimum;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMinimum,
pData->nRangeXMin,
- ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True );
- rPropValues[ n ].Name = sRangeXMinimum;
- rPropValues[ n++ ].Value <<= aRangeXMinimum;
- }
- if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
- {
- const rtl::OUString sRangeXMaximum( RTL_CONSTASCII_USTRINGPARAM (
"RangeXMaximum" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMaximum;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMaximum,
pData->nRangeXMax,
- ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
- rPropValues[ n ].Name = sRangeXMaximum;
- rPropValues[ n++ ].Value <<= aRangeXMaximum;
- }
- if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
- {
- const rtl::OUString sRangeYMinimum( RTL_CONSTASCII_USTRINGPARAM (
"RangeYMinimum" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMinimum;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMinimum,
pData->nRangeYMin,
- ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL ) != 0, sal_True );
- rPropValues[ n ].Name = sRangeYMinimum;
- rPropValues[ n++ ].Value <<= aRangeYMinimum;
- }
- if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
- {
- const rtl::OUString sRangeYMaximum( RTL_CONSTASCII_USTRINGPARAM (
"RangeYMaximum" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMaximum;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMaximum,
pData->nRangeYMax,
- ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL ) != 0, sal_False );
- rPropValues[ n ].Name = sRangeYMaximum;
- rPropValues[ n++ ].Value <<= aRangeYMaximum;
- }
- }
+ SetProperties ( pData, rPropValues );
}
aPropVal.Name = sHandles;
aPropVal.Value <<= seqHandles;
@@ -1237,112 +1246,7 @@ sal_Bool SdrObjCustomShape::IsDefaultGeometry( const DefaultType
eDefaultType )
{
EnhancedCustomShapeSegment& rSegInfo = seqSegments2[ i ];
sal_uInt16 nSDat = pDefCustomShape->pElements[ i ];
- switch( nSDat >> 8 )
- {
- case 0x00 :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::LINETO;
- rSegInfo.Count = nSDat & 0xff;
- if ( !rSegInfo.Count )
- rSegInfo.Count = 1;
- }
- break;
- case 0x20 :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::CURVETO;
- rSegInfo.Count = nSDat & 0xff;
- if ( !rSegInfo.Count )
- rSegInfo.Count = 1;
- }
- break;
- case 0x40 :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::MOVETO;
- rSegInfo.Count = nSDat & 0xff;
- if ( !rSegInfo.Count )
- rSegInfo.Count = 1;
- }
- break;
- case 0x60 :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
- rSegInfo.Count = 0;
- }
- break;
- case 0x80 :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
- rSegInfo.Count = 0;
- }
- break;
- case 0xa1 :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO;
- rSegInfo.Count = ( nSDat & 0xff ) / 3;
- }
- break;
- case 0xa2 :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE;
- rSegInfo.Count = ( nSDat & 0xff ) / 3;
- }
- break;
- case 0xa3 :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::ARCTO;
- rSegInfo.Count = ( nSDat & 0xff ) >> 2;
- }
- break;
- case 0xa4 :
- {
- rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARC;
- rSegInfo.Count = ( nSDat & 0xff ) >> 2;
- }
- break;
- case 0xa5 :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO;
- rSegInfo.Count = ( nSDat & 0xff ) >> 2;
- }
- break;
- case 0xa6 :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::CLOCKWISEARC;
- rSegInfo.Count = ( nSDat & 0xff ) >> 2;
- }
- break;
- case 0xa7 :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX;
- rSegInfo.Count = nSDat & 0xff;
- }
- break;
- case 0xa8 :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY;
- rSegInfo.Count = nSDat & 0xff;
- }
- break;
- case 0xaa :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::NOFILL;
- rSegInfo.Count = 0;
- }
- break;
- case 0xab :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::NOSTROKE;
- rSegInfo.Count = 0;
- }
- break;
- default:
- case 0xf8 :
- {
- rSegInfo.Command =
EnhancedCustomShapeSegmentCommand::UNKNOWN;
- rSegInfo.Count = nSDat;
- }
- break;
- }
+ rSegInfo_nSDat_method ( rSegInfo, nSDat );
}
if ( seqSegments1 == seqSegments2 )
bIsDefaultGeometry = sal_True;
@@ -1465,147 +1369,16 @@ sal_Bool SdrObjCustomShape::IsDefaultGeometry( const DefaultType
eDefaultType )
com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues >
seqHandles1, seqHandles2;
if ( *pAny >>= seqHandles1 )
{
- sal_Int32 i, n, nCount = pDefCustomShape->nHandles;
+ sal_Int32 i, nCount = pDefCustomShape->nHandles;
const SvxMSDffHandle* pData = pDefCustomShape->pHandles;
seqHandles2.realloc( nCount );
for ( i = 0; i < nCount; i++, pData++ )
{
- sal_Int32 nPropertiesNeeded = 1; // position is always needed
- sal_Int32 nFlags = pData->nFlags;
- if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
- nPropertiesNeeded++;
- if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
- nPropertiesNeeded++;
- if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
- nPropertiesNeeded++;
- if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
- {
- nPropertiesNeeded++;
- if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
- {
- if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
- nPropertiesNeeded++;
- if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
- nPropertiesNeeded++;
- }
- }
- else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
- {
- if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
- nPropertiesNeeded++;
- if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
- nPropertiesNeeded++;
- if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
- nPropertiesNeeded++;
- if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
- nPropertiesNeeded++;
- }
-
- n = 0;
+ sal_Int32 nPropertiesNeeded;
com::sun::star::beans::PropertyValues& rPropValues = seqHandles2[ i ];
+ nPropertiesNeeded = GetNumberOfProperties ( pData );
rPropValues.realloc( nPropertiesNeeded );
-
- // POSITION
- {
- const rtl::OUString sPosition( RTL_CONSTASCII_USTRINGPARAM (
"Position" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter(
aPosition.First, pData->nPositionX, sal_True, sal_True );
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter(
aPosition.Second, pData->nPositionY, sal_True, sal_False );
- rPropValues[ n ].Name = sPosition;
- rPropValues[ n++ ].Value <<= aPosition;
- }
- if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
- {
- const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM (
"MirroredX" ) );
- sal_Bool bMirroredX = sal_True;
- rPropValues[ n ].Name = sMirroredX;
- rPropValues[ n++ ].Value <<= bMirroredX;
- }
- if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
- {
- const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM (
"MirroredY" ) );
- sal_Bool bMirroredY = sal_True;
- rPropValues[ n ].Name = sMirroredY;
- rPropValues[ n++ ].Value <<= bMirroredY;
- }
- if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
- {
- const rtl::OUString sSwitched( RTL_CONSTASCII_USTRINGPARAM (
"Switched" ) );
- sal_Bool bSwitched = sal_True;
- rPropValues[ n ].Name = sSwitched;
- rPropValues[ n++ ].Value <<= bSwitched;
- }
- if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
- {
- const rtl::OUString sPolar( RTL_CONSTASCII_USTRINGPARAM (
"Polar" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aCenter;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter(
aCenter.First, pData->nCenterX,
- ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_X_IS_SPECIAL ) != 0, sal_True
);
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter(
aCenter.Second, pData->nCenterY,
- ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_Y_IS_SPECIAL ) != 0,
sal_False );
- rPropValues[ n ].Name = sPolar;
- rPropValues[ n++ ].Value <<= aCenter;
- if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
- {
- if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
- {
- const rtl::OUString sRadiusRangeMinimum(
RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMinimum" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameter
aRadiusRangeMinimum;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter(
aRadiusRangeMinimum, pData->nRangeXMin,
- ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) !=
0, sal_True );
- rPropValues[ n ].Name = sRadiusRangeMinimum;
- rPropValues[ n++ ].Value <<= aRadiusRangeMinimum;
- }
- if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
- {
- const rtl::OUString sRadiusRangeMaximum(
RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMaximum" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameter
aRadiusRangeMaximum;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter(
aRadiusRangeMaximum, pData->nRangeXMax,
- ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) !=
0, sal_False );
- rPropValues[ n ].Name = sRadiusRangeMaximum;
- rPropValues[ n++ ].Value <<= aRadiusRangeMaximum;
- }
- }
- }
- else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
- {
- if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
- {
- const rtl::OUString sRangeXMinimum( RTL_CONSTASCII_USTRINGPARAM
( "RangeXMinimum" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameter
aRangeXMinimum;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter(
aRangeXMinimum, pData->nRangeXMin,
- ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0,
sal_True );
- rPropValues[ n ].Name = sRangeXMinimum;
- rPropValues[ n++ ].Value <<= aRangeXMinimum;
- }
- if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
- {
- const rtl::OUString sRangeXMaximum( RTL_CONSTASCII_USTRINGPARAM
( "RangeXMaximum" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameter
aRangeXMaximum;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter(
aRangeXMaximum, pData->nRangeXMax,
- ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0,
sal_False );
- rPropValues[ n ].Name = sRangeXMaximum;
- rPropValues[ n++ ].Value <<= aRangeXMaximum;
- }
- if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
- {
- const rtl::OUString sRangeYMinimum( RTL_CONSTASCII_USTRINGPARAM
( "RangeYMinimum" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameter
aRangeYMinimum;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter(
aRangeYMinimum, pData->nRangeYMin,
- ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL ) != 0,
sal_True );
- rPropValues[ n ].Name = sRangeYMinimum;
- rPropValues[ n++ ].Value <<= aRangeYMinimum;
- }
- if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
- {
- const rtl::OUString sRangeYMaximum( RTL_CONSTASCII_USTRINGPARAM
( "RangeYMaximum" ) );
- ::com::sun::star::drawing::EnhancedCustomShapeParameter
aRangeYMaximum;
- EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter(
aRangeYMaximum, pData->nRangeYMax,
- ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL ) != 0,
sal_False );
- rPropValues[ n ].Name = sRangeYMaximum;
- rPropValues[ n++ ].Value <<= aRangeYMaximum;
- }
- }
+ SetProperties ( pData, rPropValues );
}
if ( seqHandles1 == seqHandles2 )
bIsDefaultGeometry = sal_True;
--
1.7.0.4
Context
- [Libreoffice] Moving duplicate code into methods · Chr. Rossmanith
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.