read support for docx w:embedTrueTypeFonts/w:embedSystemFonts

No write support yet.

Change-Id: Ia10239acc77cf9ebc4f511e30c007da36abf43cb
This commit is contained in:
Luboš Luňák
2012-09-06 17:34:08 +02:00
parent 9b14fa8f64
commit 7a045f48ba
11 changed files with 89 additions and 5 deletions

View File

@@ -249,6 +249,21 @@ published service Settings
*/
[optional, property] boolean AddExternalLeading;
// Writer, maybe later others
/**
Whether to embed fonts used by the document (see e.g. handling
of OOXML embedRegular etc.)
@since LibreOffice 3.7
*/
[optional, property] boolean EmbedFonts;
// Writer, maybe later others
/**
Whether to embed also system fonts used by the document.
Does not have any effect if EmbedFonts is false.
@since LibreOffice 3.7
*/
[optional, property] boolean EmbedSystemFonts;
};

View File

@@ -96,7 +96,9 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd
KERN_ASIAN_PUNCTUATION,
MATH_BASELINE_ALIGNMENT,
STYLES_NODEFAULT,
FLOATTABLE_NOMARGINS
FLOATTABLE_NOMARGINS,
EMBED_FONTS,
EMBED_SYSTEM_FONTS
};
public:

View File

@@ -568,6 +568,8 @@ private:
bool mbMathBaselineAlignment : 1; // TL 2010-10-29 #i972#
bool mbStylesNoDefault : 1;
bool mbFloattableNomargins : 1; ///< If paragraph margins next to a floating table should be ignored.
bool mEmbedFonts : 1; ///< Whether to embed fonts used by the document when saving.
bool mEmbedSystemFonts : 1; ///< Whether to embed also system fonts.
// non-ui-compatibility flags:
bool mbOldNumbering : 1;

View File

@@ -212,6 +212,8 @@ bool SwDoc::get(/*[in]*/ DocumentSettingId id) const
case MATH_BASELINE_ALIGNMENT: return mbMathBaselineAlignment;
case STYLES_NODEFAULT: return mbStylesNoDefault;
case FLOATTABLE_NOMARGINS: return mbFloattableNomargins;
case EMBED_FONTS: return mEmbedFonts;
case EMBED_SYSTEM_FONTS: return mEmbedSystemFonts;
default:
OSL_FAIL("Invalid setting id");
}
@@ -391,6 +393,12 @@ void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value)
case FLOATTABLE_NOMARGINS:
mbFloattableNomargins = value;
break;
case EMBED_FONTS:
mEmbedFonts = value;
break;
case EMBED_SYSTEM_FONTS:
mEmbedSystemFonts = value;
break;
default:
OSL_FAIL("Invalid setting id");
}

View File

@@ -359,6 +359,8 @@ SwDoc::SwDoc()
mbUnbreakableNumberings = false;
mbFloattableNomargins = false;
mbClippedPictures = false;
mEmbedFonts = false;
mEmbedSystemFonts = false;
//
// COMPATIBILITY FLAGS END

View File

