LCOV - code coverage report
Current view: top level - ucb/source/ucp/webdav - webdavcontentcaps.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 206 0.0 %
Date: 2012-08-25 Functions: 0 3 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 440 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : /**************************************************************************
      30                 :            :                                TODO
      31                 :            :  **************************************************************************
      32                 :            : 
      33                 :            :  *************************************************************************/
      34                 :            : 
      35                 :            : #include <set>
      36                 :            : #include <com/sun/star/beans/Property.hpp>
      37                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      38                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      39                 :            : #include <com/sun/star/ucb/CommandInfo.hpp>
      40                 :            : #include <com/sun/star/ucb/ContentInfo.hpp>
      41                 :            : #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
      42                 :            : #include <com/sun/star/ucb/InsertCommandArgument.hpp>
      43                 :            : #include <com/sun/star/ucb/PostCommandArgument2.hpp>
      44                 :            : #include <com/sun/star/ucb/TransferInfo.hpp>
      45                 :            : #include <com/sun/star/uno/Sequence.hxx>
      46                 :            : #include <com/sun/star/util/DateTime.hpp>
      47                 :            : #include <com/sun/star/ucb/Link.hpp>
      48                 :            : #include <com/sun/star/ucb/Lock.hpp>
      49                 :            : #include <com/sun/star/ucb/LockEntry.hpp>
      50                 :            : #include "webdavcontent.hxx"
      51                 :            : #include "webdavprovider.hxx"
      52                 :            : #include "DAVSession.hxx"
      53                 :            : #include "ContentProperties.hxx"
      54                 :            : 
      55                 :            : using namespace com::sun::star;
      56                 :            : using namespace webdav_ucp;
      57                 :            : 
      58                 :            : //=========================================================================
      59                 :            : //
      60                 :            : // ContentProvider implementation.
      61                 :            : //
      62                 :            : //=========================================================================
      63                 :            : 
      64                 :          0 : bool ContentProvider::getProperty(
      65                 :            :         const rtl::OUString & rPropName, beans::Property & rProp, bool bStrict )
      66                 :            : {
      67         [ #  # ]:          0 :     if ( !m_pProps )
      68                 :            :     {
      69         [ #  # ]:          0 :         osl::MutexGuard aGuard( m_aMutex );
      70         [ #  # ]:          0 :         if ( !m_pProps )
      71                 :            :         {
      72 [ #  # ][ #  # ]:          0 :             m_pProps = new PropertyMap;
      73                 :            : 
      74                 :            :             //////////////////////////////////////////////////////////////
      75                 :            :             // Fill map of known properties...
      76                 :            :             //////////////////////////////////////////////////////////////
      77                 :            : 
      78                 :            :             // Mandatory UCB properties.
      79                 :            :             m_pProps->insert(
      80                 :            :                 beans::Property(
      81                 :            :                     rtl::OUString(
      82                 :            :                         RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ),
      83                 :            :                     -1,
      84         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
      85                 :            :                     beans::PropertyAttribute::BOUND
      86 [ #  # ][ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
      87                 :            : 
      88                 :            :             m_pProps->insert(
      89                 :            :                 beans::Property(
      90                 :            :                     rtl::OUString(
      91                 :            :                         RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ),
      92                 :            :                     -1,
      93         [ #  # ]:          0 :                     getCppuBooleanType(),
      94                 :            :                     beans::PropertyAttribute::BOUND
      95 [ #  # ][ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
      96                 :            : 
      97                 :            :             m_pProps->insert(
      98                 :            :                 beans::Property(
      99                 :            :                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ),
     100                 :            :                     -1,
     101         [ #  # ]:          0 :                     getCppuBooleanType(),
     102                 :            :                     beans::PropertyAttribute::BOUND
     103 [ #  # ][ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     104                 :            : 
     105                 :            :             m_pProps->insert(
     106                 :            :                 beans::Property(
     107                 :            :                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ),
     108                 :            :                     -1,
     109         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
     110 [ #  # ][ #  # ]:          0 :                     beans::PropertyAttribute::BOUND ) );
     111                 :            : 
     112                 :            :             // Optional UCB properties.
     113                 :            : 
     114                 :            :             m_pProps->insert(
     115                 :            :                 beans::Property(
     116                 :            :                     rtl::OUString(
     117                 :            :                         RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ),
     118                 :            :                     -1,
     119         [ #  # ]:          0 :                     getCppuType( static_cast< const util::DateTime * >( 0 ) ),
     120                 :            :                     beans::PropertyAttribute::BOUND
     121 [ #  # ][ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     122                 :            : 
     123                 :            :             m_pProps->insert(
     124                 :            :                 beans::Property(
     125                 :            :                     rtl::OUString(
     126                 :            :                         RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ),
     127                 :            :                     -1,
     128         [ #  # ]:          0 :                     getCppuType( static_cast< const util::DateTime * >( 0 ) ),
     129                 :            :                     beans::PropertyAttribute::BOUND
     130 [ #  # ][ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     131                 :            : 
     132                 :            :             m_pProps->insert(
     133                 :            :                 beans::Property(
     134                 :            :                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ),
     135                 :            :                     -1,
     136         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
     137                 :            :                     beans::PropertyAttribute::BOUND
     138 [ #  # ][ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     139                 :            : 
     140                 :            :             m_pProps->insert(
     141                 :            :                 beans::Property(
     142                 :            :                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ),
     143                 :            :                     -1,
     144         [ #  # ]:          0 :                     getCppuType( static_cast< const sal_Int64 * >( 0 ) ),
     145                 :            :                     beans::PropertyAttribute::BOUND
     146 [ #  # ][ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     147                 :            : 
     148                 :            :             m_pProps->insert(
     149                 :            :                 beans::Property(
     150                 :            :                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BaseURI" ) ),
     151                 :            :                     -1,
     152         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
     153                 :            :                     beans::PropertyAttribute::BOUND
     154 [ #  # ][ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     155                 :            : 
     156                 :            :             m_pProps->insert(
     157                 :            :                 beans::Property(
     158                 :            :                     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
     159                 :            :                         "CreatableContentsInfo" ) ),
     160                 :            :                     -1,
     161                 :            :                     getCppuType( static_cast<
     162         [ #  # ]:          0 :                         const uno::Sequence< ucb::ContentInfo > * >( 0 ) ),
     163                 :            :                     beans::PropertyAttribute::BOUND
     164 [ #  # ][ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     165                 :            : 
     166                 :            :             // Standard DAV properties.
     167                 :            : 
     168                 :            :             m_pProps->insert(
     169                 :            :                 beans::Property(
     170                 :            :                     DAVProperties::CREATIONDATE,
     171                 :            :                     -1,
     172         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
     173                 :            :                     beans::PropertyAttribute::BOUND
     174         [ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     175                 :            : 
     176                 :            :             m_pProps->insert(
     177                 :            :                 beans::Property(
     178                 :            :                     DAVProperties::DISPLAYNAME,
     179                 :            :                     -1,
     180         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
     181         [ #  # ]:          0 :                     beans::PropertyAttribute::BOUND ) );
     182                 :            : 
     183                 :            :             m_pProps->insert(
     184                 :            :                 beans::Property(
     185                 :            :                     DAVProperties::GETCONTENTLANGUAGE,
     186                 :            :                     -1,
     187         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
     188                 :            :                     beans::PropertyAttribute::BOUND
     189         [ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     190                 :            : 
     191                 :            :             m_pProps->insert(
     192                 :            :                 beans::Property(
     193                 :            :                     DAVProperties::GETCONTENTLENGTH,
     194                 :            :                     -1,
     195         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
     196                 :            :                     beans::PropertyAttribute::BOUND
     197         [ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     198                 :            : 
     199                 :            :             m_pProps->insert(
     200                 :            :                 beans::Property(
     201                 :            :                     DAVProperties::GETCONTENTTYPE ,
     202                 :            :                     -1,
     203         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
     204                 :            :                     beans::PropertyAttribute::BOUND
     205         [ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     206                 :            : 
     207                 :            :             m_pProps->insert(
     208                 :            :                 beans::Property(
     209                 :            :                     DAVProperties::GETETAG,
     210                 :            :                     -1,
     211         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
     212                 :            :                     beans::PropertyAttribute::BOUND
     213         [ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     214                 :            : 
     215                 :            :             m_pProps->insert(
     216                 :            :                 beans::Property(
     217                 :            :                     DAVProperties::GETLASTMODIFIED,
     218                 :            :                     -1,
     219         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
     220                 :            :                     beans::PropertyAttribute::BOUND
     221         [ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     222                 :            : 
     223                 :            :             m_pProps->insert(
     224                 :            :                 beans::Property(
     225                 :            :                     DAVProperties::LOCKDISCOVERY,
     226                 :            :                     -1,
     227                 :            :                     getCppuType( static_cast<
     228         [ #  # ]:          0 :                                     const uno::Sequence< ucb::Lock > * >( 0 ) ),
     229                 :            :                     beans::PropertyAttribute::BOUND
     230         [ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     231                 :            : 
     232                 :            :             m_pProps->insert(
     233                 :            :                 beans::Property(
     234                 :            :                     DAVProperties::RESOURCETYPE,
     235                 :            :                     -1,
     236         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
     237                 :            :                     beans::PropertyAttribute::BOUND
     238         [ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     239                 :            : 
     240                 :            :             m_pProps->insert(
     241                 :            :                 beans::Property(
     242                 :            :                     DAVProperties::SOURCE,
     243                 :            :                     -1,
     244                 :            :                     getCppuType( static_cast<
     245         [ #  # ]:          0 :                                     const uno::Sequence< ucb::Link > * >( 0 ) ),
     246         [ #  # ]:          0 :                     beans::PropertyAttribute::BOUND ) );
     247                 :            : 
     248                 :            :             m_pProps->insert(
     249                 :            :                 beans::Property(
     250                 :            :                     DAVProperties::SUPPORTEDLOCK,
     251                 :            :                     -1,
     252                 :            :                     getCppuType( static_cast<
     253                 :            :                                     const uno::Sequence<
     254         [ #  # ]:          0 :                                         ucb::LockEntry > * >( 0 ) ),
     255                 :            :                     beans::PropertyAttribute::BOUND
     256         [ #  # ]:          0 :                         | beans::PropertyAttribute::READONLY ) );
     257                 :            : 
     258                 :            :             m_pProps->insert(
     259                 :            :                 beans::Property(
     260                 :            :                     DAVProperties::EXECUTABLE,
     261                 :            :                     -1,
     262         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
     263         [ #  # ]:          0 :                     beans::PropertyAttribute::BOUND ) );
     264         [ #  # ]:          0 :         }
     265                 :            :     }
     266                 :            : 
     267                 :            :     //////////////////////////////////////////////////////////////
     268                 :            :     // Lookup property.
     269                 :            :     //////////////////////////////////////////////////////////////
     270                 :            : 
     271                 :          0 :     beans::Property aProp;
     272                 :          0 :     aProp.Name = rPropName;
     273         [ #  # ]:          0 :     const PropertyMap::const_iterator it = m_pProps->find( aProp );
     274 [ #  # ][ #  # ]:          0 :     if ( it != m_pProps->end() )
     275                 :            :     {
     276         [ #  # ]:          0 :         rProp = (*it);
     277                 :            :     }
     278                 :            :     else
     279                 :            :     {
     280         [ #  # ]:          0 :         if ( bStrict )
     281                 :          0 :             return false;
     282                 :            : 
     283                 :            :         // All unknown props are treated as:
     284                 :            :         rProp = beans::Property(
     285                 :            :                     rPropName,
     286                 :            :                     - 1,
     287         [ #  # ]:          0 :                     getCppuType( static_cast< const rtl::OUString * >( 0 ) ),
     288                 :          0 :                     beans::PropertyAttribute::BOUND );
     289                 :            :     }
     290                 :            : 
     291                 :          0 :     return true;
     292                 :            : }
     293                 :            : 
     294                 :            : //=========================================================================
     295                 :            : //
     296                 :            : // Content implementation.
     297                 :            : //
     298                 :            : //=========================================================================
     299                 :            : 
     300                 :            : // virtual
     301                 :          0 : uno::Sequence< beans::Property > Content::getProperties(
     302                 :            :     const uno::Reference< ucb::XCommandEnvironment > & xEnv )
     303                 :            : {
     304                 :            :     sal_Bool bTransient;
     305                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     306                 :          0 :     std::auto_ptr< DAVResourceAccess > xResAccess;
     307                 :          0 :     std::auto_ptr< ContentProperties > xCachedProps;
     308                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
     309                 :          0 :     rtl::Reference< ContentProvider >  xProvider;
     310                 :            : 
     311                 :            :     {
     312         [ #  # ]:          0 :         osl::Guard< osl::Mutex > aGuard( m_aMutex );
     313                 :            : 
     314                 :          0 :         bTransient = m_bTransient;
     315 [ #  # ][ #  # ]:          0 :         xResAccess.reset( new DAVResourceAccess( *m_xResAccess.get() ) );
     316         [ #  # ]:          0 :         if ( m_xCachedProps.get() )
     317                 :            :             xCachedProps.reset(
     318 [ #  # ][ #  # ]:          0 :                 new ContentProperties( *m_xCachedProps.get() ) );
     319         [ #  # ]:          0 :         xProvider.set( m_pProvider );
     320                 :            :     }
     321                 :            : 
     322                 :            :     typedef std::set< rtl::OUString > StringSet;
     323         [ #  # ]:          0 :     StringSet aPropSet;
     324                 :            : 
     325                 :            :     // No server access for just created (not yet committed) objects.
     326                 :            :     // Only a minimal set of properties supported at this stage.
     327         [ #  # ]:          0 :     if ( !bTransient )
     328                 :            :     {
     329                 :            :         // Obtain all properties supported for this resource from server.
     330                 :            :         try
     331                 :            :         {
     332         [ #  # ]:          0 :             std::vector< DAVResourceInfo > props;
     333         [ #  # ]:          0 :             xResAccess->PROPFIND( DAVZERO, props, xEnv );
     334                 :            : 
     335                 :            :             // Note: vector always contains exactly one resource info, because
     336                 :            :             //       we used a depth of DAVZERO for PROPFIND.
     337                 :          0 :             aPropSet.insert( (*props.begin()).properties.begin(),
     338 [ #  # ][ #  # ]:          0 :                              (*props.begin()).properties.end() );
     339                 :            :         }
     340                 :          0 :         catch ( DAVException const & )
     341                 :            :         {
     342                 :            :         }
     343                 :            :     }
     344                 :            : 
     345                 :            :     // Add DAV properties, map DAV properties to UCB properties.
     346                 :          0 :     sal_Bool bHasCreationDate     = sal_False; // creationdate     <-> DateCreated
     347                 :          0 :     sal_Bool bHasGetLastModified  = sal_False; // getlastmodified  <-> DateModified
     348                 :          0 :     sal_Bool bHasGetContentType   = sal_False; // getcontenttype   <-> MediaType
     349                 :          0 :     sal_Bool bHasGetContentLength = sal_False; // getcontentlength <-> Size
     350                 :            : 
     351                 :          0 :     sal_Bool bHasContentType      = sal_False;
     352                 :          0 :     sal_Bool bHasIsDocument       = sal_False;
     353                 :          0 :     sal_Bool bHasIsFolder         = sal_False;
     354                 :          0 :     sal_Bool bHasTitle            = sal_False;
     355                 :          0 :     sal_Bool bHasBaseURI          = sal_False;
     356                 :          0 :     sal_Bool bHasDateCreated      = sal_False;
     357                 :          0 :     sal_Bool bHasDateModified     = sal_False;
     358                 :          0 :     sal_Bool bHasMediaType        = sal_False;
     359                 :          0 :     sal_Bool bHasSize             = sal_False;
     360                 :          0 :     sal_Bool bHasCreatableInfos   = sal_False;
     361                 :            : 
     362                 :            :     {
     363                 :          0 :         std::set< rtl::OUString >::const_iterator it  = aPropSet.begin();
     364                 :          0 :         std::set< rtl::OUString >::const_iterator end = aPropSet.end();
     365         [ #  # ]:          0 :         while ( it != end )
     366                 :            :         {
     367   [ #  #  #  # ]:          0 :             if ( !bHasCreationDate &&
                 [ #  # ]
     368                 :          0 :                  ( (*it) == DAVProperties::CREATIONDATE ) )
     369                 :            :             {
     370                 :          0 :                 bHasCreationDate = sal_True;
     371                 :            :             }
     372   [ #  #  #  # ]:          0 :             else if ( !bHasGetLastModified &&
                 [ #  # ]
     373                 :          0 :                       ( (*it) == DAVProperties::GETLASTMODIFIED ) )
     374                 :            :             {
     375                 :          0 :                 bHasGetLastModified = sal_True;
     376                 :            :             }
     377   [ #  #  #  # ]:          0 :             else if ( !bHasGetContentType &&
                 [ #  # ]
     378                 :          0 :                       ( (*it) == DAVProperties::GETCONTENTTYPE ) )
     379                 :            :             {
     380                 :          0 :                 bHasGetContentType = sal_True;
     381                 :            :             }
     382   [ #  #  #  # ]:          0 :             else if ( !bHasGetContentLength &&
                 [ #  # ]
     383                 :          0 :                       ( (*it) == DAVProperties::GETCONTENTLENGTH ) )
     384                 :            :             {
     385                 :          0 :                 bHasGetContentLength = sal_True;
     386                 :            :             }
     387 [ #  # ][ #  # ]:          0 :             else if ( !bHasContentType && (*it) == "ContentType" )
                 [ #  # ]
     388                 :            :             {
     389                 :          0 :                 bHasContentType = sal_True;
     390                 :            :             }
     391 [ #  # ][ #  # ]:          0 :             else if ( !bHasIsDocument && (*it) == "IsDocument" )
                 [ #  # ]
     392                 :            :             {
     393                 :          0 :                 bHasIsDocument = sal_True;
     394                 :            :             }
     395 [ #  # ][ #  # ]:          0 :             else if ( !bHasIsFolder && (*it) == "IsFolder" )
                 [ #  # ]
     396                 :            :             {
     397                 :          0 :                 bHasIsFolder = sal_True;
     398                 :            :             }
     399 [ #  # ][ #  # ]:          0 :             else if ( !bHasTitle && (*it) == "Title" )
                 [ #  # ]
     400                 :            :             {
     401                 :          0 :                 bHasTitle = sal_True;
     402                 :            :             }
     403 [ #  # ][ #  # ]:          0 :             else if ( !bHasBaseURI && (*it) == "BaseURI" )
                 [ #  # ]
     404                 :            :             {
     405                 :          0 :                 bHasBaseURI = sal_True;
     406                 :            :             }
     407 [ #  # ][ #  # ]:          0 :             else if ( !bHasDateCreated && (*it) == "DateCreated" )
                 [ #  # ]
     408                 :            :             {
     409                 :          0 :                 bHasDateCreated = sal_True;
     410                 :            :             }
     411 [ #  # ][ #  # ]:          0 :             else if ( !bHasDateModified && (*it) == "DateModified" )
                 [ #  # ]
     412                 :            :             {
     413                 :          0 :                 bHasDateModified = sal_True;
     414                 :            :             }
     415 [ #  # ][ #  # ]:          0 :             else if ( !bHasMediaType && (*it) == "MediaType" )
                 [ #  # ]
     416                 :            :             {
     417                 :          0 :                 bHasMediaType = sal_True;
     418                 :            :             }
     419 [ #  # ][ #  # ]:          0 :             else if ( !bHasSize && (*it) == "Size" )
                 [ #  # ]
     420                 :            :             {
     421                 :          0 :                 bHasSize = sal_True;
     422                 :            :             }
     423 [ #  # ][ #  # ]:          0 :             else if ( !bHasCreatableInfos && (*it) == "CreatableContentsInfo" )
                 [ #  # ]
     424                 :            :             {
     425                 :          0 :                 bHasCreatableInfos = sal_True;
     426                 :            :             }
     427                 :          0 :             ++it;
     428                 :            :         }
     429                 :            :     }
     430                 :            : 
     431                 :            :     // Add mandatory properties.
     432         [ #  # ]:          0 :     if ( !bHasContentType )
     433                 :            :         aPropSet.insert(
     434 [ #  # ][ #  # ]:          0 :             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContentType" ) ) );
     435                 :            : 
     436         [ #  # ]:          0 :     if ( !bHasIsDocument )
     437                 :            :         aPropSet.insert(
     438 [ #  # ][ #  # ]:          0 :             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDocument" ) ) );
     439                 :            : 
     440         [ #  # ]:          0 :     if ( !bHasIsFolder )
     441                 :            :         aPropSet.insert(
     442 [ #  # ][ #  # ]:          0 :             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFolder" ) ) );
     443                 :            : 
     444         [ #  # ]:          0 :     if ( !bHasTitle )
     445                 :            :     {
     446                 :            :         // Always present since it can be calculated from content's URI.
     447                 :            :         aPropSet.insert(
     448 [ #  # ][ #  # ]:          0 :             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ) );
     449                 :            :     }
     450                 :            : 
     451                 :            :     // Add optional properties.
     452                 :            : 
     453         [ #  # ]:          0 :     if ( !bHasBaseURI )
     454                 :            :     {
     455                 :            :         // Always present since it can be calculated from content's URI.
     456                 :            :         aPropSet.insert(
     457 [ #  # ][ #  # ]:          0 :             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BaseURI" ) ) );
     458                 :            :     }
     459                 :            : 
     460 [ #  # ][ #  # ]:          0 :     if ( !bHasDateCreated && bHasCreationDate )
     461                 :            :         aPropSet.insert(
     462 [ #  # ][ #  # ]:          0 :             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ) );
     463                 :            : 
     464 [ #  # ][ #  # ]:          0 :     if ( !bHasDateModified && bHasGetLastModified )
     465                 :            :         aPropSet.insert(
     466 [ #  # ][ #  # ]:          0 :             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ) );
     467                 :            : 
     468 [ #  # ][ #  # ]:          0 :     if ( !bHasMediaType && bHasGetContentType )
     469                 :            :         aPropSet.insert(
     470 [ #  # ][ #  # ]:          0 :             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ) );
     471                 :            : 
     472 [ #  # ][ #  # ]:          0 :     if ( !bHasSize && bHasGetContentLength )
     473                 :            :         aPropSet.insert(
     474 [ #  # ][ #  # ]:          0 :             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ) );
     475                 :            : 
     476         [ #  # ]:          0 :     if ( !bHasCreatableInfos )
     477                 :            :         aPropSet.insert(
     478                 :            :             rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
     479 [ #  # ][ #  # ]:          0 :                 "CreatableContentsInfo" ) ) );
     480                 :            : 
     481                 :            :     // Add cached properties, if present and still missing.
     482         [ #  # ]:          0 :     if ( xCachedProps.get() )
     483                 :            :     {
     484                 :            :         const std::set< rtl::OUString >::const_iterator set_end
     485                 :          0 :             = aPropSet.end();
     486                 :            : 
     487                 :            :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
     488                 :            :         const std::auto_ptr< PropertyValueMap > & xProps
     489                 :          0 :             = xCachedProps->getProperties();
     490                 :            :         SAL_WNODEPRECATED_DECLARATIONS_POP
     491                 :            : 
     492         [ #  # ]:          0 :         PropertyValueMap::const_iterator       map_it  = xProps->begin();
     493         [ #  # ]:          0 :         const PropertyValueMap::const_iterator map_end = xProps->end();
     494                 :            : 
     495         [ #  # ]:          0 :         while ( map_it != map_end )
     496                 :            :         {
     497 [ #  # ][ #  # ]:          0 :             if ( aPropSet.find( (*map_it).first ) == set_end )
                 [ #  # ]
     498 [ #  # ][ #  # ]:          0 :                 aPropSet.insert( (*map_it).first );
     499                 :            : 
     500                 :          0 :             ++map_it;
     501                 :            :         }
     502                 :            :     }
     503                 :            : 
     504                 :            :     // std::set -> uno::Sequence
     505                 :          0 :     sal_Int32 nCount = aPropSet.size();
     506         [ #  # ]:          0 :     uno::Sequence< beans::Property > aProperties( nCount );
     507                 :            : 
     508                 :          0 :     std::set< rtl::OUString >::const_iterator it = aPropSet.begin();
     509                 :          0 :     beans::Property aProp;
     510                 :            : 
     511         [ #  # ]:          0 :     for ( sal_Int32 n = 0; n < nCount; ++n, ++it )
     512                 :            :     {
     513         [ #  # ]:          0 :         xProvider->getProperty( (*it), aProp );
     514         [ #  # ]:          0 :         aProperties[ n ] = aProp;
     515                 :            :     }
     516                 :            : 
     517 [ #  # ][ #  # ]:          0 :     return aProperties;
     518                 :            : }
     519                 :            : 
     520                 :            : //=========================================================================
     521                 :            : // virtual
     522                 :          0 : uno::Sequence< ucb::CommandInfo > Content::getCommands(
     523                 :            :     const uno::Reference< ucb::XCommandEnvironment > & xEnv )
     524                 :            : {
     525         [ #  # ]:          0 :     osl::Guard< osl::Mutex > aGuard( m_aMutex );
     526                 :            : 
     527         [ #  # ]:          0 :     uno::Sequence< ucb::CommandInfo > aCmdInfo( 8 );
     528                 :            : 
     529                 :            :     ///////////////////////////////////////////////////////////////
     530                 :            :     // Mandatory commands
     531                 :            :     ///////////////////////////////////////////////////////////////
     532                 :            : 
     533         [ #  # ]:          0 :     aCmdInfo[ 0 ] =
     534                 :            :             ucb::CommandInfo(
     535                 :            :                 rtl::OUString(
     536                 :            :                     RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ),
     537                 :            :                 -1,
     538 [ #  # ][ #  # ]:          0 :                 getCppuVoidType() );
     539         [ #  # ]:          0 :     aCmdInfo[ 1 ] =
     540                 :            :             ucb::CommandInfo(
     541                 :            :                 rtl::OUString(
     542                 :            :                     RTL_CONSTASCII_USTRINGPARAM( "getPropertySetInfo" ) ),
     543                 :            :                 -1,
     544 [ #  # ][ #  # ]:          0 :                 getCppuVoidType() );
     545         [ #  # ]:          0 :     aCmdInfo[ 2 ] =
     546                 :            :             ucb::CommandInfo(
     547                 :            :                 rtl::OUString(
     548                 :            :                     RTL_CONSTASCII_USTRINGPARAM( "getPropertyValues" ) ),
     549                 :            :                 -1,
     550                 :            :                 getCppuType( static_cast<
     551 [ #  # ][ #  # ]:          0 :                                 uno::Sequence< beans::Property > * >( 0 ) ) );
     552         [ #  # ]:          0 :     aCmdInfo[ 3 ] =
     553                 :            :             ucb::CommandInfo(
     554                 :            :                 rtl::OUString(
     555                 :            :                     RTL_CONSTASCII_USTRINGPARAM( "setPropertyValues" ) ),
     556                 :            :                 -1,
     557                 :            :                 getCppuType( static_cast<
     558 [ #  # ][ #  # ]:          0 :                     uno::Sequence< beans::PropertyValue > * >( 0 ) ) );
     559                 :            : 
     560                 :            :     ///////////////////////////////////////////////////////////////
     561                 :            :     // Optional standard commands
     562                 :            :     ///////////////////////////////////////////////////////////////
     563                 :            : 
     564         [ #  # ]:          0 :     aCmdInfo[ 4 ] =
     565                 :            :             ucb::CommandInfo(
     566                 :            :                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ),
     567                 :            :                 -1,
     568 [ #  # ][ #  # ]:          0 :                 getCppuBooleanType() );
     569         [ #  # ]:          0 :     aCmdInfo[ 5 ] =
     570                 :            :             ucb::CommandInfo(
     571                 :            :                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert" ) ),
     572                 :            :                 -1,
     573                 :            :                 getCppuType( static_cast<
     574 [ #  # ][ #  # ]:          0 :                     ucb::InsertCommandArgument * >( 0 ) ) );
     575         [ #  # ]:          0 :     aCmdInfo[ 6 ] =
     576                 :            :             ucb::CommandInfo(
     577                 :            :                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ),
     578                 :            :                 -1,
     579                 :            :                 getCppuType( static_cast<
     580 [ #  # ][ #  # ]:          0 :                     ucb::OpenCommandArgument2 * >( 0 ) ) );
     581                 :            : 
     582                 :            :     ///////////////////////////////////////////////////////////////
     583                 :            :     // New commands
     584                 :            :     ///////////////////////////////////////////////////////////////
     585                 :            : 
     586         [ #  # ]:          0 :     aCmdInfo[ 7 ] =
     587                 :            :             ucb::CommandInfo(
     588                 :            :                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "post" ) ),
     589                 :            :                 -1,
     590                 :            :                 getCppuType( static_cast<
     591 [ #  # ][ #  # ]:          0 :                     ucb::PostCommandArgument2 * >( 0 ) ) );
                 [ #  # ]
     592                 :            : 
     593                 :          0 :     sal_Bool bFolder = sal_False;
     594                 :            : 
     595                 :            :     try
     596                 :            :     {
     597         [ #  # ]:          0 :         bFolder = isFolder( xEnv );
     598                 :            :     }
     599         [ #  # ]:          0 :     catch ( uno::Exception const & )
     600                 :            :     {
     601                 :            :         return aCmdInfo;
     602                 :            :     }
     603                 :            : 
     604         [ #  # ]:          0 :     sal_Bool bSupportsLocking = supportsExclusiveWriteLock( xEnv );
     605                 :            : 
     606                 :          0 :     sal_Int32 nPos = aCmdInfo.getLength();
     607 [ #  # ][ #  # ]:          0 :     sal_Int32 nMoreCmds = ( bFolder ? 2 : 0 ) + ( bSupportsLocking ? 2 : 0 );
     608         [ #  # ]:          0 :     if ( nMoreCmds )
     609         [ #  # ]:          0 :         aCmdInfo.realloc( nPos + nMoreCmds );
     610                 :            :     else
     611                 :            :         return aCmdInfo;
     612                 :            : 
     613         [ #  # ]:          0 :     if ( bFolder )
     614                 :            :     {
     615                 :            :         ///////////////////////////////////////////////////////////////
     616                 :            :         // Optional standard commands
     617                 :            :         ///////////////////////////////////////////////////////////////
     618                 :            : 
     619         [ #  # ]:          0 :         aCmdInfo[ nPos ] =
     620                 :            :             ucb::CommandInfo(
     621                 :            :                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ),
     622                 :            :                 -1,
     623 [ #  # ][ #  # ]:          0 :                 getCppuType( static_cast< ucb::TransferInfo * >( 0 ) ) );
     624                 :          0 :         nPos++;
     625         [ #  # ]:          0 :         aCmdInfo[ nPos ] =
     626                 :            :             ucb::CommandInfo(
     627                 :            :                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
     628                 :            :                     "createNewContent" ) ),
     629                 :            :                 -1,
     630 [ #  # ][ #  # ]:          0 :                 getCppuType( static_cast< ucb::ContentInfo * >( 0 ) ) );
     631                 :          0 :         nPos++;
     632                 :            :     }
     633                 :            :     else
     634                 :            :     {
     635                 :            :         // no document-only commands at the moment.
     636                 :            :     }
     637                 :            : 
     638         [ #  # ]:          0 :     if ( bSupportsLocking )
     639                 :            :     {
     640         [ #  # ]:          0 :         aCmdInfo[ nPos ] =
     641                 :            :             ucb::CommandInfo(
     642                 :            :                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "lock" ) ),
     643                 :            :                 -1,
     644 [ #  # ][ #  # ]:          0 :                 getCppuVoidType() );
     645                 :          0 :         nPos++;
     646         [ #  # ]:          0 :         aCmdInfo[ nPos ] =
     647                 :            :             ucb::CommandInfo(
     648                 :            :                 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "unlock" ) ),
     649                 :            :                 -1,
     650 [ #  # ][ #  # ]:          0 :                 getCppuVoidType() );
     651                 :          0 :         nPos++;
     652                 :            :     }
     653         [ #  # ]:          0 :     return aCmdInfo;
     654                 :            : }
     655                 :            : 
     656                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10