29 #include <com/sun/star/embed/InvalidStorageException.hpp>
30 #include <com/sun/star/embed/StorageWrappedTargetException.hpp>
31 #include <com/sun/star/io/IOException.hpp>
32 #include <com/sun/star/ucb/IllegalIdentifierException.hpp>
51 const uno::Reference< uno::XComponentContext >& rxContext )
52 : ::
ucbhelper::ContentProviderImplHelper( rxContext ),
71 OWeakObject::acquire();
77 OWeakObject::release();
83 static_cast< lang::XTypeProvider* >(
this),
84 static_cast< lang::XServiceInfo* >(
this),
85 static_cast< ucb::XContentProvider* >(
this),
86 static_cast< frame::XTransientDocumentsDocumentContentIdentifierFactory* >(
this),
87 static_cast< frame::XTransientDocumentsDocumentContentFactory* >(
this)
89 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
98 ucb::XContentProvider,
99 frame::XTransientDocumentsDocumentContentIdentifierFactory,
100 frame::XTransientDocumentsDocumentContentFactory );
106 return "com.sun.star.comp.ucb.TransientDocumentsContentProvider";
116 return {
"com.sun.star.ucb.TransientDocumentsContentProvider" };
123 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
125 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const&)
134 uno::Reference< ucb::XContent > SAL_CALL
136 const uno::Reference< ucb::XContentIdentifier >& Identifier )
138 Uri aUri( Identifier->getContentIdentifier() );
139 if ( !aUri.isValid() )
140 throw ucb::IllegalIdentifierException(
145 uno::Reference< ucb::XContentIdentifier > xCanonicId
146 = new ::ucbhelper::ContentIdentifier( aUri.getUri() );
151 uno::Reference< ucb::XContent >
xContent
154 if ( !xContent.is() )
167 uno::Reference<ucb::XContentIdentifier> SAL_CALL
169 uno::Reference<frame::XModel>
const& xModel)
174 throw lang::IllegalArgumentException(
175 "No Document Manager!",
176 static_cast< cppu::OWeakObject * >(
this ),
181 if ( aDocId.isEmpty() )
183 throw lang::IllegalArgumentException(
184 "Unable to obtain document id from model!",
185 static_cast< cppu::OWeakObject * >(
this ),
191 uno::Reference< ucb::XContentIdentifier >
xId
192 = new ::ucbhelper::ContentIdentifier( aBuffer );
198 uno::Reference< ucb::XContent > SAL_CALL
200 uno::Reference<frame::XModel>
const& xModel)
202 uno::Reference<ucb::XContentIdentifier>
const xId(
208 uno::Reference< ucb::XContent > xContent
211 if ( !xContent.is() )
221 throw lang::IllegalArgumentException(
222 "Illegal Content Identifier!",
223 static_cast< cppu::OWeakObject * >(
this ),
241 bool bFoundDocumentContent =
false;
244 for (
const auto& rContent : aAllContents )
246 Uri aUri( rContent->getIdentifier()->getContentIdentifier() );
247 OSL_ENSURE( aUri.isValid(),
248 "ContentProvider::notifyDocumentClosed - Invalid URI!" );
250 if ( !bFoundDocumentContent )
254 xRoot =
static_cast< Content *
>( rContent.get() );
256 else if ( aUri.isDocument() )
258 if ( aUri.getDocumentId() == rDocId )
260 bFoundDocumentContent =
true;
269 if ( aUri.getDocumentId() == rDocId )
273 =
static_cast< Content *
>( rContent.get() );
275 xContent->notifyDocumentClosed();
284 xRoot->notifyChildRemoved( rDocId );
299 for (
const auto& rContent : aAllContents )
301 Uri aUri( rContent->getIdentifier()->getContentIdentifier() );
302 OSL_ENSURE( aUri.isValid(),
303 "ContentProvider::notifyDocumentOpened - Invalid URI!" );
308 =
static_cast< Content *
>( rContent.get() );
309 xRoot->notifyChildInserted( rDocId );
321 uno::Reference< embed::XStorage >
331 catch ( embed::InvalidStorageException
const & )
335 catch ( lang::IllegalArgumentException
const & )
339 catch ( io::IOException
const & )
344 catch ( embed::StorageWrappedTargetException
const & )
349 return uno::Reference< embed::XStorage >();
353 uno::Reference< embed::XStorage >
361 uno::Reference< embed::XStorage > xParentStorage
363 uno::Reference< embed::XStorage > xStorage
366 xParentStorage->copyStorageElementLastCommitTo(
370 catch ( embed::InvalidStorageException
const & )
374 catch ( lang::IllegalArgumentException
const & )
378 catch ( io::IOException
const & )
383 catch ( embed::StorageWrappedTargetException
const & )
389 return uno::Reference< embed::XStorage >();
393 uno::Reference< io::XInputStream >
395 const OUString & rPassword )
const
403 catch ( embed::InvalidStorageException
const & )
407 catch ( lang::IllegalArgumentException
const & )
411 catch ( io::IOException
const & )
415 catch ( embed::StorageWrappedTargetException
const & )
425 return uno::Reference< io::XInputStream >();
429 uno::Reference< io::XOutputStream >
431 const OUString & rPassword,
432 bool bTruncate )
const
439 m_xStgElemFac->createOutputStream( rUri, rPassword, bTruncate );
441 catch ( embed::InvalidStorageException
const & )
445 catch ( lang::IllegalArgumentException
const & )
449 catch ( io::IOException
const & )
454 catch ( embed::StorageWrappedTargetException
const & )
464 return uno::Reference< io::XOutputStream >();
468 uno::Reference< io::XStream >
470 const OUString & rPassword,
471 bool bTruncate )
const
477 return m_xStgElemFac->createStream( rUri, rPassword, bTruncate );
479 catch ( embed::InvalidStorageException
const & )
483 catch ( lang::IllegalArgumentException
const & )
487 catch ( io::IOException
const & )
492 catch ( embed::StorageWrappedTargetException
const & )
502 return uno::Reference< io::XStream >();
507 const OUString & rUri, uno::Sequence< OUString > & rNames )
const
525 uno::Reference< embed::XStorage > xStorage
528 OSL_ENSURE( xStorage.is(),
"Got no Storage!" );
532 rNames = xStorage->getElementNames();
536 catch ( embed::InvalidStorageException
const & )
540 catch ( lang::IllegalArgumentException
const & )
544 catch ( io::IOException
const & )
549 catch ( embed::StorageWrappedTargetException
const & )
583 OSL_ENSURE( !aTitle.isEmpty() || aUri.
isRoot(),
584 "ContentProvider::queryStorageTitle - empty title!" );
589 uno::Reference< frame::XModel >
592 uno::Reference< frame::XModel >
xModel;
600 OSL_ENSURE( xModel.is(),
601 "ContentProvider::queryDocumentModel - no model!" );
std::vector< ContentImplHelperRef > ContentRefList
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
rtl::Reference< StorageElementFactory > m_xStgElemFac
osl::Mutex & getContentListMutex()
css::uno::Reference< css::frame::XModel > queryDocumentModel(const OUString &rUri) const
void queryExistingContents(ContentRefList &rContents)
css::uno::Reference< css::embed::XStorage > queryStorageClone(const OUString &rUri) const
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL createDocumentContentIdentifier(css::uno::Reference< css::frame::XModel > const &xModel) override
css::uno::Reference< css::io::XInputStream > queryInputStream(const OUString &rUri, const OUString &rPassword) const
css::uno::Reference< css::io::XStream > queryStream(const OUString &rUri, const OUString &rPassword, bool bTruncate) const
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createDocumentContent(const css::uno::Reference< css::frame::XModel > &Model) override
OUString queryStorageTitle(const OUString &rUri) const
virtual void SAL_CALL acquire() noexcept override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent(const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier) override
XTYPEPROVIDER_IMPL_5(ContentProvider, lang::XTypeProvider, lang::XServiceInfo, ucb::XContentProvider, frame::XTransientDocumentsDocumentContentIdentifierFactory, frame::XTransientDocumentsDocumentContentFactory)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ucb_tdoc_ContentProvider_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
#define TOOLS_WARN_EXCEPTION(area, stream)
const OUString & getDecodedName() const
css::uno::Reference< css::io::XOutputStream > queryOutputStream(const OUString &rUri, const OUString &rPassword, bool bTruncate) const
bool queryNamesOfChildren(const OUString &rUri, css::uno::Sequence< OUString > &rNames) const
rtl::Reference< ContentImplHelper > queryExistingContent(const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier)
static OUString queryDocumentId(const css::uno::Reference< css::frame::XModel > &xModel)
css::uno::Reference< css::uno::XComponentContext > m_xContext
void registerNewContent(const css::uno::Reference< css::ucb::XContent > &xContent)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
css::uno::Reference< css::embed::XStorage > queryStorage(const OUString &rUri, StorageAccessMode eMode) const
virtual ~ContentProvider() override
std::unique_ptr< char[]> aBuffer
rtl::Reference< OfficeDocumentsManager > m_xDocsMgr
virtual void SAL_CALL release() noexcept override
const OUString & getDocumentId() const
static rtl::Reference< Content > create(const css::uno::Reference< css::uno::XComponentContext > &rxContext, ContentProvider *pProvider, const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier)
const OUString & getParentUri() const
::rtl::Reference< OContentHelper > xContent
void notifyDocumentClosed(std::u16string_view rDocId)
Reference< XModel > xModel
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
void notifyDocumentOpened(std::u16string_view rDocId)
Reference< XContentIdentifier > xId