LCOV - code coverage report
Current view: top level - svl/source/misc - fstathelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 25 26 96.2 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 28 57.1 %

           Branch data     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                 :            : #include <tools/date.hxx>
      21                 :            : #include <tools/time.hxx>
      22                 :            : #include <tools/string.hxx>
      23                 :            : #include <ucbhelper/content.hxx>
      24                 :            : #include <com/sun/star/util/DateTime.hpp>
      25                 :            : #include <svl/fstathelper.hxx>
      26                 :            : 
      27                 :            : using namespace ::com::sun::star;
      28                 :            : using namespace ::com::sun::star::uno;
      29                 :            : using namespace ::com::sun::star::ucb;
      30                 :            : using namespace ::rtl;
      31                 :            : 
      32                 :        182 : sal_Bool FStatHelper::GetModifiedDateTimeOfFile( const rtl::OUString& rURL,
      33                 :            :                                         Date* pDate, Time* pTime )
      34                 :            : {
      35                 :        182 :     sal_Bool bRet = sal_False;
      36                 :            :     try
      37                 :            :     {
      38                 :            :         ::ucbhelper::Content aTestContent( rURL,
      39         [ +  - ]:        182 :                                 uno::Reference< XCommandEnvironment > ());
      40                 :            :         uno::Any aAny = aTestContent.getPropertyValue(
      41         [ +  + ]:        182 :             OUString("DateModified") );
      42         [ +  - ]:        174 :         if( aAny.hasValue() )
      43                 :            :         {
      44                 :        174 :             bRet = sal_True;
      45                 :        174 :             const util::DateTime* pDT = (util::DateTime*)aAny.getValue();
      46         [ +  - ]:        174 :             if( pDate )
      47                 :        174 :                 *pDate = Date( pDT->Day, pDT->Month, pDT->Year );
      48         [ +  - ]:        174 :             if( pTime )
      49                 :            :                 *pTime = Time( pDT->Hours, pDT->Minutes,
      50 [ +  - ][ +  - ]:        174 :                                pDT->Seconds, pDT->HundredthSeconds );
      51         [ +  - ]:        182 :         }
      52                 :            :     }
      53                 :          8 :     catch(...)
      54                 :            :     {
      55                 :            :     }
      56                 :            : 
      57                 :        182 :     return bRet;
      58                 :            : }
      59                 :            : 
      60                 :        244 : sal_Bool FStatHelper::IsDocument( const rtl::OUString& rURL )
      61                 :            : {
      62                 :        244 :     sal_Bool bExist = sal_False;
      63                 :            :     try
      64                 :            :     {
      65                 :            :         ::ucbhelper::Content aTestContent( rURL,
      66         [ +  - ]:        244 :                                 uno::Reference< XCommandEnvironment > ());
      67 [ +  - ][ +  + ]:        244 :         bExist = aTestContent.isDocument();
      68                 :            :     }
      69                 :         16 :     catch(...)
      70                 :            :     {
      71                 :            :     }
      72                 :        244 :     return bExist;
      73                 :            : }
      74                 :            : 
      75                 :          4 : sal_Bool FStatHelper::IsFolder( const rtl::OUString& rURL )
      76                 :            : {
      77                 :          4 :     sal_Bool bExist = sal_False;
      78                 :            :     try
      79                 :            :     {
      80                 :            :         ::ucbhelper::Content aTestContent( rURL,
      81         [ +  - ]:          4 :                                 uno::Reference< XCommandEnvironment > ());
      82 [ +  - ][ +  - ]:          4 :         bExist = aTestContent.isFolder();
      83                 :            :     }
      84                 :          0 :     catch(...)
      85                 :            :     {
      86                 :            :     }
      87                 :          4 :     return bExist;
      88                 :            : }
      89                 :            : 
      90                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10