LibreOffice Module drawinglayer (master) 1
Primitive2DContainer.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
26
27using namespace css;
28
30{
32 const css::uno::Sequence<css::uno::Reference<css::graphic::XPrimitive2D>>& rSource)
33{
34 for (const auto& rPrimitive : rSource)
35 append(static_cast<const UnoPrimitive2D*>(rPrimitive.get())->getBasePrimitive2D());
36}
38 const std::deque<css::uno::Reference<css::graphic::XPrimitive2D>>& rSource)
39{
40 for (const auto& rPrimitive : rSource)
41 append(static_cast<const UnoPrimitive2D*>(rPrimitive.get())->getBasePrimitive2D());
42}
43
44css::uno::Sequence<css::uno::Reference<css::graphic::XPrimitive2D>>
46{
47 css::uno::Sequence<css::uno::Reference<css::graphic::XPrimitive2D>> aVal(size());
48 auto p = aVal.getArray();
49 for (const auto& rPrimitive : *this)
50 {
51 *p = new UnoPrimitive2D(rPrimitive);
52 ++p;
53 }
54 return aVal;
55}
56
58{
59 if (bInvert)
60 std::reverse(begin(), end());
61 return std::move(*this);
62}
63
64// get B2DRange from a given Primitive2DSequence
67{
68 basegfx::B2DRange aRetval;
69
70 if (!empty())
71 {
72 const sal_Int32 nCount(size());
73
74 for (sal_Int32 a(0); a < nCount; a++)
75 {
76 aRetval.expand(getB2DRangeFromPrimitive2DReference((*this)[a], aViewInformation));
77 }
78 }
79
80 return aRetval;
81}
82
84{
85 const bool bAHasElements(!empty());
86
87 if (bAHasElements != !rB.empty())
88 {
89 return false;
90 }
91
92 if (!bAHasElements)
93 {
94 return true;
95 }
96
97 const size_t nCount(size());
98
99 if (nCount != rB.size())
100 {
101 return false;
102 }
103
104 for (size_t a(0); a < nCount; a++)
105 {
106 if (!arePrimitive2DReferencesEqual((*this)[a], rB[a]))
107 {
108 return false;
109 }
110 }
111
112 return true;
113}
114
116
117void Primitive2DContainer::append(const Primitive2DReference& rSource) { push_back(rSource); }
118
120{
121 insert(end(), rSource.begin(), rSource.end());
122}
123
125{
126 this->insert(this->end(), std::make_move_iterator(rSource.begin()),
127 std::make_move_iterator(rSource.end()));
128}
129
131
132css::uno::Sequence<::css::uno::Reference<::css::graphic::XPrimitive2D>>
134 const css::uno::Sequence<css::beans::PropertyValue>& rViewParameters)
135{
136 std::unique_lock aGuard(m_aMutex);
137 return mxPrimitive->getDecomposition(rViewParameters).toSequence();
138}
139
140css::geometry::RealRectangle2D SAL_CALL
141UnoPrimitive2D::getRange(const css::uno::Sequence<css::beans::PropertyValue>& rViewParameters)
142{
143 std::unique_lock aGuard(m_aMutex);
144 return mxPrimitive->getRange(rViewParameters);
145}
146
148{
149 std::unique_lock aGuard(m_aMutex);
150 return mxPrimitive->estimateUsage();
151}
152
153} // end of namespace drawinglayer::primitive2d
154
155/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void expand(const Tuple2D< TYPE > &rTuple)
bool operator==(const Primitive2DContainer &rB) const
css::uno::Sequence< css::uno::Reference< css::graphic::XPrimitive2D > > toSequence() const
basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D &aViewInformation) const
Primitive2DContainer maybeInvert(bool bInvert=false)
Rather than make all the BasePrimitive2D classes bear the cost of being an UNO object,...
virtual css::geometry::RealRectangle2D SAL_CALL getRange(const css::uno::Sequence< css::beans::PropertyValue > &rViewParameters) override
The getRange implementation for UNO API will use getRange from this implementation.
rtl::Reference< BasePrimitive2D > const & getBasePrimitive2D() const
rtl::Reference< BasePrimitive2D > mxPrimitive
virtual sal_Int64 SAL_CALL estimateUsage() override
virtual css::uno::Sequence<::css::uno::Reference<::css::graphic::XPrimitive2D > > SAL_CALL getDecomposition(const css::uno::Sequence< css::beans::PropertyValue > &rViewParameters) override
The getDecomposition implementation for UNO API will use getDecomposition from this implementation.
int nCount
void * p
uno_Any a
size
bool arePrimitive2DReferencesEqual(const Primitive2DReference &rxA, const Primitive2DReference &rxB)
compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitiv...
basegfx::B2DRange getB2DRangeFromPrimitive2DReference(const Primitive2DReference &rCandidate, const geometry::ViewInformation2D &aViewInformation)
get B2DRange from a given Primitive2DReference
enumrange< T >::Iterator begin(enumrange< T >)
end