LibreOffice Module fpicker (master) 1
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
svt::SmartContent Class Reference

a "smart content" which basically wraps a UCB content, but caches some information so that repeatedly recreating it may be faster More...

#include <fpsmartcontent.hxx>

Collaboration diagram for svt::SmartContent:
[legend]

Public Types

enum  State {
  NOT_BOUND ,
  UNKNOWN ,
  VALID ,
  INVALID
}
 
enum  InteractionHandlerType {
  IHT_NONE ,
  IHT_OWN ,
  IHT_DEFAULT
}
 describes different types of interaction handlers More...
 

Public Member Functions

 SmartContent ()
 
 SmartContent (const OUString &_rInitialURL)
 
 ~SmartContent ()
 
void enableOwnInteractionHandler (::svt::OFilePickerInteractionHandler::EInterceptedInteractions eInterceptions)
 create and set a specialized interaction handler at the internal used command environment. More...
 
void enableDefaultInteractionHandler ()
 disable the specialized interaction handler and use the global UI interaction handler only. More...
 
::svt::OFilePickerInteractionHandlergetOwnInteractionHandler () const
 return the internal used interaction handler object ... Because this pointer will be valid only, if the uno object is hold alive by its uno reference (and this reference is set on the command environment) we must return NULL, in case this environment does not exist! More...
 
InteractionHandlerType queryCurrentInteractionHandler () const
 return the type of the internal used interaction handler object ... More...
 
void disableInteractionHandler ()
 disable internal used interaction handler object ... More...
 
State getState () const
 returns the current state of the content More...
 
bool isValid () const
 checks if the content is valid More...
 
bool isInvalid () const
 checks if the content is valid More...
 
bool isBound () const
 checks if the content is bound More...
 
OUString const & getURL () const
 returns the URL of the content More...
 
void bindTo (const OUString &_rURL)
 (re)creates the content for the given URL More...
 
void getTitle (OUString &_rTitle)
 retrieves the title of the content @precond the content is bound and not invalid More...
 
bool hasParentFolder ()
 checks if the content has a parent folder @precond the content is bound and not invalid More...
 
bool canCreateFolder ()
 checks if sub folders below the content can be created @precond the content is bound and not invalid More...
 
OUString createFolder (const OUString &_rTitle)
 creates a new folder with the given title and return the corresponding URL. More...
 
bool isFolder (const OUString &_rURL)
 binds to the given URL, checks whether or not it refers to a folder More...
 
bool is (const OUString &_rURL)
 checks if the content is existent (it is if and only if it is a document or a folder) More...
 
bool isFolder ()
 

Private Types

enum  Type {
  Folder ,
  Document
}
 

Private Member Functions

bool implIs (const OUString &_rURL, Type _eType)
 checks if the currently bound content is a folder or document More...
 
 SmartContent (const SmartContent &_rSource)=delete
 
SmartContentoperator= (const SmartContent &_rSource)=delete
 

Private Attributes

OUString m_sURL
 
std::optional<::ucbhelper::Contentm_oContent
 
State m_eState
 
css::uno::Reference< css::ucb::XCommandEnvironment > m_xCmdEnv
 
rtl::Reference<::svt::OFilePickerInteractionHandlerm_xOwnInteraction
 

Detailed Description

a "smart content" which basically wraps a UCB content, but caches some information so that repeatedly recreating it may be faster

Definition at line 40 of file fpsmartcontent.hxx.

Member Enumeration Documentation

◆ InteractionHandlerType

describes different types of interaction handlers

Enumerator
IHT_NONE 
IHT_OWN 
IHT_DEFAULT 

Definition at line 94 of file fpsmartcontent.hxx.

◆ State

Enumerator
NOT_BOUND 
UNKNOWN 
VALID 
INVALID 

Definition at line 43 of file fpsmartcontent.hxx.

◆ Type

Enumerator
Folder 
Document 

Definition at line 59 of file fpsmartcontent.hxx.

Constructor & Destructor Documentation

◆ SmartContent() [1/3]

svt::SmartContent::SmartContent ( const SmartContent _rSource)
privatedelete

◆ SmartContent() [2/3]

svt::SmartContent::SmartContent ( )

Definition at line 48 of file fpsmartcontent.cxx.

◆ SmartContent() [3/3]

svt::SmartContent::SmartContent ( const OUString &  _rInitialURL)
explicit

Definition at line 54 of file fpsmartcontent.cxx.

References bindTo().

◆ ~SmartContent()

svt::SmartContent::~SmartContent ( )

Definition at line 61 of file fpsmartcontent.cxx.

Member Function Documentation

◆ bindTo()

void svt::SmartContent::bindTo ( const OUString &  _rURL)

(re)creates the content for the given URL

Note that getState will return either UNKNOWN or INVALID after the call returns, but never VALID. The reason is that there are content providers which allow to construct content objects, even if the respective contents are not accessible. They tell about this only upon working with the content object (e.g. when asking for the IsFolder).

@postcond <member>getState</member> does not return NOT_BOUND after the call returns

Definition at line 126 of file fpsmartcontent.cxx.

References Exception, svt::OFilePickerInteractionHandler::forgetRequest(), getOwnInteractionHandler(), comphelper::getProcessComponentContext(), getURL(), INVALID, m_eState, m_oContent, m_sURL, m_xCmdEnv, NOT_BOUND, svt::OFilePickerInteractionHandler::resetUseState(), TOOLS_WARN_EXCEPTION, and UNKNOWN.

Referenced by SvtFileDialog::ContentCanMakeFolder(), SvtFileDialog::ContentGetTitle(), SvtFileDialog::ContentHasParentFolder(), SvtFileDialog::implGetInitialURL(), implIs(), SvtFileDialog::OpenHdl_Impl(), and SmartContent().

◆ canCreateFolder()

bool svt::SmartContent::canCreateFolder ( )

checks if sub folders below the content can be created @precond the content is bound and not invalid

Definition at line 257 of file fpsmartcontent.cxx.

References Exception, INVALID, isBound(), isInvalid(), m_eState, m_oContent, and VALID.

Referenced by SvtFileDialog::ContentCanMakeFolder().

◆ createFolder()

OUString svt::SmartContent::createFolder ( const OUString &  _rTitle)

creates a new folder with the given title and return the corresponding URL.

Returns
the URL of the created folder or an empty string

Definition at line 287 of file fpsmartcontent.cxx.

References Any, Exception, ucbhelper::Content::getURL(), and m_oContent.

◆ disableInteractionHandler()

void svt::SmartContent::disableInteractionHandler ( )

disable internal used interaction handler object ...

Definition at line 119 of file fpsmartcontent.cxx.

References m_xCmdEnv, and m_xOwnInteraction.

Referenced by SvtFileDialog::OpenHdl_Impl().

◆ enableDefaultInteractionHandler()

void svt::SmartContent::enableDefaultInteractionHandler ( )

disable the specialized interaction handler and use the global UI interaction handler only.

Definition at line 90 of file fpsmartcontent.cxx.

References m_xCmdEnv, and m_xOwnInteraction.

Referenced by SvtFileDialog::OpenHdl_Impl(), and SvtFileDialog::PrepareExecute().

◆ enableOwnInteractionHandler()

void svt::SmartContent::enableOwnInteractionHandler ( ::svt::OFilePickerInteractionHandler::EInterceptedInteractions  eInterceptions)

create and set a specialized interaction handler at the internal used command environment.

Parameters
eInterceptionswill be directly forwarded to OFilePickerInteractionHandler::enableInterceptions()

Definition at line 77 of file fpsmartcontent.cxx.

References m_xCmdEnv, and m_xOwnInteraction.

Referenced by SvtFileDialog::OpenHdl_Impl(), and SvtFileDialog::PrepareExecute().

◆ getOwnInteractionHandler()

svt::OFilePickerInteractionHandler * svt::SmartContent::getOwnInteractionHandler ( ) const

return the internal used interaction handler object ... Because this pointer will be valid only, if the uno object is hold alive by its uno reference (and this reference is set on the command environment) we must return NULL, in case this environment does not exist!

Definition at line 101 of file fpsmartcontent.cxx.

References m_xOwnInteraction.

Referenced by bindTo(), and SvtFileDialog::OpenHdl_Impl().

◆ getState()

State svt::SmartContent::getState ( ) const
inline

returns the current state of the content

@seealso State

Definition at line 115 of file fpsmartcontent.hxx.

References m_eState.

Referenced by isBound(), isInvalid(), and isValid().

◆ getTitle()

void svt::SmartContent::getTitle ( OUString &  _rTitle)

retrieves the title of the content @precond the content is bound and not invalid

Definition at line 204 of file fpsmartcontent.cxx.

References INVALID, isBound(), isInvalid(), m_eState, m_oContent, and VALID.

Referenced by SvtFileDialog::ContentGetTitle().

◆ getURL()

OUString const & svt::SmartContent::getURL ( ) const
inline

returns the URL of the content

Definition at line 133 of file fpsmartcontent.hxx.

References m_oContent, and m_sURL.

Referenced by bindTo(), and isFolder().

◆ hasParentFolder()

bool svt::SmartContent::hasParentFolder ( )

checks if the content has a parent folder @precond the content is bound and not invalid

Definition at line 226 of file fpsmartcontent.cxx.

References Exception, INVALID, isBound(), isInvalid(), m_eState, m_oContent, and VALID.

Referenced by SvtFileDialog::ContentHasParentFolder().

◆ implIs()

bool svt::SmartContent::implIs ( const OUString &  _rURL,
Type  _eType 
)
private

checks if the currently bound content is a folder or document

Definition at line 171 of file fpsmartcontent.cxx.

References bindTo(), Exception, Folder, INVALID, isBound(), isInvalid(), m_eState, m_oContent, and VALID.

Referenced by is(), and isFolder().

◆ is()

bool svt::SmartContent::is ( const OUString &  _rURL)
inline

checks if the content is existent (it is if and only if it is a document or a folder)

Definition at line 184 of file fpsmartcontent.hxx.

References Document, Folder, and implIs().

Referenced by SvtFileDialog::OpenHdl_Impl().

◆ isBound()

bool svt::SmartContent::isBound ( ) const
inline

checks if the content is bound

Definition at line 129 of file fpsmartcontent.hxx.

References getState(), and NOT_BOUND.

Referenced by canCreateFolder(), getTitle(), hasParentFolder(), and implIs().

◆ isFolder() [1/2]

bool svt::SmartContent::isFolder ( )
inline

Definition at line 189 of file fpsmartcontent.hxx.

References getURL(), and isFolder().

Referenced by isFolder().

◆ isFolder() [2/2]

bool svt::SmartContent::isFolder ( const OUString &  _rURL)
inline

binds to the given URL, checks whether or not it refers to a folder

@postcond the content is not in the state UNKNOWN

Definition at line 177 of file fpsmartcontent.hxx.

References Folder, and implIs().

Referenced by SvtFileDialog::ContentIsFolder(), SvtFileDialog::implGetInitialURL(), SvtFileDialog::OpenHdl_Impl(), and SvtFileDialog::run().

◆ isInvalid()

bool svt::SmartContent::isInvalid ( ) const
inline

checks if the content is valid

Note that "not (is invalid)" is not the same as "is valid"

Definition at line 125 of file fpsmartcontent.hxx.

References getState(), and INVALID.

Referenced by canCreateFolder(), SvtFileDialog::ContentCanMakeFolder(), SvtFileDialog::ContentGetTitle(), SvtFileDialog::ContentHasParentFolder(), getTitle(), hasParentFolder(), SvtFileDialog::implGetInitialURL(), implIs(), and SvtFileDialog::OpenHdl_Impl().

◆ isValid()

bool svt::SmartContent::isValid ( ) const
inline

checks if the content is valid

Note that "not (is valid)" is not the same as "is invalid"

Definition at line 120 of file fpsmartcontent.hxx.

References getState(), and VALID.

Referenced by SvtFileDialog::ContentCanMakeFolder(), SvtFileDialog::ContentGetTitle(), SvtFileDialog::ContentHasParentFolder(), and SvtFileDialog::ContentIsFolder().

◆ operator=()

SmartContent & svt::SmartContent::operator= ( const SmartContent _rSource)
privatedelete

◆ queryCurrentInteractionHandler()

SmartContent::InteractionHandlerType svt::SmartContent::queryCurrentInteractionHandler ( ) const

return the type of the internal used interaction handler object ...

@seealso InteractionHandlerType

Definition at line 107 of file fpsmartcontent.cxx.

References IHT_DEFAULT, IHT_NONE, IHT_OWN, m_xCmdEnv, and m_xOwnInteraction.

Referenced by SvtFileDialog::OpenHdl_Impl().

Member Data Documentation

◆ m_eState

State svt::SmartContent::m_eState
private

Definition at line 54 of file fpsmartcontent.hxx.

Referenced by bindTo(), canCreateFolder(), getState(), getTitle(), hasParentFolder(), and implIs().

◆ m_oContent

std::optional<::ucbhelper::Content> svt::SmartContent::m_oContent
private

◆ m_sURL

OUString svt::SmartContent::m_sURL
private

Definition at line 52 of file fpsmartcontent.hxx.

Referenced by bindTo(), and getURL().

◆ m_xCmdEnv

css::uno::Reference< css::ucb::XCommandEnvironment > svt::SmartContent::m_xCmdEnv
private

◆ m_xOwnInteraction

rtl::Reference<::svt::OFilePickerInteractionHandler> svt::SmartContent::m_xOwnInteraction
private

The documentation for this class was generated from the following files: