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_sd.hxx"
26
27 #include "fuconuno.hxx"
28 #include <svl/aeitem.hxx>
29 #include <sfx2/dispatch.hxx>
30 #include <sfx2/viewfrm.hxx>
31 #include <sfx2/request.hxx>
32 #include <svl/intitem.hxx>
33
34
35 #include <svx/fmglob.hxx>
36
37 #include <svx/dialogs.hrc>
38
39 class SbModule;
40
41
42 #include "app.hrc"
43 #include "glob.hrc"
44 #include "ViewShell.hxx"
45 #include "View.hxx"
46 #ifndef SD_WINDOW_SHELL_HXX
47 #include "Window.hxx"
48 #endif
49 #include "ViewShellBase.hxx"
50 #include "ToolBarManager.hxx"
51 #include "drawdoc.hxx"
52 #include "sdresid.hxx"
53 #include "res_bmp.hrc"
54
55 namespace sd {
56
57 TYPEINIT1( FuConstructUnoControl, FuConstruct );
58
59 /*************************************************************************
60 |*
61 |* Konstruktor
62 |*
63 \************************************************************************/
64
FuConstructUnoControl(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)65 FuConstructUnoControl::FuConstructUnoControl (
66 ViewShell* pViewSh,
67 ::sd::Window* pWin,
68 ::sd::View* pView,
69 SdDrawDocument* pDoc,
70 SfxRequest& rReq)
71 : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
72 {
73 }
74
Create(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq,bool bPermanent)75 FunctionReference FuConstructUnoControl::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
76 {
77 FuConstructUnoControl* pFunc;
78 FunctionReference xFunc( pFunc = new FuConstructUnoControl( pViewSh, pWin, pView, pDoc, rReq ) );
79 xFunc->DoExecute(rReq);
80 pFunc->SetPermanent(bPermanent);
81 return xFunc;
82 }
83
DoExecute(SfxRequest & rReq)84 void FuConstructUnoControl::DoExecute( SfxRequest& rReq )
85 {
86 FuConstruct::DoExecute( rReq );
87
88 SFX_REQUEST_ARG( rReq, pInventorItem, SfxUInt32Item, SID_FM_CONTROL_INVENTOR, sal_False );
89 SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, sal_False );
90 if( pInventorItem )
91 nInventor = pInventorItem->GetValue();
92 if( pIdentifierItem )
93 nIdentifier = pIdentifierItem->GetValue();
94
95 mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
96 ToolBarManager::TBG_FUNCTION,
97 ToolBarManager::msDrawingObjectToolBar);
98 }
99
100 /*************************************************************************
101 |*
102 |* MouseButtonDown-event
103 |*
104 \************************************************************************/
MouseButtonDown(const MouseEvent & rMEvt)105 sal_Bool FuConstructUnoControl::MouseButtonDown(const MouseEvent& rMEvt)
106 {
107 sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
108
109 if ( rMEvt.IsLeft() && !mpView->IsAction() )
110 {
111 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
112 mpWindow->CaptureMouse();
113 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
114 mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog);
115 bReturn = sal_True;
116 }
117 return bReturn;
118 }
119
120 /*************************************************************************
121 |*
122 |* MouseMove-event
123 |*
124 \************************************************************************/
MouseMove(const MouseEvent & rMEvt)125 sal_Bool FuConstructUnoControl::MouseMove(const MouseEvent& rMEvt)
126 {
127 return FuConstruct::MouseMove(rMEvt);
128 }
129
130 /*************************************************************************
131 |*
132 |* MouseButtonUp-event
133 |*
134 \************************************************************************/
MouseButtonUp(const MouseEvent & rMEvt)135 sal_Bool FuConstructUnoControl::MouseButtonUp(const MouseEvent& rMEvt)
136 {
137 sal_Bool bReturn = sal_False;
138
139 if ( mpView->IsCreateObj() && rMEvt.IsLeft() )
140 {
141 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
142 mpView->EndCreateObj(SDRCREATE_FORCEEND);
143 bReturn = sal_True;
144 }
145
146 bReturn = (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
147
148 if (!bPermanent)
149 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
150
151 return (bReturn);
152 }
153
154 /*************************************************************************
155 |*
156 |* Tastaturereignisse bearbeiten
157 |*
158 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
159 |* sal_False.
160 |*
161 \************************************************************************/
KeyInput(const KeyEvent & rKEvt)162 sal_Bool FuConstructUnoControl::KeyInput(const KeyEvent& rKEvt)
163 {
164 sal_Bool bReturn = FuConstruct::KeyInput(rKEvt);
165 return(bReturn);
166 }
167
168 /*************************************************************************
169 |*
170 |* Function aktivieren
171 |*
172 \************************************************************************/
Activate()173 void FuConstructUnoControl::Activate()
174 {
175 mpView->SetCurrentObj( nIdentifier, nInventor );
176
177 aNewPointer = Pointer(POINTER_DRAW_RECT);
178 aOldPointer = mpWindow->GetPointer();
179 mpWindow->SetPointer( aNewPointer );
180
181 aOldLayer = mpView->GetActiveLayer();
182 String aStr(SdResId(STR_LAYER_CONTROLS));
183 mpView->SetActiveLayer( aStr );
184
185 FuConstruct::Activate();
186 }
187
188 /*************************************************************************
189 |*
190 |* Function deaktivieren
191 |*
192 \************************************************************************/
Deactivate()193 void FuConstructUnoControl::Deactivate()
194 {
195 FuConstruct::Deactivate();
196 mpView->SetActiveLayer( aOldLayer );
197 mpWindow->SetPointer( aOldPointer );
198 }
199
200 // #97016#
CreateDefaultObject(const sal_uInt16,const Rectangle & rRectangle)201 SdrObject* FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const Rectangle& rRectangle)
202 {
203 // case SID_FM_CREATE_CONTROL:
204
205 SdrObject* pObj = SdrObjFactory::MakeNewObject(
206 mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
207 0L, mpDoc);
208
209 if(pObj)
210 {
211 pObj->SetLogicRect(rRectangle);
212 }
213
214 return pObj;
215 }
216
217 } // end of namespace sd
218