nss: upgrade to release 3.73
[LibreOffice.git] / drawinglayer / source / primitive2d / Primitive2DContainer.cxx
blob3ae4a9b3e3c493ab23411908109e8adf63496eeb
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/Tools.hxx>
24 #include <drawinglayer/geometry/viewinformation2d.hxx>
26 using namespace css;
28 namespace drawinglayer::primitive2d
30 Primitive2DContainer Primitive2DContainer::maybeInvert(bool bInvert) const
32 const sal_uInt32 nSize(size());
33 Primitive2DContainer aRetval;
35 aRetval.resize(nSize);
37 for (sal_uInt32 a(0); a < nSize; a++)
39 aRetval[bInvert ? nSize - 1 - a : a] = (*this)[a];
42 // all entries taken over to Uno References as owners. To avoid
43 // errors with users of this mechanism to delete pointers to BasePrimitive2D
44 // itself, clear given vector
45 const_cast<Primitive2DContainer&>(*this).clear();
47 return aRetval;
50 // get B2DRange from a given Primitive2DSequence
51 basegfx::B2DRange
52 Primitive2DContainer::getB2DRange(const geometry::ViewInformation2D& aViewInformation) const
54 basegfx::B2DRange aRetval;
56 if (!empty())
58 const sal_Int32 nCount(size());
60 for (sal_Int32 a(0); a < nCount; a++)
62 aRetval.expand(getB2DRangeFromPrimitive2DReference((*this)[a], aViewInformation));
66 return aRetval;
69 bool Primitive2DContainer::operator==(const Primitive2DContainer& rB) const
71 const bool bAHasElements(!empty());
73 if (bAHasElements != !rB.empty())
75 return false;
78 if (!bAHasElements)
80 return true;
83 const size_t nCount(size());
85 if (nCount != rB.size())
87 return false;
90 for (size_t a(0); a < nCount; a++)
92 if (!arePrimitive2DReferencesEqual((*this)[a], rB[a]))
94 return false;
98 return true;
101 Primitive2DContainer::~Primitive2DContainer() {}
103 void Primitive2DContainer::append(const Primitive2DReference& rSource) { push_back(rSource); }
105 void Primitive2DContainer::append(const Primitive2DContainer& rSource)
107 insert(end(), rSource.begin(), rSource.end());
110 void Primitive2DContainer::append(Primitive2DContainer&& rSource)
112 this->insert(this->end(), std::make_move_iterator(rSource.begin()),
113 std::make_move_iterator(rSource.end()));
116 void Primitive2DContainer::append(const Primitive2DSequence& rSource)
118 this->insert(this->end(), rSource.begin(), rSource.end());
121 } // end of namespace drawinglayer::primitive2d
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */