fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / fwi / classes / converter.cxx
blob4dfe07028fbe29797f04303b8e355454768e3419
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <classes/converter.hxx>
21 #include <rtl/ustrbuf.hxx>
23 namespace framework{
25 /**
26 * converts a sequence of PropertyValue to a sequence of NamedValue.
28 css::uno::Sequence< css::beans::NamedValue > Converter::convert_seqPropVal2seqNamedVal( const css::uno::Sequence< css::beans::PropertyValue >& lSource )
30 sal_Int32 nCount = lSource.getLength();
31 css::uno::Sequence< css::beans::NamedValue > lDestination(nCount);
32 for (sal_Int32 nItem=0; nItem<nCount; ++nItem)
34 lDestination[nItem].Name = lSource[nItem].Name;
35 lDestination[nItem].Value = lSource[nItem].Value;
37 return lDestination;
40 /**
41 * converts a sequence of unicode strings into a vector of such items
43 OUStringList Converter::convert_seqOUString2OUStringList( const css::uno::Sequence< OUString >& lSource )
45 OUStringList lDestination;
46 sal_Int32 nCount = lSource.getLength();
48 for (sal_Int32 nItem=0; nItem<nCount; ++nItem )
50 lDestination.push_back(lSource[nItem]);
53 return lDestination;
56 OUString Converter::convert_DateTime2ISO8601( const DateTime& aSource )
58 OUStringBuffer sBuffer(25);
60 sal_Int32 nYear = aSource.GetYear();
61 sal_Int32 nMonth = aSource.GetMonth();
62 sal_Int32 nDay = aSource.GetDay();
64 sal_Int32 nHour = aSource.GetHour();
65 sal_Int32 nMin = aSource.GetMin();
66 sal_Int32 nSec = aSource.GetSec();
68 // write year formatted as "YYYY"
69 if (nYear<10)
70 sBuffer.appendAscii("000");
71 else if (nYear<100)
72 sBuffer.appendAscii("00");
73 else if (nYear<1000)
74 sBuffer.appendAscii("0");
75 sBuffer.append( (sal_Int32)nYear );
77 sBuffer.appendAscii("-");
78 // write month formatted as "MM"
79 if (nMonth<10)
80 sBuffer.appendAscii("0");
81 sBuffer.append( (sal_Int32)nMonth );
83 sBuffer.appendAscii("-");
84 // write day formatted as "DD"
85 if (nDay<10)
86 sBuffer.appendAscii("0");
87 sBuffer.append( (sal_Int32)nDay );
89 sBuffer.appendAscii("T");
90 // write hours formatted as "hh"
91 if (nHour<10)
92 sBuffer.appendAscii("0");
93 sBuffer.append( (sal_Int32)nHour );
95 sBuffer.appendAscii(":");
96 // write min formatted as "mm"
97 if (nMin<10)
98 sBuffer.appendAscii("0");
99 sBuffer.append( (sal_Int32)nMin );
101 sBuffer.appendAscii(":");
102 // write sec formatted as "ss"
103 if (nSec<10)
104 sBuffer.appendAscii("0");
105 sBuffer.append( (sal_Int32)nSec );
107 sBuffer.appendAscii("Z");
109 return sBuffer.makeStringAndClear();
112 } // namespace framework
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */