Files
libreoffice/connectivity/source/commontools/DriversConfig.cxx
Kurt Zenker 99efc0ba1f CWS-TOOLING: integrate CWS dba32h
2009-10-12 12:21:44 +0200 msc  r276827 : remove warning for issue 102712 because the issue is fixed
2009-10-05 07:14:20 +0200 oj  r276658 : #105585# add missing dependency for OOO_UI
2009-10-02 12:50:19 +0200 fs  r276632 : #i105505#
If a model is created, and is a revenant of a previous incarnation, then ensure it is properly initialized.
In particular, in its ctor, set the state to "Initializing", not "Initialized", and then let the ModelImpl
call attachResource. This ensures that the model is initialized completely, including firing the necessary
events.
2009-10-02 12:46:12 +0200 fs  r276631 : #i105505# always do an attachResource at the newly loaded model, even if it (internally) was not really loaded, but only a revenant of a previous incarnation of this document
2009-10-01 13:09:07 +0200 fs  r276596 : do not rely on the name 'Standard' for the one and only form in a document
2009-10-01 12:35:56 +0200 fs  r276589 : #i105509# don't rely on default form component names, use indexes
2009-10-01 11:19:18 +0200 fs  r276584 : copying the fix for #i105082# into this CWS
2009-10-01 11:13:22 +0200 fs  r276583 : improved logs
2009-10-01 11:10:44 +0200 fs  r276581 : #i105505#
2009-10-01 08:07:57 +0200 fs  r276575 : manual merge of trunk, to allow cwslocalize to run
2009-09-30 22:48:30 +0200 fs  r276574 : removed that strange ONLOAD definition
2009-09-30 12:58:18 +0200 fs  r276553 : copy fix for #i105387# into this CWS, as the issue prevents us from finalizing the CWS
2009-09-30 12:56:45 +0200 fs  r276552 : copy fix for #i105387# into this CWS, as the issue prevents us from finalizing the CWS
2009-09-30 11:47:45 +0200 fs  r276549 : #i105235#
2009-09-29 12:27:40 +0200 fs  r276521 : #i105367#
2009-09-28 12:08:17 +0200 oj  r276485 : #i105371# export version in manifest.xml as well
2009-09-28 12:07:02 +0200 oj  r276484 : #i105371# export version in manifest.xml as well
2009-09-28 09:48:01 +0200 oj  r276481 : #i105366# init drivers when not empty
2009-09-25 14:31:27 +0200 fs  r276466 : CWS-TOOLING: rebase CWS dba32h to trunk@276429 (milestone: DEV300:m60)
2009-09-24 13:52:54 +0200 fs  r276422 : #i105234# do not zoom the control when they view information is still uninitialized (happens at least in Writer when opening a form document)
2009-09-24 11:42:03 +0200 fs  r276413 : #i105234# proper zoom handling for the nav bar
2009-09-24 11:41:40 +0200 fs  r276412 : #i105234# setZoom: care for precision errors caused by implicit conversion float->double
2009-09-23 12:21:22 +0200 oj  r276377 : remove dos lineends
2009-09-23 11:44:52 +0200 oj  r276376 : #i105216# load config on demand
2009-09-23 11:44:19 +0200 oj  r276375 : #i105216# load config on demand
2009-09-23 11:43:35 +0200 oj  r276374 : #i105216# load config on demand
2009-09-21 09:13:03 +0200 oj  r276307 : #i105158# use Thread support
2009-09-18 13:06:50 +0200 fs  r276277 : #i105147#
2009-09-18 11:48:23 +0200 oj  r276271 : #i105158# new method for thread safety
2009-09-18 10:42:56 +0200 fs  r276266 : CWS-TOOLING: rebase CWS dba32h to trunk@276192 (milestone: DEV300:m59)
2009-09-18 08:30:03 +0200 oj  r276263 : #i105016# load correct ldap so
2009-09-17 13:42:31 +0200 oj  r276240 : change count of check boxes
2009-09-17 13:32:59 +0200 oj  r276239 : revert false to true for currency
2009-09-17 09:14:46 +0200 oj  r276220 : #i104901# add patch for every issue
2009-09-17 09:10:29 +0200 oj  r276219 : #i104901# add patch for every issue
2009-09-11 13:47:49 +0200 oj  r276060 : #i104901# fix for indentity
2009-09-11 12:14:14 +0200 fs  r276056 : #i104594# allow to render controls without an SdrPageView
2009-09-11 11:49:31 +0200 fs  r276055 : CWS-TOOLING: rebase CWS dba32h to trunk@276043 (milestone: DEV300:m58)
2009-09-10 08:41:40 +0200 oj  r276021 : #i104911# export variable-set not for repeating sections
2009-10-14 18:48:09 +00:00

271 lines
11 KiB
C++
Executable File

