From 4a281debd23ac8604bb80978e5f26c0cfebcc4b0 Mon Sep 17 00:00:00 2001 From: Vishv Brahmbhatt Date: Sat, 29 Jun 2013 02:55:37 +0530 Subject: Changing the XML parser with configuration file path Updating the "getRootElement" function.So "layoutlist.xml" can be read from actual configuration path. Change-Id: Iee636d32e629e935e46a18572646659780ae20e3 --- sd/Package_xml.mk | 1 + sd/source/core/sdpage.cxx | 59 +++++++++++++++++++++++++++++++++++++++++++---- sd/xml/layoutlist.xml | 8 +++++++ 3 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 sd/xml/layoutlist.xml (limited to 'sd') diff --git a/sd/Package_xml.mk b/sd/Package_xml.mk index 3178e0d49d10..694d452e87dc 100644 --- a/sd/Package_xml.mk +++ b/sd/Package_xml.mk @@ -14,6 +14,7 @@ $(eval $(call gb_Package_set_outdir,sd_xml,$(INSTDIR))) $(eval $(call gb_Package_add_files,sd_xml,$(LIBO_SHARE_FOLDER)/config/soffice.cfg/simpress,\ effects.xml \ transitions.xml \ + layoutlist.xml \ )) # vim: set noet sw=4 ts=4: diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index 090577432c7f..4fa89a9b57a6 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -57,6 +57,15 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "../ui/inc/DrawDocShell.hxx" #include "Outliner.hxx" @@ -81,9 +90,15 @@ using namespace ::sd; using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; using namespace com::sun::star::xml::dom; using ::com::sun::star::uno::Reference; +using ::com::sun::star::io::XInputStream; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::container::XNameAccess; +using ::com::sun::star::beans::PropertyValue; + TYPEINIT2( SdPage, FmFormPage, SdrObjUserCall ); @@ -1173,15 +1188,51 @@ static const LayoutDescriptor& GetLayoutDescriptor( AutoLayout eLayout ) return aLayouts[ eLayout - AUTOLAYOUT__START ]; } +#define EXPAND_PROTOCOL "vnd.sun.star.expand:" //to get the root element of the xml file Reference getRootElement() { rtl::OUString filepath="/home/vishv/layoutlist.xml"; const Reference xContext(comphelper_getProcessComponentContext()); - const Reference xDocBuilder(css::xml::dom::DocumentBuilder::create(xContext)); - const Reference xDoc = xDocBuilder->parseURI(filepath); - const Reference xRoot = xDoc->getDocumentElement(); - return xRoot; + Reference< XMultiServiceFactory > xServiceFactory(xContext->getServiceManager(), UNO_QUERY_THROW ); + Reference< util::XMacroExpander > xMacroExpander =util::theMacroExpander::get(xContext); + Reference< XMultiServiceFactory > xConfigProvider =configuration::theDefaultProvider::get( xContext ); + // read path to transition effects files from config + Any propValue = uno::makeAny( + beans::PropertyValue( + "nodepath", -1, + uno::makeAny( OUString( "/org.openoffice.Office.Impress/Misc" )), + beans::PropertyState_DIRECT_VALUE ) ); + + Reference xNameAccess( + xConfigProvider->createInstanceWithArguments( + "com.sun.star.configuration.ConfigurationAccess", + Sequence( &propValue, 1 ) ), UNO_QUERY_THROW ); + uno::Sequence< OUString > aFiles; + xNameAccess->getByName( "LayoutListFiles" ) >>= aFiles; + + for( sal_Int32 i=0; iexpandMacros( aMacro ); + } + SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aURL, STREAM_READ ); + ::utl::OInputStreamWrapper* isw=new ::utl::OInputStreamWrapper( pIStm); + Reference xIs(isw); + + rtl::OUString sServName = rtl::OUString::createFromAscii("com.sun.star.xml.dom.DocumentBuilder"); + Reference xDb( xServiceFactory->createInstance(sServName), UNO_QUERY); + const Reference xDom(xDb->parse(xIs), UNO_QUERY_THROW ); + const Reference xRoot( xDom->getDocumentElement(),UNO_QUERY_THROW ); + return xRoot;//this loops seems to work only once,so temporary returning the root element + } } //read the information from XML file(traversing from layout node) diff --git a/sd/xml/layoutlist.xml b/sd/xml/layoutlist.xml new file mode 100644 index 000000000000..0b1e9d9a59c8 --- /dev/null +++ b/sd/xml/layoutlist.xml @@ -0,0 +1,8 @@ + + + + + + + -- cgit