Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "ColumnControl.hxx"
21 : #include "ColumnPeer.hxx"
22 : #include "dbustrings.hrc"
23 : #include "apitools.hxx"
24 : #include <com/sun/star/awt/PosSize.hpp>
25 : #include "dbu_reghelper.hxx"
26 :
27 0 : extern "C" void SAL_CALL createRegistryInfo_OColumnControl()
28 : {
29 0 : static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OColumnControl> aAutoRegistration;
30 0 : }
31 : //.........................................................................
32 : namespace dbaui
33 : {
34 : //.........................................................................
35 : using namespace ::com::sun::star::uno;
36 : using namespace ::com::sun::star::awt;
37 : using namespace ::com::sun::star::beans;
38 : using namespace ::com::sun::star::lang;
39 : using namespace ::com::sun::star::sdbc;
40 :
41 0 : OColumnControl::OColumnControl(const Reference<XMultiServiceFactory>& _rxFactory)
42 0 : :UnoControl( _rxFactory )
43 : {
44 0 : }
45 : // -----------------------------------------------------------------------------
46 0 : IMPLEMENT_SERVICE_INFO2_STATIC(OColumnControl,SERVICE_CONTROLDEFAULT.ascii,"com.sun.star.awt.UnoControl","com.sun.star.sdb.ColumnDescriptorControl")
47 : // -----------------------------------------------------------------------------
48 0 : ::rtl::OUString OColumnControl::GetComponentServiceName()
49 : {
50 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ColumnDescriptorControl"));
51 : }
52 : // -----------------------------------------------------------------------------
53 0 : void SAL_CALL OColumnControl::createPeer(const Reference< XToolkit >& /*rToolkit*/, const Reference< XWindowPeer >& rParentPeer) throw( RuntimeException )
54 : {
55 0 : ::osl::ClearableMutexGuard aGuard( GetMutex() );
56 0 : if ( !getPeer().is() )
57 : {
58 0 : mbCreatingPeer = sal_True;
59 :
60 0 : Window* pParentWin = NULL;
61 0 : if (rParentPeer.is())
62 : {
63 0 : VCLXWindow* pParent = VCLXWindow::GetImplementation(rParentPeer);
64 0 : if (pParent)
65 0 : pParentWin = pParent->GetWindow();
66 : }
67 :
68 0 : OColumnPeer* pPeer = new OColumnPeer( pParentWin, maContext.getUNOContext() );
69 : OSL_ENSURE(pPeer != NULL, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !");
70 0 : setPeer( pPeer );
71 :
72 0 : UnoControlComponentInfos aComponentInfos(maComponentInfos);
73 0 : Reference< XGraphics > xGraphics( mxGraphics );
74 0 : Reference< XView > xV(getPeer(), UNO_QUERY);
75 0 : Reference< XWindow > xW(getPeer(), UNO_QUERY);
76 :
77 0 : aGuard.clear();
78 :
79 0 : updateFromModel();
80 :
81 0 : xV->setZoom( aComponentInfos.nZoomX, aComponentInfos.nZoomY );
82 0 : setPosSize( aComponentInfos.nX, aComponentInfos.nY, aComponentInfos.nWidth, aComponentInfos.nHeight, ::com::sun::star::awt::PosSize::POSSIZE );
83 :
84 0 : Reference<XPropertySet> xProp(getModel(), UNO_QUERY);
85 0 : if ( xProp.is() )
86 : {
87 0 : Reference<XConnection> xCon(xProp->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
88 0 : pPeer->setConnection(xCon);
89 0 : Reference<XPropertySet> xColumn(xProp->getPropertyValue(PROPERTY_COLUMN),UNO_QUERY);
90 0 : pPeer->setColumn(xColumn);
91 0 : sal_Int32 nWidth = 50;
92 0 : xProp->getPropertyValue(PROPERTY_EDIT_WIDTH) >>= nWidth;
93 0 : pPeer->setEditWidth(nWidth);
94 : }
95 :
96 0 : if (aComponentInfos.bVisible)
97 0 : xW->setVisible(sal_True);
98 :
99 0 : if (!aComponentInfos.bEnable)
100 0 : xW->setEnable(sal_False);
101 :
102 0 : if (maWindowListeners.getLength())
103 0 : xW->addWindowListener( &maWindowListeners );
104 :
105 0 : if (maFocusListeners.getLength())
106 0 : xW->addFocusListener( &maFocusListeners );
107 :
108 0 : if (maKeyListeners.getLength())
109 0 : xW->addKeyListener( &maKeyListeners );
110 :
111 0 : if (maMouseListeners.getLength())
112 0 : xW->addMouseListener( &maMouseListeners );
113 :
114 0 : if (maMouseMotionListeners.getLength())
115 0 : xW->addMouseMotionListener( &maMouseMotionListeners );
116 :
117 0 : if (maPaintListeners.getLength())
118 0 : xW->addPaintListener( &maPaintListeners );
119 :
120 0 : Reference< ::com::sun::star::awt::XView > xPeerView(getPeer(), UNO_QUERY);
121 0 : xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY );
122 0 : xPeerView->setGraphics( xGraphics );
123 :
124 0 : mbCreatingPeer = sal_False;
125 0 : }
126 0 : }
127 : //.........................................................................
128 : } // namespace dbaui
129 : //.........................................................................
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|