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 .
21 #include <com/sun/star/ucb/XContent.hpp>
22 #include <com/sun/star/ucb/XCommandProcessor.hpp>
23 #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
24 #include <com/sun/star/beans/XPropertyContainer.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/lang/XInitialization.hpp>
27 #include <com/sun/star/sdbc/XRow.hpp>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <cppuhelper/compbase.hxx>
30 #include <cppuhelper/basemutex.hxx>
31 #include <comphelper/interfacecontainer3.hxx>
32 #include <comphelper/multiinterfacecontainer3.hxx>
33 #include <com/sun/star/beans/Property.hpp>
34 #include <com/sun/star/container/XChild.hpp>
35 #include <com/sun/star/sdbcx/XRename.hpp>
36 #include <connectivity/sqlerror.hxx>
39 namespace com::sun::star::beans
{ struct PropertyValue
; }
43 class ODatabaseModelImpl
;
44 struct ContentProperties
46 OUString aTitle
; // Title
47 ::std::optional
< OUString
>
48 aContentType
; // ContentType (aka MediaType aka MimeType)
49 bool bIsDocument
; // IsDocument
50 bool bIsFolder
; // IsFolder
51 bool bAsTemplate
; // AsTemplate
52 OUString sPersistentName
;// persistent name of the document
62 class OContentHelper_Impl
65 OContentHelper_Impl();
66 virtual ~OContentHelper_Impl();
68 ContentProperties m_aProps
;
69 ODatabaseModelImpl
* m_pDataSource
; // this will stay alive as long as the content exists
72 typedef std::shared_ptr
<OContentHelper_Impl
> TContentPtr
;
74 typedef comphelper::OMultiTypeInterfaceContainerHelperVar3
<css::beans::XPropertiesChangeListener
, OUString
>
75 PropertyChangeListenerContainer
;
76 typedef ::cppu::WeakComponentImplHelper
< css::ucb::XContent
77 , css::ucb::XCommandProcessor
78 , css::lang::XServiceInfo
79 , css::beans::XPropertiesChangeNotifier
80 , css::beans::XPropertyContainer
81 , css::lang::XInitialization
82 , css::container::XChild
84 > OContentHelper_COMPBASE
;
86 class OContentHelper
: public ::cppu::BaseMutex
87 ,public OContentHelper_COMPBASE
89 css::uno::Sequence
< css::uno::Any
>
90 setPropertyValues( const css::uno::Sequence
< css::beans::PropertyValue
>& rValues
);
92 void impl_rename_throw(const OUString
& _sNewName
,bool _bNotify
= true);
95 ::comphelper::OInterfaceContainerHelper3
<css::ucb::XContentEventListener
> m_aContentListeners
;
96 PropertyChangeListenerContainer m_aPropertyChangeListeners
;
97 css::uno::Reference
< css::uno::XInterface
>
99 const css::uno::Reference
< css::uno::XComponentContext
>
101 const ::connectivity::SQLError m_aErrorHelper
;
103 sal_uInt32 m_nCommandId
;
106 virtual void SAL_CALL
disposing() override
;
108 void notifyDataSourceModified();
111 * This method can be used to propagate changes of property values.
113 * @param evt is a sequence of property change events.
115 void notifyPropertiesChange( const css::uno::Sequence
< css::beans::PropertyChangeEvent
>& evt
) const;
117 OUString
impl_getHierarchicalName( bool _includingRootContainer
) const;
121 OContentHelper( const css::uno::Reference
< css::uno::XComponentContext
>& _xORB
122 ,const css::uno::Reference
< css::uno::XInterface
>& _xParentContainer
126 // css::lang::XTypeProvider
127 virtual css::uno::Sequence
<sal_Int8
> SAL_CALL
getImplementationId( ) override
;
129 // css::lang::XServiceInfo
130 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
131 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
132 virtual OUString SAL_CALL
getImplementationName( ) override
;
135 virtual css::uno::Reference
< css::ucb::XContentIdentifier
> SAL_CALL
getIdentifier( ) override
;
136 virtual OUString SAL_CALL
getContentType( ) override
;
137 virtual void SAL_CALL
addContentEventListener( const css::uno::Reference
< css::ucb::XContentEventListener
>& Listener
) override
;
138 virtual void SAL_CALL
removeContentEventListener( const css::uno::Reference
< css::ucb::XContentEventListener
>& Listener
) override
;
141 virtual sal_Int32 SAL_CALL
createCommandIdentifier( ) override
;
142 virtual css::uno::Any SAL_CALL
execute( const css::ucb::Command
& aCommand
, sal_Int32 CommandId
, const css::uno::Reference
< css::ucb::XCommandEnvironment
>& Environment
) override
;
143 virtual void SAL_CALL
abort( sal_Int32 CommandId
) override
;
145 // XPropertiesChangeNotifier
146 virtual void SAL_CALL
addPropertiesChangeListener( const css::uno::Sequence
< OUString
>& PropertyNames
, const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& Listener
) override
;
147 virtual void SAL_CALL
removePropertiesChangeListener( const css::uno::Sequence
< OUString
>& PropertyNames
, const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& Listener
) override
;
149 // XPropertyContainer
150 virtual void SAL_CALL
addProperty( const OUString
& Name
, sal_Int16 Attributes
, const css::uno::Any
& DefaultValue
) override
;
151 virtual void SAL_CALL
removeProperty( const OUString
& Name
) override
;
154 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
156 // css::container::XChild
157 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getParent( ) override
;
158 virtual void SAL_CALL
setParent( const css::uno::Reference
< css::uno::XInterface
>& Parent
) override
;
161 virtual void SAL_CALL
rename( const OUString
& newName
) override
;
163 const ContentProperties
& getContentProperties() const { return m_pImpl
->m_aProps
; }
164 css::uno::Reference
< css::sdbc::XRow
>
165 getPropertyValues( const css::uno::Sequence
< css::beans::Property
>& rProperties
);
167 const css::uno::Reference
< css::uno::XComponentContext
>& getContext() const { return m_aContext
; }
169 const TContentPtr
& getImpl() const { return m_pImpl
; }
172 virtual OUString
determineContentType() const = 0;
175 } // namespace dbaccess
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */