editeng/source/editeng/editdoc.cxx | 11 +++++ editeng/source/items/paraitem.cxx | 32 ++++++++++++++++ include/editeng/memberids.h | 1 include/editeng/tstpitem.hxx | 3 + include/editeng/unoprnms.hxx | 1 include/editeng/unotext.hxx | 1 oox/inc/drawingml/textparagraphproperties.hxx | 2 + oox/source/drawingml/textparagraphproperties.cxx | 7 +++ oox/source/drawingml/textparagraphpropertiescontext.cxx | 12 ++++-- oox/source/token/properties.txt | 1 sd/qa/unit/import-tests2.cxx | 4 +- 11 files changed, 69 insertions(+), 6 deletions(-)
New commits: commit e4952bbf58edeb6f385d4003f370955994426a9f Author: Sarper Akdemir <[email protected]> AuthorDate: Tue Feb 28 16:36:40 2023 +0300 Commit: Sarper Akdemir <[email protected]> CommitDate: Tue Mar 28 14:53:32 2023 +0000 tdf#102261: pptx import: handle defTabSz Introduce import of defTabSz using ParaTabStopDefaultDistance. Change-Id: Ied59c2bc5d9dfffa6254ef87849c3dbad4c48d07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148059 Tested-by: Jenkins Reviewed-by: Miklos Vajna <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149511 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Sarper Akdemir <[email protected]> diff --git a/oox/inc/drawingml/textparagraphproperties.hxx b/oox/inc/drawingml/textparagraphproperties.hxx index 083b61e37da7..d3742e7377e0 100644 --- a/oox/inc/drawingml/textparagraphproperties.hxx +++ b/oox/inc/drawingml/textparagraphproperties.hxx @@ -89,6 +89,7 @@ public: TextSpacing& getParaBottomMargin() { return maParaBottomMargin; } std::optional< sal_Int32 >& getParaLeftMargin(){ return moParaLeftMargin; } std::optional< sal_Int32 >& getFirstLineIndentation(){ return moFirstLineIndentation; } + std::optional<sal_Int32>& getDefaultTabSize() { return moDefaultTabSize; } std::optional< css::style::ParagraphAdjust >& getParaAdjust() { return moParaAdjust; } void setParaAdjust( css::style::ParagraphAdjust nParaAdjust ) { moParaAdjust = nParaAdjust; } @@ -125,6 +126,7 @@ private: std::optional< sal_Int32 > moParaLeftMargin; std::optional< sal_Int32 > moFirstLineIndentation; std::optional< css::style::ParagraphAdjust > moParaAdjust; + std::optional< sal_Int32 > moDefaultTabSize; sal_Int16 mnLevel; TextSpacing maLineSpacing; }; diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx index 0006b7530a76..af65e0037d16 100644 --- a/oox/source/drawingml/textparagraphproperties.cxx +++ b/oox/source/drawingml/textparagraphproperties.cxx @@ -395,6 +395,8 @@ void TextParagraphProperties::apply( const TextParagraphProperties& rSourceProps moParaLeftMargin = rSourceProps.moParaLeftMargin; if ( rSourceProps.moFirstLineIndentation ) moFirstLineIndentation = rSourceProps.moFirstLineIndentation; + if ( rSourceProps.moDefaultTabSize ) + moDefaultTabSize = rSourceProps.moDefaultTabSize; if( rSourceProps.mnLevel ) mnLevel = rSourceProps.mnLevel; if( rSourceProps.moParaAdjust ) @@ -501,6 +503,11 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* p } } + if ( moDefaultTabSize ) + { + aPropSet.setProperty( PROP_ParaTabStopDefaultDistance, *moDefaultTabSize ); + } + if ( moParaAdjust ) { aPropSet.setProperty( PROP_ParaAdjust, *moParaAdjust); diff --git a/oox/source/drawingml/textparagraphpropertiescontext.cxx b/oox/source/drawingml/textparagraphpropertiescontext.cxx index 4e83d2ece24b..e75d65913cd9 100644 --- a/oox/source/drawingml/textparagraphpropertiescontext.cxx +++ b/oox/source/drawingml/textparagraphpropertiescontext.cxx @@ -93,10 +93,14 @@ TextParagraphPropertiesContext::TextParagraphPropertiesContext( ContextHandler2H // TODO see to do the same with RubyAdjust // ST_Coordinate32 -// sValue = rAttribs.getString( XML_defTabSz ).get(); SJ: we need to be able to set the default tab size for each text object, -// this is possible at the moment only for the whole document. -// sal_Int32 nDefTabSize = ( sValue.getLength() == 0 ? 0 : GetCoordinate( sValue ) ); - // TODO + if ( rAttribs.hasAttribute(XML_defTabSz)) + { + sValue = rAttribs.getStringDefaulted(XML_defTabSz); + if(!sValue.isEmpty()) + { + mrTextParagraphProperties.getDefaultTabSize() = GetCoordinate(sValue); + } + } // bool bEaLineBrk = rAttribs.getBool( XML_eaLnBrk, true ); if ( rAttribs.hasAttribute( XML_latinLnBrk ) ) diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 43bed81c5d62..edf799c2c8df 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -385,6 +385,7 @@ ParaLeftMargin ParaLineSpacing ParaRightMargin ParaTabStops +ParaTabStopDefaultDistance ParaTopMargin Path PercentageNumberFormat diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx index 5d5864a2891e..4467c5f81381 100644 --- a/sd/qa/unit/import-tests2.cxx +++ b/sd/qa/unit/import-tests2.cxx @@ -1500,8 +1500,8 @@ void SdImportTest2::testTdf120028() double fCharHeight = 0; xPropSet->getPropertyValue("CharHeight") >>= fCharHeight; CPPUNIT_ASSERT_DOUBLES_EQUAL(13.5, fCharHeight, 1E-12); - // 13.5 * 87% is approx. 11.7 (the correct scaled font size) - CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(87)), xShape->getPropertyValue("TextFitToSizeScale")); + // 13.5 * 90% is approx. 12.1 (the correct scaled font size) + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(90)), xShape->getPropertyValue("TextFitToSizeScale")); } void SdImportTest2::testDescriptionImport() commit a549be6d42656cb92c5934c1438ab924c0c71573 Author: Sarper Akdemir <[email protected]> AuthorDate: Tue Feb 28 16:13:48 2023 +0300 Commit: Sarper Akdemir <[email protected]> CommitDate: Tue Mar 28 14:53:20 2023 +0000 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 <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149510 Tested-by: Sarper Akdemir <[email protected]> Reviewed-by: Sarper Akdemir <[email protected]> diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 1fbf46de184b..9fff222d9368 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -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; 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); diff --git a/include/editeng/memberids.h b/include/editeng/memberids.h index 0b110cb52c5d..f3677799390c 100644 --- a/include/editeng/memberids.h +++ b/include/editeng/memberids.h @@ -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 diff --git a/include/editeng/tstpitem.hxx b/include/editeng/tstpitem.hxx index b5aab04bc92d..4c015d6677ec 100644 --- a/include/editeng/tstpitem.hxx +++ b/include/editeng/tstpitem.hxx @@ -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(); } diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx index 300a0a2b7765..a321e54e5a73 100644 --- a/include/editeng/unoprnms.hxx +++ b/include/editeng/unoprnms.hxx @@ -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"; diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx index dec8c4cc50a5..5231219b5a1a 100644 --- a/include/editeng/unotext.hxx +++ b/include/editeng/unotext.hxx @@ -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 }, \
