merged in re/DEV300_next towards DEV300_m74

This commit is contained in:
sb
2010-03-04 23:05:27 +01:00
621 changed files with 22500 additions and 112149 deletions
-35
View File
@@ -191,41 +191,6 @@ BOOL IsTTSignatureForUnicodeTextfile( String aLine )
BasicApp aBasicApp; // Application instance
static const char * const components[] =
{
SAL_MODULENAME( "ucb1" ) // KSO, ABI
, SAL_MODULENAME( "ucpfile1" )
, "configmgr2.uno" SAL_DLLEXTENSION
, "sax.uno" SAL_DLLEXTENSION
, "stocservices.uno" SAL_DLLEXTENSION
, SAL_MODULENAME( "fileacc" )
, SAL_MODULENAME( "mcnttype" ) // Clipboard Ask Oliver Braun
, "i18npool.uno" SAL_DLLEXTENSION
// Reading of files in specific encodings like UTF-8 using
// createUnoService( "com.sun.star.io.TextInputStream" ) and such
, "textinstream.uno" SAL_DLLEXTENSION
, "textoutstream.uno" SAL_DLLEXTENSION
, "introspection.uno" SAL_DLLEXTENSION
, "reflection.uno" SAL_DLLEXTENSION
// RemoteUno
, "connector.uno" SAL_DLLEXTENSION
, "bridgefac.uno" SAL_DLLEXTENSION
, "remotebridge.uno" SAL_DLLEXTENSION
#ifdef SAL_UNX
#ifdef QUARTZ
, SVLIBRARY( "dtransaqua" ) // Mac OS X Aqua uses a dedicated libdtransaqua
#else
, SVLIBRARY( "dtransX11" ) // OBR
#endif
#endif
#ifdef SAL_W32
, SAL_MODULENAME( "sysdtrans" )
, SAL_MODULENAME( "ftransl" )
, SAL_MODULENAME( "dnd" )
#endif
, 0
};
uno::Reference< XContentProviderManager > InitializeUCB( void )
{
uno::Reference< XMultiServiceFactory > xSMgr;
+23 -23
View File
@@ -1,28 +1,28 @@
#*************************************************************************
#
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# 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.
#
#*************************************************************************
# Anmerkungen
@@ -0,0 +1,41 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef INCLUDED_CONFIGMGR_DETAIL_CONFIGMGRDLLAPI_HXX
#define INCLUDED_CONFIGMGR_DETAIL_CONFIGMGRDLLAPI_HXX
#include "sal/config.h"
#include "sal/types.h"
#if defined OOO_DLLIMPLEMENTATION_CONFIGMGR
#define OOO_DLLPUBLIC_CONFIGMGR SAL_DLLPUBLIC_EXPORT
#else
#define OOO_DLLPUBLIC_CONFIGMGR SAL_DLLPUBLIC_IMPORT
#endif
#endif
+51
View File
@@ -0,0 +1,51 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef INCLUDED_CONFIGMGR_UPDATE_HXX
#define INCLUDED_CONFIGMGR_UPDATE_HXX
#include "sal/config.h"
#include "configmgr/detail/configmgrdllapi.hxx"
namespace rtl { class OUString; }
namespace configmgr {
namespace update {
OOO_DLLPUBLIC_CONFIGMGR void insertExtensionXcsFile(
bool shared, rtl::OUString const & fileUri);
OOO_DLLPUBLIC_CONFIGMGR void insertExtensionXcuFile(
bool shared, rtl::OUString const & fileUri);
}
}
#endif
+12 -22
View File
@@ -1,7 +1,6 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
@@ -22,27 +21,18 @@
# version 3 along with OpenOffice.org. If not, see
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
#*************************************************************************
PRJ=..
#***********************************************************************/
PRJNAME=configmgr
TARGET=inc
PRJ = ..
PRJNAME = configmgr
TARGET = inc
# --- Settings -----------------------------------------------------
ENABLE_EXCEPTIONS = TRUE
VISIBILITY_HIDDEN = TRUE
.INCLUDE : settings.mk
.INCLUDE : $(PRJ)$/makefile.pmk
# --- Files --------------------------------------------------------
# --- Targets -------------------------------------------------------
.INCLUDE : target.mk
.IF "$(ENABLE_PCH)"!=""
ALLTAR : \
$(SLO)$/precompiled.pch \
$(SLO)$/precompiled_ex.pch
.ENDIF # "$(ENABLE_PCH)"!=""
.INCLUDE: settings.mk
.INCLUDE: target.mk
.IF "$(ENABLE_PCH)" != ""
ALLTAR: $(SLO)/precompiled.pch $(SLO)/precompiled_ex.pch
.ENDIF
+25 -26
View File
@@ -1,29 +1,28 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#include "precompiled_configmgr.hxx"
+26 -239
View File
@@ -1,245 +1,32 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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): Generated on 2006-09-01 17:49:35.077252
#if defined PRECOMPILED_HEADERS
#ifdef PRECOMPILED_HEADERS
//---MARKER---
#include "sal/config.h"
#include "sal/types.h"
#include "com/sun/star/beans/IllegalTypeException.hpp"
#include "com/sun/star/beans/NamedValue.hpp"
#include "com/sun/star/beans/Property.hpp"
#include "com/sun/star/beans/PropertyAttribute.hpp"
#include "com/sun/star/beans/PropertyExistException.hpp"
#include "com/sun/star/beans/PropertyValue.hpp"
#include "com/sun/star/beans/PropertyVetoException.hpp"
#include "com/sun/star/beans/UnknownPropertyException.hpp"
#include "com/sun/star/beans/XExactName.hpp"
#include "com/sun/star/beans/XHierarchicalPropertySet.hpp"
#include "com/sun/star/beans/XMultiHierarchicalPropertySet.hpp"
#include "com/sun/star/beans/XMultiPropertySet.hpp"
#include "com/sun/star/beans/XMultiPropertyStates.hpp"
#include "com/sun/star/beans/XPropertiesChangeListener.hpp"
#include "com/sun/star/beans/XProperty.hpp"
#include "com/sun/star/beans/XPropertyChangeListener.hpp"
#include "com/sun/star/beans/XPropertySet.hpp"
#include "com/sun/star/beans/XPropertySetInfo.hpp"
#include "com/sun/star/beans/XPropertyState.hpp"
#include "com/sun/star/beans/XPropertyWithState.hpp"
#include "com/sun/star/beans/XVetoableChangeListener.hpp"
#include "com/sun/star/configuration/CannotLoadConfigurationException.hpp"
#include "com/sun/star/configuration/InstallationIncompleteException.hpp"
#include "com/sun/star/configuration/InvalidBootstrapFileException.hpp"
#include "com/sun/star/configuration/MissingBootstrapFileException.hpp"
#include "com/sun/star/configuration/XTemplateContainer.hpp"
#include "com/sun/star/configuration/XTemplateInstance.hpp"
#include "com/sun/star/configuration/backend/AuthenticationFailedException.hpp"
#include "com/sun/star/configuration/backend/BackendAccessException.hpp"
#include "com/sun/star/configuration/backend/BackendSetupException.hpp"
#include "com/sun/star/configuration/backend/CannotConnectException.hpp"
#include "com/sun/star/configuration/backend/ComponentChangeEvent.hpp"
#include "com/sun/star/configuration/backend/ConnectionLostException.hpp"
#include "com/sun/star/configuration/backend/InsufficientAccessRightsException.hpp"
#include "com/sun/star/configuration/backend/InvalidAuthenticationMechanismException.hpp"
#include "com/sun/star/configuration/backend/MalformedDataException.hpp"
#include "com/sun/star/configuration/backend/MergeRecoveryRequest.hpp"
#include "com/sun/star/configuration/backend/NodeAttribute.hpp"
#include "com/sun/star/configuration/backend/PropertyInfo.hpp"
#include "com/sun/star/configuration/backend/SchemaAttribute.hpp"
#include "com/sun/star/configuration/backend/StratumCreationException.hpp"
#include "com/sun/star/configuration/backend/TemplateIdentifier.hpp"
#include "com/sun/star/configuration/backend/XBackend.hpp"
#include "com/sun/star/configuration/backend/XBackendChangesListener.hpp"
#include "com/sun/star/configuration/backend/XBackendChangesNotifier.hpp"
#include "com/sun/star/configuration/backend/XBackendEntities.hpp"
#include "com/sun/star/configuration/backend/XCompositeLayer.hpp"
#include "com/sun/star/configuration/backend/XLayer.hpp"
#include "com/sun/star/configuration/backend/XLayerContentDescriber.hpp"
#include "com/sun/star/configuration/backend/XLayerHandler.hpp"
#include "com/sun/star/configuration/backend/XLayerImporter.hpp"
#include "com/sun/star/configuration/backend/XMultiLayerStratum.hpp"
#include "com/sun/star/configuration/backend/XSchema.hpp"
#include "com/sun/star/configuration/backend/XSchemaHandler.hpp"
#include "com/sun/star/configuration/backend/XSchemaSupplier.hpp"
#include "com/sun/star/configuration/backend/XSingleLayerStratum.hpp"
#include "com/sun/star/configuration/backend/XUpdatableLayer.hpp"
#include "com/sun/star/configuration/backend/XUpdateHandler.hpp"
#include "com/sun/star/configuration/backend/XVersionedSchemaSupplier.hpp"
#include "com/sun/star/container/ElementExistException.hpp"
#include "com/sun/star/container/NoSuchElementException.hpp"
#include "com/sun/star/container/XChild.hpp"
#include "com/sun/star/container/XContainer.hpp"
#include "com/sun/star/container/XContainerListener.hpp"
#include "com/sun/star/container/XContentEnumerationAccess.hpp"
#include "com/sun/star/container/XEnumeration.hpp"
#include "com/sun/star/container/XHierarchicalName.hpp"
#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
#include "com/sun/star/container/XNameAccess.hpp"
#include "com/sun/star/container/XNameContainer.hpp"
#include "com/sun/star/container/XNameReplace.hpp"
#include "com/sun/star/container/XNamed.hpp"
#include "com/sun/star/io/BufferSizeExceededException.hpp"
#include "com/sun/star/io/IOException.hpp"
#include "com/sun/star/io/UnexpectedEOFException.hpp"
#include "com/sun/star/io/WrongFormatException.hpp"
#include "com/sun/star/io/XActiveDataControl.hpp"
#include "com/sun/star/io/XActiveDataSink.hpp"
#include "com/sun/star/io/XActiveDataSource.hpp"
#include "com/sun/star/io/XDataExporter.hpp"
#include "com/sun/star/io/XDataImporter.hpp"
#include "com/sun/star/io/XDataInputStream.hpp"
#include "com/sun/star/io/XDataOutputStream.hpp"
#include "com/sun/star/io/XDataTransferEventListener.hpp"
#include "com/sun/star/io/XInputStream.hpp"
#include "com/sun/star/io/XOutputStream.hpp"
#include "com/sun/star/lang/DisposedException.hpp"
#include "com/sun/star/lang/IllegalAccessException.hpp"
#include "com/sun/star/lang/IllegalArgumentException.hpp"
#include "com/sun/star/lang/Locale.hpp"
#include "com/sun/star/lang/NoSupportException.hpp"
#include "com/sun/star/lang/NullPointerException.hpp"
#include "com/sun/star/lang/ServiceNotRegisteredException.hpp"
#include "com/sun/star/lang/WrappedTargetException.hpp"
#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
#include "com/sun/star/lang/XComponent.hpp"
#include "com/sun/star/lang/XEventListener.hpp"
#include "com/sun/star/lang/XInitialization.hpp"
#include "com/sun/star/lang/XLocalizable.hpp"
#include "com/sun/star/lang/XMultiServiceFactory.hpp"
#include "com/sun/star/lang/XServiceInfo.hpp"
#include "com/sun/star/lang/XSingleComponentFactory.hpp"
#include "com/sun/star/lang/XSingleServiceFactory.hpp"
#include "com/sun/star/lang/XTypeProvider.hpp"
#include "com/sun/star/lang/XUnoTunnel.hpp"
#include "com/sun/star/registry/XRegistryKey.hpp"
#include "com/sun/star/registry/XSimpleRegistry.hpp"
#include "com/sun/star/script/FailReason.hpp"
#include "com/sun/star/script/XTypeConverter.hpp"
#include "com/sun/star/task/XInteractionAbort.hpp"
#include "com/sun/star/task/XInteractionApprove.hpp"
#include "com/sun/star/task/XInteractionDisapprove.hpp"
#include "com/sun/star/task/XInteractionHandler.hpp"
#include "com/sun/star/task/XInteractionRequest.hpp"
#include "com/sun/star/task/XInteractionRetry.hpp"
#include "com/sun/star/task/XJob.hpp"
#include "com/sun/star/uno/Any.h"
#include "com/sun/star/uno/Any.hxx"
#include "com/sun/star/uno/Exception.hpp"
#include "com/sun/star/uno/Reference.h"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.h"
#include "com/sun/star/uno/Sequence.hxx"
#include "com/sun/star/uno/Type.hxx"
#include "com/sun/star/uno/TypeClass.hpp"
#include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/uno/XCurrentContext.hpp"
#include "com/sun/star/uno/XInterface.hpp"
#include "com/sun/star/util/XChangesBatch.hpp"
#include "com/sun/star/util/XChangesListener.hpp"
#include "com/sun/star/util/XChangesNotifier.hpp"
#include "com/sun/star/util/XFlushable.hpp"
#include "com/sun/star/util/XRefreshable.hpp"
#include "com/sun/star/util/XStringEscape.hpp"
#include "com/sun/star/util/XTimeStamped.hpp"
#include "com/sun/star/util/logging/LogLevel.hpp"
#include "com/sun/star/util/logging/XLogger.hpp"
#include "com/sun/star/xml/sax/InputSource.hpp"
#include "com/sun/star/xml/sax/SAXException.hpp"
#include "com/sun/star/xml/sax/SAXParseException.hpp"
#include "com/sun/star/xml/sax/XAttributeList.hpp"
#include "com/sun/star/xml/sax/XDocumentHandler.hpp"
#include "com/sun/star/xml/sax/XExtendedDocumentHandler.hpp"
#include "com/sun/star/xml/sax/XParser.hpp"
#include "comphelper/processfactory.hxx"
#include "comphelper/propertycontainer.hxx"
#include "comphelper/sequence.hxx"
#include "comphelper/stl_types.hxx"
#include "cppuhelper/bootstrap.hxx"
#include "cppuhelper/component_context.hxx"
#include "cppuhelper/exc_hlp.hxx"
#include "cppuhelper/factory.hxx"
#include "cppuhelper/implementationentry.hxx"
#include "cppuhelper/interfacecontainer.hxx"
#include "cppuhelper/propshlp.hxx"
#include "cppuhelper/queryinterface.hxx"
#include "cppuhelper/servicefactory.hxx"
#include "cppuhelper/typeprovider.hxx"
#include "cppuhelper/weak.hxx"
#include "osl/conditn.hxx"
#include "osl/diagnose.h"
#include "osl/file.h"
#include "osl/file.hxx"
#include "osl/interlck.h"
#include "osl/module.hxx"
#include "osl/mutex.hxx"
#include "osl/process.h"
#include "osl/thread.h"
#include "osl/time.h"
#include "rtl/alloc.h"
#include "rtl/bootstrap.h"
#include "rtl/bootstrap.hxx"
#include "rtl/logfile.hxx"
#include "rtl/process.h"
#include "rtl/ref.hxx"
#include "rtl/strbuf.hxx"
#include "rtl/string.h"
#include "rtl/string.hxx"
#include "rtl/ustrbuf.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/main.h"
#include "salhelper/simplereferenceobject.hxx"
#include "sys/timeb.h"
#include "typelib/typedescription.hxx"
#include "uno/any2.h"
#include "uno/current_context.hxx"
#include "vos/conditn.hxx"
#include "vos/pipe.hxx"
#include "vos/ref.hxx"
#include "vos/refernce.hxx"
#include "vos/socket.hxx"
#include "vos/thread.hxx"
#include "vos/timer.hxx"
//---MARKER---
#endif
+3 -17
View File
@@ -1,18 +1,4 @@
cg configmgr : BOOST:boost offapi comphelper cppuhelper salhelper tools vos NULL
cg configmgr usr1 - all cg_mkout NULL
cg configmgr\inc nmake - all cg_inc NULL
cg configmgr\source\misc nmake - all cg_misc cg_inc NULL
cg configmgr\source\data nmake - all cg_data cg_inc NULL
cg configmgr\source\tree nmake - all cg_tree cg_inc NULL
cg configmgr\source\treecache nmake - all cg_trcache cg_inc NULL
cg configmgr\source\xml nmake - all cg_xml cg_inc NULL
cg configmgr\source\backend nmake - all cg_backend cg_inc NULL
cg configmgr\source\backendhelper nmake - all cg_backendhelper cg_inc NULL
cg configmgr\source\api nmake - all cg_api cg_inc NULL
cg configmgr\source\api2 nmake - all cg_api2 cg_inc NULL
cg configmgr\source\treemgr nmake - all cg_treemgr cg_inc NULL
cg configmgr\source\registry nmake - all cg_reg cg_inc NULL
cg configmgr\source\platformbe nmake - all cg_platformbe cg_inc NULL
cg configmgr\util nmake - all cg_util cg_platformbe cg_api cg_api2 cg_misc cg_reg cg_trcache cg_data cg_tree cg_treemgr cg_xml cg_backend cg_localbe NULL
cg configmgr\source\localbe nmake - all cg_localbe cg_inc NULL
cg configmgr : BOOST:boost comphelper cppu cppuhelper offuh sal salhelper stlport NULL
cg configmgr\inc nmake - all cg_inc NULL
cg configmgr\source nmake - all cg_source cg_inc NULL
cg configmgr\qa\unoapi nmake - all cg_qa_unoapi NULL
+7 -9
View File
@@ -1,10 +1,8 @@
mkdir: %_DEST%\inc%_EXT%\configmgr
..\%__SRC%\lib\behelper.uno.so %_DEST%\lib%_EXT%\behelper.uno.so
..\%__SRC%\lib\configmgr*.uno.so %_DEST%\lib%_EXT%\configmgr*.uno.so
..\%__SRC%\lib\sysmgr*.uno.so %_DEST%\lib%_EXT%\sysmgr*.uno.so
..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
..\%__SRC%\bin\behelper*.dll %_DEST%\bin%_EXT%\behelper*.dll
..\%__SRC%\bin\configmg*.dll %_DEST%\bin%_EXT%\configmg*.dll
..\%__SRC%\bin\sysmgr*.dll %_DEST%\bin%_EXT%\sysmgr*.dll
..\%__SRC%\misc\configmgr2.uno.xml %_DEST%\xml%_EXT%\configmgr2.uno.xml
mkdir: %_DEST%\inc%_EXT%\configmgr\detail
..\%__SRC%\bin\configmgr.dll %_DEST%\bin%_EXT%\configmgr.dll
..\%__SRC%\lib\iconfigmgr.lib %_DEST%\lib%_EXT%\iconfigmgr.lib
..\%__SRC%\lib\libconfigmgr.dylib %_DEST%\lib%_EXT%\libconfigmgr.dylib
..\%__SRC%\lib\libconfigmgr.so %_DEST%\lib%_EXT%\libconfigmgr.so
..\inc\configmgr\detail\configmgrdllapi.hxx %_DEST%\inc%_EXT%\configmgr\detail\configmgrdllapi.hxx
..\inc\configmgr\update.hxx %_DEST%\inc%_EXT%\configmgr\update.hxx
-111
View File
@@ -1,111 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#include "sal/config.h"
#include <cstdlib>
#include "com/sun/star/beans/NamedValue.hpp"
#include "com/sun/star/beans/XPropertySet.hpp"
#include "com/sun/star/beans/XPropertyState.hpp"
#include "com/sun/star/lang/XComponent.hpp"
#include "com/sun/star/lang/XMultiComponentFactory.hpp"
#include "com/sun/star/lang/XMultiServiceFactory.hpp"
#include "com/sun/star/container/XNameReplace.hpp"
#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
#include "com/sun/star/util/XChangesBatch.hpp"
#include "com/sun/star/uno/Any.hxx"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/XComponentContext.hpp"
#include "cppuhelper/component_context.hxx"
#include "cppuhelper/servicefactory.hxx"
#include "testshl/simpleheader.hxx"
#include "osl/file.hxx"
#include "osl/thread.h"
#include "osl/process.h"
#include "rtl/string.h"
#include "rtl/bootstrap.h"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
namespace css = com::sun::star;
#define CATCH_FAIL(msg) \
catch (const css::uno::Exception &e) { \
t_print ("msg '%s'\n", rtl::OUStringToOString (e.Message, RTL_TEXTENCODING_UTF8).getStr()); \
CPPUNIT_FAIL( msg ); \
throw; \
}
class Magic
{
rtl::OUString maTempDir;
public:
Magic();
~Magic();
};
class Test: public CppUnit::TestFixture {
Magic *mpMagic;
public:
// init
virtual void setUp();
virtual void tearDown();
// helpers
void normalizePathKey (rtl::OString &rPath, rtl::OString &rKey);
css::uno::Reference< css::uno::XInterface > createView(const sal_Char *pNodepath, bool bUpdate);
css::uno::Any getKey (const sal_Char *pPath, rtl::OUString aName);
css::uno::Any getKey (const sal_Char *pPath, const sal_Char *pName)
{ return getKey (pPath, rtl::OUString::createFromAscii (pName)); }
void setKey (const sal_Char *pPath, rtl::OUString aName, css::uno::Any a);
void resetKey (const sal_Char *pPath, rtl::OUString aName);
// tests
void keyFetch();
void keySet();
void keyReset();
void readCommands();
void threadTests();
void recursiveTests();
void eventTests();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(keyFetch);
CPPUNIT_TEST(keySet);
CPPUNIT_TEST(keyReset);
CPPUNIT_TEST(readCommands);
CPPUNIT_TEST(threadTests);
CPPUNIT_TEST(recursiveTests);
CPPUNIT_TEST(eventTests);
CPPUNIT_TEST_SUITE_END();
private:
css::uno::Reference< css::uno::XComponentContext > mxContext;
css::uno::Reference< css::lang::XMultiServiceFactory > mxProvider;
};
void disposeComponent (const css::uno::Reference<css::uno::XInterface> &xComp);
-22
View File
@@ -1,22 +0,0 @@
[Bootstrap]
CFG_ServerType=uno
BootstrapFile=$ORIGIN/bootstraprc
VersionFile=$ORIGIN/versionrc
UnoFile=$ORIGIN/unorc
BaseInstallation=${$BootstrapFile:BaseInstallation}
UserInstallation=${$BootstrapFile:UserInstallation}
CFG_SchemaVersion=${$VersionFile:buildid}
CFG_SchemaDataUrl=$BaseInstallation/schema
CFG_DefaultLayerUrls=$BaseInstallation
CFG_CacheDisposeDelay=900
CFG_CacheDisposeInterval=60
CFG_CacheWriteInterval=2
CFG_UserLayerUrl=$UserInstallation
CFG_CacheUrl=$BaseInstallation/cache
CFG_DefaultLayerUrl=$BaseInstallation
CFG_BackendService=com.sun.star.comp.configuration.backend.MultiStratumBackend
CFG_SchemaSupplier=com.sun.star.comp.configuration.backend.LocalSchemaSupplier
CFG_LocalDataSvc=com.sun.star.comp.configuration.backend.LocalStratum
CFG_LocalModuleDataSvc=com.sun.star.comp.configuration.backend.LocalMultiStratum
# CFG_Strata=${CFG_LocalDataSvc}:$CFG_DefaultLayerUrl;?com.sun.star.comp.configuration.backend.SystemIntegration:;${CFG_LocalDataSvc}:$CFG_UserLayerUrl
CFG_Strata=${CFG_LocalDataSvc}:$CFG_DefaultLayerUrl;${CFG_LocalDataSvc}:$CFG_UserLayerUrl
@@ -1,31 +1,150 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--***********************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************ -->
<!DOCTYPE oor:component-data SYSTEM "../../../../../component-update.dtd">
<!--**********************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
**********************************************************************-->
<oor:data xmlns:oor="http://openoffice.org/2001/registry">
<oor:component-schema xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="Setup" oor:package="org.openoffice" xml:lang="en-US">
<info>
<author>mmeeks</author>
<desc >Setup prefs (for configmgr) and unit test schema bits.</desc>
</info>
<component>
<group oor:name="L10N">
<info>
<author>PB</author>
<desc>Specifies the installation locales.</desc>
</info>
<prop oor:name="ooLocale" oor:type="xs:string">
<info>
<author>PB</author>
<desc>Indicates the Office language selected by the user.</desc>
<label>Locale</label>
</info>
<value/>
</prop>
</group>
<group oor:name="Test">
<info>
<author>mmeeks</author>
<desc>Misc test pieces</desc>
</info>
<prop oor:name="ABoolean" oor:type="xs:boolean">
<info>
<author>mmeeks</author>
<desc>A boolean</desc>
<label>Boolean</label>
</info>
<value>false</value>
</prop>
<prop oor:name="AString" oor:type="xs:string">
<info>
<author>mmeeks</author>
<desc>A string</desc>
<label>String</label>
</info>
<value>Foo</value>
</prop>
</group>
</component>
</oor:component-schema>
<oor:component-schema xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="Commands" oor:package="org.openoffice.UI" xml:lang="en-US"> <info>
<author>CD</author>
<desc >Contains general information about ~ and rules, and about actions based on office commands.</desc>
</info>
<templates>
<group oor:name="LabelType">
<info>
<desc>Provides a mapping between commands and their textual representation on the user interface.</desc>
</info>
<prop oor:name="Label" oor:type="xs:string" oor:localized="true">
<info>
<desc>A localized text that describes the command or identifier. Can be used as a label inside a menu or as short tool tip help.</desc>
</info>
</prop>
<prop oor:name="ContextLabel" oor:type="xs:string" oor:localized="true">
<info>
<desc>A localized text that describes the identifier of a command in a structured menu. </desc>
</info>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<info>
<desc>
Additional information about a single command.
Bit 0 = Command has an image.
Bit 1 = Image must be mirrored (CTL/vertical text).
Bit 2 = Image must be rotated (CTL/vertical text).
</desc>
</info>
<value>0</value>
</prop>
</group>
</templates>
<component/>
</oor:component-schema>
<oor:component-schema xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="GenericCommands" oor:package="org.openoffice.UI" xml:lang="en-US">
<info>
<author>CD</author>
<desc >Contains general information about ~ and rules, and about actions based on office commands.</desc>
</info>
<import oor:component="org.openoffice.UI.Commands"/>
<uses oor:component="org.openoffice.UI.Commands"/>
<templates/>
<component>
<group oor:name="UserInterface">
<info>
<desc>Contains user interface data for Office commands and identifiers that are used by the user interface."</desc>
</info>
<set oor:name="Commands" oor:node-type="LabelType" oor:component="org.openoffice.UI.Commands">
<info>
<desc>Contains label text for Office commands and identifiers that are used by the user interface."</desc>
</info>
</set>
</group>
</component>
</oor:component-schema>
<oor:component-data oor:name="Setup" oor:package="org.openoffice" xmlns:oor="http://openoffice.org/2001/registry" xmlns:install="http://openoffice.org/2004/installation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<node oor:name="L10N">
<prop oor:name="ooLocale" oor:type="xs:string">
<value>en-US</value>
</prop>
</node>
<node oor:name="Test">
<prop oor:name="ABoolean" oor:type="xs:boolean">
<value>true</value>
</prop>
<prop oor:name="AString" oor:type="xs:string">
<value>Foo</value>
</prop>
</node>
</oor:component-data>
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="GenericCommands" oor:package="org.openoffice.UI">
<node oor:name="UserInterface">
<node oor:name="Commands">
@@ -5067,3 +5186,5 @@
</node>
</node>
</oor:component-data>
</oor:data>
@@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--***********************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************ -->
<!DOCTYPE oor:component-data SYSTEM "../../../component-update.dtd">
<oor:component-data oor:name="Setup" oor:package="org.openoffice" xmlns:oor="http://openoffice.org/2001/registry" xmlns:install="http://openoffice.org/2004/installation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<node oor:name="L10N">
<prop oor:name="ooLocale" oor:type="xs:string">
<value>en-US</value>
</prop>
</node>
<node oor:name="Test">
<prop oor:name="ABoolean" oor:type="xs:boolean">
<value>true</value>
</prop>
<prop oor:name="AString" oor:type="xs:string">
<value>Foo</value>
</prop>
</node>
</oor:component-data>
-7
View File
@@ -1,7 +0,0 @@
UDK_3_0_0 {
global:
registerAllTestFunction;
local:
*;
};
+55 -23
View File
@@ -1,7 +1,7 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
@@ -23,39 +23,71 @@
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
#*************************************************************************
#***********************************************************************/
PRJ := ..$/..
PRJNAME := configmgr
TARGET := qa_unit
PRJ = ../..
PRJNAME = configmgr
TARGET = unit
ENABLE_EXCEPTIONS := TRUE
ENABLE_EXCEPTIONS = TRUE
.INCLUDE: settings.mk
CFLAGSCXX += $(CPPUNIT_CFLAGS)
DLLPRE = # no leading "lib" on .so files
SLOFILES = $(SLO)/test.obj
SHL1TARGET = $(TARGET)
SHL1OBJS = $(SLO)$/performance.obj $(SLO)$/threading.obj $(SLO)$/ubootstrap.obj
SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(CPPUNITLIB) $(TESTSHL2LIB) $(SALLIB)
SHL1VERSIONMAP = export.map
SHL1IMPLIB = i$(SHL1TARGET)
SHL1OBJS = $(SLOFILES)
SHL1STDLIBS = \
$(CPPUHELPERLIB) \
$(CPPULIB) \
$(CPPUNITLIB) \
$(SALLIB) \
$(TESTSHL2LIB)
SHL1TARGET = unit
SHL1VERSIONMAP = version.map
DEF1NAME = $(SHL1TARGET)
SLOFILES = $(SHL1OBJS)
.INCLUDE: target.mk
ALLTAR: test
ALLTAR: TEST
$(MISC)$/$(TARGET).rdb .ERRREMOVE:
$(COPY) $(SOLARBINDIR)$/types.rdb $@
$(REGCOMP) -register -r $@ -c $(subst,$/,/ $(DLLDEST)$/configmgr2.uno$(DLLPOST))
$(REGCOMP) -register -r $@ -c $(subst,$/,/ $(SOLARLIBDIR)/sax.uno$(DLLPOST))
$(REGCOMP) -register -r $@ -c $(subst,$/,/ $(SOLARLIBDIR)/stocservices.uno$(DLLPOST))
$(REGCOMP) -register -r $@ -c $(subst,$/,/ $(SOLARLIBDIR)/streams.uno$(DLLPOST))
.IF "$(OS)" == "OS2" || "$(OS)" == "WNT"
MY_INI = .ini
.ELSE
MY_INI = rc
.ENDIF
test .PHONY: $(SHL1TARGETN) $(MISC)$/$(TARGET).rdb
$(AUGMENT_LIBRARY_PATH) testshl2 $(SHL1TARGETN) -forward "$(MISC)$/$(TARGET).rdb#$(PWD)$/$(MISC)$/$(TARGET).registry"
$(MISC)/unit.rdb .ERRREMOVE:
cp $(SOLARBINDIR)/types.rdb $@
$(REGCOMP) -register -r $@ -c $(DLLDEST)/$(DLLPRE)configmgr$(DLLPOST)
TEST .PHONY: $(SHL1TARGETN) $(MISC)/unit.rdb
rm -rf $(MISC)/unitdata
mkdir $(MISC)/unitdata
cp urebootstrap.ini $(MISC)/unitdata
mkdir $(MISC)/unitdata/basis
mkdir $(MISC)/unitdata/basis/program
echo '[Bootstrap]' > $(MISC)/unitdata/basis/program/uno$(MY_INI)
echo 'UNO_SHARED_PACKAGES_CACHE = $$OOO_BASE_DIR' \
>> $(MISC)/unitdata/basis/program/uno$(MY_INI)
echo 'UNO_USER_PACKAGES_CACHE =' \
'$${$$BRAND_BASE_DIR/program/bootstrap$(MY_INI):UserInstallation}' \
>> $(MISC)/unitdata/basis/program/uno$(MY_INI)
mkdir $(MISC)/unitdata/basis/share
mkdir $(MISC)/unitdata/basis/share/registry
cp data.xcd $(MISC)/unitdata/basis/share/registry
mkdir $(MISC)/unitdata/brand
mkdir $(MISC)/unitdata/brand/program
echo '[Bootstrap]' > $(MISC)/unitdata/brand/program/bootstrap$(MY_INI)
echo 'UserInstallation = $$ORIGIN/../../user' \
>> $(MISC)/unitdata/brand/program/bootstrap$(MY_INI)
.IF "$(USE_SHELL)" == "bash"
export \
URE_BOOTSTRAP=vnd.sun.star.pathname:$(MISC)/unitdata/urebootstrap.ini \
&& $(TESTSHL2) $(SHL1TARGETN) -forward $(MISC)/unit.rdb
.ELSE
setenv \
URE_BOOTSTRAP vnd.sun.star.pathname:$(MISC)/unitdata/urebootstrap.ini \
&& $(TESTSHL2) $(SHL1TARGETN) -forward $(MISC)/unit.rdb
.ENDIF
View File
-268
View File
@@ -1,268 +0,0 @@
// To debug me use:
// $ export ENVCFGFLAGS='-me -ti -tw -tp -td'
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#include "common.hxx"
void Test::setUp()
{
mpMagic = new Magic();
char const * f = getForwardString();
rtl::OUString args(
f, rtl_str_getLength(f), osl_getThreadTextEncoding());
//TODO: handle conversion failure
sal_Int32 i = args.indexOf('#');
if (i < 0)
std::abort();
rtl::OUString rdb(args.copy(0, i));
rtl::OUString regpath(args.copy(i + 1));
rtl::OUString regurl;
if (osl::FileBase::getFileURLFromSystemPath(regpath, regurl) !=
osl::FileBase::E_None)
std::abort();
css::uno::Reference< css::beans::XPropertySet > factory(
cppu::createRegistryServiceFactory(rdb), css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::uno::XComponentContext > context(
factory->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))),
css::uno::UNO_QUERY_THROW);
cppu::ContextEntry_Init entry(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"/modules/com.sun.star.configuration/bootstrap/Strata")),
css::uno::makeAny(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.configuration.backend.LocalStratum:"))
+ regurl));
mxContext = cppu::createComponentContext(&entry, 1, context);
CPPUNIT_ASSERT_MESSAGE ("component context is valid", mxContext.is());
try {
mxProvider = css::uno::Reference< css::lang::XMultiServiceFactory >(
(css::uno::Reference< css::lang::XMultiComponentFactory >(
mxContext->getServiceManager(), css::uno::UNO_QUERY_THROW)->
createInstanceWithContext(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.configuration.ConfigurationProvider")),
mxContext)),
css::uno::UNO_QUERY_THROW);
} catch (css::uno::Exception&e) {
CPPUNIT_FAIL( "exception creating provider" );
throw;
}
}
css::uno::Reference< css::uno::XInterface >
Test::createView(const sal_Char *pNodepath, bool bUpdate)
{
rtl::OUString aNodePath = rtl::OUString::createFromAscii(pNodepath);
static const rtl::OUString kInfoViewService(
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess")) ;
static const rtl::OUString kUpdateViewService(
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationUpdateAccess")) ;
static const rtl::OUString kNodepath(RTL_CONSTASCII_USTRINGPARAM("nodepath")) ;
static const rtl::OUString kAsync(RTL_CONSTASCII_USTRINGPARAM("EnableAsync")) ;
const rtl::OUString & kViewService = bUpdate ? kUpdateViewService : kInfoViewService;
css::uno::Sequence< css::uno::Any > aViewArgs(2);
aViewArgs[0] <<= css::beans::NamedValue( kNodepath, css::uno::makeAny(aNodePath) );
aViewArgs[1] <<= css::beans::NamedValue( kAsync, css::uno::makeAny(sal_False) );
css::uno::Reference< css::uno::XInterface > xView(
mxProvider->createInstanceWithArguments( kViewService, aViewArgs ) );
return xView;
}
void disposeComponent (const css::uno::Reference<css::uno::XInterface> &xComp)
{
css::uno::Reference< css::lang::XComponent >(
xComp, css::uno::UNO_QUERY_THROW)->dispose();
}
void Test::tearDown()
{
disposeComponent (mxProvider);
disposeComponent (mxContext);
delete mpMagic;
}
void Test::normalizePathKey (rtl::OString &rPath, rtl::OString &rKey)
{
sal_Int32 idx = rKey.lastIndexOf("/");
if (idx > 0) {
rPath += "/";
rPath += rKey.copy (0, idx);
rKey = rKey.copy (idx + 1);
// t_print ("write to '%s' '%s'\n", (const sal_Char *)rPath,
// (const sal_Char *)rKey);
}
}
css::uno::Any Test::getKey (const sal_Char *pPath, rtl::OUString aName)
{
css::uno::Reference< css::container::XHierarchicalNameAccess > xNameAccess(
createView(pPath, false), css::uno::UNO_QUERY_THROW);
css::uno::Any aVal;
aVal = xNameAccess->getByHierarchicalName (aName);
disposeComponent (xNameAccess);
return aVal;
}
void Test::setKey (const sal_Char *pPath, rtl::OUString aName, css::uno::Any a)
{
css::uno::Reference< css::util::XChangesBatch > xAppView;
xAppView = css::uno::Reference< css::util::XChangesBatch > (
createView(pPath, true), css::uno::UNO_QUERY_THROW );
css::uno::Reference< css::container::XNameReplace > xSettings(xAppView, css::uno::UNO_QUERY_THROW);
rtl::OUString aStr;
// set key
xSettings->replaceByName(aName, a);
xAppView->commitChanges();
disposeComponent(xAppView);
}
void Test::resetKey (const sal_Char *pPath, rtl::OUString aName)
{
css::uno::Reference< css::util::XChangesBatch > xAppView;
// reset to default
xAppView = css::uno::Reference< css::util::XChangesBatch > ( createView(pPath, true), css::uno::UNO_QUERY_THROW );
css::uno::Reference< css::container::XNameReplace > xSettings(xAppView, css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::beans::XPropertyState > xSettingsState(xSettings, css::uno::UNO_QUERY);
xSettingsState->setPropertyToDefault(aName);
xAppView->commitChanges();
disposeComponent(xAppView);
}
void Test::keyFetch()
{
try {
rtl::OUString aStr;
if (!(getKey ("/org.openoffice.Setup", "L10N/ooLocale") >>= aStr))
CPPUNIT_FAIL("to fetch key");
if (!(getKey ("/org.openoffice.Setup", "Test/AString") >>= aStr))
CPPUNIT_FAIL("to fetch key");
} CATCH_FAIL ("fetching key")
}
void Test::keySet()
{
try {
setKey ("/org.openoffice.Setup/Test",
rtl::OUString::createFromAscii("AString"),
css::uno::makeAny (rtl::OUString::createFromAscii("baa")));
// check value
rtl::OUString aStr;
if (!(getKey ("/org.openoffice.Setup/Test", "AString") >>= aStr))
CPPUNIT_FAIL("to fetch key");
CPPUNIT_ASSERT_MESSAGE ("check set value valid", aStr.equalsAscii("baa"));
} CATCH_FAIL ("exception setting keys" )
}
void Test::keyReset()
{
try {
resetKey ("/org.openoffice.Setup/Test",
rtl::OUString::createFromAscii("AString"));
// check value
rtl::OUString aStr;
if (!(getKey ("/org.openoffice.Setup/Test", "AString") >>= aStr))
CPPUNIT_FAIL("to fetch key");
CPPUNIT_ASSERT_MESSAGE ("check default value valid",
aStr == rtl::OUString::createFromAscii("Foo"));
} CATCH_FAIL ("exception setting keys" )
}
// This simulates the framework UI description code paths
void Test::readCommands()
{
rtl::OUString aPropUILabel( RTL_CONSTASCII_USTRINGPARAM( "Label" ));
rtl::OUString aPropUIContextLabel( RTL_CONSTASCII_USTRINGPARAM( "ContextLabel" ));
rtl::OUString aPropProperties( RTL_CONSTASCII_USTRINGPARAM( "Properties" ));
try {
css::uno::Reference< css::container::XNameAccess > xNameAccess (
createView("/org.openoffice.UI.GenericCommands/UserInterface/Commands", false),
css::uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE ("fetched UI generic commands", xNameAccess.is());
css::uno::Any a;
css::uno::Sequence< rtl::OUString > aNameSeq = xNameAccess->getElementNames();
CPPUNIT_ASSERT_MESSAGE ("right element / sequence", aNameSeq.getLength() == 696);
sal_uInt32 end, start = osl_getGlobalTimer();
for ( sal_Int32 j = 0; j < 8; j++ )
{
for ( sal_Int32 i = 0; i < aNameSeq.getLength(); i++ )
{
try
{
{
css::uno::Reference< css::container::XNameAccess > xChildNameAccess;
// This is the slow bit ! ...
// Creating the @#$@#$ing XNameAccess object [ 650 times ]
// which we then use to 'getByName' etc.
a = xNameAccess->getByName( aNameSeq[i] );
if ( a >>= xChildNameAccess )
{
a = xChildNameAccess->getByName( aPropUILabel );
a = xChildNameAccess->getByName( aPropUIContextLabel );
a = xChildNameAccess->getByName( aPropProperties );
}
}
} CATCH_FAIL( "fetching keys" );
}
}
end = osl_getGlobalTimer();
t_print ("Reading elements took %d ms\n", (int)(end-start));
disposeComponent (xNameAccess);
} CATCH_FAIL( "accessing commands" );
}
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "alltests");
NOADDITIONAL;
@@ -1,72 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--***********************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************ -->
<!DOCTYPE oor:component-schema SYSTEM "../../../component-schema.dtd">
<oor:component-schema xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="Setup" oor:package="org.openoffice" xml:lang="en-US">
<info>
<author>mmeeks</author>
<desc >Setup prefs (for configmgr) and unit test schema bits.</desc>
</info>
<component>
<group oor:name="L10N">
<info>
<author>PB</author>
<desc>Specifies the installation locales.</desc>
</info>
<prop oor:name="ooLocale" oor:type="xs:string">
<info>
<author>PB</author>
<desc>Indicates the Office language selected by the user.</desc>
<label>Locale</label>
</info>
<value/>
</prop>
</group>
<group oor:name="Test">
<info>
<author>mmeeks</author>
<desc>Misc test pieces</desc>
</info>
<prop oor:name="ABoolean" oor:type="xs:boolean">
<info>
<author>mmeeks</author>
<desc>A boolean</desc>
<label>Boolean</label>
</info>
<value>false</value>
</prop>
<prop oor:name="AString" oor:type="xs:string">
<info>
<author>mmeeks</author>
<desc>A string</desc>
<label>String</label>
</info>
<value>Foo</value>
</prop>
</group>
</component>
</oor:component-schema>
@@ -1,62 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--***********************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************ -->
<!DOCTYPE oor:component-schema SYSTEM "../../../../../component-schema.dtd">
<oor:component-schema xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="Commands" oor:package="org.openoffice.UI" xml:lang="en-US"> <info>
<author>CD</author>
<desc >Contains general information about ~ and rules, and about actions based on office commands.</desc>
</info>
<templates>
<group oor:name="LabelType">
<info>
<desc>Provides a mapping between commands and their textual representation on the user interface.</desc>
</info>
<prop oor:name="Label" oor:type="xs:string" oor:localized="true">
<info>
<desc>A localized text that describes the command or identifier. Can be used as a label inside a menu or as short tool tip help.</desc>
</info>
</prop>
<prop oor:name="ContextLabel" oor:type="xs:string" oor:localized="true">
<info>
<desc>A localized text that describes the identifier of a command in a structured menu. </desc>
</info>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<info>
<desc>
Additional information about a single command.
Bit 0 = Command has an image.
Bit 1 = Image must be mirrored (CTL/vertical text).
Bit 2 = Image must be rotated (CTL/vertical text).
</desc>
</info>
<value>0</value>
</prop>
</group>
</templates>
<component/>
</oor:component-schema>
@@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--***********************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************ -->
<!DOCTYPE oor:component-schema SYSTEM "../../../../../component-schema.dtd">
<oor:component-schema xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="GenericCommands" oor:package="org.openoffice.UI" xml:lang="en-US">
<info>
<author>CD</author>
<desc >Contains general information about ~ and rules, and about actions based on office commands.</desc>
</info>
<import oor:component="org.openoffice.UI.Commands"/>
<uses oor:component="org.openoffice.UI.Commands"/>
<templates/>
<component>
<group oor:name="UserInterface">
<info>
<desc>Contains user interface data for Office commands and identifiers that are used by the user interface."</desc>
</info>
<set oor:name="Commands" oor:node-type="LabelType" oor:component="org.openoffice.UI.Commands">
<info>
<desc>Contains label text for Office commands and identifiers that are used by the user interface."</desc>
</info>
</set>
</group>
</component>
</oor:component-schema>
+678
View File
@@ -0,0 +1,678 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#include "precompiled_configmgr.hxx"
#include "sal/config.h"
#include <cstddef>
#include "com/sun/star/beans/NamedValue.hpp"
#include "com/sun/star/beans/PropertyChangeEvent.hpp"
#include "com/sun/star/beans/XPropertyChangeListener.hpp"
#include "com/sun/star/beans/XPropertySet.hpp"
#include "com/sun/star/beans/XPropertyState.hpp"
#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
#include "com/sun/star/container/XNameReplace.hpp"
#include "com/sun/star/container/XNamed.hpp"
#include "com/sun/star/lang/EventObject.hpp"
#include "com/sun/star/lang/XComponent.hpp"
#include "com/sun/star/lang/XMultiServiceFactory.hpp"
#include "com/sun/star/uno/Any.hxx"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.hxx"
#include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/uno/XInterface.hpp"
#include "com/sun/star/util/XChangesBatch.hpp"
#include "cppuhelper/implbase1.hxx"
#include "cppuhelper/servicefactory.hxx"
#include "osl/conditn.hxx"
#include "osl/thread.h"
#include "osl/thread.hxx"
#include "osl/time.h"
#include "rtl/ref.hxx"
#include "rtl/string.h"
#include "rtl/textcvt.h"
#include "rtl/ustrbuf.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
#include "testshl/simpleheader.hxx"
namespace {
namespace css = com::sun::star;
void normalize(
rtl::OUString const & path, rtl::OUString const & relative,
rtl::OUString * normalizedPath, rtl::OUString * name)
{
sal_Int32 i = relative.lastIndexOf('/');
if (i == -1) {
*normalizedPath = path;
*name = relative;
} else {
rtl::OUStringBuffer buf(path);
buf.append(sal_Unicode('/'));
buf.append(relative.copy(0, i));
*normalizedPath = buf.makeStringAndClear();
*name = relative.copy(i + 1);
}
}
class Test: public CppUnit::TestFixture {
public:
virtual void setUp();
virtual void tearDown();
void testKeyFetch();
void testKeySet();
void testKeyReset();
void testSetSetMemberName();
void testReadCommands();
void testThreads();
void testRecursive();
void testCrossThreads();
css::uno::Any getKey(
rtl::OUString const & path, rtl::OUString const & relative) const;
void setKey(
rtl::OUString const & path, rtl::OUString const & name,
css::uno::Any const & value) const;
bool resetKey(rtl::OUString const & path, rtl::OUString const & name) const;
css::uno::Reference< css::uno::XInterface > createViewAccess(
rtl::OUString const & path) const;
css::uno::Reference< css::uno::XInterface > createUpdateAccess(
rtl::OUString const & path) const;
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testKeyFetch);
CPPUNIT_TEST(testKeySet);
CPPUNIT_TEST(testKeyReset);
CPPUNIT_TEST(testSetSetMemberName);
CPPUNIT_TEST(testReadCommands);
CPPUNIT_TEST(testThreads);
CPPUNIT_TEST(testRecursive);
CPPUNIT_TEST(testCrossThreads);
CPPUNIT_TEST_SUITE_END();
private:
css::uno::Reference< css::uno::XComponentContext > context_;
css::uno::Reference< css::lang::XMultiServiceFactory > provider_;
};
class TestThread: public osl::Thread {
public:
TestThread(osl::Condition & stop);
bool getSuccess() const;
protected:
virtual bool iteration() = 0;
private:
virtual void SAL_CALL run();
osl::Condition & stop_;
bool success_;
};
TestThread::TestThread(
osl::Condition & stop):
stop_(stop), success_(true)
{}
bool TestThread::getSuccess() const {
return success_;
}
void TestThread::run() {
try {
while (!stop_.check()) {
if (!iteration()) {
success_ = false;
}
}
} catch (...) {
success_ = false;
}
}
class ReaderThread: public TestThread {
public:
ReaderThread(
osl::Condition & stop, Test const & test, rtl::OUString const & path,
rtl::OUString const & relative);
private:
virtual bool iteration();
Test const & test_;
rtl::OUString path_;
rtl::OUString relative_;
};
ReaderThread::ReaderThread(
osl::Condition & stop, Test const & test, rtl::OUString const & path,
rtl::OUString const & relative):
TestThread(stop), test_(test), path_(path), relative_(relative)
{
create();
}
bool ReaderThread::iteration() {
return test_.getKey(path_, relative_).hasValue();
}
class WriterThread: public TestThread {
public:
WriterThread(
osl::Condition & stop, Test const & test, rtl::OUString const & path,
rtl::OUString const & relative);
private:
virtual bool iteration();
Test const & test_;
rtl::OUString path_;
rtl::OUString name_;
std::size_t index_;
};
WriterThread::WriterThread(
osl::Condition & stop, Test const & test, rtl::OUString const & path,
rtl::OUString const & relative):
TestThread(stop), test_(test), index_(0)
{
normalize(path, relative, &path_, &name_);
create();
}
bool WriterThread::iteration() {
rtl::OUString options[] = {
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("fish")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("chips")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("kippers")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bloaters")) };
test_.setKey(path_, name_, css::uno::makeAny(options[index_]));
index_ = (index_ + 1) % (sizeof options / sizeof (rtl::OUString));
return true;
}
class RecursiveTest:
public cppu::WeakImplHelper1< css::beans::XPropertyChangeListener >
{
public:
RecursiveTest(Test const & theTest, int count, bool * destroyed);
void test();
protected:
virtual ~RecursiveTest();
virtual void step() const = 0;
Test const & test_;
private:
virtual void SAL_CALL disposing(css::lang::EventObject const &)
throw (css::uno::RuntimeException);
virtual void SAL_CALL propertyChange(
css::beans::PropertyChangeEvent const &)
throw (css::uno::RuntimeException);
int count_;
bool * destroyed_;
css::uno::Reference< css::beans::XPropertySet > properties_;
};
RecursiveTest::RecursiveTest(
Test const & theTest, int count, bool * destroyed):
test_(theTest), count_(count), destroyed_(destroyed)
{}
void RecursiveTest::test() {
properties_ = css::uno::Reference< css::beans::XPropertySet >(
test_.createUpdateAccess(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
"dotuno:WebHtml"))),
css::uno::UNO_QUERY_THROW);
properties_->addPropertyChangeListener(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")), this);
step();
CPPUNIT_ASSERT(count_ == 0);
css::uno::Reference< css::lang::XComponent >(
properties_, css::uno::UNO_QUERY_THROW)->dispose();
}
RecursiveTest::~RecursiveTest() {
*destroyed_ = true;
}
void RecursiveTest::disposing(css::lang::EventObject const & Source)
throw (css::uno::RuntimeException)
{
CPPUNIT_ASSERT(properties_.is() && Source.Source == properties_);
properties_.clear();
}
void RecursiveTest::propertyChange(css::beans::PropertyChangeEvent const & evt)
throw (css::uno::RuntimeException)
{
CPPUNIT_ASSERT(
evt.Source == properties_ &&
evt.PropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Label")));
if (count_ > 0) {
--count_;
step();
}
}
class SimpleRecursiveTest: public RecursiveTest {
public:
SimpleRecursiveTest(Test const & theTest, int count, bool * destroyed);
private:
virtual void step() const;
};
SimpleRecursiveTest::SimpleRecursiveTest(
Test const & theTest, int count, bool * destroyed):
RecursiveTest(theTest, count, destroyed)
{}
void SimpleRecursiveTest::step() const {
test_.setKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
"dotuno:WebHtml")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")),
css::uno::makeAny(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("step"))));
}
class CrossThreadTest: public RecursiveTest {
public:
CrossThreadTest(Test const & theTest, int count, bool * destroyed);
private:
virtual void step() const;
};
CrossThreadTest::CrossThreadTest(
Test const & theTest, int count, bool * destroyed):
RecursiveTest(theTest, count, destroyed)
{}
void CrossThreadTest::step() const {
osl::Condition stop;
stop.set();
WriterThread(
stop, test_,
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
"dotuno:WebHtml")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label"))).join();
test_.resetKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
"dotuno:WebHtml")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")));
}
void Test::setUp() {
char const * forward = getForwardString();
rtl_uString * registry = 0;
CPPUNIT_ASSERT(
rtl_convertStringToUString(
&registry, forward, rtl_str_getLength(forward),
osl_getThreadTextEncoding(),
(RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)));
context_ = css::uno::Reference< css::uno::XComponentContext >(
css::uno::Reference< css::beans::XPropertySet >(
cppu::createRegistryServiceFactory(
rtl::OUString(registry, SAL_NO_ACQUIRE)),
css::uno::UNO_QUERY_THROW)->getPropertyValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))),
css::uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT(
context_->getValueByName(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"/singletons/"
"com.sun.star.configuration.theDefaultProvider"))) >>=
provider_);
}
void Test::tearDown() {
css::uno::Reference< css::lang::XComponent >(
context_, css::uno::UNO_QUERY_THROW)->dispose();
}
void Test::testKeyFetch() {
rtl::OUString s;
CPPUNIT_ASSERT(
getKey(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("L10N/ooLocale"))) >>=
s);
CPPUNIT_ASSERT(
getKey(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test/AString"))) >>=
s);
}
void Test::testKeySet() {
setKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString")),
css::uno::makeAny(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("baa"))));
rtl::OUString s;
CPPUNIT_ASSERT(
getKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString"))) >>=
s);
CPPUNIT_ASSERT(s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("baa")));
}
void Test::testKeyReset() {
if (resetKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString"))))
{
rtl::OUString s;
CPPUNIT_ASSERT(
getKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Test")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AString"))) >>=
s);
CPPUNIT_ASSERT(s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Foo")));
}
}
void Test::testSetSetMemberName() {
rtl::OUString s;
CPPUNIT_ASSERT(
getKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
".uno:FontworkShapeType")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label"))) >>=
s);
CPPUNIT_ASSERT(
s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Fontwork Shape")));
css::uno::Reference< css::container::XNameAccess > access(
createUpdateAccess(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.UI.GenericCommands/UserInterface/"
"Commands"))),
css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::container::XNamed > member;
access->getByName(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(".uno:FontworkGalleryFloater"))) >>=
member;
CPPUNIT_ASSERT(member.is());
member->setName(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(".uno:FontworkShapeType")));
css::uno::Reference< css::util::XChangesBatch >(
access, css::uno::UNO_QUERY_THROW)->commitChanges();
css::uno::Reference< css::lang::XComponent >(
access, css::uno::UNO_QUERY_THROW)->dispose();
CPPUNIT_ASSERT(
getKey(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.UI.GenericCommands/UserInterface/Commands/"
".uno:FontworkShapeType")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label"))) >>=
s);
CPPUNIT_ASSERT(
s.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Fontwork Gallery")));
}
void Test::testReadCommands() {
css::uno::Reference< css::container::XNameAccess > access(
createViewAccess(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.UI.GenericCommands/UserInterface/"
"Commands"))),
css::uno::UNO_QUERY_THROW);
css::uno::Sequence< rtl::OUString > names(access->getElementNames());
CPPUNIT_ASSERT(names.getLength() == 695);
// testSetSetMemberName() already removed ".uno:FontworkGalleryFloater"
sal_uInt32 n = osl_getGlobalTimer();
for (int i = 0; i < 8; ++i) {
for (sal_Int32 j = 0; j < names.getLength(); ++j) {
css::uno::Reference< css::container::XNameAccess > child;
if (access->getByName(names[j]) >>= child) {
CPPUNIT_ASSERT(child.is());
child->getByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Label")));
child->getByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ContextLabel")));
child->getByName(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Properties")));
}
}
}
n = osl_getGlobalTimer() - n;
t_print("Reading elements took %" SAL_PRIuUINT32 " ms\n", n);
css::uno::Reference< css::lang::XComponent >(
access, css::uno::UNO_QUERY_THROW)->dispose();
}
void Test::testThreads() {
struct Entry { rtl::OUString path; rtl::OUString relative; };
Entry list[] = {
{ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test/AString")) },
{ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test/AString")) },
{ rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.UI.GenericCommands")),
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"UserInterface/Commands/dotuno:WebHtml/Label")) },
{ rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.UI.GenericCommands")),
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"UserInterface/Commands/dotuno:NewPresentation/Label")) },
{ rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"/org.openoffice.UI.GenericCommands")),
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"UserInterface/Commands/dotuno:RecentFileList/Label")) },
{ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("L10N/ooLocale")) },
{ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test/ABoolean")) }
};
std::size_t const numReaders = sizeof list / sizeof (Entry);
std::size_t const numWriters = numReaders - 2;
ReaderThread * readers[numReaders];
WriterThread * writers[numWriters];
osl::Condition stop;
for (std::size_t i = 0; i < numReaders; ++i) {
CPPUNIT_ASSERT(getKey(list[i].path, list[i].relative).hasValue());
readers[i] = new ReaderThread(
stop, *this, list[i].path, list[i].relative);
}
for (std::size_t i = 0; i < numWriters; ++i) {
writers[i] = new WriterThread(
stop, *this, list[i].path, list[i].relative);
}
for (int i = 0; i < 5; ++i) {
for (std::size_t j = 0; j < numReaders; ++j) {
rtl::OUString path;
rtl::OUString name;
normalize(list[j].path, list[j].relative, &path, &name);
resetKey(path, name);
osl::Thread::yield();
}
}
stop.set();
bool success = true;
for (std::size_t i = 0; i < numReaders; ++i) {
readers[i]->join();
success = success && readers[i]->getSuccess();
delete readers[i];
}
for (std::size_t i = 0; i < numWriters; ++i) {
writers[i]->join();
success = success && writers[i]->getSuccess();
delete writers[i];
}
CPPUNIT_ASSERT(success);
}
void Test::testRecursive() {
bool destroyed = false;
rtl::Reference< RecursiveTest >(
new SimpleRecursiveTest(*this, 100, &destroyed))->test();
CPPUNIT_ASSERT(destroyed);
}
void Test::testCrossThreads() {
bool destroyed = false;
rtl::Reference< RecursiveTest >(
new SimpleRecursiveTest(*this, 10, &destroyed))->test();
CPPUNIT_ASSERT(destroyed);
}
css::uno::Any Test::getKey(
rtl::OUString const & path, rtl::OUString const & relative) const
{
css::uno::Reference< css::container::XHierarchicalNameAccess > access(
createViewAccess(path), css::uno::UNO_QUERY_THROW);
css::uno::Any value(access->getByHierarchicalName(relative));
css::uno::Reference< css::lang::XComponent >(
access, css::uno::UNO_QUERY_THROW)->dispose();
return value;
}
void Test::setKey(
rtl::OUString const & path, rtl::OUString const & name,
css::uno::Any const & value) const
{
css::uno::Reference< css::container::XNameReplace > access(
createUpdateAccess(path), css::uno::UNO_QUERY_THROW);
access->replaceByName(name, value);
css::uno::Reference< css::util::XChangesBatch >(
access, css::uno::UNO_QUERY_THROW)->commitChanges();
css::uno::Reference< css::lang::XComponent >(
access, css::uno::UNO_QUERY_THROW)->dispose();
}
bool Test::resetKey(rtl::OUString const & path, rtl::OUString const & name)
const
{
//TODO: support setPropertyToDefault
css::uno::Reference< css::util::XChangesBatch > access(
createUpdateAccess(path), css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::beans::XPropertyState > state(
access, css::uno::UNO_QUERY);
if (!state.is()) {
return false;
}
state->setPropertyToDefault(name);
access->commitChanges();
css::uno::Reference< css::lang::XComponent >(
access, css::uno::UNO_QUERY_THROW)->dispose();
return true;
}
css::uno::Reference< css::uno::XInterface > Test::createViewAccess(
rtl::OUString const & path) const
{
css::uno::Any arg(
css::uno::makeAny(
css::beans::NamedValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")),
css::uno::makeAny(path))));
return provider_->createInstanceWithArguments(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.configuration.ConfigurationAccess")),
css::uno::Sequence< css::uno::Any >(&arg, 1));
}
css::uno::Reference< css::uno::XInterface > Test::createUpdateAccess(
rtl::OUString const & path) const
{
css::uno::Any arg(
css::uno::makeAny(
css::beans::NamedValue(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")),
css::uno::makeAny(path))));
return provider_->createInstanceWithArguments(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.configuration.ConfigurationUpdateAccess")),
css::uno::Sequence< css::uno::Any >(&arg, 1));
}
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "alltest");
}
NOADDITIONAL;
-259
View File
@@ -1,259 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#include "common.hxx"
#include <osl/thread.hxx>
#include <osl/conditn.hxx>
#include <cppuhelper/implbase1.hxx>
#include "com/sun/star/beans/XPropertyChangeListener.hpp"
class KeyTester : public osl::Thread
{
osl::Condition *m_pCond;
protected:
rtl::OString m_aPath;
rtl::OString m_aKey;
Test *m_pTest;
public:
KeyTester (osl::Condition *pCond, Test *pTest,
const char *pPath, const char *pKey)
: m_pCond (pCond)
, m_aPath (pPath)
, m_aKey (pKey)
, m_pTest (pTest)
{
}
virtual ~KeyTester ()
{
}
virtual void SAL_CALL run ()
{
testIteration();
while (!m_pCond->check())
testIteration();
}
virtual void testIteration()
{
css::uno::Any a = m_pTest->getKey (m_aPath, m_aKey);
CPPUNIT_ASSERT_MESSAGE ("no value", a.hasValue());
}
};
class KeyReader : public KeyTester
{
public:
KeyReader (osl::Condition *pCond, Test *pTest,
const char *pPath, const char *pKey)
: KeyTester (pCond, pTest, pPath, pKey)
{
// to ensure we have the right vtable when we hit 'run'
create();
}
};
class KeyWriter : public KeyTester
{
int curOpt;
public:
KeyWriter (osl::Condition *pCond, Test *pTest,
const char *pPath, const char *pKey)
: KeyTester (pCond, pTest, pPath, pKey)
, curOpt(0)
{
m_pTest->normalizePathKey (m_aPath, m_aKey);
create();
}
virtual void testIteration ()
{
try {
static const char *options[] = { "fish", "chips", "kippers", "bloaters" };
// fprintf (stderr, "set key %d\n",
// (int) osl_getThreadIdentifier(NULL));
m_pTest->setKey (m_aPath, rtl::OUString::createFromAscii (m_aKey),
css::uno::makeAny (rtl::OUString::createFromAscii(options[(curOpt++ & 3)])));
} CATCH_FAIL ("setting keys")
}
};
void Test::threadTests()
{
osl::Condition stop;
stop.reset();
struct {
const char *pPath;
const char *pKey;
} keyList[] = {
{ "/org.openoffice.Setup", "Test/AString" },
{ "/org.openoffice.Setup", "Test/AString" },
{ "/org.openoffice.UI.GenericCommands", "UserInterface/Commands/dotuno:WebHtml/Label" },
{ "/org.openoffice.UI.GenericCommands", "UserInterface/Commands/dotuno:NewPresentation/Label" },
{ "/org.openoffice.UI.GenericCommands", "UserInterface/Commands/dotuno:RecentFileList/Label" },
{ "/org.openoffice.Setup", "L10N/ooLocale" },
{ "/org.openoffice.Setup", "Test/ABoolean" }
};
const int numReaders = sizeof (keyList) / sizeof (keyList[0]);
const int numWriters = (sizeof (keyList) / sizeof (keyList[0])) - 2;
KeyReader *pReaders[numReaders];
KeyWriter *pWriters[numReaders];
int i;
try {
for (i = 0; i < numReaders; i++) {
css::uno::Any a = getKey (keyList[i].pPath, keyList[i].pKey);
CPPUNIT_ASSERT_MESSAGE ("check key", a.hasValue());
}
// a few readers
for (i = 0; i < numReaders; i++)
pReaders[i] = new KeyReader (&stop, this, keyList[i].pPath,
keyList[i].pKey);
// a few writers
for (i = 0; i < numWriters; i++)
pWriters[i] = new KeyWriter (&stop, this, keyList[i].pPath,
keyList[i].pKey);
// Threads are running ...
const int numIters = 5;
for (int j = 0; j < numIters; j++) {
for (i = 0; i < numReaders; i++)
{
try {
rtl::OString aPath (keyList[i].pPath);
rtl::OString aKey (keyList[i].pKey);
normalizePathKey (aPath, aKey);
resetKey (aPath, rtl::OUString::createFromAscii (aKey));
osl::Thread::yield();
} CATCH_FAIL ("resetting keys");
}
}
stop.set();
for (i = 0; i < numReaders; i++) {
pReaders[i]->join();
delete pReaders[i];
}
for (i = 0; i < numWriters; i++) {
pWriters[i]->join();
delete pWriters[i];
}
} CATCH_FAIL ("checking keys exist")
}
class RecursiveListener : public cppu::WeakImplHelper1< css::beans::XPropertyChangeListener >
{
public:
sal_Int32 m_nRecurse;
css::uno::Reference< css::beans::XPropertySet > mxPropSet;
protected:
Test *m_pTest;
rtl::OString m_pPath;
rtl::OString m_pKey;
public:
RecursiveListener (Test *pTest, int nCount,
const char *pPath, const char *pKey)
: m_nRecurse (nCount)
, m_pTest (pTest)
, m_pPath (pPath)
, m_pKey (pKey)
{
mxPropSet = css::uno::Reference< css::beans::XPropertySet > (
pTest->createView (pPath, true), css::uno::UNO_QUERY_THROW );
CPPUNIT_ASSERT_MESSAGE ("is prop set", mxPropSet.is());
mxPropSet->addPropertyChangeListener (rtl::OUString::createFromAscii (m_pKey),
css::uno::Reference<css::beans::XPropertyChangeListener>(this));
}
virtual ~RecursiveListener()
{
disposeComponent (mxPropSet);
}
virtual void SAL_CALL acquire() throw() { cppu::WeakImplHelper1< css::beans::XPropertyChangeListener >::acquire(); }
virtual void SAL_CALL release() throw() { cppu::WeakImplHelper1< css::beans::XPropertyChangeListener >::acquire(); }
// XPropertyChangeListener
virtual void SAL_CALL propertyChange( const ::css::beans::PropertyChangeEvent& ) throw (::css::uno::RuntimeException)
{
if (m_nRecurse-- > 0)
runTest();
}
// XEventListener
virtual void SAL_CALL disposing( const ::css::lang::EventObject& ) throw (::css::uno::RuntimeException)
{
}
virtual void runTest()
{
m_pTest->setKey (m_pPath, rtl::OUString::createFromAscii (m_pKey),
css::uno::makeAny(
rtl::OUString::valueOf (m_nRecurse) ) );
}
};
class CrossThreadListener : public RecursiveListener
{
public:
CrossThreadListener (Test *pTest, int nCount,
const char *pPath, const char *pKey)
: RecursiveListener (pTest, nCount, pPath, pKey)
{
}
virtual ~CrossThreadListener()
{
}
virtual void runTest()
{
osl::Condition stopAfterOne;
stopAfterOne.set();
KeyWriter aWriter (&stopAfterOne, m_pTest, m_pPath, m_pKey);
aWriter.join();
rtl::OString aPath (m_pPath), aKey (m_pKey);
m_pTest->normalizePathKey (aPath, aKey);
m_pTest->resetKey (aPath, rtl::OUString::createFromAscii (aKey));
}
};
void Test::recursiveTests()
{
RecursiveListener *pList = new RecursiveListener(this, 100,
"/org.openoffice.UI.GenericCommands/UserInterface/Commands/dotuno:WebHtml",
"Label");
css::uno::Reference< css::beans::XPropertyChangeListener > xListener(pList);
pList->runTest();
}
void Test::eventTests()
{
CrossThreadListener *pList = new CrossThreadListener(this, 10,
"/org.openoffice.UI.GenericCommands/UserInterface/Commands/dotuno:WebHtml",
"Label");
css::uno::Reference< css::beans::XPropertyChangeListener > xListener(pList);
pList->runTest();
}
-120
View File
@@ -1,120 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#include "common.hxx"
#include <osl/file.hxx>
// Do all those evil things to make the tests actually work ...
Magic::Magic()
{
rtl_uString *curWd = NULL;
osl_getProcessWorkingDir( &curWd );
rtl::OUString aKey;
rtl::OUString aValue( curWd );
// Unless you do this, obviously you don't want your paths to be correct
// or file access to work properly
aKey = rtl::OUString::createFromAscii( "BaseInstallation" );
rtl_bootstrap_set( aKey.pData, aValue.pData );
// Unless you do this, obviously you don't deserve to have anything work
aKey = rtl::OUString::createFromAscii( "CFG_INIFILE" );
aValue += rtl::OUString::createFromAscii( "/configmgrrc" );
rtl_bootstrap_set( aKey.pData, aValue.pData );
// FIXME: Create a safe /tmp directory - unfotunately that
// either requires dependencies we don't have, or some cut &
// paste action of unotools/source/ucbhelper/tempfile.cxx
if (osl::File::getTempDirURL(maTempDir) != osl::FileBase::E_None) {
t_print ("no tmp dir");
CPPUNIT_FAIL ("no tmp dir");
}
maTempDir += rtl::OUString::createFromAscii("/unittstconfig");
osl::FileBase::RC err = osl::Directory::create (maTempDir);
if (err != osl::FileBase::E_None) {
t_print ("tmp dir '%s' already exists\n",
rtl::OUStringToOString (maTempDir, RTL_TEXTENCODING_UTF8).getStr());
CPPUNIT_FAIL ("tmp user config dir already exists!");
}
aKey = rtl::OUString::createFromAscii( "UserInstallation" );
rtl_bootstrap_set( aKey.pData, maTempDir.pData );
}
void removeRecursive (const rtl::OUString& aPath)
{
sal_Int32 nMask = FileStatusMask_Type | FileStatusMask_FileURL;
// fprintf (stderr, "Remove recursive '%s'\n", rtl::OUStringToOString (aPath, RTL_TEXTENCODING_UTF8).getStr());
osl::DirectoryItem aItem;
osl::FileStatus aStatus( nMask );
osl::FileBase::RC nError;
nError = osl::DirectoryItem::get( aPath, aItem );
CPPUNIT_ASSERT_MESSAGE ("invalid path", nError == osl::FileBase::E_None);
nError = aItem.getFileStatus( aStatus );
CPPUNIT_ASSERT_MESSAGE ("invalid file", nError == osl::FileBase::E_None);
if (aStatus.getFileType() == osl::FileStatus::Regular ||
aStatus.getFileType() == osl::FileStatus::Link )
{
nError = osl::File::remove( aPath );
// fprintf (stderr, "Remove file '%s'\n", rtl::OUStringToOString (aPath, RTL_TEXTENCODING_UTF8).getStr());
CPPUNIT_ASSERT_MESSAGE ("removing file", nError == osl::FileBase::E_None);
}
else if (aStatus.getFileType() == osl::FileStatus::Directory)
{
osl::Directory aDirectory (aPath);
nError = aDirectory.open();
CPPUNIT_ASSERT_MESSAGE ("opening dir", nError == osl::FileBase::E_None);
rtl::OUString name;
while (true) {
nError = aDirectory.getNextItem( aItem );
if ( nError != osl::FileBase::E_None )
break;
nError = aItem.getFileStatus( aStatus );
CPPUNIT_ASSERT_MESSAGE ("getting status", nError == osl::FileBase::E_None);
removeRecursive (aStatus.getFileURL());
}
aDirectory.close();
nError = osl::Directory::remove( aPath );
// fprintf (stderr, "Remove dir '%s'\n", rtl::OUStringToOString (aPath, RTL_TEXTENCODING_UTF8).getStr());
CPPUNIT_ASSERT_MESSAGE ("removing directory", nError == osl::FileBase::E_None);
}
}
Magic::~Magic()
{
removeRecursive (maTempDir);
}
@@ -1,7 +1,7 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
@@ -23,27 +23,8 @@
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
#*************************************************************************
PRJ=..$/..
PRJINC=$(PRJ)$/source$/inc
PRJNAME=configmgr
TARGET=api
ENABLE_EXCEPTIONS=TRUE
# --- Settings ----------------------------------
.INCLUDE : settings.mk
.INCLUDE : $(PRJ)$/makefile.pmk
# --- Files -------------------------------------
SLOFILES= \
$(SLO)$/confevents.obj \
$(SLO)$/confsvccomponent.obj
# --- Targets ----------------------------------
.INCLUDE : target.mk
#***********************************************************************/
[Bootstrap]
OOO_BASE_DIR = $ORIGIN/basis
BRAND_BASE_DIR = $ORIGIN/brand
@@ -1,7 +1,7 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
@@ -23,24 +23,12 @@
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
#*************************************************************************
# ----------------------------CFGMGR settings------------------------------------#
# target
CFGMGR_TARGET=configmgr
# the major
CFGMGR_MAJOR=2
# the minor
CFGMGR_MINOR=0
# the micro
CFGMGR_MICRO=0
# this is a c++ compatible library
CFGMGR_CPP=1
CFGMGR=$(CFGMGR_TARGET_TARGET)_$(CMPEXT)
#***********************************************************************/
UDK_3_0_0 {
global:
registerAllTestFunction;
local:
*;
};
-34
View File
@@ -1,34 +0,0 @@
-o cfgmgr2.LocalSchemaSupplier
-o cfgmgr2.LocalSingleStratum
-o cfgmgr2.MultiStratumBackend
-o sysmgr1.SystemIntegration
#i46913# -o cfgmgr2.BootstrapContext
-o cfgmgr2.LayerUpdateMerger
-o cfgmgr2.LayerWriter
-o cfgmgr2.LocalDataImporter
-o cfgmgr2.LocalHierarchyBrowser
-o cfgmgr2.LocalSingleBackend
-o cfgmgr2.MergeImporter
-o cfgmgr2.OConfigurationRegistry
-o cfgmgr2.OInnerGroupInfoAccess
-o cfgmgr2.OInnerGroupUpdateAccess
-o cfgmgr2.OInnerSetInfoAccess
#i46185# -o cfgmgr2.OInnerTreeSetUpdateAccess
-o cfgmgr2.OInnerValueSetUpdateAccess
-o cfgmgr2.ORootElementGroupInfoAccess
-o cfgmgr2.ORootElementGroupUpdateAccess
-o cfgmgr2.ORootElementSetInfoAccess
#i46185# -o cfgmgr2.ORootElementTreeSetUpdateAccess
-o cfgmgr2.ORootElementValueSetUpdateAccess
-o cfgmgr2.OSetElementGroupInfoAccess
-o cfgmgr2.OSetElementGroupUpdateAccess
-o cfgmgr2.OSetElementSetInfoAccess
#i46185# -o cfgmgr2.OSetElementTreeSetUpdateAccess
#i84221# -o cfgmgr2.OSetElementValueSetUpdateAccess
-o cfgmgr2.SchemaParser
-o cfgmgr2.SingleBackendAdapter
-o cfgmgr2.ConfigurationProviderWrapper
#i87744# -o cfgmgr2.LayerParser
-o cfgmgr2.CopyImporter
-o cfgmgr2.AdministrationProvider
-o cfgmgr2.ConfigurationProvider
-55
View File
@@ -1,55 +0,0 @@
### i84222 ###
cfgmgr2.LocalSingleBackend::com::sun::star::configuration::backend::XMultiLayerStratum
### i23145 ###
cfgmgr2.OSetElementGroupUpdateAccess::com::sun::star::container::XChild
### i38211 ###
cfgmgr2.ConfigurationProvider::com::sun::star::lang::XComponent
### i46185 ###
cfgmgr2.OInnerTreeSetUpdateAccess::com::sun::star::container::XNameContainer
cfgmgr2.OSetElementTreeSetUpdateAccess::com::sun::star::container::XNameContainer
cfgmgr2.ORootElementTreeSetUpdateAccess::com::sun::star::container::XNameContainer
# -> test is disbaled in cfgmgr2.sce
### i46913 ###
cfgmgr2.BootstrapContext::com::sun::star::uno::XComponentContext
# -> test is disbaled in cfgmgr2.sce
### i83881 ###
cfgmgr2.OInnerValueSetUpdateAccess::com::sun::star::container::XNameReplace
### i65847 ###
cfgmgr2.OInnerTreeSetUpdateAccess::com::sun::star::beans::XPropertyWithState
# -> test is disbaled in cfgmgr2.sce
### i68673 ###
cfgmgr2.ORootElementTreeSetUpdateAccess::com::sun::star::beans::XPropertyWithState
# -> test is disbaled in cfgmgr2.sce
### i79114 ###
sysmgr1.SystemIntegration::com::sun::star::configuration::backend::XBackend
### i83880 ###
cfgmgr2.ORootElementValueSetUpdateAccess::com::sun::star::container::XNameReplace
### i84221 ###
cfgmgr2.OSetElementValueSetUpdateAccess
### i87744 ###
cfgmgr2.LayerParser
# -> test is disbaled in cfgmgr2.sce
### i88358 ###
cfgmgr2.OInnerValueSetUpdateAccess::com::sun::star::container::XHierarchicalNameAccess
cfgmgr2.OInnerValueSetUpdateAccess::com::sun::star::beans::XExactName
### i88360 ###
cfgmgr2.ORootElementValueSetUpdateAccess::com::sun::star::util::XChangesBatch
### i89412 ###
cfgmgr2.OInnerValueSetUpdateAccess::com::sun::star::container::XElementAccess
### i89413 ###
cfgmgr2.ORootElementValueSetUpdateAccess::com::sun::star::container::XHierarchicalNameAccess
+2
View File
@@ -1,4 +1,5 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
@@ -21,6 +22,7 @@
# version 3 along with OpenOffice.org. If not, see
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
#***********************************************************************/
.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
@@ -1,7 +1,7 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
@@ -23,6 +23,7 @@
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
#*************************************************************************
#***********************************************************************/
VISIBILITY_HIDDEN = TRUE
-o configmgr.ConfigurationProvider
-o configmgr.DefaultProvider
+156
View File
@@ -0,0 +1,156 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# 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.
#
#***********************************************************************/
Source Overview
===============
configurationprovider.cxx
configurationregistry.cxx
defaultprovider.cxx
services.cxx
UNO service implementations.
access.cxx
childaccess.cxx
rootaccess.cxx
UNO objects passed to clients.
components.cxx
Central singleton that aggregates all data (reads in the XML files, manages
modifications and global notifications).
groupnode.cxx
localizedpropertynode.cxx
localizedvaluenode.cxx
node.cxx
propertynode.cxx
setnode.cxx
Internal representations of data nodes.
pad.cxx
parsemanager.cxx
parser.hxx
span.hxx
valueparser.cxx
xcdparser.cxx
xcsparser.cxx
xcuparser.cxx
xmldata.cxx
xmlreader.cxx
XML file reading.
modifications.cxx
writemodfile.cxx
Modification management.
broadcaster.cxx
Notification management.
update.cxx
Extension manager interface.
data.cxx
lock.cxx
nodemap.cxx
path.hxx
type.cxx
Utilities.
Mandatory Set Members
=====================
- A set member can be marked as "mandatory," meaning that a member of that name
must always be present in a set.
- The above definition implies that calling replaceByName on a mandatory set
member is OK.
- The XCU format can contain oor:mandatory attributes on nodes. (The XCS format
does not support them. In the registrymodifications file, oor:mandatory
attributes should never be needed, as being mandatory cannot be controlled via
the UNO API.) The XCU reading code only evaluates the oor:mandatory attribute
for set members, and ignores it everywhere else.
- Only true sets support mandatory members. A localized property for the "*"
locale, though acting much like a set, does not support mandatory members.
- The OpenOffice.org Registry Format document claims that group extension
properties are implicitly mandatory, but at least the new configmgr code does
not treat them like that (i.e., they can be removed again).
- For simplicity, setMandatory/getMandatory are available as virtual functions
at the base Node, even though they can only make sense for GroupNodes and
SetNodes that are set members. The default getMandatory implementation returns
NO_LAYER, meaning oor:mandatory is not set to true in any layer. (Returning
NO_LAYER simplifies the code, e.g., removeByName does not have to check whether
getMandatory is called on a member of a true set to decide whether to forbid
removal.)
- When committing changes (made through the UNO API), the "mandatory" status of
inserted nodes must be updated (in case the insert is due to a replaceByName, or
the "mandatory" flag was added by a concurrent modification of a lower layer).
Also, for to-be-removed nodes, removal is ignored for (newly; due to concurrent
modification of a lower layer) mandatory nodes (but still recorded in
registrymodifications, so may take effect once the lower layer addition is
removed again---whether or not that is a good idea).
XcuParser Modification Recording
================================
- XcuParser records modifications when reading user layer data
(valueParser_.getLayer() == Data::NO_LAYER).
- oor:finalized and oor:mandatory attributes cannot be set via the UNO API, so
it is assumed that user layer data does not contain them (for one, they are not
written by writeModFile; for another, the logic to record modifications expects
a locprop(modify,fuse) to be followed by one or more value(fuse,remove), which
would not necessarily be true if the locprop were only present in the user layer
data to flag it as finalized).
- The logic to record modifications considers the top of the XML element stack.
In the following list of all possible cases, items marked with an asterisk are
recorded:
... group(modify,fuse) - group(modify,fuse) - ...
... group(modify,fuse) - set(modify,fuse) - ...
... group(modify,fuse) - *prop(modify,fuse,replace) - value(fuse)
... group(modify,fuse) - *prop(remove)
... group(modify,fuse) - locprop(modify,fuse) - *value(fuse)
... group(modify,fuse) - locprop(modify,fuse) - *value(remove)
... group(modify,fuse) - *locprop(replace) ...
... set(modify,fuse,replace) - group(modify/fuse) - ...
... set(modify,fuse,replace) - *group(replace/fuse) - ...
... set(modify,fuse,replace) - *group(remove)
... set(modify,fuse,replace) - set(modify/fuse) - ...
... set(modify,fuse,replace) - *set(replace/fuse) - ...
... set(modify,fuse,replace) - *set(remove)
Legend: "...": zero or more further items
"- ...": one or more further items
"modify,fuse" etc.: any of those operations
"modify/fuse": a modify or a fuse on an existing member
"replace/fuse": a replace or a fuse on a non-existing member
File diff suppressed because it is too large Load Diff
+582
View File
@@ -0,0 +1,582 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef INCLUDED_CONFIGMGR_SOURCE_ACCESS_HXX
#define INCLUDED_CONFIGMGR_SOURCE_ACCESS_HXX
#include "sal/config.h"
#include <map>
#include <set>
#include <vector>
#include "boost/noncopyable.hpp"
#include "com/sun/star/beans/PropertyVetoException.hpp"
#include "com/sun/star/beans/UnknownPropertyException.hpp"
#include "com/sun/star/beans/XExactName.hpp"
#include "com/sun/star/beans/XHierarchicalPropertySet.hpp"
#include "com/sun/star/beans/XHierarchicalPropertySetInfo.hpp"
#include "com/sun/star/beans/XMultiHierarchicalPropertySet.hpp"
#include "com/sun/star/beans/XMultiPropertySet.hpp"
#include "com/sun/star/beans/XProperty.hpp"
#include "com/sun/star/beans/XPropertySet.hpp"
#include "com/sun/star/beans/XPropertySetInfo.hpp"
#include "com/sun/star/container/ElementExistException.hpp"
#include "com/sun/star/container/NoSuchElementException.hpp"
#include "com/sun/star/container/XContainer.hpp"
#include "com/sun/star/container/XHierarchicalName.hpp"
#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
#include "com/sun/star/container/XNameContainer.hpp"
#include "com/sun/star/container/XNamed.hpp"
#include "com/sun/star/lang/IllegalArgumentException.hpp"
#include "com/sun/star/lang/NoSupportException.hpp"
#include "com/sun/star/lang/WrappedTargetException.hpp"
#include "com/sun/star/lang/XComponent.hpp"
#include "com/sun/star/lang/XServiceInfo.hpp"
#include "com/sun/star/lang/XTypeProvider.hpp"
#include "com/sun/star/lang/XSingleServiceFactory.hpp"
#include "com/sun/star/uno/Exception.hpp"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.hxx"
#include "cppuhelper/weak.hxx"
#include "osl/interlck.h"
#include "rtl/ref.hxx"
#include "sal/types.h"
#include "modifications.hxx"
#include "path.hxx"
#include "type.hxx"
namespace com { namespace sun { namespace star {
namespace beans {
class XHierarchicalPropertySetInfo;
class XPropertiesChangeListener;
class XPropertyChangeListener;
class XVetoableChangeListener;
struct Property;
}
namespace container { class XContainerListener; }
namespace lang { class XEventListener; }
namespace uno {
class Any;
class Type;
class XInterface;
}
namespace util { struct ElementChange; }
} } }
namespace rtl { class OUString; }
namespace configmgr {
class Broadcaster;
class Change;
class ChildAccess;
class Components;
class Node;
class RootAccess;
class Access:
public cppu::OWeakObject, public com::sun::star::lang::XTypeProvider,
public com::sun::star::lang::XServiceInfo,
public com::sun::star::lang::XComponent,
public com::sun::star::container::XHierarchicalNameAccess,
public com::sun::star::container::XContainer,
public com::sun::star::beans::XExactName,
public com::sun::star::beans::XPropertySetInfo,
public com::sun::star::container::XHierarchicalName,
public com::sun::star::container::XNamed,
public com::sun::star::beans::XProperty,
public com::sun::star::beans::XPropertySet,
public com::sun::star::beans::XMultiPropertySet,
public com::sun::star::beans::XHierarchicalPropertySet,
public com::sun::star::beans::XMultiHierarchicalPropertySet,
public com::sun::star::beans::XHierarchicalPropertySetInfo,
public com::sun::star::container::XNameContainer,
public com::sun::star::lang::XSingleServiceFactory,
private boost::noncopyable
{
public:
oslInterlockedCount acquireCounting();
void releaseNondeleting();
bool isValue();
void markChildAsModified(rtl::Reference< ChildAccess > const & child);
void releaseChild(rtl::OUString const & name);
virtual Path getAbsolutePath() = 0;
virtual Path getRelativePath() = 0;
virtual rtl::OUString getRelativePathRepresentation() = 0;
virtual rtl::Reference< Node > getNode() = 0;
virtual bool isFinalized() = 0;
virtual void initBroadcaster(
Modifications::Node const & modifications, Broadcaster * broadcaster);
using OWeakObject::acquire;
using OWeakObject::release;
protected:
Access(Components & components);
virtual ~Access();
virtual rtl::OUString getNameInternal() = 0;
virtual rtl::Reference< RootAccess > getRootAccess() = 0;
virtual rtl::Reference< Access > getParentAccess() = 0;
virtual void addTypes(std::vector< com::sun::star::uno::Type > * types)
const = 0;
virtual void addSupportedServiceNames(
std::vector< rtl::OUString > * services) = 0;
virtual void initDisposeBroadcaster(Broadcaster * broadcaster);
virtual void clearListeners() throw ();
virtual com::sun::star::uno::Any SAL_CALL queryInterface(
com::sun::star::uno::Type const & aType)
throw (com::sun::star::uno::RuntimeException);
Components & getComponents() const;
void checkLocalizedPropertyAccess();
rtl::Reference< Node > getParentNode();
rtl::Reference< ChildAccess > getChild(rtl::OUString const & name);
std::vector< rtl::Reference< ChildAccess > > getAllChildren();
void checkValue(
com::sun::star::uno::Any const & value, Type type, bool nillable);
void insertLocalizedValueChild(
rtl::OUString const & name, com::sun::star::uno::Any const & value,
Modifications * localModifications);
void reportChildChanges(
std::vector< com::sun::star::util::ElementChange > * changes);
void commitChildChanges(bool valid, Modifications * globalModifications);
void initBroadcasterAndChanges(
Modifications::Node const & modifications, Broadcaster * broadcaster,
std::vector< com::sun::star::util::ElementChange > * changes);
bool isDisposed() const;
private:
struct ModifiedChild {
rtl::Reference< ChildAccess > child;
bool directlyModified;
ModifiedChild();
ModifiedChild(
rtl::Reference< ChildAccess > const & theChild,
bool theDirectlyModified);
};
typedef std::map< rtl::OUString, ModifiedChild > ModifiedChildren;
virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL
getTypes() throw (com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL
getImplementationId() throw (com::sun::star::uno::RuntimeException);
virtual rtl::OUString SAL_CALL getImplementationName()
throw (com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
throw (com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException);
virtual void SAL_CALL dispose()
throw (com::sun::star::uno::RuntimeException);
virtual void SAL_CALL addEventListener(
com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >
const & xListener)
throw (com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removeEventListener(
com::sun::star::uno::Reference< com::sun::star::lang::XEventListener >
const & aListener)
throw (com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Type SAL_CALL getElementType()
throw (com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL hasElements()
throw (com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Any SAL_CALL getByName(
rtl::OUString const & aName)
throw (
com::sun::star::container::NoSuchElementException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
getElementNames() throw (com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL hasByName(rtl::OUString const & aName)
throw (com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Any SAL_CALL getByHierarchicalName(
rtl::OUString const & aName)
throw (
com::sun::star::container::NoSuchElementException,
com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL hasByHierarchicalName(rtl::OUString const & aName)
throw (com::sun::star::uno::RuntimeException);
virtual void SAL_CALL addContainerListener(
com::sun::star::uno::Reference<
com::sun::star::container::XContainerListener > const & xListener)
throw (com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removeContainerListener(
com::sun::star::uno::Reference<
com::sun::star::container::XContainerListener > const & xListener)
throw (com::sun::star::uno::RuntimeException);
virtual rtl::OUString SAL_CALL getExactName(
rtl::OUString const & aApproximateName)
throw (com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
SAL_CALL getProperties() throw (com::sun::star::uno::RuntimeException);
virtual com::sun::star::beans::Property SAL_CALL getPropertyByName(
rtl::OUString const & aName)
throw (
com::sun::star::beans::UnknownPropertyException,
com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL hasPropertyByName(rtl::OUString const & Name)
throw (com::sun::star::uno::RuntimeException);
virtual rtl::OUString SAL_CALL getHierarchicalName()
throw (com::sun::star::uno::RuntimeException);
virtual rtl::OUString SAL_CALL composeHierarchicalName(
rtl::OUString const & aRelativeName)
throw (
com::sun::star::lang::IllegalArgumentException,
com::sun::star::lang::NoSupportException,
com::sun::star::uno::RuntimeException);
virtual rtl::OUString SAL_CALL getName()
throw (com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setName(rtl::OUString const & aName)
throw (com::sun::star::uno::RuntimeException);
virtual com::sun::star::beans::Property SAL_CALL getAsProperty()
throw (com::sun::star::uno::RuntimeException);
virtual
com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >
SAL_CALL getPropertySetInfo() throw (com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setPropertyValue(
rtl::OUString const & aPropertyName,
com::sun::star::uno::Any const & aValue)
throw (
com::sun::star::beans::UnknownPropertyException,
com::sun::star::beans::PropertyVetoException,
com::sun::star::lang::IllegalArgumentException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Any SAL_CALL getPropertyValue(
rtl::OUString const & PropertyName)
throw (
com::sun::star::beans::UnknownPropertyException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual void SAL_CALL addPropertyChangeListener(
rtl::OUString const & aPropertyName,
com::sun::star::uno::Reference<
com::sun::star::beans::XPropertyChangeListener > const & xListener)
throw (
com::sun::star::beans::UnknownPropertyException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removePropertyChangeListener(
rtl::OUString const & aPropertyName,
com::sun::star::uno::Reference<
com::sun::star::beans::XPropertyChangeListener > const & aListener)
throw (
com::sun::star::beans::UnknownPropertyException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual void SAL_CALL addVetoableChangeListener(
rtl::OUString const & PropertyName,
com::sun::star::uno::Reference<
com::sun::star::beans::XVetoableChangeListener > const & aListener)
throw (
com::sun::star::beans::UnknownPropertyException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removeVetoableChangeListener(
rtl::OUString const & PropertyName,
com::sun::star::uno::Reference<
com::sun::star::beans::XVetoableChangeListener > const & aListener)
throw (
com::sun::star::beans::UnknownPropertyException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setPropertyValues(
com::sun::star::uno::Sequence< rtl::OUString > const & aPropertyNames,
com::sun::star::uno::Sequence< com::sun::star::uno::Any > const &
aValues)
throw (
com::sun::star::beans::PropertyVetoException,
com::sun::star::lang::IllegalArgumentException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Sequence< com::sun::star::uno::Any > SAL_CALL
getPropertyValues(
com::sun::star::uno::Sequence< rtl::OUString > const & aPropertyNames)
throw (com::sun::star::uno::RuntimeException);
virtual void SAL_CALL addPropertiesChangeListener(
com::sun::star::uno::Sequence< rtl::OUString > const & aPropertyNames,
com::sun::star::uno::Reference<
com::sun::star::beans::XPropertiesChangeListener > const &
xListener)
throw (com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removePropertiesChangeListener(
com::sun::star::uno::Reference<
com::sun::star::beans::XPropertiesChangeListener > const &
xListener)
throw (com::sun::star::uno::RuntimeException);
virtual void SAL_CALL firePropertiesChangeEvent(
com::sun::star::uno::Sequence< rtl::OUString > const & aPropertyNames,
com::sun::star::uno::Reference<
com::sun::star::beans::XPropertiesChangeListener > const &
xListener)
throw (com::sun::star::uno::RuntimeException);
virtual
com::sun::star::uno::Reference<
com::sun::star::beans::XHierarchicalPropertySetInfo > SAL_CALL
getHierarchicalPropertySetInfo()
throw (com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setHierarchicalPropertyValue(
rtl::OUString const & aHierarchicalPropertyName,
com::sun::star::uno::Any const & aValue)
throw (
com::sun::star::beans::UnknownPropertyException,
com::sun::star::beans::PropertyVetoException,
com::sun::star::lang::IllegalArgumentException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Any SAL_CALL getHierarchicalPropertyValue(
rtl::OUString const & aHierarchicalPropertyName)
throw (
com::sun::star::beans::UnknownPropertyException,
com::sun::star::lang::IllegalArgumentException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setHierarchicalPropertyValues(
com::sun::star::uno::Sequence< rtl::OUString > const &
aHierarchicalPropertyNames,
com::sun::star::uno::Sequence< com::sun::star::uno::Any > const &
Values)
throw (
com::sun::star::beans::PropertyVetoException,
com::sun::star::lang::IllegalArgumentException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Sequence< com::sun::star::uno::Any > SAL_CALL
getHierarchicalPropertyValues(
com::sun::star::uno::Sequence< rtl::OUString > const &
aHierarchicalPropertyNames)
throw (
com::sun::star::lang::IllegalArgumentException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual com::sun::star::beans::Property SAL_CALL
getPropertyByHierarchicalName(rtl::OUString const & aHierarchicalName)
throw (
com::sun::star::beans::UnknownPropertyException,
com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL hasPropertyByHierarchicalName(
rtl::OUString const & aHierarchicalName)
throw (com::sun::star::uno::RuntimeException);
virtual void SAL_CALL replaceByName(
rtl::OUString const & aName, com::sun::star::uno::Any const & aElement)
throw (
com::sun::star::lang::IllegalArgumentException,
com::sun::star::container::NoSuchElementException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual void SAL_CALL insertByName(
rtl::OUString const & aName, com::sun::star::uno::Any const & aElement)
throw (
com::sun::star::lang::IllegalArgumentException,
com::sun::star::container::ElementExistException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removeByName(rtl::OUString const & aName)
throw (
com::sun::star::container::NoSuchElementException,
com::sun::star::lang::WrappedTargetException,
com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
SAL_CALL createInstance()
throw (
com::sun::star::uno::Exception,
com::sun::star::uno::RuntimeException);
virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
SAL_CALL createInstanceWithArguments(
com::sun::star::uno::Sequence< com::sun::star::uno::Any > const &
aArguments)
throw (
com::sun::star::uno::Exception,
com::sun::star::uno::RuntimeException);
rtl::Reference< ChildAccess > getModifiedChild(
ModifiedChildren::iterator const & childIterator);
rtl::Reference< ChildAccess > getUnmodifiedChild(
rtl::OUString const & name);
rtl::Reference< ChildAccess > getSubChild(rtl::OUString const & path);
bool setChildProperty(
rtl::OUString const & name, com::sun::star::uno::Any const & value,
Modifications * localModifications);
com::sun::star::beans::Property asProperty();
void checkFinalized();
void checkKnownProperty(rtl::OUString const & descriptor);
rtl::Reference< ChildAccess > getFreeSetMember(
com::sun::star::uno::Any const & value);
rtl::Reference< Access > getNotificationRoot();
typedef std::map< rtl::OUString, ChildAccess * > WeakChildMap;
typedef
std::multiset<
com::sun::star::uno::Reference<
com::sun::star::lang::XEventListener > >
DisposeListeners;
typedef
std::multiset<
com::sun::star::uno::Reference<
com::sun::star::container::XContainerListener > >
ContainerListeners;
typedef
std::multiset<
com::sun::star::uno::Reference<
com::sun::star::beans::XPropertyChangeListener > >
PropertyChangeListenersElement;
typedef std::map< rtl::OUString, PropertyChangeListenersElement >
PropertyChangeListeners;
typedef
std::multiset<
com::sun::star::uno::Reference<
com::sun::star::beans::XVetoableChangeListener > >
VetoableChangeListenersElement;
typedef std::map< rtl::OUString, VetoableChangeListenersElement >
VetoableChangeListeners;
typedef
std::multiset<
com::sun::star::uno::Reference<
com::sun::star::beans::XPropertiesChangeListener > >
PropertiesChangeListeners;
Components & components_;
ModifiedChildren modifiedChildren_;
WeakChildMap cachedChildren_;
DisposeListeners disposeListeners_;
ContainerListeners containerListeners_;
PropertyChangeListeners propertyChangeListeners_;
VetoableChangeListeners vetoableChangeListeners_;
PropertiesChangeListeners propertiesChangeListeners_;
bool disposed_;
#if OSL_DEBUG_LEVEL > 0
protected:
enum {
IS_ANY = 0, IS_GROUP = 0x01, IS_SET = 0x02, IS_EXTENSIBLE = 0x04,
IS_GROUP_MEMBER = 0x08, IS_SET_MEMBER = 0x10, IS_UPDATE = 0x20 };
bool thisIs(int what);
#endif
};
}
#endif
-302
View File
@@ -1,302 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 <stdio.h>
#include <string.h>
#include "confevents.hxx"
#include "configexcept.hxx"
#include "treechangelist.hxx"
#include <osl/diagnose.h>
namespace configmgr
{
/////////////////////////////////////////////////////////////////////////
ConfigChangeBroadcastHelper::ConfigChangeBroadcastHelper()
{
}
ConfigChangeBroadcastHelper::~ConfigChangeBroadcastHelper()
{
OSL_ENSURE(m_aListeners.begin() == m_aListeners.end(), "Remaining listeners found - forgot to dispose ?");
OSL_ENSURE(m_aPathMap.empty(), "Spurious mappings found");
}
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcastHelper::dispose(TreeManager * pSource)
{
disposing(pSource);
}
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcastHelper::addListener(configuration::AbsolutePath const& aName, rtl::Reference<INodeListener> const& pHandler)
{
add(aName, pHandler);
}
void ConfigChangeBroadcastHelper::removeListener(rtl::Reference<INodeListener> const& pHandler)
{
remove(pHandler);
}
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcastHelper::broadcast(TreeChangeList const& anUpdate, sal_Bool bError, TreeManager * pSource)
{
dispatch(anUpdate, bError, pSource);
}
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcastHelper::add(configuration::AbsolutePath const& aName, rtl::Reference<INodeListener> const& pListener)
{
osl::MutexGuard aGuard(m_aListeners.mutex);
internal::BroadcastImplHelper<internal::NodeListenerInfo>::Interfaces::iterator aAdded = m_aListeners.addListener(internal::NodeListenerInfo(pListener));
aAdded->addPath(aName);
m_aPathMap.insert(PathMap::value_type(aName,aAdded));
}
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcastHelper::remove(rtl::Reference<INodeListener> const& pListener)
{
osl::MutexGuard aGuard(m_aListeners.mutex);
internal::BroadcastImplHelper<internal::NodeListenerInfo>::Interfaces::const_iterator const iter = m_aListeners.find(pListener);
if (iter != m_aListeners.end())
{
internal::NodeListenerInfo::Pathes const& pathes = iter->pathList();
// first clear the Path Map
for(internal::NodeListenerInfo::Pathes::iterator itPath = pathes.begin(); itPath != pathes.end(); ++itPath)
{
std::pair<PathMap::iterator, PathMap::iterator> aRange = m_aPathMap.equal_range(*itPath);
while (aRange.first != aRange.second)
{
PathMap::iterator cur = aRange.first++;
if (cur->second == iter)
m_aPathMap.erase(cur);
}
}
// the remove the broadcast helper entry
m_aListeners.removeListener(pListener);
}
}
/////////////////////////////////////////////////////////////////////////
// This should actually be available from the TreeChangeList
/////////////////////////////////////////////////////////////////////////
static Change const* resolvePath(Change const& rChange, configuration::RelativePath& aRelativePath, RemoveNode const*& pRemoveNode)
{
std::vector<configuration::Path::Component>::const_reverse_iterator aIter;
OSL_ASSERT(pRemoveNode == NULL);
pRemoveNode = NULL;
Change const* pChange = &rChange;
pRemoveNode = dynamic_cast<RemoveNode const*>(pChange);
std::vector<configuration::Path::Component>::const_reverse_iterator const aEnd(aRelativePath.end());
for( aIter = aRelativePath.begin();
aIter != aEnd;
++aIter)
{
OSL_ASSERT( pChange != NULL );
pChange = pChange->getSubChange(aIter->getName());
if (pChange == NULL) break;
OSL_ASSERT(pRemoveNode == NULL);
OSL_ASSERT(aIter->getName() == pChange->getNodeName());
pRemoveNode = dynamic_cast<RemoveNode const*>(pChange);
}
if (pRemoveNode)
{
aRelativePath = configuration::RelativePath( configuration::Path::Rep(aRelativePath.begin(),aIter) );
OSL_ASSERT( aRelativePath.getLocalName().getName() == pRemoveNode->getNodeName());
}
else
OSL_ASSERT( pChange == 0 || configuration::matches(aRelativePath, configuration::RelativePath( configuration::Path::Rep(aRelativePath.begin(),aIter) )) );
return pChange;
}
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcastHelper::dispatchInner
(
rtl::Reference<INodeListener> const& pTarget,
configuration::AbsolutePath const& _aTargetPath,
Change const& rBaseChange,
configuration::AbsolutePath const& _aChangeLocation,
sal_Bool , //_bError,
TreeManager * pSource
)
{
try
{
OSL_ASSERT(pTarget.is());
OSL_ASSERT( configuration::Path::hasPrefix( _aTargetPath, _aChangeLocation ) );
configuration::RelativePath aLocalPath = configuration::Path::stripPrefix( _aTargetPath, _aChangeLocation );
RemoveNode const* pRemoved = 0;
Change const* pTargetChange = resolvePath(rBaseChange, aLocalPath, pRemoved );
OSL_ASSERT( !pTargetChange || matches(_aChangeLocation.compose(aLocalPath),_aTargetPath) );
if (pRemoved)
pTarget->nodeDeleted(_aChangeLocation.compose(aLocalPath), pSource);
else if (pTargetChange)
pTarget->nodeChanged(*pTargetChange, _aTargetPath, pSource);
}
catch (configuration::InvalidName& )
{
OSL_ENSURE(false,"ConfigChangeBroadcastHelper: Could not dispatch notification: context path mismatch");
}
}
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcastHelper::dispatchOuter
(
rtl::Reference<INodeListener> const& pTarget,
configuration::AbsolutePath const& _aTargetPath,
Change const& rBaseChange,
configuration::AbsolutePath const& _aChangeLocation,
sal_Bool , //_bError,
TreeManager * pSource
)
{
{ (void)_aTargetPath; }
OSL_ASSERT(pTarget.is());
OSL_ASSERT( configuration::Path::hasPrefix( _aChangeLocation, _aTargetPath) );
pTarget->nodeChanged(rBaseChange, _aChangeLocation, pSource);
}
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcastHelper::dispatch(TreeChangeList const& rList_, sal_Bool _bError, TreeManager * pSource)
{
dispatch(rList_.root, rList_.getRootNodePath(),_bError, pSource);
}
/////////////////////////////////////////////////////////////////////////
namespace
{
struct DispatchTarget
{
DispatchTarget(rtl::Reference<INodeListener> _pTarget, configuration::AbsolutePath const* _pDispatchPath)
: pTarget(_pTarget), pDispatchPath( _pDispatchPath) {}
rtl::Reference<INodeListener> pTarget;
configuration::AbsolutePath const* pDispatchPath;
};
}
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcastHelper::dispatch
(
Change const& rBaseChange,
configuration::AbsolutePath const& _aChangeLocation,
sal_Bool _bError,
TreeManager * pSource
)
{
OSL_ENSURE(!_aChangeLocation.isRoot(),"Cannot dispatch changes directly to the root node");
// listeners registered under multiple sub-pathes will be called multiple times !
// Collect the targets
osl::ClearableMutexGuard aGuard(m_aListeners.mutex);
// Dispatch listeners to ancestors of the change root
std::vector<DispatchTarget> aOuterTargets;
if (_aChangeLocation.getDepth() > 1)
{
configuration::AbsolutePath const aModulePath( configuration::Path::Rep(*_aChangeLocation.begin()) );
PathMap::const_iterator itOuter = m_aPathMap.lower_bound( aModulePath );
PathMap::const_iterator const endOuter = m_aPathMap.upper_bound(_aChangeLocation.getParentPath());
// TODO: Both loops are so similar - they should be a single function
while (itOuter != endOuter)
{
OSL_ASSERT( m_aListeners.find(itOuter->second->get()) != m_aListeners.end() );
// check whether this should be dispatched at all
if ( configuration::Path::hasPrefix(_aChangeLocation,itOuter->first) )
{
aOuterTargets.push_back( DispatchTarget(itOuter->second->get(), &itOuter->first) );
}
++itOuter;
}
}
// Dispatch listeners to descendants of the change root
std::vector<DispatchTarget> aInnerTargets;
{
PathMap::const_iterator itInner = m_aPathMap.lower_bound(_aChangeLocation);
while( itInner != m_aPathMap.end() && configuration::Path::hasPrefix(itInner->first,_aChangeLocation) )
{
OSL_ASSERT( m_aListeners.find(itInner->second->get()) != m_aListeners.end() );
aInnerTargets.push_back( DispatchTarget(itInner->second->get(), &itInner->first) );
++itInner;
}
}
aGuard.clear();
{for (std::vector<DispatchTarget>::const_iterator it = aOuterTargets.begin(); it != aOuterTargets.end(); ++it){
this->dispatchOuter(it->pTarget, *it->pDispatchPath, rBaseChange, _aChangeLocation, _bError, pSource);
}}
{for (std::vector<DispatchTarget>::const_iterator it = aInnerTargets.begin(); it != aInnerTargets.end(); ++it){
this->dispatchInner(it->pTarget, *it->pDispatchPath, rBaseChange, _aChangeLocation, _bError, pSource);
}}
}
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcastHelper::disposing(TreeManager * pSource)
{
osl::ClearableMutexGuard aGuard(m_aListeners.mutex);
m_aPathMap.clear();
aGuard.clear();
m_aListeners.disposing(pSource);
}
} // namespace
-100
View File
@@ -1,100 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "confsvccomponent.hxx"
#include "datalock.hxx"
#include <com/sun/star/lang/DisposedException.hpp>
#include <cppuhelper/typeprovider.hxx>
#include <osl/mutex.hxx>
#include "utility.hxx"
#include <map>
namespace configmgr {
ServiceComponentImpl::ServiceComponentImpl(ServiceImplementationInfo const* aInfo)
: ::cppu::WeakComponentImplHelper1< lang::XServiceInfo >(UnoApiLock::getLock())
, m_info(aInfo)
{
}
void ServiceComponentImpl::disposing()
{
::cppu::WeakComponentImplHelper1< lang::XServiceInfo >::disposing();
}
void ServiceComponentImpl::checkAlive() throw (uno::RuntimeException)
{
checkAlive("Object was disposed");
}
void ServiceComponentImpl::checkAlive(rtl::OUString const& sMessage) throw (uno::RuntimeException)
{
if (rBHelper.bDisposed)
throw lang::DisposedException(sMessage, *this);
}
// XTypeProvider
uno::Sequence<sal_Int8> ServiceComponentImpl::getStaticImplementationId(ServiceImplementationInfo const* pServiceInfo)
throw(uno::RuntimeException)
{
static osl::Mutex aMapMutex;
static std::map<ServiceImplementationInfo const*, ::cppu::OImplementationId> aIdMap;
osl::MutexGuard aMapGuard(aMapMutex);
return aIdMap[pServiceInfo].getImplementationId();
}
uno::Sequence<sal_Int8> SAL_CALL ServiceComponentImpl::getImplementationId()
throw(uno::RuntimeException)
{
return getStaticImplementationId(m_info);
}
// XServiceInfo
rtl::OUString SAL_CALL ServiceComponentImpl::getImplementationName( ) throw(uno::RuntimeException)
{
return ServiceInfoHelper(m_info).getImplementationName();
}
sal_Bool SAL_CALL ServiceComponentImpl::supportsService( const ::rtl::OUString& ServiceName ) throw(uno::RuntimeException)
{
return ServiceInfoHelper(m_info).supportsService( ServiceName );
}
uno::Sequence< rtl::OUString > SAL_CALL ServiceComponentImpl::getSupportedServiceNames( ) throw(uno::RuntimeException)
{
return ServiceInfoHelper(m_info).getSupportedServiceNames( );
}
//ServiceComponentImpl::
} // namespace configmgr
-804
View File
@@ -1,804 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 <stdio.h>
#include "accessimpl.hxx"
#include "apinodeaccess.hxx"
#include "valueref.hxx"
#include "anynoderef.hxx"
#include "noderef.hxx"
#include "configset.hxx"
#include "confignotifier.hxx"
#include "propertyinfohelper.hxx"
#include "treeiterators.hxx"
#include "attributes.hxx"
#include "apitypes.hxx"
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/WrappedTargetException.hpp>
#include <com/sun/star/beans/PropertyVetoException.hpp>
#include <osl/diagnose.h>
#include <rtl/logfile.hxx>
#define RTL_LOGFILE_OU2A(rtlOUString) (::rtl::OString((rtlOUString).getStr(), (rtlOUString).getLength(), RTL_TEXTENCODING_ASCII_US).getStr())
namespace configmgr
{
namespace configapi
{
//-----------------------------------------------------------------------------------
namespace lang = css::lang;
namespace util = css::util;
//-----------------------------------------------------------------------------------
// Constructors
//-----------------------------------------------------------------------------------
// Interface methods
//-----------------------------------------------------------------------------------
// XHierarchicalName
//------------------------------------------------------------------------------------------------------------------
rtl::OUString implGetHierarchicalName( NodeAccess& rNode ) throw(uno::RuntimeException)
{
// RTL_LOGFILE_CONTEXT(aLog, "Configmgr::API::implGetHierarchicalName()");
rtl::OUString sRet;
try
{
GuardedNodeData<NodeAccess> lock( rNode );
rtl::Reference< configuration::Tree > aTree( lock.getTree());
configuration::AbsolutePath const aFullPath = aTree->getAbsolutePath(lock.getNode());
sRet = aFullPath.toString();
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
return sRet;
}
//------------------------------------------------------------------------------------------------------------------
rtl::OUString implComposeHierarchicalName(NodeGroupInfoAccess& rNode, const rtl::OUString& sRelativeName )
throw(css::lang::IllegalArgumentException, lang::NoSupportException, uno::RuntimeException)
{
rtl::OUString sRet;
try
{
GuardedNodeData<NodeAccess> lock( rNode );
configuration::NodeRef aNode( lock.getNode() );
rtl::Reference< configuration::Tree > aTree( lock.getTree() );
configuration::RelativePath const aAddedPath = configuration::validateRelativePath(sRelativeName, aTree, aNode);
// TODO: add (relative) name validation based on node type - may then need provider lock
configuration::AbsolutePath const aFullPath = aTree->getAbsolutePath(aNode).compose(aAddedPath);
sRet = aFullPath.toString();
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.illegalArgument(1);
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
return sRet;
}
//------------------------------------------------------------------------------------------------------------------
rtl::OUString implComposeHierarchicalName(NodeSetInfoAccess& rNode, const rtl::OUString& sElementName )
throw(css::lang::IllegalArgumentException, lang::NoSupportException, uno::RuntimeException)
{
rtl::OUString sRet;
try
{
GuardedNodeData<NodeAccess> lock( rNode );
configuration::NodeRef aNode( lock.getNode() );
rtl::Reference< configuration::Tree > aTree( lock.getTree() );
configuration::Path::Component const aAddedName = configuration::validateElementPathComponent(sElementName, aTree, aNode);
// TODO: add (relative) name validation based on node type - may then need provider lock
configuration::AbsolutePath const aFullPath = aTree->getAbsolutePath(aNode).compose(aAddedName);
sRet = aFullPath.toString();
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.illegalArgument(1);
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
return sRet;
}
//------------------------------------------------------------------------------------------------------------------
// XElementAccess, base class of XNameAccess (and XHierarchicalNameAccess ? )
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// for group nodes
uno::Type implGetElementType(NodeGroupInfoAccess& rNode) throw(uno::RuntimeException)
{
rNode.checkAlive();
// group nodes have a mix of types
// TODO(?): Discover single common type
return ::getCppuType( static_cast< uno::Any const*>(0) );
}
// for set nodes
uno::Type implGetElementType(NodeSetInfoAccess& rNode) throw(uno::RuntimeException)
{
uno::Type aRet;
try
{
GuardedNodeData<NodeSetInfoAccess> lock( rNode );
aRet = rNode.getElementInfo()->getInstanceType();
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
return aRet;
}
//-----------------------------------------------------------------------------------
// for group nodes
sal_Bool implHasElements(NodeGroupInfoAccess& rNode) throw(uno::RuntimeException)
{
// rNode.checkAlive();
// return true; // group nodes always have children
// Better: cater for the case where we are reaching the depth limit
try
{
GuardedNodeData<NodeAccess> lock( rNode ); // no provider lock needed
rtl::Reference< configuration::Tree > aThisTree( lock.getTree() );
configuration::NodeRef aThisNode( lock.getNode() );
OSL_ASSERT( !aThisTree->hasElements(aThisNode) );
return aThisTree->hasChildren(aThisNode);
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
// unreachable, but still there to make compiler happy
OSL_ASSERT(!"Unreachable code");
return false;
}
// for set nodes
sal_Bool implHasElements(NodeSetInfoAccess& rNode) throw(uno::RuntimeException)
{
try
{
GuardedNodeData<NodeAccess> lock( rNode ); // provider lock needed
rtl::Reference< configuration::Tree > aThisTree( lock.getTree() );
configuration::NodeRef aThisNode( lock.getNode() );
OSL_ASSERT( !aThisTree->hasChildren(aThisNode) );
return aThisTree->hasElements(aThisNode);
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
// unreachable, but still there to make compiler happy
OSL_ASSERT(!"Unreachable code");
return false;
}
// XExactName
//-----------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
namespace internal
{
struct SearchExactName : private configuration::NodeVisitor
{
protected:
// warning: order dependency
configuration::RelativePath aSearchPath;
std::vector<configuration::Path::Component>::reverse_iterator pSearchComponent;
public:
explicit
SearchExactName(const configuration::RelativePath& aLookFor)
: aSearchPath(aLookFor)
, pSearchComponent(aSearchPath.begin_mutate())
{}
bool complete() { return aSearchPath.end_mutate() == pSearchComponent; }
bool search(configuration::NodeRef const& aNode, rtl::Reference< configuration::Tree > const& aTree);
configuration::RelativePath const& getBestMatch() const { return aSearchPath; }
private:
bool findMatch(configuration::NodeRef& aNode, rtl::Reference< configuration::Tree > & aTree);
virtual Result handle(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const&); // NodeVisitor
virtual Result handle(rtl::Reference< configuration::Tree > const& aTree, configuration::ValueRef const&); // NodeVisitor
};
//..................................................................................................................
bool SearchExactName::findMatch(configuration::NodeRef& aNode, rtl::Reference< configuration::Tree > & aTree)
{
OSL_ASSERT( !complete() );
if ( !aNode.isValid() ) return false;
// exact match ?
if (!configuration::hasChildOrElement(aTree,aNode,*pSearchComponent))
{
if (aTree->dispatchToChildren(aNode,*this) == CONTINUE) // not found there
return false;
}
OSL_ASSERT(configuration::hasChildOrElement(aTree,aNode,*pSearchComponent));
if (! configuration::findInnerChildOrAvailableElement(aTree,aNode,pSearchComponent->getName()) )
aNode = configuration::NodeRef(); // will stop recursion (value or unloaded element found)
++pSearchComponent;
return true;
}
//..................................................................................................................
// helper
static configuration::Path::Component getExtendedNodeName(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode, rtl::OUString const& aSimpleNodeName)
{
OSL_PRECOND( !configuration::isEmpty(aTree.get()), "ERROR: Configuration: Tree operation requires valid tree" );
OSL_PRECOND( !aNode.isValid() || aTree->isValidNode(aNode.getOffset()), "ERROR: Configuration: NodeRef does not match tree" );
if (aTree->isRootNode(aNode))
return aTree->getExtendedRootName();
else
return configuration::Path::wrapSimpleName(aSimpleNodeName);
}
//..................................................................................................................
configuration::NodeVisitor::Result SearchExactName::handle(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode)
{
OSL_ASSERT( aNode.isValid() );
OSL_ASSERT( !complete() );
// find inexact match (the first one, but the order is unspecified)
// TODO: Add support for node-type-specific element names
rtl::OUString aNodeName = aTree->getSimpleNodeName(aNode.getOffset());
rtl::OUString aSearchName = pSearchComponent->getName();
if (aNodeName.equalsIgnoreAsciiCase(aSearchName))
{
*pSearchComponent = getExtendedNodeName(aTree,aNode,aNodeName);
return DONE; // for this level
}
else
return CONTINUE;
}
//..................................................................................................................
configuration::NodeVisitor::Result SearchExactName::handle(rtl::Reference< configuration::Tree > const&, configuration::ValueRef const& aNode)
{
OSL_ASSERT( aNode.isValid() );
OSL_ASSERT( !complete() );
// find inexact match (the first one, but the order is unspecified)
// TODO: Add support for node-type-specific element names
rtl::OUString aNodeName = aNode.m_sNodeName;
OSL_ASSERT( configuration::isSimpleName(aNodeName) );
// value refs are group members and thus have to have simple names
if (aNodeName.equalsIgnoreAsciiCase(pSearchComponent->getName()))
{
*pSearchComponent = configuration::Path::wrapSimpleName(aNodeName);
return DONE; // for this level
}
else
return CONTINUE;
}
//..................................................................................................................
bool SearchExactName::search(configuration::NodeRef const & aNode, rtl::Reference< configuration::Tree > const & aTree)
{
if (!aNode.isValid()) return false;
rtl::Reference< configuration::Tree > aSearchTree(aTree);
configuration::NodeRef aSearchNode(aNode);
while (!complete())
if (! findMatch(aSearchNode, aSearchTree))
break;
return complete();
}
} // namespace internal
//..................................................................................................................
rtl::OUString implGetExactName(NodeGroupInfoAccess& rNode, const rtl::OUString& rApproximateName ) throw(uno::RuntimeException)
{
// here we try to support both tree-fragment-local pathes and simple names (the latter ones are just an instance of the first)
try
{
GuardedNodeData<NodeAccess> lock( rNode );
rtl::Reference< configuration::Tree > aTree(lock.getTree());
configuration::NodeRef aNode(lock.getNode());
configuration::RelativePath aApproximatePath = configuration::validateRelativePath(rApproximateName,aTree,aNode);
internal::SearchExactName aSearch(aApproximatePath);
aSearch.search(aNode, aTree);
OSL_ENSURE( aSearch.getBestMatch().getDepth() == aApproximatePath.getDepth(),
"Search for exact names changed number of path components !?");
return aSearch.getBestMatch().toString();
}
catch (configuration::InvalidName& )
{
OSL_TRACE("WARNING: Configuration::getExactName: query uses locally invalid Path");
return rApproximateName;
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
// unreachable, but still there to make compiler happy
OSL_ASSERT(!"Unreachable code");
return rApproximateName;
}
//..................................................................................................................
rtl::OUString implGetExactName(NodeSetInfoAccess& rNode, const rtl::OUString& rApproximateName ) throw(uno::RuntimeException)
{
// here we can support only local names
try
{
GuardedNodeData<NodeAccess> lock( rNode );
rtl::Reference< configuration::Tree > aTree(lock.getTree());
configuration::NodeRef aNode(lock.getNode());
configuration::Path::Component aApproximateName = configuration::validateElementPathComponent(rApproximateName,aTree,aNode);
internal::SearchExactName aSearch(aApproximateName);
aSearch.search(aNode, aTree);
OSL_ENSURE( aSearch.getBestMatch().getDepth() == 1,
"Search for exact names changed number of path components !?");
return aSearch.getBestMatch().getLocalName().getName();
}
catch (configuration::InvalidName& )
{
OSL_TRACE("WARNING: Configuration::getExactName: query uses locally invalid Path");
return rApproximateName;
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
// unreachable, but still there to make compiler happy
OSL_ASSERT(!"Unreachable code");
return rApproximateName;
}
// XProperty
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
beans::Property implGetAsProperty(NodeAccess& rNode)
throw(uno::RuntimeException)
{
try
{
GuardedNodeData<NodeAccess> lock( rNode );
rtl::Reference< configuration::Tree > aTree( lock.getTree());
configuration::NodeRef aNode( lock.getNode());
rtl::OUString aName = aTree->getSimpleNodeName(aNode.getOffset());
node::Attributes aAttributes = aTree->getAttributes(aNode);
uno::Type aApiType = getUnoInterfaceType();
return helperMakeProperty( aName,aAttributes,aApiType, aTree->hasNodeDefault(aNode) );
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
// unreachable, but still there to make some compilers happy
OSL_ASSERT(!"Unreachable code");
return beans::Property();
}
// XPropertySetInfo
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
uno::Sequence< css::beans::Property > implGetProperties( NodeAccess& rNode ) throw (uno::RuntimeException)
{
CollectPropertyInfo aCollect;
try
{
GuardedNodeData<NodeAccess> lock( rNode );
lock.getTree()->dispatchToChildren(lock.getNode(), aCollect);
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
return makeSequence( aCollect.list() );
}
//-----------------------------------------------------------------------------------
css::beans::Property implGetPropertyByName( NodeAccess& rNode, const rtl::OUString& aName )
throw (css::beans::UnknownPropertyException, uno::RuntimeException)
{
try
{
GuardedNodeData<NodeAccess> lock( rNode );
rtl::Reference< configuration::Tree > aTree( lock.getTree() );
configuration::NodeRef const aNode( lock.getNode() );
rtl::OUString aChildName = configuration::validateChildOrElementName(aName,aTree,aNode);
configuration::AnyNodeRef aChildNode = configuration::getChildOrElement(aTree,aNode, aChildName);
if (!aChildNode.isValid())
{
OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Property not found by implementation");
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Property. Property '") );
sMessage += aName;
sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' could not be found in ") );
sMessage += aTree->getAbsolutePath(aNode).toString();
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw css::beans::UnknownPropertyException( sMessage, xContext );
}
node::Attributes aChildAttributes = aTree->getAttributes(aChildNode);
uno::Type aApiType = aChildNode.isNode() ? getUnoInterfaceType() : aTree->getUnoType(aChildNode.toValue());
return helperMakeProperty( aChildName,aChildAttributes,aApiType, aTree->hasNodeDefault(aChildNode) );
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw css::beans::UnknownPropertyException( e.message(), xContext );
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
// unreachable, but still there to make some compilers happy
OSL_ASSERT(!"Unreachable code");
return css::beans::Property();
}
//-----------------------------------------------------------------------------------
sal_Bool implHasPropertyByName( NodeAccess& rNode, const rtl::OUString& name ) throw (uno::RuntimeException)
{
return implHasByName(rNode, name);
}
// XNameAccess
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// TODO: optimization - cache the node found (for subsequent getByName)
// TODO: optimization - less locking for group nodes
//-----------------------------------------------------------------------------------
sal_Bool implHasByName(NodeAccess& rNode, const rtl::OUString& sName ) throw(uno::RuntimeException)
{
try
{
GuardedNodeData<NodeAccess> lock( rNode );
rtl::OUString aChildName(sName);
return configuration::hasChildOrElement(lock.getTree(), lock.getNode(), aChildName);
}
#if OSL_DEBUG_LEVEL > 0
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
OSL_ENSURE(false,"configmgr: BasicAccess::hasByName: Unexpected exception <InvalidName>");
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
#endif
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
// unreachable, but still there to make compiler happy
OSL_ASSERT(!"Unreachable code");
return false;
}
//-----------------------------------------------------------------------------------
uno::Any implGetByName(NodeAccess& rNode, const rtl::OUString& sName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
{
try
{
GuardedNodeData<NodeAccess> lock( rNode );
rtl::Reference< configuration::Tree > aTree( lock.getTree() );
configuration::NodeRef aNode( lock.getNode() );
rtl::OUString aChildName = configuration::validateChildOrElementName(sName,aTree,aNode);
configuration::AnyNodeRef aChildNode = configuration::getChildOrElement(aTree,aNode, aChildName);
if (!aChildNode.isValid())
{
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Child Element '") );
sMessage += sName;
sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
sMessage += aTree->getAbsolutePath(aNode).toString();
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw com::sun::star::container::NoSuchElementException( sMessage, xContext );
}
OSL_ASSERT(aNode.isValid());
return configapi::makeElement( rNode.getFactory(), aTree, aChildNode );
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw com::sun::star::container::NoSuchElementException( e.message(), xContext );
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
// unreachable, but still there to make some compilers happy
OSL_ASSERT(!"Unreachable code");
return uno::Any();
}
//-----------------------------------------------------------------------------------
// TODO: optimization - less locking for group nodes
//-----------------------------------------------------------------------------------
uno::Sequence< rtl::OUString > implGetElementNames( NodeAccess& rNode ) throw( uno::RuntimeException)
{
CollectNodeNames aCollect;
try
{
GuardedNodeData<NodeAccess> lock( rNode );
lock.getTree()->dispatchToChildren(lock.getNode(), aCollect);
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
return makeSequence( aCollect.list() );
}
// XHierarchicalNameAccess
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// TO DO: optimization - cache the node found for subsequent getByHierarchicalName()
//-----------------------------------------------------------------------------------
sal_Bool implHasByHierarchicalName(NodeAccess& rNode, const rtl::OUString& sHierarchicalName ) throw(uno::RuntimeException)
{
try
{
GuardedNodeData<NodeAccess> lock( rNode );
rtl::Reference< configuration::Tree > aTree( lock.getTree() );
configuration::NodeRef aNode( lock.getNode() );
configuration::RelativePath aRelPath = configuration::validateAndReducePath( sHierarchicalName, aTree, aNode );
return configuration::getDeepDescendant(aTree, aNode, aRelPath).isValid();
}
catch (configuration::InvalidName& )
{
OSL_TRACE("WARNING: Configuration::hasByHierarchicalName: query uses locally invalid Path");
return false;
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
// unreachable, but still there to make some compilers happy
OSL_ASSERT(!"Unreachable code");
return false;
}
//-----------------------------------------------------------------------------------
uno::Any implGetByHierarchicalName(NodeAccess& rNode, const rtl::OUString& sHierarchicalName )
throw(css::container::NoSuchElementException, uno::RuntimeException)
{
// rtl::OUString aTmpStr(implGetHierarchicalName(rNode));
// RTL_LOGFILE_CONTEXT_TRACE2(aLog, "Node: %s HierachicalName: %s",RTL_LOGFILE_OU2A(aTmpStr), RTL_LOGFILE_OU2A(sHierarchicalName));
try
{
GuardedNodeData<NodeAccess> lock( rNode );
rtl::Reference< configuration::Tree > aTree( lock.getTree() );
configuration::NodeRef aNode( lock.getNode() );
configuration::RelativePath aRelPath = configuration::validateAndReducePath( sHierarchicalName, aTree, aNode );
configuration::AnyNodeRef aNestedNode = configuration::getDeepDescendant( aTree, aNode, aRelPath );
if (!aNestedNode.isValid())
{
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Descendant Element '") );
sMessage += aRelPath.toString();
sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Node ") );
sMessage += aTree->getAbsolutePath(aNode).toString();
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw com::sun::star::container::NoSuchElementException( sMessage, xContext );
}
OSL_ASSERT(aNode.isValid());
return configapi::makeElement( rNode.getFactory(), aTree, aNestedNode );
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw com::sun::star::container::NoSuchElementException( e.message(), xContext );
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
// unreachable, but still there to make some compilers happy
OSL_ASSERT(!"Unreachable code");
return uno::Any();
}
// XPropertyWithState
//---------------------------------------------------------------------
css::beans::PropertyState implGetStateAsProperty(NodeAccess& rNode)
throw (uno::RuntimeException)
{
css::beans::PropertyState aRet = css::beans::PropertyState_AMBIGUOUS_VALUE;
try
{
GuardedNodeData<NodeAccess> lock( rNode );
if ( lock.getTree()->isNodeDefault( lock.getNode() ) )
aRet = css::beans::PropertyState_DEFAULT_VALUE;
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
return aRet;
}
uno::Reference< uno::XInterface > implGetDefaultAsProperty(NodeAccess& )
throw (css::lang::WrappedTargetException, uno::RuntimeException)
{
// not really supported
/* possible, but nor really useful:
GuardedNodeAccess lock( rNode );
if (implGetStateAsProperty(rNode) == PropertyState_DEFAULT_VALUE)
return rNode.getUnoInstance();
*/
return uno::Reference< uno::XInterface >();
}
// set-specific Interfaces
//-----------------------------------------------------------------------------------
// XTemplateContainer
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL implGetElementTemplateName(NodeSetInfoAccess& rNode)
throw(uno::RuntimeException)
{
GuardedNodeData<NodeSetInfoAccess> lock(rNode);
return rNode.getElementInfo()->getPathString();
}
//-----------------------------------------------------------------------------------
} // namespace configapi
} // namespace configmgr
-136
View File
@@ -1,136 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_BASEACCESSIMPL_HXX_
#define CONFIGMGR_API_BASEACCESSIMPL_HXX_
#include <com/sun/star/container/XHierarchicalName.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/configuration/XTemplateInstance.hpp>
#include <com/sun/star/configuration/XTemplateContainer.hpp>
#include <com/sun/star/beans/XExactName.hpp>
#include <com/sun/star/beans/XProperty.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/beans/XPropertyWithState.hpp>
namespace configmgr
{
namespace css = ::com::sun::star;
namespace uno = ::com::sun::star::uno;
/* implementations of the interfaces supported by a (parent) node
within the configuration tree.
(read-only operation)
*/
namespace configapi
{
class NodeAccess;
class NodeSetInfoAccess;
class NodeGroupInfoAccess;
// XHierarchicalName
rtl::OUString implGetHierarchicalName(NodeAccess& rNode)
throw(uno::RuntimeException);
rtl::OUString implComposeHierarchicalName(NodeGroupInfoAccess& rNode, const rtl::OUString& aRelativeName )
throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, uno::RuntimeException);
rtl::OUString implComposeHierarchicalName(NodeSetInfoAccess& rNode, const rtl::OUString& aRelativeName )
throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, uno::RuntimeException);
// XElementAccess, base class of XNameAccess
uno::Type implGetElementType(NodeGroupInfoAccess& rNode)
throw(uno::RuntimeException);
uno::Type implGetElementType(NodeSetInfoAccess& rNode)
throw(uno::RuntimeException);
sal_Bool implHasElements(NodeGroupInfoAccess& rNode)
throw(uno::RuntimeException);
sal_Bool implHasElements(NodeSetInfoAccess& rNode)
throw(uno::RuntimeException);
// XNameAccess
uno::Any implGetByName(NodeAccess& rNode, const rtl::OUString& aName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
uno::Sequence< rtl::OUString > implGetElementNames(NodeAccess& rNode)
throw( uno::RuntimeException);
sal_Bool implHasByName(NodeAccess& rNode, const rtl::OUString& aName )
throw(uno::RuntimeException);
// XHierarchicalNameAccess
uno::Any implGetByHierarchicalName(NodeAccess& rNode, const rtl::OUString& aName )
throw(css::container::NoSuchElementException, uno::RuntimeException);
sal_Bool implHasByHierarchicalName(NodeAccess& rNode, const rtl::OUString& aName )
throw(uno::RuntimeException);
// XExactName
rtl::OUString implGetExactName(NodeGroupInfoAccess& rNode, const rtl::OUString& aApproximateName )
throw(uno::RuntimeException);
rtl::OUString implGetExactName(NodeSetInfoAccess& rNode, const rtl::OUString& aApproximateName )
throw(uno::RuntimeException);
// XProperty
css::beans::Property implGetAsProperty(NodeAccess& rNode)
throw(uno::RuntimeException);
// XPropertySetInfo
uno::Sequence< css::beans::Property > implGetProperties( NodeAccess& rNode )
throw (uno::RuntimeException);
css::beans::Property implGetPropertyByName( NodeAccess& rNode, const rtl::OUString& aName )
throw (css::beans::UnknownPropertyException, uno::RuntimeException);
sal_Bool implHasPropertyByName( NodeAccess& rNode, const rtl::OUString& name )
throw (uno::RuntimeException);
// XPropertyWithState
css::beans::PropertyState implGetStateAsProperty(NodeAccess& rNode)
throw (uno::RuntimeException);
uno::Reference< uno::XInterface > implGetDefaultAsProperty(NodeAccess& rNode)
throw (css::lang::WrappedTargetException, uno::RuntimeException);
// set-specific interfaces
// XTemplateContainer
rtl::OUString SAL_CALL implGetElementTemplateName(NodeSetInfoAccess& rNode)
throw(uno::RuntimeException);
}
}
#endif // CONFIGMGR_API_BASEACCESSIMPL_HXX_
-290
View File
@@ -1,290 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 <stdio.h>
#include "apiaccessobj.hxx"
#include "apiserviceinfo.hxx"
#include "confsvccomponent.hxx"
namespace configmgr
{
//-----------------------------------------------------------------------------
namespace configapi
{
//========================================================================
//= service infos
//========================================================================
/*
const AsciiServiceName c_aUserContainerServices[] =
{
"com.sun.star.configuration.UserAdministration",
"com.sun.star.configuration.ConfigurationContainer",
"com.sun.star.configuration.ConfigurationUpdateAccess",
"com.sun.star.configuration.ConfigurationAccess",
NULL
};
const AsciiServiceName c_aContainerServices[] =
{
"com.sun.star.configuration.ConfigurationContainer",
"com.sun.star.configuration.ConfigurationUpdateAccess",
"com.sun.star.configuration.ConfigurationAccess",
NULL
};
const AsciiServiceName c_aUpdateServices[] =
{
"com.sun.star.configuration.ConfigurationUpdateAccess",
"com.sun.star.configuration.ConfigurationAccess",
NULL
};
const AsciiServiceName c_aAccessServices[] =
{
"com.sun.star.configuration.ConfigurationAccess",
NULL
};
const AsciiServiceName c_aNoServices[] =
{
NULL
};
//-----------------------------------------------------------------------------
ServiceInfo const aInnerGroupInfoSI =
{
"com.sun.star.configuration.configmgr.OInnerGroupInfoAccess",
c_aNoServices
};
ServiceInfo const aInnerGroupUpdateSI =
{
"com.sun.star.configuration.configmgr.OInnerGroupUpdateAccess",
c_aNoServices
};
ServiceInfo const aInnerSetInfoSI =
{
"com.sun.star.configuration.configmgr.OInnerSetInfoAccess",
c_aNoServices
};
ServiceInfo const aInnerTreeSetSI =
{
"com.sun.star.configuration.configmgr.OInnerTreeSetUpdateAccess",
c_aNoServices
};
ServiceInfo const aInnerValueSetSI =
{
"com.sun.star.configuration.configmgr.OInnerValueSetUpdateAccess",
c_aNoServices
};
//-----------------------------------------------------------------------------
ServiceInfo const aSetElementGroupInfoSI =
{
"com.sun.star.configuration.configmgr.OSetElementGroupInfoAccess",
c_aAccessServices
};
ServiceInfo const aSetElementGroupUpdateSI =
{
"com.sun.star.configuration.configmgr.OSetElementGroupUpdateAccess",
c_aUpdateServices
};
ServiceInfo const aSetElementSetInfoSI =
{
"com.sun.star.configuration.configmgr.OSetElementSetInfoAccess",
c_aAccessServices
};
ServiceInfo const aSetElementTreeSetSI =
{
"com.sun.star.configuration.configmgr.OSetElementTreeSetUpdateAccess",
c_aContainerServices
};
ServiceInfo const aSetElementValueSetSI =
{
"com.sun.star.configuration.configmgr.OSetElementValueSetUpdateAccess",
c_aContainerServices
};
//-----------------------------------------------------------------------------
ServiceInfo const aRootElementGroupInfoSI =
{
"com.sun.star.configuration.configmgr.ORootElementGroupInfoAccess",
c_aAccessServices
};
ServiceInfo const aRootElementGroupUpdateSI =
{
"com.sun.star.configuration.configmgr.ORootElementGroupUpdateAccess",
c_aUpdateServices
};
ServiceInfo const aRootElementSetInfoSI =
{
"com.sun.star.configuration.configmgr.ORootElementSetInfoAccess",
c_aAccessServices
};
ServiceInfo const aRootElementTreeSetUpdateSI =
{
"com.sun.star.configuration.configmgr.ORootElementTreeSetUpdateAccess",
c_aContainerServices
};
ServiceInfo const aRootElementValueSetUpdateSI =
{
"com.sun.star.configuration.configmgr.ORootElementValueSetUpdateAccess",
c_aContainerServices
};
//-----------------------------------------------------------------------------
ServiceInfo const aRootElementReadAccessSI =
{
"com.sun.star.configuration.configmgr.ORootElementReadAccess",
c_aAccessServices
};
ServiceInfo const aRootElementUpdateAccessSI =
{
"com.sun.star.configuration.configmgr.ORootElementUpdateAccess",
c_aUpdateServices
};
ServiceInfo const aRootElementAdminAccessSI =
{
"com.sun.star.configuration.configmgr.ORootElementUserAdminAccess",
c_aUserContainerServices
};*/
//========================================================================
//= service info static members
//========================================================================
//-----------------------------------------------------------------------------
// Inner Elements
//-----------------------------------------------------------------------------
template <>
ServiceImplementationInfo const *
const OInnerElement<NodeGroupInfoAccess>::s_pServiceInfo = &aInnerGroupInfoSI;
template <>
ServiceImplementationInfo const *
const OInnerElement<NodeGroupAccess>::s_pServiceInfo = &aInnerGroupUpdateSI;
template <>
ServiceImplementationInfo const *
const OInnerElement<NodeSetInfoAccess>::s_pServiceInfo = &aInnerSetInfoSI;
template <>
ServiceImplementationInfo const *
const OInnerElement<NodeTreeSetAccess>::s_pServiceInfo = &aInnerTreeSetSI;
template <>
ServiceImplementationInfo const *
const OInnerElement<NodeValueSetAccess>::s_pServiceInfo = &aInnerValueSetSI;
//-----------------------------------------------------------------------------
// Set Elements
//-----------------------------------------------------------------------------
template <>
ServiceImplementationInfo const *
const OSetElement<NodeGroupInfoAccess>::s_pServiceInfo = &aSetElementGroupInfoSI;
template <>
ServiceImplementationInfo const *
const OSetElement<NodeGroupAccess>::s_pServiceInfo = &aSetElementGroupUpdateSI;
template <>
ServiceImplementationInfo const *
const OSetElement<NodeSetInfoAccess>::s_pServiceInfo = &aSetElementSetInfoSI;
template <>
ServiceImplementationInfo const *
const OSetElement<NodeTreeSetAccess>::s_pServiceInfo = &aSetElementTreeSetSI;
template <>
ServiceImplementationInfo const *
const OSetElement<NodeValueSetAccess>::s_pServiceInfo = &aSetElementValueSetSI;
//-----------------------------------------------------------------------------
// Root Elements
//-----------------------------------------------------------------------------
template <>
ServiceImplementationInfo const *
const OReadRootElement<NodeGroupInfoAccess>::s_pServiceInfo = &aRootElementGroupInfoSI;
template <>
ServiceImplementationInfo const *
const OUpdateRootElement<NodeGroupAccess>::s_pServiceInfo = &aRootElementGroupUpdateSI;
template <>
ServiceImplementationInfo const *
const OReadRootElement<NodeSetInfoAccess>::s_pServiceInfo = &aRootElementSetInfoSI;
template <>
ServiceImplementationInfo const *
const OUpdateRootElement<NodeTreeSetAccess>::s_pServiceInfo = &aRootElementTreeSetUpdateSI;
template <>
ServiceImplementationInfo const *
const OUpdateRootElement<NodeValueSetAccess>::s_pServiceInfo = &aRootElementValueSetUpdateSI;
//========================================================================
//= Instantiations
//========================================================================
/*
//-----------------------------------------------------------------------------
// Inner Elements
//-----------------------------------------------------------------------------
template class OInnerElement<NodeGroupInfoAccess>; // OInnerGroupInfoAccess
template class OInnerElement<NodeGroupAccess>; // OInnerGroupUpdateAccess
template class OInnerElement<NodeSetInfoAccess>; // OInnerSetInfoAccess
template class OInnerElement<NodeTreeSetAccess>; // OInnerTreeSetUpdateAccess
template class OInnerElement<NodeValueSetAccess>; // OInnerValueSetUpdateAccess
//-----------------------------------------------------------------------------
// Set Elements
//-----------------------------------------------------------------------------
template class OSetElement<NodeGroupInfoAccess>; // OSetElementGroupInfoAccess
template class OSetElement<NodeGroupAccess>; // OSetElementGroupUpdateAccess
template class OSetElement<NodeSetInfoAccess>; // OSetElementSetInfoAccess
template class OSetElement<NodeTreeSetAccess>; // OSetElementTreeSetUpdateAccess
template class OSetElement<NodeValueSetAccess>; // OSetElementValueSetUpdateAccess
//-----------------------------------------------------------------------------
// Root Elements
//-----------------------------------------------------------------------------
template class OReadRootElement<NodeGroupInfoAccess>; // ORootElementGroupInfoAccess
template class OUpdateRootElement<NodeGroupAccess>; // ORootElementGroupUpdateAccess
template class OReadRootElement<NodeSetInfoAccess>; // ORootElementSetInfoAccess
template class OUpdateRootElement<NodeTreeSetAccess>; // ORootElementTreeSetUpdateAccess
template class OUpdateRootElement<NodeValueSetAccess>; // ORootElementValueSetUpdateAccess
*/
//-----------------------------------------------------------------------------
}
}
-145
View File
@@ -1,145 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_ACCESSOBJECTS_HXX_
#define CONFIGMGR_API_ACCESSOBJECTS_HXX_
#include "apitreeaccess.hxx"
#include "apinodeaccess.hxx"
#include "apinodeupdate.hxx"
#include "apitreeimplobj.hxx"
#include "noderef.hxx"
#include "apiserviceinfo.hxx"
namespace configmgr
{
//-----------------------------------------------------------------------------
namespace configapi
{
//-----------------------------------------------------------------------------
// Inner Elements
//-----------------------------------------------------------------------------
template <class NodeClass>
class OInnerElement : public InnerElement, public NodeClass
{
static ServiceImplementationInfo const*const s_pServiceInfo;
uno::XInterface* m_pUnoThis;
ApiTreeImpl& m_rTree;
configuration::NodeRef m_aNode;
public:
inline OInnerElement(uno::XInterface* pUnoThis,ApiTreeImpl& rTree, configuration::NodeRef const& aNode);
inline ~OInnerElement();
virtual inline configuration::NodeRef doGetNode() const;
virtual inline ApiTreeImpl& getApiTree() const;
virtual inline uno::XInterface* doGetUnoInstance() const;
virtual inline ServiceImplementationInfo const* doGetServiceInfo() const;
static inline ServiceImplementationInfo const* getStaticServiceInfo();
};
//-----------------------------------------------------------------------------
// Set Elements
//-----------------------------------------------------------------------------
template <class NodeClass>
class OSetElement : public SetElement, public NodeClass
{
static ServiceImplementationInfo const*const s_pServiceInfo;
mutable ApiTreeImpl m_aTree;
public:
OSetElement(uno::XInterface* pUnoThis, rtl::Reference< configuration::Tree > const& aTree, ApiProvider& rProvider, ApiTreeImpl* pParentTree = 0)
: m_aTree(pUnoThis, rProvider,aTree,pParentTree)
{}
virtual inline configuration::NodeRef doGetNode() const;
virtual inline ApiTreeImpl& getApiTree() const;
virtual inline uno::XInterface* doGetUnoInstance() const;
virtual inline ServiceImplementationInfo const* doGetServiceInfo() const;
static inline ServiceImplementationInfo const* getStaticServiceInfo();
};
//-----------------------------------------------------------------------------
// Root Elements
//-----------------------------------------------------------------------------
template <class NodeClass>
class OReadRootElement : public RootElement, public NodeClass
{
static ServiceImplementationInfo const*const s_pServiceInfo;
mutable ApiRootTreeImpl m_aRootTree;
public:
OReadRootElement(uno::XInterface* pUnoThis, ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions)
: m_aRootTree(pUnoThis, rProvider,aTree, _xOptions)
{}
virtual inline configuration::NodeRef doGetNode() const;
virtual inline ApiTreeImpl& getApiTree() const;
virtual inline ApiRootTreeImpl& getRootTree();
virtual inline uno::XInterface* doGetUnoInstance() const;
virtual inline ServiceImplementationInfo const* doGetServiceInfo() const;
static inline ServiceImplementationInfo const* getStaticServiceInfo();
};
//-------------------------------------------------------------------------
template <class NodeClass>
class OUpdateRootElement : public UpdateRootElement, public NodeClass
{
static ServiceImplementationInfo const*const s_pServiceInfo;
mutable ApiRootTreeImpl m_aRootTree;
public:
OUpdateRootElement(uno::XInterface* pUnoThis, ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions)
: m_aRootTree(pUnoThis, rProvider,aTree,_xOptions)
{}
virtual inline configuration::NodeRef doGetNode() const;
virtual inline ApiTreeImpl& getApiTree() const;
virtual inline ApiRootTreeImpl& getRootTree();
virtual inline uno::XInterface* doGetUnoInstance() const;
virtual inline ServiceImplementationInfo const* doGetServiceInfo() const;
static inline ServiceImplementationInfo const* getStaticServiceInfo();
};
}
}
//-----------------------------------------------------------------------------
#include "apiaccessobj.inl"
//-----------------------------------------------------------------------------
#endif // CONFIGMGR_API_ACCESSOBJECTS_HXX_
-260
View File
@@ -1,260 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
namespace configmgr
{
//-----------------------------------------------------------------------------
namespace configapi
{
//========================================================================
//= member functions
//========================================================================
//-----------------------------------------------------------------------------
// Inner Elements
//-----------------------------------------------------------------------------
template <class NodeClass>
OInnerElement<NodeClass>::OInnerElement(uno::XInterface* pUnoThis,ApiTreeImpl& rTree, configuration::NodeRef const& aNode)
: m_pUnoThis(pUnoThis)
, m_rTree(rTree)
, m_aNode(aNode)
{
m_rTree.setNodeInstance(aNode,pUnoThis);
m_rTree.getUnoInstance()->acquire();
}
template <class NodeClass>
OInnerElement<NodeClass>::~OInnerElement()
{
m_rTree.getUnoInstance()->release();
}
//-----------------------------------------------------------------------------
template <class NodeClass>
configuration::NodeRef OInnerElement<NodeClass>::doGetNode() const
{
return m_aNode;
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ApiTreeImpl& OInnerElement<NodeClass>::getApiTree() const
{
return m_rTree;
}
//-----------------------------------------------------------------------------
template <class NodeClass>
uno::XInterface* OInnerElement<NodeClass>::doGetUnoInstance() const
{
return m_pUnoThis;
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ServiceImplementationInfo const* OInnerElement<NodeClass>::doGetServiceInfo() const
{
return s_pServiceInfo;
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ServiceImplementationInfo const* OInnerElement<NodeClass>::getStaticServiceInfo()
{
return s_pServiceInfo;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Set Elements
//-----------------------------------------------------------------------------
template <class NodeClass>
configuration::NodeRef OSetElement<NodeClass>::doGetNode() const
{
return m_aTree.getTree()->getRootNode();
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ApiTreeImpl& OSetElement<NodeClass>::getApiTree() const
{
return m_aTree;
}
//-----------------------------------------------------------------------------
template <class NodeClass>
uno::XInterface* OSetElement<NodeClass>::doGetUnoInstance() const
{
return m_aTree.getUnoInstance();
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ServiceImplementationInfo const* OSetElement<NodeClass>::doGetServiceInfo() const
{
return s_pServiceInfo;
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ServiceImplementationInfo const* OSetElement<NodeClass>::getStaticServiceInfo()
{
return s_pServiceInfo;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Read-only Root Elements
//-----------------------------------------------------------------------------
template <class NodeClass>
configuration::NodeRef OReadRootElement<NodeClass>::doGetNode() const
{
return m_aRootTree.getApiTree().getTree()->getRootNode();
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ApiTreeImpl& OReadRootElement<NodeClass>::getApiTree() const
{
return m_aRootTree.getApiTree();
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ApiRootTreeImpl& OReadRootElement<NodeClass>::getRootTree()
{
return m_aRootTree;
}
//-----------------------------------------------------------------------------
template <class NodeClass>
uno::XInterface* OReadRootElement<NodeClass>::doGetUnoInstance() const
{
return m_aRootTree.getApiTree().getUnoInstance();
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ServiceImplementationInfo const* OReadRootElement<NodeClass>::doGetServiceInfo() const
{
return s_pServiceInfo;
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ServiceImplementationInfo const* OReadRootElement<NodeClass>::getStaticServiceInfo()
{
return s_pServiceInfo;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Update Root Elements
//-----------------------------------------------------------------------------
template <class NodeClass>
configuration::NodeRef OUpdateRootElement<NodeClass>::doGetNode() const
{
return m_aRootTree.getApiTree().getTree()->getRootNode();
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ApiTreeImpl& OUpdateRootElement<NodeClass>::getApiTree() const
{
return m_aRootTree.getApiTree();
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ApiRootTreeImpl& OUpdateRootElement<NodeClass>::getRootTree()
{
return m_aRootTree;
}
//-----------------------------------------------------------------------------
template <class NodeClass>
uno::XInterface* OUpdateRootElement<NodeClass>::doGetUnoInstance() const
{
return m_aRootTree.getApiTree().getUnoInstance();
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ServiceImplementationInfo const* OUpdateRootElement<NodeClass>::doGetServiceInfo() const
{
return s_pServiceInfo;
}
//-----------------------------------------------------------------------------
template <class NodeClass>
ServiceImplementationInfo const* OUpdateRootElement<NodeClass>::getStaticServiceInfo()
{
return s_pServiceInfo;
}
//-----------------------------------------------------------------------------
//========================================================================
//= Instantiations
//========================================================================
/*
//-----------------------------------------------------------------------------
// Inner Elements
//-----------------------------------------------------------------------------
template class OInnerElement<NodeGroupInfoAccess>; // OInnerGroupInfoAccess
template class OInnerElement<NodeGroupAccess>; // OInnerGroupUpdateAccess
template class OInnerElement<NodeSetInfoAccess>; // OInnerSetInfoAccess
template class OInnerElement<NodeTreeSetAccess>; // OInnerTreeSetUpdateAccess
template class OInnerElement<NodeValueSetAccess>; // OInnerValueSetUpdateAccess
//-----------------------------------------------------------------------------
// Set Elements
//-----------------------------------------------------------------------------
template class OSetElement<NodeGroupInfoAccess>; // OSetElementGroupInfoAccess
template class OSetElement<NodeGroupAccess>; // OSetElementGroupUpdateAccess
template class OSetElement<NodeSetInfoAccess>; // OSetElementSetInfoAccess
template class OSetElement<NodeTreeSetAccess>; // OSetElementTreeSetUpdateAccess
template class OSetElement<NodeValueSetAccess>; // OSetElementValueSetUpdateAccess
//-----------------------------------------------------------------------------
// Root Elements
//-----------------------------------------------------------------------------
template class OReadRootElement<NodeGroupInfoAccess>; // ORootElementGroupInfoAccess
template class OUpdateRootElement<NodeGroupAccess>; // ORootElementGroupUpdateAccess
template class OReadRootElement<NodeSetInfoAccess>; // ORootElementSetInfoAccess
template class OUpdateRootElement<NodeTreeSetAccess>; // ORootElementTreeSetUpdateAccess
template class OUpdateRootElement<NodeValueSetAccess>; // ORootElementValueSetUpdateAccess
*/
//-----------------------------------------------------------------------------
}
}
-335
View File
@@ -1,335 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "apifactory.hxx"
#include "objectregistry.hxx"
#include "apitreeaccess.hxx"
#include "apitreeimplobj.hxx"
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include "noderef.hxx"
#include "anynoderef.hxx"
#include "configexcept.hxx"
#include "configset.hxx"
namespace configmgr
{
//-----------------------------------------------------------------------------
namespace css = ::com::sun::star;
namespace uno = css::uno;
namespace lang = css::lang;
//-----------------------------------------------------------------------------
namespace configapi
{
//-----------------------------------------------------------------------------
ObjectRegistry::~ObjectRegistry()
{
OSL_ENSURE(m_aMap.empty(),"WARNING: Configuration Object Map: Some Objects were not revoked correctly");
}
//-----------------------------------------------------------------------------
Factory::Factory(rtl::Reference<ObjectRegistry> pRegistry)
: m_pRegistry(pRegistry)
, m_aTunnelID()
{
OSL_ENSURE(pRegistry.is(), "ERROR: Factory requires a Object Registry");
}
//-----------------------------------------------------------------------------
Factory::~Factory()
{
}
//-----------------------------------------------------------------------------
inline
NodeElement* Factory::implFind(configuration::NodeID const& aNode)
{
return m_pRegistry->findElement(aNode);
}
//-----------------------------------------------------------------------------
inline
void Factory::doRegisterElement(configuration::NodeID const& aNode, NodeElement* pElement)
{
m_pRegistry->registerElement(aNode,pElement);
}
//-----------------------------------------------------------------------------
inline
void Factory::doRevokeElement(configuration::NodeID const& aNode, NodeElement* pElement)
{
m_pRegistry->revokeElement(aNode,pElement);
}
//-----------------------------------------------------------------------------
ApiTreeImpl& Factory::getImplementation(NodeElement& rElement)
{
return rElement.getApiTree();
}
//-----------------------------------------------------------------------------
inline
rtl::Reference<configuration::Template> Factory::implGetSetElementTemplate(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode)
{
rtl::Reference<configuration::Template> aRet;
if (configuration::isSetNode(aTree,aNode))
{
aRet = aTree->extractElementInfo(aNode);
}
else if (!configuration::isGroupNode(aTree,aNode))
{
OSL_ENSURE( !configuration::isStructuralNode(aTree,aNode), "ERROR: Configuration: unknown kind of object");
throw configuration::Exception("INTERNAL ERROR: Cannot create template - Unexpected node type");
}
return aRet;
}
//-----------------------------------------------------------------------------
inline
uno::Reference< uno::XInterface > Factory::implToUno(NodeElement* pElement)
{
if ( pElement )
return uno::Reference< uno::XInterface >(pElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE);
else
return uno::Reference< uno::XInterface >();
}
//-----------------------------------------------------------------------------
inline
void Factory::implHaveNewElement(configuration::NodeID aNodeID, NodeElement* pElement)
{
OSL_ENSURE(pElement ,"WARNING: New API object could not be created");
if (pElement)
{
doRegisterElement(aNodeID,pElement);
OSL_ENSURE(implFind(aNodeID) == pElement,"WARNING: New API object could not be registered with its factory");
}
}
//-----------------------------------------------------------------------------
uno::Reference< uno::XInterface > Factory::makeUnoElement(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode)
{
return implToUno(makeElement(aTree,aNode));
}
//-----------------------------------------------------------------------------
NodeElement* Factory::makeElement(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode)
{
OSL_PRECOND( !configuration::isEmpty(aTree.get()) == aNode.isValid(), "ERROR: Configuration: Making element from tree requires valid node");
if (configuration::isEmpty(aTree.get()))
return 0;
OSL_PRECOND( aNode.isValid() && aTree->isValidNode(aNode.getOffset()), "ERROR: Configuration: NodeRef does not match Tree");
OSL_PRECOND( configuration::isStructuralNode(aTree,aNode), "ERROR: Configuration: Cannot make object for value node");
configuration::NodeID aNodeID(aTree,aNode);
NodeElement* pRet = findElement(aNodeID);
if (pRet == 0)
{
rtl::Reference<configuration::Template> aTemplate = implGetSetElementTemplate(aTree,aNode);
if (!aTree->isRootNode(aNode))
{
pRet = doCreateGroupMember(aTree,aNode,aTemplate.get());
}
else
{
rtl::Reference< configuration::ElementTree > aElementTree(dynamic_cast< configuration::ElementTree * >(aTree.get()));
if (aElementTree.is())
{
pRet = doCreateSetElement(aElementTree,aTemplate.get());
}
else
{
OSL_ENSURE(configuration::isEmpty(aTree->getContextTree()),"INTERNAL ERROR: Found tree (not a set element) with a parent tree.");
pRet = doCreateAccessRoot(aTree,aTemplate.get(), vos::ORef< OOptions >());
}
}
implHaveNewElement(aNodeID,pRet);
}
return pRet;
}
//-----------------------------------------------------------------------------
uno::Reference< uno::XInterface > Factory::findUnoElement(configuration::NodeID const& aNodeID)
{
return implToUno(findElement(aNodeID));
}
//-----------------------------------------------------------------------------
NodeElement* Factory::findElement(configuration::NodeID const& aNodeID)
{
NodeElement* pReturn = implFind(aNodeID);
if (pReturn) pReturn->getUnoInstance()->acquire();
return pReturn;
}
//-----------------------------------------------------------------------------
void Factory::revokeElement(configuration::NodeID const& aNodeID)
{
if (NodeElement* pElement = implFind(aNodeID))
doRevokeElement(aNodeID, pElement);
}
//-----------------------------------------------------------------------------
TreeElement* Factory::makeAccessRoot(rtl::Reference< configuration::Tree > const& aTree, RequestOptions const& _aOptions)
{
OSL_PRECOND( !configuration::isEmpty(aTree.get()) , "ERROR: Configuration: Making element from tree requires valid tree");
if (configuration::isEmpty(aTree.get())) return 0;
OSL_ENSURE(configuration::isEmpty(aTree->getContextTree()),"INTERNAL ERROR: Tree with parent tree should not be used for an access root");
OSL_ENSURE(dynamic_cast< configuration::ElementTree * >(aTree.get()) == 0, "INTERNAL ERROR: Element Tree should not be used for an access root");
configuration::NodeRef aRoot = aTree->getRootNode();
OSL_ENSURE(aRoot.isValid(),"INTERNAL ERROR: Tree has no root node");
OSL_PRECOND( configuration::isStructuralNode(aTree,aRoot), "ERROR: Configuration: Cannot make object for value node");
configuration::NodeID aNodeID(aTree,aRoot);
// must be a tree element if it is a tree root
TreeElement* pRet = static_cast<TreeElement*>(findElement(aNodeID));
if (0 == pRet)
{
rtl::Reference<configuration::Template> aTemplate = implGetSetElementTemplate(aTree,aRoot);
vos::ORef<OOptions> xOptions = new OOptions(_aOptions);
pRet = doCreateAccessRoot(aTree,aTemplate.get(), xOptions);
implHaveNewElement (aNodeID,pRet);
}
return pRet;
}
//-----------------------------------------------------------------------------
uno::Reference< uno::XInterface > Factory::makeUnoSetElement(rtl::Reference< configuration::ElementTree > const& aElementTree)
{
uno::Reference< uno::XInterface > aRet = implToUno(makeSetElement(aElementTree));
OSL_ENSURE( uno::Reference<lang::XUnoTunnel>::query(aRet).is(),"ERROR: API set element has no UnoTunnel");
OSL_ENSURE( uno::Reference<lang::XUnoTunnel>::query(aRet).is() &&
0 != uno::Reference<lang::XUnoTunnel>::query(aRet)->getSomething(doGetElementTunnelID()),
"ERROR: API set element does not support the right tunnel ID");
return aRet;
}
//-----------------------------------------------------------------------------
SetElement* Factory::makeSetElement(rtl::Reference< configuration::ElementTree > const& aElementTree)
{
OSL_PRECOND( aElementTree.is() , "ERROR: Configuration: Making element from tree requires valid tree");
if (!aElementTree.is()) return 0;
rtl::Reference< configuration::Tree > aTree(aElementTree.get());
OSL_ENSURE(!configuration::isEmpty(aTree.get()),"INTERNAL ERROR: Element Tree has no Tree");
configuration::NodeRef aRoot = aTree->getRootNode();
OSL_ENSURE(aRoot.isValid(),"INTERNAL ERROR: Tree has no root node");
OSL_ENSURE( configuration::isStructuralNode(aTree,aRoot), "ERROR: Configuration: Cannot make object for value node");
configuration::NodeID aNodeID(aTree,aRoot);
// must be a set element if it wraps a ElementTree
SetElement* pRet = static_cast<SetElement*>( findElement(aNodeID) );
if (0 == pRet)
{
rtl::Reference<configuration::Template> aTemplate = implGetSetElementTemplate(aTree,aRoot);
pRet = doCreateSetElement(aElementTree,aTemplate.get());
implHaveNewElement(aNodeID,pRet);
}
return pRet;
}
//-----------------------------------------------------------------------------
SetElement* Factory::findSetElement(rtl::Reference< configuration::ElementTree > const& aElement)
{
OSL_PRECOND( aElement.is() , "ERROR: Configuration: Making element from tree requires valid tree");
if (!aElement.is()) return 0;
rtl::Reference< configuration::Tree > aTree(aElement.get());
OSL_ENSURE(!isEmpty(aTree.get()),"INTERNAL ERROR: Element Tree has no Tree");
configuration::NodeRef aRoot = aTree->getRootNode();
OSL_ENSURE(aRoot.isValid(),"INTERNAL ERROR: Tree has no root node");
configuration::NodeID aNodeID(aTree,aRoot);
// must be a set element if it wraps a ElementTree
SetElement* pRet = static_cast<SetElement*>( findElement(aNodeID) );
return pRet;
}
//-----------------------------------------------------------------------------
SetElement* Factory::extractSetElement(uno::Any const& aElement)
{
SetElement* pTunneledImpl = 0;
uno::Reference< lang::XUnoTunnel > xElementTunnel;
if ( aElement.hasValue() && (aElement >>= xElementTunnel) )
{
OSL_ASSERT( xElementTunnel.is() );
sal_Int64 nSomething = xElementTunnel->getSomething(doGetElementTunnelID());
if (0 != nSomething)
{
void* pVoid = reinterpret_cast<void*>(nSomething);
pTunneledImpl = static_cast<SetElement*>(pVoid);
}
}
return pTunneledImpl;
}
//-----------------------------------------------------------------------------
bool Factory::tunnelSetElement(sal_Int64& nSomething, SetElement& rElement, uno::Sequence< sal_Int8 > const& aTunnelID)
{
if (aTunnelID == doGetElementTunnelID())
{
void* pVoid = &rElement;
nSomething = reinterpret_cast<sal_Int64>(pVoid);
return true;
}
else
return false;
}
//-----------------------------------------------------------------------------
ApiTreeImpl const* Factory::findDescendantTreeImpl(configuration::NodeID const& aNode, ApiTreeImpl const* pImpl)
{
ApiTreeImpl* pRet = 0;
if (pImpl)
{
if ( NodeElement* pElement = pImpl->getFactory().implFind( aNode ) )
pRet = &pElement->getApiTree();
}
return pRet;
}
//-----------------------------------------------------------------------------
}
}
-119
View File
@@ -1,119 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_FACTORY_HXX_
#define CONFIGMGR_API_FACTORY_HXX_
#include "options.hxx"
#include "utility.hxx"
#include <boost/utility.hpp>
#include <rtl/ref.hxx>
#include <vos/ref.hxx>
#include <cppuhelper/typeprovider.hxx>
namespace configmgr
{
namespace configuration
{
class NodeID;
class NodeRef;
class ElementTree;
class Template;
class Tree;
}
namespace configapi
{
namespace uno = com::sun::star::uno;
class ApiTreeImpl;
class NodeElement;
class InnerElement;
class TreeElement;
class SetElement;
class RootElement;
// used to register objects
class ObjectRegistry;
// used to create UNO objects
class Factory : private boost::noncopyable
{
rtl::Reference<ObjectRegistry> m_pRegistry;
cppu::OImplementationId const m_aTunnelID;
private:
/// return the element _without_ acquiring it
NodeElement* implFind(configuration::NodeID const& aNode);
public:
Factory(rtl::Reference<ObjectRegistry> pRegistry);
virtual ~Factory();
uno::Reference< uno::XInterface > makeUnoElement(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode);
uno::Reference< uno::XInterface > findUnoElement(configuration::NodeID const& aNode);
uno::Reference< uno::XInterface > makeUnoSetElement(rtl::Reference< configuration::ElementTree > const& aTree);
NodeElement* makeElement(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode);
NodeElement* findElement(configuration::NodeID const& aNode);
TreeElement* makeAccessRoot(rtl::Reference< configuration::Tree > const& aTree, RequestOptions const& _aOptions);
SetElement* makeSetElement(rtl::Reference< configuration::ElementTree > const& aTree);
SetElement* findSetElement(rtl::Reference< configuration::ElementTree > const& aElement);
/// check for the existence of an element
sal_Bool hasElement(configuration::NodeID const& _rNode) { return NULL != implFind(_rNode); }
void revokeElement(configuration::NodeID const& aNode);
SetElement* extractSetElement(uno::Any const& aElement);
bool tunnelSetElement(sal_Int64& nSomething, SetElement& rElement, uno::Sequence< sal_Int8 > const& aTunnelID);
// registry operations
static ApiTreeImpl const* findDescendantTreeImpl(configuration::NodeID const& aNode, ApiTreeImpl const* pImpl);
protected:
void doRegisterElement(configuration::NodeID const& aNode, NodeElement* pElement);
void doRevokeElement(configuration::NodeID const& aNode, NodeElement* pElement);
uno::Sequence< sal_Int8 > doGetElementTunnelID() const { return m_aTunnelID.getImplementationId(); }
virtual NodeElement* doCreateGroupMember(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode, configuration::Template* pSetElementTemplate) = 0;
virtual TreeElement* doCreateAccessRoot(rtl::Reference< configuration::Tree > const& aTree, configuration::Template* pSetElementTemplate, vos::ORef< OOptions >const& _xOptions) = 0;
virtual SetElement* doCreateSetElement(rtl::Reference< configuration::ElementTree > const& aTree, configuration::Template* pSetElementTemplate) = 0;
static ApiTreeImpl& getImplementation(NodeElement& pElement);
private:
static rtl::Reference<configuration::Template> implGetSetElementTemplate(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode);
static uno::Reference< uno::XInterface > implToUno(NodeElement* pNode);
void implHaveNewElement(configuration::NodeID aNodeID, NodeElement* pNode);
};
}
}
#endif // CONFIGMGR_API_FACTORY_HXX_
-352
View File
@@ -1,352 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 <stdio.h>
#include "apifactoryimpl.hxx"
#include "setobjects.hxx"
#include "groupobjects.hxx"
#include "configset.hxx"
#include "configpath.hxx"
#include "template.hxx"
#include "noderef.hxx"
#include "objectregistry.hxx"
#include "attributes.hxx"
namespace configmgr
{
namespace configapi
{
//-----------------------------------------------------------------------------
// class ReadOnlyObjectFactory
//-----------------------------------------------------------------------------
ReadOnlyObjectFactory::ReadOnlyObjectFactory(ApiProvider& rProvider,rtl::Reference<ObjectRegistry> pRegistry)
: Factory(pRegistry)
, m_rProvider(rProvider)
{
}
//-----------------------------------------------------------------------------
ReadOnlyObjectFactory::~ReadOnlyObjectFactory()
{
}
//-----------------------------------------------------------------------------
NodeElement* ReadOnlyObjectFactory::doCreateGroupMember(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode, configuration::Template* pSetElementTemplate)
{
OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create a group member without a tree");
OSL_ENSURE(aNode.isValid(), "ERROR: trying to create a group member without a node");
OSL_ENSURE(aTree->isValidNode(aNode.getOffset()), "ERROR: node does not match tree , while trying to create a group member");
OSL_ENSURE(!aTree->isRootNode(aNode), "ERROR: trying to create a group member on a root node");
if (aTree->isRootNode(aNode))
return 0;
NodeElement* pRootElement = makeElement(aTree,aTree->getRootNode());
OSL_ENSURE(pRootElement, "Could not create root element of tree - cannot create group member object");
if (!pRootElement)
return 0;
uno::Reference<uno::XInterface> aRootRelease(pRootElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE);
ApiTreeImpl& rRootContext = getImplementation(*pRootElement);
NodeElement * pResult = 0;
if (!pSetElementTemplate)
{
OInnerGroupInfo * pNewObject = new OInnerGroupInfo(rRootContext, aNode);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
else
{
OInnerSetInfo * pNewObject = new OInnerSetInfo(rRootContext, aNode);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
return pResult;
}
//-----------------------------------------------------------------------------
TreeElement* ReadOnlyObjectFactory::doCreateAccessRoot(rtl::Reference< configuration::Tree > const& aTree, configuration::Template* pSetElementTemplate, vos::ORef< OOptions >const& _xOptions)
{
OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create a root object without a tree");
TreeElement * pResult = 0;
if (!pSetElementTemplate)
{
ORootElementGroupInfo * pNewObject = new ORootElementGroupInfo(m_rProvider, aTree, _xOptions);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
else
{
ORootElementSetInfo * pNewObject = new ORootElementSetInfo(m_rProvider, aTree, _xOptions);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
return pResult;
}
//-----------------------------------------------------------------------------
SetElement* ReadOnlyObjectFactory::doCreateSetElement(rtl::Reference< configuration::ElementTree > const& aElementTree, configuration::Template* pSetElementTemplate)
{
OSL_ENSURE(aElementTree.is(), "ERROR: trying to create a set element object without a tree");
rtl::Reference< configuration::Tree > aTree( aElementTree.get() );
OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create a set element object without a tree");
ApiTreeImpl * pParentContext = 0;
uno::Reference<uno::XInterface> aParentRelease;
rtl::Reference< configuration::Tree > aParentTree = aTree->getContextTree();
if (!configuration::isEmpty(aParentTree.get()))
{
//configuration::NodeRef aParentNode = aTree.getContextNode();
configuration::NodeRef aParentRoot = aParentTree->getRootNode();
if (NodeElement* pParentRootElement = makeElement(aParentTree,aParentRoot) )
{
aParentRelease = uno::Reference<uno::XInterface>(pParentRootElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE);
pParentContext = &getImplementation(*pParentRootElement);
}
}
SetElement * pResult = 0;
if (!pSetElementTemplate)
{
OSetElementGroupInfo * pNewObject = new OSetElementGroupInfo(aTree,m_rProvider,pParentContext);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
else
{
OSetElementSetInfo * pNewObject = new OSetElementSetInfo(aTree,m_rProvider,pParentContext);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
return pResult;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// class UpdateObjectFactory
//-----------------------------------------------------------------------------
UpdateObjectFactory::UpdateObjectFactory(ApiProvider& rProvider,rtl::Reference<ObjectRegistry> pRegistry)
: Factory(pRegistry)
, m_rProvider(rProvider)
{
}
//-----------------------------------------------------------------------------
UpdateObjectFactory::~UpdateObjectFactory()
{
}
//-----------------------------------------------------------------------------
bool UpdateObjectFactory::implIsReadOnly(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode)
{
OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create an object without a tree");
OSL_ENSURE(aNode.isValid(), "ERROR: trying to create an object without a node");
OSL_ENSURE(aTree->isValidNode(aNode.getOffset()), "ERROR: node does not match tree , while trying to create an object");
return aTree->getAttributes(aNode).isReadonly();
}
//-----------------------------------------------------------------------------
NodeElement* UpdateObjectFactory::doCreateGroupMember(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode, configuration::Template* pSetElementTemplate)
{
OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create a group member without a tree");
OSL_ENSURE(aNode.isValid(), "ERROR: trying to create a group member without a node");
OSL_ENSURE(aTree->isValidNode(aNode.getOffset()), "ERROR: node does not match tree , while trying to create a group");
NodeElement* pRootElement = makeElement(aTree,aTree->getRootNode());
OSL_ENSURE(pRootElement, "Could not create root element of tree - cannot create group member object");
if (!pRootElement)
return 0;
uno::Reference<uno::XInterface> aRootRelease(pRootElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE);
ApiTreeImpl& rRootContext = getImplementation(*pRootElement);
NodeElement * pResult = 0;
if (implIsReadOnly(aTree,aNode))
{
if (!pSetElementTemplate)
{
OInnerGroupInfo * pNewObject = new OInnerGroupInfo(rRootContext, aNode);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
else
{
OInnerSetInfo * pNewObject = new OInnerSetInfo(rRootContext, aNode);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
}
else
{
if (!pSetElementTemplate)
{
OInnerGroupUpdate * pNewObject = new OInnerGroupUpdate(rRootContext, aNode);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
else if (pSetElementTemplate->isInstanceValue())
{
OInnerValueSetUpdate * pNewObject = new OInnerValueSetUpdate(rRootContext, aNode);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
else
{
OInnerTreeSetUpdate * pNewObject = new OInnerTreeSetUpdate(rRootContext, aNode);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
}
return pResult;
}
//-----------------------------------------------------------------------------
TreeElement* UpdateObjectFactory::doCreateAccessRoot(rtl::Reference< configuration::Tree > const& aTree, configuration::Template* pSetElementTemplate, vos::ORef< OOptions >const& _xOptions)
{
OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create a root object without a tree");
TreeElement * pResult = 0;
if (implIsReadOnly(aTree,aTree->getRootNode()))
{
OSL_ENSURE(false, "WARNING: Trying to create an 'Update Access' on a read-only tree/node");
if (!pSetElementTemplate)
{
ORootElementGroupInfo * pNewObject = new ORootElementGroupInfo(m_rProvider, aTree, _xOptions);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
else
{
ORootElementSetInfo * pNewObject = new ORootElementSetInfo(m_rProvider, aTree, _xOptions);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
}
else
{
if (!pSetElementTemplate)
{
ORootElementGroupUpdate * pNewObject = new ORootElementGroupUpdate(m_rProvider, aTree, _xOptions);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
else if (pSetElementTemplate->isInstanceValue())
{
ORootElementValueSetUpdate * pNewObject = new ORootElementValueSetUpdate(m_rProvider, aTree, _xOptions);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
else
{
ORootElementTreeSetUpdate * pNewObject = new ORootElementTreeSetUpdate(m_rProvider, aTree, _xOptions);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
}
return pResult;
}
//-----------------------------------------------------------------------------
SetElement* UpdateObjectFactory::doCreateSetElement(rtl::Reference< configuration::ElementTree > const& aElementTree, configuration::Template* pSetElementTemplate)
{
OSL_ENSURE(aElementTree.is(), "ERROR: trying to create a set element object without a tree");
rtl::Reference< configuration::Tree > aTree( aElementTree.get() );
OSL_ENSURE(!configuration::isEmpty(aTree.get()), "ERROR: trying to create a set element object without a tree");
ApiTreeImpl * pParentContext = 0;
uno::Reference<uno::XInterface> aParentRelease;
rtl::Reference< configuration::Tree > aParentTree = aTree->getContextTree();
if (!configuration::isEmpty(aParentTree.get()))
{
//configuration::NodeRef aParentNode = aTree.getContextNode();
configuration::NodeRef aParentRoot = aParentTree->getRootNode();
if (NodeElement* pParentRootElement = makeElement(aParentTree,aParentRoot) )
{
aParentRelease = uno::Reference<uno::XInterface>(pParentRootElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE);
pParentContext = &getImplementation(*pParentRootElement);
}
}
SetElement * pResult = 0;
if (implIsReadOnly(aTree,aTree->getRootNode()))
{
if (!pSetElementTemplate)
{
OSetElementGroupInfo * pNewObject = new OSetElementGroupInfo(aTree,m_rProvider,pParentContext);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
else
{
OSetElementSetInfo * pNewObject = new OSetElementSetInfo(aTree,m_rProvider,pParentContext);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
}
else
{
if (!pSetElementTemplate)
{
OSetElementGroupUpdate * pNewObject = new OSetElementGroupUpdate(aTree,m_rProvider,pParentContext);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
else if (pSetElementTemplate->isInstanceValue())
{
OSetElementValueSetUpdate * pNewObject = new OSetElementValueSetUpdate(aTree,m_rProvider,pParentContext);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
else
{
OSetElementTreeSetUpdate * pNewObject = new OSetElementTreeSetUpdate(aTree,m_rProvider,pParentContext);
pNewObject->acquire();
pResult = &pNewObject->getElementClass();
}
}
return pResult;
}
//-----------------------------------------------------------------------------
}
}
-68
View File
@@ -1,68 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_FACTORYIMPL_HXX_
#define CONFIGMGR_API_FACTORYIMPL_HXX_
#include "apifactory.hxx"
namespace configmgr
{
namespace configapi
{
class ApiProvider;
// used to create UNO objects
class ReadOnlyObjectFactory : public Factory
{
ApiProvider& m_rProvider;
public:
ReadOnlyObjectFactory(ApiProvider& rProvider,rtl::Reference<ObjectRegistry> pRegistry);
~ReadOnlyObjectFactory();
virtual NodeElement* doCreateGroupMember(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode, configuration::Template* pSetElementTemplate);
virtual TreeElement* doCreateAccessRoot(rtl::Reference< configuration::Tree > const& aTree, configuration::Template* pSetElementTemplate, vos::ORef< OOptions >const& _xOptions);
virtual SetElement* doCreateSetElement(rtl::Reference< configuration::ElementTree > const& aTree, configuration::Template* pSetElementTemplate);
};
// used to create UNO objects
class UpdateObjectFactory : public Factory
{
ApiProvider& m_rProvider;
public:
UpdateObjectFactory(ApiProvider& rProvider,rtl::Reference<ObjectRegistry> pRegistry);
~UpdateObjectFactory();
virtual NodeElement* doCreateGroupMember(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode, configuration::Template* pSetElementTemplate);
virtual TreeElement* doCreateAccessRoot(rtl::Reference< configuration::Tree > const& aTree, configuration::Template* pSetElementTemplate, vos::ORef< OOptions >const& _xOptions);
virtual SetElement* doCreateSetElement(rtl::Reference< configuration::ElementTree > const& aTree, configuration::Template* pSetElementTemplate);
private:
bool implIsReadOnly(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode);
};
}
}
#endif // CONFIGMGR_API_FACTORYIMPL_HXX_
-178
View File
@@ -1,178 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 <stdio.h>
#include "apinodeaccess.hxx"
#include "apitreeimplobj.hxx"
#include "apifactory.hxx"
#include "apitreeaccess.hxx"
#include "noderef.hxx"
#include "anynoderef.hxx"
#include "valueref.hxx"
#include "configset.hxx"
#include "configpath.hxx"
#include "confignotifier.hxx"
namespace configmgr
{
namespace configapi
{
//-----------------------------------------------------------------------------
NodeAccess::~NodeAccess()
{
}
//-----------------------------------------------------------------------------
configuration::NodeRef NodeAccess::getNodeRef() const
{
return doGetNode();
}
//-----------------------------------------------------------------------------
rtl::Reference< configuration::Tree > NodeAccess::getTreeRef() const
{
return getApiTree().getTree();
}
//-----------------------------------------------------------------------------
rtl::Reference< configuration::Tree > NodeAccess::getTree() const
{
return getApiTree().getTree();
}
//-----------------------------------------------------------------------------
void NodeAccess::checkAlive() const
{
getApiTree().checkAlive();
}
//-----------------------------------------------------------------------------
void NodeAccess::disposeNode()
{
getApiTree().disposeNode(getNodeRef(), getUnoInstance());
}
//-----------------------------------------------------------------------------
Factory& NodeAccess::getFactory() const
{
return getApiTree().getFactory();
}
//-----------------------------------------------------------------------------
Notifier NodeAccess::getNotifier() const
{
return getApiTree().getNotifier();
}
//-----------------------------------------------------------------------------
uno::Any makeElement(configapi::Factory& rFactory, rtl::Reference< configuration::Tree > const& aTree, configuration::AnyNodeRef const& aNode)
{
if (!configuration::isEmpty(aTree.get()) && aNode.isValid())
{
if (aNode.isNode())
{
configuration::NodeRef aInnerNode = aNode.toNode();
if (configuration::isStructuralNode(aTree,aInnerNode))
return uno::makeAny( rFactory.makeUnoElement(aTree,aInnerNode) );
else
return configuration::getSimpleElementValue(aTree,aInnerNode);
}
else
{
return configuration::getSimpleValue(aTree,aNode.toValue());
}
}
return uno::Any();
}
//-----------------------------------------------------------------------------
uno::Any makeInnerElement(configapi::Factory& rFactory, rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode)
{
if (!configuration::isEmpty(aTree.get()) && aNode.isValid())
{
OSL_ENSURE(configuration::isStructuralNode(aTree,aNode), "Trying to makeInnerElement for a simple value");
return uno::makeAny( rFactory.makeUnoElement(aTree,aNode) );
}
return uno::Any();
}
//-----------------------------------------------------------------------------
uno::Any makeElement(configapi::Factory& rFactory, rtl::Reference< configuration::ElementTree > const& aTree)
{
if (aTree.is())
{
return uno::makeAny( rFactory.makeUnoSetElement(aTree) );
}
return uno::Any();
}
//-----------------------------------------------------------------------------
rtl::Reference< configuration::ElementTree > extractElementTree(configapi::Factory& rFactory, uno::Any const& aElement, rtl::Reference< configuration::Template > const& aTemplate )
{
OSL_ENSURE(aTemplate.is(), "ERROR: Need a template to extract a matching set element");
if (SetElement* pSetElement = rFactory.extractSetElement(aElement))
{
rtl::Reference<configuration::Template> aFoundTemplate = pSetElement->getTemplateInfo();
if (aFoundTemplate.is())
{
if (aFoundTemplate != aTemplate)
throw configuration::TypeMismatch(aFoundTemplate->getPathString(), aTemplate->getPathString());
return pSetElement->getElementRef( );
}
}
return rtl::Reference< configuration::ElementTree >();
}
//-----------------------------------------------------------------------------
rtl::Reference< configuration::Template > NodeSetInfoAccess::getElementInfo() const
{
rtl::Reference<configuration::Template> aTemplate = getTree()->extractElementInfo(getNodeRef());
OSL_ENSURE(aTemplate.is(), "ERROR: Set must have an element template");
return aTemplate;
}
}
}
-172
View File
@@ -1,172 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_NODEACCESS_HXX_
#define CONFIGMGR_API_NODEACCESS_HXX_
#include "sal/config.h"
#include "boost/utility.hpp"
#include "datalock.hxx"
#include "utility.hxx"
#include "noderef.hxx"
namespace osl { class Mutex; }
namespace configmgr
{
namespace configuration
{
class AnyNodeRef;
class NodeRef;
class Tree;
}
namespace configapi
{
class Factory;
class Notifier;
class SetElement;
class ApiTreeImpl;
namespace uno = com::sun::star::uno;
// API object implementation wrappers
// these objects just provide the pieces needed to navigate and manipulate trees and nodes
// The common part of all nodes, provides all you need to read and listen
class NodeAccess : private boost::noncopyable
{
public:
virtual ~NodeAccess();
// model access
configuration::NodeRef getNodeRef() const;
rtl::Reference< configuration::Tree > getTreeRef() const;
rtl::Reference< configuration::Tree > getTree() const;
// self-locked methods for dispose handling
void checkAlive() const;
void disposeNode();
// api object handling
uno::XInterface* getUnoInstance() const
{ return doGetUnoInstance(); }
Factory& getFactory() const;
Notifier getNotifier() const;
protected:
virtual configuration::NodeRef doGetNode() const = 0;
virtual uno::XInterface* doGetUnoInstance() const = 0;
virtual ApiTreeImpl& getApiTree() const = 0;
};
/** builds a Uno <type scope='com::sun::star::uno'>Any</type> representing node <var>aNode</var>.
<p> Uses the <type scope='configmgr::configapi'>Factory</type> provided
to create service implementations wrapping inner nodes</p>
<p> returns VOID if <var>aNode</var> is empty.</p>
*/
uno::Any makeElement(configapi::Factory& rFactory, rtl::Reference< configuration::Tree > const& aTree, configuration::AnyNodeRef const& aNode);
/** builds a Uno <type scope='com::sun::star::uno'>Any</type> representing inner node <var>aNode</var>.
<p> Uses the <type scope='configmgr::configapi'>Factory</type> provided
to create service implementations wrapping inner nodes</p>
<p> returns VOID if <var>aNode</var> is empty.</p>
*/
uno::Any makeInnerElement(configapi::Factory& rFactory, rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode);
/** builds a Uno <type scope='com::sun::star::uno'>Any</type> representing set element <var>aElement</var>.
<p> Uses the <type scope='configmgr::configapi'>Factory</type> provided
to create service implementations wrapping inner nodes</p>
<p> returns VOID if <var>aNode</var> is empty.</p>
*/
uno::Any makeElement(configapi::Factory& rFactory, rtl::Reference< configuration::ElementTree > const& aTree);
// Info interfaces for Group Nodes
class NodeGroupInfoAccess : public NodeAccess
{
public:
// currently only used for tagging group nodes
};
// Info interfaces for Set Nodes
class NodeSetInfoAccess : public NodeAccess
{
friend class SetElement;
public:
rtl::Reference< configuration::Template > getElementInfo() const;
};
/** extracts a <type scope='configmgr::configuration'>ElementTree</type> from a <type scope='com::sun::star::uno'>Any</type>
which must contain an object which wraps an instance of the template available in <var>aTemplate</var>.
<p> Uses the <type scope='configmgr::configapi'>Factory</type> provided
to resolve inner nodes (which may suppose that the object was created using the same factory)</p>
<p> returns an empty tree if <var>aElement</var> is empty.</p>
<p> May throw exceptions if the type doesn't match the template.</p>
*/
rtl::Reference< configuration::ElementTree > extractElementTree(Factory& rFactory, uno::Any const& aElement, rtl::Reference< configuration::Template > const& aTemplate );
/// wraps a NodeAccess; provides both object and provider (read) locks,
// ensures object was not disposed
template <class Access>
class GuardedNodeData
{
UnoApiLock m_aLock;
Access & m_rNode;
public:
GuardedNodeData(Access& rNode);
public:
Access& get() const { return m_rNode; }
rtl::Reference< configuration::Tree > getTree() const;
configuration::NodeRef getNode() const;
};
template <class Access>
GuardedNodeData<Access>::GuardedNodeData(Access& rNode)
: m_rNode(rNode)
{
rNode.checkAlive();
}
template <class Access>
rtl::Reference< configuration::Tree > GuardedNodeData<Access>::getTree() const
{
return m_rNode.getTree();
}
template <class Access>
configuration::NodeRef GuardedNodeData<Access>::getNode() const
{
return m_rNode.getNodeRef();
}
}
}
#endif // CONFIGMGR_API_NODEACCESS_HXX_
-169
View File
@@ -1,169 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 <stdio.h>
#include "apinodeupdate.hxx"
#include "apitreeimplobj.hxx"
#include "apitreeaccess.hxx"
#include "noderef.hxx"
#include "configset.hxx"
#include "configgroup.hxx"
#include "configpath.hxx"
#include "apifactory.hxx"
namespace configmgr
{
namespace configapi
{
//-----------------------------------------------------------------------------
NodeGroupAccess& withDefaultData(NodeGroupAccess& _aGroup)
{
configuration::GroupDefaulter::ensureDataAvailable(_aGroup.getTreeRef(),_aGroup.getNodeRef(),
_aGroup.getApiTree().getDefaultProvider());
return _aGroup;
}
//-----------------------------------------------------------------------------
configuration::GroupUpdater NodeGroupAccess::getNodeUpdater()
{
return configuration::GroupUpdater(getTree(),getNodeRef(), getApiTree().getProvider().getTypeConverter());
}
//-----------------------------------------------------------------------------
configuration::GroupDefaulter NodeGroupAccess::getNodeDefaulter()
{
return configuration::GroupDefaulter(getTree(),getNodeRef(), getApiTree().getDefaultProvider());
}
//-----------------------------------------------------------------------------
configuration::SetElementFactory NodeTreeSetAccess::getElementFactory()
{
configuration::TemplateProvider aProvider = configuration::SetElementFactory::findTemplateProvider(getTree(),getNodeRef());
return configuration::SetElementFactory(aProvider);
}
//-----------------------------------------------------------------------------
configuration::SetDefaulter NodeSetAccess::getNodeDefaulter()
{
return configuration::SetDefaulter(getTree(),getNodeRef(), getApiTree().getDefaultProvider());
}
//-----------------------------------------------------------------------------
configuration::TreeSetUpdater NodeTreeSetAccess::getNodeUpdater()
{
return configuration::TreeSetUpdater(getTree(),getNodeRef(),getElementInfo());
}
//-----------------------------------------------------------------------------
configuration::ValueSetUpdater NodeValueSetAccess::getNodeUpdater()
{
return configuration::ValueSetUpdater(getTree(),getNodeRef(),getElementInfo(), getApiTree().getProvider().getTypeConverter());
}
//-----------------------------------------------------------------------------
void attachSetElement(NodeTreeSetAccess& aSet, SetElement& aElement)
{
OSL_ENSURE( configuration::NodeID(aSet.getTreeRef(),aSet.getNodeRef()) ==
configuration::NodeID(rtl::Reference< configuration::Tree >(aElement.getTreeRef()->getContextTree()),aElement.getTreeRef()->getContextNodeRef()),
"ERROR: Attaching an unrelated SetElement to a SetInfoAccess");
aElement.haveNewParent(&aSet);
}
//-----------------------------------------------------------------------------
bool attachSetElement(NodeTreeSetAccess& aSet, rtl::Reference< configuration::ElementTree > const& aElementTree)
{
OSL_ENSURE( configuration::NodeID(aSet.getTreeRef(),aSet.getNodeRef()) ==
configuration::NodeID(rtl::Reference< configuration::Tree >(aElementTree->getContextTree()), aElementTree->getContextNodeRef()),
"ERROR: Attaching an unrelated ElementTree to a SetInfoAccess");
Factory& rFactory = aSet.getFactory();
if (SetElement* pSetElement = rFactory.findSetElement(aElementTree))
{
// the factory always does an extra acquire
uno::Reference<uno::XInterface> xReleaseSetElement(pSetElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE);
attachSetElement(aSet, *pSetElement);
return true;
}
else
return false;
}
//-----------------------------------------------------------------------------
void detachSetElement(SetElement& aElement)
{
OSL_ENSURE( configuration::isEmpty(aElement.getTreeRef()->getContextTree()),
"ERROR: Detaching a SetElement that has a parent");
aElement.haveNewParent(0);
}
//-----------------------------------------------------------------------------
bool detachSetElement(Factory& rFactory, rtl::Reference< configuration::ElementTree > const& aElementTree)
{
OSL_ENSURE( configuration::isEmpty(aElementTree->getContextTree()),
"ERROR: Detaching an ElementTree that has a parent");
if (SetElement* pSetElement = rFactory.findSetElement(aElementTree))
{
// the factory always does an extra acquire
uno::Reference<uno::XInterface> xReleaseSetElement(pSetElement->getUnoInstance(), uno::UNO_REF_NO_ACQUIRE);
detachSetElement(*pSetElement);
return true;
}
else
return false;
}
//-----------------------------------------------------------------------------
UpdateGuardImpl::UpdateGuardImpl(NodeGroupAccess& rNode)
: m_rNode(rNode)
{
rNode.checkAlive();
}
//-----------------------------------------------------------------------------
UpdateGuardImpl::UpdateGuardImpl(NodeSetAccess& rNode)
: m_rNode(rNode)
{
}
//-----------------------------------------------------------------------------
UpdateGuardImpl::~UpdateGuardImpl() throw ()
{
}
//-----------------------------------------------------------------------------
}
}
-174
View File
@@ -1,174 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_NODEUPDATE_HXX_
#define CONFIGMGR_API_NODEUPDATE_HXX_
#include "sal/config.h"
#include "boost/utility.hpp"
#include "apinodeaccess.hxx"
#include "utility.hxx"
namespace configmgr
{
namespace configuration
{
class GroupUpdater;
class GroupDefaulter;
class TreeSetUpdater;
class ValueSetUpdater;
class SetDefaulter;
class SetElementFactory;
class NodeUpdate;
}
namespace configapi
{
class SetElement;
// API object implementation wrappers
// these objects just provide the pieces needed to navigate and manipulate trees and nodes
// Updating access for Group Nodes
class NodeGroupAccess : public NodeGroupInfoAccess
{
public:
typedef configuration::GroupUpdater NodeUpdater;
typedef configuration::GroupDefaulter NodeDefaulter;
NodeUpdater getNodeUpdater();
NodeDefaulter getNodeDefaulter();
/** ensures that the default data for a group is loaded (if possible)
<p>Must be called outside of any locks !</p>
*/
friend NodeGroupAccess& withDefaultData(NodeGroupAccess& aGroup);
};
// Updating access for Set Nodes
class NodeSetAccess : public NodeSetInfoAccess
{
public:
typedef struct SetUpdater_PlaceHolder NodeUpdater;
typedef configuration::SetDefaulter NodeDefaulter;
NodeDefaulter getNodeDefaulter();
};
// Updating access for Set Nodes containing whole trees
class NodeTreeSetAccess : public NodeSetAccess
{
public:
typedef configuration::TreeSetUpdater NodeUpdater;
NodeUpdater getNodeUpdater();
configuration::SetElementFactory getElementFactory();
};
// Updating access for Set Nodes containing simple values
class NodeValueSetAccess : public NodeSetAccess
{
public:
typedef configuration::ValueSetUpdater NodeUpdater;
NodeUpdater getNodeUpdater();
};
/// informs a <type>SetElement</type> that it should now link to the given SetElement
void attachSetElement(NodeTreeSetAccess& aSet, SetElement& aElement);
/// informs a <type>SetElement</type> that it should now link to the given SetElement
bool attachSetElement(NodeTreeSetAccess& aSet, rtl::Reference< configuration::ElementTree > const& aElementTree);
/// informs a <type>SetElement</type> that it should now unlink from its owning SetElement
void detachSetElement(SetElement& aElement);
/// informs a <type>SetElement</type> that it should now unlink from its owning SetElement
bool detachSetElement(Factory& rFactory, rtl::Reference< configuration::ElementTree > const& aElementTree);
/// Guarding and locking implementations
/// guards a NodeGroupAccess, or NodeSetAccess; provides an object (write)/provider(read) lock; ensures object was not disposed
class UpdateGuardImpl : private boost::noncopyable
{
NodeAccess& m_rNode;
public:
UpdateGuardImpl(NodeGroupAccess& rNode);
UpdateGuardImpl(NodeSetAccess& rNode);
~UpdateGuardImpl() throw ();
public:
NodeAccess& get() const { return m_rNode; }
void downgrade() { }
};
// Thin Wrappers around NodeAccesses: Provide guarding and convenient access
/// wraps a NodeAccess; provides an object (write)/provider(read) lock, ensures object was not disposed
template <class Access>
class GuardedNodeUpdate
{
UnoApiLock m_aLock;
UpdateGuardImpl m_aImpl;
public:
GuardedNodeUpdate(Access& rNode) : m_aImpl(rNode) {}
public:
Access& get() const { return static_cast<Access&>(m_aImpl.get()); }
rtl::Reference< configuration::Tree > getTree() const;
configuration::NodeRef getNode() const;
typename Access::NodeUpdater getNodeUpdater() const;
typename Access::NodeDefaulter getNodeDefaulter() const;
void clearForBroadcast() { m_aImpl.downgrade(); }
};
template <class Access>
rtl::Reference< configuration::Tree > GuardedNodeUpdate<Access>::getTree() const
{
return get().getTree();
}
template <class Access>
configuration::NodeRef GuardedNodeUpdate<Access>::getNode() const
{
return get().getNodeRef();
}
template <class Access>
typename Access::NodeUpdater GuardedNodeUpdate<Access>::getNodeUpdater() const
{
return get().getNodeUpdater();
}
template <class Access>
typename Access::NodeDefaulter GuardedNodeUpdate<Access>::getNodeDefaulter() const
{
return get().getNodeDefaulter();
}
}
}
#endif // CONFIGMGR_API_NODEUPDATE_HXX_
-329
View File
@@ -1,329 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "apinotifierimpl.hxx"
#include "apinodeaccess.hxx"
#include "noderef.hxx"
#include "valueref.hxx"
#include "confignotifier.hxx"
#include "configexcept.hxx"
#include <osl/diagnose.h>
namespace configmgr
{
namespace configapi
{
//-----------------------------------------------------------------------------------
namespace lang = css::lang;
namespace util = css::util;
namespace beans = css::beans;
// Generic Notifier Support Implementations
//-----------------------------------------------------------------------------------
/// add a Listener to the notifier of a NodeAccess
template <class Listener>
inline
void genericAddListener(NodeAccess& rNode, const uno::Reference< Listener >& xListener )
{
GuardedNotifier aGuardedNotifier( rNode ); // guard the notifier
aGuardedNotifier->add(rNode.getNodeRef(), xListener);
}
/// remove a Listener from the notifier of a NodeAccess
template <class Listener>
inline
void genericRemoveListener(NodeAccess& rNode, const uno::Reference< Listener >& xListener )
{
GuardedNotifier aGuardedNotifier( rNode ); // guard the notifier
aGuardedNotifier->remove(rNode.getNodeRef(), xListener);
}
/** add a Listener for all or some children of a NodeAccess to its notifier
<p> If the name given is empty, the listener will be added to all children of the node</p>
@returns
<TRUE/> if the node was found, or the name was empty
<FALSE/> if the named node wasn't found
*/
template <class Listener>
inline
bool genericAddChildListener(NodeGroupInfoAccess& rNode, const uno::Reference< Listener >& xListener, const rtl::OUString& sName )
{
if (sName.getLength() != 0)
{
GuardedNodeData<NodeAccess> aGuardedNode( rNode ); // guard access to children
GuardedNotifier aGuardedNotifier( rNode ); // guard the notifier
rtl::Reference< configuration::Tree > aTree( aGuardedNode.getTree() );
configuration::NodeRef aNode( aGuardedNode.getNode() );
rtl::OUString aChildName = configuration::validateChildName(sName,aTree,aNode);
if (!aTree->hasChild(aNode,aChildName)) return false;
aGuardedNotifier->addForOne(aNode, xListener, aChildName);
}
else
{
GuardedNotifier aGuardedNotifier( rNode ); // guard the notifier
aGuardedNotifier->addForAll(rNode.getNodeRef(), xListener);
// always ok, as we addreess no specific NodeRef
}
return true;
}
/** remove a Listener from all or some children of a NodeAccess to its notifier
<p> If the name given is empty, the listener will be removed from any children of the node</p>
@returns
<TRUE/> if the node was found, or the name was empty
<FALSE/> if the named node wasn't found
*/
template <class Listener>
inline
bool genericRemoveChildListener(NodeGroupInfoAccess& rNode, const uno::Reference< Listener >& xListener, const rtl::OUString& sName )
{
if (sName.getLength() != 0)
{
GuardedNodeData<NodeAccess> aGuardedNode( rNode ); // guard access to children
GuardedNotifier aGuardedNotifier( rNode ); // guard the notifier
rtl::Reference< configuration::Tree > aTree( aGuardedNode.getTree() );
configuration::NodeRef aNode( aGuardedNode.getNode() );
rtl::OUString aChildName = configuration::validateChildName(sName,aTree,aNode);
if (!aTree->hasChild(aNode,aChildName)) return false;
aGuardedNotifier->removeForOne(aNode, xListener, aChildName);
}
else
{
GuardedNotifier aGuardedNotifier( rNode ); // guard the notifier
aGuardedNotifier->removeForAll(rNode.getNodeRef(), xListener);
// always ok, as we addreess no specific NodeRef
}
return true;
}
// XComponent
//-----------------------------------------------------------------------------------
void implAddListener(NodeAccess& rNode, const uno::Reference< css::lang::XEventListener >& xListener )
throw(uno::RuntimeException)
{
genericAddListener(rNode,xListener);
}
void implRemoveListener(NodeAccess& rNode, const uno::Reference< css::lang::XEventListener >& xListener )
throw(uno::RuntimeException)
{
genericRemoveListener(rNode,xListener);
}
// XContainer
//-----------------------------------------------------------------------------------
void implAddListener(NodeAccess& rNode, const uno::Reference< css::container::XContainerListener >& xListener )
throw(uno::RuntimeException)
{
genericAddListener(rNode,xListener);
}
void implRemoveListener(NodeAccess& rNode, const uno::Reference< css::container::XContainerListener >& xListener )
throw(uno::RuntimeException)
{
genericRemoveListener(rNode,xListener);
}
// XChangesNotifier
//-----------------------------------------------------------------------------------
void implAddListener(NodeAccess& rNode, const uno::Reference< css::util::XChangesListener >& xListener )
throw(uno::RuntimeException)
{
genericAddListener(rNode,xListener);
}
void implRemoveListener(NodeAccess& rNode, const uno::Reference< css::util::XChangesListener >& xListener )
throw(uno::RuntimeException)
{
genericRemoveListener(rNode,xListener);
}
// XMultiPropertySet
//-----------------------------------------------------------------------------------
void implAddListener( NodeAccess& rNode, const uno::Reference< beans::XPropertiesChangeListener >& xListener, const uno::Sequence< rtl::OUString >& aPropertyNames )
throw(uno::RuntimeException)
{
GuardedNotifier impl( rNode );
// TODO: is an exception for unknown names allowed/needed ?
impl->add(rNode.getNodeRef(), xListener, aPropertyNames);
}
void implRemoveListener( NodeAccess& rNode, const uno::Reference< beans::XPropertiesChangeListener >& xListener )
throw(uno::RuntimeException)
{
genericRemoveListener(rNode,xListener);
}
// XPropertySet (manages listeners associated with named child node)
//-----------------------------------------------------------------------------------
// XPropertySet - VetoableChangeListeners
//-----------------------------------------------------------------------------------
void implAddListener( NodeGroupInfoAccess& rNode, const uno::Reference< beans::XVetoableChangeListener >& xListener, const rtl::OUString& sPropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
try
{
if (!genericAddChildListener(rNode,xListener,sPropertyName))
{
throw css::beans::UnknownPropertyException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot add listener - node not found !")),
rNode.getUnoInstance() );
}
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
throw css::beans::UnknownPropertyException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot add listener - node not found:")) += ex.message(),
rNode.getUnoInstance() );
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
}
void implRemoveListener( NodeGroupInfoAccess& rNode, const uno::Reference< beans::XVetoableChangeListener >& xListener, const rtl::OUString& sPropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
try
{
if (!genericRemoveChildListener(rNode,xListener,sPropertyName))
{
throw css::beans::UnknownPropertyException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot remove listener - node not found !")),
rNode.getUnoInstance() );
}
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
throw css::beans::UnknownPropertyException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot remove listener - node not found:")) += ex.message(),
rNode.getUnoInstance() );
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
}
// XPropertySet - PropertyChangeListeners
//-----------------------------------------------------------------------------------
void implAddListener( NodeGroupInfoAccess& rNode, const uno::Reference< beans::XPropertyChangeListener >& xListener, const rtl::OUString& sPropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
try
{
if (!genericAddChildListener(rNode,xListener,sPropertyName))
{
throw css::beans::UnknownPropertyException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot add listener - node not found !")),
rNode.getUnoInstance() );
}
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
throw css::beans::UnknownPropertyException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot add listener - node not found:")) += ex.message(),
rNode.getUnoInstance() );
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
}
void implRemoveListener( NodeGroupInfoAccess& rNode, const uno::Reference< beans::XPropertyChangeListener >& xListener, const rtl::OUString& sPropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
try
{
if (!genericRemoveChildListener(rNode,xListener,sPropertyName))
{
throw css::beans::UnknownPropertyException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot remove listener - node not found !")),
rNode.getUnoInstance() );
}
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
throw css::beans::UnknownPropertyException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: cannot remove listener - node not found:")) += ex.message(),
rNode.getUnoInstance() );
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
}
//-----------------------------------------------------------------------------------
} // namespace configapi
} // namespace configmgr
-102
View File
@@ -1,102 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_NOTIFIERIMPL_HXX_
#define CONFIGMGR_API_NOTIFIERIMPL_HXX_
#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
#include <com/sun/star/container/XChild.hpp>
#endif
#include <com/sun/star/container/XContainer.hpp>
#include <com/sun/star/util/XChangesNotifier.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XMultiPropertySet.hpp>
namespace configmgr
{
namespace css = ::com::sun::star;
namespace uno = ::com::sun::star::uno;
/* implementations of the event notification interfaces
supported by a node within the configuration tree.
*/
namespace configapi
{
class NodeAccess;
class NodeSetInfoAccess;
class NodeGroupInfoAccess;
// Notification support
// XComponent
void implAddListener(NodeAccess& rNode, const uno::Reference< css::lang::XEventListener >& xListener )
throw(uno::RuntimeException);
void implRemoveListener(NodeAccess& rNode, const uno::Reference< css::lang::XEventListener >& xListener )
throw(uno::RuntimeException);
// XContainer
void implAddListener(NodeAccess& rNode, const uno::Reference< css::container::XContainerListener >& xListener )
throw(uno::RuntimeException);
void implRemoveListener(NodeAccess& rNode, const uno::Reference< css::container::XContainerListener >& xListener )
throw(uno::RuntimeException);
// XChangesNotifier
void implAddListener(NodeAccess& rNode, const uno::Reference< css::util::XChangesListener >& xListener )
throw(uno::RuntimeException);
void implRemoveListener(NodeAccess& rNode, const uno::Reference< css::util::XChangesListener >& xListener )
throw(uno::RuntimeException);
// XPropertySet - VetoableChangeListeners
void implAddListener( NodeGroupInfoAccess& rNode, const uno::Reference< css::beans::XVetoableChangeListener >& xListener, const rtl::OUString& sPropertyName )
throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, uno::RuntimeException);
void implRemoveListener( NodeGroupInfoAccess& rNode, const uno::Reference< css::beans::XVetoableChangeListener >& xListener, const rtl::OUString& sPropertyName )
throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, uno::RuntimeException);
// XPropertySet
void implAddListener( NodeGroupInfoAccess& rNode, const uno::Reference< css::beans::XPropertyChangeListener >& xListener, const rtl::OUString& sPropertyName )
throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, uno::RuntimeException);
void implRemoveListener( NodeGroupInfoAccess& rNode, const uno::Reference< css::beans::XPropertyChangeListener >& xListener, const rtl::OUString& sPropertyName )
throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, uno::RuntimeException);
// XMultiPropertySet
void implAddListener( NodeAccess& rNode, const uno::Reference< css::beans::XPropertiesChangeListener >& xListener, const uno::Sequence< rtl::OUString >& sPropertyNames )
throw(uno::RuntimeException);
void implRemoveListener( NodeAccess& rNode, const uno::Reference< css::beans::XPropertiesChangeListener >& xListener )
throw(uno::RuntimeException);
}
}
#endif // CONFIGMGR_API_NOTIFIERIMPL_HXX_
-337
View File
@@ -1,337 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "apiserviceinfo.hxx"
namespace configmgr
{
//-----------------------------------------------------------------------------
namespace configapi
{
//========================================================================
//= service names
//========================================================================
//========================================================================
//= service infos
//========================================================================
//-- ACCESS (CONTAINER) ROLES -----------------------------
#define CFG_SVCLIST_SETACCESS \
"com.sun.star.configuration.ConfigurationAccess", \
"com.sun.star.configuration.SetAccess", \
"com.sun.star.configuration.HierarchyAccess", \
"com.sun.star.configuration.SimpleSetAccess"
#define CFG_SVCLIST_GROUPACCESS \
"com.sun.star.configuration.ConfigurationAccess", \
"com.sun.star.configuration.GroupAccess", \
"com.sun.star.configuration.HierarchyAccess", \
"com.sun.star.configuration.PropertyHierarchy"
#define CFG_SVCLIST_SETUPDATE \
"com.sun.star.configuration.ConfigurationUpdateAccess", \
"com.sun.star.configuration.SetUpdate", \
"com.sun.star.configuration.SimpleSetUpdate", \
"com.sun.star.configuration.ConfigurationContainer", /* Obsolete */ \
CFG_SVCLIST_SETACCESS
#define CFG_SVCLIST_GROUPUPDATE \
"com.sun.star.configuration.ConfigurationUpdateAccess", \
"com.sun.star.configuration.GroupUpdate", \
CFG_SVCLIST_GROUPACCESS
//-- ELEMENT ROLES ----------------------------------------
#define CFG_SVCLIST_SETELEMENT \
"com.sun.star.configuration.SetElement", \
"com.sun.star.configuration.HierarchyElement"
#define CFG_SVCLIST_GROUPELEMENT \
"com.sun.star.configuration.GroupElement", \
"com.sun.star.configuration.HierarchyElement"
#define CFG_SVCLIST_ACCESSROOTELEMENT \
"com.sun.star.configuration.AccessRootElement", \
"com.sun.star.configuration.HierarchyElement"
#define CFG_SVCLIST_UPDATEROOTELEMENT \
"com.sun.star.configuration.UpdateRootElement", \
CFG_SVCLIST_ACCESSROOTELEMENT
//-----------------------------------------------------------------------------
sal_Char const * const c_aNoServices[] =
{
NULL
};
//-----------------------------------------------------------------------------
sal_Char const * const c_aCreateAccessServiceNames[] =
{
"com.sun.star.configuration.ConfigurationAccess",
"com.sun.star.configuration.HierarchyAccess",
"com.sun.star.configuration.HierarchyElement",
NULL
};
sal_Char const * const c_aCreateUpdateServiceNames[] =
{
"com.sun.star.configuration.ConfigurationUpdateAccess",
"com.sun.star.configuration.ConfigurationAccess",
"com.sun.star.configuration.HierarchyAccess",
"com.sun.star.configuration.HierarchyElement",
NULL
};
//-----------------------------------------------------------------------------
sal_Char const * const c_aUserAdministrationServices[] =
{
"com.sun.star.configuration.UserAdministration",
"com.sun.star.configuration.SimpleSetUpdate",
"com.sun.star.configuration.SimpleSetAccess",
"com.sun.star.configuration.ConfigurationContainer", // Obsolete
NULL
};
sal_Char const * const c_aGroupAdministrationServices[] =
{
"com.sun.star.configuration.GroupAdministration",
"com.sun.star.configuration.SimpleSetUpdate",
"com.sun.star.configuration.SimpleSetAccess",
"com.sun.star.configuration.ConfigurationContainer", // Obsolete
NULL
};
//-- ROLE COMBINATIONS ------------------
//-- GroupElements
sal_Char const * const c_aInnerGroupAccessServices[] =
{
CFG_SVCLIST_GROUPACCESS,
CFG_SVCLIST_GROUPELEMENT,
NULL
};
sal_Char const * const c_aInnerGroupUpdateServices[] =
{
CFG_SVCLIST_GROUPUPDATE,
CFG_SVCLIST_GROUPELEMENT,
NULL
};
sal_Char const * const c_aInnerSetAccessServices[] =
{
CFG_SVCLIST_SETACCESS,
CFG_SVCLIST_GROUPELEMENT,
NULL
};
sal_Char const * const c_aInnerSetUpdateServices[] =
{
CFG_SVCLIST_SETUPDATE,
CFG_SVCLIST_GROUPELEMENT,
NULL
};
//-- SetElements
sal_Char const * const c_aSetElementGroupAccessServices[] =
{
CFG_SVCLIST_GROUPACCESS,
CFG_SVCLIST_SETELEMENT,
NULL
};
sal_Char const * const c_aSetElementGroupUpdateServices[] =
{
CFG_SVCLIST_GROUPUPDATE,
CFG_SVCLIST_SETELEMENT,
NULL
};
sal_Char const * const c_aSetElementSetAccessServices[] =
{
CFG_SVCLIST_SETACCESS,
CFG_SVCLIST_SETELEMENT,
NULL
};
sal_Char const * const c_aSetElementSetUpdateServices[] =
{
CFG_SVCLIST_SETUPDATE,
CFG_SVCLIST_SETELEMENT,
NULL
};
//-- RootElements
sal_Char const * const c_aRootGroupAccessServices[] =
{
CFG_SVCLIST_GROUPACCESS,
CFG_SVCLIST_ACCESSROOTELEMENT,
NULL
};
sal_Char const * const c_aRootGroupUpdateServices[] =
{
CFG_SVCLIST_GROUPUPDATE,
CFG_SVCLIST_UPDATEROOTELEMENT,
NULL
};
sal_Char const * const c_aRootSetAccessServices[] =
{
CFG_SVCLIST_SETACCESS,
CFG_SVCLIST_ACCESSROOTELEMENT,
NULL
};
sal_Char const * const c_aRootSetUpdateServices[] =
{
CFG_SVCLIST_SETUPDATE,
CFG_SVCLIST_UPDATEROOTELEMENT,
NULL
};
//-----------------------------------------------------------------------------
ServiceImplementationInfo const aInnerGroupInfoSI =
{
"com.sun.star.comp.configuration.OInnerGroupInfoAccess",
c_aInnerGroupAccessServices,
NULL
};
ServiceImplementationInfo const aInnerGroupUpdateSI =
{
"com.sun.star.comp.configuration.OInnerGroupUpdateAccess",
c_aInnerGroupUpdateServices,
NULL
};
ServiceImplementationInfo const aInnerSetInfoSI =
{
"com.sun.star.comp.configuration.OInnerSetInfoAccess",
c_aInnerSetAccessServices,
NULL
};
ServiceImplementationInfo const aInnerTreeSetSI =
{
"com.sun.star.comp.configuration.OInnerTreeSetUpdateAccess",
c_aInnerSetUpdateServices,
NULL
};
ServiceImplementationInfo const aInnerValueSetSI =
{
"com.sun.star.comp.configuration.OInnerValueSetUpdateAccess",
c_aInnerSetUpdateServices,
NULL
};
//-----------------------------------------------------------------------------
ServiceImplementationInfo const aSetElementGroupInfoSI =
{
"com.sun.star.comp.configuration.OSetElementGroupInfoAccess",
c_aSetElementGroupUpdateServices,
NULL
};
ServiceImplementationInfo const aSetElementGroupUpdateSI =
{
"com.sun.star.comp.configuration.OSetElementGroupUpdateAccess",
c_aSetElementGroupUpdateServices,
NULL
};
ServiceImplementationInfo const aSetElementSetInfoSI =
{
"com.sun.star.comp.configuration.OSetElementSetInfoAccess",
c_aSetElementSetAccessServices,
NULL
};
ServiceImplementationInfo const aSetElementTreeSetSI =
{
"com.sun.star.comp.configuration.OSetElementTreeSetUpdateAccess",
c_aSetElementSetUpdateServices,
NULL
};
ServiceImplementationInfo const aSetElementValueSetSI =
{
"com.sun.star.comp.configuration.OSetElementValueSetUpdateAccess",
c_aSetElementSetUpdateServices,
NULL
};
//-----------------------------------------------------------------------------
ServiceImplementationInfo const aRootElementGroupInfoSI =
{
"com.sun.star.comp.configuration.ORootElementGroupInfoAccess",
c_aRootGroupAccessServices,
NULL
};
ServiceImplementationInfo const aRootElementGroupUpdateSI =
{
"com.sun.star.comp.configuration.ORootElementGroupUpdateAccess",
c_aRootGroupUpdateServices,
NULL
};
ServiceImplementationInfo const aRootElementSetInfoSI =
{
"com.sun.star.comp.configuration.ORootElementSetInfoAccess",
c_aRootSetAccessServices,
NULL
};
ServiceImplementationInfo const aRootElementTreeSetUpdateSI =
{
"com.sun.star.comp.configuration.ORootElementTreeSetUpdateAccess",
c_aRootSetUpdateServices,
NULL
};
ServiceImplementationInfo const aRootElementValueSetUpdateSI =
{
"com.sun.star.comp.configuration.ORootElementValueSetUpdateAccess",
c_aRootSetUpdateServices,
NULL
};
//-----------------------------------------------------------------------------
ServiceRegistrationInfo const aCreateReadAccessSI =
{
NULL, //"com.sun.star.comp.configuration.ORootElementReadAccess",
c_aCreateAccessServiceNames
};
ServiceRegistrationInfo const aCreateUpdateAccessSI =
{
NULL, //"com.sun.star.comp.configuration.ORootElementUpdateAccess",
c_aCreateUpdateServiceNames
};
//-----------------------------------------------------------------------------
}
}
-69
View File
@@ -1,69 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_SERVICEINFO_HXX_
#define CONFIGMGR_API_SERVICEINFO_HXX_
#include "serviceinfohelper.hxx"
namespace configmgr
{
//-----------------------------------------------------------------------------
namespace configapi
{
//-----------------------------------------------------------------------------
extern sal_Char const * const c_aUserAdministrationServices[];
extern sal_Char const * const c_aGroupAdministrationServices[];
//-----------------------------------------------------------------------------
extern ServiceImplementationInfo const aInnerGroupInfoSI;
extern ServiceImplementationInfo const aInnerGroupUpdateSI;
extern ServiceImplementationInfo const aInnerSetInfoSI;
extern ServiceImplementationInfo const aInnerTreeSetSI;
extern ServiceImplementationInfo const aInnerValueSetSI;
extern ServiceImplementationInfo const aSetElementGroupInfoSI;
extern ServiceImplementationInfo const aSetElementGroupUpdateSI;
extern ServiceImplementationInfo const aSetElementSetInfoSI;
extern ServiceImplementationInfo const aSetElementTreeSetSI;
extern ServiceImplementationInfo const aSetElementValueSetSI;
extern ServiceImplementationInfo const aRootElementGroupInfoSI;
extern ServiceImplementationInfo const aRootElementGroupUpdateSI;
extern ServiceImplementationInfo const aRootElementSetInfoSI;
extern ServiceImplementationInfo const aRootElementTreeSetUpdateSI;
extern ServiceImplementationInfo const aRootElementValueSetUpdateSI;
//-----------------------------------------------------------------------------
extern ServiceRegistrationInfo const aCreateReadAccessSI;
extern ServiceRegistrationInfo const aCreateUpdateAccessSI;
//-----------------------------------------------------------------------------
}
}
//-----------------------------------------------------------------------------
#endif // CONFIGMGR_API_SERVICEINFO_HXX_
-110
View File
@@ -1,110 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 <stdio.h>
#include "apitreeaccess.hxx"
#include "apitreeimplobj.hxx"
#include "configset.hxx"
#include "confignotifier.hxx"
#include "committer.hxx"
#include "apinodeaccess.hxx"
namespace configmgr
{
//-----------------------------------------------------------------------------
namespace configapi
{
//-----------------------------------------------------------------------------
// self-locked methods for dispose handling
void NodeElement::checkAlive() const
{
getApiTree().checkAlive();
}
//-----------------------------------------------------------------------------
rtl::Reference< configuration::Tree > TreeElement::getTree() const
{
return getTreeRef();
}
//-----------------------------------------------------------------------------
rtl::Reference< configuration::Tree > TreeElement::getTreeRef() const
{
return getApiTree().getTree();
}
//-----------------------------------------------------------------------------
// self-locked methods for dispose handling
bool SetElement::disposeTree(bool bForce)
{
return getApiTree().disposeTree(bForce);
}
//-----------------------------------------------------------------------------
Factory& TreeElement::getFactory()
{
return getApiTree().getFactory();
}
//-----------------------------------------------------------------------------
rtl::Reference< configuration::ElementTree > SetElement::getElementRef() const
{
return dynamic_cast< configuration::ElementTree * >(getTreeRef().get());
}
//-----------------------------------------------------------------------------
rtl::Reference< configuration::Template > SetElement::getTemplateInfo() const
{
rtl::Reference< configuration::ElementTree > aTree(dynamic_cast< configuration::ElementTree * >(getTreeRef().get()));
OSL_ENSURE(aTree.is(), "This really must be a set element");
return aTree->getTemplate();
}
//-----------------------------------------------------------------------------
void SetElement::haveNewParent(NodeSetInfoAccess* pNewParent)
{
ApiTreeImpl* pNewParentImpl = pNewParent ? &pNewParent->getApiTree() : 0;
this->getApiTree().haveNewParent( pNewParentImpl );
}
//-----------------------------------------------------------------------------
bool RootElement::disposeTree()
{
return getRootTree().disposeTree();
}
//-----------------------------------------------------------------------------
Committer UpdateRootElement::getCommitter()
{
return Committer(getRootTree());
}
}
}
-176
View File
@@ -1,176 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_TREEACCESS_HXX_
#define CONFIGMGR_API_TREEACCESS_HXX_
#include "sal/config.h"
#include "boost/utility.hpp"
#include "rtl/ref.hxx"
#include "datalock.hxx"
#include "options.hxx"
#include "utility.hxx"
namespace osl { class Mutex; }
namespace configmgr
{
//-----------------------------------------------------------------------------
struct ServiceImplementationInfo;
//-----------------------------------------------------------------------------
namespace configuration
{
class ElementTree;
class Template;
class Tree;
}
//-----------------------------------------------------------------------------
namespace configapi
{
//-----------------------------------------------------------------------------
namespace uno = com::sun::star::uno;
//-----------------------------------------------------------------------------
class Factory;
class Notifier;
class Committer;
class NodeSetInfoAccess;
//-----------------------------------------------------------------------------
// API object implementation wrappers
//-------------------------------------------------------------------------
class ApiTreeImpl;
class ApiRootTreeImpl;
// these objects just provide the pieces needed to navigate and manipulate trees and nodes
// A common base class for 'element' classes
class NodeElement: private boost::noncopyable
{
public:
virtual ~NodeElement() {}
// self-locked methods for dispose handling
void checkAlive() const;
// api object handling
uno::XInterface* getUnoInstance() const
{ return doGetUnoInstance(); }
ServiceImplementationInfo const * getServiceInfo() const
{ return doGetServiceInfo(); }
private:
virtual uno::XInterface* doGetUnoInstance() const = 0;
virtual ServiceImplementationInfo const* doGetServiceInfo() const = 0;
virtual ApiTreeImpl& getApiTree() const = 0;
friend class Factory;
};
//-----------------------------------------------------------------------------
// A class for tagging inner nodes
class InnerElement : public NodeElement
{
public:
// Only used as a tag
};
//-----------------------------------------------------------------------------
// A common base class for tree-owning elemnt classes
class TreeElement : public NodeElement
{
public:
// model access
rtl::Reference< configuration::Tree > getTreeRef() const;
rtl::Reference< configuration::Tree > getTree() const;
// api object handling
Factory& getFactory();
protected:
virtual ApiTreeImpl& getApiTree() const = 0;
};
//-----------------------------------------------------------------------------
// Info interfaces for Set Elements
class SetElement : public TreeElement
{
public:
// self-locked methods for dispose handling
bool disposeTree(bool bForceDispose);
void haveNewParent(NodeSetInfoAccess* pNewParent);
rtl::Reference< configuration::ElementTree > getElementRef() const;
rtl::Reference< configuration::Template > getTemplateInfo() const;
};
//-----------------------------------------------------------------------------
// Info interfaces for Set Elements
class RootElement : public TreeElement
{
public:
bool disposeTree();
protected:
virtual ApiRootTreeImpl& getRootTree() = 0;
};
//-----------------------------------------------------------------------------
// Info interfaces for Set Elements
class UpdateRootElement : public RootElement
{
public:
Committer getCommitter();
};
// Thin Wrappers around TreeElements: Provide guarding and convenient access
/// wraps a TreeElement; provides an object (read) lock, ensures object was not disposed
class GuardedTreeElement {
UnoApiLock m_aLock;
TreeElement & m_rTree;
public:
explicit GuardedTreeElement(TreeElement & rTree): m_rTree(rTree)
{ rTree.checkAlive(); }
TreeElement & get() const { return m_rTree; }
};
class GuardedRootElement {
UnoApiLock m_aLock;
RootElement & m_rTree;
public:
explicit GuardedRootElement(RootElement & rTree): m_rTree(rTree)
{ rTree.checkAlive(); }
RootElement & get() const { return m_rTree; }
};
}
}
#endif // CONFIGMGR_API_TREEACCESS_HXX_
File diff suppressed because it is too large Load Diff
-189
View File
@@ -1,189 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_TREEIMPLOBJECTS_HXX_
#define CONFIGMGR_API_TREEIMPLOBJECTS_HXX_
#include "noderef.hxx"
#include "configset.hxx"
#include "configdefaultprovider.hxx"
#include "confevents.hxx"
#include "options.hxx"
#include "utility.hxx"
#include <boost/utility.hpp>
#include <vos/ref.hxx>
#include <rtl/ref.hxx>
#include <osl/mutex.hxx>
#ifndef INCLUDED_MEMORY
#include <memory>
#define INCLUDED_MEMORY
#endif
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XComponent.hpp>
namespace com { namespace sun { namespace star {
namespace script { class XTypeConverter; }
} } }
namespace configmgr
{
//-----------------------------------------------------------------------------
class OProviderImpl;
//-----------------------------------------------------------------------------
namespace configapi
{
//-----------------------------------------------------------------------------
class Factory;
class Notifier;
class NotifierImpl;
//-----------------------------------------------------------------------------
class ObjectRegistry;
//-----------------------------------------------------------------------------
// API object implementation wrappers
//-------------------------------------------------------------------------
class ApiProvider: private boost::noncopyable
{
Factory& m_rFactory;
OProviderImpl& m_rProviderImpl;
public:
ApiProvider(Factory& rFactory, OProviderImpl& rProviderImpl );
~ApiProvider()
{}
uno::Reference<com::sun::star::script::XTypeConverter> getTypeConverter() const;
Factory& getFactory() { return m_rFactory; }
OProviderImpl& getProviderImpl() { return m_rProviderImpl; }
};
//-----------------------------------------------------------------------------
//-------------------------------------------------------------------------
class ApiTreeImpl: private boost::noncopyable
{
class ComponentAdapter;
rtl::Reference< configuration::Tree > m_aTree;
vos::ORef<NotifierImpl> m_aNotifier;
configuration::DefaultProvider m_aDefaultProvider;
uno::Reference<ComponentAdapter> m_xProvider;
ApiProvider& m_rProvider;
ApiTreeImpl* m_pParentTree;
uno::XInterface* m_pInstance;
public:
explicit ApiTreeImpl(uno::XInterface* pInstance, ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, ApiTreeImpl* pParentTree);
explicit ApiTreeImpl(uno::XInterface* _pInstance, ApiProvider& _rProvider, rtl::Reference< configuration::Tree > const& _aTree, configuration::DefaultProvider const & _aDefaultProvider);
~ApiTreeImpl();
// initialization
void setNodeInstance(configuration::NodeRef const& aNode, uno::XInterface* pInstance);
// model access
rtl::Reference< configuration::Tree > getTree() const { return m_aTree; }
// self-locked methods for dispose handling
bool isAlive() const;
void checkAlive() const;
bool disposeTree(bool bForce);
bool disposeTreeNow();
void disposeNode(configuration::NodeRef const& aNode, uno::XInterface* pInstance);
// api object handling
Factory& getFactory() const { return m_rProvider.getFactory(); }
Notifier getNotifier() const;
configuration::DefaultProvider getDefaultProvider() const { return m_aDefaultProvider; }
// needs external locking
ApiTreeImpl const* getRootTreeImpl() const;
uno::XInterface* getUnoInstance() const { return m_pInstance; }
ApiProvider& getProvider() { return m_rProvider; }
uno::Reference<uno::XInterface> getUnoProviderInstance() const; // { return m_xProvider; }
/// wire this to a new parent tree
void haveNewParent(ApiTreeImpl* pNewParent);
private:
void init(ApiTreeImpl* pParentTree);
void setParentTree(ApiTreeImpl* pNewParentTree);
void deinit();
bool implDisposeTree();
void implDisposeNode(configuration::NodeRef const& aNode, uno::XInterface* pInstance);
friend class ComponentAdapter;
void disposing(com::sun::star::lang::EventObject const& rEvt) throw();
uno::Reference<com::sun::star::lang::XComponent> getProviderComponent();
uno::Reference<com::sun::star::lang::XComponent> getParentComponent();
};
//-----------------------------------------------------------------------------
class ApiRootTreeImpl
{
public:
explicit ApiRootTreeImpl(uno::XInterface* pInstance, ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions > const& _xOptions);
~ApiRootTreeImpl();
ApiTreeImpl& getApiTree() { return m_aTreeImpl; }
ApiTreeImpl const& getApiTree() const { return m_aTreeImpl; }
configuration::AbsolutePath const & getLocation() const { return m_aLocationPath; }
vos::ORef< OOptions > getOptions() const { return m_xOptions; }
// self-locked methods for dispose handling
bool disposeTree();
/// toggle whether this object relays notifications from the base provider
bool enableNotification(bool bEnable);
private:
TreeManager * implSetNotificationSource(TreeManager * pNew);
void implSetLocation(rtl::Reference< configuration::Tree > const& _aTree);
void releaseData();
private:
class NodeListener;
friend class NodeListener;
// IConfigListener
void disposing(TreeManager * pSource) ;
//INodeListener : IConfigListener
void nodeChanged(Change const& aChange, configuration::AbsolutePath const& aPath, TreeManager * pSource);
void nodeDeleted(configuration::AbsolutePath const& aPath, TreeManager * pSource);
private:
ApiTreeImpl m_aTreeImpl;
configuration::AbsolutePath m_aLocationPath;
rtl::Reference<NodeListener> m_pNotificationListener;
vos::ORef< OOptions > m_xOptions;
};
//-----------------------------------------------------------------------------
}
}
#endif // CONFIGMGR_API_TREEIMPLOBJECTS_HXX_
File diff suppressed because it is too large Load Diff
-88
View File
@@ -1,88 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_BROADCASTER_HXX_
#define CONFIGMGR_API_BROADCASTER_HXX_
#include <com/sun/star/beans/PropertyVetoException.hpp>
#include <vos/ref.hxx>
namespace configmgr
{
namespace configuration
{
// ---------------------------------------------------------------------------------------------------
class NodeChange;
class NodeChanges;
class NodeChangeInformation;
class NodeChangesInformation;
}
// ---------------------------------------------------------------------------------------------------
namespace configapi
{
class Notifier;
namespace css = ::com::sun::star;
// ---------------------------------------------------------------------------------------------------
/// broadcasts events for changes to a single config node or several sibling nodes
class Broadcaster
{
public:
/// construct a broadcaster
Broadcaster(Notifier const& aNotifier, configuration::NodeChange const& aChange, bool bLocal);
Broadcaster(Notifier const& aNotifier, configuration::NodeChanges const& aChanges, bool bLocal);
Broadcaster(Notifier const& aNotifier, configuration::NodeChangesInformation const& aChanges, bool bLocal);
Broadcaster(Broadcaster const& aOther);
~Broadcaster();
/// give all property veto listeners on the affected node a chance to veto
void queryConstraints(configuration::NodeChange const& aChange) throw(css::beans::PropertyVetoException);
/// give all property veto listeners on any of the affected nodes a chance to veto
void queryConstraints(configuration::NodeChanges const& aChanges, bool bSingleBase = true) throw(css::beans::PropertyVetoException);
/// notify all listeners which are affected by this change
void notifyListeners(configuration::NodeChange const& aChange) throw();
/// notify all listeners which are affected by any of these changes (potentially from many different bases)
void notifyListeners(configuration::NodeChanges const& aChanges, bool bSingleBase) throw();
/// notify all listeners which are affected by any of these changes (potentially from many different bases)
void notifyListeners(configuration::NodeChangesInformation const& aChanges, bool bSingleBase = false) throw();
class Impl;
private:
vos::ORef<Impl> m_pImpl;
private:
void operator=(Broadcaster const& aOther);
};
// ---------------------------------------------------------------------------------------------------
}
}
#endif // CONFIGMGR_API_BROADCASTER_HXX_
-130
View File
@@ -1,130 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 <stdio.h>
#include "committer.hxx"
#include "apitreeimplobj.hxx"
#include "providerimpl.hxx"
#include "roottree.hxx"
#include "treechangelist.hxx"
namespace configmgr
{
//-----------------------------------------------------------------------------
namespace configapi
{
//-----------------------------------------------------------------------------
namespace
{
//-------------------------------------------------------------------------
struct NotifyDisabler
{
ApiRootTreeImpl& m_rTree;
bool m_bOldState;
NotifyDisabler(ApiRootTreeImpl& rTree)
: m_rTree(rTree)
, m_bOldState(rTree .enableNotification(false) )
{
}
~NotifyDisabler()
{
m_rTree.enableNotification(m_bOldState);
}
};
//-------------------------------------------------------------------------
}
//-----------------------------------------------------------------------------
// class Committer
//-----------------------------------------------------------------------------
Committer::Committer(ApiRootTreeImpl& rTree)
: m_rTree(rTree)
{}
//-----------------------------------------------------------------------------
OProviderImpl * Committer::getUpdateProvider()
{
return &m_rTree.getApiTree().getProvider().getProviderImpl();
}
//-----------------------------------------------------------------------------
void Committer::commit()
{
ApiTreeImpl& rApiTree = m_rTree.getApiTree();
OSL_PRECOND(!m_rTree.getLocation().isRoot(),"INTERNAL ERROR: Empty location used.");
OSL_PRECOND(m_rTree.getOptions().isValid(),"INTERNAL ERROR: Invalid Options used.");
if (!m_rTree.getOptions().isValid()) return;
RequestOptions aOptions = m_rTree.getOptions()->getRequestOptions();
OProviderImpl * pUpdateProvider = getUpdateProvider();
OSL_ASSERT(pUpdateProvider);
rtl::Reference< configuration::Tree > aTree( rApiTree.getTree());
if (!aTree->hasChanges()) return;
TreeChangeList aChangeList(aOptions,
aTree->getRootPath(),
aTree->getAttributes(aTree->getRootNode()));
// now do the commit
configuration::CommitHelper aHelper(rApiTree.getTree());
if (aHelper.prepareCommit(aChangeList))
try
{
pUpdateProvider->updateTree(aChangeList);
aHelper.finishCommit(aChangeList);
NotifyDisabler aDisableNotify(m_rTree); // do not notify self
pUpdateProvider->saveAndNotifyUpdate(aChangeList);
}
catch(...)
{
// should be a special clean-up routine, but for now we just need a consistent state
try
{
aHelper.failedCommit(aChangeList);
}
catch(configuration::Exception&)
{
OSL_ENSURE(false, "Cleanup really should not throw");
}
throw;
}
}
//-----------------------------------------------------------------------------
}
}
-57
View File
@@ -1,57 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_COMMITTER_HXX_
#define CONFIGMGR_API_COMMITTER_HXX_
namespace configmgr
{
class OProviderImpl;
//-----------------------------------------------------------------------------
namespace configapi
{
//-----------------------------------------------------------------------------
class ApiRootTreeImpl;
//-----------------------------------------------------------------------------
/// allows to update values of a simple type within a <type>NodeRef</type> that refers to a Group
class Committer
{
ApiRootTreeImpl& m_rTree;
public:
Committer(ApiRootTreeImpl& rTree);
void commit();
private:
OProviderImpl * getUpdateProvider();
};
//-----------------------------------------------------------------------------
}
}
#endif // CONFIGMGR_API_COMMITTER_HXX_
-243
View File
@@ -1,243 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "confignotifier.hxx"
#include "notifierimpl.hxx"
#include "broadcaster.hxx"
#include "noderef.hxx"
#include "valueref.hxx"
#include "nodechange.hxx"
#include "apinodeaccess.hxx"
#include "apitreeaccess.hxx"
#include "apitreeimplobj.hxx"
#include <set>
#include <functional>
namespace configmgr
{
namespace configapi
{
// ---------------------------------------------------------------------------------------------------
// class Notifier (-Impl)
// ---------------------------------------------------------------------------------------------------
Notifier::Notifier(vos::ORef<NotifierImpl> const& aImpl,ApiTreeImpl const* pTree)
: m_aImpl(aImpl)
, m_pTree(pTree)
{
OSL_ENSURE(aImpl.isValid(),"Invalid initialization of a Notifier: No impl");
OSL_ENSURE(pTree,"Invalid initialization of a Notifier: No tree");
}
// ---------------------------------------------------------------------------------------------------
Notifier::Notifier(Notifier const& aOther)
: m_aImpl(aOther.m_aImpl)
, m_pTree(aOther.m_pTree)
{
}
// ---------------------------------------------------------------------------------------------------
Notifier::~Notifier()
{
}
// ---------------------------------------------------------------------------------------------------
Broadcaster Notifier::makeBroadcaster(configuration::NodeChange const& aChange, bool bLocal) const
{
return Broadcaster(*this,aChange,bLocal);
}
// ---------------------------------------------------------------------------------------------------
Broadcaster Notifier::makeBroadcaster(configuration::NodeChanges const& aChanges, bool bLocal) const
{
OSL_ENSURE(!aChanges.isEmpty(),"Creating broadcaster for no changes");
return Broadcaster(*this,aChanges,bLocal);
}
// ---------------------------------------------------------------------------------------------------
NotifierImpl::NotifierImpl(rtl::Reference< configuration::Tree > const& aTree)
: m_aListeners(aTree->nodeCount(), SubNodeToIndex(aTree))
{
}
// ---------------------------------------------------------------------------------------------------
NotifierImpl::~NotifierImpl()
{
}
// ---------------------------------------------------------------------------------------------------
void Notifier::add(configuration::NodeRef const& aNode, uno::Reference< css::lang::XEventListener > const& xListener) const
{
if (xListener.is())
m_aImpl->add( configuration::NodeID(m_pTree->getTree(),aNode), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::add(configuration::NodeRef const& aNode, uno::Reference< css::container::XContainerListener > const& xListener) const
{
if (xListener.is())
m_aImpl->add( configuration::NodeID(m_pTree->getTree(),aNode), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::add(configuration::NodeRef const& aNode, uno::Reference< css::util::XChangesListener > const& xListener) const
{
if (xListener.is())
m_aImpl->add( configuration::NodeID(m_pTree->getTree(),aNode), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::addForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener) const
{
if (xListener.is())
m_aImpl->addForAll( configuration::NodeID(m_pTree->getTree(),aNode), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::addForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener, rtl::OUString const& aName) const
{
if (xListener.is())
m_aImpl->addNamed( configuration::SubNodeID(m_pTree->getTree(),aNode, aName), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::addForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) const
{
if (xListener.is())
m_aImpl->addForAll( configuration::NodeID(m_pTree->getTree(),aNode), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::addForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener, rtl::OUString const& aName) const
{
if (xListener.is())
m_aImpl->addNamed( configuration::SubNodeID(m_pTree->getTree(),aNode, aName), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::add(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener, uno::Sequence<rtl::OUString> const& aNames) const
{
if (xListener.is())
{
if (aNames.getLength() > 0)
m_aImpl->add( configuration::NodeID(m_pTree->getTree(),aNode), xListener, aNames);
else
m_aImpl->add( configuration::NodeID(m_pTree->getTree(),aNode), xListener );
}
}
// ---------------------------------------------------------------------------------------------------
void Notifier::remove(configuration::NodeRef const& aNode, uno::Reference< css::lang::XEventListener > const& xListener) const
{
if (xListener.is())
m_aImpl->remove( configuration::NodeID(m_pTree->getTree(),aNode), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::remove(configuration::NodeRef const& aNode, uno::Reference< css::container::XContainerListener > const& xListener) const
{
if (xListener.is())
m_aImpl->remove( configuration::NodeID(m_pTree->getTree(),aNode), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::remove(configuration::NodeRef const& aNode, uno::Reference< css::util::XChangesListener > const& xListener) const
{
if (xListener.is())
m_aImpl->remove( configuration::NodeID(m_pTree->getTree(),aNode), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::removeForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener) const
{
if (xListener.is())
m_aImpl->removeForAll( configuration::NodeID(m_pTree->getTree(),aNode), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::removeForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener, rtl::OUString const& aName) const
{
if (xListener.is())
m_aImpl->removeNamed( configuration::SubNodeID(m_pTree->getTree(),aNode, aName), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::removeForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) const
{
if (xListener.is())
m_aImpl->removeForAll( configuration::NodeID(m_pTree->getTree(),aNode), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::removeForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener, rtl::OUString const& aName) const
{
if (xListener.is())
m_aImpl->removeNamed( configuration::SubNodeID(m_pTree->getTree(),aNode, aName), xListener );
}
// ---------------------------------------------------------------------------------------------------
void Notifier::remove(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener) const
{
if (xListener.is())
m_aImpl->remove( configuration::NodeID(m_pTree->getTree(),aNode), xListener );
}
// ---------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------
DisposeGuardImpl::DisposeGuardImpl(Notifier const&) throw()
{
}
// ---------------------------------------------------------------------------------------------------
DisposeGuardImpl::~DisposeGuardImpl() throw ()
{
}
// ---------------------------------------------------------------------------------------------------
GuardedNotifier::GuardedNotifier(NodeAccess& rNode) throw()
: m_aNotifier(rNode.getNotifier())
, m_aImpl(m_aNotifier)
{
}
// ---------------------------------------------------------------------------------------------------
DisposeGuard::DisposeGuard(NodeAccess& rNode) throw(css::lang::DisposedException)
: m_aImpl(rNode.getNotifier())
{
rNode.checkAlive();
}
// ---------------------------------------------------------------------------------------------------
}
}
-197
View File
@@ -1,197 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_CONFIGNOTIFIER_HXX_
#define CONFIGMGR_CONFIGNOTIFIER_HXX_
#include "configexcept.hxx"
#include "configpath.hxx"
#include "datalock.hxx"
#include "utility.hxx"
#include <boost/utility.hpp>
#include <vos/ref.hxx>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/uno/Sequence.hxx>
namespace com { namespace sun { namespace star {
namespace beans
{
class XPropertyChangeListener;
class XVetoableChangeListener;
class XPropertiesChangeListener;
class PropertyVetoException;
}
namespace lang
{
class XEventListener;
struct EventObject;
}
namespace container { class XContainerListener; }
namespace util { class XChangesListener; }
namespace uno { class RuntimeException; }
} } }
namespace osl { class Mutex; }
namespace configmgr
{
namespace configuration
{
// ---------------------------------------------------------------------------------------------------
class NodeRef;
class ValueRef;
class NodeChange;
class NodeChanges;
}
// ---------------------------------------------------------------------------------------------------
namespace configapi
{
// ---------------------------------------------------------------------------------------------------
class Broadcaster;
class NotifierImpl;
class ApiTreeImpl;
namespace css = ::com::sun::star;
// ---------------------------------------------------------------------------------------------------
/// manages collections of event listeners observing a config tree, thread-safe
class Notifier
{
friend class Broadcaster;
friend class BroadcasterHelper;
vos::ORef<NotifierImpl> m_aImpl;
ApiTreeImpl const*const m_pTree;
public:
/// construct this around the given Implementation, for the given tree
explicit Notifier(vos::ORef<NotifierImpl> const & aImpl, ApiTreeImpl const* pTree);
Notifier(Notifier const& aOther);
~Notifier();
// ---------------------------------------------------------------------------------------------------
/// create a broadcaster for a single change (either local or (possibly) nested)
Broadcaster makeBroadcaster(configuration::NodeChange const& aChange, bool bLocal) const;
/// create a broadcaster for a collection of changes (either local or (possibly) nested)
Broadcaster makeBroadcaster(configuration::NodeChanges const& aChange, bool bLocal) const;
// ---------------------------------------------------------------------------------------------------
bool checkAlive(uno::XInterface* pObject) const throw(css::lang::DisposedException);
// ---------------------------------------------------------------------------------------------------
/// Add a <type scope='com::sun::star::lang'>XEventListener</type> observing <var>aNode</var>.
void add(configuration::NodeRef const& aNode, uno::Reference< css::lang::XEventListener > const& xListener) const;
/// Add a <type scope='com::sun::star::container'>XContainerListener</type> observing <var>aNode</var>.
void add(configuration::NodeRef const& aNode, uno::Reference< css::container::XContainerListener > const& xListener) const;
/// Add a <type scope='com::sun::star::util'>XChangesListener</type> observing <var>aNode</var> and its descendants.
void add(configuration::NodeRef const& aNode, uno::Reference< css::util::XChangesListener > const& xListener) const;
/// Add a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing all children of <var>aNode</var>.
void addForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener) const;
/// Add a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing only the child named <var>aName</var> of <var>aNode</var>.
void addForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener, rtl::OUString const& aName) const;
/// Add a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining all children of <var>aNode</var>.
void addForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) const;
/// Add a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining only the child named <var>aName</var> of <var>aNode</var>.
void addForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener, rtl::OUString const& aName) const;
/** Add a <type scope='com::sun::star::beans'>XPropertiesChangeListener</type>
observing the properties of <var>aNode</var> (optimally only those given by <var>aNames</var>.
*/
void add(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener, uno::Sequence<rtl::OUString> const& aNames) const;
// ---------------------------------------------------------------------------------------------------
/// Remove a <type scope='com::sun::star::lang'>XEventListener</type> observing <var>aNode</var>.
void remove(configuration::NodeRef const& aNode, uno::Reference< css::lang::XEventListener > const& xListener) const;
/// Remove a <type scope='com::sun::star::container'>XContainerListener</type> observing <var>aNode</var>.
void remove(configuration::NodeRef const& aNode, uno::Reference< css::container::XContainerListener > const& xListener) const;
/// Remove a <type scope='com::sun::star::util'>XChangesListener</type> observing <var>aNode</var> and its descendants.
void remove(configuration::NodeRef const& aNode, uno::Reference< css::util::XChangesListener > const& xListener) const;
/// Remove a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing <var>aNode</var>.
void removeForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener) const;
/// Remove a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing the child named <var>aName</var> of <var>aNode</var>.
void removeForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener, rtl::OUString const& aName) const;
/// Remove a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining <var>aNode</var>.
void removeForAll(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) const;
/// Remove a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining the child named <var>aName</var> of <var>aNode</var>.
void removeForOne(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener, rtl::OUString const& aName) const;
/// Remove a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining <var>aNode</var>.
void remove(configuration::NodeRef const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener) const;
/** Remove a <type scope='com::sun::star::beans'>XPropertiesChangeListener</type>
observing any properties of <var>aNode</var>.
*/
void remove(configuration::NodeRef const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener) const;
// ---------------------------------------------------------------------------------------------------
private:
void operator=(Notifier const& aOther);
};
// ---------------------------------------------------------------------------------------------------
// Thin Wrappers around Notifiers: Provide guarding and convenient access
// Guarding and locking implementations
class NodeAccess;
class TreeElement;
/// guards a NodeAccess; provides a simple lock for non-data access, does not check for disposed state
class DisposeGuardImpl: private boost::noncopyable
{
public:
DisposeGuardImpl(Notifier const& rNotifier) throw();
~DisposeGuardImpl() throw ();
};
/// wraps a Notifier (from a node or tree); provides a simple lock for notifier access, does not check for disposed state
class GuardedNotifier
{
UnoApiLock m_aLock;
Notifier m_aNotifier;
DisposeGuardImpl m_aImpl;
public:
GuardedNotifier(NodeAccess& rNode) throw();
public:
Notifier const& get() const { return m_aNotifier; }
Notifier const& operator *() const { return get(); }
Notifier const* operator->() const { return &get(); }
};
/// guards a Node or Tree provides a simple lock for non-data access, does (!) check for disposed state
class DisposeGuard
{
DisposeGuardImpl m_aImpl;
UnoApiLock m_aLock;
public:
DisposeGuard(NodeAccess& rNode) throw(css::lang::DisposedException);
};
// ---------------------------------------------------------------------------------------------------
}
}
#endif // CONFIGMGR_CONFIGNOTIFIER_HXX_
-486
View File
@@ -1,486 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "elementaccess.hxx"
#include "elementimpl.hxx"
#include "apinotifierimpl.hxx"
#include "apitreeaccess.hxx"
//-----------------------------------------------------------------------------------
namespace configmgr
{
//-----------------------------------------------------------------------------------
namespace uno = com::sun::star::uno;
//-----------------------------------------------------------------------------------
// XInterface (but not method queryInterface)
//-----------------------------------------------------------------------------------
// acuire doesn't really do anything but forward. OTOH it should always be overridden when release() is
void SAL_CALL BasicInnerElement ::acquire() throw() { cppu::WeakImplHelper3< css::container::XChild, css::container::XNamed, css::lang::XServiceInfo >::acquire(); }
void SAL_CALL BasicSetElement ::acquire() throw() { cppu::WeakImplHelper6< css::container::XChild, css::container::XNamed, css::lang::XComponent, css::lang::XServiceInfo, css::configuration::XTemplateInstance, css::lang::XUnoTunnel >::acquire(); }
void SAL_CALL BasicRootElement ::acquire() throw() { cppu::WeakImplHelper5< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable >::acquire(); }
void SAL_CALL BasicUpdateElement::acquire() throw() { cppu::WeakImplHelper6< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable, css::util::XChangesBatch >::acquire(); }
//-----------------------------------------------------------------------------------
void SAL_CALL BasicInnerElement::release() throw()
{
// FIXME: this looks highly flaky wrt. weak-refs etc.
bool bLastRef = (1 == m_refCount);
if (bLastRef)
{
UnoApiLock::acquire();
configapi::implDisposeObject( getNodeAccess(), getElementClass() );
}
cppu::WeakImplHelper3< css::container::XChild, css::container::XNamed, css::lang::XServiceInfo >::release();
if (bLastRef)
UnoApiLock::release();
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicSetElement::release() throw()
{
// FIXME: this looks highly flaky wrt. weak-refs etc.
bool bLastRef = (1 == m_refCount);
if (bLastRef)
{
UnoApiLock::acquire();
configapi::implDisposeObject( getNodeAccess(), getElementClass() );
}
cppu::WeakImplHelper6< css::container::XChild, css::container::XNamed, css::lang::XComponent, css::lang::XServiceInfo, css::configuration::XTemplateInstance, css::lang::XUnoTunnel >::release();
if (bLastRef)
UnoApiLock::release();
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicRootElement::release() throw()
{
// FIXME: this looks highly flaky wrt. weak-refs etc.
bool bLastRef = (1 == m_refCount);
if (bLastRef)
{
UnoApiLock::acquire();
configapi::implDisposeObject( getNodeAccess(), getElementClass() );
}
cppu::WeakImplHelper5< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable >::release();
if (bLastRef)
UnoApiLock::release();
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicUpdateElement::release() throw()
{
// FIXME: this looks highly flaky wrt. weak-refs etc.
bool bLastRef = (1 == m_refCount);
if (bLastRef)
{
UnoApiLock::acquire();
configapi::implDisposeObject( getNodeAccess(), getElementClass() );
}
cppu::WeakImplHelper6< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable, css::util::XChangesBatch >::release();
if (bLastRef)
UnoApiLock::release();
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// XTypeProvider (but not method getTypes)
//-----------------------------------------------------------------------------------
uno::Sequence<sal_Int8> SAL_CALL BasicInnerElement::getImplementationId( ) throw(uno::RuntimeException)
{
return configapi::implGetImplementationId( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
uno::Sequence<sal_Int8> SAL_CALL BasicSetElement::getImplementationId( ) throw(uno::RuntimeException)
{
return configapi::implGetImplementationId( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
uno::Sequence<sal_Int8> SAL_CALL BasicRootElement::getImplementationId( ) throw(uno::RuntimeException)
{
return configapi::implGetImplementationId( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
uno::Sequence<sal_Int8> SAL_CALL BasicUpdateElement::getImplementationId( ) throw(uno::RuntimeException)
{
return configapi::implGetImplementationId( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// XChild (not for root elements)
//-----------------------------------------------------------------------------------
uno::Reference< uno::XInterface > SAL_CALL BasicInnerElement::getParent( ) throw(uno::RuntimeException)
{
return configapi::implGetParent( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
uno::Reference< uno::XInterface > SAL_CALL BasicSetElement::getParent( ) throw(uno::RuntimeException)
{
return configapi::implGetParent( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
void SAL_CALL BasicInnerElement::setParent( const uno::Reference< uno::XInterface >& xParent )
throw(css::lang::NoSupportException, uno::RuntimeException)
{
configapi::implSetParent( getNodeAccess(), getElementClass(), xParent );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicSetElement::setParent( const uno::Reference< uno::XInterface >& xParent )
throw(css::lang::NoSupportException, uno::RuntimeException)
{
configapi::implSetParent( getNodeAccess(), getElementClass(), xParent );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// XNamed
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicInnerElement::getName( ) throw(uno::RuntimeException)
{
return configapi::implGetName( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicSetElement::getName( ) throw(uno::RuntimeException)
{
return configapi::implGetName( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicRootElement::getName( ) throw(uno::RuntimeException)
{
return configapi::implGetName( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicUpdateElement::getName( ) throw(uno::RuntimeException)
{
return configapi::implGetName( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
void SAL_CALL BasicInnerElement::setName( const rtl::OUString& aName ) throw(uno::RuntimeException)
{
configapi::implSetName( getNodeAccess(), getElementClass(), aName );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicSetElement::setName( const rtl::OUString& aName ) throw(uno::RuntimeException)
{
configapi::implSetName( getNodeAccess(), getElementClass(), aName );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicRootElement::setName( const rtl::OUString& aName ) throw(uno::RuntimeException)
{
configapi::implSetName( getNodeAccess(), getElementClass(), aName );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicUpdateElement::setName( const rtl::OUString& aName ) throw(uno::RuntimeException)
{
configapi::implSetName( getNodeAccess(), getElementClass(), aName );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// XChangesNotifier
//-----------------------------------------------------------------------------------
void SAL_CALL BasicRootElement::addChangesListener( const uno::Reference< css::util::XChangesListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implAddListener( getNodeAccess(), xListener );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicUpdateElement::addChangesListener( const uno::Reference< css::util::XChangesListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implAddListener( getNodeAccess(), xListener );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
void SAL_CALL BasicRootElement::removeChangesListener( const uno::Reference< css::util::XChangesListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implRemoveListener( getNodeAccess(), xListener );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicUpdateElement::removeChangesListener( const uno::Reference< css::util::XChangesListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implRemoveListener( getNodeAccess(), xListener );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// XComponent
//-----------------------------------------------------------------------------------
void SAL_CALL BasicSetElement::dispose( ) throw(uno::RuntimeException)
{
configapi::implDispose( getElementClass() );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicRootElement::dispose( ) throw(uno::RuntimeException)
{
configapi::implDispose( getElementClass() );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicUpdateElement::dispose( ) throw(uno::RuntimeException)
{
configapi::implDispose( getElementClass() );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
void SAL_CALL BasicSetElement::addEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implAddListener( getNodeAccess(), xListener );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicRootElement::addEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implAddListener( getNodeAccess(), xListener );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicUpdateElement::addEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implAddListener( getNodeAccess(), xListener );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
void SAL_CALL BasicSetElement::removeEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implRemoveListener( getNodeAccess(), xListener );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicRootElement::removeEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implRemoveListener( getNodeAccess(), xListener );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicUpdateElement::removeEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implRemoveListener( getNodeAccess(), xListener );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// XServiceInfo
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicInnerElement::getImplementationName( ) throw(uno::RuntimeException)
{
return configapi::implGetImplementationName( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicSetElement::getImplementationName( ) throw(uno::RuntimeException)
{
return configapi::implGetImplementationName( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicRootElement::getImplementationName( ) throw(uno::RuntimeException)
{
return configapi::implGetImplementationName( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicUpdateElement::getImplementationName( ) throw(uno::RuntimeException)
{
return configapi::implGetImplementationName( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
sal_Bool SAL_CALL BasicInnerElement::supportsService( const rtl::OUString& ServiceName ) throw(uno::RuntimeException)
{
return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName );
}
//-----------------------------------------------------------------------------------
sal_Bool SAL_CALL BasicSetElement::supportsService( const rtl::OUString& ServiceName ) throw(uno::RuntimeException)
{
return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName );
}
//-----------------------------------------------------------------------------------
sal_Bool SAL_CALL BasicRootElement::supportsService( const rtl::OUString& ServiceName ) throw(uno::RuntimeException)
{
return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName );
}
//-----------------------------------------------------------------------------------
sal_Bool SAL_CALL BasicUpdateElement::supportsService( const rtl::OUString& ServiceName ) throw(uno::RuntimeException)
{
return configapi::implSupportsService( getNodeAccess(), getElementClass(), ServiceName );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
uno::Sequence< rtl::OUString > SAL_CALL BasicInnerElement::getSupportedServiceNames( ) throw(uno::RuntimeException)
{
return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
uno::Sequence< rtl::OUString > SAL_CALL BasicSetElement::getSupportedServiceNames( ) throw(uno::RuntimeException)
{
return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
uno::Sequence< rtl::OUString > SAL_CALL BasicRootElement::getSupportedServiceNames( ) throw(uno::RuntimeException)
{
return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
uno::Sequence< rtl::OUString > SAL_CALL BasicUpdateElement::getSupportedServiceNames( ) throw(uno::RuntimeException)
{
return configapi::implGetSupportedServiceNames( getNodeAccess(), getElementClass() );
}
//-----------------------------------------------------------------------------------
// ONLY set elements
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// XTemplateInstance
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicSetElement::getTemplateName( ) throw(uno::RuntimeException)
{
return configapi::implGetTemplateName( getElementClass() );
}
//-----------------------------------------------------------------------------------
// XUnoTunnel
//-----------------------------------------------------------------------------------
sal_Int64 SAL_CALL BasicSetElement::getSomething( const uno::Sequence< sal_Int8 >& aIdentifier )
throw(uno::RuntimeException)
{
return configapi::implGetSomething( getElementClass(), aIdentifier);
}
//-----------------------------------------------------------------------------------
// ONLY root elements
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// XLocalizable
//-----------------------------------------------------------------------------------
css::lang::Locale SAL_CALL BasicRootElement::getLocale( ) throw(uno::RuntimeException)
{
return configapi::implGetLocale( getElementClass() );
}
//-----------------------------------------------------------------------------------
css::lang::Locale SAL_CALL BasicUpdateElement::getLocale( ) throw(uno::RuntimeException)
{
return configapi::implGetLocale( getElementClass() );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
void SAL_CALL BasicRootElement::setLocale( const css::lang::Locale& eLocale ) throw(uno::RuntimeException)
{
configapi::implSetLocale( getElementClass(), eLocale );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicUpdateElement::setLocale( const css::lang::Locale& eLocale ) throw(uno::RuntimeException)
{
configapi::implSetLocale( getElementClass(), eLocale );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// XChangesBatch (only on update root)
//-----------------------------------------------------------------------------------
void SAL_CALL BasicUpdateElement::commitChanges( ) throw(css::lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implCommitChanges( getElementClass() );
}
//-----------------------------------------------------------------------------------
sal_Bool SAL_CALL BasicUpdateElement::hasPendingChanges( ) throw(uno::RuntimeException)
{
return configapi::implHasPendingChanges( getElementClass() );
}
//-----------------------------------------------------------------------------------
uno::Sequence< css::util::ElementChange > SAL_CALL BasicUpdateElement::getPendingChanges( ) throw(uno::RuntimeException)
{
return configapi::implGetPendingChanges( getElementClass() );
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
} // namespace configmgr
-383
View File
@@ -1,383 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_ELEMENTACCESS_HXX_
#define CONFIGMGR_API_ELEMENTACCESS_HXX_
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/configuration/XTemplateInstance.hpp>
#include <com/sun/star/lang/XLocalizable.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/util/XChangesNotifier.hpp>
#include <com/sun/star/util/XChangesBatch.hpp>
#include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implbase5.hxx>
#include <cppuhelper/implbase6.hxx>
namespace configmgr
{
//-----------------------------------------------------------------------------
namespace css = ::com::sun::star;
namespace uno = ::com::sun::star::uno;
//-----------------------------------------------------------------------------
namespace configapi
{
class NodeAccess;
class InnerElement;
class SetElement;
class RootElement;
class UpdateRootElement;
}
//-----------------------------------------------------------------------------
/** implements the interfaces supported by a inner node
within the configuration tree that is a plain node (group member).
<p> Is an interface adapter around
<type scope='configmgr::configapi'>NodeAccess</type> and
<type scope='configmgr::configapi'>InnerElement</type>.</p>
*/
class BasicInnerElement : public cppu::WeakImplHelper3< css::container::XChild, css::container::XNamed, css::lang::XServiceInfo >
{
protected:
// Destructors
virtual ~BasicInnerElement() {}
public:
// Interface methods
// XInterface ('dispose' management) - partial implementation
virtual void SAL_CALL acquire() throw();
virtual void SAL_CALL release() throw();
// XTypeProvider (from implhelper) - partial implementation
virtual uno::Sequence<sal_Int8> SAL_CALL
getImplementationId( )
throw(uno::RuntimeException);
// XChild
virtual uno::Reference< uno::XInterface > SAL_CALL
getParent( )
throw(uno::RuntimeException);
virtual void SAL_CALL // not supported
setParent( const uno::Reference< uno::XInterface >& Parent )
throw(css::lang::NoSupportException, css::uno::RuntimeException);
// XNamed
virtual rtl::OUString SAL_CALL
getName( )
throw(uno::RuntimeException);
virtual void SAL_CALL // not supported (! - missing exception)
setName( const rtl::OUString& aName )
throw(uno::RuntimeException);
// XServiceInfo
virtual rtl::OUString SAL_CALL
getImplementationName( )
throw(uno::RuntimeException);
virtual sal_Bool SAL_CALL
supportsService( const rtl::OUString& ServiceName )
throw(uno::RuntimeException);
virtual uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames( )
throw(uno::RuntimeException);
protected:
virtual configapi::InnerElement& getElementClass() = 0;
virtual configapi::NodeAccess& getNodeAccess() = 0;
};
//-----------------------------------------------------------------------------
/** implements the interfaces supported by a node
within the configuration tree that is a set element (or floating free).
<p> Is an interface adapter around
<type scope='configmgr::configapi'>NodeAccess</type> and
<type scope='configmgr::configapi'>SetElement</type>.</p>
*/
class BasicSetElement : public cppu::WeakImplHelper6< css::container::XChild, css::container::XNamed, css::lang::XComponent, css::lang::XServiceInfo, css::configuration::XTemplateInstance, css::lang::XUnoTunnel >
{
protected:
// Destructors
virtual ~BasicSetElement() {}
public:
// Interface methods
// XInterface ('dispose' management) - partial implementation
virtual void SAL_CALL acquire() throw();
virtual void SAL_CALL release() throw();
// XTypeProvider (from implhelper) - partial implementation
virtual uno::Sequence<sal_Int8> SAL_CALL
getImplementationId( )
throw(uno::RuntimeException);
// XChild
virtual uno::Reference< uno::XInterface > SAL_CALL
getParent( )
throw(uno::RuntimeException);
virtual void SAL_CALL // currently not supported
setParent( const uno::Reference< uno::XInterface >& Parent )
throw(css::lang::NoSupportException, css::uno::RuntimeException);
// XNamed
virtual rtl::OUString SAL_CALL
getName( )
throw(uno::RuntimeException);
virtual void SAL_CALL // generally not supported (! - missing exception)
setName( const rtl::OUString& aName )
throw(uno::RuntimeException);
// XComponent
virtual void SAL_CALL
dispose( )
throw(uno::RuntimeException);
virtual void SAL_CALL
addEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
throw(uno::RuntimeException);
virtual void SAL_CALL
removeEventListener( const uno::Reference< css::lang::XEventListener >& aListener )
throw(uno::RuntimeException);
// XServiceInfo
virtual rtl::OUString SAL_CALL
getImplementationName( )
throw(uno::RuntimeException);
virtual sal_Bool SAL_CALL
supportsService( const rtl::OUString& ServiceName )
throw(uno::RuntimeException);
virtual uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames( )
throw(uno::RuntimeException);
// XTemplateInstance
virtual rtl::OUString SAL_CALL
getTemplateName( )
throw(uno::RuntimeException);
// XUnoTunnel
virtual sal_Int64 SAL_CALL
getSomething( const uno::Sequence< sal_Int8 >& aIdentifier )
throw(uno::RuntimeException);
protected:
virtual configapi::SetElement& getElementClass() = 0;
virtual configapi::NodeAccess& getNodeAccess() = 0;
};
//-----------------------------------------------------------------------------
/** implements the interfaces supported by a node
within the configuration that is the root of a read-only access
<p> Is an interface adapter around
<type scope='configmgr::configapi'>NodeAccess</type> and
<type scope='configmgr::configapi'>SetElement</type>.</p>
*/
class BasicRootElement : public cppu::WeakImplHelper5< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable >
{
protected:
// Destructors
virtual ~BasicRootElement() {}
public:
// Interface methods
// XInterface ('dispose' management) - partial implementation
virtual void SAL_CALL acquire() throw();
virtual void SAL_CALL release() throw();
// XTypeProvider (from implhelper) - partial implementation
virtual uno::Sequence<sal_Int8> SAL_CALL
getImplementationId( )
throw(uno::RuntimeException);
// XNamed
virtual rtl::OUString SAL_CALL
getName( )
throw(uno::RuntimeException);
virtual void SAL_CALL // generally not supported (! - missing exception)
setName( const rtl::OUString& aName )
throw(uno::RuntimeException);
// XChangesNotifier
virtual void SAL_CALL
addChangesListener( const uno::Reference< css::util::XChangesListener >& xListener )
throw(uno::RuntimeException);
virtual void SAL_CALL
removeChangesListener( const uno::Reference< css::util::XChangesListener >& xListener )
throw(uno::RuntimeException);
// XComponent
virtual void SAL_CALL
dispose( )
throw(uno::RuntimeException);
virtual void SAL_CALL
addEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
throw(uno::RuntimeException);
virtual void SAL_CALL
removeEventListener( const uno::Reference< css::lang::XEventListener >& aListener )
throw(uno::RuntimeException);
// XServiceInfo
virtual rtl::OUString SAL_CALL
getImplementationName( )
throw(uno::RuntimeException);
virtual sal_Bool SAL_CALL
supportsService( const rtl::OUString& ServiceName )
throw(uno::RuntimeException);
virtual uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames( )
throw(uno::RuntimeException);
// XLocalizable
virtual css::lang::Locale SAL_CALL
getLocale( )
throw(uno::RuntimeException);
virtual void SAL_CALL // maybe not supported (! - missing exception)
setLocale( const css::lang::Locale& eLocale )
throw(uno::RuntimeException);
protected:
virtual configapi::RootElement& getElementClass() = 0;
virtual configapi::NodeAccess& getNodeAccess() = 0;
};
//-----------------------------------------------------------------------------
/** implements the interfaces supported by a node
within the configuration that is the root of an update access
<p> Is an interface adapter around
<type scope='configmgr::configapi'>NodeAccess</type> and
<type scope='configmgr::configapi'>SetElement</type>.</p>
*/
class BasicUpdateElement : public cppu::WeakImplHelper6< css::container::XNamed, css::util::XChangesNotifier, css::lang::XComponent, css::lang::XServiceInfo, css::lang::XLocalizable, css::util::XChangesBatch >
{
protected:
// Destructors
virtual ~BasicUpdateElement() {}
public:
// Interface methods
// XInterface ('dispose' management) - partial implementation
virtual void SAL_CALL acquire() throw();
virtual void SAL_CALL release() throw();
// XTypeProvider (from implhelper) - partial implementation
virtual uno::Sequence<sal_Int8> SAL_CALL
getImplementationId( )
throw(uno::RuntimeException);
// XNamed
virtual rtl::OUString SAL_CALL
getName( )
throw(uno::RuntimeException);
virtual void SAL_CALL // generally not supported (! - missing exception)
setName( const rtl::OUString& aName )
throw(uno::RuntimeException);
// XChangesNotifier
virtual void SAL_CALL
addChangesListener( const uno::Reference< css::util::XChangesListener >& xListener )
throw(uno::RuntimeException);
virtual void SAL_CALL
removeChangesListener( const uno::Reference< css::util::XChangesListener >& xListener )
throw(uno::RuntimeException);
// XComponent
virtual void SAL_CALL
dispose( )
throw(uno::RuntimeException);
virtual void SAL_CALL
addEventListener( const uno::Reference< css::lang::XEventListener >& xListener )
throw(uno::RuntimeException);
virtual void SAL_CALL
removeEventListener( const uno::Reference< css::lang::XEventListener >& aListener )
throw(uno::RuntimeException);
// XServiceInfo
virtual rtl::OUString SAL_CALL
getImplementationName( )
throw(uno::RuntimeException);
virtual sal_Bool SAL_CALL
supportsService( const rtl::OUString& ServiceName )
throw(uno::RuntimeException);
virtual uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames( )
throw(uno::RuntimeException);
// XChangesBatch
virtual void SAL_CALL
commitChanges( )
throw(css::lang::WrappedTargetException, uno::RuntimeException);
virtual sal_Bool SAL_CALL
hasPendingChanges( )
throw(uno::RuntimeException);
virtual uno::Sequence< css::util::ElementChange > SAL_CALL
getPendingChanges( )
throw(uno::RuntimeException);
// XLocalizable
virtual css::lang::Locale SAL_CALL
getLocale( )
throw(uno::RuntimeException);
virtual void SAL_CALL // maybe not supported (! - missing exception)
setLocale( const css::lang::Locale& eLocale )
throw(uno::RuntimeException);
protected:
virtual configapi::UpdateRootElement& getElementClass() = 0;
virtual configapi::NodeAccess& getNodeAccess() = 0;
};
//-----------------------------------------------------------------------------
}
#endif // CONFIGMGR_API_ELEMENTACCESS_HXX_
-588
View File
@@ -1,588 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "elementimpl.hxx"
#include "apitreeaccess.hxx"
#include "apinodeaccess.hxx"
#include "apifactory.hxx"
#include "noderef.hxx"
#include "nodechange.hxx"
#include "nodechangeinfo.hxx"
#include "translatechanges.hxx"
#include "apitypes.hxx"
#include "configset.hxx"
#include "confignotifier.hxx"
#include "confsvccomponent.hxx"
#include "committer.hxx"
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/configuration/XTemplateContainer.hpp>
#include <osl/diagnose.h>
namespace configmgr
{
namespace configapi
{
//-----------------------------------------------------------------------------------
namespace lang = css::lang;
namespace util = css::util;
//-----------------------------------------------------------------------------------
// Interface methods
//-----------------------------------------------------------------------------------
// XChild
//-----------------------------------------------------------------------------------
uno::Reference< uno::XInterface > implGetParent(NodeAccess& rNode, InnerElement&) throw(uno::RuntimeException)
{
uno::Reference<uno::XInterface> xRet;
try
{
GuardedNodeData<NodeAccess> impl( rNode ); // no provider lock needed - tree must be prebuilt already
rtl::Reference< configuration::Tree > aTree(impl.getTree());
configuration::NodeRef aParentNode = aTree->getParent(impl.getNode());
uno::Any aAny = configapi::makeInnerElement( rNode.getFactory(), aTree, aParentNode );
if (!(aAny >>= xRet)) // no parent available
{
OSL_ASSERT(!xRet.is()); // make sure we return NULL
OSL_ENSURE(!aAny.hasValue(), "configmgr: BasicElement::getParent: could not extract parent - node is not an object");
}
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
return xRet;
}
//-----------------------------------------------------------------------------------
uno::Reference< uno::XInterface > implGetParent(NodeAccess& rNode, SetElement& /*rElement*/) throw(uno::RuntimeException)
{
uno::Reference<uno::XInterface> xRet;
try
{
// assume shared lock for connected trees
GuardedNodeData<NodeAccess> impl( rNode ); // no provider lock needed - tree must be prebuilt already
rtl::Reference< configuration::Tree > aTree(impl.getTree());
rtl::Reference< configuration::Tree > aParentTree( aTree->getContextTree() );
if (!configuration::isEmpty(aParentTree.get()))
{
configuration::NodeRef aParentNode( aTree->getContextNodeRef() );
// assume shared factory for connected trees
uno::Any aAny = configapi::makeInnerElement( rNode.getFactory(), aParentTree, aParentNode );
if (!(aAny >>= xRet)) // no parent available
{
// should occur only if the any is void
OSL_ENSURE(!aAny.hasValue(), "configmgr: BasicSetElement::getParent: could not extract parent - node is not an object");
OSL_ASSERT(!xRet.is()); // make sure we return NULL
}
}
else
{
OSL_ASSERT(!xRet.is()); // make sure we return NULL
}
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
return xRet;
}
//-----------------------------------------------------------------------------------
// UNSUPPORTED method
void implSetParent(NodeAccess& rNode, InnerElement& /*rElement*/, const uno::Reference< uno::XInterface >& /*xParent*/ )
throw(lang::NoSupportException, uno::RuntimeException)
{
UnoApiLock aLock;
rNode.checkAlive(); // Does locking internally, checks for disposed nodes
// TODO(?): allow for xParent == getParent()
throw lang::NoSupportException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("configmgr: BasicElement::setParent: cannot move Entry")),
rNode.getUnoInstance() );
}
//-----------------------------------------------------------------------------------
// preliminary implementation
void implSetParent(NodeAccess& rNode, SetElement& rElement, const uno::Reference< uno::XInterface >& xParent )
throw(lang::NoSupportException, uno::RuntimeException)
{
UnoApiLock aLock;
//implSetParent(rNode,xParent);
// TODO: lock the whole transaction ???? - would need Uno Tunneling ?
uno::Reference< uno::XInterface > xGotParent( implGetParent(rNode,rElement) );
uno::Reference< css::container::XNameContainer > xOldParent( xGotParent, uno::UNO_QUERY );
uno::Reference< css::container::XNameContainer > xNewParent( xParent, uno::UNO_QUERY );
if (xGotParent.is() && !xOldParent.is())
{
throw lang::NoSupportException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: this is not element of a container")),
rNode.getUnoInstance() );
}
if (xParent.is() && !xNewParent.is())
{
throw lang::NoSupportException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: new parent is no container")),
rNode.getUnoInstance() );
}
uno::Reference< uno::XInterface > xThis(rNode.getUnoInstance());
OSL_ASSERT(xThis.is());
if (xOldParent != xNewParent)
{
rtl::OUString const sName( implGetName(rNode,rElement) );
if (xParent.is())
{
rtl::OUString const sTemplate( implGetTemplateName(rElement) );
if (sTemplate.getLength() == 0)
{
throw lang::NoSupportException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: object has no recognizable type")),
xThis );
}
uno::Reference< css::configuration::XTemplateContainer > xNewTemplate( xParent, uno::UNO_QUERY );
if (!xNewTemplate.is())
{
throw lang::NoSupportException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: new parent has no element template")),
xThis );
}
if ( sTemplate != xNewTemplate->getElementTemplateName())
{
throw lang::NoSupportException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: object has wrong type")),
xThis );
}
if ( xNewParent->hasByName( sName ) )
{
throw lang::NoSupportException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: an object of this name already exists in new parent")),
xThis );
}
// TODO: check for circularity (i.e. that This is not one of new parent's ancestors) !!
}
// now do it
try
{
if ( xOldParent.is()) xOldParent->removeByName(sName);
if ( xNewParent.is()) xNewParent->insertByName(sName, uno::makeAny(xThis));
}
catch (uno::Exception& e)
{
e.Message = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Config API: implSetParent: changing parent failed: "))
+= e.Message;
if (xOldParent.is())
try
{
xOldParent->insertByName(sName, uno::makeAny(xThis));
}
catch(uno::Exception& bad)
{
e.Message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n\t ! Could not restore old parent: ")) += bad.Message;
}
throw uno::RuntimeException(e.Message,xThis);
}
}
}
//-----------------------------------------------------------------------------
// XNamed
//-----------------------------------------------------------------------------
rtl::OUString implGetName(NodeAccess& rNode, NodeElement& ) throw(uno::RuntimeException)
{
rtl::OUString sRet;
try
{
GuardedNodeData<NodeAccess> impl( rNode ); // maybe passive only ?
rtl::Reference< configuration::Tree > aTree(impl.getTree());
configuration::NodeRef aNode(impl.getNode());
sRet = aTree->getSimpleNodeName(aNode.getOffset());
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
return sRet;
}
//-----------------------------------------------------------------------------
// UNSUPPORTED method
void implSetName(NodeAccess & rNode, NodeElement& /*rElement*/, const rtl::OUString& /*aName*/ ) throw(uno::RuntimeException)
{
UnoApiLock aLock;
rNode.checkAlive(); // Does locking internally, checks for disposed nodes
// TODO(?): allow for aName == getName()
throw uno::RuntimeException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("configmgr: BasicElement::setName: cannot rename Entry")),
rNode.getUnoInstance() );
}
//-----------------------------------------------------------------------------
// TODO: Implementations for elements to be added to a container node
void implSetName(NodeAccess& rNode, SetElement& rElement, const rtl::OUString& aName ) throw(uno::RuntimeException)
{
UnoApiLock aLock;
// TODO: Implement
NodeElement& rDelegate = rElement;
implSetName(rNode,rDelegate,aName); // delegate to unsupported version
}
//-----------------------------------------------------------------------------
// XComponent & XInterface
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void implDispose( SetElement& rElement) throw(uno::RuntimeException)
{
UnoApiLock aLock;
if (!rElement.disposeTree(false))
{
throw uno::RuntimeException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONFIGURATION: Can't dispose an object that has an owner")),
rElement.getUnoInstance() );
}
}
//-----------------------------------------------------------------------------
void implDispose( RootElement& rElement) throw(uno::RuntimeException)
{
UnoApiLock aLock;
if (!rElement.disposeTree())
{
throw lang::DisposedException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONFIGURATION: Can't dispose an object that already was disposed")),
rElement.getUnoInstance() );
}
}
//-----------------------------------------------------------------------------
void implDisposeObject( NodeAccess& ,SetElement& rElement) throw(uno::RuntimeException)
{
UnoApiLock aLock;
// FIXME: should we hold a ref on the element over this ?
// call apitreeaccess.hxx (doGetUnoInterface) & hold a ref / unref ?
// [or!] - call getApiTree & ref/unref on that ?
// [or!] - hold the ref inside the dispose method itself ...
rElement.disposeTree(true);
}
//-----------------------------------------------------------------------------
void implDisposeObject( NodeAccess& , RootElement& rElement) throw(uno::RuntimeException)
{
UnoApiLock aLock;
rElement.disposeTree();
}
//-----------------------------------------------------------------------------
void implDisposeObject( NodeAccess& rNode, InnerElement& ) throw(uno::RuntimeException)
{
UnoApiLock aLock;
rNode.disposeNode();
}
//-----------------------------------------------------------------------------
// XTypeProvider
//-----------------------------------------------------------------------------
uno::Sequence<sal_Int8> implGetImplementationId(NodeAccess& rNode, NodeElement& rElement)
throw(uno::RuntimeException)
{
DisposeGuard aLock(rNode);
ServiceImplementationInfo const* pInfo = rElement.getServiceInfo();
OSL_ENSURE(pInfo, "Configuration: Object has no implementation (service) info - cannot get implementation id");
if (!pInfo)
throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONFIGURATION: Object has no implementation information - cannot get implementation id")),rElement.getUnoInstance() );
return ServiceComponentImpl::getStaticImplementationId(pInfo);
}
//-----------------------------------------------------------------------------
// XServiceInfo
//-----------------------------------------------------------------------------
rtl::OUString implGetImplementationName( NodeAccess& rNode, NodeElement& rElement ) throw(uno::RuntimeException)
{
DisposeGuard aLock(rNode);
ServiceImplementationInfo const* pInfo = rElement.getServiceInfo();
OSL_ENSURE(pInfo, "Configuration: Object has no service info");
return ServiceInfoHelper(pInfo).getImplementationName();
}
//-----------------------------------------------------------------------------
sal_Bool implSupportsService( NodeAccess& rNode, NodeElement& rElement, const rtl::OUString& ServiceName ) throw(uno::RuntimeException)
{
DisposeGuard aLock(rNode);
ServiceImplementationInfo const* pInfo = rElement.getServiceInfo();
OSL_ENSURE(pInfo, "Configuration: Object has no service info");
return ServiceInfoHelper(pInfo).supportsService(ServiceName);
}
//-----------------------------------------------------------------------------
uno::Sequence< rtl::OUString > implGetSupportedServiceNames( NodeAccess& rNode, NodeElement& rElement ) throw(uno::RuntimeException)
{
DisposeGuard aLock(rNode);
ServiceImplementationInfo const* pInfo = rElement.getServiceInfo();
OSL_ENSURE(pInfo, "Configuration: Object has no service info");
return ServiceInfoHelper(pInfo).getSupportedServiceNames();
}
//-----------------------------------------------------------------------------
// Root only ------------------------------------------------------------------
// XLocalizable
// TODO: Implement locale support
//-----------------------------------------------------------------------------
lang::Locale implGetLocale( RootElement& rElement ) throw(uno::RuntimeException)
{
GuardedRootElement aLocked(rElement);
OSL_ENSURE(false,"CONFIGURATION: Locale information is not yetsupported.");
return lang::Locale();
}
//-----------------------------------------------------------------------------
void implSetLocale( RootElement& rElement, const css::lang::Locale& /*eLocale*/ ) throw(uno::RuntimeException)
{
UnoApiLock aLock;
// TODO: Implement if possible
rElement.checkAlive();
OSL_ENSURE(false,"CONFIGURATION: Changing the set Locale is not supported.");
throw uno::RuntimeException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONFIGURATION: Changing the locale is currently not supported")),
rElement.getUnoInstance()
);
}
//-----------------------------------------------------------------------------
// XChangesBatch
//-----------------------------------------------------------------------------
void implCommitChanges( UpdateRootElement& rElement ) throw(css::lang::WrappedTargetException, uno::RuntimeException)
{
UnoApiLock aLock;
// quick check to avoid big locks for nothing (has its own locking)
if (!implHasPendingChanges(rElement)) return;
try
{
rElement.getCommitter().commit();
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rElement.getUnoInstance() );
e.unhandled();
}
// filter/wrap uno::Exceptions
catch (lang::WrappedTargetException& ) { throw; }
catch (uno::RuntimeException& ) { throw; }
catch (uno::Exception& ex)
{
uno::Reference<uno::XInterface> xContext( rElement.getUnoInstance() );
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration: can't commit Changes: ") );
throw lang::WrappedTargetException( sMessage += ex.Message, xContext, uno::makeAny(ex));
}
}
//-----------------------------------------------------------------------------
sal_Bool implHasPendingChanges( RootElement& rElement ) throw(uno::RuntimeException)
{
try
{
GuardedRootElement aLocked(rElement);
return aLocked.get().getTree()->hasChanges();
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rElement.getUnoInstance() );
e.unhandled();
}
OSL_ENSURE(false,"Unreachable Code");
return false;
}
//-----------------------------------------------------------------------------
uno::Sequence< css::util::ElementChange > implGetPendingChanges( RootElement& rElement )
throw(uno::RuntimeException)
{
std::vector<css::util::ElementChange> aResult;
try
{
GuardedRootElement aLocked(rElement);
rtl::Reference< configuration::Tree > aTree( aLocked.get().getTree() );
configuration::NodeChangesInformation aInfos;
{
configuration::NodeChanges aChanges;
if (aTree->collectChanges(aChanges))
{
aChanges.getChangesInfos(aInfos);
}
}
Factory& rFactory = rElement.getFactory();
for(std::vector< configuration::NodeChangeInformation >::const_iterator it = aInfos.begin(), stop = aInfos.end();
it != stop;
++it)
{
css::util::ElementChange aChange;
fillChange(aChange,*it,aTree,rFactory);
aResult.push_back(aChange);
}
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rElement.getUnoInstance() );
e.unhandled();
}
return makeSequence(aResult);
}
//-----------------------------------------------------------------------------
// Set only -------------------------------------------------------------------------
// XTemplateInstance
//-----------------------------------------------------------------------------------
rtl::OUString implGetTemplateName(SetElement& rElement)
throw(uno::RuntimeException)
{
try
{
GuardedTreeElement aLocked(rElement);
return rElement.getTemplateInfo()->getPathString();
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rElement.getUnoInstance() );
e.unhandled();
}
OSL_ENSURE(false,"Unreachable Code");
return rtl::OUString();
}
//-----------------------------------------------------------------------------------
// XUnoTunnel
//-----------------------------------------------------------------------------------
sal_Int64 implGetSomething(SetElement& rElement, const uno::Sequence< sal_Int8 >& aIdentifier )
throw(uno::RuntimeException)
{
sal_Int64 nSomething = 0;
try
{
GuardedTreeElement aLocked(rElement);
if (!rElement.getFactory().tunnelSetElement(nSomething, rElement, aIdentifier))
OSL_ASSERT(nSomething == 0);
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rElement.getUnoInstance() );
e.unhandled();
}
return nSomething;
}
//-----------------------------------------------------------------------------------
} // namespace configapi
} // namespace configmgr
-157
View File
@@ -1,157 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_ELEMENTIMPL_HXX_
#define CONFIGMGR_API_ELEMENTIMPL_HXX_
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/configuration/XTemplateInstance.hpp>
#include <com/sun/star/lang/XLocalizable.hpp>
#include <com/sun/star/util/XChangesBatch.hpp>
namespace configmgr
{
namespace css = ::com::sun::star;
namespace uno = ::com::sun::star::uno;
/* implementations of the interfaces supported by a (parent) node
within the configuration tree.
(read-only operation)
*/
namespace configapi
{
//-------------------------------------------------------------------------
class NodeAccess;
class NodeElement;
class InnerElement;
class TreeElement;
class SetElement;
class RootElement;
class UpdateRootElement;
//-------------------------------------------------------------------------
// XComponent and XInterface (EOL handling)
//---------------------------------------------------------------------
void implDispose( SetElement& rElement)
throw(uno::RuntimeException);
void implDispose( RootElement& rElement)
throw(uno::RuntimeException);
void implDisposeObject( NodeAccess& aNode, SetElement& rElement)
throw(uno::RuntimeException);
void implDisposeObject( NodeAccess& aNode, RootElement& rElement)
throw(uno::RuntimeException);
void implDisposeObject( NodeAccess& aNode, InnerElement& rElement)
throw(uno::RuntimeException);
// XTypeProvider
//---------------------------------------------------------------------
uno::Sequence<sal_Int8> implGetImplementationId(NodeAccess& rNode, NodeElement& rElement ) throw(uno::RuntimeException);
// XChild
//---------------------------------------------------------------------
uno::Reference< uno::XInterface > implGetParent(NodeAccess& rNode, InnerElement& rElement)
throw(uno::RuntimeException);
uno::Reference< uno::XInterface > implGetParent(NodeAccess& rNode, SetElement& rElement)
throw(uno::RuntimeException);
void implSetParent(NodeAccess& rNode, InnerElement& rElement, const uno::Reference< uno::XInterface >& Parent ) // generally not supported
throw(css::lang::NoSupportException, css::uno::RuntimeException);
void implSetParent(NodeAccess& rNode, SetElement& rElement, const uno::Reference< uno::XInterface >& Parent ) // maybe supported
throw(css::lang::NoSupportException, css::uno::RuntimeException);
// XNamed
//---------------------------------------------------------------------
rtl::OUString implGetName(NodeAccess& rNode, NodeElement& rElement)
throw(uno::RuntimeException);
void implSetName(NodeAccess& rNode, NodeElement& rElement, const rtl::OUString& aName ) // generally not supported (! - missing exception)
throw(uno::RuntimeException);
void implSetName(NodeAccess& rNode, SetElement& rElement, const rtl::OUString& aName ) // maybe supported
throw(uno::RuntimeException);
// XServiceInfo
//---------------------------------------------------------------------
rtl::OUString implGetImplementationName( NodeAccess& rNode, NodeElement& rElement )
throw(uno::RuntimeException);
sal_Bool implSupportsService( NodeAccess& rNode, NodeElement& rElement, const rtl::OUString& ServiceName )
throw(uno::RuntimeException);
uno::Sequence< rtl::OUString > implGetSupportedServiceNames( NodeAccess& rNode, NodeElement& rElement )
throw(uno::RuntimeException);
// Root only only
//-------------------------------------------------------------------------
// XLocalizable
//---------------------------------------------------------------------
css::lang::Locale implGetLocale( RootElement& rElement )
throw(uno::RuntimeException);
void implSetLocale( RootElement& rElement, const css::lang::Locale& eLocale )
throw(uno::RuntimeException);
// XChangesBatch
//---------------------------------------------------------------------
void implCommitChanges( UpdateRootElement& rElement )
throw(css::lang::WrappedTargetException, uno::RuntimeException);
sal_Bool implHasPendingChanges( RootElement& rElement )
throw(uno::RuntimeException);
uno::Sequence< css::util::ElementChange > implGetPendingChanges( RootElement& rElement )
throw(uno::RuntimeException);
// Set only
//-------------------------------------------------------------------------
// XTemplateInstance
//---------------------------------------------------------------------
rtl::OUString implGetTemplateName(SetElement& rElement)
throw(uno::RuntimeException);
// XUnoTunnel
//---------------------------------------------------------------------
sal_Int64 implGetSomething(SetElement& rElement, const uno::Sequence< sal_Int8 >& aIdentifier )
throw(uno::RuntimeException);
//-------------------------------------------------------------------------
}
}
#endif // CONFIGMGR_API_BASEACCESSIMPL_HXX_
-144
View File
@@ -1,144 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "groupaccess.hxx"
#include "accessimpl.hxx"
#include "apinotifierimpl.hxx"
#include "apinodeaccess.hxx"
namespace configmgr
{
// XHierarchicalName
//------------------------------------------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicGroupAccess::getHierarchicalName( ) throw(uno::RuntimeException)
{
return configapi::implGetHierarchicalName( getNode() );
}
//------------------------------------------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicGroupAccess::composeHierarchicalName( const rtl::OUString& sRelativeName )
throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, uno::RuntimeException)
{
return configapi::implComposeHierarchicalName( getNode(), sRelativeName );
}
//------------------------------------------------------------------------------------------------------------------
// XElementAccess, base class of XNameAccess (and XHierarchicalNameAccess ? )
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
uno::Type SAL_CALL BasicGroupAccess::getElementType( ) throw(uno::RuntimeException)
{
return configapi::implGetElementType( getNode() );
}
//-----------------------------------------------------------------------------------
sal_Bool SAL_CALL BasicGroupAccess::hasElements( ) throw(uno::RuntimeException)
{
return configapi::implHasElements( getNode() );
}
// XExactName
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicGroupAccess::getExactName( const rtl::OUString& rApproximateName ) throw(uno::RuntimeException)
{
return configapi::implGetExactName( getNode(), rApproximateName);
}
// XProperty
//-----------------------------------------------------------------------------------
css::beans::Property SAL_CALL BasicGroupAccess::getAsProperty( ) throw(uno::RuntimeException)
{
return configapi::implGetAsProperty( getNode() );
}
// XNameAccess
//-----------------------------------------------------------------------------------
sal_Bool SAL_CALL BasicGroupAccess::hasByName( const rtl::OUString& sName ) throw(uno::RuntimeException)
{
return configapi::implHasByName( getNode(), sName);
}
//-----------------------------------------------------------------------------------
uno::Any SAL_CALL BasicGroupAccess::getByName( const rtl::OUString& sName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
{
return configapi::implGetByName( getNode(), sName );
}
//-----------------------------------------------------------------------------------
uno::Sequence< rtl::OUString > SAL_CALL BasicGroupAccess::getElementNames( ) throw( uno::RuntimeException)
{
return configapi::implGetElementNames( getNode() );
}
// XHierarchicalNameAccess
//-----------------------------------------------------------------------------------
sal_Bool SAL_CALL BasicGroupAccess::hasByHierarchicalName( const rtl::OUString& sName ) throw(uno::RuntimeException)
{
return configapi::implHasByHierarchicalName( getNode(), sName);
}
//-----------------------------------------------------------------------------------
uno::Any SAL_CALL BasicGroupAccess::getByHierarchicalName( const rtl::OUString& sName )
throw(css::container::NoSuchElementException, uno::RuntimeException)
{
return configapi::implGetByHierarchicalName( getNode(), sName );
}
// XContainer
//-----------------------------------------------------------------------------------
void SAL_CALL BasicGroupAccess::addContainerListener( const uno::Reference< css::container::XContainerListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implAddListener( getNode(), xListener );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicGroupAccess::removeContainerListener( const uno::Reference< css::container::XContainerListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implRemoveListener( getNode(), xListener );
}
//-----------------------------------------------------------------------------------
} // namespace configmgr
-135
View File
@@ -1,135 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_GROUPACCESS_HXX_
#define CONFIGMGR_API_GROUPACCESS_HXX_
#include <com/sun/star/container/XHierarchicalName.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/container/XContainer.hpp>
#include <com/sun/star/beans/XExactName.hpp>
#include <com/sun/star/beans/XProperty.hpp>
#include <cppuhelper/implbase6.hxx>
namespace configmgr
{
namespace css = ::com::sun::star;
namespace uno = ::com::sun::star::uno;
namespace configapi { class NodeGroupInfoAccess; }
/** implements the (read-only) interfaces supported by a group node
within the configuration tree.
<p> Is an interface adapter around <type scope='configmgr::configapi'>NodeAccess</type>.</p>
*/
class BasicGroupAccess
: public ::cppu::ImplHelper6
< css::container::XNameAccess
, css::container::XHierarchicalName
, css::container::XHierarchicalNameAccess
, css::container::XContainer
, css::beans::XExactName
, css::beans::XProperty
>
{
protected:
// Destructors
virtual ~BasicGroupAccess() {}
public:
// Interface methods
// XHierarchicalName
virtual rtl::OUString SAL_CALL
getHierarchicalName( )
throw(uno::RuntimeException);
virtual rtl::OUString SAL_CALL
composeHierarchicalName( const rtl::OUString& aRelativeName )
throw(css::lang::IllegalArgumentException, css::lang::NoSupportException,
uno::RuntimeException);
// XElementAccess, base class of XNameAccess
virtual uno::Type SAL_CALL
getElementType( )
throw(uno::RuntimeException);
virtual sal_Bool SAL_CALL
hasElements( )
throw(uno::RuntimeException);
// XNameAccess
virtual uno::Any SAL_CALL
getByName( const rtl::OUString& aName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException,
uno::RuntimeException);
virtual uno::Sequence< rtl::OUString > SAL_CALL
getElementNames( )
throw( uno::RuntimeException);
virtual sal_Bool SAL_CALL
hasByName( const rtl::OUString& aName )
throw(uno::RuntimeException);
// XHierarchicalNameAccess
virtual uno::Any SAL_CALL
getByHierarchicalName( const rtl::OUString& aName )
throw(css::container::NoSuchElementException, uno::RuntimeException);
virtual sal_Bool SAL_CALL
hasByHierarchicalName( const rtl::OUString& aName )
throw(uno::RuntimeException);
// XContainer
virtual void SAL_CALL
addContainerListener( const uno::Reference< css::container::XContainerListener >& xListener )
throw(uno::RuntimeException);
virtual void SAL_CALL
removeContainerListener( const uno::Reference< css::container::XContainerListener >& xListener )
throw(uno::RuntimeException);
// XExactName
virtual ::rtl::OUString SAL_CALL
getExactName( const rtl::OUString& aApproximateName )
throw(uno::RuntimeException);
// XProperty
virtual css::beans::Property SAL_CALL
getAsProperty( )
throw(uno::RuntimeException);
protected:
virtual configapi::NodeGroupInfoAccess& getNode() = 0;
};
}
#endif // CONFIGMGR_API_GROUPACCESS_HXX_
-407
View File
@@ -1,407 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 <stdio.h>
#include "groupobjects.hxx"
#include "comphelper/sequence.hxx"
//........................................................................
namespace configmgr
{
//==========================================================================
//= OInnerGroupInfo
//==========================================================================
// XInterface refcounting
void SAL_CALL OInnerGroupInfo::acquire( ) throw ()
{
BasicInnerElement::acquire();
}
void SAL_CALL OInnerGroupInfo::release( ) throw ()
{
BasicInnerElement::release();
}
// XInterface joining
uno::Any SAL_CALL OInnerGroupInfo::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicInnerElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicGroupAccess::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicPropertySet::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL OInnerGroupInfo::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicInnerElement::getTypes(), BasicGroupAccess::getTypes(), BasicPropertySet::getTypes());
}
uno::Sequence< sal_Int8 > SAL_CALL OInnerGroupInfo::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicInnerElement::getImplementationId();
}
configapi::NodeAccess& OInnerGroupInfo::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeGroupInfoAccess& OInnerGroupInfo::getNode()
{
return m_aAccessElement;
}
configapi::NodeGroupAccess* OInnerGroupInfo::maybeGetUpdateAccess()
{
return 0;
}
configapi::InnerElement& OInnerGroupInfo::getElementClass()
{
return m_aAccessElement;
}
//==========================================================================
//= OInnerGroupUpdate
//==========================================================================
// XInterface refcounting
void SAL_CALL OInnerGroupUpdate::acquire( ) throw ()
{
BasicInnerElement::acquire();
}
void SAL_CALL OInnerGroupUpdate::release( ) throw ()
{
BasicInnerElement::release();
}
// XInterface joining
uno::Any SAL_CALL OInnerGroupUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicInnerElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicGroup::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicPropertySet::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL OInnerGroupUpdate::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicInnerElement::getTypes(), BasicGroup::getTypes(), BasicPropertySet::getTypes());
}
uno::Sequence< sal_Int8 > SAL_CALL OInnerGroupUpdate::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicInnerElement::getImplementationId();
}
configapi::NodeAccess& OInnerGroupUpdate::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeGroupInfoAccess& OInnerGroupUpdate::getNode()
{
return m_aAccessElement;
}
configapi::NodeGroupAccess* OInnerGroupUpdate::maybeGetUpdateAccess()
{
return &m_aAccessElement;
}
configapi::InnerElement& OInnerGroupUpdate::getElementClass()
{
return m_aAccessElement;
}
//==========================================================================
//= OSetElementGroupInfo
//==========================================================================
// XInterface refcounting
void SAL_CALL OSetElementGroupInfo::acquire( ) throw ()
{
BasicSetElement::acquire();
}
void SAL_CALL OSetElementGroupInfo::release( ) throw ()
{
BasicSetElement::release();
}
// XInterface joining
uno::Any SAL_CALL OSetElementGroupInfo::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicSetElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicGroupAccess::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicPropertySet::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL OSetElementGroupInfo::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicSetElement::getTypes(), BasicGroupAccess::getTypes(), BasicPropertySet::getTypes() );
}
uno::Sequence< sal_Int8 > SAL_CALL OSetElementGroupInfo::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicSetElement::getImplementationId();
}
configapi::NodeAccess& OSetElementGroupInfo::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeGroupInfoAccess& OSetElementGroupInfo::getNode()
{
return m_aAccessElement;
}
configapi::NodeGroupAccess* OSetElementGroupInfo::maybeGetUpdateAccess()
{
return 0;
}
configapi::SetElement& OSetElementGroupInfo::getElementClass()
{
return m_aAccessElement;
}
//==========================================================================
//= OSetElementGroupUpdate
//==========================================================================
// XInterface refcounting
void SAL_CALL OSetElementGroupUpdate::acquire( ) throw ()
{
BasicSetElement::acquire();
}
void SAL_CALL OSetElementGroupUpdate::release( ) throw ()
{
BasicSetElement::release();
}
// XInterface joining
uno::Any SAL_CALL OSetElementGroupUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicSetElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicGroup::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicPropertySet::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL OSetElementGroupUpdate::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicSetElement::getTypes(), BasicGroup::getTypes(), BasicPropertySet::getTypes());
}
uno::Sequence< sal_Int8 > SAL_CALL OSetElementGroupUpdate::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicSetElement::getImplementationId();
}
configapi::NodeAccess& OSetElementGroupUpdate::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeGroupInfoAccess& OSetElementGroupUpdate::getNode()
{
return m_aAccessElement;
}
configapi::NodeGroupAccess* OSetElementGroupUpdate::maybeGetUpdateAccess()
{
return &m_aAccessElement;
}
configapi::SetElement& OSetElementGroupUpdate::getElementClass()
{
return m_aAccessElement;
}
//==========================================================================
//= ORootElementGroupInfo
//==========================================================================
// XInterface refcounting
void SAL_CALL ORootElementGroupInfo::acquire( ) throw ()
{
BasicRootElement::acquire();
}
void SAL_CALL ORootElementGroupInfo::release( ) throw ()
{
BasicRootElement::release();
}
// XInterface joining
uno::Any SAL_CALL ORootElementGroupInfo::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicRootElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicGroupAccess::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicPropertySet::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL ORootElementGroupInfo::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicRootElement::getTypes(), BasicGroupAccess::getTypes(), BasicPropertySet::getTypes());
}
uno::Sequence< sal_Int8 > SAL_CALL ORootElementGroupInfo::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicRootElement::getImplementationId();
}
configapi::NodeAccess& ORootElementGroupInfo::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeGroupInfoAccess& ORootElementGroupInfo::getNode()
{
return m_aAccessElement;
}
configapi::NodeGroupAccess* ORootElementGroupInfo::maybeGetUpdateAccess()
{
return 0;
}
configapi::RootElement& ORootElementGroupInfo::getElementClass()
{
return m_aAccessElement;
}
//==========================================================================
//= ORootElementGroupUpdate
//==========================================================================
// XInterface refcounting
void SAL_CALL ORootElementGroupUpdate::acquire( ) throw ()
{
BasicUpdateElement::acquire();
}
void SAL_CALL ORootElementGroupUpdate::release( ) throw ()
{
BasicUpdateElement::release();
}
// XInterface joining
uno::Any SAL_CALL ORootElementGroupUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicUpdateElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicGroup::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicPropertySet::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL ORootElementGroupUpdate::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicUpdateElement::getTypes(),BasicGroup::getTypes(), BasicPropertySet::getTypes());
}
uno::Sequence< sal_Int8 > SAL_CALL ORootElementGroupUpdate::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicUpdateElement::getImplementationId();
}
configapi::NodeAccess& ORootElementGroupUpdate::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeGroupInfoAccess& ORootElementGroupUpdate::getNode()
{
return m_aAccessElement;
}
configapi::NodeGroupAccess* ORootElementGroupUpdate::maybeGetUpdateAccess()
{
return &m_aAccessElement;
}
configapi::UpdateRootElement& ORootElementGroupUpdate::getElementClass()
{
return m_aAccessElement;
}
//........................................................................
} // namespace configmgr
//........................................................................
-268
View File
@@ -1,268 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_GROUPOBJECTS_HXX_
#define CONFIGMGR_API_GROUPOBJECTS_HXX_
#include "groupaccess.hxx"
#include "groupupdate.hxx"
#include "propertysetaccess.hxx"
#include "elementaccess.hxx"
#include "apiaccessobj.hxx"
//........................................................................
namespace configmgr
{
//........................................................................
//==========================================================================
//= Inner Group Instances
//==========================================================================
/** read-only access class for configuration nodes which are inner nodes and groups of other nodes
*/
class OInnerGroupInfo
: public BasicInnerElement
, public BasicGroupAccess
, public BasicPropertySet
{
public:
// Construction/Destruction
OInnerGroupInfo(configapi::ApiTreeImpl& rTree, configuration::NodeRef const& aNode)
: m_aAccessElement(static_cast<css::container::XChild*>(this),rTree,aNode)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeGroupInfoAccess& getNode();
virtual configapi::NodeGroupAccess* maybeGetUpdateAccess();
virtual configapi::InnerElement& getElementClass();
private:
configapi::OInnerElement<configapi::NodeGroupInfoAccess> m_aAccessElement;
};
/** updating access class for configuration nodes which are inner nodes and groups of other nodes
*/
class OInnerGroupUpdate
: public BasicInnerElement
, public BasicGroup
, public BasicPropertySet
{
public:
// Construction/Destruction
OInnerGroupUpdate(configapi::ApiTreeImpl& rTree, configuration::NodeRef const& aNode)
: m_aAccessElement(static_cast<css::container::XChild*>(this),rTree,aNode)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeGroupInfoAccess& getNode();
virtual configapi::NodeGroupAccess* maybeGetUpdateAccess();
virtual configapi::InnerElement& getElementClass();
private:
configapi::OInnerElement<configapi::NodeGroupAccess> m_aAccessElement;
};
//==========================================================================
//= Set Element Group Instances
//==========================================================================
/** read-only access class for configuration nodes which are set elements and groups of other nodes
*/
class OSetElementGroupInfo
: public BasicSetElement
, public BasicGroupAccess
, public BasicPropertySet
{
public:
// Construction/Destruction
OSetElementGroupInfo(rtl::Reference< configuration::Tree > const& aTree, configapi::ApiProvider& rProvider, configapi::ApiTreeImpl* pParentTree = 0)
: m_aAccessElement(static_cast<css::container::XChild*>(this),aTree,rProvider,pParentTree)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeGroupInfoAccess& getNode();
virtual configapi::NodeGroupAccess* maybeGetUpdateAccess();
virtual configapi::SetElement& getElementClass();
private:
configapi::OSetElement<configapi::NodeGroupInfoAccess> m_aAccessElement;
};
/** updating access class for configuration nodes which are set elements and groups of other nodes
*/
class OSetElementGroupUpdate
: public BasicSetElement
, public BasicGroup
, public BasicPropertySet
{
public:
// Construction/Destruction
OSetElementGroupUpdate(rtl::Reference< configuration::Tree > const& aTree, configapi::ApiProvider& rProvider, configapi::ApiTreeImpl* pParentTree = 0)
: m_aAccessElement(static_cast<css::container::XChild*>(this),aTree,rProvider,pParentTree)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeGroupInfoAccess& getNode();
virtual configapi::NodeGroupAccess* maybeGetUpdateAccess();
virtual configapi::SetElement& getElementClass();
private:
configapi::OSetElement<configapi::NodeGroupAccess> m_aAccessElement;
};
//==========================================================================
//= Root Element Set Instances
//==========================================================================
/** read-only access class for configuration nodes which are root nodes and groups of other nodes
*/
class ORootElementGroupInfo
: public BasicRootElement
, public BasicGroupAccess
, public BasicPropertySet
{
public:
// Construction/Destruction
ORootElementGroupInfo(configapi::ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions)
: m_aAccessElement(static_cast<css::lang::XComponent*>(this),rProvider,aTree, _xOptions)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeGroupInfoAccess& getNode();
virtual configapi::NodeGroupAccess* maybeGetUpdateAccess();
virtual configapi::RootElement& getElementClass();
private:
configapi::OReadRootElement<configapi::NodeGroupInfoAccess> m_aAccessElement;
};
/** updating access class for configuration nodes which are root nodes and groups of other nodes
*/
class ORootElementGroupUpdate
: public BasicUpdateElement
, public BasicGroup
, public BasicPropertySet
{
public:
// Construction/Destruction
ORootElementGroupUpdate(configapi::ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions)
: m_aAccessElement(static_cast<css::lang::XComponent*>(this),rProvider,aTree, _xOptions)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeGroupInfoAccess& getNode();
virtual configapi::NodeGroupAccess* maybeGetUpdateAccess();
virtual configapi::UpdateRootElement& getElementClass();
private:
configapi::OUpdateRootElement<configapi::NodeGroupAccess> m_aAccessElement;
};
//........................................................................
} // namespace configmgr
//........................................................................
#endif // CONFIGMGR_API_GROUPOBJECTS_HXX_
-104
View File
@@ -1,104 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "groupupdate.hxx"
#include "updateimpl.hxx"
#include "apinodeaccess.hxx"
#include "apitypes.hxx"
#include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/typeprovider.hxx>
namespace configmgr
{
//////////////////////////////////////////////////////////////////////////////////
// class BasicGroup
//////////////////////////////////////////////////////////////////////////////////
// XInterface joining
//////////////////////////////////////////////////////////////////////////////////
uno::Any SAL_CALL BasicGroup::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicGroupAccess::queryInterface( rType );
if (!aRet.hasValue())
{
aRet = cppu::queryInterface(rType
, static_cast< css::container::XNameReplace *>(this)
);
}
return aRet;
}
// XTypeProvider joining
//////////////////////////////////////////////////////////////////////////////////
uno::Sequence< uno::Type > SAL_CALL BasicGroup::getTypes( ) throw (uno::RuntimeException )
{
/*static ?*/
cppu::OTypeCollection aTypes(
configapi::getReferenceType(static_cast< css::container::XNameReplace *>(this)),
BasicGroupAccess::getTypes());
return aTypes.getTypes();
}
//uno::Sequence< sal_Int8 > SAL_CALL BasicGroup::getImplementationId( ) throw (uno::RuntimeException ) = 0;
//////////////////////////////////////////////////////////////////////////////////
// safe write access
/////////////////////////////////////////////////////////////
configapi::NodeGroupAccess& BasicGroup::getGroupNode()
{
configapi::NodeGroupAccess* pAccess = maybeGetUpdateAccess();
OSL_ENSURE(pAccess, "Write operation invoked on a read-only node access - failing with RuntimeException");
if (!pAccess)
{
throw uno::RuntimeException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: Invalid Object - internal update interface missing.")),
static_cast< css::container::XNameReplace * >(this)
);
}
return *pAccess;
}
// New Interface methods
// XNameReplace
//////////////////////////////////////////////////////////////////////////////////
void SAL_CALL BasicGroup::replaceByName( const rtl::OUString& rName, const uno::Any& rElement )
throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implReplaceByName( getGroupNode(), rName, rElement );
}
//-----------------------------------------------------------------------------------
} // namespace configmgr
-98
View File
@@ -1,98 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_GROUPUPDATE_HXX_
#define CONFIGMGR_API_GROUPUPDATE_HXX_
#include "groupaccess.hxx"
#include <com/sun/star/container/XNameReplace.hpp>
//........................................................................
namespace configmgr
{
//........................................................................
namespace configapi { class NodeGroupAccess; }
//==========================================================================
//= BasicGroup
//==========================================================================
/** base class for configuration nodes which are dynamic sets of complex types (trees)
*/
class BasicGroup
: public BasicGroupAccess
, public css::container::XNameReplace
{
protected:
// Destructors
virtual ~BasicGroup() {}
public:
// Base class Interface methods
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ) = 0;
// XElementAccess forwarding
virtual uno::Type SAL_CALL getElementType( ) throw(uno::RuntimeException)
{ return BasicGroupAccess::getElementType(); }
virtual sal_Bool SAL_CALL hasElements( ) throw(uno::RuntimeException)
{ return BasicGroupAccess::hasElements(); }
// XNameAccess forwarding
virtual uno::Any SAL_CALL getByName( const rtl::OUString& aName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
{ return BasicGroupAccess::getByName(aName); }
virtual uno::Sequence< rtl::OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException)
{ return BasicGroupAccess::getElementNames(); }
virtual sal_Bool SAL_CALL hasByName( const rtl::OUString& aName ) throw(uno::RuntimeException)
{ return BasicGroupAccess::hasByName(aName); }
// New Interface methods
// XNameReplace
virtual void SAL_CALL
replaceByName( const rtl::OUString& rName, const uno::Any& rElement )
throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
protected:
configapi::NodeGroupAccess& getGroupNode();
virtual configapi::NodeGroupAccess* maybeGetUpdateAccess() = 0;
};
//........................................................................
} // namespace configmgr
//........................................................................
#endif // CONFIGMGR_API_GROUPUPDATE_HXX_
@@ -1,80 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "listenercontainer.hxx"
#include <com/sun/star/lang/XEventListener.hpp>
#include <osl/diagnose.h>
namespace configmgr
{
namespace configapi
{
/////////////////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
// class DisposeNotifier
//-----------------------------------------------------------------------------
void DisposeNotifier::appendAndClearContainer(cppu::OInterfaceContainerHelper* pContainer)
{
if (pContainer)
{
{
cppu::OInterfaceIteratorHelper aIterator(*pContainer);
while (aIterator.hasMoreElements())
{
aListeners.push_back(uno::Reference< lang::XEventListener >::query(aIterator.next()));
}
}
pContainer->clear();
}
}
//-----------------------------------------------------------------------------
void DisposeNotifier::notify()
{
for(std::vector< uno::Reference< lang::XEventListener > >::iterator it = aListeners.begin(); it != aListeners.end(); ++it)
{
if (it->is())
{
try { (*it)->disposing(aEvent); } catch (uno::Exception & ) {}
it->clear();
}
}
aListeners.clear();
}
//-----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////////////////
}
}
-581
View File
@@ -1,581 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_LISTENERCONTAINER_HXX_
#define CONFIGMGR_API_LISTENERCONTAINER_HXX_
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <cppuhelper/interfacecontainer.hxx>
#include "datalock.hxx"
#include "utility.hxx"
#include <osl/diagnose.h>
namespace configmgr
{
namespace configapi
{
/////////////////////////////////////////////////////////////////////////////////////////////
namespace css = ::com::sun::star;
namespace uno = css::uno;
namespace lang = css::lang;
//-----------------------------------------------------------------------------
template <class Listener>
class ListenerContainerIterator
{
public:
/**
* Create an iterator over the elements of the container. The iterator
* copies the elements of the conatainer. A change to the container does not
* affect the iterator.<BR>
* Remark: The copy is on demand. The iterator copy the elements only if the container
* change the contens. It is not allowed to destroy the container if a iterator exist.
*
* @param rCont the container of the elements.
*/
ListenerContainerIterator( cppu::OInterfaceContainerHelper& rCont )
: m_aIter(rCont)
, m_xNext()
{ advance(); }
/**
* Release the connection to the container.
*/
~ListenerContainerIterator() {}
/** Return true, if there are more elements in the iterator. */
sal_Bool hasMoreElements() const { return m_xNext.is() != 0; }
/** Return the next element of the iterator. Call this method if
* hasMoreElements return false, is an error.
*/
uno::Reference<Listener> next();
private:
void advance();
cppu::OInterfaceIteratorHelper m_aIter;
uno::Reference<Listener> m_xNext;
};
//-----------------------------------------------------------------------------
class DisposeNotifier
{
lang::EventObject aEvent;
std::vector< uno::Reference< lang::XEventListener > > aListeners;
public:
explicit
DisposeNotifier(uno::Reference<uno::XInterface> const& aInterface) : aEvent(aInterface) {}
void appendAndClearContainer(cppu::OInterfaceContainerHelper* pContainer);
void notify();
};
//-----------------------------------------------------------------------------
struct BasicContainerInfo
{
uno::XInterface* pInterface;
cppu::OMultiTypeInterfaceContainerHelper* pContainer;
BasicContainerInfo() : pInterface(0), pContainer(0) {}
};
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
class SpecialListenerContainer
{
public:
/**
* Create a container of interface containers.
*/
SpecialListenerContainer(std::vector<BasicContainerInfo>::size_type nCount, KeyToIndex_ aMapper)
: m_aSpecialHelper(UnoApiLock::getLock())
, m_aContainers(nCount)
, m_aMapper(aMapper)
, m_bDisposeLock(false)
{}
~SpecialListenerContainer()
{
OSL_ENSURE(isDisposed(), "ERROR: Object was not disposed properly");
}
public:
/**
* check whether this is disposed or still alive
* @param pObject
* an interface on the object on which's behalf the operation was started
* @return <FALSE/>
* if the object is being disposed
* @throw com::sun::star::lang::DisposedException
* if the object was disposed completely
*/
bool checkAlive(uno::XInterface* pObject = 0) volatile const throw(lang::DisposedException);
/// return whether the object is completely alive
bool isAlive() volatile const throw();
/// return whether the object is currently being disposed
bool isDisposing()volatile const throw();
/// return whether the object is completely disposed
bool isDisposed()volatile const throw();
/// return whether the object is present in this container
bool isAvailable(std::vector<BasicContainerInfo>::size_type nIndex) const throw()
{
return nIndex < m_aContainers.size() && m_aContainers[nIndex].pInterface;
}
std::vector<BasicContainerInfo>::size_type getSize() const
{
return m_aContainers.size();
}
/// return the interface associated with an index
void setObjectAt(std::vector<BasicContainerInfo>::size_type nIndex, uno::XInterface* pInterface)
{
OSL_ENSURE( !isDisposed(), "object is disposed" );
if (isAlive())
{
OSL_ENSURE( nIndex < m_aContainers.size(), " Invalid Index into Notifier");
OSL_ENSURE( pInterface, "Invalid NULL Interface passed into Notifier");
if ( nIndex < m_aContainers.size() && pInterface != NULL)
{
OSL_ENSURE( m_aContainers[nIndex].pInterface == NULL, "Interface already set");
if (m_aContainers[nIndex].pInterface == NULL)
m_aContainers[nIndex].pInterface = pInterface;
}
}
}
/// return the interface associated with an index
uno::Reference<uno::XInterface> getObjectAt(std::vector<BasicContainerInfo>::size_type nIndex) const
{
uno::Reference<uno::XInterface> xRet( nIndex < m_aContainers.size() ? m_aContainers[nIndex].pInterface : 0 );
return xRet;
}
/// return the interface associated with an index
uno::Reference<uno::XInterface> getObjectForKey(Key_ const& aKey ) const
{
std::vector<BasicContainerInfo>::size_type nIndex = m_aMapper.findIndexForKey(aKey);
uno::Reference<uno::XInterface> xRet( nIndex < m_aContainers.size() ? m_aContainers[nIndex].pInterface : 0 );
return xRet;
}
/**
* Call disposing on all object in all the container for anIndex
* and in the containers for the associated indices
* support XEventListener. Then clear the container.
*/
bool disposeOne( std::vector<BasicContainerInfo>::size_type anIndex ) throw();
/**
* Start disposing this object
* @return <TRUE/>
* if disposing has been started
* @return <FALSE/>
* if disposing had already been started before
*/
bool beginDisposing() throw();
/**
* Continue disposing this object
* <p> Call disposing on all object in all the containers that
* support XEventListener. Then clear the container.
* </p>
* @return <TRUE/>
* if disposing has been started
* @return <FALSE/>
* if disposing had already been started before
*/
void notifyDisposing() throw();
/// mark the end of the dispose processing
void endDisposing() throw();
public:
/**
* Return the specuial container created under this key.
* @return the container created under this key. If the container
* was not created, null was returned.
*/
cppu::OInterfaceContainerHelper * getSpecialContainer( const Key_ & aKey) const
{ return m_aSpecialHelper.aLC.getContainer(aKey); }
/**
* Return the containerhelper created under this index.
* @return the container helper created under this key. If the container helper
* was not created, null was returned.
*/
cppu::OMultiTypeInterfaceContainerHelper * getContainerHelper( std::vector<BasicContainerInfo>::size_type nIndex) const
{
return ((nIndex < m_aContainers.size()) ? m_aContainers[nIndex].pContainer : 0 );
}
/**
* Return the container for the given type created under this index.
* @return the container created under this key. If the container
* was not created, null was returned.
*/
cppu::OInterfaceContainerHelper * getContainer( std::vector<BasicContainerInfo>::size_type nIndex, const uno::Type & aType) const
{
cppu::OMultiTypeInterfaceContainerHelper* pContainer = (nIndex < m_aContainers.size()) ? m_aContainers[nIndex].pContainer : 0 ;
return pContainer ? pContainer->getContainer(aType) : 0;
}
/**
* Insert an element in the container specified with the index and type. The position is not specified.
* The interface at the given index must be set already.
* @param aKey the id of the container.
* @param xListener the added interface. It is allowed to insert null or
* the same pointer more than once.
* @return the new count of elements in the container (or 0 if the object is ready being disposed).
*/
sal_Int32 addListener( std::vector<BasicContainerInfo>::size_type nIndex, const uno::Type& aType, uno::Reference< lang::XEventListener > const& xListener) throw();
/**
* Remove an element from the container specified with the index and type.
* It uses the equal definition of uno objects to remove the interfaces.
* @param aKey the id of the container.
* @param xListener the removed interface.
* @return the new count of elements in the container (or 0 if the object is ready being disposed).
*/
sal_Int32 removeListener( std::vector<BasicContainerInfo>::size_type nIndex, const uno::Type& aType, uno::Reference< lang::XEventListener > const& xListener) throw();
/**
* Insert an element in the special container specified with the key. The position is not specified.
* The interface at the given index must be set already.
* @param aKey the id of the container.
* @param xListener the added interface. It is allowed to insert null or
* the same pointer more than once.
* @return the new count of elements in the container (or 0 if the object is ready being disposed).
*/
sal_Int32 addSpecialListener( const Key_& aKey, uno::Reference< lang::XEventListener > const& xListener) throw();
/**
* Remove an element from the container specified with the key.
* It uses the equal definition of uno objects to remove the interfaces.
* @param aKey the id of the container.
* @param xListener the removed interface.
* @return the new count of elements in the container (or 0 if the object is ready being disposed).
*/
sal_Int32 removeSpecialListener( const Key_& aKey, uno::Reference< lang::XEventListener > const& xListener) throw();
private:
void implFillDisposer(DisposeNotifier& aNotifier, std::vector<BasicContainerInfo>::size_type nIndex);
cppu::OBroadcastHelperVar< cppu::OMultiTypeInterfaceContainerHelperVar< Key_,KeyHash_,KeyEq_ >, Key_ > m_aSpecialHelper;
std::vector<BasicContainerInfo> m_aContainers;
KeyToIndex_ m_aMapper;
bool m_bDisposeLock;
};
//-----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////////////////
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::checkAlive(uno::XInterface* pObject) volatile const throw(lang::DisposedException)
{
bool bAlive = !m_aSpecialHelper.bInDispose;
if (m_aSpecialHelper.bDisposed)
{
throw lang::DisposedException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The object has already been disposed")),pObject);
}
return bAlive;
}
//-----------------------------------------------------------------------------
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
inline
bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::isAlive() volatile const throw()
{
return !m_aSpecialHelper.bInDispose && !m_aSpecialHelper.bDisposed;
}
//-----------------------------------------------------------------------------
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
inline
bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::isDisposing() volatile const throw()
{
return !!m_aSpecialHelper.bInDispose;
}
//-----------------------------------------------------------------------------
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
inline
bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::isDisposed() volatile const throw()
{
return !!m_aSpecialHelper.bDisposed;
}
//-----------------------------------------------------------------------------
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::disposeOne(std::vector<BasicContainerInfo>::size_type nIndex) throw()
{
// OSL_ENSURE(!isDisposed(),"Object is already disposed in toto");
if (isAlive())
{
if (nIndex < m_aContainers.size())
{
if (uno::XInterface* pObject = m_aContainers[nIndex].pInterface)
{
DisposeNotifier aNotifier(pObject);
implFillDisposer(aNotifier, nIndex);
m_aContainers[nIndex].pInterface = 0;
delete m_aContainers[nIndex].pContainer;
aNotifier.notify();
}
}
return true;
}
else
return false;
}
//-----------------------------------------------------------------------------
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::beginDisposing() throw()
{
if (isAlive())
{
m_aSpecialHelper.bInDispose = sal_True;
m_bDisposeLock = true;
return true;
}
return false;
}
//-----------------------------------------------------------------------------
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
void SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::notifyDisposing() throw()
{
OSL_ENSURE(isDisposing(),"Disposing isn't in progress on this object");
OSL_ENSURE(m_bDisposeLock,"Duplicate call for dispose notification or disposing is not taking place");
if (m_bDisposeLock)
{
OSL_ASSERT(m_aSpecialHelper.bInDispose);
lang::EventObject aBaseEvt;
std::vector<DisposeNotifier> aNotifiers;
if (std::vector<BasicContainerInfo>::size_type size = m_aContainers.size())
{
aNotifiers.reserve(m_aContainers.size());
aBaseEvt.Source = m_aContainers[0].pInterface;
for(std::vector<BasicContainerInfo>::size_type ix = 0; ix < size; ++ix)
{
if (m_aContainers[ix].pInterface)
{
aNotifiers.push_back(DisposeNotifier(m_aContainers[ix].pInterface));
implFillDisposer(aNotifiers.back(), ix);
m_aContainers[ix].pInterface = 0;
delete m_aContainers[ix].pContainer;
}
}
}
m_bDisposeLock = false;
for(std::vector<BasicContainerInfo>::size_type jx = 0, count = aNotifiers.size(); jx < count; ++jx)
{
aNotifiers[jx].notify();
}
// in case we missed something
m_aSpecialHelper.aLC.disposeAndClear( aBaseEvt );
}
}
//-----------------------------------------------------------------------------
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
void SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::endDisposing() throw()
{
OSL_ENSURE(isDisposing(),"Disposing isn't in progress on this object");
if (!isAlive())
{
OSL_ENSURE(!m_bDisposeLock,"Did you forget to notify ?");
m_aSpecialHelper.bDisposed = sal_True;
m_aSpecialHelper.bInDispose = sal_False;
if (m_bDisposeLock)
{
m_bDisposeLock = false;
}
}
}
//-----------------------------------------------------------------------------
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::addListener( std::vector<BasicContainerInfo>::size_type nIndex, const uno::Type& aType, const uno::Reference< lang::XEventListener > & xListener ) throw()
{
if ( nIndex < m_aContainers.size() && m_aContainers[nIndex].pInterface )
{
if ( isAlive() )
{
if (m_aContainers[nIndex].pContainer == 0)
m_aContainers[nIndex].pContainer = new cppu::OMultiTypeInterfaceContainerHelper(UnoApiLock::getLock());
return m_aContainers[nIndex].pContainer->addInterface(aType,xListener);
}
else if (xListener.is())
{
lang::EventObject aEvent(m_aContainers[nIndex].pInterface);
try { xListener->disposing(aEvent); } catch (uno::Exception & ) {}
}
}
else
OSL_ENSURE(false, "Invalid index or interface not set");
return 0;
}
//-----------------------------------------------------------------------------
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::addSpecialListener( const Key_& aKey, const uno::Reference< lang::XEventListener > & xListener ) throw()
{
std::vector<BasicContainerInfo>::size_type nIndex = m_aMapper.findIndexForKey(aKey);
if ( nIndex < m_aContainers.size() && m_aContainers[nIndex].pInterface )
{
if ( isAlive() )
{
return m_aSpecialHelper.aLC.addInterface(aKey,xListener);
}
else if (xListener.is())
{
lang::EventObject aEvent(m_aContainers[nIndex].pInterface);
try { xListener->disposing(aEvent); } catch (uno::Exception & ) {}
}
}
else
OSL_ENSURE(false, "Invalid index or interface not set");
return 0;
}
//-----------------------------------------------------------------------------
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::removeListener( std::vector<BasicContainerInfo>::size_type nIndex, const uno::Type& aType, const uno::Reference< lang::XEventListener > & xListener ) throw()
{
OSL_ENSURE( !isDisposed(), "object is disposed" );
if ( isAlive() )
{
if ( nIndex < m_aContainers.size() && m_aContainers[nIndex].pContainer )
{
return m_aContainers[nIndex].pContainer->removeInterface(aType,xListener);
}
}
return 0;
}
//-----------------------------------------------------------------------------
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
sal_Int32 SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::removeSpecialListener( const Key_& aKey, const uno::Reference< lang::XEventListener > & xListener ) throw()
{
OSL_ENSURE( !isDisposed(), "object is disposed" );
if ( isAlive() )
return m_aSpecialHelper.aLC.removeInterface(aKey, xListener );
else
return 0;
}
//-----------------------------------------------------------------------------
// relation function. Uses KeyToIndex
/* template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::Index
SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::findIndexForKey(Key const& aKey)
{
m_aMapper.findIndexForKey(aKey);
}
//-----------------------------------------------------------------------------
// relation function. Uses KeyToIndex
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
bool SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::findKeysForIndex(std::vector<BasicContainerInfo>::size_type nIndex, std::vector<Key_> & aKeys)
{
aKeys.clear();
m_aMapper.findKeysForIndex(nIndex,aKeys);
return !aKeys.empty();
}
*///-----------------------------------------------------------------------------
// relation function. Uses KeyToIndex
template <class Key_, class KeyHash_, class KeyEq_, class KeyToIndex_>
void SpecialListenerContainer<Key_,KeyHash_,KeyEq_, KeyToIndex_>::implFillDisposer(DisposeNotifier& aNotifier, std::vector<BasicContainerInfo>::size_type nIndex)
{
if (cppu::OMultiTypeInterfaceContainerHelper* pMultiContainer = m_aContainers[nIndex].pContainer)
{
uno::Sequence< uno::Type > aTypes(pMultiContainer->getContainedTypes());
for (sal_Int32 ix = 0; ix < aTypes.getLength(); ++ix)
{
cppu::OInterfaceContainerHelper* pContainer = pMultiContainer->getContainer(aTypes[ix]);
OSL_ENSURE(pContainer,"No container, but the type ?");
if (pContainer)
aNotifier.appendAndClearContainer(pContainer);
}
}
std::vector<Key_> aKeys;
if (m_aMapper.findKeysForIndex(nIndex,aKeys))
{
for(typename std::vector<Key_>::iterator it = aKeys.begin(); it != aKeys.end(); ++it)
{
if (cppu::OInterfaceContainerHelper* pContainer = m_aSpecialHelper.aLC.getContainer(*it))
{
aNotifier.appendAndClearContainer(pContainer);
}
}
}
}
//-----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////////////////
template <class Listener>
inline
void ListenerContainerIterator<Listener>::advance()
{
while (!m_xNext.is() && m_aIter.hasMoreElements())
{
m_xNext = m_xNext.query( m_aIter.next() );
}
}
//-----------------------------------------------------------------------------
template <class Listener>
uno::Reference<Listener> ListenerContainerIterator<Listener>::next()
{
uno::Reference<Listener> xRet(m_xNext);
m_xNext.clear();
advance();
return xRet;
}
//-----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif // CONFIGMGR_API_LISTENERCONTAINER_HXX_
-79
View File
@@ -1,79 +0,0 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# 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.
#
#*************************************************************************
PRJ=..$/..
PRJINC=$(PRJ)$/source$/inc
PRJNAME=configmgr
TARGET=api2
ENABLE_EXCEPTIONS=TRUE
# --- Settings ----------------------------------
.INCLUDE : settings.mk
.INCLUDE : $(PRJ)$/makefile.pmk
# --- Files -------------------------------------
SLOFILES= \
$(SLO)$/broadcaster.obj \
$(SLO)$/listenercontainer.obj \
$(SLO)$/provider.obj \
$(SLO)$/providerimpl.obj \
$(SLO)$/accessimpl.obj \
$(SLO)$/apiaccessobj.obj \
$(SLO)$/apiserviceinfo.obj \
$(SLO)$/apifactory.obj \
$(SLO)$/apifactoryimpl.obj \
$(SLO)$/apinodeaccess.obj \
$(SLO)$/apinodeupdate.obj \
$(SLO)$/apinotifierimpl.obj \
$(SLO)$/apitreeaccess.obj \
$(SLO)$/apitreeimplobj.obj \
$(SLO)$/confignotifier.obj \
$(SLO)$/committer.obj \
$(SLO)$/elementaccess.obj \
$(SLO)$/elementimpl.obj \
$(SLO)$/groupaccess.obj \
$(SLO)$/groupobjects.obj \
$(SLO)$/groupupdate.obj \
$(SLO)$/propertiesfilterednotifier.obj \
$(SLO)$/propertyinfohelper.obj \
$(SLO)$/propertysetaccess.obj \
$(SLO)$/propsetaccessimpl.obj \
$(SLO)$/setaccess.obj \
$(SLO)$/setobjects.obj \
$(SLO)$/setupdate.obj \
$(SLO)$/translatechanges.obj \
$(SLO)$/treeiterators.obj \
$(SLO)$/updateimpl.obj \
# --- Targets ----------------------------------
.INCLUDE : target.mk
-238
View File
@@ -1,238 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_NOTIFIERIMPL_HXX_
#define CONFIGMGR_API_NOTIFIERIMPL_HXX_
#include "listenercontainer.hxx"
#include "noderef.hxx"
#include "valueref.hxx"
#include <com/sun/star/beans/XPropertyChangeListener.hpp>
#include <com/sun/star/beans/XVetoableChangeListener.hpp>
#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
#include <com/sun/star/beans/PropertyVetoException.hpp>
#include <com/sun/star/container/XContainerListener.hpp>
#include <com/sun/star/util/XChangesListener.hpp>
#include "propertiesfilterednotifier.hxx"
#include <vos/refernce.hxx>
namespace configmgr
{
namespace configapi
{
// ---------------------------------------------------------------------------------------------------
struct SubNodeHash
{
size_t operator() (const configuration::SubNodeID& rKey) const {return rKey.hashCode();}
};
struct SubNodeEq
{
bool operator() (const configuration::SubNodeID& lhs,const configuration::SubNodeID& rhs) const {return lhs == rhs;}
};
struct SubNodeToIndex
{
rtl::Reference< configuration::Tree > aTree;
SubNodeToIndex( rtl::Reference< configuration::Tree > const& rTree ) : aTree(rTree) {}
bool findKeysForIndex(unsigned int nNode, std::vector<configuration::SubNodeID>& aList)
{
aList.clear();
configuration::getAllChildrenHelper(configuration::findNodeFromIndex(aTree,nNode), aList);
return !aList.empty();
}
unsigned int findIndexForKey(configuration::SubNodeID const& aNode)
{
return aNode.getParentID().toIndex();
}
};
/// manages collections of event listeners observing a whole config tree, thread-safe
class NotifierImpl : public vos::OReference
{
public:
SpecialListenerContainer <configuration::SubNodeID,SubNodeHash,SubNodeEq,SubNodeToIndex> m_aListeners;
public:
/// construct this around the given Implementation, for the given tree
explicit
NotifierImpl(rtl::Reference< configuration::Tree > const& aTree);
~NotifierImpl();
/// Add a <type scope='com::sun::star::lang'>XEventListener</type> observing <var>aNode</var>.
void add(configuration::NodeID const& aNode, uno::Reference< css::lang::XEventListener > const& xListener)
{
OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener");
// ignore the names for now
m_aListeners.addListener(aNode.toIndex(),getCppuType(&xListener),xListener.get());
}
/// Add a <type scope='com::sun::star::container'>XContainerListener</type> observing <var>aNode</var>.
void add(configuration::NodeID const& aNode, uno::Reference< css::container::XContainerListener > const& xListener)
{
OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener");
// ignore the names for now
m_aListeners.addListener(aNode.toIndex(),getCppuType(&xListener),xListener.get());
}
/// Add a <type scope='com::sun::star::util'>XChangesListener</type> observing <var>aNode</var> and its descendants.
void add(configuration::NodeID const& aNode, uno::Reference< css::util::XChangesListener > const& xListener)
{
OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener");
// ignore the names for now
m_aListeners.addListener(aNode.toIndex(),getCppuType(&xListener),xListener.get());
}
/// Add a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing <var>aNode</var>.
void addNamed(configuration::SubNodeID const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener)
{
OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener");
// ignore the names for now
m_aListeners.addSpecialListener(aNode,xListener.get());
}
/// Add a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing <var>aNode</var>.
void addForAll(configuration::NodeID const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener)
{
OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener");
// ignore the names for now
m_aListeners.addListener(aNode.toIndex(),getCppuType(&xListener),xListener.get());
}
/// Add a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining <var>aNode</var>.
void addNamed(configuration::SubNodeID const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener)
{
OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener");
// ignore the names for now
m_aListeners.addSpecialListener(aNode,xListener.get());
}
/// Add a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining <var>aNode</var>.
void addForAll(configuration::NodeID const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener)
{
OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener");
// ignore the names for now
m_aListeners.addListener(aNode.toIndex(),getCppuType(&xListener),xListener.get());
}
/** Add a <type scope='com::sun::star::beans'>XPropertiesChangeListener</type>
observing all properties of <var>aNode</var>.
*/
void add(configuration::NodeID const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener)
{
OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener");
// ignore the names for now
m_aListeners.addListener(aNode.toIndex(),getCppuType(&xListener),xListener.get());
}
/** Add a <type scope='com::sun::star::beans'>XPropertiesChangeListener</type>
observing the properties of <var>aNode</var> (optimally only those given by <var>aNames</var>.
*/
void add(configuration::NodeID const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener, uno::Sequence< rtl::OUString> const& aNames)
{
OSL_PRECOND(xListener.is(), "ERROR: Unexpected NULL listener");
OSL_PRECOND(aNames.getLength() > 0, "ERROR: Unexpected empty sequence");
uno::Reference< css::beans::XPropertiesChangeListener > xForwarder( new PropertiesFilteredNotifier(xListener,aNames) );
// ignore the names for now
add(aNode,xForwarder);
}
// ---------------------------------------------------------------------------------------------------
/// Remove a <type scope='com::sun::star::lang'>XEventListener</type> observing <var>aNode</var>.
void remove(configuration::NodeID const& aNode, uno::Reference< css::lang::XEventListener > const& xListener)
{
// ignore the names for now
m_aListeners.removeListener(aNode.toIndex(),getCppuType(&xListener),xListener.get());
}
/// Remove a <type scope='com::sun::star::container'>XContainerListener</type> observing <var>aNode</var>.
void remove(configuration::NodeID const& aNode, uno::Reference< css::container::XContainerListener > const& xListener)
{
// ignore the names for now
m_aListeners.removeListener(aNode.toIndex(),getCppuType(&xListener),xListener.get());
}
/// Remove a <type scope='com::sun::star::util'>XChangesListener</type> observing <var>aNode</var> and its descendants.
void remove(configuration::NodeID const& aNode, uno::Reference< css::util::XChangesListener > const& xListener)
{
// ignore the names for now
m_aListeners.removeListener(aNode.toIndex(),getCppuType(&xListener),xListener.get());
}
/// Remove a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing <var>aNode</var>.
void removeNamed(configuration::SubNodeID const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener)
{
// ignore the names for now
m_aListeners.removeSpecialListener(aNode,xListener.get());
}
/// Remove a <type scope='com::sun::star::beans'>XPropertyChangeListener</type> observing <var>aNode</var>.
void removeForAll(configuration::NodeID const& aNode, uno::Reference< css::beans::XPropertyChangeListener > const& xListener)
{
// ignore the names for now
m_aListeners.removeListener(aNode.toIndex(),getCppuType(&xListener),xListener.get());
}
/// Remove a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining <var>aNode</var>.
void removeNamed(configuration::SubNodeID const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener)
{
// ignore the names for now
m_aListeners.removeSpecialListener(aNode,xListener.get());
}
/// Remove a <type scope='com::sun::star::beans'>XVetoableChangeListener</type> constraining <var>aNode</var>.
void removeForAll(configuration::NodeID const& aNode, uno::Reference< css::beans::XVetoableChangeListener > const& xListener)
{
// ignore the names for now
m_aListeners.removeListener(aNode.toIndex(),getCppuType(&xListener),xListener.get());
}
/** Remove a <type scope='com::sun::star::beans'>XPropertiesChangeListener</type>
observing any properties of <var>aNode</var>.
*/
void remove(configuration::NodeID const& aNode, uno::Reference< css::beans::XPropertiesChangeListener > const& xListener)
{
// ignore the names for now
m_aListeners.removeListener(aNode.toIndex(),getCppuType(&xListener),xListener.get());
}
// ---------------------------------------------------------------------------------------------------
};
// ---------------------------------------------------------------------------------------------------
}
}
#endif // CONFIGMGR_API_NOTIFIERIMPL_HXX_
-95
View File
@@ -1,95 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_OBJECTREGISTRY_HXX_
#define CONFIGMGR_API_OBJECTREGISTRY_HXX_
#include "noderef.hxx"
#include <osl/mutex.hxx>
#include <vos/refernce.hxx>
#include <hash_map>
#include "tracer.hxx"
namespace configmgr
{
namespace configapi
{
class NodeElement;
class ObjectRegistry : public vos::OReference
{
public:
static NodeElement* notFound() { return 0; }
struct KeyHash
{
size_t operator() (const configuration::NodeID& rKey) const {return rKey.hashCode();}
};
struct KeyEq
{
bool operator() (const configuration::NodeID& lhs,const configuration::NodeID& rhs) const {return lhs == rhs;}
};
typedef std::hash_map<configuration::NodeID,NodeElement*,KeyHash, KeyEq> ObjectMap;
public:
ObjectRegistry() {}
~ObjectRegistry();
NodeElement* findElement(configuration::NodeID const& aNode) const
{
ObjectMap::const_iterator aFound = m_aMap.find(aNode);
return (aFound != m_aMap.end()) ? aFound->second : notFound();
}
void registerElement(configuration::NodeID const& aNode, NodeElement* aElement)
{
OSL_ENSURE(m_aMap.find(aNode) == m_aMap.end(), "ERROR: Node is already registered");
m_aMap[aNode] = aElement;
}
void revokeElement(configuration::NodeID const& aNode, NodeElement* aElement)
{
ObjectMap::iterator aFound = m_aMap.find(aNode);
if (aFound != m_aMap.end())
{
OSL_ENSURE(aFound->second == aElement,"Found unexpected element in map");
if (aFound->second == aElement)
m_aMap.erase(aFound);
}
}
private:
ObjectMap m_aMap;
};
//-----------------------------------------------------------------------------
}
}
#endif // CONFIGMGR_API_FACTORY_HXX_
@@ -1,151 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "propertiesfilterednotifier.hxx"
#include <cppuhelper/queryinterface.hxx>
namespace configmgr
{
namespace uno = ::com::sun::star::uno;
namespace lang = ::com::sun::star::lang;
namespace beans = ::com::sun::star::beans;
//-----------------------------------------------------------------------------
// class PropertiesFilteredNotifier
//-----------------------------------------------------------------------------
PropertiesFilteredNotifier::PropertiesFilteredNotifier(
uno::Reference< beans::XPropertiesChangeListener >const& xTarget,
uno::Sequence< rtl::OUString > const& aFilterNames
)
: m_aRefCount()
, m_xTarget(xTarget)
, m_aFilterNames(aFilterNames)
{
OSL_ENSURE(xTarget.is(),"PropertiesFilteredNotifier: FORWARDING TO NULL LISTENER");
OSL_ENSURE(aFilterNames.getLength() > 0,"PropertiesFilteredNotifier: FILTER IS EMPTY (no target)");
}
//-----------------------------------------------------------------------------
PropertiesFilteredNotifier::~PropertiesFilteredNotifier()
{
}
//-----------------------------------------------------------------------------
void SAL_CALL PropertiesFilteredNotifier::acquire() throw()
{
m_aRefCount.acquire();
}
//-----------------------------------------------------------------------------
void SAL_CALL PropertiesFilteredNotifier::release( ) throw()
{
if (m_aRefCount.release() == 0)
delete this;
}
//-----------------------------------------------------------------------------
uno::Any SAL_CALL PropertiesFilteredNotifier::queryInterface( const uno::Type& aType )
throw(uno::RuntimeException)
{
return cppu::queryInterface(aType
, static_cast< beans::XPropertiesChangeListener *>(this)
, static_cast< lang::XEventListener *>(this)
, static_cast< uno::XInterface *>(this)
);
}
//-----------------------------------------------------------------------------
void SAL_CALL PropertiesFilteredNotifier::disposing( const lang::EventObject& Source )
throw(uno::RuntimeException)
{
if (m_xTarget.is())
m_xTarget->disposing(Source);
}
//-----------------------------------------------------------------------------
inline // private and only used twice
bool PropertiesFilteredNotifier::implAccept(const ::com::sun::star::beans::PropertyChangeEvent& evt) const
{
// todo: optimize by presorting and binary searching
sal_Int32 const nCount = m_aFilterNames.getLength();
for (sal_Int32 i = 0; i<nCount; ++i)
if (evt.PropertyName == m_aFilterNames[i])
return true;
return false;
}
//-----------------------------------------------------------------------------
// private and only used once
uno::Sequence< beans::PropertyChangeEvent > PropertiesFilteredNotifier::implFilter(const uno::Sequence< beans::PropertyChangeEvent >& evt) const
{
sal_Int32 const nSize = evt.getLength();
sal_Int32 nAccepted = 0;
while ( nAccepted < nSize && implAccept(evt[nAccepted]) )
++nAccepted;
if (nAccepted == nSize) // all accepted
return evt;
// create a modified copy
uno::Sequence< beans::PropertyChangeEvent > aResult(evt);
for (sal_Int32 nCur = nAccepted+1; nCur<nSize; ++nCur)
{
if (implAccept(evt[nCur]))
{
aResult[nAccepted++] = evt[nCur];
}
}
aResult.realloc(nAccepted);
OSL_ASSERT(aResult.getLength() == nAccepted);
return aResult;
}
//-----------------------------------------------------------------------------
void SAL_CALL PropertiesFilteredNotifier::propertiesChange( const uno::Sequence< beans::PropertyChangeEvent >& evt )
throw(uno::RuntimeException)
{
uno::Sequence< beans::PropertyChangeEvent > aFilteredEvt( implFilter(evt) );
if (aFilteredEvt.getLength() > 0)
{
if (m_xTarget.is())
m_xTarget->propertiesChange(aFilteredEvt);
}
}
//-----------------------------------------------------------------------------
}
@@ -1,76 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_PROPERTIESFILTEREDNOTIFIER_HXX_
#define CONFIGMGR_PROPERTIESFILTEREDNOTIFIER_HXX_
#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
#include <vos/refernce.hxx>
namespace configmgr
{
class PropertiesFilteredNotifier
: public ::com::sun::star::beans::XPropertiesChangeListener
{
public:
PropertiesFilteredNotifier(
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener > const& xTarget,
::com::sun::star::uno::Sequence< ::rtl::OUString > const& aFilterNames
);
virtual ~PropertiesFilteredNotifier();
public:
virtual void SAL_CALL acquire( ) throw();
virtual void SAL_CALL release( ) throw();
virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type& aType )
throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject& Source )
throw(::com::sun::star::uno::RuntimeException) ;
virtual void SAL_CALL
propertiesChange( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& evt )
throw(::com::sun::star::uno::RuntimeException);
private:
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >
implFilter(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& evt)
const;
bool implAccept(const ::com::sun::star::beans::PropertyChangeEvent& evt) const;
::vos::ORefCount m_aRefCount;
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener > m_xTarget;
::com::sun::star::uno::Sequence< ::rtl::OUString > m_aFilterNames;
};
}
#endif // CONFIGMGR_PROPERTIESFILTEREDNOTIFIER_HXX_
@@ -1,72 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "propertyinfohelper.hxx"
#include "configpath.hxx"
#include "attributes.hxx"
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HDL_
#include <com/sun/star/beans/PropertyAttribute.hdl>
#endif
namespace configmgr
{
namespace css = ::com::sun::star;
namespace uno = ::com::sun::star::uno;
namespace beans = ::com::sun::star::beans;
namespace configapi
{
//-----------------------------------------------------------------------------
beans::Property helperMakeProperty(rtl::OUString const& aName,
node::Attributes const aAttributes,
uno::Type const& aType,
bool bDefaultable )
throw(uno::RuntimeException)
{
namespace PropertyAttribute = com::sun::star::beans::PropertyAttribute;
sal_Int16 nPropAttributes = 0;
if (aAttributes.isReadonly()) nPropAttributes |= PropertyAttribute::READONLY;
if (aAttributes.isNullable()) nPropAttributes |= PropertyAttribute::MAYBEVOID;
/*if ( aAttributes.bNotified)*/ nPropAttributes |= PropertyAttribute::BOUND;
/*if ( aAttributes.bConstrained)nPropAttributes |= PropertyAttribute::CONSTRAINED;*/
if ( aAttributes.isRemovable()) nPropAttributes |= PropertyAttribute::REMOVABLE;
if ( bDefaultable) nPropAttributes |= PropertyAttribute::MAYBEDEFAULT;
return beans::Property(aName, -1, aType, nPropAttributes);
}
//-----------------------------------------------------------------------------
}
}
@@ -1,56 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_PROPERTYINFOIMPL_HXX_
#define CONFIGMGR_API_PROPERTYINFOIMPL_HXX_
#include <com/sun/star/beans/Property.hpp>
#include <com/sun/star/uno/RuntimeException.hpp>
namespace configmgr
{
namespace uno = ::com::sun::star::uno;
namespace beans = ::com::sun::star::beans;
/* implementations of the interfaces supported by a (parent) node
within the configuration tree.
(read-only operation)
*/
namespace node { struct Attributes; }
namespace configapi
{
// translation helper
beans::Property helperMakeProperty( rtl::OUString const& aName, node::Attributes const aAttributes, uno::Type const& aType, bool bDefaultable )
throw(uno::RuntimeException);
}
}
#endif // CONFIGMGR_API_PROPERTYINFOIMPL_HXX_
-275
View File
@@ -1,275 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "propertysetaccess.hxx"
#include "propsetaccessimpl.hxx"
#include "apinotifierimpl.hxx"
#include "apinodeaccess.hxx"
#include "apinodeupdate.hxx"
namespace configmgr
{
//////////////////////////////////////////////////////////////////////////////////
// class BasicPropertySet
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// getting Property Metadata
//////////////////////////////////////////////////////////////////////////////////
// XPropertySet & XMultiPropertySet
//////////////////////////////////////////////////////////////////////////////////
uno::Reference< beans::XPropertySetInfo > SAL_CALL BasicPropertySet::getPropertySetInfo( )
throw(uno::RuntimeException)
{
return configapi::implGetPropertySetInfo( getNode(), NULL != maybeGetUpdateAccess() );
}
// XHierarchicalPropertySet & XHierarchicalMultiPropertySet
//////////////////////////////////////////////////////////////////////////////////
uno::Reference< beans::XHierarchicalPropertySetInfo > SAL_CALL BasicPropertySet::getHierarchicalPropertySetInfo( )
throw(uno::RuntimeException)
{
return configapi::implGetHierarchicalPropertySetInfo( getNode() );
}
//////////////////////////////////////////////////////////////////////////////////
// setting values - may all throw (PropertyVeto)Exceptions on read-only property sets
//////////////////////////////////////////////////////////////////////////////////
/// get the access for updating, check that it is present
configapi::NodeGroupAccess& BasicPropertySet::getGroupNode()
{
configapi::NodeGroupAccess* pAccess = maybeGetUpdateAccess();
OSL_ENSURE(pAccess, "Write operation invoked on a read-only node access - failing with PropertyVetoException");
if (!pAccess)
{
throw beans::PropertyVetoException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: INTERNAL VETO - Write operation invoked on a read-only node access")),
static_cast< beans::XPropertySet * >(this)
);
}
return *pAccess;
}
// XPropertySet
//////////////////////////////////////////////////////////////////////////////////
void SAL_CALL BasicPropertySet::setPropertyValue( const rtl::OUString& aPropertyName, const uno::Any& aValue )
throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implSetPropertyValue( getGroupNode(), aPropertyName, aValue );
}
// XMultiPropertySet
//////////////////////////////////////////////////////////////////////////////////
void SAL_CALL BasicPropertySet::setPropertyValues( const uno::Sequence< rtl::OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values )
throw(beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implSetPropertyValues( getGroupNode(), PropertyNames, Values );
}
// XHierarchicalPropertySet
//////////////////////////////////////////////////////////////////////////////////
void SAL_CALL BasicPropertySet::setHierarchicalPropertyValue( const rtl::OUString& aPropertyName, const uno::Any& aValue )
throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implSetHierarchicalPropertyValue( getGroupNode(), aPropertyName, aValue );
}
// XMultiHierarchicalPropertySet
//////////////////////////////////////////////////////////////////////////////////
void SAL_CALL BasicPropertySet::setHierarchicalPropertyValues( const uno::Sequence< rtl::OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values )
throw(beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implSetHierarchicalPropertyValues( getGroupNode(), PropertyNames, Values );
}
//////////////////////////////////////////////////////////////////////////////////
// getting values
//////////////////////////////////////////////////////////////////////////////////
// XPropertySet
//////////////////////////////////////////////////////////////////////////////////
uno::Any SAL_CALL BasicPropertySet::getPropertyValue( const rtl::OUString& aPropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
return configapi::implGetPropertyValue( getNode(), aPropertyName );
}
// XMultiPropertySet
//////////////////////////////////////////////////////////////////////////////////
uno::Sequence< uno::Any > SAL_CALL BasicPropertySet::getPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames )
throw(uno::RuntimeException)
{
return configapi::implGetPropertyValues( getNode(), aPropertyNames );
}
// XHierarchicalPropertySet
//////////////////////////////////////////////////////////////////////////////////
uno::Any SAL_CALL BasicPropertySet::getHierarchicalPropertyValue( const rtl::OUString& aPropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
return configapi::implGetHierarchicalPropertyValue( getNode(), aPropertyName );
}
// XMultiHierarchicalPropertySet
//////////////////////////////////////////////////////////////////////////////////
uno::Sequence< uno::Any > SAL_CALL BasicPropertySet::getHierarchicalPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames )
throw(uno::RuntimeException)
{
return configapi::implGetHierarchicalPropertyValues( getNode(), aPropertyNames );
}
//////////////////////////////////////////////////////////////////////////////////
// adding/removing listeners
//////////////////////////////////////////////////////////////////////////////////
void SAL_CALL BasicPropertySet::addVetoableChangeListener( const rtl::OUString& aPropertyName, const uno::Reference< beans::XVetoableChangeListener >& xListener )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implAddListener( getNode(), xListener, aPropertyName );
}
void SAL_CALL BasicPropertySet::addPropertyChangeListener( const rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implAddListener( getNode(), xListener, aPropertyName );
}
void SAL_CALL BasicPropertySet::addPropertiesChangeListener( const uno::Sequence< rtl::OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implAddListener( getNode(), xListener, aPropertyNames );
}
//////////////////////////////////////////////////////////////////////////////////
void SAL_CALL BasicPropertySet::removeVetoableChangeListener( const rtl::OUString& aPropertyName, const uno::Reference< beans::XVetoableChangeListener >& xListener )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implRemoveListener( getNode(), xListener, aPropertyName );
}
//---------------------------------------------------------------------------------
void SAL_CALL BasicPropertySet::removePropertyChangeListener( const rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implRemoveListener( getNode(), xListener, aPropertyName );
}
//---------------------------------------------------------------------------------
void SAL_CALL BasicPropertySet::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implRemoveListener( getNode(), xListener );
}
//---------------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////
// SPECIAL: XMultiPropertySet::firePropertiesChangeEvent
//////////////////////////////////////////////////////////////////////////////////
void SAL_CALL BasicPropertySet::firePropertiesChangeEvent( const uno::Sequence< rtl::OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implFirePropertiesChangeEvent( getNode(),aPropertyNames , xListener );
}
//////////////////////////////////////////////////////////////////////////////////
// XPropertyState / XMultiPropertyStates
//////////////////////////////////////////////////////////////////////////////////
// getting property states
//////////////////////////////////////////////////////////////////////////////////
beans::PropertyState SAL_CALL BasicPropertySet::getPropertyState( const rtl::OUString& sPropertyName )
throw(beans::UnknownPropertyException, uno::RuntimeException)
{
return configapi::implGetPropertyState( getNode(), sPropertyName);
}
//---------------------------------------------------------------------------------
uno::Sequence< beans::PropertyState > SAL_CALL BasicPropertySet::getPropertyStates( const uno::Sequence< rtl::OUString >& aPropertyNames )
throw(beans::UnknownPropertyException, uno::RuntimeException)
{
return configapi::implGetPropertyStates( getNode(), aPropertyNames );
}
//---------------------------------------------------------------------------------
// setting to default state
//////////////////////////////////////////////////////////////////////////////////
void SAL_CALL BasicPropertySet::setPropertyToDefault( const rtl::OUString& sPropertyName )
throw(beans::UnknownPropertyException, uno::RuntimeException)
{
configapi::implSetPropertyToDefault( getGroupNode(), sPropertyName);
}
//---------------------------------------------------------------------------------
void SAL_CALL BasicPropertySet::setPropertiesToDefault( const uno::Sequence< rtl::OUString >& aPropertyNames )
throw (beans::UnknownPropertyException, uno::RuntimeException)
{
configapi::implSetPropertiesToDefault( getGroupNode(), aPropertyNames);
}
//---------------------------------------------------------------------------------
void SAL_CALL BasicPropertySet::setAllPropertiesToDefault( )
throw (uno::RuntimeException)
{
configapi::implSetAllPropertiesToDefault( getGroupNode() );
}
//---------------------------------------------------------------------------------
// getting defaults
//////////////////////////////////////////////////////////////////////////////////
uno::Any SAL_CALL BasicPropertySet::getPropertyDefault( const rtl::OUString& sPropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
return configapi::implGetPropertyDefault( getNode(), sPropertyName);
}
//---------------------------------------------------------------------------------
uno::Sequence< uno::Any > SAL_CALL BasicPropertySet::getPropertyDefaults( const uno::Sequence< rtl::OUString >& aPropertyNames )
throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
return configapi::implGetPropertyDefaults( getNode(), aPropertyNames);
}
//---------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
} // namespace configmgr
-215
View File
@@ -1,215 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_PROPERTYSET_HXX_
#define CONFIGMGR_API_PROPERTYSET_HXX_
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XHierarchicalPropertySet.hpp>
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/beans/XMultiHierarchicalPropertySet.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
#include <com/sun/star/beans/XMultiPropertyStates.hpp>
#include <cppuhelper/implbase6.hxx>
namespace configmgr
{
/////////////////////////////////////////////////////////////////////////////////////////////
namespace css = ::com::sun::star;
namespace uno = css::uno;
namespace lang = css::lang;
namespace beans = css::beans;
namespace configapi
{
class NodeGroupAccess;
class NodeGroupInfoAccess;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/** implements the interfaces supported by a group node, viewed as a property set
within the configuration tree.
<p> Is an interface adapter around <type scope='configmgr::configapi'>NodeGroup(Info)Access</type>.</p>
*/
class BasicPropertySet
: public ::cppu::ImplHelper6
< beans::XPropertySet
, beans::XMultiPropertySet
, beans::XHierarchicalPropertySet
, beans::XMultiHierarchicalPropertySet
, beans::XPropertyState
, beans::XMultiPropertyStates
>
{
protected:
// Constructors & Destructors
virtual ~BasicPropertySet() {}
public:
// getting Property Metadata
// XPropertySet & XMultiPropertySet
virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo( )
throw(uno::RuntimeException);
// XHierarchicalPropertySet & XHierarchicalMultiPropertySet
virtual uno::Reference< beans::XHierarchicalPropertySetInfo > SAL_CALL
getHierarchicalPropertySetInfo( )
throw(uno::RuntimeException);
// setting values - may all throw (PropertyVeto)Exceptions on read-only property sets
// XPropertySet
virtual void SAL_CALL
setPropertyValue( const rtl::OUString& aPropertyName, const uno::Any& aValue )
throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, uno::RuntimeException);
// XMultiPropertySet
virtual void SAL_CALL
setPropertyValues( const uno::Sequence< rtl::OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values )
throw(beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, uno::RuntimeException);
// XHierarchicalPropertySet
virtual void SAL_CALL
setHierarchicalPropertyValue( const rtl::OUString& aPropertyName, const uno::Any& aValue )
throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, uno::RuntimeException);
// XMultiHierarchicalPropertySet
virtual void SAL_CALL
setHierarchicalPropertyValues( const uno::Sequence< rtl::OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values )
throw(beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, uno::RuntimeException);
// getting values
// XPropertySet
virtual uno::Any SAL_CALL
getPropertyValue( const rtl::OUString& PropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
// XMultiPropertySet
virtual uno::Sequence< uno::Any > SAL_CALL
getPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames )
throw(uno::RuntimeException);
// XHierarchicalPropertySet
virtual uno::Any SAL_CALL
getHierarchicalPropertyValue( const rtl::OUString& PropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
// XMultiHierarchicalPropertySet
virtual uno::Sequence< uno::Any > SAL_CALL
getHierarchicalPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames )
throw(uno::RuntimeException);
// adding listeners
// XPropertySet
virtual void SAL_CALL
addPropertyChangeListener( const rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
// XMultiPropertySet
virtual void SAL_CALL
addPropertiesChangeListener( const uno::Sequence< rtl::OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener )
throw(uno::RuntimeException);
// removing listeners
// XPropertySet
virtual void SAL_CALL
removePropertyChangeListener( const rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
// XMultiPropertySet
virtual void SAL_CALL
removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& Listener )
throw(uno::RuntimeException);
// SPECIAL: support for VetoableChangeListeners
// XPropertySet
virtual void SAL_CALL
addVetoableChangeListener( const rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
virtual void SAL_CALL
removeVetoableChangeListener( const rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
// SPECIAL: firePropertiesChangeEvent
// XMultiPropertySet
virtual void SAL_CALL
firePropertiesChangeEvent( const uno::Sequence< rtl::OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener )
throw(uno::RuntimeException);
// XPropertyState
virtual beans::PropertyState SAL_CALL
getPropertyState( const rtl::OUString& PropertyName )
throw(beans::UnknownPropertyException, uno::RuntimeException);
// see below:
// virtual uno::Sequence< beans::PropertyState > SAL_CALL
// getPropertyStates( const uno::Sequence< rtl::OUString >& aPropertyName )
// throw(beans::UnknownPropertyException, uno::RuntimeException);
virtual void SAL_CALL
setPropertyToDefault( const rtl::OUString& PropertyName )
throw(beans::UnknownPropertyException, uno::RuntimeException);
virtual uno::Any SAL_CALL
getPropertyDefault( const rtl::OUString& aPropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
// XMultiPropertyStates
virtual uno::Sequence< beans::PropertyState > SAL_CALL
getPropertyStates( const uno::Sequence< rtl::OUString >& aPropertyName )
throw (beans::UnknownPropertyException, uno::RuntimeException);
virtual void SAL_CALL
setAllPropertiesToDefault( )
throw (uno::RuntimeException);
virtual void SAL_CALL
setPropertiesToDefault( const uno::Sequence< rtl::OUString >& aPropertyNames )
throw (beans::UnknownPropertyException, uno::RuntimeException);
virtual uno::Sequence< uno::Any > SAL_CALL
getPropertyDefaults( const uno::Sequence< rtl::OUString >& aPropertyNames )
throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
protected:
virtual configapi::NodeGroupInfoAccess& getNode() = 0;
configapi::NodeGroupAccess& getGroupNode();
virtual configapi::NodeGroupAccess* maybeGetUpdateAccess() = 0;
};
//--------------------------------------------------------------------------
}
#endif // CONFIGMGR_API_PROPERTYSET_HXX_
File diff suppressed because it is too large Load Diff
-138
View File
@@ -1,138 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_PROPERTYSETIMPL_HXX_
#define CONFIGMGR_API_PROPERTYSETIMPL_HXX_
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XHierarchicalPropertySet.hpp>
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/beans/XMultiHierarchicalPropertySet.hpp>
#ifndef CONFIGMGR_NO_PROPERTYSTATE
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_
#include <com/sun/star/beans/XPropertyState.hpp>
#endif
#endif
namespace configmgr
{
namespace css = ::com::sun::star;
namespace uno = ::com::sun::star::uno;
namespace lang = ::com::sun::star::lang;
namespace beans = ::com::sun::star::beans;
/* implementations of the interfaces supported by a (parent) node
within the configuration tree.
(read-only operation)
*/
namespace configapi
{
class NodeAccess;
class NodeGroupInfoAccess;
class NodeGroupAccess;
// getting Property Metadata
// XPropertySet & XMultiPropertySet
uno::Reference< beans::XPropertySetInfo > implGetPropertySetInfo( NodeGroupInfoAccess& rNode, sal_Bool _bWriteable )
throw(uno::RuntimeException);
// XHierarchicalPropertySet & XHierarchicalMultiPropertySet
uno::Reference< beans::XHierarchicalPropertySetInfo > implGetHierarchicalPropertySetInfo( NodeGroupInfoAccess& rNode )
throw(uno::RuntimeException);
// setting values - may all throw (PropertyVeto)Exceptions on read-only property sets
// XPropertySet
void implSetPropertyValue( NodeGroupAccess& rNode, const rtl::OUString& aPropertyName, const uno::Any& aValue )
throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, uno::RuntimeException);
// XMultiPropertySet
void implSetPropertyValues( NodeGroupAccess& rNode, const uno::Sequence< rtl::OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values )
throw(beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, uno::RuntimeException);
// XHierarchicalPropertySet
void implSetHierarchicalPropertyValue( NodeGroupAccess& rNode, const rtl::OUString& aPropertyName, const uno::Any& aValue )
throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, uno::RuntimeException);
// XMultiHierarchicalPropertySet
void implSetHierarchicalPropertyValues( NodeGroupAccess& rNode, const uno::Sequence< rtl::OUString >& PropertyNames, const uno::Sequence< uno::Any >& Values )
throw(beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, uno::RuntimeException);
// getting values
// XPropertySet
uno::Any implGetPropertyValue( NodeGroupInfoAccess& rNode,const rtl::OUString& PropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
// XMultiPropertySet
uno::Sequence< uno::Any > implGetPropertyValues( NodeGroupInfoAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames )
throw(uno::RuntimeException);
// XHierarchicalPropertySet
uno::Any implGetHierarchicalPropertyValue( NodeGroupInfoAccess& rNode, const rtl::OUString& PropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
// XMultiHierarchicalPropertySet
uno::Sequence< uno::Any > implGetHierarchicalPropertyValues( NodeGroupInfoAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames )
throw(uno::RuntimeException);
// SPECIAL: firePropertiesChangeEvent
// XMultiPropertySet
void implFirePropertiesChangeEvent( NodeGroupInfoAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener )
throw(uno::RuntimeException);
// XPropertyState
beans::PropertyState implGetPropertyState( NodeAccess& rNode, const rtl::OUString& sPropertyName )
throw(beans::UnknownPropertyException, uno::RuntimeException);
void implSetPropertyToDefault( NodeGroupAccess& rNode, const rtl::OUString& sPropertyName )
throw(beans::UnknownPropertyException, uno::RuntimeException);
uno::Any implGetPropertyDefault( NodeGroupInfoAccess& rNode, const rtl::OUString& sPropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
// XMultiPropertyState
uno::Sequence< beans::PropertyState > implGetPropertyStates( NodeAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyName )
throw(beans::UnknownPropertyException, uno::RuntimeException);
void implSetPropertiesToDefault( NodeGroupAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames )
throw(beans::UnknownPropertyException, uno::RuntimeException);
void implSetAllPropertiesToDefault( NodeGroupAccess& rNode )
throw(uno::RuntimeException);
uno::Sequence< uno::Any > implGetPropertyDefaults( NodeGroupInfoAccess& rNode, const uno::Sequence< rtl::OUString >& aPropertyNames )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
}
}
#endif // CONFIGMGR_API_PROPERTYSETIMPL_HXX_
-711
View File
@@ -1,711 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "apiserviceinfo.hxx"
#include "confapifactory.hxx"
#include "configpath.hxx"
#include "datalock.hxx"
#include "provider.hxx"
#include "providerimpl.hxx"
#include "tracer.hxx"
#include "bootstrap.hxx"
#include "wrapexception.hxx"
#include <osl/mutex.hxx>
#include <rtl/ustrbuf.hxx>
#ifndef __SGI_STL_ALGORITHM
#include <algorithm>
#endif
#include <comphelper/sequence.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <cppuhelper/typeprovider.hxx>
#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
namespace configmgr
{
namespace css = ::com::sun::star;
namespace uno = css::uno;
namespace lang = css::lang;
namespace beans = css::beans;
namespace
{
//------------------------------------------------------------------------
sal_Char const * const aConfigProviderServices[] =
{
"com.sun.star.configuration.ConfigurationProvider",
0
};
sal_Char const * const aAdminProviderServices[] =
{
"com.sun.star.configuration.AdministrationProvider",
0
};
//------------------------------------------------------------------------
ServiceImplementationInfo const aConfigProviderInfo =
{
"com.sun.star.comp.configuration.ConfigurationProvider",
aConfigProviderServices,
0
};
ServiceImplementationInfo const aAdminProviderInfo =
{
"com.sun.star.comp.configuration.AdministrationProvider",
aAdminProviderServices,
aConfigProviderServices
};
//------------------------------------------------------------------------
sal_Char const * const
aDefaultProviderServiceAndImplName = A_DefaultProviderServiceAndImplName;
//------------------------------------------------------------------------
sal_Char const * const aDefaultProviderServices[] =
{
aDefaultProviderServiceAndImplName,
0
};
//------------------------------------------------------------------------
ServiceRegistrationInfo const aDefaultProviderInfo =
{
aDefaultProviderServiceAndImplName,
aDefaultProviderServices
};
SingletonRegistrationInfo const aDefaultProviderSingletonInfo =
{
A_DefaultProviderSingletonName,
aDefaultProviderServiceAndImplName,
aDefaultProviderServiceAndImplName,
0
};
//------------------------------------------------------------------------
typedef uno::Reference< uno::XInterface > (OProviderImpl::*CreatorFunc)(const uno::Sequence< uno::Any >& aArguments);
struct ServiceCreationInfo
{
ServiceRegistrationInfo const* info;
CreatorFunc create;
};
static sal_Int32 getCreateServiceDataCount()
{
return 2;
}
static const ServiceCreationInfo* getCreateServiceData()
{
static ServiceCreationInfo const createServiceData[] =
{
{ &configapi::aCreateReadAccessSI, &OProviderImpl::createReadAccess },
{ &configapi::aCreateUpdateAccessSI, &OProviderImpl::createUpdateAccess },
};
OSL_ENSURE(sizeof(createServiceData)/sizeof(createServiceData[0]) == getCreateServiceDataCount(),
"getCreateServiceData : inconsistent data !");
return createServiceData;
}
//------------------------------------------------------------------------
}
static ServiceCreationInfo const* findCreationInfo( const rtl::OUString& aServiceSpecifier )
{
for (int i= 0; i<getCreateServiceDataCount(); ++i)
{
ServiceCreationInfo const& rCreationInfo = getCreateServiceData()[i];
ServiceRegistrationInfo const* pInfo = rCreationInfo.info;
if (!pInfo)
continue;
if (sal_Char const * pImplName = pInfo->implementationName)
{
if (0 == aServiceSpecifier.compareToAscii(pImplName))
return &rCreationInfo;
}
if (sal_Char const * const* pNames = pInfo->registeredServiceNames)
{
while(*pNames)
{
if (0 == aServiceSpecifier.compareToAscii(*pNames))
return &rCreationInfo;
++pNames;
}
}
}
// not found
return 0;
}
//#define ID_PREFETCH 1
static const int ID_PREFETCH=1;
static const int ID_ENABLEASYNC=2;
static inline
rtl::OUString getPrefetchPropName() { return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrefetchNodes") ); }
static inline
rtl::OUString getEnableAsyncPropName() { return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("EnableAsync") ); }
//=============================================================================
//= OProvider
//=============================================================================
// service info export
const ServiceRegistrationInfo* getConfigurationProviderServiceInfo()
{
return getRegistrationInfo(&aConfigProviderInfo);
}
const ServiceRegistrationInfo* getAdminProviderServiceInfo()
{
return getRegistrationInfo(&aAdminProviderInfo);
}
const ServiceRegistrationInfo* getDefaultProviderServiceInfo()
{
return &aDefaultProviderInfo;
}
const SingletonRegistrationInfo* getDefaultProviderSingletonInfo()
{
return &aDefaultProviderSingletonInfo;
}
//-----------------------------------------------------------------------------
uno::Reference<uno::XInterface> SAL_CALL
getDefaultConfigProviderSingleton( uno::Reference< uno::XComponentContext > const& xContext )
{
OSL_ENSURE( xContext.is(), "ERROR: NULL context has no singletons" );
UnoContextTunnel aTunnel;
aTunnel.passthru( xContext );
uno::Reference<uno::XInterface> xResult;
if (xContext.is())
try
{
rtl::OUString aSingletonName = SINGLETON(A_DefaultProviderSingletonName);
uno::Any aResult = xContext->getValueByName(aSingletonName);
aResult >>= xResult;
}
catch (uno::Exception & )
{
// to do: really use the tunneled failure when that is set properly
if ( aTunnel.recoverFailure(true).hasValue() )
{
// have a failure, but can't recover it
// -> try to regenerate
instantiateDefaultProvider(xContext);
OSL_ENSURE(false, "Cannot recreate configuration backend instantiation failure - using generic error");
}
// cannot recover any failure
throw;
}
return xResult;
}
// ------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#define TUNNEL_ALL_EXCEPTIONS() \
WRAP_CONFIGBACKEND_CREATION_EXCEPTIONS1( UnoContextTunnel::tunnelFailure, true)
// ----------------------------------------------------------------------------
// ------------------------------------------------------------------------
uno::Reference< uno::XInterface > SAL_CALL instantiateDefaultProvider( uno::Reference< uno::XComponentContext > const & xTargetContext )
{
uno::Reference< uno::XComponentContext > xContext = UnoContextTunnel::recoverContext(xTargetContext);
ServiceImplementationInfo const * pProviderInfo =
ContextReader::testAdminService(xContext,true) ? &aAdminProviderInfo : &aConfigProviderInfo;
OProvider* pNewProvider = new OProvider(xContext,pProviderInfo);
uno::Reference< lang::XMultiServiceFactory > aRet( pNewProvider );
try
{
pNewProvider->connect();
}
TUNNEL_ALL_EXCEPTIONS()
return uno::Reference< uno::XInterface >( aRet, uno::UNO_QUERY );
}
// -----------------------------------------------------------------------------
class OProviderDisposingListener : public cppu::WeakImplHelper1<lang::XEventListener>
{
OProvider* m_pProvider;
public:
OProviderDisposingListener(OProvider* pProvider)
:m_pProvider(pProvider){}
virtual void SAL_CALL disposing(com::sun::star::lang::EventObject const& rEvt) throw()
{
CFG_TRACE_INFO("Service Manager or context disposed, disposing the provider");
if (OProvider* pProvider = m_pProvider)
{
m_pProvider = NULL;
pProvider->disposing(rEvt);
}
}
};
//=============================================================================
//= OProvider
//=============================================================================
//-----------------------------------------------------------------------------
OProvider::OProvider(uno::Reference< uno::XComponentContext > const & xContext, ServiceImplementationInfo const* pInfo)
:ServiceComponentImpl(pInfo)
,OPropertyContainer(ServiceComponentImpl::rBHelper)
,m_xContext(xContext)
,m_pImpl(NULL)
,m_bEnableAsync(false)
{
OSL_ENSURE(m_xContext.is(), "Creating a provider without a context");
attachToContext();
registerProperty(getPrefetchPropName(), ID_PREFETCH, 0,&m_aPrefetchNodes, ::getCppuType(&m_aPrefetchNodes));
registerProperty(getEnableAsyncPropName(), ID_ENABLEASYNC, 0, &m_bEnableAsync, ::getBooleanCppuType());
}
//-----------------------------------------------------------------------------
OProvider::~OProvider()
{
delete m_pImpl;
discardContext(releaseContext());
}
//-----------------------------------------------------------------------------
void OProvider::connect() throw (uno::Exception)
{
OSL_ENSURE( m_pImpl == NULL, "Error: Configuration Provider already is connected");
std::auto_ptr<OProviderImpl> pNewImpl( new OProviderImpl(this, m_xContext) );
implConnect(*pNewImpl,ContextReader(m_xContext));
m_pImpl = pNewImpl.release();
if (m_pImpl)
{
sal_Bool isEnabled = m_pImpl->getDefaultOptions().isAsyncEnabled();
this->setPropertyValue( getEnableAsyncPropName(), uno::makeAny(isEnabled) );
}
}
//-----------------------------------------------------------------------------
void OProvider::attachToContext()
{
UnoApiLock aLock;
::osl::MutexGuard aGuard(ServiceComponentImpl::rBHelper.rMutex);
OSL_ASSERT(!m_xDisposeListener.is());
if (m_xContext.is())
{
uno::Reference< lang::XComponent > xContextComp(m_xContext, uno::UNO_QUERY);
uno::Reference< lang::XComponent > xServiceMgrComp(m_xContext->getServiceManager(), uno::UNO_QUERY);
m_xDisposeListener = new OProviderDisposingListener(this);
if (xContextComp.is()) xContextComp ->addEventListener(m_xDisposeListener);
if (xServiceMgrComp.is()) xServiceMgrComp->addEventListener(m_xDisposeListener);
OSL_ENSURE(xServiceMgrComp.is() || xContextComp.is(),
"Provider cannot detect shutdown -> no XComponent found");
}
}
//-----------------------------------------------------------------------------
uno::Reference< lang::XComponent > OProvider::releaseContext()
{
UnoApiLock aLock;
::osl::MutexGuard aGuard(ServiceComponentImpl::rBHelper.rMutex);
uno::Reference< lang::XComponent > xContextComp(m_xContext, uno::UNO_QUERY);
if (m_xDisposeListener.is() && m_xContext.is())
{
uno::Reference< lang::XComponent > xServiceMgrComp(m_xContext->getServiceManager(), uno::UNO_QUERY);
if (xContextComp.is())
{
try { xContextComp ->removeEventListener(m_xDisposeListener); }
catch (uno::Exception & ) {}
}
if (xServiceMgrComp.is())
{
try { xServiceMgrComp->removeEventListener(m_xDisposeListener); }
catch (uno::Exception & ) {}
}
}
m_xDisposeListener = NULL;
m_xContext = NULL;
return xContextComp;
}
//-----------------------------------------------------------------------------
void OProvider::discardContext(uno::Reference< lang::XComponent > const & xContext)
{
UnoApiLock aLock;
if (xContext.is())
{
uno::Reference< uno::XComponentContext > xCC(xContext,uno::UNO_QUERY);
OSL_ASSERT(xCC.is());
if (BootstrapContext::isWrapper(xCC))
{
try { xContext->dispose(); }
catch (uno::Exception & ) {}
}
}
}
//-----------------------------------------------------------------------------
// XTypeProvider
//-----------------------------------------------------------------------------
uno::Sequence< uno::Type > SAL_CALL OProvider::getTypes( ) throw(uno::RuntimeException)
{
cppu::OTypeCollection aCollection(::getCppuType( (const uno::Reference< beans::XPropertySet > *)0 ),
::getCppuType( (const uno::Reference< beans::XFastPropertySet > *)0 ),
::getCppuType( (const uno::Reference< beans::XMultiPropertySet > *)0 ),
::comphelper::concatSequences(ServiceComponentImpl::getTypes(), cppu::ImplHelper4< lang::XMultiServiceFactory, lang::XLocalizable, util::XRefreshable, util::XFlushable >::getTypes()));
return aCollection.getTypes();
}
// XPropertySet
//-----------------------------------------------------------------------------
uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OProvider::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
{
return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
}
//-----------------------------------------------------------------------------
uno::Reference< uno::XInterface > SAL_CALL OProvider::createInstance( const rtl::OUString& aServiceSpecifier )
throw(uno::Exception, uno::RuntimeException)
{
UnoApiLock aLock;
// same as creating with empty sequence of arguments
return this->createInstanceWithArguments( aServiceSpecifier, uno::Sequence< uno::Any >() );
}
//-----------------------------------------------------------------------------
uno::Reference< uno::XInterface > SAL_CALL
OProvider::createInstanceWithArguments( const rtl::OUString& aServiceSpecifier, const uno::Sequence< uno::Any >& aArguments )
throw(uno::Exception, uno::RuntimeException)
{
UnoApiLock aLock;
OSL_ENSURE(m_pImpl, "OProvider: no implementation available");
if (ServiceCreationInfo const* pInfo = findCreationInfo(aServiceSpecifier))
{
// it's a known service name - try to create without args
if (CreatorFunc create = pInfo->create)
{
return (m_pImpl->*create)(aArguments);
}
}
rtl::OUStringBuffer sMsg;
sMsg.appendAscii("ConfigurationProvider: Cannot create view - ");
sMsg.append( aServiceSpecifier ) .appendAscii(" is not a valid configuration access service. ");
throw lang::ServiceNotRegisteredException(sMsg.makeStringAndClear(),*this);
}
//-----------------------------------------------------------------------------
uno::Sequence< rtl::OUString > SAL_CALL OProvider::getAvailableServiceNames( )
throw(uno::RuntimeException)
{
UnoApiLock aLock;
sal_Int32 nCount = 0;
{
for (int i= 0; i< getCreateServiceDataCount(); ++i)
nCount += countServices(getCreateServiceData()[i].info);
}
uno::Sequence< rtl::OUString > aNames(nCount);
if (nCount > 0)
{
sal_Int32 n = 0;
for (int i= 0; i<getCreateServiceDataCount(); ++i)
{
ServiceRegistrationInfo const* pInfo = getCreateServiceData()[i].info;
sal_Char const * const* pNames = pInfo ? pInfo->registeredServiceNames : 0;
if (pNames)
{
while(*pNames)
{
aNames[n] = rtl::OUString::createFromAscii(*pNames);
++n;
++pNames;
}
}
}
}
return aNames;
}
// XLocalizable
//-----------------------------------------------------------------------------
void SAL_CALL OProvider::setLocale( const lang::Locale& eLocale )
throw (uno::RuntimeException)
{
UnoApiLock aLock;
OSL_ENSURE(m_pImpl, "OProvider: no implementation available");
m_pImpl->setDefaultLocale( eLocale );
}
//-----------------------------------------------------------------------------
lang::Locale SAL_CALL OProvider::getLocale()
throw (uno::RuntimeException)
{
UnoApiLock aLock;
OSL_ENSURE(m_pImpl, "OProvider: no implementation available");
return m_pImpl->getDefaultOptions().getUnoLocale();
}
//XRefreshable
//-----------------------------------------------------------------------------
void SAL_CALL OProvider::refresh()
throw (uno::RuntimeException)
{
UnoApiLock aLock;
OSL_ENSURE(m_pImpl, "OProvider: no implementation available");
try
{
m_pImpl->refreshAll();
}
catch (uno::RuntimeException& ) { throw; }
catch (uno::Exception& e)
{
// FIXME: use getCaughtException()
throw lang::WrappedTargetRuntimeException(e.Message, *this, uno::makeAny(e));
}
//Broadcast the changes
uno::Reference< css::util::XRefreshListener > const * const pRefresh = 0;
cppu::OInterfaceContainerHelper * aInterfaceContainer=
getBroadcastHelper().getContainer (::getCppuType(pRefresh));
if(aInterfaceContainer)
{
lang::EventObject aEventObject(*this);
cppu::OInterfaceIteratorHelper aIterator(*aInterfaceContainer);
while(aIterator.hasMoreElements())
{
uno::Reference< uno::XInterface > xIface = aIterator.next();
uno::Reference< util::XRefreshListener > xRefresh (xIface, uno::UNO_QUERY);
if (xRefresh.is())
{
xRefresh->refreshed(aEventObject);
}
}
}
}
//-----------------------------------------------------------------------------
void SAL_CALL OProvider::addRefreshListener(
const uno::Reference< util::XRefreshListener >& aListener )
throw (uno::RuntimeException)
{
UnoApiLock aLock;
getBroadcastHelper().addListener(::getCppuType(&aListener), aListener);
}
//-----------------------------------------------------------------------------
void SAL_CALL OProvider::removeRefreshListener(
const uno::Reference< util::XRefreshListener >& aListener )
throw (uno::RuntimeException)
{
UnoApiLock aLock;
getBroadcastHelper().removeListener(::getCppuType(&aListener), aListener);
}
//XFlushable
//-----------------------------------------------------------------------------
void SAL_CALL OProvider::flush( )
throw (uno::RuntimeException)
{
UnoApiLock aLock;
OSL_ENSURE(m_pImpl, "OProvider: no implementation available");
m_pImpl->flushAll();
//Broadcast the changes
uno::Reference< css::util::XFlushListener > const * const pFlush = 0;
cppu::OInterfaceContainerHelper * aInterfaceContainer=
getBroadcastHelper().getContainer(::getCppuType(pFlush));
if(aInterfaceContainer)
{
lang::EventObject aEventObject(*this);
cppu::OInterfaceIteratorHelper aIterator(*aInterfaceContainer);
while(aIterator.hasMoreElements())
{
uno::Reference< uno::XInterface > xIface = aIterator.next();
uno::Reference< util::XFlushListener > xFlush (xIface, uno::UNO_QUERY);
if (xFlush.is())
{
xFlush->flushed(aEventObject);
}
}
}
}
//-----------------------------------------------------------------------------
void SAL_CALL OProvider::addFlushListener(
const uno::Reference< util::XFlushListener >& aListener )
throw (uno::RuntimeException)
{
UnoApiLock aLock;
getBroadcastHelper().addListener(::getCppuType(&aListener), aListener);
}
//-----------------------------------------------------------------------------
void SAL_CALL OProvider::removeFlushListener(
const uno::Reference< util::XFlushListener >& aListener )
throw (uno::RuntimeException)
{
UnoApiLock aLock;
getBroadcastHelper().removeListener(::getCppuType(&aListener), aListener);
}
// XInterface
//-----------------------------------------------------------------------------
uno::Any SAL_CALL OProvider::queryInterface(uno::Type const& rType) throw(uno::RuntimeException)
{
UnoApiLock aLock;
uno::Any aRet( ServiceComponentImpl::queryInterface(rType) );
if ( !aRet.hasValue() )
aRet = cppu::ImplHelper4< lang::XMultiServiceFactory, lang::XLocalizable, util::XRefreshable, util::XFlushable >::queryInterface(rType);
if ( !aRet.hasValue() )
aRet = queryPropertyInterface(rType);
return aRet;
}
//-----------------------------------------------------------------------------
void OProvider::implConnect(OProviderImpl& _rFreshProviderImpl, const ContextReader& _rSettings) throw(uno::Exception)
{
UnoApiLock aLock;
if (!_rFreshProviderImpl.initSession(_rSettings))
throw uno::Exception(::rtl::OUString::createFromAscii("Could not connect to the configuration. Please check your settings."), static_cast< ::cppu::OWeakObject* >(this) );
}
//-----------------------------------------------------------------------------
void SAL_CALL OProvider::disposing(com::sun::star::lang::EventObject const& /*rEvt*/) throw()
{
UnoApiLock aLock;
releaseContext();
this->dispose();
}
//-----------------------------------------------------------------------------
void SAL_CALL OProvider::disposing()
{
UnoApiLock aLock;
if (m_pImpl)
m_pImpl->dispose();
uno::Reference< lang::XComponent > xComp = releaseContext();
ServiceComponentImpl::disposing();
OPropertyContainer::disposing();
discardContext( xComp );
}
// OPropertyArrayUsageHelper
// -------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* OProvider::createArrayHelper( ) const
{
UnoApiLock aLock;
uno::Sequence< beans::Property > aProps;
describeProperties(aProps);
return new ::cppu::OPropertyArrayHelper(aProps);
}
// -------------------------------------------------------------------------
::cppu::IPropertyArrayHelper & OProvider::getInfoHelper()
{
UnoApiLock aLock;
return *getArrayHelper();
}
void SAL_CALL OProvider::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue)
throw (::com::sun::star::uno::Exception)
{
UnoApiLock aLock;
OPropertyContainer::setFastPropertyValue_NoBroadcast( nHandle, rValue );
switch(nHandle)
{
case ID_PREFETCH:
{
uno::Sequence< rtl::OUString > aNodeList;
rValue >>= aNodeList;
RequestOptions const aOptions = m_pImpl->getDefaultOptions();
for (sal_Int32 i = 0; i < aNodeList.getLength(); i++)
{
configuration::AbsolutePath aModulePath = configuration::AbsolutePath::makeModulePath(aNodeList[i]);
m_pImpl->fetchSubtree(aModulePath , aOptions);
}
}break;
case ID_ENABLEASYNC:
{
//Forward to TreeManager
sal_Bool bAsync;
if (rValue >>= bAsync)
{
m_pImpl->enableAsync(bAsync);
if (!bAsync)
this->flush();
}
else
OSL_ENSURE(false, "Unexpected type of new property value");
}
break;
default:
{
OSL_ENSURE(false, "OProvider::setFastPropertyValue_NoBroadcast -unknown property");
}
}
}
} // namespace configmgr
-198
View File
@@ -1,198 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_PROVIDER_HXX_
#define CONFIGMGR_API_PROVIDER_HXX_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XLocalizable.hpp>
#include <com/sun/star/util/XRefreshable.hpp>
#include <com/sun/star/util/XFlushable.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HDL_
#include <com/sun/star/lang/IllegalArgumentException.hdl>
#endif
#include "confsvccomponent.hxx"
#include <rtl/ustring.hxx>
#include <vos/ref.hxx>
#include <cppuhelper/implbase4.hxx>
#include <comphelper/proparrhlp.hxx>
#include <comphelper/propertycontainer.hxx>
namespace configmgr
{
namespace css = ::com::sun::star;
namespace uno = css::uno;
namespace lang = css::lang;
namespace beans = css::beans;
namespace util = css::util;
class Module;
class ContextReader;
class OProviderImpl;
//==========================================================================
//= OProvider
//==========================================================================
/** Base class to receive access to the configuration data. A provider for configuration is
a factory for service which allow a readonly or update access to the configuration trees.
*/
class OProvider:
private ServiceComponentImpl, private comphelper::OPropertyContainer,
public comphelper::OPropertyArrayUsageHelper< OProvider >
// don't want to allow our derivees to access the mutex of ServiceComponentImpl
// (this helps to prevent deadlocks: The mutex of the base class is used by the OComponentHelper to
// protect addEvenetListener calls. Unfortunately these calls are made from within API object we create,
// too, which can lead do deadlocks ....)
, public cppu::ImplHelper4< lang::XMultiServiceFactory, lang::XLocalizable, util::XRefreshable, util::XFlushable >
{
private:
friend class OProviderDisposingListener;
uno::Reference< uno::XComponentContext > m_xContext;
uno::Reference< lang::XEventListener > m_xDisposeListener;
OProviderImpl * m_pImpl;
uno::Sequence< ::rtl::OUString > m_aPrefetchNodes;
sal_Bool m_bEnableAsync;
public:
// make ServiceComponentImpl allocation functions public
static void * SAL_CALL operator new( size_t nSize ) throw()
{ return ServiceComponentImpl::operator new( nSize ); }
static void SAL_CALL operator delete( void * pMem ) throw()
{ ServiceComponentImpl::operator delete( pMem ); }
OProvider(uno::Reference< uno::XComponentContext > const & xContext, ServiceImplementationInfo const* pInfo);
virtual ~OProvider();
void connect() throw (uno::Exception);
/// XTypeOProvider
virtual uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw(uno::RuntimeException);
/// XInterface
virtual void SAL_CALL acquire() throw() { ServiceComponentImpl::acquire(); }
virtual void SAL_CALL release() throw() { ServiceComponentImpl::release(); }
virtual uno::Any SAL_CALL queryInterface(uno::Type const& rType) throw (uno::RuntimeException);
// XPropertySet
virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(uno::RuntimeException);
/// XMultiServiceFactory
virtual uno::Reference< uno::XInterface > SAL_CALL
createInstance( const rtl::OUString& aServiceSpecifier )
throw(uno::Exception, uno::RuntimeException);
virtual uno::Reference< uno::XInterface > SAL_CALL
createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const uno::Sequence< uno::Any >& Arguments )
throw(uno::Exception, uno::RuntimeException);
virtual uno::Sequence< rtl::OUString > SAL_CALL
getAvailableServiceNames( )
throw(uno::RuntimeException);
/// XLocalizable
virtual void SAL_CALL
setLocale( const lang::Locale& eLocale )
throw (uno::RuntimeException);
virtual lang::Locale SAL_CALL
getLocale( )
throw (uno::RuntimeException);
//XRefreshable
virtual void SAL_CALL
refresh( )
throw (uno::RuntimeException);
virtual void SAL_CALL
addRefreshListener(
const uno::Reference< util::XRefreshListener >& aListener )
throw (uno::RuntimeException);
virtual void SAL_CALL
removeRefreshListener(
const uno::Reference< util::XRefreshListener >& aListener )
throw (uno::RuntimeException);
//XFlushable
virtual void SAL_CALL
flush( )
throw (uno::RuntimeException);
virtual void SAL_CALL
addFlushListener(
const uno::Reference< util::XFlushListener >& aListener )
throw (uno::RuntimeException);
virtual void SAL_CALL
removeFlushListener(
const uno::Reference< util::XFlushListener >& aListener )
throw (uno::RuntimeException);
// OPropertSetHelper
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
sal_Int32 nHandle, const uno::Any& rValue) throw (uno::Exception);
static sal_Int32 countServices(ServiceRegistrationInfo const* aInfo) { return ServiceRegistrationHelper(aInfo).countServices(); }
private:
// creates a new session
void implConnect(OProviderImpl& rFreshProviderImpl, const ContextReader& _rSettings) throw (uno::Exception);
// disambuiguated access
cppu::OBroadcastHelper & getBroadcastHelper()
{ return ServiceComponentImpl::rBHelper; }
/// Component Helper override
virtual void SAL_CALL disposing();
virtual void SAL_CALL disposing(lang::EventObject const& rEvt) throw();
// OPropertyArrayUsageHelper
virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
// OPropertySetHelper
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
// OPropertyContainer
void registerProperty(const rtl::OUString& _rName, sal_Int32 _nHandle, sal_Int32 _nAttributes,
void* _pPointerToMember, const uno::Type& _rMemberType)
{ OPropertyContainer::registerProperty(_rName, _nHandle, _nAttributes, _pPointerToMember, _rMemberType);}
void describeProperties(uno::Sequence< beans::Property >& /* [out] */ _rProps) const
{ OPropertyContainer::describeProperties(_rProps);}
uno::Any SAL_CALL queryPropertyInterface(uno::Type const& rType) throw (uno::RuntimeException)
{ return OPropertyContainer::queryInterface(rType);}
void attachToContext();
uno::Reference< lang::XComponent > releaseContext();
void discardContext(uno::Reference< lang::XComponent > const & xContext);
};
} // namespace configmgr
#endif // CONFIGMGR_API_PROVIDER_HXX_
-893
View File
@@ -1,893 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 <stdio.h>
#include "providerimpl.hxx"
#include "options.hxx"
#include "apifactoryimpl.hxx"
#include "apitreeimplobj.hxx"
#include "apitreeaccess.hxx"
#include "roottree.hxx"
#include "node.hxx"
#include "noderef.hxx"
#include "objectregistry.hxx"
#include "bootstrap.hxx"
#include "cachefactory.hxx"
#include "provider.hxx"
#include "treemanager.hxx"
#include "tracer.hxx"
#include <osl/interlck.h>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/Locale.hpp>
#include <rtl/ustrbuf.hxx>
#include <rtl/logfile.hxx>
#define RTL_LOGFILE_OU2A(rtlOUString) (::rtl::OUStringToOString((rtlOUString), RTL_TEXTENCODING_ASCII_US).getStr())
namespace configmgr
{
namespace css = ::com::sun::star;
namespace uno = css::uno;
namespace beans = css::beans;
namespace configapi
{
class ApiProviderInstances
{
rtl::Reference<ObjectRegistry> m_aObjectRegistry;
ReadOnlyObjectFactory m_aReaderFactory;
UpdateObjectFactory m_aWriterFactory;
ApiProvider m_aReaderProvider;
ApiProvider m_aWriterProvider;
public:
ApiProviderInstances(OProviderImpl& rProviderImpl)
: m_aObjectRegistry(new ObjectRegistry())
, m_aReaderFactory(m_aReaderProvider,m_aObjectRegistry)
, m_aWriterFactory(m_aWriterProvider,m_aObjectRegistry)
, m_aReaderProvider(m_aReaderFactory,rProviderImpl)
, m_aWriterProvider(m_aWriterFactory,rProviderImpl)
{
}
~ApiProviderInstances()
{}
ApiProvider& getReaderProvider() { return m_aReaderProvider; }
ApiProvider& getWriterProvider() { return m_aWriterProvider; }
Factory& getReaderFactory() { return m_aReaderFactory; }
Factory& getWriterFactory() { return m_aWriterFactory; }
};
}
//=============================================================================
//=============================================================================
//= OProviderImpl
//=============================================================================
//-----------------------------------------------------------------------------
OProviderImpl::OProviderImpl(OProvider* _pProvider, uno::Reference< uno::XComponentContext > const & _xContext)
:m_pProvider(_pProvider)
,m_xTypeConverter()
,m_aDefaultOptions()
,m_pNewProviders(NULL)
,m_aTreeManagerMutex()
,m_pTreeManager(NULL)
{
OSL_ENSURE(_xContext.is(), "OProviderImpl : NULL context !");
uno::Reference< lang::XMultiComponentFactory > xFactory = _xContext->getServiceManager();
OSL_ENSURE(xFactory.is(), "OProviderImpl : missing service factory !");
m_xTypeConverter = m_xTypeConverter.query(
xFactory->createInstanceWithContext( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.Converter" )),
_xContext));
OSL_ENSURE(m_xTypeConverter.is(), "Module::Module : could not create an instance of the type converter !");
}
//-----------------------------------------------------------------------------
rtl::Reference< TreeManager > OProviderImpl::maybeGetTreeManager() const SAL_THROW(())
{
osl::MutexGuard aGuard(m_aTreeManagerMutex);
rtl::Reference< TreeManager > xResult(m_pTreeManager);
return xResult;
}
//-----------------------------------------------------------------------------
rtl::Reference< TreeManager > OProviderImpl::getTreeManager() const SAL_THROW((com::sun::star::uno::RuntimeException))
{
osl::MutexGuard aGuard(m_aTreeManagerMutex);
if (m_pTreeManager == NULL)
{
rtl::OUString sMsg = rtl::OUString::createFromAscii("OProviderImpl: No cache available - provider was already disposed.");
throw com::sun::star::lang::DisposedException(sMsg,static_cast<lang::XMultiServiceFactory*>(m_pProvider));
}
rtl::Reference< TreeManager > xResult(m_pTreeManager);
return xResult;
}
//-----------------------------------------------------------------------------
void OProviderImpl::setTreeManager(TreeManager * pTreeManager) SAL_THROW((com::sun::star::uno::RuntimeException))
{
osl::MutexGuard aGuard(m_aTreeManagerMutex);
OSL_PRECOND(m_pTreeManager == NULL, "OProviderImpl: TreeManager is already set");
OSL_PRECOND(pTreeManager != NULL, "OProviderImpl: Trying to set a NULL TreeManager");
if (pTreeManager == NULL)
{
rtl::OUString sMsg = rtl::OUString::createFromAscii("OProviderImpl: No cache available - cache creation failed.");
throw com::sun::star::uno::RuntimeException(sMsg,NULL);
}
(m_pTreeManager = pTreeManager) -> acquire();
}
//-----------------------------------------------------------------------------
void OProviderImpl::clearTreeManager() SAL_THROW(())
{
osl::ClearableMutexGuard aGuard(m_aTreeManagerMutex);
if (TreeManager * pTM = m_pTreeManager)
{
m_pTreeManager = NULL;
pTM->release();
}
}
//-----------------------------------------------------------------------------
bool OProviderImpl::initSession(const ContextReader& _rSettings)
{
bool bNeedProfile = false;
rtl::Reference< TreeManager > xNewTreeManager;
if (_rSettings.isUnoBackend())
{
this->implInitFromSettings(_rSettings,bNeedProfile);
xNewTreeManager = CacheFactory::instance().createCacheManager(_rSettings.getBaseContext());
}
else
{
throw com::sun::star::uno::RuntimeException(rtl::OUString::createFromAscii("OProviderImpl: Only UNO Backends Supported"),NULL);
}
setTreeManager( xNewTreeManager.get() );
OSL_ASSERT( xNewTreeManager.get() );
// put out of line to get rid of the order dependency (and to have a acquired configuration)
m_pNewProviders = new configapi::ApiProviderInstances(*this);
// now complete our state from the user's profile, if necessary
if (bNeedProfile)
try
{
static ::rtl::OUString ssUserProfile(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup"));
configuration::AbsolutePath aProfileModule = configuration::AbsolutePath::makeModulePath(ssUserProfile);
sharable::Node * profileTree = xNewTreeManager->requestSubtree(aProfileModule, m_aDefaultOptions);
if (profileTree != 0)
{
implInitFromProfile(profileTree);
// should we clean this up ?
// xNewTreeManager->releaseSubtree(aProfileModule, xTempOptions);
}
}
catch (uno::Exception& e)
{
// could not read profile
(void)e;
CFG_TRACE_ERROR_NI("Provider bootstrapping: Caught an exception trying to get 'Setup' data: %s", OUSTRING2ASCII(e.Message));
}
return true;
}
//-----------------------------------------------------------------------------
// these can be overridden. default does nothing
void OProviderImpl::initFromSettings(const ContextReader& , bool& )
{
}
//-----------------------------------------------------------------------------
void OProviderImpl::initFromProfile(sharable::Node *)
{
}
//-----------------------------------------------------------------------------
// these implement the base class behavior
void OProviderImpl::implInitFromSettings(const ContextReader& _rSettings, bool& rNeedProfile)
{
bool bIntrinsicNeedProfile = true;
if (_rSettings.hasLocale())
{
bIntrinsicNeedProfile = false;
rtl::OUString sDefaultLocale = _rSettings.getLocale();
m_aDefaultOptions.setIsoLocale(sDefaultLocale);
}
else if (_rSettings.isAdminService())
{
bIntrinsicNeedProfile = false;
m_aDefaultOptions.setAllLocales();
}
else
OSL_ASSERT(!m_aDefaultOptions.hasLocale());
if (_rSettings.hasAsyncSetting())
{
m_aDefaultOptions.enableAsync( !!_rSettings.getAsyncSetting() );
}
// call the template method
this->initFromSettings(_rSettings, rNeedProfile);
if (bIntrinsicNeedProfile)
rNeedProfile = true; // to get locale
}
//-----------------------------------------------------------------------------
void OProviderImpl::implInitFromProfile(sharable::Node * profile)
{
OSL_ASSERT(profile != 0);
sharable::GroupNode * profileNode = sharable::GroupNode::from(profile);
OSL_ASSERT(profileNode != 0);
// read the default locale for the user
if (!m_aDefaultOptions.hasLocale())
{
static rtl::OUString ssSubGroup(RTL_CONSTASCII_USTRINGPARAM("L10N"));
static rtl::OUString ssLocale(RTL_CONSTASCII_USTRINGPARAM("ooLocale"));
sharable::GroupNode * l10nNode = sharable::GroupNode::from(profileNode->getChild(ssSubGroup));
if (l10nNode != 0)
{
sharable::ValueNode * value = sharable::ValueNode::from(l10nNode->getChild(ssLocale));
if (value != 0)
{
rtl::OUString sDefaultLocale;
if (value->getValue() >>= sDefaultLocale)
{
m_aDefaultOptions.setIsoLocale(sDefaultLocale);
}
else
OSL_ENSURE(false, "Could not extract locale parameter into string");
}
}
}
// call the template method
this->initFromProfile(profile);
// last fallback, if there is no locale - even in ooLocale
m_aDefaultOptions.ensureLocaleSet();
}
//-----------------------------------------------------------------------------
void OProviderImpl::setDefaultLocale( com::sun::star::lang::Locale const & aLocale )
{
m_aDefaultOptions.setLocale( aLocale );
// ensure that the locale is never cleared to 'empty'
m_aDefaultOptions.ensureLocaleSet();
}
//-----------------------------------------------------------------------------
OProviderImpl::~OProviderImpl()
{
UnoApiLock aLock; // hmm...
clearTreeManager();
delete m_pNewProviders;
}
// --------------------------------- disposing ---------------------------------
void SAL_CALL OProviderImpl::dispose() throw()
{
try
{
rtl::Reference< TreeManager > xTM = maybeGetTreeManager();
if (xTM.is())
xTM->dispose();
clearTreeManager();
}
catch (uno::Exception& e)
{
(void)e;
CFG_TRACE_ERROR("Disposing the TreeManager or closing the session caused an exception: %s", OUSTRING2ASCII(e.Message));
clearTreeManager();
}
}
//-----------------------------------------------------------------------------
// access to the raw notifications
TreeManager * OProviderImpl::getNotifier() SAL_THROW(())
{
rtl::Reference< TreeManager > xTM = maybeGetTreeManager();
return xTM.get();
}
// DefaultProvider access
//-----------------------------------------------------------------------------
rtl::Reference< TreeManager > OProviderImpl::getDefaultProvider() const SAL_THROW((com::sun::star::uno::RuntimeException))
{
return getTreeManager().get();
}
//-----------------------------------------------------------------------------
sharable::Node * OProviderImpl::requestSubtree( configuration::AbsolutePath const& aSubtreePath,
RequestOptions const & _aOptions
) SAL_THROW((com::sun::star::uno::Exception))
{
rtl::Reference< TreeManager > xTreeManager = getTreeManager();
sharable::Node * tree = 0;
try
{
tree = xTreeManager->requestSubtree(aSubtreePath, _aOptions);
}
catch(uno::Exception&e)
{
::rtl::OUString sMessage = getErrorMessage(aSubtreePath, _aOptions);
// append the error message given by the tree provider
sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n\nThe backend returned the following error:\n"));
sMessage += e.Message;
throw lang::WrappedTargetException(sMessage, getProviderInstance(), uno::makeAny(e));
}
if (tree == 0)
{
::rtl::OUString sMessage = getErrorMessage(aSubtreePath, _aOptions);
sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n\nNo backend error message available\n"));
throw uno::Exception(sMessage, getProviderInstance());
}
return tree;
}
//-----------------------------------------------------------------------------
void OProviderImpl::updateTree(TreeChangeList& aChanges) SAL_THROW((com::sun::star::uno::Exception))
{
getTreeManager()->updateTree(aChanges);
}
//-----------------------------------------------------------------------------
void OProviderImpl::releaseSubtree( configuration::AbsolutePath const& aSubtreePath, RequestOptions const& _aOptions ) SAL_THROW(())
{
rtl::Reference< TreeManager > xTM = maybeGetTreeManager();
if (xTM.is())
xTM->releaseSubtree(aSubtreePath, _aOptions);
}
//-----------------------------------------------------------------------------
void OProviderImpl::saveAndNotifyUpdate(TreeChangeList const& aChanges) SAL_THROW((com::sun::star::uno::Exception))
{
getTreeManager()->saveAndNotifyUpdate(aChanges);
}
//-----------------------------------------------------------------------------
void OProviderImpl::fetchSubtree(configuration::AbsolutePath const& aSubtreePath, RequestOptions const& _aOptions) SAL_THROW(())
{
rtl::Reference< TreeManager > xTM = maybeGetTreeManager();
if (xTM.is())
xTM->fetchSubtree(aSubtreePath, _aOptions);
}
//-----------------------------------------------------------------------------
sal_Bool OProviderImpl::fetchDefaultData(configuration::AbsolutePath const& aSubtreePath, RequestOptions const& _aOptions) SAL_THROW((com::sun::star::uno::Exception))
{
return getTreeManager()->fetchDefaultData(aSubtreePath, _aOptions);
}
//-----------------------------------------------------------------------------------
void OProviderImpl::refreshAll()SAL_THROW((com::sun::star::uno::Exception))
{
m_pTreeManager->refreshAll();
}
//-----------------------------------------------------------------------------------
void OProviderImpl::flushAll()SAL_THROW(())
{
m_pTreeManager->flushAll();
}
//-----------------------------------------------------------------------------------
void OProviderImpl::enableAsync(const sal_Bool& bEnableAsync) SAL_THROW(())
{
m_pTreeManager->enableAsync(bEnableAsync);
}
//-----------------------------------------------------------------------------
uno::XInterface* OProviderImpl::getProviderInstance()
{
return static_cast<com::sun::star::lang::XMultiServiceFactory*>(m_pProvider);
}
//-----------------------------------------------------------------------------------
rtl::OUString OProviderImpl::getErrorMessage(configuration::AbsolutePath const& _rAccessor, RequestOptions const& _aOptions)
{
rtl::OUString const sAccessor = _rAccessor.toString();
CFG_TRACE_ERROR("config provider: the cache manager could not provide the tree (neither from the cache nor from the session)");
::rtl::OUString sMessage;
::rtl::OUString sEntity(_aOptions.getEntity());
::rtl::OUString sLocale(_aOptions.getLocale());
CFG_TRACE_INFO_NI("config provider: the entity we tried this for is \"%s\", the locale \"%s\", the path \"%s\"", OUSTRING2ASCII(sEntity), OUSTRING2ASCII(sLocale), OUSTRING2ASCII(sAccessor));
sMessage += sAccessor;
if (sEntity.getLength())
{
sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" (and for entity "));
sMessage += sEntity;
sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
}
if (sLocale.getLength())
{
sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" (and for locale "));
sMessage += sLocale;
sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
}
sMessage += ::rtl::OUString::createFromAscii(" could not be created. Unable to retrieve the node from the configuration server.");
return sMessage;
}
// actual factory methods
//-----------------------------------------------------------------------------------
configapi::NodeElement* OProviderImpl::buildReadAccess(rtl::OUString const& _rAccessor, RequestOptions const& _aOptions, sal_Int32 nMinLevels) SAL_THROW((com::sun::star::uno::Exception))
{
CFG_TRACE_INFO("config provider: requesting the tree from the cache manager");
OSL_ASSERT(sal_Int16(nMinLevels) == nMinLevels);
RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::OProviderImpl", "jb99855", "configmgr::OProviderImpl::buildReadAccess()");
RTL_LOGFILE_CONTEXT_TRACE1(aLog, "request path: %s", RTL_LOGFILE_OU2A(_rAccessor) );
try
{
configuration::AbsolutePath aAccessorPath = configuration::AbsolutePath::parse(_rAccessor);
sharable::Node * tree = requestSubtree(aAccessorPath,_aOptions);
RTL_LOGFILE_CONTEXT_TRACE(aLog, "data loaded" );
unsigned int nDepth = (nMinLevels == treeop::ALL_LEVELS) ? configuration::C_TreeDepthAll : (unsigned int)(nMinLevels);
RTL_LOGFILE_CONTEXT_AUTHOR(aLog2, "configmgr::OProviderImpl", "jb99855", "configmgr: createReadOnlyTree()");
rtl::Reference< configuration::Tree > aRootTree( configuration::createReadOnlyTree(
aAccessorPath, tree, nDepth,
configuration::TemplateProvider( getTreeManager(), _aOptions )
));
return m_pNewProviders->getReaderFactory().makeAccessRoot(aRootTree, _aOptions);
}
catch (configuration::Exception& e)
{
configapi::ExceptionMapper ec(e);
ec.setContext(this->getProviderInstance());
//ec.unhandled();
throw lang::WrappedTargetException(ec.message(), ec.context(), uno::Any());
}
}
//-----------------------------------------------------------------------------------
configapi::NodeElement* OProviderImpl::buildUpdateAccess(rtl::OUString const& _rAccessor, RequestOptions const& _aOptions,
sal_Int32 nMinLevels) SAL_THROW((com::sun::star::uno::Exception))
{
CFG_TRACE_INFO("config provider: requesting the tree from the cache manager");
OSL_ASSERT(sal_Int16(nMinLevels) == nMinLevels);
RTL_LOGFILE_CONTEXT_AUTHOR(aLog, "configmgr::OProviderImpl", "jb99855", "configmgr: buildUpdateAccess()");
RTL_LOGFILE_CONTEXT_TRACE1(aLog, "request path: %s", RTL_LOGFILE_OU2A(_rAccessor) );
try
{
configuration::AbsolutePath aAccessorPath = configuration::AbsolutePath::parse(_rAccessor);
sharable::Node * tree = requestSubtree(aAccessorPath, _aOptions);
RTL_LOGFILE_CONTEXT_TRACE(aLog, "data loaded" );
unsigned int nDepth = (nMinLevels == treeop::ALL_LEVELS) ? configuration::C_TreeDepthAll : (unsigned int)(nMinLevels);
RTL_LOGFILE_CONTEXT_AUTHOR(aLog2, "configmgr::OProviderImpl", "jb99855", "createUpdatableTree()");
rtl::Reference< configuration::Tree > aRootTree( configuration::createUpdatableTree(
aAccessorPath, tree, nDepth,
configuration::TemplateProvider( getTreeManager(), _aOptions )
));
return m_pNewProviders->getWriterFactory().makeAccessRoot(aRootTree, _aOptions);
}
catch (configuration::Exception& e)
{
configapi::ExceptionMapper ec(e);
ec.setContext(this->getProviderInstance());
//ec.unhandled();
throw lang::WrappedTargetException(ec.message(), ec.context(), uno::Any());
}
}
//=============================================================================
//= OProvider::FactoryArguments
//=============================================================================
sal_Char const * const OProviderImpl::FactoryArguments::asciiArgumentNames[] =
{
"nodepath", // ARG_NODEPATH, // requested node path
"depth", // ARG_DEPTH, // depth of the tree
"user", // ARG_USER_DEPRECATED, // name of the user - only for admin
"locale", // ARG_LOCALE, // desired locale
"nocache", // ARG_NOCACHE_OBSOLETE, // cache disabling
"lazywrite", // ARG_ASYNC_DEPRECATED, // lasy write data
"enableasync", // ARG_ASYNC, // lasy write data
"entity", // ARG_ENTITY, // name of the entity to be manipulated - only for admin
"reload", //ARG_REFRESH // refresh component
};
OProviderImpl::FactoryArguments::Argument
OProviderImpl::FactoryArguments::lookupArgument(const rtl::OUString& rName)
SAL_THROW(())
{
rtl::OUString sCheck( rName.toAsciiLowerCase() );
sal_Char const * const * const pFirst = asciiArgumentNames;
sal_Char const * const * const pLast = pFirst + _arg_count;
sal_Char const * const * it = pFirst;
for(; it != pLast; ++it)
{
if (0 == sCheck.compareToAscii(*it))
{
break;
}
}
OSL_ASSERT( Argument(pLast-pFirst) == ARG_NOT_FOUND );
return static_cast<Argument>(it - pFirst);
}
//-----------------------------------------------------------------------------------
bool OProviderImpl::FactoryArguments::extractOneArgument(
rtl::OUString const& aName, uno::Any const& aValue,
rtl::OUString& /* [out] */ _rNodeAccessor,
sal_Int32& /* [out] */ _nLevels,
RequestOptions& /* [in/out] */ _rOptions )
SAL_THROW(())
{
switch ( lookupArgument(aName) )
{
case ARG_NODEPATH:
{
rtl::OUString sStringVal;
if (aValue >>= sStringVal)
_rNodeAccessor = sStringVal;
else
return false;
}
break;
case ARG_DEPTH:
{
sal_Int32 nIntVal = 0;
if (aValue >>= nIntVal)
_nLevels = nIntVal;
else
return false;
}
break;
case ARG_ENTITY:
case ARG_USER_DEPRECATED:
{
rtl::OUString sStringVal;
if (aValue >>= sStringVal)
_rOptions.setEntity(sStringVal);
else
return false;
}
break;
case ARG_LOCALE:
{
rtl::OUString sStringVal;
if (aValue >>= sStringVal)
{
_rOptions.setIsoLocale(sStringVal);
break;
}
lang::Locale aLocale;
if (aValue >>= aLocale)
{
_rOptions.setLocale(aLocale);
break;
}
return false;
}
case ARG_NOCACHE_OBSOLETE:
{
sal_Bool bBoolVal;
if (aValue >>= bBoolVal)
OSL_ENSURE(false,"ConfigurationProvider: Parameter \"nocache\" is obsolete and has no effect");
else
return false;
}
break;
case ARG_ASYNC:
case ARG_ASYNC_DEPRECATED:
{
sal_Bool bBoolVal = sal_False;
if (aValue >>= bBoolVal)
_rOptions.enableAsync(!!bBoolVal);
else
return false;
}
break;
case ARG_REFRESH:
{
sal_Bool bBoolVal = sal_False;
if (aValue >>= bBoolVal)
_rOptions.forceRefresh(!!bBoolVal);
else
return false;
}
break;
case ARG_NOT_FOUND:
{
rtl::OString sMessage(RTL_CONSTASCII_STRINGPARAM("Unknown argument \""));
sMessage += rtl::OUStringToOString(aName, RTL_TEXTENCODING_ASCII_US);
sMessage += rtl::OString(RTL_CONSTASCII_STRINGPARAM("\" !\n- Parameter will be ignored -\n"));
CFG_TRACE_WARNING( "provider: %s", sMessage.getStr() );
#ifdef DBG_UTIL
OSL_ENSURE(false, sMessage.getStr());
#endif
}
break;
default:
CFG_TRACE_ERROR( "Known argument is not handled" );
OSL_ENSURE(false, "Known argument is not handled");
break;
}
return true;
}
//-----------------------------------------------------------------------------------
static
void failInvalidArg(uno::Any const & aArg, sal_Int32 _nArg = -1)
SAL_THROW((lang::IllegalArgumentException))
{
OSL_ENSURE( sal_Int16(_nArg) == _nArg, "Argument number out of range. Raising imprecise exception.");
rtl::OUStringBuffer sMessage;
sMessage.appendAscii("Configuration Provider: An argument");
sMessage.appendAscii(" has the wrong type.");
sMessage.appendAscii("\n- Expected a NamedValue or PropertyValue");
sMessage.appendAscii("\n- Found type ").append( aArg.getValueType().getTypeName() );
throw lang::IllegalArgumentException( sMessage.makeStringAndClear(),
uno::Reference<uno::XInterface>(),
sal_Int16(_nArg+1));
}
//-----------------------------------------------------------------------------------
static
void failInvalidArgValue(rtl::OUString const & aName, uno::Any const & aValue, sal_Int32 _nArg = -1)
SAL_THROW((lang::IllegalArgumentException))
{
OSL_ENSURE( sal_Int16(_nArg) == _nArg, "Argument number out of range. Raising imprecise exception.");
rtl::OUStringBuffer sMessage;
sMessage.appendAscii("Configuration Provider: The argument ").append(aName);
sMessage.appendAscii(" has the wrong type.");
sMessage.appendAscii("\n- Found type ").append( aValue.getValueType().getTypeName() );
throw lang::IllegalArgumentException( sMessage.makeStringAndClear(),
uno::Reference<uno::XInterface>(),
sal_Int16(_nArg+1));
}
//-----------------------------------------------------------------------------------
static
bool extractLegacyArguments( const uno::Sequence<uno::Any>& _rArgs,
rtl::OUString& /* [out] */ _rNodeAccessor,
sal_Int32& /* [out] */ _nLevels )
SAL_THROW((lang::IllegalArgumentException))
{
OSL_ASSERT( _rArgs.getLength() != 0 );
// compatibility : formerly, you could specify the node path as first arg and the (optional) depth
// as second arg
if (! (_rArgs[0] >>= _rNodeAccessor) )
return false;
switch (_rArgs.getLength() )
{
case 1:
// valid single argument
return true;
case 2:
// valid second argument
if (_rArgs[1] >>= _nLevels)
return true;
break;
default:
if (_rArgs[1] >>= _nLevels)
{
// valid second argument, but too many arguments altogether
throw lang::IllegalArgumentException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"Configuration Provider: Too many arguments. "
"Additional arguments are not supported when passing the node path as string (deprecated convention).")),
uno::Reference<uno::XInterface>(),
sal_Int16(3)
);
}
break;
}
// here we have an invalid second argument
if (_rArgs[1].getValueTypeClass() != uno::TypeClass_STRUCT)
{
// completely invalid second argument
failInvalidArgValue(rtl::OUString::createFromAscii("<depth>"),_rArgs[1],1);
}
// Assume PropertyValue or NamedValue,
// which should be handled consistently by caller
return false;
}
//-----------------------------------------------------------------------------------
void OProviderImpl::FactoryArguments::extractArgs( const uno::Sequence<uno::Any>& _rArgs,
rtl::OUString& /* [out] */ _rNodeAccessor,
sal_Int32& /* [out] */ _nLevels,
RequestOptions & /* [in/out] */ _aOptions )
SAL_THROW((lang::IllegalArgumentException))
{
UnoApiLock aLock;
_nLevels = treeop::ALL_LEVELS; // setting a fallback
// the args have to be a sequence of property or named values
beans::NamedValue aNV;
beans::PropertyValue aPV;
for (sal_Int32 i=0; i<_rArgs.getLength(); ++i)
{
if (_rArgs[i] >>= aPV)
{
if ( !extractOneArgument(aPV.Name,aPV.Value,_rNodeAccessor,_nLevels,_aOptions) )
failInvalidArgValue(aPV.Name,aPV.Value,i);
}
else if (_rArgs[i] >>= aNV)
{
if ( !extractOneArgument(aNV.Name,aNV.Value,_rNodeAccessor,_nLevels,_aOptions) )
failInvalidArgValue(aNV.Name,aNV.Value,i);
}
else
{
if (i == 0)// try compatibility format
if ( extractLegacyArguments(_rArgs,_rNodeAccessor,_nLevels))
break;
failInvalidArg(_rArgs[i],i);
OSL_ASSERT(false);
}
}
if (_rNodeAccessor.getLength() == 0)
{
rtl::OUString sMessage(RTL_CONSTASCII_USTRINGPARAM("Configuration Provider: Missing argument: no nodepath was provided"));
throw lang::IllegalArgumentException(sMessage,uno::Reference<uno::XInterface>(),0);
}
}
//--------------------------------------------------------------------------
uno::Reference<uno::XInterface> OProviderImpl::createReadAccess( uno::Sequence<uno::Any> const& aArgs)
SAL_THROW((com::sun::star::uno::Exception))
{
CFG_TRACE_INFO("config provider: going to create a read access instance");
// extract the args
rtl::OUString sPath;
sal_Int32 nLevels;
RequestOptions aOptions = getDefaultOptions();
OProviderImpl::FactoryArguments::extractArgs(aArgs, sPath, nLevels, aOptions);
CFG_TRACE_INFO_NI("config provider: node accessor extracted from the args is %s", OUSTRING2ASCII(sPath));
CFG_TRACE_INFO_NI("config provider: level depth extracted from the args is %i", nLevels);
// create the access object
uno::Reference< uno::XInterface > xReturn;
configapi::NodeElement* pElement = buildReadAccess(sPath, aOptions, nLevels);
if (pElement != 0)
{
xReturn = pElement->getUnoInstance();
if (xReturn.is())
// acquired once by buildReadAccess
xReturn->release();
}
return xReturn;
}
//-----------------------------------------------------------------------------------
uno::Reference<uno::XInterface> OProviderImpl::createUpdateAccess( uno::Sequence<uno::Any> const& aArgs)
SAL_THROW((com::sun::star::uno::Exception))
{
CFG_TRACE_INFO("config provider: going to create an update access instance");
// extract the args
rtl::OUString sPath;
sal_Int32 nLevels;
RequestOptions aOptions = getDefaultOptions();
OProviderImpl::FactoryArguments::extractArgs(aArgs, sPath, nLevels, aOptions);
CFG_TRACE_INFO_NI("config provider: node accessor extracted from the args is %s", OUSTRING2ASCII(sPath));
CFG_TRACE_INFO_NI("config provider: level depth extracted from the args is %i", nLevels);
// create the access object
uno::Reference< uno::XInterface > xReturn;
configapi::NodeElement* pElement = buildUpdateAccess(sPath, aOptions, nLevels);
if (pElement != 0)
{
xReturn = pElement->getUnoInstance();
if (xReturn.is())
// acquired once by buildReadAccess
xReturn->release();
}
return xReturn;
}
//-----------------------------------------------------------------------------------
} // namespace configmgr
-228
View File
@@ -1,228 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_PROVIDERIMPL_HXX_
#define CONFIGMGR_API_PROVIDERIMPL_HXX_
#include "defaultprovider.hxx"
#include "requestoptions.hxx"
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/script/XTypeConverter.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <cppuhelper/implbase1.hxx>
#include <osl/mutex.hxx>
namespace com { namespace sun { namespace star {
namespace uno
{
class Any;
class XInterface;
template <class> class Sequence;
template <class> class Reference;
}
namespace beans
{
struct PropertyValue;
}
} } }
namespace rtl
{
class OUString;
template <class RCType> class Reference;
}
namespace configmgr
{
namespace css = ::com::sun::star;
namespace uno = css::uno;
namespace script = css::script;
namespace lang = css::lang;
namespace beans = css::beans;
class ISubtree;
struct TreeChangeList;
class TreeManager;
class ContextReader;
class OProvider;
namespace configapi
{
class NodeElement;
class ApiProviderInstances;
class Factory;
}
namespace sharable { union Node; }
// -----------------------------------------------------------------------------
class OProviderImpl : public IDefaultableTreeManager
{
friend class OProvider;
public:
//==========================================================================
//= FactoryArguments
//==========================================================================
/** Helper class for evaluation of the arguments for creating a service instance.*/
struct FactoryArguments
{
/// possible arguments, given only in small letters.
enum Argument
{
ARG_NODEPATH, // requested node path
ARG_DEPTH, // depth of the tree
ARG_USER_DEPRECATED, // name of the entity to be manipulated - deprecated version
ARG_LOCALE, // desired locale
ARG_NOCACHE_OBSOLETE, // cache disabling - obsolete and nonfunctional
ARG_ASYNC_DEPRECATED, // lasy write data - deprecated version
ARG_ASYNC, // lazy write data
ARG_ENTITY, // name of the entity to be manipulated - only for admin
ARG_REFRESH, // force refresh of data into cache
_arg_count,
ARG_NOT_FOUND = _arg_count
};
static sal_Char const * const asciiArgumentNames[];
static Argument lookupArgument(rtl::OUString const& sArgumentName) SAL_THROW(());
public:
/** extracts arguments from the argument sequence into to the parameter variables
<p>unknown arguments are ignored</p>
@throws com::sun::star::lang::IllegalArgumentException
if an element of _rArgs had the wrong type or
if the value of a known argument has the wrong type or
if the value of a known argument is out of range (sometimes)
or if no non-empty node path argument could be extracted,
*/
static void extractArgs( const uno::Sequence<uno::Any>& _rArgs,
rtl::OUString& /* [out] */ _rNodeAccessor,
sal_Int32& /* [out] */ _nLevels,
RequestOptions& /* [in/out] */ xOptions)
SAL_THROW((lang::IllegalArgumentException));
static bool extractOneArgument( rtl::OUString const& aName, uno::Any const& aValue,
rtl::OUString& /* [out] */ _rNodeAccessor,
sal_Int32& /* [out] */ _nLevels,
RequestOptions& /* [in/out] */ xOptions
) SAL_THROW(());
};
private:
OProvider* m_pProvider; /// used for ref counting, uno representation
uno::Reference< script::XTypeConverter > m_xTypeConverter;
RequestOptions m_aDefaultOptions;
configapi::ApiProviderInstances* m_pNewProviders;
mutable osl::Mutex m_aTreeManagerMutex;
TreeManager* m_pTreeManager; /// the tree cache. Will hold a reference to us as long as it life
rtl::Reference< TreeManager > maybeGetTreeManager() const SAL_THROW(());
rtl::Reference< TreeManager > getTreeManager() const SAL_THROW((com::sun::star::uno::RuntimeException));
void setTreeManager(TreeManager * pTreeManager) SAL_THROW((com::sun::star::uno::RuntimeException));
void clearTreeManager() SAL_THROW(());
OProviderImpl(OProvider* _pProvider,
uno::Reference< uno::XComponentContext > const & xContext);
public:
virtual ~OProviderImpl();
/** request that the tree named by a path is added to the collection of managed trees
respecting certain options and requiring a specific loading depth.
Return a reference to that managed tree.
The reference must later be released by calling releaseSubtree with the same path and options.
*/
sharable::Node * requestSubtree(configuration::AbsolutePath const& aSubtreePath, const RequestOptions& _aOptions) SAL_THROW((com::sun::star::uno::Exception));
/// update the managed data according to a changes list - update the changes list accordingly with old values
void updateTree(TreeChangeList& aChanges) SAL_THROW((com::sun::star::uno::Exception));
// bookkeeping support
void releaseSubtree( configuration::AbsolutePath const& aSubtreePath, const RequestOptions& _aOptions ) SAL_THROW(());
// notification
void saveAndNotifyUpdate(TreeChangeList const& aChanges) SAL_THROW((com::sun::star::uno::Exception));
/** request that the tree named by a path is added to the collection of managed trees
respecting certain options and requiring a specific loading depth.
*/
void fetchSubtree(configuration::AbsolutePath const& aSubtreePath, const RequestOptions& _aOptions) SAL_THROW(());
//Refresh all components in the cache
void refreshAll() SAL_THROW((com::sun::star::uno::Exception));
//Flush all components in the cache
void flushAll() SAL_THROW(());
//Enable/Disable Asynchronous write-back to cache
void enableAsync(const sal_Bool& bEnableAsync) SAL_THROW(());
/// IDefaultableTreeManager
virtual sal_Bool fetchDefaultData(configuration::AbsolutePath const& aSubtreePath, const RequestOptions& _aOptions
) SAL_THROW((com::sun::star::uno::Exception));
// DefaultProvider access
rtl::Reference< TreeManager > getDefaultProvider() const SAL_THROW((com::sun::star::uno::RuntimeException));
protected:
static rtl::OUString getErrorMessage(configuration::AbsolutePath const& _rAccessor, const RequestOptions& _aOptions);
void SAL_CALL dispose() throw();
public:
void setDefaultLocale( com::sun::star::lang::Locale const & aLocale );
RequestOptions const& getDefaultOptions() const {return m_aDefaultOptions;}
uno::Reference< script::XTypeConverter > getTypeConverter() const {return m_xTypeConverter;}
TreeManager * getNotifier() SAL_THROW(());
uno::XInterface* getProviderInstance();
// actual factory methods
// the returned object (if any) has to be acquired once)
configapi::NodeElement* buildReadAccess( rtl::OUString const& _rAccessor, const RequestOptions& _aOptions, sal_Int32 nMinLevels) SAL_THROW((com::sun::star::uno::Exception));
// the returned object (if any) has to be acquired once)
configapi::NodeElement* buildUpdateAccess(rtl::OUString const& _rAccessor, const RequestOptions& _aOptions, sal_Int32 nMinLevels) SAL_THROW((com::sun::star::uno::Exception));
// factory methods
uno::Reference<uno::XInterface> createReadAccess( uno::Sequence<uno::Any> const& aArgs) SAL_THROW((com::sun::star::uno::Exception));
uno::Reference<uno::XInterface> createUpdateAccess( uno::Sequence<uno::Any> const& aArgs) SAL_THROW((com::sun::star::uno::Exception));
private:
bool initSession(const ContextReader& _rSettings);
private:
void implInitFromSettings(const ContextReader& _rSettings, bool& rNeedProfile);
void implInitFromProfile(sharable::Node * aProfile);
void initFromSettings(const ContextReader& _rSettings, bool& rNeedProfile);
void initFromProfile(sharable::Node * aProfile);
};
} // namespace configmgr
#endif // CONFIGMGR_API_PROVIDERIMPL_HXX_
-185
View File
@@ -1,185 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "setaccess.hxx"
#include "accessimpl.hxx"
#include "apinotifierimpl.hxx"
#include "apinodeaccess.hxx"
namespace configmgr
{
// XHierarchicalName
//------------------------------------------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicSetAccess::getHierarchicalName( ) throw(uno::RuntimeException)
{
return configapi::implGetHierarchicalName( getNode() );
}
//------------------------------------------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicSetAccess::composeHierarchicalName( const rtl::OUString& sRelativeName )
throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, uno::RuntimeException)
{
return configapi::implComposeHierarchicalName( getNode(), sRelativeName );
}
//------------------------------------------------------------------------------------------------------------------
// XElementAccess, base class of XNameAccess (and XHierarchicalNameAccess ? )
//-----------------------------------------------------------------------------------
uno::Type SAL_CALL BasicSetAccess::getElementType( ) throw(uno::RuntimeException)
{
return configapi::implGetElementType( getNode() );
}
//-----------------------------------------------------------------------------------
sal_Bool SAL_CALL BasicSetAccess::hasElements( ) throw(uno::RuntimeException)
{
return configapi::implHasElements( getNode() );
}
// XExactName
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicSetAccess::getExactName( const rtl::OUString& rApproximateName ) throw(uno::RuntimeException)
{
return configapi::implGetExactName( getNode(), rApproximateName);
}
// XProperty
//-----------------------------------------------------------------------------------
css::beans::Property SAL_CALL BasicSetAccess::getAsProperty( ) throw(uno::RuntimeException)
{
return configapi::implGetAsProperty( getNode() );
}
// XPropertySetInfo
//-----------------------------------------------------------------------------------
uno::Sequence< css::beans::Property > SAL_CALL BasicSetAccess::getProperties( ) throw (uno::RuntimeException)
{
return configapi::implGetProperties( getNode() );
}
css::beans::Property SAL_CALL BasicSetAccess::getPropertyByName( const rtl::OUString& aName )
throw (css::beans::UnknownPropertyException, uno::RuntimeException)
{
return configapi::implGetPropertyByName( getNode(), aName );
}
sal_Bool SAL_CALL BasicSetAccess::hasPropertyByName( const rtl::OUString& name ) throw (uno::RuntimeException)
{
return configapi::implHasPropertyByName( getNode(), name );
}
// XNameAccess
//-----------------------------------------------------------------------------------
sal_Bool SAL_CALL BasicSetAccess::hasByName( const rtl::OUString& sName ) throw(uno::RuntimeException)
{
return configapi::implHasByName( getNode(), sName);
}
//-----------------------------------------------------------------------------------
uno::Any SAL_CALL BasicSetAccess::getByName( const rtl::OUString& sName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
{
return configapi::implGetByName( getNode(), sName );
}
//-----------------------------------------------------------------------------------
uno::Sequence< rtl::OUString > SAL_CALL BasicSetAccess::getElementNames( ) throw( uno::RuntimeException)
{
return configapi::implGetElementNames( getNode() );
}
// XHierarchicalNameAccess
//-----------------------------------------------------------------------------------
sal_Bool SAL_CALL BasicSetAccess::hasByHierarchicalName( const rtl::OUString& sName ) throw(uno::RuntimeException)
{
return configapi::implHasByHierarchicalName( getNode(), sName);
}
//-----------------------------------------------------------------------------------
uno::Any SAL_CALL BasicSetAccess::getByHierarchicalName( const rtl::OUString& sName )
throw(css::container::NoSuchElementException, uno::RuntimeException)
{
return configapi::implGetByHierarchicalName( getNode(), sName );
}
// XContainer
//-----------------------------------------------------------------------------------
void SAL_CALL BasicSetAccess::addContainerListener( const uno::Reference< css::container::XContainerListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implAddListener( getNode(), xListener );
}
void SAL_CALL BasicSetAccess::removeContainerListener( const uno::Reference< css::container::XContainerListener >& xListener )
throw(uno::RuntimeException)
{
configapi::implRemoveListener( getNode(), xListener );
}
//-----------------------------------------------------------------------------------
// Set-specific interfaces
//-----------------------------------------------------------------------------------
// XTemplateContainer
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicSetAccess::getElementTemplateName( )
throw(uno::RuntimeException)
{
return configapi::implGetElementTemplateName( getNode() );
}
// XStringEscape
//-----------------------------------------------------------------------------------
rtl::OUString SAL_CALL BasicSetAccess::escapeString( const rtl::OUString& aString )
throw(css::lang::IllegalArgumentException, uno::RuntimeException)
{
return aString;
}
rtl::OUString SAL_CALL BasicSetAccess::unescapeString( const rtl::OUString& aEscapedString )
throw(css::lang::IllegalArgumentException, uno::RuntimeException)
{
return aEscapedString;
}
//-----------------------------------------------------------------------------------
} // namespace configmgr
-167
View File
@@ -1,167 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_SETACCESS_HXX_
#define CONFIGMGR_API_SETACCESS_HXX_
#include <com/sun/star/container/XHierarchicalName.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/container/XContainer.hpp>
#include <com/sun/star/configuration/XTemplateContainer.hpp>
#include <com/sun/star/beans/XExactName.hpp>
#include <com/sun/star/beans/XProperty.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/util/XStringEscape.hpp>
#include <cppuhelper/implbase9.hxx>
namespace configmgr
{
namespace css = ::com::sun::star;
namespace uno = ::com::sun::star::uno;
namespace configapi { class NodeSetInfoAccess; }
/** implements the (read-only) interfaces supported by a set node
within the configuration tree.
<p> Is an interface adapter around <type scope='configmgr::configapi'>NodeAccess</type>.</p>
*/
class BasicSetAccess
: public ::cppu::ImplHelper9
< css::container::XNameAccess
, css::container::XHierarchicalName
, css::container::XHierarchicalNameAccess
, css::container::XContainer
, css::beans::XExactName
, css::beans::XProperty
, css::beans::XPropertySetInfo
, css::configuration::XTemplateContainer
, css::util::XStringEscape
>
{
protected:
// Destructors
virtual ~BasicSetAccess() {}
public:
// Interface methods
// XHierarchicalName
virtual rtl::OUString SAL_CALL
getHierarchicalName( )
throw(uno::RuntimeException);
virtual rtl::OUString SAL_CALL
composeHierarchicalName( const rtl::OUString& aRelativeName )
throw(css::lang::IllegalArgumentException, css::lang::NoSupportException,
uno::RuntimeException);
// XElementAccess, base class of XNameAccess
virtual uno::Type SAL_CALL
getElementType( )
throw(uno::RuntimeException);
virtual sal_Bool SAL_CALL
hasElements( )
throw(uno::RuntimeException);
// XNameAccess
virtual uno::Any SAL_CALL
getByName( const rtl::OUString& aName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException,
uno::RuntimeException);
virtual uno::Sequence< rtl::OUString > SAL_CALL
getElementNames( )
throw( uno::RuntimeException);
virtual sal_Bool SAL_CALL
hasByName( const rtl::OUString& aName )
throw(uno::RuntimeException);
// XHierarchicalNameAccess
virtual uno::Any SAL_CALL
getByHierarchicalName( const rtl::OUString& aName )
throw(css::container::NoSuchElementException, uno::RuntimeException);
virtual sal_Bool SAL_CALL
hasByHierarchicalName( const rtl::OUString& aName )
throw(uno::RuntimeException);
// XContainer
virtual void SAL_CALL
addContainerListener( const uno::Reference< css::container::XContainerListener >& xListener )
throw(uno::RuntimeException);
virtual void SAL_CALL
removeContainerListener( const uno::Reference< css::container::XContainerListener >& xListener )
throw(uno::RuntimeException);
// XExactName
virtual rtl::OUString SAL_CALL
getExactName( const rtl::OUString& aApproximateName )
throw(uno::RuntimeException);
// XProperty
virtual css::beans::Property SAL_CALL
getAsProperty( )
throw(uno::RuntimeException);
// XPropertySetInfo
virtual uno::Sequence< css::beans::Property > SAL_CALL
getProperties( )
throw (uno::RuntimeException);
virtual css::beans::Property SAL_CALL
getPropertyByName( const rtl::OUString& aName )
throw (css::beans::UnknownPropertyException, uno::RuntimeException);
virtual sal_Bool SAL_CALL
hasPropertyByName( const rtl::OUString& name )
throw (uno::RuntimeException);
// XTemplateContainer
rtl::OUString SAL_CALL
getElementTemplateName( )
throw(uno::RuntimeException);
// XStringEscape
rtl::OUString SAL_CALL
escapeString( const rtl::OUString& aString )
throw(css::lang::IllegalArgumentException, uno::RuntimeException);
rtl::OUString SAL_CALL
unescapeString( const rtl::OUString& aEscapedString )
throw(css::lang::IllegalArgumentException, uno::RuntimeException);
protected:
virtual configapi::NodeSetInfoAccess& getNode() = 0;
};
}
#endif // CONFIGMGR_API_SETACCESS_HXX_
-547
View File
@@ -1,547 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 <stdio.h>
#include "setobjects.hxx"
#include "comphelper/sequence.hxx"
//........................................................................
namespace configmgr
{
//==========================================================================
//= OInnerSetInfo
//==========================================================================
// XInterface refcounting
void SAL_CALL OInnerSetInfo::acquire( ) throw ()
{
BasicInnerElement::acquire();
}
void SAL_CALL OInnerSetInfo::release( ) throw ()
{
BasicInnerElement::release();
}
// XInterface joining
uno::Any SAL_CALL OInnerSetInfo::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicInnerElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicSetAccess::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL OInnerSetInfo::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicInnerElement::getTypes(),BasicSetAccess::getTypes() );
}
uno::Sequence< sal_Int8 > SAL_CALL OInnerSetInfo::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicInnerElement::getImplementationId();
}
configapi::NodeAccess& OInnerSetInfo::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeSetInfoAccess& OInnerSetInfo::getNode()
{
return m_aAccessElement;
}
configapi::InnerElement& OInnerSetInfo::getElementClass()
{
return m_aAccessElement;
}
//==========================================================================
//= OInnerTreeSetUpdate
//==========================================================================
// XInterface refcounting
void SAL_CALL OInnerTreeSetUpdate::acquire( ) throw ()
{
BasicInnerElement::acquire();
}
void SAL_CALL OInnerTreeSetUpdate::release( ) throw ()
{
BasicInnerElement::release();
}
// XInterface joining
uno::Any SAL_CALL OInnerTreeSetUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicInnerElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicSet::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL OInnerTreeSetUpdate::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicInnerElement::getTypes(),BasicSet::getTypes() );
}
uno::Sequence< sal_Int8 > SAL_CALL OInnerTreeSetUpdate::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicInnerElement::getImplementationId();
}
configapi::NodeAccess& OInnerTreeSetUpdate::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeSetInfoAccess& OInnerTreeSetUpdate::getNode()
{
return m_aAccessElement;
}
configapi::NodeTreeSetAccess* OInnerTreeSetUpdate::maybeGetUpdateAccess()
{
return &m_aAccessElement;
}
configapi::InnerElement& OInnerTreeSetUpdate::getElementClass()
{
return m_aAccessElement;
}
//==========================================================================
//= OInnerValueSetUpdate
//==========================================================================
// XInterface refcounting
void SAL_CALL OInnerValueSetUpdate::acquire( ) throw ()
{
BasicInnerElement::acquire();
}
void SAL_CALL OInnerValueSetUpdate::release( ) throw ()
{
BasicInnerElement::release();
}
// XInterface joining
uno::Any SAL_CALL OInnerValueSetUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicInnerElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicValueSet::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL OInnerValueSetUpdate::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicInnerElement::getTypes(),BasicValueSet::getTypes() );
}
uno::Sequence< sal_Int8 > SAL_CALL OInnerValueSetUpdate::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicInnerElement::getImplementationId();
}
configapi::NodeAccess& OInnerValueSetUpdate::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeSetInfoAccess& OInnerValueSetUpdate::getNode()
{
return m_aAccessElement;
}
configapi::NodeValueSetAccess* OInnerValueSetUpdate::maybeGetUpdateAccess()
{
return &m_aAccessElement;
}
configapi::InnerElement& OInnerValueSetUpdate::getElementClass()
{
return m_aAccessElement;
}
//==========================================================================
//= OSetElementSetInfo
//==========================================================================
// XInterface refcounting
void SAL_CALL OSetElementSetInfo::acquire( ) throw ()
{
BasicSetElement::acquire();
}
void SAL_CALL OSetElementSetInfo::release( ) throw ()
{
BasicSetElement::release();
}
// XInterface joining
uno::Any SAL_CALL OSetElementSetInfo::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicSetElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicSetAccess::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL OSetElementSetInfo::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicSetElement::getTypes(),BasicSetAccess::getTypes() );
}
uno::Sequence< sal_Int8 > SAL_CALL OSetElementSetInfo::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicSetElement::getImplementationId();
}
configapi::NodeAccess& OSetElementSetInfo::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeSetInfoAccess& OSetElementSetInfo::getNode()
{
return m_aAccessElement;
}
configapi::SetElement& OSetElementSetInfo::getElementClass()
{
return m_aAccessElement;
}
//==========================================================================
//= OSetElementTreeSetUpdate
//==========================================================================
// XInterface refcounting
void SAL_CALL OSetElementTreeSetUpdate::acquire( ) throw ()
{
BasicSetElement::acquire();
}
void SAL_CALL OSetElementTreeSetUpdate::release( ) throw ()
{
BasicSetElement::release();
}
// XInterface joining
uno::Any SAL_CALL OSetElementTreeSetUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicSetElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicSet::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL OSetElementTreeSetUpdate::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicSetElement::getTypes(),BasicSet::getTypes() );
}
uno::Sequence< sal_Int8 > SAL_CALL OSetElementTreeSetUpdate::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicSetElement::getImplementationId();
}
configapi::NodeAccess& OSetElementTreeSetUpdate::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeSetInfoAccess& OSetElementTreeSetUpdate::getNode()
{
return m_aAccessElement;
}
configapi::NodeTreeSetAccess* OSetElementTreeSetUpdate::maybeGetUpdateAccess()
{
return &m_aAccessElement;
}
configapi::SetElement& OSetElementTreeSetUpdate::getElementClass()
{
return m_aAccessElement;
}
//==========================================================================
//= OSetElementValueSetUpdate
//==========================================================================
// XInterface refcounting
void SAL_CALL OSetElementValueSetUpdate::acquire( ) throw ()
{
BasicSetElement::acquire();
}
void SAL_CALL OSetElementValueSetUpdate::release( ) throw ()
{
BasicSetElement::release();
}
// XInterface joining
uno::Any SAL_CALL OSetElementValueSetUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicSetElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicValueSet::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL OSetElementValueSetUpdate::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicSetElement::getTypes(),BasicValueSet::getTypes() );
}
uno::Sequence< sal_Int8 > SAL_CALL OSetElementValueSetUpdate::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicSetElement::getImplementationId();
}
configapi::NodeAccess& OSetElementValueSetUpdate::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeSetInfoAccess& OSetElementValueSetUpdate::getNode()
{
return m_aAccessElement;
}
configapi::NodeValueSetAccess* OSetElementValueSetUpdate::maybeGetUpdateAccess()
{
return &m_aAccessElement;
}
configapi::SetElement& OSetElementValueSetUpdate::getElementClass()
{
return m_aAccessElement;
}
//==========================================================================
//= ORootElementSetInfo
//==========================================================================
// XInterface refcounting
void SAL_CALL ORootElementSetInfo::acquire( ) throw ()
{
BasicRootElement::acquire();
}
void SAL_CALL ORootElementSetInfo::release( ) throw ()
{
BasicRootElement::release();
}
// XInterface joining
uno::Any SAL_CALL ORootElementSetInfo::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicRootElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicSetAccess::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL ORootElementSetInfo::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicRootElement::getTypes(),BasicSetAccess::getTypes() );
}
uno::Sequence< sal_Int8 > SAL_CALL ORootElementSetInfo::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicRootElement::getImplementationId();
}
configapi::NodeAccess& ORootElementSetInfo::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeSetInfoAccess& ORootElementSetInfo::getNode()
{
return m_aAccessElement;
}
configapi::RootElement& ORootElementSetInfo::getElementClass()
{
return m_aAccessElement;
}
//==========================================================================
//= ORootElementTreeSetUpdate
//==========================================================================
// XInterface refcounting
void SAL_CALL ORootElementTreeSetUpdate::acquire( ) throw ()
{
BasicUpdateElement::acquire();
}
void SAL_CALL ORootElementTreeSetUpdate::release( ) throw ()
{
BasicUpdateElement::release();
}
// XInterface joining
uno::Any SAL_CALL ORootElementTreeSetUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicUpdateElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicSet::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL ORootElementTreeSetUpdate::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicUpdateElement::getTypes(),BasicSet::getTypes() );
}
uno::Sequence< sal_Int8 > SAL_CALL ORootElementTreeSetUpdate::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicUpdateElement::getImplementationId();
}
configapi::NodeAccess& ORootElementTreeSetUpdate::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeSetInfoAccess& ORootElementTreeSetUpdate::getNode()
{
return m_aAccessElement;
}
configapi::NodeTreeSetAccess* ORootElementTreeSetUpdate::maybeGetUpdateAccess()
{
return &m_aAccessElement;
}
configapi::UpdateRootElement& ORootElementTreeSetUpdate::getElementClass()
{
return m_aAccessElement;
}
//==========================================================================
//= ORootElementValueSetUpdate
//==========================================================================
// XInterface refcounting
void SAL_CALL ORootElementValueSetUpdate::acquire( ) throw ()
{
BasicUpdateElement::acquire();
}
void SAL_CALL ORootElementValueSetUpdate::release( ) throw ()
{
BasicUpdateElement::release();
}
// XInterface joining
uno::Any SAL_CALL ORootElementValueSetUpdate::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicUpdateElement::queryInterface(rType);
if (!aRet.hasValue())
aRet = BasicValueSet::queryInterface(rType);
return aRet;
}
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL ORootElementValueSetUpdate::getTypes( ) throw (uno::RuntimeException )
{
return comphelper::concatSequences(BasicUpdateElement::getTypes(),BasicValueSet::getTypes() );
}
uno::Sequence< sal_Int8 > SAL_CALL ORootElementValueSetUpdate::getImplementationId( ) throw (uno::RuntimeException )
{
return BasicUpdateElement::getImplementationId();
}
configapi::NodeAccess& ORootElementValueSetUpdate::getNodeAccess()
{
return m_aAccessElement;
}
configapi::NodeSetInfoAccess& ORootElementValueSetUpdate::getNode()
{
return m_aAccessElement;
}
configapi::NodeValueSetAccess* ORootElementValueSetUpdate::maybeGetUpdateAccess()
{
return &m_aAccessElement;
}
configapi::UpdateRootElement& ORootElementValueSetUpdate::getElementClass()
{
return m_aAccessElement;
}
//........................................................................
} // namespace configmgr
//........................................................................
-358
View File
@@ -1,358 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_SETOBJECTS_HXX_
#define CONFIGMGR_API_SETOBJECTS_HXX_
#include "setaccess.hxx"
#include "setupdate.hxx"
#include "elementaccess.hxx"
#include "apiaccessobj.hxx"
//........................................................................
namespace configmgr
{
//........................................................................
//==========================================================================
//= Inner Set Instances
//==========================================================================
/** read-only access class for configuration nodes which are inner nodes and dynamic sets
*/
class OInnerSetInfo
: public BasicInnerElement
, public BasicSetAccess
{
public:
// Construction/Destruction
OInnerSetInfo(configapi::ApiTreeImpl& rTree, configuration::NodeRef const& aNode)
: m_aAccessElement(static_cast<css::container::XChild*>(this),rTree,aNode)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeSetInfoAccess& getNode();
virtual configapi::InnerElement& getElementClass();
private:
configapi::OInnerElement<configapi::NodeSetInfoAccess> m_aAccessElement;
};
/** updating access class for configuration nodes which are inner nodes and dynamic sets of complex types (trees)
*/
class OInnerTreeSetUpdate
: public BasicInnerElement
, public BasicSet
{
public:
// Construction/Destruction
OInnerTreeSetUpdate(configapi::ApiTreeImpl& rTree, configuration::NodeRef const& aNode)
: m_aAccessElement(static_cast<css::container::XChild*>(this),rTree,aNode)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeSetInfoAccess& getNode();
virtual configapi::NodeTreeSetAccess* maybeGetUpdateAccess();
virtual configapi::InnerElement& getElementClass();
private:
configapi::OInnerElement<configapi::NodeTreeSetAccess> m_aAccessElement;
};
/** update access class for configuration nodes which are inner nodes and dynamic sets of simple types (values)
*/
class OInnerValueSetUpdate
: public BasicInnerElement
, public BasicValueSet
{
public:
// Construction/Destruction
OInnerValueSetUpdate(configapi::ApiTreeImpl& rTree, configuration::NodeRef const& aNode)
: m_aAccessElement(static_cast<css::container::XChild*>(this),rTree,aNode)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeSetInfoAccess& getNode();
virtual configapi::NodeValueSetAccess* maybeGetUpdateAccess();
virtual configapi::InnerElement& getElementClass();
private:
configapi::OInnerElement<configapi::NodeValueSetAccess> m_aAccessElement;
};
//==========================================================================
//= Set Element Set Instances
//==========================================================================
/** read-only access class for configuration nodes which are set elements and dynamic sets
*/
class OSetElementSetInfo
: public BasicSetElement
, public BasicSetAccess
{
public:
// Construction/Destruction
OSetElementSetInfo(rtl::Reference< configuration::Tree > const& aTree, configapi::ApiProvider& rProvider, configapi::ApiTreeImpl* pParentTree = 0)
: m_aAccessElement(static_cast<css::container::XChild*>(this),aTree,rProvider,pParentTree)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeSetInfoAccess& getNode();
virtual configapi::SetElement& getElementClass();
private:
configapi::OSetElement<configapi::NodeSetInfoAccess> m_aAccessElement;
};
/** updating access class for configuration nodes which are set elements and dynamic sets of complex types (trees)
*/
class OSetElementTreeSetUpdate
: public BasicSetElement
, public BasicSet
{
public:
// Construction/Destruction
OSetElementTreeSetUpdate(rtl::Reference< configuration::Tree > const& aTree, configapi::ApiProvider& rProvider, configapi::ApiTreeImpl* pParentTree = 0)
: m_aAccessElement(static_cast<css::container::XChild*>(this),aTree,rProvider,pParentTree)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeSetInfoAccess& getNode();
virtual configapi::NodeTreeSetAccess* maybeGetUpdateAccess();
virtual configapi::SetElement& getElementClass();
private:
configapi::OSetElement<configapi::NodeTreeSetAccess> m_aAccessElement;
};
/** update access class for configuration nodes which are set elements and dynamic sets of simple types (values)
*/
class OSetElementValueSetUpdate
: public BasicSetElement
, public BasicValueSet
{
public:
// Construction/Destruction
OSetElementValueSetUpdate(rtl::Reference< configuration::Tree > const& aTree, configapi::ApiProvider& rProvider, configapi::ApiTreeImpl* pParentTree = 0)
: m_aAccessElement(static_cast<css::container::XChild*>(this),aTree,rProvider,pParentTree)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeSetInfoAccess& getNode();
virtual configapi::NodeValueSetAccess* maybeGetUpdateAccess();
virtual configapi::SetElement& getElementClass();
private:
configapi::OSetElement<configapi::NodeValueSetAccess> m_aAccessElement;
};
//==========================================================================
//= Root Element Set Instances
//==========================================================================
/** read-only access class for configuration nodes which are root nodes and dynamic sets
*/
class ORootElementSetInfo
: public BasicRootElement
, public BasicSetAccess
{
public:
// Construction/Destruction
ORootElementSetInfo(configapi::ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions)
: m_aAccessElement(static_cast<css::lang::XComponent*>(this),rProvider,aTree,_xOptions)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeSetInfoAccess& getNode();
virtual configapi::RootElement& getElementClass();
private:
configapi::OReadRootElement<configapi::NodeSetInfoAccess> m_aAccessElement;
};
/** updating access class for configuration nodes which are root nodes and dynamic sets of complex types (trees)
*/
class ORootElementTreeSetUpdate
: public BasicUpdateElement
, public BasicSet
{
public:
// Construction/Destruction
ORootElementTreeSetUpdate(configapi::ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions)
: m_aAccessElement(static_cast<css::lang::XComponent*>(this),rProvider,aTree, _xOptions)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeSetInfoAccess& getNode();
virtual configapi::NodeTreeSetAccess* maybeGetUpdateAccess();
virtual configapi::UpdateRootElement& getElementClass();
private:
configapi::OUpdateRootElement<configapi::NodeTreeSetAccess> m_aAccessElement;
};
/** update access class for configuration nodes which are root nodes and dynamic sets of simple types (values)
*/
class ORootElementValueSetUpdate
: public BasicUpdateElement
, public BasicValueSet
{
public:
// Construction/Destruction
ORootElementValueSetUpdate(configapi::ApiProvider& rProvider, rtl::Reference< configuration::Tree > const& aTree, vos::ORef< OOptions >const& _xOptions)
: m_aAccessElement(static_cast<css::lang::XComponent*>(this),rProvider,aTree,_xOptions)
{
}
// XInterface refcounting
void SAL_CALL acquire( ) throw ();
void SAL_CALL release( ) throw ();
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException );
// Base class implementation
virtual configapi::NodeAccess& getNodeAccess();
virtual configapi::NodeSetInfoAccess& getNode();
virtual configapi::NodeValueSetAccess* maybeGetUpdateAccess();
virtual configapi::UpdateRootElement& getElementClass();
private:
configapi::OUpdateRootElement<configapi::NodeValueSetAccess> m_aAccessElement;
};
//........................................................................
} // namespace configmgr
//........................................................................
#endif // CONFIGMGR_API_SETOBJECTS_HXX_
-241
View File
@@ -1,241 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "setupdate.hxx"
#include "accessimpl.hxx"
#include "updateimpl.hxx"
#include "apinodeupdate.hxx"
#include "apitypes.hxx"
#include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/typeprovider.hxx>
namespace configmgr
{
//////////////////////////////////////////////////////////////////////////////////
// classes BasicSet / BasicValueSet
//////////////////////////////////////////////////////////////////////////////////
// XInterface joining
//////////////////////////////////////////////////////////////////////////////////
uno::Any SAL_CALL BasicSet::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicSetAccess::queryInterface( rType );
if (!aRet.hasValue())
{
aRet = cppu::queryInterface(rType
, static_cast< css::container::XNameContainer *>(this)
, static_cast< css::container::XNameReplace *>(this)
, static_cast< css::beans::XPropertyWithState *>(this)
, static_cast< css::lang::XSingleServiceFactory *>(this)
);
}
return aRet;
}
//..............................................................................
uno::Any SAL_CALL BasicValueSet::queryInterface( uno::Type const& rType ) throw (uno::RuntimeException )
{
uno::Any aRet = BasicSetAccess::queryInterface( rType );
if (!aRet.hasValue())
{
aRet = cppu::queryInterface(rType
, static_cast< css::container::XNameContainer *>(this)
, static_cast< css::container::XNameReplace *>(this)
, static_cast< css::beans::XPropertyWithState *>(this)
);
}
return aRet;
}
// XTypeProvider joining
//////////////////////////////////////////////////////////////////////////////////
uno::Sequence< uno::Type > SAL_CALL BasicSet::getTypes( ) throw (uno::RuntimeException )
{
/*static ?*/
cppu::OTypeCollection aTypes(
configapi::getReferenceType(static_cast< css::container::XNameContainer *>(this)),
configapi::getReferenceType(static_cast< css::container::XNameReplace *>(this)),
configapi::getReferenceType(static_cast< css::beans::XPropertyWithState *>(this)),
configapi::getReferenceType(static_cast< css::lang::XSingleServiceFactory *>(this)),
BasicSetAccess::getTypes());
return aTypes.getTypes();
}
//..............................................................................
uno::Sequence< uno::Type > SAL_CALL BasicValueSet::getTypes( ) throw (uno::RuntimeException )
{
/*static ?*/
cppu::OTypeCollection aTypes(
configapi::getReferenceType(static_cast< css::container::XNameContainer *>(this)),
configapi::getReferenceType(static_cast< css::container::XNameReplace *>(this)),
configapi::getReferenceType(static_cast< css::beans::XPropertyWithState *>(this)),
BasicSetAccess::getTypes());
return aTypes.getTypes();
}
//uno::Sequence< sal_Int8 > SAL_CALL BasicSet::getImplementationId( ) throw (uno::RuntimeException ) = 0;
//uno::Sequence< sal_Int8 > SAL_CALL BasicValueSet::getImplementationId( ) throw (uno::RuntimeException ) = 0;
// safe write access
//////////////////////////////////////////////////////////////////////////////////
configapi::NodeTreeSetAccess& BasicSet::getSetNode()
{
configapi::NodeTreeSetAccess* pAccess = maybeGetUpdateAccess();
OSL_ENSURE(pAccess, "Write operation invoked on a read-only node access - failing with RuntimeException");
if (!pAccess)
{
throw uno::RuntimeException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: Invalid Object - internal update-interface missing.")),
static_cast< css::container::XNameReplace * >(this)
);
}
return *pAccess;
}
configapi::NodeValueSetAccess& BasicValueSet::getSetNode()
{
configapi::NodeValueSetAccess* pAccess = maybeGetUpdateAccess();
OSL_ENSURE(pAccess, "Write operation invoked on a read-only node access - failing with RuntimeException");
if (!pAccess)
{
throw uno::RuntimeException(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Configuration: Invalid Object - internal update-interface missing.")),
static_cast< css::container::XNameReplace* >(this)
);
}
return *pAccess;
}
// New Interface methods
// XNameReplace
//////////////////////////////////////////////////////////////////////////////////
void SAL_CALL BasicSet::replaceByName( const rtl::OUString& rName, const uno::Any& rElement )
throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implReplaceByName( getSetNode(), rName, rElement );
}
//..............................................................................
void SAL_CALL BasicValueSet::replaceByName( const rtl::OUString& rName, const uno::Any& rElement )
throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implReplaceByName( getSetNode(), rName, rElement );
}
// XNameContainer
//////////////////////////////////////////////////////////////////////////////////
void SAL_CALL BasicSet::insertByName( const rtl::OUString& rName, const uno::Any& rElement)
throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implInsertByName( getSetNode(), rName, rElement );
}
//..............................................................................
void SAL_CALL BasicValueSet::insertByName( const rtl::OUString& rName, const uno::Any& rElement)
throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implInsertByName( getSetNode(), rName, rElement );
}
//----------------------------------------------------------------------------------
void SAL_CALL BasicSet::removeByName( const rtl::OUString& rName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implRemoveByName( getSetNode(), rName );
}
//..............................................................................
void SAL_CALL BasicValueSet::removeByName( const rtl::OUString& rName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implRemoveByName( getSetNode(), rName );
}
// XPropertyWithState
//////////////////////////////////////////////////////////////////////////////////
css::beans::PropertyState SAL_CALL BasicSet::getStateAsProperty() throw (uno::RuntimeException)
{
return configapi::implGetStateAsProperty( getSetNode() );
}
//..............................................................................
css::beans::PropertyState SAL_CALL BasicValueSet::getStateAsProperty() throw (uno::RuntimeException)
{
return configapi::implGetStateAsProperty( getSetNode() );
}
//-----------------------------------------------------------------------------------
void SAL_CALL BasicSet::setToDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implSetToDefaultAsProperty( getSetNode() );
}
//..............................................................................
void SAL_CALL BasicValueSet::setToDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException)
{
configapi::implSetToDefaultAsProperty( getSetNode() );
}
//-----------------------------------------------------------------------------------
uno::Reference< uno::XInterface > SAL_CALL BasicSet::getDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException)
{
return configapi::implGetDefaultAsProperty( getSetNode() );
}
//..............................................................................
uno::Reference< uno::XInterface > SAL_CALL BasicValueSet::getDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException)
{
return configapi::implGetDefaultAsProperty( getSetNode() );
}
// XSingleServiceFactory (not for ValueSet)
//////////////////////////////////////////////////////////////////////////////////
uno::Reference< uno::XInterface > SAL_CALL BasicSet::createInstance( )
throw(uno::Exception, uno::RuntimeException)
{
return configapi::implCreateElement( getSetNode() );
}
//----------------------------------------------------------------------------------
uno::Reference< uno::XInterface > SAL_CALL BasicSet::createInstanceWithArguments( const uno::Sequence< uno::Any >& aArguments )
throw(uno::Exception, uno::RuntimeException)
{
return configapi::implCreateElement( getSetNode(), aArguments );
}
//-----------------------------------------------------------------------------------
} // namespace configmgr
-208
View File
@@ -1,208 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_SETUPDATE_HXX_
#define CONFIGMGR_API_SETUPDATE_HXX_
#include "setaccess.hxx"
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/beans/XPropertyWithState.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
//........................................................................
namespace configmgr
{
//........................................................................
namespace configapi { class NodeTreeSetAccess; class NodeValueSetAccess; }
//==========================================================================
//= BasicSet
//==========================================================================
/** base class for configuration nodes which are dynamic sets of complex types (trees)
*/
class BasicSet
: public BasicSetAccess
, public css::container::XNameContainer
, public css::beans::XPropertyWithState
, public css::lang::XSingleServiceFactory
{
protected:
// Destructors
virtual ~BasicSet() {}
public:
// Base class Interface methods
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ) = 0;
// XElementAccess forwarding
virtual uno::Type SAL_CALL getElementType( ) throw(uno::RuntimeException)
{ return BasicSetAccess::getElementType(); }
virtual sal_Bool SAL_CALL hasElements( ) throw(uno::RuntimeException)
{ return BasicSetAccess::hasElements(); }
// XNameAccess forwarding
virtual uno::Any SAL_CALL getByName( const rtl::OUString& aName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
{ return BasicSetAccess::getByName(aName); }
virtual uno::Sequence< rtl::OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException)
{ return BasicSetAccess::getElementNames(); }
virtual sal_Bool SAL_CALL hasByName( const rtl::OUString& aName ) throw(uno::RuntimeException)
{ return BasicSetAccess::hasByName(aName); }
// New Interface methods
// XNameReplace
virtual void SAL_CALL
replaceByName( const rtl::OUString& rName, const uno::Any& rElement )
throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
// XNameContainer
virtual void SAL_CALL
insertByName( const rtl::OUString& rName, const uno::Any& rElement)
throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException);
virtual void SAL_CALL
removeByName( const rtl::OUString& rName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
// XPropertyWithState
virtual css::beans::PropertyState SAL_CALL
getStateAsProperty( )
throw (uno::RuntimeException);
virtual void SAL_CALL
setToDefaultAsProperty( )
throw (css::lang::WrappedTargetException, uno::RuntimeException);
virtual uno::Reference< uno::XInterface > SAL_CALL
getDefaultAsProperty( )
throw (css::lang::WrappedTargetException, uno::RuntimeException);
// XSingleServiceFactory
virtual uno::Reference< uno::XInterface > SAL_CALL
createInstance( )
throw(uno::Exception, uno::RuntimeException);
virtual uno::Reference< uno::XInterface > SAL_CALL
createInstanceWithArguments( const uno::Sequence< uno::Any >& aArguments )
throw(uno::Exception, uno::RuntimeException);
protected:
configapi::NodeTreeSetAccess& getSetNode();
virtual configapi::NodeTreeSetAccess* maybeGetUpdateAccess() = 0;
};
//==========================================================================
//= BasicValueSet
//==========================================================================
/** class for configuration nodes which are dynamic sets of simple types (values)
*/
class BasicValueSet
: public BasicSetAccess
, public css::beans::XPropertyWithState
, public css::container::XNameContainer
{
protected:
// Destructors
virtual ~BasicValueSet() {}
public:
// Base class Interface methods
// XInterface joining
uno::Any SAL_CALL queryInterface( uno::Type const& rType ) throw (uno::RuntimeException );
// XTypeProvider joining
uno::Sequence< uno::Type > SAL_CALL getTypes( ) throw (uno::RuntimeException );
uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (uno::RuntimeException ) = 0;
// XElementAccess forwarding
virtual uno::Type SAL_CALL getElementType( ) throw(uno::RuntimeException)
{ return BasicSetAccess::getElementType(); }
virtual sal_Bool SAL_CALL hasElements( ) throw(uno::RuntimeException)
{ return BasicSetAccess::hasElements(); }
// XNameAccess forwarding
virtual uno::Any SAL_CALL getByName( const rtl::OUString& aName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException)
{ return BasicSetAccess::getByName(aName); }
virtual uno::Sequence< rtl::OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException)
{ return BasicSetAccess::getElementNames(); }
virtual sal_Bool SAL_CALL hasByName( const rtl::OUString& aName ) throw(uno::RuntimeException)
{ return BasicSetAccess::hasByName(aName); }
// New Interface methods
// XNameReplace
virtual void SAL_CALL
replaceByName( const rtl::OUString& rName, const uno::Any& rElement )
throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
// XNameContainer
virtual void SAL_CALL
insertByName( const rtl::OUString& rName, const uno::Any& rElement)
throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException);
virtual void SAL_CALL
removeByName( const rtl::OUString& rName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
// XPropertyWithState
virtual css::beans::PropertyState SAL_CALL
getStateAsProperty( )
throw (uno::RuntimeException);
virtual void SAL_CALL
setToDefaultAsProperty( )
throw (css::lang::WrappedTargetException, uno::RuntimeException);
virtual uno::Reference< uno::XInterface > SAL_CALL
getDefaultAsProperty( )
throw (css::lang::WrappedTargetException, uno::RuntimeException);
protected:
configapi::NodeValueSetAccess& getSetNode();
virtual configapi::NodeValueSetAccess* maybeGetUpdateAccess() = 0;
};
//........................................................................
} // namespace configmgr
//........................................................................
#endif // CONFIGMGR_API_VALUESETACCESS_HXX_
-283
View File
@@ -1,283 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "translatechanges.hxx"
#include "noderef.hxx"
#include "nodechange.hxx"
#include "nodechangeinfo.hxx"
#include "apifactory.hxx"
namespace configmgr
{
// ---------------------------------------------------------------------------------------------------
namespace css = ::com::sun::star;
namespace uno = css::uno;
namespace lang = css::lang;
namespace util = css::util;
namespace beans = css::beans;
namespace container = css::container;
// ---------------------------------------------------------------------------------------------------
namespace configuration
{
class NodeChange;
class NodeChanges;
class NodeRef;
class NodeID;
}
// ---------------------------------------------------------------------------------------------------
namespace configapi
{
// ---------------------------------------------------------------------------------------------------
//interpreting NodeChanges
// resolve the relative path from a given base to the changed node
bool resolveChangeLocation(configuration::RelativePath& aPath, configuration::NodeChangeLocation const& aChange, rtl::Reference< configuration::Tree > const& aBaseTree, configuration::NodeRef const& aBaseNode)
{
OSL_ENSURE(aChange.isValidLocation(), "Trying to resolve against change location that wasn't set up properly");
namespace Path = configuration::Path;
rtl::Reference< configuration::Tree > aChangeBaseTree = aChange.getBaseTree();
configuration::AbsolutePath aOuterBasePath = aBaseTree->getAbsolutePath(aBaseNode);
configuration::AbsolutePath aChangeBasePath = aChangeBaseTree->getAbsolutePath(aChange.getBaseNode());
std::vector<configuration::Path::Component>::const_reverse_iterator aChangeIt = aChangeBasePath.begin(), aChangeEnd = aChangeBasePath.end();
std::vector<configuration::Path::Component>::const_reverse_iterator aOuterIt = aOuterBasePath.begin(), aOuterEnd = aOuterBasePath.end();
// First by resolve the base node pathes
while (aOuterIt != aOuterEnd && aChangeIt != aChangeEnd)
{
if ( ! Path::matches(*aOuterIt,*aChangeIt) ) return false; // mismatch
++aOuterIt;
++aChangeIt;
}
// Next consider the stored accessor
if (aChangeIt != aChangeEnd) // stepping outward - prepend
{
Path::Rep aRemaining(aChangeIt, aChangeEnd);
aPath = configuration::RelativePath(aRemaining).compose(aChange.getAccessor());
}
else if (aOuterIt == aOuterEnd) // exact match outside
{
aPath = aChange.getAccessor();
}
else //(aChangeIt == aChangeEnd) but outer left
{
configuration::RelativePath aAccessor = aChange.getAccessor();
aChangeIt = aAccessor.begin();
aChangeEnd = aAccessor.end();
// resolve the outer path against the change accessor
while (aOuterIt != aOuterEnd && aChangeIt != aChangeEnd)
{
if ( ! Path::matches(*aOuterIt,*aChangeIt) ) return false; // mismatch
++aOuterIt;
++aChangeIt;
}
if (aOuterIt == aOuterEnd)
{
Path::Rep aRemaining(aChangeIt, aChangeEnd);
aPath = configuration::RelativePath( aRemaining );
}
}
return (aOuterIt == aOuterEnd); // resolved completely and assigned ??
}
// ---------------------------------------------------------------------------------------------------
// change path and base settings to start from the given base
bool rebaseChange(configuration::NodeChangeLocation& aChange, rtl::Reference< configuration::Tree > const& _aBaseTreeRef)
{
return rebaseChange(aChange,_aBaseTreeRef,_aBaseTreeRef->getRootNode());
}
bool rebaseChange(configuration::NodeChangeLocation& aChange, rtl::Reference< configuration::Tree > const& _aBaseTreeRef, configuration::NodeRef const& aBaseNode)
{
OSL_ENSURE(aChange.isValidLocation(), "Trying to rebase change location that wasn't set up properly");
rtl::Reference< configuration::Tree > aBaseTree(_aBaseTreeRef);
configuration::RelativePath aNewPath;
if (resolveChangeLocation(aNewPath,aChange,aBaseTree,aBaseNode))
{
aChange.setBase( aBaseTree, aBaseNode);
aChange.setAccessor( aNewPath );
return true;
}
else
return false;
}
// ---------------------------------------------------------------------------------------------------
// resolve non-uno elements to Uno Objects
bool resolveUnoObjects(UnoChange& aUnoChange, configuration::NodeChangeData const& aChange,
Factory& rFactory)
{
if (aChange.isSetChange())
{
//Check we have ElementTree
if ((aChange.element.newValue == NULL) &&
(aChange.element.oldValue == NULL))
{
if( ( aChange.unoData.newValue.getValue()!=NULL) ||
( aChange.unoData.newValue.getValue()!=NULL))
{
return true;
}
else return false;
}
//Check if complex or simple type
rtl::Reference< configuration::Tree > aTree = aChange.isRemoveSetChange()?
aChange.getOldElementTree():
aChange.getNewElementTree();
configuration::NodeRef aNodeRef = aTree->getRootNode();
if (configuration::isStructuralNode(aTree, aNodeRef))
{
uno::Reference<uno::XInterface> aNewUnoObject = rFactory.findUnoElement(aChange.getNewElementNodeID());
uno::Reference<uno::XInterface> aOldUnoObject = rFactory.findUnoElement(aChange.getOldElementNodeID());
bool bFound = aNewUnoObject.is() || aOldUnoObject.is();
aUnoChange.newValue <<= aNewUnoObject;
aUnoChange.oldValue <<= aOldUnoObject;
return bFound;
}
else
{
aUnoChange.newValue = configuration::getSimpleElementValue(aTree, aNodeRef);
if (aChange.isReplaceSetChange() )
{
rtl::Reference< configuration::Tree > aOldTree = aChange.getOldElementTree();
aNodeRef = aOldTree->getRootNode();
OSL_ENSURE(!configuration::isStructuralNode(aOldTree, aNodeRef), "resolveUnoObject types mismatch");
aUnoChange.oldValue = configuration::getSimpleElementValue(aOldTree, aNodeRef);
}
bool bFound = aUnoChange.newValue.hasValue() || aUnoChange.oldValue.hasValue();
return bFound;
}
}
else if (aChange.isValueChange())
{
aUnoChange.newValue = aChange.unoData.newValue;
aUnoChange.oldValue = aChange.unoData.oldValue;
return true;
}
else
{
return false;
}
}
// ---------------------------------------------------------------------------------------------------
// resolve non-uno elements to Uno Objects inplace
bool resolveToUno(configuration::NodeChangeData& aChange, Factory& rFactory)
{
struct UnoChange aUnoChange;
if (resolveUnoObjects(aUnoChange,aChange, rFactory))
{
aChange.unoData.newValue = aUnoChange.newValue;
aChange.unoData.oldValue = aUnoChange.oldValue;
return true;
}
else
return false;
}
// ---------------------------------------------------------------------------------------------------
/// fill a change info from a NodeChangeInfo
void fillChange(util::ElementChange& rChange, configuration::NodeChangeInformation const& aInfo, rtl::Reference< configuration::Tree > const& aBaseTree, Factory& rFactory)
{
fillChange(rChange,aInfo,aBaseTree,aBaseTree->getRootNode(),rFactory);
}
/// fill a change info from a NodeChangeInfo
void fillChange(util::ElementChange& rChange, configuration::NodeChangeInformation const& aInfo, rtl::Reference< configuration::Tree > const& aBaseTree, configuration::NodeRef const& aBaseNode, Factory& rFactory)
{
configuration::RelativePath aRelativePath;
if (!resolveChangeLocation(aRelativePath, aInfo.location, aBaseTree, aBaseNode))
OSL_ENSURE(false, "WARNING: Change is not part of the given Tree");
UnoChange aUnoChange;
if (!resolveUnoObjects(aUnoChange, aInfo.change, rFactory))
OSL_ENSURE(false, "WARNING: Cannot find out old/new UNO objects involved in change");
rChange.Accessor <<= aRelativePath.toString();
rChange.Element = aUnoChange.newValue;
rChange.ReplacedElement = aUnoChange.oldValue;
}
// ---------------------------------------------------------------------------------------------------
/// fill a change info from a NodeChangeInfo (base,path and uno objects are assumed to be resolved already)
void fillChangeFromResolved(util::ElementChange& rChange, configuration::NodeChangeInformation const& aInfo)
{
rChange.Accessor <<= aInfo.location.getAccessor().toString();
rChange.Element = aInfo.change.unoData.newValue;
rChange.ReplacedElement = aInfo.change.unoData.oldValue;
}
// ---------------------------------------------------------------------------------------------------
/// fill a event from a NodeChangeInfo (uno objects are assumed to be resolved already)
bool fillEventDataFromResolved(container::ContainerEvent& rEvent, configuration::NodeChangeInformation const& aInfo)
{
rEvent.Accessor <<= aInfo.location.getAccessor().getLocalName().getName();
rEvent.Element = aInfo.change.unoData.newValue;
rEvent.ReplacedElement = aInfo.change.unoData.oldValue;
return !aInfo.isEmptyChange();
}
// ---------------------------------------------------------------------------------------------------
/// fill a event from a NodeChangeInfo(uno objects are assumed to be resolved already)
bool fillEventDataFromResolved(beans::PropertyChangeEvent& rEvent, configuration::NodeChangeInformation const& aInfo, bool bMore)
{
if (!aInfo.isValueChange())
return false;
rEvent.PropertyName = aInfo.location.getAccessor().getLocalName().getName();
rEvent.NewValue = aInfo.change.unoData.newValue;
rEvent.OldValue = aInfo.change.unoData.oldValue;
rEvent.PropertyHandle = -1;
rEvent.Further = bMore;
return !aInfo.isEmptyChange();
}
// ---------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------
}
// ---------------------------------------------------------------------------------------------------
}
-117
View File
@@ -1,117 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_TRANSLATECHANGES_HXX_
#define CONFIGMGR_API_TRANSLATECHANGES_HXX_
#include <com/sun/star/beans/XPropertyChangeListener.hpp>
#include <com/sun/star/beans/XVetoableChangeListener.hpp>
#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
#include <com/sun/star/container/XContainerListener.hpp>
#include <com/sun/star/util/XChangesListener.hpp>
#include "rtl/ref.hxx"
namespace configmgr
{
// ---------------------------------------------------------------------------------------------------
namespace css = ::com::sun::star;
namespace uno = css::uno;
namespace lang = css::lang;
namespace util = css::util;
namespace beans = css::beans;
namespace container = css::container;
// ---------------------------------------------------------------------------------------------------
namespace configuration
{
class NodeChangeInformation;
class NodeChangeData;
class NodeChangeLocation;
//class NodeChange;
//class NodeChanges;
class Tree;
class NodeRef;
class NodeID;
class RelativePath;
}
// ---------------------------------------------------------------------------------------------------
namespace configapi
{
class NotifierImpl;
class Factory;
struct UnoChange { uno::Any newValue, oldValue; };
//interpreting NodeChanges
// resolve the relative path from a given base node to the changed node
bool resolveChangeLocation( configuration::RelativePath& aPath,
configuration::NodeChangeLocation const& aChange,
rtl::Reference< configuration::Tree > const& aBaseTree,
configuration::NodeRef const& aBaseNode);
// change path and base settings to start from the given base tree (root)
bool rebaseChange( configuration::NodeChangeLocation& aChange,
rtl::Reference< configuration::Tree > const& _aBaseTreeRef);
// change path and base settings to start from the given base node
bool rebaseChange( configuration::NodeChangeLocation& aChange,
rtl::Reference< configuration::Tree > const& _aBaseTreeRef,
configuration::NodeRef const& aBaseNode);
// resolve non-uno elements to Uno Objects
bool resolveUnoObjects(UnoChange& aUnoChange,
configuration::NodeChangeData const& aChange,
Factory& rFactory);
// resolve non-uno elements to Uno Objects inplace
bool resolveToUno(configuration::NodeChangeData& aChange,
Factory& rFactory);
// building events
/// fill a change info from a NodeChangeInfo
void fillChange(util::ElementChange& rChange,
configuration::NodeChangeInformation const& aInfo,
rtl::Reference< configuration::Tree > const& aBaseTree,
Factory& rFactory);
/// fill a change info from a NodeChangeInfo
void fillChange(util::ElementChange& rChange,
configuration::NodeChangeInformation const& aInfo,
rtl::Reference< configuration::Tree > const& aBaseTree,
configuration::NodeRef const& aBaseNode,
Factory& rFactory);
/// fill a change info from a NodeChangeInfo (base,path and uno objects are assumed to be resolved already)
void fillChangeFromResolved(util::ElementChange& rChange, configuration::NodeChangeInformation const& aInfo);
/// fill a event from a NodeChangeInfo (uno objects are assumed to be resolved already)
bool fillEventDataFromResolved(container::ContainerEvent& rEvent, configuration::NodeChangeInformation const& aInfo);
/// fill a event from a NodeChangeInfo(uno objects are assumed to be resolved already) - returns false if this isn't a property change
bool fillEventDataFromResolved(beans::PropertyChangeEvent& rEvent, configuration::NodeChangeInformation const& aInfo, bool bMore);
}
// ---------------------------------------------------------------------------------------------------
}
#endif // CONFIGMGR_API_TRANSLATECHANGES_HXX_
-93
View File
@@ -1,93 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 <stdio.h>
#include "treeiterators.hxx"
#include "apitypes.hxx"
#include "configpath.hxx"
#include "attributes.hxx"
#include "valueref.hxx"
#include "propertyinfohelper.hxx"
// .......................................................................
namespace configmgr
{
// .......................................................................
namespace configapi
{
// ===================================================================
// = CollectNodeNames
// ===================================================================
// -------------------------------------------------------------------
CollectPropertyInfo::Result CollectNodeNames::handle(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode)
{
m_aList.push_back(aTree->getSimpleNodeName(aNode.getOffset()));
return CONTINUE;
}
// -------------------------------------------------------------------
CollectPropertyInfo::Result CollectNodeNames::handle(rtl::Reference< configuration::Tree > const&, configuration::ValueRef const& aNode)
{
m_aList.push_back(aNode.m_sNodeName);
return CONTINUE;
}
// ===================================================================
// = CollectPropertyInfo
// ===================================================================
// -------------------------------------------------------------------
CollectNodeNames::Result CollectPropertyInfo::handle(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode)
{
rtl::OUString aName = aTree->getSimpleNodeName(aNode.getOffset());
node::Attributes aAttributes = aTree->getAttributes(aNode);
uno::Type aApiType = getUnoInterfaceType();
m_aList.push_back( helperMakeProperty(aName,aAttributes,aApiType,aTree->hasNodeDefault(aNode)) );
return CONTINUE;
}
// -------------------------------------------------------------------
CollectNodeNames::Result CollectPropertyInfo::handle(rtl::Reference< configuration::Tree > const& aTree, configuration::ValueRef const& aNode)
{
rtl::OUString aName = aNode.m_sNodeName;
node::Attributes aAttributes = aTree->getAttributes(aNode);
uno::Type aApiType = aTree->getUnoType(aNode);
m_aList.push_back( helperMakeProperty(aName,aAttributes,aApiType,aTree->hasNodeDefault(aNode)) );
return CONTINUE;
}
// .......................................................................
} // namespace configapi
// .......................................................................
} // namespace configmgr
// .......................................................................
-85
View File
@@ -1,85 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_TREEITERATORS_HXX_
#define CONFIGMGR_TREEITERATORS_HXX_
#include "tree.hxx"
#include <com/sun/star/beans/Property.hpp>
#include <rtl/ustring.hxx>
#ifndef INCLUDED_VECTOR
#include <vector>
#define INCLUDED_VECTOR
#endif
// .......................................................................
namespace configmgr
{
// .......................................................................
namespace configapi
{
// ===================================================================
// = CollectNodeNames
// ===================================================================
class CollectNodeNames : public configuration::NodeVisitor
{
protected:
std::vector<rtl::OUString> m_aList;
public:
CollectNodeNames() { }
virtual Result handle(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode); // NodeVisitor
virtual Result handle(rtl::Reference< configuration::Tree > const& aTree, configuration::ValueRef const& aNode); // NodeVisitor
std::vector<rtl::OUString> const& list() const { return m_aList; }
};
// ===================================================================
// = CollectPropertyInfo
// ===================================================================
class CollectPropertyInfo : public configuration::NodeVisitor
{
protected:
std::vector<com::sun::star::beans::Property> m_aList;
public:
CollectPropertyInfo() { }
virtual Result handle(rtl::Reference< configuration::Tree > const& aTree, configuration::NodeRef const& aNode); // NodeVisitor
virtual Result handle(rtl::Reference< configuration::Tree > const& aTree, configuration::ValueRef const& aNode); // NodeVisitor
std::vector<com::sun::star::beans::Property> const& list() const { return m_aList; }
};
}
// .......................................................................
} // namespace configmgr
// .......................................................................
#endif // _CONFIGMGR_TREEITERATORS_HXX_
-647
View File
@@ -1,647 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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 "updateimpl.hxx"
#include "accessimpl.hxx"
#include "apinodeaccess.hxx"
#include "apinodeupdate.hxx"
#include "noderef.hxx"
#include "valueref.hxx"
#include "nodechange.hxx"
#include "configset.hxx"
#include "configgroup.hxx"
#include "confignotifier.hxx"
#include "broadcaster.hxx"
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/beans/PropertyVetoException.hpp>
#include <osl/diagnose.h>
namespace configmgr
{
namespace configapi
{
//-----------------------------------------------------------------------------------
namespace lang = css::lang;
namespace util = css::util;
namespace container = css::container;
// Interface methods
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// Update methods
//-----------------------------------------------------------------------------------
// XNameReplace
//-----------------------------------------------------------------------------------
void implReplaceByName(NodeGroupAccess& rNode, const rtl::OUString& sName, const uno::Any& rElement )
throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
{
try
{
GuardedNodeUpdate<NodeGroupAccess> lock( rNode );
rtl::Reference< configuration::Tree > const aTree( lock.getTree() );
configuration::NodeRef const aNode( lock.getNode() );
rtl::OUString aChildName = configuration::validateChildName(sName,aTree,aNode);
configuration::ValueRef aChildValue( aTree->getChildValue(aNode, aChildName) );
if (!aChildValue.isValid())
{
if (aTree->hasChildNode(aNode, aChildName))
{
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Value. Node '") );
sMessage += sName;
sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value.") );
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw lang::IllegalArgumentException( sMessage, xContext, 2 );
}
else
{
OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing child node not found by implementation");
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Value. Value '") );
sMessage += sName;
sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
sMessage += aTree->getAbsolutePath(aNode).toString();
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw container::NoSuchElementException( sMessage, xContext );
}
}
configuration::NodeChange aChange = lock.getNodeUpdater().validateSetValue(aChildValue, rElement);
if (aChange.test().isChange())
{
Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true));
// lock.clearForBroadcast();
aSender.queryConstraints(aChange);
aTree->integrate(aChange, aNode, true);
lock.clearForBroadcast();
aSender.notifyListeners(aChange);
}
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Value: ") );
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw container::NoSuchElementException( e.message(), xContext );
}
catch (configuration::TypeMismatch& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.illegalArgument(2);
}
catch (configuration::ConstraintViolation& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.illegalArgument(2);
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
catch (css::beans::PropertyVetoException& ex)
{
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Value. Change was Vetoed: ") );
throw lang::WrappedTargetException( sMessage += ex.Message, rNode.getUnoInstance(), uno::makeAny(ex) );
}
}
//-----------------------------------------------------------------------------------
void implReplaceByName(NodeTreeSetAccess& rNode, const rtl::OUString& sName, const uno::Any& rElement )
throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
{
try
{
GuardedNodeUpdate<NodeTreeSetAccess> lock( rNode );
rtl::Reference< configuration::Tree > const aTree( lock.getTree() );
configuration::NodeRef const aNode( lock.getNode() );
rtl::OUString aChildName = configuration::validateElementName(sName,aTree,aNode);
rtl::Reference< configuration::ElementTree > aElement( aTree->getElement(aNode,aChildName) );
if (!aElement.is())
{
OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Set element not found by implementation");
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element. Element '") );
sMessage += sName;
sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") );
sMessage += aTree->getAbsolutePath(aNode).toString();
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw container::NoSuchElementException( sMessage, xContext );
}
rtl::Reference< configuration::ElementTree > aElementTree = configapi::extractElementTree(rNode.getFactory(), rElement, rNode.getElementInfo());
if (!aElementTree.is())
{
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element: ") );
sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Replacing object was not created from this set's template") );
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw lang::IllegalArgumentException( sMessage, xContext, 2 );
}
configuration::NodeChange aChange = lock.getNodeUpdater().validateReplaceElement( aElement, aElementTree );
if (aChange.test().isChange())
{
Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true));
//aSender.queryConstraints(aChange); - N/A: no external constraints on set children possible
aTree->integrate(aChange, aNode, true);
attachSetElement(rNode, aElementTree);
lock.clearForBroadcast();
aSender.notifyListeners(aChange);
}
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element: ") );
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw container::NoSuchElementException( e.message(), xContext );
}
catch (configuration::TypeMismatch& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.illegalArgument(2);
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
}
//-----------------------------------------------------------------------------------
void implReplaceByName(NodeValueSetAccess& rNode, const rtl::OUString& sName, const uno::Any& rElement )
throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
{
try
{
GuardedNodeUpdate<NodeValueSetAccess> lock( rNode );
rtl::Reference< configuration::Tree > const aTree( lock.getTree() );
configuration::NodeRef const aNode( lock.getNode() );
rtl::OUString aChildName = configuration::validateElementName(sName,aTree,aNode);
rtl::Reference< configuration::ElementTree > aElement( aTree->getElement(aNode,aChildName) );
if (!aElement.is())
{
OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Set element not found by implementation");
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element. Element '") );
sMessage += sName;
sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") );
sMessage += aTree->getAbsolutePath(aNode).toString();
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw container::NoSuchElementException( sMessage, xContext );
}
configuration::NodeChange aChange = lock.getNodeUpdater().validateReplaceElement( aElement, rElement );
if (aChange.test().isChange())
{
Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true));
//aSender.queryConstraints(aChange); - N/A: no external constraints on set children possible
aTree->integrate(aChange, aNode, true);
lock.clearForBroadcast();
aSender.notifyListeners(aChange);
}
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element: ") );
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw container::NoSuchElementException( e.message(), xContext );
}
catch (configuration::TypeMismatch& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.illegalArgument(2);
}
catch (configuration::ConstraintViolation& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.illegalArgument(2);
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
}
// XNameContainer
//-----------------------------------------------------------------------------------
void implInsertByName(NodeTreeSetAccess& rNode, const rtl::OUString& sName, const uno::Any& rElement)
throw(lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException)
{
try
{
GuardedNodeUpdate<NodeTreeSetAccess> lock( rNode );
rtl::Reference< configuration::Tree > const aTree( lock.getTree() );
configuration::NodeRef const aNode( lock.getNode() );
rtl::OUString aChildName = configuration::validateElementName(sName,aTree,aNode);
if( aTree->hasElement(aNode,aChildName) )
{
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot insert into Set. Element '") );
sMessage += sName;
sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is already present in Set ") );
sMessage += aTree->getAbsolutePath(aNode).toString();
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw container::ElementExistException( sMessage, xContext );
}
OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Set element not found by implementation");
rtl::Reference< configuration::ElementTree > aElementTree = configapi::extractElementTree(rNode.getFactory(), rElement, rNode.getElementInfo());
if (!aElementTree.is())
{
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot insert into Set: ") );
sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Inserted object was not created from this set's template") );
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw lang::IllegalArgumentException( sMessage, xContext, 2 );
}
configuration::NodeChange aChange = lock.getNodeUpdater().validateInsertElement(aChildName, aElementTree);
aChange.test(); // make sure old values are set up correctly
OSL_ENSURE(aChange.isChange(), "ERROR: Adding a node validated as empty change");
Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true));
//aSender.queryConstraints(); - N/A: no external constraints on set children possible
aTree->integrate(aChange, aNode, true);
attachSetElement(rNode, aElementTree);
lock.clearForBroadcast();
aSender.notifyListeners(aChange);
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.illegalArgument( 1 );
}
catch (configuration::TypeMismatch& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.illegalArgument(2);
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
}
//-----------------------------------------------------------------------------------
void implInsertByName(NodeValueSetAccess& rNode, const rtl::OUString& sName, const uno::Any& rElement)
throw(lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException)
{
try
{
GuardedNodeUpdate<NodeValueSetAccess> lock( rNode );
rtl::Reference< configuration::Tree > const aTree( lock.getTree() );
configuration::NodeRef const aNode( lock.getNode() );
rtl::OUString aChildName = configuration::validateElementName(sName,aTree,aNode);
if( aTree->hasElement(aNode,aChildName) )
{
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot insert into Set. Element '") );
sMessage += sName;
sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' is already present in Set ") );
sMessage += aTree->getAbsolutePath(aNode).toString();
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw container::ElementExistException( sMessage, xContext );
}
OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Set element not found by implementation");
configuration::NodeChange aChange = lock.getNodeUpdater().validateInsertElement(aChildName, rElement);
aChange.test(); // make sure old values are set up correctly
OSL_ENSURE(aChange.isChange(), "ERROR: Adding a node validated as empty change");
Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true));
//aSender.queryConstraints(); - N/A: no external constraints on set children possible
aTree->integrate(aChange, aNode, true);
lock.clearForBroadcast();
aSender.notifyListeners(aChange);
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.illegalArgument( 1 );
}
catch (configuration::TypeMismatch& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.illegalArgument(2);
}
catch (configuration::ConstraintViolation& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.illegalArgument(2);
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
}
//-----------------------------------------------------------------------------------
void implRemoveByName(NodeTreeSetAccess& rNode, const rtl::OUString& sName )
throw(css::container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
{
try
{
GuardedNodeUpdate<NodeTreeSetAccess> lock( rNode );
rtl::Reference< configuration::Tree > const aTree( lock.getTree() );
configuration::NodeRef const aNode( lock.getNode() );
rtl::OUString aChildName = configuration::validateElementName(sName,aTree,aNode);
rtl::Reference< configuration::ElementTree > aElement( aTree->getElement(aNode,aChildName) );
if (!aElement.is())
{
OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Set element not found by implementation");
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element. Element '") );
sMessage += sName;
sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") );
sMessage += aTree->getAbsolutePath(aNode).toString();
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw container::NoSuchElementException( sMessage, xContext );
}
configuration::NodeChange aChange = lock.getNodeUpdater().validateRemoveElement(aElement);
aChange.test(); // make sure old values are set up correctly
OSL_ENSURE(aChange.isChange(), "ERROR: Removing a node validated as empty change");
Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true));
//aSender.queryConstraints(); - N/A: no external constraints on set children possible
aTree->integrate(aChange, aNode, true);
detachSetElement(rNode.getFactory(), aElement);
lock.clearForBroadcast();
aSender.notifyListeners(aChange);
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element: ") );
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw container::NoSuchElementException( sMessage += e.message(), xContext );
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
}
//-----------------------------------------------------------------------------------
void implRemoveByName(NodeValueSetAccess& rNode, const rtl::OUString& sName )
throw(css::container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
{
try
{
GuardedNodeUpdate<NodeValueSetAccess> lock( rNode );
rtl::Reference< configuration::Tree > const aTree( lock.getTree() );
configuration::NodeRef const aNode( lock.getNode() );
rtl::OUString aChildName = configuration::validateElementName(sName,aTree,aNode);
rtl::Reference< configuration::ElementTree > aElement = aTree->getElement(aNode,aChildName);
if (!aElement.is())
{
OSL_ENSURE(!configuration::hasChildOrElement(aTree,aNode,aChildName),"ERROR: Configuration: Existing Set element not found by implementation");
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element. Element '") );
sMessage += sName;
sMessage += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") );
sMessage += aTree->getAbsolutePath(aNode).toString();
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw container::NoSuchElementException( sMessage, xContext );
}
configuration::NodeChange aChange = lock.getNodeUpdater().validateRemoveElement(aElement);
aChange.test(); // make sure old values are set up correctly
OSL_ENSURE(aChange.isChange(), "ERROR: Removing a node validated as empty change");
Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,true));
//aSender.queryConstraints(); - N/A: no external constraints on set children possible
aTree->integrate(aChange, aNode, true);
lock.clearForBroadcast();
aSender.notifyListeners(aChange);
}
catch (configuration::InvalidName& ex)
{
ExceptionMapper e(ex);
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element: ") );
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw container::NoSuchElementException( sMessage += e.message(), xContext );
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
}
//-----------------------------------------------------------------------------------
// XPropertyWithState
//-----------------------------------------------------------------------------------
void implSetToDefaultAsProperty(NodeSetAccess& rNode)
throw (css::lang::WrappedTargetException, uno::RuntimeException)
{
try
{
GuardedNodeUpdate<NodeSetAccess> lock( rNode );
rtl::Reference< configuration::Tree > const aTree( lock.getTree() );
configuration::NodeRef const aNode( lock.getNode() );
configuration::SetDefaulter aDefaulter = lock.getNodeDefaulter();
configuration::NodeChange aChange = aDefaulter.validateSetToDefaultState();
const bool bLocal = true;
if (aChange.test().isChange() )
{
Broadcaster aSender(rNode.getNotifier().makeBroadcaster(aChange,bLocal));
aSender.queryConstraints(aChange);
aTree->integrate(aChange, aNode, bLocal);
lock.clearForBroadcast();
aSender.notifyListeners(aChange);
}
}
catch (configuration::ConstraintViolation & ex)
{
ExceptionMapper e(ex);
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default: ") );
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw lang::WrappedTargetException( sMessage += e.message(), xContext, uno::Any());
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
catch (lang::WrappedTargetException& ) { throw;}
catch (uno::RuntimeException& ) { throw;}
catch (uno::Exception& e)
{
rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default: ") );
uno::Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw lang::WrappedTargetException( sMessage += e.Message, xContext, uno::makeAny(e));
}
}
//-----------------------------------------------------------------------------------
// XSingleServiceFactory
//-----------------------------------------------------------------------------------
uno::Reference< uno::XInterface > implCreateElement(NodeTreeSetAccess& rNode )
throw(uno::Exception, uno::RuntimeException)
{
uno::Reference< uno::XInterface > xRet;
try
{
GuardedNodeData<NodeSetAccess> lock( rNode ); // no provider lock needed ? => if template lock is separate - OK
rtl::Reference< configuration::ElementTree > aNewElement( rNode.getElementFactory().instantiateTemplate(rNode.getElementInfo()) );
uno::Any aAny = configapi::makeElement( rNode.getFactory(), aNewElement );
if (!(aAny >>= xRet)) // no parent available
{
OSL_ASSERT(!xRet.is()); // make sure we return NULL
OSL_ENSURE(!aAny.hasValue(), "configmgr: BasicSetElement::getParent: could not extract parent - node is not an object");
}
}
catch (configuration::Exception& ex)
{
ExceptionMapper e(ex);
e.setContext( rNode.getUnoInstance() );
e.unhandled();
}
return xRet;
}
//-----------------------------------------------------------------------------------
uno::Reference< uno::XInterface > implCreateElement(NodeTreeSetAccess& rNode, const uno::Sequence< uno::Any >& aArguments )
throw(uno::Exception, uno::RuntimeException)
{
{ (void)aArguments; }
OSL_ENSURE(aArguments.getLength() == 0, "ConfigurationContainer: createInstance: Arguments not supported - ignoring ...");
return implCreateElement(rNode);
}
//-----------------------------------------------------------------------------------
} // namespace configapi
} // namespace configmgr
-95
View File
@@ -1,95 +0,0 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* 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.
*
************************************************************************/
#ifndef CONFIGMGR_API_BASEUPDATEIMPL_HXX_
#define CONFIGMGR_API_BASEUPDATEIMPL_HXX_
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/beans/XPropertyWithState.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
namespace configmgr
{
namespace css = ::com::sun::star;
namespace uno = ::com::sun::star::uno;
/* implementations of the interfaces supported by a (parent) node
within the configuration tree.
(updating operation)
*/
namespace configapi
{
class NodeSetAccess;
class NodeTreeSetAccess;
class NodeValueSetAccess;
class NodeGroupAccess;
// XNameReplace
//---------------------------------------------------------------------
void implReplaceByName(NodeGroupAccess& rNode, const rtl::OUString& rName, const uno::Any& rElement )
throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
void implReplaceByName(NodeTreeSetAccess& rNode, const rtl::OUString& rName, const uno::Any& rElement )
throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
void implReplaceByName(NodeValueSetAccess& rNode, const rtl::OUString& rName, const uno::Any& rElement )
throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
// XNameContainer
//---------------------------------------------------------------------
void implInsertByName(NodeTreeSetAccess& rNode, const rtl::OUString& rName, const uno::Any& rElement)
throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException);
void implInsertByName(NodeValueSetAccess& rNode, const rtl::OUString& rName, const uno::Any& rElement)
throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException);
void implRemoveByName(NodeTreeSetAccess& rNode, const rtl::OUString& rName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
void implRemoveByName(NodeValueSetAccess& rNode, const rtl::OUString& rName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
// XPropertyWithState - updating operation only
//---------------------------------------------------------------------
void implSetToDefaultAsProperty(NodeSetAccess& rNode)
throw (css::lang::WrappedTargetException, uno::RuntimeException);
// XSingleServiceFactory
//---------------------------------------------------------------------
uno::Reference< uno::XInterface > implCreateElement(NodeTreeSetAccess& rNode )
throw(uno::Exception, uno::RuntimeException);
uno::Reference< uno::XInterface > implCreateElement(NodeTreeSetAccess& rNode, const uno::Sequence< uno::Any >& aArguments )
throw(uno::Exception, uno::RuntimeException);
//---------------------------------------------------------------------
}
}
#endif // CONFIGMGR_API_BASEUPDATEIMPL_HXX_

Some files were not shown because too many files have changed in this diff Show More