| 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 <string_view> |
| 25 |
|
| 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" |
| 33 |
|
| 34 |
namespace com::sun::star::embed { |
| 35 |
class XStorage; |
| 36 |
} |
| 37 |
|
| 38 |
namespace com::sun::star::frame { |
| 39 |
class XModel; |
| 40 |
} |
| 41 |
|
| 42 |
namespace com::sun::star::util { |
| 43 |
struct DateTime; |
| 44 |
} |
| 45 |
|
| 46 |
namespace tdoc_ucp { |
| 47 |
|
| 48 |
|
| 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; |
| 57 |
|
| 58 |
|
| 59 |
typedef cppu::ImplInheritanceHelper< |
| 60 |
::ucbhelper::ContentProviderImplHelper, |
| 61 |
css::frame::XTransientDocumentsDocumentContentIdentifierFactory, |
| 62 |
css::frame::XTransientDocumentsDocumentContentFactory > ContentProvider_Base; |
| 63 |
class ContentProvider : public ContentProvider_Base |
| 64 |
{ |
| 65 |
public: |
| 66 |
explicit ContentProvider( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); |
| 67 |
virtual ~ContentProvider() override; |
| 68 |
|
| 69 |
// XServiceInfo |
| 70 |
virtual OUString SAL_CALL getImplementationName() override; |
| 71 |
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; |
| 72 |
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; |
| 73 |
|
| 74 |
// XContentProvider |
| 75 |
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL |
| 76 |
queryContent( const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier ) override; |
| 77 |
|
| 78 |
// XTransientDocumentsDocumentContentIdentifierFactory |
| 79 |
virtual css::uno::Reference<css::ucb::XContentIdentifier> SAL_CALL |
| 80 |
createDocumentContentIdentifier( |
| 81 |
css::uno::Reference<css::frame::XModel> const& xModel) override; |
| 82 |
|
| 83 |
// XTransientDocumentsDocumentContentFactory |
| 84 |
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL |
| 85 |
createDocumentContent( const css::uno::Reference< |
| 86 |
css::frame::XModel >& Model ) override; |
| 87 |
|
| 88 |
// Non-UNO interfaces |
| 89 |
css::uno::Reference< css::embed::XStorage > |
| 90 |
queryStorage( const OUString & rUri, StorageAccessMode eMode ) const; |
| 91 |
|
| 92 |
css::uno::Reference< css::embed::XStorage > |
| 93 |
queryStorageClone( const OUString & rUri ) const; |
| 94 |
|
| 95 |
/// @throws css::packages::WrongPasswordException |
| 96 |
/// @throws css::uno::RuntimeException |
| 97 |
css::uno::Reference< css::io::XInputStream > |
| 98 |
queryInputStream( const OUString & rUri, |
| 99 |
const OUString & rPassword ) const; |
| 100 |
|
| 101 |
/// @throws css::packages::WrongPasswordException |
| 102 |
/// @throws css::uno::RuntimeException |
| 103 |
css::uno::Reference< css::io::XOutputStream > |
| 104 |
queryOutputStream( const OUString & rUri, |
| 105 |
const OUString & rPassword, |
| 106 |
bool bTruncate ) const; |
| 107 |
|
| 108 |
/// @throws css::packages::WrongPasswordException |
| 109 |
/// @throws css::uno::RuntimeException |
| 110 |
css::uno::Reference< css::io::XStream > |
| 111 |
queryStream( const OUString & rUri, |
| 112 |
const OUString & rPassword, |
| 113 |
bool bTruncate ) const; |
| 114 |
|
| 115 |
bool queryNamesOfChildren( |
| 116 |
const OUString & rUri, |
| 117 |
css::uno::Sequence< OUString > & rNames ) const; |
| 118 |
|
| 119 |
// storage properties |
| 120 |
OUString queryStorageTitle( const OUString & rUri ) const; |
| 121 |
|
| 122 |
css::uno::Reference< css::frame::XModel > |
| 123 |
queryDocumentModel( const OUString & rUri ) const; |
| 124 |
|
| 125 |
css::util::DateTime queryStreamDateModified(OUString const & uri) const; |
| 126 |
|
| 127 |
// interface OfficeDocumentsEventListener |
| 128 |
void notifyDocumentOpened( std::u16string_view rDocId ); |
| 129 |
void notifyDocumentClosed( std::u16string_view rDocId ); |
| 130 |
|
| 131 |
private: |
| 132 |
rtl::Reference< OfficeDocumentsManager > m_xDocsMgr; |
| 133 |
rtl::Reference< StorageElementFactory > m_xStgElemFac; |
| 134 |
}; |
| 135 |
|
| 136 |
} // namespace tdoc_ucp |
| 137 |
|
| 138 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |