tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / basegfx / source / range / b2dpolyrange.cxx
blob42ee21ec0d64b995b0d953f3adfec03b435703da
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 <basegfx/range/b2dpolyrange.hxx>
22 #include <basegfx/range/b2drange.hxx>
23 #include <basegfx/range/b2drangeclipper.hxx>
24 #include <basegfx/polygon/b2dpolypolygon.hxx>
26 #include <algorithm>
27 #include <vector>
29 namespace basegfx
31 class ImplB2DPolyRange
33 public:
34 ImplB2DPolyRange()
37 bool operator==(const ImplB2DPolyRange& rRHS) const
39 return maRanges == rRHS.maRanges && maOrient == rRHS.maOrient;
42 sal_uInt32 count() const
44 return maRanges.size();
47 B2DPolyRange::ElementType getElement(sal_uInt32 nIndex) const
49 return std::make_tuple(maRanges[nIndex], maOrient[nIndex]);
52 void appendElement(const B2DRange& rRange, B2VectorOrientation eOrient)
54 maRanges.push_back(rRange);
55 maOrient.push_back(eOrient);
56 maBounds.expand(rRange);
59 void clear()
61 std::vector<B2DRange>().swap(maRanges);
62 std::vector<B2VectorOrientation>().swap(maOrient);
64 maBounds.reset();
67 bool overlaps( const B2DRange& rRange ) const
69 if( !maBounds.overlaps( rRange ) )
70 return false;
72 const std::vector<B2DRange>::const_iterator aEnd( maRanges.end() );
73 return std::any_of( maRanges.begin(),
74 aEnd,
75 [&rRange](const B2DRange& aRange) { return aRange.overlaps(rRange); } );
78 B2DPolyPolygon solveCrossovers() const
80 return utils::solveCrossovers(maRanges,maOrient);
83 void transform(const basegfx::B2DHomMatrix& rTranslate)
85 maBounds.transform(rTranslate);
86 for (auto &a : maRanges)
87 a.transform(rTranslate);
90 private:
91 B2DRange maBounds;
92 std::vector<B2DRange> maRanges;
93 std::vector<B2VectorOrientation> maOrient;
96 B2DPolyRange::B2DPolyRange() = default;
98 B2DPolyRange::~B2DPolyRange() = default;
100 B2DPolyRange::B2DPolyRange( const B2DPolyRange& ) = default;
102 B2DPolyRange& B2DPolyRange::operator=( const B2DPolyRange& ) = default;
104 bool B2DPolyRange::operator==(const B2DPolyRange& rRange) const
106 if(mpImpl.same_object(rRange.mpImpl))
107 return true;
109 return ((*mpImpl) == (*rRange.mpImpl));
112 sal_uInt32 B2DPolyRange::count() const
114 return mpImpl->count();
117 B2DPolyRange::ElementType B2DPolyRange::getElement(sal_uInt32 nIndex) const
119 return mpImpl->getElement(nIndex);
122 void B2DPolyRange::appendElement(const B2DRange& rRange, B2VectorOrientation eOrient)
124 mpImpl->appendElement(rRange, eOrient);
127 void B2DPolyRange::clear()
129 mpImpl->clear();
132 bool B2DPolyRange::overlaps( const B2DRange& rRange ) const
134 return mpImpl->overlaps(rRange);
137 void B2DPolyRange::transform(const basegfx::B2DHomMatrix& rTranslate)
139 mpImpl->transform(rTranslate);
142 B2DPolyPolygon B2DPolyRange::solveCrossovers() const
144 return mpImpl->solveCrossovers();
146 } // end of namespace basegfx
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */