xref: /AOO41X/main/ucbhelper/workben/myucp/myucp_contentcaps.cxx (revision ac9096f48ddc8269a54878c5b102c19157b971bd)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_ucbhelper.hxx"
26 
27 /**************************************************************************
28                                 TODO
29  **************************************************************************
30 
31  *************************************************************************/
32 
33 #include "com/sun/star/beans/Property.hpp"
34 #include "com/sun/star/beans/PropertyAttribute.hpp"
35 #include "com/sun/star/beans/PropertyValue.hpp"
36 #include "com/sun/star/ucb/CommandInfo.hpp"
37 #include "com/sun/star/uno/Sequence.hxx"
38 
39 #include "myucp_content.hxx"
40 
41 #ifdef IMPLEMENT_COMMAND_INSERT
42 #include "com/sun/star/ucb/InsertCommandArgument.hpp"
43 #endif
44 
45 #ifdef IMPLEMENT_COMMAND_OPEN
46 #include "com/sun/star/ucb/OpenCommandArgument2.hpp"
47 #endif
48 
49 using namespace com::sun::star;
50 
51 // @@@ Adjust namespace name.
52 using namespace myucp;
53 
54 //=========================================================================
55 //
56 // Content implementation.
57 //
58 //=========================================================================
59 
60 //=========================================================================
61 //
62 // IMPORTENT: If any property data ( name / type / ... ) are changed, then
63 //            Content::getPropertyValues(...) must be adapted too!
64 //
65 //=========================================================================
66 
67 // virtual
getProperties(const uno::Reference<ucb::XCommandEnvironment> &)68 uno::Sequence< beans::Property > Content::getProperties(
69     const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
70 {
71     // @@@ Add additional properties...
72 
73     // @@@ Note: If your data source supports adding/removing properties,
74     //           you should implement the interface XPropertyContainer
75     //           by yourself and supply your own logic here. The base class
76     //           uses the service "com.sun.star.ucb.Store" to maintain
77     //           Additional Core properties. But using server functionality
78     //           is preferred! In fact you should return a table conatining
79     //           even that dynamicly added properties.
80 
81 //  osl::Guard< osl::Mutex > aGuard( m_aMutex );
82 
83     //=================================================================
84     //
85     // Supported properties
86     //
87     //=================================================================
88 
89     #define PROPERTY_COUNT 4
90 
91     static beans::Property aPropertyInfoTable[] =
92     {
93         ///////////////////////////////////////////////////////////////
94         // Mandatory properties
95         ///////////////////////////////////////////////////////////////
96         beans::Property(
97             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
98             -1,
99             getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
100             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
101         ),
102         beans::Property(
103             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
104             -1,
105             getCppuBooleanType(),
106             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
107         ),
108         beans::Property(
109             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
110             -1,
111             getCppuBooleanType(),
112             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
113         ),
114         beans::Property(
115             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
116             -1,
117             getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
118             beans::PropertyAttribute::BOUND
119         )
120         ///////////////////////////////////////////////////////////////
121         // Optional standard properties
122         ///////////////////////////////////////////////////////////////
123 
124         ///////////////////////////////////////////////////////////////
125         // New properties
126         ///////////////////////////////////////////////////////////////
127     };
128     return uno::Sequence<
129             beans::Property >( aPropertyInfoTable, PROPERTY_COUNT );
130 }
131 
132 //=========================================================================
133 // virtual
getCommands(const uno::Reference<ucb::XCommandEnvironment> &)134 uno::Sequence< ucb::CommandInfo > Content::getCommands(
135     const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
136 {
137     // @@@ Add additional commands...
138 
139 //  osl::Guard< osl::Mutex > aGuard( m_aMutex );
140 
141     //=================================================================
142     //
143     // Supported commands
144     //
145     //=================================================================
146 
147     sal_uInt32 nCommandCount = 4;
148 #ifdef IMPLEMENT_COMMAND_DELETE
149     nCommandCount++;
150 #endif
151 #ifdef IMPLEMENT_COMMAND_INSERT
152     nCommandCount++;
153 #endif
154 #ifdef IMPLEMENT_COMMAND_OPEN
155     nCommandCount++;
156 #endif
157 
158     static const ucb::CommandInfo aCommandInfoTable[] =
159     {
160         ///////////////////////////////////////////////////////////////
161         // Mandatory commands
162         ///////////////////////////////////////////////////////////////
163         ucb::CommandInfo(
164             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
165             -1,
166             getCppuVoidType()
167         ),
168         ucb::CommandInfo(
169             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
170             -1,
171             getCppuVoidType()
172         ),
173         ucb::CommandInfo(
174             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
175             -1,
176             getCppuType(
177                 static_cast< uno::Sequence< beans::Property > * >( 0 ) )
178         ),
179         ucb::CommandInfo(
180             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
181             -1,
182             getCppuType(
183                 static_cast< uno::Sequence< beans::PropertyValue > * >( 0 ) )
184         )
185         ///////////////////////////////////////////////////////////////
186         // Optional standard commands
187         ///////////////////////////////////////////////////////////////
188 
189 #ifdef IMPLEMENT_COMMAND_DELETE
190         , ucb::CommandInfo(
191             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
192             -1,
193             getCppuBooleanType()
194         )
195 #endif
196 #ifdef IMPLEMENT_COMMAND_INSERT
197         , ucb::CommandInfo(
198             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
199             -1,
200             getCppuType(
201                 static_cast< ucb::InsertCommandArgument * >( 0 ) )
202         )
203 #endif
204 #ifdef IMPLEMENT_COMMAND_OPEN
205         , ucb::CommandInfo(
206             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
207             -1,
208             getCppuType( static_cast< ucb::OpenCommandArgument2 * >( 0 ) )
209         )
210 #endif
211         ///////////////////////////////////////////////////////////////
212         // New commands
213         ///////////////////////////////////////////////////////////////
214     };
215 
216     return uno::Sequence<
217         ucb::CommandInfo >( aCommandInfoTable, nCommandCount );
218 }
219 
220