Update ooo320-m1
[ooovba.git] / drawinglayer / source / primitive2d / primitivetools2d.cxx
blobd288a697d7290c3f21d4eab24ab223a581b169bb
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: baseprimitive2d.cxx,v $
7 * $Revision: 1.6 $
9 * last change: $Author: aw $ $Date: 2008-05-27 14:11:20 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <drawinglayer/primitive2d/primitivetools2d.hxx>
40 #include <basegfx/vector/b2dvector.hxx>
41 #include <drawinglayer/geometry/viewinformation2d.hxx>
43 //////////////////////////////////////////////////////////////////////////////
45 namespace drawinglayer
47 namespace primitive2d
49 Primitive2DSequence DiscreteMetricDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
51 ::osl::MutexGuard aGuard( m_aMutex );
53 // get the current DiscreteUnit
54 const double fDiscreteUnit((rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength());
56 if(getLocalDecomposition().hasElements() && !basegfx::fTools::equal(fDiscreteUnit, getDiscreteUnit()))
58 // conditions of last local decomposition have changed, delete
59 const_cast< DiscreteMetricDependentPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence());
62 if(!getLocalDecomposition().hasElements())
64 // remember new valid DiscreteUnit
65 const_cast< DiscreteMetricDependentPrimitive2D* >(this)->mfDiscreteUnit = fDiscreteUnit;
68 // call base implementation
69 return BasePrimitive2D::get2DDecomposition(rViewInformation);
71 } // end of namespace primitive2d
72 } // end of namespace drawinglayer
74 //////////////////////////////////////////////////////////////////////////////
76 namespace drawinglayer
78 namespace primitive2d
80 Primitive2DSequence ViewportDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
82 ::osl::MutexGuard aGuard( m_aMutex );
84 // get the current Viewport
85 const basegfx::B2DRange& rViewport = rViewInformation.getViewport();
87 if(getLocalDecomposition().hasElements() && !rViewport.equal(getViewport()))
89 // conditions of last local decomposition have changed, delete
90 const_cast< ViewportDependentPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence());
93 if(!getLocalDecomposition().hasElements())
95 // remember new valid DiscreteUnit
96 const_cast< ViewportDependentPrimitive2D* >(this)->maViewport = rViewport;
99 // call base implementation
100 return BasePrimitive2D::get2DDecomposition(rViewInformation);
102 } // end of namespace primitive2d
103 } // end of namespace drawinglayer
105 //////////////////////////////////////////////////////////////////////////////
106 // eof