summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Behrens <tbehrens@suse.com>2013-03-14 12:52:03 +0100
committerThorsten Behrens <tbehrens@suse.com>2013-03-14 13:47:02 +0100
commit42f9c7f8364818e91c95cf3dae8ab9ae6f1b561e (patch)
tree0bab14f7aa790aec6816519b35f0a6259b676fc4
parentd7093ec5942c0c40ac34e3b48bd12ca003ecc876 (diff)
More cleanup of pptx comment import code.
- moved non-trivial code out of header file - replaced all std::string occurences with OUString - binned boost/atoi string parsing in favour of builtins. Change-Id: I872e18e33ae9b997e041b4ccc26f80e79b54052b
-rw-r--r--oox/Library_oox.mk1
-rw-r--r--oox/inc/oox/ppt/comments.hxx72
-rw-r--r--oox/source/ppt/comments.cxx65
3 files changed, 74 insertions, 64 deletions
diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index 303b21f25a7e..e4682563a6c8 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -253,6 +253,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\
oox/source/ppt/animvariantcontext \
oox/source/ppt/backgroundproperties \
oox/source/ppt/buildlistcontext \
+ oox/source/ppt/comments \
oox/source/ppt/commonbehaviorcontext \
oox/source/ppt/commontimenodecontext \
oox/source/ppt/conditioncontext \
diff --git a/oox/inc/oox/ppt/comments.hxx b/oox/inc/oox/ppt/comments.hxx
index 81bcb78eaea9..fe718db36efa 100644
--- a/oox/inc/oox/ppt/comments.hxx
+++ b/oox/inc/oox/ppt/comments.hxx
@@ -12,10 +12,7 @@
#define OOX_PPT_COMMENTS_HXX
#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 {
@@ -34,20 +31,7 @@ class CommentAuthorList
std::vector<CommentAuthor> cmAuthorLst;
public:
- void setValues(const CommentAuthorList& list)
- {
- std::vector<CommentAuthor>::const_iterator it;
- for(it = list.cmAuthorLst.begin(); it != list.cmAuthorLst.end(); ++it)
- {
- CommentAuthor temp;
- cmAuthorLst.push_back(temp);
- cmAuthorLst.back().clrIdx = it->clrIdx;
- cmAuthorLst.back().id = it->id;
- cmAuthorLst.back().initials = it->initials;
- cmAuthorLst.back().lastIdx = it->lastIdx;
- cmAuthorLst.back().name = it->name;
- }
- }
+ void setValues(const CommentAuthorList& list);
const std::vector<CommentAuthor>& getCmAuthorLst() const
{
@@ -73,20 +57,7 @@ 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;
- }
+ void setDateTime (::rtl::OUString datetime);
public:
void setAuthorId(const ::rtl::OUString& _aId)
@@ -107,10 +78,6 @@ class Comment
x=_x;
y=_y;
}
- void setText(std::string _text)
- {
- text = rtl::OUString::createFromAscii ( _text.c_str() );
- }
void setText(const rtl::OUString& _text)
{
text = _text;
@@ -143,32 +110,15 @@ class Comment
{
return aDateTime;
}
- int getIntX()
- {
- std::string temp = rtl::OUStringToOString(get_X(), RTL_TEXTENCODING_UTF8).getStr();
- return atoi(temp.c_str());
- }
- int getIntY()
+ sal_Int32 getIntX()
{
- std::string temp = rtl::OUStringToOString(get_Y(), RTL_TEXTENCODING_UTF8).getStr();
- return atoi(temp.c_str());
+ return x.toInt32();
}
- OUString getAuthor ( const CommentAuthorList& list )
+ sal_Int32 getIntY()
{
- std::string temp = rtl::OUStringToOString(authorId, RTL_TEXTENCODING_UTF8).getStr();
- int aId = atoi(temp.c_str());
- 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 OUString("Anonymous");
+ return y.toInt32();
}
+ ::rtl::OUString getAuthor ( const CommentAuthorList& list );
};
class CommentList
@@ -179,13 +129,7 @@ class CommentList
{
return (int)cmLst.size();
}
- const Comment& getCommentAtIndex (int index)
- {
- if(index < (int)cmLst.size() && index >= 0)
- return cmLst.at(index);
- else
- throw css::lang::IllegalArgumentException();
- }
+ const Comment& getCommentAtIndex (int index);
};
} }
diff --git a/oox/source/ppt/comments.cxx b/oox/source/ppt/comments.cxx
new file mode 100644
index 000000000000..8ca11b9caca1
--- /dev/null
+++ b/oox/source/ppt/comments.cxx
@@ -0,0 +1,65 @@
+/* -*- 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 "oox/ppt/comments.hxx"
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+
+
+namespace oox { namespace ppt {
+
+void CommentAuthorList::setValues(const CommentAuthorList& list)
+{
+ std::vector<CommentAuthor>::const_iterator it;
+ for(it = list.cmAuthorLst.begin(); it != list.cmAuthorLst.end(); ++it)
+ {
+ CommentAuthor temp;
+ cmAuthorLst.push_back(temp);
+ cmAuthorLst.back().clrIdx = it->clrIdx;
+ cmAuthorLst.back().id = it->id;
+ cmAuthorLst.back().initials = it->initials;
+ cmAuthorLst.back().lastIdx = it->lastIdx;
+ cmAuthorLst.back().name = it->name;
+ }
+}
+
+//DateTime is saved as : 2013-01-10T15:53:26.000
+void Comment::setDateTime (::rtl::OUString datetime)
+{
+ aDateTime.Year = datetime.getToken(0,'-').toInt32();
+ aDateTime.Month = datetime.getToken(1,'-').toInt32();
+ aDateTime.Day = datetime.getToken(2,'-').toInt32();
+ datetime = datetime.getToken(1,'T');
+ aDateTime.Hours = datetime.getToken(0,':').toInt32();
+ aDateTime.Minutes = datetime.getToken(1,':').toInt32();
+ aDateTime.HundredthSeconds = int(datetime.getToken(2,':').toDouble() + .5);
+}
+
+OUString Comment::getAuthor ( const CommentAuthorList& list )
+{
+ const sal_Int32 nId = authorId.toInt32();
+ std::vector<CommentAuthor>::const_iterator it;
+ for(it = list.cmAuthorLst.begin(); it != list.cmAuthorLst.end(); ++it)
+ {
+ if(it->id.toInt32() == nId)
+ return it->name;
+ }
+ return OUString("Anonymous");
+}
+
+const Comment& CommentList::getCommentAtIndex (int index)
+{
+ if(index < (int)cmLst.size() && index >= 0)
+ return cmLst.at(index);
+ else
+ throw css::lang::IllegalArgumentException();
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */