00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef OpenCalc_IMPORT_H__
00022 #define OpenCalc_IMPORT_H__
00023
00024 #include <KoFilter.h>
00025 #include "kspread_format.h"
00026
00027 #include <qdict.h>
00028 #include <qdom.h>
00029
00030 class KoStyleStack;
00031 class KoStore;
00032
00033 namespace KSpread
00034 {
00035 class Cell;
00036 class Conditional;
00037 class Doc;
00038 class Sheet;
00039 class Validity;
00040 }
00041
00042 class OpenCalcImport : public KoFilter
00043 {
00044 Q_OBJECT
00045 public:
00046 OpenCalcImport( KoFilter * parent, const char * name, const QStringList & );
00047 virtual ~OpenCalcImport();
00048
00049 virtual KoFilter::ConversionStatus convert( QCString const & from, QCString const & to );
00050
00051
00052 private:
00053
00054 class OpenCalcPoint
00055 {
00056 public:
00057 OpenCalcPoint( QString const & str );
00058
00059 QString table;
00060 QString translation;
00061 QPoint topLeft;
00062 QPoint botRight;
00063 bool isRange;
00064 };
00065
00066 enum bPos { Left, Top, Right, Bottom, Fall, GoUp, Border };
00067
00068 KSpread::Doc * m_doc;
00069 KSpread::Format * m_defaultLayout;
00070
00071 QDomDocument m_content;
00072 QDomDocument m_meta;
00073 QDomDocument m_settings;
00074
00075 QDict<QDomElement> m_styles;
00076 QDict<KSpread::Format> m_defaultStyles;
00077 QDict<QString> m_formats;
00078 QMap<QString,QDomElement> m_validationList;
00079
00080 QStringList m_namedAreas;
00081
00082 int readMetaData();
00083 bool parseBody( int numOfTables );
00084 void insertStyles( QDomElement const & element );
00085 bool createStyleMap( QDomDocument const & styles );
00086 bool readRowFormat( QDomElement & rowNode, QDomElement * rowStyle,
00087 KSpread::Sheet * table, int & row, int & number, bool last );
00088 bool readColLayouts( QDomElement & content, KSpread::Sheet * table );
00089 bool readRowsAndCells( QDomElement & content, KSpread::Sheet * table );
00090 bool readCells( QDomElement & rowNode, KSpread::Sheet * table, int row, int & columns );
00091 void convertFormula( QString & text, QString const & f ) const;
00092 void loadFontStyle( KSpread::Format * layout, QDomElement const * font ) const;
00093 void readInStyle( KSpread::Format * layout, QDomElement const & style );
00094 void loadStyleProperties( KSpread::Format * layout, QDomElement const & property ) const;
00095 void loadBorder( KSpread::Format * layout, QString const & borderDef, bPos pos ) const;
00096 void loadTableMasterStyle( KSpread::Sheet * table, QString const & stylename );
00097 QString * loadFormat( QDomElement * element,
00098 KSpread::FormatType & formatType,
00099 QString name );
00100 void checkForNamedAreas( QString & formula ) const;
00101 void loadOasisCellValidation( const QDomElement&body );
00102 void loadOasisValidation( KSpread::Validity* val, const QString& validationName );
00103 void loadOasisValidationCondition( KSpread::Validity* val,QString &valExpression );
00104 void loadOasisAreaName( const QDomElement&body );
00105 void loadOasisMasterLayoutPage( KSpread::Sheet * table,KoStyleStack &styleStack );
00106 void loadOasisValidationValue( KSpread::Validity* val, const QStringList &listVal );
00107 QString translatePar( QString & par ) const;
00108 void loadCondition( KSpread::Cell*cell,const QDomElement &property );
00109 void loadOasisCondition(KSpread::Cell*cell,const QDomElement &property );
00110 void loadOasisConditionValue( const QString &styleCondition, KSpread::Conditional &newCondition );
00111 void loadOasisCondition( QString &valExpression, KSpread::Conditional &newCondition );
00112 void loadOasisValidationValue( const QStringList &listVal, KSpread::Conditional &newCondition );
00113 KoFilter::ConversionStatus loadAndParse( QDomDocument& doc, const QString& fileName,KoStore *m_store );
00114
00115 KoFilter::ConversionStatus openFile();
00116 };
00117
00118 #endif // OpenCalc_IMPORT_H__
00119