merge the formfield patch from ooo-build
[ooovba.git] / svx / source / sdr / overlay / overlayanimatedbitmapex.cxx
blob7ea78b6d4c4f8188c7044e7faf81c8a02373a5d4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: overlayanimatedbitmapex.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <svx/sdr/overlay/overlayanimatedbitmapex.hxx>
34 #include <vcl/salbtype.hxx>
35 #include <vcl/outdev.hxx>
36 #include <svx/sdr/overlay/overlaymanager.hxx>
37 #include <basegfx/matrix/b2dhommatrix.hxx>
38 #include <svx/sdr/overlay/overlaytools.hxx>
40 //////////////////////////////////////////////////////////////////////////////
42 namespace sdr
44 namespace overlay
46 // #i53216# check blink time value range
47 void OverlayAnimatedBitmapEx::impCheckBlinkTimeValueRange()
49 if(mnBlinkTime < 25)
51 mnBlinkTime = 25;
53 else if(mnBlinkTime > 10000)
55 mnBlinkTime = 10000;
59 drawinglayer::primitive2d::Primitive2DSequence OverlayAnimatedBitmapEx::createOverlayObjectPrimitive2DSequence()
61 if(mbOverlayState)
63 const drawinglayer::primitive2d::Primitive2DReference aPrimitive(
64 new drawinglayer::primitive2d::OverlayBitmapExPrimitive(
65 getBitmapEx1(),
66 getBasePosition(),
67 getCenterX1(),
68 getCenterY1()));
70 return drawinglayer::primitive2d::Primitive2DSequence(&aPrimitive, 1);
72 else
74 const drawinglayer::primitive2d::Primitive2DReference aPrimitive(
75 new drawinglayer::primitive2d::OverlayBitmapExPrimitive(
76 getBitmapEx2(),
77 getBasePosition(),
78 getCenterX2(),
79 getCenterY2()));
81 return drawinglayer::primitive2d::Primitive2DSequence(&aPrimitive, 1);
85 OverlayAnimatedBitmapEx::OverlayAnimatedBitmapEx(
86 const basegfx::B2DPoint& rBasePos,
87 const BitmapEx& rBitmapEx1,
88 const BitmapEx& rBitmapEx2,
89 sal_uInt32 nBlinkTime,
90 sal_uInt16 nCenX1,
91 sal_uInt16 nCenY1,
92 sal_uInt16 nCenX2,
93 sal_uInt16 nCenY2)
94 : OverlayObjectWithBasePosition(rBasePos, Color(COL_WHITE)),
95 maBitmapEx1(rBitmapEx1),
96 maBitmapEx2(rBitmapEx2),
97 mnCenterX1(nCenX1), mnCenterY1(nCenY1),
98 mnCenterX2(nCenX2), mnCenterY2(nCenY2),
99 mnBlinkTime(nBlinkTime),
100 mbOverlayState(false)
102 // set AllowsAnimation flag to mark this object as animation capable
103 mbAllowsAnimation = true;
105 // #i53216# check blink time value range
106 impCheckBlinkTimeValueRange();
109 OverlayAnimatedBitmapEx::~OverlayAnimatedBitmapEx()
113 void OverlayAnimatedBitmapEx::setBitmapEx1(const BitmapEx& rNew)
115 if(rNew != maBitmapEx1)
117 // remember new Bitmap
118 maBitmapEx1 = rNew;
120 // register change (after change)
121 objectChange();
125 void OverlayAnimatedBitmapEx::setBitmapEx2(const BitmapEx& rNew)
127 if(rNew != maBitmapEx2)
129 // remember new Bitmap
130 maBitmapEx2 = rNew;
132 // register change (after change)
133 objectChange();
137 void OverlayAnimatedBitmapEx::setCenterXY1(sal_uInt16 nNewX, sal_uInt16 nNewY)
139 if(nNewX != mnCenterX1 || nNewY != mnCenterY1)
141 // remember new values
142 if(nNewX != mnCenterX1)
144 mnCenterX1 = nNewX;
147 if(nNewY != mnCenterY1)
149 mnCenterY1 = nNewY;
152 // register change (after change)
153 objectChange();
157 void OverlayAnimatedBitmapEx::setCenterXY2(sal_uInt16 nNewX, sal_uInt16 nNewY)
159 if(nNewX != mnCenterX2 || nNewY != mnCenterY2)
161 // remember new values
162 if(nNewX != mnCenterX2)
164 mnCenterX2 = nNewX;
167 if(nNewY != mnCenterY2)
169 mnCenterY2 = nNewY;
172 // register change (after change)
173 objectChange();
177 void OverlayAnimatedBitmapEx::setBlinkTime(sal_uInt32 nNew)
179 if(mnBlinkTime != nNew)
181 // remember new value
182 mnBlinkTime = nNew;
184 // #i53216# check blink time value range
185 impCheckBlinkTimeValueRange();
187 // register change (after change)
188 objectChange();
192 void OverlayAnimatedBitmapEx::Trigger(sal_uInt32 nTime)
194 if(getOverlayManager())
196 // #i53216# produce event after nTime + x
197 SetTime(nTime + mnBlinkTime);
199 // switch state
200 if(mbOverlayState)
202 mbOverlayState = false;
204 else
206 mbOverlayState = true;
209 // re-insert me as event
210 getOverlayManager()->InsertEvent(this);
212 // register change (after change)
213 objectChange();
216 } // end of namespace overlay
217 } // end of namespace sdr
219 //////////////////////////////////////////////////////////////////////////////
220 // eof