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_ucb.hxx" 30 31 /************************************************************************** 32 TODO 33 ************************************************************************** 34 35 Props/Commands: 36 37 rootfolder folder stream 38 --------------------------------------------- 39 ContentType r r r 40 IsDocument r r r 41 IsFolder r r r 42 MediaType (w) (w) w 43 Title r w w 44 Size - - r 45 CreatableContentsInfo r r r 46 Compressed - - w 47 Encrypted - - w 48 HasEncryptedEntries r - - 49 50 getCommandInfo x x x 51 getPropertySetInfo x x x 52 getPropertyValues x x x 53 setPropertyValues x x x 54 insert - x x 55 delete - x x 56 open x x x 57 transfer x x - 58 flush x x - 59 createNewContent x x - 60 61 *************************************************************************/ 62 #include <com/sun/star/beans/Property.hpp> 63 #include <com/sun/star/beans/PropertyAttribute.hpp> 64 #include <com/sun/star/beans/PropertyValue.hpp> 65 #include <com/sun/star/ucb/CommandInfo.hpp> 66 #include <com/sun/star/ucb/OpenCommandArgument2.hpp> 67 #include <com/sun/star/ucb/TransferInfo.hpp> 68 #include <com/sun/star/uno/Sequence.hxx> 69 #include "pkgcontent.hxx" 70 71 using namespace com::sun::star; 72 using namespace package_ucp; 73 74 //========================================================================= 75 // 76 // Content implementation. 77 // 78 //========================================================================= 79 80 #define MAKEPROPSEQUENCE( a ) \ 81 uno::Sequence< beans::Property >( a, sizeof( a ) / sizeof( a[ 0 ] ) ) 82 83 #define MAKECMDSEQUENCE( a ) \ 84 uno::Sequence< ucb::CommandInfo >( a, sizeof( a ) / sizeof( a[ 0 ] ) ) 85 86 //========================================================================= 87 // 88 // IMPORTENT: If any property data ( name / type / ... ) are changed, then 89 // Content::getPropertyValues(...) must be adapted too! 90 // 91 //========================================================================= 92 93 // virtual 94 uno::Sequence< beans::Property > Content::getProperties( 95 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ ) 96 { 97 osl::Guard< osl::Mutex > aGuard( m_aMutex ); 98 99 if ( isFolder() ) 100 { 101 if ( m_aUri.isRootFolder() ) 102 { 103 //================================================================= 104 // 105 // Root Folder: Supported properties 106 // 107 //================================================================= 108 109 static const beans::Property aRootFolderPropertyInfoTable[] = 110 { 111 /////////////////////////////////////////////////////////////// 112 // Required properties 113 /////////////////////////////////////////////////////////////// 114 beans::Property( 115 rtl::OUString( 116 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), 117 -1, 118 getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 119 beans::PropertyAttribute::BOUND 120 | beans::PropertyAttribute::READONLY 121 ), 122 beans::Property( 123 rtl::OUString( 124 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), 125 -1, 126 getCppuBooleanType(), 127 beans::PropertyAttribute::BOUND 128 | beans::PropertyAttribute::READONLY 129 ), 130 beans::Property( 131 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), 132 -1, 133 getCppuBooleanType(), 134 beans::PropertyAttribute::BOUND 135 | beans::PropertyAttribute::READONLY 136 ), 137 beans::Property( 138 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), 139 -1, 140 getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 141 beans::PropertyAttribute::BOUND 142 | beans::PropertyAttribute::READONLY 143 ), 144 /////////////////////////////////////////////////////////////// 145 // Optional standard properties 146 /////////////////////////////////////////////////////////////// 147 beans::Property( 148 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), 149 -1, 150 getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 151 beans::PropertyAttribute::BOUND 152 ), 153 beans::Property( 154 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 155 "CreatableContentsInfo" ) ), 156 -1, 157 getCppuType( static_cast< 158 const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), 159 beans::PropertyAttribute::BOUND 160 | beans::PropertyAttribute::READONLY 161 ), 162 /////////////////////////////////////////////////////////////// 163 // New properties 164 /////////////////////////////////////////////////////////////// 165 beans::Property( 166 rtl::OUString( 167 RTL_CONSTASCII_USTRINGPARAM( "HasEncryptedEntries" ) ), 168 -1, 169 getCppuBooleanType(), 170 beans::PropertyAttribute::BOUND 171 | beans::PropertyAttribute::READONLY 172 ) 173 }; 174 return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable ); 175 } 176 else 177 { 178 //================================================================= 179 // 180 // Folder: Supported properties 181 // 182 //================================================================= 183 184 static const beans::Property aFolderPropertyInfoTable[] = 185 { 186 /////////////////////////////////////////////////////////////// 187 // Required properties 188 /////////////////////////////////////////////////////////////// 189 beans::Property( 190 rtl::OUString( 191 RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), 192 -1, 193 getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 194 beans::PropertyAttribute::BOUND 195 | beans::PropertyAttribute::READONLY 196 ), 197 beans::Property( 198 rtl::OUString( 199 RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), 200 -1, 201 getCppuBooleanType(), 202 beans::PropertyAttribute::BOUND 203 | beans::PropertyAttribute::READONLY 204 ), 205 beans::Property( 206 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), 207 -1, 208 getCppuBooleanType(), 209 beans::PropertyAttribute::BOUND 210 | beans::PropertyAttribute::READONLY 211 ), 212 beans::Property( 213 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), 214 -1, 215 getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 216 beans::PropertyAttribute::BOUND 217 ), 218 /////////////////////////////////////////////////////////////// 219 // Optional standard properties 220 /////////////////////////////////////////////////////////////// 221 beans::Property( 222 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), 223 -1, 224 getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 225 beans::PropertyAttribute::BOUND 226 ), 227 beans::Property( 228 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 229 "CreatableContentsInfo" ) ), 230 -1, 231 getCppuType( static_cast< 232 const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), 233 beans::PropertyAttribute::BOUND 234 | beans::PropertyAttribute::READONLY 235 ) 236 /////////////////////////////////////////////////////////////// 237 // New properties 238 /////////////////////////////////////////////////////////////// 239 }; 240 return MAKEPROPSEQUENCE( aFolderPropertyInfoTable ); 241 } 242 } 243 else 244 { 245 //================================================================= 246 // 247 // Stream: Supported properties 248 // 249 //================================================================= 250 251 static const beans::Property aStreamPropertyInfoTable[] = 252 { 253 /////////////////////////////////////////////////////////////// 254 // Required properties 255 /////////////////////////////////////////////////////////////// 256 beans::Property( 257 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ), 258 -1, 259 getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 260 beans::PropertyAttribute::BOUND 261 | beans::PropertyAttribute::READONLY 262 ), 263 beans::Property( 264 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ), 265 -1, 266 getCppuBooleanType(), 267 beans::PropertyAttribute::BOUND 268 | beans::PropertyAttribute::READONLY 269 ), 270 beans::Property( 271 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ), 272 -1, 273 getCppuBooleanType(), 274 beans::PropertyAttribute::BOUND 275 | beans::PropertyAttribute::READONLY 276 ), 277 beans::Property( 278 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), 279 -1, 280 getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 281 beans::PropertyAttribute::BOUND 282 ), 283 /////////////////////////////////////////////////////////////// 284 // Optional standard properties 285 /////////////////////////////////////////////////////////////// 286 beans::Property( 287 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), 288 -1, 289 getCppuType( static_cast< const rtl::OUString * >( 0 ) ), 290 beans::PropertyAttribute::BOUND 291 ), 292 beans::Property( 293 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ), 294 -1, 295 getCppuType( static_cast< const sal_Int64 * >( 0 ) ), 296 beans::PropertyAttribute::BOUND 297 | beans::PropertyAttribute::READONLY 298 ), 299 beans::Property( 300 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 301 "CreatableContentsInfo" ) ), 302 -1, 303 getCppuType( static_cast< 304 const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), 305 beans::PropertyAttribute::BOUND 306 | beans::PropertyAttribute::READONLY 307 ), 308 /////////////////////////////////////////////////////////////// 309 // New properties 310 /////////////////////////////////////////////////////////////// 311 beans::Property( 312 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Compressed" ) ), 313 -1, 314 getCppuBooleanType(), 315 beans::PropertyAttribute::BOUND 316 ), 317 beans::Property( 318 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Encrypted" ) ), 319 -1, 320 getCppuBooleanType(), 321 beans::PropertyAttribute::BOUND 322 ) 323 }; 324 return MAKEPROPSEQUENCE( aStreamPropertyInfoTable ); 325 } 326 } 327 328 //========================================================================= 329 // virtual 330 uno::Sequence< ucb::CommandInfo > Content::getCommands( 331 const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ ) 332 { 333 osl::Guard< osl::Mutex > aGuard( m_aMutex ); 334 335 if ( isFolder() ) 336 { 337 if ( m_aUri.isRootFolder() ) 338 { 339 //================================================================= 340 // 341 // Root Folder: Supported commands 342 // 343 //================================================================= 344 345 static const ucb::CommandInfo aRootFolderCommandInfoTable[] = 346 { 347 /////////////////////////////////////////////////////////// 348 // Required commands 349 /////////////////////////////////////////////////////////// 350 ucb::CommandInfo( 351 rtl::OUString( 352 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ), 353 -1, 354 getCppuVoidType() 355 ), 356 ucb::CommandInfo( 357 rtl::OUString( 358 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ), 359 -1, 360 getCppuVoidType() 361 ), 362 ucb::CommandInfo( 363 rtl::OUString( 364 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ), 365 -1, 366 getCppuType( 367 static_cast< 368 uno::Sequence< beans::Property > * >( 0 ) ) 369 ), 370 ucb::CommandInfo( 371 rtl::OUString( 372 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ), 373 -1, 374 getCppuType( 375 static_cast< 376 uno::Sequence< beans::PropertyValue > * >( 0 ) ) 377 ), 378 /////////////////////////////////////////////////////////// 379 // Optional standard commands 380 /////////////////////////////////////////////////////////// 381 ucb::CommandInfo( 382 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ), 383 -1, 384 getCppuType( 385 static_cast< ucb::OpenCommandArgument2 * >( 0 ) ) 386 ), 387 ucb::CommandInfo( 388 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ), 389 -1, 390 getCppuType( 391 static_cast< ucb::TransferInfo * >( 0 ) ) 392 ), 393 ucb::CommandInfo( 394 rtl::OUString( 395 RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ), 396 -1, 397 getCppuType( static_cast< ucb::ContentInfo * >( 0 ) ) 398 ), 399 /////////////////////////////////////////////////////////// 400 // New commands 401 /////////////////////////////////////////////////////////// 402 ucb::CommandInfo( 403 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "flush" ) ), 404 -1, 405 getCppuVoidType() 406 ) 407 }; 408 409 return MAKECMDSEQUENCE( aRootFolderCommandInfoTable ); 410 } 411 else 412 { 413 //================================================================= 414 // 415 // Folder: Supported commands 416 // 417 //================================================================= 418 419 static const ucb::CommandInfo aFolderCommandInfoTable[] = 420 { 421 /////////////////////////////////////////////////////////// 422 // Required commands 423 /////////////////////////////////////////////////////////// 424 ucb::CommandInfo( 425 rtl::OUString( 426 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ), 427 -1, 428 getCppuVoidType() 429 ), 430 ucb::CommandInfo( 431 rtl::OUString( 432 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ), 433 -1, 434 getCppuVoidType() 435 ), 436 ucb::CommandInfo( 437 rtl::OUString( 438 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ), 439 -1, 440 getCppuType( 441 static_cast< 442 uno::Sequence< beans::Property > * >( 0 ) ) 443 ), 444 ucb::CommandInfo( 445 rtl::OUString( 446 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ), 447 -1, 448 getCppuType( 449 static_cast< 450 uno::Sequence< beans::PropertyValue > * >( 0 ) ) 451 ), 452 /////////////////////////////////////////////////////////// 453 // Optional standard commands 454 /////////////////////////////////////////////////////////// 455 ucb::CommandInfo( 456 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ), 457 -1, 458 getCppuBooleanType() 459 ), 460 ucb::CommandInfo( 461 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ), 462 -1, 463 getCppuVoidType() 464 ), 465 ucb::CommandInfo( 466 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ), 467 -1, 468 getCppuType( 469 static_cast< ucb::OpenCommandArgument2 * >( 0 ) ) 470 ), 471 ucb::CommandInfo( 472 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ), 473 -1, 474 getCppuType( 475 static_cast< ucb::TransferInfo * >( 0 ) ) 476 ), 477 ucb::CommandInfo( 478 rtl::OUString( 479 RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ), 480 -1, 481 getCppuType( static_cast< ucb::ContentInfo * >( 0 ) ) 482 ), 483 /////////////////////////////////////////////////////////// 484 // New commands 485 /////////////////////////////////////////////////////////// 486 ucb::CommandInfo( 487 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "flush" ) ), 488 -1, 489 getCppuVoidType() 490 ) 491 }; 492 493 return MAKECMDSEQUENCE( aFolderCommandInfoTable ); 494 } 495 } 496 else 497 { 498 //================================================================= 499 // 500 // Stream: Supported commands 501 // 502 //================================================================= 503 504 static const ucb::CommandInfo aStreamCommandInfoTable[] = 505 { 506 /////////////////////////////////////////////////////////////// 507 // Required commands 508 /////////////////////////////////////////////////////////////// 509 ucb::CommandInfo( 510 rtl::OUString( 511 RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ), 512 -1, 513 getCppuVoidType() 514 ), 515 ucb::CommandInfo( 516 rtl::OUString( 517 RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ), 518 -1, 519 getCppuVoidType() 520 ), 521 ucb::CommandInfo( 522 rtl::OUString( 523 RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ), 524 -1, 525 getCppuType( 526 static_cast< uno::Sequence< beans::Property > * >( 0 ) ) 527 ), 528 ucb::CommandInfo( 529 rtl::OUString( 530 RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ), 531 -1, 532 getCppuType( 533 static_cast< 534 uno::Sequence< beans::PropertyValue > * >( 0 ) ) 535 ), 536 /////////////////////////////////////////////////////////////// 537 // Optional standard commands 538 /////////////////////////////////////////////////////////////// 539 ucb::CommandInfo( 540 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ), 541 -1, 542 getCppuBooleanType() 543 ), 544 ucb::CommandInfo( 545 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ), 546 -1, 547 getCppuVoidType() 548 ), 549 ucb::CommandInfo( 550 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ), 551 -1, 552 getCppuType( 553 static_cast< ucb::OpenCommandArgument2 * >( 0 ) ) 554 ) 555 /////////////////////////////////////////////////////////////// 556 // New commands 557 /////////////////////////////////////////////////////////////// 558 }; 559 560 return MAKECMDSEQUENCE( aStreamCommandInfoTable ); 561 } 562 } 563