avmedia/source/viewer/mediawindow_impl.cxx | 13 - editeng/source/items/frmitems.cxx | 9 - embeddedobj/source/commonembedding/persistence.cxx | 17 +- forms/source/component/ImageControl.cxx | 7 forms/source/component/clickableimage.cxx | 11 + include/toolkit/controls/unocontrols.hxx | 2 linguistic/source/lngsvcmgr.cxx | 7 sfx2/source/appl/linkmgr2.cxx | 5 sfx2/source/dialog/splitwin.cxx | 5 svl/source/items/itemset.cxx | 4 sw/CppunitTest_sw_odfexport2.mk | 8 + sw/layoutwriter_setup.mk | 8 + sw/ooxmlexport_setup.mk | 8 + sw/qa/extras/layout/layout3.cxx | 6 sw/qa/extras/unowriter/data/section-table.fodt | 162 +++++++++++++++++++++ sw/qa/extras/unowriter/unowriter.cxx | 31 ++++ sw/source/core/doc/doc.cxx | 4 sw/source/core/doc/docfmt.cxx | 3 sw/source/core/text/atrstck.cxx | 3 sw/source/core/unocore/unomap.cxx | 2 sw/source/core/unocore/unoobj2.cxx | 30 ++- sw/source/filter/html/htmlgrin.cxx | 3 sw/uiwriter_setup.mk | 8 + toolkit/inc/helper/property.hxx | 1 toolkit/source/awt/vclxwindows.cxx | 1 toolkit/source/controls/dialogcontrol.cxx | 4 toolkit/source/controls/unocontrols.cxx | 14 + toolkit/source/helper/property.cxx | 2 tools/qa/cppunit/test_urlobj.cxx | 44 +++++ tools/source/fsys/urlobj.cxx | 31 +++- unotools/source/misc/mediadescriptor.cxx | 4 vcl/source/filter/graphicfilter.cxx | 8 - vcl/source/filter/png/PngImageReader.cxx | 7 vcl/source/gdi/embeddedfontshelper.cxx | 16 +- xmloff/source/forms/elementimport.cxx | 9 + 35 files changed, 440 insertions(+), 57 deletions(-)
New commits: commit d8f324c2d7ce9e7eb0d8ba73e7c2f4ac1e41c451 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Mon Nov 25 13:45:39 2024 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 16:28:12 2024 +0100 sw: fix property set implementation of SwXTextRange RANGE_IS_SECTION Use cursor that includes section nodes, the core implementation should not need start/end to be a text node. Fix one case in SwDoc::ResetAttrs() where a text node is expected. (regression from commit 7ab349296dac79dad3fec09f60348efcbb9ea17e) Change-Id: I56960b5d233ced02703a7c522ebe6afa3347cd25 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177259 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 4fef75d4c8798dd5ebff1c6bd66993665602507d) diff --git a/sw/qa/extras/unowriter/data/section-table.fodt b/sw/qa/extras/unowriter/data/section-table.fodt new file mode 100644 index 000000000000..4f46ac086c91 --- /dev/null +++ b/sw/qa/extras/unowriter/data/section-table.fodt @@ -0,0 +1,162 @@ +<?xml version='1.0' encoding='UTF-8'?> +<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:c alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns: meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.4" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:meta><meta:initial-creator>GCC</meta:initial-creator><meta:creation-date>2024-11-25T12:23:18.360978950</meta:creation-date><dc:date>2024-11-25T12:24:38.999591414</dc:date><dc:creator>GCC</dc:creator><meta:editing-duration>PT1M22S</meta:editing-duration><meta:editing-cycles>1</meta:editing-cycles><meta:document-statistic meta:table-count="1" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="2" meta:word-count="5" meta:character-count="31" meta:non-whitespace-character-count="28"/><meta:generator>LibreOfficeDev/25.2.0.0.alpha0$Linux_X86_64 LibreOffice_project/10f916791e49306b51a6a299739b130fc2129de1</meta:generator></office:meta> + <office:font-face-decls> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Lucida Sans1" svg:font-family="'Lucida Sans'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Noto Serif CJK SC" svg:font-family="'Noto Serif CJK SC'" style:font-family-generic="system" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" loext:tab-stop-distance="0cm" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Noto Serif CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lucida Sans1" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/> + </style:default-style> + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:orphans="2" fo:widows="2" fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="auto" loext:hyphenation-keep-type="column" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Noto Serif CJK SC" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lucida Sans1" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false" loext:hyphenation-word-char-count="5" loext:hyphenation-zone="no-limit"/> + </style:default-style> + <style:default-style style:family="table"> + <style:table-properties table:border-model="collapsing"/> + </style:default-style> + <style:default-style style:family="table-row"> + <style:table-row-properties fo:keep-together="auto"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + <style:style style:name="Table_20_Contents" style:display-name="Table Contents" style:family="paragraph" style:parent-style-name="Standard" style:class="extra"> + <style:paragraph-properties fo:orphans="0" fo:widows="0" text:number-lines="false" text:line-number="0"/> + </style:style> + <text:outline-style style:name="Outline"> + <text:outline-level-style text:level="1" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="2" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="3" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="4" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="5" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="6" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="7" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="8" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="9" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + <text:outline-level-style text:level="10" style:num-format=""> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab"/> + </style:list-level-properties> + </text:outline-level-style> + </text:outline-style> + <text:notes-configuration text:note-class="footnote" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/> + <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/> + <text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/> + </office:styles> + <office:automatic-styles> + <style:style style:name="Table1" style:family="table"> + <style:table-properties style:width="17cm" table:align="margins"/> + </style:style> + <style:style style:name="Table1.A" style:family="table-column"> + <style:table-column-properties style:column-width="8.5cm" style:rel-column-width="32767*"/> + </style:style> + <style:style style:name="Table1.A1" style:family="table-cell"> + <style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.5pt solid #000000" fo:border-right="none" fo:border-top="0.5pt solid #000000" fo:border-bottom="0.5pt solid #000000"/> + </style:style> + <style:style style:name="Table1.B1" style:family="table-cell"> + <style:table-cell-properties fo:padding="0.097cm" fo:border="0.5pt solid #000000"/> + </style:style> + <style:style style:name="Table1.A2" style:family="table-cell"> + <style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.5pt solid #000000" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.5pt solid #000000"/> + </style:style> + <style:style style:name="Table1.B2" style:family="table-cell"> + <style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.5pt solid #000000" fo:border-right="0.5pt solid #000000" fo:border-top="none" fo:border-bottom="0.5pt solid #000000"/> + </style:style> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Table_20_Contents"> + <style:text-properties/> + </style:style> + <style:style style:name="P2" style:family="paragraph" style:parent-style-name="Standard"> + <style:text-properties/> + </style:style> + <style:style style:name="Sect1" style:family="section"> + <style:section-properties fo:background-color="#158466" style:editable="false"> + <style:columns fo:column-count="1" fo:column-gap="0cm"/> + <style:background-image/> + </style:section-properties> + </style:style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm" loext:margin-gutter="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <text:sequence-decls> + <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> + <text:sequence-decl text:display-outline-level="0" text:name="Table"/> + <text:sequence-decl text:display-outline-level="0" text:name="Text"/> + <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> + <text:sequence-decl text:display-outline-level="0" text:name="Figure"/> + </text:sequence-decls> + <text:section text:style-name="Sect1" text:name="Section1"> + <table:table table:name="Table1" table:style-name="Table1"> + <table:table-column table:style-name="Table1.A" table:number-columns-repeated="2"/> + <table:table-row> + <table:table-cell table:style-name="Table1.A1" office:value-type="string"> + <text:p text:style-name="P1">Table in section</text:p> + </table:table-cell> + <table:table-cell table:style-name="Table1.B1" office:value-type="string"> + <text:p text:style-name="Table_20_Contents"/> + </table:table-cell> + </table:table-row> + <table:table-row> + <table:table-cell table:style-name="Table1.A2" office:value-type="string"> + <text:p text:style-name="Table_20_Contents"/> + </table:table-cell> + <table:table-cell table:style-name="Table1.B2" office:value-type="string"> + <text:p text:style-name="Table_20_Contents"/> + </table:table-cell> + </table:table-row> + </table:table> + </text:section> + <text:p text:style-name="P2">Outside section</text:p> + </office:text> + </office:body> +</office:document> \ No newline at end of file diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx index a2c03bbaaf02..8823cb1defa5 100644 --- a/sw/qa/extras/unowriter/unowriter.cxx +++ b/sw/qa/extras/unowriter/unowriter.cxx @@ -556,6 +556,37 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testSectionAnchorCopyTable) xCursor->getString()); } +CPPUNIT_TEST_FIXTURE(SwUnoWriter, testSectionAnchorProperties) +{ + createSwDoc("section-table.fodt"); + + uno::Reference<text::XTextSectionsSupplier> const xTextSectionsSupplier(mxComponent, + uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> const xSections( + xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount()); + + uno::Reference<text::XTextContent> const xSection(xSections->getByIndex(0), uno::UNO_QUERY); + uno::Reference<text::XTextRange> const xAnchor(xSection->getAnchor()); + uno::Reference<beans::XPropertySet> const xAnchorProp(xAnchor, uno::UNO_QUERY); + + // the problem was that the property set didn't work + auto xSecFromProp = getProperty<uno::Reference<text::XTextContent>>(xAnchorProp, "TextSection"); + CPPUNIT_ASSERT_EQUAL(xSection, xSecFromProp); + + xAnchorProp->setPropertyValue("CharHeight", uno::Any(float(64))); + CPPUNIT_ASSERT_EQUAL(float(64), getProperty<float>(xAnchorProp, "CharHeight")); + uno::Reference<beans::XPropertyState> const xAnchorState(xAnchor, uno::UNO_QUERY); + // TODO: why does this return DEFAULT_VALUE instead of DIRECT_VALUE? + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DEFAULT_VALUE, + xAnchorState->getPropertyState("CharHeight")); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DEFAULT_VALUE, + xAnchorState->getPropertyStates({ "CharHeight" })[0]); + CPPUNIT_ASSERT_EQUAL(float(12), xAnchorState->getPropertyDefault("CharHeight").get<float>()); + xAnchorState->setPropertyToDefault("CharHeight"); + CPPUNIT_ASSERT_EQUAL(float(12), getProperty<float>(xAnchorProp, "CharHeight")); +} + CPPUNIT_TEST_FIXTURE(SwUnoWriter, testTextRangeInTable) { createSwDoc("bookmarkintable.fodt"); diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 755ee2541fde..4f89de65e4f4 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -365,7 +365,8 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, ++aTmpStt; } - if( pEnd->GetContentIndex() == pEnd->GetNode().GetContentNode()->Len() ) + if (!pEnd->GetNode().IsContentNode() + || pEnd->GetContentIndex() == pEnd->GetNode().GetContentNode()->Len()) { // set up a later, and all CharFormatAttr -> TextFormatAttr ++aTmpEnd; diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 5cb73bf7b8f0..db08e63592e6 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1439,12 +1439,13 @@ SwXTextRange::setPropertyValue( { SolarMutexGuard aGuard; - if (!m_pImpl->GetBookmark()) + if (!m_pImpl->GetBookmark() + && (m_pImpl->m_eRangePosition != RANGE_IS_SECTION || !m_pImpl->m_pTableOrSectionFormat)) { throw uno::RuntimeException("range has no mark (table?)"); } SwPaM aPaM(GetDoc().GetNodes()); - GetPositions(aPaM); + GetPositions(aPaM, ::sw::TextRangeMode::AllowNonTextNode); SwUnoCursorHelper::SetPropertyValue(aPaM, m_pImpl->m_rPropSet, rPropertyName, rValue); } @@ -1454,12 +1455,13 @@ SwXTextRange::getPropertyValue(const OUString& rPropertyName) { SolarMutexGuard aGuard; - if (!m_pImpl->GetBookmark()) + if (!m_pImpl->GetBookmark() + && (m_pImpl->m_eRangePosition != RANGE_IS_SECTION || !m_pImpl->m_pTableOrSectionFormat)) { throw uno::RuntimeException("range has no mark (table?)"); } SwPaM aPaM(GetDoc().GetNodes()); - GetPositions(aPaM); + GetPositions(aPaM, ::sw::TextRangeMode::AllowNonTextNode); return SwUnoCursorHelper::GetPropertyValue(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1501,12 +1503,13 @@ SwXTextRange::getPropertyState(const OUString& rPropertyName) { SolarMutexGuard aGuard; - if (!m_pImpl->GetBookmark()) + if (!m_pImpl->GetBookmark() + && (m_pImpl->m_eRangePosition != RANGE_IS_SECTION || !m_pImpl->m_pTableOrSectionFormat)) { throw uno::RuntimeException("range has no mark (table?)"); } SwPaM aPaM(GetDoc().GetNodes()); - GetPositions(aPaM); + GetPositions(aPaM, ::sw::TextRangeMode::AllowNonTextNode); return SwUnoCursorHelper::GetPropertyState(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1516,12 +1519,13 @@ SwXTextRange::getPropertyStates(const uno::Sequence< OUString >& rPropertyName) { SolarMutexGuard g; - if (!m_pImpl->GetBookmark()) + if (!m_pImpl->GetBookmark() + && (m_pImpl->m_eRangePosition != RANGE_IS_SECTION || !m_pImpl->m_pTableOrSectionFormat)) { throw uno::RuntimeException("range has no mark (table?)"); } SwPaM aPaM(GetDoc().GetNodes()); - GetPositions(aPaM); + GetPositions(aPaM, ::sw::TextRangeMode::AllowNonTextNode); return SwUnoCursorHelper::GetPropertyStates(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1530,12 +1534,13 @@ void SAL_CALL SwXTextRange::setPropertyToDefault(const OUString& rPropertyName) { SolarMutexGuard aGuard; - if (!m_pImpl->GetBookmark()) + if (!m_pImpl->GetBookmark() + && (m_pImpl->m_eRangePosition != RANGE_IS_SECTION || !m_pImpl->m_pTableOrSectionFormat)) { throw uno::RuntimeException("range has no mark (table?)"); } SwPaM aPaM(GetDoc().GetNodes()); - GetPositions(aPaM); + GetPositions(aPaM, ::sw::TextRangeMode::AllowNonTextNode); SwUnoCursorHelper::SetPropertyToDefault(aPaM, m_pImpl->m_rPropSet, rPropertyName); } @@ -1545,12 +1550,13 @@ SwXTextRange::getPropertyDefault(const OUString& rPropertyName) { SolarMutexGuard aGuard; - if (!m_pImpl->GetBookmark()) + if (!m_pImpl->GetBookmark() + && (m_pImpl->m_eRangePosition != RANGE_IS_SECTION || !m_pImpl->m_pTableOrSectionFormat)) { throw uno::RuntimeException("range has no mark (table?)"); } SwPaM aPaM(GetDoc().GetNodes()); - GetPositions(aPaM); + GetPositions(aPaM, ::sw::TextRangeMode::AllowNonTextNode); return SwUnoCursorHelper::GetPropertyDefault(aPaM, m_pImpl->m_rPropSet, rPropertyName); } commit a1a7ac2331758d6544c2a92cd538aaa29f8f15d8 Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Thu Jul 25 14:17:06 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 16:27:59 2024 +0100 Use NDEBUG to show/hide m_bDeleted "#ifndef NDEBUG" is now always used to hide/show member m_bDeleted Change-Id: I10f5111cd36e13b8101d2a69ed9268bee622344a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171012 Tested-by: Jenkins Reviewed-by: Oliver Specht <oliver.spe...@cib.de> (cherry picked from commit 44d129870795da2e370ad5f2f8abc95c5c6873aa) diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index acc5d64ea50a..5a85d2d7780e 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -110,7 +110,7 @@ SfxPoolItemHolder::~SfxPoolItemHolder() #endif if (nullptr != m_pItem) implCleanupItemEntry(*m_pPool, m_pItem); -#ifdef DBG_UTIL +#ifndef NDEBUG m_bDeleted = true; #endif } commit 4248b3779ff90978c21073a1674c9a285333bbda Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Sat Dec 23 13:52:09 2023 +0000 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 16:27:45 2024 +0100 cid#1559884 Uninitialized scalar variable etc, since: commit e9e3576ada06d53de12efed041fb309fe5388e01 Date: Thu Dec 21 22:49:27 2023 +0100 svl: fix build with --enable-debug Change-Id: I1c3c82f0f1674cb46fa6a36d5f9f5cc4435ebef1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161241 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit b803b3a7a1eda1b9862112f399c0a8b988c1f930) diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index fd9cbb1dddee..acc5d64ea50a 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -61,7 +61,7 @@ static bool g_bItemClassicMode(getenv("ITEM_CLASSIC_MODE")); SfxPoolItemHolder::SfxPoolItemHolder() : m_pPool(nullptr) , m_pItem(nullptr) -#ifdef DBG_UTIL +#ifndef NDEBUG , m_bDeleted(false) #endif { commit 8f147ae672dc9cc3a664b98adc78715c54852e24 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed Mar 13 16:24:50 2024 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 16:27:35 2024 +0100 sw: convert OSL_ENSURE to assert To avoid spurious -Warray-bounds from GCC 13.2.1 Change-Id: I26aba84a6ceda79ffc111c925c8be96df8b186dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164782 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 7389be1996159b557f2e4022459ed8408302d72a) diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index 048878292fc0..0eb8d74e89c6 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -472,8 +472,7 @@ void SwAttrHandler::Pop( const SwTextAttr& rAttr ) void SwAttrHandler::ActivateTop( SwFont& rFnt, const sal_uInt16 nAttr ) { - OSL_ENSURE( nAttr < RES_TXTATR_WITHEND_END, - "I cannot activate this attribute, nWhich >= RES_TXTATR_WITHEND_END" ); + assert(nAttr < RES_TXTATR_WITHEND_END); const sal_uInt16 nStackPos = StackPos[ nAttr ]; const SwTextAttr* pTopAt = GetTop(nStackPos); diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 3004fb684e9c..78df4a8dc6d8 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -73,7 +73,7 @@ using namespace ::com::sun::star::beans; std::span<const SfxItemPropertyMapEntry> SwUnoPropertyMapProvider::GetPropertyMapEntries(sal_uInt16 nPropertyId) { - OSL_ENSURE(nPropertyId < PROPERTY_MAP_END, "Id ?" ); + assert(nPropertyId < PROPERTY_MAP_END); if( m_aMapEntriesArr[ nPropertyId ].empty() ) { switch(nPropertyId) commit 039b555d00980dc8dce231c2d8e2737d070ae336 Author: Julien Nabet <serval2...@yahoo.fr> AuthorDate: Fri Aug 23 11:57:45 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 16:27:23 2024 +0100 Silence some bogus -Werror=array-bounds etc. also with GCC 14 and -std=c++20 Change-Id: If7a3e0d7536642ae672ba6096183bb8413b36a31 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172310 Reviewed-by: Julien Nabet <serval2...@yahoo.fr> Tested-by: Julien Nabet <serval2...@yahoo.fr> (cherry picked from commit 6e51d65c3d8031967727092ee2f48b8577db9b85) diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 93ec0fa23e48..1a92fc3224ed 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -992,13 +992,13 @@ void SwDoc::CalculatePagePairsForProspectPrinting( // just one page is special ... if ( 1 == aVec.size() ) { -#if defined __GNUC__ && !defined __clang__ && __GNUC__ <= 13 && __cplusplus == 202002L +#if defined __GNUC__ && !defined __clang__ && __GNUC__ <= 14 && __cplusplus == 202002L #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Warray-bounds" #pragma GCC diagnostic ignored "-Wstringop-overflow" #endif aVec.insert( aVec.begin() + 1, nullptr ); // insert a second empty page -#if defined __GNUC__ && !defined __clang__ && __GNUC__ <= 13 && __cplusplus == 202002L +#if defined __GNUC__ && !defined __clang__ && __GNUC__ <= 14 && __cplusplus == 202002L #pragma GCC diagnostic pop #endif } commit 869f3ef25f0f9410aa1ce9255f796ea9fda15899 Author: Julien Nabet <serval2...@yahoo.fr> AuthorDate: Wed May 1 15:50:50 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 16:27:04 2024 +0100 Silence some bogus -Werror=array-bounds etc. also with GCC 13 and -std=c++20 See 1c3c27bc2e42f70e588ef5dbc769a8a346042e04 Silence some bogus -Werror=array-bounds etc. with GCC 12 and -std=c++20 Change-Id: I65675d1f18415ae82afb98c7d388dac3cdc18ab0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166966 Reviewed-by: Julien Nabet <serval2...@yahoo.fr> Tested-by: Jenkins (cherry picked from commit a835b40e05462e9be58cb501aa6b938f3dc998b8) diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 4bcb2a35e856..93ec0fa23e48 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -992,13 +992,13 @@ void SwDoc::CalculatePagePairsForProspectPrinting( // just one page is special ... if ( 1 == aVec.size() ) { -#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 12 && __cplusplus == 202002L +#if defined __GNUC__ && !defined __clang__ && __GNUC__ <= 13 && __cplusplus == 202002L #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Warray-bounds" #pragma GCC diagnostic ignored "-Wstringop-overflow" #endif aVec.insert( aVec.begin() + 1, nullptr ); // insert a second empty page -#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 12 && __cplusplus == 202002L +#if defined __GNUC__ && !defined __clang__ && __GNUC__ <= 13 && __cplusplus == 202002L #pragma GCC diagnostic pop #endif } commit 23534a791159811a254145afe8beec22c2f46fc1 Author: Julien Nabet <serval2...@yahoo.fr> AuthorDate: Fri Aug 23 10:56:27 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 16:26:40 2024 +0100 -Werror=maybe-uninitialized in sfx2 /home/julien/lo/libo_perf/sfx2/source/dialog/splitwin.cxx: In member function ‘void SfxSplitWindow::InsertWindow(SfxDockingWindow*, const Size&)’: /home/julien/lo/libo_perf/sfx2/source/dialog/splitwin.cxx:462:23: error: ‘nL’ may be used uninitialized [-Werror=maybe-uninitialized] 462 | nLine = static_cast<short>(nL); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ /home/julien/lo/libo_perf/sfx2/source/dialog/splitwin.cxx:433:16: note: ‘nL’ was declared here 433 | sal_uInt16 nL; | ^~ /home/julien/lo/libo_perf/sfx2/source/dialog/splitwin.cxx: In member function ‘void SfxSplitWindow::MoveWindow(SfxDockingWindow*, const Size&, sal_uInt16, sal_uInt16, bool)’: /home/julien/lo/libo_perf/sfx2/source/dialog/splitwin.cxx:552:21: error: ‘nL’ may be used uninitialized [-Werror=maybe-uninitialized] 552 | if ( nLine > nL && GetItemCount( GetItemId( nL ) ) == 1 ) | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/julien/lo/libo_perf/sfx2/source/dialog/splitwin.cxx:548:16: note: ‘nL’ was declared here 548 | sal_uInt16 nL, nP; | ^~ Change-Id: I816ec49fe2c63e4f448ae83251d3a24b08383903 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172306 Reviewed-by: Julien Nabet <serval2...@yahoo.fr> Tested-by: Jenkins (cherry picked from commit 73884e28faeb457c01b80051a701c073112ad564) diff --git a/sfx2/source/dialog/splitwin.cxx b/sfx2/source/dialog/splitwin.cxx index 210a9dbeaaff..61903bb13d6c 100644 --- a/sfx2/source/dialog/splitwin.cxx +++ b/sfx2/source/dialog/splitwin.cxx @@ -429,7 +429,6 @@ void SfxSplitWindow::InsertWindow( SfxDockingWindow* pDockWin, const Size& rSize */ { short nLine = -1; // so that the first window cab set nline to 0 - sal_uInt16 nL; sal_uInt16 nPos = 0; bool bNewLine = true; bool bSaveConfig = false; @@ -456,6 +455,7 @@ void SfxSplitWindow::InsertWindow( SfxDockingWindow* pDockWin, const Size& rSize if ( bNewLine && !pFoundDock ) { // Not known until now in which real line it is located + sal_uInt16 nL = 0; GetWindowPos( rDock.pWin, nL, nPos ); nLine = static_cast<short>(nL); } @@ -543,7 +543,8 @@ void SfxSplitWindow::MoveWindow( SfxDockingWindow* pDockWin, const Size& rSize, */ { - sal_uInt16 nL, nP; + sal_uInt16 nL = 0; + sal_uInt16 nP = 0; GetWindowPos( pDockWin, nL, nP ); if ( nLine > nL && GetItemCount( GetItemId( nL ) ) == 1 ) commit 3af18d6180bd7a0748e686c63a901e6fd89d2828 Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Fri Apr 5 16:43:08 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 16:26:13 2024 +0100 Silence strange -Wmaybe-uninitialized with recent GCC 14 ...seen at least with some (--enable-dbgutil --enable-otpimized etc.) configuration and a recent GCC 14 trunk, > In file included from ~/gcc/inst/include/c++/14.0.1/vector:66, > from include/unotools/options.hxx:26, > from include/unotools/lingucfg.hxx:27, > from linguistic/source/lngsvcmgr.cxx:35: > In destructor ‘constexpr std::__cxx1998::vector< <template-parameter-1-1>, <template-parameter-1-2> >::~vector() [with _Tp = SvcInfo; _Alloc = std::allocator<SvcInfo>]’, > inlined from ‘constexpr std::__debug::vector<_Tp, _Allocator>::~vector() [with _Tp = SvcInfo; _Allocator = std::allocator<SvcInfo>]’ at ~/gcc/inst/include/c++/14.0.1/debug/vector:245:7, > inlined from ‘constexpr void std::_Optional_payload_base<_Tp>::_M_destroy() [with _Tp = std::__debug::vector<SvcInfo>]’ at ~/gcc/inst/include/c++/14.0.1/optional:283:35, > inlined from ‘constexpr void std::_Optional_payload_base<_Tp>::_M_reset() [with _Tp = std::__debug::vector<SvcInfo>]’ at ~/gcc/inst/include/c++/14.0.1/optional:314:14, > inlined from ‘constexpr std::_Optional_payload<_Tp, false, _Copy, _Move>::~_Optional_payload() [with _Tp = std::__debug::vector<SvcInfo>; bool _Copy = false; bool _Move = false]’ at ~/gcc/inst/include/c++/14.0.1/optional:437:65, > inlined from ‘constexpr std::_Optional_base<std::__debug::vector<SvcInfo>, false, false>::~_Optional_base()’ at ~/gcc/inst/include/c++/14.0.1/optional:508:12, > inlined from ‘constexpr std::optional<std::__debug::vector<SvcInfo> >::~optional()’ at ~/gcc/inst/include/c++/14.0.1/optional:703:11, > inlined from ‘LngSvcMgr::~LngSvcMgr()’ at linguistic/source/lngsvcmgr.cxx:519:1: > ~/gcc/inst/include/c++/14.0.1/bits/stl_vector.h:735:22: error: ‘((std::__cxx1998::vector<SvcInfo, std::allocator<SvcInfo> >*)((char*)this + 16))[22].std::__cxx1998::vector<SvcInfo, std::allocator<SvcInfo> >::std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >.std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_M_impl.std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_Vector_impl::std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_Vector_impl_data.std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_Vector_impl_data::_M_finish’ may be used uninitialized [-Werror=maybe-uninitialized] > 735 | std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, > | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 736 | _M_get_Tp_allocator()); > | ~~~~~~~~~~~~~~~~~~~~~~ > ~/gcc/inst/include/c++/14.0.1/bits/stl_vector.h:735:22: error: ‘((std::__cxx1998::vector<SvcInfo, std::allocator<SvcInfo> >*)((char*)this + 16))[22].std::__cxx1998::vector<SvcInfo, std::allocator<SvcInfo> >::std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >.std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_M_impl.std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_Vector_impl::std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_Vector_impl_data.std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_Vector_impl_data::_M_start’ may be used uninitialized [-Werror=maybe-uninitialized] Change-Id: I02815c39ee6026b4637a4bb6ad2804af7a446a57 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165821 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> (cherry picked from commit 745ba22017fde53b50f38a1db5c3eaa388003871) diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx index 850d4d813bfd..f6bd3b705344 100644 --- a/linguistic/source/lngsvcmgr.cxx +++ b/linguistic/source/lngsvcmgr.cxx @@ -496,6 +496,10 @@ void LngSvcMgr::disposing(const lang::EventObject&) stopListening(); } +#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 14 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif LngSvcMgr::~LngSvcMgr() { stopListening(); @@ -509,6 +513,9 @@ LngSvcMgr::~LngSvcMgr() pAvailHyphSvcs.reset(); pAvailThesSvcs.reset(); } +#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 14 +#pragma GCC diagnostic pop +#endif namespace { commit 3a1f7489896a20711f4388910fa7b9074bac0bef Author: Julien Nabet <serval2...@yahoo.fr> AuthorDate: Thu May 2 09:16:26 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 16:25:44 2024 +0100 Extend silence strange -Wclobbered with GCC <= 14 See 2bcd9fe0fa10339294e6ab820498fa18334e02f3 Silence strange -Wclobbered with recent GCC 14 Change-Id: Id51659cb8cd49b65c55b22ed0ac515a8ab609602 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166994 Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> Tested-by: Julien Nabet <serval2...@yahoo.fr> (cherry picked from commit e783a1c09093f3dbaf778661b77a2d5872a2029d) diff --git a/vcl/source/filter/png/PngImageReader.cxx b/vcl/source/filter/png/PngImageReader.cxx index a317cff70458..5e4673286ee3 100644 --- a/vcl/source/filter/png/PngImageReader.cxx +++ b/vcl/source/filter/png/PngImageReader.cxx @@ -322,7 +322,7 @@ bool fcTLbeforeIDAT(SvStream& rStream) return false; } -#if defined __GNUC__ && __GNUC__ == 14 && !defined __clang__ +#if defined __GNUC__ && __GNUC__ <= 14 && !defined __clang__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wclobbered" #endif @@ -821,7 +821,7 @@ BinaryDataContainer getMsGifChunk(SvStream& rStream) return {}; } } -#if defined __GNUC__ && __GNUC__ == 14 && !defined __clang__ +#if defined __GNUC__ && __GNUC__ <= 14 && !defined __clang__ #pragma GCC diagnostic pop #endif commit d4c048a296473a3f224186d3484bf50ebe53d350 Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Fri Apr 5 16:55:28 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 16:25:28 2024 +0100 Silence strange -Wclobbered with recent GCC 14 ...seen at least with some (--enable-dbgutil --enable-otpimized etc.) configuration and a recent GCC 14 trunk, > vcl/source/filter/png/PngImageReader.cxx: In function ‘bool {anonymous}::reader(SvStream&, Graphic&, GraphicFilterImportFlags, BitmapScopedWriteAccess*, BitmapScopedWriteAccess*)’: > vcl/source/filter/png/PngImageReader.cxx:361:16: error: variable ‘bSupportsBitmap32’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered] > 361 | const bool bSupportsBitmap32 = bFuzzing || ImplGetSVData()->mpDefInst->supportsBitmap32(); > | ^~~~~~~~~~~~~~~~~ Change-Id: Icc1932347a213877ecc9f561f98de779f8041c09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165823 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> (cherry picked from commit 2bcd9fe0fa10339294e6ab820498fa18334e02f3) diff --git a/vcl/source/filter/png/PngImageReader.cxx b/vcl/source/filter/png/PngImageReader.cxx index b2fe3b8c81a9..a317cff70458 100644 --- a/vcl/source/filter/png/PngImageReader.cxx +++ b/vcl/source/filter/png/PngImageReader.cxx @@ -322,6 +322,10 @@ bool fcTLbeforeIDAT(SvStream& rStream) return false; } +#if defined __GNUC__ && __GNUC__ == 14 && !defined __clang__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclobbered" +#endif bool reader(SvStream& rStream, Graphic& rGraphic, GraphicFilterImportFlags nImportFlags = GraphicFilterImportFlags::NONE, BitmapScopedWriteAccess* pAccess = nullptr, @@ -817,6 +821,9 @@ BinaryDataContainer getMsGifChunk(SvStream& rStream) return {}; } } +#if defined __GNUC__ && __GNUC__ == 14 && !defined __clang__ +#pragma GCC diagnostic pop +#endif } // anonymous namespace commit 7279deb50d0f1fe7e7a14579720d0e978f898e87 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Tue Jun 11 12:48:22 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 16:21:56 2024 +0100 sw: fix hyphenation dependencies of CppunitTests testTdf123898 fails locally but passes on Jenkins, because in Jenkins builds the hyphenation data doesn't exist yet (as verified by a CPPUNIT_ASSERT(xHyphenator->hasLocale(lang::Locale("de", "DE", OUString()))) in first revision of this patch. Add makefile dependencies to all sw tests that call hasLocale(). The test still needs to check though in case --without-myspell-dicts is used. Failure looks ignorable, adapt the test: Test name: (anonymous namespace)::testTdf123898::TestBody equality assertion failed - Expected: PortionType::Para - Actual : PortionType::Text Change-Id: Iaa94e248b01f7bab7f8451f6b0ff08a7d0a8e9b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168669 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 5f191abb7bebe46ef0c139076857d7b982763ce4) diff --git a/sw/CppunitTest_sw_odfexport2.mk b/sw/CppunitTest_sw_odfexport2.mk index 6ef306d5cd87..f85ef0fd1634 100644 --- a/sw/CppunitTest_sw_odfexport2.mk +++ b/sw/CppunitTest_sw_odfexport2.mk @@ -70,6 +70,14 @@ $(eval $(call gb_CppunitTest_use_uiconfigs,sw_odfexport2, \ $(eval $(call gb_CppunitTest_use_more_fonts,sw_odfexport2)) +ifneq ($(filter DICTIONARIES,$(BUILD_TYPE)),) +$(eval $(call gb_CppunitTest_use_packages,sw_odfexport2,\ + $(call gb_Dictionary_get_packagename,dict-de) \ + $(call gb_Dictionary_get_packagename,dict-en) \ + $(call gb_Dictionary_get_packagename,dict-hu) \ +)) +endif + $(eval $(call gb_CppunitTest_add_arguments,sw_odfexport2, \ -env:arg-env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \ )) diff --git a/sw/layoutwriter_setup.mk b/sw/layoutwriter_setup.mk index bfc9548fceef..80763139aee9 100644 --- a/sw/layoutwriter_setup.mk +++ b/sw/layoutwriter_setup.mk @@ -89,6 +89,14 @@ $(eval $(call gb_CppunitTest_set_non_application_font_use,sw_layoutwriter$(1),ab $(eval $(call gb_CppunitTest_use_more_fonts,sw_layoutwriter$(1))) +$(eval $(call gb_CppunitTest_use_packages,sw_layoutwriter$(1),\ + $(if $(filter DICTIONARIES,$(BUILD_TYPE)), + $(call gb_Dictionary_get_packagename,dict-de) \ + $(call gb_Dictionary_get_packagename,dict-en) \ + $(call gb_Dictionary_get_packagename,dict-hu) \ + ) \ +)) + endef # vim: set noet sw=4 ts=4: diff --git a/sw/ooxmlexport_setup.mk b/sw/ooxmlexport_setup.mk index ef1cbb3bffe9..6ead5e7f1481 100644 --- a/sw/ooxmlexport_setup.mk +++ b/sw/ooxmlexport_setup.mk @@ -86,6 +86,14 @@ $(call gb_CppunitTest_get_target,sw_ooxmlexport$(1)) : $(call gb_Library_get_tar $(eval $(call gb_CppunitTest_use_more_fonts,sw_ooxmlexport$(1))) +$(eval $(call gb_CppunitTest_use_packages,sw_ooxmlexport$(1),\ + $(if $(filter DICTIONARIES,$(BUILD_TYPE)), + $(call gb_Dictionary_get_packagename,dict-de) \ + $(call gb_Dictionary_get_packagename,dict-en) \ + $(call gb_Dictionary_get_packagename,dict-hu) \ + ) \ +)) + ifeq ($(OS),WNT) # gpgme-w32spawn.exe is needed in workdir/LinkTarget/Executable $(eval $(call gb_CppunitTest_use_packages,sw_ooxmlexport$(1),\ diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index 6acf3b4009ef..ea29afd4422c 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -1157,13 +1157,17 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf123898) // Make sure spellchecker has done its job already Scheduler::ProcessEventsToIdle(); + uno::Reference<linguistic2::XHyphenator> xHyphenator = LinguMgr::GetHyphenator(); + if (!xHyphenator->hasLocale(lang::Locale("de", "DE", OUString()))) + return; + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // Make sure that the arrow on the left is not there (the first portion's type is // PortionType::Arrow if it's there) assertXPath( pXmlDoc, "/root/page/body/txt/anchored/fly/txt/SwParaPortion/SwLineLayout[1]/child::*[1]"_ostr, - "type"_ostr, "PortionType::Para"); + "type"_ostr, "PortionType::Text"); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf123651) diff --git a/sw/uiwriter_setup.mk b/sw/uiwriter_setup.mk index 013cb3e29953..9f5fa172d92b 100644 --- a/sw/uiwriter_setup.mk +++ b/sw/uiwriter_setup.mk @@ -96,6 +96,14 @@ $(call gb_CppunitTest_get_target,sw_uiwriter$(1)) : $(call gb_Library_get_target $(eval $(call gb_CppunitTest_use_more_fonts,sw_uiwriter$(1))) +$(eval $(call gb_CppunitTest_use_packages,sw_uiwriter$(1),\ + $(if $(filter DICTIONARIES,$(BUILD_TYPE)), + $(call gb_Dictionary_get_packagename,dict-de) \ + $(call gb_Dictionary_get_packagename,dict-en) \ + $(call gb_Dictionary_get_packagename,dict-hu) \ + ) \ +)) + $(eval $(call gb_CppunitTest_add_arguments,sw_uiwriter$(1), \ -env:arg-env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \ )) commit 18be7cb81dce9020f72829cce16a57d1e03a9b88 Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Sat Dec 7 17:36:22 2024 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 14:38:15 2024 +0100 Fix check for further exotic protocols ...that were added in 59891cd3985469bc44dbd05c9fc704eeb07f0c78 "look at 'embedded' protocols for protocols that support them" Change-Id: I42836d6fd27cd99e39ab07e626053f002a2651f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178047 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> (cherry picked from commit 8075798b22f2188530f57b8747589923bfd419ef) diff --git a/tools/qa/cppunit/test_urlobj.cxx b/tools/qa/cppunit/test_urlobj.cxx index fff77e41f5e7..12635eba8dd3 100644 --- a/tools/qa/cppunit/test_urlobj.cxx +++ b/tools/qa/cppunit/test_urlobj.cxx @@ -354,6 +354,49 @@ namespace tools_urlobj } } + void testIsExoticProtocol() { + { + INetURLObject url(u"vnd.sun.star.pkg://slot%3A0"); + CPPUNIT_ASSERT_EQUAL(INetProtocol::VndSunStarPkg, url.GetProtocol()); + CPPUNIT_ASSERT(url.IsExoticProtocol()); + } + { + INetURLObject url(u"vnd.sun.star.pkg://vnd.sun.star.pkg%3A%2F%2Fslot%253A0"); + CPPUNIT_ASSERT_EQUAL(INetProtocol::VndSunStarPkg, url.GetProtocol()); + CPPUNIT_ASSERT(url.IsExoticProtocol()); + } + { + INetURLObject url(u"vnd.sun.star.pkg://http%3A%2F%2Fexample.net"); + CPPUNIT_ASSERT_EQUAL(INetProtocol::VndSunStarPkg, url.GetProtocol()); + CPPUNIT_ASSERT(!url.IsExoticProtocol()); + } + { + INetURLObject url(u"vnd.sun.star.zip://slot%3A0"); + CPPUNIT_ASSERT_EQUAL(INetProtocol::Generic, url.GetProtocol()); + CPPUNIT_ASSERT(url.IsExoticProtocol()); + } + { + INetURLObject url(u"vnd.sun.star.zip://slot%3A0/foo"); + CPPUNIT_ASSERT_EQUAL(INetProtocol::Generic, url.GetProtocol()); + CPPUNIT_ASSERT(url.IsExoticProtocol()); + } + { + INetURLObject url(u"vnd.sun.star.zip://slot%3A0?foo"); + CPPUNIT_ASSERT_EQUAL(INetProtocol::Generic, url.GetProtocol()); + CPPUNIT_ASSERT(url.IsExoticProtocol()); + } + { + INetURLObject url(u"vnd.sun.star.zip://slot%3A0#foo"); + CPPUNIT_ASSERT_EQUAL(INetProtocol::Generic, url.GetProtocol()); + CPPUNIT_ASSERT(url.IsExoticProtocol()); + } + { + INetURLObject url(u"vnd.sun.star.zip://http%3A%2F%2Fexample.net"); + CPPUNIT_ASSERT_EQUAL(INetProtocol::Generic, url.GetProtocol()); + CPPUNIT_ASSERT(!url.IsExoticProtocol()); + } + } + // Change the following lines only, if you add, remove or rename // member functions of the current class, // because these macros are need by auto register mechanism. @@ -371,6 +414,7 @@ namespace tools_urlobj CPPUNIT_TEST( testChangeScheme ); CPPUNIT_TEST( testTd146382 ); CPPUNIT_TEST( testParseSmart ); + CPPUNIT_TEST( testIsExoticProtocol ); CPPUNIT_TEST_SUITE_END( ); }; // class createPool diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 785fbd09404f..a9ce65ecb538 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -4891,10 +4891,21 @@ bool INetURLObject::IsExoticProtocol() const { return true; } - if (isSchemeEqualTo(u"vnd.sun.star.pkg") || isSchemeEqualTo(u"vnd.sun.star.zip")) + if (m_eScheme == INetProtocol::VndSunStarPkg) { + return INetURLObject(GetHost(INetURLObject::DecodeMechanism::WithCharset)) + .IsExoticProtocol(); + } + if (isSchemeEqualTo(u"vnd.sun.star.zip")) { - OUString sPayloadURL = GetURLPath(INetURLObject::DecodeMechanism::WithCharset); - return sPayloadURL.startsWith(u"//") && INetURLObject(sPayloadURL.subView(2)).IsExoticProtocol(); + OUString sPayloadURL = GetURLPath(INetURLObject::DecodeMechanism::NONE); + if (!sPayloadURL.startsWith(u"//")) { + return false; + } + auto const find = [&sPayloadURL](auto c) { + auto const n = sPayloadURL.indexOf(c, 2); + return n == -1 ? sPayloadURL.getLength() : n; + }; + return INetURLObject(decode(sPayloadURL.subView(2, std::min(find('/'), find('?')) - 2), INetURLObject::DecodeMechanism::WithCharset)).IsExoticProtocol(); } return false; } commit b7c5424cd0a14bc2c4e18acb21fd3d1741d094bc Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Dec 6 14:41:19 2024 +0000 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 14:36:57 2024 +0100 look at 'embedded' protocols too Change-Id: Ie99f5f5a390639bdc69397c831e0a32594a5030c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177981 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit 59891cd3985469bc44dbd05c9fc704eeb07f0c78) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177987 Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> (cherry picked from commit b63aa51c55244ee67410201fa5e7c003427b1009) diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 23204f43375b..785fbd09404f 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -4882,12 +4882,21 @@ OUString INetURLObject::CutExtension() bool INetURLObject::IsExoticProtocol() const { - return m_eScheme == INetProtocol::Slot || - m_eScheme == INetProtocol::Macro || - m_eScheme == INetProtocol::Uno || - m_eScheme == INetProtocol::VndSunStarExpand || - isSchemeEqualTo(u"vnd.sun.star.script") || - isSchemeEqualTo(u"service"); + if (m_eScheme == INetProtocol::Slot || + m_eScheme == INetProtocol::Macro || + m_eScheme == INetProtocol::Uno || + m_eScheme == INetProtocol::VndSunStarExpand || + isSchemeEqualTo(u"vnd.sun.star.script") || + isSchemeEqualTo(u"service")) + { + return true; + } + if (isSchemeEqualTo(u"vnd.sun.star.pkg") || isSchemeEqualTo(u"vnd.sun.star.zip")) + { + OUString sPayloadURL = GetURLPath(INetURLObject::DecodeMechanism::WithCharset); + return sPayloadURL.startsWith(u"//") && INetURLObject(sPayloadURL.subView(2)).IsExoticProtocol(); + } + return false; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 737b54d507b2a8402f3b52bbfc677bf089671dfc Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Nov 15 12:30:39 2024 +0000 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 14:30:00 2024 +0100 consider VndSunStarExpand an exotic protocol and generally don't bother with it when fetching data from urls Change-Id: I51a2601c6fb7d6c32f9e2d1286ee0d3b05b370b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176797 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit d6c89af2598e866aa9cb4fa3600691fb558befdb) diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx index 82ca1b92821c..7a6755e40052 100644 --- a/avmedia/source/viewer/mediawindow_impl.cxx +++ b/avmedia/source/viewer/mediawindow_impl.cxx @@ -170,15 +170,16 @@ void MediaWindowImpl::dispose() uno::Reference<media::XPlayer> MediaWindowImpl::createPlayer(const OUString& rURL, const OUString& rReferer, const OUString*) { - uno::Reference<media::XPlayer> xPlayer; - if( rURL.isEmpty() ) - return xPlayer; + return nullptr; if (SvtSecurityOptions::isUntrustedReferer(rReferer)) - { - return xPlayer; - } + return nullptr; + + if (INetURLObject(rURL).IsExoticProtocol()) + return nullptr; + + uno::Reference<media::XPlayer> xPlayer; // currently there isn't anything else, throw any mime type to the media players //if (!pMimeType || *pMimeType == AVMEDIA_MIMETYPE_COMMON) diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index 94b7704303ba..505cef2c58b1 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -4398,6 +4398,13 @@ const GraphicObject* SvxBrushItem::GetGraphicObject(OUString const & referer) co return nullptr; } + INetURLObject aGraphicURL( maStrLink ); + if (aGraphicURL.IsExoticProtocol()) + { + SAL_WARN("editeng", "Ignore exotic protocol: " << maStrLink); + return nullptr; + } + // tdf#94088 prepare graphic and state Graphic aGraphic; bool bGraphicLoaded = false; @@ -4418,8 +4425,6 @@ const GraphicObject* SvxBrushItem::GetGraphicObject(OUString const & referer) co // a 'data:' scheme url and try to load that (embedded graphics) if(!bGraphicLoaded) { - INetURLObject aGraphicURL( maStrLink ); - if( INetProtocol::Data == aGraphicURL.GetProtocol() ) { std::unique_ptr<SvMemoryStream> const xMemStream(aGraphicURL.getData()); diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx index 6859de216c24..f85830a8bd47 100644 --- a/embeddedobj/source/commonembedding/persistence.cxx +++ b/embeddedobj/source/commonembedding/persistence.cxx @@ -55,6 +55,7 @@ #include <comphelper/namedvaluecollection.hxx> #include <comphelper/propertyvalue.hxx> #include <unotools/configmgr.hxx> +#include <tools/urlobj.hxx> #include <unotools/mediadescriptor.hxx> #include <unotools/securityoptions.hxx> @@ -368,11 +369,19 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadLink_Impl() uno::Sequence< beans::PropertyValue > aArgs( m_aDocMediaDescriptor.getLength() + nLen ); auto pArgs = aArgs.getArray(); - pArgs[0].Name = "URL"; - if(m_aLinkTempFile.is()) - pArgs[0].Value <<= m_aLinkTempFile->getUri(); + OUString sURL; + if (m_aLinkTempFile.is()) + sURL = m_aLinkTempFile->getUri(); else - pArgs[0].Value <<= m_aLinkURL; + sURL = m_aLinkURL; + if (INetURLObject(sURL).IsExoticProtocol()) + { + SAL_WARN("embeddedobj.common", "Ignore exotic protocol: " << pArgs[0].Value); + return nullptr; + } + + pArgs[0].Name = "URL"; + pArgs[0].Value <<= sURL; pArgs[1].Name = "FilterName"; pArgs[1].Value <<= m_aLinkFilterName; diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx index e9fda79d224b..9dd71a2d42e4 100644 --- a/forms/source/component/ImageControl.cxx +++ b/forms/source/component/ImageControl.cxx @@ -401,7 +401,7 @@ bool OImageControlModel::impl_updateStreamForURL_lck( const OUString& _rURL, Val { OUString referer; getPropertyValue("Referer") >>= referer; - if (SvtSecurityOptions::isUntrustedReferer(referer)) { + if (SvtSecurityOptions::isUntrustedReferer(referer) || INetURLObject(_rURL).IsExoticProtocol()) { return false; } diff --git a/forms/source/component/clickableimage.cxx b/forms/source/component/clickableimage.cxx index 5d6a8f7a7f3d..9925c1c4b3a6 100644 --- a/forms/source/component/clickableimage.cxx +++ b/forms/source/component/clickableimage.cxx @@ -737,7 +737,7 @@ namespace frm // the SfxMedium is not allowed to be created with an invalid URL, so we have to check this first INetURLObject aUrl(rURL); - if (INetProtocol::NotValid == aUrl.GetProtocol()) + if (INetProtocol::NotValid == aUrl.GetProtocol() || aUrl.IsExoticProtocol()) // we treat an invalid URL like we would treat no URL return; diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx index a20501a1bad6..3412d727c656 100644 --- a/sfx2/source/appl/linkmgr2.cxx +++ b/sfx2/source/appl/linkmgr2.cxx @@ -534,8 +534,11 @@ bool LinkManager::GetGraphicFromAny(std::u16string_view rMimeType, sReferer = sh->GetMedium()->GetName(); OUString sURL = rValue.get<OUString>(); - if (!SvtSecurityOptions::isUntrustedReferer(sReferer)) + if (!SvtSecurityOptions::isUntrustedReferer(sReferer) && + !INetURLObject(sURL).IsExoticProtocol()) + { rGraphic = vcl::graphic::loadFromURL(sURL, pParentWin); + } if (rGraphic.IsNone()) rGraphic.SetDefaultType(); rGraphic.setOriginURL(sURL); diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index 072b8945d234..eb7d3404770b 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -673,7 +673,8 @@ IMAGE_SETEVENT: bool bNeedWidth = (!bPercentWidth && !nWidth) || bRelWidthScale; bool bRelHeightScale = bPercentHeight && nHeight == SwFormatFrameSize::SYNCED; bool bNeedHeight = (!bPercentHeight && !nHeight) || bRelHeightScale; - if ((bNeedWidth || bNeedHeight) && !bFuzzing && allowAccessLink(*m_xDoc)) + if ((bNeedWidth || bNeedHeight) && !bFuzzing && allowAccessLink(*m_xDoc) && + !aGraphicURL.IsExoticProtocol()) { GraphicDescriptor aDescriptor(aGraphicURL); if (aDescriptor.Detect(/*bExtendedInfo=*/true)) diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index 9a4f19e7481b..f842f74347af 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -31,6 +31,7 @@ #include <o3tl/safeint.hxx> #include <controls/formattedcontrol.hxx> #include <toolkit/controls/unocontrols.hxx> +#include <tools/urlobj.hxx> #include <helper/property.hxx> #include <toolkit/helper/macros.hxx> #include <unotools/securityoptions.hxx> @@ -69,7 +70,7 @@ css::uno::Reference< css::graphic::XGraphic > ImageHelper::getGraphicFromURL_nothrow( const OUString& _rURL, OUString const & referer ) { uno::Reference< graphic::XGraphic > xGraphic; - if ( _rURL.isEmpty() || SvtSecurityOptions::isUntrustedReferer(referer) ) + if (_rURL.isEmpty() || SvtSecurityOptions::isUntrustedReferer(referer) || INetURLObject(_rURL).IsExoticProtocol()) return xGraphic; try diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 18ee57b18ee4..23204f43375b 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -4885,6 +4885,7 @@ bool INetURLObject::IsExoticProtocol() const return m_eScheme == INetProtocol::Slot || m_eScheme == INetProtocol::Macro || m_eScheme == INetProtocol::Uno || + m_eScheme == INetProtocol::VndSunStarExpand || isSchemeEqualTo(u"vnd.sun.star.script") || isSchemeEqualTo(u"service"); } diff --git a/unotools/source/misc/mediadescriptor.cxx b/unotools/source/misc/mediadescriptor.cxx index f797728f7b3f..1fde1e426401 100644 --- a/unotools/source/misc/mediadescriptor.cxx +++ b/unotools/source/misc/mediadescriptor.cxx @@ -337,6 +337,10 @@ bool MediaDescriptor::impl_openStreamWithURL( const OUString& sURL, bool bLockFi if (sURL.matchIgnoreAsciiCase(".component:")) return false; // No UCB content for .component URLs + + if (INetURLObject(sURL).IsExoticProtocol()) + return false; + OUString referer(getUnpackedValueOrDefault(PROP_REFERRER, OUString())); if (SvtSecurityOptions::isUntrustedReferer(referer)) { return false; diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 25bcdd201ccd..a7e0ffe972a4 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -466,10 +466,16 @@ ErrCode GraphicFilter::CanImportGraphic( std::u16string_view rMainUrl, SvStream& ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, const INetURLObject& rPath, sal_uInt16 nFormat, sal_uInt16 * pDeterminedFormat, GraphicFilterImportFlags nImportFlags ) { - ErrCode nRetValue = ERRCODE_GRFILTER_FORMATERROR; SAL_WARN_IF( rPath.GetProtocol() == INetProtocol::NotValid, "vcl.filter", "GraphicFilter::ImportGraphic() : ProtType == INetProtocol::NotValid" ); OUString aMainUrl( rPath.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + if (rPath.IsExoticProtocol()) + { + SAL_WARN("vcl.filter", "GraphicFilter::ImportGraphic(), ignore exotic protocol: " << aMainUrl); + return ERRCODE_GRFILTER_FORMATERROR; + } + + ErrCode nRetValue = ERRCODE_GRFILTER_FORMATERROR; std::unique_ptr<SvStream> xStream(::utl::UcbStreamHelper::CreateStream( aMainUrl, StreamMode::READ | StreamMode::SHARE_DENYNONE )); if (xStream) { commit 9d651a826dc321f21b165c5946337772f43118b9 Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Tue Jun 11 14:15:47 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 13:42:42 2024 +0100 Some missing "block untrusted referer links" for form controls ...where "Referer" is now passed in as an additional property, so that the relevant objects can decide whether to obtain graphics while loading a document Change-Id: Ie3dabc574861713212b906a0d7793f438a7d50a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168674 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> (cherry picked from commit dc01a6e7efd3e4c41287dc10c7ea1fdfa1ab5cb5) diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx index c2bc0953c6c8..e9fda79d224b 100644 --- a/forms/source/component/ImageControl.cxx +++ b/forms/source/component/ImageControl.cxx @@ -52,6 +52,7 @@ #include <comphelper/property.hxx> #include <comphelper/types.hxx> #include <cppuhelper/queryinterface.hxx> +#include <unotools/securityoptions.hxx> #include <unotools/ucbstreamhelper.hxx> #include <svl/urihelper.hxx> @@ -398,6 +399,12 @@ void OImageControlModel::read(const Reference<XObjectInputStream>& _rxInStream) bool OImageControlModel::impl_updateStreamForURL_lck( const OUString& _rURL, ValueChangeInstigator _eInstigator ) { + OUString referer; + getPropertyValue("Referer") >>= referer; + if (SvtSecurityOptions::isUntrustedReferer(referer)) { + return false; + } + // create a stream for the image specified by the URL std::unique_ptr< SvStream > pImageStream; Reference< XInputStream > xImageStream; diff --git a/forms/source/component/clickableimage.cxx b/forms/source/component/clickableimage.cxx index e1f6f068faf0..5d6a8f7a7f3d 100644 --- a/forms/source/component/clickableimage.cxx +++ b/forms/source/component/clickableimage.cxx @@ -47,6 +47,7 @@ #include <comphelper/types.hxx> #include <cppuhelper/exc_hlp.hxx> #include <svtools/imageresourceaccess.hxx> +#include <unotools/securityoptions.hxx> #define LOCAL_URL_PREFIX '#' @@ -757,8 +758,12 @@ namespace frm m_bProdStarted = false; - // Kick off download (caution: can be synchronous). - m_pMedium->Download(LINK(this, OClickableImageBaseModel, DownloadDoneLink)); + OUString referer; + getPropertyValue("Referer") >>= referer; + if (!SvtSecurityOptions::isUntrustedReferer(referer)) { + // Kick off download (caution: can be synchronous). + m_pMedium->Download(LINK(this, OClickableImageBaseModel, DownloadDoneLink)); + } } else { diff --git a/include/toolkit/controls/unocontrols.hxx b/include/toolkit/controls/unocontrols.hxx index 1fba20389a8b..7c5c424fe276 100644 --- a/include/toolkit/controls/unocontrols.hxx +++ b/include/toolkit/controls/unocontrols.hxx @@ -70,7 +70,7 @@ public: // appropriately ( e.g. NULL if non GraphicObject scheme ) or a valid // object if the rURL points to a valid object static css::uno::Reference< css::graphic::XGraphic > getGraphicAndGraphicObjectFromURL_nothrow( css::uno::Reference< css::graphic::XGraphicObject >& xOutGraphicObject, const OUString& _rURL ); - static css::uno::Reference< css::graphic::XGraphic > getGraphicFromURL_nothrow( const OUString& _rURL ); + static css::uno::Reference< css::graphic::XGraphic > getGraphicFromURL_nothrow( const OUString& _rURL, OUString const & referer ); }; diff --git a/toolkit/inc/helper/property.hxx b/toolkit/inc/helper/property.hxx index 013f73496482..9a26e06a9902 100644 --- a/toolkit/inc/helper/property.hxx +++ b/toolkit/inc/helper/property.hxx @@ -205,6 +205,7 @@ namespace com::sun::star::uno { #define BASEPROPERTY_HIGHLIGHT_COLOR 169 #define BASEPROPERTY_HIGHLIGHT_TEXT_COLOR 170 #define BASEPROPERTY_TYPEDITEMLIST 171 // AnySequence +#define BASEPROPERTY_REFERER 172 // These properties are not bound, they are always extracted from the BASEPROPERTY_FONTDESCRIPTOR property diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index d6ba5e48a6e8..e156cd21b69d 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -206,6 +206,7 @@ namespace toolkit void VCLXGraphicControl::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds ) { + PushPropertyIds(rIds, BASEPROPERTY_REFERER, 0); VCLXWindow::ImplGetPropertyIds( rIds ); } diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx index ba954a15412a..6326d76bc581 100644 --- a/toolkit/source/controls/dialogcontrol.cxx +++ b/toolkit/source/controls/dialogcontrol.cxx @@ -418,7 +418,7 @@ void UnoDialogControl::PrepareWindowDescriptor( css::awt::WindowDescriptor& rDes ( !aImageURL.isEmpty() )) { OUString absoluteUrl = getPhysicalLocation(ImplGetPropertyValue(PROPERTY_DIALOGSOURCEURL), uno::Any(aImageURL)); - xGraphic = ImageHelper::getGraphicFromURL_nothrow( absoluteUrl ); + xGraphic = ImageHelper::getGraphicFromURL_nothrow( absoluteUrl, "" ); ImplSetPropertyValue( PROPERTY_GRAPHIC, uno::Any( xGraphic ), true ); } } @@ -633,7 +633,7 @@ void UnoDialogControl::ImplModelPropertiesChanged( const Sequence< PropertyChang ( !aImageURL.isEmpty() )) { OUString absoluteUrl = getPhysicalLocation(ImplGetPropertyValue(GetPropertyName(BASEPROPERTY_DIALOGSOURCEURL)), uno::Any(aImageURL)); - xGraphic = ImageHelper::getGraphicFromURL_nothrow( absoluteUrl ); + xGraphic = ImageHelper::getGraphicFromURL_nothrow( absoluteUrl, "" ); } ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC), uno::Any( xGraphic ), true ); break; diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index d9bc55f8cb45..9a4f19e7481b 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -33,6 +33,7 @@ #include <toolkit/controls/unocontrols.hxx> #include <helper/property.hxx> #include <toolkit/helper/macros.hxx> +#include <unotools/securityoptions.hxx> // for introspection #include <awt/vclxwindows.hxx> @@ -61,14 +62,14 @@ uno::Reference< graphic::XGraphic > ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( uno::Reference< graphic::XGraphicObject >& xOutGraphicObj, const OUString& _rURL ) { xOutGraphicObj = nullptr; - return ImageHelper::getGraphicFromURL_nothrow( _rURL ); + return ImageHelper::getGraphicFromURL_nothrow( _rURL, "" ); } css::uno::Reference< css::graphic::XGraphic > -ImageHelper::getGraphicFromURL_nothrow( const OUString& _rURL ) +ImageHelper::getGraphicFromURL_nothrow( const OUString& _rURL, OUString const & referer ) { uno::Reference< graphic::XGraphic > xGraphic; - if ( _rURL.isEmpty() ) + if ( _rURL.isEmpty() || SvtSecurityOptions::isUntrustedReferer(referer) ) return xGraphic; try @@ -605,7 +606,11 @@ void GraphicControlModel::setFastPropertyValue_NoBroadcast( std::unique_lock<std mbAdjustingGraphic = true; OUString sImageURL; OSL_VERIFY( rValue >>= sImageURL ); - setDependentFastPropertyValue( rGuard, BASEPROPERTY_GRAPHIC, uno::Any( ImageHelper::getGraphicFromURL_nothrow( sImageURL ) ) ); + css::uno::Any any; + getFastPropertyValue(rGuard, any, BASEPROPERTY_REFERER); + OUString referer; + any >>= referer; + setDependentFastPropertyValue( rGuard, BASEPROPERTY_GRAPHIC, uno::Any( ImageHelper::getGraphicFromURL_nothrow( sImageURL, referer ) ) ); mbAdjustingGraphic = false; } break; diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx index 945c4b016a64..db33e8a28ba6 100644 --- a/toolkit/source/helper/property.cxx +++ b/toolkit/source/helper/property.cxx @@ -271,6 +271,8 @@ static const ImpPropertyInfoMap & ImplGetPropertyInfos() DECL_PROP_3 ( "InactiveSelectionBackgroundColor", INACTIVE_SEL_BACKGROUND_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_PROP_3 ( "ActiveSelectionTextColor", ACTIVE_SEL_TEXT_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_PROP_3 ( "InactiveSelectionTextColor", INACTIVE_SEL_TEXT_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + + DECL_PROP_2("Referer", REFERER, OUString, BOUND, MAYBEVOID), }; return aImplPropertyInfos; } diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index d1d691d6519a..a46b8d2835f8 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -567,6 +567,15 @@ namespace xmloff OUStringToOString(m_sServiceName, RTL_TEXTENCODING_ASCII_US) + ")!").getStr()); xReturn.set(xPure, UNO_QUERY); + if (auto const props = Reference<css::beans::XPropertySet>(xPure, css::uno::UNO_QUERY)) + { + try { + props->setPropertyValue( + "Referer", css::uno::Any(m_rFormImport.getGlobalContext().GetBaseURL())); + } catch (css::uno::Exception &) { + TOOLS_INFO_EXCEPTION("xmloff.forms", "setPropertyValue Referer failed"); + } + } } else OSL_FAIL("OElementImport::createElement: no service name to create an element!"); commit 19c2a3004315a0976e0d43bed22c6eeb06df9eb9 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Nov 8 16:51:47 2024 +0000 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Dec 11 13:29:21 2024 +0100 be conservative on allowed temp font names Change-Id: Iefdc1a8c9b4c7e8c08c84f747f8287ac3c419839 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176236 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Jenkins (cherry picked from commit f761d098e9a0960554aa4fc02f84a711b50a1cff) diff --git a/vcl/source/gdi/embeddedfontshelper.cxx b/vcl/source/gdi/embeddedfontshelper.cxx index a8a4f7e983ba..b277806f131f 100644 --- a/vcl/source/gdi/embeddedfontshelper.cxx +++ b/vcl/source/gdi/embeddedfontshelper.cxx @@ -19,6 +19,7 @@ #include <vcl/svapp.hxx> #include <vcl/embeddedfontshelper.hxx> #include <com/sun/star/io/XInputStream.hpp> +#include <comphelper/storagehelper.hxx> #include <font/PhysicalFontFaceCollection.hxx> #include <font/PhysicalFontCollection.hxx> @@ -191,10 +192,6 @@ void EmbeddedFontsHelper::activateFonts() OUString EmbeddedFontsHelper::fileUrlForTemporaryFont( const OUString& fontName, std::u16string_view extra ) { - OUString path = "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}"; - rtl::Bootstrap::expandMacros( path ); - path += "/user/temp/embeddedfonts/fromdocs/"; - osl::Directory::createPath( path ); OUString filename = fontName; static int uniqueCounter = 0; if( extra == u"?" ) @@ -202,6 +199,17 @@ OUString EmbeddedFontsHelper::fileUrlForTemporaryFont( const OUString& fontName, else filename += extra; filename += ".ttf"; // TODO is it always ttf? + + if (!::comphelper::OStorageHelper::IsValidZipEntryFileName(filename, false)) + { + SAL_WARN( "vcl.fonts", "Cannot use filename: " << filename << " for temporary font"); + filename = "font" + OUString::number(uniqueCounter++) + ".ttf"; + } + + OUString path = "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}"; + rtl::Bootstrap::expandMacros( path ); + path += "/user/temp/embeddedfonts/fromdocs/"; + osl::Directory::createPath( path ); return path + filename; }