Update ooo320-m1
[ooovba.git] / ucb / source / ucp / ftp / ftpresultsetI.cxx
blob40bd4569fd34cf7c9b518a866418f8db92814c27
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ftpresultsetI.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucb.hxx"
34 #include "ucbhelper/propertyvalueset.hxx"
35 #include "rtl/ref.hxx"
36 #include "com/sun/star/ucb/Command.hpp"
37 #include "com/sun/star/ucb/XCommandEnvironment.hpp"
38 #include "com/sun/star/ucb/XCommandProcessor.hpp"
39 #include "com/sun/star/sdbc/XRow.hpp"
40 #include "ftpresultsetI.hxx"
44 using namespace std;
45 using namespace ftp;
46 using namespace com::sun::star::ucb;
47 using namespace com::sun::star::lang;
48 using namespace com::sun::star::uno;
49 using namespace com::sun::star::beans;
50 using namespace com::sun::star::sdbc;
53 ResultSetI::ResultSetI(const Reference<XMultiServiceFactory>& xMSF,
54 const Reference<XContentProvider>& xProvider,
55 sal_Int32 nOpenMode,
56 const Sequence<Property>& seqProp,
57 const Sequence< NumberedSortingInfo >& seqSort,
58 const std::vector<FTPDirentry>& dirvec)
59 : ResultSetBase(xMSF,xProvider,nOpenMode,seqProp,seqSort)
61 for( unsigned int i = 0; i < dirvec.size(); ++i)
62 m_aPath.push_back(dirvec[i].m_aURL);
64 // m_aIdents holds the contentidentifiers
66 m_aItems.resize( m_aPath.size() );
67 m_aIdents.resize( m_aPath.size() );
69 for(unsigned n = 0; n < m_aItems.size(); ++n) {
70 rtl::Reference<ucbhelper::PropertyValueSet> xRow =
71 new ucbhelper::PropertyValueSet(xMSF);
73 for( int i = 0; i < seqProp.getLength(); ++i) {
74 const rtl::OUString& Name = seqProp[i].Name;
75 if(Name.compareToAscii("ContentType") == 0 )
76 xRow->appendString(seqProp[i],
77 rtl::OUString::createFromAscii(
78 "application/ftp" ));
79 else if(Name.compareToAscii("Title") == 0)
80 xRow->appendString(seqProp[i],dirvec[n].m_aName);
81 else if(Name.compareToAscii("IsReadOnly") == 0)
82 xRow->appendBoolean(seqProp[i],
83 sal_Bool(dirvec[n].m_nMode &
84 INETCOREFTP_FILEMODE_WRITE));
85 else if(Name.compareToAscii("IsDocument") == 0)
86 xRow->appendBoolean(seqProp[i],
87 ! sal_Bool(dirvec[n].m_nMode &
88 INETCOREFTP_FILEMODE_ISDIR));
89 else if(Name.compareToAscii("IsFolder") == 0)
90 xRow->appendBoolean(seqProp[i],
91 sal_Bool(dirvec[n].m_nMode &
92 INETCOREFTP_FILEMODE_ISDIR));
93 else if(Name.compareToAscii("Size") == 0)
94 xRow->appendLong(seqProp[i],
95 dirvec[n].m_nSize);
96 else if(Name.compareToAscii("DateCreated") == 0)
97 xRow->appendTimestamp(seqProp[i],
98 dirvec[n].m_aDate);
99 else
100 xRow->appendVoid(seqProp[i]);
102 m_aItems[n] = Reference<XRow>(xRow.get());