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
This commit is contained in:
parent
4a281debd2
commit
2fd74b3b15
4 changed files with 30 additions and 21 deletions
|
@ -468,15 +468,15 @@
|
|||
<label>List of files containing object effects</label>
|
||||
</info>
|
||||
<value oor:separator=";">vnd.sun.star.expand:$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/config/soffice.cfg/simpress/effects.xml</value>
|
||||
</prop>
|
||||
<prop oor:name="LayoutListFiles" oor:type="oor:string-list" oor:nillable="false">
|
||||
<!-- OldPath: -->
|
||||
<!-- OldLocation: -->
|
||||
<!-- UIHints: List of files containing object effects -->
|
||||
<info>
|
||||
<desc>
|
||||
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.
|
||||
</desc>
|
||||
<label>List of files containing list of layouts</label>
|
||||
</info>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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>
|
|
@ -0,0 +1,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>
|
Loading…
Reference in a new issue