if you like to use word docx on qt .. yesterday a write a xslt converter....
xmlpatterns from qt its nice to use as xslt2 or xsltproc xslt1 and can run on mac linux or window
ActiveQt Word run only on window...
docx is all xml based and can use as template... to write new file... docx
https://github.com/pehohlva/qt-gmail.../docx2html.xsl
same to odt openformat:
https://github.com/pehohlva/qt-gmail...c/odt2html.xsl
args << "xsltproc";
bin_xsltproc
= execlocal
(QString("which"), args
).
simplified();
/// cmd is xmlpatterns or xsltproc
int success = -1;
debughere.append(" ");
debughere.append(args.join(" "));
console
(QString("EXEC: %1").
arg(debughere
));
process
->setReadChannelMode
(QProcess::MergedChannels);
process
->start
(cmd, args,
QIODevice::ReadOnly);
//// waitForFinished default int msecs = 30000 ok
if (!process->waitForFinished()) {
success = -1;
} else {
success = 1;
rec = process->readAll();
}
if (success == 1) {
return rec;
} else {
return QString("ERROR: Time out by %1").
arg(debughere
);
}
}
if (doc_continue && !bin_xsltproc.isEmpty()) {
/// convert xslt now by
console
(QString("Init xslt convert...%1.").
arg(bin_xsltproc
));
xsltparam << "--param";
xsltparam << "convert_time";
xsltparam <<
QString("'%1'").
arg(Tools
::TimeNow());
xsltparam << "--output";
xsltparam << indexhtmlnewfile;
xsltparam << worddocx2htmlstyle;
xsltparam << word_document.xml; /// by unzip docx
/// xslt param --param name "value"
const QString errorcmd
= execlocal
(bin_xsltproc, xsltparam
);
if (errorcmd.isEmpty()) {
console
(QString("Xslt convert successful document..."));
} else {
console
(QString("Xslt convert... say: %1").
arg(errorcmd
));
}
}
QStringList args;
args << "xsltproc";
bin_xsltproc = execlocal(QString("which"), args).simplified();
QString Document::execlocal(const QString cmd, const QStringList args) {
/// cmd is xmlpatterns or xsltproc
QString debughere = cmd;
int success = -1;
debughere.append(" ");
debughere.append(args.join(" "));
console(QString("EXEC: %1").arg(debughere));
QString rec;
QProcess *process = new QProcess(NULL);
process->setReadChannelMode(QProcess::MergedChannels);
process->start(cmd, args, QIODevice::ReadOnly);
//// waitForFinished default int msecs = 30000 ok
if (!process->waitForFinished()) {
success = -1;
} else {
success = 1;
rec = process->readAll();
}
if (success == 1) {
return rec;
} else {
return QString("ERROR: Time out by %1").arg(debughere);
}
}
if (doc_continue && !bin_xsltproc.isEmpty()) {
/// convert xslt now by
console(QString("Init xslt convert...%1.").arg(bin_xsltproc));
QStringList xsltparam;
xsltparam << "--param";
xsltparam << "convert_time";
xsltparam << QString("'%1'").arg(Tools::TimeNow());
xsltparam << "--output";
xsltparam << indexhtmlnewfile;
xsltparam << worddocx2htmlstyle;
xsltparam << word_document.xml; /// by unzip docx
/// xslt param --param name "value"
const QString errorcmd = execlocal(bin_xsltproc, xsltparam);
if (errorcmd.isEmpty()) {
console(QString("Xslt convert successful document..."));
} else {
console(QString("Xslt convert... say: %1").arg(errorcmd));
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks