Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/LibreOffice/cui/source/tabpages/   (Office von Apache Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 114 kB image not shown  

Quelle  paragrph.cxx   Sprache: C

 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * 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/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */


#include <memory>
#include <osl/diagnose.h>
#include <svl/style.hxx>
#include <sfx2/objsh.hxx>
#include <vcl/mnemonic.hxx>
#include <vcl/settings.hxx>
#include <svx/flagsdef.hxx>
#include <svx/svxids.hrc>
#include <svx/sdtaitm.hxx>

#include <svl/cjkoptions.hxx>
#include <editeng/pgrditem.hxx>
#include <svx/strings.hrc>
#include <svx/dialmgr.hxx>
#include <paragrph.hxx>
#include <editeng/frmdiritem.hxx>
#include <editeng/lspcitem.hxx>
#include <editeng/adjustitem.hxx>
#include <editeng/orphitem.hxx>
#include <editeng/widwitem.hxx>
#include <editeng/tstpitem.hxx>
#include <editeng/pmdlitem.hxx>
#include <editeng/spltitem.hxx>
#include <editeng/hyphenzoneitem.hxx>
#include <editeng/ulspitem.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/formatbreakitem.hxx>
#include <editeng/keepitem.hxx>
#include <editeng/scriptspaceitem.hxx>
#include <editeng/hngpnctitem.hxx>
#include <editeng/forbiddenruleitem.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <svx/dlgutil.hxx>
#include <sfx2/htmlmode.hxx>
#include <editeng/paravertalignitem.hxx>
#include <svl/eitem.hxx>
#include <svl/intitem.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <com/sun/star/text/ParagraphHyphenationKeepType.hpp>

const WhichRangesContainer SvxStdParagraphTabPage::pStdRanges(
    svl::Items<
    SID_ATTR_PARA_LINESPACE, SID_ATTR_PARA_LINESPACE, // 10033
    SID_ATTR_PARA_LEFTSPACE, SID_ATTR_PARA_FIRSTLINESPACE,
    SID_ATTR_LRSPACE, SID_ATTR_ULSPACE,              // 10048 - 10049
    SID_ATTR_PARA_REGISTER, SID_ATTR_PARA_REGISTER  // 10413
    >);

const WhichRangesContainer SvxParaAlignTabPage::pAlignRanges(
    svl::Items<
    SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_ADJUST, // 10027
    // tdf#154543 - reset snap to grid to parent
    SID_ATTR_PARA_SNAPTOGRID, SID_ATTR_PARA_SNAPTOGRID // 10945
    >);

const WhichRangesContainer SvxParaAlignTabPage::pSdrAlignRanges(
    svl::Items<
    SDRATTR_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST, // 1076
    SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_ADJUST ,      // 10027
    SID_ATTR_FRAMEDIRECTION, SID_ATTR_FRAMEDIRECTION  // 10944
    >);

const WhichRangesContainer SvxExtParagraphTabPage::pExtRanges(svl::Items<
    SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_WIDOWS, // 10037 - 10041
    SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP        // 10065 - 10066
>);

#define MAX_DURCH 31680     // tdf#68335: 1584 pt for UX interoperability with Word
#define FIX_DIST_DEF 283    // standard fix distance 0,5 cm

namespace {

enum LineSpaceList
{
    LLINESPACE_1    = 0,
    LLINESPACE_115  = 1,
    LLINESPACE_15   = 2,
    LLINESPACE_2    = 3,
    LLINESPACE_PROP = 4,
    LLINESPACE_MIN  = 5,
    LLINESPACE_DURCH= 6,
    LLINESPACE_FIX  = 7
};

SvxIndentValue lcl_GetFontRelativeValue(const SvxRelativeField& rField, MapUnit eUnit)
{
    switch (rField.GetCurrentUnit())
    {
        case FieldUnit::FONT_EM:
            return SvxIndentValue{ static_cast<double>(rField.get_value(FieldUnit::NONE)) / 100.0,
                                   css::util::MeasureUnit::FONT_EM };

        case FieldUnit::FONT_CJK_ADVANCE:
            return SvxIndentValue{ static_cast<double>(rField.get_value(FieldUnit::NONE)) / 100.0,
                                   css::util::MeasureUnit::FONT_CJK_ADVANCE };

        default:
            return SvxIndentValue::twips(static_cast<double>(rField.GetCoreValue(eUnit)));
    }
}

void lcl_SetFontRelativeValue(SvxRelativeField& rField, const SvxIndentValue& ;rValue, MapUnit eUnit)
{
    switch (rValue.m_nUnit)
    {
        case css::util::MeasureUnit::FONT_EM:
            rField.SetFontRelative(FieldUnit::FONT_EM);
            rField.set_value(static_cast<sal_Int64>(std::llround(rValue.m_dValue * 100.0)),
                             FieldUnit::FONT_EM);
            break;

        case css::util::MeasureUnit::FONT_CJK_ADVANCE:
            rField.SetFontRelative(FieldUnit::FONT_CJK_ADVANCE);
            rField.set_value(static_cast<sal_Int64>(std::llround(rValue.m_dValue * 100.0)),
                             FieldUnit::FONT_CJK_ADVANCE);
            break;

        default:
            rField.SetMetricValue(static_cast<sal_Int64>(std::llround(rValue.m_dValue)), eUnit);
            break;
    }
}
}

static void SetLineSpace_Impl( SvxLineSpacingItem&, int, tools::Long lValue = 0 );

void SetLineSpace_Impl( SvxLineSpacingItem& rLineSpace,
                        int eSpace, tools::Long lValue )
{
    switch ( eSpace )
    {
        case LLINESPACE_1:
            rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
            rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
            break;

        case LLINESPACE_115:
            rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
            rLineSpace.SetPropLineSpace( 115 );
            break;

        case LLINESPACE_15:
            rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
            rLineSpace.SetPropLineSpace( 150 );
            break;

        case LLINESPACE_2:
            rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
            rLineSpace.SetPropLineSpace( 200 );
            break;

        case LLINESPACE_PROP:
            rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
            rLineSpace.SetPropLineSpace( static_cast<sal_uInt16>(lValue) );
            break;

        case LLINESPACE_MIN:
            rLineSpace.SetLineHeight( static_cast<sal_uInt16>(lValue) );
            rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
            break;

        case LLINESPACE_DURCH:
            rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Auto );
            rLineSpace.SetInterLineSpace( static_cast<sal_uInt16>(lValue) );
            break;

        case LLINESPACE_FIX:
            rLineSpace.SetLineHeight(static_cast<sal_uInt16>(lValue));
            rLineSpace.SetLineSpaceRule( SvxLineSpaceRule::Fix );
            rLineSpace.SetInterLineSpaceRule( SvxInterLineSpaceRule::Off );
        break;
    }
}

static sal_uInt16 GetHtmlMode_Impl(const SfxItemSet& rSet)
{
    sal_uInt16 nHtmlMode = 0;
    const SfxUInt16Item* pItem = rSet.GetItemIfSet(SID_HTML_MODE, false);
    if (!pItem)
    {
        if (SfxObjectShell* pShell = SfxObjectShell::Current())
            pItem = pShell->GetItem(SID_HTML_MODE);
    }
    if(pItem)
    {
        nHtmlMode = pItem->GetValue();
    }
    return nHtmlMode;

}

void SvxStdParagraphTabPage::ELRLoseFocus()
{
    SfxItemPool* pPool = GetItemSet().GetPool();
    assert(pPool && "Where is the pool?");
    FieldUnit eUnit =
        MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );

    sal_Int64 nL = m_aLeftIndent.denormalize(m_aLeftIndent.get_value(eUnit));
    sal_Int64 nR = m_aRightIndent.denormalize(m_aRightIndent.get_value(eUnit));
    OUString aTmp = m_aFLineIndent.get_text();

    if (m_aLeftIndent.get_min(FieldUnit::NONE) < 0)
        m_aFLineIndent.set_min(-99999, FieldUnit::MM);
    else
        m_aFLineIndent.set_min(m_aFLineIndent.normalize(-nL), eUnit);

    // Check only for concrete width (Shell)
    sal_Int64 nTmp = nWidth - nL - nR - MM50;
    m_aFLineIndent.set_max(m_aFLineIndent.normalize(nTmp), eUnit);

    if (aTmp.isEmpty())
        m_aFLineIndent.set_text(OUString());
    // maximum left right
    aTmp = m_aLeftIndent.get_text();
    nTmp = nWidth - nR - MM50;
    m_aLeftIndent.set_max(m_aLeftIndent.normalize(nTmp), eUnit);

    if ( aTmp.isEmpty() )
        m_aLeftIndent.set_text(OUString());
    aTmp = m_aRightIndent.get_text();
    nTmp = nWidth - nL - MM50;
    m_aRightIndent.set_max(m_aRightIndent.normalize(nTmp), eUnit);

    if ( aTmp.isEmpty() )
        m_aRightIndent.set_text(OUString());

    UpdateExample_Impl();
}

IMPL_LINK_NOARG(SvxStdParagraphTabPage, ELRLoseFocusHdl, weld::MetricSpinButton&,&nbsp;void)
{
    ELRLoseFocus();
}

std::unique_ptr<SfxTabPage> SvxStdParagraphTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
{
    return std::make_unique<SvxStdParagraphTabPage>(pPage, pController, *rSet);
}

bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
{
    const SfxPoolItem* pOld = nullptr;
    SfxItemPool* pPool = rOutSet->GetPool();
    DBG_ASSERT( pPool, "Where is the pool?" );

    bool bModified = false;
    sal_uInt16 nWhich;
    int nPos = m_xLineDist->get_active();

    if ( nPos != -1 &&
         ( m_bLineDistToggled ||
           m_xLineDist->get_value_changed_from_saved() ||
           m_xLineDistAtPercentBox->get_value_changed_from_saved() ||
           m_xLineDistAtMetricBox->get_value_changed_from_saved() ) )
    {
        nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
        MapUnit eUnit = pPool->GetMetric( nWhich );
        SvxLineSpacingItem aSpacing(
            static_cast<const SvxLineSpacingItem&>(GetItemSet().Get( nWhich )) );

        switch ( nPos )
        {
            case LLINESPACE_1:
            case LLINESPACE_115:
            case LLINESPACE_15:
            case LLINESPACE_2:
                SetLineSpace_Impl( aSpacing, nPos );
                break;

            case LLINESPACE_PROP:
                SetLineSpace_Impl( aSpacing, nPos,
                                   static_cast<tools::Long>(m_xLineDistAtPercentBox->denormalize(
                                   m_xLineDistAtPercentBox->get_value(FieldUnit::NONE) )) );
                break;

            case LLINESPACE_MIN:
            case LLINESPACE_DURCH:
            case LLINESPACE_FIX:
                SetLineSpace_Impl( aSpacing, nPos,
                    GetCoreValue( *m_xLineDistAtMetricBox, eUnit ) );
            break;

            default:
                OSL_FAIL( "unknown LineDist entry" );
                break;
        }
        pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_LINESPACE );

        if ( m_bLineDistToggled ||
             !pOld || !( *static_cast<const SvxLineSpacingItem*>(pOld) == aSpacing ) ||
             SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) )
        {
            rOutSet->Put( aSpacing );
            bModified = true;
        }
    }

    if ( m_aTopDist.get_value_changed_from_saved() || m_aBottomDist.get_value_changed_from_saved()
         || m_xContextualCB->get_state_changed_from_saved())
    {
        nWhich = GetWhich( SID_ATTR_ULSPACE );
        MapUnit eUnit = pPool->GetMetric( nWhich );
        pOld = GetOldItem( *rOutSet, SID_ATTR_ULSPACE );
        SvxULSpaceItem aMargin( nWhich );

        if ( bRelativeMode )
        {
            DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );

            const SvxULSpaceItem& rOldItem =
                static_cast<const SvxULSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));

            if ( m_aTopDist.IsRelative() )
                aMargin.SetUpper( rOldItem.GetUpper(),
                                  static_cast<sal_uInt16>(m_aTopDist.get_value(FieldUnit::NONE)) );
            else
                aMargin.SetUpper( static_cast<sal_uInt16>(m_aTopDist.GetCoreValue(eUnit)) );

            if ( m_aBottomDist.IsRelative() )
                aMargin.SetLower( rOldItem.GetLower(),
                                  static_cast<sal_uInt16>(m_aBottomDist.get_value(FieldUnit::NONE)) );
            else
                aMargin.SetLower( static_cast<sal_uInt16>(m_aBottomDist.GetCoreValue(eUnit)) );

        }
        else
        {
            aMargin.SetUpper(static_cast<sal_uInt16>(m_aTopDist.GetCoreValue(eUnit)));
            aMargin.SetLower(static_cast<sal_uInt16>(m_aBottomDist.GetCoreValue(eUnit)));
        }
        aMargin.SetContextValue(m_xContextualCB->get_active());

        if ( !pOld || *static_cast<const SvxULSpaceItem*>(pOld) != aMargin ||
             SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) )
        {
            rOutSet->Put( aMargin );
            bModified = true;
        }
    }
    bool bNullTab = false;

    if (m_bSplitLRSpace && m_aLeftIndent.get_value_changed_from_saved())
    {
        nWhich = GetWhich(SID_ATTR_PARA_LEFTSPACE);
        MapUnit const eUnit = pPool->GetMetric(nWhich);
        SvxTextLeftMarginItem item(nWhich);
        pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_LEFTSPACE);

        if (bRelativeMode)
        {
            assert(GetItemSet().GetParent());

            const SvxTextLeftMarginItem & rOldItem(
                static_cast<const SvxTextLeftMarginItem&>(GetItemSet().GetParent()->Get(nWhich)));

            if (m_aLeftIndent.IsRelative())
            {
                item.SetTextLeft(rOldItem.GetTextLeft(),
                    static_cast<sal_uInt16>(m_aLeftIndent.get_value(FieldUnit::NONE)));
            }
            else
            {
                item.SetTextLeft(lcl_GetFontRelativeValue(m_aLeftIndent, eUnit));
            }
        }
        else
        {
            item.SetTextLeft(lcl_GetFontRelativeValue(m_aLeftIndent, eUnit));
        }
        if (!pOld || *static_cast<const SvxTextLeftMarginItem*>(pOld) != item
            || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich))
        {
            rOutSet->Put(item);
            bModified = true;
        }
    }

    if (m_bSplitLRSpace && m_aRightIndent.get_value_changed_from_saved())
    {
        nWhich = GetWhich(SID_ATTR_PARA_RIGHTSPACE);
        MapUnit const eUnit = pPool->GetMetric(nWhich);
        SvxRightMarginItem item(nWhich);
        pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_RIGHTSPACE);

        if (bRelativeMode)
        {
            assert(GetItemSet().GetParent());

            const SvxRightMarginItem & rOldItem(
                static_cast<const SvxRightMarginItem&>(GetItemSet().GetParent()->Get(nWhich)));

            if (m_aRightIndent.IsRelative())
            {
                item.SetRight(rOldItem.GetRight(),
                    static_cast<sal_uInt16>(m_aRightIndent.get_value(FieldUnit::NONE)));
            }
            else
            {
                item.SetRight(lcl_GetFontRelativeValue(m_aRightIndent, eUnit));
            }
        }
        else
        {
            item.SetRight(lcl_GetFontRelativeValue(m_aRightIndent, eUnit));
        }
        if (!pOld || *static_cast<const SvxRightMarginItem*>(pOld) != item
            || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich))
        {
            rOutSet->Put(item);
            bModified = true;
        }
    }

    if (m_bSplitLRSpace && (m_aFLineIndent.get_value_changed_from_saved()
                            || m_xAutoCB->get_state_changed_from_saved()))
    {
        nWhich = GetWhich(SID_ATTR_PARA_FIRSTLINESPACE);
        MapUnit const eUnit = pPool->GetMetric(nWhich);
        SvxFirstLineIndentItem item(nWhich);
        pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_FIRSTLINESPACE);

        if (bRelativeMode)
        {
            assert(GetItemSet().GetParent());

            const SvxFirstLineIndentItem & rOldItem(
                static_cast<const SvxFirstLineIndentItem&>(GetItemSet().GetParent()->Get(nWhich)));

            if (m_aFLineIndent.IsRelative())
            {
                item.SetTextFirstLineOffset(
                    rOldItem.GetTextFirstLineOffset(),
                    static_cast<sal_uInt16>(m_aFLineIndent.get_value(FieldUnit::NONE)));
            }
            else
            {
                item.SetTextFirstLineOffset(lcl_GetFontRelativeValue(m_aFLineIndent, eUnit));
            }
        }
        else
        {
            item.SetTextFirstLineOffset(lcl_GetFontRelativeValue(m_aFLineIndent, eUnit));
        }
        item.SetAutoFirst(m_xAutoCB->get_active());
        if (item.GetTextFirstLineOffset().m_dValue < 0.0)
        {
            bNullTab = true;
        }

        if (!pOld || *static_cast<const SvxFirstLineIndentItem*>(pOld) != item
            || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich))
        {
            rOutSet->Put(item);
            bModified = true;
        }
    }

    if (!m_bSplitLRSpace &&
        (m_aLeftIndent.get_value_changed_from_saved() ||
         m_aFLineIndent.get_value_changed_from_saved() ||
         m_aRightIndent.get_value_changed_from_saved() ||
         m_xAutoCB->get_state_changed_from_saved()))
    {
        nWhich = GetWhich( SID_ATTR_LRSPACE );
        MapUnit eUnit = pPool->GetMetric( nWhich );
        SvxLRSpaceItem aMargin( nWhich );
        pOld = GetOldItem( *rOutSet, SID_ATTR_LRSPACE );

        if ( bRelativeMode )
        {
            DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );

            const SvxLRSpaceItem& rOldItem =
                static_cast<const SvxLRSpaceItem&>(GetItemSet().GetParent()->Get( nWhich ));

            if (m_aLeftIndent.IsRelative())
                aMargin.SetTextLeft( rOldItem.GetTextLeft(),
                                    static_cast<sal_uInt16>(m_aLeftIndent.get_value(FieldUnit::NONE)) );
            else
                aMargin.SetTextLeft(lcl_GetFontRelativeValue(m_aLeftIndent, eUnit));

            if ( m_aRightIndent.IsRelative() )
                aMargin.SetRight( rOldItem.GetRight(),
                                  static_cast<sal_uInt16>(m_aRightIndent.get_value(FieldUnit::NONE)) );
            else
                aMargin.SetRight(lcl_GetFontRelativeValue(m_aRightIndent, eUnit));

            if ( m_aFLineIndent.IsRelative() )
                aMargin.SetTextFirstLineOffset(
                    rOldItem.GetTextFirstLineOffset(),
                    static_cast<sal_uInt16>(m_aFLineIndent.get_value(FieldUnit::NONE)));
            else
            {
                aMargin.SetTextFirstLineOffset(lcl_GetFontRelativeValue(m_aFLineIndent, eUnit));
            }
        }
        else
        {
            aMargin.SetTextLeft(lcl_GetFontRelativeValue(m_aLeftIndent, eUnit));
            aMargin.SetRight(lcl_GetFontRelativeValue(m_aRightIndent, eUnit));
            aMargin.SetTextFirstLineOffset(lcl_GetFontRelativeValue(m_aFLineIndent, eUnit));
        }
        aMargin.SetAutoFirst(m_xAutoCB->get_active());
        if (aMargin.GetTextFirstLineOffset().m_dValue < 0.0)
            bNullTab = true;

        if ( !pOld || *static_cast<const SvxLRSpaceItem*>(pOld) != aMargin ||
             SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) )
        {
            rOutSet->Put( aMargin );
            bModified = true;
        }
    }

    if ( bNullTab )
    {
        MapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
        if ( MapUnit::Map100thMM != eUnit )
        {

            // negative first line indent -> set null default tabstob if applicable
            sal_uInt16 _nWhich = GetWhich( SID_ATTR_TABSTOP );
            const SfxItemSet& rInSet = GetItemSet();

            if ( rInSet.GetItemState( _nWhich ) >= SfxItemState::DEFAULT )
            {
                const SvxTabStopItem& rTabItem =
                    static_cast<const SvxTabStopItem&>(rInSet.Get( _nWhich ));
                SvxTabStopItem aNullTab( rTabItem );
                SvxTabStop aNull( 0, SvxTabAdjust::Default );
                aNullTab.Insert( aNull );
                rOutSet->Put( aNullTab );
            }
        }
    }
    if (m_xRegisterCB->get_visible())
    {
        const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>(GetOldItem(
                            *rOutSet, SID_ATTR_PARA_REGISTER));
        if (!pBoolItem)
            return bModified;
        sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
        bool bSet = pBoolItem->GetValue();

        if (m_xRegisterCB->get_active() != bSet)
        {
            std::unique_ptr<SfxBoolItem> pRegItem(pBoolItem->Clone());
            pRegItem->SetValue(!bSet);
            rOutSet->Put(std::move(pRegItem));
            bModified = true;
        }
        else if ( SfxItemState::DEFAULT == GetItemSet().GetItemState( _nWhich, false ) )
            rOutSet->ClearItem(_nWhich);
    }

    return bModified;
}

static bool UseCharUnitInUI(const SfxItemSet& rSet)
{
    const bool bApplyCharUnit = GetApplyCharUnit(rSet);
    if (!bApplyCharUnit)
        return false;
    if (!SvtCJKOptions::IsAsianTypographyEnabled())
        return false;
    // tdf#101895 Given that we choose to show cm vs inch based on this Locale
    // setting, also choose to use ch[ar] and line based on that locale when
    // bApplyCharUnit is enabled.
    return MsLangId::isCJK(SvtSysLocaleOptions().GetRealLanguageTag().getLanguageType());
}

void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet )
{
    SfxItemPool* pPool = rSet->GetPool();
    DBG_ASSERT( pPool, "Where is the pool?" );

    // adjust metric
    FieldUnit eFUnit = GetModuleFieldUnit( *rSet );
    if (UseCharUnitInUI(*rSet))
        eFUnit = FieldUnit::CHAR;

    m_aLeftIndent.SetFieldUnit(eFUnit);
    m_aRightIndent.SetFieldUnit(eFUnit);
    m_aFLineIndent.SetFieldUnit(eFUnit);
    if ( eFUnit == FieldUnit::CHAR )
    {
        m_aTopDist.SetFieldUnit(FieldUnit::LINE);
        m_aBottomDist.SetFieldUnit(FieldUnit::LINE);
        SetFieldUnit(*m_xLineDistAtMetricBox, FieldUnit::POINT);
    }
    else
    {
        m_aTopDist.SetFieldUnit(eFUnit);
        m_aBottomDist.SetFieldUnit(eFUnit);
        SetFieldUnit(*m_xLineDistAtMetricBox, eFUnit);
    }

    sal_uInt16 const nWhichFL(GetWhich(SID_ATTR_PARA_FIRSTLINESPACE));
    m_bSplitLRSpace = (nWhichFL != SID_ATTR_PARA_FIRSTLINESPACE);
    SfxItemState const eItemStateFL(rSet->GetItemState(nWhichFL));
    sal_uInt16 const nWhichLM(GetWhich(SID_ATTR_PARA_LEFTSPACE));
    SfxItemState const eItemStateLM(rSet->GetItemState(nWhichLM));
    sal_uInt16 const nWhichRM(GetWhich(SID_ATTR_PARA_RIGHTSPACE));
    SfxItemState const eItemStateRM(rSet->GetItemState(nWhichRM));

    if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateLM)
    {
        const SvxTextLeftMarginItem & rOldLeftMargin(
            static_cast<const SvxTextLeftMarginItem &>(rSet->Get(nWhichLM)));

        MapUnit const eUnit = pPool->GetMetric(nWhichLM);

        if (bRelativeMode)
        {
            if (rOldLeftMargin.GetPropLeft() != 100)
            {
                m_aLeftIndent.SetRelative( true );
                m_aLeftIndent.set_value(rOldLeftMargin.GetPropLeft(), FieldUnit::NONE);
            }
            else
            {
                m_aLeftIndent.SetRelative(false);
                m_aLeftIndent.SetFieldUnit(eFUnit);
                lcl_SetFontRelativeValue(m_aLeftIndent, rOldLeftMargin.GetTextLeft(), eUnit);
            }
        }
        else
        {
            lcl_SetFontRelativeValue(m_aLeftIndent, rOldLeftMargin.GetTextLeft(), eUnit);
        }
    }
    else if (m_bSplitLRSpace)
    {
        m_aLeftIndent.set_text(OUString());
    }

    if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateRM)
    {
        const SvxRightMarginItem & rOldRightMargin(
            static_cast<const SvxRightMarginItem &>(rSet->Get(nWhichRM)));

        MapUnit const eUnit = pPool->GetMetric(nWhichRM);

        if (bRelativeMode)
        {
            if (rOldRightMargin.GetPropRight() != 100)
            {
                m_aRightIndent.SetRelative( true );
                m_aRightIndent.set_value(rOldRightMargin.GetPropRight(), FieldUnit::NONE);
            }
            else
            {
                m_aRightIndent.SetRelative(false);
                m_aRightIndent.SetFieldUnit(eFUnit);
                lcl_SetFontRelativeValue(m_aRightIndent, rOldRightMargin.GetRight(), eUnit);
            }
        }
        else
        {
            lcl_SetFontRelativeValue(m_aRightIndent, rOldRightMargin.GetRight(), eUnit);
        }
    }
    else if (m_bSplitLRSpace)
    {
        m_aRightIndent.set_text(OUString());
    }

    if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateFL)
    {
        const SvxFirstLineIndentItem & rOldFirstLine(
            static_cast<const SvxFirstLineIndentItem &>(rSet->Get(nWhichFL)));

        MapUnit const eUnit = pPool->GetMetric(nWhichFL);

        if (bRelativeMode)
        {
            if (rOldFirstLine.GetPropTextFirstLineOffset() != 100)
            {
                m_aFLineIndent.SetRelative(true);
                m_aFLineIndent.set_value(rOldFirstLine.GetPropTextFirstLineOffset(), FieldUnit::NONE);
            }
            else
            {
                m_aFLineIndent.SetRelative(false);
                m_aFLineIndent.set_min(-9999, FieldUnit::NONE);
                m_aFLineIndent.SetFieldUnit(eFUnit);
                lcl_SetFontRelativeValue(m_aFLineIndent, rOldFirstLine.GetTextFirstLineOffset(),
                                         eUnit);
            }
            m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst());
        }
        else
        {
            lcl_SetFontRelativeValue(m_aFLineIndent, rOldFirstLine.GetTextFirstLineOffset(), eUnit);
            m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst());
        }
        AutoHdl_Impl(*m_xAutoCB);
    }
    else if (m_bSplitLRSpace)
    {
        m_aFLineIndent.set_text(OUString());
    }

    sal_uInt16 _nWhich = GetWhich( SID_ATTR_LRSPACE );
    SfxItemState eItemState = rSet->GetItemState( _nWhich );

    if (!m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemState)
    {
        MapUnit eUnit = pPool->GetMetric( _nWhich );

        if ( bRelativeMode )
        {
            const SvxLRSpaceItem& rOldItem =
                static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));

            if ( rOldItem.GetPropLeft() != 100 )
            {
                m_aLeftIndent.SetRelative( true );
                m_aLeftIndent.set_value(rOldItem.GetPropLeft(), FieldUnit::NONE);
            }
            else
            {
                m_aLeftIndent.SetRelative(false);
                m_aLeftIndent.SetFieldUnit(eFUnit);
                lcl_SetFontRelativeValue(m_aLeftIndent, rOldItem.GetTextLeft(), eUnit);
            }

            if ( rOldItem.GetPropRight() != 100 )
            {
                m_aRightIndent.SetRelative( true );
                m_aRightIndent.set_value(rOldItem.GetPropRight(), FieldUnit::NONE);
            }
            else
            {
                m_aRightIndent.SetRelative(false);
                m_aRightIndent.SetFieldUnit(eFUnit);
                lcl_SetFontRelativeValue(m_aRightIndent, rOldItem.GetRight(), eUnit);
            }

            if ( rOldItem.GetPropTextFirstLineOffset() != 100 )
            {
                m_aFLineIndent.SetRelative(true);
                m_aFLineIndent.set_value(rOldItem.GetPropTextFirstLineOffset(), FieldUnit::NONE);
            }
            else
            {
                m_aFLineIndent.SetRelative(false);
                m_aFLineIndent.set_min(-9999, FieldUnit::NONE);
                m_aFLineIndent.SetFieldUnit(eFUnit);
                lcl_SetFontRelativeValue(m_aFLineIndent, rOldItem.GetTextFirstLineOffset(), eUnit);
            }
            m_xAutoCB->set_active(rOldItem.IsAutoFirst());
        }
        else
        {
            const SvxLRSpaceItem& rSpace =
                static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich ));

            lcl_SetFontRelativeValue(m_aLeftIndent, rSpace.GetTextLeft(), eUnit);
            lcl_SetFontRelativeValue(m_aRightIndent, rSpace.GetRight(), eUnit);
            lcl_SetFontRelativeValue(m_aFLineIndent, rSpace.GetTextFirstLineOffset(), eUnit);
            m_xAutoCB->set_active(rSpace.IsAutoFirst());
        }
        AutoHdl_Impl(*m_xAutoCB);
    }
    else if (!m_bSplitLRSpace)
    {
        m_aLeftIndent.set_text(OUString());
        m_aRightIndent.set_text(OUString());
        m_aFLineIndent.set_text(OUString());
    }

    _nWhich = GetWhich( SID_ATTR_ULSPACE );
    eItemState = rSet->GetItemState( _nWhich );

    if ( eItemState >= SfxItemState::DEFAULT )
    {
        MapUnit eUnit = pPool->GetMetric( _nWhich );

        const SvxULSpaceItem& rOldItem =
            static_cast<const SvxULSpaceItem&>(rSet->Get( _nWhich ));
        if ( bRelativeMode )
        {

            if ( rOldItem.GetPropUpper() != 100 )
            {
                m_aTopDist.SetRelative( true );
                m_aTopDist.set_value(rOldItem.GetPropUpper(), FieldUnit::NONE);
            }
            else
            {
                m_aTopDist.SetRelative(false);
                if (eFUnit == FieldUnit::CHAR)
                    m_aTopDist.SetFieldUnit(FieldUnit::LINE);
                else
                    m_aTopDist.SetFieldUnit(eFUnit);
                m_aTopDist.SetMetricValue(rOldItem.GetUpper(), eUnit);
            }

            if ( rOldItem.GetPropLower() != 100 )
            {
                m_aBottomDist.SetRelative( true );
                m_aBottomDist.set_value(rOldItem.GetPropLower(), FieldUnit::NONE);
            }
            else
            {
                m_aBottomDist.SetRelative(false);
                if (eFUnit == FieldUnit::CHAR)
                    m_aBottomDist.SetFieldUnit(FieldUnit::LINE);
                else
                    m_aBottomDist.SetFieldUnit(eFUnit);
                m_aBottomDist.SetMetricValue(rOldItem.GetLower(), eUnit);
            }
        }
        else
        {
            m_aTopDist.SetMetricValue(rOldItem.GetUpper(), eUnit);
            m_aBottomDist.SetMetricValue(rOldItem.GetLower(), eUnit);
        }
        m_xContextualCB->set_active(rOldItem.GetContext());
    }
    else
    {
        m_aTopDist.set_text(OUString());
        m_aBottomDist.set_text(OUString());
    }

    _nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
    eItemState = rSet->GetItemState( _nWhich );

    if ( eItemState >= SfxItemState::DEFAULT )
        SetLineSpacing_Impl( static_cast<const SvxLineSpacingItem &>(rSet->Get( _nWhich )) );
    else
        m_xLineDist->set_active(-1);

    _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
    eItemState = rSet->GetItemState( _nWhich );

    if ( eItemState >= SfxItemState::DEFAULT )
        m_xRegisterCB->set_active( static_cast<const SfxBoolItem &>(rSet->Get( _nWhich )).GetValue());
    m_xRegisterCB->save_state();
    sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
    if(nHtmlMode & HTMLMODE_ON)
    {
        m_xRegisterCB->hide();
        m_xAutoCB->hide();
    }

    // this sets the min/max limits; do this _after_ setting the values,
    // because for Impress the min of first-line indent depends on value of
    // left-indent!
    ELRLoseFocus();
    ChangesApplied();
}

void SvxStdParagraphTabPage::ChangesApplied()
{
    m_aLeftIndent.save_value();
    m_aRightIndent.save_value();
    m_aFLineIndent.save_value();
    m_xLineDist->save_value();
    m_xLineDistAtPercentBox->save_value();
    m_xLineDistAtMetricBox->save_value();
    m_xRegisterCB->save_state();
    m_aTopDist.save_value();
    m_aBottomDist.save_value();
    m_xContextualCB->save_state();
    m_xAutoCB->save_state();
}

void SvxStdParagraphTabPage::EnableRelativeMode()
{
    DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no parent-set!" );

    m_aLeftIndent.EnableRelativeMode( 0, 999 );
    m_aFLineIndent.EnableRelativeMode( 0, 999 );
    m_aRightIndent.EnableRelativeMode( 0, 999 );
    m_aTopDist.EnableRelativeMode( 0, 999 );
    m_aBottomDist.EnableRelativeMode( 0, 999 );
    bRelativeMode = true;
}

void SvxStdParagraphTabPage::ActivatePage( const SfxItemSet& rSet )
{
    sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
    SfxItemState eItemState = rSet.GetItemState( _nWhich );

    if ( eItemState < SfxItemState::DEFAULT )
        return;

    const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>( rSet.Get( _nWhich ) );
    SvxAdjust eAdjust = rAdj.GetAdjust();
    if ( eAdjust == SvxAdjust::Center || eAdjust == SvxAdjust::Block )
    {
        _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
        eItemState = rSet.GetItemState( _nWhich );

        if ( eItemState >= SfxItemState::DEFAULT )
        {
            const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet.Get( _nWhich ) );
            SvxFrameDirection eFrameDirection = rFrameDirItem.GetValue();

            m_aExampleWin.EnableRTL( SvxFrameDirection::Horizontal_RL_TB == eFrameDirection );

            if ( eAdjust == SvxAdjust::Block )
                m_aExampleWin.SetLastLine( rAdj.GetLastBlock() );
        }
    }
    else
    {
        m_aExampleWin.EnableRTL( eAdjust == SvxAdjust::Right );
        eAdjust = SvxAdjust::Left; //required for correct preview display
        m_aExampleWin.SetLastLine( eAdjust );
    }
    m_aExampleWin.SetAdjust( eAdjust );

    UpdateExample_Impl();
}

DeactivateRC SvxStdParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
{
    ELRLoseFocus();

    if ( _pSet )
        FillItemSet( _pSet );
    return DeactivateRC::LeavePage;
}

SvxStdParagraphTabPage::SvxStdParagraphTabPage(weld::Container* pPage, weld::DialogController* pController,  const SfxItemSet& rAttr)
    : SfxTabPage(pPage, pController, u"cui/ui/paraindentspacing.ui"_ustr, u"ParaIndentSpacing"_ustr, &rAttr)
    , nWidth(11905 /*567 * 50*/)
    , nMinFixDist(0)
    , bRelativeMode(false)
    , m_aLeftIndent(m_xBuilder->weld_metric_spin_button(u"spinED_LEFTINDENT"_ustr, FieldUnit::CM))
    , m_aRightIndent(m_xBuilder->weld_metric_spin_button(u"spinED_RIGHTINDENT"_ustr, FieldUnit::CM))
    , m_xFLineLabel(m_xBuilder->weld_label(u"labelFT_FLINEINDENT"_ustr))
    , m_aFLineIndent(m_xBuilder->weld_metric_spin_button(u"spinED_FLINEINDENT"_ustr, FieldUnit::CM))
    , m_xAutoCB(m_xBuilder->weld_check_button(u"checkCB_AUTO"_ustr))
    , m_aTopDist(m_xBuilder->weld_metric_spin_button(u"spinED_TOPDIST"_ustr, FieldUnit::CM))
    , m_aBottomDist(m_xBuilder->weld_metric_spin_button(u"spinED_BOTTOMDIST"_ustr, FieldUnit::CM))
    , m_xContextualCB(m_xBuilder->weld_check_button(u"checkCB_CONTEXTUALSPACING"_ustr))
    , m_xLineDist(m_xBuilder->weld_combo_box(u"comboLB_LINEDIST"_ustr))
    , m_xLineDistAtPercentBox(m_xBuilder->weld_metric_spin_button(u"spinED_LINEDISTPERCENT"_ustr, FieldUnit::PERCENT))
    , m_xLineDistAtMetricBox(m_xBuilder->weld_metric_spin_button(u"spinED_LINEDISTMETRIC"_ustr, FieldUnit::CM))
    , m_xLineDistAtPlaceHolderBox(m_xBuilder->weld_metric_spin_button(u"spinED_BLANK"_ustr, FieldUnit::CM))
    , m_xLineDistAtLabel(m_xBuilder->weld_label(u"labelFT_LINEDIST"_ustr))
    , m_xAbsDist(m_xBuilder->weld_label(u"labelST_LINEDIST_ABS"_ustr))
    , m_xRegisterCB(m_xBuilder->weld_check_button(u"checkCB_REGISTER"_ustr))
    , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, u"drawingareaWN_EXAMPLE"_ustr, m_aExampleWin))
{
    // this page needs ExchangeSupport
    SetExchangeSupport();

    m_xLineDistAtMetricBox->hide();
    m_xLineDistAtPlaceHolderBox->hide();
    m_xLineDistAtPlaceHolderBox->set_text(OUString());

    Init_Impl();
    m_aFLineIndent.set_min(-9999, FieldUnit::NONE);    // is set to 0 on default
    m_aFLineIndent.EnableNegativeMode();
    m_aFLineIndent.EnableFontRelativeMode();

    m_aLeftIndent.EnableFontRelativeMode();
    m_aRightIndent.EnableFontRelativeMode();
}

SvxStdParagraphTabPage::~SvxStdParagraphTabPage()
{
}

void SvxStdParagraphTabPage::EnableNegativeMode()
{
    m_aLeftIndent.set_min(-9999, FieldUnit::NONE);
    m_aRightIndent.set_min(-9999, FieldUnit::NONE);
    m_aRightIndent.EnableNegativeMode();
    m_aLeftIndent.EnableNegativeMode();
}

void SvxStdParagraphTabPage::SetLineSpacing_Impl
(
    const SvxLineSpacingItem &rAttr
)
{
    MapUnit eUnit = GetItemSet().GetPool()->GetMetric( rAttr.Which() );

    switch( rAttr.GetLineSpaceRule() )
    {
        case SvxLineSpaceRule::Auto:
        {
            SvxInterLineSpaceRule eInter = rAttr.GetInterLineSpaceRule();

            switch( eInter )
            {
                // Default single line spacing
                case SvxInterLineSpaceRule::Off:
                    m_xLineDist->set_active( LLINESPACE_1 );
                    break;

                // Default single line spacing
                case SvxInterLineSpaceRule::Prop:
                    if ( 100 == rAttr.GetPropLineSpace() )
                    {
                        m_xLineDist->set_active( LLINESPACE_1 );
                        break;
                    }
                    // 1.15 line spacing
                    if ( 115 == rAttr.GetPropLineSpace() )
                    {
                        m_xLineDist->set_active( LLINESPACE_115 );
                        break;
                    }
                    // 1.5 line spacing
                    if ( 150 == rAttr.GetPropLineSpace() )
                    {
                        m_xLineDist->set_active( LLINESPACE_15 );
                        break;
                    }
                    // double line spacing
                    if ( 200 == rAttr.GetPropLineSpace() )
                    {
                        m_xLineDist->set_active( LLINESPACE_2 );
                        break;
                    }
                    // the set per cent value
                    m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(rAttr.GetPropLineSpace()), FieldUnit::NONE);
                    m_xLineDist->set_active( LLINESPACE_PROP );
                    break;

                case SvxInterLineSpaceRule::Fix:
                    SetMetricValue( *m_xLineDistAtMetricBox, rAttr.GetInterLineSpace(), eUnit );
                    m_xLineDist->set_active( LLINESPACE_DURCH );
                    break;
                default: ;//prevent warning
            }
        }
        break;
        case SvxLineSpaceRule::Fix:
            SetMetricValue(*m_xLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
            m_xLineDist->set_active( LLINESPACE_FIX );
        break;

        case SvxLineSpaceRule::Min:
            SetMetricValue(*m_xLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
            m_xLineDist->set_active( LLINESPACE_MIN );
            break;
        default: ;//prevent warning
    }
    LineDistHdl_Impl( *m_xLineDist );
}

IMPL_LINK_NOARG(SvxStdParagraphTabPage, LineDistPopupHdl_Impl, weld::ComboBox&, void)
{
    m_bLineDistToggled = true;
}

IMPL_LINK(SvxStdParagraphTabPage, LineDistHdl_Impl, weld::ComboBox&, rBox, void)
{
    switch (rBox.get_active())
    {
        case LLINESPACE_1:
        case LLINESPACE_115:
        case LLINESPACE_15:
        case LLINESPACE_2:
            m_xLineDistAtLabel->set_sensitive(false);
            m_xLineDistAtPercentBox->hide();
            m_xLineDistAtMetricBox->hide();
            m_xLineDistAtPlaceHolderBox->show();
            break;

        case LLINESPACE_DURCH:
            // setting a sensible default?
            // limit MS min(10, aPageSize)
            m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE);

            if (m_xLineDistAtPlaceHolderBox->get_visible())
                m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(1), FieldUnit::NONE);
            m_xLineDistAtPlaceHolderBox->hide();
            m_xLineDistAtPercentBox->hide();
            m_xLineDistAtMetricBox->show();
            m_xLineDistAtLabel->set_sensitive(true);
            break;

        case LLINESPACE_MIN:
            m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE);

            if (m_xLineDistAtPlaceHolderBox->get_visible())
                m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(10), FieldUnit::TWIP);
            m_xLineDistAtPlaceHolderBox->hide();
            m_xLineDistAtPercentBox->hide();
            m_xLineDistAtMetricBox->show();
            m_xLineDistAtLabel->set_sensitive(true);
            break;

        case LLINESPACE_PROP:

            if (m_xLineDistAtPlaceHolderBox->get_visible())
                m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(100), FieldUnit::TWIP);
            m_xLineDistAtPlaceHolderBox->hide();
            m_xLineDistAtMetricBox->hide();
            m_xLineDistAtPercentBox->show();
            m_xLineDistAtLabel->set_sensitive(true);
            break;
        case LLINESPACE_FIX:
        {
            auto nTemp = m_xLineDistAtMetricBox->get_value(FieldUnit::NONE);
            m_xLineDistAtMetricBox->set_min(m_xLineDistAtMetricBox->normalize(nMinFixDist), FieldUnit::TWIP);

            // if the value has been changed at SetMin,
            // it is time for the default
            if (m_xLineDistAtMetricBox->get_value(FieldUnit::NONE) != nTemp)
                SetMetricValue( *m_xLineDistAtMetricBox, FIX_DIST_DEF, MapUnit::MapTwip ); // fix is only in Writer
            m_xLineDistAtPlaceHolderBox->hide();
            m_xLineDistAtPercentBox->hide();
            m_xLineDistAtMetricBox->show();
            m_xLineDistAtLabel->set_sensitive(true);
        }
        break;
    }
    UpdateExample_Impl();
}

IMPL_LINK_NOARG(SvxStdParagraphTabPage, ModifyHdl_Impl, weld::MetricSpinButton&, ;void)
{
    UpdateExample_Impl();
}

void SvxStdParagraphTabPage::Init_Impl()
{
    m_xLineDist->connect_popup_toggled(LINK(this, SvxStdParagraphTabPage, LineDistPopupHdl_Impl));
    m_xLineDist->connect_changed(LINK(this, SvxStdParagraphTabPage, LineDistHdl_Impl));

    Link<weld::MetricSpinButton&,void> aLink2 = LINK(this, SvxStdParagraphTabPage, ELRLoseFocusHdl);
    m_aFLineIndent.connect_value_changed(aLink2);
    m_aLeftIndent.connect_value_changed(aLink2);
    m_aRightIndent.connect_value_changed(aLink2);

    Link<weld::MetricSpinButton&,void> aLink = LINK(this, SvxStdParagraphTabPage, ModifyHdl_Impl);
    m_aTopDist.connect_value_changed(aLink);
    m_aBottomDist.connect_value_changed(aLink);

    m_xAutoCB->connect_toggled(LINK(this, SvxStdParagraphTabPage, AutoHdl_Impl));
    SfxItemPool* pPool = GetItemSet().GetPool();
    assert(pPool && "Where is the pool?");
    FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );

    m_aTopDist.set_max( m_aTopDist.normalize( MAX_DURCH ), eUnit );
    m_aBottomDist.set_max( m_aBottomDist.normalize( MAX_DURCH ), eUnit );
    m_xLineDistAtMetricBox->set_max( m_xLineDistAtMetricBox->normalize( MAX_DURCH ), eUnit );
}

void SvxStdParagraphTabPage::UpdateExample_Impl()
{
    m_aExampleWin.SetFirstLineOffset( static_cast<short>(m_aFLineIndent.denormalize( m_aFLineIndent.get_value( FieldUnit::TWIP ) )) );
    m_aExampleWin.SetLeftMargin( static_cast<tools::Long>(m_aLeftIndent.denormalize( m_aLeftIndent.get_value( FieldUnit::TWIP ) ) ) );
    m_aExampleWin.SetRightMargin( static_cast<tools::Long>(m_aRightIndent.denormalize( m_aRightIndent.get_value( FieldUnit::TWIP ) ) ) );
    m_aExampleWin.SetUpper( static_cast<sal_uInt16>(m_aTopDist.denormalize( m_aTopDist.get_value( FieldUnit::TWIP ) )) );
    m_aExampleWin.SetLower( static_cast<sal_uInt16>(m_aBottomDist.denormalize( m_aBottomDist.get_value( FieldUnit::TWIP ) )) );

    int nPos = m_xLineDist->get_active();

    switch ( nPos )
    {
        case LLINESPACE_1:
        case LLINESPACE_115:
        case LLINESPACE_15:
        case LLINESPACE_2:
        case LLINESPACE_PROP:
        case LLINESPACE_MIN:
        case LLINESPACE_DURCH:
        case LLINESPACE_FIX:
            m_aExampleWin.SetLineSpace( static_cast<SvxPrevLineSpace>(nPos) );
            break;
    }
    m_aExampleWin.Invalidate();
}

void SvxStdParagraphTabPage::EnableRegisterMode()
{
    m_xRegisterCB->show();
}

void SvxStdParagraphTabPage::EnableContextualMode()
{
    m_xContextualCB->show();
}

IMPL_LINK(SvxStdParagraphTabPage, AutoHdl_Impl, weld::Toggleable&, rBox, void)
{
    bool bEnable = !rBox.get_active();
    m_xFLineLabel->set_sensitive(bEnable);
    m_aFLineIndent.set_sensitive(bEnable);
}

void SvxStdParagraphTabPage::EnableAutoFirstLine()
{
    m_xAutoCB->show();
}

void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet)
{

/* different bit represent call to different method of SvxStdParagraphTabPage
                        0x0001 --->EnableRelativeMode()
                        0x0002 --->EnableRegisterMode()
                        0x0004 --->EnableAutoFirstLine()
                        0x0008 --->EnableNegativeMode()
                        0x0010 --->EnableContextualMode()
            */

    const SfxUInt16Item* pPageWidthItem = aSet.GetItem<SfxUInt16Item>(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH, false);
    const SfxUInt32Item* pFlagSetItem = aSet.GetItem<SfxUInt32Item>(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET, false);

    if (pPageWidthItem)
        nWidth = pPageWidthItem->GetValue();

    if (pFlagSetItem )
    {
        if (( 0x0001 & pFlagSetItem->GetValue())== 0x0001 )
            EnableRelativeMode();

        if (( 0x0002 & pFlagSetItem->GetValue())== 0x0002 )
                EnableRegisterMode();

        if ( ( 0x0004 & pFlagSetItem->GetValue())== 0x0004 )
            EnableAutoFirstLine();
    }

    if (pFlagSetItem)
    {
        if  (( 0x0008 & pFlagSetItem->GetValue()) == 0x0008 )
                EnableNegativeMode();

        if  (( 0x0010 & pFlagSetItem->GetValue()) == 0x0010 )
                EnableContextualMode();
    }
}

#define LASTLINEPOS_DEFAULT     0
#define LASTLINEPOS_LEFT        1

#define LASTLINECOUNT_OLD       3
#define LASTLINECOUNT_NEW       4

SvxParaAlignTabPage::SvxParaAlignTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
    : SfxTabPage(pPage, pController, u"cui/ui/paragalignpage.ui"_ustr, u"ParaAlignPage"_ustr, &rSet)
    , m_bSdrVertAlign(false)
    , m_xLeft(m_xBuilder->weld_radio_button(u"radioBTN_LEFTALIGN"_ustr))
    , m_xRight(m_xBuilder->weld_radio_button(u"radioBTN_RIGHTALIGN"_ustr))
    , m_xCenter(m_xBuilder->weld_radio_button(u"radioBTN_CENTERALIGN"_ustr))
    , m_xJustify(m_xBuilder->weld_radio_button(u"radioBTN_JUSTIFYALIGN"_ustr))
    , m_xLeftBottom(m_xBuilder->weld_label(u"labelST_LEFTALIGN_ASIAN"_ustr))
    , m_xRightTop(m_xBuilder->weld_label(u"labelST_RIGHTALIGN_ASIAN"_ustr))
    , m_xLastLineFT(m_xBuilder->weld_label(u"labelLB_LASTLINE"_ustr))
    , m_xLastLineLB(m_xBuilder->weld_combo_box(u"comboLB_LASTLINE"_ustr))
    , m_xExpandCB(m_xBuilder->weld_check_button(u"checkCB_EXPAND"_ustr))
    , m_xSnapToGridCB(m_xBuilder->weld_check_button(u"checkCB_SNAP"_ustr))
    , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, u"drawingareaWN_EXAMPLE"_ustr, m_aExampleWin))
    , m_xVertAlignFL(m_xBuilder->weld_widget(u"frameFL_VERTALIGN"_ustr))
    , m_xVertAlignLB(m_xBuilder->weld_combo_box(u"comboLB_VERTALIGN"_ustr))
    , m_xVertAlign(m_xBuilder->weld_label(u"labelFL_VERTALIGN"_ustr))
    , m_xVertAlignSdr(m_xBuilder->weld_label(u"labelST_VERTALIGN_SDR"_ustr))
    , m_xTextDirectionLB(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box(u"comboLB_TEXTDIRECTION"_ustr)))
    , m_xLabelWordSpacing(m_xBuilder->weld_label(u"labelWordSpacing"_ustr))
    , m_xLabelMinimum(m_xBuilder->weld_label(u"labelMinimum"_ustr))
    , m_xLabelDesired(m_xBuilder->weld_label(u"labelDesired"_ustr))
    , m_xLabelMaximum(m_xBuilder->weld_label(u"labelMaximum"_ustr))
    , m_xWordSpacing(m_xBuilder->weld_metric_spin_button(u"spin_WORD_SPACING"_ustr, FieldUnit::PERCENT))
    , m_xWordSpacingMinimum(m_xBuilder->weld_metric_spin_button(u"spin_WORD_SPACING_MIN"_ustr, FieldUnit::PERCENT))
    , m_xWordSpacingMaximum(m_xBuilder->weld_metric_spin_button(u"spin_WORD_SPACING_MAX"_ustr, FieldUnit::PERCENT))
{
    SetExchangeSupport();

    sal_uInt16 nLastLinePos = LASTLINEPOS_DEFAULT;

    if ( SvtCJKOptions::IsAsianTypographyEnabled() )
    {
        m_xLeft->set_label(m_xLeftBottom->get_label());
        m_xRight->set_label(m_xRightTop->get_label());

        OUString sLeft(m_xLeft->get_label());
        sLeft = MnemonicGenerator::EraseAllMnemonicChars( sLeft );

        if (m_xLastLineLB->get_count() == LASTLINECOUNT_OLD)
        {
            m_xLastLineLB->remove(0);
            m_xLastLineLB->insert_text(0, sLeft);
        }
        else
            nLastLinePos = LASTLINEPOS_LEFT;
    }

    // remove "Default" or "Left" entry, depends on CJKOptions
    if (m_xLastLineLB->get_count() == LASTLINECOUNT_NEW)
        m_xLastLineLB->remove(nLastLinePos);

    Link<weld::Toggleable&, void> aLink = LINK( this, SvxParaAlignTabPage, AlignHdl_Impl );
    m_xLeft->connect_toggled(aLink);
    m_xRight->connect_toggled(aLink);
    m_xCenter->connect_toggled(aLink);
    m_xJustify->connect_toggled(aLink);
    m_xLastLineLB->connect_changed(LINK(this, SvxParaAlignTabPage, LastLineHdl_Impl));
    m_xTextDirectionLB->connect_changed(LINK(this, SvxParaAlignTabPage, TextDirectionHdl_Impl));

    m_xTextDirectionLB->append(SvxFrameDirection::Environment, SvxResId(RID_SVXSTR_FRAMEDIR_SUPER));
    m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_LR_TB, SvxResId(RID_SVXSTR_FRAMEDIR_LTR));
    m_xTextDirectionLB->append(SvxFrameDirection::Horizontal_RL_TB, SvxResId(RID_SVXSTR_FRAMEDIR_RTL));

    // Minimum <= Desired <= Maximum word spacing
    // apply these modifying the other values, if needed
    m_xWordSpacing->connect_value_changed(LINK(this, SvxParaAlignTabPage, WordSpacingHdl_Impl));
    m_xWordSpacingMinimum->connect_value_changed(LINK(this, SvxParaAlignTabPage, WordSpacingMinimumHdl_Impl));
    m_xWordSpacingMaximum->connect_value_changed(LINK(this, SvxParaAlignTabPage, WordSpacingMaximumHdl_Impl));
}

SvxParaAlignTabPage::~SvxParaAlignTabPage()
{
}

DeactivateRC SvxParaAlignTabPage::DeactivatePage( SfxItemSet* _pSet )
{
    if ( _pSet )
        FillItemSet( _pSet );
    return DeactivateRC::LeavePage;
}

std::unique_ptr<SfxTabPage> SvxParaAlignTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
{
    return std::make_unique<SvxParaAlignTabPage>(pPage, pController, *rSet);
}

bool SvxParaAlignTabPage::FillItemSet( SfxItemSet* rOutSet )
{
    bool bModified = false;

    bool bAdj = false;
    SvxAdjust eAdjust = SvxAdjust::Left;

    if (m_xLeft->get_active())
    {
        eAdjust = SvxAdjust::Left;
        bAdj = m_xLeft->get_saved_state() == TRISTATE_FALSE;
    }
    else if (m_xRight->get_active())
    {
        eAdjust = SvxAdjust::Right;
        bAdj = m_xRight->get_saved_state() == TRISTATE_FALSE;
    }
    else if (m_xCenter->get_active())
    {
        eAdjust = SvxAdjust::Center;
        bAdj = m_xCenter->get_saved_state() == TRISTATE_FALSE;
    }
    else if (m_xJustify->get_active())
    {
        eAdjust = SvxAdjust::Block;
        bAdj = m_xJustify->get_saved_state() == TRISTATE_FALSE ||
            m_xExpandCB->get_state_changed_from_saved() ||
            m_xLastLineLB->get_value_changed_from_saved() ||
            m_xWordSpacing->get_value_changed_from_saved() ||
            m_xWordSpacingMinimum->get_value_changed_from_saved() ||
            m_xWordSpacingMaximum->get_value_changed_from_saved();
    }

    sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );

    if (bAdj)
    {
        SvxAdjust eOneWord = m_xExpandCB->get_active() ? SvxAdjust::Block : SvxAdjust::Left;

        int nLBPos = m_xLastLineLB->get_active();
        SvxAdjust eLastBlock = SvxAdjust::Left;
        if ( 1 == nLBPos )
            eLastBlock = SvxAdjust::Center;
        else if ( 2 == nLBPos )
            eLastBlock = SvxAdjust::Block;

        SvxAdjustItem aAdj( static_cast<const SvxAdjustItem&>(GetItemSet().Get( _nWhich )) );
        aAdj.SetAdjust( eAdjust );
        aAdj.SetOneWord( eOneWord );
        aAdj.SetLastBlock( eLastBlock );
        aAdj.SetPropWordSpacing( m_xWordSpacing->get_value(FieldUnit::PERCENT) );
        aAdj.SetPropWordSpacingMinimum( m_xWordSpacingMinimum->get_value(FieldUnit::PERCENT) );
        aAdj.SetPropWordSpacingMaximum( m_xWordSpacingMaximum->get_value(FieldUnit::PERCENT) );
        rOutSet->Put( aAdj );
        bModified = true;
    }

    if (m_xSnapToGridCB->get_state_changed_from_saved())
    {
        rOutSet->Put(SvxParaGridItem(m_xSnapToGridCB->get_active(), GetWhich( SID_ATTR_PARA_SNAPTOGRID )));
        bModified = true;
    }

    if (m_xVertAlignLB->get_value_changed_from_saved())
    {
        if (m_bSdrVertAlign)
            rOutSet->Put(SdrTextVertAdjustItem(static_cast<SdrTextVertAdjust>(m_xVertAlignLB->get_active())));
        else
            rOutSet->Put(SvxParaVertAlignItem(static_cast<SvxParaVertAlignItem::Align>(m_xVertAlignLB->get_active()), GetWhich( SID_PARA_VERTALIGN )));
        bModified = true;
    }

    if (m_xTextDirectionLB->get_visible())
    {
        if (m_xTextDirectionLB->get_value_changed_from_saved())
        {
            SvxFrameDirection eDir = m_xTextDirectionLB->get_active_id();
            rOutSet->Put( SvxFrameDirectionItem( eDir, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) );
            bModified = true;
        }
    }

    return bModified;
}

void SvxParaAlignTabPage::ActivatePage( const SfxItemSet& rSet )
{
    Reset( &rSet );
}

void SvxParaAlignTabPage::Reset( const SfxItemSet* rSet )
{
    sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
    SfxItemState eItemState = rSet->GetItemState( _nWhich );

    sal_Int32 nLBSelect = 0;
    if ( eItemState >= SfxItemState::DEFAULT )
    {
        const SvxAdjustItem& rAdj = static_cast<const SvxAdjustItem&>(rSet->Get( _nWhich ));

        switch ( rAdj.GetAdjust() /*!!! ask VB rAdj.GetLastBlock()*/ )
        {
            case SvxAdjust::Left: m_xLeft->set_active(true); break;

            case SvxAdjust::Right: m_xRight->set_active(true); break;

            case SvxAdjust::Center: m_xCenter->set_active(true); break;

            case SvxAdjust::Block: m_xJustify->set_active(true); break;
            default: ; //prevent warning
        }
        bool bEnable = m_xJustify->get_active();
        m_xLastLineFT->set_sensitive(bEnable);
        m_xLastLineLB->set_sensitive(bEnable);

        switch(rAdj.GetLastBlock())
        {
            case SvxAdjust::Left:  nLBSelect = 0; break;

            case SvxAdjust::Center: nLBSelect = 1;  break;

            case SvxAdjust::Block: nLBSelect = 2;  break;
            default: ; //prevent warning
        }
        m_xExpandCB->set_sensitive(bEnable && nLBSelect == 2);
        m_xExpandCB->set_active(SvxAdjust::Block == rAdj.GetOneWord());

        if (m_xJustify->get_active())
        {
            m_xLabelWordSpacing->set_sensitive(true);
            m_xLabelMinimum->set_sensitive(true);
            m_xLabelDesired->set_sensitive(true);
            m_xLabelMaximum->set_sensitive(true);
            m_xWordSpacing->set_sensitive(true);
            m_xWordSpacingMinimum->set_sensitive(true);
            m_xWordSpacingMaximum->set_sensitive(true);
            m_xWordSpacing->set_value(rAdj.GetPropWordSpacing(), FieldUnit::PERCENT);
            m_xWordSpacingMinimum->set_value(rAdj.GetPropWordSpacingMinimum(), FieldUnit::PERCENT);
            m_xWordSpacingMaximum->set_value(rAdj.GetPropWordSpacingMaximum(), FieldUnit::PERCENT);
        }
        else
        {
            m_xLabelWordSpacing->set_sensitive(false);
            m_xLabelMinimum->set_sensitive(false);
            m_xLabelDesired->set_sensitive(false);
            m_xLabelMaximum->set_sensitive(false);
            m_xWordSpacing->set_sensitive(false);
            m_xWordSpacingMinimum->set_sensitive(false);
            m_xWordSpacingMaximum->set_sensitive(false);
        }
    }
    else
    {
        m_xLeft->set_active(false);
        m_xRight->set_active(false);
        m_xCenter->set_active(false);
        m_xJustify->set_active(false);
        m_xLabelWordSpacing->set_sensitive(false);
        m_xLabelMinimum->set_sensitive(false);
        m_xLabelDesired->set_sensitive(false);
        m_xLabelMaximum->set_sensitive(false);
        m_xWordSpacing->set_sensitive(false);
        m_xWordSpacingMinimum->set_sensitive(false);
        m_xWordSpacingMaximum->set_sensitive(false);
    }
    m_xLastLineLB->set_active(nLBSelect);

    sal_uInt16 nHtmlMode = GetHtmlMode_Impl(*rSet);
    if(nHtmlMode & HTMLMODE_ON)
    {
        m_xLastLineLB->hide();
        m_xLastLineFT->hide();
        m_xExpandCB->hide();
        if(!(nHtmlMode & HTMLMODE_FULL_STYLES) )
            m_xJustify->set_sensitive(false);
        m_xSnapToGridCB->hide();
    }
    _nWhich = GetWhich(SID_ATTR_PARA_SNAPTOGRID);
    eItemState = rSet->GetItemState( _nWhich );
    if ( eItemState >= SfxItemState::DEFAULT )
    {
        const SvxParaGridItem& rSnap = static_cast<const SvxParaGridItem&>(rSet->Get( _nWhich ));
        m_xSnapToGridCB->set_active(rSnap.GetValue());
    }

    _nWhich = m_bSdrVertAlign ? SDRATTR_TEXT_VERTADJUST : GetWhich( SID_PARA_VERTALIGN );
    eItemState = rSet->GetItemState( _nWhich );

    if ( eItemState >= SfxItemState::DEFAULT )
    {
        m_xVertAlignFL->show();

        if (m_bSdrVertAlign)
        {
            const SdrTextVertAdjustItem& rAlign = static_cast<const SdrTextVertAdjustItem&>(rSet->Get( _nWhich ));
            m_xVertAlignLB->set_active(rAlign.GetValue());
        }
        else
        {
            const SvxParaVertAlignItem& rAlign = static_cast<const SvxParaVertAlignItem&>(rSet->Get( _nWhich ));
            m_xVertAlignLB->set_active(static_cast<sal_Int32>(rAlign.GetValue()));
        }
    }

    _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
    //text direction
    if( SfxItemState::DEFAULT <= rSet->GetItemState( _nWhich ) )
    {
        const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>( rSet->Get( _nWhich ) );
        m_xTextDirectionLB->set_active_id(rFrameDirItem.GetValue());
        m_xTextDirectionLB->save_value();
    }

    m_xSnapToGridCB->save_state();
    m_xVertAlignLB->save_value();
    m_xLeft->save_state();
    m_xRight->save_state();
    m_xCenter->save_state();
    m_xJustify->save_state();
    m_xLastLineLB->save_value();
    m_xExpandCB->save_state();
    m_xWordSpacing->save_value();
    m_xWordSpacingMinimum->save_value();
    m_xWordSpacingMaximum->save_value();

    UpdateExample_Impl();
}

