[Libreoffice-commits] core.git: sw/qa writerfilter/source
Mark Hung
marklh9 at gmail.com
Tue Jul 28 14:58:26 PDT 2015
sw/qa/extras/ooxmlexport/data/tdf91594.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 17 +++++++
writerfilter/source/dmapper/DomainMapper.cxx | 51 +++++++++-------------
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 6 --
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 19 ++++++--
writerfilter/source/ooxml/model.xml | 1
6 files changed, 55 insertions(+), 39 deletions(-)
New commits:
commit 62e2fae93e8894f73560a30ae1e752cbd4c001ad
Author: Mark Hung <marklh9 at gmail.com>
Date: Wed Jun 24 01:40:13 2015 +0800
tdf#91594 misinterprets letters from Symbol font in docx files
Fix the issue caused by wrong assumption about symbol chracter
and symbol font attributes order in writerfilter. Also allow
symbols to be displayed if user's language is not Western.
Change-Id: I602d9fbfa79c33c90f655dbf5ee22738b6391ae6
Reviewed-on: https://gerrit.libreoffice.org/16543
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Stahl <mstahl at redhat.com>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf91594.docx b/sw/qa/extras/ooxmlexport/data/tdf91594.docx
new file mode 100644
index 0000000..ea539af
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf91594.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 20be877..c870263 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -726,6 +726,23 @@ DECLARE_OOXMLEXPORT_TEST(testTdf89890, "tdf89890.docx")
CPPUNIT_ASSERT(bFound);
}
+DECLARE_OOXMLEXPORT_TEST(testTdf91594, "tdf91594.docx")
+{
+ uno::Reference<text::XTextRange> xPara1(getParagraph(1));
+ CPPUNIT_ASSERT_EQUAL(sal_Unicode(0xf0fb), xPara1->getString()[0] );
+ uno::Reference<text::XTextRange> xPara2(getParagraph(2));
+ CPPUNIT_ASSERT_EQUAL(sal_Unicode(0xf0fc), xPara2->getString()[0] );
+ uno::Reference<text::XTextRange> xPara3(getParagraph(3));
+ CPPUNIT_ASSERT_EQUAL(sal_Unicode(0xf0fd), xPara3->getString()[0] );
+ uno::Reference<text::XTextRange> xPara4(getParagraph(4));
+ CPPUNIT_ASSERT_EQUAL(sal_Unicode(0xf0fe), xPara4->getString()[0] );
+
+ uno::Reference<beans::XPropertySet> xRun(getRun(xPara1,1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), getProperty<OUString>(xRun, "CharFontName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), getProperty<OUString>(xRun, "CharFontNameAsian"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), getProperty<OUString>(xRun, "CharFontNameComplex"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 25c3cd5..4493b68 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -253,37 +253,10 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
break;
case NS_ooxml::LN_CT_Sym_char:
- if( m_pImpl->GetTopContext() && m_pImpl->GetTopContext()->GetFootnote().is())
- {
- m_pImpl->GetTopContext()->GetFootnote()->setLabel(OUString( sal_Unicode(nIntValue)));
- break;
- }
- else //it's a _real_ symbol
- {
- m_pImpl->SetSymbolData(nIntValue);
- }
+ m_pImpl->SetSymbolChar(nIntValue);
break;
case NS_ooxml::LN_CT_Sym_font:
- //the footnote symbol and font are provided after the footnote is already inserted
- if( m_pImpl->GetTopContext() && m_pImpl->GetTopContext()->GetFootnote().is())
- {
- uno::Reference< beans::XPropertySet > xAnchorProps( m_pImpl->GetTopContext()->GetFootnote()->getAnchor(), uno::UNO_QUERY );
- xAnchorProps->setPropertyValue(
- getPropertyName( PROP_CHAR_FONT_NAME),
- uno::makeAny( sStringValue ));
- }
- else //a real symbol
- if (m_pImpl->GetTopContext())
- {
- m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME, uno::makeAny( sStringValue ));
- /*
- * In case of symbol, symbol character get imported first and then font of symbols.
- * So we are storing symbol character and when we parse symbol font then create UNO object for text.
- */
- sal_Int32 symboldata = m_pImpl->GetSymbolData();
- utext( reinterpret_cast < const sal_uInt8 * >( &(symboldata) ), 1 );
- }
-
+ m_pImpl->SetSymbolFont(sStringValue);
break;
case NS_ooxml::LN_CT_Underline_val:
handleUnderlineType(nIntValue, m_pImpl->GetTopContext());
@@ -2551,6 +2524,26 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
m_pImpl->disableInteropGrabBag();
}
break;
+ case NS_ooxml::LN_EG_RunInnerContent_sym:
+ {
+ resolveSprmProps(*this, rSprm);
+ SymbolData aSymbolData = m_pImpl->GetSymbolData();
+ uno::Any aVal = uno::makeAny( aSymbolData.sFont );
+ if( rContext->GetFootnote().is())
+ {
+ uno::Reference< beans::XPropertySet > xAnchorProps( rContext->GetFootnote()->getAnchor(), uno::UNO_QUERY );
+ xAnchorProps->setPropertyValue( getPropertyName( PROP_CHAR_FONT_NAME), aVal);
+ rContext->GetFootnote()->setLabel(OUString( aSymbolData.cSymbol ));
+ }
+ else //it's a _real_ symbol
+ {
+ rContext->Insert(PROP_CHAR_FONT_NAME, aVal);
+ rContext->Insert(PROP_CHAR_FONT_NAME_ASIAN, aVal);
+ rContext->Insert(PROP_CHAR_FONT_NAME_COMPLEX, aVal);
+ utext( reinterpret_cast < const sal_uInt8 * >( &(aSymbolData.cSymbol) ), 1 );
+ }
+ }
+ break;
default:
{
#ifdef DEBUG_WRITERFILTER
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 473e47d..ad96b2d 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -198,7 +198,6 @@ DomainMapper_Impl::DomainMapper_Impl(
m_bTOCPageRef(false),
m_bStartGenericField(false),
m_bTextInserted(false),
- m_nSymboldata(-1),
m_pLastSectionContext( ),
m_pLastCharacterContext(),
m_nCurrentTabStopIndex( 0 ),
@@ -426,11 +425,6 @@ void DomainMapper_Impl::RemoveLastParagraph( )
}
}
-void DomainMapper_Impl::SetSymbolData( sal_Int32 nSymbolData )
-{
- m_nSymboldata = nSymbolData;
-}
-
void DomainMapper_Impl::SetIsLastSectionGroup( bool bIsLast )
{
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 101445a..4b2e638 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -313,6 +313,16 @@ struct FloatingTableInfo
css::uno::Any getPropertyValue(const OUString &propertyName);
};
+struct SymbolData
+{
+ sal_Unicode cSymbol;
+ OUString sFont;
+ SymbolData():
+ cSymbol(),
+ sFont()
+ { }
+};
+
class DomainMapper;
class DomainMapper_Impl
{
@@ -362,8 +372,7 @@ private:
OUString m_sCurrentBkmkName;
_PageMar m_aPageMargins;
- sal_Int32 m_nSymboldata;
-
+ SymbolData m_aSymbolData;
// TableManagers are stacked: one for each stream to avoid any confusion
std::stack< std::shared_ptr< DomainMapperTableManager > > m_aTableManagers;
@@ -500,8 +509,10 @@ public:
void SetParaSectpr(bool bParaSectpr);
bool GetParaSectpr() { return m_bParaSectpr;}
- void SetSymbolData( sal_Int32 nSymbolData );
- sal_Int32 GetSymbolData() { return m_nSymboldata;}
+ void SetSymbolChar( sal_Int32 nSymbol) { m_aSymbolData.cSymbol = sal_Unicode(nSymbol); }
+ void SetSymbolFont( OUString &rName ) { m_aSymbolData.sFont = rName; }
+ const SymbolData & GetSymbolData() { return m_aSymbolData;}
+
/// Setter method for m_bSdt.
void SetSdt(bool bSdt);
/// Getter method for m_bSdt.
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 9a8c4d0..860655e 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -17840,6 +17840,7 @@
<resource name="CT_Sym" resource="Properties">
<attribute name="font" tokenid="ooxml:CT_Sym_font"/>
<attribute name="char" tokenid="ooxml:CT_Sym_char"/>
+ <action name="end" tokenid="ooxml:EG_RunInnerContent_sym" action="sendPropertiesWithId" sendtokenid="ooxml:EG_RunInnerContent_sym"/>
</resource>
<resource name="CT_Text" resource="Stream">
<attribute name="xml:space" tokenid="ooxml:CT_Text_space"/>
More information about the Libreoffice-commits
mailing list