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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
27 #include <svx/sdr/overlay/overlaybitmapex.hxx>
28 #include <vcl/salbtype.hxx>
29 #include <vcl/outdev.hxx>
30 #include <basegfx/matrix/b2dhommatrix.hxx>
31 #include <svx/sdr/overlay/overlaytools.hxx>
32 
33 //////////////////////////////////////////////////////////////////////////////
34 
35 namespace sdr
36 {
37 	namespace overlay
38 	{
createOverlayObjectPrimitive2DSequence()39 		drawinglayer::primitive2d::Primitive2DSequence OverlayBitmapEx::createOverlayObjectPrimitive2DSequence()
40 		{
41             drawinglayer::primitive2d::Primitive2DReference aReference(
42                 new drawinglayer::primitive2d::OverlayBitmapExPrimitive(
43                     getBitmapEx(),
44                     getBasePosition(),
45                     getCenterX(),
46                     getCenterY(),
47                     getShearX(),
48                     getRotation()));
49 
50 			if(basegfx::fTools::more(mfAlpha, 0.0))
51 			{
52 				const drawinglayer::primitive2d::Primitive2DSequence aNewTransPrimitiveVector(&aReference, 1L);
53 				aReference = drawinglayer::primitive2d::Primitive2DReference(
54 				                new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(aNewTransPrimitiveVector, mfAlpha));
55 			}
56 
57             return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
58 		}
59 
OverlayBitmapEx(const basegfx::B2DPoint & rBasePos,const BitmapEx & rBitmapEx,sal_uInt16 nCenX,sal_uInt16 nCenY,double fAlpha,double fShearX,double fRotation)60         OverlayBitmapEx::OverlayBitmapEx(
61             const basegfx::B2DPoint& rBasePos,
62             const BitmapEx& rBitmapEx,
63             sal_uInt16 nCenX,
64             sal_uInt16 nCenY,
65             double fAlpha,
66             double fShearX,
67             double fRotation)
68         :   OverlayObjectWithBasePosition(rBasePos, Color(COL_WHITE)),
69             maBitmapEx(rBitmapEx),
70             mnCenterX(nCenX),
71             mnCenterY(nCenY),
72             mfAlpha(fAlpha),
73             mfShearX(fShearX),
74             mfRotation(fRotation)
75         {
76         }
77 
~OverlayBitmapEx()78 		OverlayBitmapEx::~OverlayBitmapEx()
79 		{
80 		}
81 
setBitmapEx(const BitmapEx & rNew)82 		void OverlayBitmapEx::setBitmapEx(const BitmapEx& rNew)
83 		{
84 			if(rNew != maBitmapEx)
85 			{
86 				// remember new Bitmap
87 				maBitmapEx = rNew;
88 
89 				// register change (after change)
90 				objectChange();
91 			}
92 		}
93 
setCenterXY(sal_uInt16 nNewX,sal_uInt16 nNewY)94 		void OverlayBitmapEx::setCenterXY(sal_uInt16 nNewX, sal_uInt16 nNewY)
95 		{
96 			if(nNewX != mnCenterX || nNewY != mnCenterY)
97 			{
98 				// remember new values
99 				if(nNewX != mnCenterX)
100 				{
101 					mnCenterX = nNewX;
102 				}
103 
104 				if(nNewY != mnCenterY)
105 				{
106 					mnCenterY = nNewY;
107 				}
108 
109 				// register change (after change)
110 				objectChange();
111 			}
112 		}
113 	} // end of namespace overlay
114 } // end of namespace sdr
115 
116 //////////////////////////////////////////////////////////////////////////////
117 // eof
118