summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2013-02-21 13:43:44 +0100
committerLuboš Luňák <l.lunak@suse.cz>2013-02-26 11:43:21 +0100
commit381154356c15128255e313f37641f0e50145f965 (patch)
tree6a435b01cf5f2a7b2d06da0c6632a1ad170e678f
parent0d8169955a3ccfb314605c06a790919175d30de0 (diff)
embed also system fonts when embedding fonts in a document
Without this, only fonts that had come embedded with the document were embedded when saving, which meant that it was impossible to create new documents that would have any fonts embedded. Change-Id: I3b4e87b1b3ca5ae1ccfe29d9b571b0262c568dcf
-rw-r--r--sw/inc/pch/precompiled_msword.hxx2
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx21
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx5
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx2
-rw-r--r--vcl/Library_vcl.mk2
-rw-r--r--vcl/Package_inc.mk2
-rw-r--r--vcl/generic/fontmanager/fontmanager.cxx2
-rw-r--r--vcl/inc/vcl/embeddedfontshelper.hxx (renamed from vcl/inc/vcl/temporaryfonts.hxx)26
-rw-r--r--vcl/source/app/svmain.cxx6
-rw-r--r--vcl/source/gdi/embeddedfontshelper.cxx104
-rw-r--r--vcl/source/gdi/temporaryfonts.cxx56
-rw-r--r--writerfilter/inc/pch/precompiled_writerfilter.hxx2
-rw-r--r--writerfilter/source/dmapper/FontTable.cxx6
-rw-r--r--xmloff/inc/pch/precompiled_xo.hxx2
-rw-r--r--xmloff/source/style/XMLFontAutoStylePool.cxx13
-rw-r--r--xmloff/source/style/XMLFontStylesContext.cxx8
16 files changed, 160 insertions, 99 deletions
diff --git a/sw/inc/pch/precompiled_msword.hxx b/sw/inc/pch/precompiled_msword.hxx
index acacb8bdeaa2..e05919fcc59b 100644
--- a/sw/inc/pch/precompiled_msword.hxx
+++ b/sw/inc/pch/precompiled_msword.hxx
@@ -252,7 +252,7 @@
#include <vcl/outdev.hxx>
#include <vcl/salbtype.hxx>
#include <vcl/svapp.hxx>
-#include <vcl/temporaryfonts.hxx>
+#include <vcl/embeddedfontshelper.hxx>
#include <vcl/vclenum.hxx>
#include <vcl/virdev.hxx>
#include <vcl/wmf.hxx>
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 8a6e8bbbff0d..b7e211ffb8e5 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -98,7 +98,7 @@
#include <txtinet.hxx>
#include <osl/file.hxx>
-#include <vcl/temporaryfonts.hxx>
+#include <vcl/embeddedfontshelper.hxx>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
@@ -3055,14 +3055,14 @@ void DocxAttributeOutput::FontPitchType( FontPitch ePitch ) const
FSEND );
}
-void DocxAttributeOutput::EmbedFont( const OUString& name )
+void DocxAttributeOutput::EmbedFont( const OUString& name, FontFamily family, FontPitch pitch, rtl_TextEncoding encoding )
{
if( !m_rExport.pDoc->get( IDocumentSettingAccess::EMBED_FONTS ))
return; // no font embedding with this document
- EmbedFontStyle( name, XML_embedRegular, "" );
- EmbedFontStyle( name, XML_embedBold, "b" );
- EmbedFontStyle( name, XML_embedItalic, "i" );
- EmbedFontStyle( name, XML_embedBoldItalic, "bi" );
+ EmbedFontStyle( name, XML_embedRegular, family, ITALIC_NONE, WEIGHT_NORMAL, pitch, encoding );
+ EmbedFontStyle( name, XML_embedBold, family, ITALIC_NONE, WEIGHT_BOLD, pitch, encoding );
+ EmbedFontStyle( name, XML_embedItalic, family, ITALIC_NORMAL, WEIGHT_NORMAL, pitch, encoding );
+ EmbedFontStyle( name, XML_embedBoldItalic, family, ITALIC_NORMAL, WEIGHT_BOLD, pitch, encoding );
}
static inline char toHexChar( int value )
@@ -3070,11 +3070,12 @@ static inline char toHexChar( int value )
return value >= 10 ? value + 'A' - 10 : value + '0';
}
-void DocxAttributeOutput::EmbedFontStyle( const OUString& name, int tag, const char* style )
+void DocxAttributeOutput::EmbedFontStyle( const OUString& name, int tag, FontFamily family, FontItalic italic,
+ FontWeight weight, FontPitch pitch, rtl_TextEncoding encoding )
{
- OUString fontUrl = TemporaryFonts::fileUrlForFont( name, style );
- // If a temporary font file exists for this font, assume it was embedded
- // and embed it again.
+ OUString fontUrl = EmbeddedFontsHelper::fontFileUrl( name, family, italic, weight, pitch, encoding );
+ if( fontUrl.isEmpty())
+ return;
// TODO IDocumentSettingAccess::EMBED_SYSTEM_FONTS
osl::File file( fontUrl );
if( file.open( osl_File_OpenFlag_Read ) != osl::File::E_None )
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index af94b1f8467a..37a6d4ee124b 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -244,7 +244,7 @@ public:
void FontPitchType( FontPitch ePitch ) const;
/// Write out the font into the document, if it's an embedded font.
- void EmbedFont( const OUString& name );
+ void EmbedFont( const OUString& name, FontFamily family, FontPitch pitch, rtl_TextEncoding encoding );
/// Definition of a numbering instance.
virtual void NumberingDefinition( sal_uInt16 nId, const SwNumRule &rRule );
@@ -326,7 +326,8 @@ private:
void WriteFFData( const FieldInfos& rInfos );
- void EmbedFontStyle( const OUString& name, int tag, const char* style );
+ void EmbedFontStyle( const OUString& name, int tag, FontFamily family, FontItalic italic, FontWeight weight,
+ FontPitch pitch, rtl_TextEncoding encoding );
protected:
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 3d40f4e24c9e..4c9e80f7ce8e 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -718,7 +718,7 @@ void wwFont::WriteDocx( DocxAttributeOutput* rAttrOutput ) const
rAttrOutput->FontCharset( sw::ms::rtl_TextEncodingToWinCharset( meChrSet ), meChrSet );
rAttrOutput->FontFamilyType( meFamily );
rAttrOutput->FontPitchType( mePitch );
- rAttrOutput->EmbedFont( msFamilyNm );
+ rAttrOutput->EmbedFont( msFamilyNm, meFamily, mePitch, meChrSet );
rAttrOutput->EndFont();
}
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index c71543de585b..49c1c786efae 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -207,6 +207,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/gdi/configsettings \
vcl/source/gdi/cvtgrf \
vcl/source/gdi/cvtsvm \
+ vcl/source/gdi/embeddedfontshelper \
vcl/source/gdi/extoutdevdata \
vcl/source/gdi/font \
vcl/source/gdi/gdimtf \
@@ -255,7 +256,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/gdi/salmisc \
vcl/source/gdi/salnativewidgets-none \
vcl/source/gdi/svgdata \
- vcl/source/gdi/temporaryfonts \
vcl/source/gdi/textlayout \
vcl/source/gdi/virdev \
vcl/source/gdi/wall \
diff --git a/vcl/Package_inc.mk b/vcl/Package_inc.mk
index 53a7326279b1..6088b66f2dd3 100644
--- a/vcl/Package_inc.mk
+++ b/vcl/Package_inc.mk
@@ -144,7 +144,7 @@ $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/tabctrl.hxx,vcl/tabctrl.hxx))
$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/tabdlg.hxx,vcl/tabdlg.hxx))
$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/tabpage.hxx,vcl/tabpage.hxx))
$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/taskpanelist.hxx,vcl/taskpanelist.hxx))
-$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/temporaryfonts.hxx,vcl/temporaryfonts.hxx))
+$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/embeddedfontshelper.hxx,vcl/embeddedfontshelper.hxx))
$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/textdata.hxx,vcl/textdata.hxx))
$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/texteng.hxx,vcl/texteng.hxx))
$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/textview.hxx,vcl/textview.hxx))
diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx
index 175b000c8c5e..cd5e437408ab 100644
--- a/vcl/generic/fontmanager/fontmanager.cxx
+++ b/vcl/generic/fontmanager/fontmanager.cxx
@@ -33,7 +33,7 @@
#include "vcl/fontmanager.hxx"
#include "vcl/strhelper.hxx"
#include "vcl/ppdparser.hxx"
-#include <vcl/temporaryfonts.hxx>
+#include <vcl/embeddedfontshelper.hxx>
#include "tools/urlobj.hxx"
#include "tools/stream.hxx"
diff --git a/vcl/inc/vcl/temporaryfonts.hxx b/vcl/inc/vcl/embeddedfontshelper.hxx
index f8fe162c67b1..96e8226b3b00 100644
--- a/vcl/inc/vcl/temporaryfonts.hxx
+++ b/vcl/inc/vcl/embeddedfontshelper.hxx
@@ -7,31 +7,35 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#ifndef VCL_TEMPORARYFONTS_HXX
-#define VCL_TEMPORARYFONTS_HXX
+#ifndef VCL_EMBEDDEDFONTSHELPER_HXX
+#define VCL_EMBEDDEDFONTSHELPER_HXX
#include <vcl/dllapi.h>
#include <rtl/ustring.hxx>
+#include <tools/fontenum.hxx>
/**
- Management of temporary fonts (e.g. embedded in documents).
+ Helper functions for handling embedded fonts in documents.
- This class handles adding of temporary fonts.
- @since LibreOffice 4.0
*/
-class VCL_DLLPUBLIC TemporaryFonts
+class VCL_DLLPUBLIC EmbeddedFontsHelper
{
public:
/**
- Returns an URL for a file where to store contents of a temporary font
- (the file may or may not exist). The file will be cleaned up automatically as appropriate.
+ Returns URL for a font file for the given font, or empty if it does not exist.
+ */
+ static OUString fontFileUrl( const OUString& familyName, FontFamily family, FontItalic italic,
+ FontWeight weight, FontPitch pitch, rtl_TextEncoding encoding );
+ /**
+ Returns an URL for a file where to store contents of a given temporary font.
+ The file may or not may not exist yet, and will be cleaned up automatically as appropriate.
Use activateTemporaryFont() to actually enable usage of the font.
@param fontName name of the font (e.g. 'Times New Roman')
@param fontStyle font style, "" for regular, "bi" for bold italic, etc.
*/
- static OUString fileUrlForFont( const OUString& fontName, const char* fontStyle );
+ static OUString fileUrlForTemporaryFont( const OUString& fontName, const char* fontStyle );
/**
Adds the given font to the list of known fonts. The font is used only until application
@@ -43,10 +47,10 @@ public:
static void activateFont( const OUString& fontName, const OUString& fileUrl );
/**
- Removes all temporary fonts.
+ Removes all temporary fonts in the path used by fileUrlForTemporaryFont().
@internal
*/
- static void clear();
+ static void clearTemporaryFontFiles();
};
#endif
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 7f22828fa1e1..c89a04e110c6 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -40,7 +40,7 @@
#include "vcl/unowrap.hxx"
#include "vcl/configsettings.hxx"
#include "vcl/lazydelete.hxx"
-#include "vcl/temporaryfonts.hxx"
+#include "vcl/embeddedfontshelper.hxx"
#ifdef WNT
#include <svsys.h>
@@ -248,7 +248,7 @@ sal_Bool InitVCL()
if( pExceptionHandler != NULL )
return sal_False;
- TemporaryFonts::clear();
+ EmbeddedFontsHelper::clearTemporaryFontFiles();
if( ! ImplGetSVData() )
ImplInitSVData();
@@ -575,7 +575,7 @@ void DeInitVCL()
pOwnSvApp = NULL;
}
- TemporaryFonts::clear();
+ EmbeddedFontsHelper::clearTemporaryFontFiles();
}
// only one call is allowed
diff --git a/vcl/source/gdi/embeddedfontshelper.cxx b/vcl/source/gdi/embeddedfontshelper.cxx
new file mode 100644
index 000000000000..b5d1c01d8432
--- /dev/null
+++ b/vcl/source/gdi/embeddedfontshelper.cxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <vcl/embeddedfontshelper.hxx>
+
+#include <osl/file.hxx>
+#include <rtl/bootstrap.hxx>
+#include <vcl/fontmanager.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/outdev.hxx>
+
+using namespace std;
+
+void EmbeddedFontsHelper::clearTemporaryFontFiles()
+{
+ OUString path = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
+ rtl::Bootstrap::expandMacros( path );
+ path += "/user/temp/embeddedfonts/";
+ osl::Directory dir( path );
+ if( dir.reset() == osl::Directory::E_None )
+ {
+ for(;;)
+ {
+ osl::DirectoryItem item;
+ if( dir.getNextItem( item ) != osl::Directory::E_None )
+ break;
+ osl::FileStatus status( osl_FileStatus_Mask_FileURL );
+ if( item.getFileStatus( status ) == osl::File::E_None )
+ osl::File::remove( status.getFileURL());
+ }
+ }
+}
+
+OUString EmbeddedFontsHelper::fileUrlForTemporaryFont( const OUString& fontName, const char* fontStyle )
+{
+ OUString path = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
+ rtl::Bootstrap::expandMacros( path );
+ path += "/user/temp/embeddedfonts/";
+ osl::Directory::createPath( path );
+ OUString filename = fontName;
+ filename += OStringToOUString( fontStyle, RTL_TEXTENCODING_ASCII_US );
+ filename += ".ttf"; // TODO is it always ttf?
+ return path + filename;
+}
+
+void EmbeddedFontsHelper::activateFont( const OUString& fontName, const OUString& fileUrl )
+{
+ OutputDevice *pDevice = Application::GetDefaultDevice();
+ pDevice->AddTempDevFont( fileUrl, fontName );
+ pDevice->ImplUpdateAllFontData( true );
+}
+
+OUString EmbeddedFontsHelper::fontFileUrl( const OUString& familyName, FontFamily family, FontItalic italic,
+ FontWeight weight, FontPitch pitch, rtl_TextEncoding )
+{
+ OUString url;
+ psp::PrintFontManager& mgr = psp::PrintFontManager::get();
+ list< psp::fontID > fontIds;
+ mgr.getFontList( fontIds );
+ for( list< psp::fontID >::const_iterator it = fontIds.begin();
+ it != fontIds.end();
+ ++it )
+ {
+ psp::fontID id = *it;
+ psp::FastPrintFontInfo info;
+ if( !mgr.getFontFastInfo( id, info ))
+ continue;
+ if( info.m_aFamilyName == familyName )
+ {
+ // Ignore comparing text encodings, at least for now. They cannot be trivially compared
+ // (e.g. UCS2 and UTF8 are technically the same characters, just have different encoding,
+ // and just having a unicode font doesn't say what glyphs it actually contains).
+ // It is possible that it still may be needed to do at least some checks here
+ // for some encodings (can one font have more font files for more encodings?).
+ if(( family == FAMILY_DONTKNOW || info.m_eFamilyStyle == family )
+ && ( italic == ITALIC_DONTKNOW || info.m_eItalic == italic )
+ && ( weight == WEIGHT_DONTKNOW || info.m_eWeight == weight )
+ && ( pitch == PITCH_DONTKNOW || info.m_ePitch == pitch ))
+ { // Exact match, return it immediately.
+ OUString ret;
+ osl::File::getFileURLFromSystemPath(
+ OStringToOUString( mgr.getFontFileSysPath( id ), RTL_TEXTENCODING_UTF8 ), ret );
+ return ret;
+ }
+ if(( info.m_eFamilyStyle == FAMILY_DONTKNOW || family == FAMILY_DONTKNOW || info.m_eFamilyStyle == family )
+ && ( info.m_eItalic == ITALIC_DONTKNOW || italic == ITALIC_DONTKNOW || info.m_eItalic == italic )
+ && ( info.m_eWeight == WEIGHT_DONTKNOW || weight == WEIGHT_DONTKNOW || info.m_eWeight == weight )
+ && ( info.m_ePitch == PITCH_DONTKNOW || pitch == PITCH_DONTKNOW || info.m_ePitch == pitch ))
+ { // Some fonts specify 'DONTKNOW' for some things, still a good match, if we don't find a better one.
+ osl::File::getFileURLFromSystemPath(
+ OStringToOUString( mgr.getFontFileSysPath( id ), RTL_TEXTENCODING_UTF8 ), url );
+ }
+ }
+ }
+ return url;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/temporaryfonts.cxx b/vcl/source/gdi/temporaryfonts.cxx
deleted file mode 100644
index 292e09e25485..000000000000
--- a/vcl/source/gdi/temporaryfonts.cxx
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include <vcl/temporaryfonts.hxx>
-
-#include <osl/file.hxx>
-#include <rtl/bootstrap.hxx>
-#include <vcl/svapp.hxx>
-#include <vcl/outdev.hxx>
-
-void TemporaryFonts::clear()
-{
- OUString path = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
- rtl::Bootstrap::expandMacros( path );
- path += "/user/temp/fonts/";
- osl::Directory dir( path );
- if( dir.reset() == osl::Directory::E_None )
- {
- for(;;)
- {
- osl::DirectoryItem item;
- if( dir.getNextItem( item ) != osl::Directory::E_None )
- break;
- osl::FileStatus status( osl_FileStatus_Mask_FileURL );
- if( item.getFileStatus( status ) == osl::File::E_None )
- osl::File::remove( status.getFileURL());
- }
- }
-}
-
-OUString TemporaryFonts::fileUrlForFont( const OUString& fontName, const char* fontStyle )
-{
- OUString path = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
- rtl::Bootstrap::expandMacros( path );
- path += "/user/temp/fonts/";
- osl::Directory::createPath( path );
- OUString filename = fontName;
- filename += OStringToOUString( fontStyle, RTL_TEXTENCODING_ASCII_US );
- filename += ".ttf"; // TODO is it always ttf?
- return path + filename;
-}
-
-void TemporaryFonts::activateFont( const OUString& fontName, const OUString& fileUrl )
-{
- OutputDevice *pDevice = Application::GetDefaultDevice();
- pDevice->AddTempDevFont( fileUrl, fontName );
- pDevice->ImplUpdateAllFontData( true );
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/inc/pch/precompiled_writerfilter.hxx b/writerfilter/inc/pch/precompiled_writerfilter.hxx
index 23a12997d1af..f2565ad407d3 100644
--- a/writerfilter/inc/pch/precompiled_writerfilter.hxx
+++ b/writerfilter/inc/pch/precompiled_writerfilter.hxx
@@ -209,7 +209,7 @@
#include <vcl/graph.hxx>
#include <vcl/outdev.hxx>
#include <vcl/svapp.hxx>
-#include <vcl/temporaryfonts.hxx>
+#include <vcl/embeddedfontshelper.hxx>
#include <vcl/wmf.hxx>
#include <vector>
#include <xmloff/odffields.hxx>
diff --git a/writerfilter/source/dmapper/FontTable.cxx b/writerfilter/source/dmapper/FontTable.cxx
index 08aab1149b75..cb737f1edb36 100644
--- a/writerfilter/source/dmapper/FontTable.cxx
+++ b/writerfilter/source/dmapper/FontTable.cxx
@@ -24,7 +24,7 @@
#include <osl/file.hxx>
#include <stdio.h>
#include <rtl/tencinfo.h>
-#include <vcl/temporaryfonts.hxx>
+#include <vcl/embeddedfontshelper.hxx>
#include "dmapperLoggers.hxx"
@@ -251,7 +251,7 @@ EmbeddedFontHandler::~EmbeddedFontHandler()
{
if( !inputStream.is())
return;
- OUString fileUrl = TemporaryFonts::fileUrlForFont( fontName, style );
+ OUString fileUrl = EmbeddedFontsHelper::fileUrlForTemporaryFont( fontName, style );
osl::File file( fileUrl );
switch( file.open( osl_File_OpenFlag_Create | osl_File_OpenFlag_Write ))
{
@@ -318,7 +318,7 @@ EmbeddedFontHandler::~EmbeddedFontHandler()
osl::File::remove( fileUrl );
return;
}
- TemporaryFonts::activateFont( fontName, fileUrl );
+ EmbeddedFontsHelper::activateFont( fontName, fileUrl );
}
void EmbeddedFontHandler::lcl_attribute( Id name, Value& val )
diff --git a/xmloff/inc/pch/precompiled_xo.hxx b/xmloff/inc/pch/precompiled_xo.hxx
index d13eef387807..aeffb54ed465 100644
--- a/xmloff/inc/pch/precompiled_xo.hxx
+++ b/xmloff/inc/pch/precompiled_xo.hxx
@@ -550,7 +550,7 @@
#include <unotools/streamwrap.hxx>
#include <unotools/syslocale.hxx>
#include <utility>
-#include <vcl/temporaryfonts.hxx>
+#include <vcl/embeddedfontshelper.hxx>
#include <vector>
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/style/XMLFontAutoStylePool.cxx b/xmloff/source/style/XMLFontAutoStylePool.cxx
index 9163ef593476..e8c33aafdd71 100644
--- a/xmloff/source/style/XMLFontAutoStylePool.cxx
+++ b/xmloff/source/style/XMLFontAutoStylePool.cxx
@@ -25,7 +25,7 @@
#include "fonthdl.hxx"
#include <xmloff/xmlexp.hxx>
#include <xmloff/XMLFontAutoStylePool.hxx>
-#include <vcl/temporaryfonts.hxx>
+#include <vcl/embeddedfontshelper.hxx>
#include <osl/file.hxx>
#include <com/sun/star/embed/ElementModes.hpp>
@@ -276,18 +276,25 @@ void XMLFontAutoStylePool::exportXML()
{
std::vector< OUString > fileUrls;
static const char* const styles[] = { "", "b", "i", "bi" };
+ static const FontWeight weight[] = { WEIGHT_NORMAL, WEIGHT_BOLD, WEIGHT_NORMAL, WEIGHT_BOLD };
+ static const FontItalic italic[] = { ITALIC_NONE, ITALIC_NONE, ITALIC_NORMAL, ITALIC_NORMAL };
+ assert( SAL_N_ELEMENTS( styles ) == SAL_N_ELEMENTS( italic ));
+ assert( SAL_N_ELEMENTS( styles ) == SAL_N_ELEMENTS( weight ));
for( unsigned int j = 0;
j < SAL_N_ELEMENTS( styles );
++j )
{
- OUString fileUrl = TemporaryFonts::fileUrlForFont( pEntry->GetFamilyName(), styles[ j ] );
+ OUString fileUrl = EmbeddedFontsHelper::fontFileUrl( pEntry->GetFamilyName(), pEntry->GetFamily(),
+ italic[ j ], weight[ j ], pEntry->GetPitch(), pEntry->GetEncoding());
+ if( fileUrl.isEmpty())
+ continue;
if( !fontFilesMap.count( fileUrl ))
{
OUString docUrl = embedFontFile( fileUrl, styles[ j ] );
if( !docUrl.isEmpty())
fontFilesMap[ fileUrl ] = docUrl;
else
- continue; // --> failed (most probably this font is not embedded)
+ continue; // --> failed to embed
}
fileUrls.push_back( fileUrl );
}
diff --git a/xmloff/source/style/XMLFontStylesContext.cxx b/xmloff/source/style/XMLFontStylesContext.cxx
index 86433b8480db..f269284f3319 100644
--- a/xmloff/source/style/XMLFontStylesContext.cxx
+++ b/xmloff/source/style/XMLFontStylesContext.cxx
@@ -26,7 +26,7 @@
#include <osl/file.hxx>
#include <rtl/logfile.hxx>
-#include <vcl/temporaryfonts.hxx>
+#include <vcl/embeddedfontshelper.hxx>
#include <xmloff/nmspmap.hxx>
#include "xmloff/xmlnmspe.hxx"
@@ -241,7 +241,7 @@ void XMLFontStyleContextFontFaceUri::handleEmbeddedFont( const OUString& url )
OUString fontName = font.familyName();
const char* style = "";
// OOXML needs to know what kind of style the font is (regular, italic, bold, bold-italic),
- // and the TemporaryFonts class is modelled after it. But ODF doesn't (need to) include
+ // and the EmbeddedFontsHelper class is modelled after it. But ODF doesn't (need to) include
// this information, so try to guess from the name (LO encodes the style), otherwise
// go with regular and hope it works.
if( url.endsWithIgnoreAsciiCase( "bi.ttf" ))
@@ -258,7 +258,7 @@ void XMLFontStyleContextFontFaceUri::handleEmbeddedFont( const OUString& url )
if( url.indexOf( '/' ) > -1 ) // TODO what if more levels?
storage.set( storage->openStorageElement( url.copy( 0, url.indexOf( '/' )),
::embed::ElementModes::READ ), uno::UNO_QUERY_THROW );
- OUString fileUrl = TemporaryFonts::fileUrlForFont( fontName, style );
+ OUString fileUrl = EmbeddedFontsHelper::fileUrlForTemporaryFont( fontName, style );
osl::File file( fileUrl );
switch( file.open( osl_File_OpenFlag_Create | osl_File_OpenFlag_Write ))
{
@@ -291,7 +291,7 @@ void XMLFontStyleContextFontFaceUri::handleEmbeddedFont( const OUString& url )
osl::File::remove( fileUrl );
return;
}
- TemporaryFonts::activateFont( fontName, fileUrl );
+ EmbeddedFontsHelper::activateFont( fontName, fileUrl );
GetImport().NotifyEmbeddedFontRead();
}
else