LCOV - code coverage report
Current view: top level - libreoffice/framework/source/fwi/classes - converter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 50 12.0 %
Date: 2012-12-27 Functions: 1 3 33.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10