/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: makefile,v $
*
* $Revision: 1.1 $
*
* last change: $Author: st $ $Date: 2000/11/22 02:32:00 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
#include "connectivity/DriversConfig.hxx"
#include <tools/wldcrd.hxx>
using namespace connectivity;
using namespace utl;
using namespace ::com::sun::star;
namespace
{
void lcl_convert(const uno::Sequence< ::rtl::OUString >& _aSource,uno::Any& _rDest)
{
uno::Sequence<uno::Any> aRet(_aSource.getLength());
uno::Any* pAny = aRet.getArray();
const ::rtl::OUString* pIter = _aSource.getConstArray();
const ::rtl::OUString* pEnd = pIter + _aSource.getLength();
for (;pIter != pEnd ; ++pIter,++pAny)
{
*pAny <<= *pIter;
}
_rDest <<= aRet;
}
void lcl_fillValues(const ::utl::OConfigurationNode& _aURLPatternNode,const ::rtl::OUString& _sNode,::comphelper::NamedValueCollection& _rValues)
{
const ::utl::OConfigurationNode aPropertiesNode = _aURLPatternNode.openNode(_sNode);
if ( aPropertiesNode.isValid() )
{
uno::Sequence< ::rtl::OUString > aStringSeq;
static const ::rtl::OUString s_sValue(RTL_CONSTASCII_USTRINGPARAM("/Value"));
const uno::Sequence< ::rtl::OUString > aProperties = aPropertiesNode.getNodeNames();
const ::rtl::OUString* pPropertiesIter = aProperties.getConstArray();
const ::rtl::OUString* pPropertiesEnd = pPropertiesIter + aProperties.getLength();
for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter)
{
uno::Any aValue = aPropertiesNode.getNodeValue(*pPropertiesIter + s_sValue);
if ( aValue >>= aStringSeq )
{
lcl_convert(aStringSeq,aValue);
}
_rValues.put(*pPropertiesIter,aValue);
} // for (;pPropertiesIter != pPropertiesEnd ; ++pPropertiesIter,++pNamedIter)
} // if ( aPropertiesNode.isValid() )
}
void lcl_readURLPatternNode(const ::utl::OConfigurationTreeRoot& _aInstalled,const ::rtl::OUString& _sEntry,TInstalledDriver& _rInstalledDriver)
{
const ::utl::OConfigurationNode aURLPatternNode = _aInstalled.openNode(_sEntry);
if ( aURLPatternNode.isValid() )
{
static const ::rtl::OUString s_sParentURLPattern(RTL_CONSTASCII_USTRINGPARAM("ParentURLPattern"));
static const ::rtl::OUString s_sDriver(RTL_CONSTASCII_USTRINGPARAM("Driver"));
static const ::rtl::OUString s_sDriverTypeDisplayName(RTL_CONSTASCII_USTRINGPARAM("DriverTypeDisplayName"));
static const ::rtl::OUString s_sProperties(RTL_CONSTASCII_USTRINGPARAM("Properties"));
static const ::rtl::OUString s_sFeatures(RTL_CONSTASCII_USTRINGPARAM("Features"));
static const ::rtl::OUString s_sMetaData(RTL_CONSTASCII_USTRINGPARAM("MetaData"));
::rtl::OUString sParentURLPattern;
aURLPatternNode.getNodeValue(s_sParentURLPattern) >>= sParentURLPattern;
if ( sParentURLPattern.getLength() )
lcl_readURLPatternNode(_aInstalled,sParentURLPattern,_rInstalledDriver);
::rtl::OUString sDriverFactory;
aURLPatternNode.getNodeValue(s_sDriver) >>= sDriverFactory;
if ( sDriverFactory.getLength() )
_rInstalledDriver.sDriverFactory = sDriverFactory;
::rtl::OUString sDriverTypeDisplayName;
aURLPatternNode.getNodeValue(s_sDriverTypeDisplayName) >>= sDriverTypeDisplayName;
OSL_ENSURE(sDriverTypeDisplayName.getLength(),"No valid DriverTypeDisplayName property!");
if ( sDriverTypeDisplayName.getLength() )
_rInstalledDriver.sDriverTypeDisplayName = sDriverTypeDisplayName;
lcl_fillValues(aURLPatternNode,s_sProperties,_rInstalledDriver.aProperties);
lcl_fillValues(aURLPatternNode,s_sFeatures,_rInstalledDriver.aFeatures);
lcl_fillValues(aURLPatternNode,s_sMetaData,_rInstalledDriver.aMetaData);
}
}
}
// -----------------------------------------------------------------------------
DriversConfigImpl::DriversConfigImpl()
{
}
// -----------------------------------------------------------------------------
void DriversConfigImpl::Load(const uno::Reference< lang::XMultiServiceFactory >& _rxORB) const
{
if ( m_aDrivers.empty() )
{
if ( !m_aInstalled.isValid() )
{
static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess.Drivers/Installed")); ///Installed
m_aInstalled = ::utl::OConfigurationTreeRoot::createWithServiceFactory(_rxORB, s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY);
}
if ( m_aInstalled.isValid() )
{
const uno::Sequence< ::rtl::OUString > aURLPatterns = m_aInstalled.getNodeNames();
const ::rtl::OUString* pPatternIter = aURLPatterns.getConstArray();
const ::rtl::OUString* pPatternEnd = pPatternIter + aURLPatterns.getLength();
for (;pPatternIter != pPatternEnd ; ++pPatternIter)
{
TInstalledDriver aInstalledDriver;
lcl_readURLPatternNode(m_aInstalled,*pPatternIter,aInstalledDriver);
if ( aInstalledDriver.sDriverFactory.getLength() )
m_aDrivers.insert(TInstalledDrivers::value_type(*pPatternIter,aInstalledDriver));
}
} // if ( m_aInstalled.isValid() )
}
}
// -----------------------------------------------------------------------------
DriversConfig::DriversConfig(const uno::Reference< lang::XMultiServiceFactory >& _rxORB)
:m_xORB(_rxORB)
{
}
// -----------------------------------------------------------------------------
DriversConfig::~DriversConfig()
{
}
// -----------------------------------------------------------------------------
DriversConfig::DriversConfig( const DriversConfig& _rhs )
{
*this = _rhs;
}
// -----------------------------------------------------------------------------
DriversConfig& DriversConfig::operator=( const DriversConfig& _rhs )
{
if ( this != &_rhs )
{
m_aNode = _rhs.m_aNode;
}
return *this;
}
// -----------------------------------------------------------------------------
::rtl::OUString DriversConfig::getDriverFactoryName(const ::rtl::OUString& _sURL) const
{
const TInstalledDrivers& rDrivers = m_aNode->getInstalledDrivers(m_xORB);
::rtl::OUString sRet;
::rtl::OUString sOldPattern;
TInstalledDrivers::const_iterator aIter = rDrivers.begin();
TInstalledDrivers::const_iterator aEnd = rDrivers.end();
for(;aIter != aEnd;++aIter)
{
WildCard aWildCard(aIter->first);
if ( sOldPattern.getLength() < aIter->first.getLength() && aWildCard.Matches(_sURL) )
{
sRet = aIter->second.sDriverFactory;
sOldPattern = aIter->first;
}
}
return sRet;
}
// -----------------------------------------------------------------------------
::rtl::OUString DriversConfig::getDriverTypeDisplayName(const ::rtl::OUString& _sURL) const
{
const TInstalledDrivers& rDrivers = m_aNode->getInstalledDrivers(m_xORB);
::rtl::OUString sRet;
::rtl::OUString sOldPattern;
TInstalledDrivers::const_iterator aIter = rDrivers.begin();
TInstalledDrivers::const_iterator aEnd = rDrivers.end();
for(;aIter != aEnd;++aIter)
{
WildCard aWildCard(aIter->first);
if ( sOldPattern.getLength() < aIter->first.getLength() && aWildCard.Matches(_sURL) )
{
sRet = aIter->second.sDriverTypeDisplayName;
sOldPattern = aIter->first;
}
}
return sRet;
}
// -----------------------------------------------------------------------------
const ::comphelper::NamedValueCollection& DriversConfig::getProperties(const ::rtl::OUString& _sURL) const
{
return impl_get(_sURL,1);
}
// -----------------------------------------------------------------------------
const ::comphelper::NamedValueCollection& DriversConfig::getFeatures(const ::rtl::OUString& _sURL) const
{
return impl_get(_sURL,0);
}
// -----------------------------------------------------------------------------
const ::comphelper::NamedValueCollection& DriversConfig::getMetaData(const ::rtl::OUString& _sURL) const
{
return impl_get(_sURL,2);
}
// -----------------------------------------------------------------------------
const ::comphelper::NamedValueCollection& DriversConfig::impl_get(const ::rtl::OUString& _sURL,sal_Int32 _nProps) const
{
const TInstalledDrivers& rDrivers = m_aNode->getInstalledDrivers(m_xORB);
const ::comphelper::NamedValueCollection* pRet = NULL;
::rtl::OUString sOldPattern;
TInstalledDrivers::const_iterator aIter = rDrivers.begin();
TInstalledDrivers::const_iterator aEnd = rDrivers.end();
for(;aIter != aEnd;++aIter)
{
WildCard aWildCard(aIter->first);
if ( sOldPattern.getLength() < aIter->first.getLength() && aWildCard.Matches(_sURL) )
{
switch(_nProps)
{
case 0:
pRet = &aIter->second.aFeatures;
break;
case 1:
pRet = &aIter->second.aProperties;
break;
case 2:
pRet = &aIter->second.aMetaData;
break;
}
sOldPattern = aIter->first;
}
} // for(;aIter != aEnd;++aIter)
if ( pRet == NULL )
{
static const ::comphelper::NamedValueCollection s_sEmpty;
pRet = &s_sEmpty;
}
return *pRet;
}
// -----------------------------------------------------------------------------
uno::Sequence< ::rtl::OUString > DriversConfig::getURLs() const
{
const TInstalledDrivers& rDrivers = m_aNode->getInstalledDrivers(m_xORB);
uno::Sequence< ::rtl::OUString > aRet(rDrivers.size());
::rtl::OUString* pIter = aRet.getArray();
TInstalledDrivers::const_iterator aIter = rDrivers.begin();
TInstalledDrivers::const_iterator aEnd = rDrivers.end();
for(;aIter != aEnd;++aIter,++pIter)
{
*pIter = aIter->first;
}
return aRet;
}