1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #ifndef DBAUI_TOOLS_HXX 32*cdf0e10cSrcweir #include "UITools.hxx" 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir #ifndef _SFX_DOCFILT_HACK_HXX 35*cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 36*cdf0e10cSrcweir #endif 37*cdf0e10cSrcweir #ifndef _DBACCESS_UI_CALLBACKS_HXX_ 38*cdf0e10cSrcweir #include "callbacks.hxx" 39*cdf0e10cSrcweir #endif 40*cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC 41*cdf0e10cSrcweir #include "dbustrings.hrc" 42*cdf0e10cSrcweir #endif 43*cdf0e10cSrcweir #ifndef _DBU_RESOURCE_HRC_ 44*cdf0e10cSrcweir #include "dbu_resource.hrc" 45*cdf0e10cSrcweir #endif 46*cdf0e10cSrcweir #ifndef DBAUI_DLGSAVE_HXX 47*cdf0e10cSrcweir #include "dlgsave.hxx" 48*cdf0e10cSrcweir #endif 49*cdf0e10cSrcweir #ifndef DBAUI_DBTREELISTBOX_HXX 50*cdf0e10cSrcweir #include "dbtreelistbox.hxx" 51*cdf0e10cSrcweir #endif 52*cdf0e10cSrcweir #ifndef DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX 53*cdf0e10cSrcweir #include "defaultobjectnamecheck.hxx" 54*cdf0e10cSrcweir #endif 55*cdf0e10cSrcweir #ifndef _COMPHELPER_EXTRACT_HXX_ 56*cdf0e10cSrcweir #include <comphelper/extract.hxx> 57*cdf0e10cSrcweir #endif 58*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYANALYZER_HPP_ 59*cdf0e10cSrcweir #include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp> 60*cdf0e10cSrcweir #endif 61*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_ 62*cdf0e10cSrcweir #include <com/sun/star/sdb/XCompletedConnection.hpp> 63*cdf0e10cSrcweir #endif 64*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_ 65*cdf0e10cSrcweir #include <com/sun/star/sdbc/XDataSource.hpp> 66*cdf0e10cSrcweir #endif 67*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ 68*cdf0e10cSrcweir #include <com/sun/star/sdb/SQLContext.hpp> 69*cdf0e10cSrcweir #endif 70*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_ 71*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XKeysSupplier.hpp> 72*cdf0e10cSrcweir #endif 73*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ 74*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> 75*cdf0e10cSrcweir #endif 76*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_ 77*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XViewsSupplier.hpp> 78*cdf0e10cSrcweir #endif 79*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ 80*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp> 81*cdf0e10cSrcweir #endif 82*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ 83*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> 84*cdf0e10cSrcweir #endif 85*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ 86*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XAppend.hpp> 87*cdf0e10cSrcweir #endif 88*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ 89*cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 90*cdf0e10cSrcweir #endif 91*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ 92*cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> 93*cdf0e10cSrcweir #endif 94*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_ 95*cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaData.hpp> 96*cdf0e10cSrcweir #endif 97*cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp> 98*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ 99*cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp> 100*cdf0e10cSrcweir #endif 101*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_ 102*cdf0e10cSrcweir #include <com/sun/star/ucb/XContent.hpp> 103*cdf0e10cSrcweir #endif 104*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UI_DIALOGS_XEXECUTABLEDIALOG_HPP_ 105*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 106*cdf0e10cSrcweir #endif 107*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ 108*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 109*cdf0e10cSrcweir #endif 110*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ 111*cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp> 112*cdf0e10cSrcweir #endif 113*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ 114*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp> 115*cdf0e10cSrcweir #endif 116*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_INTERACTIVEIOEXCEPTION_HPP_ 117*cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveIOException.hpp> 118*cdf0e10cSrcweir #endif 119*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_ 120*cdf0e10cSrcweir #include <com/sun/star/sdb/XDocumentDataSource.hpp> 121*cdf0e10cSrcweir #endif 122*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_IOERRORCODE_HPP_ 123*cdf0e10cSrcweir #include <com/sun/star/ucb/IOErrorCode.hpp> 124*cdf0e10cSrcweir #endif 125*cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 126*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 127*cdf0e10cSrcweir #endif 128*cdf0e10cSrcweir #ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_ 129*cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx> 130*cdf0e10cSrcweir #endif 131*cdf0e10cSrcweir #ifndef _VCL_STDTEXT_HXX 132*cdf0e10cSrcweir #include <vcl/stdtext.hxx> 133*cdf0e10cSrcweir #endif 134*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_ 135*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp> 136*cdf0e10cSrcweir #endif 137*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ 138*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 139*cdf0e10cSrcweir #endif 140*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ 141*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 142*cdf0e10cSrcweir #endif 143*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_ 144*cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp> 145*cdf0e10cSrcweir #endif 146*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMECONTAINER_HPP_ 147*cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameContainer.hpp> 148*cdf0e10cSrcweir #endif 149*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ 150*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 151*cdf0e10cSrcweir #endif 152*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_TEXTALIGN_HPP_ 153*cdf0e10cSrcweir #include <com/sun/star/awt/TextAlign.hpp> 154*cdf0e10cSrcweir #endif 155*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_FONTDESCRIPTOR_HPP_ 156*cdf0e10cSrcweir #include <com/sun/star/awt/FontDescriptor.hpp> 157*cdf0e10cSrcweir #endif 158*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_FONTWEIGHT_HPP_ 159*cdf0e10cSrcweir #include <com/sun/star/awt/FontWeight.hpp> 160*cdf0e10cSrcweir #endif 161*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_FONTRELIEF_HPP_ 162*cdf0e10cSrcweir #include <com/sun/star/awt/FontRelief.hpp> 163*cdf0e10cSrcweir #endif 164*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_FONTWIDTH_HPP_ 165*cdf0e10cSrcweir #include <com/sun/star/awt/FontWidth.hpp> 166*cdf0e10cSrcweir #endif 167*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ 168*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 169*cdf0e10cSrcweir #endif 170*cdf0e10cSrcweir #ifndef DBAUI_SBATTRDLG_HRC 171*cdf0e10cSrcweir #include "dlgattr.hrc" 172*cdf0e10cSrcweir #endif 173*cdf0e10cSrcweir #ifndef DBAUI_TYPEINFO_HXX 174*cdf0e10cSrcweir #include "TypeInfo.hxx" 175*cdf0e10cSrcweir #endif 176*cdf0e10cSrcweir #ifndef DBAUI_FIELDDESCRIPTIONS_HXX 177*cdf0e10cSrcweir #include "FieldDescriptions.hxx" 178*cdf0e10cSrcweir #endif 179*cdf0e10cSrcweir #ifndef _COMPHELPER_STLTYPES_HXX_ 180*cdf0e10cSrcweir #include <comphelper/stl_types.hxx> 181*cdf0e10cSrcweir #endif 182*cdf0e10cSrcweir #ifndef COMPHELPER_COMPONENTCONTEXT_HXX 183*cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 184*cdf0e10cSrcweir #endif 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC 187*cdf0e10cSrcweir #include <svx/svxids.hrc> 188*cdf0e10cSrcweir #endif 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir #define ITEMID_HORJUSTIFY SID_ATTR_ALIGN_HOR_JUSTIFY 191*cdf0e10cSrcweir #define ITEMID_VERJUSTIFY SID_ATTR_ALIGN_VER_JUSTIFY 192*cdf0e10cSrcweir //#define ITEMID_ORIENTATION SID_ATTR_ALIGN_ORIENTATION 193*cdf0e10cSrcweir #define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK 194*cdf0e10cSrcweir #define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN 195*cdf0e10cSrcweir #define ITEMID_NUMBERINFO SID_ATTR_NUMBERFORMAT_INFO 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir #ifndef _SFXITEMPOOL_HXX 198*cdf0e10cSrcweir #include <svl/itempool.hxx> 199*cdf0e10cSrcweir #endif 200*cdf0e10cSrcweir #ifndef _STRING_HXX 201*cdf0e10cSrcweir #include <tools/string.hxx> 202*cdf0e10cSrcweir #endif 203*cdf0e10cSrcweir #ifndef _DBA_DBACCESS_HELPID_HRC_ 204*cdf0e10cSrcweir #include "dbaccess_helpid.hrc" 205*cdf0e10cSrcweir #endif 206*cdf0e10cSrcweir #ifndef _SFXITEMSET_HXX //autogen wg. SfxItemSet 207*cdf0e10cSrcweir #include <svl/itemset.hxx> 208*cdf0e10cSrcweir #endif 209*cdf0e10cSrcweir #ifndef DBACCESS_SBA_GRID_HRC 210*cdf0e10cSrcweir #include "sbagrid.hrc" 211*cdf0e10cSrcweir #endif 212*cdf0e10cSrcweir #ifndef _SFXRNGITEM_HXX 213*cdf0e10cSrcweir #include <svl/rngitem.hxx> 214*cdf0e10cSrcweir #endif 215*cdf0e10cSrcweir #ifndef _SFXINTITEM_HXX 216*cdf0e10cSrcweir #include <svl/intitem.hxx> 217*cdf0e10cSrcweir #endif 218*cdf0e10cSrcweir #ifndef _SVX_ALGITEM_HXX 219*cdf0e10cSrcweir #include <svx/algitem.hxx> 220*cdf0e10cSrcweir #endif 221*cdf0e10cSrcweir #ifndef _SVX_NUMINF_HXX 222*cdf0e10cSrcweir #include <svx/numinf.hxx> 223*cdf0e10cSrcweir #endif 224*cdf0e10cSrcweir #define _ZFORLIST_DECLARE_TABLE 225*cdf0e10cSrcweir #ifndef _SVX_NUMINF_HXX 226*cdf0e10cSrcweir #include <svx/numinf.hxx> 227*cdf0e10cSrcweir #endif 228*cdf0e10cSrcweir #ifndef _ZFORLIST_HXX 229*cdf0e10cSrcweir #include <svl/zforlist.hxx> 230*cdf0e10cSrcweir #endif 231*cdf0e10cSrcweir #ifndef DBAUI_SBATTRDLG_HXX 232*cdf0e10cSrcweir #include "dlgattr.hxx" 233*cdf0e10cSrcweir #endif 234*cdf0e10cSrcweir #ifndef _SV_MSGBOX_HXX 235*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 236*cdf0e10cSrcweir #endif 237*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ 238*cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 239*cdf0e10cSrcweir #endif 240*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_ 241*cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatsSupplier.hpp> 242*cdf0e10cSrcweir #endif 243*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_ 244*cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatter.hpp> 245*cdf0e10cSrcweir #endif 246*cdf0e10cSrcweir #ifndef _DBU_MISC_HRC_ 247*cdf0e10cSrcweir #include "dbu_misc.hrc" 248*cdf0e10cSrcweir #endif 249*cdf0e10cSrcweir #ifndef _DBAUI_SQLMESSAGE_HXX_ 250*cdf0e10cSrcweir #include "sqlmessage.hxx" 251*cdf0e10cSrcweir #endif 252*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_ 253*cdf0e10cSrcweir #include <com/sun/star/util/NumberFormat.hpp> 254*cdf0e10cSrcweir #endif 255*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_URL_HPP_ 256*cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp> 257*cdf0e10cSrcweir #endif 258*cdf0e10cSrcweir #ifndef _SV_TOOLBOX_HXX 259*cdf0e10cSrcweir #include <vcl/toolbox.hxx> 260*cdf0e10cSrcweir #endif 261*cdf0e10cSrcweir #ifndef _DBAUI_DLGSIZE_HXX 262*cdf0e10cSrcweir #include "dlgsize.hxx" 263*cdf0e10cSrcweir #endif 264*cdf0e10cSrcweir #ifndef _SVTOOLS_EDITBROWSEBOX_HXX_ 265*cdf0e10cSrcweir #include <svtools/editbrowsebox.hxx> 266*cdf0e10cSrcweir #endif 267*cdf0e10cSrcweir #ifndef _UTL_CONFIGMGR_HXX_ 268*cdf0e10cSrcweir #include <unotools/configmgr.hxx> 269*cdf0e10cSrcweir #endif 270*cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_HELPOPT_HXX 271*cdf0e10cSrcweir #include <svtools/helpopt.hxx> 272*cdf0e10cSrcweir #endif 273*cdf0e10cSrcweir #ifndef _UCBHELPER_CONTENT_HXX 274*cdf0e10cSrcweir #include <ucbhelper/content.hxx> 275*cdf0e10cSrcweir #endif 276*cdf0e10cSrcweir #ifndef _URLOBJ_HXX 277*cdf0e10cSrcweir #include <tools/urlobj.hxx> 278*cdf0e10cSrcweir #endif 279*cdf0e10cSrcweir #ifndef TOOLS_DIAGNOSE_EX_H 280*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 281*cdf0e10cSrcweir #endif 282*cdf0e10cSrcweir #ifndef _NUMUNO_HXX 283*cdf0e10cSrcweir #include <svl/numuno.hxx> 284*cdf0e10cSrcweir #endif 285*cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX 286*cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 287*cdf0e10cSrcweir #endif 288*cdf0e10cSrcweir #ifndef SVTOOLS_FILENOTATION_HXX_ 289*cdf0e10cSrcweir #include <svl/filenotation.hxx> 290*cdf0e10cSrcweir #endif 291*cdf0e10cSrcweir #ifndef _SVT_FILEVIEW_HXX 292*cdf0e10cSrcweir #include <svtools/fileview.hxx> 293*cdf0e10cSrcweir #endif 294*cdf0e10cSrcweir #ifndef _CONNECTIVITY_FILE_VALUE_HXX_ 295*cdf0e10cSrcweir #include <connectivity/FValue.hxx> 296*cdf0e10cSrcweir #endif 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir // ......................................................................... 299*cdf0e10cSrcweir namespace dbaui 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir // ......................................................................... 302*cdf0e10cSrcweir using namespace ::dbtools; 303*cdf0e10cSrcweir using namespace ::comphelper; 304*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 305*cdf0e10cSrcweir using namespace ::com::sun::star::task; 306*cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 307*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 308*cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 309*cdf0e10cSrcweir using namespace ::com::sun::star::util; 310*cdf0e10cSrcweir using namespace ::com::sun::star::ucb; 311*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 312*cdf0e10cSrcweir using namespace ::com::sun::star::container; 313*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 314*cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs; 315*cdf0e10cSrcweir using namespace ::svt; 316*cdf0e10cSrcweir using ::com::sun::star::ucb::InteractiveIOException; 317*cdf0e10cSrcweir using ::com::sun::star::ucb::IOErrorCode_NO_FILE; 318*cdf0e10cSrcweir using ::com::sun::star::ucb::IOErrorCode_NOT_EXISTING; 319*cdf0e10cSrcweir using ::com::sun::star::frame::XModel; 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 322*cdf0e10cSrcweir SQLExceptionInfo createConnection( const ::rtl::OUString& _rsDataSourceName, 323*cdf0e10cSrcweir const Reference< ::com::sun::star::container::XNameAccess >& _xDatabaseContext, 324*cdf0e10cSrcweir const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF, 325*cdf0e10cSrcweir Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst, 326*cdf0e10cSrcweir Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection ) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir Reference<XPropertySet> xProp; 329*cdf0e10cSrcweir try 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir xProp.set(_xDatabaseContext->getByName(_rsDataSourceName),UNO_QUERY); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir catch(Exception&) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir SQLExceptionInfo aInfo; 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir return createConnection(xProp,_rMF,_rEvtLst,_rOUTConnection); 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 341*cdf0e10cSrcweir SQLExceptionInfo createConnection( const Reference< ::com::sun::star::beans::XPropertySet>& _xDataSource, 342*cdf0e10cSrcweir const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF, 343*cdf0e10cSrcweir Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst, 344*cdf0e10cSrcweir Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection ) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir SQLExceptionInfo aInfo; 347*cdf0e10cSrcweir if ( !_xDataSource.is() ) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir OSL_ENSURE(0,"createConnection: coult not retrieve the data source!"); 350*cdf0e10cSrcweir return aInfo; 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir ::rtl::OUString sPwd, sUser; 354*cdf0e10cSrcweir sal_Bool bPwdReq = sal_False; 355*cdf0e10cSrcweir try 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir _xDataSource->getPropertyValue(PROPERTY_PASSWORD) >>= sPwd; 358*cdf0e10cSrcweir bPwdReq = ::cppu::any2bool(_xDataSource->getPropertyValue(PROPERTY_ISPASSWORDREQUIRED)); 359*cdf0e10cSrcweir _xDataSource->getPropertyValue(PROPERTY_USER) >>= sUser; 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir catch(Exception&) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir OSL_ENSURE(0,"createConnection: error while retrieving data source properties!"); 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir try 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir if(bPwdReq && !sPwd.getLength()) 370*cdf0e10cSrcweir { // password required, but empty -> connect using an interaction handler 371*cdf0e10cSrcweir Reference<XCompletedConnection> xConnectionCompletion(_xDataSource, UNO_QUERY); 372*cdf0e10cSrcweir if (!xConnectionCompletion.is()) 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir OSL_ENSURE(0,"createConnection: missing an interface ... need an error message here!"); 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir else 377*cdf0e10cSrcweir { // instantiate the default SDB interaction handler 378*cdf0e10cSrcweir Reference< XInteractionHandler > xHandler(_rMF->createInstance(SERVICE_TASK_INTERACTION_HANDLER), UNO_QUERY); 379*cdf0e10cSrcweir if (!xHandler.is()) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir OSL_ENSURE(sal_False, "createConnection: could not instantiate an interaction handler!"); 382*cdf0e10cSrcweir // ShowServiceNotAvailableError(NULL, String(SERVICE_TASK_INTERACTION_HANDLER), sal_True); 383*cdf0e10cSrcweir // TODO: a real parent! 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir else 386*cdf0e10cSrcweir _rOUTConnection = xConnectionCompletion->connectWithCompletion(xHandler); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir else 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir Reference<XDataSource> xDataSource(_xDataSource,UNO_QUERY); 392*cdf0e10cSrcweir _rOUTConnection = xDataSource->getConnection(sUser, sPwd); 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir // be notified when connection is in disposing 395*cdf0e10cSrcweir Reference< XComponent > xComponent(_rOUTConnection, UNO_QUERY); 396*cdf0e10cSrcweir if (xComponent.is() && _rEvtLst.is()) 397*cdf0e10cSrcweir xComponent->addEventListener(_rEvtLst); 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir catch(SQLContext& e) { aInfo = SQLExceptionInfo(e); } 400*cdf0e10cSrcweir catch(SQLWarning& e) { aInfo = SQLExceptionInfo(e); } 401*cdf0e10cSrcweir catch(SQLException& e) { aInfo = SQLExceptionInfo(e); } 402*cdf0e10cSrcweir catch(Exception&) { OSL_ENSURE(0,"SbaTableQueryBrowser::OnExpandEntry: could not connect - unknown exception!"); } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir // showError(aInfo); 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir return aInfo; 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 409*cdf0e10cSrcweir Reference< XDataSource > getDataSourceByName( const ::rtl::OUString& _rDataSourceName, 410*cdf0e10cSrcweir Window* _pErrorMessageParent, Reference< XMultiServiceFactory > _rxORB, ::dbtools::SQLExceptionInfo* _pErrorInfo ) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir ::comphelper::ComponentContext aContext( _rxORB ); 413*cdf0e10cSrcweir Reference< XNameAccess > xDatabaseContext( aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW ); 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir Reference< XDataSource > xDatasource; 416*cdf0e10cSrcweir Any aError; 417*cdf0e10cSrcweir SQLExceptionInfo aSQLError; 418*cdf0e10cSrcweir try 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir xDatabaseContext->getByName( _rDataSourceName ) >>= xDatasource; 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir catch(const WrappedTargetException& e) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir InteractiveIOException aIOException; 425*cdf0e10cSrcweir if ( ( e.TargetException >>= aIOException ) 426*cdf0e10cSrcweir && ( ( aIOException.Code == IOErrorCode_NO_FILE ) 427*cdf0e10cSrcweir || ( aIOException.Code == IOErrorCode_NOT_EXISTING ) 428*cdf0e10cSrcweir ) 429*cdf0e10cSrcweir ) 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir String sErrorMessage = String( ModuleRes( STR_FILE_DOES_NOT_EXIST ) ); 432*cdf0e10cSrcweir OFileNotation aTransformer( e.Message ); 433*cdf0e10cSrcweir sErrorMessage.SearchAndReplaceAscii( "$file$", aTransformer.get( OFileNotation::N_SYSTEM ) ); 434*cdf0e10cSrcweir aSQLError = SQLExceptionInfo( sErrorMessage ).get(); 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir else 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir aSQLError = SQLExceptionInfo( e.TargetException ); 439*cdf0e10cSrcweir if ( !aSQLError.isValid() ) 440*cdf0e10cSrcweir aError = e.TargetException; 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir catch( const Exception& ) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir if ( xDatasource.is() ) 449*cdf0e10cSrcweir return xDatasource; 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir if ( aSQLError.isValid() ) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir if ( _pErrorInfo ) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir *_pErrorInfo = aSQLError; 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir else 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir showError( aSQLError, _pErrorMessageParent, _rxORB ); 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir return Reference<XDataSource>(); 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 466*cdf0e10cSrcweir Reference< XInterface > getDataSourceOrModel(const Reference< XInterface >& _xObject) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir Reference< XInterface > xRet; 469*cdf0e10cSrcweir Reference<XDocumentDataSource> xDocumentDataSource(_xObject,UNO_QUERY); 470*cdf0e10cSrcweir if ( xDocumentDataSource.is() ) 471*cdf0e10cSrcweir xRet = xDocumentDataSource->getDatabaseDocument(); 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir if ( !xRet.is() ) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir Reference<XOfficeDatabaseDocument> xOfficeDoc(_xObject,UNO_QUERY); 476*cdf0e10cSrcweir if ( xOfficeDoc.is() ) 477*cdf0e10cSrcweir xRet = xOfficeDoc->getDataSource(); 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir return xRet; 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 483*cdf0e10cSrcweir void showError(const SQLExceptionInfo& _rInfo,Window* _pParent,const Reference< XMultiServiceFactory >& _xFactory) 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir OSL_ENSURE(_pParent,"showError: Parent window must be NOT NULL!"); 486*cdf0e10cSrcweir ::dbtools::showError(_rInfo,VCLUnoHelper::GetInterface(_pParent),_xFactory); 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 490*cdf0e10cSrcweir ::std::vector< Reference<XNameAccess> > getKeyColumns(const Reference<XIndexAccess >& _rxKeys, 491*cdf0e10cSrcweir sal_Int32 _nKeyType) 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir // use keys and indexes for excat postioning 494*cdf0e10cSrcweir // first the keys 495*cdf0e10cSrcweir ::std::vector< Reference<XNameAccess> > vRet; 496*cdf0e10cSrcweir if(_rxKeys.is()) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir Reference<XPropertySet> xProp; 499*cdf0e10cSrcweir for(sal_Int32 i=0;i< _rxKeys->getCount();++i) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir _rxKeys->getByIndex(i) >>= xProp; 502*cdf0e10cSrcweir sal_Int32 nKeyType = 0; 503*cdf0e10cSrcweir xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType; 504*cdf0e10cSrcweir if(_nKeyType == nKeyType) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir Reference<XColumnsSupplier> xKeyColsSup(xProp,UNO_QUERY); 507*cdf0e10cSrcweir OSL_ENSURE(xKeyColsSup.is(),"Columnsupplier is null!"); 508*cdf0e10cSrcweir vRet.push_back(xKeyColsSup->getColumns()); 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir return vRet; 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir TOTypeInfoSP getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo, 518*cdf0e10cSrcweir sal_Int32 _nType, 519*cdf0e10cSrcweir const ::rtl::OUString& _sTypeName, 520*cdf0e10cSrcweir const ::rtl::OUString& _sCreateParams, 521*cdf0e10cSrcweir sal_Int32 _nPrecision, 522*cdf0e10cSrcweir sal_Int32 _nScale, 523*cdf0e10cSrcweir sal_Bool _bAutoIncrement, 524*cdf0e10cSrcweir sal_Bool& _brForceToType) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir TOTypeInfoSP pTypeInfo; 527*cdf0e10cSrcweir _brForceToType = sal_False; 528*cdf0e10cSrcweir // search for type 529*cdf0e10cSrcweir ::std::pair<OTypeInfoMap::const_iterator, OTypeInfoMap::const_iterator> aPair = _rTypeInfo.equal_range(_nType); 530*cdf0e10cSrcweir OTypeInfoMap::const_iterator aIter = aPair.first; 531*cdf0e10cSrcweir if(aIter != _rTypeInfo.end()) // compare with end is correct here 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir for(;aIter != aPair.second;++aIter) 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir // search the best matching type 536*cdf0e10cSrcweir #ifdef DBG_UTIL 537*cdf0e10cSrcweir ::rtl::OUString sDBTypeName = aIter->second->aTypeName; (void)sDBTypeName; 538*cdf0e10cSrcweir sal_Int32 nDBTypePrecision = aIter->second->nPrecision; (void)nDBTypePrecision; 539*cdf0e10cSrcweir sal_Int32 nDBTypeScale = aIter->second->nMaximumScale; (void)nDBTypeScale; 540*cdf0e10cSrcweir sal_Bool bDBAutoIncrement = aIter->second->bAutoIncrement; (void)bDBAutoIncrement; 541*cdf0e10cSrcweir #endif 542*cdf0e10cSrcweir if ( ( 543*cdf0e10cSrcweir !_sTypeName.getLength() 544*cdf0e10cSrcweir || (aIter->second->aTypeName.equalsIgnoreAsciiCase(_sTypeName)) 545*cdf0e10cSrcweir ) 546*cdf0e10cSrcweir && ( 547*cdf0e10cSrcweir ( 548*cdf0e10cSrcweir !aIter->second->aCreateParams.getLength() 549*cdf0e10cSrcweir && !_sCreateParams.getLength() 550*cdf0e10cSrcweir ) 551*cdf0e10cSrcweir || ( 552*cdf0e10cSrcweir (aIter->second->nPrecision >= _nPrecision) 553*cdf0e10cSrcweir && (aIter->second->nMaximumScale >= _nScale) 554*cdf0e10cSrcweir && ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement ) 555*cdf0e10cSrcweir ) 556*cdf0e10cSrcweir ) 557*cdf0e10cSrcweir ) 558*cdf0e10cSrcweir break; 559*cdf0e10cSrcweir } 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir if (aIter == aPair.second) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir for(aIter = aPair.first; aIter != aPair.second; ++aIter) 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir sal_Int32 nPrec = aIter->second->nPrecision; 566*cdf0e10cSrcweir sal_Int32 nScale = aIter->second->nMaximumScale; 567*cdf0e10cSrcweir // search the best matching type (now comparing the local names) 568*cdf0e10cSrcweir if ( (aIter->second->aLocalTypeName.equalsIgnoreAsciiCase(_sTypeName)) 569*cdf0e10cSrcweir && (nPrec >= _nPrecision) 570*cdf0e10cSrcweir && (nScale >= _nScale) 571*cdf0e10cSrcweir && ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement ) 572*cdf0e10cSrcweir ) 573*cdf0e10cSrcweir { 574*cdf0e10cSrcweir OSL_ENSURE(sal_False, 575*cdf0e10cSrcweir ( ::rtl::OString("getTypeInfoFromType: assuming column type ") 576*cdf0e10cSrcweir += ::rtl::OString(aIter->second->aTypeName.getStr(), aIter->second->aTypeName.getLength(), gsl_getSystemTextEncoding()) 577*cdf0e10cSrcweir += ::rtl::OString("\" (expected type name ") 578*cdf0e10cSrcweir += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding()) 579*cdf0e10cSrcweir += ::rtl::OString(" matches the type's local name).")).getStr()); 580*cdf0e10cSrcweir break; 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir } 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir if (aIter == aPair.second) 586*cdf0e10cSrcweir { // no match for the names, no match for the local names 587*cdf0e10cSrcweir // -> drop the precision and the scale restriction, accept any type with the property 588*cdf0e10cSrcweir // type id (nType) 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir //OSL_ENSURE(sal_False, 591*cdf0e10cSrcweir // ( ::rtl::OString("getTypeInfoFromType: did not find a matching type") 592*cdf0e10cSrcweir // += ::rtl::OString(" (expected type name: ") 593*cdf0e10cSrcweir // += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding()) 594*cdf0e10cSrcweir // += ::rtl::OString(")! Defaulting to the first matching type.")).getStr()); 595*cdf0e10cSrcweir for(aIter = aPair.first; aIter != aPair.second; ++aIter) 596*cdf0e10cSrcweir { 597*cdf0e10cSrcweir // search the best matching type (now comparing the local names) 598*cdf0e10cSrcweir #ifdef DBG_UTIL 599*cdf0e10cSrcweir ::rtl::OUString sDBTypeName = aIter->second->aTypeName; 600*cdf0e10cSrcweir #endif 601*cdf0e10cSrcweir sal_Int32 nPrec = aIter->second->nPrecision; 602*cdf0e10cSrcweir sal_Int32 nScale = aIter->second->nMaximumScale; 603*cdf0e10cSrcweir if ( (nPrec >= _nPrecision) 604*cdf0e10cSrcweir && (nScale >= _nScale) 605*cdf0e10cSrcweir && ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement ) 606*cdf0e10cSrcweir ) 607*cdf0e10cSrcweir break; 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir } 610*cdf0e10cSrcweir if (aIter == aPair.second) 611*cdf0e10cSrcweir { 612*cdf0e10cSrcweir if ( _bAutoIncrement ) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir for(aIter = aPair.first; aIter != aPair.second; ++aIter) 615*cdf0e10cSrcweir { 616*cdf0e10cSrcweir // search the best matching type (now comparing the local names) 617*cdf0e10cSrcweir #ifdef DBG_UTIL 618*cdf0e10cSrcweir ::rtl::OUString sDBTypeName = aIter->second->aTypeName; 619*cdf0e10cSrcweir #endif 620*cdf0e10cSrcweir sal_Int32 nScale = aIter->second->nMaximumScale; 621*cdf0e10cSrcweir if ( (nScale >= _nScale) 622*cdf0e10cSrcweir && (aIter->second->bAutoIncrement == _bAutoIncrement) 623*cdf0e10cSrcweir ) 624*cdf0e10cSrcweir break; 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir if ( aIter == aPair.second ) 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir // try it without the auto increment flag 629*cdf0e10cSrcweir pTypeInfo = getTypeInfoFromType(_rTypeInfo, 630*cdf0e10cSrcweir _nType, 631*cdf0e10cSrcweir _sTypeName, 632*cdf0e10cSrcweir _sCreateParams, 633*cdf0e10cSrcweir _nPrecision, 634*cdf0e10cSrcweir _nScale, 635*cdf0e10cSrcweir sal_False, 636*cdf0e10cSrcweir _brForceToType); 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir else 639*cdf0e10cSrcweir pTypeInfo = aIter->second; 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir else 642*cdf0e10cSrcweir { 643*cdf0e10cSrcweir pTypeInfo = aPair.first->second; 644*cdf0e10cSrcweir _brForceToType = sal_True; 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir } 647*cdf0e10cSrcweir else 648*cdf0e10cSrcweir pTypeInfo = aIter->second; 649*cdf0e10cSrcweir } 650*cdf0e10cSrcweir else 651*cdf0e10cSrcweir { 652*cdf0e10cSrcweir ::comphelper::TStringMixEqualFunctor aCase(sal_False); 653*cdf0e10cSrcweir // search for typeinfo where the typename is equal _sTypeName 654*cdf0e10cSrcweir OTypeInfoMap::const_iterator typeInfoLoop = _rTypeInfo.begin(); 655*cdf0e10cSrcweir OTypeInfoMap::const_iterator typeInfoEnd = _rTypeInfo.end(); 656*cdf0e10cSrcweir for (; typeInfoLoop != typeInfoEnd; ++typeInfoLoop) 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir if ( aCase( typeInfoLoop->second->getDBName() , _sTypeName ) ) 659*cdf0e10cSrcweir { 660*cdf0e10cSrcweir pTypeInfo = typeInfoLoop->second; 661*cdf0e10cSrcweir break; 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir } 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir OSL_ENSURE(pTypeInfo, "getTypeInfoFromType: no type info found for this type!"); 667*cdf0e10cSrcweir return pTypeInfo; 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 670*cdf0e10cSrcweir void fillTypeInfo( const Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection, 671*cdf0e10cSrcweir const String& _rsTypeNames, 672*cdf0e10cSrcweir OTypeInfoMap& _rTypeInfoMap, 673*cdf0e10cSrcweir ::std::vector<OTypeInfoMap::iterator>& _rTypeInfoIters) 674*cdf0e10cSrcweir { 675*cdf0e10cSrcweir if(!_rxConnection.is()) 676*cdf0e10cSrcweir return; 677*cdf0e10cSrcweir Reference< XResultSet> xRs = _rxConnection->getMetaData ()->getTypeInfo (); 678*cdf0e10cSrcweir Reference< XRow> xRow(xRs,UNO_QUERY); 679*cdf0e10cSrcweir // Information for a single SQL type 680*cdf0e10cSrcweir if(xRs.is()) 681*cdf0e10cSrcweir { 682*cdf0e10cSrcweir static const ::rtl::OUString aB1 = ::rtl::OUString::createFromAscii(" [ "); 683*cdf0e10cSrcweir static const ::rtl::OUString aB2 = ::rtl::OUString::createFromAscii(" ]"); 684*cdf0e10cSrcweir Reference<XResultSetMetaData> xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(xRs,UNO_QUERY)->getMetaData(); 685*cdf0e10cSrcweir ::connectivity::ORowSetValue aValue; 686*cdf0e10cSrcweir ::std::vector<sal_Int32> aTypes; 687*cdf0e10cSrcweir ::std::vector<sal_Bool> aNullable; 688*cdf0e10cSrcweir // Loop on the result set until we reach end of file 689*cdf0e10cSrcweir while (xRs->next()) 690*cdf0e10cSrcweir { 691*cdf0e10cSrcweir TOTypeInfoSP pInfo(new OTypeInfo()); 692*cdf0e10cSrcweir sal_Int32 nPos = 1; 693*cdf0e10cSrcweir if ( aTypes.empty() ) 694*cdf0e10cSrcweir { 695*cdf0e10cSrcweir sal_Int32 nCount = xResultSetMetaData->getColumnCount(); 696*cdf0e10cSrcweir if ( nCount < 1 ) 697*cdf0e10cSrcweir nCount = 18; 698*cdf0e10cSrcweir aTypes.reserve(nCount+1); 699*cdf0e10cSrcweir aTypes.push_back(-1); 700*cdf0e10cSrcweir aNullable.push_back(sal_False); 701*cdf0e10cSrcweir for (sal_Int32 j = 1; j <= nCount ; ++j) 702*cdf0e10cSrcweir { 703*cdf0e10cSrcweir aTypes.push_back(xResultSetMetaData->getColumnType(j)); 704*cdf0e10cSrcweir aNullable.push_back(xResultSetMetaData->isNullable(j) != ColumnValue::NO_NULLS); 705*cdf0e10cSrcweir } 706*cdf0e10cSrcweir } 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 709*cdf0e10cSrcweir pInfo->aTypeName = aValue; 710*cdf0e10cSrcweir ++nPos; 711*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 712*cdf0e10cSrcweir pInfo->nType = aValue; 713*cdf0e10cSrcweir ++nPos; 714*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 715*cdf0e10cSrcweir pInfo->nPrecision = aValue; 716*cdf0e10cSrcweir ++nPos; 717*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 718*cdf0e10cSrcweir pInfo->aLiteralPrefix = aValue; 719*cdf0e10cSrcweir ++nPos; 720*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 721*cdf0e10cSrcweir pInfo->aLiteralSuffix = aValue; 722*cdf0e10cSrcweir ++nPos; 723*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 724*cdf0e10cSrcweir pInfo->aCreateParams = aValue; 725*cdf0e10cSrcweir ++nPos; 726*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 727*cdf0e10cSrcweir pInfo->bNullable = (sal_Int32)aValue == ColumnValue::NULLABLE; 728*cdf0e10cSrcweir ++nPos; 729*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 730*cdf0e10cSrcweir pInfo->bCaseSensitive = (sal_Bool)aValue; 731*cdf0e10cSrcweir ++nPos; 732*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 733*cdf0e10cSrcweir pInfo->nSearchType = aValue; 734*cdf0e10cSrcweir ++nPos; 735*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 736*cdf0e10cSrcweir pInfo->bUnsigned = (sal_Bool)aValue; 737*cdf0e10cSrcweir ++nPos; 738*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 739*cdf0e10cSrcweir pInfo->bCurrency = (sal_Bool)aValue; 740*cdf0e10cSrcweir ++nPos; 741*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 742*cdf0e10cSrcweir pInfo->bAutoIncrement = (sal_Bool)aValue; 743*cdf0e10cSrcweir ++nPos; 744*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 745*cdf0e10cSrcweir pInfo->aLocalTypeName = aValue; 746*cdf0e10cSrcweir ++nPos; 747*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 748*cdf0e10cSrcweir pInfo->nMinimumScale = aValue; 749*cdf0e10cSrcweir ++nPos; 750*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 751*cdf0e10cSrcweir pInfo->nMaximumScale = aValue; 752*cdf0e10cSrcweir nPos = 18; 753*cdf0e10cSrcweir aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow); 754*cdf0e10cSrcweir 755*cdf0e10cSrcweir // check if values are less than zero like it happens in a oracle jdbc driver 756*cdf0e10cSrcweir if( pInfo->nPrecision < 0) 757*cdf0e10cSrcweir pInfo->nPrecision = 0; 758*cdf0e10cSrcweir if( pInfo->nMinimumScale < 0) 759*cdf0e10cSrcweir pInfo->nMinimumScale = 0; 760*cdf0e10cSrcweir if( pInfo->nMaximumScale < 0) 761*cdf0e10cSrcweir pInfo->nMaximumScale = 0; 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir String aName; 764*cdf0e10cSrcweir switch(pInfo->nType) 765*cdf0e10cSrcweir { 766*cdf0e10cSrcweir case DataType::CHAR: 767*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_CHAR); 768*cdf0e10cSrcweir break; 769*cdf0e10cSrcweir case DataType::VARCHAR: 770*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_TEXT); 771*cdf0e10cSrcweir break; 772*cdf0e10cSrcweir case DataType::DECIMAL: 773*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_DECIMAL); 774*cdf0e10cSrcweir break; 775*cdf0e10cSrcweir case DataType::NUMERIC: 776*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_NUMERIC); 777*cdf0e10cSrcweir break; 778*cdf0e10cSrcweir case DataType::BIGINT: 779*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_BIGINT); 780*cdf0e10cSrcweir break; 781*cdf0e10cSrcweir case DataType::FLOAT: 782*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_FLOAT); 783*cdf0e10cSrcweir break; 784*cdf0e10cSrcweir case DataType::DOUBLE: 785*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_DOUBLE); 786*cdf0e10cSrcweir break; 787*cdf0e10cSrcweir case DataType::LONGVARCHAR: 788*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_MEMO); 789*cdf0e10cSrcweir break; 790*cdf0e10cSrcweir case DataType::LONGVARBINARY: 791*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_IMAGE); 792*cdf0e10cSrcweir break; 793*cdf0e10cSrcweir case DataType::DATE: 794*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_DATE); 795*cdf0e10cSrcweir break; 796*cdf0e10cSrcweir case DataType::TIME: 797*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_TIME); 798*cdf0e10cSrcweir break; 799*cdf0e10cSrcweir case DataType::TIMESTAMP: 800*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_DATETIME); 801*cdf0e10cSrcweir break; 802*cdf0e10cSrcweir case DataType::BIT: 803*cdf0e10cSrcweir if ( pInfo->aCreateParams.getLength() ) 804*cdf0e10cSrcweir { 805*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_BIT); 806*cdf0e10cSrcweir break; 807*cdf0e10cSrcweir } 808*cdf0e10cSrcweir // run through 809*cdf0e10cSrcweir case DataType::BOOLEAN: 810*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_BOOL); 811*cdf0e10cSrcweir break; 812*cdf0e10cSrcweir case DataType::TINYINT: 813*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_TINYINT); 814*cdf0e10cSrcweir break; 815*cdf0e10cSrcweir case DataType::SMALLINT: 816*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_SMALLINT); 817*cdf0e10cSrcweir break; 818*cdf0e10cSrcweir case DataType::INTEGER: 819*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_INTEGER); 820*cdf0e10cSrcweir break; 821*cdf0e10cSrcweir case DataType::REAL: 822*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_REAL); 823*cdf0e10cSrcweir break; 824*cdf0e10cSrcweir case DataType::BINARY: 825*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_BINARY); 826*cdf0e10cSrcweir break; 827*cdf0e10cSrcweir case DataType::VARBINARY: 828*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_VARBINARY); 829*cdf0e10cSrcweir break; 830*cdf0e10cSrcweir case DataType::SQLNULL: 831*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_SQLNULL); 832*cdf0e10cSrcweir break; 833*cdf0e10cSrcweir case DataType::OBJECT: 834*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_OBJECT); 835*cdf0e10cSrcweir break; 836*cdf0e10cSrcweir case DataType::DISTINCT: 837*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_DISTINCT); 838*cdf0e10cSrcweir break; 839*cdf0e10cSrcweir case DataType::STRUCT: 840*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_STRUCT); 841*cdf0e10cSrcweir break; 842*cdf0e10cSrcweir case DataType::ARRAY: 843*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_ARRAY); 844*cdf0e10cSrcweir break; 845*cdf0e10cSrcweir case DataType::BLOB: 846*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_BLOB); 847*cdf0e10cSrcweir break; 848*cdf0e10cSrcweir case DataType::CLOB: 849*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_CLOB); 850*cdf0e10cSrcweir break; 851*cdf0e10cSrcweir case DataType::REF: 852*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_REF); 853*cdf0e10cSrcweir break; 854*cdf0e10cSrcweir case DataType::OTHER: 855*cdf0e10cSrcweir aName = _rsTypeNames.GetToken(TYPE_OTHER); 856*cdf0e10cSrcweir break; 857*cdf0e10cSrcweir } 858*cdf0e10cSrcweir if ( aName.Len() ) 859*cdf0e10cSrcweir { 860*cdf0e10cSrcweir pInfo->aUIName = aName.GetBuffer(); 861*cdf0e10cSrcweir pInfo->aUIName += aB1; 862*cdf0e10cSrcweir } 863*cdf0e10cSrcweir pInfo->aUIName += pInfo->aTypeName; 864*cdf0e10cSrcweir if ( aName.Len() ) 865*cdf0e10cSrcweir pInfo->aUIName += aB2; 866*cdf0e10cSrcweir // Now that we have the type info, save it in the multimap 867*cdf0e10cSrcweir _rTypeInfoMap.insert(OTypeInfoMap::value_type(pInfo->nType,pInfo)); 868*cdf0e10cSrcweir } 869*cdf0e10cSrcweir // for a faster index access 870*cdf0e10cSrcweir _rTypeInfoIters.reserve(_rTypeInfoMap.size()); 871*cdf0e10cSrcweir 872*cdf0e10cSrcweir OTypeInfoMap::iterator aIter = _rTypeInfoMap.begin(); 873*cdf0e10cSrcweir OTypeInfoMap::iterator aEnd = _rTypeInfoMap.end(); 874*cdf0e10cSrcweir for(;aIter != aEnd;++aIter) 875*cdf0e10cSrcweir _rTypeInfoIters.push_back(aIter); 876*cdf0e10cSrcweir 877*cdf0e10cSrcweir // Close the result set/statement. 878*cdf0e10cSrcweir 879*cdf0e10cSrcweir ::comphelper::disposeComponent(xRs); 880*cdf0e10cSrcweir } 881*cdf0e10cSrcweir } 882*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 883*cdf0e10cSrcweir void setColumnProperties(const Reference<XPropertySet>& _rxColumn,const OFieldDescription* _pFieldDesc) 884*cdf0e10cSrcweir { 885*cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_NAME,makeAny(_pFieldDesc->GetName())); 886*cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_TYPENAME,makeAny(_pFieldDesc->getTypeInfo()->aTypeName)); 887*cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_TYPE,makeAny(_pFieldDesc->GetType())); 888*cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_PRECISION,makeAny(_pFieldDesc->GetPrecision())); 889*cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_SCALE,makeAny(_pFieldDesc->GetScale())); 890*cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_ISNULLABLE, makeAny(_pFieldDesc->GetIsNullable())); 891*cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_ISAUTOINCREMENT,::cppu::bool2any(_pFieldDesc->IsAutoIncrement())); 892*cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_DESCRIPTION,makeAny(_pFieldDesc->GetDescription())); 893*cdf0e10cSrcweir if ( _rxColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISCURRENCY) && _pFieldDesc->IsCurrency() ) 894*cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_ISCURRENCY,::cppu::bool2any(_pFieldDesc->IsCurrency())); 895*cdf0e10cSrcweir // set autoincrement value when available 896*cdf0e10cSrcweir // and only set when the entry is not empty, that lets the value in the column untouched 897*cdf0e10cSrcweir if ( _pFieldDesc->IsAutoIncrement() && _pFieldDesc->GetAutoIncrementValue().getLength() && _rxColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION) ) 898*cdf0e10cSrcweir _rxColumn->setPropertyValue(PROPERTY_AUTOINCREMENTCREATION,makeAny(_pFieldDesc->GetAutoIncrementValue())); 899*cdf0e10cSrcweir } 900*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 901*cdf0e10cSrcweir ::rtl::OUString createDefaultName(const Reference< XDatabaseMetaData>& _xMetaData,const Reference<XNameAccess>& _xTables,const ::rtl::OUString& _sName) 902*cdf0e10cSrcweir { 903*cdf0e10cSrcweir OSL_ENSURE(_xMetaData.is(),"No MetaData!"); 904*cdf0e10cSrcweir ::rtl::OUString sDefaultName = _sName; 905*cdf0e10cSrcweir try 906*cdf0e10cSrcweir { 907*cdf0e10cSrcweir ::rtl::OUString sCatalog,sSchema,sCompsedName; 908*cdf0e10cSrcweir if(_xMetaData->supportsCatalogsInTableDefinitions()) 909*cdf0e10cSrcweir { 910*cdf0e10cSrcweir try 911*cdf0e10cSrcweir { 912*cdf0e10cSrcweir Reference< XConnection> xCon = _xMetaData->getConnection(); 913*cdf0e10cSrcweir if ( xCon.is() ) 914*cdf0e10cSrcweir sCatalog = xCon->getCatalog(); 915*cdf0e10cSrcweir if ( !sCatalog.getLength() ) 916*cdf0e10cSrcweir { 917*cdf0e10cSrcweir Reference<XResultSet> xRes = _xMetaData->getCatalogs(); 918*cdf0e10cSrcweir Reference<XRow> xRow(xRes,UNO_QUERY); 919*cdf0e10cSrcweir while(xRes.is() && xRes->next()) 920*cdf0e10cSrcweir { 921*cdf0e10cSrcweir sCatalog = xRow->getString(1); 922*cdf0e10cSrcweir if(!xRow->wasNull()) 923*cdf0e10cSrcweir break; 924*cdf0e10cSrcweir } 925*cdf0e10cSrcweir } 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir catch(const SQLException&) 928*cdf0e10cSrcweir { 929*cdf0e10cSrcweir } 930*cdf0e10cSrcweir } 931*cdf0e10cSrcweir if(_xMetaData->supportsSchemasInTableDefinitions()) 932*cdf0e10cSrcweir { 933*cdf0e10cSrcweir sSchema = _xMetaData->getUserName(); 934*cdf0e10cSrcweir } 935*cdf0e10cSrcweir sCompsedName = ::dbtools::composeTableName( _xMetaData, sCatalog, sSchema, _sName, sal_False, ::dbtools::eInDataManipulation ); 936*cdf0e10cSrcweir sDefaultName = ::dbtools::createUniqueName(_xTables,sCompsedName); 937*cdf0e10cSrcweir } 938*cdf0e10cSrcweir catch(const SQLException&) 939*cdf0e10cSrcweir { 940*cdf0e10cSrcweir } 941*cdf0e10cSrcweir return sDefaultName; 942*cdf0e10cSrcweir } 943*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 944*cdf0e10cSrcweir sal_Bool checkDataSourceAvailable(const ::rtl::OUString& _sDataSourceName,const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB) 945*cdf0e10cSrcweir { 946*cdf0e10cSrcweir sal_Bool bRet = sal_False; 947*cdf0e10cSrcweir Reference< XNameAccess > xDataBaseContext(_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); 948*cdf0e10cSrcweir if ( xDataBaseContext.is() ) 949*cdf0e10cSrcweir { 950*cdf0e10cSrcweir bRet = xDataBaseContext->hasByName(_sDataSourceName); 951*cdf0e10cSrcweir if ( !bRet ) 952*cdf0e10cSrcweir { // try if this one is a URL 953*cdf0e10cSrcweir try 954*cdf0e10cSrcweir { 955*cdf0e10cSrcweir bRet = xDataBaseContext->getByName(_sDataSourceName).hasValue(); 956*cdf0e10cSrcweir } 957*cdf0e10cSrcweir catch(Exception) 958*cdf0e10cSrcweir { 959*cdf0e10cSrcweir } 960*cdf0e10cSrcweir } 961*cdf0e10cSrcweir } 962*cdf0e10cSrcweir return bRet; 963*cdf0e10cSrcweir } 964*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 965*cdf0e10cSrcweir sal_Int32 mapTextAllign(const SvxCellHorJustify& _eAlignment) 966*cdf0e10cSrcweir { 967*cdf0e10cSrcweir sal_Int32 nAlignment = com::sun::star::awt::TextAlign::LEFT; 968*cdf0e10cSrcweir switch (_eAlignment) 969*cdf0e10cSrcweir { 970*cdf0e10cSrcweir case SVX_HOR_JUSTIFY_STANDARD: 971*cdf0e10cSrcweir case SVX_HOR_JUSTIFY_LEFT: nAlignment = ::com::sun::star::awt::TextAlign::LEFT; break; 972*cdf0e10cSrcweir case SVX_HOR_JUSTIFY_CENTER: nAlignment = ::com::sun::star::awt::TextAlign::CENTER; break; 973*cdf0e10cSrcweir case SVX_HOR_JUSTIFY_RIGHT: nAlignment = ::com::sun::star::awt::TextAlign::RIGHT; break; 974*cdf0e10cSrcweir default: 975*cdf0e10cSrcweir OSL_ENSURE(0,"Invalid TextAlign!"); 976*cdf0e10cSrcweir } 977*cdf0e10cSrcweir return nAlignment; 978*cdf0e10cSrcweir } 979*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 980*cdf0e10cSrcweir SvxCellHorJustify mapTextJustify(const sal_Int32& _nAlignment) 981*cdf0e10cSrcweir { 982*cdf0e10cSrcweir SvxCellHorJustify eJustify = SVX_HOR_JUSTIFY_LEFT; 983*cdf0e10cSrcweir switch (_nAlignment) 984*cdf0e10cSrcweir { 985*cdf0e10cSrcweir case ::com::sun::star::awt::TextAlign::LEFT : eJustify = SVX_HOR_JUSTIFY_LEFT; break; 986*cdf0e10cSrcweir case ::com::sun::star::awt::TextAlign::CENTER : eJustify = SVX_HOR_JUSTIFY_CENTER; break; 987*cdf0e10cSrcweir case ::com::sun::star::awt::TextAlign::RIGHT : eJustify = SVX_HOR_JUSTIFY_RIGHT; break; 988*cdf0e10cSrcweir default: 989*cdf0e10cSrcweir OSL_ENSURE(0,"Invalid TextAlign!"); 990*cdf0e10cSrcweir } 991*cdf0e10cSrcweir return eJustify; 992*cdf0e10cSrcweir } 993*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 994*cdf0e10cSrcweir float ConvertFontWeight( ::FontWeight eWeight ) 995*cdf0e10cSrcweir { 996*cdf0e10cSrcweir if( eWeight == WEIGHT_DONTKNOW ) 997*cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::DONTKNOW; 998*cdf0e10cSrcweir else if( eWeight == WEIGHT_THIN ) 999*cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::THIN; 1000*cdf0e10cSrcweir else if( eWeight == WEIGHT_ULTRALIGHT ) 1001*cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::ULTRALIGHT; 1002*cdf0e10cSrcweir else if( eWeight == WEIGHT_LIGHT ) 1003*cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::LIGHT; 1004*cdf0e10cSrcweir else if( eWeight == WEIGHT_SEMILIGHT ) 1005*cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::SEMILIGHT; 1006*cdf0e10cSrcweir else if( ( eWeight == WEIGHT_NORMAL ) || ( eWeight == WEIGHT_MEDIUM ) ) 1007*cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::NORMAL; 1008*cdf0e10cSrcweir else if( eWeight == WEIGHT_SEMIBOLD ) 1009*cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::SEMIBOLD; 1010*cdf0e10cSrcweir else if( eWeight == WEIGHT_BOLD ) 1011*cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::BOLD; 1012*cdf0e10cSrcweir else if( eWeight == WEIGHT_ULTRABOLD ) 1013*cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::ULTRABOLD; 1014*cdf0e10cSrcweir else if( eWeight == WEIGHT_BLACK ) 1015*cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::BLACK; 1016*cdf0e10cSrcweir 1017*cdf0e10cSrcweir OSL_ENSURE(0, "Unknown FontWeigth" ); 1018*cdf0e10cSrcweir return ::com::sun::star::awt::FontWeight::DONTKNOW; 1019*cdf0e10cSrcweir } 1020*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1021*cdf0e10cSrcweir float ConvertFontWidth( ::FontWidth eWidth ) 1022*cdf0e10cSrcweir { 1023*cdf0e10cSrcweir if( eWidth == WIDTH_DONTKNOW ) 1024*cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::DONTKNOW; 1025*cdf0e10cSrcweir else if( eWidth == WIDTH_ULTRA_CONDENSED ) 1026*cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::ULTRACONDENSED; 1027*cdf0e10cSrcweir else if( eWidth == WIDTH_EXTRA_CONDENSED ) 1028*cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::EXTRACONDENSED; 1029*cdf0e10cSrcweir else if( eWidth == WIDTH_CONDENSED ) 1030*cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::CONDENSED; 1031*cdf0e10cSrcweir else if( eWidth == WIDTH_SEMI_CONDENSED ) 1032*cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::SEMICONDENSED; 1033*cdf0e10cSrcweir else if( eWidth == WIDTH_NORMAL ) 1034*cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::NORMAL; 1035*cdf0e10cSrcweir else if( eWidth == WIDTH_SEMI_EXPANDED ) 1036*cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::SEMIEXPANDED; 1037*cdf0e10cSrcweir else if( eWidth == WIDTH_EXPANDED ) 1038*cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::EXPANDED; 1039*cdf0e10cSrcweir else if( eWidth == WIDTH_EXTRA_EXPANDED ) 1040*cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::EXTRAEXPANDED; 1041*cdf0e10cSrcweir else if( eWidth == WIDTH_ULTRA_EXPANDED ) 1042*cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::ULTRAEXPANDED; 1043*cdf0e10cSrcweir 1044*cdf0e10cSrcweir OSL_ENSURE(0, "Unknown FontWidth" ); 1045*cdf0e10cSrcweir return ::com::sun::star::awt::FontWidth::DONTKNOW; 1046*cdf0e10cSrcweir } 1047*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1048*cdf0e10cSrcweir ::com::sun::star::awt::FontDescriptor CreateFontDescriptor( const Font& rFont ) 1049*cdf0e10cSrcweir { 1050*cdf0e10cSrcweir ::com::sun::star::awt::FontDescriptor aFD; 1051*cdf0e10cSrcweir aFD.Name = rFont.GetName(); 1052*cdf0e10cSrcweir aFD.StyleName = rFont.GetStyleName(); 1053*cdf0e10cSrcweir aFD.Height = (sal_Int16)rFont.GetSize().Height(); 1054*cdf0e10cSrcweir aFD.Width = (sal_Int16)rFont.GetSize().Width(); 1055*cdf0e10cSrcweir aFD.Family = sal::static_int_cast< sal_Int16 >(rFont.GetFamily()); 1056*cdf0e10cSrcweir aFD.CharSet = rFont.GetCharSet(); 1057*cdf0e10cSrcweir aFD.Pitch = sal::static_int_cast< sal_Int16 >(rFont.GetPitch()); 1058*cdf0e10cSrcweir aFD.CharacterWidth = ConvertFontWidth( rFont.GetWidthType() ); 1059*cdf0e10cSrcweir aFD.Weight = ConvertFontWeight( rFont.GetWeight() ); 1060*cdf0e10cSrcweir aFD.Slant = (::com::sun::star::awt::FontSlant)rFont.GetItalic(); 1061*cdf0e10cSrcweir aFD.Underline = sal::static_int_cast< sal_Int16 >( 1062*cdf0e10cSrcweir rFont.GetUnderline()); 1063*cdf0e10cSrcweir aFD.Strikeout = sal::static_int_cast< sal_Int16 >( 1064*cdf0e10cSrcweir rFont.GetStrikeout()); 1065*cdf0e10cSrcweir aFD.Orientation = rFont.GetOrientation(); 1066*cdf0e10cSrcweir aFD.Kerning = rFont.IsKerning(); 1067*cdf0e10cSrcweir aFD.WordLineMode = rFont.IsWordLineMode(); 1068*cdf0e10cSrcweir aFD.Type = 0; // ??? => Nur an Metric... 1069*cdf0e10cSrcweir return aFD; 1070*cdf0e10cSrcweir } 1071*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1072*cdf0e10cSrcweir void callColumnFormatDialog(const Reference<XPropertySet>& xAffectedCol, 1073*cdf0e10cSrcweir const Reference<XPropertySet>& xField, 1074*cdf0e10cSrcweir SvNumberFormatter* _pFormatter, 1075*cdf0e10cSrcweir Window* _pParent) 1076*cdf0e10cSrcweir { 1077*cdf0e10cSrcweir if (xAffectedCol.is() && xField.is()) 1078*cdf0e10cSrcweir { 1079*cdf0e10cSrcweir try 1080*cdf0e10cSrcweir { 1081*cdf0e10cSrcweir Reference< XPropertySetInfo > xInfo = xAffectedCol->getPropertySetInfo(); 1082*cdf0e10cSrcweir sal_Bool bHasFormat = xInfo->hasPropertyByName(PROPERTY_FORMATKEY); 1083*cdf0e10cSrcweir sal_Int32 nDataType = ::comphelper::getINT32(xField->getPropertyValue(PROPERTY_TYPE)); 1084*cdf0e10cSrcweir 1085*cdf0e10cSrcweir SvxCellHorJustify eJustify(SVX_HOR_JUSTIFY_STANDARD); 1086*cdf0e10cSrcweir Any aAlignment = xAffectedCol->getPropertyValue(PROPERTY_ALIGN); 1087*cdf0e10cSrcweir if (aAlignment.hasValue()) 1088*cdf0e10cSrcweir eJustify = dbaui::mapTextJustify(::comphelper::getINT16(aAlignment)); 1089*cdf0e10cSrcweir sal_Int32 nFormatKey = 0; 1090*cdf0e10cSrcweir if ( bHasFormat ) 1091*cdf0e10cSrcweir nFormatKey = ::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_FORMATKEY)); 1092*cdf0e10cSrcweir 1093*cdf0e10cSrcweir sal_uInt16 nFlags = 0; 1094*cdf0e10cSrcweir if(callColumnFormatDialog(_pParent,_pFormatter,nDataType,nFormatKey,eJustify,nFlags,bHasFormat)) 1095*cdf0e10cSrcweir { 1096*cdf0e10cSrcweir xAffectedCol->setPropertyValue(PROPERTY_ALIGN, makeAny((sal_Int16)dbaui::mapTextAllign(eJustify))); 1097*cdf0e10cSrcweir if (nFlags & TP_ATTR_NUMBER) 1098*cdf0e10cSrcweir xAffectedCol->setPropertyValue(PROPERTY_FORMATKEY, makeAny(nFormatKey)); 1099*cdf0e10cSrcweir 1100*cdf0e10cSrcweir } 1101*cdf0e10cSrcweir } 1102*cdf0e10cSrcweir catch( const Exception& ) 1103*cdf0e10cSrcweir { 1104*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1105*cdf0e10cSrcweir } 1106*cdf0e10cSrcweir } 1107*cdf0e10cSrcweir } 1108*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1109*cdf0e10cSrcweir sal_Bool callColumnFormatDialog(Window* _pParent, 1110*cdf0e10cSrcweir SvNumberFormatter* _pFormatter, 1111*cdf0e10cSrcweir sal_Int32 _nDataType, 1112*cdf0e10cSrcweir sal_Int32& _nFormatKey, 1113*cdf0e10cSrcweir SvxCellHorJustify& _eJustify, 1114*cdf0e10cSrcweir sal_uInt16& _nFlags, 1115*cdf0e10cSrcweir sal_Bool _bHasFormat) 1116*cdf0e10cSrcweir { 1117*cdf0e10cSrcweir sal_Bool bRet = sal_False; 1118*cdf0e10cSrcweir // the allowed format changes depend of the type of the field ... 1119*cdf0e10cSrcweir _nFlags = TP_ATTR_ALIGN; 1120*cdf0e10cSrcweir 1121*cdf0e10cSrcweir if (_bHasFormat) 1122*cdf0e10cSrcweir _nFlags |= TP_ATTR_NUMBER; 1123*cdf0e10cSrcweir 1124*cdf0e10cSrcweir // ------------ 1125*cdf0e10cSrcweir // UNO->ItemSet 1126*cdf0e10cSrcweir static SfxItemInfo aItemInfos[] = 1127*cdf0e10cSrcweir { 1128*cdf0e10cSrcweir { 0, 0 }, 1129*cdf0e10cSrcweir { SID_ATTR_NUMBERFORMAT_VALUE, SFX_ITEM_POOLABLE }, 1130*cdf0e10cSrcweir { SID_ATTR_ALIGN_HOR_JUSTIFY, SFX_ITEM_POOLABLE }, 1131*cdf0e10cSrcweir { SID_ATTR_NUMBERFORMAT_ONE_AREA, SFX_ITEM_POOLABLE }, 1132*cdf0e10cSrcweir { SID_ATTR_NUMBERFORMAT_INFO, SFX_ITEM_POOLABLE } 1133*cdf0e10cSrcweir }; 1134*cdf0e10cSrcweir static sal_uInt16 aAttrMap[] = 1135*cdf0e10cSrcweir { 1136*cdf0e10cSrcweir SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY, 1137*cdf0e10cSrcweir SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA, 1138*cdf0e10cSrcweir SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO, 1139*cdf0e10cSrcweir 0 1140*cdf0e10cSrcweir }; 1141*cdf0e10cSrcweir 1142*cdf0e10cSrcweir SfxPoolItem* pDefaults[] = 1143*cdf0e10cSrcweir { 1144*cdf0e10cSrcweir new SfxRangeItem(SBA_DEF_RANGEFORMAT, SBA_DEF_FMTVALUE, SBA_ATTR_ALIGN_HOR_JUSTIFY), 1145*cdf0e10cSrcweir new SfxUInt32Item(SBA_DEF_FMTVALUE), 1146*cdf0e10cSrcweir new SvxHorJustifyItem(SVX_HOR_JUSTIFY_STANDARD, SBA_ATTR_ALIGN_HOR_JUSTIFY), 1147*cdf0e10cSrcweir new SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_False), 1148*cdf0e10cSrcweir new SvxNumberInfoItem(SID_ATTR_NUMBERFORMAT_INFO) 1149*cdf0e10cSrcweir }; 1150*cdf0e10cSrcweir 1151*cdf0e10cSrcweir SfxItemPool* pPool = new SfxItemPool(String::CreateFromAscii("GridBrowserProperties"), SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY, aItemInfos, pDefaults); 1152*cdf0e10cSrcweir pPool->SetDefaultMetric( SFX_MAPUNIT_TWIP ); // ripped, don't understand why 1153*cdf0e10cSrcweir pPool->FreezeIdRanges(); // the same 1154*cdf0e10cSrcweir 1155*cdf0e10cSrcweir SfxItemSet* pFormatDescriptor = new SfxItemSet(*pPool, aAttrMap); 1156*cdf0e10cSrcweir // fill it 1157*cdf0e10cSrcweir pFormatDescriptor->Put(SvxHorJustifyItem(_eJustify, SBA_ATTR_ALIGN_HOR_JUSTIFY)); 1158*cdf0e10cSrcweir sal_Bool bText = sal_False; 1159*cdf0e10cSrcweir if (_bHasFormat) 1160*cdf0e10cSrcweir { 1161*cdf0e10cSrcweir // if the col is bound to a text field we have to disallow all non-text formats 1162*cdf0e10cSrcweir if ((DataType::CHAR == _nDataType) || (DataType::VARCHAR == _nDataType) || (DataType::LONGVARCHAR == _nDataType) || (DataType::CLOB == _nDataType)) 1163*cdf0e10cSrcweir { 1164*cdf0e10cSrcweir bText = sal_True; 1165*cdf0e10cSrcweir pFormatDescriptor->Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_True)); 1166*cdf0e10cSrcweir if (!_pFormatter->IsTextFormat(_nFormatKey)) 1167*cdf0e10cSrcweir // text fields can only have text formats 1168*cdf0e10cSrcweir _nFormatKey = _pFormatter->GetStandardFormat(NUMBERFORMAT_TEXT,_pParent->GetSettings().GetLanguage()); 1169*cdf0e10cSrcweir } 1170*cdf0e10cSrcweir 1171*cdf0e10cSrcweir pFormatDescriptor->Put(SfxUInt32Item(SBA_DEF_FMTVALUE, _nFormatKey)); 1172*cdf0e10cSrcweir } 1173*cdf0e10cSrcweir 1174*cdf0e10cSrcweir if (!bText) 1175*cdf0e10cSrcweir { 1176*cdf0e10cSrcweir double dPreviewVal = 1234.56789; 1177*cdf0e10cSrcweir SvxNumberInfoItem aFormatter(_pFormatter, dPreviewVal, SID_ATTR_NUMBERFORMAT_INFO); 1178*cdf0e10cSrcweir pFormatDescriptor->Put(aFormatter); 1179*cdf0e10cSrcweir } 1180*cdf0e10cSrcweir 1181*cdf0e10cSrcweir { // want the dialog to be destroyed before our set 1182*cdf0e10cSrcweir SbaSbAttrDlg aDlg(_pParent, pFormatDescriptor, _pFormatter, _nFlags); 1183*cdf0e10cSrcweir if (RET_OK == aDlg.Execute()) 1184*cdf0e10cSrcweir { 1185*cdf0e10cSrcweir // ------------ 1186*cdf0e10cSrcweir // ItemSet->UNO 1187*cdf0e10cSrcweir // UNO-properties 1188*cdf0e10cSrcweir const SfxItemSet* pSet = aDlg.GetExampleSet(); 1189*cdf0e10cSrcweir // (of course we could put the modified items directly into the column, but then the UNO-model 1190*cdf0e10cSrcweir // won't reflect these changes, and why do we have a model, then ?) 1191*cdf0e10cSrcweir 1192*cdf0e10cSrcweir // horizontal justify 1193*cdf0e10cSrcweir SFX_ITEMSET_GET(*pSet, pHorJustify, SvxHorJustifyItem, SBA_ATTR_ALIGN_HOR_JUSTIFY, sal_True); 1194*cdf0e10cSrcweir 1195*cdf0e10cSrcweir _eJustify = (SvxCellHorJustify)pHorJustify->GetValue(); 1196*cdf0e10cSrcweir 1197*cdf0e10cSrcweir // format key 1198*cdf0e10cSrcweir if (_nFlags & TP_ATTR_NUMBER) 1199*cdf0e10cSrcweir { 1200*cdf0e10cSrcweir SFX_ITEMSET_GET(*pSet, pFormat, SfxUInt32Item, SBA_DEF_FMTVALUE, sal_True); 1201*cdf0e10cSrcweir _nFormatKey = (sal_Int32)pFormat->GetValue(); 1202*cdf0e10cSrcweir } 1203*cdf0e10cSrcweir bRet = sal_True; 1204*cdf0e10cSrcweir } 1205*cdf0e10cSrcweir // deleted formats 1206*cdf0e10cSrcweir const SfxItemSet* pResult = aDlg.GetOutputItemSet(); 1207*cdf0e10cSrcweir if (pResult) 1208*cdf0e10cSrcweir { 1209*cdf0e10cSrcweir const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO ); 1210*cdf0e10cSrcweir const SvxNumberInfoItem* pInfoItem = static_cast<const SvxNumberInfoItem*>(pItem); 1211*cdf0e10cSrcweir if (pInfoItem && pInfoItem->GetDelCount()) 1212*cdf0e10cSrcweir { 1213*cdf0e10cSrcweir const sal_uInt32* pDeletedKeys = pInfoItem->GetDelArray(); 1214*cdf0e10cSrcweir 1215*cdf0e10cSrcweir for (sal_uInt16 i=0; i< pInfoItem->GetDelCount(); ++i, ++pDeletedKeys) 1216*cdf0e10cSrcweir _pFormatter->DeleteEntry(*pDeletedKeys); 1217*cdf0e10cSrcweir } 1218*cdf0e10cSrcweir } 1219*cdf0e10cSrcweir } 1220*cdf0e10cSrcweir 1221*cdf0e10cSrcweir delete pFormatDescriptor; 1222*cdf0e10cSrcweir SfxItemPool::Free(pPool); 1223*cdf0e10cSrcweir for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i) 1224*cdf0e10cSrcweir delete pDefaults[i]; 1225*cdf0e10cSrcweir 1226*cdf0e10cSrcweir return bRet; 1227*cdf0e10cSrcweir } 1228*cdf0e10cSrcweir 1229*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1230*cdf0e10cSrcweir const SfxFilter* getStandardDatabaseFilter() 1231*cdf0e10cSrcweir { 1232*cdf0e10cSrcweir static const String s_sDatabaseType = String::CreateFromAscii("StarOffice XML (Base)"); 1233*cdf0e10cSrcweir const SfxFilter* pFilter = SfxFilter::GetFilterByName( s_sDatabaseType); 1234*cdf0e10cSrcweir OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!"); 1235*cdf0e10cSrcweir return pFilter; 1236*cdf0e10cSrcweir } 1237*cdf0e10cSrcweir 1238*cdf0e10cSrcweir 1239*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1240*cdf0e10cSrcweir sal_Bool appendToFilter(const Reference<XConnection>& _xConnection, 1241*cdf0e10cSrcweir const ::rtl::OUString& _sName, 1242*cdf0e10cSrcweir const Reference< XMultiServiceFactory >& _xFactory, 1243*cdf0e10cSrcweir Window* _pParent) 1244*cdf0e10cSrcweir { 1245*cdf0e10cSrcweir sal_Bool bRet = sal_False; 1246*cdf0e10cSrcweir Reference< XChild> xChild(_xConnection,UNO_QUERY); 1247*cdf0e10cSrcweir if(xChild.is()) 1248*cdf0e10cSrcweir { 1249*cdf0e10cSrcweir Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY); 1250*cdf0e10cSrcweir if(xProp.is()) 1251*cdf0e10cSrcweir { 1252*cdf0e10cSrcweir Sequence< ::rtl::OUString > aFilter; 1253*cdf0e10cSrcweir xProp->getPropertyValue(PROPERTY_TABLEFILTER) >>= aFilter; 1254*cdf0e10cSrcweir // first check if we have something like SCHEMA.% 1255*cdf0e10cSrcweir sal_Bool bHasToInsert = sal_True; 1256*cdf0e10cSrcweir static ::rtl::OUString sPattern = ::rtl::OUString::createFromAscii("%"); 1257*cdf0e10cSrcweir const ::rtl::OUString* pBegin = aFilter.getConstArray(); 1258*cdf0e10cSrcweir const ::rtl::OUString* pEnd = pBegin + aFilter.getLength(); 1259*cdf0e10cSrcweir for (;pBegin != pEnd; ++pBegin) 1260*cdf0e10cSrcweir { 1261*cdf0e10cSrcweir if(pBegin->indexOf('%') != -1) 1262*cdf0e10cSrcweir { 1263*cdf0e10cSrcweir sal_Int32 nLen; 1264*cdf0e10cSrcweir if((nLen = pBegin->lastIndexOf('.')) != -1 && !pBegin->compareTo(_sName,nLen)) 1265*cdf0e10cSrcweir bHasToInsert = sal_False; 1266*cdf0e10cSrcweir else if(pBegin->getLength() == 1) 1267*cdf0e10cSrcweir bHasToInsert = sal_False; 1268*cdf0e10cSrcweir } 1269*cdf0e10cSrcweir } 1270*cdf0e10cSrcweir 1271*cdf0e10cSrcweir bRet = sal_True; 1272*cdf0e10cSrcweir if(bHasToInsert) 1273*cdf0e10cSrcweir { 1274*cdf0e10cSrcweir if(! ::dbaui::checkDataSourceAvailable(::comphelper::getString(xProp->getPropertyValue(PROPERTY_NAME)),_xFactory)) 1275*cdf0e10cSrcweir { 1276*cdf0e10cSrcweir String aMessage(ModuleRes(STR_TABLEDESIGN_DATASOURCE_DELETED)); 1277*cdf0e10cSrcweir OSQLWarningBox( _pParent, aMessage ).Execute(); 1278*cdf0e10cSrcweir bRet = sal_False; 1279*cdf0e10cSrcweir } 1280*cdf0e10cSrcweir else 1281*cdf0e10cSrcweir { 1282*cdf0e10cSrcweir aFilter.realloc(aFilter.getLength()+1); 1283*cdf0e10cSrcweir aFilter.getArray()[aFilter.getLength()-1] = _sName; 1284*cdf0e10cSrcweir xProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aFilter)); 1285*cdf0e10cSrcweir } 1286*cdf0e10cSrcweir } 1287*cdf0e10cSrcweir } 1288*cdf0e10cSrcweir } 1289*cdf0e10cSrcweir return bRet; 1290*cdf0e10cSrcweir } 1291*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1292*cdf0e10cSrcweir void notifySystemWindow(Window* _pWindow,Window* _pToRegister, ::comphelper::mem_fun1_t<TaskPaneList,Window*> _rMemFunc) 1293*cdf0e10cSrcweir { 1294*cdf0e10cSrcweir OSL_ENSURE(_pWindow,"Window can not be null!"); 1295*cdf0e10cSrcweir SystemWindow* pSystemWindow = _pWindow ? _pWindow->GetSystemWindow() : NULL; 1296*cdf0e10cSrcweir if ( pSystemWindow ) 1297*cdf0e10cSrcweir { 1298*cdf0e10cSrcweir _rMemFunc( pSystemWindow->GetTaskPaneList(), _pToRegister ); 1299*cdf0e10cSrcweir } 1300*cdf0e10cSrcweir } 1301*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1302*cdf0e10cSrcweir void adjustToolBoxSize(ToolBox* _pToolBox) 1303*cdf0e10cSrcweir { 1304*cdf0e10cSrcweir // adjust the toolbox size, otherwise large bitmaps don't fit into 1305*cdf0e10cSrcweir Size aOldSize = _pToolBox->GetSizePixel(); 1306*cdf0e10cSrcweir Size aSize = _pToolBox->CalcWindowSizePixel(); 1307*cdf0e10cSrcweir if ( !aSize.Width() ) 1308*cdf0e10cSrcweir aSize.Width() = aOldSize.Width(); 1309*cdf0e10cSrcweir else if ( !aSize.Height() ) 1310*cdf0e10cSrcweir aSize.Height() = aOldSize.Height(); 1311*cdf0e10cSrcweir 1312*cdf0e10cSrcweir Size aTbSize = _pToolBox->GetSizePixel(); 1313*cdf0e10cSrcweir if ( (aSize.Width() && aSize.Width() != aTbSize.Width()) || 1314*cdf0e10cSrcweir (aSize.Height() && aSize.Height() != aTbSize.Height()) ) 1315*cdf0e10cSrcweir { 1316*cdf0e10cSrcweir _pToolBox->SetPosSizePixel( _pToolBox->GetPosPixel(), aSize ); 1317*cdf0e10cSrcweir _pToolBox->Invalidate(); 1318*cdf0e10cSrcweir } 1319*cdf0e10cSrcweir } 1320*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1321*cdf0e10cSrcweir sal_Bool isHiContrast(Window* _pWindow) 1322*cdf0e10cSrcweir { 1323*cdf0e10cSrcweir OSL_ENSURE(_pWindow,"Window must be not null!"); 1324*cdf0e10cSrcweir Window* pIter = _pWindow; 1325*cdf0e10cSrcweir // while( pIter && pIter->GetBackground().GetColor().GetColor() == COL_TRANSPARENT ) 1326*cdf0e10cSrcweir while( pIter ) 1327*cdf0e10cSrcweir { 1328*cdf0e10cSrcweir if ( pIter->GetBackground().GetColor().GetColor() == COL_TRANSPARENT ) 1329*cdf0e10cSrcweir pIter = pIter->GetParent(); 1330*cdf0e10cSrcweir else 1331*cdf0e10cSrcweir break; 1332*cdf0e10cSrcweir } 1333*cdf0e10cSrcweir return pIter && pIter->GetSettings().GetStyleSettings().GetHighContrastMode(); 1334*cdf0e10cSrcweir } 1335*cdf0e10cSrcweir 1336*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1337*cdf0e10cSrcweir void adjustBrowseBoxColumnWidth( ::svt::EditBrowseBox* _pBox, sal_uInt16 _nColId ) 1338*cdf0e10cSrcweir { 1339*cdf0e10cSrcweir sal_Int32 nColSize = -1; 1340*cdf0e10cSrcweir sal_uInt32 nDefaultWidth = _pBox->GetDefaultColumnWidth( _pBox->GetColumnTitle( _nColId ) ); 1341*cdf0e10cSrcweir if ( nDefaultWidth != _pBox->GetColumnWidth( _nColId ) ) 1342*cdf0e10cSrcweir { 1343*cdf0e10cSrcweir Size aSizeMM = _pBox->PixelToLogic( Size( _pBox->GetColumnWidth( _nColId ), 0 ), MapMode( MAP_MM ) ); 1344*cdf0e10cSrcweir nColSize = aSizeMM.Width() * 10; 1345*cdf0e10cSrcweir } 1346*cdf0e10cSrcweir 1347*cdf0e10cSrcweir Size aDefaultMM = _pBox->PixelToLogic( Size( nDefaultWidth, 0 ), MapMode( MAP_MM ) ); 1348*cdf0e10cSrcweir 1349*cdf0e10cSrcweir DlgSize aColumnSizeDlg( _pBox, nColSize, sal_False, aDefaultMM.Width() * 10 ); 1350*cdf0e10cSrcweir if ( aColumnSizeDlg.Execute() ) 1351*cdf0e10cSrcweir { 1352*cdf0e10cSrcweir sal_Int32 nValue = aColumnSizeDlg.GetValue(); 1353*cdf0e10cSrcweir if ( -1 == nValue ) 1354*cdf0e10cSrcweir { // default width 1355*cdf0e10cSrcweir nValue = _pBox->GetDefaultColumnWidth( _pBox->GetColumnTitle( _nColId ) ); 1356*cdf0e10cSrcweir } 1357*cdf0e10cSrcweir else 1358*cdf0e10cSrcweir { 1359*cdf0e10cSrcweir Size aSizeMM( nValue / 10, 0 ); 1360*cdf0e10cSrcweir nValue = _pBox->LogicToPixel( aSizeMM, MapMode( MAP_MM ) ).Width(); 1361*cdf0e10cSrcweir } 1362*cdf0e10cSrcweir _pBox->SetColumnWidth( _nColId, nValue ); 1363*cdf0e10cSrcweir } 1364*cdf0e10cSrcweir } 1365*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1366*cdf0e10cSrcweir // check if SQL92 name checking is enabled 1367*cdf0e10cSrcweir sal_Bool isSQL92CheckEnabled(const Reference<XConnection>& _xConnection) 1368*cdf0e10cSrcweir { 1369*cdf0e10cSrcweir return ::dbtools::getBooleanDataSourceSetting( _xConnection, PROPERTY_ENABLESQL92CHECK ); 1370*cdf0e10cSrcweir } 1371*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1372*cdf0e10cSrcweir sal_Bool isAppendTableAliasEnabled(const Reference<XConnection>& _xConnection) 1373*cdf0e10cSrcweir { 1374*cdf0e10cSrcweir return ::dbtools::getBooleanDataSourceSetting( _xConnection, INFO_APPEND_TABLE_ALIAS ); 1375*cdf0e10cSrcweir } 1376*cdf0e10cSrcweir 1377*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1378*cdf0e10cSrcweir sal_Bool generateAsBeforeTableAlias(const Reference<XConnection>& _xConnection) 1379*cdf0e10cSrcweir { 1380*cdf0e10cSrcweir return ::dbtools::getBooleanDataSourceSetting( _xConnection, INFO_AS_BEFORE_CORRELATION_NAME ); 1381*cdf0e10cSrcweir } 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1384*cdf0e10cSrcweir void fillAutoIncrementValue(const Reference<XPropertySet>& _xDatasource, 1385*cdf0e10cSrcweir sal_Bool& _rAutoIncrementValueEnabled, 1386*cdf0e10cSrcweir ::rtl::OUString& _rsAutoIncrementValue) 1387*cdf0e10cSrcweir { 1388*cdf0e10cSrcweir if ( _xDatasource.is() ) 1389*cdf0e10cSrcweir { 1390*cdf0e10cSrcweir OSL_ENSURE(_xDatasource->getPropertySetInfo()->hasPropertyByName(PROPERTY_INFO),"NO datasource supplied!"); 1391*cdf0e10cSrcweir Sequence<PropertyValue> aInfo; 1392*cdf0e10cSrcweir _xDatasource->getPropertyValue(PROPERTY_INFO) >>= aInfo; 1393*cdf0e10cSrcweir 1394*cdf0e10cSrcweir // search the right propertyvalue 1395*cdf0e10cSrcweir const PropertyValue* pValue =::std::find_if(aInfo.getConstArray(), 1396*cdf0e10cSrcweir aInfo.getConstArray() + aInfo.getLength(), 1397*cdf0e10cSrcweir ::std::bind2nd(TPropertyValueEqualFunctor(),PROPERTY_AUTOINCREMENTCREATION)); 1398*cdf0e10cSrcweir if ( pValue && pValue != (aInfo.getConstArray() + aInfo.getLength()) ) 1399*cdf0e10cSrcweir pValue->Value >>= _rsAutoIncrementValue; 1400*cdf0e10cSrcweir pValue =::std::find_if(aInfo.getConstArray(), 1401*cdf0e10cSrcweir aInfo.getConstArray() + aInfo.getLength(), 1402*cdf0e10cSrcweir ::std::bind2nd(TPropertyValueEqualFunctor(),::rtl::OUString::createFromAscii("IsAutoRetrievingEnabled") )); 1403*cdf0e10cSrcweir if ( pValue && pValue != (aInfo.getConstArray() + aInfo.getLength()) ) 1404*cdf0e10cSrcweir pValue->Value >>= _rAutoIncrementValueEnabled; 1405*cdf0e10cSrcweir } 1406*cdf0e10cSrcweir } 1407*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1408*cdf0e10cSrcweir void fillAutoIncrementValue(const Reference<XConnection>& _xConnection, 1409*cdf0e10cSrcweir sal_Bool& _rAutoIncrementValueEnabled, 1410*cdf0e10cSrcweir ::rtl::OUString& _rsAutoIncrementValue) 1411*cdf0e10cSrcweir { 1412*cdf0e10cSrcweir Reference< XChild> xChild(_xConnection,UNO_QUERY); 1413*cdf0e10cSrcweir if(xChild.is()) 1414*cdf0e10cSrcweir { 1415*cdf0e10cSrcweir Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY); 1416*cdf0e10cSrcweir fillAutoIncrementValue(xProp,_rAutoIncrementValueEnabled,_rsAutoIncrementValue); 1417*cdf0e10cSrcweir } 1418*cdf0e10cSrcweir } 1419*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1420*cdf0e10cSrcweir ::rtl::OUString getStrippedDatabaseName(const Reference<XPropertySet>& _xDataSource,::rtl::OUString& _rsDatabaseName) 1421*cdf0e10cSrcweir { 1422*cdf0e10cSrcweir if ( !_rsDatabaseName.getLength() && _xDataSource.is() ) 1423*cdf0e10cSrcweir { 1424*cdf0e10cSrcweir try 1425*cdf0e10cSrcweir { 1426*cdf0e10cSrcweir _xDataSource->getPropertyValue(PROPERTY_NAME) >>= _rsDatabaseName; 1427*cdf0e10cSrcweir } 1428*cdf0e10cSrcweir catch(const Exception& ) 1429*cdf0e10cSrcweir { 1430*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1431*cdf0e10cSrcweir } 1432*cdf0e10cSrcweir } 1433*cdf0e10cSrcweir ::rtl::OUString sName = _rsDatabaseName; 1434*cdf0e10cSrcweir INetURLObject aURL(sName); 1435*cdf0e10cSrcweir if ( aURL.GetProtocol() != INET_PROT_NOT_VALID ) 1436*cdf0e10cSrcweir sName = aURL.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_UNAMBIGUOUS); 1437*cdf0e10cSrcweir return sName; 1438*cdf0e10cSrcweir } 1439*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1440*cdf0e10cSrcweir void AppendConfigToken( ::rtl::OUString& _rURL, sal_Bool _bQuestionMark ) 1441*cdf0e10cSrcweir { 1442*cdf0e10cSrcweir Any aLocale = 1443*cdf0e10cSrcweir ::utl::ConfigManager::GetConfigManager()->GetDirectConfigProperty( ::utl::ConfigManager::LOCALE ); 1444*cdf0e10cSrcweir ::rtl::OUString sLocaleStr; 1445*cdf0e10cSrcweir if ( !( aLocale >>= sLocaleStr ) ) 1446*cdf0e10cSrcweir // fallback is english 1447*cdf0e10cSrcweir sLocaleStr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en")); 1448*cdf0e10cSrcweir 1449*cdf0e10cSrcweir // query part exists? 1450*cdf0e10cSrcweir if ( _bQuestionMark ) 1451*cdf0e10cSrcweir // no, so start with '?' 1452*cdf0e10cSrcweir _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("?")); 1453*cdf0e10cSrcweir else 1454*cdf0e10cSrcweir // yes, so only append with '&' 1455*cdf0e10cSrcweir _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("&")); 1456*cdf0e10cSrcweir 1457*cdf0e10cSrcweir // set parameters 1458*cdf0e10cSrcweir _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Language=")); 1459*cdf0e10cSrcweir _rURL += sLocaleStr; 1460*cdf0e10cSrcweir _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("&System=")); 1461*cdf0e10cSrcweir _rURL += SvtHelpOptions().GetSystem(); 1462*cdf0e10cSrcweir } 1463*cdf0e10cSrcweir 1464*cdf0e10cSrcweir namespace 1465*cdf0e10cSrcweir { 1466*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1467*cdf0e10cSrcweir 1468*cdf0e10cSrcweir sal_Bool GetHelpAnchor_Impl( const ::rtl::OUString& _rURL, ::rtl::OUString& _rAnchor ) 1469*cdf0e10cSrcweir { 1470*cdf0e10cSrcweir sal_Bool bRet = sal_False; 1471*cdf0e10cSrcweir ::rtl::OUString sAnchor; 1472*cdf0e10cSrcweir 1473*cdf0e10cSrcweir try 1474*cdf0e10cSrcweir { 1475*cdf0e10cSrcweir ::ucbhelper::Content aCnt( INetURLObject( _rURL ).GetMainURL( INetURLObject::NO_DECODE ), 1476*cdf0e10cSrcweir Reference< ::com::sun::star::ucb::XCommandEnvironment > () ); 1477*cdf0e10cSrcweir if ( ( aCnt.getPropertyValue( ::rtl::OUString::createFromAscii( "AnchorName" ) ) >>= sAnchor ) ) 1478*cdf0e10cSrcweir { 1479*cdf0e10cSrcweir 1480*cdf0e10cSrcweir if ( sAnchor.getLength() > 0 ) 1481*cdf0e10cSrcweir { 1482*cdf0e10cSrcweir _rAnchor = sAnchor; 1483*cdf0e10cSrcweir bRet = sal_True; 1484*cdf0e10cSrcweir } 1485*cdf0e10cSrcweir } 1486*cdf0e10cSrcweir else 1487*cdf0e10cSrcweir { 1488*cdf0e10cSrcweir DBG_ERRORFILE( "Property 'AnchorName' is missing" ); 1489*cdf0e10cSrcweir } 1490*cdf0e10cSrcweir } 1491*cdf0e10cSrcweir catch( Exception& ) 1492*cdf0e10cSrcweir { 1493*cdf0e10cSrcweir } 1494*cdf0e10cSrcweir 1495*cdf0e10cSrcweir return bRet; 1496*cdf0e10cSrcweir } 1497*cdf0e10cSrcweir // ......................................................................... 1498*cdf0e10cSrcweir } // annonymous 1499*cdf0e10cSrcweir // ......................................................................... 1500*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1501*cdf0e10cSrcweir ::com::sun::star::util::URL createHelpAgentURL(const ::rtl::OUString& _sModuleName, const rtl::OString& sHelpId) 1502*cdf0e10cSrcweir { 1503*cdf0e10cSrcweir ::com::sun::star::util::URL aURL; 1504*cdf0e10cSrcweir aURL.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.help://" ) ); 1505*cdf0e10cSrcweir aURL.Complete += _sModuleName; 1506*cdf0e10cSrcweir aURL.Complete += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ); 1507*cdf0e10cSrcweir aURL.Complete += ::rtl::OUString(sHelpId, sHelpId.getLength(), RTL_TEXTENCODING_UTF8); 1508*cdf0e10cSrcweir 1509*cdf0e10cSrcweir ::rtl::OUString sAnchor; 1510*cdf0e10cSrcweir ::rtl::OUString sTempURL = aURL.Complete; 1511*cdf0e10cSrcweir AppendConfigToken( sTempURL, sal_True ); 1512*cdf0e10cSrcweir sal_Bool bHasAnchor = GetHelpAnchor_Impl( sTempURL, sAnchor ); 1513*cdf0e10cSrcweir AppendConfigToken(aURL.Complete,sal_True); 1514*cdf0e10cSrcweir if ( bHasAnchor ) 1515*cdf0e10cSrcweir { 1516*cdf0e10cSrcweir aURL.Complete += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("#")); 1517*cdf0e10cSrcweir aURL.Complete += sAnchor; 1518*cdf0e10cSrcweir } 1519*cdf0e10cSrcweir return aURL; 1520*cdf0e10cSrcweir } 1521*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1522*cdf0e10cSrcweir void setEvalDateFormatForFormatter(Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter) 1523*cdf0e10cSrcweir { 1524*cdf0e10cSrcweir OSL_ENSURE( _rxFormatter.is(),"setEvalDateFormatForFormatter: Formatter is NULL!"); 1525*cdf0e10cSrcweir if ( _rxFormatter.is() ) 1526*cdf0e10cSrcweir { 1527*cdf0e10cSrcweir Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = _rxFormatter->getNumberFormatsSupplier(); 1528*cdf0e10cSrcweir 1529*cdf0e10cSrcweir Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY); 1530*cdf0e10cSrcweir SvNumberFormatsSupplierObj* pSupplierImpl = reinterpret_cast<SvNumberFormatsSupplierObj*>(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId())); 1531*cdf0e10cSrcweir OSL_ENSURE(pSupplierImpl,"No Supplier!"); 1532*cdf0e10cSrcweir 1533*cdf0e10cSrcweir if ( pSupplierImpl ) 1534*cdf0e10cSrcweir { 1535*cdf0e10cSrcweir SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter(); 1536*cdf0e10cSrcweir pFormatter->SetEvalDateFormat(NF_EVALDATEFORMAT_FORMAT); 1537*cdf0e10cSrcweir } 1538*cdf0e10cSrcweir } 1539*cdf0e10cSrcweir } 1540*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1541*cdf0e10cSrcweir TOTypeInfoSP queryPrimaryKeyType(const OTypeInfoMap& _rTypeInfo) 1542*cdf0e10cSrcweir { 1543*cdf0e10cSrcweir TOTypeInfoSP pTypeInfo; 1544*cdf0e10cSrcweir // first we search for a type which supports autoIncrement 1545*cdf0e10cSrcweir OTypeInfoMap::const_iterator aIter = _rTypeInfo.begin(); 1546*cdf0e10cSrcweir OTypeInfoMap::const_iterator aEnd = _rTypeInfo.end(); 1547*cdf0e10cSrcweir for(;aIter != aEnd;++aIter) 1548*cdf0e10cSrcweir { 1549*cdf0e10cSrcweir // OJ: we don't want to set an autoincrement column to be key 1550*cdf0e10cSrcweir // because we don't have the possiblity to know how to create 1551*cdf0e10cSrcweir // such auto increment column later on 1552*cdf0e10cSrcweir // so until we know how to do it, we create a column without autoincrement 1553*cdf0e10cSrcweir // if ( !aIter->second->bAutoIncrement ) 1554*cdf0e10cSrcweir { // therefor we have searched 1555*cdf0e10cSrcweir if ( aIter->second->nType == DataType::INTEGER ) 1556*cdf0e10cSrcweir { 1557*cdf0e10cSrcweir pTypeInfo = aIter->second; // alternative 1558*cdf0e10cSrcweir break; 1559*cdf0e10cSrcweir } 1560*cdf0e10cSrcweir else if ( !pTypeInfo.get() && aIter->second->nType == DataType::DOUBLE ) 1561*cdf0e10cSrcweir pTypeInfo = aIter->second; // alternative 1562*cdf0e10cSrcweir else if ( !pTypeInfo.get() && aIter->second->nType == DataType::REAL ) 1563*cdf0e10cSrcweir pTypeInfo = aIter->second; // alternative 1564*cdf0e10cSrcweir } 1565*cdf0e10cSrcweir } 1566*cdf0e10cSrcweir if ( !pTypeInfo.get() ) // just a fallback 1567*cdf0e10cSrcweir pTypeInfo = queryTypeInfoByType(DataType::VARCHAR,_rTypeInfo); 1568*cdf0e10cSrcweir 1569*cdf0e10cSrcweir OSL_ENSURE(pTypeInfo.get(),"checkColumns: cann't find a type which is useable as a key!"); 1570*cdf0e10cSrcweir return pTypeInfo; 1571*cdf0e10cSrcweir } 1572*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1573*cdf0e10cSrcweir TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rTypeInfo) 1574*cdf0e10cSrcweir { 1575*cdf0e10cSrcweir OTypeInfoMap::const_iterator aIter = _rTypeInfo.find(_nDataType); 1576*cdf0e10cSrcweir if(aIter != _rTypeInfo.end()) 1577*cdf0e10cSrcweir return aIter->second; 1578*cdf0e10cSrcweir // fall back if the type is unknown 1579*cdf0e10cSrcweir TOTypeInfoSP pTypeInfo; 1580*cdf0e10cSrcweir switch(_nDataType) 1581*cdf0e10cSrcweir { 1582*cdf0e10cSrcweir case DataType::TINYINT: 1583*cdf0e10cSrcweir if( pTypeInfo = queryTypeInfoByType(DataType::SMALLINT,_rTypeInfo)) 1584*cdf0e10cSrcweir break; 1585*cdf0e10cSrcweir // run through 1586*cdf0e10cSrcweir case DataType::SMALLINT: 1587*cdf0e10cSrcweir if( pTypeInfo = queryTypeInfoByType(DataType::INTEGER,_rTypeInfo)) 1588*cdf0e10cSrcweir break; 1589*cdf0e10cSrcweir // run through 1590*cdf0e10cSrcweir case DataType::INTEGER: 1591*cdf0e10cSrcweir if( pTypeInfo = queryTypeInfoByType(DataType::FLOAT,_rTypeInfo)) 1592*cdf0e10cSrcweir break; 1593*cdf0e10cSrcweir // run through 1594*cdf0e10cSrcweir case DataType::FLOAT: 1595*cdf0e10cSrcweir if( pTypeInfo = queryTypeInfoByType(DataType::REAL,_rTypeInfo)) 1596*cdf0e10cSrcweir break; 1597*cdf0e10cSrcweir // run through 1598*cdf0e10cSrcweir case DataType::DATE: 1599*cdf0e10cSrcweir case DataType::TIME: 1600*cdf0e10cSrcweir if( DataType::DATE == _nDataType || DataType::TIME == _nDataType ) 1601*cdf0e10cSrcweir { 1602*cdf0e10cSrcweir if( pTypeInfo = queryTypeInfoByType(DataType::TIMESTAMP,_rTypeInfo)) 1603*cdf0e10cSrcweir break; 1604*cdf0e10cSrcweir } 1605*cdf0e10cSrcweir // run through 1606*cdf0e10cSrcweir case DataType::TIMESTAMP: 1607*cdf0e10cSrcweir case DataType::REAL: 1608*cdf0e10cSrcweir case DataType::BIGINT: 1609*cdf0e10cSrcweir if ( pTypeInfo = queryTypeInfoByType(DataType::DOUBLE,_rTypeInfo) ) 1610*cdf0e10cSrcweir break; 1611*cdf0e10cSrcweir // run through 1612*cdf0e10cSrcweir case DataType::DOUBLE: 1613*cdf0e10cSrcweir if ( pTypeInfo = queryTypeInfoByType(DataType::NUMERIC,_rTypeInfo) ) 1614*cdf0e10cSrcweir break; 1615*cdf0e10cSrcweir // run through 1616*cdf0e10cSrcweir case DataType::NUMERIC: 1617*cdf0e10cSrcweir pTypeInfo = queryTypeInfoByType(DataType::DECIMAL,_rTypeInfo); 1618*cdf0e10cSrcweir break; 1619*cdf0e10cSrcweir case DataType::DECIMAL: 1620*cdf0e10cSrcweir if ( pTypeInfo = queryTypeInfoByType(DataType::NUMERIC,_rTypeInfo) ) 1621*cdf0e10cSrcweir break; 1622*cdf0e10cSrcweir if ( pTypeInfo = queryTypeInfoByType(DataType::DOUBLE,_rTypeInfo) ) 1623*cdf0e10cSrcweir break; 1624*cdf0e10cSrcweir break; 1625*cdf0e10cSrcweir case DataType::VARCHAR: 1626*cdf0e10cSrcweir if ( pTypeInfo = queryTypeInfoByType(DataType::LONGVARCHAR,_rTypeInfo) ) 1627*cdf0e10cSrcweir break; 1628*cdf0e10cSrcweir break; 1629*cdf0e10cSrcweir case DataType::LONGVARCHAR: 1630*cdf0e10cSrcweir if ( pTypeInfo = queryTypeInfoByType(DataType::CLOB,_rTypeInfo) ) 1631*cdf0e10cSrcweir break; 1632*cdf0e10cSrcweir break; 1633*cdf0e10cSrcweir default: 1634*cdf0e10cSrcweir ; 1635*cdf0e10cSrcweir } // switch(_nDataType) 1636*cdf0e10cSrcweir if ( !pTypeInfo ) 1637*cdf0e10cSrcweir { 1638*cdf0e10cSrcweir ::rtl::OUString sCreate(RTL_CONSTASCII_USTRINGPARAM("x")),sTypeName; 1639*cdf0e10cSrcweir sal_Bool bForce = sal_True; 1640*cdf0e10cSrcweir pTypeInfo = ::dbaui::getTypeInfoFromType(_rTypeInfo,DataType::VARCHAR,sTypeName,sCreate,50,0,sal_False,bForce); 1641*cdf0e10cSrcweir } // if ( !pTypeInfo ) 1642*cdf0e10cSrcweir OSL_ENSURE(pTypeInfo,"Wrong DataType supplied!"); 1643*cdf0e10cSrcweir return pTypeInfo; 1644*cdf0e10cSrcweir } 1645*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1646*cdf0e10cSrcweir sal_Int32 askForUserAction(Window* _pParent,sal_uInt16 _nTitle,sal_uInt16 _nText,sal_Bool _bAll,const ::rtl::OUString& _sName) 1647*cdf0e10cSrcweir { 1648*cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() ); 1649*cdf0e10cSrcweir String aMsg = String(ModuleRes(_nText)); 1650*cdf0e10cSrcweir aMsg.SearchAndReplace(String::CreateFromAscii("%1"),String(_sName)); 1651*cdf0e10cSrcweir OSQLMessageBox aAsk(_pParent,String(ModuleRes(_nTitle )),aMsg,WB_YES_NO | WB_DEF_YES,OSQLMessageBox::Query); 1652*cdf0e10cSrcweir if ( _bAll ) 1653*cdf0e10cSrcweir { 1654*cdf0e10cSrcweir aAsk.AddButton(String(ModuleRes(STR_BUTTON_TEXT_ALL)), RET_ALL, 0); 1655*cdf0e10cSrcweir aAsk.GetPushButton(RET_ALL)->SetHelpId(HID_CONFIRM_DROP_BUTTON_ALL); 1656*cdf0e10cSrcweir } 1657*cdf0e10cSrcweir return aAsk.Execute(); 1658*cdf0e10cSrcweir } 1659*cdf0e10cSrcweir 1660*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1661*cdf0e10cSrcweir namespace 1662*cdf0e10cSrcweir { 1663*cdf0e10cSrcweir static ::rtl::OUString lcl_createSDBCLevelStatement( const ::rtl::OUString& _rStatement, const Reference< XConnection >& _rxConnection ) 1664*cdf0e10cSrcweir { 1665*cdf0e10cSrcweir ::rtl::OUString sSDBCLevelStatement( _rStatement ); 1666*cdf0e10cSrcweir try 1667*cdf0e10cSrcweir { 1668*cdf0e10cSrcweir Reference< XMultiServiceFactory > xAnalyzerFactory( _rxConnection, UNO_QUERY_THROW ); 1669*cdf0e10cSrcweir Reference< XSingleSelectQueryAnalyzer > xAnalyzer( xAnalyzerFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW ); 1670*cdf0e10cSrcweir xAnalyzer->setQuery( _rStatement ); 1671*cdf0e10cSrcweir sSDBCLevelStatement = xAnalyzer->getQueryWithSubstitution(); 1672*cdf0e10cSrcweir } 1673*cdf0e10cSrcweir catch( const Exception& ) 1674*cdf0e10cSrcweir { 1675*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1676*cdf0e10cSrcweir } 1677*cdf0e10cSrcweir return sSDBCLevelStatement; 1678*cdf0e10cSrcweir } 1679*cdf0e10cSrcweir } 1680*cdf0e10cSrcweir 1681*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1682*cdf0e10cSrcweir Reference< XPropertySet > createView( const ::rtl::OUString& _rName, const Reference< XConnection >& _rxConnection, 1683*cdf0e10cSrcweir const ::rtl::OUString& _rCommand ) 1684*cdf0e10cSrcweir { 1685*cdf0e10cSrcweir Reference<XViewsSupplier> xSup(_rxConnection,UNO_QUERY); 1686*cdf0e10cSrcweir Reference< XNameAccess > xViews; 1687*cdf0e10cSrcweir if(xSup.is()) 1688*cdf0e10cSrcweir xViews = xSup->getViews(); 1689*cdf0e10cSrcweir Reference<XDataDescriptorFactory> xFact(xViews,UNO_QUERY); 1690*cdf0e10cSrcweir OSL_ENSURE(xFact.is(),"No XDataDescriptorFactory available!"); 1691*cdf0e10cSrcweir if(!xFact.is()) 1692*cdf0e10cSrcweir return NULL; 1693*cdf0e10cSrcweir 1694*cdf0e10cSrcweir Reference<XPropertySet> xView = xFact->createDataDescriptor(); 1695*cdf0e10cSrcweir if ( !xView.is() ) 1696*cdf0e10cSrcweir return NULL; 1697*cdf0e10cSrcweir 1698*cdf0e10cSrcweir ::rtl::OUString sCatalog,sSchema,sTable; 1699*cdf0e10cSrcweir ::dbtools::qualifiedNameComponents(_rxConnection->getMetaData(), 1700*cdf0e10cSrcweir _rName, 1701*cdf0e10cSrcweir sCatalog, 1702*cdf0e10cSrcweir sSchema, 1703*cdf0e10cSrcweir sTable, 1704*cdf0e10cSrcweir ::dbtools::eInDataManipulation); 1705*cdf0e10cSrcweir 1706*cdf0e10cSrcweir xView->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(sCatalog)); 1707*cdf0e10cSrcweir xView->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(sSchema)); 1708*cdf0e10cSrcweir xView->setPropertyValue(PROPERTY_NAME,makeAny(sTable)); 1709*cdf0e10cSrcweir 1710*cdf0e10cSrcweir xView->setPropertyValue( PROPERTY_COMMAND, makeAny( _rCommand ) ); 1711*cdf0e10cSrcweir 1712*cdf0e10cSrcweir Reference<XAppend> xAppend(xViews,UNO_QUERY); 1713*cdf0e10cSrcweir if(xAppend.is()) 1714*cdf0e10cSrcweir xAppend->appendByDescriptor(xView); 1715*cdf0e10cSrcweir 1716*cdf0e10cSrcweir xView = NULL; 1717*cdf0e10cSrcweir // we need to reget the view because after appending it it is no longer valid 1718*cdf0e10cSrcweir // but this time it isn't a view object it is a table object with type "VIEW" 1719*cdf0e10cSrcweir Reference<XTablesSupplier> xTabSup(_rxConnection,UNO_QUERY); 1720*cdf0e10cSrcweir Reference< XNameAccess > xTables; 1721*cdf0e10cSrcweir if ( xTabSup.is() ) 1722*cdf0e10cSrcweir { 1723*cdf0e10cSrcweir xTables = xTabSup->getTables(); 1724*cdf0e10cSrcweir if ( xTables.is() && xTables->hasByName( _rName ) ) 1725*cdf0e10cSrcweir xTables->getByName( _rName ) >>= xView; 1726*cdf0e10cSrcweir } 1727*cdf0e10cSrcweir 1728*cdf0e10cSrcweir return xView; 1729*cdf0e10cSrcweir } 1730*cdf0e10cSrcweir 1731*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1732*cdf0e10cSrcweir Reference<XPropertySet> createView( const ::rtl::OUString& _rName, const Reference< XConnection >& _rxConnection 1733*cdf0e10cSrcweir ,const Reference<XPropertySet>& _rxSourceObject) 1734*cdf0e10cSrcweir { 1735*cdf0e10cSrcweir ::rtl::OUString sCommand; 1736*cdf0e10cSrcweir Reference< XPropertySetInfo > xPSI( _rxSourceObject->getPropertySetInfo(), UNO_SET_THROW ); 1737*cdf0e10cSrcweir if ( xPSI->hasPropertyByName( PROPERTY_COMMAND ) ) 1738*cdf0e10cSrcweir { 1739*cdf0e10cSrcweir _rxSourceObject->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand; 1740*cdf0e10cSrcweir 1741*cdf0e10cSrcweir sal_Bool bEscapeProcessing( sal_False ); 1742*cdf0e10cSrcweir OSL_VERIFY( _rxSourceObject->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) >>= bEscapeProcessing ); 1743*cdf0e10cSrcweir if ( bEscapeProcessing ) 1744*cdf0e10cSrcweir sCommand = lcl_createSDBCLevelStatement( sCommand, _rxConnection ); 1745*cdf0e10cSrcweir } 1746*cdf0e10cSrcweir else 1747*cdf0e10cSrcweir { 1748*cdf0e10cSrcweir sCommand = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SELECT * FROM " ) ); 1749*cdf0e10cSrcweir sCommand += composeTableNameForSelect( _rxConnection, _rxSourceObject ); 1750*cdf0e10cSrcweir } 1751*cdf0e10cSrcweir return createView( _rName, _rxConnection, sCommand ); 1752*cdf0e10cSrcweir } 1753*cdf0e10cSrcweir 1754*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1755*cdf0e10cSrcweir sal_Bool insertHierachyElement( Window* _pParent, const Reference< XMultiServiceFactory >& _rxORB, 1756*cdf0e10cSrcweir const Reference<XHierarchicalNameContainer>& _xNames, 1757*cdf0e10cSrcweir const String& _sParentFolder, 1758*cdf0e10cSrcweir sal_Bool _bForm, 1759*cdf0e10cSrcweir sal_Bool _bCollection, 1760*cdf0e10cSrcweir const Reference<XContent>& _xContent, 1761*cdf0e10cSrcweir sal_Bool _bMove) 1762*cdf0e10cSrcweir { 1763*cdf0e10cSrcweir OSL_ENSURE( _xNames.is(), "insertHierachyElement: illegal name container!" ); 1764*cdf0e10cSrcweir if ( !_xNames.is() ) 1765*cdf0e10cSrcweir return sal_False; 1766*cdf0e10cSrcweir 1767*cdf0e10cSrcweir Reference<XNameAccess> xNameAccess( _xNames, UNO_QUERY ); 1768*cdf0e10cSrcweir ::rtl::OUString sName = _sParentFolder; 1769*cdf0e10cSrcweir if ( _xNames->hasByHierarchicalName(sName) ) 1770*cdf0e10cSrcweir { 1771*cdf0e10cSrcweir Reference<XChild> xChild(_xNames->getByHierarchicalName(sName),UNO_QUERY); 1772*cdf0e10cSrcweir xNameAccess.set(xChild,UNO_QUERY); 1773*cdf0e10cSrcweir if ( !xNameAccess.is() && xChild.is() ) 1774*cdf0e10cSrcweir xNameAccess.set(xChild->getParent(),UNO_QUERY); 1775*cdf0e10cSrcweir } 1776*cdf0e10cSrcweir 1777*cdf0e10cSrcweir OSL_ENSURE( xNameAccess.is(), "insertHierachyElement: could not find the proper name container!" ); 1778*cdf0e10cSrcweir if ( !xNameAccess.is() ) 1779*cdf0e10cSrcweir return sal_False; 1780*cdf0e10cSrcweir 1781*cdf0e10cSrcweir ::rtl::OUString sNewName; 1782*cdf0e10cSrcweir Reference<XPropertySet> xProp(_xContent,UNO_QUERY); 1783*cdf0e10cSrcweir if ( xProp.is() ) 1784*cdf0e10cSrcweir xProp->getPropertyValue(PROPERTY_NAME) >>= sNewName; 1785*cdf0e10cSrcweir 1786*cdf0e10cSrcweir if ( !_bMove || !sNewName.getLength() ) 1787*cdf0e10cSrcweir { 1788*cdf0e10cSrcweir String sTargetName,sLabel; 1789*cdf0e10cSrcweir if ( !sNewName.getLength() || xNameAccess->hasByName(sNewName) ) 1790*cdf0e10cSrcweir { 1791*cdf0e10cSrcweir if ( sNewName.getLength() ) 1792*cdf0e10cSrcweir sTargetName = sNewName; 1793*cdf0e10cSrcweir else 1794*cdf0e10cSrcweir sTargetName = String(ModuleRes( _bCollection ? STR_NEW_FOLDER : ((_bForm) ? RID_STR_FORM : RID_STR_REPORT))); 1795*cdf0e10cSrcweir sLabel = String(ModuleRes( _bCollection ? STR_FOLDER_LABEL : ((_bForm) ? STR_FRM_LABEL : STR_RPT_LABEL))); 1796*cdf0e10cSrcweir sTargetName = ::dbtools::createUniqueName(xNameAccess,sTargetName); 1797*cdf0e10cSrcweir 1798*cdf0e10cSrcweir 1799*cdf0e10cSrcweir // here we have everything needed to create a new query object ... 1800*cdf0e10cSrcweir HierarchicalNameCheck aNameChecker( _xNames.get(), sName ); 1801*cdf0e10cSrcweir // ... ehm, except a new name 1802*cdf0e10cSrcweir OSaveAsDlg aAskForName( _pParent, 1803*cdf0e10cSrcweir _rxORB, 1804*cdf0e10cSrcweir sTargetName, 1805*cdf0e10cSrcweir sLabel, 1806*cdf0e10cSrcweir aNameChecker, 1807*cdf0e10cSrcweir SAD_ADDITIONAL_DESCRIPTION | SAD_TITLE_PASTE_AS); 1808*cdf0e10cSrcweir if ( RET_OK != aAskForName.Execute() ) 1809*cdf0e10cSrcweir // cancelled by the user 1810*cdf0e10cSrcweir return sal_False; 1811*cdf0e10cSrcweir 1812*cdf0e10cSrcweir sNewName = aAskForName.getName(); 1813*cdf0e10cSrcweir } 1814*cdf0e10cSrcweir } 1815*cdf0e10cSrcweir else if ( xNameAccess->hasByName(sNewName) ) 1816*cdf0e10cSrcweir { 1817*cdf0e10cSrcweir String sError(ModuleRes(STR_NAME_ALREADY_EXISTS)); 1818*cdf0e10cSrcweir sError.SearchAndReplaceAscii("#",sNewName); 1819*cdf0e10cSrcweir throw SQLException(sError,NULL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")) ,0,Any()); 1820*cdf0e10cSrcweir } 1821*cdf0e10cSrcweir 1822*cdf0e10cSrcweir try 1823*cdf0e10cSrcweir { 1824*cdf0e10cSrcweir Reference<XMultiServiceFactory> xORB( xNameAccess, UNO_QUERY_THROW ); 1825*cdf0e10cSrcweir Sequence< Any > aArguments(3); 1826*cdf0e10cSrcweir PropertyValue aValue; 1827*cdf0e10cSrcweir // set as folder 1828*cdf0e10cSrcweir aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")); 1829*cdf0e10cSrcweir aValue.Value <<= sNewName; 1830*cdf0e10cSrcweir aArguments[0] <<= aValue; 1831*cdf0e10cSrcweir //parent 1832*cdf0e10cSrcweir aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent")); 1833*cdf0e10cSrcweir aValue.Value <<= xNameAccess; 1834*cdf0e10cSrcweir aArguments[1] <<= aValue; 1835*cdf0e10cSrcweir 1836*cdf0e10cSrcweir aValue.Name = PROPERTY_EMBEDDEDOBJECT; 1837*cdf0e10cSrcweir aValue.Value <<= _xContent; 1838*cdf0e10cSrcweir aArguments[2] <<= aValue; 1839*cdf0e10cSrcweir 1840*cdf0e10cSrcweir ::rtl::OUString sServiceName(_bCollection ? ((_bForm) ? SERVICE_NAME_FORM_COLLECTION : SERVICE_NAME_REPORT_COLLECTION) : SERVICE_SDB_DOCUMENTDEFINITION); 1841*cdf0e10cSrcweir 1842*cdf0e10cSrcweir Reference<XContent > xNew( xORB->createInstanceWithArguments( sServiceName, aArguments ), UNO_QUERY_THROW ); 1843*cdf0e10cSrcweir Reference< XNameContainer > xNameContainer( xNameAccess, UNO_QUERY_THROW ); 1844*cdf0e10cSrcweir xNameContainer->insertByName( sNewName, makeAny( xNew ) ); 1845*cdf0e10cSrcweir } 1846*cdf0e10cSrcweir catch( const IllegalArgumentException& e ) 1847*cdf0e10cSrcweir { 1848*cdf0e10cSrcweir ::dbtools::throwGenericSQLException( e.Message, e.Context ); 1849*cdf0e10cSrcweir } 1850*cdf0e10cSrcweir catch( const Exception& ) 1851*cdf0e10cSrcweir { 1852*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1853*cdf0e10cSrcweir return sal_False; 1854*cdf0e10cSrcweir } 1855*cdf0e10cSrcweir 1856*cdf0e10cSrcweir return sal_True; 1857*cdf0e10cSrcweir } 1858*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1859*cdf0e10cSrcweir Reference< XNumberFormatter > getNumberFormatter(const Reference< XConnection >& _rxConnection,const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF ) 1860*cdf0e10cSrcweir { 1861*cdf0e10cSrcweir // --------------------------------------------------------------- 1862*cdf0e10cSrcweir // create a formatter working with the connections format supplier 1863*cdf0e10cSrcweir Reference< XNumberFormatter > xFormatter; 1864*cdf0e10cSrcweir 1865*cdf0e10cSrcweir try 1866*cdf0e10cSrcweir { 1867*cdf0e10cSrcweir Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(::dbtools::getNumberFormats(_rxConnection, sal_True,_rMF)); 1868*cdf0e10cSrcweir 1869*cdf0e10cSrcweir if ( xSupplier.is() ) 1870*cdf0e10cSrcweir { 1871*cdf0e10cSrcweir // create a new formatter 1872*cdf0e10cSrcweir xFormatter = Reference< ::com::sun::star::util::XNumberFormatter > ( 1873*cdf0e10cSrcweir _rMF->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY); 1874*cdf0e10cSrcweir if ( xFormatter.is() ) 1875*cdf0e10cSrcweir xFormatter->attachNumberFormatsSupplier(xSupplier); 1876*cdf0e10cSrcweir } 1877*cdf0e10cSrcweir } 1878*cdf0e10cSrcweir catch(const Exception&) 1879*cdf0e10cSrcweir { 1880*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 1881*cdf0e10cSrcweir } 1882*cdf0e10cSrcweir return xFormatter; 1883*cdf0e10cSrcweir } 1884*cdf0e10cSrcweir 1885*cdf0e10cSrcweir 1886*cdf0e10cSrcweir // ......................................................................... 1887*cdf0e10cSrcweir } // dbaui 1888*cdf0e10cSrcweir // ......................................................................... 1889