diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-18 18:26:28 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-23 22:20:31 +0200 |
commit | b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 (patch) | |
tree | 53ee1bd3dfd213815a21579151983cb997922b05 /include/ucbhelper | |
parent | f4e1642a1761d5eab6ccdd89928869c2b2f1528a (diff) |
execute move of global headers
see https://gerrit.libreoffice.org/#/c/3367/
and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details
Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a
Diffstat (limited to 'include/ucbhelper')
29 files changed, 6635 insertions, 0 deletions
diff --git a/include/ucbhelper/activedatasink.hxx b/include/ucbhelper/activedatasink.hxx new file mode 100644 index 000000000000..f58fef55a4c9 --- /dev/null +++ b/include/ucbhelper/activedatasink.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_ACTIVEDATASINK_HXX +#define _UCBHELPER_ACTIVEDATASINK_HXX + +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/io/XActiveDataSink.hpp> +#include <cppuhelper/weak.hxx> +#include <ucbhelper/macros.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace ucbhelper +{ + +//========================================================================= + +/** + * This class implements the interface com::sun::star::io::XActiveDataSink. + * Instances of this class can be passed with the parameters of an + * "open" command. + */ + +class UCBHELPER_DLLPUBLIC ActiveDataSink : public cppu::OWeakObject, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::io::XActiveDataSink +{ + com::sun::star::uno::Reference< + com::sun::star::io::XInputStream > m_xStream; + +public: + // XInterface + XINTERFACE_DECL() + + // XTypeProvider + XTYPEPROVIDER_DECL() + + // XActiveDataSink methods. + virtual void SAL_CALL + setInputStream( const com::sun::star::uno::Reference< + com::sun::star::io::XInputStream >& aStream ) + throw( com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Reference< + com::sun::star::io::XInputStream > SAL_CALL + getInputStream() + throw( com::sun::star::uno::RuntimeException ); +}; + +} /* namespace ucbhelper */ + +#endif /* !_UCBHELPER_ACTIVEDATASINK_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/activedatastreamer.hxx b/include/ucbhelper/activedatastreamer.hxx new file mode 100644 index 000000000000..2f84ff7543e0 --- /dev/null +++ b/include/ucbhelper/activedatastreamer.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_ACTIVEDATASTREAMER_HXX +#define _UCBHELPER_ACTIVEDATASTREAMER_HXX + +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/io/XActiveDataStreamer.hpp> +#include <cppuhelper/weak.hxx> +#include <ucbhelper/macros.hxx> + +namespace ucbhelper +{ + +//========================================================================= + +/** + * This class implements the interface com::sun::star::io::XActiveDataStreamer. + * Instances of this class can be passed with the parameters of an + * "open" command. + */ + +class ActiveDataStreamer : public cppu::OWeakObject, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::io::XActiveDataStreamer +{ + com::sun::star::uno::Reference< + com::sun::star::io::XStream > m_xStream; + +public: + // XInterface + XINTERFACE_DECL() + + // XTypeProvider + XTYPEPROVIDER_DECL() + + // XActiveDataStreamer methods. + virtual void SAL_CALL setStream( const com::sun::star::uno::Reference< com::sun::star::io::XStream >& xStream ) + throw( com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Reference< com::sun::star::io::XStream > SAL_CALL getStream() + throw( com::sun::star::uno::RuntimeException ); +}; + +} /* namespace ucbhelper */ + +#endif /* !_UCBHELPER_ACTIVEDATASTREAMER_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/cancelcommandexecution.hxx b/include/ucbhelper/cancelcommandexecution.hxx new file mode 100644 index 000000000000..67e000b33fb3 --- /dev/null +++ b/include/ucbhelper/cancelcommandexecution.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_ +#define _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_ + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Exception.hpp> +#include <com/sun/star/ucb/IOErrorCode.hpp> +#include <com/sun/star/ucb/XCommandProcessor.hpp> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace com { namespace sun { namespace star { + namespace uno { class Any; } + namespace ucb { class XCommandEnvironment; } +} } } + +namespace ucbhelper +{ + +//============================================================================ +/** Cancel the execution of a command by throwing the appropriate exception. + If an Interaction Handler is given with the command environment and the + handler handles the exception by selecting the supplied continuation, + then this function will put the original exception supplied into a + com::sun::star::ucb::CommandFailedException and throw the + CommandFailedException. If no handler was given or the handler was not + able to handle the exception, then the given exception will be thrown + directly. + + NOTE THAT THIS FUNCTION NEVER RETURNS! IT ALWAYS THROWS AN EXCEPTION! + + @param rException is the exception describing the error to handle. + + @param xEnv is the command environment that may contain an Interaction + Handler to use before throwing the appropriate exception. + */ +UCBHELPER_DLLPUBLIC void cancelCommandExecution( const com::sun::star::uno::Any & rException, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & + xEnv ) + throw( com::sun::star::uno::Exception ); + +/** Cancel the execution of a command by throwing the appropriate exception. + If an Interaction Handler is given with the command environment and the + handler handles the exception by selecting the supplied continuation, + then this function will put the original exception supplied into a + com::sun::star::ucb::CommandFailedException and throw the + CommandFailedException. If no handler was given or the handler was not + able to handle the exception, then the given exception will be thrown + directly. + + NOTE THAT THIS FUNCTION NEVER RETURNS! IT ALWAYS THROWS AN EXCEPTION! + + @param eError is an IO error code. + + @param rArgs is a sequeence containing the arguments to pass along with + the exception. Each IO error code can be combined with one or + more additional arguments. Refer to com/sun/star/ucb/IOErroprCode.idl + for details. + + @param xEnv is the command environment that may contain an Interaction + Handler to use before throwing the appropriate exception. + + @param rMessage is a text containing additional error information. + Used as debugging aid only. Passed to the member 'Message' of the + uno::Exception thrown by this function. + + @param xContext is the command processor executing the command to cancel. + Used as debugging aid only. Passed to the member 'Context' of the + uno::Exception thrown by this function. + */ +UCBHELPER_DLLPUBLIC void cancelCommandExecution( const com::sun::star::ucb::IOErrorCode eError, + const com::sun::star::uno::Sequence< + com::sun::star::uno::Any > & rArgs, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & + xEnv, + const OUString & rMessage = OUString(), + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandProcessor > & + xContext = 0 ) + throw( com::sun::star::uno::Exception ); +} + +#endif // _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/commandenvironment.hxx b/include/ucbhelper/commandenvironment.hxx new file mode 100644 index 000000000000..01883eee335e --- /dev/null +++ b/include/ucbhelper/commandenvironment.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_COMMANDENVIRONMENT_HXX +#define _UCBHELPER_COMMANDENVIRONMENT_HXX + +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/ucb/XCommandEnvironment.hpp> +#include <cppuhelper/weak.hxx> +#include <ucbhelper/macros.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace ucbhelper +{ + +struct CommandEnvironment_Impl; + +//========================================================================= + +/** + * This class implements the interface + * com::sun::star::ucb::XCommandEnvironement. Instances of this class can + * be used to supply environments to commands executed by UCB contents. + */ +class UCBHELPER_DLLPUBLIC CommandEnvironment : public cppu::OWeakObject, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::ucb::XCommandEnvironment +{ + CommandEnvironment_Impl* m_pImpl; + +private: + UCBHELPER_DLLPRIVATE CommandEnvironment( const CommandEnvironment& ); // n.i. + UCBHELPER_DLLPRIVATE CommandEnvironment& operator=( const CommandEnvironment& ); // n.i. + +public: + /** + * Constructor. + * + * @param rxInteractionHandler is the implementation of an Interaction + * Handler or an empty reference. + * @param rxProgressHandler is the implementation of a Progress + * Handler or an empty reference. + */ + CommandEnvironment( + const com::sun::star::uno::Reference< + com::sun::star::task::XInteractionHandler >& + rxInteractionHandler, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XProgressHandler >& + rxProgressHandler ); + /** + * Destructor. + */ + virtual ~CommandEnvironment(); + + // XInterface + XINTERFACE_DECL() + + // XTypeProvider + XTYPEPROVIDER_DECL() + + // XCommandEnvironemnt + virtual com::sun::star::uno::Reference< + com::sun::star::task::XInteractionHandler > SAL_CALL + getInteractionHandler() + throw ( com::sun::star::uno::RuntimeException ); + + virtual com::sun::star::uno::Reference< + com::sun::star::ucb::XProgressHandler > SAL_CALL + getProgressHandler() + throw ( com::sun::star::uno::RuntimeException ); +}; + +} /* namespace ucbhelper */ + +#endif /* !_UCBHELPER_COMMANDENVIRONMENT_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/content.hxx b/include/ucbhelper/content.hxx new file mode 100644 index 000000000000..0c5a2b45db5b --- /dev/null +++ b/include/ucbhelper/content.hxx @@ -0,0 +1,719 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _UCBHELPER_CONTENT_HXX +#define _UCBHELPER_CONTENT_HXX + +#include "rtl/ref.hxx" +#include <com/sun/star/ucb/ContentCreationException.hpp> +#include <com/sun/star/ucb/CommandAbortedException.hpp> +#include <com/sun/star/io/XStream.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace com { namespace sun { namespace star { namespace beans { + class XPropertySetInfo; +} } } } + +namespace com { namespace sun { namespace star { namespace io { + class XActiveDataSink; + class XOutputStream; + class XInputStream; +} } } } + +namespace com { namespace sun { namespace star { namespace sdbc { + class XResultSet; + class XRow; +} } } } + +namespace com { namespace sun { namespace star { namespace ucb { + class XCommandEnvironment; + class XCommandInfo; + class XContent; + class XContentIdentifier; + class XDynamicResultSet; + class XAnyCompareFactory; + struct ContentInfo; + struct NumberedSortingInfo; +} } } } + +namespace com { namespace sun { namespace star { namespace uno { + class XComponentContext; +} } } } + +namespace ucbhelper +{ + +//========================================================================= + +/** + * These are the possible values for the parameter eMode of method + * ucbhelper::Content::createCursor. + */ +enum ResultSetInclude +{ + INCLUDE_FOLDERS_ONLY, + INCLUDE_DOCUMENTS_ONLY, + INCLUDE_FOLDERS_AND_DOCUMENTS +}; + +/** + * These are the possible values for the parameter eOperation of method + * ucbhelper::Content::insertNewContent. + */ +enum InsertOperation +{ + InsertOperation_COPY, // copy source data + InsertOperation_MOVE, // move source data + InsertOperation_LINK, // create a link to source + InsertOperation_CHECKIN // check-in source data +}; + +//========================================================================= + +class Content_Impl; + +/** + * This class simplifies access to UCB contents by providing a more + * convenient API for frequently used functionality then the "raw" + * UCB-API does. + */ +class UCBHELPER_DLLPUBLIC Content +{ + rtl::Reference< Content_Impl > m_xImpl; + +protected: + ::com::sun::star::uno::Any createCursorAny( const ::com::sun::star::uno::Sequence< + OUString >& rPropertyNames, + ResultSetInclude eMode ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + +public: + /** + * Constructor. + */ + Content(); + + /** + * Constructor. + * + * @param rURL is the URL of the content to create. + * @param rEnv is the environment to use for commands executed by the + * content. The command environment is used by the content + * implementation to interact with the client and to propagate + * errors. + */ + Content( const OUString& rURL, + const ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XCommandEnvironment >& rEnv, + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& rCtx ) + throw ( ::com::sun::star::ucb::ContentCreationException, + ::com::sun::star::uno::RuntimeException ); + /** + * Constructor. + * + * @param rContent is the content object of the content to create. + * @param rEnv is the environment to use for commands executed by the + * content. The command environment is used by the content + * implementation to interact with the client and to propagate + * errors. + */ + Content( const ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XContent >& rContent, + const ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XCommandEnvironment >& rEnv, + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& rCtx ) + throw ( ::com::sun::star::ucb::ContentCreationException, + ::com::sun::star::uno::RuntimeException ); + /** + * Copy Constructor. + * + * @param rContent is the content this content shall be a copy of. + */ + Content( const Content& rOther ); + + /** + * Destructor. + */ + ~Content(); + + /** + * Assignment operator. + * + * @param rContent is the content this content shall be a copy of. + */ + Content& operator=( const Content& rOther ); + + /** + * Constructor. This method should be used, if the exception thrown + * by the direct ctors of this class are to 'expensive' for your + * application + * + * @param rURL is the URL of the content to create. + * @param rEnv is the environment to use for commands executed by the + * content. The command environment is used by the content + * implementation to interact with the client and to propagate + * errors. + * @param rContent will be filled by this method with the content created. + * @return true, if the operation was successful - false, otherwise. + */ + static sal_Bool + create( const OUString& rURL, + const ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XCommandEnvironment >& rEnv, + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& rCtx, + Content& rContent ); + + ////////////////////////////////////////////////////////////////////// + // Direct access to UCB content. + ////////////////////////////////////////////////////////////////////// + + /** + * This method provides access to the "native" UCB content interface(s). + * This is useful in case the convenience methods provided by this + * class are insufficient for your needs. You may obtain all interfaces + * supported by the underlying UCB content by calling this method and + * after that doing a queryInterface call. + * + * @return the XContent interface of the underlying UCB content. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > + get() const; + + ////////////////////////////////////////////////////////////////////// + // Object identity. + ////////////////////////////////////////////////////////////////////// + + /** + * This method returns the URL of the content. + * + * @return the URL of the content. + */ + const OUString& getURL() const; + + ////////////////////////////////////////////////////////////////////// + // Command environment. + ////////////////////////////////////////////////////////////////////// + + /** + * This method returns the environment to use when executing commands. + * + * @return the command environment. + */ + const ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XCommandEnvironment >& + getCommandEnvironment() const; + + /** + * This method sets a new command environment. + * + * @param xNewEnv is the new command environment. + */ + void setCommandEnvironment( + const ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XCommandEnvironment >& xNewEnv ); + + ////////////////////////////////////////////////////////////////////// + // Access to supported commands/properties. + ////////////////////////////////////////////////////////////////////// + + /** + * This methods provides access to meta data of the commands supported + * by this content. + * + * @return an XCommandInfo interface implementation, which can be used + * to obtain meta data of the commands supported by this content. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandInfo > + getCommands() + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + /** + * This methods provides access to meta data of the properties supported + * by this content. + * + * @return an XPropertSetInfo interface implementation, which can be used + * to obtain meta data of the properties supported by this content. + */ + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > + getProperties() + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + + ////////////////////////////////////////////////////////////////////// + // Access to property value(s). + ////////////////////////////////////////////////////////////////////// + + /** + * This method can be used to read a single property value. + * + * @param rPropertyName is the name of the property for that the value + * shall be obtained. + * @return the property value. + */ + ::com::sun::star::uno::Any + getPropertyValue( const OUString& rPropertyName ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + /** + * This method can be used to set a single property value. + * + * @param rPropertyName is the name of the property for that the + * value shall be set. + * @return an any containing: + * - No value indicates, that the property value was set + * successfully. + * - com::sun::star::beans::UnknownPropertyException indicates, + * that the property is not known to the content implementation. + * - com::sun::star::beans::IllegalTypeException indicates, that + * the data type of the property value is not acceptable. + * - com::sun::star::lang::IllegalAccessException indicates, that + * the property is constant. + * - com::sun::star::lang::IllegalArgumentException indicates, + * that the property value is not acceptable. For instance, + * setting an empty title may be illegal. + * - Any other execption derived from + * com::sun::star::uno::Exception indicates, that the value was + * not set successfully. For example, this can be a + * com::sun:star::ucb::InteractiveAugmentedIOException + * transporting the error code + * com::sun::star::ucb::IOErrorCode::ACCESS_DENIED. + */ + ::com::sun::star::uno::Any + setPropertyValue( const OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + /** + * This method can be used to read multiple property values. + * + * @param rPropertyNames is a sequence of names of properties for + * that the values shall be obtained. + * @return the property values. + */ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > + getPropertyValues( const ::com::sun::star::uno::Sequence< + OUString >& rPropertyNames ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + /** + * This method can be used to read multiple property values. + * + * @param rPropertyNames is a sequence of names of properties for + * that the values shall be obtained. + * @return the property values. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > + getPropertyValuesInterface( const ::com::sun::star::uno::Sequence< + OUString >& rPropertyNames ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + + /** + * This method can be used to set multiple property values. + * + * @param rPropertyNames is a sequence of names of properties for + * that values shall be set. + * @return a sequence of any's which has exactly the same number + * of elements as the number of properties to set. Every + * sequence element contains the status for a property. The + * first sequence elements corresponds to the first element in + * the sequence of property names and so on. + * + * An any containing: + * - No value indicates, that the property value was set + * successfully. + * - com::sun::star::beans::UnknownPropertyException indicates, + * that the property is not known to the content implementation. + * - com::sun::star::beans::IllegalTypeException indicates, that + * the data type of the property value is not acceptable. + * - com::sun::star::lang::IllegalAccessException indicates, that + * the property is constant. + * - com::sun::star::lang::IllegalArgumentException indicates, + * that the property value is not acceptable. For instance, + * setting an empty title may be illegal. + * - Any other execption derived from + * com::sun::star::uno::Exception indicates, that the value was + * not set successfully. For example, this can be a + * com::sun:star::ucb::InteractiveAugmentedIOException + * transporting the error code + * com::sun::star::ucb::IOErrorCode::ACCESS_DENIED. + */ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > + setPropertyValues( const ::com::sun::star::uno::Sequence< + OUString >& rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& rValues ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + + ////////////////////////////////////////////////////////////////////// + // General command execution. + ////////////////////////////////////////////////////////////////////// + + /** + * This method can be used to execute any command supported by the + * content. + * + * @param rCommandName is the name of the command to execute. + * @param rCommandArgument is the argument for the command. Type and + * values of this parameter must correspond to the command + * specification. + * @return the result of the command according to its specification. + */ + ::com::sun::star::uno::Any + executeCommand( const OUString& rCommandName, + const ::com::sun::star::uno::Any& rCommandArgument ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + + ////////////////////////////////////////////////////////////////////// + // Special commands. + ////////////////////////////////////////////////////////////////////// + + /** + * This methods gives access to the children of a folder content. + * Additionally, the result set returned provides efficient access to + * preselected property values of the children. + * Internally it executes the command "open" at the content. + * + * @param rPropertyNames is a sequence of names of properties for + * that the values should be accessible via the resultset + * returned by this method. + * @param eMode is a very simple filter for the children contained + * in the resultset. + * @return an implementation of the service + * com.cun.star.ucb.ContentResultSet, which can be used to + * get access to the children of a content. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > + createCursor( const ::com::sun::star::uno::Sequence< + OUString >& rPropertyNames, + ResultSetInclude eMode = INCLUDE_FOLDERS_AND_DOCUMENTS ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + /** + * This methods gives access to the children of a folder content. + * Additionally, the result set returned provides efficient access to + * preselected property values of the children. + * Internally it executes the command "open" at the content. + * + * @param rPropertyNames is a sequence of names of properties for + * that the values should be accessible via the resultset + * returned by this method. + * @param eMode is a very simple filter for the children contained + * in the resultset. + * @return an implementation of the service + * com.cun.star.ucb.DynamicResultSet, which can be used to + * get access to the children of a content. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XDynamicResultSet > + createDynamicCursor( const ::com::sun::star::uno::Sequence< + OUString >& rPropertyNames, + ResultSetInclude eMode + = INCLUDE_FOLDERS_AND_DOCUMENTS ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > + createSortedCursor( const ::com::sun::star::uno::Sequence< OUString >& rPropertyNames, + const ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::NumberedSortingInfo >& rSortInfo, + ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XAnyCompareFactory > rAnyCompareFactory, + ResultSetInclude eMode = INCLUDE_FOLDERS_AND_DOCUMENTS ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + + /** + * This methods gives read access to the content stream of a content (i.e + * the content of a file located at the local file system). + * Internally it executes the command "open" at the content. + * + * @return an implementation of the interface XInputStream, which can + * be used to read the content's data. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > + openStream() + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + /** + * This methods gives read access to the content stream of a content (i.e + * the content of a file located at the local file system). + * Internally it executes the command "open" at the content. + * The method requests opening without locking. + * + * @return an implementation of the interface XInputStream, which can + * be used to read the content's data. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > + openStreamNoLock() + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + + /** + * This methods gives read/write access to the content stream of a content (i.e + * the content of a file located at the local file system). + * Internally it executes the command "open" at the content. + * + * @return an implementation of the interface XStream, which can + * be used to read/write the content's data. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > + openWriteableStream() + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + /** + * This methods gives read/write access to the content stream of a content (i.e + * the content of a file located at the local file system). + * Internally it executes the command "open" at the content. + * The method requests opening without locking. + * + * @return an implementation of the interface XStream, which can + * be used to read/write the content's data. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > + openWriteableStreamNoLock() + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + + /** + * This methods gives read access to the content stream of a content (i.e + * the content of a file located at the local file system). + * Internally it executes the command "open" at the content. + * + * @param rSink is the implementation of an XActiveDataSink interface, + * which shall be used by the content to deliver the data. + */ + sal_Bool + openStream( const ::com::sun::star::uno::Reference< + ::com::sun::star::io::XActiveDataSink >& rSink ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + /** + * This methods gives read access to the content stream of a content (i.e + * the content of a file located at the local file system). + * Internally it executes the command "open" at the content. + * + * @param rStream is the implementation of an XOutputStream interface, + * which shall be used by the content to deliver the data. + */ + sal_Bool + openStream( const ::com::sun::star::uno::Reference< + ::com::sun::star::io::XOutputStream >& rStream ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + /** + * This methods gives write access to the content stream of a content (i.e + * the content of a file located at the local file system). + * Internally it executes the command "insert" at the content. + * + * @param rStream is the implementation of an XInputStream interface, + * which contains the content data to write. + * @param bReplaceExisting specifies, whether any existing content data + * shall be overwritten. + */ + void + writeStream( const ::com::sun::star::uno::Reference< + ::com::sun::star::io::XInputStream >& rStream, + sal_Bool bReplaceExisting ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + + /** + * This method returns the different types of contents this content + * can create. + * + * @return the content types or an empty sequence if no contents can be + * created by this content. + */ + ::com::sun::star::uno::Sequence< ::com::sun::star::ucb::ContentInfo > + queryCreatableContentsInfo() + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + + /** + * This method creates, initializes and inserts ( commits ) a new content + * (i.e. it could be used to create a new file system folder). + * Internally this method does a + * XCommandProcessor::execute( "createNewContent", ... ); + * XCommandProcessor::execute( "setPropertyValues", ... ); + * XCommandProcessor::execute( "insert", ... ); calling sequence. + * + * @param rContentType is the type for the new UCB content. Each content + * provider implementation may introduce own types for its content + * objects (See queryCreatableContentsInfo()). + * @param rPropertyNames is a sequence of names of properties for that + * values are to set at the new content before it will be inserted + * ( commited ). + * The order of the names must correspond to the order of the + * property values. + * @param rPropertyValues is a sequence of property values that are to + * set at the new content before it will be inserted ( commited ). + * The order of the values must correspond to the order of the + * property names. + * @param rNewContent will be filled by the implementation of this method + * with the new content. + */ + sal_Bool + insertNewContent( const OUString& rContentType, + const ::com::sun::star::uno::Sequence< + OUString >& rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& rPropertyValues, + Content& rNewContent ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + /** + * This method creates, initializes and inserts (commits) a new content + * inside this (the target folder) content. For example, it can be used to + * create a new file system file. + * Internally this method does a + * XCommandProcessor::execute( "createNewContent", ... ); + * XCommandProcessor::execute( "setPropertyValues", ... ); + * XCommandProcessor::execute( "insert", ... ); calling sequence. + * + * @param rContentType is the type for the new UCB content. Each content + * provider implementation may introduce own types for its content + * objects (See queryCreatableContentsInfo()). + * @param rPropertyNames is a sequence of names of properties for that + * values are to set at the new content before it will be inserted + * ( commited ). + * The order of the names must correspond to the order of the + * property values. + * @param rPropertyValues is a sequence of property values that are to + * set at the new content before it will be inserted ( commited ). + * The order of the values must correspond to the order of the + * property names. + * @param rStream is a stream containing the content data for the new + * content (i.e. the content of a file to create) + * @param rNewContent will be filled by the implementation of this method + * with the new content. + */ + sal_Bool + insertNewContent( const OUString& rContentType, + const ::com::sun::star::uno::Sequence< + OUString >& rPropertyNames, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& rPropertyValues, + const ::com::sun::star::uno::Reference< + ::com::sun::star::io::XInputStream >& rStream, + Content& rNewContent ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + + /** + * This method transfers (copies/moves) a content. It creates a new + * resource inside this (the target folder) content. + * The implementation is able to do cross-provider transfers (like copying + * a file from the local file system to a directory located on an HTTP + * server). + * Internally this method executes the command "globalTransfer" at the UCB. + * + * @param rSourceContent is the content that contains the data for the + * new UCB content. + * @param eOperation defines what shall be done with the source data + * ( COPY, MOVE, LINK ). + * @param rTitle contains a title for the new content. If this is an empty + * string, the new content will have the same title as the source + * content. + * @param rNameClashAction describes how the implementation shall behave + * in case a content with a clashing name exists in the target + * folder. + * NameClash::ERROR will abort the operation, NameClash::OVERWRITE + * will overwrite the clashing content and all its data, + * NameClash::RENAME will generate and supply a non-clashing title. + * @see com/sun/star/ucb/NameClash.idl + * @param rMimeType contains the MIME type of the document to write. + * @param bMajorVersion tells to create a new major version for checkin operations + * @param rCommentVersion contains the comment to use for checkin operations + * @param rResultURL is a hacky way to get the update URL after the operation in + * case there was a change (introduced for the checkin operation) + */ + sal_Bool + transferContent( const Content& rSourceContent, + InsertOperation eOperation, + const OUString & rTitle, + const sal_Int32 nNameClashAction, + const OUString & rMimeType = OUString( ), + bool bMajorVersion = false, + const OUString & rCommentVersion = OUString( ), + OUString* pResultURL = NULL ) + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + + ////////////////////////////////////////////////////////////////////// + // Required properties. + ////////////////////////////////////////////////////////////////////// + + /** + * This method returns the value of the content's property "IsFolder". + * + * @return true, if the content is a folder ( it can contain other + * UCB contents). false, otherwise. + */ + sal_Bool + isFolder() + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); + /** + * This method returns the value of the content's property "IsDocument". + * + * @return true, if the content is a document ( it has a content stream ). + * false, otherwise. + */ + sal_Bool + isDocument() + throw( ::com::sun::star::ucb::CommandAbortedException, + ::com::sun::star::uno::RuntimeException, + ::com::sun::star::uno::Exception ); +}; + +} /* namespace ucbhelper */ + +#endif /* !_UCBHELPER_CONTENT_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/contenthelper.hxx b/include/ucbhelper/contenthelper.hxx new file mode 100644 index 000000000000..e903d97f193a --- /dev/null +++ b/include/ucbhelper/contenthelper.hxx @@ -0,0 +1,504 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_CONTENTHELPER_HXX +#define _UCBHELPER_CONTENTHELPER_HXX + +#include <com/sun/star/beans/XPropertyContainer.hpp> +#include <com/sun/star/beans/XPropertiesChangeNotifier.hpp> +#include <com/sun/star/ucb/XCommandProcessor.hpp> +#include <com/sun/star/ucb/XContent.hpp> +#include <com/sun/star/beans/XPropertySetInfoChangeNotifier.hpp> +#include <com/sun/star/ucb/XCommandInfoChangeNotifier.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/ucb/CommandAbortedException.hpp> +#include <cppuhelper/weak.hxx> + +#include "osl/mutex.hxx" +#include "rtl/ref.hxx" +#include <ucbhelper/macros.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace com { namespace sun { namespace star { namespace ucb { + struct CommandInfo; + class XCommandEnvironment; + class XCommandInfo; + class XPersistentPropertySet; +} } } } + +namespace com { namespace sun { namespace star { namespace beans { + struct Property; + class XPropertySetInfo; +} } } } + +namespace ucbhelper_impl { struct ContentImplHelper_Impl; } + +namespace ucbhelper +{ + +//========================================================================= + +class ContentProviderImplHelper; + +/** + * This is an abstract base class for implementations of the service + * com.sun.star.ucb.Content. Implementations derived from this class are + * objects provided by implementations derived from + * class ucb::ContentProviderImplHelper. + * + * Features of the base class implementation: + * - standard interfaces ( XInterface, XTypeProvider, XServiceInfo ) + * - all required interfaces for service com::sun::star::ucb::Content + * - all required listener containers + * ( XComponent, XPropertiesChangeNotifier, XPropertySetInfoChangeNotifier, + * XCommandInfoChangeNotifier ) + * - XPropertyContainer implementation ( persistence is implemented using + * service com.sun.star.ucb.Store ) + * - complete XPropertySetInfo implementation ( including Additioanl Core + * Properties supplied via XPropertyContainer interface ) + * -> protected method: getPropertySetInfo + * - complete XCommandInfo implementation + * -> protected method: getCommandInfo + */ +class UCBHELPER_DLLPUBLIC ContentImplHelper : + 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::ucb::XContent, + public com::sun::star::ucb::XCommandProcessor, + public com::sun::star::beans::XPropertiesChangeNotifier, + public com::sun::star::beans::XPropertyContainer, + public com::sun::star::beans::XPropertySetInfoChangeNotifier, + public com::sun::star::ucb::XCommandInfoChangeNotifier, + public com::sun::star::container::XChild +{ + friend class PropertySetInfo; + friend class CommandProcessorInfo; + + ucbhelper_impl::ContentImplHelper_Impl* m_pImpl; + +protected: + osl::Mutex m_aMutex; + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + m_xContext; + com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier > + m_xIdentifier; + rtl::Reference< ContentProviderImplHelper > + m_xProvider; + sal_uInt32 m_nCommandId; + +private: + /** + * Your implementation of this method must return a sequence containing + * the meta data of the properties supported by the content. + * Note: If you wish to provide your own implementation of the interface + * XPropertyContainer ( completely override addContent and removeContent + * implementation of this base class in this case ), you can supply the + * meta data for your Additional Core Properties here to get a fully + * featured getPropertySetInfo method ( see below ). + * + * @param xEnv is an environment to use for example, for interactions. + * @return a sequence containing the property meta data. + */ + UCBHELPER_DLLPRIVATE + virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property > + getProperties( const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & xEnv ) = 0; + + /** + * Your implementation of this method must return a sequence containing + * the meta data of the commands supported by the content. + * + * @param xEnv is an environment to use for example, for interactions. + * @return a sequence containing the command meta data. + */ + UCBHELPER_DLLPRIVATE + virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo > + getCommands( const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & xEnv ) = 0; + + /** + * The implementation of this method shall return the URL of the parent + * of your content. + * + * @return the URL of the parent content or an empty string. + * Note that not all contents must have one parent. There may + * be contents with no parent. In that case an empty string must + * be returned. If your content has more than one parent you may + * return the URL of one "preferred" parent or an empty string. + */ + UCBHELPER_DLLPRIVATE virtual OUString getParentURL() = 0; + +protected: + /** + * This method returns complete meta data for the properties ( including + * Additional Core Properties supplied via XPropertyContainer interface ) + * supported by the content. To implement the required command + * "getPropertySetInfo" simply return the return value of this method. + * + * @param xEnv is an environment to use for example, for interactions. + * @param bCache indicates, whether the implemetation should use + * cached data, if exist. + * @return an XPropertySetInfo implementation object containing meta data + * for the properties supported by this content. + */ + com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > + getPropertySetInfo( const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & xEnv, + sal_Bool bCache = sal_True ); + + /** + * This method returns complete meta data for the commands supported by + * the content. To implement the required command "getCommandInfo" simply + * return the return value of this method. + * + * @param xEnv is an environment to use for example, for interactions. + * @param bCache indicates, whether the implemetation should use + * cached data, if exist. + * @return an XCommandInfo implementation object containing meta data + * for the commands supported by this content. + */ + com::sun::star::uno::Reference< com::sun::star::ucb::XCommandInfo > + getCommandInfo( const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & xEnv, + sal_Bool bCache = sal_True ); + + /** + * This method can be used to propagate changes of property values. + * + * @param evt is a sequence of property change events. + */ + void notifyPropertiesChange( + const com::sun::star::uno::Sequence< + com::sun::star::beans::PropertyChangeEvent >& evt ) const; + + /** + * This method can be used to propagate changes of the propertyset + * info of your content (i.e. this happens if a new property is added + * to your content via its XPropertyContainer interface). This base class + * automatically generates events when the propertyset info changes. If + * you provide your own implementations of addproperty and removeProperty, + * then you must call "notifyPropertySetInfoChange" by yourself. + * + * @param evt is a sequence of property change events. + */ + void notifyPropertySetInfoChange( + const com::sun::star::beans::PropertySetInfoChangeEvent& evt ) const; + + /** + * This method can be used to propagate content events. + * + * @param evt is a sequence of content events. + */ + void notifyContentEvent( + const com::sun::star::ucb::ContentEvent& evt ) const; + + /** + * Use this method to announce the insertion of this content at + * the end of your implementation of the command "insert". The + * implementation of is method propagates a ContentEvent( INSERTED ). + */ + void inserted(); + + /** + * Use this method to announce the destruction of this content at + * the end of your implementation of the command "delete". The + * implementation of is method propagates a ContentEvent( DELETED ) + * and a ContentEvent( REMOVED ) at the parent of the deleted content, + * if a parent exists. + */ + void deleted(); + + /** + * Use this method to change the identity of a content. The implementation + * of this method will replace the content identifier of the content and + * propagate the appropriate ContentEvent( EXCHANGED ). + * + * @param rNewId is the new content identifier for the contant. + * @return a success indicator. + */ + sal_Bool exchange( const com::sun::star::uno::Reference< + com::sun::star::ucb::XContentIdentifier >& rNewId ); + + /** + * Use this method to get access to the Additional Core Properties of + * the content ( added using content's XPropertyContainer interface ). + * If you supply your own XPropertyContainer implementation, this method + * will always return an empty propertyset. + * + * @param bCreate indicates whether a new propertyset shall be created + * if it does not exist. + * @return the implementation of the service + * com.sun.star.ucb.PersistentPropertySet. + */ + com::sun::star::uno::Reference< + com::sun::star::ucb::XPersistentPropertySet > + getAdditionalPropertySet( sal_Bool bCreate ); + + /** + * This method renames the propertyset containing the Additional Core + * Properties of the content. + * + * @param rOldKey is the old key of the propertyset. + * @param rNewKey is the new key for the propertyset. + * @param bRecursive is a flag indicating whether propertysets for + * children described by rOldKey shall be renamed too. + * @return True, if the operation succeeded - False, otherwise. + */ + sal_Bool renameAdditionalPropertySet( const OUString& rOldKey, + const OUString& rNewKey, + sal_Bool bRecursive ); + + /** + * This method copies the propertyset containing the Additional Core + * Properties of the content. + * + * @param rSourceKey is the key of the source propertyset. + * @param rTargetKey is the key of the target propertyset. + * @param bRecursive is a flag indicating whether propertysets for + * children described by rSourceKey shall be copied too. + * @return True, if the operation succeeded - False, otherwise. + */ + sal_Bool copyAdditionalPropertySet( const OUString& rSourceKey, + const OUString& rTargetKey, + sal_Bool bRecursive ); + + /** + * This method removes the propertyset containing the Additional Core + * Properties of the content. + * + * @param bRecursive is a flag indicating whether propertysets for + * children described by rOldKey shall be removed too. + * @return True, if the operation succeeded - False, otherwise. + */ + sal_Bool removeAdditionalPropertySet( sal_Bool bRecursive ); + +public: + /** + * Constructor. + * + * Note that the implementation of this ctor registers itself at its + * content provider. The provider implementation inserts the content + * in a hash map. So it easyly can be found and reused when the provider + * is asked for a content. + * + * @param rxContext is a Service Manager. + * @param rxProvider is the provider for the content. + * @param Identifier is the content identifier for the content. + */ + ContentImplHelper( + const com::sun::star::uno::Reference< + com::sun::star::uno::XComponentContext >& rxContext, + const rtl::Reference< ContentProviderImplHelper >& rxProvider, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XContentIdentifier >& Identifier ); + + /** + * Destructor. + * + * Note that the implementation of this dtor deregisters itself from its + * content provider. The provider implementation removes the content + * from a hash map. + */ + virtual ~ContentImplHelper(); + + // XInterface + XINTERFACE_DECL() + + // XTypeProvider + XTYPEPROVIDER_DECL() + + // XServiceInfo + virtual OUString SAL_CALL + getImplementationName() + throw( ::com::sun::star::uno::RuntimeException ) = 0; + virtual sal_Bool SAL_CALL + supportsService( const OUString& ServiceName ) + throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() + throw( ::com::sun::star::uno::RuntimeException ) = 0; + + // XComponent + virtual void SAL_CALL + dispose() + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + addEventListener( const com::sun::star::uno::Reference< + com::sun::star::lang::XEventListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + removeEventListener( const com::sun::star::uno::Reference< + com::sun::star::lang::XEventListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + + // XContent + virtual com::sun::star::uno::Reference< + com::sun::star::ucb::XContentIdentifier > SAL_CALL + getIdentifier() + throw( com::sun::star::uno::RuntimeException ); + virtual OUString SAL_CALL + getContentType() + throw( com::sun::star::uno::RuntimeException ) = 0; + virtual void SAL_CALL + addContentEventListener( + const com::sun::star::uno::Reference< + com::sun::star::ucb::XContentEventListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + removeContentEventListener( + const com::sun::star::uno::Reference< + com::sun::star::ucb::XContentEventListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + + // XCommandProcessor + virtual sal_Int32 SAL_CALL + createCommandIdentifier() + throw( com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Any SAL_CALL + execute( const com::sun::star::ucb::Command& aCommand, + sal_Int32 CommandId, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& Environment ) + throw( com::sun::star::uno::Exception, + com::sun::star::ucb::CommandAbortedException, + com::sun::star::uno::RuntimeException ) = 0; + virtual void SAL_CALL + abort( sal_Int32 CommandId ) + throw( com::sun::star::uno::RuntimeException ) = 0; + + // XPropertiesChangeNotifier + virtual void SAL_CALL + addPropertiesChangeListener( + const com::sun::star::uno::Sequence< OUString >& PropertyNames, + const com::sun::star::uno::Reference< + com::sun::star::beans::XPropertiesChangeListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + removePropertiesChangeListener( + const com::sun::star::uno::Sequence< OUString >& PropertyNames, + const com::sun::star::uno::Reference< + com::sun::star::beans::XPropertiesChangeListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + + // XCommandInfoChangeNotifier + virtual void SAL_CALL + addCommandInfoChangeListener( + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandInfoChangeListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + removeCommandInfoChangeListener( + const com::sun::star::uno::Reference< + ::com::sun::star::ucb::XCommandInfoChangeListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + + // XPropertyContainer + + /** + * This method adds a property to the content according to the interface + * specification. The properties will be stored using the service + * com.sun.star.ucb.Store. + * + * Note: You may provide your own implementation of this method, for + * instance, if your data source supports adding/removing of properties. + * Don't forget to return the meta data for these properties in your + * implementation of getPropertyInfoTable. + */ + virtual void SAL_CALL + addProperty( const OUString& Name, + sal_Int16 Attributes, + const com::sun::star::uno::Any& DefaultValue ) + throw( com::sun::star::beans::PropertyExistException, + com::sun::star::beans::IllegalTypeException, + com::sun::star::lang::IllegalArgumentException, + com::sun::star::uno::RuntimeException ); + + /** + * This method removes a property from the content according to the + * interface specification. The properties will be stored using the + * service com.sun.star.ucb.Store. + * + * Note: You may provide your own implementation of this method, for + * instance, if your data source supports adding/removing of properties. + * Don't forget to return the meta data for these properties in your + * implementation of getPropertyInfoTable. + */ + virtual void SAL_CALL + removeProperty( const OUString& Name ) + throw( com::sun::star::beans::UnknownPropertyException, + com::sun::star::beans::NotRemoveableException, + com::sun::star::uno::RuntimeException ); + + // XPropertySetInfoChangeNotifier + virtual void SAL_CALL + addPropertySetInfoChangeListener( + const com::sun::star::uno::Reference< + com::sun::star::beans::XPropertySetInfoChangeListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + removePropertySetInfoChangeListener( + const com::sun::star::uno::Reference< + com::sun::star::beans::XPropertySetInfoChangeListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + + // XChild + + /** + * This method returns the content representing the parent of a content, + * if such a parent exists. The implementation of this method uses your + * implementation of getParentURL. + */ + virtual com::sun::star::uno::Reference< + com::sun::star::uno::XInterface > SAL_CALL + getParent() + throw( com::sun::star::uno::RuntimeException ); + + /** + * The implementation of this method always throws a NoSupportException. + */ + virtual void SAL_CALL + setParent( const com::sun::star::uno::Reference< + com::sun::star::uno::XInterface >& Parent ) + throw( com::sun::star::lang::NoSupportException, + com::sun::star::uno::RuntimeException ); + + ////////////////////////////////////////////////////////////////////// + // Non-interface methods. + ////////////////////////////////////////////////////////////////////// + + /** + * This method returns the provider of the content. + * + * @return the provider of the content. + */ + const rtl::Reference< ContentProviderImplHelper >& getProvider() const + { return m_xProvider; } +}; + +} // namespace ucbhelper + +#endif /* !_UCBHELPER_CONTENTHELPER_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/contentidentifier.hxx b/include/ucbhelper/contentidentifier.hxx new file mode 100644 index 000000000000..4aa5459806f1 --- /dev/null +++ b/include/ucbhelper/contentidentifier.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX +#define _UCBHELPER_CONTENTIDENTIFIER_HXX + +#include <cppuhelper/weak.hxx> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/ucb/XContentIdentifier.hpp> +#include "ucbhelper/ucbhelperdllapi.h" + + +namespace ucbhelper +{ + +struct ContentIdentifier_Impl; + +//========================================================================= + +/** + * This class implements a simple identifier object for UCB contents. + * It mainly stores and returns the URL as it was passed to the constructor - + * The only difference is that the URL scheme will be lower cased. This can + * be done, because URL schemes are never case sensitive. + */ +class UCBHELPER_DLLPUBLIC ContentIdentifier : + public cppu::OWeakObject, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::ucb::XContentIdentifier +{ +public: + ContentIdentifier( const OUString& rURL ); + virtual ~ContentIdentifier(); + + // XInterface + virtual com::sun::star::uno::Any SAL_CALL + queryInterface( const com::sun::star::uno::Type & rType ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + acquire() throw(); + virtual void SAL_CALL + release() throw(); + + // XTypeProvider + virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() + throw( com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL + getTypes() + throw( com::sun::star::uno::RuntimeException ); + + // XContentIdentifier + virtual OUString SAL_CALL + getContentIdentifier() + throw( com::sun::star::uno::RuntimeException ); + virtual OUString SAL_CALL + getContentProviderScheme() + throw( com::sun::star::uno::RuntimeException ); + +private: + ContentIdentifier_Impl* m_pImpl; +}; + +} /* namespace ucbhelper */ + +#endif /* !_UCBHELPER_CONTENTIDENTIFIER_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/contentinfo.hxx b/include/ucbhelper/contentinfo.hxx new file mode 100644 index 000000000000..347c86304359 --- /dev/null +++ b/include/ucbhelper/contentinfo.hxx @@ -0,0 +1,162 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_CONTENTINFO_HXX +#define _UCBHELPER_CONTENTINFO_HXX + +#include <com/sun/star/ucb/XCommandInfo.hpp> +#include <com/sun/star/ucb/XCommandEnvironment.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <cppuhelper/weak.hxx> + +#include "osl/mutex.hxx" +#include <ucbhelper/macros.hxx> + +namespace ucbhelper { + +//============================================================================ +// +// class PropertySetInfo. +// +//============================================================================ + +class ContentImplHelper; + +/** + * This class provides a propertyset info ( the complete implementation of + * the interface XPropertySetInfo ) for an object derived from class + * ucb::ContentImplHelper. The implementation takes care about Additional + * Core Properties that may have been added to the content. + */ +class PropertySetInfo : + public cppu::OWeakObject, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::beans::XPropertySetInfo +{ + com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > + m_xEnv; + com::sun::star::uno::Sequence< com::sun::star::beans::Property >* + m_pProps; + osl::Mutex m_aMutex; + ContentImplHelper* m_pContent; + +private: + sal_Bool queryProperty( const OUString& rName, + com::sun::star::beans::Property& rProp ); + +public: + PropertySetInfo( const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& rxEnv, + ContentImplHelper* pContent ); + virtual ~PropertySetInfo(); + + // XInterface + XINTERFACE_DECL() + + // XTypeProvider + XTYPEPROVIDER_DECL() + + // XPropertySetInfo + 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( const OUString& aName ) + throw( com::sun::star::beans::UnknownPropertyException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + hasPropertyByName( const OUString& Name ) + throw( com::sun::star::uno::RuntimeException ); + + // Non-Interface methods. + void reset(); +}; + +//============================================================================ +// +// class CommandProcessorInfo. +// +//============================================================================ + +/** + * This class provides a command info ( the complete implementation of + * the interface XCommandInfo ) for an object derived from class + * ucb::ContentImplHelper. + */ +class CommandProcessorInfo : + public cppu::OWeakObject, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::ucb::XCommandInfo +{ + com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > + m_xEnv; + com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >* + m_pCommands; + osl::Mutex m_aMutex; + ContentImplHelper* m_pContent; + +private: + sal_Bool queryCommand( const OUString& rName, + com::sun::star::ucb::CommandInfo& rCommand ); + sal_Bool queryCommand( sal_Int32 nHandle, + com::sun::star::ucb::CommandInfo& rCommand ); + +public: + CommandProcessorInfo( const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& rxEnv, + ContentImplHelper* pContent ); + virtual ~CommandProcessorInfo(); + + // XInterface + XINTERFACE_DECL() + + // XTypeProvider + XTYPEPROVIDER_DECL() + + // XCommandInfo + virtual com::sun::star::uno::Sequence< + com::sun::star::ucb::CommandInfo > SAL_CALL + getCommands() + throw( com::sun::star::uno::RuntimeException ); + virtual com::sun::star::ucb::CommandInfo SAL_CALL + getCommandInfoByName( const OUString& Name ) + throw( com::sun::star::ucb::UnsupportedCommandException, + com::sun::star::uno::RuntimeException ); + virtual com::sun::star::ucb::CommandInfo SAL_CALL + getCommandInfoByHandle( sal_Int32 Handle ) + throw( com::sun::star::ucb::UnsupportedCommandException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + hasCommandByName( const OUString& Name ) + throw( com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + hasCommandByHandle( sal_Int32 Handle ) + throw( com::sun::star::uno::RuntimeException ); + + // Non-Interface methods. + void reset(); +}; + +} // namespace ucbhelper + +#endif /* !_UCBHELPER_CONTENTINFO_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/fd_inputstream.hxx b/include/ucbhelper/fd_inputstream.hxx new file mode 100644 index 000000000000..df3d6e386b67 --- /dev/null +++ b/include/ucbhelper/fd_inputstream.hxx @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_FD_INPUTSTREAM_HXX_ +#define _UCBHELPER_FD_INPUTSTREAM_HXX_ + +#include <rtl/ustring.hxx> +#include <osl/mutex.hxx> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/queryinterface.hxx> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XSeekable.hpp> +#include <stdio.h> + +#include "ucbhelper/ucbhelperdllapi.h" + +namespace ucbhelper +{ + /** Implements a seekable InputStream + * working on a buffer. + */ + class UCBHELPER_DLLPUBLIC FdInputStream + : public cppu::OWeakObject, + public com::sun::star::io::XInputStream, + public com::sun::star::io::XSeekable + { + public: + + /** Defines the storage kind found + * on which the inputstream acts. + */ + + FdInputStream(FILE* tmpfl = 0); + + ~FdInputStream(); + + virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& rType) + throw(css::uno::RuntimeException); + + virtual void SAL_CALL acquire(void) throw(); + + virtual void SAL_CALL release(void) throw(); + + virtual sal_Int32 SAL_CALL + readBytes(css::uno::Sequence< sal_Int8 >& aData, + sal_Int32 nBytesToRead) + throw( css::io::NotConnectedException, + css::io::BufferSizeExceededException, + css::io::IOException, + css::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL + readSomeBytes(css::uno::Sequence< sal_Int8 >& aData, + sal_Int32 nMaxBytesToRead ) + throw( css::io::NotConnectedException, + css::io::BufferSizeExceededException, + css::io::IOException, + css::uno::RuntimeException); + + virtual void SAL_CALL + skipBytes(sal_Int32 nBytesToSkip) + throw(css::io::NotConnectedException, + css::io::BufferSizeExceededException, + css::io::IOException, + css::uno::RuntimeException ); + + virtual sal_Int32 SAL_CALL + available(void) + throw(css::io::NotConnectedException, + css::io::IOException, + css::uno::RuntimeException ); + + virtual void SAL_CALL + closeInput(void) + throw(css::io::NotConnectedException, + css::io::IOException, + css::uno::RuntimeException); + + + /** XSeekable + */ + + virtual void SAL_CALL + seek(sal_Int64 location) + throw(css::lang::IllegalArgumentException, + css::io::IOException, + css::uno::RuntimeException); + + + virtual sal_Int64 SAL_CALL + getPosition(void) + throw(css::io::IOException, + css::uno::RuntimeException); + + + virtual sal_Int64 SAL_CALL + getLength(void) + throw(css::io::IOException, + css::uno::RuntimeException); + + // additional +// void append(const void* pBuffer,size_t size,size_t nmemb); + + private: + + osl::Mutex m_aMutex; + FILE* m_tmpfl; + sal_Int64 m_nLength; + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/fileidentifierconverter.hxx b/include/ucbhelper/fileidentifierconverter.hxx new file mode 100644 index 000000000000..052a7413bf93 --- /dev/null +++ b/include/ucbhelper/fileidentifierconverter.hxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_FILEIDENTIFIERCONVERTER_HXX_ +#define _UCBHELPER_FILEIDENTIFIERCONVERTER_HXX_ + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/RuntimeException.hpp> +#include <sal/types.h> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace com { namespace sun { namespace star { namespace ucb { + class XUniversalContentBroker; +} } } } + +namespace ucbhelper { + +//============================================================================ +/** Get a 'root' URL for the most 'local' file content provider. + + @descr + The result can be used as the rBaseURL parameter of + ucb::getFileURLFromSystemPath(). + + @returns + either a 'root' URL for the most 'local' file content provider, or an + empty string, if no such URL can meaningfully be constructed. + */ +UCBHELPER_DLLPUBLIC OUString getLocalFileURL() + SAL_THROW((com::sun::star::uno::RuntimeException)); + +//============================================================================ +/** Using a specific content provider manager, convert a file path in system + dependent notation to a (file) URL. + + @param rManager + A content provider manager. Must not be null. + + @param rBaseURL + See the corresponding parameter of + com::sun::star::ucb::XFileIdentifierConverter::getFileURLFromSystemPath(). + + @param rURL + See the corresponding parameter of + com::sun::star::ucb::XFileIdentifierConverter::getFileURLFromSystemPath(). + + @returns + a URL, if the content provider registered at the content provider manager + that is responsible for the base URL returns a URL when calling + com::sun::star::ucb::XFileIdentiferConverter::getFileURLFromSystemPath() + on it. Otherwise, an empty string is returned. + + @see + com::sun::star::ucb::XFileIdentiferConverter::getFileURLFromSystemPath(). + */ +UCBHELPER_DLLPUBLIC OUString +getFileURLFromSystemPath( + com::sun::star::uno::Reference< + com::sun::star::ucb::XUniversalContentBroker > const & + rUcb, + OUString const & rBaseURL, + OUString const & rSystemPath) + SAL_THROW((com::sun::star::uno::RuntimeException)); + +//============================================================================ +/** Using a specific content provider manager, convert a (file) URL to a + file path in system dependent notation. + + @param rManager + A content provider manager. Must not be null. + + @param rURL + See the corresponding parameter of + com::sun::star::ucb::XFileIdentiferConverter::getSystemPathFromFileURL(). + + @returns + a system path, if the content provider registered at the content provider + manager that is responsible for the base URL returns a system path when + calling + com::sun::star::ucb::XFileIdentiferConverter::getSystemPathFromFileURL() + on it. Otherwise, an empty string is returned. + + @see + com::sun::star::ucb::XFileIdentiferConverter::getSystemPathFromFileURL(). + */ +UCBHELPER_DLLPUBLIC OUString +getSystemPathFromFileURL( + com::sun::star::uno::Reference< + com::sun::star::ucb::XUniversalContentBroker > const & + rUcb, + OUString const & rURL) + SAL_THROW((com::sun::star::uno::RuntimeException)); + +} + +#endif // _UCBHELPER_FILEIDENTIFIERCONVERTER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/getcomponentcontext.hxx b/include/ucbhelper/getcomponentcontext.hxx new file mode 100644 index 000000000000..5d25e6cf8e9b --- /dev/null +++ b/include/ucbhelper/getcomponentcontext.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_UCBHELPER_GETCOMPONENTCONTEXT_HXX +#define INCLUDED_UCBHELPER_GETCOMPONENTCONTEXT_HXX + +#include "sal/config.h" + +#include "com/sun/star/uno/Reference.hxx" +#include "ucbhelper/ucbhelperdllapi.h" + +namespace com { namespace sun { namespace star { + namespace lang { class XMultiServiceFactory; } + namespace uno { class XComponentContext; } +} } } + +namespace ucbhelper { + +//TODO: a duplicate of comphelper::getComponentContext +// (comphelper/processfactory.hxx) +UCBHELPER_DLLPUBLIC +com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > +getComponentContext( + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > + const & factory); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/interactionrequest.hxx b/include/ucbhelper/interactionrequest.hxx new file mode 100644 index 000000000000..6de19931238c --- /dev/null +++ b/include/ucbhelper/interactionrequest.hxx @@ -0,0 +1,721 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_INTERATIONREQUEST_HXX +#define _UCBHELPER_INTERATIONREQUEST_HXX + +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/task/XInteractionRequest.hpp> +#include <com/sun/star/task/XInteractionAbort.hpp> +#include <com/sun/star/task/XInteractionRetry.hpp> +#include <com/sun/star/task/XInteractionApprove.hpp> +#include <com/sun/star/task/XInteractionDisapprove.hpp> +#include <com/sun/star/ucb/XInteractionReplaceExistingData.hpp> +#include <com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp> +#include <com/sun/star/ucb/XInteractionSupplyName.hpp> +#include <rtl/ref.hxx> +#include <cppuhelper/weak.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace ucbhelper { + +class InteractionContinuation; + +//============================================================================ +struct InteractionRequest_Impl; + +/** + * This class implements the interface XInteractionRequest. Instances can + * be passed directly to XInteractionHandler::handle(...). Each interaction + * request contains an exception describing the error and a number of + * interaction continuations describing the possible "answers" for the request. + * After the request was passed to XInteractionHandler::handle(...) the method + * getSelection() returns the continuation choosen by the interaction handler. + * + * The typical usage of this class would be: + * + * 1) Create exception object that shall be handled by the interaction handler. + * 2) Create InteractionRequest, supply exception as ctor parameter + * 3) Create continuations needed and add them to a sequence + * 4) Supply the continuations to the InteractionRequest by calling + * setContinuations(...) + * + * This class can also be used as base class for more specialized requests, + * like authentication requests. + */ +class UCBHELPER_DLLPUBLIC InteractionRequest : public cppu::OWeakObject, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::task::XInteractionRequest +{ + InteractionRequest_Impl * m_pImpl; + +protected: + void setRequest( const com::sun::star::uno::Any & rRequest ); + + InteractionRequest(); + virtual ~InteractionRequest(); + +public: + /** + * Constructor. + * + * @param rRequest is the exception describing the error. + */ + InteractionRequest( const com::sun::star::uno::Any & rRequest ); + + /** + * This method sets the continuations for the request. + * + * @param rContinuations contains the possible continuations. + */ + void setContinuations( + const com::sun::star::uno::Sequence< + com::sun::star::uno::Reference< + com::sun::star::task::XInteractionContinuation > > & + rContinuations ); + + // XInterface + virtual com::sun::star::uno::Any SAL_CALL + queryInterface( const com::sun::star::uno::Type & rType ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire() + throw(); + virtual void SAL_CALL release() + throw(); + + // XTypeProvider + 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 ); + + // XInteractionRequest + virtual com::sun::star::uno::Any SAL_CALL + getRequest() + throw( com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Sequence< + com::sun::star::uno::Reference< + com::sun::star::task::XInteractionContinuation > > SAL_CALL + getContinuations() + throw( com::sun::star::uno::RuntimeException ); + + // Non-interface methods. + + /** + * After passing this request to XInteractionHandler::handle, this method + * returns the continuation that was choosen by the interaction handler. + * + * @return the continuation choosen by an interaction handler or an empty + * reference, if the request was not (yet) handled. + */ + rtl::Reference< InteractionContinuation > getSelection() const; + + /** + * This method sets a continuation for the request. It also can be used + * to reset the continuation set by a previous XInteractionHandler::handle + * call in order to use this request object more then once. + * + * @param rxSelection is the interaction continuation to activate for + * the request or an empty reference in order to reset the + * current selection. + */ + void + setSelection( + const rtl::Reference< InteractionContinuation > & rxSelection ); +}; + +//============================================================================ +struct InteractionContinuation_Impl; + +/** + * This class is the base for implementations of the interface + * XInteractionContinuation. Classes derived from this bas class work together + * with class InteractionRequest. + * + * Derived classes must implement their XInteractionContinuation::select() + * method the way that they simply call recordSelection() which is provided by + * this class. + */ +class UCBHELPER_DLLPUBLIC InteractionContinuation : public cppu::OWeakObject +{ + InteractionContinuation_Impl * m_pImpl; + +protected: + /** + * This method marks this continuation as "selected" at the request it + * belongs to. + * + * Derived classes must implement their XInteractionContinuation::select() + * method the way that they call this method. + */ + void recordSelection(); + virtual ~InteractionContinuation(); + +public: + InteractionContinuation( InteractionRequest * pRequest ); +}; + +//============================================================================ +/** + * This class implements a standard interaction continuation, namely the + * interface XInteractionAbort. Instances of this class can be passed + * along with an interaction request to indicate the possiblity to abort + * the operation that caused the request. + */ +class UCBHELPER_DLLPUBLIC InteractionAbort : public InteractionContinuation, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::task::XInteractionAbort +{ +public: + InteractionAbort( InteractionRequest * pRequest ) + : InteractionContinuation( pRequest ) {} + + // XInterface + virtual com::sun::star::uno::Any SAL_CALL + queryInterface( const com::sun::star::uno::Type & rType ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire() + throw(); + virtual void SAL_CALL release() + throw(); + + // XTypeProvider + 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 ); + + // XInteractionContinuation + virtual void SAL_CALL select() + throw( com::sun::star::uno::RuntimeException ); +}; + +//============================================================================ +/** + * This class implements a standard interaction continuation, namely the + * interface XInteractionRetry. Instances of this class can be passed + * along with an interaction request to indicate the possiblity to retry + * the operation that caused the request. + */ +class UCBHELPER_DLLPUBLIC InteractionRetry : public InteractionContinuation, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::task::XInteractionRetry +{ +public: + InteractionRetry( InteractionRequest * pRequest ) + : InteractionContinuation( pRequest ) {} + + // XInterface + virtual com::sun::star::uno::Any SAL_CALL + queryInterface( const com::sun::star::uno::Type & rType ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire() + throw(); + virtual void SAL_CALL release() + throw(); + + // XTypeProvider + 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 ); + + // XInteractionContinuation + virtual void SAL_CALL select() + throw( com::sun::star::uno::RuntimeException ); +}; + +//============================================================================ +/** + * This class implements a standard interaction continuation, namely the + * interface XInteractionApprove. Instances of this class can be passed + * along with an interaction request to indicate the possiblity to approve + * the request. + */ +class UCBHELPER_DLLPUBLIC InteractionApprove : public InteractionContinuation, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::task::XInteractionApprove +{ +public: + InteractionApprove( InteractionRequest * pRequest ) + : InteractionContinuation( pRequest ) {} + + // XInterface + virtual com::sun::star::uno::Any SAL_CALL + queryInterface( const com::sun::star::uno::Type & rType ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire() + throw(); + virtual void SAL_CALL release() + throw(); + + // XTypeProvider + 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 ); + + // XInteractionContinuation + virtual void SAL_CALL select() + throw( com::sun::star::uno::RuntimeException ); +}; + +//============================================================================ +/** + * This class implements a standard interaction continuation, namely the + * interface XInteractionDisapprove. Instances of this class can be passed + * along with an interaction request to indicate the possiblity to disapprove + * the request. + */ +class UCBHELPER_DLLPUBLIC InteractionDisapprove : public InteractionContinuation, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::task::XInteractionDisapprove +{ +public: + InteractionDisapprove( InteractionRequest * pRequest ) + : InteractionContinuation( pRequest ) {} + + // XInterface + virtual com::sun::star::uno::Any SAL_CALL + queryInterface( const com::sun::star::uno::Type & rType ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire() + throw(); + virtual void SAL_CALL release() + throw(); + + // XTypeProvider + 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 ); + + // XInteractionContinuation + virtual void SAL_CALL select() + throw( com::sun::star::uno::RuntimeException ); +}; + +//============================================================================ +/** + * This class implements a standard interaction continuation, namely the + * interface XInteractionSupplyAuthentication. Instances of this class can be + * passed along with an authentication interaction request to enable the + * interaction handler to supply the missing authentication data. + */ +class UCBHELPER_DLLPUBLIC InteractionSupplyAuthentication : + public InteractionContinuation, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::ucb::XInteractionSupplyAuthentication2 +{ + com::sun::star::uno::Sequence< com::sun::star::ucb::RememberAuthentication > + m_aRememberPasswordModes; + com::sun::star::uno::Sequence< com::sun::star::ucb::RememberAuthentication > + m_aRememberAccountModes; + OUString m_aRealm; + OUString m_aUserName; + OUString m_aPassword; + OUString m_aAccount; + com::sun::star::ucb::RememberAuthentication m_eRememberPasswordMode; + com::sun::star::ucb::RememberAuthentication m_eDefaultRememberPasswordMode; + com::sun::star::ucb::RememberAuthentication m_eRememberAccountMode; + com::sun::star::ucb::RememberAuthentication m_eDefaultRememberAccountMode; + unsigned m_bCanSetRealm : 1; + unsigned m_bCanSetUserName : 1; + unsigned m_bCanSetPassword : 1; + unsigned m_bCanSetAccount : 1; + unsigned m_bCanUseSystemCredentials : 1; + unsigned m_bDefaultUseSystemCredentials : 1; + unsigned m_bUseSystemCredentials : 1; + +public: + /** + * Constructor. + * + * @param rxRequest is the interaction request that owns this continuation. + * @param bCanSetRealm indicates, whether the realm given with the + * authentication request is read-only. + * @param bCanSetUserName indicates, whether the username given with the + * authentication request is read-only. + * @param bCanSetPassword indicates, whether the password given with the + * authentication request is read-only. + * @param bCanSetAccount indicates, whether the account given with the + * authentication request is read-only. + * + * @see com::sun::star::ucb::AuthenticationRequest + */ + inline InteractionSupplyAuthentication( + InteractionRequest * pRequest, + sal_Bool bCanSetRealm, + sal_Bool bCanSetUserName, + sal_Bool bCanSetPassword, + sal_Bool bCanSetAccount); + /** + * Constructor. + * + * Note: The remember-authentication stuff is interesting only for + * clients implementing own password storage functionality. + * + * @param rxRequest is the interaction request that owns this continuation. + * @param bCanSetRealm indicates, whether the realm given with the + * authentication request is read-only. + * @param bCanSetUserName indicates, whether the username given with the + * authentication request is read-only. + * @param bCanSetPassword indicates, whether the password given with the + * authentication request is read-only. + * @param bCanSetAccount indicates, whether the account given with the + * authentication request is read-only. + * @param rRememberPasswordModes specifies the authentication-remember- + * modes for passwords supported by the requesting client. + * @param eDefaultRememberPasswordMode specifies the default + * authentication-remember-mode for passwords preferred by the + * requesting client. + * @param rRememberAccountModes specifies the authentication-remember- + * modes for accounts supported by the requesting client. + * @param eDefaultRememberAccountMode specifies the default + * authentication-remember-mode for accounts preferred by the + * requesting client. + * @param bCanUseSystemCredentials indicates whether issuer of the + * authetication request can obtain and use system credentials + * for authentication. + * @param bDefaultUseSystemCredentials specifies the default system + * credentials usage preferred by the requesting client + * + * @see com::sun::star::ucb::AuthenticationRequest + * @see com::sun::star::ucb::RememberAuthentication + */ + inline InteractionSupplyAuthentication( + InteractionRequest * pRequest, + sal_Bool bCanSetRealm, + sal_Bool bCanSetUserName, + sal_Bool bCanSetPassword, + sal_Bool bCanSetAccount, + const com::sun::star::uno::Sequence< + com::sun::star::ucb::RememberAuthentication > & + rRememberPasswordModes, + const com::sun::star::ucb::RememberAuthentication + eDefaultRememberPasswordMode, + const com::sun::star::uno::Sequence< + com::sun::star::ucb::RememberAuthentication > & + rRememberAccountModes, + const com::sun::star::ucb::RememberAuthentication + eDefaultRememberAccountMode, + sal_Bool bCanUseSystemCredentials, + sal_Bool bDefaultUseSystemCredentials ); + + // XInterface + virtual com::sun::star::uno::Any SAL_CALL + queryInterface( const com::sun::star::uno::Type & rType ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire() + throw(); + virtual void SAL_CALL release() + throw(); + + // XTypeProvider + 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 ); + + // XInteractionContinuation + virtual void SAL_CALL select() + throw( com::sun::star::uno::RuntimeException ); + + // XInteractionSupplyAuthentication + virtual sal_Bool SAL_CALL + canSetRealm() + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + setRealm( const OUString& Realm ) + throw( com::sun::star::uno::RuntimeException ); + + virtual sal_Bool SAL_CALL + canSetUserName() + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + setUserName( const OUString& UserName ) + throw( com::sun::star::uno::RuntimeException ); + + virtual sal_Bool SAL_CALL + canSetPassword() + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + setPassword( const OUString& Password ) + throw( com::sun::star::uno::RuntimeException ); + + virtual com::sun::star::uno::Sequence< + com::sun::star::ucb::RememberAuthentication > SAL_CALL + getRememberPasswordModes( + com::sun::star::ucb::RememberAuthentication& Default ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + setRememberPassword( com::sun::star::ucb::RememberAuthentication Remember ) + throw( com::sun::star::uno::RuntimeException ); + + virtual sal_Bool SAL_CALL + canSetAccount() + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + setAccount( const OUString& Account ) + throw( com::sun::star::uno::RuntimeException ); + + virtual com::sun::star::uno::Sequence< + com::sun::star::ucb::RememberAuthentication > SAL_CALL + getRememberAccountModes( + com::sun::star::ucb::RememberAuthentication& Default ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + setRememberAccount( com::sun::star::ucb::RememberAuthentication Remember ) + throw( com::sun::star::uno::RuntimeException ); + + // XInteractionSupplyAuthentication2 + virtual ::sal_Bool SAL_CALL canUseSystemCredentials( ::sal_Bool& Default ) + throw ( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setUseSystemCredentials( ::sal_Bool UseSystemCredentials ) + throw ( ::com::sun::star::uno::RuntimeException ); + + // Non-interface methods. + + /** + * This method returns the realm that was supplied by the interaction + * handler. + * + * @return the realm. + */ + const OUString & getRealm() const { return m_aRealm; } + + /** + * This method returns the username that was supplied by the interaction + * handler. + * + * @return the username. + */ + const OUString & getUserName() const { return m_aUserName; } + + /** + * This method returns the password that was supplied by the interaction + * handler. + * + * @return the password. + */ + const OUString & getPassword() const { return m_aPassword; } + + /** + * This method returns the account that was supplied by the interaction + * handler. + * + * @return the account. + */ + const OUString & getAccount() const { return m_aAccount; } + + /** + * This method returns the authentication remember-mode for the password + * that was supplied by the interaction handler. + * + * @return the remember-mode for the password. + */ + const com::sun::star::ucb::RememberAuthentication & + getRememberPasswordMode() const { return m_eRememberPasswordMode; } + + /** + * This method returns the authentication remember-mode for the account + * that was supplied by the interaction handler. + * + * @return the remember-mode for the account. + */ + const com::sun::star::ucb::RememberAuthentication & + getRememberAccountMode() const { return m_eRememberAccountMode; } + + sal_Bool getUseSystemCredentials() const { return m_bUseSystemCredentials; } +}; + +//============================================================================ +inline InteractionSupplyAuthentication::InteractionSupplyAuthentication( + InteractionRequest * pRequest, + sal_Bool bCanSetRealm, + sal_Bool bCanSetUserName, + sal_Bool bCanSetPassword, + sal_Bool bCanSetAccount ) +: InteractionContinuation( pRequest ), + m_aRememberPasswordModes( com::sun::star::uno::Sequence< + com::sun::star::ucb::RememberAuthentication >( 1 ) ), + m_aRememberAccountModes( com::sun::star::uno::Sequence< + com::sun::star::ucb::RememberAuthentication >( 1 ) ), + m_eRememberPasswordMode( com::sun::star::ucb::RememberAuthentication_NO ), + m_eDefaultRememberPasswordMode( + com::sun::star::ucb::RememberAuthentication_NO ), + m_eRememberAccountMode( com::sun::star::ucb::RememberAuthentication_NO ), + m_eDefaultRememberAccountMode( + com::sun::star::ucb::RememberAuthentication_NO ), + m_bCanSetRealm( bCanSetRealm ), + m_bCanSetUserName( bCanSetUserName ), + m_bCanSetPassword( bCanSetPassword ), + m_bCanSetAccount( bCanSetAccount ), + m_bCanUseSystemCredentials( sal_False ), + m_bDefaultUseSystemCredentials( sal_False ), + m_bUseSystemCredentials( sal_False ) +{ + m_aRememberPasswordModes[ 0 ] + = com::sun::star::ucb::RememberAuthentication_NO; + m_aRememberAccountModes [ 0 ] + = com::sun::star::ucb::RememberAuthentication_NO; +} + +//============================================================================ +inline InteractionSupplyAuthentication::InteractionSupplyAuthentication( + InteractionRequest * pRequest, + sal_Bool bCanSetRealm, + sal_Bool bCanSetUserName, + sal_Bool bCanSetPassword, + sal_Bool bCanSetAccount, + const com::sun::star::uno::Sequence< + com::sun::star::ucb::RememberAuthentication > & rRememberPasswordModes, + const com::sun::star::ucb::RememberAuthentication + eDefaultRememberPasswordMode, + const com::sun::star::uno::Sequence< + com::sun::star::ucb::RememberAuthentication > & rRememberAccountModes, + const com::sun::star::ucb::RememberAuthentication + eDefaultRememberAccountMode, + sal_Bool bCanUseSystemCredentials, + sal_Bool bDefaultUseSystemCredentials ) +: InteractionContinuation( pRequest ), + m_aRememberPasswordModes( rRememberPasswordModes ), + m_aRememberAccountModes( rRememberAccountModes ), + m_eRememberPasswordMode( eDefaultRememberPasswordMode ), + m_eDefaultRememberPasswordMode( eDefaultRememberPasswordMode ), + m_eRememberAccountMode( eDefaultRememberAccountMode ), + m_eDefaultRememberAccountMode( eDefaultRememberAccountMode ), + m_bCanSetRealm( bCanSetRealm ), + m_bCanSetUserName( bCanSetUserName ), + m_bCanSetPassword( bCanSetPassword ), + m_bCanSetAccount( bCanSetAccount ), + m_bCanUseSystemCredentials( bCanUseSystemCredentials ), + m_bDefaultUseSystemCredentials( bDefaultUseSystemCredentials ), + m_bUseSystemCredentials( bDefaultUseSystemCredentials & bCanUseSystemCredentials ) +{ +} + +//============================================================================ +/** + * This class implements a standard interaction continuation, namely the + * interface XInteractionSupplyName. Instances of this class can be passed + * along with an interaction request to indicate the possiblity to + * supply a new name. + */ +class InteractionSupplyName : public InteractionContinuation, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::ucb::XInteractionSupplyName +{ + OUString m_aName; + +public: + InteractionSupplyName( InteractionRequest * pRequest ) + : InteractionContinuation( pRequest ) {} + + // XInterface + virtual com::sun::star::uno::Any SAL_CALL + queryInterface( const com::sun::star::uno::Type & rType ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire() + throw(); + virtual void SAL_CALL release() + throw(); + + // XTypeProvider + 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 ); + + // XInteractionContinuation + virtual void SAL_CALL select() + throw( com::sun::star::uno::RuntimeException ); + + // XInteractionSupplyName + virtual void SAL_CALL setName( const OUString& Name ) + throw ( com::sun::star::uno::RuntimeException ); + + // Non-interface methods. + + /** + * This method returns the name that was supplied by the interaction + * handler. + * + * @return the name. + */ + const OUString & getName() const { return m_aName; } +}; + +//============================================================================ +/** + * This class implements a standard interaction continuation, namely the + * interface XInteractionReplaceExistingData. Instances of this class can be + * passed along with an interaction request to indicate the possiblity to + * replace existing data. + */ +class InteractionReplaceExistingData : + public InteractionContinuation, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::ucb::XInteractionReplaceExistingData +{ +public: + InteractionReplaceExistingData( InteractionRequest * pRequest ) + : InteractionContinuation( pRequest ) {} + + // XInterface + virtual com::sun::star::uno::Any SAL_CALL + queryInterface( const com::sun::star::uno::Type & rType ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire() + throw(); + virtual void SAL_CALL release() + throw(); + + // XTypeProvider + 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 ); + + // XInteractionContinuation + virtual void SAL_CALL select() + throw( com::sun::star::uno::RuntimeException ); +}; + +} // namespace ucbhelper + +#endif /* !_UCBHELPER_INTERATIONREQUEST_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/interceptedinteraction.hxx b/include/ucbhelper/interceptedinteraction.hxx new file mode 100644 index 000000000000..8c9b52239ad6 --- /dev/null +++ b/include/ucbhelper/interceptedinteraction.hxx @@ -0,0 +1,334 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_INTERCEPTEDINTERACTION_HXX_ +#define _UCBHELPER_INTERCEPTEDINTERACTION_HXX_ + +#include <vector> + +#include <com/sun/star/task/XInteractionHandler.hpp> + +#include <com/sun/star/task/XInteractionRequest.hpp> +#include <cppuhelper/implbase1.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + + +namespace ucbhelper{ + + +/** @short it wraps any other interaction handler and intercept + its handle() requests. + + @descr This class can be used as: + - instance if special interactions must be supressed + only + - or as base class if interactions must be modified. + */ +class UCBHELPER_DLLPUBLIC InterceptedInteraction : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionHandler > +{ + //------------------------------------------- + // types + public: + + struct InterceptedRequest + { + //----------------------------------- + /** @short marks an Handle as invalid. + */ + static const sal_Int32 INVALID_HANDLE = -1; + + //----------------------------------- + /** @short contains the interaction request, which should be intercepted. */ + ::com::sun::star::uno::Any Request; + + //----------------------------------- + /** @short specify the fix continuation, which must be selected, if the + interaction could be intercepted successfully. + */ + ::com::sun::star::uno::Type Continuation; + + //----------------------------------- + /** @short specify, if both interactions must have the same type + or can be derived from. + + @descr Interaction base on exceptions - and exceptions are real types. + So they can be checked in its type. These parameter "MatchExact" + influence the type-check in the following way: + TRUE => the exception will be intercepted only + if it supports exactly the same type ... + or + FALSE => derived exceptions will be intercepted too. + + @attention This parameter does not influence the check of the continuation + type! The continuation must be matched exactly everytimes ... + */ + sal_Bool MatchExact; + + //----------------------------------- + /** @short its an unique identifier, which must be managed by the outside code. + + @descr If there is a derived class, which overwrites the InterceptedInteraction::intercepted() + method, it will be called with a reference to an InterceptedRequest struct. + Then it can use the handle to react without checking the request type again. + */ + sal_Int32 Handle; + + //----------------------------------- + /** @short default ctor. + + @descr Such constructed object cant be used realy. + Might it will crash if its used! + Dont forget to initialize all(!) members ... + */ + InterceptedRequest() + { + MatchExact = sal_False; + Handle = INVALID_HANDLE; + } + + //----------------------------------- + /** @short initialize this instance. + + @param nHandle + used to identify every intercepted request + + @param aRequest + must contain an exception object, which can be checked + in its uno-type against the later handled interaction. + + @param aContinuation + must contain a continuation object, which is used + in its uno-type to locate the same continuation + inside the list of possible ones. + + @param bMatchExact + influence the type check of the interception request. + Its not used to check the continuation! + */ + InterceptedRequest( sal_Int32 nHandle , + const ::com::sun::star::uno::Any& aRequest , + const ::com::sun::star::uno::Type& aContinuation, + sal_Bool bMatchExact ) + { + Handle = nHandle; + Request = aRequest; + Continuation = aContinuation; + MatchExact = bMatchExact; + } + }; + + //--------------------------------------- + /** @short represent the different states, which can occure + as result of an interception. + + @see impl_interceptRequest() + */ + enum EInterceptionState + { + /** none of the specified interceptions match the incoming request */ + E_NOT_INTERCEPTED, + /** the request could be intercepted - but the specified continuation could not be located. + Thats normaly an error of the programmer. May be the interaction request does not use + the right set of continuations ... or the interception list contains the wrong continuation. */ + E_NO_CONTINUATION_FOUND, + /** the request could be intercepted and the specified continuation could be selected successfully. */ + E_INTERCEPTED + }; + + //------------------------------------------- + // member + protected: + + //--------------------------------------- + /** @short reference to the intercepted interaction handler. + + @descr NULL is allowed for this member! + All interaction will be aborted then ... + expecting th handle() was overwritten by + a derived class. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xInterceptedHandler; + + //--------------------------------------- + /** @short these list contains the requests, which should be intercepted. + */ + ::std::vector< InterceptedRequest > m_lInterceptions; + + //------------------------------------------- + // native interface + public: + + //--------------------------------------- + /** @short initialize a new instance with default values. + */ + InterceptedInteraction(); + + //--------------------------------------- + /** @short initialize a new instance with real values. + + @param xInterceptedHandler + the outside interaction handler, which should + be intercepted here. + + @param lInterceptions + the list of intercepted requests. + */ + InterceptedInteraction(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xInterceptedHandler, + const ::std::vector< InterceptedRequest >& lInterceptions ); + + //--------------------------------------- + /** @short initialize a new instance with the interaction handler, + which should be intercepted. + + @attention If such interaction handler isnt set here, + all incoming requests will be aborted ... + if the right continuation is available! + + @param xInterceptedHandler + the outside interaction handler, which should + be intercepted here. + */ + void setInterceptedHandler(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xInterceptedHandler); + + //--------------------------------------- + /** @short set a new list of intercepted interactions. + + @attention If the interface method handle() will be overwritten by + a derived class, the functionality behind these static list + cant be used. + + @param lInterceptions + the list of intercepted requests. + */ + void setInterceptions(const ::std::vector< InterceptedRequest >& lInterceptions); + + //--------------------------------------- + /** @short extract a requested continuation from te list of available ones. + + @param lContinuations + the list of available continuations. + + @param aType + is used to locate the right continuation, + by checking its interface type. + + @return A valid reference to the continuation, if it could be located ... + or an empty reference otherwise. + */ + static ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > extractContinuation( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& lContinuations, + const ::com::sun::star::uno::Type& aType ); + + //------------------------------------------- + // useable for derived classes + protected: + + //--------------------------------------- + /** @short can be overwritten by a derived class to handle interceptions + outside. + + @descr This base implementation checks, if the request could be intercepted + successfully. Then this method intercepted() is called. + The default implementation returns "NOT_INTERCEPTED" everytimes. + So the method impl_interceptRequest() uses the right continuation automaticly. + + If this method was overwritten and something different "NO_INTERCEPTED" + is returned, the method impl_interceptRequest() will return immediately with + the result, which is returned by this intercepted() method. + Then the continuations must be selected inside the intercepted() call! + + @param rRequest + it points to the intercepted request (means the item of the + set interception list). e.g. its "Handle" member can be used + to identify it and react very easy, without the need to check the + type of the exception ... + + @param xOrgRequest + points to the original interaction, which was intercepted. + It provides access to the exception and the list of possible + continuations. + + @return The result of this operation. + Note: If E_NOT_INTERCEPTED is returned the default handling of the base class + will be used automaticly for this request! + */ + virtual EInterceptionState intercepted(const InterceptedRequest& rRequest , + const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xOrgRequest); + + //------------------------------------------- + // uno interface + public: + + //--------------------------------------- + /** @short implements the default handling of this class .... + or can be overwritten by any derived class. + + @descr If no further class is derived from this one + -> the default implementation is used. Then the + internal list of requests is used to handle different + interactions automaticly. + (see impl_interceptRequest()) + + If this method was overwritten by a derived implementation + -> the new implementation has to do everything by itself. + Of course it can access all members/helpers and work with it. + But the default implementation isnt used automaticly then. + + @param xRequest + the interaction request, which should be intercepted. + */ + virtual void SAL_CALL handle(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest) + throw(::com::sun::star::uno::RuntimeException); + + //------------------------------------------- + // helper + private: + + //--------------------------------------- + /** @short implements the default handling: + - intercept or forward to internal handler. + */ + UCBHELPER_DLLPRIVATE void impl_handleDefault(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest); + + //--------------------------------------- + /** @short implements the interception of requests. + + @descr The incoming request will be analyzed, if it match + any request of the m_lIntercepions list. + If an interception could be found, its continuation will be + searched and selected. + + The method return the state of that operation. + But it doesnt call the intercepted and here set + interaction handler. That has to be done in the outside method. + + @param xRequest + the interaction request, which should be intercepted. + + @return A identifier, which inidicates if the request was intercepted, + the continuation was found and selected ... or not. + */ + UCBHELPER_DLLPRIVATE EInterceptionState impl_interceptRequest(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest); +}; + +} // namespace ucbhelper + +#endif // _UCBHELPER_INTERCEPTEDINTERACTION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/macros.hxx b/include/ucbhelper/macros.hxx new file mode 100644 index 000000000000..2f31e3098545 --- /dev/null +++ b/include/ucbhelper/macros.hxx @@ -0,0 +1,761 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_MACROS_HXX +#define _UCBHELPER_MACROS_HXX + +#include <sal/types.h> +#include <cppuhelper/queryinterface.hxx> +#include <cppuhelper/factory.hxx> +#include <cppuhelper/weakref.hxx> +#include <cppuhelper/typeprovider.hxx> + +#include "osl/mutex.hxx" +#include "ucbhelper/getcomponentcontext.hxx" + +//========================================================================= + +#define CPPU_TYPE( T ) getCppuType( static_cast< T * >( 0 ) ) +#define CPPU_TYPE_REF( T ) CPPU_TYPE( com::sun::star::uno::Reference< T > ) + +//========================================================================= +// +// XInterface decl. +// +//========================================================================= + +#define XINTERFACE_DECL() \ + virtual com::sun::star::uno::Any SAL_CALL \ + queryInterface( const com::sun::star::uno::Type & rType ) \ + throw( com::sun::star::uno::RuntimeException ); \ + virtual void SAL_CALL \ + acquire() \ + throw(); \ + virtual void SAL_CALL \ + release() \ + throw(); + +//========================================================================= +// +// XInterface impl. internals. +// +//========================================================================= + +#define XINTERFACE_COMMON_IMPL( Class ) \ +void SAL_CALL Class::acquire() \ + throw() \ +{ \ + OWeakObject::acquire(); \ +} \ + \ +void SAL_CALL Class::release() \ + throw() \ +{ \ + OWeakObject::release(); \ +} + +#define QUERYINTERFACE_IMPL_START( Class ) \ +com::sun::star::uno::Any SAL_CALL Class::queryInterface( \ + const com::sun::star::uno::Type & rType ) \ + throw( com::sun::star::uno::RuntimeException ) \ +{ \ + com::sun::star::uno::Any aRet = cppu::queryInterface( rType, + +#define QUERYINTERFACE_IMPL_END \ + ); \ + return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); \ +} + +//========================================================================= +// +// XInterface impl. +// +//========================================================================= + +// 1 interface implemented +#define XINTERFACE_IMPL_1( Class, Ifc1 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< Ifc1* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 2 interfaces implemented +#define XINTERFACE_IMPL_2( Class, Ifc1, Ifc2 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< Ifc1* >(this)), \ + (static_cast< Ifc2* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 3 interfaces implemented +#define XINTERFACE_IMPL_3( Class, Ifc1, Ifc2, Ifc3 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< Ifc1* >(this)), \ + (static_cast< Ifc2* >(this)), \ + (static_cast< Ifc3* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 4 interfaces implemented +#define XINTERFACE_IMPL_4( Class, Ifc1, Ifc2, Ifc3, Ifc4 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< Ifc1* >(this)), \ + (static_cast< Ifc2* >(this)), \ + (static_cast< Ifc3* >(this)), \ + (static_cast< Ifc4* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 5 interfaces implemented +#define XINTERFACE_IMPL_5( Class, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< Ifc1* >(this)), \ + (static_cast< Ifc2* >(this)), \ + (static_cast< Ifc3* >(this)), \ + (static_cast< Ifc4* >(this)), \ + (static_cast< Ifc5* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 6 interfaces implemented +#define XINTERFACE_IMPL_6( Class,I1,I2,I3,I4,I5,I6 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< I1* >(this)), \ + (static_cast< I2* >(this)), \ + (static_cast< I3* >(this)), \ + (static_cast< I4* >(this)), \ + (static_cast< I5* >(this)), \ + (static_cast< I6* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 7 interfaces implemented +#define XINTERFACE_IMPL_7( Class,I1,I2,I3,I4,I5,I6,I7 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< I1* >(this)), \ + (static_cast< I2* >(this)), \ + (static_cast< I3* >(this)), \ + (static_cast< I4* >(this)), \ + (static_cast< I5* >(this)), \ + (static_cast< I6* >(this)), \ + (static_cast< I7* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 8 interfaces implemented +#define XINTERFACE_IMPL_8( Class,I1,I2,I3,I4,I5,I6,I7,I8 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< I1* >(this)), \ + (static_cast< I2* >(this)), \ + (static_cast< I3* >(this)), \ + (static_cast< I4* >(this)), \ + (static_cast< I5* >(this)), \ + (static_cast< I6* >(this)), \ + (static_cast< I7* >(this)), \ + (static_cast< I8* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 9 interfaces implemented +#define XINTERFACE_IMPL_9( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< I1* >(this)), \ + (static_cast< I2* >(this)), \ + (static_cast< I3* >(this)), \ + (static_cast< I4* >(this)), \ + (static_cast< I5* >(this)), \ + (static_cast< I6* >(this)), \ + (static_cast< I7* >(this)), \ + (static_cast< I8* >(this)), \ + (static_cast< I9* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 10 interfaces implemented +#define XINTERFACE_IMPL_10( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< I1* >(this)), \ + (static_cast< I2* >(this)), \ + (static_cast< I3* >(this)), \ + (static_cast< I4* >(this)), \ + (static_cast< I5* >(this)), \ + (static_cast< I6* >(this)), \ + (static_cast< I7* >(this)), \ + (static_cast< I8* >(this)), \ + (static_cast< I9* >(this)), \ + (static_cast< I10* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 11 interfaces implemented +#define XINTERFACE_IMPL_11( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< I1* >(this)), \ + (static_cast< I2* >(this)), \ + (static_cast< I3* >(this)), \ + (static_cast< I4* >(this)), \ + (static_cast< I5* >(this)), \ + (static_cast< I6* >(this)), \ + (static_cast< I7* >(this)), \ + (static_cast< I8* >(this)), \ + (static_cast< I9* >(this)), \ + (static_cast< I10* >(this)), \ + (static_cast< I11* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 12 interfaces implemented +#define XINTERFACE_IMPL_12( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< I1* >(this)), \ + (static_cast< I2* >(this)), \ + (static_cast< I3* >(this)), \ + (static_cast< I4* >(this)), \ + (static_cast< I5* >(this)), \ + (static_cast< I6* >(this)), \ + (static_cast< I7* >(this)), \ + (static_cast< I8* >(this)), \ + (static_cast< I9* >(this)), \ + (static_cast< I10* >(this)), \ + (static_cast< I11* >(this)), \ + (static_cast< I12* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 13 interfaces implemented +#define XINTERFACE_IMPL_13( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< I1* >(this)), \ + (static_cast< I2* >(this)), \ + (static_cast< I3* >(this)), \ + (static_cast< I4* >(this)), \ + (static_cast< I5* >(this)), \ + (static_cast< I6* >(this)), \ + (static_cast< I7* >(this)), \ + (static_cast< I8* >(this)), \ + (static_cast< I9* >(this)), \ + (static_cast< I10* >(this)), \ + (static_cast< I11* >(this)), \ + (static_cast< I12* >(this)), \ + (static_cast< I13* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 14 interfaces implemented +#define XINTERFACE_IMPL_14( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13,I14 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< I1* >(this)), \ + (static_cast< I2* >(this)), \ + (static_cast< I3* >(this)), \ + (static_cast< I4* >(this)), \ + (static_cast< I5* >(this)), \ + (static_cast< I6* >(this)), \ + (static_cast< I7* >(this)), \ + (static_cast< I8* >(this)), \ + (static_cast< I9* >(this)), \ + (static_cast< I10* >(this)), \ + (static_cast< I11* >(this)), \ + (static_cast< I12* >(this)), \ + (static_cast< I13* >(this)), \ + (static_cast< I14* >(this)) \ +QUERYINTERFACE_IMPL_END + +// 15 interfaces implemented +#define XINTERFACE_IMPL_15( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13,I14,I15 ) \ +XINTERFACE_COMMON_IMPL( Class ) \ +QUERYINTERFACE_IMPL_START( Class ) \ + (static_cast< I1* >(this)), \ + (static_cast< I2* >(this)), \ + (static_cast< I3* >(this)), \ + (static_cast< I4* >(this)), \ + (static_cast< I5* >(this)), \ + (static_cast< I6* >(this)), \ + (static_cast< I7* >(this)), \ + (static_cast< I8* >(this)), \ + (static_cast< I9* >(this)), \ + (static_cast< I10* >(this)), \ + (static_cast< I11* >(this)), \ + (static_cast< I12* >(this)), \ + (static_cast< I13* >(this)), \ + (static_cast< I14* >(this)), \ + (static_cast< I15* >(this)) \ +QUERYINTERFACE_IMPL_END + +//========================================================================= +// +// XTypeProvider decl. +// +//========================================================================= + +#define XTYPEPROVIDER_DECL() \ + virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL \ + getImplementationId() \ + throw( com::sun::star::uno::RuntimeException ); \ + virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL \ + getTypes() \ + throw( com::sun::star::uno::RuntimeException ); + +//========================================================================= +// +// XTypeProvider impl. internals +// +//========================================================================= + +#define XTYPEPROVIDER_COMMON_IMPL( Class ) \ +com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL \ +Class::getImplementationId() \ + throw( com::sun::star::uno::RuntimeException ) \ +{ \ + static cppu::OImplementationId* pId = NULL; \ + if ( !pId ) \ + { \ + osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); \ + if ( !pId ) \ + { \ + static cppu::OImplementationId id( sal_False ); \ + pId = &id; \ + } \ + } \ + return (*pId).getImplementationId(); \ +} + +#define GETTYPES_IMPL_START( Class ) \ +com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL \ +Class::getTypes() \ + throw( com::sun::star::uno::RuntimeException ) \ +{ \ + static cppu::OTypeCollection* pCollection = NULL; \ + if ( !pCollection ) \ + { \ + osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); \ + if ( !pCollection ) \ + { \ + static cppu::OTypeCollection collection( + +#define GETTYPES_IMPL_END \ + ); \ + pCollection = &collection; \ + } \ + } \ + return (*pCollection).getTypes(); \ +} + +//========================================================================= +// +// XTypeProvider impl. +// +//========================================================================= + +// 1 interface supported +#define XTYPEPROVIDER_IMPL_1( Class, I1 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ) \ +GETTYPES_IMPL_END + +// 2 interfaces supported +#define XTYPEPROVIDER_IMPL_2( Class, I1,I2 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ) \ +GETTYPES_IMPL_END + +// 3 interfaces supported +#define XTYPEPROVIDER_IMPL_3( Class, I1,I2,I3 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ), \ + CPPU_TYPE_REF( I3 ) \ +GETTYPES_IMPL_END + +// 4 interfaces supported +#define XTYPEPROVIDER_IMPL_4( Class, I1,I2,I3,I4 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ), \ + CPPU_TYPE_REF( I3 ), \ + CPPU_TYPE_REF( I4 ) \ +GETTYPES_IMPL_END + +// 5 interfaces supported +#define XTYPEPROVIDER_IMPL_5( Class, I1,I2,I3,I4,I5 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ), \ + CPPU_TYPE_REF( I3 ), \ + CPPU_TYPE_REF( I4 ), \ + CPPU_TYPE_REF( I5 ) \ +GETTYPES_IMPL_END + +// 6 interfaces supported +#define XTYPEPROVIDER_IMPL_6( Class, I1,I2,I3,I4,I5,I6 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ), \ + CPPU_TYPE_REF( I3 ), \ + CPPU_TYPE_REF( I4 ), \ + CPPU_TYPE_REF( I5 ), \ + CPPU_TYPE_REF( I6 ) \ +GETTYPES_IMPL_END + +// 7 interfaces supported +#define XTYPEPROVIDER_IMPL_7( Class, I1,I2,I3,I4,I5,I6,I7 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ), \ + CPPU_TYPE_REF( I3 ), \ + CPPU_TYPE_REF( I4 ), \ + CPPU_TYPE_REF( I5 ), \ + CPPU_TYPE_REF( I6 ), \ + CPPU_TYPE_REF( I7 ) \ +GETTYPES_IMPL_END + +// 8 interfaces supported +#define XTYPEPROVIDER_IMPL_8( Class, I1,I2,I3,I4,I5,I6,I7,I8 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ), \ + CPPU_TYPE_REF( I3 ), \ + CPPU_TYPE_REF( I4 ), \ + CPPU_TYPE_REF( I5 ), \ + CPPU_TYPE_REF( I6 ), \ + CPPU_TYPE_REF( I7 ), \ + CPPU_TYPE_REF( I8 ) \ +GETTYPES_IMPL_END + +// 9 interfaces supported +#define XTYPEPROVIDER_IMPL_9( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ), \ + CPPU_TYPE_REF( I3 ), \ + CPPU_TYPE_REF( I4 ), \ + CPPU_TYPE_REF( I5 ), \ + CPPU_TYPE_REF( I6 ), \ + CPPU_TYPE_REF( I7 ), \ + CPPU_TYPE_REF( I8 ), \ + CPPU_TYPE_REF( I9 ) \ +GETTYPES_IMPL_END + +// 10 interfaces supported +#define XTYPEPROVIDER_IMPL_10( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ), \ + CPPU_TYPE_REF( I3 ), \ + CPPU_TYPE_REF( I4 ), \ + CPPU_TYPE_REF( I5 ), \ + CPPU_TYPE_REF( I6 ), \ + CPPU_TYPE_REF( I7 ), \ + CPPU_TYPE_REF( I8 ), \ + CPPU_TYPE_REF( I9 ), \ + CPPU_TYPE_REF( I10 ) \ +GETTYPES_IMPL_END + +// 11 interfaces supported +#define XTYPEPROVIDER_IMPL_11( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ), \ + CPPU_TYPE_REF( I3 ), \ + CPPU_TYPE_REF( I4 ), \ + CPPU_TYPE_REF( I5 ), \ + CPPU_TYPE_REF( I6 ), \ + CPPU_TYPE_REF( I7 ), \ + CPPU_TYPE_REF( I8 ), \ + CPPU_TYPE_REF( I9 ), \ + CPPU_TYPE_REF( I10 ), \ + CPPU_TYPE_REF( I11 ) \ +GETTYPES_IMPL_END + +// 12 interfaces supported +#define XTYPEPROVIDER_IMPL_12( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ), \ + CPPU_TYPE_REF( I3 ), \ + CPPU_TYPE_REF( I4 ), \ + CPPU_TYPE_REF( I5 ), \ + CPPU_TYPE_REF( I6 ), \ + CPPU_TYPE_REF( I7 ), \ + CPPU_TYPE_REF( I8 ), \ + CPPU_TYPE_REF( I9 ), \ + CPPU_TYPE_REF( I10 ), \ + CPPU_TYPE_REF( I11 ), \ + CPPU_TYPE_REF( I12 ) \ +GETTYPES_IMPL_END + +// 13 interfaces supported +#define XTYPEPROVIDER_IMPL_13( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ), \ + CPPU_TYPE_REF( I3 ), \ + CPPU_TYPE_REF( I4 ), \ + CPPU_TYPE_REF( I5 ), \ + CPPU_TYPE_REF( I6 ), \ + CPPU_TYPE_REF( I7 ), \ + CPPU_TYPE_REF( I8 ), \ + CPPU_TYPE_REF( I9 ), \ + CPPU_TYPE_REF( I10 ), \ + CPPU_TYPE_REF( I11 ), \ + CPPU_TYPE_REF( I12 ), \ + CPPU_TYPE_REF( I13 ) \ +GETTYPES_IMPL_END + +// 14 interfaces supported +#define XTYPEPROVIDER_IMPL_14( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13,I14 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ), \ + CPPU_TYPE_REF( I3 ), \ + CPPU_TYPE_REF( I4 ), \ + CPPU_TYPE_REF( I5 ), \ + CPPU_TYPE_REF( I6 ), \ + CPPU_TYPE_REF( I7 ), \ + CPPU_TYPE_REF( I8 ), \ + CPPU_TYPE_REF( I9 ), \ + CPPU_TYPE_REF( I10 ), \ + CPPU_TYPE_REF( I11 ), \ + CPPU_TYPE_REF( I12 ), \ + CPPU_TYPE_REF( I13 ), \ + CPPU_TYPE_REF( I14 ) \ +GETTYPES_IMPL_END + +// 15 interfaces supported +#define XTYPEPROVIDER_IMPL_15( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13,I14,I15 ) \ +XTYPEPROVIDER_COMMON_IMPL( Class ) \ +GETTYPES_IMPL_START( Class ) \ + CPPU_TYPE_REF( I1 ), \ + CPPU_TYPE_REF( I2 ), \ + CPPU_TYPE_REF( I3 ), \ + CPPU_TYPE_REF( I4 ), \ + CPPU_TYPE_REF( I5 ), \ + CPPU_TYPE_REF( I6 ), \ + CPPU_TYPE_REF( I7 ), \ + CPPU_TYPE_REF( I8 ), \ + CPPU_TYPE_REF( I9 ), \ + CPPU_TYPE_REF( I10 ), \ + CPPU_TYPE_REF( I11 ), \ + CPPU_TYPE_REF( I12 ), \ + CPPU_TYPE_REF( I13 ), \ + CPPU_TYPE_REF( I14 ), \ + CPPU_TYPE_REF( I15 ) \ +GETTYPES_IMPL_END + +//========================================================================= +// +// XServiceInfo decl. +// +//========================================================================= + +#define XSERVICEINFO_NOFACTORY_DECL() \ + virtual OUString SAL_CALL \ + getImplementationName() \ + throw( com::sun::star::uno::RuntimeException ); \ + virtual sal_Bool SAL_CALL \ + supportsService( const OUString& ServiceName ) \ + throw( com::sun::star::uno::RuntimeException ); \ + virtual com::sun::star::uno::Sequence< OUString > SAL_CALL \ + getSupportedServiceNames() \ + throw( com::sun::star::uno::RuntimeException ); \ + \ + static OUString \ + getImplementationName_Static(); \ + static com::sun::star::uno::Sequence< OUString > \ + getSupportedServiceNames_Static(); + +#define XSERVICEINFO_DECL() \ + XSERVICEINFO_NOFACTORY_DECL() \ + \ + static com::sun::star::uno::Reference< \ + com::sun::star::lang::XSingleServiceFactory > \ + createServiceFactory( const com::sun::star::uno::Reference< \ + com::sun::star::lang::XMultiServiceFactory >& rxServiceMgr ); + +//========================================================================= +// +// XServiceInfo impl. internals +// +//========================================================================= + +#define XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ +OUString SAL_CALL Class::getImplementationName() \ + throw( com::sun::star::uno::RuntimeException ) \ +{ \ + return getImplementationName_Static(); \ +} \ + \ +OUString Class::getImplementationName_Static() \ +{ \ + return ImplName; \ +} \ + \ +sal_Bool SAL_CALL \ +Class::supportsService( const OUString& ServiceName ) \ + throw( com::sun::star::uno::RuntimeException ) \ +{ \ + com::sun::star::uno::Sequence< OUString > aSNL = \ + getSupportedServiceNames(); \ + const OUString* pArray = aSNL.getArray(); \ + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) \ + { \ + if( pArray[ i ] == ServiceName ) \ + return sal_True; \ + } \ + \ + return sal_False; \ +} \ + \ +com::sun::star::uno::Sequence< OUString > SAL_CALL \ +Class::getSupportedServiceNames() \ + throw( com::sun::star::uno::RuntimeException ) \ +{ \ + return getSupportedServiceNames_Static(); \ +} + +#define XSERVICEINFO_CREATE_INSTANCE_IMPL( Class ) \ +static com::sun::star::uno::Reference< \ + com::sun::star::uno::XInterface > SAL_CALL \ +Class##_CreateInstance( const com::sun::star::uno::Reference< \ + com::sun::star::lang::XMultiServiceFactory> & rSMgr ) \ + throw( com::sun::star::uno::Exception ) \ +{ \ + com::sun::star::lang::XServiceInfo* pX = \ + (com::sun::star::lang::XServiceInfo*)new Class( rSMgr ); \ + return com::sun::star::uno::Reference< \ + com::sun::star::uno::XInterface >::query( pX ); \ +} + +#define XSERVICEINFO_CREATE_INSTANCE_IMPL_CTX( Class ) \ +static com::sun::star::uno::Reference< \ + com::sun::star::uno::XInterface > SAL_CALL \ +Class##_CreateInstance( const com::sun::star::uno::Reference< \ + com::sun::star::lang::XMultiServiceFactory> & rSMgr ) \ + throw( com::sun::star::uno::Exception ) \ +{ \ + com::sun::star::lang::XServiceInfo* pX = \ + (com::sun::star::lang::XServiceInfo*)new Class( ucbhelper::getComponentContext(rSMgr) ); \ + return com::sun::star::uno::Reference< \ + com::sun::star::uno::XInterface >::query( pX ); \ +} + +//========================================================================= +// +// XServiceInfo impl. +// +//========================================================================= + +#define ONE_INSTANCE_SERVICE_FACTORY_IMPL( Class ) \ +com::sun::star::uno::Reference< \ + com::sun::star::lang::XSingleServiceFactory > \ +Class::createServiceFactory( const com::sun::star::uno::Reference< \ + com::sun::star::lang::XMultiServiceFactory >& rxServiceMgr ) \ +{ \ + return com::sun::star::uno::Reference< \ + com::sun::star::lang::XSingleServiceFactory >( \ + cppu::createOneInstanceFactory( \ + rxServiceMgr, \ + Class::getImplementationName_Static(), \ + Class##_CreateInstance, \ + Class::getSupportedServiceNames_Static() ) ); \ +} + +// Service without service factory. + +// Own implementation of getSupportedServiceNames_Static(). +#define XSERVICEINFO_NOFACTORY_IMPL_0( Class, ImplName ) \ +XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ + \ +com::sun::star::uno::Sequence< OUString > \ +Class::getSupportedServiceNames_Static() + +// 1 service name +#define XSERVICEINFO_NOFACTORY_IMPL_1( Class, ImplName, Service1 ) \ +XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ + \ +com::sun::star::uno::Sequence< OUString > \ +Class::getSupportedServiceNames_Static() \ +{ \ + com::sun::star::uno::Sequence< OUString > aSNS( 1 ); \ + aSNS.getArray()[ 0 ] = Service1; \ + return aSNS; \ +} + +// Service with service factory. + +// Own implementation of getSupportedServiceNames_Static(). +#define XSERVICEINFO_IMPL_0( Class, ImplName ) \ +XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ +XSERVICEINFO_CREATE_INSTANCE_IMPL( Class ) \ + \ +com::sun::star::uno::Sequence< OUString > \ +Class::getSupportedServiceNames_Static() + +// Own implementation of getSupportedServiceNames_Static(). +#define XSERVICEINFO_IMPL_0_CTX( Class, ImplName ) \ +XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ +XSERVICEINFO_CREATE_INSTANCE_IMPL_CTX( Class ) \ + \ +com::sun::star::uno::Sequence< OUString > \ +Class::getSupportedServiceNames_Static() + +// 1 service name +#define XSERVICEINFO_IMPL_1( Class, ImplName, Service1 ) \ +XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ +XSERVICEINFO_CREATE_INSTANCE_IMPL( Class ) \ + \ +com::sun::star::uno::Sequence< OUString > \ +Class::getSupportedServiceNames_Static() \ +{ \ + com::sun::star::uno::Sequence< OUString > aSNS( 1 ); \ + aSNS.getArray()[ 0 ] = Service1; \ + return aSNS; \ +} + +// 1 service name +#define XSERVICEINFO_IMPL_1_CTX( Class, ImplName, Service1 ) \ +XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ +XSERVICEINFO_CREATE_INSTANCE_IMPL_CTX( Class ) \ + \ +com::sun::star::uno::Sequence< OUString > \ +Class::getSupportedServiceNames_Static() \ +{ \ + com::sun::star::uno::Sequence< OUString > aSNS( 1 ); \ + aSNS.getArray()[ 0 ] = Service1; \ + return aSNS; \ +} + +#endif /* !_UCBHELPER_MACROS_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/propertyvalueset.hxx b/include/ucbhelper/propertyvalueset.hxx new file mode 100644 index 000000000000..91459e828ef3 --- /dev/null +++ b/include/ucbhelper/propertyvalueset.hxx @@ -0,0 +1,275 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_PROPERTYVALUESET_HXX +#define _UCBHELPER_PROPERTYVALUESET_HXX + +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/sdbc/XColumnLocate.hpp> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/beans/Property.hpp> +#include <cppuhelper/weak.hxx> + +#include "osl/mutex.hxx" +#include <ucbhelper/macros.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace com { namespace sun { namespace star { namespace script { + class XTypeConverter; +} } } } + +namespace com { namespace sun { namespace star { namespace beans { + struct PropertyValue; + class XPropertySet; +} } } } + +namespace ucbhelper { + +class PropertyValues; + +//========================================================================= + +/** + * This class implements the interface XRow. After construction of a valueset + * the user can append properties ( incl. its values ) to the set. This class + * is useful when implementing the command "getPropertyValues", because the + * values to return can easyly appended to a valueset object. That object can + * directly be returned by the implementation of the command. + */ +class UCBHELPER_DLLPUBLIC PropertyValueSet : + public cppu::OWeakObject, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::sdbc::XRow, + public com::sun::star::sdbc::XColumnLocate +{ + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + m_xContext; + com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter > + m_xTypeConverter; + osl::Mutex m_aMutex; + PropertyValues* m_pValues; + sal_Bool m_bWasNull; + sal_Bool m_bTriedToGetTypeConverter; + +private: + UCBHELPER_DLLPRIVATE const com::sun::star::uno::Reference< + com::sun::star::script::XTypeConverter >& + getTypeConverter(); + +public: + PropertyValueSet( + const com::sun::star::uno::Reference< + com::sun::star::uno::XComponentContext >& rxContext ); + virtual ~PropertyValueSet(); + + // XInterface + XINTERFACE_DECL() + + // XTypeProvider + XTYPEPROVIDER_DECL() + + // XRow + virtual sal_Bool SAL_CALL + wasNull() + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual OUString SAL_CALL + getString( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + getBoolean( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual sal_Int8 SAL_CALL + getByte( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual sal_Int16 SAL_CALL + getShort( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual sal_Int32 SAL_CALL + getInt( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual sal_Int64 SAL_CALL + getLong( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual float SAL_CALL + getFloat( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual double SAL_CALL + getDouble( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL + getBytes( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::util::Date SAL_CALL + getDate( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::util::Time SAL_CALL + getTime( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::util::DateTime SAL_CALL + getTimestamp( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::io::XInputStream > SAL_CALL + getBinaryStream( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::io::XInputStream > SAL_CALL + getCharacterStream( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Any SAL_CALL + getObject( sal_Int32 columnIndex, + const ::com::sun::star::uno::Reference< + ::com::sun::star::container::XNameAccess >& typeMap ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::sdbc::XRef > SAL_CALL + getRef( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::sdbc::XBlob > SAL_CALL + getBlob( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::sdbc::XClob > SAL_CALL + getClob( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::sdbc::XArray > SAL_CALL + getArray( sal_Int32 columnIndex ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + + // XColumnLocate + virtual sal_Int32 SAL_CALL + findColumn( const OUString& columnName ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + + ////////////////////////////////////////////////////////////////////// + // Non-interface methods + ////////////////////////////////////////////////////////////////////// + + void appendString( const OUString& rPropName, const OUString& rValue ); + void appendString( const sal_Char* pAsciiPropName, const OUString& rValue ) + { + appendString( OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendString( const ::com::sun::star::beans::Property& rProp, const OUString& rValue ) + { + appendString( rProp.Name, rValue ); + } + + void appendBoolean( const OUString& rPropName, sal_Bool bValue ); + void appendBoolean( const sal_Char* pAsciiPropName, sal_Bool bValue ) + { + appendBoolean( OUString::createFromAscii( pAsciiPropName ), bValue ); + } + void appendBoolean( const ::com::sun::star::beans::Property& rProp, sal_Bool bValue ) + { + appendBoolean( rProp.Name, bValue ); + } + + void appendLong( const OUString& rPropName, sal_Int64 nValue ); + void appendLong( const sal_Char* pAsciiPropName, sal_Int64 nValue ) + { + appendLong( OUString::createFromAscii( pAsciiPropName ), nValue ); + } + void appendLong( const ::com::sun::star::beans::Property& rProp, sal_Int64 nValue ) + { + appendLong( rProp.Name, nValue ); + } + + void appendTimestamp( const OUString& rPropName, const ::com::sun::star::util::DateTime& rValue ); + void appendTimestamp( const sal_Char* pAsciiPropName, const ::com::sun::star::util::DateTime& rValue ) + { + appendTimestamp( OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendTimestamp( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::util::DateTime& rValue ) + { + appendTimestamp( rProp.Name, rValue ); + } + + void appendObject( const OUString& rPropName, const ::com::sun::star::uno::Any& rValue ); + void appendObject( const sal_Char* pAsciiPropName, const ::com::sun::star::uno::Any& rValue ) + { + appendObject( OUString::createFromAscii( pAsciiPropName ), rValue ); + } + void appendObject( const ::com::sun::star::beans::Property& rProp, const ::com::sun::star::uno::Any& rValue ) + { + appendObject( rProp.Name, rValue ); + } + + void appendVoid( const OUString& rPropName ); + void appendVoid( const sal_Char* pAsciiPropName) + { + appendVoid( OUString::createFromAscii( pAsciiPropName ) ); + } + void appendVoid( const ::com::sun::star::beans::Property& rProp ) + { + appendVoid( rProp.Name ); + } + + /** + * This method tries to append all property values contained in a + * property set to the value set. + * + * @param rSet is a property set containing the property values. + */ + void appendPropertySet( const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet >& rSet ); + + /** This method tries to append a single property value contained in a + * property set to the value set. + * + * @param rSet is a property set containing the property values. + * @param rProperty is the property for that the value shall be obtained + * from the given property set. + * @return False, if the property value cannot be obtained from the + * given property pet. True, otherwise. + */ + sal_Bool appendPropertySetValue( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet >& rSet, + const ::com::sun::star::beans::Property& rProperty ); +}; + +} + +#endif /* !_UCBHELPER_PROPERTYVALUESET_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/providerhelper.hxx b/include/ucbhelper/providerhelper.hxx new file mode 100644 index 000000000000..827d5c8379b2 --- /dev/null +++ b/include/ucbhelper/providerhelper.hxx @@ -0,0 +1,278 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_PROVIDERHELPER_HXX +#define _UCBHELPER_PROVIDERHELPER_HXX + +#ifndef __LIST__ +#include <list> +#endif +#include <com/sun/star/ucb/XContentProvider.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <cppuhelper/weak.hxx> + +#include "osl/mutex.hxx" +#include "rtl/ref.hxx" +#include <ucbhelper/macros.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + +//========================================================================= + +namespace com { namespace sun { namespace star { namespace ucb { + class XPropertySetRegistry; + class XPersistentPropertySet; +} } } } + +namespace ucbhelper_impl { struct ContentProviderImplHelper_Impl; } + +namespace ucbhelper { + +//========================================================================= + +class ContentImplHelper; +typedef rtl::Reference< ContentImplHelper > ContentImplHelperRef; +typedef std::list< ContentImplHelperRef > ContentRefList; + +/** + * This is an abstract base class for implementations of the service + * com.sun.star.ucb.ContentProvider. It provides contents derived from + * class ucb::ContentImplHelper. + * + * Features of the base class implementation: + * - standard interfaces ( XInterface, XTypeProvider, XServiceInfo ) + * - maintains a set of ContentImplHelper objects, which were created by + * the provider implementation. So there will be exactly one object for + * one Content Identifier. + * - Provides access to the Additional Core PropertySet of a content. + * ( These set contains the properties added to a content using its + * XPropertyContainer interface ) + */ +class UCBHELPER_DLLPUBLIC ContentProviderImplHelper : public cppu::OWeakObject, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::lang::XServiceInfo, + public com::sun::star::ucb::XContentProvider +{ + friend class ContentImplHelper; + + ucbhelper_impl::ContentProviderImplHelper_Impl* m_pImpl; + +protected: + osl::Mutex m_aMutex; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + +private: + UCBHELPER_DLLPRIVATE void removeContent( ContentImplHelper* pContent ); + + UCBHELPER_DLLPRIVATE ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XPropertySetRegistry > + getAdditionalPropertySetRegistry(); + + UCBHELPER_DLLPRIVATE void cleanupRegisteredContents(); + +protected: + /** + * This method returns a content with the given id, if it already exists. + * Use this method in your "queryContent" implementation to ensure unique + * objects. + * + * @param Identifier is the content identifier, for that an existing + * content object is requested. + * @return the content with the given identifier, if it exists or 0, if it + * does not exist. + */ + rtl::Reference< ContentImplHelper > + queryExistingContent( const ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XContentIdentifier >& Identifier ); + + /** + * This method returns a content with the given URL, if it already exists. + * + * @param rURL is the URL ( content identifier string ), for that an + * existing content object is requested. + * @return the content with the given URL, if it exists or 0, if it + * does not exist. + */ + rtl::Reference< ContentImplHelper > + queryExistingContent( const OUString& rURL ); + + /** + * This method registers a newly created content instance with the + * content provider. It should be called directly after creating a new + * content instance. The provider can reuse a registered instance upon + * subsedent requests for content instances with an idententifier + * of a registered instance. + * Note that the provider does not hold a hard reference on the + * registered instance. If last external reference is gone, the provider + * will remove the instance from its inventory of known instances. + * Nothing will happen in case an already registered instance shall + * be registered more than once. + * + * @param the content instance that is to be registered. + */ + void registerNewContent( + const com::sun::star::uno::Reference< + ::com::sun::star::ucb::XContent > & xContent ); + +public: + + ////////////////////////////////////////////////////////////////////// + // Contsruction/Destruction + ////////////////////////////////////////////////////////////////////// + + ContentProviderImplHelper( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& rxContext ); + virtual ~ContentProviderImplHelper(); + + ////////////////////////////////////////////////////////////////////// + // XInterface + ////////////////////////////////////////////////////////////////////// + + XINTERFACE_DECL() + + ////////////////////////////////////////////////////////////////////// + // XTypeProvider + ////////////////////////////////////////////////////////////////////// + + XTYPEPROVIDER_DECL() + + ////////////////////////////////////////////////////////////////////// + // XServiceInfo + ////////////////////////////////////////////////////////////////////// + + virtual OUString SAL_CALL + getImplementationName() + throw( ::com::sun::star::uno::RuntimeException ) = 0; + virtual sal_Bool SAL_CALL + supportsService( const OUString& ServiceName ) + throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() + throw( ::com::sun::star::uno::RuntimeException ) = 0; + + ////////////////////////////////////////////////////////////////////// + // XContentProvider + ////////////////////////////////////////////////////////////////////// + + /** + * This method returns a content with the requested id. + * + * The implementation should: + * + * - Check, whether the Identifier is valid ( URL syntax ). + * - Use queryExistingContent(...) to determine, whether there exists + * already a content with the given id. + * - Return the possibly existing content.Create and return a new + * content, otherwise + */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XContent > SAL_CALL + queryContent( const ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XContentIdentifier >& Identifier ) + throw( ::com::sun::star::ucb::IllegalIdentifierException, + ::com::sun::star::uno::RuntimeException ) = 0; + virtual sal_Int32 SAL_CALL + compareContentIds( const ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XContentIdentifier >& Id1, + const ::com::sun::star::uno::Reference< + ::com::sun::star::ucb::XContentIdentifier >& Id2 ) + throw( ::com::sun::star::uno::RuntimeException ); + + ////////////////////////////////////////////////////////////////////// + // Non-interface methods. + ////////////////////////////////////////////////////////////////////// + + /** + * This method returns a mutex, which protects the content list of the + * provider. So you can prevent modifications of that list easyly. + * + * @return the mutex. + */ + osl::Mutex& getContentListMutex() { return m_aMutex; } + + /** + * This method fills a list with all contents existing at calling time. + * Note: You may prevent modifications of the content list at any time + * by acquiring the content list mutex of the provider. + * + * @param rContents is the list to fill with the children. + */ + void queryExistingContents( ContentRefList& rContents ); + + /** + * This method returns the propertyset containing the Additional Core + * Properties of a content. + * + * @param rKey is the key for the propertyset. + * @param bCreate is a flag indicating whether the propertyset shall + * be created in case it does not exist. + * @return the propertyset containing the Additional Core Properties. + */ + ::com::sun::star::uno::Reference< + com::sun::star::ucb::XPersistentPropertySet > + getAdditionalPropertySet( const OUString& rKey, sal_Bool bCreate ); + + /** + * This method renames the propertyset containing the Additional Core + * Properties of a content. + * + * @param rOldKey is the old key of the propertyset. + * @param rNewKey is the new key for the propertyset. + * @param bRecursive is a flag indicating whether propertysets for + * children described by rOldKey shall be renamed, too. + * @return True, if the operation succeeded - False, otherwise. + */ + sal_Bool renameAdditionalPropertySet( const OUString& rOldKey, + const OUString& rNewKey, + sal_Bool bRecursive ); + + /** + * This method copies the propertyset containing the Additional Core + * Properties of a content. + * + * @param rSourceKey is the key of the source propertyset. + * @param rTargetKey is the key of the target propertyset. + * @param bRecursive is a flag indicating whether propertysets for + * children described by rSourceKey shall be copied, too. + * @return True, if the operation succeeded - False, otherwise. + */ + sal_Bool copyAdditionalPropertySet( const OUString& rSourceKey, + const OUString& rTargetKey, + sal_Bool bRecursive ); + + /** + * This method removes the propertyset containing the Additional Core + * Properties of a content. + * + * @param rKey is the key of the propertyset. + * @param bRecursive is a flag indicating whether propertysets for + * children described by rOldKey shall be removed, too. + * @return True, if the operation succeeded - False, otherwise. + */ + sal_Bool removeAdditionalPropertySet( const OUString& rKey, + sal_Bool bRecursive ); +}; + +} // namespace ucbhelper + +#endif /* !_UCBHELPER_PROVIDERHELPER_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/proxydecider.hxx b/include/ucbhelper/proxydecider.hxx new file mode 100644 index 000000000000..e3ec58180a00 --- /dev/null +++ b/include/ucbhelper/proxydecider.hxx @@ -0,0 +1,138 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_PROXYDECIDER_HXX +#define _UCBHELPER_PROXYDECIDER_HXX + +#include <rtl/ustring.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace com { namespace sun { namespace star { namespace lang { + class XMultiServiceFactory; +} } } } + +namespace ucbhelper +{ + +/** + * This struct describes a proxy server. + */ +struct InternetProxyServer +{ + /** + * The name of the proxy server. + */ + OUString aName; + + /** + * The port of the proxy server. + */ + sal_Int32 nPort; + + /** + * Constructor. + */ + InternetProxyServer() : nPort( -1 ) {} +}; + +namespace proxydecider_impl { class InternetProxyDecider_Impl; } + +/** + * This class is able to decide whether and which internet proxy server is to + * be used to access a given URI. + * + * The implementation reads the internet proxy settings from Office + * configuration. It listens for configuration changes and adapts itself + * accordingly. Because configuration data can change during runtime clients + * should not cache results obtained from InternetProxyDecider instances. One + * instance should be kept to be queried multiple times instead. + */ +class UCBHELPER_DLLPUBLIC InternetProxyDecider +{ +public: + /** + * Constructor. + * + * Note: Every instance should be held alive as long as possible because + * because construction is quite expensive. + * + * @param rxSMgr is a Service Manager. + */ + InternetProxyDecider( const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& rxContext ); + + /** + * Destructor. + */ + ~InternetProxyDecider(); + + /** + * Informs whether a proxy server should be used. + * + * @param rProtocol contains the internet protocol to be used to + * access the server (i.e. "ftp", "http"). The protocol string + * is handled case-insensitive and must not be empty. + * @param rHost contains the name of the server that should be accessed. + * This parameter might be left empty. In this case the + * implementation will return whether a proxy is configured + * for the given protocol. + * @param nPort contains the port of the server that should be accessed. + * If host is not empty this parameter must always contain a valid + * port number, for instance the default port for the requested + * protocol(i.e. 80 or http). + * @return true if a proxy server should be used, false otherwise. + */ + bool + shouldUseProxy( const OUString & rProtocol, + const OUString & rHost, + sal_Int32 nPort ) const; + + /** + * Returns the proxy server to be used. + * + * @param rProtocol contains the internet protocol to be used to + * access the server (i.e. "ftp", "http"). The protocol string + * is handled case-insensitive and must not be empty. + * @param rHost contains the name of the server that should be accessed. + * This parameter might be left empty. In this case the + * implementation will return the proxy that is configured + * for the given protocol. + * @param nPort contains the port of the server that should be accessed. + * If host is not empty this parameter must always contain a valid + * port number, for instance the default port for the requested + * protocol(i.e. 80 or http). + * @return a InternetProxyServer reference. If member aName of the + * InternetProxyServer is empty no proxy server is to be used. + */ + const InternetProxyServer & + getProxy( const OUString & rProtocol, + const OUString & rHost, + sal_Int32 nPort ) const; + +private: + proxydecider_impl::InternetProxyDecider_Impl * m_pImpl; +}; + +} // namespace ucbhelper + +#endif /* !_UCBHELPER_PROXYDECIDER_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/registerucb.hxx b/include/ucbhelper/registerucb.hxx new file mode 100644 index 000000000000..ab241a2f9cb4 --- /dev/null +++ b/include/ucbhelper/registerucb.hxx @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_REGISTERUCB_HXX_ +#define _UCBHELPER_REGISTERUCB_HXX_ + +#include <com/sun/star/uno/RuntimeException.hpp> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/ucb/XContentProvider.hpp> +#include <com/sun/star/ucb/XContentProviderManager.hpp> +#include <vector> + +#include "ucbhelper/ucbhelperdllapi.h" + +namespace com { namespace sun { namespace star { + namespace lang { class XMultiServiceFactory; } +} } } + + +namespace ucbhelper { + +//============================================================================ +/** Information about a registered content provider. + */ +struct ContentProviderRegistrationInfo +{ + /** The registered content provider (or null if registration failed). + */ + com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > + m_xProvider; + + /** The arguments the content provider was instantiated with. + */ + OUString m_aArguments; + + /** The URL template the content provider is registered on. + */ + OUString m_aTemplate; +}; + +typedef std::vector< ContentProviderRegistrationInfo > + ContentProviderRegistrationInfoList; + +//============================================================================ +/** Information about a content provider, passed to + <method>configureUcb</method>. + */ +struct ContentProviderData +{ + /** The UNO service name to use to instanciate the content provider. + */ + OUString ServiceName; + + /** The URL template to use to instanciate the content provider. + */ + OUString URLTemplate; + + /** The arguments to use to instanciate the content provider. + */ + OUString Arguments; + + ContentProviderData() {}; + ContentProviderData( const OUString & rService, + const OUString & rTemplate, + const OUString & rArgs ) + : ServiceName( rService ), URLTemplate( rTemplate ), Arguments( rArgs ) {} +}; + +typedef std::vector< ContentProviderData > ContentProviderDataList; +//============================================================================ +/** Register a content provider at a Universal Content Broker. + + @param rManager A content provider manager (normally, this would be a + UCB). May be null, which is only useful if the content provider is an + <type>XParamterizedContentProvider</type>s. + + @param rServiceFactory A factory through which to obtain the required + services. + + @param rName The service name of the content provider. + + @param rArguments Any arguments to instantiate the content provider with. + + @param rTemplate The URL template to register the content provider on. + + @param pInfo If not null, this output parameter is filled with + information about the (atemptively) registered provider. + */ + +UCBHELPER_DLLPUBLIC bool registerAtUcb( + com::sun::star::uno::Reference< + com::sun::star::ucb::XContentProviderManager > const & + rManager, + com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory > const & + rServiceFactory, + OUString const & rName, + OUString const & rArguments, + OUString const & rTemplate, + ContentProviderRegistrationInfo * pInfo) + throw (com::sun::star::uno::RuntimeException); + +} +#endif // _UCBHELPER_REGISTERUCB_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/resultset.hxx b/include/ucbhelper/resultset.hxx new file mode 100644 index 000000000000..531955124f2b --- /dev/null +++ b/include/ucbhelper/resultset.hxx @@ -0,0 +1,573 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_RESULTSET_HXX +#define _UCBHELPER_RESULTSET_HXX + +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/ucb/ResultSetException.hpp> +#include <com/sun/star/ucb/XCommandEnvironment.hpp> +#include <com/sun/star/ucb/XContentAccess.hpp> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XCloseable.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +#include "rtl/ref.hxx" +#include "salhelper/simplereferenceobject.hxx" +#include <cppuhelper/weak.hxx> +#include <ucbhelper/macros.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace ucbhelper { + +//========================================================================= + +#define RESULTSET_SERVICE_NAME "com.sun.star.ucb.ContentResultSet" + +//========================================================================= + +class ResultSetDataSupplier; +struct ResultSet_Impl; + +/** + * This is an implementation of the service com.sun.star.ucb.ContentResultSet. + * It can be used to implement the method XDynamicResultSet::getStaticResultSet, + * which needs to be implemented for instance to implement the command "open" + * at folder objects. This class uses a user supplied ResultSetDataSupplier + * object to request data on demand. + * + * @see ResultSetDataSupplier + */ +class UCBHELPER_DLLPUBLIC ResultSet : + 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::ucb::XContentAccess, + public com::sun::star::sdbc::XResultSet, + public com::sun::star::sdbc::XResultSetMetaDataSupplier, + public com::sun::star::sdbc::XRow, + public com::sun::star::sdbc::XCloseable, + public com::sun::star::beans::XPropertySet +{ + ResultSet_Impl* m_pImpl; + +public: + /** + * Construction. + * + * @param rxSMgr is a Service Manager. + * @param rProperties is a sequence of properties for that the resultset + * shall be able to obtain the values. + * @param rDataSupplier is a supplier for the resultset data. + */ + ResultSet( + const com::sun::star::uno::Reference< + com::sun::star::uno::XComponentContext >& rxContext, + const com::sun::star::uno::Sequence< + com::sun::star::beans::Property >& rProperties, + const rtl::Reference< ResultSetDataSupplier >& rDataSupplier ); + /** + * Construction. + * + * @param rxSMgr is a Service Manager. + * @param rProperties is a sequence of properties for that the resultset + * shall be able to obtain the values. + * @param rDataSupplier is a supplier for the resultset data. + * @param rxEnv is the environment for interactions, progress propagation, + * ... + */ + ResultSet( + const com::sun::star::uno::Reference< + com::sun::star::uno::XComponentContext >& rxContext, + const com::sun::star::uno::Sequence< + com::sun::star::beans::Property >& rProperties, + const rtl::Reference< ResultSetDataSupplier >& rDataSupplier, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& rxEnv ); + virtual ~ResultSet(); + + // XInterface + XINTERFACE_DECL() + + // XTypeProvider + XTYPEPROVIDER_DECL() + + // XServiceInfo + XSERVICEINFO_NOFACTORY_DECL() + + // XComponent + virtual void SAL_CALL + dispose() + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + addEventListener( const com::sun::star::uno::Reference< + com::sun::star::lang::XEventListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + removeEventListener( const com::sun::star::uno::Reference< + com::sun::star::lang::XEventListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + + // XContentAccess + virtual OUString SAL_CALL + queryContentIdentifierString() + throw( com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Reference< + com::sun::star::ucb::XContentIdentifier > SAL_CALL + queryContentIdentifier() + throw( com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Reference< + com::sun::star::ucb::XContent > SAL_CALL + queryContent() + throw( com::sun::star::uno::RuntimeException ); + + // XResultSetMetaDataSupplier + virtual com::sun::star::uno::Reference< + com::sun::star::sdbc::XResultSetMetaData > SAL_CALL + getMetaData() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + + // XResultSet + virtual sal_Bool SAL_CALL + next() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + isBeforeFirst() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + isAfterLast() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + isFirst() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + isLast() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + beforeFirst() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + afterLast() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + first() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + last() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Int32 SAL_CALL + getRow() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + absolute( sal_Int32 row ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + relative( sal_Int32 rows ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + previous() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + refreshRow() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + rowUpdated() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + rowInserted() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + rowDeleted() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Reference< + com::sun::star::uno::XInterface > SAL_CALL + getStatement() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + + // XRow + virtual sal_Bool SAL_CALL + wasNull() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual OUString SAL_CALL + getString( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL + getBoolean( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Int8 SAL_CALL + getByte( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Int16 SAL_CALL + getShort( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Int32 SAL_CALL + getInt( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual sal_Int64 SAL_CALL + getLong( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual float SAL_CALL + getFloat( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual double SAL_CALL + getDouble( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL + getBytes( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual com::sun::star::util::Date SAL_CALL + getDate( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual com::sun::star::util::Time SAL_CALL + getTime( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual com::sun::star::util::DateTime SAL_CALL + getTimestamp( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Reference< + com::sun::star::io::XInputStream > SAL_CALL + getBinaryStream( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Reference< + com::sun::star::io::XInputStream > SAL_CALL + getCharacterStream( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Any SAL_CALL + getObject( sal_Int32 columnIndex, + const com::sun::star::uno::Reference< + com::sun::star::container::XNameAccess >& typeMap ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Reference< + com::sun::star::sdbc::XRef > SAL_CALL + getRef( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Reference< + com::sun::star::sdbc::XBlob > SAL_CALL + getBlob( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Reference< + com::sun::star::sdbc::XClob > SAL_CALL + getClob( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Reference< + com::sun::star::sdbc::XArray > SAL_CALL + getArray( sal_Int32 columnIndex ) + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + + // XCloseable + virtual void SAL_CALL + close() + throw( com::sun::star::sdbc::SQLException, + com::sun::star::uno::RuntimeException ); + + // XPropertySet + 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( const OUString& aPropertyName, + const com::sun::star::uno::Any& 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( const OUString& PropertyName ) + throw( com::sun::star::beans::UnknownPropertyException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + addPropertyChangeListener( const OUString& aPropertyName, + const com::sun::star::uno::Reference< + com::sun::star::beans::XPropertyChangeListener >& xListener ) + throw( com::sun::star::beans::UnknownPropertyException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + removePropertyChangeListener( const OUString& aPropertyName, + const com::sun::star::uno::Reference< + com::sun::star::beans::XPropertyChangeListener >& aListener ) + throw( com::sun::star::beans::UnknownPropertyException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + addVetoableChangeListener( const OUString& PropertyName, + const com::sun::star::uno::Reference< + com::sun::star::beans::XVetoableChangeListener >& aListener ) + throw( com::sun::star::beans::UnknownPropertyException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + removeVetoableChangeListener( const OUString& PropertyName, + const com::sun::star::uno::Reference< + com::sun::star::beans::XVetoableChangeListener >& aListener ) + throw( com::sun::star::beans::UnknownPropertyException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException ); + + ///////////////////////////////////////////////////////////////////// + // Non-interface methods. + ///////////////////////////////////////////////////////////////////// + + /** + * This method propagates property value changes to all registered + * listeners. + * + * @param rEvt is a property change event. + */ + void propertyChanged( + const com::sun::star::beans::PropertyChangeEvent& rEvt ); + + /** + * This method should be called by the data supplier for the result set + * to indicate that there were new data obtained from the data source. + * + * @param nOld is the old count of rows; must be non-negative. + * @param nnew is the new count of rows; must be non-negative. + */ + void rowCountChanged( sal_uInt32 nOld, sal_uInt32 nNew ); + + /** + * This method should be called by the data supplier for the result set + * to indicate that there were all rows obtained from the data source. + */ + void rowCountFinal(); + + /** + * This method returns a sequence containing all properties ( not the + * values! ) of the result set. + * + * @return a sequence of properties. + */ + const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& + getProperties(); + + /** + * This method returns the environment to use for interactions, progress + * propagation, ... It can by empty. + * + * @return an environment or an empty reference. + */ + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& + getEnvironment(); +}; + +//========================================================================= + +/** + * This is the base class for an object that supplies data to a result set + * + * @see ResultSet + */ +class ResultSetDataSupplier : public salhelper::SimpleReferenceObject +{ + friend class ResultSet; + + // No ref, otherwise we get a cyclic reference between supplier and set! + // Will be set from ResultSet ctor. + ResultSet* m_pResultSet; + +public: + ResultSetDataSupplier() : m_pResultSet( 0 ) {} + + /** + * This method returns the resultset this supplier belongs to. + * + * @return the resultset for that the supplier supplies data. + */ + rtl::Reference< ResultSet > getResultSet() const { return m_pResultSet; } + + /** + * This method returns the identifier string of the content at the + * specified index. + * + * @param nIndex is the zero-based index within the logical data array + * of the supplier; must be non-negative. + * @return the content's identifier string. + */ + virtual OUString queryContentIdentifierString( sal_uInt32 nIndex ) = 0; + + /** + * This method returns the identifier of the content at the specified index. + * + * @param nIndex is the zero-based index within the logical data array + * of the supplier; must be non-negative. + * @return the content's identifier. + */ + virtual com::sun::star::uno::Reference< + com::sun::star::ucb::XContentIdentifier > + queryContentIdentifier( sal_uInt32 nIndex ) = 0; + + /** + * This method returns the content at the specified index. + * + * @param nIndex is the zero-based index within the logical data array + * of the supplier; must be non-negative. + * @return the content. + */ + virtual com::sun::star::uno::Reference< com::sun::star::ucb::XContent > + queryContent( sal_uInt32 nIndex ) = 0; + + /** + * This method returns whether there is a content at the specified index. + * + * @param nIndex is the zero-based index within the logical data array + * of the supplier; must be non-negative. + * @return true, if there is a content at the given index. + */ + virtual sal_Bool getResult( sal_uInt32 nIndex ) = 0; + + /** + * This method returns the total count of objects in the logical data array + * of the supplier. The implementation of this method may be very + * "expensive", because it can be necessary to obtain all data in order + * to determine the count. Therefor the ResultSet implementation calls + * it very seldom. + * + * @return the total count of objects; will always be non-negative. + */ + virtual sal_uInt32 totalCount() = 0; + + /** + * This method returns the count of objects obtained so far. There is no + * for the implemetation to obtain all objects at once. It can obtain + * all data on demand. + * + * The implementation should call m_pResultSet->rowCountChanged(...) + * everytime it has inserted a new entry in its logical result array. + * + * @return the count of objects obtained so far; will always be + * non-negative. + */ + virtual sal_uInt32 currentCount() = 0; + + /** + * This method returns whether the value returned by currentCount() is + * "final". This is the case, if that there was all data obtained by the + * supplier and the current count won't increase any more. + * + * The implementation should call m_pResultSet->rowCountFinal(...) if + * it has inserted all entries in its logical result array. + * + * @return true, if the value returned by currentCount() won't change + anymore. + */ + virtual sal_Bool isCountFinal() = 0; + + /** + * This method returns an object for accessing the property values at + * the specified index. The implementation may use the helper class + * ucb::PropertyValueSet to provide the return value. + * + * @param nIndex is the zero-based index within the logical data array + * of the supplier. + * @return the object for accessing the property values. + */ + virtual com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > + queryPropertyValues( sal_uInt32 nIndex ) = 0; + + /** + * This method is called to instruct the supplier to release the (possibly + * presnt) property values at the given index. + * + * @param nIndex is the zero-based index within the logical data array + * of the supplier. + */ + virtual void releasePropertyValues( sal_uInt32 nIndex ) = 0; + + /** + * This method will be called by the resultset implementation in order + * to instruct the data supplier to release all resources it has + * allocated so far. In case the supplier is collecting data + * asynchronously, that process must be stopped. + */ + virtual void close() = 0; + + /** + * This method will be called by the resultset implementation in order + * check, whether an error has occurred while collecting data. The + * implementation of this method must throw an exception in that case. + * + * Note: An exception thrown to indicate an error must always be thrown + * by the thread that created the data supplier. If the supplier collects + * data asynchronously ( i.e. in a separate thread ) and an error + * occures, throwing of the appropriate exception must be deferred + * until validate() is called by the ResultSet implementation from + * inside the main thread. + * In case data are obtained synchronously, the ResultSetException can + * be thrown directly. + * + * @exception ResultSetException thrown, if an error has occurred + */ + virtual void validate() + throw( com::sun::star::ucb::ResultSetException ) = 0; +}; + +} + +#endif /* !_UCBHELPER_RESULTSET_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/resultsethelper.hxx b/include/ucbhelper/resultsethelper.hxx new file mode 100644 index 000000000000..80dd0581652d --- /dev/null +++ b/include/ucbhelper/resultsethelper.hxx @@ -0,0 +1,204 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_RESULTSETHELPER_HXX +#define _UCBHELPER_RESULTSETHELPER_HXX + +#include <osl/mutex.hxx> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/ucb/XDynamicResultSet.hpp> +#include <com/sun/star/ucb/XCommandEnvironment.hpp> +#include <com/sun/star/ucb/OpenCommandArgument2.hpp> +#include <cppuhelper/weak.hxx> +#include <ucbhelper/macros.hxx> +#include <ucbhelper/contenthelper.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace cppu { + class OInterfaceContainerHelper; +} + +namespace ucbhelper { + +//========================================================================= + +#define DYNAMICRESULTSET_SERVICE_NAME "com.sun.star.ucb.DynamicResultSet" + +//========================================================================= + +/** + * This is an abstract base class for implementations of the service + * com.sun.star.ucb.DynamicResultSet, which is the result of the command + * "open" executed at a UCB folder content. + * + * Features of the base class implementation: + * - standard interfaces ( XInterface, XTypeProvider, XServiceInfo ) + * - all required interfaces for service com::sun::star::ucb::DynamicResultSet + */ +class UCBHELPER_DLLPUBLIC ResultSetImplHelper : + public cppu::OWeakObject, + public com::sun::star::lang::XTypeProvider, + public com::sun::star::lang::XServiceInfo, + public com::sun::star::ucb::XDynamicResultSet +{ + cppu::OInterfaceContainerHelper* m_pDisposeEventListeners; + sal_Bool m_bStatic; + sal_Bool m_bInitDone; + +protected: + osl::Mutex m_aMutex; + com::sun::star::ucb::OpenCommandArgument2 m_aCommand; + com::sun::star::uno::Reference< + com::sun::star::uno::XComponentContext > m_xContext; + // Resultset #1 + com::sun::star::uno::Reference< + com::sun::star::sdbc::XResultSet > m_xResultSet1; + // Resultset #2 + com::sun::star::uno::Reference< + com::sun::star::sdbc::XResultSet > m_xResultSet2; + // Resultset changes listener. + com::sun::star::uno::Reference< + com::sun::star::ucb::XDynamicResultSetListener > m_xListener; + +private: + UCBHELPER_DLLPRIVATE void init( sal_Bool bStatic ); + + /** + * Your implementation of this method has to fill the protected member + * m_xResultSet1. This resultset must implement a complete static + * resultset ( service com.sun.star.ucb.ContentResultSet ). This method + * will be called at most once in the life of your implementation object. + * After this method was called, the type of this resultset will be + * "static". There is no way to change the type afterwards. + * If this method gets called the client wants to use your resultset + * exclusively statically. You may deploy this factum to optimize your + * implementation (i.e. "switch off" all changes detection code in + * your implementation). + * Note that you may use the class ucb::ResultSet to implement the + * static resultset, that is required here. + */ + UCBHELPER_DLLPRIVATE virtual void initStatic() = 0; + + /** + * Your implementation of this method has to fill the protected members + * m_xResultSet1 and m_xResultSet2 of this base class. Each of these + * resultsets must implement a complete static resultset + * ( service com.sun.star.ucb.ContentResultSet ). This method will be + * called at most once in the life of your implementation object. + * After this method was called, the type of this resultset will be + * "dynamic". There is no way to change the type afterwards. + * If this method gets called the client wants to use your resultset + * exclusively dynamically. This means, it is interested in getting + * notifications on changes of data of the resultset contents. ( These + * changes are to propagate by your implementation throw the member + * m_xListener of this base class ). + * If your implementation cannot detect changes of relevant data, you + * may fill m_xResultSet1 and m_xResultSet2 with the same static resultset + * implementation object. This normally will be the same instance you put + * into m_xResultSet1 when initStatic() is called. + */ + UCBHELPER_DLLPRIVATE virtual void initDynamic() = 0; + +public: + /** + * Construtor. + * + * @param rxContext is a Service Manager. + * @param rCommand is the paramter for the open command that produces + * this resultset. + */ + ResultSetImplHelper( + const com::sun::star::uno::Reference< + com::sun::star::uno::XComponentContext >& rxContext, + const com::sun::star::ucb::OpenCommandArgument2& rCommand ); + + /** + * Destructor. + */ + virtual ~ResultSetImplHelper(); + + // XInterface + XINTERFACE_DECL() + + // XTypeProvider + XTYPEPROVIDER_DECL() + + // XServiceInfo + XSERVICEINFO_NOFACTORY_DECL() + + // XComponent ( base class of XDynamicResultSet ) + virtual void SAL_CALL + dispose() + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + addEventListener( const com::sun::star::uno::Reference< + com::sun::star::lang::XEventListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + removeEventListener( const com::sun::star::uno::Reference< + com::sun::star::lang::XEventListener >& Listener ) + throw( com::sun::star::uno::RuntimeException ); + + // XDynamicResultSet + virtual com::sun::star::uno::Reference< + com::sun::star::sdbc::XResultSet > SAL_CALL + getStaticResultSet() + throw( com::sun::star::ucb::ListenerAlreadySetException, + com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + setListener( const com::sun::star::uno::Reference< + com::sun::star::ucb::XDynamicResultSetListener >& Listener ) + throw( com::sun::star::ucb::ListenerAlreadySetException, + com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL + connectToCache( const com::sun::star::uno::Reference< + com::sun::star::ucb::XDynamicResultSet > & xCache ) + throw( com::sun::star::ucb::ListenerAlreadySetException, + com::sun::star::ucb::AlreadyInitializedException, + com::sun::star::ucb::ServiceNotFoundException, + com::sun::star::uno::RuntimeException ); + + /** + * The implemetation of this method always returns 0. Override this + * method, if necessary. + */ + virtual sal_Int16 SAL_CALL + getCapabilities() + throw( com::sun::star::uno::RuntimeException ); + + ////////////////////////////////////////////////////////////////////// + // Non-interface methods. + ////////////////////////////////////////////////////////////////////// + + /** + * This method returns, whether the resultset is static or dynamic. + * If neither getStatic() nor getDynamic() was called, the type + * of the resultset is "dynamic". + * + * @return true, if the resultset type is "static". False, otherwise. + */ + sal_Bool isStatic() const { return m_bStatic; } +}; + +} + +#endif /* !_UCBHELPER_RESULTSETHELPER_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/resultsetmetadata.hxx b/include/ucbhelper/resultsetmetadata.hxx new file mode 100644 index 000000000000..35996657553a --- /dev/null +++ b/include/ucbhelper/resultsetmetadata.hxx @@ -0,0 +1,470 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_RESULTSETMETADATA_HXX +#define _UCBHELPER_RESULTSETMETADATA_HXX + +#include <vector> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/sdbc/ColumnValue.hpp> +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#include <cppuhelper/weak.hxx> +#include <ucbhelper/macros.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace com { namespace sun { namespace star { + namespace lang { class XMultiServiceFactory; } + namespace beans { struct Property; } +} } } + +namespace ucbhelper_impl { + struct ResultSetMetaData_Impl; +} + +namespace ucbhelper +{ + +//========================================================================= + +/** + * This is a structure that holds additional meta data for one column + * of a resultset. The default values set in the constructor should be a + * good guess for many UCB use cases. + */ +struct ResultSetColumnData +{ + /** @see ResultSetMetaData::isAutoIncrement */ + sal_Bool isAutoIncrement; + + /** @see ResultSetMetaData::isCaseSensitive */ + sal_Bool isCaseSensitive; + + /** @see ResultSetMetaData::isSearchable */ + sal_Bool isSearchable; + + /** @see ResultSetMetaData::isCurrency */ + sal_Bool isCurrency; + + /** @see ResultSetMetaData::isNullable */ + sal_Int32 isNullable; + + /** @see ResultSetMetaData::isSigned */ + sal_Bool isSigned; + + /** @see ResultSetMetaData::getColumnDisplaySize */ + sal_Int32 columnDisplaySize; + + /** @see ResultSetMetaData::getColumnLabel */ + OUString columnLabel; + + /** @see ResultSetMetaData::getSchemaName */ + OUString schemaName; + + /** @see ResultSetMetaData::getPrecision */ + sal_Int32 precision; + + /** @see ResultSetMetaData::getScale */ + sal_Int32 scale; + + /** @see ResultSetMetaData::getTableName */ + OUString tableName; + + /** @see ResultSetMetaData::getCatalogName */ + OUString catalogName; + + /** @see ResultSetMetaData::getColumnTypeName */ + OUString columnTypeName; + + /** @see ResultSetMetaData::isReadOnly */ + sal_Bool isReadOnly; + + /** @see ResultSetMetaData::isWritable */ + sal_Bool isWritable; + + /** @see ResultSetMetaData::isDefinitelyWritable */ + sal_Bool isDefinitelyWritable; + + /** @see ResultSetMetaData::getColumnServiceName */ + OUString columnServiceName; + + inline ResultSetColumnData(); +}; + +// Note: Never change the initial values! Implementations using this struct +// may havily depend on the behaviour of the default constructor. + +ResultSetColumnData::ResultSetColumnData() +: isAutoIncrement( sal_False ), + isCaseSensitive( sal_True ), + isSearchable( sal_False ), + isCurrency( sal_False ), + isNullable( ::com::sun::star::sdbc::ColumnValue::NULLABLE ), + isSigned( sal_False ), + columnDisplaySize( 16 ), + precision( -1 ), + scale( 0 ), + isReadOnly( sal_True ), + isWritable( sal_False ), + isDefinitelyWritable( sal_False ) +{ +} + +//========================================================================= + +/** + * This is an implementation of the interface XResultSetMetaData. It can be + * used to implement the interface + * com::sun::star::sdbc::XResultSetMetaDataSupplier, which is required for + * implementations of service com.sun.star.ucb.ContentResultSet. + */ +class UCBHELPER_DLLPUBLIC ResultSetMetaData : + public ::cppu::OWeakObject, + public ::com::sun::star::lang::XTypeProvider, + public ::com::sun::star::sdbc::XResultSetMetaData +{ +private: + ucbhelper_impl::ResultSetMetaData_Impl* m_pImpl; + +protected: + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::Property > m_aProps; + sal_Bool m_bReadOnly; + +public: + + /** + * Constructor. + * + * @param rxSMgr is a Servive Manager. + * @param rProps is a sequence of properties (partially) describing the + * columns of a resultset. + * @param bReadOnly is used to specify whether the whole(!) resultset + * is read-only. + */ + ResultSetMetaData( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& rxContext, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::Property >& rProps, + sal_Bool bReadOnly = sal_True ); + + /** + * Constructor. + * + * @param rxSMgr is a Servive Manager. + * @param rProps is a sequence of properties (partially) describing the + * columns of a resultset. + * @param rColumnData contains additional meta data for the columns of + * a resultset, which override the default values returned by the + * appropriate methods of this class. The length of rColumnData + * must be the same as length of rProps. + * rColumnData[ 0 ] corresponds to data in rProps[ 0 ], + * rColumnData[ 1 ] corresponds to data in rProps[ 1 ], ... + */ + ResultSetMetaData( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& rxContext, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::Property >& rProps, + const std::vector< ResultSetColumnData >& rColumnData ); + + /** + * Destructor. + */ + virtual ~ResultSetMetaData(); + + // XInterface + XINTERFACE_DECL() + + // XTypeProvider + XTYPEPROVIDER_DECL() + + // XResultSetMetaData + + /** + * Returns the number of columns of the resultset. + * + * @return the length of the property sequence. + */ + virtual sal_Int32 SAL_CALL + getColumnCount() + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Checks whether column is automatically numbered, which makes it + * read-only. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return true, if column is automatically numbered. + */ + virtual sal_Bool SAL_CALL + isAutoIncrement( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Checks whether column is case sensitive. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return true, if column is case sensitive. + */ + virtual sal_Bool SAL_CALL + isCaseSensitive( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Checks whether the value stored in column can be used in a + * WHERE clause. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return true, if the column is searchable. + */ + virtual sal_Bool SAL_CALL + isSearchable( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Checks whether column is a cash value. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return true, if the column is a cash value. + */ + virtual sal_Bool SAL_CALL + isCurrency( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Checks whether a NULL can be stored in column. + * + * @see com::sun::star::sdbc::ColumnValue + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return ::com::sun::star::sdbc::ColumnValue::NULLABLE, if a NULL + * can be stored in the column. + */ + virtual sal_Int32 SAL_CALL + isNullable( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Checks whether the value stored in column is a signed number. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return true, if the value stored in column is a signed number. + */ + virtual sal_Bool SAL_CALL + isSigned( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Gets the normal maximum width in characters for column. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return the normal maximum width in characters for column. + */ + virtual sal_Int32 SAL_CALL + getColumnDisplaySize( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Gets the suggested column title for column, to be used in print- + * outs and displays. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return the column label. + */ + virtual OUString SAL_CALL + getColumnLabel( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Gets the name of column. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return the name of the property that corresponds to column. + */ + virtual OUString SAL_CALL + getColumnName( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Gets the schema name for the table from which column of this + * result set was derived. + * Because this feature is not widely supported, the return value + * for many DBMSs will be an empty string. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return the schema name of column or an empty string. + */ + virtual OUString SAL_CALL + getSchemaName( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * For number types, getprecision gets the number of decimal digits + * in column. + * For character types, it gets the maximum length in characters for + * column. + * For binary types, it gets the maximum length in bytes for column. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return the precision for the column. + */ + virtual sal_Int32 SAL_CALL + getPrecision( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Gets the number of digits to the right of the decimal point for + * values in column. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return the scale of the column. + */ + virtual sal_Int32 SAL_CALL + getScale( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Gets the name of the table from which column of this result set + * was derived or "" if there is none (for example, for a join). + * Because this feature is not widely supported, the return value + * for many DBMSs will be an empty string. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return the table name for column or an empty string. + */ + virtual OUString SAL_CALL + getTableName( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + virtual OUString SAL_CALL + /** + * Gets the catalog name for the table from which column of this + * result set was derived. + * Because this feature is not widely supported, the return value + * for many DBMSs will be an empty string. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return the catalog name for column or an empty string. + */ + getCatalogName( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Gets the JDBC type for the value stored in column. ... The STRUCT + * and DISTINCT type codes are always returned for structured and + * distinct types, regardless of whether the value will be mapped + * according to the standard mapping or be a custom mapping. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return the type of the property that corresponds to column - mapped + * from UNO-Type to SQL-Type. + */ + virtual sal_Int32 SAL_CALL + getColumnType( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Gets the type name used by this particular data source for the + * values stored in column. If the type code for the type of value + * stored in column is STRUCT, DISTINCT or JAVA_OBJECT, this method + * returns a fully-qualified SQL type name. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return the column type name. + */ + virtual OUString SAL_CALL + getColumnTypeName( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Indicates whether a column is definitely not writable. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return true, if the column is definetely not writable. + */ + virtual sal_Bool SAL_CALL + isReadOnly( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Indicates whether it is possible for a write on the column to succeed. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return true, if it is possible for a write to succeed. + */ + virtual sal_Bool SAL_CALL + isWritable( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Indicates whether a write on the column will definitely succeed. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return true, if a write on the column will definetely succeed. + */ + virtual sal_Bool SAL_CALL + isDefinitelyWritable( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); + /** + * Returns the fully-qualified name of the service whose instances + * are manufactured if the method + * com::sun::star::sdbc::ResultSet::getObject is called to retrieve a + * value from the column. + * + * @param column is the number of the column for that a value shall + * be returned. The first column is 1, the second is 2, ... + * @return the service name for column or an empty string, if no service + * is applicable. + */ + virtual OUString SAL_CALL + getColumnServiceName( sal_Int32 column ) + throw( ::com::sun::star::sdbc::SQLException, + ::com::sun::star::uno::RuntimeException ); +}; + +} // namespace ucbhelper + +#endif /* !_UCBHELPER_RESULTSETMETADATA_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/simpleauthenticationrequest.hxx b/include/ucbhelper/simpleauthenticationrequest.hxx new file mode 100644 index 000000000000..7a084265003c --- /dev/null +++ b/include/ucbhelper/simpleauthenticationrequest.hxx @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_SIMPLEAUTHENTICATIONREQUEST_HXX +#define _UCBHELPER_SIMPLEAUTHENTICATIONREQUEST_HXX + +#include <rtl/ref.hxx> +#include <ucbhelper/interactionrequest.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace com { namespace sun { namespace star { namespace ucb { + class URLAuthenticationRequest; +} } } } + +namespace ucbhelper { + +/** + * This class implements a simple authentication interaction request. + * Instances can be passed directly to XInteractionHandler::handle(...). Each + * instance contains an AuthenticationRequest and three interaction + * continuations: "Abort", "Retry" and "SupplyAuthentication". The parameters + * for the AuthenticationRequest and the InteractionSupplyAuthentication + * objects are partly taken from contructors parameters and partly defaulted + * as follows: + * + * Read-only values : servername, realm + * Read-write values: username, password, account + * All remember-authentication values: RememberAuthentication_NO + * + * @see com::sun::star::ucb::AuthenticationRequest + * @see com::sun::star::ucb::RememberAuthentication + * @see InteractionAbort + * @see InteractionRetry + * @see InteractionSupplyAuthentication + */ +class UCBHELPER_DLLPUBLIC SimpleAuthenticationRequest : public ucbhelper::InteractionRequest +{ + rtl::Reference< + ucbhelper::InteractionSupplyAuthentication > m_xAuthSupplier; + +private: + void initialize( const ::com::sun::star::ucb::URLAuthenticationRequest & rRequest, + sal_Bool bCanSetRealm, + sal_Bool bCanSetUserName, + sal_Bool bCanSetPassword, + sal_Bool bCanSetAccount, + sal_Bool bAllowPersistentStoring, + sal_Bool bAllowUseSystemCredentials ); + +public: + /** Specification whether some entity (realm, username, password, account) + is either not applicable at all, has a fixed value, or is modifiable. + */ + enum EntityType + { + ENTITY_NA, + ENTITY_FIXED, + ENTITY_MODIFY + }; + + /** + * Constructor. + * + * @param rURL contains a URL for which authentication is requested. + * @param rServerName contains a server name. + * @param rRealm contains a realm, if applicable. + * @param rUserName contains a username, if available (for instance from + * a previous try). + * @param rPassword contains a password, if available (for instance from + * a previous try). + * @param rAccount contains an account, if applicable. + * @param bAllowPersistentStoring specifies if the credentials should + * be stored in the passowrd container persistently + * @param bAllowUseSystemCredntials specifies if requesting client is + * able to obtain and use system credentials for authentication + */ + SimpleAuthenticationRequest( const OUString & rURL, + const OUString & rServerName, + const OUString & rRealm, + const OUString & rUserName, + const OUString & rPassword, + const OUString & rAccount, + sal_Bool bAllowPersistentStoring, + sal_Bool bAllowUseSystemCredentials ); + + + /** + * Constructor. + * + * @param rServerName contains a server name. + * @param eRealmType specifies whether a realm is applicable and + modifiable. + * @param rRealm contains a realm, if applicable. + * @param eUserNameType specifies whether a username is applicable and + modifiable. + * @param rUserName contains a username, if available (for instance from + * a previous try). + * @param ePasswordType specifies whether a password is applicable and + modifiable. + * @param rPassword contains a password, if available (for instance from + * a previous try). + * @param eAccountType specifies whether an account is applicable and + modifiable. + * @param rAccount contains an account, if applicable. + */ + SimpleAuthenticationRequest( const OUString & rURL, + const OUString & rServerName, + EntityType eRealmType, + const OUString & rRealm, + EntityType eUserNameType, + const OUString & rUserName, + EntityType ePasswordType, + const OUString & rPassword, + EntityType eAccountType = ENTITY_NA, + const OUString & rAccount + = OUString() ); + + /** + * This method returns the supplier for the missing authentication data, + * that, for instance can be used to query the password supplied by the + * interaction handler. + * + * @return the supplier for the missing authentication data. + */ + const rtl::Reference< ucbhelper::InteractionSupplyAuthentication > & + getAuthenticationSupplier() const { return m_xAuthSupplier; } +}; + +} // namespace ucbhelper + +#endif /* !_UCBHELPER_SIMPLEAUTHENTICATIONREQUEST_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/simplecertificatevalidationrequest.hxx b/include/ucbhelper/simplecertificatevalidationrequest.hxx new file mode 100644 index 000000000000..3f761153582b --- /dev/null +++ b/include/ucbhelper/simplecertificatevalidationrequest.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_SIMPLECERTIFICATEVALIDATIONREQUEST_HXX +#define _UCBHELPER_SIMPLECERTIFICATEVALIDATIONREQUEST_HXX + +#include <rtl/ref.hxx> +#include <ucbhelper/interactionrequest.hxx> +#include "ucbhelper/ucbhelperdllapi.h" +#include <com/sun/star/security/XCertificate.hpp> + + +namespace ucbhelper { + +/** + * This class implements a simple validation interaction request of a certificate. + * Instances can be passed directly to XInteractionHandler::handle(...). Each + * instance contains an CertificateValidationRequest and two interaction + * continuations: "Abort" and "Approved". The parameters + * for the CertificateValidationRequest object are partly taken from contructors parameters and partly defaulted + * as follows: + * + * Read-write values: certificateValidity, certificate + * + * @see com::sun::star::ucb::CertificateValidationRequest + * @see InteractionApproved + * @see InteractionRetry + */ +class UCBHELPER_DLLPUBLIC SimpleCertificateValidationRequest : public ucbhelper::InteractionRequest +{ +public: + /** + * Constructor. + * + * @param lCertificateValidity contains a bitmask which validation error occur. + * @param pCertificate contaisn the server certificate. + */ + SimpleCertificateValidationRequest( const sal_Int32 & lCertificateValidity, + const com::sun::star::uno::Reference<com::sun::star::security::XCertificate> pCertificate, + const OUString & hostname ); +}; + +} // namespace ucbhelper + +#endif /* !_UCBHELPER_SIMPLECERTIFICATEVALIDATIONREQUEST_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/simpleinteractionrequest.hxx b/include/ucbhelper/simpleinteractionrequest.hxx new file mode 100644 index 000000000000..746aaf284bd6 --- /dev/null +++ b/include/ucbhelper/simpleinteractionrequest.hxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_SIMPLEINTERACTIONREQUEST_HXX +#define _UCBHELPER_SIMPLEINTERACTIONREQUEST_HXX + +#include <ucbhelper/interactionrequest.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace ucbhelper { + +/** These are the constants that can be passed to the constructor of class + * SimpleInteractionRequest and that are returned by method + * SimpleInteractionRequest::getResponse(). + */ + +/** The request was not (yet) handled by the interaction handler. */ +static const sal_Int32 CONTINUATION_UNKNOWN = 0; + +/** The interaction handler selected XInteractionAbort. */ +static const sal_Int32 CONTINUATION_ABORT = 1; + +/** The interaction handler selected XInteractionRetry. */ +static const sal_Int32 CONTINUATION_RETRY = 2; + +/** The interaction handler selected XInteractionApprove. */ +static const sal_Int32 CONTINUATION_APPROVE = 4; + +/** The interaction handler selected XInteractionDisapprove. */ +static const sal_Int32 CONTINUATION_DISAPPROVE = 8; + +/** + * This class implements a simple interaction request. The user must not deal + * with XInteractionContinuations directly, but can use constants that are + * mapped internally to the according objects. This class encapsulates the + * standard Interaction Continuations "Abort", "Retry", "Approve" and + * "Disaprrove". Instances can be passed directly to + * XInteractionHandler::handle(...). + * + * @see InteractionRequest + * @see InteractionAbort + * @see InteractionRetry + * @see InteractionApprove + * @see InteractionDisapprove + */ +class UCBHELPER_DLLPUBLIC SimpleInteractionRequest : public ucbhelper::InteractionRequest +{ +public: + /** + * Constructor. + * + * @param rRequest is the exception describing the error. + * @param nContinuations contains the possible "answers" for the request. + * This can be any of the CONTINUATION_* constants combinations + * listed above. + */ + SimpleInteractionRequest( const com::sun::star::uno::Any & rRequest, + const sal_Int32 nContinuations ); + + /** + * After passing this request to XInteractionHandler::handle, this method + * returns the continuation that was choosen by the interaction handler. + * + * @return the continuation choosen by an interaction handler or + * CONTINUATION_UNKNOWN, if the request was not (yet) handled. + */ + sal_Int32 getResponse() const; +}; + +} // namespace ucbhelper + +#endif /* !_UCBHELPER_SIMPLEINTERACTIONREQUEST_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/simpleioerrorrequest.hxx b/include/ucbhelper/simpleioerrorrequest.hxx new file mode 100644 index 000000000000..d4c9c5277316 --- /dev/null +++ b/include/ucbhelper/simpleioerrorrequest.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_SIMPLEIOERRORREQUEST_HXX +#define _UCBHELPER_SIMPLEIOERRORREQUEST_HXX + +#include <com/sun/star/ucb/IOErrorCode.hpp> +#include <ucbhelper/interactionrequest.hxx> + +namespace com { namespace sun { namespace star { namespace ucb { + class XCommandProcessor; +} } } } + +namespace ucbhelper { + +/** + * This class implements a simple IO error interaction request. Instances + * can be passed directly to XInteractionHandler::handle(...). Each + * instance contains an InteractiveIOException and one interaction + * continuation: "Abort". + * + * @see com::sun::star::ucb::InteractiveIOException + * @see InteractionAbort + */ +class SimpleIOErrorRequest : public ucbhelper::InteractionRequest +{ +public: + /** + * Constructor. + * + * @param xContext contains the command processor that executes the + * command related to the request. + * + * @param eError is the error code to pass along with the request. + * + * qparam rArgs are additional parameters according to the specification + * of the error code. Refer to com/sun/star/ucb/IOErrorCode.idl + * for details. + */ + SimpleIOErrorRequest( const com::sun::star::ucb::IOErrorCode eError, + const com::sun::star::uno::Sequence< + com::sun::star::uno::Any > & rArgs, + const OUString & rMessage, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandProcessor > & xContext + ); +}; + +} // namespace ucbhelper + +#endif /* !_UCBHELPER_SIMPLEIOERRORREQUEST_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/simplenameclashresolverequest.hxx b/include/ucbhelper/simplenameclashresolverequest.hxx new file mode 100644 index 000000000000..be789fd6a148 --- /dev/null +++ b/include/ucbhelper/simplenameclashresolverequest.hxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UCBHELPER_SIMPLENAMECLASHRESOLVEREQUEST_HXX +#define _UCBHELPER_SIMPLENAMECLASHRESOLVEREQUEST_HXX + +#include <rtl/ref.hxx> +#include <ucbhelper/interactionrequest.hxx> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace ucbhelper { + +/** + * This class implements a simple name clash resolve interaction request. + * Instances can be passed directly to XInteractionHandler::handle(...). Each + * instance contains a NameClashResolveRequest and two interaction + * continuations: "Abort" and "SupplyName". Another continuation + * ("ReplaceExistingData") may be supplied optionally. + * + * @see com::sun::star::ucb::NameClashResolveRequest + * @see InteractionAbort + * @see InteractioneplaceExistingData + * @see InteractionSupplyName + */ +class UCBHELPER_DLLPUBLIC SimpleNameClashResolveRequest : public ucbhelper::InteractionRequest +{ + rtl::Reference< InteractionSupplyName > m_xNameSupplier; + +public: + /** + * Constructor. + * + * @param rTargetFolderURL contains the URL of the folder that contains + * the clashing resource. + * @param rClashingName contains the clashing name. + * @param rProposedNewName contains a proposal for the new name or is + * empty. + * @param bSupportsOverwriteData indicates whether an + * InteractionReplaceExistingData continuation shall be supplied + * with the interaction request. + */ + SimpleNameClashResolveRequest( const OUString & rTargetFolderURL, + const OUString & rClashingName, + const OUString & rProposedNewName, + sal_Bool bSupportsOverwriteData = sal_True ); + /** + * This method returns the new name that was supplied by the interaction + * handler. + * + * @return the new name, if supplied. + */ + const OUString getNewName() const + { return m_xNameSupplier->getName(); } + +}; + +} // namespace ucbhelper + +#endif /* !_UCBHELPER_SIMPLENAMECLASHRESOLVEREQUEST_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/std_inputstream.hxx b/include/ucbhelper/std_inputstream.hxx new file mode 100644 index 000000000000..92c9577519bc --- /dev/null +++ b/include/ucbhelper/std_inputstream.hxx @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef _UCBHELPER_STD_INPUTSTREAM_HXX_ +#define _UCBHELPER_STD_INPUTSTREAM_HXX_ + +#include <boost/shared_ptr.hpp> +#include <istream> + +#include <rtl/ustring.hxx> +#include <osl/mutex.hxx> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/queryinterface.hxx> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XSeekable.hpp> + +#include "ucbhelper/ucbhelperdllapi.h" + +namespace ucbhelper +{ + /** Implements a seekable InputStream + * working on an std::istream + */ + class UCBHELPER_DLLPUBLIC StdInputStream + : public cppu::OWeakObject, + public com::sun::star::io::XInputStream, + public com::sun::star::io::XSeekable + { + public: + + StdInputStream( boost::shared_ptr< std::istream > pStream ); + + ~StdInputStream(); + + virtual css::uno::Any SAL_CALL queryInterface ( const css::uno::Type& rType ) + throw ( css::uno::RuntimeException ); + + virtual void SAL_CALL acquire( ) throw ( ); + + virtual void SAL_CALL release( ) throw ( ); + + virtual sal_Int32 SAL_CALL + readBytes ( css::uno::Sequence< sal_Int8 >& aData, + sal_Int32 nBytesToRead ) + throw ( css::io::NotConnectedException, + css::io::BufferSizeExceededException, + css::io::IOException, + css::uno::RuntimeException ); + + virtual sal_Int32 SAL_CALL + readSomeBytes ( css::uno::Sequence< sal_Int8 >& aData, + sal_Int32 nMaxBytesToRead ) + throw ( css::io::NotConnectedException, + css::io::BufferSizeExceededException, + css::io::IOException, + css::uno::RuntimeException ); + + virtual void SAL_CALL + skipBytes ( sal_Int32 nBytesToSkip ) + throw ( css::io::NotConnectedException, + css::io::BufferSizeExceededException, + css::io::IOException, + css::uno::RuntimeException ); + + virtual sal_Int32 SAL_CALL + available ( ) + throw ( css::io::NotConnectedException, + css::io::IOException, + css::uno::RuntimeException ); + + virtual void SAL_CALL + closeInput ( ) + throw ( css::io::NotConnectedException, + css::io::IOException, + css::uno::RuntimeException ); + + + /** XSeekable + */ + + virtual void SAL_CALL + seek ( sal_Int64 location ) + throw ( css::lang::IllegalArgumentException, + css::io::IOException, + css::uno::RuntimeException ); + + + virtual sal_Int64 SAL_CALL + getPosition ( ) + throw ( css::io::IOException, css::uno::RuntimeException ); + + + virtual sal_Int64 SAL_CALL + getLength ( ) + throw ( css::io::IOException, + css::uno::RuntimeException ); + + private: + + osl::Mutex m_aMutex; + boost::shared_ptr< std::istream > m_pStream; + sal_Int64 m_nLength; + }; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/std_outputstream.hxx b/include/ucbhelper/std_outputstream.hxx new file mode 100644 index 000000000000..d0ad4a660248 --- /dev/null +++ b/include/ucbhelper/std_outputstream.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef _UCBHELPER_STD_OUTPUTSTREAM_HXX_ +#define _UCBHELPER_STD_OUTPUTSTREAM_HXX_ + +#include <boost/shared_ptr.hpp> +#include <ostream> + +#include <osl/mutex.hxx> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/queryinterface.hxx> +#include <com/sun/star/io/XOutputStream.hpp> +#include "ucbhelper/ucbhelperdllapi.h" + +namespace ucbhelper +{ + /** Implements a OutputStream + * working on an std::ostream + */ + class UCBHELPER_DLLPUBLIC StdOutputStream : + public cppu::OWeakObject, + public css::io::XOutputStream + { + public: + + StdOutputStream( boost::shared_ptr< std::ostream > pStream ); + + ~StdOutputStream( ); + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType ) + throw ( css::uno::RuntimeException ); + + virtual void SAL_CALL acquire ( ) throw ( ); + + virtual void SAL_CALL release ( ) throw ( ); + + virtual void SAL_CALL writeBytes ( const css::uno::Sequence< sal_Int8 >& aData ) + throw ( css::io::NotConnectedException, + css::io::BufferSizeExceededException, + css::io::IOException, + css::uno::RuntimeException ); + + virtual void SAL_CALL flush ( ) + throw ( css::io::NotConnectedException, + css::io::BufferSizeExceededException, + css::io::IOException, + css::uno::RuntimeException ); + + virtual void SAL_CALL closeOutput ( ) + throw ( css::io::NotConnectedException, + css::io::BufferSizeExceededException, + css::io::IOException, + css::uno::RuntimeException ); + + private: + + osl::Mutex m_aMutex; + boost::shared_ptr< std::ostream > m_pStream; + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/ucbhelper/ucbhelperdllapi.h b/include/ucbhelper/ucbhelperdllapi.h new file mode 100644 index 000000000000..b129f163de8f --- /dev/null +++ b/include/ucbhelper/ucbhelperdllapi.h @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_UCBHELPERDLLAPI_H +#define INCLUDED_UCBHELPERDLLAPI_H + +#include "sal/types.h" + +#if defined(UCBHELPER_DLLIMPLEMENTATION) +#define UCBHELPER_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define UCBHELPER_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define UCBHELPER_DLLPRIVATE SAL_DLLPRIVATE + +#endif /* INCLUDED_UCBHELPERDLLAPI_H */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |