LibreOffice Module fpicker (master) 1
contentenumeration.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 <sal/config.h>
23
24#include <memory>
25#include <mutex>
26
27#include <com/sun/star/ucb/XCommandEnvironment.hpp>
28#include <salhelper/thread.hxx>
29#include <ucbhelper/content.hxx>
30#include <rtl/ustring.hxx>
31#include <tools/datetime.hxx>
32#include <utility>
33
34namespace svt
35{
36
37
38 //= SortingData_Impl
39
41 {
42 private:
43 OUString maFilename; // only filename in upper case - for compare purposes
44 OUString maTitle; // -> be careful when changing maTitle to update maFilename only when new
45 OUString maLowerTitle;
46
47
48 public:
49 OUString maType;
50 OUString maTargetURL;
51 OUString maDisplayName;
52 OUString maDisplaySize;
53 OUString maDisplayDate;
55 OUString maImage;
56 sal_Int64 maSize;
63
64 inline SortingData_Impl();
65 inline const OUString& GetTitle() const;
66 inline const OUString& GetLowerTitle() const;
67 inline const OUString& GetFileName() const;
68 inline void SetNewTitle( const OUString& rNewTitle ); // new maTitle is set -> maFilename is set to same!
69
70 private:
71 inline void SetTitles( const OUString& rNewTitle );
72 };
73
75 maModDate ( DateTime::EMPTY ),
76 maSize ( 0 ),
77 mbIsFolder ( false ),
78 mbIsVolume ( false ),
79 mbIsRemote ( false ),
80 mbIsRemoveable ( false ),
81 mbIsFloppy ( false ),
82 mbIsCompactDisc ( false )
83 {
84 }
85
86 inline const OUString& SortingData_Impl::GetTitle() const
87 {
88 return maTitle;
89 }
90
91 inline const OUString& SortingData_Impl::GetLowerTitle() const
92 {
93 return maLowerTitle;
94 }
95
96 inline const OUString& SortingData_Impl::GetFileName() const
97 {
98 return maFilename;
99 }
100
101 inline void SortingData_Impl::SetNewTitle( const OUString& rNewTitle )
102 {
103 SetTitles( rNewTitle );
104 maFilename = rNewTitle.toAsciiUpperCase();
105 }
106
107 inline void SortingData_Impl::SetTitles( const OUString& rNewTitle )
108 {
109 maTitle = rNewTitle;
110 maLowerTitle = rNewTitle.toAsciiLowerCase();
111 }
112
113
114 //= EnumerationResult
115
117 {
118 SUCCESS,
119 ERROR,
120 };
121
122
123 //= FolderDescriptor
124
126 {
133 OUString sURL;
134
136
137 explicit FolderDescriptor( OUString _aURL )
138 :sURL(std::move( _aURL ))
139 {
140 }
141 };
142
143
144 //= IEnumerationResultHandler
145
147 {
148 public:
149 virtual void enumerationDone( EnumerationResult _eResult ) = 0;
150
151 protected:
153 };
154
155
156 //= FileViewContentEnumerator
157
159 {
160 public:
161 typedef ::std::vector< std::unique_ptr<SortingData_Impl> > ContentData;
162
163 private:
165 ::osl::Mutex& m_rContentMutex;
166
167 mutable std::mutex m_aMutex;
168
170 css::uno::Reference< css::ucb::XCommandEnvironment >
174
175 css::uno::Sequence< OUString > m_rDenyList;
176
177 bool URLOnDenyList ( std::u16string_view sRealURL );
178
179 public:
190 const css::uno::Reference< css::ucb::XCommandEnvironment >& _rxCommandEnv,
191 ContentData& _rContentToFill,
192 ::osl::Mutex& _rContentMutex
193 );
194
205 const FolderDescriptor& _rFolder,
206 IEnumerationResultHandler* _pResultHandler
207 );
208
212 const FolderDescriptor& _rFolder,
213 const css::uno::Sequence< OUString >& rDenyList
214 );
215
221 void cancel();
222
223 protected:
224 virtual ~FileViewContentEnumerator() override;
225
226 private:
228
229 // Thread overridables
230 virtual void execute() override;
231
232 };
233
234
235} // namespace svt
236
237
238/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
geometry::RealSize2D maSize
virtual ~FileViewContentEnumerator() override
css::uno::Reference< css::ucb::XCommandEnvironment > m_xCommandEnv
css::uno::Sequence< OUString > m_rDenyList
EnumerationResult enumerateFolderContentSync(const FolderDescriptor &_rFolder, const css::uno::Sequence< OUString > &rDenyList)
enumerates the content of a given folder synchronously
EnumerationResult enumerateFolderContent()
::std::vector< std::unique_ptr< SortingData_Impl > > ContentData
bool URLOnDenyList(std::u16string_view sRealURL)
void cancel()
cancels the running operation.
FileViewContentEnumerator(const css::uno::Reference< css::ucb::XCommandEnvironment > &_rxCommandEnv, ContentData &_rContentToFill, ::osl::Mutex &_rContentMutex)
constructs an enumerator instance
IEnumerationResultHandler * m_pResultHandler
virtual void enumerationDone(EnumerationResult _eResult)=0
ERROR
constexpr OUStringLiteral EMPTY
FolderDescriptor(OUString _aURL)
::ucbhelper::Content aContent
a content object describing the folder.
OUString sURL
the URL of a folder.
void SetTitles(const OUString &rNewTitle)
void SetNewTitle(const OUString &rNewTitle)
const OUString & GetFileName() const
const OUString & GetLowerTitle() const
const OUString & GetTitle() const