1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 32 #include <dbconfig.hxx> 33 #include <tools/debug.hxx> 34 #include <com/sun/star/uno/Any.hxx> 35 #include <com/sun/star/uno/Sequence.hxx> 36 #include <swdbdata.hxx> 37 38 #include <unomid.h> 39 40 using namespace utl; 41 using rtl::OUString; 42 using namespace com::sun::star::uno; 43 44 /*-------------------------------------------------------------------- 45 Beschreibung: Ctor 46 --------------------------------------------------------------------*/ 47 48 const Sequence<OUString>& SwDBConfig::GetPropertyNames() 49 { 50 static Sequence<OUString> aNames; 51 if(!aNames.getLength()) 52 { 53 static const char* aPropNames[] = 54 { 55 "AddressBook/DataSourceName", // 0 56 "AddressBook/Command", // 1 57 "AddressBook/CommandType", // 2 58 "Bibliography/CurrentDataSource/DataSourceName", // 4 59 "Bibliography/CurrentDataSource/Command", // 5 60 "Bibliography/CurrentDataSource/CommandType" // 6 61 }; 62 const int nCount = sizeof(aPropNames)/sizeof(const char*); 63 aNames.realloc(nCount); 64 OUString* pNames = aNames.getArray(); 65 for(int i = 0; i < nCount; i++) 66 pNames[i] = OUString::createFromAscii(aPropNames[i]); 67 } 68 return aNames; 69 } 70 /* -----------------------------06.09.00 16:44-------------------------------- 71 72 ---------------------------------------------------------------------------*/ 73 SwDBConfig::SwDBConfig() : 74 ConfigItem(C2U("Office.DataAccess"), 75 CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE), 76 pAdrImpl(0), 77 pBibImpl(0) 78 { 79 }; 80 /* -----------------------------06.09.00 16:50-------------------------------- 81 82 ---------------------------------------------------------------------------*/ 83 SwDBConfig::~SwDBConfig() 84 { 85 delete pAdrImpl; 86 delete pBibImpl; 87 } 88 /* -----------------------------20.02.01 12:32-------------------------------- 89 90 ---------------------------------------------------------------------------*/ 91 void SwDBConfig::Load() 92 { 93 const Sequence<OUString>& rNames = GetPropertyNames(); 94 if(!pAdrImpl) 95 { 96 97 pAdrImpl = new SwDBData; 98 pAdrImpl->nCommandType = 0; 99 pBibImpl = new SwDBData; 100 pBibImpl->nCommandType = 0; 101 } 102 Sequence<Any> aValues = GetProperties(rNames); 103 const Any* pValues = aValues.getConstArray(); 104 DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed"); 105 if(aValues.getLength() == rNames.getLength()) 106 { 107 for(int nProp = 0; nProp < rNames.getLength(); nProp++) 108 { 109 switch(nProp) 110 { 111 case 0: pValues[nProp] >>= pAdrImpl->sDataSource; break; 112 case 1: pValues[nProp] >>= pAdrImpl->sCommand; break; 113 case 2: pValues[nProp] >>= pAdrImpl->nCommandType; break; 114 case 3: pValues[nProp] >>= pBibImpl->sDataSource; break; 115 case 4: pValues[nProp] >>= pBibImpl->sCommand; break; 116 case 5: pValues[nProp] >>= pBibImpl->nCommandType; break; 117 } 118 } 119 } 120 } 121 /* -----------------------------20.02.01 12:36-------------------------------- 122 123 ---------------------------------------------------------------------------*/ 124 const SwDBData& SwDBConfig::GetAddressSource() 125 { 126 if(!pAdrImpl) 127 Load(); 128 return *pAdrImpl; 129 } 130 /* -----------------29.11.2002 11:43----------------- 131 * 132 * --------------------------------------------------*/ 133 const SwDBData& SwDBConfig::GetBibliographySource() 134 { 135 if(!pBibImpl) 136 Load(); 137 return *pBibImpl; 138 } 139 140 void SwDBConfig::Commit() {} 141 void SwDBConfig::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {} 142 143 144