sd/inc/drawdoc.hxx | 4 ++-- sd/source/core/drawdoc.cxx | 31 ++++++++++++++++--------------- sd/source/core/sdpage.cxx | 8 +++----- 3 files changed, 21 insertions(+), 22 deletions(-)
New commits: commit 6a239432895511dfc9ade58c683ad18f71ead822 Author: Vishv Brahmbhatt <vishvbrahmbhat...@gmail.com> Date: Mon Aug 5 20:18:29 2013 +0530 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 diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx index cce2bc5..2320885 100644 --- a/sd/inc/drawdoc.hxx +++ b/sd/inc/drawdoc.hxx @@ -188,7 +188,7 @@ private: DECL_LINK(OnlineSpellEventHdl, EditStatus*); std::vector< OUString > maAnnotationAuthors; - 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>> maLayoutInfo; bool mbUseEmbedFonts; @@ -260,7 +260,7 @@ public: bool IsStartWithPresentation() const; void SetStartWithPresentation( bool bStartWithPresentation ); void SetLayoutVector(); - inline std::vector<com::sun::star::uno::Reference<com::sun::star::xml::dom::XNode>>& GetLayoutVector(){ return malayoutinfo; } + std::vector<com::sun::star::uno::Reference<com::sun::star::xml::dom::XNode>> &GetLayoutVector() { return maLayoutInfo; } /** Insert pages into this document This method inserts whole pages into this document, either diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index f9ccd9e..dc631cf 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -77,7 +77,6 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <rtl/ustring.hxx> #include <rtl/uri.hxx> -#include <unotools/ucbstreamhelper.hxx> #include <editeng/outliner.hxx> #include "drawdoc.hxx" @@ -1002,14 +1001,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<XElement> getRoot() { - const Reference<css::uno::XComponentContext> 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<css::uno::XComponentContext> 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( @@ -1024,41 +1022,44 @@ Reference<XElement> getRoot() Sequence< rtl::OUString > aFiles; xNameAccess->getByName( "LayoutListFiles" ) >>= aFiles; rtl::OUString aURL; - for( sal_Int32 i=0; i<aFiles.getLength(); ++i ) + + for( sal_Int32 i=0; i < aFiles.getLength(); ++i ) { aURL = aFiles[i]; - if( aURL.startsWith( EXPAND_PROTOCOL ) ) + if( aURL.startsWith( "vnd.sun.star.expand:" ) ) { // cut protocol - rtl::OUString aMacro( aURL.copy( sizeof ( EXPAND_PROTOCOL ) -1 ) ); + rtl::OUString aMacro( aURL.copy( sizeof ( "vnd.sun.star.expand:" ) -1 ) ); // decode uric class chars aMacro = rtl::Uri::decode( aMacro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); // expand macro string aURL = xMacroExpander->expandMacros( aMacro ); } } + if( aURL.startsWith( "file://" ) ) { rtl::OUString aSysPath; if( osl_getSystemPathFromFileURL( aURL.pData, &aSysPath.pData ) == osl_File_E_None ) aURL = aSysPath; } - const Reference<XDocumentBuilder> xDocBuilder(css::xml::dom::DocumentBuilder::create(comphelper::getComponentContext(xServiceFactory))); - const Reference<XDocument> xDoc = xDocBuilder->parseURI(aURL); + + const Reference<XDocumentBuilder> xDocBuilder( css::xml::dom::DocumentBuilder::create( comphelper::getComponentContext (xServiceFactory)) ); + const Reference<XDocument> xDoc = xDocBuilder->parseURI( aURL ); const Reference<XElement> 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<XElement> root= getRoot();//get the root element of my xml file + const Reference<XElement> root = getRoot(); //get the root element of my xml file const Reference<XNodeList> layoutlist = root->getElementsByTagName("layout"); layoutlistsize=layoutlist->getLength(); - for(int index=0; index<layoutlistsize ;index++) + for(int index=0; index < layoutlistsize; index++) { Reference<XNode> 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 715753b..f6cb6a0 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<Reference<XNode>> 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<Reference<XNode>> 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<Reference<XNode>> &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<XNode> layoutnode = malayoutinfo[y]; //get i'th layout element + Reference<XNode> layoutnode = layoutinfo[y]; //get i'th layout element Reference<XNamedNodeMap> layoutattrlist =layoutnode->getAttributes(); Reference<XNode> layoutattr = layoutattrlist->getNamedItem("type"); sLayoutAttName=layoutattr->getNodeValue(); //get the attribute value of layout(i.e it's type) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits