[Libreoffice-commits] core.git: oox/inc oox/Library_oox.mk oox/source

Thorsten Behrens tbehrens at suse.com
Thu Mar 14 05:52:29 PDT 2013


 oox/Library_oox.mk           |    1 
 oox/inc/oox/ppt/comments.hxx |   72 ++++---------------------------------------
 oox/source/ppt/comments.cxx  |   65 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 74 insertions(+), 64 deletions(-)

New commits:
commit 42f9c7f8364818e91c95cf3dae8ab9ae6f1b561e
Author: Thorsten Behrens <tbehrens at suse.com>
Date:   Thu Mar 14 12:52:03 2013 +0100

    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

diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index 303b21f..e468256 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 81bcb78..fe718db 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 0000000..8ca11b9
--- /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: */


More information about the Libreoffice-commits mailing list