<commit_before>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* EBookImportFilter: Sets up the filter, and calls DocumentCollector
 * to do the actual filtering
 *
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>

#include <libe-book/libe-book.h>

#include "EBookImportFilter.hxx"

using com::sun::star::uno::Sequence;
using com::sun::star::uno::Reference;
using com::sun::star::uno::Any;
using com::sun::star::uno::XInterface;
using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
using com::sun::star::uno::XComponentContext;

using libebook::EBOOKDocument;

bool EBookImportFilter::doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator )
{
    if (rFilterName == "FictionBook 2")
        return EBOOKDocument::parse(&rInput, &rGenerator, EBOOKDocument::TYPE_FICTIONBOOK2);
    else if (rFilterName == "PalmDoc")
        return EBOOKDocument::parse(&rInput, &rGenerator, EBOOKDocument::TYPE_PALMDOC);
    else if (rFilterName == "Plucker eBook")
        return EBOOKDocument::parse(&rInput, &rGenerator, EBOOKDocument::TYPE_PLUCKER);
    else if (rFilterName == "eReader eBook")
        return EBOOKDocument::parse(&rInput, &rGenerator, EBOOKDocument::TYPE_PEANUTPRESS);
    else if (rFilterName == "TealDoc")
        return EBOOKDocument::parse(&rInput, &rGenerator, EBOOKDocument::TYPE_TEALDOC);
    else if (rFilterName == "zTXT")
        return EBOOKDocument::parse(&rInput, &rGenerator, EBOOKDocument::TYPE_ZTXT);

    return false;
}
<commit_msg>fix return value for libe-book import filter<commit_after>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* EBookImportFilter: Sets up the filter, and calls DocumentCollector
 * to do the actual filtering
 *
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>

#include <libe-book/libe-book.h>

#include "EBookImportFilter.hxx"

using com::sun::star::uno::Sequence;
using com::sun::star::uno::Reference;
using com::sun::star::uno::Any;
using com::sun::star::uno::XInterface;
using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
using com::sun::star::uno::XComponentContext;

using libebook::EBOOKDocument;

bool EBookImportFilter::doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator )
{
    EBOOKDocument::Type type = EBOOKDocument::TYPE_UNKNOWN;

    if (rFilterName == "FictionBook 2")
        type = EBOOKDocument::TYPE_FICTIONBOOK2;
    else if (rFilterName == "PalmDoc")
        type = EBOOKDocument::TYPE_PALMDOC;
    else if (rFilterName == "Plucker eBook")
        type = EBOOKDocument::TYPE_PLUCKER;
    else if (rFilterName == "eReader eBook")
        type = EBOOKDocument::TYPE_PEANUTPRESS;
    else if (rFilterName == "TealDoc")
        type = EBOOKDocument::TYPE_TEALDOC;
    else if (rFilterName == "zTXT")
        type = EBOOKDocument::TYPE_ZTXT;

    if (EBOOKDocument::TYPE_UNKNOWN != type)
        return EBOOKDocument::RESULT_OK == EBOOKDocument::parse(&rInput, &rGenerator, type);

    return false;
}

{'fraction_non_alphanumeric': 0.13746991174110726, 'fraction_numerical': 0.004279219042524739, 'mean_word_length': 4.936507936507937, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5389424', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1202, 'n_words': 303}