diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de (CIB)> | 2018-02-22 11:14:31 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de (CIB)> | 2018-03-17 23:15:49 +0100 |
commit | 9886a69c472f212d88f11cfa0f3835e5dcf485b2 (patch) | |
tree | f7acb83ef0fa808db334eb10dd7242236404077f | |
parent | 823ef9ef3238efd92895254e0f8042ff1e543bb6 (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
-rw-r--r-- | include/svx/EnhancedCustomShape2d.hxx | 18 | ||||
-rw-r--r-- | include/svx/svdopath.hxx | 5 | ||||
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShape2d.cxx | 179 | ||||
-rw-r--r-- | svx/source/svdraw/svdopath.cxx | 6 |
4 files changed, 135 insertions, 73 deletions
diff --git a/include/svx/EnhancedCustomShape2d.hxx b/include/svx/EnhancedCustomShape2d.hxx index df6603a46183..074ecfa0a124 100644 --- a/include/svx/EnhancedCustomShape2d.hxx +++ b/include/svx/EnhancedCustomShape2d.hxx @@ -123,14 +123,22 @@ class SVX_DLLPUBLIC EnhancedCustomShape2d : public SfxItemSet SAL_DLLPRIVATE bool SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex ); SAL_DLLPRIVATE sal_Int32 GetLuminanceChange( sal_uInt32 nIndex ) const; SAL_DLLPRIVATE Color GetColorData( const Color& rFillColor, sal_uInt32 nIndex, double dBrightness ) const; - SAL_DLLPRIVATE void AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet, - sal_uInt32& nColorIndex, sal_uInt32 nColorCount); + SAL_DLLPRIVATE void AdaptObjColor( + SdrPathObj& rObj, + double dBrightness, + const SfxItemSet& rCustomShapeSet, + sal_uInt32& nColorIndex, + sal_uInt32 nColorCount); SAL_DLLPRIVATE Point GetPoint( const css::drawing::EnhancedCustomShapeParameterPair&, const bool bScale = true, const bool bReplaceGeoSize = false ) const; - SAL_DLLPRIVATE void CreateSubPath( sal_Int32& rSrcPt, sal_Int32& rSegmentInd, std::vector< SdrPathObj* >& rObjectList, - bool bLineGeometryNeededOnly, bool bSortFilledObjectsToBack, - sal_Int32 nIndex ); + SAL_DLLPRIVATE void CreateSubPath( + sal_Int32& rSrcPt, + sal_Int32& rSegmentInd, + std::vector< std::pair< SdrPathObj*, double> >& rObjectList, + bool bLineGeometryNeededOnly, + bool bSortFilledObjectsToBack, + sal_Int32 nIndex); SAL_DLLPRIVATE SdrObject* CreatePathObj( bool bLineGeometryNeededOnly ); SAL_DLLPRIVATE void ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rItem ); diff --git a/include/svx/svdopath.hxx b/include/svx/svdopath.hxx index 465ef0c6a702..fac63b375fb8 100644 --- a/include/svx/svdopath.hxx +++ b/include/svx/svdopath.hxx @@ -55,9 +55,6 @@ private: // for isolation of old Drag/Create code std::unique_ptr<ImpPathForDragAndCreate> mpDAC; - // brightness - used in EnhancedCustomShapes2d.cxx for DARKEN[LESS] and LIGHTEN[LESS] segments implementation - double mdBrightness; - // helper functions for GET, SET, INS etc. PNT void ImpSetClosed(bool bClose); void ImpForceKind(); @@ -65,8 +62,6 @@ private: ImpPathForDragAndCreate& impGetDAC() const; public: - double GetBrightness() { return mdBrightness; } - SdrPathObj(SdrObjKind eNewKind); SdrPathObj(SdrObjKind eNewKind, const basegfx::B2DPolyPolygon& rPathPoly, double dBrightness = 0.0); virtual ~SdrPathObj() override; 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(); |