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