1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <strings.hxx>
24 #include <FieldDescriptions.hxx>
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(nullptr)
37 osl_atomic_increment( &m_refCount
);
39 VclPtrInstance
<OColumnControlTopLevel
> 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
<OColumnControlTopLevel
> pFieldControl
= GetAs
<OColumnControlTopLevel
>();
51 pFieldControl
->GetControl().setEditWidth(_nWidth
);
54 void OColumnPeer::setColumn(const Reference
< XPropertySet
>& _xColumn
)
56 SolarMutexGuard aGuard
;
58 VclPtr
<OColumnControlTopLevel
> pFieldControl
= GetAs
<OColumnControlTopLevel
>();
62 OColumnControlWindow
& rControl
= pFieldControl
->GetControl();
64 if ( m_pActFieldDescr
)
66 delete m_pActFieldDescr
;
67 m_pActFieldDescr
= nullptr;
73 sal_Int32 nPrecision
= 0;
74 bool bAutoIncrement
= false;
79 // get the properties from the column
80 _xColumn
->getPropertyValue(PROPERTY_TYPENAME
) >>= sTypeName
;
81 _xColumn
->getPropertyValue(PROPERTY_TYPE
) >>= nType
;
82 _xColumn
->getPropertyValue(PROPERTY_SCALE
) >>= nScale
;
83 _xColumn
->getPropertyValue(PROPERTY_PRECISION
) >>= nPrecision
;
84 _xColumn
->getPropertyValue(PROPERTY_ISAUTOINCREMENT
) >>= bAutoIncrement
;
86 catch(const Exception
&)
90 m_pActFieldDescr
= new OFieldDescription(_xColumn
,true);
93 TOTypeInfoSP pTypeInfo
= ::dbaui::getTypeInfoFromType(*rControl
.getTypeInfo(),nType
,sTypeName
,"x",nPrecision
,nScale
,bAutoIncrement
,bForce
);
95 pTypeInfo
= rControl
.getDefaultTyp();
97 m_pActFieldDescr
->FillFromTypeInfo(pTypeInfo
,true,false);
100 rControl
.DisplayData(m_pActFieldDescr
);
103 void OColumnPeer::setConnection(const Reference
< XConnection
>& _xCon
)
105 SolarMutexGuard aGuard
;
106 VclPtr
<OColumnControlTopLevel
> pFieldControl
= GetAs
<OColumnControlTopLevel
>();
108 pFieldControl
->GetControl().setConnection(_xCon
);
111 void OColumnPeer::setProperty( const OUString
& _rPropertyName
, const Any
& Value
)
113 SolarMutexGuard aGuard
;
115 if (_rPropertyName
== PROPERTY_COLUMN
)
117 Reference
<XPropertySet
> xProp(Value
,UNO_QUERY
);
120 else if (_rPropertyName
== PROPERTY_ACTIVE_CONNECTION
)
122 Reference
<XConnection
> xCon(Value
,UNO_QUERY
);
126 VCLXWindow::setProperty(_rPropertyName
,Value
);
129 Any
OColumnPeer::getProperty( const OUString
& _rPropertyName
)
132 VclPtr
<OColumnControlTopLevel
> pFieldControl
= GetAs
<OColumnControlTopLevel
>();
133 if (pFieldControl
&& _rPropertyName
== PROPERTY_COLUMN
)
137 else if (pFieldControl
&& _rPropertyName
== PROPERTY_ACTIVE_CONNECTION
)
139 aProp
<<= pFieldControl
->GetControl().getConnection();
142 aProp
= VCLXWindow::getProperty(_rPropertyName
);
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */