filters

opencalcimport.h
1/* This file is part of the KDE project
2 Copyright (C) 2002 Norbert Andres <nandres@web.de>
3 Copyright (C) 2004 Montel Laurent <montel@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef OpenCalc_IMPORT_H__
22#define OpenCalc_IMPORT_H__
23
24#include <KoFilter.h>
25#include "kspread_format.h"
26
27#include <tqdict.h>
28#include <tqdom.h>
29
30class KoStyleStack;
31class KoStore;
32
33namespace KSpread
34{
35class Cell;
36class Conditional;
37class Doc;
38class Sheet;
39class Validity;
40}
41
42class OpenCalcImport : public KoFilter
43{
44 TQ_OBJECT
45
46 public:
47 OpenCalcImport( KoFilter * parent, const char * name, const TQStringList & );
48 virtual ~OpenCalcImport();
49
50 virtual KoFilter::ConversionStatus convert( TQCString const & from, TQCString const & to );
51
52
53 private:
54
55 class OpenCalcPoint
56 {
57 public:
58 OpenCalcPoint( TQString const & str );
59
60 TQString table;
61 TQString translation;
62 TQPoint topLeft;
63 TQPoint botRight;
64 bool isRange;
65 };
66
67 enum bPos { Left, Top, Right, Bottom, Fall, GoUp, Border };
68
69 KSpread::Doc * m_doc;
70 KSpread::Format * m_defaultLayout;
71
72 TQDomDocument m_content;
73 TQDomDocument m_meta;
74 TQDomDocument m_settings;
75
76 TQDict<TQDomElement> m_styles;
77 TQDict<KSpread::Format> m_defaultStyles;
78 TQDict<TQString> m_formats;
79 TQMap<TQString,TQDomElement> m_validationList;
80
81 TQStringList m_namedAreas;
82
83 int readMetaData();
84 bool parseBody( int numOfTables );
85 void insertStyles( TQDomElement const & element );
86 bool createStyleMap( TQDomDocument const & styles );
87 bool readRowFormat( TQDomElement & rowNode, TQDomElement * rowStyle,
88 KSpread::Sheet * table, int & row, int & number, bool last );
89 bool readColLayouts( TQDomElement & content, KSpread::Sheet * table );
90 bool readRowsAndCells( TQDomElement & content, KSpread::Sheet * table );
91 bool readCells( TQDomElement & rowNode, KSpread::Sheet * table, int row, int & columns );
92 void convertFormula( TQString & text, TQString const & f ) const;
93 void loadFontStyle( KSpread::Format * layout, TQDomElement const * font ) const;
94 void readInStyle( KSpread::Format * layout, TQDomElement const & style );
95 void loadStyleProperties( KSpread::Format * layout, TQDomElement const & property ) const;
96 void loadBorder( KSpread::Format * layout, TQString const & borderDef, bPos pos ) const;
97 void loadTableMasterStyle( KSpread::Sheet * table, TQString const & stylename );
98 TQString * loadFormat( TQDomElement * element,
99 KSpread::FormatType & formatType,
100 TQString name );
101 void checkForNamedAreas( TQString & formula ) const;
102 void loadOasisCellValidation( const TQDomElement&body );
103 void loadOasisValidation( KSpread::Validity* val, const TQString& validationName );
104 void loadOasisValidationCondition( KSpread::Validity* val,TQString &valExpression );
105 void loadOasisAreaName( const TQDomElement&body );
106 void loadOasisMasterLayoutPage( KSpread::Sheet * table,KoStyleStack &styleStack );
107 void loadOasisValidationValue( KSpread::Validity* val, const TQStringList &listVal );
108 TQString translatePar( TQString & par ) const;
109 void loadCondition( KSpread::Cell*cell,const TQDomElement &property );
110 void loadOasisCondition(KSpread::Cell*cell,const TQDomElement &property );
111 void loadOasisConditionValue( const TQString &styleCondition, KSpread::Conditional &newCondition );
112 void loadOasisCondition( TQString &valExpression, KSpread::Conditional &newCondition );
113 void loadOasisValidationValue( const TQStringList &listVal, KSpread::Conditional &newCondition );
114 KoFilter::ConversionStatus loadAndParse( TQDomDocument& doc, const TQString& fileName,KoStore *m_store );
115
116 KoFilter::ConversionStatus openFile();
117};
118
119#endif // OpenCalc_IMPORT_H__
120