summaryrefslogtreecommitdiff
path: root/editeng/source/items/paraitem.cxx
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir@collabora.com>2023-02-28 16:13:48 +0300
committerMiklos Vajna <vmiklos@collabora.com>2023-03-16 11:20:48 +0000
commitcced51a1ed7c140276aabfe857510afb974fcef5 (patch)
treee0721ef743caec53daeb3a0d116c6ccb9a00c8fa /editeng/source/items/paraitem.cxx
parent910226f2916b271a496daa6920843bf8d82238a6 (diff)
tdf#102261: introduce editeng paragraph tab stop default distance
Adds mnDefaultDistance to SvxTabStopItem that if defined will set a paragraph wide tab stop default distance and override the document wide setting. Also makes editeng consider mnDefaultDistance while getting tab stop default distance. Change-Id: I0fa098f874d6b9c91ddbaa2634224ff55cafcc95 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148058 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'editeng/source/items/paraitem.cxx')
-rw-r--r--editeng/source/items/paraitem.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/editeng/source/items/paraitem.cxx b/editeng/source/items/paraitem.cxx
index 9368dfdf3c2a..f67ddf599b06 100644
--- a/editeng/source/items/paraitem.cxx
+++ b/editeng/source/items/paraitem.cxx
@@ -821,6 +821,15 @@ sal_uInt16 SvxTabStopItem::GetPos( const sal_Int32 nPos ) const
return it != maTabStops.end() ? it - maTabStops.begin() : SVX_TAB_NOTFOUND;
}
+void SvxTabStopItem::SetDefaultDistance(sal_Int32 nDefaultDistance)
+{
+ mnDefaultDistance = nDefaultDistance;
+}
+
+sal_Int32 SvxTabStopItem::GetDefaultDistance() const
+{
+ return mnDefaultDistance;
+}
bool SvxTabStopItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
{
@@ -859,6 +868,11 @@ bool SvxTabStopItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(rTab.GetTabPos()) : rTab.GetTabPos());
break;
}
+ case MID_TABSTOP_DEFAULT_DISTANCE:
+ {
+ rVal <<= static_cast<sal_Int32>(bConvert ? convertTwipToMm100(mnDefaultDistance) : mnDefaultDistance);
+ break;
+ }
}
return true;
}
@@ -956,6 +970,18 @@ bool SvxTabStopItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
Insert( aNewTab );
break;
}
+ case MID_TABSTOP_DEFAULT_DISTANCE:
+ {
+ sal_Int32 nNewDefaultDistance = 0;
+ if (!(rVal >>= nNewDefaultDistance))
+ return false;
+ if (bConvert)
+ nNewDefaultDistance = o3tl::toTwips(nNewDefaultDistance, o3tl::Length::mm100);
+ if (nNewDefaultDistance <= 0)
+ return false;
+ mnDefaultDistance = nNewDefaultDistance;
+ break;
+ }
}
return true;
}
@@ -967,6 +993,9 @@ bool SvxTabStopItem::operator==( const SfxPoolItem& rAttr ) const
const SvxTabStopItem& rTSI = static_cast<const SvxTabStopItem&>(rAttr);
+ if ( mnDefaultDistance != rTSI.GetDefaultDistance() )
+ return false;
+
if ( Count() != rTSI.Count() )
return false;
@@ -990,6 +1019,7 @@ bool SvxTabStopItem::GetPresentation
) const
{
rText.clear();
+ // TODO also consider mnDefaultTabDistance here
bool bComma = false;
@@ -1038,6 +1068,8 @@ void SvxTabStopItem::Insert( const SvxTabStopItem* pTabs )
void SvxTabStopItem::dumpAsXml(xmlTextWriterPtr pWriter) const
{
(void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxTabStopItem"));
+ (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("mnDefaultDistance"),
+ BAD_CAST(OString::number(mnDefaultDistance).getStr()));
for (const auto& rTabStop : maTabStops)
rTabStop.dumpAsXml(pWriter);
(void)xmlTextWriterEndElement(pWriter);