compilerplugins/clang/mergeclasses.results | 1 ucb/Library_ucpfile1.mk | 1 ucb/source/ucp/file/bc.cxx | 8 ucb/source/ucp/file/bc.hxx | 10 ucb/source/ucp/file/filcmd.cxx | 4 ucb/source/ucp/file/filcmd.hxx | 6 ucb/source/ucp/file/filglob.cxx | 2 ucb/source/ucp/file/filid.cxx | 10 ucb/source/ucp/file/filid.hxx | 2 ucb/source/ucp/file/filinl.hxx | 16 ucb/source/ucp/file/filinpstr.cxx | 2 ucb/source/ucp/file/filinpstr.hxx | 2 ucb/source/ucp/file/filinsreq.cxx | 4 ucb/source/ucp/file/filinsreq.hxx | 4 ucb/source/ucp/file/filnot.cxx | 4 ucb/source/ucp/file/filnot.hxx | 8 ucb/source/ucp/file/filprp.cxx | 12 ucb/source/ucp/file/filprp.hxx | 8 ucb/source/ucp/file/filrow.cxx | 6 ucb/source/ucp/file/filrow.hxx | 6 ucb/source/ucp/file/filrset.cxx | 4 ucb/source/ucp/file/filrset.hxx | 4 ucb/source/ucp/file/filstr.cxx | 2 ucb/source/ucp/file/filstr.hxx | 2 ucb/source/ucp/file/filtask.cxx | 2937 ++++++++++++++++++++++++++++ ucb/source/ucp/file/filtask.hxx | 510 ++++ ucb/source/ucp/file/prov.cxx | 24 ucb/source/ucp/file/prov.hxx | 4 ucb/source/ucp/file/shell.cxx | 2992 ----------------------------- ucb/source/ucp/file/shell.hxx | 557 ----- 30 files changed, 3517 insertions(+), 3635 deletions(-)
New commits: commit 37b21a0a71d500cc5785d856d2e4402df17d8f87 Author: Stephan Bergmann <[email protected]> Date: Wed Dec 14 17:52:03 2016 +0100 Merge shell into TaskManager base class (arbitrarily decided to keep the latter, being the less odd class name) Change-Id: I5c061a0f12b8f3095e283b4896f7c910948ac50f diff --git a/compilerplugins/clang/mergeclasses.results b/compilerplugins/clang/mergeclasses.results index 096d79a..b76adfb 100644 --- a/compilerplugins/clang/mergeclasses.results +++ b/compilerplugins/clang/mergeclasses.results @@ -234,7 +234,6 @@ merge detail::ScVbaHlinkContainerMember with ScVbaHyperlinks merge drawinglayer::primitive2d::ObjectAndViewTransformationDependentPrimitive2D with drawinglayer::primitive2d::DiscreteBitmapPrimitive2D merge drawinglayer::primitive2d::ViewTransformationDependentPrimitive2D with drawinglayer::primitive2d::WallpaperBitmapPrimitive2D merge drawinglayer::processor3d::DefaultProcessor3D with drawinglayer::processor3d::ZBufferProcessor3D -merge fileaccess::TaskManager with fileaccess::shell merge frm::ICommandImageProvider with frm::DocumentCommandImageProvider merge frm::IEngineStatusListener with frm::RichTextControlImpl merge frm::IEngineTextChangeListener with frm::ORichTextModel diff --git a/ucb/Library_ucpfile1.mk b/ucb/Library_ucpfile1.mk index 07e97ed..a85c6c4 100644 --- a/ucb/Library_ucpfile1.mk +++ b/ucb/Library_ucpfile1.mk @@ -40,7 +40,6 @@ $(eval $(call gb_Library_add_exception_objects,ucpfile1,\ ucb/source/ucp/file/filstr \ ucb/source/ucp/file/filtask \ ucb/source/ucp/file/prov \ - ucb/source/ucp/file/shell \ )) # vim: set noet sw=4 ts=4: diff --git a/ucb/source/ucp/file/bc.cxx b/ucb/source/ucp/file/bc.cxx index d7b6db8..bafc57c 100644 --- a/ucb/source/ucp/file/bc.cxx +++ b/ucb/source/ucp/file/bc.cxx @@ -78,7 +78,7 @@ public: // Private Constructor for just inserted Contents -BaseContent::BaseContent( shell* pMyShell, +BaseContent::BaseContent( TaskManager* pMyShell, const OUString& parentName, bool bFolder ) : m_pMyShell( pMyShell ), @@ -98,7 +98,7 @@ BaseContent::BaseContent( shell* pMyShell, // Constructor for full featured Contents -BaseContent::BaseContent( shell* pMyShell, +BaseContent::BaseContent( TaskManager* pMyShell, const Reference< XContentIdentifier >& xContentIdentifier, const OUString& aUncPath ) : m_pMyShell( pMyShell ), @@ -699,7 +699,7 @@ BaseContent::getParent() OUString ParentUrl; - bool err = fileaccess::shell::getUrlFromUnq( ParentUnq, ParentUrl ); + bool err = fileaccess::TaskManager::getUrlFromUnq( ParentUnq, ParentUrl ); if( err ) return Reference< XInterface >( nullptr ); @@ -1045,7 +1045,7 @@ BaseContent::transfer( sal_Int32 nMyCommandIdentifier, } OUString srcUnc; - if( fileaccess::shell::getUnqFromUrl( aTransferInfo.SourceURL,srcUnc ) ) + if( fileaccess::TaskManager::getUnqFromUrl( aTransferInfo.SourceURL,srcUnc ) ) { m_pMyShell->installError( nMyCommandIdentifier, TASKHANDLING_TRANSFER_INVALIDURL ); diff --git a/ucb/source/ucp/file/bc.hxx b/ucb/source/ucp/file/bc.hxx index d8b47de..ccb52fd 100644 --- a/ucb/source/ucp/file/bc.hxx +++ b/ucb/source/ucp/file/bc.hxx @@ -49,13 +49,13 @@ #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/ucb/OpenCommandArgument2.hpp> #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> -#include "shell.hxx" +#include "filtask.hxx" namespace fileaccess { class PropertyListeners; - class shell; + class TaskManager; class BaseContent: public cppu::OWeakObject, @@ -74,13 +74,13 @@ namespace fileaccess { private: // A special creator for inserted contents; Creates an ugly object - BaseContent( shell* pMyShell, + BaseContent( TaskManager* pMyShell, const OUString& parentName, bool bFolder ); public: BaseContent( - shell* pMyShell, + TaskManager* pMyShell, const css::uno::Reference< css::ucb::XContentIdentifier >& xContentIdentifier, const OUString& aUnqPath ); @@ -251,7 +251,7 @@ namespace fileaccess { private: // Data members - shell* m_pMyShell; + TaskManager* m_pMyShell; css::uno::Reference< css::ucb::XContentIdentifier > m_xContentIdentifier; OUString m_aUncPath; diff --git a/ucb/source/ucp/file/filcmd.cxx b/ucb/source/ucp/file/filcmd.cxx index 09c8e8a2..daa4e74 100644 --- a/ucb/source/ucp/file/filcmd.cxx +++ b/ucb/source/ucp/file/filcmd.cxx @@ -18,7 +18,7 @@ */ #include "filcmd.hxx" -#include "shell.hxx" +#include "filtask.hxx" #include "prov.hxx" using namespace fileaccess; @@ -31,7 +31,7 @@ using namespace com::sun::star::ucb; #define THROW_WHERE "" #endif -XCommandInfo_impl::XCommandInfo_impl( shell* pMyShell ) +XCommandInfo_impl::XCommandInfo_impl( TaskManager* pMyShell ) : m_pMyShell( pMyShell ) { } diff --git a/ucb/source/ucp/file/filcmd.hxx b/ucb/source/ucp/file/filcmd.hxx index 154f3dc..c9b686c 100644 --- a/ucb/source/ucp/file/filcmd.hxx +++ b/ucb/source/ucp/file/filcmd.hxx @@ -30,7 +30,7 @@ namespace fileaccess { // forward - class shell; + class TaskManager; class XCommandInfo_impl @@ -39,7 +39,7 @@ namespace fileaccess { { public: - explicit XCommandInfo_impl( shell* pMyShell ); + explicit XCommandInfo_impl( TaskManager* pMyShell ); virtual ~XCommandInfo_impl() override; @@ -83,7 +83,7 @@ namespace fileaccess { private: - shell* m_pMyShell; + TaskManager* m_pMyShell; }; } diff --git a/ucb/source/ucp/file/filglob.cxx b/ucb/source/ucp/file/filglob.cxx index 493cdb3..49d08c6 100644 --- a/ucb/source/ucp/file/filglob.cxx +++ b/ucb/source/ucp/file/filglob.cxx @@ -19,7 +19,7 @@ #include "filglob.hxx" #include "filerror.hxx" -#include "shell.hxx" +#include "filtask.hxx" #include "bc.hxx" #include <osl/file.hxx> #include <vector> diff --git a/ucb/source/ucp/file/filid.cxx b/ucb/source/ucp/file/filid.cxx index 2e0d531..5ef3565 100644 --- a/ucb/source/ucp/file/filid.cxx +++ b/ucb/source/ucp/file/filid.cxx @@ -18,7 +18,7 @@ */ #include "filid.hxx" -#include "shell.hxx" +#include "filtask.hxx" #include <cppuhelper/queryinterface.hxx> @@ -33,15 +33,15 @@ FileContentIdentifier::FileContentIdentifier( { if( IsNormalized ) { - fileaccess::shell::getUrlFromUnq( aUnqPath,m_aContentId ); + fileaccess::TaskManager::getUrlFromUnq( aUnqPath,m_aContentId ); m_aNormalizedId = aUnqPath; - shell::getScheme( m_aProviderScheme ); + TaskManager::getScheme( m_aProviderScheme ); } else { - fileaccess::shell::getUnqFromUrl( aUnqPath,m_aNormalizedId ); + fileaccess::TaskManager::getUnqFromUrl( aUnqPath,m_aNormalizedId ); m_aContentId = aUnqPath; - shell::getScheme( m_aProviderScheme ); + TaskManager::getScheme( m_aProviderScheme ); } } diff --git a/ucb/source/ucp/file/filid.hxx b/ucb/source/ucp/file/filid.hxx index d2c2baf5..be04b00 100644 --- a/ucb/source/ucp/file/filid.hxx +++ b/ucb/source/ucp/file/filid.hxx @@ -26,7 +26,7 @@ namespace fileaccess { - class shell; + class TaskManager; class FileContentIdentifier : public cppu::OWeakObject, diff --git a/ucb/source/ucp/file/filinl.hxx b/ucb/source/ucp/file/filinl.hxx index 224353c..5292515 100644 --- a/ucb/source/ucp/file/filinl.hxx +++ b/ucb/source/ucp/file/filinl.hxx @@ -19,35 +19,35 @@ #ifndef INCLUDED_UCB_SOURCE_UCP_FILE_FILINL_HXX #define INCLUDED_UCB_SOURCE_UCP_FILE_FILINL_HXX -inline const bool& SAL_CALL shell::MyProperty::IsNative() const +inline const bool& SAL_CALL TaskManager::MyProperty::IsNative() const { return isNative; } -inline const sal_Int32& SAL_CALL shell::MyProperty::getHandle() const +inline const sal_Int32& SAL_CALL TaskManager::MyProperty::getHandle() const { return Handle; } -inline const css::uno::Type& SAL_CALL shell::MyProperty::getType() const +inline const css::uno::Type& SAL_CALL TaskManager::MyProperty::getType() const { return Typ; } -inline const css::uno::Any& SAL_CALL shell::MyProperty::getValue() const +inline const css::uno::Any& SAL_CALL TaskManager::MyProperty::getValue() const { return Value; } -inline const css::beans::PropertyState& SAL_CALL shell::MyProperty::getState() const +inline const css::beans::PropertyState& SAL_CALL TaskManager::MyProperty::getState() const { return State; } -inline const sal_Int16& SAL_CALL shell::MyProperty::getAttributes() const +inline const sal_Int16& SAL_CALL TaskManager::MyProperty::getAttributes() const { return Attributes; } -inline void SAL_CALL shell::MyProperty::setValue( const css::uno::Any& theValue ) const +inline void SAL_CALL TaskManager::MyProperty::setValue( const css::uno::Any& theValue ) const { const_cast<MyProperty*>(this)->Value = theValue; } -inline void SAL_CALL shell::MyProperty::setState( const css::beans::PropertyState& theState ) const +inline void SAL_CALL TaskManager::MyProperty::setState( const css::beans::PropertyState& theState ) const { const_cast<MyProperty*>(this)->State = theState; } diff --git a/ucb/source/ucp/file/filinpstr.cxx b/ucb/source/ucp/file/filinpstr.cxx index 0f2ba54..9b6d560 100644 --- a/ucb/source/ucp/file/filinpstr.cxx +++ b/ucb/source/ucp/file/filinpstr.cxx @@ -19,7 +19,7 @@ #include "filinpstr.hxx" #include "filerror.hxx" -#include "shell.hxx" +#include "filtask.hxx" #include "prov.hxx" using namespace fileaccess; diff --git a/ucb/source/ucp/file/filinpstr.hxx b/ucb/source/ucp/file/filinpstr.hxx index 25aa6dd..8dc6c28 100644 --- a/ucb/source/ucp/file/filinpstr.hxx +++ b/ucb/source/ucp/file/filinpstr.hxx @@ -32,7 +32,7 @@ namespace fileaccess { - class shell; + class TaskManager; class XInputStream_impl : public cppu::OWeakObject, diff --git a/ucb/source/ucp/file/filinsreq.cxx b/ucb/source/ucp/file/filinsreq.cxx index e96b604..e33f918 100644 --- a/ucb/source/ucp/file/filinsreq.cxx +++ b/ucb/source/ucp/file/filinsreq.cxx @@ -18,7 +18,7 @@ */ #include "filinsreq.hxx" -#include "shell.hxx" +#include "filtask.hxx" #include "filglob.hxx" #include <comphelper/interaction.hxx> @@ -42,7 +42,7 @@ using namespace fileaccess; XInteractionRequestImpl::XInteractionRequestImpl( const OUString& aClashingName, const Reference<XInterface>& xOrigin, - shell *pShell,sal_Int32 CommandId) + TaskManager *pShell,sal_Int32 CommandId) : p1( new XInteractionSupplyNameImpl ), p2( new XInteractionAbortImpl ), m_nErrorCode(0), diff --git a/ucb/source/ucp/file/filinsreq.hxx b/ucb/source/ucp/file/filinsreq.hxx index a39b32a..549f008 100644 --- a/ucb/source/ucp/file/filinsreq.hxx +++ b/ucb/source/ucp/file/filinsreq.hxx @@ -32,7 +32,7 @@ namespace fileaccess { - class shell; + class TaskManager; class XInteractionSupplyNameImpl : public cppu::WeakImplHelper< @@ -109,7 +109,7 @@ class XInteractionSupplyNameImpl : public cppu::WeakImplHelper< XInteractionRequestImpl( const OUString& aClashingName, const css::uno::Reference< css::uno::XInterface>& xOrigin, - shell* pShell, + TaskManager* pShell, sal_Int32 CommandId); bool aborted() const diff --git a/ucb/source/ucp/file/filnot.cxx b/ucb/source/ucp/file/filnot.cxx index 32ca396..49f074c 100644 --- a/ucb/source/ucp/file/filnot.cxx +++ b/ucb/source/ucp/file/filnot.cxx @@ -31,7 +31,7 @@ using namespace com::sun::star; using namespace com::sun::star::ucb; -ContentEventNotifier::ContentEventNotifier( shell* pMyShell, +ContentEventNotifier::ContentEventNotifier( TaskManager* pMyShell, const uno::Reference< XContent >& xCreatorContent, const uno::Reference< XContentIdentifier >& xCreatorId, const std::vector< uno::Reference< uno::XInterface > >& sListeners ) @@ -43,7 +43,7 @@ ContentEventNotifier::ContentEventNotifier( shell* pMyShell, } -ContentEventNotifier::ContentEventNotifier( shell* pMyShell, +ContentEventNotifier::ContentEventNotifier( TaskManager* pMyShell, const uno::Reference< XContent >& xCreatorContent, const uno::Reference< XContentIdentifier >& xCreatorId, const uno::Reference< XContentIdentifier >& xOldId, diff --git a/ucb/source/ucp/file/filnot.hxx b/ucb/source/ucp/file/filnot.hxx index ffecfe7..2a5b510 100644 --- a/ucb/source/ucp/file/filnot.hxx +++ b/ucb/source/ucp/file/filnot.hxx @@ -29,12 +29,12 @@ namespace fileaccess { - class shell; + class TaskManager; class ContentEventNotifier { private: - shell* m_pMyShell; + TaskManager* m_pMyShell; css::uno::Reference< css::ucb::XContent > m_xCreatorContent; css::uno::Reference< css::ucb::XContentIdentifier > m_xCreatorId; css::uno::Reference< css::ucb::XContentIdentifier > m_xOldId; @@ -42,13 +42,13 @@ namespace fileaccess { public: ContentEventNotifier( - shell* pMyShell, + TaskManager* pMyShell, const css::uno::Reference< css::ucb::XContent >& xCreatorContent, const css::uno::Reference< css::ucb::XContentIdentifier >& xCreatorId, const std::vector< css::uno::Reference< css::uno::XInterface > >& sListeners ); ContentEventNotifier( - shell* pMyShell, + TaskManager* pMyShell, const css::uno::Reference< css::ucb::XContent >& xCreatorContent, const css::uno::Reference< css::ucb::XContentIdentifier >& xCreatorId, const css::uno::Reference< css::ucb::XContentIdentifier >& xOldId, diff --git a/ucb/source/ucp/file/filprp.cxx b/ucb/source/ucp/file/filprp.cxx index e5c74f6..be7fbec 100644 --- a/ucb/source/ucp/file/filprp.cxx +++ b/ucb/source/ucp/file/filprp.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "shell.hxx" +#include "filtask.hxx" #include "prov.hxx" #include "filprp.hxx" @@ -34,17 +34,17 @@ using namespace com::sun::star::ucb; #define THROW_WHERE "" #endif -XPropertySetInfo_impl::XPropertySetInfo_impl( shell* pMyShell,const OUString& aUnqPath ) +XPropertySetInfo_impl::XPropertySetInfo_impl( TaskManager* pMyShell,const OUString& aUnqPath ) : m_pMyShell( pMyShell ), m_count( 0 ), m_seq( 0 ) { m_pMyShell->m_pProvider->acquire(); - shell::ContentMap::iterator it = m_pMyShell->m_aContent.find( aUnqPath ); + TaskManager::ContentMap::iterator it = m_pMyShell->m_aContent.find( aUnqPath ); - shell::PropertySet& properties = *(it->second.properties); - shell::PropertySet::iterator it1 = properties.begin(); + TaskManager::PropertySet& properties = *(it->second.properties); + TaskManager::PropertySet::iterator it1 = properties.begin(); m_seq.realloc( properties.size() ); @@ -59,7 +59,7 @@ XPropertySetInfo_impl::XPropertySetInfo_impl( shell* pMyShell,const OUString& aU } -XPropertySetInfo_impl::XPropertySetInfo_impl( shell* pMyShell,const Sequence< beans::Property >& seq ) +XPropertySetInfo_impl::XPropertySetInfo_impl( TaskManager* pMyShell,const Sequence< beans::Property >& seq ) : m_pMyShell( pMyShell ), m_count( seq.getLength() ), m_seq( seq ) diff --git a/ucb/source/ucp/file/filprp.hxx b/ucb/source/ucp/file/filprp.hxx index dfba38f..0a9208d 100644 --- a/ucb/source/ucp/file/filprp.hxx +++ b/ucb/source/ucp/file/filprp.hxx @@ -26,14 +26,14 @@ namespace fileaccess { - class shell; + class TaskManager; class XPropertySetInfo_impl : public cppu::WeakImplHelper< css::beans::XPropertySetInfo > { public: - XPropertySetInfo_impl( shell* pMyShell,const OUString& aUnqPath ); - XPropertySetInfo_impl( shell* pMyShell,const css::uno::Sequence< css::beans::Property >& seq ); + XPropertySetInfo_impl( TaskManager* pMyShell,const OUString& aUnqPath ); + XPropertySetInfo_impl( TaskManager* pMyShell,const css::uno::Sequence< css::beans::Property >& seq ); virtual ~XPropertySetInfo_impl() override; @@ -51,7 +51,7 @@ class XPropertySetInfo_impl : public cppu::WeakImplHelper< throw( css::uno::RuntimeException, std::exception ) override; private: - shell* m_pMyShell; + TaskManager* m_pMyShell; sal_Int32 m_count; css::uno::Sequence< css::beans::Property > m_seq; }; diff --git a/ucb/source/ucp/file/filrow.cxx b/ucb/source/ucp/file/filrow.cxx index 3709062..e79555f 100644 --- a/ucb/source/ucp/file/filrow.cxx +++ b/ucb/source/ucp/file/filrow.cxx @@ -18,7 +18,7 @@ */ #include "filrow.hxx" -#include "shell.hxx" +#include "filtask.hxx" #include "prov.hxx" #include <com/sun/star/script/Converter.hpp> #include <comphelper/processfactory.hxx> @@ -36,7 +36,7 @@ using namespace css::uno; // Function for TypeConverting template< class _type_ > -bool convert( shell* pShell, +bool convert( TaskManager* pShell, uno::Reference< script::XTypeConverter >& xConverter, uno::Any& rValue, _type_& aReturn ) @@ -75,7 +75,7 @@ bool convert( shell* pShell, } -XRow_impl::XRow_impl( shell* pMyShell,const uno::Sequence< uno::Any >& seq ) +XRow_impl::XRow_impl( TaskManager* pMyShell,const uno::Sequence< uno::Any >& seq ) : m_aValueMap( seq ), m_nWasNull(false), m_pMyShell( pMyShell ), diff --git a/ucb/source/ucp/file/filrow.hxx b/ucb/source/ucp/file/filrow.hxx index 8449543..8666275 100644 --- a/ucb/source/ucp/file/filrow.hxx +++ b/ucb/source/ucp/file/filrow.hxx @@ -26,13 +26,13 @@ namespace fileaccess { - class shell; + class TaskManager; class XRow_impl: public cppu::WeakImplHelper< css::sdbc::XRow > { public: - XRow_impl( shell* pShell,const css::uno::Sequence< css::uno::Any >& aValueMap ); + XRow_impl( TaskManager* pShell,const css::uno::Sequence< css::uno::Any >& aValueMap ); virtual ~XRow_impl() override; virtual sal_Bool SAL_CALL @@ -143,7 +143,7 @@ namespace fileaccess { osl::Mutex m_aMutex; css::uno::Sequence< css::uno::Any > m_aValueMap; bool m_nWasNull; - shell* m_pMyShell; + TaskManager* m_pMyShell; css::uno::Reference< css::script::XTypeConverter > m_xTypeConverter; }; diff --git a/ucb/source/ucp/file/filrset.cxx b/ucb/source/ucp/file/filrset.cxx index 2022e9a..f677e85 100644 --- a/ucb/source/ucp/file/filrset.cxx +++ b/ucb/source/ucp/file/filrset.cxx @@ -19,7 +19,7 @@ #include <com/sun/star/ucb/WelcomeDynamicResultSetStruct.hpp> #include "filid.hxx" -#include "shell.hxx" +#include "filtask.hxx" #include "filprp.hxx" #include "filrset.hxx" #include <com/sun/star/ucb/OpenMode.hpp> @@ -41,7 +41,7 @@ using namespace com::sun::star; #define THROW_WHERE "" #endif -XResultSet_impl::XResultSet_impl( shell* pMyShell, +XResultSet_impl::XResultSet_impl( TaskManager* pMyShell, const OUString& aUnqPath, sal_Int32 OpenMode, const uno::Sequence< beans::Property >& seq, diff --git a/ucb/source/ucp/file/filrset.hxx b/ucb/source/ucp/file/filrset.hxx index 19a169a..17865b7 100644 --- a/ucb/source/ucp/file/filrset.hxx +++ b/ucb/source/ucp/file/filrset.hxx @@ -53,7 +53,7 @@ class XResultSet_impl : public Notifier, { public: - XResultSet_impl( shell* pMyShell, + XResultSet_impl( TaskManager* pMyShell, const OUString& aUnqPath, sal_Int32 OpenMode, const css::uno::Sequence< css::beans::Property >& seq, @@ -536,7 +536,7 @@ class XResultSet_impl : public Notifier, private: - shell* m_pMyShell; + TaskManager* m_pMyShell; bool m_nIsOpen; sal_Int32 m_nRow; bool m_nWasNull; diff --git a/ucb/source/ucp/file/filstr.cxx b/ucb/source/ucp/file/filstr.cxx index 3190bd2..4189183 100644 --- a/ucb/source/ucp/file/filstr.cxx +++ b/ucb/source/ucp/file/filstr.cxx @@ -21,7 +21,7 @@ #include "com/sun/star/uno/RuntimeException.hpp" #include "osl/diagnose.h" #include "filstr.hxx" -#include "shell.hxx" +#include "filtask.hxx" #include "prov.hxx" #include <memory> diff --git a/ucb/source/ucp/file/filstr.hxx b/ucb/source/ucp/file/filstr.hxx index 7a94033..fdc1657 100644 --- a/ucb/source/ucp/file/filstr.hxx +++ b/ucb/source/ucp/file/filstr.hxx @@ -36,7 +36,7 @@ namespace fileaccess { // forward: - class shell; + class TaskManager; class XStream_impl : public cppu::WeakImplHelper< css::io::XStream, diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx index 22cc98f..cc038ca 100644 --- a/ucb/source/ucp/file/filtask.cxx +++ b/ucb/source/ucp/file/filtask.cxx @@ -17,8 +17,29 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/lang/IllegalAccessException.hpp> +#include <com/sun/star/task/InteractionClassification.hpp> +#include <com/sun/star/ucb/ContentInfoAttribute.hpp> +#include <com/sun/star/ucb/IOErrorCode.hpp> +#include <com/sun/star/ucb/InsertCommandArgument.hpp> +#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> +#include <com/sun/star/ucb/NameClash.hpp> +#include <com/sun/star/ucb/OpenCommandArgument.hpp> +#include <com/sun/star/ucb/Store.hpp> +#include <config_features.h> +#include <rtl/uri.hxx> + #include "filtask.hxx" +#include "filcmd.hxx" #include "filglob.hxx" +#include "filinpstr.hxx" +#include "filprp.hxx" +#include "filrset.hxx" +#include "filstr.hxx" +#include "prov.hxx" /******************************************************************************/ /* */ @@ -32,10 +53,331 @@ using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::ucb; +#if OSL_DEBUG_LEVEL > 0 +#define THROW_WHERE SAL_WHERE +#else +#define THROW_WHERE "" +#endif + +TaskManager::UnqPathData::UnqPathData() + : properties( nullptr ), + notifier( nullptr ), + xS( nullptr ), + xC( nullptr ), + xA( nullptr ) +{ + // empty +} + + +TaskManager::UnqPathData::UnqPathData( const UnqPathData& a ) + : properties( a.properties ), + notifier( a.notifier ), + xS( a.xS ), + xC( a.xC ), + xA( a.xA ) +{ +} + + +TaskManager::UnqPathData& TaskManager::UnqPathData::operator=( UnqPathData& a ) +{ + properties = a.properties; + notifier = a.notifier; + xS = a.xS; + xC = a.xC; + xA = a.xA; + a.properties = nullptr; + a.notifier = nullptr; + a.xS = nullptr; + a.xC = nullptr; + a.xA = nullptr; + return *this; +} + +TaskManager::UnqPathData::~UnqPathData() +{ + delete properties; + delete notifier; +} + +TaskManager::MyProperty::MyProperty( const OUString& thePropertyName ) + : PropertyName( thePropertyName ) + , Handle(-1) + , isNative(false) + , State(beans::PropertyState_AMBIGUOUS_VALUE) + , Attributes(0) +{ + // empty +} + +TaskManager::MyProperty::MyProperty( bool theisNative, + const OUString& thePropertyName, + sal_Int32 theHandle, + const css::uno::Type& theTyp, + const css::uno::Any& theValue, + const css::beans::PropertyState& theState, + sal_Int16 theAttributes ) + : PropertyName( thePropertyName ), + Handle( theHandle ), + isNative( theisNative ), + Typ( theTyp ), + Value( theValue ), + State( theState ), + Attributes( theAttributes ) +{ + // empty +} + +TaskManager::MyProperty::~MyProperty() +{ + // empty for now +} + +#include "filinl.hxx" -TaskManager::TaskManager() - : m_nCommandId( 0 ) +TaskManager::TaskManager( const uno::Reference< uno::XComponentContext >& rxContext, + FileProvider* pProvider, bool bWithConfig ) + : m_nCommandId( 0 ), + m_bWithConfig( bWithConfig ), + m_pProvider( pProvider ), + m_xContext( rxContext ), + Title( "Title" ), + CasePreservingURL( "CasePreservingURL" ), + IsDocument( "IsDocument" ), + IsFolder( "IsFolder" ), + DateModified( "DateModified" ), + Size( "Size" ), + IsVolume( "IsVolume" ), + IsRemoveable( "IsRemoveable" ), + IsRemote( "IsRemote" ), + IsCompactDisc( "IsCompactDisc" ), + IsFloppy( "IsFloppy" ), + IsHidden( "IsHidden" ), + ContentType( "ContentType" ), + IsReadOnly( "IsReadOnly" ), + CreatableContentsInfo( "CreatableContentsInfo" ), + FolderContentType( "application/vnd.sun.staroffice.fsys-folder" ), + FileContentType( "application/vnd.sun.staroffice.fsys-file" ), + m_sCommandInfo( 9 ) { + // Title + m_aDefaultProperties.insert( MyProperty( true, + Title, + -1 , + cppu::UnoType<OUString>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND ) ); + + // CasePreservingURL + m_aDefaultProperties.insert( + MyProperty( true, + CasePreservingURL, + -1 , + cppu::UnoType<OUString>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); + + + // IsFolder + m_aDefaultProperties.insert( MyProperty( true, + IsFolder, + -1 , + cppu::UnoType<sal_Bool>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); + + + // IsDocument + m_aDefaultProperties.insert( MyProperty( true, + IsDocument, + -1 , + cppu::UnoType<sal_Bool>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); + + // Removable + m_aDefaultProperties.insert( MyProperty( true, + IsVolume, + -1 , + cppu::UnoType<sal_Bool>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); + + + // Removable + m_aDefaultProperties.insert( MyProperty( true, + IsRemoveable, + -1 , + cppu::UnoType<sal_Bool>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); + + // Remote + m_aDefaultProperties.insert( MyProperty( true, + IsRemote, + -1 , + cppu::UnoType<sal_Bool>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); + + // CompactDisc + m_aDefaultProperties.insert( MyProperty( true, + IsCompactDisc, + -1 , + cppu::UnoType<sal_Bool>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); + + // Floppy + m_aDefaultProperties.insert( MyProperty( true, + IsFloppy, + -1 , + cppu::UnoType<sal_Bool>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); + + // Hidden + m_aDefaultProperties.insert( + MyProperty( + true, + IsHidden, + -1 , + cppu::UnoType<sal_Bool>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND +#if defined(_WIN32) + )); +#else + | beans::PropertyAttribute::READONLY)); // under unix/linux only readable +#endif + + + // ContentType + m_aDefaultProperties.insert( MyProperty( false, + ContentType, + -1 , + cppu::UnoType<OUString>::get(), + uno::Any(OUString()), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); + + + // DateModified + m_aDefaultProperties.insert( MyProperty( true, + DateModified, + -1 , + cppu::UnoType<util::DateTime>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND ) ); + + // Size + m_aDefaultProperties.insert( MyProperty( true, + Size, + -1, + cppu::UnoType<sal_Int64>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND ) ); + + // IsReadOnly + m_aDefaultProperties.insert( MyProperty( true, + IsReadOnly, + -1 , + cppu::UnoType<sal_Bool>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND ) ); + + + // CreatableContentsInfo + m_aDefaultProperties.insert( MyProperty( true, + CreatableContentsInfo, + -1 , + cppu::UnoType<uno::Sequence< ucb::ContentInfo >>::get(), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); + + // Commands + m_sCommandInfo[0].Name = "getCommandInfo"; + m_sCommandInfo[0].Handle = -1; + m_sCommandInfo[0].ArgType = cppu::UnoType<void>::get(); + + m_sCommandInfo[1].Name = "getPropertySetInfo"; + m_sCommandInfo[1].Handle = -1; + m_sCommandInfo[1].ArgType = cppu::UnoType<void>::get(); + + m_sCommandInfo[2].Name = "getPropertyValues"; + m_sCommandInfo[2].Handle = -1; + m_sCommandInfo[2].ArgType = cppu::UnoType<uno::Sequence< beans::Property >>::get(); + + m_sCommandInfo[3].Name = "setPropertyValues"; + m_sCommandInfo[3].Handle = -1; + m_sCommandInfo[3].ArgType = cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(); + + m_sCommandInfo[4].Name = "open"; + m_sCommandInfo[4].Handle = -1; + m_sCommandInfo[4].ArgType = cppu::UnoType<OpenCommandArgument>::get(); + + m_sCommandInfo[5].Name = "transfer"; + m_sCommandInfo[5].Handle = -1; + m_sCommandInfo[5].ArgType = cppu::UnoType<TransferInfo>::get(); + + m_sCommandInfo[6].Name = "delete"; + m_sCommandInfo[6].Handle = -1; + m_sCommandInfo[6].ArgType = cppu::UnoType<sal_Bool>::get(); + + m_sCommandInfo[7].Name = "insert"; + m_sCommandInfo[7].Handle = -1; + m_sCommandInfo[7].ArgType = cppu::UnoType<InsertCommandArgument>::get(); + + m_sCommandInfo[7].Name = "createNewContent"; + m_sCommandInfo[7].Handle = -1; + m_sCommandInfo[7].ArgType = cppu::UnoType<ucb::ContentInfo>::get(); + + if(m_bWithConfig) + { + uno::Reference< XPropertySetRegistryFactory > xRegFac = ucb::Store::create( m_xContext ); + // Open/create a registry + m_xFileRegistry = xRegFac->createPropertySetRegistry( OUString() ); + } } @@ -163,4 +505,2595 @@ void SAL_CALL TaskManager::handleTask( } } +/*********************************************************************************/ +/* */ +/* de/registerNotifier-Implementation */ +/* */ +/*********************************************************************************/ + + +// This two methods register and deregister a change listener for the content belonging +// to URL aUnqPath + + +void SAL_CALL +TaskManager::registerNotifier( const OUString& aUnqPath, Notifier* pNotifier ) +{ + osl::MutexGuard aGuard( m_aMutex ); + + ContentMap::iterator it = + m_aContent.insert( ContentMap::value_type( aUnqPath,UnqPathData() ) ).first; + + if( ! it->second.notifier ) + it->second.notifier = new NotifierList(); + + std::list< Notifier* >& nlist = *( it->second.notifier ); + + std::list<Notifier*>::iterator it1 = nlist.begin(); + while( it1 != nlist.end() ) // Every "Notifier" only once + { + if( *it1 == pNotifier ) return; + ++it1; + } + nlist.push_back( pNotifier ); +} + + +void SAL_CALL +TaskManager::deregisterNotifier( const OUString& aUnqPath,Notifier* pNotifier ) +{ + osl::MutexGuard aGuard( m_aMutex ); + + ContentMap::iterator it = m_aContent.find( aUnqPath ); + if( it == m_aContent.end() ) + return; + + it->second.notifier->remove( pNotifier ); + + if( it->second.notifier->empty() ) + m_aContent.erase( it ); +} + + +/*********************************************************************************/ +/* */ +/* de/associate-Implementation */ +/* */ +/*********************************************************************************/ + +// Used to associate and deassociate a new property with +// the content belonging to URL UnqPath. +// The default value and the attributes are input + + +void SAL_CALL +TaskManager::associate( const OUString& aUnqPath, + const OUString& PropertyName, + const uno::Any& DefaultValue, + const sal_Int16 Attributes ) + throw( beans::PropertyExistException, + beans::IllegalTypeException, + uno::RuntimeException ) +{ + MyProperty newProperty( false, + PropertyName, + -1, + DefaultValue.getValueType(), + DefaultValue, + beans::PropertyState_DEFAULT_VALUE, + Attributes ); + + TaskManager::PropertySet::iterator it1 = m_aDefaultProperties.find( newProperty ); + if( it1 != m_aDefaultProperties.end() ) + throw beans::PropertyExistException( THROW_WHERE ); + + { + osl::MutexGuard aGuard( m_aMutex ); + + ContentMap::iterator it = m_aContent.insert( ContentMap::value_type( aUnqPath,UnqPathData() ) ).first; + + // Load the XPersistentPropertySetInfo and create it, if it does not exist + load( it,true ); + + PropertySet& properties = *(it->second.properties); + it1 = properties.find( newProperty ); + if( it1 != properties.end() ) + throw beans::PropertyExistException(THROW_WHERE ); + + // Property does not exist + properties.insert( newProperty ); + it->second.xC->addProperty( PropertyName,Attributes,DefaultValue ); + } + notifyPropertyAdded( getPropertySetListeners( aUnqPath ), PropertyName ); +} + + +void SAL_CALL +TaskManager::deassociate( const OUString& aUnqPath, + const OUString& PropertyName ) + throw( beans::UnknownPropertyException, + beans::NotRemoveableException, + uno::RuntimeException ) +{ + MyProperty oldProperty( PropertyName ); + + TaskManager::PropertySet::iterator it1 = m_aDefaultProperties.find( oldProperty ); + if( it1 != m_aDefaultProperties.end() ) + throw beans::NotRemoveableException( THROW_WHERE ); + + osl::MutexGuard aGuard( m_aMutex ); + + ContentMap::iterator it = m_aContent.insert( ContentMap::value_type( aUnqPath,UnqPathData() ) ).first; + + load( it,false ); + + PropertySet& properties = *(it->second.properties); + + it1 = properties.find( oldProperty ); + if( it1 == properties.end() ) + throw beans::UnknownPropertyException( THROW_WHERE ); + + properties.erase( it1 ); + + if( it->second.xC.is() ) + it->second.xC->removeProperty( PropertyName ); + + if( properties.size() == 9 ) + { + MyProperty ContentTProperty( ContentType ); + + if( properties.find( ContentTProperty )->getState() == beans::PropertyState_DEFAULT_VALUE ) + { + it->second.xS = nullptr; + it->second.xC = nullptr; + it->second.xA = nullptr; + if(m_xFileRegistry.is()) + m_xFileRegistry->removePropertySet( aUnqPath ); + } + } + notifyPropertyRemoved( getPropertySetListeners( aUnqPath ), PropertyName ); +} + + +/*********************************************************************************/ +/* */ +/* page-Implementation */ +/* */ +/*********************************************************************************/ + +// Given an xOutputStream, this method writes the content of the file belonging to +// URL aUnqPath into the XOutputStream + + +void SAL_CALL TaskManager::page( sal_Int32 CommandId, + const OUString& aUnqPath, + const uno::Reference< io::XOutputStream >& xOutputStream ) +{ + uno::Reference< XContentProvider > xProvider( m_pProvider ); + osl::File aFile( aUnqPath ); + osl::FileBase::RC err = aFile.open( osl_File_OpenFlag_Read ); + + if( err != osl::FileBase::E_None ) + { + aFile.close(); + installError( CommandId, + TASKHANDLING_OPEN_FILE_FOR_PAGING, + err ); + return; + } + + const sal_uInt64 bfz = 4*1024; + sal_Int8 BFF[bfz]; + sal_uInt64 nrc; // Retrieved number of Bytes; + + do + { + err = aFile.read( static_cast<void*>(BFF),bfz,nrc ); + if( err == osl::FileBase::E_None ) + { + uno::Sequence< sal_Int8 > seq( BFF, (sal_uInt32)nrc ); + try + { + xOutputStream->writeBytes( seq ); + } + catch (const io::NotConnectedException&) + { + installError( CommandId, + TASKHANDLING_NOTCONNECTED_FOR_PAGING ); + break; + } + catch (const io::BufferSizeExceededException&) + { + installError( CommandId, + TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING ); + break; + } + catch (const io::IOException&) + { + installError( CommandId, + TASKHANDLING_IOEXCEPTION_FOR_PAGING ); + break; + } + } + else + { + installError( CommandId, + TASKHANDLING_READING_FILE_FOR_PAGING, + err ); + break; + } + } while( nrc == bfz ); + + + aFile.close(); + + + try + { + xOutputStream->closeOutput(); + } + catch (const io::NotConnectedException&) + { + } + catch (const io::BufferSizeExceededException&) + { + } + catch (const io::IOException&) + { + } +} + + +/*********************************************************************************/ +/* */ +/* open-Implementation */ +/* */ +/*********************************************************************************/ + +// Given a file URL aUnqPath, this methods returns a XInputStream which reads from the open file. + + +uno::Reference< io::XInputStream > SAL_CALL +TaskManager::open( sal_Int32 CommandId, + const OUString& aUnqPath, + bool bLock ) +{ + XInputStream_impl* pInputStream = new XInputStream_impl( aUnqPath, bLock ); // from filinpstr.hxx + + sal_Int32 ErrorCode = pInputStream->CtorSuccess(); + + if( ErrorCode != TASKHANDLER_NO_ERROR ) + { + installError( CommandId, + ErrorCode, + pInputStream->getMinorError() ); + + delete pInputStream; + pInputStream = nullptr; + } + + return uno::Reference< io::XInputStream >( pInputStream ); +} + + +/*********************************************************************************/ +/* */ +/* open for read/write access-Implementation */ +/* */ +/*********************************************************************************/ + +// Given a file URL aUnqPath, this methods returns a XStream which can be used +// to read and write from/to the file. + + +uno::Reference< io::XStream > SAL_CALL +TaskManager::open_rw( sal_Int32 CommandId, + const OUString& aUnqPath, + bool bLock ) +{ + XStream_impl* pStream = new XStream_impl( aUnqPath, bLock ); // from filstr.hxx + + sal_Int32 ErrorCode = pStream->CtorSuccess(); + + if( ErrorCode != TASKHANDLER_NO_ERROR ) + { + installError( CommandId, + ErrorCode, + pStream->getMinorError() ); + + delete pStream; + pStream = nullptr; + } + return uno::Reference< io::XStream >( pStream ); +} + + +/*********************************************************************************/ +/* */ +/* ls-Implementation */ +/* */ +/*********************************************************************************/ + +// This method returns the result set containing the children of the directory belonging +// to file URL aUnqPath + + +uno::Reference< XDynamicResultSet > SAL_CALL +TaskManager::ls( sal_Int32 CommandId, + const OUString& aUnqPath, + const sal_Int32 OpenMode, + const uno::Sequence< beans::Property >& seq, + const uno::Sequence< NumberedSortingInfo >& seqSort ) +{ + XResultSet_impl* p = new XResultSet_impl( this,aUnqPath,OpenMode,seq,seqSort ); + + sal_Int32 ErrorCode = p->CtorSuccess(); + + if( ErrorCode != TASKHANDLER_NO_ERROR ) + { + installError( CommandId, + ErrorCode, + p->getMinorError() ); + + delete p; + p = nullptr; + } + + return uno::Reference< XDynamicResultSet > ( p ); +} + + +/*********************************************************************************/ +/* */ +/* info_c implementation */ +/* */ +/*********************************************************************************/ +// Info for commands + +uno::Reference< XCommandInfo > SAL_CALL +TaskManager::info_c() +{ + XCommandInfo_impl* p = new XCommandInfo_impl( this ); + return uno::Reference< XCommandInfo >( p ); +} + + +/*********************************************************************************/ +/* */ +/* info_p-Implementation */ +/* */ +/*********************************************************************************/ +// Info for the properties + +uno::Reference< beans::XPropertySetInfo > SAL_CALL +TaskManager::info_p( const OUString& aUnqPath ) +{ + osl::MutexGuard aGuard( m_aMutex ); + XPropertySetInfo_impl* p = new XPropertySetInfo_impl( this,aUnqPath ); + return uno::Reference< beans::XPropertySetInfo >( p ); +} + + +/*********************************************************************************/ +/* */ +/* setv-Implementation */ +/* */ +/*********************************************************************************/ + +// Sets the values of the properties belonging to fileURL aUnqPath + + +uno::Sequence< uno::Any > SAL_CALL +TaskManager::setv( const OUString& aUnqPath, + const uno::Sequence< beans::PropertyValue >& values ) +{ + osl::MutexGuard aGuard( m_aMutex ); + + sal_Int32 propChanged = 0; + uno::Sequence< uno::Any > ret( values.getLength() ); + uno::Sequence< beans::PropertyChangeEvent > seqChanged( values.getLength() ); + + TaskManager::ContentMap::iterator it = m_aContent.find( aUnqPath ); + PropertySet& properties = *( it->second.properties ); + TaskManager::PropertySet::iterator it1; + uno::Any aAny; + + for( sal_Int32 i = 0; i < values.getLength(); ++i ) + { + MyProperty toset( values[i].Name ); + it1 = properties.find( toset ); + if( it1 == properties.end() ) + { + ret[i] <<= beans::UnknownPropertyException( THROW_WHERE ); + continue; + } + + aAny = it1->getValue(); + if( aAny == values[i].Value ) + continue; // nothing needs to be changed + + if( it1->getAttributes() & beans::PropertyAttribute::READONLY ) + { + ret[i] <<= lang::IllegalAccessException( THROW_WHERE ); + continue; + } + + seqChanged[ propChanged ].PropertyName = values[i].Name; + seqChanged[ propChanged ].PropertyHandle = -1; + seqChanged[ propChanged ].Further = false; + seqChanged[ propChanged ].OldValue = aAny; + seqChanged[ propChanged++ ].NewValue = values[i].Value; + + it1->setValue( values[i].Value ); // Put the new value into the local cash + + if( ! it1->IsNative() ) + { + // Also put logical properties into storage + if( !it->second.xS.is() ) + load( it,true ); + + if( ( values[i].Name == ContentType ) && + it1->getState() == beans::PropertyState_DEFAULT_VALUE ) + { // Special logic for ContentType + // 09.07.01: Not reached anymore, because ContentType is readonly + it1->setState( beans::PropertyState_DIRECT_VALUE ); + it->second.xC->addProperty( values[i].Name, + beans::PropertyAttribute::MAYBEVOID, + values[i].Value ); + } + + try + { + it->second.xS->setPropertyValue( values[i].Name,values[i].Value ); + } + catch (const uno::Exception&e) + { + --propChanged; // unsuccessful setting + ret[i] <<= e; + } + } + else + { + // native properties + // Setting of physical file properties + if( values[i].Name == Size ) + { + sal_Int64 newSize = 0; + if( values[i].Value >>= newSize ) + { // valid value for the size + osl::File aFile(aUnqPath); + bool err = + aFile.open(osl_File_OpenFlag_Write) != osl::FileBase::E_None || + aFile.setSize(sal_uInt64(newSize)) != osl::FileBase::E_None || + aFile.close() != osl::FileBase::E_None; + + if( err ) + { + --propChanged; // unsuccessful setting + uno::Sequence< uno::Any > names( 1 ); + ret[0] <<= beans::PropertyValue( + OUString("Uri"), -1, + uno::makeAny(aUnqPath), + beans::PropertyState_DIRECT_VALUE); + IOErrorCode ioError(IOErrorCode_GENERAL); + ret[i] <<= InteractiveAugmentedIOException( + OUString(), + nullptr, + task::InteractionClassification_ERROR, + ioError, + names ); + } + } + else + ret[i] <<= beans::IllegalTypeException( THROW_WHERE ); + } + else if(values[i].Name == IsReadOnly || + values[i].Name == IsHidden) + { + bool value = false; + if( values[i].Value >>= value ) + { + osl::DirectoryItem aDirItem; + osl::FileBase::RC err = + osl::DirectoryItem::get(aUnqPath,aDirItem); + sal_uInt64 nAttributes(0); + if(err == osl::FileBase::E_None) + { + osl::FileStatus aFileStatus(osl_FileStatus_Mask_Attributes); + err = aDirItem.getFileStatus(aFileStatus); + if(err == osl::FileBase::E_None && + aFileStatus.isValid(osl_FileStatus_Mask_Attributes)) + nAttributes = aFileStatus.getAttributes(); + } + // now we have the attributes provided all went well. + if(err == osl::FileBase::E_None) { + if(values[i].Name == IsReadOnly) + { + nAttributes &= ~(osl_File_Attribute_OwnWrite | + osl_File_Attribute_GrpWrite | + osl_File_Attribute_OthWrite | + osl_File_Attribute_ReadOnly); + if(value) + nAttributes |= osl_File_Attribute_ReadOnly; + else + nAttributes |= ( + osl_File_Attribute_OwnWrite | + osl_File_Attribute_GrpWrite | + osl_File_Attribute_OthWrite); + } + else if(values[i].Name == IsHidden) + { + nAttributes &= ~(osl_File_Attribute_Hidden); + if(value) + nAttributes |= osl_File_Attribute_Hidden; + } + err = osl::File::setAttributes( + aUnqPath,nAttributes); + } + + if( err != osl::FileBase::E_None ) + { + --propChanged; // unsuccessful setting + uno::Sequence< uno::Any > names( 1 ); + names[0] <<= beans::PropertyValue( + OUString("Uri"), -1, + uno::makeAny(aUnqPath), + beans::PropertyState_DIRECT_VALUE); + IOErrorCode ioError; + switch( err ) + { + case osl::FileBase::E_NOMEM: + // not enough memory for allocating structures <br> + ioError = IOErrorCode_OUT_OF_MEMORY; + break; + case osl::FileBase::E_INVAL: + // the format of the parameters was not valid<p> + ioError = IOErrorCode_INVALID_PARAMETER; + break; + case osl::FileBase::E_NAMETOOLONG: + // File name too long<br> + ioError = IOErrorCode_NAME_TOO_LONG; + break; + case osl::FileBase::E_NOENT: + // No such file or directory<br> + case osl::FileBase::E_NOLINK: + // Link has been severed<br> + ioError = IOErrorCode_NOT_EXISTING; + break; + case osl::FileBase::E_ROFS: + // #i4735# handle ROFS transparently + // as ACCESS_DENIED + case osl::FileBase::E_PERM: + case osl::FileBase::E_ACCES: + // permission denied<br> + ioError = IOErrorCode_ACCESS_DENIED; + break; + case osl::FileBase::E_LOOP: + // Too many symbolic links encountered<br> + case osl::FileBase::E_FAULT: + // Bad address<br> + case osl::FileBase::E_IO: + // I/O error<br> + case osl::FileBase::E_NOSYS: + // Function not implemented<br> + case osl::FileBase::E_MULTIHOP: + // Multihop attempted<br> + case osl::FileBase::E_INTR: + // function call was interrupted<p> + default: + ioError = IOErrorCode_GENERAL; + break; + } + ret[i] <<= InteractiveAugmentedIOException( + OUString(), + nullptr, + task::InteractionClassification_ERROR, + ioError, + names ); + } + } + else + ret[i] <<= beans::IllegalTypeException( THROW_WHERE ); + } + } + } // end for + + if( propChanged ) + { + seqChanged.realloc( propChanged ); + notifyPropertyChanges( getPropertyChangeNotifier( aUnqPath ),seqChanged ); + } + + return ret; +} + +/*********************************************************************************/ +/* */ +/* getv-Implementation */ +/* */ +/*********************************************************************************/ + +// Reads the values of the properties belonging to fileURL aUnqPath; +// Returns an XRow object containing the values in the requested order. + + +uno::Reference< sdbc::XRow > SAL_CALL +TaskManager::getv( sal_Int32 CommandId, + const OUString& aUnqPath, + const uno::Sequence< beans::Property >& properties ) +{ + uno::Sequence< uno::Any > seq( properties.getLength() ); + + sal_Int32 n_Mask; + getMaskFromProperties( n_Mask,properties ); + osl::FileStatus aFileStatus( n_Mask ); + + osl::DirectoryItem aDirItem; + osl::FileBase::RC nError1 = osl::DirectoryItem::get( aUnqPath,aDirItem ); + if( nError1 != osl::FileBase::E_None ) + installError(CommandId, + TASKHANDLING_OPEN_FILE_FOR_PAGING, // BEAWARE, REUSED + nError1); + + osl::FileBase::RC nError2 = aDirItem.getFileStatus( aFileStatus ); + if( nError1 == osl::FileBase::E_None && + nError2 != osl::FileBase::E_None ) + installError(CommandId, + TASKHANDLING_OPEN_FILE_FOR_PAGING, // BEAWARE, REUSED + nError2); + + { + osl::MutexGuard aGuard( m_aMutex ); + + TaskManager::ContentMap::iterator it = m_aContent.find( aUnqPath ); + commit( it,aFileStatus ); + + TaskManager::PropertySet::iterator it1; + PropertySet& propset = *(it->second.properties); + + for( sal_Int32 i = 0; i < seq.getLength(); ++i ) + { + MyProperty readProp( properties[i].Name ); + it1 = propset.find( readProp ); + if( it1 == propset.end() ) + seq[i] = uno::Any(); + else + seq[i] = it1->getValue(); + } + } + + XRow_impl* p = new XRow_impl( this,seq ); + return uno::Reference< sdbc::XRow >( p ); +} + + +/********************************************************************************/ +/* */ +/* transfer-commandos */ +/* */ +/********************************************************************************/ + + +/********************************************************************************/ +/* */ +/* move-implementation */ +/* */ +/********************************************************************************/ + +// Moves the content belonging to fileURL srcUnqPath to fileURL dstUnqPath. + + +void SAL_CALL +TaskManager::move( sal_Int32 CommandId, + const OUString& srcUnqPath, + const OUString& dstUnqPathIn, + const sal_Int32 NameClash ) +{ + // --> #i88446# Method notifyContentExchanged( getContentExchangedEventListeners( srcUnqPath,dstUnqPath,!isDocument ) ); crashes if + // srcUnqPath and dstUnqPathIn are equal + if( srcUnqPath == dstUnqPathIn ) + return; + + osl::FileBase::RC nError; + OUString dstUnqPath( dstUnqPathIn ); + + switch( NameClash ) + { + case NameClash::KEEP: + { + nError = osl_File_move( srcUnqPath,dstUnqPath,true ); + if( nError != osl::FileBase::E_None && nError != osl::FileBase::E_EXIST ) + { + installError( CommandId, + TASKHANDLING_KEEPERROR_FOR_MOVE, + nError ); + return; + } + break; + } + case NameClash::OVERWRITE: + { + // stat to determine whether we have a symlink + OUString targetPath(dstUnqPath); + + osl::FileStatus aStatus(osl_FileStatus_Mask_Type|osl_FileStatus_Mask_LinkTargetURL); + osl::DirectoryItem aItem; + osl::DirectoryItem::get(dstUnqPath,aItem); + aItem.getFileStatus(aStatus); + + if( aStatus.isValid(osl_FileStatus_Mask_Type) && + aStatus.isValid(osl_FileStatus_Mask_LinkTargetURL) && + aStatus.getFileType() == osl::FileStatus::Link ) + targetPath = aStatus.getLinkTargetURL(); + + // Will do nothing if file does not exist. + osl::File::remove( targetPath ); + + nError = osl_File_move( srcUnqPath,targetPath ); + if( nError != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_OVERWRITE_FOR_MOVE, + nError ); + return; + } + break; + } + case NameClash::RENAME: + { + OUString newDstUnqPath; + nError = osl_File_move( srcUnqPath,dstUnqPath,true ); + if( nError == osl::FileBase::E_EXIST ) + { + // "invent" a new valid title. + + sal_Int32 nPos = -1; + sal_Int32 nLastDot = dstUnqPath.lastIndexOf( '.' ); + sal_Int32 nLastSlash = dstUnqPath.lastIndexOf( '/' ); + if( ( nLastSlash < nLastDot ) // dot is part of last(!) path segment + && ( nLastSlash != ( nLastDot - 1 ) ) ) // file name does not start with a dot + nPos = nLastDot; + else + nPos = dstUnqPath.getLength(); + + sal_Int32 nTry = 0; + + do + { + newDstUnqPath = dstUnqPath; + + OUString aPostfix = "_" + OUString::number( ++nTry ); + + newDstUnqPath = newDstUnqPath.replaceAt( nPos, 0, aPostfix ); + + nError = osl_File_move( srcUnqPath,newDstUnqPath,true ); + } + while( ( nError == osl::FileBase::E_EXIST ) && ( nTry < 10000 ) ); + } + + if( nError == osl::FileBase::E_EXIST ) + { + installError( CommandId, + TASKHANDLING_RENAME_FOR_MOVE ); + return; + } + else if( nError != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_RENAMEMOVE_FOR_MOVE, + nError ); + return; + } + else + dstUnqPath = newDstUnqPath; + + break; + } + case NameClash::ERROR: + { + nError = osl_File_move( srcUnqPath,dstUnqPath,true ); + if( nError == osl::FileBase::E_EXIST ) + { + installError( CommandId, + TASKHANDLING_NAMECLASH_FOR_MOVE ); + return; + } + else if( nError != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_NAMECLASHMOVE_FOR_MOVE, + nError ); + return; + } + break; + } + case NameClash::ASK: + default: + { + nError = osl_File_move( srcUnqPath,dstUnqPath,true ); + if( nError == osl::FileBase::E_EXIST ) + { + installError( CommandId, + TASKHANDLING_NAMECLASHSUPPORT_FOR_MOVE, + NameClash::ASK); + return; + } + } + break; + } + + // Determine, whether we have moved a file or a folder + osl::DirectoryItem aItem; + nError = osl::DirectoryItem::get( dstUnqPath,aItem ); + if( nError != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_TRANSFER_BY_MOVE_SOURCE, + nError ); + return; + } + osl::FileStatus aStatus( osl_FileStatus_Mask_Type ); + nError = aItem.getFileStatus( aStatus ); + if( nError != osl::FileBase::E_None || ! aStatus.isValid( osl_FileStatus_Mask_Type ) ) + { + installError( CommandId, + TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT, + nError ); + return; + } + bool isDocument = ( aStatus.getFileType() == osl::FileStatus::Regular ); + + + copyPersistentSet( srcUnqPath,dstUnqPath,!isDocument ); + + OUString aDstParent = getParentName( dstUnqPath ); + OUString aSrcParent = getParentName( srcUnqPath ); + + notifyInsert( getContentEventListeners( aDstParent ),dstUnqPath ); + if( aDstParent != aSrcParent ) + notifyContentRemoved( getContentEventListeners( aSrcParent ),srcUnqPath ); + + notifyContentExchanged( getContentExchangedEventListeners( srcUnqPath,dstUnqPath,!isDocument ) ); + erasePersistentSet( srcUnqPath,!isDocument ); +} + + +/********************************************************************************/ +/* */ +/* copy-implementation */ +/* */ +/********************************************************************************/ + +// Copies the content belonging to fileURL srcUnqPath to fileURL dstUnqPath ( files and directories ) + + +namespace { + +bool getType( + TaskManager & task, sal_Int32 id, OUString const & fileUrl, + osl::DirectoryItem * item, osl::FileStatus::Type * type) +{ + OSL_ASSERT(item != nullptr && type != nullptr); + osl::FileBase::RC err = osl::DirectoryItem::get(fileUrl, *item); + if (err != osl::FileBase::E_None) { + task.installError(id, TASKHANDLING_TRANSFER_BY_COPY_SOURCE, err); + return false; + } + osl::FileStatus stat(osl_FileStatus_Mask_Type); + err = item->getFileStatus(stat); + if (err != osl::FileBase::E_None) { + task.installError(id, TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT, err); + return false; + } + *type = stat.getFileType(); + return true; +} + +} + +void SAL_CALL +TaskManager::copy( + sal_Int32 CommandId, + const OUString& srcUnqPath, + const OUString& dstUnqPathIn, + sal_Int32 NameClash ) +{ + osl::FileBase::RC nError; + OUString dstUnqPath( dstUnqPathIn ); + + // Resolve symbolic links within the source path. If srcUnqPath denotes a + // symbolic link (targeting either a file or a folder), the contents of the + // target is copied (recursively, in the case of a folder). However, if + // recursively copying the contents of a folder causes a symbolic link to be + // copied, the symbolic link itself is copied. + osl::DirectoryItem item; + osl::FileStatus::Type type; + if (!getType(*this, CommandId, srcUnqPath, &item, &type)) { + return; + } + OUString rslvdSrcUnqPath; + if (type == osl::FileStatus::Link) { + osl::FileStatus stat(osl_FileStatus_Mask_LinkTargetURL); + nError = item.getFileStatus(stat); + if (nError != osl::FileBase::E_None) { + installError( + CommandId, TASKHANDLING_TRANSFER_BY_COPY_SOURCESTAT, nError); + return; + } + rslvdSrcUnqPath = stat.getLinkTargetURL(); + if (!getType(*this, CommandId, srcUnqPath, &item, &type)) { + return; + } + } else { + rslvdSrcUnqPath = srcUnqPath; + } + + bool isDocument + = type != osl::FileStatus::Directory && type != osl::FileStatus::Volume; + FileUrlType IsWhat = isDocument ? FileUrlType::File : FileUrlType::Folder; + + switch( NameClash ) + { + case NameClash::KEEP: + { + nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,true ); + if( nError != osl::FileBase::E_None && nError != osl::FileBase::E_EXIST ) + { + installError( CommandId, + TASKHANDLING_KEEPERROR_FOR_COPY, + nError ); + return; + } + break; + } + case NameClash::OVERWRITE: + { + // remove (..., MustExist = sal_False). + remove( CommandId, dstUnqPath, IsWhat, false ); + + // copy. + nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,false ); + if( nError != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_OVERWRITE_FOR_COPY, + nError ); + return; + } + break; + } + case NameClash::RENAME: + { + OUString newDstUnqPath; + nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,true ); + + if( nError == osl::FileBase::E_EXIST ) + { + // "invent" a new valid title. + + sal_Int32 nPos = -1; + sal_Int32 nLastDot = dstUnqPath.lastIndexOf( '.' ); + sal_Int32 nLastSlash = dstUnqPath.lastIndexOf( '/' ); + if ( ( nLastSlash < nLastDot ) // dot is part of last(!) path segment + && ( nLastSlash != ( nLastDot - 1 ) ) ) // file name does not start with a dot + nPos = nLastDot; + else + nPos = dstUnqPath.getLength(); + + sal_Int32 nTry = 0; + + do + { + newDstUnqPath = dstUnqPath; + + OUString aPostfix = "_" + OUString::number( ++nTry ); + + newDstUnqPath = newDstUnqPath.replaceAt( nPos, 0, aPostfix ); + + nError = copy_recursive( rslvdSrcUnqPath,newDstUnqPath,IsWhat,true ); + } + while( ( nError == osl::FileBase::E_EXIST ) && ( nTry < 10000 ) ); + } + + if( nError == osl::FileBase::E_EXIST ) + { + installError( CommandId, + TASKHANDLING_RENAME_FOR_COPY ); + return; + } + else if( nError != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_RENAMEMOVE_FOR_COPY, + nError ); + return; + } + else + dstUnqPath = newDstUnqPath; + + break; + } + case NameClash::ERROR: + { + nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,true ); + + if( nError == osl::FileBase::E_EXIST ) + { + installError( CommandId, + TASKHANDLING_NAMECLASH_FOR_COPY ); + return; + } + else if( nError != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_NAMECLASHMOVE_FOR_COPY, + nError ); + return; + } + break; + } + case NameClash::ASK: + default: + { + nError = copy_recursive( rslvdSrcUnqPath,dstUnqPath,IsWhat,true ); + + if( nError == osl::FileBase::E_EXIST ) + { + installError( CommandId, + TASKHANDLING_NAMECLASHSUPPORT_FOR_COPY, + NameClash); + return; + } + break; + } + } + + copyPersistentSet( srcUnqPath,dstUnqPath, !isDocument ); + notifyInsert( getContentEventListeners( getParentName( dstUnqPath ) ),dstUnqPath ); +} + + +/********************************************************************************/ +/* */ +/* remove-implementation */ +/* */ +/********************************************************************************/ + +// Deletes the content belonging to fileURL aUnqPath( recursively in case of directory ) +// Return: success of operation + + +bool SAL_CALL +TaskManager::remove( sal_Int32 CommandId, + const OUString& aUnqPath, + FileUrlType IsWhat, + bool MustExist ) +{ + sal_Int32 nMask = osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileURL; + + osl::DirectoryItem aItem; + osl::FileStatus aStatus( nMask ); + osl::FileBase::RC nError; + + if( IsWhat == FileUrlType::Unknown ) // Determine whether we are removing a directory or a file + { + nError = osl::DirectoryItem::get( aUnqPath, aItem ); + if( nError != osl::FileBase::E_None ) + { + if (MustExist) + { + installError( CommandId, + TASKHANDLING_NOSUCHFILEORDIR_FOR_REMOVE, + nError ); + } + return (!MustExist); + } + + nError = aItem.getFileStatus( aStatus ); + if( nError != osl::FileBase::E_None || ! aStatus.isValid( nMask ) ) + { + installError( CommandId, + TASKHANDLING_VALIDFILESTATUS_FOR_REMOVE, + nError != osl::FileBase::E_None ? nError : TASKHANDLER_NO_ERROR ); + return false; + } + + if( aStatus.getFileType() == osl::FileStatus::Regular || + aStatus.getFileType() == osl::FileStatus::Link ) + IsWhat = FileUrlType::File; + else if( aStatus.getFileType() == osl::FileStatus::Directory || + aStatus.getFileType() == osl::FileStatus::Volume ) + IsWhat = FileUrlType::Folder; + } + + + if( IsWhat == FileUrlType::File ) + { + nError = osl::File::remove( aUnqPath ); + if( nError != osl::FileBase::E_None ) + { + if (MustExist) + { + installError( CommandId, + TASKHANDLING_DELETEFILE_FOR_REMOVE, + nError ); + } + return (!MustExist); + } + else + { + notifyContentDeleted( getContentDeletedEventListeners(aUnqPath) ); + erasePersistentSet( aUnqPath ); // Removes from XPersistentPropertySet + } + } + else if( IsWhat == FileUrlType::Folder ) + { + osl::Directory aDirectory( aUnqPath ); + + nError = aDirectory.open(); + if( nError != osl::FileBase::E_None ) + { + if (MustExist) + { + installError( CommandId, + TASKHANDLING_OPENDIRECTORY_FOR_REMOVE, + nError ); + } + return (!MustExist); + } + + bool whileSuccess = true; + FileUrlType recurse = FileUrlType::Unknown; + OUString name; + + nError = aDirectory.getNextItem( aItem ); + while( nError == osl::FileBase::E_None ) + { + nError = aItem.getFileStatus( aStatus ); + if( nError != osl::FileBase::E_None || ! aStatus.isValid( nMask ) ) + { + installError( CommandId, + TASKHANDLING_VALIDFILESTATUSWHILE_FOR_REMOVE, + nError != osl::FileBase::E_None ? nError : TASKHANDLER_NO_ERROR ); + whileSuccess = false; + break; + } + + if( aStatus.getFileType() == osl::FileStatus::Regular || + aStatus.getFileType() == osl::FileStatus::Link ) + recurse = FileUrlType::File; + else if( aStatus.getFileType() == osl::FileStatus::Directory || + aStatus.getFileType() == osl::FileStatus::Volume ) + recurse = FileUrlType::Folder; + + name = aStatus.getFileURL(); + whileSuccess = remove( CommandId, name, recurse, MustExist ); + if( !whileSuccess ) + break; + + nError = aDirectory.getNextItem( aItem ); + } + + aDirectory.close(); + + if( ! whileSuccess ) + return false; // error code is installed + + if( nError != osl::FileBase::E_NOENT ) + { + installError( CommandId, + TASKHANDLING_DIRECTORYEXHAUSTED_FOR_REMOVE, + nError ); + return false; + } + + nError = osl::Directory::remove( aUnqPath ); + if( nError != osl::FileBase::E_None ) + { + if (MustExist) + { + installError( CommandId, + TASKHANDLING_DELETEDIRECTORY_FOR_REMOVE, + nError ); + } + return (!MustExist); + } + else + { + notifyContentDeleted( getContentDeletedEventListeners(aUnqPath) ); + erasePersistentSet( aUnqPath ); + } + } + else // Don't know what to remove + { + installError( CommandId, + TASKHANDLING_FILETYPE_FOR_REMOVE ); + return false; + } + + return true; +} + + +/********************************************************************************/ +/* */ +/* mkdir-implementation */ +/* */ +/********************************************************************************/ + +// Creates new directory with given URL, recursively if necessary +// Return:: success of operation + + +bool SAL_CALL +TaskManager::mkdir( sal_Int32 CommandId, + const OUString& rUnqPath, + bool OverWrite ) +{ + OUString aUnqPath; + + // remove trailing slash + if ( rUnqPath.endsWith("/") ) + aUnqPath = rUnqPath.copy( 0, rUnqPath.getLength() - 1 ); + else + aUnqPath = rUnqPath; + + osl::FileBase::RC nError = osl::Directory::create( aUnqPath ); + + switch ( nError ) + { + case osl::FileBase::E_EXIST: // Directory cannot be overwritten + { + if( !OverWrite ) + { + installError( CommandId, + TASKHANDLING_FOLDER_EXISTS_MKDIR ); + return false; + } + else + return true; + } + case osl::FileBase::E_INVAL: + { + installError(CommandId, + TASKHANDLING_INVALID_NAME_MKDIR); + return false; + } + case osl::FileBase::E_None: + { + OUString aPrtPath = getParentName( aUnqPath ); + notifyInsert( getContentEventListeners( aPrtPath ),aUnqPath ); + return true; + } + default: + return ensuredir( + CommandId, + aUnqPath, + TASKHANDLING_CREATEDIRECTORY_MKDIR ); + } +} + + +/********************************************************************************/ +/* */ +/* mkfil-implementation */ +/* */ +/********************************************************************************/ + +// Creates new file with given URL. +// The content of aInputStream becomes the content of the file +// Return:: success of operation + + +bool SAL_CALL +TaskManager::mkfil( sal_Int32 CommandId, + const OUString& aUnqPath, + bool Overwrite, + const uno::Reference< io::XInputStream >& aInputStream ) +{ + // return value unimportant + bool bSuccess = write( CommandId, + aUnqPath, + Overwrite, + aInputStream ); + if ( bSuccess ) + { + OUString aPrtPath = getParentName( aUnqPath ); + notifyInsert( getContentEventListeners( aPrtPath ),aUnqPath ); + } + return bSuccess; +} + + +/********************************************************************************/ +/* */ +/* write-implementation */ +/* */ +/********************************************************************************/ + +// writes to the file with given URL. +// The content of aInputStream becomes the content of the file +// Return:: success of operation + + +bool SAL_CALL +TaskManager::write( sal_Int32 CommandId, + const OUString& aUnqPath, + bool OverWrite, + const uno::Reference< io::XInputStream >& aInputStream ) +{ + if( ! aInputStream.is() ) + { + installError( CommandId, + TASKHANDLING_INPUTSTREAM_FOR_WRITE ); + return false; + } + + // Create parent path, if necessary. + if ( ! ensuredir( CommandId, + getParentName( aUnqPath ), + TASKHANDLING_ENSUREDIR_FOR_WRITE ) ) + return false; + + osl::FileBase::RC err; + osl::File aFile( aUnqPath ); + + if( OverWrite ) + { + err = aFile.open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create ); + + if( err != osl::FileBase::E_None ) + { + aFile.close(); + err = aFile.open( osl_File_OpenFlag_Write ); + + if( err != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_NO_OPEN_FILE_FOR_OVERWRITE, + err ); + return false; + } + + // the existing file was just opened and should be overwritten now, + // truncate it first + + err = aFile.setSize( 0 ); + if( err != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_FILESIZE_FOR_WRITE, + err ); + return false; + } + } + } + else + { + err = aFile.open( osl_File_OpenFlag_Read | osl_File_OpenFlag_NoLock ); + if( err == osl::FileBase::E_None ) // The file exists and shall not be overwritten + { + installError( CommandId, + TASKHANDLING_NOREPLACE_FOR_WRITE, // Now an exception + err ); + + aFile.close(); + return false; + } + + // as a temporary solution the creation does not lock the file at all + // in future it should be possible to create the file without lock explicitly + err = aFile.open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create | osl_File_OpenFlag_NoLock ); + + if( err != osl::FileBase::E_None ) + { + aFile.close(); + installError( CommandId, + TASKHANDLING_NO_OPEN_FILE_FOR_WRITE, + err ); + return false; + } + } + + bool bSuccess = true; + + sal_uInt64 nWrittenBytes; + sal_Int32 nReadBytes = 0, nRequestedBytes = 32768 /*32k*/; + uno::Sequence< sal_Int8 > seq( nRequestedBytes ); + + do + { + try + { + nReadBytes = aInputStream->readBytes( seq, + nRequestedBytes ); + } + catch( const io::NotConnectedException& ) + { + installError( CommandId, + TASKHANDLING_NOTCONNECTED_FOR_WRITE ); + bSuccess = false; + break; + } + catch( const io::BufferSizeExceededException& ) + { + installError( CommandId, + TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_WRITE ); + bSuccess = false; + break; + } + catch( const io::IOException& ) + { + installError( CommandId, + TASKHANDLING_IOEXCEPTION_FOR_WRITE ); + bSuccess = false; + break; + } + + if( nReadBytes ) + { + const sal_Int8* p = seq.getConstArray(); + + err = aFile.write( (static_cast<void const *>(p)), + sal_uInt64( nReadBytes ), + nWrittenBytes ); + + if( err != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_FILEIOERROR_FOR_WRITE, + err ); + bSuccess = false; + break; + } + else if( nWrittenBytes != sal_uInt64( nReadBytes ) ) + { + installError( CommandId, + TASKHANDLING_FILEIOERROR_FOR_NO_SPACE ); + bSuccess = false; + break; + } + } + } while( nReadBytes == nRequestedBytes ); + + err = aFile.close(); + if( err != osl::FileBase::E_None ) + { + installError( CommandId, + TASKHANDLING_FILEIOERROR_FOR_WRITE, + err ); + bSuccess = false; + } + + return bSuccess; +} + + +/*********************************************************************************/ +/* */ +/* insertDefaultProperties-Implementation */ +/* */ +/*********************************************************************************/ + + +void SAL_CALL TaskManager::insertDefaultProperties( const OUString& aUnqPath ) +{ + osl::MutexGuard aGuard( m_aMutex ); + + ContentMap::iterator it = + m_aContent.insert( ContentMap::value_type( aUnqPath,UnqPathData() ) ).first; + + load( it,false ); + + MyProperty ContentTProperty( ContentType ); + + PropertySet& properties = *(it->second.properties); + bool ContentNotDefau = properties.find( ContentTProperty ) != properties.end(); + + TaskManager::PropertySet::iterator it1 = m_aDefaultProperties.begin(); + while( it1 != m_aDefaultProperties.end() ) + { + if( ContentNotDefau && it1->getPropertyName() == ContentType ) + { + // No insertion + } + else + properties.insert( *it1 ); + ++it1; + } +} + + +/******************************************************************************/ +/* */ +/* mapping of file urls */ +/* to uncpath and vice versa */ +/* */ +/******************************************************************************/ + + +bool SAL_CALL TaskManager::getUnqFromUrl( const OUString& Url, OUString& Unq ) +{ + if ( Url == "file:///" || Url == "file://localhost/" || Url == "file://127.0.0.1/" ) + { + Unq = "file:///"; + return false; + } + + bool err = osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( Url,Unq ); + + Unq = Url; + + sal_Int32 l = Unq.getLength()-1; + if( ! err && Unq.endsWith("/") && + Unq.indexOf( '/', RTL_CONSTASCII_LENGTH("//") ) != -1 ) + Unq = Unq.copy(0, l); + + return err; +} + + +bool SAL_CALL TaskManager::getUrlFromUnq( const OUString& Unq,OUString& Url ) +{ + bool err = osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( Unq,Url ); + + Url = Unq; + + return err; +} + + +// Helper function for public copy + +osl::FileBase::RC SAL_CALL +TaskManager::copy_recursive( const OUString& srcUnqPath, + const OUString& dstUnqPath, + FileUrlType TypeToCopy, + bool testExistBeforeCopy ) +{ + osl::FileBase::RC err = osl::FileBase::E_None; + + if( TypeToCopy == FileUrlType::File ) // Document + { + err = osl_File_copy( srcUnqPath,dstUnqPath,testExistBeforeCopy ); + } + else if( TypeToCopy == FileUrlType::Folder ) + { + osl::Directory aDir( srcUnqPath ); + aDir.open(); + + err = osl::Directory::create( dstUnqPath ); + osl::FileBase::RC next = err; + if( err == osl::FileBase::E_None ) + { + sal_Int32 n_Mask = osl_FileStatus_Mask_FileURL | osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Type; + + osl::DirectoryItem aDirItem; + + while( err == osl::FileBase::E_None && ( next = aDir.getNextItem( aDirItem ) ) == osl::FileBase::E_None ) + { + bool IsDoc = false; + osl::FileStatus aFileStatus( n_Mask ); + aDirItem.getFileStatus( aFileStatus ); + if( aFileStatus.isValid( osl_FileStatus_Mask_Type ) ) + IsDoc = aFileStatus.getFileType() == osl::FileStatus::Regular; + + // Getting the information for the next recursive copy + FileUrlType newTypeToCopy = IsDoc ? FileUrlType::File : FileUrlType::Folder; + + OUString newSrcUnqPath; + if( aFileStatus.isValid( osl_FileStatus_Mask_FileURL ) ) + newSrcUnqPath = aFileStatus.getFileURL(); + + OUString newDstUnqPath = dstUnqPath; + OUString tit; + if( aFileStatus.isValid( osl_FileStatus_Mask_FileName ) ) + tit = rtl::Uri::encode( aFileStatus.getFileName(), + rtl_UriCharClassPchar, + rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8 ); + + if( !newDstUnqPath.endsWith( "/" ) ) + newDstUnqPath += "/"; + + newDstUnqPath += tit; + + if ( newSrcUnqPath != dstUnqPath ) + err = copy_recursive( newSrcUnqPath,newDstUnqPath,newTypeToCopy,false ); + } + + if( err == osl::FileBase::E_None && next != osl::FileBase::E_NOENT ) + err = next; + } + aDir.close(); + } + + return err; +} + + +// Helper function for mkfil,mkdir and write +// Creates whole path +// returns success of the operation + + +bool SAL_CALL TaskManager::ensuredir( sal_Int32 CommandId, + const OUString& rUnqPath, + sal_Int32 errorCode ) +{ + OUString aPath; + + if ( rUnqPath.isEmpty() ) + return false; + + if ( rUnqPath.endsWith("/") ) + aPath = rUnqPath.copy( 0, rUnqPath.getLength() - 1 ); + else + aPath = rUnqPath; + +#if HAVE_FEATURE_MACOSX_SANDBOX + + // Avoid annoying sandbox messages in the system.log from the + // below aDirectory.open(), which ends up calling opendir(). + // Surely it is easier to just call stat()? Calling stat() on an + // arbitrary (?) directory does not seem to cause any sandbox + // violation, while opendir() does. (Sorry I could not be bothered + // to use some complex cross-platform abstraction over stat() here + // in this OS X specific code block.) + + OUString aDirName; + struct stat s; + if( osl::FileBase::getSystemPathFromFileURL( aPath, aDirName ) == osl::FileBase::E_None && + stat(OUStringToOString( aDirName, RTL_TEXTENCODING_UTF8).getStr(), &s ) == 0 && + S_ISDIR( s.st_mode ) ) + return sal_True; +#endif + + // HACK: create directory on a mount point with nobrowse option + // returns ENOSYS in any case !! + osl::Directory aDirectory( aPath ); + osl::FileBase::RC nError = aDirectory.open(); + aDirectory.close(); + + if( nError == osl::File::E_None ) + return true; + + nError = osl::Directory::create( aPath ); + + if( nError == osl::File::E_None ) + notifyInsert( getContentEventListeners( getParentName( aPath ) ),aPath ); + + bool bSuccess = ( nError == osl::File::E_None || nError == osl::FileBase::E_EXIST ); + + if( ! bSuccess ) + { + OUString aParentDir = getParentName( aPath ); + + if ( aParentDir != aPath ) + { // Create first the parent directory + bSuccess = ensuredir( CommandId, + getParentName( aPath ), + errorCode ); + + // After parent directory structure exists try it one's more + + if ( bSuccess ) + { // Parent directory exists, retry creation of directory + nError = osl::Directory::create( aPath ); + + if( nError == osl::File::E_None ) + notifyInsert( getContentEventListeners( getParentName( aPath ) ),aPath ); + + bSuccess =( nError == osl::File::E_None || nError == osl::FileBase::E_EXIST ); + } + } + } + + if( ! bSuccess ) + installError( CommandId, + errorCode, + nError ); + + return bSuccess; +} + + +// Given a sequence of properties seq, this method determines the mask +// used to instantiate a osl::FileStatus, so that a call to +// osl::DirectoryItem::getFileStatus fills the required fields. + + +void SAL_CALL +TaskManager::getMaskFromProperties( + sal_Int32& n_Mask, + const uno::Sequence< beans::Property >& seq ) +{ + n_Mask = 0; + for(sal_Int32 j = 0; j < seq.getLength(); ++j) { + if(seq[j].Name == Title) + n_Mask |= osl_FileStatus_Mask_FileName; + else if(seq[j].Name == CasePreservingURL) + n_Mask |= osl_FileStatus_Mask_FileURL; + else if(seq[j].Name == IsDocument || + seq[j].Name == IsFolder || + seq[j].Name == IsVolume || + seq[j].Name == IsRemoveable || + seq[j].Name == IsRemote || + seq[j].Name == IsCompactDisc || + seq[j].Name == IsFloppy || + seq[j].Name == ContentType) + n_Mask |= (osl_FileStatus_Mask_Type | osl_FileStatus_Mask_LinkTargetURL); + else if(seq[j].Name == Size) ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
