writerfilter/source/dmapper/TagLogger.cxx | 10 ++++++++++ writerfilter/source/dmapper/TagLogger.hxx | 5 +++++ 2 files changed, 15 insertions(+)
New commits: commit 6522d0f44a92f8102f50f94e26c6d7140fd7fd44 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Wed Dec 28 21:15:24 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Thu Dec 29 07:56:56 2022 +0000 Properly print floats ...avoiding > /writerfilter/source/dmapper/PropertyMap.cxx:324:71: runtime error: -2539 is outside the range of representable values of type 'unsigned int' > #0 0x7f80e9a3b6c3 in writerfilter::dmapper::PropertyMap::dumpXml() const /writerfilter/source/dmapper/PropertyMap.cxx:324:71 > #1 0x7f80e928eccb in writerfilter::dmapper::DomainMapperTableHandler::endTableGetTableStyle(writerfilter::dmapper::TableInfo&, std::__debug::vector<com::sun::star::beans::PropertyValue, std::allocator<com::sun::star::beans::PropertyValue> >&, bool) /writerfilter/source/dmapper/DomainMapperTableHandler.cxx:434:40 > #2 0x7f80e92b4b8f in writerfilter::dmapper::DomainMapperTableHandler::endTable(unsigned int, bool) /writerfilter/source/dmapper/DomainMapperTableHandler.cxx:1377:30 > #3 0x7f80e9c289de in writerfilter::dmapper::TableManager::resolveCurrentTable() /writerfilter/source/dmapper/TableManager.cxx:409:33 > #4 0x7f80e9c297a1 in writerfilter::dmapper::TableManager::endLevel() /writerfilter/source/dmapper/TableManager.cxx:427:9 > #5 0x7f80e936a997 in writerfilter::dmapper::DomainMapperTableManager::endLevel() /writerfilter/source/dmapper/DomainMapperTableManager.cxx:497:19 > #6 0x7f80e9c256d1 in writerfilter::dmapper::TableManager::endParagraphGroup() /writerfilter/source/dmapper/TableManager.cxx:338:9 > #7 0x7f80e9205974 in writerfilter::dmapper::DomainMapper::lcl_endParagraphGroup() /writerfilter/source/dmapper/DomainMapper.cxx:3511:35 > #8 0x7f80e984598e in writerfilter::LoggedStream::endParagraphGroup() /writerfilter/source/dmapper/LoggedResources.cxx:108:5 > #9 0x7f80e9d9addf in writerfilter::ooxml::OOXMLFastContextHandler::endParagraphGroup() /writerfilter/source/ooxml/OOXMLFastContextHandler.cxx:452:23 > #10 0x7f80ea042658 in writerfilter::ooxml::OOXMLFactory_wml::endAction(writerfilter::ooxml::OOXMLFastContextHandler*) /workdir/CustomTarget/writerfilter/source/ooxml/OOXMLFactory_wml.cxx:7574:19 > #11 0x7f80e9d8822a in writerfilter::ooxml::OOXMLFactory::endAction(writerfilter::ooxml::OOXMLFastContextHandler*) /writerfilter/source/ooxml/OOXMLFactory.cxx:157:19 > #12 0x7f80e9d944eb in writerfilter::ooxml::OOXMLFastContextHandler::lcl_endFastElement(int) /writerfilter/source/ooxml/OOXMLFastContextHandler.cxx:242:5 > #13 0x7f80e9d941da in writerfilter::ooxml::OOXMLFastContextHandler::endFastElement(int) /writerfilter/source/ooxml/OOXMLFastContextHandler.cxx:225:9 > #14 0x7f80f44ffe2a in (anonymous namespace)::Entity::endElement() /sax/source/fastparser/fastparser.cxx:515:27 > #15 0x7f80f44ff818 in sax_fastparser::FastSaxParserImpl::callbackEndElement() /sax/source/fastparser/fastparser.cxx:1343:17 > #16 0x7f80f44ef554 in (anonymous namespace)::call_callbackEndElement(void*, unsigned char const*, unsigned char const*, unsigned char const*) /sax/source/fastparser/fastparser.cxx:339:18 > #17 0x7f8179cde54a in xmlParseEndTag2 /workdir/UnpackedTarball/libxml2/parser.c:9742:2 > #18 0x7f8179c8ced0 in xmlParseTryOrFinish /workdir/UnpackedTarball/libxml2/parser.c:11642:14 > #19 0x7f8179c7acc9 in xmlParseChunk /workdir/UnpackedTarball/libxml2/parser.c:12351:13 > #20 0x7f80f44ea4f1 in sax_fastparser::FastSaxParserImpl::parse() /sax/source/fastparser/fastparser.cxx:1099:21 > #21 0x7f80f44e4146 in sax_fastparser::FastSaxParserImpl::parseStream(com::sun::star::xml::sax::InputSource const&) /sax/source/fastparser/fastparser.cxx:904:9 > #22 0x7f80f4505300 in sax_fastparser::FastSaxParser::parseStream(com::sun::star::xml::sax::InputSource const&) /sax/source/fastparser/fastparser.cxx:1482:13 > #23 0x7f80e9d46e98 in writerfilter::ooxml::OOXMLDocumentImpl::resolve(writerfilter::Stream&) /writerfilter/source/ooxml/OOXMLDocumentImpl.cxx:508:18 > #24 0x7f80e9cfed05 in (anonymous namespace)::WriterFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /writerfilter/source/filter/WriterFilter.cxx:208:24 > #25 0x7f8149202866 in SfxObjectShell::ImportFrom(SfxMedium&, com::sun::star::uno::Reference<com::sun::star::text::XTextRange> const&) /sfx2/source/doc/objstor.cxx:2272:34 > #26 0x7f81491c2434 in SfxObjectShell::DoLoad(SfxMedium*) /sfx2/source/doc/objstor.cxx:739:23 > #27 0x7f81493c9870 in SfxBaseModel::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /sfx2/source/doc/sfxbasemodel.cxx:1937:36 > #28 0x7f8149b20d71 in (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) /sfx2/source/view/frmload.cxx:720:28 > #29 0x7f810e00256b in framework::LoadEnv::impl_loadContent() /framework/source/loadenv/loadenv.cxx:1167:37 > #30 0x7f810dff896b in framework::LoadEnv::start() /framework/source/loadenv/loadenv.cxx:403:20 > #31 0x7f810dff0dec in framework::LoadEnv::startLoading(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, rtl::OUString const&, int, LoadEnvFeatures) /framework/source/loadenv/loadenv.cxx:308:5 > #32 0x7f810dfec180 in framework::LoadEnv::loadComponentFromURL(com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader> const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /framework/source/loadenv/loadenv.cxx:168:14 > #33 0x7f810e0b541d in framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /framework/source/services/desktop.cxx:604:16 > #34 0x7f810e0b5646 in non-virtual thunk to framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /framework/source/services/desktop.cxx > #35 0x7f812a050c25 in unotest::MacrosTest::loadFromDesktop(rtl::OUString const&, rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /unotest/source/cpp/macros_test.cxx:70:62 > #36 0x7f81444fcad9 in UnoApiTest::load(rtl::OUString const&, char const*) /test/source/unoapi_test.cxx:115:11 > #37 0x7f812a8ae042 in SwModelTestBase::loadURL(rtl::OUString const&, char const*, char const*) /sw/qa/unit/swmodeltestbase.cxx:449:20 > #38 0x7f812a8b9452 in SwModelTestBase::load(char const*, char const*) /sw/qa/inc/swmodeltestbase.hxx:351:16 > #39 0x7f812a8af516 in SwModelTestBase::loadAndSave(char const*) /sw/qa/unit/swmodeltestbase.cxx:502:5 > #40 0x7f814fcfe242 in testTableThemePreservation::TestBody() /sw/qa/extras/ooxmlexport/ooxmlexport3.cxx:888:5 during CppunitTest_sw_ooxmlexport3 (<https://ci.libreoffice.org//job/lo_ubsan/2629/>). (The overload for is_integral parameters is needed now to avoid ambiguity errors when integer types other than sal_uInt32 could also match the newly added float overload.) Change-Id: I6482bccef2442655359c71e13f0c9bfe7e4d9dd4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144855 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/writerfilter/source/dmapper/TagLogger.cxx b/writerfilter/source/dmapper/TagLogger.cxx index 607f01aaf42f..69ffbbc09f39 100644 --- a/writerfilter/source/dmapper/TagLogger.cxx +++ b/writerfilter/source/dmapper/TagLogger.cxx @@ -175,6 +175,16 @@ namespace writerfilter xmlFree( xmlName ); } + void TagLogger::attribute(const std::string & name, float value) + { + if (!pWriter) + return; + xmlChar* xmlName = xmlCharStrdup( name.c_str() ); + (void)xmlTextWriterWriteFormatAttribute( pWriter, xmlName, + "%f", value ); + xmlFree( xmlName ); + } + void TagLogger::attribute(const std::string & name, const uno::Any& aAny) { if (!pWriter) diff --git a/writerfilter/source/dmapper/TagLogger.hxx b/writerfilter/source/dmapper/TagLogger.hxx index 33da346eec12..f3ab1575dba3 100644 --- a/writerfilter/source/dmapper/TagLogger.hxx +++ b/writerfilter/source/dmapper/TagLogger.hxx @@ -24,6 +24,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <string> #include <string_view> +#include <type_traits> #include <libxml/xmlwriter.h> namespace writerfilter @@ -54,6 +55,10 @@ namespace writerfilter #ifdef DBG_UTIL void attribute(const std::string & name, std::u16string_view value); void attribute(const std::string & name, sal_uInt32 value); + template<typename T> std::enable_if_t<std::is_integral_v<T>, void> + attribute(const std::string & name, T value) + { return attribute(name, static_cast<sal_uInt32>(value)); } + void attribute(const std::string & name, float value); void attribute(const std::string & name, const css::uno::Any& aAny); void chars(const std::string & chars); void chars(std::u16string_view chars);