<commit_before>#include <iostream>
#include <DomainMapperTableHandler.hxx>

namespace dmapper {

using namespace ::com::sun::star;
using namespace ::std;

void DomainMapperTableHandler::startTable(unsigned int nRows,
                                          unsigned int /*nDepth*/,
                                          PropertyMapPtr /*pProps*/)
{
    m_pHandleSeq3 = HandleSequence3Pointer_t(new HandleSequence3_t(nRows));
    m_nHandle3Index = 0;
}

void DomainMapperTableHandler::endTable()
{
    PropertyValuesSeq2_t aCellProperties;
    PropertyValuesSeq_t aRowProperties;
    PropertyValues_t aTableProperties;

    sal_Int32 nRows = m_pHandleSeq3->getLength();
    char sBuffer[256];

    snprintf(sBuffer, sizeof(sBuffer), "%ld", nRows);

    clog << "<table rows=\"" << sBuffer << "\">" << endl;

    for (sal_Int32 nRow = 0; nRow < nRows; ++nRow)
    {
        HandleSequence2_t  aHandleSeq2 = (*m_pHandleSeq3)[nRow];

        sal_Int32 nCells = aHandleSeq2.getLength();

        snprintf(sBuffer, sizeof(sBuffer), "%ld", nCells);

        clog << "<table.row cells=\"" << sBuffer << "\">" << endl;

        for (sal_Int32 nCell = 0; nCell < nCells; ++nCell)
        {
            HandleSequence_t aHandleSeq = aHandleSeq2[nCell];

            sal_Int32 nHandles = aHandleSeq.getLength();

            snprintf(sBuffer, sizeof(sBuffer), "%ld", nHandles);

            clog << "<table.cell handles=\"" << sBuffer << "\">" << endl;

            for (sal_Int32 nHandle = 0; nHandle < nHandles; ++nHandle)
            {
                clog << "<table.text>" << endl;

                Handle_t aHandle = aHandleSeq[nHandle];

                rtl::OUString aOUStr = aHandle->getString();
                rtl::OString aOStr(aOUStr.getStr(), RTL_TEXTENCODING_ASCII_US,
                                   aOUStr.getLength());

                clog << aOStr.getStr() << endl;
                clog << "</table.text>" << endl;
            }

            clog << "</table.cell>" << endl;
        }

        clog << "</table.row>" << endl;
    }

    clog << "</table>" << endl;

    if (m_pHandleSeq3->getLength() > 0)
    {
        try
        {
            m_xText->convertToTable(*m_pHandleSeq3, aCellProperties,
                                    aRowProperties,
                                    aTableProperties);
        }
        catch (lang::IllegalArgumentException e)
        {
            clog << "failed to import table!" << endl;
        }
    }
}

void DomainMapperTableHandler::startRow(unsigned int nCells,
                                        PropertyMapPtr /*pProps*/)
{
    m_pHandleSeq2 = HandleSequence2Pointer_t(new HandleSequence2_t(nCells));
    m_nHandle2Index = 0;
}

void DomainMapperTableHandler::endRow()
{
    (*m_pHandleSeq3)[m_nHandle3Index] = *m_pHandleSeq2;
    ++m_nHandle3Index;
}

void DomainMapperTableHandler::startCell(const Handle_t & start,
                                         PropertyMapPtr /*pProps*/)
{
    m_pHandleSeq = HandleSequencePointer_t(new HandleSequence_t(2));
    (*m_pHandleSeq)[0] = start->getStart();
}

void DomainMapperTableHandler::endCell(const Handle_t & end)
{
    (*m_pHandleSeq)[1] = end->getEnd();
    (*m_pHandleSeq2)[m_nHandle2Index] = *m_pHandleSeq;
    ++m_nHandle2Index;
}

}<commit_msg>debug information<commit_after>#include <iostream>
#include <DomainMapperTableHandler.hxx>

namespace dmapper {

using namespace ::com::sun::star;
using namespace ::std;

static void lcl_printHandle(const Handle_t rHandle)
{
    rtl::OUString aOUStr = rHandle->getString();
    rtl::OString aOStr(aOUStr.getStr(), RTL_TEXTENCODING_ASCII_US,
                       aOUStr.getLength());

    clog << aOStr.getStr() << endl;
}

void DomainMapperTableHandler::startTable(unsigned int nRows,
                                          unsigned int /*nDepth*/,
                                          PropertyMapPtr /*pProps*/)
{
    m_pHandleSeq3 = HandleSequence3Pointer_t(new HandleSequence3_t(nRows));
    m_nHandle3Index = 0;

#ifdef DEBUG
    char sBuffer[256];
    snprintf(sBuffer, sizeof(sBuffer), "%d", nRows);
    clog << "<table rows=\"" << sBuffer << "\">" << endl;
#endif
}

void DomainMapperTableHandler::endTable()
{
#ifdef DEBUG
    clog << "</table>" << endl;
#endif

    PropertyValuesSeq2_t aCellProperties;
    PropertyValuesSeq_t aRowProperties;
    PropertyValues_t aTableProperties;

    if (m_pHandleSeq3->getLength() > 0)
    {
        try
        {
            m_xText->convertToTable(*m_pHandleSeq3, aCellProperties,
                                    aRowProperties,
                                    aTableProperties);
        }
        catch (lang::IllegalArgumentException e)
        {
#ifdef DEBUG
            clog << "failed to import table!" << endl;
#endif
        }
    }
}

void DomainMapperTableHandler::startRow(unsigned int nCells,
                                        PropertyMapPtr /*pProps*/)
{
    char sBuffer[256];
    snprintf(sBuffer, sizeof(sBuffer), "%d", nCells);

#ifdef DEBUG
    clog << "<table.row cells=\"" << sBuffer << "\">" << endl;
#endif

    m_pHandleSeq2 = HandleSequence2Pointer_t(new HandleSequence2_t(nCells));
    m_nHandle2Index = 0;
}

void DomainMapperTableHandler::endRow()
{
    (*m_pHandleSeq3)[m_nHandle3Index] = *m_pHandleSeq2;
    ++m_nHandle3Index;

#ifdef DEBUG
    clog << "</table.row>" << endl;
#endif
}

void DomainMapperTableHandler::startCell(const Handle_t & start,
                                         PropertyMapPtr /*pProps*/)
{
#ifdef DEBUG
    clog << "<table.cell>";
    lcl_printHandle(start);
    clog << ",";
#endif

    m_pHandleSeq = HandleSequencePointer_t(new HandleSequence_t(2));
    (*m_pHandleSeq)[0] = start->getStart();
}

void DomainMapperTableHandler::endCell(const Handle_t & end)
{
#ifdef DEBUG
    lcl_printHandle(end);
    clog << "</table.cell>" << endl;
#endif

    (*m_pHandleSeq)[1] = end->getEnd();
    (*m_pHandleSeq2)[m_nHandle2Index] = *m_pHandleSeq;
    ++m_nHandle2Index;
}

}
{'fraction_non_alphanumeric': 0.12959866220735786, 'fraction_numerical': 0.013043478260869565, 'mean_word_length': 2.41186537364518, 'pattern_counts': {'":': 0, '<': 116, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 19, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4737219', 'n_tokens_mistral': 1939, 'n_tokens_neox': 1836, 'n_words': 340}