1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 #include <svx/sdr/overlay/overlayline.hxx>
31 #include <tools/gen.hxx>
32 #include <vcl/salbtype.hxx>
33 #include <vcl/outdev.hxx>
34 #include <basegfx/vector/b2dvector.hxx>
35 #include <basegfx/matrix/b2dhommatrix.hxx>
36 #include <basegfx/polygon/b2dpolygontools.hxx>
37 #include <svx/sdr/overlay/overlaymanager.hxx>
38 #include <basegfx/polygon/b2dpolygon.hxx>
39 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
40 
41 //////////////////////////////////////////////////////////////////////////////
42 
43 namespace sdr
44 {
45 	namespace overlay
46 	{
47 		drawinglayer::primitive2d::Primitive2DSequence OverlayLineStriped::createOverlayObjectPrimitive2DSequence()
48 		{
49 			drawinglayer::primitive2d::Primitive2DSequence aRetval;
50 
51             if(getOverlayManager())
52             {
53                 const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor());
54                 const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor());
55                 const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel());
56                 basegfx::B2DPolygon aLine;
57 
58                 aLine.append(getBasePosition());
59                 aLine.append(getSecondPosition());
60 
61                 const drawinglayer::primitive2d::Primitive2DReference aReference(
62                     new drawinglayer::primitive2d::PolygonMarkerPrimitive2D(
63                         aLine,
64                         aRGBColorA,
65                         aRGBColorB,
66                         fStripeLengthPixel));
67 
68                 aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
69             }
70 
71             return aRetval;
72 		}
73 
74 		void OverlayLineStriped::stripeDefinitionHasChanged()
75 		{
76 			// react on OverlayManager's stripe definition change
77 			objectChange();
78 		}
79 
80 		OverlayLineStriped::OverlayLineStriped(
81 			const basegfx::B2DPoint& rBasePos,
82 			const basegfx::B2DPoint& rSecondPos)
83 		:	OverlayObjectWithBasePosition(rBasePos, Color(COL_BLACK)),
84 			maSecondPosition(rSecondPos)
85 		{
86 		}
87 
88 		OverlayLineStriped::~OverlayLineStriped()
89 		{
90 		}
91 
92 		void OverlayLineStriped::setSecondPosition(const basegfx::B2DPoint& rNew)
93 		{
94 			if(rNew != maSecondPosition)
95 			{
96 				// remember new value
97 				maSecondPosition = rNew;
98 
99 				// register change (after change)
100 				objectChange();
101 			}
102 		}
103 	} // end of namespace overlay
104 } // end of namespace sdr
105 
106 //////////////////////////////////////////////////////////////////////////////
107 // eof
108