Kaydet (Commit) d50bd55c authored tarafından Vishv Brahmbhatt's avatar Vishv Brahmbhatt Kaydeden (comit) Thorsten Behrens

Parsing master presentation objects from 'objectlist.xml'

Parsing the property values of master presentation objects.
Also new functions added to comphelper module for expanding
filepaths macro to appropriate system file paths(for
configuration files present at 'Impress.xcs')

Change-Id: If0381a12155673e85103ddb5d51c34ae53fe2ecb
üst b1e46499
......@@ -86,6 +86,7 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\
comphelper/source/misc/documentiologring \
comphelper/source/misc/evtlistenerhlp \
comphelper/source/misc/evtmethodhelper \
comphelper/source/misc/expandmacro \
comphelper/source/misc/ihwrapnofilter \
comphelper/source/misc/instancelocker \
comphelper/source/misc/interaction \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <comphelper/expandmacro.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/util/theMacroExpander.hpp>
#include <rtl/ustring.hxx>
#include <rtl/uri.hxx>
#include <osl/file.h>
#include <comphelper/processfactory.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using ::com::sun::star::lang::XMultiServiceFactory;
namespace comphelper
{
rtl::OUString getExpandedFilePath(const rtl::OUString& filepath)
{
const Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
return getExpandedFilePath(filepath, xContext);
}
rtl::OUString getExpandedFilePath(const rtl::OUString& filepath, const Reference<XComponentContext>& xContext)
{
Reference< util::XMacroExpander > xMacroExpander = util::theMacroExpander::get( xContext );
rtl::OUString aFilename = filepath;
if( aFilename.startsWith( "vnd.sun.star.expand:" ) )
{
// cut protocol
rtl::OUString aMacro( aFilename.copy( sizeof ( "vnd.sun.star.expand:" ) -1 ) );
// decode uric class chars
aMacro = rtl::Uri::decode( aMacro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
// expand macro string
aFilename = xMacroExpander->expandMacros( aMacro );
}
if( aFilename.startsWith( "file://" ) )
{
rtl::OUString aSysPath;
if( osl_getSystemPathFromFileURL( aFilename.pData, &aSysPath.pData ) == osl_File_E_None )
aFilename = aSysPath;
}
return aFilename;
}
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef COMPHELPER_EXPANDMACRO_HXX_INCLUDED
#define COMPHELPER_EXPANDMACRO_HXX_INCLUDED
#include "rtl/ustring.hxx"
#include "comphelper/comphelperdllapi.h"
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
namespace comphelper
{
/**
A helper function to get expanded version of macro for filepaths.
If the given path is prefixed by "vnd.sun.star.expand:", this
function substitutes contained macro references. It then always
returns a system file path, if necessary converting file
URIs. Example:
vnd.sun.star.expand:$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR gets
converted to e.g. /usr/lib64/libreoffice/share.
@param path to operate on. Both system file path and file URIs are accepted.
@return macro-expanded system file path.
*/
COMPHELPER_DLLPUBLIC rtl::OUString getExpandedFilePath(const rtl::OUString& filepath);
/**
A helper function to get expanded version of macro for filepaths.
If the given path is prefixed by "vnd.sun.star.expand:", this
function substitutes contained macro references. It then always
returns a system file path, if necessary converting file
URIs. Example:
vnd.sun.star.expand:$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR gets
converted to e.g. /usr/lib64/libreoffice/share.
Use this version if you have a local reference of a component
context at hand, saves us the extra lookup.
@param path to operate on. Both system file path and file URIs are accepted.
@param xContext refers to the component context of the process.
@return macro-expanded system file path.
*/
COMPHELPER_DLLPUBLIC rtl::OUString getExpandedFilePath(const rtl::OUString& filepath,
const ::com::sun::star::uno::Reference<css::uno::XComponentContext>& xContext);
}
#endif
......@@ -482,6 +482,20 @@
</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="PresObjListFiles" oor:type="oor:string-list" oor:nillable="false">
<info>
<desc>
Contains a list of xml files defining the presentation
object used in the master page of "notes" and "handout".
It contains properties of presentation objects,like
their position, width, and height. Entries are run
through macro expansion, so, vnd.sun.star.expand prefix is
allowed.
</desc>
<label>List of files containing master presentation objects</label>
</info>
<value oor:separator=";">vnd.sun.star.expand:$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/config/soffice.cfg/simpress/objectlist.xml</value>
</prop>
<prop oor:name="PreviewNewEffects" oor:type="xs:boolean" oor:nillable="false">
<!-- OldPath: -->
<!-- OldLocation: -->
......
......@@ -15,6 +15,7 @@ $(eval $(call gb_Package_add_files,sd_xml,$(LIBO_SHARE_FOLDER)/config/soffice.cf
effects.xml \
transitions.xml \
layoutlist.xml \
objectlist.xml \
))
# vim: set noet sw=4 ts=4:
......@@ -192,6 +192,9 @@ private:
std::vector<com::sun::star::uno::Reference<
com::sun::star::xml::dom::XNode> > maLayoutInfo;
std::vector<com::sun::star::uno::Reference<
com::sun::star::xml::dom::XNode> > maPresObjectInfo;
bool mbUseEmbedFonts;
protected:
......@@ -272,6 +275,10 @@ public:
com::sun::star::xml::dom::XNode> >& GetLayoutVector() const
{ return maLayoutInfo; }
/// load xml-based impress master presentation object definitions into document
void InitObjectVector();
/// return reference to vector of master presentation object definitions
const std::vector<com::sun::star::uno::Reference<com::sun::star::xml::dom::XNode>>& GetObjectVector() const { return maPresObjectInfo; }
/** Insert pages into this document
This method inserts whole pages into this document, either
......@@ -317,6 +324,7 @@ public:
Whether the replace operation should take the name from the new
page, or preserve the old name
*/
sal_Bool InsertBookmarkAsPage(const std::vector<OUString> &rBookmarkList,
std::vector<OUString> *pExchangeList,
sal_Bool bLink, sal_Bool bReplace, sal_uInt16 nPgPos,
......
......@@ -70,11 +70,9 @@
#include <com/sun/star/xml/dom/XNamedNodeMap.hpp>
#include <com/sun/star/xml/dom/DocumentBuilder.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/util/theMacroExpander.hpp>
#include <rtl/ustring.hxx>
#include <rtl/uri.hxx>
#include <osl/file.h>
#include <comphelper/expandmacro.hxx>
#include <editeng/outliner.hxx>
#include "drawdoc.hxx"
......@@ -105,9 +103,7 @@ using namespace ::com::sun::star::linguistic2;
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;
TYPEINIT1( SdDrawDocument, FmFormModel );
......@@ -183,6 +179,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh)
new ImpMasterPageListWatcher(*this));
InitLayoutVector();
InitObjectVector();
SetObjectShell(pDrDocSh); // for VCDrawModel
if (mpDocSh)
......@@ -995,36 +992,16 @@ void SdDrawDocument::InitLayoutVector()
{
const Reference<css::uno::XComponentContext> xContext(
::comphelper::getProcessComponentContext() );
Reference< util::XMacroExpander > xMacroExpander(
util::theMacroExpander::get( xContext ) );
// get file list from configuration
Sequence< rtl::OUString > aFiles(
officecfg::Office::Impress::Misc::LayoutListFiles::get(xContext) );
// loop over each file in sequence
rtl::OUString aFilename;
rtl::OUString sFilename;
for( sal_Int32 i=0; i < aFiles.getLength(); ++i )
{
aFilename = aFiles[i];
if( aFilename.startsWith( "vnd.sun.star.expand:" ) )
{
// cut protocol
rtl::OUString aMacro( aFilename.copy( sizeof ( "vnd.sun.star.expand:" ) -1 ) );
// decode uric class chars
aMacro = rtl::Uri::decode( aMacro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
// expand macro string
aFilename = xMacroExpander->expandMacros( aMacro );
}
if( aFilename.startsWith( "file://" ) )
{
rtl::OUString aSysPath;
if( osl_getSystemPathFromFileURL( aFilename.pData, &aSysPath.pData ) == osl_File_E_None )
aFilename = aSysPath;
}
rtl::OUString filepath = aFiles[i];
sFilename= ::comphelper::getExpandedFilePath(filepath,xContext);
// load layout file into DOM
Reference< XMultiServiceFactory > xServiceFactory(
......@@ -1033,7 +1010,7 @@ void SdDrawDocument::InitLayoutVector()
DocumentBuilder::create( comphelper::getComponentContext (xServiceFactory) ));
// loop over every layout entry in current file
const Reference<XDocument> xDoc = xDocBuilder->parseURI( aFilename );
const Reference<XDocument> xDoc = xDocBuilder->parseURI( sFilename );
const Reference<XNodeList> layoutlist = xDoc->getElementsByTagName("layout");
const int nElements = layoutlist->getLength();
for(int index=0; index < nElements; index++)
......@@ -1041,4 +1018,33 @@ void SdDrawDocument::InitLayoutVector()
}
}
void SdDrawDocument::InitObjectVector()
{
const Reference<css::uno::XComponentContext> xContext(
::comphelper::getProcessComponentContext() );
// get file list from configuration
Sequence< rtl::OUString > aFiles(
officecfg::Office::Impress::Misc::PresObjListFiles::get(xContext) );
rtl::OUString sFilename;
for( sal_Int32 i=0; i < aFiles.getLength(); ++i )
{
rtl::OUString filepath = aFiles[i];
sFilename= ::comphelper::getExpandedFilePath(filepath,xContext);
// load presentation object file into DOM
Reference< XMultiServiceFactory > xServiceFactory(
xContext->getServiceManager() , UNO_QUERY_THROW );
const Reference<XDocumentBuilder> xDocBuilder(
DocumentBuilder::create( comphelper::getComponentContext (xServiceFactory) ));
// loop over every object entry in current file
const Reference<XDocument> xDoc = xDocBuilder->parseURI( sFilename );
const Reference<XNodeList> objectlist = xDoc->getElementsByTagName("object");
const int nElements = objectlist->getLength();
for(int index=0; index < nElements; index++)
maPresObjectInfo.push_back( objectlist->item(index) );
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
-->
<object-list>
<object pagekind="PK_STANDARD" type="PRESOBJ_DATETIME" relative-height="0.069" relative-width="0.233" relative-posX="0.05" relative-posY="0.911"/>
<object pagekind="PK_HANDOUT" type="PRESOBJ_DATETIME" relative-height="0.434" relative-width="0.05" relative-posX="0.434" relative-posY="0"/>
<object pagekind="PK_NOTES" type="PRESOBJ_DATETIME" relative-height="0.434" relative-width="0.05" relative-posX="0.434" relative-posY="0"/>
<object pagekind="PK_STANDARD" type="PRESOBJ_FOOTER" relative-height="0.069" relative-width="0.317" relative-posX="0.342" relative-posY="0.911"/>
<object pagekind="PK_HANDOUT" type="PRESOBJ_FOOTER" relative-height="0.434" relative-width="0.05" relative-posX="0" relative-posY="0.05"/>
<object pagekind="PK_NOTES" type="PRESOBJ_FOOTER" relative-height="0.434" relative-width="0.05" relative-posX="0" relative-posY="0.05"/>
<object pagekind="PK_STANDARD" type="PRESOBJ_SLIDENUMBER" relative-height="0.069" relative-width="0.317" relative-posX="0.717" relative-posY="0.911"/>
<object pagekind="PK_HANDOUT" type="PRESOBJ_SLIDENUMBER" relative-height="0.434" relative-width="0.05" relative-posX="0" relative-posY="0.05"/>
<object pagekind="PK_NOTES" type="PRESOBJ_SLIDENUMBER" relative-height="0.434" relative-width="0.05" relative-posX="0" relative-posY="0.05"/>
<object pagekind="PK_STANDARD" type="PRESOBJ_HEADER" relative-height="0.069" relative-width="0.317" relative-posX="0.717" relative-posY="0.911"/>
<object pagekind="PK_HANDOUT" type="PRESOBJ_HEADER" relative-height="0.434" relative-width="0.05" relative-posX="0" relative-posY="0"/>
<object pagekind="PK_NOTES" type="PRESOBJ_HEADER" relative-height="0.434" relative-width="0.05" relative-posX="0" relative-posY="0"/>
<object pagekind="PK_STANDARD" type="PRESOBJ_TITLE" relative-height="0.167" relative-width="0.9" relative-posX="0.05" relative-posY="0.0399"/>
<object pagekind="PK_NOTES" type="PRESOBJ_TITLE" relative-height="0.375" relative-width="1" relative-posX="0" relative-posY="0.076"/>
<object pagekind="PK_STANDARD" type="PRESOBJ_OUTLINE" relative-height="0.58" relative-width="0.9" relative-posX="0.05" relative-posY="0.234"/>
<object pagekind="PK_NOTES" type="PRESOBJ_OUTLINE" relative-height="0.45" relative-width="0.1" relative-posX="0.1" relative-posY="0.475"/>
<object type="PRESOBJ_DATETIME">
<object-prop pagekind="PK_STANDARD" relative-height="0.069" relative-width="0.233" relative-posX="0.05" relative-posY="0.911"/>
<object-prop pagekind="PK_HANDOUT" relative-height="0.05" relative-width="0.434" relative-posX="0.434" relative-posY="0"/>
<object-prop pagekind="PK_NOTES" relative-height="0.05" relative-width="0.434" relative-posX="0.434" relative-posY="0"/>
</object>
<object type="PRESOBJ_FOOTER">
<object-prop pagekind="PK_STANDARD" relative-height="0.069" relative-width="0.317" relative-posX="0.342" relative-posY="0.911"/>
<object-prop pagekind="PK_HANDOUT" relative-height="0.05" relative-width="0.434" relative-posX="0" relative-posY="0.05"/>
<object-prop pagekind="PK_NOTES" relative-height="0.05" relative-width="0.434" relative-posX="0" relative-posY="0.05"/>
</object>
<object type="PRESOBJ_SLIDENUMBER">
<object-prop pagekind="PK_STANDARD" relative-height="0.069" relative-width="0.233" relative-posX="0.717" relative-posY="0.911"/>
<object-prop pagekind="PK_HANDOUT" relative-height="0.05" relative-width="0.434" relative-posX="0.434" relative-posY="0.05"/>
<object-prop pagekind="PK_NOTES" relative-height="0.05" relative-width="0.434" relative-posX="0.434" relative-posY="0.05"/>
</object>
<object type="PRESOBJ_HEADER">
<object-prop pagekind="PK_STANDARD" relative-height="0.069" relative-width="0.317" relative-posX="0.717" relative-posY="0.911"/>
<object-prop pagekind="PK_HANDOUT" relative-height="0.05" relative-width="0.434" relative-posX="0" relative-posY="0"/>
<object-prop pagekind="PK_NOTES" relative-height="0.05" relative-width="0.434" relative-posX="0" relative-posY="0"/>
</object>
<object type="PRESOBJ_TITLE">
<object-prop pagekind="PK_STANDARD" relative-height="0.167" relative-width="0.9" relative-posX="0.05" relative-posY="0.0399"/>
<object-prop pagekind="PK_NOTES" relative-height="0.375" relative-width="1" relative-posX="0" relative-posY="0.076"/>
</object>
<object type="PRESOBJ_OUTLINE">
<object-prop pagekind="PK_STANDARD" relative-height="0.58" relative-width="0.9" relative-posX="0.05" relative-posY="0.234"/>
</object>
<object type="PRESOBJ_NOTES">
<object-prop pagekind="PK_NOTES" relative-height="0.45" relative-width="0.8" relative-posX="0.1" relative-posY="0.475"/>
</object>
</object-list>
\ No newline at end of file
......@@ -23,6 +23,7 @@ $(eval $(call gb_Package_add_file,test_unittest,unittest/install/share/config/so
$(eval $(call gb_Package_add_file,test_unittest,unittest/install/share/config/soffice.cfg/simpress/transitions-ogl.xml,user/config/soffice.cfg/simpress/transitions-ogl.xml))
$(eval $(call gb_Package_add_file,test_unittest,unittest/install/share/config/soffice.cfg/simpress/effects.xml,user/config/soffice.cfg/simpress/effects.xml))
$(eval $(call gb_Package_add_file,test_unittest,unittest/install/share/config/soffice.cfg/simpress/layoutlist.xml,user/config/soffice.cfg/simpress/layoutlist.xml))
$(eval $(call gb_Package_add_file,test_unittest,unittest/install/share/config/soffice.cfg/simpress/objectlist.xml,user/config/soffice.cfg/simpress/objectlist.xml))
$(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/psetupl.xpm,user/config/psetupl.xpm))
# vim: set noet sw=4 ts=4:
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
-->
<object-list>
<object type="PRESOBJ_DATETIME">
<object-prop pagekind="PK_STANDARD" relative-height="0.069" relative-width="0.233" relative-posX="0.05" relative-posY="0.911"/>
<object-prop pagekind="PK_HANDOUT" relative-height="0.05" relative-width="0.434" relative-posX="0.434" relative-posY="0"/>
<object-prop pagekind="PK_NOTES" relative-height="0.05" relative-width="0.434" relative-posX="0.434" relative-posY="0"/>
</object>
<object type="PRESOBJ_FOOTER">
<object-prop pagekind="PK_STANDARD" relative-height="0.069" relative-width="0.317" relative-posX="0.342" relative-posY="0.911"/>
<object-prop pagekind="PK_HANDOUT" relative-height="0.05" relative-width="0.434" relative-posX="0" relative-posY="0.05"/>
<object-prop pagekind="PK_NOTES" relative-height="0.05" relative-width="0.434" relative-posX="0" relative-posY="0.05"/>
</object>
<object type="PRESOBJ_SLIDENUMBER">
<object-prop pagekind="PK_STANDARD" relative-height="0.069" relative-width="0.233" relative-posX="0.717" relative-posY="0.911"/>
<object-prop pagekind="PK_HANDOUT" relative-height="0.05" relative-width="0.434" relative-posX="0.434" relative-posY="0.05"/>
<object-prop pagekind="PK_NOTES" relative-height="0.05" relative-width="0.434" relative-posX="0.434" relative-posY="0.05"/>
</object>
<object type="PRESOBJ_HEADER">
<object-prop pagekind="PK_STANDARD" relative-height="0.069" relative-width="0.317" relative-posX="0.717" relative-posY="0.911"/>
<object-prop pagekind="PK_HANDOUT" relative-height="0.05" relative-width="0.434" relative-posX="0" relative-posY="0"/>
<object-prop pagekind="PK_NOTES" relative-height="0.05" relative-width="0.434" relative-posX="0" relative-posY="0"/>
</object>
<object type="PRESOBJ_TITLE">
<object-prop pagekind="PK_STANDARD" relative-height="0.167" relative-width="0.9" relative-posX="0.05" relative-posY="0.0399"/>
<object-prop pagekind="PK_NOTES" relative-height="0.375" relative-width="1" relative-posX="0" relative-posY="0.076"/>
</object>
<object type="PRESOBJ_OUTLINE">
<object-prop pagekind="PK_STANDARD" relative-height="0.58" relative-width="0.9" relative-posX="0.05" relative-posY="0.234"/>
</object>
<object type="PRESOBJ_NOTES">
<object-prop pagekind="PK_NOTES" relative-height="0.45" relative-width="0.8" relative-posX="0.1" relative-posY="0.475"/>
</object>
</object-list>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment