1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _FRM_FORMATTED_FIELD_WRAPPER_HXX_ 25 #define _FRM_FORMATTED_FIELD_WRAPPER_HXX_ 26 27 #include "FormComponent.hxx" 28 #include <cppuhelper/implbase3.hxx> 29 #include <com/sun/star/lang/XServiceInfo.hpp> 30 #include <com/sun/star/util/XCloneable.hpp> 31 32 //......................................................................... 33 namespace frm 34 { 35 36 class OEditModel; 37 //================================================================== 38 //= OFormattedFieldWrapper 39 //================================================================== 40 typedef ::cppu::WeakAggImplHelper3 < ::com::sun::star::io::XPersistObject 41 , ::com::sun::star::lang::XServiceInfo 42 , ::com::sun::star::util::XCloneable 43 > OFormattedFieldWrapper_Base; 44 45 class OFormattedFieldWrapper : public OFormattedFieldWrapper_Base 46 { 47 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xServiceFactory; 48 49 protected: 50 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation> m_xAggregate; 51 52 OEditModel* m_pEditPart; 53 // if we act as formatted this is used to write the EditModel part 54 ::com::sun::star::uno::Reference< ::com::sun::star::io::XPersistObject> m_xFormattedPart; 55 // if we act as formatted, this is the PersistObject interface of our aggregate, used 56 // to read and write the FormattedModel part 57 58 OFormattedFieldWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, sal_Bool _bActAsFormatted); 59 // if _bActAsFormatted is sal_False, the state is undetermined until somebody calls ::read or does 60 // anything which requires a living aggregate 61 OFormattedFieldWrapper( const OFormattedFieldWrapper* _pCloneSource ); 62 virtual ~OFormattedFieldWrapper(); 63 64 friend InterfaceRef SAL_CALL OFormattedFieldWrapper_CreateInstance_ForceFormatted(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); 65 friend InterfaceRef SAL_CALL OFormattedFieldWrapper_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory); 66 67 public: 68 // UNO 69 DECLARE_UNO3_AGG_DEFAULTS(OFormattedFieldWrapper, OWeakAggObject); 70 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException); 71 72 // XServiceInfo 73 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); 74 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 75 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); 76 77 // XPersistObject 78 virtual ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); 79 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); 80 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); 81 82 // XCloneable 83 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); 84 85 protected: 86 /// ensure we're in a defined state, which means a FormattedModel _OR_ an EditModel 87 void ensureAggregate(); 88 }; 89 90 //......................................................................... 91 } 92 //......................................................................... 93 94 #endif // _FRM_FORMATTED_FIELD_WRAPPER_HXX_ 95 96