summaryrefslogtreecommitdiffstats
path: root/filters/kspread/opencalc/opencalcimport.h
blob: cdb04ed28c987c41555cba61c8e48ec95447e6b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* This file is part of the KDE project
   Copyright (C) 2002 Norbert Andres <nandres@web.de>
   Copyright (C) 2004 Montel Laurent <montel@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef OpenCalc_IMPORT_H__
#define OpenCalc_IMPORT_H__

#include <KoFilter.h>
#include "kspread_format.h"

#include <tqdict.h>
#include <tqdom.h>

class KoStyleStack;
class KoStore;

namespace KSpread
{
class Cell;
class Conditional;
class Doc;
class Sheet;
class Validity;
}

class OpenCalcImport : public KoFilter
{
  TQ_OBJECT
  
 public:
  OpenCalcImport( KoFilter * parent, const char * name, const TQStringList & );
  virtual ~OpenCalcImport();

  virtual KoFilter::ConversionStatus convert( TQCString const & from, TQCString const & to );


 private:

  class OpenCalcPoint
  {
   public:
    OpenCalcPoint( TQString const & str );

    TQString table;
    TQString translation;
    TQPoint  topLeft;
    TQPoint  botRight;
    bool    isRange;
  };

  enum bPos { Left, Top, Right, Bottom, Fall, GoUp, Border };

  KSpread::Doc *    m_doc;
  KSpread::Format * m_defaultLayout;

  TQDomDocument    m_content;
  TQDomDocument    m_meta;
  TQDomDocument    m_settings;

  TQDict<TQDomElement>   m_styles;
  TQDict<KSpread::Format> m_defaultStyles;
  TQDict<TQString>       m_formats;
  TQMap<TQString,TQDomElement> m_validationList;

  TQStringList          m_namedAreas;

  int  readMetaData();
  bool parseBody( int numOfTables );
  void insertStyles( TQDomElement const & element );
  bool createStyleMap( TQDomDocument const & styles );
  bool readRowFormat( TQDomElement & rowNode, TQDomElement * rowStyle,
                      KSpread::Sheet * table, int & row, int & number, bool last );
  bool readColLayouts( TQDomElement & content, KSpread::Sheet * table );
  bool readRowsAndCells( TQDomElement & content, KSpread::Sheet * table );
  bool readCells( TQDomElement & rowNode, KSpread::Sheet  * table, int row, int & columns );
  void convertFormula( TQString & text, TQString const & f ) const;
  void loadFontStyle( KSpread::Format * layout, TQDomElement const * font ) const;
  void readInStyle( KSpread::Format * layout, TQDomElement const & style );
  void loadStyleProperties( KSpread::Format * layout, TQDomElement const & property ) const;
  void loadBorder( KSpread::Format * layout, TQString const & borderDef, bPos pos ) const;
  void loadTableMasterStyle( KSpread::Sheet * table, TQString const & stylename );
  TQString * loadFormat( TQDomElement * element,
                        KSpread::FormatType & formatType,
                        TQString name );
  void checkForNamedAreas( TQString & formula ) const;
  void loadOasisCellValidation( const TQDomElement&body );
  void loadOasisValidation( KSpread::Validity* val, const TQString& validationName );
  void loadOasisValidationCondition( KSpread::Validity* val,TQString &valExpression );
  void loadOasisAreaName( const TQDomElement&body );
  void loadOasisMasterLayoutPage( KSpread::Sheet * table,KoStyleStack &styleStack );
  void loadOasisValidationValue( KSpread::Validity* val, const TQStringList &listVal );
    TQString translatePar( TQString & par ) const;
    void loadCondition( KSpread::Cell*cell,const TQDomElement &property );
    void loadOasisCondition(KSpread::Cell*cell,const TQDomElement &property );
    void loadOasisConditionValue( const TQString &styleCondition, KSpread::Conditional &newCondition );
    void loadOasisCondition( TQString &valExpression, KSpread::Conditional &newCondition );
    void loadOasisValidationValue( const TQStringList &listVal, KSpread::Conditional &newCondition );
    KoFilter::ConversionStatus loadAndParse( TQDomDocument& doc, const TQString& fileName,KoStore *m_store );

  KoFilter::ConversionStatus openFile();
};

#endif // OpenCalc_IMPORT_H__