Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "fmvwimp.hxx"
21 : #include <svx/fmshell.hxx>
22 : #include "svx/fmtools.hxx"
23 : #include "fmservs.hxx"
24 : #include "fmprop.hrc"
25 : #include "fmpgeimp.hxx"
26 : #include "fmitems.hxx"
27 : #include "fmundo.hxx"
28 : #include <vcl/waitobj.hxx>
29 : #include <com/sun/star/form/XLoadable.hpp>
30 : #include <com/sun/star/container/XNamed.hpp>
31 : #include <com/sun/star/sdbcx/Privilege.hpp>
32 : #include <com/sun/star/beans/XPropertySet.hpp>
33 : #include <com/sun/star/beans/XMultiPropertySet.hpp>
34 : #include <com/sun/star/beans/XFastPropertySet.hpp>
35 : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
36 : #include <com/sun/star/lang/XServiceInfo.hpp>
37 : #include <com/sun/star/container/XNameContainer.hpp>
38 : #include <com/sun/star/awt/XTabControllerModel.hpp>
39 : #include <sfx2/viewfrm.hxx>
40 : #include <vcl/layout.hxx>
41 : #include <vcl/wrkwin.hxx>
42 : #include <svl/whiter.hxx>
43 : #include <sfx2/app.hxx>
44 : #include <svl/intitem.hxx>
45 : #include <svl/visitem.hxx>
46 : #include <unotools/moduleoptions.hxx>
47 : #include <sfx2/objface.hxx>
48 : #include <sfx2/request.hxx>
49 : #include <sfx2/dispatch.hxx>
50 : #include <sfx2/objsh.hxx>
51 : #include <svx/svdobj.hxx>
52 : #include <svx/fmpage.hxx>
53 : #include "svx/svditer.hxx"
54 : #include "fmobj.hxx"
55 :
56 : #include <svx/svxids.hrc>
57 :
58 : #include "svx/fmresids.hrc"
59 : #include "fmexch.hxx"
60 : #include <svx/fmglob.hxx>
61 : #include <svl/eitem.hxx>
62 : #include <tools/diagnose_ex.h>
63 : #include <svx/svdpage.hxx>
64 : #include <svx/fmmodel.hxx>
65 : #include <svx/dialmgr.hxx>
66 : #include "fmshimp.hxx"
67 : #include <svx/svdpagv.hxx>
68 : #include <sfx2/objitem.hxx>
69 : #include <sfx2/viewsh.hxx>
70 : #include "fmexpl.hxx"
71 : #include "formcontrolling.hxx"
72 : #include <svl/numuno.hxx>
73 : #include <connectivity/dbtools.hxx>
74 : #include <comphelper/types.hxx>
75 : #include <comphelper/processfactory.hxx>
76 : #include "fmdocumentclassification.hxx"
77 : #include "formtoolbars.hxx"
78 :
79 : #include <svx/svxdlg.hxx>
80 : #include <svx/dialogs.hrc>
81 :
82 : #include "svx/sdrobjectfilter.hxx"
83 :
84 : #define FmFormShell
85 : #include "svxslots.hxx"
86 :
87 : #include "tbxform.hxx"
88 : #include <comphelper/property.hxx>
89 : #include <com/sun/star/beans/PropertyValue.hpp>
90 :
91 : #include <boost/scoped_ptr.hpp>
92 :
93 : // wird fuer Invalidate verwendet -> mitpflegen
94 : // aufsteigend sortieren !!!!!!
95 : sal_uInt16 ControllerSlotMap[] = // slots des Controllers
96 : {
97 : SID_FM_CONFIG,
98 : SID_FM_PUSHBUTTON,
99 : SID_FM_RADIOBUTTON,
100 : SID_FM_CHECKBOX,
101 : SID_FM_FIXEDTEXT,
102 : SID_FM_GROUPBOX,
103 : SID_FM_EDIT,
104 : SID_FM_LISTBOX,
105 : SID_FM_COMBOBOX,
106 : SID_FM_DBGRID,
107 : SID_FM_IMAGEBUTTON,
108 : SID_FM_FILECONTROL,
109 : SID_FM_NAVIGATIONBAR,
110 : SID_FM_CTL_PROPERTIES,
111 : SID_FM_PROPERTIES,
112 : SID_FM_TAB_DIALOG,
113 : SID_FM_ADD_FIELD,
114 : SID_FM_DESIGN_MODE,
115 : SID_FM_SHOW_FMEXPLORER,
116 : SID_FM_SHOW_PROPERTIES,
117 : SID_FM_FMEXPLORER_CONTROL,
118 : SID_FM_DATEFIELD,
119 : SID_FM_TIMEFIELD,
120 : SID_FM_NUMERICFIELD,
121 : SID_FM_CURRENCYFIELD,
122 : SID_FM_PATTERNFIELD,
123 : SID_FM_OPEN_READONLY,
124 : SID_FM_IMAGECONTROL,
125 : SID_FM_USE_WIZARDS,
126 : SID_FM_FORMATTEDFIELD,
127 : SID_FM_FILTER_NAVIGATOR,
128 : SID_FM_AUTOCONTROLFOCUS,
129 : SID_FM_SCROLLBAR,
130 : SID_FM_SPINBUTTON,
131 : SID_FM_SHOW_DATANAVIGATOR,
132 : SID_FM_DATANAVIGATOR_CONTROL,
133 :
134 : 0
135 : };
136 :
137 : using namespace ::com::sun::star::uno;
138 : using namespace ::com::sun::star::awt;
139 : using namespace ::com::sun::star::sdbc;
140 : using namespace ::com::sun::star::sdbcx;
141 : using namespace ::com::sun::star::beans;
142 : using namespace ::com::sun::star::form;
143 : using namespace ::com::sun::star::form::runtime;
144 : using namespace ::com::sun::star::frame;
145 : using namespace ::svxform;
146 :
147 5498 : FmDesignModeChangedHint::FmDesignModeChangedHint( bool bDesMode )
148 5498 : :m_bDesignMode( bDesMode )
149 : {
150 5498 : }
151 :
152 :
153 5498 : FmDesignModeChangedHint::~FmDesignModeChangedHint()
154 : {
155 5498 : }
156 :
157 : const sal_uInt32 FM_UI_FEATURE_SHOW_DATABASEBAR = 0x00000001;
158 : const sal_uInt32 FM_UI_FEATURE_SHOW_FIELD = 0x00000002;
159 : const sal_uInt32 FM_UI_FEATURE_SHOW_PROPERTIES = 0x00000004;
160 : const sal_uInt32 FM_UI_FEATURE_SHOW_EXPLORER = 0x00000008;
161 : const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERBAR = 0x00000010;
162 : const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERNAVIGATOR = 0x00000020;
163 : const sal_uInt32 FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR = 0x00000040;
164 : const sal_uInt32 FM_UI_FEATURE_TB_CONTROLS = 0x00000080;
165 : const sal_uInt32 FM_UI_FEATURE_TB_MORECONTROLS = 0x00000100;
166 : const sal_uInt32 FM_UI_FEATURE_TB_FORMDESIGN = 0x00000200;
167 : const sal_uInt32 FM_UI_FEATURE_SHOW_DATANAVIGATOR = 0x00000400;
168 :
169 201646 : SFX_IMPL_INTERFACE(FmFormShell, SfxShell, SVX_RES(RID_STR_FORMSHELL))
170 :
171 170 : void FmFormShell::InitInterface_Impl()
172 : {
173 : GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_NAVIGATION|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_READONLYDOC,
174 170 : SVX_RES(RID_SVXTBX_FORM_NAVIGATION),
175 170 : FM_UI_FEATURE_SHOW_DATABASEBAR);
176 :
177 : GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_NAVIGATION|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_READONLYDOC,
178 170 : SVX_RES(RID_SVXTBX_FORM_FILTER),
179 170 : FM_UI_FEATURE_SHOW_FILTERBAR);
180 :
181 : GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_READONLYDOC,
182 170 : SVX_RES(RID_SVXTBX_TEXT_CONTROL_ATTRIBUTES),
183 170 : FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR);
184 :
185 170 : GetStaticInterface()->RegisterChildWindow(SID_FM_ADD_FIELD, false, FM_UI_FEATURE_SHOW_FIELD);
186 170 : GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_PROPERTIES, false, FM_UI_FEATURE_SHOW_PROPERTIES);
187 170 : GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_FMEXPLORER, false, FM_UI_FEATURE_SHOW_EXPLORER);
188 170 : GetStaticInterface()->RegisterChildWindow(SID_FM_FILTER_NAVIGATOR, false, FM_UI_FEATURE_SHOW_FILTERNAVIGATOR);
189 170 : GetStaticInterface()->RegisterChildWindow(SID_FM_SHOW_DATANAVIGATOR, false, FM_UI_FEATURE_SHOW_DATANAVIGATOR);
190 :
191 : GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD,
192 170 : SVX_RES(RID_SVXTBX_CONTROLS),
193 170 : FM_UI_FEATURE_TB_CONTROLS);
194 :
195 : GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD,
196 170 : SVX_RES(RID_SVXTBX_MORECONTROLS),
197 170 : FM_UI_FEATURE_TB_MORECONTROLS);
198 :
199 : GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD,
200 170 : SVX_RES(RID_SVXTBX_FORMDESIGN),
201 170 : FM_UI_FEATURE_TB_FORMDESIGN);
202 170 : }
203 :
204 70411 : TYPEINIT1(FmFormShell,SfxShell)
205 :
206 5452 : FmFormShell::FmFormShell( SfxViewShell* _pParent, FmFormView* pView )
207 : :SfxShell(_pParent)
208 5452 : ,m_pImpl(new FmXFormShell(*this, _pParent->GetViewFrame()))
209 : ,m_pFormView( pView )
210 : ,m_pFormModel( NULL )
211 : ,m_pParentShell(_pParent)
212 : ,m_nLastSlot( 0 )
213 : ,m_bDesignMode( true )
214 10904 : ,m_bHasForms(false)
215 : {
216 5452 : m_pImpl->acquire();
217 5452 : SetPool( &SfxGetpApp()->GetPool() );
218 5452 : SetName( OUString("Form") );
219 :
220 5452 : SetView(m_pFormView);
221 5452 : }
222 :
223 :
224 16350 : FmFormShell::~FmFormShell()
225 : {
226 5450 : if ( m_pFormView )
227 5238 : SetView( NULL );
228 :
229 5450 : m_pImpl->dispose();
230 5450 : m_pImpl->release();
231 5450 : m_pImpl = NULL;
232 10900 : }
233 :
234 :
235 578 : void FmFormShell::NotifyMarkListChanged(FmFormView* pWhichView)
236 : {
237 578 : FmNavViewMarksChanged aChangeNotification(pWhichView);
238 578 : Broadcast(aChangeNotification);
239 578 : }
240 :
241 :
242 12617 : bool FmFormShell::PrepareClose(bool bUI)
243 : {
244 12617 : if ( GetImpl()->didPrepareClose() )
245 : // we already did a PrepareClose for the current modifications of the current form
246 0 : return true;
247 :
248 12617 : bool bResult = true;
249 : // Save the data records, not in DesignMode and FilterMode
250 26060 : if (!m_bDesignMode && !GetImpl()->isInFilterMode() &&
251 14165 : m_pFormView && m_pFormView->GetActualOutDev() &&
252 722 : m_pFormView->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW)
253 : {
254 722 : SdrPageView* pCurPageView = m_pFormView->GetSdrPageView();
255 :
256 : // sal_uInt16 nPos = pCurPageView ? pCurPageView->GetWinList().Find((OutputDevice*)m_pFormView->GetActualOutDev()) : SDRPAGEVIEWWIN_NOTFOUND;
257 722 : SdrPageWindow* pWindow = pCurPageView ? pCurPageView->FindPageWindow(*((OutputDevice*)m_pFormView->GetActualOutDev())) : 0L;
258 :
259 722 : if(pWindow)
260 : {
261 : // Zunaechst werden die aktuellen Inhalte der Controls gespeichert
262 : // Wenn alles glatt gelaufen ist, werden die modifizierten Datensaetze gespeichert
263 720 : if ( GetImpl()->getActiveController().is() )
264 : {
265 6 : const ::svx::ControllerFeatures& rController = GetImpl()->getActiveControllerFeatures();
266 6 : if ( rController->commitCurrentControl() )
267 : {
268 6 : bool bModified = rController->isModifiedRow();
269 :
270 6 : if ( bModified && bUI )
271 : {
272 : MessageDialog aQry(NULL, "SaveModifiedDialog",
273 0 : "svx/ui/savemodifieddialog.ui");
274 0 : switch (aQry.Execute())
275 : {
276 : case RET_NO:
277 0 : bModified = false;
278 0 : GetImpl()->didPrepareClose( true );
279 0 : break;
280 :
281 : case RET_CANCEL:
282 0 : return false;
283 : }
284 :
285 0 : if ( bModified )
286 0 : bResult = rController->commitCurrentRecord( );
287 : }
288 : }
289 : }
290 : }
291 : }
292 12617 : return bResult;
293 : }
294 :
295 :
296 5498 : void FmFormShell::impl_setDesignMode(bool bDesign)
297 : {
298 5498 : if (m_pFormView)
299 : {
300 5498 : if (!bDesign)
301 320 : m_nLastSlot = SID_FM_DESIGN_MODE;
302 :
303 5498 : GetImpl()->SetDesignMode(bDesign);
304 : // mein m_bDesignMode wird auch von der Impl gesetzt ...
305 : }
306 : else
307 : {
308 0 : m_bHasForms = false;
309 0 : m_bDesignMode = bDesign;
310 0 : UIFeatureChanged();
311 : }
312 :
313 5498 : GetViewShell()->GetViewFrame()->GetBindings().Invalidate(ControllerSlotMap);
314 5498 : }
315 :
316 :
317 79657 : bool FmFormShell::HasUIFeature( sal_uInt32 nFeature )
318 : {
319 79657 : bool bResult = false;
320 79657 : if ((nFeature & FM_UI_FEATURE_SHOW_DATABASEBAR) == FM_UI_FEATURE_SHOW_DATABASEBAR)
321 : {
322 : // nur wenn auch formulare verfuegbar
323 7247 : bResult = !m_bDesignMode && GetImpl()->hasDatabaseBar() && !GetImpl()->isInFilterMode();
324 : }
325 72410 : else if ((nFeature & FM_UI_FEATURE_SHOW_FILTERBAR) == FM_UI_FEATURE_SHOW_FILTERBAR)
326 : {
327 : // nur wenn auch formulare verfuegbar
328 7247 : bResult = !m_bDesignMode && GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
329 : }
330 65163 : else if ((nFeature & FM_UI_FEATURE_SHOW_FILTERNAVIGATOR) == FM_UI_FEATURE_SHOW_FILTERNAVIGATOR)
331 : {
332 7247 : bResult = !m_bDesignMode && GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
333 : }
334 57916 : else if ((nFeature & FM_UI_FEATURE_SHOW_FIELD) == FM_UI_FEATURE_SHOW_FIELD)
335 : {
336 7237 : bResult = m_bDesignMode && m_pFormView && m_bHasForms;
337 : }
338 50679 : else if ((nFeature & FM_UI_FEATURE_SHOW_PROPERTIES) == FM_UI_FEATURE_SHOW_PROPERTIES)
339 : {
340 7237 : bResult = m_bDesignMode && m_pFormView && m_bHasForms;
341 : }
342 43442 : else if ((nFeature & FM_UI_FEATURE_SHOW_EXPLORER) == FM_UI_FEATURE_SHOW_EXPLORER)
343 : {
344 7237 : bResult = m_bDesignMode; // OJ #101593# && m_pFormView && m_bHasForms;
345 : }
346 36205 : else if ( ( nFeature & FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR ) == FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR )
347 : {
348 7247 : bResult = !GetImpl()->IsReadonlyDoc() && m_pImpl->IsActiveControl( true );
349 : }
350 28958 : else if ((nFeature & FM_UI_FEATURE_SHOW_DATANAVIGATOR) == FM_UI_FEATURE_SHOW_DATANAVIGATOR)
351 : {
352 7247 : bResult = GetImpl()->isEnhancedForm();
353 : }
354 21711 : else if ( ( ( nFeature & FM_UI_FEATURE_TB_CONTROLS ) == FM_UI_FEATURE_TB_CONTROLS )
355 14474 : || ( ( nFeature & FM_UI_FEATURE_TB_MORECONTROLS ) == FM_UI_FEATURE_TB_MORECONTROLS )
356 7237 : || ( ( nFeature & FM_UI_FEATURE_TB_FORMDESIGN ) == FM_UI_FEATURE_TB_FORMDESIGN )
357 : )
358 : {
359 21711 : bResult = true;
360 : }
361 :
362 79657 : return bResult;
363 : }
364 :
365 :
366 4 : void FmFormShell::Execute(SfxRequest &rReq)
367 : {
368 4 : sal_uInt16 nSlot = rReq.GetSlot();
369 :
370 :
371 : // MasterSlot setzen
372 4 : switch( nSlot )
373 : {
374 : case SID_FM_PUSHBUTTON:
375 : case SID_FM_RADIOBUTTON:
376 : case SID_FM_CHECKBOX:
377 : case SID_FM_FIXEDTEXT:
378 : case SID_FM_GROUPBOX:
379 : case SID_FM_LISTBOX:
380 : case SID_FM_COMBOBOX:
381 : case SID_FM_NAVIGATIONBAR:
382 : case SID_FM_EDIT:
383 : case SID_FM_DBGRID:
384 : case SID_FM_IMAGEBUTTON:
385 : case SID_FM_IMAGECONTROL:
386 : case SID_FM_FILECONTROL:
387 : case SID_FM_DATEFIELD:
388 : case SID_FM_TIMEFIELD:
389 : case SID_FM_NUMERICFIELD:
390 : case SID_FM_CURRENCYFIELD:
391 : case SID_FM_PATTERNFIELD:
392 : case SID_FM_FORMATTEDFIELD:
393 : case SID_FM_SCROLLBAR:
394 : case SID_FM_SPINBUTTON:
395 0 : m_nLastSlot = nSlot;
396 0 : GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG );
397 0 : break;
398 : }
399 :
400 :
401 : // Identifier und Inventor des Uno-Controls setzen
402 4 : sal_uInt16 nIdentifier = 0;
403 4 : switch( nSlot )
404 : {
405 : case SID_FM_CHECKBOX:
406 0 : nIdentifier = OBJ_FM_CHECKBOX;
407 0 : break;
408 : case SID_FM_PUSHBUTTON:
409 0 : nIdentifier = OBJ_FM_BUTTON;
410 0 : break;
411 : case SID_FM_FIXEDTEXT:
412 0 : nIdentifier = OBJ_FM_FIXEDTEXT;
413 0 : break;
414 : case SID_FM_LISTBOX:
415 0 : nIdentifier = OBJ_FM_LISTBOX;
416 0 : break;
417 : case SID_FM_EDIT:
418 0 : nIdentifier = OBJ_FM_EDIT;
419 0 : break;
420 : case SID_FM_RADIOBUTTON:
421 0 : nIdentifier = OBJ_FM_RADIOBUTTON;
422 0 : break;
423 : case SID_FM_GROUPBOX:
424 0 : nIdentifier = OBJ_FM_GROUPBOX;
425 0 : break;
426 : case SID_FM_COMBOBOX:
427 0 : nIdentifier = OBJ_FM_COMBOBOX;
428 0 : break;
429 : case SID_FM_NAVIGATIONBAR:
430 0 : nIdentifier = OBJ_FM_NAVIGATIONBAR;
431 0 : break;
432 : case SID_FM_DBGRID:
433 0 : nIdentifier = OBJ_FM_GRID;
434 0 : break;
435 : case SID_FM_IMAGEBUTTON:
436 0 : nIdentifier = OBJ_FM_IMAGEBUTTON;
437 0 : break;
438 : case SID_FM_IMAGECONTROL:
439 0 : nIdentifier = OBJ_FM_IMAGECONTROL;
440 0 : break;
441 : case SID_FM_FILECONTROL:
442 0 : nIdentifier = OBJ_FM_FILECONTROL;
443 0 : break;
444 : case SID_FM_DATEFIELD:
445 0 : nIdentifier = OBJ_FM_DATEFIELD;
446 0 : break;
447 : case SID_FM_TIMEFIELD:
448 0 : nIdentifier = OBJ_FM_TIMEFIELD;
449 0 : break;
450 : case SID_FM_NUMERICFIELD:
451 0 : nIdentifier = OBJ_FM_NUMERICFIELD;
452 0 : break;
453 : case SID_FM_CURRENCYFIELD:
454 0 : nIdentifier = OBJ_FM_CURRENCYFIELD;
455 0 : break;
456 : case SID_FM_PATTERNFIELD:
457 0 : nIdentifier = OBJ_FM_PATTERNFIELD;
458 0 : break;
459 : case SID_FM_FORMATTEDFIELD:
460 0 : nIdentifier = OBJ_FM_FORMATTEDFIELD;
461 0 : break;
462 : case SID_FM_SCROLLBAR:
463 0 : nIdentifier = OBJ_FM_SCROLLBAR;
464 0 : break;
465 : case SID_FM_SPINBUTTON:
466 0 : nIdentifier = OBJ_FM_SPINBUTTON;
467 0 : break;
468 : }
469 :
470 4 : switch ( nSlot )
471 : {
472 : case SID_FM_CHECKBOX:
473 : case SID_FM_PUSHBUTTON:
474 : case SID_FM_FIXEDTEXT:
475 : case SID_FM_LISTBOX:
476 : case SID_FM_EDIT:
477 : case SID_FM_RADIOBUTTON:
478 : case SID_FM_COMBOBOX:
479 : case SID_FM_NAVIGATIONBAR:
480 : case SID_FM_GROUPBOX:
481 : case SID_FM_DBGRID:
482 : case SID_FM_IMAGEBUTTON:
483 : case SID_FM_IMAGECONTROL:
484 : case SID_FM_FILECONTROL:
485 : case SID_FM_DATEFIELD:
486 : case SID_FM_TIMEFIELD:
487 : case SID_FM_NUMERICFIELD:
488 : case SID_FM_CURRENCYFIELD:
489 : case SID_FM_PATTERNFIELD:
490 : case SID_FM_FORMATTEDFIELD:
491 : case SID_FM_SCROLLBAR:
492 : case SID_FM_SPINBUTTON:
493 : {
494 0 : SFX_REQUEST_ARG( rReq, pGrabFocusItem, SfxBoolItem, SID_FM_TOGGLECONTROLFOCUS, false );
495 0 : if ( pGrabFocusItem && pGrabFocusItem->GetValue() )
496 : { // see below
497 0 : SfxViewShell* pShell = GetViewShell();
498 0 : vcl::Window* pShellWnd = pShell ? pShell->GetWindow() : NULL;
499 0 : if ( pShellWnd )
500 0 : pShellWnd->GrabFocus();
501 0 : break;
502 : }
503 :
504 0 : SfxUInt16Item aIdentifierItem( SID_FM_CONTROL_IDENTIFIER, nIdentifier );
505 0 : SfxUInt32Item aInventorItem( SID_FM_CONTROL_INVENTOR, FmFormInventor );
506 : const SfxPoolItem* pArgs[] =
507 : {
508 : &aIdentifierItem, &aInventorItem, NULL
509 0 : };
510 : const SfxPoolItem* pInternalArgs[] =
511 : {
512 : NULL
513 0 : };
514 :
515 : GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_CREATE_CONTROL, SfxCallMode::ASYNCHRON,
516 0 : pArgs, rReq.GetModifier(), pInternalArgs );
517 :
518 0 : if ( rReq.GetModifier() & KEY_MOD1 )
519 : {
520 : // #99013# if selected with control key, return focus to current view
521 : // do this asynchron, so that the creation can be finished first
522 : // reusing the SID_FM_TOGGLECONTROLFOCUS is somewhat hacky ... which it wouldn't if it would have another
523 : // name, so I do not really have a big problem with this ....
524 0 : SfxBoolItem aGrabFocusIndicatorItem( SID_FM_TOGGLECONTROLFOCUS, true );
525 : GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( nSlot, SfxCallMode::ASYNCHRON,
526 0 : &aGrabFocusIndicatorItem, NULL );
527 : }
528 :
529 0 : rReq.Done();
530 0 : } break;
531 : }
532 :
533 : // Individuelle Aktionen
534 4 : switch( nSlot )
535 : {
536 : case SID_FM_MORE_CONTROLS:
537 : case SID_FM_FORM_DESIGN_TOOLS:
538 : {
539 0 : FormToolboxes aToolboxAccess( GetImpl()->getHostFrame() );
540 0 : aToolboxAccess.toggleToolbox( nSlot );
541 0 : rReq.Done();
542 : }
543 0 : break;
544 :
545 : case SID_FM_TOGGLECONTROLFOCUS:
546 : {
547 0 : FmFormView* pFormView = GetFormView();
548 0 : if ( !pFormView )
549 0 : break;
550 :
551 : // if we execute this ourself, then either the application does not implement an own handling for this,
552 : // of we're on the top of the dispatcher stack, which means a control has the focus.
553 : // In the latter case, we put the focus to the document window, otherwise, we focus the first control
554 0 : const bool bHasControlFocus = GetImpl()->HasControlFocus();
555 0 : if ( bHasControlFocus )
556 : {
557 0 : const OutputDevice* pDevice = GetCurrentViewDevice();
558 0 : vcl::Window* pWindow = dynamic_cast< vcl::Window* >( const_cast< OutputDevice* >( pDevice ) );
559 0 : if ( pWindow )
560 0 : pWindow->GrabFocus();
561 : }
562 : else
563 : {
564 0 : pFormView->GrabFirstControlFocus( );
565 : }
566 : }
567 0 : break;
568 :
569 : case SID_FM_VIEW_AS_GRID:
570 0 : GetImpl()->CreateExternalView();
571 0 : break;
572 : case SID_FM_CONVERTTO_EDIT :
573 : case SID_FM_CONVERTTO_BUTTON :
574 : case SID_FM_CONVERTTO_FIXEDTEXT :
575 : case SID_FM_CONVERTTO_LISTBOX :
576 : case SID_FM_CONVERTTO_CHECKBOX :
577 : case SID_FM_CONVERTTO_RADIOBUTTON :
578 : case SID_FM_CONVERTTO_GROUPBOX :
579 : case SID_FM_CONVERTTO_COMBOBOX :
580 : case SID_FM_CONVERTTO_IMAGEBUTTON :
581 : case SID_FM_CONVERTTO_FILECONTROL :
582 : case SID_FM_CONVERTTO_DATE :
583 : case SID_FM_CONVERTTO_TIME :
584 : case SID_FM_CONVERTTO_NUMERIC :
585 : case SID_FM_CONVERTTO_CURRENCY :
586 : case SID_FM_CONVERTTO_PATTERN :
587 : case SID_FM_CONVERTTO_IMAGECONTROL :
588 : case SID_FM_CONVERTTO_FORMATTED :
589 : case SID_FM_CONVERTTO_SCROLLBAR :
590 : case SID_FM_CONVERTTO_SPINBUTTON :
591 : case SID_FM_CONVERTTO_NAVIGATIONBAR :
592 0 : GetImpl()->executeControlConversionSlot( nSlot );
593 : // nach dem Konvertieren die Selektion neu bestimmern, da sich ja das selektierte Objekt
594 : // geaendert hat
595 0 : GetImpl()->SetSelection(GetFormView()->GetMarkedObjectList());
596 0 : break;
597 : case SID_FM_LEAVE_CREATE:
598 0 : m_nLastSlot = 0;
599 0 : GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG );
600 0 : rReq.Done();
601 0 : break;
602 : case SID_FM_SHOW_PROPERTY_BROWSER:
603 : {
604 0 : SFX_REQUEST_ARG( rReq, pShowItem, SfxBoolItem, SID_FM_SHOW_PROPERTIES, false );
605 0 : bool bShow = true;
606 0 : if ( pShowItem )
607 0 : bShow = pShowItem->GetValue();
608 0 : GetImpl()->ShowSelectionProperties( bShow );
609 :
610 0 : rReq.Done();
611 0 : } break;
612 :
613 : case SID_FM_PROPERTIES:
614 : {
615 : // PropertyBrowser anzeigen
616 0 : SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, nSlot, false);
617 0 : bool bShow = pShowItem ? pShowItem->GetValue() : sal_True;
618 :
619 0 : InterfaceBag aOnlyTheForm;
620 0 : aOnlyTheForm.insert( Reference< XInterface >( GetImpl()->getCurrentForm(), UNO_QUERY ) );
621 0 : GetImpl()->setCurrentSelection( aOnlyTheForm );
622 :
623 0 : GetImpl()->ShowSelectionProperties( bShow );
624 :
625 0 : rReq.Done();
626 0 : } break;
627 :
628 : case SID_FM_CTL_PROPERTIES:
629 : {
630 0 : SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, nSlot, false);
631 0 : bool bShow = pShowItem ? pShowItem->GetValue() : sal_True;
632 :
633 : OSL_ENSURE( GetImpl()->onlyControlsAreMarked(), "FmFormShell::Execute: ControlProperties should be disabled!" );
634 0 : if ( bShow )
635 0 : GetImpl()->selectLastMarkedControls();
636 0 : GetImpl()->ShowSelectionProperties( bShow );
637 :
638 0 : rReq.Done();
639 0 : } break;
640 : case SID_FM_SHOW_PROPERTIES:
641 : case SID_FM_ADD_FIELD:
642 : case SID_FM_FILTER_NAVIGATOR:
643 : case SID_FM_SHOW_DATANAVIGATOR :
644 : {
645 0 : GetViewShell()->GetViewFrame()->ChildWindowExecute( rReq );
646 0 : rReq.Done();
647 0 : } break;
648 : case SID_FM_SHOW_FMEXPLORER:
649 : {
650 0 : if (!m_pFormView) // setzen der View Forcieren
651 0 : GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_CREATE_SW_DRAWVIEW);
652 :
653 0 : GetViewShell()->GetViewFrame()->ChildWindowExecute(rReq);
654 0 : rReq.Done();
655 : }
656 0 : break;
657 :
658 : case SID_FM_TAB_DIALOG:
659 : {
660 0 : GetImpl()->ExecuteTabOrderDialog( Reference< XTabControllerModel >( GetImpl()->getCurrentForm(), UNO_QUERY ) );
661 0 : rReq.Done();
662 : }
663 0 : break;
664 :
665 : case SID_FM_DESIGN_MODE:
666 : {
667 4 : SFX_REQUEST_ARG(rReq, pDesignItem, SfxBoolItem, nSlot, false);
668 4 : bool bDesignMode = pDesignItem ? pDesignItem->GetValue() : !m_bDesignMode;
669 4 : SetDesignMode( bDesignMode );
670 4 : if ( m_bDesignMode == bDesignMode )
671 4 : rReq.Done();
672 :
673 4 : m_nLastSlot = SID_FM_DESIGN_MODE;
674 4 : GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG );
675 : }
676 4 : break;
677 :
678 : case SID_FM_AUTOCONTROLFOCUS:
679 : {
680 0 : FmFormModel* pModel = GetFormModel();
681 : DBG_ASSERT(pModel, "FmFormShell::Execute : invalid call !");
682 : // should have been disabled in GetState if we don't have a FormModel
683 0 : pModel->SetAutoControlFocus( !pModel->GetAutoControlFocus() );
684 0 : GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_AUTOCONTROLFOCUS);
685 : }
686 0 : break;
687 : case SID_FM_OPEN_READONLY:
688 : {
689 0 : FmFormModel* pModel = GetFormModel();
690 : DBG_ASSERT(pModel, "FmFormShell::Execute : invalid call !");
691 : // should have been disabled in GetState if we don't have a FormModel
692 0 : pModel->SetOpenInDesignMode( !pModel->GetOpenInDesignMode() );
693 0 : GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_OPEN_READONLY);
694 : }
695 0 : break;
696 : case SID_FM_USE_WIZARDS:
697 : {
698 0 : GetImpl()->SetWizardUsing(!GetImpl()->GetWizardUsing());
699 0 : GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_USE_WIZARDS);
700 : }
701 0 : break;
702 : case SID_FM_SEARCH:
703 : {
704 0 : const ::svx::ControllerFeatures& rController = GetImpl()->getActiveControllerFeatures();
705 0 : if ( rController->commitCurrentControl() && rController->commitCurrentRecord() )
706 0 : GetImpl()->ExecuteSearch();
707 0 : rReq.Done();
708 : }
709 0 : break;
710 :
711 : case SID_FM_RECORD_FIRST:
712 : case SID_FM_RECORD_PREV:
713 : case SID_FM_RECORD_NEXT:
714 : case SID_FM_RECORD_LAST:
715 : case SID_FM_RECORD_NEW:
716 : case SID_FM_REFRESH:
717 : case SID_FM_REFRESH_FORM_CONTROL:
718 : case SID_FM_RECORD_DELETE:
719 : case SID_FM_RECORD_UNDO:
720 : case SID_FM_RECORD_SAVE:
721 : case SID_FM_REMOVE_FILTER_SORT:
722 : case SID_FM_SORTDOWN:
723 : case SID_FM_SORTUP:
724 : case SID_FM_AUTOFILTER:
725 : case SID_FM_ORDERCRIT:
726 : case SID_FM_FORM_FILTERED:
727 : {
728 0 : GetImpl()->ExecuteFormSlot( nSlot );
729 0 : rReq.Done();
730 : }
731 0 : break;
732 :
733 : case SID_FM_RECORD_ABSOLUTE:
734 : {
735 0 : const ::svx::ControllerFeatures& rController = GetImpl()->getNavControllerFeatures();
736 0 : sal_Int32 nRecord = -1;
737 :
738 0 : const SfxItemSet* pArgs = rReq.GetArgs();
739 0 : if ( pArgs )
740 : {
741 : const SfxPoolItem* pItem;
742 0 : if ( ( pArgs->GetItemState( FN_PARAM_1, true, &pItem ) ) == SfxItemState::SET )
743 : {
744 0 : const SfxInt32Item* pTypedItem = PTR_CAST( SfxInt32Item, pItem );
745 0 : if ( pTypedItem )
746 0 : nRecord = std::max( pTypedItem->GetValue(), sal_Int32(0) );
747 : }
748 : }
749 : else
750 : {
751 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
752 : DBG_ASSERT( pFact, "no dialog factory!" );
753 0 : if ( pFact )
754 : {
755 0 : boost::scoped_ptr< AbstractFmInputRecordNoDialog > dlg( pFact->CreateFmInputRecordNoDialog( NULL ) );
756 : DBG_ASSERT( dlg.get(), "Dialog creation failed!" );
757 0 : dlg->SetValue( rController->getCursor()->getRow() );
758 0 : if ( dlg->Execute() == RET_OK )
759 0 : nRecord = dlg->GetValue();
760 :
761 0 : rReq.AppendItem( SfxInt32Item( FN_PARAM_1, nRecord ) );
762 : }
763 : }
764 :
765 0 : if ( nRecord != -1 )
766 0 : rController->execute( nSlot, OUString( "Position" ), makeAny( (sal_Int32)nRecord ) );
767 :
768 0 : rReq.Done();
769 0 : } break;
770 : case SID_FM_FILTER_EXECUTE:
771 : case SID_FM_FILTER_EXIT:
772 : {
773 0 : bool bCancelled = ( SID_FM_FILTER_EXIT == nSlot );
774 0 : bool bReopenNavigator = false;
775 :
776 0 : if ( !bCancelled )
777 : {
778 : // if the filter navigator is still open, we need to close it, so it can possibly
779 : // commit it's most recent changes
780 0 : if ( GetViewShell() && GetViewShell()->GetViewFrame() )
781 0 : if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR ) )
782 : {
783 0 : GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR );
784 0 : bReopenNavigator = true;
785 : }
786 :
787 0 : Reference< runtime::XFormController > xController( GetImpl()->getActiveController() );
788 :
789 0 : if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR )
790 : // closing the window was denied, for instance because of a invalid criterion
791 :
792 0 : || ( xController.is()
793 0 : && !GetImpl()->getActiveControllerFeatures()->commitCurrentControl( )
794 : )
795 : // committing the controller was denied
796 : )
797 : {
798 0 : rReq.Done();
799 0 : break;
800 0 : }
801 : }
802 :
803 0 : GetImpl()->stopFiltering( !bCancelled );
804 0 : rReq.Done();
805 :
806 0 : if ( bReopenNavigator )
807 : // we closed the navigator only to implicitly commit it (as we do not have another
808 : // direct wire to it), but to the user, it should look it it was always open
809 0 : GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR );
810 : }
811 0 : break;
812 :
813 : case SID_FM_FILTER_START:
814 : {
815 0 : GetImpl()->startFiltering();
816 0 : rReq.Done();
817 :
818 : // initially open the filter navigator, the whole form based filter is pretty useless without it
819 0 : SfxBoolItem aIdentifierItem( SID_FM_FILTER_NAVIGATOR, true );
820 : GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_FILTER_NAVIGATOR, SfxCallMode::ASYNCHRON,
821 0 : &aIdentifierItem, NULL );
822 0 : } break;
823 : }
824 4 : }
825 :
826 :
827 82 : void FmFormShell::GetState(SfxItemSet &rSet)
828 : {
829 82 : SfxWhichIter aIter( rSet );
830 82 : sal_uInt16 nWhich = aIter.FirstWhich();
831 246 : while ( nWhich )
832 : {
833 82 : switch( nWhich )
834 : {
835 : case SID_FM_MORE_CONTROLS:
836 : case SID_FM_FORM_DESIGN_TOOLS:
837 : {
838 0 : FormToolboxes aToolboxAccess( GetImpl()->getHostFrame() );
839 0 : rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible( nWhich ) ) );
840 : }
841 0 : break;
842 :
843 : case SID_FM_FILTER_EXECUTE:
844 : case SID_FM_FILTER_EXIT:
845 0 : if (!GetImpl()->isInFilterMode())
846 0 : rSet.DisableItem( nWhich );
847 0 : break;
848 :
849 : case SID_FM_USE_WIZARDS:
850 0 : if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
851 0 : rSet.Put( SfxVisibilityItem( nWhich, false ) );
852 0 : else if (!GetFormModel())
853 0 : rSet.DisableItem( nWhich );
854 : else
855 0 : rSet.Put( SfxBoolItem(nWhich, GetImpl()->GetWizardUsing() ) );
856 0 : break;
857 : case SID_FM_AUTOCONTROLFOCUS:
858 0 : if (!GetFormModel())
859 0 : rSet.DisableItem( nWhich );
860 : else
861 0 : rSet.Put( SfxBoolItem(nWhich, GetFormModel()->GetAutoControlFocus() ) );
862 0 : break;
863 : case SID_FM_OPEN_READONLY:
864 0 : if (!GetFormModel())
865 0 : rSet.DisableItem( nWhich );
866 : else
867 0 : rSet.Put( SfxBoolItem(nWhich, GetFormModel()->GetOpenInDesignMode() ) );
868 0 : break;
869 :
870 : case SID_FM_NAVIGATIONBAR:
871 : case SID_FM_DBGRID:
872 0 : if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
873 : {
874 0 : rSet.Put( SfxVisibilityItem( nWhich, false ) );
875 0 : break;
876 : }
877 : // NO break!
878 :
879 : case SID_FM_SCROLLBAR:
880 : case SID_FM_IMAGECONTROL:
881 : case SID_FM_FILECONTROL:
882 : case SID_FM_CURRENCYFIELD:
883 : case SID_FM_PATTERNFIELD:
884 : case SID_FM_IMAGEBUTTON:
885 : case SID_FM_RADIOBUTTON:
886 : case SID_FM_COMBOBOX:
887 : case SID_FM_GROUPBOX:
888 : case SID_FM_CHECKBOX:
889 : case SID_FM_PUSHBUTTON:
890 : case SID_FM_FIXEDTEXT:
891 : case SID_FM_LISTBOX:
892 : case SID_FM_EDIT:
893 : case SID_FM_DATEFIELD:
894 : case SID_FM_TIMEFIELD:
895 : case SID_FM_NUMERICFIELD:
896 : case SID_FM_FORMATTEDFIELD:
897 : case SID_FM_SPINBUTTON:
898 0 : if (!m_bDesignMode)
899 0 : rSet.DisableItem( nWhich );
900 : else
901 : {
902 0 : bool bLayerLocked = false;
903 0 : if (m_pFormView)
904 : {
905 : // Ist der ::com::sun::star::drawing::Layer gelocked, so m???ssen die Slots disabled werden. #36897
906 0 : SdrPageView* pPV = m_pFormView->GetSdrPageView();
907 0 : if (pPV != NULL)
908 0 : bLayerLocked = pPV->IsLayerLocked(m_pFormView->GetActiveLayer());
909 : }
910 0 : if (bLayerLocked)
911 0 : rSet.DisableItem( nWhich );
912 : else
913 0 : rSet.Put( SfxBoolItem(nWhich, (nWhich==m_nLastSlot)) );
914 : }
915 0 : break;
916 : case SID_FM_FILTER_NAVIGATOR_CONTROL:
917 : {
918 0 : if (GetImpl()->isInFilterMode())
919 0 : rSet.Put(SfxObjectItem(nWhich, this));
920 : else
921 0 : rSet.Put(SfxObjectItem(nWhich));
922 0 : } break;
923 : case SID_FM_FIELDS_CONTROL:
924 : case SID_FM_PROPERTY_CONTROL:
925 : {
926 0 : if (!m_bDesignMode || !m_pFormView || !m_bHasForms)
927 0 : rSet.Put(SfxObjectItem(nWhich));
928 : else
929 0 : rSet.Put(SfxObjectItem(nWhich, this));
930 :
931 0 : } break;
932 : case SID_FM_FMEXPLORER_CONTROL:
933 : case SID_FM_DATANAVIGATOR_CONTROL :
934 : {
935 0 : if (!m_bDesignMode || !m_pFormView)
936 0 : rSet.Put(SfxObjectItem(nWhich));
937 : else
938 0 : rSet.Put(SfxObjectItem(nWhich, this));
939 :
940 0 : } break;
941 : case SID_FM_ADD_FIELD:
942 : case SID_FM_SHOW_FMEXPLORER:
943 : case SID_FM_SHOW_PROPERTIES:
944 : case SID_FM_FILTER_NAVIGATOR:
945 : case SID_FM_SHOW_DATANAVIGATOR:
946 : {
947 0 : if ( GetViewShell()->GetViewFrame()->KnowsChildWindow(nWhich) )
948 0 : rSet.Put( SfxBoolItem( nWhich, GetViewShell()->GetViewFrame()->HasChildWindow(nWhich)) );
949 : else
950 0 : rSet.DisableItem(nWhich);
951 0 : } break;
952 :
953 : case SID_FM_SHOW_PROPERTY_BROWSER:
954 : {
955 0 : rSet.Put(SfxBoolItem(nWhich, GetImpl()->IsPropBrwOpen()));
956 : }
957 0 : break;
958 :
959 : case SID_FM_CTL_PROPERTIES:
960 : {
961 : // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
962 : // auf den neuesten Stand zu bringen
963 0 : if (GetImpl()->IsSelectionUpdatePending())
964 0 : GetImpl()->ForceUpdateSelection(false);
965 :
966 0 : if ( !m_pFormView || !m_bDesignMode || !GetImpl()->onlyControlsAreMarked() )
967 0 : rSet.DisableItem( nWhich );
968 : else
969 : {
970 0 : bool bChecked = GetImpl()->IsPropBrwOpen() && !GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
971 : // if the property browser is open, and only controls are marked, and the current selection
972 : // does not consist of only the current form, then the current selection is the (composition of)
973 : // the currently marked controls
974 0 : rSet.Put( SfxBoolItem( nWhich, bChecked ) );
975 : }
976 0 : } break;
977 :
978 : case SID_FM_PROPERTIES:
979 : {
980 : // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
981 : // auf den neuesten Stand zu bringen
982 0 : if (GetImpl()->IsSelectionUpdatePending())
983 0 : GetImpl()->ForceUpdateSelection(false);
984 :
985 0 : if ( !m_pFormView || !m_bDesignMode || !GetImpl()->getCurrentForm().is() )
986 0 : rSet.DisableItem( nWhich );
987 : else
988 : {
989 0 : bool bChecked = GetImpl()->IsPropBrwOpen() && GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
990 0 : rSet.Put(SfxBoolItem(nWhich, bChecked));
991 : }
992 0 : } break;
993 : case SID_FM_TAB_DIALOG:
994 : // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
995 : // auf den neuesten Stand zu bringen
996 0 : if (GetImpl()->IsSelectionUpdatePending())
997 0 : GetImpl()->ForceUpdateSelection(false);
998 :
999 0 : if (!m_pFormView || !m_bDesignMode || !GetImpl()->getCurrentForm().is() )
1000 0 : rSet.DisableItem( nWhich );
1001 0 : break;
1002 : case SID_FM_CONFIG:
1003 68 : rSet.Put(SfxUInt16Item(nWhich, m_nLastSlot));
1004 68 : break;
1005 : case SID_FM_DESIGN_MODE:
1006 14 : if (!m_pFormView || GetImpl()->IsReadonlyDoc() )
1007 0 : rSet.DisableItem( nWhich );
1008 : else
1009 14 : rSet.Put( SfxBoolItem(nWhich, m_bDesignMode) );
1010 14 : break;
1011 : case SID_FM_SEARCH:
1012 : case SID_FM_RECORD_FIRST:
1013 : case SID_FM_RECORD_NEXT:
1014 : case SID_FM_RECORD_PREV:
1015 : case SID_FM_RECORD_LAST:
1016 : case SID_FM_RECORD_NEW:
1017 : case SID_FM_RECORD_DELETE:
1018 : case SID_FM_RECORD_ABSOLUTE:
1019 : case SID_FM_RECORD_TOTAL:
1020 : case SID_FM_RECORD_SAVE:
1021 : case SID_FM_RECORD_UNDO:
1022 : case SID_FM_FORM_FILTERED:
1023 : case SID_FM_REMOVE_FILTER_SORT:
1024 : case SID_FM_SORTUP:
1025 : case SID_FM_SORTDOWN:
1026 : case SID_FM_ORDERCRIT:
1027 : case SID_FM_FILTER_START:
1028 : case SID_FM_AUTOFILTER:
1029 : case SID_FM_REFRESH:
1030 : case SID_FM_REFRESH_FORM_CONTROL:
1031 : case SID_FM_VIEW_AS_GRID:
1032 0 : GetFormState(rSet,nWhich);
1033 0 : break;
1034 :
1035 : case SID_FM_CHANGECONTROLTYPE:
1036 : {
1037 0 : if ( !m_pFormView || !m_bDesignMode )
1038 0 : rSet.DisableItem( nWhich );
1039 : else
1040 : {
1041 0 : if ( !GetImpl()->canConvertCurrentSelectionToControl( OBJ_FM_FIXEDTEXT ) )
1042 : // if it cannot be converted to a fixed text, it is no single control
1043 0 : rSet.DisableItem( nWhich );
1044 : }
1045 0 : } break;
1046 :
1047 : case SID_FM_CONVERTTO_FILECONTROL :
1048 : case SID_FM_CONVERTTO_CURRENCY :
1049 : case SID_FM_CONVERTTO_PATTERN :
1050 : case SID_FM_CONVERTTO_IMAGECONTROL :
1051 : case SID_FM_CONVERTTO_SCROLLBAR :
1052 : case SID_FM_CONVERTTO_NAVIGATIONBAR :
1053 : case SID_FM_CONVERTTO_IMAGEBUTTON :
1054 : case SID_FM_CONVERTTO_EDIT :
1055 : case SID_FM_CONVERTTO_BUTTON :
1056 : case SID_FM_CONVERTTO_FIXEDTEXT :
1057 : case SID_FM_CONVERTTO_LISTBOX :
1058 : case SID_FM_CONVERTTO_CHECKBOX :
1059 : case SID_FM_CONVERTTO_RADIOBUTTON :
1060 : case SID_FM_CONVERTTO_GROUPBOX :
1061 : case SID_FM_CONVERTTO_COMBOBOX :
1062 : case SID_FM_CONVERTTO_DATE :
1063 : case SID_FM_CONVERTTO_TIME :
1064 : case SID_FM_CONVERTTO_NUMERIC :
1065 : case SID_FM_CONVERTTO_FORMATTED :
1066 : case SID_FM_CONVERTTO_SPINBUTTON :
1067 : {
1068 0 : if ( !m_pFormView || !m_bDesignMode || !GetImpl()->canConvertCurrentSelectionToControl( nWhich ) )
1069 0 : rSet.DisableItem( nWhich );
1070 : else
1071 : {
1072 0 : rSet.Put( SfxBoolItem( nWhich, false ) );
1073 : // just to have a defined state (available and not checked)
1074 : }
1075 : }
1076 0 : break;
1077 : }
1078 82 : nWhich = aIter.NextWhich();
1079 82 : }
1080 82 : }
1081 :
1082 :
1083 0 : void FmFormShell::GetFormState(SfxItemSet &rSet, sal_uInt16 nWhich)
1084 : {
1085 0 : if ( !GetImpl()->getNavController().is()
1086 0 : || !isRowSetAlive(GetImpl()->getNavController()->getModel())
1087 0 : || !m_pFormView
1088 0 : || m_bDesignMode
1089 0 : || !GetImpl()->getActiveForm().is()
1090 0 : || GetImpl()->isInFilterMode()
1091 : )
1092 0 : rSet.DisableItem(nWhich);
1093 : else
1094 : {
1095 0 : bool bEnable = false;
1096 : try
1097 : {
1098 0 : switch (nWhich)
1099 : {
1100 : case SID_FM_VIEW_AS_GRID:
1101 0 : if (GetImpl()->getHostFrame().is() && GetImpl()->getNavController().is())
1102 : {
1103 0 : bEnable = true;
1104 : bool bDisplayingCurrent =
1105 : GetImpl()->getInternalForm(
1106 0 : Reference< XForm >( GetImpl()->getNavController()->getModel(), UNO_QUERY )
1107 0 : ) == GetImpl()->getExternallyDisplayedForm();
1108 0 : rSet.Put(SfxBoolItem(nWhich, bDisplayingCurrent));
1109 : }
1110 0 : break;
1111 :
1112 : case SID_FM_SEARCH:
1113 : {
1114 0 : Reference< ::com::sun::star::beans::XPropertySet > xNavSet(GetImpl()->getActiveForm(), UNO_QUERY);
1115 0 : sal_Int32 nCount = ::comphelper::getINT32(xNavSet->getPropertyValue(FM_PROP_ROWCOUNT));
1116 0 : bEnable = nCount != 0;
1117 0 : } break;
1118 : case SID_FM_RECORD_ABSOLUTE:
1119 : case SID_FM_RECORD_TOTAL:
1120 : {
1121 0 : FeatureState aState;
1122 0 : GetImpl()->getNavControllerFeatures()->getState( nWhich, aState );
1123 0 : if ( SID_FM_RECORD_ABSOLUTE == nWhich )
1124 : {
1125 0 : sal_Int32 nPosition = 0;
1126 0 : aState.State >>= nPosition;
1127 0 : rSet.Put( SfxInt32Item( nWhich, nPosition ) );
1128 : }
1129 0 : else if ( SID_FM_RECORD_TOTAL == nWhich )
1130 : {
1131 0 : OUString sTotalCount;
1132 0 : aState.State >>= sTotalCount;
1133 0 : rSet.Put( SfxStringItem( nWhich, sTotalCount ) );
1134 : }
1135 0 : bEnable = aState.Enabled;
1136 : }
1137 0 : break;
1138 :
1139 : // first, prev, next, last, and absolute affect the nav controller, not the
1140 : // active controller
1141 : case SID_FM_RECORD_FIRST:
1142 : case SID_FM_RECORD_PREV:
1143 : case SID_FM_RECORD_NEXT:
1144 : case SID_FM_RECORD_LAST:
1145 : case SID_FM_RECORD_NEW:
1146 : case SID_FM_RECORD_SAVE:
1147 : case SID_FM_RECORD_UNDO:
1148 : case SID_FM_RECORD_DELETE:
1149 : case SID_FM_REFRESH:
1150 : case SID_FM_REFRESH_FORM_CONTROL:
1151 : case SID_FM_REMOVE_FILTER_SORT:
1152 : case SID_FM_SORTUP:
1153 : case SID_FM_SORTDOWN:
1154 : case SID_FM_AUTOFILTER:
1155 : case SID_FM_ORDERCRIT:
1156 0 : bEnable = GetImpl()->IsFormSlotEnabled( nWhich );
1157 0 : break;
1158 :
1159 : case SID_FM_FORM_FILTERED:
1160 : {
1161 0 : FeatureState aState;
1162 0 : bEnable = GetImpl()->IsFormSlotEnabled( nWhich, &aState );
1163 :
1164 0 : rSet.Put( SfxBoolItem( nWhich, ::comphelper::getBOOL( aState.State ) ) );
1165 : }
1166 0 : break;
1167 :
1168 : case SID_FM_FILTER_START:
1169 0 : bEnable = GetImpl()->getActiveControllerFeatures()->canDoFormFilter();
1170 0 : break;
1171 : }
1172 : }
1173 0 : catch( const Exception& )
1174 : {
1175 : OSL_FAIL( "FmFormShell::GetFormState: caught an exception while determining the state!" );
1176 : }
1177 0 : if (!bEnable)
1178 0 : rSet.DisableItem(nWhich);
1179 : }
1180 0 : }
1181 :
1182 :
1183 24546 : FmFormPage* FmFormShell::GetCurPage() const
1184 : {
1185 24546 : FmFormPage* pP = NULL;
1186 24546 : if (m_pFormView && m_pFormView->GetSdrPageView())
1187 24512 : pP = PTR_CAST(FmFormPage,m_pFormView->GetSdrPageView()->GetPage());
1188 24546 : return pP;
1189 : }
1190 :
1191 :
1192 16142 : void FmFormShell::SetView( FmFormView* _pView )
1193 : {
1194 16142 : if ( m_pFormView )
1195 : {
1196 5662 : if ( IsActive() )
1197 0 : GetImpl()->viewDeactivated( *m_pFormView );
1198 :
1199 5662 : m_pFormView->SetFormShell( NULL, FmFormView::FormShellAccess() );
1200 5662 : m_pFormView = NULL;
1201 5662 : m_pFormModel = NULL;
1202 : }
1203 :
1204 16142 : if ( !_pView )
1205 26832 : return;
1206 :
1207 5452 : m_pFormView = _pView;
1208 5452 : m_pFormView->SetFormShell( this, FmFormView::FormShellAccess() );
1209 5452 : m_pFormModel = static_cast<FmFormModel*>(m_pFormView->GetModel());
1210 :
1211 5452 : impl_setDesignMode( m_pFormView->IsDesignMode() );
1212 :
1213 : // We activate our view if we are activated ourself, but sometimes the Activate precedes the SetView.
1214 : // But here we know both the view and our activation state so we at least are able to pass the latter
1215 : // to the former.
1216 : // FS - 30.06.99 - 67308
1217 5452 : if ( IsActive() )
1218 4586 : GetImpl()->viewActivated( *m_pFormView );
1219 : }
1220 :
1221 :
1222 20038 : void FmFormShell::DetermineForms(bool bInvalidate)
1223 : {
1224 : // Existieren Formulare auf der aktuellen Page
1225 20038 : bool bForms = GetImpl()->hasForms();
1226 20038 : if (bForms != m_bHasForms)
1227 : {
1228 250 : m_bHasForms = bForms;
1229 250 : if (bInvalidate)
1230 242 : UIFeatureChanged();
1231 : }
1232 20038 : }
1233 :
1234 :
1235 0 : bool FmFormShell::GetY2KState(sal_uInt16& nReturn)
1236 : {
1237 0 : return GetImpl()->GetY2KState(nReturn);
1238 : }
1239 :
1240 :
1241 10 : void FmFormShell::SetY2KState(sal_uInt16 n)
1242 : {
1243 10 : GetImpl()->SetY2KState(n);
1244 10 : }
1245 :
1246 :
1247 5550 : void FmFormShell::Activate(bool bMDI)
1248 : {
1249 5550 : SfxShell::Activate(bMDI);
1250 :
1251 5550 : if ( m_pFormView )
1252 964 : GetImpl()->viewActivated( *m_pFormView, true );
1253 5550 : }
1254 :
1255 :
1256 5762 : void FmFormShell::Deactivate(bool bMDI)
1257 : {
1258 5762 : SfxShell::Deactivate(bMDI);
1259 :
1260 5762 : if ( m_pFormView )
1261 5762 : GetImpl()->viewDeactivated( *m_pFormView, false );
1262 5762 : }
1263 :
1264 :
1265 0 : void FmFormShell::ExecuteTextAttribute( SfxRequest& _rReq )
1266 : {
1267 0 : m_pImpl->ExecuteTextAttribute( _rReq );
1268 0 : }
1269 :
1270 :
1271 2 : void FmFormShell::GetTextAttributeState( SfxItemSet& _rSet )
1272 : {
1273 2 : m_pImpl->GetTextAttributeState( _rSet );
1274 2 : }
1275 :
1276 :
1277 23799 : bool FmFormShell::IsActiveControl() const
1278 : {
1279 23799 : return m_pImpl->IsActiveControl();
1280 : }
1281 :
1282 :
1283 605 : void FmFormShell::ForgetActiveControl()
1284 : {
1285 605 : m_pImpl->ForgetActiveControl();
1286 605 : }
1287 :
1288 :
1289 5660 : void FmFormShell::SetControlActivationHandler( const Link& _rHdl )
1290 : {
1291 5660 : m_pImpl->SetControlActivationHandler( _rHdl );
1292 5660 : }
1293 :
1294 :
1295 : namespace
1296 : {
1297 190 : SdrUnoObj* lcl_findUnoObject( const SdrObjList& _rObjList, const Reference< XControlModel >& _rxModel )
1298 : {
1299 190 : SdrObjListIter aIter( _rObjList );
1300 446 : while ( aIter.IsMore() )
1301 : {
1302 254 : SdrObject* pObject = aIter.Next();
1303 254 : SdrUnoObj* pUnoObject = pObject ? PTR_CAST( SdrUnoObj, pObject ) : NULL;
1304 254 : if ( !pUnoObject )
1305 0 : continue;
1306 :
1307 254 : Reference< XControlModel > xControlModel = pUnoObject->GetUnoControlModel();
1308 254 : if ( !xControlModel.is() )
1309 0 : continue;
1310 :
1311 254 : if ( _rxModel == xControlModel )
1312 188 : return pUnoObject;
1313 66 : }
1314 2 : return NULL;
1315 : }
1316 : }
1317 :
1318 :
1319 0 : void FmFormShell::ToggleControlFocus( const SdrUnoObj& i_rUnoObject, const SdrView& i_rView, OutputDevice& i_rDevice ) const
1320 : {
1321 : try
1322 : {
1323 : // check if the focus currently is in a control
1324 : // Well, okay, do it the other way 'round: Check whether the current control of the active controller
1325 : // actually has the focus. This should be equivalent.
1326 0 : const bool bHasControlFocus = GetImpl()->HasControlFocus();
1327 :
1328 0 : if ( bHasControlFocus )
1329 : {
1330 0 : vcl::Window* pWindow( dynamic_cast< vcl::Window* >( &i_rDevice ) );
1331 : OSL_ENSURE( pWindow, "FmFormShell::ToggleControlFocus: I need a Window, really!" );
1332 0 : if ( pWindow )
1333 0 : pWindow->GrabFocus();
1334 : }
1335 : else
1336 : {
1337 0 : Reference< XControl > xControl;
1338 0 : GetFormControl( i_rUnoObject.GetUnoControlModel(), i_rView, i_rDevice, xControl );
1339 0 : Reference< XWindow > xControlWindow( xControl, UNO_QUERY );
1340 0 : if ( xControlWindow.is() )
1341 0 : xControlWindow->setFocus();
1342 : }
1343 : }
1344 0 : catch( const Exception& )
1345 : {
1346 : DBG_UNHANDLED_EXCEPTION();
1347 : }
1348 0 : }
1349 :
1350 :
1351 : namespace
1352 : {
1353 0 : class FocusableControlsFilter : public ::svx::ISdrObjectFilter
1354 : {
1355 : public:
1356 0 : FocusableControlsFilter( const SdrView& i_rView, const OutputDevice& i_rDevice )
1357 : :m_rView( i_rView )
1358 0 : ,m_rDevice( i_rDevice )
1359 : {
1360 0 : }
1361 :
1362 : public:
1363 0 : virtual bool includeObject( const SdrObject& i_rObject ) const SAL_OVERRIDE
1364 : {
1365 0 : const SdrUnoObj* pUnoObj = dynamic_cast< const SdrUnoObj* >( &i_rObject );
1366 0 : if ( !pUnoObj )
1367 0 : return false;
1368 :
1369 0 : Reference< XControl > xControl = pUnoObj->GetUnoControl( m_rView, m_rDevice );
1370 0 : return FmXFormView::isFocusable( xControl );
1371 : }
1372 :
1373 : private:
1374 : const SdrView& m_rView;
1375 : const OutputDevice& m_rDevice;
1376 : };
1377 : }
1378 :
1379 :
1380 0 : ::std::unique_ptr< ::svx::ISdrObjectFilter > FmFormShell::CreateFocusableControlFilter( const SdrView& i_rView, const OutputDevice& i_rDevice ) const
1381 : {
1382 0 : ::std::unique_ptr< ::svx::ISdrObjectFilter > pFilter;
1383 :
1384 0 : if ( !i_rView.IsDesignMode() )
1385 0 : pFilter.reset( new FocusableControlsFilter( i_rView, i_rDevice ) );
1386 :
1387 0 : return pFilter;
1388 : }
1389 :
1390 :
1391 190 : SdrUnoObj* FmFormShell::GetFormControl( const Reference< XControlModel >& _rxModel, const SdrView& _rView, const OutputDevice& _rDevice, Reference< XControl >& _out_rxControl ) const
1392 : {
1393 190 : if ( !_rxModel.is() )
1394 0 : return NULL;
1395 :
1396 : // we can only retrieve controls for SdrObjects which belong to page which is actually displayed in the given view
1397 190 : SdrPageView* pPageView = _rView.GetSdrPageView();
1398 190 : SdrPage* pPage = pPageView ? pPageView->GetPage() : NULL;
1399 : OSL_ENSURE( pPage, "FmFormShell::GetFormControl: no page displayed in the given view!" );
1400 190 : if ( !pPage )
1401 0 : return NULL;
1402 :
1403 190 : SdrUnoObj* pUnoObject = lcl_findUnoObject( *pPage, _rxModel );
1404 190 : if ( pUnoObject )
1405 : {
1406 188 : _out_rxControl = pUnoObject->GetUnoControl( _rView, _rDevice );
1407 188 : return pUnoObject;
1408 : }
1409 :
1410 : #if OSL_DEBUG_LEVEL > 0
1411 : // perhaps we are fed with a control model which lives on a page other than the one displayed
1412 : // in the given view. This is worth being reported as error, in non-product builds.
1413 : FmFormModel* pModel = GetFormModel();
1414 : if ( pModel )
1415 : {
1416 : sal_uInt16 pageCount = pModel->GetPageCount();
1417 : for ( sal_uInt16 page = 0; page < pageCount; ++page )
1418 : {
1419 : pPage = pModel->GetPage( page );
1420 : OSL_ENSURE( pPage, "FmFormShell::GetFormControl: NULL page encountered!" );
1421 : if ( !pPage )
1422 : continue;
1423 :
1424 : pUnoObject = lcl_findUnoObject( *pPage, _rxModel );
1425 : OSL_ENSURE( !pUnoObject, "FmFormShell::GetFormControl: the given control model belongs to a wrong page (displayed elsewhere)!" );
1426 : }
1427 : }
1428 : #endif
1429 :
1430 2 : return NULL;
1431 : }
1432 :
1433 :
1434 0 : Reference< runtime::XFormController > FmFormShell::GetFormController( const Reference< XForm >& _rxForm, const SdrView& _rView, const OutputDevice& _rDevice ) const
1435 : {
1436 0 : const FmFormView* pFormView = dynamic_cast< const FmFormView* >( &_rView );
1437 0 : if ( !pFormView )
1438 0 : return NULL;
1439 :
1440 0 : return pFormView->GetFormController( _rxForm, _rDevice );
1441 : }
1442 :
1443 :
1444 46 : void FmFormShell::SetDesignMode( bool _bDesignMode )
1445 : {
1446 46 : if ( _bDesignMode == m_bDesignMode )
1447 46 : return;
1448 :
1449 46 : FmFormModel* pModel = GetFormModel();
1450 46 : if (pModel)
1451 : // fuer die Zeit des Uebergangs das Undo-Environment ausschalten, das sichert, dass man dort auch nicht-transiente
1452 : // Properties mal eben aendern kann (sollte allerdings mit Vorsicht genossen und beim Rueckschalten des Modes
1453 : // auch immer wieder rueckgaegig gemacht werden. Ein Beispiel ist das Setzen der maximalen Text-Laenge durch das
1454 : // OEditModel an seinem Control.)
1455 46 : pModel->GetUndoEnv().Lock();
1456 :
1457 : // dann die eigentliche Umschaltung
1458 46 : if ( m_bDesignMode || PrepareClose( true ) )
1459 46 : impl_setDesignMode(!m_bDesignMode );
1460 :
1461 : // und mein Undo-Environment wieder an
1462 46 : if ( pModel )
1463 46 : pModel->GetUndoEnv().UnLock();
1464 651 : }
1465 :
1466 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|