nss: upgrade to release 3.73
[LibreOffice.git] / drawinglayer / source / primitive2d / primitivetools2d.cxx
blobda0a378a00898078caeb1b1458c96c738118220d
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 <drawinglayer/primitive2d/primitivetools2d.hxx>
21 #include <basegfx/vector/b2dvector.hxx>
22 #include <drawinglayer/geometry/viewinformation2d.hxx>
25 namespace drawinglayer::primitive2d
27 void DiscreteMetricDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
29 ::osl::MutexGuard aGuard( m_aMutex );
31 // get the current DiscreteUnit, look at X and Y and use the maximum
32 const basegfx::B2DVector aDiscreteVector(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 1.0));
33 const double fDiscreteUnit(std::min(fabs(aDiscreteVector.getX()), fabs(aDiscreteVector.getY())));
35 if(!getBuffered2DDecomposition().empty() && !basegfx::fTools::equal(fDiscreteUnit, getDiscreteUnit()))
37 // conditions of last local decomposition have changed, delete
38 const_cast< DiscreteMetricDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DContainer());
41 if(getBuffered2DDecomposition().empty())
43 // remember new valid DiscreteUnit
44 const_cast< DiscreteMetricDependentPrimitive2D* >(this)->mfDiscreteUnit = fDiscreteUnit;
47 // call base implementation
48 BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
54 void ViewportDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
56 ::osl::MutexGuard aGuard( m_aMutex );
58 // get the current Viewport
59 const basegfx::B2DRange& rViewport = rViewInformation.getViewport();
61 if(!getBuffered2DDecomposition().empty() && !rViewport.equal(getViewport()))
63 // conditions of last local decomposition have changed, delete
64 const_cast< ViewportDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DContainer());
67 if(getBuffered2DDecomposition().empty())
69 // remember new valid DiscreteUnit
70 const_cast< ViewportDependentPrimitive2D* >(this)->maViewport = rViewport;
73 // call base implementation
74 BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
77 void ViewTransformationDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
79 ::osl::MutexGuard aGuard( m_aMutex );
81 // get the current ViewTransformation
82 const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation();
84 if(!getBuffered2DDecomposition().empty() && rViewTransformation != getViewTransformation())
86 // conditions of last local decomposition have changed, delete
87 const_cast< ViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DContainer());
90 if(getBuffered2DDecomposition().empty())
92 // remember new valid ViewTransformation
93 const_cast< ViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation;
96 // call base implementation
97 BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
100 void ObjectAndViewTransformationDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
102 ::osl::MutexGuard aGuard( m_aMutex );
104 // get the current ViewTransformation
105 const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation();
107 if(!getBuffered2DDecomposition().empty() && rViewTransformation != getViewTransformation())
109 // conditions of last local decomposition have changed, delete
110 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DContainer());
113 // get the current ObjectTransformation
114 const basegfx::B2DHomMatrix& rObjectTransformation = rViewInformation.getObjectTransformation();
116 if(!getBuffered2DDecomposition().empty() && rObjectTransformation != getObjectTransformation())
118 // conditions of last local decomposition have changed, delete
119 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DContainer());
122 if(getBuffered2DDecomposition().empty())
124 // remember new valid ViewTransformation, and ObjectTransformation
125 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation;
126 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maObjectTransformation = rObjectTransformation;
129 // call base implementation
130 BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
133 } // end of namespace
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */