<commit_before>/* TextRunStyle: Stores (and writes) paragraph/span-style-based information
 * (e.g.: a paragraph might be bold) that is needed at the head of an OO
 * document.
 *
 * Copyright (C) 2002-2004 <NAME> (<EMAIL>)
 * Copyright (C) 2004 Net Integration Technologies, Inc. (http://www.net-itech.com)
 * Copyright (C) 2004 <NAME> (<EMAIL>)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 * For further information visit http://libwpd.sourceforge.net
 *
 */

/* "This product is not manufactured, approved, or supported by
 * Corel Corporation or Corel Corporation Limited."
 */
#include "FilterInternal.hxx"
#include "TextRunStyle.hxx"
#include "WriterProperties.hxx"
#include "DocumentElement.hxx"

#ifdef _MSC_VER
#include <minmax.h>
#endif

#include <string.h>

ParagraphStyle::ParagraphStyle(WPXPropertyList *pPropList, const WPXPropertyListVector &xTabStops, const WPXString &sName) :
    mpPropList(pPropList),
    mxTabStops(xTabStops),
    msName(sName)
{
}

ParagraphStyle::~ParagraphStyle()
{
    delete mpPropList;
}

void ParagraphStyle::write(DocumentHandler *pHandler) const
{
    WRITER_DEBUG_MSG(("Writing a paragraph style..\n"));

        WPXPropertyList propList;
    propList.insert("style:name", msName.cstr());
    propList.insert("style:family", "paragraph");
    propList.insert("style:parent-style-name", (*mpPropList)["style:parent-style-name"]->getStr());
    if ((*mpPropList)["style:master-page-name"])
        propList.insert("style:master-page-name", (*mpPropList)["style:master-page-name"]->getStr());
        pHandler->startElement("style:style", propList);

        propList.clear();
    WPXPropertyList::Iter k((*mpPropList));
    for (k.rewind(); k.next(); )
    {
                if (strcmp(k.key(), "style:list-style-name") == 0)
                        propList.insert("style:list-style-name", k()->getStr());
        if (strcmp(k.key(), "fo:margin-left") == 0)
            propList.insert("fo:margin-left", k()->getStr());
        if (strcmp(k.key(), "fo:margin-right") == 0)
            propList.insert("fo:margin-right", k()->getStr());
        if (strcmp(k.key(), "fo:text-indent") == 0)
            propList.insert("fo:text-indent", k()->getStr());
        if (strcmp(k.key(), "fo:margin-top") == 0)
            propList.insert("fo:margin-top", k()->getStr());
        if (strcmp(k.key(), "fo:margin-bottom") == 0)
            propList.insert("fo:margin-bottom", k()->getStr());
        if (strcmp(k.key(), "fo:line-height") == 0)
            propList.insert("fo:line-height", k()->getStr());
        if (strcmp(k.key(), "fo:break-before") == 0)
            propList.insert("fo:break-before", k()->getStr());
        if (strcmp(k.key(), "fo:text-align") == 0)
            propList.insert("fo:text-align", k()->getStr());
                if (strcmp(k.key(), "fo:text-align-last") == 0)
                        propList.insert("fo:text-align-last", k()->getStr());
    }

    propList.insert("style:justify-single-word", "false");
    pHandler->startElement("style:properties", propList);

        if (mxTabStops.count() > 0)
        {
                TagOpenElement tabListOpen("style:tab-stops");
                tabListOpen.write(pHandler);
                WPXPropertyListVector::Iter i(mxTabStops);
                for (i.rewind(); i.next();)
                {
                        TagOpenElement tabStopOpen("style:tab-stop");<commit_msg>writerperfect-nocondensedparagraphs.diff: no negative paragraph height.<commit_after>/* TextRunStyle: Stores (and writes) paragraph/span-style-based information
 * (e.g.: a paragraph might be bold) that is needed at the head of an OO
 * document.
 *
 * Copyright (C) 2002-2004 <NAME> (<EMAIL>)
 * Copyright (C) 2004 Net Integration Technologies, Inc. (http://www.net-itech.com)
 * Copyright (C) 2004 <NAME> (<EMAIL>)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 * For further information visit http://libwpd.sourceforge.net
 *
 */

/* "This product is not manufactured, approved, or supported by
 * Corel Corporation or Corel Corporation Limited."
 */
#include "FilterInternal.hxx"
#include "TextRunStyle.hxx"
#include "WriterProperties.hxx"
#include "DocumentElement.hxx"

#ifdef _MSC_VER
#include <minmax.h>
#endif

#include <string.h>

ParagraphStyle::ParagraphStyle(WPXPropertyList *pPropList, const WPXPropertyListVector &xTabStops, const WPXString &sName) :
    mpPropList(pPropList),
    mxTabStops(xTabStops),
    msName(sName)
{
}

ParagraphStyle::~ParagraphStyle()
{
    delete mpPropList;
}

void ParagraphStyle::write(DocumentHandler *pHandler) const
{
    WRITER_DEBUG_MSG(("Writing a paragraph style..\n"));

        WPXPropertyList propList;
    propList.insert("style:name", msName.cstr());
    propList.insert("style:family", "paragraph");
    propList.insert("style:parent-style-name", (*mpPropList)["style:parent-style-name"]->getStr());
    if ((*mpPropList)["style:master-page-name"])
        propList.insert("style:master-page-name", (*mpPropList)["style:master-page-name"]->getStr());
        pHandler->startElement("style:style", propList);

        propList.clear();
    WPXPropertyList::Iter k((*mpPropList));
    for (k.rewind(); k.next(); )
    {
                if (strcmp(k.key(), "style:list-style-name") == 0)
                        propList.insert("style:list-style-name", k()->getStr());
        if (strcmp(k.key(), "fo:margin-left") == 0)
            propList.insert("fo:margin-left", k()->getStr());
        if (strcmp(k.key(), "fo:margin-right") == 0)
            propList.insert("fo:margin-right", k()->getStr());
        if (strcmp(k.key(), "fo:text-indent") == 0)
            propList.insert("fo:text-indent", k()->getStr());
        if (strcmp(k.key(), "fo:margin-top") == 0)
            propList.insert("fo:margin-top", k()->getStr());
        if (strcmp(k.key(), "fo:margin-bottom") == 0)
        {
            if (k()->getFloat() > 0.0f)
                propList.insert("fo:margin-bottom", k()->getStr());
            else
                propList.insert("fo:margin-bottom", 0.0f);
        }
        if (strcmp(k.key(), "fo:line-height") == 0)
            propList.insert("fo:line-height", k()->getStr());
        if (strcmp(k.key(), "fo:break-before") == 0)
            propList.insert("fo:break-before", k()->getStr());
        if (strcmp(k.key(), "fo:text-align") == 0)
            propList.insert("fo:text-align", k()->getStr());
                if (strcmp(k.key(), "fo:text-align-last") == 0)
                        propList.insert("fo:text-align-last", k()->getStr());
    }

    propList.insert("style:justify-single-word", "false");
    pHandler->startElement("style:properties", propList);

        if (mxTabStops.count() > 0)
        {
                TagOpenElement tabListOpen("style:tab-stops");
                tabListOpen.write(pHandler);
                WPXPropertyListVector::Iter i(mxTabStops);
                for (i.rewind(); i.next();)
                {
                        TagOpenElement tabStopOpen("style:tab-stop");
{'fraction_non_alphanumeric': 0.15759312320916904, 'fraction_numerical': 0.010506208213944603, 'mean_word_length': 3.138833992094862, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1205890', 'n_tokens_mistral': 2630, 'n_tokens_neox': 2527, 'n_words': 631}