LCOV - code coverage report
Current view: top level - sc/source/ui/dbgui - imoptdlg.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 45 2.2 %
Date: 2014-11-03 Functions: 2 5 40.0 %
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 "imoptdlg.hxx"
      21             : #include "asciiopt.hxx"
      22             : #include "scresid.hxx"
      23             : #include <comphelper/string.hxx>
      24             : #include <osl/thread.h>
      25             : #include <rtl/tencinfo.h>
      26             : 
      27             : static const sal_Char pStrFix[] = "FIX";
      28             : 
      29             : //  Der Options-String darf kein Semikolon mehr enthalten (wegen Pickliste)
      30             : //  darum ab Version 336 Komma stattdessen
      31             : 
      32           0 : ScImportOptions::ScImportOptions( const OUString& rStr )
      33             : {
      34             :     // Use the same string format as ScAsciiOptions,
      35             :     // because the import options string is passed here when a CSV file is loaded and saved again.
      36             :     // The old format is still supported because it might be used in macros.
      37             : 
      38           0 :     bFixedWidth = false;
      39           0 :     nFieldSepCode = 0;
      40           0 :     nTextSepCode = 0;
      41           0 :     eCharSet = RTL_TEXTENCODING_DONTKNOW;
      42           0 :     bSaveAsShown = true;    // "true" if not in string (after CSV import)
      43           0 :     bQuoteAllText = false;
      44           0 :     bSaveFormulas = false;
      45           0 :     sal_Int32 nTokenCount = comphelper::string::getTokenCount(rStr, ',');
      46           0 :     if ( nTokenCount >= 3 )
      47             :     {
      48             :         // first 3 tokens: common
      49           0 :         OUString aToken( rStr.getToken( 0, ',' ) );
      50           0 :         if( aToken.equalsIgnoreAsciiCase( pStrFix ) )
      51           0 :             bFixedWidth = true;
      52             :         else
      53           0 :             nFieldSepCode = ScAsciiOptions::GetWeightedFieldSep( aToken, true);
      54           0 :         nTextSepCode  = (sal_Unicode) rStr.getToken(1,',').toInt32();
      55           0 :         aStrFont      = rStr.getToken(2,',');
      56           0 :         eCharSet      = ScGlobal::GetCharsetValue(aStrFont);
      57             : 
      58           0 :         if ( nTokenCount == 4 )
      59             :         {
      60             :             // compatibility with old options string: "Save as shown" as 4th token, numeric
      61           0 :             bSaveAsShown = (rStr.getToken( 3, ',' ).toInt32() ? true : false);
      62           0 :             bQuoteAllText = true;   // use old default then
      63             :         }
      64             :         else
      65             :         {
      66             :             // look at the same positions as in ScAsciiOptions
      67           0 :             if ( nTokenCount >= 7 )
      68           0 :                 bQuoteAllText = rStr.getToken(6, ',').equalsAscii("true");
      69           0 :             if ( nTokenCount >= 9 )
      70           0 :                 bSaveAsShown = rStr.getToken(8, ',').equalsAscii("true");
      71           0 :             if ( nTokenCount >= 10 )
      72           0 :                 bSaveFormulas = rStr.getToken(9, ',').equalsAscii("true");
      73           0 :         }
      74             :     }
      75           0 : }
      76             : 
      77           0 : OUString ScImportOptions::BuildString() const
      78             : {
      79           0 :     OUString aResult;
      80             : 
      81           0 :     if( bFixedWidth )
      82           0 :         aResult += pStrFix;
      83             :     else
      84           0 :         aResult += OUString::number(nFieldSepCode);
      85           0 :     aResult += "," + OUString::number(nTextSepCode) + "," + aStrFont +
      86             :                                                  // use the same string format as ScAsciiOptions:
      87           0 :             ",1,,0," +                           // first row, no column info, default language
      88           0 :             OUString::boolean( bQuoteAllText ) + // same as "quoted field as text" in ScAsciiOptions
      89           0 :             ",true," +                           // "detect special numbers"
      90           0 :             OUString::boolean( bSaveAsShown ) +  // "save as shown": not in ScAsciiOptions
      91           0 :             "," +
      92           0 :             OUString::boolean( bSaveFormulas );  // "save formulas": not in ScAsciiOptions
      93             : 
      94           0 :     return aResult;
      95             : }
      96             : 
      97           0 : void ScImportOptions::SetTextEncoding( rtl_TextEncoding nEnc )
      98             : {
      99             :     eCharSet = (nEnc == RTL_TEXTENCODING_DONTKNOW ?
     100           0 :         osl_getThreadTextEncoding() : nEnc);
     101           0 :     aStrFont = ScGlobal::GetCharsetString( nEnc );
     102         228 : }
     103             : 
     104             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10