1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xfldui.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <tools/debug.hxx>
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <com/sun/star/container/XNameAccess.hpp>
38 #include <com/sun/star/sdbc/XDataSource.hpp>
39 #include <com/sun/star/sdbc/DataType.hpp>
40 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
41 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
42 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #include <comphelper/processfactory.hxx>
49 #include <wrtsh.hxx> // Actives Fenster
53 #include <swmodule.hxx>
56 using namespace ::com::sun::star::uno
;
57 using namespace ::com::sun::star::container
;
58 using namespace ::com::sun::star::lang
;
59 using namespace ::com::sun::star::sdb
;
60 using namespace ::com::sun::star::sdbc
;
61 using namespace ::com::sun::star::sdbcx
;
62 using namespace ::com::sun::star::beans
;
65 // ---------------------------------------------------------------------------
66 // This file contains all routines of the fldui directory, which must compile
67 // with exceptions. So we can reduce the code of the other files, which don't
68 // need any exception handling.
69 // ---------------------------------------------------------------------------
71 /*--------------------------------------------------------------------
72 Beschreibung: Ist das Datenbankfeld numerisch?
73 Anm: Im Fehlerfall wird TRUE returnt.
74 --------------------------------------------------------------------*/
76 BOOL
SwFldMgr::IsDBNumeric( const String
& rDBName
, const String
& rTblQryName
,
77 BOOL bIsTable
, const String
& rFldName
)
81 SwNewDBMgr
* pDBMgr
= pWrtShell
? pWrtShell
->GetNewDBMgr() :
82 ::GetActiveView()->GetWrtShell().GetNewDBMgr();
84 ::rtl::OUString
sSource(rDBName
);
85 Reference
< XConnection
> xConnection
=
86 pDBMgr
->RegisterConnection(sSource
);
88 if( !xConnection
.is() )
91 Reference
<XColumnsSupplier
> xColsSupplier
;
94 Reference
<XTablesSupplier
> xTSupplier
= Reference
<XTablesSupplier
>(xConnection
, UNO_QUERY
);
97 Reference
<XNameAccess
> xTbls
= xTSupplier
->getTables();
98 DBG_ASSERT(xTbls
->hasByName(rTblQryName
), "table not available anymore?");
101 Any aTable
= xTbls
->getByName(rTblQryName
);
102 Reference
<XPropertySet
> xPropSet
;
104 xColsSupplier
= Reference
<XColumnsSupplier
>(xPropSet
, UNO_QUERY
);
111 Reference
<XQueriesSupplier
> xQSupplier
= Reference
<XQueriesSupplier
>(xConnection
, UNO_QUERY
);
114 Reference
<XNameAccess
> xQueries
= xQSupplier
->getQueries();
115 DBG_ASSERT(xQueries
->hasByName(rTblQryName
), "table not available anymore?");
118 Any aQuery
= xQueries
->getByName(rTblQryName
);
119 Reference
<XPropertySet
> xPropSet
;
121 xColsSupplier
= Reference
<XColumnsSupplier
>(xPropSet
, UNO_QUERY
);
127 if(xColsSupplier
.is())
129 Reference
<XNameAccess
> xCols
;
132 xCols
= xColsSupplier
->getColumns();
136 DBG_ERROR("Exception in getColumns()");
138 if(xCols
.is() && xCols
->hasByName(rFldName
))
140 Any aCol
= xCols
->getByName(rFldName
);
141 Reference
<XPropertySet
> xCol
;
143 Any aType
= xCol
->getPropertyValue( UniString::CreateFromAscii("Type"));
144 sal_Int32 eDataType
= 0;
149 case DataType::BOOLEAN
:
150 case DataType::TINYINT
:
151 case DataType::SMALLINT
:
152 case DataType::INTEGER
:
153 case DataType::BIGINT
:
154 case DataType::FLOAT
:
156 case DataType::DOUBLE
:
157 case DataType::NUMERIC
:
158 case DataType::DECIMAL
:
161 case DataType::TIMESTAMP
:
164 case DataType::BINARY
:
165 case DataType::VARBINARY
:
166 case DataType::LONGVARBINARY
:
167 case DataType::SQLNULL
:
168 case DataType::OTHER
:
169 case DataType::OBJECT
:
170 case DataType::DISTINCT
:
171 case DataType::STRUCT
:
172 case DataType::ARRAY
:
177 case DataType::VARCHAR
:
178 case DataType::LONGVARCHAR
: