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