diff options
author | Vishv Brahmbhatt <vishvbrahmbhatt19@gmail.com> | 2013-06-29 02:55:37 +0530 |
---|---|---|
committer | Thorsten Behrens <tbehrens@suse.com> | 2013-08-26 14:47:21 +0200 |
commit | 4a281debd23ac8604bb80978e5f26c0cfebcc4b0 (patch) | |
tree | b71992c3e5fa4bbc381525581a1257f00dab9c0d | |
parent | 58056cd73efbbda3065692427b69ed926700c9ca (diff) |
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
-rw-r--r-- | officecfg/registry/schema/org/openoffice/Office/Impress.xcs | 13 | ||||
-rw-r--r-- | sd/Package_xml.mk | 1 | ||||
-rw-r--r-- | sd/source/core/sdpage.cxx | 59 | ||||
-rw-r--r-- | sd/xml/layoutlist.xml | 8 | ||||
-rw-r--r-- | test/Package_unittest.mk | 1 |
5 files changed, 78 insertions, 4 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs index 77c23986ff78..75091d18ede6 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs @@ -468,6 +468,19 @@ <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 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 + </desc> + <label>List of files containing list of layouts</label> + </info> + <value oor:separator=";">vnd.sun.star.expand:$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/config/soffice.cfg/simpress/layoutlist.xml</value> </prop> <prop oor:name="PreviewNewEffects" oor:type="xs:boolean" oor:nillable="false"> <!-- OldPath: --> 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 <rtl/ustring.hxx> #include <comphelper/processfactory.hxx> #include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/util/theMacroExpander.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <unotools/streamwrap.hxx> +#include <rtl/uri.hxx> +#include <unotools/ucbstreamhelper.hxx> #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<XElement> getRootElement() { rtl::OUString filepath="/home/vishv/layoutlist.xml"; const Reference<css::uno::XComponentContext> xContext(comphelper_getProcessComponentContext()); - const Reference<XDocumentBuilder> xDocBuilder(css::xml::dom::DocumentBuilder::create(xContext)); - const Reference<XDocument> xDoc = xDocBuilder->parseURI(filepath); - const Reference<XElement> 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<container::XNameAccess> xNameAccess( + xConfigProvider->createInstanceWithArguments( + "com.sun.star.configuration.ConfigurationAccess", + Sequence<Any>( &propValue, 1 ) ), UNO_QUERY_THROW ); + uno::Sequence< OUString > aFiles; + xNameAccess->getByName( "LayoutListFiles" ) >>= aFiles; + + for( sal_Int32 i=0; i<aFiles.getLength(); ++i ) + { + OUString aURL = aFiles[i]; + if( aURL.startsWith( EXPAND_PROTOCOL ) ) + { + // cut protocol + 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 + } } //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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- 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> diff --git a/test/Package_unittest.mk b/test/Package_unittest.mk index df8735655d8c..4c1d9ad13038 100644 --- a/test/Package_unittest.mk +++ b/test/Package_unittest.mk @@ -25,6 +25,7 @@ $(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/psetup.xpm, $(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/soffice.cfg/simpress/transitions.xml,user/config/soffice.cfg/simpress/transitions.xml)) $(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/soffice.cfg/simpress/transitions-ogl.xml,user/config/soffice.cfg/simpress/transitions-ogl.xml)) $(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/soffice.cfg/simpress/effects.xml,user/config/soffice.cfg/simpress/effects.xml)) +$(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/soffice.cfg/simpress/layoutlist.xml,user/config/soffice.cfg/simpress/layoutlist.xml)) $(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/soffice.cfg/modules/empty_directory,user/config/soffice.cfg/modules/empty_directory)) $(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/psetupl.xpm,user/config/psetupl.xpm)) $(eval $(call gb_Package_add_file,test_unittest,unittest/user/autocorr/empty_directory,user/autocorr/empty_directory)) |