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 :
21 : #include <sal/macros.h>
22 : #include "fmitems.hxx"
23 : #include "fmobj.hxx"
24 : #include "fmpgeimp.hxx"
25 : #include "svx/fmtools.hxx"
26 : #include "fmprop.hrc"
27 : #include "svx/fmresids.hrc"
28 : #include "fmservs.hxx"
29 : #include "fmshimp.hxx"
30 : #include "fmtextcontrolshell.hxx"
31 : #include "fmundo.hxx"
32 : #include "fmurl.hxx"
33 : #include "fmvwimp.hxx"
34 : #include "formtoolbars.hxx"
35 : #include "gridcols.hxx"
36 : #include "svx/svditer.hxx"
37 : #include "svx/dialmgr.hxx"
38 : #include "svx/dialogs.hrc"
39 : #include "svx/fmglob.hxx"
40 : #include "svx/fmmodel.hxx"
41 : #include "svx/fmpage.hxx"
42 : #include "svx/fmshell.hxx"
43 : #include "svx/obj3d.hxx"
44 : #include "svx/sdrpagewindow.hxx"
45 : #include "svx/svdpagv.hxx"
46 : #include "svx/svxdlg.hxx"
47 : #include "svx/svxids.hrc"
48 :
49 : #include <com/sun/star/awt/XWindow2.hpp>
50 : #include <com/sun/star/awt/XCheckBox.hpp>
51 : #include <com/sun/star/awt/XListBox.hpp>
52 : #include <com/sun/star/awt/XTextComponent.hpp>
53 : #include <com/sun/star/beans/theIntrospection.hpp>
54 : #include <com/sun/star/beans/NamedValue.hpp>
55 : #include <com/sun/star/beans/PropertyAttribute.hpp>
56 : #include <com/sun/star/beans/XPropertyState.hpp>
57 : #include <com/sun/star/container/XContainer.hpp>
58 : #include <com/sun/star/container/XEnumeration.hpp>
59 : #include <com/sun/star/container/XEnumerationAccess.hpp>
60 : #include <com/sun/star/container/XIndexAccess.hpp>
61 : #include <com/sun/star/container/XNamed.hpp>
62 : #include <com/sun/star/form/ListSourceType.hpp>
63 : #include <com/sun/star/form/TabOrderDialog.hpp>
64 : #include <com/sun/star/form/XBoundComponent.hpp>
65 : #include <com/sun/star/form/XBoundControl.hpp>
66 : #include <com/sun/star/form/XGrid.hpp>
67 : #include <com/sun/star/form/XGridPeer.hpp>
68 : #include <com/sun/star/form/XLoadable.hpp>
69 : #include <com/sun/star/form/XReset.hpp>
70 : #include <com/sun/star/form/binding/XBindableValue.hpp>
71 : #include <com/sun/star/form/binding/XListEntrySink.hpp>
72 : #include <com/sun/star/frame/FrameSearchFlag.hpp>
73 : #include <com/sun/star/script/XEventAttacherManager.hpp>
74 : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
75 : #include <com/sun/star/util/XCancellable.hpp>
76 : #include <com/sun/star/util/XModeSelector.hpp>
77 : #include <com/sun/star/util/XModifyBroadcaster.hpp>
78 : #include <com/sun/star/util/XNumberFormatter.hpp>
79 : #include <com/sun/star/view/XSelectionSupplier.hpp>
80 :
81 : #include <comphelper/evtmethodhelper.hxx>
82 : #include <comphelper/processfactory.hxx>
83 : #include <comphelper/property.hxx>
84 : #include <comphelper/solarmutex.hxx>
85 : #include <comphelper/string.hxx>
86 : #include <connectivity/dbtools.hxx>
87 : #include <sfx2/dispatch.hxx>
88 : #include <sfx2/docfile.hxx>
89 : #include <sfx2/frame.hxx>
90 : #include <sfx2/objsh.hxx>
91 : #include <sfx2/viewfrm.hxx>
92 : #include <sfx2/viewsh.hxx>
93 : #include <toolkit/helper/vclunohelper.hxx>
94 : #include <tools/diagnose_ex.h>
95 : #include <vcl/layout.hxx>
96 : #include <vcl/waitobj.hxx>
97 : #include <vcl/settings.hxx>
98 :
99 : #include <algorithm>
100 : #include <functional>
101 : #include <map>
102 : #include <vector>
103 : #include <boost/scoped_ptr.hpp>
104 :
105 : // wird fuer Invalidate verwendet -> mitpflegen
106 : static const sal_uInt16 DatabaseSlotMap[] =
107 : {
108 : SID_FM_RECORD_FIRST,
109 : SID_FM_RECORD_NEXT,
110 : SID_FM_RECORD_PREV,
111 : SID_FM_RECORD_LAST,
112 : SID_FM_RECORD_NEW,
113 : SID_FM_RECORD_DELETE,
114 : SID_FM_RECORD_ABSOLUTE,
115 : SID_FM_RECORD_TOTAL,
116 : SID_FM_RECORD_SAVE,
117 : SID_FM_RECORD_UNDO,
118 : SID_FM_REMOVE_FILTER_SORT,
119 : SID_FM_SORTUP,
120 : SID_FM_SORTDOWN,
121 : SID_FM_ORDERCRIT,
122 : SID_FM_AUTOFILTER,
123 : SID_FM_FORM_FILTERED,
124 : SID_FM_REFRESH,
125 : SID_FM_REFRESH_FORM_CONTROL,
126 : SID_FM_SEARCH,
127 : SID_FM_FILTER_START,
128 : SID_FM_VIEW_AS_GRID,
129 : 0
130 : };
131 :
132 : // wird fuer Invalidate verwendet -> mitpflegen
133 : // aufsteigend sortieren !!!!!!
134 : static const sal_Int16 DlgSlotMap[] = // slots des Controllers
135 : {
136 : SID_FM_CTL_PROPERTIES,
137 : SID_FM_PROPERTIES,
138 : SID_FM_TAB_DIALOG,
139 : SID_FM_ADD_FIELD,
140 : SID_FM_SHOW_FMEXPLORER,
141 : SID_FM_FIELDS_CONTROL,
142 : SID_FM_SHOW_PROPERTIES,
143 : SID_FM_PROPERTY_CONTROL,
144 : SID_FM_FMEXPLORER_CONTROL,
145 : SID_FM_SHOW_DATANAVIGATOR,
146 : SID_FM_DATANAVIGATOR_CONTROL,
147 : 0
148 : };
149 :
150 : static const sal_Int16 SelObjectSlotMap[] = // vom SelObject abhaengige Slots
151 : {
152 : SID_FM_CONVERTTO_EDIT,
153 : SID_FM_CONVERTTO_BUTTON,
154 : SID_FM_CONVERTTO_FIXEDTEXT,
155 : SID_FM_CONVERTTO_LISTBOX,
156 : SID_FM_CONVERTTO_CHECKBOX,
157 : SID_FM_CONVERTTO_RADIOBUTTON,
158 : SID_FM_CONVERTTO_GROUPBOX,
159 : SID_FM_CONVERTTO_COMBOBOX,
160 : SID_FM_CONVERTTO_IMAGEBUTTON,
161 : SID_FM_CONVERTTO_FILECONTROL,
162 : SID_FM_CONVERTTO_DATE,
163 : SID_FM_CONVERTTO_TIME,
164 : SID_FM_CONVERTTO_NUMERIC,
165 : SID_FM_CONVERTTO_CURRENCY,
166 : SID_FM_CONVERTTO_PATTERN,
167 : SID_FM_CONVERTTO_IMAGECONTROL,
168 : SID_FM_CONVERTTO_FORMATTED,
169 : SID_FM_CONVERTTO_SCROLLBAR,
170 : SID_FM_CONVERTTO_SPINBUTTON,
171 : SID_FM_CONVERTTO_NAVIGATIONBAR,
172 :
173 : SID_FM_FMEXPLORER_CONTROL,
174 : SID_FM_DATANAVIGATOR_CONTROL,
175 :
176 : 0
177 : };
178 :
179 : // die folgenden Arrays muessen kosistent sein, also einander entsprechende Eintraege an der selben relativen Position
180 : // innerhalb ihres jeweiligen Arrays stehen
181 : static const sal_Int16 nConvertSlots[] =
182 : {
183 : SID_FM_CONVERTTO_EDIT,
184 : SID_FM_CONVERTTO_BUTTON,
185 : SID_FM_CONVERTTO_FIXEDTEXT,
186 : SID_FM_CONVERTTO_LISTBOX,
187 : SID_FM_CONVERTTO_CHECKBOX,
188 : SID_FM_CONVERTTO_RADIOBUTTON,
189 : SID_FM_CONVERTTO_GROUPBOX,
190 : SID_FM_CONVERTTO_COMBOBOX,
191 : SID_FM_CONVERTTO_IMAGEBUTTON,
192 : SID_FM_CONVERTTO_FILECONTROL,
193 : SID_FM_CONVERTTO_DATE,
194 : SID_FM_CONVERTTO_TIME,
195 : SID_FM_CONVERTTO_NUMERIC,
196 : SID_FM_CONVERTTO_CURRENCY,
197 : SID_FM_CONVERTTO_PATTERN,
198 : SID_FM_CONVERTTO_IMAGECONTROL,
199 : SID_FM_CONVERTTO_FORMATTED,
200 : SID_FM_CONVERTTO_SCROLLBAR,
201 : SID_FM_CONVERTTO_SPINBUTTON,
202 : SID_FM_CONVERTTO_NAVIGATIONBAR
203 : };
204 :
205 : static const sal_Int16 nCreateSlots[] =
206 : {
207 : SID_FM_EDIT,
208 : SID_FM_PUSHBUTTON,
209 : SID_FM_FIXEDTEXT,
210 : SID_FM_LISTBOX,
211 : SID_FM_CHECKBOX,
212 : SID_FM_RADIOBUTTON,
213 : SID_FM_GROUPBOX,
214 : SID_FM_COMBOBOX,
215 : SID_FM_IMAGEBUTTON,
216 : SID_FM_FILECONTROL,
217 : SID_FM_DATEFIELD,
218 : SID_FM_TIMEFIELD,
219 : SID_FM_NUMERICFIELD,
220 : SID_FM_CURRENCYFIELD,
221 : SID_FM_PATTERNFIELD,
222 : SID_FM_IMAGECONTROL,
223 : SID_FM_FORMATTEDFIELD,
224 : SID_FM_SCROLLBAR,
225 : SID_FM_SPINBUTTON,
226 : SID_FM_NAVIGATIONBAR
227 : };
228 :
229 : static const sal_Int16 nObjectTypes[] =
230 : {
231 : OBJ_FM_EDIT,
232 : OBJ_FM_BUTTON,
233 : OBJ_FM_FIXEDTEXT,
234 : OBJ_FM_LISTBOX,
235 : OBJ_FM_CHECKBOX,
236 : OBJ_FM_RADIOBUTTON,
237 : OBJ_FM_GROUPBOX,
238 : OBJ_FM_COMBOBOX,
239 : OBJ_FM_IMAGEBUTTON,
240 : OBJ_FM_FILECONTROL,
241 : OBJ_FM_DATEFIELD,
242 : OBJ_FM_TIMEFIELD,
243 : OBJ_FM_NUMERICFIELD,
244 : OBJ_FM_CURRENCYFIELD,
245 : OBJ_FM_PATTERNFIELD,
246 : OBJ_FM_IMAGECONTROL,
247 : OBJ_FM_FORMATTEDFIELD,
248 : OBJ_FM_SCROLLBAR,
249 : OBJ_FM_SPINBUTTON,
250 : OBJ_FM_NAVIGATIONBAR
251 : };
252 :
253 : using namespace ::com::sun::star;
254 : using namespace ::com::sun::star::ui;
255 : using namespace ::com::sun::star::uno;
256 : using namespace ::com::sun::star::sdb;
257 : using namespace ::com::sun::star::sdbc;
258 : using namespace ::com::sun::star::sdbcx;
259 : using namespace ::com::sun::star::beans;
260 : using namespace ::com::sun::star::container;
261 : using namespace ::com::sun::star::form;
262 : using namespace ::com::sun::star::form::binding;
263 : using namespace ::com::sun::star::form::runtime;
264 : using namespace ::com::sun::star::awt;
265 : using namespace ::com::sun::star::view;
266 : using namespace ::com::sun::star::util;
267 : using namespace ::com::sun::star::frame;
268 : using namespace ::com::sun::star::script;
269 : using namespace ::svxform;
270 : using namespace ::svx;
271 : using namespace ::dbtools;
272 :
273 :
274 : //= helper
275 :
276 : namespace
277 : {
278 :
279 0 : void collectInterfacesFromMarkList( const SdrMarkList& _rMarkList, InterfaceBag& /* [out] */ _rInterfaces )
280 : {
281 0 : _rInterfaces.clear();
282 :
283 0 : const size_t nMarkCount = _rMarkList.GetMarkCount();
284 0 : for ( size_t i = 0; i < nMarkCount; ++i)
285 : {
286 0 : SdrObject* pCurrent = _rMarkList.GetMark( i )->GetMarkedSdrObj();
287 :
288 0 : boost::scoped_ptr<SdrObjListIter> pGroupIterator;
289 0 : if ( pCurrent->IsGroupObject() )
290 : {
291 0 : pGroupIterator.reset(new SdrObjListIter( *pCurrent->GetSubList() ));
292 0 : pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
293 : }
294 :
295 0 : while ( pCurrent )
296 : {
297 0 : FmFormObj* pAsFormObject = FmFormObj::GetFormObject( pCurrent );
298 : // note this will de-reference virtual objects, if necessary/possible
299 0 : if ( pAsFormObject )
300 : {
301 0 : Reference< XInterface > xControlModel( pAsFormObject->GetUnoControlModel(), UNO_QUERY );
302 : // the UNO_QUERY is important for normalization
303 0 : if ( xControlModel.is() )
304 0 : _rInterfaces.insert( xControlModel );
305 : }
306 :
307 : // next element
308 0 : pCurrent = pGroupIterator && pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
309 : }
310 0 : }
311 0 : }
312 :
313 :
314 0 : sal_Int16 GridView2ModelPos(const Reference< XIndexAccess>& rColumns, sal_Int16 nViewPos)
315 : {
316 : try
317 : {
318 0 : if (rColumns.is())
319 : {
320 : // loop through all columns
321 : sal_Int16 i;
322 0 : Reference< XPropertySet> xCur;
323 0 : for (i=0; i<rColumns->getCount(); ++i)
324 : {
325 0 : rColumns->getByIndex(i) >>= xCur;
326 0 : if (!::comphelper::getBOOL(xCur->getPropertyValue(FM_PROP_HIDDEN)))
327 : {
328 : // for every visible col : if nViewPos is greater zero, decrement it, else we
329 : // have found the model position
330 0 : if (!nViewPos)
331 0 : break;
332 : else
333 0 : --nViewPos;
334 : }
335 : }
336 0 : if (i<rColumns->getCount())
337 0 : return i;
338 : }
339 : }
340 0 : catch(const Exception&)
341 : {
342 : DBG_UNHANDLED_EXCEPTION();
343 : }
344 0 : return (sal_Int16)-1;
345 : }
346 :
347 :
348 0 : void TransferEventScripts(const Reference< XControlModel>& xModel, const Reference< XControl>& xControl,
349 : const Sequence< ScriptEventDescriptor>& rTransferIfAvailable)
350 : {
351 : // first check if we have a XEventAttacherManager for the model
352 0 : Reference< XChild> xModelChild(xModel, UNO_QUERY);
353 0 : if (!xModelChild.is())
354 0 : return; // nothing to do
355 :
356 0 : Reference< XEventAttacherManager> xEventManager(xModelChild->getParent(), UNO_QUERY);
357 0 : if (!xEventManager.is())
358 0 : return; // nothing to do
359 :
360 0 : if (!rTransferIfAvailable.getLength())
361 0 : return; // nothing to do
362 :
363 : // check for the index of the model within its parent
364 0 : Reference< XIndexAccess> xParentIndex(xModelChild->getParent(), UNO_QUERY);
365 0 : if (!xParentIndex.is())
366 0 : return; // nothing to do
367 0 : sal_Int32 nIndex = getElementPos(xParentIndex, xModel);
368 0 : if (nIndex<0 || nIndex>=xParentIndex->getCount())
369 0 : return; // nothing to do
370 :
371 : // then we need information about the listeners supported by the control and the model
372 0 : Sequence< Type> aModelListeners;
373 0 : Sequence< Type> aControlListeners;
374 :
375 0 : Reference< XIntrospection> xIntrospection = theIntrospection::get(::comphelper::getProcessComponentContext());
376 :
377 0 : if (xModel.is())
378 : {
379 0 : Any aModel(makeAny(xModel));
380 0 : aModelListeners = xIntrospection->inspect(aModel)->getSupportedListeners();
381 : }
382 :
383 0 : if (xControl.is())
384 : {
385 0 : Any aControl(makeAny(xControl));
386 0 : aControlListeners = xIntrospection->inspect(aControl)->getSupportedListeners();
387 : }
388 :
389 0 : sal_Int32 nMaxNewLen = aModelListeners.getLength() + aControlListeners.getLength();
390 0 : if (!nMaxNewLen)
391 0 : return; // the model and the listener don't support any listeners (or we were unable to retrieve these infos)
392 :
393 0 : Sequence< ScriptEventDescriptor> aTransferable(nMaxNewLen);
394 0 : ScriptEventDescriptor* pTransferable = aTransferable.getArray();
395 :
396 0 : const ScriptEventDescriptor* pCurrent = rTransferIfAvailable.getConstArray();
397 : sal_Int32 i,j,k;
398 0 : for (i=0; i<rTransferIfAvailable.getLength(); ++i, ++pCurrent)
399 : {
400 : // search the model/control idl classes for the event described by pCurrent
401 0 : for ( Sequence< Type>* pCurrentArray = &aModelListeners;
402 : pCurrentArray;
403 : pCurrentArray = (pCurrentArray == &aModelListeners) ? &aControlListeners : NULL
404 : )
405 : {
406 0 : const Type* pCurrentListeners = pCurrentArray->getConstArray();
407 0 : for (j=0; j<pCurrentArray->getLength(); ++j, ++pCurrentListeners)
408 : {
409 0 : OUString aListener = (*pCurrentListeners).getTypeName();
410 0 : sal_Int32 nTokens = comphelper::string::getTokenCount(aListener, '.');
411 0 : if (nTokens)
412 0 : aListener = aListener.getToken(nTokens - 1, '.');
413 :
414 0 : if (aListener == pCurrent->ListenerType.getStr())
415 : // the current ScriptEventDescriptor doesn't match the current listeners class
416 0 : continue;
417 :
418 : // now check the methods
419 0 : Sequence< OUString> aMethodsNames = ::comphelper::getEventMethodsForType(*pCurrentListeners);
420 :
421 0 : const OUString* pMethodsNames = aMethodsNames.getConstArray();
422 0 : for (k=0; k<aMethodsNames.getLength(); ++k, ++pMethodsNames)
423 : {
424 0 : if ((*pMethodsNames) != pCurrent->EventMethod)
425 : // the current ScriptEventDescriptor doesn't match the current listeners current method
426 0 : continue;
427 :
428 : // we can transfer the script event : the model (control) supports it
429 0 : *pTransferable = *pCurrent;
430 0 : ++pTransferable;
431 0 : break;
432 : }
433 0 : if (k<aMethodsNames.getLength())
434 0 : break;
435 0 : }
436 : }
437 : }
438 :
439 0 : sal_Int32 nRealNewLen = pTransferable - aTransferable.getArray();
440 0 : aTransferable.realloc(nRealNewLen);
441 :
442 0 : xEventManager->registerScriptEvents(nIndex, aTransferable);
443 : }
444 :
445 :
446 0 : OUString getServiceNameByControlType(sal_Int16 nType)
447 : {
448 0 : switch (nType)
449 : {
450 0 : case OBJ_FM_EDIT : return OUString(FM_COMPONENT_TEXTFIELD);
451 0 : case OBJ_FM_BUTTON : return OUString(FM_COMPONENT_COMMANDBUTTON);
452 0 : case OBJ_FM_FIXEDTEXT : return OUString(FM_COMPONENT_FIXEDTEXT);
453 0 : case OBJ_FM_LISTBOX : return OUString(FM_COMPONENT_LISTBOX);
454 0 : case OBJ_FM_CHECKBOX : return OUString(FM_COMPONENT_CHECKBOX);
455 0 : case OBJ_FM_RADIOBUTTON : return OUString(FM_COMPONENT_RADIOBUTTON);
456 0 : case OBJ_FM_GROUPBOX : return OUString(FM_COMPONENT_GROUPBOX);
457 0 : case OBJ_FM_COMBOBOX : return OUString(FM_COMPONENT_COMBOBOX);
458 0 : case OBJ_FM_GRID : return OUString(FM_COMPONENT_GRIDCONTROL);
459 0 : case OBJ_FM_IMAGEBUTTON : return OUString(FM_COMPONENT_IMAGEBUTTON);
460 0 : case OBJ_FM_FILECONTROL : return OUString(FM_COMPONENT_FILECONTROL);
461 0 : case OBJ_FM_DATEFIELD : return OUString(FM_COMPONENT_DATEFIELD);
462 0 : case OBJ_FM_TIMEFIELD : return OUString(FM_COMPONENT_TIMEFIELD);
463 0 : case OBJ_FM_NUMERICFIELD : return OUString(FM_COMPONENT_NUMERICFIELD);
464 0 : case OBJ_FM_CURRENCYFIELD : return OUString(FM_COMPONENT_CURRENCYFIELD);
465 0 : case OBJ_FM_PATTERNFIELD : return OUString(FM_COMPONENT_PATTERNFIELD);
466 0 : case OBJ_FM_HIDDEN : return OUString(FM_COMPONENT_HIDDENCONTROL);
467 0 : case OBJ_FM_IMAGECONTROL : return OUString(FM_COMPONENT_IMAGECONTROL);
468 0 : case OBJ_FM_FORMATTEDFIELD : return OUString(FM_COMPONENT_FORMATTEDFIELD);
469 0 : case OBJ_FM_SCROLLBAR : return OUString(FM_SUN_COMPONENT_SCROLLBAR);
470 0 : case OBJ_FM_SPINBUTTON : return OUString(FM_SUN_COMPONENT_SPINBUTTON);
471 0 : case OBJ_FM_NAVIGATIONBAR : return OUString(FM_SUN_COMPONENT_NAVIGATIONBAR);
472 : }
473 0 : return OUString();
474 : }
475 :
476 : }
477 :
478 :
479 : // check if the control has one of the interfaces we can use for searching
480 : // *_pCurrentText will be filled with the current text of the control (as used when searching this control)
481 0 : bool IsSearchableControl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rxControl,
482 : OUString* _pCurrentText )
483 : {
484 0 : if ( !_rxControl.is() )
485 0 : return false;
486 :
487 0 : Reference< XTextComponent > xAsText( _rxControl, UNO_QUERY );
488 0 : if ( xAsText.is() )
489 : {
490 0 : if ( _pCurrentText )
491 0 : *_pCurrentText = xAsText->getText();
492 0 : return true;
493 : }
494 :
495 0 : Reference< XListBox > xListBox( _rxControl, UNO_QUERY );
496 0 : if ( xListBox.is() )
497 : {
498 0 : if ( _pCurrentText )
499 0 : *_pCurrentText = xListBox->getSelectedItem();
500 0 : return true;
501 : }
502 :
503 0 : Reference< XCheckBox > xCheckBox( _rxControl, UNO_QUERY );
504 0 : if ( xCheckBox.is() )
505 : {
506 0 : if ( _pCurrentText )
507 : {
508 0 : switch ( (::TriState)xCheckBox->getState() )
509 : {
510 0 : case TRISTATE_FALSE: *_pCurrentText = "0"; break;
511 0 : case TRISTATE_TRUE: *_pCurrentText = "1"; break;
512 0 : default: _pCurrentText->clear(); break;
513 : }
514 : }
515 0 : return true;
516 : }
517 :
518 0 : return false;
519 : }
520 :
521 :
522 0 : bool FmXBoundFormFieldIterator::ShouldStepInto(const Reference< XInterface>& _rContainer) const
523 : {
524 0 : if (_rContainer == m_xStartingPoint)
525 : // would be quite stupid to step over the root ....
526 0 : return true;
527 :
528 0 : return Reference< XControlModel>(_rContainer, UNO_QUERY).is();
529 : }
530 :
531 :
532 0 : bool FmXBoundFormFieldIterator::ShouldHandleElement(const Reference< XInterface>& _rElement)
533 : {
534 0 : if (!_rElement.is())
535 : // NULL element
536 0 : return false;
537 :
538 0 : if (Reference< XForm>(_rElement, UNO_QUERY).is() || Reference< XGrid>(_rElement, UNO_QUERY).is())
539 : // a forms or a grid
540 0 : return false;
541 :
542 0 : Reference< XPropertySet> xSet(_rElement, UNO_QUERY);
543 0 : if (!xSet.is() || !::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
544 : // no "BoundField" property
545 0 : return false;
546 :
547 0 : Any aVal( xSet->getPropertyValue(FM_PROP_BOUNDFIELD) );
548 0 : if (aVal.getValueTypeClass() != TypeClass_INTERFACE)
549 : // void or invalid property value
550 0 : return false;
551 :
552 0 : return aVal.hasValue();
553 : }
554 :
555 :
556 1 : bool isControlList(const SdrMarkList& rMarkList)
557 : {
558 : // enthaelt die liste nur Controls und mindestens ein control
559 1 : const size_t nMarkCount = rMarkList.GetMarkCount();
560 1 : bool bControlList = nMarkCount != 0;
561 :
562 1 : bool bHadAnyLeafs = false;
563 :
564 2 : for (size_t i = 0; i < nMarkCount && bControlList; ++i)
565 : {
566 1 : SdrObject *pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
567 1 : E3dObject* pAs3DObject = PTR_CAST(E3dObject, pObj);
568 : // E3dObject's do not contain any 2D-objects (by definition)
569 : // we need this extra check here : an E3dObject->IsGroupObject says "YES", but an SdrObjListIter working
570 : // with an E3dObject doesn't give me any Nodes (E3dObject has a sub list, but no members in that list,
571 : // cause there implementation differs from the one of "normal" SdrObject's. Unfortunally SdrObject::IsGroupObject
572 : // doesn't check the element count of the sub list, which is simply a bug in IsGroupObject we can't fix at the moment).
573 : // So at the end of this function bControlList would have the same value it was initialized with above : sal_True
574 : // And this would be wrong :)
575 : // 03.02.00 - 72529 - FS
576 1 : if (!pAs3DObject)
577 : {
578 1 : if (pObj->IsGroupObject())
579 : {
580 0 : SdrObjListIter aIter(*pObj->GetSubList());
581 0 : while (aIter.IsMore() && bControlList)
582 : {
583 0 : bControlList = FmFormInventor == aIter.Next()->GetObjInventor();
584 0 : bHadAnyLeafs = true;
585 0 : }
586 : }
587 : else
588 : {
589 1 : bHadAnyLeafs = true;
590 1 : bControlList = FmFormInventor == pObj->GetObjInventor();
591 : }
592 : }
593 : }
594 :
595 1 : return bControlList && bHadAnyLeafs;
596 : }
597 :
598 :
599 0 : Reference< XForm > GetForm(const Reference< XInterface>& _rxElement)
600 : {
601 0 : Reference< XForm > xForm( _rxElement, UNO_QUERY );
602 0 : if ( xForm.is() )
603 0 : return xForm;
604 :
605 0 : Reference< XChild > xChild( _rxElement, UNO_QUERY );
606 0 : if ( xChild.is() )
607 0 : return GetForm( xChild->getParent() );
608 :
609 0 : return Reference< XForm >();
610 : }
611 :
612 3235 : FmXFormShell_Base_Disambiguation::FmXFormShell_Base_Disambiguation( ::osl::Mutex& _rMutex )
613 3235 : :FmXFormShell_BD_BASE( _rMutex )
614 : {
615 3235 : }
616 :
617 3228 : void SAL_CALL FmXFormShell_Base_Disambiguation::disposing()
618 : {
619 3228 : WeakComponentImplHelperBase::disposing();
620 : // Note:
621 : // This is a HACK.
622 : // Normally it should be sufficient to call the "disposing" of our direct
623 : // base class, but SUN PRO 5 does not like this and claims there is a conflict
624 : // with the XEventListener::disposing(EventObject) of our various listener
625 : // base classes.
626 3228 : }
627 :
628 3235 : FmXFormShell::FmXFormShell( FmFormShell& _rShell, SfxViewFrame* _pViewFrame )
629 : :FmXFormShell_BASE(m_aMutex)
630 : ,FmXFormShell_CFGBASE(OUString("Office.Common/Misc"), ConfigItemMode::DelayedUpdate)
631 : ,m_eNavigate( NavigationBarMode_NONE )
632 : ,m_nInvalidationEvent( 0 )
633 : ,m_nActivationEvent( 0 )
634 : ,m_pShell( &_rShell )
635 3235 : ,m_pTextShell( new svx::FmTextControlShell( _pViewFrame ) )
636 : ,m_aActiveControllerFeatures( this )
637 : ,m_aNavControllerFeatures( this )
638 : ,m_eDocumentType( eUnknownDocumentType )
639 : ,m_nLockSlotInvalidation( 0 )
640 : ,m_bHadPropertyBrowserInDesignMode( false )
641 : ,m_bTrackProperties( true )
642 : ,m_bUseWizards( true )
643 : ,m_bDatabaseBar( false )
644 : ,m_bInActivate( false )
645 : ,m_bSetFocus( false )
646 : ,m_bFilterMode( false )
647 : ,m_bChangingDesignMode( false )
648 : ,m_bPreparedClose( false )
649 6470 : ,m_bFirstActivation( true )
650 : {
651 3235 : m_aMarkTimer.SetTimeout(100);
652 3235 : m_aMarkTimer.SetTimeoutHdl(LINK(this,FmXFormShell,OnTimeOut));
653 :
654 3235 : m_xAttachedFrame = _pViewFrame->GetFrame().GetFrameInterface();
655 :
656 : // to prevent deletion of this we acquire our refcounter once
657 3235 : osl_atomic_increment(&m_refCount);
658 :
659 : // correct the refcounter
660 3235 : osl_atomic_decrement(&m_refCount);
661 :
662 : // cache the current configuration settings we're interested in
663 3235 : implAdjustConfigCache();
664 : // and register for changes on this settings
665 3235 : Sequence< OUString > aNames(1);
666 3235 : aNames[0] = "FormControlPilotsEnabled";
667 3235 : EnableNotification(aNames);
668 3235 : }
669 :
670 :
671 9684 : FmXFormShell::~FmXFormShell()
672 : {
673 3228 : delete m_pTextShell;
674 6456 : }
675 :
676 :
677 3165 : Reference< XModel > FmXFormShell::getContextDocument() const
678 : {
679 3165 : Reference< XModel > xModel;
680 :
681 : // determine the type of document we live in
682 : try
683 : {
684 3165 : Reference< XController > xController;
685 3165 : if ( m_xAttachedFrame.is() )
686 3165 : xController = m_xAttachedFrame->getController();
687 3165 : if ( xController.is() )
688 3165 : xModel = xController->getModel();
689 : }
690 0 : catch( const Exception& )
691 : {
692 : DBG_UNHANDLED_EXCEPTION();
693 : }
694 3165 : return xModel;
695 : }
696 :
697 :
698 4806 : bool FmXFormShell::isEnhancedForm() const
699 : {
700 4806 : return getDocumentType() == eEnhancedForm;
701 : }
702 :
703 :
704 32967 : bool FmXFormShell::impl_checkDisposed() const
705 : {
706 32967 : if ( !m_pShell )
707 : {
708 : OSL_FAIL( "FmXFormShell::impl_checkDisposed: already disposed!" );
709 0 : return true;
710 : }
711 32967 : return false;
712 : }
713 :
714 :
715 4806 : ::svxform::DocumentType FmXFormShell::getDocumentType() const
716 : {
717 4806 : if ( m_eDocumentType != eUnknownDocumentType )
718 1641 : return m_eDocumentType;
719 :
720 : // determine the type of document we live in
721 3165 : Reference< XModel > xModel = getContextDocument();
722 3165 : if ( xModel.is() )
723 3165 : m_eDocumentType = DocumentClassification::classifyDocument( xModel );
724 : else
725 : {
726 : OSL_FAIL( "FmXFormShell::getDocumentType: can't determine the document type!" );
727 0 : m_eDocumentType = eTextDocument;
728 : // fallback, just to have a defined state
729 : }
730 :
731 3165 : return m_eDocumentType;
732 : }
733 :
734 :
735 4272 : bool FmXFormShell::IsReadonlyDoc() const
736 : {
737 4272 : if ( impl_checkDisposed() )
738 0 : return true;
739 :
740 4272 : FmFormModel* pModel = m_pShell->GetFormModel();
741 4272 : if ( pModel && pModel->GetObjectShell() )
742 4272 : return pModel->GetObjectShell()->IsReadOnly() || pModel->GetObjectShell()->IsReadOnlyUI();
743 0 : return true;
744 : }
745 :
746 : // EventListener
747 :
748 2 : void SAL_CALL FmXFormShell::disposing(const lang::EventObject& e) throw( RuntimeException, std::exception )
749 : {
750 :
751 2 : if (m_xActiveController == e.Source)
752 : {
753 : // wird der Controller freigeben dann alles loslassen
754 0 : stopListening();
755 0 : m_xActiveForm = NULL;
756 0 : m_xActiveController = NULL;
757 0 : m_xNavigationController = NULL;
758 :
759 0 : m_aActiveControllerFeatures.dispose();
760 0 : m_aNavControllerFeatures.dispose();
761 :
762 0 : if ( m_pShell )
763 0 : m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
764 : }
765 :
766 2 : if (e.Source == m_xExternalViewController)
767 : {
768 0 : Reference< runtime::XFormController > xFormController( m_xExternalViewController, UNO_QUERY );
769 : OSL_ENSURE( xFormController.is(), "FmXFormShell::disposing: invalid external view controller!" );
770 0 : if (xFormController.is())
771 0 : xFormController->removeActivateListener(static_cast<XFormControllerListener*>(this));
772 :
773 0 : Reference< ::com::sun::star::lang::XComponent> xComp(m_xExternalViewController, UNO_QUERY);
774 0 : if (xComp.is())
775 0 : xComp->removeEventListener(static_cast<XEventListener*>(static_cast<XPropertyChangeListener*>(this)));
776 :
777 0 : m_xExternalViewController = NULL;
778 0 : m_xExternalDisplayedForm = NULL;
779 0 : m_xExtViewTriggerController = NULL;
780 :
781 0 : InvalidateSlot( SID_FM_VIEW_AS_GRID, false );
782 : }
783 2 : }
784 :
785 :
786 0 : void SAL_CALL FmXFormShell::propertyChange(const PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException, std::exception)
787 : {
788 0 : if ( impl_checkDisposed() )
789 0 : return;
790 :
791 0 : if (evt.PropertyName == FM_PROP_ROWCOUNT)
792 : {
793 : // Das gleich folgenden Update erzwingt ein Neu-Painten der entsprechenden Slots. Wenn ich mich aber hier nicht
794 : // in dem HauptThread der Applikation befinde (weil zum Beispiel ein Cursor gerade Datensaetze zaehlt und mir dabei
795 : // immer diese PropertyChanges beschert), kann sich das mit en normalen Paints im HauptThread der Applikation beissen.
796 : // (Solche Paints passieren zum Beispiel, wenn man einfach nur eine andere Applikation ueber das Office legt und wieder
797 : // zurueckschaltet).
798 : // Deshalb die Benutzung des SolarMutex, der sichert das ab.
799 0 : comphelper::SolarMutex& rSolarSafety = Application::GetSolarMutex();
800 0 : if (rSolarSafety.tryToAcquire())
801 : {
802 0 : m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_RECORD_TOTAL, true, false);
803 0 : m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Update(SID_FM_RECORD_TOTAL);
804 0 : rSolarSafety.release();
805 : }
806 : else
807 : {
808 : // with the following the slot is invalidated asynchron
809 0 : LockSlotInvalidation(true);
810 0 : InvalidateSlot(SID_FM_RECORD_TOTAL, false);
811 0 : LockSlotInvalidation(false);
812 : }
813 : }
814 :
815 : // this may be called from a non-main-thread so invalidate the shell asynchronously
816 0 : LockSlotInvalidation(true);
817 0 : InvalidateSlot(0, false); // special meaning : invalidate m_pShell
818 0 : LockSlotInvalidation(false);
819 : }
820 :
821 :
822 0 : void FmXFormShell::invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures )
823 : {
824 0 : if ( impl_checkDisposed() )
825 0 : return;
826 :
827 : OSL_ENSURE( _rFeatures.size() > 0, "FmXFormShell::invalidateFeatures: invalid arguments!" );
828 :
829 0 : if ( m_pShell->GetViewShell() && m_pShell->GetViewShell()->GetViewFrame() )
830 : {
831 : // unfortunately, SFX requires sal_uInt16
832 0 : ::std::vector< sal_uInt16 > aSlotIds;
833 0 : aSlotIds.reserve( _rFeatures.size() );
834 : ::std::copy( _rFeatures.begin(),
835 : _rFeatures.end(),
836 : ::std::insert_iterator< ::std::vector< sal_uInt16 > >( aSlotIds, aSlotIds.begin() )
837 0 : );
838 :
839 : // furthermore, SFX wants a terminating 0
840 0 : aSlotIds.push_back( 0 );
841 :
842 : // and, last but not least, SFX wants the ids to be sorted
843 0 : ::std::sort( aSlotIds.begin(), aSlotIds.end() - 1 );
844 :
845 0 : sal_uInt16 *pSlotIds = &(aSlotIds[0]);
846 0 : m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( pSlotIds );
847 : }
848 : }
849 :
850 :
851 1 : void SAL_CALL FmXFormShell::formActivated(const lang::EventObject& rEvent) throw( RuntimeException, std::exception )
852 : {
853 1 : if ( impl_checkDisposed() )
854 1 : return;
855 :
856 1 : Reference< runtime::XFormController > xController( rEvent.Source, UNO_QUERY_THROW );
857 1 : m_pTextShell->formActivated( xController );
858 1 : setActiveController( xController );
859 : }
860 :
861 :
862 1 : void SAL_CALL FmXFormShell::formDeactivated(const lang::EventObject& rEvent) throw( RuntimeException, std::exception )
863 : {
864 1 : if ( impl_checkDisposed() )
865 1 : return;
866 :
867 1 : Reference< runtime::XFormController > xController( rEvent.Source, UNO_QUERY_THROW );
868 1 : m_pTextShell->formDeactivated( xController );
869 : }
870 :
871 :
872 3228 : void FmXFormShell::disposing()
873 : {
874 :
875 3228 : FmXFormShell_BASE::disposing();
876 :
877 3228 : if ( m_pShell && !m_pShell->IsDesignMode() )
878 257 : setActiveController( NULL, true );
879 : // do NOT save the content of the old form (the second parameter tells this)
880 : // if we're here, then we expect that PrepareClose has been called, and thus the user
881 : // got a chance to commit or reject any changes. So in case we're here and there
882 : // are still uncommitted changes, the user explicitly wanted this.
883 :
884 3228 : m_pTextShell->dispose();
885 :
886 3228 : m_xAttachedFrame = NULL;
887 :
888 3228 : CloseExternalFormViewer();
889 :
890 6457 : while ( m_aLoadingPages.size() )
891 : {
892 1 : Application::RemoveUserEvent( m_aLoadingPages.front().nEventId );
893 1 : m_aLoadingPages.pop();
894 : }
895 :
896 : {
897 3228 : ::osl::MutexGuard aGuard(m_aInvalidationSafety);
898 3228 : if (m_nInvalidationEvent)
899 : {
900 0 : Application::RemoveUserEvent(m_nInvalidationEvent);
901 0 : m_nInvalidationEvent = 0;
902 : }
903 3228 : if ( m_nActivationEvent )
904 : {
905 2552 : Application::RemoveUserEvent( m_nActivationEvent );
906 2552 : m_nActivationEvent = 0;
907 3228 : }
908 : }
909 :
910 : {
911 3228 : ::osl::ClearableMutexGuard aGuard(m_aAsyncSafety);
912 3228 : aGuard.clear();
913 :
914 : DBG_ASSERT(!m_nInvalidationEvent, "FmXFormShell::~FmXFormShell : still have an invalidation event !");
915 : // should have been deleted while being disposed
916 :
917 3228 : m_aMarkTimer.Stop();
918 : }
919 :
920 3228 : DisableNotification();
921 :
922 3228 : RemoveElement( m_xForms );
923 3228 : m_xForms.clear();
924 :
925 3228 : impl_switchActiveControllerListening( false );
926 3228 : m_xActiveController = NULL;
927 3228 : m_xActiveForm = NULL;
928 :
929 3228 : m_pShell = NULL;
930 3228 : m_xNavigationController = NULL;
931 3228 : m_xCurrentForm = NULL;
932 3228 : m_xLastGridFound = NULL;
933 3228 : m_xAttachedFrame = NULL;
934 3228 : m_xExternalViewController = NULL;
935 3228 : m_xExtViewTriggerController = NULL;
936 3228 : m_xExternalDisplayedForm = NULL;
937 3228 : m_xLastGridFound = NULL;
938 :
939 3228 : InterfaceBag aEmpty;
940 3228 : m_aCurrentSelection.swap( aEmpty );
941 :
942 3228 : m_aActiveControllerFeatures.dispose();
943 3228 : m_aNavControllerFeatures.dispose();
944 3228 : }
945 :
946 :
947 0 : void FmXFormShell::UpdateSlot( sal_Int16 _nId )
948 : {
949 0 : if ( impl_checkDisposed() )
950 0 : return;
951 :
952 0 : ::osl::MutexGuard aGuard(m_aInvalidationSafety);
953 :
954 0 : if ( m_nLockSlotInvalidation )
955 : {
956 : OSL_FAIL( "FmXFormShell::UpdateSlot: cannot update if invalidation is currently locked!" );
957 0 : InvalidateSlot( _nId, false );
958 : }
959 : else
960 : {
961 : OSL_ENSURE( _nId, "FmXFormShell::UpdateSlot: can't update the complete shell!" );
962 0 : m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( _nId, true, true );
963 0 : m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Update( _nId );
964 0 : }
965 : }
966 :
967 :
968 602 : void FmXFormShell::InvalidateSlot( sal_Int16 nId, bool bWithId )
969 : {
970 602 : if ( impl_checkDisposed() )
971 602 : return;
972 :
973 602 : ::osl::MutexGuard aGuard(m_aInvalidationSafety);
974 602 : if (m_nLockSlotInvalidation)
975 : {
976 0 : sal_uInt8 nFlags = ( bWithId ? 0x01 : 0 );
977 0 : m_arrInvalidSlots.push_back( InvalidSlotInfo(nId, nFlags) );
978 : }
979 : else
980 602 : if (nId)
981 552 : m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(nId, true, bWithId);
982 : else
983 50 : m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
984 : }
985 :
986 :
987 0 : void FmXFormShell::LockSlotInvalidation(bool bLock)
988 : {
989 0 : if ( impl_checkDisposed() )
990 0 : return;
991 :
992 0 : ::osl::MutexGuard aGuard(m_aInvalidationSafety);
993 : DBG_ASSERT(bLock || m_nLockSlotInvalidation>0, "FmXFormShell::LockSlotInvalidation : invalid call !");
994 :
995 0 : if (bLock)
996 0 : ++m_nLockSlotInvalidation;
997 0 : else if (!--m_nLockSlotInvalidation)
998 : {
999 : // alles, was sich waehrend der gelockten Phase angesammelt hat, (asynchron) invalidieren
1000 0 : if (!m_nInvalidationEvent)
1001 0 : m_nInvalidationEvent = Application::PostUserEvent(LINK(this, FmXFormShell, OnInvalidateSlots));
1002 0 : }
1003 : }
1004 :
1005 :
1006 0 : IMPL_LINK_NOARG(FmXFormShell, OnInvalidateSlots)
1007 : {
1008 0 : if ( impl_checkDisposed() )
1009 0 : return 0L;
1010 :
1011 0 : ::osl::MutexGuard aGuard(m_aInvalidationSafety);
1012 0 : m_nInvalidationEvent = 0;
1013 :
1014 0 : for (std::vector<InvalidSlotInfo>::const_iterator i = m_arrInvalidSlots.begin(); i < m_arrInvalidSlots.end(); ++i)
1015 : {
1016 0 : if (i->id)
1017 0 : m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(i->id, true, (i->flags & 0x01));
1018 : else
1019 0 : m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
1020 : }
1021 0 : m_arrInvalidSlots.clear();
1022 0 : return 0L;
1023 : }
1024 :
1025 :
1026 0 : void FmXFormShell::ForceUpdateSelection(bool bAllowInvalidation)
1027 : {
1028 0 : if ( impl_checkDisposed() )
1029 0 : return;
1030 :
1031 0 : if (IsSelectionUpdatePending())
1032 : {
1033 0 : m_aMarkTimer.Stop();
1034 :
1035 : // die Invalidierung der Slots, die implizit von SetSelection besorgt wird, eventuell abschalten
1036 0 : if (!bAllowInvalidation)
1037 0 : LockSlotInvalidation(true);
1038 :
1039 0 : SetSelection(m_pShell->GetFormView()->GetMarkedObjectList());
1040 :
1041 0 : if (!bAllowInvalidation)
1042 0 : LockSlotInvalidation(false);
1043 : }
1044 : }
1045 :
1046 :
1047 0 : PopupMenu* FmXFormShell::GetConversionMenu()
1048 : {
1049 :
1050 0 : PopupMenu* pNewMenu = new PopupMenu(SVX_RES( RID_FMSHELL_CONVERSIONMENU ));
1051 :
1052 0 : ImageList aImageList( SVX_RES( RID_SVXIMGLIST_FMEXPL) );
1053 0 : for ( size_t i = 0; i < sizeof (nConvertSlots) / sizeof (nConvertSlots[0]); ++i )
1054 : {
1055 : // das entsprechende Image dran
1056 0 : pNewMenu->SetItemImage(nConvertSlots[i], aImageList.GetImage(nCreateSlots[i]));
1057 : }
1058 :
1059 0 : return pNewMenu;
1060 : }
1061 :
1062 :
1063 0 : bool FmXFormShell::isControlConversionSlot( sal_uInt16 nSlotId )
1064 : {
1065 0 : for ( size_t i = 0; i < sizeof (nConvertSlots) / sizeof (nConvertSlots[0]); ++i )
1066 0 : if (nConvertSlots[i] == nSlotId)
1067 0 : return true;
1068 0 : return false;
1069 : }
1070 :
1071 :
1072 0 : bool FmXFormShell::executeControlConversionSlot( sal_uInt16 _nSlotId )
1073 : {
1074 : OSL_PRECOND( canConvertCurrentSelectionToControl( _nSlotId ), "FmXFormShell::executeControlConversionSlot: illegal call!" );
1075 0 : InterfaceBag::const_iterator aSelectedElement = m_aCurrentSelection.begin();
1076 0 : if ( aSelectedElement == m_aCurrentSelection.end() )
1077 0 : return false;
1078 :
1079 0 : return executeControlConversionSlot( Reference< XFormComponent >( *aSelectedElement, UNO_QUERY ), _nSlotId );
1080 : }
1081 :
1082 :
1083 0 : bool FmXFormShell::executeControlConversionSlot( const Reference< XFormComponent >& _rxObject, sal_uInt16 _nSlotId )
1084 : {
1085 0 : if ( impl_checkDisposed() )
1086 0 : return false;
1087 :
1088 : OSL_ENSURE( _rxObject.is(), "FmXFormShell::executeControlConversionSlot: invalid object!" );
1089 0 : if ( !_rxObject.is() )
1090 0 : return false;
1091 :
1092 0 : SdrPage* pPage = m_pShell->GetCurPage();
1093 0 : FmFormPage* pFormPage = pPage ? dynamic_cast< FmFormPage* >( pPage ) : NULL;
1094 : OSL_ENSURE( pFormPage, "FmXFormShell::executeControlConversionSlot: no current (form) page!" );
1095 0 : if ( !pFormPage )
1096 0 : return false;
1097 :
1098 : OSL_ENSURE( isSolelySelected( _rxObject ),
1099 : "FmXFormShell::executeControlConversionSlot: hmm ... shouldn't this parameter be redundant?" );
1100 :
1101 0 : for ( size_t lookupSlot = 0; lookupSlot < sizeof( nConvertSlots ) / sizeof( nConvertSlots[0] ); ++lookupSlot )
1102 : {
1103 0 : if (nConvertSlots[lookupSlot] == _nSlotId)
1104 : {
1105 0 : Reference< XInterface > xNormalizedObject( _rxObject, UNO_QUERY );
1106 :
1107 0 : FmFormObj* pFormObject = NULL;
1108 0 : SdrObjListIter aPageIter( *pFormPage );
1109 0 : while ( aPageIter.IsMore() )
1110 : {
1111 0 : SdrObject* pCurrent = aPageIter.Next();
1112 0 : pFormObject = FmFormObj::GetFormObject( pCurrent );
1113 0 : if ( !pFormObject )
1114 0 : continue;
1115 :
1116 0 : Reference< XInterface > xCurrentNormalized( pFormObject->GetUnoControlModel(), UNO_QUERY );
1117 0 : if ( xCurrentNormalized.get() == xNormalizedObject.get() )
1118 0 : break;
1119 :
1120 0 : pFormObject = NULL;
1121 0 : }
1122 :
1123 0 : if ( !pFormObject )
1124 0 : return false;
1125 :
1126 0 : OUString sNewName( getServiceNameByControlType( nObjectTypes[ lookupSlot ] ) );
1127 0 : Reference<XComponentContext> xContext = comphelper::getProcessComponentContext();
1128 0 : Reference< XControlModel> xNewModel( xContext->getServiceManager()->createInstanceWithContext(sNewName, xContext), UNO_QUERY );
1129 0 : if (!xNewModel.is())
1130 0 : return false;
1131 :
1132 0 : Reference< XControlModel> xOldModel( pFormObject->GetUnoControlModel() );
1133 0 : Reference< lang::XServiceInfo> xModelInfo(xOldModel, UNO_QUERY);
1134 :
1135 : // Properties uebertragen
1136 0 : Reference< XPropertySet> xOldSet(xOldModel, UNO_QUERY);
1137 0 : Reference< XPropertySet> xNewSet(xNewModel, UNO_QUERY);
1138 :
1139 :
1140 0 : lang::Locale aNewLanguage = Application::GetSettings().GetUILanguageTag().getLocale();
1141 0 : TransferFormComponentProperties(xOldSet, xNewSet, aNewLanguage);
1142 :
1143 0 : Sequence< ::com::sun::star::script::ScriptEventDescriptor> aOldScripts;
1144 0 : Reference< XChild> xChild(xOldModel, UNO_QUERY);
1145 0 : if (xChild.is())
1146 : {
1147 0 : Reference< XIndexAccess> xParent(xChild->getParent(), UNO_QUERY);
1148 :
1149 : // remember old script events
1150 0 : Reference< ::com::sun::star::script::XEventAttacherManager> xEvManager(xChild->getParent(), UNO_QUERY);
1151 0 : if (xParent.is() && xEvManager.is())
1152 : {
1153 0 : sal_Int32 nIndex = getElementPos(xParent, xOldModel);
1154 0 : if (nIndex>=0 && nIndex<xParent->getCount())
1155 0 : aOldScripts = xEvManager->getScriptEvents(nIndex);
1156 : }
1157 :
1158 : // replace the mdoel within the parent container
1159 0 : Reference< XIndexContainer> xIndexParent(xChild->getParent(), UNO_QUERY);
1160 0 : if (xIndexParent.is())
1161 : {
1162 : // the form container works with FormComponents
1163 0 : Reference< XFormComponent> xComponent(xNewModel, UNO_QUERY);
1164 : DBG_ASSERT(xComponent.is(), "FmXFormShell::executeControlConversionSlot: the new model is no form component !");
1165 0 : Any aNewModel(makeAny(xComponent));
1166 : try
1167 : {
1168 :
1169 0 : sal_Int32 nIndex = getElementPos(xParent, xOldModel);
1170 0 : if (nIndex>=0 && nIndex<xParent->getCount())
1171 0 : xIndexParent->replaceByIndex(nIndex, aNewModel);
1172 : else
1173 : {
1174 : OSL_FAIL("FmXFormShell::executeControlConversionSlot: could not replace the model !");
1175 0 : Reference< ::com::sun::star::lang::XComponent> xNewComponent(xNewModel, UNO_QUERY);
1176 0 : if (xNewComponent.is())
1177 0 : xNewComponent->dispose();
1178 0 : return false;
1179 : }
1180 : }
1181 0 : catch(Exception&)
1182 : {
1183 : OSL_FAIL("FmXFormShell::executeControlConversionSlot: could not replace the model !");
1184 0 : Reference< ::com::sun::star::lang::XComponent> xNewComponent(xNewModel, UNO_QUERY);
1185 0 : if (xNewComponent.is())
1186 0 : xNewComponent->dispose();
1187 0 : return false;
1188 0 : }
1189 :
1190 0 : }
1191 : }
1192 :
1193 : // special handling for the LabelControl-property : can only be set when the model is placed
1194 : // within the forms hierarchy
1195 0 : if (::comphelper::hasProperty(FM_PROP_CONTROLLABEL, xOldSet) && ::comphelper::hasProperty(FM_PROP_CONTROLLABEL, xNewSet))
1196 : {
1197 : try
1198 : {
1199 0 : xNewSet->setPropertyValue(FM_PROP_CONTROLLABEL, xOldSet->getPropertyValue(FM_PROP_CONTROLLABEL));
1200 : }
1201 0 : catch(Exception&)
1202 : {
1203 : }
1204 :
1205 : }
1206 :
1207 : // neues Model setzen
1208 0 : pFormObject->SetChanged();
1209 0 : pFormObject->SetUnoControlModel(xNewModel);
1210 :
1211 : // transfer script events
1212 : // (do this _after_ SetUnoControlModel as we need the new (implicitly created) control)
1213 0 : if (aOldScripts.getLength())
1214 : {
1215 : // das Control zum Model suchen
1216 0 : Reference< XControlContainer > xControlContainer( getControlContainerForView() );
1217 :
1218 0 : Sequence< Reference< XControl> > aControls( xControlContainer->getControls() );
1219 0 : const Reference< XControl>* pControls = aControls.getConstArray();
1220 :
1221 0 : sal_uInt32 nLen = aControls.getLength();
1222 0 : Reference< XControl> xControl;
1223 0 : for (sal_uInt32 i=0 ; i<nLen; ++i)
1224 : {
1225 0 : if (pControls[i]->getModel() == xNewModel)
1226 : {
1227 0 : xControl = pControls[i];
1228 0 : break;
1229 : }
1230 : }
1231 0 : TransferEventScripts(xNewModel, xControl, aOldScripts);
1232 : }
1233 :
1234 : // transfer value bindings, if possible
1235 : {
1236 0 : Reference< XBindableValue > xOldBindable( xOldModel, UNO_QUERY );
1237 0 : Reference< XBindableValue > xNewBindable( xNewModel, UNO_QUERY );
1238 0 : if ( xOldBindable.is() )
1239 : {
1240 : try
1241 : {
1242 0 : if ( xNewBindable.is() )
1243 0 : xNewBindable->setValueBinding( xOldBindable->getValueBinding() );
1244 0 : xOldBindable->setValueBinding( NULL );
1245 : }
1246 0 : catch(const Exception&)
1247 : {
1248 : DBG_UNHANDLED_EXCEPTION();
1249 : }
1250 0 : }
1251 : }
1252 : // same for list entry sources
1253 : {
1254 0 : Reference< XListEntrySink > xOldSink( xOldModel, UNO_QUERY );
1255 0 : Reference< XListEntrySink > xNewSink( xNewModel, UNO_QUERY );
1256 0 : if ( xOldSink.is() )
1257 : {
1258 : try
1259 : {
1260 0 : if ( xNewSink.is() )
1261 0 : xNewSink->setListEntrySource( xOldSink->getListEntrySource() );
1262 0 : xOldSink->setListEntrySource( NULL );
1263 : }
1264 0 : catch(const Exception&)
1265 : {
1266 : DBG_UNHANDLED_EXCEPTION();
1267 : }
1268 0 : }
1269 : }
1270 :
1271 : // create an undo action
1272 0 : FmFormModel* pModel = m_pShell->GetFormModel();
1273 : DBG_ASSERT(pModel != NULL, "FmXFormShell::executeControlConversionSlot: my shell has no model !");
1274 0 : if (pModel && pModel->IsUndoEnabled() )
1275 : {
1276 0 : pModel->AddUndo(new FmUndoModelReplaceAction(*pModel, pFormObject, xOldModel));
1277 : }
1278 : else
1279 : {
1280 0 : FmUndoModelReplaceAction::DisposeElement( xOldModel );
1281 : }
1282 :
1283 0 : return true;
1284 : }
1285 : }
1286 0 : return false;
1287 : }
1288 :
1289 :
1290 0 : bool FmXFormShell::canConvertCurrentSelectionToControl( sal_Int16 nConversionSlot )
1291 : {
1292 0 : if ( m_aCurrentSelection.empty() )
1293 0 : return false;
1294 :
1295 0 : InterfaceBag::const_iterator aCheck = m_aCurrentSelection.begin();
1296 0 : Reference< lang::XServiceInfo > xElementInfo( *aCheck, UNO_QUERY );
1297 0 : if ( !xElementInfo.is() )
1298 : // no service info -> cannot determine this
1299 0 : return false;
1300 :
1301 0 : if ( ++aCheck != m_aCurrentSelection.end() )
1302 : // more than one element
1303 0 : return false;
1304 :
1305 0 : if ( Reference< XForm >::query( xElementInfo ).is() )
1306 : // it's a form
1307 0 : return false;
1308 :
1309 0 : sal_Int16 nObjectType = getControlTypeByObject( xElementInfo );
1310 :
1311 0 : if ( ( OBJ_FM_HIDDEN == nObjectType )
1312 0 : || ( OBJ_FM_CONTROL == nObjectType )
1313 0 : || ( OBJ_FM_GRID == nObjectType )
1314 : )
1315 0 : return false; // those types cannot be converted
1316 :
1317 : DBG_ASSERT(sizeof(nConvertSlots)/sizeof(nConvertSlots[0]) == sizeof(nObjectTypes)/sizeof(nObjectTypes[0]),
1318 : "FmXFormShell::canConvertCurrentSelectionToControl: nConvertSlots & nObjectTypes must have the same size !");
1319 :
1320 0 : for ( size_t i = 0; i < sizeof( nConvertSlots ) / sizeof( nConvertSlots[0] ); ++i )
1321 0 : if (nConvertSlots[i] == nConversionSlot)
1322 0 : return nObjectTypes[i] != nObjectType;
1323 :
1324 0 : return true; // all other slots: assume "yes"
1325 : }
1326 :
1327 :
1328 0 : void FmXFormShell::checkControlConversionSlotsForCurrentSelection( Menu& rMenu )
1329 : {
1330 0 : for (sal_Int16 i=0; i<rMenu.GetItemCount(); ++i)
1331 : // der Context ist schon von einem Typ, der dem Eitnrag entspricht -> disable
1332 0 : rMenu.EnableItem( rMenu.GetItemId(i), canConvertCurrentSelectionToControl( rMenu.GetItemId( i ) ) );
1333 0 : }
1334 :
1335 :
1336 0 : void FmXFormShell::LoopGrids(sal_Int16 nWhat)
1337 : {
1338 0 : if ( impl_checkDisposed() )
1339 0 : return;
1340 :
1341 0 : Reference< XIndexContainer> xControlModels(m_xActiveForm, UNO_QUERY);
1342 0 : if (xControlModels.is())
1343 : {
1344 0 : for (sal_Int32 i=0; i<xControlModels->getCount(); ++i)
1345 : {
1346 0 : Reference< XPropertySet> xModelSet;
1347 0 : xControlModels->getByIndex(i) >>= xModelSet;
1348 0 : if (!xModelSet.is())
1349 0 : continue;
1350 :
1351 0 : if (!::comphelper::hasProperty(FM_PROP_CLASSID, xModelSet))
1352 0 : continue;
1353 0 : sal_Int16 nClassId = ::comphelper::getINT16(xModelSet->getPropertyValue(FM_PROP_CLASSID));
1354 0 : if (FormComponentType::GRIDCONTROL != nClassId)
1355 0 : continue;
1356 :
1357 0 : if (!::comphelper::hasProperty(FM_PROP_CURSORCOLOR, xModelSet) || !::comphelper::hasProperty(FM_PROP_ALWAYSSHOWCURSOR, xModelSet) || !::comphelper::hasProperty(FM_PROP_DISPLAYSYNCHRON, xModelSet))
1358 0 : continue;
1359 :
1360 0 : switch (nWhat & GA_SYNC_MASK)
1361 : {
1362 : case GA_DISABLE_SYNC:
1363 : {
1364 0 : sal_Bool bB(sal_False);
1365 0 : xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(&bB,cppu::UnoType<bool>::get()));
1366 : }
1367 0 : break;
1368 : case GA_FORCE_SYNC:
1369 : {
1370 0 : Any aOldVal( xModelSet->getPropertyValue(FM_PROP_DISPLAYSYNCHRON) );
1371 0 : sal_Bool bB(sal_True);
1372 0 : xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(&bB,cppu::UnoType<bool>::get()));
1373 0 : xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, aOldVal);
1374 : }
1375 0 : break;
1376 : case GA_ENABLE_SYNC:
1377 : {
1378 0 : sal_Bool bB(sal_True);
1379 0 : xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(&bB,cppu::UnoType<bool>::get()));
1380 : }
1381 0 : break;
1382 : }
1383 :
1384 0 : if (nWhat & GA_DISABLE_ROCTRLR)
1385 : {
1386 0 : sal_Bool bB(sal_False);
1387 0 : xModelSet->setPropertyValue(FM_PROP_ALWAYSSHOWCURSOR, Any(&bB,cppu::UnoType<bool>::get()));
1388 0 : Reference< XPropertyState> xModelPropState(xModelSet, UNO_QUERY);
1389 0 : if (xModelPropState.is())
1390 0 : xModelPropState->setPropertyToDefault(FM_PROP_CURSORCOLOR);
1391 : else
1392 0 : xModelSet->setPropertyValue(FM_PROP_CURSORCOLOR, Any()); // this should be the default
1393 : }
1394 0 : else if (nWhat & GA_ENABLE_ROCTRLR)
1395 : {
1396 0 : sal_Bool bB(sal_True);
1397 0 : xModelSet->setPropertyValue(FM_PROP_ALWAYSSHOWCURSOR, Any(&bB,cppu::UnoType<bool>::get()));
1398 0 : xModelSet->setPropertyValue(FM_PROP_CURSORCOLOR, makeAny(sal_Int32(COL_LIGHTRED)));
1399 : }
1400 0 : }
1401 0 : }
1402 : }
1403 :
1404 :
1405 0 : Reference< XControlContainer > FmXFormShell::getControlContainerForView()
1406 : {
1407 0 : if ( impl_checkDisposed() )
1408 0 : return NULL;
1409 :
1410 0 : SdrPageView* pPageView = NULL;
1411 0 : if ( m_pShell && m_pShell->GetFormView() )
1412 0 : pPageView = m_pShell->GetFormView()->GetSdrPageView();
1413 :
1414 0 : Reference< XControlContainer> xControlContainer;
1415 0 : if ( pPageView )
1416 0 : xControlContainer = pPageView->GetPageWindow(0)->GetControlContainer();
1417 :
1418 0 : return xControlContainer;
1419 : }
1420 :
1421 :
1422 0 : void FmXFormShell::ExecuteTabOrderDialog( const Reference< XTabControllerModel >& _rxForForm )
1423 : {
1424 0 : if ( impl_checkDisposed() )
1425 0 : return;
1426 :
1427 : OSL_PRECOND( _rxForForm.is(), "FmXFormShell::ExecuteTabOrderDialog: invalid tabbing model!" );
1428 0 : if ( !_rxForForm.is() )
1429 0 : return;
1430 :
1431 : try
1432 : {
1433 0 : Reference< XWindow > xParentWindow;
1434 0 : if ( m_pShell->GetViewShell() && m_pShell->GetViewShell()->GetViewFrame() )
1435 0 : xParentWindow = VCLUnoHelper::GetInterface ( &m_pShell->GetViewShell()->GetViewFrame()->GetWindow() );
1436 :
1437 : Reference< dialogs::XExecutableDialog > xDialog = form::TabOrderDialog::createWithModel(
1438 : comphelper::getProcessComponentContext(),
1439 : _rxForForm, getControlContainerForView(), xParentWindow
1440 0 : );
1441 :
1442 0 : xDialog->execute();
1443 : }
1444 0 : catch( const Exception& )
1445 : {
1446 : OSL_FAIL( "FmXFormShell::ExecuteTabOrderDialog: caught an exception!" );
1447 : }
1448 : }
1449 :
1450 :
1451 0 : void FmXFormShell::ExecuteSearch()
1452 : {
1453 0 : if ( impl_checkDisposed() )
1454 0 : return;
1455 :
1456 : // eine Sammlung aller (logischen) Formulare
1457 0 : FmFormArray aEmpty;
1458 0 : m_aSearchForms.swap( aEmpty );
1459 0 : ::std::vector< OUString > aContextNames;
1460 0 : impl_collectFormSearchContexts_nothrow( m_pShell->GetCurPage()->GetForms(), OUString(), m_aSearchForms, aContextNames );
1461 :
1462 0 : if ( m_aSearchForms.size() != aContextNames.size() )
1463 : {
1464 : SAL_WARN ( "svx.form", "FmXFormShell::ExecuteSearch: nonsense!" );
1465 0 : return;
1466 : }
1467 :
1468 : // filter out the forms which do not contain valid controls at all
1469 : {
1470 0 : FmFormArray aValidForms;
1471 0 : ::std::vector< OUString > aValidContexts;
1472 0 : FmFormArray::const_iterator form = m_aSearchForms.begin();
1473 0 : ::std::vector< OUString >::const_iterator contextName = aContextNames.begin();
1474 0 : for ( ; form != m_aSearchForms.end(); ++form, ++contextName )
1475 : {
1476 0 : FmSearchContext aTestContext;
1477 0 : aTestContext.nContext = static_cast< sal_Int16 >( form - m_aSearchForms.begin() );
1478 0 : sal_uInt32 nValidControls = OnSearchContextRequest( &aTestContext );
1479 0 : if ( nValidControls > 0 )
1480 : {
1481 0 : aValidForms.push_back( *form );
1482 0 : aValidContexts.push_back( *contextName );
1483 : }
1484 0 : }
1485 :
1486 0 : m_aSearchForms.swap( aValidForms );
1487 0 : aContextNames.swap( aValidContexts );
1488 : }
1489 :
1490 0 : if (m_aSearchForms.empty() )
1491 : { // es gibt keine Controls, die alle Bedingungen fuer eine Suche erfuellen
1492 0 : ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SVX_RESSTR(RID_STR_NODATACONTROLS))->Execute();
1493 0 : return;
1494 : }
1495 :
1496 : // jetzt brauche ich noch einen 'initial context'
1497 0 : sal_Int16 nInitialContext = 0;
1498 0 : Reference< XForm> xActiveForm( getActiveForm());
1499 0 : for ( size_t i=0; i<m_aSearchForms.size(); ++i )
1500 : {
1501 0 : if (m_aSearchForms.at(i) == xActiveForm)
1502 : {
1503 0 : nInitialContext = (sal_Int16)i;
1504 0 : break;
1505 : }
1506 : }
1507 :
1508 : // wenn der Dialog initial den Text des aktiven Controls anbieten soll, muss dieses ein XTextComponent-Interface habe,
1509 : // ausserdem macht das nur Sinn, wenn das aktuelle Feld auch an ein Tabellen- (oder was-auch-immer-)Feld gebunden ist
1510 0 : OUString strActiveField;
1511 0 : OUString strInitialText;
1512 : // ... das bekomme ich von meinem FormController
1513 : DBG_ASSERT(m_xActiveController.is(), "FmXFormShell::ExecuteSearch : no active controller !");
1514 0 : Reference< XControl> xActiveControl( m_xActiveController->getCurrentControl());
1515 0 : if (xActiveControl.is())
1516 : {
1517 : // das Control kann mir sein Model sagen ...
1518 0 : Reference< XControlModel> xActiveModel( xActiveControl->getModel());
1519 : DBG_ASSERT(xActiveModel.is(), "FmXFormShell::ExecuteSearch : active control has no model !");
1520 :
1521 : // das Model frage ich nach der ControlSource-Eigenschaft ...
1522 0 : Reference< XPropertySet> xProperties(xActiveControl->getModel(), UNO_QUERY);
1523 0 : if (::comphelper::hasProperty(FM_PROP_CONTROLSOURCE, xProperties) && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xProperties))
1524 : {
1525 0 : Reference< XPropertySet> xField;
1526 0 : xProperties->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
1527 0 : if (xField.is()) // (nur wenn das Ding wirklich gebunden ist)
1528 : {
1529 : // und das Control selber nach einem TextComponent-Interface (damit ich mir dort den Text abholen kann)
1530 0 : Reference< XTextComponent> xText(xActiveControl, UNO_QUERY);
1531 0 : if (xText.is())
1532 : {
1533 0 : strActiveField = getLabelName(xProperties).getStr();
1534 0 : strInitialText = xText->getText().getStr();
1535 0 : }
1536 0 : }
1537 : }
1538 : else
1539 : {
1540 : // das Control selber hat keine ControlSource, aber vielleicht ist es ein GridControl
1541 0 : Reference< XGrid> xGrid(xActiveControl, UNO_QUERY);
1542 0 : if (xGrid.is())
1543 : {
1544 : // fuer strActiveField brauche ich die ControlSource der Column, dafuer den Columns-Container, dafuer die
1545 : // GridPeer
1546 0 : Reference< XGridPeer> xGridPeer(xActiveControl->getPeer(), UNO_QUERY);
1547 0 : Reference< XIndexAccess> xColumns;
1548 0 : if (xGridPeer.is())
1549 0 : xColumns = Reference< XIndexAccess>(xGridPeer->getColumns(),UNO_QUERY);
1550 :
1551 0 : sal_Int16 nViewCol = xGrid->getCurrentColumnPosition();
1552 0 : sal_Int16 nModelCol = GridView2ModelPos(xColumns, nViewCol);
1553 0 : Reference< XPropertySet> xCurrentCol;
1554 0 : if(xColumns.is())
1555 0 : xColumns->getByIndex(nModelCol) >>= xCurrentCol;
1556 0 : if (xCurrentCol.is())
1557 0 : strActiveField = ::comphelper::getString(xCurrentCol->getPropertyValue(FM_PROP_LABEL)).getStr();
1558 :
1559 : // the text fo the current column
1560 0 : Reference< XIndexAccess> xColControls(xGridPeer, UNO_QUERY);
1561 0 : Reference< XInterface> xCurControl;
1562 0 : xColControls->getByIndex(nViewCol) >>= xCurControl;
1563 0 : OUString sInitialText;
1564 0 : if (IsSearchableControl(xCurControl, &sInitialText))
1565 0 : strInitialText = sInitialText.getStr();
1566 0 : }
1567 0 : }
1568 : }
1569 :
1570 : // um eventuelle GridControls, die ich kenne, kuemmern
1571 0 : LoopGrids(GA_DISABLE_SYNC /*| GA_ENABLE_ROCTRLR*/);
1572 :
1573 : // jetzt bin ich reif fuer den Dialog
1574 : // wenn die potentiellen Deadlocks, die durch die Benutzung des Solar-Mutex in MTs VCLX...-Klasen entstehen, irgendwann mal
1575 : // ausgeraeumt sind, sollte hier ein SM_USETHREAD rein, denn die Suche in einem eigenen Thread ist doch etwas fluessiger
1576 : // sollte allerdings irgendwie von dem unterliegenden Cursor abhaengig gemacht werden, DAO zum Beispiel ist nicht thread-sicher
1577 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1578 0 : boost::scoped_ptr<AbstractFmSearchDialog> pDialog;
1579 0 : if ( pFact )
1580 0 : pDialog.reset(pFact->CreateFmSearchDialog( &m_pShell->GetViewShell()->GetViewFrame()->GetWindow(), strInitialText, aContextNames, nInitialContext, LINK( this, FmXFormShell, OnSearchContextRequest ) ));
1581 : DBG_ASSERT( pDialog, "FmXFormShell::ExecuteSearch: could not create the search dialog!" );
1582 0 : if ( pDialog )
1583 : {
1584 0 : pDialog->SetActiveField( strActiveField );
1585 0 : pDialog->SetFoundHandler( LINK( this, FmXFormShell, OnFoundData ) );
1586 0 : pDialog->SetCanceledNotFoundHdl( LINK( this, FmXFormShell, OnCanceledNotFound ) );
1587 0 : pDialog->Execute();
1588 0 : pDialog.reset();
1589 : }
1590 :
1591 : // GridControls wieder restaurieren
1592 0 : LoopGrids(GA_ENABLE_SYNC | GA_DISABLE_ROCTRLR);
1593 :
1594 0 : m_pShell->GetFormView()->UnMarkAll(m_pShell->GetFormView()->GetSdrPageView());
1595 : // da ich in OnFoundData (fals ich dort war) Controls markiert habe
1596 : }
1597 :
1598 :
1599 0 : bool FmXFormShell::GetY2KState(sal_uInt16& n)
1600 : {
1601 0 : if ( impl_checkDisposed() )
1602 0 : return false;
1603 :
1604 0 : if (m_pShell->IsDesignMode())
1605 : // im Design-Modus (ohne aktive Controls) soll sich das Haupt-Dokument darum kuemmern
1606 0 : return false;
1607 :
1608 0 : Reference< XForm> xForm( getActiveForm());
1609 0 : if (!xForm.is())
1610 : // kein aktuelles Formular (also insbesondere kein aktuelles Control) -> das Haupt-Dokument soll sich kuemmern
1611 0 : return false;
1612 :
1613 0 : Reference< XRowSet> xDB(xForm, UNO_QUERY);
1614 : DBG_ASSERT(xDB.is(), "FmXFormShell::GetY2KState : current form has no dbform-interface !");
1615 :
1616 0 : Reference< XNumberFormatsSupplier> xSupplier( getNumberFormats(getConnection(xDB), false));
1617 0 : if (xSupplier.is())
1618 : {
1619 0 : Reference< XPropertySet> xSet(xSupplier->getNumberFormatSettings());
1620 0 : if (xSet.is())
1621 : {
1622 : try
1623 : {
1624 0 : Any aVal( xSet->getPropertyValue("TwoDigitDateStart") );
1625 0 : aVal >>= n;
1626 0 : return true;
1627 : }
1628 0 : catch(Exception&)
1629 : {
1630 : }
1631 :
1632 0 : }
1633 : }
1634 0 : return false;
1635 : }
1636 :
1637 :
1638 2 : void FmXFormShell::SetY2KState(sal_uInt16 n)
1639 : {
1640 2 : if ( impl_checkDisposed() )
1641 2 : return;
1642 :
1643 2 : Reference< XForm > xActiveForm( getActiveForm());
1644 2 : Reference< XRowSet > xActiveRowSet( xActiveForm, UNO_QUERY );
1645 2 : if ( xActiveRowSet.is() )
1646 : {
1647 0 : Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( getConnection( xActiveRowSet ), false ) );
1648 0 : if (xSupplier.is())
1649 : {
1650 0 : Reference< XPropertySet> xSet(xSupplier->getNumberFormatSettings());
1651 0 : if (xSet.is())
1652 : {
1653 : try
1654 : {
1655 0 : Any aVal;
1656 0 : aVal <<= n;
1657 0 : xSet->setPropertyValue("TwoDigitDateStart", aVal);
1658 : }
1659 0 : catch(Exception&)
1660 : {
1661 : OSL_FAIL("FmXFormShell::SetY2KState: Exception occurred!");
1662 : }
1663 :
1664 : }
1665 0 : return;
1666 0 : }
1667 : }
1668 :
1669 : // kein aktives Formular gefunden -> alle aktuell vorhandenen Formulare durchiterieren
1670 2 : Reference< XIndexAccess> xCurrentForms( m_xForms);
1671 2 : if (!xCurrentForms.is())
1672 : { // im alive-Modus sind meine Forms nicht gesetzt, wohl aber die an der Page
1673 2 : if (m_pShell->GetCurPage())
1674 2 : xCurrentForms = Reference< XIndexAccess>( m_pShell->GetCurPage()->GetForms( false ), UNO_QUERY );
1675 : }
1676 2 : if (!xCurrentForms.is())
1677 2 : return;
1678 :
1679 0 : ::comphelper::IndexAccessIterator aIter(xCurrentForms);
1680 0 : Reference< XInterface> xCurrentElement( aIter.Next());
1681 0 : while (xCurrentElement.is())
1682 : {
1683 : // ist das aktuelle Element eine DatabaseForm ?
1684 0 : Reference< XRowSet> xElementAsRowSet( xCurrentElement, UNO_QUERY );
1685 0 : if ( xElementAsRowSet.is() )
1686 : {
1687 0 : Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( getConnection( xElementAsRowSet ), false ) );
1688 0 : if (!xSupplier.is())
1689 0 : continue;
1690 :
1691 0 : Reference< XPropertySet> xSet(xSupplier->getNumberFormatSettings());
1692 0 : if (xSet.is())
1693 : {
1694 : try
1695 : {
1696 0 : Any aVal;
1697 0 : aVal <<= n;
1698 0 : xSet->setPropertyValue("TwoDigitDateStart", aVal);
1699 : }
1700 0 : catch(Exception&)
1701 : {
1702 : OSL_FAIL("FmXFormShell::SetY2KState: Exception occurred!");
1703 : }
1704 :
1705 0 : }
1706 : }
1707 0 : xCurrentElement = aIter.Next();
1708 0 : }
1709 : }
1710 :
1711 :
1712 3228 : void FmXFormShell::CloseExternalFormViewer()
1713 : {
1714 3228 : if ( impl_checkDisposed() )
1715 3228 : return;
1716 :
1717 3228 : if (!m_xExternalViewController.is())
1718 3228 : return;
1719 :
1720 0 : Reference< ::com::sun::star::frame::XFrame> xExternalViewFrame( m_xExternalViewController->getFrame());
1721 0 : Reference< ::com::sun::star::frame::XDispatchProvider> xCommLink(xExternalViewFrame, UNO_QUERY);
1722 0 : if (!xCommLink.is())
1723 0 : return;
1724 :
1725 0 : xExternalViewFrame->setComponent(NULL,NULL);
1726 0 : ::comphelper::disposeComponent(xExternalViewFrame);
1727 0 : m_xExternalViewController = NULL;
1728 0 : m_xExtViewTriggerController = NULL;
1729 0 : m_xExternalDisplayedForm = NULL;
1730 : }
1731 :
1732 :
1733 4 : Reference< XResultSet> FmXFormShell::getInternalForm(const Reference< XResultSet>& _xForm) const
1734 : {
1735 4 : if ( impl_checkDisposed() )
1736 0 : return NULL;
1737 :
1738 4 : Reference< runtime::XFormController> xExternalCtrlr(m_xExternalViewController, UNO_QUERY);
1739 4 : if (xExternalCtrlr.is() && (_xForm == xExternalCtrlr->getModel()))
1740 : {
1741 : DBG_ASSERT(m_xExternalDisplayedForm.is(), "FmXFormShell::getInternalForm : invalid external form !");
1742 0 : return m_xExternalDisplayedForm;
1743 : }
1744 4 : return _xForm;
1745 : }
1746 :
1747 :
1748 1 : Reference< XForm> FmXFormShell::getInternalForm(const Reference< XForm>& _xForm) const
1749 : {
1750 1 : if ( impl_checkDisposed() )
1751 0 : return NULL;
1752 :
1753 1 : Reference< runtime::XFormController > xExternalCtrlr(m_xExternalViewController, UNO_QUERY);
1754 1 : if (xExternalCtrlr.is() && (_xForm == xExternalCtrlr->getModel()))
1755 : {
1756 : DBG_ASSERT(m_xExternalDisplayedForm.is(), "FmXFormShell::getInternalForm : invalid external form !");
1757 0 : return Reference< XForm>(m_xExternalDisplayedForm, UNO_QUERY);
1758 : }
1759 1 : return _xForm;
1760 : }
1761 :
1762 :
1763 : namespace
1764 : {
1765 0 : static bool lcl_isNavigationRelevant( sal_Int32 _nWhich )
1766 : {
1767 : return ( _nWhich == SID_FM_RECORD_FIRST )
1768 0 : || ( _nWhich == SID_FM_RECORD_PREV )
1769 0 : || ( _nWhich == SID_FM_RECORD_NEXT )
1770 0 : || ( _nWhich == SID_FM_RECORD_LAST )
1771 0 : || ( _nWhich == SID_FM_RECORD_NEW );
1772 : }
1773 : }
1774 :
1775 :
1776 0 : bool FmXFormShell::IsFormSlotEnabled( sal_Int32 _nSlot, FeatureState* _pCompleteState )
1777 : {
1778 : const svx::ControllerFeatures& rController =
1779 0 : lcl_isNavigationRelevant( _nSlot )
1780 : ? getNavControllerFeatures()
1781 0 : : getActiveControllerFeatures();
1782 :
1783 0 : if ( !_pCompleteState )
1784 0 : return rController->isEnabled( _nSlot );
1785 :
1786 0 : rController->getState( _nSlot, *_pCompleteState );
1787 0 : return _pCompleteState->Enabled;
1788 : }
1789 :
1790 :
1791 0 : void FmXFormShell::ExecuteFormSlot( sal_Int32 _nSlot )
1792 : {
1793 : const svx::ControllerFeatures& rController =
1794 0 : lcl_isNavigationRelevant( _nSlot )
1795 : ? getNavControllerFeatures()
1796 0 : : getActiveControllerFeatures();
1797 :
1798 0 : rController->execute( _nSlot );
1799 :
1800 0 : if ( _nSlot == SID_FM_RECORD_UNDO )
1801 : {
1802 : // if we're doing an UNDO, *and* if the affected form is the form which we also display
1803 : // as external view, then we need to reset the controls of the external form, too
1804 0 : if ( getInternalForm( getActiveForm() ) == m_xExternalDisplayedForm )
1805 : {
1806 0 : Reference< XIndexAccess > xContainer( m_xExternalDisplayedForm, UNO_QUERY );
1807 0 : if ( xContainer.is() )
1808 : {
1809 0 : Reference< XReset > xReset;
1810 0 : for ( sal_Int32 i = 0; i < xContainer->getCount(); ++i )
1811 : {
1812 0 : if ( ( xContainer->getByIndex( i ) >>= xReset ) && xReset.is() )
1813 : {
1814 : // no resets on sub forms
1815 0 : Reference< XForm > xAsForm( xReset, UNO_QUERY );
1816 0 : if ( !xAsForm.is() )
1817 0 : xReset->reset();
1818 : }
1819 0 : }
1820 0 : }
1821 : }
1822 : }
1823 0 : }
1824 :
1825 :
1826 3232 : void FmXFormShell::impl_switchActiveControllerListening( const bool _bListen )
1827 : {
1828 3232 : Reference< XComponent> xComp( m_xActiveController, UNO_QUERY );
1829 3232 : if ( !xComp.is() )
1830 6462 : return;
1831 :
1832 2 : if ( _bListen )
1833 1 : xComp->addEventListener( static_cast<XFormControllerListener*>(this) );
1834 : else
1835 1 : xComp->removeEventListener( static_cast<XFormControllerListener*>(this) );
1836 : }
1837 :
1838 :
1839 555 : void FmXFormShell::setActiveController( const Reference< runtime::XFormController >& xController, bool _bNoSaveOldContent )
1840 : {
1841 555 : if ( impl_checkDisposed() )
1842 0 : return;
1843 :
1844 555 : if (m_bChangingDesignMode)
1845 0 : return;
1846 : DBG_ASSERT(!m_pShell->IsDesignMode(), "nur im alive mode verwenden");
1847 :
1848 : // Ist die Routine ein zweites Mal gerufen worden,
1849 : // dann sollte der Focus nicht mehr umgesetzt werden
1850 555 : if (m_bInActivate)
1851 : {
1852 0 : m_bSetFocus = xController != m_xActiveController;
1853 0 : return;
1854 : }
1855 :
1856 555 : if (xController != m_xActiveController)
1857 : {
1858 2 : ::osl::ClearableMutexGuard aGuard(m_aAsyncSafety);
1859 : // switch all nav dispatchers belonging to the form of the current nav controller to 'non active'
1860 4 : Reference< XResultSet> xNavigationForm;
1861 2 : if (m_xNavigationController.is())
1862 0 : xNavigationForm = Reference< XResultSet>(m_xNavigationController->getModel(), UNO_QUERY);
1863 2 : aGuard.clear();
1864 :
1865 2 : m_bInActivate = true;
1866 :
1867 : // check if the 2 controllers serve different forms
1868 4 : Reference< XResultSet> xOldForm;
1869 2 : if (m_xActiveController.is())
1870 1 : xOldForm = Reference< XResultSet>(m_xActiveController->getModel(), UNO_QUERY);
1871 4 : Reference< XResultSet> xNewForm;
1872 2 : if (xController.is())
1873 1 : xNewForm = Reference< XResultSet>(xController->getModel(), UNO_QUERY);
1874 2 : xOldForm = getInternalForm(xOldForm);
1875 2 : xNewForm = getInternalForm(xNewForm);
1876 :
1877 2 : bool bDifferentForm = ( xOldForm.get() != xNewForm.get() );
1878 2 : bool bNeedSave = bDifferentForm && !_bNoSaveOldContent;
1879 : // we save the content of the old form if we move to a new form, and saving old content is allowed
1880 :
1881 2 : if ( m_xActiveController.is() && bNeedSave )
1882 : {
1883 : // beim Wechsel des Controllers den Inhalt speichern, ein Commit
1884 : // wurde bereits ausgefuehrt
1885 0 : if ( m_aActiveControllerFeatures->commitCurrentControl() )
1886 : {
1887 0 : m_bSetFocus = true;
1888 0 : if ( m_aActiveControllerFeatures->isModifiedRow() )
1889 : {
1890 0 : bool bIsNew = m_aActiveControllerFeatures->isInsertionRow();
1891 0 : bool bResult = m_aActiveControllerFeatures->commitCurrentRecord();
1892 0 : if ( !bResult && m_bSetFocus )
1893 : {
1894 : // if we couldn't save the current record, set the focus back to the
1895 : // current control
1896 0 : Reference< XWindow > xWindow( m_xActiveController->getCurrentControl(), UNO_QUERY );
1897 0 : if ( xWindow.is() )
1898 0 : xWindow->setFocus();
1899 0 : m_bInActivate = false;
1900 0 : return;
1901 : }
1902 0 : else if ( bResult && bIsNew )
1903 : {
1904 0 : Reference< XResultSet > xCursor( m_aActiveControllerFeatures->getCursor().get() );
1905 0 : if ( xCursor.is() )
1906 : {
1907 0 : DO_SAFE( xCursor->last(); );
1908 0 : }
1909 : }
1910 : }
1911 : }
1912 : }
1913 :
1914 2 : stopListening();
1915 :
1916 2 : impl_switchActiveControllerListening( false );
1917 :
1918 2 : m_aActiveControllerFeatures.dispose();
1919 2 : m_xActiveController = xController;
1920 2 : if ( m_xActiveController.is() )
1921 1 : m_aActiveControllerFeatures.assign( m_xActiveController );
1922 :
1923 2 : impl_switchActiveControllerListening( true );
1924 :
1925 2 : if ( m_xActiveController.is() )
1926 1 : m_xActiveForm = getInternalForm( Reference< XForm >( m_xActiveController->getModel(), UNO_QUERY ) );
1927 : else
1928 1 : m_xActiveForm = NULL;
1929 :
1930 2 : startListening();
1931 :
1932 : // activate all dispatchers belonging to form of the new navigation controller
1933 2 : xNavigationForm = NULL;
1934 2 : if (m_xNavigationController.is())
1935 0 : xNavigationForm = Reference< XResultSet>(m_xNavigationController->getModel(), UNO_QUERY);
1936 :
1937 2 : m_bInActivate = false;
1938 :
1939 2 : m_pShell->UIFeatureChanged();
1940 2 : m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
1941 :
1942 4 : InvalidateSlot(SID_FM_FILTER_NAVIGATOR_CONTROL, true);
1943 : }
1944 : }
1945 :
1946 :
1947 0 : void FmXFormShell::getCurrentSelection( InterfaceBag& /* [out] */ _rSelection ) const
1948 : {
1949 0 : _rSelection = m_aCurrentSelection;
1950 0 : }
1951 :
1952 :
1953 318 : bool FmXFormShell::setCurrentSelectionFromMark( const SdrMarkList& _rMarkList )
1954 : {
1955 318 : m_aLastKnownMarkedControls.clear();
1956 :
1957 318 : if ( ( _rMarkList.GetMarkCount() > 0 ) && isControlList( _rMarkList ) )
1958 0 : collectInterfacesFromMarkList( _rMarkList, m_aLastKnownMarkedControls );
1959 :
1960 318 : return setCurrentSelection( m_aLastKnownMarkedControls );
1961 : }
1962 :
1963 :
1964 0 : bool FmXFormShell::selectLastMarkedControls()
1965 : {
1966 0 : return setCurrentSelection( m_aLastKnownMarkedControls );
1967 : }
1968 :
1969 :
1970 318 : bool FmXFormShell::setCurrentSelection( const InterfaceBag& _rSelection )
1971 : {
1972 318 : if ( impl_checkDisposed() )
1973 0 : return false;
1974 :
1975 : DBG_ASSERT( m_pShell->IsDesignMode(), "FmXFormShell::setCurrentSelection: only to be used in design mode!" );
1976 :
1977 318 : if ( _rSelection.empty() && m_aCurrentSelection.empty() )
1978 : // nothing to do
1979 318 : return false;
1980 :
1981 0 : if ( _rSelection.size() == m_aCurrentSelection.size() )
1982 : {
1983 0 : InterfaceBag::const_iterator aNew = _rSelection.begin();
1984 0 : InterfaceBag::const_iterator aOld = m_aCurrentSelection.begin();
1985 0 : for ( ; aNew != _rSelection.end(); ++aNew, ++aOld )
1986 : {
1987 : OSL_ENSURE( Reference< XInterface >( *aNew, UNO_QUERY ).get() == aNew->get(), "FmXFormShell::setCurrentSelection: new interface not normalized!" );
1988 : OSL_ENSURE( Reference< XInterface >( *aOld, UNO_QUERY ).get() == aOld->get(), "FmXFormShell::setCurrentSelection: old interface not normalized!" );
1989 :
1990 0 : if ( aNew->get() != aOld->get() )
1991 0 : break;
1992 : }
1993 :
1994 0 : if ( aNew == _rSelection.end() )
1995 : // both bags equal
1996 0 : return false;
1997 : }
1998 :
1999 : // the following is some strange code to ensure that when you have two grid controls in a document,
2000 : // only one of them can have a selected column.
2001 : // TODO: this should happen elsewhere, but not here - shouldn't it?
2002 0 : if ( !m_aCurrentSelection.empty() )
2003 : {
2004 0 : Reference< XChild > xCur; if ( m_aCurrentSelection.size() == 1 ) xCur.set(*m_aCurrentSelection.begin(), css::uno::UNO_QUERY);
2005 0 : Reference< XChild > xNew; if ( _rSelection.size() == 1 ) xNew.set(*_rSelection.begin(), css::uno::UNO_QUERY);
2006 :
2007 : // is there nothing to be selected, or the parents differ, and the parent of the current object
2008 : // is a selection supplier, then deselect
2009 0 : if ( xCur.is() && ( !xNew.is() || ( xCur->getParent() != xNew->getParent() ) ) )
2010 : {
2011 0 : Reference< XSelectionSupplier > xSel( xCur->getParent(), UNO_QUERY );
2012 0 : if ( xSel.is() )
2013 0 : xSel->select( Any() );
2014 0 : }
2015 : }
2016 :
2017 0 : m_aCurrentSelection = _rSelection;
2018 :
2019 : // determine the form which all the selected objects belong to, if any
2020 0 : Reference< XForm > xNewCurrentForm;
2021 0 : for ( InterfaceBag::const_iterator loop = m_aCurrentSelection.begin();
2022 0 : loop != m_aCurrentSelection.end();
2023 : ++loop
2024 : )
2025 : {
2026 0 : Reference< XForm > xThisRoundsForm( GetForm( *loop ) );
2027 : OSL_ENSURE( xThisRoundsForm.is(), "FmXFormShell::setCurrentSelection: *everything* should belong to a form!" );
2028 :
2029 0 : if ( !xNewCurrentForm.is() )
2030 : { // the first form we encounterd
2031 0 : xNewCurrentForm = xThisRoundsForm;
2032 : }
2033 0 : else if ( xNewCurrentForm != xThisRoundsForm )
2034 : { // different forms -> no "current form" at all
2035 0 : xNewCurrentForm.clear();
2036 0 : break;
2037 : }
2038 0 : }
2039 :
2040 0 : if ( !m_aCurrentSelection.empty() )
2041 0 : impl_updateCurrentForm( xNewCurrentForm );
2042 :
2043 : // ensure some slots are updated
2044 0 : for ( size_t i = 0; i < sizeof( SelObjectSlotMap ) / sizeof( SelObjectSlotMap[0] ); ++i )
2045 0 : InvalidateSlot( SelObjectSlotMap[i], false);
2046 :
2047 0 : return true;
2048 : }
2049 :
2050 :
2051 0 : bool FmXFormShell::isSolelySelected( const Reference< XInterface >& _rxObject )
2052 : {
2053 0 : return ( m_aCurrentSelection.size() == 1 ) && ( *m_aCurrentSelection.begin() == _rxObject );
2054 : }
2055 :
2056 :
2057 0 : void FmXFormShell::forgetCurrentForm()
2058 : {
2059 0 : if ( !m_xCurrentForm.is() )
2060 0 : return;
2061 :
2062 : // reset ...
2063 0 : impl_updateCurrentForm( NULL );
2064 :
2065 : // ... and try finding a new current form
2066 : // #i88186# / 2008-04-12 / frank.schoenheit@sun.com
2067 0 : impl_defaultCurrentForm_nothrow();
2068 : }
2069 :
2070 :
2071 50 : void FmXFormShell::impl_updateCurrentForm( const Reference< XForm >& _rxNewCurForm )
2072 : {
2073 50 : if ( impl_checkDisposed() )
2074 50 : return;
2075 :
2076 50 : m_xCurrentForm = _rxNewCurForm;
2077 :
2078 : // propagate to the FormPage(Impl)
2079 50 : FmFormPage* pPage = m_pShell->GetCurPage();
2080 50 : if ( pPage )
2081 50 : pPage->GetImpl().setCurForm( m_xCurrentForm );
2082 :
2083 : // ensure the UI which depends on the current form is up-to-date
2084 650 : for ( size_t i = 0; i < sizeof( DlgSlotMap ) / sizeof( DlgSlotMap[0] ); ++i )
2085 600 : InvalidateSlot( DlgSlotMap[i], false );
2086 : }
2087 :
2088 :
2089 2 : void FmXFormShell::startListening()
2090 : {
2091 2 : if ( impl_checkDisposed() )
2092 0 : return;
2093 :
2094 2 : Reference< XRowSet> xDatabaseForm(m_xActiveForm, UNO_QUERY);
2095 2 : if (xDatabaseForm.is() && getConnection(xDatabaseForm).is())
2096 : {
2097 0 : Reference< XPropertySet> xActiveFormSet(m_xActiveForm, UNO_QUERY);
2098 0 : if (xActiveFormSet.is())
2099 : {
2100 : // wenn es eine Datenquelle gibt, dann den Listener aufbauen
2101 : // TODO: this is strange - shouldn't this depend on a isLoaded instead of
2102 : // a "has command value"? Finally, the command value only means that it was
2103 : // intended to be loaded, not that it actually *is* loaded
2104 0 : OUString aSource = ::comphelper::getString(xActiveFormSet->getPropertyValue(FM_PROP_COMMAND));
2105 0 : if (!aSource.isEmpty())
2106 : {
2107 0 : m_bDatabaseBar = true;
2108 :
2109 0 : xActiveFormSet->getPropertyValue(FM_PROP_NAVIGATION) >>= m_eNavigate;
2110 :
2111 0 : switch (m_eNavigate)
2112 : {
2113 : case NavigationBarMode_PARENT:
2114 : {
2115 : // suchen des Controllers, ueber den eine Navigation moeglich ist
2116 0 : Reference< XChild> xChild(m_xActiveController, UNO_QUERY);
2117 0 : Reference< runtime::XFormController > xParent;
2118 0 : while (xChild.is())
2119 : {
2120 0 : xChild = Reference< XChild>(xChild->getParent(), UNO_QUERY);
2121 0 : xParent = Reference< runtime::XFormController >(xChild, UNO_QUERY);
2122 0 : Reference< XPropertySet> xParentSet;
2123 0 : if (xParent.is())
2124 0 : xParentSet = Reference< XPropertySet>(xParent->getModel(), UNO_QUERY);
2125 0 : if (xParentSet.is())
2126 : {
2127 0 : xParentSet->getPropertyValue(FM_PROP_NAVIGATION) >>= m_eNavigate;
2128 0 : if (m_eNavigate == NavigationBarMode_CURRENT)
2129 0 : break;
2130 : }
2131 0 : }
2132 0 : m_xNavigationController = xParent;
2133 : }
2134 0 : break;
2135 :
2136 : case NavigationBarMode_CURRENT:
2137 0 : m_xNavigationController = m_xActiveController;
2138 0 : break;
2139 :
2140 : default:
2141 0 : m_xNavigationController = NULL;
2142 0 : m_bDatabaseBar = false;
2143 : }
2144 :
2145 0 : m_aNavControllerFeatures.dispose();
2146 0 : if ( m_xNavigationController.is() && ( m_xNavigationController != m_xActiveController ) )
2147 0 : m_aNavControllerFeatures.assign( m_xNavigationController );
2148 :
2149 : // an dem Controller, der die Navigation regelt, wg. RecordCount lauschen
2150 0 : Reference< XPropertySet> xNavigationSet;
2151 0 : if (m_xNavigationController.is())
2152 : {
2153 0 : xNavigationSet = Reference< XPropertySet>(m_xNavigationController->getModel(), UNO_QUERY);
2154 0 : if (xNavigationSet.is())
2155 0 : xNavigationSet->addPropertyChangeListener(FM_PROP_ROWCOUNT,this);
2156 : }
2157 0 : return;
2158 0 : }
2159 0 : }
2160 : }
2161 :
2162 2 : m_eNavigate = NavigationBarMode_NONE;
2163 2 : m_bDatabaseBar = false;
2164 2 : m_xNavigationController = NULL;
2165 : }
2166 :
2167 :
2168 2 : void FmXFormShell::stopListening()
2169 : {
2170 2 : if ( impl_checkDisposed() )
2171 2 : return;
2172 :
2173 2 : Reference< XRowSet> xDatabaseForm(m_xActiveForm, UNO_QUERY);
2174 2 : if ( xDatabaseForm.is() )
2175 : {
2176 1 : if (m_xNavigationController.is())
2177 : {
2178 0 : Reference< XPropertySet> xSet(m_xNavigationController->getModel(), UNO_QUERY);
2179 0 : if (xSet.is())
2180 0 : xSet->removePropertyChangeListener(FM_PROP_ROWCOUNT, this);
2181 :
2182 : }
2183 : }
2184 :
2185 2 : m_bDatabaseBar = false;
2186 2 : m_eNavigate = NavigationBarMode_NONE;
2187 2 : m_xNavigationController = NULL;
2188 : }
2189 :
2190 :
2191 0 : void FmXFormShell::ShowSelectionProperties( bool bShow )
2192 : {
2193 0 : if ( impl_checkDisposed() )
2194 0 : return;
2195 :
2196 : // if the window is already visible, only update the state
2197 0 : bool bHasChild = m_pShell->GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_SHOW_PROPERTIES );
2198 0 : if ( bHasChild && bShow )
2199 0 : UpdateSlot( SID_FM_PROPERTY_CONTROL );
2200 :
2201 : // else toggle state
2202 : else
2203 0 : m_pShell->GetViewShell()->GetViewFrame()->ToggleChildWindow(SID_FM_SHOW_PROPERTIES);
2204 :
2205 0 : InvalidateSlot( SID_FM_PROPERTIES, false );
2206 0 : InvalidateSlot( SID_FM_CTL_PROPERTIES, false );
2207 : }
2208 :
2209 :
2210 0 : IMPL_LINK(FmXFormShell, OnFoundData, FmFoundRecordInformation*, pfriWhere)
2211 : {
2212 0 : if ( impl_checkDisposed() )
2213 0 : return 0;
2214 :
2215 : DBG_ASSERT((pfriWhere->nContext >= 0) && (pfriWhere->nContext < (sal_Int16)m_aSearchForms.size()),
2216 : "FmXFormShell::OnFoundData : ungueltiger Kontext !");
2217 0 : Reference< XForm> xForm( m_aSearchForms.at(pfriWhere->nContext));
2218 : DBG_ASSERT(xForm.is(), "FmXFormShell::OnFoundData : ungueltige Form !");
2219 :
2220 0 : Reference< XRowLocate> xCursor(xForm, UNO_QUERY);
2221 0 : if (!xCursor.is())
2222 0 : return 0; // was soll ich da machen ?
2223 :
2224 : // zum Datensatz
2225 : try
2226 : {
2227 0 : xCursor->moveToBookmark(pfriWhere->aPosition);
2228 : }
2229 0 : catch(const SQLException&)
2230 : {
2231 : OSL_FAIL("Can position on bookmark!");
2232 : }
2233 :
2234 0 : LoopGrids(GA_FORCE_SYNC);
2235 :
2236 : // und zum Feld (dazu habe ich vor dem Start des Suchens die XVclComponent-Interfaces eingesammelt)
2237 : SAL_WARN_IF(static_cast<size_t>(pfriWhere->nFieldPos) >=
2238 : m_arrSearchedControls.size(),
2239 : "svx.form", "FmXFormShell::OnFoundData : invalid index!");
2240 0 : SdrObject* pObject = m_arrSearchedControls.at(pfriWhere->nFieldPos);
2241 :
2242 0 : m_pShell->GetFormView()->UnMarkAll(m_pShell->GetFormView()->GetSdrPageView());
2243 0 : m_pShell->GetFormView()->MarkObj(pObject, m_pShell->GetFormView()->GetSdrPageView());
2244 :
2245 0 : FmFormObj* pFormObject = FmFormObj::GetFormObject( pObject );
2246 0 : Reference< XControlModel > xControlModel( pFormObject ? pFormObject->GetUnoControlModel() : Reference< XControlModel >() );
2247 : DBG_ASSERT( xControlModel.is(), "FmXFormShell::OnFoundData: invalid control!" );
2248 0 : if ( !xControlModel.is() )
2249 0 : return 0;
2250 :
2251 : // disable the permanent cursor for the last grid we found a record
2252 0 : if (m_xLastGridFound.is() && (m_xLastGridFound != xControlModel))
2253 : {
2254 0 : Reference< XPropertySet> xOldSet(m_xLastGridFound, UNO_QUERY);
2255 0 : xOldSet->setPropertyValue(FM_PROP_ALWAYSSHOWCURSOR, makeAny( false ) );
2256 0 : Reference< XPropertyState> xOldSetState(xOldSet, UNO_QUERY);
2257 0 : if (xOldSetState.is())
2258 0 : xOldSetState->setPropertyToDefault(FM_PROP_CURSORCOLOR);
2259 : else
2260 0 : xOldSet->setPropertyValue(FM_PROP_CURSORCOLOR, Any());
2261 : }
2262 :
2263 : // wenn das Feld sich in einem GridControl befindet, muss ich dort noch in die entsprechende Spalte gehen
2264 0 : sal_Int32 nGridColumn = m_arrRelativeGridColumn[pfriWhere->nFieldPos];
2265 0 : if (nGridColumn != -1)
2266 : { // dummer weise muss ich mir das Control erst wieder besorgen
2267 0 : Reference<XControl> xControl( pFormObject ? impl_getControl( xControlModel, *pFormObject ) : Reference< XControl>() );
2268 0 : Reference< XGrid> xGrid(xControl, UNO_QUERY);
2269 : DBG_ASSERT(xGrid.is(), "FmXFormShell::OnFoundData : ungueltiges Control !");
2270 : // wenn eine der Asserts anschlaegt, habe ich beim Aufbauen von m_arrSearchedControls wohl was falsch gemacht
2271 :
2272 : // enable a permanent cursor for the grid so we can see the found text
2273 0 : Reference< XPropertySet> xModelSet(xControlModel, UNO_QUERY);
2274 : DBG_ASSERT(xModelSet.is(), "FmXFormShell::OnFoundData : invalid control model (no property set) !");
2275 0 : xModelSet->setPropertyValue( FM_PROP_ALWAYSSHOWCURSOR, makeAny( true ) );
2276 0 : xModelSet->setPropertyValue( FM_PROP_CURSORCOLOR, makeAny( sal_Int32( COL_LIGHTRED ) ) );
2277 0 : m_xLastGridFound = xControlModel;
2278 :
2279 0 : if ( xGrid.is() )
2280 0 : xGrid->setCurrentColumnPosition((sal_Int16)nGridColumn);
2281 : }
2282 :
2283 : // als der Cursor neu positioniert wurde, habe ich (in positioned) meine Formularleisten-Slots invalidiert, aber das greift
2284 : // hier dummerweise nicht, da i.A. ja der (modale) Suchdialog oben ist ... also Gewalt ...
2285 0 : sal_uInt16 nPos = 0;
2286 0 : while (DatabaseSlotMap[nPos])
2287 0 : m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Update(DatabaseSlotMap[nPos++]);
2288 : // leider geht das Update im Gegensatz zum Invalidate nur mit einzelnen Slots)
2289 :
2290 0 : return 0;
2291 : }
2292 :
2293 :
2294 0 : IMPL_LINK(FmXFormShell, OnCanceledNotFound, FmFoundRecordInformation*, pfriWhere)
2295 : {
2296 0 : if ( impl_checkDisposed() )
2297 0 : return 0;
2298 :
2299 : DBG_ASSERT((pfriWhere->nContext >= 0) && (pfriWhere->nContext < (sal_Int16)m_aSearchForms.size()),
2300 : "FmXFormShell::OnCanceledNotFound : ungueltiger Kontext !");
2301 0 : Reference< XForm> xForm( m_aSearchForms.at(pfriWhere->nContext));
2302 : DBG_ASSERT(xForm.is(), "FmXFormShell::OnCanceledNotFound : ungueltige Form !");
2303 :
2304 0 : Reference< XRowLocate> xCursor(xForm, UNO_QUERY);
2305 0 : if (!xCursor.is())
2306 0 : return 0; // was soll ich da machen ?
2307 :
2308 : // zum Datensatz
2309 : try
2310 : {
2311 0 : xCursor->moveToBookmark(pfriWhere->aPosition);
2312 : }
2313 0 : catch(const SQLException&)
2314 : {
2315 : OSL_FAIL("Can position on bookmark!");
2316 : }
2317 :
2318 :
2319 0 : m_pShell->GetFormView()->UnMarkAll(m_pShell->GetFormView()->GetSdrPageView());
2320 0 : return 0L;
2321 : }
2322 :
2323 :
2324 0 : IMPL_LINK(FmXFormShell, OnSearchContextRequest, FmSearchContext*, pfmscContextInfo)
2325 : {
2326 0 : if ( impl_checkDisposed() )
2327 0 : return 0;
2328 :
2329 : DBG_ASSERT(pfmscContextInfo->nContext < (sal_Int16)m_aSearchForms.size(), "FmXFormShell::OnSearchContextRequest : invalid parameter !");
2330 0 : Reference< XForm> xForm( m_aSearchForms.at(pfmscContextInfo->nContext));
2331 : DBG_ASSERT(xForm.is(), "FmXFormShell::OnSearchContextRequest : unexpected : invalid context !");
2332 :
2333 0 : Reference< XResultSet> xIter(xForm, UNO_QUERY);
2334 : DBG_ASSERT(xIter.is(), "FmXFormShell::OnSearchContextRequest : unexpected : context has no iterator !");
2335 :
2336 :
2337 : // assemble the list of fields to involve (that is, the ControlSources of all fields that have such a property)
2338 0 : OUString strFieldList, sFieldDisplayNames;
2339 0 : m_arrSearchedControls.clear();
2340 0 : m_arrRelativeGridColumn.clear();
2341 :
2342 : // small problem: To mark found fields, I need SdrObjects. To determine which controls
2343 : // to include in the search, I need Controls (that is, XControl interfaces). So I have
2344 : // to iterate over one of them and get the other in some way. Unfortunately, there is
2345 : // no direct connexion between the two worlds (except from a GetUnoControl to a
2346 : // SdrUnoObject, but this requires an OutputDevice I can not do anything with.
2347 : // However I can get to the Model from the Control and also from the SdrObject, and in
2348 : // this way the assignment SdrObject<->Control is possible with a double loop.
2349 : // The alternative to this (ugly but certainly not entirely fixable) solution would be
2350 : // to renounce the caching of the SdrObjects, which would lead to significant extra
2351 : // work in OnFoundData (since there I'd have to get the SdrObject first thing every
2352 : // time). But since OnFoundData is usually called more often than ExecuteSeearch, I'll
2353 : // do that here.
2354 :
2355 0 : Reference< XNameAccess> xValidFormFields;
2356 0 : Reference< XColumnsSupplier> xSupplyCols(xIter, UNO_QUERY);
2357 : DBG_ASSERT(xSupplyCols.is(), "FmXFormShell::OnSearchContextRequest : invalid cursor : no columns supplier !");
2358 0 : if (xSupplyCols.is())
2359 0 : xValidFormFields = xSupplyCols->getColumns();
2360 : DBG_ASSERT(xValidFormFields.is(), "FmXFormShell::OnSearchContextRequest : form has no fields !");
2361 :
2362 : // current Page/Controller
2363 0 : FmFormPage* pCurrentPage = m_pShell->GetCurPage();
2364 : assert(pCurrentPage && "FmXFormShell::OnSearchContextRequest : no page !");
2365 : // Search all SdrControls of this page...
2366 0 : OUString sControlSource, aName;
2367 :
2368 0 : SdrObjListIter aPageIter( *pCurrentPage );
2369 0 : while ( aPageIter.IsMore() )
2370 : {
2371 0 : SdrObject* pCurrent = aPageIter.Next();
2372 0 : FmFormObj* pFormObject = FmFormObj::GetFormObject( pCurrent );
2373 : // note that in case pCurrent is a virtual object, pFormObject points to the referenced object
2374 :
2375 0 : if ( !pFormObject )
2376 0 : continue;
2377 :
2378 : // the current object's model, in different tastes
2379 0 : Reference< XControlModel> xControlModel( pFormObject->GetUnoControlModel() );
2380 0 : Reference< XFormComponent > xCurrentFormComponent( xControlModel, UNO_QUERY );
2381 : DBG_ASSERT( xCurrentFormComponent.is(), "FmXFormShell::OnSearchContextRequest: invalid objects!" );
2382 0 : if ( !xCurrentFormComponent.is() )
2383 0 : continue;
2384 :
2385 : // does the component belong to the form which we're interested in?
2386 0 : if ( xCurrentFormComponent->getParent() != xForm )
2387 0 : continue;
2388 :
2389 : // ... ask for the ControlSource property
2390 0 : SearchableControlIterator iter( xCurrentFormComponent );
2391 0 : Reference< XControl> xControl;
2392 : // the control that has model xControlModel
2393 : // (the following while can be passed through several times, without the Control
2394 : // being modified, so I don't have to search every time from scratch)
2395 :
2396 0 : Reference< XInterface > xSearchable( iter.Next() );
2397 0 : while ( xSearchable.is() )
2398 : {
2399 0 : sControlSource = iter.getCurrentValue();
2400 0 : if ( sControlSource.isEmpty() )
2401 : {
2402 : // the current element has no ControlSource, so it is a GridControl (that
2403 : // is the only thing that still permits the SearchableControlIteratore)
2404 0 : xControl = impl_getControl( xControlModel, *pFormObject );
2405 : DBG_ASSERT(xControl.is(), "FmXFormShell::OnSearchContextRequest : didn't ::std::find a control with requested model !");
2406 :
2407 0 : Reference< XGridPeer> xGridPeer;
2408 0 : if ( xControl.is() )
2409 0 : xGridPeer.set( xControl->getPeer(), UNO_QUERY );
2410 : do
2411 : {
2412 0 : if (!xGridPeer.is())
2413 0 : break;
2414 :
2415 0 : Reference< XIndexAccess> xPeerContainer(xGridPeer, UNO_QUERY);
2416 0 : if (!xPeerContainer.is())
2417 0 : break;
2418 :
2419 0 : Reference< XIndexAccess> xModelColumns(xGridPeer->getColumns(), UNO_QUERY);
2420 : DBG_ASSERT(xModelColumns.is(), "FmXFormShell::OnSearchContextRequest : there is a grid control without columns !");
2421 : // the case 'no columns' should be indicated with an empty container, I think ...
2422 : DBG_ASSERT(xModelColumns->getCount() >= xPeerContainer->getCount(), "FmXFormShell::OnSearchContextRequest : impossible : have more view than model columns !");
2423 :
2424 0 : Reference< XInterface> xCurrentColumn;
2425 0 : for (sal_Int32 nViewPos=0; nViewPos<xPeerContainer->getCount(); ++nViewPos)
2426 : {
2427 0 : xPeerContainer->getByIndex(nViewPos) >>= xCurrentColumn;
2428 0 : if (!xCurrentColumn.is())
2429 0 : continue;
2430 :
2431 : // can we use this column control for searching ?
2432 0 : if (!IsSearchableControl(xCurrentColumn))
2433 0 : continue;
2434 :
2435 0 : sal_Int16 nModelPos = GridView2ModelPos(xModelColumns, nViewPos);
2436 0 : Reference< XPropertySet> xCurrentColModel;
2437 0 : xModelColumns->getByIndex(nModelPos) >>= xCurrentColModel;
2438 0 : aName = ::comphelper::getString(xCurrentColModel->getPropertyValue(FM_PROP_CONTROLSOURCE));
2439 : // the cursor has a field matching the control source ?
2440 0 : if (xValidFormFields->hasByName(aName))
2441 : {
2442 0 : strFieldList = strFieldList + OUString(aName.getStr()) + ";";
2443 :
2444 0 : sFieldDisplayNames = sFieldDisplayNames +
2445 0 : OUString(::comphelper::getString(xCurrentColModel->getPropertyValue(FM_PROP_LABEL)).getStr()) +
2446 0 : ";";
2447 :
2448 0 : pfmscContextInfo->arrFields.push_back(xCurrentColumn);
2449 :
2450 : // and the SdrOject to the Field
2451 0 : m_arrSearchedControls.push_back(pCurrent);
2452 : // the number of the column
2453 0 : m_arrRelativeGridColumn.push_back(nViewPos);
2454 : }
2455 0 : }
2456 0 : } while (false);
2457 : }
2458 : else
2459 : {
2460 0 : if (!sControlSource.isEmpty() && xValidFormFields->hasByName(sControlSource))
2461 : {
2462 : // now I need the Control to SdrObject
2463 0 : if (!xControl.is())
2464 : {
2465 0 : xControl = impl_getControl( xControlModel, *pFormObject );
2466 : DBG_ASSERT(xControl.is(), "FmXFormShell::OnSearchContextRequest : didn't ::std::find a control with requested model !");
2467 : }
2468 :
2469 0 : if (IsSearchableControl(xControl))
2470 : {
2471 : // all tests passed -> take along in the list
2472 0 : strFieldList = strFieldList + OUString(sControlSource.getStr()) + ";";
2473 :
2474 : // the label which should appear for the control :
2475 0 : sFieldDisplayNames = sFieldDisplayNames +
2476 0 : OUString(getLabelName(Reference< XPropertySet>(xControlModel, UNO_QUERY)).getStr()) +
2477 0 : ";";
2478 :
2479 : // mark the SdrObject (accelerates the treatment in OnFoundData)
2480 0 : m_arrSearchedControls.push_back(pCurrent);
2481 :
2482 : // the number of the column (here a dummy, since it is only interesting for GridControls)
2483 0 : m_arrRelativeGridColumn.push_back(-1);
2484 :
2485 : // and for the formatted search...
2486 0 : pfmscContextInfo->arrFields.push_back(Reference<XInterface>( xControl, UNO_QUERY ));
2487 : }
2488 : }
2489 : }
2490 :
2491 0 : xSearchable = iter.Next();
2492 : }
2493 0 : }
2494 :
2495 0 : strFieldList = comphelper::string::stripEnd(strFieldList, ';');
2496 0 : sFieldDisplayNames = comphelper::string::stripEnd(sFieldDisplayNames, ';');
2497 :
2498 0 : if (pfmscContextInfo->arrFields.empty())
2499 : {
2500 0 : pfmscContextInfo->arrFields.clear();
2501 0 : pfmscContextInfo->xCursor = NULL;
2502 0 : pfmscContextInfo->strUsedFields.clear();
2503 0 : return 0L;
2504 : }
2505 :
2506 0 : pfmscContextInfo->xCursor = xIter;
2507 0 : pfmscContextInfo->strUsedFields = strFieldList;
2508 0 : pfmscContextInfo->sFieldDisplayNames = sFieldDisplayNames;
2509 :
2510 : // 66463 - 31.05.99 - FS
2511 : // when the cursor is a non-STANDARD RecordMode, set it back
2512 0 : Reference< XPropertySet> xCursorSet(pfmscContextInfo->xCursor, UNO_QUERY);
2513 0 : Reference< XResultSetUpdate> xUpdateCursor(pfmscContextInfo->xCursor, UNO_QUERY);
2514 0 : if (xUpdateCursor.is() && xCursorSet.is())
2515 : {
2516 0 : if (::comphelper::getBOOL(xCursorSet->getPropertyValue(FM_PROP_ISNEW)))
2517 0 : xUpdateCursor->moveToCurrentRow();
2518 0 : else if (::comphelper::getBOOL(xCursorSet->getPropertyValue(FM_PROP_ISMODIFIED)))
2519 0 : xUpdateCursor->cancelRowUpdates();
2520 : }
2521 :
2522 0 : return pfmscContextInfo->arrFields.size();
2523 : }
2524 :
2525 : // XContainerListener
2526 :
2527 353 : void FmXFormShell::elementInserted(const ContainerEvent& evt) throw(::com::sun::star::uno::RuntimeException, std::exception)
2528 : {
2529 353 : if ( impl_checkDisposed() )
2530 353 : return;
2531 :
2532 : // new object to listen to
2533 353 : Reference< XInterface> xTemp;
2534 353 : evt.Element >>= xTemp;
2535 353 : AddElement(xTemp);
2536 :
2537 706 : SolarMutexGuard g;
2538 706 : m_pShell->DetermineForms(true);
2539 : }
2540 :
2541 :
2542 6 : void FmXFormShell::elementReplaced(const ContainerEvent& evt) throw(::com::sun::star::uno::RuntimeException, std::exception)
2543 : {
2544 6 : if ( impl_checkDisposed() )
2545 6 : return;
2546 :
2547 6 : Reference< XInterface> xTemp;
2548 6 : evt.ReplacedElement >>= xTemp;
2549 6 : RemoveElement(xTemp);
2550 6 : evt.Element >>= xTemp;
2551 6 : AddElement(xTemp);
2552 : }
2553 :
2554 :
2555 9 : void FmXFormShell::elementRemoved(const ContainerEvent& evt) throw(::com::sun::star::uno::RuntimeException, std::exception)
2556 : {
2557 9 : if ( impl_checkDisposed() )
2558 9 : return;
2559 :
2560 9 : Reference< XInterface> xTemp;
2561 9 : evt.Element >>= xTemp;
2562 9 : RemoveElement(xTemp);
2563 :
2564 18 : SolarMutexGuard g;
2565 18 : m_pShell->DetermineForms(true);
2566 : }
2567 :
2568 :
2569 11548 : void FmXFormShell::UpdateForms( bool _bInvalidate )
2570 : {
2571 11548 : if ( impl_checkDisposed() )
2572 11548 : return;
2573 :
2574 11548 : Reference< XIndexAccess > xForms;
2575 :
2576 11548 : FmFormPage* pPage = m_pShell->GetCurPage();
2577 11548 : if ( pPage )
2578 : {
2579 11531 : if ( m_pShell->m_bDesignMode )
2580 10176 : xForms.set(pPage->GetForms( false ), css::uno::UNO_QUERY);
2581 : }
2582 :
2583 11548 : if ( m_xForms != xForms )
2584 : {
2585 173 : RemoveElement( m_xForms );
2586 173 : m_xForms = xForms;
2587 173 : AddElement( m_xForms );
2588 : }
2589 :
2590 23096 : SolarMutexGuard g;
2591 23096 : m_pShell->DetermineForms( _bInvalidate );
2592 : }
2593 :
2594 :
2595 532 : void FmXFormShell::AddElement(const Reference< XInterface>& _xElement)
2596 : {
2597 532 : if ( impl_checkDisposed() )
2598 532 : return;
2599 532 : impl_AddElement_nothrow(_xElement);
2600 : }
2601 :
2602 588 : void FmXFormShell::impl_AddElement_nothrow(const Reference< XInterface>& Element)
2603 : {
2604 : // am Container horchen
2605 588 : const Reference< XIndexContainer> xContainer(Element, UNO_QUERY);
2606 588 : if (xContainer.is())
2607 : {
2608 298 : const sal_uInt32 nCount = xContainer->getCount();
2609 298 : Reference< XInterface> xElement;
2610 354 : for (sal_uInt32 i = 0; i < nCount; ++i)
2611 : {
2612 56 : xElement.set(xContainer->getByIndex(i),UNO_QUERY);
2613 56 : impl_AddElement_nothrow(xElement);
2614 : }
2615 :
2616 596 : const Reference< XContainer> xCont(Element, UNO_QUERY);
2617 298 : if (xCont.is())
2618 596 : xCont->addContainerListener(this);
2619 : }
2620 :
2621 1176 : const Reference< ::com::sun::star::view::XSelectionSupplier> xSelSupplier(Element, UNO_QUERY);
2622 588 : if (xSelSupplier.is())
2623 598 : xSelSupplier->addSelectionChangeListener(this);
2624 588 : }
2625 :
2626 :
2627 3416 : void FmXFormShell::RemoveElement(const Reference< XInterface>& Element)
2628 : {
2629 3416 : if ( impl_checkDisposed() )
2630 3416 : return;
2631 3416 : impl_RemoveElement_nothrow(Element);
2632 : }
2633 :
2634 3796 : void FmXFormShell::impl_RemoveElement_nothrow(const Reference< XInterface>& Element)
2635 : {
2636 3796 : const Reference< ::com::sun::star::view::XSelectionSupplier> xSelSupplier(Element, UNO_QUERY);
2637 3796 : if (xSelSupplier.is())
2638 9 : xSelSupplier->removeSelectionChangeListener(this);
2639 :
2640 : // remove connection to children
2641 7592 : const Reference< XIndexContainer> xContainer(Element, UNO_QUERY);
2642 3796 : if (xContainer.is())
2643 : {
2644 297 : const Reference< XContainer> xCont(Element, UNO_QUERY);
2645 297 : if (xCont.is())
2646 297 : xCont->removeContainerListener(this);
2647 :
2648 297 : const sal_uInt32 nCount = xContainer->getCount();
2649 594 : Reference< XInterface> xElement;
2650 677 : for (sal_uInt32 i = 0; i < nCount; i++)
2651 : {
2652 380 : xElement.set(xContainer->getByIndex(i),UNO_QUERY);
2653 380 : impl_RemoveElement_nothrow(xElement);
2654 297 : }
2655 : }
2656 :
2657 3796 : InterfaceBag::iterator wasSelectedPos = m_aCurrentSelection.find( Element );
2658 3796 : if ( wasSelectedPos != m_aCurrentSelection.end() )
2659 3796 : m_aCurrentSelection.erase( wasSelectedPos );
2660 3796 : }
2661 :
2662 :
2663 0 : void FmXFormShell::selectionChanged(const lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException, std::exception)
2664 : {
2665 0 : if ( impl_checkDisposed() )
2666 0 : return;
2667 :
2668 0 : Reference< XSelectionSupplier > xSupplier( rEvent.Source, UNO_QUERY );
2669 0 : Reference< XInterface > xSelObj( xSupplier->getSelection(), UNO_QUERY );
2670 : // a selection was removed, this can only be done by the shell
2671 0 : if ( !xSelObj.is() )
2672 0 : return;
2673 :
2674 0 : EnableTrackProperties(false);
2675 :
2676 0 : bool bMarkChanged = m_pShell->GetFormView()->checkUnMarkAll(rEvent.Source);
2677 0 : Reference< XForm > xNewForm( GetForm( rEvent.Source ) );
2678 :
2679 0 : InterfaceBag aNewSelection;
2680 0 : aNewSelection.insert( Reference<XInterface>( xSelObj, UNO_QUERY ) );
2681 :
2682 0 : if ( setCurrentSelection( aNewSelection ) && IsPropBrwOpen() )
2683 0 : ShowSelectionProperties( true );
2684 :
2685 0 : EnableTrackProperties(true);
2686 :
2687 0 : if ( bMarkChanged )
2688 0 : m_pShell->NotifyMarkListChanged( m_pShell->GetFormView() );
2689 : }
2690 :
2691 :
2692 4 : IMPL_LINK_NOARG_TYPED(FmXFormShell, OnTimeOut, Timer*, void)
2693 : {
2694 2 : if ( impl_checkDisposed() )
2695 2 : return;
2696 :
2697 2 : if (m_pShell->IsDesignMode() && m_pShell->GetFormView())
2698 2 : SetSelection(m_pShell->GetFormView()->GetMarkedObjectList());
2699 : }
2700 :
2701 :
2702 36 : void FmXFormShell::SetSelectionDelayed()
2703 : {
2704 36 : if ( impl_checkDisposed() )
2705 36 : return;
2706 :
2707 36 : if (m_pShell->IsDesignMode() && IsTrackPropertiesEnabled() && !m_aMarkTimer.IsActive())
2708 13 : m_aMarkTimer.Start();
2709 : }
2710 :
2711 :
2712 318 : void FmXFormShell::SetSelection(const SdrMarkList& rMarkList)
2713 : {
2714 318 : if ( impl_checkDisposed() )
2715 318 : return;
2716 :
2717 318 : DetermineSelection(rMarkList);
2718 318 : m_pShell->NotifyMarkListChanged(m_pShell->GetFormView());
2719 : }
2720 :
2721 :
2722 318 : void FmXFormShell::DetermineSelection(const SdrMarkList& rMarkList)
2723 : {
2724 318 : if ( setCurrentSelectionFromMark( rMarkList ) && IsPropBrwOpen() )
2725 0 : ShowSelectionProperties( true );
2726 318 : }
2727 :
2728 :
2729 0 : bool FmXFormShell::IsPropBrwOpen() const
2730 : {
2731 0 : if ( impl_checkDisposed() )
2732 0 : return false;
2733 :
2734 0 : return m_pShell->GetViewShell() && m_pShell->GetViewShell()->GetViewFrame()
2735 0 : && m_pShell->GetViewShell()->GetViewFrame()->HasChildWindow(SID_FM_SHOW_PROPERTIES);
2736 : }
2737 :
2738 :
2739 : class FmXFormShell::SuspendPropertyTracking
2740 : {
2741 : private:
2742 : FmXFormShell& m_rShell;
2743 : bool m_bEnabled;
2744 :
2745 : public:
2746 3258 : explicit SuspendPropertyTracking( FmXFormShell& _rShell )
2747 : :m_rShell( _rShell )
2748 3258 : ,m_bEnabled( false )
2749 : {
2750 3258 : if ( m_rShell.IsTrackPropertiesEnabled() )
2751 : {
2752 3258 : m_rShell.EnableTrackProperties( false );
2753 3258 : m_bEnabled = true;
2754 : }
2755 3258 : }
2756 :
2757 3258 : ~SuspendPropertyTracking( )
2758 : {
2759 3258 : if ( m_bEnabled ) // note that ( false != m_bEnabled ) implies ( NULL != m_pShell )
2760 3258 : m_rShell.EnableTrackProperties( true );
2761 3258 : }
2762 : };
2763 :
2764 :
2765 3258 : void FmXFormShell::SetDesignMode(bool bDesign)
2766 : {
2767 3258 : if ( impl_checkDisposed() )
2768 3258 : return;
2769 :
2770 : DBG_ASSERT(m_pShell->GetFormView(), "FmXFormShell::SetDesignMode : invalid call (have no shell or no view) !");
2771 3258 : m_bChangingDesignMode = true;
2772 :
2773 : // 67506 - 15.07.99 - FS
2774 : // if we're switching off the design mode we have to force the property browser to be closed
2775 : // so it can commit it's changes _before_ we load the forms
2776 3258 : if (!bDesign)
2777 : {
2778 258 : m_bHadPropertyBrowserInDesignMode = m_pShell->GetViewShell()->GetViewFrame()->HasChildWindow(SID_FM_SHOW_PROPERTIES);
2779 258 : if (m_bHadPropertyBrowserInDesignMode)
2780 0 : m_pShell->GetViewShell()->GetViewFrame()->ToggleChildWindow(SID_FM_SHOW_PROPERTIES);
2781 : }
2782 :
2783 3258 : FmFormView* pFormView = m_pShell->GetFormView();
2784 3258 : if (bDesign)
2785 : {
2786 : // we are currently filtering, so stop filtering
2787 3000 : if (m_bFilterMode)
2788 0 : stopFiltering(false);
2789 :
2790 : // unsubscribe from the objects of my MarkList
2791 3000 : pFormView->GetImpl()->stopMarkListWatching();
2792 : }
2793 : else
2794 : {
2795 258 : m_aMarkTimer.Stop();
2796 :
2797 258 : SuspendPropertyTracking aSuspend( *this );
2798 258 : pFormView->GetImpl()->saveMarkList( true );
2799 : }
2800 :
2801 3258 : if (bDesign && m_xExternalViewController.is())
2802 0 : CloseExternalFormViewer();
2803 :
2804 3258 : pFormView->ChangeDesignMode(bDesign);
2805 :
2806 : // notify listensers
2807 3258 : FmDesignModeChangedHint aChangedHint( bDesign );
2808 3258 : m_pShell->Broadcast(aChangedHint);
2809 :
2810 3258 : m_pShell->m_bDesignMode = bDesign;
2811 3258 : UpdateForms( false );
2812 :
2813 3258 : m_pTextShell->designModeChanged( m_pShell->m_bDesignMode );
2814 :
2815 3258 : if (bDesign)
2816 : {
2817 3000 : SdrMarkList aList;
2818 : {
2819 : // during changing the mark list, don't track the selected objects in the property browser
2820 3000 : SuspendPropertyTracking aSuspend( *this );
2821 : // restore the marks
2822 3000 : pFormView->GetImpl()->restoreMarkList( aList );
2823 : }
2824 :
2825 : // synchronize with the restored mark list
2826 3000 : if ( aList.GetMarkCount() )
2827 0 : SetSelection( aList );
2828 : }
2829 : else
2830 : {
2831 : // subscribe to the model of the view (so that I'm informed when someone deletes
2832 : // during the alive mode controls that I had saved in the saveMarklist (60343)
2833 258 : pFormView->GetImpl()->startMarkListWatching();
2834 : }
2835 :
2836 3258 : m_pShell->UIFeatureChanged();
2837 :
2838 : // 67506 - 15.07.99 - FS
2839 3258 : if (bDesign && m_bHadPropertyBrowserInDesignMode)
2840 : {
2841 : // The UIFeatureChanged performs an update (a check of the available features) asynchronously.
2842 : // So we can't call ShowSelectionProperties directly as the according feature isn't enabled yet.
2843 : // That's why we use an asynchron execution on the dispatcher.
2844 : // (And that's why this has to be done AFTER the UIFeatureChanged.)
2845 0 : m_pShell->GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_SHOW_PROPERTY_BROWSER, SfxCallMode::ASYNCHRON );
2846 : }
2847 3258 : m_bChangingDesignMode = false;
2848 : }
2849 :
2850 :
2851 0 : Reference< XControl> FmXFormShell::impl_getControl( const Reference< XControlModel >& i_rxModel, const FmFormObj& i_rKnownFormObj )
2852 : {
2853 0 : if ( impl_checkDisposed() )
2854 0 : return NULL;
2855 :
2856 0 : Reference< XControl > xControl;
2857 : try
2858 : {
2859 0 : Reference< XControlContainer> xControlContainer( getControlContainerForView(), UNO_SET_THROW );
2860 :
2861 0 : Sequence< Reference< XControl > > seqControls( xControlContainer->getControls() );
2862 0 : const Reference< XControl >* pControls = seqControls.getArray();
2863 : // ... that I can then search
2864 0 : for (sal_Int32 i=0; i<seqControls.getLength(); ++i)
2865 : {
2866 0 : xControl.set( pControls[i], UNO_SET_THROW );
2867 0 : Reference< XControlModel > xCurrentModel( xControl->getModel() );
2868 0 : if ( xCurrentModel == i_rxModel )
2869 0 : break;
2870 0 : xControl.clear();
2871 0 : }
2872 :
2873 0 : if ( !xControl.is() )
2874 : {
2875 : // fallabck (some controls might not have been created, yet, since they were never visible so far)
2876 0 : Reference< XControl > xContainerControl( xControlContainer, UNO_QUERY_THROW );
2877 0 : const vcl::Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerControl->getPeer() );
2878 0 : ENSURE_OR_THROW( pContainerWindow, "unexpected control container implementation" );
2879 :
2880 0 : const SdrView* pSdrView = m_pShell ? m_pShell->GetFormView() : NULL;
2881 0 : ENSURE_OR_THROW( pSdrView, "no current view" );
2882 :
2883 0 : xControl.set( i_rKnownFormObj.GetUnoControl( *pSdrView, *pContainerWindow ), UNO_QUERY_THROW );
2884 0 : }
2885 : }
2886 0 : catch( const Exception& )
2887 : {
2888 : DBG_UNHANDLED_EXCEPTION();
2889 : }
2890 :
2891 : OSL_ENSURE( xControl.is(), "FmXFormShell::impl_getControl: no control found!" );
2892 0 : return xControl;
2893 : }
2894 :
2895 :
2896 0 : void FmXFormShell::impl_collectFormSearchContexts_nothrow( const Reference< XInterface>& _rxStartingPoint,
2897 : const OUString& _rCurrentLevelPrefix, FmFormArray& _out_rForms, ::std::vector< OUString >& _out_rNames )
2898 : {
2899 : try
2900 : {
2901 0 : Reference< XIndexAccess> xContainer( _rxStartingPoint, UNO_QUERY );
2902 0 : if ( !xContainer.is() )
2903 0 : return;
2904 :
2905 0 : sal_Int32 nCount( xContainer->getCount() );
2906 0 : if ( nCount == 0 )
2907 0 : return;
2908 :
2909 0 : OUString sCurrentFormName;
2910 0 : OUStringBuffer aNextLevelPrefix;
2911 0 : for ( sal_Int32 i=0; i<nCount; ++i )
2912 : {
2913 : // is the current child a form?
2914 0 : Reference< XForm > xCurrentAsForm( xContainer->getByIndex(i), UNO_QUERY );
2915 0 : if ( !xCurrentAsForm.is() )
2916 0 : continue;
2917 :
2918 0 : Reference< XNamed > xNamed( xCurrentAsForm, UNO_QUERY_THROW );
2919 0 : sCurrentFormName = xNamed->getName();
2920 :
2921 : // the name of the current form
2922 0 : OUStringBuffer sCompleteCurrentName( sCurrentFormName );
2923 0 : if ( !_rCurrentLevelPrefix.isEmpty() )
2924 : {
2925 0 : sCompleteCurrentName.appendAscii( " (" );
2926 0 : sCompleteCurrentName.append ( _rCurrentLevelPrefix );
2927 0 : sCompleteCurrentName.appendAscii( ")" );
2928 : }
2929 :
2930 : // the prefix for the next level
2931 0 : aNextLevelPrefix = _rCurrentLevelPrefix;
2932 0 : if ( !_rCurrentLevelPrefix.isEmpty() )
2933 0 : aNextLevelPrefix.append( '/' );
2934 0 : aNextLevelPrefix.append( sCurrentFormName );
2935 :
2936 : // remember both the form and it's "display name"
2937 0 : _out_rForms.push_back( xCurrentAsForm );
2938 0 : _out_rNames.push_back( sCompleteCurrentName.makeStringAndClear() );
2939 :
2940 : // und absteigen
2941 0 : impl_collectFormSearchContexts_nothrow( xCurrentAsForm, aNextLevelPrefix.makeStringAndClear(), _out_rForms, _out_rNames );
2942 0 : }
2943 : }
2944 0 : catch( const Exception& )
2945 : {
2946 : DBG_UNHANDLED_EXCEPTION();
2947 : }
2948 : }
2949 :
2950 :
2951 0 : void FmXFormShell::startFiltering()
2952 : {
2953 0 : if ( impl_checkDisposed() )
2954 0 : return;
2955 :
2956 : // setting all forms in filter mode
2957 0 : FmXFormView* pXView = m_pShell->GetFormView()->GetImpl();
2958 :
2959 : // if the active controller is our external one we have to use the trigger controller
2960 0 : Reference< XControlContainer> xContainer;
2961 0 : if (getActiveController() == m_xExternalViewController)
2962 : {
2963 : DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::startFiltering : inconsistent : active external controller, but no one triggered this !");
2964 0 : xContainer = m_xExtViewTriggerController->getContainer();
2965 : }
2966 : else
2967 0 : xContainer = getActiveController()->getContainer();
2968 :
2969 0 : PFormViewPageWindowAdapter pAdapter = pXView->findWindow( xContainer );
2970 0 : if ( pAdapter.is() )
2971 : {
2972 0 : const ::std::vector< Reference< runtime::XFormController> >& rControllerList = pAdapter->GetList();
2973 0 : for ( ::std::vector< Reference< runtime::XFormController> >::const_iterator j = rControllerList.begin();
2974 0 : j != rControllerList.end();
2975 : ++j
2976 : )
2977 : {
2978 0 : Reference< XModeSelector> xModeSelector(*j, UNO_QUERY);
2979 0 : if (xModeSelector.is())
2980 0 : xModeSelector->setMode( OUString( "FilterMode" ) );
2981 0 : }
2982 : }
2983 :
2984 0 : m_bFilterMode = true;
2985 :
2986 0 : m_pShell->UIFeatureChanged();
2987 0 : SfxViewFrame* pViewFrame = m_pShell->GetViewShell()->GetViewFrame();
2988 0 : pViewFrame->GetBindings().InvalidateShell( *m_pShell );
2989 :
2990 0 : if ( pViewFrame->KnowsChildWindow( SID_FM_FILTER_NAVIGATOR )
2991 0 : && !pViewFrame->HasChildWindow( SID_FM_FILTER_NAVIGATOR )
2992 : )
2993 : {
2994 0 : pViewFrame->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR );
2995 0 : }
2996 : }
2997 :
2998 :
2999 0 : void saveFilter(const Reference< runtime::XFormController >& _rxController)
3000 : {
3001 0 : Reference< XPropertySet> xFormAsSet(_rxController->getModel(), UNO_QUERY);
3002 0 : Reference< XPropertySet> xControllerAsSet(_rxController, UNO_QUERY);
3003 0 : Reference< XIndexAccess> xControllerAsIndex(_rxController, UNO_QUERY);
3004 :
3005 : // call the subcontroller
3006 0 : Reference< runtime::XFormController > xController;
3007 0 : for (sal_Int32 i = 0, nCount = xControllerAsIndex->getCount(); i < nCount; ++i)
3008 : {
3009 0 : xControllerAsIndex->getByIndex(i) >>= xController;
3010 0 : saveFilter(xController);
3011 : }
3012 :
3013 : try
3014 : {
3015 :
3016 0 : xFormAsSet->setPropertyValue(FM_PROP_FILTER, xControllerAsSet->getPropertyValue(FM_PROP_FILTER));
3017 0 : xFormAsSet->setPropertyValue(FM_PROP_APPLYFILTER, makeAny( true ) );
3018 : }
3019 0 : catch (const Exception& )
3020 : {
3021 : DBG_UNHANDLED_EXCEPTION();
3022 0 : }
3023 :
3024 0 : }
3025 :
3026 :
3027 0 : void FmXFormShell::stopFiltering(bool bSave)
3028 : {
3029 0 : if ( impl_checkDisposed() )
3030 0 : return;
3031 :
3032 0 : m_bFilterMode = false;
3033 :
3034 0 : FmXFormView* pXView = m_pShell->GetFormView()->GetImpl();
3035 :
3036 : // if the active controller is our external one we have to use the trigger controller
3037 0 : Reference< XControlContainer> xContainer;
3038 0 : if (getActiveController() == m_xExternalViewController)
3039 : {
3040 : DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::stopFiltering : inconsistent : active external controller, but no one triggered this !");
3041 0 : xContainer = m_xExtViewTriggerController->getContainer();
3042 : }
3043 : else
3044 0 : xContainer = getActiveController()->getContainer();
3045 :
3046 0 : PFormViewPageWindowAdapter pAdapter = pXView->findWindow(xContainer);
3047 0 : if ( pAdapter.is() )
3048 : {
3049 0 : const ::std::vector< Reference< runtime::XFormController > >& rControllerList = pAdapter->GetList();
3050 0 : ::std::vector < OUString > aOriginalFilters;
3051 0 : ::std::vector < sal_Bool > aOriginalApplyFlags;
3052 :
3053 0 : if (bSave)
3054 : {
3055 0 : for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllerList.begin();
3056 0 : j != rControllerList.end(); ++j)
3057 : {
3058 0 : if (bSave)
3059 : { // remember the current filter settings in case we're goin to reload the forms below (which may fail)
3060 : try
3061 : {
3062 0 : Reference< XPropertySet > xFormAsSet((*j)->getModel(), UNO_QUERY);
3063 0 : aOriginalFilters.push_back(::comphelper::getString(xFormAsSet->getPropertyValue(FM_PROP_FILTER)));
3064 0 : aOriginalApplyFlags.push_back(::comphelper::getBOOL(xFormAsSet->getPropertyValue(FM_PROP_APPLYFILTER)));
3065 : }
3066 0 : catch(Exception&)
3067 : {
3068 : OSL_FAIL("FmXFormShell::stopFiltering : could not get the original filter !");
3069 : // put dummies into the arrays so the they have the right size
3070 :
3071 0 : if (aOriginalFilters.size() == aOriginalApplyFlags.size())
3072 : // the first getPropertyValue failed -> use two dummies
3073 0 : aOriginalFilters.push_back( OUString() );
3074 0 : aOriginalApplyFlags.push_back( sal_False );
3075 : }
3076 : }
3077 0 : saveFilter(*j);
3078 : }
3079 : }
3080 0 : for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllerList.begin();
3081 0 : j != rControllerList.end(); ++j)
3082 : {
3083 :
3084 0 : Reference< XModeSelector> xModeSelector(*j, UNO_QUERY);
3085 0 : if (xModeSelector.is())
3086 0 : xModeSelector->setMode( OUString( "DataMode" ) );
3087 0 : }
3088 0 : if (bSave) // execute the filter
3089 : {
3090 0 : const ::std::vector< Reference< runtime::XFormController > > & rControllers = pAdapter->GetList();
3091 0 : for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllers.begin();
3092 0 : j != rControllers.end(); ++j)
3093 : {
3094 0 : Reference< XLoadable> xReload((*j)->getModel(), UNO_QUERY);
3095 0 : if (!xReload.is())
3096 0 : continue;
3097 0 : Reference< XPropertySet > xFormSet(xReload, UNO_QUERY);
3098 :
3099 : try
3100 : {
3101 0 : xReload->reload();
3102 : }
3103 0 : catch(Exception&)
3104 : {
3105 : OSL_FAIL("FmXFormShell::stopFiltering: Exception occurred!");
3106 : }
3107 :
3108 0 : if (!isRowSetAlive(xFormSet))
3109 : { // something went wrong -> restore the original state
3110 0 : OUString sOriginalFilter = aOriginalFilters[ j - rControllers.begin() ];
3111 0 : bool bOriginalApplyFlag = aOriginalApplyFlags[ j - rControllers.begin() ];
3112 : try
3113 : {
3114 0 : xFormSet->setPropertyValue(FM_PROP_FILTER, makeAny(sOriginalFilter));
3115 0 : xFormSet->setPropertyValue(FM_PROP_APPLYFILTER, makeAny(bOriginalApplyFlag));
3116 0 : xReload->reload();
3117 : }
3118 0 : catch(const Exception&)
3119 : {
3120 : DBG_UNHANDLED_EXCEPTION();
3121 0 : }
3122 : }
3123 0 : }
3124 0 : }
3125 : }
3126 :
3127 0 : m_pShell->UIFeatureChanged();
3128 0 : m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
3129 : }
3130 :
3131 :
3132 0 : void FmXFormShell::CreateExternalView()
3133 : {
3134 0 : if ( impl_checkDisposed() )
3135 0 : return;
3136 :
3137 : DBG_ASSERT(m_xAttachedFrame.is(), "FmXFormShell::CreateExternalView : no frame !");
3138 :
3139 : // the frame the external view is displayed in
3140 0 : bool bAlreadyExistent = m_xExternalViewController.is();
3141 0 : Reference< ::com::sun::star::frame::XFrame> xExternalViewFrame;
3142 0 : OUString sFrameName("_beamer");
3143 0 : sal_Int32 nSearchFlags = ::com::sun::star::frame::FrameSearchFlag::CHILDREN | ::com::sun::star::frame::FrameSearchFlag::CREATE;
3144 :
3145 0 : Reference< runtime::XFormController > xCurrentNavController( getNavController());
3146 : // the creation of the "partwindow" may cause a deactivate of the document which will result in our nav controller to be set to NULL
3147 :
3148 : // _first_ check if we have any valid fields we can use for the grid view
3149 : // FS - 21.10.99 - 69219
3150 : {
3151 0 : FmXBoundFormFieldIterator aModelIterator(xCurrentNavController->getModel());
3152 0 : Reference< XPropertySet> xCurrentModelSet;
3153 0 : bool bHaveUsableControls = false;
3154 0 : while ((xCurrentModelSet = Reference< XPropertySet>(aModelIterator.Next(), UNO_QUERY)).is())
3155 : {
3156 : // the FmXBoundFormFieldIterator only supplies controls with a valid control source
3157 : // so we just have to check the field type
3158 0 : sal_Int16 nClassId = ::comphelper::getINT16(xCurrentModelSet->getPropertyValue(FM_PROP_CLASSID));
3159 0 : switch (nClassId)
3160 : {
3161 : case FormComponentType::IMAGECONTROL:
3162 : case FormComponentType::CONTROL:
3163 0 : continue;
3164 : }
3165 0 : bHaveUsableControls = true;
3166 0 : break;
3167 : }
3168 :
3169 0 : if (!bHaveUsableControls)
3170 : {
3171 0 : ScopedVclPtrInstance<MessageDialog>::Create(nullptr, SVX_RESSTR(RID_STR_NOCONTROLS_FOR_EXTERNALDISPLAY))->Execute();
3172 0 : return;
3173 0 : }
3174 : }
3175 :
3176 : // load the component for external form views
3177 0 : if (!bAlreadyExistent)
3178 : {
3179 0 : URL aWantToDispatch;
3180 0 : aWantToDispatch.Complete = FMURL_COMPONENT_FORMGRIDVIEW;
3181 :
3182 0 : Reference< ::com::sun::star::frame::XDispatchProvider> xProv(m_xAttachedFrame, UNO_QUERY);
3183 0 : Reference< ::com::sun::star::frame::XDispatch> xDisp;
3184 0 : if (xProv.is())
3185 0 : xDisp = xProv->queryDispatch(aWantToDispatch, sFrameName, nSearchFlags);
3186 0 : if (xDisp.is())
3187 : {
3188 0 : xDisp->dispatch(aWantToDispatch, Sequence< PropertyValue>());
3189 : }
3190 :
3191 : // with this the component should be loaded, now search the frame where it resides in
3192 0 : xExternalViewFrame = m_xAttachedFrame->findFrame(sFrameName, ::com::sun::star::frame::FrameSearchFlag::CHILDREN);
3193 0 : if (xExternalViewFrame.is())
3194 : {
3195 0 : m_xExternalViewController = xExternalViewFrame->getController();
3196 0 : Reference< ::com::sun::star::lang::XComponent> xComp(m_xExternalViewController, UNO_QUERY);
3197 0 : if (xComp.is())
3198 0 : xComp->addEventListener(static_cast<XEventListener*>(static_cast<XPropertyChangeListener*>(this)));
3199 0 : }
3200 : }
3201 : else
3202 : {
3203 0 : xExternalViewFrame = m_xExternalViewController->getFrame();
3204 0 : Reference< ::com::sun::star::frame::XDispatchProvider> xCommLink(xExternalViewFrame, UNO_QUERY);
3205 :
3206 : // if we display the active form we interpret the slot as "remove it"
3207 0 : Reference< XForm> xCurrentModel(xCurrentNavController->getModel(), UNO_QUERY);
3208 0 : if ((xCurrentModel == m_xExternalDisplayedForm) || (getInternalForm(xCurrentModel) == m_xExternalDisplayedForm))
3209 : {
3210 0 : if ( m_xExternalViewController == getActiveController() )
3211 : {
3212 0 : Reference< runtime::XFormController > xAsFormController( m_xExternalViewController, UNO_QUERY );
3213 0 : ControllerFeatures aHelper( xAsFormController, NULL );
3214 0 : (void)aHelper->commitCurrentControl();
3215 : }
3216 :
3217 0 : Reference< runtime::XFormController > xNewController(m_xExtViewTriggerController);
3218 0 : CloseExternalFormViewer();
3219 0 : setActiveController(xNewController);
3220 0 : return;
3221 : }
3222 :
3223 0 : URL aClearURL;
3224 0 : aClearURL.Complete = FMURL_GRIDVIEW_CLEARVIEW;
3225 :
3226 0 : Reference< ::com::sun::star::frame::XDispatch> xClear( xCommLink->queryDispatch(aClearURL, OUString(), 0));
3227 0 : if (xClear.is())
3228 0 : xClear->dispatch(aClearURL, Sequence< PropertyValue>());
3229 : }
3230 :
3231 : // TODO: We need an interceptor at the xSupplier, which forwards all queryDispatch requests to the FormController
3232 : // instance for which this "external view" was triggered
3233 :
3234 : // get the dispatch interface of the frame so we can communicate (interceptable) with the controller
3235 0 : Reference< ::com::sun::star::frame::XDispatchProvider> xCommLink(xExternalViewFrame, UNO_QUERY);
3236 :
3237 0 : if (m_xExternalViewController.is())
3238 : {
3239 : DBG_ASSERT(xCommLink.is(), "FmXFormShell::CreateExternalView : the component doesn't have the necessary interfaces !");
3240 : // collect the dispatchers we will need
3241 0 : URL aAddColumnURL;
3242 0 : aAddColumnURL.Complete = FMURL_GRIDVIEW_ADDCOLUMN;
3243 0 : Reference< ::com::sun::star::frame::XDispatch> xAddColumnDispatch( xCommLink->queryDispatch(aAddColumnURL, OUString(), 0));
3244 0 : URL aAttachURL;
3245 0 : aAttachURL.Complete = FMURL_GRIDVIEW_ATTACHTOFORM;
3246 0 : Reference< ::com::sun::star::frame::XDispatch> xAttachDispatch( xCommLink->queryDispatch(aAttachURL, OUString(), 0));
3247 :
3248 0 : if (xAddColumnDispatch.is() && xAttachDispatch.is())
3249 : {
3250 : DBG_ASSERT(xCurrentNavController.is(), "FmXFormShell::CreateExternalView : invalid call : have no nav controller !");
3251 : // first : dispatch the descriptions for the columns to add
3252 0 : sal_Int16 nAddedColumns = 0;
3253 :
3254 : // for radio buttons we need some special structures
3255 : typedef std::map< OUString, Sequence< OUString> > MapUString2UstringSeq;
3256 : typedef std::map< OUString, OUString > FmMapUString2UString;
3257 : typedef std::map< OUString, sal_Int16 > FmMapUString2Int16;
3258 :
3259 0 : MapUString2UstringSeq aRadioValueLists;
3260 0 : MapUString2UstringSeq aRadioListSources;
3261 0 : FmMapUString2UString aRadioControlSources;
3262 0 : FmMapUString2Int16 aRadioPositions;
3263 :
3264 0 : FmXBoundFormFieldIterator aModelIterator(xCurrentNavController->getModel());
3265 0 : Reference< XPropertySet> xCurrentModelSet;
3266 0 : OUString sColumnType,aGroupName,sControlSource;
3267 0 : Sequence< Property> aProps;
3268 0 : Reference< XPropertySet> xCurrentBoundField;
3269 0 : while ((xCurrentModelSet = Reference< XPropertySet>(aModelIterator.Next(), UNO_QUERY)).is())
3270 : {
3271 0 : xCurrentModelSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xCurrentBoundField;
3272 : OSL_ENSURE(xCurrentModelSet.is(),"xCurrentModelSet is null!");
3273 : // create a description of the column to be created
3274 : // first : determine it's type
3275 :
3276 0 : sal_Int16 nClassId = ::comphelper::getINT16(xCurrentModelSet->getPropertyValue(FM_PROP_CLASSID));
3277 0 : switch (nClassId)
3278 : {
3279 : case FormComponentType::RADIOBUTTON:
3280 : {
3281 : // get the label of the button (this is the access key for our structures)
3282 0 : aGroupName = getLabelName(xCurrentModelSet);
3283 :
3284 : // add the reference value of the radio button to the list source sequence
3285 0 : Sequence< OUString>& aThisGroupLabels = aRadioListSources[aGroupName];
3286 0 : sal_Int32 nNewSizeL = aThisGroupLabels.getLength() + 1;
3287 0 : aThisGroupLabels.realloc(nNewSizeL);
3288 0 : aThisGroupLabels.getArray()[nNewSizeL - 1] = ::comphelper::getString(xCurrentModelSet->getPropertyValue(FM_PROP_REFVALUE));
3289 :
3290 : // add the label to the value list sequence
3291 0 : Sequence< OUString>& aThisGroupControlSources = aRadioValueLists[aGroupName];
3292 0 : sal_Int32 nNewSizeC = aThisGroupControlSources.getLength() + 1;
3293 0 : aThisGroupControlSources.realloc(nNewSizeC);
3294 0 : aThisGroupControlSources.getArray()[nNewSizeC - 1] = ::comphelper::getString(xCurrentModelSet->getPropertyValue(FM_PROP_LABEL));
3295 :
3296 : // remember the controls source of the radio group
3297 0 : sControlSource = ::comphelper::getString(xCurrentModelSet->getPropertyValue(FM_PROP_CONTROLSOURCE));
3298 0 : if (aRadioControlSources.find(aGroupName) == aRadioControlSources.end())
3299 0 : aRadioControlSources[aGroupName] = sControlSource;
3300 : #ifdef DBG_UTIL
3301 : else
3302 : DBG_ASSERT(aRadioControlSources[aGroupName] == sControlSource,
3303 : "FmXFormShell::CreateExternalView : inconsistent radio buttons detected !");
3304 : // (radio buttons with the same name should have the same control source)
3305 : #endif
3306 : // remember the position within the columns
3307 0 : if (aRadioPositions.find(aGroupName) == aRadioPositions.end())
3308 0 : aRadioPositions[aGroupName] = (sal_Int16)nAddedColumns;
3309 :
3310 : // any further handling is done below
3311 : }
3312 0 : continue;
3313 :
3314 : case FormComponentType::IMAGECONTROL:
3315 : case FormComponentType::CONTROL:
3316 : // no grid columns for these types (though they have a control source)
3317 0 : continue;
3318 : case FormComponentType::CHECKBOX:
3319 0 : sColumnType = FM_COL_CHECKBOX; break;
3320 : case FormComponentType::LISTBOX:
3321 0 : sColumnType = FM_COL_LISTBOX; break;
3322 : case FormComponentType::COMBOBOX:
3323 0 : sColumnType = FM_COL_COMBOBOX; break;
3324 : case FormComponentType::DATEFIELD:
3325 0 : sColumnType = FM_COL_DATEFIELD; break;
3326 : case FormComponentType::TIMEFIELD:
3327 0 : sColumnType = FM_COL_TIMEFIELD; break;
3328 : case FormComponentType::NUMERICFIELD:
3329 0 : sColumnType = FM_COL_NUMERICFIELD; break;
3330 : case FormComponentType::CURRENCYFIELD:
3331 0 : sColumnType = FM_COL_CURRENCYFIELD; break;
3332 : case FormComponentType::PATTERNFIELD:
3333 0 : sColumnType = FM_COL_PATTERNFIELD; break;
3334 :
3335 : case FormComponentType::TEXTFIELD:
3336 : {
3337 0 : sColumnType = FM_COL_TEXTFIELD;
3338 : // we know at least two different controls which are TextFields : the basic edit field and the formatted
3339 : // field. we distinguish them by their service name
3340 0 : Reference< lang::XServiceInfo> xInfo(xCurrentModelSet, UNO_QUERY);
3341 0 : if (xInfo.is())
3342 : {
3343 0 : sal_Int16 nObjectType = getControlTypeByObject(xInfo);
3344 0 : if (OBJ_FM_FORMATTEDFIELD == nObjectType)
3345 0 : sColumnType = FM_COL_FORMATTEDFIELD;
3346 0 : }
3347 : }
3348 0 : break;
3349 : default:
3350 0 : sColumnType = FM_COL_TEXTFIELD; break;
3351 : }
3352 :
3353 0 : const sal_Int16 nDispatchArgs = 3;
3354 0 : Sequence< PropertyValue> aDispatchArgs(nDispatchArgs);
3355 0 : PropertyValue* pDispatchArgs = aDispatchArgs.getArray();
3356 :
3357 : // properties describing "meta data" about the column
3358 : // the type
3359 0 : pDispatchArgs->Name = FMARG_ADDCOL_COLUMNTYPE;
3360 0 : pDispatchArgs->Value <<= sColumnType;
3361 0 : ++pDispatchArgs;
3362 :
3363 : // the pos : append the col
3364 0 : pDispatchArgs->Name = FMARG_ADDCOL_COLUMNPOS;
3365 0 : pDispatchArgs->Value <<= nAddedColumns;
3366 0 : ++pDispatchArgs;
3367 :
3368 : // the properties to forward to the new column
3369 0 : Sequence< PropertyValue> aColumnProps(1);
3370 0 : PropertyValue* pColumnProps = aColumnProps.getArray();
3371 :
3372 : // the label
3373 0 : pColumnProps->Name = FM_PROP_LABEL;
3374 0 : pColumnProps->Value <<= getLabelName(xCurrentModelSet);
3375 0 : ++pColumnProps;
3376 :
3377 : // for all other props : transfer them
3378 0 : Reference< XPropertySetInfo> xControlModelInfo( xCurrentModelSet->getPropertySetInfo());
3379 : DBG_ASSERT(xControlModelInfo.is(), "FmXFormShell::CreateExternalView : the control model has no property info ! This will crash !");
3380 0 : aProps = xControlModelInfo->getProperties();
3381 0 : const Property* pProps = aProps.getConstArray();
3382 :
3383 : // realloc the control description sequence
3384 0 : sal_Int32 nExistentDescs = pColumnProps - aColumnProps.getArray();
3385 0 : aColumnProps.realloc(nExistentDescs + aProps.getLength());
3386 0 : pColumnProps = aColumnProps.getArray() + nExistentDescs;
3387 :
3388 0 : for (sal_Int32 i=0; i<aProps.getLength(); ++i, ++pProps)
3389 : {
3390 0 : if (pProps->Name == FM_PROP_LABEL)
3391 : // already set
3392 0 : continue;
3393 0 : if (pProps->Name == FM_PROP_DEFAULTCONTROL)
3394 : // allow the column's own "default control"
3395 0 : continue;
3396 0 : if (pProps->Attributes & PropertyAttribute::READONLY)
3397 : // assume that properties which are readonly for the control are ro for the column to be created, too
3398 0 : continue;
3399 :
3400 0 : pColumnProps->Name = pProps->Name;
3401 0 : pColumnProps->Value = xCurrentModelSet->getPropertyValue(pProps->Name);
3402 0 : ++pColumnProps;
3403 : }
3404 0 : aColumnProps.realloc(pColumnProps - aColumnProps.getArray());
3405 :
3406 : // columns props are a dispatch argument
3407 0 : pDispatchArgs->Name = "ColumnProperties"; // TODO : fmurl.*
3408 0 : pDispatchArgs->Value = makeAny(aColumnProps);
3409 0 : ++pDispatchArgs;
3410 : DBG_ASSERT(nDispatchArgs == (pDispatchArgs - aDispatchArgs.getConstArray()),
3411 : "FmXFormShell::CreateExternalView : forgot to adjust nDispatchArgs ?");
3412 :
3413 : // dispatch the "add column"
3414 0 : xAddColumnDispatch->dispatch(aAddColumnURL, aDispatchArgs);
3415 0 : ++nAddedColumns;
3416 0 : }
3417 :
3418 : // now for the radio button handling
3419 0 : sal_Int16 nOffset(0);
3420 : // properties describing the "direct" column properties
3421 0 : const sal_Int16 nListBoxDescription = 6;
3422 0 : Sequence< PropertyValue> aListBoxDescription(nListBoxDescription);
3423 0 : for ( FmMapUString2UString::const_iterator aCtrlSource = aRadioControlSources.begin();
3424 0 : aCtrlSource != aRadioControlSources.end();
3425 : ++aCtrlSource, ++nOffset
3426 : )
3427 : {
3428 :
3429 0 : PropertyValue* pListBoxDescription = aListBoxDescription.getArray();
3430 : // label
3431 0 : pListBoxDescription->Name = FM_PROP_LABEL;
3432 0 : pListBoxDescription->Value <<= (*aCtrlSource).first;
3433 0 : ++pListBoxDescription;
3434 :
3435 : // control source
3436 0 : pListBoxDescription->Name = FM_PROP_CONTROLSOURCE;
3437 0 : pListBoxDescription->Value <<= (*aCtrlSource).second;
3438 0 : ++pListBoxDescription;
3439 :
3440 : // bound column
3441 0 : pListBoxDescription->Name = FM_PROP_BOUNDCOLUMN;
3442 0 : pListBoxDescription->Value <<= (sal_Int16)1;
3443 0 : ++pListBoxDescription;
3444 :
3445 : // content type
3446 0 : pListBoxDescription->Name = FM_PROP_LISTSOURCETYPE;
3447 0 : ListSourceType eType = ListSourceType_VALUELIST;
3448 0 : pListBoxDescription->Value = makeAny(eType);
3449 0 : ++pListBoxDescription;
3450 :
3451 : // list source
3452 0 : MapUString2UstringSeq::const_iterator aCurrentListSource = aRadioListSources.find((*aCtrlSource).first);
3453 : DBG_ASSERT(aCurrentListSource != aRadioListSources.end(),
3454 : "FmXFormShell::CreateExternalView : inconsistent radio descriptions !");
3455 0 : pListBoxDescription->Name = FM_PROP_LISTSOURCE;
3456 0 : pListBoxDescription->Value = makeAny((*aCurrentListSource).second);
3457 0 : ++pListBoxDescription;
3458 :
3459 : // value list
3460 0 : MapUString2UstringSeq::const_iterator aCurrentValueList = aRadioValueLists.find((*aCtrlSource).first);
3461 : DBG_ASSERT(aCurrentValueList != aRadioValueLists.end(),
3462 : "FmXFormShell::CreateExternalView : inconsistent radio descriptions !");
3463 0 : pListBoxDescription->Name = FM_PROP_STRINGITEMLIST;
3464 0 : pListBoxDescription->Value = makeAny(((*aCurrentValueList).second));
3465 0 : ++pListBoxDescription;
3466 :
3467 : DBG_ASSERT(nListBoxDescription == (pListBoxDescription - aListBoxDescription.getConstArray()),
3468 : "FmXFormShell::CreateExternalView : forgot to adjust nListBoxDescription ?");
3469 :
3470 : // properties describing the column "meta data"
3471 0 : const sal_Int16 nDispatchArgs = 3;
3472 0 : Sequence< PropertyValue> aDispatchArgs(nDispatchArgs);
3473 0 : PropertyValue* pDispatchArgs = aDispatchArgs.getArray();
3474 :
3475 : // column type : listbox
3476 0 : pDispatchArgs->Name = FMARG_ADDCOL_COLUMNTYPE;
3477 0 : OUString fColName = FM_COL_LISTBOX;
3478 0 : pDispatchArgs->Value <<= fColName;
3479 : // pDispatchArgs->Value <<= (OUString)FM_COL_LISTBOX;
3480 0 : ++pDispatchArgs;
3481 :
3482 : // column position
3483 0 : pDispatchArgs->Name = FMARG_ADDCOL_COLUMNPOS;
3484 0 : FmMapUString2Int16::const_iterator aOffset = aRadioPositions.find((*aCtrlSource).first);
3485 : DBG_ASSERT(aOffset != aRadioPositions.end(),
3486 : "FmXFormShell::CreateExternalView : inconsistent radio descriptions !");
3487 0 : sal_Int16 nPosition = (*aOffset).second;
3488 0 : nPosition = nPosition + nOffset;
3489 : // we already inserted nOffset additional columns ....
3490 0 : pDispatchArgs->Value <<= nPosition;
3491 0 : ++pDispatchArgs;
3492 :
3493 : // the
3494 0 : pDispatchArgs->Name = "ColumnProperties"; // TODO : fmurl.*
3495 0 : pDispatchArgs->Value = makeAny(aListBoxDescription);
3496 0 : ++pDispatchArgs;
3497 : DBG_ASSERT(nDispatchArgs == (pDispatchArgs - aDispatchArgs.getConstArray()),
3498 : "FmXFormShell::CreateExternalView : forgot to adjust nDispatchArgs ?");
3499 :
3500 : // dispatch the "add column"
3501 0 : xAddColumnDispatch->dispatch(aAddColumnURL, aDispatchArgs);
3502 0 : ++nAddedColumns;
3503 0 : }
3504 :
3505 :
3506 : DBG_ASSERT(nAddedColumns > 0, "FmXFormShell::CreateExternalView : no controls (inconsistent) !");
3507 : // we should have checked if we have any usable controls (see above).
3508 :
3509 : // "load" the "form" of the external view
3510 0 : PropertyValue aArg;
3511 0 : aArg.Name = FMARG_ATTACHTO_MASTERFORM;
3512 0 : Reference< XResultSet> xForm(xCurrentNavController->getModel(), UNO_QUERY);
3513 0 : aArg.Value <<= xForm;
3514 :
3515 0 : m_xExternalDisplayedForm = xForm;
3516 : // do this before dispatching the "attach" command, as the attach may result in a call to our queryDispatch (for the FormSlots)
3517 : // whichs needs the m_xExternalDisplayedForm
3518 :
3519 0 : xAttachDispatch->dispatch(aAttachURL, Sequence< PropertyValue>(&aArg, 1));
3520 :
3521 0 : m_xExtViewTriggerController = xCurrentNavController;
3522 :
3523 : // we want to know modifications done in the external view
3524 : // if the external controller is a XFormController we can use all our default handlings for it
3525 0 : Reference< runtime::XFormController > xFormController( m_xExternalViewController, UNO_QUERY );
3526 : OSL_ENSURE( xFormController.is(), "FmXFormShell::CreateExternalView:: invalid external view controller!" );
3527 0 : if (xFormController.is())
3528 0 : xFormController->addActivateListener(static_cast<XFormControllerListener*>(this));
3529 0 : }
3530 : }
3531 : #ifdef DBG_UTIL
3532 : else
3533 : {
3534 : OSL_FAIL("FmXFormShell::CreateExternalView : could not create the external form view !");
3535 : }
3536 : #endif
3537 0 : InvalidateSlot( SID_FM_VIEW_AS_GRID, false );
3538 : }
3539 :
3540 :
3541 3235 : void FmXFormShell::implAdjustConfigCache()
3542 : {
3543 : // get (cache) the wizard usage flag
3544 3235 : Sequence< OUString > aNames(1);
3545 3235 : aNames[0] = "FormControlPilotsEnabled";
3546 6470 : Sequence< Any > aFlags = GetProperties(aNames);
3547 3235 : if (1 == aFlags.getLength())
3548 6470 : m_bUseWizards = ::cppu::any2bool(aFlags[0]);
3549 3235 : }
3550 :
3551 :
3552 0 : void FmXFormShell::Notify( const com::sun::star::uno::Sequence< OUString >& _rPropertyNames)
3553 : {
3554 0 : if ( impl_checkDisposed() )
3555 0 : return;
3556 :
3557 0 : const OUString* pSearch = _rPropertyNames.getConstArray();
3558 0 : const OUString* pSearchTil = pSearch + _rPropertyNames.getLength();
3559 0 : for (;pSearch < pSearchTil; ++pSearch)
3560 0 : if (*pSearch == "FormControlPilotsEnabled")
3561 : {
3562 0 : implAdjustConfigCache();
3563 0 : InvalidateSlot( SID_FM_USE_WIZARDS, true );
3564 : }
3565 : }
3566 :
3567 0 : void FmXFormShell::ImplCommit()
3568 : {
3569 0 : }
3570 :
3571 :
3572 0 : void FmXFormShell::SetWizardUsing(bool _bUseThem)
3573 : {
3574 0 : m_bUseWizards = _bUseThem;
3575 :
3576 0 : Sequence< OUString > aNames(1);
3577 0 : aNames[0] = "FormControlPilotsEnabled";
3578 0 : Sequence< Any > aValues(1);
3579 0 : aValues[0] <<= m_bUseWizards;
3580 0 : PutProperties(aNames, aValues);
3581 0 : }
3582 :
3583 :
3584 3994 : void FmXFormShell::viewDeactivated( FmFormView& _rCurrentView, bool _bDeactivateController /* = sal_True */ )
3585 : {
3586 :
3587 3994 : if ( _rCurrentView.GetImpl() && !_rCurrentView.IsDesignMode() )
3588 : {
3589 561 : _rCurrentView.GetImpl()->Deactivate( _bDeactivateController );
3590 : }
3591 :
3592 : // if we have an async load operation pending for the 0-th page for this view,
3593 : // we need to cancel this
3594 3994 : FmFormPage* pPage = _rCurrentView.GetCurPage();
3595 3994 : if ( pPage )
3596 : {
3597 : // move all events from our queue to a new one, omit the events for the deactivated
3598 : // page
3599 3977 : ::std::queue< FmLoadAction > aNewEvents;
3600 8132 : while ( !m_aLoadingPages.empty() )
3601 : {
3602 178 : FmLoadAction aAction = m_aLoadingPages.front();
3603 178 : m_aLoadingPages.pop();
3604 178 : if ( pPage != aAction.pPage )
3605 : {
3606 0 : aNewEvents.push( aAction );
3607 : }
3608 : else
3609 : {
3610 178 : Application::RemoveUserEvent( aAction.nEventId );
3611 : }
3612 : }
3613 3977 : m_aLoadingPages = aNewEvents;
3614 : }
3615 :
3616 : // remove callbacks at the page
3617 3994 : if ( pPage )
3618 : {
3619 3977 : pPage->GetImpl().SetFormsCreationHdl( Link<>() );
3620 : }
3621 3994 : UpdateForms( true );
3622 3994 : }
3623 :
3624 :
3625 1196 : IMPL_LINK_NOARG( FmXFormShell, OnFirstTimeActivation )
3626 : {
3627 598 : if ( impl_checkDisposed() )
3628 0 : return 0L;
3629 :
3630 598 : m_nActivationEvent = 0;
3631 598 : SfxObjectShell* pDocument = m_pShell->GetObjectShell();
3632 :
3633 598 : if ( pDocument && !pDocument->HasName() )
3634 : {
3635 541 : if ( isEnhancedForm() )
3636 : {
3637 : // show the data navigator
3638 0 : if ( !m_pShell->GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_SHOW_DATANAVIGATOR ) )
3639 0 : m_pShell->GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_SHOW_DATANAVIGATOR );
3640 : }
3641 : }
3642 :
3643 598 : return 0L;
3644 : }
3645 :
3646 :
3647 254 : IMPL_LINK( FmXFormShell, OnFormsCreated, FmFormPage*, /*_pPage*/ )
3648 : {
3649 127 : UpdateForms( true );
3650 127 : return 0L;
3651 : }
3652 :
3653 :
3654 3853 : void FmXFormShell::viewActivated( FmFormView& _rCurrentView, bool _bSyncAction /* = sal_False */ )
3655 : {
3656 :
3657 3853 : FmFormPage* pPage = _rCurrentView.GetCurPage();
3658 :
3659 : // activate our view if we are activated ourself
3660 : // FS - 30.06.99 - 67308
3661 3853 : if ( _rCurrentView.GetImpl() && !_rCurrentView.IsDesignMode() )
3662 : {
3663 : // load forms for the page the current view belongs to
3664 560 : if ( pPage )
3665 : {
3666 560 : if ( !pPage->GetImpl().hasEverBeenActivated() )
3667 265 : loadForms( pPage, FORMS_LOAD | ( _bSyncAction ? FORMS_SYNC : FORMS_ASYNC ) );
3668 560 : pPage->GetImpl().setHasBeenActivated( );
3669 : }
3670 :
3671 : // first-time initializations for the views
3672 560 : if ( !_rCurrentView.GetImpl()->hasEverBeenActivated( ) )
3673 : {
3674 257 : _rCurrentView.GetImpl()->onFirstViewActivation( PTR_CAST( FmFormModel, _rCurrentView.GetModel() ) );
3675 257 : _rCurrentView.GetImpl()->setHasBeenActivated( );
3676 : }
3677 :
3678 : // activate the current view
3679 560 : _rCurrentView.GetImpl()->Activate( _bSyncAction );
3680 : }
3681 :
3682 : // set callbacks at the page
3683 3853 : if ( pPage )
3684 : {
3685 3853 : pPage->GetImpl().SetFormsCreationHdl( LINK( this, FmXFormShell, OnFormsCreated ) );
3686 : }
3687 :
3688 3853 : UpdateForms( true );
3689 :
3690 3853 : if ( !hasEverBeenActivated() )
3691 : {
3692 3153 : m_nActivationEvent = Application::PostUserEvent( LINK( this, FmXFormShell, OnFirstTimeActivation ) );
3693 3153 : setHasBeenActivated();
3694 : }
3695 :
3696 : // find a default "current form", if there is none, yet
3697 : // #i88186# / 2008-04-12 / frank.schoenheit@sun.com
3698 3853 : impl_defaultCurrentForm_nothrow();
3699 3853 : }
3700 :
3701 :
3702 3853 : void FmXFormShell::impl_defaultCurrentForm_nothrow()
3703 : {
3704 3853 : if ( impl_checkDisposed() )
3705 0 : return;
3706 :
3707 3853 : if ( m_xCurrentForm.is() )
3708 : // no action required
3709 73 : return;
3710 :
3711 3780 : FmFormView* pFormView = m_pShell->GetFormView();
3712 3780 : FmFormPage* pPage = pFormView ? pFormView->GetCurPage() : NULL;
3713 3780 : if ( !pPage )
3714 0 : return;
3715 :
3716 : try
3717 : {
3718 3780 : Reference< XIndexAccess > xForms( pPage->GetForms( false ), UNO_QUERY );
3719 3780 : if ( !xForms.is() || !xForms->hasElements() )
3720 3730 : return;
3721 :
3722 100 : Reference< XForm > xNewCurrentForm( xForms->getByIndex(0), UNO_QUERY_THROW );
3723 100 : impl_updateCurrentForm( xNewCurrentForm );
3724 : }
3725 0 : catch( const Exception& )
3726 : {
3727 : DBG_UNHANDLED_EXCEPTION();
3728 : }
3729 : }
3730 :
3731 :
3732 0 : void FmXFormShell::smartControlReset( const Reference< XIndexAccess >& _rxModels )
3733 : {
3734 0 : if (!_rxModels.is())
3735 : {
3736 : OSL_FAIL("FmXFormShell::smartControlReset: invalid container!");
3737 0 : return;
3738 : }
3739 :
3740 0 : static const OUString sClassIdPropertyName = FM_PROP_CLASSID;
3741 0 : static const OUString sBoundFieldPropertyName = FM_PROP_BOUNDFIELD;
3742 0 : sal_Int32 nCount = _rxModels->getCount();
3743 0 : Reference< XPropertySet > xCurrent;
3744 0 : Reference< XPropertySetInfo > xCurrentInfo;
3745 0 : Reference< XPropertySet > xBoundField;
3746 :
3747 0 : for (sal_Int32 i=0; i<nCount; ++i)
3748 : {
3749 0 : _rxModels->getByIndex(i) >>= xCurrent;
3750 0 : if (xCurrent.is())
3751 0 : xCurrentInfo = xCurrent->getPropertySetInfo();
3752 : else
3753 0 : xCurrentInfo.clear();
3754 0 : if (!xCurrentInfo.is())
3755 0 : continue;
3756 :
3757 0 : if (xCurrentInfo->hasPropertyByName(sClassIdPropertyName))
3758 : { // it's a control model
3759 :
3760 : // check if this control is bound to a living database field
3761 0 : if (xCurrentInfo->hasPropertyByName(sBoundFieldPropertyName))
3762 0 : xCurrent->getPropertyValue(sBoundFieldPropertyName) >>= xBoundField;
3763 : else
3764 0 : xBoundField.clear();
3765 :
3766 : // reset only if it's *not* bound
3767 0 : bool bReset = !xBoundField.is();
3768 :
3769 : // and additionally, check if it has an external value binding
3770 0 : Reference< XBindableValue > xBindable( xCurrent, UNO_QUERY );
3771 0 : if ( xBindable.is() && xBindable->getValueBinding().is() )
3772 0 : bReset = false;
3773 :
3774 0 : if ( bReset )
3775 : {
3776 0 : Reference< XReset > xControlReset( xCurrent, UNO_QUERY );
3777 0 : if ( xControlReset.is() )
3778 0 : xControlReset->reset();
3779 0 : }
3780 : }
3781 : else
3782 : {
3783 0 : Reference< XIndexAccess > xContainer(xCurrent, UNO_QUERY);
3784 0 : if (xContainer.is())
3785 0 : smartControlReset(xContainer);
3786 : }
3787 0 : }
3788 : }
3789 :
3790 :
3791 16 : IMPL_LINK( FmXFormShell, OnLoadForms, FmFormPage*, /*_pPage*/ )
3792 : {
3793 8 : FmLoadAction aAction = m_aLoadingPages.front();
3794 8 : m_aLoadingPages.pop();
3795 :
3796 8 : loadForms( aAction.pPage, aAction.nFlags & ~FORMS_ASYNC );
3797 8 : return 0L;
3798 : }
3799 :
3800 :
3801 : namespace
3802 : {
3803 26 : bool lcl_isLoadable( const Reference< XInterface >& _rxLoadable )
3804 : {
3805 : // determines whether a form should be loaded or not
3806 : // if there is no datasource or connection there is no reason to load a form
3807 26 : Reference< XPropertySet > xSet( _rxLoadable, UNO_QUERY );
3808 26 : if ( !xSet.is() )
3809 0 : return false;
3810 : try
3811 : {
3812 26 : Reference< XConnection > xConn;
3813 26 : if ( isEmbeddedInDatabase( _rxLoadable.get(), xConn ) )
3814 0 : return true;
3815 :
3816 : // is there already a active connection
3817 26 : xSet->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConn;
3818 26 : if ( xConn.is() )
3819 0 : return true;
3820 :
3821 52 : OUString sPropertyValue;
3822 26 : OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DATASOURCE ) >>= sPropertyValue );
3823 26 : if ( !sPropertyValue.isEmpty() )
3824 0 : return true;
3825 :
3826 26 : OSL_VERIFY( xSet->getPropertyValue( FM_PROP_URL ) >>= sPropertyValue );
3827 26 : if ( !sPropertyValue.isEmpty() )
3828 26 : return true;
3829 : }
3830 0 : catch(const Exception&)
3831 : {
3832 : DBG_UNHANDLED_EXCEPTION();
3833 : }
3834 26 : return false;
3835 : }
3836 : }
3837 :
3838 :
3839 296 : void FmXFormShell::loadForms( FmFormPage* _pPage, const sal_uInt16 _nBehaviour /* FORMS_LOAD | FORMS_SYNC */ )
3840 : {
3841 : DBG_ASSERT( ( _nBehaviour & ( FORMS_ASYNC | FORMS_UNLOAD ) ) != ( FORMS_ASYNC | FORMS_UNLOAD ),
3842 : "FmXFormShell::loadForms: async loading not supported - this will heavily fail!" );
3843 :
3844 296 : if ( _nBehaviour & FORMS_ASYNC )
3845 : {
3846 : m_aLoadingPages.push( FmLoadAction(
3847 : _pPage,
3848 : _nBehaviour,
3849 : Application::PostUserEvent( LINK( this, FmXFormShell, OnLoadForms ), _pPage )
3850 187 : ) );
3851 483 : return;
3852 : }
3853 :
3854 : DBG_ASSERT( _pPage, "FmXFormShell::loadForms: invalid page!" );
3855 109 : if ( _pPage )
3856 : {
3857 : // lock the undo env so the forms can change non-transient properties while loading
3858 : // (without this my doc's modified flag would be set)
3859 109 : FmFormModel* pModel = PTR_CAST( FmFormModel, _pPage->GetModel() );
3860 : DBG_ASSERT( pModel, "FmXFormShell::loadForms: invalid model!" );
3861 109 : if ( pModel )
3862 109 : pModel->GetUndoEnv().Lock();
3863 :
3864 : // load all forms
3865 109 : Reference< XIndexAccess > xForms;
3866 109 : xForms.set(_pPage->GetForms( false ), css::uno::UNO_QUERY);
3867 :
3868 109 : if ( xForms.is() )
3869 : {
3870 109 : Reference< XLoadable > xForm;
3871 135 : for ( sal_Int32 j = 0, nCount = xForms->getCount(); j < nCount; ++j )
3872 : {
3873 26 : xForms->getByIndex( j ) >>= xForm;
3874 26 : bool bFormWasLoaded = false;
3875 : // a database form must be loaded for
3876 : try
3877 : {
3878 26 : if ( 0 == ( _nBehaviour & FORMS_UNLOAD ) )
3879 : {
3880 26 : if ( lcl_isLoadable( xForm ) && !xForm->isLoaded() )
3881 0 : xForm->load();
3882 : }
3883 : else
3884 : {
3885 0 : if ( xForm->isLoaded() )
3886 : {
3887 0 : bFormWasLoaded = true;
3888 0 : xForm->unload();
3889 : }
3890 : }
3891 : }
3892 0 : catch( const Exception& )
3893 : {
3894 : DBG_UNHANDLED_EXCEPTION();
3895 : }
3896 :
3897 : // reset the form if it was loaded
3898 26 : if ( bFormWasLoaded )
3899 : {
3900 0 : Reference< XIndexAccess > xContainer( xForm, UNO_QUERY );
3901 : DBG_ASSERT( xContainer.is(), "FmXFormShell::loadForms: the form is no container!" );
3902 0 : if ( xContainer.is() )
3903 0 : smartControlReset( xContainer );
3904 : }
3905 109 : }
3906 : }
3907 :
3908 109 : if ( pModel )
3909 : // unlock the environment
3910 109 : pModel->GetUndoEnv().UnLock();
3911 : }
3912 : }
3913 :
3914 :
3915 0 : void FmXFormShell::ExecuteTextAttribute( SfxRequest& _rReq )
3916 : {
3917 0 : m_pTextShell->ExecuteTextAttribute( _rReq );
3918 0 : }
3919 :
3920 :
3921 859 : void FmXFormShell::GetTextAttributeState( SfxItemSet& _rSet )
3922 : {
3923 859 : m_pTextShell->GetTextAttributeState( _rSet );
3924 859 : }
3925 :
3926 :
3927 15965 : bool FmXFormShell::IsActiveControl( bool _bCountRichTextOnly ) const
3928 : {
3929 15965 : return m_pTextShell->IsActiveControl( _bCountRichTextOnly );
3930 : }
3931 :
3932 :
3933 502 : void FmXFormShell::ForgetActiveControl()
3934 : {
3935 502 : m_pTextShell->ForgetActiveControl();
3936 502 : }
3937 :
3938 :
3939 3366 : void FmXFormShell::SetControlActivationHandler( const Link<>& _rHdl )
3940 : {
3941 3366 : m_pTextShell->SetControlActivationHandler( _rHdl );
3942 3366 : }
3943 :
3944 0 : void FmXFormShell::handleShowPropertiesRequest()
3945 : {
3946 0 : if ( onlyControlsAreMarked() )
3947 0 : ShowSelectionProperties( true );
3948 0 : }
3949 :
3950 :
3951 3 : void FmXFormShell::handleMouseButtonDown( const SdrViewEvent& _rViewEvent )
3952 : {
3953 : // catch simple double clicks
3954 3 : if ( ( _rViewEvent.nMouseClicks == 2 ) && ( _rViewEvent.nMouseCode == MOUSE_LEFT ) )
3955 : {
3956 0 : if ( _rViewEvent.eHit == SDRHIT_MARKEDOBJECT )
3957 : {
3958 0 : if ( onlyControlsAreMarked() )
3959 0 : ShowSelectionProperties( true );
3960 : }
3961 : }
3962 3 : }
3963 :
3964 :
3965 0 : bool FmXFormShell::HasControlFocus() const
3966 : {
3967 0 : bool bHasControlFocus = false;
3968 :
3969 : try
3970 : {
3971 0 : Reference< runtime::XFormController > xController( getActiveController() );
3972 0 : Reference< XControl > xCurrentControl;
3973 0 : if ( xController.is() )
3974 0 : xCurrentControl.set( xController->getCurrentControl() );
3975 0 : if ( xCurrentControl.is() )
3976 : {
3977 0 : Reference< XWindow2 > xPeerWindow( xCurrentControl->getPeer(), UNO_QUERY_THROW );
3978 0 : bHasControlFocus = xPeerWindow->hasFocus();
3979 0 : }
3980 : }
3981 0 : catch( const Exception& )
3982 : {
3983 : DBG_UNHANDLED_EXCEPTION();
3984 : }
3985 :
3986 0 : return bHasControlFocus;
3987 : }
3988 :
3989 :
3990 :
3991 0 : SearchableControlIterator::SearchableControlIterator(Reference< XInterface> xStartingPoint)
3992 0 : :IndexAccessIterator(xStartingPoint)
3993 : {
3994 0 : }
3995 :
3996 :
3997 0 : bool SearchableControlIterator::ShouldHandleElement(const Reference< XInterface>& xElement)
3998 : {
3999 : // wenn das Ding eine ControlSource und einen BoundField-Property hat
4000 0 : Reference< XPropertySet> xProperties(xElement, UNO_QUERY);
4001 0 : if (::comphelper::hasProperty(FM_PROP_CONTROLSOURCE, xProperties) && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xProperties))
4002 : {
4003 : // und das BoundField gueltig ist
4004 0 : Reference< XPropertySet> xField;
4005 0 : xProperties->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
4006 0 : if (xField.is())
4007 : {
4008 : // nehmen wir's
4009 0 : m_sCurrentValue = ::comphelper::getString(xProperties->getPropertyValue(FM_PROP_CONTROLSOURCE));
4010 0 : return true;
4011 0 : }
4012 : }
4013 :
4014 : // wenn es ein Grid-Control ist
4015 0 : if (::comphelper::hasProperty(FM_PROP_CLASSID, xProperties))
4016 : {
4017 0 : Any aClassId( xProperties->getPropertyValue(FM_PROP_CLASSID) );
4018 0 : if (::comphelper::getINT16(aClassId) == FormComponentType::GRIDCONTROL)
4019 : {
4020 0 : m_sCurrentValue.clear();
4021 0 : return true;
4022 0 : }
4023 : }
4024 :
4025 0 : return false;
4026 : }
4027 :
4028 :
4029 0 : bool SearchableControlIterator::ShouldStepInto(const Reference< XInterface>& /*xContainer*/) const
4030 : {
4031 0 : return true;
4032 : }
4033 :
4034 :
4035 :
4036 :
4037 114 : SFX_IMPL_MENU_CONTROL(ControlConversionMenuController, SfxBoolItem);
4038 :
4039 :
4040 0 : ControlConversionMenuController::ControlConversionMenuController( sal_uInt16 _nId, Menu& _rMenu, SfxBindings& _rBindings )
4041 : :SfxMenuControl( _nId, _rBindings )
4042 : ,m_pMainMenu( &_rMenu )
4043 0 : ,m_pConversionMenu( NULL )
4044 : {
4045 0 : if ( _nId == SID_FM_CHANGECONTROLTYPE )
4046 : {
4047 0 : m_pConversionMenu = FmXFormShell::GetConversionMenu();
4048 0 : _rMenu.SetPopupMenu( _nId, m_pConversionMenu );
4049 :
4050 0 : for (sal_Int16 i=0; i<m_pConversionMenu->GetItemCount(); ++i)
4051 : {
4052 0 : _rBindings.Invalidate(m_pConversionMenu->GetItemId(i));
4053 0 : SfxStatusForwarder* pForwarder = new SfxStatusForwarder(m_pConversionMenu->GetItemId(i), *this);
4054 0 : m_aStatusForwarders.push_back(pForwarder);
4055 : }
4056 : }
4057 0 : }
4058 :
4059 :
4060 0 : ControlConversionMenuController::~ControlConversionMenuController()
4061 : {
4062 0 : m_pMainMenu->SetPopupMenu(SID_FM_CHANGECONTROLTYPE, NULL);
4063 0 : delete m_pConversionMenu;
4064 0 : }
4065 :
4066 :
4067 0 : void ControlConversionMenuController::StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState)
4068 : {
4069 0 : if (nSID == GetId())
4070 0 : SfxMenuControl::StateChanged(nSID, eState, pState);
4071 0 : else if (FmXFormShell::isControlConversionSlot(nSID))
4072 : {
4073 0 : if ((m_pConversionMenu->GetItemPos(nSID) != MENU_ITEM_NOTFOUND) && (eState == SfxItemState::DISABLED))
4074 : {
4075 0 : m_pConversionMenu->RemoveItem(m_pConversionMenu->GetItemPos(nSID));
4076 : }
4077 0 : else if ((m_pConversionMenu->GetItemPos(nSID) == MENU_ITEM_NOTFOUND) && (eState != SfxItemState::DISABLED))
4078 : {
4079 : // We can't simply re-insert the item because we have a clear order for all the our items.
4080 : // So first we have to determine the position of the item to insert.
4081 0 : boost::scoped_ptr<PopupMenu> pSource(FmXFormShell::GetConversionMenu());
4082 0 : sal_uInt16 nSourcePos = pSource->GetItemPos(nSID);
4083 : DBG_ASSERT(nSourcePos != MENU_ITEM_NOTFOUND, "ControlConversionMenuController::StateChanged : FmXFormShell supplied an invalid menu !");
4084 0 : sal_uInt16 nPrevInSource = nSourcePos;
4085 0 : sal_uInt16 nPrevInConversion = MENU_ITEM_NOTFOUND;
4086 0 : while (nPrevInSource>0)
4087 : {
4088 0 : sal_Int16 nPrevId = pSource->GetItemId(--nPrevInSource);
4089 :
4090 : // do we have the source's predecessor in our conversion menu, too ?
4091 0 : nPrevInConversion = m_pConversionMenu->GetItemPos(nPrevId);
4092 0 : if (nPrevInConversion != MENU_ITEM_NOTFOUND)
4093 0 : break;
4094 : }
4095 0 : if (MENU_ITEM_NOTFOUND == nPrevInConversion)
4096 : // none of the items which precede the nSID-slot in the source menu are present in our conversion menu
4097 0 : nPrevInConversion = sal::static_int_cast< sal_uInt16 >(-1); // put the item at the first position
4098 0 : m_pConversionMenu->InsertItem(nSID, pSource->GetItemText(nSID),
4099 0 : pSource->GetItemBits(nSID), OString(), ++nPrevInConversion);
4100 0 : m_pConversionMenu->SetItemImage(nSID, pSource->GetItemImage(nSID));
4101 0 : m_pConversionMenu->SetHelpId(nSID, pSource->GetHelpId(nSID));
4102 : }
4103 0 : m_pMainMenu->EnableItem(SID_FM_CHANGECONTROLTYPE, m_pConversionMenu->GetItemCount() > 0);
4104 : }
4105 : else
4106 : {
4107 : OSL_FAIL("ControlConversionMenuController::StateChanged : unknown id !");
4108 : }
4109 435 : }
4110 :
4111 :
4112 :
4113 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|