xref: /trunk/main/svl/source/misc/fstathelper.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svl.hxx"
30 #include <tools/date.hxx>
31 #include <tools/time.hxx>
32 #include <tools/string.hxx>
33 #include <ucbhelper/content.hxx>
34 #include <com/sun/star/util/DateTime.hpp>
35 #include <svl/fstathelper.hxx>
36 
37 using namespace ::com::sun::star;
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::ucb;
40 using namespace ::rtl;
41 
42 sal_Bool FStatHelper::GetModifiedDateTimeOfFile( const UniString& rURL,
43                                         Date* pDate, Time* pTime )
44 {
45     sal_Bool bRet = sal_False;
46     try
47     {
48         ::ucbhelper::Content aTestContent( rURL,
49                                 uno::Reference< XCommandEnvironment > ());
50         uno::Any aAny = aTestContent.getPropertyValue(
51             OUString::createFromAscii(  "DateModified" ) );
52         if( aAny.hasValue() )
53         {
54             bRet = sal_True;
55             const util::DateTime* pDT = (util::DateTime*)aAny.getValue();
56             if( pDate )
57                 *pDate = Date( pDT->Day, pDT->Month, pDT->Year );
58             if( pTime )
59                 *pTime = Time( pDT->Hours, pDT->Minutes,
60                                pDT->Seconds, pDT->HundredthSeconds );
61         }
62     }
63     catch(...)
64     {
65     }
66 
67     return bRet;
68 }
69 
70 sal_Bool FStatHelper::IsDocument( const UniString& rURL )
71 {
72     sal_Bool bExist = sal_False;
73     try
74     {
75         ::ucbhelper::Content aTestContent( rURL,
76                                 uno::Reference< XCommandEnvironment > ());
77         bExist = aTestContent.isDocument();
78     }
79     catch(...)
80     {
81     }
82     return bExist;
83 }
84 
85 sal_Bool FStatHelper::IsFolder( const UniString& rURL )
86 {
87     sal_Bool bExist = sal_False;
88     try
89     {
90         ::ucbhelper::Content aTestContent( rURL,
91                                 uno::Reference< XCommandEnvironment > ());
92         bExist = aTestContent.isFolder();
93     }
94     catch(...)
95     {
96     }
97     return bExist;
98 }
99 
100