LibreOffice Module dbaccess (master) 1
ColumnControlWindow.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
24#include <o3tl/safeint.hxx>
25#include <UITools.hxx>
26#include <core_resource.hxx>
27#include <strings.hrc>
28#include <com/sun/star/util/NumberFormatter.hpp>
29
30using namespace ::dbaui;
31using namespace ::com::sun::star::uno;
32using namespace ::com::sun::star::beans;
33using namespace ::com::sun::star::container;
34using namespace ::com::sun::star::util;
35using namespace ::com::sun::star::sdbc;
36using namespace ::com::sun::star::lang;
37
38OColumnControlTopLevel::OColumnControlTopLevel(vcl::Window* pParent,
39 const Reference<XComponentContext>& _rxContext)
40 : InterimItemWindow(pParent, "dbaccess/ui/colcontrolbox.ui", "ColControlBox")
42{
43}
44
46{
47 m_xControl.reset();
49}
50
52{
53 m_xControl->GrabFocus();
54}
55
56// OColumnControlWindow
58 const Reference<XComponentContext>& _rxContext)
59 : OFieldDescControl(pParent, nullptr)
60 , m_xContext(_rxContext)
61 , m_sTypeNames(DBA_RES(STR_TABLEDESIGN_DBFIELDTYPES))
62 , m_bAutoIncrementEnabled(true)
63{
65}
66
68{
69 switch(eType )
70 {
71 case tpFormat:
72 case tpDefault:
73 case tpColumnName:
74 break;
75 default:
77 }
78}
79
81{
82 switch(eType )
83 {
84 case tpFormat:
85 case tpDefault:
86 case tpColumnName:
87 break;
88 default:
90 }
91}
92
93void OColumnControlWindow::CellModified(sal_Int32 /*nRow*/, sal_uInt16 /*nColId*/ )
94{
96}
97
98css::lang::Locale OColumnControlWindow::GetLocale() const
99{
100 return m_aLocale;
101}
102
104{
105 if ( !m_xFormatter.is() )
106 try
107 {
108 Reference< XNumberFormatsSupplier > xSupplier(::dbtools::getNumberFormats(m_xConnection, true, m_xContext));
109
110 if ( xSupplier.is() )
111 {
112 // create a new formatter
113 m_xFormatter.set( NumberFormatter::create(m_xContext), UNO_QUERY_THROW);
114 m_xFormatter->attachNumberFormatsSupplier(xSupplier);
115 }
116 }
117 catch(Exception&)
118 {
119 }
120 return m_xFormatter;
121}
122
124{
125 return ( _nPos >= 0 && o3tl::make_unsigned(_nPos) < m_aDestTypeInfoIndex.size()) ? m_aDestTypeInfoIndex[_nPos]->second : TOTypeInfoSP();
126}
127
129{
130 return &m_aDestTypeInfo;
131}
132
134{
135 if ( m_xConnection.is() )
136 return m_xConnection->getMetaData();
138}
139
141{
142 return m_xConnection;
143}
144
146{
147 m_xConnection = _xCon;
148 m_xFormatter = nullptr;
149 m_aDestTypeInfoIndex.clear();
150 m_aDestTypeInfo.clear();
151
152 if ( m_xConnection.is() )
153 {
154 Init();
155
157 // read autoincrement value set in the datasource
159 }
160}
161
163{
165}
166
168{
170}
171
173{
174 if ( !m_pTypeInfo )
175 {
176 m_pTypeInfo = std::make_shared<OTypeInfo>();
177 m_pTypeInfo->aUIName = m_sTypeNames.getToken(TYPE_OTHER, ';');
178 }
179 return m_pTypeInfo;
180}
181
182/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void dispose() override
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
const LanguageTag & GetLanguageTag() const
std::unique_ptr< OColumnControlWindow > m_xControl
virtual void dispose() override
virtual void GetFocus() override
virtual css::uno::Reference< css::sdbc::XConnection > getConnection() override
TOTypeInfoSP const & getDefaultTyp() const
css::uno::Reference< css::sdbc::XConnection > m_xConnection
virtual void CellModified(sal_Int32 nRow, sal_uInt16 nColId) override
virtual OUString getAutoIncrementValue() const override
virtual void ActivateAggregate(EControlType eType) override
virtual css::lang::Locale GetLocale() const override
std::vector< OTypeInfoMap::iterator > m_aDestTypeInfoIndex
css::uno::Reference< css::util::XNumberFormatter > m_xFormatter
virtual bool isAutoIncrementValueEnabled() const override
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual css::uno::Reference< css::util::XNumberFormatter > GetFormatter() const override
OColumnControlWindow(weld::Container *pParent, const css::uno::Reference< css::uno::XComponentContext > &_rxContext)
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > getMetaData() override
virtual void DeactivateAggregate(EControlType eType) override
void setConnection(const css::uno::Reference< css::sdbc::XConnection > &_xCon)
virtual const OTypeInfoMap * getTypeInfo() const override
virtual void ActivateAggregate(EControlType eType)
virtual void DeactivateAggregate(EControlType eType)
Reference< XComponentContext > m_xContext
#define DBA_RES(id)
OUString eType
Definition: generalpage.cxx:78
@ Exception
std::multimap< DataTypeEnum, OExtendedTypeInfo * > OTypeInfoMap
void fillTypeInfo(const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, std::u16string_view _rsTypeNames, OTypeInfoMap &_rTypeInfoMap, std::vector< OTypeInfoMap::iterator > &_rTypeInfoIters)
fills a map and a vector with localized type names
const sal_uInt16 TYPE_OTHER
Definition: TypeInfo.hxx:60
void fillAutoIncrementValue(const css::uno::Reference< css::beans::XPropertySet > &_xDatasource, bool &_rAutoIncrementValueEnabled, OUString &_rsAutoIncrementValue)
fills the bool and string value with information out of the datasource info property
std::shared_ptr< OTypeInfo > TOTypeInfoSP
Definition: TypeInfo.hxx:99
EControlType
Definition: QEnumTypes.hxx:63
@ tpDefault
Definition: QEnumTypes.hxx:64
@ tpFormat
Definition: QEnumTypes.hxx:70
@ tpColumnName
Definition: QEnumTypes.hxx:73
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Reference< XNameAccess > m_xContainer
Definition: objectnames.cxx:80
Reference< XControl > m_xControl
sal_Int32 _nPos