1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dbmgr.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #ifndef _STRING_HXX //autogen
35 #include <tools/string.hxx>
39 #include <bf_svtools/svarray.hxx>
41 #ifndef _COM_SUN_STAR_UTIL_DATE_HPP_
42 #include <com/sun/star/util/Date.hpp>
46 #include <swdbdata.hxx>
48 #ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
49 #include <com/sun/star/uno/Reference.h>
51 #ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
52 #include <com/sun/star/uno/Sequence.h>
54 #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
55 #include <com/sun/star/lang/Locale.hpp>
58 namespace com
{namespace sun
{namespace star
{
71 class XColumnsSupplier
;
74 class XNumberFormatter
;
80 class SvNumberFormatter
;
82 class ODataAccessDescriptor
;
87 ::com::sun::star::util::Date aNullDate
;
88 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatter
> xFormatter
;
89 ::com::sun::star::lang::Locale aLocale
;
98 class SwDbtoolsClient
;
101 // -----------------------------------------------------------------------
105 DBMGR_MERGE
, // Datensaetze in Felder
106 DBMGR_INSERT
, // Datensaetze in Text
107 DBMGR_MERGE_MAILMERGE
, // Serienbriefe drucken
108 DBMGR_MERGE_MAILING
, // Serienbriefe als email versenden
109 DBMGR_MERGE_MAILFILES
// Serienbriefe als Datei(en) speichern
112 // -----------------------------------------------------------------------
114 /*--------------------------------------------------------------------
115 Beschreibung: (neue) Logische Datenbanken verwalten
116 --------------------------------------------------------------------*/
117 #define SW_DB_SELECT_UNKNOWN 0
118 #define SW_DB_SELECT_TABLE 1
119 #define SW_DB_SELECT_QUERY 2
121 struct SwDSParam
: public SwDBData
123 ::com::sun::star::util::Date aNullDate
;
125 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatter
> xFormatter
;
126 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> xConnection
;
127 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XStatement
> xStatement
;
128 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> xResultSet
;
129 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aSelection
;
132 BOOL bAfterSelection
;
133 long nSelectionIndex
;
135 SwDSParam(const SwDBData
& rData
) :
139 bAfterSelection(FALSE
),
143 SwDSParam(const SwDBData
& rData
,
144 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
>& xResSet
,
145 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& rSelection
) :
149 bAfterSelection(FALSE
),
152 aSelection(rSelection
)
158 bAfterSelection
= TRUE
;
161 typedef SwDSParam
* SwDSParamPtr
;
162 SV_DECL_PTRARR_DEL(SwDSParamArr
, SwDSParamPtr
, 0, 5)
164 struct SwNewDBMgr_Impl
;
165 class SwConnectionDisposedListener_Impl
;
168 friend class SwConnectionDisposedListener_Impl
;
170 static SwDbtoolsClient
* pDbtoolsClient
;
172 String sEMailAddrFld
; // Mailing: Spaltenname der E-Mail Adresse
173 String sSubject
; // Mailing: Subject
174 String sAttached
; // Mailing: Attachte Files
176 BOOL bInitDBFields
: 1; // TRUE: Datenbank an Feldern beim Mergen
177 BOOL bSingleJobs
: 1; // Einzelne Druckjobs bei Aufruf aus Basic
178 BOOL bCancel
: 1; // Serienbrief-Save abgebrochen
180 BOOL bInMerge
: 1; //merge process active
181 BOOL bMergeSilent
: 1; // suppress display of dialogs/boxes (used when called over API)
182 BOOL bMergeLock
: 1; // prevent update of database fields while document is
183 // actually printed at the ViewShell
184 SwDSParamArr aDataSourceParams
;
185 SwNewDBMgr_Impl
* pImpl
;
186 const SwXMailMerge
* pMergeEvtSrc
; // != 0 if mail merge events are to be send
188 SwDSParam
* pMergeData
;
189 SwMailMergeDlg
* pMergeDialog
;
191 SwDSParam
* FindDSData(const SwDBData
& rData
, BOOL bCreate
);
192 SwDSParam
* FindDSConnection(const ::rtl::OUString
& rSource
, BOOL bCreate
);
196 // Datensaetze als Text ins Dokument einfuegen
198 // Einzelnen Datensatz als Text ins Dokument einfuegen
200 // Mischen von Datensaetzen in Felder, dann per email versenden
201 // Mischen von Datensaetzen in Felder, dann als Datei abspeichern
202 BOOL
ToNextRecord(SwDSParam
* pParam
);
208 // Art des aktellen Mergens. Siehe DBMgrOptions-enum
209 inline USHORT
GetMergeType() const { return nMergeType
; }
210 inline void SetMergeType( USHORT nTyp
) { nMergeType
= nTyp
; }
212 // MailMergeEvent source
213 const SwXMailMerge
* GetMailMergeEvtSrc() const { return pMergeEvtSrc
; }
214 void SetMailMergeEvtSrc( const SwXMailMerge
*pSrc
) { pMergeEvtSrc
= pSrc
; }
216 inline BOOL
IsMergeSilent() const { return bMergeSilent
!= 0; }
217 inline void SetMergeSilent( BOOL bVal
) { bMergeSilent
= bVal
; }
219 // Mischen von Datensaetzen in Felder, dann drucken
220 // Datenbankfelder mit fehlendem Datenbankname initialisieren
221 inline BOOL
IsInitDBFields() const { return bInitDBFields
; }
222 inline void SetInitDBFields(BOOL b
) { bInitDBFields
= b
; }
224 // Serienbriefe einzelnd oder alle zusammen drucken/speichern
225 inline BOOL
IsSingleJobs() const { return bSingleJobs
; }
226 inline void SetSingleJobs(BOOL b
) { bSingleJobs
= b
; }
229 // email-Daten setzen
230 inline void SetEMailColumn(const String
& sColName
) { sEMailAddrFld
= sColName
; }
231 inline void SetSubject(const String
& sSbj
) { sSubject
= sSbj
; }
232 inline void SetAttachment(const String
& sAtt
) { sAttached
= sAtt
; }
235 // Listbox mit allen Tabellennamen einer Datenbank fuellen
237 // Listbox mit allen Spaltennamen einer Datenbanktabelle fuellen
241 inline BOOL
IsInMerge() const { return bInMerge
; }
243 // check if a data source is open
244 BOOL
IsDataSourceOpen(const String
& rDataSource
,
245 const String
& rTableOrQuery
, sal_Bool bMergeOnly
);
247 // add data source information to the data source array - was PreInitDBData
248 void AddDSData(const SwDBData
& rData
, long nSelStart
, long nSelEnd
);
249 void GetDSSelection(const SwDBData
& rData
, long& rSelStart
, long& rSelEnd
);
251 // open the source while fields are updated - for the calculator only!
252 BOOL
OpenDataSource(const String
& rDataSource
, const String
& rTableOrQuery
, sal_Int32 nCommandType
= -1);
253 sal_uInt32
GetSelectedRecordId(const String
& rDataSource
, const String
& rTableOrQuery
, sal_Int32 nCommandType
= -1);
254 BOOL
GetColumnCnt(const String
& rSourceName
, const String
& rTableName
,
255 const String
& rColumnName
, sal_uInt32 nAbsRecordId
, long nLanguage
,
256 String
& rResult
, double* pNumber
);
257 //create and store or find an already stored connection to a data source for use
258 //in SwFldMgr and SwDBTreeList
259 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>
260 RegisterConnection(::rtl::OUString
& rSource
);
262 const SwDSParam
* CreateDSData(const SwDBData
& rData
)
263 {return FindDSData(rData
, TRUE
);}
264 const SwDSParamArr
& GetDSParamArray() const {return aDataSourceParams
;}
267 //close all data sources - after fields were updated
268 void CloseAll(BOOL bIncludingMerge
= TRUE
);
270 BOOL
ToNextRecord(const String
& rDataSource
, const String
& rTableOrQuery
, sal_Int32 nCommandType
= -1);
272 sal_uInt32
GetSelectedRecordId();
273 sal_Bool
ToRecordId(sal_Int32 nSet
);
275 const SwDBData
& GetAddressDBName();
278 static ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>
279 GetConnection(const String
& rDataSource
,
280 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDataSource
>& rxSource
);
283 } //namespace binfilter