summaryrefslogtreecommitdiff
path: root/xmloff/source/style
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 /xmloff/source/style
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
Diffstat (limited to 'xmloff/source/style')
-rw-r--r--xmloff/source/style/XMLFontAutoStylePool.cxx13
-rw-r--r--xmloff/source/style/XMLFontStylesContext.cxx8
2 files changed, 14 insertions, 7 deletions
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