Kaydet (Commit) 1835074d authored tarafından Jacobo Aragunde Pérez's avatar Jacobo Aragunde Pérez

fdo#64232: fix theme fonts application

We were applying the theme fonts taking only into account the
<a:latin>, <a:ea> and <a:cs> tags to set latin, eastAsia and cs fonts
respectively. Word uses in addition the <a:font> tags to define a
font name per language, in combination with <w:themeFontLang> tag in
settings.xml file which indicates the default language for latin, cs
and eastAsia. For example, with <w:themeFontLang w:bidi="he-IL" />
the default language for cs text is Hebrew, if the theme says
<a:font script="Hebr" typeface="Arial"/> then the selected font for
those sections of text should be Arial.

In theory, Word would also be able to define the language for a
specific section of text and that should receive the proper font from
the theme definition, but we are currently not supporting it. More
info: http://blogs.msdn.com/b/officeinteroperability/archive/2013/04/
22/office-open-xml-themes-schemes-and-fonts.aspx

Main changes in this patch:
* Added setter and getter values to ThemeTable and SettingsTable to
  be able to pass the values read in <w:themeFontLang> tag.
* Added support to manage the values in <w:themeFontLang> and
  <a:font> tags, which used to be discarded.
* Added methods to translate locale definitions to the language codes
  used in the <a:font>, using a table defined in the link above.

