19#ifndef INCLUDED_SW_INC_DBMGR_HXX
20#define INCLUDED_SW_INC_DBMGR_HXX
22#include <rtl/ustring.hxx>
26#include <com/sun/star/util/Date.hpp>
29#include <com/sun/star/uno/Reference.h>
30#include <com/sun/star/uno/Sequence.hxx>
31#include <com/sun/star/lang/Locale.hpp>
32#include <com/sun/star/beans/PropertyValue.hpp>
50 class XColumnsSupplier;
53 class XNumberFormatter;
58 namespace embed {
class XStorage; }
59 namespace frame {
class XStorable; }
62 class ODataAccessDescriptor;
68 css::uno::Reference< css::util::XNumberFormatter>
xFormatter;
123 css::uno::Reference< css::sdbc::XResultSet> xResSet,
124 const css::uno::Sequence< css::uno::Any >& rSelection) :
269 void SetAsUsed(
const OUString& rName);
275 SAL_DLLPRIVATE
SwDSParam* FindDSConnection(
const OUString& rSource,
bool bCreate);
278 SAL_DLLPRIVATE
void ImportFromConnection(
SwWrtShell* pSh);
281 SAL_DLLPRIVATE
void ImportDBEntry(
SwWrtShell* pSh);
284 SAL_DLLPRIVATE
bool MergeMailFiles(
SwWrtShell* pSh,
287 SAL_DLLPRIVATE
bool ToNextMergeRecord();
288 SAL_DLLPRIVATE
bool IsValidMergeRecord()
const;
289 SAL_DLLPRIVATE
void ImplDestroy();
309 bool IsMergeOk()
const {
return MergeStatus::Ok == m_aMergeStatus; }
310 bool IsMergeError()
const {
return MergeStatus::Error <= m_aMergeStatus; }
312 static std::shared_ptr<SwMailMergeConfigItem> PerformMailMerge(
SwView const * pView);
319 bool GetTableNames(
weld::ComboBox& rBox,
const OUString& rDBName);
323 const OUString& rDBName,
const OUString& rTableName);
325 css::uno::Reference< css::sdbc::XConnection>
const & xConnection,
326 const OUString& rTableName);
329 css::uno::Reference< css::sdbc::XConnection>
const & xConnection,
330 css::uno::Reference< css::beans::XPropertySet>
const & xColumn,
334 sal_uLong GetColumnFormat(
const OUString& rDBName,
335 const OUString& rTableName,
336 const OUString& rColNm,
339 sal_Int32 GetColumnType(
const OUString& rDBName,
340 const OUString& rTableName,
341 const OUString& rColNm );
346 const css::uno::Sequence< css::beans::PropertyValue>& rProperties);
349 const css::uno::Sequence< css::beans::PropertyValue>& rProperties);
352 bool IsDataSourceOpen(
const OUString& rDataSource,
353 const OUString& rTableOrQuery,
bool bMergeShell);
356 bool OpenDataSource(
const OUString& rDataSource,
const OUString& rTableOrQuery);
357 sal_uInt32 GetSelectedRecordId(
const OUString& rDataSource,
const OUString& rTableOrQuery, sal_Int32 nCommandType = -1);
358 bool GetColumnCnt(
const OUString& rSourceName,
const OUString& rTableName,
359 const OUString& rColumnName, sal_uInt32 nAbsRecordId,
LanguageType nLanguage,
360 OUString& rResult,
double* pNumber);
363 css::uno::Reference< css::sdbc::XConnection>
const &
364 RegisterConnection(OUString
const& rSource);
367 { FindDSData(rData,
true); }
371 void CloseAll(
bool bIncludingMerge =
true);
373 bool GetMergeColumnCnt(
const OUString& rColumnName,
LanguageType nLanguage,
374 OUString &rResult,
double *pNumber);
377 void ToNextRecord(
const OUString& rDataSource,
const OUString& rTableOrQuery);
379 sal_uInt32 GetSelectedRecordId();
380 bool ToRecordId(sal_Int32 nSet);
382 static const SwDBData& GetAddressDBName();
384 static OUString GetDBField(
385 css::uno::Reference< css::beans::XPropertySet >
const & xColumnProp,
387 double *pNumber =
nullptr);
389 static css::uno::Reference< css::sdbc::XConnection>
390 GetConnection(
const OUString& rDataSource,
391 css::uno::Reference< css::sdbc::XDataSource>& rxSource,
394 static css::uno::Reference< css::sdbcx::XColumnsSupplier>
395 GetColumnSupplier(css::uno::Reference< css::sdbc::XConnection>
const & xConnection,
396 const OUString& rTableOrQuery,
399 static css::uno::Sequence<OUString> GetExistingDatabaseNames();
416 static OUString LoadAndRegisterDataSource(std::u16string_view rURI,
const OUString *pDestDir);
419 void LoadAndRegisterEmbeddedDataSource(
const SwDBData& rData,
const SwDocShell& rDocShell);
422 static void RevokeDataSource(
const OUString& rName);
433 static css::uno::Reference< css::sdbc::XDataSource>
434 getDataSourceAsParent(
const css::uno::Reference< css::sdbc::XConnection>& _xConnection,
const OUString& _sDataSourceName);
449 static css::uno::Reference< css::sdbc::XResultSet>
450 createCursor(
const OUString& _sDataSourceName,
451 const OUString& _sCommand,
452 sal_Int32 _nCommandType,
453 const css::uno::Reference< css::sdbc::XConnection>& _xConnection,
456 void setEmbeddedName(
const OUString& rEmbeddedName,
SwDocShell& rDocShell);
457 const OUString& getEmbeddedName()
const;
460 static void StoreEmbeddedDataSource(
const css::uno::Reference<css::frame::XStorable>& xStorable,
461 const css::uno::Reference<css::embed::XStorage>& xStorage,
462 const OUString& rStreamRelPath,
463 const OUString& rOwnURL,
bool bCopyTo =
false);
465 SwDoc* getDoc()
const;
467 void releaseRevokeListener();
470 void RevokeLastRegistrations();
473 void CommitLastRegistrations();
476 void RevokeNotUsedConnections();
std::vector< OUString > m_aNotUsedConnections
Not used connections.
const SwXMailMerge * m_pMergeEvtSrc
!= 0 if mail merge events are to be send
SwDBManager & operator=(SwDBManager const &)=delete
static std::vector< std::pair< SwDocShell *, OUString > > s_aUncommittedRegistrations
Store last registrations to revoke or commit.
bool m_bInMerge
merge process active
void CreateDSData(const SwDBData &rData)
const SwDSParams_t & GetDSParamArray() const
static sal_uLong GetColumnFormat(css::uno::Reference< css::sdbc::XDataSource > const &xSource, css::uno::Reference< css::sdbc::XConnection > const &xConnection, css::uno::Reference< css::beans::XPropertySet > const &xColumn, SvNumberFormatter *pNFormatr, LanguageType nLanguage)
void SetMergeSilent(bool bVal)
const SwXMailMerge * GetMailMergeEvtSrc() const
MailMergeEvent source.
SwDBManager(SwDBManager const &)=delete
bool m_bMergeSilent
suppress display of dialogs/boxes (used when called over API)
static void GetColumnNames(weld::ComboBox &rBox, css::uno::Reference< css::sdbc::XConnection > const &xConnection, const OUString &rTableName)
OUString m_sEmbeddedName
Name of the embedded database that's included in the current document.
bool IsMergeSilent() const
SwDSParams_t m_DataSourceParams
bool IsInitDBFields() const
Initialize data fields that lack name of database.
void SetMailMergeEvtSrc(const SwXMailMerge *pSrc)
SwDoc * m_pDoc
The document that owns this manager.
MergeStatus m_aMergeStatus
current / last merge status
void SetInitDBFields(bool b)
bool IsMergeError() const
std::unique_ptr< SwDBManager_Impl > m_pImpl
Used by the UI to modify the document model.
Gives UNO access to the global mail merge functionality, via the com.sun.star.text....
@ DBMGR_MERGE_EMAIL
Send mail merge as email.
@ DBMGR_MERGE
Data records in fields.
@ DBMGR_MERGE_SHELL
Create merge doc and keep the doc shell.
@ DBMGR_MERGE_PRINTER
Print mail merge.
@ DBMGR_MERGE_FILE
Save mail merge as files.
std::vector< std::unique_ptr< SwDSParam > > SwDSParams_t
css::uno::Sequence< OUString > aBlindCopiesTo
css::uno::Sequence< OUString > aCopiesTo
css::uno::Reference< css::mail::XSmtpService > xSmtpServer
OUString sPrefix
Basename incl.
OUString sDBPasswordColumn
DB column to fetch password.
bool bPrefixIsFilename
Use the sPrefix as the target filename also overwriting an existing target file.
OUString sDBcolumn
DB column to fetch EMail of Filename from.
css::uno::Sequence< css::beans::PropertyValue > aPrintOptions
css::uno::Sequence< css::beans::PropertyValue > aSaveToFilterData
OUString sSaveToFilterOptions
class SAL_NO_VTABLE XPropertySet
Dialog to specify the properties of date form field.
DBConnURIType GetDBunoType(const INetURLObject &rURL)
css::uno::Reference< css::util::XNumberFormatter > xFormatter
SwDSParam(const SwDBData &rData)
css::uno::Reference< css::sdbc::XResultSet > xResultSet
css::uno::Reference< css::sdbc::XStatement > xStatement
css::util::Date aNullDate
SwDSParam(const SwDBData &rData, css::uno::Reference< css::sdbc::XResultSet > xResSet, const css::uno::Sequence< css::uno::Any > &rSelection)
css::uno::Reference< css::sdbc::XConnection > xConnection
css::uno::Sequence< css::uno::Any > aSelection
bool HasValidRecord() const
tools::Long nSelectionIndex
const svx::ODataAccessDescriptor & rDescriptor
const DBManagerOptions nMergeType
SwMergeDescriptor(const DBManagerOptions nType, SwWrtShell &rShell, const svx::ODataAccessDescriptor &rDesc)
SwMailMergeConfigItem * pMailMergeConfigItem
bool bCreateSingleFile
Create a single or multiple results.