From 2fd74b3b155160e73045298bc61ba8707cac2933 Mon Sep 17 00:00:00 2001 From: Vishv Brahmbhatt Date: Fri, 5 Jul 2013 19:25:28 +0530 Subject: Working version of XML parser from configuration file path Added some changes in the "getRootElement" and new "layoutlist.xml" is added for "unit-test" module. XML parser works perfectly in the installation,only the failure of "unit-test" is left to be solved. Some refactoring related to "layoutlist.xml" will be updated soon. Change-Id: If7ed3af40e9b6df26e20881728181eb6c82936d8 --- .../schema/org/openoffice/Office/Impress.xcs | 8 +++--- sd/source/core/sdpage.cxx | 31 +++++++++++----------- sd/xml/layoutlist.xml | 4 +-- .../config/soffice.cfg/simpress/layoutlist.xml | 8 ++++++ 4 files changed, 30 insertions(+), 21 deletions(-) create mode 100644 test/user-template/user/config/soffice.cfg/simpress/layoutlist.xml diff --git a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs index 75091d18ede6..b966aa08e875 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs @@ -468,15 +468,15 @@ vnd.sun.star.expand:$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/config/soffice.cfg/simpress/effects.xml + - - - Contains a list of layout type.It contains properties of presobj like their Position, - Height and Width + Height and Width.Values are put through + macro expansion, so, vnd.sun.star.expand prefix + is allowed. diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index 4fa89a9b57a6..e8f012a91712 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -66,6 +66,7 @@ #include #include #include +#include #include "../ui/inc/DrawDocShell.hxx" #include "Outliner.hxx" @@ -1192,12 +1193,11 @@ static const LayoutDescriptor& GetLayoutDescriptor( AutoLayout eLayout ) //to get the root element of the xml file Reference getRootElement() { - rtl::OUString filepath="/home/vishv/layoutlist.xml"; const Reference xContext(comphelper_getProcessComponentContext()); 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, @@ -1208,31 +1208,32 @@ Reference getRootElement() xConfigProvider->createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", Sequence( &propValue, 1 ) ), UNO_QUERY_THROW ); - uno::Sequence< OUString > aFiles; + Sequence< rtl::OUString > aFiles; xNameAccess->getByName( "LayoutListFiles" ) >>= aFiles; - + rtl::OUString aURL; 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 } + if( aURL.startsWith( "file://" ) ) + { + rtl::OUString aSysPath; + if( osl_getSystemPathFromFileURL( aURL.pData, &aSysPath.pData ) == osl_File_E_None ) + aURL = aSysPath; + } + const Reference xDocBuilder(css::xml::dom::DocumentBuilder::create(comphelper::getComponentContext(xServiceFactory))); + const Reference xDoc = xDocBuilder->parseURI(aURL); + const Reference xRoot = xDoc->getDocumentElement(); + 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 index 0b1e9d9a59c8..61b863d4b743 100644 --- a/sd/xml/layoutlist.xml +++ b/sd/xml/layoutlist.xml @@ -1,8 +1,8 @@ - + - + \ No newline at end of file diff --git a/test/user-template/user/config/soffice.cfg/simpress/layoutlist.xml b/test/user-template/user/config/soffice.cfg/simpress/layoutlist.xml new file mode 100644 index 000000000000..61b863d4b743 --- /dev/null +++ b/test/user-template/user/config/soffice.cfg/simpress/layoutlist.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file -- cgit