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_dbaccess.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #ifndef DBACCESS_SBA_GRID_HRC 32*cdf0e10cSrcweir #include "sbagrid.hrc" 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC 36*cdf0e10cSrcweir #include <svx/svxids.hrc> 37*cdf0e10cSrcweir #endif 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #define ITEMID_HORJUSTIFY SID_ATTR_ALIGN_HOR_JUSTIFY 40*cdf0e10cSrcweir #define ITEMID_VERJUSTIFY SID_ATTR_ALIGN_VER_JUSTIFY 41*cdf0e10cSrcweir //#define ITEMID_ORIENTATION SID_ATTR_ALIGN_ORIENTATION 42*cdf0e10cSrcweir #define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK 43*cdf0e10cSrcweir #define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN 44*cdf0e10cSrcweir #define ITEMID_NUMBERINFO SID_ATTR_NUMBERFORMAT_INFO 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #define _ZFORLIST_DECLARE_TABLE 48*cdf0e10cSrcweir #ifndef _SVX_NUMINF_HXX 49*cdf0e10cSrcweir #include <svx/numinf.hxx> 50*cdf0e10cSrcweir #endif 51*cdf0e10cSrcweir #ifndef _SVX_DBAEXCHANGE_HXX_ 52*cdf0e10cSrcweir #include <svx/dbaexchange.hxx> 53*cdf0e10cSrcweir #endif 54*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_ 55*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 56*cdf0e10cSrcweir #endif 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir #ifndef _SBA_GRID_HXX 59*cdf0e10cSrcweir #include "sbagrid.hxx" 60*cdf0e10cSrcweir #endif 61*cdf0e10cSrcweir #ifndef DBAUI_SBATTRDLG_HXX 62*cdf0e10cSrcweir #include "dlgattr.hxx" 63*cdf0e10cSrcweir #endif 64*cdf0e10cSrcweir #ifndef _DBAUI_DLGSIZE_HXX 65*cdf0e10cSrcweir #include "dlgsize.hxx" 66*cdf0e10cSrcweir #endif 67*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_ 68*cdf0e10cSrcweir #include <com/sun/star/form/XLoadable.hpp> 69*cdf0e10cSrcweir #endif 70*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ 71*cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp> 72*cdf0e10cSrcweir #endif 73*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_ 74*cdf0e10cSrcweir #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp> 75*cdf0e10cSrcweir #endif 76*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XRESULTSETACCESS_HPP_ 77*cdf0e10cSrcweir #include <com/sun/star/sdb/XResultSetAccess.hpp> 78*cdf0e10cSrcweir #endif 79*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FORM_XFORM_HPP_ 80*cdf0e10cSrcweir #include <com/sun/star/form/XForm.hpp> 81*cdf0e10cSrcweir #endif 82*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_ 83*cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp> 84*cdf0e10cSrcweir #endif 85*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_ 86*cdf0e10cSrcweir #include <com/sun/star/util/NumberFormat.hpp> 87*cdf0e10cSrcweir #endif 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_VIEW_XSELECTIONSUPPLIER_HPP_ 90*cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp> 91*cdf0e10cSrcweir #endif 92*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FORM_DATASELECTIONTYPE_HPP_ 93*cdf0e10cSrcweir #include <com/sun/star/form/DataSelectionType.hpp> 94*cdf0e10cSrcweir #endif 95*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_ 96*cdf0e10cSrcweir #include <com/sun/star/awt/TextAlign.hpp> 97*cdf0e10cSrcweir #endif 98*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_XTEXTCOMPONENT_HPP_ 99*cdf0e10cSrcweir #include <com/sun/star/awt/XTextComponent.hpp> 100*cdf0e10cSrcweir #endif 101*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_DATE_HPP_ 102*cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp> 103*cdf0e10cSrcweir #endif 104*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_TIME_HPP_ 105*cdf0e10cSrcweir #include <com/sun/star/util/Time.hpp> 106*cdf0e10cSrcweir #endif 107*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_ 108*cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp> 109*cdf0e10cSrcweir #endif 110*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XRESULTSETUPDATE_HPP_ 111*cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetUpdate.hpp> 112*cdf0e10cSrcweir #endif 113*cdf0e10cSrcweir #ifndef _URLOBJ_HXX 114*cdf0e10cSrcweir #include <tools/urlobj.hxx> 115*cdf0e10cSrcweir #endif 116*cdf0e10cSrcweir #ifndef TOOLS_DIAGNOSE_EX_H 117*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 118*cdf0e10cSrcweir #endif 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir #ifndef _SFXINTITEM_HXX 121*cdf0e10cSrcweir #include <svl/intitem.hxx> 122*cdf0e10cSrcweir #endif 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir #ifndef _SVX_ALGITEM_HXX //autogen 125*cdf0e10cSrcweir #include <svx/algitem.hxx> 126*cdf0e10cSrcweir #endif 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir #ifndef _SV_MULTISEL_HXX //autogen 129*cdf0e10cSrcweir #include <tools/multisel.hxx> 130*cdf0e10cSrcweir #endif 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC 133*cdf0e10cSrcweir #include <svx/svxids.hrc> 134*cdf0e10cSrcweir #endif 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir #ifndef _NUMUNO_HXX 137*cdf0e10cSrcweir #include <svl/numuno.hxx> 138*cdf0e10cSrcweir #endif 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir #ifndef _SFXITEMPOOL_HXX //autogen wg. SfxItemInfo 141*cdf0e10cSrcweir #include <svl/itempool.hxx> 142*cdf0e10cSrcweir #endif 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir #ifndef _SFXITEMSET_HXX //autogen wg. SfxItemSet 145*cdf0e10cSrcweir #include <svl/itemset.hxx> 146*cdf0e10cSrcweir #endif 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir #ifndef _SFXRNGITEM_HXX 149*cdf0e10cSrcweir #include <svl/rngitem.hxx> 150*cdf0e10cSrcweir #endif 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir #ifndef _SV_WAITOBJ_HXX 153*cdf0e10cSrcweir #include <vcl/waitobj.hxx> 154*cdf0e10cSrcweir #endif 155*cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 156*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 157*cdf0e10cSrcweir #endif 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir #ifndef _ZFORLIST_HXX 160*cdf0e10cSrcweir #include <svl/zforlist.hxx> 161*cdf0e10cSrcweir #endif 162*cdf0e10cSrcweir #ifndef _CPPUHELPER_QUERYINTERFACE_HXX_ 163*cdf0e10cSrcweir #include <cppuhelper/queryinterface.hxx> 164*cdf0e10cSrcweir #endif 165*cdf0e10cSrcweir #ifndef _CONNECTIVITY_DBTOOLS_HXX_ 166*cdf0e10cSrcweir #include <connectivity/dbtools.hxx> 167*cdf0e10cSrcweir #endif 168*cdf0e10cSrcweir #ifndef _DBHELPER_DBCONVERSION_HXX_ 169*cdf0e10cSrcweir #include <connectivity/dbconversion.hxx> 170*cdf0e10cSrcweir #endif 171*cdf0e10cSrcweir #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ 172*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 173*cdf0e10cSrcweir #endif 174*cdf0e10cSrcweir #ifndef _RTL_UUID_H_ 175*cdf0e10cSrcweir #include <rtl/uuid.h> 176*cdf0e10cSrcweir #endif 177*cdf0e10cSrcweir #ifndef _RTL_MEMORY_H_ 178*cdf0e10cSrcweir #include <rtl/memory.h> 179*cdf0e10cSrcweir #endif 180*cdf0e10cSrcweir #ifndef _COMPHELPER_EXTRACT_HXX_ 181*cdf0e10cSrcweir #include <comphelper/extract.hxx> 182*cdf0e10cSrcweir #endif 183*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ 184*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp> 185*cdf0e10cSrcweir #endif 186*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ 187*cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp> 188*cdf0e10cSrcweir #endif 189*cdf0e10cSrcweir #ifndef _SV_MSGBOX_HXX 190*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 191*cdf0e10cSrcweir #endif 192*cdf0e10cSrcweir #ifndef _SVX_DBEXCH_HRC 193*cdf0e10cSrcweir #include <svx/dbexch.hrc> 194*cdf0e10cSrcweir #endif 195*cdf0e10cSrcweir #ifndef _DBU_BRW_HRC_ 196*cdf0e10cSrcweir #include "dbu_brw.hrc" 197*cdf0e10cSrcweir #endif 198*cdf0e10cSrcweir #ifndef DBACCESS_UI_BROWSER_ID_HXX 199*cdf0e10cSrcweir #include "browserids.hxx" 200*cdf0e10cSrcweir #endif 201*cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC 202*cdf0e10cSrcweir #include "dbustrings.hrc" 203*cdf0e10cSrcweir #endif 204*cdf0e10cSrcweir #ifndef _DBU_REGHELPER_HXX_ 205*cdf0e10cSrcweir #include "dbu_reghelper.hxx" 206*cdf0e10cSrcweir #endif 207*cdf0e10cSrcweir #ifndef DBAUI_DBEXCHANGE_HXX 208*cdf0e10cSrcweir #include "dbexchange.hxx" 209*cdf0e10cSrcweir #endif 210*cdf0e10cSrcweir #ifndef DBAUI_TABLEROW_EXCHANGE_HXX 211*cdf0e10cSrcweir #include "TableRowExchange.hxx" 212*cdf0e10cSrcweir #endif 213*cdf0e10cSrcweir #ifndef DBAUI_TABLEROW_HXX 214*cdf0e10cSrcweir #include "TableRow.hxx" 215*cdf0e10cSrcweir #endif 216*cdf0e10cSrcweir #ifndef DBAUI_FIELDDESCRIPTIONS_HXX 217*cdf0e10cSrcweir #include "FieldDescriptions.hxx" 218*cdf0e10cSrcweir #endif 219*cdf0e10cSrcweir #ifndef _SVTOOLS_STRINGTRANSFER_HXX_ 220*cdf0e10cSrcweir #include <svtools/stringtransfer.hxx> 221*cdf0e10cSrcweir #endif 222*cdf0e10cSrcweir #ifndef _VCL_STDTEXT_HXX 223*cdf0e10cSrcweir #include <vcl/stdtext.hxx> 224*cdf0e10cSrcweir #endif 225*cdf0e10cSrcweir #ifndef DBAUI_TOOLS_HXX 226*cdf0e10cSrcweir #include "UITools.hxx" 227*cdf0e10cSrcweir #endif 228*cdf0e10cSrcweir #ifndef DBAUI_TOKENWRITER_HXX 229*cdf0e10cSrcweir #include "TokenWriter.hxx" 230*cdf0e10cSrcweir #endif 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs; 233*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 234*cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 235*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 236*cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 237*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 238*cdf0e10cSrcweir using namespace ::com::sun::star::container; 239*cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer; 240*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 241*cdf0e10cSrcweir using namespace ::com::sun::star::view; 242*cdf0e10cSrcweir using namespace ::com::sun::star::form; 243*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 244*cdf0e10cSrcweir using namespace ::com::sun::star::util; 245*cdf0e10cSrcweir using namespace ::dbaui; 246*cdf0e10cSrcweir using namespace ::dbtools; 247*cdf0e10cSrcweir using namespace ::svx; 248*cdf0e10cSrcweir using namespace ::svt; 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_SbaXGridControl() 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir static OMultiInstanceAutoRegistration< SbaXGridControl > aAutoRegistration; 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir //------------------------------------------------------------------------- 255*cdf0e10cSrcweir ::comphelper::StringSequence SAL_CALL SbaXGridControl::getSupportedServiceNames() throw() 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir return getSupportedServiceNames_Static(); 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir // ------------------------------------------------------------------------- 260*cdf0e10cSrcweir Reference< XInterface > SAL_CALL SbaXGridControl::Create(const Reference<XMultiServiceFactory >& _rxFactory) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir return *(new SbaXGridControl(_rxFactory)); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir //------------------------------------------------------------------ 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir //------------------------------------------------------------------ 268*cdf0e10cSrcweir //======================================================================================= 269*cdf0e10cSrcweir // SbaXGridControl 270*cdf0e10cSrcweir //======================================================================================= 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir //------------------------------------------------------------------------------ 273*cdf0e10cSrcweir ::rtl::OUString SAL_CALL SbaXGridControl::getImplementationName() throw() 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir return getImplementationName_Static(); 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir //------------------------------------------------------------------------------ 279*cdf0e10cSrcweir ::rtl::OUString SbaXGridControl::getImplementationName_Static() throw( RuntimeException ) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii("com.sun.star.comp.dbu.SbaXGridControl"); 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir //------------------------------------------------------------------------------ 285*cdf0e10cSrcweir Sequence< ::rtl::OUString> SbaXGridControl::getSupportedServiceNames_Static(void) throw( RuntimeException ) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir Sequence< ::rtl::OUString> aSupported(3); 288*cdf0e10cSrcweir aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.form.control.InteractionGridControl"); 289*cdf0e10cSrcweir aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.form.control.GridControl"); 290*cdf0e10cSrcweir aSupported[2] = ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControl"); 291*cdf0e10cSrcweir return aSupported; 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir DBG_NAME(SbaXGridControl ); 294*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 295*cdf0e10cSrcweir SbaXGridControl::SbaXGridControl(const Reference< XMultiServiceFactory >& _rM) 296*cdf0e10cSrcweir : FmXGridControl(_rM) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir DBG_CTOR(SbaXGridControl ,NULL); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 302*cdf0e10cSrcweir SbaXGridControl::~SbaXGridControl() 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir DBG_DTOR(SbaXGridControl ,NULL); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 308*cdf0e10cSrcweir FmXGridPeer* SbaXGridControl::imp_CreatePeer(Window* pParent) 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir FmXGridPeer* pReturn = new SbaXGridPeer(m_xServiceFactory); 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir // translate properties into WinBits 313*cdf0e10cSrcweir WinBits nStyle = WB_TABSTOP; 314*cdf0e10cSrcweir Reference< XPropertySet > xModelSet(getModel(), UNO_QUERY); 315*cdf0e10cSrcweir if (xModelSet.is()) 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir try 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir if (::comphelper::getINT16(xModelSet->getPropertyValue(PROPERTY_BORDER))) 320*cdf0e10cSrcweir nStyle |= WB_BORDER; 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir catch(Exception&) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir pReturn->Create(pParent, nStyle); 329*cdf0e10cSrcweir return pReturn; 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir //------------------------------------------------------------------------------ 333*cdf0e10cSrcweir Any SAL_CALL SbaXGridControl::queryInterface(const Type& _rType) throw (RuntimeException) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir Any aRet = FmXGridControl::queryInterface(_rType); 336*cdf0e10cSrcweir return aRet.hasValue() ? aRet : ::cppu::queryInterface(_rType,(::com::sun::star::frame::XDispatch*)this); 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir //------------------------------------------------------------------------------ 340*cdf0e10cSrcweir Sequence< Type > SAL_CALL SbaXGridControl::getTypes( ) throw (RuntimeException) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir Sequence< Type > aTypes = FmXGridControl::getTypes(); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir sal_Int32 nTypes = aTypes.getLength(); 345*cdf0e10cSrcweir aTypes.realloc(nTypes + 1); 346*cdf0e10cSrcweir aTypes[nTypes] = ::getCppuType(static_cast< Reference< ::com::sun::star::frame::XDispatch >* >(NULL)); 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir return aTypes; 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir //------------------------------------------------------------------------------ 352*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL SbaXGridControl::getImplementationId( ) throw (RuntimeException) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir static ::cppu::OImplementationId * pId = 0; 355*cdf0e10cSrcweir if (! pId) 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 358*cdf0e10cSrcweir if (! pId) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir static ::cppu::OImplementationId aId; 361*cdf0e10cSrcweir pId = &aId; 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir return pId->getImplementationId(); 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 368*cdf0e10cSrcweir void SAL_CALL SbaXGridControl::createPeer(const Reference< ::com::sun::star::awt::XToolkit > & rToolkit, const Reference< ::com::sun::star::awt::XWindowPeer > & rParentPeer) throw( RuntimeException ) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir FmXGridControl::createPeer(rToolkit, rParentPeer); 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir DBG_ASSERT(/*(0 == m_nPeerCreationLevel) && */!mbCreatingPeer, "FmXGridControl::createPeer : recursion!"); 373*cdf0e10cSrcweir // see the base class' createPeer for a comment on this 374*cdf0e10cSrcweir // 14.05.2001 - 86836 - frank.schoenheit@germany.sun.com 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir // TODO: why the hell this whole class does not use any mutex? 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir // if (0 == m_nPeerCreationLevel) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir Reference< ::com::sun::star::frame::XDispatch > xDisp(getPeer(), UNO_QUERY); 381*cdf0e10cSrcweir for ( StatusMultiplexerArray::iterator aIter = m_aStatusMultiplexer.begin(); 382*cdf0e10cSrcweir aIter != m_aStatusMultiplexer.end(); 383*cdf0e10cSrcweir ++aIter) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir if ((*aIter).second && (*aIter).second->getLength()) 386*cdf0e10cSrcweir xDisp->addStatusListener((*aIter).second, (*aIter).first); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 392*cdf0e10cSrcweir void SAL_CALL SbaXGridControl::dispatch(const ::com::sun::star::util::URL& aURL, const Sequence< PropertyValue >& aArgs) throw( RuntimeException ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir Reference< ::com::sun::star::frame::XDispatch > xDisp(getPeer(), UNO_QUERY); 395*cdf0e10cSrcweir if (xDisp.is()) 396*cdf0e10cSrcweir xDisp->dispatch(aURL, aArgs); 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 399*cdf0e10cSrcweir void SAL_CALL SbaXGridControl::addStatusListener( const Reference< XStatusListener > & _rxListener, const URL& _rURL ) throw( RuntimeException ) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir ::osl::MutexGuard aGuard( GetMutex() ); 402*cdf0e10cSrcweir if ( _rxListener.is() ) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir SbaXStatusMultiplexer*& pMultiplexer = m_aStatusMultiplexer[ _rURL ]; 405*cdf0e10cSrcweir if ( !pMultiplexer ) 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir pMultiplexer = new SbaXStatusMultiplexer( *this, GetMutex() ); 408*cdf0e10cSrcweir pMultiplexer->acquire(); 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir pMultiplexer->addInterface( _rxListener ); 412*cdf0e10cSrcweir if ( getPeer().is() ) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir if ( 1 == pMultiplexer->getLength() ) 415*cdf0e10cSrcweir { // the first external listener for this URL 416*cdf0e10cSrcweir Reference< XDispatch > xDisp( getPeer(), UNO_QUERY ); 417*cdf0e10cSrcweir xDisp->addStatusListener( pMultiplexer, _rURL ); 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir else 420*cdf0e10cSrcweir { // already have other listeners for this URL 421*cdf0e10cSrcweir _rxListener->statusChanged( pMultiplexer->getLastEvent() ); 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir } 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 428*cdf0e10cSrcweir void SAL_CALL SbaXGridControl::removeStatusListener(const Reference< ::com::sun::star::frame::XStatusListener > & _rxListener, const ::com::sun::star::util::URL& _rURL) throw( RuntimeException ) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir ::osl::MutexGuard aGuard( GetMutex() ); 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir SbaXStatusMultiplexer*& pMultiplexer = m_aStatusMultiplexer[_rURL]; 433*cdf0e10cSrcweir if (!pMultiplexer) 434*cdf0e10cSrcweir { 435*cdf0e10cSrcweir pMultiplexer = new SbaXStatusMultiplexer(*this,GetMutex()); 436*cdf0e10cSrcweir pMultiplexer->acquire(); 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir if (getPeer().is() && pMultiplexer->getLength() == 1) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir Reference< ::com::sun::star::frame::XDispatch > xDisp(getPeer(), UNO_QUERY); 442*cdf0e10cSrcweir xDisp->removeStatusListener(pMultiplexer, _rURL); 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir pMultiplexer->removeInterface( _rxListener ); 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 448*cdf0e10cSrcweir void SAL_CALL SbaXGridControl::dispose(void) throw( RuntimeException ) 449*cdf0e10cSrcweir { 450*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir EventObject aEvt; 453*cdf0e10cSrcweir aEvt.Source = *this; 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir for ( StatusMultiplexerArray::iterator aIter = m_aStatusMultiplexer.begin(); 456*cdf0e10cSrcweir aIter != m_aStatusMultiplexer.end(); 457*cdf0e10cSrcweir ++aIter) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir if ((*aIter).second) 460*cdf0e10cSrcweir { 461*cdf0e10cSrcweir (*aIter).second->disposeAndClear(aEvt); 462*cdf0e10cSrcweir (*aIter).second->release(); 463*cdf0e10cSrcweir (*aIter).second = NULL; 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir StatusMultiplexerArray().swap(m_aStatusMultiplexer); 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir FmXGridControl::dispose(); 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir //======================================================================================= 472*cdf0e10cSrcweir // SbaXGridPeer 473*cdf0e10cSrcweir //======================================================================================= 474*cdf0e10cSrcweir DBG_NAME(SbaXGridPeer ) 475*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 476*cdf0e10cSrcweir SbaXGridPeer::SbaXGridPeer(const Reference< XMultiServiceFactory >& _rM) 477*cdf0e10cSrcweir : FmXGridPeer(_rM) 478*cdf0e10cSrcweir ,m_aStatusListeners(m_aMutex) 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir DBG_CTOR(SbaXGridPeer ,NULL); 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 484*cdf0e10cSrcweir SbaXGridPeer::~SbaXGridPeer() 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir DBG_DTOR(SbaXGridPeer ,NULL); 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 490*cdf0e10cSrcweir void SAL_CALL SbaXGridPeer::dispose(void) throw( RuntimeException ) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir EventObject aEvt(*this); 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir m_aStatusListeners.disposeAndClear(aEvt); 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir FmXGridPeer::dispose(); 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 500*cdf0e10cSrcweir void SbaXGridPeer::NotifyStatusChanged(const ::com::sun::star::util::URL& _rUrl, const Reference< ::com::sun::star::frame::XStatusListener > & xControl) 501*cdf0e10cSrcweir { 502*cdf0e10cSrcweir SbaGridControl* pGrid = (SbaGridControl*) GetWindow(); 503*cdf0e10cSrcweir if (!pGrid) 504*cdf0e10cSrcweir return; 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir ::com::sun::star::frame::FeatureStateEvent aEvt; 507*cdf0e10cSrcweir aEvt.Source = *this; 508*cdf0e10cSrcweir aEvt.IsEnabled = !pGrid->IsReadOnlyDB(); 509*cdf0e10cSrcweir aEvt.FeatureURL = _rUrl; 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir ConstMapDispatchToBoolIterator aURLStatePos = m_aDispatchStates.find( classifyDispatchURL( _rUrl ) ); 512*cdf0e10cSrcweir if ( m_aDispatchStates.end() != aURLStatePos ) 513*cdf0e10cSrcweir aEvt.State <<= aURLStatePos->second; 514*cdf0e10cSrcweir else 515*cdf0e10cSrcweir aEvt.State <<= sal_False; 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir if (xControl.is()) 518*cdf0e10cSrcweir xControl->statusChanged(aEvt); 519*cdf0e10cSrcweir else 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper * pIter = m_aStatusListeners.getContainer(_rUrl); 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir if (pIter) 524*cdf0e10cSrcweir { 525*cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper aListIter(*pIter); 526*cdf0e10cSrcweir while (aListIter.hasMoreElements()) 527*cdf0e10cSrcweir ((::com::sun::star::frame::XStatusListener*)aListIter.next())->statusChanged(aEvt); 528*cdf0e10cSrcweir } 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir //------------------------------------------------------------------------------ 533*cdf0e10cSrcweir Any SAL_CALL SbaXGridPeer::queryInterface(const Type& _rType) throw (RuntimeException) 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir Any aRet = ::cppu::queryInterface(_rType,(::com::sun::star::frame::XDispatch*)this); 536*cdf0e10cSrcweir if(aRet.hasValue()) 537*cdf0e10cSrcweir return aRet; 538*cdf0e10cSrcweir return FmXGridPeer::queryInterface(_rType); 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 542*cdf0e10cSrcweir Reference< ::com::sun::star::frame::XDispatch > SAL_CALL SbaXGridPeer::queryDispatch(const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( RuntimeException ) 543*cdf0e10cSrcweir { 544*cdf0e10cSrcweir if ( (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:GridSlots/BrowserAttribs"))) 545*cdf0e10cSrcweir || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:GridSlots/RowHeight"))) 546*cdf0e10cSrcweir || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:GridSlots/ColumnAttribs"))) 547*cdf0e10cSrcweir || (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:GridSlots/ColumnWidth"))) 548*cdf0e10cSrcweir ) 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir return (::com::sun::star::frame::XDispatch*)this; 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir return FmXGridPeer::queryDispatch(aURL, aTargetFrameName, nSearchFlags); 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 557*cdf0e10cSrcweir IMPL_LINK( SbaXGridPeer, OnDispatchEvent, void*, /*NOTINTERESTEDIN*/ ) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir SbaGridControl* pGrid = static_cast< SbaGridControl* >( GetWindow() ); 560*cdf0e10cSrcweir if ( pGrid ) // if this fails, we were disposing before arriving here 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir if ( Application::GetMainThreadIdentifier() != ::vos::OThread::getCurrentIdentifier() ) 563*cdf0e10cSrcweir { 564*cdf0e10cSrcweir // still not in the main thread (see SbaXGridPeer::dispatch). post an event, again 565*cdf0e10cSrcweir // without moving the special even to the back of the queue 566*cdf0e10cSrcweir pGrid->PostUserEvent( LINK( this, SbaXGridPeer, OnDispatchEvent ) ); 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir else 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir DispatchArgs aArgs = m_aDispatchArgs.front(); 571*cdf0e10cSrcweir m_aDispatchArgs.pop(); 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir SbaXGridPeer::dispatch( aArgs.aURL, aArgs.aArgs ); 574*cdf0e10cSrcweir } 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir return 0; 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 581*cdf0e10cSrcweir SbaXGridPeer::DispatchType SbaXGridPeer::classifyDispatchURL( const URL& _rURL ) 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir DispatchType eURLType = dtUnknown; 584*cdf0e10cSrcweir if ( _rURL.Complete.equalsAscii( ".uno:GridSlots/BrowserAttribs" ) ) 585*cdf0e10cSrcweir eURLType = dtBrowserAttribs; 586*cdf0e10cSrcweir else if ( _rURL.Complete.equalsAscii( ".uno:GridSlots/RowHeight" ) ) 587*cdf0e10cSrcweir eURLType = dtRowHeight; 588*cdf0e10cSrcweir else if ( _rURL.Complete.equalsAscii( ".uno:GridSlots/ColumnAttribs" ) ) 589*cdf0e10cSrcweir eURLType = dtColumnAttribs; 590*cdf0e10cSrcweir else if ( _rURL.Complete.equalsAscii( ".uno:GridSlots/ColumnWidth" ) ) 591*cdf0e10cSrcweir eURLType = dtColumnWidth; 592*cdf0e10cSrcweir return eURLType; 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 596*cdf0e10cSrcweir void SAL_CALL SbaXGridPeer::dispatch(const URL& aURL, const Sequence< PropertyValue >& aArgs) throw( RuntimeException ) 597*cdf0e10cSrcweir { 598*cdf0e10cSrcweir SbaGridControl* pGrid = (SbaGridControl*)GetWindow(); 599*cdf0e10cSrcweir if (!pGrid) 600*cdf0e10cSrcweir return; 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir if ( Application::GetMainThreadIdentifier() != ::vos::OThread::getCurrentIdentifier() ) 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir // we're not in the main thread. This is bad, as we want to raise windows here, 605*cdf0e10cSrcweir // and VCL does not like windows to be opened in non-main threads (at least on Win32). 606*cdf0e10cSrcweir // Okay, do this async. No problem with this, as XDispatch::dispatch is defined to be 607*cdf0e10cSrcweir // a one-way method. 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir // save the args 610*cdf0e10cSrcweir DispatchArgs aDispatchArgs; 611*cdf0e10cSrcweir aDispatchArgs.aURL = aURL; 612*cdf0e10cSrcweir aDispatchArgs.aArgs = aArgs; 613*cdf0e10cSrcweir m_aDispatchArgs.push( aDispatchArgs ); 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir // post an event 616*cdf0e10cSrcweir // we use the Window::PostUserEvent here, instead of the application::PostUserEvent 617*cdf0e10cSrcweir // this saves us from keeping track of these events - as soon as the window dies, 618*cdf0e10cSrcweir // the events are deleted automatically. For the application way, we would need to 619*cdf0e10cSrcweir // do this ourself. 620*cdf0e10cSrcweir // As we use our grid as window, and the grid dies before we dy, this should be no problem. 621*cdf0e10cSrcweir pGrid->PostUserEvent( LINK( this, SbaXGridPeer, OnDispatchEvent ) ); 622*cdf0e10cSrcweir return; 623*cdf0e10cSrcweir } 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir ::vos::OGuard aGuard(Application::GetSolarMutex()); 626*cdf0e10cSrcweir sal_Int16 nColId = -1; 627*cdf0e10cSrcweir const PropertyValue* pArgs = aArgs.getConstArray(); 628*cdf0e10cSrcweir for (sal_uInt16 i=0; i<aArgs.getLength(); ++i, ++pArgs) 629*cdf0e10cSrcweir { 630*cdf0e10cSrcweir if (pArgs->Name == ::rtl::OUString::createFromAscii("ColumnViewPos")) 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir nColId = pGrid->GetColumnIdFromViewPos(::comphelper::getINT16(pArgs->Value)); 633*cdf0e10cSrcweir break; 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir if (pArgs->Name == ::rtl::OUString::createFromAscii("ColumnModelPos")) 636*cdf0e10cSrcweir { 637*cdf0e10cSrcweir nColId = pGrid->GetColumnIdFromModelPos(::comphelper::getINT16(pArgs->Value)); 638*cdf0e10cSrcweir break; 639*cdf0e10cSrcweir } 640*cdf0e10cSrcweir if (pArgs->Name == ::rtl::OUString::createFromAscii("ColumnId")) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir nColId = ::comphelper::getINT16(pArgs->Value); 643*cdf0e10cSrcweir break; 644*cdf0e10cSrcweir } 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir DispatchType eURLType = classifyDispatchURL( aURL ); 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir if ( dtUnknown != eURLType ) 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir // notify any status listeners that the dialog is now active (well, about to be active) 652*cdf0e10cSrcweir MapDispatchToBool::iterator aThisURLState = m_aDispatchStates.insert( MapDispatchToBool::value_type( eURLType, sal_True ) ).first; 653*cdf0e10cSrcweir NotifyStatusChanged( aURL, NULL ); 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir // execute the dialog 656*cdf0e10cSrcweir switch ( eURLType ) 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir case dtBrowserAttribs: 659*cdf0e10cSrcweir pGrid->SetBrowserAttrs(); 660*cdf0e10cSrcweir break; 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir case dtRowHeight: 663*cdf0e10cSrcweir pGrid->SetRowHeight(); 664*cdf0e10cSrcweir break; 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir case dtColumnAttribs: 667*cdf0e10cSrcweir { 668*cdf0e10cSrcweir DBG_ASSERT(nColId != -1, "SbaXGridPeer::dispatch : invalid parameter !"); 669*cdf0e10cSrcweir if (nColId != -1) 670*cdf0e10cSrcweir break; 671*cdf0e10cSrcweir pGrid->SetColAttrs(nColId); 672*cdf0e10cSrcweir } 673*cdf0e10cSrcweir break; 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir case dtColumnWidth: 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir DBG_ASSERT(nColId != -1, "SbaXGridPeer::dispatch : invalid parameter !"); 678*cdf0e10cSrcweir if (nColId != -1) 679*cdf0e10cSrcweir break; 680*cdf0e10cSrcweir pGrid->SetColWidth(nColId); 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir break; 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir case dtUnknown: 685*cdf0e10cSrcweir break; 686*cdf0e10cSrcweir } 687*cdf0e10cSrcweir 688*cdf0e10cSrcweir // notify any status listeners that the dialog vanished 689*cdf0e10cSrcweir m_aDispatchStates.erase( aThisURLState ); 690*cdf0e10cSrcweir NotifyStatusChanged( aURL, NULL ); 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir } 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 695*cdf0e10cSrcweir void SAL_CALL SbaXGridPeer::addStatusListener(const Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( RuntimeException ) 696*cdf0e10cSrcweir { 697*cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pCont = m_aStatusListeners.getContainer(aURL); 698*cdf0e10cSrcweir if (!pCont) 699*cdf0e10cSrcweir m_aStatusListeners.addInterface(aURL,xControl); 700*cdf0e10cSrcweir else 701*cdf0e10cSrcweir pCont->addInterface(xControl); 702*cdf0e10cSrcweir NotifyStatusChanged(aURL, xControl); 703*cdf0e10cSrcweir } 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 706*cdf0e10cSrcweir void SAL_CALL SbaXGridPeer::removeStatusListener(const Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( RuntimeException ) 707*cdf0e10cSrcweir { 708*cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pCont = m_aStatusListeners.getContainer(aURL); 709*cdf0e10cSrcweir if ( pCont ) 710*cdf0e10cSrcweir pCont->removeInterface(xControl); 711*cdf0e10cSrcweir } 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 714*cdf0e10cSrcweir const Sequence< sal_Int8 > & SbaXGridPeer::getUnoTunnelId() 715*cdf0e10cSrcweir { 716*cdf0e10cSrcweir static Sequence< sal_Int8 > * pSeq = 0; 717*cdf0e10cSrcweir if( !pSeq ) 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); 720*cdf0e10cSrcweir if( !pSeq ) 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir static Sequence< sal_Int8 > aSeq( 16 ); 723*cdf0e10cSrcweir rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0,sal_True ); 724*cdf0e10cSrcweir pSeq = &aSeq; 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir } 727*cdf0e10cSrcweir return *pSeq; 728*cdf0e10cSrcweir } 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 731*cdf0e10cSrcweir Sequence< Type > SAL_CALL SbaXGridPeer::getTypes() throw (RuntimeException) 732*cdf0e10cSrcweir { 733*cdf0e10cSrcweir Sequence< Type > aTypes = FmXGridPeer::getTypes(); 734*cdf0e10cSrcweir sal_Int32 nOldLen = aTypes.getLength(); 735*cdf0e10cSrcweir aTypes.realloc(nOldLen + 1); 736*cdf0e10cSrcweir aTypes.getArray()[nOldLen] = ::getCppuType( reinterpret_cast< Reference< ::com::sun::star::frame::XDispatch >* >(NULL) ); 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir return aTypes; 739*cdf0e10cSrcweir } 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir // return implementation specific data 742*cdf0e10cSrcweir //------------------------------------------------------------------ 743*cdf0e10cSrcweir sal_Int64 SAL_CALL SbaXGridPeer::getSomething( const Sequence< sal_Int8 > & rId ) throw(::com::sun::star::uno::RuntimeException) 744*cdf0e10cSrcweir { 745*cdf0e10cSrcweir if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) 746*cdf0e10cSrcweir return reinterpret_cast< sal_Int64 >( this ); 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir return FmXGridPeer::getSomething(rId); 749*cdf0e10cSrcweir } 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 752*cdf0e10cSrcweir SbaXGridPeer* SbaXGridPeer::getImplementation(const Reference< XInterface >& _rxIFace) 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir Reference< XUnoTunnel > xTunnel( 755*cdf0e10cSrcweir _rxIFace, UNO_QUERY); 756*cdf0e10cSrcweir if (xTunnel.is()) 757*cdf0e10cSrcweir return reinterpret_cast<SbaXGridPeer*>(xTunnel->getSomething(getUnoTunnelId())); 758*cdf0e10cSrcweir return NULL; 759*cdf0e10cSrcweir } 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 762*cdf0e10cSrcweir FmGridControl* SbaXGridPeer::imp_CreateControl(Window* pParent, WinBits nStyle) 763*cdf0e10cSrcweir { 764*cdf0e10cSrcweir return new SbaGridControl(m_xServiceFactory, pParent, this, nStyle); 765*cdf0e10cSrcweir } 766*cdf0e10cSrcweir 767*cdf0e10cSrcweir //================================================================== 768*cdf0e10cSrcweir // SbaGridHeader 769*cdf0e10cSrcweir //================================================================== 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 772*cdf0e10cSrcweir SbaGridHeader::SbaGridHeader(BrowseBox* pParent, WinBits nWinBits) 773*cdf0e10cSrcweir :FmGridHeader(pParent, nWinBits) 774*cdf0e10cSrcweir ,DragSourceHelper(this) 775*cdf0e10cSrcweir { 776*cdf0e10cSrcweir } 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 779*cdf0e10cSrcweir void SbaGridHeader::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) 780*cdf0e10cSrcweir { 781*cdf0e10cSrcweir ::vos::OGuard aGuard(Application::GetSolarMutex()); 782*cdf0e10cSrcweir // in the new DnD API, the solar mutex is not locked when StartDrag get's called 783*cdf0e10cSrcweir 784*cdf0e10cSrcweir ImplStartColumnDrag( _nAction, _rPosPixel ); 785*cdf0e10cSrcweir } 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 788*cdf0e10cSrcweir void SbaGridHeader::MouseButtonDown( const MouseEvent& _rMEvt ) 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir if (_rMEvt.IsLeft()) 791*cdf0e10cSrcweir if (_rMEvt.GetClicks() != 2) 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir // the base class will start a column move here, which we don't want to allow 794*cdf0e10cSrcweir // (at the moment. If we store relative positions with the columns, we can allow column moves ....) 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir // sal_uInt16 nPos(0); 797*cdf0e10cSrcweir // sal_uInt16 nHitTest = ImplHitTest( _rMEvt.GetPosPixel(), mnMouseOff, nPos ); 798*cdf0e10cSrcweir // if (!nHitTest & HEAD_HITTEST_DIVIDER) 799*cdf0e10cSrcweir // return; 800*cdf0e10cSrcweir } 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir FmGridHeader::MouseButtonDown(_rMEvt); 803*cdf0e10cSrcweir } 804*cdf0e10cSrcweir 805*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 806*cdf0e10cSrcweir sal_Bool SbaGridHeader::ImplStartColumnDrag(sal_Int8 _nAction, const Point& _rMousePos) 807*cdf0e10cSrcweir { 808*cdf0e10cSrcweir sal_uInt16 nId = GetItemId(_rMousePos); 809*cdf0e10cSrcweir sal_Bool bResizingCol = sal_False; 810*cdf0e10cSrcweir if (HEADERBAR_ITEM_NOTFOUND != nId) 811*cdf0e10cSrcweir { 812*cdf0e10cSrcweir Rectangle aColRect = GetItemRect(nId); 813*cdf0e10cSrcweir aColRect.Left() += nId ? 3 : 0; // the handle col (nId == 0) does not have a left margin for resizing 814*cdf0e10cSrcweir aColRect.Right() -= 3; 815*cdf0e10cSrcweir bResizingCol = !aColRect.IsInside(_rMousePos); 816*cdf0e10cSrcweir } 817*cdf0e10cSrcweir if (!bResizingCol) 818*cdf0e10cSrcweir { 819*cdf0e10cSrcweir // force the the base class to end it's drag mode 820*cdf0e10cSrcweir EndTracking(ENDTRACK_CANCEL | ENDTRACK_END); 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir // because we have 3d-buttons the select handler is called from MouseButtonUp, but StartDrag 823*cdf0e10cSrcweir // occures earlier (while the mouse button is down) 824*cdf0e10cSrcweir // so for optical reasons we select the column before really starting the drag operation. 825*cdf0e10cSrcweir notifyColumnSelect(nId); 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir static_cast<SbaGridControl*>(GetParent())->StartDrag(_nAction, 828*cdf0e10cSrcweir Point( 829*cdf0e10cSrcweir _rMousePos.X() + GetPosPixel().X(), // we aren't left-justified with our parent, in contrast to the data window 830*cdf0e10cSrcweir _rMousePos.Y() - GetSizePixel().Height() 831*cdf0e10cSrcweir ) 832*cdf0e10cSrcweir ); 833*cdf0e10cSrcweir return sal_True; 834*cdf0e10cSrcweir } 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir return sal_False; 837*cdf0e10cSrcweir } 838*cdf0e10cSrcweir 839*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 840*cdf0e10cSrcweir void SbaGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu) 841*cdf0e10cSrcweir { 842*cdf0e10cSrcweir FmGridHeader::PreExecuteColumnContextMenu(nColId, rMenu); 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir // some items are valid only if the db isn't readonly 845*cdf0e10cSrcweir sal_Bool bDBIsReadOnly = ((SbaGridControl*)GetParent())->IsReadOnlyDB(); 846*cdf0e10cSrcweir 847*cdf0e10cSrcweir if (bDBIsReadOnly) 848*cdf0e10cSrcweir { 849*cdf0e10cSrcweir rMenu.EnableItem(SID_FM_HIDECOL, sal_False); 850*cdf0e10cSrcweir PopupMenu* pShowColsMenu = rMenu.GetPopupMenu(SID_FM_SHOWCOLS); 851*cdf0e10cSrcweir if (pShowColsMenu) 852*cdf0e10cSrcweir { 853*cdf0e10cSrcweir // at most 16 items which mean "show column <name>" 854*cdf0e10cSrcweir for (sal_uInt16 i=1; i<16; ++i) 855*cdf0e10cSrcweir pShowColsMenu->EnableItem(i, sal_False); 856*cdf0e10cSrcweir // "show cols/more..." and "show cols/all" 857*cdf0e10cSrcweir pShowColsMenu->EnableItem(SID_FM_SHOWCOLS_MORE, sal_False); 858*cdf0e10cSrcweir pShowColsMenu->EnableItem(SID_FM_SHOWALLCOLS, sal_False); 859*cdf0e10cSrcweir } 860*cdf0e10cSrcweir } 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir // prepend some new items 863*cdf0e10cSrcweir sal_Bool bColAttrs = (nColId != (sal_uInt16)-1) && (nColId != 0); 864*cdf0e10cSrcweir if ( bColAttrs && !bDBIsReadOnly) 865*cdf0e10cSrcweir { 866*cdf0e10cSrcweir PopupMenu aNewItems(ModuleRes(RID_SBA_GRID_COLCTXMENU)); 867*cdf0e10cSrcweir sal_uInt16 nPos = 0; 868*cdf0e10cSrcweir sal_uInt16 nModelPos = ((SbaGridControl*)GetParent())->GetModelColumnPos(nColId); 869*cdf0e10cSrcweir Reference< XPropertySet > xField = ((SbaGridControl*)GetParent())->getField(nModelPos); 870*cdf0e10cSrcweir 871*cdf0e10cSrcweir if ( xField.is() ) 872*cdf0e10cSrcweir { 873*cdf0e10cSrcweir switch( ::comphelper::getINT32(xField->getPropertyValue(PROPERTY_TYPE)) ) 874*cdf0e10cSrcweir { 875*cdf0e10cSrcweir case DataType::BINARY: 876*cdf0e10cSrcweir case DataType::VARBINARY: 877*cdf0e10cSrcweir case DataType::LONGVARBINARY: 878*cdf0e10cSrcweir case DataType::SQLNULL: 879*cdf0e10cSrcweir case DataType::OBJECT: 880*cdf0e10cSrcweir case DataType::BLOB: 881*cdf0e10cSrcweir case DataType::CLOB: 882*cdf0e10cSrcweir case DataType::REF: 883*cdf0e10cSrcweir break; 884*cdf0e10cSrcweir default: 885*cdf0e10cSrcweir rMenu.InsertItem(ID_BROWSER_COLATTRSET, aNewItems.GetItemText(ID_BROWSER_COLATTRSET), 0, nPos++); 886*cdf0e10cSrcweir rMenu.SetHelpId(ID_BROWSER_COLATTRSET, aNewItems.GetHelpId(ID_BROWSER_COLATTRSET)); 887*cdf0e10cSrcweir rMenu.InsertSeparator(nPos++); 888*cdf0e10cSrcweir } 889*cdf0e10cSrcweir } 890*cdf0e10cSrcweir 891*cdf0e10cSrcweir rMenu.InsertItem(ID_BROWSER_COLWIDTH, aNewItems.GetItemText(ID_BROWSER_COLWIDTH), 0, nPos++); 892*cdf0e10cSrcweir rMenu.SetHelpId(ID_BROWSER_COLWIDTH, aNewItems.GetHelpId(ID_BROWSER_COLWIDTH)); 893*cdf0e10cSrcweir rMenu.InsertSeparator(nPos++); 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir } 896*cdf0e10cSrcweir 897*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 898*cdf0e10cSrcweir void SbaGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult) 899*cdf0e10cSrcweir { 900*cdf0e10cSrcweir switch (nExecutionResult) 901*cdf0e10cSrcweir { 902*cdf0e10cSrcweir case ID_BROWSER_COLWIDTH: 903*cdf0e10cSrcweir ((SbaGridControl*)GetParent())->SetColWidth(nColId); 904*cdf0e10cSrcweir break; 905*cdf0e10cSrcweir 906*cdf0e10cSrcweir case ID_BROWSER_COLATTRSET: 907*cdf0e10cSrcweir ((SbaGridControl*)GetParent())->SetColAttrs(nColId); 908*cdf0e10cSrcweir break; 909*cdf0e10cSrcweir case ID_BROWSER_COLUMNINFO: 910*cdf0e10cSrcweir { 911*cdf0e10cSrcweir sal_uInt16 nModelPos = ((SbaGridControl*)GetParent())->GetModelColumnPos(nColId); 912*cdf0e10cSrcweir Reference< XPropertySet > xField = ((SbaGridControl*)GetParent())->getField(nModelPos); 913*cdf0e10cSrcweir 914*cdf0e10cSrcweir if(!xField.is()) 915*cdf0e10cSrcweir break; 916*cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<OTableRow> > vClipboardList; 917*cdf0e10cSrcweir // send it to the clipboard 918*cdf0e10cSrcweir vClipboardList.push_back(::boost::shared_ptr<OTableRow>(new OTableRow(xField))); 919*cdf0e10cSrcweir OTableRowExchange* pData = new OTableRowExchange(vClipboardList); 920*cdf0e10cSrcweir Reference< ::com::sun::star::datatransfer::XTransferable> xRef = pData; 921*cdf0e10cSrcweir pData->CopyToClipboard(GetParent()); 922*cdf0e10cSrcweir } 923*cdf0e10cSrcweir break; 924*cdf0e10cSrcweir 925*cdf0e10cSrcweir default: FmGridHeader::PostExecuteColumnContextMenu(nColId, rMenu, nExecutionResult); 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir } 928*cdf0e10cSrcweir 929*cdf0e10cSrcweir //================================================================== 930*cdf0e10cSrcweir // SbaGridControl 931*cdf0e10cSrcweir //================================================================== 932*cdf0e10cSrcweir DBG_NAME(SbaGridControl ); 933*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 934*cdf0e10cSrcweir SbaGridControl::SbaGridControl(Reference< XMultiServiceFactory > _rM, 935*cdf0e10cSrcweir Window* pParent, FmXGridPeer* _pPeer, WinBits nBits) 936*cdf0e10cSrcweir :FmGridControl(_rM,pParent, _pPeer, nBits) 937*cdf0e10cSrcweir ,m_pMasterListener(NULL) 938*cdf0e10cSrcweir ,m_nAsyncDropEvent(0) 939*cdf0e10cSrcweir ,m_nCurrentActionColId((sal_uInt16)-1) 940*cdf0e10cSrcweir ,m_bActivatingForDrop(sal_False) 941*cdf0e10cSrcweir { 942*cdf0e10cSrcweir DBG_CTOR(SbaGridControl ,NULL); 943*cdf0e10cSrcweir } 944*cdf0e10cSrcweir 945*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 946*cdf0e10cSrcweir SbaGridControl::~SbaGridControl() 947*cdf0e10cSrcweir { 948*cdf0e10cSrcweir DBG_DTOR(SbaGridControl ,NULL); 949*cdf0e10cSrcweir if (m_nAsyncDropEvent) 950*cdf0e10cSrcweir Application::RemoveUserEvent(m_nAsyncDropEvent); 951*cdf0e10cSrcweir } 952*cdf0e10cSrcweir 953*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 954*cdf0e10cSrcweir BrowserHeader* SbaGridControl::imp_CreateHeaderBar(BrowseBox* pParent) 955*cdf0e10cSrcweir { 956*cdf0e10cSrcweir return new SbaGridHeader(pParent); 957*cdf0e10cSrcweir } 958*cdf0e10cSrcweir 959*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 960*cdf0e10cSrcweir CellController* SbaGridControl::GetController(long nRow, sal_uInt16 nCol) 961*cdf0e10cSrcweir { 962*cdf0e10cSrcweir if ( m_bActivatingForDrop ) 963*cdf0e10cSrcweir return NULL; 964*cdf0e10cSrcweir 965*cdf0e10cSrcweir return FmGridControl::GetController(nRow, nCol); 966*cdf0e10cSrcweir } 967*cdf0e10cSrcweir 968*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 969*cdf0e10cSrcweir void SbaGridControl::PreExecuteRowContextMenu(sal_uInt16 nRow, PopupMenu& rMenu) 970*cdf0e10cSrcweir { 971*cdf0e10cSrcweir FmGridControl::PreExecuteRowContextMenu(nRow, rMenu); 972*cdf0e10cSrcweir 973*cdf0e10cSrcweir PopupMenu aNewItems(ModuleRes(RID_SBA_GRID_ROWCTXMENU)); 974*cdf0e10cSrcweir sal_uInt16 nPos = 0; 975*cdf0e10cSrcweir 976*cdf0e10cSrcweir if (!IsReadOnlyDB()) 977*cdf0e10cSrcweir { 978*cdf0e10cSrcweir rMenu.InsertItem(ID_BROWSER_TABLEATTR, aNewItems.GetItemText(ID_BROWSER_TABLEATTR), 0, nPos++); 979*cdf0e10cSrcweir rMenu.SetHelpId(ID_BROWSER_TABLEATTR, aNewItems.GetHelpId(ID_BROWSER_TABLEATTR)); 980*cdf0e10cSrcweir 981*cdf0e10cSrcweir rMenu.InsertItem(ID_BROWSER_ROWHEIGHT, aNewItems.GetItemText(ID_BROWSER_ROWHEIGHT), 0, nPos++); 982*cdf0e10cSrcweir rMenu.SetHelpId(ID_BROWSER_ROWHEIGHT, aNewItems.GetHelpId(ID_BROWSER_ROWHEIGHT)); 983*cdf0e10cSrcweir rMenu.InsertSeparator(nPos++); 984*cdf0e10cSrcweir } // if (!IsReadOnlyDB()) 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir if ( GetSelectRowCount() > 0 ) 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir rMenu.InsertItem(ID_BROWSER_COPY, aNewItems.GetItemText(SID_COPY), 0, nPos++); 989*cdf0e10cSrcweir rMenu.SetHelpId(ID_BROWSER_COPY, aNewItems.GetHelpId(SID_COPY)); 990*cdf0e10cSrcweir 991*cdf0e10cSrcweir rMenu.InsertSeparator(nPos++); 992*cdf0e10cSrcweir } 993*cdf0e10cSrcweir } 994*cdf0e10cSrcweir 995*cdf0e10cSrcweir //------------------------------------------------------------------------------ 996*cdf0e10cSrcweir SvNumberFormatter* SbaGridControl::GetDatasourceFormatter() 997*cdf0e10cSrcweir { 998*cdf0e10cSrcweir Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = ::dbtools::getNumberFormats(::dbtools::getConnection(Reference< XRowSet > (getDataSource(),UNO_QUERY)), sal_True,getServiceManager()); 999*cdf0e10cSrcweir 1000*cdf0e10cSrcweir SvNumberFormatsSupplierObj* pSupplierImpl = SvNumberFormatsSupplierObj::getImplementation( xSupplier ); 1001*cdf0e10cSrcweir if ( !pSupplierImpl ) 1002*cdf0e10cSrcweir return NULL; 1003*cdf0e10cSrcweir 1004*cdf0e10cSrcweir SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter(); 1005*cdf0e10cSrcweir return pFormatter; 1006*cdf0e10cSrcweir } 1007*cdf0e10cSrcweir 1008*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1009*cdf0e10cSrcweir void SbaGridControl::SetColWidth(sal_uInt16 nColId) 1010*cdf0e10cSrcweir { 1011*cdf0e10cSrcweir // get the (UNO) column model 1012*cdf0e10cSrcweir sal_uInt16 nModelPos = GetModelColumnPos(nColId); 1013*cdf0e10cSrcweir Reference< XIndexAccess > xCols(GetPeer()->getColumns(), UNO_QUERY); 1014*cdf0e10cSrcweir Reference< XPropertySet > xAffectedCol; 1015*cdf0e10cSrcweir if (xCols.is() && (nModelPos != (sal_uInt16)-1)) 1016*cdf0e10cSrcweir ::cppu::extractInterface(xAffectedCol,xCols->getByIndex(nModelPos)); 1017*cdf0e10cSrcweir 1018*cdf0e10cSrcweir if (xAffectedCol.is()) 1019*cdf0e10cSrcweir { 1020*cdf0e10cSrcweir Any aWidth = xAffectedCol->getPropertyValue(PROPERTY_WIDTH); 1021*cdf0e10cSrcweir sal_Int32 nCurWidth = aWidth.hasValue() ? ::comphelper::getINT32(aWidth) : -1; 1022*cdf0e10cSrcweir 1023*cdf0e10cSrcweir DlgSize aDlgColWidth(this, nCurWidth, sal_False); 1024*cdf0e10cSrcweir if (aDlgColWidth.Execute()) 1025*cdf0e10cSrcweir { 1026*cdf0e10cSrcweir sal_Int32 nValue = aDlgColWidth.GetValue(); 1027*cdf0e10cSrcweir Any aNewWidth; 1028*cdf0e10cSrcweir if (-1 == nValue) 1029*cdf0e10cSrcweir { // set to default 1030*cdf0e10cSrcweir Reference< XPropertyState > xPropState(xAffectedCol, UNO_QUERY); 1031*cdf0e10cSrcweir if (xPropState.is()) 1032*cdf0e10cSrcweir { 1033*cdf0e10cSrcweir try { aNewWidth = xPropState->getPropertyDefault(PROPERTY_WIDTH); } catch(Exception&) { } ; 1034*cdf0e10cSrcweir } 1035*cdf0e10cSrcweir } 1036*cdf0e10cSrcweir else 1037*cdf0e10cSrcweir aNewWidth <<= nValue; 1038*cdf0e10cSrcweir try { xAffectedCol->setPropertyValue(PROPERTY_WIDTH, aNewWidth); } catch(Exception&) { } ; 1039*cdf0e10cSrcweir } 1040*cdf0e10cSrcweir } 1041*cdf0e10cSrcweir } 1042*cdf0e10cSrcweir 1043*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1044*cdf0e10cSrcweir void SbaGridControl::SetRowHeight() 1045*cdf0e10cSrcweir { 1046*cdf0e10cSrcweir Reference< XPropertySet > xCols(GetPeer()->getColumns(), UNO_QUERY); 1047*cdf0e10cSrcweir if (!xCols.is()) 1048*cdf0e10cSrcweir return; 1049*cdf0e10cSrcweir 1050*cdf0e10cSrcweir Any aHeight = xCols->getPropertyValue(PROPERTY_ROW_HEIGHT); 1051*cdf0e10cSrcweir sal_Int32 nCurHeight = aHeight.hasValue() ? ::comphelper::getINT32(aHeight) : -1; 1052*cdf0e10cSrcweir 1053*cdf0e10cSrcweir DlgSize aDlgRowHeight(this, nCurHeight, sal_True); 1054*cdf0e10cSrcweir if (aDlgRowHeight.Execute()) 1055*cdf0e10cSrcweir { 1056*cdf0e10cSrcweir sal_Int32 nValue = aDlgRowHeight.GetValue(); 1057*cdf0e10cSrcweir Any aNewHeight; 1058*cdf0e10cSrcweir if ((sal_Int16)-1 == nValue) 1059*cdf0e10cSrcweir { // set to default 1060*cdf0e10cSrcweir Reference< XPropertyState > xPropState(xCols, UNO_QUERY); 1061*cdf0e10cSrcweir if (xPropState.is()) 1062*cdf0e10cSrcweir { 1063*cdf0e10cSrcweir try 1064*cdf0e10cSrcweir { 1065*cdf0e10cSrcweir aNewHeight = xPropState->getPropertyDefault(PROPERTY_ROW_HEIGHT); 1066*cdf0e10cSrcweir } 1067*cdf0e10cSrcweir catch(Exception&) 1068*cdf0e10cSrcweir { } 1069*cdf0e10cSrcweir } 1070*cdf0e10cSrcweir } 1071*cdf0e10cSrcweir else 1072*cdf0e10cSrcweir aNewHeight <<= nValue; 1073*cdf0e10cSrcweir try 1074*cdf0e10cSrcweir { 1075*cdf0e10cSrcweir xCols->setPropertyValue(PROPERTY_ROW_HEIGHT, aNewHeight); 1076*cdf0e10cSrcweir } 1077*cdf0e10cSrcweir catch(Exception&) 1078*cdf0e10cSrcweir { 1079*cdf0e10cSrcweir OSL_ENSURE(0,"setPropertyValue: PROPERTY_ROW_HEIGHT throws a exception"); 1080*cdf0e10cSrcweir } 1081*cdf0e10cSrcweir } 1082*cdf0e10cSrcweir } 1083*cdf0e10cSrcweir 1084*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1085*cdf0e10cSrcweir void SbaGridControl::SetColAttrs(sal_uInt16 nColId) 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir SvNumberFormatter* pFormatter = GetDatasourceFormatter(); 1088*cdf0e10cSrcweir if (!pFormatter) 1089*cdf0e10cSrcweir return; 1090*cdf0e10cSrcweir 1091*cdf0e10cSrcweir sal_uInt16 nModelPos = GetModelColumnPos(nColId); 1092*cdf0e10cSrcweir 1093*cdf0e10cSrcweir // get the (UNO) column model 1094*cdf0e10cSrcweir Reference< XIndexAccess > xCols(GetPeer()->getColumns(), UNO_QUERY); 1095*cdf0e10cSrcweir Reference< XPropertySet > xAffectedCol; 1096*cdf0e10cSrcweir if (xCols.is() && (nModelPos != (sal_uInt16)-1)) 1097*cdf0e10cSrcweir ::cppu::extractInterface(xAffectedCol,xCols->getByIndex(nModelPos)); 1098*cdf0e10cSrcweir 1099*cdf0e10cSrcweir // get the field the column is bound to 1100*cdf0e10cSrcweir Reference< XPropertySet > xField = getField(nModelPos); 1101*cdf0e10cSrcweir ::dbaui::callColumnFormatDialog(xAffectedCol,xField,pFormatter,this);//(Window::GetSettings().GetLanguage()); 1102*cdf0e10cSrcweir } 1103*cdf0e10cSrcweir 1104*cdf0e10cSrcweir 1105*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1106*cdf0e10cSrcweir void SbaGridControl::SetBrowserAttrs() 1107*cdf0e10cSrcweir { 1108*cdf0e10cSrcweir Reference< XPropertySet > xGridModel(GetPeer()->getColumns(), UNO_QUERY); 1109*cdf0e10cSrcweir if (!xGridModel.is()) 1110*cdf0e10cSrcweir return; 1111*cdf0e10cSrcweir 1112*cdf0e10cSrcweir try 1113*cdf0e10cSrcweir { 1114*cdf0e10cSrcweir PropertyValue aArg; 1115*cdf0e10cSrcweir aArg.Name = ::rtl::OUString::createFromAscii("IntrospectedObject"); 1116*cdf0e10cSrcweir aArg.Value <<= xGridModel; 1117*cdf0e10cSrcweir Sequence< Any > aDialogArgs(1); 1118*cdf0e10cSrcweir aDialogArgs[0] <<= aArg; 1119*cdf0e10cSrcweir 1120*cdf0e10cSrcweir Reference< XInterface > xDialog = getServiceManager()->createInstanceWithArguments( 1121*cdf0e10cSrcweir ::rtl::OUString::createFromAscii("com.sun.star.form.ControlFontDialog"), 1122*cdf0e10cSrcweir aDialogArgs 1123*cdf0e10cSrcweir ); 1124*cdf0e10cSrcweir if (!xDialog.is()) 1125*cdf0e10cSrcweir { 1126*cdf0e10cSrcweir ShowServiceNotAvailableError(this, String::CreateFromAscii("com.sun.star.form.ControlFontDialog"), sal_True); 1127*cdf0e10cSrcweir return; 1128*cdf0e10cSrcweir } 1129*cdf0e10cSrcweir 1130*cdf0e10cSrcweir Reference< XExecutableDialog > xExecute(xDialog, UNO_QUERY); 1131*cdf0e10cSrcweir OSL_ENSURE(xExecute.is(), "SbaGridControl::SetBrowserAttrs: missing an interface on the dialog!"); 1132*cdf0e10cSrcweir if (xExecute.is()) 1133*cdf0e10cSrcweir xExecute->execute(); 1134*cdf0e10cSrcweir } 1135*cdf0e10cSrcweir catch( const Exception& ) 1136*cdf0e10cSrcweir { 1137*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1138*cdf0e10cSrcweir } 1139*cdf0e10cSrcweir } 1140*cdf0e10cSrcweir 1141*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 1142*cdf0e10cSrcweir void SbaGridControl::PostExecuteRowContextMenu(sal_uInt16 nRow, const PopupMenu& rMenu, sal_uInt16 nExecutionResult) 1143*cdf0e10cSrcweir { 1144*cdf0e10cSrcweir switch (nExecutionResult) 1145*cdf0e10cSrcweir { 1146*cdf0e10cSrcweir case ID_BROWSER_TABLEATTR: 1147*cdf0e10cSrcweir SetBrowserAttrs(); 1148*cdf0e10cSrcweir break; 1149*cdf0e10cSrcweir case ID_BROWSER_ROWHEIGHT: 1150*cdf0e10cSrcweir SetRowHeight(); 1151*cdf0e10cSrcweir break; 1152*cdf0e10cSrcweir case ID_BROWSER_COPY: 1153*cdf0e10cSrcweir CopySelectedRowsToClipboard(); 1154*cdf0e10cSrcweir break; 1155*cdf0e10cSrcweir 1156*cdf0e10cSrcweir default: 1157*cdf0e10cSrcweir FmGridControl::PostExecuteRowContextMenu(nRow, rMenu, nExecutionResult); 1158*cdf0e10cSrcweir break; 1159*cdf0e10cSrcweir } 1160*cdf0e10cSrcweir } 1161*cdf0e10cSrcweir 1162*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 1163*cdf0e10cSrcweir void SbaGridControl::Select() 1164*cdf0e10cSrcweir { 1165*cdf0e10cSrcweir // irgendeine Selektion hat sich geaendert .... 1166*cdf0e10cSrcweir FmGridControl::Select(); 1167*cdf0e10cSrcweir 1168*cdf0e10cSrcweir if (m_pMasterListener) 1169*cdf0e10cSrcweir m_pMasterListener->SelectionChanged(); 1170*cdf0e10cSrcweir } 1171*cdf0e10cSrcweir 1172*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 1173*cdf0e10cSrcweir void SbaGridControl::CursorMoved() 1174*cdf0e10cSrcweir { 1175*cdf0e10cSrcweir FmGridControl::CursorMoved(); 1176*cdf0e10cSrcweir } 1177*cdf0e10cSrcweir 1178*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 1179*cdf0e10cSrcweir void SbaGridControl::ActivateCell(long nRow, sal_uInt16 nCol, sal_Bool bSetCellFocus /*= sal_True*/ ) 1180*cdf0e10cSrcweir { 1181*cdf0e10cSrcweir FmGridControl::ActivateCell(nRow, nCol, bSetCellFocus); 1182*cdf0e10cSrcweir if (m_pMasterListener) 1183*cdf0e10cSrcweir m_pMasterListener->CellActivated(); 1184*cdf0e10cSrcweir } 1185*cdf0e10cSrcweir 1186*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 1187*cdf0e10cSrcweir void SbaGridControl::DeactivateCell(sal_Bool bUpdate /*= sal_True*/) 1188*cdf0e10cSrcweir { 1189*cdf0e10cSrcweir FmGridControl::DeactivateCell(bUpdate); 1190*cdf0e10cSrcweir if (m_pMasterListener) 1191*cdf0e10cSrcweir m_pMasterListener->CellDeactivated(); 1192*cdf0e10cSrcweir } 1193*cdf0e10cSrcweir 1194*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 1195*cdf0e10cSrcweir void SbaGridControl::onRowChange() 1196*cdf0e10cSrcweir { 1197*cdf0e10cSrcweir if ( m_pMasterListener ) 1198*cdf0e10cSrcweir m_pMasterListener->RowChanged(); 1199*cdf0e10cSrcweir } 1200*cdf0e10cSrcweir 1201*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 1202*cdf0e10cSrcweir void SbaGridControl::onColumnChange() 1203*cdf0e10cSrcweir { 1204*cdf0e10cSrcweir if ( m_pMasterListener ) 1205*cdf0e10cSrcweir m_pMasterListener->ColumnChanged(); 1206*cdf0e10cSrcweir } 1207*cdf0e10cSrcweir 1208*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 1209*cdf0e10cSrcweir void SbaGridControl::BeforeDrop() 1210*cdf0e10cSrcweir { 1211*cdf0e10cSrcweir if (m_pMasterListener) 1212*cdf0e10cSrcweir m_pMasterListener->BeforeDrop(); 1213*cdf0e10cSrcweir } 1214*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 1215*cdf0e10cSrcweir void SbaGridControl::AfterDrop() 1216*cdf0e10cSrcweir { 1217*cdf0e10cSrcweir if (m_pMasterListener) 1218*cdf0e10cSrcweir m_pMasterListener->AfterDrop(); 1219*cdf0e10cSrcweir } 1220*cdf0e10cSrcweir 1221*cdf0e10cSrcweir 1222*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1223*cdf0e10cSrcweir Reference< XPropertySet > SbaGridControl::getField(sal_uInt16 nModelPos) 1224*cdf0e10cSrcweir { 1225*cdf0e10cSrcweir Reference< XPropertySet > xEmptyReturn; 1226*cdf0e10cSrcweir try 1227*cdf0e10cSrcweir { 1228*cdf0e10cSrcweir // first get the name of the column 1229*cdf0e10cSrcweir Reference< XIndexAccess > xCols(GetPeer()->getColumns(), UNO_QUERY); 1230*cdf0e10cSrcweir if ( xCols.is() && xCols->getCount() > nModelPos ) 1231*cdf0e10cSrcweir { 1232*cdf0e10cSrcweir Reference< XPropertySet > xCol(xCols->getByIndex(nModelPos),UNO_QUERY); 1233*cdf0e10cSrcweir if ( xCol.is() ) 1234*cdf0e10cSrcweir xEmptyReturn.set(xCol->getPropertyValue(PROPERTY_BOUNDFIELD),UNO_QUERY); 1235*cdf0e10cSrcweir } 1236*cdf0e10cSrcweir else 1237*cdf0e10cSrcweir OSL_ENSURE(0,"SbaGridControl::getField getColumns returns NULL or ModelPos is > than count!"); 1238*cdf0e10cSrcweir } 1239*cdf0e10cSrcweir catch(Exception&) 1240*cdf0e10cSrcweir { 1241*cdf0e10cSrcweir OSL_ENSURE(0,"SbaGridControl::getField Exception occured!"); 1242*cdf0e10cSrcweir } 1243*cdf0e10cSrcweir 1244*cdf0e10cSrcweir return xEmptyReturn; 1245*cdf0e10cSrcweir } 1246*cdf0e10cSrcweir 1247*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 1248*cdf0e10cSrcweir sal_Bool SbaGridControl::IsReadOnlyDB() const 1249*cdf0e10cSrcweir { 1250*cdf0e10cSrcweir // assume yes if anything fails 1251*cdf0e10cSrcweir sal_Bool bDBIsReadOnly = sal_True; 1252*cdf0e10cSrcweir 1253*cdf0e10cSrcweir // the db is the implemented by the parent of the grid control's model ... 1254*cdf0e10cSrcweir Reference< XChild > xColumns(GetPeer()->getColumns(), UNO_QUERY); 1255*cdf0e10cSrcweir if (xColumns.is()) 1256*cdf0e10cSrcweir { 1257*cdf0e10cSrcweir Reference< XRowSet > xDataSource(xColumns->getParent(), UNO_QUERY); 1258*cdf0e10cSrcweir Reference< XChild > xConn(::dbtools::getConnection(xDataSource),UNO_QUERY); 1259*cdf0e10cSrcweir if (xConn.is()) 1260*cdf0e10cSrcweir { 1261*cdf0e10cSrcweir // ... and the RO-flag simply is implemented by a property 1262*cdf0e10cSrcweir Reference< XPropertySet > xDbProps(xConn->getParent(), UNO_QUERY); 1263*cdf0e10cSrcweir if (xDbProps.is()) 1264*cdf0e10cSrcweir { 1265*cdf0e10cSrcweir Reference< XPropertySetInfo > xInfo = xDbProps->getPropertySetInfo(); 1266*cdf0e10cSrcweir if (xInfo->hasPropertyByName(PROPERTY_ISREADONLY)) 1267*cdf0e10cSrcweir bDBIsReadOnly = ::comphelper::getBOOL(xDbProps->getPropertyValue(PROPERTY_ISREADONLY)); 1268*cdf0e10cSrcweir } 1269*cdf0e10cSrcweir } 1270*cdf0e10cSrcweir } 1271*cdf0e10cSrcweir return bDBIsReadOnly; 1272*cdf0e10cSrcweir } 1273*cdf0e10cSrcweir 1274*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 1275*cdf0e10cSrcweir void SbaGridControl::MouseButtonDown( const BrowserMouseEvent& rMEvt) 1276*cdf0e10cSrcweir { 1277*cdf0e10cSrcweir long nRow = GetRowAtYPosPixel(rMEvt.GetPosPixel().Y()); 1278*cdf0e10cSrcweir sal_uInt16 nColPos = GetColumnAtXPosPixel(rMEvt.GetPosPixel().X()); 1279*cdf0e10cSrcweir sal_uInt16 nViewPos = (nColPos == BROWSER_INVALIDID) ? (sal_uInt16)-1 : nColPos-1; 1280*cdf0e10cSrcweir // 'the handle column' and 'no valid column' will both result in a view position of -1 ! 1281*cdf0e10cSrcweir 1282*cdf0e10cSrcweir sal_Bool bHitEmptySpace = (nRow > GetRowCount()) || (nViewPos == (sal_uInt16)-1); 1283*cdf0e10cSrcweir 1284*cdf0e10cSrcweir if (bHitEmptySpace && (rMEvt.GetClicks() == 2) && rMEvt.IsMod1()) 1285*cdf0e10cSrcweir Control::MouseButtonDown(rMEvt); 1286*cdf0e10cSrcweir else 1287*cdf0e10cSrcweir FmGridControl::MouseButtonDown(rMEvt); 1288*cdf0e10cSrcweir } 1289*cdf0e10cSrcweir 1290*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 1291*cdf0e10cSrcweir void SbaGridControl::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) 1292*cdf0e10cSrcweir { 1293*cdf0e10cSrcweir ::vos::OGuard aGuard(Application::GetSolarMutex()); 1294*cdf0e10cSrcweir // in the new DnD API, the solar mutex is not locked when StartDrag get's called 1295*cdf0e10cSrcweir 1296*cdf0e10cSrcweir sal_Bool bHandled = sal_False; 1297*cdf0e10cSrcweir 1298*cdf0e10cSrcweir do 1299*cdf0e10cSrcweir { 1300*cdf0e10cSrcweir // determine if dragging is allowed 1301*cdf0e10cSrcweir // (Yes, this is controller (not view) functionality. But collecting and evaluating all the 1302*cdf0e10cSrcweir // informations necessary via UNO would be quite difficult (if not impossible) so 1303*cdf0e10cSrcweir // my laziness says 'do it here' ...) 1304*cdf0e10cSrcweir long nRow = GetRowAtYPosPixel(_rPosPixel.Y()); 1305*cdf0e10cSrcweir sal_uInt16 nColPos = GetColumnAtXPosPixel(_rPosPixel.X()); 1306*cdf0e10cSrcweir sal_uInt16 nViewPos = (nColPos == BROWSER_INVALIDID) ? (sal_uInt16)-1 : nColPos-1; 1307*cdf0e10cSrcweir // 'the handle column' and 'no valid column' will both result in a view position of -1 ! 1308*cdf0e10cSrcweir 1309*cdf0e10cSrcweir sal_Bool bCurrentRowVirtual = IsCurrentAppending() && IsModified(); 1310*cdf0e10cSrcweir // the current row doesn't really exist : the user's appendign a new one and already has entered some data, 1311*cdf0e10cSrcweir // so the row contains data which has no counter part within the data source 1312*cdf0e10cSrcweir 1313*cdf0e10cSrcweir long nCorrectRowCount = GetRowCount(); 1314*cdf0e10cSrcweir if (GetOptions() & OPT_INSERT) 1315*cdf0e10cSrcweir --nCorrectRowCount; // there is a empty row for inserting records 1316*cdf0e10cSrcweir if (bCurrentRowVirtual) 1317*cdf0e10cSrcweir --nCorrectRowCount; 1318*cdf0e10cSrcweir 1319*cdf0e10cSrcweir if ((nColPos == BROWSER_INVALIDID) || (nRow >= nCorrectRowCount)) 1320*cdf0e10cSrcweir break; 1321*cdf0e10cSrcweir 1322*cdf0e10cSrcweir sal_Bool bHitHandle = (nColPos == 0); 1323*cdf0e10cSrcweir 1324*cdf0e10cSrcweir // check which kind of dragging has to be initiated 1325*cdf0e10cSrcweir if ( bHitHandle // the handle column 1326*cdf0e10cSrcweir // AND 1327*cdf0e10cSrcweir && ( GetSelectRowCount() // at least one row is selected 1328*cdf0e10cSrcweir // OR 1329*cdf0e10cSrcweir || ( (nRow >= 0) // a row below the header 1330*cdf0e10cSrcweir && !bCurrentRowVirtual // we aren't appending a new record 1331*cdf0e10cSrcweir && (nRow != GetCurrentPos()) // a row which is not the current one 1332*cdf0e10cSrcweir ) // OR 1333*cdf0e10cSrcweir || ( (0 == GetSelectRowCount()) // no rows selected 1334*cdf0e10cSrcweir && (-1 == nRow) // hit the header 1335*cdf0e10cSrcweir ) 1336*cdf0e10cSrcweir ) 1337*cdf0e10cSrcweir ) 1338*cdf0e10cSrcweir { // => start dragging the row 1339*cdf0e10cSrcweir if (GetDataWindow().IsMouseCaptured()) 1340*cdf0e10cSrcweir GetDataWindow().ReleaseMouse(); 1341*cdf0e10cSrcweir 1342*cdf0e10cSrcweir if (0 == GetSelectRowCount()) 1343*cdf0e10cSrcweir // no rows selected, but here in this branch 1344*cdf0e10cSrcweir // -> the user started dragging the upper left corner, which symbolizes the whole table 1345*cdf0e10cSrcweir SelectAll(); 1346*cdf0e10cSrcweir 1347*cdf0e10cSrcweir getMouseEvent().Clear(); 1348*cdf0e10cSrcweir DoRowDrag((sal_Int16)nRow); 1349*cdf0e10cSrcweir 1350*cdf0e10cSrcweir bHandled = sal_True; 1351*cdf0e10cSrcweir } 1352*cdf0e10cSrcweir else if ( (nRow < 0) // the header 1353*cdf0e10cSrcweir && (!bHitHandle) // non-handle column 1354*cdf0e10cSrcweir && (nViewPos < GetViewColCount()) // valid (existing) column 1355*cdf0e10cSrcweir ) 1356*cdf0e10cSrcweir { // => start dragging the column 1357*cdf0e10cSrcweir if (GetDataWindow().IsMouseCaptured()) 1358*cdf0e10cSrcweir GetDataWindow().ReleaseMouse(); 1359*cdf0e10cSrcweir 1360*cdf0e10cSrcweir getMouseEvent().Clear(); 1361*cdf0e10cSrcweir DoColumnDrag(nViewPos); 1362*cdf0e10cSrcweir 1363*cdf0e10cSrcweir bHandled = sal_True; 1364*cdf0e10cSrcweir } 1365*cdf0e10cSrcweir else if ( !bHitHandle // non-handle column 1366*cdf0e10cSrcweir && (nRow >= 0) // non-header row 1367*cdf0e10cSrcweir ) 1368*cdf0e10cSrcweir { // => start dragging the field content 1369*cdf0e10cSrcweir if (GetDataWindow().IsMouseCaptured()) 1370*cdf0e10cSrcweir GetDataWindow().ReleaseMouse(); 1371*cdf0e10cSrcweir 1372*cdf0e10cSrcweir getMouseEvent().Clear(); 1373*cdf0e10cSrcweir DoFieldDrag(nViewPos, (sal_Int16)nRow); 1374*cdf0e10cSrcweir 1375*cdf0e10cSrcweir bHandled = sal_True; 1376*cdf0e10cSrcweir } 1377*cdf0e10cSrcweir } 1378*cdf0e10cSrcweir while (sal_False); 1379*cdf0e10cSrcweir 1380*cdf0e10cSrcweir if (!bHandled) 1381*cdf0e10cSrcweir FmGridControl::StartDrag(_nAction, _rPosPixel); 1382*cdf0e10cSrcweir } 1383*cdf0e10cSrcweir 1384*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1385*cdf0e10cSrcweir void SbaGridControl::Command(const CommandEvent& rEvt) 1386*cdf0e10cSrcweir { 1387*cdf0e10cSrcweir FmGridControl::Command(rEvt); 1388*cdf0e10cSrcweir } 1389*cdf0e10cSrcweir 1390*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1391*cdf0e10cSrcweir void SbaGridControl::DoColumnDrag(sal_uInt16 nColumnPos) 1392*cdf0e10cSrcweir { 1393*cdf0e10cSrcweir Reference< XPropertySet > xDataSource(getDataSource(), UNO_QUERY); 1394*cdf0e10cSrcweir DBG_ASSERT(xDataSource.is(), "SbaGridControl::DoColumnDrag : invalid data source !"); 1395*cdf0e10cSrcweir 1396*cdf0e10cSrcweir Reference< XPropertySet > xAffectedCol; 1397*cdf0e10cSrcweir Reference< XPropertySet > xAffectedField; 1398*cdf0e10cSrcweir Reference< XConnection > xActiveConnection; 1399*cdf0e10cSrcweir 1400*cdf0e10cSrcweir // determine the field to drag 1401*cdf0e10cSrcweir ::rtl::OUString sField; 1402*cdf0e10cSrcweir try 1403*cdf0e10cSrcweir { 1404*cdf0e10cSrcweir xActiveConnection = ::dbtools::getConnection(Reference< XRowSet >(getDataSource(),UNO_QUERY)); 1405*cdf0e10cSrcweir 1406*cdf0e10cSrcweir sal_uInt16 nModelPos = GetModelColumnPos(GetColumnIdFromViewPos(nColumnPos)); 1407*cdf0e10cSrcweir Reference< XIndexContainer > xCols(GetPeer()->getColumns(), UNO_QUERY); 1408*cdf0e10cSrcweir xAffectedCol.set(xCols->getByIndex(nModelPos),UNO_QUERY); 1409*cdf0e10cSrcweir if (xAffectedCol.is()) 1410*cdf0e10cSrcweir { 1411*cdf0e10cSrcweir xAffectedCol->getPropertyValue(PROPERTY_CONTROLSOURCE) >>= sField; 1412*cdf0e10cSrcweir xAffectedField.set(xAffectedCol->getPropertyValue(PROPERTY_BOUNDFIELD),UNO_QUERY); 1413*cdf0e10cSrcweir } 1414*cdf0e10cSrcweir } 1415*cdf0e10cSrcweir catch(Exception&) 1416*cdf0e10cSrcweir { 1417*cdf0e10cSrcweir DBG_ERROR("SbaGridControl::DoColumnDrag : something went wrong while getting the column"); 1418*cdf0e10cSrcweir } 1419*cdf0e10cSrcweir if (0 == sField.getLength()) 1420*cdf0e10cSrcweir return; 1421*cdf0e10cSrcweir 1422*cdf0e10cSrcweir OColumnTransferable* pDataTransfer = new OColumnTransferable(xDataSource, sField, xAffectedField, xActiveConnection, CTF_FIELD_DESCRIPTOR | CTF_COLUMN_DESCRIPTOR); 1423*cdf0e10cSrcweir Reference< XTransferable > xEnsureDelete = pDataTransfer; 1424*cdf0e10cSrcweir pDataTransfer->StartDrag(this, DND_ACTION_COPY | DND_ACTION_LINK); 1425*cdf0e10cSrcweir } 1426*cdf0e10cSrcweir 1427*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1428*cdf0e10cSrcweir void SbaGridControl::CopySelectedRowsToClipboard() 1429*cdf0e10cSrcweir { 1430*cdf0e10cSrcweir DBG_ASSERT( GetSelectRowCount() > 0, "SbaGridControl::CopySelectedRowsToClipboard: invalid call!" ); 1431*cdf0e10cSrcweir implTransferSelectedRows( (sal_Int16)FirstSelectedRow(), true ); 1432*cdf0e10cSrcweir } 1433*cdf0e10cSrcweir 1434*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1435*cdf0e10cSrcweir void SbaGridControl::DoRowDrag( sal_Int16 nRowPos ) 1436*cdf0e10cSrcweir { 1437*cdf0e10cSrcweir implTransferSelectedRows( nRowPos, false ); 1438*cdf0e10cSrcweir } 1439*cdf0e10cSrcweir 1440*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1441*cdf0e10cSrcweir void SbaGridControl::implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag ) 1442*cdf0e10cSrcweir { 1443*cdf0e10cSrcweir Reference< XPropertySet > xForm( getDataSource(), UNO_QUERY ); 1444*cdf0e10cSrcweir DBG_ASSERT( xForm.is(), "SbaGridControl::implTransferSelectedRows: invalid form!" ); 1445*cdf0e10cSrcweir 1446*cdf0e10cSrcweir // build the sequence of numbers of selected rows 1447*cdf0e10cSrcweir Sequence< Any > aSelectedRows; 1448*cdf0e10cSrcweir sal_Bool bSelectionBookmarks = sal_True; 1449*cdf0e10cSrcweir 1450*cdf0e10cSrcweir // collect the affected rows 1451*cdf0e10cSrcweir if ((GetSelectRowCount() == 0) && (nRowPos >= 0)) 1452*cdf0e10cSrcweir { 1453*cdf0e10cSrcweir aSelectedRows.realloc( 1 ); 1454*cdf0e10cSrcweir aSelectedRows[0] <<= (sal_Int32)(nRowPos + 1); 1455*cdf0e10cSrcweir bSelectionBookmarks = sal_False; 1456*cdf0e10cSrcweir } 1457*cdf0e10cSrcweir else if ( !IsAllSelected() && GetSelectRowCount() ) 1458*cdf0e10cSrcweir { 1459*cdf0e10cSrcweir aSelectedRows = getSelectionBookmarks(); 1460*cdf0e10cSrcweir bSelectionBookmarks = sal_True; 1461*cdf0e10cSrcweir } 1462*cdf0e10cSrcweir 1463*cdf0e10cSrcweir Reference< XResultSet> xRowSetClone; 1464*cdf0e10cSrcweir try 1465*cdf0e10cSrcweir { 1466*cdf0e10cSrcweir ODataClipboard* pTransfer = new ODataClipboard( xForm, aSelectedRows, bSelectionBookmarks, getServiceManager() ); 1467*cdf0e10cSrcweir 1468*cdf0e10cSrcweir Reference< XTransferable > xEnsureDelete = pTransfer; 1469*cdf0e10cSrcweir if ( _bTrueIfClipboardFalseIfDrag ) 1470*cdf0e10cSrcweir pTransfer->CopyToClipboard( this ); 1471*cdf0e10cSrcweir else 1472*cdf0e10cSrcweir pTransfer->StartDrag(this, DND_ACTION_COPY | DND_ACTION_LINK); 1473*cdf0e10cSrcweir } 1474*cdf0e10cSrcweir catch(Exception&) 1475*cdf0e10cSrcweir { 1476*cdf0e10cSrcweir } 1477*cdf0e10cSrcweir } 1478*cdf0e10cSrcweir 1479*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1480*cdf0e10cSrcweir void SbaGridControl::DoFieldDrag(sal_uInt16 nColumnPos, sal_Int16 nRowPos) 1481*cdf0e10cSrcweir { 1482*cdf0e10cSrcweir // the only thing to do here is dragging the pure cell text 1483*cdf0e10cSrcweir // the old implementation copied a SBA_FIELDDATAEXCHANGE_FORMAT, too, (which was rather expensive to obtain), 1484*cdf0e10cSrcweir // but we have no client for this DnD format anymore (the mail part of SO 5.2 was the only client) 1485*cdf0e10cSrcweir 1486*cdf0e10cSrcweir ::rtl::OUString sCellText; 1487*cdf0e10cSrcweir try 1488*cdf0e10cSrcweir { 1489*cdf0e10cSrcweir Reference< XGridFieldDataSupplier > xFieldData(static_cast< XGridPeer* >(GetPeer()), UNO_QUERY); 1490*cdf0e10cSrcweir Sequence<sal_Bool> aSupportingText = xFieldData->queryFieldDataType(::getCppuType(&sCellText)); 1491*cdf0e10cSrcweir if (aSupportingText.getConstArray()[nColumnPos]) 1492*cdf0e10cSrcweir { 1493*cdf0e10cSrcweir Sequence< Any> aCellContents = xFieldData->queryFieldData(nRowPos, ::getCppuType(&sCellText)); 1494*cdf0e10cSrcweir sCellText = ::comphelper::getString(aCellContents.getConstArray()[nColumnPos]); 1495*cdf0e10cSrcweir ::svt::OStringTransfer::StartStringDrag(sCellText, this, DND_ACTION_COPY); 1496*cdf0e10cSrcweir } 1497*cdf0e10cSrcweir } 1498*cdf0e10cSrcweir catch(Exception&) 1499*cdf0e10cSrcweir { 1500*cdf0e10cSrcweir DBG_ERROR("SbaGridControl::DoFieldDrag : could not retrieve the cell's contents !"); 1501*cdf0e10cSrcweir return; 1502*cdf0e10cSrcweir } 1503*cdf0e10cSrcweir 1504*cdf0e10cSrcweir } 1505*cdf0e10cSrcweir /// unary_function Functor object for class ZZ returntype is void 1506*cdf0e10cSrcweir struct SbaGridControlPrec : ::std::unary_function<DataFlavorExVector::value_type,bool> 1507*cdf0e10cSrcweir { 1508*cdf0e10cSrcweir sal_Bool bQueryDrop; 1509*cdf0e10cSrcweir SbaGridControlPrec(sal_Bool _bQueryDrop) 1510*cdf0e10cSrcweir : bQueryDrop(_bQueryDrop) 1511*cdf0e10cSrcweir { 1512*cdf0e10cSrcweir } 1513*cdf0e10cSrcweir 1514*cdf0e10cSrcweir inline bool operator()(const DataFlavorExVector::value_type& _aType) 1515*cdf0e10cSrcweir { 1516*cdf0e10cSrcweir switch (_aType.mnSotId) 1517*cdf0e10cSrcweir { 1518*cdf0e10cSrcweir // case SOT_FORMAT_RTF: // RTF data descriptions 1519*cdf0e10cSrcweir // case SOT_FORMATSTR_ID_HTML: // HTML data descriptions 1520*cdf0e10cSrcweir case SOT_FORMATSTR_ID_DBACCESS_TABLE: // table descriptor 1521*cdf0e10cSrcweir case SOT_FORMATSTR_ID_DBACCESS_QUERY: // query descriptor 1522*cdf0e10cSrcweir case SOT_FORMATSTR_ID_DBACCESS_COMMAND: // SQL command 1523*cdf0e10cSrcweir return true; 1524*cdf0e10cSrcweir } 1525*cdf0e10cSrcweir return false; 1526*cdf0e10cSrcweir } 1527*cdf0e10cSrcweir }; 1528*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1529*cdf0e10cSrcweir sal_Int8 SbaGridControl::AcceptDrop( const BrowserAcceptDropEvent& rEvt ) 1530*cdf0e10cSrcweir { 1531*cdf0e10cSrcweir sal_Int8 nAction = DND_ACTION_NONE; 1532*cdf0e10cSrcweir 1533*cdf0e10cSrcweir // we need a valid connection 1534*cdf0e10cSrcweir if (!::dbtools::getConnection(Reference< XRowSet > (getDataSource(),UNO_QUERY)).is()) 1535*cdf0e10cSrcweir return nAction; 1536*cdf0e10cSrcweir 1537*cdf0e10cSrcweir if ( IsDropFormatSupported( FORMAT_STRING ) ) do 1538*cdf0e10cSrcweir { // odd construction, but spares us a lot of (explicit ;) goto's 1539*cdf0e10cSrcweir 1540*cdf0e10cSrcweir if (!GetEmptyRow().Is()) 1541*cdf0e10cSrcweir // without an empty row we're not in update mode 1542*cdf0e10cSrcweir break; 1543*cdf0e10cSrcweir 1544*cdf0e10cSrcweir long nRow = GetRowAtYPosPixel(rEvt.maPosPixel.Y(), sal_False); 1545*cdf0e10cSrcweir sal_uInt16 nCol = GetColumnAtXPosPixel(rEvt.maPosPixel.X(), sal_False); 1546*cdf0e10cSrcweir 1547*cdf0e10cSrcweir long nCorrectRowCount = GetRowCount(); 1548*cdf0e10cSrcweir if (GetOptions() & OPT_INSERT) 1549*cdf0e10cSrcweir --nCorrectRowCount; // there is a empty row for inserting records 1550*cdf0e10cSrcweir if (IsCurrentAppending()) 1551*cdf0e10cSrcweir --nCorrectRowCount; // the current data record doesn't really exist, we are appending a new one 1552*cdf0e10cSrcweir 1553*cdf0e10cSrcweir if ((nCol == BROWSER_INVALIDID) || (nRow >= nCorrectRowCount) || GetColumnId(nCol) == 0 ) 1554*cdf0e10cSrcweir // no valid cell under the mouse cursor 1555*cdf0e10cSrcweir break; 1556*cdf0e10cSrcweir 1557*cdf0e10cSrcweir Rectangle aRect = GetCellRect(nRow, nCol, sal_False); 1558*cdf0e10cSrcweir if (!aRect.IsInside(rEvt.maPosPixel)) 1559*cdf0e10cSrcweir // not dropped within a cell (a cell isn't as wide as the column - the are small spaces) 1560*cdf0e10cSrcweir break; 1561*cdf0e10cSrcweir 1562*cdf0e10cSrcweir if ((IsModified() || (GetCurrentRow().Is() && GetCurrentRow()->IsModified())) && (GetCurrentPos() != nRow)) 1563*cdf0e10cSrcweir // there is a current and modified row or cell and he text is to be dropped into another one 1564*cdf0e10cSrcweir break; 1565*cdf0e10cSrcweir 1566*cdf0e10cSrcweir CellControllerRef xCurrentController = Controller(); 1567*cdf0e10cSrcweir if (xCurrentController.Is() && xCurrentController->IsModified() && ((nRow != GetCurRow()) || (nCol != GetCurColumnId()))) 1568*cdf0e10cSrcweir // the current controller is modified and the user wants to drop in another cell -> no chance 1569*cdf0e10cSrcweir // (when leaving the modified cell a error may occur - this is deadly while dragging) 1570*cdf0e10cSrcweir break; 1571*cdf0e10cSrcweir 1572*cdf0e10cSrcweir Reference< XPropertySet > xField = getField(GetModelColumnPos(nCol)); 1573*cdf0e10cSrcweir if (!xField.is()) 1574*cdf0e10cSrcweir // the column is not valid bound (for instance a binary field) 1575*cdf0e10cSrcweir break; 1576*cdf0e10cSrcweir 1577*cdf0e10cSrcweir try 1578*cdf0e10cSrcweir { 1579*cdf0e10cSrcweir if (::comphelper::getBOOL(xField->getPropertyValue(PROPERTY_ISREADONLY))) 1580*cdf0e10cSrcweir break; 1581*cdf0e10cSrcweir } 1582*cdf0e10cSrcweir catch (const Exception& e ) 1583*cdf0e10cSrcweir { 1584*cdf0e10cSrcweir (void)e; // make compiler happy 1585*cdf0e10cSrcweir // assume RO 1586*cdf0e10cSrcweir break; 1587*cdf0e10cSrcweir } 1588*cdf0e10cSrcweir 1589*cdf0e10cSrcweir try 1590*cdf0e10cSrcweir { 1591*cdf0e10cSrcweir // assume that text can be dropped into a field if the column has a ::com::sun::star::awt::XTextComponent interface 1592*cdf0e10cSrcweir Reference< XIndexAccess > xColumnControls((::com::sun::star::form::XGridPeer*)GetPeer(), UNO_QUERY); 1593*cdf0e10cSrcweir if (xColumnControls.is()) 1594*cdf0e10cSrcweir { 1595*cdf0e10cSrcweir Reference< ::com::sun::star::awt::XTextComponent > xColControl; 1596*cdf0e10cSrcweir ::cppu::extractInterface(xColControl,xColumnControls->getByIndex(GetViewColumnPos(nCol))); 1597*cdf0e10cSrcweir if (xColControl.is()) 1598*cdf0e10cSrcweir { 1599*cdf0e10cSrcweir m_bActivatingForDrop = sal_True; 1600*cdf0e10cSrcweir GoToRowColumnId(nRow, nCol); 1601*cdf0e10cSrcweir m_bActivatingForDrop = sal_False; 1602*cdf0e10cSrcweir 1603*cdf0e10cSrcweir nAction = DND_ACTION_COPY; 1604*cdf0e10cSrcweir } 1605*cdf0e10cSrcweir } 1606*cdf0e10cSrcweir } 1607*cdf0e10cSrcweir catch( const Exception& ) 1608*cdf0e10cSrcweir { 1609*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1610*cdf0e10cSrcweir } 1611*cdf0e10cSrcweir 1612*cdf0e10cSrcweir } while (sal_False); 1613*cdf0e10cSrcweir 1614*cdf0e10cSrcweir if(nAction != DND_ACTION_COPY && GetEmptyRow().Is()) 1615*cdf0e10cSrcweir { 1616*cdf0e10cSrcweir const DataFlavorExVector& _rFlavors = GetDataFlavors(); 1617*cdf0e10cSrcweir if(::std::find_if(_rFlavors.begin(),_rFlavors.end(),SbaGridControlPrec(sal_True)) != _rFlavors.end()) 1618*cdf0e10cSrcweir nAction = DND_ACTION_COPY; 1619*cdf0e10cSrcweir } 1620*cdf0e10cSrcweir 1621*cdf0e10cSrcweir /* 1622*cdf0e10cSrcweir // check formats 1623*cdf0e10cSrcweir SvDataObjectRef xDataObj = SvDataObject::PasteDragServer( rEvt ); 1624*cdf0e10cSrcweir if (!xDataObj.Is()) 1625*cdf0e10cSrcweir return sal_False; 1626*cdf0e10cSrcweir 1627*cdf0e10cSrcweir const SvDataTypeList& rTypeList = xDataObj->GetTypeList(); 1628*cdf0e10cSrcweir if ((rTypeList.Get(Exchange::RegisterFormatName(String::CreateFromAscii(SBA_DATAEXCHANGE_FORMAT)))) ) 1629*cdf0e10cSrcweir { 1630*cdf0e10cSrcweir bAllow = (GetOptions() & OPT_INSERT) && rEvt.GetColumnId() > 0 && rEvt.GetRow() >= 0; 1631*cdf0e10cSrcweir ((BrowserDropEvent&)rEvt).SetAction(DROP_COPY); 1632*cdf0e10cSrcweir } 1633*cdf0e10cSrcweir 1634*cdf0e10cSrcweir */ 1635*cdf0e10cSrcweir return (DND_ACTION_NONE != nAction) ? nAction : FmGridControl::AcceptDrop(rEvt); 1636*cdf0e10cSrcweir } 1637*cdf0e10cSrcweir 1638*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1639*cdf0e10cSrcweir sal_Int8 SbaGridControl::ExecuteDrop( const BrowserExecuteDropEvent& rEvt ) 1640*cdf0e10cSrcweir { 1641*cdf0e10cSrcweir // we need some properties of our data source 1642*cdf0e10cSrcweir Reference< XPropertySet > xDataSource = getDataSource(); 1643*cdf0e10cSrcweir if (!xDataSource.is()) 1644*cdf0e10cSrcweir return DND_ACTION_NONE; 1645*cdf0e10cSrcweir 1646*cdf0e10cSrcweir // we need a valid connection 1647*cdf0e10cSrcweir if (!::dbtools::getConnection(Reference< XRowSet > (xDataSource,UNO_QUERY)).is()) 1648*cdf0e10cSrcweir return DND_ACTION_NONE; 1649*cdf0e10cSrcweir 1650*cdf0e10cSrcweir if ( IsDropFormatSupported( FORMAT_STRING ) ) 1651*cdf0e10cSrcweir { 1652*cdf0e10cSrcweir long nRow = GetRowAtYPosPixel(rEvt.maPosPixel.Y(), sal_False); 1653*cdf0e10cSrcweir sal_uInt16 nCol = GetColumnAtXPosPixel(rEvt.maPosPixel.X(), sal_False); 1654*cdf0e10cSrcweir 1655*cdf0e10cSrcweir long nCorrectRowCount = GetRowCount(); 1656*cdf0e10cSrcweir if (GetOptions() & OPT_INSERT) 1657*cdf0e10cSrcweir --nCorrectRowCount; // there is a empty row for inserting records 1658*cdf0e10cSrcweir if (IsCurrentAppending()) 1659*cdf0e10cSrcweir --nCorrectRowCount; // the current data record doesn't really exist, we are appending a new one 1660*cdf0e10cSrcweir 1661*cdf0e10cSrcweir DBG_ASSERT((nCol != BROWSER_INVALIDID) && (nRow < nCorrectRowCount), "SbaGridControl::Drop : dropped on an invalid position !"); 1662*cdf0e10cSrcweir // AcceptDrop should have caught this 1663*cdf0e10cSrcweir 1664*cdf0e10cSrcweir // from now we work with ids instead of positions 1665*cdf0e10cSrcweir nCol = GetColumnId(nCol); 1666*cdf0e10cSrcweir 1667*cdf0e10cSrcweir GoToRowColumnId(nRow, nCol); 1668*cdf0e10cSrcweir if (!IsEditing()) 1669*cdf0e10cSrcweir ActivateCell(); 1670*cdf0e10cSrcweir 1671*cdf0e10cSrcweir CellControllerRef xCurrentController = Controller(); 1672*cdf0e10cSrcweir if (!xCurrentController.Is() || !xCurrentController->ISA(EditCellController)) 1673*cdf0e10cSrcweir return DND_ACTION_NONE; 1674*cdf0e10cSrcweir Edit& rEdit = (Edit&)xCurrentController->GetWindow(); 1675*cdf0e10cSrcweir 1676*cdf0e10cSrcweir // get the dropped string 1677*cdf0e10cSrcweir TransferableDataHelper aDropped( rEvt.maDropEvent.Transferable ); 1678*cdf0e10cSrcweir String sDropped; 1679*cdf0e10cSrcweir if ( !aDropped.GetString( FORMAT_STRING, sDropped ) ) 1680*cdf0e10cSrcweir return DND_ACTION_NONE; 1681*cdf0e10cSrcweir 1682*cdf0e10cSrcweir rEdit.SetText( sDropped ); 1683*cdf0e10cSrcweir xCurrentController->SetModified(); 1684*cdf0e10cSrcweir rEdit.Modify(); 1685*cdf0e10cSrcweir // SetText itself doesn't call a Modify as it isn't a user interaction 1686*cdf0e10cSrcweir 1687*cdf0e10cSrcweir return DND_ACTION_COPY; 1688*cdf0e10cSrcweir } 1689*cdf0e10cSrcweir 1690*cdf0e10cSrcweir if(GetEmptyRow().Is()) 1691*cdf0e10cSrcweir { 1692*cdf0e10cSrcweir const DataFlavorExVector& _rFlavors = GetDataFlavors(); 1693*cdf0e10cSrcweir DataFlavorExVector::const_iterator aFind = ::std::find_if(_rFlavors.begin(),_rFlavors.end(),SbaGridControlPrec(sal_True)); 1694*cdf0e10cSrcweir if( aFind != _rFlavors.end()) 1695*cdf0e10cSrcweir { 1696*cdf0e10cSrcweir TransferableDataHelper aDropped( rEvt.maDropEvent.Transferable ); 1697*cdf0e10cSrcweir m_aDataDescriptor = ODataAccessObjectTransferable::extractObjectDescriptor(aDropped); 1698*cdf0e10cSrcweir if (m_nAsyncDropEvent) 1699*cdf0e10cSrcweir Application::RemoveUserEvent(m_nAsyncDropEvent); 1700*cdf0e10cSrcweir m_nAsyncDropEvent = Application::PostUserEvent(LINK(this, SbaGridControl, AsynchDropEvent)); 1701*cdf0e10cSrcweir return DND_ACTION_COPY; 1702*cdf0e10cSrcweir } 1703*cdf0e10cSrcweir } 1704*cdf0e10cSrcweir 1705*cdf0e10cSrcweir return DND_ACTION_NONE; 1706*cdf0e10cSrcweir } 1707*cdf0e10cSrcweir 1708*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1709*cdf0e10cSrcweir Reference< XPropertySet > SbaGridControl::getDataSource() const 1710*cdf0e10cSrcweir { 1711*cdf0e10cSrcweir Reference< XPropertySet > xReturn; 1712*cdf0e10cSrcweir 1713*cdf0e10cSrcweir Reference< XChild > xColumns(GetPeer()->getColumns(), UNO_QUERY); 1714*cdf0e10cSrcweir Reference< XPropertySet > xDataSource; 1715*cdf0e10cSrcweir if (xColumns.is()) 1716*cdf0e10cSrcweir xReturn = Reference< XPropertySet > (xColumns->getParent(), UNO_QUERY); 1717*cdf0e10cSrcweir 1718*cdf0e10cSrcweir return xReturn; 1719*cdf0e10cSrcweir } 1720*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1721*cdf0e10cSrcweir IMPL_LINK(SbaGridControl, AsynchDropEvent, void*, /*EMPTY_ARG*/) 1722*cdf0e10cSrcweir { 1723*cdf0e10cSrcweir m_nAsyncDropEvent = 0; 1724*cdf0e10cSrcweir 1725*cdf0e10cSrcweir Reference< XPropertySet > xDataSource = getDataSource(); 1726*cdf0e10cSrcweir if ( xDataSource.is() ) 1727*cdf0e10cSrcweir { 1728*cdf0e10cSrcweir sal_Bool bCountFinal = sal_False; 1729*cdf0e10cSrcweir xDataSource->getPropertyValue(PROPERTY_ISROWCOUNTFINAL) >>= bCountFinal; 1730*cdf0e10cSrcweir if ( !bCountFinal ) 1731*cdf0e10cSrcweir setDataSource(NULL); // deattach from grid control 1732*cdf0e10cSrcweir Reference< XResultSetUpdate > xResultSetUpdate(xDataSource,UNO_QUERY); 1733*cdf0e10cSrcweir ODatabaseImportExport* pImExport = new ORowSetImportExport(this,xResultSetUpdate,m_aDataDescriptor,getServiceManager()); 1734*cdf0e10cSrcweir Reference<XEventListener> xHolder = pImExport; 1735*cdf0e10cSrcweir Hide(); 1736*cdf0e10cSrcweir try 1737*cdf0e10cSrcweir { 1738*cdf0e10cSrcweir pImExport->initialize(m_aDataDescriptor); 1739*cdf0e10cSrcweir BeforeDrop(); 1740*cdf0e10cSrcweir if(!pImExport->Read()) 1741*cdf0e10cSrcweir { 1742*cdf0e10cSrcweir String sError = String(ModuleRes(STR_NO_COLUMNNAME_MATCHING)); 1743*cdf0e10cSrcweir throwGenericSQLException(sError,NULL); 1744*cdf0e10cSrcweir } 1745*cdf0e10cSrcweir AfterDrop(); 1746*cdf0e10cSrcweir Show(); 1747*cdf0e10cSrcweir } 1748*cdf0e10cSrcweir catch(const SQLException& e) 1749*cdf0e10cSrcweir { 1750*cdf0e10cSrcweir AfterDrop(); 1751*cdf0e10cSrcweir Show(); 1752*cdf0e10cSrcweir ::dbaui::showError(::dbtools::SQLExceptionInfo(e),this,getServiceManager()); 1753*cdf0e10cSrcweir } 1754*cdf0e10cSrcweir catch(const Exception& ) 1755*cdf0e10cSrcweir { 1756*cdf0e10cSrcweir AfterDrop(); 1757*cdf0e10cSrcweir Show(); 1758*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1759*cdf0e10cSrcweir } 1760*cdf0e10cSrcweir if ( !bCountFinal ) 1761*cdf0e10cSrcweir setDataSource(Reference< XRowSet >(xDataSource,UNO_QUERY)); 1762*cdf0e10cSrcweir } 1763*cdf0e10cSrcweir m_aDataDescriptor.clear(); 1764*cdf0e10cSrcweir 1765*cdf0e10cSrcweir return 0L; 1766*cdf0e10cSrcweir } 1767*cdf0e10cSrcweir // ------------------------------------------------------------------------- 1768*cdf0e10cSrcweir ::rtl::OUString SbaGridControl::GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition) const 1769*cdf0e10cSrcweir { 1770*cdf0e10cSrcweir ::rtl::OUString sRet; 1771*cdf0e10cSrcweir if ( ::svt::BBTYPE_BROWSEBOX == eObjType ) 1772*cdf0e10cSrcweir { 1773*cdf0e10cSrcweir ::vos::OGuard aGuard(Application::GetSolarMutex()); 1774*cdf0e10cSrcweir sRet = String(ModuleRes(STR_DATASOURCE_GRIDCONTROL_DESC)); 1775*cdf0e10cSrcweir } 1776*cdf0e10cSrcweir else 1777*cdf0e10cSrcweir sRet = FmGridControl::GetAccessibleObjectDescription( eObjType,_nPosition); 1778*cdf0e10cSrcweir return sRet; 1779*cdf0e10cSrcweir } 1780*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1781*cdf0e10cSrcweir void SbaGridControl::DeleteSelectedRows() 1782*cdf0e10cSrcweir { 1783*cdf0e10cSrcweir FmGridControl::DeleteSelectedRows(); 1784*cdf0e10cSrcweir } 1785*cdf0e10cSrcweir 1786*cdf0e10cSrcweir 1787