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_xmlhelp.hxx"
30 #include <com/sun/star/ucb/Command.hpp>
31 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
32 #include <com/sun/star/ucb/XCommandProcessor.hpp>
33 
34 #include "resultsetforroot.hxx"
35 #include "databases.hxx"
36 
37 using namespace chelp;
38 using namespace com::sun::star;
39 using namespace com::sun::star::ucb;
40 
41 
42 
43 ResultSetForRoot::ResultSetForRoot( const uno::Reference< lang::XMultiServiceFactory >&  xMSF,
44 									const uno::Reference< XContentProvider >&  xProvider,
45 									sal_Int32 nOpenMode,
46 									const uno::Sequence< beans::Property >& seq,
47 									const uno::Sequence< NumberedSortingInfo >& seqSort,
48 									URLParameter& aURLParameter,
49 									Databases* pDatabases )
50 	: ResultSetBase( xMSF,xProvider,nOpenMode,seq,seqSort ),
51 	  m_aURLParameter( aURLParameter ),
52 	  m_pDatabases( pDatabases )
53 {
54 	m_aPath = m_pDatabases->getModuleList( m_aURLParameter.get_language() );
55 	m_aItems.resize( m_aPath.size() );
56 	m_aIdents.resize( m_aPath.size() );
57 
58 	Command aCommand;
59 	aCommand.Name = rtl::OUString::createFromAscii( "getPropertyValues" );
60 	aCommand.Argument <<= m_sProperty;
61 
62 	for( sal_uInt32 i = 0; i < m_aPath.size(); ++i )
63 	{
64 		m_aPath[i] =
65 			rtl::OUString::createFromAscii( "vnd.sun.star.help://" ) +
66 			m_aPath[i]                                               +
67 			rtl::OUString::createFromAscii( "?Language=" )           +
68 			m_aURLParameter.get_language()                           +
69 			rtl::OUString::createFromAscii( "&System=" )             +
70 			m_aURLParameter.get_system();
71 
72 		m_nRow = sal_Int32( i );
73 
74 		uno::Reference< XContent > content = queryContent();
75 		if( content.is() )
76 		{
77 			uno::Reference< XCommandProcessor > cmd( content,uno::UNO_QUERY );
78 			cmd->execute( aCommand,0,uno::Reference< XCommandEnvironment >( 0 ) ) >>= m_aItems[i]; //TODO: check return value of operator >>=
79 		}
80 		m_nRow = 0xffffffff;
81 	}
82 }
83