Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <classes/converter.hxx>
30 : : #include <rtl/ustrbuf.hxx>
31 : :
32 : : namespace framework{
33 : :
34 : : //-----------------------------------------------------------------------------
35 : : /**
36 : : * converts a sequence of PropertyValue to a sequence of NamedValue.
37 : : */
38 : 0 : css::uno::Sequence< css::beans::NamedValue > Converter::convert_seqPropVal2seqNamedVal( const css::uno::Sequence< css::beans::PropertyValue >& lSource )
39 : : {
40 : 0 : sal_Int32 nCount = lSource.getLength();
41 : 0 : css::uno::Sequence< css::beans::NamedValue > lDestination(nCount);
42 [ # # ]: 0 : for (sal_Int32 nItem=0; nItem<nCount; ++nItem)
43 : : {
44 [ # # ]: 0 : lDestination[nItem].Name = lSource[nItem].Name ;
45 [ # # ]: 0 : lDestination[nItem].Value = lSource[nItem].Value;
46 : : }
47 : 0 : return lDestination;
48 : : }
49 : :
50 : : //-----------------------------------------------------------------------------
51 : : /**
52 : : * converts a sequence of unicode strings into a vector of such items
53 : : */
54 : 2590 : OUStringList Converter::convert_seqOUString2OUStringList( const css::uno::Sequence< ::rtl::OUString >& lSource )
55 : : {
56 : 2590 : OUStringList lDestination;
57 : 2590 : sal_Int32 nCount = lSource.getLength();
58 : :
59 [ + + ]: 5281 : for (sal_Int32 nItem=0; nItem<nCount; ++nItem )
60 : : {
61 [ + - ]: 2691 : lDestination.push_back(lSource[nItem]);
62 : : }
63 : :
64 : 2590 : return lDestination;
65 : : }
66 : :
67 : 0 : ::rtl::OUString Converter::convert_DateTime2ISO8601( const DateTime& aSource )
68 : : {
69 : 0 : ::rtl::OUStringBuffer sBuffer(25);
70 : :
71 : 0 : sal_Int32 nYear = aSource.GetYear();
72 : 0 : sal_Int32 nMonth = aSource.GetMonth();
73 : 0 : sal_Int32 nDay = aSource.GetDay();
74 : :
75 : 0 : sal_Int32 nHour = aSource.GetHour();
76 : 0 : sal_Int32 nMin = aSource.GetMin();
77 : 0 : sal_Int32 nSec = aSource.GetSec();
78 : :
79 : : // write year formated as "YYYY"
80 [ # # ]: 0 : if (nYear<10)
81 [ # # ]: 0 : sBuffer.appendAscii("000");
82 : : else
83 [ # # ]: 0 : if (nYear<100)
84 [ # # ]: 0 : sBuffer.appendAscii("00");
85 : : else
86 [ # # ]: 0 : if (nYear<1000)
87 [ # # ]: 0 : sBuffer.appendAscii("0");
88 [ # # ]: 0 : sBuffer.append( (sal_Int32)nYear );
89 : :
90 [ # # ]: 0 : sBuffer.appendAscii("-");
91 : : // write month formated as "MM"
92 [ # # ]: 0 : if (nMonth<10)
93 [ # # ]: 0 : sBuffer.appendAscii("0");
94 [ # # ]: 0 : sBuffer.append( (sal_Int32)nMonth );
95 : :
96 [ # # ]: 0 : sBuffer.appendAscii("-");
97 : : // write day formated as "DD"
98 [ # # ]: 0 : if (nDay<10)
99 [ # # ]: 0 : sBuffer.appendAscii("0");
100 [ # # ]: 0 : sBuffer.append( (sal_Int32)nDay );
101 : :
102 [ # # ]: 0 : sBuffer.appendAscii("T");
103 : : // write hours formated as "hh"
104 [ # # ]: 0 : if (nHour<10)
105 [ # # ]: 0 : sBuffer.appendAscii("0");
106 [ # # ]: 0 : sBuffer.append( (sal_Int32)nHour );
107 : :
108 [ # # ]: 0 : sBuffer.appendAscii(":");
109 : : // write min formated as "mm"
110 [ # # ]: 0 : if (nMin<10)
111 [ # # ]: 0 : sBuffer.appendAscii("0");
112 [ # # ]: 0 : sBuffer.append( (sal_Int32)nMin );
113 : :
114 [ # # ]: 0 : sBuffer.appendAscii(":");
115 : : // write sec formated as "ss"
116 [ # # ]: 0 : if (nSec<10)
117 [ # # ]: 0 : sBuffer.appendAscii("0");
118 [ # # ]: 0 : sBuffer.append( (sal_Int32)nSec );
119 : :
120 [ # # ]: 0 : sBuffer.appendAscii("Z");
121 : :
122 [ # # ]: 0 : return sBuffer.makeStringAndClear();
123 : : }
124 : :
125 : : } // namespace framework
126 : :
127 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|