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