diff options
Diffstat (limited to 'editeng/source/items/frmitems.cxx')
-rw-r--r-- | editeng/source/items/frmitems.cxx | 1690 |
1 files changed, 1477 insertions, 213 deletions
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index ba55d734515c..fa393ff4ccd8 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -33,11 +33,13 @@ #include <com/sun/star/frame/status/LeftRightMarginScale.hpp> #include <com/sun/star/drawing/ShadingPattern.hpp> #include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/util/XComplexColor.hpp> #include <osl/diagnose.h> #include <i18nutil/unicode.hxx> #include <unotools/ucbstreamhelper.hxx> #include <comphelper/processfactory.hxx> +#include <utility> #include <vcl/GraphicObject.hxx> #include <tools/urlobj.hxx> #include <tools/bigint.hxx> @@ -71,8 +73,10 @@ #include <libxml/xmlwriter.h> #include <o3tl/enumrange.hxx> #include <o3tl/safeint.hxx> +#include <sal/log.hxx> #include <vcl/GraphicLoader.hxx> #include <unotools/securityoptions.hxx> +#include <docmodel/uno/UnoComplexColor.hxx> #include <boost/property_tree/ptree.hpp> @@ -283,19 +287,16 @@ bool SvxSizeItem::HasMetrics() const } -SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId ) : - - SfxPoolItem( nId ), - - nTxtLeft ( 0 ), - nLeftMargin ( 0 ), - nRightMargin ( 0 ), - m_nGutterMargin(0), - m_nRightGutterMargin(0), +SvxLRSpaceItem::SvxLRSpaceItem(const sal_uInt16 nId) + : SfxPoolItem(nId) + , nFirstLineOffset(0) + , nLeftMargin(0) + , nRightMargin(0) + , m_nGutterMargin(0) + , m_nRightGutterMargin(0), nPropFirstLineOffset( 100 ), nPropLeftMargin( 100 ), nPropRightMargin( 100 ), - nFirstLineOffset ( 0 ), bAutoFirst ( false ), bExplicitZeroMarginValRight(false), bExplicitZeroMarginValLeft(false) @@ -304,19 +305,17 @@ SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId ) : SvxLRSpaceItem::SvxLRSpaceItem( const tools::Long nLeft, const tools::Long nRight, - const tools::Long nTLeft, const short nOfset, + const short nOfset, const sal_uInt16 nId ) -: SfxPoolItem( nId ), - - nTxtLeft ( nTLeft ), - nLeftMargin ( nLeft ), - nRightMargin ( nRight ), - m_nGutterMargin(0), - m_nRightGutterMargin(0), + : SfxPoolItem(nId) + , nFirstLineOffset(nOfset) + , nLeftMargin(nLeft) + , nRightMargin(nRight) + , m_nGutterMargin(0) + , m_nRightGutterMargin(0), nPropFirstLineOffset( 100 ), nPropLeftMargin( 100 ), nPropRightMargin( 100 ), - nFirstLineOffset ( nOfset ), bAutoFirst ( false ), bExplicitZeroMarginValRight(false), bExplicitZeroMarginValLeft(false) @@ -336,7 +335,7 @@ bool SvxLRSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const { css::frame::status::LeftRightMarginScale aLRSpace; aLRSpace.Left = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nLeftMargin) : nLeftMargin); - aLRSpace.TextLeft = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nTxtLeft) : nTxtLeft); + aLRSpace.TextLeft = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(GetTextLeft()) : GetTextLeft()); aLRSpace.Right = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nRightMargin) : nRightMargin); aLRSpace.ScaleLeft = static_cast<sal_Int16>(nPropLeftMargin); aLRSpace.ScaleRight = static_cast<sal_Int16>(nPropRightMargin); @@ -351,7 +350,7 @@ bool SvxLRSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const break; case MID_TXT_LMARGIN : - rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nTxtLeft) : nTxtLeft); + rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(GetTextLeft()) : GetTextLeft()); break; case MID_R_MARGIN: rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(nRightMargin) : nRightMargin); @@ -466,16 +465,1029 @@ bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) return true; } +void SvxLeftMarginItem::SetLeft(const tools::Long nL, const sal_uInt16 nProp) +{ + m_nLeftMargin = (nL * nProp) / 100; + m_nPropLeftMargin = nProp; +} + +void SvxLRSpaceItem::SetLeft(const tools::Long nL, const sal_uInt16 nProp) +{ + nLeftMargin = (nL * nProp) / 100; + SAL_WARN_IF(nFirstLineOffset != 0, "editeng", "probably call SetTextLeft instead? looks inconsistent otherwise"); + nPropLeftMargin = nProp; +} + +void SvxRightMarginItem::SetRight(const tools::Long nR, const sal_uInt16 nProp) +{ + m_nRightMargin = (nR * nProp) / 100; + m_nPropRightMargin = nProp; +} + +void SvxLRSpaceItem::SetRight(const tools::Long nR, const sal_uInt16 nProp) +{ + if (0 == nR) + { + SetExplicitZeroMarginValRight(true); + } + nRightMargin = (nR * nProp) / 100; + nPropRightMargin = nProp; +} + +void SvxFirstLineIndentItem::SetTextFirstLineOffset( + const short nF, const sal_uInt16 nProp) +{ + m_nFirstLineOffset = short((tools::Long(nF) * nProp ) / 100); + m_nPropFirstLineOffset = nProp; +} -/// Adapt nLeftMargin and nTxtLeft. -void SvxLRSpaceItem::AdjustLeft() +void SvxLRSpaceItem::SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp) { + // note: left margin contains any negative first line offset - preserve it! + if (nFirstLineOffset < 0) + { + nLeftMargin -= nFirstLineOffset; + } + nFirstLineOffset = short((tools::Long(nF) * nProp ) / 100); + nPropFirstLineOffset = nProp; + if (nFirstLineOffset < 0) + { + nLeftMargin += nFirstLineOffset; + } +} + +#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) +{ + m_nTextLeftMargin = (nL * nProp) / 100; + m_nPropLeftMargin = nProp; +} + +void SvxLRSpaceItem::SetTextLeft(const tools::Long nL, const sal_uInt16 nProp) +{ + if (0 == nL) + { + SetExplicitZeroMarginValLeft(true); + } + auto const nTxtLeft = (nL * nProp) / 100; + nPropLeftMargin = nProp; + // note: left margin contains any negative first line offset if ( 0 > nFirstLineOffset ) nLeftMargin = nTxtLeft + nFirstLineOffset; else nLeftMargin = nTxtLeft; } +tools::Long SvxTextLeftMarginItem::GetTextLeft() const +{ + return m_nTextLeftMargin; +} + +tools::Long SvxTextLeftMarginItem::GetLeft(SvxFirstLineIndentItem const& rFirstLine) const +{ + // add any negative first line offset to text left margin to get left + return (rFirstLine.GetTextFirstLineOffset() < 0) + ? m_nTextLeftMargin + rFirstLine.GetTextFirstLineOffset() + : m_nTextLeftMargin; +} + +tools::Long SvxLRSpaceItem::GetTextLeft() const +{ + // remove any negative first line offset from left margin to get text-left + return (nFirstLineOffset < 0) + ? nLeftMargin - nFirstLineOffset + : nLeftMargin; +} + +SvxLeftMarginItem::SvxLeftMarginItem(const sal_uInt16 nId) + : SfxPoolItem(nId) +{ +} + +SvxLeftMarginItem::SvxLeftMarginItem(const tools::Long nLeft, const sal_uInt16 nId) + : SfxPoolItem(nId) + , m_nLeftMargin(nLeft) +{ +} + +bool SvxLeftMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const +{ + bool bRet = true; + bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + switch (nMemberId) + { + case MID_L_MARGIN: + rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(m_nLeftMargin) : m_nLeftMargin); + break; + case MID_L_REL_MARGIN: + rVal <<= static_cast<sal_Int16>(m_nPropLeftMargin); + break; + default: + assert(false); + bRet = false; + // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? + OSL_FAIL("unknown MemberId"); + } + return bRet; +} + +bool SvxLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) +{ + bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + + switch (nMemberId) + { + case MID_L_MARGIN: + { + sal_Int32 nVal = 0; + if (!(rVal >>= nVal)) + { + return false; + } + SetLeft(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); + break; + } + case MID_L_REL_MARGIN: + { + sal_Int32 nRel = 0; + if ((rVal >>= nRel) && nRel >= 0 && nRel < SAL_MAX_UINT16) + { + m_nPropLeftMargin = static_cast<sal_uInt16>(nRel); + } + else + { + return false; + } + } + break; + default: + assert(false); + OSL_FAIL("unknown MemberId"); + return false; + } + return true; +} + +bool SvxLeftMarginItem::operator==(const SfxPoolItem& rAttr) const +{ + assert(SfxPoolItem::operator==(rAttr)); + + const SvxLeftMarginItem& rOther = static_cast<const SvxLeftMarginItem&>(rAttr); + + return (m_nLeftMargin == rOther.GetLeft() + && m_nPropLeftMargin == rOther.GetPropLeft()); +} + +SvxLeftMarginItem* SvxLeftMarginItem::Clone(SfxItemPool *) const +{ + return new SvxLeftMarginItem(*this); +} + +bool SvxLeftMarginItem::GetPresentation +( + SfxItemPresentation ePres, + MapUnit eCoreUnit, + MapUnit ePresUnit, + OUString& rText, const IntlWrapper& rIntl +) const +{ + switch (ePres) + { + case SfxItemPresentation::Nameless: + { + if (100 != m_nPropLeftMargin) + { + rText = unicode::formatPercent(m_nPropLeftMargin, + Application::GetSettings().GetUILanguageTag()); + } + else + { + rText = GetMetricText(m_nLeftMargin, + eCoreUnit, ePresUnit, &rIntl); + } + return true; + } + case SfxItemPresentation::Complete: + { + rText = EditResId(RID_SVXITEMS_LRSPACE_LEFT); + if (100 != m_nPropLeftMargin) + { + rText += unicode::formatPercent(m_nPropLeftMargin, + Application::GetSettings().GetUILanguageTag()); + } + else + { + rText += GetMetricText(m_nLeftMargin, eCoreUnit, ePresUnit, &rIntl) + + " " + EditResId(GetMetricId(ePresUnit)); + } + return true; + } + default: ; // prevent warning + } + return false; +} + +void SvxLeftMarginItem::ScaleMetrics(tools::Long const nMult, tools::Long const nDiv) +{ + m_nLeftMargin = BigInt::Scale(m_nLeftMargin, nMult, nDiv); +} + +bool SvxLeftMarginItem::HasMetrics() const +{ + return true; +} + +void SvxLeftMarginItem::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxLeftMarginItem")); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nLeftMargin"), BAD_CAST(OString::number(m_nLeftMargin).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nPropLeftMargin"), BAD_CAST(OString::number(m_nPropLeftMargin).getStr())); + (void)xmlTextWriterEndElement(pWriter); +} + +boost::property_tree::ptree SvxLeftMarginItem::dumpAsJSON() const +{ + boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); + + boost::property_tree::ptree aState; + + MapUnit eTargetUnit = MapUnit::MapInch; + + OUString sLeft = GetMetricText(GetLeft(), + MapUnit::MapTwip, eTargetUnit, nullptr); + + aState.put("left", sLeft); + aState.put("unit", "inch"); + + aTree.push_back(std::make_pair("state", aState)); + + return aTree; +} + +SvxTextLeftMarginItem::SvxTextLeftMarginItem(const sal_uInt16 nId) + : SfxPoolItem(nId) +{ +} + +SvxTextLeftMarginItem::SvxTextLeftMarginItem(const tools::Long nLeft, const sal_uInt16 nId) + : SfxPoolItem(nId) + , m_nTextLeftMargin(nLeft) +{ +} + +bool SvxTextLeftMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const +{ + bool bRet = true; + bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + switch (nMemberId) + { + // tdf#154282 - return both values for the hardcoded 0 in SfxDispatchController_Impl::StateChanged + case 0: + { + css::frame::status::LeftRightMarginScale aLRSpace; + aLRSpace.TextLeft = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(GetTextLeft()) : GetTextLeft()); + aLRSpace.ScaleLeft = static_cast<sal_Int16>(m_nPropLeftMargin); + rVal <<= aLRSpace; + break; + } + case MID_TXT_LMARGIN : + rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(GetTextLeft()) : GetTextLeft()); + break; + case MID_L_REL_MARGIN: + rVal <<= static_cast<sal_Int16>(m_nPropLeftMargin); + break; + default: + assert(false); + bRet = false; + // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? + OSL_FAIL("unknown MemberId"); + } + return bRet; +} + +bool SvxTextLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) +{ + bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + + switch (nMemberId) + { + case MID_TXT_LMARGIN: + { + sal_Int32 nVal = 0; + if (!(rVal >>= nVal)) + { + return false; + } + SetTextLeft(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); + } + break; + case MID_L_REL_MARGIN: + { + sal_Int32 nRel = 0; + if ((rVal >>= nRel) && nRel >= 0 && nRel < SAL_MAX_UINT16) + { + m_nPropLeftMargin = static_cast<sal_uInt16>(nRel); + } + else + { + return false; + } + } + break; + default: + assert(false); + OSL_FAIL("unknown MemberId"); + return false; + } + return true; +} + +bool SvxTextLeftMarginItem::operator==(const SfxPoolItem& rAttr) const +{ + assert(SfxPoolItem::operator==(rAttr)); + + const SvxTextLeftMarginItem& rOther = static_cast<const SvxTextLeftMarginItem&>(rAttr); + + return (m_nTextLeftMargin == rOther.GetTextLeft() + && m_nPropLeftMargin == rOther.GetPropLeft()); +} + +SvxTextLeftMarginItem* SvxTextLeftMarginItem::Clone(SfxItemPool *) const +{ + return new SvxTextLeftMarginItem(*this); +} + +bool SvxTextLeftMarginItem::GetPresentation +( + SfxItemPresentation ePres, + MapUnit eCoreUnit, + MapUnit ePresUnit, + OUString& rText, const IntlWrapper& rIntl +) const +{ + switch (ePres) + { + case SfxItemPresentation::Nameless: + { + if (100 != m_nPropLeftMargin) + { + rText = unicode::formatPercent(m_nPropLeftMargin, + Application::GetSettings().GetUILanguageTag()); + } + else + { + rText = GetMetricText(m_nTextLeftMargin, + eCoreUnit, ePresUnit, &rIntl); + } + return true; + } + case SfxItemPresentation::Complete: + { + rText = EditResId(RID_SVXITEMS_LRSPACE_LEFT); + if (100 != m_nPropLeftMargin) + { + rText += unicode::formatPercent(m_nPropLeftMargin, + Application::GetSettings().GetUILanguageTag()); + } + else + { + rText += GetMetricText(m_nTextLeftMargin, eCoreUnit, ePresUnit, &rIntl) + + " " + EditResId(GetMetricId(ePresUnit)); + } + return true; + } + default: ; // prevent warning + } + return false; +} + +void SvxTextLeftMarginItem::ScaleMetrics(tools::Long const nMult, tools::Long const nDiv) +{ + m_nTextLeftMargin = BigInt::Scale(m_nTextLeftMargin, nMult, nDiv); +} + +bool SvxTextLeftMarginItem::HasMetrics() const +{ + return true; +} + +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_nPropLeftMargin"), BAD_CAST(OString::number(m_nPropLeftMargin).getStr())); + (void)xmlTextWriterEndElement(pWriter); +} + +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"); + + aTree.push_back(std::make_pair("state", aState)); + + return aTree; +} + +SvxFirstLineIndentItem::SvxFirstLineIndentItem(const sal_uInt16 nId) + : SfxPoolItem(nId) +{ +} + +SvxFirstLineIndentItem::SvxFirstLineIndentItem(const short nFirst, const sal_uInt16 nId) + : SfxPoolItem(nId) + , m_nFirstLineOffset(nFirst) +{ +} + +bool SvxFirstLineIndentItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const +{ + bool bRet = true; + bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + switch (nMemberId) + { + case MID_FIRST_LINE_INDENT: + rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(m_nFirstLineOffset) : m_nFirstLineOffset); + break; + case MID_FIRST_LINE_REL_INDENT: + rVal <<= static_cast<sal_Int16>(m_nPropFirstLineOffset); + break; + case MID_FIRST_AUTO: + rVal <<= IsAutoFirst(); + break; + default: + assert(false); + bRet = false; + // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? + OSL_FAIL("unknown MemberId"); + } + return bRet; +} + +bool SvxFirstLineIndentItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) +{ + bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + + switch (nMemberId) + { + case MID_FIRST_LINE_INDENT: + { + sal_Int32 nVal = 0; + if (!(rVal >>= nVal)) + { + return false; + } + m_nFirstLineOffset = bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal; + m_nPropFirstLineOffset = 100; + break; + } + case MID_FIRST_LINE_REL_INDENT: + { + sal_Int32 nRel = 0; + if ((rVal >>= nRel) && nRel >= 0 && nRel < SAL_MAX_UINT16) + { + SetPropTextFirstLineOffset(nRel); + } + else + { + return false; + } + break; + } + case MID_FIRST_AUTO: + SetAutoFirst(Any2Bool(rVal)); + break; + default: + assert(false); + OSL_FAIL("unknown MemberId"); + return false; + } + return true; +} + +bool SvxFirstLineIndentItem::operator==(const SfxPoolItem& rAttr) const +{ + assert(SfxPoolItem::operator==(rAttr)); + + const SvxFirstLineIndentItem& rOther = static_cast<const SvxFirstLineIndentItem&>(rAttr); + + return (m_nFirstLineOffset == rOther.GetTextFirstLineOffset() + && m_nPropFirstLineOffset == rOther.GetPropTextFirstLineOffset() + && m_bAutoFirst == rOther.IsAutoFirst()); +} + +SvxFirstLineIndentItem* SvxFirstLineIndentItem::Clone(SfxItemPool *) const +{ + return new SvxFirstLineIndentItem(*this); +} + +bool SvxFirstLineIndentItem::GetPresentation +( + SfxItemPresentation ePres, + MapUnit eCoreUnit, + MapUnit ePresUnit, + OUString& rText, const IntlWrapper& rIntl +) const +{ + switch (ePres) + { + case SfxItemPresentation::Nameless: + { + if (100 != m_nPropFirstLineOffset) + { + rText += unicode::formatPercent(m_nPropFirstLineOffset, + Application::GetSettings().GetUILanguageTag()); + } + else + { + rText += GetMetricText(static_cast<tools::Long>(m_nFirstLineOffset), + eCoreUnit, ePresUnit, &rIntl); + } + return true; + } + case SfxItemPresentation::Complete: + { + rText += EditResId(RID_SVXITEMS_LRSPACE_FLINE); + if (100 != m_nPropFirstLineOffset) + { + rText += unicode::formatPercent(m_nPropFirstLineOffset, + Application::GetSettings().GetUILanguageTag()); + } + else + { + rText += GetMetricText(static_cast<tools::Long>(m_nFirstLineOffset), + eCoreUnit, ePresUnit, &rIntl) + + " " + EditResId(GetMetricId(ePresUnit)); + } + return true; + } + default: ; // prevent warning + } + return false; +} + +void SvxFirstLineIndentItem::ScaleMetrics(tools::Long const nMult, tools::Long const nDiv) +{ + m_nFirstLineOffset = static_cast<short>(BigInt::Scale(m_nFirstLineOffset, nMult, nDiv)); +} + +bool SvxFirstLineIndentItem::HasMetrics() const +{ + return true; +} + +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_nFirstLineOffset"), BAD_CAST(OString::number(m_nFirstLineOffset).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); +} + +boost::property_tree::ptree SvxFirstLineIndentItem::dumpAsJSON() const +{ + boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); + + boost::property_tree::ptree aState; + + MapUnit eTargetUnit = MapUnit::MapInch; + + OUString sFirstline = GetMetricText(GetTextFirstLineOffset(), + MapUnit::MapTwip, eTargetUnit, nullptr); + + aState.put("firstline", sFirstline); + aState.put("unit", "inch"); + + aTree.push_back(std::make_pair("state", aState)); + + return aTree; +} + +SvxRightMarginItem::SvxRightMarginItem(const sal_uInt16 nId) + : SfxPoolItem(nId) +{ +} + +SvxRightMarginItem::SvxRightMarginItem(const tools::Long nRight, const sal_uInt16 nId) + : SfxPoolItem(nId) + , m_nRightMargin(nRight) +{ +} + +bool SvxRightMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const +{ + bool bRet = true; + bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + switch (nMemberId) + { + // tdf#154282 - return both values for the hardcoded 0 in SfxDispatchController_Impl::StateChanged + case 0: + { + css::frame::status::LeftRightMarginScale aLRSpace; + aLRSpace.Right = static_cast<sal_Int32>(bConvert ? convertTwipToMm100(m_nRightMargin) : m_nRightMargin); + aLRSpace.ScaleRight = static_cast<sal_Int16>(m_nPropRightMargin); + rVal <<= aLRSpace; + break; + } + case MID_R_MARGIN: + rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(m_nRightMargin) : m_nRightMargin); + break; + case MID_R_REL_MARGIN: + rVal <<= static_cast<sal_Int16>(m_nPropRightMargin); + break; + default: + assert(false); + bRet = false; + // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? + OSL_FAIL("unknown MemberId"); + } + return bRet; +} + +bool SvxRightMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) +{ + bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + + switch (nMemberId) + { + case MID_R_MARGIN: + { + sal_Int32 nVal = 0; + if (!(rVal >>= nVal)) + { + return false; + } + SetRight(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); + break; + } + case MID_R_REL_MARGIN: + { + sal_Int32 nRel = 0; + if ((rVal >>= nRel) && nRel >= 0 && nRel < SAL_MAX_UINT16) + { + m_nPropRightMargin = static_cast<sal_uInt16>(nRel); + } + else + { + return false; + } + } + break; + default: + assert(false); + OSL_FAIL("unknown MemberId"); + return false; + } + return true; +} + +bool SvxRightMarginItem::operator==(const SfxPoolItem& rAttr) const +{ + assert(SfxPoolItem::operator==(rAttr)); + + const SvxRightMarginItem& rOther = static_cast<const SvxRightMarginItem&>(rAttr); + + return (m_nRightMargin == rOther.GetRight() + && m_nPropRightMargin == rOther.GetPropRight()); +} + +SvxRightMarginItem* SvxRightMarginItem::Clone(SfxItemPool *) const +{ + return new SvxRightMarginItem(*this); +} + +bool SvxRightMarginItem::GetPresentation +( + SfxItemPresentation ePres, + MapUnit eCoreUnit, + MapUnit ePresUnit, + OUString& rText, const IntlWrapper& rIntl +) const +{ + switch (ePres) + { + case SfxItemPresentation::Nameless: + { + if (100 != m_nRightMargin) + { + rText += unicode::formatPercent(m_nRightMargin, + Application::GetSettings().GetUILanguageTag()); + } + else + { + rText += GetMetricText(m_nRightMargin, + eCoreUnit, ePresUnit, &rIntl); + } + return true; + } + case SfxItemPresentation::Complete: + { + rText += EditResId(RID_SVXITEMS_LRSPACE_RIGHT); + if (100 != m_nPropRightMargin) + { + rText += unicode::formatPercent(m_nPropRightMargin, + Application::GetSettings().GetUILanguageTag()); + } + else + { + rText += GetMetricText(m_nRightMargin, + eCoreUnit, ePresUnit, &rIntl) + + " " + EditResId(GetMetricId(ePresUnit)); + } + return true; + } + default: ; // prevent warning + } + return false; +} + +void SvxRightMarginItem::ScaleMetrics(tools::Long const nMult, tools::Long const nDiv) +{ + m_nRightMargin = BigInt::Scale(m_nRightMargin, nMult, nDiv); +} + +bool SvxRightMarginItem::HasMetrics() const +{ + return true; +} + +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_nPropRightMargin"), BAD_CAST(OString::number(m_nPropRightMargin).getStr())); + (void)xmlTextWriterEndElement(pWriter); +} + +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"); + + aTree.push_back(std::make_pair("state", aState)); + + return aTree; +} + +SvxGutterLeftMarginItem::SvxGutterLeftMarginItem(const sal_uInt16 nId) + : SfxPoolItem(nId) +{ +} + +bool SvxGutterLeftMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const +{ + bool bRet = true; + bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + switch (nMemberId) + { + case MID_GUTTER_MARGIN: + rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(m_nGutterMargin) + : m_nGutterMargin); + break; + default: + assert(false); + bRet = false; + // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? + OSL_FAIL("unknown MemberId"); + } + return bRet; +} + +bool SvxGutterLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId) +{ + bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + + switch (nMemberId) + { + case MID_GUTTER_MARGIN: + { + sal_Int32 nVal = 0; + if (!(rVal >>= nVal)) + { + return false; + } + SetGutterMargin(bConvert ? o3tl::toTwips(nVal, o3tl::Length::mm100) : nVal); + break; + } + default: + assert(false); + OSL_FAIL("unknown MemberId"); + return false; + } + return true; +} + +bool SvxGutterLeftMarginItem::operator==(const SfxPoolItem& rAttr) const +{ + assert(SfxPoolItem::operator==(rAttr)); + + const SvxGutterLeftMarginItem& rOther = static_cast<const SvxGutterLeftMarginItem&>(rAttr); + + return (m_nGutterMargin == rOther.GetGutterMargin()); +} + +SvxGutterLeftMarginItem* SvxGutterLeftMarginItem::Clone(SfxItemPool * ) const +{ + return new SvxGutterLeftMarginItem(*this); +} + +bool SvxGutterLeftMarginItem::GetPresentation +( + SfxItemPresentation /*ePres*/, + MapUnit /*eCoreUnit*/, + MapUnit /*ePresUnit*/, + OUString& /*rText*/, const IntlWrapper& /*rIntl*/ +) const +{ + // TODO? + return false; +} + +void SvxGutterLeftMarginItem::ScaleMetrics(tools::Long const /*nMult*/, tools::Long const /*nDiv*/) +{ + // TODO? +} + +bool SvxGutterLeftMarginItem::HasMetrics() const +{ + return true; +} + +void SvxGutterLeftMarginItem::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxGutterLeftMarginItem")); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nGutterMargin"), + BAD_CAST(OString::number(m_nGutterMargin).getStr())); + (void)xmlTextWriterEndElement(pWriter); +} + +boost::property_tree::ptree SvxGutterLeftMarginItem::dumpAsJSON() const +{ + boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); + + boost::property_tree::ptree aState; + + // TODO? + aState.put("unit", "inch"); + + aTree.push_back(std::make_pair("state", aState)); + + return aTree; +} + +SvxGutterRightMarginItem::SvxGutterRightMarginItem(const sal_uInt16 nId) + : SfxPoolItem(nId) +{ +} + +bool SvxGutterRightMarginItem::QueryValue(uno::Any& /*rVal*/, sal_uInt8 nMemberId) const +{ + bool bRet = true; + //bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; +#ifndef _MSC_VER + switch (nMemberId) + { + // TODO? + default: + assert(false); + bRet = false; + // SfxDispatchController_Impl::StateChanged calls this with hardcoded 0 triggering this; there used to be a MID_LR_MARGIN 0 but what type would it have? + OSL_FAIL("unknown MemberId"); + } +#else + (void) nMemberId; +#endif + return bRet; +} + +bool SvxGutterRightMarginItem::PutValue(const uno::Any& /*rVal*/, sal_uInt8 nMemberId) +{ + //bool bConvert = 0 != (nMemberId & CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + +#ifndef _MSC_VER + switch (nMemberId) + { + // TODO? + default: + assert(false); + OSL_FAIL("unknown MemberId"); + return false; + } +#else + (void) nMemberId; +#endif + return true; +} + + +bool SvxGutterRightMarginItem::operator==(const SfxPoolItem& rAttr) const +{ + assert(SfxPoolItem::operator==(rAttr)); + + const SvxGutterRightMarginItem& rOther = static_cast<const SvxGutterRightMarginItem&>(rAttr); + + return (m_nRightGutterMargin == rOther.GetRightGutterMargin()); +} + +SvxGutterRightMarginItem* SvxGutterRightMarginItem::Clone(SfxItemPool *) const +{ + return new SvxGutterRightMarginItem(*this); +} + +bool SvxGutterRightMarginItem::GetPresentation +( + SfxItemPresentation /*ePres*/, + MapUnit /*eCoreUnit*/, + MapUnit /*ePresUnit*/, + OUString& /*rText*/, const IntlWrapper& /*rIntl*/ +) const +{ + // TODO? + return false; +} + +void SvxGutterRightMarginItem::ScaleMetrics(tools::Long const /*nMult*/, tools::Long const /*nDiv*/) +{ + // TODO? +} + +bool SvxGutterRightMarginItem::HasMetrics() const +{ + return true; +} + +void SvxGutterRightMarginItem::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxGutterRightMarginItem")); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("m_nRightGutterMargin"), + BAD_CAST(OString::number(m_nRightGutterMargin).getStr())); + (void)xmlTextWriterEndElement(pWriter); +} + +boost::property_tree::ptree SvxGutterRightMarginItem::dumpAsJSON() const +{ + boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); + + boost::property_tree::ptree aState; + + // TODO? + aState.put("unit", "inch"); + + aTree.push_back(std::make_pair("state", aState)); + + return aTree; +} + bool SvxLRSpaceItem::operator==( const SfxPoolItem& rAttr ) const { @@ -485,7 +1497,6 @@ bool SvxLRSpaceItem::operator==( const SfxPoolItem& rAttr ) const return ( nFirstLineOffset == rOther.GetTextFirstLineOffset() && - nTxtLeft == rOther.GetTextLeft() && m_nGutterMargin == rOther.GetGutterMargin() && m_nRightGutterMargin == rOther.GetRightGutterMargin() && nLeftMargin == rOther.GetLeft() && @@ -590,7 +1601,6 @@ bool SvxLRSpaceItem::GetPresentation void SvxLRSpaceItem::ScaleMetrics( tools::Long nMult, tools::Long nDiv ) { nFirstLineOffset = static_cast<short>(BigInt::Scale( nFirstLineOffset, nMult, nDiv )); - nTxtLeft = BigInt::Scale( nTxtLeft, nMult, nDiv ); nLeftMargin = BigInt::Scale( nLeftMargin, nMult, nDiv ); nRightMargin = BigInt::Scale( nRightMargin, nMult, nDiv ); } @@ -607,7 +1617,6 @@ 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("nFirstLineOffset"), BAD_CAST(OString::number(nFirstLineOffset).getStr())); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nTxtLeft"), BAD_CAST(OString::number(nTxtLeft).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_nGutterMargin"), @@ -1282,29 +2291,24 @@ void SvxShadowItem::dumpAsXml(xmlTextWriterPtr pWriter) const // class SvxBoxItem ------------------------------------------------------ -SvxBoxItem::SvxBoxItem( const SvxBoxItem& rCpy ) : - - SfxPoolItem ( rCpy ), - pTop ( rCpy.pTop ? new SvxBorderLine( *rCpy.pTop ) : nullptr ), - pBottom ( rCpy.pBottom ? new SvxBorderLine( *rCpy.pBottom ) : nullptr ), - pLeft ( rCpy.pLeft ? new SvxBorderLine( *rCpy.pLeft ) : nullptr ), - pRight ( rCpy.pRight ? new SvxBorderLine( *rCpy.pRight ) : nullptr ), - nTopDist ( rCpy.nTopDist ), - nBottomDist ( rCpy.nBottomDist ), - nLeftDist ( rCpy.nLeftDist ), - nRightDist ( rCpy.nRightDist ), - bRemoveAdjCellBorder ( rCpy.bRemoveAdjCellBorder ) +SvxBoxItem::SvxBoxItem(const SvxBoxItem& rCopy) + : SfxPoolItem (rCopy) + , mpTopBorderLine(rCopy.mpTopBorderLine ? new SvxBorderLine(*rCopy.mpTopBorderLine) : nullptr) + , mpBottomBorderLine(rCopy.mpBottomBorderLine ? new SvxBorderLine(*rCopy.mpBottomBorderLine) : nullptr) + , mpLeftBorderLine(rCopy.mpLeftBorderLine ? new SvxBorderLine(*rCopy.mpLeftBorderLine) : nullptr) + , mpRightBorderLine(rCopy.mpRightBorderLine ? new SvxBorderLine(*rCopy.mpRightBorderLine) : nullptr) + , mnTopDistance(rCopy.mnTopDistance) + , mnBottomDistance(rCopy.mnBottomDistance) + , mnLeftDistance(rCopy.mnLeftDistance) + , mnRightDistance(rCopy.mnRightDistance) + , maTempComplexColors(rCopy.maTempComplexColors) + , mbRemoveAdjCellBorder(rCopy.mbRemoveAdjCellBorder) { } -SvxBoxItem::SvxBoxItem( const sal_uInt16 nId ) : - SfxPoolItem( nId ), - nTopDist ( 0 ), - nBottomDist ( 0 ), - nLeftDist ( 0 ), - nRightDist ( 0 ), - bRemoveAdjCellBorder ( false ) +SvxBoxItem::SvxBoxItem(const sal_uInt16 nId) + : SfxPoolItem(nId) { } @@ -1313,6 +2317,20 @@ SvxBoxItem::~SvxBoxItem() { } +void SvxBoxItem::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxBoxItem")); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("top-dist"), + BAD_CAST(OString::number(mnTopDistance).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("bottom-dist"), + BAD_CAST(OString::number(mnBottomDistance).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("left-dist"), + BAD_CAST(OString::number(mnLeftDistance).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("right-dist"), + BAD_CAST(OString::number(mnRightDistance).getStr())); + SfxPoolItem::dumpAsXml(pWriter); + (void)xmlTextWriterEndElement(pWriter); +} boost::property_tree::ptree SvxBoxItem::dumpAsJSON() const { @@ -1331,7 +2349,7 @@ boost::property_tree::ptree SvxBoxItem::dumpAsJSON() const } -static bool CmpBrdLn( const std::unique_ptr<SvxBorderLine> & pBrd1, const SvxBorderLine* pBrd2 ) +static bool CompareBorderLine(const std::unique_ptr<SvxBorderLine> & pBrd1, const SvxBorderLine* pBrd2) { if( pBrd1.get() == pBrd2 ) return true; @@ -1347,15 +2365,16 @@ bool SvxBoxItem::operator==( const SfxPoolItem& rAttr ) const const SvxBoxItem& rBoxItem = static_cast<const SvxBoxItem&>(rAttr); return ( - ( nTopDist == rBoxItem.nTopDist ) && - ( nBottomDist == rBoxItem.nBottomDist ) && - ( nLeftDist == rBoxItem.nLeftDist ) && - ( nRightDist == rBoxItem.nRightDist ) && - ( bRemoveAdjCellBorder == rBoxItem.bRemoveAdjCellBorder ) && - CmpBrdLn( pTop, rBoxItem.GetTop() ) && - CmpBrdLn( pBottom, rBoxItem.GetBottom() ) && - CmpBrdLn( pLeft, rBoxItem.GetLeft() ) && - CmpBrdLn( pRight, rBoxItem.GetRight() ) ); + (mnTopDistance == rBoxItem.mnTopDistance) && + (mnBottomDistance == rBoxItem.mnBottomDistance) && + (mnLeftDistance == rBoxItem.mnLeftDistance) && + (mnRightDistance == rBoxItem.mnRightDistance) && + (mbRemoveAdjCellBorder == rBoxItem.mbRemoveAdjCellBorder ) && + (maTempComplexColors == rBoxItem.maTempComplexColors) && + CompareBorderLine(mpTopBorderLine, rBoxItem.GetTop()) && + CompareBorderLine(mpBottomBorderLine, rBoxItem.GetBottom()) && + CompareBorderLine(mpLeftBorderLine, rBoxItem.GetLeft()) && + CompareBorderLine(mpRightBorderLine, rBoxItem.GetRight())); } @@ -1372,7 +2391,10 @@ table::BorderLine2 SvxBoxItem::SvxLineToLine(const SvxBorderLine* pLine, bool bC aLine.LineWidth = sal_uInt32( bConvert ? convertTwipToMm100( pLine->GetWidth( ) ) : pLine->GetWidth( ) ); } else + { aLine.Color = aLine.InnerLineWidth = aLine.OuterLineWidth = aLine.LineDistance = 0; + aLine.LineStyle = table::BorderLineStyle::NONE; // 0 is SOLID! + } return aLine; } @@ -1380,7 +2402,7 @@ bool SvxBoxItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const { bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); table::BorderLine2 aRetLine; - sal_uInt16 nDist = 0; + sal_Int16 nDist = 0; bool bDistMember = false; nMemberId &= ~CONVERT_TWIPS; switch(nMemberId) @@ -1393,11 +2415,11 @@ bool SvxBoxItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const uno::Any(SvxBoxItem::SvxLineToLine(GetRight(), bConvert)), uno::Any(SvxBoxItem::SvxLineToLine(GetBottom(), bConvert)), uno::Any(SvxBoxItem::SvxLineToLine(GetTop(), bConvert)), - uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100( GetSmallestDistance()) : GetSmallestDistance())), - uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100( nTopDist ) : nTopDist )), - uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100( nBottomDist ) : nBottomDist )), - uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100( nLeftDist ) : nLeftDist )), - uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100( nRightDist ) : nRightDist )) + uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100(GetSmallestDistance()) : GetSmallestDistance())), + uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100(mnTopDistance) : mnTopDistance)), + uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100(mnBottomDistance) : mnBottomDistance)), + uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100(mnLeftDistance) : mnLeftDistance)), + uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100(mnRightDistance) : mnRightDistance)) }; rVal <<= aSeq; return true; @@ -1423,21 +2445,69 @@ bool SvxBoxItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const bDistMember = true; break; case TOP_BORDER_DISTANCE: - nDist = nTopDist; + nDist = mnTopDistance; bDistMember = true; break; case BOTTOM_BORDER_DISTANCE: - nDist = nBottomDist; + nDist = mnBottomDistance; bDistMember = true; break; case LEFT_BORDER_DISTANCE: - nDist = nLeftDist; + nDist = mnLeftDistance; bDistMember = true; break; case RIGHT_BORDER_DISTANCE: - nDist = nRightDist; + nDist = mnRightDistance; bDistMember = true; break; + case MID_BORDER_BOTTOM_COLOR: + { + if (mpBottomBorderLine) + { + rVal <<= model::color::createXComplexColor(mpBottomBorderLine->getComplexColor()); + } + else if (maTempComplexColors[size_t(SvxBoxItemLine::BOTTOM)].getType() != model::ColorType::Unused) + { + rVal <<= model::color::createXComplexColor(maTempComplexColors[size_t(SvxBoxItemLine::BOTTOM)]); + } + return true; + } + case MID_BORDER_LEFT_COLOR: + { + if (mpLeftBorderLine) + { + rVal <<= model::color::createXComplexColor(mpLeftBorderLine->getComplexColor()); + } + else if (maTempComplexColors[size_t(SvxBoxItemLine::LEFT)].getType() != model::ColorType::Unused) + { + rVal <<= model::color::createXComplexColor(maTempComplexColors[size_t(SvxBoxItemLine::LEFT)]); + } + return true; + } + case MID_BORDER_RIGHT_COLOR: + { + if (mpRightBorderLine) + { + rVal <<= model::color::createXComplexColor(mpRightBorderLine->getComplexColor()); + } + else if (maTempComplexColors[size_t(SvxBoxItemLine::RIGHT)].getType() != model::ColorType::Unused) + { + rVal <<= model::color::createXComplexColor(maTempComplexColors[size_t(SvxBoxItemLine::RIGHT)]); + } + return true; + } + case MID_BORDER_TOP_COLOR: + { + if (mpTopBorderLine) + { + rVal <<= model::color::createXComplexColor(mpTopBorderLine->getComplexColor()); + } + else if (maTempComplexColors[size_t(SvxBoxItemLine::TOP)].getType() != model::ColorType::Unused) + { + rVal <<= model::color::createXComplexColor(maTempComplexColors[size_t(SvxBoxItemLine::TOP)]); + } + return true; + } case LINE_STYLE: case LINE_WIDTH: // it doesn't make sense to return a value for these since it's @@ -1560,10 +2630,11 @@ bool SvxBoxItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) { // 4 Borders and 5 distances const SvxBoxItemLine aBorders[] = { SvxBoxItemLine::LEFT, SvxBoxItemLine::RIGHT, SvxBoxItemLine::BOTTOM, SvxBoxItemLine::TOP }; - for (int n(0); n != SAL_N_ELEMENTS(aBorders); ++n) + for (size_t n(0); n != std::size(aBorders); ++n) { if (!lcl_setLine(aSeq[n], *this, aBorders[n], bConvert)) return false; + tryMigrateComplexColor(aBorders[n]); } // WTH are the borders and the distances saved in different order? @@ -1662,6 +2733,66 @@ bool SvxBoxItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) } } return true; + case MID_BORDER_BOTTOM_COLOR: + { + if (mpBottomBorderLine) + return mpBottomBorderLine->setComplexColorFromAny(rVal); + else + { + css::uno::Reference<css::util::XComplexColor> xComplexColor; + if (!(rVal >>= xComplexColor)) + return false; + + if (xComplexColor.is()) + maTempComplexColors[size_t(SvxBoxItemLine::BOTTOM)] = model::color::getFromXComplexColor(xComplexColor); + } + return true; + } + case MID_BORDER_LEFT_COLOR: + { + if (mpLeftBorderLine) + return mpLeftBorderLine->setComplexColorFromAny(rVal); + else + { + css::uno::Reference<css::util::XComplexColor> xComplexColor; + if (!(rVal >>= xComplexColor)) + return false; + + if (xComplexColor.is()) + maTempComplexColors[size_t(SvxBoxItemLine::LEFT)] = model::color::getFromXComplexColor(xComplexColor); + } + return true; + } + case MID_BORDER_RIGHT_COLOR: + { + if (mpRightBorderLine) + return mpRightBorderLine->setComplexColorFromAny(rVal); + else + { + css::uno::Reference<css::util::XComplexColor> xComplexColor; + if (!(rVal >>= xComplexColor)) + return false; + + if (xComplexColor.is()) + maTempComplexColors[size_t(SvxBoxItemLine::RIGHT)] = model::color::getFromXComplexColor(xComplexColor); + } + return true; + } + case MID_BORDER_TOP_COLOR: + { + if (mpTopBorderLine) + return mpTopBorderLine->setComplexColorFromAny(rVal); + else + { + css::uno::Reference<css::util::XComplexColor> xComplexColor; + if (!(rVal >>= xComplexColor)) + return false; + + if (xComplexColor.is()) + maTempComplexColors[size_t(SvxBoxItemLine::TOP)] = model::color::getFromXComplexColor(xComplexColor); + } + return true; + } } if( bDistMember || nMemberId == BORDER_DISTANCE ) @@ -1670,7 +2801,6 @@ bool SvxBoxItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) if(!(rVal >>= nDist)) return false; - if(nDist >= 0) { if( bConvert ) nDist = o3tl::toTwips(nDist, o3tl::Length::mm100); @@ -1736,6 +2866,7 @@ bool SvxBoxItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert); SetLine(bSet ? &aLine : nullptr, nLine); + tryMigrateComplexColor(nLine); } return true; @@ -1761,112 +2892,111 @@ bool SvxBoxItem::GetPresentation { rText.clear(); - if ( pTop ) + if (mpTopBorderLine) { - rText = pTop->GetValueString( eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp; + rText = mpTopBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp; } - if( !(pTop && pBottom && pLeft && pRight && - *pTop == *pBottom && *pTop == *pLeft && *pTop == *pRight) ) + if ( !(mpTopBorderLine && mpBottomBorderLine && mpLeftBorderLine && mpRightBorderLine && + *mpTopBorderLine == *mpBottomBorderLine && + *mpTopBorderLine == *mpLeftBorderLine && + *mpTopBorderLine == *mpRightBorderLine)) { - if ( pBottom ) + if (mpBottomBorderLine) { - rText += pBottom->GetValueString( eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp; + rText += mpBottomBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp; } - if ( pLeft ) + if (mpLeftBorderLine) { - rText += pLeft->GetValueString( eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp; + rText += mpLeftBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp; } - if ( pRight ) + if (mpRightBorderLine) { - rText += pRight->GetValueString( eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp; + rText += mpRightBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp; } } - rText += GetMetricText( static_cast<tools::Long>(nTopDist), eCoreUnit, ePresUnit, &rIntl ); - if( nTopDist != nBottomDist || nTopDist != nLeftDist || - nTopDist != nRightDist ) + rText += GetMetricText( static_cast<tools::Long>(mnTopDistance), eCoreUnit, ePresUnit, &rIntl ); + if (mnTopDistance != mnBottomDistance || + mnTopDistance != mnLeftDistance || + mnTopDistance != mnRightDistance) { rText += cpDelimTmp + - GetMetricText( static_cast<tools::Long>(nBottomDist), eCoreUnit, - ePresUnit, &rIntl ) + + GetMetricText( tools::Long(mnBottomDistance), eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp + - GetMetricText( static_cast<tools::Long>(nLeftDist), eCoreUnit, ePresUnit, &rIntl ) + + GetMetricText( tools::Long(mnLeftDistance), eCoreUnit, ePresUnit, &rIntl ) + cpDelimTmp + - GetMetricText( static_cast<tools::Long>(nRightDist), eCoreUnit, - ePresUnit, &rIntl ); + GetMetricText( tools::Long(mnRightDistance), eCoreUnit, ePresUnit, &rIntl ); } return true; } case SfxItemPresentation::Complete: { - if( !(pTop || pBottom || pLeft || pRight) ) + if (!(mpTopBorderLine || mpBottomBorderLine || mpLeftBorderLine || mpRightBorderLine)) { rText = EditResId(RID_SVXITEMS_BORDER_NONE) + cpDelimTmp; } else { rText = EditResId(RID_SVXITEMS_BORDER_COMPLETE); - if( pTop && pBottom && pLeft && pRight && - *pTop == *pBottom && *pTop == *pLeft && *pTop == *pRight ) + if (mpTopBorderLine && mpBottomBorderLine && mpLeftBorderLine && mpRightBorderLine && + *mpTopBorderLine == *mpBottomBorderLine && + *mpTopBorderLine == *mpLeftBorderLine && + *mpTopBorderLine == *mpRightBorderLine) { - rText += pTop->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + cpDelimTmp; + rText += mpTopBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + cpDelimTmp; } else { - if ( pTop ) + if (mpTopBorderLine) { rText += EditResId(RID_SVXITEMS_BORDER_TOP) + - pTop->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + + mpTopBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + cpDelimTmp; } - if ( pBottom ) + if (mpBottomBorderLine) { rText += EditResId(RID_SVXITEMS_BORDER_BOTTOM) + - pBottom->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + + mpBottomBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + cpDelimTmp; } - if ( pLeft ) + if (mpLeftBorderLine) { rText += EditResId(RID_SVXITEMS_BORDER_LEFT) + - pLeft->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + + mpLeftBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + cpDelimTmp; } - if ( pRight ) + if (mpRightBorderLine) { rText += EditResId(RID_SVXITEMS_BORDER_RIGHT) + - pRight->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + + mpRightBorderLine->GetValueString( eCoreUnit, ePresUnit, &rIntl, true ) + cpDelimTmp; } } } rText += EditResId(RID_SVXITEMS_BORDER_DISTANCE); - if( nTopDist == nBottomDist && nTopDist == nLeftDist && - nTopDist == nRightDist ) + if (mnTopDistance == mnBottomDistance && + mnTopDistance == mnLeftDistance && + mnTopDistance == mnRightDistance) { - rText += GetMetricText( static_cast<tools::Long>(nTopDist), eCoreUnit, - ePresUnit, &rIntl ) + + rText += GetMetricText(tools::Long(mnTopDistance), eCoreUnit, ePresUnit, &rIntl ) + " " + EditResId(GetMetricId(ePresUnit)); } else { rText += EditResId(RID_SVXITEMS_BORDER_TOP) + - GetMetricText( static_cast<tools::Long>(nTopDist), eCoreUnit, - ePresUnit, &rIntl ) + + GetMetricText(tools::Long(mnTopDistance), eCoreUnit, ePresUnit, &rIntl) + " " + EditResId(GetMetricId(ePresUnit)) + cpDelimTmp + EditResId(RID_SVXITEMS_BORDER_BOTTOM) + - GetMetricText( static_cast<tools::Long>(nBottomDist), eCoreUnit, - ePresUnit, &rIntl ) + + GetMetricText(tools::Long(mnBottomDistance), eCoreUnit, ePresUnit, &rIntl) + " " + EditResId(GetMetricId(ePresUnit)) + cpDelimTmp + EditResId(RID_SVXITEMS_BORDER_LEFT) + - GetMetricText( static_cast<tools::Long>(nLeftDist), eCoreUnit, - ePresUnit, &rIntl ) + + GetMetricText(tools::Long(mnLeftDistance), eCoreUnit, ePresUnit, &rIntl) + " " + EditResId(GetMetricId(ePresUnit)) + cpDelimTmp + EditResId(RID_SVXITEMS_BORDER_RIGHT) + - GetMetricText( static_cast<tools::Long>(nRightDist), eCoreUnit, - ePresUnit, &rIntl ) + + GetMetricText(tools::Long(mnRightDistance), eCoreUnit, ePresUnit, &rIntl) + " " + EditResId(GetMetricId(ePresUnit)); } return true; @@ -1879,14 +3009,19 @@ bool SvxBoxItem::GetPresentation void SvxBoxItem::ScaleMetrics( tools::Long nMult, tools::Long nDiv ) { - if ( pTop ) pTop->ScaleMetrics( nMult, nDiv ); - if ( pBottom ) pBottom->ScaleMetrics( nMult, nDiv ); - if ( pLeft ) pLeft->ScaleMetrics( nMult, nDiv ); - if ( pRight ) pRight->ScaleMetrics( nMult, nDiv ); - nTopDist = static_cast<sal_uInt16>(BigInt::Scale( nTopDist, nMult, nDiv )); - nBottomDist = static_cast<sal_uInt16>(BigInt::Scale( nBottomDist, nMult, nDiv )); - nLeftDist = static_cast<sal_uInt16>(BigInt::Scale( nLeftDist, nMult, nDiv )); - nRightDist = static_cast<sal_uInt16>(BigInt::Scale( nRightDist, nMult, nDiv )); + if (mpTopBorderLine) + mpTopBorderLine->ScaleMetrics( nMult, nDiv ); + if (mpBottomBorderLine) + mpBottomBorderLine->ScaleMetrics( nMult, nDiv ); + if (mpLeftBorderLine) + mpLeftBorderLine->ScaleMetrics( nMult, nDiv ); + if (mpRightBorderLine) + mpRightBorderLine->ScaleMetrics( nMult, nDiv ); + + mnTopDistance = static_cast<sal_Int16>(BigInt::Scale(mnTopDistance, nMult, nDiv)); + mnBottomDistance = static_cast<sal_Int16>(BigInt::Scale(mnBottomDistance, nMult, nDiv)); + mnLeftDistance = static_cast<sal_Int16>(BigInt::Scale(mnLeftDistance, nMult, nDiv)); + mnRightDistance = static_cast<sal_Int16>(BigInt::Scale(mnRightDistance, nMult, nDiv)); } @@ -1903,16 +3038,16 @@ const SvxBorderLine *SvxBoxItem::GetLine( SvxBoxItemLine nLine ) const switch ( nLine ) { case SvxBoxItemLine::TOP: - pRet = pTop.get(); + pRet = mpTopBorderLine.get(); break; case SvxBoxItemLine::BOTTOM: - pRet = pBottom.get(); + pRet = mpBottomBorderLine.get(); break; case SvxBoxItemLine::LEFT: - pRet = pLeft.get(); + pRet = mpLeftBorderLine.get(); break; case SvxBoxItemLine::RIGHT: - pRet = pRight.get(); + pRet = mpRightBorderLine.get(); break; default: OSL_FAIL( "wrong line" ); @@ -1930,16 +3065,16 @@ void SvxBoxItem::SetLine( const SvxBorderLine* pNew, SvxBoxItemLine nLine ) switch ( nLine ) { case SvxBoxItemLine::TOP: - pTop = std::move( pTmp ); + mpTopBorderLine = std::move(pTmp); break; case SvxBoxItemLine::BOTTOM: - pBottom = std::move( pTmp ); + mpBottomBorderLine = std::move(pTmp); break; case SvxBoxItemLine::LEFT: - pLeft = std::move( pTmp ); + mpLeftBorderLine = std::move(pTmp); break; case SvxBoxItemLine::RIGHT: - pRight = std::move( pTmp ); + mpRightBorderLine = std::move(pTmp); break; default: OSL_FAIL( "wrong line" ); @@ -1950,58 +3085,62 @@ void SvxBoxItem::SetLine( const SvxBorderLine* pNew, SvxBoxItemLine nLine ) sal_uInt16 SvxBoxItem::GetSmallestDistance() const { // The smallest distance that is not 0 will be returned. - sal_uInt16 nDist = nTopDist; - if( nBottomDist && (!nDist || nBottomDist < nDist) ) - nDist = nBottomDist; - if( nLeftDist && (!nDist || nLeftDist < nDist) ) - nDist = nLeftDist; - if( nRightDist && (!nDist || nRightDist < nDist) ) - nDist = nRightDist; + sal_uInt16 nDist = mnTopDistance; + if (mnBottomDistance && (!nDist || mnBottomDistance < nDist)) + nDist = mnBottomDistance; + if (mnLeftDistance && (!nDist || mnLeftDistance < nDist)) + nDist = mnLeftDistance; + if (mnRightDistance && (!nDist || mnRightDistance < nDist)) + nDist = mnRightDistance; return nDist; } -sal_uInt16 SvxBoxItem::GetDistance( SvxBoxItemLine nLine ) const +sal_Int16 SvxBoxItem::GetDistance( SvxBoxItemLine nLine, bool bAllowNegative ) const { - sal_uInt16 nDist = 0; + sal_Int16 nDist = 0; switch ( nLine ) { case SvxBoxItemLine::TOP: - nDist = nTopDist; + nDist = mnTopDistance; break; case SvxBoxItemLine::BOTTOM: - nDist = nBottomDist; + nDist = mnBottomDistance; break; case SvxBoxItemLine::LEFT: - nDist = nLeftDist; + nDist = mnLeftDistance; break; case SvxBoxItemLine::RIGHT: - nDist = nRightDist; + nDist = mnRightDistance; break; default: OSL_FAIL( "wrong line" ); } + if (!bAllowNegative && nDist < 0) + { + nDist = 0; + } return nDist; } -void SvxBoxItem::SetDistance( sal_uInt16 nNew, SvxBoxItemLine nLine ) +void SvxBoxItem::SetDistance( sal_Int16 nNew, SvxBoxItemLine nLine ) { switch ( nLine ) { case SvxBoxItemLine::TOP: - nTopDist = nNew; + mnTopDistance = nNew; break; case SvxBoxItemLine::BOTTOM: - nBottomDist = nNew; + mnBottomDistance = nNew; break; case SvxBoxItemLine::LEFT: - nLeftDist = nNew; + mnLeftDistance = nNew; break; case SvxBoxItemLine::RIGHT: - nRightDist = nNew; + mnRightDistance = nNew; break; default: OSL_FAIL( "wrong line" ); @@ -2015,16 +3154,16 @@ sal_uInt16 SvxBoxItem::CalcLineWidth( SvxBoxItemLine nLine ) const switch ( nLine ) { case SvxBoxItemLine::TOP: - pTmp = pTop.get(); + pTmp = mpTopBorderLine.get(); break; case SvxBoxItemLine::BOTTOM: - pTmp = pBottom.get(); + pTmp = mpBottomBorderLine.get(); break; case SvxBoxItemLine::LEFT: - pTmp = pLeft.get(); + pTmp = mpLeftBorderLine.get(); break; case SvxBoxItemLine::RIGHT: - pTmp = pRight.get(); + pTmp = mpRightBorderLine.get(); break; default: OSL_FAIL( "wrong line" ); @@ -2036,27 +3175,27 @@ sal_uInt16 SvxBoxItem::CalcLineWidth( SvxBoxItemLine nLine ) const return nWidth; } -sal_uInt16 SvxBoxItem::CalcLineSpace( SvxBoxItemLine nLine, bool bEvenIfNoLine ) const +sal_Int16 SvxBoxItem::CalcLineSpace( SvxBoxItemLine nLine, bool bEvenIfNoLine, bool bAllowNegative ) const { SvxBorderLine* pTmp = nullptr; - sal_uInt16 nDist = 0; + sal_Int16 nDist = 0; switch ( nLine ) { case SvxBoxItemLine::TOP: - pTmp = pTop.get(); - nDist = nTopDist; + pTmp = mpTopBorderLine.get(); + nDist = mnTopDistance; break; case SvxBoxItemLine::BOTTOM: - pTmp = pBottom.get(); - nDist = nBottomDist; + pTmp = mpBottomBorderLine.get(); + nDist = mnBottomDistance; break; case SvxBoxItemLine::LEFT: - pTmp = pLeft.get(); - nDist = nLeftDist; + pTmp = mpLeftBorderLine.get(); + nDist = mnLeftDistance; break; case SvxBoxItemLine::RIGHT: - pTmp = pRight.get(); - nDist = nRightDist; + pTmp = mpRightBorderLine.get(); + nDist = mnRightDistance; break; default: OSL_FAIL( "wrong line" ); @@ -2068,9 +3207,44 @@ sal_uInt16 SvxBoxItem::CalcLineSpace( SvxBoxItemLine nLine, bool bEvenIfNoLine ) } else if( !bEvenIfNoLine ) nDist = 0; + + if (!bAllowNegative && nDist < 0) + { + nDist = 0; + } + return nDist; } +void SvxBoxItem::tryMigrateComplexColor(SvxBoxItemLine eLine) +{ + if (!GetLine(eLine)) + return; + + auto nIndex = size_t(eLine); + + if (maTempComplexColors[nIndex].getType() == model::ColorType::Unused) + return; + + switch (eLine) + { + case SvxBoxItemLine::TOP: + mpTopBorderLine->setComplexColor(maTempComplexColors[nIndex]); + break; + case SvxBoxItemLine::BOTTOM: + mpBottomBorderLine->setComplexColor(maTempComplexColors[nIndex]); + break; + case SvxBoxItemLine::LEFT: + mpLeftBorderLine->setComplexColor(maTempComplexColors[nIndex]); + break; + case SvxBoxItemLine::RIGHT: + mpRightBorderLine->setComplexColor(maTempComplexColors[nIndex]); + break; + } + + maTempComplexColors[nIndex] = model::ComplexColor(); +} + bool SvxBoxItem::HasBorder( bool bTreatPaddingAsBorder ) const { return CalcLineSpace( SvxBoxItemLine::BOTTOM, bTreatPaddingAsBorder ) @@ -2081,27 +3255,25 @@ bool SvxBoxItem::HasBorder( bool bTreatPaddingAsBorder ) const // class SvxBoxInfoItem -------------------------------------------------- -SvxBoxInfoItem::SvxBoxInfoItem( const sal_uInt16 nId ) : - SfxPoolItem( nId ), - mbEnableHor( false ), - mbEnableVer( false ), - nDefDist( 0 ) +SvxBoxInfoItem::SvxBoxInfoItem(const sal_uInt16 nId) + : SfxPoolItem(nId) + , mbDistance(false) + , mbMinimumDistance(false) { - bDist = bMinDist = false; ResetFlags(); } -SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem& rCpy ) : - SfxPoolItem( rCpy ), - pHori( rCpy.pHori ? new SvxBorderLine( *rCpy.pHori ) : nullptr ), - pVert( rCpy.pVert ? new SvxBorderLine( *rCpy.pVert ) : nullptr ), - mbEnableHor( rCpy.mbEnableHor ), - mbEnableVer( rCpy.mbEnableVer ), - bDist( rCpy.bDist ), - bMinDist ( rCpy.bMinDist ), - nValidFlags( rCpy.nValidFlags ), - nDefDist( rCpy.nDefDist ) +SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem& rCopy ) + : SfxPoolItem(rCopy) + , mpHorizontalLine(rCopy.mpHorizontalLine ? new SvxBorderLine(*rCopy.mpHorizontalLine) : nullptr) + , mpVerticalLine(rCopy.mpVerticalLine ? new SvxBorderLine(*rCopy.mpVerticalLine) : nullptr) + , mbEnableHorizontalLine(rCopy.mbEnableHorizontalLine) + , mbEnableVerticalLine(rCopy.mbEnableVerticalLine) + , mbDistance(rCopy.mbDistance) + , mbMinimumDistance (rCopy.mbMinimumDistance) + , mnValidFlags(rCopy.mnValidFlags) + , mnDefaultMinimumDistance(rCopy.mnDefaultMinimumDistance) { } @@ -2131,29 +3303,28 @@ bool SvxBoxInfoItem::operator==( const SfxPoolItem& rAttr ) const const SvxBoxInfoItem& rBoxInfo = static_cast<const SvxBoxInfoItem&>(rAttr); - return ( mbEnableHor == rBoxInfo.mbEnableHor - && mbEnableVer == rBoxInfo.mbEnableVer - && bDist == rBoxInfo.IsDist() - && bMinDist == rBoxInfo.IsMinDist() - && nValidFlags == rBoxInfo.nValidFlags - && nDefDist == rBoxInfo.GetDefDist() - && CmpBrdLn( pHori, rBoxInfo.GetHori() ) - && CmpBrdLn( pVert, rBoxInfo.GetVert() ) - ); + return (mbEnableHorizontalLine == rBoxInfo.mbEnableHorizontalLine + && mbEnableVerticalLine == rBoxInfo.mbEnableVerticalLine + && mbDistance == rBoxInfo.mbDistance + && mbMinimumDistance == rBoxInfo.mbMinimumDistance + && mnValidFlags == rBoxInfo.mnValidFlags + && mnDefaultMinimumDistance == rBoxInfo.mnDefaultMinimumDistance + && CompareBorderLine(mpHorizontalLine, rBoxInfo.GetHori()) + && CompareBorderLine(mpVerticalLine, rBoxInfo.GetVert())); } void SvxBoxInfoItem::SetLine( const SvxBorderLine* pNew, SvxBoxInfoItemLine nLine ) { - std::unique_ptr<SvxBorderLine> pTmp( pNew ? new SvxBorderLine( *pNew ) : nullptr ); + std::unique_ptr<SvxBorderLine> pCopy(pNew ? new SvxBorderLine(*pNew) : nullptr); if ( SvxBoxInfoItemLine::HORI == nLine ) { - pHori = std::move(pTmp); + mpHorizontalLine = std::move(pCopy); } else if ( SvxBoxInfoItemLine::VERT == nLine ) { - pVert = std::move(pTmp); + mpVerticalLine = std::move(pCopy); } else { @@ -2181,9 +3352,11 @@ bool SvxBoxInfoItem::GetPresentation void SvxBoxInfoItem::ScaleMetrics( tools::Long nMult, tools::Long nDiv ) { - if ( pHori ) pHori->ScaleMetrics( nMult, nDiv ); - if ( pVert ) pVert->ScaleMetrics( nMult, nDiv ); - nDefDist = static_cast<sal_uInt16>(BigInt::Scale( nDefDist, nMult, nDiv )); + if (mpHorizontalLine) + mpHorizontalLine->ScaleMetrics(nMult, nDiv); + if (mpVerticalLine) + mpVerticalLine->ScaleMetrics(nMult, nDiv); + mnDefaultMinimumDistance = sal_uInt16(BigInt::Scale(mnDefaultMinimumDistance, nMult, nDiv)); } @@ -2195,7 +3368,7 @@ bool SvxBoxInfoItem::HasMetrics() const void SvxBoxInfoItem::ResetFlags() { - nValidFlags = static_cast<SvxBoxInfoItemValidFlags>(0x7F); // all valid except Disable + mnValidFlags = static_cast<SvxBoxInfoItemValidFlags>(0x7F); // all valid except Disable } bool SvxBoxInfoItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const @@ -2217,10 +3390,10 @@ bool SvxBoxInfoItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const if ( IsMinDist() ) nVal |= 0x04; css::uno::Sequence< css::uno::Any > aSeq{ - uno::Any(SvxBoxItem::SvxLineToLine( pHori.get(), bConvert)), - uno::Any(SvxBoxItem::SvxLineToLine( pVert.get(), bConvert)), + uno::Any(SvxBoxItem::SvxLineToLine(mpHorizontalLine.get(), bConvert)), + uno::Any(SvxBoxItem::SvxLineToLine(mpVerticalLine.get(), bConvert)), uno::Any(nVal), - uno::Any(static_cast<sal_Int16>(nValidFlags)), + uno::Any(static_cast<sal_Int16>(mnValidFlags)), uno::Any(static_cast<sal_Int32>(bConvert ? convertTwipToMm100(GetDefDist()) : GetDefDist())) }; rVal <<= aSeq; @@ -2228,10 +3401,10 @@ bool SvxBoxInfoItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const } case MID_HORIZONTAL: - aRetLine = SvxBoxItem::SvxLineToLine( pHori.get(), bConvert); + aRetLine = SvxBoxItem::SvxLineToLine(mpHorizontalLine.get(), bConvert); break; case MID_VERTICAL: - aRetLine = SvxBoxItem::SvxLineToLine( pVert.get(), bConvert); + aRetLine = SvxBoxItem::SvxLineToLine(mpVerticalLine.get(), bConvert); break; case MID_FLAGS: bIntMember = true; @@ -2245,7 +3418,7 @@ bool SvxBoxInfoItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const break; case MID_VALIDFLAGS: bIntMember = true; - rVal <<= static_cast<sal_Int16>(nValidFlags); + rVal <<= static_cast<sal_Int16>(mnValidFlags); break; case MID_DISTANCE: bIntMember = true; @@ -2290,7 +3463,7 @@ bool SvxBoxInfoItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) else return false; if ( aSeq[3] >>= nFlags ) - nValidFlags = static_cast<SvxBoxInfoItemValidFlags>(nFlags); + mnValidFlags = static_cast<SvxBoxInfoItemValidFlags>(nFlags); else return false; if (( aSeq[4] >>= nVal ) && ( nVal >= 0 )) @@ -2403,7 +3576,7 @@ bool SvxBoxInfoItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) sal_Int16 nFlags = sal_Int16(); bRet = (rVal >>= nFlags); if ( bRet ) - nValidFlags = static_cast<SvxBoxInfoItemValidFlags>(nFlags); + mnValidFlags = static_cast<SvxBoxInfoItemValidFlags>(nFlags); break; } case MID_DISTANCE: @@ -2456,8 +3629,7 @@ void BorderDistanceFromWord(bool bFromEdge, sal_Int32& nMargin, sal_Int32& nBord } else if (nNewBorderDistance < 0) { - nNewMargin = std::max<sal_Int32>(nMargin - nBorderWidth, 0); - nNewBorderDistance = 0; + nNewMargin = nMargin; } nMargin = nNewMargin; @@ -2481,10 +3653,10 @@ void BorderDistancesToWord(const SvxBoxItem& rBox, const WordPageMargins& rMargi WordBorderDistances& rDistances) { // Use signed sal_Int32 that can hold sal_uInt16, to prevent overflow at subtraction below - const sal_Int32 nT = rBox.GetDistance(SvxBoxItemLine::TOP); - const sal_Int32 nL = rBox.GetDistance(SvxBoxItemLine::LEFT); - const sal_Int32 nB = rBox.GetDistance(SvxBoxItemLine::BOTTOM); - const sal_Int32 nR = rBox.GetDistance(SvxBoxItemLine::RIGHT); + const sal_Int32 nT = rBox.GetDistance(SvxBoxItemLine::TOP, /*bAllowNegative=*/true); + const sal_Int32 nL = rBox.GetDistance(SvxBoxItemLine::LEFT, /*bAllowNegative=*/true); + const sal_Int32 nB = rBox.GetDistance(SvxBoxItemLine::BOTTOM, /*bAllowNegative=*/true); + const sal_Int32 nR = rBox.GetDistance(SvxBoxItemLine::RIGHT, /*bAllowNegative=*/true); // Only take into account existing borders const SvxBorderLine* pLnT = rBox.GetLine(SvxBoxItemLine::TOP); @@ -2512,7 +3684,7 @@ void BorderDistancesToWord(const SvxBoxItem& rBox, const WordPageMargins& rMargi const sal_Int32 n32pt = 32 * 20; // 1. If all borders are in range of 31 pts from text - if (nT2BT < n32pt && nT2BL < n32pt && nT2BB < n32pt && nT2BR < n32pt) + if (nT2BT >= 0 && nT2BT < n32pt && nT2BL >= 0 && nT2BL < n32pt && nT2BB >= 0 && nT2BB < n32pt && nT2BR >= 0 && nT2BR < n32pt) { rDistances.bFromEdge = false; } @@ -2583,7 +3755,7 @@ OUString SvxFormatBreakItem::GetValueTextByPos( sal_uInt16 nPos ) RID_SVXITEMS_BREAK_PAGE_AFTER, RID_SVXITEMS_BREAK_PAGE_BOTH }; - static_assert(SAL_N_ELEMENTS(RID_SVXITEMS_BREAK) == size_t(SvxBreak::End), "unexpected size"); + static_assert(std::size(RID_SVXITEMS_BREAK) == size_t(SvxBreak::End), "unexpected size"); assert(nPos < sal_uInt16(SvxBreak::End) && "enum overflow!"); return EditResId(RID_SVXITEMS_BREAK[nPos]); } @@ -2696,7 +3868,7 @@ bool SvxLineItem::operator==( const SfxPoolItem& rAttr ) const { assert(SfxPoolItem::operator==(rAttr)); - return CmpBrdLn( pLine, static_cast<const SvxLineItem&>(rAttr).GetLine() ); + return CompareBorderLine(pLine, static_cast<const SvxLineItem&>(rAttr).GetLine()); } SvxLineItem* SvxLineItem::Clone( SfxItemPool* ) const @@ -2806,9 +3978,16 @@ void SvxLineItem::SetLine( const SvxBorderLine* pNew ) pLine.reset( pNew ? new SvxBorderLine( *pNew ) : nullptr ); } +ItemInstanceManager* SvxBrushItem::getItemInstanceManager() const +{ + static DefaultItemInstanceManager aInstanceManager(typeid(SvxBrushItem).hash_code()); + return &aInstanceManager; +} + SvxBrushItem::SvxBrushItem(sal_uInt16 _nWhich) : SfxPoolItem(_nWhich) , aColor(COL_TRANSPARENT) + , aFilterColor(COL_TRANSPARENT) , nShadingValue(ShadingPattern::CLEAR) , nGraphicTransparency(0) , eGraphicPos(GPOS_NONE) @@ -2819,6 +3998,19 @@ SvxBrushItem::SvxBrushItem(sal_uInt16 _nWhich) SvxBrushItem::SvxBrushItem(const Color& rColor, sal_uInt16 _nWhich) : SfxPoolItem(_nWhich) , aColor(rColor) + , aFilterColor(COL_TRANSPARENT) + , nShadingValue(ShadingPattern::CLEAR) + , nGraphicTransparency(0) + , eGraphicPos(GPOS_NONE) + , bLoadAgain(true) +{ +} + +SvxBrushItem::SvxBrushItem(Color const& rColor, model::ComplexColor const& rComplexColor, sal_uInt16 nWhich) + : SfxPoolItem(nWhich) + , aColor(rColor) + , maComplexColor(rComplexColor) + , aFilterColor(COL_TRANSPARENT) , nShadingValue(ShadingPattern::CLEAR) , nGraphicTransparency(0) , eGraphicPos(GPOS_NONE) @@ -2829,6 +4021,7 @@ SvxBrushItem::SvxBrushItem(const Color& rColor, sal_uInt16 _nWhich) SvxBrushItem::SvxBrushItem(const Graphic& rGraphic, SvxGraphicPosition ePos, sal_uInt16 _nWhich) : SfxPoolItem(_nWhich) , aColor(COL_TRANSPARENT) + , aFilterColor(COL_TRANSPARENT) , nShadingValue(ShadingPattern::CLEAR) , xGraphicObject(new GraphicObject(rGraphic)) , nGraphicTransparency(0) @@ -2841,6 +4034,7 @@ SvxBrushItem::SvxBrushItem(const Graphic& rGraphic, SvxGraphicPosition ePos, sal SvxBrushItem::SvxBrushItem(const GraphicObject& rGraphicObj, SvxGraphicPosition ePos, sal_uInt16 _nWhich) : SfxPoolItem(_nWhich) , aColor(COL_TRANSPARENT) + , aFilterColor(COL_TRANSPARENT) , nShadingValue(ShadingPattern::CLEAR) , xGraphicObject(new GraphicObject(rGraphicObj)) , nGraphicTransparency(0) @@ -2850,14 +4044,15 @@ SvxBrushItem::SvxBrushItem(const GraphicObject& rGraphicObj, SvxGraphicPosition DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" ); } -SvxBrushItem::SvxBrushItem(const OUString& rLink, const OUString& rFilter, +SvxBrushItem::SvxBrushItem(OUString aLink, OUString aFilter, SvxGraphicPosition ePos, sal_uInt16 _nWhich) : SfxPoolItem(_nWhich) , aColor(COL_TRANSPARENT) + , aFilterColor(COL_TRANSPARENT) , nShadingValue(ShadingPattern::CLEAR) , nGraphicTransparency(0) - , maStrLink(rLink) - , maStrFilter(rFilter) + , maStrLink(std::move(aLink)) + , maStrFilter(std::move(aFilter)) , eGraphicPos((GPOS_NONE != ePos) ? ePos : GPOS_MM) , bLoadAgain(true) { @@ -2867,6 +4062,8 @@ SvxBrushItem::SvxBrushItem(const OUString& rLink, const OUString& rFilter, SvxBrushItem::SvxBrushItem(const SvxBrushItem& rItem) : SfxPoolItem(rItem) , aColor(rItem.aColor) + , maComplexColor(rItem.maComplexColor) + , aFilterColor(rItem.aFilterColor) , nShadingValue(rItem.nShadingValue) , xGraphicObject(rItem.xGraphicObject ? new GraphicObject(*rItem.xGraphicObject) : nullptr) , nGraphicTransparency(rItem.nGraphicTransparency) @@ -2880,6 +4077,8 @@ SvxBrushItem::SvxBrushItem(const SvxBrushItem& rItem) SvxBrushItem::SvxBrushItem(SvxBrushItem&& rItem) : SfxPoolItem(std::move(rItem)) , aColor(std::move(rItem.aColor)) + , maComplexColor(std::move(rItem.maComplexColor)) + , aFilterColor(std::move(rItem.aFilterColor)) , nShadingValue(std::move(rItem.nShadingValue)) , xGraphicObject(std::move(rItem.xGraphicObject)) , nGraphicTransparency(std::move(rItem.nGraphicTransparency)) @@ -2938,6 +4137,15 @@ bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const case MID_BACK_COLOR_TRANSPARENCY: rVal <<= SvxBrushItem::TransparencyToPercent(255 - aColor.GetAlpha()); break; + + case MID_BACKGROUND_COMPLEX_COLOR: + { + auto xComplexColor = model::color::createXComplexColor(maComplexColor); + rVal <<= xComplexColor; + break; + } + break; + case MID_GRAPHIC_POSITION: rVal <<= static_cast<style::GraphicLocation>(static_cast<sal_Int16>(eGraphicPos)); break; @@ -2999,6 +4207,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) { aNewCol.SetAlpha(aColor.GetAlpha()); } + ASSERT_CHANGE_REFCOUNTED_ITEM; aColor = aNewCol; } break; @@ -3007,10 +4216,25 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) sal_Int32 nTrans = 0; if ( !( rVal >>= nTrans ) || nTrans < 0 || nTrans > 100 ) return false; + ASSERT_CHANGE_REFCOUNTED_ITEM; aColor.SetAlpha(255 - lcl_PercentToTransparency(nTrans)); } break; + case MID_BACKGROUND_COMPLEX_COLOR: + { + css::uno::Reference<css::util::XComplexColor> xComplexColor; + if (!(rVal >>= xComplexColor)) + return false; + + if (xComplexColor.is()) + { + ASSERT_CHANGE_REFCOUNTED_ITEM; + maComplexColor = model::color::getFromXComplexColor(xComplexColor); + } + } + break; + case MID_GRAPHIC_POSITION: { style::GraphicLocation eLocation; @@ -3021,11 +4245,13 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) return false; eLocation = static_cast<style::GraphicLocation>(nValue); } + ASSERT_CHANGE_REFCOUNTED_ITEM; SetGraphicPos( static_cast<SvxGraphicPosition>(static_cast<sal_uInt16>(eLocation)) ); } break; case MID_GRAPHIC_TRANSPARENT: + ASSERT_CHANGE_REFCOUNTED_ITEM; aColor.SetAlpha( Any2Bool( rVal ) ? 0 : 255 ); break; @@ -3049,6 +4275,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) { maStrLink.clear(); + ASSERT_CHANGE_REFCOUNTED_ITEM; std::unique_ptr<GraphicObject> xOldGrfObj(std::move(xGraphicObject)); xGraphicObject.reset(new GraphicObject(aGraphic)); ApplyGraphicTransparency_Impl(); @@ -3072,6 +4299,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) { OUString sLink; rVal >>= sLink; + ASSERT_CHANGE_REFCOUNTED_ITEM; SetGraphicFilter( sLink ); } } @@ -3082,6 +4310,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) rVal >>= nTmp; if(nTmp >= 0 && nTmp <= 100) { + ASSERT_CHANGE_REFCOUNTED_ITEM; nGraphicTransparency = sal_Int8(nTmp); if (xGraphicObject) ApplyGraphicTransparency_Impl(); @@ -3095,6 +4324,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) if (!(rVal >>= nVal)) return false; + ASSERT_CHANGE_REFCOUNTED_ITEM; nShadingValue = nVal; } break; @@ -3134,8 +4364,12 @@ bool SvxBrushItem::operator==( const SfxPoolItem& rAttr ) const assert(SfxPoolItem::operator==(rAttr)); const SvxBrushItem& rCmp = static_cast<const SvxBrushItem&>(rAttr); - bool bEqual = ( aColor == rCmp.aColor && eGraphicPos == rCmp.eGraphicPos && - nGraphicTransparency == rCmp.nGraphicTransparency); + bool bEqual = + aColor == rCmp.aColor && + maComplexColor == rCmp.maComplexColor && + aFilterColor == rCmp.aFilterColor && + eGraphicPos == rCmp.eGraphicPos && + nGraphicTransparency == rCmp.nGraphicTransparency; if ( bEqual ) { @@ -3208,7 +4442,7 @@ const GraphicObject* SvxBrushItem::GetGraphicObject(OUString const & referer) co std::unique_ptr<SvMemoryStream> const xMemStream(aGraphicURL.getData()); if (xMemStream) { - if (ERRCODE_NONE == GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, "", *xMemStream)) + if (ERRCODE_NONE == GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, u"", *xMemStream)) { bGraphicLoaded = true; @@ -3240,6 +4474,7 @@ void SvxBrushItem::setGraphicTransparency(sal_Int8 nNew) { if (nNew != nGraphicTransparency) { + ASSERT_CHANGE_REFCOUNTED_ITEM; nGraphicTransparency = nNew; ApplyGraphicTransparency_Impl(); } @@ -3253,6 +4488,10 @@ const Graphic* SvxBrushItem::GetGraphic(OUString const & referer) const void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew ) { + if (eGraphicPos == eNew) + return; + + ASSERT_CHANGE_REFCOUNTED_ITEM; eGraphicPos = eNew; if ( GPOS_NONE == eGraphicPos ) @@ -3274,6 +4513,7 @@ void SvxBrushItem::SetGraphic( const Graphic& rNew ) { if ( maStrLink.isEmpty() ) { + ASSERT_CHANGE_REFCOUNTED_ITEM; if (xGraphicObject) xGraphicObject->SetGraphic(rNew); else @@ -3294,6 +4534,7 @@ void SvxBrushItem::SetGraphicObject( const GraphicObject& rNewObj ) { if ( maStrLink.isEmpty() ) { + ASSERT_CHANGE_REFCOUNTED_ITEM; if (xGraphicObject) *xGraphicObject = rNewObj; else @@ -3312,6 +4553,7 @@ void SvxBrushItem::SetGraphicObject( const GraphicObject& rNewObj ) void SvxBrushItem::SetGraphicLink( const OUString& rNew ) { + ASSERT_CHANGE_REFCOUNTED_ITEM; if ( rNew.isEmpty() ) maStrLink.clear(); else @@ -3323,6 +4565,7 @@ void SvxBrushItem::SetGraphicLink( const OUString& rNew ) void SvxBrushItem::SetGraphicFilter( const OUString& rNew ) { + ASSERT_CHANGE_REFCOUNTED_ITEM; maStrFilter = rNew; } @@ -3343,6 +4586,7 @@ void SvxBrushItem::dumpAsXml(xmlTextWriterPtr pWriter) const (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxBrushItem")); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("color"), BAD_CAST(aColor.AsRGBHexString().toUtf8().getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("filtercolor"), BAD_CAST(aFilterColor.AsRGBHexString().toUtf8().getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("shadingValue"), BAD_CAST(OString::number(nShadingValue).getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("link"), BAD_CAST(maStrLink.toUtf8().getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("filter"), BAD_CAST(maStrFilter.toUtf8().getStr())); @@ -3352,6 +4596,12 @@ void SvxBrushItem::dumpAsXml(xmlTextWriterPtr pWriter) const } +ItemInstanceManager* SvxFrameDirectionItem::getItemInstanceManager() const +{ + static DefaultItemInstanceManager aInstanceManager(typeid(SvxFrameDirectionItem).hash_code()); + return &aInstanceManager; +} + SvxFrameDirectionItem::SvxFrameDirectionItem( SvxFrameDirection nValue , sal_uInt16 _nWhich ) : SfxEnumItem<SvxFrameDirection>( _nWhich, nValue ) @@ -3377,7 +4627,8 @@ TranslateId getFrmDirResId(size_t nIndex) RID_SVXITEMS_FRMDIR_VERT_TOP_RIGHT, RID_SVXITEMS_FRMDIR_VERT_TOP_LEFT, RID_SVXITEMS_FRMDIR_ENVIRONMENT, - RID_SVXITEMS_FRMDIR_VERT_BOT_LEFT + RID_SVXITEMS_FRMDIR_VERT_BOT_LEFT, + RID_SVXITEMS_FRMDIR_VERT_TOP_RIGHT90 }; return RID_SVXITEMS_FRMDIR[nIndex]; } @@ -3399,6 +4650,7 @@ bool SvxFrameDirectionItem::PutValue( const css::uno::Any& rVal, bool bRet = ( rVal >>= nVal ); if( bRet ) { + ASSERT_CHANGE_REFCOUNTED_ITEM; // translate WritingDirection2 constants into SvxFrameDirection switch( nVal ) { @@ -3417,9 +4669,15 @@ bool SvxFrameDirectionItem::PutValue( const css::uno::Any& rVal, case text::WritingMode2::BT_LR: SetValue( SvxFrameDirection::Vertical_LR_BT ); break; + case text::WritingMode2::TB_RL90: + SetValue(SvxFrameDirection::Vertical_RL_TB90); + break; case text::WritingMode2::PAGE: SetValue( SvxFrameDirection::Environment ); break; + case text::WritingMode2::STACKED: + SetValue(SvxFrameDirection::Stacked); + break; default: bRet = false; break; @@ -3453,9 +4711,15 @@ bool SvxFrameDirectionItem::QueryValue( css::uno::Any& rVal, case SvxFrameDirection::Vertical_LR_BT: nVal = text::WritingMode2::BT_LR; break; + case SvxFrameDirection::Vertical_RL_TB90: + nVal = text::WritingMode2::TB_RL90; + break; case SvxFrameDirection::Environment: nVal = text::WritingMode2::PAGE; break; + case SvxFrameDirection::Stacked: + nVal = text::WritingMode2::STACKED; + break; default: OSL_FAIL("Unknown SvxFrameDirection value!"); bRet = false; |