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 .
20 #ifndef INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_PROVIDER_HXX
21 #define INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_PROVIDER_HXX
23 #include "rtl/ref.hxx"
24 #include <com/sun/star/frame/XTransientDocumentsDocumentContentFactory.hpp>
25 #include <com/sun/star/packages/WrongPasswordException.hpp>
26 #include "ucbhelper/providerhelper.hxx"
27 #include "tdoc_uri.hxx"
28 #include "tdoc_docmgr.hxx"
29 #include "tdoc_storage.hxx"
31 namespace com
{ namespace sun
{ namespace star
{ namespace embed
{
35 namespace com
{ namespace sun
{ namespace star
{ namespace frame
{
43 #define TDOC_CONTENT_PROVIDER_SERVICE_NAME \
44 "com.sun.star.ucb.TransientDocumentsContentProvider"
46 #define TDOC_ROOT_CONTENT_TYPE \
47 "application/" TDOC_URL_SCHEME "-root"
48 #define TDOC_DOCUMENT_CONTENT_TYPE \
49 "application/" TDOC_URL_SCHEME "-document"
50 #define TDOC_FOLDER_CONTENT_TYPE \
51 "application/" TDOC_URL_SCHEME "-folder"
52 #define TDOC_STREAM_CONTENT_TYPE \
53 "application/" TDOC_URL_SCHEME "-stream"
57 class StorageElementFactory
;
59 class ContentProvider
:
60 public ::ucbhelper::ContentProviderImplHelper
,
61 public com::sun::star::frame::XTransientDocumentsDocumentContentFactory
,
62 public OfficeDocumentsEventListener
65 ContentProvider( const com::sun::star::uno::Reference
<
66 com::sun::star::uno::XComponentContext
>& rxContext
);
67 virtual ~ContentProvider();
70 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
)
71 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
72 virtual void SAL_CALL
acquire()
74 virtual void SAL_CALL
release()
78 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId()
79 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
80 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes()
81 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
84 virtual OUString SAL_CALL
getImplementationName()
85 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
86 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
87 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
88 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames()
89 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
91 static OUString
getImplementationName_Static();
92 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static();
94 static css::uno::Reference
< css::lang::XSingleServiceFactory
>
95 createServiceFactory( const css::uno::Reference
<
96 css::lang::XMultiServiceFactory
>& rxServiceMgr
);
99 virtual com::sun::star::uno::Reference
<
100 com::sun::star::ucb::XContent
> SAL_CALL
101 queryContent( const com::sun::star::uno::Reference
<
102 com::sun::star::ucb::XContentIdentifier
>& Identifier
)
103 throw( com::sun::star::ucb::IllegalIdentifierException
,
104 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
106 // XTransientDocumentsDocumentContentFactory
107 virtual com::sun::star::uno::Reference
<
108 com::sun::star::ucb::XContent
> SAL_CALL
109 createDocumentContent( const ::com::sun::star::uno::Reference
<
110 com::sun::star::frame::XModel
>& Model
)
111 throw ( com::sun::star::lang::IllegalArgumentException
,
112 com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
114 // Non-UNO interfaces
115 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>
116 queryStorage( const OUString
& rUri
, StorageAccessMode eMode
) const;
118 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>
119 queryStorageClone( const OUString
& rUri
) const;
121 com::sun::star::uno::Reference
< com::sun::star::io::XInputStream
>
122 queryInputStream( const OUString
& rUri
,
123 const OUString
& rPassword
) const
124 throw ( com::sun::star::packages::WrongPasswordException
,
125 css::uno::RuntimeException
);
127 com::sun::star::uno::Reference
< com::sun::star::io::XOutputStream
>
128 queryOutputStream( const OUString
& rUri
,
129 const OUString
& rPassword
,
130 bool bTruncate
) const
131 throw ( com::sun::star::packages::WrongPasswordException
,
132 css::uno::RuntimeException
);
134 com::sun::star::uno::Reference
< com::sun::star::io::XStream
>
135 queryStream( const OUString
& rUri
,
136 const OUString
& rPassword
,
137 bool bTruncate
) const
138 throw ( com::sun::star::packages::WrongPasswordException
,
139 css::uno::RuntimeException
);
141 bool queryNamesOfChildren(
142 const OUString
& rUri
,
143 com::sun::star::uno::Sequence
< OUString
> & rNames
) const;
145 // storage properties
146 OUString
queryStorageTitle( const OUString
& rUri
) const;
148 com::sun::star::uno::Reference
< com::sun::star::frame::XModel
>
149 queryDocumentModel( const OUString
& rUri
) const;
151 // interface OfficeDocumentsEventListener
152 virtual void notifyDocumentOpened( const OUString
& rDocId
) SAL_OVERRIDE
;
153 virtual void notifyDocumentClosed( const OUString
& rDocId
) SAL_OVERRIDE
;
156 rtl::Reference
< OfficeDocumentsManager
> m_xDocsMgr
;
157 rtl::Reference
< StorageElementFactory
> m_xStgElemFac
;
160 } // namespace tdoc_ucp
162 #endif // INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_PROVIDER_HXX
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */