xref: /aoo4110/main/sw/source/ui/config/dbconfig.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <dbconfig.hxx>
29 #include <tools/debug.hxx>
30 #include <com/sun/star/uno/Any.hxx>
31 #include <com/sun/star/uno/Sequence.hxx>
32 #include <swdbdata.hxx>
33 
34 #include <unomid.h>
35 
36 using namespace utl;
37 using rtl::OUString;
38 using namespace com::sun::star::uno;
39 
40 /*--------------------------------------------------------------------
41 	 Beschreibung: Ctor
42  --------------------------------------------------------------------*/
43 
GetPropertyNames()44 const Sequence<OUString>& SwDBConfig::GetPropertyNames()
45 {
46 	static Sequence<OUString> aNames;
47 	if(!aNames.getLength())
48 	{
49 		static const char* aPropNames[] =
50 		{
51             "AddressBook/DataSourceName",        //  0
52             "AddressBook/Command",              //  1
53             "AddressBook/CommandType",          //  2
54             "Bibliography/CurrentDataSource/DataSourceName",        //  4
55             "Bibliography/CurrentDataSource/Command",              //  5
56             "Bibliography/CurrentDataSource/CommandType"          //  6
57         };
58         const int nCount = sizeof(aPropNames)/sizeof(const char*);
59 		aNames.realloc(nCount);
60 		OUString* pNames = aNames.getArray();
61 		for(int i = 0; i < nCount; i++)
62 			pNames[i] = OUString::createFromAscii(aPropNames[i]);
63 	}
64 	return aNames;
65 }
66 /* -----------------------------06.09.00 16:44--------------------------------
67 
68  ---------------------------------------------------------------------------*/
SwDBConfig()69 SwDBConfig::SwDBConfig() :
70     ConfigItem(C2U("Office.DataAccess"),
71         CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE),
72     pAdrImpl(0),
73     pBibImpl(0)
74 {
75 };
76 /* -----------------------------06.09.00 16:50--------------------------------
77 
78  ---------------------------------------------------------------------------*/
~SwDBConfig()79 SwDBConfig::~SwDBConfig()
80 {
81     delete pAdrImpl;
82     delete pBibImpl;
83 }
84 /* -----------------------------20.02.01 12:32--------------------------------
85 
86  ---------------------------------------------------------------------------*/
Load()87 void SwDBConfig::Load()
88 {
89 	const Sequence<OUString>& rNames = GetPropertyNames();
90     if(!pAdrImpl)
91 	{
92 
93         pAdrImpl = new SwDBData;
94         pAdrImpl->nCommandType = 0;
95         pBibImpl = new SwDBData;
96         pBibImpl->nCommandType = 0;
97     }
98 	Sequence<Any> aValues = GetProperties(rNames);
99 	const Any* pValues = aValues.getConstArray();
100 	DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed");
101 	if(aValues.getLength() == rNames.getLength())
102 	{
103 		for(int nProp = 0; nProp < rNames.getLength(); nProp++)
104 		{
105 			switch(nProp)
106 			{
107                 case  0: pValues[nProp] >>= pAdrImpl->sDataSource;  break;
108                 case  1: pValues[nProp] >>= pAdrImpl->sCommand;     break;
109                 case  2: pValues[nProp] >>= pAdrImpl->nCommandType; break;
110                 case  3: pValues[nProp] >>= pBibImpl->sDataSource;  break;
111                 case  4: pValues[nProp] >>= pBibImpl->sCommand;     break;
112                 case  5: pValues[nProp] >>= pBibImpl->nCommandType; break;
113             }
114 		}
115 	}
116 }
117 /* -----------------------------20.02.01 12:36--------------------------------
118 
119  ---------------------------------------------------------------------------*/
GetAddressSource()120 const SwDBData& SwDBConfig::GetAddressSource()
121 {
122     if(!pAdrImpl)
123 		Load();
124     return *pAdrImpl;
125 }
126 /* -----------------29.11.2002 11:43-----------------
127  *
128  * --------------------------------------------------*/
GetBibliographySource()129 const SwDBData& SwDBConfig::GetBibliographySource()
130 {
131     if(!pBibImpl)
132         Load();
133     return *pBibImpl;
134 }
135 
Commit()136 void SwDBConfig::Commit() {}
Notify(const::com::sun::star::uno::Sequence<rtl::OUString> &)137 void SwDBConfig::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
138 
139 
140