update dev300-m58
[ooovba.git] / configmgr / workben / memory / treeload.cxx
blob5de5d4ca9bb7208abb2bf465480b4c4cda333c57
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: treeload.cxx,v $
10 * $Revision: 1.3 $
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 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_configmgr.hxx"
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <localsession.hxx>
36 #include <treecache.hxx>
37 #include <options.hxx>
38 #include <rtl/ustring.hxx>
39 #include "treeload.hxx"
41 // -----------------------------------------------------------------------------
42 namespace configmgr
44 namespace uno = ::com::sun::star::uno;
45 namespace lang = ::com::sun::star::lang;
47 #define ASCII(x) ::rtl::OUString::createFromAscii(x)
49 // -----------------------------------------------------------------------------
50 // ------------------------- requestSubtree without API -------------------------
51 // -----------------------------------------------------------------------------
53 OTreeLoad::OTreeLoad(uno::Reference<lang::XMultiServiceFactory> const& _xServiceProvider,
54 rtl::OUString const& _sSourceDirectory, rtl::OUString const& _sUpdateDirectory) throw (uno::Exception)
55 :m_xServiceProvider(_xServiceProvider)
57 // Create a TypeConverter
58 uno::Reference<script::XTypeConverter> xConverter;
59 xConverter = xConverter.query(m_xServiceProvider->createInstance(ASCII( "com.sun.star.script.Converter" )) );
61 m_xDefaultOptions = new OOptions(xConverter);
62 m_xDefaultOptions->setNoCache(true);
64 // create it .. and connect
65 std::auto_ptr<LocalSession> pLocal( new LocalSession(m_xServiceProvider) );
66 sal_Bool bOpen = pLocal->open(_sSourceDirectory, _sUpdateDirectory);
68 IConfigSession* pConfigSession = pLocal.release();
70 m_pTreeMgr = new TreeManager(pConfigSession, m_xDefaultOptions);
72 // -----------------------------------------------------------------------------
73 ISubtree* OTreeLoad::requestSubtree( OUString const& aSubtreePath) throw (uno::Exception)
75 return m_pTreeMgr->requestSubtree(aSubtreePath, m_xDefaultOptions, /* MinLevel */ -1);
77 // -----------------------------------------------------------------------------
78 void OTreeLoad::releaseSubtree( OUString const& aSubtreePath) throw (uno::Exception)
80 m_pTreeMgr->releaseSubtree(aSubtreePath, m_xDefaultOptions);
83 // -----------------------------------------------------------------------------
84 } // namespace