LibreOffice Module dbaccess (master) 1
ColumnControl.cxx
Go to the documentation of this file.
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 <strings.hxx>
23#include <vcl/window.hxx>
24#include <com/sun/star/awt/PosSize.hpp>
25
26extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
28 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& )
29{
30 return cppu::acquire(new ::dbaui::OColumnControl(context));
31}
32
33namespace dbaui
34{
35using namespace ::com::sun::star::uno;
36using namespace ::com::sun::star::awt;
37using namespace ::com::sun::star::beans;
38using namespace ::com::sun::star::lang;
39using namespace ::com::sun::star::sdbc;
40
42 : m_xContext(rxContext)
43{
44}
45
47{
49}
50sal_Bool SAL_CALL OColumnControl::supportsService(const OUString& _rServiceName)
51 {
52 const css::uno::Sequence< OUString > aSupported(getSupportedServiceNames());
53 for (const OUString& s : aSupported)
54 if (s == _rServiceName)
55 return true;
56
57 return false;
58 }
59css::uno::Sequence< OUString > SAL_CALL OColumnControl::getSupportedServiceNames()
60{
61 return { "com.sun.star.awt.UnoControl","com.sun.star.sdb.ColumnDescriptorControl" };
62}
63
65{
66 return "com.sun.star.sdb.ColumnDescriptorControl";
67}
68
69void SAL_CALL OColumnControl::createPeer(const Reference< XToolkit >& /*rToolkit*/, const Reference< XWindowPeer >& rParentPeer)
70{
71 ::osl::ClearableMutexGuard aGuard( GetMutex() );
72 if ( getPeer().is() )
73 return;
74
75 mbCreatingPeer = true;
76
77 vcl::Window* pParentWin = nullptr;
78 if (rParentPeer.is())
79 {
80 VCLXWindow* pParent = dynamic_cast<VCLXWindow*>(rParentPeer.get());
81 if (pParent)
82 pParentWin = pParent->GetWindow();
83 }
84
85 rtl::Reference<OColumnPeer> pPeer = new OColumnPeer( pParentWin, m_xContext );
86 OSL_ENSURE(pPeer != nullptr, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !");
87 setPeer( pPeer );
88
91 Reference< XView > xV(getPeer(), UNO_QUERY);
92 Reference< XWindow > xW(getPeer(), UNO_QUERY);
93
94 aGuard.clear();
95
97
98 xV->setZoom( aComponentInfos.nZoomX, aComponentInfos.nZoomY );
99 setPosSize( aComponentInfos.nX, aComponentInfos.nY, aComponentInfos.nWidth, aComponentInfos.nHeight, css::awt::PosSize::POSSIZE );
100
101 Reference<XPropertySet> xProp(getModel(), UNO_QUERY);
102 if ( xProp.is() )
103 {
104 Reference<XConnection> xCon(xProp->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
105 pPeer->setConnection(xCon);
106 Reference<XPropertySet> xColumn(xProp->getPropertyValue(PROPERTY_COLUMN),UNO_QUERY);
107 pPeer->setColumn(xColumn);
108 sal_Int32 nWidth = 50;
109 xProp->getPropertyValue(PROPERTY_EDIT_WIDTH) >>= nWidth;
110 pPeer->setEditWidth(nWidth);
111 }
112
113 if (aComponentInfos.bVisible)
114 xW->setVisible(true);
115
116 if (!aComponentInfos.bEnable)
117 xW->setEnable(false);
118
119 if (maWindowListeners.getLength())
120 xW->addWindowListener( &maWindowListeners );
121
122 if (maFocusListeners.getLength())
123 xW->addFocusListener( &maFocusListeners );
124
125 if (maKeyListeners.getLength())
126 xW->addKeyListener( &maKeyListeners );
127
128 if (maMouseListeners.getLength())
129 xW->addMouseListener( &maMouseListeners );
130
131 if (maMouseMotionListeners.getLength())
132 xW->addMouseMotionListener( &maMouseMotionListeners );
133
134 if (maPaintListeners.getLength())
135 xW->addPaintListener( &maPaintListeners );
136
137 Reference< css::awt::XView > xPeerView(getPeer(), UNO_QUERY);
138 xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY );
139 xPeerView->setGraphics( xGraphics );
140
141 mbCreatingPeer = false;
142}
143
144} // namespace dbaui
145
146/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_dbu_OColumnControl_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override
MouseListenerMultiplexer maMouseListeners
MouseMotionListenerMultiplexer maMouseMotionListeners
KeyListenerMultiplexer maKeyListeners
::osl::Mutex & GetMutex()
virtual void updateFromModel()
UnoControlComponentInfos maComponentInfos
FocusListenerMultiplexer maFocusListeners
void SAL_CALL setPosSize(sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags) override
css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer() override
OUString SAL_CALL getImplementationName() override
WindowListenerMultiplexer maWindowListeners
void setPeer(const css::uno::Reference< css::awt::XVclWindowPeer > &_xPeer)
PaintListenerMultiplexer maPaintListeners
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
css::uno::Reference< css::awt::XGraphics > mxGraphics
bool mbCreatingPeer
vcl::Window * GetWindow() const
virtual OUString GetComponentServiceName() const override
OColumnControl(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual void SAL_CALL createPeer(const css::uno::Reference< css::awt::XToolkit > &_rToolkit, const css::uno::Reference< css::awt::XWindowPeer > &Parent) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
Reference< XComponentContext > m_xContext
Reference< XColumn > xColumn
constexpr OUStringLiteral PROPERTY_COLUMN(u"Column")
constexpr OUStringLiteral SERVICE_CONTROLDEFAULT
Definition: strings.hxx:257
constexpr OUStringLiteral PROPERTY_ACTIVE_CONNECTION(u"ActiveConnection")
constexpr OUStringLiteral PROPERTY_EDIT_WIDTH(u"EditWidth")
unsigned char sal_Bool