1*6df1ea1fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*6df1ea1fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*6df1ea1fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*6df1ea1fSAndrew Rist * distributed with this work for additional information 6*6df1ea1fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*6df1ea1fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*6df1ea1fSAndrew Rist * "License"); you may not use this file except in compliance 9*6df1ea1fSAndrew Rist * with the License. You may obtain a copy of the License at 10*6df1ea1fSAndrew Rist * 11*6df1ea1fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*6df1ea1fSAndrew Rist * 13*6df1ea1fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*6df1ea1fSAndrew Rist * software distributed under the License is distributed on an 15*6df1ea1fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*6df1ea1fSAndrew Rist * KIND, either express or implied. See the License for the 17*6df1ea1fSAndrew Rist * specific language governing permissions and limitations 18*6df1ea1fSAndrew Rist * under the License. 19*6df1ea1fSAndrew Rist * 20*6df1ea1fSAndrew Rist *************************************************************/ 21*6df1ea1fSAndrew Rist 22*6df1ea1fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _HIERARCHYCONTENT_HXX 25cdf0e10cSrcweir #define _HIERARCHYCONTENT_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <list> 28cdf0e10cSrcweir #include <rtl/ref.hxx> 29cdf0e10cSrcweir #include <com/sun/star/ucb/XContentCreator.hpp> 30cdf0e10cSrcweir #include <ucbhelper/contenthelper.hxx> 31cdf0e10cSrcweir #include "hierarchydata.hxx" 32cdf0e10cSrcweir #include "hierarchyprovider.hxx" 33cdf0e10cSrcweir 34cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace beans { 35cdf0e10cSrcweir struct Property; 36cdf0e10cSrcweir struct PropertyValue; 37cdf0e10cSrcweir } } } } 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace sdbc { 40cdf0e10cSrcweir class XRow; 41cdf0e10cSrcweir } } } } 42cdf0e10cSrcweir 43cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace ucb { 44cdf0e10cSrcweir struct TransferInfo; 45cdf0e10cSrcweir } } } } 46cdf0e10cSrcweir 47cdf0e10cSrcweir namespace hierarchy_ucp 48cdf0e10cSrcweir { 49cdf0e10cSrcweir 50cdf0e10cSrcweir //========================================================================= 51cdf0e10cSrcweir 52cdf0e10cSrcweir #define HIERARCHY_ROOT_FOLDER_CONTENT_SERVICE_NAME \ 53cdf0e10cSrcweir "com.sun.star.ucb.HierarchyRootFolderContent" 54cdf0e10cSrcweir #define HIERARCHY_FOLDER_CONTENT_SERVICE_NAME \ 55cdf0e10cSrcweir "com.sun.star.ucb.HierarchyFolderContent" 56cdf0e10cSrcweir #define HIERARCHY_LINK_CONTENT_SERVICE_NAME \ 57cdf0e10cSrcweir "com.sun.star.ucb.HierarchyLinkContent" 58cdf0e10cSrcweir 59cdf0e10cSrcweir //========================================================================= 60cdf0e10cSrcweir 61cdf0e10cSrcweir class HierarchyContentProperties 62cdf0e10cSrcweir { 63cdf0e10cSrcweir public: HierarchyContentProperties()64cdf0e10cSrcweir HierarchyContentProperties() {}; 65cdf0e10cSrcweir HierarchyContentProperties(const HierarchyEntryData::Type & rType)66cdf0e10cSrcweir HierarchyContentProperties( const HierarchyEntryData::Type & rType ) 67cdf0e10cSrcweir : m_aData( rType ), 68cdf0e10cSrcweir m_aContentType( rType == HierarchyEntryData::FOLDER 69cdf0e10cSrcweir ? rtl::OUString::createFromAscii( HIERARCHY_FOLDER_CONTENT_TYPE ) 70cdf0e10cSrcweir : rtl::OUString::createFromAscii( HIERARCHY_LINK_CONTENT_TYPE ) ) {} 71cdf0e10cSrcweir HierarchyContentProperties(const HierarchyEntryData & rData)72cdf0e10cSrcweir HierarchyContentProperties( const HierarchyEntryData & rData ) 73cdf0e10cSrcweir : m_aData( rData ), 74cdf0e10cSrcweir m_aContentType( rData.getType() == HierarchyEntryData::FOLDER 75cdf0e10cSrcweir ? rtl::OUString::createFromAscii( HIERARCHY_FOLDER_CONTENT_TYPE ) 76cdf0e10cSrcweir : rtl::OUString::createFromAscii( HIERARCHY_LINK_CONTENT_TYPE ) ) {} 77cdf0e10cSrcweir getName() const78cdf0e10cSrcweir const rtl::OUString & getName() const { return m_aData.getName(); } setName(const rtl::OUString & rName)79cdf0e10cSrcweir void setName( const rtl::OUString & rName ) { m_aData.setName( rName ); }; 80cdf0e10cSrcweir getTitle() const81cdf0e10cSrcweir const rtl::OUString & getTitle() const { return m_aData.getTitle(); } setTitle(const rtl::OUString & rTitle)82cdf0e10cSrcweir void setTitle( const rtl::OUString & rTitle ) 83cdf0e10cSrcweir { m_aData.setTitle( rTitle ); }; 84cdf0e10cSrcweir getTargetURL() const85cdf0e10cSrcweir const rtl::OUString & getTargetURL() const 86cdf0e10cSrcweir { return m_aData.getTargetURL(); } setTargetURL(const rtl::OUString & rURL)87cdf0e10cSrcweir void setTargetURL( const rtl::OUString & rURL ) 88cdf0e10cSrcweir { m_aData.setTargetURL( rURL ); }; 89cdf0e10cSrcweir getContentType() const90cdf0e10cSrcweir const rtl::OUString & getContentType() const { return m_aContentType; } 91cdf0e10cSrcweir getIsFolder() const92cdf0e10cSrcweir sal_Bool getIsFolder() const 93cdf0e10cSrcweir { return m_aData.getType() == HierarchyEntryData::FOLDER; } 94cdf0e10cSrcweir getIsDocument() const95cdf0e10cSrcweir sal_Bool getIsDocument() const { return !getIsFolder(); } 96cdf0e10cSrcweir 97cdf0e10cSrcweir com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > 98cdf0e10cSrcweir getCreatableContentsInfo() const; 99cdf0e10cSrcweir getHierarchyEntryData() const100cdf0e10cSrcweir const HierarchyEntryData & getHierarchyEntryData() const { return m_aData; } 101cdf0e10cSrcweir 102cdf0e10cSrcweir private: 103cdf0e10cSrcweir HierarchyEntryData m_aData; 104cdf0e10cSrcweir rtl::OUString m_aContentType; 105cdf0e10cSrcweir }; 106cdf0e10cSrcweir 107cdf0e10cSrcweir //========================================================================= 108cdf0e10cSrcweir 109cdf0e10cSrcweir class HierarchyContentProvider; 110cdf0e10cSrcweir 111cdf0e10cSrcweir class HierarchyContent : public ::ucbhelper::ContentImplHelper, 112cdf0e10cSrcweir public com::sun::star::ucb::XContentCreator 113cdf0e10cSrcweir { 114cdf0e10cSrcweir enum ContentKind { LINK, FOLDER, ROOT }; 115cdf0e10cSrcweir enum ContentState { TRANSIENT, // created via CreateNewContent, 116cdf0e10cSrcweir // but did not process "insert" yet 117cdf0e10cSrcweir PERSISTENT, // processed "insert" 118cdf0e10cSrcweir DEAD // processed "delete" 119cdf0e10cSrcweir }; 120cdf0e10cSrcweir 121cdf0e10cSrcweir HierarchyContentProperties m_aProps; 122cdf0e10cSrcweir ContentKind m_eKind; 123cdf0e10cSrcweir ContentState m_eState; 124cdf0e10cSrcweir HierarchyContentProvider* m_pProvider; 125cdf0e10cSrcweir bool m_bCheckedReadOnly; 126cdf0e10cSrcweir bool m_bIsReadOnly; 127cdf0e10cSrcweir 128cdf0e10cSrcweir private: 129cdf0e10cSrcweir HierarchyContent( 130cdf0e10cSrcweir const com::sun::star::uno::Reference< 131cdf0e10cSrcweir com::sun::star::lang::XMultiServiceFactory >& rxSMgr, 132cdf0e10cSrcweir HierarchyContentProvider* pProvider, 133cdf0e10cSrcweir const com::sun::star::uno::Reference< 134cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier >& Identifier, 135cdf0e10cSrcweir const HierarchyContentProperties& rProps ); 136cdf0e10cSrcweir HierarchyContent( 137cdf0e10cSrcweir const com::sun::star::uno::Reference< 138cdf0e10cSrcweir com::sun::star::lang::XMultiServiceFactory >& rxSMgr, 139cdf0e10cSrcweir HierarchyContentProvider* pProvider, 140cdf0e10cSrcweir const com::sun::star::uno::Reference< 141cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier >& Identifier, 142cdf0e10cSrcweir const com::sun::star::ucb::ContentInfo& Info ); 143cdf0e10cSrcweir 144cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property > 145cdf0e10cSrcweir getProperties( const com::sun::star::uno::Reference< 146cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ); 147cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo > 148cdf0e10cSrcweir getCommands( const com::sun::star::uno::Reference< 149cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment > & xEnv ); 150cdf0e10cSrcweir virtual ::rtl::OUString getParentURL(); 151cdf0e10cSrcweir 152cdf0e10cSrcweir static sal_Bool hasData( 153cdf0e10cSrcweir const com::sun::star::uno::Reference< 154cdf0e10cSrcweir com::sun::star::lang::XMultiServiceFactory >& rxSMgr, 155cdf0e10cSrcweir HierarchyContentProvider* pProvider, 156cdf0e10cSrcweir const com::sun::star::uno::Reference< 157cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier >& Identifier ); hasData(const com::sun::star::uno::Reference<com::sun::star::ucb::XContentIdentifier> & Identifier)158cdf0e10cSrcweir sal_Bool hasData( 159cdf0e10cSrcweir const com::sun::star::uno::Reference< 160cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier >& Identifier ) 161cdf0e10cSrcweir { return hasData( m_xSMgr, m_pProvider, Identifier ); } 162cdf0e10cSrcweir static sal_Bool loadData( 163cdf0e10cSrcweir const com::sun::star::uno::Reference< 164cdf0e10cSrcweir com::sun::star::lang::XMultiServiceFactory >& rxSMgr, 165cdf0e10cSrcweir HierarchyContentProvider* pProvider, 166cdf0e10cSrcweir const com::sun::star::uno::Reference< 167cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier >& Identifier, 168cdf0e10cSrcweir HierarchyContentProperties& rProps ); 169cdf0e10cSrcweir sal_Bool storeData(); 170cdf0e10cSrcweir sal_Bool renameData( const com::sun::star::uno::Reference< 171cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier >& xOldId, 172cdf0e10cSrcweir const com::sun::star::uno::Reference< 173cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier >& xNewId ); 174cdf0e10cSrcweir sal_Bool removeData(); 175cdf0e10cSrcweir 176cdf0e10cSrcweir void setKind( const com::sun::star::uno::Reference< 177cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier >& Identifier ); 178cdf0e10cSrcweir 179cdf0e10cSrcweir bool isReadOnly(); 180cdf0e10cSrcweir isFolder() const181cdf0e10cSrcweir sal_Bool isFolder() const { return ( m_eKind > LINK ); } 182cdf0e10cSrcweir 183cdf0e10cSrcweir ::com::sun::star::uno::Reference< 184cdf0e10cSrcweir ::com::sun::star::ucb::XContentIdentifier > 185cdf0e10cSrcweir makeNewIdentifier( const rtl::OUString& rTitle ); 186cdf0e10cSrcweir 187cdf0e10cSrcweir typedef rtl::Reference< HierarchyContent > HierarchyContentRef; 188cdf0e10cSrcweir typedef std::list< HierarchyContentRef > HierarchyContentRefList; 189cdf0e10cSrcweir void queryChildren( HierarchyContentRefList& rChildren ); 190cdf0e10cSrcweir 191cdf0e10cSrcweir sal_Bool exchangeIdentity( 192cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 193cdf0e10cSrcweir ::com::sun::star::ucb::XContentIdentifier >& xNewId ); 194cdf0e10cSrcweir 195cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > 196cdf0e10cSrcweir getPropertyValues( const ::com::sun::star::uno::Sequence< 197cdf0e10cSrcweir ::com::sun::star::beans::Property >& rProperties ); 198cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > 199cdf0e10cSrcweir setPropertyValues( 200cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 201cdf0e10cSrcweir ::com::sun::star::beans::PropertyValue >& rValues, 202cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 203cdf0e10cSrcweir ::com::sun::star::ucb::XCommandEnvironment > & xEnv ) 204cdf0e10cSrcweir throw( ::com::sun::star::uno::Exception ); 205cdf0e10cSrcweir 206cdf0e10cSrcweir void insert( sal_Int32 nNameClashResolve, 207cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 208cdf0e10cSrcweir ::com::sun::star::ucb::XCommandEnvironment > & xEnv ) 209cdf0e10cSrcweir throw( ::com::sun::star::uno::Exception ); 210cdf0e10cSrcweir 211cdf0e10cSrcweir void destroy( sal_Bool bDeletePhysical, 212cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 213cdf0e10cSrcweir ::com::sun::star::ucb::XCommandEnvironment > & xEnv ) 214cdf0e10cSrcweir throw( ::com::sun::star::uno::Exception ); 215cdf0e10cSrcweir 216cdf0e10cSrcweir void transfer( const ::com::sun::star::ucb::TransferInfo& rInfo, 217cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 218cdf0e10cSrcweir ::com::sun::star::ucb::XCommandEnvironment > & xEnv ) 219cdf0e10cSrcweir throw( ::com::sun::star::uno::Exception ); 220cdf0e10cSrcweir 221cdf0e10cSrcweir public: 222cdf0e10cSrcweir // Create existing content. Fail, if not already exists. 223cdf0e10cSrcweir static HierarchyContent* create( 224cdf0e10cSrcweir const com::sun::star::uno::Reference< 225cdf0e10cSrcweir com::sun::star::lang::XMultiServiceFactory >& rxSMgr, 226cdf0e10cSrcweir HierarchyContentProvider* pProvider, 227cdf0e10cSrcweir const com::sun::star::uno::Reference< 228cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier >& Identifier ); 229cdf0e10cSrcweir 230cdf0e10cSrcweir // Create new content. Fail, if already exists. 231cdf0e10cSrcweir static HierarchyContent* create( 232cdf0e10cSrcweir const com::sun::star::uno::Reference< 233cdf0e10cSrcweir com::sun::star::lang::XMultiServiceFactory >& rxSMgr, 234cdf0e10cSrcweir HierarchyContentProvider* pProvider, 235cdf0e10cSrcweir const com::sun::star::uno::Reference< 236cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier >& Identifier, 237cdf0e10cSrcweir const com::sun::star::ucb::ContentInfo& Info ); 238cdf0e10cSrcweir 239cdf0e10cSrcweir virtual ~HierarchyContent(); 240cdf0e10cSrcweir 241cdf0e10cSrcweir // XInterface 242cdf0e10cSrcweir XINTERFACE_DECL() 243cdf0e10cSrcweir 244cdf0e10cSrcweir // XTypeProvider 245cdf0e10cSrcweir XTYPEPROVIDER_DECL() 246cdf0e10cSrcweir 247cdf0e10cSrcweir // XServiceInfo 248cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 249cdf0e10cSrcweir getImplementationName() 250cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 251cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 252cdf0e10cSrcweir getSupportedServiceNames() 253cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 254cdf0e10cSrcweir 255cdf0e10cSrcweir // XContent 256cdf0e10cSrcweir virtual rtl::OUString SAL_CALL 257cdf0e10cSrcweir getContentType() 258cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 259cdf0e10cSrcweir virtual com::sun::star::uno::Reference< 260cdf0e10cSrcweir com::sun::star::ucb::XContentIdentifier > SAL_CALL 261cdf0e10cSrcweir getIdentifier() 262cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 263cdf0e10cSrcweir 264cdf0e10cSrcweir // XCommandProcessor 265cdf0e10cSrcweir virtual com::sun::star::uno::Any SAL_CALL 266cdf0e10cSrcweir execute( const com::sun::star::ucb::Command& aCommand, 267cdf0e10cSrcweir sal_Int32 CommandId, 268cdf0e10cSrcweir const com::sun::star::uno::Reference< 269cdf0e10cSrcweir com::sun::star::ucb::XCommandEnvironment >& Environment ) 270cdf0e10cSrcweir throw( com::sun::star::uno::Exception, 271cdf0e10cSrcweir com::sun::star::ucb::CommandAbortedException, 272cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 273cdf0e10cSrcweir virtual void SAL_CALL 274cdf0e10cSrcweir abort( sal_Int32 CommandId ) 275cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 276cdf0e10cSrcweir 277cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 278cdf0e10cSrcweir // Additional interfaces 279cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 280cdf0e10cSrcweir 281cdf0e10cSrcweir // XContentCreator 282cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< 283cdf0e10cSrcweir com::sun::star::ucb::ContentInfo > SAL_CALL 284cdf0e10cSrcweir queryCreatableContentsInfo() 285cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 286cdf0e10cSrcweir virtual com::sun::star::uno::Reference< 287cdf0e10cSrcweir com::sun::star::ucb::XContent > SAL_CALL 288cdf0e10cSrcweir createNewContent( const com::sun::star::ucb::ContentInfo& Info ) 289cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 290cdf0e10cSrcweir 291cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 292cdf0e10cSrcweir // Non-interface methods. 293cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 294cdf0e10cSrcweir 295cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > 296cdf0e10cSrcweir getPropertyValues( const ::com::sun::star::uno::Reference< 297cdf0e10cSrcweir ::com::sun::star::lang::XMultiServiceFactory >& rSMgr, 298cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 299cdf0e10cSrcweir ::com::sun::star::beans::Property >& rProperties, 300cdf0e10cSrcweir const HierarchyContentProperties& rData, 301cdf0e10cSrcweir HierarchyContentProvider* pProvider, 302cdf0e10cSrcweir const ::rtl::OUString& rContentId ); 303cdf0e10cSrcweir }; 304cdf0e10cSrcweir 305cdf0e10cSrcweir } // namespace hierarchy_ucp 306cdf0e10cSrcweir 307cdf0e10cSrcweir #endif /* !_HIERARCHYCONTENT_HXX */ 308