<commit_before>#include "ConversionHelper.hxx"
#include "GraphicHelpers.hxx"

#include <ooxml/resourceids.hxx>

#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
#include <com/sun/star/text/WrapTextMode.hpp>

#include <iostream>
using namespace std;

namespace writerfilter {
namespace dmapper {

using namespace com::sun::star;

PositionHandler::PositionHandler( ) :
    Properties( )
{
    m_nOrient = text::VertOrientation::NONE;
    m_nRelation = text::RelOrientation::FRAME;
    m_nPosition = 0;
}

PositionHandler::~PositionHandler( )
{
}

void PositionHandler::attribute( Id aName, Value& rVal )
{
    sal_Int32 nIntValue = rVal.getInt( );
    switch ( aName )
    {
        case NS_ooxml::LN_CT_PosV_relativeFrom:
            {
                // TODO There are some other unhandled values
                static Id pVertRelValues[] =
                {
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_margin,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_paragraph,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_line
                };

                static sal_Int16 pVertRelations[] =
                {
                    text::RelOrientation::PAGE_PRINT_AREA,
                    text::RelOrientation::PAGE_FRAME,
                    text::RelOrientation::FRAME,
                    text::RelOrientation::TEXT_LINE
                };

                for ( int i = 0; i < 4; i++ )
                {
                    if ( pVertRelValues[i] == sal_uInt32( nIntValue ) )
                        m_nRelation = pVertRelations[i];
                }
            }
            break;
        case NS_ooxml::LN_CT_PosH_relativeFrom:
            {
                // TODO There are some other unhandled values
                static Id pHoriRelValues[] =
                {
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_margin,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_column,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_character
                };

                static sal_Int16 pHoriRelations[] =
                {
                    text::RelOrientation::PAGE_PRINT_AREA,
                    text::RelOrientation::PAGE_FRAME,
                    text::RelOrientation::FRAME,
                    text::RelOrientation::CHAR,
                };

                for ( int i = 0; i < 4; i++ )
                {
                    if ( pHoriRelValues[i] == sal_uInt32( nIntValue ) )
                        m_nRelation = pHoriRelations[i];
                }
            }
            break;
        default:;
    }
}

void PositionHandler::sprm( Sprm& rSprm )
{
    Value::Pointer_t pValue = rSprm.getValue();
    sal_Int32 nIntValue = pValue->getInt();

    switch ( rSprm.getId( ) )
    {
        case NS_ooxml::LN_CT_PosV_align:
            {
                static Id pVertValues[] =
                {
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignV_top,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignV_bottom,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignV_center,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignV_inside,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignV_outside
                };

                static sal_Int16 pVertOrients[] =
                {
                    text::VertOrientation::TOP,
                    text::VertOrientation::BOTTOM,
                    text::VertOrientation::CENTER,
                    text::VertOrientation::NONE,
                    text::VertOrientation::NONE
                };

                for ( int i = 0; i < 5; i++ )
                {
                    if ( pVertValues[i] == sal_uInt32( nIntValue ) )
                        m_nOrient = pVertOrients[i];
                }
            }
            break;
        case NS_ooxml::LN_CT_PosH_align:
            {
                static Id pHoriValues[] =
                {
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignH_left,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignH_right,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignH_center,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignH_inside,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignH_outside
                };

                static sal_Int16 pHoriOrients[] =
                {
                    text::HoriOrientation::LEFT,
                    text::HoriOrientation::RIGHT,
                    text::HoriOrientation::CENTER,
                    text::HoriOrientation::INSIDE,
                    text::HoriOrientation::OUTSIDE
                };

                for ( int i = 0; i < 5; i++ )
                {
                    if ( pHoriValues[i] == sal_uInt32( nIntValue ) )
                        m_nOrient = pHoriOrients[i];
                }
            }
            break;
        case NS_ooxml::LN_CT_PosH_posOffset:
        case NS_ooxml::LN_CT_PosV_posOffset:
            m_nPosition = ConversionHelper::convertEMUToMM100( nIntValue );
        default:;
    }
}

WrapHandler::WrapHandler( ) :
    Properties( ),
    m_nType( 0 ),
    m_nSide( 0 )
{
}

WrapHandler::~WrapHandler( )
{
}
<commit_msg>writerfilter09: added debugging code for PositionHandler<commit_after>#include "ConversionHelper.hxx"
#include "GraphicHelpers.hxx"

#include <ooxml/resourceids.hxx>

#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
#include <com/sun/star/text/WrapTextMode.hpp>

#ifdef DEBUG_DOMAINMAPPER
#include <resourcemodel/QNameToString.hxx>
#include "dmapperloggers.hxx"
#endif

#include <iostream>
using namespace std;

namespace writerfilter {
namespace dmapper {

using namespace com::sun::star;

PositionHandler::PositionHandler( ) :
    Properties( )
{
    m_nOrient = text::VertOrientation::NONE;
    m_nRelation = text::RelOrientation::FRAME;
    m_nPosition = 0;
}

PositionHandler::~PositionHandler( )
{
}

void PositionHandler::attribute( Id aName, Value& rVal )
{
#ifdef DEBUG_DOMAINMAPPER
    dmapper_logger->startElement("PositionHandler.attribute");
    dmapper_logger->attribute("name", (*QNameToString::Instance())(aName));
    dmapper_logger->attribute("value", rVal.toString());
#endif

    sal_Int32 nIntValue = rVal.getInt( );
    switch ( aName )
    {
        case NS_ooxml::LN_CT_PosV_relativeFrom:
            {
                // TODO There are some other unhandled values
                static Id pVertRelValues[] =
                {
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_margin,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_paragraph,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_line
                };

                static sal_Int16 pVertRelations[] =
                {
                    text::RelOrientation::PAGE_PRINT_AREA,
                    text::RelOrientation::PAGE_FRAME,
                    text::RelOrientation::FRAME,
                    text::RelOrientation::TEXT_LINE
                };

                for ( int i = 0; i < 4; i++ )
                {
                    if ( pVertRelValues[i] == sal_uInt32( nIntValue ) )
                        m_nRelation = pVertRelations[i];
                }
            }
            break;
        case NS_ooxml::LN_CT_PosH_relativeFrom:
            {
                // TODO There are some other unhandled values
                static Id pHoriRelValues[] =
                {
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_margin,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_column,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_character
                };

                static sal_Int16 pHoriRelations[] =
                {
                    text::RelOrientation::PAGE_PRINT_AREA,
                    text::RelOrientation::PAGE_FRAME,
                    text::RelOrientation::FRAME,
                    text::RelOrientation::CHAR,
                };

                for ( int i = 0; i < 4; i++ )
                {
                    if ( pHoriRelValues[i] == sal_uInt32( nIntValue ) )
                        m_nRelation = pHoriRelations[i];
                }
            }
            break;
        default:
#ifdef DEBUG_DOMAINMAPPER
            dmapper_logger->element("unhandled");
#endif
            break;
    }

#ifdef DEBUG_DOMAINMAPPER
    dmapper_logger->endElement("PositionHandler.attribute");
#endif
}

void PositionHandler::sprm( Sprm& rSprm )
{
#ifdef DEBUG_DOMAINMAPPER
    string sSprm = rSprm.toString();
    dmapper_logger->startElement("PositionHandler.sprm");
    dmapper_logger->attribute("sprm", sSprm);
#endif

    Value::Pointer_t pValue = rSprm.getValue();
    sal_Int32 nIntValue = pValue->getInt();

    switch ( rSprm.getId( ) )
    {
        case NS_ooxml::LN_CT_PosV_align:
            {
                static Id pVertValues[] =
                {
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignV_top,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignV_bottom,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignV_center,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignV_inside,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignV_outside
                };

                static sal_Int16 pVertOrients[] =
                {
                    text::VertOrientation::TOP,
                    text::VertOrientation::BOTTOM,
                    text::VertOrientation::CENTER,
                    text::VertOrientation::NONE,
                    text::VertOrientation::NONE
                };

                for ( int i = 0; i < 5; i++ )
                {
                    if ( pVertValues[i] == sal_uInt32( nIntValue ) )
                        m_nOrient = pVertOrients[i];
                }
            }
            break;
        case NS_ooxml::LN_CT_PosH_align:
            {
                static Id pHoriValues[] =
                {
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignH_left,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignH_right,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignH_center,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignH_inside,
                    NS_ooxml::LN_Value_wordprocessingDrawing_ST_AlignH_outside
                };

                static sal_Int16 pHoriOrients[] =
                {
                    text::HoriOrientation::LEFT,
                    text::HoriOrientation::RIGHT,
                    text::HoriOrientation::CENTER,
                    text::HoriOrientation::INSIDE,
                    text::HoriOrientation::OUTSIDE
                };

                for ( int i = 0; i < 5; i++ )
                {
                    if ( pHoriValues[i] == sal_uInt32( nIntValue ) )
                        m_nOrient = pHoriOrients[i];
                }
            }
            break;
        case NS_ooxml::LN_CT_PosH_posOffset:
        case NS_ooxml::LN_CT_PosV_posOffset:
            m_nPosition = ConversionHelper::convertEMUToMM100( nIntValue );
        default:
#ifdef DEBUG_DOMAINMAPPER
            dmapper_logger->element("unhandled");
#endif
            break;
    }

#ifdef DEBUG_DOMAINMAPPER
    dmapper_logger->endElement("PositionHandler.sprm");
#endif
}

WrapHandler::WrapHandler( ) :
    Properties( ),
    m_nType( 0 ),
    m_nSide( 0 )
{
}

WrapHandler::~WrapHandler( )
{
}

{'fraction_non_alphanumeric': 0.08615057978115304, 'fraction_numerical': 0.0057161522129675, 'mean_word_length': 1.7215555555555555, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 50}, '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': '3099048', 'n_tokens_mistral': 3815, 'n_tokens_neox': 3447, 'n_words': 471}