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