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