summaryrefslogtreecommitdiffstats
path: root/tools/activeqt/dumpdoc/main.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 09:18:55 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 09:18:55 (GMT)
commite5fcad302d86d316390c6b0f62759a067313e8a9 (patch)
treec2afbf6f1066b6ce261f14341cf6d310e5595bc1 /tools/activeqt/dumpdoc/main.cpp
downloadQt-e5fcad302d86d316390c6b0f62759a067313e8a9.zip
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.bz2
Long live Qt 4.5!
Diffstat (limited to 'tools/activeqt/dumpdoc/main.cpp')
-rw-r--r--tools/activeqt/dumpdoc/main.cpp146
1 files changed, 146 insertions, 0 deletions
diff --git a/tools/activeqt/dumpdoc/main.cpp b/tools/activeqt/dumpdoc/main.cpp
new file mode 100644
index 0000000..87b9540
--- /dev/null
+++ b/tools/activeqt/dumpdoc/main.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QAxObject>
+#include <QFile>
+#include <QTextStream>
+#include <qt_windows.h>
+
+QT_USE_NAMESPACE
+
+int main(int argc, char **argv)
+{
+ CoInitialize(0);
+
+ enum State {
+ Default = 0,
+ OutOption
+ } state;
+ state = Default;
+
+ QByteArray outname;
+ QByteArray object;
+
+ for (int a = 1; a < argc; ++a) {
+ QByteArray arg(argv[a]);
+ const char first = arg[0];
+ switch(state) {
+ case Default:
+ if (first == '-' || first == '/') {
+ arg = arg.mid(1);
+ arg.toLower();
+ if (arg == "o")
+ state = OutOption;
+ else if (arg == "v") {
+ qWarning("dumpdoc: Version 1.0");
+ return 0;
+ } else if (arg == "h") {
+ qWarning("dumpdoc Usage:\n\tdumpdoc object [-o <file>]"
+ " \n\tobject : object[/subobject]*"
+ " \n\tsubobject: property\n"
+ " \nexample:\n\tdumpdoc Outlook.Application/Session/CurrentUser -o outlook.html");
+ return 0;
+ }
+ } else {
+ object = arg;
+ }
+ break;
+ case OutOption:
+ outname = arg;
+ state = Default;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (object.isEmpty()) {
+ qWarning("dumpdoc: No object name provided.\n"
+ " Use -h for help.");
+ return -1;
+ }
+ QFile outfile;
+ if (!outname.isEmpty()) {
+ outfile.setFileName(QString::fromLatin1(outname.constData()));
+ if (!outfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ qWarning("dumpdoc: Could not open output file '%s'", outname.data());
+ }
+ } else {
+ outfile.open(stdout, QIODevice::WriteOnly);
+ }
+ QTextStream out(&outfile);
+
+ QByteArray subobject = object;
+ int index = subobject.indexOf('/');
+ if (index != -1)
+ subobject = subobject.left(index);
+
+ QAxObject topobject(QString::fromLatin1(subobject.constData()));
+
+ if (topobject.isNull()) {
+ qWarning("dumpdoc: Could not instantiate COM object '%s'", subobject.data());
+ return -2;
+ }
+
+ QAxObject *axobject = &topobject;
+ while (index != -1 && axobject) {
+ index++;
+ subobject = object.mid(index);
+ if (object.indexOf('/', index) != -1) {
+ int oldindex = index;
+ index = object.indexOf('/', index);
+ subobject = object.mid(oldindex, index-oldindex);
+ } else {
+ index = -1;
+ }
+
+ axobject = axobject->querySubObject(subobject);
+ }
+ if (!axobject || axobject->isNull()) {
+ qWarning("dumpdoc: Subobject '%s' does not exist in '%s'", subobject.data(), object.data());
+ return -3;
+ }
+
+ QString docu = axobject->generateDocumentation();
+ out << docu;
+ return 0;
+}