diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-07-22 15:05:24 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-07-22 16:32:36 +0200 |
commit | 82e17dbb2a16c7653a163139f0eea51faa4d46b8 (patch) | |
tree | 7dda49d5d83cdb129ae785a830e8bb3c256e07d8 /sw/qa/extras/rtfimport | |
parent | 78234837352b9417573a4bd1efa8cfe68902e24b (diff) |
fdo#77996: writerfilter: RTF import: re-work destination text buffering
The problem in the bugdoc is that the ';' style terminator is encoded as
{\uc1 \u59 ?}, i.e. inside a group, so when reading the ';' the
aDestinationText of the top group is empty and the style name is lost.
Or since the style name characters are encoded in the same way, every
character is lost once the group closes.
The same problem affects some of the document properties.
Introduce an abstraction of RTFParserState::aDestinationText so that for
every destination only one of these buffers is used, regardless of
nested group structures; the aDestinationText buffer is only switched
when entering a new destination.
Also, the \revtbl and \stylesheet destinations do not contain entries
directly, i.e., every entry must be in a sub-group, so remove some
special-casing for these; however, for \fonttbl the entries may be in
groups or not.
Change-Id: Ica276a8b730e4a707530471ba27bfdd1582b8890
Diffstat (limited to 'sw/qa/extras/rtfimport')
-rw-r--r-- | sw/qa/extras/rtfimport/data/fdo77996.rtf | 35 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 22 |
2 files changed, 57 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo77996.rtf b/sw/qa/extras/rtfimport/data/fdo77996.rtf new file mode 100644 index 000000000000..b5b4fdec7905 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo77996.rtf @@ -0,0 +1,35 @@ +{\rtf \ansi \ansicpg0 \deff0 \stshfdbch1 \stshfloch0 \stshfhich0 \deflang1033 \deflangfe1033 + +{\fonttbl +{\f0 \froman \fcharset0 \fprq2 Times New Roman{\*\falt Times New Roman};} +{\f1 \fnil \fcharset134 \fprq0 {\uc1 \u23435 ?}{\uc1 \u20307 ?}{\*\falt {\uc1 \u23435 ?}{\uc1 \u20307 ?}};} +{\f6 \fnil \fcharset0 \fprq0 Wingdings{\*\falt Wingdings};} +{\f10 \fnil \fcharset0 \fprq0 Calibri{\*\falt Calibri};} +{\f11 \fnil \fcharset134 \fprq0 {\uc1 \u24494 ?}{\uc1 \u36719 ?}{\uc1 \u38597 ?}{\uc1 \u40657 ?}{\*\falt {\uc1 \u24494 ?}{\uc1 \u36719 ?}{\uc1 \u38597 ?}{\uc1 \u40657 ?}};} +} + +{\stylesheet +{\qj \li0 \ri0 \nowidctlpar \aspalpha \aspnum \adjustright \lin0 \rin0 \itap0 \fs21 \kerning2 \dbch \af1 \hich \af10 \loch \f10 \lang1033 \langnp1033 \langfe2052 \langfenp2052 \snext0 Normal{\uc1 \u59 ?}} +{\s1 \ql \li0 \ri0 \sb100 \lisb0 \sa100 \lisa0 \sbauto1 \saauto1 \widctlpar \aspalpha \aspnum \adjustright \lin0 \rin0 \itap0 \outlinelevel0 \b1 \fs48 \kerning36 \dbch \af1 \hich \af1 \loch \f1 \lang1033 \langnp1033 \langfe2052 \langfenp2052 \sbasedon0 \snext1 \slink18 heading 1{\uc1 \u59 ?}} +{\s2 \ql \li0 \ri0 \sb100 \lisb0 \sa100 \lisa0 \sbauto1 \saauto1 \widctlpar \aspalpha \aspnum \adjustright \lin0 \rin0 \itap0 \outlinelevel1 \b1 \fs36 \kerning0 \dbch \af1 \hich \af1 \loch \f1 \lang1033 \langnp1033 \langfe2052 \langfenp2052 \sbasedon0 \snext2 \slink16 heading 2{\uc1 \u59 ?}} +{\*\cs10 \snext10 Default Paragraph Font{\uc1 \u59 ?}} +{\*\cs15 \fs18 \v0 \sbasedon10 \snext15 {\uc1 \u97 ?}{\uc1 \u117 ?}{\uc1 \u116 ?}{\uc1 \u104 ?}{\uc1 \u111 ?}{\uc1 \u114 ?}{\uc1 \u59 ?}} +{\*\cs16 \b1 \fs36 \kerning0 \dbch \af1 \hich \af1 \loch \f1 \sbasedon10 \snext16 \slink2 {\uc1 \u26631 ?}{\uc1 \u39064 ?}{\uc1 \u32 ?}{\uc1 \u50 ?}{\uc1 \u32 ?}{\uc1 \u67 ?}{\uc1 \u104 ?}{\uc1 \u97 ?}{\uc1 \u114 ?}{\uc1 \u59 ?}} +{\*\cs17 \b1 \sbasedon10 \snext17 strong{\uc1 \u59 ?}} +{\*\cs18 \b1 \fs48 \kerning36 \dbch \af1 \hich \af1 \loch \f1 \sbasedon10 \snext18 \slink1 {\uc1 \u26631 ?}{\uc1 \u39064 ?}{\uc1 \u32 ?}{\uc1 \u49 ?}{\uc1 \u32 ?}{\uc1 \u67 ?}{\uc1 \u104 ?}{\uc1 \u97 ?}{\uc1 \u114 ?}{\uc1 \u59 ?}} +{\s19 \ql \li0 \ri0 \sb375 \lisb0 \sa100 \lisa0 \saauto1 \widctlpar \aspalpha \aspnum \adjustright \lin0 \rin0 \itap0 \fs18 \kerning0 \dbch \af1 \hich \af1 \loch \f1 \lang1033 \langnp1033 \langfe2052 \langfenp2052 \sbasedon0 \snext19 {\uc1 \u101 ?}{\uc1 \u120 ?}{\uc1 \u116 ?}{\uc1 \u114 ?}{\uc1 \u97 ?}{\uc1 \u99 ?}{\uc1 \u116 ?}{\uc1 \u50 ?}{\uc1 \u59 ?}} +} + +{\info +{\title {\uc1 \u21414 ?}{\uc1 \u38376 ?}{\uc1 \u38056 ?}{\uc1 \u19994 ?}{\uc1 \u32929 ?}{\uc1 \u20221 ?}{\uc1 \u26377 ?}{\uc1 \u38480 ?}{\uc1 \u20844 ?}{\uc1 \u21496 ?}} +{\author {\uc1 \u65 ?}{\uc1 \u108 ?}{\uc1 \u110 ?}{\uc1 \u32 ?}{\uc1 \u76 ?}{\uc1 \u105 ?}{\uc1 \u110 ?}{\uc1 \u32 ?}{\uc1 \u40 ?}{\uc1 \u66 ?}{\uc1 \u101 ?}{\uc1 \u105 ?}{\uc1 \u32 ?}{\uc1 \u74 ?}{\uc1 \u105 ?}{\uc1 \u110 ?}{\uc1 \u103 ?}{\uc1 \u41 ?}} +{\operator {\uc1 \u106 ?}{\uc1 \u97 ?}{\uc1 \u121 ?}} +} + + +{\loch \af11 \hich \af11 \dbch \f11 +{\uc1 \u21414 ?}{\uc1 \u38376 ?}{\uc1 \u38056 ?}{\uc1 \u19994 ?}{\uc1 \u32929 ?}{\uc1 \u20221 ?}{\uc1 \u26377 ?}{\uc1 \u38480 ?}{\uc1 \u20844 ?}{\uc1 \u21496 ?} +} +\par + +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 97847361a9d6..14a8728befa2 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1323,6 +1323,28 @@ DECLARE_RTFIMPORT_TEST(testN823675, "n823675.rtf") CPPUNIT_ASSERT_EQUAL(OUString("Symbol"), aFont.Name); } +DECLARE_RTFIMPORT_TEST(testFdo77996, "fdo77996.rtf") +{ + // all styles were imported as name "0" + uno::Reference<container::XNameAccess> xChars(getStyles("CharacterStyles")); + CPPUNIT_ASSERT(!xChars->hasByName("0")); + CPPUNIT_ASSERT(xChars->hasByName("strong")); + CPPUNIT_ASSERT(xChars->hasByName("author")); + uno::Reference<container::XNameAccess> xParas(getStyles("ParagraphStyles")); + CPPUNIT_ASSERT(!xParas->hasByName("0")); + CPPUNIT_ASSERT(xParas->hasByName("extract2")); + // some document properties were lost + uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<document::XDocumentProperties> xProps(xDocumentPropertiesSupplier->getDocumentProperties()); + CPPUNIT_ASSERT_EQUAL(OUString("Aln Lin (Bei Jing)"), xProps->getAuthor()); + CPPUNIT_ASSERT_EQUAL( + OUString("\xe5\x8e\xa6\xe9\x97\xa8\xe9\x92\xa8\xe4\xb8\x9a\xe8\x82\xa1\xe4\xbb\xbd\xe6\x9c\x89\xe9\x99\x90\xe5\x85\xac\xe5\x8f\xb8", 30, + RTL_TEXTENCODING_UTF8), + xProps->getTitle()); + uno::Reference<beans::XPropertySet> xUDProps(xProps->getUserDefinedProperties(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("jay"), getProperty<OUString>(xUDProps, "Operator")); +} + DECLARE_RTFIMPORT_TEST(testFdo47802, "fdo47802.rtf") { uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); |