Line data Source code
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 : #ifndef INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELDWRAPPER_HXX
21 : #define INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELDWRAPPER_HXX
22 :
23 : #include "FormComponent.hxx"
24 : #include <cppuhelper/implbase3.hxx>
25 : #include <com/sun/star/lang/XServiceInfo.hpp>
26 : #include <com/sun/star/util/XCloneable.hpp>
27 :
28 :
29 : namespace frm
30 : {
31 :
32 : class OEditModel;
33 :
34 : //= OFormattedFieldWrapper
35 :
36 : typedef ::cppu::WeakAggImplHelper3 < ::com::sun::star::io::XPersistObject
37 : , ::com::sun::star::lang::XServiceInfo
38 : , ::com::sun::star::util::XCloneable
39 : > OFormattedFieldWrapper_Base;
40 :
41 : class OFormattedFieldWrapper : public OFormattedFieldWrapper_Base
42 : {
43 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext;
44 :
45 : protected:
46 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation> m_xAggregate;
47 :
48 : rtl::Reference< OEditModel > m_pEditPart;
49 : // if we act as formatted this is used to write the EditModel part
50 : ::com::sun::star::uno::Reference< ::com::sun::star::io::XPersistObject> m_xFormattedPart;
51 : // if we act as formatted, this is the PersistObject interface of our aggregate, used
52 : // to read and write the FormattedModel part
53 : // if bActAsFormatted is false, the state is undetermined until somebody calls
54 : // ::read or does anything which requires a living aggregate
55 : static InterfaceRef createFormattedFieldWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory, bool bActAsFormatted);
56 :
57 : private:
58 : OFormattedFieldWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory);
59 :
60 : protected:
61 : virtual ~OFormattedFieldWrapper();
62 :
63 : friend InterfaceRef SAL_CALL OFormattedFieldWrapper_CreateInstance_ForceFormatted(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
64 : friend InterfaceRef SAL_CALL OFormattedFieldWrapper_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
65 :
66 : public:
67 : // UNO
68 0 : DECLARE_UNO3_AGG_DEFAULTS(OFormattedFieldWrapper, OWeakAggObject)
69 : virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
70 :
71 : // XServiceInfo
72 : virtual OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
73 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
74 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
75 :
76 : // XPersistObject
77 : virtual OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
78 : virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
79 : virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
80 :
81 : // XCloneable
82 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 :
84 : protected:
85 : /// ensure we're in a defined state, which means a FormattedModel _OR_ an EditModel
86 : void ensureAggregate();
87 : };
88 :
89 :
90 : }
91 :
92 :
93 : #endif // INCLUDED_FORMS_SOURCE_COMPONENT_FORMATTEDFIELDWRAPPER_HXX
94 :
95 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|