LCOV - code coverage report
Current view: top level - ucb/source/ucp/package - pkgcontentcaps.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 33 69 47.8 %
Date: 2014-04-11 Functions: 4 8 50.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10