xref: /aoo41x/main/sw/source/ui/ribbar/conarc.cxx (revision cdf0e10c)
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_sw.hxx"
30 
31 
32 #include <svx/svdobj.hxx>
33 
34 
35 #include "view.hxx"
36 #include "edtwin.hxx"
37 #include "wrtsh.hxx"
38 #include "drawbase.hxx"
39 #include "conarc.hxx"
40 
41 
42 
43 /*************************************************************************
44 |*
45 |* Konstruktor
46 |*
47 \************************************************************************/
48 
49 
50 
51 ConstArc::ConstArc(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView)
52 	: SwDrawBase(pWrtShell, pEditWin, pSwView),	nAnzButUp(0)
53 {
54 }
55 
56 /*************************************************************************
57 |*
58 |* MouseButtonDown-event
59 |*
60 \************************************************************************/
61 
62 
63 
64 sal_Bool ConstArc::MouseButtonDown( const MouseEvent& rMEvt )
65 {
66 	sal_Bool bReturn;
67 
68 	if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True)
69 	{
70 		if (!nAnzButUp)
71             aStartPnt = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
72 	}
73 	return (bReturn);
74 }
75 
76 /*************************************************************************
77 |*
78 |* MouseButtonUp-event
79 |*
80 \************************************************************************/
81 
82 
83 
84 sal_Bool ConstArc::MouseButtonUp( const MouseEvent& rMEvt )
85 {
86 	sal_Bool bReturn = sal_False;
87 
88     if ((m_pSh->IsDrawCreate() || m_pWin->IsDrawAction()) && rMEvt.IsLeft())
89 	{
90         Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
91 		if (!nAnzButUp && aPnt == aStartPnt)
92 		{
93 			SwDrawBase::MouseButtonUp(rMEvt);
94 			bReturn = sal_True;
95 		}
96 		else
97 		{	nAnzButUp++;
98 
99 			if (nAnzButUp == 3)		// Kreisbogenerzeugung beendet
100 			{
101 				SwDrawBase::MouseButtonUp(rMEvt);
102 				nAnzButUp = 0;
103 				bReturn = sal_True;
104 			}
105 			else
106                 m_pSh->EndCreate(SDRCREATE_NEXTPOINT);
107 		}
108 	}
109 /*	else if ( pView->IsCreateObj() && rMEvt.IsRight() )
110 	{
111 		pView->EndCreateObj( SDRCREATE_FORCEEND );
112 		bReturn = sal_True;
113 	}*/
114 
115 	return (bReturn);
116 }
117 
118 /*************************************************************************
119 |*
120 |* Function aktivieren
121 |*
122 \************************************************************************/
123 
124 
125 
126 void ConstArc::Activate(const sal_uInt16 nSlotId)
127 {
128 	switch (nSlotId)
129 	{
130 		case SID_DRAW_ARC:
131             m_pWin->SetSdrDrawMode(OBJ_CARC);
132 			break;
133 		case SID_DRAW_PIE:
134             m_pWin->SetSdrDrawMode(OBJ_SECT);
135 			break;
136 		case SID_DRAW_CIRCLECUT:
137             m_pWin->SetSdrDrawMode(OBJ_CCUT);
138 			break;
139 		default:
140             m_pWin->SetSdrDrawMode(OBJ_NONE);
141 			break;
142 	}
143 
144 	SwDrawBase::Activate(nSlotId);
145 }
146 
147 /*************************************************************************
148 |*
149 |* Funktion deaktivieren
150 |*
151 \************************************************************************/
152 
153 void ConstArc::Deactivate()
154 {
155 	nAnzButUp = 0;
156 
157 	SwDrawBase::Deactivate();
158 }
159 
160 
161 
162