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
121
122
123
124
125
126
127
128
129
130
131
132
|
/* This file is part of the KDE project
Copyright (C) 2001, 2002, 2004 Nicolas GOUTTE <goutte@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 _IMPORT_FORMATTING_H
#define _IMPORT_FORMATTING_H
#include <tqptrstack.h>
#include <tqstring.h>
#include <tqcolor.h>
#include <tqxml.h>
#include <tqdom.h>
#include "ImportHelpers.h"
// Tags in lower case (e.g. <c>) are AbiWord's ones.
// Tags in upper case (e.g. <TEXT>) are KWord's ones.
// Note: as we are not validating anything, we are quite tolerant about the file
// that we will read.
/**
* States
*
* Tags that we do not care of:
* \<abiword\> (or \<awml\>), \<data\>, \<styles\>, \<ignorewords\>, \<lists\>, \<metadata\>
*
* Tags that we do not support (however KWord could):
* \<bookmark\>, \<l\>
*
* Tags that we cannot support (lack of support in KWord):
* N/A
*
* Properties that we do not or cannot support:
* page-margin-footer, page-margin-header, lang, font-stretch, keep-with-next...
*/
enum StackItemElementType{
ElementTypeUnknown = 0,
ElementTypeBottom, ///< Bottom of the stack
ElementTypeIgnore, ///< Element is known but ignored
ElementTypeEmpty, ///< Element is empty (\<pagesize\>, \<s\>, \<image\>, \<field\>, \<br\>, \<cbr\>, \<pbr\>)
ElementTypeSection, ///< \<section\>
ElementTypeParagraph, ///< \<p\>
ElementTypeContent, ///< \<c\> (not child of \<a\>), also \<a\> if it points to a bookmark
ElementTypeRealData, ///< \<d\>
ElementTypeAnchor, ///< \<a\>
ElementTypeAnchorContent,///< \<c\> when child of \<a\>
ElementTypeIgnoreWord, ///< \<iw\>
ElementTypeRealMetaData,///< \<m\>
ElementTypeFoot, ///< \<foot\>
ElementTypeTable, ///< \<table\>
ElementTypeCell ///< \<cell\>
};
class StackItem
{
public:
StackItem();
~StackItem();
public:
TQString itemName; ///< Name of the tag (only for error purposes)
StackItemElementType elementType;
TQDomElement m_frameset; ///< current \<FRAMESET\>
TQDomElement stackElementParagraph; ///< \<PARAGRAPH\>
TQDomElement stackElementText; ///< \<TEXT\>
TQDomElement stackElementFormatsPlural; ///< \<FORMATS\>
TQString fontName; ///< font name but for \<d\>: name
int fontSize;
int pos; ///< Position
bool italic;
bool bold; ///< bold but for \<d\>: is base64 coded?
bool underline;
bool strikeout;
TQColor fgColor;
TQColor bgColor;
int textPosition; ///< Normal (0), subscript(1), superscript (2)
TQString strTemp1; /**< for \<d\>: mime type
* for \<a\>: link reference
* for \<m\>: key
* for \<table\>: KWord's table name
*/
TQString strTemp2; /**< for \<d\>: collecting the data
* for \<a\>: link name
* for \<iw\>: collecting the data (i.e. word to ignore)
* for \<m\>: value of the meta data
* for \<table\>: Number of the table (needed as I18N does not allow adding phrases)
*/
/**
* for tables (\<table\>, \<cell\>): defines the widths of the columns.
* Be careful: we are using the shallow copy mechanism of TQt. Use TQMemArray::detach when needed to avoid modifying the parents
*/
TQMemArray<double> m_doubleArray;
};
class StackItemStack : public TQPtrStack<StackItem>
{
public:
StackItemStack(void) { }
virtual ~StackItemStack(void) { }
};
class StyleData;
void PopulateProperties(StackItem* stackItem, const TQString& strStyleProps,
const TQXmlAttributes& attributes, AbiPropsMap& abiPropsMap,
const bool allowInit);
void AddFormat(TQDomElement& formatElementOut, StackItem* stackItem,
TQDomDocument& mainDocument);
void AddLayout(const TQString& strStyleName, TQDomElement& layoutElement,
StackItem* stackItem, TQDomDocument& mainDocument,
const AbiPropsMap& abiPropsMap, const int level, const bool isStyle);
void AddStyle(TQDomElement& styleElement, const TQString& strStyleName,
const StyleData& styleData, TQDomDocument& mainDocument);
#endif // _IMPORT_FORMATTING_H
|