xref: /aoo42x/main/sw/source/ui/ribbar/conarc.cxx (revision 64e9ad3a)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sw.hxx"
24 
25 #include <svx/svdobj.hxx>
26 
27 #include "view.hxx"
28 #include "edtwin.hxx"
29 #include "wrtsh.hxx"
30 #include "drawbase.hxx"
31 #include "conarc.hxx"
32 
33 /*************************************************************************
34 |* C'Tor
35 \************************************************************************/
36 
ConstArc(SwWrtShell * pWrtShell,SwEditWin * pEditWin,SwView * pSwView)37 ConstArc::ConstArc(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView)
38 	: SwDrawBase(pWrtShell, pEditWin, pSwView),	nAnzButUp(0)
39 {
40 }
41 
42 /*************************************************************************
43 |* MouseButtonDown-event
44 \************************************************************************/
45 
MouseButtonDown(const MouseEvent & rMEvt)46 sal_Bool ConstArc::MouseButtonDown( const MouseEvent& rMEvt )
47 {
48 	sal_Bool bReturn;
49 
50 	if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True)
51 	{
52 		if (!nAnzButUp)
53 			aStartPnt = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
54 	}
55 	return (bReturn);
56 }
57 
58 /*************************************************************************
59 |* MouseButtonUp-event
60 \************************************************************************/
61 
MouseButtonUp(const MouseEvent & rMEvt)62 sal_Bool ConstArc::MouseButtonUp( const MouseEvent& rMEvt )
63 {
64 	sal_Bool bReturn = sal_False;
65 
66 	if ((m_pSh->IsDrawCreate() || m_pWin->IsDrawAction()) && rMEvt.IsLeft())
67 	{
68 		Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
69 		if (!nAnzButUp && aPnt == aStartPnt)
70 		{
71 			SwDrawBase::MouseButtonUp(rMEvt);
72 			bReturn = sal_True;
73 		}
74 		else
75 		{	nAnzButUp++;
76 
77 			if (nAnzButUp == 3) // Arc generation completed
78 			{
79 				SwDrawBase::MouseButtonUp(rMEvt);
80 				nAnzButUp = 0;
81 				bReturn = sal_True;
82 			}
83 			else
84 				m_pSh->EndCreate(SDRCREATE_NEXTPOINT);
85 		}
86 	}
87 /*	else if ( pView->IsCreateObj() && rMEvt.IsRight() )
88 	{
89 		pView->EndCreateObj( SDRCREATE_FORCEEND );
90 		bReturn = sal_True;
91 	}*/
92 
93 	return (bReturn);
94 }
95 
96 /*************************************************************************
97 |* activate function
98 \************************************************************************/
99 
Activate(const sal_uInt16 nSlotId)100 void ConstArc::Activate(const sal_uInt16 nSlotId)
101 {
102 	switch (nSlotId)
103 	{
104 		case SID_DRAW_ARC:
105 			m_pWin->SetSdrDrawMode(OBJ_CARC);
106 			break;
107 		case SID_DRAW_PIE:
108 			m_pWin->SetSdrDrawMode(OBJ_SECT);
109 			break;
110 		case SID_DRAW_CIRCLECUT:
111 			m_pWin->SetSdrDrawMode(OBJ_CCUT);
112 			break;
113 		default:
114 			m_pWin->SetSdrDrawMode(OBJ_NONE);
115 			break;
116 	}
117 
118 	SwDrawBase::Activate(nSlotId);
119 }
120 
121 /*************************************************************************
122 |* deactivate function
123 \************************************************************************/
124 
Deactivate()125 void ConstArc::Deactivate()
126 {
127 	nAnzButUp = 0;
128 
129 	SwDrawBase::Deactivate();
130 }
131 
132 /* vim: set noet sw=4 ts=4: */
133