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

Generated by: LCOV version 1.10