LibreOffice Module framework (master) 1
converter.cxx
Go to the documentation of this file.
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
23namespace framework{
24
28css::uno::Sequence< css::beans::NamedValue > Converter::convert_seqPropVal2seqNamedVal( const css::uno::Sequence< css::beans::PropertyValue >& lSource )
29{
30 sal_Int32 nCount = lSource.getLength();
31 css::uno::Sequence< css::beans::NamedValue > lDestination(nCount);
32 auto lDestinationRange = asNonConstRange(lDestination);
33 for (sal_Int32 nItem=0; nItem<nCount; ++nItem)
34 {
35 lDestinationRange[nItem].Name = lSource[nItem].Name;
36 lDestinationRange[nItem].Value = lSource[nItem].Value;
37 }
38 return lDestination;
39}
40
44std::vector<OUString> Converter::convert_seqOUString2OUStringList( const css::uno::Sequence< OUString >& lSource )
45{
46 std::vector<OUString> lDestination;
47 sal_Int32 nCount = lSource.getLength();
48
49 lDestination.reserve(nCount);
50 for (sal_Int32 nItem = 0; nItem < nCount; ++nItem)
51 {
52 lDestination.push_back(lSource[nItem]);
53 }
54
55 return lDestination;
56}
57
59{
60 OUStringBuffer sBuffer(25);
61
62 sal_Int32 nYear = aSource.GetYear();
63 sal_Int32 nMonth = aSource.GetMonth();
64 sal_Int32 nDay = aSource.GetDay();
65
66 sal_Int32 nHour = aSource.GetHour();
67 sal_Int32 nMin = aSource.GetMin();
68 sal_Int32 nSec = aSource.GetSec();
69
70 // write year formatted as "YYYY"
71 if (nYear<10)
72 sBuffer.append("000");
73 else if (nYear<100)
74 sBuffer.append("00");
75 else if (nYear<1000)
76 sBuffer.append("0");
77 sBuffer.append( nYear );
78
79 // write month formatted as "MM"
80 sBuffer.append("-");
81 if (nMonth<10)
82 sBuffer.append("0");
83 sBuffer.append( nMonth );
84
85 // write day formatted as "DD"
86 sBuffer.append("-");
87 if (nDay<10)
88 sBuffer.append("0");
89 sBuffer.append( nDay );
90
91 // write hours formatted as "hh"
92 sBuffer.append("T");
93 if (nHour<10)
94 sBuffer.append("0");
95 sBuffer.append( nHour );
96
97 // write min formatted as "mm"
98 sBuffer.append(":");
99 if (nMin<10)
100 sBuffer.append("0");
101 sBuffer.append( nMin );
102
103 // write sec formatted as "ss"
104 sBuffer.append(":");
105 if (nSec<10)
106 sBuffer.append("0");
107 sBuffer.append( nSec );
108
109 // write time-zone
110 sBuffer.append("Z");
111
112 return sBuffer.makeStringAndClear();
113}
114
115} // namespace framework
116
117/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int16 GetYear() const
sal_uInt16 GetDay() const
sal_uInt16 GetMonth() const
static OUString convert_DateTime2ISO8601(const DateTime &aSource)
Definition: converter.cxx:58
static std::vector< OUString > convert_seqOUString2OUStringList(const css::uno::Sequence< OUString > &lSource)
converts a sequence of unicode strings into a vector of such items
Definition: converter.cxx:44
static css::uno::Sequence< css::beans::NamedValue > convert_seqPropVal2seqNamedVal(const css::uno::Sequence< css::beans::PropertyValue > &lSource)
converts a sequence of PropertyValue to a sequence of NamedValue.
Definition: converter.cxx:28
sal_uInt16 GetSec() const
sal_uInt16 GetMin() const
sal_uInt16 GetHour() const
int nCount