merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / view / overlayobject.cxx
blobe5ff9a0578f4e71cf9042695b80273c744678bf4
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: gridwin.hxx,v $
10 * $Revision: 1.30 $
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_sc.hxx"
34 #include "overlayobject.hxx"
35 #include "vcl/outdev.hxx"
36 #include "vcl/lineinfo.hxx"
37 #include "vcl/salbtype.hxx"
38 #include "vcl/window.hxx"
39 #include "tools/fract.hxx"
40 #include "basegfx/range/b2drange.hxx"
41 #include "basegfx/polygon/b2dpolygon.hxx"
42 #include "basegfx/polygon/b2dpolygontools.hxx"
43 #include "svx/sdr/overlay/overlaymanager.hxx"
44 #include "drawinglayer/primitive2d/baseprimitive2d.hxx"
45 #include "drawinglayer/primitive2d/polypolygonprimitive2d.hxx"
47 using ::sdr::overlay::OverlayObject;
48 using ::sdr::overlay::OverlayManager;
49 using ::drawinglayer::primitive2d::Primitive2DSequence;
51 #define DASH_UPDATE_INTERVAL 180 // in msec
53 ScOverlayDashedBorder::ScOverlayDashedBorder(const ::basegfx::B2DRange& rRange, const Color& rColor, Window* pWin) :
54 OverlayObject(rColor),
55 mpParent(pWin),
56 mbToggle(true)
58 mbAllowsAnimation = true;
59 maRange = rRange;
62 ScOverlayDashedBorder::~ScOverlayDashedBorder()
66 void ScOverlayDashedBorder::Trigger(sal_uInt32 nTime)
68 OverlayManager* pMgr = getOverlayManager();
69 if (pMgr)
71 SetTime(nTime + DASH_UPDATE_INTERVAL);
72 mbToggle = !mbToggle;
73 pMgr->InsertEvent(this);
74 objectChange();
78 void ScOverlayDashedBorder::stripeDefinitionHasChanged()
80 objectChange();
83 Primitive2DSequence ScOverlayDashedBorder::createOverlayObjectPrimitive2DSequence()
85 using ::basegfx::B2DPolygon;
86 using ::basegfx::B2DPolyPolygon;
88 OverlayManager* pMgr = getOverlayManager();
89 if (!pMgr)
90 return Primitive2DSequence();
92 basegfx::BColor aColorA = pMgr->getStripeColorA().getBColor();
93 basegfx::BColor aColorB = pMgr->getStripeColorB().getBColor();
94 if (!mbToggle)
95 ::std::swap(aColorA, aColorB);
97 const basegfx::B2DPolygon aPoly = basegfx::tools::createPolygonFromRect(maRange);
98 B2DPolyPolygon aPolygon(aPoly);
99 const drawinglayer::primitive2d::Primitive2DReference aReference(
100 new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D(
101 aPolygon, aColorA, aColorB, pMgr->getStripeLengthPixel()));
103 return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);