/src/libreoffice/sw/source/uibase/config/dbconfig.cxx
Line | Count | Source |
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 | 0 | { |
30 | 0 | static Sequence<OUString> aNames { |
31 | 0 | u"AddressBook/DataSourceName"_ustr, // 0 |
32 | 0 | u"AddressBook/Command"_ustr, // 1 |
33 | 0 | u"AddressBook/CommandType"_ustr, // 2 |
34 | 0 | u"Bibliography/CurrentDataSource/DataSourceName"_ustr, // 4 |
35 | 0 | u"Bibliography/CurrentDataSource/Command"_ustr, // 5 |
36 | 0 | u"Bibliography/CurrentDataSource/CommandType"_ustr // 6 |
37 | 0 | }; |
38 | 0 | return aNames; |
39 | 0 | } |
40 | | |
41 | | SwDBConfig::SwDBConfig() : |
42 | 0 | ConfigItem(u"Office.DataAccess"_ustr, ConfigItemMode::ReleaseTree) |
43 | 0 | { |
44 | 0 | } |
45 | | |
46 | | SwDBConfig::~SwDBConfig() |
47 | 0 | { |
48 | 0 | m_pAdrImpl.reset(); |
49 | 0 | m_pBibImpl.reset(); |
50 | 0 | } |
51 | | |
52 | | void SwDBConfig::Load() |
53 | 0 | { |
54 | 0 | const Sequence<OUString>& rNames = GetPropertyNames(); |
55 | 0 | if (!m_pAdrImpl) |
56 | 0 | m_pAdrImpl.reset(new SwDBData); |
57 | 0 | if (!m_pBibImpl) |
58 | 0 | m_pBibImpl.reset(new SwDBData); |
59 | 0 | Sequence<Any> aValues = GetProperties(rNames); |
60 | 0 | const Any* pValues = aValues.getConstArray(); |
61 | 0 | OSL_ENSURE(aValues.getLength() == rNames.getLength(), "GetProperties failed"); |
62 | 0 | if(aValues.getLength() != rNames.getLength()) |
63 | 0 | return; |
64 | | |
65 | 0 | for(int nProp = 0; nProp < rNames.getLength(); nProp++) |
66 | 0 | { |
67 | 0 | switch(nProp) |
68 | 0 | { |
69 | 0 | case 0: pValues[nProp] >>= m_pAdrImpl->sDataSource; break; |
70 | 0 | case 1: pValues[nProp] >>= m_pAdrImpl->sCommand; break; |
71 | 0 | case 2: pValues[nProp] >>= m_pAdrImpl->nCommandType; break; |
72 | 0 | case 3: pValues[nProp] >>= m_pBibImpl->sDataSource; break; |
73 | 0 | case 4: pValues[nProp] >>= m_pBibImpl->sCommand; break; |
74 | 0 | case 5: pValues[nProp] >>= m_pBibImpl->nCommandType; break; |
75 | 0 | } |
76 | 0 | } |
77 | 0 | } |
78 | | |
79 | | const SwDBData& SwDBConfig::GetAddressSource() |
80 | 0 | { |
81 | 0 | if(!m_pAdrImpl) |
82 | 0 | Load(); |
83 | 0 | return *m_pAdrImpl; |
84 | 0 | } |
85 | | |
86 | | const SwDBData& SwDBConfig::GetBibliographySource() |
87 | 0 | { |
88 | 0 | if(!m_pBibImpl) |
89 | 0 | Load(); |
90 | 0 | return *m_pBibImpl; |
91 | 0 | } |
92 | | |
93 | 0 | void SwDBConfig::ImplCommit() {} |
94 | 0 | void SwDBConfig::Notify( const css::uno::Sequence< OUString >& ) {} |
95 | | |
96 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |