1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: gridwin.hxx,v $
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
),
58 mbAllowsAnimation
= true;
62 ScOverlayDashedBorder::~ScOverlayDashedBorder()
66 void ScOverlayDashedBorder::Trigger(sal_uInt32 nTime
)
68 OverlayManager
* pMgr
= getOverlayManager();
71 SetTime(nTime
+ DASH_UPDATE_INTERVAL
);
73 pMgr
->InsertEvent(this);
78 void ScOverlayDashedBorder::stripeDefinitionHasChanged()
83 Primitive2DSequence
ScOverlayDashedBorder::createOverlayObjectPrimitive2DSequence()
85 using ::basegfx::B2DPolygon
;
86 using ::basegfx::B2DPolyPolygon
;
88 OverlayManager
* pMgr
= getOverlayManager();
90 return Primitive2DSequence();
92 basegfx::BColor aColorA
= pMgr
->getStripeColorA().getBColor();
93 basegfx::BColor aColorB
= pMgr
->getStripeColorB().getBColor();
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);