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 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <classes/converter.hxx>
21 : #include <rtl/ustrbuf.hxx>
22 :
23 : namespace framework{
24 :
25 : /**
26 : * converts a sequence of PropertyValue to a sequence of NamedValue.
27 : */
28 0 : css::uno::Sequence< css::beans::NamedValue > Converter::convert_seqPropVal2seqNamedVal( const css::uno::Sequence< css::beans::PropertyValue >& lSource )
29 : {
30 0 : sal_Int32 nCount = lSource.getLength();
31 0 : css::uno::Sequence< css::beans::NamedValue > lDestination(nCount);
32 0 : for (sal_Int32 nItem=0; nItem<nCount; ++nItem)
33 : {
34 0 : lDestination[nItem].Name = lSource[nItem].Name;
35 0 : lDestination[nItem].Value = lSource[nItem].Value;
36 : }
37 0 : return lDestination;
38 : }
39 :
40 : /**
41 : * converts a sequence of unicode strings into a vector of such items
42 : */
43 0 : OUStringList Converter::convert_seqOUString2OUStringList( const css::uno::Sequence< OUString >& lSource )
44 : {
45 0 : OUStringList lDestination;
46 0 : sal_Int32 nCount = lSource.getLength();
47 :
48 0 : for (sal_Int32 nItem=0; nItem<nCount; ++nItem )
49 : {
50 0 : lDestination.push_back(lSource[nItem]);
51 : }
52 :
53 0 : return lDestination;
54 : }
55 :
56 0 : OUString Converter::convert_DateTime2ISO8601( const DateTime& aSource )
57 : {
58 0 : OUStringBuffer sBuffer(25);
59 :
60 0 : sal_Int32 nYear = aSource.GetYear();
61 0 : sal_Int32 nMonth = aSource.GetMonth();
62 0 : sal_Int32 nDay = aSource.GetDay();
63 :
64 0 : sal_Int32 nHour = aSource.GetHour();
65 0 : sal_Int32 nMin = aSource.GetMin();
66 0 : sal_Int32 nSec = aSource.GetSec();
67 :
68 : // write year formated as "YYYY"
69 0 : if (nYear<10)
70 0 : sBuffer.appendAscii("000");
71 0 : else if (nYear<100)
72 0 : sBuffer.appendAscii("00");
73 0 : else if (nYear<1000)
74 0 : sBuffer.appendAscii("0");
75 0 : sBuffer.append( (sal_Int32)nYear );
76 :
77 0 : sBuffer.appendAscii("-");
78 : // write month formated as "MM"
79 0 : if (nMonth<10)
80 0 : sBuffer.appendAscii("0");
81 0 : sBuffer.append( (sal_Int32)nMonth );
82 :
83 0 : sBuffer.appendAscii("-");
84 : // write day formated as "DD"
85 0 : if (nDay<10)
86 0 : sBuffer.appendAscii("0");
87 0 : sBuffer.append( (sal_Int32)nDay );
88 :
89 0 : sBuffer.appendAscii("T");
90 : // write hours formated as "hh"
91 0 : if (nHour<10)
92 0 : sBuffer.appendAscii("0");
93 0 : sBuffer.append( (sal_Int32)nHour );
94 :
95 0 : sBuffer.appendAscii(":");
96 : // write min formated as "mm"
97 0 : if (nMin<10)
98 0 : sBuffer.appendAscii("0");
99 0 : sBuffer.append( (sal_Int32)nMin );
100 :
101 0 : sBuffer.appendAscii(":");
102 : // write sec formated as "ss"
103 0 : if (nSec<10)
104 0 : sBuffer.appendAscii("0");
105 0 : sBuffer.append( (sal_Int32)nSec );
106 :
107 0 : sBuffer.appendAscii("Z");
108 :
109 0 : return sBuffer.makeStringAndClear();
110 : }
111 :
112 : } // namespace framework
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|