From 7885ead7ee4ed8858655001bedd1b312c03a452b Mon Sep 17 00:00:00 2001 From: Vishv Brahmbhatt Date: Wed, 31 Jul 2013 01:58:58 +0530 Subject: Temporarily adding new methods to "drawdoc.cxx". Adding new methods to "SdDrawDocument" class to set the vector "layoutlist" from the constructor of "SdDrawDocument" and use it in "CalcAutoLayoutRectangles". Build got failed in-between,so authentication of it's working is left to be done. Change-Id: Ia614ab0e1d45022d770e61d27b0ae6c74dc71bf8 --- sd/inc/drawdoc.hxx | 6 +++- sd/source/core/drawdoc.cxx | 88 ++++++++++++++++++++++++++++++++++++++++++++++ sd/xml/layoutlist.xml | 22 ++++++------ 3 files changed, 104 insertions(+), 12 deletions(-) diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx index f33cfdedaeb4..58736028422c 100644 --- a/sd/inc/drawdoc.hxx +++ b/sd/inc/drawdoc.hxx @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -188,6 +189,7 @@ private: DECL_LINK(OnlineSpellEventHdl, EditStatus*); std::vector< OUString > maAnnotationAuthors; + std::vector> layoutinfo; bool mbUseEmbedFonts; @@ -262,6 +264,9 @@ public: bool IsExitAfterPresenting() const; void SetExitAfterPresenting( bool bExitAfterPresenting ); + void SetLayoutVector(); + std::vector> GetLayoutVector(); + /** Insert pages into this document This method inserts whole pages into this document, either @@ -307,7 +312,6 @@ public: Whether the replace operation should take the name from the new page, or preserve the old name */ - sal_Bool InsertBookmarkAsPage(const std::vector &rBookmarkList, std::vector *pExchangeList, sal_Bool bLink, sal_Bool bReplace, sal_uInt16 nPgPos, diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index 60fa917a0bc3..9f56101a14c6 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -61,6 +61,22 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include "drawdoc.hxx" @@ -89,6 +105,13 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; 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 ); @@ -169,6 +192,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) mpMasterPageListWatcher = ::std::auto_ptr( new ImpMasterPageListWatcher(*this)); + SetLayoutVector(); SetObjectShell(pDrDocSh); // for VCDrawModel if (mpDocSh) @@ -988,4 +1012,68 @@ sal_uInt16 SdDrawDocument::GetAnnotationAuthorIndex( const OUString& rAuthor ) return idx; } +#define EXPAND_PROTOCOL "vnd.sun.star.expand:" +// to get the root element of the xml file +Reference getRoot() +{ + const Reference 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 ); + + Any propValue = uno::makeAny( + beans::PropertyValue( + "nodepath", -1, + uno::makeAny( OUString( "/org.openoffice.Office.Impress/Misc" )), + beans::PropertyState_DIRECT_VALUE ) ); + + Reference xNameAccess( + xConfigProvider->createInstanceWithArguments( + "com.sun.star.configuration.ConfigurationAccess", + Sequence( &propValue, 1 ) ), UNO_QUERY_THROW ); + Sequence< rtl::OUString > aFiles; + xNameAccess->getByName( "LayoutListFiles" ) >>= aFiles; + rtl::OUString aURL; + for( sal_Int32 i=0; iexpandMacros( aMacro ); + } + } + if( aURL.startsWith( "file://" ) ) + { + rtl::OUString aSysPath; + if( osl_getSystemPathFromFileURL( aURL.pData, &aSysPath.pData ) == osl_File_E_None ) + aURL = aSysPath; + } + const Reference xDocBuilder(css::xml::dom::DocumentBuilder::create(comphelper::getComponentContext(xServiceFactory))); + const Reference xDoc = xDocBuilder->parseURI(aURL); + const Reference xRoot = xDoc->getDocumentElement(); + return xRoot;//this loops seems to work only once,so temporary returning the root element +} + +void SdDrawDocument::SetLayoutVector() +{ + int layoutlistsize; + const Reference root= getRoot();//get the root element of my xml file + const Reference layoutlist = root->getElementsByTagName("layout"); + layoutlistsize=layoutlist->getLength(); + for(int index=0; index layoutnode = layoutlist->item(index); //get i'th layout element + layoutinfo.push_back(layoutnode); + } +} + +std::vector> GetLayoutVector() +{ + return layoutinfo; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/xml/layoutlist.xml b/sd/xml/layoutlist.xml index 82424b071481..727e5a8bb86a 100644 --- a/sd/xml/layoutlist.xml +++ b/sd/xml/layoutlist.xml @@ -18,20 +18,20 @@ - - - + + + - - - - + + + + - + @@ -50,9 +50,9 @@ - - - + + + -- cgit