LibreOffice Module fpicker (master) 1
fpsmartcontent.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include "fpinteraction.hxx"
23
24#include <com/sun/star/ucb/XCommandEnvironment.hpp>
25#include <ucbhelper/content.hxx>
26#include <rtl/ref.hxx>
27#include <memory>
28#include <optional>
29
30
31namespace svt
32{
33
34
35 //= SmartContent
36
41 {
42 public:
43 enum State
44 {
45 NOT_BOUND, // never bound
46 UNKNOWN, // bound, but validity is unknown
47 VALID, // bound to a URL, and valid
48 INVALID // bound to a URL, and invalid
49 };
50
51 private:
52 OUString m_sURL;
53 std::optional<::ucbhelper::Content> m_oContent;
55 css::uno::Reference < css::ucb::XCommandEnvironment > m_xCmdEnv;
57
58 private:
59 enum Type { Folder, Document };
61 bool implIs( const OUString& _rURL, Type _eType );
62
63 SmartContent( const SmartContent& _rSource ) = delete;
64 SmartContent& operator=( const SmartContent& _rSource ) = delete;
65
66 public:
68 explicit SmartContent( const OUString& _rInitialURL );
70
71 public:
72
79
83
91
95 {
99 };
100
106
110
115 State getState( ) const { return m_eState; }
116
120 bool isValid( ) const { return VALID == getState(); }
121
125 bool isInvalid( ) const { return INVALID == getState(); }
126
129 bool isBound( ) const { return NOT_BOUND != getState(); }
130
133 OUString const & getURL() const { return m_oContent ? m_oContent->getURL() : m_sURL; }
134
145 void bindTo( const OUString& _rURL );
146
151 void getTitle( OUString& /* [out] */ _rTitle );
152
157 bool hasParentFolder( );
158
163 bool canCreateFolder( );
164
170 OUString createFolder( const OUString& _rTitle );
171
177 bool isFolder( const OUString& _rURL )
178 {
179 return implIs( _rURL, Folder );
180 }
181
184 bool is( const OUString& _rURL )
185 {
186 return implIs( _rURL, Folder ) || implIs( _rURL, Document );
187 }
188
189 bool isFolder( ) { return isFolder( getURL() ); }
190 };
191
192
193} // namespace svt
194
195
196/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
an InteractionHandler implementation which extends another handler with some customizability
EInterceptedInteractions
flags, which indicates special handled interactions These values will be used combined as flags - so ...
a "smart content" which basically wraps a UCB content, but caches some information so that repeatedly...
InteractionHandlerType
describes different types of interaction handlers
std::optional<::ucbhelper::Content > m_oContent
::svt::OFilePickerInteractionHandler * getOwnInteractionHandler() const
return the internal used interaction handler object ... Because this pointer will be valid only,...
State getState() const
returns the current state of the content
SmartContent(const SmartContent &_rSource)=delete
bool isBound() const
checks if the content is bound
void getTitle(OUString &_rTitle)
retrieves the title of the content @precond the content is bound and not invalid
void enableDefaultInteractionHandler()
disable the specialized interaction handler and use the global UI interaction handler only.
void disableInteractionHandler()
disable internal used interaction handler object ...
bool hasParentFolder()
checks if the content has a parent folder @precond the content is bound and not invalid
void bindTo(const OUString &_rURL)
(re)creates the content for the given URL
void enableOwnInteractionHandler(::svt::OFilePickerInteractionHandler::EInterceptedInteractions eInterceptions)
create and set a specialized interaction handler at the internal used command environment.
css::uno::Reference< css::ucb::XCommandEnvironment > m_xCmdEnv
bool canCreateFolder()
checks if sub folders below the content can be created @precond the content is bound and not invalid
OUString const & getURL() const
returns the URL of the content
OUString createFolder(const OUString &_rTitle)
creates a new folder with the given title and return the corresponding URL.
InteractionHandlerType queryCurrentInteractionHandler() const
return the type of the internal used interaction handler object ...
bool isInvalid() const
checks if the content is valid
bool isValid() const
checks if the content is valid
SmartContent & operator=(const SmartContent &_rSource)=delete
bool is(const OUString &_rURL)
checks if the content is existent (it is if and only if it is a document or a folder)
bool implIs(const OUString &_rURL, Type _eType)
checks if the currently bound content is a folder or document
bool isFolder(const OUString &_rURL)
binds to the given URL, checks whether or not it refers to a folder
rtl::Reference<::svt::OFilePickerInteractionHandler > m_xOwnInteraction
Type