From 44ebc73272f1b77ec067d3b90f5343c144886616c2c701ac00c373f1d1610b55 Mon Sep 17 00:00:00 2001 From: Danilo Spinella Date: Mon, 29 May 2023 14:43:54 +0000 Subject: [PATCH] Accepting request 1089480 from LibreOffice:7.5 - Fix bsc#1204040 - LO-L3: PPTX: shadow effect for table offset too far to the right * bsc1204040.patch - Fix bsc#1198666 - LO-L3: Need to be able to set the default tab size for each text object * bsc1198666.patch OBS-URL: https://build.opensuse.org/request/show/1089480 OBS-URL: https://build.opensuse.org/package/show/LibreOffice:Factory/libreoffice?expand=0&rev=1078 --- bsc1198666.patch | 520 ++++++++++++++++++++++++++++++++ bsc1204040.patch | 711 ++++++++++++++++++++++++++++++++++++++++++++ libreoffice.changes | 8 + libreoffice.spec | 6 + 4 files changed, 1245 insertions(+) create mode 100644 bsc1198666.patch create mode 100644 bsc1204040.patch diff --git a/bsc1198666.patch b/bsc1198666.patch new file mode 100644 index 0000000..5416a59 --- /dev/null +++ b/bsc1198666.patch @@ -0,0 +1,520 @@ +From 8da40c7a3c9680adb4ab0209384808545146b8e0 Mon Sep 17 00:00:00 2001 +From: Sarper Akdemir +Date: Tue, 28 Feb 2023 16:13:48 +0300 +Subject: [PATCH] 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 + +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 + +tdf#102261: pptx export: implement defTabSz ParaTabStopDefaultDistance + +Adds export of ParaTabStopDefaultDistance property into defTabSz. + +Also adds a unit test that checks pptx roundtrip of the property. + +Change-Id: I5be9ea88b15e3e8cab25af79488983a71b96dae1 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148539 +Tested-by: Jenkins +Reviewed-by: Miklos Vajna + +related tdf#102261: consider ParaTabStopDefaultDistance in SvxRuler + +If there's a paragraph scoped tab default distance defined, +use that as the default tab distance in the SvxRuler instead +of the document wide setting. + +Change-Id: I9b0e7d0db0b25aee08bd27948b2e462b4a4ee496 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148060 +Tested-by: Jenkins +Reviewed-by: Sarper Akdemir + +related tdf#102261: xmloff: ODF import/export for ParaTabStopDefaultDistance + +Introduces ODF import/export for ParaTabStopDefaultDistance +(loext:tab-stop-distance). + +Also adds a unit test that covers import & export of the +property. + +Change-Id: I8a69a9e2b73e8f1172f92dc35fada901f4b887f4 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148540 +Tested-by: Jenkins +Reviewed-by: Miklos Vajna +--- + 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 + + .../drawingml/textparagraphproperties.cxx | 7 +++ + .../textparagraphpropertiescontext.cxx | 12 +++-- + oox/source/export/drawingml.cxx | 6 +++ + oox/source/token/properties.txt | 1 + + .../OpenDocument-v1.3+libreoffice-schema.rng | 6 +++ + ...102261_testParaTabStopDefaultDistance.pptx | Bin 0 -> 32892 bytes + sd/qa/unit/export-tests-ooxml3.cxx | 24 ++++++++++ + sd/qa/unit/import-tests2.cxx | 4 +- + svx/source/dialog/svxruler.cxx | 9 ++-- + xmloff/inc/xmlprop.hxx | 1 + + .../data/paragraph-tab-stop-distance.fodp | 19 ++++++++ + xmloff/qa/unit/text.cxx | 41 ++++++++++++++++++ + xmloff/source/text/txtprmap.cxx | 2 + + 20 files changed, 174 insertions(+), 9 deletions(-) + create mode 100644 sd/qa/unit/data/pptx/tdf102261_testParaTabStopDefaultDistance.pptx + create mode 100644 xmloff/qa/unit/data/paragraph-tab-stop-distance.fodp + +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& rPoolItem, MapUnit eSourceUnit, + assert(dynamic_cast(rPoolItem.get()) != nullptr); + SvxTabStopItem& rItem = static_cast(*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(bConvert ? convertTwipToMm100(rTab.GetTabPos()) : rTab.GetTabPos()); + break; + } ++ case MID_TABSTOP_DEFAULT_DISTANCE: ++ { ++ rVal <<= static_cast(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(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 9b89ebafaefb..ca3be460c566 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 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 7a95ba989b86..f8239b470404 100644 +--- a/include/editeng/unoprnms.hxx ++++ b/include/editeng/unoprnms.hxx +@@ -291,6 +291,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 1d6743a0e410..d76305df24bd 100644 +--- a/include/editeng/unotext.hxx ++++ b/include/editeng/unotext.hxx +@@ -146,6 +146,7 @@ struct SfxItemPropertyMapEntry; + { UNO_NAME_EDIT_PARA_LINESPACING, EE_PARA_SBL, cppu::UnoType::get(), 0, CONVERT_TWIPS}, \ + { UNO_NAME_EDIT_PARA_RMARGIN, EE_PARA_LRSPACE, ::cppu::UnoType::get(), 0, MID_R_MARGIN, PropertyMoreFlags::METRIC_ITEM }, \ + { UNO_NAME_EDIT_PARA_TAPSTOPS, EE_PARA_TABS, cppu::UnoType>::get(), 0, 0 }, \ ++ { UNO_NAME_EDIT_PARA_TABSTOP_DEFAULT_DISTANCE, EE_PARA_TABS, ::cppu::UnoType::get(), 0, MID_TABSTOP_DEFAULT_DISTANCE }, \ + { UNO_NAME_EDIT_PARA_TMARGIN, EE_PARA_ULSPACE, ::cppu::UnoType::get(), 0, MID_UP_MARGIN, PropertyMoreFlags::METRIC_ITEM },\ + { UNO_NAME_EDIT_PARA_FIRST_LINE_INDENT, EE_PARA_LRSPACE, ::cppu::UnoType::get(), 0, MID_FIRST_LINE_INDENT, PropertyMoreFlags::METRIC_ITEM}, \ + { UNO_NAME_EDIT_PARA_IS_HANGING_PUNCTUATION,EE_PARA_HANGINGPUNCTUATION, cppu::UnoType::get(), 0 ,0 }, \ +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& 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/export/drawingml.cxx b/oox/source/export/drawingml.cxx +index f39951ade707..cd94896503a9 100644 +--- a/oox/source/export/drawingml.cxx ++++ b/oox/source/export/drawingml.cxx +@@ -3233,6 +3233,10 @@ bool DrawingML::WriteParagraphProperties(const Reference& rParagra + return false; + } + ++ sal_Int32 nParaDefaultTabSize = 0; ++ if (GetProperty(rXPropSet, "ParaTabStopDefaultDistance")) ++ mAny >>= nParaDefaultTabSize; ++ + // for autofitted textboxes, scale the indents + if (GetProperty(rXShapePropSet, "TextFitToSize") && mAny.get() == TextFitToSizeType_AUTOFIT) + { +@@ -3257,6 +3261,7 @@ bool DrawingML::WriteParagraphProperties(const Reference& rParagra + XML_marL, sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nParaLeftMargin)), nParaLeftMargin > 0), + XML_indent, sax_fastparser::UseIf(OString::number(!bForceZeroIndent ? oox::drawingml::convertHmmToEmu(nParaFirstLineIndent) : 0), (bForceZeroIndent || (nParaFirstLineIndent != 0))), + XML_algn, GetAlignment( nAlignment ), ++ XML_defTabSz, sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nParaDefaultTabSize)), nParaDefaultTabSize > 0), + XML_rtl, sax_fastparser::UseIf(ToPsz10(bRtl), bRtl)); + else + mpFS->startElementNS( XML_a, nElement, +@@ -3264,6 +3269,7 @@ bool DrawingML::WriteParagraphProperties(const Reference& rParagra + XML_marL, sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nLeftMargin)), nLeftMargin > 0), + XML_indent, sax_fastparser::UseIf(OString::number(!bForceZeroIndent ? oox::drawingml::convertHmmToEmu(nLineIndentation) : 0), (bForceZeroIndent || ( nLineIndentation != 0))), + XML_algn, GetAlignment( nAlignment ), ++ XML_defTabSz, sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nParaDefaultTabSize)), nParaDefaultTabSize > 0), + XML_rtl, sax_fastparser::UseIf(ToPsz10(bRtl), bRtl)); + + +diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt +index 60b5c375c033..2394ca94300b 100644 +--- a/oox/source/token/properties.txt ++++ b/oox/source/token/properties.txt +@@ -382,6 +382,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() +diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx +index be53a0c91c58..671afa9f6737 100644 +--- a/svx/source/dialog/svxruler.cxx ++++ b/svx/source/dialog/svxruler.cxx +@@ -1027,7 +1027,10 @@ void SvxRuler::UpdateTabs() + const tools::Long lPosPixel = ConvertHPosPixel(lParaIndent) + lLastTab; + const tools::Long lRightIndent = ConvertHPosPixel(nRightFrameMargin - mxParaItem->GetRight()); + +- tools::Long nDefTabDist = ConvertHPosPixel(lDefTabDist); ++ tools::Long lCurrentDefTabDist = lDefTabDist; ++ if(mxTabStopItem->GetDefaultDistance()) ++ lCurrentDefTabDist = mxTabStopItem->GetDefaultDistance(); ++ tools::Long nDefTabDist = ConvertHPosPixel(lCurrentDefTabDist); + + const sal_uInt16 nDefTabBuf = lPosPixel > lRightIndent || lLastTab > lRightIndent + ? 0 +@@ -1063,13 +1066,13 @@ void SvxRuler::UpdateTabs() + } + + // Adjust to previous-to-first default tab stop +- lLastTabOffsetLogic -= lLastTabOffsetLogic % lDefTabDist; ++ lLastTabOffsetLogic -= lLastTabOffsetLogic % lCurrentDefTabDist; + + // fill the rest with default Tabs + for (j = 0; j < nDefTabBuf; ++j) + { + //simply add the default distance to the last position +- lLastTabOffsetLogic += lDefTabDist; ++ lLastTabOffsetLogic += lCurrentDefTabDist; + if (bRTL) + { + mpTabs[nTabCount + TAB_GAP].nPos = +diff --git a/xmloff/inc/xmlprop.hxx b/xmloff/inc/xmlprop.hxx +index 868f619a7246..2326bcf2f34d 100644 +--- a/xmloff/inc/xmlprop.hxx ++++ b/xmloff/inc/xmlprop.hxx +@@ -518,6 +518,7 @@ inline constexpr OUStringLiteral PROP_ParaRightMarginRelative = u"ParaRightMargi + inline constexpr OUStringLiteral PROP_ParaShadowFormat = u"ParaShadowFormat"; + inline constexpr OUStringLiteral PROP_ParaSplit = u"ParaSplit"; + inline constexpr OUStringLiteral PROP_ParaTabStops = u"ParaTabStops"; ++inline constexpr OUStringLiteral PROP_ParaTabStopDefaultDistance = u"ParaTabStopDefaultDistance"; + inline constexpr OUStringLiteral PROP_ParaTopMargin = u"ParaTopMargin"; + inline constexpr OUStringLiteral PROP_ParaTopMarginRelative = u"ParaTopMarginRelative"; + inline constexpr OUStringLiteral PROP_ParaUserDefinedAttributes = u"ParaUserDefinedAttributes"; +diff --git a/xmloff/qa/unit/data/paragraph-tab-stop-distance.fodp b/xmloff/qa/unit/data/paragraph-tab-stop-distance.fodp +new file mode 100644 +index 000000000000..f51e75b79699 +--- /dev/null ++++ b/xmloff/qa/unit/data/paragraph-tab-stop-distance.fodp +@@ -0,0 +1,19 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ starttab1tab2tab4 ++ ++ ++ ++ ++ ++ +diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx +index 9c30c2f81dee..62ffe78fa570 100644 +--- a/xmloff/qa/unit/text.cxx ++++ b/xmloff/qa/unit/text.cxx +@@ -16,6 +16,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -892,6 +893,46 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testScaleWidthRedline) + assertXPath(pXmlDoc, "//draw:frame[@draw:name='Image45']", "width", "6.1728in"); + } + ++CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testParagraphScopedTabDistance) ++{ ++ // Given a document with paragraph scoped default tab stop distance (loext:tab-stop-distance="0.5cm") ++ loadFromURL(u"paragraph-tab-stop-distance.fodp"); ++ ++ uno::Reference xDoc(mxComponent, uno::UNO_QUERY); ++ uno::Reference xPage(xDoc->getDrawPages()->getByIndex(0), ++ uno::UNO_QUERY_THROW); ++ ++ uno::Reference xShape(xPage->getByIndex(0), uno::UNO_QUERY); ++ uno::Reference xText ++ = uno::Reference(xShape, uno::UNO_QUERY_THROW)->getText(); ++ ++ uno::Reference paraEnumAccess(xText, uno::UNO_QUERY); ++ uno::Reference paraEnum(paraEnumAccess->createEnumeration()); ++ uno::Reference xParagraph(paraEnum->nextElement(), uno::UNO_QUERY_THROW); ++ ++ uno::Reference runEnumAccess(xParagraph, uno::UNO_QUERY); ++ uno::Reference runEnum = runEnumAccess->createEnumeration(); ++ uno::Reference xRun(runEnum->nextElement(), uno::UNO_QUERY); ++ uno::Reference xPropSet(xRun, uno::UNO_QUERY_THROW); ++ ++ // Make sure the tab stop default distance is imported correctly ++ // Without the accompanying fix in place, this test would have failed with: ++ // - Expected: 10000 ++ // - Actual : 0 ++ CPPUNIT_ASSERT_EQUAL(static_cast(10000), ++ xPropSet->getPropertyValue("ParaTabStopDefaultDistance").get()); ++ ++ // Save the imported file to test the export too ++ save("impress8"); ++ ++ // Then make sure we write the tab-stop-distance ++ xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); ++ assertXPath(pXmlDoc, "//style:style[@style:name='P1']/style:paragraph-properties", ++ "tab-stop-distance", "10cm"); ++ ++ assertXPath(pXmlDoc, "//text:p[@text:style-name='P1']"); ++} ++ + CPPUNIT_PLUGIN_IMPLEMENT(); + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx +index b961a2c60944..d259bf4aa55d 100644 +--- a/xmloff/source/text/txtprmap.cxx ++++ b/xmloff/source/text/txtprmap.cxx +@@ -448,6 +448,8 @@ XMLPropertyMapEntry const aXMLParaPropMap[] = + MP_ED( PROP_ParaIsHangingPunctuation, STYLE, PUNCTUATION_WRAP, XML_TYPE_TEXT_PUNCTUATION_WRAP, 0 ), + MP_ED( PROP_ParaIsForbiddenRules, STYLE, LINE_BREAK, XML_TYPE_TEXT_LINE_BREAK, 0 ), + MP_E( PROP_TabStopDistance, STYLE, TAB_STOP_DISTANCE, XML_TYPE_MEASURE, 0 ), ++ MAP_EXT_I( PROP_ParaTabStopDefaultDistance, XML_NAMESPACE_STYLE, XML_TAB_STOP_DISTANCE, XML_TYPE_MEASURE|XML_TYPE_PROP_PARAGRAPH, 0 ), ++ MAP_EXT( PROP_ParaTabStopDefaultDistance, XML_NAMESPACE_LO_EXT, XML_TAB_STOP_DISTANCE, XML_TYPE_MEASURE|XML_TYPE_PROP_PARAGRAPH, 0 ), + + // RES_PARATR_VERTALIGN + MP_E( PROP_ParaVertAlignment, STYLE, VERTICAL_ALIGN, XML_TYPE_TEXT_VERTICAL_ALIGN, 0 ), +-- +2.35.3 + diff --git a/bsc1204040.patch b/bsc1204040.patch new file mode 100644 index 0000000..7c0a4f9 --- /dev/null +++ b/bsc1204040.patch @@ -0,0 +1,711 @@ +From 42573f7f27efd6153d396d6907486cda0af7d57a Mon Sep 17 00:00:00 2001 +From: Sarper Akdemir +Date: Wed, 15 Mar 2023 19:25:03 +0300 +Subject: [PATCH] tdf#150020 pptx import: handle algn for outerShdw + +Introduces RectangleAlignmentItem that holds a value of the enum +model::RectangleAlignment. + +Introduces SDRATTR_SHADOWALIGNMENT that holds alignment for a shadow. + +Implements import of algn for outerShdw. + +Makes the alignment considered while the shadow is being scaled. +Also adds a unit test that covers this. + +Cherry picks relevant model::RectangleAlignment bits of FormatScheme.hxx +from (0ffa50031eb33500a3530ece76ea32d15864f345 and 2a7ab2ab7786ab88b1bdbbe5e4b00ea8e93636f7) + +Cherry picks convertToRectangleAlignment bits from (2a7ab2ab7786ab88b1bdbbe5e4b00ea8e93636f7) + +Change-Id: I8f4eaed5f0d9428a7f405c65f19237f9e70ca151 +Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148934 +Tested-by: Jenkins +Reviewed-by: Sarper Akdemir +--- + .../source/attribute/sdrshadowattribute.cxx | 13 +++- + include/docmodel/theme/FormatScheme.hxx | 34 +++++++++ + .../attribute/sdrshadowattribute.hxx | 6 ++ + include/editeng/unoprnms.hxx | 1 + + include/oox/drawingml/drawingmltypes.hxx | 2 + + include/svx/RectangleAlignmentItem.hxx | 42 +++++++++++ + include/svx/svddef.hxx | 4 +- + include/svx/unoshprp.hxx | 3 +- + oox/source/drawingml/drawingmltypes.cxx | 19 +++++ + oox/source/drawingml/effectproperties.cxx | 5 ++ + oox/source/drawingml/effectproperties.hxx | 5 ++ + .../drawingml/effectpropertiescontext.cxx | 2 + + oox/source/token/properties.txt | 1 + + svx/Library_svxcore.mk | 1 + + .../unit/data/tdf150020-shadow-alignment.pptx | Bin 0 -> 45485 bytes + svx/qa/unit/sdr.cxx | 68 ++++++++++++++++++ + svx/source/items/RectangleAlignmentItem.cxx | 31 ++++++++ + .../sdr/primitive2d/sdrattributecreator.cxx | 5 +- + .../sdr/primitive2d/sdrdecompositiontools.cxx | 45 ++++++++---- + svx/source/svdraw/svdattr.cxx | 4 ++ + svx/source/table/viewcontactoftableobj.cxx | 54 +++++++------- + sw/qa/extras/layout/layout.cxx | 17 +++-- + 22 files changed, 318 insertions(+), 44 deletions(-) + create mode 100644 include/docmodel/theme/FormatScheme.hxx + create mode 100644 include/svx/RectangleAlignmentItem.hxx + create mode 100644 svx/qa/unit/data/tdf150020-shadow-alignment.pptx + create mode 100644 svx/source/items/RectangleAlignmentItem.cxx + +diff --git a/drawinglayer/source/attribute/sdrshadowattribute.cxx b/drawinglayer/source/attribute/sdrshadowattribute.cxx +index 6e046f1f07c7..1eb1b3ea687c 100644 +--- a/drawinglayer/source/attribute/sdrshadowattribute.cxx ++++ b/drawinglayer/source/attribute/sdrshadowattribute.cxx +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + + + namespace drawinglayer::attribute +@@ -32,6 +33,7 @@ namespace drawinglayer::attribute + basegfx::B2DVector maSize; // [0.0 .. 2.0] + double mfTransparence; // [0.0 .. 1.0], 0.0==no transp. + sal_Int32 mnBlur; // [0 .. 180], radius of the blur ++ model::RectangleAlignment meAlignment{model::RectangleAlignment::Unset}; // alignment of the shadow + basegfx::BColor maColor; // color of shadow + + ImpSdrShadowAttribute( +@@ -39,11 +41,13 @@ namespace drawinglayer::attribute + const basegfx::B2DVector& rSize, + double fTransparence, + sal_Int32 nBlur, ++ model::RectangleAlignment eAlignment, + const basegfx::BColor& rColor) + : maOffset(rOffset), + maSize(rSize), + mfTransparence(fTransparence), + mnBlur(nBlur), ++ meAlignment(eAlignment), + maColor(rColor) + { + } +@@ -67,6 +71,7 @@ namespace drawinglayer::attribute + && getSize() == rCandidate.getSize() + && getTransparence() == rCandidate.getTransparence() + && getBlur() == rCandidate.getBlur() ++ && meAlignment == rCandidate.meAlignment + && getColor() == rCandidate.getColor()); + } + }; +@@ -86,9 +91,10 @@ namespace drawinglayer::attribute + const basegfx::B2DVector& rSize, + double fTransparence, + sal_Int32 nBlur, ++ model::RectangleAlignment eAlignment, + const basegfx::BColor& rColor) + : mpSdrShadowAttribute(ImpSdrShadowAttribute( +- rOffset, rSize, fTransparence,nBlur, rColor)) ++ rOffset, rSize, fTransparence, nBlur, eAlignment, rColor)) + { + } + +@@ -141,6 +147,11 @@ namespace drawinglayer::attribute + return mpSdrShadowAttribute->getBlur(); + } + ++ model::RectangleAlignment SdrShadowAttribute::getAlignment() const ++ { ++ return mpSdrShadowAttribute->meAlignment; ++ } ++ + const basegfx::BColor& SdrShadowAttribute::getColor() const + { + return mpSdrShadowAttribute->getColor(); +diff --git a/include/docmodel/theme/FormatScheme.hxx b/include/docmodel/theme/FormatScheme.hxx +new file mode 100644 +index 000000000000..1a29eb199c0f +--- /dev/null ++++ b/include/docmodel/theme/FormatScheme.hxx +@@ -0,0 +1,34 @@ ++/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ ++/* ++ * This file is part of the LibreOffice project. ++ * ++ * This Source Code Form is subject to the terms of the Mozilla Public ++ * License, v. 2.0. If a copy of the MPL was not distributed with this ++ * file, You can obtain one at http://mozilla.org/MPL/2.0/. ++ * ++ */ ++ ++#pragma once ++ ++#include ++ ++namespace model ++{ ++enum class RectangleAlignment ++{ ++ Unset, ++ TopLeft, ++ Top, ++ TopRight, ++ Left, ++ Center, ++ Right, ++ BottomLeft, ++ Bottom, ++ BottomRight ++}; ++constexpr sal_uInt16 RECTANGLE_ALIGNMENT_COUNT ++ = static_cast(RectangleAlignment::BottomRight) + 1; ++} ++ ++/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +diff --git a/include/drawinglayer/attribute/sdrshadowattribute.hxx b/include/drawinglayer/attribute/sdrshadowattribute.hxx +index ffe249498db2..ab2c045e49bb 100644 +--- a/include/drawinglayer/attribute/sdrshadowattribute.hxx ++++ b/include/drawinglayer/attribute/sdrshadowattribute.hxx +@@ -31,6 +31,10 @@ namespace basegfx { + class B2DVector; + } + ++namespace model { ++ enum class RectangleAlignment; ++} ++ + namespace drawinglayer::attribute { + class ImpSdrShadowAttribute; + } +@@ -53,6 +57,7 @@ namespace drawinglayer::attribute + const basegfx::B2DVector& rSize, + double fTransparence, + sal_Int32 nBlur, ++ model::RectangleAlignment eAlignment, + const basegfx::BColor& rColor); + SdrShadowAttribute(); + SdrShadowAttribute(const SdrShadowAttribute&); +@@ -72,6 +77,7 @@ namespace drawinglayer::attribute + const basegfx::B2DVector& getSize() const; + double getTransparence() const; + sal_Int32 getBlur() const; ++ model::RectangleAlignment getAlignment() const; + const basegfx::BColor& getColor() const; + }; + +diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx +index 0df739ee5285..7a95ba989b86 100644 +--- a/include/editeng/unoprnms.hxx ++++ b/include/editeng/unoprnms.hxx +@@ -91,6 +91,7 @@ inline constexpr OUStringLiteral UNO_NAME_SHADOWSIZEX = u"ShadowSizeX"; + inline constexpr OUStringLiteral UNO_NAME_SHADOWSIZEY = u"ShadowSizeY"; + inline constexpr OUStringLiteral UNO_NAME_SHADOWTRANSPARENCE = u"ShadowTransparence"; + inline constexpr OUStringLiteral UNO_NAME_SHADOWBLUR = u"ShadowBlur"; ++inline constexpr OUStringLiteral UNO_NAME_SHADOWALIGNMENT = u"ShadowAlignment"; + + inline constexpr OUStringLiteral UNO_NAME_EDGERADIUS = u"CornerRadius"; + +diff --git a/include/oox/drawingml/drawingmltypes.hxx b/include/oox/drawingml/drawingmltypes.hxx +index 5fe86d56439e..04b7e09e10b2 100644 +--- a/include/oox/drawingml/drawingmltypes.hxx ++++ b/include/oox/drawingml/drawingmltypes.hxx +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -227,6 +228,7 @@ struct EmuRectangle : public EmuPoint, public EmuSize + void setSize( const EmuSize& rSize ) { static_cast< EmuSize& >( *this ) = rSize; } + }; + ++model::RectangleAlignment convertToRectangleAlignment(sal_Int32 nToken); + + } // namespace oox::drawingml + +diff --git a/include/svx/RectangleAlignmentItem.hxx b/include/svx/RectangleAlignmentItem.hxx +new file mode 100644 +index 000000000000..91179e628a40 +--- /dev/null ++++ b/include/svx/RectangleAlignmentItem.hxx +@@ -0,0 +1,42 @@ ++/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ ++/* ++ * This file is part of the LibreOffice project. ++ * ++ * This Source Code Form is subject to the terms of the Mozilla Public ++ * License, v. 2.0. If a copy of the MPL was not distributed with this ++ * file, You can obtain one at http://mozilla.org/MPL/2.0/. ++ */ ++ ++#pragma once ++ ++#include ++#include ++ ++namespace model ++{ ++enum class RectangleAlignment; ++} ++ ++/** Item that holds a rectangle alignment value. ++ ++ e.g. Top Left, Top, Top Right, Center. ++ @see model::RectangleAlignment ++ */ ++class SVXCORE_DLLPUBLIC SvxRectangleAlignmentItem final ++ : public SfxEnumItem ++{ ++public: ++ SvxRectangleAlignmentItem(sal_uInt16 nWhich, model::RectangleAlignment nValue); ++ virtual ~SvxRectangleAlignmentItem() override; ++ ++ SvxRectangleAlignmentItem(SvxRectangleAlignmentItem const&) = default; ++ SvxRectangleAlignmentItem(SvxRectangleAlignmentItem&&) = default; ++ SvxRectangleAlignmentItem& operator=(SvxRectangleAlignmentItem const&) = delete; ++ SvxRectangleAlignmentItem& operator=(SvxRectangleAlignmentItem&&) = delete; ++ ++ virtual SvxRectangleAlignmentItem* Clone(SfxItemPool* pPool = nullptr) const override; ++ ++ virtual sal_uInt16 GetValueCount() const override; ++}; ++ ++/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ +diff --git a/include/svx/svddef.hxx b/include/svx/svddef.hxx +index 059c461721b4..1801f2dfee7b 100644 +--- a/include/svx/svddef.hxx ++++ b/include/svx/svddef.hxx +@@ -159,6 +159,7 @@ class SvxBoxInfoItem; + class SvxBoxItem; + class SvxColorItem; + class SvxLineItem; ++class SvxRectangleAlignmentItem; + class SvxTextRotateItem; + class SvxWritingModeItem; + class XColorItem; +@@ -190,7 +191,8 @@ constexpr TypedWhichId SDRATTR_SHADOWPERSP (SDRATTR_SHADO + constexpr TypedWhichId SDRATTR_SHADOWSIZEX (SDRATTR_SHADOW_FIRST+ 7); + constexpr TypedWhichId SDRATTR_SHADOWSIZEY (SDRATTR_SHADOW_FIRST+ 8); + constexpr TypedWhichId SDRATTR_SHADOWBLUR (SDRATTR_SHADOW_FIRST+ 9); +-constexpr sal_uInt16 SDRATTR_SHADOW_LAST (SDRATTR_SHADOWBLUR); /* 1078 */ /* 1078 */ /* 1061 */ /* Pool V1: 1039 */ ++constexpr TypedWhichId SDRATTR_SHADOWALIGNMENT(SDRATTR_SHADOW_FIRST + 10); ++constexpr sal_uInt16 SDRATTR_SHADOW_LAST (SDRATTR_SHADOWALIGNMENT); /* 1078 */ /* 1078 */ /* 1061 */ /* Pool V1: 1039 */ + + constexpr sal_uInt16 SDRATTR_CAPTION_FIRST (SDRATTR_SHADOW_LAST + 1); /* 1080 */ /* 1080 */ /* 1063 */ /* Pool V1: 1041 */ + constexpr TypedWhichId SDRATTR_CAPTIONTYPE (SDRATTR_CAPTION_FIRST+ 0); /* 1080 */ /* 1080 */ /* 1063 */ +diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx +index 010cbbcd4b36..6b68d7d1e790 100644 +--- a/include/svx/unoshprp.hxx ++++ b/include/svx/unoshprp.hxx +@@ -230,7 +230,8 @@ + { UNO_NAME_SHADOWYDIST, SDRATTR_SHADOWYDIST, ::cppu::UnoType::get(), 0, 0, PropertyMoreFlags::METRIC_ITEM}, \ + { UNO_NAME_SHADOWSIZEX, SDRATTR_SHADOWSIZEX, ::cppu::UnoType::get(), 0, 0}, \ + { UNO_NAME_SHADOWSIZEY, SDRATTR_SHADOWSIZEY, ::cppu::UnoType::get(), 0, 0}, \ +- { UNO_NAME_SHADOWBLUR, SDRATTR_SHADOWBLUR, ::cppu::UnoType::get(), 0, 0, PropertyMoreFlags::METRIC_ITEM}, ++ { UNO_NAME_SHADOWBLUR, SDRATTR_SHADOWBLUR, ::cppu::UnoType::get(), 0, 0, PropertyMoreFlags::METRIC_ITEM}, \ ++ { UNO_NAME_SHADOWALIGNMENT, SDRATTR_SHADOWALIGNMENT, /*ENUM*/::cppu::UnoType::get(), 0, 0}, + + + #define LINE_PROPERTIES_DEFAULTS\ +diff --git a/oox/source/drawingml/drawingmltypes.cxx b/oox/source/drawingml/drawingmltypes.cxx +index fc2f28d902b7..c53e13662c37 100644 +--- a/oox/source/drawingml/drawingmltypes.cxx ++++ b/oox/source/drawingml/drawingmltypes.cxx +@@ -414,6 +414,25 @@ IndexRange GetIndexRange( const Reference< XFastAttributeList >& xAttributes ) + return range; + } + ++model::RectangleAlignment convertToRectangleAlignment(sal_Int32 nToken) ++{ ++ switch (nToken) ++ { ++ case XML_tl: return model::RectangleAlignment::TopLeft; ++ case XML_t: return model::RectangleAlignment::Top; ++ case XML_tr: return model::RectangleAlignment::TopRight; ++ case XML_l: return model::RectangleAlignment::Left; ++ case XML_ctr: return model::RectangleAlignment::Center; ++ case XML_r: return model::RectangleAlignment::Right; ++ case XML_bl: return model::RectangleAlignment::BottomLeft; ++ case XML_b: return model::RectangleAlignment::Bottom; ++ case XML_br: return model::RectangleAlignment::BottomRight; ++ default: ++ break; ++ } ++ return model::RectangleAlignment::Unset; ++} ++ + } // namespace oox::drawingml + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +diff --git a/oox/source/drawingml/effectproperties.cxx b/oox/source/drawingml/effectproperties.cxx +index 579f4e1ab0ac..8424e3436c1a 100644 +--- a/oox/source/drawingml/effectproperties.cxx ++++ b/oox/source/drawingml/effectproperties.cxx +@@ -14,6 +14,7 @@ + + #include + #include ++#include + + #include + +@@ -38,6 +39,7 @@ void EffectShadowProperties::assignUsed(const EffectShadowProperties& rSourcePro + assignIfUsed( moShadowSy, rSourceProps.moShadowSy ); + moShadowColor.assignIfUsed( rSourceProps.moShadowColor ); + assignIfUsed( moShadowBlur, rSourceProps.moShadowBlur ); ++ assignIfUsed( moShadowAlignment, rSourceProps.moShadowAlignment ); + + } + +@@ -105,6 +107,9 @@ void EffectProperties::pushToPropMap( PropertyMap& rPropMap, + rPropMap.setProperty( PROP_ShadowColor, it->moColor.getColor(rGraphicHelper ) ); + rPropMap.setProperty( PROP_ShadowTransparence, it->moColor.getTransparency()); + rPropMap.setProperty( PROP_ShadowBlur, convertEmuToHmm(nAttrBlur)); ++ rPropMap.setProperty( ++ PROP_ShadowAlignment, ++ static_cast(maShadow.moShadowAlignment.value_or(model::RectangleAlignment::Bottom))); + + } + } +diff --git a/oox/source/drawingml/effectproperties.hxx b/oox/source/drawingml/effectproperties.hxx +index 54c7068ef5c6..992e2bddf3ef 100644 +--- a/oox/source/drawingml/effectproperties.hxx ++++ b/oox/source/drawingml/effectproperties.hxx +@@ -17,6 +17,10 @@ + #include + #include + ++namespace model { ++enum class RectangleAlignment; ++} ++ + namespace oox::drawingml { + + struct EffectGlowProperties +@@ -43,6 +47,7 @@ struct EffectShadowProperties + std::optional< sal_Int64 > moShadowSy; + Color moShadowColor; + std::optional< sal_Int64 > moShadowBlur; // size of blur effect ++ std::optional< model::RectangleAlignment > moShadowAlignment; + + /** Overwrites all members that are explicitly set in rSourceProps. */ + void assignUsed( const EffectShadowProperties& rSourceProps ); +diff --git a/oox/source/drawingml/effectpropertiescontext.cxx b/oox/source/drawingml/effectpropertiescontext.cxx +index 23793cdc26dc..a386814ed4b4 100644 +--- a/oox/source/drawingml/effectpropertiescontext.cxx ++++ b/oox/source/drawingml/effectpropertiescontext.cxx +@@ -13,6 +13,7 @@ + #include + #include + #include ++#include + + using namespace ::oox::core; + using namespace ::com::sun::star::uno; +@@ -85,6 +86,7 @@ ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement, + mrEffectProperties.maShadow.moShadowSx = rAttribs.getInteger( XML_sx, 0 ); + mrEffectProperties.maShadow.moShadowSy = rAttribs.getInteger( XML_sy, 0 ); + mrEffectProperties.maShadow.moShadowBlur = rAttribs.getInteger( XML_blurRad, 0 ); ++ mrEffectProperties.maShadow.moShadowAlignment = convertToRectangleAlignment( rAttribs.getToken(XML_algn, XML_b) ); + return new ColorContext(*this, mrEffectProperties.m_Effects[nPos]->moColor); + } + break; +diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt +index 5df793846a50..60b5c375c033 100644 +--- a/oox/source/token/properties.txt ++++ b/oox/source/token/properties.txt +@@ -467,6 +467,7 @@ Segments + SelectedItems + SelectedPage + Shadow ++ShadowAlignment + ShadowColor + ShadowFormat + ShadowSizeX +diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk +index 6a1c0b5de352..9f35193a3645 100644 +--- a/svx/Library_svxcore.mk ++++ b/svx/Library_svxcore.mk +@@ -218,6 +218,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\ + svx/source/items/customshapeitem \ + svx/source/items/drawitem \ + svx/source/items/e3ditem \ ++ svx/source/items/RectangleAlignmentItem \ + svx/source/items/galleryitem \ + svx/source/items/grfitem \ + svx/source/sdr/animation/scheduler \ +diff --git a/svx/source/items/RectangleAlignmentItem.cxx b/svx/source/items/RectangleAlignmentItem.cxx +new file mode 100644 +index 000000000000..3b0b7b0f1081 +--- /dev/null ++++ b/svx/source/items/RectangleAlignmentItem.cxx +@@ -0,0 +1,31 @@ ++/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ ++/* ++ * This file is part of the LibreOffice project. ++ * ++ * This Source Code Form is subject to the terms of the Mozilla Public ++ * License, v. 2.0. If a copy of the MPL was not distributed with this ++ * file, You can obtain one at http://mozilla.org/MPL/2.0/. ++ */ ++ ++#include ++#include ++ ++SvxRectangleAlignmentItem::SvxRectangleAlignmentItem(sal_uInt16 nWhich, ++ model::RectangleAlignment nValue) ++ : SfxEnumItem(nWhich, nValue) ++{ ++} ++ ++SvxRectangleAlignmentItem::~SvxRectangleAlignmentItem() {} ++ ++SvxRectangleAlignmentItem* SvxRectangleAlignmentItem::Clone(SfxItemPool*) const ++{ ++ return new SvxRectangleAlignmentItem(*this); ++} ++ ++sal_uInt16 SvxRectangleAlignmentItem::GetValueCount() const ++{ ++ return model::RECTANGLE_ALIGNMENT_COUNT; ++} ++ ++/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ +diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx +index bafa96f95cd8..9c3155435d4b 100644 +--- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx ++++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx +@@ -53,6 +53,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -401,7 +402,9 @@ namespace drawinglayer::primitive2d + + sal_Int32 nBlur(rSet.Get(SDRATTR_SHADOWBLUR).GetValue()); + +- return attribute::SdrShadowAttribute(aOffset, aSize, static_cast(nTransparence) * 0.01,nBlur, aColor.getBColor()); ++ model::RectangleAlignment eAlignment{rSet.Get(SDRATTR_SHADOWALIGNMENT).GetValue()}; ++ ++ return attribute::SdrShadowAttribute(aOffset, aSize, static_cast(nTransparence) * 0.01, nBlur, eAlignment, aColor.getBColor()); + } + } + +diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx +index 1a5459643006..b5df830d73fe 100644 +--- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx ++++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx +@@ -49,6 +49,7 @@ + #include + #include + #include ++#include + #include + + // for SlideBackgroundFillPrimitive2D +@@ -65,6 +66,35 @@ namespace drawinglayer::primitive2d + { + namespace + { ++/// @returns the offset to apply/unapply to scale according to correct origin for a given alignment. ++basegfx::B2DTuple getShadowScaleOriginOffset(const basegfx::B2DTuple& aScale, ++ model::RectangleAlignment eAlignment) ++{ ++ switch (eAlignment) ++ { ++ case model::RectangleAlignment::TopLeft: ++ return { 0, 0 }; ++ case model::RectangleAlignment::Top: ++ return { aScale.getX() / 2, 0 }; ++ case model::RectangleAlignment::TopRight: ++ return { aScale.getX(), 0 }; ++ case model::RectangleAlignment::Left: ++ return { 0, aScale.getY() / 2 }; ++ case model::RectangleAlignment::Center: ++ return { aScale.getX() / 2, aScale.getY() / 2 }; ++ case model::RectangleAlignment::Right: ++ return { aScale.getX(), aScale.getY() / 2 }; ++ case model::RectangleAlignment::BottomLeft: ++ return { 0, aScale.getY() }; ++ case model::RectangleAlignment::Bottom: ++ return { aScale.getX() / 2, aScale.getY() }; ++ case model::RectangleAlignment::BottomRight: ++ return { aScale.getX(), aScale.getY() }; ++ default: ++ return { 0, 0 }; ++ } ++}; ++ + // See also: SdrTextObj::AdjustRectToTextDistance + basegfx::B2DRange getTextAnchorRange(const attribute::SdrTextAttribute& rText, + const basegfx::B2DRange& rSnapRange) +@@ -775,19 +805,10 @@ sal_uInt32 SlideBackgroundFillPrimitive2D::getPrimitive2DID() const + double fShearX = 0; + rObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX); + // Scale the shadow +- double nTranslateX = aTranslate.getX(); +- double nTranslateY = aTranslate.getY(); +- +- // The origin for scaling is the top left corner by default. A negative +- // shadow offset changes the origin. +- if (rShadow.getOffset().getX() < 0) +- nTranslateX += aScale.getX(); +- if (rShadow.getOffset().getY() < 0) +- nTranslateY += aScale.getY(); +- +- aShadowOffset.translate(-nTranslateX, -nTranslateY); ++ aTranslate += getShadowScaleOriginOffset(aScale, rShadow.getAlignment()); ++ aShadowOffset.translate(-aTranslate); + aShadowOffset.scale(rShadow.getSize().getX() * 0.00001, rShadow.getSize().getY() * 0.00001); +- aShadowOffset.translate(nTranslateX, nTranslateY); ++ aShadowOffset.translate(aTranslate); + } + + aShadowOffset.translate(rShadow.getOffset().getX(), rShadow.getOffset().getY()); +diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx +index 86794dc92bfe..39455dd81916 100644 +--- a/svx/source/svdraw/svdattr.cxx ++++ b/svx/source/svdraw/svdattr.cxx +@@ -29,6 +29,8 @@ + #include + #include + ++#include ++ + #include + #include + #include +@@ -93,6 +95,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -133,6 +136,7 @@ SdrItemPool::SdrItemPool( + rPoolDefaults[SDRATTR_SHADOWSIZEY -SDRATTR_START]=new SdrMetricItem(SDRATTR_SHADOWSIZEY, 100000); + rPoolDefaults[SDRATTR_SHADOWTRANSPARENCE-SDRATTR_START]=new SdrPercentItem(SDRATTR_SHADOWTRANSPARENCE, 0); + rPoolDefaults[SDRATTR_SHADOWBLUR -SDRATTR_START]=new SdrMetricItem(SDRATTR_SHADOWBLUR, 0); ++ rPoolDefaults[SDRATTR_SHADOWALIGNMENT -SDRATTR_START]=new SvxRectangleAlignmentItem(SDRATTR_SHADOWALIGNMENT, model::RectangleAlignment::Unset); + rPoolDefaults[SDRATTR_SHADOW3D -SDRATTR_START]=new SfxVoidItem(SDRATTR_SHADOW3D ); + rPoolDefaults[SDRATTR_SHADOWPERSP -SDRATTR_START]=new SfxVoidItem(SDRATTR_SHADOWPERSP ); + rPoolDefaults[SDRATTR_CAPTIONTYPE -SDRATTR_START]=new SdrCaptionTypeItem ; +diff --git a/svx/source/table/viewcontactoftableobj.cxx b/svx/source/table/viewcontactoftableobj.cxx +index 3f17c5ccae21..5b9418ab06bf 100644 +--- a/svx/source/table/viewcontactoftableobj.cxx ++++ b/svx/source/table/viewcontactoftableobj.cxx +@@ -448,33 +448,39 @@ namespace sdr::contact + aRetvalForShadow.append(new drawinglayer::primitive2d::TransformPrimitive2D( + aTransform, std::move(aCellBorderPrimitives))); + } +- } +- +- if(!aRetval.empty()) +- { +- // check and create evtl. shadow for created content +- const SfxItemSet& rObjectItemSet = rTableObj.GetMergedItemSet(); +- const drawinglayer::attribute::SdrShadowAttribute aNewShadowAttribute( +- drawinglayer::primitive2d::createNewSdrShadowAttribute(rObjectItemSet)); + +- if(!aNewShadowAttribute.isDefault()) ++ if(!aRetval.empty()) + { +- bool bDirectShadow +- = rObjectItemSet.Get(SDRATTR_SHADOW, /*bSrchInParent=*/false) +- .GetValue(); +- if (bDirectShadow) +- { +- // Shadow as direct formatting: no shadow for text, to be compatible +- // with PowerPoint. +- basegfx::B2DHomMatrix aMatrix; +- aRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive( +- std::move(aRetval), aNewShadowAttribute, aMatrix, &aRetvalForShadow); +- } +- else ++ // check and create evtl. shadow for created content ++ const SfxItemSet& rObjectItemSet = rTableObj.GetMergedItemSet(); ++ const drawinglayer::attribute::SdrShadowAttribute aNewShadowAttribute( ++ drawinglayer::primitive2d::createNewSdrShadowAttribute(rObjectItemSet)); ++ ++ if(!aNewShadowAttribute.isDefault()) + { +- // Shadow as style: shadow for text, to be backwards-compatible. +- aRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive( +- std::move(aRetval), aNewShadowAttribute); ++ // pass in table's transform and scale matrix, to ++ // correctly scale and align shadows ++ const basegfx::B2DHomMatrix aTransformScaleMatrix ++ = basegfx::utils::createScaleTranslateB2DHomMatrix( ++ aObjectRange.getRange(), aObjectRange.getMinimum()); ++ ++ bool bDirectShadow ++ = rObjectItemSet.Get(SDRATTR_SHADOW, /*bSrchInParent=*/false) ++ .GetValue(); ++ if (bDirectShadow) ++ { ++ // Shadow as direct formatting: no shadow for text, to be compatible ++ // with PowerPoint. ++ aRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive( ++ std::move(aRetval), aNewShadowAttribute, aTransformScaleMatrix, ++ &aRetvalForShadow); ++ } ++ else ++ { ++ // Shadow as style: shadow for text, to be backwards-compatible. ++ aRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive( ++ std::move(aRetval), aNewShadowAttribute, aTransformScaleMatrix); ++ } + } + } + } +diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx +index 587fa4d4294e..e60fa05aab71 100644 +--- a/sw/qa/extras/layout/layout.cxx ++++ b/sw/qa/extras/layout/layout.cxx +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -1213,22 +1214,30 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025) + // SDRATTR_TEXT_LEFTDIST + assertXPath(pXmlDoc, + "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject" +- "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item[@whichId='1072']", ++ "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item" ++ "[@whichId='" ++ + OString::number(SDRATTR_TEXT_LEFTDIST) + "']", + "value", "567"); + // SDRATTR_TEXT_RIGHTDIST + assertXPath(pXmlDoc, + "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject" +- "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item[@whichId='1073']", ++ "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item" ++ "[@whichId='" ++ + OString::number(SDRATTR_TEXT_RIGHTDIST) + "']", + "value", "1134"); + // SDRATTR_TEXT_UPPERDIST + assertXPath(pXmlDoc, + "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject" +- "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item[@whichId='1074']", ++ "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item" ++ "[@whichId='" ++ + OString::number(SDRATTR_TEXT_UPPERDIST) + "']", + "value", "1701"); + // SDRATTR_TEXT_LOWERDIST + assertXPath(pXmlDoc, + "/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject" +- "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item[@whichId='1075']", ++ "/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item" ++ "[@whichId='" ++ + OString::number(SDRATTR_TEXT_LOWERDIST) + "']", + "value", "2268"); + + // Check the textbox-shape import too +-- +2.35.3 + diff --git a/libreoffice.changes b/libreoffice.changes index 5959bed..e3f04a9 100644 --- a/libreoffice.changes +++ b/libreoffice.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Sun May 28 19:46:01 UTC 2023 - Andras Timar + +- Fix bsc#1204040 - LO-L3: PPTX: shadow effect for table offset too far to the right + * bsc1204040.patch +- Fix bsc#1198666 - LO-L3: Need to be able to set the default tab size for each text object + * bsc1198666.patch + ------------------------------------------------------------------- Wed May 24 07:49:40 UTC 2023 - Danilo Spinella diff --git a/libreoffice.spec b/libreoffice.spec index 5b0d878..2089a53 100644 --- a/libreoffice.spec +++ b/libreoffice.spec @@ -117,6 +117,10 @@ Patch15: fix-sdk-idl.patch Patch16: 0002-Revert-Require-HarfBuzz-5.1.0.patch # LO-L3: FILEOPEN PPTX: extra paragraph after some 2-line text with link Patch17: bsc1200085.patch +# LO-L3: PPTX: shadow effect for table offset too far to the right +Patch18: bsc1204040.patch +# LO-L3: Need to be able to set the default tab size for each text object +Patch19: bsc1198666.patch # Build with java 8 Patch101: 0001-Revert-java-9-changes.patch # try to save space by using hardlinks @@ -1044,6 +1048,8 @@ Provides %{langname} translations and additional resources (help files, etc.) fo %patch16 -p1 %endif %patch17 -p1 +%patch18 -p1 +%patch19 -p1 %patch990 -p1 %patch991 -p1