update dev300-m58
[ooovba.git] / fpicker / source / office / fpsmartcontent.hxx
blobfc280c555ba35a57366165c230af9eb9d14ec8bd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fpsmartcontent.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SVTOOLS_SOURCE_FILEPICKER_FPSMARTCONTENT_HXX
32 #define SVTOOLS_SOURCE_FILEPICKER_FPSMARTCONTENT_HXX
34 #include "fpinteraction.hxx"
36 /** === begin UNO includes === **/
37 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
38 #include <com/sun/star/task/XInteractionHandler.hpp>
39 /** === end UNO includes === **/
40 #include <ucbhelper/content.hxx>
42 //........................................................................
43 namespace svt
45 //........................................................................
47 //====================================================================
48 //= SmartContent
49 //====================================================================
50 /** a "smart content" which basically wraps an UCB content, but caches some informations
51 so that repeatedly recreating it may be faster
53 class SmartContent
55 public:
56 enum State
58 NOT_BOUND, // never bound
59 UNKNOWN, // bound, but validity is unknown
60 VALID, // bound to an URL, and valid
61 INVALID // bound to an URL, and invalid
64 private:
65 ::rtl::OUString m_sURL;
66 ::ucbhelper::Content* m_pContent;
67 State m_eState;
68 ::com::sun::star::uno::Reference < ::com::sun::star::ucb::XCommandEnvironment > m_xCmdEnv;
69 ::com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionHandler > m_xOwnInteraction;
70 ::svt::OFilePickerInteractionHandler* m_pOwnInteraction;
72 private:
73 enum Type { Folder, Document };
74 /// checks if the currently bound content is a folder or document
75 sal_Bool implIs( const ::rtl::OUString& _rURL, Type _eType );
77 SmartContent( const SmartContent& _rSource ); // never implemented
78 SmartContent& operator=( const SmartContent& _rSource ); // never implemented
80 public:
81 SmartContent();
82 SmartContent( const ::rtl::OUString& _rInitialURL );
83 ~SmartContent();
85 public:
87 /** create and set a specialized interaction handler at the internal used command environment.
89 @param eInterceptions
90 will be directly forwarded to OFilePickerInteractionHandler::enableInterceptions()
92 void enableOwnInteractionHandler(::svt::OFilePickerInteractionHandler::EInterceptedInteractions eInterceptions);
94 /** disable the specialized interaction handler and use the global UI interaction handler only.
96 void enableDefaultInteractionHandler();
98 /** return the internal used interaction handler object ...
99 Because this pointer will be valid only, if the uno object is hold
100 alive by it's uno reference (and this reference is set on the
101 command environment) we must return NULL, in case this environment does
102 not exist!
104 ::svt::OFilePickerInteractionHandler* getOwnInteractionHandler() const;
106 /** describes different types of interaction handlers
108 enum InteractionHandlerType
110 IHT_NONE,
111 IHT_OWN,
112 IHT_DEFAULT
115 /** return the type of the internal used interaction handler object ...
117 @seealso InteractionHandlerType
119 InteractionHandlerType queryCurrentInteractionHandler() const;
121 /** disable internal used interaction handler object ...
123 void disableInteractionHandler();
125 /** returns the current state of the content
127 @seealso State
129 inline State getState( ) const { return m_eState; }
131 /** checks if the content is valid
132 <p>Note that "not (is valid)" is not the same as "is invalid"</p>
134 inline sal_Bool isValid( ) const { return VALID == getState(); }
136 /** checks if the content is valid
137 <p>Note that "not (is invalid)" is not the same as "is valid"</p>
139 inline sal_Bool isInvalid( ) const { return INVALID == getState(); }
141 /** checks if the content is bound
143 inline sal_Bool isBound( ) const { return NOT_BOUND != getState(); }
145 /** returns the URL of the content
147 inline ::rtl::OUString getURL() const { return m_pContent ? m_pContent->getURL() : m_sURL; }
149 /** (re)creates the content for the given URL
151 <p>Note that getState will return either UNKNOWN or INVALID after the call returns,
152 but never VALID. The reason is that there are content providers which allow to construct
153 content objects, even if the respective contents are not accessible. They tell about this
154 only upon working with the content object (e.g. when asking for the IsFolder).</p>
156 @postcond
157 <member>getState</member> does not return NOT_BOUND after the call returns
159 void bindTo( const ::rtl::OUString& _rURL );
161 /** retrieves the title of the content
162 @precond
163 the content is bound and not invalid
165 void getTitle( ::rtl::OUString& /* [out] */ _rTitle );
167 /** checks if the content has a parent folder
168 @precond
169 the content is bound and not invalid
171 sal_Bool hasParentFolder( );
173 /** checks if sub folders below the content can be created
174 @precond
175 the content is bound and not invalid
177 sal_Bool canCreateFolder( );
179 /** binds to the given URL, checks whether or not it refers to a folder
181 @postcond
182 the content is not in the state UNKNOWN
184 inline sal_Bool isFolder( const ::rtl::OUString& _rURL )
186 return implIs( _rURL, Folder );
189 /** binds to the given URL, checks whether or not it refers to a document
191 @postcond
192 the content is not in the state UNKNOWN
194 inline sal_Bool isDocument( const ::rtl::OUString& _rURL )
196 return implIs( _rURL, Document );
199 /** checks if the content is existent (it is if and only if it is a document or a folder)
201 inline sal_Bool is( const ::rtl::OUString& _rURL )
203 return implIs( _rURL, Folder ) || implIs( _rURL, Document );
206 inline sal_Bool isFolder( ) { return isFolder( getURL() ); }
207 inline sal_Bool isDocument( ) { return isDocument( getURL() ); }
208 inline sal_Bool is( ) { return is( getURL() ); }
211 //........................................................................
212 } // namespace svt
213 //........................................................................
215 #endif // SVTOOLS_SOURCE_FILEPICKER_FPSMARTCONTENT_HXX