Branch data Line data Source code
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 "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 : :
27 : :
28 : : using namespace ::dbaui;
29 : : using namespace ::com::sun::star::uno;
30 : : using namespace ::com::sun::star::beans;
31 : : using namespace ::com::sun::star::container;
32 : : using namespace ::com::sun::star::util;
33 : : using namespace ::com::sun::star::sdbc;
34 : : using namespace ::com::sun::star::lang;
35 : :
36 : : //========================================================================
37 : : // OColumnControlWindow
38 : : DBG_NAME(OColumnControlWindow)
39 : : //========================================================================
40 : 0 : OColumnControlWindow::OColumnControlWindow(Window* pParent
41 : : ,const Reference<XMultiServiceFactory>& _rxFactory)
42 : : : OFieldDescControl(pParent,NULL)
43 : : , m_xORB(_rxFactory)
44 : : , m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES))
45 [ # # ][ # # ]: 0 : , m_bAutoIncrementEnabled(sal_True)
[ # # ][ # # ]
[ # # ]
46 : : {
47 : : DBG_CTOR(OColumnControlWindow,NULL);
48 : :
49 : 0 : setRightAligned();
50 [ # # ][ # # ]: 0 : m_aLocale = SvtSysLocale().GetLocaleData().getLocale();
[ # # ][ # # ]
51 : 0 : }
52 : : // -----------------------------------------------------------------------------
53 [ # # ][ # # ]: 0 : OColumnControlWindow::~OColumnControlWindow()
54 : : {
55 : :
56 : : DBG_DTOR(OColumnControlWindow,NULL);
57 [ # # ]: 0 : }
58 : : // -----------------------------------------------------------------------
59 : 0 : void OColumnControlWindow::ActivateAggregate( EControlType eType )
60 : : {
61 [ # # ]: 0 : switch(eType )
62 : : {
63 : : case tpFormat:
64 : : case tpDefault:
65 : : case tpColumnName:
66 : 0 : break;
67 : : default:
68 : 0 : OFieldDescControl::ActivateAggregate( eType );
69 : : }
70 : 0 : }
71 : : // -----------------------------------------------------------------------
72 : 0 : void OColumnControlWindow::DeactivateAggregate( EControlType eType )
73 : : {
74 [ # # ]: 0 : switch(eType )
75 : : {
76 : : case tpFormat:
77 : : case tpDefault:
78 : : case tpColumnName:
79 : 0 : break;
80 : : default:
81 : 0 : OFieldDescControl::DeactivateAggregate( eType );
82 : : }
83 : 0 : }
84 : : // -----------------------------------------------------------------------------
85 : 0 : void OColumnControlWindow::CellModified(long /*nRow*/, sal_uInt16 /*nColId*/ )
86 : : {
87 : 0 : saveCurrentFieldDescData();
88 : 0 : }
89 : : // -----------------------------------------------------------------------------
90 : 0 : ::com::sun::star::lang::Locale OColumnControlWindow::GetLocale() const
91 : : {
92 : 0 : return m_aLocale;
93 : : }
94 : : // -----------------------------------------------------------------------------
95 : 0 : Reference< XNumberFormatter > OColumnControlWindow::GetFormatter() const
96 : : {
97 [ # # ]: 0 : if ( !m_xFormatter.is() )
98 : : try
99 : : {
100 [ # # ]: 0 : Reference< XNumberFormatsSupplier > xSupplier(::dbtools::getNumberFormats(m_xConnection, sal_True,m_xORB));
101 : :
102 [ # # ]: 0 : if ( xSupplier.is() )
103 : : {
104 : : // create a new formatter
105 [ # # ][ # # ]: 0 : m_xFormatter.set( m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY);
[ # # ][ # # ]
106 [ # # ]: 0 : if (m_xFormatter.is())
107 [ # # ][ # # ]: 0 : m_xFormatter->attachNumberFormatsSupplier(xSupplier);
108 [ # # ]: 0 : }
109 : : }
110 : 0 : catch(Exception&)
111 : : {
112 : : }
113 : 0 : return m_xFormatter;
114 : : }
115 : : // -----------------------------------------------------------------------------
116 : 0 : TOTypeInfoSP OColumnControlWindow::getTypeInfo(sal_Int32 _nPos)
117 : : {
118 [ # # ][ # # ]: 0 : return ( _nPos >= 0 && _nPos < static_cast<sal_Int32>(m_aDestTypeInfoIndex.size())) ? m_aDestTypeInfoIndex[_nPos]->second : TOTypeInfoSP();
119 : : }
120 : : // -----------------------------------------------------------------------------
121 : 0 : const OTypeInfoMap* OColumnControlWindow::getTypeInfo() const
122 : : {
123 : 0 : return &m_aDestTypeInfo;
124 : : }
125 : : // -----------------------------------------------------------------------------
126 : 0 : Reference< XDatabaseMetaData> OColumnControlWindow::getMetaData()
127 : : {
128 [ # # ]: 0 : if ( m_xConnection.is() )
129 : 0 : return m_xConnection->getMetaData();
130 : 0 : return Reference< XDatabaseMetaData>();
131 : : }
132 : : // -----------------------------------------------------------------------------
133 : 0 : Reference< XConnection> OColumnControlWindow::getConnection()
134 : : {
135 : 0 : return m_xConnection;
136 : : }
137 : : // -----------------------------------------------------------------------------
138 : 0 : void OColumnControlWindow::setConnection(const Reference< XConnection>& _xCon)
139 : : {
140 : 0 : m_xConnection = _xCon;
141 : 0 : m_xFormatter = NULL;
142 : 0 : m_aDestTypeInfoIndex.clear();
143 : 0 : m_aDestTypeInfo.clear();
144 : :
145 [ # # ]: 0 : if ( m_xConnection.is() )
146 : : {
147 : 0 : Init();
148 : :
149 : 0 : ::dbaui::fillTypeInfo(m_xConnection,m_sTypeNames,m_aDestTypeInfo,m_aDestTypeInfoIndex);
150 : : // read autoincrement value set in the datasource
151 : 0 : ::dbaui::fillAutoIncrementValue(m_xConnection,m_bAutoIncrementEnabled,m_sAutoIncrementValue);
152 : : }
153 : 0 : }
154 : : // -----------------------------------------------------------------------------
155 : 0 : sal_Bool OColumnControlWindow::isAutoIncrementValueEnabled() const
156 : : {
157 : 0 : return m_bAutoIncrementEnabled;
158 : : }
159 : : // -----------------------------------------------------------------------------
160 : 0 : ::rtl::OUString OColumnControlWindow::getAutoIncrementValue() const
161 : : {
162 : 0 : return m_sAutoIncrementValue;
163 : : }
164 : : // -----------------------------------------------------------------------------
165 : 0 : TOTypeInfoSP OColumnControlWindow::getDefaultTyp() const
166 : : {
167 [ # # ]: 0 : if ( !m_pTypeInfo.get() )
168 : : {
169 [ # # ]: 0 : m_pTypeInfo = TOTypeInfoSP(new OTypeInfo());
170 [ # # ]: 0 : m_pTypeInfo->aUIName = m_sTypeNames.GetToken(TYPE_OTHER);
171 : : }
172 : 0 : return m_pTypeInfo;
173 : : }
174 : : // -----------------------------------------------------------------------------
175 : :
176 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|