fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / uno / ColumnPeer.cxx
blob7a32f0b175f6f3af9f9281e639c9586317fc71a7
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 "ColumnPeer.hxx"
21 #include "ColumnControlWindow.hxx"
22 #include <vcl/svapp.hxx>
23 #include "dbustrings.hrc"
24 #include "FieldDescriptions.hxx"
26 namespace dbaui
28 using namespace ::com::sun::star::awt;
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::beans;
31 using namespace ::com::sun::star::lang;
32 using namespace ::com::sun::star::sdbc;
34 OColumnPeer::OColumnPeer(vcl::Window* _pParent,const Reference<XComponentContext>& _rxContext)
35 :m_pActFieldDescr(NULL)
37 osl_atomic_increment( &m_refCount );
39 VclPtrInstance<OColumnControlWindow> pFieldControl(_pParent, _rxContext);
40 pFieldControl->SetComponentInterface(this);
41 pFieldControl->Show();
43 osl_atomic_decrement( &m_refCount );
46 void OColumnPeer::setEditWidth(sal_Int32 _nWidth)
48 SolarMutexGuard aGuard;
49 VclPtr<OColumnControlWindow> pFieldControl = GetAs<OColumnControlWindow>();
50 if ( pFieldControl )
51 pFieldControl->setEditWidth(_nWidth);
54 void OColumnPeer::setColumn(const Reference< XPropertySet>& _xColumn)
56 SolarMutexGuard aGuard;
58 VclPtr<OColumnControlWindow> pFieldControl = GetAs<OColumnControlWindow>();
59 if ( pFieldControl )
61 if ( m_pActFieldDescr )
63 delete m_pActFieldDescr;
64 m_pActFieldDescr = NULL;
66 if ( _xColumn.is() )
68 sal_Int32 nType = 0;
69 sal_Int32 nScale = 0;
70 sal_Int32 nPrecision = 0;
71 bool bAutoIncrement = false;
72 OUString sTypeName;
74 try
76 // get the properties from the column
77 _xColumn->getPropertyValue(PROPERTY_TYPENAME) >>= sTypeName;
78 _xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType;
79 _xColumn->getPropertyValue(PROPERTY_SCALE) >>= nScale;
80 _xColumn->getPropertyValue(PROPERTY_PRECISION) >>= nPrecision;
81 _xColumn->getPropertyValue(PROPERTY_ISAUTOINCREMENT) >>= bAutoIncrement;
83 catch(const Exception&)
87 m_pActFieldDescr = new OFieldDescription(_xColumn,true);
88 // search for type
89 OUString sCreateParam("x");
90 bool bForce;
91 TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(*pFieldControl->getTypeInfo(),nType,sTypeName,sCreateParam,nPrecision,nScale,bAutoIncrement,bForce);
92 if ( !pTypeInfo.get() )
93 pTypeInfo = pFieldControl->getDefaultTyp();
95 m_pActFieldDescr->FillFromTypeInfo(pTypeInfo,true,false);
96 m_xColumn = _xColumn;
98 pFieldControl->DisplayData(m_pActFieldDescr);
102 void OColumnPeer::setConnection(const Reference< XConnection>& _xCon)
104 SolarMutexGuard aGuard;
105 VclPtr<OColumnControlWindow> pFieldControl = GetAs<OColumnControlWindow>();
106 if ( pFieldControl )
107 pFieldControl->setConnection(_xCon);
110 void OColumnPeer::setProperty( const OUString& _rPropertyName, const Any& Value) throw( RuntimeException, std::exception )
112 SolarMutexGuard aGuard;
114 if (_rPropertyName == PROPERTY_COLUMN)
116 Reference<XPropertySet> xProp(Value,UNO_QUERY);
117 setColumn(xProp);
119 else if (_rPropertyName == PROPERTY_ACTIVE_CONNECTION)
121 Reference<XConnection> xCon(Value,UNO_QUERY);
122 setConnection(xCon);
124 else
125 VCLXWindow::setProperty(_rPropertyName,Value);
128 Any OColumnPeer::getProperty( const OUString& _rPropertyName ) throw( RuntimeException, std::exception )
130 Any aProp;
131 VclPtr< OFieldDescControl > pFieldControl = GetAs< OFieldDescControl >();
132 if (pFieldControl && _rPropertyName == PROPERTY_COLUMN)
134 aProp <<= m_xColumn;
136 else if (pFieldControl && _rPropertyName == PROPERTY_ACTIVE_CONNECTION)
138 aProp <<= pFieldControl->getConnection();
140 else
141 aProp = VCLXWindow::getProperty(_rPropertyName);
142 return aProp;
145 } // namespace dbaui
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */