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 #ifndef DBAUI_COLUMNCONTROL_HXX 31*cdf0e10cSrcweir #include "ColumnControl.hxx" 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir #ifndef DBAUI_COLUMNPEER_HXX 34*cdf0e10cSrcweir #include "ColumnPeer.hxx" 35*cdf0e10cSrcweir #endif 36*cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC 37*cdf0e10cSrcweir #include "dbustrings.hrc" 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir #ifndef _DBASHARED_APITOOLS_HXX_ 40*cdf0e10cSrcweir #include "apitools.hxx" 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_ 43*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir #ifndef _DBU_REGHELPER_HXX_ 46*cdf0e10cSrcweir #include "dbu_reghelper.hxx" 47*cdf0e10cSrcweir #endif 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_OColumnControl() 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OColumnControl> aAutoRegistration; 52*cdf0e10cSrcweir } 53*cdf0e10cSrcweir //......................................................................... 54*cdf0e10cSrcweir namespace dbaui 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir //......................................................................... 57*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 58*cdf0e10cSrcweir using namespace ::com::sun::star::awt; 59*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 60*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 61*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir OColumnControl::OColumnControl(const Reference<XMultiServiceFactory>& _rxFactory) 64*cdf0e10cSrcweir :UnoControl( _rxFactory ) 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir } 67*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 68*cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO2_STATIC(OColumnControl,SERVICE_CONTROLDEFAULT,"com.sun.star.awt.UnoControl","com.sun.star.sdb.ColumnDescriptorControl") 69*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 70*cdf0e10cSrcweir ::rtl::OUString OColumnControl::GetComponentServiceName() 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ColumnDescriptorControl")); 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 75*cdf0e10cSrcweir void SAL_CALL OColumnControl::createPeer(const Reference< XToolkit >& /*rToolkit*/, const Reference< XWindowPeer >& rParentPeer) throw( RuntimeException ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( GetMutex() ); 78*cdf0e10cSrcweir if ( !getPeer().is() ) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir mbCreatingPeer = sal_True; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir Window* pParentWin = NULL; 83*cdf0e10cSrcweir if (rParentPeer.is()) 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir VCLXWindow* pParent = VCLXWindow::GetImplementation(rParentPeer); 86*cdf0e10cSrcweir if (pParent) 87*cdf0e10cSrcweir pParentWin = pParent->GetWindow(); 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir OColumnPeer* pPeer = new OColumnPeer( pParentWin, maContext.getLegacyServiceFactory() ); 91*cdf0e10cSrcweir OSL_ENSURE(pPeer != NULL, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !"); 92*cdf0e10cSrcweir setPeer( pPeer ); 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir UnoControlComponentInfos aComponentInfos(maComponentInfos); 95*cdf0e10cSrcweir Reference< XGraphics > xGraphics( mxGraphics ); 96*cdf0e10cSrcweir Reference< XView > xV(getPeer(), UNO_QUERY); 97*cdf0e10cSrcweir Reference< XWindow > xW(getPeer(), UNO_QUERY); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir aGuard.clear(); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir updateFromModel(); 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir xV->setZoom( aComponentInfos.nZoomX, aComponentInfos.nZoomY ); 104*cdf0e10cSrcweir setPosSize( aComponentInfos.nX, aComponentInfos.nY, aComponentInfos.nWidth, aComponentInfos.nHeight, ::com::sun::star::awt::PosSize::POSSIZE ); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir Reference<XPropertySet> xProp(getModel(), UNO_QUERY); 107*cdf0e10cSrcweir if ( xProp.is() ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir Reference<XConnection> xCon(xProp->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY); 110*cdf0e10cSrcweir pPeer->setConnection(xCon); 111*cdf0e10cSrcweir Reference<XPropertySet> xColumn(xProp->getPropertyValue(PROPERTY_COLUMN),UNO_QUERY); 112*cdf0e10cSrcweir pPeer->setColumn(xColumn); 113*cdf0e10cSrcweir sal_Int32 nWidth = 50; 114*cdf0e10cSrcweir xProp->getPropertyValue(PROPERTY_EDIT_WIDTH) >>= nWidth; 115*cdf0e10cSrcweir pPeer->setEditWidth(nWidth); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir if (aComponentInfos.bVisible) 119*cdf0e10cSrcweir xW->setVisible(sal_True); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir if (!aComponentInfos.bEnable) 122*cdf0e10cSrcweir xW->setEnable(sal_False); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir if (maWindowListeners.getLength()) 125*cdf0e10cSrcweir xW->addWindowListener( &maWindowListeners ); 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir if (maFocusListeners.getLength()) 128*cdf0e10cSrcweir xW->addFocusListener( &maFocusListeners ); 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir if (maKeyListeners.getLength()) 131*cdf0e10cSrcweir xW->addKeyListener( &maKeyListeners ); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir if (maMouseListeners.getLength()) 134*cdf0e10cSrcweir xW->addMouseListener( &maMouseListeners ); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir if (maMouseMotionListeners.getLength()) 137*cdf0e10cSrcweir xW->addMouseMotionListener( &maMouseMotionListeners ); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir if (maPaintListeners.getLength()) 140*cdf0e10cSrcweir xW->addPaintListener( &maPaintListeners ); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir Reference< ::com::sun::star::awt::XView > xPeerView(getPeer(), UNO_QUERY); 143*cdf0e10cSrcweir xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY ); 144*cdf0e10cSrcweir xPeerView->setGraphics( xGraphics ); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir mbCreatingPeer = sal_False; 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir //......................................................................... 150*cdf0e10cSrcweir } // namespace dbaui 151*cdf0e10cSrcweir //......................................................................... 152