xref: /aoo41x/main/sc/source/ui/drawfunc/fuconuno.cxx (revision b3f79822)
1*b3f79822SAndrew Rist /**************************************************************
2*b3f79822SAndrew Rist  *
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
10*b3f79822SAndrew Rist  *
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.
19*b3f79822SAndrew Rist  *
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 "fuconuno.hxx"
28cdf0e10cSrcweir #include "tabvwsh.hxx"
29cdf0e10cSrcweir #include "sc.hrc"
30cdf0e10cSrcweir #include "drawview.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir /*************************************************************************
33cdf0e10cSrcweir |*
34cdf0e10cSrcweir |* Konstruktor
35cdf0e10cSrcweir |*
36cdf0e10cSrcweir \************************************************************************/
37cdf0e10cSrcweir 
FuConstUnoControl(ScTabViewShell * pViewSh,Window * pWin,ScDrawView * pViewP,SdrModel * pDoc,SfxRequest & rReq)38cdf0e10cSrcweir FuConstUnoControl::FuConstUnoControl(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
39cdf0e10cSrcweir 				   SdrModel* pDoc, SfxRequest& rReq)
40cdf0e10cSrcweir     : FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq)
41cdf0e10cSrcweir {
42cdf0e10cSrcweir 	SFX_REQUEST_ARG( rReq, pInventorItem, SfxUInt32Item, SID_FM_CONTROL_INVENTOR, sal_False );
43cdf0e10cSrcweir 	SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, sal_False );
44cdf0e10cSrcweir 	if( pInventorItem )
45cdf0e10cSrcweir 		nInventor = pInventorItem->GetValue();
46cdf0e10cSrcweir 	if( pIdentifierItem )
47cdf0e10cSrcweir 		nIdentifier = pIdentifierItem->GetValue();
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir /*************************************************************************
51cdf0e10cSrcweir |*
52cdf0e10cSrcweir |* Destruktor
53cdf0e10cSrcweir |*
54cdf0e10cSrcweir \************************************************************************/
55cdf0e10cSrcweir 
~FuConstUnoControl()56cdf0e10cSrcweir FuConstUnoControl::~FuConstUnoControl()
57cdf0e10cSrcweir {
58cdf0e10cSrcweir }
59cdf0e10cSrcweir 
60cdf0e10cSrcweir /*************************************************************************
61cdf0e10cSrcweir |*
62cdf0e10cSrcweir |* MouseButtonDown-event
63cdf0e10cSrcweir |*
64cdf0e10cSrcweir \************************************************************************/
65cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rMEvt)66cdf0e10cSrcweir sal_Bool __EXPORT FuConstUnoControl::MouseButtonDown(const MouseEvent& rMEvt)
67cdf0e10cSrcweir {
68cdf0e10cSrcweir 	// #95491# remember button state for creation of own MouseEvents
69cdf0e10cSrcweir 	SetMouseButtonCode(rMEvt.GetButtons());
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 	sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	if ( rMEvt.IsLeft() && !pView->IsAction() )
74cdf0e10cSrcweir 	{
75cdf0e10cSrcweir 		Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
76cdf0e10cSrcweir 		pWindow->CaptureMouse();
77cdf0e10cSrcweir 		pView->BegCreateObj(aPnt);
78cdf0e10cSrcweir 		bReturn = sal_True;
79cdf0e10cSrcweir 	}
80cdf0e10cSrcweir 	return bReturn;
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir /*************************************************************************
84cdf0e10cSrcweir |*
85cdf0e10cSrcweir |* MouseMove-event
86cdf0e10cSrcweir |*
87cdf0e10cSrcweir \************************************************************************/
88cdf0e10cSrcweir 
MouseMove(const MouseEvent & rMEvt)89cdf0e10cSrcweir sal_Bool __EXPORT FuConstUnoControl::MouseMove(const MouseEvent& rMEvt)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	return FuConstruct::MouseMove(rMEvt);
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir /*************************************************************************
95cdf0e10cSrcweir |*
96cdf0e10cSrcweir |* MouseButtonUp-event
97cdf0e10cSrcweir |*
98cdf0e10cSrcweir \************************************************************************/
99cdf0e10cSrcweir 
MouseButtonUp(const MouseEvent & rMEvt)100cdf0e10cSrcweir sal_Bool __EXPORT FuConstUnoControl::MouseButtonUp(const MouseEvent& rMEvt)
101cdf0e10cSrcweir {
102cdf0e10cSrcweir 	// #95491# remember button state for creation of own MouseEvents
103cdf0e10cSrcweir 	SetMouseButtonCode(rMEvt.GetButtons());
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	if ( pView->IsCreateObj() && rMEvt.IsLeft() )
108cdf0e10cSrcweir 	{
109cdf0e10cSrcweir 		Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
110cdf0e10cSrcweir 		pView->EndCreateObj(SDRCREATE_FORCEEND);
111cdf0e10cSrcweir 		bReturn = sal_True;
112cdf0e10cSrcweir 	}
113cdf0e10cSrcweir 	return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir /*************************************************************************
117cdf0e10cSrcweir |*
118cdf0e10cSrcweir |* Tastaturereignisse bearbeiten
119cdf0e10cSrcweir |*
120cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
121cdf0e10cSrcweir |* FALSE.
122cdf0e10cSrcweir |*
123cdf0e10cSrcweir \************************************************************************/
124cdf0e10cSrcweir 
KeyInput(const KeyEvent & rKEvt)125cdf0e10cSrcweir sal_Bool __EXPORT FuConstUnoControl::KeyInput(const KeyEvent& rKEvt)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir 	sal_Bool bReturn = FuConstruct::KeyInput(rKEvt);
128cdf0e10cSrcweir 	return(bReturn);
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir /*************************************************************************
132cdf0e10cSrcweir |*
133cdf0e10cSrcweir |* Function aktivieren
134cdf0e10cSrcweir |*
135cdf0e10cSrcweir \************************************************************************/
136cdf0e10cSrcweir 
Activate()137cdf0e10cSrcweir void FuConstUnoControl::Activate()
138cdf0e10cSrcweir {
139cdf0e10cSrcweir 	pView->SetCurrentObj( nIdentifier, nInventor );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	aNewPointer = Pointer( POINTER_DRAW_RECT );
142cdf0e10cSrcweir 	aOldPointer = pWindow->GetPointer();
143cdf0e10cSrcweir 	pViewShell->SetActivePointer( aNewPointer );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_CONTROLS);
146cdf0e10cSrcweir 	if (pLayer)
147cdf0e10cSrcweir 		pView->SetActiveLayer( pLayer->GetName() );
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	FuConstruct::Activate();
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir /*************************************************************************
153cdf0e10cSrcweir |*
154cdf0e10cSrcweir |* Function deaktivieren
155cdf0e10cSrcweir |*
156cdf0e10cSrcweir \************************************************************************/
157cdf0e10cSrcweir 
Deactivate()158cdf0e10cSrcweir void FuConstUnoControl::Deactivate()
159cdf0e10cSrcweir {
160cdf0e10cSrcweir 	FuConstruct::Deactivate();
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_FRONT);
163cdf0e10cSrcweir 	if (pLayer)
164cdf0e10cSrcweir 		pView->SetActiveLayer( pLayer->GetName() );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	pViewShell->SetActivePointer( aOldPointer );
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir // #98185# Create default drawing objects via keyboard
CreateDefaultObject(const sal_uInt16,const Rectangle & rRectangle)170cdf0e10cSrcweir SdrObject* FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& rRectangle)
171cdf0e10cSrcweir {
172cdf0e10cSrcweir 	// case SID_FM_CREATE_CONTROL:
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	SdrObject* pObj = SdrObjFactory::MakeNewObject(
175cdf0e10cSrcweir 		pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
176cdf0e10cSrcweir 		0L, pDrDoc);
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	if(pObj)
179cdf0e10cSrcweir 	{
180cdf0e10cSrcweir 		pObj->SetLogicRect(rRectangle);
181cdf0e10cSrcweir 	}
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 	return pObj;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 
187