sw/qa/core/data/odt/tdf155780_filename_display_format.odt |binary
 sw/qa/core/macros-test.cxx                                |   14 ++++++++++++++
 sw/source/core/unocore/unofield.cxx                       |    6 ------
 3 files changed, 14 insertions(+), 6 deletions(-)

New commits:
commit 2a6ab94b377443cae0514cbd9049508379a0ac40
Author:     Andreas Heinisch <[email protected]>
AuthorDate: Tue Dec 2 20:08:07 2025 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Fri Dec 12 09:54:27 2025 +0100

    tdf#155780 - Provide correct value for FileName field
    
    Removed the invalid and redundant value assignment to the filename
    field, since the value had already been correctly set by the prior cast
    to SwFileNameFormat.
    
    Change-Id: Id04bd32ebe91fc1e15305886461d210246984918
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194935
    Tested-by: Jenkins
    Reviewed-by: Andreas Heinisch <[email protected]>
    (cherry picked from commit c44271e0f026674be9d89a33e5c37adf4f0a3568)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195488
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sw/qa/core/data/odt/tdf155780_filename_display_format.odt 
b/sw/qa/core/data/odt/tdf155780_filename_display_format.odt
new file mode 100644
index 000000000000..8331957427cb
Binary files /dev/null and 
b/sw/qa/core/data/odt/tdf155780_filename_display_format.odt differ
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 6d4512bfb0f0..d6c260992de2 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -69,6 +69,7 @@ public:
     void testBookmarkDeleteTdf90816();
     void testControlShapeGrouping();
     void testTdf151846();
+    void testTdf155780_filename_display_format();
     void testTdf162431();
     void testFdo55289();
     void testFdo68983();
@@ -82,6 +83,7 @@ public:
     CPPUNIT_TEST(testBookmarkDeleteTdf90816);
     CPPUNIT_TEST(testControlShapeGrouping);
     CPPUNIT_TEST(testTdf151846);
+    CPPUNIT_TEST(testTdf155780_filename_display_format);
     CPPUNIT_TEST(testTdf162431);
     CPPUNIT_TEST(testFdo55289);
     CPPUNIT_TEST(testFdo68983);
@@ -359,6 +361,18 @@ void SwMacrosTest::testTdf151846()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeq.getLength());
 }
 
+void SwMacrosTest::testTdf155780_filename_display_format()
+{
+    loadFromFile(u"odt/tdf155780_filename_display_format.odt");
+
+    uno::Any aRet = executeMacro(
+        
u"vnd.sun.Star.script:Standard.Module1.testFilenameDisplayFormat?language=Basic&location=document"_ustr);
+
+    OUString aStringRes;
+    CPPUNIT_ASSERT(aRet >>= aStringRes);
+    CPPUNIT_ASSERT_EQUAL(u"OK"_ustr, aStringRes);
+}
+
 void SwMacrosTest::testTdf162431()
 {
     loadFromFile(u"odt/tdf162431.odt");
diff --git a/sw/source/core/unocore/unofield.cxx 
b/sw/source/core/unocore/unofield.cxx
index 63334c2cfc86..8ffc5e468058 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1452,9 +1452,6 @@ void SAL_CALL SwXTextField::attach(
                 xField.reset(pFNField);
                 if (!m_pImpl->m_pProps->sPar3.isEmpty())
                     pFNField->SetExpansion(m_pImpl->m_pProps->sPar3);
-                uno::Any aFormat;
-                aFormat <<= m_pImpl->m_pProps->nFormat;
-                xField->PutValue( aFormat, FIELD_PROP_FORMAT );
             }
             break;
             case SwServiceType::FieldTypeTemplateName:
@@ -1462,9 +1459,6 @@ void SAL_CALL SwXTextField::attach(
                 SwFieldType* pFieldType = 
pDoc->getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::TemplateName);
                 xField.reset(new 
SwTemplNameField(static_cast<SwTemplNameFieldType*>(pFieldType),
                                             
static_cast<SwFileNameFormat>(m_pImpl->m_pProps->nFormat)));
-                uno::Any aFormat;
-                aFormat <<= m_pImpl->m_pProps->nFormat;
-                xField->PutValue(aFormat, FIELD_PROP_FORMAT);
             }
             break;
             case SwServiceType::FieldTypeChapter:

Reply via email to