1*2f86921cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2f86921cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2f86921cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2f86921cSAndrew Rist  * distributed with this work for additional information
6*2f86921cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2f86921cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2f86921cSAndrew Rist  * "License"); you may not use this file except in compliance
9*2f86921cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2f86921cSAndrew Rist  *
11*2f86921cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2f86921cSAndrew Rist  *
13*2f86921cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2f86921cSAndrew Rist  * software distributed under the License is distributed on an
15*2f86921cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2f86921cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2f86921cSAndrew Rist  * specific language governing permissions and limitations
18*2f86921cSAndrew Rist  * under the License.
19*2f86921cSAndrew Rist  *
20*2f86921cSAndrew Rist  *************************************************************/
21*2f86921cSAndrew Rist 
22*2f86921cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_ucb.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir /**************************************************************************
28cdf0e10cSrcweir 								TODO
29cdf0e10cSrcweir  **************************************************************************
30cdf0e10cSrcweir 
31cdf0e10cSrcweir  *************************************************************************/
32cdf0e10cSrcweir #include <com/sun/star/beans/Property.hpp>
33cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
34cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
35cdf0e10cSrcweir #include <com/sun/star/ucb/CommandInfo.hpp>
36cdf0e10cSrcweir #include <com/sun/star/ucb/InsertCommandArgument.hpp>
37cdf0e10cSrcweir #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
38cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
39cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp>
40cdf0e10cSrcweir #include <com/sun/star/ucb/TransferInfo.hpp>
41cdf0e10cSrcweir #include "odma_content.hxx"
42cdf0e10cSrcweir 
43cdf0e10cSrcweir using namespace com::sun::star;
44cdf0e10cSrcweir using namespace odma;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir //=========================================================================
47cdf0e10cSrcweir //
48cdf0e10cSrcweir // Content implementation.
49cdf0e10cSrcweir //
50cdf0e10cSrcweir //=========================================================================
51cdf0e10cSrcweir 
52cdf0e10cSrcweir //=========================================================================
53cdf0e10cSrcweir //
54cdf0e10cSrcweir // IMPORTENT: If any property data ( name / type / ... ) are changed, then
55cdf0e10cSrcweir //            Content::getPropertyValues(...) must be adapted too!
56cdf0e10cSrcweir //
57cdf0e10cSrcweir //=========================================================================
58cdf0e10cSrcweir 
59cdf0e10cSrcweir // virtual
getProperties(const uno::Reference<ucb::XCommandEnvironment> &)60cdf0e10cSrcweir uno::Sequence< beans::Property > Content::getProperties(
61cdf0e10cSrcweir     const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir 	// @@@ Add additional properties...
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	// @@@ Note: If your data source supports adding/removing properties,
66cdf0e10cSrcweir 	//           you should implement the interface XPropertyContainer
67cdf0e10cSrcweir 	//           by yourself and supply your own logic here. The base class
68cdf0e10cSrcweir 	//           uses the service "com.sun.star.ucb.Store" to maintain
69cdf0e10cSrcweir 	//           Additional Core properties. But using server functionality
70cdf0e10cSrcweir 	//           is preferred! In fact you should return a table conatining
71cdf0e10cSrcweir 	//           even that dynamicly added properties.
72cdf0e10cSrcweir 
73cdf0e10cSrcweir //	osl::Guard< osl::Mutex > aGuard( m_aMutex );
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	//=================================================================
76cdf0e10cSrcweir 	//
77cdf0e10cSrcweir 	// Supported properties
78cdf0e10cSrcweir 	//
79cdf0e10cSrcweir 	//=================================================================
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	#define PROPERTY_COUNT 10
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     static beans::Property aPropertyInfoTable[] =
84cdf0e10cSrcweir 	{
85cdf0e10cSrcweir 		///////////////////////////////////////////////////////////////
86cdf0e10cSrcweir 		// Required properties
87cdf0e10cSrcweir 		///////////////////////////////////////////////////////////////
88cdf0e10cSrcweir         beans::Property(
89cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
90cdf0e10cSrcweir 			-1,
91cdf0e10cSrcweir             getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
92cdf0e10cSrcweir             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
93cdf0e10cSrcweir 		),
94cdf0e10cSrcweir         beans::Property(
95cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
96cdf0e10cSrcweir 			-1,
97cdf0e10cSrcweir 			getCppuBooleanType(),
98cdf0e10cSrcweir             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
99cdf0e10cSrcweir 		),
100cdf0e10cSrcweir         beans::Property(
101cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
102cdf0e10cSrcweir 			-1,
103cdf0e10cSrcweir 			getCppuBooleanType(),
104cdf0e10cSrcweir             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
105cdf0e10cSrcweir 		),
106cdf0e10cSrcweir         beans::Property(
107cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
108cdf0e10cSrcweir 			-1,
109cdf0e10cSrcweir             getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
110cdf0e10cSrcweir             beans::PropertyAttribute::BOUND
111cdf0e10cSrcweir 		),
112cdf0e10cSrcweir 		///////////////////////////////////////////////////////////////
113cdf0e10cSrcweir 		// Optional standard properties
114cdf0e10cSrcweir 		///////////////////////////////////////////////////////////////
115cdf0e10cSrcweir 		beans::Property(
116cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ),
117cdf0e10cSrcweir 			-1,
118cdf0e10cSrcweir 			getCppuType(static_cast< const util::DateTime * >( 0 ) ),
119cdf0e10cSrcweir             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
120cdf0e10cSrcweir 		),
121cdf0e10cSrcweir 		beans::Property(
122cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ),
123cdf0e10cSrcweir 			-1,
124cdf0e10cSrcweir 			getCppuType(static_cast< const util::DateTime * >( 0 ) ),
125cdf0e10cSrcweir             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
126cdf0e10cSrcweir 		),
127cdf0e10cSrcweir 		beans::Property(
128cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ),
129cdf0e10cSrcweir 			-1,
130cdf0e10cSrcweir 			getCppuBooleanType(),
131cdf0e10cSrcweir             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY
132cdf0e10cSrcweir 		),
133cdf0e10cSrcweir 		///////////////////////////////////////////////////////////////
134cdf0e10cSrcweir 		// New properties
135cdf0e10cSrcweir 		///////////////////////////////////////////////////////////////
136cdf0e10cSrcweir 		beans::Property(
137cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Author" ) ),
138cdf0e10cSrcweir 			-1,
139cdf0e10cSrcweir             getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
140cdf0e10cSrcweir             beans::PropertyAttribute::BOUND
141cdf0e10cSrcweir 		),
142cdf0e10cSrcweir 		beans::Property(
143cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subject" ) ),
144cdf0e10cSrcweir 			-1,
145cdf0e10cSrcweir             getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
146cdf0e10cSrcweir             beans::PropertyAttribute::BOUND
147cdf0e10cSrcweir 		),
148cdf0e10cSrcweir 		beans::Property(
149cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Keywords" ) ),
150cdf0e10cSrcweir 			-1,
151cdf0e10cSrcweir             getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
152cdf0e10cSrcweir             beans::PropertyAttribute::BOUND
153cdf0e10cSrcweir 		)
154cdf0e10cSrcweir 	};
155cdf0e10cSrcweir     return uno::Sequence<
156cdf0e10cSrcweir             beans::Property >( aPropertyInfoTable, PROPERTY_COUNT );
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir //=========================================================================
160cdf0e10cSrcweir // virtual
getCommands(const uno::Reference<ucb::XCommandEnvironment> &)161cdf0e10cSrcweir uno::Sequence< ucb::CommandInfo > Content::getCommands(
162cdf0e10cSrcweir     const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir 	// @@@ Add additional commands...
165cdf0e10cSrcweir 
166cdf0e10cSrcweir //	osl::Guard< osl::Mutex > aGuard( m_aMutex );
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 	//=================================================================
169cdf0e10cSrcweir 	//
170cdf0e10cSrcweir 	// Supported commands
171cdf0e10cSrcweir 	//
172cdf0e10cSrcweir 	//=================================================================
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	#define COMMAND_COUNT 8
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     static ucb::CommandInfo aCommandInfoTable[] =
177cdf0e10cSrcweir 	{
178cdf0e10cSrcweir 		///////////////////////////////////////////////////////////////
179cdf0e10cSrcweir 		// Required commands
180cdf0e10cSrcweir 		///////////////////////////////////////////////////////////////
181cdf0e10cSrcweir         ucb::CommandInfo(
182cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
183cdf0e10cSrcweir 			-1,
184cdf0e10cSrcweir 			getCppuVoidType()
185cdf0e10cSrcweir 		),
186cdf0e10cSrcweir         ucb::CommandInfo(
187cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
188cdf0e10cSrcweir 			-1,
189cdf0e10cSrcweir 			getCppuVoidType()
190cdf0e10cSrcweir 		),
191cdf0e10cSrcweir         ucb::CommandInfo(
192cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
193cdf0e10cSrcweir 			-1,
194cdf0e10cSrcweir             getCppuType(
195cdf0e10cSrcweir                 static_cast< uno::Sequence< beans::Property > * >( 0 ) )
196cdf0e10cSrcweir 		),
197cdf0e10cSrcweir         ucb::CommandInfo(
198cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
199cdf0e10cSrcweir 			-1,
200cdf0e10cSrcweir             getCppuType(
201cdf0e10cSrcweir                 static_cast< uno::Sequence< beans::PropertyValue > * >( 0 ) )
202cdf0e10cSrcweir 		),
203cdf0e10cSrcweir 		///////////////////////////////////////////////////////////////
204cdf0e10cSrcweir 		// Optional standard commands
205cdf0e10cSrcweir 		///////////////////////////////////////////////////////////////
206cdf0e10cSrcweir /*
207cdf0e10cSrcweir         ucb::CommandInfo(
208cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
209cdf0e10cSrcweir 			-1,
210cdf0e10cSrcweir 			getCppuBooleanType()
211cdf0e10cSrcweir 		),
212cdf0e10cSrcweir */
213cdf0e10cSrcweir         ucb::CommandInfo(
214cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
215cdf0e10cSrcweir 			-1,
216cdf0e10cSrcweir             getCppuType(
217cdf0e10cSrcweir                 static_cast< ucb::InsertCommandArgument * >( 0 ) )
218cdf0e10cSrcweir 		),
219cdf0e10cSrcweir         ucb::CommandInfo(
220cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
221cdf0e10cSrcweir 			-1,
222cdf0e10cSrcweir             getCppuType( static_cast< ucb::OpenCommandArgument2 * >( 0 ) )
223cdf0e10cSrcweir 		),
224cdf0e10cSrcweir 		ucb::CommandInfo(
225cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "close" ) ),
226cdf0e10cSrcweir 			-1,
227cdf0e10cSrcweir             getCppuVoidType( )
228cdf0e10cSrcweir 		),
229cdf0e10cSrcweir 		ucb::CommandInfo(
230cdf0e10cSrcweir             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
231cdf0e10cSrcweir 			-1,
232cdf0e10cSrcweir             getCppuType( static_cast< ucb::TransferInfo * >( 0 ) )
233cdf0e10cSrcweir 		)
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 		///////////////////////////////////////////////////////////////
236cdf0e10cSrcweir 		// New commands
237cdf0e10cSrcweir 		///////////////////////////////////////////////////////////////
238cdf0e10cSrcweir 	};
239cdf0e10cSrcweir 
240cdf0e10cSrcweir     return uno::Sequence<
241cdf0e10cSrcweir             ucb::CommandInfo >( aCommandInfoTable, COMMAND_COUNT );
242cdf0e10cSrcweir }
243cdf0e10cSrcweir 
244