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