sc/inc/unonames.hxx | 1 + sc/qa/unit/subsequent_export_test4.cxx | 3 +-- sc/source/ui/unoobj/fielduno.cxx | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-)
New commits: commit 48dae1af66b227e72d58935d5719610c957da30d Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Fri Aug 22 22:44:44 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Fri Aug 22 21:36:26 2025 +0200 tdf#168066: implement Format property for Calc's URL field Inserting the field threw exception from SvxUnoTextBase::insertTextContent, because SvxFieldData::Create tried to access Format property of the field, which is documented in css::text::textfield::URL service. It is trivial to implement it, because the underlying SvxURLField already has it. Change-Id: I98ddb7ed554b4223922a9da7560a62a0202878b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190080 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 0d8fd9dbd696..1f8c01847666 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -341,6 +341,7 @@ inline constexpr OUString SC_UNONAME_TEXTFIELD_TYPE = u"TextFieldType"_ustr; inline constexpr OUString SC_UNONAME_REPR = u"Representation"_ustr; inline constexpr OUString SC_UNONAME_TARGET = u"TargetFrame"_ustr; inline constexpr OUString SC_UNONAME_URL = u"URL"_ustr; +inline constexpr OUString SC_UNONAME_FORMAT = u"Format"_ustr; // date time field inline constexpr OUString SC_UNONAME_ISDATE = u"IsDate"_ustr; diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index 9c0b90124e34..61548dfe43a3 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -2274,8 +2274,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf150229) xField->setPropertyValue(u"URL"_ustr, uno::Any(longUrl)); xField->setPropertyValue(u"Representation"_ustr, uno::Any(u"hyperlink"_ustr)); - xCell->insertTextContent(xCell->createTextCursor(), xField.queryThrow<text::XTextContent>(), - false); + xCell->insertTextContent(xCell->getEnd(), xField.queryThrow<text::XTextContent>(), false); } // Test XLSX export: the hyperlink must truncate at 8192 character boundary diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx index 6e6e06fa7453..b47e47cc3d36 100644 --- a/sc/source/ui/unoobj/fielduno.cxx +++ b/sc/source/ui/unoobj/fielduno.cxx @@ -81,6 +81,7 @@ const SfxItemPropertySet* lcl_GetURLPropertySet() { SC_UNONAME_TARGET, 0, cppu::UnoType<OUString>::get(), 0, 0}, { SC_UNONAME_TEXTWRAP, 0, cppu::UnoType<text::WrapTextMode>::get(), beans::PropertyAttribute::READONLY, 0 }, { SC_UNONAME_URL, 0, cppu::UnoType<OUString>::get(), 0, 0}, + { SC_UNONAME_FORMAT, 0, cppu::UnoType<sal_Int16>::get(), 0, 0 }, }; static SfxItemPropertySet aURLPropertySet_Impl( aURLPropertyMap_Impl ); return &aURLPropertySet_Impl; @@ -644,6 +645,11 @@ void ScEditFieldObj::setPropertyValueURL(const OUString& rName, const css::uno:: if (rVal >>= aStrVal) pURL->SetTargetFrame(aStrVal); } + else if (rName == SC_UNONAME_FORMAT) + { + if (sal_Int16 nVal; rVal >>= nVal) + pURL->SetFormat(static_cast<SvxURLFormat>(nVal)); + } else throw beans::UnknownPropertyException(rName); @@ -703,6 +709,8 @@ uno::Any ScEditFieldObj::getPropertyValueURL(const OUString& rName) aRet <<= pURL->GetRepresentation(); else if (rName == SC_UNONAME_TARGET) aRet <<= pURL->GetTargetFrame(); + else if (rName == SC_UNONAME_FORMAT) + aRet <<= static_cast<sal_Int16>(pURL->GetFormat()); else throw beans::UnknownPropertyException(rName); } @@ -716,6 +724,8 @@ uno::Any ScEditFieldObj::getPropertyValueURL(const OUString& rName) aRet <<= rURL.GetRepresentation(); else if (rName == SC_UNONAME_TARGET) aRet <<= rURL.GetTargetFrame(); + else if (rName == SC_UNONAME_FORMAT) + aRet <<= static_cast<sal_Int16>(rURL.GetFormat()); else throw beans::UnknownPropertyException(rName); }