diff options
Diffstat (limited to 'drawinglayer/source')
-rw-r--r-- | drawinglayer/source/processor2d/baseprocessor2d.cxx | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/drawinglayer/source/processor2d/baseprocessor2d.cxx b/drawinglayer/source/processor2d/baseprocessor2d.cxx index 00d71151e887..a078fe882e9e 100644 --- a/drawinglayer/source/processor2d/baseprocessor2d.cxx +++ b/drawinglayer/source/processor2d/baseprocessor2d.cxx @@ -41,28 +41,32 @@ namespace drawinglayer::processor2d void BaseProcessor2D::process(const primitive2d::BasePrimitive2D& rCandidate) { - primitive2d::Primitive2DContainer aContainer; - rCandidate.get2DDecomposition(aContainer, getViewInformation2D()); - process(aContainer); + // use the visitor API to avoid the cost of constructing Primitive2DContainers + rCandidate.get2DDecomposition(*this, getViewInformation2D()); } - void BaseProcessor2D::process(const primitive2d::Primitive2DContainer& rSource) + // Primitive2DDecompositionVisitor + void BaseProcessor2D::append(const primitive2d::Primitive2DReference& rCandidate) { - if(rSource.empty()) - return; - - const sal_Int32 nCount(rSource.size()); + const primitive2d::BasePrimitive2D* pBasePrimitive = static_cast< const primitive2d::BasePrimitive2D* >(rCandidate.get()); + processBasePrimitive2D(*pBasePrimitive); + } + void BaseProcessor2D::append(const primitive2d::Primitive2DContainer& rContainer) + { + process(rContainer); + } + void BaseProcessor2D::append(primitive2d::Primitive2DContainer&& rCandidate) + { + process(rCandidate); + } - for(sal_Int32 a(0); a < nCount; a++) + void BaseProcessor2D::process(const primitive2d::Primitive2DContainer& rSource) + { + for (const primitive2d::Primitive2DReference& rCandidate : rSource) { - // get reference - const primitive2d::Primitive2DReference xReference(rSource[a]); - - if(xReference.is()) - { - const primitive2d::BasePrimitive2D* pBasePrimitive = static_cast< const primitive2d::BasePrimitive2D* >(xReference.get()); + const primitive2d::BasePrimitive2D* pBasePrimitive = static_cast< const primitive2d::BasePrimitive2D* >(rCandidate.get()); + if (pBasePrimitive) processBasePrimitive2D(*pBasePrimitive); - } } } |