Author: axeld Date: 2010-05-21 13:26:48 +0200 (Fri, 21 May 2010) New Revision: 36883 Changeset: http://dev.haiku-os.org/changeset/36883/haiku Modified: haiku/trunk/src/add-ons/translators/rtf/Jamfile haiku/trunk/src/add-ons/translators/rtf/main.cpp Log: * The RTF-Translator will now convert all command line arguments to plain text to stdout (mostly for testing). * Removed no longer needed packaging jam rule. Modified: haiku/trunk/src/add-ons/translators/rtf/Jamfile =================================================================== --- haiku/trunk/src/add-ons/translators/rtf/Jamfile 2010-05-21 10:59:19 UTC (rev 36882) +++ haiku/trunk/src/add-ons/translators/rtf/Jamfile 2010-05-21 11:26:48 UTC (rev 36883) @@ -1,27 +1,21 @@ SubDir HAIKU_TOP src add-ons translators rtf ; -SetSubDirSupportedPlatformsBeOSCompatible ; - # It's called RTF-Translator (with a dash) to differentiate it from the # RTFTranslator that comes with Gobe Productive (that doesn't support # STXT or plain text files output). SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ; -UsePrivateHeaders shared ; +UsePrivateHeaders shared storage ; Translator RTF-Translator : - # RTFTranslator classes main.cpp - RTFTranslator.cpp ConfigView.cpp - RTF.cpp + convert.cpp + RTF.cpp + RTFTranslator.cpp + : be translation libtranslatorsutils.a $(TARGET_LIBSUPC++) : true ; - -Package haiku-translationkit-cvs : - RTF-Translator - : boot home config add-ons Translators - ; Modified: haiku/trunk/src/add-ons/translators/rtf/main.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/rtf/main.cpp 2010-05-21 10:59:19 UTC (rev 36882) +++ haiku/trunk/src/add-ons/translators/rtf/main.cpp 2010-05-21 11:26:48 UTC (rev 36883) @@ -1,28 +1,63 @@ /* - * Copyright 2004-2005, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights reserved. + * Copyright 2004-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx * Distributed under the terms of the MIT License. */ -#include "RTFTranslator.h" -#include "RTF.h" +#include <stdio.h> +#include <string.h> +#include <Application.h> +#include <FileIO.h> +#include <TranslatorRoster.h> + #include "TranslatorWindow.h" -#include <TranslatorRoster.h> -#include <Application.h> +#include "convert.h" +#include "RTF.h" +#include "RTFTranslator.h" -#include <stdio.h> -#include <string.h> - int -main(int /*argc*/, char **/*argv*/) +main(int argc, char** argv) { + if (argc > 1) { + // Convert input files to plain text directly + BFileIO output(stdout); + int result = 0; + + for (int i = 1; i < argc; i++) { + BFile input; + status_t status = input.SetTo(argv[i], B_READ_ONLY); + if (status != B_OK) { + fprintf(stderr, "Could not open file \"%s\": %s\n", argv[i], + strerror(status)); + result = 1; + continue; + } + + RTF::Parser parser(input); + RTF::Header header; + + status = parser.Parse(header); + if (status != B_OK) { + fprintf(stderr, "Could not convert file \"%s\": %s\n", argv[i], + strerror(status)); + result = 1; + continue; + } + + convert_to_plain_text(header, output); + } + + return 1; + } + BApplication app("application/x-vnd.Haiku-RTFTranslator"); status_t result; - result = LaunchTranslatorWindow(new RTFTranslator, "RTF Settings", BRect(0, 0, 225, 175)); + result = LaunchTranslatorWindow(new RTFTranslator, "RTF Settings", + BRect(0, 0, 225, 175)); if (result != B_OK) return 1;