1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2a97ec55SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2a97ec55SAndrew Rist  * distributed with this work for additional information
6*2a97ec55SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2a97ec55SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist  * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2a97ec55SAndrew Rist  *
11*2a97ec55SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2a97ec55SAndrew Rist  *
13*2a97ec55SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist  * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2a97ec55SAndrew Rist  * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist  * under the License.
19*2a97ec55SAndrew Rist  *
20*2a97ec55SAndrew Rist  *************************************************************/
21*2a97ec55SAndrew Rist 
22*2a97ec55SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <bibconfig.hxx>
28cdf0e10cSrcweir #include <svl/svarray.hxx>
29cdf0e10cSrcweir #include <tools/debug.hxx>
30cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
31cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
32cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
33cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
34cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir using namespace rtl;
38cdf0e10cSrcweir using namespace ::com::sun::star::uno;
39cdf0e10cSrcweir using namespace ::com::sun::star::beans;
40cdf0e10cSrcweir using namespace ::com::sun::star::container;
41cdf0e10cSrcweir using namespace ::com::sun::star::lang;
42cdf0e10cSrcweir /* -----------------11.11.99 14:34-------------------
43cdf0e10cSrcweir 
44cdf0e10cSrcweir  --------------------------------------------------*/
45cdf0e10cSrcweir typedef Mapping* MappingPtr;
46cdf0e10cSrcweir SV_DECL_PTRARR_DEL(MappingArray, MappingPtr, 2, 2)
47cdf0e10cSrcweir SV_IMPL_PTRARR(MappingArray, MappingPtr);
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #define C2U(cChar) OUString::createFromAscii(cChar)
50cdf0e10cSrcweir 
51cdf0e10cSrcweir const char* cDataSourceHistory = "DataSourceHistory";
52cdf0e10cSrcweir /* -----------------------------13.11.00 12:21--------------------------------
53cdf0e10cSrcweir 
54cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
GetPropertyNames()55cdf0e10cSrcweir Sequence<OUString> BibConfig::GetPropertyNames()
56cdf0e10cSrcweir {
57cdf0e10cSrcweir 	static Sequence<OUString> aNames;
58cdf0e10cSrcweir 	if(!aNames.getLength())
59cdf0e10cSrcweir 	{
60cdf0e10cSrcweir         aNames.realloc(8);
61cdf0e10cSrcweir 		OUString* pNames = aNames.getArray();
62cdf0e10cSrcweir 		pNames[0] = C2U("CurrentDataSource/DataSourceName");
63cdf0e10cSrcweir 		pNames[1] = C2U("CurrentDataSource/Command");
64cdf0e10cSrcweir 		pNames[2] = C2U("CurrentDataSource/CommandType");
65cdf0e10cSrcweir 		pNames[3] = C2U("BeamerHeight");
66cdf0e10cSrcweir 		pNames[4] = C2U("ViewHeight");
67cdf0e10cSrcweir 		pNames[5] = C2U("QueryText");
68cdf0e10cSrcweir 		pNames[6] = C2U("QueryField");
69cdf0e10cSrcweir         pNames[7] = C2U("ShowColumnAssignmentWarning");
70cdf0e10cSrcweir     }
71cdf0e10cSrcweir 	return aNames;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir /* -----------------------------13.11.00 11:00--------------------------------
74cdf0e10cSrcweir 
75cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
BibConfig()76cdf0e10cSrcweir BibConfig::BibConfig() :
77cdf0e10cSrcweir     ConfigItem(C2U("Office.DataAccess/Bibliography"), CONFIG_MODE_DELAYED_UPDATE),
78cdf0e10cSrcweir 	pMappingsArr(new MappingArray),
79cdf0e10cSrcweir 	nBeamerSize(0),
80cdf0e10cSrcweir 	nViewSize(0),
81cdf0e10cSrcweir 	bShowColumnAssignmentWarning(sal_False)
82cdf0e10cSrcweir {
83cdf0e10cSrcweir 	//Names of the default columns
84cdf0e10cSrcweir 	aColumnDefaults[0] = C2U("Identifier");
85cdf0e10cSrcweir 	aColumnDefaults[1] = C2U("BibliographyType");
86cdf0e10cSrcweir 	aColumnDefaults[2] = C2U("Author");
87cdf0e10cSrcweir 	aColumnDefaults[3] = C2U("Title");
88cdf0e10cSrcweir 	aColumnDefaults[4] = C2U("Year");
89cdf0e10cSrcweir 	aColumnDefaults[5] = C2U("ISBN");
90cdf0e10cSrcweir 	aColumnDefaults[6] = C2U("Booktitle");
91cdf0e10cSrcweir 	aColumnDefaults[7] = C2U("Chapter");
92cdf0e10cSrcweir 	aColumnDefaults[8] = C2U("Edition");
93cdf0e10cSrcweir 	aColumnDefaults[9] = C2U("Editor");
94cdf0e10cSrcweir 	aColumnDefaults[10] = C2U("Howpublished");
95cdf0e10cSrcweir 	aColumnDefaults[11] = C2U("Institution");
96cdf0e10cSrcweir 	aColumnDefaults[12] = C2U("Journal");
97cdf0e10cSrcweir 	aColumnDefaults[13] = C2U("Month");
98cdf0e10cSrcweir 	aColumnDefaults[14] = C2U("Note");
99cdf0e10cSrcweir 	aColumnDefaults[15] = C2U("Annote");
100cdf0e10cSrcweir 	aColumnDefaults[16] = C2U("Number");
101cdf0e10cSrcweir 	aColumnDefaults[17] = C2U("Organizations");
102cdf0e10cSrcweir 	aColumnDefaults[18] = C2U("Pages");
103cdf0e10cSrcweir 	aColumnDefaults[19] = C2U("Publisher");
104cdf0e10cSrcweir 	aColumnDefaults[20] = C2U("Address");
105cdf0e10cSrcweir 	aColumnDefaults[21] = C2U("School");
106cdf0e10cSrcweir 	aColumnDefaults[22] = C2U("Series");
107cdf0e10cSrcweir 	aColumnDefaults[23] = C2U("ReportType");
108cdf0e10cSrcweir 	aColumnDefaults[24] = C2U("Volume");
109cdf0e10cSrcweir 	aColumnDefaults[25] = C2U("URL");
110cdf0e10cSrcweir 	aColumnDefaults[26] = C2U("Custom1");
111cdf0e10cSrcweir 	aColumnDefaults[27] = C2U("Custom2");
112cdf0e10cSrcweir 	aColumnDefaults[28] = C2U("Custom3");
113cdf0e10cSrcweir 	aColumnDefaults[29] = C2U("Custom4");
114cdf0e10cSrcweir 	aColumnDefaults[30] = C2U("Custom5");
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	const Sequence< OUString > aPropertyNames = GetPropertyNames();
118cdf0e10cSrcweir 	const Sequence<Any> aPropertyValues = GetProperties( aPropertyNames );
119cdf0e10cSrcweir 	const Any* pValues = aPropertyValues.getConstArray();
120cdf0e10cSrcweir 	if(aPropertyValues.getLength() == aPropertyNames.getLength())
121cdf0e10cSrcweir 	{
122cdf0e10cSrcweir 		for(int nProp = 0; nProp < aPropertyNames.getLength(); nProp++)
123cdf0e10cSrcweir 		{
124cdf0e10cSrcweir 			if(pValues[nProp].hasValue())
125cdf0e10cSrcweir 			{
126cdf0e10cSrcweir 				switch(nProp)
127cdf0e10cSrcweir 				{
128cdf0e10cSrcweir 					case  0: pValues[nProp] >>= sDataSource; break;
129cdf0e10cSrcweir 					case  1: pValues[nProp] >>= sTableOrQuery; break;
130cdf0e10cSrcweir 					case  2: pValues[nProp] >>= nTblOrQuery;  break;
131cdf0e10cSrcweir 					case  3: pValues[nProp] >>= nBeamerSize;  break;
132cdf0e10cSrcweir 					case  4: pValues[nProp] >>= nViewSize  ;  break;
133cdf0e10cSrcweir 					case  5: pValues[nProp] >>= sQueryText ;  break;
134cdf0e10cSrcweir 					case  6: pValues[nProp] >>= sQueryField;  break;
135cdf0e10cSrcweir                     case  7:
136cdf0e10cSrcweir                         bShowColumnAssignmentWarning = *(sal_Bool*)pValues[nProp].getValue();
137cdf0e10cSrcweir                     break;
138cdf0e10cSrcweir                 }
139cdf0e10cSrcweir 			}
140cdf0e10cSrcweir 		}
141cdf0e10cSrcweir 	}
142cdf0e10cSrcweir 	OUString sName(C2U("DataSourceName"));
143cdf0e10cSrcweir 	OUString sTable(C2U("Command"));
144cdf0e10cSrcweir 	OUString sCommandType(C2U("CommandType"));
145cdf0e10cSrcweir 	Sequence< OUString > aNodeNames = GetNodeNames(C2U(cDataSourceHistory));
146cdf0e10cSrcweir 	const OUString* pNodeNames = aNodeNames.getConstArray();
147cdf0e10cSrcweir 	for(sal_Int32 nNode = 0; nNode < aNodeNames.getLength(); nNode++)
148cdf0e10cSrcweir 	{
149cdf0e10cSrcweir         Sequence<OUString> aHistoryNames(3);
150cdf0e10cSrcweir 		OUString* pHistoryNames = aHistoryNames.getArray();
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 		OUString sPrefix(C2U(cDataSourceHistory));
153cdf0e10cSrcweir 		sPrefix += C2U("/");
154cdf0e10cSrcweir 		sPrefix += pNodeNames[nNode];
155cdf0e10cSrcweir 		sPrefix += C2U("/");
156cdf0e10cSrcweir 		pHistoryNames[0] = sPrefix;
157cdf0e10cSrcweir 		pHistoryNames[0] += sName;
158cdf0e10cSrcweir 		pHistoryNames[1] = sPrefix;
159cdf0e10cSrcweir 		pHistoryNames[1] += sTable;
160cdf0e10cSrcweir 		pHistoryNames[2] = sPrefix;
161cdf0e10cSrcweir 		pHistoryNames[2] += sCommandType;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir         Sequence<Any> aHistoryValues = GetProperties( aHistoryNames );
164cdf0e10cSrcweir         const Any* pHistoryValues = aHistoryValues.getConstArray();
165cdf0e10cSrcweir 
166cdf0e10cSrcweir         if(aHistoryValues.getLength() == aHistoryNames.getLength())
167cdf0e10cSrcweir 		{
168cdf0e10cSrcweir 			Mapping* pMapping = new Mapping;
169cdf0e10cSrcweir 			pHistoryValues[0] >>= pMapping->sURL;
170cdf0e10cSrcweir 			pHistoryValues[1] >>= pMapping->sTableName;
171cdf0e10cSrcweir 			pHistoryValues[2] >>= pMapping->nCommandType;
172cdf0e10cSrcweir 			//field assignment is contained in another set
173cdf0e10cSrcweir 			sPrefix += C2U("Fields");
174cdf0e10cSrcweir 			Sequence< OUString > aAssignmentNodeNames = GetNodeNames(sPrefix);
175cdf0e10cSrcweir 			const OUString* pAssignmentNodeNames = aAssignmentNodeNames.getConstArray();
176cdf0e10cSrcweir 			Sequence<OUString> aAssignmentPropertyNames(aAssignmentNodeNames.getLength() * 2);
177cdf0e10cSrcweir 			OUString* pAssignmentPropertyNames = aAssignmentPropertyNames.getArray();
178cdf0e10cSrcweir 			sal_Int16 nFieldIdx = 0;
179cdf0e10cSrcweir 			for(sal_Int16 nField = 0; nField < aAssignmentNodeNames.getLength(); nField++)
180cdf0e10cSrcweir 			{
181cdf0e10cSrcweir 				OUString sSubPrefix(sPrefix);
182cdf0e10cSrcweir 				sSubPrefix += C2U("/");
183cdf0e10cSrcweir 				sSubPrefix += pAssignmentNodeNames[nField];
184cdf0e10cSrcweir 				pAssignmentPropertyNames[nFieldIdx] = sSubPrefix;
185cdf0e10cSrcweir 				pAssignmentPropertyNames[nFieldIdx++] += C2U("/ProgrammaticFieldName");
186cdf0e10cSrcweir 				pAssignmentPropertyNames[nFieldIdx] = sSubPrefix;
187cdf0e10cSrcweir 				pAssignmentPropertyNames[nFieldIdx++]	+= C2U("/AssignedFieldName");
188cdf0e10cSrcweir 			}
189cdf0e10cSrcweir 			Sequence<Any> aAssignmentValues = GetProperties(aAssignmentPropertyNames);
190cdf0e10cSrcweir 			const Any* pAssignmentValues = aAssignmentValues.getConstArray();
191cdf0e10cSrcweir 			OUString sTempLogical;
192cdf0e10cSrcweir 			OUString sTempReal;
193cdf0e10cSrcweir 			sal_Int16 nSetMapping = 0;
194cdf0e10cSrcweir 			nFieldIdx = 0;
195cdf0e10cSrcweir 			for(sal_Int16 nFieldVal = 0; nFieldVal < aAssignmentValues.getLength() / 2; nFieldVal++)
196cdf0e10cSrcweir 			{
197cdf0e10cSrcweir 				pAssignmentValues[nFieldIdx++] >>= sTempLogical;
198cdf0e10cSrcweir 				pAssignmentValues[nFieldIdx++] >>= sTempReal;
199cdf0e10cSrcweir 				if(sTempLogical.getLength() && sTempReal.getLength())
200cdf0e10cSrcweir 				{
201cdf0e10cSrcweir 					pMapping->aColumnPairs[nSetMapping].sLogicalColumnName = sTempLogical;
202cdf0e10cSrcweir 					pMapping->aColumnPairs[nSetMapping++].sRealColumnName = sTempReal;
203cdf0e10cSrcweir 				}
204cdf0e10cSrcweir 			}
205cdf0e10cSrcweir 			pMappingsArr->Insert(pMapping, pMappingsArr->Count());
206cdf0e10cSrcweir 		}
207cdf0e10cSrcweir 	}
208cdf0e10cSrcweir }
209cdf0e10cSrcweir /* -----------------------------13.11.00 11:00--------------------------------
210cdf0e10cSrcweir 
211cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
~BibConfig()212cdf0e10cSrcweir BibConfig::~BibConfig()
213cdf0e10cSrcweir {
214cdf0e10cSrcweir 	if(IsModified())
215cdf0e10cSrcweir 		Commit();
216cdf0e10cSrcweir 	delete pMappingsArr;
217cdf0e10cSrcweir }
218cdf0e10cSrcweir /* -----------------------------13.11.00 12:08--------------------------------
219cdf0e10cSrcweir 
220cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
GetBibliographyURL()221cdf0e10cSrcweir BibDBDescriptor BibConfig::GetBibliographyURL()
222cdf0e10cSrcweir {
223cdf0e10cSrcweir 	BibDBDescriptor	aRet;
224cdf0e10cSrcweir 	aRet.sDataSource = sDataSource;
225cdf0e10cSrcweir 	aRet.sTableOrQuery = sTableOrQuery;
226cdf0e10cSrcweir 	aRet.nCommandType = nTblOrQuery;
227cdf0e10cSrcweir 	return aRet;
228cdf0e10cSrcweir };
229cdf0e10cSrcweir /* -----------------------------13.11.00 12:20--------------------------------
230cdf0e10cSrcweir 
231cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
SetBibliographyURL(const BibDBDescriptor & rDesc)232cdf0e10cSrcweir void BibConfig::SetBibliographyURL(const BibDBDescriptor& rDesc)
233cdf0e10cSrcweir {
234cdf0e10cSrcweir 	sDataSource = rDesc.sDataSource;
235cdf0e10cSrcweir 	sTableOrQuery = rDesc.sTableOrQuery;
236cdf0e10cSrcweir 	nTblOrQuery = rDesc.nCommandType;
237cdf0e10cSrcweir 	SetModified();
238cdf0e10cSrcweir };
239cdf0e10cSrcweir //---------------------------------------------------------------------------
Notify(const com::sun::star::uno::Sequence<rtl::OUString> &)240cdf0e10cSrcweir void BibConfig::Notify( const com::sun::star::uno::Sequence<rtl::OUString>& )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir }
243cdf0e10cSrcweir 
Commit()244cdf0e10cSrcweir void	BibConfig::Commit()
245cdf0e10cSrcweir {
246cdf0e10cSrcweir 	const Sequence<OUString> aPropertyNames = GetPropertyNames();
247cdf0e10cSrcweir 	Sequence<Any> aValues(aPropertyNames.getLength());
248cdf0e10cSrcweir 	Any* pValues = aValues.getArray();
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 	for(int nProp = 0; nProp < aPropertyNames.getLength(); nProp++)
251cdf0e10cSrcweir 	{
252cdf0e10cSrcweir 		switch(nProp)
253cdf0e10cSrcweir 		{
254cdf0e10cSrcweir 			case  0: pValues[nProp] <<= sDataSource; break;
255cdf0e10cSrcweir 			case  1: pValues[nProp] <<= sTableOrQuery; break;
256cdf0e10cSrcweir 			case  2: pValues[nProp] <<= nTblOrQuery;  break;
257cdf0e10cSrcweir 			case  3: pValues[nProp] <<= nBeamerSize;  break;
258cdf0e10cSrcweir 			case  4: pValues[nProp] <<= nViewSize;  break;
259cdf0e10cSrcweir 			case  5: pValues[nProp] <<= sQueryText;  break;
260cdf0e10cSrcweir 			case  6: pValues[nProp] <<= sQueryField;  break;
261cdf0e10cSrcweir             case  7:
262cdf0e10cSrcweir                 pValues[nProp].setValue(&bShowColumnAssignmentWarning, ::getBooleanCppuType());
263cdf0e10cSrcweir             break;
264cdf0e10cSrcweir 		}
265cdf0e10cSrcweir 	}
266cdf0e10cSrcweir 	PutProperties(aPropertyNames, aValues);
267cdf0e10cSrcweir 	ClearNodeSet( C2U(cDataSourceHistory));
268cdf0e10cSrcweir 	OUString sEmpty;
269cdf0e10cSrcweir 	Sequence< PropertyValue > aNodeValues(pMappingsArr->Count() * 3);
270cdf0e10cSrcweir 	PropertyValue* pNodeValues = aNodeValues.getArray();
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 	sal_Int32 nIndex = 0;
273cdf0e10cSrcweir 	OUString sName(C2U("DataSourceName"));
274cdf0e10cSrcweir 	OUString sTable(C2U("Command"));
275cdf0e10cSrcweir 	OUString sCommandType(C2U("CommandType"));
276cdf0e10cSrcweir 	for(sal_Int32 i = 0; i < pMappingsArr->Count(); i++)
277cdf0e10cSrcweir 	{
278cdf0e10cSrcweir         const Mapping* pMapping = pMappingsArr->GetObject((sal_uInt16)i);
279cdf0e10cSrcweir 		OUString sPrefix(C2U(cDataSourceHistory));
280cdf0e10cSrcweir 		sPrefix += C2U("/_");
281cdf0e10cSrcweir 		sPrefix += OUString::valueOf(i);
282cdf0e10cSrcweir 		sPrefix += C2U("/");
283cdf0e10cSrcweir 		pNodeValues[nIndex].Name	= sPrefix;
284cdf0e10cSrcweir 		pNodeValues[nIndex].Name	+= sName;
285cdf0e10cSrcweir 		pNodeValues[nIndex++].Value <<= pMapping->sURL;
286cdf0e10cSrcweir 		pNodeValues[nIndex].Name	= sPrefix;
287cdf0e10cSrcweir 		pNodeValues[nIndex].Name    += sTable;
288cdf0e10cSrcweir 		pNodeValues[nIndex++].Value <<= pMapping->sTableName;
289cdf0e10cSrcweir 		pNodeValues[nIndex].Name	= sPrefix;
290cdf0e10cSrcweir 		pNodeValues[nIndex].Name    += sCommandType;
291cdf0e10cSrcweir 		pNodeValues[nIndex++].Value <<= pMapping->nCommandType;
292cdf0e10cSrcweir 		SetSetProperties( C2U(cDataSourceHistory), aNodeValues);
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 		sPrefix += C2U("Fields");
295cdf0e10cSrcweir 		sal_Int32 nFieldAssignment = 0;
296cdf0e10cSrcweir 		OUString sFieldName = C2U("/ProgrammaticFieldName");
297cdf0e10cSrcweir 		OUString sDatabaseFieldName = C2U("/AssignedFieldName");
298cdf0e10cSrcweir 		ClearNodeSet( sPrefix );
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 		while(nFieldAssignment < COLUMN_COUNT &&
301cdf0e10cSrcweir 			pMapping->aColumnPairs[nFieldAssignment].sLogicalColumnName.getLength())
302cdf0e10cSrcweir 		{
303cdf0e10cSrcweir 			OUString sSubPrefix(sPrefix);
304cdf0e10cSrcweir 			sSubPrefix += C2U("/_");
305cdf0e10cSrcweir 			sSubPrefix += OUString::valueOf(nFieldAssignment);
306cdf0e10cSrcweir 			Sequence< PropertyValue > aAssignmentValues(2);
307cdf0e10cSrcweir 			PropertyValue* pAssignmentValues = aAssignmentValues.getArray();
308cdf0e10cSrcweir 			pAssignmentValues[0].Name	= sSubPrefix;
309cdf0e10cSrcweir 			pAssignmentValues[0].Name	+= sFieldName;
310cdf0e10cSrcweir 			pAssignmentValues[0].Value <<= pMapping->aColumnPairs[nFieldAssignment].sLogicalColumnName;
311cdf0e10cSrcweir 			pAssignmentValues[1].Name	= sSubPrefix;
312cdf0e10cSrcweir 			pAssignmentValues[1].Name	+= sDatabaseFieldName;
313cdf0e10cSrcweir 			pAssignmentValues[1].Value <<= pMapping->aColumnPairs[nFieldAssignment].sRealColumnName;
314cdf0e10cSrcweir 			SetSetProperties( sPrefix, aAssignmentValues );
315cdf0e10cSrcweir 			nFieldAssignment++;
316cdf0e10cSrcweir 		}
317cdf0e10cSrcweir 	}
318cdf0e10cSrcweir }
319cdf0e10cSrcweir /* -----------------------------13.11.00 12:23--------------------------------
320cdf0e10cSrcweir 
321cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
GetMapping(const BibDBDescriptor & rDesc) const322cdf0e10cSrcweir const Mapping* 	BibConfig::GetMapping(const BibDBDescriptor& rDesc) const
323cdf0e10cSrcweir {
324cdf0e10cSrcweir 	for(sal_uInt16 i = 0; i < pMappingsArr->Count(); i++)
325cdf0e10cSrcweir 	{
326cdf0e10cSrcweir 		const Mapping* pMapping = pMappingsArr->GetObject(i);
327cdf0e10cSrcweir 		sal_Bool bURLEqual = rDesc.sDataSource.equals(pMapping->sURL);
328cdf0e10cSrcweir 		if(rDesc.sTableOrQuery == pMapping->sTableName && bURLEqual)
329cdf0e10cSrcweir 			return pMapping;
330cdf0e10cSrcweir 	}
331cdf0e10cSrcweir 	return 0;
332cdf0e10cSrcweir }
333cdf0e10cSrcweir /* -----------------------------13.11.00 12:23--------------------------------
334cdf0e10cSrcweir 
335cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
SetMapping(const BibDBDescriptor & rDesc,const Mapping * pSetMapping)336cdf0e10cSrcweir void BibConfig::SetMapping(const BibDBDescriptor& rDesc, const Mapping* pSetMapping)
337cdf0e10cSrcweir {
338cdf0e10cSrcweir 	for(sal_uInt16 i = 0; i < pMappingsArr->Count(); i++)
339cdf0e10cSrcweir 	{
340cdf0e10cSrcweir 		const Mapping* pMapping = pMappingsArr->GetObject(i);
341cdf0e10cSrcweir 		sal_Bool bURLEqual = rDesc.sDataSource.equals(pMapping->sURL);
342cdf0e10cSrcweir 		if(rDesc.sTableOrQuery == pMapping->sTableName && bURLEqual)
343cdf0e10cSrcweir 		{
344cdf0e10cSrcweir 			pMappingsArr->DeleteAndDestroy(i, 1);
345cdf0e10cSrcweir 			break;
346cdf0e10cSrcweir 		}
347cdf0e10cSrcweir 	}
348cdf0e10cSrcweir 	Mapping* pNew = new Mapping(*pSetMapping);
349cdf0e10cSrcweir 	pMappingsArr->Insert(pNew, pMappingsArr->Count());
350cdf0e10cSrcweir 	SetModified();
351cdf0e10cSrcweir }
352cdf0e10cSrcweir /* -----------------------------20.11.00 11:56--------------------------------
353cdf0e10cSrcweir 
354cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
DBChangeDialogConfig_Impl()355cdf0e10cSrcweir DBChangeDialogConfig_Impl::DBChangeDialogConfig_Impl()
356cdf0e10cSrcweir {
357cdf0e10cSrcweir }
358cdf0e10cSrcweir /* -----------------------------20.11.00 11:57--------------------------------
359cdf0e10cSrcweir 
360cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
~DBChangeDialogConfig_Impl()361cdf0e10cSrcweir DBChangeDialogConfig_Impl::~DBChangeDialogConfig_Impl()
362cdf0e10cSrcweir {
363cdf0e10cSrcweir }
364cdf0e10cSrcweir /* -----------------------------14.03.01 12:53--------------------------------
365cdf0e10cSrcweir 
366cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
GetDataSourceNames()367cdf0e10cSrcweir const Sequence<OUString>& DBChangeDialogConfig_Impl::GetDataSourceNames()
368cdf0e10cSrcweir {
369cdf0e10cSrcweir     if(!aSourceNames.getLength())
370cdf0e10cSrcweir     {
371cdf0e10cSrcweir         Reference<XNameAccess> xDBContext;
372cdf0e10cSrcweir         Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
373cdf0e10cSrcweir         if( xMgr.is() )
374cdf0e10cSrcweir         {
375cdf0e10cSrcweir             Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" ));
376cdf0e10cSrcweir             xDBContext = Reference<XNameAccess>(xInstance, UNO_QUERY) ;
377cdf0e10cSrcweir         }
378cdf0e10cSrcweir         if(xDBContext.is())
379cdf0e10cSrcweir         {
380cdf0e10cSrcweir             aSourceNames = xDBContext->getElementNames();
381cdf0e10cSrcweir         }
382cdf0e10cSrcweir     }
383cdf0e10cSrcweir     return aSourceNames;
384cdf0e10cSrcweir }
385cdf0e10cSrcweir 
386