void SvxParaAlignTabPage::ChangesApplied()
{
    m_xTextDirectionLB->save_value();
    m_xSnapToGridCB->save_state();
    m_xVertAlignLB->save_value();
    m_xLeft->save_state();
    m_xRight->save_state();
    m_xCenter->save_state();
    m_xJustify->save_state();
    m_xLastLineLB->save_value();
    m_xExpandCB->save_state();
    m_xWordSpacing->save_value();
    m_xWordSpacingMinimum->save_value();
    m_xWordSpacingMaximum->save_value();
}

IMPL_LINK_NOARG(SvxParaAlignTabPage, AlignHdl_Impl, weld::Toggleable&, void)
{
    bool bJustify = m_xJustify->get_active();
    m_xLastLineFT->set_sensitive(bJustify);
    m_xLastLineLB->set_sensitive(bJustify);
    m_xLabelWordSpacing->set_sensitive(bJustify);
    m_xLabelMinimum->set_sensitive(bJustify);
    m_xLabelDesired->set_sensitive(bJustify);
    m_xLabelMaximum->set_sensitive(bJustify);
    m_xWordSpacing->set_sensitive(bJustify);
    m_xWordSpacingMinimum->set_sensitive(bJustify);
    m_xWordSpacingMaximum->set_sensitive(bJustify);
    bool bLastLineIsBlock = m_xLastLineLB->get_active() == 2;
    m_xExpandCB->set_sensitive(bJustify && bLastLineIsBlock);
    //set last line listbox to entry position 0 if not enabled
    if (!m_xLastLineLB->get_sensitive())
        m_xLastLineLB->set_active(0);
    //uncheck 'Expand ... word' when check box is not enabled
    if (!m_xExpandCB->get_sensitive())
        m_xExpandCB->set_active(false);
    UpdateExample_Impl();
}

IMPL_LINK_NOARG(SvxParaAlignTabPage, LastLineHdl_Impl, weld::ComboBox&, void)
{
    //fdo#41350 only enable 'Expand last word' if last line is also justified
    bool bLastLineIsBlock = m_xLastLineLB->get_active() == 2;
    m_xExpandCB->set_sensitive(bLastLineIsBlock);
    //uncheck 'Expand ... word' when check box is not enabled
    if (!m_xExpandCB->get_sensitive())
        m_xExpandCB->set_active(false);
    UpdateExample_Impl();
}

IMPL_LINK_NOARG(SvxParaAlignTabPage, TextDirectionHdl_Impl, weld::ComboBox&, void)
{
    UpdateExample_Impl();
}

IMPL_LINK_NOARG(SvxParaAlignTabPage, WordSpacingHdl_Impl, weld::MetricSpinButton&,&nbsp;void)
{
    sal_Int16 nDesired = m_xWordSpacing->get_value(FieldUnit::PERCENT);
    if (nDesired < m_xWordSpacingMinimum->get_value(FieldUnit::PERCENT))
        m_xWordSpacingMinimum->set_value(nDesired, FieldUnit::PERCENT);
    if (nDesired > m_xWordSpacingMaximum->get_value(FieldUnit::PERCENT))
        m_xWordSpacingMaximum->set_value(nDesired, FieldUnit::PERCENT);
}

IMPL_LINK_NOARG(SvxParaAlignTabPage, WordSpacingMinimumHdl_Impl, weld::MetricSpinButton&, void)
{
    sal_Int16 nMinimum = m_xWordSpacingMinimum->get_value(FieldUnit::PERCENT);
    if (nMinimum > m_xWordSpacing->get_value(FieldUnit::PERCENT))
        m_xWordSpacing->set_value(nMinimum, FieldUnit::PERCENT);
    if (nMinimum > m_xWordSpacingMaximum->get_value(FieldUnit::PERCENT))
        m_xWordSpacingMaximum->set_value(nMinimum, FieldUnit::PERCENT);
}

IMPL_LINK_NOARG(SvxParaAlignTabPage, WordSpacingMaximumHdl_Impl, weld::MetricSpinButton&, void)
{
    sal_Int16 nMaximum = m_xWordSpacingMaximum->get_value(FieldUnit::PERCENT);
    if (nMaximum < m_xWordSpacingMinimum->get_value(FieldUnit::PERCENT))
        m_xWordSpacingMinimum->set_value(nMaximum, FieldUnit::PERCENT);
    if (nMaximum < m_xWordSpacing->get_value(FieldUnit::PERCENT))
        m_xWordSpacing->set_value(nMaximum, FieldUnit::PERCENT);
}

void SvxParaAlignTabPage::UpdateExample_Impl()
{
    if (m_xLeft->get_active())
    {
        m_aExampleWin.EnableRTL(false);
        m_aExampleWin.SetAdjust(SvxAdjust::Left);
        m_aExampleWin.SetLastLine(SvxAdjust::Left);
    }
    else if (m_xRight->get_active())
    {
        m_aExampleWin.EnableRTL(true);
        m_aExampleWin.SetAdjust(SvxAdjust::Left);
        m_aExampleWin.SetLastLine(SvxAdjust::Left);
    }
    else
    {
        SvxFrameDirection eDir = m_xTextDirectionLB->get_active_id();
        switch ( eDir )
        {
            case SvxFrameDirection::Environment :
                if ( !m_xRight->get_active() )
                    m_aExampleWin.EnableRTL( AllSettings::GetLayoutRTL() );
                break;
            case SvxFrameDirection::Horizontal_RL_TB :
                if ( !m_xLeft->get_active() )
                    m_aExampleWin.EnableRTL( true );
                break;
            case SvxFrameDirection::Horizontal_LR_TB :
                if ( !m_xRight->get_active() )
                    m_aExampleWin.EnableRTL( false );
                break;
            default: ; //prevent warning
        }
        if (m_xCenter->get_active())
            m_aExampleWin.SetAdjust( SvxAdjust::Center );
        else if (m_xJustify->get_active())
        {
            m_aExampleWin.SetAdjust( SvxAdjust::Block );
            int nLBPos = m_xLastLineLB->get_active();
            if (nLBPos == 0)
                m_aExampleWin.SetLastLine(SvxAdjust::Left);
            else if (nLBPos == 1)
                m_aExampleWin.SetLastLine(SvxAdjust::Center);
            else if (nLBPos == 2)
                m_aExampleWin.SetLastLine(SvxAdjust::Block);
        }
    }

    m_aExampleWin.Invalidate();
}

void SvxParaAlignTabPage::EnableJustifyExt()
{
    m_xLastLineFT->show();
    m_xLastLineLB->show();
    m_xExpandCB->show();
    if (SvtCJKOptions::IsAsianTypographyEnabled())
        m_xSnapToGridCB->show();

}

void SvxParaAlignTabPage::EnableSdrVertAlign()
{
    m_bSdrVertAlign = true;

    m_xVertAlignLB->remove_id(u"0"_ustr);
    m_xVertAlignLB->remove_id(u"1"_ustr);
    m_xVertAlign->set_label(m_xVertAlignSdr->get_label());
}

void SvxParaAlignTabPage::PageCreated (const SfxAllItemSet& aSet)
{
    const SfxBoolItem* pBoolItem = aSet.GetItem<SfxBoolItem>(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT, false);
    if (pBoolItem && pBoolItem->GetValue())
        EnableJustifyExt();
}

std::unique_ptr<SfxTabPage> SvxExtParagraphTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
{
    return std::make_unique<SvxExtParagraphTabPage>(pPage, pController, *rSet);
}

bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet )
{
    bool bModified = false;
    sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
    const TriState eHyphenState = m_xHyphenBox->get_state();
    const SfxPoolItem* pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_HYPHENZONE );

    if ( m_xHyphenBox->get_state_changed_from_saved() ||
         m_xHyphenNoCapsBox->get_state_changed_from_saved() ||
         m_xHyphenNoLastWordBox->get_state_changed_from_saved() ||
         m_xAcrossMoveLineBox->get_state_changed_from_saved() ||
         m_xExtHyphenBeforeBox->get_value_changed_from_saved() ||
         m_xExtHyphenAfterBox->get_value_changed_from_saved() ||
         m_xExtCompoundHyphenBeforeBox->get_value_changed_from_saved() ||
         m_xMaxHyphenEdit->get_value_changed_from_saved() ||
         m_xMinWordLength->get_value_changed_from_saved() ||
         m_aHyphenZone.get_value_changed_from_saved() ||
--> --------------------

--> maximum size reached

--> --------------------

Messung V0.5
C=96 H=99 G=97

¤ Dauer der Verarbeitung: 0.9 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.