summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/inc/vcl/embeddedfontshelper.hxx4
-rw-r--r--vcl/source/gdi/embeddedfontshelper.cxx8
-rw-r--r--xmloff/inc/xmloff/XMLFontAutoStylePool.hxx2
-rw-r--r--xmloff/inc/xmloff/xmlimp.hxx7
-rw-r--r--xmloff/source/core/xmlimp.cxx8
-rw-r--r--xmloff/source/style/XMLFontAutoStylePool.cxx12
-rw-r--r--xmloff/source/style/XMLFontStylesContext.cxx21
7 files changed, 35 insertions, 27 deletions
diff --git a/vcl/inc/vcl/embeddedfontshelper.hxx b/vcl/inc/vcl/embeddedfontshelper.hxx
index 96e8226b3b00..ac4778620361 100644
--- a/vcl/inc/vcl/embeddedfontshelper.hxx
+++ b/vcl/inc/vcl/embeddedfontshelper.hxx
@@ -33,9 +33,9 @@ public:
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.
+ @param extra additional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique
*/
- static OUString fileUrlForTemporaryFont( const OUString& fontName, const char* fontStyle );
+ static OUString fileUrlForTemporaryFont( const OUString& fontName, const char* extra );
/**
Adds the given font to the list of known fonts. The font is used only until application
diff --git a/vcl/source/gdi/embeddedfontshelper.cxx b/vcl/source/gdi/embeddedfontshelper.cxx
index ac18655a837d..e53ed1847133 100644
--- a/vcl/source/gdi/embeddedfontshelper.cxx
+++ b/vcl/source/gdi/embeddedfontshelper.cxx
@@ -49,14 +49,18 @@ void EmbeddedFontsHelper::clearTemporaryFontFiles()
clearDir( path + "fromsystem/" );
}
-OUString EmbeddedFontsHelper::fileUrlForTemporaryFont( const OUString& fontName, const char* fontStyle )
+OUString EmbeddedFontsHelper::fileUrlForTemporaryFont( const OUString& fontName, const char* extra )
{
OUString path = "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
rtl::Bootstrap::expandMacros( path );
path += "/user/temp/embeddedfonts/fromdocs/";
osl::Directory::createPath( path );
OUString filename = fontName;
- filename += OStringToOUString( fontStyle, RTL_TEXTENCODING_ASCII_US );
+ static int uniqueCounter = 0;
+ if( strcmp( extra, "?" ) == 0 )
+ filename += OUString::number( uniqueCounter++ );
+ else
+ filename += OStringToOUString( extra, RTL_TEXTENCODING_ASCII_US );
filename += ".ttf"; // TODO is it always ttf?
return path + filename;
}
diff --git a/xmloff/inc/xmloff/XMLFontAutoStylePool.hxx b/xmloff/inc/xmloff/XMLFontAutoStylePool.hxx
index 1b16725e5a88..ad6a46d81b8e 100644
--- a/xmloff/inc/xmloff/XMLFontAutoStylePool.hxx
+++ b/xmloff/inc/xmloff/XMLFontAutoStylePool.hxx
@@ -39,7 +39,7 @@ class XMLOFF_DLLPUBLIC XMLFontAutoStylePool : public UniRefBase
XMLFontAutoStylePoolNames_Impl m_aNames;
bool tryToEmbedFonts;
- OUString embedFontFile( const OUString& fontUrl, const char* style );
+ OUString embedFontFile( const OUString& fontUrl );
protected:
diff --git a/xmloff/inc/xmloff/xmlimp.hxx b/xmloff/inc/xmloff/xmlimp.hxx
index 24f1f9799c11..750f56725aaf 100644
--- a/xmloff/inc/xmloff/xmlimp.hxx
+++ b/xmloff/inc/xmloff/xmlimp.hxx
@@ -138,6 +138,7 @@ class XMLOFF_DLLPUBLIC SvXMLImport : public ::cppu::WeakImplHelper6<
sal_uInt16 mnImportFlags;
sal_uInt16 mnErrorFlags;
+ std::set< OUString > embeddedFontUrlsKnown;
protected:
@@ -449,6 +450,12 @@ public:
*/
bool isGraphicLoadOnDemandSupported() const;
+ /**
+ Returns true if the embedded font document URL has already been processed.
+ Otherwise returns false and consequent calls with the same URL will return true.
+ */
+ bool embeddedFontAlreadyProcessed( const OUString& url );
+
virtual void NotifyEmbeddedFontRead() {};
};
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 9962db56fd89..2edbac4ad084 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -1902,4 +1902,12 @@ SvXMLImport::AddRDFa(uno::Reference<rdf::XMetadatable> i_xObject,
i_rAbout, i_rProperty, i_rContent, i_rDatatype);
}
+bool SvXMLImport::embeddedFontAlreadyProcessed( const OUString& url )
+{
+ if( embeddedFontUrlsKnown.count( url ) != 0 )
+ return true;
+ embeddedFontUrlsKnown.insert( url );
+ return false;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/style/XMLFontAutoStylePool.cxx b/xmloff/source/style/XMLFontAutoStylePool.cxx
index e8c33aafdd71..561814d32c18 100644
--- a/xmloff/source/style/XMLFontAutoStylePool.cxx
+++ b/xmloff/source/style/XMLFontAutoStylePool.cxx
@@ -275,13 +275,11 @@ void XMLFontAutoStylePool::exportXML()
if( tryToEmbedFonts )
{
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 ));
+ assert( SAL_N_ELEMENTS( weight ) == SAL_N_ELEMENTS( italic ));
for( unsigned int j = 0;
- j < SAL_N_ELEMENTS( styles );
+ j < SAL_N_ELEMENTS( weight );
++j )
{
OUString fileUrl = EmbeddedFontsHelper::fontFileUrl( pEntry->GetFamilyName(), pEntry->GetFamily(),
@@ -290,7 +288,7 @@ void XMLFontAutoStylePool::exportXML()
continue;
if( !fontFilesMap.count( fileUrl ))
{
- OUString docUrl = embedFontFile( fileUrl, styles[ j ] );
+ OUString docUrl = embedFontFile( fileUrl );
if( !docUrl.isEmpty())
fontFilesMap[ fileUrl ] = docUrl;
else
@@ -319,7 +317,7 @@ void XMLFontAutoStylePool::exportXML()
}
}
-OUString XMLFontAutoStylePool::embedFontFile( const OUString& fileUrl, const char* style )
+OUString XMLFontAutoStylePool::embedFontFile( const OUString& fileUrl )
{
try
{
@@ -333,7 +331,7 @@ OUString XMLFontAutoStylePool::embedFontFile( const OUString& fileUrl, const cha
OUString name;
do
{
- name = "font" + OUString::number( ++index ) + OUString::createFromAscii( style ) + ".ttf";
+ name = "font" + OUString::number( ++index ) + ".ttf";
} while( storage->hasByName( name ) );
uno::Reference< io::XOutputStream > outputStream;
outputStream.set( storage->openStreamElement( name, ::embed::ElementModes::WRITE ), UNO_QUERY_THROW );
diff --git a/xmloff/source/style/XMLFontStylesContext.cxx b/xmloff/source/style/XMLFontStylesContext.cxx
index f269284f3319..21b9cdb83d45 100644
--- a/xmloff/source/style/XMLFontStylesContext.cxx
+++ b/xmloff/source/style/XMLFontStylesContext.cxx
@@ -238,18 +238,12 @@ void XMLFontStyleContextFontFaceUri::SetAttribute( sal_uInt16 nPrefixKey, const
void XMLFontStyleContextFontFaceUri::handleEmbeddedFont( const OUString& url )
{
+ if( GetImport().embeddedFontAlreadyProcessed( url ))
+ {
+ GetImport().NotifyEmbeddedFontRead();
+ return;
+ }
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 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" ))
- style = "bi";
- else if( url.endsWithIgnoreAsciiCase( "b.ttf" ))
- style = "b";
- else if( url.endsWithIgnoreAsciiCase( "i.ttf" ))
- style = "i";
// If there's any giveMeStreamForThisURL(), then it's well-hidden for me to find it.
if( GetImport().IsPackageURL( url ))
{
@@ -258,15 +252,12 @@ 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 = EmbeddedFontsHelper::fileUrlForTemporaryFont( fontName, style );
+ OUString fileUrl = EmbeddedFontsHelper::fileUrlForTemporaryFont( fontName, "?" );
osl::File file( fileUrl );
switch( file.open( osl_File_OpenFlag_Create | osl_File_OpenFlag_Write ))
{
case osl::File::E_None:
break; // ok
- case osl::File::E_EXIST:
- GetImport().NotifyEmbeddedFontRead();
- return; // Assume it's already been added correctly.
default:
SAL_WARN( "xmloff", "Cannot open file for temporary font" );
return;