Related: tdf#129300 add ScIndentItem to provide a description
Change-Id: Ieb1a12f35cf8974c557c6e52eac0cd9fb7f80914
Reviewed-on: https://gerrit.libreoffice.org/84945
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx
index ead7d7d..48ee077 100644
--- a/cui/source/tabpages/align.cxx
+++ b/cui/source/tabpages/align.cxx
@@ -207,7 +207,12 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet )
if (m_xEdIndent->get_value_changed_from_saved())
{
rSet->Put(SfxUInt16Item(GetWhich(SID_ATTR_ALIGN_INDENT), m_xEdIndent->get_value(FieldUnit::TWIP)));
const SfxUInt16Item* pIndentItem = static_cast<const SfxUInt16Item*>(GetOldItem(
*rSet, SID_ATTR_ALIGN_INDENT));
assert(pIndentItem);
std::unique_ptr<SfxUInt16Item> pNewIndentItem(static_cast<SfxUInt16Item*>(pIndentItem->Clone()));
pNewIndentItem->SetValue(m_xEdIndent->get_value(FieldUnit::TWIP));
rSet->Put(*pNewIndentItem);
bChanged = true;
}
diff --git a/sc/inc/attrib.hxx b/sc/inc/attrib.hxx
index 59be64fb..5227a36 100644
--- a/sc/inc/attrib.hxx
+++ b/sc/inc/attrib.hxx
@@ -345,6 +345,18 @@ public:
const IntlWrapper& rIntl) const override;
};
class SC_DLLPUBLIC ScIndentItem final : public SfxUInt16Item
{
public:
ScIndentItem(sal_uInt16 nIndent = 0);
virtual ScIndentItem* Clone(SfxItemPool* pPool=nullptr) const override;
virtual bool GetPresentation( SfxItemPresentation ePresentation,
MapUnit, MapUnit,
OUString& rText,
const IntlWrapper& rIntl) const override;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 4f13865..acb159d 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -523,6 +523,7 @@
#define STR_LINEBREAKCELL_OFF NC_("STR_LINEBREAKCELL_OFF", "Wrap text automatically: Off")
#define STR_HYPHENATECELL_ON NC_("STR_HYPHENATECELL_ON", "Hyphenate: On")
#define STR_HYPHENATECELL_OFF NC_("STR_HYPHENATECELL_OFF", "Hyphenate: Off")
#define STR_INDENTCELL NC_("STR_INDENTCELL", "Indent: ")
#endif
diff --git a/sc/inc/scitems.hxx b/sc/inc/scitems.hxx
index 674bf07..6e5054d 100644
--- a/sc/inc/scitems.hxx
+++ b/sc/inc/scitems.hxx
@@ -117,7 +117,7 @@ class SvxSizeItem;
#define ATTR_FORBIDDEN_RULES TypedWhichId<SvxForbiddenRuleItem>(128)
#define ATTR_HOR_JUSTIFY TypedWhichId<SvxHorJustifyItem>(129)
#define ATTR_HOR_JUSTIFY_METHOD TypedWhichId<SvxJustifyMethodItem>(130)
#define ATTR_INDENT TypedWhichId<SfxUInt16Item>(131)
#define ATTR_INDENT TypedWhichId<ScIndentItem>(131)
#define ATTR_VER_JUSTIFY TypedWhichId<SvxVerJustifyItem>(132)
#define ATTR_VER_JUSTIFY_METHOD TypedWhichId<SvxJustifyMethodItem>(133)
#define ATTR_STACKED TypedWhichId<ScShrinkToFitCell>(134)
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 42a0e9fd..e7be9ee 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -1758,7 +1758,7 @@ void ScAttrArray::ChangeIndent( SCROW nStartRow, SCROW nEndRow, bool bIncrement
SCROW nThisEnd = mvData[nIndex].nEndRow;
SCROW nAttrRow = std::min( nThisEnd, nEndRow );
auto pNewPattern = std::make_unique<ScPatternAttr>(*pOldPattern);
pNewPattern->GetItemSet().Put( SfxUInt16Item( ATTR_INDENT, nNewValue ) );
pNewPattern->GetItemSet().Put( ScIndentItem( nNewValue ) );
if ( bNeedJust )
pNewPattern->GetItemSet().Put(
SvxHorJustifyItem( SvxCellHorJustify::Left, ATTR_HOR_JUSTIFY ) );
diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx
index 4ed6188..04a607b 100644
--- a/sc/source/core/data/attrib.cxx
+++ b/sc/source/core/data/attrib.cxx
@@ -23,7 +23,9 @@
#include <editeng/editeng.hxx>
#include <editeng/editobj.hxx>
#include <editeng/eerdll.hxx>
#include <editeng/borderline.hxx>
#include <editeng/itemtype.hxx>
#include <libxml/xmlwriter.h>
@@ -828,4 +830,35 @@ bool ScHyphenateCell::GetPresentation(SfxItemPresentation,
return true;
}
ScIndentItem::ScIndentItem(sal_uInt16 nIndent)
: SfxUInt16Item(ATTR_INDENT, nIndent)
{
}
ScIndentItem* ScIndentItem::Clone(SfxItemPool*) const
{
return new ScIndentItem(GetValue());
}
bool ScIndentItem::GetPresentation(SfxItemPresentation ePres,
MapUnit eCoreUnit, MapUnit,
OUString& rText,
const IntlWrapper& rIntl) const
{
auto nValue = GetValue();
switch (ePres)
{
case SfxItemPresentation::Complete:
rText = ScResId(STR_INDENTCELL);
[[fallthrough]];
case SfxItemPresentation::Nameless:
rText += GetMetricText( nValue, eCoreUnit, MapUnit::MapPoint, &rIntl ) +
" " + EditResId(GetMetricId(MapUnit::MapPoint));
return true;
default: ; //prevent warning
}
return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 6120e71..e64da24 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -242,7 +242,7 @@ long ScColumn::GetNeededSize(
{
if (pCondSet &&
pCondSet->GetItemState(ATTR_INDENT, true, &pCondItem) == SfxItemState::SET)
nIndent = static_cast<const SfxUInt16Item*>(pCondItem)->GetValue();
nIndent = static_cast<const ScIndentItem*>(pCondItem)->GetValue();
else
nIndent = pPattern->GetItem(ATTR_INDENT).GetValue();
}
diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx
index 148438d..d229654 100644
--- a/sc/source/core/data/docpool.cxx
+++ b/sc/source/core/data/docpool.cxx
@@ -246,7 +246,7 @@ ScDocumentPool::ScDocumentPool()
mvPoolDefaults[ ATTR_FORBIDDEN_RULES - ATTR_STARTINDEX ] = new SvxForbiddenRuleItem( false, ATTR_FORBIDDEN_RULES);
mvPoolDefaults[ ATTR_HOR_JUSTIFY - ATTR_STARTINDEX ] = new SvxHorJustifyItem( SvxCellHorJustify::Standard, ATTR_HOR_JUSTIFY);
mvPoolDefaults[ ATTR_HOR_JUSTIFY_METHOD - ATTR_STARTINDEX ] = new SvxJustifyMethodItem( SvxCellJustifyMethod::Auto, ATTR_HOR_JUSTIFY_METHOD);
mvPoolDefaults[ ATTR_INDENT - ATTR_STARTINDEX ] = new SfxUInt16Item( ATTR_INDENT, 0 );
mvPoolDefaults[ ATTR_INDENT - ATTR_STARTINDEX ] = new ScIndentItem( 0 );
mvPoolDefaults[ ATTR_VER_JUSTIFY - ATTR_STARTINDEX ] = new SvxVerJustifyItem( SvxCellVerJustify::Standard, ATTR_VER_JUSTIFY);
mvPoolDefaults[ ATTR_VER_JUSTIFY_METHOD - ATTR_STARTINDEX ] = new SvxJustifyMethodItem( SvxCellJustifyMethod::Auto, ATTR_VER_JUSTIFY_METHOD);
mvPoolDefaults[ ATTR_STACKED - ATTR_STARTINDEX ] = new ScVerticalStackCell(false);
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index 89c5406..3a2cd52 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -822,7 +822,7 @@ void XclImpCellAlign::FillToItemSet( SfxItemSet& rItemSet, const XclImpFont* pFo
// indent
sal_uInt16 nScIndent = mnIndent * 200; // 1 Excel unit == 10 pt == 200 twips
ScfTools::PutItem( rItemSet, SfxUInt16Item( ATTR_INDENT, nScIndent ), bSkipPoolDefs );
ScfTools::PutItem( rItemSet, ScIndentItem( nScIndent ), bSkipPoolDefs );
// shrink to fit
ScfTools::PutItem( rItemSet, ScShrinkToFitCell( mbShrink ), bSkipPoolDefs );
diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx
index f373f0a..009faee 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -1299,7 +1299,7 @@ void Alignment::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
// Orientation
ScfTools::PutItem( rItemSet, ScVerticalStackCell( maApiData.meOrientation == css::table::CellOrientation_STACKED ), bSkipPoolDefs );
// indent
ScfTools::PutItem( rItemSet, SfxUInt16Item( ATTR_INDENT, maApiData.mnIndent ), bSkipPoolDefs );
ScfTools::PutItem( rItemSet, ScIndentItem( maApiData.mnIndent ), bSkipPoolDefs );
// line wrap
ScfTools::PutItem( rItemSet, ScLineBreakCell( maApiData.mbWrapText ), bSkipPoolDefs );
ScfTools::PutItem( rItemSet, ScShrinkToFitCell( maApiData.mbShrink ), bSkipPoolDefs );
diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx
index e0a7b72..60c4928 100644
--- a/sc/source/ui/Accessibility/AccessibleText.cxx
+++ b/sc/source/ui/Accessibility/AccessibleText.cxx
@@ -500,7 +500,7 @@ SvxTextForwarder* ScAccessibleCellTextData::GetTextForwarder()
SvxCellHorJustify eHorJust = pHorJustifyItem ? pHorJustifyItem->GetValue() : SvxCellHorJustify::Standard;
if ( eHorJust == SvxCellHorJustify::Left )
{
const SfxUInt16Item* pIndentItem = rDoc.GetAttr( aCellPos, ATTR_INDENT );
const ScIndentItem* pIndentItem = rDoc.GetAttr( aCellPos, ATTR_INDENT );
if ( pIndentItem )
{
nIndent = static_cast< long >( pIndentItem->GetValue() );
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index a5ffd15..f65b7fcf 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1959,7 +1959,7 @@ uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const OUString& aPropert
aAny <<= static_cast<sal_Int32>( static_cast<const SfxUInt32Item&>(rSet.Get(pEntry->nWID)).GetValue() );
break;
case ATTR_INDENT:
aAny <<= static_cast<sal_Int16>( TwipsToHMM(static_cast<const SfxUInt16Item&>(
aAny <<= static_cast<sal_Int16>( TwipsToHMM(static_cast<const ScIndentItem&>(
rSet.Get(pEntry->nWID)).GetValue()) );
break;
default:
@@ -2097,7 +2097,7 @@ static void lcl_SetCellProperty( const SfxItemPropertySimpleEntry& rEntry, const
if ( !(rValue >>= nIntVal) )
throw lang::IllegalArgumentException();
rSet.Put( SfxUInt16Item( rEntry.nWID, static_cast<sal_uInt16>(HMMToTwips(nIntVal)) ) );
rSet.Put( ScIndentItem( static_cast<sal_uInt16>(HMMToTwips(nIntVal)) ) );
}
break;
@@ -2409,7 +2409,7 @@ void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pE
}
break;
case ATTR_INDENT:
rAny <<= static_cast<sal_Int16>( TwipsToHMM(static_cast<const SfxUInt16Item&>(
rAny <<= static_cast<sal_Int16>( TwipsToHMM(static_cast<const ScIndentItem&>(
pDataSet->Get(pEntry->nWID)).GetValue()) );
break;
case ATTR_STACKED:
diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx
index 37af7b7..aed15b3 100644
--- a/sc/source/ui/unoobj/styleuno.cxx
+++ b/sc/source/ui/unoobj/styleuno.cxx
@@ -1238,7 +1238,7 @@ uno::Any ScStyleObj::getPropertyDefault_Impl( const OUString& aPropertyName )
aAny <<= sal_Int32( static_cast<const SfxUInt32Item&>(pItemSet->Get(nWhich)).GetValue() );
break;
case ATTR_INDENT:
aAny <<= sal_Int16( TwipsToHMM(static_cast<const SfxUInt16Item&>(
aAny <<= sal_Int16( TwipsToHMM(static_cast<const ScIndentItem&>(
pItemSet->Get(nWhich)).GetValue()) );
break;
case ATTR_PAGE_SCALE:
@@ -1520,8 +1520,7 @@ void ScStyleObj::setPropertyValue_Impl( const OUString& rPropertyName, const Sfx
{
sal_Int16 nVal = 0;
*pValue >>= nVal;
rSet.Put(SfxUInt16Item(pEntry->nWID,
static_cast<sal_uInt16>(HMMToTwips(nVal))));
rSet.Put(ScIndentItem(static_cast<sal_uInt16>(HMMToTwips(nVal))));
}
break;
case ATTR_ROTATE_VALUE:
@@ -1789,7 +1788,7 @@ uno::Any ScStyleObj::getPropertyValue_Impl( const OUString& aPropertyName )
}
break;
case ATTR_INDENT:
aAny <<= sal_Int16( TwipsToHMM(static_cast<const SfxUInt16Item&>(
aAny <<= sal_Int16( TwipsToHMM(static_cast<const ScIndentItem&>(
pItemSet->Get(nWhich)).GetValue()) );
break;
case ATTR_STACKED:
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 8a057dcf..947bda3 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -2447,7 +2447,7 @@ void ScOutputData::DrawEditParam::calcMargins(long& rTopM, long& rLeftM, long& r
sal_uInt16 nIndent = 0;
if (meHorJustAttr == SvxCellHorJustify::Left || meHorJustAttr == SvxCellHorJustify::Right)
nIndent = lcl_GetValue<SfxUInt16Item, sal_uInt16>(*mpPattern, ATTR_INDENT, mpCondSet);
nIndent = lcl_GetValue<ScIndentItem, sal_uInt16>(*mpPattern, ATTR_INDENT, mpCondSet);
rLeftM = static_cast<long>(((rMargin.GetLeftMargin() + nIndent) * nPPTX));
rTopM = static_cast<long>((rMargin.GetTopMargin() * nPPTY));
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 344a43a..1dbb1c1 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1015,7 +1015,7 @@ void ScViewFunc::ApplyAttr( const SfxPoolItem& rAttrItem, bool bAdjustBlockHeigh
aNewAttrs.GetItemSet().Put( rAttrItem );
// if justify is set (with Buttons), always indentation 0
if ( rAttrItem.Which() == ATTR_HOR_JUSTIFY )
aNewAttrs.GetItemSet().Put( SfxUInt16Item( ATTR_INDENT, 0 ) );
aNewAttrs.GetItemSet().Put( ScIndentItem( 0 ) );
ApplySelectionPattern( aNewAttrs );
// Prevent useless compute