fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / uno / ColumnControl.cxx
blobfe7a24e969c6f08cbe88a952e817d2e2e773dc59
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "ColumnControl.hxx"
21 #include "ColumnPeer.hxx"
22 #include "dbustrings.hrc"
23 #include "uiservices.hxx"
24 #include "apitools.hxx"
25 #include <com/sun/star/awt/PosSize.hpp>
26 #include "dbu_reghelper.hxx"
27 #include <comphelper/processfactory.hxx>
29 extern "C" void SAL_CALL createRegistryInfo_OColumnControl()
31 static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OColumnControl> aAutoRegistration;
34 namespace dbaui
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::awt;
38 using namespace ::com::sun::star::beans;
39 using namespace ::com::sun::star::lang;
40 using namespace ::com::sun::star::sdbc;
42 OColumnControl::OColumnControl(const Reference<XComponentContext>& rxContext)
43 :UnoControl(), m_xContext(rxContext)
47 IMPLEMENT_SERVICE_INFO_IMPLNAME_STATIC(OColumnControl, SERVICE_CONTROLDEFAULT)
48 IMPLEMENT_SERVICE_INFO_SUPPORTS(OColumnControl)
49 IMPLEMENT_SERVICE_INFO_GETSUPPORTED2_STATIC(OColumnControl, "com.sun.star.awt.UnoControl","com.sun.star.sdb.ColumnDescriptorControl")
51 Reference< XInterface > SAL_CALL OColumnControl::Create(const Reference< XMultiServiceFactory >& _rxORB)
53 return static_cast< XServiceInfo* >(new OColumnControl(comphelper::getComponentContext(_rxORB)));
56 OUString OColumnControl::GetComponentServiceName()
58 return OUString("com.sun.star.sdb.ColumnDescriptorControl");
61 void SAL_CALL OColumnControl::createPeer(const Reference< XToolkit >& /*rToolkit*/, const Reference< XWindowPeer >& rParentPeer) throw( RuntimeException, std::exception )
63 ::osl::ClearableMutexGuard aGuard( GetMutex() );
64 if ( !getPeer().is() )
66 mbCreatingPeer = true;
68 vcl::Window* pParentWin = NULL;
69 if (rParentPeer.is())
71 VCLXWindow* pParent = VCLXWindow::GetImplementation(rParentPeer);
72 if (pParent)
73 pParentWin = pParent->GetWindow();
76 OColumnPeer* pPeer = new OColumnPeer( pParentWin, m_xContext );
77 OSL_ENSURE(pPeer != NULL, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !");
78 setPeer( pPeer );
80 UnoControlComponentInfos aComponentInfos(maComponentInfos);
81 Reference< XGraphics > xGraphics( mxGraphics );
82 Reference< XView > xV(getPeer(), UNO_QUERY);
83 Reference< XWindow > xW(getPeer(), UNO_QUERY);
85 aGuard.clear();
87 updateFromModel();
89 xV->setZoom( aComponentInfos.nZoomX, aComponentInfos.nZoomY );
90 setPosSize( aComponentInfos.nX, aComponentInfos.nY, aComponentInfos.nWidth, aComponentInfos.nHeight, ::com::sun::star::awt::PosSize::POSSIZE );
92 Reference<XPropertySet> xProp(getModel(), UNO_QUERY);
93 if ( xProp.is() )
95 Reference<XConnection> xCon(xProp->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
96 pPeer->setConnection(xCon);
97 Reference<XPropertySet> xColumn(xProp->getPropertyValue(PROPERTY_COLUMN),UNO_QUERY);
98 pPeer->setColumn(xColumn);
99 sal_Int32 nWidth = 50;
100 xProp->getPropertyValue(PROPERTY_EDIT_WIDTH) >>= nWidth;
101 pPeer->setEditWidth(nWidth);
104 if (aComponentInfos.bVisible)
105 xW->setVisible(sal_True);
107 if (!aComponentInfos.bEnable)
108 xW->setEnable(sal_False);
110 if (maWindowListeners.getLength())
111 xW->addWindowListener( &maWindowListeners );
113 if (maFocusListeners.getLength())
114 xW->addFocusListener( &maFocusListeners );
116 if (maKeyListeners.getLength())
117 xW->addKeyListener( &maKeyListeners );
119 if (maMouseListeners.getLength())
120 xW->addMouseListener( &maMouseListeners );
122 if (maMouseMotionListeners.getLength())
123 xW->addMouseMotionListener( &maMouseMotionListeners );
125 if (maPaintListeners.getLength())
126 xW->addPaintListener( &maPaintListeners );
128 Reference< ::com::sun::star::awt::XView > xPeerView(getPeer(), UNO_QUERY);
129 xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY );
130 xPeerView->setGraphics( xGraphics );
132 mbCreatingPeer = false;
136 } // namespace dbaui
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */