summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2015-06-24 01:40:13 +0800
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-08-03 16:08:38 +0000
commitfd2bb1847eb3e1edaa590eac9dfaaaf1c64f638a (patch)
tree3ec6337ffc0db999e40851e742eeef6955280ca1
parent183c317f01ccade1c7865e05e608ea7295c8d39e (diff)
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. Reviewed-on: https://gerrit.libreoffice.org/16543 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com> Conflicts: writerfilter/source/dmapper/DomainMapper.cxx Change-Id: I602d9fbfa79c33c90f655dbf5ee22738b6391ae6 Reviewed-on: https://gerrit.libreoffice.org/17457 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf91594.docxbin0 -> 13037 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx17
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx51
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx6
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx19
-rw-r--r--writerfilter/source/ooxml/model.xml1
6 files changed, 55 insertions, 39 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf91594.docx b/sw/qa/extras/ooxmlexport/data/tdf91594.docx
new file mode 100644
index 000000000000..ea539afa3af6
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf91594.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 20be877a78d9..c8702636b39a 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 d78aca7a699c..8f13b5bfd435 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -255,37 +255,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(
- PropertyNameSupplier::GetPropertyNameSupplier().GetName( 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());
@@ -2554,6 +2527,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( PropertyNameSupplier::GetPropertyNameSupplier().GetName( 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 515d6fe0514c..363d300fca2a 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 b2b24b408daf..0fa9ce76816c 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;
@@ -504,8 +513,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 9a8c4d07af77..860655eaa320 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"/>