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>
This commit is contained in:
Sarper Akdemir
2023-02-28 16:13:48 +03:00
committed by Miklos Vajna
parent 910226f291
commit cced51a1ed
6 changed files with 49 additions and 0 deletions

View File

@@ -857,6 +857,13 @@ void ConvertItem( std::unique_ptr<SfxPoolItem>& rPoolItem, MapUnit eSourceUnit,
assert(dynamic_cast<const SvxTabStopItem *>(rPoolItem.get()) != nullptr);
SvxTabStopItem& rItem = static_cast<SvxTabStopItem&>(*rPoolItem);
SvxTabStopItem* pNewItem(new SvxTabStopItem(EE_PARA_TABS));
if (sal_Int32 nDefTabDistance = rItem.GetDefaultDistance())
{
pNewItem->SetDefaultDistance(
OutputDevice::LogicToLogic(nDefTabDistance, eSourceUnit, eDestUnit));
}
for ( sal_uInt16 i = 0; i < rItem.Count(); i++ )
{
const SvxTabStop& rTab = rItem[i];
@@ -1821,6 +1828,10 @@ SvxTabStop ContentAttribs::FindTabStop( sal_Int32 nCurPos, sal_uInt16 nDefTab )
return rTab;
}
// if there's a default tab size defined for this item use that instead
if (rTabs.GetDefaultDistance())
nDefTab = rTabs.GetDefaultDistance();
// Determine DefTab ...
SvxTabStop aTabStop;
const sal_Int32 x = nCurPos / nDefTab + 1;

View File

@@ -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);

View File

@@ -40,6 +40,7 @@
// SvxTabStop
#define MID_TABSTOPS 0
#define MID_STD_TAB 1
#define MID_TABSTOP_DEFAULT_DISTANCE 2
//SvxHyphenZoneItem
#define MID_IS_HYPHEN 0

View File

@@ -92,6 +92,7 @@ typedef o3tl::sorted_vector<SvxTabStop> SvxTabStopArr;
class EDITENG_DLLPUBLIC SvxTabStopItem final : public SfxPoolItem
{
SvxTabStopArr maTabStops;
sal_Int32 mnDefaultDistance = 0;
public:
static SfxPoolItem* CreateDefault();
@@ -107,6 +108,8 @@ public:
// Returns index of the tab at nPos, or TAB_NOTFOUND
sal_uInt16 GetPos( const sal_Int32 nPos ) const;
void SetDefaultDistance(sal_Int32 nDefaultDistancenDefTabSize);
sal_Int32 GetDefaultDistance() const;
// unprivatized:
sal_uInt16 Count() const { return maTabStops.size(); }

View File

@@ -295,6 +295,7 @@ inline constexpr OUStringLiteral UNO_NAME_EDIT_PARA_LMARGIN = u"ParaLeftMargin";
inline constexpr OUStringLiteral UNO_NAME_EDIT_PARA_LINESPACING = u"ParaLineSpacing";
inline constexpr OUStringLiteral UNO_NAME_EDIT_PARA_RMARGIN = u"ParaRightMargin";
inline constexpr OUStringLiteral UNO_NAME_EDIT_PARA_TAPSTOPS = u"ParaTabStops";
inline constexpr OUStringLiteral UNO_NAME_EDIT_PARA_TABSTOP_DEFAULT_DISTANCE = u"ParaTabStopDefaultDistance";
inline constexpr OUStringLiteral UNO_NAME_EDIT_PARA_TMARGIN = u"ParaTopMargin";
inline constexpr OUStringLiteral UNO_NAME_EDIT_PARA_IS_HYPHEN = u"ParaIsHyphenation";
inline constexpr OUStringLiteral UNO_NAME_EDIT_PARA_IS_HANGING_PUNCTUATION = u"ParaIsHangingPunctuation";

View File

@@ -147,6 +147,7 @@ struct SfxItemPropertyMapEntry;
{ UNO_NAME_EDIT_PARA_LINESPACING, EE_PARA_SBL, cppu::UnoType<css::style::LineSpacing>::get(), 0, CONVERT_TWIPS}, \
{ UNO_NAME_EDIT_PARA_RMARGIN, EE_PARA_LRSPACE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_R_MARGIN, PropertyMoreFlags::METRIC_ITEM }, \
{ UNO_NAME_EDIT_PARA_TAPSTOPS, EE_PARA_TABS, cppu::UnoType<css::uno::Sequence< css::style::TabStop >>::get(), 0, 0 }, \
{ UNO_NAME_EDIT_PARA_TABSTOP_DEFAULT_DISTANCE, EE_PARA_TABS, ::cppu::UnoType<sal_Int32>::get(), 0, MID_TABSTOP_DEFAULT_DISTANCE }, \
{ UNO_NAME_EDIT_PARA_TMARGIN, EE_PARA_ULSPACE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_UP_MARGIN, PropertyMoreFlags::METRIC_ITEM },\
{ UNO_NAME_EDIT_PARA_FIRST_LINE_INDENT, EE_PARA_LRSPACE, ::cppu::UnoType<sal_Int32>::get(), 0, MID_FIRST_LINE_INDENT, PropertyMoreFlags::METRIC_ITEM}, \
{ UNO_NAME_EDIT_PARA_IS_HANGING_PUNCTUATION,EE_PARA_HANGINGPUNCTUATION, cppu::UnoType<bool>::get(), 0 ,0 }, \