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