1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PAGEPREVIEWPRIMITIVE2D_HXX
25 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PAGEPREVIEWPRIMITIVE2D_HXX
26 
27 #include <drawinglayer/drawinglayerdllapi.h>
28 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
29 #include <com/sun/star/drawing/XDrawPage.hpp>
30 #include <basegfx/matrix/b2dhommatrix.hxx>
31 
32 //////////////////////////////////////////////////////////////////////////////
33 
34 namespace drawinglayer
35 {
36 	namespace primitive2d
37 	{
38         /** PagePreviewPrimitive2D class
39 
40             This primitive is needed to have the correct XDrawPage as ViewInformation for decomposing
41             the page contents (given as PageContent here) if these contain e.g.
42             view-dependent (in this case XDrawPage-dependent) text fields like PageNumber. If You want
43             those primitives to be visualized correctly, Your renderer needs to locally correct it's
44             ViewInformation2D to reference the new XDrawPage.
45          */
46 		class DRAWINGLAYER_DLLPUBLIC PagePreviewPrimitive2D : public BufferedDecompositionPrimitive2D
47 		{
48 		private:
49             /** the XDrawPage visualized by this primitive. When we go forward with primitives
50 			    this will not only be used by the renderers to provide the correct decompose
51 			    graphic attribute context, but also to completely create the page's sub-content.
52              */
53             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mxDrawPage;
54 
55             /// the PageContent
56             Primitive2DSequence                         maPageContent;
57 
58             /// the own geometry
59 			basegfx::B2DHomMatrix						maTransform;
60 
61             /// content width and height
62             double                                      mfContentWidth;
63             double                                      mfContentHeight;
64 
65 			/// bitfield
66 			/// flag to allow keeping the aspect ratio
67 			unsigned									mbKeepAspectRatio : 1;
68 
69 		protected:
70 			/// local decomposition. Implementation will just return children
71 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
72 
73         public:
74             /// constructor
75 			PagePreviewPrimitive2D(
76                 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage,
77                 const basegfx::B2DHomMatrix& rTransform,
78                 double fContentWidth,
79                 double fContentHeight,
80 				const Primitive2DSequence& rPageContent,
81 				bool bKeepAspectRatio);
82 
83 			/// data read access
getXDrawPage() const84             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& getXDrawPage() const { return mxDrawPage; }
getPageContent() const85             const Primitive2DSequence& getPageContent() const { return maPageContent; }
getTransform() const86             const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
getContentWidth() const87             double getContentWidth() const { return mfContentWidth; }
getContentHeight() const88             double getContentHeight() const { return mfContentHeight; }
getKeepAspectRatio() const89 			bool getKeepAspectRatio() const { return mbKeepAspectRatio; }
90 
91 			/// compare operator
92 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
93 
94 			/// own getB2DRange
95 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
96 
97             /// provide unique ID
98 			DeclPrimitrive2DIDBlock()
99 		};
100 	} // end of namespace primitive2d
101 } // end of namespace drawinglayer
102 
103 //////////////////////////////////////////////////////////////////////////////
104 
105 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PAGEPREVIEWPRIMITIVE2D_HXX
106 
107 //////////////////////////////////////////////////////////////////////////////
108 // eof
109