LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/orcus - orcusfiltersimpl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 25 0.0 %
Date: 2012-12-27 Functions: 0 4 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             : 
      10             : #include "orcusfiltersimpl.hxx"
      11             : #include "orcusinterface.hxx"
      12             : 
      13             : #include "document.hxx"
      14             : 
      15             : #include "tools/urlobj.hxx"
      16             : 
      17             : #include <orcus/spreadsheet/import_interface.hpp>
      18             : #include <orcus/orcus_csv.hpp>
      19             : #include <orcus/orcus_gnumeric.hpp>
      20             : #include <orcus/global.hpp>
      21             : 
      22             : #ifdef WNT
      23             : #define SYSTEM_PATH INetURLObject::FSYS_DOS
      24             : #else
      25             : #define SYSTEM_PATH INetURLObject::FSYS_UNX
      26             : #endif
      27             : 
      28           0 : OString ScOrcusFiltersImpl::toSystemPath(const OUString& rPath)
      29             : {
      30           0 :     INetURLObject aURL(rPath);
      31           0 :     return rtl::OUStringToOString(aURL.getFSysPath(SYSTEM_PATH), RTL_TEXTENCODING_UTF8);
      32             : }
      33             : 
      34           0 : bool ScOrcusFiltersImpl::importCSV(ScDocument& rDoc, const OUString& rPath) const
      35             : {
      36           0 :     ScOrcusFactory aFactory(rDoc);
      37           0 :     OString aSysPath = toSystemPath(rPath);
      38           0 :     const char* path = aSysPath.getStr();
      39             : 
      40             :     try
      41             :     {
      42           0 :         orcus::orcus_csv filter(&aFactory);
      43           0 :         filter.read_file(path);
      44             :     }
      45           0 :     catch (const std::exception&)
      46             :     {
      47           0 :         rDoc.InsertTab(SC_TAB_APPEND, OUString("Foo"));
      48           0 :         rDoc.SetString(0, 0, 0, "Failed to load!!!");
      49           0 :         return false;
      50             :     }
      51           0 :     return true;
      52             : }
      53             : 
      54           0 : bool ScOrcusFiltersImpl::importGnumeric(ScDocument& rDoc, const OUString& rPath) const
      55             : {
      56           0 :     ScOrcusFactory aFactory(rDoc);
      57           0 :     OString aSysPath = toSystemPath(rPath);
      58           0 :     const char* path = aSysPath.getStr();
      59             : 
      60             :     try
      61             :     {
      62           0 :         orcus::orcus_gnumeric filter(&aFactory);
      63           0 :         filter.read_file(path);
      64             :     }
      65           0 :     catch (const std::exception& e)
      66             :     {
      67             :         SAL_WARN("sc", "Unable to load gnumeric file! " << e.what());
      68           0 :         return false;
      69             :     }
      70             : 
      71           0 :     return true;
      72             : }
      73             : 
      74           0 : ScOrcusXMLContext* ScOrcusFiltersImpl::createXMLContext(ScDocument& rDoc, const rtl::OUString& rPath) const
      75             : {
      76           0 :     return new ScOrcusXMLContextImpl(rDoc, rPath);
      77             : }
      78             : 
      79             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10