LibreOffice Module sw (master)
1
sw
source
uibase
config
dbconfig.cxx
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
#include <
dbconfig.hxx
>
21
#include <osl/diagnose.h>
22
#include <com/sun/star/uno/Sequence.hxx>
23
#include <
swdbdata.hxx
>
24
25
using namespace
utl
;
26
using namespace
com::sun::star::uno
;
27
28
const
Sequence<OUString>
&
SwDBConfig::GetPropertyNames
()
29
{
30
static
Sequence<OUString>
aNames {
31
"AddressBook/DataSourceName"
,
// 0
32
"AddressBook/Command"
,
// 1
33
"AddressBook/CommandType"
,
// 2
34
"Bibliography/CurrentDataSource/DataSourceName"
,
// 4
35
"Bibliography/CurrentDataSource/Command"
,
// 5
36
"Bibliography/CurrentDataSource/CommandType"
// 6
37
};
38
return
aNames;
39
}
40
41
SwDBConfig::SwDBConfig
() :
42
ConfigItem
(
"Office.DataAccess"
,
ConfigItemMode
::
ReleaseTree
)
43
{
44
};
45
46
SwDBConfig::~SwDBConfig
()
47
{
48
m_pAdrImpl
.reset();
49
m_pBibImpl
.reset();
50
}
51
52
void
SwDBConfig::Load
()
53
{
54
const
Sequence<OUString>
& rNames =
GetPropertyNames
();
55
if
(!
m_pAdrImpl
)
56
{
57
m_pAdrImpl
.reset(
new
SwDBData
);
58
m_pAdrImpl
->nCommandType = 0;
59
m_pBibImpl
.reset(
new
SwDBData
);
60
m_pBibImpl
->nCommandType = 0;
61
}
62
Sequence<Any>
aValues =
GetProperties
(rNames);
63
const
Any
*
pValues
= aValues.getConstArray();
64
OSL_ENSURE(aValues.getLength() == rNames.getLength(),
"GetProperties failed"
);
65
if
(aValues.getLength() != rNames.getLength())
66
return
;
67
68
for
(
int
nProp = 0; nProp < rNames.getLength(); nProp++)
69
{
70
switch
(nProp)
71
{
72
case
0:
pValues
[nProp] >>=
m_pAdrImpl
->sDataSource;
break
;
73
case
1:
pValues
[nProp] >>=
m_pAdrImpl
->sCommand;
break
;
74
case
2:
pValues
[nProp] >>=
m_pAdrImpl
->nCommandType;
break
;
75
case
3:
pValues
[nProp] >>=
m_pBibImpl
->sDataSource;
break
;
76
case
4:
pValues
[nProp] >>=
m_pBibImpl
->sCommand;
break
;
77
case
5:
pValues
[nProp] >>=
m_pBibImpl
->nCommandType;
break
;
78
}
79
}
80
}
81
82
const
SwDBData
&
SwDBConfig::GetAddressSource
()
83
{
84
if
(!
m_pAdrImpl
)
85
Load
();
86
return
*
m_pAdrImpl
;
87
}
88
89
const
SwDBData
&
SwDBConfig::GetBibliographySource
()
90
{
91
if
(!
m_pBibImpl
)
92
Load
();
93
return
*
m_pBibImpl
;
94
}
95
96
void
SwDBConfig::ImplCommit
() {}
97
void
SwDBConfig::Notify
(
const
css::uno::Sequence< OUString >& ) {}
98
99
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
pValues
const PropertyValue * pValues
SwDBConfig::ImplCommit
virtual void ImplCommit() override
Definition:
dbconfig.cxx:96
SwDBConfig::GetPropertyNames
static SAL_DLLPRIVATE const css::uno::Sequence< OUString > & GetPropertyNames()
Definition:
dbconfig.cxx:28
SwDBConfig::~SwDBConfig
virtual ~SwDBConfig() override
Definition:
dbconfig.cxx:46
SwDBConfig::m_pBibImpl
std::unique_ptr< SwDBData > m_pBibImpl
Definition:
dbconfig.hxx:34
SwDBConfig::m_pAdrImpl
std::unique_ptr< SwDBData > m_pAdrImpl
Definition:
dbconfig.hxx:33
SwDBConfig::Notify
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition:
dbconfig.cxx:97
SwDBConfig::GetAddressSource
const SwDBData & GetAddressSource()
Definition:
dbconfig.cxx:82
SwDBConfig::GetBibliographySource
const SwDBData & GetBibliographySource()
Definition:
dbconfig.cxx:89
SwDBConfig::Load
void Load()
Definition:
dbconfig.cxx:52
SwDBConfig::SwDBConfig
SwDBConfig()
Definition:
dbconfig.cxx:41
com::sun::star::uno::Sequence
utl::ConfigItem
utl::ConfigItem::GetProperties
static css::uno::Sequence< css::uno::Any > GetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, bool bAllLocales)
ConfigItemMode
ConfigItemMode
ConfigItemMode::ReleaseTree
@ ReleaseTree
RedlineType::Any
@ Any
dbconfig.hxx
com::sun::star::uno
utl
SwDBData
Definition:
swdbdata.hxx:29
swdbdata.hxx
Generated on Sun Jul 30 2023 04:29:48 for LibreOffice Module sw (master) by
1.9.3