Debian Codegraph @

ucb/source/ucp/tdoc/tdoc_datasupplier.hxx

raw
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 <rtl/ref.hxx>
23 #include <ucbhelper/resultset.hxx>
24 #include <mutex>
25 #include <optional>
26 #include <string_view>
27 #include <utility>
28 #include <vector>
29
30 namespace tdoc_ucp {
31
32 class Content;
33
34 class ResultSetDataSupplier final : public ::ucbhelper::ResultSetDataSupplier
35 {
36 struct ResultListEntry
37 {
38 OUString aURL;
39 css::uno::Reference< css::ucb::XContentIdentifier > xId;
40 css::uno::Reference< css::ucb::XContent > xContent;
41 css::uno::Reference< css::sdbc::XRow > xRow;
42
43 explicit ResultListEntry( OUString _aURL ) : aURL(std::move( _aURL )) {}
44 };
45
46 std::mutex m_aMutex;
47 std::vector< ResultListEntry > m_aResults;
48 rtl::Reference< Content > m_xContent;
49 css::uno::Reference< css::uno::XComponentContext > m_xContext;
50 std::optional<css::uno::Sequence< OUString > > m_xNamesOfChildren;
51 bool m_bCountFinal;
52 bool m_bThrowException;
53
54 private:
55 bool queryNamesOfChildren(std::unique_lock<std::mutex>& rGuard);
56 OUString assembleChildURL( std::u16string_view aName );
57
58 public:
59 ResultSetDataSupplier(
60 css::uno::Reference< css::uno::XComponentContext > xContext,
61 rtl::Reference< Content > xContent );
62 virtual ~ResultSetDataSupplier() override;
63
64 virtual OUString queryContentIdentifierString( std::unique_lock<std::mutex>& rResultSetGuard, sal_uInt32 nIndex ) override;
65 virtual css::uno::Reference< css::ucb::XContentIdentifier >
66 queryContentIdentifier( std::unique_lock<std::mutex>& rResultSetGuard, sal_uInt32 nIndex ) override;
67 virtual css::uno::Reference< css::ucb::XContent >
68 queryContent( std::unique_lock<std::mutex>& rResultSetGuard, sal_uInt32 nIndex ) override;
69
70 virtual bool getResult( std::unique_lock<std::mutex>& rResultSetGuard, sal_uInt32 nIndex ) override;
71
72 virtual sal_uInt32 totalCount(std::unique_lock<std::mutex>& rResultSetGuard) override;
73 virtual sal_uInt32 currentCount() override;
74 virtual bool isCountFinal() override;
75
76 virtual css::uno::Reference< css::sdbc::XRow >
77 queryPropertyValues( std::unique_lock<std::mutex>& rResultSetGuard, sal_uInt32 nIndex ) override;
78 virtual void releasePropertyValues( sal_uInt32 nIndex ) override;
79
80 virtual void close() override;
81
82 virtual void validate() override;
83
84 private:
85 OUString queryContentIdentifierStringImpl( std::unique_lock<std::mutex>& rResultSetGuard, std::unique_lock<std::mutex>& rGuard, sal_uInt32 nIndex );
86 css::uno::Reference< css::ucb::XContentIdentifier >
87 queryContentIdentifierImpl( std::unique_lock<std::mutex>& rResultSetGuard, std::unique_lock<std::mutex>& rGuard, sal_uInt32 nIndex );
88 bool getResultImpl( std::unique_lock<std::mutex>& rResultSetGuard, std::unique_lock<std::mutex>& rGuard, sal_uInt32 nIndex );
89 };
90
91 } // namespace tdoc_ucp
92
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */