LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svl/source/misc - fstathelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 27 96.3 %
Date: 2013-07-09 Functions: 3 3 100.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             : #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 <comphelper/processfactory.hxx>
      26             : #include <svl/fstathelper.hxx>
      27             : 
      28             : using namespace ::com::sun::star;
      29             : using namespace ::com::sun::star::uno;
      30             : using namespace ::com::sun::star::ucb;
      31             : using namespace ::rtl;
      32             : 
      33          92 : sal_Bool FStatHelper::GetModifiedDateTimeOfFile( const OUString& rURL,
      34             :                                         Date* pDate, Time* pTime )
      35             : {
      36          92 :     sal_Bool bRet = sal_False;
      37             :     try
      38             :     {
      39             :         ::ucbhelper::Content aTestContent( rURL,
      40             :                                 uno::Reference< XCommandEnvironment > (),
      41          92 :                                 comphelper::getProcessComponentContext());
      42             :         uno::Any aAny = aTestContent.getPropertyValue(
      43         184 :             OUString("DateModified") );
      44          88 :         if( aAny.hasValue() )
      45             :         {
      46          88 :             bRet = sal_True;
      47          88 :             const util::DateTime* pDT = (util::DateTime*)aAny.getValue();
      48          88 :             if( pDate )
      49          88 :                 *pDate = Date( pDT->Day, pDT->Month, pDT->Year );
      50          88 :             if( pTime )
      51         176 :                 *pTime = Time( pDT->Hours, pDT->Minutes,
      52          88 :                                pDT->Seconds, pDT->NanoSeconds );
      53          92 :         }
      54             :     }
      55           4 :     catch(...)
      56             :     {
      57             :     }
      58             : 
      59          92 :     return bRet;
      60             : }
      61             : 
      62         158 : sal_Bool FStatHelper::IsDocument( const OUString& rURL )
      63             : {
      64         158 :     sal_Bool bExist = sal_False;
      65             :     try
      66             :     {
      67             :         ::ucbhelper::Content aTestContent( rURL,
      68             :                                 uno::Reference< XCommandEnvironment > (),
      69         194 :                                 comphelper::getProcessComponentContext());
      70         130 :         bExist = aTestContent.isDocument();
      71             :     }
      72          44 :     catch(...)
      73             :     {
      74             :     }
      75         158 :     return bExist;
      76             : }
      77             : 
      78           2 : sal_Bool FStatHelper::IsFolder( const OUString& rURL )
      79             : {
      80           2 :     sal_Bool bExist = sal_False;
      81             :     try
      82             :     {
      83             :         ::ucbhelper::Content aTestContent( rURL,
      84             :                                 uno::Reference< XCommandEnvironment > (),
      85           2 :                                 comphelper::getProcessComponentContext());
      86           2 :         bExist = aTestContent.isFolder();
      87             :     }
      88           0 :     catch(...)
      89             :     {
      90             :     }
      91           2 :     return bExist;
      92             : }
      93             : 
      94             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10