update dev300-m58
[ooovba.git] / dbaccess / source / ui / uno / ColumnControl.cxx
blob83113be65277545867b4f69406216387782ab20f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ColumnControl.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBAUI_COLUMNCONTROL_HXX
34 #include "ColumnControl.hxx"
35 #endif
36 #ifndef DBAUI_COLUMNPEER_HXX
37 #include "ColumnPeer.hxx"
38 #endif
39 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
40 #include "dbustrings.hrc"
41 #endif
42 #ifndef _DBASHARED_APITOOLS_HXX_
43 #include "apitools.hxx"
44 #endif
45 #ifndef _COM_SUN_STAR_AWT_POSSIZE_HPP_
46 #include <com/sun/star/awt/PosSize.hpp>
47 #endif
48 #ifndef _DBU_REGHELPER_HXX_
49 #include "dbu_reghelper.hxx"
50 #endif
52 extern "C" void SAL_CALL createRegistryInfo_OColumnControl()
54 static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OColumnControl> aAutoRegistration;
56 //.........................................................................
57 namespace dbaui
59 //.........................................................................
60 using namespace ::com::sun::star::uno;
61 using namespace ::com::sun::star::awt;
62 using namespace ::com::sun::star::beans;
63 using namespace ::com::sun::star::lang;
64 using namespace ::com::sun::star::sdbc;
66 OColumnControl::OColumnControl(const Reference<XMultiServiceFactory>& _rxFactory)
67 : m_xORB(_rxFactory)
70 // -----------------------------------------------------------------------------
71 IMPLEMENT_SERVICE_INFO2_STATIC(OColumnControl,SERVICE_CONTROLDEFAULT,"com.sun.star.awt.UnoControl","com.sun.star.sdb.ColumnDescriptorControl")
72 // -----------------------------------------------------------------------------
73 ::rtl::OUString OColumnControl::GetComponentServiceName()
75 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ColumnDescriptorControl"));
77 // -----------------------------------------------------------------------------
78 void SAL_CALL OColumnControl::createPeer(const Reference< XToolkit >& /*rToolkit*/, const Reference< XWindowPeer >& rParentPeer) throw( RuntimeException )
80 ::osl::ClearableMutexGuard aGuard( GetMutex() );
81 if ( !getPeer().is() )
83 mbCreatingPeer = sal_True;
85 Window* pParentWin = NULL;
86 if (rParentPeer.is())
88 VCLXWindow* pParent = VCLXWindow::GetImplementation(rParentPeer);
89 if (pParent)
90 pParentWin = pParent->GetWindow();
93 OColumnPeer* pPeer = new OColumnPeer(pParentWin,m_xORB);
94 OSL_ENSURE(pPeer != NULL, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !");
95 setPeer( pPeer );
97 UnoControlComponentInfos aComponentInfos(maComponentInfos);
98 Reference< XGraphics > xGraphics( mxGraphics );
99 Reference< XView > xV(getPeer(), UNO_QUERY);
100 Reference< XWindow > xW(getPeer(), UNO_QUERY);
102 aGuard.clear();
104 updateFromModel();
106 xV->setZoom( aComponentInfos.nZoomX, aComponentInfos.nZoomY );
107 setPosSize( aComponentInfos.nX, aComponentInfos.nY, aComponentInfos.nWidth, aComponentInfos.nHeight, ::com::sun::star::awt::PosSize::POSSIZE );
109 Reference<XPropertySet> xProp(getModel(), UNO_QUERY);
110 if ( xProp.is() )
112 Reference<XConnection> xCon(xProp->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
113 pPeer->setConnection(xCon);
114 Reference<XPropertySet> xColumn(xProp->getPropertyValue(PROPERTY_COLUMN),UNO_QUERY);
115 pPeer->setColumn(xColumn);
116 sal_Int32 nWidth = 50;
117 xProp->getPropertyValue(PROPERTY_EDIT_WIDTH) >>= nWidth;
118 pPeer->setEditWidth(nWidth);
121 if (aComponentInfos.bVisible)
122 xW->setVisible(sal_True);
124 if (!aComponentInfos.bEnable)
125 xW->setEnable(sal_False);
127 if (maWindowListeners.getLength())
128 xW->addWindowListener( &maWindowListeners );
130 if (maFocusListeners.getLength())
131 xW->addFocusListener( &maFocusListeners );
133 if (maKeyListeners.getLength())
134 xW->addKeyListener( &maKeyListeners );
136 if (maMouseListeners.getLength())
137 xW->addMouseListener( &maMouseListeners );
139 if (maMouseMotionListeners.getLength())
140 xW->addMouseMotionListener( &maMouseMotionListeners );
142 if (maPaintListeners.getLength())
143 xW->addPaintListener( &maPaintListeners );
145 Reference< ::com::sun::star::awt::XView > xPeerView(getPeer(), UNO_QUERY);
146 xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY );
147 xPeerView->setGraphics( xGraphics );
149 mbCreatingPeer = sal_False;
152 //.........................................................................
153 } // namespace dbaui
154 //.........................................................................