GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / oox / source / ppt / comments.cxx
blobbf598c7e3386b90a935a98e01b83b93361764b4e
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>
15 namespace oox { namespace ppt {
17 void CommentAuthorList::setValues(const CommentAuthorList& list)
19 std::vector<CommentAuthor>::const_iterator it;
20 for(it = list.cmAuthorLst.begin(); it != list.cmAuthorLst.end(); ++it)
22 CommentAuthor temp;
23 cmAuthorLst.push_back(temp);
24 cmAuthorLst.back().clrIdx = it->clrIdx;
25 cmAuthorLst.back().id = it->id;
26 cmAuthorLst.back().initials = it->initials;
27 cmAuthorLst.back().lastIdx = it->lastIdx;
28 cmAuthorLst.back().name = it->name;
32 //DateTime is saved as : 2013-01-10T15:53:26.000
33 void Comment::setDateTime (OUString 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: */