xref: /trunk/main/drawinglayer/source/geometry/viewinformation2d.cxx (revision de57a71b4c7763dcb58c39badd7e2d67d1e608b9)
1464702f4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3464702f4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4464702f4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5464702f4SAndrew Rist  * distributed with this work for additional information
6464702f4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7464702f4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8464702f4SAndrew Rist  * "License"); you may not use this file except in compliance
9464702f4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11464702f4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13464702f4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14464702f4SAndrew Rist  * software distributed under the License is distributed on an
15464702f4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16464702f4SAndrew Rist  * KIND, either express or implied.  See the License for the
17464702f4SAndrew Rist  * specific language governing permissions and limitations
18464702f4SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20464702f4SAndrew Rist  *************************************************************/
21464702f4SAndrew Rist 
22464702f4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <drawinglayer/geometry/viewinformation2d.hxx>
28cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
29cdf0e10cSrcweir #include <basegfx/range/b2drange.hxx>
30cdf0e10cSrcweir #include <osl/mutex.hxx>
31cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx>
32cdf0e10cSrcweir #include <com/sun/star/geometry/AffineMatrix2D.hpp>
33cdf0e10cSrcweir #include <com/sun/star/geometry/RealRectangle2D.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
36cdf0e10cSrcweir 
37cdf0e10cSrcweir using namespace com::sun::star;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace drawinglayer
42cdf0e10cSrcweir {
43cdf0e10cSrcweir     namespace geometry
44cdf0e10cSrcweir     {
45cdf0e10cSrcweir         class ImpViewInformation2D
46cdf0e10cSrcweir         {
47cdf0e10cSrcweir         private:
48cdf0e10cSrcweir             // ViewInformation2D implementation can change refcount, so we have only
49cdf0e10cSrcweir             // two memory regions for pairs of ViewInformation2D/ImpViewInformation2D
50cdf0e10cSrcweir             friend class ::drawinglayer::geometry::ViewInformation2D;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir             // the refcounter. 0 means exclusively used
53cdf0e10cSrcweir             sal_uInt32                                  mnRefCount;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir         protected:
56cdf0e10cSrcweir             // the object transformation
57cdf0e10cSrcweir             basegfx::B2DHomMatrix                       maObjectTransformation;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir             // the view transformation
60cdf0e10cSrcweir             basegfx::B2DHomMatrix                       maViewTransformation;
61cdf0e10cSrcweir 
62*de57a71bSmseidel             // the ObjectToView and its inverse, both on demand from ObjectTransformation
63cdf0e10cSrcweir             // and ViewTransformation
64cdf0e10cSrcweir             basegfx::B2DHomMatrix                       maObjectToViewTransformation;
65cdf0e10cSrcweir             basegfx::B2DHomMatrix                       maInverseObjectToViewTransformation;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir             // the visible range and the on-demand one in ViewCoordinates
68cdf0e10cSrcweir             basegfx::B2DRange                           maViewport;
69cdf0e10cSrcweir             basegfx::B2DRange                           maDiscreteViewport;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir             // the DrawPage which is target of visualisation. This is needed e.g. for
72cdf0e10cSrcweir             // the view-dependent decomposition of PageNumber TextFields.
73cdf0e10cSrcweir             // This parameter is buffered here, but mainly resides in mxExtendedInformation,
74cdf0e10cSrcweir             // so it will be interpreted, but held there. It will also not be added
75cdf0e10cSrcweir             // to mxExtendedInformation in impFillViewInformationFromContent (it's there already)
76cdf0e10cSrcweir             uno::Reference< drawing::XDrawPage >        mxVisualizedPage;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir             // the point in time
79cdf0e10cSrcweir             double                                      mfViewTime;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir             // bitfield
82cdf0e10cSrcweir             bool                                        mbReducedDisplayQuality : 1;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir             // the complete PropertyValue representation (if already created)
85cdf0e10cSrcweir             uno::Sequence< beans::PropertyValue >       mxViewInformation;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir             // the extra PropertyValues; not represented by ViewTransformation,
88cdf0e10cSrcweir             // Viewport, VisualizedPage or ViewTime
89cdf0e10cSrcweir             uno::Sequence< beans::PropertyValue >       mxExtendedInformation;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir             // the local UNO API strings
getNamePropertyObjectTransformation()92cdf0e10cSrcweir             const ::rtl::OUString& getNamePropertyObjectTransformation()
93cdf0e10cSrcweir             {
94cdf0e10cSrcweir                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("ObjectTransformation"));
95cdf0e10cSrcweir                 return s_sNameProperty;
96cdf0e10cSrcweir             }
97cdf0e10cSrcweir 
getNamePropertyViewTransformation()98cdf0e10cSrcweir             const ::rtl::OUString& getNamePropertyViewTransformation()
99cdf0e10cSrcweir             {
100cdf0e10cSrcweir                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("ViewTransformation"));
101cdf0e10cSrcweir                 return s_sNameProperty;
102cdf0e10cSrcweir             }
103cdf0e10cSrcweir 
getNamePropertyViewport()104cdf0e10cSrcweir             const ::rtl::OUString& getNamePropertyViewport()
105cdf0e10cSrcweir             {
106cdf0e10cSrcweir                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("Viewport"));
107cdf0e10cSrcweir                 return s_sNameProperty;
108cdf0e10cSrcweir             }
109cdf0e10cSrcweir 
getNamePropertyTime()110cdf0e10cSrcweir             const ::rtl::OUString& getNamePropertyTime()
111cdf0e10cSrcweir             {
112cdf0e10cSrcweir                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("Time"));
113cdf0e10cSrcweir                 return s_sNameProperty;
114cdf0e10cSrcweir             }
115cdf0e10cSrcweir 
getNamePropertyVisualizedPage()116cdf0e10cSrcweir             const ::rtl::OUString& getNamePropertyVisualizedPage()
117cdf0e10cSrcweir             {
118cdf0e10cSrcweir                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("VisualizedPage"));
119cdf0e10cSrcweir                 return s_sNameProperty;
120cdf0e10cSrcweir             }
121cdf0e10cSrcweir 
getNamePropertyReducedDisplayQuality()122cdf0e10cSrcweir             const ::rtl::OUString& getNamePropertyReducedDisplayQuality()
123cdf0e10cSrcweir             {
124cdf0e10cSrcweir                 static ::rtl::OUString s_sNameProperty(RTL_CONSTASCII_USTRINGPARAM("ReducedDisplayQuality"));
125cdf0e10cSrcweir                 return s_sNameProperty;
126cdf0e10cSrcweir             }
127cdf0e10cSrcweir 
impInterpretPropertyValues(const uno::Sequence<beans::PropertyValue> & rViewParameters)128cdf0e10cSrcweir             void impInterpretPropertyValues(const uno::Sequence< beans::PropertyValue >& rViewParameters)
129cdf0e10cSrcweir             {
130cdf0e10cSrcweir                 if(rViewParameters.hasElements())
131cdf0e10cSrcweir                 {
132cdf0e10cSrcweir                     const sal_Int32 nCount(rViewParameters.getLength());
133cdf0e10cSrcweir                     sal_Int32 nExtendedInsert(0);
134cdf0e10cSrcweir 
135cdf0e10cSrcweir                     // prepare extended information for filtering. Maximum size is nCount
136cdf0e10cSrcweir                     mxExtendedInformation.realloc(nCount);
137cdf0e10cSrcweir 
138cdf0e10cSrcweir                     for(sal_Int32 a(0); a < nCount; a++)
139cdf0e10cSrcweir                     {
140cdf0e10cSrcweir                         const beans::PropertyValue& rProp = rViewParameters[a];
141cdf0e10cSrcweir 
142cdf0e10cSrcweir                         if(rProp.Name == getNamePropertyReducedDisplayQuality())
143cdf0e10cSrcweir                         {
144cdf0e10cSrcweir                             // extra information; add to filtered information
145cdf0e10cSrcweir                             mxExtendedInformation[nExtendedInsert++] = rProp;
146cdf0e10cSrcweir 
147cdf0e10cSrcweir                             // for performance reasons, also cache content locally
148cdf0e10cSrcweir                             sal_Bool bSalBool(false);
149cdf0e10cSrcweir                             rProp.Value >>= bSalBool;
150cdf0e10cSrcweir                             mbReducedDisplayQuality = bSalBool;
151cdf0e10cSrcweir                         }
152cdf0e10cSrcweir                         else if(rProp.Name == getNamePropertyObjectTransformation())
153cdf0e10cSrcweir                         {
154cdf0e10cSrcweir                             com::sun::star::geometry::AffineMatrix2D aAffineMatrix2D;
155cdf0e10cSrcweir                             rProp.Value >>= aAffineMatrix2D;
156cdf0e10cSrcweir                             basegfx::unotools::homMatrixFromAffineMatrix(maObjectTransformation, aAffineMatrix2D);
157cdf0e10cSrcweir                         }
158cdf0e10cSrcweir                         else if(rProp.Name == getNamePropertyViewTransformation())
159cdf0e10cSrcweir                         {
160cdf0e10cSrcweir                             com::sun::star::geometry::AffineMatrix2D aAffineMatrix2D;
161cdf0e10cSrcweir                             rProp.Value >>= aAffineMatrix2D;
162cdf0e10cSrcweir                             basegfx::unotools::homMatrixFromAffineMatrix(maViewTransformation, aAffineMatrix2D);
163cdf0e10cSrcweir                         }
164cdf0e10cSrcweir                         else if(rProp.Name == getNamePropertyViewport())
165cdf0e10cSrcweir                         {
166cdf0e10cSrcweir                             com::sun::star::geometry::RealRectangle2D aViewport;
167cdf0e10cSrcweir                             rProp.Value >>= aViewport;
168cdf0e10cSrcweir                             maViewport = basegfx::unotools::b2DRectangleFromRealRectangle2D(aViewport);
169cdf0e10cSrcweir                         }
170cdf0e10cSrcweir                         else if(rProp.Name == getNamePropertyTime())
171cdf0e10cSrcweir                         {
172cdf0e10cSrcweir                             rProp.Value >>= mfViewTime;
173cdf0e10cSrcweir                         }
174cdf0e10cSrcweir                         else if(rProp.Name == getNamePropertyVisualizedPage())
175cdf0e10cSrcweir                         {
176cdf0e10cSrcweir                             rProp.Value >>= mxVisualizedPage;
177cdf0e10cSrcweir                         }
178cdf0e10cSrcweir                         else
179cdf0e10cSrcweir                         {
180cdf0e10cSrcweir                             // extra information; add to filtered information
181cdf0e10cSrcweir                             mxExtendedInformation[nExtendedInsert++] = rProp;
182cdf0e10cSrcweir                         }
183cdf0e10cSrcweir                     }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir                     // extra information size is now known; realloc to final size
186cdf0e10cSrcweir                     mxExtendedInformation.realloc(nExtendedInsert);
187cdf0e10cSrcweir                 }
188cdf0e10cSrcweir             }
189cdf0e10cSrcweir 
impFillViewInformationFromContent()190cdf0e10cSrcweir             void impFillViewInformationFromContent()
191cdf0e10cSrcweir             {
192cdf0e10cSrcweir                 uno::Sequence< beans::PropertyValue > xRetval;
193cdf0e10cSrcweir                 const bool bObjectTransformationUsed(!maObjectTransformation.isIdentity());
194cdf0e10cSrcweir                 const bool bViewTransformationUsed(!maViewTransformation.isIdentity());
195cdf0e10cSrcweir                 const bool bViewportUsed(!maViewport.isEmpty());
196cdf0e10cSrcweir                 const bool bTimeUsed(0.0 < mfViewTime);
197cdf0e10cSrcweir                 const bool bVisualizedPageUsed(mxVisualizedPage.is());
198cdf0e10cSrcweir                 const bool bReducedDisplayQualityUsed(true == mbReducedDisplayQuality);
199cdf0e10cSrcweir                 const bool bExtraInformation(mxExtendedInformation.hasElements());
200cdf0e10cSrcweir                 sal_uInt32 nIndex(0);
201cdf0e10cSrcweir                 const sal_uInt32 nCount(
202cdf0e10cSrcweir                     (bObjectTransformationUsed ? 1 : 0) +
203cdf0e10cSrcweir                     (bViewTransformationUsed ? 1 : 0) +
204cdf0e10cSrcweir                     (bViewportUsed ? 1 : 0) +
205cdf0e10cSrcweir                     (bTimeUsed ? 1 : 0) +
206cdf0e10cSrcweir                     (bVisualizedPageUsed ? 1 : 0) +
207cdf0e10cSrcweir                     (bReducedDisplayQualityUsed ? 1 : 0) +
208cdf0e10cSrcweir                     (bExtraInformation ? mxExtendedInformation.getLength() : 0));
209cdf0e10cSrcweir 
210cdf0e10cSrcweir                 mxViewInformation.realloc(nCount);
211cdf0e10cSrcweir 
212cdf0e10cSrcweir                 if(bObjectTransformationUsed)
213cdf0e10cSrcweir                 {
214cdf0e10cSrcweir                     com::sun::star::geometry::AffineMatrix2D aAffineMatrix2D;
215cdf0e10cSrcweir                     basegfx::unotools::affineMatrixFromHomMatrix(aAffineMatrix2D, maObjectTransformation);
216cdf0e10cSrcweir                     mxViewInformation[nIndex].Name = getNamePropertyObjectTransformation();
217cdf0e10cSrcweir                     mxViewInformation[nIndex].Value <<= aAffineMatrix2D;
218cdf0e10cSrcweir                     nIndex++;
219cdf0e10cSrcweir                 }
220cdf0e10cSrcweir 
221cdf0e10cSrcweir                 if(bViewTransformationUsed)
222cdf0e10cSrcweir                 {
223cdf0e10cSrcweir                     com::sun::star::geometry::AffineMatrix2D aAffineMatrix2D;
224cdf0e10cSrcweir                     basegfx::unotools::affineMatrixFromHomMatrix(aAffineMatrix2D, maViewTransformation);
225cdf0e10cSrcweir                     mxViewInformation[nIndex].Name = getNamePropertyViewTransformation();
226cdf0e10cSrcweir                     mxViewInformation[nIndex].Value <<= aAffineMatrix2D;
227cdf0e10cSrcweir                     nIndex++;
228cdf0e10cSrcweir                 }
229cdf0e10cSrcweir 
230cdf0e10cSrcweir                 if(bViewportUsed)
231cdf0e10cSrcweir                 {
232cdf0e10cSrcweir                     const com::sun::star::geometry::RealRectangle2D aViewport(basegfx::unotools::rectangle2DFromB2DRectangle(maViewport));
233cdf0e10cSrcweir                     mxViewInformation[nIndex].Name = getNamePropertyViewport();
234cdf0e10cSrcweir                     mxViewInformation[nIndex].Value <<= aViewport;
235cdf0e10cSrcweir                     nIndex++;
236cdf0e10cSrcweir                 }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir                 if(bTimeUsed)
239cdf0e10cSrcweir                 {
240cdf0e10cSrcweir                     mxViewInformation[nIndex].Name = getNamePropertyTime();
241cdf0e10cSrcweir                     mxViewInformation[nIndex].Value <<= mfViewTime;
242cdf0e10cSrcweir                     nIndex++;
243cdf0e10cSrcweir                 }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir                 if(bVisualizedPageUsed)
246cdf0e10cSrcweir                 {
247cdf0e10cSrcweir                     mxViewInformation[nIndex].Name = getNamePropertyVisualizedPage();
248cdf0e10cSrcweir                     mxViewInformation[nIndex].Value <<= mxVisualizedPage;
249cdf0e10cSrcweir                     nIndex++;
250cdf0e10cSrcweir                 }
251cdf0e10cSrcweir 
252cdf0e10cSrcweir                 if(bExtraInformation)
253cdf0e10cSrcweir                 {
254cdf0e10cSrcweir                     const sal_Int32 nExtra(mxExtendedInformation.getLength());
255cdf0e10cSrcweir 
256cdf0e10cSrcweir                     for(sal_Int32 a(0); a < nExtra; a++)
257cdf0e10cSrcweir                     {
258cdf0e10cSrcweir                         mxViewInformation[nIndex++] = mxExtendedInformation[a];
259cdf0e10cSrcweir                     }
260cdf0e10cSrcweir                 }
261cdf0e10cSrcweir             }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir         public:
ImpViewInformation2D(const basegfx::B2DHomMatrix & rObjectTransformation,const basegfx::B2DHomMatrix & rViewTransformation,const basegfx::B2DRange & rViewport,const uno::Reference<drawing::XDrawPage> & rxDrawPage,double fViewTime,const uno::Sequence<beans::PropertyValue> & rExtendedParameters)264cdf0e10cSrcweir             ImpViewInformation2D(
265cdf0e10cSrcweir                 const basegfx::B2DHomMatrix& rObjectTransformation,
266cdf0e10cSrcweir                 const basegfx::B2DHomMatrix& rViewTransformation,
267cdf0e10cSrcweir                 const basegfx::B2DRange& rViewport,
268cdf0e10cSrcweir                 const uno::Reference< drawing::XDrawPage >& rxDrawPage,
269cdf0e10cSrcweir                 double fViewTime,
270cdf0e10cSrcweir                 const uno::Sequence< beans::PropertyValue >& rExtendedParameters)
271cdf0e10cSrcweir             :   mnRefCount(0),
272cdf0e10cSrcweir                 maObjectTransformation(rObjectTransformation),
273cdf0e10cSrcweir                 maViewTransformation(rViewTransformation),
274cdf0e10cSrcweir                 maObjectToViewTransformation(),
275cdf0e10cSrcweir                 maInverseObjectToViewTransformation(),
276cdf0e10cSrcweir                 maViewport(rViewport),
277cdf0e10cSrcweir                 maDiscreteViewport(),
278cdf0e10cSrcweir                 mxVisualizedPage(rxDrawPage),
279cdf0e10cSrcweir                 mfViewTime(fViewTime),
280cdf0e10cSrcweir                 mbReducedDisplayQuality(false),
281cdf0e10cSrcweir                 mxViewInformation(),
282cdf0e10cSrcweir                 mxExtendedInformation()
283cdf0e10cSrcweir             {
284cdf0e10cSrcweir                 impInterpretPropertyValues(rExtendedParameters);
285cdf0e10cSrcweir             }
286cdf0e10cSrcweir 
ImpViewInformation2D(const uno::Sequence<beans::PropertyValue> & rViewParameters)287cdf0e10cSrcweir             ImpViewInformation2D(const uno::Sequence< beans::PropertyValue >& rViewParameters)
288cdf0e10cSrcweir             :   mnRefCount(0),
289cdf0e10cSrcweir                 maObjectTransformation(),
290cdf0e10cSrcweir                 maViewTransformation(),
291cdf0e10cSrcweir                 maObjectToViewTransformation(),
292cdf0e10cSrcweir                 maInverseObjectToViewTransformation(),
293cdf0e10cSrcweir                 maViewport(),
294cdf0e10cSrcweir                 maDiscreteViewport(),
295cdf0e10cSrcweir                 mxVisualizedPage(),
296cdf0e10cSrcweir                 mfViewTime(),
297cdf0e10cSrcweir                 mbReducedDisplayQuality(false),
298cdf0e10cSrcweir                 mxViewInformation(rViewParameters),
299cdf0e10cSrcweir                 mxExtendedInformation()
300cdf0e10cSrcweir             {
301cdf0e10cSrcweir                 impInterpretPropertyValues(rViewParameters);
302cdf0e10cSrcweir             }
303cdf0e10cSrcweir 
ImpViewInformation2D()304cdf0e10cSrcweir             ImpViewInformation2D()
305cdf0e10cSrcweir             :   mnRefCount(0),
306cdf0e10cSrcweir                 maObjectTransformation(),
307cdf0e10cSrcweir                 maViewTransformation(),
308cdf0e10cSrcweir                 maObjectToViewTransformation(),
309cdf0e10cSrcweir                 maInverseObjectToViewTransformation(),
310cdf0e10cSrcweir                 maViewport(),
311cdf0e10cSrcweir                 maDiscreteViewport(),
312cdf0e10cSrcweir                 mxVisualizedPage(),
313cdf0e10cSrcweir                 mfViewTime(),
314cdf0e10cSrcweir                 mbReducedDisplayQuality(false),
315cdf0e10cSrcweir                 mxViewInformation(),
316cdf0e10cSrcweir                 mxExtendedInformation()
317cdf0e10cSrcweir             {
318cdf0e10cSrcweir             }
319cdf0e10cSrcweir 
getObjectTransformation() const320cdf0e10cSrcweir             const basegfx::B2DHomMatrix& getObjectTransformation() const
321cdf0e10cSrcweir             {
322cdf0e10cSrcweir                 return maObjectTransformation;
323cdf0e10cSrcweir             }
324cdf0e10cSrcweir 
getViewTransformation() const325cdf0e10cSrcweir             const basegfx::B2DHomMatrix& getViewTransformation() const
326cdf0e10cSrcweir             {
327cdf0e10cSrcweir                 return maViewTransformation;
328cdf0e10cSrcweir             }
329cdf0e10cSrcweir 
getViewport() const330cdf0e10cSrcweir             const basegfx::B2DRange& getViewport() const
331cdf0e10cSrcweir             {
332cdf0e10cSrcweir                 return maViewport;
333cdf0e10cSrcweir             }
334cdf0e10cSrcweir 
getDiscreteViewport() const335cdf0e10cSrcweir             const basegfx::B2DRange& getDiscreteViewport() const
336cdf0e10cSrcweir             {
337cdf0e10cSrcweir                 ::osl::Mutex m_mutex;
338cdf0e10cSrcweir 
339cdf0e10cSrcweir                 if(maDiscreteViewport.isEmpty() && !maViewport.isEmpty())
340cdf0e10cSrcweir                 {
341cdf0e10cSrcweir                     basegfx::B2DRange aDiscreteViewport(maViewport);
342cdf0e10cSrcweir                     aDiscreteViewport.transform(getViewTransformation());
343cdf0e10cSrcweir                     const_cast< ImpViewInformation2D* >(this)->maDiscreteViewport = aDiscreteViewport;
344cdf0e10cSrcweir                 }
345cdf0e10cSrcweir 
346cdf0e10cSrcweir                 return maDiscreteViewport;
347cdf0e10cSrcweir             }
348cdf0e10cSrcweir 
getObjectToViewTransformation() const349cdf0e10cSrcweir             const basegfx::B2DHomMatrix& getObjectToViewTransformation() const
350cdf0e10cSrcweir             {
351cdf0e10cSrcweir                 ::osl::Mutex m_mutex;
352cdf0e10cSrcweir 
353cdf0e10cSrcweir                 if(maObjectToViewTransformation.isIdentity() &&
354cdf0e10cSrcweir                     (!maObjectTransformation.isIdentity() || !maViewTransformation.isIdentity()))
355cdf0e10cSrcweir                 {
356cdf0e10cSrcweir                     basegfx::B2DHomMatrix aObjectToView(maViewTransformation * maObjectTransformation);
357cdf0e10cSrcweir                     const_cast< ImpViewInformation2D* >(this)->maObjectToViewTransformation = aObjectToView;
358cdf0e10cSrcweir                 }
359cdf0e10cSrcweir 
360cdf0e10cSrcweir                 return maObjectToViewTransformation;
361cdf0e10cSrcweir             }
362cdf0e10cSrcweir 
getInverseObjectToViewTransformation() const363cdf0e10cSrcweir             const basegfx::B2DHomMatrix& getInverseObjectToViewTransformation() const
364cdf0e10cSrcweir             {
365cdf0e10cSrcweir                 ::osl::Mutex m_mutex;
366cdf0e10cSrcweir 
367cdf0e10cSrcweir                 if(maInverseObjectToViewTransformation.isIdentity() &&
368cdf0e10cSrcweir                     (!maObjectTransformation.isIdentity() || !maViewTransformation.isIdentity()))
369cdf0e10cSrcweir                 {
370cdf0e10cSrcweir                     basegfx::B2DHomMatrix aInverseObjectToView(maViewTransformation * maObjectTransformation);
371cdf0e10cSrcweir                     aInverseObjectToView.invert();
372cdf0e10cSrcweir                     const_cast< ImpViewInformation2D* >(this)->maInverseObjectToViewTransformation = aInverseObjectToView;
373cdf0e10cSrcweir                 }
374cdf0e10cSrcweir 
375cdf0e10cSrcweir                 return maInverseObjectToViewTransformation;
376cdf0e10cSrcweir             }
377cdf0e10cSrcweir 
getViewTime() const378cdf0e10cSrcweir             double getViewTime() const
379cdf0e10cSrcweir             {
380cdf0e10cSrcweir                 return mfViewTime;
381cdf0e10cSrcweir             }
382cdf0e10cSrcweir 
getVisualizedPage() const383cdf0e10cSrcweir             const uno::Reference< drawing::XDrawPage >& getVisualizedPage() const
384cdf0e10cSrcweir             {
385cdf0e10cSrcweir                 return mxVisualizedPage;
386cdf0e10cSrcweir             }
387cdf0e10cSrcweir 
getReducedDisplayQuality() const388cdf0e10cSrcweir             bool getReducedDisplayQuality() const
389cdf0e10cSrcweir             {
390cdf0e10cSrcweir                 return mbReducedDisplayQuality;
391cdf0e10cSrcweir             }
392cdf0e10cSrcweir 
getViewInformationSequence() const393cdf0e10cSrcweir             const uno::Sequence< beans::PropertyValue >& getViewInformationSequence() const
394cdf0e10cSrcweir             {
395cdf0e10cSrcweir                 if(!mxViewInformation.hasElements())
396cdf0e10cSrcweir                 {
397cdf0e10cSrcweir                     const_cast< ImpViewInformation2D* >(this)->impFillViewInformationFromContent();
398cdf0e10cSrcweir                 }
399cdf0e10cSrcweir 
400cdf0e10cSrcweir                 return mxViewInformation;
401cdf0e10cSrcweir             }
402cdf0e10cSrcweir 
getExtendedInformationSequence() const403cdf0e10cSrcweir             const uno::Sequence< beans::PropertyValue >& getExtendedInformationSequence() const
404cdf0e10cSrcweir             {
405cdf0e10cSrcweir                 return mxExtendedInformation;
406cdf0e10cSrcweir             }
407cdf0e10cSrcweir 
operator ==(const ImpViewInformation2D & rCandidate) const408cdf0e10cSrcweir             bool operator==(const ImpViewInformation2D& rCandidate) const
409cdf0e10cSrcweir             {
410cdf0e10cSrcweir                 return (maObjectTransformation == rCandidate.maObjectTransformation
411cdf0e10cSrcweir                     && maViewTransformation == rCandidate.maViewTransformation
412cdf0e10cSrcweir                     && maViewport == rCandidate.maViewport
413cdf0e10cSrcweir                     && mxVisualizedPage == rCandidate.mxVisualizedPage
414cdf0e10cSrcweir                     && mfViewTime == rCandidate.mfViewTime
415cdf0e10cSrcweir                     && mxExtendedInformation == rCandidate.mxExtendedInformation);
416cdf0e10cSrcweir             }
417cdf0e10cSrcweir 
get_global_default()418cdf0e10cSrcweir             static ImpViewInformation2D* get_global_default()
419cdf0e10cSrcweir             {
420cdf0e10cSrcweir                 static ImpViewInformation2D* pDefault = 0;
421cdf0e10cSrcweir 
422cdf0e10cSrcweir                 if(!pDefault)
423cdf0e10cSrcweir                 {
424cdf0e10cSrcweir                     pDefault = new ImpViewInformation2D();
425cdf0e10cSrcweir 
426cdf0e10cSrcweir                     // never delete; start with RefCount 1, not 0
427cdf0e10cSrcweir                     pDefault->mnRefCount++;
428cdf0e10cSrcweir                 }
429cdf0e10cSrcweir 
430cdf0e10cSrcweir                 return pDefault;
431cdf0e10cSrcweir             }
432cdf0e10cSrcweir         };
433cdf0e10cSrcweir     } // end of anonymous namespace
434cdf0e10cSrcweir } // end of namespace drawinglayer
435cdf0e10cSrcweir 
436cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
437cdf0e10cSrcweir 
438cdf0e10cSrcweir namespace drawinglayer
439cdf0e10cSrcweir {
440cdf0e10cSrcweir     namespace geometry
441cdf0e10cSrcweir     {
ViewInformation2D(const basegfx::B2DHomMatrix & rObjectTransformation,const basegfx::B2DHomMatrix & rViewTransformation,const basegfx::B2DRange & rViewport,const uno::Reference<drawing::XDrawPage> & rxDrawPage,double fViewTime,const uno::Sequence<beans::PropertyValue> & rExtendedParameters)442cdf0e10cSrcweir         ViewInformation2D::ViewInformation2D(
443cdf0e10cSrcweir             const basegfx::B2DHomMatrix& rObjectTransformation,
444cdf0e10cSrcweir             const basegfx::B2DHomMatrix& rViewTransformation,
445cdf0e10cSrcweir             const basegfx::B2DRange& rViewport,
446cdf0e10cSrcweir             const uno::Reference< drawing::XDrawPage >& rxDrawPage,
447cdf0e10cSrcweir             double fViewTime,
448cdf0e10cSrcweir             const uno::Sequence< beans::PropertyValue >& rExtendedParameters)
449cdf0e10cSrcweir         :   mpViewInformation2D(new ImpViewInformation2D(
450cdf0e10cSrcweir                 rObjectTransformation,
451cdf0e10cSrcweir                 rViewTransformation,
452cdf0e10cSrcweir                 rViewport,
453cdf0e10cSrcweir                 rxDrawPage,
454cdf0e10cSrcweir                 fViewTime,
455cdf0e10cSrcweir                 rExtendedParameters))
456cdf0e10cSrcweir         {
457cdf0e10cSrcweir         }
458cdf0e10cSrcweir 
ViewInformation2D(const uno::Sequence<beans::PropertyValue> & rViewParameters)459cdf0e10cSrcweir         ViewInformation2D::ViewInformation2D(const uno::Sequence< beans::PropertyValue >& rViewParameters)
460cdf0e10cSrcweir         :   mpViewInformation2D(new ImpViewInformation2D(rViewParameters))
461cdf0e10cSrcweir         {
462cdf0e10cSrcweir         }
463cdf0e10cSrcweir 
ViewInformation2D()464cdf0e10cSrcweir         ViewInformation2D::ViewInformation2D()
465cdf0e10cSrcweir         :   mpViewInformation2D(ImpViewInformation2D::get_global_default())
466cdf0e10cSrcweir         {
467cdf0e10cSrcweir             mpViewInformation2D->mnRefCount++;
468cdf0e10cSrcweir         }
469cdf0e10cSrcweir 
ViewInformation2D(const ViewInformation2D & rCandidate)470cdf0e10cSrcweir         ViewInformation2D::ViewInformation2D(const ViewInformation2D& rCandidate)
471cdf0e10cSrcweir         :   mpViewInformation2D(rCandidate.mpViewInformation2D)
472cdf0e10cSrcweir         {
473cdf0e10cSrcweir             ::osl::Mutex m_mutex;
474cdf0e10cSrcweir             mpViewInformation2D->mnRefCount++;
475cdf0e10cSrcweir         }
476cdf0e10cSrcweir 
~ViewInformation2D()477cdf0e10cSrcweir         ViewInformation2D::~ViewInformation2D()
478cdf0e10cSrcweir         {
479cdf0e10cSrcweir             ::osl::Mutex m_mutex;
480cdf0e10cSrcweir 
481cdf0e10cSrcweir             if(mpViewInformation2D->mnRefCount)
482cdf0e10cSrcweir             {
483cdf0e10cSrcweir                 mpViewInformation2D->mnRefCount--;
484cdf0e10cSrcweir             }
485cdf0e10cSrcweir             else
486cdf0e10cSrcweir             {
487cdf0e10cSrcweir                 delete mpViewInformation2D;
488cdf0e10cSrcweir             }
489cdf0e10cSrcweir         }
490cdf0e10cSrcweir 
isDefault() const491cdf0e10cSrcweir         bool ViewInformation2D::isDefault() const
492cdf0e10cSrcweir         {
493cdf0e10cSrcweir             return mpViewInformation2D == ImpViewInformation2D::get_global_default();
494cdf0e10cSrcweir         }
495cdf0e10cSrcweir 
operator =(const ViewInformation2D & rCandidate)496cdf0e10cSrcweir         ViewInformation2D& ViewInformation2D::operator=(const ViewInformation2D& rCandidate)
497cdf0e10cSrcweir         {
498cdf0e10cSrcweir             ::osl::Mutex m_mutex;
499cdf0e10cSrcweir 
500cdf0e10cSrcweir             if(mpViewInformation2D->mnRefCount)
501cdf0e10cSrcweir             {
502cdf0e10cSrcweir                 mpViewInformation2D->mnRefCount--;
503cdf0e10cSrcweir             }
504cdf0e10cSrcweir             else
505cdf0e10cSrcweir             {
506cdf0e10cSrcweir                 delete mpViewInformation2D;
507cdf0e10cSrcweir             }
508cdf0e10cSrcweir 
509cdf0e10cSrcweir             mpViewInformation2D = rCandidate.mpViewInformation2D;
510cdf0e10cSrcweir             mpViewInformation2D->mnRefCount++;
511cdf0e10cSrcweir 
512cdf0e10cSrcweir             return *this;
513cdf0e10cSrcweir         }
514cdf0e10cSrcweir 
operator ==(const ViewInformation2D & rCandidate) const515cdf0e10cSrcweir         bool ViewInformation2D::operator==(const ViewInformation2D& rCandidate) const
516cdf0e10cSrcweir         {
517cdf0e10cSrcweir             if(rCandidate.mpViewInformation2D == mpViewInformation2D)
518cdf0e10cSrcweir             {
519cdf0e10cSrcweir                 return true;
520cdf0e10cSrcweir             }
521cdf0e10cSrcweir 
522cdf0e10cSrcweir             if(rCandidate.isDefault() != isDefault())
523cdf0e10cSrcweir             {
524cdf0e10cSrcweir                 return false;
525cdf0e10cSrcweir             }
526cdf0e10cSrcweir 
527cdf0e10cSrcweir             return (*rCandidate.mpViewInformation2D == *mpViewInformation2D);
528cdf0e10cSrcweir         }
529cdf0e10cSrcweir 
getObjectTransformation() const530cdf0e10cSrcweir         const basegfx::B2DHomMatrix& ViewInformation2D::getObjectTransformation() const
531cdf0e10cSrcweir         {
532cdf0e10cSrcweir             return mpViewInformation2D->getObjectTransformation();
533cdf0e10cSrcweir         }
534cdf0e10cSrcweir 
getViewTransformation() const535cdf0e10cSrcweir         const basegfx::B2DHomMatrix& ViewInformation2D::getViewTransformation() const
536cdf0e10cSrcweir         {
537cdf0e10cSrcweir             return mpViewInformation2D->getViewTransformation();
538cdf0e10cSrcweir         }
539cdf0e10cSrcweir 
getViewport() const540cdf0e10cSrcweir         const basegfx::B2DRange& ViewInformation2D::getViewport() const
541cdf0e10cSrcweir         {
542cdf0e10cSrcweir             return mpViewInformation2D->getViewport();
543cdf0e10cSrcweir         }
544cdf0e10cSrcweir 
getViewTime() const545cdf0e10cSrcweir         double ViewInformation2D::getViewTime() const
546cdf0e10cSrcweir         {
547cdf0e10cSrcweir             return mpViewInformation2D->getViewTime();
548cdf0e10cSrcweir         }
549cdf0e10cSrcweir 
getVisualizedPage() const550cdf0e10cSrcweir         const uno::Reference< drawing::XDrawPage >& ViewInformation2D::getVisualizedPage() const
551cdf0e10cSrcweir         {
552cdf0e10cSrcweir             return mpViewInformation2D->getVisualizedPage();
553cdf0e10cSrcweir         }
554cdf0e10cSrcweir 
getObjectToViewTransformation() const555cdf0e10cSrcweir         const basegfx::B2DHomMatrix& ViewInformation2D::getObjectToViewTransformation() const
556cdf0e10cSrcweir         {
557cdf0e10cSrcweir             return mpViewInformation2D->getObjectToViewTransformation();
558cdf0e10cSrcweir         }
559cdf0e10cSrcweir 
getInverseObjectToViewTransformation() const560cdf0e10cSrcweir         const basegfx::B2DHomMatrix& ViewInformation2D::getInverseObjectToViewTransformation() const
561cdf0e10cSrcweir         {
562cdf0e10cSrcweir             return mpViewInformation2D->getInverseObjectToViewTransformation();
563cdf0e10cSrcweir         }
564cdf0e10cSrcweir 
getDiscreteViewport() const565cdf0e10cSrcweir         const basegfx::B2DRange& ViewInformation2D::getDiscreteViewport() const
566cdf0e10cSrcweir         {
567cdf0e10cSrcweir             return mpViewInformation2D->getDiscreteViewport();
568cdf0e10cSrcweir         }
569cdf0e10cSrcweir 
getReducedDisplayQuality() const570cdf0e10cSrcweir         bool ViewInformation2D::getReducedDisplayQuality() const
571cdf0e10cSrcweir         {
572cdf0e10cSrcweir             return mpViewInformation2D->getReducedDisplayQuality();
573cdf0e10cSrcweir         }
574cdf0e10cSrcweir 
getViewInformationSequence() const575cdf0e10cSrcweir         const uno::Sequence< beans::PropertyValue >& ViewInformation2D::getViewInformationSequence() const
576cdf0e10cSrcweir         {
577cdf0e10cSrcweir             return mpViewInformation2D->getViewInformationSequence();
578cdf0e10cSrcweir         }
579cdf0e10cSrcweir 
getExtendedInformationSequence() const580cdf0e10cSrcweir         const uno::Sequence< beans::PropertyValue >& ViewInformation2D::getExtendedInformationSequence() const
581cdf0e10cSrcweir         {
582cdf0e10cSrcweir             return mpViewInformation2D->getExtendedInformationSequence();
583cdf0e10cSrcweir         }
584cdf0e10cSrcweir     } // end of namespace geometry
585cdf0e10cSrcweir } // end of namespace drawinglayer
586cdf0e10cSrcweir 
587cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
588cdf0e10cSrcweir // eof
589