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