1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmlhelp.hxx"
30 #include <com/sun/star/beans/Property.hpp>
31 #include <com/sun/star/beans/PropertyAttribute.hpp>
32 #include <com/sun/star/beans/PropertyValue.hpp>
33 #include <com/sun/star/ucb/CommandInfo.hpp>
34 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
35 #include <com/sun/star/uno/Sequence.hxx>
36 
37 #include "content.hxx"
38 
39 using namespace com::sun;
40 using namespace com::sun::star;
41 
42 using namespace chelp;
43 
44 // virtual
45 uno::Sequence< beans::Property > Content::getProperties(
46     const uno::Reference< star::ucb::XCommandEnvironment > & /*xEnv*/ )
47 {
48 	bool withMediaType = m_aURLParameter.isFile() || m_aURLParameter.isRoot();
49 	bool isModule = m_aURLParameter.isModule();
50 	bool isFile = m_aURLParameter.isFile();
51 
52 	sal_Int32 num = withMediaType ? 7 : 6;
53 	if( isModule ) num+=6;
54 	if( isFile )   num++;
55 
56 	uno::Sequence< beans::Property > props(num);
57 
58 	sal_Int32 idx = 0;
59 	props[idx++] =
60 		beans::Property(
61 			rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
62 			-1,
63 			getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
64 			beans::PropertyAttribute::BOUND
65             | beans::PropertyAttribute::READONLY );
66 
67 	props[idx++] =
68 		beans::Property(
69 			rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ),
70 			-1,
71 			getCppuBooleanType(),
72 			beans::PropertyAttribute::BOUND
73             | beans::PropertyAttribute::READONLY );
74 
75 	props[idx++] =
76 		beans::Property(
77 			rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsErrorDocument" ) ),
78 			-1,
79 			getCppuBooleanType(),
80 			beans::PropertyAttribute::BOUND
81             | beans::PropertyAttribute::READONLY );
82 
83 	props[idx++] =
84 		beans::Property(
85 			rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
86 			-1,
87 			getCppuBooleanType(),
88 			beans::PropertyAttribute::BOUND
89             | beans::PropertyAttribute::READONLY );
90 
91 	props[idx++] =
92 		beans::Property(
93 			rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
94 			-1,
95 			getCppuBooleanType(),
96 			beans::PropertyAttribute::BOUND
97             | beans::PropertyAttribute::READONLY );
98 
99 	props[idx++] =
100 		beans::Property(
101 			rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
102 			-1,
103 			getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
104 			beans::PropertyAttribute::BOUND
105             | beans::PropertyAttribute::READONLY );
106 
107 	if( withMediaType )
108 		props[idx++] =
109 			beans::Property(
110                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ),
111                 -1,
112                 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
113                 beans::PropertyAttribute::BOUND
114                 | beans::PropertyAttribute::READONLY );
115 
116 	if( isModule )
117 	{
118 		props[idx++] =
119 			beans::Property(
120                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Order" ) ),
121                 -1,
122                 getCppuType( static_cast< sal_Int32* >( 0 ) ),
123                 beans::PropertyAttribute::BOUND
124                 | beans::PropertyAttribute::READONLY );
125 
126 		props[idx++] =
127 			beans::Property(
128                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeywordList" ) ),
129                 -1,
130                 getCppuType(
131                     static_cast< const uno::Sequence< rtl::OUString >* >(
132                         0 ) ),
133                 beans::PropertyAttribute::BOUND
134                 | beans::PropertyAttribute::READONLY );
135 
136 		props[idx++] =
137 			beans::Property(
138                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "KeywordRef" ) ),
139                 -1,
140                 getCppuType(
141                     static_cast< const uno::Sequence< uno::Sequence< rtl::OUString > >* >( 0 ) ),
142                 beans::PropertyAttribute::BOUND
143                 | beans::PropertyAttribute::READONLY );
144 
145 		props[idx++] =
146 			beans::Property(
147                 rtl::OUString(
148                     RTL_CONSTASCII_USTRINGPARAM( "KeywordTitleForRef" ) ),
149                 -1,
150                 getCppuType(
151                     static_cast< const uno::Sequence< uno::Sequence< rtl::OUString > >* >( 0 ) ),
152                 beans::PropertyAttribute::BOUND
153                 | beans::PropertyAttribute::READONLY );
154 
155 		props[idx++] =
156 			beans::Property(
157                 rtl::OUString(
158                     RTL_CONSTASCII_USTRINGPARAM( "KeywordAnchorForRef" ) ),
159                 -1,
160                 getCppuType(
161                     static_cast< const uno::Sequence< uno::Sequence< rtl::OUString > >* >( 0 ) ),
162                 beans::PropertyAttribute::BOUND
163                 | beans::PropertyAttribute::READONLY );
164 
165 		props[idx++] =
166 			beans::Property(
167                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SearchScopes" ) ),
168                 -1,
169                 getCppuType(
170                     static_cast< const uno::Sequence< rtl::OUString >* >( 0 ) ),
171                 beans::PropertyAttribute::BOUND
172                 | beans::PropertyAttribute::READONLY );
173 	}
174 
175 	if( isFile )
176 	{
177 		props[idx++] =
178 			beans::Property(
179                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AnchorName" ) ),
180                 -1,
181                 getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
182                 beans::PropertyAttribute::BOUND
183                 | beans::PropertyAttribute::READONLY );
184 	}
185 
186 	return props;
187 }
188 
189 
190 
191 //=========================================================================
192 // virtual
193 uno::Sequence< star::ucb::CommandInfo > Content::getCommands(
194     const uno::Reference< star::ucb::XCommandEnvironment > & /*xEnv*/ )
195 {
196 //	osl::MutexGuard aGuard( m_aMutex );
197 
198 	//=================================================================
199 	//
200 	// Supported commands
201 	//
202 	//=================================================================
203 
204 #define COMMAND_COUNT 5
205 
206 	static const star::ucb::CommandInfo aCommandInfoTable[] =
207 	{
208 		///////////////////////////////////////////////////////////////
209 		// Required commands
210 		///////////////////////////////////////////////////////////////
211 		star::ucb::CommandInfo(
212 			rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
213 			-1,
214 			getCppuVoidType()
215 		),
216 		star::ucb::CommandInfo(
217 			rtl::OUString(
218                 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
219 			-1,
220 			getCppuVoidType()
221 		),
222 		star::ucb::CommandInfo(
223 			rtl::OUString(
224                 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
225 			-1,
226 			getCppuType(
227                 static_cast< uno::Sequence< beans::Property > * >( 0 ) )
228 		),
229 		star::ucb::CommandInfo(
230 			rtl::OUString(
231                 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
232 			-1,
233 			getCppuType(
234                 static_cast< uno::Sequence< beans::PropertyValue > * >( 0 ) )
235 		),
236 		star::ucb::CommandInfo(
237 			rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
238 			-1,
239 			getCppuType(
240                 static_cast< star::ucb::OpenCommandArgument2 * >( 0 ) )
241 		)
242 	};
243 
244 	return uno::Sequence< star::ucb::CommandInfo >(
245         aCommandInfoTable, COMMAND_COUNT );
246 }
247 
248