1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <dbconfig.hxx>
21 #include <osl/diagnose.h>
22 #include <com/sun/star/uno/Any.hxx>
23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <swdbdata.hxx>
29 using namespace com::sun::star::uno
;
31 /*--------------------------------------------------------------------
33 --------------------------------------------------------------------*/
35 const Sequence
<OUString
>& SwDBConfig::GetPropertyNames()
37 static Sequence
<OUString
> aNames
;
38 if(!aNames
.getLength())
40 static const char* aPropNames
[] =
42 "AddressBook/DataSourceName", // 0
43 "AddressBook/Command", // 1
44 "AddressBook/CommandType", // 2
45 "Bibliography/CurrentDataSource/DataSourceName", // 4
46 "Bibliography/CurrentDataSource/Command", // 5
47 "Bibliography/CurrentDataSource/CommandType" // 6
49 const int nCount
= sizeof(aPropNames
)/sizeof(const char*);
50 aNames
.realloc(nCount
);
51 OUString
* pNames
= aNames
.getArray();
52 for(int i
= 0; i
< nCount
; i
++)
53 pNames
[i
] = OUString::createFromAscii(aPropNames
[i
]);
58 SwDBConfig::SwDBConfig() :
59 ConfigItem("Office.DataAccess",
60 CONFIG_MODE_DELAYED_UPDATE
|CONFIG_MODE_RELEASE_TREE
),
66 SwDBConfig::~SwDBConfig()
72 void SwDBConfig::Load()
74 const Sequence
<OUString
>& rNames
= GetPropertyNames();
78 pAdrImpl
= new SwDBData
;
79 pAdrImpl
->nCommandType
= 0;
80 pBibImpl
= new SwDBData
;
81 pBibImpl
->nCommandType
= 0;
83 Sequence
<Any
> aValues
= GetProperties(rNames
);
84 const Any
* pValues
= aValues
.getConstArray();
85 OSL_ENSURE(aValues
.getLength() == rNames
.getLength(), "GetProperties failed");
86 if(aValues
.getLength() == rNames
.getLength())
88 for(int nProp
= 0; nProp
< rNames
.getLength(); nProp
++)
92 case 0: pValues
[nProp
] >>= pAdrImpl
->sDataSource
; break;
93 case 1: pValues
[nProp
] >>= pAdrImpl
->sCommand
; break;
94 case 2: pValues
[nProp
] >>= pAdrImpl
->nCommandType
; break;
95 case 3: pValues
[nProp
] >>= pBibImpl
->sDataSource
; break;
96 case 4: pValues
[nProp
] >>= pBibImpl
->sCommand
; break;
97 case 5: pValues
[nProp
] >>= pBibImpl
->nCommandType
; break;
103 const SwDBData
& SwDBConfig::GetAddressSource()
110 const SwDBData
& SwDBConfig::GetBibliographySource()
117 void SwDBConfig::Commit() {}
118 void SwDBConfig::Notify( const ::com::sun::star::uno::Sequence
< OUString
>& ) {}
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */