[Libreoffice-commits] core.git: sw/qa writerfilter/inc writerfilter/source
Justin Luth (via logerrit)
logerrit at kemper.freedesktop.org
Wed Apr 14 10:24:07 UTC 2021
sw/qa/extras/rtfexport/data/tdf100961_fixedDateTime.rtf | 38 ++++++++++++++++
sw/qa/extras/rtfexport/rtfexport3.cxx | 12 +++++
writerfilter/inc/dmapper/resourcemodel.hxx | 1
writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 1
writerfilter/source/rtftok/rtfdispatchdestination.cxx | 1
writerfilter/source/rtftok/rtfdispatchflag.cxx | 6 ++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 4 +
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 3 +
8 files changed, 65 insertions(+), 1 deletion(-)
New commits:
commit 4ed7a2c8af03bc0f45df1f03fd160ccbf045ed4f
Author: Justin Luth <justin_luth at sil.org>
AuthorDate: Tue Apr 13 17:57:58 2021 +0200
Commit: Justin Luth <justin_luth at sil.org>
CommitDate: Wed Apr 14 12:23:25 2021 +0200
tdf#100961 rtf import: fldlock is FIXEDFLD
This depends on another fix in this bug report for
exporting.
I'm not sure why I even bother trying to work
on RTF stuff. I'm not really into black magic.
Change-Id: If596cae011a261a80ca13962932bf25561c0f63f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114062
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth at sil.org>
diff --git a/sw/qa/extras/rtfexport/data/tdf100961_fixedDateTime.rtf b/sw/qa/extras/rtfexport/data/tdf100961_fixedDateTime.rtf
new file mode 100644
index 000000000000..95f28e34ddbb
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf100961_fixedDateTime.rtf
@@ -0,0 +1,38 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff1\deff0\stshfdbch42\stshfloch41\stshfhich41\stshfbi1\deflang2057\deflangfe2057{\fonttbl{\f1\fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial;}{\f36\fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Liberation Sans{\*\falt Arial};}
+{\f41\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Liberation Serif{\*\falt Times New Roman};}{\f42\fmodern\fcharset134\fprq1{\*\panose 02010609030101010101}NSimSun;}{\f43\fswiss\fcharset134\fprq2{\*\panose 020b0503020204020204}Microsoft YaHei;}
+{\f72\fmodern\fcharset134\fprq1{\*\panose 00000000000000000000}@NSimSun;}{\f73\fswiss\fcharset134\fprq2{\*\panose 00000000000000000000}@Microsoft YaHei;}{\f84\fswiss\fcharset238\fprq2 Arial CE;}{\f85\fswiss\fcharset204\fprq2 Arial Cyr;}
+{\f87\fswiss\fcharset161\fprq2 Arial Greek;}{\f88\fswiss\fcharset162\fprq2 Arial Tur;}{\f89\fbidi \fswiss\fcharset177\fprq2 Arial (Hebrew);}{\f90\fbidi \fswiss\fcharset178\fprq2 Arial (Arabic);}{\f91\fswiss\fcharset186\fprq2 Arial Baltic;}
+{\f92\fswiss\fcharset163\fprq2 Arial (Vietnamese);}{\f434\fswiss\fcharset238\fprq2 Liberation Sans CE{\*\falt Arial};}{\f435\fswiss\fcharset204\fprq2 Liberation Sans Cyr{\*\falt Arial};}
+{\f437\fswiss\fcharset161\fprq2 Liberation Sans Greek{\*\falt Arial};}{\f438\fswiss\fcharset162\fprq2 Liberation Sans Tur{\*\falt Arial};}{\f439\fbidi \fswiss\fcharset177\fprq2 Liberation Sans (Hebrew){\*\falt Arial};}
+{\f441\fswiss\fcharset186\fprq2 Liberation Sans Baltic{\*\falt Arial};}{\f442\fswiss\fcharset163\fprq2 Liberation Sans (Vietnamese){\*\falt Arial};}{\f484\froman\fcharset238\fprq2 Liberation Serif CE{\*\falt Times New Roman};}
+{\f485\froman\fcharset204\fprq2 Liberation Serif Cyr{\*\falt Times New Roman};}{\f487\froman\fcharset161\fprq2 Liberation Serif Greek{\*\falt Times New Roman};}{\f488\froman\fcharset162\fprq2 Liberation Serif Tur{\*\falt Times New Roman};}
+{\f489\fbidi \froman\fcharset177\fprq2 Liberation Serif (Hebrew){\*\falt Times New Roman};}{\f491\froman\fcharset186\fprq2 Liberation Serif Baltic{\*\falt Times New Roman};}
+{\f492\froman\fcharset163\fprq2 Liberation Serif (Vietnamese){\*\falt Times New Roman};}{\f74\froman\fcharset238\fprq2 Times New Roman CE;}{\f75\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f77\froman\fcharset161\fprq2 Times New Roman Greek;}
+{\f78\froman\fcharset162\fprq2 Times New Roman Tur;}{\f79\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f80\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f81\froman\fcharset186\fprq2 Times New Roman Baltic;}
+{\f82\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}}{\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;}{\stylesheet{
+\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af1\afs24\alang1081 \ltrch\fcs0 \fs24\lang1049\langfe2052\kerning2\loch\f41\hich\af41\dbch\af42\cgrid\langnp1049\langfenp2052 \snext0 Normal;}{\*\cs10
+\additive \ssemihidden Default Paragraph Font;}{\*
+\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tblind0\tblindtype3\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
+\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af1\afs20 \ltrch\fcs0 \fs20\lang1024\langfe1024\loch\f41\hich\af41\dbch\af42\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}{
+\s15\ql \li0\ri0\sb240\sa120\keepn\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af1\afs28\alang1081 \ltrch\fcs0 \fs28\lang1049\langfe2052\kerning2\loch\f36\hich\af36\dbch\af43\cgrid\langnp1049\langfenp2052
+\sbasedon0 \snext16 Heading;}{\s16\ql \li0\ri0\sa140\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af1\afs24\alang1081 \ltrch\fcs0
+\fs24\lang1049\langfe2052\kerning2\loch\f41\hich\af41\dbch\af42\cgrid\langnp1049\langfenp2052 \sbasedon0 \snext16 Body Text;}{\s17\ql \li0\ri0\sa140\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1
+\af1\afs24\alang1081 \ltrch\fcs0 \fs24\lang1049\langfe2052\kerning2\loch\f41\hich\af41\dbch\af42\cgrid\langnp1049\langfenp2052 \sbasedon16 \snext17 List;}{
+\s18\ql \li0\ri0\sb120\sa120\widctlpar\noline\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \ai\af1\afs24\alang1081 \ltrch\fcs0 \i\fs24\lang1049\langfe2052\kerning2\loch\f41\hich\af41\dbch\af42\cgrid\langnp1049\langfenp2052
+\sbasedon0 \snext18 caption;}{\s19\ql \li0\ri0\widctlpar\noline\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af1\afs24\alang1081 \ltrch\fcs0
+\fs24\lang1049\langfe2052\kerning2\loch\f41\hich\af41\dbch\af42\cgrid\langnp1049\langfenp2052 \sbasedon0 \snext19 Index;}}{\*\latentstyles\lsdstimax156\lsdlockeddef0}{\*\rsidtbl \rsid336885\rsid2430917\rsid2647374\rsid4946236}{\*\generator Microsoft Word
+11.0.0000;}{\info{\title 05}{\author Mike Kaganski}{\operator JLAutoBuild}{\creatim\yr2021\mo4\dy13\hr10\min21}{\revtim\yr2021\mo4\dy13\hr10\min21}{\version2}{\edmins1}{\nofpages1}{\nofwords8}{\nofchars50}{\nofcharsws57}{\vern24611}{\*\password 00000000}}
+{\*\xmlnstbl {\xmlns1 http://schemas.microsoft.com/office/word/2003/wordml}}\paperw11906\paperh16838\margl1134\margr1134\margt1134\margb1134\gutter0\ltrsect
+\deftab709\widowctrl\ftnbj\aenddoc\donotembedsysfont1\donotembedlingdata0\grfdocevents0\validatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0\showxmlerrors1\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin
+\dghspace180\dgvspace180\dghorigin1134\dgvorigin1134\dghshow1\dgvshow1
+\jexpand\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct
+\asianbrkrule\rsidroot2647374\newtblstyruls\nogrowautofit \fet0{\*\wgrffmtfilter 2450}\ilfomacatclnup0\ltrpar \sectd \ltrsect\linex0\endnhere\sectunlocked1\sectexpand32768\sectlinegrid600\sectdefaultcl\sftnbj {\*\pnseclvl1
+\pnucrm\pnqc\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnqc\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnqc\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnqc\pnstart1\pnindent720\pnhang {\pntxta )}}
+{\*\pnseclvl5\pndec\pnqc\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnqc\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnqc\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8
+\pnlcltr\pnqc\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnqc\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain \ltrpar\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0
+\rtlch\fcs1 \af1\afs24\alang1081 \ltrch\fcs0 \fs24\lang1049\langfe2052\kerning2\loch\af41\hich\af41\dbch\af42\cgrid\langnp1049\langfenp2052 {\field\fldlock{\*\fldinst {\rtlch\fcs1 \af1 \ltrch\fcs0 \insrsid336885 \hich\af41\dbch\af42\loch\f41 DATE \\
+@"dd.MM.yy"}}{\fldrslt {\rtlch\fcs1 \af1 \ltrch\fcs0 \insrsid336885 \hich\af41\dbch\af42\loch\f41 05.01.19}}}\sectd \ltrsect\linex0\endnhere\sectunlocked1\sectexpand32768\sectlinegrid600\sectdefaultcl\sftnbj {\rtlch\fcs1 \af1 \ltrch\fcs0 \insrsid336885
+\hich\af41\dbch\af42\loch\f41 }{\field\fldlock{\*\fldinst {\rtlch\fcs1 \af1 \ltrch\fcs0 \insrsid336885 \hich\af41\dbch\af42\loch\f41 TIME \\@"HH:mm:ss"}}{\fldrslt {\rtlch\fcs1 \af1 \ltrch\fcs0 \insrsid336885 \hich\af41\dbch\af42\loch\f41 04:06:08}}}
+\sectd \ltrsect\linex0\endnhere\sectunlocked1\sectexpand32768\sectlinegrid600\sectdefaultcl\sftnbj {\rtlch\fcs1 \af1 \ltrch\fcs0 \insrsid2647374
+\par }}
\ No newline at end of file
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx
index 6f801bc3f8cc..4468a97650b5 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -14,6 +14,8 @@
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/text/XEndnotesSupplier.hpp>
+#include <com/sun/star/text/XTextField.hpp>
+#include <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <com/sun/star/text/XTextTablesSupplier.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
@@ -33,6 +35,16 @@ public:
}
};
+DECLARE_RTFEXPORT_TEST(testTdf100961_fixedDateTime, "tdf100961_fixedDateTime.rtf")
+{
+ // This should be a fixed date/time field, not the current time.
+ getParagraph(1, "05.01.19 04:06:08");
+
+ uno::Reference<text::XTextFieldsSupplier> xTFS(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xFields(xTFS->getTextFields()->createEnumeration());
+ CPPUNIT_ASSERT_MESSAGE("constant time", getProperty<bool>(xFields->nextElement(), "IsFixed"));
+}
+
DECLARE_RTFEXPORT_TEST(testTdf108949, "tdf108949_footnoteCharFormat.odt")
{
CPPUNIT_ASSERT_EQUAL(1, getPages());
diff --git a/writerfilter/inc/dmapper/resourcemodel.hxx b/writerfilter/inc/dmapper/resourcemodel.hxx
index 2a9833f7ea2f..fce90839d520 100644
--- a/writerfilter/inc/dmapper/resourcemodel.hxx
+++ b/writerfilter/inc/dmapper/resourcemodel.hxx
@@ -171,6 +171,7 @@ protected:
~BinaryObj() {}
};
+const sal_uInt8 cFieldLock = 0x8;
const sal_uInt8 cFieldStart = 0x13;
const sal_uInt8 cFieldSep = 0x14;
const sal_uInt8 cFieldEnd = 0x15;
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index e4bd09130c69..0263196e6d8c 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -48,7 +48,6 @@ const sal_Unicode uNoBreakHyphen = 0x2011;
const sal_Unicode uSoftHyphen = 0xAD;
const sal_uInt8 cFtnEdnCont = 0x4;
-const sal_uInt8 cFieldLock = 0x8;
namespace writerfilter::ooxml
{
diff --git a/writerfilter/source/rtftok/rtfdispatchdestination.cxx b/writerfilter/source/rtftok/rtfdispatchdestination.cxx
index 2f7975073a37..11db48a0ec6d 100644
--- a/writerfilter/source/rtftok/rtfdispatchdestination.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchdestination.cxx
@@ -63,6 +63,7 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
break;
case RTFKeyword::FIELD:
m_aStates.top().setDestination(Destination::FIELD);
+ m_aStates.top().setFieldLocked(false);
break;
case RTFKeyword::FLDINST:
{
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index c56124106eb2..7bfa56d42d7c 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -1234,6 +1234,12 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
new RTFValue(1));
}
break;
+ case RTFKeyword::FLDLOCK:
+ {
+ if (m_aStates.top().getDestination() == Destination::FIELD)
+ m_aStates.top().setFieldLocked(true);
+ }
+ break;
default:
{
SAL_INFO("writerfilter", "TODO handle flag '" << keywordToString(nKeyword) << "'");
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 7066c7b5c53e..f4a66c5c3c98 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2223,6 +2223,9 @@ RTFError RTFDocumentImpl::beforePopState(RTFParserState& rState)
}
m_aFormfieldAttributes.clear();
m_aFormfieldSprms.clear();
+
+ if (m_aStates.top().isFieldLocked())
+ singleChar(cFieldLock);
singleChar(cFieldSep);
}
break;
@@ -3642,6 +3645,7 @@ RTFParserState::RTFParserState(RTFDocumentImpl* pDocumentImpl)
, m_nInternalState(RTFInternalState::NORMAL)
, m_eDestination(Destination::NORMAL)
, m_eFieldStatus(RTFFieldStatus::NONE)
+ , m_bFieldLocked(false)
, m_nBorderState(RTFBorderState::NONE)
, m_nCurrentEncoding(rtl_getTextEncodingFromWindowsCharset(0))
, m_nUc(1)
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 991cca90a562..b7f7335eb7d9 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -516,6 +516,8 @@ public:
RTFBorderState getBorderState() const { return m_nBorderState; }
void setFieldStatus(RTFFieldStatus eFieldStatus) { m_eFieldStatus = eFieldStatus; }
RTFFieldStatus getFieldStatus() const { return m_eFieldStatus; }
+ void setFieldLocked(bool bSet) { m_bFieldLocked = bSet; }
+ bool isFieldLocked() { return m_bFieldLocked; }
void setDestination(Destination eDestination) { m_eDestination = eDestination; }
Destination getDestination() const { return m_eDestination; }
void setInternalState(RTFInternalState nInternalState) { m_nInternalState = nInternalState; }
@@ -527,6 +529,7 @@ private:
RTFInternalState m_nInternalState;
Destination m_eDestination;
RTFFieldStatus m_eFieldStatus;
+ bool m_bFieldLocked;
RTFBorderState m_nBorderState;
// font table, stylesheet table
RTFSprms m_aTableSprms;
More information about the Libreoffice-commits
mailing list