diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx index 809bd672817b..3f13a6bf6324 100644 --- a/cui/source/tabpages/page.cxx +++ b/cui/source/tabpages/page.cxx @@ -336,13 +336,13 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) if ( pItem ) { const SvxLRSpaceItem& rLRSpace = static_cast(*pItem); - SetMetricValue( *m_xLeftMarginEdit, rLRSpace.GetLeft(), eUnit ); + SetMetricValue(*m_xLeftMarginEdit, rLRSpace.ResolveLeft({}), eUnit); SetMetricValue(*m_xGutterMarginEdit, rLRSpace.GetGutterMargin(), eUnit); m_aBspWin.SetLeft( - static_cast(ConvertLong_Impl( rLRSpace.GetLeft(), eUnit )) ); - SetMetricValue( *m_xRightMarginEdit, rLRSpace.GetRight(), eUnit ); + static_cast(ConvertLong_Impl(rLRSpace.ResolveLeft({}), eUnit))); + SetMetricValue(*m_xRightMarginEdit, rLRSpace.ResolveRight({}), eUnit); m_aBspWin.SetRight( - static_cast(ConvertLong_Impl( rLRSpace.GetRight(), eUnit )) ); + static_cast(ConvertLong_Impl(rLRSpace.ResolveRight({}), eUnit))); } // adjust margins (top/bottom) @@ -633,13 +633,15 @@ bool SvxPageDescPage::FillItemSet( SfxItemSet* rSet ) if (m_xLeftMarginEdit->get_value_changed_from_saved()) { - aMargin.SetLeft( static_cast(GetCoreValue( *m_xLeftMarginEdit, eUnit )) ); + aMargin.SetLeft(SvxIndentValue::twips( + static_cast(GetCoreValue(*m_xLeftMarginEdit, eUnit)))); bModified = true; } if (m_xRightMarginEdit->get_value_changed_from_saved()) { - aMargin.SetRight( static_cast(GetCoreValue( *m_xRightMarginEdit, eUnit )) ); + aMargin.SetRight(SvxIndentValue::twips( + static_cast(GetCoreValue(*m_xRightMarginEdit, eUnit)))); bModified = true; } @@ -1254,8 +1256,8 @@ void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet ) m_aBspWin.SetHdDist( nDist ); const SvxLRSpaceItem& rLR = rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) ); - m_aBspWin.SetHdLeft( rLR.GetLeft() ); - m_aBspWin.SetHdRight( rLR.GetRight() ); + m_aBspWin.SetHdLeft(rLR.ResolveLeft({})); + m_aBspWin.SetHdRight(rLR.ResolveRight({})); m_aBspWin.SetHeader( true ); } else @@ -1309,8 +1311,8 @@ void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet ) m_aBspWin.SetFtDist( nDist ); const SvxLRSpaceItem& rLR = rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) ); - m_aBspWin.SetFtLeft( rLR.GetLeft() ); - m_aBspWin.SetFtRight( rLR.GetRight() ); + m_aBspWin.SetFtLeft(rLR.ResolveLeft({})); + m_aBspWin.SetFtRight(rLR.ResolveRight({})); m_aBspWin.SetFooter( true ); } else diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx index a8f6150d0dab..ea8b6a4def38 100644 --- a/cui/source/tabpages/paragrph.cxx +++ b/cui/source/tabpages/paragrph.cxx @@ -381,12 +381,12 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) } else { - item.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit)); + item.SetTextLeft(lcl_GetFontRelativeValue(m_aLeftIndent, eUnit)); } } else { - item.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit)); + item.SetTextLeft(lcl_GetFontRelativeValue(m_aLeftIndent, eUnit)); } if (!pOld || *static_cast(pOld) != item || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich)) @@ -417,12 +417,12 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) } else { - item.SetRight(m_aRightIndent.GetCoreValue(eUnit)); + item.SetRight(lcl_GetFontRelativeValue(m_aRightIndent, eUnit)); } } else { - item.SetRight(m_aRightIndent.GetCoreValue(eUnit)); + item.SetRight(lcl_GetFontRelativeValue(m_aRightIndent, eUnit)); } if (!pOld || *static_cast(pOld) != item || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich)) @@ -463,7 +463,7 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) item.SetTextFirstLineOffset(lcl_GetFontRelativeValue(m_aFLineIndent, eUnit)); } item.SetAutoFirst(m_xAutoCB->get_active()); - if (item.GetTextFirstLineOffsetValue() < 0) + if (item.GetTextFirstLineOffset().m_dValue < 0.0) { bNullTab = true; } @@ -498,13 +498,13 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) aMargin.SetTextLeft( rOldItem.GetTextLeft(), static_cast(m_aLeftIndent.get_value(FieldUnit::NONE)) ); else - aMargin.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit)); + aMargin.SetTextLeft(lcl_GetFontRelativeValue(m_aLeftIndent, eUnit)); if ( m_aRightIndent.IsRelative() ) aMargin.SetRight( rOldItem.GetRight(), static_cast(m_aRightIndent.get_value(FieldUnit::NONE)) ); else - aMargin.SetRight(m_aRightIndent.GetCoreValue(eUnit)); + aMargin.SetRight(lcl_GetFontRelativeValue(m_aRightIndent, eUnit)); if ( m_aFLineIndent.IsRelative() ) aMargin.SetTextFirstLineOffset( @@ -517,12 +517,12 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) } else { - aMargin.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit)); - aMargin.SetRight(m_aRightIndent.GetCoreValue(eUnit)); + 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.GetTextFirstLineOffsetValue() < 0.0 ) + if (aMargin.GetTextFirstLineOffset().m_dValue < 0.0) bNullTab = true; if ( !pOld || *static_cast(pOld) != aMargin || @@ -642,12 +642,12 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) { m_aLeftIndent.SetRelative(false); m_aLeftIndent.SetFieldUnit(eFUnit); - m_aLeftIndent.SetMetricValue(rOldLeftMargin.GetTextLeft(), eUnit); + lcl_SetFontRelativeValue(m_aLeftIndent, rOldLeftMargin.GetTextLeft(), eUnit); } } else { - m_aLeftIndent.SetMetricValue(rOldLeftMargin.GetTextLeft(), eUnit); + lcl_SetFontRelativeValue(m_aLeftIndent, rOldLeftMargin.GetTextLeft(), eUnit); } } else if (m_bSplitLRSpace) @@ -673,12 +673,12 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) { m_aRightIndent.SetRelative(false); m_aRightIndent.SetFieldUnit(eFUnit); - m_aRightIndent.SetMetricValue(rOldRightMargin.GetRight(), eUnit); + lcl_SetFontRelativeValue(m_aRightIndent, rOldRightMargin.GetRight(), eUnit); } } else { - m_aRightIndent.SetMetricValue(rOldRightMargin.GetRight(), eUnit); + lcl_SetFontRelativeValue(m_aRightIndent, rOldRightMargin.GetRight(), eUnit); } } else if (m_bSplitLRSpace) @@ -743,7 +743,7 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) { m_aLeftIndent.SetRelative(false); m_aLeftIndent.SetFieldUnit(eFUnit); - m_aLeftIndent.SetMetricValue(rOldItem.GetTextLeft(), eUnit); + lcl_SetFontRelativeValue(m_aLeftIndent, rOldItem.GetTextLeft(), eUnit); } if ( rOldItem.GetPropRight() != 100 ) @@ -755,7 +755,7 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) { m_aRightIndent.SetRelative(false); m_aRightIndent.SetFieldUnit(eFUnit); - m_aRightIndent.SetMetricValue(rOldItem.GetRight(), eUnit); + lcl_SetFontRelativeValue(m_aRightIndent, rOldItem.GetRight(), eUnit); } if ( rOldItem.GetPropTextFirstLineOffset() != 100 ) @@ -777,8 +777,8 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) const SvxLRSpaceItem& rSpace = static_cast(rSet->Get( _nWhich )); - m_aLeftIndent.SetMetricValue(rSpace.GetTextLeft(), eUnit); - m_aRightIndent.SetMetricValue(rSpace.GetRight(), eUnit); + 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()); } @@ -979,6 +979,9 @@ SvxStdParagraphTabPage::SvxStdParagraphTabPage(weld::Container* pPage, weld::Dia Init_Impl(); m_aFLineIndent.set_min(-9999, FieldUnit::NONE); // is set to 0 on default m_aFLineIndent.EnableFontRelativeMode(); + + m_aLeftIndent.EnableFontRelativeMode(); + m_aRightIndent.EnableFontRelativeMode(); } SvxStdParagraphTabPage::~SvxStdParagraphTabPage() diff --git a/cui/source/tabpages/tabstpge.cxx b/cui/source/tabpages/tabstpge.cxx index 34b0b631af3a..78e9aec3b739 100644 --- a/cui/source/tabpages/tabstpge.cxx +++ b/cui/source/tabpages/tabstpge.cxx @@ -177,7 +177,8 @@ bool SvxTabulatorTabPage::FillItemSet(SfxItemSet* rSet) pLRSpace = GetOldItem(*rSet, SID_ATTR_LRSPACE); if (pLRSpace - && static_cast(pLRSpace)->GetTextFirstLineOffsetValue() < 0.0) + && static_cast(pLRSpace)->GetTextFirstLineOffset().m_dValue + < 0.0) { SvxTabStop aNull(0, SvxTabAdjust::Default); aNewTabs->Insert(aNull); diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx index 2b4d3956eefd..d2a9290dae00 100644 --- a/editeng/source/editeng/editdbg.cxx +++ b/editeng/source/editeng/editdbg.cxx @@ -71,8 +71,8 @@ struct DebOutBuffer { str.append(OString::Concat(descr) + "FI=" + OString::number(rItem.ResolveTextFirstLineOffset({})) - + ", LI=" + OString::number(rItem.GetTextLeft()) - + ", RI=" + OString::number(rItem.GetRight())); + + ", LI=" + OString::number(rItem.ResolveTextLeft({})) + + ", RI=" + OString::number(rItem.ResolveRight({}))); } void append(std::string_view descr, const SvxNumBulletItem& rItem) { diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 63961daefe27..d0e6d987b424 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -574,14 +574,19 @@ void ConvertItem( std::unique_ptr& rPoolItem, MapUnit eSourceUnit, { assert(dynamic_cast(rPoolItem.get()) != nullptr); SvxLRSpaceItem& rItem = static_cast(*rPoolItem); - if (rItem.GetTextFirstLineOffsetUnit() == css::util::MeasureUnit::TWIP) + if (rItem.GetTextFirstLineOffset().m_nUnit == css::util::MeasureUnit::TWIP) { rItem.SetTextFirstLineOffset( SvxIndentValue::twips(sal::static_int_cast(OutputDevice::LogicToLogic( rItem.ResolveTextFirstLineOffset({}), eSourceUnit, eDestUnit)))); } - rItem.SetTextLeft( OutputDevice::LogicToLogic( rItem.GetTextLeft(), eSourceUnit, eDestUnit ) ); - rItem.SetRight( OutputDevice::LogicToLogic( rItem.GetRight(), eSourceUnit, eDestUnit ) ); + rItem.SetTextLeft(SvxIndentValue::twips( + OutputDevice::LogicToLogic(rItem.ResolveTextLeft({}), eSourceUnit, eDestUnit))); + if (rItem.GetRight().m_nUnit == css::util::MeasureUnit::TWIP) + { + rItem.SetRight(SvxIndentValue::twips( + OutputDevice::LogicToLogic(rItem.ResolveRight({}), eSourceUnit, eDestUnit))); + } } break; case EE_PARA_ULSPACE: diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 029ae6a9e223..24d30ba3b559 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -686,7 +686,8 @@ private: EditPaM RemoveText(); bool createLinesForEmptyParagraph(ParaPortion& rParaPortion); - tools::Long calculateMaxLineWidth(tools::Long nStartX, SvxLRSpaceItem const& rLRItem); + tools::Long calculateMaxLineWidth(tools::Long nStartX, SvxLRSpaceItem const& rLRItem, + const SvxFontUnitMetrics& rMetrics); bool CreateLines(sal_Int32 nPara, sal_uInt32 nStartPosY); void CreateAndInsertEmptyLine(ParaPortion& rParaPortion); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 95ea82178989..4fcf6e142a7a 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -3473,7 +3473,8 @@ sal_uInt32 ImpEditEngine::CalcParaWidth( sal_Int32 nPara, bool bIgnoreExtraSpace // width, here not preferred. I general, it is best not leave it // to StartPosX, also the right indents have to be taken into // account! - tools::Long nCurWidth = scaleXSpacingValue(rLRItem.GetTextLeft() + nSpaceBeforeAndMinLabelWidth); + tools::Long nCurWidth + = scaleXSpacingValue(rLRItem.ResolveTextLeft({}) + nSpaceBeforeAndMinLabelWidth); if ( nLine == 0 ) { tools::Long nFI = scaleXSpacingValue(rLRItem.ResolveTextFirstLineOffset(stMetrics)); @@ -3485,7 +3486,7 @@ sal_uInt32 ImpEditEngine::CalcParaWidth( sal_Int32 nPara, bool bIgnoreExtraSpace nCurWidth = pPortion->GetBulletX(); } } - nCurWidth += scaleXSpacingValue(rLRItem.GetRight()); + nCurWidth += scaleXSpacingValue(rLRItem.ResolveRight({})); nCurWidth += CalcLineWidth(*pPortion, rLine, bIgnoreExtraSpace); if ( nCurWidth > nMaxWidth ) { @@ -3800,7 +3801,7 @@ Point ImpEditEngine::GetDocPosTopLeft( sal_Int32 nParagraph ) const SvxLRSpaceItem& rLRItem = GetLRSpaceItem(pPPortion->GetNode()); sal_Int32 nSpaceBefore = 0; GetSpaceBeforeAndMinLabelWidth(pPPortion->GetNode(), &nSpaceBefore); - short nX = static_cast(rLRItem.GetTextLeft() + short nX = static_cast(rLRItem.ResolveTextLeft(stMetrics) + rLRItem.ResolveTextFirstLineOffset(stMetrics) + nSpaceBefore); diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index b060d35fbc0a..068a6b56aa0f 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -605,18 +605,20 @@ bool ImpEditEngine::createLinesForEmptyParagraph(ParaPortion& rParaPortion) return FinishCreateLines(rParaPortion); } -tools::Long ImpEditEngine::calculateMaxLineWidth(tools::Long nStartX, SvxLRSpaceItem const& rLRItem) +tools::Long ImpEditEngine::calculateMaxLineWidth(tools::Long nStartX, SvxLRSpaceItem const& rLRItem, + const SvxFontUnitMetrics& rMetrics) { const bool bAutoSize = IsEffectivelyVertical() ? maStatus.AutoPageHeight() : maStatus.AutoPageWidth(); tools::Long nMaxLineWidth = GetColumnWidth(bAutoSize ? maMaxAutoPaperSize : maPaperSize); - nMaxLineWidth -= scaleXSpacingValue(rLRItem.GetRight()); + nMaxLineWidth -= scaleXSpacingValue(rLRItem.ResolveRight(rMetrics)); nMaxLineWidth -= nStartX; // If PaperSize == long_max, one cannot take away any negative // first line indent. (Overflow) if (nMaxLineWidth < 0 && nStartX < 0) - nMaxLineWidth = GetColumnWidth(maPaperSize) - scaleXSpacingValue(rLRItem.GetRight()); + nMaxLineWidth + = GetColumnWidth(maPaperSize) - scaleXSpacingValue(rLRItem.ResolveRight(rMetrics)); // If still less than 0, it may be just the right edge. if (nMaxLineWidth <= 0) @@ -810,12 +812,13 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) sal_Int32 nPortionStart = 0; sal_Int32 nPortionEnd = 0; - tools::Long nStartX = scaleXSpacingValue(rLRItem.GetTextLeft() + nSpaceBeforeAndMinLabelWidth); + auto stMetrics = GetFontUnitMetrics(pNode); + tools::Long nStartX + = scaleXSpacingValue(rLRItem.ResolveTextLeft(stMetrics) + nSpaceBeforeAndMinLabelWidth); // Multiline hyperlink may need to know if the next line is bigger. tools::Long nStartXNextLine = nStartX; if ( nIndex == 0 ) { - auto stMetrics = GetFontUnitMetrics(pNode); tools::Long nFI = scaleXSpacingValue(rLRItem.ResolveTextFirstLineOffset(stMetrics)); nStartX += nFI; @@ -827,7 +830,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) nStartX += nStartNextLineAfterMultiLineField; nStartNextLineAfterMultiLineField = 0; - tools::Long nMaxLineWidth = calculateMaxLineWidth(nStartX, rLRItem); + tools::Long nMaxLineWidth = calculateMaxLineWidth(nStartX, rLRItem, stMetrics); // Problem: // Since formatting starts a line _before_ the invalid position, @@ -905,8 +908,9 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) } } nXWidth = nMaxRangeWidth; - if ( nXWidth ) - nMaxLineWidth = nXWidth - nStartX - scaleXSpacingValue(rLRItem.GetRight()); + if (nXWidth) + nMaxLineWidth + = nXWidth - nStartX - scaleXSpacingValue(rLRItem.ResolveRight(stMetrics)); else { // Try further down in the polygon. @@ -1002,7 +1006,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) if (maStatus.DoStretch() && (fFontScalingX != 1.0)) nCurPos = basegfx::fround(double(nCurPos) / std::max(fFontScalingX, 0.01)); - short nAllSpaceBeforeText = short(rLRItem.GetTextLeft()); + short nAllSpaceBeforeText = short(rLRItem.ResolveTextLeft({})); aCurrentTab.aTabStop = pNode->GetContentAttribs().FindTabStop( nCurPos - nAllSpaceBeforeText , maEditDoc.GetDefTab() ); aCurrentTab.nTabPos = tools::Long(aCurrentTab.aTabStop.GetTabPos() + nAllSpaceBeforeText); aCurrentTab.bValid = false; @@ -1575,7 +1579,9 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) // has to be used for the Alignment. If it does not fit or if it // will change the paper width, it will be formatted again for // Justification! = LEFT anyway. - tools::Long nMaxLineWidthFix = GetColumnWidth(maPaperSize) - scaleXSpacingValue(rLRItem.GetRight()) - nStartX; + tools::Long nMaxLineWidthFix = GetColumnWidth(maPaperSize) + - scaleXSpacingValue(rLRItem.ResolveRight(stMetrics)) + - nStartX; if ( aTextSize.Width() < nMaxLineWidthFix ) nMaxLineWidth = nMaxLineWidthFix; } @@ -1799,13 +1805,14 @@ void ImpEditEngine::CreateAndInsertEmptyLine(ParaPortion& rParaPortion) sal_Int32 nSpaceBeforeAndMinLabelWidth = GetSpaceBeforeAndMinLabelWidth(rParaPortion.GetNode(), &nSpaceBefore); const SvxLRSpaceItem& rLRItem = GetLRSpaceItem(rParaPortion.GetNode()); const SvxLineSpacingItem& rLSItem = rParaPortion.GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL ); - tools::Long nStartX = scaleXSpacingValue( - rLRItem.GetTextLeft() + rLRItem.ResolveTextFirstLineOffset(stMetrics) + nSpaceBefore); + tools::Long nStartX + = scaleXSpacingValue(rLRItem.ResolveTextLeft(stMetrics) + + rLRItem.ResolveTextFirstLineOffset(stMetrics) + nSpaceBefore); tools::Rectangle aBulletArea { Point(), Point() }; if ( bLineBreak ) { - nStartX = scaleXSpacingValue(rLRItem.GetTextLeft() + nStartX = scaleXSpacingValue(rLRItem.ResolveTextLeft(stMetrics) + rLRItem.ResolveTextFirstLineOffset(stMetrics) + nSpaceBeforeAndMinLabelWidth); } @@ -1818,7 +1825,7 @@ void ImpEditEngine::CreateAndInsertEmptyLine(ParaPortion& rParaPortion) rParaPortion.SetBulletX( 0 ); // If Bullet set incorrectly. if (rParaPortion.GetBulletX() > nStartX) { - nStartX = scaleXSpacingValue(rLRItem.GetTextLeft() + nStartX = scaleXSpacingValue(rLRItem.ResolveTextLeft(stMetrics) + rLRItem.ResolveTextFirstLineOffset(stMetrics) + nSpaceBeforeAndMinLabelWidth); if (rParaPortion.GetBulletX() > nStartX) @@ -1848,7 +1855,7 @@ void ImpEditEngine::CreateAndInsertEmptyLine(ParaPortion& rParaPortion) sal_Int32 nPara = GetParaPortions().GetPos(&rParaPortion); SvxAdjust eJustification = GetJustification( nPara ); tools::Long nMaxLineWidth = GetColumnWidth(maPaperSize); - nMaxLineWidth -= scaleXSpacingValue(rLRItem.GetRight()); + nMaxLineWidth -= scaleXSpacingValue(rLRItem.ResolveRight(stMetrics)); if ( nMaxLineWidth < 0 ) nMaxLineWidth = 1; if ( eJustification == SvxAdjust::Center ) diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index 50d7f6fe9669..e6730a64ef86 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -780,11 +780,11 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, nTxtFirst = LogicToTwips( nTxtFirst ); rOutput.WriteNumberAsString( nTxtFirst ); rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_LI ); - sal_uInt32 nTxtLeft = static_cast< sal_uInt32 >(static_cast(rItem).GetTextLeft()); + sal_uInt32 nTxtLeft = static_cast(rItem).ResolveTextLeft({}); nTxtLeft = static_cast(LogicToTwips( nTxtLeft )); rOutput.WriteNumberAsString( nTxtLeft ); rOutput.WriteOString( OOO_STRING_SVTOOLS_RTF_RI ); - sal_uInt32 nTxtRight = static_cast(rItem).GetRight(); + sal_uInt32 nTxtRight = static_cast(rItem).ResolveRight({}); nTxtRight = LogicToTwips( nTxtRight); rOutput.WriteNumberAsString( nTxtRight ); } diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index 8b4e10e25c83..924ce4b50ece 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -288,11 +288,124 @@ bool SvxSizeItem::HasMetrics() const return true; } +double SvxIndentValue::ResolveDouble(const SvxFontUnitMetrics& rMetrics) const +{ + if (m_nUnit == css::util::MeasureUnit::TWIP) + return m_dValue; + + SAL_WARN_IF(!rMetrics.m_bInitialized, "editeng", "font-relative indentation lost"); + + switch (m_nUnit) + { + case css::util::MeasureUnit::FONT_EM: + return m_dValue * rMetrics.m_dEmTwips; + + case css::util::MeasureUnit::FONT_CJK_ADVANCE: + return m_dValue * rMetrics.m_dIcTwips; + + default: + SAL_WARN("editeng", "unhandled type conversion"); + return 0.0; + } +} + +sal_Int32 SvxIndentValue::Resolve(const SvxFontUnitMetrics& rMetrics) const +{ + return static_cast(std::llround(ResolveDouble(rMetrics))); +} + +sal_Int32 SvxIndentValue::ResolveFixedPart() const +{ + if (m_nUnit == css::util::MeasureUnit::TWIP) + return Resolve({}); + + return 0; +} + +sal_Int32 SvxIndentValue::ResolveVariablePart(const SvxFontUnitMetrics& rMetrics) const +{ + if (m_nUnit == css::util::MeasureUnit::TWIP) + return 0; + + return Resolve(rMetrics); +} + +void SvxIndentValue::ScaleMetrics(tools::Long const nMult, tools::Long const nDiv) +{ + m_dValue = (m_dValue * static_cast(nMult)) / static_cast(nDiv); +} + +size_t SvxIndentValue::hashCode() const +{ + std::size_t seed(0); + o3tl::hash_combine(seed, m_dValue); + o3tl::hash_combine(seed, m_nUnit); + return seed; +} + +namespace +{ + +boost::property_tree::ptree lcl_IndentValueToJson(const char* aName, SvxIndentValue stValue) +{ + boost::property_tree::ptree aState; + + switch (stValue.m_nUnit) + { + case css::util::MeasureUnit::TWIP: + { + OUString sValue + = GetMetricText(stValue.m_dValue, MapUnit::MapTwip, MapUnit::MapInch, nullptr); + aState.put(aName, sValue); + aState.put("unit", "inch"); + } + break; + + case css::util::MeasureUnit::FONT_EM: + aState.put(aName, stValue.m_dValue); + aState.put("unit", "em"); + break; + + case css::util::MeasureUnit::FONT_CJK_ADVANCE: + aState.put(aName, stValue.m_dValue); + aState.put("unit", "ic"); + break; + + default: + SAL_WARN("editeng", "unhandled type conversion"); + break; + } + + return aState; +} + +bool lcl_FillAbsoluteMeasureAny(const SvxIndentValue& rIndent, uno::Any& rVal, bool bConvert) +{ + if (rIndent.m_nUnit == css::util::MeasureUnit::TWIP) + { + auto nConvOffset = (bConvert ? convertTwipToMm100(rIndent.m_dValue) : rIndent.m_dValue); + rVal <<= static_cast(std::llround(nConvOffset)); + return true; + } + + return false; +} + +bool lcl_FillRelativeMeasureAny(const SvxIndentValue& rIndent, uno::Any& rVal) +{ + if (rIndent.m_nUnit != css::util::MeasureUnit::TWIP) + { + rVal <<= css::beans::Pair{ rIndent.m_dValue, rIndent.m_nUnit }; + return true; + } + + return false; +} + +} SvxLRSpaceItem::SvxLRSpaceItem(const sal_uInt16 nId) : SfxPoolItem(nId, SfxItemType::SvxLRSpaceItemType) - , nLeftMargin(0) - , nRightMargin(0) , m_nGutterMargin(0) , m_nRightGutterMargin(0), nPropFirstLineOffset( 100 ), @@ -304,11 +417,9 @@ SvxLRSpaceItem::SvxLRSpaceItem(const sal_uInt16 nId) { } -SvxLRSpaceItem::SvxLRSpaceItem(const tools::Long nLeft, const tools::Long nRight, +SvxLRSpaceItem::SvxLRSpaceItem(SvxIndentValue stLeft, SvxIndentValue stRight, SvxIndentValue stOffset, const sal_uInt16 nId) : SfxPoolItem(nId, SfxItemType::SvxLRSpaceItemType) - , nLeftMargin(nLeft) - , nRightMargin(nRight) , m_nGutterMargin(0) , m_nRightGutterMargin(0) , nPropFirstLineOffset(100) @@ -318,6 +429,8 @@ SvxLRSpaceItem::SvxLRSpaceItem(const tools::Long nLeft, const tools::Long nRight , bExplicitZeroMarginValRight(false) , bExplicitZeroMarginValLeft(false) { + SetLeft(stLeft); + SetRight(stRight); SetTextFirstLineOffset(stOffset); } @@ -333,9 +446,19 @@ bool SvxLRSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const case 0: { css::frame::status::LeftRightMarginScale aLRSpace; - aLRSpace.Left = static_cast(bConvert ? convertTwipToMm100(nLeftMargin) : nLeftMargin); - aLRSpace.TextLeft = static_cast(bConvert ? convertTwipToMm100(GetTextLeft()) : GetTextLeft()); - aLRSpace.Right = static_cast(bConvert ? convertTwipToMm100(nRightMargin) : nRightMargin); + + auto nLeftTwips = ResolveLeft({}); + aLRSpace.Left + = static_cast(bConvert ? convertTwipToMm100(nLeftTwips) : nLeftTwips); + + auto nTextLeftTwips = ResolveTextLeft({}); + aLRSpace.TextLeft = static_cast(bConvert ? convertTwipToMm100(nTextLeftTwips) + : nTextLeftTwips); + + auto nRightTwips = ResolveRight({}); + aLRSpace.Right + = static_cast(bConvert ? convertTwipToMm100(nRightTwips) : nRightTwips); + aLRSpace.ScaleLeft = static_cast(nPropLeftMargin); aLRSpace.ScaleRight = static_cast(nPropRightMargin); @@ -348,15 +471,24 @@ bool SvxLRSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const break; } case MID_L_MARGIN: - rVal <<= static_cast(bConvert ? convertTwipToMm100(nLeftMargin) : nLeftMargin); + bRet = lcl_FillAbsoluteMeasureAny(GetLeft(), rVal, bConvert); break; - case MID_TXT_LMARGIN : - rVal <<= static_cast(bConvert ? convertTwipToMm100(GetTextLeft()) : GetTextLeft()); - break; - case MID_R_MARGIN: - rVal <<= static_cast(bConvert ? convertTwipToMm100(nRightMargin) : nRightMargin); + case MID_TXT_LMARGIN: + bRet = lcl_FillAbsoluteMeasureAny(GetTextLeft(), rVal, bConvert); break; + + case MID_L_UNIT_MARGIN: + bRet = lcl_FillRelativeMeasureAny(GetTextLeft(), rVal); + break; + + case MID_R_MARGIN: + bRet = lcl_FillAbsoluteMeasureAny(m_stRightMargin, rVal, bConvert); + break; + case MID_R_UNIT_MARGIN: + bRet = lcl_FillRelativeMeasureAny(m_stRightMargin, rVal); + break; + case MID_L_REL_MARGIN: rVal <<= static_cast(nPropLeftMargin); break; @@ -365,38 +497,16 @@ bool SvxLRSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const break; case MID_FIRST_LINE_INDENT: - // MID_FIRST_LINE_INDENT only supports statically-convertible measures. - // In practice, these are always stored here in twips. - if (m_nFirstLineUnit == css::util::MeasureUnit::TWIP) - { - auto nConvOffset - = (bConvert ? convertTwipToMm100(m_dFirstLineOffset) : m_dFirstLineOffset); - rVal <<= static_cast(std::llround(nConvOffset)); - } - else - { - bRet = false; - } - break; + bRet = lcl_FillAbsoluteMeasureAny(m_stFirstLineOffset, rVal, bConvert); + break; case MID_FIRST_LINE_REL_INDENT: rVal <<= static_cast(nPropFirstLineOffset); break; case MID_FIRST_LINE_UNIT_INDENT: - // MID_FIRST_LINE_UNIT_INDENT is used for any values that must be serialized - // as a unit-value pair. In practice, this will be limited to font-relative - // units (e.g. em, ic), and all other units will be pre-converted to twips. - if (m_nFirstLineUnit != css::util::MeasureUnit::TWIP) - { - rVal - <<= css::beans::Pair{ m_dFirstLineOffset, m_nFirstLineUnit }; - } - else - { - bRet = false; - } - break; + bRet = lcl_FillRelativeMeasureAny(m_stFirstLineOffset, rVal); + break; case MID_FIRST_AUTO: rVal <<= IsAutoFirst(); @@ -422,8 +532,9 @@ bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) nMemberId &= ~CONVERT_TWIPS; sal_Int32 nVal = 0; if (nMemberId != 0 && nMemberId != MID_FIRST_AUTO && nMemberId != MID_L_REL_MARGIN - && nMemberId != MID_R_REL_MARGIN && nMemberId != MID_FIRST_LINE_UNIT_INDENT) - if(!(rVal >>= nVal)) + && nMemberId != MID_R_REL_MARGIN && nMemberId != MID_FIRST_LINE_UNIT_INDENT + && nMemberId != MID_L_UNIT_MARGIN && nMemberId != MID_R_UNIT_MARGIN) + if (!(rVal >>= nVal)) return false; switch( nMemberId ) @@ -434,9 +545,13 @@ bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) if(!(rVal >>= aLRSpace)) return false; - SetLeft( bConvert ? o3tl::toTwips(aLRSpace.Left, o3tl::Length::mm100) : aLRSpace.Left ); - SetTextLeft( bConvert ? o3tl::toTwips(aLRSpace.TextLeft, o3tl::Length::mm100) : aLRSpace.TextLeft ); - SetRight(bConvert ? o3tl::toTwips(aLRSpace.Right, o3tl::Length::mm100) : aLRSpace.Right); + SetLeft(SvxIndentValue::twips( + bConvert ? o3tl::toTwips(aLRSpace.Left, o3tl::Length::mm100) : aLRSpace.Left)); + SetTextLeft(SvxIndentValue::twips( + bConvert ? o3tl::toTwips(aLRSpace.TextLeft, o3tl::Length::mm100) + : aLRSpace.TextLeft)); + SetRight(SvxIndentValue::twips( + bConvert ? o3tl::toTwips(aLRSpace.Right, o3tl::Length::mm100) : aLRSpace.Right)); nPropLeftMargin = aLRSpace.ScaleLeft; nPropRightMargin = aLRSpace.ScaleRight; SetTextFirstLineOffset(SvxIndentValue::twips( @@ -447,16 +562,44 @@ bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) break; } case MID_L_MARGIN: - SetLeft( bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal ); + SetLeft( + SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal)); break; - case MID_TXT_LMARGIN : - SetTextLeft( bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal ); - break; + case MID_TXT_LMARGIN: + SetTextLeft( + SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal)); + break; + + case MID_L_UNIT_MARGIN: + { + css::beans::Pair stVal; + if (!(rVal >>= stVal)) + { + return false; + } + + SetTextLeft(SvxIndentValue{ stVal.First, stVal.Second }); + break; + } case MID_R_MARGIN: - SetRight(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); + SetRight( + SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal)); break; + + case MID_R_UNIT_MARGIN: + { + css::beans::Pair stVal; + if (!(rVal >>= stVal)) + { + return false; + } + + SetRight(SvxIndentValue{ stVal.First, stVal.Second }); + break; + } + case MID_L_REL_MARGIN: case MID_R_REL_MARGIN: { @@ -472,7 +615,7 @@ bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) return false; } break; - case MID_FIRST_LINE_INDENT : + case MID_FIRST_LINE_INDENT: SetTextFirstLineOffset( SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal)); break; @@ -514,147 +657,226 @@ void SvxLeftMarginItem::SetLeft(const tools::Long nL, const sal_uInt16 nProp) m_nPropLeftMargin = nProp; } -void SvxLRSpaceItem::SetLeft(const tools::Long nL, const sal_uInt16 nProp) +void SvxLRSpaceItem::SetLeft(SvxIndentValue stL, const sal_uInt16 nProp) { - nLeftMargin = (nL * nProp) / 100; - SAL_WARN_IF(m_dFirstLineOffset != 0.0, "editeng", + SAL_WARN_IF(m_stFirstLineOffset.m_dValue != 0.0, "editeng", "probably call SetTextLeft instead? looks inconsistent otherwise"); + + m_stLeftMargin = stL; nPropLeftMargin = nProp; + + if (nProp != 100) + { + m_stLeftMargin.m_dValue = (stL.m_dValue * static_cast(nProp)) / 100.0; + } } -void SvxRightMarginItem::SetRight(const tools::Long nR, const sal_uInt16 nProp) +SvxIndentValue SvxLRSpaceItem::GetLeft() const { return m_stLeftMargin; } + +sal_Int32 SvxLRSpaceItem::ResolveLeft(const SvxFontUnitMetrics& rMetrics) const +{ + return m_stLeftMargin.Resolve(rMetrics); +} + +void SvxRightMarginItem::SetRight(SvxIndentValue stR, const sal_uInt16 nProp) { ASSERT_CHANGE_REFCOUNTED_ITEM; - m_nRightMargin = (nR * nProp) / 100; + + m_stRightMargin = stR; m_nPropRightMargin = nProp; + + if (nProp != 100) + { + m_stRightMargin.m_dValue = (stR.m_dValue * static_cast(nProp)) / 100.0; + } } -void SvxLRSpaceItem::SetRight(const tools::Long nR, const sal_uInt16 nProp) +SvxIndentValue SvxRightMarginItem::GetRight() const { return m_stRightMargin; } + +SvxIndentValue SvxLRSpaceItem::GetRight() const { return m_stRightMargin; } + +sal_Int32 SvxRightMarginItem::ResolveRight(const SvxFontUnitMetrics& rMetrics) const { - if (0 == nR) + return m_stRightMargin.Resolve(rMetrics); +} + +sal_Int32 SvxLRSpaceItem::ResolveRight(const SvxFontUnitMetrics& rMetrics) const +{ + return m_stRightMargin.Resolve(rMetrics); +} + +sal_Int32 SvxRightMarginItem::ResolveRightFixedPart() const +{ + return m_stRightMargin.ResolveFixedPart(); +} + +sal_Int32 SvxRightMarginItem::ResolveRightVariablePart(const SvxFontUnitMetrics& rMetrics) const +{ + return m_stRightMargin.ResolveVariablePart(rMetrics); +} + +sal_uInt16 SvxRightMarginItem::GetPropRight() const { return m_nPropRightMargin; } + +void SvxLRSpaceItem::SetRight(SvxIndentValue stR, const sal_uInt16 nProp) +{ + if (0.0 == stR.m_dValue) { SetExplicitZeroMarginValRight(true); } - nRightMargin = (nR * nProp) / 100; + + m_stRightMargin = stR; nPropRightMargin = nProp; + + if (nProp != 100) + { + m_stRightMargin.m_dValue = (stR.m_dValue * static_cast(nProp)) / 100.0; + } } void SvxLRSpaceItem::SetTextFirstLineOffset(SvxIndentValue stValue, sal_uInt16 nProp) { // note: left margin contains any negative first line offset - preserve it! - if (m_dFirstLineOffset < 0.0) + if (m_stFirstLineOffset.m_dValue < 0.0) { - nLeftMargin -= ResolveTextFirstLineOffset({}); + m_stLeftMargin + = SvxIndentValue::twips(m_stLeftMargin.Resolve({}) - ResolveTextFirstLineOffset({})); } - m_dFirstLineOffset = stValue.m_dValue; - m_nFirstLineUnit = stValue.m_nUnit; + m_stFirstLineOffset = stValue; nPropFirstLineOffset = nProp; if (nProp != 100) { - m_dFirstLineOffset = (stValue.m_dValue * static_cast(nProp)) / 100.0; + m_stFirstLineOffset.m_dValue = (stValue.m_dValue * static_cast(nProp)) / 100.0; } - if (m_dFirstLineOffset < 0.0) + if (m_stFirstLineOffset.m_dValue < 0.0) { - nLeftMargin += ResolveTextFirstLineOffset({}); + m_stLeftMargin + = SvxIndentValue::twips(m_stLeftMargin.Resolve({}) + ResolveTextFirstLineOffset({})); } } -#if 0 -void SvxTextLeftMarginItem::SetLeft(SvxFirstLineIndentItem const& rFirstLine, - const tools::Long nL, const sal_uInt16 nProp) -{ - m_nTextLeftMargin = (nL * nProp) / 100; - m_nPropLeftMargin = nProp; - // note: text left margin contains any negative first line offset - if (rFirstLine.GetTextFirstLineOffset() < 0) - { - m_nTextLeftMargin += rFirstLine.GetTextFirstLineOffset(); - } -} -#endif - -void SvxTextLeftMarginItem::SetTextLeft(const tools::Long nL, const sal_uInt16 nProp) +void SvxTextLeftMarginItem::SetTextLeft(SvxIndentValue stL, const sal_uInt16 nProp) { ASSERT_CHANGE_REFCOUNTED_ITEM; - m_nTextLeftMargin = (nL * nProp) / 100; + + m_stTextLeftMargin = stL; m_nPropLeftMargin = nProp; + + if (nProp != 100) + { + m_stTextLeftMargin.m_dValue = (stL.m_dValue * static_cast(nProp)) / 100.0; + } } -void SvxLRSpaceItem::SetTextLeft(const tools::Long nL, const sal_uInt16 nProp) +void SvxLRSpaceItem::SetTextLeft(SvxIndentValue stL, const sal_uInt16 nProp) { - if (0 == nL) + if (0.0 == stL.m_dValue) { SetExplicitZeroMarginValLeft(true); } - auto const nTxtLeft = (nL * nProp) / 100; + + m_stLeftMargin = stL; nPropLeftMargin = nProp; + + if (nProp != 100) + { + m_stLeftMargin.m_dValue = (stL.m_dValue * static_cast(nProp)) / 100.0; + } + // note: left margin contains any negative first line offset - if (0.0 > m_dFirstLineOffset) - nLeftMargin = nTxtLeft + ResolveTextFirstLineOffset({}); - else - nLeftMargin = nTxtLeft; + if (0.0 > m_stFirstLineOffset.m_dValue) + { + m_stLeftMargin + = SvxIndentValue::twips(m_stLeftMargin.Resolve({}) + ResolveTextFirstLineOffset({})); + } } SvxIndentValue SvxLRSpaceItem::GetTextFirstLineOffset() const { - return { m_dFirstLineOffset, m_nFirstLineUnit }; -} - -double SvxLRSpaceItem::GetTextFirstLineOffsetValue() const { return m_dFirstLineOffset; } - -sal_Int16 SvxLRSpaceItem::GetTextFirstLineOffsetUnit() const { return m_nFirstLineUnit; } - -double SvxLRSpaceItem::ResolveTextFirstLineOffsetDouble(const SvxFontUnitMetrics& rMetrics) const -{ - if (m_nFirstLineUnit == css::util::MeasureUnit::TWIP) - return m_dFirstLineOffset; - - SAL_WARN_IF(!rMetrics.m_bInitialized, "editeng", "font-relative indentation lost"); - - switch (m_nFirstLineUnit) - { - case css::util::MeasureUnit::FONT_EM: - return m_dFirstLineOffset * rMetrics.m_dEmTwips; - - case css::util::MeasureUnit::FONT_CJK_ADVANCE: - return m_dFirstLineOffset * rMetrics.m_dIcTwips; - - default: - SAL_WARN("editeng", "unhandled type conversion"); - return 0.0; - } + return m_stFirstLineOffset; } sal_Int32 SvxLRSpaceItem::ResolveTextFirstLineOffset(const SvxFontUnitMetrics& rMetrics) const { - return static_cast(std::llround(ResolveTextFirstLineOffsetDouble(rMetrics))); + return m_stFirstLineOffset.Resolve(rMetrics); } -tools::Long SvxTextLeftMarginItem::GetTextLeft() const +SvxIndentValue SvxTextLeftMarginItem::GetTextLeft() const { return m_stTextLeftMargin; } + +sal_Int32 SvxTextLeftMarginItem::ResolveTextLeft(const SvxFontUnitMetrics& rMetrics) const { - return m_nTextLeftMargin; + return m_stTextLeftMargin.Resolve(rMetrics); } -tools::Long SvxTextLeftMarginItem::GetLeft(const SvxFirstLineIndentItem& rFirstLine, - const SvxFontUnitMetrics& rMetrics) const +sal_Int32 SvxTextLeftMarginItem::ResolveLeft(const SvxFirstLineIndentItem& rFirstLine, + const SvxFontUnitMetrics& rMetrics) const { + auto nLeft = m_stTextLeftMargin.Resolve(rMetrics); + // add any negative first line offset to text left margin to get left - if (rFirstLine.GetTextFirstLineOffsetValue() < 0.0) + auto nFirstLine = rFirstLine.GetTextFirstLineOffset().Resolve(rMetrics); + if (nFirstLine < 0) { - auto nFirstLineOffset = rFirstLine.ResolveTextFirstLineOffset(rMetrics); - return m_nTextLeftMargin + nFirstLineOffset; + nLeft += nFirstLine; } - return m_nTextLeftMargin; + return nLeft; } -tools::Long SvxLRSpaceItem::GetTextLeft() const +sal_Int32 +SvxTextLeftMarginItem::ResolveLeftFixedPart(const SvxFirstLineIndentItem& rFirstLine) const +{ + auto nLeft = m_stTextLeftMargin.ResolveFixedPart(); + + // add any negative first line offset to text left margin to get left + auto nFirstLine = rFirstLine.GetTextFirstLineOffset().ResolveFixedPart(); + if (nFirstLine < 0) + { + nLeft += nFirstLine; + } + + return nLeft; +} + +sal_Int32 SvxTextLeftMarginItem::ResolveLeftVariablePart(const SvxFirstLineIndentItem& rFirstLine, + const SvxFontUnitMetrics& rMetrics) const +{ + auto nLeft = m_stTextLeftMargin.ResolveVariablePart(rMetrics); + + // add any negative first line offset to text left margin to get left + auto nFirstLine = rFirstLine.GetTextFirstLineOffset().ResolveVariablePart(rMetrics); + if (nFirstLine < 0) + { + nLeft += nFirstLine; + } + + return nLeft; +} + +sal_uInt16 SvxTextLeftMarginItem::GetPropLeft() const { return m_nPropLeftMargin; } + +SvxIndentValue SvxLRSpaceItem::GetTextLeft() const { // remove any negative first line offset from left margin to get text-left - return (m_dFirstLineOffset < 0) ? nLeftMargin - ResolveTextFirstLineOffset({}) : nLeftMargin; + if (m_stFirstLineOffset.m_dValue < 0.0) + { + return SvxIndentValue::twips(m_stLeftMargin.Resolve({}) - ResolveTextFirstLineOffset({})); + } + + return m_stLeftMargin; +} + +sal_Int32 SvxLRSpaceItem::ResolveTextLeft(const SvxFontUnitMetrics& rMetrics) const +{ + // remove any negative first line offset from left margin to get text-left + if (m_stFirstLineOffset.m_dValue < 0.0) + { + return m_stLeftMargin.Resolve(rMetrics) - ResolveTextFirstLineOffset(rMetrics); + } + + return m_stLeftMargin.Resolve(rMetrics); } SvxLeftMarginItem::SvxLeftMarginItem(const sal_uInt16 nId) @@ -830,15 +1052,15 @@ SvxTextLeftMarginItem::SvxTextLeftMarginItem(const sal_uInt16 nId) { } -SvxTextLeftMarginItem::SvxTextLeftMarginItem(const tools::Long nLeft, const sal_uInt16 nId) +SvxTextLeftMarginItem::SvxTextLeftMarginItem(SvxIndentValue stLeft, const sal_uInt16 nId) : SfxPoolItem(nId, SfxItemType::SvxTextLeftMarginItemType) - , m_nTextLeftMargin(nLeft) { + SetTextLeft(stLeft); } bool SvxTextLeftMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const { - bool bRet = true; + bool bRet = false; bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); nMemberId &= ~CONVERT_TWIPS; switch (nMemberId) @@ -847,17 +1069,25 @@ bool SvxTextLeftMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) cons case 0: { css::frame::status::LeftRightMarginScale aLRSpace; - aLRSpace.TextLeft = static_cast(bConvert ? convertTwipToMm100(GetTextLeft()) : GetTextLeft()); + + auto nLeftTwips = m_stTextLeftMargin.Resolve({}); + aLRSpace.TextLeft + = static_cast(bConvert ? convertTwipToMm100(nLeftTwips) : nLeftTwips); aLRSpace.ScaleLeft = static_cast(m_nPropLeftMargin); rVal <<= aLRSpace; + bRet = true; break; } case MID_TXT_LMARGIN : - rVal <<= static_cast(bConvert ? convertTwipToMm100(GetTextLeft()) : GetTextLeft()); - break; + bRet = lcl_FillAbsoluteMeasureAny(m_stTextLeftMargin, rVal, bConvert); + break; case MID_L_REL_MARGIN: rVal <<= static_cast(m_nPropLeftMargin); - break; + bRet = true; + break; + case MID_L_UNIT_MARGIN: + bRet = lcl_FillRelativeMeasureAny(m_stTextLeftMargin, rVal); + break; default: assert(false); bRet = false; @@ -882,9 +1112,10 @@ bool SvxTextLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) { return false; } - SetTextLeft(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); + SetTextLeft( + SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal)); + break; } - break; case MID_L_REL_MARGIN: { sal_Int32 nRel = 0; @@ -896,8 +1127,19 @@ bool SvxTextLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) { return false; } + break; + } + case MID_L_UNIT_MARGIN: + { + css::beans::Pair stVal; + if (!(rVal >>= stVal)) + { + return false; + } + + SetTextLeft(SvxIndentValue{ stVal.First, stVal.Second }); + break; } - break; default: assert(false); OSL_FAIL("unknown MemberId"); @@ -912,14 +1154,14 @@ bool SvxTextLeftMarginItem::operator==(const SfxPoolItem& rAttr) const const SvxTextLeftMarginItem& rOther = static_cast(rAttr); - return (m_nTextLeftMargin == rOther.GetTextLeft() - && m_nPropLeftMargin == rOther.GetPropLeft()); + return std::tie(m_stTextLeftMargin, m_nPropLeftMargin) + == std::tie(rOther.m_stTextLeftMargin, rOther.m_nPropLeftMargin); } size_t SvxTextLeftMarginItem::hashCode() const { std::size_t seed(0); - o3tl::hash_combine(seed, m_nTextLeftMargin); + o3tl::hash_combine(seed, m_stTextLeftMargin.hashCode()); o3tl::hash_combine(seed, m_nPropLeftMargin); return seed; } @@ -947,10 +1189,16 @@ bool SvxTextLeftMarginItem::GetPresentation rText = unicode::formatPercent(m_nPropLeftMargin, Application::GetSettings().GetUILanguageTag()); } + else if (m_stTextLeftMargin.m_nUnit != css::util::MeasureUnit::TWIP) + { + OUStringBuffer stBuf; + sax::Converter::convertMeasureUnit(stBuf, m_stTextLeftMargin.m_dValue, + m_stTextLeftMargin.m_nUnit); + rText += stBuf.makeStringAndClear(); + } else { - rText = GetMetricText(m_nTextLeftMargin, - eCoreUnit, ePresUnit, &rIntl); + rText = GetMetricText(m_stTextLeftMargin.m_dValue, eCoreUnit, ePresUnit, &rIntl); } return true; } @@ -962,9 +1210,16 @@ bool SvxTextLeftMarginItem::GetPresentation rText += unicode::formatPercent(m_nPropLeftMargin, Application::GetSettings().GetUILanguageTag()); } + else if (m_stTextLeftMargin.m_nUnit != css::util::MeasureUnit::TWIP) + { + OUStringBuffer stBuf; + sax::Converter::convertMeasureUnit(stBuf, m_stTextLeftMargin.m_dValue, + m_stTextLeftMargin.m_nUnit); + rText += stBuf.makeStringAndClear(); + } else { - rText += GetMetricText(m_nTextLeftMargin, eCoreUnit, ePresUnit, &rIntl) + rText += GetMetricText(m_stTextLeftMargin.m_dValue, eCoreUnit, ePresUnit, &rIntl) + " " + EditResId(GetMetricId(ePresUnit)); } return true; @@ -977,7 +1232,7 @@ bool SvxTextLeftMarginItem::GetPresentation void SvxTextLeftMarginItem::ScaleMetrics(tools::Long const nMult, tools::Long const nDiv) { ASSERT_CHANGE_REFCOUNTED_ITEM; - m_nTextLeftMargin = BigInt::Scale(m_nTextLeftMargin, nMult, nDiv); + m_stTextLeftMargin.ScaleMetrics(nMult, nDiv); } bool SvxTextLeftMarginItem::HasMetrics() const @@ -989,7 +1244,12 @@ void SvxTextLeftMarginItem::dumpAsXml(xmlTextWriterPtr pWriter) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxTextLeftMarginItem")); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nTextLeftMargin"), BAD_CAST(OString::number(m_nTextLeftMargin).getStr())); + (void)xmlTextWriterWriteAttribute( + pWriter, BAD_CAST("m_dTextLeftMargin"), + BAD_CAST(OString::number(m_stTextLeftMargin.m_dValue).getStr())); + (void)xmlTextWriterWriteAttribute( + pWriter, BAD_CAST("m_nUnit"), + BAD_CAST(OString::number(m_stTextLeftMargin.m_nUnit).getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nPropLeftMargin"), BAD_CAST(OString::number(m_nPropLeftMargin).getStr())); (void)xmlTextWriterEndElement(pWriter); } @@ -998,16 +1258,7 @@ boost::property_tree::ptree SvxTextLeftMarginItem::dumpAsJSON() const { boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); - boost::property_tree::ptree aState; - - MapUnit eTargetUnit = MapUnit::MapInch; - - OUString sLeft = GetMetricText(GetTextLeft(), - MapUnit::MapTwip, eTargetUnit, nullptr); - - aState.put("left", sLeft); - aState.put("unit", "inch"); - + auto aState = lcl_IndentValueToJson("left", m_stTextLeftMargin); aTree.push_back(std::make_pair("state", aState)); return aTree; @@ -1046,51 +1297,24 @@ sal_uInt16 SvxFirstLineIndentItem::GetPropTextFirstLineOffset() const void SvxFirstLineIndentItem::SetTextFirstLineOffset(SvxIndentValue stValue, sal_uInt16 nProp) { ASSERT_CHANGE_REFCOUNTED_ITEM; - m_dFirstLineOffset = stValue.m_dValue; - m_nUnit = stValue.m_nUnit; + m_stFirstLineOffset = stValue; m_nPropFirstLineOffset = nProp; if (nProp != 100) { - m_dFirstLineOffset = (stValue.m_dValue * static_cast(nProp)) / 100.0; + m_stFirstLineOffset.m_dValue = (stValue.m_dValue * static_cast(nProp)) / 100.0; } } SvxIndentValue SvxFirstLineIndentItem::GetTextFirstLineOffset() const { - return { m_dFirstLineOffset, m_nUnit }; -} - -double SvxFirstLineIndentItem::GetTextFirstLineOffsetValue() const { return m_dFirstLineOffset; } - -sal_Int16 SvxFirstLineIndentItem::GetTextFirstLineOffsetUnit() const { return m_nUnit; } - -double -SvxFirstLineIndentItem::ResolveTextFirstLineOffsetDouble(const SvxFontUnitMetrics& rMetrics) const -{ - if(m_nUnit == css::util::MeasureUnit::TWIP) - return m_dFirstLineOffset; - - SAL_WARN_IF(!rMetrics.m_bInitialized, "editeng", "font-relative indentation lost"); - - switch (m_nUnit) - { - case css::util::MeasureUnit::FONT_EM: - return m_dFirstLineOffset * rMetrics.m_dEmTwips; - - case css::util::MeasureUnit::FONT_CJK_ADVANCE: - return m_dFirstLineOffset * rMetrics.m_dIcTwips; - - default: - SAL_WARN("editeng", "unhandled type conversion"); - return 0.0; - } + return m_stFirstLineOffset; } sal_Int32 SvxFirstLineIndentItem::ResolveTextFirstLineOffset(const SvxFontUnitMetrics& rMetrics) const { - return static_cast(std::llround(ResolveTextFirstLineOffsetDouble(rMetrics))); + return m_stFirstLineOffset.Resolve(rMetrics); } bool SvxFirstLineIndentItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const @@ -1101,16 +1325,8 @@ bool SvxFirstLineIndentItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) con switch (nMemberId) { case MID_FIRST_LINE_INDENT: - // MID_FIRST_LINE_INDENT only supports statically-convertible measures. - // In practice, these are always stored here in twips. - if (m_nUnit == css::util::MeasureUnit::TWIP) - { - auto nConvOffset - = (bConvert ? convertTwipToMm100(m_dFirstLineOffset) : m_dFirstLineOffset); - rVal <<= static_cast(std::llround(nConvOffset)); - bRet = true; - } - break; + bRet = lcl_FillAbsoluteMeasureAny(m_stFirstLineOffset, rVal, bConvert); + break; case MID_FIRST_LINE_REL_INDENT: rVal <<= static_cast(m_nPropFirstLineOffset); @@ -1118,15 +1334,8 @@ bool SvxFirstLineIndentItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) con break; case MID_FIRST_LINE_UNIT_INDENT: - // MID_FIRST_LINE_UNIT_INDENT is used for any values that must be serialized - // as a unit-value pair. In practice, this will be limited to font-relative - // units (e.g. em, ic), and all other units will be pre-converted to twips. - if (m_nUnit != css::util::MeasureUnit::TWIP) - { - rVal <<= css::beans::Pair{ m_dFirstLineOffset, m_nUnit }; - bRet = true; - } - break; + bRet = lcl_FillRelativeMeasureAny(m_stFirstLineOffset, rVal); + break; case MID_FIRST_AUTO: rVal <<= IsAutoFirst(); @@ -1158,8 +1367,8 @@ bool SvxFirstLineIndentItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) return false; } - m_dFirstLineOffset = bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal; - m_nUnit = css::util::MeasureUnit::TWIP; + m_stFirstLineOffset + = SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); m_nPropFirstLineOffset = 100; break; } @@ -1204,16 +1413,15 @@ bool SvxFirstLineIndentItem::operator==(const SfxPoolItem& rAttr) const const SvxFirstLineIndentItem& rOther = static_cast(rAttr); - return std::tie(m_dFirstLineOffset, m_nUnit, m_nPropFirstLineOffset, m_bAutoFirst) - == std::tie(rOther.m_dFirstLineOffset, rOther.m_nUnit, rOther.m_nPropFirstLineOffset, + return std::tie(m_stFirstLineOffset, m_nPropFirstLineOffset, m_bAutoFirst) + == std::tie(rOther.m_stFirstLineOffset, rOther.m_nPropFirstLineOffset, rOther.m_bAutoFirst); } size_t SvxFirstLineIndentItem::hashCode() const { std::size_t seed(0); - o3tl::hash_combine(seed, m_dFirstLineOffset); - o3tl::hash_combine(seed, m_nUnit); + o3tl::hash_combine(seed, m_stFirstLineOffset.hashCode()); o3tl::hash_combine(seed, m_nPropFirstLineOffset); o3tl::hash_combine(seed, m_bAutoFirst); return seed; @@ -1241,15 +1449,16 @@ bool SvxFirstLineIndentItem::GetPresentation rText += unicode::formatPercent(m_nPropFirstLineOffset, Application::GetSettings().GetUILanguageTag()); } - else if (m_nUnit != css::util::MeasureUnit::TWIP) + else if (m_stFirstLineOffset.m_nUnit != css::util::MeasureUnit::TWIP) { OUStringBuffer stBuf; - sax::Converter::convertMeasureUnit(stBuf, m_dFirstLineOffset, m_nUnit); + sax::Converter::convertMeasureUnit(stBuf, m_stFirstLineOffset.m_dValue, + m_stFirstLineOffset.m_nUnit); rText += stBuf.makeStringAndClear(); } else { - rText += GetMetricText(m_dFirstLineOffset, eCoreUnit, ePresUnit, &rIntl); + rText += GetMetricText(m_stFirstLineOffset.m_dValue, eCoreUnit, ePresUnit, &rIntl); } return true; } @@ -1261,16 +1470,17 @@ bool SvxFirstLineIndentItem::GetPresentation rText += unicode::formatPercent(m_nPropFirstLineOffset, Application::GetSettings().GetUILanguageTag()); } - else if (m_nUnit != css::util::MeasureUnit::TWIP) + else if (m_stFirstLineOffset.m_nUnit != css::util::MeasureUnit::TWIP) { OUStringBuffer stBuf; - sax::Converter::convertMeasureUnit(stBuf, m_dFirstLineOffset, m_nUnit); + sax::Converter::convertMeasureUnit(stBuf, m_stFirstLineOffset.m_dValue, + m_stFirstLineOffset.m_nUnit); rText += stBuf.makeStringAndClear(); } else { - rText += GetMetricText(m_dFirstLineOffset, eCoreUnit, ePresUnit, &rIntl) + " " - + EditResId(GetMetricId(ePresUnit)); + rText += GetMetricText(m_stFirstLineOffset.m_dValue, eCoreUnit, ePresUnit, &rIntl) + + " " + EditResId(GetMetricId(ePresUnit)); } return true; } @@ -1282,8 +1492,7 @@ bool SvxFirstLineIndentItem::GetPresentation void SvxFirstLineIndentItem::ScaleMetrics(tools::Long const nMult, tools::Long const nDiv) { ASSERT_CHANGE_REFCOUNTED_ITEM; - m_dFirstLineOffset - = (m_dFirstLineOffset * static_cast(nMult)) / static_cast(nDiv); + m_stFirstLineOffset.ScaleMetrics(nMult, nDiv); } bool SvxFirstLineIndentItem::HasMetrics() const @@ -1295,9 +1504,12 @@ void SvxFirstLineIndentItem::dumpAsXml(xmlTextWriterPtr pWriter) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxFirstLineIndentItem")); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_dFirstLineOffset"), - BAD_CAST(OString::number(m_dFirstLineOffset).getStr())); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nUnit"), BAD_CAST(OString::number(m_nUnit).getStr())); + (void)xmlTextWriterWriteAttribute( + pWriter, BAD_CAST("m_dFirstLineOffset"), + BAD_CAST(OString::number(m_stFirstLineOffset.m_dValue).getStr())); + (void)xmlTextWriterWriteAttribute( + pWriter, BAD_CAST("m_nUnit"), + BAD_CAST(OString::number(m_stFirstLineOffset.m_nUnit).getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nPropFirstLineOffset"), BAD_CAST(OString::number(m_nPropFirstLineOffset).getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_bAutoFirst"), BAD_CAST(OString::number(int(m_bAutoFirst)).getStr())); (void)xmlTextWriterEndElement(pWriter); @@ -1307,36 +1519,7 @@ boost::property_tree::ptree SvxFirstLineIndentItem::dumpAsJSON() const { boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); - boost::property_tree::ptree aState; - - switch (m_nUnit) - { - case css::util::MeasureUnit::TWIP: - { - MapUnit eTargetUnit = MapUnit::MapInch; - - OUString sFirstline - = GetMetricText(m_dFirstLineOffset, MapUnit::MapTwip, eTargetUnit, nullptr); - - aState.put("firstline", sFirstline); - aState.put("unit", "inch"); - } - break; - - case css::util::MeasureUnit::FONT_EM: - aState.put("firstline", m_dFirstLineOffset); - aState.put("unit", "em"); - break; - - case css::util::MeasureUnit::FONT_CJK_ADVANCE: - aState.put("firstline", m_dFirstLineOffset); - aState.put("unit", "ic"); - break; - - default: - SAL_WARN("editeng", "unhandled type conversion"); - break; - } + auto aState = lcl_IndentValueToJson("firstline", m_stFirstLineOffset); aTree.push_back(std::make_pair("state", aState)); @@ -1348,15 +1531,15 @@ SvxRightMarginItem::SvxRightMarginItem(const sal_uInt16 nId) { } -SvxRightMarginItem::SvxRightMarginItem(const tools::Long nRight, const sal_uInt16 nId) +SvxRightMarginItem::SvxRightMarginItem(SvxIndentValue stRight, const sal_uInt16 nId) : SfxPoolItem(nId, SfxItemType::SvxRightMarginItemType) - , m_nRightMargin(nRight) { + SetRight(stRight); } bool SvxRightMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const { - bool bRet = true; + bool bRet = false; bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); nMemberId &= ~CONVERT_TWIPS; switch (nMemberId) @@ -1365,17 +1548,25 @@ bool SvxRightMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const case 0: { css::frame::status::LeftRightMarginScale aLRSpace; - aLRSpace.Right = static_cast(bConvert ? convertTwipToMm100(m_nRightMargin) : m_nRightMargin); + + auto nRightTwips = ResolveRight({}); + aLRSpace.Right + = static_cast(bConvert ? convertTwipToMm100(nRightTwips) : nRightTwips); aLRSpace.ScaleRight = static_cast(m_nPropRightMargin); rVal <<= aLRSpace; + bRet = true; break; } case MID_R_MARGIN: - rVal <<= static_cast(bConvert ? convertTwipToMm100(m_nRightMargin) : m_nRightMargin); + bRet = lcl_FillAbsoluteMeasureAny(m_stRightMargin, rVal, bConvert); break; case MID_R_REL_MARGIN: rVal <<= static_cast(m_nPropRightMargin); - break; + bRet = true; + break; + case MID_R_UNIT_MARGIN: + bRet = lcl_FillRelativeMeasureAny(m_stRightMargin, rVal); + break; default: assert(false); bRet = false; @@ -1400,7 +1591,8 @@ bool SvxRightMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) { return false; } - SetRight(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); + SetRight( + SvxIndentValue::twips(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal)); break; } case MID_R_REL_MARGIN: @@ -1414,8 +1606,19 @@ bool SvxRightMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) { return false; } + break; + } + case MID_R_UNIT_MARGIN: + { + css::beans::Pair stVal; + if (!(rVal >>= stVal)) + { + return false; + } + + SetRight(SvxIndentValue{ stVal.First, stVal.Second }); + break; } - break; default: assert(false); OSL_FAIL("unknown MemberId"); @@ -1430,14 +1633,14 @@ bool SvxRightMarginItem::operator==(const SfxPoolItem& rAttr) const const SvxRightMarginItem& rOther = static_cast(rAttr); - return (m_nRightMargin == rOther.GetRight() - && m_nPropRightMargin == rOther.GetPropRight()); + return std::tie(m_stRightMargin, m_nPropRightMargin) + == std::tie(rOther.m_stRightMargin, rOther.m_nPropRightMargin); } size_t SvxRightMarginItem::hashCode() const { std::size_t seed(0); - o3tl::hash_combine(seed, m_nRightMargin); + o3tl::hash_combine(seed, m_stRightMargin.hashCode()); o3tl::hash_combine(seed, m_nPropRightMargin); return seed; } @@ -1459,15 +1662,21 @@ bool SvxRightMarginItem::GetPresentation { case SfxItemPresentation::Nameless: { - if (100 != m_nRightMargin) + if (100 != m_nPropRightMargin) { - rText += unicode::formatPercent(m_nRightMargin, - Application::GetSettings().GetUILanguageTag()); + rText += unicode::formatPercent(m_nPropRightMargin, + Application::GetSettings().GetUILanguageTag()); + } + else if (m_stRightMargin.m_nUnit != css::util::MeasureUnit::TWIP) + { + OUStringBuffer stBuf; + sax::Converter::convertMeasureUnit(stBuf, m_stRightMargin.m_dValue, + m_stRightMargin.m_nUnit); + rText += stBuf.makeStringAndClear(); } else { - rText += GetMetricText(m_nRightMargin, - eCoreUnit, ePresUnit, &rIntl); + rText += GetMetricText(m_stRightMargin.m_dValue, eCoreUnit, ePresUnit, &rIntl); } return true; } @@ -1479,11 +1688,17 @@ bool SvxRightMarginItem::GetPresentation rText += unicode::formatPercent(m_nPropRightMargin, Application::GetSettings().GetUILanguageTag()); } + else if (m_stRightMargin.m_nUnit != css::util::MeasureUnit::TWIP) + { + OUStringBuffer stBuf; + sax::Converter::convertMeasureUnit(stBuf, m_stRightMargin.m_dValue, + m_stRightMargin.m_nUnit); + rText += stBuf.makeStringAndClear(); + } else { - rText += GetMetricText(m_nRightMargin, - eCoreUnit, ePresUnit, &rIntl) - + " " + EditResId(GetMetricId(ePresUnit)); + rText += GetMetricText(m_stRightMargin.m_dValue, eCoreUnit, ePresUnit, &rIntl) + " " + + EditResId(GetMetricId(ePresUnit)); } return true; } @@ -1495,7 +1710,7 @@ bool SvxRightMarginItem::GetPresentation void SvxRightMarginItem::ScaleMetrics(tools::Long const nMult, tools::Long const nDiv) { ASSERT_CHANGE_REFCOUNTED_ITEM; - m_nRightMargin = BigInt::Scale(m_nRightMargin, nMult, nDiv); + m_stRightMargin.ScaleMetrics(nMult, nDiv); } bool SvxRightMarginItem::HasMetrics() const @@ -1507,7 +1722,10 @@ void SvxRightMarginItem::dumpAsXml(xmlTextWriterPtr pWriter) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxRightMarginItem")); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nRightMargin"), BAD_CAST(OString::number(m_nRightMargin).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_dRightMargin"), + BAD_CAST(OString::number(m_stRightMargin.m_dValue).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nUnit"), + BAD_CAST(OString::number(m_stRightMargin.m_nUnit).getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nPropRightMargin"), BAD_CAST(OString::number(m_nPropRightMargin).getStr())); (void)xmlTextWriterEndElement(pWriter); } @@ -1516,16 +1734,7 @@ boost::property_tree::ptree SvxRightMarginItem::dumpAsJSON() const { boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); - boost::property_tree::ptree aState; - - MapUnit eTargetUnit = MapUnit::MapInch; - - OUString sRight = GetMetricText(GetRight(), - MapUnit::MapTwip, eTargetUnit, nullptr); - - aState.put("right", sRight); - aState.put("unit", "inch"); - + auto aState = lcl_IndentValueToJson("right", m_stRightMargin); aTree.push_back(std::make_pair("state", aState)); return aTree; @@ -1753,12 +1962,11 @@ bool SvxLRSpaceItem::operator==( const SfxPoolItem& rAttr ) const const SvxLRSpaceItem& rOther = static_cast(rAttr); - return std::tie(m_dFirstLineOffset, m_nFirstLineUnit, m_nGutterMargin, m_nRightGutterMargin, - nLeftMargin, nRightMargin, nPropFirstLineOffset, nPropLeftMargin, - nPropRightMargin, bAutoFirst, bExplicitZeroMarginValRight, - bExplicitZeroMarginValLeft) - == std::tie(rOther.m_dFirstLineOffset, rOther.m_nFirstLineUnit, rOther.m_nGutterMargin, - rOther.m_nRightGutterMargin, rOther.nLeftMargin, rOther.nRightMargin, + return std::tie(m_stFirstLineOffset, m_nGutterMargin, m_nRightGutterMargin, m_stLeftMargin, + m_stRightMargin, nPropFirstLineOffset, nPropLeftMargin, nPropRightMargin, + bAutoFirst, bExplicitZeroMarginValRight, bExplicitZeroMarginValLeft) + == std::tie(rOther.m_stFirstLineOffset, rOther.m_nGutterMargin, + rOther.m_nRightGutterMargin, rOther.m_stLeftMargin, rOther.m_stRightMargin, rOther.nPropFirstLineOffset, rOther.nPropLeftMargin, rOther.nPropRightMargin, rOther.bAutoFirst, rOther.bExplicitZeroMarginValRight, rOther.bExplicitZeroMarginValLeft); @@ -1786,33 +1994,48 @@ bool SvxLRSpaceItem::GetPresentation rText = unicode::formatPercent(nPropLeftMargin, Application::GetSettings().GetUILanguageTag()); } + else if (m_stLeftMargin.m_nUnit != css::util::MeasureUnit::TWIP) + { + OUStringBuffer stBuf; + sax::Converter::convertMeasureUnit(stBuf, m_stLeftMargin.m_dValue, + m_stLeftMargin.m_nUnit); + rText += stBuf.makeStringAndClear(); + } else - rText = GetMetricText( nLeftMargin, - eCoreUnit, ePresUnit, &rIntl ); + rText = GetMetricText(static_cast(m_stLeftMargin.m_dValue), eCoreUnit, + ePresUnit, &rIntl); rText += cpDelim; if ( 100 != nPropFirstLineOffset ) { rText += unicode::formatPercent(nPropFirstLineOffset, Application::GetSettings().GetUILanguageTag()); } - else if (m_nFirstLineUnit != css::util::MeasureUnit::TWIP) + else if (m_stFirstLineOffset.m_nUnit != css::util::MeasureUnit::TWIP) { OUStringBuffer stBuf; - sax::Converter::convertMeasureUnit(stBuf, m_dFirstLineOffset, m_nFirstLineUnit); + sax::Converter::convertMeasureUnit(stBuf, m_stFirstLineOffset.m_dValue, + m_stFirstLineOffset.m_nUnit); rText += stBuf.makeStringAndClear(); } else - rText += GetMetricText(static_cast(m_dFirstLineOffset), eCoreUnit, - ePresUnit, &rIntl); + rText += GetMetricText(static_cast(m_stFirstLineOffset.m_dValue), + eCoreUnit, ePresUnit, &rIntl); rText += cpDelim; - if ( 100 != nRightMargin ) + if (100 != nPropRightMargin) { - rText += unicode::formatPercent(nRightMargin, - Application::GetSettings().GetUILanguageTag()); + rText += unicode::formatPercent(nPropRightMargin, + Application::GetSettings().GetUILanguageTag()); + } + else if (m_stRightMargin.m_nUnit != css::util::MeasureUnit::TWIP) + { + OUStringBuffer stBuf; + sax::Converter::convertMeasureUnit(stBuf, m_stRightMargin.m_dValue, + m_stRightMargin.m_nUnit); + rText += stBuf.makeStringAndClear(); } else - rText += GetMetricText( nRightMargin, - eCoreUnit, ePresUnit, &rIntl ); + rText += GetMetricText(static_cast(m_stRightMargin.m_dValue), + eCoreUnit, ePresUnit, &rIntl); return true; } case SfxItemPresentation::Complete: @@ -1821,41 +2044,59 @@ bool SvxLRSpaceItem::GetPresentation if ( 100 != nPropLeftMargin ) rText += unicode::formatPercent(nPropLeftMargin, Application::GetSettings().GetUILanguageTag()); + else if (m_stLeftMargin.m_nUnit != css::util::MeasureUnit::TWIP) + { + OUStringBuffer stBuf; + sax::Converter::convertMeasureUnit(stBuf, m_stLeftMargin.m_dValue, + m_stLeftMargin.m_nUnit); + rText += stBuf.makeStringAndClear(); + } else { - rText += GetMetricText( nLeftMargin, eCoreUnit, ePresUnit, &rIntl ) + - " " + EditResId(GetMetricId(ePresUnit)); + rText += GetMetricText(static_cast(m_stLeftMargin.m_dValue), eCoreUnit, + ePresUnit, &rIntl) + + " " + EditResId(GetMetricId(ePresUnit)); } rText += cpDelim; - if (100 != nPropFirstLineOffset || m_dFirstLineOffset != 0.0) + if (100 != nPropFirstLineOffset || m_stFirstLineOffset.m_dValue != 0.0) { rText += EditResId(RID_SVXITEMS_LRSPACE_FLINE); if ( 100 != nPropFirstLineOffset ) rText += unicode::formatPercent(nPropFirstLineOffset, Application::GetSettings().GetUILanguageTag()); - else if (m_nFirstLineUnit != css::util::MeasureUnit::TWIP) + else if (m_stFirstLineOffset.m_nUnit != css::util::MeasureUnit::TWIP) { OUStringBuffer stBuf; - sax::Converter::convertMeasureUnit(stBuf, m_dFirstLineOffset, m_nFirstLineUnit); + sax::Converter::convertMeasureUnit(stBuf, m_stFirstLineOffset.m_dValue, + m_stFirstLineOffset.m_nUnit); rText += stBuf.makeStringAndClear(); } else { - rText += GetMetricText(static_cast(m_dFirstLineOffset), eCoreUnit, - ePresUnit, &rIntl) + rText += GetMetricText(static_cast(m_stFirstLineOffset.m_dValue), + eCoreUnit, ePresUnit, &rIntl) + " " + EditResId(GetMetricId(ePresUnit)); } rText += cpDelim; } rText += EditResId(RID_SVXITEMS_LRSPACE_RIGHT); - if ( 100 != nPropRightMargin ) + if (100 != nPropRightMargin) + { rText += unicode::formatPercent(nPropRightMargin, - Application::GetSettings().GetUILanguageTag()); + Application::GetSettings().GetUILanguageTag()); + } + else if (m_stRightMargin.m_nUnit != css::util::MeasureUnit::TWIP) + { + OUStringBuffer stBuf; + sax::Converter::convertMeasureUnit(stBuf, m_stRightMargin.m_dValue, + m_stRightMargin.m_nUnit); + rText += stBuf.makeStringAndClear(); + } else { - rText += GetMetricText( nRightMargin, - eCoreUnit, ePresUnit, &rIntl ) + - " " + EditResId(GetMetricId(ePresUnit)); + rText += GetMetricText(static_cast(m_stRightMargin.m_dValue), + eCoreUnit, ePresUnit, &rIntl) + + " " + EditResId(GetMetricId(ePresUnit)); } return true; } @@ -1867,10 +2108,9 @@ bool SvxLRSpaceItem::GetPresentation void SvxLRSpaceItem::ScaleMetrics( tools::Long nMult, tools::Long nDiv ) { - m_dFirstLineOffset - = (m_dFirstLineOffset * static_cast(nMult)) / static_cast(nDiv); - nLeftMargin = BigInt::Scale( nLeftMargin, nMult, nDiv ); - nRightMargin = BigInt::Scale( nRightMargin, nMult, nDiv ); + m_stFirstLineOffset.ScaleMetrics(nMult, nDiv); + m_stLeftMargin.ScaleMetrics(nMult, nDiv); + m_stRightMargin.ScaleMetrics(nMult, nDiv); } @@ -1884,12 +2124,20 @@ void SvxLRSpaceItem::dumpAsXml(xmlTextWriterPtr pWriter) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxLRSpaceItem")); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_dFirstLineOffset"), - BAD_CAST(OString::number(m_dFirstLineOffset).getStr())); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nFirstLineUnit"), - BAD_CAST(OString::number(m_nFirstLineUnit).getStr())); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nLeftMargin"), BAD_CAST(OString::number(nLeftMargin).getStr())); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nRightMargin"), BAD_CAST(OString::number(nRightMargin).getStr())); + (void)xmlTextWriterWriteAttribute( + pWriter, BAD_CAST("m_dFirstLineOffset"), + BAD_CAST(OString::number(m_stFirstLineOffset.m_dValue).getStr())); + (void)xmlTextWriterWriteAttribute( + pWriter, BAD_CAST("m_nFirstLineUnit"), + BAD_CAST(OString::number(m_stFirstLineOffset.m_nUnit).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_dLeftMargin"), + BAD_CAST(OString::number(m_stLeftMargin.m_dValue).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nLeftMarginUnit"), + BAD_CAST(OString::number(m_stLeftMargin.m_nUnit).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_dRightMargin"), + BAD_CAST(OString::number(m_stRightMargin.m_dValue).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nRightMarginUnit"), + BAD_CAST(OString::number(m_stRightMargin.m_nUnit).getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nGutterMargin"), BAD_CAST(OString::number(m_nGutterMargin).getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nRightGutterMargin"), @@ -1912,11 +2160,9 @@ boost::property_tree::ptree SvxLRSpaceItem::dumpAsJSON() const MapUnit eTargetUnit = MapUnit::MapInch; - OUString sLeft = GetMetricText(GetLeft(), - MapUnit::MapTwip, eTargetUnit, nullptr); + OUString sLeft = GetMetricText(ResolveLeft({}), MapUnit::MapTwip, eTargetUnit, nullptr); - OUString sRight = GetMetricText(GetRight(), - MapUnit::MapTwip, eTargetUnit, nullptr); + OUString sRight = GetMetricText(ResolveRight({}), MapUnit::MapTwip, eTargetUnit, nullptr); OUString sFirstline = GetMetricText(ResolveTextFirstLineOffset({}), MapUnit::MapTwip, eTargetUnit, nullptr); diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index e23ee74ff09f..4ff4c5a46751 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -1492,7 +1492,7 @@ tools::Rectangle Outliner::ImpCalcBulletArea( sal_Int32 nPara, bool bAdjust, boo const auto nSpaceBefore = pFmt->GetAbsLSpace() + pFmt->GetFirstLineOffset(); const SvxLRSpaceItem& rLR = pEditEngine->GetParaAttrib( nPara, bOutlineMode ? EE_PARA_OUTLLRSPACE : EE_PARA_LRSPACE ); - aTopLeft.setX(rLR.GetTextLeft() + rLR.ResolveTextFirstLineOffset({}) + nSpaceBefore); + aTopLeft.setX(rLR.ResolveTextLeft({}) + rLR.ResolveTextFirstLineOffset({}) + nSpaceBefore); tools::Long nBulletWidth = std::max( static_cast(-rLR.ResolveTextFirstLineOffset({})), diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx index 129e43ebc33c..17aafa8a558e 100644 --- a/editeng/source/rtf/rtfitem.cxx +++ b/editeng/source/rtf/rtfitem.cxx @@ -342,7 +342,7 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) CalcValue(); nSz = sal_uInt16(nTokenValue); } - aLR.SetTextLeft( nSz ); + aLR.SetTextLeft(SvxIndentValue::twips(nSz)); pSet->Put( aLR ); } break; @@ -359,7 +359,7 @@ void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet ) CalcValue(); nSz = sal_uInt16(nTokenValue); } - aLR.SetRight( nSz ); + aLR.SetRight(SvxIndentValue::twips(nSz)); pSet->Put( aLR ); } break; diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index d4bcc197d2e2..8ec7567edb37 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -6187,7 +6187,7 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, std::optional< sal_Int16 >& rS auto const nAbsLSpace = convertMasterUnitToMm100(_nTextOfs); auto const nFirstLineOffset = nAbsLSpace - convertMasterUnitToMm100(_nBulletOfs); aLRSpaceItem.SetTextFirstLineOffset(SvxIndentValue::twips(-nFirstLineOffset)); - aLRSpaceItem.SetTextLeft( nAbsLSpace ); + aLRSpaceItem.SetTextLeft(SvxIndentValue::twips(nAbsLSpace)); } rSet.Put( aLRSpaceItem ); diff --git a/include/editeng/lrspitem.hxx b/include/editeng/lrspitem.hxx index c47f9a8f29cf..f5b4d1054056 100644 --- a/include/editeng/lrspitem.hxx +++ b/include/editeng/lrspitem.hxx @@ -79,6 +79,16 @@ struct SvxIndentValue static SvxIndentValue twips(double dValue) { return { dValue, css::util::MeasureUnit::TWIP }; } static SvxIndentValue zero() { return twips(0.0); } + + double ResolveDouble(const SvxFontUnitMetrics& rMetrics) const; + sal_Int32 Resolve(const SvxFontUnitMetrics& rMetrics) const; + sal_Int32 ResolveFixedPart() const; + sal_Int32 ResolveVariablePart(const SvxFontUnitMetrics& rMetrics) const; + + void ScaleMetrics(tools::Long nMult, tools::Long nDiv); + + size_t hashCode() const; + bool operator==(SvxIndentValue const&) const = default; }; /// GetLeft() - for everything that's not applied to a paragraph @@ -127,22 +137,24 @@ class EDITENG_DLLPUBLIC SvxTextLeftMarginItem final : public SfxPoolItem private: friend class SvxFirstLineIndentItem; /// left margin including negative first-line indent - tools::Long m_nTextLeftMargin = 0; + SvxIndentValue m_stTextLeftMargin = SvxIndentValue::zero(); sal_uInt16 m_nPropLeftMargin = 100; public: - //TODO: need this? - //void SetLeft(SvxFirstLineIndentItem const& rFirstLine, const tools::Long nL, const sal_uInt16 nProp = 100); /// get left margin without negative first-line indent - tools::Long GetLeft(const SvxFirstLineIndentItem& rFirstLine, - const SvxFontUnitMetrics& rMetrics) const; - sal_uInt16 GetPropLeft() const { return m_nPropLeftMargin; } + sal_Int32 ResolveLeft(const SvxFirstLineIndentItem& rFirstLine, + const SvxFontUnitMetrics& rMetrics) const; + sal_Int32 ResolveLeftFixedPart(const SvxFirstLineIndentItem& rFirstLine) const; + sal_Int32 ResolveLeftVariablePart(const SvxFirstLineIndentItem& rFirstLine, + const SvxFontUnitMetrics& rMetrics) const; + sal_uInt16 GetPropLeft() const; - void SetTextLeft(const tools::Long nL, const sal_uInt16 nProp = 100); - tools::Long GetTextLeft() const; + void SetTextLeft(SvxIndentValue stL, const sal_uInt16 nProp = 100); + sal_Int32 ResolveTextLeft(const SvxFontUnitMetrics& rMetrics) const; + SvxIndentValue GetTextLeft() const; explicit SvxTextLeftMarginItem(const sal_uInt16 nId); - SvxTextLeftMarginItem(const tools::Long nLeft, const sal_uInt16 nId); + SvxTextLeftMarginItem(SvxIndentValue stLeft, const sal_uInt16 nId); SvxTextLeftMarginItem(SvxTextLeftMarginItem const &) = default; // SfxPoolItem copy function dichotomy // "pure virtual Methods" from SfxPoolItem @@ -171,8 +183,7 @@ class EDITENG_DLLPUBLIC SvxFirstLineIndentItem final : public SfxPoolItem { private: /// First-line indent always relative to GetTextLeft() - double m_dFirstLineOffset = 0.0; - sal_Int16 m_nUnit = css::util::MeasureUnit::TWIP; + SvxIndentValue m_stFirstLineOffset = SvxIndentValue::zero(); sal_uInt16 m_nPropFirstLineOffset = 100; /// Automatic calculation of the first line indent bool m_bAutoFirst = false; @@ -186,9 +197,6 @@ public: void SetTextFirstLineOffset(SvxIndentValue stValue, sal_uInt16 nProp = 100); SvxIndentValue GetTextFirstLineOffset() const; - double GetTextFirstLineOffsetValue() const; - sal_Int16 GetTextFirstLineOffsetUnit() const; - double ResolveTextFirstLineOffsetDouble(const SvxFontUnitMetrics& rMetrics) const; sal_Int32 ResolveTextFirstLineOffset(const SvxFontUnitMetrics& rMetrics) const; explicit SvxFirstLineIndentItem(const sal_uInt16 nId); @@ -220,20 +228,23 @@ class EDITENG_DLLPUBLIC SvxRightMarginItem final : public SfxPoolItem { private: /// right margin: nothing special - tools::Long m_nRightMargin = 0; + SvxIndentValue m_stRightMargin = SvxIndentValue::zero(); sal_uInt16 m_nPropRightMargin = 100; public: // The "layout interface": - void SetRight(const tools::Long nR, const sal_uInt16 nProp = 100); + void SetRight(SvxIndentValue stR, const sal_uInt16 nProp = 100); // Query/direct setting of the absolute values - tools::Long GetRight() const { return m_nRightMargin;} + SvxIndentValue GetRight() const; + sal_Int32 ResolveRight(const SvxFontUnitMetrics& rMetrics) const; + sal_Int32 ResolveRightFixedPart() const; + sal_Int32 ResolveRightVariablePart(const SvxFontUnitMetrics& rMetrics) const; - sal_uInt16 GetPropRight() const { return m_nPropRightMargin; } + sal_uInt16 GetPropRight() const; explicit SvxRightMarginItem(const sal_uInt16 nId); - SvxRightMarginItem(const tools::Long nRight, const sal_uInt16 nId); + SvxRightMarginItem(SvxIndentValue stRight, const sal_uInt16 nId); SvxRightMarginItem(SvxRightMarginItem const &) = default; // SfxPoolItem copy function dichotomy // "pure virtual Methods" from SfxPoolItem @@ -325,10 +336,10 @@ public: class EDITENG_DLLPUBLIC SvxLRSpaceItem final : public SfxPoolItem { /// First-line indent always relative to GetTextLeft() - double m_dFirstLineOffset = 0.0; - sal_Int16 m_nFirstLineUnit = css::util::MeasureUnit::TWIP; - tools::Long nLeftMargin; // nLeft or the negative first-line indent - tools::Long nRightMargin; // The unproblematic right edge + SvxIndentValue m_stFirstLineOffset = SvxIndentValue::zero(); + SvxIndentValue m_stLeftMargin + = SvxIndentValue::zero(); // nLeft or the negative first-line indent + SvxIndentValue m_stRightMargin = SvxIndentValue::zero(); /// The amount of extra space added to the left margin. tools::Long m_nGutterMargin; /// The amount of extra space added to the right margin, on mirrored pages. @@ -344,7 +355,7 @@ public: static SfxPoolItem* CreateDefault(); explicit SvxLRSpaceItem( const sal_uInt16 nId ); - SvxLRSpaceItem(const tools::Long nLeft, const tools::Long nRight, SvxIndentValue stValue, + SvxLRSpaceItem(SvxIndentValue stLeft, SvxIndentValue stRight, SvxIndentValue stValue, const sal_uInt16 nId); SvxLRSpaceItem(SvxLRSpaceItem const &) = default; // SfxPoolItem copy function dichotomy @@ -364,18 +375,14 @@ public: virtual bool HasMetrics() const override; // The "layout interface": - void SetLeft (const tools::Long nL, const sal_uInt16 nProp = 100); - void SetRight(const tools::Long nR, const sal_uInt16 nProp = 100); + void SetLeft(SvxIndentValue stL, const sal_uInt16 nProp = 100); + void SetRight(SvxIndentValue stR, const sal_uInt16 nProp = 100); // Query/direct setting of the absolute values - tools::Long GetLeft() const { return nLeftMargin; } - tools::Long GetRight() const { return nRightMargin;} - void SetLeftValue(const tools::Long nL) - { - assert(m_dFirstLineOffset == 0.0); - nLeftMargin = nL; - } - void SetRightValue( const tools::Long nR ) { nRightMargin = nR; } + SvxIndentValue GetLeft() const; + sal_Int32 ResolveLeft(const SvxFontUnitMetrics& rMetrics) const; + SvxIndentValue GetRight() const; + sal_Int32 ResolveRight(const SvxFontUnitMetrics& rMetrics) const; bool IsAutoFirst() const { return bAutoFirst; } void SetAutoFirst( const bool bNew ) { bAutoFirst = bNew; } @@ -387,14 +394,12 @@ public: sal_uInt16 GetPropRight() const { return nPropRightMargin;} // The UI/text interface: - void SetTextLeft(const tools::Long nL, const sal_uInt16 nProp = 100); - tools::Long GetTextLeft() const; + void SetTextLeft(SvxIndentValue stL, const sal_uInt16 nProp = 100); + SvxIndentValue GetTextLeft() const; + sal_Int32 ResolveTextLeft(const SvxFontUnitMetrics& rMetrics) const; void SetTextFirstLineOffset(SvxIndentValue stValue, sal_uInt16 nProp = 100); SvxIndentValue GetTextFirstLineOffset() const; - double GetTextFirstLineOffsetValue() const; - sal_Int16 GetTextFirstLineOffsetUnit() const; - double ResolveTextFirstLineOffsetDouble(const SvxFontUnitMetrics& rMetrics) const; sal_Int32 ResolveTextFirstLineOffset(const SvxFontUnitMetrics& rMetrics) const; void SetPropTextFirstLineOffset( const sal_uInt16 nProp ) diff --git a/include/editeng/memberids.h b/include/editeng/memberids.h index 195eccce41c8..82a1fe65e9bf 100644 --- a/include/editeng/memberids.h +++ b/include/editeng/memberids.h @@ -139,6 +139,8 @@ #define MID_TXT_LMARGIN 11 #define MID_GUTTER_MARGIN 12 #define MID_FIRST_LINE_UNIT_INDENT 13 +#define MID_R_UNIT_MARGIN 14 +#define MID_L_UNIT_MARGIN 15 //ProtectItem #define MID_PROTECT_CONTENT 0 diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx index 0ba35cbee24a..b42c03bca762 100644 --- a/include/editeng/unoprnms.hxx +++ b/include/editeng/unoprnms.hxx @@ -295,8 +295,10 @@ inline constexpr OUString UNO_NAME_EDIT_PARA_ADJUST = u"ParaAdjust"_ustr; inline constexpr OUString UNO_NAME_EDIT_PARA_BMARGIN = u"ParaBottomMargin"_ustr; inline constexpr OUString UNO_NAME_EDIT_PARA_LASTLINEADJ = u"ParaLastLineAdjust"_ustr; inline constexpr OUString UNO_NAME_EDIT_PARA_LMARGIN = u"ParaLeftMargin"_ustr; +inline constexpr OUString UNO_NAME_EDIT_PARA_LMARGIN_UNIT = u"ParaLeftMarginUnit"_ustr; inline constexpr OUString UNO_NAME_EDIT_PARA_LINESPACING = u"ParaLineSpacing"_ustr; inline constexpr OUString UNO_NAME_EDIT_PARA_RMARGIN = u"ParaRightMargin"_ustr; +inline constexpr OUString UNO_NAME_EDIT_PARA_RMARGIN_UNIT = u"ParaRightMarginUnit"_ustr; inline constexpr OUString UNO_NAME_EDIT_PARA_TABSTOPS = u"ParaTabStops"_ustr; inline constexpr OUString UNO_NAME_EDIT_PARA_TABSTOP_DEFAULT_DISTANCE = u"ParaTabStopDefaultDistance"_ustr; inline constexpr OUString UNO_NAME_EDIT_PARA_TMARGIN = u"ParaTopMargin"_ustr; diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx index 4011fac9d479..168b9ce063ee 100644 --- a/include/editeng/unotext.hxx +++ b/include/editeng/unotext.hxx @@ -148,8 +148,10 @@ struct SfxItemPropertyMapEntry; {u"ParaHyphenationNoLastWord"_ustr, EE_PARA_HYPHENATE_NO_LAST_WORD, ::cppu::UnoType::get(), 0, 0 }, \ { UNO_NAME_EDIT_PARA_LASTLINEADJ, EE_PARA_JUST, ::cppu::UnoType::get(), 0, MID_LAST_LINE_ADJUST }, \ { UNO_NAME_EDIT_PARA_LMARGIN, EE_PARA_LRSPACE, ::cppu::UnoType::get(), 0, MID_TXT_LMARGIN, PropertyMoreFlags::METRIC_ITEM }, \ + { UNO_NAME_EDIT_PARA_LMARGIN_UNIT, EE_PARA_LRSPACE, ::cppu::UnoType>::get(), 0, MID_L_UNIT_MARGIN }, \ { UNO_NAME_EDIT_PARA_LINESPACING, EE_PARA_SBL, cppu::UnoType::get(), 0, CONVERT_TWIPS}, \ { UNO_NAME_EDIT_PARA_RMARGIN, EE_PARA_LRSPACE, ::cppu::UnoType::get(), 0, MID_R_MARGIN, PropertyMoreFlags::METRIC_ITEM }, \ + { UNO_NAME_EDIT_PARA_RMARGIN_UNIT, EE_PARA_LRSPACE, ::cppu::UnoType>::get(), 0, MID_R_UNIT_MARGIN }, \ { UNO_NAME_EDIT_PARA_TABSTOPS, EE_PARA_TABS, cppu::UnoType>::get(), 0, 0 }, \ { UNO_NAME_EDIT_PARA_TABSTOP_DEFAULT_DISTANCE, EE_PARA_TABS, ::cppu::UnoType::get(), 0, MID_TABSTOP_DEFAULT_DISTANCE }, \ { UNO_NAME_EDIT_PARA_TMARGIN, EE_PARA_ULSPACE, ::cppu::UnoType::get(), 0, MID_UP_MARGIN, PropertyMoreFlags::METRIC_ITEM },\ diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index 41914a33ca7a..149b43d5efe2 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -2415,10 +2415,11 @@ void OReportController::openPageDialog(const uno::Reference& _ { aDescriptor.Put(SvxSizeItem(RPTUI_ID_SIZE, VCLUnoHelper::ConvertToVCLSize(getStyleProperty(m_xReportDefinition,PROPERTY_PAPERSIZE)))); - aDescriptor.Put(SvxLRSpaceItem( - getStyleProperty(m_xReportDefinition, PROPERTY_LEFTMARGIN), - getStyleProperty(m_xReportDefinition, PROPERTY_RIGHTMARGIN), - SvxIndentValue::zero(), RPTUI_ID_LRSPACE)); + aDescriptor.Put(SvxLRSpaceItem(SvxIndentValue::twips(getStyleProperty( + m_xReportDefinition, PROPERTY_LEFTMARGIN)), + SvxIndentValue::twips(getStyleProperty( + m_xReportDefinition, PROPERTY_RIGHTMARGIN)), + SvxIndentValue::zero(), RPTUI_ID_LRSPACE)); aDescriptor.Put(SvxULSpaceItem(static_cast(getStyleProperty(m_xReportDefinition,PROPERTY_TOPMARGIN)) ,static_cast(getStyleProperty(m_xReportDefinition,PROPERTY_BOTTOMMARGIN)),RPTUI_ID_ULSPACE)); aDescriptor.Put(SfxUInt16Item(SID_ATTR_METRIC,static_cast(eUserMetric))); diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx index 2add110bc0f2..7a1000ca3cce 100644 --- a/sc/source/core/data/docpool.cxx +++ b/sc/source/core/data/docpool.cxx @@ -313,9 +313,9 @@ static bool lcl_HFPresentation sal_uInt16 nPropRightMargin = rLRItem.GetPropRight(); sal_uInt16 nLeftMargin, nRightMargin; tools::Long nTmp; - nTmp = rLRItem.GetLeft(); + nTmp = rLRItem.ResolveLeft({}); nLeftMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp); - nTmp = rLRItem.GetRight(); + nTmp = rLRItem.ResolveRight({}); nRightMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp); aText = EditResId(RID_SVXITEMS_LRSPACE_LEFT); diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx index eafe3f48a264..47b861756337 100644 --- a/sc/source/core/data/stlsheet.cxx +++ b/sc/source/core/data/stlsheet.cxx @@ -175,8 +175,8 @@ SfxItemSet& ScStyleSheet::GetItemSet() HFDIST_CM,// nLow ATTR_ULSPACE ); - SvxLRSpaceItem aLRSpaceItem(TWO_CM, // nLeft - TWO_CM, // nRight + SvxLRSpaceItem aLRSpaceItem(SvxIndentValue::twips(TWO_CM), // nLeft + SvxIndentValue::twips(TWO_CM), // nRight SvxIndentValue::zero(), // nFirstLineOffset ATTR_LRSPACE); SvxULSpaceItem aULSpaceItem( TWO_CM, // nUp @@ -193,7 +193,8 @@ SfxItemSet& ScStyleSheet::GetItemSet() rHFSet.Put( aBoxInfoItem ); rHFSet.Put( aHFSizeItem ); rHFSet.Put( aHFDistItem ); - rHFSet.Put(SvxLRSpaceItem(0, 0, SvxIndentValue::zero(), + rHFSet.Put(SvxLRSpaceItem(SvxIndentValue::zero(), SvxIndentValue::zero(), + SvxIndentValue::zero(), ATTR_LRSPACE)); // Set border to Null aHFSetItem.SetWhich(ATTR_PAGE_HEADERSET); diff --git a/sc/source/filter/excel/xepage.cxx b/sc/source/filter/excel/xepage.cxx index 144ab51c076e..28779bd209a1 100644 --- a/sc/source/filter/excel/xepage.cxx +++ b/sc/source/filter/excel/xepage.cxx @@ -246,8 +246,8 @@ XclExpPageSettings::XclExpPageSettings( const XclExpRoot& rRoot ) : maData.mbManualStart = maData.mnStartPage && (!nScTab || rDoc.NeedPageResetAfterTab( nScTab - 1 )); const SvxLRSpaceItem& rLRItem = rItemSet.Get( ATTR_LRSPACE ); - maData.mfLeftMargin = XclTools::GetInchFromTwips( rLRItem.GetLeft() ); - maData.mfRightMargin = XclTools::GetInchFromTwips( rLRItem.GetRight() ); + maData.mfLeftMargin = XclTools::GetInchFromTwips(rLRItem.ResolveLeft({})); + maData.mfRightMargin = XclTools::GetInchFromTwips(rLRItem.ResolveRight({})); const SvxULSpaceItem& rULItem = rItemSet.Get( ATTR_ULSPACE ); maData.mfTopMargin = XclTools::GetInchFromTwips( rULItem.GetUpper() ); maData.mfBottomMargin = XclTools::GetInchFromTwips( rULItem.GetLower() ); diff --git a/sc/source/filter/excel/xipage.cxx b/sc/source/filter/excel/xipage.cxx index bfb775fe321e..1c4e4a1bc375 100644 --- a/sc/source/filter/excel/xipage.cxx +++ b/sc/source/filter/excel/xipage.cxx @@ -214,10 +214,10 @@ void lclPutMarginItem( SfxItemSet& rItemSet, sal_uInt16 nRecId, double fMarginIn case EXC_ID_RIGHTMARGIN: { SvxLRSpaceItem aItem( rItemSet.Get( ATTR_LRSPACE ) ); - if( nRecId == EXC_ID_LEFTMARGIN ) - aItem.SetLeftValue( nMarginTwips ); + if (nRecId == EXC_ID_LEFTMARGIN) + aItem.SetLeft(SvxIndentValue::twips(nMarginTwips)); else - aItem.SetRightValue( nMarginTwips ); + aItem.SetRight(SvxIndentValue::twips(nMarginTwips)); rItemSet.Put( aItem ); } break; diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx index 724500b7b406..d0dbefc3f2f3 100644 --- a/sc/source/filter/html/htmlimp.cxx +++ b/sc/source/filter/html/htmlimp.cxx @@ -72,8 +72,8 @@ ScHTMLImport::ScHTMLImport( ScDocument* pDocP, const OUString& rBaseURL, const S { const SfxItemSet& rSet = pStyleSheet->GetItemSet(); const SvxLRSpaceItem* pLRItem = &rSet.Get( ATTR_LRSPACE ); - tools::Long nLeftMargin = pLRItem->GetLeft(); - tools::Long nRightMargin = pLRItem->GetRight(); + tools::Long nLeftMargin = pLRItem->ResolveLeft({}); + tools::Long nRightMargin = pLRItem->ResolveRight({}); const SvxULSpaceItem* pULItem = &rSet.Get( ATTR_ULSPACE ); tools::Long nTopMargin = pULItem->GetUpper(); tools::Long nBottomMargin = pULItem->GetLower(); diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 20c33cb669e0..19ef534be1e6 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -2426,7 +2426,7 @@ static void lcl_PDFExportMediaShapeScreen(const OutputDevice* pDev, const std::u SfxStyleSheetBase* pStyleSheet = pStylePool->Find(rDoc.GetPageStyle(nTab), SfxStyleFamily::Page); SfxItemSet* pItemSet = &pStyleSheet->GetItemSet(); - tools::Long nLeftMargin(pItemSet->Get(ATTR_LRSPACE).GetLeft()); + tools::Long nLeftMargin(pItemSet->Get(ATTR_LRSPACE).ResolveLeft({})); nLeftMargin = o3tl::convert(nLeftMargin, o3tl::Length::twip, o3tl::Length::mm100); tools::Long nTopMargin(pItemSet->Get(ATTR_ULSPACE).GetUpper()); diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx index dc34e4722421..51699f6aa4c7 100644 --- a/sc/source/ui/view/preview.cxx +++ b/sc/source/ui/view/preview.cxx @@ -1064,12 +1064,20 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) bMoveRulerAction = false; Invalidate(tools::Rectangle(0, 0, 10000, 10000)); } - else if( bLeftRulerChange && ( o3tl::convert(aButtonUpPt.X(), o3tl::Length::mm100, o3tl::Length::twip) > nWidth - aLRItem.GetRight() - o3tl::convert(aOffset.X(), o3tl::Length::mm100, o3tl::Length::twip) ) ) + else if (bLeftRulerChange + && (o3tl::convert(aButtonUpPt.X(), o3tl::Length::mm100, o3tl::Length::twip) + > nWidth - aLRItem.ResolveRight({}) + - o3tl::convert(aOffset.X(), o3tl::Length::mm100, + o3tl::Length::twip))) { bMoveRulerAction = false; Invalidate(tools::Rectangle(0, 0, 10000, 10000)); } - else if( bRightRulerChange && ( o3tl::convert(aButtonUpPt.X(), o3tl::Length::mm100, o3tl::Length::twip) < aLRItem.GetLeft() - o3tl::convert(aOffset.X(), o3tl::Length::mm100, o3tl::Length::twip) ) ) + else if (bRightRulerChange + && (o3tl::convert(aButtonUpPt.X(), o3tl::Length::mm100, o3tl::Length::twip) + < aLRItem.ResolveLeft({}) + - o3tl::convert(aOffset.X(), o3tl::Length::mm100, + o3tl::Length::twip))) { bMoveRulerAction = false; Invalidate(tools::Rectangle(0, 0, 10000, 10000)); @@ -1084,13 +1092,19 @@ void ScPreview::MouseButtonUp( const MouseEvent& rMEvt ) ScDocShellModificator aModificator( *pDocShell ); if( bLeftRulerChange && bLeftRulerMove ) { - aLRItem.SetLeft(o3tl::convert( aButtonUpPt.X(), o3tl::Length::mm100, o3tl::Length::twip) + o3tl::convert(aOffset.X(), o3tl::Length::mm100, o3tl::Length::twip)); - rStyleSet.Put( aLRItem ); - pDocShell->SetModified(); + aLRItem.SetLeft(SvxIndentValue::twips( + o3tl::convert(aButtonUpPt.X(), o3tl::Length::mm100, o3tl::Length::twip) + + o3tl::convert(aOffset.X(), o3tl::Length::mm100, o3tl::Length::twip))); + rStyleSet.Put(aLRItem); + pDocShell->SetModified(); } else if( bRightRulerChange && bRightRulerMove ) { - aLRItem.SetRight(nWidth - o3tl::convert(aButtonUpPt.X(), o3tl::Length::mm100, o3tl::Length::twip) - o3tl::convert(aOffset.X(), o3tl::Length::mm100, o3tl::Length::twip)); + aLRItem.SetRight(SvxIndentValue::twips( + nWidth + - o3tl::convert(aButtonUpPt.X(), o3tl::Length::mm100, + o3tl::Length::twip) + - o3tl::convert(aOffset.X(), o3tl::Length::mm100, o3tl::Length::twip))); rStyleSet.Put( aLRItem ); pDocShell->SetModified(); } diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index e02254251ae7..a8c3990b1288 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -669,9 +669,9 @@ static void lcl_FillHFParam( ScPrintHFParam& rParam, const SfxItemSet* pHFSet ) rParam.nHeight = pHFSet->Get(ATTR_PAGE_SIZE).GetSize().Height(); const SvxLRSpaceItem* pHFLR = &pHFSet->Get(ATTR_LRSPACE); tools::Long nTmp; - nTmp = pHFLR->GetLeft(); + nTmp = pHFLR->ResolveLeft({}); rParam.nLeft = nTmp < 0 ? 0 : sal_uInt16(nTmp); - nTmp = pHFLR->GetRight(); + nTmp = pHFLR->ResolveRight({}); rParam.nRight = nTmp < 0 ? 0 : sal_uInt16(nTmp); rParam.pBorder = &pHFSet->Get(ATTR_BORDER); rParam.pBack = &pHFSet->Get(ATTR_BACKGROUND); @@ -862,9 +862,9 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions ) // TabPage "Page" const SvxLRSpaceItem* pLRItem = &pParamSet->Get( ATTR_LRSPACE ); tools::Long nTmp; - nTmp = pLRItem->GetLeft(); + nTmp = pLRItem->ResolveLeft({}); nLeftMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp); - nTmp = pLRItem->GetRight(); + nTmp = pLRItem->ResolveRight({}); nRightMargin = nTmp < 0 ? 0 : sal_uInt16(nTmp); const SvxULSpaceItem* pULItem = &pParamSet->Get( ATTR_ULSPACE ); nTopMargin = pULItem->GetUpper(); diff --git a/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng index f4e2cc8f0656..e8e2c5be98e1 100644 --- a/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng +++ b/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng @@ -3125,6 +3125,30 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1. + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index e611246eded6..4607a5f3aa65 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -2144,7 +2144,7 @@ static rtl::Reference convertPresentationObjectImpl(SdPage& rPage, Sd const SvxLRSpaceItem& rLRItem = aSet.Get(EE_PARA_LRSPACE); SvxLRSpaceItem aNewLRItem(rLRItem); - aNewLRItem.SetTextLeft(0); + aNewLRItem.SetTextLeft(SvxIndentValue::zero()); aSet.Put(aNewLRItem); pNewObj->SetMergedItemSet(aSet); diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx index 7af9b22146d3..8ecda5046c51 100644 --- a/sd/source/core/stlpool.cxx +++ b/sd/source/core/stlpool.cxx @@ -394,7 +394,7 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName, rSubtitleSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) ); // #i16874# enable kerning by default but only for new documents rSubtitleSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) ); - aSvxLRSpaceItem.SetTextLeft(0); + aSvxLRSpaceItem.SetTextLeft(SvxIndentValue::zero()); rSubtitleSet.Put(aSvxLRSpaceItem); vcl::Font aTmpFont( GetBulletFont() ); @@ -439,7 +439,8 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName, rNotesSet.Put( SvxCharReliefItem(FontRelief::NONE, EE_CHAR_RELIEF) ); rNotesSet.Put( SvxColorItem( COL_AUTO, EE_CHAR_COLOR ) ); rNotesSet.Put( SvxColorItem( COL_AUTO, EE_CHAR_BKGCOLOR ) ); - rNotesSet.Put(SvxLRSpaceItem(0, 0, SvxIndentValue::twips(-600.0), EE_PARA_LRSPACE)); + rNotesSet.Put(SvxLRSpaceItem(SvxIndentValue::zero(), SvxIndentValue::zero(), + SvxIndentValue::twips(-600.0), EE_PARA_LRSPACE)); // #i16874# enable kerning by default but only for new documents rNotesSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) ); diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx index 9c402c8956e5..8fcc2cbd1440 100644 --- a/sd/source/core/stlsheet.cxx +++ b/sd/source/core/stlsheet.cxx @@ -579,12 +579,12 @@ void SdStyleSheet::AdjustToFontHeight(SfxItemSet& rSet, bool bOnlyMissingItems) if (rSet.GetItemState(EE_PARA_LRSPACE) != SfxItemState::SET || !bOnlyMissingItems) { const SvxLRSpaceItem& rLRItem = pCurSet->Get(EE_PARA_LRSPACE); - double fIndentFraction = double(rLRItem.GetTextLeft()) / nOldHeight; + double fIndentFraction = double(rLRItem.ResolveTextLeft({})) / nOldHeight; SvxLRSpaceItem aNewLRItem(rLRItem); - aNewLRItem.SetTextLeft(fIndentFraction * nNewHeight); - double fFirstIndentFraction = rLRItem.GetTextFirstLineOffsetValue() / nOldHeight; + aNewLRItem.SetTextLeft(SvxIndentValue::twips(fIndentFraction * nNewHeight)); + double fFirstIndentFraction = rLRItem.GetTextFirstLineOffset().m_dValue / nOldHeight; aNewLRItem.SetTextFirstLineOffset(SvxIndentValue{ fFirstIndentFraction * nNewHeight, - rLRItem.GetTextFirstLineOffsetUnit() }); + rLRItem.GetTextFirstLineOffset().m_nUnit }); rSet.Put(aNewLRItem); } diff --git a/sd/source/filter/xml/sdtransform.cxx b/sd/source/filter/xml/sdtransform.cxx index d11327c76fbb..b62554a60d7a 100644 --- a/sd/source/filter/xml/sdtransform.cxx +++ b/sd/source/filter/xml/sdtransform.cxx @@ -294,9 +294,9 @@ bool SdTransformOOo2xDocument::transformItemSet( SfxItemSet& rSet, bool bNumberi if (pItem) { SvxLRSpaceItem aItem(*pItem); - if ((aItem.GetLeft() != 0) || (aItem.GetTextFirstLineOffsetValue() != 0.0)) + if ((aItem.GetLeft().m_dValue != 0.0) || (aItem.GetTextFirstLineOffset().m_dValue != 0.0)) { - aItem.SetLeftValue( 0 ); + aItem.SetLeft(SvxIndentValue::zero()); aItem.SetTextFirstLineOffset(SvxIndentValue::zero()); rSet.Put( aItem ); bRet = true; diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx index 9170f72622b2..dc3d4ea66faa 100644 --- a/sd/source/ui/func/fupage.cxx +++ b/sd/source/ui/func/fupage.cxx @@ -244,8 +244,8 @@ void FuPage::ExecuteAsyncDialog(weld::Window* pParent, const SfxRequest& rReq) SvxPaperBinItem aPaperBinItem( SID_ATTR_PAGE_PAPERBIN, static_cast(mpPage->GetPaperBin()) ); aNewAttr->Put( aPaperBinItem ); - SvxLRSpaceItem aLRSpaceItem(static_cast(mpPage->GetLeftBorder()), - static_cast(mpPage->GetRightBorder()), + SvxLRSpaceItem aLRSpaceItem(SvxIndentValue::twips(mpPage->GetLeftBorder()), + SvxIndentValue::twips(mpPage->GetRightBorder()), SvxIndentValue::zero(), mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_LRSPACE)); aNewAttr->Put( aLRSpaceItem ); @@ -526,8 +526,8 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs ) if( pArgs->GetItemState(mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_LRSPACE), true, &pPoolItem) == SfxItemState::SET ) { - nLeft = static_cast(pPoolItem)->GetLeft(); - nRight = static_cast(pPoolItem)->GetRight(); + nLeft = static_cast(pPoolItem)->ResolveLeft({}); + nRight = static_cast(pPoolItem)->ResolveRight({}); if( mpPage->GetLeftBorder() != nLeft || mpPage->GetRightBorder() != nRight ) bSetPageSizeAndBorder = true; diff --git a/sd/source/ui/func/fuparagr.cxx b/sd/source/ui/func/fuparagr.cxx index 2640b9251f19..ee50cc05d304 100644 --- a/sd/source/ui/func/fuparagr.cxx +++ b/sd/source/ui/func/fuparagr.cxx @@ -74,7 +74,7 @@ void FuParagraph::DoExecute( SfxRequest& rReq ) aNewAttr.Put( aEditAttr ); // left border is offset - const ::tools::Long nOff = aNewAttr.Get( EE_PARA_LRSPACE ).GetTextLeft(); + const ::tools::Long nOff = aNewAttr.Get(EE_PARA_LRSPACE).ResolveTextLeft({}); // conversion since TabulatorTabPage always uses Twips! SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff ); aNewAttr.Put( aOff ); diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx index 898f11687d8f..9058f7ad30a0 100644 --- a/sd/source/ui/view/drtxtob1.cxx +++ b/sd/source/ui/view/drtxtob1.cxx @@ -158,7 +158,7 @@ void TextObjectBar::ExecuteImpl(ViewShell* mpViewShell, ::sd::View* mpView, SfxR const SvxLRSpaceItem& rItem = aAttr.Get( EE_PARA_LRSPACE ); std::unique_ptr pNewItem(rItem.Clone()); - ::tools::Long nLeft = pNewItem->GetLeft(); + ::tools::Long nLeft = pNewItem->ResolveLeft({}); if( nSlot == SID_INC_INDENT ) nLeft += nIndentDefaultDist; else @@ -166,7 +166,7 @@ void TextObjectBar::ExecuteImpl(ViewShell* mpViewShell, ::sd::View* mpView, SfxR nLeft -= nIndentDefaultDist; nLeft = std::max<::tools::Long>( nLeft, 0 ); } - pNewItem->SetLeftValue( static_cast(nLeft) ); + pNewItem->SetLeft(SvxIndentValue::twips(static_cast(nLeft))); aAttr.Put( std::move(pNewItem) ); pOLV->GetOutliner()->SetParaAttribs( nPara, aAttr ); @@ -352,7 +352,8 @@ void TextObjectBar::ExecuteImpl(ViewShell* mpViewShell, ::sd::View* mpView, SfxR if (nIndentDist == 0.0) nIndentDist = nIndentDefaultDist; - aNewMargin.SetTextLeft(aParaMargin.GetTextLeft() + nIndentDist); + aNewMargin.SetTextLeft( + SvxIndentValue::twips(aParaMargin.ResolveTextLeft({}) + nIndentDist)); aNewMargin.SetRight(aParaMargin.GetRight()); aNewMargin.SetTextFirstLineOffset(SvxIndentValue::twips(nIndentDist * -1)); diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx index 63add2a2aca8..422ebaaa9828 100644 --- a/sd/source/ui/view/drviews3.cxx +++ b/sd/source/ui/view/drviews3.cxx @@ -833,16 +833,16 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) // become negative - EditEngine really does not // like that. const auto nAbsLSpace=aFormat.GetAbsLSpace(); - const ::tools::Long nTxtLeft=rItem.GetTextLeft(); + const ::tools::Long nTxtLeft = rItem.ResolveTextLeft({}); const ::tools::Long nLeftIndent=std::max(::tools::Long(0),nTxtLeft - nAbsLSpace); - aLRSpaceItem.SetTextLeft(nLeftIndent); + aLRSpaceItem.SetTextLeft(SvxIndentValue::twips(nLeftIndent)); // control for clipped left indent - remainder // reduces number format first line indent aFormat.SetAbsLSpace(nTxtLeft - nLeftIndent); // negative first line indent goes to the number // format, positive to the lrSpace item - if (rItem.GetTextFirstLineOffsetValue() < 0.0) + if (rItem.GetTextFirstLineOffset().m_dValue < 0.0) { aFormat.SetFirstLineOffset(rItem.ResolveTextFirstLineOffset({}) - rOrigLRSpaceItem.ResolveTextFirstLineOffset({}) @@ -952,7 +952,8 @@ void DrawViewShell::GetRulerState(SfxItemSet& rSet) rNumBulletItem.GetNumRule().GetLevelCount() > nOutlineLevel ) { const SvxNumberFormat& rFormat = rNumBulletItem.GetNumRule().GetLevel(nOutlineLevel); - aLRSpaceItem.SetTextLeft(rFormat.GetAbsLSpace() + rLRSpaceItem.GetTextLeft()); + aLRSpaceItem.SetTextLeft(SvxIndentValue::twips( + rFormat.GetAbsLSpace() + rLRSpaceItem.ResolveTextLeft({}))); aLRSpaceItem.SetTextFirstLineOffset(SvxIndentValue::twips( rLRSpaceItem.ResolveTextFirstLineOffset({}) + rFormat.GetFirstLineOffset() - rFormat.GetCharTextDistance())); diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx index 15fad231a696..3e713c912dae 100644 --- a/sd/source/ui/view/outlview.cxx +++ b/sd/source/ui/view/outlview.cxx @@ -70,15 +70,17 @@ namespace sd { // PROCESS_WITH_PROGRESS_THRESHOLD pages are concerned #define PROCESS_WITH_PROGRESS_THRESHOLD 5 -OutlineView::OutlineView( DrawDocShell& rDocSh, vcl::Window* pWindow, OutlineViewShell& rOutlineViewShell) -: ::sd::SimpleOutlinerView(*rDocSh.GetDoc(), pWindow->GetOutDev(), &rOutlineViewShell) -, mrOutlineViewShell(rOutlineViewShell) -, mrOutliner(*mrDoc.GetOutliner()) -, mnPagesToProcess(0) -, mnPagesProcessed(0) -, mbFirstPaint(true) -, maDocColor( COL_WHITE ) -, maLRSpaceItem(2000, 0, SvxIndentValue::zero(), EE_PARA_OUTLLRSPACE) +OutlineView::OutlineView(DrawDocShell& rDocSh, vcl::Window* pWindow, + OutlineViewShell& rOutlineViewShell) + : ::sd::SimpleOutlinerView(*rDocSh.GetDoc(), pWindow->GetOutDev(), &rOutlineViewShell) + , mrOutlineViewShell(rOutlineViewShell) + , mrOutliner(*mrDoc.GetOutliner()) + , mnPagesToProcess(0) + , mnPagesProcessed(0) + , mbFirstPaint(true) + , maDocColor(COL_WHITE) + , maLRSpaceItem(SvxIndentValue::twips(2000), SvxIndentValue::zero(), SvxIndentValue::zero(), + EE_PARA_OUTLLRSPACE) { bool bInitOutliner = false; diff --git a/svx/source/dialog/hdft.cxx b/svx/source/dialog/hdft.cxx index fe91c933326b..0bce3b3f4381 100644 --- a/svx/source/dialog/hdft.cxx +++ b/svx/source/dialog/hdft.cxx @@ -255,8 +255,8 @@ bool SvxHFPage::FillItemSet( SfxItemSet* rSet ) // Margins SvxLRSpaceItem aLR( nWLRSpace ); - aLR.SetLeft( static_cast(GetCoreValue( *m_xLMEdit, eUnit )) ); - aLR.SetRight( static_cast(GetCoreValue( *m_xRMEdit, eUnit )) ); + aLR.SetLeft(SvxIndentValue::twips(GetCoreValue(*m_xLMEdit, eUnit))); + aLR.SetRight(SvxIndentValue::twips(GetCoreValue(*m_xRMEdit, eUnit))); aSet.Put( aLR ); SvxULSpaceItem aUL( nWULSpace ); @@ -372,8 +372,8 @@ void SvxHFPage::Reset( const SfxItemSet* rSet ) } m_xHeightDynBtn->set_active(rDynamic.GetValue()); - SetMetricValue( *m_xLMEdit, rLR.GetLeft(), eUnit ); - SetMetricValue( *m_xRMEdit, rLR.GetRight(), eUnit ); + SetMetricValue(*m_xLMEdit, rLR.ResolveLeft({}), eUnit); + SetMetricValue(*m_xRMEdit, rLR.ResolveRight({}), eUnit); m_xCntSharedBox->set_active(rShared.GetValue()); if (pSharedFirst) m_xCntSharedFirstBox->set_active(pSharedFirst->GetValue()); @@ -794,8 +794,8 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) // Set left and right margins const SvxLRSpaceItem& rLRSpace = static_cast(*pItem); - m_aBspWin.SetLeft( rLRSpace.GetLeft() ); - m_aBspWin.SetRight( rLRSpace.GetRight() ); + m_aBspWin.SetLeft(rLRSpace.ResolveLeft({})); + m_aBspWin.SetRight(rLRSpace.ResolveRight({})); } else { @@ -865,8 +865,8 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) m_aBspWin.SetHdHeight( rSize.GetSize().Height() - nDist ); m_aBspWin.SetHdDist( nDist ); - m_aBspWin.SetHdLeft( rLR.GetLeft() ); - m_aBspWin.SetHdRight( rLR.GetRight() ); + m_aBspWin.SetHdLeft(rLR.ResolveLeft({})); + m_aBspWin.SetHdRight(rLR.ResolveRight({})); m_aBspWin.SetHeader( true ); } else @@ -903,8 +903,8 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) m_aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist ); m_aBspWin.SetFtDist( nDist ); - m_aBspWin.SetFtLeft( rLR.GetLeft() ); - m_aBspWin.SetFtRight( rLR.GetRight() ); + m_aBspWin.SetFtLeft(rLR.ResolveLeft({})); + m_aBspWin.SetFtRight(rLR.ResolveRight({})); m_aBspWin.SetFooter( true ); } else diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx index 6bbf1b1a9ddd..7c60ac13faf6 100644 --- a/svx/source/dialog/svxruler.cxx +++ b/svx/source/dialog/svxruler.cxx @@ -565,11 +565,11 @@ void SvxRuler::MouseMove( const MouseEvent& rMEvt ) tools::Long nIndentValue = 0.0; if (nIndex == INDENT_LEFT_MARGIN) - nIndentValue = mxParaItem->GetTextLeft(); + nIndentValue = mxParaItem->ResolveTextLeft({}); else if (nIndex == INDENT_FIRST_LINE) nIndentValue = mxParaItem->ResolveTextFirstLineOffset({}); else if (nIndex == INDENT_RIGHT_MARGIN) - nIndentValue = mxParaItem->GetRight(); + nIndentValue = mxParaItem->ResolveRight({}); double fValue = OutputDevice::LogicToLogic(Size(nIndentValue, 0), pEditWin->GetMapMode(), GetCurrentMapMode()).Width(); fValue = rtl::math::round(fValue / aUnitData.nTickUnit, aNoDecimalPlaces); @@ -845,15 +845,15 @@ void SvxRuler::UpdatePara() if(bRTLText) { - leftMargin = nRightFrameMargin - mxParaItem->GetTextLeft() + lAppNullOffset; + leftMargin = nRightFrameMargin - mxParaItem->ResolveTextLeft({}) + lAppNullOffset; leftFirstLine = leftMargin - mxParaItem->ResolveTextFirstLineOffset({}); - rightMargin = nLeftFrameMargin + mxParaItem->GetRight() + lAppNullOffset; + rightMargin = nLeftFrameMargin + mxParaItem->ResolveRight({}) + lAppNullOffset; } else { - leftMargin = nLeftFrameMargin + mxParaItem->GetTextLeft() + lAppNullOffset; + leftMargin = nLeftFrameMargin + mxParaItem->ResolveTextLeft({}) + lAppNullOffset; leftFirstLine = leftMargin + mxParaItem->ResolveTextFirstLineOffset({}); - rightMargin = nRightFrameMargin - mxParaItem->GetRight() + lAppNullOffset; + rightMargin = nRightFrameMargin - mxParaItem->ResolveRight({}) + lAppNullOffset; } mpIndents[INDENT_LEFT_MARGIN].nPos = ConvertHPosPixel(leftMargin); @@ -1024,7 +1024,7 @@ void SvxRuler::UpdateTabs() const tools::Long nRightFrameMargin = GetRightFrameMargin(); //#i24363# tab stops relative to indent - const tools::Long nParaItemTxtLeft = mxParaItem->GetTextLeft(); + const tools::Long nParaItemTxtLeft = mxParaItem->ResolveTextLeft({}); const tools::Long lParaIndent = nLeftFrameMargin + nParaItemTxtLeft; const tools::Long lRightMargin = nRightFrameMargin - nParaItemTxtLeft; @@ -1033,7 +1033,8 @@ void SvxRuler::UpdateTabs() ? ConvertHPosPixel(mxTabStopItem->At(mxTabStopItem->Count() - 1).GetTabPos()) : 0; const tools::Long lPosPixel = ConvertHPosPixel(lParaIndent) + lLastTab; - const tools::Long lRightIndent = ConvertHPosPixel(nRightFrameMargin - mxParaItem->GetRight()); + const tools::Long lRightIndent + = ConvertHPosPixel(nRightFrameMargin - mxParaItem->ResolveRight({})); tools::Long lCurrentDefTabDist = lDefTabDist; if(mxTabStopItem->GetDefaultDistance()) @@ -1301,7 +1302,8 @@ tools::Long SvxRuler::GetRightIndent() const tools::Long SvxRuler::GetLogicRightIndent() const { /* Get Right paragraph margin in Logic */ - return mxParaItem ? GetRightFrameMargin() - mxParaItem->GetRight() : GetRightFrameMargin(); + return mxParaItem ? GetRightFrameMargin() - mxParaItem->ResolveRight({}) + : GetRightFrameMargin(); } // Left margin in App values, is either the margin (= 0) or the left edge of @@ -1320,7 +1322,7 @@ tools::Long SvxRuler::GetLeftFrameMargin() const } if (mxBorderItem && (!mxColumnItem || mxColumnItem->IsTable())) - nLeft += mxBorderItem->GetLeft(); + nLeft += mxBorderItem->ResolveLeft({}); return nLeft; } @@ -1374,7 +1376,7 @@ tools::Long SvxRuler::GetRightFrameMargin() const lResult += mxULSpaceItem->GetLower(); if (bHorz && mxBorderItem && (!mxColumnItem || mxColumnItem->IsTable())) - lResult += mxBorderItem->GetRight(); + lResult += mxBorderItem->ResolveRight({}); if(bHorz) lResult = mxPagePosItem->GetWidth() - lResult; @@ -2195,8 +2197,8 @@ void SvxRuler::ApplyIndents() } mxParaItem->SetTextFirstLineOffset(SvxIndentValue::twips(nNewFirstLineOffset)); - mxParaItem->SetTextLeft(nNewTxtLeft); - mxParaItem->SetRight(nNewRight); + mxParaItem->SetTextLeft(SvxIndentValue::twips(nNewTxtLeft)); + mxParaItem->SetRight(SvxIndentValue::twips(nNewRight)); sal_uInt16 nParagraphId = bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL; pBindings->GetDispatcher()->ExecuteList(nParagraphId, SfxCallMode::RECORD, @@ -2257,7 +2259,8 @@ void SvxRuler::ApplyTabs() = lAppNullOffset + (bRTL ? GetRightFrameMargin() : GetLeftFrameMargin()); if (mxRulerImpl->bIsTabsRelativeToIndent && mxParaItem) { - nTmpLeftIndentLogic += bRTL ? mxParaItem->GetRight() : mxParaItem->GetTextLeft(); + nTmpLeftIndentLogic + += bRTL ? mxParaItem->ResolveRight({}) : mxParaItem->ResolveTextLeft({}); } aTabStop.GetTabPos() = mxRulerImpl->lMaxRightLogic - lLogicNullOffset - nTmpLeftIndentLogic; diff --git a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx index 2fd5647d8666..c729f76bc710 100644 --- a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx +++ b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx @@ -219,9 +219,9 @@ void ParaPropertyPanel::initial() IMPL_LINK_NOARG( ParaPropertyPanel, ModifyIndentHdl_Impl, weld::MetricSpinButton&, void) { SvxLRSpaceItem aMargin( SID_ATTR_PARA_LRSPACE ); - aMargin.SetTextLeft(mxLeftIndent->GetCoreValue(m_eLRSpaceUnit)); - aMargin.SetRight(mxRightIndent->GetCoreValue(m_eLRSpaceUnit)); // tdf#36709: TODO: Handle font-relative units from GUI + aMargin.SetTextLeft(SvxIndentValue::twips(mxLeftIndent->GetCoreValue(m_eLRSpaceUnit))); + aMargin.SetRight(SvxIndentValue::twips(mxRightIndent->GetCoreValue(m_eLRSpaceUnit))); aMargin.SetTextFirstLineOffset( SvxIndentValue::twips(mxFLineIndent->GetCoreValue(m_eLRSpaceUnit))); @@ -396,14 +396,15 @@ void ParaPropertyPanel::StateChangedIndentImpl( SfxItemState eState, const SfxPo if (pState && eState >= SfxItemState::DEFAULT) { + // tdf#36709: TODO: Handle font-relative units const SvxLRSpaceItem* pSpace = static_cast(pState); - maTxtLeft = pSpace->GetTextLeft(); + + maTxtLeft = pSpace->ResolveTextLeft({}); maTxtLeft = OutputDevice::LogicToLogic(maTxtLeft, m_eLRSpaceUnit, MapUnit::MapTwip); - tools::Long aTxtRight = pSpace->GetRight(); + tools::Long aTxtRight = pSpace->ResolveRight({}); aTxtRight = OutputDevice::LogicToLogic(aTxtRight, m_eLRSpaceUnit, MapUnit::MapTwip); - // tdf#36709: TODO: Handle font-relative units tools::Long aTxtFirstLineOfst = pSpace->ResolveTextFirstLineOffset({}); aTxtFirstLineOfst = OutputDevice::LogicToLogic( aTxtFirstLineOfst, m_eLRSpaceUnit, MapUnit::MapTwip ); diff --git a/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx b/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx index 933a2f5f06ab..01ccd794d642 100644 --- a/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx +++ b/svx/source/sidebar/paragraph/ParaSpacingWindow.cxx @@ -213,9 +213,9 @@ void ParaLRSpacingWindow::SetValue(SfxItemState eState, const SfxPoolItem* pStat m_xFLSpacing->set_sensitive(true); const SvxLRSpaceItem* pSpace = static_cast(pState); - tools::Long aTxtLeft = pSpace->GetTextLeft(); - tools::Long aTxtRight = pSpace->GetRight(); // tdf#36709: TODO: Handle font-relative units + tools::Long aTxtLeft = pSpace->ResolveTextLeft({}); + tools::Long aTxtRight = pSpace->ResolveRight({}); tools::Long aTxtFirstLineOfst = pSpace->ResolveTextFirstLineOffset({}); aTxtLeft = m_xBeforeSpacing->normalize(aTxtLeft); @@ -293,9 +293,9 @@ IMPL_LINK_NOARG(ParaLRSpacingWindow, ModifySpacingHdl, weld::MetricSpinButton&, if(pDisp) { SvxLRSpaceItem aMargin(SID_ATTR_PARA_LRSPACE); - aMargin.SetTextLeft(m_xBeforeSpacing->GetCoreValue(m_eUnit)); - aMargin.SetRight(m_xAfterSpacing->GetCoreValue(m_eUnit)); // tdf#36709: TODO: Handle font-relative units from GUI + aMargin.SetTextLeft(SvxIndentValue::twips(m_xBeforeSpacing->GetCoreValue(m_eUnit))); + aMargin.SetRight(SvxIndentValue::twips(m_xAfterSpacing->GetCoreValue(m_eUnit))); aMargin.SetTextFirstLineOffset(SvxIndentValue::twips(m_xFLSpacing->GetCoreValue(m_eUnit))); pDisp->ExecuteList(SID_ATTR_PARA_LRSPACE, SfxCallMode::RECORD, {&aMargin}); diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 13a64ef5484d..b262018c41f6 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -59,6 +59,8 @@ inline constexpr OUString UNO_NAME_PARA_LEFT_MARGIN = u"ParaLeftMargin"_ustr; inline constexpr OUString UNO_NAME_PARA_RIGHT_MARGIN = u"ParaRightMargin"_ustr; inline constexpr OUString UNO_NAME_PARA_LEFT_MARGIN_RELATIVE = u"ParaLeftMarginRelative"_ustr; inline constexpr OUString UNO_NAME_PARA_RIGHT_MARGIN_RELATIVE = u"ParaRightMarginRelative"_ustr; +inline constexpr OUString UNO_NAME_PARA_LEFT_MARGIN_UNIT = u"ParaLeftMarginUnit"_ustr; +inline constexpr OUString UNO_NAME_PARA_RIGHT_MARGIN_UNIT = u"ParaRightMarginUnit"_ustr; inline constexpr OUString UNO_NAME_PARA_IS_AUTO_FIRST_LINE_INDENT = u"ParaIsAutoFirstLineIndent"_ustr; inline constexpr OUString UNO_NAME_PARA_FIRST_LINE_INDENT = u"ParaFirstLineIndent"_ustr; diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index a7e5428abf89..4ce2c35ea97b 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -1692,8 +1692,8 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf124770) // Set left and right margin. SvxLRSpaceItem aLRSpace = rPageSet.GetLRSpace(); - aLRSpace.SetLeft(1418); - aLRSpace.SetRight(1418); + aLRSpace.SetLeft(SvxIndentValue::twips(1418)); + aLRSpace.SetRight(SvxIndentValue::twips(1418)); rPageFormat.SetFormatAttr(aLRSpace); pDoc->ChgPageDesc(0, rPageDesc); diff --git a/sw/qa/extras/odfexport/data/tdf163913.fodt b/sw/qa/extras/odfexport/data/tdf163913.fodt new file mode 100644 index 000000000000..a0e88fe0379d --- /dev/null +++ b/sw/qa/extras/odfexport/data/tdf163913.fodt @@ -0,0 +1,131 @@ + + + 2024-10-31T15:19:06.5804455702024-11-28T01:14:40.961720728PT6M53S5LibreOfficeDev/25.2.0.0.alpha1$Linux_X86_64 LibreOffice_project/b1c60908eba7871a522777048a72630a6360e4e8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3in loext:margin-left + 6em loext:margin-left + 3in loext:margin-right + 6em loext:margin-right + + + \ No newline at end of file diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx index a8cea9a6bbfb..2dcac38ae108 100644 --- a/sw/qa/extras/odfexport/odfexport2.cxx +++ b/sw/qa/extras/odfexport/odfexport2.cxx @@ -1819,6 +1819,50 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf36709) assertXPath(pXmlDoc, "//style:style[@style:name='P2']/style:paragraph-properties", "text-indent", u"6em"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf163913) +{ + // Verifies that loext:left-margin and loext:right-margin correctly round-trip + loadAndReload("tdf163913.fodt"); + CPPUNIT_ASSERT_EQUAL(1, getPages()); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + + // Style P1 should have been rewritten as fo:margin-left + assertXPath(pXmlDoc, + "//style:style[@style:name='P1']/style:paragraph-properties[@fo:margin-left]", 1); + assertXPath(pXmlDoc, + "//style:style[@style:name='P1']/style:paragraph-properties[@loext:margin-left]", + 0); + assertXPath(pXmlDoc, "//style:style[@style:name='P1']/style:paragraph-properties", + "margin-left", u"3in"); + + // Style P2 should have round-tripped as loext:margin-left + assertXPath(pXmlDoc, + "//style:style[@style:name='P2']/style:paragraph-properties[@fo:margin-left]", 0); + assertXPath(pXmlDoc, + "//style:style[@style:name='P2']/style:paragraph-properties[@loext:margin-left]", + 1); + assertXPath(pXmlDoc, "//style:style[@style:name='P2']/style:paragraph-properties", + "margin-left", u"6em"); + + // Style P3 should have been rewritten as fo:margin-right + assertXPath(pXmlDoc, + "//style:style[@style:name='P3']/style:paragraph-properties[@fo:margin-right]", 1); + assertXPath(pXmlDoc, + "//style:style[@style:name='P3']/style:paragraph-properties[@loext:margin-right]", + 0); + assertXPath(pXmlDoc, "//style:style[@style:name='P3']/style:paragraph-properties", + "margin-right", u"3in"); + + // Style P4 should have round-tripped as loext:margin-right + assertXPath(pXmlDoc, + "//style:style[@style:name='P4']/style:paragraph-properties[@fo:margin-right]", 0); + assertXPath(pXmlDoc, + "//style:style[@style:name='P4']/style:paragraph-properties[@loext:margin-right]", + 1); + assertXPath(pXmlDoc, "//style:style[@style:name='P4']/style:paragraph-properties", + "margin-right", u"6em"); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 29d31cb4db21..59320a62709d 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -153,7 +153,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf101534) pWrtShell->GetCurAttr(aSet); CPPUNIT_ASSERT(!aSet.HasItem(RES_MARGIN_FIRSTLINE)); CPPUNIT_ASSERT(aSet.HasItem(RES_MARGIN_TEXTLEFT)); - CPPUNIT_ASSERT_EQUAL(::tools::Long(0), aSet.GetItem(RES_MARGIN_TEXTLEFT)->GetTextLeft()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aSet.GetItem(RES_MARGIN_TEXTLEFT)->ResolveTextLeft({})); // Make sure that direct formatting is preserved during paste. pWrtShell->EndPara(/*bSelect=*/false); @@ -163,7 +163,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf101534) // This failed, direct formatting was lost. CPPUNIT_ASSERT(!aSet.HasItem(RES_MARGIN_FIRSTLINE)); CPPUNIT_ASSERT(aSet.HasItem(RES_MARGIN_TEXTLEFT)); - CPPUNIT_ASSERT_EQUAL(::tools::Long(0), aSet.GetItem(RES_MARGIN_TEXTLEFT)->GetTextLeft()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aSet.GetItem(RES_MARGIN_TEXTLEFT)->ResolveTextLeft({})); } CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testExtendedSelectAllHang) diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx b/sw/qa/extras/uiwriter/uiwriter7.cxx index fdd09d358fa1..c05b7212dcc9 100644 --- a/sw/qa/extras/uiwriter/uiwriter7.cxx +++ b/sw/qa/extras/uiwriter/uiwriter7.cxx @@ -414,8 +414,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf69282) SwFrameFormat& rSourceMasterFormat = sPageDesc->GetMaster(); //Setting horizontal spaces on master SvxLRSpaceItem horizontalSpace(RES_LR_SPACE); - horizontalSpace.SetLeft(11); - horizontalSpace.SetRight(12); + horizontalSpace.SetLeft(SvxIndentValue::twips(11)); + horizontalSpace.SetRight(SvxIndentValue::twips(12)); rSourceMasterFormat.SetFormatAttr(horizontalSpace); //Setting vertical spaces on master SvxULSpaceItem verticalSpace(RES_UL_SPACE); @@ -432,17 +432,17 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf69282) SwFrameFormat& rTargetFirstLeftFormat = tPageDesc->GetFirstLeft(); //Checking horizontal spaces const SvxLRSpaceItem MasterLRSpace = rTargetMasterFormat.GetLRSpace(); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetLeft(), MasterLRSpace.GetLeft()); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetRight(), MasterLRSpace.GetRight()); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveLeft({}), MasterLRSpace.ResolveLeft({})); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveRight({}), MasterLRSpace.ResolveRight({})); const SvxLRSpaceItem LeftLRSpace = rTargetLeftFormat.GetLRSpace(); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetLeft(), LeftLRSpace.GetLeft()); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetRight(), LeftLRSpace.GetRight()); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveLeft({}), LeftLRSpace.ResolveLeft({})); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveRight({}), LeftLRSpace.ResolveRight({})); const SvxLRSpaceItem FirstMasterLRSpace = rTargetFirstMasterFormat.GetLRSpace(); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetLeft(), FirstMasterLRSpace.GetLeft()); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetRight(), FirstMasterLRSpace.GetRight()); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveLeft({}), FirstMasterLRSpace.ResolveLeft({})); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveRight({}), FirstMasterLRSpace.ResolveRight({})); const SvxLRSpaceItem FirstLeftLRSpace = rTargetFirstLeftFormat.GetLRSpace(); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetLeft(), FirstLeftLRSpace.GetLeft()); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetRight(), FirstLeftLRSpace.GetRight()); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveLeft({}), FirstLeftLRSpace.ResolveLeft({})); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveRight({}), FirstLeftLRSpace.ResolveRight({})); //Checking vertical spaces const SvxULSpaceItem MasterULSpace = rTargetMasterFormat.GetULSpace(); CPPUNIT_ASSERT_EQUAL(verticalSpace.GetUpper(), MasterULSpace.GetUpper()); @@ -474,8 +474,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf69282WithMirror) SwFrameFormat& rSourceMasterFormat = sPageDesc->GetMaster(); //Setting horizontal spaces on master SvxLRSpaceItem horizontalSpace(RES_LR_SPACE); - horizontalSpace.SetLeft(11); - horizontalSpace.SetRight(12); + horizontalSpace.SetLeft(SvxIndentValue::twips(11)); + horizontalSpace.SetRight(SvxIndentValue::twips(12)); rSourceMasterFormat.SetFormatAttr(horizontalSpace); //Setting vertical spaces on master SvxULSpaceItem verticalSpace(RES_UL_SPACE); @@ -492,19 +492,19 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf69282WithMirror) SwFrameFormat& rTargetFirstLeftFormat = tPageDesc->GetFirstLeft(); //Checking horizontal spaces const SvxLRSpaceItem MasterLRSpace = rTargetMasterFormat.GetLRSpace(); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetLeft(), MasterLRSpace.GetLeft()); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetRight(), MasterLRSpace.GetRight()); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveLeft({}), MasterLRSpace.ResolveLeft({})); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveRight({}), MasterLRSpace.ResolveRight({})); //mirror effect should be present const SvxLRSpaceItem LeftLRSpace = rTargetLeftFormat.GetLRSpace(); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetRight(), LeftLRSpace.GetLeft()); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetLeft(), LeftLRSpace.GetRight()); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveRight({}), LeftLRSpace.ResolveLeft({})); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveLeft({}), LeftLRSpace.ResolveRight({})); const SvxLRSpaceItem FirstMasterLRSpace = rTargetFirstMasterFormat.GetLRSpace(); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetLeft(), FirstMasterLRSpace.GetLeft()); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetRight(), FirstMasterLRSpace.GetRight()); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveLeft({}), FirstMasterLRSpace.ResolveLeft({})); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveRight({}), FirstMasterLRSpace.ResolveRight({})); //mirror effect should be present const SvxLRSpaceItem FirstLeftLRSpace = rTargetFirstLeftFormat.GetLRSpace(); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetRight(), FirstLeftLRSpace.GetLeft()); - CPPUNIT_ASSERT_EQUAL(horizontalSpace.GetLeft(), FirstLeftLRSpace.GetRight()); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveRight({}), FirstLeftLRSpace.ResolveLeft({})); + CPPUNIT_ASSERT_EQUAL(horizontalSpace.ResolveLeft({}), FirstLeftLRSpace.ResolveRight({})); //Checking vertical spaces const SvxULSpaceItem MasterULSpace = rTargetMasterFormat.GetULSpace(); CPPUNIT_ASSERT_EQUAL(verticalSpace.GetUpper(), MasterULSpace.GetUpper()); diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx index df3be99f9037..63c17c5b74b5 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -989,13 +989,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testInsertAutoTextIntoListFromParaStyle) CPPUNIT_ASSERT_EQUAL(u"Default Paragraph Style"_ustr, rNode.GetTextColl()->GetName()); CPPUNIT_ASSERT(rNode.GetText().startsWith("As more applicants applied")); CPPUNIT_ASSERT_EQUAL(pNumRule, rNode.GetNumRule()); - CPPUNIT_ASSERT_EQUAL(pTextLeftMargin->GetTextLeft(), - rNode.GetAttr(RES_MARGIN_TEXTLEFT).GetTextLeft()); - CPPUNIT_ASSERT_DOUBLES_EQUAL( - pFirstLineIndent->GetTextFirstLineOffsetValue(), - rNode.GetAttr(RES_MARGIN_FIRSTLINE).GetTextFirstLineOffsetValue(), 0.01); - CPPUNIT_ASSERT_EQUAL(pFirstLineIndent->GetTextFirstLineOffsetUnit(), - rNode.GetAttr(RES_MARGIN_FIRSTLINE).GetTextFirstLineOffsetUnit()); + CPPUNIT_ASSERT_EQUAL(pTextLeftMargin->ResolveTextLeft({}), + rNode.GetAttr(RES_MARGIN_TEXTLEFT).ResolveTextLeft({})); + CPPUNIT_ASSERT_EQUAL(pFirstLineIndent->ResolveTextFirstLineOffset({}), + rNode.GetAttr(RES_MARGIN_FIRSTLINE).ResolveTextFirstLineOffset({})); } pWrtShell->FwdPara(); @@ -1018,13 +1015,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testInsertAutoTextIntoListFromParaStyle) CPPUNIT_ASSERT_EQUAL(u"ListAndIndents"_ustr, rNode.GetTextColl()->GetName()); CPPUNIT_ASSERT(rNode.GetText().endsWith("as soon as we have come to a decision.")); CPPUNIT_ASSERT_EQUAL(pNumRule, rNode.GetNumRule()); - CPPUNIT_ASSERT_EQUAL(pTextLeftMargin->GetTextLeft(), - rNode.GetAttr(RES_MARGIN_TEXTLEFT).GetTextLeft()); - CPPUNIT_ASSERT_DOUBLES_EQUAL( - pFirstLineIndent->GetTextFirstLineOffsetValue(), - rNode.GetAttr(RES_MARGIN_FIRSTLINE).GetTextFirstLineOffsetValue(), 0.01); - CPPUNIT_ASSERT_EQUAL(pFirstLineIndent->GetTextFirstLineOffsetUnit(), - rNode.GetAttr(RES_MARGIN_FIRSTLINE).GetTextFirstLineOffsetUnit()); + CPPUNIT_ASSERT_EQUAL(pTextLeftMargin->ResolveTextLeft({}), + rNode.GetAttr(RES_MARGIN_TEXTLEFT).ResolveTextLeft({})); + CPPUNIT_ASSERT_EQUAL(pFirstLineIndent->ResolveTextFirstLineOffset({}), + rNode.GetAttr(RES_MARGIN_FIRSTLINE).ResolveTextFirstLineOffset({})); } pWrtShell->FwdPara(); @@ -1047,13 +1041,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testInsertAutoTextIntoListFromParaStyle) CPPUNIT_ASSERT_EQUAL(u"ListAndIndents"_ustr, rNode.GetTextColl()->GetName()); CPPUNIT_ASSERT_EQUAL(u"more"_ustr, rNode.GetText()); // pre-existing list item CPPUNIT_ASSERT_EQUAL(pNumRule, rNode.GetNumRule()); - CPPUNIT_ASSERT_EQUAL(pTextLeftMargin->GetTextLeft(), - rNode.GetAttr(RES_MARGIN_TEXTLEFT).GetTextLeft()); - CPPUNIT_ASSERT_DOUBLES_EQUAL( - pFirstLineIndent->GetTextFirstLineOffsetValue(), - rNode.GetAttr(RES_MARGIN_FIRSTLINE).GetTextFirstLineOffsetValue(), 0.01); - CPPUNIT_ASSERT_EQUAL(pFirstLineIndent->GetTextFirstLineOffsetUnit(), - rNode.GetAttr(RES_MARGIN_FIRSTLINE).GetTextFirstLineOffsetUnit()); + CPPUNIT_ASSERT_EQUAL(pTextLeftMargin->ResolveTextLeft({}), + rNode.GetAttr(RES_MARGIN_TEXTLEFT).ResolveTextLeft({})); + CPPUNIT_ASSERT_EQUAL(pFirstLineIndent->ResolveTextFirstLineOffset({}), + rNode.GetAttr(RES_MARGIN_FIRSTLINE).ResolveTextFirstLineOffset({})); } } diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index f3abe2607376..68e67fb83f18 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -143,8 +143,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf121734) CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, rFormat.GetItemState(RES_LR_SPACE, false, &pItem)); auto pLR = static_cast(pItem); CPPUNIT_ASSERT(pLR); - CPPUNIT_ASSERT_EQUAL(tools::Long(0), pLR->GetLeft()); - CPPUNIT_ASSERT_EQUAL(tools::Long(0), pLR->GetRight()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pLR->ResolveLeft({})); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pLR->ResolveRight({})); CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, rFormat.GetItemState(RES_UL_SPACE, false, &pItem)); auto pUL = static_cast(pItem); @@ -209,8 +209,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf122425_1) CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, rFormat.GetItemState(RES_LR_SPACE, false, &pItem)); auto pLR = static_cast(pItem); CPPUNIT_ASSERT(pLR); - CPPUNIT_ASSERT_EQUAL(tools::Long(0), pLR->GetLeft()); - CPPUNIT_ASSERT_EQUAL(tools::Long(0), pLR->GetRight()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pLR->ResolveLeft({})); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pLR->ResolveRight({})); CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, rFormat.GetItemState(RES_UL_SPACE, false, &pItem)); auto pUL = static_cast(pItem); diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx index eacf0e8129f0..019524a0689f 100644 --- a/sw/source/core/attr/format.cxx +++ b/sw/source/core/attr/format.cxx @@ -674,7 +674,8 @@ void SwFormat::DelDiffs( const SfxItemSet& rSet ) void SwFormat::SetPageFormatToDefault() { const sal_Int32 nSize = o3tl::convert(2, o3tl::Length::cm, o3tl::Length::twip); - SetFormatAttr(SvxLRSpaceItem(nSize, nSize, SvxIndentValue::zero(), RES_LR_SPACE)); + SetFormatAttr(SvxLRSpaceItem(SvxIndentValue::twips(nSize), SvxIndentValue::twips(nSize), + SvxIndentValue::zero(), RES_LR_SPACE)); SetFormatAttr(SvxULSpaceItem(nSize, nSize, RES_UL_SPACE)); } diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index ca2c9c371222..4af08af4c24d 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -2462,7 +2462,7 @@ bool SwCursorShell::SetShadowCursorPos( const Point& rPt, SwFillMode eFillMode ) SvxFirstLineIndentItem firstLine(pCNd->GetAttr(RES_MARGIN_FIRSTLINE)); SvxTextLeftMarginItem leftMargin(pCNd->GetAttr(RES_MARGIN_TEXTLEFT)); firstLine.SetTextFirstLineOffset(SvxIndentValue::zero()); - leftMargin.SetTextLeft(aFPos.nTabCnt); + leftMargin.SetTextLeft(SvxIndentValue::twips(aFPos.nTabCnt)); aSet.Put(firstLine); aSet.Put(leftMargin); diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx index 665f8094232e..557c278968fc 100644 --- a/sw/source/core/doc/DocumentStylePoolManager.cxx +++ b/sw/source/core/doc/DocumentStylePoolManager.cxx @@ -115,8 +115,8 @@ namespace // page style const SwFrameFormat& rPgDscFormat = rDoc.GetPageDesc( 0 ).GetMaster(); const SvxLRSpaceItem& rLR = rPgDscFormat.GetLRSpace(); - const tools::Long nLeft = rLR.GetLeft(); - const tools::Long nRight = rLR.GetRight(); + const tools::Long nLeft = rLR.ResolveLeft({}); + const tools::Long nRight = rLR.ResolveRight({}); const tools::Long nWidth = rPgDscFormat.GetFrameSize().GetWidth(); return nWidth - nLeft - nRight; } @@ -215,7 +215,7 @@ namespace firstLine.SetTextFirstLineOffset( SvxIndentValue{ static_cast(rNFormat.GetFirstLineOffset()), rNFormat.GetFirstLineOffsetUnit() }); - leftMargin.SetTextLeft(rNFormat.GetAbsLSpace()); + leftMargin.SetTextLeft(SvxIndentValue::twips(rNFormat.GetAbsLSpace())); pColl->SetFormatAttr(firstLine); pColl->SetFormatAttr(leftMargin); } @@ -234,7 +234,7 @@ namespace { sal_uInt16 nLeft = o3tl::convert(5 * nFact, o3tl::Length::mm, o3tl::Length::twip); SvxFirstLineIndentItem const firstLine(RES_MARGIN_FIRSTLINE); - SvxTextLeftMarginItem const leftMargin(nLeft, RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(nLeft), RES_MARGIN_TEXTLEFT); rSet.Put(firstLine); rSet.Put(leftMargin); if( bHeader ) @@ -260,7 +260,7 @@ namespace { SvxFirstLineIndentItem firstLine(SvxIndentValue::twips(nEZ), RES_MARGIN_FIRSTLINE); - SvxTextLeftMarginItem const leftMargin(sal_uInt16(nLeft), RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(nLeft), RES_MARGIN_TEXTLEFT); rSet.Put(firstLine); rSet.Put(leftMargin); SvxULSpaceItem aUL( RES_UL_SPACE ); @@ -714,7 +714,7 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, auto const first(o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip)); SvxFirstLineIndentItem const firstLine(SvxIndentValue::twips(first), RES_MARGIN_FIRSTLINE); - SvxTextLeftMarginItem const leftMargin(0, RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::zero(), RES_MARGIN_TEXTLEFT); aSet.Put(firstLine); aSet.Put(leftMargin); } @@ -725,7 +725,8 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, auto const left(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); SvxFirstLineIndentItem const firstLine(SvxIndentValue::twips(first), RES_MARGIN_FIRSTLINE); - SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left), + RES_MARGIN_TEXTLEFT); aSet.Put(firstLine); aSet.Put(leftMargin); @@ -738,7 +739,8 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, { auto const left(o3tl::convert(5, o3tl::Length::mm, o3tl::Length::twip)); SvxFirstLineIndentItem const firstLine(RES_MARGIN_FIRSTLINE); - SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left), + RES_MARGIN_TEXTLEFT); aSet.Put(firstLine); aSet.Put(leftMargin); } @@ -750,7 +752,8 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, auto const left(o3tl::convert(5, o3tl::Length::cm, o3tl::Length::twip)); SvxFirstLineIndentItem const firstLine(SvxIndentValue::twips(first), RES_MARGIN_FIRSTLINE); - SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left), + RES_MARGIN_TEXTLEFT); aSet.Put(firstLine); aSet.Put(leftMargin); @@ -763,7 +766,8 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, { auto const left(o3tl::convert(4, o3tl::Length::cm, o3tl::Length::twip)); SvxFirstLineIndentItem const firstLine(RES_MARGIN_FIRSTLINE); - SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left), + RES_MARGIN_TEXTLEFT); aSet.Put(firstLine); aSet.Put(leftMargin); } @@ -959,7 +963,8 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, auto const left(o3tl::convert(6, o3tl::Length::mm, o3tl::Length::twip)); SvxFirstLineIndentItem const firstLine(SvxIndentValue::twips(first), RES_MARGIN_FIRSTLINE); - SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left), + RES_MARGIN_TEXTLEFT); aSet.Put(firstLine); aSet.Put(leftMargin); @@ -1025,8 +1030,10 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, // tdf#159531: Paddings added to ease readability on comments // Left and Right margin (i.e. Before and After text indent) auto const aIndent(o3tl::convert(0.1, o3tl::Length::cm, o3tl::Length::twip)); - SvxTextLeftMarginItem const leftMargin(aIndent, RES_MARGIN_TEXTLEFT); - SvxRightMarginItem const rightMargin(aIndent, RES_MARGIN_RIGHT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(aIndent), + RES_MARGIN_TEXTLEFT); + SvxRightMarginItem const rightMargin(SvxIndentValue::twips(aIndent), + RES_MARGIN_RIGHT); aSet.Put(leftMargin); aSet.Put(rightMargin); @@ -1401,8 +1408,10 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, auto const left(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); auto const right(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); SvxFirstLineIndentItem const firstLine(RES_MARGIN_FIRSTLINE); - SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); - SvxRightMarginItem const rightMargin(right, RES_MARGIN_RIGHT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left), + RES_MARGIN_TEXTLEFT); + SvxRightMarginItem const rightMargin(SvxIndentValue::twips(right), + RES_MARGIN_RIGHT); aSet.Put(firstLine); aSet.Put(leftMargin); aSet.Put(rightMargin); @@ -1456,7 +1465,8 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, { // We indent by 1 cm. The IDs are always 2 away from each other! auto const left(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); - SvxTextLeftMarginItem const leftMargin(left, RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(left), + RES_MARGIN_TEXTLEFT); aSet.Put(leftMargin); } break; @@ -1466,7 +1476,7 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, pNewColl->SetNextTextFormatColl( *GetTextCollFromPool( RES_POOLCOLL_HTML_DD )); } // We indent by 0 cm. The IDs are always 2 away from each other! - SvxTextLeftMarginItem const leftMargin(0, RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::zero(), RES_MARGIN_TEXTLEFT); aSet.Put(leftMargin); } break; @@ -1684,7 +1694,8 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( sal_uInt16 nId ) aBox.SetLine( &aLine, SvxBoxItemLine::RIGHT ); aBox.SetAllDistances( 85 ); aSet.Put( aBox ); - aSet.Put(SvxLRSpaceItem(114, 114, SvxIndentValue::zero(), RES_LR_SPACE)); + aSet.Put(SvxLRSpaceItem(SvxIndentValue::twips(114), SvxIndentValue::twips(114), + SvxIndentValue::zero(), RES_LR_SPACE)); aSet.Put( SvxULSpaceItem( 114, 114, RES_UL_SPACE ) ); } @@ -1706,7 +1717,8 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( sal_uInt16 nId ) { aSet.Put( SwFormatAnchor( RndStdIds::FLY_AS_CHAR ) ); aSet.Put( SwFormatVertOrient( 0, text::VertOrientation::CHAR_CENTER, text::RelOrientation::FRAME ) ); - aSet.Put(SvxLRSpaceItem(0, 0, SvxIndentValue::zero(), RES_LR_SPACE)); + aSet.Put(SvxLRSpaceItem(SvxIndentValue::zero(), SvxIndentValue::zero(), + SvxIndentValue::zero(), RES_LR_SPACE)); if ( RES_POOLFRM_INLINE_HEADING == nId ) { @@ -1747,7 +1759,8 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( sal_uInt16 nId ) { aSet.Put( SwFormatAnchor( RndStdIds::FLY_AS_CHAR ) ); aSet.Put( SwFormatVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ) ); - aSet.Put(SvxLRSpaceItem(114, 114, SvxIndentValue::zero(), RES_LR_SPACE)); + aSet.Put(SvxLRSpaceItem(SvxIndentValue::twips(114), SvxIndentValue::twips(114), + SvxIndentValue::zero(), RES_LR_SPACE)); SvxProtectItem aProtect( RES_PROTECT ); aProtect.SetSizeProtect( true ); @@ -1815,13 +1828,13 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool SvxLRSpaceItem aLR( RES_LR_SPACE ); { - aLR.SetLeft(o3tl::convert(2, o3tl::Length::cm, o3tl::Length::twip)); - aLR.SetRight( aLR.GetLeft() ); + aLR.SetLeft(SvxIndentValue::twips(o3tl::convert(2, o3tl::Length::cm, o3tl::Length::twip))); + aLR.SetRight(aLR.GetLeft()); } SvxULSpaceItem aUL( RES_UL_SPACE ); { - aUL.SetUpper( o3tl::narrowing(aLR.GetLeft()) ); - aUL.SetLower( o3tl::narrowing(aLR.GetLeft()) ); + aUL.SetUpper(o3tl::narrowing(aLR.ResolveLeft({}))); + aUL.SetLower(o3tl::narrowing(aLR.ResolveLeft({}))); } SwAttrSet aSet( m_rDoc.GetAttrPool(), aPgFrameFormatSetRange ); @@ -1877,7 +1890,8 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool Size aPSize( SvxPaperInfo::GetPaperSize( PAPER_ENV_C65 ) ); LandscapeSwap( aPSize ); aSet.Put( SwFormatFrameSize( SwFrameSize::Fixed, aPSize.Width(), aPSize.Height() )); - aLR.SetLeft( 0 ); aLR.SetRight( 0 ); + aLR.SetLeft(SvxIndentValue::zero()); + aLR.SetRight(SvxIndentValue::zero()); aUL.SetUpper( 0 ); aUL.SetLower( 0 ); aSet.Put( aLR ); aSet.Put( aUL ); @@ -1890,9 +1904,10 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool case RES_POOLPAGE_HTML: // "HTML" { lcl_PutStdPageSizeIntoItemSet( m_rDoc, aSet ); - aLR.SetRight(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip)); - aUL.SetUpper( o3tl::narrowing(aLR.GetRight()) ); - aUL.SetLower( o3tl::narrowing(aLR.GetRight()) ); + aLR.SetRight( + SvxIndentValue::twips(o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip))); + aUL.SetUpper(o3tl::narrowing(aLR.ResolveRight({}))); + aUL.SetLower(o3tl::narrowing(aLR.ResolveRight({}))); aSet.Put( aLR ); aSet.Put( aUL ); diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx index 67a954510e97..b03a3558baca 100644 --- a/sw/source/core/doc/docdesc.cxx +++ b/sw/source/core/doc/docdesc.cxx @@ -109,8 +109,8 @@ static void lcl_DefaultPageFormat( sal_uInt16 nPoolFormatId, aUL.SetUpper( o3tl::narrowing(nMinTop) ); aUL.SetLower( o3tl::narrowing(nMinBottom) ); - aLR.SetRight( nMinRight ); - aLR.SetLeft( nMinLeft ); + aLR.SetRight(SvxIndentValue::twips(nMinRight)); + aLR.SetLeft(SvxIndentValue::twips(nMinLeft)); rFormat1.SetFormatAttr( aFrameSize ); rFormat1.SetFormatAttr( aLR ); diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index fe20483d963e..34772d2fd1e1 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -1703,7 +1703,8 @@ void SwDoc::MoveLeftMargin(const SwPaM& rPam, bool bRight, bool bModulus, { if (indents & ::sw::ListLevelIndents::LeftMargin) { - leftMargin.SetTextLeft(rFormat.GetIndentAt()); + leftMargin.SetTextLeft( + SvxIndentValue::twips(rFormat.GetIndentAt())); } if (indents & ::sw::ListLevelIndents::FirstLine) { @@ -1716,7 +1717,7 @@ void SwDoc::MoveLeftMargin(const SwPaM& rPam, bool bRight, bool bModulus, } } - tools::Long nNext = leftMargin.GetTextLeft(); + tools::Long nNext = leftMargin.ResolveTextLeft({}); if( bModulus ) nNext = ( nNext / nDefDist ) * nDefDist; @@ -1726,7 +1727,7 @@ void SwDoc::MoveLeftMargin(const SwPaM& rPam, bool bRight, bool bModulus, if(nNext >0) // fdo#75936 set limit for decreasing indent nNext -= nDefDist; - leftMargin.SetTextLeft( nNext ); + leftMargin.SetTextLeft(SvxIndentValue::twips(nNext)); SwRegHistory aRegH( pTNd, *pTNd, pHistory ); pTNd->SetAttr(firstLine); diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx index 353048fcb7c8..cbb95cfd162e 100644 --- a/sw/source/core/doc/fmtcol.cxx +++ b/sw/source/core/doc/fmtcol.cxx @@ -251,10 +251,10 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH // We had a relative value -> recalculate if (100 != pOldFirstLineIndent->GetPropTextFirstLineOffset()) { - const double dOld = pOldFirstLineIndent->GetTextFirstLineOffsetValue(); + const auto stOld = pOldFirstLineIndent->GetTextFirstLineOffset(); aNew.SetTextFirstLineOffset(pNewFirstLineIndent->GetTextFirstLineOffset(), pOldFirstLineIndent->GetPropTextFirstLineOffset()); - bChg = dOld != aNew.GetTextFirstLineOffsetValue(); + bChg = (stOld != aNew.GetTextFirstLineOffset()); } if( bChg ) { @@ -274,10 +274,10 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH if (100 != pOldTextLeftMargin->GetPropLeft()) { // note: changing from Left to TextLeft - looked wrong with Left - const tools::Long nOld = pOldTextLeftMargin->GetTextLeft(); + const auto stOld = pOldTextLeftMargin->GetTextLeft(); aNew.SetTextLeft(pNewTextLeftMargin->GetTextLeft(), pOldTextLeftMargin->GetPropLeft()); - bChg = nOld != aNew.GetTextLeft(); + bChg = (stOld != aNew.GetTextLeft()); } if( bChg ) { @@ -296,9 +296,9 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH // We had a relative value -> recalculate if (100 != pOldRightMargin->GetPropRight()) { - const tools::Long nOld = pOldRightMargin->GetRight(); + const auto stOld = pOldRightMargin->GetRight(); aNew.SetRight(pNewRightMargin->GetRight(), pOldRightMargin->GetPropRight()); - bChg = nOld != aNew.GetRight(); + bChg = (stOld != aNew.GetRight()); } if( bChg ) { diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index bc1333591853..f0a1ece6f00e 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -2654,12 +2654,12 @@ bool SwTable::SetColWidth( SwTableBox& rCurrentBox, TableChgWidthHeightType eTyp { // silence -Wsign-compare on Android with the static cast bRet = rSz.GetWidth() < static_cast(USHRT_MAX) - nRelDiff; - bChgLRSpace = bLeft ? rLR.GetLeft() >= nAbsDiff - : rLR.GetRight() >= nAbsDiff; + bChgLRSpace = bLeft ? rLR.ResolveLeft({}) >= nAbsDiff + : rLR.ResolveRight({}) >= nAbsDiff; } else - bRet = bLeft ? rLR.GetLeft() >= nAbsDiff - : rLR.GetRight() >= nAbsDiff; + bRet = bLeft ? rLR.ResolveLeft({}) >= nAbsDiff + : rLR.ResolveRight({}) >= nAbsDiff; if( !bRet ) { @@ -2714,21 +2714,25 @@ bool SwTable::SetColWidth( SwTableBox& rCurrentBox, TableChgWidthHeightType eTyp } if( bLeft ) - aLR.SetLeft( sal_uInt16( aLR.GetLeft() - nAbsDiff ) ); + aLR.SetLeft( + SvxIndentValue::twips(sal_uInt16(aLR.ResolveLeft({}) - nAbsDiff))); else - aLR.SetRight( sal_uInt16( aLR.GetRight() - nAbsDiff ) ); + aLR.SetRight( + SvxIndentValue::twips(sal_uInt16(aLR.ResolveRight({}) - nAbsDiff))); } else if( bLeft ) - aLR.SetLeft( sal_uInt16( aLR.GetLeft() + nAbsDiff ) ); + aLR.SetLeft(SvxIndentValue::twips(sal_uInt16(aLR.ResolveLeft({}) + nAbsDiff))); else - aLR.SetRight( sal_uInt16( aLR.GetRight() + nAbsDiff ) ); + aLR.SetRight( + SvxIndentValue::twips(sal_uInt16(aLR.ResolveRight({}) + nAbsDiff))); if( bChgLRSpace ) GetFrameFormat()->SetFormatAttr( aLR ); const SwFormatHoriOrient& rHOri = GetFrameFormat()->GetHoriOrient(); - if( text::HoriOrientation::FULL == rHOri.GetHoriOrient() || - (text::HoriOrientation::LEFT == rHOri.GetHoriOrient() && aLR.GetLeft()) || - (text::HoriOrientation::RIGHT == rHOri.GetHoriOrient() && aLR.GetRight())) + if (text::HoriOrientation::FULL == rHOri.GetHoriOrient() + || (text::HoriOrientation::LEFT == rHOri.GetHoriOrient() && aLR.ResolveLeft({})) + || (text::HoriOrientation::RIGHT == rHOri.GetHoriOrient() + && aLR.ResolveRight({}))) { SwFormatHoriOrient aHOri( rHOri ); aHOri.SetHoriOrient( text::HoriOrientation::NONE ); @@ -2758,9 +2762,10 @@ bool SwTable::SetColWidth( SwTableBox& rCurrentBox, TableChgWidthHeightType eTyp else aSz.SetWidth( aSz.GetWidth() - nRelDiff ); - if( rSz.GetWidthPercent() ) - aSz.SetWidthPercent( static_cast(( aSz.GetWidth() * 100 ) / - ( aSz.GetWidth() + aLR.GetRight() + aLR.GetLeft()))); + if (rSz.GetWidthPercent()) + aSz.SetWidthPercent(static_cast( + (aSz.GetWidth() * 100) + / (aSz.GetWidth() + aLR.ResolveRight({}) + aLR.ResolveLeft({})))); GetFrameFormat()->SetFormatAttr( aSz ); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 9ef42c1ba407..653bc2849624 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -1370,7 +1370,7 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb // tdf#152142: For RTL, positioning is relative to the right if (pShape->GetLayoutDir() == SwFrameFormat::HORI_R2L) { - auto nRightSpace = pShape->GetLRSpace().GetRight(); + auto nRightSpace = pShape->GetLRSpace().ResolveRight({}); const bool bMSOLayout = pFormat->getIDocumentSettingAccess().get( DocumentSettingId::DO_NOT_MIRROR_RTL_DRAW_OBJS); @@ -1387,7 +1387,7 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape, SdrObject* pOb } else { - auto nLeftSpace = pShape->GetLRSpace().GetLeft(); + auto nLeftSpace = pShape->GetLRSpace().ResolveLeft({}); aNewHOri.SetPos(aRect.Left() + nLeftSpace + (bIsGroupObj ? pObj->GetRelativePos().getX() : 0)); } diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 39608e359739..726cb36a894d 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -431,8 +431,9 @@ const SwTable* SwDoc::InsertTable( const SwInsertTableOptions& rInsTableOpts, { sal_uInt16 nFrameWidth = nLastPos; nLastPos = (*pColArr)[ pColArr->size()-2 ]; - pTableFormat->SetFormatAttr(SvxLRSpaceItem(nSttPos, nFrameWidth - nLastPos, - SvxIndentValue::zero(), RES_LR_SPACE)); + pTableFormat->SetFormatAttr(SvxLRSpaceItem( + SvxIndentValue::twips(nSttPos), SvxIndentValue::twips(nFrameWidth - nLastPos), + SvxIndentValue::zero(), RES_LR_SPACE)); } nWidth = nLastPos - nSttPos; } diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index df598d501a4e..df1346d7dadd 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -1486,10 +1486,10 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel ) nLeftTextPos -= m_pCurTextFrame->GetTextNodeForParaProps() ->GetSwAttrSet() .GetTextLeftMargin() - .GetLeft(m_pCurTextFrame->GetTextNodeForParaProps() - ->GetSwAttrSet() - .GetFirstLineIndent(), - /*metrics*/ {}); + .ResolveLeft(m_pCurTextFrame->GetTextNodeForParaProps() + ->GetSwAttrSet() + .GetFirstLineIndent(), + /*metrics*/ {}); } if( m_bMoreLines ) @@ -2516,10 +2516,10 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags aFlags, // Unit conversion is not needed here: check the sign only double dIndentValue = 0.0; if (pFirstLineIndent) - dIndentValue = pFirstLineIndent->GetTextFirstLineOffsetValue(); + dIndentValue = pFirstLineIndent->GetTextFirstLineOffset().m_dValue; if (0.0 != dIndentValue - || (pTextLeftMargin && 0 != pTextLeftMargin->GetTextLeft())) + || (pTextLeftMargin && (0.0 != pTextLeftMargin->GetTextLeft().m_dValue))) { // exception: numbering/enumeration can have an indentation if (IsEnumericChar(*m_pCurTextFrame)) @@ -2542,7 +2542,9 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags aFlags, BuildIndent(); else if (0.0 > dIndentValue) // negative 1st line indentation BuildNegIndent( aFInfo.GetLineStart() ); - else if (pTextLeftMargin && pTextLeftMargin->GetTextLeft() != 0) // is indentation + else if (pTextLeftMargin + && (pTextLeftMargin->GetTextLeft().m_dValue + != 0.0)) // is indentation BuildTextIndent(); } eStat = READ_NEXT_PARA; @@ -2760,11 +2762,12 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags aFlags, // Unit conversion is not needed here: check the sign only double dIndentValue = 0.0; if (pFirstLineIndent) - dIndentValue = pFirstLineIndent->GetTextFirstLineOffsetValue(); + dIndentValue = pFirstLineIndent->GetTextFirstLineOffset().m_dValue; if (bReplaceStyles && (0.0 != dIndentValue - || (pTextLeftMargin && 0 != pTextLeftMargin->GetTextLeft()))) + || (pTextLeftMargin + && (0.0 != pTextLeftMargin->GetTextLeft().m_dValue)))) { // then use one of our templates if (0.0 < dIndentValue) // positive 1st line indentation @@ -2773,7 +2776,9 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFormatFlags aFlags, { BuildNegIndent( aFInfo.GetLineStart() ); } - else if (pTextLeftMargin && pTextLeftMargin->GetTextLeft()) // is indentation + else if (pTextLeftMargin + && (0.0 + != pTextLeftMargin->GetTextLeft().m_dValue)) // is indentation BuildTextIndent(); else BuildText(); diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index d2ccd73b7bbc..0c0478750c1e 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -511,7 +511,7 @@ bool SwEditShell::IsMoveLeftMargin( bool bRight, bool bModulus ) const const SvxLRSpaceItem& rLS = pCNd->GetAttr( RES_LR_SPACE ); if( bRight ) { - tools::Long nNext = rLS.GetTextLeft() + nDefDist; + tools::Long nNext = rLS.ResolveTextLeft({}) + nDefDist; if( bModulus ) nNext = ( nNext / nDefDist ) * nDefDist; SwFrame* pFrame = pCNd->getLayoutFrame( GetLayout() ); diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx index 59ebbcbe27de..bf0efef7ae8a 100644 --- a/sw/source/core/layout/anchoredobject.cxx +++ b/sw/source/core/layout/anchoredobject.cxx @@ -581,9 +581,9 @@ const SwRect& SwAnchoredObject::GetObjRectWithSpaces() const maObjRectWithSpaces.Top(std::max( maObjRectWithSpaces.Top() - tools::Long(rUL.GetUpper()), tools::Long(0))); maObjRectWithSpaces.Left( - std::max(maObjRectWithSpaces.Left() - rLR.GetLeft(), tools::Long(0))); + std::max(maObjRectWithSpaces.Left() - rLR.ResolveLeft({}), tools::Long(0))); maObjRectWithSpaces.AddHeight(rUL.GetLower()); - maObjRectWithSpaces.AddWidth(rLR.GetRight()); + maObjRectWithSpaces.AddWidth(rLR.ResolveRight({})); } mbObjRectWithSpacesValid = true; diff --git a/sw/source/core/layout/colfrm.cxx b/sw/source/core/layout/colfrm.cxx index e29b295c46da..8b6aa8b60a3b 100644 --- a/sw/source/core/layout/colfrm.cxx +++ b/sw/source/core/layout/colfrm.cxx @@ -389,23 +389,23 @@ void SwLayoutFrame::AdjustColumns( const SwFormatCol *pAttr, bool bAdjustAttribu const sal_uInt16 nLeft = pC->GetLeft(); const sal_uInt16 nRight = pC->GetRight(); - aLR.SetLeft ( nLeft ); - aLR.SetRight( nRight ); + aLR.SetLeft(SvxIndentValue::twips(nLeft)); + aLR.SetRight(SvxIndentValue::twips(nRight)); if ( bLine ) { if ( i == 0 ) { - aLR.SetRight( std::max( nRight, nMin ) ); + aLR.SetRight(SvxIndentValue::twips(std::max(nRight, nMin))); } else if ( i == pAttr->GetNumCols() - 1 ) { - aLR.SetLeft ( std::max( nLeft, nMin ) ); + aLR.SetLeft(SvxIndentValue::twips(std::max(nLeft, nMin))); } else { - aLR.SetLeft ( std::max( nLeft, nMin ) ); - aLR.SetRight( std::max( nRight, nMin ) ); + aLR.SetLeft(SvxIndentValue::twips(std::max(nLeft, nMin))); + aLR.SetRight(SvxIndentValue::twips(std::max(nRight, nMin))); } } @@ -419,7 +419,7 @@ void SwLayoutFrame::AdjustColumns( const SwFormatCol *pAttr, bool bAdjustAttribu static_cast(pCol)->GetFormat()->SetFormatAttr( aUL ); } - nGutter += aLR.GetLeft() + aLR.GetRight(); + nGutter += aLR.ResolveLeft({}) + aLR.ResolveRight({}); } pCol = bR2L ? pCol->GetPrev() : pCol->GetNext(); @@ -438,7 +438,7 @@ void SwLayoutFrame::AdjustColumns( const SwFormatCol *pAttr, bool bAdjustAttribu else { SvxLRSpaceItem aLR( pCol->GetAttrSet()->GetLRSpace() ); - nWidth = nInnerWidth + aLR.GetLeft() + aLR.GetRight(); + nWidth = nInnerWidth + aLR.ResolveLeft({}) + aLR.ResolveRight({}); } if( nWidth < 0 ) nWidth = 0; diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 98e10b4d1c83..cee12b59818b 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -982,8 +982,8 @@ void SwFlyFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew, aOld.Top( std::max( aOld.Top() - tools::Long(rUL.GetUpper()), tools::Long(0) ) ); aOld.AddHeight(rUL.GetLower() ); const SvxLRSpaceItem &rLR = static_cast(pOld)->pChangedFormat->GetLRSpace(); - aOld.Left ( std::max( aOld.Left() - rLR.GetLeft(), tools::Long(0) ) ); - aOld.AddWidth(rLR.GetRight() ); + aOld.Left(std::max(aOld.Left() - rLR.ResolveLeft({}), tools::Long(0))); + aOld.AddWidth(rLR.ResolveRight({})); aNew.Union( aOld ); NotifyBackground( FindPageFrame(), aNew, PrepareHint::Clear ); @@ -1106,8 +1106,8 @@ void SwFlyFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew, else { const SvxLRSpaceItem &rLR = *static_cast(pNew); - aOld.Left ( std::max( aOld.Left() - rLR.GetLeft(), tools::Long(0) ) ); - aOld.AddWidth(rLR.GetRight() ); + aOld.Left(std::max(aOld.Left() - rLR.ResolveLeft({}), tools::Long(0))); + aOld.AddWidth(rLR.ResolveRight({})); } } aNew.Union( aOld ); @@ -3018,7 +3018,7 @@ static SwTwips lcl_CalcAutoWidth( const SwLayoutFrame& rFrame ) SvxRightMarginItem const& rRightMargin(rParaSet.GetRightMargin()); if (!static_cast(pFrame)->IsLocked()) { - nMin += rRightMargin.GetRight() + rLeftMargin.GetTextLeft() + nMin += rRightMargin.ResolveRight({}) + rLeftMargin.ResolveTextLeft({}) + rFirstLine.ResolveTextFirstLineOffset({}); } } diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 2ccb8b34116d..7dadcfaa9cde 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -2351,17 +2351,19 @@ tools::Long SwBorderAttrs::CalcRight( const SwFrame* pCaller ) const // for paragraphs, "left" is "before text" and "right" is "after text" if (pCaller->IsTextFrame()) { + // tdf#163913: Only apply the fixed-width part of the margin here. + // Font-relative margins will be applied as an adjustment later on. if (pCaller->IsRightToLeft()) { - nRight += m_pTextLeftMargin->GetLeft(*m_pFirstLineIndent, /*metrics*/ {}); + nRight += m_pTextLeftMargin->ResolveLeftFixedPart(*m_pFirstLineIndent); } else { - nRight += m_pRightMargin->GetRight(); + nRight += m_pRightMargin->ResolveRightFixedPart(); } } else - nRight += m_xLR->GetRight(); + nRight += m_xLR->ResolveRight({}); // correction: retrieve left margin for numbering in R2L-layout if ( pCaller->IsTextFrame() && pCaller->IsRightToLeft() ) @@ -2402,16 +2404,23 @@ tools::Long SwBorderAttrs::CalcLeft( const SwFrame *pCaller ) const } // for paragraphs, "left" is "before text" and "right" is "after text" - if ( pCaller->IsTextFrame() && pCaller->IsRightToLeft() ) - nLeft += m_pRightMargin->GetRight(); + + // tdf#163913: Only apply the fixed-width part of the margin here. + // Font-relative margins will be applied as an adjustment later on. + if (pCaller->IsTextFrame() && pCaller->IsRightToLeft()) + { + nLeft += m_pRightMargin->ResolveRightFixedPart(); + } else { if (pCaller->IsTextFrame()) { - nLeft += m_pTextLeftMargin->GetLeft(*m_pFirstLineIndent, /*metrics*/ {}); + nLeft += m_pTextLeftMargin->ResolveLeftFixedPart(*m_pFirstLineIndent); } else - nLeft += m_xLR->GetLeft(); + { + nLeft += m_xLR->ResolveLeft({}); + } } // correction: do not retrieve left margin for numbering in R2L-layout @@ -3249,8 +3258,8 @@ void Notify( SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect aFrame( pFly->GetObjRectWithSpaces() ); if ( rOld.Pos() != aFrame.Pos() ) { // changed position, invalidate old and new area - if ( rOld.HasArea() && - rOld.Left()+pFly->GetFormat()->GetLRSpace().GetLeft() < FAR_AWAY ) + if (rOld.HasArea() + && rOld.Left() + pFly->GetFormat()->GetLRSpace().ResolveLeft({}) < FAR_AWAY) { pFly->NotifyBackground( pOld, rOld, PrepareHint::FlyFrameLeave ); } diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx index fa408703e8bd..1c0ad58f24b6 100644 --- a/sw/source/core/layout/pagedesc.cxx +++ b/sw/source/core/layout/pagedesc.cxx @@ -176,8 +176,8 @@ void SwPageDesc::Mirror() //Only the margins are mirrored, all other values are just copied. SvxLRSpaceItem aLR( RES_LR_SPACE ); const SvxLRSpaceItem &rLR = m_Master.GetLRSpace(); - aLR.SetLeft( rLR.GetRight() ); - aLR.SetRight( rLR.GetLeft() ); + aLR.SetLeft(rLR.GetRight()); + aLR.SetRight(rLR.GetLeft()); aLR.SetRightGutterMargin(rLR.GetGutterMargin()); SfxItemSet aSet( *m_Master.GetAttrSet().GetPool(), diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx index d67c2b931650..0e2cf8d0463b 100644 --- a/sw/source/core/layout/sectfrm.cxx +++ b/sw/source/core/layout/sectfrm.cxx @@ -139,8 +139,8 @@ void SwSectionFrame::Init() { SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this); - aRectFnSet.SetLeft( aPrt, rLRSpace.GetLeft() ); - aRectFnSet.SetWidth( aPrt, nWidth - rLRSpace.GetLeft() - rLRSpace.GetRight() ); + aRectFnSet.SetLeft(aPrt, rLRSpace.ResolveLeft({})); + aRectFnSet.SetWidth(aPrt, nWidth - rLRSpace.ResolveLeft({}) - rLRSpace.ResolveRight({})); aRectFnSet.SetHeight( aPrt, 0 ); } @@ -1453,7 +1453,7 @@ void SwSectionFrame::Format( vcl::RenderContext* pRenderContext, const SwBorderA // #109700# LRSpace for sections const SvxLRSpaceItem& rLRSpace = GetFormat()->GetLRSpace(); - aRectFnSet.SetXMargins( *this, rLRSpace.GetLeft(), rLRSpace.GetRight() ); + aRectFnSet.SetXMargins(*this, rLRSpace.ResolveLeft({}), rLRSpace.ResolveRight({})); if( nUpper != aRectFnSet.GetTopMargin(*this) ) { @@ -1515,7 +1515,8 @@ void SwSectionFrame::Format( vcl::RenderContext* pRenderContext, const SwBorderA { const SvxLRSpaceItem& rLRSpace = GetFormat()->GetLRSpace(); SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this); - aRectFnSet.SetWidth( aPrt, nWidth - rLRSpace.GetLeft() - rLRSpace.GetRight() ); + aRectFnSet.SetWidth(aPrt, + nWidth - rLRSpace.ResolveLeft({}) - rLRSpace.ResolveRight({})); } // OD 15.10.2002 #103517# - allow grow in online layout diff --git a/sw/source/core/objectpositioning/anchoredobjectposition.cxx b/sw/source/core/objectpositioning/anchoredobjectposition.cxx index 667a88b9a9ec..c00002a4797e 100644 --- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx @@ -388,10 +388,9 @@ SwTwips SwAnchoredObjectPosition::GetVertRelPos( break; case text::VertOrientation::TOP: { - nRelPosY += aRectFnSet.IsVert() - ? ( aRectFnSet.IsVertL2R() - ? _rLRSpacing.GetLeft() - : _rLRSpacing.GetRight() ) + nRelPosY += aRectFnSet.IsVert() + ? (aRectFnSet.IsVertL2R() ? _rLRSpacing.ResolveLeft({}) + : _rLRSpacing.ResolveRight({})) : _rULSpacing.GetUpper(); } break; @@ -402,12 +401,12 @@ SwTwips SwAnchoredObjectPosition::GetVertRelPos( break; case text::VertOrientation::BOTTOM: { - nRelPosY += nAlignAreaHeight - - ( nObjHeight + ( aRectFnSet.IsVert() - ? ( aRectFnSet.IsVertL2R() - ? _rLRSpacing.GetRight() - : _rLRSpacing.GetLeft() ) - : _rULSpacing.GetLower() ) ); + nRelPosY += nAlignAreaHeight + - (nObjHeight + + (aRectFnSet.IsVert() + ? (aRectFnSet.IsVertL2R() ? _rLRSpacing.ResolveRight({}) + : _rLRSpacing.ResolveLeft({})) + : _rULSpacing.GetLower())); } break; default: @@ -923,12 +922,13 @@ SwTwips SwAnchoredObjectPosition::CalcRelPosX( } else if ( text::HoriOrientation::CENTER == eHoriOrient ) nRelPosX += (nWidth / 2) - (nObjWidth / 2); - else if ( text::HoriOrientation::RIGHT == eHoriOrient ) - nRelPosX += nWidth - - ( nObjWidth + - ( aRectFnSet.IsVert() ? _rULSpacing.GetLower() : _rLRSpacing.GetRight() ) ); + else if (text::HoriOrientation::RIGHT == eHoriOrient) + nRelPosX + += nWidth + - (nObjWidth + + (aRectFnSet.IsVert() ? _rULSpacing.GetLower() : _rLRSpacing.ResolveRight({}))); else - nRelPosX += aRectFnSet.IsVert() ? _rULSpacing.GetUpper() : _rLRSpacing.GetLeft(); + nRelPosX += aRectFnSet.IsVert() ? _rULSpacing.GetUpper() : _rLRSpacing.ResolveLeft({}); // adjust relative position by distance between anchor frame and // the frame, the object is oriented at. @@ -1070,31 +1070,34 @@ SwTwips SwAnchoredObjectPosition::AdjustHoriRelPosForDrawAside( else { const SvxLRSpaceItem& rOtherLR = pFly->GetFormat()->GetLRSpace(); - const SwTwips nOtherLeft = pFly->getFrameArea().Left() - rOtherLR.GetLeft(); - const SwTwips nOtherRight = pFly->getFrameArea().Right() + rOtherLR.GetRight(); - if( nOtherLeft <= aTmpObjRect.Right() + _rLRSpacing.GetRight() && - nOtherRight >= aTmpObjRect.Left() - _rLRSpacing.GetLeft() ) + const SwTwips nOtherLeft = pFly->getFrameArea().Left() - rOtherLR.ResolveLeft({}); + const SwTwips nOtherRight + = pFly->getFrameArea().Right() + rOtherLR.ResolveRight({}); + if (nOtherLeft <= aTmpObjRect.Right() + _rLRSpacing.ResolveRight({}) + && nOtherRight >= aTmpObjRect.Left() - _rLRSpacing.ResolveLeft({})) { if ( _eHoriOrient == text::HoriOrientation::LEFT ) { - SwTwips nTmp = nOtherRight + 1 + _rLRSpacing.GetLeft() - - rAnchorTextFrame.getFrameArea().Left(); - if ( nTmp > nAdjustedRelPosX && - rAnchorTextFrame.getFrameArea().Left() + nTmp + - aObjBoundRect.Width() + _rLRSpacing.GetRight() - <= pObjPage->getFrameArea().Width() + pObjPage->getFrameArea().Left() ) + SwTwips nTmp = nOtherRight + 1 + _rLRSpacing.ResolveLeft({}) + - rAnchorTextFrame.getFrameArea().Left(); + if (nTmp > nAdjustedRelPosX + && rAnchorTextFrame.getFrameArea().Left() + nTmp + aObjBoundRect.Width() + + _rLRSpacing.ResolveRight({}) + <= pObjPage->getFrameArea().Width() + + pObjPage->getFrameArea().Left()) { nAdjustedRelPosX = nTmp; } } else if ( _eHoriOrient == text::HoriOrientation::RIGHT ) { - SwTwips nTmp = nOtherLeft - 1 - _rLRSpacing.GetRight() - - aObjBoundRect.Width() - - rAnchorTextFrame.getFrameArea().Left(); - if ( nTmp < nAdjustedRelPosX && - rAnchorTextFrame.getFrameArea().Left() + nTmp - _rLRSpacing.GetLeft() - >= pObjPage->getFrameArea().Left() ) + SwTwips nTmp = nOtherLeft - 1 - _rLRSpacing.ResolveRight({}) + - aObjBoundRect.Width() + - rAnchorTextFrame.getFrameArea().Left(); + if (nTmp < nAdjustedRelPosX + && rAnchorTextFrame.getFrameArea().Left() + nTmp + - _rLRSpacing.ResolveLeft({}) + >= pObjPage->getFrameArea().Left()) { nAdjustedRelPosX = nTmp; } diff --git a/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx b/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx index e82659ccd59f..4a44cc109e36 100644 --- a/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx @@ -106,20 +106,20 @@ void SwAsCharAnchoredObjectPosition::CalcPosition() // convert the spacing values nLRSpaceLeft = rULSpace.GetUpper(); nLRSpaceRight = rULSpace.GetLower(); - nULSpaceUpper = rLRSpace.GetRight(); - nULSpaceLower = rLRSpace.GetLeft(); + nULSpaceUpper = rLRSpace.ResolveRight({}); + nULSpaceLower = rLRSpace.ResolveLeft({}); } else { if ( rAnchorFrame.IsRightToLeft() ) { - nLRSpaceLeft = rLRSpace.GetRight(); - nLRSpaceRight = rLRSpace.GetLeft(); + nLRSpaceLeft = rLRSpace.ResolveRight({}); + nLRSpaceRight = rLRSpace.ResolveLeft({}); } else { - nLRSpaceLeft = rLRSpace.GetLeft(); - nLRSpaceRight = rLRSpace.GetRight(); + nLRSpaceLeft = rLRSpace.ResolveLeft({}); + nLRSpaceRight = rLRSpace.ResolveRight({}); } nULSpaceUpper = rULSpace.GetUpper(); @@ -308,8 +308,8 @@ void SwAsCharAnchoredObjectPosition::CalcPosition() { // recalculate object bound rectangle, if object width has changed. aObjBoundRect = GetAnchoredObj().GetObjRect(); - aObjBoundRect.AddLeft( - rLRSpace.GetLeft() ); - aObjBoundRect.AddWidth( rLRSpace.GetRight() ); + aObjBoundRect.AddLeft(-rLRSpace.ResolveLeft({})); + aObjBoundRect.AddWidth(rLRSpace.ResolveRight({})); aObjBoundRect.AddTop( - rULSpace.GetUpper() ); aObjBoundRect.AddHeight( rULSpace.GetLower() ); } diff --git a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx index f5d7a79f9de8..9ffb25400fd7 100644 --- a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx @@ -307,17 +307,15 @@ void SwToContentAnchoredObjectPosition::CalcPosition() // determine relative vertical position SwTwips nRelPosY = nAlignAreaOffset; const SwTwips nObjHeight = aRectFnSet.GetHeight(aObjBoundRect); - const SwTwips nUpperSpace = aRectFnSet.IsVert() - ? ( aRectFnSet.IsVertL2R() - ? rLR.GetLeft() - : rLR.GetRight() ) - : rUL.GetUpper(); + const SwTwips nUpperSpace + = aRectFnSet.IsVert() + ? (aRectFnSet.IsVertL2R() ? rLR.ResolveLeft({}) : rLR.ResolveRight({})) + : rUL.GetUpper(); // --> OD 2009-08-31 #monglianlayout# - const SwTwips nLowerSpace = aRectFnSet.IsVert() - ? ( aRectFnSet.IsVertL2R() - ? rLR.GetLeft() - : rLR.GetRight() ) - : rUL.GetLower(); + const SwTwips nLowerSpace + = aRectFnSet.IsVert() + ? (aRectFnSet.IsVertL2R() ? rLR.ResolveLeft({}) : rLR.ResolveRight({})) + : rUL.GetLower(); switch ( aVert.GetVertOrient() ) { case text::VertOrientation::CHAR_BOTTOM: diff --git a/sw/source/core/objectpositioning/tolayoutanchoredobjectposition.cxx b/sw/source/core/objectpositioning/tolayoutanchoredobjectposition.cxx index 3e7d98bf7aaa..04d94185d755 100644 --- a/sw/source/core/objectpositioning/tolayoutanchoredobjectposition.cxx +++ b/sw/source/core/objectpositioning/tolayoutanchoredobjectposition.cxx @@ -172,11 +172,12 @@ void SwToLayoutAnchoredObjectPosition::CalcPosition() } else if ( text::HoriOrientation::CENTER == eHoriOrient ) nRelPosX = (nWidth / 2) - (nObjWidth / 2); - else if ( text::HoriOrientation::RIGHT == eHoriOrient ) - nRelPosX = nWidth - ( nObjWidth + - ( aRectFnSet.IsVert() ? rUL.GetLower() : rLR.GetRight() ) ); + else if (text::HoriOrientation::RIGHT == eHoriOrient) + nRelPosX + = nWidth + - (nObjWidth + (aRectFnSet.IsVert() ? rUL.GetLower() : rLR.ResolveRight({}))); else - nRelPosX = aRectFnSet.IsVert() ? rUL.GetUpper() : rLR.GetLeft(); + nRelPosX = aRectFnSet.IsVert() ? rUL.GetUpper() : rLR.ResolveLeft({}); nRelPosX += nOffset; // no 'negative' relative horizontal position diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index bad44b2b04dc..8bd4ed50a63c 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -854,8 +854,8 @@ void SwTable::SetTabCols( const SwTabCols &rNew, const SwTabCols &rOld, SwTwips nShRight = aSh.CalcShadowSpace( SvxShadowItemSide::RIGHT ); SwTwips nShLeft = aSh.CalcShadowSpace( SvxShadowItemSide::LEFT ); - aLR.SetLeft ( rNew.GetLeft() - nShLeft ); - aLR.SetRight( rNew.GetRightMax() - rNew.GetRight() - nShRight ); + aLR.SetLeft(SvxIndentValue::twips(rNew.GetLeft() - nShLeft)); + aLR.SetRight(SvxIndentValue::twips(rNew.GetRightMax() - rNew.GetRight() - nShRight)); pFormat->SetFormatAttr( aLR ); // The alignment of the table needs to be adjusted accordingly. diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx index 7961e14a58ff..e80a0b354f16 100644 --- a/sw/source/core/text/frmcrsr.cxx +++ b/sw/source/core/text/frmcrsr.cxx @@ -1483,9 +1483,9 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const rRect.Top( rRect.Top() + nFirst ); rRect.Height( nLineHeight ); - SwTwips nLeft = rFill.Left() + rTextLeftMargin.GetLeft(rFirstLine, /*metrics*/ {}) + SwTwips nLeft = rFill.Left() + rTextLeftMargin.ResolveLeft(rFirstLine, /*metrics*/ {}) + GetTextNodeForParaProps()->GetLeftMarginWithNum(); - SwTwips nRight = rFill.Right() - rRightMargin.GetRight(); + SwTwips nRight = rFill.Right() - rRightMargin.ResolveRight({}); SwTwips nCenter = ( nLeft + nRight ) / 2; rRect.Left( nLeft ); if( SwFillMode::Margin == rFill.Mode() ) @@ -1555,8 +1555,8 @@ void SwTextFrame::FillCursorPos( SwFillData& rFill ) const } else if( rFill.X() > nLeft ) { - SwTwips nTextLeft = rFill.Left() + rTextLeftMargin.GetTextLeft() + - GetTextNodeForParaProps()->GetLeftMarginWithNum(true); + SwTwips nTextLeft = rFill.Left() + rTextLeftMargin.ResolveTextLeft({}) + + GetTextNodeForParaProps()->GetLeftMarginWithNum(true); rFill.nLineWidth += rFill.bFirstLine ? nLeft : nTextLeft; SwTwips nLeftTab; SwTwips nRightTab = nLeft; diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx index 54f55f45f35e..6d116cdbc156 100644 --- a/sw/source/core/text/frmpaint.cxx +++ b/sw/source/core/text/frmpaint.cxx @@ -559,7 +559,7 @@ bool SwTextFrame::PaintEmpty( const SwRect &rRect, bool bCheck ) const const SvxFirstLineIndentItem& rFirstLine( GetTextNodeForParaProps()->GetSwAttrSet().GetFirstLineIndent()); - if (0.0 < rFirstLine.GetTextFirstLineOffsetValue()) + if (0.0 < rFirstLine.GetTextFirstLineOffset().m_dValue) { aPos.AdjustX(rFirstLine.ResolveTextFirstLineOffset({})); } diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index f93b7274e257..fe94ad999ef5 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -1006,10 +1006,10 @@ static void lcl_MinMaxNode(SwFrameFormat* pNd, SwMinMaxNodeArgs& rIn) } const SvxLRSpaceItem &rLR = pNd->GetLRSpace(); - nMin += rLR.GetLeft(); - nMin += rLR.GetRight(); - nMax += rLR.GetLeft(); - nMax += rLR.GetRight(); + nMin += rLR.ResolveLeft({}); + nMin += rLR.ResolveRight({}); + nMax += rLR.ResolveLeft({}); + nMax += rLR.ResolveRight({}); if( css::text::WrapTextMode_THROUGH == pNd->GetSurround().GetSurround() ) { @@ -1082,7 +1082,7 @@ void SwTextNode::GetMinMaxSize( SwNodeOffset nIndex, sal_uLong& rMin, sal_uLong SvxTextLeftMarginItem const& rTextLeftMargin(GetSwAttrSet().GetTextLeftMargin()); SvxRightMarginItem const& rRightMargin(GetSwAttrSet().GetRightMargin()); - tools::Long nLROffset = rTextLeftMargin.GetTextLeft() + GetLeftMarginWithNum( true ); + tools::Long nLROffset = rTextLeftMargin.ResolveTextLeft({}) + GetLeftMarginWithNum(true); short nFLOffs; // For enumerations a negative first line indentation is probably filled already if (!GetFirstLineOfsWithNum(nFLOffs, {}) || nFLOffs > nLROffset) @@ -1092,7 +1092,7 @@ void SwTextNode::GetMinMaxSize( SwNodeOffset nIndex, sal_uLong& rMin, sal_uLong aNodeArgs.m_nMinWidth = 0; aNodeArgs.m_nMaxWidth = 0; aNodeArgs.m_nLeftRest = nLROffset; - aNodeArgs.m_nRightRest = rRightMargin.GetRight(); + aNodeArgs.m_nRightRest = rRightMargin.ResolveRight({}); aNodeArgs.m_nLeftDiff = 0; aNodeArgs.m_nRightDiff = 0; if( nIndex ) @@ -1112,7 +1112,7 @@ void SwTextNode::GetMinMaxSize( SwNodeOffset nIndex, sal_uLong& rMin, sal_uLong aNodeArgs.m_nMaxWidth -= aNodeArgs.m_nLeftRest; if (aNodeArgs.m_nRightRest < 0) - aNodeArgs.Minimum(rRightMargin.GetRight() - aNodeArgs.m_nRightRest); + aNodeArgs.Minimum(rRightMargin.ResolveRight({}) - aNodeArgs.m_nRightRest); aNodeArgs.m_nRightRest -= aNodeArgs.m_nRightDiff; if (aNodeArgs.m_nRightRest < 0) aNodeArgs.m_nMaxWidth -= aNodeArgs.m_nRightRest; @@ -1234,8 +1234,8 @@ void SwTextNode::GetMinMaxSize( SwNodeOffset nIndex, sal_uLong& rMin, sal_uLong else nCurrentWidth = pFrameFormat->GetFrameSize().GetWidth(); } - nCurrentWidth += rLR.GetLeft(); - nCurrentWidth += rLR.GetRight(); + nCurrentWidth += rLR.ResolveLeft({}); + nCurrentWidth += rLR.ResolveRight({}); aArg.m_nWordAdd = nOldWidth + nOldAdd; aArg.m_nWordWidth = nCurrentWidth; aArg.m_nRowWidth += nCurrentWidth; @@ -1285,7 +1285,7 @@ void SwTextNode::GetMinMaxSize( SwNodeOffset nIndex, sal_uLong& rMin, sal_uLong if (static_cast(rMax) < aArg.m_nRowWidth) rMax = aArg.m_nRowWidth; - nLROffset += rRightMargin.GetRight(); + nLROffset += rRightMargin.ResolveRight({}); rAbsMin += nLROffset; rAbsMin += nAdd; diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 6da4d23ce54d..00dfa384029f 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -165,6 +165,8 @@ void SwTextMargin::CtorInitTextMargin( SwTextFrame *pNewFrame, SwTextSizeInfo *p SvxFirstLineIndentItem const& rFirstLine(pNode->GetSwAttrSet().GetFirstLineIndent()); SvxTextLeftMarginItem const& rTextLeftMargin(pNode->GetSwAttrSet().GetTextLeftMargin()); + SvxRightMarginItem const& rRightMargin(pNode->GetSwAttrSet().GetRightMargin()); + // #i95907# // #i111284# const SwTextNode *pTextNode = m_pFrame->GetTextNodeForParaProps(); @@ -187,14 +189,13 @@ void SwTextMargin::CtorInitTextMargin( SwTextFrame *pNewFrame, SwTextSizeInfo *p if ( m_pFrame->IsRightToLeft() ) { // this calculation is identical this the calculation for L2R layout - see below - mnLeft = m_pFrame->getFrameArea().Left() + - m_pFrame->getFramePrintArea().Left() + - nLMWithNum - - pNode->GetLeftMarginWithNum() - - // #i95907# - // #i111284# - // rSpace.GetLeft() + rSpace.GetTextLeft(); - (rTextLeftMargin.GetLeft(rFirstLine, stMetrics) - rTextLeftMargin.GetTextLeft()); + mnLeft = m_pFrame->getFrameArea().Left() + m_pFrame->getFramePrintArea().Left() + nLMWithNum + - pNode->GetLeftMarginWithNum() - + // #i95907# + // #i111284# + // rSpace.GetLeft() + rSpace.GetTextLeft(); + (rTextLeftMargin.ResolveLeft(rFirstLine, stMetrics) + - rTextLeftMargin.ResolveTextLeft(stMetrics)); } else { @@ -204,31 +205,37 @@ void SwTextMargin::CtorInitTextMargin( SwTextFrame *pNewFrame, SwTextSizeInfo *p !pNode->getIDocumentSettingAccess()->get(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING) ) { // this calculation is identical this the calculation for R2L layout - see above - mnLeft = m_pFrame->getFrameArea().Left() + - m_pFrame->getFramePrintArea().Left() + - nLMWithNum - - pNode->GetLeftMarginWithNum() - - // #i95907# - // #i111284# - (rTextLeftMargin.GetLeft(rFirstLine, stMetrics) - rTextLeftMargin.GetTextLeft()); + mnLeft = m_pFrame->getFrameArea().Left() + m_pFrame->getFramePrintArea().Left() + + nLMWithNum - pNode->GetLeftMarginWithNum() - + // #i95907# + // #i111284# + (rTextLeftMargin.ResolveLeft(rFirstLine, stMetrics) + - rTextLeftMargin.ResolveTextLeft(stMetrics)); } else { - mnLeft = m_pFrame->getFrameArea().Left() + - std::max(tools::Long(rTextLeftMargin.GetTextLeft() + nLMWithNum), - m_pFrame->getFramePrintArea().Left() ); + mnLeft + = m_pFrame->getFrameArea().Left() + + std::max(tools::Long(rTextLeftMargin.ResolveTextLeft(stMetrics) + nLMWithNum), + m_pFrame->getFramePrintArea().Left()); } } mnRight = m_pFrame->getFrameArea().Left() + m_pFrame->getFramePrintArea().Left() + m_pFrame->getFramePrintArea().Width(); - if( mnLeft >= mnRight && - // #i53066# Omit adjustment of nLeft for numbered - // paras inside cells inside new documents: - ( pNode->getIDocumentSettingAccess()->get(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING) || - !m_pFrame->IsInTab() || - (bListLevelIndentsApplicable && nLMWithNum == rTextLeftMargin.GetTextLeft()) - || (!bLabelAlignmentActive && nLMWithNum == 0))) + // tdf#163913: Apply font-relative adjustment to the margins + mnLeft += rTextLeftMargin.ResolveLeftVariablePart(rFirstLine, stMetrics); + mnRight -= rRightMargin.ResolveRightVariablePart(stMetrics); + + if (mnLeft >= mnRight && + // #i53066# Omit adjustment of nLeft for numbered + // paras inside cells inside new documents: + (pNode->getIDocumentSettingAccess()->get( + DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING) + || !m_pFrame->IsInTab() + || (bListLevelIndentsApplicable + && nLMWithNum == rTextLeftMargin.ResolveTextLeft(stMetrics)) + || (!bLabelAlignmentActive && nLMWithNum == 0))) { mnLeft = m_pFrame->getFramePrintArea().Left() + m_pFrame->getFrameArea().Left(); if( mnLeft >= mnRight ) // e.g. with large paragraph indentations in slim table columns @@ -323,9 +330,10 @@ void SwTextMargin::CtorInitTextMargin( SwTextFrame *pNewFrame, SwTextSizeInfo *p } else { - mnFirst = m_pFrame->getFrameArea().Left() + - std::max(rTextLeftMargin.GetTextLeft() + nLMWithNum + nFirstLineOfs, - m_pFrame->getFramePrintArea().Left() ); + mnFirst = m_pFrame->getFrameArea().Left() + + std::max(rTextLeftMargin.ResolveTextLeft(stMetrics) + nLMWithNum + + nFirstLineOfs, + m_pFrame->getFramePrintArea().Left()); } // Note: returns a negative diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx index 45eea8eeee53..67a1abae2dc9 100644 --- a/sw/source/core/text/txtfly.cxx +++ b/sw/source/core/text/txtfly.cxx @@ -243,12 +243,12 @@ SwRect SwContourCache::ContourRect( const SwFormat* pFormat, } const SvxLRSpaceItem &rLRSpace = pFormat->GetLRSpace(); const SvxULSpaceItem &rULSpace = pFormat->GetULSpace(); - CacheItem item { - pObj, // due to #37347 the Object must be entered only after GetContour() - std::make_unique( aPolyPolygon, pPolyPolygon ? &*pPolyPolygon : nullptr, 20, - o3tl::narrowing(rLRSpace.GetLeft()), o3tl::narrowing(rLRSpace.GetRight()), - pFormat->GetSurround().IsOutside(), false, pFrame->IsVertical() ) - }; + CacheItem item{ pObj, // due to #37347 the Object must be entered only after GetContour() + std::make_unique( + aPolyPolygon, pPolyPolygon ? &*pPolyPolygon : nullptr, 20, + o3tl::narrowing(rLRSpace.ResolveLeft({})), + o3tl::narrowing(rLRSpace.ResolveRight({})), + pFormat->GetSurround().IsOutside(), false, pFrame->IsVertical()) }; mvItems.insert(mvItems.begin(), std::move(item)); mvItems[0].mxTextRanger->SetUpper( rULSpace.GetUpper() ); mvItems[0].mxTextRanger->SetLower( rULSpace.GetLower() ); diff --git a/sw/source/core/tox/ToxTabStopTokenHandler.cxx b/sw/source/core/tox/ToxTabStopTokenHandler.cxx index 45020252f592..7b6bcfc716ed 100644 --- a/sw/source/core/tox/ToxTabStopTokenHandler.cxx +++ b/sw/source/core/tox/ToxTabStopTokenHandler.cxx @@ -54,9 +54,9 @@ DefaultToxTabStopTokenHandler::HandleTabStopToken( SvxTextLeftMarginItem const& rTextLeftMargin( targetNode.SwContentNode::GetAttr(RES_MARGIN_TEXTLEFT)); tools::Long nTabPosition = aToken.nTabStopPosition; - if (!mTabPositionIsRelativeToParagraphIndent && rTextLeftMargin.GetTextLeft() != 0) + if (!mTabPositionIsRelativeToParagraphIndent && rTextLeftMargin.ResolveTextLeft({}) != 0) { - nTabPosition -= rTextLeftMargin.GetTextLeft(); + nTabPosition -= rTextLeftMargin.ResolveTextLeft({}); } result.tabStop = SvxTabStop(nTabPosition, aToken.eTabAlign, cDfltDecimalChar, aToken.cTabFillChar); return result; @@ -115,7 +115,7 @@ auto DefaultToxTabStopTokenHandler::CalcEndStop(SwTextNode const& rNode, SvxTextLeftMarginItem const& rTextLeftMargin( rNode.GetTextColl()->GetTextLeftMargin()); - nRightMargin -= rTextLeftMargin.GetLeft(rFirstLine, /*metrics*/ {}); + nRightMargin -= rTextLeftMargin.ResolveLeft(rFirstLine, /*metrics*/ {}); nRightMargin -= rFirstLine.ResolveTextFirstLineOffset(/*metrics*/ {}); } return nRightMargin - 1; // subtract 1 twip to avoid equal for TabOverMargin @@ -132,8 +132,9 @@ DefaultToxTabStopTokenHandler::CalculatePageMarginFromPageDescription(const SwTe pPageDesc = &mDefaultPageDescription; } const SwFrameFormat& rPgDscFormat = pPageDesc->GetMaster(); - tools::Long result = rPgDscFormat.GetFrameSize().GetWidth() - rPgDscFormat.GetLRSpace().GetLeft() - - rPgDscFormat.GetLRSpace().GetRight(); + tools::Long result = rPgDscFormat.GetFrameSize().GetWidth() + - rPgDscFormat.GetLRSpace().ResolveLeft({}) + - rPgDscFormat.GetLRSpace().ResolveRight({}); // Also consider borders const SvxBoxItem& rBox = rPgDscFormat.GetBox(); result -= rBox.CalcLineSpace(SvxBoxItemLine::LEFT) + rBox.CalcLineSpace(SvxBoxItemLine::RIGHT); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 356645f6c9d6..81dcab11db24 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -3313,7 +3313,8 @@ tools::Long SwTextNode::GetLeftMarginWithNum( bool bTextLeft ) const if( pRule->IsAbsSpaces() ) { SvxFirstLineIndentItem const& rFirst(GetSwAttrSet().GetFirstLineIndent()); - nRet = nRet - GetSwAttrSet().GetTextLeftMargin().GetLeft(rFirst, /*metrics*/ {}); + nRet + = nRet - GetSwAttrSet().GetTextLeftMargin().ResolveLeft(rFirst, /*metrics*/ {}); } } else if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) @@ -3326,11 +3327,11 @@ tools::Long SwTextNode::GetLeftMarginWithNum( bool bTextLeft ) const // list/paragraph items. (this is rather inelegant) SvxFirstLineIndentItem firstLine(GetSwAttrSet().GetFirstLineIndent()); SvxTextLeftMarginItem leftMargin(GetSwAttrSet().GetTextLeftMargin()); - nRet = bTextLeft ? -leftMargin.GetTextLeft() - : -leftMargin.GetLeft(firstLine, /*metrics*/ {}); + nRet = bTextLeft ? -leftMargin.ResolveTextLeft(/*metrics*/ {}) + : -leftMargin.ResolveLeft(firstLine, /*metrics*/ {}); if (indents & ::sw::ListLevelIndents::LeftMargin) { - leftMargin.SetTextLeft(rFormat.GetIndentAt()); + leftMargin.SetTextLeft(SvxIndentValue::twips(rFormat.GetIndentAt())); } if (indents & ::sw::ListLevelIndents::FirstLine) { @@ -3338,8 +3339,8 @@ tools::Long SwTextNode::GetLeftMarginWithNum( bool bTextLeft ) const SvxIndentValue{ static_cast(rFormat.GetFirstLineIndent()), rFormat.GetFirstLineIndentUnit() }); } - nRet += bTextLeft ? leftMargin.GetTextLeft() - : leftMargin.GetLeft(firstLine, /*metrics*/ {}); + nRet += bTextLeft ? leftMargin.ResolveTextLeft(/*metrics*/ {}) + : leftMargin.ResolveLeft(firstLine, /*metrics*/ {}); } } @@ -3402,7 +3403,8 @@ SwTwips SwTextNode::GetAdditionalIndentForStartingNewList() const { SvxFirstLineIndentItem const& rFirst(GetSwAttrSet().GetFirstLineIndent()); - nAdditionalIndent = GetSwAttrSet().GetTextLeftMargin().GetLeft(rFirst, /*metrics*/ {}); + nAdditionalIndent + = GetSwAttrSet().GetTextLeftMargin().ResolveLeft(rFirst, /*metrics*/ {}); if (getIDocumentSettingAccess()->get(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING)) { @@ -3425,10 +3427,11 @@ SwTwips SwTextNode::GetAdditionalIndentForStartingNewList() const RES_MARGIN_FIRSTLINE) : GetSwAttrSet().GetFirstLineIndent()); SvxTextLeftMarginItem const aLeft( - indents & ::sw::ListLevelIndents::LeftMargin - ? SvxTextLeftMarginItem(rFormat.GetIndentAt(), RES_MARGIN_TEXTLEFT) + indents & ::sw::ListLevelIndents::LeftMargin + ? SvxTextLeftMarginItem(SvxIndentValue::twips(rFormat.GetIndentAt()), + RES_MARGIN_TEXTLEFT) : GetSwAttrSet().GetTextLeftMargin()); - nAdditionalIndent = aLeft.GetLeft(aFirst, /*metrics*/ {}); + nAdditionalIndent = aLeft.ResolveLeft(aFirst, /*metrics*/ {}); if (!(indents & ::sw::ListLevelIndents::FirstLine)) { if (getIDocumentSettingAccess()->get(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING)) @@ -3441,7 +3444,7 @@ SwTwips SwTextNode::GetAdditionalIndentForStartingNewList() const else { SvxFirstLineIndentItem const& rFirst(GetSwAttrSet().GetFirstLineIndent()); - nAdditionalIndent = GetSwAttrSet().GetTextLeftMargin().GetLeft(rFirst, /*metrics*/ {}); + nAdditionalIndent = GetSwAttrSet().GetTextLeftMargin().ResolveLeft(rFirst, /*metrics*/ {}); } return nAdditionalIndent; @@ -3468,7 +3471,7 @@ tools::Long SwTextNode::GetLeftMarginForTabCalculation() const } if ( !bLeftMarginForTabCalcSetToListLevelIndent ) { - nLeftMarginForTabCalc = GetSwAttrSet().GetTextLeftMargin().GetTextLeft(); + nLeftMarginForTabCalc = GetSwAttrSet().GetTextLeftMargin().ResolveTextLeft({}); } return nLeftMarginForTabCalc; @@ -4784,7 +4787,7 @@ bool SwTextNode::GetListTabStopPosition( tools::Long& nListTabStopPosition ) con else if (!getIDocumentSettingAccess()->get(DocumentSettingId::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING)) { SvxTextLeftMarginItem const aItem(GetSwAttrSet().GetTextLeftMargin()); - nListTabStopPosition -= aItem.GetTextLeft(); + nListTabStopPosition -= aItem.ResolveTextLeft({}); } } } diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index a2dffac99636..77a342a09bcd 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -2143,7 +2143,8 @@ static void lcl_MergeListLevelIndentAsLRSpaceItem( const SwTextNode& rTextNode, } if (indents & ::sw::ListLevelIndents::LeftMargin) { - SvxTextLeftMarginItem const leftMargin(rFormat.GetIndentAt(), RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(rFormat.GetIndentAt()), + RES_MARGIN_TEXTLEFT); rSet.Put(leftMargin); } } diff --git a/sw/source/core/unocore/unomapproperties.hxx b/sw/source/core/unocore/unomapproperties.hxx index 2401fbc42db7..7e3f4c86216a 100644 --- a/sw/source/core/unocore/unomapproperties.hxx +++ b/sw/source/core/unocore/unomapproperties.hxx @@ -155,7 +155,9 @@ { UNO_NAME_PARA_GRAPHIC_FILTER, RES_BACKGROUND, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_GRAPHIC_FILTER }, \ { UNO_NAME_PARA_GRAPHIC_LOCATION, RES_BACKGROUND, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_GRAPHIC_POSITION }, \ { UNO_NAME_PARA_LEFT_MARGIN, RES_MARGIN_TEXTLEFT, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_TXT_LMARGIN | CONVERT_TWIPS }, \ + { UNO_NAME_PARA_LEFT_MARGIN_UNIT, RES_MARGIN_TEXTLEFT, cppu::UnoType>::get(), PropertyAttribute::MAYBEVOID, MID_L_UNIT_MARGIN }, \ { UNO_NAME_PARA_RIGHT_MARGIN, RES_MARGIN_RIGHT, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_R_MARGIN | CONVERT_TWIPS }, \ + { UNO_NAME_PARA_RIGHT_MARGIN_UNIT, RES_MARGIN_RIGHT, cppu::UnoType>::get(), PropertyAttribute::MAYBEVOID, MID_R_UNIT_MARGIN }, \ { UNO_NAME_PARA_IS_AUTO_FIRST_LINE_INDENT, RES_MARGIN_FIRSTLINE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_FIRST_AUTO }, \ { UNO_NAME_PARA_FIRST_LINE_INDENT, RES_MARGIN_FIRSTLINE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_FIRST_LINE_INDENT | CONVERT_TWIPS }, \ { UNO_NAME_PARA_FIRST_LINE_INDENT_UNIT, RES_MARGIN_FIRSTLINE, cppu::UnoType>::get(), PropertyAttribute::MAYBEVOID, MID_FIRST_LINE_UNIT_INDENT }, \ @@ -418,7 +420,9 @@ { UNO_NAME_CHAR_OVERLINE_HAS_COLOR, RES_CHRATR_OVERLINE , cppu::UnoType::get(), PROPERTY_NONE, MID_TL_HASCOLOR},\ { UNO_NAME_CHAR_OVERLINE_COMPLEX_COLOR, RES_CHRATR_OVERLINE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_TL_COMPLEX_COLOR }, \ { UNO_NAME_PARA_LEFT_MARGIN, RES_MARGIN_TEXTLEFT, cppu::UnoType::get(), PROPERTY_NONE, MID_TXT_LMARGIN|CONVERT_TWIPS},\ + { UNO_NAME_PARA_LEFT_MARGIN_UNIT, RES_MARGIN_TEXTLEFT, cppu::UnoType>::get(), PROPERTY_NONE, MID_L_UNIT_MARGIN }, \ { UNO_NAME_PARA_RIGHT_MARGIN, RES_MARGIN_RIGHT, cppu::UnoType::get(), PROPERTY_NONE, MID_R_MARGIN|CONVERT_TWIPS},\ + { UNO_NAME_PARA_RIGHT_MARGIN_UNIT, RES_MARGIN_RIGHT, cppu::UnoType>::get(), PROPERTY_NONE, MID_R_UNIT_MARGIN }, \ { UNO_NAME_PARA_LEFT_MARGIN_RELATIVE, RES_MARGIN_TEXTLEFT, cppu::UnoType::get(), PROPERTY_NONE, MID_L_REL_MARGIN},\ { UNO_NAME_PARA_RIGHT_MARGIN_RELATIVE, RES_MARGIN_RIGHT, cppu::UnoType::get(), PROPERTY_NONE, MID_R_REL_MARGIN},\ { UNO_NAME_PARA_IS_AUTO_FIRST_LINE_INDENT, RES_MARGIN_FIRSTLINE, cppu::UnoType::get(), PROPERTY_NONE, MID_FIRST_AUTO},\ @@ -549,8 +553,10 @@ { UNO_NAME_PARA_FIRST_LINE_INDENT, RES_MARGIN_FIRSTLINE, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_FIRST_LINE_INDENT|CONVERT_TWIPS}, \ { UNO_NAME_PARA_FIRST_LINE_INDENT_UNIT, RES_MARGIN_FIRSTLINE, cppu::UnoType>::get(), PropertyAttribute::MAYBEVOID, MID_FIRST_LINE_UNIT_INDENT}, \ { UNO_NAME_PARA_LEFT_MARGIN, RES_MARGIN_TEXTLEFT, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_TXT_LMARGIN|CONVERT_TWIPS}, \ + { UNO_NAME_PARA_LEFT_MARGIN_UNIT, RES_MARGIN_TEXTLEFT, cppu::UnoType>::get(), PropertyAttribute::MAYBEVOID, MID_L_UNIT_MARGIN }, \ { UNO_NAME_PARA_LINE_SPACING, RES_PARATR_LINESPACING, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, CONVERT_TWIPS}, \ { UNO_NAME_PARA_RIGHT_MARGIN, RES_MARGIN_RIGHT, cppu::UnoType::get(), PropertyAttribute::MAYBEVOID, MID_R_MARGIN|CONVERT_TWIPS}, \ + { UNO_NAME_PARA_RIGHT_MARGIN_UNIT, RES_MARGIN_RIGHT, cppu::UnoType>::get(), PropertyAttribute::MAYBEVOID, MID_R_UNIT_MARGIN }, \ { UNO_NAME_TABSTOPS, RES_PARATR_TABSTOP, cppu::UnoType< cppu::UnoSequenceType >::get(), PropertyAttribute::MAYBEVOID, CONVERT_TWIPS}, \ { UNO_NAME_CHAR_NO_HYPHENATION, RES_CHRATR_NOHYPHEN, cppu::UnoType::get(), PROPERTY_NONE, 0}, \ diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx index 90c505eba8bd..6010dba6464b 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -1928,10 +1928,11 @@ void SwHTMLWriter::OutCSS1_FrameFormatOptions( const SwFrameFormat& rFrameFormat // left if( IsHTMLMode( HTMLMODE_FLY_MARGINS) ) { - nXPos -= aLRItem.GetLeft(); + nXPos -= aLRItem.ResolveLeft({}); if( nXPos < 0 ) { - aLRItem.SetLeft( o3tl::narrowing(aLRItem.GetLeft() + nXPos) ); + aLRItem.SetLeft(SvxIndentValue::twips( + o3tl::narrowing(aLRItem.ResolveLeft({}) + nXPos))); nXPos = 0; } } @@ -2813,7 +2814,7 @@ static SwHTMLWriter& OutCSS1_SvxTextLeftMargin(SwHTMLWriter & rWrt, SfxPoolItem // match that of the current template // A left margin can exist because of a list nearby - tools::Long nLeftMargin = rLeftMargin.GetTextLeft() - rWrt.m_nLeftMargin; + tools::Long nLeftMargin = rLeftMargin.ResolveTextLeft({}) - rWrt.m_nLeftMargin; if (rWrt.m_nDfltLeftMargin != nLeftMargin) { rWrt.OutCSS1_UnitProperty(sCSS1_P_margin_left, nLeftMargin); @@ -2834,9 +2835,9 @@ static SwHTMLWriter& OutCSS1_SvxRightMargin(SwHTMLWriter & rWrt, SfxPoolItem con // No Export of a firm attribute is needed if the new values // match that of the current template - if (rWrt.m_nDfltRightMargin != rRightMargin.GetRight()) + if (rWrt.m_nDfltRightMargin != rRightMargin.ResolveRight({})) { - rWrt.OutCSS1_UnitProperty(sCSS1_P_margin_right, rRightMargin.GetRight()); + rWrt.OutCSS1_UnitProperty(sCSS1_P_margin_right, rRightMargin.ResolveRight({})); } return rWrt; @@ -2850,7 +2851,7 @@ static SwHTMLWriter& OutCSS1_SvxLRSpace( SwHTMLWriter& rWrt, const SfxPoolItem& // match that of the current template // A left margin can exist because of a list nearby - tools::Long nLeftMargin = rLRItem.GetTextLeft() - rWrt.m_nLeftMargin; + tools::Long nLeftMargin = rLRItem.ResolveTextLeft({}) - rWrt.m_nLeftMargin; if( rWrt.m_nDfltLeftMargin != nLeftMargin ) { rWrt.OutCSS1_UnitProperty( sCSS1_P_margin_left, nLeftMargin ); @@ -2861,9 +2862,9 @@ static SwHTMLWriter& OutCSS1_SvxLRSpace( SwHTMLWriter& rWrt, const SfxPoolItem& } - if( rWrt.m_nDfltRightMargin != rLRItem.GetRight() ) + if (rWrt.m_nDfltRightMargin != rLRItem.ResolveRight({})) { - rWrt.OutCSS1_UnitProperty( sCSS1_P_margin_right, rLRItem.GetRight() ); + rWrt.OutCSS1_UnitProperty(sCSS1_P_margin_right, rLRItem.ResolveRight({})); } // The LineIndent of the first line might contain the room for numbering @@ -2901,16 +2902,15 @@ static SwHTMLWriter& OutCSS1_SvxULSpace_SvxLRSpace( SwHTMLWriter& rWrt, const SvxULSpaceItem *pULItem, const SvxLRSpaceItem *pLRItem ) { - if( pLRItem && pULItem && - pLRItem->GetLeft() == pLRItem->GetRight() && - pLRItem->GetLeft() == pULItem->GetUpper() && - pLRItem->GetLeft() == pULItem->GetLower() && - pLRItem->GetLeft() != rWrt.m_nDfltLeftMargin && - pLRItem->GetRight() != rWrt.m_nDfltRightMargin && - pULItem->GetUpper() != rWrt.m_nDfltTopMargin && - pULItem->GetLower() != rWrt.m_nDfltBottomMargin ) + if (pLRItem && pULItem && pLRItem->GetLeft() == pLRItem->GetRight() + && pLRItem->GetLeft() == SvxIndentValue::twips(pULItem->GetUpper()) + && pLRItem->GetLeft() == SvxIndentValue::twips(pULItem->GetLower()) + && pLRItem->GetLeft() != SvxIndentValue::twips(rWrt.m_nDfltLeftMargin) + && pLRItem->GetRight() != SvxIndentValue::twips(rWrt.m_nDfltRightMargin) + && pULItem->GetUpper() != rWrt.m_nDfltTopMargin + && pULItem->GetLower() != rWrt.m_nDfltBottomMargin) { - rWrt.OutCSS1_UnitProperty( sCSS1_P_margin, pLRItem->GetLeft() ); + rWrt.OutCSS1_UnitProperty(sCSS1_P_margin, pLRItem->ResolveLeft({})); } else { diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index 68ca031e4220..7e2009263cd6 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -375,8 +375,8 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem (pReferenceFormat ? pReferenceFormat : pFormat)->GetTextLeftMargin()); SvxRightMarginItem const& rRightMargin( (pReferenceFormat ? pReferenceFormat : pFormat)->GetRightMargin()); - nLeftMargin = rTextLeftMargin.GetTextLeft(); - nRightMargin = rRightMargin.GetRight(); + nLeftMargin = rTextLeftMargin.ResolveTextLeft({}); + nRightMargin = rRightMargin.ResolveRight({}); nFirstLineIndent = rFirstLine.ResolveTextFirstLineOffset({}); const SvxULSpaceItem &rULSpace = @@ -649,12 +649,12 @@ static void OutHTML_SwFormat( SwHTMLWriter& rWrt, const SwFormat& rFormat, if( (!rWrt.m_bCfgOutStyles || bForceDL) && !rInfo.bInNumberBulletList ) { sal_Int32 nLeftMargin; - if( bForceDL ) - nLeftMargin = rTextLeftMargin.GetTextLeft(); + if (bForceDL) + nLeftMargin = rTextLeftMargin.ResolveTextLeft({}); else - nLeftMargin = rTextLeftMargin.GetTextLeft() > pFormatInfo->nLeftMargin - ? rTextLeftMargin.GetTextLeft() - pFormatInfo->nLeftMargin - : 0; + nLeftMargin = rTextLeftMargin.ResolveTextLeft({}) > pFormatInfo->nLeftMargin + ? rTextLeftMargin.ResolveTextLeft({}) - pFormatInfo->nLeftMargin + : 0; if( nLeftMargin > 0 && rWrt.m_nDefListMargin > 0 ) { @@ -723,8 +723,8 @@ static void OutHTML_SwFormat( SwHTMLWriter& rWrt, const SwFormat& rFormat, if( rInfo.bInNumberBulletList ) { - if( !rWrt.IsHTMLMode( HTMLMODE_LSPACE_IN_NUMBER_BULLET ) ) - rWrt.m_nDfltLeftMargin = rTextLeftMargin.GetTextLeft(); + if (!rWrt.IsHTMLMode(HTMLMODE_LSPACE_IN_NUMBER_BULLET)) + rWrt.m_nDfltLeftMargin = rTextLeftMargin.ResolveTextLeft({}); // In numbered lists, don't output a first line indent. rWrt.m_nFirstLineIndent = rFirstLine.ResolveTextFirstLineOffset({}); @@ -2102,8 +2102,8 @@ SwHTMLWriter& OutHTML_SwTextNode( SwHTMLWriter& rWrt, const SwContentNode& rNode SvxFirstLineIndentItem const& rFirstLine(pItemSet->Get(RES_MARGIN_FIRSTLINE)); SvxTextLeftMarginItem const& rTextLeftMargin(pItemSet->Get(RES_MARGIN_TEXTLEFT)); SvxRightMarginItem const& rRightMargin(pItemSet->Get(RES_MARGIN_RIGHT)); - sal_Int32 const nLeft(rTextLeftMargin.GetLeft(rFirstLine, /*metrics*/ {})); - sal_Int32 const nRight(rRightMargin.GetRight()); + sal_Int32 const nLeft(rTextLeftMargin.ResolveLeft(rFirstLine, /*metrics*/ {})); + sal_Int32 const nRight(rRightMargin.ResolveRight({})); if( nLeft || nRight ) { const SwFrameFormat& rPgFormat = @@ -2113,7 +2113,8 @@ SwHTMLWriter& OutHTML_SwTextNode( SwHTMLWriter& rWrt, const SwContentNode& rNode const SvxLRSpaceItem& rLR = rPgFormat.GetLRSpace(); const SwFormatCol& rCol = rPgFormat.GetCol(); - tools::Long nPageWidth = rSz.GetWidth() - rLR.GetLeft() - rLR.GetRight(); + tools::Long nPageWidth + = rSz.GetWidth() - rLR.ResolveLeft({}) - rLR.ResolveRight({}); if( 1 < rCol.GetNumCols() ) nPageWidth /= rCol.GetNumCols(); diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx index 9a9e8ac032a9..3b8702641be8 100644 --- a/sw/source/filter/html/htmlcss1.cxx +++ b/sw/source/filter/html/htmlcss1.cxx @@ -1489,7 +1489,7 @@ void SwCSS1Parser::FillDropCap( SwFormatDrop& rDrop, // a right border becomes the spacing to text! if (const SvxRightMarginItem *const pRightMargin = rItemSet.GetItemIfSet(RES_MARGIN_RIGHT, false)) { - rDrop.SetDistance(static_cast(pRightMargin->GetRight())); + rDrop.SetDistance(static_cast(pRightMargin->ResolveRight({}))); rItemSet.ClearItem(RES_MARGIN_RIGHT); } rItemSet.ClearItem(RES_MARGIN_FIRSTLINE); diff --git a/sw/source/filter/html/htmlctxt.cxx b/sw/source/filter/html/htmlctxt.cxx index 4035a4dde407..6e3d0f639ef3 100644 --- a/sw/source/filter/html/htmlctxt.cxx +++ b/sw/source/filter/html/htmlctxt.cxx @@ -615,10 +615,10 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, // the item (with value 0) will be added if( rPropInfo.m_bLeftMargin ) { - OSL_ENSURE( rPropInfo.m_nLeftMargin < 0 || - !pTextLeftMargin || - rPropInfo.m_nLeftMargin == pTextLeftMargin->GetTextLeft(), - "left margin does not match with item" ); + OSL_ENSURE(rPropInfo.m_nLeftMargin < 0 || !pTextLeftMargin + || rPropInfo.m_nLeftMargin + == pTextLeftMargin->ResolveTextLeft({}), + "left margin does not match with item"); if( rPropInfo.m_nLeftMargin < 0 && -rPropInfo.m_nLeftMargin > nOldLeft ) nLeft = 0; @@ -627,10 +627,9 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, } if( rPropInfo.m_bRightMargin ) { - OSL_ENSURE( rPropInfo.m_nRightMargin < 0 || - !pRightMargin || - rPropInfo.m_nRightMargin == pRightMargin->GetRight(), - "right margin does not match with item" ); + OSL_ENSURE(rPropInfo.m_nRightMargin < 0 || !pRightMargin + || rPropInfo.m_nRightMargin == pRightMargin->ResolveRight({}), + "right margin does not match with item"); if( rPropInfo.m_nRightMargin < 0 && -rPropInfo.m_nRightMargin > nOldRight ) nRight = 0; @@ -648,10 +647,12 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet, RES_MARGIN_FIRSTLINE); NewAttr(m_xAttrTab, &m_xAttrTab->pFirstLineIndent, firstLine); EndAttr(m_xAttrTab->pFirstLineIndent, false); - SvxTextLeftMarginItem const leftMargin(nLeft, RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(nLeft), + RES_MARGIN_TEXTLEFT); NewAttr(m_xAttrTab, &m_xAttrTab->pTextLeftMargin, leftMargin); EndAttr(m_xAttrTab->pTextLeftMargin, false); - SvxRightMarginItem const rightMargin(nRight, RES_MARGIN_RIGHT); + SvxRightMarginItem const rightMargin(SvxIndentValue::twips(nRight), + RES_MARGIN_RIGHT); NewAttr(m_xAttrTab, &m_xAttrTab->pRightMargin, rightMargin); EndAttr(m_xAttrTab->pRightMargin, false); } diff --git a/sw/source/filter/html/htmldrawreader.cxx b/sw/source/filter/html/htmldrawreader.cxx index f374751a5174..d03ebbaba48c 100644 --- a/sw/source/filter/html/htmldrawreader.cxx +++ b/sw/source/filter/html/htmldrawreader.cxx @@ -100,7 +100,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, if( rCSS1PropInfo.m_bLeftMargin ) { // should be SvxLeftMarginItem... "cast" it - nLeftSpace = static_cast(pLeft->GetTextLeft()); + nLeftSpace = static_cast(pLeft->ResolveTextLeft({})); rCSS1PropInfo.m_bLeftMargin = false; } rCSS1ItemSet.ClearItem(RES_MARGIN_TEXTLEFT); @@ -109,7 +109,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, { if( rCSS1PropInfo.m_bRightMargin ) { - nRightSpace = static_cast< sal_uInt16 >(pRight->GetRight()); + nRightSpace = static_cast(pRight->ResolveRight({})); rCSS1PropInfo.m_bRightMargin = false; } rCSS1ItemSet.ClearItem(RES_MARGIN_RIGHT); @@ -117,8 +117,8 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, if( nLeftSpace || nRightSpace ) { SvxLRSpaceItem aLRItem( RES_LR_SPACE ); - aLRItem.SetLeft( nLeftSpace ); - aLRItem.SetRight( nRightSpace ); + aLRItem.SetLeft(SvxIndentValue::twips(nLeftSpace)); + aLRItem.SetRight(SvxIndentValue::twips(nRightSpace)); aFrameSet.Put( aLRItem ); } diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx index 69a3d56a2ed0..45d1893e4232 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -323,7 +323,7 @@ void SwHTMLWriter::CollectFlyFrames() pACNd->GetAttr(RES_MARGIN_TEXTLEFT); const SvxRightMarginItem& rRightMargin = pACNd->GetAttr(RES_MARGIN_RIGHT); - if (rTextLeftMargin.GetTextLeft() || rRightMargin.GetRight()) + if (rTextLeftMargin.ResolveTextLeft({}) || rRightMargin.ResolveRight({})) { nMode = getHTMLOutFrameParaFrameTable(eType, m_nExportMode); break; @@ -612,8 +612,7 @@ OString SwHTMLWriter::OutFrameFormatOptions( const SwFrameFormat &rFrameFormat, if( (nFrameOpts & (HtmlFrmOpts::Space|HtmlFrmOpts::MarginSize)) && (pLRSpaceItem = rItemSet.GetItemIfSet( RES_LR_SPACE )) ) { - aTwipSpc.setWidth( - ( pLRSpaceItem->GetLeft() + pLRSpaceItem->GetRight() ) / 2 ); + aTwipSpc.setWidth((pLRSpaceItem->ResolveLeft({}) + pLRSpaceItem->ResolveRight({})) / 2); m_nDfltLeftMargin = m_nDfltRightMargin = aTwipSpc.Width(); } const SvxULSpaceItem* pULSpaceItem; @@ -865,8 +864,7 @@ void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameForma if( (nFrameOptions & (HtmlFrmOpts::Space | HtmlFrmOpts::MarginSize)) && (pLRSpaceItem = rItemSet.GetItemIfSet( RES_LR_SPACE )) ) { - aTwipSpc.setWidth( - ( pLRSpaceItem->GetLeft() + pLRSpaceItem->GetRight() ) / 2 ); + aTwipSpc.setWidth((pLRSpaceItem->ResolveLeft({}) + pLRSpaceItem->ResolveRight({})) / 2); m_nDfltLeftMargin = m_nDfltRightMargin = aTwipSpc.Width(); } const SvxULSpaceItem* pULSpaceItem; diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx index cc234aabd586..a387f019d51f 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -876,7 +876,7 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl( if( rCSS1PropInfo.m_bLeftMargin ) { // should be SvxLeftMarginItem... "cast" it - nLeftSpace = convertTwipToMm100(pLeft->GetTextLeft()); + nLeftSpace = convertTwipToMm100(pLeft->ResolveTextLeft({})); rCSS1PropInfo.m_bLeftMargin = false; } rCSS1ItemSet.ClearItem(RES_MARGIN_TEXTLEFT); @@ -885,7 +885,7 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl( { if( rCSS1PropInfo.m_bRightMargin ) { - nRightSpace = convertTwipToMm100(pRight->GetRight()); + nRightSpace = convertTwipToMm100(pRight->ResolveRight({})); rCSS1PropInfo.m_bRightMargin = false; } rCSS1ItemSet.ClearItem(RES_MARGIN_RIGHT); diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx index 238b09dbc2dc..40ccc0c6cb66 100644 --- a/sw/source/filter/html/htmlplug.cxx +++ b/sw/source/filter/html/htmlplug.cxx @@ -258,7 +258,7 @@ void SwHTMLParser::SetSpace( const Size& rPixSpace, if( rCSS1PropInfo.m_bLeftMargin ) { // should be SvxLeftMarginItem... "cast" it - nLeftSpace = pLeft->GetTextLeft(); + nLeftSpace = pLeft->ResolveTextLeft({}); rCSS1PropInfo.m_bLeftMargin = false; } rCSS1ItemSet.ClearItem(RES_MARGIN_TEXTLEFT); @@ -267,7 +267,7 @@ void SwHTMLParser::SetSpace( const Size& rPixSpace, { if( rCSS1PropInfo.m_bRightMargin ) { - nRightSpace = pRight->GetRight(); + nRightSpace = pRight->ResolveRight({}); rCSS1PropInfo.m_bRightMargin = false; } rCSS1ItemSet.ClearItem(RES_MARGIN_RIGHT); @@ -275,8 +275,8 @@ void SwHTMLParser::SetSpace( const Size& rPixSpace, if( nLeftSpace > 0 || nRightSpace > 0 ) { SvxLRSpaceItem aLRItem( RES_LR_SPACE ); - aLRItem.SetLeft( std::max(nLeftSpace, 0) ); - aLRItem.SetRight( std::max(nRightSpace, 0) ); + aLRItem.SetLeft(SvxIndentValue::twips(std::max(nLeftSpace, 0))); + aLRItem.SetRight(SvxIndentValue::twips(std::max(nRightSpace, 0))); rFlyItemSet.Put( aLRItem ); if( nLeftSpace ) { diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index 23ec0f9b6d7b..96664b710f2a 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -2371,8 +2371,8 @@ void HTMLTable::MakeTable( SwTableBox *pBox, sal_uInt16 nAbsAvail, // The right margin will be ignored anyway. SvxLRSpaceItem aLRItem( m_pSwTable->GetFrameFormat()->GetLRSpace() ); - aLRItem.SetLeft( m_nLeftMargin ); - aLRItem.SetRight( m_nRightMargin ); + aLRItem.SetLeft(SvxIndentValue::twips(m_nLeftMargin)); + aLRItem.SetRight(SvxIndentValue::twips(m_nRightMargin)); pFrameFormat->SetFormatAttr( aLRItem ); } @@ -3458,9 +3458,10 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions, aFrameSet.Put( aFrameSize ); sal_uInt16 nSpace = pCurTable->GetHSpace(); - if( nSpace ) - aFrameSet.Put( - SvxLRSpaceItem(nSpace, nSpace, SvxIndentValue::zero(), RES_LR_SPACE)); + if (nSpace) + aFrameSet.Put(SvxLRSpaceItem(SvxIndentValue::twips(nSpace), + SvxIndentValue::twips(nSpace), + SvxIndentValue::zero(), RES_LR_SPACE)); nSpace = pCurTable->GetVSpace(); if( nSpace ) aFrameSet.Put( SvxULSpaceItem(nSpace,nSpace, RES_UL_SPACE) ); diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx index b1ef282396a0..c1ef09d2922d 100644 --- a/sw/source/filter/html/htmltabw.cxx +++ b/sw/source/filter/html/htmltabw.cxx @@ -885,7 +885,8 @@ SwHTMLWriter& OutHTML_SwTableNode( SwHTMLWriter& rWrt, SwTableNode & rNode, eFlyHoriOri = text::HoriOrientation::LEFT; const SvxLRSpaceItem& rLRSpace = pFlyFrameFormat->GetLRSpace(); - nFlyHSpace = static_cast< sal_uInt16 >((rLRSpace.GetLeft() + rLRSpace.GetRight()) / 2); + nFlyHSpace + = static_cast((rLRSpace.ResolveLeft({}) + rLRSpace.ResolveRight({})) / 2); const SvxULSpaceItem& rULSpace = pFlyFrameFormat->GetULSpace(); nFlyVSpace = (rULSpace.GetUpper() + rULSpace.GetLower()) / 2; @@ -924,7 +925,7 @@ SwHTMLWriter& OutHTML_SwTableNode( SwHTMLWriter& rWrt, SwTableNode & rNode, case text::HoriOrientation::NONE: { const SvxLRSpaceItem& aLRItem = pFormat->GetLRSpace(); - if( aLRItem.GetRight() ) + if (aLRItem.ResolveRight({})) { // The table width is defined on the basis of the left and // right margin. Therefore we try to define the actual @@ -977,19 +978,18 @@ SwHTMLWriter& OutHTML_SwTableNode( SwHTMLWriter& rWrt, SwTableNode & rNode, rWrt.GetNextNumInfo(), "NumInfo for next paragraph is missing!" ); const SvxLRSpaceItem& aLRItem = pFormat->GetLRSpace(); - if( aLRItem.GetLeft() > 0 && rWrt.m_nDefListMargin > 0 && - ( !rWrt.GetNumInfo().GetNumRule() || - ( rWrt.GetNextNumInfo() && - (rWrt.GetNumInfo().GetNumRule() != rWrt.GetNextNumInfo()->GetNumRule() || - rWrt.GetNextNumInfo()->IsRestart(rWrt.GetNumInfo())) ) ) ) + if (aLRItem.ResolveLeft({}) > 0 && rWrt.m_nDefListMargin > 0 + && (!rWrt.GetNumInfo().GetNumRule() + || (rWrt.GetNextNumInfo() + && (rWrt.GetNumInfo().GetNumRule() != rWrt.GetNextNumInfo()->GetNumRule() + || rWrt.GetNextNumInfo()->IsRestart(rWrt.GetNumInfo()))))) { // If the paragraph before the table is not numbered or the // paragraph after the table starts with a new numbering or with // a different rule, we can maintain the indentation with a DL. // Otherwise we keep the indentation of the numbering. - nNewDefListLvl = static_cast< sal_uInt16 >( - (aLRItem.GetLeft() + (rWrt.m_nDefListMargin/2)) / - rWrt.m_nDefListMargin ); + nNewDefListLvl = static_cast( + (aLRItem.ResolveLeft({}) + (rWrt.m_nDefListMargin / 2)) / rWrt.m_nDefListMargin); } } diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx index b1dc184d722f..7b18efd302d7 100644 --- a/sw/source/filter/html/svxcss1.cxx +++ b/sw/source/filter/html/svxcss1.cxx @@ -2046,7 +2046,8 @@ static void ParseCSS1_margin_left( const CSS1Expression *pExpr, nLeft = 0; // TODO: other things may need a SvxLeftMarginItem ? but they currently convert it anyway so they can convert that too. - SvxTextLeftMarginItem const leftMargin(o3tl::narrowing(nLeft), RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin( + SvxIndentValue::twips(o3tl::narrowing(nLeft)), RES_MARGIN_TEXTLEFT); rItemSet.Put(leftMargin); rPropInfo.m_bLeftMargin = true; } @@ -2100,7 +2101,8 @@ static void ParseCSS1_margin_right( const CSS1Expression *pExpr, if( nRight < 0 ) nRight = 0; - SvxRightMarginItem rightMargin(o3tl::narrowing(nRight), RES_MARGIN_RIGHT); + SvxRightMarginItem rightMargin(SvxIndentValue::twips(o3tl::narrowing(nRight)), + RES_MARGIN_RIGHT); rItemSet.Put(rightMargin); rPropInfo.m_bRightMargin = true; } @@ -2320,12 +2322,15 @@ static void ParseCSS1_margin( const CSS1Expression *pExpr, if (bSetMargins[3]) { - SvxTextLeftMarginItem const leftMargin(o3tl::narrowing(nMargins[3]), RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin( + SvxIndentValue::twips(o3tl::narrowing(nMargins[3])), + RES_MARGIN_TEXTLEFT); rItemSet.Put(leftMargin); } if (bSetMargins[1]) { - SvxRightMarginItem const rightMargin(o3tl::narrowing(nMargins[1]), RES_MARGIN_RIGHT); + SvxRightMarginItem const rightMargin( + SvxIndentValue::twips(o3tl::narrowing(nMargins[1])), RES_MARGIN_RIGHT); rItemSet.Put(rightMargin); } } diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index ec7a37f6f4c0..e838e2868fa8 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -4428,7 +4428,7 @@ void SwHTMLParser::NewDefList() SvxTextLeftMarginItem const& rTextLeftMargin = m_pCSS1Parser->GetTextFormatColl(RES_POOLCOLL_HTML_DD, OUString()) ->GetTextLeftMargin(); - nLeft = nLeft + static_cast(rTextLeftMargin.GetTextLeft()); + nLeft = nLeft + static_cast(rTextLeftMargin.ResolveTextLeft({})); } xCntxt->SetMargins( nLeft, nRight, nIndent ); @@ -4769,16 +4769,16 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext *pContext ) || rItemSet.GetItemIfSet(RES_MARGIN_TEXTLEFT) || rItemSet.GetItemIfSet(RES_MARGIN_RIGHT)) { - sal_Int32 nLeft = rItemSet.Get(RES_MARGIN_TEXTLEFT).GetTextLeft(); - sal_Int32 nRight = rItemSet.Get(RES_MARGIN_RIGHT).GetRight(); + sal_Int32 nLeft = rItemSet.Get(RES_MARGIN_TEXTLEFT).ResolveTextLeft({}); + sal_Int32 nRight = rItemSet.Get(RES_MARGIN_RIGHT).ResolveRight({}); nFirstLineIndent = rItemSet.Get(RES_MARGIN_FIRSTLINE).ResolveTextFirstLineOffset({}); // In Definition lists the margins also contain the margins from the previous levels if( RES_POOLCOLL_HTML_DD == nTopColl ) { auto const*const pColl(m_pCSS1Parser->GetTextFormatColl(RES_POOLCOLL_HTML_DT, OUString())); - nLeft -= pColl->GetTextLeftMargin().GetTextLeft(); - nRight -= pColl->GetRightMargin().GetRight(); + nLeft -= pColl->GetTextLeftMargin().ResolveTextLeft({}); + nRight -= pColl->GetRightMargin().ResolveRight({}); } else if( RES_POOLCOLL_HTML_DT == nTopColl ) { @@ -4805,11 +4805,12 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext *pContext ) pCollToSet = m_pCSS1Parser->GetTextCollFromPool( nDfltColl ); if( !nLeftMargin ) { - nLeftMargin = static_cast(pCollToSet->GetTextLeftMargin().GetTextLeft()); + nLeftMargin + = static_cast(pCollToSet->GetTextLeftMargin().ResolveTextLeft({})); } if( !nRightMargin ) { - nRightMargin = static_cast(pCollToSet->GetRightMargin().GetRight()); + nRightMargin = static_cast(pCollToSet->GetRightMargin().ResolveRight({})); } if( !nFirstLineIndent ) { @@ -4836,9 +4837,9 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext *pContext ) const SvxFirstLineIndentItem & rFirstLine = pCollToSet->GetFirstLineIndent(); const SvxTextLeftMarginItem & rTextLeftMargin = pCollToSet->GetTextLeftMargin(); const SvxRightMarginItem & rRightMargin = pCollToSet->GetRightMargin(); - bool bSetLRSpace = nLeftMargin != rTextLeftMargin.GetTextLeft() + bool bSetLRSpace = nLeftMargin != rTextLeftMargin.ResolveTextLeft({}) || nFirstLineIndent != rFirstLine.ResolveTextFirstLineOffset({}) - || nRightMargin != rRightMargin.GetRight(); + || nRightMargin != rRightMargin.ResolveRight({}); if( bSetLRSpace ) { @@ -4846,8 +4847,8 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext *pContext ) SvxTextLeftMarginItem leftMargin(rTextLeftMargin); SvxRightMarginItem rightMargin(rRightMargin); firstLine.SetTextFirstLineOffset(SvxIndentValue::twips(nFirstLineIndent)); - leftMargin.SetTextLeft(nLeftMargin); - rightMargin.SetRight(nRightMargin); + leftMargin.SetTextLeft(SvxIndentValue::twips(nLeftMargin)); + rightMargin.SetRight(SvxIndentValue::twips(nRightMargin)); if( pItemSet ) { pItemSet->Put(firstLine); @@ -5082,8 +5083,10 @@ void SwHTMLParser::InsertSpacer() SvxFirstLineIndentItem const firstLine(SvxIndentValue::twips(nIndent), RES_MARGIN_FIRSTLINE); - SvxTextLeftMarginItem const leftMargin(nLeft, RES_MARGIN_TEXTLEFT); - SvxRightMarginItem const rightMargin(nRight, RES_MARGIN_RIGHT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(nLeft), + RES_MARGIN_TEXTLEFT); + SvxRightMarginItem const rightMargin(SvxIndentValue::twips(nRight), + RES_MARGIN_RIGHT); NewAttr(m_xAttrTab, &m_xAttrTab->pFirstLineIndent, firstLine); EndAttr(m_xAttrTab->pFirstLineIndent, false); @@ -5123,7 +5126,7 @@ SwTwips SwHTMLParser::GetCurrentBrowseWidth() const SvxULSpaceItem& rUL = rPgFormat.GetULSpace(); const SwFormatCol& rCol = rPgFormat.GetCol(); - m_aHTMLPageSize.setWidth( rSz.GetWidth() - rLR.GetLeft() - rLR.GetRight() ); + m_aHTMLPageSize.setWidth(rSz.GetWidth() - rLR.ResolveLeft({}) - rLR.ResolveRight({})); m_aHTMLPageSize.setHeight( rSz.GetHeight() - rUL.GetUpper() - rUL.GetLower() ); if( 1 < rCol.GetNumCols() ) @@ -5382,16 +5385,20 @@ void SwHTMLParser::InsertHorzRule() switch( eAdjust ) { case SvxAdjust::Right: - oLeft.emplace(o3tl::narrowing(nDist), RES_MARGIN_TEXTLEFT); + oLeft.emplace(SvxIndentValue::twips(o3tl::narrowing(nDist)), + RES_MARGIN_TEXTLEFT); break; case SvxAdjust::Left: - oRight.emplace(o3tl::narrowing(nDist), RES_MARGIN_RIGHT); + oRight.emplace(SvxIndentValue::twips(o3tl::narrowing(nDist)), + RES_MARGIN_RIGHT); break; case SvxAdjust::Center: default: nDist /= 2; - oLeft.emplace(o3tl::narrowing(nDist), RES_MARGIN_TEXTLEFT); - oRight.emplace(o3tl::narrowing(nDist), RES_MARGIN_RIGHT); + oLeft.emplace(SvxIndentValue::twips(o3tl::narrowing(nDist)), + RES_MARGIN_TEXTLEFT); + oRight.emplace(SvxIndentValue::twips(o3tl::narrowing(nDist)), + RES_MARGIN_RIGHT); break; } diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index 88a4da9e3dd3..a1ea378e5e09 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -492,8 +492,10 @@ ErrCode SwHTMLWriter::WriteStream() m_nLastLFPos = 0; m_nDefListLvl = 0; m_nDefListMargin = ((m_xTemplate.is() && !m_bCfgOutStyles) ? m_xTemplate.get() : m_pDoc) - ->getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_HTML_DD, false ) - ->GetTextLeftMargin().GetTextLeft(); + ->getIDocumentStylePoolAccess() + .GetTextCollFromPool(RES_POOLCOLL_HTML_DD, false) + ->GetTextLeftMargin() + .ResolveTextLeft({}); m_nHeaderFooterSpace = 0; m_nTextAttrsToIgnore = 0; m_nCSS1OutMode = 0; diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 8b0709638f3b..69408eddad61 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1082,8 +1082,8 @@ void DocxAttributeOutput::PopulateFrameProperties(const SwFrameFormat* pFrameFor else if (aPos.Y) attrList->add( FSNS( XML_w, XML_y), OString::number(aPos.Y)); - sal_Int16 nLeft = pFrameFormat->GetLRSpace().GetLeft(); - sal_Int16 nRight = pFrameFormat->GetLRSpace().GetRight(); + sal_Int16 nLeft = pFrameFormat->GetLRSpace().ResolveLeft({}); + sal_Int16 nRight = pFrameFormat->GetLRSpace().ResolveRight({}); sal_Int16 nUpper = pFrameFormat->GetULSpace().GetUpper(); sal_Int16 nLower = pFrameFormat->GetULSpace().GetLower(); @@ -6216,10 +6216,12 @@ OString DocxAttributeOutput::GetOLEStyle(const SwFlyFrameFormat& rFormat, const "pt"; //from VMLExport::AddRectangleDimensions(), it does: value/20 const SvxLRSpaceItem& rLRSpace = rFormat.GetLRSpace(); - if (rLRSpace.IsExplicitZeroMarginValLeft() || rLRSpace.GetLeft()) - sShapeStyle += ";mso-wrap-distance-left:" + OString::number(double(rLRSpace.GetLeft()) / 20) + "pt"; - if (rLRSpace.IsExplicitZeroMarginValRight() || rLRSpace.GetRight()) - sShapeStyle += ";mso-wrap-distance-right:" + OString::number(double(rLRSpace.GetRight()) / 20) + "pt"; + if (rLRSpace.IsExplicitZeroMarginValLeft() || rLRSpace.ResolveLeft({})) + sShapeStyle += ";mso-wrap-distance-left:" + + OString::number(double(rLRSpace.ResolveLeft({})) / 20) + "pt"; + if (rLRSpace.IsExplicitZeroMarginValRight() || rLRSpace.ResolveRight({})) + sShapeStyle += ";mso-wrap-distance-right:" + + OString::number(double(rLRSpace.ResolveRight({})) / 20) + "pt"; const SvxULSpaceItem& rULSpace = rFormat.GetULSpace(); if (rULSpace.GetUpper()) sShapeStyle += ";mso-wrap-distance-top:" + OString::number(double(rULSpace.GetUpper()) / 20) + "pt"; @@ -9321,9 +9323,8 @@ void DocxAttributeOutput::FormatTextLeftMargin(SvxTextLeftMarginItem const& rTex } } bool const bEcma1st(m_rExport.GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION); - AddToAttrList(m_pLRSpaceAttrList, - FSNS(XML_w, (bEcma1st ? XML_left : XML_start)), - OString::number(pTextLeftMargin->GetTextLeft())); + AddToAttrList(m_pLRSpaceAttrList, FSNS(XML_w, (bEcma1st ? XML_left : XML_start)), + OString::number(pTextLeftMargin->ResolveTextLeft({}))); } void DocxAttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMargin) @@ -9334,9 +9335,8 @@ void DocxAttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMarg #endif { bool const bEcma1st(m_rExport.GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION); - AddToAttrList(m_pLRSpaceAttrList, - FSNS(XML_w, (bEcma1st ? XML_right : XML_end)), - OString::number(rRightMargin.GetRight())); + AddToAttrList(m_pLRSpaceAttrList, FSNS(XML_w, (bEcma1st ? XML_right : XML_end)), + OString::number(rRightMargin.ResolveRight({}))); } } @@ -9345,17 +9345,20 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) bool const bEcma = m_rExport.GetFilter().getVersion() == oox::core::ECMA_376_1ST_EDITION; if (m_rExport.SdrExporter().getTextFrameSyntax()) { - m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-left:" + OString::number(double(rLRSpace.GetLeft()) / 20) + "pt"); - m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-right:" + OString::number(double(rLRSpace.GetRight()) / 20) + "pt"); + m_rExport.SdrExporter().getTextFrameStyle().append( + ";mso-wrap-distance-left:" + OString::number(double(rLRSpace.ResolveLeft({})) / 20) + + "pt"); + m_rExport.SdrExporter().getTextFrameStyle().append( + ";mso-wrap-distance-right:" + OString::number(double(rLRSpace.ResolveRight({})) / 20) + + "pt"); } else if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) { } else if ( m_rExport.m_bOutFlyFrameAttrs ) { - AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_hSpace ), - OString::number( - ( rLRSpace.GetLeft() + rLRSpace.GetRight() ) / 2 ) ); + AddToAttrList(m_rExport.SdrExporter().getFlyAttrList(), FSNS(XML_w, XML_hSpace), + OString::number((rLRSpace.ResolveLeft({}) + rLRSpace.ResolveRight({})) / 2)); } else if ( m_rExport.m_bOutPageDescs ) { @@ -9369,8 +9372,8 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) m_pageMargins.nRight = pBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT, /*bEvenIfNoLine*/true ); } - m_pageMargins.nLeft += sal::static_int_cast(rLRSpace.GetLeft()); - m_pageMargins.nRight += sal::static_int_cast(rLRSpace.GetRight()); + m_pageMargins.nLeft += sal::static_int_cast(rLRSpace.ResolveLeft({})); + m_pageMargins.nRight += sal::static_int_cast(rLRSpace.ResolveRight({})); // if page layout is 'left' then left/right margin need to be exchanged // as it is exported as mirrored layout starting with even page const WW8_SepInfo *pSectionInfo = m_rExport.Sections().CurrentSectionInfo(); @@ -9396,13 +9399,15 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) ::std::optional oLRSpace; assert(dynamic_cast(GetExport().m_pOutFormatNode) == nullptr); rtl::Reference pLRSpaceAttrList = FastSerializerHelper::createAttrList(); - if ((0 != pLRSpace->GetTextLeft()) || (pLRSpace->IsExplicitZeroMarginValLeft())) + if ((0 != pLRSpace->ResolveTextLeft({})) || (pLRSpace->IsExplicitZeroMarginValLeft())) { - pLRSpaceAttrList->add( FSNS(XML_w, (bEcma ? XML_left : XML_start)), OString::number(pLRSpace->GetTextLeft()) ); + pLRSpaceAttrList->add(FSNS(XML_w, (bEcma ? XML_left : XML_start)), + OString::number(pLRSpace->ResolveTextLeft({}))); } - if ((0 != pLRSpace->GetRight()) || (pLRSpace->IsExplicitZeroMarginValRight())) + if ((0 != pLRSpace->ResolveRight({})) || (pLRSpace->IsExplicitZeroMarginValRight())) { - pLRSpaceAttrList->add( FSNS(XML_w, (bEcma ? XML_right : XML_end)), OString::number(pLRSpace->GetRight()) ); + pLRSpaceAttrList->add(FSNS(XML_w, (bEcma ? XML_right : XML_end)), + OString::number(pLRSpace->ResolveRight({}))); } // tdf#83844: TODO: export FONT_CJK_ADVANCE first line indent as HangingChars/FirstLineChars sal_Int32 const nFirstLineAdjustment = pLRSpace->ResolveTextFirstLineOffset({}); diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 4bfd56ae0fc8..de0e3769a561 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -700,8 +700,8 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons const SvxULSpaceItem& aULSpaceItem = pFrameFormat->GetULSpace(); sal_Int64 nDistT = aULSpaceItem.GetUpper(); sal_Int64 nDistB = aULSpaceItem.GetLower(); - sal_Int64 nDistL = aLRSpaceItem.GetLeft(); - sal_Int64 nDistR = aLRSpaceItem.GetRight(); + sal_Int64 nDistL = aLRSpaceItem.ResolveLeft({}); + sal_Int64 nDistR = aLRSpaceItem.ResolveRight({}); // LibreOffice behaves different for frames and drawing objects, but MS Office treats frames // as drawing objects too. Therefore we transform the values from frame so as if they come diff --git a/sw/source/filter/ww8/docxtableexport.cxx b/sw/source/filter/ww8/docxtableexport.cxx index 6a35e414a2d9..e1fd3f3d48c1 100644 --- a/sw/source/filter/ww8/docxtableexport.cxx +++ b/sw/source/filter/ww8/docxtableexport.cxx @@ -116,11 +116,11 @@ void CollectFloatingTableAttributes(DocxExport& rExport, const ww8::Frame& rFram if (nValue != 0) pAttributes->add(FSNS(XML_w, XML_bottomFromText), OString::number(nValue)); - nValue = rFrame.GetFrameFormat().GetLRSpace().GetLeft(); + nValue = rFrame.GetFrameFormat().GetLRSpace().ResolveLeft({}); if (nValue != 0) pAttributes->add(FSNS(XML_w, XML_leftFromText), OString::number(nValue)); - nValue = rFrame.GetFrameFormat().GetLRSpace().GetRight(); + nValue = rFrame.GetFrameFormat().GetLRSpace().ResolveRight({}); if (nValue != 0) pAttributes->add(FSNS(XML_w, XML_rightFromText), OString::number(nValue)); @@ -459,7 +459,7 @@ void DocxAttributeOutput::TableDefinition( pJcVal = "left"; else pJcVal = "start"; - nIndent = sal_Int32(pTableFormat->GetLRSpace().GetLeft()); + nIndent = pTableFormat->GetLRSpace().ResolveLeft({}); // Table indentation has different meaning in Word, depending if the table is nested or not. // If nested, tblInd is added to parent table's left spacing and defines left edge position diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 3edc159ce2ae..228fcd65ce97 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -788,10 +788,10 @@ void RtfAttributeOutput::TablePositioning(SwFrameFormat* pFlyFormat) m_aRowDefs.append(static_cast(nTdfrmtxtBottom)); // Similar to RtfAttributeOutput::FormatLRSpace(), but for tables. - sal_uInt16 nTdfrmtxtLeft = pFlyFormat->GetLRSpace().GetLeft(); + sal_uInt16 nTdfrmtxtLeft = pFlyFormat->GetLRSpace().ResolveLeft({}); m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TDFRMTXTLEFT); m_aRowDefs.append(static_cast(nTdfrmtxtLeft)); - sal_uInt16 nTdfrmtxtRight = pFlyFormat->GetLRSpace().GetRight(); + sal_uInt16 nTdfrmtxtRight = pFlyFormat->GetLRSpace().ResolveRight({}); m_aRowDefs.append(LO_STRING_SVTOOLS_RTF_TDFRMTXTRIGHT); m_aRowDefs.append(static_cast(nTdfrmtxtRight)); @@ -868,7 +868,7 @@ void RtfAttributeOutput::TableDefinition( // value of nSz is needed. nSz += pCellFormat->GetFrameSize().GetWidth(); m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CELLX); - m_aRowDefs.append(static_cast(pFormat->GetLRSpace().GetLeft() + m_aRowDefs.append(static_cast(pFormat->GetLRSpace().ResolveLeft({}) + rtl::math::round(nSz * fWidthRatio))); } } @@ -1093,7 +1093,7 @@ void RtfAttributeOutput::TableOrientation( case text::HoriOrientation::NONE: case text::HoriOrientation::LEFT_AND_WIDTH: aTableAdjust.append(OOO_STRING_SVTOOLS_RTF_TRLEFT); - aTableAdjust.append(static_cast(pFormat->GetLRSpace().GetLeft())); + aTableAdjust.append(pFormat->GetLRSpace().ResolveLeft({})); break; default: break; @@ -3252,7 +3252,8 @@ void RtfAttributeOutput::ParaNumRule_Impl(const SwTextNode* pTextNd, sal_Int32 n SvxFirstLineIndentItem firstLine(rNdSet.Get(RES_MARGIN_FIRSTLINE)); SvxTextLeftMarginItem leftMargin(rNdSet.Get(RES_MARGIN_TEXTLEFT)); - leftMargin.SetTextLeft(leftMargin.GetTextLeft() + pFormat->GetIndentAt()); + leftMargin.SetTextLeft( + SvxIndentValue::twips(leftMargin.ResolveTextLeft({}) + pFormat->GetIndentAt())); firstLine.SetTextFirstLineOffset(SvxIndentValue{ static_cast(pFormat->GetFirstLineOffset()), pFormat->GetFirstLineOffsetUnit() }); @@ -3388,9 +3389,9 @@ void RtfAttributeOutput::FormatFirstLineIndent(SvxFirstLineIndentItem const& rFi void RtfAttributeOutput::FormatTextLeftMargin(SvxTextLeftMarginItem const& rTextLeftMargin) { m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LI); - m_aStyles.append(static_cast(rTextLeftMargin.GetTextLeft())); + m_aStyles.append(rTextLeftMargin.ResolveTextLeft({})); m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LIN); - m_aStyles.append(static_cast(rTextLeftMargin.GetTextLeft())); + m_aStyles.append(rTextLeftMargin.ResolveTextLeft({})); } void RtfAttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMargin) @@ -3401,9 +3402,9 @@ void RtfAttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMargi #endif { m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RI); - m_aStyles.append(static_cast(rRightMargin.GetRight())); + m_aStyles.append(rRightMargin.ResolveRight({})); m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RIN); - m_aStyles.append(static_cast(rRightMargin.GetRight())); + m_aStyles.append(rRightMargin.ResolveRight({})); } } @@ -3424,15 +3425,15 @@ void RtfAttributeOutput::FormatLRSpace(const SvxLRSpaceItem& rLRSpace) = pBoxItem->CalcLineSpace(SvxBoxItemLine::RIGHT, /*bEvenIfNoLine*/ true); } - m_aPageMargins.nLeft += sal::static_int_cast(rLRSpace.GetLeft()); - m_aPageMargins.nRight += sal::static_int_cast(rLRSpace.GetRight()); + m_aPageMargins.nLeft += sal::static_int_cast(rLRSpace.ResolveLeft({})); + m_aPageMargins.nRight += sal::static_int_cast(rLRSpace.ResolveRight({})); - if (rLRSpace.GetLeft()) + if (rLRSpace.ResolveLeft({})) { m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGLSXN); m_aSectionBreaks.append(static_cast(m_aPageMargins.nLeft)); } - if (rLRSpace.GetRight()) + if (rLRSpace.ResolveRight({})) { m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGRSXN); m_aSectionBreaks.append(static_cast(m_aPageMargins.nRight)); @@ -3451,13 +3452,13 @@ void RtfAttributeOutput::FormatLRSpace(const SvxLRSpaceItem& rLRSpace) else { m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LI); - m_aStyles.append(static_cast(rLRSpace.GetTextLeft())); + m_aStyles.append(rLRSpace.ResolveTextLeft({})); m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RI); - m_aStyles.append(static_cast(rLRSpace.GetRight())); + m_aStyles.append(rLRSpace.ResolveRight({})); m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LIN); - m_aStyles.append(static_cast(rLRSpace.GetTextLeft())); + m_aStyles.append(rLRSpace.ResolveTextLeft({})); m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RIN); - m_aStyles.append(static_cast(rLRSpace.GetRight())); + m_aStyles.append(rLRSpace.ResolveRight({})); m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FI); m_aStyles.append(rLRSpace.ResolveTextFirstLineOffset({})); } @@ -3468,11 +3469,11 @@ void RtfAttributeOutput::FormatLRSpace(const SvxLRSpaceItem& rLRSpace) m_aFlyProperties.push_back(std::make_pair( "dxWrapDistLeft"_ostr, OString::number( - o3tl::convert(rLRSpace.GetLeft(), o3tl::Length::twip, o3tl::Length::emu)))); + o3tl::convert(rLRSpace.ResolveLeft({}), o3tl::Length::twip, o3tl::Length::emu)))); m_aFlyProperties.push_back(std::make_pair( "dxWrapDistRight"_ostr, OString::number( - o3tl::convert(rLRSpace.GetRight(), o3tl::Length::twip, o3tl::Length::emu)))); + o3tl::convert(rLRSpace.ResolveRight({}), o3tl::Length::twip, o3tl::Length::emu)))); } } diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index bdbcdbe000df..7cdbd70c2e52 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -894,8 +894,10 @@ ErrCode RtfExport::ExportDocument_Impl() { const SvxLRSpaceItem& rLR = rFormatPage.GetLRSpace(); Strm().WriteOString(OOO_STRING_SVTOOLS_RTF_MARGL); - Strm().WriteNumberAsString(rLR.GetLeft()).WriteOString(OOO_STRING_SVTOOLS_RTF_MARGR); - Strm().WriteNumberAsString(rLR.GetRight()); + Strm() + .WriteNumberAsString(rLR.ResolveLeft({})) + .WriteOString(OOO_STRING_SVTOOLS_RTF_MARGR); + Strm().WriteNumberAsString(rLR.ResolveRight({})); } { diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx index 1f3fa03fd962..dd5b9849b3b1 100644 --- a/sw/source/filter/ww8/writerwordglue.cxx +++ b/sw/source/filter/ww8/writerwordglue.cxx @@ -357,13 +357,15 @@ static SvxLRSpaceItem lcl_getWordLRSpace(const SwFrameFormat& rFormat) SvxLRSpaceItem aLR(rFormat.GetLRSpace()); const SvxBoxItem& rBox = rFormat.GetBox(); - aLR.SetLeft(aLR.GetLeft() + rBox.GetDistance(SvxBoxItemLine::LEFT)); + aLR.SetLeft( + SvxIndentValue::twips(aLR.ResolveLeft({}) + rBox.GetDistance(SvxBoxItemLine::LEFT))); if (const editeng::SvxBorderLine* pLeft = rBox.GetLeft()) - aLR.SetLeft(aLR.GetLeft() + pLeft->GetWidth()); + aLR.SetLeft(SvxIndentValue::twips(aLR.ResolveLeft({}) + pLeft->GetWidth())); - aLR.SetRight(aLR.GetRight() + rBox.GetDistance(SvxBoxItemLine::RIGHT)); + aLR.SetRight( + SvxIndentValue::twips(aLR.ResolveRight({}) + rBox.GetDistance(SvxBoxItemLine::RIGHT))); if (const editeng::SvxBorderLine* pRight = rBox.GetRight()) - aLR.SetRight(aLR.GetRight() + pRight->GetWidth()); + aLR.SetRight(SvxIndentValue::twips(aLR.ResolveRight({}) + pRight->GetWidth())); return aLR; } diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index e0b1f250db55..c9a457b2961e 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -2069,10 +2069,8 @@ sal_Int32 SwEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat, MSO_SPT eS */ if (const SvxLRSpaceItem* pItem = rFormat.GetItemIfSet(RES_LR_SPACE)) { - rPropOpt.AddOpt( ESCHER_Prop_dxWrapDistLeft, - DrawModelToEmu( pItem->GetLeft() ) ); - rPropOpt.AddOpt( ESCHER_Prop_dxWrapDistRight, - DrawModelToEmu( pItem->GetRight() ) ); + rPropOpt.AddOpt(ESCHER_Prop_dxWrapDistLeft, DrawModelToEmu(pItem->ResolveLeft({}))); + rPropOpt.AddOpt(ESCHER_Prop_dxWrapDistRight, DrawModelToEmu(pItem->ResolveRight({}))); } else { diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 463646a1cfee..622ad906b992 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -3051,7 +3051,8 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) if ( pFormat->GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { - leftMargin.SetTextLeft(leftMargin.GetTextLeft() + pFormat->GetAbsLSpace()); + leftMargin.SetTextLeft(SvxIndentValue::twips(leftMargin.ResolveTextLeft({}) + + pFormat->GetAbsLSpace())); } if( rNode.IsNumbered() && rNode.IsCountedInList() ) @@ -3170,9 +3171,10 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) SvxFirstLineIndentItem firstLine(pFirstLineIndent ? *pFirstLineIndent : SvxFirstLineIndentItem(RES_MARGIN_FIRSTLINE)); - SvxTextLeftMarginItem leftMargin(pTextLeftMargin + SvxTextLeftMarginItem leftMargin( + pTextLeftMargin ? *pTextLeftMargin - : SvxTextLeftMarginItem(0, RES_MARGIN_TEXTLEFT)); + : SvxTextLeftMarginItem(SvxIndentValue::zero(), RES_MARGIN_TEXTLEFT)); // new left margin = old left + label space const SwNumRule* pRule = rNode.GetNumRule(); @@ -3190,13 +3192,15 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) if ( rNumFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { - leftMargin.SetTextLeft(leftMargin.GetLeft(firstLine, /*metrics*/ {}) - + rNumFormat.GetAbsLSpace()); + leftMargin.SetTextLeft( + SvxIndentValue::twips(leftMargin.ResolveLeft(firstLine, /*metrics*/ {}) + + rNumFormat.GetAbsLSpace())); } else { - leftMargin.SetTextLeft(leftMargin.GetLeft(firstLine, /*metrics*/ {}) - + rNumFormat.GetIndentAt()); + leftMargin.SetTextLeft( + SvxIndentValue::twips(leftMargin.ResolveLeft(firstLine, /*metrics*/ {}) + + rNumFormat.GetIndentAt())); } // new first line indent = 0 diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 6b26ce5533db..64a685254f2a 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -1729,15 +1729,16 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt const SvxLRSpaceItem &rPageLR = pPdFormat->GetFormatAttr( RES_LR_SPACE ); - SvxLRSpaceItem aResultLR(rPageLR.GetLeft() + rSectionLR.GetLeft(), - rPageLR.GetRight() + rSectionLR.GetRight(), - SvxIndentValue::zero(), RES_LR_SPACE); + SvxLRSpaceItem aResultLR( + SvxIndentValue::twips(rPageLR.ResolveLeft({}) + rSectionLR.ResolveLeft({})), + SvxIndentValue::twips(rPageLR.ResolveRight({}) + rSectionLR.ResolveRight({})), + SvxIndentValue::zero(), RES_LR_SPACE); //i120133: The Section width should consider section indent value. - if (rSectionLR.GetLeft()+rSectionLR.GetRight()!=0) + if (rSectionLR.ResolveLeft({}) + rSectionLR.ResolveRight({}) != 0) { const SwFormatCol& rCol = rSepInfo.pSectionFormat->GetFormatAttr(RES_COL); SwFormatCol aCol(rCol); - aCol.SetAdjustValue(rSectionLR.GetLeft()+rSectionLR.GetRight()); + aCol.SetAdjustValue(rSectionLR.ResolveLeft({}) + rSectionLR.ResolveRight({})); aSet.Put(aCol); } else diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 41ec0aaf4e46..cad075e97d8b 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2423,10 +2423,10 @@ void WW8AttributeOutput::TablePositioning(SwFrameFormat* pFlyFormat) m_rWW8Export.InsUInt16(nDyaFromTextBottom); // Similar to WW8AttributeOutput::FormatLRSpace(), but for tables. - sal_uInt16 nDxaFromText = pFlyFormat->GetLRSpace().GetLeft(); + sal_uInt16 nDxaFromText = pFlyFormat->GetLRSpace().ResolveLeft({}); m_rWW8Export.InsUInt16(NS_sprm::TDxaFromText::val); m_rWW8Export.InsUInt16(nDxaFromText); - sal_uInt16 nDxaFromTextRight = pFlyFormat->GetLRSpace().GetRight(); + sal_uInt16 nDxaFromTextRight = pFlyFormat->GetLRSpace().ResolveRight({}); m_rWW8Export.InsUInt16(NS_sprm::TDxaFromTextRight::val); m_rWW8Export.InsUInt16(nDxaFromTextRight); @@ -2500,7 +2500,7 @@ void WW8AttributeOutput::TableDefinition(const ww8::WW8TableNodeInfoInner::Point default: nTableOffset = rHori.GetPos(); const SvxLRSpaceItem& rLRSp = pFormat->GetLRSpace(); - nTableOffset += rLRSp.GetLeft(); + nTableOffset += rLRSp.ResolveLeft({}); // convert offset to be measured from right margin in right-to-left tables if ( nTableOffset && m_rWW8Export.TrueFrameDirection(*pFormat) == SvxFrameDirection::Horizontal_RL_TB ) @@ -2626,8 +2626,8 @@ void AttributeOutputBase::GetTablePageSize( ww8::WW8TableNodeInfoInner const * p if ( 0 == nPageSize ) { const SvxLRSpaceItem& rLR = pParentFormat->GetLRSpace(); - nPageSize = pParentFormat->GetFrameSize().GetWidth() - rLR.GetLeft() - - rLR.GetRight(); + nPageSize = pParentFormat->GetFrameSize().GetWidth() - rLR.ResolveLeft({}) + - rLR.ResolveRight({}); } } else @@ -2637,7 +2637,7 @@ void AttributeOutputBase::GetTablePageSize( ww8::WW8TableNodeInfoInner const * p { // #i37571# For manually aligned tables const SvxLRSpaceItem &rLR = pFormat->GetLRSpace(); - nPageSize -= (rLR.GetLeft() + rLR.GetRight()); + nPageSize -= (rLR.ResolveLeft({}) + rLR.ResolveRight({})); } } diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 37915ccf7b66..895c4636ffe7 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -793,7 +793,7 @@ tools::Long MSWordExportBase::GetParaTabStopOffset() const // don't do it for editengine text, it doesn't implement this anyway if (!m_pISet || m_pISet->GetRanges()[0].first < RES_WHICHHINT_END) { - nOffset = GetItem(RES_MARGIN_TEXTLEFT).GetTextLeft(); + nOffset = GetItem(RES_MARGIN_TEXTLEFT).ResolveTextLeft({}); } } return nOffset; @@ -926,7 +926,8 @@ void MSWordExportBase::OutputFormat( const SwFormat& rFormat, bool bPapFormat, b SvxFirstLineIndentItem firstLine(aSet.Get(RES_MARGIN_FIRSTLINE)); SvxTextLeftMarginItem leftMargin(aSet.Get(RES_MARGIN_TEXTLEFT)); - leftMargin.SetTextLeft(leftMargin.GetTextLeft() + rNFormat.GetAbsLSpace()); + leftMargin.SetTextLeft(SvxIndentValue::twips(leftMargin.ResolveTextLeft({}) + + rNFormat.GetAbsLSpace())); firstLine.SetTextFirstLineOffset( SvxIndentValue::twips(GetWordFirstLineOffset(rNFormat))); @@ -4359,7 +4360,7 @@ void WW8AttributeOutput::FormatTextLeftMargin(SvxTextLeftMarginItem const& rText { // normal paragraphs // sprmPDxaLeft m_rWW8Export.InsUInt16( 0x845E ); //asian version ? - m_rWW8Export.InsUInt16( o3tl::narrowing(rTextLeftMargin.GetTextLeft()) ); + m_rWW8Export.InsUInt16(o3tl::narrowing(rTextLeftMargin.ResolveTextLeft({}))); } void WW8AttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMargin) @@ -4371,7 +4372,7 @@ void WW8AttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMargi { // normal paragraphs // sprmPDxaRight m_rWW8Export.InsUInt16( 0x845D ); //asian version ? - m_rWW8Export.InsUInt16( o3tl::narrowing(rRightMargin.GetRight()) ); + m_rWW8Export.InsUInt16(o3tl::narrowing(rRightMargin.ResolveRight({}))); } } @@ -4384,7 +4385,8 @@ void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR ) // sprmPDxaFromText10 m_rWW8Export.InsUInt16( NS_sprm::LN_PDxaFromText10 ); // use average, since WW only knows one value - m_rWW8Export.InsUInt16( o3tl::narrowing( ( rLR.GetLeft() + rLR.GetRight() ) / 2 ) ); + m_rWW8Export.InsUInt16( + o3tl::narrowing((rLR.ResolveLeft({}) + rLR.ResolveRight({})) / 2)); } else if ( m_rWW8Export.m_bOutPageDescs ) // PageDescs { @@ -4397,8 +4399,8 @@ void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR ) m_pageMargins.nRight = pBoxItem->CalcLineSpace( SvxBoxItemLine::RIGHT, /*bEvenIfNoLine*/true ); } - m_pageMargins.nLeft += sal::static_int_cast(rLR.GetLeft()); - m_pageMargins.nRight += sal::static_int_cast(rLR.GetRight()); + m_pageMargins.nLeft += sal::static_int_cast(rLR.ResolveLeft({})); + m_pageMargins.nRight += sal::static_int_cast(rLR.ResolveRight({})); sal_uInt16 nGutter = rLR.GetGutterMargin(); // sprmSDxaLeft @@ -4420,11 +4422,11 @@ void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR ) { // normal paragraphs // sprmPDxaLeft m_rWW8Export.InsUInt16( 0x845E ); //asian version ? - m_rWW8Export.InsUInt16( o3tl::narrowing(rLR.GetTextLeft()) ); + m_rWW8Export.InsUInt16(o3tl::narrowing(rLR.ResolveTextLeft({}))); // sprmPDxaRight m_rWW8Export.InsUInt16( 0x845D ); //asian version ? - m_rWW8Export.InsUInt16( o3tl::narrowing(rLR.GetRight()) ); + m_rWW8Export.InsUInt16(o3tl::narrowing(rLR.ResolveRight({}))); // sprmPDxaLeft1 // tdf#80596: TODO export sprmPDxcLeft1 for first line indents in ICs @@ -4976,8 +4978,8 @@ SwTwips WW8Export::CurrentPageWidth(SwTwips &rLeft, SwTwips &rRight) const const SvxLRSpaceItem& rLR = pFormat->GetLRSpace(); SwTwips nPageSize = pFormat->GetFrameSize().GetWidth(); - rLeft = rLR.GetLeft(); - rRight = rLR.GetRight(); + rLeft = rLR.ResolveLeft({}); + rRight = rLR.ResolveRight({}); return nPageSize; } @@ -5066,7 +5068,7 @@ void AttributeOutputBase::FormatColumns( const SwFormatCol& rCol ) { const SvxLRSpaceItem &rLR = pFormat->GetLRSpace(); nPageSize = pFormat->GetFrameSize().GetWidth(); - nPageSize -= rLR.GetLeft() + rLR.GetRight(); + nPageSize -= rLR.ResolveLeft({}) + rLR.ResolveRight({}); //i120133: The Section width should consider page indent value. nPageSize -= rCol.GetAdjustValue(); @@ -5567,7 +5569,7 @@ void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops ) { if (const auto pLeft = pItem->DynamicWhichCast(RES_MARGIN_TEXTLEFT)) { - nCurrentLeft = pLeft->GetTextLeft(); + nCurrentLeft = pLeft->ResolveTextLeft({}); } else // FIXME: This fails in sw.ww8export/testCommentExport::Load_Verify_Reload_Verify @@ -5594,7 +5596,7 @@ void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops ) if ( bTabsRelativeToIndex ) { SvxTextLeftMarginItem const& rLeftMargin(pParentStyle->GetAttrSet().Get(RES_MARGIN_TEXTLEFT)); - nParentLeft = rLeftMargin.GetTextLeft(); + nParentLeft = rLeftMargin.ResolveTextLeft({}); } ParaTabStopDelAdd( m_rWW8Export, aParentTabs, nParentLeft, rTabStops, nCurrentLeft ); @@ -5617,7 +5619,7 @@ void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops ) if ( bTabsRelativeToIndex ) { SvxTextLeftMarginItem const& rLeftMargin(m_rWW8Export.m_pStyAttr->Get(RES_MARGIN_TEXTLEFT)); - nStyleLeft = rLeftMargin.GetTextLeft(); + nStyleLeft = rLeftMargin.ResolveTextLeft({}); } ParaTabStopDelAdd( m_rWW8Export, diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index fd25867d8c8c..16fca927f57d 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -1992,7 +1992,7 @@ void SwWW8ImplReader::AdjustLRWrapForWordMargins( if (rRecord.nXAlign == 1) { if ((nXRelTo == 0) || (nXRelTo == 2)) - rLR.SetLeft(sal_uInt16(0)); + rLR.SetLeft(SvxIndentValue::zero()); } // Right adjustments - if horizontally aligned to right of @@ -2000,19 +2000,19 @@ void SwWW8ImplReader::AdjustLRWrapForWordMargins( if (rRecord.nXAlign == 3) { if ((nXRelTo == 0) || (nXRelTo == 2)) - rLR.SetRight(sal_uInt16(0)); + rLR.SetRight(SvxIndentValue::zero()); } // Inside margin, remove left wrapping if ((rRecord.nXAlign == 4) && (nXRelTo == 0)) { - rLR.SetLeft(sal_uInt16(0)); + rLR.SetLeft(SvxIndentValue::zero()); } // Outside margin, remove left wrapping if ((rRecord.nXAlign == 5) && (nXRelTo == 0)) { - rLR.SetRight(sal_uInt16(0)); + rLR.SetRight(SvxIndentValue::zero()); } } @@ -2051,8 +2051,8 @@ void SwWW8ImplReader::MapWrapIntoFlyFormat(const SvxMSDffImportRec& rRecord, { if (rRecord.nDxWrapDistLeft || rRecord.nDxWrapDistRight) { - SvxLRSpaceItem aLR(writer_cast(rRecord.nDxWrapDistLeft), - writer_cast(rRecord.nDxWrapDistRight), + SvxLRSpaceItem aLR(SvxIndentValue::twips(writer_cast(rRecord.nDxWrapDistLeft)), + SvxIndentValue::twips(writer_cast(rRecord.nDxWrapDistRight)), SvxIndentValue::zero(), RES_LR_SPACE); AdjustLRWrapForWordMargins(rRecord, aLR); rFlyFormat.SetFormatAttr(aLR); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index e3fb612e75de..0ed8fcac0ca7 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1225,7 +1225,7 @@ static tools::Long lcl_GetTrueMargin(SvxFirstLineIndentItem const& rFirstLine, OSL_ENSURE( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION, " - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION" ); - const tools::Long nBodyIndent = rLeftMargin.GetTextLeft(); + const tools::Long nBodyIndent = rLeftMargin.ResolveTextLeft({}); const tools::Long nFirstLineDiff = rFirstLine.ResolveTextFirstLineOffset({}); rFirstLinePos = nBodyIndent + nFirstLineDiff; @@ -1248,7 +1248,7 @@ void SyncIndentWithList( SvxFirstLineIndentItem & rFirstLine, { tools::Long nWantedFirstLinePos; tools::Long nExtraListIndent = lcl_GetTrueMargin(rFirstLine, rLeftMargin, rFormat, nWantedFirstLinePos); - rLeftMargin.SetTextLeft(nWantedFirstLinePos - nExtraListIndent); + rLeftMargin.SetTextLeft(SvxIndentValue::twips(nWantedFirstLinePos - nExtraListIndent)); rFirstLine.SetTextFirstLineOffset(SvxIndentValue::zero()); } else if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) @@ -1263,7 +1263,7 @@ void SyncIndentWithList( SvxFirstLineIndentItem & rFirstLine, else if ( bFirstLineOfstSet && !bLeftIndentSet && rFormat.GetIndentAt() != 0 ) { - rLeftMargin.SetTextLeft(rFormat.GetIndentAt()); + rLeftMargin.SetTextLeft(SvxIndentValue::twips(rFormat.GetIndentAt())); } else if (!bFirstLineOfstSet && !bLeftIndentSet ) { @@ -1275,7 +1275,7 @@ void SyncIndentWithList( SvxFirstLineIndentItem & rFirstLine, } if ( rFormat.GetIndentAt() != 0 ) { - rLeftMargin.SetTextLeft(rFormat.GetIndentAt()); + rLeftMargin.SetTextLeft(SvxIndentValue::twips(rFormat.GetIndentAt())); } } } diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index dc2a4ed4f77a..246f56ad9b84 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -2526,7 +2526,7 @@ void WW8TabDesc::CreateSwTable() nLeft += m_pIo->m_aSectionManager.GetTextAreaWidth(); nLeft = nLeft - nTableWidth - GetMinLeft(); } - aL.SetLeft(nLeft); + aL.SetLeft(SvxIndentValue::twips(nLeft)); m_aItemSet.Put(aL); } diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index e3fc0acabd88..4a08b1c58af7 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -1679,7 +1679,7 @@ void UseListIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat) const tools::Long nListFirstLineIndent = GetListFirstLineIndent(rFormat); SvxFirstLineIndentItem firstLine(rStyle.m_pFormat->GetFormatAttr(RES_MARGIN_FIRSTLINE)); SvxTextLeftMarginItem leftMargin(rStyle.m_pFormat->GetFormatAttr(RES_MARGIN_TEXTLEFT)); - leftMargin.SetTextLeft(nAbsLSpace); + leftMargin.SetTextLeft(SvxIndentValue::twips(nAbsLSpace)); firstLine.SetTextFirstLineOffset(SvxIndentValue::twips(nListFirstLineIndent)); rStyle.m_pFormat->SetFormatAttr(firstLine); rStyle.m_pFormat->SetFormatAttr(leftMargin); @@ -1701,7 +1701,7 @@ void SetStyleIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat) } else { - leftMargin.SetTextLeft(0); + leftMargin.SetTextLeft(SvxIndentValue::zero()); firstLine.SetTextFirstLineOffset(SvxIndentValue::zero()); } rStyle.m_pFormat->SetFormatAttr(firstLine); @@ -2021,7 +2021,7 @@ void SwWW8ImplReader::Read_LFOPosition(sal_uInt16, const sal_uInt8* pData, // reset/blank the left indent (and only the left) pFirstLine->SetTextFirstLineOffset(SvxIndentValue::zero()); - SvxTextLeftMarginItem leftMargin(0, RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem leftMargin(SvxIndentValue::zero(), RES_MARGIN_TEXTLEFT); // apply the modified SvxLRSpaceItem to the current paragraph pTextNode->SetAttr(*pFirstLine); diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 2a229d831a25..4ba3fb42a401 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -227,8 +227,8 @@ void SwWW8ImplReader::SetDocumentGrid(SwFrameFormat &rFormat, const wwSection &r SwTwips nTextareaWidth = rFormat.GetFrameSize().GetWidth(); const SvxLRSpaceItem &rLR = rFormat.GetFormatAttr(RES_LR_SPACE); - nTextareaWidth -= rLR.GetLeft(); - nTextareaWidth -= rLR.GetRight(); + nTextareaWidth -= rLR.ResolveLeft({}); + nTextareaWidth -= rLR.ResolveRight({}); if (rSection.IsVertical()) std::swap(nTextareaHeight, nTextareaWidth); @@ -523,7 +523,8 @@ void wwSectionManager::SetPage(SwPageDesc &rInPageDesc, SwFrameFormat &rFormat, aSz.SetHeight(SvxPaperInfo::GetSloppyPaperDimension(rSection.GetPageHeight())); rFormat.SetFormatAttr(aSz); - SvxLRSpaceItem aLR(rSection.GetPageLeft(), rSection.GetPageRight(), SvxIndentValue::zero(), + SvxLRSpaceItem aLR(SvxIndentValue::twips(rSection.GetPageLeft()), + SvxIndentValue::twips(rSection.GetPageRight()), SvxIndentValue::zero(), RES_LR_SPACE); aLR.SetGutterMargin(rSection.m_nPgGutter); rFormat.SetFormatAttr(aLR); @@ -566,8 +567,10 @@ void SwWW8ImplReader::SetPageBorder(SwFrameFormat &rFormat, const wwSection &rSe SvxBoxItem aBox(aSet.Get(RES_BOX)); bool bFromEdge = rSection.maSep.pgbOffsetFrom == 1; - aLR.SetLeft(SetBorderDistance(bFromEdge, aBox, SvxBoxItemLine::LEFT, aLR.GetLeft())); - aLR.SetRight(SetBorderDistance(bFromEdge, aBox, SvxBoxItemLine::RIGHT, aLR.GetRight())); + aLR.SetLeft(SvxIndentValue::twips( + SetBorderDistance(bFromEdge, aBox, SvxBoxItemLine::LEFT, aLR.ResolveLeft({})))); + aLR.SetRight(SvxIndentValue::twips( + SetBorderDistance(bFromEdge, aBox, SvxBoxItemLine::RIGHT, aLR.ResolveRight({})))); aUL.SetUpper(SetBorderDistance(bFromEdge, aBox, SvxBoxItemLine::TOP, aUL.GetUpper())); aUL.SetLower(SetBorderDistance(bFromEdge, aBox, SvxBoxItemLine::BOTTOM, aUL.GetLower())); @@ -756,13 +759,15 @@ SwSectionFormat *wwSectionManager::InsertSection( SwFrameFormat& rFormat = pPage->GetMaster(); const SvxLRSpaceItem& rLR = rFormat.GetLRSpace(); - tools::Long nPageLeft = rLR.GetLeft(); - tools::Long nPageRight = rLR.GetRight(); + tools::Long nPageLeft = rLR.ResolveLeft({}); + tools::Long nPageRight = rLR.ResolveRight({}); tools::Long nSectionLeft = rSection.GetPageLeft() - nPageLeft; tools::Long nSectionRight = rSection.GetPageRight() - nPageRight; if ((nSectionLeft != 0) || (nSectionRight != 0)) { - SvxLRSpaceItem aLR(nSectionLeft, nSectionRight, SvxIndentValue::zero(), RES_LR_SPACE); + SvxLRSpaceItem aLR(SvxIndentValue::twips(nSectionLeft), + SvxIndentValue::twips(nSectionRight), SvxIndentValue::zero(), + RES_LR_SPACE); pFormat->SetFormatAttr(aLR); } @@ -2192,8 +2197,9 @@ WW8FlySet::WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW, Put( SwFormatHoriOrient(nXPos, pFS->eHAlign, pFS->eHRel, pFS->bTogglePos )); Put( SwFormatVertOrient( pFS->nYPos, pFS->eVAlign, pFS->eVRel ) ); - if (pFS->nLeftMargin || pFS->nRightMargin) // set borders - Put(SvxLRSpaceItem(pFS->nLeftMargin, pFS->nRightMargin, SvxIndentValue::zero(), + if (pFS->nLeftMargin || pFS->nRightMargin) // set borders + Put(SvxLRSpaceItem(SvxIndentValue::twips(pFS->nLeftMargin), + SvxIndentValue::twips(pFS->nRightMargin), SvxIndentValue::zero(), RES_LR_SPACE)); if (pFS->nUpperMargin || pFS->nLowerMargin) @@ -2255,7 +2261,8 @@ WW8FlySet::WW8FlySet( SwWW8ImplReader& rReader, const SwPaM* pPaM, brcVer9[i] = WW8_BRCVer9(rPic.rgbrc[i]); if (SwWW8ImplReader::SetFlyBordersShadow( *this, brcVer9, &aSizeArray[0])) { - Put(SvxLRSpaceItem(aSizeArray[WW8_LEFT], 0, SvxIndentValue::zero(), RES_LR_SPACE)); + Put(SvxLRSpaceItem(SvxIndentValue::twips(aSizeArray[WW8_LEFT]), SvxIndentValue::zero(), + SvxIndentValue::zero(), RES_LR_SPACE)); Put(SvxULSpaceItem( aSizeArray[WW8_TOP], 0, RES_UL_SPACE )); aSizeArray[WW8_RIGHT]*=2; aSizeArray[WW8_BOT]*=2; @@ -2656,10 +2663,10 @@ void SwWW8ImplReader::StripNegativeAfterIndent(SwFrameFormat const *pFlyFormat) if (pNd) { const SvxRightMarginItem & rRightMargin(pNd->GetAttr(RES_MARGIN_RIGHT)); - if (rRightMargin.GetRight() < 0) + if (rRightMargin.GetRight().m_dValue < 0.0) { SvxRightMarginItem rightMargin(rRightMargin); - rightMargin.SetRight(0); + rightMargin.SetRight(SvxIndentValue::zero()); pNd->SetAttr(rightMargin); } } @@ -4301,7 +4308,7 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe const SwNumFormat* pFormat = pNumRule->GetNumFormat( nLvl ); if ( pFormat && pFormat->GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { - pLeftMargin->SetTextLeft(pFormat->GetIndentAt()); + pLeftMargin->SetTextLeft(SvxIndentValue::twips(pFormat->GetIndentAt())); pFirstLine->SetTextFirstLineOffset( SvxIndentValue{ static_cast(pFormat->GetFirstLineIndent()), pFormat->GetFirstLineIndentUnit() }); @@ -4347,7 +4354,7 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe case NS_sprm::v6::sprmPDxaLeft: case NS_sprm::PDxaLeft80::val: case NS_sprm::PDxaLeft::val: - pLeftMargin->SetTextLeft(nPara); + pLeftMargin->SetTextLeft(SvxIndentValue::twips(nPara)); if (m_pCurrentColl && m_nCurrentColl < m_vColl.size()) { m_vColl[m_nCurrentColl].m_bListRelevantIndentSet = true; @@ -4392,7 +4399,8 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe { if (!lcl_HasExplicitLeft(m_xPlcxMan.get(), m_bVer67)) { - pLeftMargin->SetTextLeft(pNumFormat->GetIndentAt()); + pLeftMargin->SetTextLeft( + SvxIndentValue::twips(pNumFormat->GetIndentAt())); // If have not explicit left, set number format list tab position is doc default tab const SvxTabStopItem *pDefaultStopItem = m_rDoc.GetAttrPool().GetUserDefaultItem(RES_PARATR_TABSTOP); @@ -4412,7 +4420,7 @@ void SwWW8ImplReader::Read_LR( sal_uInt16 nId, const sal_uInt8* pData, short nLe case NS_sprm::v6::sprmPDxaRight: case NS_sprm::PDxaRight80::val: case NS_sprm::PDxaRight::val: - pRightMargin->SetRight(nPara); + pRightMargin->SetRight(SvxIndentValue::twips(nPara)); break; default: return; diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx index 637adfcccbe5..4e906dec6c33 100644 --- a/sw/source/filter/xml/xmlexpit.cxx +++ b/sw/source/filter/xml/xmlexpit.cxx @@ -387,10 +387,14 @@ bool SvXMLExportItemMapper::QueryXMLValue( ::sax::Converter::convertPercent( aOut, rLRSpace.GetPropLeft() ); } + else if (rLRSpace.GetLeft().m_nUnit != css::util::MeasureUnit::TWIP) + { + ::sax::Converter::convertMeasureUnit(aOut, rLRSpace.GetLeft().m_dValue, + rLRSpace.GetLeft().m_nUnit); + } else { - rUnitConverter.convertMeasureToXML( - aOut, rLRSpace.GetLeft() ); + rUnitConverter.convertMeasureToXML(aOut, rLRSpace.GetLeft().m_dValue); } break; @@ -400,10 +404,14 @@ bool SvXMLExportItemMapper::QueryXMLValue( ::sax::Converter::convertPercent( aOut, rLRSpace.GetPropRight() ); } + else if (rLRSpace.GetRight().m_nUnit != css::util::MeasureUnit::TWIP) + { + ::sax::Converter::convertMeasureUnit(aOut, rLRSpace.GetRight().m_dValue, + rLRSpace.GetRight().m_nUnit); + } else { - rUnitConverter.convertMeasureToXML( - aOut, rLRSpace.GetRight() ); + rUnitConverter.convertMeasureToXML(aOut, rLRSpace.GetRight().m_dValue); } break; @@ -425,17 +433,17 @@ bool SvXMLExportItemMapper::QueryXMLValue( ::sax::Converter::convertPercent( aOut, rLRSpace.GetPropTextFirstLineOffset() ); } - else if (rLRSpace.GetTextFirstLineOffsetUnit() + else if (rLRSpace.GetTextFirstLineOffset().m_nUnit != css::util::MeasureUnit::TWIP) { ::sax::Converter::convertMeasureUnit( - aOut, rLRSpace.GetTextFirstLineOffsetValue(), - rLRSpace.GetTextFirstLineOffsetUnit()); + aOut, rLRSpace.GetTextFirstLineOffset().m_dValue, + rLRSpace.GetTextFirstLineOffset().m_nUnit); } else { rUnitConverter.convertMeasureToXML( - aOut, rLRSpace.GetTextFirstLineOffsetValue()); + aOut, rLRSpace.GetTextFirstLineOffset().m_dValue); } } else diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx index a4dbe7e328b1..af8e30c19a5e 100644 --- a/sw/source/filter/xml/xmlimpit.cxx +++ b/sw/source/filter/xml/xmlimpit.cxx @@ -345,10 +345,12 @@ bool SvXMLImportItemMapper::PutXMLValue( switch( nMemberId ) { case MID_L_MARGIN: - rLRSpace.SetTextLeft( nAbs, o3tl::narrowing(nProp) ); + rLRSpace.SetTextLeft(SvxIndentValue::twips(nAbs), + o3tl::narrowing(nProp)); break; case MID_R_MARGIN: - rLRSpace.SetRight( nAbs, o3tl::narrowing(nProp) ); + rLRSpace.SetRight(SvxIndentValue::twips(nAbs), + o3tl::narrowing(nProp)); break; } } diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx index d82f13a14049..896144f953b1 100644 --- a/sw/source/ui/dialog/uiregionsw.cxx +++ b/sw/source/ui/dialog/uiregionsw.cxx @@ -2091,9 +2091,11 @@ bool SwSectionIndentTabPage::FillItemSet(SfxItemSet* rSet) { if (m_xBeforeMF->get_value_changed_from_saved() || m_xAfterMF->get_value_changed_from_saved()) { - SvxLRSpaceItem aLRSpace(m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP)), - m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP)), - SvxIndentValue::zero(), RES_LR_SPACE); + SvxLRSpaceItem aLRSpace( + SvxIndentValue::twips( + m_xBeforeMF->denormalize(m_xBeforeMF->get_value(FieldUnit::TWIP))), + SvxIndentValue::twips(m_xAfterMF->denormalize(m_xAfterMF->get_value(FieldUnit::TWIP))), + SvxIndentValue::zero(), RES_LR_SPACE); rSet->Put(aLRSpace); } return true; @@ -2112,8 +2114,8 @@ void SwSectionIndentTabPage::Reset( const SfxItemSet* rSet) const SvxLRSpaceItem& rSpace = rSet->Get( RES_LR_SPACE ); - m_xBeforeMF->set_value(m_xBeforeMF->normalize(rSpace.GetLeft()), FieldUnit::TWIP); - m_xAfterMF->set_value(m_xAfterMF->normalize(rSpace.GetRight()), FieldUnit::TWIP); + m_xBeforeMF->set_value(m_xBeforeMF->normalize(rSpace.ResolveLeft({})), FieldUnit::TWIP); + m_xAfterMF->set_value(m_xAfterMF->normalize(rSpace.ResolveRight({})), FieldUnit::TWIP); } else { diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx index cea77abbdb80..8e635e0eebff 100644 --- a/sw/source/ui/envelp/envfmt.cxx +++ b/sw/source/ui/envelp/envfmt.cxx @@ -223,7 +223,7 @@ void SwEnvFormatPage::Edit(std::u16string_view rIdent, bool bSender) aTmpSet.Put( aTabPos ); // left border as offset - const tools::Long nOff = aTmpSet.Get(RES_MARGIN_TEXTLEFT).GetTextLeft(); + const tools::Long nOff = aTmpSet.Get(RES_MARGIN_TEXTLEFT).ResolveTextLeft({}); SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff ); aTmpSet.Put( aOff ); diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx index 8edd1959a1de..8352bd72ff66 100644 --- a/sw/source/ui/frmdlg/column.cxx +++ b/sw/source/ui/frmdlg/column.cxx @@ -144,7 +144,8 @@ SwColumnDlg::SwColumnDlg(weld::Window* pParent, SwWrtShell& rSh) const SvxLRSpaceItem& rLRSpace = rFormat.GetLRSpace(); const SvxBoxItem& rBox = rFormat.GetBox(); - m_nPageWidth -= rLRSpace.GetLeft() + rLRSpace.GetRight() + rBox.GetSmallestDistance(); + m_nPageWidth + -= rLRSpace.ResolveLeft({}) + rLRSpace.ResolveRight({}) + rBox.GetSmallestDistance(); m_pPageSet->Put(rFormat.GetCol()); m_pPageSet->Put(rFormat.GetLRSpace()); @@ -1171,8 +1172,8 @@ void SwColumnPage::ActivatePage(const SfxItemSet& rSet) { const SvxLRSpaceItem& rLRSpace = rSet.Get(RES_LR_SPACE); const SvxBoxItem& rBox = rSet.Get(RES_BOX); - nActWidth = rSize.GetSize().Width() - - rLRSpace.GetLeft() - rLRSpace.GetRight() - rBox.GetSmallestDistance(); + nActWidth = rSize.GetSize().Width() - rLRSpace.ResolveLeft({}) + - rLRSpace.ResolveRight({}) - rBox.GetSmallestDistance(); } else { diff --git a/sw/source/ui/frmdlg/wrap.cxx b/sw/source/ui/frmdlg/wrap.cxx index 6e2047928ae0..e12ebb47aa36 100644 --- a/sw/source/ui/frmdlg/wrap.cxx +++ b/sw/source/ui/frmdlg/wrap.cxx @@ -241,8 +241,8 @@ void SwWrapTabPage::Reset(const SfxItemSet *rSet) const SvxLRSpaceItem& rLR = rSet->Get(RES_LR_SPACE); // gap to text - m_xLeftMarginED->set_value(m_xLeftMarginED->normalize(rLR.GetLeft()), FieldUnit::TWIP); - m_xRightMarginED->set_value(m_xRightMarginED->normalize(rLR.GetRight()), FieldUnit::TWIP); + m_xLeftMarginED->set_value(m_xLeftMarginED->normalize(rLR.ResolveLeft({})), FieldUnit::TWIP); + m_xRightMarginED->set_value(m_xRightMarginED->normalize(rLR.ResolveRight({})), FieldUnit::TWIP); m_xTopMarginED->set_value(m_xTopMarginED->normalize(rUL.GetUpper()), FieldUnit::TWIP); m_xBottomMarginED->set_value(m_xBottomMarginED->normalize(rUL.GetLower()), FieldUnit::TWIP); @@ -337,8 +337,10 @@ bool SwWrapTabPage::FillItemSet(SfxItemSet *rSet) bool bRightMod = m_xRightMarginED->get_value_changed_from_saved(); SvxLRSpaceItem aLR( RES_LR_SPACE ); - aLR.SetLeft(o3tl::narrowing(m_xLeftMarginED->denormalize(m_xLeftMarginED->get_value(FieldUnit::TWIP)))); - aLR.SetRight(o3tl::narrowing(m_xRightMarginED->denormalize(m_xRightMarginED->get_value(FieldUnit::TWIP)))); + aLR.SetLeft(SvxIndentValue::twips(o3tl::narrowing( + m_xLeftMarginED->denormalize(m_xLeftMarginED->get_value(FieldUnit::TWIP))))); + aLR.SetRight(SvxIndentValue::twips(o3tl::narrowing( + m_xRightMarginED->denormalize(m_xRightMarginED->get_value(FieldUnit::TWIP))))); if ( bLeftMod || bRightMod ) { diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx index 64dbdf825277..d4a97633feb7 100644 --- a/sw/source/ui/misc/pggrid.cxx +++ b/sw/source/ui/misc/pggrid.cxx @@ -276,7 +276,7 @@ void SwTextGridPage::UpdatePageSize(const SfxItemSet& rSet) const SvxLRSpaceItem& rLRSpace = rSet.Get( RES_LR_SPACE ); const SvxULSpaceItem& rULSpace = rSet.Get( RES_UL_SPACE ); const SvxBoxItem& rBox = rSet.Get(RES_BOX); - sal_Int32 nDistanceLR = rLRSpace.GetLeft() + rLRSpace.GetRight(); + sal_Int32 nDistanceLR = rLRSpace.ResolveLeft({}) + rLRSpace.ResolveRight({}); sal_Int32 nDistanceUL = rULSpace.GetUpper() + rULSpace.GetLower(); for( const TypedWhichId & nId : { SID_ATTR_PAGE_HEADERSET, SID_ATTR_PAGE_FOOTERSET }) diff --git a/sw/source/uibase/app/appenv.cxx b/sw/source/uibase/app/appenv.cxx index 6c744867ada1..d3a36a7518c6 100644 --- a/sw/source/uibase/app/appenv.cxx +++ b/sw/source/uibase/app/appenv.cxx @@ -355,9 +355,9 @@ void SwModule::InsertEnv( SfxRequest& rReq ) } SvxLRSpaceItem aLRMargin( RES_LR_SPACE ); SvxULSpaceItem aULMargin( RES_UL_SPACE ); - aLRMargin.SetLeft (o3tl::narrowing(lLeft) ); + aLRMargin.SetLeft(SvxIndentValue::twips(o3tl::narrowing(lLeft))); aULMargin.SetUpper(o3tl::narrowing(lUpper)); - aLRMargin.SetRight(0); + aLRMargin.SetRight(SvxIndentValue::zero()); aULMargin.SetLower(0); rFormat.SetFormatAttr(aLRMargin); rFormat.SetFormatAttr(aULMargin); diff --git a/sw/source/uibase/app/applab.cxx b/sw/source/uibase/app/applab.cxx index 279bed8d1e74..c71906653829 100644 --- a/sw/source/uibase/app/applab.cxx +++ b/sw/source/uibase/app/applab.cxx @@ -227,9 +227,9 @@ void SwModule::InsertLab(SfxRequest& rReq, bool bLabel) // Borders SvxLRSpaceItem aLRMargin( RES_LR_SPACE ); SvxULSpaceItem aULMargin( RES_UL_SPACE ); - aLRMargin.SetLeft (o3tl::narrowing(rItem.m_lLeft) ); + aLRMargin.SetLeft(SvxIndentValue::twips(o3tl::narrowing(rItem.m_lLeft))); aULMargin.SetUpper(o3tl::narrowing(rItem.m_lUpper)); - aLRMargin.SetRight( 0 ); + aLRMargin.SetRight(SvxIndentValue::zero()); aULMargin.SetLower( 0 ); rFormat.SetFormatAttr(aLRMargin); rFormat.SetFormatAttr(aULMargin); @@ -282,7 +282,8 @@ void SwModule::InsertLab(SfxRequest& rReq, bool bLabel) //frame represents label itself, no border space SvxULSpaceItem aFrameNoULSpace( 0, 0, RES_UL_SPACE ); - SvxLRSpaceItem aFrameNoLRSpace(0, 0, SvxIndentValue::zero(), RES_LR_SPACE); + SvxLRSpaceItem aFrameNoLRSpace(SvxIndentValue::zero(), SvxIndentValue::zero(), + SvxIndentValue::zero(), RES_LR_SPACE); pFormat->SetFormatAttr( aFrameNoULSpace ); pFormat->SetFormatAttr( aFrameNoLRSpace ); diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx index 277679464613..31e7b14ab127 100644 --- a/sw/source/uibase/app/docstyle.cxx +++ b/sw/source/uibase/app/docstyle.cxx @@ -222,7 +222,8 @@ public: { if (!oLRSpaceItem) oLRSpaceItem.emplace(EE_PARA_LRSPACE); - (*oLRSpaceItem).SetTextLeft(static_cast(pItem)->GetTextLeft()); + (*oLRSpaceItem) + .SetTextLeft(static_cast(pItem)->GetTextLeft()); } else if (nWhich == RES_MARGIN_RIGHT) { @@ -1611,7 +1612,8 @@ void SwDocStyleSheet::MergeIndentAttrsOfListStyle( SfxItemSet& rSet ) } if (indents & ::sw::ListLevelIndents::LeftMargin) { - SvxTextLeftMarginItem const leftMargin(rFormat.GetIndentAt(), RES_MARGIN_TEXTLEFT); + SvxTextLeftMarginItem const leftMargin(SvxIndentValue::twips(rFormat.GetIndentAt()), + RES_MARGIN_TEXTLEFT); rSet.Put(leftMargin); } } diff --git a/sw/source/uibase/frmdlg/colex.cxx b/sw/source/uibase/frmdlg/colex.cxx index 3864e61c66b6..d8843596d87b 100644 --- a/sw/source/uibase/frmdlg/colex.cxx +++ b/sw/source/uibase/frmdlg/colex.cxx @@ -67,8 +67,8 @@ void SwPageExample::UpdateExample( const SfxItemSet& rSet ) // set left and right border const SvxLRSpaceItem& rLRSpace = static_cast(rSet.Get( nWhich )); - SetLeft( rLRSpace.GetLeft() ); - SetRight( rLRSpace.GetRight() ); + SetLeft(rLRSpace.ResolveLeft({})); + SetRight(rLRSpace.ResolveRight({})); } else { @@ -111,8 +111,8 @@ void SwPageExample::UpdateExample( const SfxItemSet& rSet ) SetHdHeight( rSize.GetSize().Height() - rUL.GetLower()); SetHdDist( rUL.GetLower() ); - SetHdLeft( rLR.GetLeft() ); - SetHdRight( rLR.GetRight() ); + SetHdLeft(rLR.ResolveLeft({})); + SetHdRight(rLR.ResolveRight({})); SetHeader( true ); if(SfxItemState::SET == rHeaderSet.GetItemState(RES_BACKGROUND)) @@ -147,8 +147,8 @@ void SwPageExample::UpdateExample( const SfxItemSet& rSet ) SetFtHeight( rSize.GetSize().Height() - rUL.GetUpper()); SetFtDist( rUL.GetUpper() ); - SetFtLeft( rLR.GetLeft() ); - SetFtRight( rLR.GetRight() ); + SetFtLeft(rLR.ResolveLeft({})); + SetFtRight(rLR.ResolveRight({})); SetFooter( true ); if( rFooterSet.GetItemState( RES_BACKGROUND ) == SfxItemState::SET ) diff --git a/sw/source/uibase/frmdlg/colmgr.cxx b/sw/source/uibase/frmdlg/colmgr.cxx index 692a8395d662..495039efba74 100644 --- a/sw/source/uibase/frmdlg/colmgr.cxx +++ b/sw/source/uibase/frmdlg/colmgr.cxx @@ -141,8 +141,8 @@ SwColMgr::SwColMgr(const SfxItemSet& rSet) if (m_nWidth < MINLAY) m_nWidth = USHRT_MAX; const SvxLRSpaceItem& rLR = rSet.Get(RES_LR_SPACE); - m_nWidth = m_nWidth - o3tl::narrowing(rLR.GetLeft()); - m_nWidth = m_nWidth - o3tl::narrowing(rLR.GetRight()); + m_nWidth = m_nWidth - o3tl::narrowing(rLR.ResolveLeft({})); + m_nWidth = m_nWidth - o3tl::narrowing(rLR.ResolveRight({})); ::FitToActualSize(m_aFormatCol, m_nWidth); } diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx b/sw/source/uibase/frmdlg/frmmgr.cxx index cdfeb267b990..275bd4a8cb66 100644 --- a/sw/source/uibase/frmdlg/frmmgr.cxx +++ b/sw/source/uibase/frmdlg/frmmgr.cxx @@ -543,10 +543,10 @@ void SwFlyFrameAttrMgr::SetLRSpace( tools::Long nLeft, tools::Long nRight ) OSL_ENSURE( LONG_MAX != nLeft && LONG_MAX != nRight, "Which border to set?" ); SvxLRSpaceItem aTmp( m_aSet.Get( RES_LR_SPACE ) ); - if( LONG_MAX != nLeft ) - aTmp.SetLeft( sal_uInt16(nLeft) ); - if( LONG_MAX != nRight ) - aTmp.SetRight( sal_uInt16(nRight) ); + if (LONG_MAX != nLeft) + aTmp.SetLeft(SvxIndentValue::twips(nLeft)); + if (LONG_MAX != nRight) + aTmp.SetRight(SvxIndentValue::twips(nRight)); m_aSet.Put( aTmp ); } diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx index 52aff06cdcaa..7ca27451c256 100644 --- a/sw/source/uibase/shells/drwtxtex.cxx +++ b/sw/source/uibase/shells/drwtxtex.cxx @@ -250,7 +250,8 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) nIndentDist = ::GetTabDist(rDefTabItem); } - aParaMargin.SetTextLeft(aParaMargin.GetTextLeft() + nIndentDist); + aParaMargin.SetTextLeft( + SvxIndentValue::twips(aParaMargin.ResolveTextLeft({}) + nIndentDist)); aParaMargin.SetRight(aParaMargin.GetRight()); aParaMargin.SetTextFirstLineOffset(SvxIndentValue::twips(nIndentDist * -1)); diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx index 577be8fe0369..57e066669db7 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -230,8 +230,8 @@ static std::shared_ptr lcl_TableParamToItemSet( SfxItemSet& rSet, Sw const sal_uInt16 nAlign = pFormat->GetHoriOrient().GetHoriOrient(); pRep->SetAlign(nAlign); SvxLRSpaceItem aLRSpace( pFormat->GetLRSpace() ); - SwTwips nLeft = aLRSpace.GetLeft(); - SwTwips nRight = aLRSpace.GetRight(); + SwTwips nLeft = aLRSpace.ResolveLeft({}); + SwTwips nRight = aLRSpace.ResolveRight({}); if(nAlign != text::HoriOrientation::FULL) { SwTwips nLR = pRep->GetSpace() - nWidth; @@ -375,8 +375,8 @@ void ItemSetToTableParam( const SfxItemSet& rSet, } SvxLRSpaceItem aLRSpace( RES_LR_SPACE ); - aLRSpace.SetLeft(pRep->GetLeftSpace()); - aLRSpace.SetRight(pRep->GetRightSpace()); + aLRSpace.SetLeft(SvxIndentValue::twips(pRep->GetLeftSpace())); + aLRSpace.SetRight(SvxIndentValue::twips(pRep->GetRightSpace())); aSet.Put( aLRSpace ); sal_Int16 eOrient = pRep->GetAlign(); @@ -1296,8 +1296,8 @@ void SwTableShell::Execute(SfxRequest &rReq) SwFormatFrameSize aSz( SwFrameSize::Variable, nWidth ); aSet.Put(aSz); - aLRSpace.SetLeft(nLeft); - aLRSpace.SetRight(nRight); + aLRSpace.SetLeft(SvxIndentValue::twips(nLeft)); + aLRSpace.SetRight(SvxIndentValue::twips(nRight)); aSet.Put( aLRSpace ); aSet.Put( aAttr ); @@ -1680,8 +1680,8 @@ void SwTableShell::GetState(SfxItemSet &rSet) rSh.GetTabCols(aTabCols); tools::Long nSpace = aTabCols.GetRightMax(); SvxLRSpaceItem aLRSpace(pFormat->GetLRSpace()); - SwTwips nLeft = aLRSpace.GetLeft(); - SwTwips nRight = aLRSpace.GetRight(); + SwTwips nLeft = aLRSpace.ResolveLeft({}); + SwTwips nRight = aLRSpace.ResolveRight({}); sal_uInt16 nPercent = 0; auto nWidth = ::GetTableWidth(pFormat, aTabCols, &nPercent, &rSh ); diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 2b3614437a79..e7ad2b19f872 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -1707,8 +1707,10 @@ void SwTextShell::Execute(SfxRequest &rReq) // Left border as offset //#i24363# tab stops relative to indent - const tools::Long nOff = rWrtSh.getIDocumentSettingAccess().get(DocumentSettingId::TABS_RELATIVE_TO_INDENT) - ? aCoreSet.Get(RES_MARGIN_TEXTLEFT).GetTextLeft() : 0; + const tools::Long nOff + = rWrtSh.getIDocumentSettingAccess().get(DocumentSettingId::TABS_RELATIVE_TO_INDENT) + ? aCoreSet.Get(RES_MARGIN_TEXTLEFT).ResolveTextLeft({}) + : 0; SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff ); aCoreSet.Put( aOff ); diff --git a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx index 12d16bca5d26..9064b51502c7 100644 --- a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx +++ b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx @@ -120,7 +120,8 @@ IMPL_LINK(WrapPropertyPanel, SpacingLBHdl, weld::ComboBox&, rBox, void) { sal_uInt16 nVal = rBox.get_active_id().toUInt32(); - SvxLRSpaceItem aLRItem(nVal, nVal, SvxIndentValue::zero(), RES_LR_SPACE); + SvxLRSpaceItem aLRItem(SvxIndentValue::twips(nVal), SvxIndentValue::twips(nVal), + SvxIndentValue::zero(), RES_LR_SPACE); SvxULSpaceItem aULItem(nVal, nVal, RES_UL_SPACE); m_nTop = m_nBottom = m_nLeft = m_nRight = nVal; @@ -144,8 +145,8 @@ void WrapPropertyPanel::NotifyItemUpdate( const SvxLRSpaceItem* pItem = dynamic_cast< const SvxLRSpaceItem* >(pState); if(pItem) { - m_nLeft = pItem->GetLeft(); - m_nRight = pItem->GetRight(); + m_nLeft = pItem->ResolveLeft({}); + m_nRight = pItem->ResolveRight({}); UpdateSpacingLB(); } diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index ff795be11827..7f6384050d6b 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -2430,7 +2430,7 @@ void SwView::InsFrameMode(sal_uInt16 nCols) m_pWrtShell->GetPageDesc(m_pWrtShell->GetCurPageDesc()).GetMaster(); SwTwips lWidth = rPageFormat.GetFrameSize().GetWidth(); const SvxLRSpaceItem &rLR = rPageFormat.GetLRSpace(); - lWidth -= rLR.GetLeft() + rLR.GetRight(); + lWidth -= rLR.ResolveLeft({}) + rLR.ResolveRight({}); aMgr.SetSize(Size(lWidth, aMgr.GetSize().Height())); if(nCols > 1) { diff --git a/sw/source/uibase/uiview/viewmdi.cxx b/sw/source/uibase/uiview/viewmdi.cxx index e62c4987ea79..16f5359215b1 100644 --- a/sw/source/uibase/uiview/viewmdi.cxx +++ b/sw/source/uibase/uiview/viewmdi.cxx @@ -126,12 +126,14 @@ void SwView::SetZoom_( const Size &rEditSize, SvxZoomType eZoomType, if( UseOnPage::Mirror == rDesc.GetUseOn() ) // mirrored pages { const SvxLRSpaceItem &rLeftLRSpace = rDesc.GetLeft().GetLRSpace(); - aPageSize.AdjustWidth(std::abs( rLeftLRSpace.GetLeft() - rLRSpace.GetLeft() ) ); + aPageSize.AdjustWidth( + std::abs(rLeftLRSpace.ResolveLeft({}) - rLRSpace.ResolveLeft({}))); } if (!pPostItMgr->HasNotes() || !pPostItMgr->ShowNotes()) - aPageSize.AdjustWidth( -( rLRSpace.GetLeft() + rLRSpace.GetRight() + nLeftOfst * 2 ) ); - lLeftMargin = rLRSpace.GetLeft() + DOCUMENTBORDER + nLeftOfst; + aPageSize.AdjustWidth( + -(rLRSpace.ResolveLeft({}) + rLRSpace.ResolveRight({}) + nLeftOfst * 2)); + lLeftMargin = rLRSpace.ResolveLeft({}) + DOCUMENTBORDER + nLeftOfst; nFac = aWindowSize.Width() * 100 / aPageSize.Width(); } else if(SvxZoomType::WHOLEPAGE == eZoomType || SvxZoomType::PAGEWIDTH == eZoomType ) diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx index 4302a5439f9b..55d610fc185e 100644 --- a/sw/source/uibase/uiview/viewtab.cxx +++ b/sw/source/uibase/uiview/viewtab.cxx @@ -171,9 +171,9 @@ void SwView::SwapPageMargin(const SwPageDesc& rDesc, SvxLRSpaceItem& rLRSpace) if ( rDesc.GetUseOn() == UseOnPage::Mirror && (nPhyPage % 2) == 0 ) { - tools::Long nTmp = rLRSpace.GetRight(); - rLRSpace.SetRight( rLRSpace.GetLeft() ); - rLRSpace.SetLeft( nTmp ); + auto stTmp = rLRSpace.GetRight(); + rLRSpace.SetRight(rLRSpace.GetLeft()); + rLRSpace.SetLeft(stTmp); } } @@ -339,13 +339,13 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) else if ( nFrameType & ( FrameTypeFlags::HEADER | FrameTypeFlags::FOOTER )) { // Subtract out page margins - tools::Long nOld = rDesc.GetMaster().GetLRSpace().GetLeft(); + tools::Long nOld = rDesc.GetMaster().GetLRSpace().ResolveLeft({}); aLongLR.SetLeft( nOld > aLongLR.GetLeft() ? 0 : aLongLR.GetLeft() - nOld ); - nOld = rDesc.GetMaster().GetLRSpace().GetRight(); + nOld = rDesc.GetMaster().GetLRSpace().ResolveRight({}); aLongLR.SetRight( nOld > aLongLR.GetRight() ? 0 : aLongLR.GetRight() - nOld ); - aLR.SetLeft(aLongLR.GetLeft()); - aLR.SetRight(aLongLR.GetRight()); + aLR.SetLeft(SvxIndentValue::twips(aLongLR.GetLeft())); + aLR.SetRight(SvxIndentValue::twips(aLongLR.GetRight())); if ( nFrameType & FrameTypeFlags::HEADER && pHeaderFormat ) pHeaderFormat->SetFormatAttr( aLR ); @@ -372,8 +372,8 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) const SwSection* pCurrSect = rSh.GetCurrSection(); const SwSectionFormat* pSectFormat = pCurrSect->GetFormat(); SvxLRSpaceItem aLRTmp = pSectFormat->GetLRSpace(); - aLRTmp.SetLeft(aLRTmp.GetLeft() + nLeftDiff); - aLRTmp.SetRight(aLRTmp.GetRight() + nRightDiff); + aLRTmp.SetLeft(SvxIndentValue::twips(aLRTmp.ResolveLeft({}) + nLeftDiff)); + aLRTmp.SetRight(SvxIndentValue::twips(aLRTmp.ResolveRight({}) + nRightDiff)); SfxItemSetFixed aSet(rSh.GetAttrPool()); aSet.Put(aLRTmp); //change the first/last column @@ -389,8 +389,8 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) } else { // Adjust page margins - aLR.SetLeft(aLongLR.GetLeft()); - aLR.SetRight(aLongLR.GetRight()); + aLR.SetLeft(SvxIndentValue::twips(aLongLR.GetLeft())); + aLR.SetRight(SvxIndentValue::twips(aLongLR.GetRight())); SwapPageMargin( rDesc, aLR ); SwPageDesc aDesc( rDesc ); aDesc.GetMaster().SetFormatAttr( aLR ); @@ -408,8 +408,8 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) SwPageDesc aDesc( rDesc ); { SvxLRSpaceItem aLR( RES_LR_SPACE ); - aLR.SetLeft(aLongLR.GetLeft()); - aLR.SetRight(aLongLR.GetRight()); + aLR.SetLeft(SvxIndentValue::twips(aLongLR.GetLeft())); + aLR.SetRight(SvxIndentValue::twips(aLongLR.GetRight())); SwapPageMargin( rDesc, aLR ); aDesc.GetMaster().SetFormatAttr( aLR ); } @@ -484,8 +484,8 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) const SwSection* pCurrSect = rSh.GetCurrSection(); const SwSectionFormat* pSectFormat = pCurrSect->GetFormat(); SvxLRSpaceItem aLR = pSectFormat->GetLRSpace(); - aLR.SetLeft(aLR.GetLeft() + nLeftDiff); - aLR.SetRight(aLR.GetRight() + nRightDiff); + aLR.SetLeft(SvxIndentValue::twips(aLR.ResolveLeft({}) + nLeftDiff)); + aLR.SetRight(SvxIndentValue::twips(aLR.ResolveRight({}) + nRightDiff)); SfxItemSetFixed aSet(rSh.GetAttrPool()); aSet.Put(aLR); //change the first/last column @@ -582,8 +582,8 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) const sal_uInt16 nGutterWidth = 0; const SvxLRSpaceItem aLR( rDesc.GetMaster().GetLRSpace() ); - const tools::Long nLeft = aLR.GetLeft(); - const tools::Long nRight = aLR.GetRight(); + const tools::Long nLeft = aLR.ResolveLeft({}); + const tools::Long nRight = aLR.ResolveRight({}); const tools::Long nWidth = nPageWidth - nLeft - nRight; SwFormatCol aCols( rDesc.GetMaster().GetCol() ); @@ -630,7 +630,7 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) rSh.GetCurAttr( aSet ); const SvxFirstLineIndentItem & rFirstLine(aSet.Get(RES_MARGIN_FIRSTLINE)); - if (rFirstLine.GetTextFirstLineOffsetValue() < 0.0) + if (rFirstLine.GetTextFirstLineOffset().m_dValue < 0.0) { SvxTabStop aSwTabStop( 0, SvxTabAdjust::Default ); aTabStops.Insert( aSwTabStop ); @@ -714,14 +714,14 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) SvxTextLeftMarginItem leftMargin(aLRSpaceSet.Get(RES_MARGIN_TEXTLEFT)); const OUString ratio = pLeftIndent->GetValue(); // this used to call SetLeft() but was probably a bug - leftMargin.SetTextLeft(nPageWidth * ratio.toFloat()); + leftMargin.SetTextLeft(SvxIndentValue::twips(nPageWidth * ratio.toFloat())); rSh.SetAttrItem(leftMargin); } else if (const SfxStringItem *pRightIndent = pReqArgs->GetItemIfSet(SID_PARAGRAPH_RIGHT_INDENT)) { SvxRightMarginItem rightMargin(aLRSpaceSet.Get(RES_MARGIN_RIGHT)); const OUString ratio = pRightIndent->GetValue(); - rightMargin.SetRight(nPageWidth * ratio.toFloat()); + rightMargin.SetRight(SvxIndentValue::twips(nPageWidth * ratio.toFloat())); rSh.SetAttrItem(rightMargin); } } @@ -743,7 +743,7 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) nIndentDist = ::GetTabDist(rDefTabItem); } - leftMargin.SetTextLeft(leftMargin.GetTextLeft() + nIndentDist); + leftMargin.SetTextLeft(SvxIndentValue::twips(leftMargin.ResolveTextLeft({}) + nIndentDist)); firstLine.SetTextFirstLineOffset(SvxIndentValue::twips(nIndentDist * -1)); firstLine.SetAutoFirst(false); // old code would do this, is it wanted? @@ -758,8 +758,10 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) { SvxLRSpaceItem aParaMargin(static_cast(pReqArgs->Get(nSlot))); - aParaMargin.SetRight( aParaMargin.GetRight() - m_nRightBorderDistance ); - aParaMargin.SetTextLeft(aParaMargin.GetTextLeft() - m_nLeftBorderDistance ); + aParaMargin.SetRight( + SvxIndentValue::twips(aParaMargin.ResolveRight({}) - m_nRightBorderDistance)); + aParaMargin.SetTextLeft( + SvxIndentValue::twips(aParaMargin.ResolveTextLeft({}) - m_nLeftBorderDistance)); aParaMargin.SetWhich( RES_LR_SPACE ); SwTextFormatColl* pColl = rSh.GetCurTextFormatColl(); @@ -782,7 +784,9 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) SwPosition aPos(*m_pNumRuleNodeFromDoc); // #i90078# - rSh.SetIndent(static_cast(aParaMargin.GetTextLeft() - rLeftMargin.GetTextLeft()), aPos); + rSh.SetIndent(static_cast(aParaMargin.ResolveTextLeft({}) + - rLeftMargin.ResolveTextLeft({})), + aPos); // #i42921# invalidate state of indent in order to get a ruler update. aParaMargin.SetWhich( nSlot ); GetViewFrame().GetBindings().SetState( aParaMargin ); @@ -802,7 +806,7 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) rSh.SetAttrItem(rightMargin); } - if (aParaMargin.GetTextFirstLineOffsetValue() < 0.0) + if (aParaMargin.GetTextFirstLineOffset().m_dValue < 0.0) { SfxItemSetFixed aSet( GetPool() ); @@ -1216,8 +1220,8 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) const SvxLongLRSpaceItem& aLongLR = pReqArgs->Get(SID_ATTR_PAGE_HEADER_LRMARGIN); SvxLRSpaceItem aLR(RES_LR_SPACE); SwPageDesc aDesc(rDesc); - aLR.SetLeft(aLongLR.GetLeft()); - aLR.SetRight(aLongLR.GetRight()); + aLR.SetLeft(SvxIndentValue::twips(aLongLR.GetLeft())); + aLR.SetRight(SvxIndentValue::twips(aLongLR.GetRight())); SwFrameFormat* pFormat = const_cast(aDesc.GetMaster().GetHeader().GetHeaderFormat()); pFormat->SetFormatAttr( aLR ); rSh.ChgPageDesc(rSh.GetCurPageDesc(), aDesc); @@ -1269,8 +1273,8 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) const SvxLongLRSpaceItem& aLongLR = pReqArgs->Get(SID_ATTR_PAGE_FOOTER_LRMARGIN); SvxLRSpaceItem aLR(RES_LR_SPACE); SwPageDesc aDesc(rDesc); - aLR.SetLeft(aLongLR.GetLeft()); - aLR.SetRight(aLongLR.GetRight()); + aLR.SetLeft(SvxIndentValue::twips(aLongLR.GetLeft())); + aLR.SetRight(SvxIndentValue::twips(aLongLR.GetRight())); SwFrameFormat* pFormat = const_cast(aDesc.GetMaster().GetFooter().GetFooterFormat()); pFormat->SetFormatAttr( aLR ); rSh.ChgPageDesc(rSh.GetCurPageDesc(), aDesc); @@ -1476,9 +1480,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) case SID_ATTR_LONG_LRSPACE: { - SvxLongLRSpaceItem aLongLR( aPageLRSpace.GetLeft(), - aPageLRSpace.GetRight(), - SID_ATTR_LONG_LRSPACE); + SvxLongLRSpaceItem aLongLR(aPageLRSpace.ResolveLeft({}), aPageLRSpace.ResolveRight({}), + SID_ATTR_LONG_LRSPACE); if(bBrowse) { aLongLR.SetLeft(rPagePrtRect.Left()); @@ -1495,8 +1498,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) SwRect aRect( rSh.GetAnyCurRect( CurRectType::HeaderFooter, pPt)); aRect.Pos() -= rSh.GetAnyCurRect( CurRectType::Page, pPt ).Pos(); const SvxLRSpaceItem& aLR = pFormat->GetLRSpace(); - aLongLR.SetLeft ( aLR.GetLeft() + aRect.Left() ); - aLongLR.SetRight( nPageWidth - aRect.Right() + aLR.GetRight() ); + aLongLR.SetLeft(aLR.ResolveLeft({}) + aRect.Left()); + aLongLR.SetRight(nPageWidth - aRect.Right() + aLR.ResolveRight({})); } } else @@ -1529,10 +1532,9 @@ void SwView::StateTabWin(SfxItemSet& rSet) case SID_ATTR_PAGE_LRSPACE: { const SvxLRSpaceItem aTmpPageLRSpace( rDesc.GetMaster().GetLRSpace() ); - const SvxLongLRSpaceItem aLongLR( - aTmpPageLRSpace.GetLeft(), - aTmpPageLRSpace.GetRight(), - SID_ATTR_PAGE_LRSPACE ); + const SvxLongLRSpaceItem aLongLR(aTmpPageLRSpace.ResolveLeft({}), + aTmpPageLRSpace.ResolveRight({}), + SID_ATTR_PAGE_LRSPACE); rSet.Put( aLongLR ); } break; @@ -1683,17 +1685,18 @@ void SwView::StateTabWin(SfxItemSet& rSet) // #i23726# if (m_pNumRuleNodeFromDoc) { - short nOffset = static_cast< short >(aLR->GetTextLeft() + - // #i42922# Mouse move of numbering label - // has to consider the left indent of the paragraph - m_pNumRuleNodeFromDoc->GetLeftMarginWithNum( true ) ); + short nOffset + = static_cast(aLR->ResolveTextLeft({}) + + // #i42922# Mouse move of numbering label + // has to consider the left indent of the paragraph + m_pNumRuleNodeFromDoc->GetLeftMarginWithNum(true)); short nFLOffset; // tdf#36709: TODO: Handle font-relative units m_pNumRuleNodeFromDoc->GetFirstLineOfsWithNum(nFLOffset, {}); - aLR->SetLeft( nOffset + nFLOffset ); + aLR->SetLeft(SvxIndentValue::twips(nOffset + nFLOffset)); } } aLR->SetWhich(nWhich); @@ -1755,8 +1758,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) if( IsTabColFromDoc() ) { const SwRect& rFlyPrtRect = rSh.GetAnyCurRect( CurRectType::FlyEmbeddedPrt, pPt ); - aDistLR.SetLeft(rFlyPrtRect.Left()); - aDistLR.SetRight(rFlyPrtRect.Left()); + aDistLR.SetLeft(SvxIndentValue::twips(rFlyPrtRect.Left())); + aDistLR.SetRight(SvxIndentValue::twips(rFlyPrtRect.Left())); rSet.Put(aDistLR); } else @@ -1765,19 +1768,24 @@ void SwView::StateTabWin(SfxItemSet& rSet) aCoreSet2.Put(aBoxInfo); rSh.GetFlyFrameAttr(aCoreSet2); const SvxBoxItem& rBox = aCoreSet2.Get(RES_BOX); - aDistLR.SetLeft(rBox.GetDistance(SvxBoxItemLine::LEFT)); - aDistLR.SetRight(rBox.GetDistance(SvxBoxItemLine::RIGHT)); + aDistLR.SetLeft( + SvxIndentValue::twips(rBox.GetDistance(SvxBoxItemLine::LEFT))); + aDistLR.SetRight( + SvxIndentValue::twips(rBox.GetDistance(SvxBoxItemLine::RIGHT))); rSet.Put(aDistLR); //add the paragraph border distance SfxItemSetFixed aCoreSet1( GetPool() ); rSh.GetCurAttr( aCoreSet1 ); const SvxBoxItem& rParaBox = aCoreSet1.Get(RES_BOX); - aDistLR.SetLeft(aDistLR.GetLeft() + rParaBox.GetDistance(SvxBoxItemLine::LEFT)); - aDistLR.SetRight(aDistLR.GetRight() + rParaBox.GetDistance(SvxBoxItemLine::RIGHT)); + aDistLR.SetLeft(SvxIndentValue::twips( + aDistLR.ResolveLeft({}) + rParaBox.GetDistance(SvxBoxItemLine::LEFT))); + aDistLR.SetRight( + SvxIndentValue::twips(aDistLR.ResolveRight({}) + + rParaBox.GetDistance(SvxBoxItemLine::RIGHT))); } - m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft()); - m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight()); + m_nLeftBorderDistance = static_cast(aDistLR.ResolveLeft({})); + m_nRightBorderDistance = static_cast(aDistLR.ResolveRight({})); } else if ( IsTabColFromDoc() || ( rSh.GetTableFormat() && !bFrameSelection && @@ -1789,26 +1797,30 @@ void SwView::StateTabWin(SfxItemSet& rSet) aCoreSet2.Put(aBoxInfo); rSh.GetTabBorders( aCoreSet2 ); const SvxBoxItem& rBox = aCoreSet2.Get(RES_BOX); - aDistLR.SetLeft(rBox.GetDistance(SvxBoxItemLine::LEFT)); - aDistLR.SetRight(rBox.GetDistance(SvxBoxItemLine::RIGHT)); + aDistLR.SetLeft(SvxIndentValue::twips(rBox.GetDistance(SvxBoxItemLine::LEFT))); + aDistLR.SetRight( + SvxIndentValue::twips(rBox.GetDistance(SvxBoxItemLine::RIGHT))); rSet.Put(aDistLR); //add the border distance of the paragraph SfxItemSetFixed aCoreSet1( GetPool() ); rSh.GetCurAttr( aCoreSet1 ); const SvxBoxItem& rParaBox = aCoreSet1.Get(RES_BOX); - aDistLR.SetLeft(aDistLR.GetLeft() + rParaBox.GetDistance(SvxBoxItemLine::LEFT)); - aDistLR.SetRight(aDistLR.GetRight() + rParaBox.GetDistance(SvxBoxItemLine::RIGHT)); - m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft()); - m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight()); + aDistLR.SetLeft(SvxIndentValue::twips( + aDistLR.ResolveLeft({}) + rParaBox.GetDistance(SvxBoxItemLine::LEFT))); + aDistLR.SetRight(SvxIndentValue::twips( + aDistLR.ResolveRight({}) + rParaBox.GetDistance(SvxBoxItemLine::RIGHT))); + m_nLeftBorderDistance = static_cast(aDistLR.ResolveLeft({})); + m_nRightBorderDistance = static_cast(aDistLR.ResolveRight({})); } else if ( !rSh.IsDirectlyInSection() ) { //get the page/header/footer border distance const SwFrameFormat& rMaster = rDesc.GetMaster(); const SvxBoxItem& rBox = rMaster.GetAttrSet().Get(RES_BOX); - aDistLR.SetLeft(rBox.GetDistance(SvxBoxItemLine::LEFT)); - aDistLR.SetRight(rBox.GetDistance(SvxBoxItemLine::RIGHT)); + aDistLR.SetLeft(SvxIndentValue::twips(rBox.GetDistance(SvxBoxItemLine::LEFT))); + aDistLR.SetRight( + SvxIndentValue::twips(rBox.GetDistance(SvxBoxItemLine::RIGHT))); const SvxBoxItem* pBox = nullptr; if(nFrameType & FrameTypeFlags::HEADER) @@ -1828,18 +1840,22 @@ void SwView::StateTabWin(SfxItemSet& rSet) } if(pBox) { - aDistLR.SetLeft(pBox->GetDistance(SvxBoxItemLine::LEFT)); - aDistLR.SetRight(pBox->GetDistance(SvxBoxItemLine::RIGHT)); + aDistLR.SetLeft( + SvxIndentValue::twips(pBox->GetDistance(SvxBoxItemLine::LEFT))); + aDistLR.SetRight( + SvxIndentValue::twips(pBox->GetDistance(SvxBoxItemLine::RIGHT))); } rSet.Put(aDistLR); //add the border distance of the paragraph rSh.GetCurAttr(aCoreSet2); const SvxBoxItem& rParaBox = aCoreSet2.Get(RES_BOX); - aDistLR.SetLeft(aDistLR.GetLeft() + rParaBox.GetDistance(SvxBoxItemLine::LEFT)); - aDistLR.SetRight(aDistLR.GetRight() + rParaBox.GetDistance(SvxBoxItemLine::RIGHT)); - m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft()); - m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight()); + aDistLR.SetLeft(SvxIndentValue::twips( + aDistLR.ResolveLeft({}) + rParaBox.GetDistance(SvxBoxItemLine::LEFT))); + aDistLR.SetRight(SvxIndentValue::twips( + aDistLR.ResolveRight({}) + rParaBox.GetDistance(SvxBoxItemLine::RIGHT))); + m_nLeftBorderDistance = static_cast(aDistLR.ResolveLeft({})); + m_nRightBorderDistance = static_cast(aDistLR.ResolveRight({})); } } } @@ -2094,8 +2110,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) } else { - aColItem.SetLeft (aPageLRSpace.GetLeft()); - aColItem.SetRight(aPageLRSpace.GetRight()); + aColItem.SetLeft(aPageLRSpace.ResolveLeft({})); + aColItem.SetRight(aPageLRSpace.ResolveRight({})); } } aColItem.SetOrtho(aColItem.CalcOrtho()); @@ -2325,8 +2341,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) } else { - aRectangle.SetLeft( aPageLRSpace.GetLeft() ); - aRectangle.SetRight( aPageLRSpace.GetRight() ); + aRectangle.SetLeft(aPageLRSpace.ResolveLeft({})); + aRectangle.SetRight(aPageLRSpace.ResolveRight({})); } } else @@ -2398,8 +2414,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) } else if(!bBrowse) { - aRectangle.SetLeft( aPageLRSpace.GetLeft() + nStart ); - aRectangle.SetRight( nPageWidth - nEnd - aPageLRSpace.GetLeft() ); + aRectangle.SetLeft(aPageLRSpace.ResolveLeft({}) + nStart); + aRectangle.SetRight(nPageWidth - nEnd - aPageLRSpace.ResolveLeft({})); } else { @@ -2416,8 +2432,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) } else if ( nFrameType & ( FrameTypeFlags::HEADER | FrameTypeFlags::FOOTER )) { - aRectangle.SetLeft( aPageLRSpace.GetLeft() ); - aRectangle.SetRight( aPageLRSpace.GetRight() ); + aRectangle.SetLeft(aPageLRSpace.ResolveLeft({})); + aRectangle.SetRight(aPageLRSpace.ResolveRight({})); } else { @@ -2469,7 +2485,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) const SvxULSpaceItem* pUL = rHeader.GetHeaderFormat()->GetAttrSet().GetItem(SID_ATTR_ULSPACE); if (pLR && pUL) { - SvxLongLRSpaceItem aLR(pLR->GetLeft(), pLR->GetRight(), SID_ATTR_PAGE_HEADER_LRMARGIN); + SvxLongLRSpaceItem aLR(pLR->ResolveLeft({}), pLR->ResolveRight({}), + SID_ATTR_PAGE_HEADER_LRMARGIN); rSet.Put(aLR); SvxLongULSpaceItem aUL( pUL->GetUpper(), pUL->GetLower(), SID_ATTR_PAGE_HEADER_SPACING); rSet.Put(aUL); @@ -2495,7 +2512,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) { if (const SvxLRSpaceItem* rLR = rFooter.GetFooterFormat()->GetAttrSet().GetItem(SID_ATTR_LRSPACE)) { - SvxLongLRSpaceItem aLR(rLR->GetLeft(), rLR->GetRight(), SID_ATTR_PAGE_FOOTER_LRMARGIN); + SvxLongLRSpaceItem aLR(rLR->ResolveLeft({}), rLR->ResolveRight({}), + SID_ATTR_PAGE_FOOTER_LRMARGIN); rSet.Put(aLR); } if (const SvxULSpaceItem* rUL = rFooter.GetFooterFormat()->GetAttrSet().GetItem(SID_ATTR_ULSPACE)) diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx index e7d4ca9f76cd..05e39532ad3f 100644 --- a/sw/source/uibase/uno/unotxvw.cxx +++ b/sw/source/uibase/uno/unotxvw.cxx @@ -853,7 +853,7 @@ awt::Point SwXTextViewCursor::getPosition() aRet.Y = convertTwipToMm100(nY); const SvxLRSpaceItem& rLR = rMaster.GetLRSpace(); - const tools::Long nX = aCharRect.Left() - (rLR.GetLeft() + DOCUMENTBORDER); + const tools::Long nX = aCharRect.Left() - (rLR.ResolveLeft({}) + DOCUMENTBORDER); aRet.X = convertTwipToMm100(nX); return aRet; diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx index ac13b482ea92..64b15924a168 100644 --- a/sw/source/uibase/utlui/uitool.cxx +++ b/sw/source/uibase/utlui/uitool.cxx @@ -853,7 +853,7 @@ SwTwips GetTableWidth( SwFrameFormat const * pFormat, SwTabCols const & rCols, s OSL_FAIL("where to get the actual width from?"); } const SvxLRSpaceItem& rLRSpace = pFormat->GetLRSpace(); - nWidth -= (rLRSpace.GetRight() + rLRSpace.GetLeft()); + nWidth -= (rLRSpace.ResolveRight({}) + rLRSpace.ResolveLeft({})); } } if (pPercent) diff --git a/sw/source/uibase/wrtsh/delete.cxx b/sw/source/uibase/wrtsh/delete.cxx index 3d3d7624f196..16e3406d585a 100644 --- a/sw/source/uibase/wrtsh/delete.cxx +++ b/sw/source/uibase/wrtsh/delete.cxx @@ -81,12 +81,13 @@ bool SwWrtShell::TryRemoveIndent() { // this used to call SetLeft() but this should be the same result firstLine.SetTextFirstLineOffset(SvxIndentValue::zero()); - leftMargin.SetTextLeft(leftMargin.GetTextLeft() + aOldFirstLineOfst); + leftMargin.SetTextLeft( + SvxIndentValue::twips(leftMargin.ResolveTextLeft({}) + aOldFirstLineOfst)); bResult = true; } - else if (leftMargin.GetTextLeft() != 0) + else if (leftMargin.GetTextLeft().m_dValue != 0.0) { - leftMargin.SetTextLeft(0); + leftMargin.SetTextLeft(SvxIndentValue::zero()); bResult = true; } diff --git a/vcl/qa/cppunit/pdfexport/data/tdf163913.fodt b/vcl/qa/cppunit/pdfexport/data/tdf163913.fodt new file mode 100644 index 000000000000..a8d22620534d --- /dev/null +++ b/vcl/qa/cppunit/pdfexport/data/tdf163913.fodt @@ -0,0 +1,147 @@ + + + 2024-10-31T13:46:50.189497642LibreOfficeDev/25.2.0.0.alpha0$Linux_X86_64 LibreOffice_project/372a9f642e1268a1888f6a85d42da0499e1f85162024-11-08T04:00:30.046342730PT4M32S3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AAAAAAAAAAAAAAA + AAAAAAAAAAAAAAA + + + + AAAAAAAAAAAAAAA + AAAAAAAAAAAAAAA + + + + + + diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx index 38e2109d3ef8..214b03b861d9 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx @@ -5933,6 +5933,62 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf36709FirstLineIndentEm) CPPUNIT_ASSERT_DOUBLES_EQUAL(115.906, aRect.at(15).getMinX(), /*delta*/ 2.0); } +CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf163913LeftRightMarginEm) +{ + saveAsPDF(u"tdf163913.fodt"); + + auto pPdfDocument = parsePDFExport(); + CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount()); + + auto pPdfPage = pPdfDocument->openPage(/*nIndex*/ 0); + CPPUNIT_ASSERT(pPdfPage); + auto pTextPage = pPdfPage->getTextPage(); + CPPUNIT_ASSERT(pTextPage); + + int nPageObjectCount = pPdfPage->getObjectCount(); + + CPPUNIT_ASSERT_EQUAL(9, nPageObjectCount); + + std::vector aText; + std::vector aRect; + + for (int i = 0; i < nPageObjectCount; ++i) + { + auto pPageObject = pPdfPage->getObject(i); + CPPUNIT_ASSERT_MESSAGE("no object", pPageObject != nullptr); + if (pPageObject->getType() == vcl::pdf::PDFPageObjectType::Text) + { + aText.push_back(pPageObject->getText(pTextPage)); + aRect.push_back(pPageObject->getBounds()); + } + } + + CPPUNIT_ASSERT_EQUAL(size_t(9), aText.size()); + + // Lines from the Writer portion + CPPUNIT_ASSERT_EQUAL(u"AAAAAAAAAAA"_ustr, aText.at(0).trim()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(56.800, aRect.at(0).getMinX(), /*delta*/ 2.0); + CPPUNIT_ASSERT_EQUAL(u"AAAA"_ustr, aText.at(1).trim()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(56.800, aRect.at(1).getMinX(), /*delta*/ 2.0); + CPPUNIT_ASSERT_EQUAL(u"AAAAAAAA"_ustr, aText.at(2).trim()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(117.400, aRect.at(2).getMinX(), /*delta*/ 2.0); + CPPUNIT_ASSERT_EQUAL(u"AAAAAAA"_ustr, aText.at(3).trim()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(117.400, aRect.at(3).getMinX(), /*delta*/ 2.0); + + CPPUNIT_ASSERT_EQUAL(u""_ustr, aText.at(4).trim()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(56.800, aRect.at(4).getMinX(), /*delta*/ 2.0); + + // Lines from the Edit Engine portion + CPPUNIT_ASSERT_EQUAL(u"AAAAAAAAAAA"_ustr, aText.at(5).trim()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(56.800, aRect.at(5).getMinX(), /*delta*/ 2.0); + CPPUNIT_ASSERT_EQUAL(u"AAAA"_ustr, aText.at(6).trim()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(56.800, aRect.at(6).getMinX(), /*delta*/ 2.0); + CPPUNIT_ASSERT_EQUAL(u"AAAAAAAA"_ustr, aText.at(7).trim()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(123.750, aRect.at(7).getMinX(), /*delta*/ 2.0); + CPPUNIT_ASSERT_EQUAL(u"AAAAAAA"_ustr, aText.at(8).trim()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(123.750, aRect.at(8).getMinX(), /*delta*/ 2.0); +} + } // end anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/xmloff/inc/xmlprop.hxx b/xmloff/inc/xmlprop.hxx index dd48cb11ff63..d96e81a510a5 100644 --- a/xmloff/inc/xmlprop.hxx +++ b/xmloff/inc/xmlprop.hxx @@ -513,6 +513,7 @@ inline constexpr OUString PROP_ParaKeepTogether = u"ParaKeepTogether"_ustr; inline constexpr OUString PROP_ParaLastLineAdjust = u"ParaLastLineAdjust"_ustr; inline constexpr OUString PROP_ParaLeftMargin = u"ParaLeftMargin"_ustr; inline constexpr OUString PROP_ParaLeftMarginRelative = u"ParaLeftMarginRelative"_ustr; +inline constexpr OUString PROP_ParaLeftMarginUnit = u"ParaLeftMarginUnit"_ustr; inline constexpr OUString PROP_ParaLineNumberCount = u"ParaLineNumberCount"_ustr; inline constexpr OUString PROP_ParaLineNumberStartValue = u"ParaLineNumberStartValue"_ustr; inline constexpr OUString PROP_ParaLineSpacing = u"ParaLineSpacing"_ustr; @@ -520,6 +521,7 @@ inline constexpr OUString PROP_ParaOrphans = u"ParaOrphans"_ustr; inline constexpr OUString PROP_ParaRegisterModeActive = u"ParaRegisterModeActive"_ustr; inline constexpr OUString PROP_ParaRightMargin = u"ParaRightMargin"_ustr; inline constexpr OUString PROP_ParaRightMarginRelative = u"ParaRightMarginRelative"_ustr; +inline constexpr OUString PROP_ParaRightMarginUnit = u"ParaRightMarginUnit"_ustr; inline constexpr OUString PROP_ParaShadowFormat = u"ParaShadowFormat"_ustr; inline constexpr OUString PROP_ParaSplit = u"ParaSplit"_ustr; inline constexpr OUString PROP_ParaTabStops = u"ParaTabStops"_ustr; diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx index 8553965c67d0..cd362b98ede6 100644 --- a/xmloff/source/text/txtprmap.cxx +++ b/xmloff/source/text/txtprmap.cxx @@ -119,10 +119,19 @@ XMLPropertyMapEntry constexpr aXMLParaPropMap[] = // !!! DO NOT REORDER THE MARGINS !!! MP_E( PROP_ParaLeftMargin, XML_NAMESPACE_FO, XML_MARGIN, XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, CTF_PARAMARGINALL ), MP_E( PROP_ParaLeftMarginRelative, XML_NAMESPACE_FO, XML_MARGIN, XML_TYPE_PERCENT16, CTF_PARAMARGINALL_REL ), + MAP_EXT( PROP_ParaLeftMarginUnit, XML_NAMESPACE_LO_EXT, XML_MARGIN, XML_TYPE_PROP_PARAGRAPH|XML_TYPE_UNIT_MEASURE|MID_FLAG_MULTI_PROPERTY, 0 ), + MAP_EXT_I( PROP_ParaLeftMargin, XML_NAMESPACE_LO_EXT, XML_MARGIN, XML_TYPE_PROP_PARAGRAPH|XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, CTF_PARAMARGINALL ), + MAP_EXT_I( PROP_ParaLeftMarginRelative, XML_NAMESPACE_LO_EXT, XML_MARGIN, XML_TYPE_PROP_PARAGRAPH|XML_TYPE_PERCENT16, CTF_PARAMARGINALL_REL ), MP_E( PROP_ParaLeftMargin, XML_NAMESPACE_FO, XML_MARGIN_LEFT, XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, CTF_PARALEFTMARGIN ), MP_E( PROP_ParaLeftMarginRelative, XML_NAMESPACE_FO, XML_MARGIN_LEFT, XML_TYPE_PERCENT16, CTF_PARALEFTMARGIN_REL ), + MAP_EXT( PROP_ParaLeftMarginUnit, XML_NAMESPACE_LO_EXT, XML_MARGIN_LEFT, XML_TYPE_PROP_PARAGRAPH|XML_TYPE_UNIT_MEASURE|MID_FLAG_MULTI_PROPERTY, 0 ), + MAP_EXT_I( PROP_ParaLeftMargin, XML_NAMESPACE_FO, XML_MARGIN_LEFT, XML_TYPE_PROP_PARAGRAPH|XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, CTF_PARALEFTMARGIN ), + MAP_EXT_I( PROP_ParaLeftMarginRelative, XML_NAMESPACE_FO, XML_MARGIN_LEFT, XML_TYPE_PROP_PARAGRAPH|XML_TYPE_PERCENT16, CTF_PARALEFTMARGIN_REL ), MP_E( PROP_ParaRightMargin, XML_NAMESPACE_FO, XML_MARGIN_RIGHT, XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, CTF_PARARIGHTMARGIN ), MP_E( PROP_ParaRightMarginRelative, XML_NAMESPACE_FO, XML_MARGIN_RIGHT, XML_TYPE_PERCENT16, CTF_PARARIGHTMARGIN_REL ), + MAP_EXT( PROP_ParaRightMarginUnit, XML_NAMESPACE_LO_EXT, XML_MARGIN_RIGHT, XML_TYPE_PROP_PARAGRAPH|XML_TYPE_UNIT_MEASURE|MID_FLAG_MULTI_PROPERTY, 0 ), + MAP_EXT_I( PROP_ParaRightMargin, XML_NAMESPACE_FO, XML_MARGIN_RIGHT, XML_TYPE_PROP_PARAGRAPH|XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, CTF_PARARIGHTMARGIN ), + MAP_EXT_I( PROP_ParaRightMarginRelative, XML_NAMESPACE_FO, XML_MARGIN_RIGHT, XML_TYPE_PROP_PARAGRAPH|XML_TYPE_PERCENT16, CTF_PARARIGHTMARGIN_REL ), // RES_UL_SPACE MP_E( PROP_ParaTopMargin, XML_NAMESPACE_FO, XML_MARGIN_TOP, XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, CTF_PARATOPMARGIN ), MP_E( PROP_ParaTopMarginRelative, XML_NAMESPACE_FO, XML_MARGIN_TOP, XML_TYPE_PERCENT16, CTF_PARATOPMARGIN_REL ),