summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de (CIB)>2018-03-15 11:32:00 +0100
committerArmin Le Grand <Armin.Le.Grand@cib.de (CIB)>2018-03-17 23:15:49 +0100
commit86c4672f4600daf19238ef25377406f445d9453a (patch)
treef00afc0f3f77760b8aaad9801c6ee01917c48f28 /svx/source
parentd1027af3c74529827d53e8cf7b0d42a0ee47d1ba (diff)
OperationSmiley: Secured quite some places using CustomShape
Changed quite some places of SdrObjCustomShape usage to use references instead of pointers, thus forcing to more secure handling. Changed some test and change methods, even found a memory leak by doing so. Change-Id: Iba76037a3c54af50bb05e6bd63d7ad04624665a7
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/customshapes/EnhancedCustomShape2d.cxx41
-rw-r--r--svx/source/customshapes/EnhancedCustomShape3d.cxx62
-rw-r--r--svx/source/customshapes/EnhancedCustomShape3d.hxx15
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeEngine.cxx259
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeFontWork.cxx81
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeFontWork.hxx4
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeHandle.cxx31
7 files changed, 307 insertions, 186 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index 39d694b112a8..17fe098ff3fe 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -690,9 +690,9 @@ void EnhancedCustomShape2d::SetPathSize( sal_Int32 nIndex )
fYRatio = 1.0;
}
-EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) :
- SfxItemSet ( pAObj->GetMergedItemSet() ),
- pCustomShapeObj ( pAObj ),
+EnhancedCustomShape2d::EnhancedCustomShape2d(SdrObjCustomShape& rSdrObjCustomShape)
+: SfxItemSet ( rSdrObjCustomShape.GetMergedItemSet() ),
+ mrSdrObjCustomShape ( rSdrObjCustomShape ),
eSpType ( mso_sptNil ),
nCoordLeft ( 0 ),
nCoordTop ( 0 ),
@@ -702,8 +702,8 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) :
nXRef ( 0x80000000 ),
nYRef ( 0x80000000 ),
nColorData ( 0 ),
- bFilled ( pAObj->GetMergedItem( XATTR_FILLSTYLE ).GetValue() != drawing::FillStyle_NONE ),
- bStroked ( pAObj->GetMergedItem( XATTR_LINESTYLE ).GetValue() != drawing::LineStyle_NONE ),
+ bFilled ( rSdrObjCustomShape.GetMergedItem( XATTR_FILLSTYLE ).GetValue() != drawing::FillStyle_NONE ),
+ bStroked ( rSdrObjCustomShape.GetMergedItem( XATTR_LINESTYLE ).GetValue() != drawing::LineStyle_NONE ),
bFlipH ( false ),
bFlipV ( false )
{
@@ -723,14 +723,14 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) :
// 2D helper shape.
ClearItem(SDRATTR_SHADOW);
- Point aP( pCustomShapeObj->GetSnapRect().Center() );
- Size aS( pCustomShapeObj->GetLogicRect().GetSize() );
+ Point aP( mrSdrObjCustomShape.GetSnapRect().Center() );
+ Size aS( mrSdrObjCustomShape.GetLogicRect().GetSize() );
aP.AdjustX( -(aS.Width() / 2) );
aP.AdjustY( -(aS.Height() / 2) );
aLogicRect = tools::Rectangle( aP, aS );
OUString sShapeType;
- const SdrCustomShapeGeometryItem& rGeometryItem = pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ const SdrCustomShapeGeometryItem& rGeometryItem(mrSdrObjCustomShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
const Any* pAny = rGeometryItem.GetPropertyValueByName( "Type" );
if ( pAny ) {
*pAny >>= sShapeType;
@@ -746,10 +746,7 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) :
if ( pAny )
*pAny >>= bFlipV;
- if ( dynamic_cast<const SdrObjCustomShape*>( pCustomShapeObj) != nullptr ) // should always be a SdrObjCustomShape, but you don't know
- nRotateAngle = static_cast<sal_Int32>(static_cast<SdrObjCustomShape*>(pCustomShapeObj)->GetObjectRotation() * 100.0);
- else
- nRotateAngle = pCustomShapeObj->GetRotateAngle();
+ nRotateAngle = static_cast<sal_Int32>(static_cast< SdrObjCustomShape& >(mrSdrObjCustomShape).GetObjectRotation() * 100.0);
/*const sal_Int32* pDefData =*/ ApplyShapeAttributes( rGeometryItem );
SetPathSize();
@@ -1170,7 +1167,7 @@ bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Point& r
}
rReturnPosition = GetPoint( aHandle.aPosition );
}
- const GeoStat aGeoStat( static_cast<SdrObjCustomShape*>(pCustomShapeObj)->GetGeoStat() );
+ const GeoStat aGeoStat(mrSdrObjCustomShape.GetGeoStat());
if ( aGeoStat.nShearAngle )
{
double nTan = aGeoStat.nTan;
@@ -1215,7 +1212,7 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex
double a = -nRotateAngle * F_PI18000;
RotatePoint( aP, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), sin( a ), cos( a ) );
}
- const GeoStat aGeoStat( static_cast<SdrObjCustomShape*>(pCustomShapeObj)->GetGeoStat() );
+ const GeoStat aGeoStat(mrSdrObjCustomShape.GetGeoStat());
if ( aGeoStat.nShearAngle )
{
double nTan = -aGeoStat.nTan;
@@ -1372,13 +1369,12 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex
}
}
// and writing them back into the GeometryItem
- SdrCustomShapeGeometryItem aGeometryItem(
- pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
+ SdrCustomShapeGeometryItem aGeometryItem(mrSdrObjCustomShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
css::beans::PropertyValue aPropVal;
aPropVal.Name = "AdjustmentValues";
aPropVal.Value <<= seqAdjustmentValues;
aGeometryItem.SetPropertyValue( aPropVal );
- pCustomShapeObj->SetMergedItem( aGeometryItem );
+ mrSdrObjCustomShape.SetMergedItem( aGeometryItem );
bRetValue = true;
}
}
@@ -1610,7 +1606,7 @@ void EnhancedCustomShape2d::CreateSubPath(
bIsDefaultPath = true;
OUString sShpType;
- SdrCustomShapeGeometryItem& rGeometryItem = const_cast<SdrCustomShapeGeometryItem&>(pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
+ SdrCustomShapeGeometryItem& rGeometryItem = const_cast<SdrCustomShapeGeometryItem&>(mrSdrObjCustomShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
Any* pAny = rGeometryItem.GetPropertyValueByName( "Type" );
if ( pAny )
*pAny >>= sShpType;
@@ -1642,7 +1638,7 @@ void EnhancedCustomShape2d::CreateSubPath(
aPropVal.Name = "ViewBox";
aPropVal.Value <<= aViewBox;
rGeometryItem.SetPropertyValue( aPropVal );
- pCustomShapeObj->SetMergedItem( rGeometryItem );
+ mrSdrObjCustomShape.SetMergedItem( rGeometryItem );
}else{
_aCenter = GetPoint( seqCoordinates[ rSrcPt ], true, true );
GetParameter( fWidth, seqCoordinates[ rSrcPt + 1 ].First, true, false);
@@ -2257,7 +2253,7 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
if ( !vObjectList.empty() )
{
- const SfxItemSet& rCustomShapeSet(pCustomShapeObj->GetMergedItemSet());
+ const SfxItemSet& rCustomShapeSet(mrSdrObjCustomShape.GetMergedItemSet());
const sal_uInt32 nColorCount(nColorData >> 28);
sal_uInt32 nColorIndex(0);
@@ -2325,10 +2321,7 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
// to define that all helper geometites defined here (SdrObjects currently)
// will use the same FillGeometryDefinition (from the referenced SdrObjCustomShape).
// This will all same-filled objects look like filled smoothly with the same style.
- if(pCustomShapeObj)
- {
- pObj->setFillGeometryDefiningShape(pCustomShapeObj);
- }
+ pObj->setFillGeometryDefiningShape(&mrSdrObjCustomShape);
}
}
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx
index 820430b83435..60177fc9fbe8 100644
--- a/svx/source/customshapes/EnhancedCustomShape3d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx
@@ -175,8 +175,10 @@ drawing::Direction3D GetDirection3D( const SdrCustomShapeGeometryItem& rItem, co
}
-EnhancedCustomShape3d::Transformation2D::Transformation2D( const SdrObject* pCustomShape, const double *pM )
- : aCenter( pCustomShape->GetSnapRect().Center() )
+EnhancedCustomShape3d::Transformation2D::Transformation2D(
+ const SdrObjCustomShape& rSdrObjCustomShape,
+ const double *pM)
+: aCenter(rSdrObjCustomShape.GetSnapRect().Center())
, eProjectionMode( drawing::ProjectionMode_PARALLEL )
, fSkewAngle(0.0)
, fSkew(0.0)
@@ -185,7 +187,7 @@ EnhancedCustomShape3d::Transformation2D::Transformation2D( const SdrObject* pCus
, fOriginY(0.0)
, pMap( pM )
{
- const SdrCustomShapeGeometryItem& rGeometryItem = pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ const SdrCustomShapeGeometryItem& rGeometryItem(rSdrObjCustomShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
const Any* pAny = rGeometryItem.GetPropertyValueByName( "Extrusion", "ProjectionMode" );
if ( pAny )
*pAny >>= eProjectionMode;
@@ -195,8 +197,8 @@ EnhancedCustomShape3d::Transformation2D::Transformation2D( const SdrObject* pCus
else
{
GetOrigin( rGeometryItem, fOriginX, fOriginY );
- fOriginX = fOriginX * pCustomShape->GetLogicRect().GetWidth();
- fOriginY = fOriginY * pCustomShape->GetLogicRect().GetHeight();
+ fOriginX = fOriginX * rSdrObjCustomShape.GetLogicRect().GetWidth();
+ fOriginY = fOriginY * rSdrObjCustomShape.GetLogicRect().GetHeight();
drawing::Position3D aViewPointDefault( 3472, -3472, 25000 );
drawing::Position3D aViewPoint( GetPosition3D( rGeometryItem, "ViewPoint", aViewPointDefault, pMap ) );
@@ -249,11 +251,13 @@ bool EnhancedCustomShape3d::Transformation2D::IsParallel() const
return eProjectionMode == css::drawing::ProjectionMode_PARALLEL;
}
-SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, const SdrObject* pCustomShape )
+SdrObject* EnhancedCustomShape3d::Create3DObject(
+ const SdrObject* pShape2d,
+ const SdrObjCustomShape& rSdrObjCustomShape)
{
SdrObject* pRet = nullptr;
- SdrModel* pModel = pCustomShape->GetModel();
- const SdrCustomShapeGeometryItem& rGeometryItem = pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ SdrModel* pModel = rSdrObjCustomShape.GetModel();
+ const SdrCustomShapeGeometryItem& rGeometryItem = rSdrObjCustomShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
double fMap, *pMap = nullptr;
if ( pModel )
@@ -274,17 +278,17 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
}
if ( GetBool( rGeometryItem, "Extrusion", false ) )
{
- bool bIsMirroredX = static_cast<const SdrObjCustomShape*>(pCustomShape)->IsMirroredX();
- bool bIsMirroredY = static_cast<const SdrObjCustomShape*>(pCustomShape)->IsMirroredY();
- tools::Rectangle aSnapRect( pCustomShape->GetLogicRect() );
- long nObjectRotation = pCustomShape->GetRotateAngle();
+ bool bIsMirroredX(rSdrObjCustomShape.IsMirroredX());
+ bool bIsMirroredY(rSdrObjCustomShape.IsMirroredY());
+ tools::Rectangle aSnapRect(rSdrObjCustomShape.GetLogicRect());
+ long nObjectRotation(rSdrObjCustomShape.GetRotateAngle());
if ( nObjectRotation )
{
double a = ( 36000 - nObjectRotation ) * nPi180;
long dx = aSnapRect.Right() - aSnapRect.Left();
long dy = aSnapRect.Bottom()- aSnapRect.Top();
Point aP( aSnapRect.TopLeft() );
- RotatePoint( aP, pCustomShape->GetSnapRect().Center(), sin( a ), cos( a ) );
+ RotatePoint( aP, rSdrObjCustomShape.GetSnapRect().Center(), sin( a ), cos( a ) );
aSnapRect.SetLeft( aP.X() );
aSnapRect.SetTop( aP.Y() );
aSnapRect.SetRight( aSnapRect.Left() + dx );
@@ -292,7 +296,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
}
Point aCenter( aSnapRect.Center() );
- SfxItemSet aSet( pCustomShape->GetMergedItemSet() );
+ SfxItemSet aSet( rSdrObjCustomShape.GetMergedItemSet() );
//SJ: vertical writing is not required, by removing this item no outliner is created
aSet.ClearItem( SDRATTR_TEXTDIRECTION );
@@ -530,7 +534,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
p3DObj->NbcSetLayer( pShape2d->GetLayer() );
p3DObj->SetMergedItemSet( aLocalSet );
if ( bUseExtrusionColor )
- p3DObj->SetMergedItem( XFillColorItem( "", pCustomShape->GetMergedItem( XATTR_SECONDARYFILLCOLOR ).GetColorValue() ) );
+ p3DObj->SetMergedItem( XFillColorItem( "", rSdrObjCustomShape.GetMergedItem( XATTR_SECONDARYFILLCOLOR ).GetColorValue() ) );
p3DObj->SetMergedItem( XFillStyleItem( drawing::FillStyle_SOLID ) );
p3DObj->SetMergedItem( Svx3DCloseFrontItem( false ) );
p3DObj->SetMergedItem( Svx3DCloseBackItem( false ) );
@@ -599,7 +603,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
double fXRotate, fYRotate;
GetRotateAngle( rGeometryItem, fXRotate, fYRotate );
- double fZRotate = static_cast<const SdrObjCustomShape*>(pCustomShape)->GetObjectRotation() * F_PI180;
+ double fZRotate(rSdrObjCustomShape.GetObjectRotation() * F_PI180);
if ( fZRotate != 0.0 )
aNewTransform.rotate( 0.0, 0.0, fZRotate );
if ( bIsMirroredX )
@@ -717,7 +721,12 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
pScene->GetProperties().SetObjectItem( makeSvx3DMaterialSpecularItem( aSpecularCol ) );
pScene->GetProperties().SetObjectItem( makeSvx3DMaterialSpecularIntensityItem( static_cast<sal_uInt16>(nIntensity) ) );
- pScene->SetLogicRect( CalculateNewSnapRect( pCustomShape, aSnapRect, aBoundRect2d, pMap ) );
+ pScene->SetLogicRect(
+ CalculateNewSnapRect(
+ rSdrObjCustomShape,
+ aSnapRect,
+ aBoundRect2d,
+ pMap));
// removing placeholder objects
for (std::vector< E3dCompoundObject* >::iterator aObjectListIter( aPlaceholderObjectList.begin() ); aObjectListIter != aPlaceholderObjectList.end(); )
@@ -732,9 +741,13 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con
return pRet;
}
-tools::Rectangle EnhancedCustomShape3d::CalculateNewSnapRect( const SdrObject* pCustomShape, const tools::Rectangle& rSnapRect, const tools::Rectangle& rBoundRect, const double* pMap )
+tools::Rectangle EnhancedCustomShape3d::CalculateNewSnapRect(
+ const SdrObjCustomShape& rSdrObjCustomShape,
+ const tools::Rectangle& rSnapRect,
+ const tools::Rectangle& rBoundRect,
+ const double* pMap)
{
- const SdrCustomShapeGeometryItem& rGeometryItem = pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ const SdrCustomShapeGeometryItem& rGeometryItem(rSdrObjCustomShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
const Point aCenter( rSnapRect.Center() );
double fExtrusionBackward, fExtrusionForward;
GetExtrusionDepth( rGeometryItem, pMap, fExtrusionBackward, fExtrusionForward );
@@ -759,16 +772,16 @@ tools::Rectangle EnhancedCustomShape3d::CalculateNewSnapRect( const SdrObject* p
double fXRotate, fYRotate;
GetRotateAngle( rGeometryItem, fXRotate, fYRotate );
- double fZRotate = - static_cast<const SdrObjCustomShape*>(pCustomShape)->GetObjectRotation() * F_PI180;
+ double fZRotate(rSdrObjCustomShape.GetObjectRotation() * F_PI180);
// rotating bound volume
basegfx::B3DHomMatrix aMatrix;
aMatrix.translate(-aRotationCenter.DirectionX, -aRotationCenter.DirectionY, -aRotationCenter.DirectionZ);
if ( fZRotate != 0.0 )
aMatrix.rotate( 0.0, 0.0, fZRotate );
- if ( static_cast<const SdrObjCustomShape*>(pCustomShape)->IsMirroredX() )
+ if (rSdrObjCustomShape.IsMirroredX())
aMatrix.scale( -1.0, 1, 1 );
- if ( static_cast<const SdrObjCustomShape*>(pCustomShape)->IsMirroredY() )
+ if (rSdrObjCustomShape.IsMirroredY())
aMatrix.scale( 1, -1.0, 1 );
if( fYRotate != 0.0 )
aMatrix.rotate( 0.0, fYRotate, 0.0 );
@@ -777,7 +790,10 @@ tools::Rectangle EnhancedCustomShape3d::CalculateNewSnapRect( const SdrObject* p
aMatrix.translate(aRotationCenter.DirectionX, aRotationCenter.DirectionY, aRotationCenter.DirectionZ);
aBoundVolume.transform(aMatrix);
- Transformation2D aTransformation2D( pCustomShape, pMap );
+ Transformation2D aTransformation2D(
+ rSdrObjCustomShape,
+ pMap);
+
if ( aTransformation2D.IsParallel() )
aBoundVolume = aTransformation2D.ApplySkewSettings( aBoundVolume );
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.hxx b/svx/source/customshapes/EnhancedCustomShape3d.hxx
index 011d92ccc639..1c8290846b12 100644
--- a/svx/source/customshapes/EnhancedCustomShape3d.hxx
+++ b/svx/source/customshapes/EnhancedCustomShape3d.hxx
@@ -49,8 +49,9 @@ class EnhancedCustomShape3d final
const double* pMap;
public:
-
- Transformation2D( const SdrObject* pCustomShape, const double* pMap );
+ Transformation2D(
+ const SdrObjCustomShape& rSdrObjCustomShape,
+ const double* pMap);
basegfx::B3DPolygon ApplySkewSettings( const basegfx::B3DPolygon& rPolygon3D ) const;
Point Transform2D( const basegfx::B3DPoint& rPoint ) const;
@@ -59,10 +60,16 @@ class EnhancedCustomShape3d final
friend class Transformation2D;
- static tools::Rectangle CalculateNewSnapRect( const SdrObject* pCustomShape, const tools::Rectangle& rSnapRect, const tools::Rectangle& rBoundRect, const double* pMap );
+ static tools::Rectangle CalculateNewSnapRect(
+ const SdrObjCustomShape& rSdrObjCustomShape,
+ const tools::Rectangle& rSnapRect,
+ const tools::Rectangle& rBoundRect,
+ const double* pMap);
public:
- static SdrObject* Create3DObject( const SdrObject* pShape2d, const SdrObject* pCustomShape );
+ static SdrObject* Create3DObject(
+ const SdrObject* pShape2d,
+ const SdrObjCustomShape& rSdrObjCustomShape);
};
#endif
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
index 30e7be880d3e..899ea6e03c26 100644
--- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
@@ -72,7 +72,9 @@ class EnhancedCustomShapeEngine : public cppu::WeakImplHelper
css::uno::Reference< css::drawing::XShape > mxShape;
bool mbForceGroupWithText;
- SdrObject* ImplForceGroupWithText( const SdrObjCustomShape* pCustoObj, SdrObject* pRenderedShape );
+ SdrObject* ImplForceGroupWithText(
+ const SdrObjCustomShape& rSdrObjCustomShape,
+ SdrObject* pRenderedShape);
public:
EnhancedCustomShapeEngine();
@@ -147,13 +149,17 @@ Sequence< OUString > SAL_CALL EnhancedCustomShapeEngine::getSupportedServiceName
}
// XCustomShapeEngine
-SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText( const SdrObjCustomShape* pCustoObj, SdrObject* pRenderedShape )
+SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText(
+ const SdrObjCustomShape& rSdrObjCustomShape,
+ SdrObject* pRenderedShape)
{
- bool bHasText = pCustoObj->HasText();
+ const bool bHasText(rSdrObjCustomShape.HasText());
+
if ( pRenderedShape || bHasText )
{
// applying shadow
- const SdrObject* pShadowGeometry = pCustoObj->GetSdrObjectShadowFromCustomShape();
+ const SdrObject* pShadowGeometry(rSdrObjCustomShape.GetSdrObjectShadowFromCustomShape());
+
if ( pShadowGeometry )
{
if ( pRenderedShape )
@@ -175,37 +181,48 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText( const SdrObjCustom
{
// #i37011# also create a text object and add at rPos + 1
SdrObject* pTextObj = SdrObjFactory::MakeNewObject(
- pCustoObj->GetObjInventor(), OBJ_TEXT, nullptr, pCustoObj->GetModel());
+ rSdrObjCustomShape.GetObjInventor(),
+ OBJ_TEXT,
+ nullptr,
+ rSdrObjCustomShape.GetModel());
// Copy text content
- OutlinerParaObject* pParaObj = pCustoObj->GetOutlinerParaObject();
+ OutlinerParaObject* pParaObj(rSdrObjCustomShape.GetOutlinerParaObject());
+
if( pParaObj )
pTextObj->NbcSetOutlinerParaObject( new OutlinerParaObject(*pParaObj) );
// copy all attributes
- SfxItemSet aTargetItemSet( pCustoObj->GetMergedItemSet() );
+ SfxItemSet aTargetItemSet(rSdrObjCustomShape.GetMergedItemSet());
// clear fill and line style
aTargetItemSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
aTargetItemSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
// get the text bounds and set at text object
- tools::Rectangle aTextBounds = pCustoObj->GetSnapRect();
- SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxShape ) );
- if ( pSdrObjCustomShape )
+ tools::Rectangle aTextBounds(rSdrObjCustomShape.GetSnapRect());
+ const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(mxShape)));
+
+ if(bIsSdrObjCustomShape)
{
- EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
+ SdrObjCustomShape& rSdrObjCustomShape(
+ static_cast< SdrObjCustomShape& >(
+ *GetSdrObjectFromXShape(mxShape)));
+ EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
aTextBounds = aCustomShape2d.GetTextRect();
}
+
pTextObj->SetSnapRect( aTextBounds );
// if rotated, copy GeoStat, too.
- const GeoStat& rSourceGeo = pCustoObj->GetGeoStat();
+ const GeoStat& rSourceGeo(rSdrObjCustomShape.GetGeoStat());
if ( rSourceGeo.nRotationAngle )
{
pTextObj->NbcRotate(
- pCustoObj->GetSnapRect().Center(), rSourceGeo.nRotationAngle,
- rSourceGeo.nSin, rSourceGeo.nCos);
+ rSdrObjCustomShape.GetSnapRect().Center(),
+ rSourceGeo.nRotationAngle,
+ rSourceGeo.nSin,
+ rSourceGeo.nCos);
}
// set modified ItemSet at text object
@@ -234,10 +251,12 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText( const SdrObjCustom
pRenderedShape = new SdrObjGroup();
static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pTmp );
}
- pRenderedShape->SetPage( pCustoObj->GetPage() );
- pRenderedShape->SetModel( pCustoObj->GetModel() );
+
+ pRenderedShape->SetPage(rSdrObjCustomShape.GetPage());
+ pRenderedShape->SetModel(rSdrObjCustomShape.GetModel());
}
}
+
return pRenderedShape;
}
@@ -253,104 +272,130 @@ void SetTemporary( uno::Reference< drawing::XShape > const & xShape )
Reference< drawing::XShape > SAL_CALL EnhancedCustomShapeEngine::render()
{
- Reference< drawing::XShape > xShape;
- SdrObject* pSdrObjCustomShape( dynamic_cast<SdrObjCustomShape*>( GetSdrObjectFromXShape( mxShape ) ) );
- if ( pSdrObjCustomShape )
+ const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(mxShape)));
+
+ if(!bIsSdrObjCustomShape)
{
- // retrieving the TextPath property to check if feature is enabled
- const SdrCustomShapeGeometryItem& rGeometryItem =
- pSdrObjCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
- bool bTextPathOn = false;
- const uno::Any* pAny = rGeometryItem.GetPropertyValueByName( "TextPath", "TextPath" );
- if ( pAny )
- *pAny >>= bTextPathOn;
-
- EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
- sal_Int32 nRotateAngle = aCustomShape2d.GetRotateAngle();
-
- bool bFlipV = aCustomShape2d.IsFlipVert();
- bool bFlipH = aCustomShape2d.IsFlipHorz();
- bool bLineGeometryNeededOnly = bTextPathOn;
-
- SdrObject* pRenderedShape = aCustomShape2d.CreateObject( bLineGeometryNeededOnly );
- if ( pRenderedShape )
+ return Reference< drawing::XShape >();
+ }
+
+ SdrObjCustomShape& rSdrObjCustomShape(
+ static_cast< SdrObjCustomShape& >(
+ *GetSdrObjectFromXShape(mxShape)));
+
+ // retrieving the TextPath property to check if feature is enabled
+ const SdrCustomShapeGeometryItem& rGeometryItem(rSdrObjCustomShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
+ bool bTextPathOn = false;
+ const uno::Any* pAny = rGeometryItem.GetPropertyValueByName( "TextPath", "TextPath" );
+ if ( pAny )
+ *pAny >>= bTextPathOn;
+
+ EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
+ sal_Int32 nRotateAngle = aCustomShape2d.GetRotateAngle();
+
+ bool bFlipV = aCustomShape2d.IsFlipVert();
+ bool bFlipH = aCustomShape2d.IsFlipHorz();
+ bool bLineGeometryNeededOnly = bTextPathOn;
+
+ SdrObject* pRenderedShape = aCustomShape2d.CreateObject( bLineGeometryNeededOnly );
+ if ( pRenderedShape )
+ {
+ if ( bTextPathOn )
{
- if ( bTextPathOn )
- {
- SdrObject* pRenderedFontWork = EnhancedCustomShapeFontWork::CreateFontWork( pRenderedShape, pSdrObjCustomShape );
- if ( pRenderedFontWork )
- {
- SdrObject::Free( pRenderedShape );
- pRenderedShape = pRenderedFontWork;
- }
- }
- SdrObject* pRenderedShape3d = EnhancedCustomShape3d::Create3DObject( pRenderedShape, pSdrObjCustomShape );
- if ( pRenderedShape3d )
+ SdrObject* pRenderedFontWork(
+ EnhancedCustomShapeFontWork::CreateFontWork(
+ pRenderedShape,
+ rSdrObjCustomShape));
+
+ if ( pRenderedFontWork )
{
- bFlipV = bFlipH = false;
- nRotateAngle = 0;
SdrObject::Free( pRenderedShape );
- pRenderedShape = pRenderedShape3d;
+ pRenderedShape = pRenderedFontWork;
}
- tools::Rectangle aRect( pSdrObjCustomShape->GetSnapRect() );
+ }
+ SdrObject* pRenderedShape3d = EnhancedCustomShape3d::Create3DObject(pRenderedShape, rSdrObjCustomShape);
+ if ( pRenderedShape3d )
+ {
+ bFlipV = bFlipH = false;
+ nRotateAngle = 0;
+ SdrObject::Free( pRenderedShape );
+ pRenderedShape = pRenderedShape3d;
+ }
- const GeoStat& rGeoStat = static_cast<SdrObjCustomShape*>(pSdrObjCustomShape)->GetGeoStat();
- if ( rGeoStat.nShearAngle )
- {
- long nShearAngle = rGeoStat.nShearAngle;
- double nTan = rGeoStat.nTan;
- if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
- {
- nShearAngle = -nShearAngle;
- nTan = -nTan;
- }
- pRenderedShape->Shear( pSdrObjCustomShape->GetSnapRect().Center(), nShearAngle, nTan, false);
- }
- if(nRotateAngle )
- {
- double a = nRotateAngle * F_PI18000;
- pRenderedShape->NbcRotate( pSdrObjCustomShape->GetSnapRect().Center(), nRotateAngle, sin( a ), cos( a ) );
- }
- if ( bFlipV )
+ tools::Rectangle aRect(rSdrObjCustomShape.GetSnapRect());
+ const GeoStat& rGeoStat(rSdrObjCustomShape.GetGeoStat());
+
+ if ( rGeoStat.nShearAngle )
+ {
+ long nShearAngle = rGeoStat.nShearAngle;
+ double nTan = rGeoStat.nTan;
+ if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
{
- Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
- Point aRight( aLeft.X() + 1000, aLeft.Y() );
- pRenderedShape->NbcMirror( aLeft, aRight );
+ nShearAngle = -nShearAngle;
+ nTan = -nTan;
}
- if ( bFlipH )
- {
- Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
- Point aBottom( aTop.X(), aTop.Y() + 1000 );
- pRenderedShape->NbcMirror( aTop, aBottom );
- }
- pRenderedShape->NbcSetStyleSheet( pSdrObjCustomShape->GetStyleSheet(), true );
- pRenderedShape->RecalcSnapRect();
- }
- if ( mbForceGroupWithText )
- pRenderedShape = ImplForceGroupWithText( static_cast<SdrObjCustomShape*>(pSdrObjCustomShape), pRenderedShape );
+ pRenderedShape->Shear(rSdrObjCustomShape.GetSnapRect().Center(), nShearAngle, nTan, false);
+ }
+ if(nRotateAngle )
+ {
+ double a = nRotateAngle * F_PI18000;
- if ( pRenderedShape )
+ pRenderedShape->NbcRotate(rSdrObjCustomShape.GetSnapRect().Center(), nRotateAngle, sin( a ), cos( a ));
+ }
+ if ( bFlipV )
+ {
+ Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
+ Point aRight( aLeft.X() + 1000, aLeft.Y() );
+ pRenderedShape->NbcMirror( aLeft, aRight );
+ }
+ if ( bFlipH )
{
- aCustomShape2d.ApplyGluePoints( pRenderedShape );
- xShape = SvxDrawPage::CreateShapeByTypeAndInventor( pRenderedShape->GetObjIdentifier(),
- pRenderedShape->GetObjInventor(), pRenderedShape );
+ Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
+ Point aBottom( aTop.X(), aTop.Y() + 1000 );
+ pRenderedShape->NbcMirror( aTop, aBottom );
}
- SetTemporary( xShape );
+
+ pRenderedShape->NbcSetStyleSheet(rSdrObjCustomShape.GetStyleSheet(), true);
+ pRenderedShape->RecalcSnapRect();
}
+
+ if ( mbForceGroupWithText )
+ {
+ pRenderedShape = ImplForceGroupWithText(
+ rSdrObjCustomShape,
+ pRenderedShape);
+ }
+
+ Reference< drawing::XShape > xShape;
+
+ if ( pRenderedShape )
+ {
+ aCustomShape2d.ApplyGluePoints( pRenderedShape );
+ xShape = SvxDrawPage::CreateShapeByTypeAndInventor( pRenderedShape->GetObjIdentifier(),
+ pRenderedShape->GetObjInventor(), pRenderedShape );
+ }
+
+ SetTemporary( xShape );
+
return xShape;
}
awt::Rectangle SAL_CALL EnhancedCustomShapeEngine::getTextBounds()
{
awt::Rectangle aTextRect;
- SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxShape ) );
- uno::Reference< document::XActionLockable > xLockable( mxShape, uno::UNO_QUERY );
- if ( pSdrObjCustomShape && pSdrObjCustomShape->GetModel() && xLockable.is() && !xLockable->isActionLocked() )
+ const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(mxShape)));
+
+ if(bIsSdrObjCustomShape)
{
- if ( pSdrObjCustomShape )
+ SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*GetSdrObjectFromXShape(mxShape)));
+ uno::Reference< document::XActionLockable > xLockable( mxShape, uno::UNO_QUERY );
+
+ if(rSdrObjCustomShape.GetModel()
+ && xLockable.is()
+ && !xLockable->isActionLocked())
{
- EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
+ EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
tools::Rectangle aRect( aCustomShape2d.GetTextRect() );
aTextRect.X = aRect.Left();
aTextRect.Y = aRect.Top();
@@ -358,24 +403,30 @@ awt::Rectangle SAL_CALL EnhancedCustomShapeEngine::getTextBounds()
aTextRect.Height = aRect.GetHeight();
}
}
+
return aTextRect;
}
drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeometry()
{
drawing::PolyPolygonBezierCoords aPolyPolygonBezierCoords;
- SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxShape ) );
- if ( pSdrObjCustomShape )
+ const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(mxShape)));
+
+ if(bIsSdrObjCustomShape)
{
- EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
+ SdrObjCustomShape& rSdrObjCustomShape(
+ static_cast< SdrObjCustomShape& >(
+ *GetSdrObjectFromXShape(mxShape)));
+ EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
SdrObject* pObj = aCustomShape2d.CreateLineGeometry();
+
if ( pObj )
{
- tools::Rectangle aRect( pSdrObjCustomShape->GetSnapRect() );
+ tools::Rectangle aRect(rSdrObjCustomShape.GetSnapRect());
bool bFlipV = aCustomShape2d.IsFlipVert();
bool bFlipH = aCustomShape2d.IsFlipHorz();
+ const GeoStat& rGeoStat(rSdrObjCustomShape.GetGeoStat());
- const GeoStat& rGeoStat = static_cast<SdrObjCustomShape*>(pSdrObjCustomShape)->GetGeoStat();
if ( rGeoStat.nShearAngle )
{
long nShearAngle = rGeoStat.nShearAngle;
@@ -444,13 +495,19 @@ drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeom
Sequence< Reference< drawing::XCustomShapeHandle > > SAL_CALL EnhancedCustomShapeEngine::getInteraction()
{
sal_uInt32 i, nHdlCount = 0;
- SdrObject* pSdrObjCustomShape = GetSdrObjectFromXShape( mxShape );
- if ( pSdrObjCustomShape )
+ const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(mxShape)));
+
+ if(bIsSdrObjCustomShape)
{
- EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
+ SdrObjCustomShape& rSdrObjCustomShape(
+ static_cast< SdrObjCustomShape& >(
+ *GetSdrObjectFromXShape(mxShape)));
+ EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
nHdlCount = aCustomShape2d.GetHdlCount();
}
+
Sequence< Reference< drawing::XCustomShapeHandle > > aSeq( nHdlCount );
+
for ( i = 0; i < nHdlCount; i++ )
aSeq[ i ] = new EnhancedCustomShapeHandle( mxShape, i );
return aSeq;
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
index c6d45574a9e4..71dc441f1727 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -85,7 +85,10 @@ struct FWData // representing the whole text
};
-static bool InitializeFontWorkData( const SdrObject* pCustomShape, const sal_uInt16 nOutlinesCount2d, FWData& rFWData )
+static bool InitializeFontWorkData(
+ const SdrObjCustomShape& rSdrObjCustomShape,
+ const sal_uInt16 nOutlinesCount2d,
+ FWData& rFWData)
{
bool bNoErr = false;
bool bSingleLineMode = false;
@@ -100,7 +103,8 @@ static bool InitializeFontWorkData( const SdrObject* pCustomShape, const sal_uIn
rFWData.bSingleLineMode = bSingleLineMode;
// setting the strings
- OutlinerParaObject* pParaObj = static_cast<const SdrObjCustomShape*>(pCustomShape)->GetOutlinerParaObject();
+ OutlinerParaObject* pParaObj(rSdrObjCustomShape.GetOutlinerParaObject());
+
if ( pParaObj )
{
const EditTextObject& rTextObj = pParaObj->GetTextObject();
@@ -146,8 +150,10 @@ double GetLength( const tools::Polygon& rPolygon )
/* CalculateHorizontalScalingFactor returns the horizontal scaling factor for
the whole text object, so that each text will match its corresponding 2d Outline */
-void CalculateHorizontalScalingFactor( const SdrObject* pCustomShape,
- FWData& rFWData, const tools::PolyPolygon& rOutline2d )
+void CalculateHorizontalScalingFactor(
+ const SdrObjCustomShape& rSdrObjCustomShape,
+ FWData& rFWData,
+ const tools::PolyPolygon& rOutline2d)
{
double fScalingFactor = 1.0;
bool bScalingFactorDefined = false;
@@ -157,8 +163,8 @@ void CalculateHorizontalScalingFactor( const SdrObject* pCustomShape,
sal_uInt16 nOutlinesCount2d = rOutline2d.Count();
vcl::Font aFont;
- const SvxFontItem& rFontItem = pCustomShape->GetMergedItem( EE_CHAR_FONTINFO );
- aFont.SetFontHeight( pCustomShape->GetLogicRect().GetHeight() / rFWData.nMaxParagraphsPerTextArea );
+ const SvxFontItem& rFontItem(rSdrObjCustomShape.GetMergedItem( EE_CHAR_FONTINFO ));
+ aFont.SetFontHeight(rSdrObjCustomShape.GetLogicRect().GetHeight() / rFWData.nMaxParagraphsPerTextArea);
aFont.SetAlignment( ALIGN_TOP );
aFont.SetFamilyName( rFontItem.GetFamilyName() );
aFont.SetFamily( rFontItem.GetFamily() );
@@ -210,9 +216,13 @@ void CalculateHorizontalScalingFactor( const SdrObject* pCustomShape,
rFWData.fHorizontalTextScaling = fScalingFactor;
}
-void GetTextAreaOutline( const FWData& rFWData, const SdrObject* pCustomShape, FWTextArea& rTextArea, bool bSameLetterHeights )
+void GetTextAreaOutline(
+ const FWData& rFWData,
+ const SdrObjCustomShape& rSdrObjCustomShape,
+ FWTextArea& rTextArea,
+ bool bSameLetterHeights)
{
- bool bIsVertical = static_cast<const SdrObjCustomShape*>(pCustomShape)->IsVerticalWriting();
+ bool bIsVertical(rSdrObjCustomShape.IsVerticalWriting());
sal_Int32 nVerticalOffset = rFWData.nMaxParagraphsPerTextArea > rTextArea.vParagraphs.size()
? rFWData.nSingleLineHeight / 2 : 0;
@@ -243,7 +253,7 @@ void GetTextAreaOutline( const FWData& rFWData, const SdrObject* pCustomShape, F
nFntItm = EE_CHAR_FONTINFO_CTL;
else if ( nScriptType == i18n::ScriptType::ASIAN )
nFntItm = EE_CHAR_FONTINFO_CJK;
- const SvxFontItem& rFontItem = static_cast<const SvxFontItem&>(pCustomShape->GetMergedItem( nFntItm ));
+ const SvxFontItem& rFontItem = static_cast<const SvxFontItem&>(rSdrObjCustomShape.GetMergedItem( nFntItm ));
vcl::Font aFont;
aFont.SetFontHeight( rFWData.nSingleLineHeight );
aFont.SetAlignment( ALIGN_TOP );
@@ -253,10 +263,10 @@ void GetTextAreaOutline( const FWData& rFWData, const SdrObject* pCustomShape, F
aFont.SetStyleName( rFontItem.GetStyleName() );
aFont.SetOrientation( 0 );
- const SvxPostureItem& rPostureItem = pCustomShape->GetMergedItem( EE_CHAR_ITALIC );
+ const SvxPostureItem& rPostureItem = rSdrObjCustomShape.GetMergedItem( EE_CHAR_ITALIC );
aFont.SetItalic( rPostureItem.GetPosture() );
- const SvxWeightItem& rWeightItem = pCustomShape->GetMergedItem( EE_CHAR_WEIGHT );
+ const SvxWeightItem& rWeightItem = rSdrObjCustomShape.GetMergedItem( EE_CHAR_WEIGHT );
aFont.SetWeight( rWeightItem.GetWeight() );
// initializing virtual device
@@ -267,7 +277,7 @@ void GetTextAreaOutline( const FWData& rFWData, const SdrObject* pCustomShape, F
if ( aParagraphIter->nFrameDirection == SvxFrameDirection::Horizontal_RL_TB )
pVirDev->SetLayoutMode( ComplexTextLayoutFlags::BiDiRtl );
- const SvxCharScaleWidthItem& rCharScaleWidthItem = pCustomShape->GetMergedItem( EE_CHAR_FONTWIDTH );
+ const SvxCharScaleWidthItem& rCharScaleWidthItem = rSdrObjCustomShape.GetMergedItem( EE_CHAR_FONTWIDTH );
sal_uInt16 nCharScaleWidth = rCharScaleWidthItem.GetValue();
std::unique_ptr<long[]> pDXArry;
sal_Int32 nWidth = 0;
@@ -413,29 +423,36 @@ void GetTextAreaOutline( const FWData& rFWData, const SdrObject* pCustomShape, F
}
}
-bool GetFontWorkOutline(FWData& rFWData, const SdrObject* pCustomShape)
+bool GetFontWorkOutline(
+ FWData& rFWData,
+ const SdrObjCustomShape& rSdrObjCustomShape)
{
- SdrTextHorzAdjust eHorzAdjust( pCustomShape->GetMergedItem( SDRATTR_TEXT_HORZADJUST ).GetValue() );
- drawing::TextFitToSizeType const eFTS( pCustomShape->GetMergedItem( SDRATTR_TEXT_FITTOSIZE ).GetValue() );
+ SdrTextHorzAdjust eHorzAdjust(rSdrObjCustomShape.GetMergedItem( SDRATTR_TEXT_HORZADJUST ).GetValue());
+ drawing::TextFitToSizeType const eFTS(rSdrObjCustomShape.GetMergedItem( SDRATTR_TEXT_FITTOSIZE ).GetValue());
std::vector< FWTextArea >::iterator aTextAreaIter = rFWData.vTextAreas.begin();
std::vector< FWTextArea >::const_iterator aTextAreaIEnd = rFWData.vTextAreas.end();
- rFWData.nSingleLineHeight = static_cast<sal_Int32>( ( static_cast<double>(pCustomShape->GetLogicRect().GetHeight())
+ rFWData.nSingleLineHeight = static_cast<sal_Int32>( ( static_cast<double>(rSdrObjCustomShape.GetLogicRect().GetHeight())
/ rFWData.nMaxParagraphsPerTextArea ) * rFWData.fHorizontalTextScaling );
if (rFWData.nSingleLineHeight == SAL_MIN_INT32)
return false;
bool bSameLetterHeights = false;
- const SdrCustomShapeGeometryItem& rGeometryItem = pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ const SdrCustomShapeGeometryItem& rGeometryItem(rSdrObjCustomShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
const css::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( "TextPath", "SameLetterHeights" );
if ( pAny )
*pAny >>= bSameLetterHeights;
while ( aTextAreaIter != aTextAreaIEnd )
{
- GetTextAreaOutline( rFWData, pCustomShape, *aTextAreaIter, bSameLetterHeights );
+ GetTextAreaOutline(
+ rFWData,
+ rSdrObjCustomShape,
+ *aTextAreaIter,
+ bSameLetterHeights);
+
if (eFTS == drawing::TextFitToSizeType_ALLLINES ||
// tdf#97630 interpret PROPORTIONAL same as ALLLINES so we don't
// need another ODF attribute!
@@ -802,7 +819,9 @@ void FitTextOutlinesToShapeOutlines( const tools::PolyPolygon& aOutlines2d, FWDa
}
}
-SdrObject* CreateSdrObjectFromParagraphOutlines( const FWData& rFWData, const SdrObject* pCustomShape )
+SdrObject* CreateSdrObjectFromParagraphOutlines(
+ const FWData& rFWData,
+ const SdrObjCustomShape& rSdrObjCustomShape)
{
SdrObject* pRet = nullptr;
basegfx::B2DPolyPolygon aPolyPoly;
@@ -836,7 +855,7 @@ SdrObject* CreateSdrObjectFromParagraphOutlines( const FWData& rFWData, const Sd
pRet = new SdrPathObj( OBJ_POLY, aPolyPoly );
- SfxItemSet aSet( pCustomShape->GetMergedItemSet() );
+ SfxItemSet aSet(rSdrObjCustomShape.GetMergedItemSet());
aSet.ClearItem( SDRATTR_TEXTDIRECTION ); //SJ: vertical writing is not required, by removing this item no outliner is created
aSet.Put(makeSdrShadowItem(false)); // #i37011# NO shadow for FontWork geometry
pRet->SetMergedItemSet( aSet ); // * otherwise we would crash, because the outliner tries to create a Paraobject, but there is no model
@@ -856,7 +875,9 @@ Reference < i18n::XBreakIterator > const & EnhancedCustomShapeFontWork::GetBreak
return mxBreakIterator;
}
-SdrObject* EnhancedCustomShapeFontWork::CreateFontWork( const SdrObject* pShape2d, const SdrObject* pCustomShape )
+SdrObject* EnhancedCustomShapeFontWork::CreateFontWork(
+ const SdrObject* pShape2d,
+ const SdrObjCustomShape& rSdrObjCustomShape)
{
SdrObject* pRet = nullptr;
@@ -865,19 +886,29 @@ SdrObject* EnhancedCustomShapeFontWork::CreateFontWork( const SdrObject* pShape2
if ( nOutlinesCount2d )
{
FWData aFWData;
- if ( InitializeFontWorkData( pCustomShape, nOutlinesCount2d, aFWData ) )
+
+ if(InitializeFontWorkData(rSdrObjCustomShape, nOutlinesCount2d, aFWData))
{
/* retrieves the horizontal scaling factor that has to be used
to fit each paragraph text into its corresponding 2d outline */
- CalculateHorizontalScalingFactor( pCustomShape, aFWData, aOutlines2d );
+ CalculateHorizontalScalingFactor(
+ rSdrObjCustomShape,
+ aFWData,
+ aOutlines2d);
/* retrieving the Outlines for the each Paragraph. */
- if (!GetFontWorkOutline(aFWData, pCustomShape))
+ if(!GetFontWorkOutline(
+ aFWData,
+ rSdrObjCustomShape))
+ {
return nullptr;
+ }
FitTextOutlinesToShapeOutlines( aOutlines2d, aFWData );
- pRet = CreateSdrObjectFromParagraphOutlines( aFWData, pCustomShape );
+ pRet = CreateSdrObjectFromParagraphOutlines(
+ aFWData,
+ rSdrObjCustomShape);
}
}
return pRet;
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.hxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.hxx
index d86388cb75fc..9fd954cd7034 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.hxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.hxx
@@ -30,7 +30,9 @@ class EnhancedCustomShapeFontWork
public:
static css::uno::Reference < css::i18n::XBreakIterator > const & GetBreakIterator();
- static SdrObject* CreateFontWork( const SdrObject* pShape2d, const SdrObject* pCustomShape );
+ static SdrObject* CreateFontWork(
+ const SdrObject* pShape2d,
+ const SdrObjCustomShape& rSdrObjCustomShape);
};
#endif
diff --git a/svx/source/customshapes/EnhancedCustomShapeHandle.cxx b/svx/source/customshapes/EnhancedCustomShapeHandle.cxx
index b541eb410978..d4975c41f4db 100644
--- a/svx/source/customshapes/EnhancedCustomShapeHandle.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeHandle.cxx
@@ -48,26 +48,41 @@ void SAL_CALL EnhancedCustomShapeHandle::release() throw()
// XCustomShapeHandle
css::awt::Point SAL_CALL EnhancedCustomShapeHandle::getPosition()
{
- SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxCustomShape ) );
- if ( !pSdrObjCustomShape )
+ const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(mxCustomShape)));
+
+ if(!bIsSdrObjCustomShape)
+ {
throw css::uno::RuntimeException();
+ }
+ SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*GetSdrObjectFromXShape(mxCustomShape)));
Point aPosition;
- EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
- if ( !aCustomShape2d.GetHandlePosition( mnIndex, aPosition ) )
+ EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
+
+ if(!aCustomShape2d.GetHandlePosition(mnIndex, aPosition))
+ {
throw css::uno::RuntimeException();
+ }
+
return css::awt::Point( aPosition.X(), aPosition.Y() );
}
void SAL_CALL EnhancedCustomShapeHandle::setControllerPosition( const css::awt::Point& aPnt )
{
- SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxCustomShape ) );
- if ( !pSdrObjCustomShape )
+ const bool bIsSdrObjCustomShape(nullptr != dynamic_cast< SdrObjCustomShape* >(GetSdrObjectFromXShape(mxCustomShape)));
+
+ if(!bIsSdrObjCustomShape)
+ {
throw css::uno::RuntimeException();
+ }
+
+ SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*GetSdrObjectFromXShape(mxCustomShape)));
+ EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
- EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
- if ( !aCustomShape2d.SetHandleControllerPosition( mnIndex, aPnt ) )
+ if(!aCustomShape2d.SetHandleControllerPosition(mnIndex, aPnt))
+ {
throw css::uno::RuntimeException();
+ }
}
// XInitialization