145
145
m_sep = sep; //store sep for section end
147
147
//type of the section break
148
kDebug(30513) << "sep->bkc = " << sep->bkc;
148
kDebug(30513) << "section" << m_sectionNumber << "| sep->bkc:" << sep->bkc;
150
150
//page layout could change
151
151
if (sep->bkc != 1) {
292
if (m_document->omittMasterPage()) {
293
kDebug(30513) << "Omitting headers/footers because master-page was omitted!";
292
if (m_document->omittMasterPage() || m_document->useLastMasterPage()) {
293
kDebug(30513) << "Processing of headers/footers cancelled, master-page creation omitted.";
296
296
//NOTE: only parse headers if we're in a section that can have new headers
797
797
outlineLevel = paragraphProperties->pap().ilvl + 1;
799
799
// List processing
800
// This takes car of all the cases:
800
// This takes care of all the cases:
802
802
// - A list with higher level than before
803
803
// - A list with lower level than before
862
862
//add nested field snippets to this paragraph
863
863
if (m_fldStates.empty()) {
864
QList<QString>* list = &fld_snippets;
865
while (!list->isEmpty()) {
864
QList<QString>* flds = &fld_snippets;
865
while (!flds->isEmpty()) {
866
866
//add writer content to m_paragraph as a runOfText with no text style
867
m_paragraph->addRunOfText(list->takeFirst(), 0, QString(""), m_parser->styleSheet());
867
m_paragraph->addRunOfText(flds->takeFirst(), 0, QString(""), m_parser->styleSheet());
926
926
//NOTE: The content between fieldStart and fieldSeparator represents field
927
927
//instructions and the content between fieldSeparator and fieldEnd
928
//represents the field result.
929
kDebug(30513) << "fld->flt = " << hex << fld->flt;
928
//represents the field RESULT [optional]. In most cases the field RESULT
929
//stores the complete information (instruction are applied by msword).
930
kDebug(30513) << "fld->flt:" << fld->flt << "(" << hex << fld->flt << ")";
932
933
if (m_insideField) {
944
945
//check to see if we can process this field type or not
945
946
switch (m_fieldType) {
948
kDebug(30513) << "processing field... EQ (Combined Characters)";
951
kDebug(30513) << "processing field... HYPERLINK";
954
kDebug(30513) << "processing field... MACROBUTTON";
958
m_paragraph->setContainsPageNumberField(true);
961
kDebug(30513) << "processing field... PAGEREF";
947
kWarning(30513) << "Warning: REF (Not supported yet)";
964
kWarning(30513) << "Warning: unsupported field (REF)";
948
965
m_fieldType = UNSUPPORTED;
951
kWarning(30513) << "Warning: TOC (Not supported yet)";
968
kWarning(30513) << "Warning: unsupported field (TOC)";
952
969
m_fieldType = UNSUPPORTED;
956
m_paragraph->setContainsPageNumberField(true);
959
kDebug(30513) << "processing field... PAGEREF";
962
kDebug(30513) << "processing field... EQ (Combined Characters)";
965
kDebug(30513) << "processing field... HYPERLINK";
969
kWarning(30513) << "Warning: unsupported field, just outputting text into document...";
977
kWarning(30513) << "Warning: field instructions not supported, storing field result!";
980
kWarning(30513) << "Warning: processing only a subset of field instructions!";
972
983
kWarning(30513) << "Warning: unrecognized field type, ignoring!";
1006
1017
void KWordTextHandler::fieldEnd(const wvWare::FLD* /*fld*/, wvWare::SharedPtr<const wvWare::Word97::CHP> chp)
1008
1019
// Q_UNUSED(chp);
1011
//process different fields
1012
//we could be writing to content.xml or styles.xml (in a header)
1021
//process different fields, we could be writing to content.xml or
1022
//styles.xml (header/footer)
1015
1025
buf.open(QIODevice::WriteOnly);
1020
1030
switch (m_fieldType) {
1022
writer.startElement("text:page-count");
1023
writer.endElement();
1026
writer.startElement("text:page-number");
1027
writer.addAttribute("text:select-page", "current");
1028
writer.endElement();
1031
//NOTE: reference-format can be: chapter, direction, page, text
1032
if (str->contains("PAGEREF")) {
1033
str->remove("PAGEREF");
1035
//we should create a hyperlink to the bookmarked paragraph
1036
if (str->contains("\\h")) {
1042
*str = str->trimmed();
1043
writer.startElement("text:bookmark-ref");
1044
writer.addAttribute("text:reference-format", tmp);
1045
writer.addAttribute("text:ref-name", *str);
1046
writer.addTextNode(m_fldResult);
1047
writer.endElement();
1049
case EQ: // combined characters stored as 'equation'
1032
//TODO: nested fields support required
1033
//NOTE: actually combined characters stored as 'equation'
1051
1035
QRegExp rx("eq \\\\o\\(\\\\s\\\\up 36\\(([^\\)]*)\\),\\\\s\\\\do 12\\(([^\\)]*)\\)\\)");
1052
1036
int where = rx.indexIn(*str);
1082
1066
//else a frame or drawing shape acting as a hyperlink already processed
1069
//TODO: nested fields support required
1071
QRegExp rx("MACROBUTTON\\s\\s?\\w+\\s\\s?(.+)$");
1072
*str = str->trimmed();
1073
if (rx.indexIn(*str) >= 0) {
1074
m_paragraph->addRunOfText(rx.cap(1), chp, QString(""), m_parser->styleSheet());
1079
writer.startElement("text:page-count");
1080
writer.endElement();
1083
writer.startElement("text:page-number");
1084
writer.addAttribute("text:select-page", "current");
1085
writer.endElement();
1088
//NOTE: reference-format can be: chapter, direction, page, text
1089
if (str->contains("PAGEREF")) {
1090
str->remove("PAGEREF");
1092
//we should create a hyperlink to the bookmarked paragraph
1093
if (str->contains("\\h")) {
1099
*str = str->trimmed();
1100
writer.startElement("text:bookmark-ref");
1101
writer.addAttribute("text:reference-format", tmp);
1102
writer.addAttribute("text:ref-name", *str);
1103
writer.addTextNode(m_fldResult);
1104
writer.endElement();
1107
//TODO: nested fields support required
1109
QRegExp rx_txt("SYMBOL\\s{2}(\\S+)\\s+.+$");
1111
*str = str->trimmed();
1113
//check for text in field instructions
1114
if (rx_txt.indexIn(*str) >= 0) {
1115
txt = rx_txt.cap(1);
1118
if (str->contains("\\a")) {
1119
QRegExp rx16("0\\D.+");
1123
if (rx16.indexIn(txt) >= 0) {
1124
n = txt.toInt(&ok, 16);
1127
n = txt.toInt(&ok, 10);
1130
tmp.append((char) n);
1134
if (str->contains("\\u")) {
1135
qDebug() << "Warning: unicode symbols not supported!";
1138
//default value (check the corresponding test)
1139
if (tmp.isEmpty()) {
1142
m_paragraph->addRunOfText(tmp, chp, QString(""), m_parser->styleSheet());
1142
1203
//processing field instructions
1143
1204
if (!m_fieldAfterSeparator) {
1144
1205
switch (m_fieldType) {
1148
1211
m_fldInst.append(newText);
1151
kDebug(30513) << "Ignoring field instructions.";
1214
kDebug(30513) << "Ignoring field instructions!";