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 "ColumnControlWindow.hxx"
21 #include "FieldControls.hxx"
22 #include <unotools/syslocale.hxx>
23 #include <connectivity/dbtools.hxx>
24 #include "UITools.hxx"
25 #include "dbu_resource.hrc"
26 #include <comphelper/processfactory.hxx>
27 #include <com/sun/star/util/NumberFormatter.hpp>
29 using namespace ::dbaui
;
30 using namespace ::com::sun::star::uno
;
31 using namespace ::com::sun::star::beans
;
32 using namespace ::com::sun::star::container
;
33 using namespace ::com::sun::star::util
;
34 using namespace ::com::sun::star::sdbc
;
35 using namespace ::com::sun::star::lang
;
37 // OColumnControlWindow
38 OColumnControlWindow::OColumnControlWindow(vcl::Window
* pParent
39 ,const Reference
<XComponentContext
>& _rxContext
)
40 : OFieldDescControl(pParent
,NULL
)
41 , m_xContext(_rxContext
)
42 , m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES
))
43 , m_bAutoIncrementEnabled(true)
47 m_aLocale
= SvtSysLocale().GetLanguageTag().getLocale();
50 void OColumnControlWindow::ActivateAggregate( EControlType eType
)
59 OFieldDescControl::ActivateAggregate( eType
);
63 void OColumnControlWindow::DeactivateAggregate( EControlType eType
)
72 OFieldDescControl::DeactivateAggregate( eType
);
76 void OColumnControlWindow::CellModified(long /*nRow*/, sal_uInt16
/*nColId*/ )
78 saveCurrentFieldDescData();
81 ::com::sun::star::lang::Locale
OColumnControlWindow::GetLocale() const
86 Reference
< XNumberFormatter
> OColumnControlWindow::GetFormatter() const
88 if ( !m_xFormatter
.is() )
91 Reference
< XNumberFormatsSupplier
> xSupplier(::dbtools::getNumberFormats(m_xConnection
, true, m_xContext
));
95 // create a new formatter
96 m_xFormatter
.set( NumberFormatter::create(m_xContext
), UNO_QUERY_THROW
);
97 m_xFormatter
->attachNumberFormatsSupplier(xSupplier
);
106 TOTypeInfoSP
OColumnControlWindow::getTypeInfo(sal_Int32 _nPos
)
108 return ( _nPos
>= 0 && _nPos
< static_cast<sal_Int32
>(m_aDestTypeInfoIndex
.size())) ? m_aDestTypeInfoIndex
[_nPos
]->second
: TOTypeInfoSP();
111 const OTypeInfoMap
* OColumnControlWindow::getTypeInfo() const
113 return &m_aDestTypeInfo
;
116 Reference
< XDatabaseMetaData
> OColumnControlWindow::getMetaData()
118 if ( m_xConnection
.is() )
119 return m_xConnection
->getMetaData();
120 return Reference
< XDatabaseMetaData
>();
123 Reference
< XConnection
> OColumnControlWindow::getConnection()
125 return m_xConnection
;
128 void OColumnControlWindow::setConnection(const Reference
< XConnection
>& _xCon
)
130 m_xConnection
= _xCon
;
132 m_aDestTypeInfoIndex
.clear();
133 m_aDestTypeInfo
.clear();
135 if ( m_xConnection
.is() )
139 ::dbaui::fillTypeInfo(m_xConnection
,m_sTypeNames
,m_aDestTypeInfo
,m_aDestTypeInfoIndex
);
140 // read autoincrement value set in the datasource
141 ::dbaui::fillAutoIncrementValue(m_xConnection
,m_bAutoIncrementEnabled
,m_sAutoIncrementValue
);
145 bool OColumnControlWindow::isAutoIncrementValueEnabled() const
147 return m_bAutoIncrementEnabled
;
150 OUString
OColumnControlWindow::getAutoIncrementValue() const
152 return m_sAutoIncrementValue
;
155 TOTypeInfoSP
OColumnControlWindow::getDefaultTyp() const
157 if ( !m_pTypeInfo
.get() )
159 m_pTypeInfo
= TOTypeInfoSP(new OTypeInfo());
160 m_pTypeInfo
->aUIName
= m_sTypeNames
.getToken(TYPE_OTHER
, ';');
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */