officecfg/registry/schema/org/openoffice/Office/Impress.xcs | 14 ++ sd/Package_xml.mk | 1 sd/source/core/sdpage.cxx | 59 +++++++++++- sd/xml/layoutlist.xml | 8 + test/Package_unittest.mk | 1 5 files changed, 79 insertions(+), 4 deletions(-)
New commits: commit e2a23779c42a4b252706794dd7e89e975804c50e Author: Vishv Brahmbhatt <vishvbrahmbhat...@gmail.com> Date: Sat Jun 29 02:55:37 2013 +0530 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 diff --git a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs index 8161806..fcb0e74 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs @@ -468,6 +468,20 @@ <label>List of files containing object effects</label> </info> <value oor:separator=";">vnd.sun.star.expand:$BRAND_BASE_DIR/share/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/share/config/soffice.cfg/simpress/layoutlist.xml</value> + </prop> </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 94e9607..3c997e0 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,share/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 9dbe297..1bcda69 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 0000000..0b1e9d9 --- /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 df87356..4c1d9ad 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)) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits