From 20ee726d6f6ca7bd72de9a6cfc4d73b5292c7ce0 Mon Sep 17 00:00:00 2001 From: Vishv Brahmbhatt Date: Mon, 5 Aug 2013 20:18:29 +0530 Subject: Few changes to "drawdoc.cxx". Prettifying some of the code in "drawdoc.cxx".Also few changes related to static_cast is left to be discussed.It will be pushed in the next commit. Change-Id: I30e7550de4e8c40ba100dbe178f357763bee8ca4 --- sd/inc/drawdoc.hxx | 4 ++-- sd/source/core/drawdoc.cxx | 31 ++++++++++++++++--------------- sd/source/core/sdpage.cxx | 8 +++----- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx index ed892040aac4..88d11c92793d 100644 --- a/sd/inc/drawdoc.hxx +++ b/sd/inc/drawdoc.hxx @@ -189,7 +189,7 @@ private: DECL_LINK(OnlineSpellEventHdl, EditStatus*); std::vector< OUString > maAnnotationAuthors; - std::vector> malayoutinfo; + std::vector> maLayoutInfo; bool mbUseEmbedFonts; @@ -265,7 +265,7 @@ public: void SetExitAfterPresenting( bool bExitAfterPresenting ); void SetLayoutVector(); - inline std::vector>& GetLayoutVector(){ return malayoutinfo; } + std::vector> &GetLayoutVector() { return maLayoutInfo; } /** Insert pages into this document diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index 7c0525b78746..d1c6bde6a770 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -76,7 +76,6 @@ #include #include #include -#include #include #include "drawdoc.hxx" @@ -1012,14 +1011,13 @@ 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 ); + 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( @@ -1034,41 +1032,44 @@ Reference getRoot() 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 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 + return xRoot; //this loops seems to work only once,so returning the root element } void SdDrawDocument::SetLayoutVector() { int layoutlistsize; - const Reference root= getRoot();//get the root element of my xml file + 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 - malayoutinfo.push_back(layoutnode); + maLayoutInfo.push_back(layoutnode); } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index c73f13993971..c3316be80a79 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -1117,7 +1117,6 @@ Rectangle SdPage::GetLayoutRect() const const int MAX_PRESOBJS = 7; // maximum number of presentation objects per layout const int VERTICAL = 0x8000; const int PRESOBJPROP = 4; -std::vector> layoutinfo; //temporarily at global scope struct LayoutDescriptor { @@ -1244,7 +1243,6 @@ static void CalcAutoLayoutRectangles( SdPage& rPage, int nLayout, Rectangle* rRe rtl::OUString sLayoutAttName; rtl::OUString sPresObjKindAttName; double propvalue[4]; - std::vector> malayoutinfo; if( rPage.GetPageKind() != PK_HANDOUT ) { @@ -1285,10 +1283,10 @@ static void CalcAutoLayoutRectangles( SdPage& rPage, int nLayout, Rectangle* rRe aTempPnt = aLayoutPos; sal_Bool bRightToLeft = ( rPage.GetModel() && static_cast< SdDrawDocument* >( rPage.GetModel() )->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB ); - malayoutinfo = static_cast< SdDrawDocument* >( rPage.GetModel() )->GetLayoutVector(); //getting vector from "SdDrawDocument" - for(size_t y=0; y < malayoutinfo.size(); y++) //loop through vector of Xnodes + std::vector> &layoutinfo = static_cast< SdDrawDocument* >( rPage.GetModel() )->GetLayoutVector(); //getting vector from "SdDrawDocument" ,not sure about the correct mechanism + for(size_t y=0; y < layoutinfo.size(); y++) //loop through vector of Xnodes { - Reference layoutnode = malayoutinfo[y]; //get i'th layout element + Reference layoutnode = layoutinfo[y]; //get i'th layout element Reference layoutattrlist =layoutnode->getAttributes(); Reference layoutattr = layoutattrlist->getNamedItem("type"); sLayoutAttName=layoutattr->getNodeValue(); //get the attribute value of layout(i.e it's type) -- cgit