xref: /aoo41x/main/sw/source/ui/ribbar/conarc.cxx (revision efeef26f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <svx/svdobj.hxx>
29 
30 
31 #include "view.hxx"
32 #include "edtwin.hxx"
33 #include "wrtsh.hxx"
34 #include "drawbase.hxx"
35 #include "conarc.hxx"
36 
37 
38 
39 /*************************************************************************
40 |*
41 |* Konstruktor
42 |*
43 \************************************************************************/
44 
45 
46 
ConstArc(SwWrtShell * pWrtShell,SwEditWin * pEditWin,SwView * pSwView)47 ConstArc::ConstArc(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView)
48 	: SwDrawBase(pWrtShell, pEditWin, pSwView),	nAnzButUp(0)
49 {
50 }
51 
52 /*************************************************************************
53 |*
54 |* MouseButtonDown-event
55 |*
56 \************************************************************************/
57 
58 
59 
MouseButtonDown(const MouseEvent & rMEvt)60 sal_Bool ConstArc::MouseButtonDown( const MouseEvent& rMEvt )
61 {
62 	sal_Bool bReturn;
63 
64 	if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True)
65 	{
66 		if (!nAnzButUp)
67             aStartPnt = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
68 	}
69 	return (bReturn);
70 }
71 
72 /*************************************************************************
73 |*
74 |* MouseButtonUp-event
75 |*
76 \************************************************************************/
77 
78 
79 
MouseButtonUp(const MouseEvent & rMEvt)80 sal_Bool ConstArc::MouseButtonUp( const MouseEvent& rMEvt )
81 {
82 	sal_Bool bReturn = sal_False;
83 
84     if ((m_pSh->IsDrawCreate() || m_pWin->IsDrawAction()) && rMEvt.IsLeft())
85 	{
86         Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
87 		if (!nAnzButUp && aPnt == aStartPnt)
88 		{
89 			SwDrawBase::MouseButtonUp(rMEvt);
90 			bReturn = sal_True;
91 		}
92 		else
93 		{	nAnzButUp++;
94 
95 			if (nAnzButUp == 3)		// Kreisbogenerzeugung beendet
96 			{
97 				SwDrawBase::MouseButtonUp(rMEvt);
98 				nAnzButUp = 0;
99 				bReturn = sal_True;
100 			}
101 			else
102                 m_pSh->EndCreate(SDRCREATE_NEXTPOINT);
103 		}
104 	}
105 /*	else if ( pView->IsCreateObj() && rMEvt.IsRight() )
106 	{
107 		pView->EndCreateObj( SDRCREATE_FORCEEND );
108 		bReturn = sal_True;
109 	}*/
110 
111 	return (bReturn);
112 }
113 
114 /*************************************************************************
115 |*
116 |* Function aktivieren
117 |*
118 \************************************************************************/
119 
120 
121 
Activate(const sal_uInt16 nSlotId)122 void ConstArc::Activate(const sal_uInt16 nSlotId)
123 {
124 	switch (nSlotId)
125 	{
126 		case SID_DRAW_ARC:
127             m_pWin->SetSdrDrawMode(OBJ_CARC);
128 			break;
129 		case SID_DRAW_PIE:
130             m_pWin->SetSdrDrawMode(OBJ_SECT);
131 			break;
132 		case SID_DRAW_CIRCLECUT:
133             m_pWin->SetSdrDrawMode(OBJ_CCUT);
134 			break;
135 		default:
136             m_pWin->SetSdrDrawMode(OBJ_NONE);
137 			break;
138 	}
139 
140 	SwDrawBase::Activate(nSlotId);
141 }
142 
143 /*************************************************************************
144 |*
145 |* Funktion deaktivieren
146 |*
147 \************************************************************************/
148 
Deactivate()149 void ConstArc::Deactivate()
150 {
151 	nAnzButUp = 0;
152 
153 	SwDrawBase::Deactivate();
154 }
155 
156 
157 
158