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

Generated by: LCOV version 1.10