LibreOffice Module drawinglayer (master) 1
baseprimitive2d.cxx
Go to the documentation of this file.
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
27
28using namespace css;
29
31{
33
35
36bool BasePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
37{
38 return (getPrimitive2DID() == rPrimitive.getPrimitive2DID());
39}
40
41namespace
42{
43// Visitor class to get the B2D range from a tree of Primitive2DReference's
44//
45class B2DRangeVisitor : public Primitive2DDecompositionVisitor
46{
47public:
48 const geometry::ViewInformation2D& mrViewInformation;
50 B2DRangeVisitor(const geometry::ViewInformation2D& rViewInformation)
51 : mrViewInformation(rViewInformation)
52 {
53 }
54 virtual void visit(const Primitive2DReference& r) override
55 {
57 }
58 virtual void visit(const Primitive2DContainer& r) override
59 {
60 maRetval.expand(r.getB2DRange(mrViewInformation));
61 }
62 virtual void visit(Primitive2DContainer&& r) override
63 {
64 maRetval.expand(r.getB2DRange(mrViewInformation));
65 }
66};
67}
68
71{
72 B2DRangeVisitor aVisitor(rViewInformation);
73 get2DDecomposition(aVisitor, rViewInformation);
74 return aVisitor.maRetval;
75}
76
79 const geometry::ViewInformation2D& /*rViewInformation*/) const
80{
81}
82
84BasePrimitive2D::getDecomposition(const uno::Sequence<beans::PropertyValue>& rViewParameters)
85{
86 const auto aViewInformation = geometry::createViewInformation2D(rViewParameters);
87 Primitive2DContainer aContainer;
88 get2DDecomposition(aContainer, aViewInformation);
89 return aContainer;
90}
91
92css::geometry::RealRectangle2D
93BasePrimitive2D::getRange(const uno::Sequence<beans::PropertyValue>& rViewParameters)
94{
95 const auto aViewInformation = geometry::createViewInformation2D(rViewParameters);
97}
98
100{
101 return 0; // for now ignore the objects themselves
102}
103
104} // end of namespace drawinglayer::primitive2d
105
106/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basegfx::B2DRange maRetval
const geometry::ViewInformation2D & mrViewInformation
void expand(const Tuple2D< TYPE > &rTuple)
virtual void get2DDecomposition(Primitive2DDecompositionVisitor &rVisitor, const geometry::ViewInformation2D &rViewInformation) const
The default implementation will return an empty sequence.
Primitive2DContainer getDecomposition(const css::uno::Sequence< css::beans::PropertyValue > &rViewParameters)
The getDecomposition implementation for UNO API will use getDecomposition from this implementation.
virtual sal_uInt32 getPrimitive2DID() const =0
provide unique ID for fast identifying of known primitive implementations in renderers.
css::geometry::RealRectangle2D getRange(const css::uno::Sequence< css::beans::PropertyValue > &rViewParameters)
The getRange implementation for UNO API will use getRange from this implementation.
virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D &rViewInformation) const
The default implementation will use getDecomposition results to create the range.
virtual bool operator==(const BasePrimitive2D &rPrimitive) const
the ==operator is mainly needed to allow testing newly-created primitives against their last incarnat...
geometry::RealRectangle2D rectangle2DFromB2DRectangle(const ::basegfx::B2DRange &rRect)
ViewInformation2D createViewInformation2D(const css::uno::Sequence< css::beans::PropertyValue > &rViewParameters)
rtl::Reference< BasePrimitive2D > Primitive2DReference
Definition: CommonTypes.hxx:27
basegfx::B2DRange getB2DRangeFromPrimitive2DReference(const Primitive2DReference &rCandidate, const geometry::ViewInformation2D &aViewInformation)
get B2DRange from a given Primitive2DReference