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 <rtl/ref.hxx>
23 #include <com/sun/star/frame/XTransientDocumentsDocumentContentFactory.hpp>
24 #include <com/sun/star/frame/XTransientDocumentsDocumentContentIdentifierFactory.hpp>
25 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <ucbhelper/providerhelper.hxx>
28 #include "tdoc_uri.hxx"
29 #include "tdoc_docmgr.hxx"
30 #include "tdoc_storage.hxx"
32 namespace com::sun::star::embed
{
36 namespace com::sun::star::frame
{
43 #define TDOC_ROOT_CONTENT_TYPE \
44 u"application/" TDOC_URL_SCHEME "-root"
45 #define TDOC_DOCUMENT_CONTENT_TYPE \
46 u"application/" TDOC_URL_SCHEME "-document"
47 #define TDOC_FOLDER_CONTENT_TYPE \
48 u"application/" TDOC_URL_SCHEME "-folder"
49 #define TDOC_STREAM_CONTENT_TYPE \
50 u"application/" TDOC_URL_SCHEME "-stream"
53 class StorageElementFactory
;
56 : public ::ucbhelper::ContentProviderImplHelper
57 , public css::frame::XTransientDocumentsDocumentContentIdentifierFactory
58 , public css::frame::XTransientDocumentsDocumentContentFactory
61 explicit ContentProvider( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
62 virtual ~ContentProvider() override
;
65 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
66 virtual void SAL_CALL
acquire()
68 virtual void SAL_CALL
release()
72 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
73 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
76 virtual OUString SAL_CALL
getImplementationName() override
;
77 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
78 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
81 virtual css::uno::Reference
< css::ucb::XContent
> SAL_CALL
82 queryContent( const css::uno::Reference
< css::ucb::XContentIdentifier
>& Identifier
) override
;
84 // XTransientDocumentsDocumentContentIdentifierFactory
85 virtual css::uno::Reference
<css::ucb::XContentIdentifier
> SAL_CALL
86 createDocumentContentIdentifier(
87 css::uno::Reference
<css::frame::XModel
> const& xModel
) override
;
89 // XTransientDocumentsDocumentContentFactory
90 virtual css::uno::Reference
< css::ucb::XContent
> SAL_CALL
91 createDocumentContent( const css::uno::Reference
<
92 css::frame::XModel
>& Model
) override
;
95 css::uno::Reference
< css::embed::XStorage
>
96 queryStorage( const OUString
& rUri
, StorageAccessMode eMode
) const;
98 css::uno::Reference
< css::embed::XStorage
>
99 queryStorageClone( const OUString
& rUri
) const;
101 /// @throws css::packages::WrongPasswordException
102 /// @throws css::uno::RuntimeException
103 css::uno::Reference
< css::io::XInputStream
>
104 queryInputStream( const OUString
& rUri
,
105 const OUString
& rPassword
) const;
107 /// @throws css::packages::WrongPasswordException
108 /// @throws css::uno::RuntimeException
109 css::uno::Reference
< css::io::XOutputStream
>
110 queryOutputStream( const OUString
& rUri
,
111 const OUString
& rPassword
,
112 bool bTruncate
) const;
114 /// @throws css::packages::WrongPasswordException
115 /// @throws css::uno::RuntimeException
116 css::uno::Reference
< css::io::XStream
>
117 queryStream( const OUString
& rUri
,
118 const OUString
& rPassword
,
119 bool bTruncate
) const;
121 bool queryNamesOfChildren(
122 const OUString
& rUri
,
123 css::uno::Sequence
< OUString
> & rNames
) const;
125 // storage properties
126 OUString
queryStorageTitle( const OUString
& rUri
) const;
128 css::uno::Reference
< css::frame::XModel
>
129 queryDocumentModel( const OUString
& rUri
) const;
131 // interface OfficeDocumentsEventListener
132 void notifyDocumentOpened( const OUString
& rDocId
);
133 void notifyDocumentClosed( const OUString
& rDocId
);
136 rtl::Reference
< OfficeDocumentsManager
> m_xDocsMgr
;
137 rtl::Reference
< StorageElementFactory
> m_xStgElemFac
;
140 } // namespace tdoc_ucp
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */