[Libreoffice-commits] core.git: 2 commits - dbaccess/source reportdesign/source sc/source sw/inc sw/source vcl/generic vcl/inc vcl/Library_vcl.mk vcl/Package_inc.mk vcl/source writerfilter/inc writerfilter/source xmloff/inc xmloff/source

Luboš Luňák l.lunak at suse.cz
Thu Feb 21 09:35:24 PST 2013


 dbaccess/source/filter/xml/xmlExport.cxx          |    3 
 reportdesign/source/filter/xml/xmlExport.cxx      |    3 
 sc/source/filter/xml/xmlfonte.cxx                 |    6 -
 sw/inc/pch/precompiled_msword.hxx                 |    2 
 sw/source/filter/ww8/docxattributeoutput.cxx      |   21 ++--
 sw/source/filter/ww8/docxattributeoutput.hxx      |    5 -
 sw/source/filter/ww8/wrtw8sty.cxx                 |    2 
 sw/source/filter/xml/xmlfonte.cxx                 |    4 
 vcl/Library_vcl.mk                                |    2 
 vcl/Package_inc.mk                                |    2 
 vcl/generic/fontmanager/fontmanager.cxx           |    2 
 vcl/inc/vcl/embeddedfontshelper.hxx               |   58 ++++++++++++
 vcl/inc/vcl/temporaryfonts.hxx                    |   54 -----------
 vcl/source/app/svmain.cxx                         |    6 -
 vcl/source/gdi/embeddedfontshelper.cxx            |  104 ++++++++++++++++++++++
 vcl/source/gdi/temporaryfonts.cxx                 |   56 -----------
 writerfilter/inc/pch/precompiled_writerfilter.hxx |    2 
 writerfilter/source/dmapper/FontTable.cxx         |    6 -
 xmloff/inc/pch/precompiled_xo.hxx                 |    2 
 xmloff/inc/xmloff/XMLFontAutoStylePool.hxx        |    9 +
 xmloff/source/style/XMLFontAutoStylePool.cxx      |   45 +++++----
 xmloff/source/style/XMLFontStylesContext.cxx      |    8 -
 xmloff/source/style/xmlnume.cxx                   |    8 -
 xmloff/source/text/txtexppr.cxx                   |   11 --
 24 files changed, 240 insertions(+), 181 deletions(-)

New commits:
commit 596bd0f61f8cfc957410148ae221c62331067bdd
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Feb 21 13:43:44 2013 +0100

    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

diff --git a/sw/inc/pch/precompiled_msword.hxx b/sw/inc/pch/precompiled_msword.hxx
index acacb8b..e05919f 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 8a6e8bb..b7e211f 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 af94b1f..37a6d4e 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 3d40f4e..4c9e80f 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 c71543d..49c1c78 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 53a7326..6088b66 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 b571955..c84b15a 100644
--- a/vcl/generic/fontmanager/fontmanager.cxx
+++ b/vcl/generic/fontmanager/fontmanager.cxx
@@ -34,7 +34,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/embeddedfontshelper.hxx b/vcl/inc/vcl/embeddedfontshelper.hxx
new file mode 100644
index 0000000..96e8226
--- /dev/null
+++ b/vcl/inc/vcl/embeddedfontshelper.hxx
@@ -0,0 +1,58 @@
+/* -*- 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/.
+ */
+
+#ifndef VCL_EMBEDDEDFONTSHELPER_HXX
+#define VCL_EMBEDDEDFONTSHELPER_HXX
+
+#include <vcl/dllapi.h>
+
+#include <rtl/ustring.hxx>
+#include <tools/fontenum.hxx>
+
+/**
+ Helper functions for handling embedded fonts in documents.
+
+*/
+class VCL_DLLPUBLIC EmbeddedFontsHelper
+{
+public:
+    /**
+      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 fileUrlForTemporaryFont( const OUString& fontName, const char* fontStyle );
+
+    /**
+      Adds the given font to the list of known fonts. The font is used only until application
+      exit.
+
+      @param fontName name of the font (e.g. 'Times New Roman')
+      @param fileUrl URL of the font file
+    */
+    static void activateFont( const OUString& fontName, const OUString& fileUrl );
+
+    /**
+      Removes all temporary fonts in the path used by fileUrlForTemporaryFont().
+      @internal
+    */
+    static void clearTemporaryFontFiles();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/vcl/temporaryfonts.hxx b/vcl/inc/vcl/temporaryfonts.hxx
deleted file mode 100644
index f8fe162..0000000
--- a/vcl/inc/vcl/temporaryfonts.hxx
+++ /dev/null
@@ -1,54 +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/.
- */
-
-#ifndef VCL_TEMPORARYFONTS_HXX
-#define VCL_TEMPORARYFONTS_HXX
-
-#include <vcl/dllapi.h>
-
-#include <rtl/ustring.hxx>
-
-/**
- Management of temporary fonts (e.g. embedded in documents).
-
- This class handles adding of temporary fonts.
- @since LibreOffice 4.0
-*/
-class VCL_DLLPUBLIC TemporaryFonts
-{
-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.
-      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 );
-
-    /**
-      Adds the given font to the list of known fonts. The font is used only until application
-      exit.
-
-      @param fontName name of the font (e.g. 'Times New Roman')
-      @param fileUrl URL of the font file
-    */
-    static void activateFont( const OUString& fontName, const OUString& fileUrl );
-
-    /**
-      Removes all temporary fonts.
-      @internal
-    */
-    static void clear();
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 9b83c6d..308bfb7 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();
@@ -578,7 +578,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 0000000..b5d1c01
--- /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 292e09e..0000000
--- 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 23a1299..f2565ad 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 08aab11..cb737f1 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 d13eef3..aeffb54 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 9163ef5..e8c33aa 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 86433b8..f269284 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
commit 895dc882c451bcc03236267d3ce33be218451721
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Feb 21 12:45:12 2013 +0100

    generic integers to enums
    
    Change-Id: Ic43283b9e1666c0f2162e277dc79fc6f992ef616

diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx
index ca5bb8c..4410d85 100644
--- a/dbaccess/source/filter/xml/xmlExport.cxx
+++ b/dbaccess/source/filter/xml/xmlExport.cxx
@@ -1177,7 +1177,8 @@ void ODBExport::exportAutoStyle(XPropertySet* _xProp)
             xCollection.set( xSup->getColumns(), UNO_SET_THROW );
             awt::FontDescriptor aFont;
             _xProp->getPropertyValue(PROPERTY_FONT) >>= aFont;
-            GetFontAutoStylePool()->Add(aFont.Name,aFont.StyleName,aFont.Family,aFont.Pitch,aFont.CharSet );
+            GetFontAutoStylePool()->Add(aFont.Name,aFont.StyleName,static_cast<FontFamily>(aFont.Family),
+                static_cast<FontPitch>(aFont.Pitch),aFont.CharSet );
 
             m_aCurrentPropertyStates = m_xCellExportHelper->Filter(_xProp);
             if ( !m_aCurrentPropertyStates.empty() && !xCollection->hasElements() )
diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx
index df6a24e..7a41d84 100644
--- a/reportdesign/source/filter/xml/xmlExport.cxx
+++ b/reportdesign/source/filter/xml/xmlExport.cxx
@@ -1150,7 +1150,8 @@ void ORptExport::exportAutoStyle(XPropertySet* _xProp,const Reference<XFormatted
         {
             const awt::FontDescriptor aFont = xFormat->getFontDescriptor();
             OSL_ENSURE(!aFont.Name.isEmpty(),"No Font Name !");
-            GetFontAutoStylePool()->Add(aFont.Name,aFont.StyleName,aFont.Family,aFont.Pitch,aFont.CharSet );
+            GetFontAutoStylePool()->Add(aFont.Name,aFont.StyleName,static_cast<FontFamily>(aFont.Family),
+                static_cast<FontPitch>(aFont.Pitch),aFont.CharSet );
         }
         catch(beans::UnknownPropertyException&)
         {
diff --git a/sc/source/filter/xml/xmlfonte.cxx b/sc/source/filter/xml/xmlfonte.cxx
index 0caca55..4092bfa 100644
--- a/sc/source/filter/xml/xmlfonte.cxx
+++ b/sc/source/filter/xml/xmlfonte.cxx
@@ -49,8 +49,7 @@ void ScXMLFontAutoStylePool_Impl::AddFontItems(sal_uInt16* pWhichIds, sal_uInt8
         {
             const SvxFontItem *pFont((const SvxFontItem *)pItem);
             Add( pFont->GetFamilyName(), pFont->GetStyleName(),
-                    sal::static_int_cast<sal_Int16>(pFont->GetFamily()),
-                    sal::static_int_cast<sal_Int16>(pFont->GetPitch()),
+                    pFont->GetFamily(), pFont->GetPitch(),
                     pFont->GetCharSet() );
         }
         sal_uInt32 nItems(pItemPool->GetItemCount2( nWhichId ));
@@ -60,8 +59,7 @@ void ScXMLFontAutoStylePool_Impl::AddFontItems(sal_uInt16* pWhichIds, sal_uInt8
             {
                 const SvxFontItem *pFont((const SvxFontItem *)pItem);
                 Add( pFont->GetFamilyName(), pFont->GetStyleName(),
-                     sal::static_int_cast<sal_Int16>(pFont->GetFamily()),
-                     sal::static_int_cast<sal_Int16>(pFont->GetPitch()),
+                     pFont->GetFamily(), pFont->GetPitch(),
                      pFont->GetCharSet() );
             }
         }
diff --git a/sw/source/filter/xml/xmlfonte.cxx b/sw/source/filter/xml/xmlfonte.cxx
index 60e9dca5..1f1dd57 100644
--- a/sw/source/filter/xml/xmlfonte.cxx
+++ b/sw/source/filter/xml/xmlfonte.cxx
@@ -56,7 +56,7 @@ SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(
         const SvxFontItem& rFont =
             (const SvxFontItem&)rPool.GetDefaultItem( nWhichId );
         Add( rFont.GetFamilyName(), rFont.GetStyleName(),
-             static_cast< sal_uInt16 >(rFont.GetFamily()), static_cast< sal_uInt16 >(rFont.GetPitch()),
+             rFont.GetFamily(), rFont.GetPitch(),
              rFont.GetCharSet() );
         sal_uInt32 nItems = rPool.GetItemCount2( nWhichId );
         for( sal_uInt32 j = 0; j < nItems; ++j )
@@ -66,7 +66,7 @@ SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(
                 const SvxFontItem *pFont =
                             (const SvxFontItem *)pItem;
                 Add( pFont->GetFamilyName(), pFont->GetStyleName(),
-                     static_cast< sal_uInt16 >(pFont->GetFamily()), static_cast< sal_uInt16 >(pFont->GetPitch()),
+                     pFont->GetFamily(), pFont->GetPitch(),
                      pFont->GetCharSet() );
             }
         }
diff --git a/xmloff/inc/xmloff/XMLFontAutoStylePool.hxx b/xmloff/inc/xmloff/XMLFontAutoStylePool.hxx
index 8ed243d..a4c6425 100644
--- a/xmloff/inc/xmloff/XMLFontAutoStylePool.hxx
+++ b/xmloff/inc/xmloff/XMLFontAutoStylePool.hxx
@@ -23,6 +23,7 @@
 #include "sal/config.h"
 #include "xmloff/dllapi.h"
 #include <rtl/ustring.hxx>
+#include <tools/fontenum.hxx>
 #include <xmloff/uniref.hxx>
 #include <set>
 
@@ -53,15 +54,15 @@ public:
     ::rtl::OUString Add(
             const ::rtl::OUString& rFamilyName,
             const ::rtl::OUString& rStyleName,
-            sal_Int16 nFamily,
-            sal_Int16 nPitch,
+            FontFamily nFamily,
+            FontPitch nPitch,
             rtl_TextEncoding eEnc );
 
     ::rtl::OUString Find(
             const ::rtl::OUString& rFamilyName,
             const ::rtl::OUString& rStyleName,
-            sal_Int16 nFamily,
-            sal_Int16 nPitch,
+            FontFamily nFamily,
+            FontPitch nPitch,
             rtl_TextEncoding eEnc )const;
     ::rtl::OUString Find( const ::rtl::OUString& rInternalName ) const;
 
diff --git a/xmloff/source/style/XMLFontAutoStylePool.cxx b/xmloff/source/style/XMLFontAutoStylePool.cxx
index 0f92d66..9163ef5 100644
--- a/xmloff/source/style/XMLFontAutoStylePool.cxx
+++ b/xmloff/source/style/XMLFontAutoStylePool.cxx
@@ -44,8 +44,8 @@ class XMLFontAutoStylePoolEntry_Impl
     OUString    sName;
     OUString    sFamilyName;
     OUString    sStyleName;
-    sal_Int16   nFamily;
-    sal_Int16   nPitch;
+    FontFamily  nFamily;
+    FontPitch   nPitch;
     rtl_TextEncoding eEnc;
 
 public:
@@ -54,22 +54,22 @@ public:
             const ::rtl::OUString& rName,
             const ::rtl::OUString& rFamilyName,
             const ::rtl::OUString& rStyleName,
-            sal_Int16 nFamily,
-            sal_Int16 nPitch,
+            FontFamily nFamily,
+            FontPitch nPitch,
             rtl_TextEncoding eEnc );
 
     inline XMLFontAutoStylePoolEntry_Impl(
             const ::rtl::OUString& rFamilyName,
             const ::rtl::OUString& rStyleName,
-            sal_Int16 nFamily,
-            sal_Int16 nPitch,
+            FontFamily nFamily,
+            FontPitch nPitch,
             rtl_TextEncoding eEnc );
 
     const OUString& GetName() const { return sName; }
     const OUString& GetFamilyName() const { return sFamilyName; }
     const OUString& GetStyleName() const { return sStyleName; }
-    sal_Int16 GetFamily() const {   return nFamily; }
-    sal_Int16 GetPitch() const { return nPitch; }
+    FontFamily GetFamily() const {   return nFamily; }
+    FontPitch GetPitch() const { return nPitch; }
     rtl_TextEncoding GetEncoding() const { return eEnc; }
 };
 
@@ -78,8 +78,8 @@ inline XMLFontAutoStylePoolEntry_Impl::XMLFontAutoStylePoolEntry_Impl(
         const ::rtl::OUString& rName,
         const ::rtl::OUString& rFamilyName,
         const ::rtl::OUString& rStyleName,
-        sal_Int16 nFam,
-        sal_Int16 nP,
+        FontFamily nFam,
+        FontPitch nP,
         rtl_TextEncoding eE ) :
     sName( rName ),
     sFamilyName( rFamilyName ),
@@ -93,8 +93,8 @@ inline XMLFontAutoStylePoolEntry_Impl::XMLFontAutoStylePoolEntry_Impl(
 inline XMLFontAutoStylePoolEntry_Impl::XMLFontAutoStylePoolEntry_Impl(
         const ::rtl::OUString& rFamilyName,
         const ::rtl::OUString& rStyleName,
-        sal_Int16 nFam,
-        sal_Int16 nP,
+        FontFamily nFam,
+        FontPitch nP,
         rtl_TextEncoding eE ) :
     sFamilyName( rFamilyName ),
     sStyleName( rStyleName ),
@@ -149,8 +149,8 @@ XMLFontAutoStylePool::~XMLFontAutoStylePool()
 OUString XMLFontAutoStylePool::Add(
             const OUString& rFamilyName,
             const OUString& rStyleName,
-            sal_Int16 nFamily,
-            sal_Int16 nPitch,
+            FontFamily nFamily,
+            FontPitch nPitch,
             rtl_TextEncoding eEnc )
 {
     OUString sPoolName;
@@ -203,8 +203,8 @@ OUString XMLFontAutoStylePool::Add(
 ::rtl::OUString XMLFontAutoStylePool::Find(
             const OUString& rFamilyName,
             const OUString& rStyleName,
-            sal_Int16 nFamily,
-            sal_Int16 nPitch,
+            FontFamily nFamily,
+            FontPitch nPitch,
             rtl_TextEncoding eEnc ) const
 {
     OUString sName;
diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx
index 6c94cbd..4a6bd2b 100644
--- a/xmloff/source/style/xmlnume.cxx
+++ b/xmloff/source/style/xmlnume.cxx
@@ -118,8 +118,8 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel,
 
     sal_Unicode cBullet = 0xf095;
     OUString sBulletFontName, sBulletFontStyleName ;
-    sal_Int16 eBulletFontFamily = FAMILY_DONTKNOW;
-    sal_Int16 eBulletFontPitch = PITCH_DONTKNOW;
+    FontFamily eBulletFontFamily = FAMILY_DONTKNOW;
+    FontPitch eBulletFontPitch = PITCH_DONTKNOW;
     rtl_TextEncoding eBulletFontEncoding = RTL_TEXTENCODING_DONTKNOW;
 
     OUString sImageURL;
@@ -177,8 +177,8 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel,
             {
                 sBulletFontName = rFDesc.Name;
                 sBulletFontStyleName = rFDesc.StyleName;
-                eBulletFontFamily = (sal_Int16)rFDesc.Family;
-                eBulletFontPitch = (sal_Int16)rFDesc.Pitch;
+                eBulletFontFamily = static_cast< FontFamily >( rFDesc.Family );
+                eBulletFontPitch = static_cast< FontPitch >( rFDesc.Pitch );
                 eBulletFontEncoding = (rtl_TextEncoding)rFDesc.CharSet;
             }
         }
diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx
index 56e36e7..c2c042a 100644
--- a/xmloff/source/text/txtexppr.cxx
+++ b/xmloff/source/text/txtexppr.cxx
@@ -24,8 +24,6 @@
 #include <com/sun/star/text/SizeType.hpp>
 #include <com/sun/star/text/WrapTextMode.hpp>
 #include <com/sun/star/text/TextContentAnchorType.hpp>
-#include <com/sun/star/awt/FontFamily.hpp>
-#include <com/sun/star/awt/FontPitch.hpp>
 #include <com/sun/star/awt/FontUnderline.hpp>
 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
 
@@ -43,7 +41,6 @@ using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::style;
 using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::text;
-using namespace ::com::sun::star::awt;
 
 void XMLTextExportPropertySetMapper::handleElementItem(
         SvXMLExport& rExp,
@@ -204,8 +201,8 @@ void XMLTextExportPropertySetMapper::ContextFontFilter(
 {
     OUString sFamilyName;
     OUString sStyleName;
-    sal_Int16 nFamily = awt::FontFamily::DONTKNOW;
-    sal_Int16 nPitch = awt::FontPitch::DONTKNOW;
+    FontFamily nFamily = FAMILY_DONTKNOW;
+    FontPitch nPitch = PITCH_DONTKNOW;
     rtl_TextEncoding eEnc = RTL_TEXTENCODING_DONTKNOW;
 
     OUString sTmp;
@@ -216,9 +213,9 @@ void XMLTextExportPropertySetMapper::ContextFontFilter(
 
     sal_Int16 nTmp = sal_Int16();
     if( pFontFamilyState && (pFontFamilyState->maValue >>= nTmp ) )
-        nFamily = nTmp;
+        nFamily = static_cast< FontFamily >( nTmp );
     if( pFontPitchState && (pFontPitchState->maValue >>= nTmp ) )
-        nPitch = nTmp;
+        nPitch = static_cast< FontPitch >( nTmp );
     if( pFontCharsetState && (pFontCharsetState->maValue >>= nTmp ) )
         eEnc = (rtl_TextEncoding)nTmp;
 


More information about the Libreoffice-commits mailing list