summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de (CIB)>2018-02-22 11:14:31 +0100
committerArmin Le Grand <Armin.Le.Grand@cib.de (CIB)>2018-03-17 23:15:49 +0100
commit9886a69c472f212d88f11cfa0f3835e5dcf485b2 (patch)
treef7acb83ef0fa808db334eb10dd7242236404077f /svx
parent823ef9ef3238efd92895254e0f8042ff1e543bb6 (diff)
OperationSmiley: Remove brightness from SdrPathObj
There was a member at SdrPathObj called mdBrightness only for holding a blend value during creation of SdrPathObjs for CustomShape visualization. This has nothing to do on the model data, move it to where it belongs Change-Id: Iee101f90a1275ce1ed97e8e8d0ccf7084c83d4f6
Diffstat (limited to 'svx')
-rw-r--r--svx/source/customshapes/EnhancedCustomShape2d.cxx179
-rw-r--r--svx/source/svdraw/svdopath.cxx6
2 files changed, 122 insertions, 63 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index 1cc071e1ff24..b50836fd138f 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -1449,10 +1449,13 @@ static basegfx::B2DPolygon CreateArc( const tools::Rectangle& rRect, const Point
return aRetval;
}
-void EnhancedCustomShape2d::CreateSubPath( sal_Int32& rSrcPt, sal_Int32& rSegmentInd, std::vector< SdrPathObj* >& rObjectList,
- const bool bLineGeometryNeededOnly,
- const bool bSortFilledObjectsToBack,
- sal_Int32 nIndex )
+void EnhancedCustomShape2d::CreateSubPath(
+ sal_Int32& rSrcPt,
+ sal_Int32& rSegmentInd,
+ std::vector< std::pair< SdrPathObj*, double> >& rObjectList,
+ const bool bLineGeometryNeededOnly,
+ const bool bSortFilledObjectsToBack,
+ sal_Int32 nIndex)
{
bool bNoFill = false;
bool bNoStroke = false;
@@ -1997,12 +2000,12 @@ void EnhancedCustomShape2d::CreateSubPath( sal_Int32& rSrcPt, sal_Int32& rSegmen
{
basegfx::B2DPolyPolygon aClosedPolyPolygon(aNewB2DPolyPolygon);
aClosedPolyPolygon.setClosed(true);
- SdrPathObj* pFill = new SdrPathObj(OBJ_POLY, aClosedPolyPolygon, dBrightness);
+ SdrPathObj* pFill = new SdrPathObj(OBJ_POLY, aClosedPolyPolygon);
SfxItemSet aTempSet(*this);
aTempSet.Put(makeSdrShadowItem(false));
aTempSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
pFill->SetMergedItemSet(aTempSet);
- rObjectList.push_back(pFill);
+ rObjectList.push_back(std::pair< SdrPathObj*, double >(pFill, dBrightness));
}
if(!bNoStroke)
@@ -2013,12 +2016,12 @@ void EnhancedCustomShape2d::CreateSubPath( sal_Int32& rSrcPt, sal_Int32& rSegmen
// Thus, use a type that fits the polygon
SdrPathObj* pStroke = new SdrPathObj(
aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
- aNewB2DPolyPolygon, dBrightness);
+ aNewB2DPolyPolygon);
SfxItemSet aTempSet(*this);
aTempSet.Put(makeSdrShadowItem(false));
aTempSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
pStroke->SetMergedItemSet(aTempSet);
- rObjectList.push_back(pStroke);
+ rObjectList.push_back(std::pair< SdrPathObj*, double >(pStroke, dBrightness));
}
}
else
@@ -2032,13 +2035,13 @@ void EnhancedCustomShape2d::CreateSubPath( sal_Int32& rSrcPt, sal_Int32& rSegmen
// see comment above about OBJ_PLIN
pObj = new SdrPathObj(
aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
- aNewB2DPolyPolygon, dBrightness);
+ aNewB2DPolyPolygon);
aTempSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
}
else
{
aNewB2DPolyPolygon.setClosed(true);
- pObj = new SdrPathObj(OBJ_POLY, aNewB2DPolyPolygon, dBrightness);
+ pObj = new SdrPathObj(OBJ_POLY, aNewB2DPolyPolygon);
}
if(bNoStroke)
@@ -2049,13 +2052,16 @@ void EnhancedCustomShape2d::CreateSubPath( sal_Int32& rSrcPt, sal_Int32& rSegmen
if(pObj)
{
pObj->SetMergedItemSet(aTempSet);
- rObjectList.push_back(pObj);
+ rObjectList.push_back(std::pair< SdrPathObj*, double >(pObj, dBrightness));
}
}
}
}
-void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::vector< SdrPathObj* >& vObjectList )
+void CorrectCalloutArrows(
+ MSO_SPT eSpType,
+ sal_uInt32 nLineObjectCount,
+ std::vector< std::pair< SdrPathObj*, double> >& vObjectList )
{
bool bAccent = false;
switch( eSpType )
@@ -2073,8 +2079,11 @@ void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::ve
case mso_sptAccentBorderCallout90 :
{
sal_uInt32 nLine = 0;
- for ( SdrPathObj* pObj: vObjectList )
+
+ for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
{
+ SdrPathObj* pObj(rCandidate.first);
+
if(pObj->IsLine())
{
nLine++;
@@ -2097,8 +2106,11 @@ void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::ve
case mso_sptBorderCallout2 :
{
sal_uInt32 nLine = 0;
- for ( SdrPathObj* pObj: vObjectList )
+
+ for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
{
+ SdrPathObj* pObj(rCandidate.first);
+
if(pObj->IsLine())
{
nLine++;
@@ -2122,8 +2134,11 @@ void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::ve
case mso_sptBorderCallout3 :
{
sal_uInt32 nLine = 0;
- for ( SdrPathObj* pObj: vObjectList )
+
+ for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
{
+ SdrPathObj* pObj(rCandidate.first);
+
if(pObj->IsLine())
{
if ( nLine )
@@ -2142,8 +2157,12 @@ void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::ve
}
}
-void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet,
- sal_uInt32& nColorIndex, sal_uInt32 nColorCount)
+void EnhancedCustomShape2d::AdaptObjColor(
+ SdrPathObj& rObj,
+ double dBrightness,
+ const SfxItemSet& rCustomShapeSet,
+ sal_uInt32& nColorIndex,
+ sal_uInt32 nColorCount)
{
if ( !rObj.IsLine() )
{
@@ -2154,11 +2173,13 @@ void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rC
case drawing::FillStyle_SOLID:
{
Color aFillColor;
- if ( nColorCount || rObj.GetBrightness() != 0.0 )
+
+ if ( nColorCount || 0.0 != dBrightness )
{
aFillColor = GetColorData(
rCustomShapeSet.Get( XATTR_FILLCOLOR ).GetColorValue(),
- std::min(nColorIndex, nColorCount-1), rObj.GetBrightness() );
+ std::min(nColorIndex, nColorCount-1),
+ dBrightness );
rObj.SetMergedItem( XFillColorItem( "", aFillColor ) );
}
break;
@@ -2166,16 +2187,19 @@ void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rC
case drawing::FillStyle_GRADIENT:
{
XGradient aXGradient(rObj.GetMergedItem(XATTR_FILLGRADIENT).GetGradientValue());
- if ( nColorCount || rObj.GetBrightness() != 0.0 )
+
+ if ( nColorCount || 0.0 != dBrightness )
{
aXGradient.SetStartColor(
GetColorData(
aXGradient.GetStartColor(),
- std::min(nColorIndex, nColorCount-1), rObj.GetBrightness() ));
+ std::min(nColorIndex, nColorCount-1),
+ dBrightness ));
aXGradient.SetEndColor(
GetColorData(
aXGradient.GetEndColor(),
- std::min(nColorIndex, nColorCount-1), rObj.GetBrightness() ));
+ std::min(nColorIndex, nColorCount-1),
+ dBrightness ));
}
rObj.SetMergedItem( XFillGradientItem( "", aXGradient ) );
@@ -2184,12 +2208,14 @@ void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rC
case drawing::FillStyle_HATCH:
{
XHatch aXHatch(rObj.GetMergedItem(XATTR_FILLHATCH).GetHatchValue());
- if ( nColorCount || rObj.GetBrightness() != 0.0 )
+
+ if ( nColorCount || 0.0 != dBrightness )
{
aXHatch.SetColor(
GetColorData(
aXHatch.GetColor(),
- std::min(nColorIndex, nColorCount-1), rObj.GetBrightness() ));
+ std::min(nColorIndex, nColorCount-1),
+ dBrightness ));
}
rObj.SetMergedItem( XFillHatchItem( "", aXHatch ) );
@@ -2197,7 +2223,7 @@ void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rC
}
case drawing::FillStyle_BITMAP:
{
- if ( nColorCount || rObj.GetBrightness() != 0.0 )
+ if ( nColorCount || 0.0 != dBrightness )
{
Bitmap aBitmap(rObj.GetMergedItem(XATTR_FILLBITMAP).GetGraphicObject().GetGraphic().GetBitmapEx().GetBitmap());
@@ -2219,46 +2245,58 @@ void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rC
SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
{
- sal_Int32 nCoordSize = seqCoordinates.getLength();
+ const sal_Int32 nCoordSize(seqCoordinates.getLength());
+
if ( !nCoordSize )
+ {
return nullptr;
+ }
- std::vector< SdrPathObj* > vObjectList;
- bool bSortFilledObjectsToBack = SortFilledObjectsToBackByDefault( eSpType );
-
- sal_Int32 nSubPathIndex = 0;
+ std::vector< std::pair< SdrPathObj*, double > > vObjectList;
+ const bool bSortFilledObjectsToBack(SortFilledObjectsToBackByDefault(eSpType));
+ sal_Int32 nSubPathIndex(0);
+ sal_Int32 nSrcPt(0);
+ sal_Int32 nSegmentInd(0);
+ SdrObject* pRet(nullptr);
- sal_Int32 nSrcPt = 0;
- sal_Int32 nSegmentInd = 0;
while( nSegmentInd <= seqSegments.getLength() )
{
- CreateSubPath( nSrcPt, nSegmentInd, vObjectList, bLineGeometryNeededOnly, bSortFilledObjectsToBack, nSubPathIndex );
- nSubPathIndex ++;
+ CreateSubPath(
+ nSrcPt,
+ nSegmentInd,
+ vObjectList,
+ bLineGeometryNeededOnly,
+ bSortFilledObjectsToBack,
+ nSubPathIndex);
+ nSubPathIndex++;
}
- SdrObject* pRet = nullptr;
-
if ( !vObjectList.empty() )
{
- const SfxItemSet& rCustomShapeSet = pCustomShapeObj->GetMergedItemSet();
- sal_uInt32 nColorCount = nColorData >> 28;
- sal_uInt32 nColorIndex = 0;
+ const SfxItemSet& rCustomShapeSet(pCustomShapeObj->GetMergedItemSet());
+ const sal_uInt32 nColorCount(nColorData >> 28);
+ sal_uInt32 nColorIndex(0);
// #i37011# remove invisible objects
if(!vObjectList.empty())
{
- std::vector< SdrPathObj* > vTempList;
+ std::vector< std::pair< SdrPathObj*, double> > vTempList;
- for(SdrPathObj* pObj : vObjectList)
+ for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
{
- const drawing::LineStyle eLineStyle = pObj->GetMergedItem(XATTR_LINESTYLE).GetValue();
- const drawing::FillStyle eFillStyle = pObj->GetMergedItem(XATTR_FILLSTYLE).GetValue();
+ SdrPathObj* pObj(rCandidate.first);
+ const drawing::LineStyle eLineStyle(pObj->GetMergedItem(XATTR_LINESTYLE).GetValue());
+ const drawing::FillStyle eFillStyle(pObj->GetMergedItem(XATTR_FILLSTYLE).GetValue());
// #i40600# if bLineGeometryNeededOnly is set, linestyle does not matter
- if( !bLineGeometryNeededOnly && ( drawing::LineStyle_NONE == eLineStyle ) && ( drawing::FillStyle_NONE == eFillStyle ) )
+ if(!bLineGeometryNeededOnly && (drawing::LineStyle_NONE == eLineStyle) && (drawing::FillStyle_NONE == eFillStyle))
+ {
delete pObj;
+ }
else
- vTempList.push_back(pObj);
+ {
+ vTempList.push_back(rCandidate);
+ }
}
vObjectList = vTempList;
@@ -2267,16 +2305,23 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
if(1 == vObjectList.size())
{
// a single object, correct some values
- AdaptObjColor(*vObjectList[0L],rCustomShapeSet,nColorIndex,nColorCount);
+ AdaptObjColor(
+ *vObjectList.begin()->first,
+ vObjectList.begin()->second,
+ rCustomShapeSet,
+ nColorIndex,
+ nColorCount);
}
else
{
- sal_Int32 nLineObjectCount = 0;
- sal_Int32 nAreaObjectCount = 0;
+ sal_Int32 nLineObjectCount(0);
+ sal_Int32 nAreaObjectCount(0);
// correct some values and collect content data
- for (SdrPathObj* pObj : vObjectList)
+ for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
{
+ SdrPathObj* pObj(rCandidate.first);
+
if(pObj->IsLine())
{
nLineObjectCount++;
@@ -2284,34 +2329,48 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
else
{
nAreaObjectCount++;
- AdaptObjColor(*pObj,rCustomShapeSet,nColorIndex,nColorCount);
+ AdaptObjColor(
+ *pObj,
+ rCandidate.second,
+ rCustomShapeSet,
+ nColorIndex,
+ nColorCount);
}
}
// #i88870# correct line arrows for callouts
if ( nLineObjectCount )
- CorrectCalloutArrows( eSpType, nLineObjectCount, vObjectList );
+ {
+ CorrectCalloutArrows(
+ eSpType,
+ nLineObjectCount,
+ vObjectList);
+ }
// sort objects so that filled ones are in front. Necessary
// for some strange objects
- if ( bSortFilledObjectsToBack )
+ if(bSortFilledObjectsToBack)
{
- std::vector< SdrPathObj* > vTempList;
+ std::vector< std::pair< SdrPathObj*, double> > vTempList;
vTempList.reserve(vObjectList.size());
- for (SdrPathObj* pObj : vObjectList)
+ for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
{
+ SdrPathObj* pObj(rCandidate.first);
+
if ( !pObj->IsLine() )
{
- vTempList.push_back(pObj);
+ vTempList.push_back(rCandidate);
}
}
- for (SdrPathObj* pObj : vObjectList)
+ for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
{
+ SdrPathObj* pObj(rCandidate.first);
+
if ( pObj->IsLine() )
{
- vTempList.push_back(pObj);
+ vTempList.push_back(rCandidate);
}
}
@@ -2328,14 +2387,16 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
{
pRet = new SdrObjGroup;
- for (SdrPathObj* pObj : vObjectList)
+ for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
{
+ SdrPathObj* pObj(rCandidate.first);
+
pRet->GetSubList()->NbcInsertObject(pObj);
}
}
else if(1 == vObjectList.size())
{
- pRet = vObjectList[0L];
+ pRet = vObjectList.begin()->first;
}
if(pRet)
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index b574da18f22c..2935164da771 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -1629,16 +1629,14 @@ sdr::contact::ViewContact* SdrPathObj::CreateObjectSpecificViewContact()
SdrPathObj::SdrPathObj(SdrObjKind eNewKind)
-: meKind(eNewKind),
- mdBrightness(0.0)
+: meKind(eNewKind)
{
bClosedObj = IsClosed();
}
SdrPathObj::SdrPathObj(SdrObjKind eNewKind, const basegfx::B2DPolyPolygon& rPathPoly, double dBrightness)
: maPathPolygon(rPathPoly),
- meKind(eNewKind),
- mdBrightness(dBrightness)
+ meKind(eNewKind)
{
bClosedObj = IsClosed();
ImpForceKind();