@@ -128,7 +128,9 @@ enum SwDocumentSettingsPropertyHandles
HANDLE_UNBREAKABLE_NUMBERINGS,
HANDLE_STYLES_NODEFAULT,
HANDLE_FLOATTABLE_NOMARGINS,
HANDLE_CLIPPED_PICTURES
HANDLE_CLIPPED_PICTURES,
HANDLE_EMBED_FONTS,
HANDLE_EMBED_SYSTEM_FONTS
};
MasterPropertySetInfo * lcl_createSettingsInfo()
@@ -194,6 +196,8 @@ MasterPropertySetInfo * lcl_createSettingsInfo()
{ RTL_CONSTASCII_STRINGPARAM("StylesNoDefault"), HANDLE_STYLES_NODEFAULT, CPPUTYPE_BOOLEAN, 0, 0},
{ RTL_CONSTASCII_STRINGPARAM("FloattableNomargins"), HANDLE_FLOATTABLE_NOMARGINS, CPPUTYPE_BOOLEAN, 0, 0},
{ RTL_CONSTASCII_STRINGPARAM("ClippedPictures"), HANDLE_CLIPPED_PICTURES, CPPUTYPE_BOOLEAN, 0, 0},
{ RTL_CONSTASCII_STRINGPARAM("EmbedFonts"), HANDLE_EMBED_FONTS, CPPUTYPE_BOOLEAN, 0, 0},
{ RTL_CONSTASCII_STRINGPARAM("EmbedSystemFonts"), HANDLE_EMBED_SYSTEM_FONTS, CPPUTYPE_BOOLEAN, 0, 0},
/*
* As OS said, we don't have a view when we need to set this, so I have to
* find another solution before adding them to this property set - MTG
@@ -771,6 +775,17 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
mpDoc->set(IDocumentSettingAccess::CLIPPED_PICTURES, bTmp);
}
break;
case HANDLE_EMBED_FONTS:
{
sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
mpDoc->set(IDocumentSettingAccess::EMBED_FONTS, bTmp);
}
case HANDLE_EMBED_SYSTEM_FONTS:
{
sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
mpDoc->set(IDocumentSettingAccess::EMBED_SYSTEM_FONTS, bTmp);
}
break;
default:
throw UnknownPropertyException();
}
@@ -1161,6 +1176,17 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
rValue.setValue( &bTmp, ::getBooleanCppuType() );
}
break;
case HANDLE_EMBED_FONTS:
{
sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::EMBED_FONTS );
rValue.setValue( &bTmp, ::getBooleanCppuType() );
}
case HANDLE_EMBED_SYSTEM_FONTS:
{
sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::EMBED_SYSTEM_FONTS );
rValue.setValue( &bTmp, ::getBooleanCppuType() );
}
break;
default:
throw UnknownPropertyException();
}

View File

@@ -3665,11 +3665,13 @@ void DomainMapper_Impl::ApplySettingsTable()
xViewDataSupplier->setViewData(xIndexAccess);
}
uno::Reference< beans::XPropertySet > xSettings(m_xTextFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY);
if (m_pSettingsTable->GetUsePrinterMetrics())
{
uno::Reference< beans::XPropertySet > xSettings(m_xTextFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY);
xSettings->setPropertyValue("PrinterIndependentLayout", uno::makeAny(document::PrinterIndependentLayout::DISABLED));
}
if( m_pSettingsTable->GetEmbedTrueTypeFonts())
xSettings->setPropertyValue( PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_EMBED_FONTS ), uno::makeAny(true) );
if( m_pSettingsTable->GetEmbedSystemFonts())
xSettings->setPropertyValue( PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_EMBED_SYSTEM_FONTS ), uno::makeAny(true) );
}
catch(const uno::Exception&)
{

View File

@@ -316,6 +316,8 @@ const OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_IS_VISIBLE: sName = "IsVisible"; break;
case PROP_PAGE_STYLE_LAYOUT: sName = "PageStyleLayout"; break;
case PROP_Z_ORDER: sName = "ZOrder"; break;
case PROP_EMBED_FONTS: sName = "EmbedFonts"; break;
case PROP_EMBED_SYSTEM_FONTS: sName = "EmbedSystemFonts"; break;
}
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));

View File

@@ -289,6 +289,8 @@ enum PropertyIds
,PROP_PARA_CONTEXT_MARGIN
,PROP_PAGE_STYLE_LAYOUT
,PROP_Z_ORDER
,PROP_EMBED_FONTS
,PROP_EMBED_SYSTEM_FONTS
};
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier

View File

@@ -69,6 +69,8 @@ struct SettingsTable_Impl
sal_Int16 m_nZoomFactor;
bool m_bEvenAndOddHeaders;
bool m_bUsePrinterMetrics;
bool embedTrueTypeFonts;
bool embedSystemFonts;
SettingsTable_Impl( DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory ) :
m_rDMapper( rDMapper )
@@ -89,6 +91,8 @@ struct SettingsTable_Impl
, m_nZoomFactor(0)
, m_bEvenAndOddHeaders(false)
, m_bUsePrinterMetrics(false)
, embedTrueTypeFonts(false)
, embedSystemFonts(false)
{}
};
@@ -199,6 +203,12 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
case NS_ooxml::LN_CT_Compat_usePrinterMetrics:
m_pImpl->m_bUsePrinterMetrics = nIntValue;
break;
case NS_ooxml::LN_CT_Settings_embedTrueTypeFonts:
m_pImpl->embedTrueTypeFonts = nIntValue != 0;
break;
case NS_ooxml::LN_CT_Settings_embedSystemFonts:
m_pImpl->embedSystemFonts = nIntValue != 0;
break;
default:
{
#ifdef DEBUG_DMAPPER_SETTINGS_TABLE
@@ -241,6 +251,16 @@ bool SettingsTable::GetEvenAndOddHeaders() const
return m_pImpl->m_bEvenAndOddHeaders;
}
bool SettingsTable::GetEmbedTrueTypeFonts() const
{
return m_pImpl->embedTrueTypeFonts;
}
bool SettingsTable::GetEmbedSystemFonts() const
{
return m_pImpl->embedSystemFonts;
}
void SettingsTable::ApplyProperties( uno::Reference< text::XTextDocument > xDoc )
{
uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );

View File

@@ -65,6 +65,9 @@ class WRITERFILTER_DLLPRIVATE SettingsTable : public LoggedProperties, public Lo
bool GetUsePrinterMetrics() const;
bool GetEmbedTrueTypeFonts() const;
bool GetEmbedSystemFonts() const;
void ApplyProperties( uno::Reference< text::XTextDocument > xDoc );
private: