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 _COMPHELPER_PROPERTY_STATE_HXX_
21 : #define _COMPHELPER_PROPERTY_STATE_HXX_
22 :
23 : #include <com/sun/star/beans/XPropertyState.hpp>
24 : #include <com/sun/star/uno/Sequence.hxx>
25 :
26 :
27 : #include <cppuhelper/propshlp.hxx>
28 : #include <cppuhelper/proptypehlp.hxx>
29 : #include <cppuhelper/weak.hxx>
30 : #include <comphelper/uno3.hxx>
31 : #include <comphelper/broadcasthelper.hxx>
32 : #include <com/sun/star/lang/XTypeProvider.hpp>
33 : #include "comphelper/comphelperdllapi.h"
34 :
35 : //=========================================================================
36 : //= property helper classes
37 : //=========================================================================
38 :
39 : //.........................................................................
40 : namespace comphelper
41 : {
42 : //.........................................................................
43 :
44 : //==================================================================
45 : //= OPropertyStateHelper
46 : //==================================================================
47 : /// helper class for implementing property states
48 : class COMPHELPER_DLLPUBLIC OPropertyStateHelper :public ::cppu::OPropertySetHelper2
49 : ,public ::com::sun::star::beans::XPropertyState
50 : {
51 : public:
52 843 : OPropertyStateHelper(::cppu::OBroadcastHelper& rBHlp):OPropertySetHelper2(rBHlp) { }
53 : OPropertyStateHelper(::cppu::OBroadcastHelper& rBHlp,
54 : ::cppu::IEventNotificationHook *i_pFireEvents);
55 :
56 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& aType) throw(::com::sun::star::uno::RuntimeException);
57 :
58 : // XPropertyState
59 : virtual ::com::sun::star::beans::PropertyState SAL_CALL
60 : getPropertyState(const OUString& PropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
61 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState> SAL_CALL
62 : getPropertyStates(const ::com::sun::star::uno::Sequence< OUString >& aPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
63 : virtual void SAL_CALL
64 : setPropertyToDefault(const OUString& PropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
65 : virtual ::com::sun::star::uno::Any SAL_CALL
66 : getPropertyDefault(const OUString& aPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
67 :
68 : // access via handle
69 : virtual ::com::sun::star::beans::PropertyState getPropertyStateByHandle(sal_Int32 nHandle);
70 : virtual void setPropertyToDefaultByHandle(sal_Int32 nHandle);
71 : virtual ::com::sun::star::uno::Any getPropertyDefaultByHandle(sal_Int32 nHandle) const;
72 :
73 : protected:
74 : virtual ~OPropertyStateHelper();
75 :
76 : void firePropertyChange(sal_Int32 nHandle, const ::com::sun::star::uno::Any& aNewValue, const ::com::sun::star::uno::Any& aOldValue);
77 :
78 : protected:
79 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
80 : };
81 :
82 : //==================================================================
83 : //= OPropertyStateHelper
84 : //==================================================================
85 : class COMPHELPER_DLLPUBLIC OStatefulPropertySet :public ::cppu::OWeakObject
86 : ,public ::com::sun::star::lang::XTypeProvider
87 : ,public OMutexAndBroadcastHelper // order matters: before OPropertyStateHelper/OPropertySetHelper
88 : ,public OPropertyStateHelper
89 : {
90 : protected:
91 : OStatefulPropertySet();
92 : virtual ~OStatefulPropertySet();
93 :
94 : protected:
95 : DECLARE_XINTERFACE()
96 : DECLARE_XTYPEPROVIDER()
97 : };
98 :
99 : //.........................................................................
100 : } // namespace comphelper
101 : //.........................................................................
102 :
103 : #endif // _COMPHELPER_PROPERTY_STATE_HXX_
104 :
105 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|