Change-Id: I78e6da5feab34cb9ff770a2c60e2f7229e7fb140
üst 0f5a7bc9
...@@ -4035,6 +4035,8 @@ void DomainMapper::lcl_table(Id name, writerfilter::Reference<Table>::Pointer_t ...@@ -4035,6 +4035,8 @@ void DomainMapper::lcl_table(Id name, writerfilter::Reference<Table>::Pointer_t
} }
break; break;
case NS_ooxml::LN_THEMETABLE: case NS_ooxml::LN_THEMETABLE:
m_pImpl->GetThemeTable()->setThemeFontLangProperties(
m_pImpl->GetSettingsTable()->GetThemeFontLangProperties() );
ref->resolve ( *m_pImpl->GetThemeTable() ); ref->resolve ( *m_pImpl->GetThemeTable() );
break; break;
case NS_ooxml::LN_settings_settings: case NS_ooxml::LN_settings_settings:
......
...@@ -73,6 +73,7 @@ struct SettingsTable_Impl ...@@ -73,6 +73,7 @@ struct SettingsTable_Impl
bool embedSystemFonts; bool embedSystemFonts;
bool m_bDoNotUseHTMLParagraphAutoSpacing; bool m_bDoNotUseHTMLParagraphAutoSpacing;
bool m_bSplitPgBreakAndParaMark; bool m_bSplitPgBreakAndParaMark;
uno::Sequence<beans::PropertyValue> m_pThemeFontLangProps;
SettingsTable_Impl( DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory ) : SettingsTable_Impl( DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory ) :
m_rDMapper( rDMapper ) m_rDMapper( rDMapper )
...@@ -97,6 +98,7 @@ struct SettingsTable_Impl ...@@ -97,6 +98,7 @@ struct SettingsTable_Impl
, embedSystemFonts(false) , embedSystemFonts(false)
, m_bDoNotUseHTMLParagraphAutoSpacing(false) , m_bDoNotUseHTMLParagraphAutoSpacing(false)
, m_bSplitPgBreakAndParaMark(false) , m_bSplitPgBreakAndParaMark(false)
, m_pThemeFontLangProps(3)
{} {}
}; };
...@@ -117,12 +119,25 @@ SettingsTable::~SettingsTable() ...@@ -117,12 +119,25 @@ SettingsTable::~SettingsTable()
void SettingsTable::lcl_attribute(Id nName, Value & val) void SettingsTable::lcl_attribute(Id nName, Value & val)
{ {
int nIntValue = val.getInt(); int nIntValue = val.getInt();
OUString sStringValue = val.getString();
switch(nName) switch(nName)
{ {
case NS_ooxml::LN_CT_Zoom_percent: case NS_ooxml::LN_CT_Zoom_percent:
m_pImpl->m_nZoomFactor = nIntValue; m_pImpl->m_nZoomFactor = nIntValue;
break; break;
case NS_ooxml::LN_CT_Language_val:
m_pImpl->m_pThemeFontLangProps[0].Name = "val";
m_pImpl->m_pThemeFontLangProps[0].Value <<= sStringValue;
break;
case NS_ooxml::LN_CT_Language_eastAsia:
m_pImpl->m_pThemeFontLangProps[1].Name = "eastAsia";
m_pImpl->m_pThemeFontLangProps[1].Value <<= sStringValue;
break;
case NS_ooxml::LN_CT_Language_bidi:
m_pImpl->m_pThemeFontLangProps[2].Name = "bidi";
m_pImpl->m_pThemeFontLangProps[2].Value <<= sStringValue;
break;
default: default:
{ {
#ifdef DEBUG_DMAPPER_SETTINGS_TABLE #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
...@@ -281,6 +296,11 @@ bool SettingsTable::GetSplitPgBreakAndParaMark() const ...@@ -281,6 +296,11 @@ bool SettingsTable::GetSplitPgBreakAndParaMark() const
return m_pImpl->m_bSplitPgBreakAndParaMark; return m_pImpl->m_bSplitPgBreakAndParaMark;
} }
uno::Sequence<beans::PropertyValue> SettingsTable::GetThemeFontLangProperties() const
{
return m_pImpl->m_pThemeFontLangProps;
}
void SettingsTable::ApplyProperties( uno::Reference< text::XTextDocument > xDoc ) void SettingsTable::ApplyProperties( uno::Reference< text::XTextDocument > xDoc )
{ {
uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
......
...@@ -71,6 +71,8 @@ class WRITERFILTER_DLLPRIVATE SettingsTable : public LoggedProperties, public Lo ...@@ -71,6 +71,8 @@ class WRITERFILTER_DLLPRIVATE SettingsTable : public LoggedProperties, public Lo
bool GetDoNotUseHTMLParagraphAutoSpacing() const; bool GetDoNotUseHTMLParagraphAutoSpacing() const;
bool GetSplitPgBreakAndParaMark() const; bool GetSplitPgBreakAndParaMark() const;
uno::Sequence<beans::PropertyValue> GetThemeFontLangProperties() const;
void ApplyProperties( uno::Reference< text::XTextDocument > xDoc ); void ApplyProperties( uno::Reference< text::XTextDocument > xDoc );
private: private:
......
...@@ -22,7 +22,9 @@ ...@@ -22,7 +22,9 @@
#include <WriterFilterDllApi.hxx> #include <WriterFilterDllApi.hxx>
#include <resourcemodel/LoggedResources.hxx> #include <resourcemodel/LoggedResources.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XComponent.hpp>
#include <i18nlangtag/languagetag.hxx>
#include <map> #include <map>
namespace writerfilter { namespace writerfilter {
...@@ -41,6 +43,7 @@ public: ...@@ -41,6 +43,7 @@ public:
const OUString getFontNameForTheme(const Id id) const; const OUString getFontNameForTheme(const Id id) const;
static OUString getStringForTheme(const Id id); static OUString getStringForTheme(const Id id);
void setThemeFontLangProperties(uno::Sequence<beans::PropertyValue> aPropSeq);
private: private:
// Properties // Properties
...@@ -49,6 +52,10 @@ public: ...@@ -49,6 +52,10 @@ public:
// Table // Table
virtual void lcl_entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref); virtual void lcl_entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref);
// Helper methods
OUString fromLocaleToScriptTag(OUString sLocale);
OUString fromLCIDToScriptTag(LanguageType lang);
}; };
typedef boost::shared_ptr< ThemeTable > ThemeTablePtr; typedef boost::shared_ptr< ThemeTable > ThemeTablePtr;
}} }}
......
...@@ -989,6 +989,9 @@ ...@@ -989,6 +989,9 @@
</attribute> </attribute>
<attribute name="typeface"> <attribute name="typeface">
<ref name="ST_TextTypeface"/> <ref name="ST_TextTypeface"/>
<data type="string">
<xs:documentation>Typeface</xs:documentation>
</data>
<xs:documentation>Typeface</xs:documentation> <xs:documentation>Typeface</xs:documentation>
</attribute> </attribute>
</define> </define>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment