sw/qa/extras/rtfexport/data/tdf108505_fieldCharFormat.rtf |   34 ++++++++++++++
 sw/qa/extras/rtfexport/rtfexport6.cxx                     |   14 +++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx         |   11 ++++
 3 files changed, 58 insertions(+), 1 deletion(-)

New commits:
commit c1ac4185afc496e0af18175a6ad31c14fe43ebb3
Author:     Justin Luth <[email protected]>
AuthorDate: Fri Dec 1 10:34:36 2023 -0500
Commit:     Thorsten Behrens <[email protected]>
CommitDate: Wed Dec 13 00:24:36 2023 +0100

    tdf#108505 writerfilter: fix legacy dropdown fields direct bold setting
    
    Any character property should be passed on,
    but do that in a follow-up commit, so that
    at least the bold case will remain intact
    if the broader fix gets reverted for any reason.
    
    make CppunitTest_sw_rtfexport6 \
        CPPUNIT_TEST_NAME=testTdf108505_fieldCharFormat
    
    Change-Id: Id77980b704db2ff118e89c29eb9d4db82e117cdc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160221
    Reviewed-by: Justin Luth <[email protected]>
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160626
    Reviewed-by: Thorsten Behrens <[email protected]>

diff --git a/sw/qa/extras/rtfexport/data/tdf108505_fieldCharFormat.rtf 
b/sw/qa/extras/rtfexport/data/tdf108505_fieldCharFormat.rtf
new file mode 100644
index 000000000000..b05c2deec6b6
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf108505_fieldCharFormat.rtf
@@ -0,0 +1,34 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff0\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang2057\deflangfe2057\themelang3079\themelangfe0\themelangcs0
+
+\noqfpromote {\stylesheet{\ql 
\li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0
 \rtlch\fcs1 
+\af0\afs20\alang1025 \ltrch\fcs0 
\fs26\lang1031\langfe3079\cgrid\langnp1031\langfenp3079 \snext0 \sqformat 
\spriority0 Normal;}{\s17\ql \li0\ri0\widctlpar
+\tqc\tx4819\tqr\tx9071\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0
 \rtlch\fcs1 \af0\afs20\alang1025 \ltrch\fcs0 
\fs26\lang1031\langfe3079\cgrid\langnp1031\langfenp3079 \sbasedon0 \snext17 
\slink18 header;}
+}
+\paperw16834\paperh11913\margl1134\margr1418\margt1418\margb567\gutter0\ltrsect
 
+\deftab708\widowctrl\ftnbj\aenddoc\hyphhotz425\trackmoves0\trackformatting1\donotembedsysfont0\relyonvml0\donotembedlingdata0\grfdocevents0\validatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0
+\showxmlerrors1\noextrasprl\prcolbl\cvmme\sprsspbf\brkfrm\swpbdr\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\lytprtmet\hyphcaps0\formshade\horzdoc\fracwidth\dghspace180\dgvspace180\dghorigin1701\dgvorigin1984\dghshow0\dgvshow0
+\jexpand\viewkind1\viewscale70\pgbrdrhead\pgbrdrfoot\nolnhtadjtbl\nojkernpunct\rsidroot3825670
 \fet0
+
+\ltrrow\trowd \irow0\irowband0\lastrow \ltrrow
+\ts11\trgaph70\trleft-70\trkeep\trftsWidth3\trwWidth8931\trftsWidthB3\trftsWidthA3\trpaddl70\trpaddr70\trpaddfl3\trpaddfr3\tblrsid16408416\tblind0\tblindtype3
 \clvertalc\clbrdrt\brdrtbl \clbrdrl\brdrtbl \clbrdrb\brdrtbl \clbrdrr\brdrtbl 
+\cltxlrtb\clftsWidth3\clwWidth1276\clshdrawnil 
\cellx1206\clvertalc\clbrdrt\brdrtbl \clbrdrl\brdrtbl \clbrdrb\brdrtbl 
\clbrdrr\brdrs\brdrw30 \cltxlrtb\clftsWidth3\clwWidth3969\clshdrawnil 
\cellx5175\clvertalt\clbrdrt\brdrs\brdrw30 \clbrdrl\brdrs\brdrw30 
+\clbrdrb\brdrs\brdrw30 \clbrdrr\brdrs\brdrw30 
\cltxlrtb\clftsWidth3\clwWidth2126\clshdrawnil 
\cellx7301\clvertalt\clbrdrt\brdrtbl \clbrdrl\brdrs\brdrw30 \clbrdrb\brdrtbl 
\clbrdrr\brdrs\brdrw30 \cltxlrtb\clftsWidth3\clwWidth1560\clshdrawnil \cellx8861
+\pard\plain \ltrpar\s17\ql 
\li72\ri0\sb120\sa120\widctlpar\intbl\tqr\tx1561\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin72\pararsid8918882
 \rtlch\fcs1 \af0\afs20\alang1025 \ltrch\fcs0 
\fs26\lang1031\langfe3079\cgrid\langnp1031\langfenp3079
+
+{\fonttbl{\f0\froman\fprq2\fcharset0 Times New 
Roman;}{\f5\fnil\fprq2\fcharset128 Linux Biolinum Keyboard O;}}
+
+{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}
+
+{\rtlch\fcs1 \af0 \ltrch\fcs0 \f5\fs32\chcbpat7\insrsid16408416 
Header}{\rtlch\fcs1 \af0 \ltrch\fcs0 \fs32\insrsid16408416\charrsid8918882 
\cell }\pard\plain \ltrpar\ql 
\li0\ri0\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\pararsid5246913
 
+\rtlch\fcs1 \af0\afs20\alang1025 \ltrch\fcs0 
\fs26\lang1031\langfe3079\cgrid\langnp1031\langfenp3079 {\rtlch\fcs1 \af0 
\ltrch\fcs0 \insrsid16408416\charrsid8918882 Normal\cell }\pard \ltrpar
+\qc 
\li0\ri0\sb120\sa120\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0
 {\rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid5701682\charrsid5701682 {\*\bkmkstart 
Dropdown1}x}{\field\fldpriv{\*\fldinst {\ltrch\fcs0 
+\b\fs48\cf4  FORMDROPDOWN }{{\*\datafield 0abcd}
+{\*\formfield{\fftype2\ffres25\fftypetxt0\ffhaslistbox{\*\ffname 
Dropdown1}\ffdefres0{\*\ffl MZ}{\*\ffl MVB}}}}}
+{\fldrslt \i\cf6 bogus result}}
+\sectd \ltrsect
+\lndscpsxn\binfsxn4\binsxn4\linex0\headery851\sectlinegrid354\sectdefaultcl\sectrsid1197700\sftnbj
 {\rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid5701682\charrsid5701682 {\*\bkmkend 
Dropdown1}y}{ 
+\cell }{\rtlch\fcs1 \af0 \ltrch\fcs0 \b\fs32\insrsid16408416\charrsid4871016 
bold16\cell }\pard \ltrpar\ql 
\li0\ri0\sa200\sl276\slmult1\widctlpar\intbl\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0
 {\trowd \irow0\irowband0\lastrow 
\ltrrow\ts11\trgaph70\trleft-70\trkeep\trftsWidth3\trwWidth8931\trftsWidthB3\trftsWidthA3\trpaddl70\trpaddr70\trpaddfl3\trpaddfr3\tblrsid16408416\tblind0\tblindtype3
 \clvertalc\clbrdrt\brdrtbl 
+\clbrdrl\brdrtbl \clbrdrb\brdrtbl \clbrdrr\brdrtbl 
\cltxlrtb\clftsWidth3\clwWidth1276\clshdrawnil 
\cellx1206\clvertalc\clbrdrt\brdrtbl \clbrdrl\brdrtbl \clbrdrb\brdrtbl 
\clbrdrr\brdrs\brdrw30 \cltxlrtb\clftsWidth3\clwWidth3969\clshdrawnil \cellx5175
+\clvertalt\clbrdrt\brdrs\brdrw30 \clbrdrl\brdrs\brdrw30 \clbrdrb\brdrs\brdrw30 
\clbrdrr\brdrs\brdrw30 \cltxlrtb\clftsWidth3\clwWidth2126\clshdrawnil 
\cellx7301\clvertalt\clbrdrt\brdrtbl \clbrdrl\brdrs\brdrw30 \clbrdrb\brdrtbl 
\clbrdrr\brdrs\brdrw30 
+\cltxlrtb\clftsWidth3\clwWidth1560\clshdrawnil \cellx8861\row }\pard
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport6.cxx 
b/sw/qa/extras/rtfexport/rtfexport6.cxx
index 1d11581aba78..6baa86e3079a 100644
--- a/sw/qa/extras/rtfexport/rtfexport6.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport6.cxx
@@ -160,6 +160,20 @@ DECLARE_RTFEXPORT_TEST(testTdf86814, "tdf86814.rtf")
                          getProperty<float>(getRun(getParagraph(1), 1), 
"CharWeight"));
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf108505_fieldCharFormat, 
"tdf108505_fieldCharFormat.rtf")
+{
+    uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), 
uno::UNO_QUERY);
+    uno::Reference<text::XTextRange> xCell(xTable->getCellByName("C1"), 
uno::UNO_QUERY);
+    uno::Reference<text::XTextRange> xPara = getParagraphOfText(1, 
xCell->getText());
+
+    // Character formatting can be defined inside the field for part of it. It 
wasn't being applied.
+    // Bold and green are specified. \fldrslt's "bogus result" (with 
italic/red) should be ignored.
+    uno::Reference<text::XTextRange> xRun = getRun(xPara, 3, "MZ");
+    CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xRun, 
"CharWeight"));
+    CPPUNIT_ASSERT_EQUAL(awt::FontSlant_NONE, 
getProperty<awt::FontSlant>(xRun, "CharPosture"));
+    // CPPUNIT_ASSERT_EQUAL(COL_LIGHTGREEN, getProperty<Color>(xRun, 
"CharColor"));
+}
+
 /** Make sure that the document variable "Unused", which is not referenced in 
the document,
     is imported and exported. */
 DECLARE_RTFEXPORT_TEST(testTdf150267, "tdf150267.rtf")
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 9e90f132b76e..d6775189d8cb 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -7059,7 +7059,10 @@ void DomainMapper_Impl::CloseFieldCommand()
         OUString const sFirstParam(vArguments.empty() ? OUString() : 
vArguments.front());
 
         // apply font size to the form control
-        if (!m_aTextAppendStack.empty() &&  m_pLastCharacterContext && ( 
m_pLastCharacterContext->isSet(PROP_CHAR_HEIGHT) || 
m_pLastCharacterContext->isSet(PROP_CHAR_FONT_NAME )))
+        if (!m_aTextAppendStack.empty() && m_pLastCharacterContext
+            && (m_pLastCharacterContext->isSet(PROP_CHAR_HEIGHT)
+                || m_pLastCharacterContext->isSet(PROP_CHAR_FONT_NAME)
+                || m_pLastCharacterContext->isSet(PROP_CHAR_WEIGHT)))
         {
             uno::Reference< text::XTextAppend >  xTextAppend = 
m_aTextAppendStack.top().xTextAppend;
             if (xTextAppend.is())
@@ -7075,6 +7078,12 @@ void DomainMapper_Impl::CloseFieldCommand()
                         if 
(m_pLastCharacterContext->isSet(PROP_CHAR_HEIGHT_COMPLEX))
                             
xProp->setPropertyValue(getPropertyName(PROP_CHAR_HEIGHT_COMPLEX), 
m_pLastCharacterContext->getProperty(PROP_CHAR_HEIGHT_COMPLEX)->second);
                     }
+                    if (m_pLastCharacterContext->isSet(PROP_CHAR_WEIGHT))
+                    {
+                        
xProp->setPropertyValue(getPropertyName(PROP_CHAR_WEIGHT), 
m_pLastCharacterContext->getProperty(PROP_CHAR_WEIGHT)->second);
+                        if 
(m_pLastCharacterContext->isSet(PROP_CHAR_WEIGHT_COMPLEX))
+                            
xProp->setPropertyValue(getPropertyName(PROP_CHAR_WEIGHT_COMPLEX), 
m_pLastCharacterContext->getProperty(PROP_CHAR_WEIGHT_COMPLEX)->second);
+                    }
                     if (m_pLastCharacterContext->isSet(PROP_CHAR_FONT_NAME))
                         
xProp->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME), 
m_pLastCharacterContext->getProperty(PROP_CHAR_FONT_NAME)->second);
                 }

Reply via email to