summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorVishv Brahmbhatt <vishvbrahmbhatt19@gmail.com>2013-07-05 19:25:28 +0530
committerThorsten Behrens <tbehrens@suse.com>2013-08-26 14:47:21 +0200
commit2fd74b3b155160e73045298bc61ba8707cac2933 (patch)
tree70fa84678b2a20d8f23ecefd2fd7f4ba62aeb98f /sd
parent4a281debd23ac8604bb80978e5f26c0cfebcc4b0 (diff)
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
Diffstat (limited to 'sd')
-rw-r--r--sd/source/core/sdpage.cxx31
-rw-r--r--sd/xml/layoutlist.xml4
2 files changed, 18 insertions, 17 deletions
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 <unotools/streamwrap.hxx>
#include <rtl/uri.hxx>
#include <unotools/ucbstreamhelper.hxx>
+#include <osl/file.h>
#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<XElement> getRootElement()
{
- rtl::OUString filepath="/home/vishv/layoutlist.xml";
const Reference<css::uno::XComponentContext> 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<XElement> getRootElement()
xConfigProvider->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationAccess",
Sequence<Any>( &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; i<aFiles.getLength(); ++i )
{
- OUString aURL = aFiles[i];
+ aURL = aFiles[i];
if( aURL.startsWith( EXPAND_PROTOCOL ) )
{
// cut protocol
- OUString aMacro( aURL.copy( sizeof ( EXPAND_PROTOCOL ) -1 ) );
+ rtl::OUString aMacro( aURL.copy( sizeof ( EXPAND_PROTOCOL ) -1 ) );
// decode uric class chars
aMacro = rtl::Uri::decode( aMacro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
// expand macro string
aURL = xMacroExpander->expandMacros( aMacro );
}
- SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aURL, STREAM_READ );
- ::utl::OInputStreamWrapper* isw=new ::utl::OInputStreamWrapper( pIStm);
- Reference<XInputStream> xIs(isw);
-
- rtl::OUString sServName = rtl::OUString::createFromAscii("com.sun.star.xml.dom.DocumentBuilder");
- Reference<XDocumentBuilder> xDb( xServiceFactory->createInstance(sServName), UNO_QUERY);
- const Reference<XDocument> xDom(xDb->parse(xIs), UNO_QUERY_THROW );
- const Reference<XElement> 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<XDocumentBuilder> xDocBuilder(css::xml::dom::DocumentBuilder::create(comphelper::getComponentContext(xServiceFactory)));
+ const Reference<XDocument> xDoc = xDocBuilder->parseURI(aURL);
+ const Reference<XElement> 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 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0"?>
<!-- At present I am not sure about corect XML namespace,so once I am aware of it.I am ready to add it.
-->
<layout-list>
<layout type="AUTOLAYOUT_TITLE_CONTENT"><presobj kind="PRESOBJ_TITLE" layout-pos-x="1400" layout-pos-y="837" layout-size-height="4400" layout-size-width="25600"/><presobj kind="PRESOBJ_OUTLINE1" layout-pos-x="1400" layout-pos-y="4914" layout-size-height="25200" layout-size-width="12180"/></layout>
<layout type="AUTOLAYOUT_TITLE_2VTEXT"><presobj kind="PRESOBJ_TITLE" layout-pos-x="1400" layout-pos-y="837" layout-size-height="4400" layout-size-width="25600"/><presobj kind="PRESOBJ_OUTLINE1" layout-pos-x="1400" layout-pos-y="4914" layout-size-height="12297" layout-size-width="12180"/><presobj kind="PRESOBJ_OUTLINE2" layout-pos-x="14311" layout-pos-y="4914" layout-size-height="12297" layout-size-width="12180"/></layout>
<layout type="AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT"><presobj kind="PRESOBJ_TITLE" layout-pos-x="1400" layout-pos-y="837" layout-size-height="4400" layout-size-width="25600"/><presobj kind="PRESOBJ_OUTLINE1" layout-pos-x="1400" layout-pos-y="4914" layout-size-height="25200" layout-size-width="5809"/><presobj kind="PRESOBJ_OUTLINE2" layout-pos-x="1400" layout-pos-y="11274" layout-size-height="25200" layout-size-width="5809"/></layout>
-</layout-list>
+</layout-list> \ No newline at end of file