bump product version to 5.0.4.1
[LibreOffice.git] / oox / source / ppt / comments.cxx
blob965a7ef658b074839727406dc26c46af7802e0fe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "oox/ppt/comments.hxx"
11 #include <com/sun/star/lang/IllegalArgumentException.hpp>
12 #include <rtl/math.hxx>
14 namespace oox { namespace ppt {
16 void CommentAuthorList::setValues(const CommentAuthorList& list)
18 std::vector<CommentAuthor>::const_iterator it;
19 for(it = list.cmAuthorLst.begin(); it != list.cmAuthorLst.end(); ++it)
21 CommentAuthor temp;
22 cmAuthorLst.push_back(temp);
23 cmAuthorLst.back().clrIdx = it->clrIdx;
24 cmAuthorLst.back().id = it->id;
25 cmAuthorLst.back().initials = it->initials;
26 cmAuthorLst.back().lastIdx = it->lastIdx;
27 cmAuthorLst.back().name = it->name;
31 //DateTime is saved as : 2013-01-10T15:53:26.000
32 void Comment::setDateTime (const OUString& _datetime)
34 OUString datetime = _datetime;
35 aDateTime.Year = datetime.getToken(0,'-').toInt32();
36 aDateTime.Month = datetime.getToken(1,'-').toInt32();
37 aDateTime.Day = datetime.getToken(2,'-').toInt32();
38 datetime = datetime.getToken(1,'T');
39 aDateTime.Hours = datetime.getToken(0,':').toInt32();
40 aDateTime.Minutes = datetime.getToken(1,':').toInt32();
41 double seconds = datetime.getToken(2,':').toDouble();
42 aDateTime.Seconds = floor(seconds);
43 seconds -= aDateTime.Seconds;
44 aDateTime.NanoSeconds = ::rtl::math::round(seconds * 1000000000);
45 const int secondsOverflow = (aDateTime.Seconds == 60) ? 61 : 60;
46 // normalise time part of aDateTime
47 if (aDateTime.NanoSeconds == 1000000000)
49 aDateTime.NanoSeconds = 0;
50 ++aDateTime.Seconds;
52 if (aDateTime.Seconds == secondsOverflow)
54 aDateTime.Seconds = 0;
55 ++aDateTime.Minutes;
57 if (aDateTime.Minutes == 60)
59 aDateTime.Minutes = 0;
60 ++aDateTime.Hours;
62 // if overflow goes into date, I give up
65 OUString Comment::getAuthor ( const CommentAuthorList& list )
67 const sal_Int32 nId = authorId.toInt32();
68 std::vector<CommentAuthor>::const_iterator it;
69 for(it = list.cmAuthorLst.begin(); it != list.cmAuthorLst.end(); ++it)
71 if(it->id.toInt32() == nId)
72 return it->name;
74 return OUString("Anonymous");
77 const Comment& CommentList::getCommentAtIndex (int index)
79 if(index < (int)cmLst.size() && index >= 0)
80 return cmLst.at(index);
81 else
82 throw css::lang::IllegalArgumentException();
85 } }
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */