LCOV - code coverage report
Current view: top level - sc/source/filter/inc - orcusinterface.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 7 0.0 %
Date: 2014-04-14 Functions: 0 13 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             : #ifndef __SC_ORCUSINTERFACE_HXX__
      11             : #define __SC_ORCUSINTERFACE_HXX__
      12             : 
      13             : #include "address.hxx"
      14             : #include "documentimport.hxx"
      15             : 
      16             : #include "sharedformulagroups.hxx"
      17             : 
      18             : #include "rtl/strbuf.hxx"
      19             : 
      20             : #define __ORCUS_STATIC_LIB
      21             : #include <orcus/spreadsheet/import_interface.hpp>
      22             : 
      23             : #include <boost/ptr_container/ptr_vector.hpp>
      24             : #include <boost/unordered_map.hpp>
      25             : 
      26             : #include <map>
      27             : 
      28             : class ScDocumentImport;
      29             : class ScOrcusSheet;
      30             : class ScOrcusFactory;
      31             : class ScRangeData;
      32             : 
      33             : namespace com { namespace sun { namespace star { namespace task {
      34             : 
      35             : class XStatusIndicator;
      36             : 
      37             : }}}}
      38             : 
      39           0 : class ScOrcusGlobalSettings : public orcus::spreadsheet::iface::import_global_settings
      40             : {
      41             :     ScDocumentImport& mrDoc;
      42             : 
      43             : public:
      44             :     ScOrcusGlobalSettings(ScDocumentImport& rDoc);
      45             : 
      46             :     virtual void set_origin_date(int year, int month, int day) SAL_OVERRIDE;
      47             : };
      48             : 
      49           0 : class ScOrcusSharedStrings : public orcus::spreadsheet::iface::import_shared_strings
      50             : {
      51             :     ScOrcusFactory& mrFactory;
      52             : 
      53             :     OStringBuffer maCurSegment;
      54             : public:
      55             :     ScOrcusSharedStrings(ScOrcusFactory& rFactory);
      56             : 
      57             :     virtual size_t append(const char* s, size_t n) SAL_OVERRIDE;
      58             :     virtual size_t add(const char* s, size_t n) SAL_OVERRIDE;
      59             : 
      60             :     virtual void set_segment_bold(bool b) SAL_OVERRIDE;
      61             :     virtual void set_segment_italic(bool b) SAL_OVERRIDE;
      62             :     virtual void set_segment_font(size_t font_index) SAL_OVERRIDE;
      63             :     virtual void set_segment_font_name(const char* s, size_t n) SAL_OVERRIDE;
      64             :     virtual void set_segment_font_size(double point) SAL_OVERRIDE;
      65             :     virtual void set_segment_font_color(orcus::spreadsheet::color_elem_t alpha,
      66             :             orcus::spreadsheet::color_elem_t red,
      67             :             orcus::spreadsheet::color_elem_t green,
      68             :             orcus::spreadsheet::color_elem_t blue) SAL_OVERRIDE;
      69             :     virtual void append_segment(const char* s, size_t n) SAL_OVERRIDE;
      70             : 
      71             :     virtual size_t commit_segments() SAL_OVERRIDE;
      72             : };
      73             : 
      74           0 : class ScOrcusSheet : public orcus::spreadsheet::iface::import_sheet
      75             : {
      76             :     ScDocumentImport& mrDoc;
      77             :     SCTAB mnTab;
      78             :     ScOrcusFactory& mrFactory;
      79             :     sc::SharedFormulaGroups maFormulaGroups;
      80             : 
      81             :     typedef std::map<size_t, ScRangeData*> SharedFormulaContainer;
      82             :     SharedFormulaContainer maSharedFormulas;
      83             : 
      84             :     int mnCellCount;
      85             : 
      86             :     void cellInserted();
      87             : 
      88             : public:
      89             :     ScOrcusSheet(ScDocumentImport& rDoc, SCTAB nTab, ScOrcusFactory& rFactory);
      90             : 
      91             :     // Orcus import interface
      92             :     virtual void set_auto(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, const char* p, size_t n) SAL_OVERRIDE;
      93             :     virtual void set_string(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, size_t sindex) SAL_OVERRIDE;
      94             :     virtual void set_value(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, double value) SAL_OVERRIDE;
      95             :     virtual void set_bool(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, bool value) SAL_OVERRIDE;
      96             :     virtual void set_date_time(
      97             :         orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, int year, int month, int day, int hour, int minute, double second) SAL_OVERRIDE;
      98             : 
      99             :     virtual void set_format(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, size_t xf_index) SAL_OVERRIDE;
     100             : 
     101             :     virtual void set_formula(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar, const char* p, size_t n) SAL_OVERRIDE;
     102             :     virtual void set_formula_result(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, const char* p, size_t n) SAL_OVERRIDE;
     103             : 
     104             :     virtual void set_shared_formula(
     105             :         orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar, size_t sindex,
     106             :         const char* p_formula, size_t n_formula) SAL_OVERRIDE;
     107             : 
     108             :     virtual void set_shared_formula(
     109             :         orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar, size_t sindex,
     110             :         const char* p_formula, size_t n_formula, const char* p_range, size_t n_range) SAL_OVERRIDE;
     111             : 
     112             :     virtual void set_shared_formula(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, size_t sindex) SAL_OVERRIDE;
     113             : 
     114             :     virtual void set_array_formula(
     115             :         orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar,
     116             :         const char* p, size_t n, orcus::spreadsheet::row_t array_rows, orcus::spreadsheet::col_t array_cols) SAL_OVERRIDE;
     117             : 
     118             :     virtual void set_array_formula(
     119             :         orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar,
     120             :         const char* p, size_t n, const char* p_range, size_t n_range) SAL_OVERRIDE;
     121             : 
     122           0 :     SCTAB getIndex() const { return mnTab; }
     123             : };
     124             : 
     125           0 : class ScOrcusStyles : public orcus::spreadsheet::iface::import_styles
     126             : {
     127             : 
     128             : public:
     129             :     // font
     130             : 
     131             :     virtual void set_font_count(size_t n) SAL_OVERRIDE;
     132             :     virtual void set_font_bold(bool b) SAL_OVERRIDE;
     133             :     virtual void set_font_italic(bool b) SAL_OVERRIDE;
     134             :     virtual void set_font_name(const char* s, size_t n) SAL_OVERRIDE;
     135             :     virtual void set_font_size(double point) SAL_OVERRIDE;
     136             :     virtual void set_font_underline(orcus::spreadsheet::underline_t e) SAL_OVERRIDE;
     137             :     virtual void set_font_color( orcus::spreadsheet::color_elem_t alpha,
     138             :             orcus::spreadsheet::color_elem_t red,
     139             :             orcus::spreadsheet::color_elem_t green,
     140             :             orcus::spreadsheet::color_elem_t blue) SAL_OVERRIDE;
     141             :     virtual size_t commit_font() SAL_OVERRIDE;
     142             : 
     143             :     // fill
     144             : 
     145             :     virtual void set_fill_count(size_t n) SAL_OVERRIDE;
     146             :     virtual void set_fill_pattern_type(const char* s, size_t n) SAL_OVERRIDE;
     147             :     virtual void set_fill_fg_color(orcus::spreadsheet::color_elem_t alpha, orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue) SAL_OVERRIDE;
     148             :     virtual void set_fill_bg_color(orcus::spreadsheet::color_elem_t alpha, orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue) SAL_OVERRIDE;
     149             :     virtual size_t commit_fill() SAL_OVERRIDE;
     150             : 
     151             :     // border
     152             : 
     153             :     virtual void set_border_count(size_t n) SAL_OVERRIDE;
     154             :     virtual void set_border_style(orcus::spreadsheet::border_direction_t dir, const char* s, size_t n) SAL_OVERRIDE;
     155             :     virtual void set_border_color(orcus::spreadsheet::border_direction_t dir,
     156             :             orcus::spreadsheet::color_elem_t alpha,
     157             :             orcus::spreadsheet::color_elem_t red,
     158             :             orcus::spreadsheet::color_elem_t green,
     159             :             orcus::spreadsheet::color_elem_t blue) SAL_OVERRIDE;
     160             :     virtual size_t commit_border() SAL_OVERRIDE;
     161             : 
     162             :     // cell protection
     163             :     virtual void set_cell_hidden(bool b) SAL_OVERRIDE;
     164             :     virtual void set_cell_locked(bool b) SAL_OVERRIDE;
     165             :     virtual size_t commit_cell_protection() SAL_OVERRIDE;
     166             : 
     167             :     // number format
     168             :     virtual void set_number_format_count(size_t n) SAL_OVERRIDE;
     169             :     virtual void set_number_format_identifier(size_t n) SAL_OVERRIDE;
     170             :     virtual void set_number_format_code(const char* s, size_t n) SAL_OVERRIDE;
     171             :     virtual size_t commit_number_format() SAL_OVERRIDE;
     172             : 
     173             :     // cell style xf
     174             : 
     175             :     virtual void set_cell_style_xf_count(size_t n) SAL_OVERRIDE;
     176             :     virtual size_t commit_cell_style_xf() SAL_OVERRIDE;
     177             : 
     178             :     // cell xf
     179             : 
     180             :     virtual void set_cell_xf_count(size_t n) SAL_OVERRIDE;
     181             :     virtual size_t commit_cell_xf() SAL_OVERRIDE;
     182             : 
     183             :     // xf (cell format) - used both by cell xf and cell style xf.
     184             : 
     185             :     virtual void set_xf_number_format(size_t index) SAL_OVERRIDE;
     186             :     virtual void set_xf_font(size_t index) SAL_OVERRIDE;
     187             :     virtual void set_xf_fill(size_t index) SAL_OVERRIDE;
     188             :     virtual void set_xf_border(size_t index) SAL_OVERRIDE;
     189             :     virtual void set_xf_protection(size_t index) SAL_OVERRIDE;
     190             :     virtual void set_xf_style_xf(size_t index) SAL_OVERRIDE;
     191             :     virtual void set_xf_apply_alignment(bool b) SAL_OVERRIDE;
     192             :     virtual void set_xf_horizontal_alignment(orcus::spreadsheet::hor_alignment_t align) SAL_OVERRIDE;
     193             :     virtual void set_xf_vertical_alignment(orcus::spreadsheet::ver_alignment_t align) SAL_OVERRIDE;
     194             : 
     195             :     // cell style entry
     196             : 
     197             :     virtual void set_cell_style_count(size_t n) SAL_OVERRIDE;
     198             :     virtual void set_cell_style_name(const char* s, size_t n) SAL_OVERRIDE;
     199             :     virtual void set_cell_style_xf(size_t index) SAL_OVERRIDE;
     200             :     virtual void set_cell_style_builtin(size_t index) SAL_OVERRIDE;
     201             :     virtual size_t commit_cell_style() SAL_OVERRIDE;
     202             : };
     203             : 
     204           0 : class ScOrcusFactory : public orcus::spreadsheet::iface::import_factory
     205             : {
     206           0 :     struct StringCellCache
     207             :     {
     208             :         ScAddress maPos;
     209             :         size_t mnIndex;
     210             : 
     211             :         StringCellCache(const ScAddress& rPos, size_t nIndex);
     212             :     };
     213             : 
     214             :     typedef boost::unordered_map<OUString, size_t, OUStringHash> StringHashType;
     215             :     typedef std::vector<StringCellCache> StringCellCaches;
     216             : 
     217             :     ScDocumentImport maDoc;
     218             : 
     219             :     std::vector<OUString> maStrings;
     220             :     StringHashType maStringHash;
     221             : 
     222             :     StringCellCaches maStringCells;
     223             :     ScOrcusGlobalSettings maGlobalSettings;
     224             :     ScOrcusSharedStrings maSharedStrings;
     225             :     boost::ptr_vector<ScOrcusSheet> maSheets;
     226             :     ScOrcusStyles maStyles;
     227             : 
     228             :     int mnProgress;
     229             : 
     230             :     com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator> mxStatusIndicator;
     231             : 
     232             : public:
     233             :     ScOrcusFactory(ScDocument& rDoc);
     234             : 
     235             :     virtual orcus::spreadsheet::iface::import_sheet* append_sheet(const char *sheet_name, size_t sheet_name_length) SAL_OVERRIDE;
     236             :     virtual orcus::spreadsheet::iface::import_sheet* get_sheet(const char *sheet_name, size_t sheet_name_length) SAL_OVERRIDE;
     237             :     virtual orcus::spreadsheet::iface::import_sheet* get_sheet(orcus::spreadsheet::sheet_t sheet_index) SAL_OVERRIDE;
     238             :     virtual orcus::spreadsheet::iface::import_global_settings* get_global_settings() SAL_OVERRIDE;
     239             :     virtual orcus::spreadsheet::iface::import_shared_strings* get_shared_strings() SAL_OVERRIDE;
     240             :     virtual orcus::spreadsheet::iface::import_styles* get_styles() SAL_OVERRIDE;
     241             :     virtual void finalize() SAL_OVERRIDE;
     242             : 
     243             :     size_t appendString(const OUString& rStr);
     244             :     size_t addString(const OUString& rStr);
     245             : 
     246             :     void pushStringCell(const ScAddress& rPos, size_t nStrIndex);
     247             : 
     248             :     void incrementProgress();
     249             : 
     250             :     void setStatusIndicator(const com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator>& rIndicator);
     251             : };
     252             : 
     253             : #endif
     254             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10