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