calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / drawinglayer / source / primitive2d / baseprimitive2d.cxx
bloba2e0eaf6b6ba1ab5a2d05a73fb859ad1be2d0465
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
23 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
24 #include <drawinglayer/primitive2d/Tools.hxx>
25 #include <drawinglayer/geometry/viewinformation2d.hxx>
26 #include <basegfx/utils/canvastools.hxx>
28 using namespace css;
30 namespace drawinglayer::primitive2d
32 BasePrimitive2D::BasePrimitive2D() {}
34 BasePrimitive2D::~BasePrimitive2D() {}
36 bool BasePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
38 return (getPrimitive2DID() == rPrimitive.getPrimitive2DID());
41 namespace
43 // Visitor class to get the B2D range from a tree of Primitive2DReference's
45 class B2DRangeVisitor : public Primitive2DDecompositionVisitor
47 public:
48 const geometry::ViewInformation2D& mrViewInformation;
49 basegfx::B2DRange maRetval;
50 B2DRangeVisitor(const geometry::ViewInformation2D& rViewInformation)
51 : mrViewInformation(rViewInformation)
54 virtual void visit(const Primitive2DReference& r) override
56 maRetval.expand(getB2DRangeFromPrimitive2DReference(r, mrViewInformation));
58 virtual void visit(const Primitive2DContainer& r) override
60 maRetval.expand(r.getB2DRange(mrViewInformation));
62 virtual void visit(Primitive2DContainer&& r) override
64 maRetval.expand(r.getB2DRange(mrViewInformation));
69 basegfx::B2DRange
70 BasePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
72 B2DRangeVisitor aVisitor(rViewInformation);
73 get2DDecomposition(aVisitor, rViewInformation);
74 return aVisitor.maRetval;
77 void BasePrimitive2D::get2DDecomposition(
78 Primitive2DDecompositionVisitor& /*rVisitor*/,
79 const geometry::ViewInformation2D& /*rViewInformation*/) const
83 Primitive2DContainer
84 BasePrimitive2D::getDecomposition(const uno::Sequence<beans::PropertyValue>& rViewParameters)
86 const auto aViewInformation = geometry::createViewInformation2D(rViewParameters);
87 Primitive2DContainer aContainer;
88 get2DDecomposition(aContainer, aViewInformation);
89 return aContainer;
92 css::geometry::RealRectangle2D
93 BasePrimitive2D::getRange(const uno::Sequence<beans::PropertyValue>& rViewParameters)
95 const auto aViewInformation = geometry::createViewInformation2D(rViewParameters);
96 return basegfx::unotools::rectangle2DFromB2DRectangle(getB2DRange(aViewInformation));
99 sal_Int64 BasePrimitive2D::estimateUsage()
101 return 0; // for now ignore the objects themselves
104 } // end of namespace drawinglayer::primitive2d
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */