xref: /trunk/main/sc/source/ui/drawfunc/fuconarc.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "fuconarc.hxx"
28cdf0e10cSrcweir #include "sc.hrc"
29cdf0e10cSrcweir #include "tabvwsh.hxx"
30cdf0e10cSrcweir #include "drawview.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir // #98185# Create default drawing objects via keyboard
33cdf0e10cSrcweir #include <svx/svdocirc.hxx>
34cdf0e10cSrcweir #include <svx/sxciaitm.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir /*************************************************************************
37cdf0e10cSrcweir |*
38cdf0e10cSrcweir |* Konstruktor
39cdf0e10cSrcweir |*
40cdf0e10cSrcweir \************************************************************************/
41cdf0e10cSrcweir 
FuConstArc(ScTabViewShell * pViewSh,Window * pWin,ScDrawView * pViewP,SdrModel * pDoc,SfxRequest & rReq)42cdf0e10cSrcweir FuConstArc::FuConstArc( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
43cdf0e10cSrcweir                    SdrModel* pDoc, SfxRequest& rReq )
44cdf0e10cSrcweir     : FuConstruct( pViewSh, pWin, pViewP, pDoc, rReq )
45cdf0e10cSrcweir {
46cdf0e10cSrcweir }
47cdf0e10cSrcweir 
48cdf0e10cSrcweir /*************************************************************************
49cdf0e10cSrcweir |*
50cdf0e10cSrcweir |* Destruktor
51cdf0e10cSrcweir |*
52cdf0e10cSrcweir \************************************************************************/
53cdf0e10cSrcweir 
~FuConstArc()54cdf0e10cSrcweir FuConstArc::~FuConstArc()
55cdf0e10cSrcweir {
56cdf0e10cSrcweir }
57cdf0e10cSrcweir 
58cdf0e10cSrcweir /*************************************************************************
59cdf0e10cSrcweir |*
60cdf0e10cSrcweir |* MouseButtonDown-event
61cdf0e10cSrcweir |*
62cdf0e10cSrcweir \************************************************************************/
63cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rMEvt)64cdf0e10cSrcweir sal_Bool __EXPORT FuConstArc::MouseButtonDown( const MouseEvent& rMEvt )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir     // #95491# remember button state for creation of own MouseEvents
67cdf0e10cSrcweir     SetMouseButtonCode(rMEvt.GetButtons());
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     sal_Bool bReturn = FuConstruct::MouseButtonDown( rMEvt );
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     if ( rMEvt.IsLeft() && !pView->IsAction() )
72cdf0e10cSrcweir     {
73cdf0e10cSrcweir         Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
74cdf0e10cSrcweir         pWindow->CaptureMouse();
75cdf0e10cSrcweir         pView->BegCreateObj( aPnt );
76cdf0e10cSrcweir         bReturn = sal_True;
77cdf0e10cSrcweir     }
78cdf0e10cSrcweir     return bReturn;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir /*************************************************************************
82cdf0e10cSrcweir |*
83cdf0e10cSrcweir |* MouseMove-event
84cdf0e10cSrcweir |*
85cdf0e10cSrcweir \************************************************************************/
86cdf0e10cSrcweir 
MouseMove(const MouseEvent & rMEvt)87cdf0e10cSrcweir sal_Bool __EXPORT FuConstArc::MouseMove( const MouseEvent& rMEvt )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir     return FuConstruct::MouseMove(rMEvt);
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir /*************************************************************************
93cdf0e10cSrcweir |*
94cdf0e10cSrcweir |* MouseButtonUp-event
95cdf0e10cSrcweir |*
96cdf0e10cSrcweir \************************************************************************/
97cdf0e10cSrcweir 
MouseButtonUp(const MouseEvent & rMEvt)98cdf0e10cSrcweir sal_Bool __EXPORT FuConstArc::MouseButtonUp( const MouseEvent& rMEvt )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir     // #95491# remember button state for creation of own MouseEvents
101cdf0e10cSrcweir     SetMouseButtonCode(rMEvt.GetButtons());
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     sal_Bool bReturn = sal_False;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     if ( pView->IsCreateObj() && rMEvt.IsLeft() )
106cdf0e10cSrcweir     {
107cdf0e10cSrcweir         // Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
108cdf0e10cSrcweir         pView->EndCreateObj( SDRCREATE_NEXTPOINT );
109cdf0e10cSrcweir         bReturn = sal_True;
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir /*
112cdf0e10cSrcweir     else if ( pView->IsCreateObj() && rMEvt.IsRight() )
113cdf0e10cSrcweir     {
114cdf0e10cSrcweir         // Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
115cdf0e10cSrcweir         pView->EndCreateObj( SDRCREATE_FORCEEND );
116cdf0e10cSrcweir         bReturn = sal_True;
117cdf0e10cSrcweir     }
118cdf0e10cSrcweir */
119cdf0e10cSrcweir     return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
120cdf0e10cSrcweir }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir /*************************************************************************
123cdf0e10cSrcweir |*
124cdf0e10cSrcweir |* Tastaturereignisse bearbeiten
125cdf0e10cSrcweir |*
126cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
127cdf0e10cSrcweir |* FALSE.
128cdf0e10cSrcweir |*
129cdf0e10cSrcweir \************************************************************************/
130cdf0e10cSrcweir 
KeyInput(const KeyEvent & rKEvt)131cdf0e10cSrcweir sal_Bool __EXPORT FuConstArc::KeyInput(const KeyEvent& rKEvt)
132cdf0e10cSrcweir {
133cdf0e10cSrcweir     sal_Bool bReturn = FuConstruct::KeyInput(rKEvt);
134cdf0e10cSrcweir     return(bReturn);
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir /*************************************************************************
138cdf0e10cSrcweir |*
139cdf0e10cSrcweir |* Function aktivieren
140cdf0e10cSrcweir |*
141cdf0e10cSrcweir \************************************************************************/
142cdf0e10cSrcweir 
Activate()143cdf0e10cSrcweir void FuConstArc::Activate()
144cdf0e10cSrcweir {
145cdf0e10cSrcweir     SdrObjKind aObjKind;
146cdf0e10cSrcweir 
147cdf0e10cSrcweir     switch (aSfxRequest.GetSlot() )
148cdf0e10cSrcweir     {
149cdf0e10cSrcweir         case SID_DRAW_ARC:
150cdf0e10cSrcweir             aNewPointer = Pointer( POINTER_DRAW_ARC );
151cdf0e10cSrcweir             aObjKind = OBJ_CARC;
152cdf0e10cSrcweir             break;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir         case SID_DRAW_PIE:
155cdf0e10cSrcweir             aNewPointer = Pointer( POINTER_DRAW_PIE );
156cdf0e10cSrcweir             aObjKind = OBJ_SECT;
157cdf0e10cSrcweir             break;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir         case SID_DRAW_CIRCLECUT:
160cdf0e10cSrcweir             aNewPointer = Pointer( POINTER_DRAW_CIRCLECUT );
161cdf0e10cSrcweir             aObjKind = OBJ_CCUT;
162cdf0e10cSrcweir             break;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir         default:
165cdf0e10cSrcweir             aNewPointer = Pointer( POINTER_CROSS );
166cdf0e10cSrcweir             aObjKind = OBJ_CARC;
167cdf0e10cSrcweir             break;
168cdf0e10cSrcweir     }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     pView->SetCurrentObj( sal::static_int_cast<sal_uInt16>( aObjKind ) );
171cdf0e10cSrcweir 
172cdf0e10cSrcweir     aOldPointer = pWindow->GetPointer();
173cdf0e10cSrcweir     pViewShell->SetActivePointer( aNewPointer );
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     FuDraw::Activate();
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir /*************************************************************************
179cdf0e10cSrcweir |*
180cdf0e10cSrcweir |* Function deaktivieren
181cdf0e10cSrcweir |*
182cdf0e10cSrcweir \************************************************************************/
183cdf0e10cSrcweir 
Deactivate()184cdf0e10cSrcweir void FuConstArc::Deactivate()
185cdf0e10cSrcweir {
186cdf0e10cSrcweir     FuDraw::Deactivate();
187cdf0e10cSrcweir     pViewShell->SetActivePointer( aOldPointer );
188cdf0e10cSrcweir }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir // #98185# Create default drawing objects via keyboard
CreateDefaultObject(const sal_uInt16 nID,const Rectangle & rRectangle)191cdf0e10cSrcweir SdrObject* FuConstArc::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
192cdf0e10cSrcweir {
193cdf0e10cSrcweir     // case SID_DRAW_ARC:
194cdf0e10cSrcweir     // case SID_DRAW_PIE:
195cdf0e10cSrcweir     // case SID_DRAW_CIRCLECUT:
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     SdrObject* pObj = SdrObjFactory::MakeNewObject(
198cdf0e10cSrcweir         pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
199cdf0e10cSrcweir         0L, pDrDoc);
200cdf0e10cSrcweir 
201cdf0e10cSrcweir     if(pObj)
202cdf0e10cSrcweir     {
203cdf0e10cSrcweir         if(pObj->ISA(SdrCircObj))
204cdf0e10cSrcweir         {
205cdf0e10cSrcweir             Rectangle aRect(rRectangle);
206cdf0e10cSrcweir 
207cdf0e10cSrcweir             if(SID_DRAW_ARC == nID || SID_DRAW_CIRCLECUT == nID)
208cdf0e10cSrcweir             {
209cdf0e10cSrcweir                 // force quadratic
210cdf0e10cSrcweir                 ImpForceQuadratic(aRect);
211cdf0e10cSrcweir             }
212cdf0e10cSrcweir 
213cdf0e10cSrcweir             pObj->SetLogicRect(aRect);
214cdf0e10cSrcweir 
215cdf0e10cSrcweir             SfxItemSet aAttr(pDrDoc->GetItemPool());
216cdf0e10cSrcweir             aAttr.Put(SdrCircStartAngleItem(9000));
217cdf0e10cSrcweir             aAttr.Put(SdrCircEndAngleItem(0));
218cdf0e10cSrcweir 
219cdf0e10cSrcweir             pObj->SetMergedItemSet(aAttr);
220cdf0e10cSrcweir         }
221cdf0e10cSrcweir         else
222cdf0e10cSrcweir         {
223cdf0e10cSrcweir             DBG_ERROR("Object is NO circle object");
224cdf0e10cSrcweir         }
225cdf0e10cSrcweir     }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir     return pObj;
228cdf0e10cSrcweir }
229