diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2021-05-23 20:48:35 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2021-05-29 15:17:38 +0900 |
commit | d63c9d696eb6e2539528b99afc21f4086c9defe3 (patch) | |
tree | b3bfc97a66431a12cdd8f9379c0072673ede43df /tools/kthesaurus/main.cpp | |
parent | 5363fe3c36504c37bdc6dcfafd5f71daeae251e8 (diff) | |
download | koffice-d63c9d69.tar.gz koffice-d63c9d69.zip |
Renaming of files in preparation for code style tools.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 8b78a8791bc539bcffe7159f9d9714d577cb3d7d)
Diffstat (limited to 'tools/kthesaurus/main.cpp')
-rw-r--r-- | tools/kthesaurus/main.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/tools/kthesaurus/main.cpp b/tools/kthesaurus/main.cpp new file mode 100644 index 000000000..9db6e571b --- /dev/null +++ b/tools/kthesaurus/main.cpp @@ -0,0 +1,87 @@ +/*************************************************************************** + main.cpp - using the thesaurus KDataTool stand alone + ------------------- + begin : 2001-12-22 + copyright : (C) 2001 by Daniel Naber + email : daniel.naber@t-online.de + $Id: main.cpp 381440 2005-01-23 07:53:34Z mlaurent $ + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <tqstring.h> + +#include <tdeaboutdata.h> +#include <tdeapplication.h> +#include <tdecmdlineargs.h> +#include <kdatatool.h> +#include <kdebug.h> +#include <tdeglobal.h> +#include <tdelocale.h> +#include <koffice_export.h> +static TDECmdLineOptions options[] = +{ + { "+[term]", I18N_NOOP("Term to search for when starting up"), 0 }, + TDECmdLineLastOption +}; + +extern "C" KOFFICETOOLS_EXPORT int kdemain(int argc, char **argv) +{ + + TDEAboutData aboutData("kthesaurus", I18N_NOOP("KThesaurus"), "1.0", + I18N_NOOP( "KThesaurus - List synonyms" ), TDEAboutData::License_GPL, + I18N_NOOP( "(c) 2001 Daniel Naber" ) ); + + TDECmdLineArgs::init(argc, argv, &aboutData); + TDECmdLineArgs::addCmdLineOptions(options); + TDEApplication a; // KDataTool needs an instance + + // TODO: take term from command line! + + KService::Ptr service = KService::serviceByDesktopName("thesaurustool"); + if( ! service ) { + kdWarning() << "Could not find Service/KDataTool 'thesaurustool'!" << endl; + return 1; + } + + KDataToolInfo *info = new KDataToolInfo(service, 0); + KDataTool *tool = info->createTool(); + if ( !tool ) { + kdWarning() << "Could not create tool 'thesaurustool'!" << endl; + return 2; + } + +/* TODO: get selection(), not only clipboard! + TQClipboard *cb = TQApplication::clipboard(); + TQString text = cb->text(); + if( text.isNull() || text.length() > 50 ) { + // long texts are probably not supposed to be searched for + text = ""; + } +*/ + TQString text = ""; + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + if ( args->count() > 0 ) { + text = args->arg(0); + } + + TQString command = "thesaurus_standalone"; // 'standalone' will give us different buttons + TQString mimetype = "text/plain"; + TQString datatype = TQSTRING_OBJECT_NAME_STRING; + + //kdDebug() << "KThesaurus command=" << command + // << " dataType=" << info->dataType() << endl; + + tool->run(command, &text, datatype, mimetype); + + delete tool; + + return 0; +} |