1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <sal/config.h>
24 #include <string_view>
26 #include <rtl/ref.hxx>
27 #include <com/sun/star/frame/XTransientDocumentsDocumentContentFactory.hpp>
28 #include <com/sun/star/frame/XTransientDocumentsDocumentContentIdentifierFactory.hpp>
29 #include <ucbhelper/providerhelper.hxx>
30 #include "tdoc_uri.hxx"
31 #include "tdoc_docmgr.hxx"
32 #include "tdoc_storage.hxx"
34 namespace com::sun::star::embed
{
38 namespace com::sun::star::frame
{
42 namespace com::sun::star::util
{
49 inline constexpr OUString TDOC_ROOT_CONTENT_TYPE
=
50 u
"application/" TDOC_URL_SCHEME
"-root"_ustr
;
51 inline constexpr OUString TDOC_DOCUMENT_CONTENT_TYPE
=
52 u
"application/" TDOC_URL_SCHEME
"-document"_ustr
;
53 inline constexpr OUString TDOC_FOLDER_CONTENT_TYPE
=
54 u
"application/" TDOC_URL_SCHEME
"-folder"_ustr
;
55 inline constexpr OUString TDOC_STREAM_CONTENT_TYPE
=
56 u
"application/" TDOC_URL_SCHEME
"-stream"_ustr
;
59 class StorageElementFactory
;
61 typedef cppu::ImplInheritanceHelper
<
62 ::ucbhelper::ContentProviderImplHelper
,
63 css::frame::XTransientDocumentsDocumentContentIdentifierFactory
,
64 css::frame::XTransientDocumentsDocumentContentFactory
> ContentProvider_Base
;
65 class ContentProvider
: public ContentProvider_Base
68 explicit ContentProvider( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
69 virtual ~ContentProvider() override
;
72 virtual OUString SAL_CALL
getImplementationName() override
;
73 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
74 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
77 virtual css::uno::Reference
< css::ucb::XContent
> SAL_CALL
78 queryContent( const css::uno::Reference
< css::ucb::XContentIdentifier
>& Identifier
) override
;
80 // XTransientDocumentsDocumentContentIdentifierFactory
81 virtual css::uno::Reference
<css::ucb::XContentIdentifier
> SAL_CALL
82 createDocumentContentIdentifier(
83 css::uno::Reference
<css::frame::XModel
> const& xModel
) override
;
85 // XTransientDocumentsDocumentContentFactory
86 virtual css::uno::Reference
< css::ucb::XContent
> SAL_CALL
87 createDocumentContent( const css::uno::Reference
<
88 css::frame::XModel
>& Model
) override
;
91 css::uno::Reference
< css::embed::XStorage
>
92 queryStorage( const OUString
& rUri
, StorageAccessMode eMode
) const;
94 css::uno::Reference
< css::embed::XStorage
>
95 queryStorageClone( const OUString
& rUri
) const;
97 /// @throws css::packages::WrongPasswordException
98 /// @throws css::uno::RuntimeException
99 css::uno::Reference
< css::io::XInputStream
>
100 queryInputStream( const OUString
& rUri
,
101 const OUString
& rPassword
) const;
103 /// @throws css::packages::WrongPasswordException
104 /// @throws css::uno::RuntimeException
105 css::uno::Reference
< css::io::XOutputStream
>
106 queryOutputStream( const OUString
& rUri
,
107 const OUString
& rPassword
,
108 bool bTruncate
) const;
110 /// @throws css::packages::WrongPasswordException
111 /// @throws css::uno::RuntimeException
112 css::uno::Reference
< css::io::XStream
>
113 queryStream( const OUString
& rUri
,
114 const OUString
& rPassword
,
115 bool bTruncate
) const;
117 bool queryNamesOfChildren(
118 const OUString
& rUri
,
119 css::uno::Sequence
< OUString
> & rNames
) const;
121 // storage properties
122 OUString
queryStorageTitle( const OUString
& rUri
) const;
124 css::uno::Reference
< css::frame::XModel
>
125 queryDocumentModel( const OUString
& rUri
) const;
127 css::util::DateTime
queryStreamDateModified(OUString
const & uri
) const;
129 // interface OfficeDocumentsEventListener
130 void notifyDocumentOpened( std::u16string_view rDocId
);
131 void notifyDocumentClosed( std::u16string_view rDocId
);
134 rtl::Reference
< OfficeDocumentsManager
> m_xDocsMgr
;
135 rtl::Reference
< StorageElementFactory
> m_xStgElemFac
;
138 } // namespace tdoc_ucp
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */