1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_dbaccess.hxx" 26 #ifndef DBAUI_COLUMNCONTROL_HXX 27 #include "ColumnControl.hxx" 28 #endif 29 #ifndef DBAUI_COLUMNPEER_HXX 30 #include "ColumnPeer.hxx" 31 #endif 32 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC 33 #include "dbustrings.hrc" 34 #endif 35 #ifndef _DBASHARED_APITOOLS_HXX_ 36 #include "apitools.hxx" 37 #endif 38 #ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_ 39 #include <com/sun/star/awt/PosSize.hpp> 40 #endif 41 #ifndef _DBU_REGHELPER_HXX_ 42 #include "dbu_reghelper.hxx" 43 #endif 44 45 extern "C" void SAL_CALL createRegistryInfo_OColumnControl() 46 { 47 static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OColumnControl> aAutoRegistration; 48 } 49 //......................................................................... 50 namespace dbaui 51 { 52 //......................................................................... 53 using namespace ::com::sun::star::uno; 54 using namespace ::com::sun::star::awt; 55 using namespace ::com::sun::star::beans; 56 using namespace ::com::sun::star::lang; 57 using namespace ::com::sun::star::sdbc; 58 59 OColumnControl::OColumnControl(const Reference<XMultiServiceFactory>& _rxFactory) 60 :UnoControl( _rxFactory ) 61 { 62 } 63 // ----------------------------------------------------------------------------- 64 IMPLEMENT_SERVICE_INFO2_STATIC(OColumnControl,SERVICE_CONTROLDEFAULT,"com.sun.star.awt.UnoControl","com.sun.star.sdb.ColumnDescriptorControl") 65 // ----------------------------------------------------------------------------- 66 ::rtl::OUString OColumnControl::GetComponentServiceName() 67 { 68 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ColumnDescriptorControl")); 69 } 70 // ----------------------------------------------------------------------------- 71 void SAL_CALL OColumnControl::createPeer(const Reference< XToolkit >& /*rToolkit*/, const Reference< XWindowPeer >& rParentPeer) throw( RuntimeException ) 72 { 73 ::osl::ClearableMutexGuard aGuard( GetMutex() ); 74 if ( !getPeer().is() ) 75 { 76 mbCreatingPeer = sal_True; 77 78 Window* pParentWin = NULL; 79 if (rParentPeer.is()) 80 { 81 VCLXWindow* pParent = VCLXWindow::GetImplementation(rParentPeer); 82 if (pParent) 83 pParentWin = pParent->GetWindow(); 84 } 85 86 OColumnPeer* pPeer = new OColumnPeer( pParentWin, maContext.getLegacyServiceFactory() ); 87 OSL_ENSURE(pPeer != NULL, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !"); 88 setPeer( pPeer ); 89 90 UnoControlComponentInfos aComponentInfos(maComponentInfos); 91 Reference< XGraphics > xGraphics( mxGraphics ); 92 Reference< XView > xV(getPeer(), UNO_QUERY); 93 Reference< XWindow > xW(getPeer(), UNO_QUERY); 94 95 aGuard.clear(); 96 97 updateFromModel(); 98 99 xV->setZoom( aComponentInfos.nZoomX, aComponentInfos.nZoomY ); 100 setPosSize( aComponentInfos.nX, aComponentInfos.nY, aComponentInfos.nWidth, aComponentInfos.nHeight, ::com::sun::star::awt::PosSize::POSSIZE ); 101 102 Reference<XPropertySet> xProp(getModel(), UNO_QUERY); 103 if ( xProp.is() ) 104 { 105 Reference<XConnection> xCon(xProp->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY); 106 pPeer->setConnection(xCon); 107 Reference<XPropertySet> xColumn(xProp->getPropertyValue(PROPERTY_COLUMN),UNO_QUERY); 108 pPeer->setColumn(xColumn); 109 sal_Int32 nWidth = 50; 110 xProp->getPropertyValue(PROPERTY_EDIT_WIDTH) >>= nWidth; 111 pPeer->setEditWidth(nWidth); 112 } 113 114 if (aComponentInfos.bVisible) 115 xW->setVisible(sal_True); 116 117 if (!aComponentInfos.bEnable) 118 xW->setEnable(sal_False); 119 120 if (maWindowListeners.getLength()) 121 xW->addWindowListener( &maWindowListeners ); 122 123 if (maFocusListeners.getLength()) 124 xW->addFocusListener( &maFocusListeners ); 125 126 if (maKeyListeners.getLength()) 127 xW->addKeyListener( &maKeyListeners ); 128 129 if (maMouseListeners.getLength()) 130 xW->addMouseListener( &maMouseListeners ); 131 132 if (maMouseMotionListeners.getLength()) 133 xW->addMouseMotionListener( &maMouseMotionListeners ); 134 135 if (maPaintListeners.getLength()) 136 xW->addPaintListener( &maPaintListeners ); 137 138 Reference< ::com::sun::star::awt::XView > xPeerView(getPeer(), UNO_QUERY); 139 xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY ); 140 xPeerView->setGraphics( xGraphics ); 141 142 mbCreatingPeer = sal_False; 143 } 144 } 145 //......................................................................... 146 } // namespace dbaui 147 //......................................................................... 148