xref: /AOO41X/main/ucbhelper/inc/ucbhelper/contentinfo.hxx (revision b3b486c3fa1b38c2de306d076387b46c94e4246f)
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 _UCBHELPER_CONTENTINFO_HXX
25 #define _UCBHELPER_CONTENTINFO_HXX
26 
27 #include <com/sun/star/ucb/XCommandInfo.hpp>
28 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/lang/XTypeProvider.hpp>
31 #include <com/sun/star/beans/XPropertySetInfo.hpp>
32 #include <cppuhelper/weak.hxx>
33 
34 #include "osl/mutex.hxx"
35 #include <ucbhelper/macros.hxx>
36 
37 namespace ucbhelper {
38 
39 //============================================================================
40 //
41 // class PropertySetInfo.
42 //
43 //============================================================================
44 
45 class ContentImplHelper;
46 
47 /**
48   * This class provides a propertyset info ( the complete implementation of
49   * the interface XPropertySetInfo ) for an object derived from class
50   * ucb::ContentImplHelper. The implementation takes care about Additional
51   * Core Properties that may have been added to the content.
52   */
53 class PropertySetInfo :
54                 public cppu::OWeakObject,
55                 public com::sun::star::lang::XTypeProvider,
56                 public com::sun::star::beans::XPropertySetInfo
57 {
58     com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
59                                 m_xSMgr;
60     com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >
61                                 m_xEnv;
62     com::sun::star::uno::Sequence< com::sun::star::beans::Property >*
63                                 m_pProps;
64     osl::Mutex                  m_aMutex;
65     ContentImplHelper*          m_pContent;
66 
67 private:
68     sal_Bool queryProperty( const rtl::OUString& rName,
69                             com::sun::star::beans::Property& rProp );
70 
71 public:
72     PropertySetInfo( const com::sun::star::uno::Reference<
73                         com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
74                      const com::sun::star::uno::Reference<
75                         com::sun::star::ucb::XCommandEnvironment >& rxEnv,
76                      ContentImplHelper* pContent );
77     virtual ~PropertySetInfo();
78 
79     // XInterface
80     XINTERFACE_DECL()
81 
82     // XTypeProvider
83     XTYPEPROVIDER_DECL()
84 
85     // XPropertySetInfo
86     virtual com::sun::star::uno::Sequence<
87                 com::sun::star::beans::Property > SAL_CALL
88     getProperties()
89         throw( com::sun::star::uno::RuntimeException );
90     virtual com::sun::star::beans::Property SAL_CALL
91     getPropertyByName( const rtl::OUString& aName )
92         throw( com::sun::star::beans::UnknownPropertyException,
93                com::sun::star::uno::RuntimeException );
94     virtual sal_Bool SAL_CALL
95     hasPropertyByName( const rtl::OUString& Name )
96         throw( com::sun::star::uno::RuntimeException );
97 
98     // Non-Interface methods.
99     void reset();
100 };
101 
102 //============================================================================
103 //
104 // class CommandProcessorInfo.
105 //
106 //============================================================================
107 
108 /**
109   * This class provides a command info ( the complete implementation of
110   * the interface XCommandInfo ) for an object derived from class
111   * ucb::ContentImplHelper.
112   */
113 class CommandProcessorInfo :
114                 public cppu::OWeakObject,
115                 public com::sun::star::lang::XTypeProvider,
116                 public com::sun::star::ucb::XCommandInfo
117 {
118     com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
119                                 m_xSMgr;
120     com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >
121                                 m_xEnv;
122     com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >*
123                                 m_pCommands;
124     osl::Mutex                  m_aMutex;
125     ContentImplHelper*          m_pContent;
126 
127 private:
128     sal_Bool queryCommand( const rtl::OUString& rName,
129                            com::sun::star::ucb::CommandInfo& rCommand );
130     sal_Bool queryCommand( sal_Int32 nHandle,
131                            com::sun::star::ucb::CommandInfo& rCommand );
132 
133 public:
134     CommandProcessorInfo( const com::sun::star::uno::Reference<
135                             com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
136                           const com::sun::star::uno::Reference<
137                             com::sun::star::ucb::XCommandEnvironment >& rxEnv,
138                          ContentImplHelper* pContent );
139     virtual ~CommandProcessorInfo();
140 
141     // XInterface
142     XINTERFACE_DECL()
143 
144     // XTypeProvider
145     XTYPEPROVIDER_DECL()
146 
147     // XCommandInfo
148     virtual com::sun::star::uno::Sequence<
149                 com::sun::star::ucb::CommandInfo > SAL_CALL
150     getCommands()
151         throw( com::sun::star::uno::RuntimeException );
152     virtual com::sun::star::ucb::CommandInfo SAL_CALL
153     getCommandInfoByName( const rtl::OUString& Name )
154         throw( com::sun::star::ucb::UnsupportedCommandException,
155         com::sun::star::uno::RuntimeException );
156     virtual com::sun::star::ucb::CommandInfo SAL_CALL
157     getCommandInfoByHandle( sal_Int32 Handle )
158         throw( com::sun::star::ucb::UnsupportedCommandException,
159         com::sun::star::uno::RuntimeException );
160     virtual sal_Bool SAL_CALL
161     hasCommandByName( const rtl::OUString& Name )
162         throw( com::sun::star::uno::RuntimeException );
163     virtual sal_Bool SAL_CALL
164     hasCommandByHandle( sal_Int32 Handle )
165         throw( com::sun::star::uno::RuntimeException );
166 
167     // Non-Interface methods.
168     void reset();
169 };
170 
171 } // namespace ucbhelper
172 
173 #endif /* !_UCBHELPER_CONTENTINFO_HXX */
174