LibreOffice Module extensions (master) 1
datasourcehandling.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <com/sun/star/uno/Reference.hxx>
23#include <com/sun/star/uno/XComponentContext.hpp>
24#include <memory>
25
26#include "abptypes.hxx"
27
28
29namespace com::sun::star {
30 namespace beans {
31 class XPropertySet;
32 }
33}
34
35namespace weld { class Window; }
36
37
38namespace abp
39{
40
41 struct ODataSourceContextImpl;
42 class ODataSource;
45 {
46 private:
47 std::unique_ptr<ODataSourceContextImpl> m_pImpl;
48
49 public:
50 explicit ODataSourceContext(
51 const css::uno::Reference< css::uno::XComponentContext >& _rxORB
52 );
54
56 void getDataSourceNames( StringBag& _rNames ) const;
57
59 void disambiguate(OUString& _rDataSourceName);
60
62 ODataSource createNewThunderbird( const OUString& _rName );
63
65 ODataSource createNewEvolution( const OUString& _rName );
66
68 ODataSource createNewEvolutionLdap( const OUString& _rName );
69
71 ODataSource createNewEvolutionGroupwise( const OUString& _rName );
72
74 ODataSource createNewKab( const OUString& _rName );
75
77 ODataSource createNewMacab( const OUString& _rName );
78
80 ODataSource createNewOther( const OUString& _rName );
81 };
82
83 struct ODataSourceImpl;
84 struct AddressSettings;
92 {
93 private:
94 std::unique_ptr<ODataSourceImpl> m_pImpl;
95
96 public:
97
98 // - ctor/dtor/assignment
99
101 explicit ODataSource(
102 const css::uno::Reference< css::uno::XComponentContext >& _rxORB
103 );
104
106 ODataSource( const ODataSource& _rSource );
107
109 ~ODataSource( );
110
112 ODataSource& operator=( const ODataSource& _rSource );
113
115 ODataSource& operator=(ODataSource&& _rSource) noexcept;
116
118 bool isValid() const;
119
120
122 void remove();
123 // TODO: put this into the context class
124
126 OUString
127 getName() const;
128
130 bool rename( const OUString& _rName );
131 // TODO: put this into the context class
132
133
134 // - connection handling
135
142 bool connect(weld::Window* _pMessageParent);
143
145 bool isConnected( ) const;
146
148 void disconnect( );
149
151 void store(const AddressSettings& rSettings);
152
154 void registerDataSource( const OUString& _sRegisteredDataSourceName );
155
156
160 const StringBag& getTableNames() const;
161
164 bool hasTable( const OUString& _rTableName ) const;
165
167 css::uno::Reference< css::beans::XPropertySet > getDataSource() const;
168
169
173 void setDataSource(
174 const css::uno::Reference< css::beans::XPropertySet >& _rxDS
175 ,const OUString& _sName
176 );
177 };
178
179
180} // namespace abp
181/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
a non-UNO wrapper for the data source context
ODataSource createNewEvolutionGroupwise(const OUString &_rName)
creates a new Evolution GROUPWISE data source
ODataSource createNewEvolutionLdap(const OUString &_rName)
creates a new Evolution LDAP data source
ODataSourceContext(const css::uno::Reference< css::uno::XComponentContext > &_rxORB)
ODataSource createNewKab(const OUString &_rName)
creates a new KDE address book data source
ODataSource createNewMacab(const OUString &_rName)
creates a new macOS address book data source
std::unique_ptr< ODataSourceContextImpl > m_pImpl
void disambiguate(OUString &_rDataSourceName)
disambiguates the given name by appending successive numbers
void getDataSourceNames(StringBag &_rNames) const
retrieves the names of all data sources
ODataSource createNewOther(const OUString &_rName)
creates a new Other data source; tdf117101: Spreadsheet by default
ODataSource createNewEvolution(const OUString &_rName)
creates a new Evolution local data source
ODataSource createNewThunderbird(const OUString &_rName)
creates a new Thunderbird data source
a non-UNO wrapper for a data source
void store(const AddressSettings &rSettings)
stores the database file
bool connect(weld::Window *_pMessageParent)
connects to the data source represented by this object
void remove()
removes the data source represented by the object from the data source context
bool isValid() const
checks whether or not the object represents a valid data source
void setDataSource(const css::uno::Reference< css::beans::XPropertySet > &_rxDS, const OUString &_sName)
set a new data source.
void disconnect()
disconnects from the data source (i.e. disposes the UNO connection hold internally)
std::unique_ptr< ODataSourceImpl > m_pImpl
bool rename(const OUString &_rName)
renames the data source
const StringBag & getTableNames() const
retrieves the tables names from the connection
ODataSource(const css::uno::Reference< css::uno::XComponentContext > &_rxORB)
constructs an object which is initially invalid
bool hasTable(const OUString &_rTableName) const
determines whether a given table exists
void registerDataSource(const OUString &_sRegisteredDataSourceName)
register the data source under the given name in the configuration
ODataSource & operator=(const ODataSource &_rSource)
copy assignment
css::uno::Reference< css::beans::XPropertySet > getDataSource() const
return the internal data source object
OUString getName() const
returns the name of the data source
bool isConnected() const
returns <TRUE> if the object has a valid connection, obtained from its data source
std::set< OUString > StringBag
Definition: abptypes.hxx:34
class SAL_NO_VTABLE XPropertySet