xref: /AOO41X/main/sd/source/ui/func/fuconuno.cxx (revision 5b1900111deff329a5580f97b99b67a25168e53d)
1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5b190011SAndrew Rist  * distributed with this work for additional information
6*5b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist  * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*5b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*5b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist  * software distributed under the License is distributed on an
15*5b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
17*5b190011SAndrew Rist  * specific language governing permissions and limitations
18*5b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*5b190011SAndrew Rist  *************************************************************/
21*5b190011SAndrew Rist 
22*5b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "fuconuno.hxx"
28cdf0e10cSrcweir #include <svl/aeitem.hxx>
29cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
30cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
31cdf0e10cSrcweir #include <sfx2/request.hxx>
32cdf0e10cSrcweir #include <svl/intitem.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <svx/fmglob.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <svx/dialogs.hrc>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir class SbModule;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include "app.hrc"
43cdf0e10cSrcweir #include "glob.hrc"
44cdf0e10cSrcweir #include "ViewShell.hxx"
45cdf0e10cSrcweir #include "View.hxx"
46cdf0e10cSrcweir #ifndef SD_WINDOW_SHELL_HXX
47cdf0e10cSrcweir #include "Window.hxx"
48cdf0e10cSrcweir #endif
49cdf0e10cSrcweir #include "ViewShellBase.hxx"
50cdf0e10cSrcweir #include "ToolBarManager.hxx"
51cdf0e10cSrcweir #include "drawdoc.hxx"
52cdf0e10cSrcweir #include "sdresid.hxx"
53cdf0e10cSrcweir #include "res_bmp.hrc"
54cdf0e10cSrcweir 
55cdf0e10cSrcweir namespace sd {
56cdf0e10cSrcweir 
57cdf0e10cSrcweir TYPEINIT1( FuConstructUnoControl, FuConstruct );
58cdf0e10cSrcweir 
59cdf0e10cSrcweir /*************************************************************************
60cdf0e10cSrcweir |*
61cdf0e10cSrcweir |* Konstruktor
62cdf0e10cSrcweir |*
63cdf0e10cSrcweir \************************************************************************/
64cdf0e10cSrcweir 
65cdf0e10cSrcweir FuConstructUnoControl::FuConstructUnoControl (
66cdf0e10cSrcweir     ViewShell* 	pViewSh,
67cdf0e10cSrcweir     ::sd::Window*		pWin,
68cdf0e10cSrcweir     ::sd::View*			pView,
69cdf0e10cSrcweir     SdDrawDocument*	pDoc,
70cdf0e10cSrcweir     SfxRequest&		rReq)
71cdf0e10cSrcweir 	: FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
72cdf0e10cSrcweir {
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir FunctionReference FuConstructUnoControl::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 	FuConstructUnoControl* pFunc;
78cdf0e10cSrcweir 	FunctionReference xFunc( pFunc = new FuConstructUnoControl( pViewSh, pWin, pView, pDoc, rReq ) );
79cdf0e10cSrcweir 	xFunc->DoExecute(rReq);
80cdf0e10cSrcweir 	pFunc->SetPermanent(bPermanent);
81cdf0e10cSrcweir 	return xFunc;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir 
84cdf0e10cSrcweir void FuConstructUnoControl::DoExecute( SfxRequest& rReq )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir 	FuConstruct::DoExecute( rReq );
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	SFX_REQUEST_ARG( rReq, pInventorItem, SfxUInt32Item, SID_FM_CONTROL_INVENTOR, sal_False );
89cdf0e10cSrcweir 	SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, sal_False );
90cdf0e10cSrcweir 	if( pInventorItem )
91cdf0e10cSrcweir 		nInventor = pInventorItem->GetValue();
92cdf0e10cSrcweir 	if( pIdentifierItem )
93cdf0e10cSrcweir 		nIdentifier = pIdentifierItem->GetValue();
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
96cdf0e10cSrcweir         ToolBarManager::TBG_FUNCTION,
97cdf0e10cSrcweir         ToolBarManager::msDrawingObjectToolBar);
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir /*************************************************************************
101cdf0e10cSrcweir |*
102cdf0e10cSrcweir |* MouseButtonDown-event
103cdf0e10cSrcweir |*
104cdf0e10cSrcweir \************************************************************************/
105cdf0e10cSrcweir sal_Bool FuConstructUnoControl::MouseButtonDown(const MouseEvent& rMEvt)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir 	sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	if ( rMEvt.IsLeft() && !mpView->IsAction() )
110cdf0e10cSrcweir 	{
111cdf0e10cSrcweir 		Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
112cdf0e10cSrcweir 		mpWindow->CaptureMouse();
113cdf0e10cSrcweir 		sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
114cdf0e10cSrcweir 		mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog);
115cdf0e10cSrcweir 		bReturn = sal_True;
116cdf0e10cSrcweir 	}
117cdf0e10cSrcweir 	return bReturn;
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir /*************************************************************************
121cdf0e10cSrcweir |*
122cdf0e10cSrcweir |* MouseMove-event
123cdf0e10cSrcweir |*
124cdf0e10cSrcweir \************************************************************************/
125cdf0e10cSrcweir sal_Bool FuConstructUnoControl::MouseMove(const MouseEvent& rMEvt)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir 	return FuConstruct::MouseMove(rMEvt);
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir /*************************************************************************
131cdf0e10cSrcweir |*
132cdf0e10cSrcweir |* MouseButtonUp-event
133cdf0e10cSrcweir |*
134cdf0e10cSrcweir \************************************************************************/
135cdf0e10cSrcweir sal_Bool FuConstructUnoControl::MouseButtonUp(const MouseEvent& rMEvt)
136cdf0e10cSrcweir {
137cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	if ( mpView->IsCreateObj() && rMEvt.IsLeft() )
140cdf0e10cSrcweir 	{
141cdf0e10cSrcweir 		Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
142cdf0e10cSrcweir 		mpView->EndCreateObj(SDRCREATE_FORCEEND);
143cdf0e10cSrcweir 		bReturn = sal_True;
144cdf0e10cSrcweir 	}
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	bReturn = (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	if (!bPermanent)
149cdf0e10cSrcweir 		mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	return (bReturn);
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir /*************************************************************************
155cdf0e10cSrcweir |*
156cdf0e10cSrcweir |* Tastaturereignisse bearbeiten
157cdf0e10cSrcweir |*
158cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
159cdf0e10cSrcweir |* sal_False.
160cdf0e10cSrcweir |*
161cdf0e10cSrcweir \************************************************************************/
162cdf0e10cSrcweir sal_Bool FuConstructUnoControl::KeyInput(const KeyEvent& rKEvt)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir 	sal_Bool bReturn = FuConstruct::KeyInput(rKEvt);
165cdf0e10cSrcweir 	return(bReturn);
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir /*************************************************************************
169cdf0e10cSrcweir |*
170cdf0e10cSrcweir |* Function aktivieren
171cdf0e10cSrcweir |*
172cdf0e10cSrcweir \************************************************************************/
173cdf0e10cSrcweir void FuConstructUnoControl::Activate()
174cdf0e10cSrcweir {
175cdf0e10cSrcweir 	mpView->SetCurrentObj( nIdentifier, nInventor );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	aNewPointer = Pointer(POINTER_DRAW_RECT);
178cdf0e10cSrcweir 	aOldPointer = mpWindow->GetPointer();
179cdf0e10cSrcweir 	mpWindow->SetPointer( aNewPointer );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 	aOldLayer = mpView->GetActiveLayer();
182cdf0e10cSrcweir 	String aStr(SdResId(STR_LAYER_CONTROLS));
183cdf0e10cSrcweir 	mpView->SetActiveLayer( aStr );
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	FuConstruct::Activate();
186cdf0e10cSrcweir }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir /*************************************************************************
189cdf0e10cSrcweir |*
190cdf0e10cSrcweir |* Function deaktivieren
191cdf0e10cSrcweir |*
192cdf0e10cSrcweir \************************************************************************/
193cdf0e10cSrcweir void FuConstructUnoControl::Deactivate()
194cdf0e10cSrcweir {
195cdf0e10cSrcweir 	FuConstruct::Deactivate();
196cdf0e10cSrcweir 	mpView->SetActiveLayer( aOldLayer );
197cdf0e10cSrcweir 	mpWindow->SetPointer( aOldPointer );
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir // #97016#
201cdf0e10cSrcweir SdrObject* FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const Rectangle& rRectangle)
202cdf0e10cSrcweir {
203cdf0e10cSrcweir 	// case SID_FM_CREATE_CONTROL:
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	SdrObject* pObj = SdrObjFactory::MakeNewObject(
206cdf0e10cSrcweir 		mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
207cdf0e10cSrcweir 		0L, mpDoc);
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 	if(pObj)
210cdf0e10cSrcweir 	{
211cdf0e10cSrcweir 		pObj->SetLogicRect(rRectangle);
212cdf0e10cSrcweir 	}
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 	return pObj;
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir } // end of namespace sd
218