/src/libreoffice/drawinglayer/source/primitive2d/baseprimitive2d.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <sal/config.h> |
21 | | |
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> |
27 | | |
28 | | using namespace css; |
29 | | |
30 | | namespace drawinglayer::primitive2d |
31 | | { |
32 | 419k | BasePrimitive2D::BasePrimitive2D() {} |
33 | | |
34 | 419k | BasePrimitive2D::~BasePrimitive2D() {} |
35 | | |
36 | | bool BasePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const |
37 | 1.89k | { |
38 | 1.89k | return (getPrimitive2DID() == rPrimitive.getPrimitive2DID()); |
39 | 1.89k | } |
40 | | |
41 | | namespace |
42 | | { |
43 | | // Visitor class to get the B2D range from a tree of Primitive2DReference's |
44 | | // |
45 | | class B2DRangeVisitor : public Primitive2DDecompositionVisitor |
46 | | { |
47 | | public: |
48 | | const geometry::ViewInformation2D& mrViewInformation; |
49 | | basegfx::B2DRange maRetval; |
50 | | B2DRangeVisitor(const geometry::ViewInformation2D& rViewInformation) |
51 | 14.7k | : mrViewInformation(rViewInformation) |
52 | 14.7k | { |
53 | 14.7k | } |
54 | | virtual void visit(const Primitive2DReference& r) override |
55 | 3.61k | { |
56 | 3.61k | maRetval.expand(getB2DRangeFromPrimitive2DReference(r, mrViewInformation)); |
57 | 3.61k | } |
58 | | virtual void visit(const Primitive2DContainer& r) override |
59 | 11.1k | { |
60 | 11.1k | maRetval.expand(r.getB2DRange(mrViewInformation)); |
61 | 11.1k | } |
62 | | virtual void visit(Primitive2DContainer&& r) override |
63 | 0 | { |
64 | 0 | maRetval.expand(r.getB2DRange(mrViewInformation)); |
65 | 0 | } |
66 | | }; |
67 | | } |
68 | | |
69 | | basegfx::B2DRange |
70 | | BasePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const |
71 | 14.7k | { |
72 | 14.7k | B2DRangeVisitor aVisitor(rViewInformation); |
73 | 14.7k | get2DDecomposition(aVisitor, rViewInformation); |
74 | 14.7k | return aVisitor.maRetval; |
75 | 14.7k | } |
76 | | |
77 | | void BasePrimitive2D::get2DDecomposition( |
78 | | Primitive2DDecompositionVisitor& /*rVisitor*/, |
79 | | const geometry::ViewInformation2D& /*rViewInformation*/) const |
80 | 225 | { |
81 | 225 | } |
82 | | |
83 | | Primitive2DContainer |
84 | | BasePrimitive2D::getDecomposition(const uno::Sequence<beans::PropertyValue>& rViewParameters) |
85 | 0 | { |
86 | 0 | const auto aViewInformation = geometry::createViewInformation2D(rViewParameters); |
87 | 0 | Primitive2DContainer aContainer; |
88 | 0 | get2DDecomposition(aContainer, aViewInformation); |
89 | 0 | return aContainer; |
90 | 0 | } |
91 | | |
92 | | css::geometry::RealRectangle2D |
93 | | BasePrimitive2D::getRange(const uno::Sequence<beans::PropertyValue>& rViewParameters) |
94 | 6.81k | { |
95 | 6.81k | const auto aViewInformation = geometry::createViewInformation2D(rViewParameters); |
96 | 6.81k | return basegfx::unotools::rectangle2DFromB2DRectangle(getB2DRange(aViewInformation)); |
97 | 6.81k | } |
98 | | |
99 | | sal_Int64 BasePrimitive2D::estimateUsage() |
100 | 6.81k | { |
101 | 6.81k | return 0; // for now ignore the objects themselves |
102 | 6.81k | } |
103 | | |
104 | | } // end of namespace drawinglayer::primitive2d |
105 | | |
106 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |