diff options
author | Thorsten Behrens <tbehrens@suse.com> | 2013-03-13 20:54:06 +0100 |
---|---|---|
committer | Thorsten Behrens <tbehrens@suse.com> | 2013-03-13 20:58:52 +0100 |
commit | 83e1044d939285f90a3e1adbc67d1c4d08cb5c58 (patch) | |
tree | 900694e46a8c3c84bb94b56d420db237d240df26 /oox/inc | |
parent | 8131b3892a6d7b287075a3ccb50f947a63e42e33 (diff) |
Cleanup pptx comment import patch a bit.
This cleans up 856756ec77ac64d1caee6c1b80c3641d4e487b2d a bit:
* add vim footer for new file
* use UpperCamelCase for class names
* use const references for parameter / bulk object passing
* indent properly
* don't mix private/public class members randomly
* use customary exception object, actually handle the error
* stick comment classes into oox namespace
* use 'ma' class member prefixes where applicable
Change-Id: I98021415331e62a8ee583ecfd27829f7dbfbc498
Diffstat (limited to 'oox/inc')
-rw-r--r-- | oox/inc/oox/ppt/comments.hxx | 100 | ||||
-rw-r--r-- | oox/inc/oox/ppt/presentationfragmenthandler.hxx | 6 | ||||
-rw-r--r-- | oox/inc/oox/ppt/slidefragmenthandler.hxx | 11 | ||||
-rw-r--r-- | oox/inc/oox/ppt/slidepersist.hxx | 15 |
4 files changed, 64 insertions, 68 deletions
diff --git a/oox/inc/oox/ppt/comments.hxx b/oox/inc/oox/ppt/comments.hxx index 44ea442c614c..81bcb78eaea9 100644 --- a/oox/inc/oox/ppt/comments.hxx +++ b/oox/inc/oox/ppt/comments.hxx @@ -11,16 +11,15 @@ #ifndef OOX_PPT_COMMENTS_HXX #define OOX_PPT_COMMENTS_HXX -#define ELEMENT_NOT_FOUND 0 - -using rtl::OUString; #include <vector> #include <boost/algorithm/string.hpp> //split function to tokenize for date time #include <com/sun/star/util/DateTime.hpp> +#include <com/sun/star/lang/IllegalArgumentException.hpp> +namespace oox { namespace ppt { -struct commentAuthor +struct CommentAuthor { ::rtl::OUString clrIdx; ::rtl::OUString id; @@ -29,17 +28,18 @@ struct commentAuthor ::rtl::OUString name; }; -class commentAuthorList +class CommentAuthorList { private: - std::vector<commentAuthor> cmAuthorLst; + std::vector<CommentAuthor> cmAuthorLst; + public: - void setValues( commentAuthorList list) + void setValues(const CommentAuthorList& list) { - std::vector<commentAuthor>::iterator it; - for(it=list.cmAuthorLst.begin();it!=list.cmAuthorLst.end();it++) + std::vector<CommentAuthor>::const_iterator it; + for(it = list.cmAuthorLst.begin(); it != list.cmAuthorLst.end(); ++it) { - commentAuthor temp; + CommentAuthor temp; cmAuthorLst.push_back(temp); cmAuthorLst.back().clrIdx = it->clrIdx; cmAuthorLst.back().id = it->id; @@ -49,18 +49,20 @@ class commentAuthorList } } - std::vector<commentAuthor> getCmAuthorLst() + const std::vector<CommentAuthor>& getCmAuthorLst() const { return cmAuthorLst; } - void addAuthor(commentAuthor _author) + + void addAuthor(const CommentAuthor& _author) { cmAuthorLst.push_back(_author); } - friend class comment; + + friend class Comment; }; -class comment +class Comment { private: ::rtl::OUString authorId; @@ -71,21 +73,36 @@ class comment ::rtl::OUString text; ::com::sun::star::util::DateTime aDateTime; + //DateTime is saved as : 2013-01-10T15:53:26.000 + void setDateTime (::rtl::OUString datetime) + { + std::string _datetime = rtl::OUStringToOString(datetime, RTL_TEXTENCODING_UTF8).getStr(); + std::vector<std::string> _dt; + boost::split( _dt, _datetime, boost::is_any_of( "-:T" ) ); + aDateTime.Year = atoi(_dt.at(0).c_str()); + aDateTime.Month = atoi(_dt.at(1).c_str()); + aDateTime.Day = atoi(_dt.at(2).c_str()); + aDateTime.Hours = atoi(_dt.at(3).c_str()); + aDateTime.Minutes = atoi(_dt.at(4).c_str()); + aDateTime.HundredthSeconds = atoi(_dt.at(5).c_str()); + std::vector<std::string>::iterator i; + } + public: - void setAuthorId(::rtl::OUString _aId) + void setAuthorId(const ::rtl::OUString& _aId) { authorId = _aId; } - void setdt(::rtl::OUString _dt) + void setdt(const ::rtl::OUString& _dt) { dt=_dt; setDateTime(_dt); } - void setidx(::rtl::OUString _idx) + void setidx(const ::rtl::OUString& _idx) { idx=_idx; } - void setPoint(::rtl::OUString _x, ::rtl::OUString _y) + void setPoint(const ::rtl::OUString& _x, const ::rtl::OUString& _y) { x=_x; y=_y; @@ -94,28 +111,10 @@ class comment { text = rtl::OUString::createFromAscii ( _text.c_str() ); } - void setText(rtl::OUString _text) + void setText(const rtl::OUString& _text) { text = _text; } - - private: - //DateTime is saved as : 2013-01-10T15:53:26.000 - void setDateTime (::rtl::OUString datetime) - { - std::string _datetime = rtl::OUStringToOString(datetime, RTL_TEXTENCODING_UTF8).getStr(); - std::vector<std::string> _dt; - boost::split( _dt, _datetime, boost::is_any_of( "-:T" ) ); - aDateTime.Year = atoi(_dt.at(0).c_str()); - aDateTime.Month = atoi(_dt.at(1).c_str()); - aDateTime.Day = atoi(_dt.at(2).c_str()); - aDateTime.Hours = atoi(_dt.at(3).c_str()); - aDateTime.Minutes = atoi(_dt.at(4).c_str()); - aDateTime.HundredthSeconds = atoi(_dt.at(5).c_str()); - std::vector<std::string>::iterator i; - } - - public: ::rtl::OUString getAuthorId() { return authorId; @@ -154,42 +153,43 @@ class comment std::string temp = rtl::OUStringToOString(get_Y(), RTL_TEXTENCODING_UTF8).getStr(); return atoi(temp.c_str()); } - OUString getAuthor ( commentAuthorList list ) + OUString getAuthor ( const CommentAuthorList& list ) { std::string temp = rtl::OUStringToOString(authorId, RTL_TEXTENCODING_UTF8).getStr(); int aId = atoi(temp.c_str()); - std::vector<commentAuthor>::iterator it; - for(it = list.cmAuthorLst.begin(); it != list.cmAuthorLst.end(); it++) + std::vector<CommentAuthor>::const_iterator it; + for(it = list.cmAuthorLst.begin(); it != list.cmAuthorLst.end(); ++it) { temp = rtl::OUStringToOString(it->id, RTL_TEXTENCODING_UTF8).getStr(); int list_aId = atoi(temp.c_str()); std::string temp_a =rtl::OUStringToOString(it->name, RTL_TEXTENCODING_UTF8).getStr(); if(list_aId == aId) - { return it->name; - } - + return it->name; } - OUString _unknown = "Anonymous"; - return _unknown; + return OUString("Anonymous"); } }; -class commentList +class CommentList { public: - std::vector<comment> cmLst; + std::vector<Comment> cmLst; int getSize () { return (int)cmLst.size(); } - comment getCommentAtIndex (int index) + const Comment& getCommentAtIndex (int index) { if(index < (int)cmLst.size() && index >= 0) return cmLst.at(index); else - throw ELEMENT_NOT_FOUND; + throw css::lang::IllegalArgumentException(); } }; -#endif
\ No newline at end of file +} } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/oox/ppt/presentationfragmenthandler.hxx b/oox/inc/oox/ppt/presentationfragmenthandler.hxx index 8730352bc238..f6d0feb0897e 100644 --- a/oox/inc/oox/ppt/presentationfragmenthandler.hxx +++ b/oox/inc/oox/ppt/presentationfragmenthandler.hxx @@ -42,9 +42,6 @@ public: virtual ~PresentationFragmentHandler() throw(); virtual void finalizeImport(); virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); -private: - commentAuthorList AuthorList; - int readCommentAuthors; // read commentAuthors.xml only once protected: bool importSlide( const ::oox::core::FragmentHandlerRef& rxSlideFragmentHandler, @@ -63,6 +60,9 @@ private: ::com::sun::star::awt::Size maNotesSize; std::vector< CustomShow > maCustomShowList; + + CommentAuthorList maAuthorList; + bool mbCommentAuthorsRead; // read commentAuthors.xml only once }; } } diff --git a/oox/inc/oox/ppt/slidefragmenthandler.hxx b/oox/inc/oox/ppt/slidefragmenthandler.hxx index 6cd50ab9f7c7..b3a9c6745e87 100644 --- a/oox/inc/oox/ppt/slidefragmenthandler.hxx +++ b/oox/inc/oox/ppt/slidefragmenthandler.hxx @@ -39,7 +39,10 @@ public: virtual void finalizeImport(); virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ); - void onCharacters( const ::rtl::OUString& rChars ); + virtual void onCharacters( const ::rtl::OUString& rChars ); + + const ::std::vector< rtl::OUString>& getCharVector() { return maCharVector; } + protected: SlidePersistPtr mpSlidePersistPtr; ShapeLocation meShapeLocation; @@ -47,11 +50,7 @@ protected: private: ::rtl::OUString maSlideName; PropertyMap maSlideProperties; -private: - ::std::vector< rtl::OUString> charVector; // handle char in OnCharacters -public: - ::std::vector< rtl::OUString> getCharVector(void) { return charVector; } - + ::std::vector< rtl::OUString> maCharVector; // handle char in OnCharacters }; } } diff --git a/oox/inc/oox/ppt/slidepersist.hxx b/oox/inc/oox/ppt/slidepersist.hxx index 68caa18db34e..10274117b678 100644 --- a/oox/inc/oox/ppt/slidepersist.hxx +++ b/oox/inc/oox/ppt/slidepersist.hxx @@ -31,7 +31,6 @@ #include <com/sun/star/drawing/XDrawPage.hpp> #include <com/sun/star/animations/XAnimationNode.hpp> #include "oox/core/fragmenthandler.hxx" - #include "oox/ppt/comments.hxx" #include <list> @@ -118,14 +117,8 @@ public: ::oox::drawingml::ShapePtr getShape( const ::rtl::OUString & id ) { return maShapeMap[ id ]; } ::oox::drawingml::ShapeIdMap& getShapeMap() { return maShapeMap; } - //comments -private: - commentList commentsList; - commentAuthorList commentAuthors; - -public: - commentList* getCommentsList() { return &commentsList; } - commentAuthorList* getCommentAuthors() { return &commentAuthors; } + CommentList& getCommentsList() { return maCommentsList; } + CommentAuthorList& getCommentAuthors() { return maCommentAuthors; } private: rtl::OUString maPath; @@ -155,6 +148,10 @@ private: std::map< ::rtl::OUString, ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > > maAnimNodesMap; std::map< ::rtl::OUString, ::oox::drawingml::ShapePtr > maShapeMap; + + // slide comments + CommentList maCommentsList; + CommentAuthorList maCommentAuthors; }; } } |