Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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 : */
9 :
10 : #include "oox/ppt/comments.hxx"
11 : #include <com/sun/star/lang/IllegalArgumentException.hpp>
12 : #include <rtl/math.hxx>
13 :
14 :
15 : namespace oox { namespace ppt {
16 :
17 0 : void CommentAuthorList::setValues(const CommentAuthorList& list)
18 : {
19 0 : std::vector<CommentAuthor>::const_iterator it;
20 0 : for(it = list.cmAuthorLst.begin(); it != list.cmAuthorLst.end(); ++it)
21 : {
22 0 : CommentAuthor temp;
23 0 : cmAuthorLst.push_back(temp);
24 0 : cmAuthorLst.back().clrIdx = it->clrIdx;
25 0 : cmAuthorLst.back().id = it->id;
26 0 : cmAuthorLst.back().initials = it->initials;
27 0 : cmAuthorLst.back().lastIdx = it->lastIdx;
28 0 : cmAuthorLst.back().name = it->name;
29 0 : }
30 0 : }
31 :
32 : //DateTime is saved as : 2013-01-10T15:53:26.000
33 0 : void Comment::setDateTime (const OUString& _datetime)
34 : {
35 0 : OUString datetime = _datetime;
36 0 : aDateTime.Year = datetime.getToken(0,'-').toInt32();
37 0 : aDateTime.Month = datetime.getToken(1,'-').toInt32();
38 0 : aDateTime.Day = datetime.getToken(2,'-').toInt32();
39 0 : datetime = datetime.getToken(1,'T');
40 0 : aDateTime.Hours = datetime.getToken(0,':').toInt32();
41 0 : aDateTime.Minutes = datetime.getToken(1,':').toInt32();
42 0 : double seconds = datetime.getToken(2,':').toDouble();
43 0 : aDateTime.Seconds = floor(seconds);
44 0 : seconds -= aDateTime.Seconds;
45 0 : aDateTime.NanoSeconds = ::rtl::math::round(seconds * 1000000000);
46 0 : const int secondsOverflow = (aDateTime.Seconds == 60) ? 61 : 60;
47 : // normalise time part of aDateTime
48 0 : if (aDateTime.NanoSeconds == 1000000000)
49 : {
50 0 : aDateTime.NanoSeconds = 0;
51 0 : ++aDateTime.Seconds;
52 : }
53 0 : if (aDateTime.Seconds == secondsOverflow)
54 : {
55 0 : aDateTime.Seconds = 0;
56 0 : ++aDateTime.Minutes;
57 : }
58 0 : if (aDateTime.Minutes == 60)
59 : {
60 0 : aDateTime.Minutes = 0;
61 0 : ++aDateTime.Hours;
62 0 : }
63 : // if overflow goes into date, I give up
64 0 : }
65 :
66 0 : OUString Comment::getAuthor ( const CommentAuthorList& list )
67 : {
68 0 : const sal_Int32 nId = authorId.toInt32();
69 0 : std::vector<CommentAuthor>::const_iterator it;
70 0 : for(it = list.cmAuthorLst.begin(); it != list.cmAuthorLst.end(); ++it)
71 : {
72 0 : if(it->id.toInt32() == nId)
73 0 : return it->name;
74 : }
75 0 : return OUString("Anonymous");
76 : }
77 :
78 0 : const Comment& CommentList::getCommentAtIndex (int index)
79 : {
80 0 : if(index < (int)cmLst.size() && index >= 0)
81 0 : return cmLst.at(index);
82 : else
83 0 : throw css::lang::IllegalArgumentException();
84 : }
85 :
86 : } }
87 :
88 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|