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