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_ucb.hxx" 30 31 #include "ucbhelper/propertyvalueset.hxx" 32 #include "rtl/ref.hxx" 33 #include "com/sun/star/ucb/Command.hpp" 34 #include "com/sun/star/ucb/XCommandEnvironment.hpp" 35 #include "com/sun/star/ucb/XCommandProcessor.hpp" 36 #include "com/sun/star/sdbc/XRow.hpp" 37 #include "ftpresultsetI.hxx" 38 #include "ftpcontent.hxx" 39 40 41 using namespace std; 42 using namespace ftp; 43 using namespace com::sun::star::ucb; 44 using namespace com::sun::star::lang; 45 using namespace com::sun::star::uno; 46 using namespace com::sun::star::beans; 47 using namespace com::sun::star::sdbc; 48 49 50 ResultSetI::ResultSetI(const Reference<XMultiServiceFactory>& xMSF, 51 const Reference<XContentProvider>& xProvider, 52 sal_Int32 nOpenMode, 53 const Sequence<Property>& seqProp, 54 const Sequence< NumberedSortingInfo >& seqSort, 55 const std::vector<FTPDirentry>& dirvec) 56 : ResultSetBase(xMSF,xProvider,nOpenMode,seqProp,seqSort) 57 { 58 for( unsigned int i = 0; i < dirvec.size(); ++i) 59 m_aPath.push_back(dirvec[i].m_aURL); 60 61 // m_aIdents holds the contentidentifiers 62 63 m_aItems.resize( m_aPath.size() ); 64 m_aIdents.resize( m_aPath.size() ); 65 66 for(unsigned n = 0; n < m_aItems.size(); ++n) { 67 rtl::Reference<ucbhelper::PropertyValueSet> xRow = 68 new ucbhelper::PropertyValueSet(xMSF); 69 70 for( int i = 0; i < seqProp.getLength(); ++i) { 71 const rtl::OUString& Name = seqProp[i].Name; 72 if(Name.compareToAscii("ContentType") == 0 ) 73 xRow->appendString(seqProp[i], 74 rtl::OUString::createFromAscii( 75 "application/ftp" )); 76 else if(Name.compareToAscii("Title") == 0) 77 xRow->appendString(seqProp[i],dirvec[n].m_aName); 78 else if(Name.compareToAscii("IsReadOnly") == 0) 79 xRow->appendBoolean(seqProp[i], 80 sal_Bool(dirvec[n].m_nMode & 81 INETCOREFTP_FILEMODE_WRITE)); 82 else if(Name.compareToAscii("IsDocument") == 0) 83 xRow->appendBoolean(seqProp[i], 84 ! sal_Bool(dirvec[n].m_nMode & 85 INETCOREFTP_FILEMODE_ISDIR)); 86 else if(Name.compareToAscii("IsFolder") == 0) 87 xRow->appendBoolean(seqProp[i], 88 sal_Bool(dirvec[n].m_nMode & 89 INETCOREFTP_FILEMODE_ISDIR)); 90 else if(Name.compareToAscii("Size") == 0) 91 xRow->appendLong(seqProp[i], 92 dirvec[n].m_nSize); 93 else if(Name.compareToAscii("DateCreated") == 0) 94 xRow->appendTimestamp(seqProp[i], 95 dirvec[n].m_aDate); 96 else if(Name.compareToAscii("CreatableContentsInfo") == 0) 97 xRow->appendObject( 98 seqProp[i], 99 makeAny(FTPContent::queryCreatableContentsInfo_Static())); 100 else 101 xRow->appendVoid(seqProp[i]); 102 } 103 m_aItems[n] = Reference<XRow>(xRow.get()); 104 } 105 } 106