nss: upgrade to release 3.73
[LibreOffice.git] / dbaccess / source / core / inc / ContentHelper.hxx
blobb7d275481ec1bcde56959ff7335b3d55f9df29e8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #pragma once
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/lang/XUnoTunnel.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <cppuhelper/compbase.hxx>
31 #include <cppuhelper/basemutex.hxx>
32 #include <comphelper/interfacecontainer2.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>
37 #include <memory>
39 namespace com::sun::star::beans { struct PropertyValue; }
41 namespace dbaccess
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
54 ContentProperties()
55 :bIsDocument( true )
56 ,bIsFolder( false )
57 ,bAsTemplate( false )
62 class OContentHelper_Impl
64 public:
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 cppu::OMultiTypeInterfaceContainerHelperVar<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::lang::XUnoTunnel
83 , css::container::XChild
84 , css::sdbcx::XRename
85 > OContentHelper_COMPBASE;
87 class OContentHelper : public ::cppu::BaseMutex
88 ,public OContentHelper_COMPBASE
90 css::uno::Sequence< css::uno::Any >
91 setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& rValues );
93 void impl_rename_throw(const OUString& _sNewName,bool _bNotify = true);
95 protected:
96 ::comphelper::OInterfaceContainerHelper2 m_aContentListeners;
97 PropertyChangeListenerContainer m_aPropertyChangeListeners;
98 css::uno::Reference< css::uno::XInterface >
99 m_xParentContainer;
100 const css::uno::Reference< css::uno::XComponentContext >
101 m_aContext;
102 const ::connectivity::SQLError m_aErrorHelper;
103 TContentPtr m_pImpl;
104 sal_uInt32 m_nCommandId;
106 // helper
107 virtual void SAL_CALL disposing() override;
109 void notifyDataSourceModified();
112 * This method can be used to propagate changes of property values.
114 * @param evt is a sequence of property change events.
116 void notifyPropertiesChange( const css::uno::Sequence< css::beans::PropertyChangeEvent >& evt ) const;
118 OUString impl_getHierarchicalName( bool _includingRootContainer ) const;
120 public:
122 OContentHelper( const css::uno::Reference< css::uno::XComponentContext >& _xORB
123 ,const css::uno::Reference< css::uno::XInterface >& _xParentContainer
124 ,const TContentPtr& _pImpl
127 // css::lang::XTypeProvider
128 virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) override;
130 // css::lang::XServiceInfo
131 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
132 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
133 virtual OUString SAL_CALL getImplementationName( ) override;
135 // XContent
136 virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL getIdentifier( ) override ;
137 virtual OUString SAL_CALL getContentType( ) override ;
138 virtual void SAL_CALL addContentEventListener( const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) override ;
139 virtual void SAL_CALL removeContentEventListener( const css::uno::Reference< css::ucb::XContentEventListener >& Listener ) override ;
141 // XCommandProcessor
142 virtual sal_Int32 SAL_CALL createCommandIdentifier( ) override ;
143 virtual css::uno::Any SAL_CALL execute( const css::ucb::Command& aCommand, sal_Int32 CommandId, const css::uno::Reference< css::ucb::XCommandEnvironment >& Environment ) override ;
144 virtual void SAL_CALL abort( sal_Int32 CommandId ) override ;
146 // XPropertiesChangeNotifier
147 virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) override ;
148 virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Sequence< OUString >& PropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& Listener ) override ;
150 // XPropertyContainer
151 virtual void SAL_CALL addProperty( const OUString& Name, sal_Int16 Attributes, const css::uno::Any& DefaultValue ) override ;
152 virtual void SAL_CALL removeProperty( const OUString& Name ) override ;
154 // XInitialization
155 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
157 // css::lang::XUnoTunnel
158 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
159 static css::uno::Sequence< sal_Int8 > getUnoTunnelId();
161 // css::container::XChild
162 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override;
163 virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) override;
165 // XRename
166 virtual void SAL_CALL rename( const OUString& newName ) override;
168 const ContentProperties& getContentProperties() const { return m_pImpl->m_aProps; }
169 css::uno::Reference< css::sdbc::XRow >
170 getPropertyValues( const css::uno::Sequence< css::beans::Property >& rProperties );
172 const css::uno::Reference< css::uno::XComponentContext >& getContext() const { return m_aContext; }
174 const TContentPtr& getImpl() const { return m_pImpl; }
176 protected:
177 virtual OUString determineContentType() const = 0;
180 } // namespace dbaccess
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */