1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dbconfig.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <dbconfig.hxx>
36 #include <tools/debug.hxx>
37 #include <com/sun/star/uno/Any.hxx>
38 #include <com/sun/star/uno/Sequence.hxx>
39 #include <swdbdata.hxx>
45 using namespace com::sun::star::uno
;
47 /*--------------------------------------------------------------------
49 --------------------------------------------------------------------*/
51 const Sequence
<OUString
>& SwDBConfig::GetPropertyNames()
53 static Sequence
<OUString
> aNames
;
54 if(!aNames
.getLength())
56 static const char* aPropNames
[] =
58 "AddressBook/DataSourceName", // 0
59 "AddressBook/Command", // 1
60 "AddressBook/CommandType", // 2
61 "Bibliography/CurrentDataSource/DataSourceName", // 4
62 "Bibliography/CurrentDataSource/Command", // 5
63 "Bibliography/CurrentDataSource/CommandType" // 6
65 const int nCount
= sizeof(aPropNames
)/sizeof(const char*);
66 aNames
.realloc(nCount
);
67 OUString
* pNames
= aNames
.getArray();
68 for(int i
= 0; i
< nCount
; i
++)
69 pNames
[i
] = OUString::createFromAscii(aPropNames
[i
]);
73 /* -----------------------------06.09.00 16:44--------------------------------
75 ---------------------------------------------------------------------------*/
76 SwDBConfig::SwDBConfig() :
77 ConfigItem(C2U("Office.DataAccess"),
78 CONFIG_MODE_DELAYED_UPDATE
|CONFIG_MODE_RELEASE_TREE
),
83 /* -----------------------------06.09.00 16:50--------------------------------
85 ---------------------------------------------------------------------------*/
86 SwDBConfig::~SwDBConfig()
91 /* -----------------------------20.02.01 12:32--------------------------------
93 ---------------------------------------------------------------------------*/
94 void SwDBConfig::Load()
96 const Sequence
<OUString
>& rNames
= GetPropertyNames();
100 pAdrImpl
= new SwDBData
;
101 pAdrImpl
->nCommandType
= 0;
102 pBibImpl
= new SwDBData
;
103 pBibImpl
->nCommandType
= 0;
105 Sequence
<Any
> aValues
= GetProperties(rNames
);
106 const Any
* pValues
= aValues
.getConstArray();
107 DBG_ASSERT(aValues
.getLength() == rNames
.getLength(), "GetProperties failed");
108 if(aValues
.getLength() == rNames
.getLength())
110 for(int nProp
= 0; nProp
< rNames
.getLength(); nProp
++)
114 case 0: pValues
[nProp
] >>= pAdrImpl
->sDataSource
; break;
115 case 1: pValues
[nProp
] >>= pAdrImpl
->sCommand
; break;
116 case 2: pValues
[nProp
] >>= pAdrImpl
->nCommandType
; break;
117 case 3: pValues
[nProp
] >>= pBibImpl
->sDataSource
; break;
118 case 4: pValues
[nProp
] >>= pBibImpl
->sCommand
; break;
119 case 5: pValues
[nProp
] >>= pBibImpl
->nCommandType
; break;
124 /* -----------------------------20.02.01 12:36--------------------------------
126 ---------------------------------------------------------------------------*/
127 const SwDBData
& SwDBConfig::GetAddressSource()
133 /* -----------------29.11.2002 11:43-----------------
135 * --------------------------------------------------*/
136 const SwDBData
& SwDBConfig::GetBibliographySource()