7545436c5b
2008-12-08 10:12:55 +0100 cmc r264975 : #i96203# protect with ifdefs to avoid unused symbol on mac 2008-12-05 12:23:47 +0100 cmc r264898 : CWS-TOOLING: rebase CWS cmcfixes51 to trunk@264807 (milestone: DEV300:m37) 2008-12-01 14:45:17 +0100 cmc r264606 : #i76655# ehlos apparently required 2008-11-28 17:49:30 +0100 cmc r264567 : #i96655# remove newly unused method 2008-11-28 10:41:28 +0100 cmc r264531 : #i96647# better ppc-bridges flushCode impl 2008-11-27 12:58:40 +0100 cmc r264478 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:32:49 +0100 cmc r264476 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:26:02 +0100 cmc r264475 : #i96655# redundant old table export helpers 2008-11-27 11:49:06 +0100 cmc r264473 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:38:35 +0100 cmc r264471 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:14:21 +0100 cmc r264467 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:06:22 +0100 cmc r264464 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:58:18 +0100 cmc r264462 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:41:44 +0100 cmc r264461 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:19:24 +0100 cmc r264460 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:13:39 +0100 cmc r264459 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:06:14 +0100 cmc r264458 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:59:54 +0100 cmc r264457 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:52:51 +0100 cmc r264456 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:48:26 +0100 cmc r264454 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:40:20 +0100 cmc r264452 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:35:26 +0100 cmc r264451 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:31:00 +0100 cmc r264450 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:24:08 +0100 cmc r264449 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:26:15 +0100 cmc r264443 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:21:01 +0100 cmc r264442 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:09:40 +0100 cmc r264441 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:51:56 +0100 cmc r264440 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:49:09 +0100 cmc r264439 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:09:54 +0100 cmc r264432 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:07:40 +0100 cmc r264431 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:28:02 +0100 cmc r264429 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:27:39 +0100 cmc r264428 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:18:36 +0100 cmc r264426 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 16:22:16 +0100 cmc r264415 : #i96624# make implicit braces and brackets explicit to avoid warnings 2008-11-26 16:00:23 +0100 cmc r264409 : #i90426# remove warnings from svtools 2008-11-26 15:59:17 +0100 cmc r264408 : #i90426# remove warnings 2008-11-26 15:47:32 +0100 cmc r264404 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:46:57 +0100 cmc r264394 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:19:50 +0100 cmc r264387 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:15:26 +0100 cmc r264386 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:11:26 +0100 cmc r264384 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:44:23 +0100 cmc r264380 : #i96084# comfirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:12:24 +0100 cmc r264372 : #i96604# silence new warnings 2008-11-26 12:35:02 +0100 cmc r264369 : #i96203# make qstarter work in 3-layer land 2008-11-26 12:33:04 +0100 cmc r264368 : #i96170# ensure gtypes are up and running
360 lines
13 KiB
C++
360 lines
13 KiB
C++
/*************************************************************************
|
|
*
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
*
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
|
*
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
*
|
|
* $RCSfile: localdataimportsvc.cxx,v $
|
|
* $Revision: 1.9 $
|
|
*
|
|
* This file is part of OpenOffice.org.
|
|
*
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
* only, as published by the Free Software Foundation.
|
|
*
|
|
* OpenOffice.org 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 version 3 for more details
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
* <http://www.openoffice.org/license.html>
|
|
* for a copy of the LGPLv3 License.
|
|
*
|
|
************************************************************************/
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
#include "precompiled_configmgr.hxx"
|
|
|
|
#include "localdataimportsvc.hxx"
|
|
#include "localsinglebackend.hxx"
|
|
|
|
#ifndef CONFIGMGR_API_FACTORY_HXX_
|
|
#include "confapifactory.hxx"
|
|
#endif
|
|
#include <rtl/ustrbuf.hxx>
|
|
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
|
|
#include <com/sun/star/configuration/backend/XLayerImporter.hpp>
|
|
|
|
// -----------------------------------------------------------------------------
|
|
#define OUSTRING( constascii ) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(constascii))
|
|
// -----------------------------------------------------------------------------
|
|
namespace configmgr
|
|
{
|
|
// -----------------------------------------------------------------------------
|
|
namespace localbe
|
|
{
|
|
// -----------------------------------------------------------------------------
|
|
namespace backend = ::com::sun::star::configuration::backend;
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Char const * const aLocalDataImportServices[] =
|
|
{
|
|
"com.sun.star.configuration.backend.LocalDataImporter",
|
|
0,
|
|
"com.sun.star.configuration.backend.DataImporter",
|
|
0
|
|
};
|
|
const ServiceImplementationInfo aLocalDataImportSI =
|
|
{
|
|
"com.sun.star.comp.configuration.backend.LocalDataImporter",
|
|
aLocalDataImportServices,
|
|
aLocalDataImportServices + 3
|
|
};
|
|
// -----------------------------------------------------------------------------
|
|
|
|
const ServiceRegistrationInfo* getLocalDataImportServiceInfo()
|
|
{ return getRegistrationInfo(& aLocalDataImportSI); }
|
|
// -----------------------------------------------------------------------------
|
|
|
|
inline
|
|
ServiceInfoHelper LocalDataImportService::getServiceInfo()
|
|
{
|
|
return & aLocalDataImportSI;
|
|
}
|
|
// -----------------------------------------------------------------------------
|
|
|
|
uno::Reference< uno::XInterface > SAL_CALL instantiateLocalDataImporter
|
|
( uno::Reference< uno::XComponentContext > const& xContext )
|
|
{
|
|
return * new LocalDataImportService( xContext );
|
|
}
|
|
// -----------------------------------------------------------------------------
|
|
|
|
LocalDataImportService::LocalDataImportService(uno::Reference< uno::XComponentContext > const & _xContext)
|
|
: m_xServiceFactory(_xContext->getServiceManager(), uno::UNO_QUERY)
|
|
{
|
|
if (!m_xServiceFactory.is())
|
|
{
|
|
rtl::OUString sMessage = OUSTRING("Configuration Importer: Context has no service manager (or interface is missing)");
|
|
throw lang::NullPointerException(sMessage,NULL);
|
|
}
|
|
}
|
|
// -----------------------------------------------------------------------------
|
|
|
|
LocalDataImportService::~LocalDataImportService()
|
|
{}
|
|
// -----------------------------------------------------------------------------
|
|
|
|
namespace
|
|
{
|
|
// -----------------------------------------------------------------------------
|
|
struct JobDesc
|
|
{
|
|
explicit JobDesc(task::XJob * pJob, const uno::Sequence< beans::NamedValue >& aArguments);
|
|
|
|
rtl::OUString aLayerDataUrl;
|
|
rtl::OUString aImporterService;
|
|
|
|
rtl::OUString aComponent;
|
|
rtl::OUString aEntity;
|
|
|
|
uno::Reference< backend::XLayer > xLayerFilter;
|
|
|
|
sal_Bool overwrite;
|
|
sal_Bool truncate;
|
|
|
|
sal_Bool use_component;
|
|
sal_Bool use_entity;
|
|
sal_Bool use_overwrite;
|
|
sal_Bool use_truncate;
|
|
};
|
|
// -----------------------------------------------------------------------------
|
|
|
|
JobDesc::JobDesc(task::XJob * pJob, const uno::Sequence< beans::NamedValue >& aArguments)
|
|
: aLayerDataUrl()
|
|
, aImporterService()
|
|
, aComponent()
|
|
, aEntity()
|
|
, xLayerFilter()
|
|
, overwrite(true)
|
|
, truncate(false)
|
|
, use_component(false)
|
|
, use_entity(false)
|
|
, use_overwrite(false)
|
|
, use_truncate(false)
|
|
{
|
|
sal_Int16 const nCount = static_cast<sal_Int16>(aArguments.getLength());
|
|
|
|
if (sal_Int32(nCount) != aArguments.getLength())
|
|
{
|
|
rtl::OUString sMessage = OUSTRING("Too many arguments for LocalDataImporter Job");
|
|
throw lang::IllegalArgumentException(sMessage,pJob,0);
|
|
}
|
|
|
|
for (sal_Int16 i=0; i < nCount; ++i)
|
|
{
|
|
sal_Bool bKnown = false;
|
|
sal_Bool bGood = false;
|
|
|
|
if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("LayerDataUrl")))
|
|
{
|
|
bKnown = true;
|
|
bGood = (aArguments[i].Value >>= aLayerDataUrl);
|
|
}
|
|
else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ImporterService")))
|
|
{
|
|
bKnown = true;
|
|
bGood = (aArguments[i].Value >>= aImporterService);
|
|
}
|
|
else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Component")))
|
|
{
|
|
bKnown = true;
|
|
bGood = (aArguments[i].Value >>= aComponent);
|
|
use_component = bGood && (aComponent.getLength() != 0);
|
|
}
|
|
else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Entity")))
|
|
{
|
|
bKnown = true;
|
|
bGood = (aArguments[i].Value >>= aEntity);
|
|
use_entity = bGood && (aEntity.getLength() != 0);
|
|
}
|
|
else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("LayerFilter")))
|
|
{
|
|
bKnown = true;
|
|
bGood = (aArguments[i].Value >>= xLayerFilter);
|
|
if (xLayerFilter.is() && !uno::Reference<lang::XInitialization>::query(xLayerFilter).is())
|
|
bGood = false;
|
|
}
|
|
else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("OverwriteExisting")))
|
|
{
|
|
bKnown = true;
|
|
bGood = (aArguments[i].Value >>= overwrite);
|
|
use_overwrite = bGood;
|
|
}
|
|
else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TruncateExisting")))
|
|
{
|
|
bKnown = true;
|
|
bGood = (aArguments[i].Value >>= truncate);
|
|
use_truncate = bGood;
|
|
}
|
|
|
|
if (!bGood)
|
|
{
|
|
rtl::OUStringBuffer sMsg;
|
|
sMsg.appendAscii("LocalDataImportService - Illegal argument: ");
|
|
if (bKnown)
|
|
sMsg.appendAscii("Wrong value type for argument '");
|
|
else
|
|
sMsg.appendAscii("Unknown argument '");
|
|
|
|
sMsg.append(aArguments[i].Name).appendAscii("'.");
|
|
|
|
throw lang::IllegalArgumentException(sMsg.makeStringAndClear(),pJob,i+1);
|
|
}
|
|
}
|
|
if (aLayerDataUrl.getLength() == 0)
|
|
{
|
|
rtl::OUStringBuffer sMsg;
|
|
sMsg.appendAscii("LocalDataImportService - Missing argument: ");
|
|
sMsg.appendAscii("No data URL available");
|
|
throw lang::IllegalArgumentException(sMsg.makeStringAndClear(),pJob,0);
|
|
}
|
|
if (aImporterService.getLength() == 0)
|
|
{
|
|
if ( (use_truncate && truncate) || (use_overwrite && !overwrite) )
|
|
aImporterService = OUSTRING("com.sun.star.configuration.backend.CopyImporter");
|
|
else
|
|
aImporterService = OUSTRING("com.sun.star.configuration.backend.MergeImporter");
|
|
}
|
|
}
|
|
// -----------------------------------------------------------------------------
|
|
|
|
static
|
|
inline
|
|
uno::Type getOverwriteFailedExceptionType()
|
|
{
|
|
lang::IllegalAccessException const * const selected = 0;
|
|
return ::getCppuType(selected);
|
|
}
|
|
// -----------------------------------------------------------------------------
|
|
}
|
|
// -----------------------------------------------------------------------------
|
|
// XJob
|
|
|
|
uno::Any SAL_CALL
|
|
LocalDataImportService::execute( const uno::Sequence< beans::NamedValue >& Arguments )
|
|
throw (lang::IllegalArgumentException, uno::Exception, uno::RuntimeException)
|
|
{
|
|
JobDesc const aJob(this,Arguments);
|
|
|
|
uno::Reference< lang::XMultiServiceFactory > aFactory = this->getServiceFactory();
|
|
|
|
uno::Reference< backend::XLayer > xLayer = aJob.use_component ?
|
|
LocalSingleBackend::createSimpleLayer(aFactory,aJob.aLayerDataUrl, aJob.aComponent ):
|
|
LocalSingleBackend::createSimpleLayer(aFactory,aJob.aLayerDataUrl) ;
|
|
|
|
if (!xLayer.is())
|
|
{
|
|
rtl::OUString sMessage = OUSTRING("LocalDataImportService - Cannot create layer to import from");
|
|
throw lang::NullPointerException(sMessage,*this);
|
|
}
|
|
|
|
uno::Reference< lang::XInitialization > xFilterInit(aJob.xLayerFilter,uno::UNO_QUERY);
|
|
if (xFilterInit.is())
|
|
{
|
|
beans::NamedValue argvalue(
|
|
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Source") ),
|
|
uno::makeAny( xLayer) );
|
|
|
|
uno::Sequence< uno::Any > args(1);
|
|
args[0] <<= argvalue;
|
|
|
|
xFilterInit->initialize(args);
|
|
|
|
xLayer = aJob.xLayerFilter;
|
|
}
|
|
|
|
uno::Reference< backend::XLayerImporter > xImporter;
|
|
|
|
int nArgCount = 0;
|
|
if (aJob.use_overwrite) ++nArgCount;
|
|
if (aJob.use_truncate) ++nArgCount;
|
|
|
|
if (nArgCount)
|
|
{
|
|
uno::Sequence< uno::Any > aArgs(nArgCount);
|
|
|
|
int n = 0;
|
|
if (aJob.use_overwrite)
|
|
aArgs[n++] <<= beans::NamedValue(OUSTRING("Overwrite"), uno::makeAny(aJob.overwrite));
|
|
|
|
if (aJob.use_truncate)
|
|
aArgs[n++] <<= beans::NamedValue(OUSTRING("Truncate"), uno::makeAny(aJob.truncate));
|
|
|
|
OSL_ASSERT(n == nArgCount);
|
|
|
|
xImporter.set( aFactory->createInstanceWithArguments(aJob.aImporterService,aArgs), uno::UNO_QUERY);
|
|
}
|
|
else
|
|
xImporter.set( aFactory->createInstance(aJob.aImporterService), uno::UNO_QUERY);
|
|
|
|
if (!xImporter.is())
|
|
{
|
|
rtl::OUString sMessage = OUSTRING("LocalDataImportService - Cannot create importer service: ") + aJob.aImporterService;
|
|
throw lang::NullPointerException(sMessage,*this);
|
|
}
|
|
|
|
try
|
|
{
|
|
if (aJob.use_entity)
|
|
xImporter->importLayerForEntity(xLayer,aJob.aEntity);
|
|
|
|
else
|
|
xImporter->importLayer(xLayer);
|
|
}
|
|
catch (lang::WrappedTargetException & e)
|
|
{
|
|
if (aJob.overwrite || !e.TargetException.isExtractableTo(getOverwriteFailedExceptionType())) throw;
|
|
return e.TargetException;
|
|
}
|
|
catch (lang::WrappedTargetRuntimeException & e)
|
|
{
|
|
if (aJob.overwrite || !e.TargetException.isExtractableTo(getOverwriteFailedExceptionType())) throw;
|
|
return e.TargetException;
|
|
}
|
|
|
|
return uno::Any();
|
|
}
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XServiceInfo
|
|
|
|
rtl::OUString SAL_CALL
|
|
LocalDataImportService::getImplementationName( )
|
|
throw (uno::RuntimeException)
|
|
{
|
|
return getServiceInfo().getImplementationName( );
|
|
}
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
sal_Bool SAL_CALL
|
|
LocalDataImportService::supportsService( const rtl::OUString& ServiceName )
|
|
throw (uno::RuntimeException)
|
|
{
|
|
return getServiceInfo().supportsService( ServiceName );
|
|
}
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
uno::Sequence< ::rtl::OUString > SAL_CALL
|
|
LocalDataImportService::getSupportedServiceNames( )
|
|
throw (uno::RuntimeException)
|
|
{
|
|
return getServiceInfo().getSupportedServiceNames( );
|
|
}
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// -----------------------------------------------------------------------------
|
|
} // namespace
|
|
|
|
// -----------------------------------------------------------------------------
|
|
} // namespace
|
|
|