[Libreoffice-commits] .: 2 commits - sw/source vcl/generic vcl/inc vcl/Library_vcl.mk vcl/Package_inc.mk vcl/source writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Sep 7 05:38:30 PDT 2012


 sw/source/filter/ww8/docxattributeoutput.cxx |    4 +-
 vcl/Library_vcl.mk                           |    1 
 vcl/Package_inc.mk                           |    1 
 vcl/generic/fontmanager/fontmanager.cxx      |   45 +---------------------
 vcl/inc/vcl/fontmanager.hxx                  |   25 ------------
 vcl/inc/vcl/temporaryfonts.hxx               |   54 +++++++++++++++++++++++++++
 vcl/source/gdi/temporaryfonts.cxx            |   54 +++++++++++++++++++++++++++
 writerfilter/source/dmapper/FontTable.cxx    |    6 +--
 8 files changed, 119 insertions(+), 71 deletions(-)

New commits:
commit 063966ee0e8b98231cb622311eb2131d19531926
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri Sep 7 14:35:10 2012 +0200

    Revert "vcl: export PrintFontManager"
    
    This reverts commit 23cd24bd4d4df9247f8f0496f9934a2ce6d110dd.
    Not needed after the temporary font code has been moved elsewhere.

diff --git a/vcl/inc/vcl/fontmanager.hxx b/vcl/inc/vcl/fontmanager.hxx
index 3049be0..6666f0f 100644
--- a/vcl/inc/vcl/fontmanager.hxx
+++ b/vcl/inc/vcl/fontmanager.hxx
@@ -153,7 +153,7 @@ class FontCache;
 
 class FontCache;
 
-class VCL_DLLPUBLIC PrintFontManager
+class VCL_PLUGIN_PUBLIC PrintFontManager
 {
     struct PrintFont;
     struct TrueTypeFontFile;
commit fc169270eaeb8156d40740cd088cd8ed958ea99c
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri Sep 7 14:33:54 2012 +0200

    move the code for adding temporary fonts to a separate class
    
    I'm a bit confused on how this stuff is separated between platforms,
    so better do it this way.
    
    Change-Id: I2dbd9baef587c81ee37b509bde272ef970f5b118

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index f9de95a..e4cd092 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -122,7 +122,7 @@
 #include <rtl/strbuf.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <rtl/ustring.hxx>
-#include <vcl/fontmanager.hxx>
+#include <vcl/temporaryfonts.hxx>
 
 #include <tools/color.hxx>
 
@@ -2829,7 +2829,7 @@ static inline char toHexChar( int value )
 
 void DocxAttributeOutput::EmbedFontStyle( const OUString& name, int tag, const char* style )
 {
-    OUString fontUrl = psp::PrintFontManager::get().fileUrlForTemporaryFont( name, style );
+    OUString fontUrl = TemporaryFonts::fileUrlForFont( name, style );
     // If a temporary font file exists for this font, assume it was embedded
     // and embed it again.
     // TODO IDocumentSettingAccess::EMBED_SYSTEM_FONTS
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 0a7c807..f8afea0 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -234,6 +234,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/gdi/salmisc \
     vcl/source/gdi/salnativewidgets-none \
     vcl/source/gdi/svgread \
+    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 3f95e97..e791793 100644
--- a/vcl/Package_inc.mk
+++ b/vcl/Package_inc.mk
@@ -150,6 +150,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/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 7b9294a..209970d 100644
--- a/vcl/generic/fontmanager/fontmanager.cxx
+++ b/vcl/generic/fontmanager/fontmanager.cxx
@@ -43,8 +43,7 @@
 #include "vcl/fontmanager.hxx"
 #include "vcl/strhelper.hxx"
 #include "vcl/ppdparser.hxx"
-#include <vcl/svapp.hxx>
-#include <vcl/outdev.hxx>
+#include <vcl/temporaryfonts.hxx>
 
 #include "tools/urlobj.hxx"
 #include "tools/stream.hxx"
@@ -53,7 +52,6 @@
 #include "osl/file.hxx"
 #include "osl/process.h"
 
-#include <rtl/bootstrap.hxx>
 #include "rtl/tencinfo.h"
 #include "rtl/ustrbuf.hxx"
 #include "rtl/strbuf.hxx"
@@ -1037,7 +1035,7 @@ PrintFontManager::~PrintFontManager()
     delete m_pAtoms;
     if( m_pFontCache )
         delete m_pFontCache;
-    cleanTemporaryFonts();
+    TemporaryFonts::clear();
 }
 
 // -------------------------------------------------------------------------
@@ -1664,7 +1662,7 @@ void PrintFontManager::initialize()
     CALLGRIND_ZERO_STATS();
     #endif
 
-    cleanTemporaryFonts();
+    TemporaryFonts::clear();
 
     long aDirEntBuffer[ (sizeof(struct dirent)+_PC_NAME_MAX)+1 ];
 
@@ -3063,41 +3061,4 @@ bool PrintFontManager::readOverrideMetrics()
     return true;
 }
 
-void PrintFontManager::cleanTemporaryFonts()
-{
-    OUString path = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
-    rtl::Bootstrap::expandMacros( path );
-    path += "/user/temp/fonts/";
-    osl::Directory dir( path );
-    dir.reset();
-    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 PrintFontManager::fileUrlForTemporaryFont( 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 PrintFontManager::activateTemporaryFont( 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/vcl/inc/vcl/fontmanager.hxx b/vcl/inc/vcl/fontmanager.hxx
index b659435..3049be0 100644
--- a/vcl/inc/vcl/fontmanager.hxx
+++ b/vcl/inc/vcl/fontmanager.hxx
@@ -330,8 +330,6 @@ class VCL_DLLPUBLIC PrintFontManager
     rtl::OString getDirectory( int nAtom ) const;
     int getDirectoryAtom( const rtl::OString& rDirectory, bool bCreate = false );
 
-    void cleanTemporaryFonts();
-
     /* try to initialize fonts from libfontconfig
 
     called from <code>initialize()</code>
@@ -595,27 +593,6 @@ public:
     bool Substitute( FontSelectPattern &rPattern, rtl::OUString& rMissingCodes );
 
     int FreeTypeCharIndex( void *pFace, sal_uInt32 aChar );
-
-    /**
-      Returns an URL for a file where to store contents of a temporary font, or an empty string
-      if this font is already known. 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.
-      @since 3.7
-    */
-    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
-      @since 3.7
-    */
-    void activateTemporaryFont( const OUString& fontName, const OUString& fileUrl );
 };
 
 } // namespace
diff --git a/vcl/inc/vcl/temporaryfonts.hxx b/vcl/inc/vcl/temporaryfonts.hxx
new file mode 100644
index 0000000..6333b92
--- /dev/null
+++ b/vcl/inc/vcl/temporaryfonts.hxx
@@ -0,0 +1,54 @@
+/* -*- 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 3.7
+*/
+class VCL_DLLPUBLIC TemporaryFonts
+{
+public:
+    /**
+      Returns an URL for a file where to store contents of a temporary font, or an empty string
+      if this font is already known. 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/gdi/temporaryfonts.cxx b/vcl/source/gdi/temporaryfonts.cxx
new file mode 100644
index 0000000..e74ea18
--- /dev/null
+++ b/vcl/source/gdi/temporaryfonts.cxx
@@ -0,0 +1,54 @@
+/* -*- 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 );
+    dir.reset();
+    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/source/dmapper/FontTable.cxx b/writerfilter/source/dmapper/FontTable.cxx
index 9bb108b..d821822 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/fontmanager.hxx>
+#include <vcl/temporaryfonts.hxx>
 
 #include "dmapperLoggers.hxx"
 
@@ -252,7 +252,7 @@ EmbeddedFontHandler::~EmbeddedFontHandler()
 {
     if( !inputStream.is())
         return;
-    OUString fileUrl = psp::PrintFontManager::get().fileUrlForTemporaryFont( fontName, style );
+    OUString fileUrl = TemporaryFonts::fileUrlForFont( fontName, style );
     osl::File file( fileUrl );
     switch( file.open( osl_File_OpenFlag_Create | osl_File_OpenFlag_Write ))
     {
@@ -319,7 +319,7 @@ EmbeddedFontHandler::~EmbeddedFontHandler()
         osl::File::remove( fileUrl );
         return;
     }
-    psp::PrintFontManager::get().activateTemporaryFont( fontName, fileUrl );
+    TemporaryFonts::activateFont( fontName, fileUrl );
 }
 
 void EmbeddedFontHandler::lcl_attribute( Id name, Value& val )


More information about the Libreoffice-commits mailing list