[Libreoffice-commits] .: 6 commits - offapi/com sw/inc sw/source vcl/generic vcl/inc writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Sep 6 08:36:27 PDT 2012


 offapi/com/sun/star/document/Settings.idl             |   15 ++
 sw/inc/IDocumentSettingAccess.hxx                     |    4 
 sw/inc/doc.hxx                                        |    2 
 sw/source/core/doc/doc.cxx                            |    8 +
 sw/source/core/doc/docnew.cxx                         |    2 
 sw/source/filter/ww8/docxattributeoutput.cxx          |   91 ++++++++++++
 sw/source/filter/ww8/docxattributeoutput.hxx          |    7 
 sw/source/filter/ww8/docxexport.cxx                   |    6 
 sw/source/filter/ww8/wrtw8sty.cxx                     |    3 
 sw/source/filter/ww8/wrtww8.hxx                       |    2 
 sw/source/ui/uno/SwXDocumentSettings.cxx              |   28 +++
 vcl/generic/fontmanager/fontmanager.cxx               |   43 ++++++
 vcl/inc/vcl/fontmanager.hxx                           |   23 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx     |    8 -
 writerfilter/source/dmapper/FontTable.cxx             |  127 ++++++++++++++++++
 writerfilter/source/dmapper/FontTable.hxx             |   18 ++
 writerfilter/source/dmapper/PropertyIds.cxx           |    2 
 writerfilter/source/dmapper/PropertyIds.hxx           |    2 
 writerfilter/source/dmapper/SettingsTable.cxx         |   20 ++
 writerfilter/source/dmapper/SettingsTable.hxx         |    3 
 writerfilter/source/ooxml/Handler.cxx                 |   28 +++
 writerfilter/source/ooxml/Handler.hxx                 |   12 +
 writerfilter/source/ooxml/OOXMLDocumentImpl.cxx       |    4 
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |    9 +
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |    3 
 writerfilter/source/ooxml/factoryimpl_ns.xsl          |    3 
 writerfilter/source/ooxml/model.xml                   |    1 
 27 files changed, 461 insertions(+), 13 deletions(-)

New commits:
commit 11f7d6aca36b25fb0b225cd0c641cd4f09338672
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Sep 5 15:02:17 2012 +0200

    basic .docx write support for embedded fonts
    
    Docx embedded fonts now should be usable for practical use,
    although there is still a number of small todos:
    - fonts are embedded when saving only if the document had embedded
      fonts when it was opened (this means the document needed to be
      saved in MSO first with the option enabled), there's no UI
      to enable it and it's a question if it makes sense on Linux
    - w:embedSystemFonts is similarly questionable, given that the spec
      is very vague on what system fonts are supposed to be
    - font subsetting is ignored, when reading a document, the font
      is simply used and it is hoped it will work (that should mean
      the document should not be modified, otherwise glyphs may be missing
      for the new text), write has no support for subsetting; also, since
      fonts are global for LO, opening several documents with the same
      but differently subset font probably will not work
    
    Change-Id: I470a9f2857738a10e82546223412bd9320841e65

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 652a7cc..6590b8a 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -118,9 +118,11 @@
 #include <txtinet.hxx>
 #include <numrule.hxx>
 
+#include <osl/file.hxx>
 #include <rtl/strbuf.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <rtl/ustring.hxx>
+#include <vcl/fontmanager.hxx>
 
 #include <tools/color.hxx>
 
@@ -130,6 +132,7 @@
 #include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
 #include <IMark.hxx>
 
 #if OSL_DEBUG_LEVEL > 1
@@ -2809,6 +2812,90 @@ void DocxAttributeOutput::FontPitchType( FontPitch ePitch ) const
                 FSEND );
 }
 
+void DocxAttributeOutput::EmbedFont( const OUString& name )
+{
+    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" );
+}
+
+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 )
+{
+    OUString fontUrl = psp::PrintFontManager::get().fileUrlForTemporaryFont( name, style );
+    // If a temporary font file exists for this font, assume it was embedded
+    // and embed it again.
+    // TODO IDocumentSettingAccess::EMBED_SYSTEM_FONTS
+    osl::File file( fontUrl );
+    if( file.open( osl_File_OpenFlag_Write ) != osl::File::E_None )
+        return;
+    uno::Reference< com::sun::star::io::XOutputStream > xOutStream = m_rExport.GetFilter().openFragmentStream(
+        OUString( "word/fonts/font" ) + OUString::valueOf( m_nextFontId ) + ".ttf",
+        "application/vnd.openxmlformats-officedocument.obfuscatedFont" );
+    // Not much point in trying hard with the obfuscation key, whoever reads the spec can read the font anyway,
+    // so just alter the first and last part of the key.
+    char fontKeyStr[] = "{00014A78-CABC-4EF0-12AC-5CD89AEFDE00}";
+    sal_uInt8 fontKey[ 16 ] = { 0, 0xDE, 0xEF, 0x9A, 0xD8, 0x5C, 0xAC, 0x12, 0xF0, 0x4E,
+        0xBC, 0xCA, 0x78, 0x4A, 0x01, 0 };
+    fontKey[ 0 ] = fontKey[ 15 ] = m_nextFontId % 256;
+    fontKeyStr[ 1 ] = fontKeyStr[ 35 ] = toHexChar(( m_nextFontId % 256 ) / 16 );
+    fontKeyStr[ 2 ] = fontKeyStr[ 36 ] = toHexChar(( m_nextFontId % 256 ) % 16 );
+    char buffer[ 4096 ];
+    sal_uInt64 readSize;
+    file.read( buffer, 32, readSize );
+    if( readSize < 32 )
+    {
+        SAL_WARN( "sw.ww8", "Font file size too small (" << fontUrl << ")" );
+        xOutStream->closeOutput();
+        return;
+    }
+    for( int i = 0;
+         i < 16;
+         ++i )
+    {
+        buffer[ i ] ^= fontKey[ i ];
+        buffer[ i + 16 ] ^= fontKey[ i ];
+    }
+    xOutStream->writeBytes( uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( buffer ), 32 ));
+    for(;;)
+    {
+        sal_Bool eof;
+        if( file.isEndOfFile( &eof ) != osl::File::E_None )
+        {
+            SAL_WARN( "sw.ww8", "Error reading font file " << fontUrl );
+            xOutStream->closeOutput();
+            return;
+        }
+        if( eof )
+            break;
+        if( file.read( buffer, 4096, readSize ) != osl::File::E_None )
+        {
+            SAL_WARN( "sw.ww8", "Error reading font file " << fontUrl );
+            xOutStream->closeOutput();
+            return;
+        }
+        if( readSize == 0 )
+            break;
+        xOutStream->writeBytes( uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( buffer ), readSize ));
+    }
+    xOutStream->closeOutput();
+    OString relId = OUStringToOString( GetExport().GetFilter().addRelation( m_pSerializer->getOutputStream(),
+        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font",
+        OUString( "fonts/font" ) + OUString::valueOf( m_nextFontId ) + ".ttf" ), RTL_TEXTENCODING_UTF8 );
+    m_pSerializer->singleElementNS( XML_w, tag,
+        FSNS( XML_r, XML_id ), relId.getStr(),
+        FSNS( XML_w, XML_fontKey ), fontKeyStr,
+        FSEND );
+    ++m_nextFontId;
+}
+
 void DocxAttributeOutput::NumberingDefinition( sal_uInt16 nId, const SwNumRule &rRule )
 {
     // nId is the same both for abstract numbering definition as well as the
@@ -4415,7 +4502,8 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
       m_postponedGraphic( NULL ),
       m_postponedMath( NULL ),
       m_postitFieldsMaxId( 0 ),
-      m_anchorId( 0 )
+      m_anchorId( 0 ),
+      m_nextFontId( 1 )
 {
 }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 3a9c7cb..8ab41d4 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -240,6 +240,9 @@ public:
     /// Font pitch.
     void FontPitchType( FontPitch ePitch ) const;
 
+    /// Write out the font into the document, if it's an embedded font.
+    void EmbedFont( const OUString& name );
+
     /// Definition of a numbering instance.
     virtual void NumberingDefinition( sal_uInt16 nId, const SwNumRule &rRule );
 
@@ -314,6 +317,9 @@ private:
     void FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t pInner, bool bForceEmptyParagraph = false );
 
     void WriteFFData( const FieldInfos& rInfos );
+
+    void EmbedFontStyle( const OUString& name, int tag, const char* style );
+
 protected:
 
     /// Output frames - the implementation.
@@ -605,6 +611,7 @@ private:
     std::vector< const SwPostItField* > m_postitFields;
     unsigned int m_postitFieldsMaxId;
     int m_anchorId;
+    int m_nextFontId;
 
 public:
     DocxAttributeOutput( DocxExport &rExport, ::sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML );
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index b19b47b..59e9bd1 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -624,6 +624,7 @@ void DocxExport::WriteFonts()
 
     pFS->startElementNS( XML_w, XML_fonts,
             FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
+            FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
             FSEND );
 
     // switch the serializer to redirect the output to word/styles.xml
@@ -675,7 +676,10 @@ void DocxExport::WriteSettings()
     // Zoom
     rtl::OString aZoom(rtl::OString::valueOf(sal_Int32(pViewShell->GetViewOptions()->GetZoom())));
     pFS->singleElementNS(XML_w, XML_zoom, FSNS(XML_w, XML_percent), aZoom.getStr(), FSEND);
-
+    if( pDoc->get( IDocumentSettingAccess::EMBED_FONTS ))
+        pFS->singleElementNS( XML_w, XML_embedTrueTypeFonts, FSEND );
+    if( pDoc->get( IDocumentSettingAccess::EMBED_SYSTEM_FONTS ))
+        pFS->singleElementNS( XML_w, XML_embedSystemFonts, FSEND );
     if( settings.defaultTabStop != 0 )
         pFS->singleElementNS( XML_w, XML_defaultTabStop, FSNS( XML_w, XML_val ),
             rtl::OString::valueOf( sal_Int32( settings.defaultTabStop )).getStr(), FSEND );
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 54cc347..00a0817 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -714,7 +714,7 @@ bool wwFont::Write(SvStream *pTableStrm) const
     return true;
 }
 
-void wwFont::WriteDocx( const DocxAttributeOutput* rAttrOutput ) const
+void wwFont::WriteDocx( DocxAttributeOutput* rAttrOutput ) const
 {
     // no font embedding, panose id, subsetting, ... implemented
 
@@ -725,6 +725,7 @@ void wwFont::WriteDocx( const DocxAttributeOutput* rAttrOutput ) const
     rAttrOutput->FontCharset( sw::ms::rtl_TextEncodingToWinCharset( meChrSet ), meChrSet );
     rAttrOutput->FontFamilyType( meFamily );
     rAttrOutput->FontPitchType( mePitch );
+    rAttrOutput->EmbedFont( msFamilyNm );
 
     rAttrOutput->EndFont();
 }
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 28cda40..a601b38 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -294,7 +294,7 @@ public:
     wwFont( const String &rFamilyName, FontPitch ePitch, FontFamily eFamily,
         rtl_TextEncoding eChrSet, bool bWrtWW8 );
     bool Write( SvStream *pTableStram ) const;
-    void WriteDocx( const DocxAttributeOutput* rAttrOutput ) const;
+    void WriteDocx( DocxAttributeOutput* rAttrOutput ) const;
     void WriteRtf( const RtfAttributeOutput* rAttrOutput ) const;
     rtl::OUString GetFamilyName() const { return rtl::OUString( msFamilyNm ); }
     friend bool operator < (const wwFont &r1, const wwFont &r2);
commit cf6d2e2f8319fb4a2b15b9a805699312fe7305f9
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Sep 4 19:51:21 2012 +0200

    make sure a font from SvxFontItem is written to fontTable.xml
    
    Change-Id: Ie1cd6aeded226da49e8ff10c262a00d7f95228f6

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index b5165e7..652a7cc 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3072,6 +3072,7 @@ void DocxAttributeOutput::CharFont( const SvxFontItem& rFont)
 {
     if (!m_pFontsAttrList)
         m_pFontsAttrList = m_pSerializer->createAttrList();
+    GetExport().GetId( rFont ); // ensure font info is written to fontTable.xml
     OUString sFontName(rFont.GetFamilyName());
     OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8);
     m_pFontsAttrList->add(FSNS(XML_w, XML_ascii), sFontNameUtf8);
commit 7a045f48bad2177538c43f76019c1caecdd5baf7
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Sep 6 17:34:08 2012 +0200

    read support for docx w:embedTrueTypeFonts/w:embedSystemFonts
    
    No write support yet.
    
    Change-Id: Ia10239acc77cf9ebc4f511e30c007da36abf43cb

diff --git a/offapi/com/sun/star/document/Settings.idl b/offapi/com/sun/star/document/Settings.idl
index be4d186..a2eee71 100644
--- a/offapi/com/sun/star/document/Settings.idl
+++ b/offapi/com/sun/star/document/Settings.idl
@@ -249,6 +249,21 @@ published service Settings
      */
     [optional, property] boolean AddExternalLeading;
 
+    // Writer, maybe later others
+    /**
+       Whether to embed fonts used by the document (see e.g. handling
+       of OOXML embedRegular etc.)
+       @since LibreOffice 3.7
+     */
+    [optional, property] boolean EmbedFonts;
+    // Writer, maybe later others
+    /**
+       Whether to embed also system fonts used by the document.
+       Does not have any effect if EmbedFonts is false.
+       @since LibreOffice 3.7
+     */
+    [optional, property] boolean EmbedSystemFonts;
+
 };
 
 
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index 44eef47..b7d2c13 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -96,7 +96,9 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd
          KERN_ASIAN_PUNCTUATION,
          MATH_BASELINE_ALIGNMENT,
          STYLES_NODEFAULT,
-         FLOATTABLE_NOMARGINS
+         FLOATTABLE_NOMARGINS,
+         EMBED_FONTS,
+         EMBED_SYSTEM_FONTS
      };
 
  public:
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 51c4f28..001ebf8 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -568,6 +568,8 @@ private:
     bool mbMathBaselineAlignment            : 1;    // TL  2010-10-29 #i972#
     bool mbStylesNoDefault                  : 1;
     bool mbFloattableNomargins              : 1; ///< If paragraph margins next to a floating table should be ignored.
+    bool mEmbedFonts                        : 1;  ///< Whether to embed fonts used by the document when saving.
+    bool mEmbedSystemFonts                  : 1;  ///< Whether to embed also system fonts.
 
     // non-ui-compatibility flags:
     bool mbOldNumbering                             : 1;
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 46bccde..f7b5bfd 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -212,6 +212,8 @@ bool SwDoc::get(/*[in]*/ DocumentSettingId id) const
         case MATH_BASELINE_ALIGNMENT: return mbMathBaselineAlignment;
         case STYLES_NODEFAULT: return mbStylesNoDefault;
         case FLOATTABLE_NOMARGINS: return mbFloattableNomargins;
+        case EMBED_FONTS: return mEmbedFonts;
+        case EMBED_SYSTEM_FONTS: return mEmbedSystemFonts;
         default:
             OSL_FAIL("Invalid setting id");
     }
@@ -391,6 +393,12 @@ void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value)
         case FLOATTABLE_NOMARGINS:
             mbFloattableNomargins = value;
             break;
+        case EMBED_FONTS:
+            mEmbedFonts = value;
+            break;
+        case EMBED_SYSTEM_FONTS:
+            mEmbedSystemFonts = value;
+            break;
         default:
             OSL_FAIL("Invalid setting id");
     }
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 5e9cdf6..b2d07db 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -359,6 +359,8 @@ SwDoc::SwDoc()
     mbUnbreakableNumberings                 = false;
     mbFloattableNomargins                   = false;
     mbClippedPictures                       = false;
+    mEmbedFonts                             = false;
+    mEmbedSystemFonts                       = false;
 
     //
     // COMPATIBILITY FLAGS END
diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx
index fda8a6c..728e54c 100644
--- a/sw/source/ui/uno/SwXDocumentSettings.cxx
+++ b/sw/source/ui/uno/SwXDocumentSettings.cxx
@@ -128,7 +128,9 @@ enum SwDocumentSettingsPropertyHandles
     HANDLE_UNBREAKABLE_NUMBERINGS,
     HANDLE_STYLES_NODEFAULT,
     HANDLE_FLOATTABLE_NOMARGINS,
-    HANDLE_CLIPPED_PICTURES
+    HANDLE_CLIPPED_PICTURES,
+    HANDLE_EMBED_FONTS,
+    HANDLE_EMBED_SYSTEM_FONTS
 };
 
 MasterPropertySetInfo * lcl_createSettingsInfo()
@@ -194,6 +196,8 @@ MasterPropertySetInfo * lcl_createSettingsInfo()
         { RTL_CONSTASCII_STRINGPARAM("StylesNoDefault"), HANDLE_STYLES_NODEFAULT, CPPUTYPE_BOOLEAN, 0, 0},
         { RTL_CONSTASCII_STRINGPARAM("FloattableNomargins"), HANDLE_FLOATTABLE_NOMARGINS, CPPUTYPE_BOOLEAN, 0, 0},
         { RTL_CONSTASCII_STRINGPARAM("ClippedPictures"), HANDLE_CLIPPED_PICTURES, CPPUTYPE_BOOLEAN, 0, 0},
+        { RTL_CONSTASCII_STRINGPARAM("EmbedFonts"), HANDLE_EMBED_FONTS, CPPUTYPE_BOOLEAN, 0, 0},
+        { RTL_CONSTASCII_STRINGPARAM("EmbedSystemFonts"), HANDLE_EMBED_SYSTEM_FONTS, CPPUTYPE_BOOLEAN, 0, 0},
 /*
  * As OS said, we don't have a view when we need to set this, so I have to
  * find another solution before adding them to this property set - MTG
@@ -771,6 +775,17 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
             mpDoc->set(IDocumentSettingAccess::CLIPPED_PICTURES, bTmp);
         }
         break;
+        case HANDLE_EMBED_FONTS:
+        {
+            sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+            mpDoc->set(IDocumentSettingAccess::EMBED_FONTS, bTmp);
+        }
+        case HANDLE_EMBED_SYSTEM_FONTS:
+        {
+            sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+            mpDoc->set(IDocumentSettingAccess::EMBED_SYSTEM_FONTS, bTmp);
+        }
+        break;
         default:
             throw UnknownPropertyException();
     }
@@ -1161,6 +1176,17 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
             rValue.setValue( &bTmp, ::getBooleanCppuType() );
         }
         break;
+        case HANDLE_EMBED_FONTS:
+        {
+            sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::EMBED_FONTS );
+            rValue.setValue( &bTmp, ::getBooleanCppuType() );
+        }
+        case HANDLE_EMBED_SYSTEM_FONTS:
+        {
+            sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::EMBED_SYSTEM_FONTS );
+            rValue.setValue( &bTmp, ::getBooleanCppuType() );
+        }
+        break;
         default:
             throw UnknownPropertyException();
     }
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index bc0871c..40acc30 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3665,11 +3665,13 @@ void DomainMapper_Impl::ApplySettingsTable()
                 xViewDataSupplier->setViewData(xIndexAccess);
             }
 
+            uno::Reference< beans::XPropertySet > xSettings(m_xTextFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY);
             if (m_pSettingsTable->GetUsePrinterMetrics())
-            {
-                uno::Reference< beans::XPropertySet > xSettings(m_xTextFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY);
                 xSettings->setPropertyValue("PrinterIndependentLayout", uno::makeAny(document::PrinterIndependentLayout::DISABLED));
-            }
+            if( m_pSettingsTable->GetEmbedTrueTypeFonts())
+                xSettings->setPropertyValue( PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_EMBED_FONTS ), uno::makeAny(true) );
+            if( m_pSettingsTable->GetEmbedSystemFonts())
+                xSettings->setPropertyValue( PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_EMBED_SYSTEM_FONTS ), uno::makeAny(true) );
         }
         catch(const uno::Exception&)
         {
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 66aecf6..1b4e8ab 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -316,6 +316,8 @@ const OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const
             case PROP_IS_VISIBLE: sName = "IsVisible"; break;
             case PROP_PAGE_STYLE_LAYOUT: sName = "PageStyleLayout"; break;
             case PROP_Z_ORDER: sName = "ZOrder"; break;
+            case PROP_EMBED_FONTS: sName = "EmbedFonts"; break;
+            case PROP_EMBED_SYSTEM_FONTS: sName = "EmbedSystemFonts"; break;
         }
         ::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
                 m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index 8a55b82..5f21ee1 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -289,6 +289,8 @@ enum PropertyIds
         ,PROP_PARA_CONTEXT_MARGIN
         ,PROP_PAGE_STYLE_LAYOUT
         ,PROP_Z_ORDER
+        ,PROP_EMBED_FONTS
+        ,PROP_EMBED_SYSTEM_FONTS
     };
 struct PropertyNameSupplier_Impl;
 class PropertyNameSupplier
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx
index c28b45b..74161ed 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -69,6 +69,8 @@ struct SettingsTable_Impl
     sal_Int16           m_nZoomFactor;
     bool                m_bEvenAndOddHeaders;
     bool                m_bUsePrinterMetrics;
+    bool                embedTrueTypeFonts;
+    bool                embedSystemFonts;
 
     SettingsTable_Impl( DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory ) :
     m_rDMapper( rDMapper )
@@ -89,6 +91,8 @@ struct SettingsTable_Impl
     , m_nZoomFactor(0)
     , m_bEvenAndOddHeaders(false)
     , m_bUsePrinterMetrics(false)
+    , embedTrueTypeFonts(false)
+    , embedSystemFonts(false)
     {}
 
 };
@@ -199,6 +203,12 @@ void SettingsTable::lcl_sprm(Sprm& rSprm)
     case NS_ooxml::LN_CT_Compat_usePrinterMetrics:
         m_pImpl->m_bUsePrinterMetrics = nIntValue;
         break;
+    case NS_ooxml::LN_CT_Settings_embedTrueTypeFonts:
+        m_pImpl->embedTrueTypeFonts = nIntValue != 0;
+        break;
+    case NS_ooxml::LN_CT_Settings_embedSystemFonts:
+        m_pImpl->embedSystemFonts = nIntValue != 0;
+        break;
     default:
     {
 #ifdef DEBUG_DMAPPER_SETTINGS_TABLE
@@ -241,6 +251,16 @@ bool SettingsTable::GetEvenAndOddHeaders() const
     return m_pImpl->m_bEvenAndOddHeaders;
 }
 
+bool SettingsTable::GetEmbedTrueTypeFonts() const
+{
+    return m_pImpl->embedTrueTypeFonts;
+}
+
+bool SettingsTable::GetEmbedSystemFonts() const
+{
+    return m_pImpl->embedSystemFonts;
+}
+
 void SettingsTable::ApplyProperties( uno::Reference< text::XTextDocument > xDoc )
 {
     uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
diff --git a/writerfilter/source/dmapper/SettingsTable.hxx b/writerfilter/source/dmapper/SettingsTable.hxx
index 6c30f37..d8a88c9 100644
--- a/writerfilter/source/dmapper/SettingsTable.hxx
+++ b/writerfilter/source/dmapper/SettingsTable.hxx
@@ -65,6 +65,9 @@ class WRITERFILTER_DLLPRIVATE SettingsTable : public LoggedProperties, public Lo
 
     bool GetUsePrinterMetrics() const;
 
+    bool GetEmbedTrueTypeFonts() const;
+    bool GetEmbedSystemFonts() const;
+
     void ApplyProperties( uno::Reference< text::XTextDocument > xDoc );
 
  private:
commit 9b14fa8f64d84866777e35acfe369503da188c7a
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Mon Sep 3 18:09:09 2012 +0200

    basic .docx read support for embedded fonts (w:embedRegular etc.)
    
    Change-Id: I9bbca2e348bd999e05f6d9e53f3bbcd2d6bb911a

diff --git a/writerfilter/source/dmapper/FontTable.cxx b/writerfilter/source/dmapper/FontTable.cxx
index 203283d..9bb108b 100644
--- a/writerfilter/source/dmapper/FontTable.cxx
+++ b/writerfilter/source/dmapper/FontTable.cxx
@@ -21,8 +21,10 @@
 #include <doctok/resourceids.hxx>
 #include <ooxml/resourceids.hxx>
 #include <vector>
+#include <osl/file.hxx>
 #include <stdio.h>
 #include <rtl/tencinfo.h>
+#include <vcl/fontmanager.hxx>
 
 #include "dmapperLoggers.hxx"
 
@@ -133,6 +135,23 @@ void FontTable::lcl_sprm(Sprm& rSprm)
         case NS_ooxml::LN_CT_Font_charset:
             resolveSprm( rSprm );
             break;
+        case NS_ooxml::LN_CT_Font_embedRegular:
+        case NS_ooxml::LN_CT_Font_embedBold:
+        case NS_ooxml::LN_CT_Font_embedItalic:
+        case NS_ooxml::LN_CT_Font_embedBoldItalic:
+        {
+            writerfilter::Reference< Properties >::Pointer_t pProperties = rSprm.getProps();
+            if( pProperties.get( ))
+            {
+                EmbeddedFontHandler handler( m_pImpl->pCurrentEntry->sFontName,
+                    nSprmId == NS_ooxml::LN_CT_Font_embedRegular ? ""
+                    : nSprmId == NS_ooxml::LN_CT_Font_embedBold ? "b"
+                    : nSprmId == NS_ooxml::LN_CT_Font_embedItalic ? "i"
+                    : nSprmId == NS_ooxml::LN_CT_Font_embedBoldItalic ? "bi" : "?" );
+                pProperties->resolve( handler );
+            }
+            break;
+        }
     }
 }
 
@@ -222,6 +241,114 @@ sal_uInt32 FontTable::size()
     return m_pImpl->aFontEntries.size();
 }
 
+EmbeddedFontHandler::EmbeddedFontHandler( const OUString& _fontName, const char* _style )
+: LoggedProperties(dmapper_logger, "EmbeddedFontHandler")
+, fontName( _fontName )
+, style( _style )
+{
+}
+
+EmbeddedFontHandler::~EmbeddedFontHandler()
+{
+    if( !inputStream.is())
+        return;
+    OUString fileUrl = psp::PrintFontManager::get().fileUrlForTemporaryFont( fontName, style );
+    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:
+            return; // Assume it's already been added correctly.
+        default:
+            SAL_WARN( "writerfilter", "Cannot open file for temporary font" );
+            inputStream->closeInput();
+            return;
+    }
+    if( !fontKey.isEmpty())
+    { // unobfuscate
+        uno::Sequence< sal_Int8 > buffer;
+        int read = inputStream->readBytes( buffer, 32 );
+        if( read < 32 )
+        {
+            SAL_WARN( "writerfilter", "Embedded font too small" );
+            inputStream->closeInput();
+            file.close();
+            osl::File::remove( fileUrl );
+            return;
+        }
+        //  1 3 5 7 10 2  5 7 20 2  5 7 9 1 3 5
+        // {62E79491-959F-41E9-B76B-6B32631DEA5C}
+        static const int pos[ 16 ] = { 35, 33, 31, 29, 27, 25, 22, 20, 17, 15, 12, 10, 7, 5, 3, 1 };
+        char key[ 16 ];
+        for( int i = 0;
+             i < 16;
+             ++i )
+        {
+            int v1 = fontKey[ pos[ i ]];
+            int v2 = fontKey[ pos[ i ] + 1 ];
+            assert(( v1 >= '0' && v1 <= '9' ) || ( v1 >= 'A' && v1 <= 'F' ));
+            assert(( v2 >= '0' && v2 <= '9' ) || ( v2 >= 'A' && v2 <= 'F' ));
+            int val = ( v1 - ( v1 <= '9' ? '0' : 'A' - 10 )) * 16 + v2 - ( v2 <= '9' ? '0' : 'A' - 10 );
+            key[ i ] = val;
+        }
+        for( int i = 0;
+             i < 16;
+             ++i )
+        {
+            buffer[ i ] ^= key[ i ];
+            buffer[ i + 16 ] ^= key[ i ];
+        }
+        sal_uInt64 dummy;
+        file.write( buffer.getConstArray(), 32, dummy );
+    }
+    for(;;)
+    {
+        uno::Sequence< sal_Int8 > buffer;
+        int read = inputStream->readBytes( buffer, 1024 );
+        sal_uInt64 dummy;
+        if( read > 0 )
+            file.write( buffer.getConstArray(), read, dummy );
+        if( read < 1024 )
+            break;
+    }
+    inputStream->closeInput();
+    if( file.close() != osl::File::E_None )
+    {
+        SAL_WARN( "writerfilter", "Writing temporary font file failed" );
+        osl::File::remove( fileUrl );
+        return;
+    }
+    psp::PrintFontManager::get().activateTemporaryFont( fontName, fileUrl );
+}
+
+void EmbeddedFontHandler::lcl_attribute( Id name, Value& val )
+{
+    OUString sValue = val.getString();
+    switch( name )
+    {
+        case NS_ooxml::LN_CT_FontRel_fontKey:
+            fontKey = sValue;
+            break;
+        case NS_ooxml::LN_CT_Rel_id:
+            id = sValue;
+            break;
+        case NS_ooxml::LN_CT_FontRel_subsetted:
+            break; // TODO? Let's just ignore this for now and hope
+                   // it doesn't break anything.
+        case NS_ooxml::LN_inputstream: // the actual font data as stream
+            val.getAny() >>= inputStream;
+            break;
+        default:
+            break;
+    }
+}
+
+void EmbeddedFontHandler::lcl_sprm( Sprm& )
+{
+}
+
+
 }//namespace dmapper
 }//namespace writerfilter
 
diff --git a/writerfilter/source/dmapper/FontTable.hxx b/writerfilter/source/dmapper/FontTable.hxx
index 9308da8..36dec44 100644
--- a/writerfilter/source/dmapper/FontTable.hxx
+++ b/writerfilter/source/dmapper/FontTable.hxx
@@ -24,6 +24,7 @@
 #include <WriterFilterDllApi.hxx>
 #include <resourcemodel/LoggedResources.hxx>
 #include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
 
 namespace writerfilter {
 namespace dmapper
@@ -96,6 +97,23 @@ class WRITERFILTER_DLLPRIVATE FontTable : public LoggedProperties, public Logged
 
 };
 typedef boost::shared_ptr< FontTable >          FontTablePtr;
+
+class EmbeddedFontHandler : public LoggedProperties
+{
+public:
+    EmbeddedFontHandler( const OUString& fontName, const char* style );
+    virtual ~EmbeddedFontHandler();
+private:
+    virtual void lcl_attribute( Id name, Value& val );
+    virtual void lcl_sprm( Sprm& rSprm );
+    OUString fontName;
+    const char* const style;
+    OUString id;
+    OUString fontKey;
+    ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > inputStream;
+};
+
+
 }}
 
 #endif //
diff --git a/writerfilter/source/ooxml/Handler.cxx b/writerfilter/source/ooxml/Handler.cxx
index 6dca8cd..1c79525 100644
--- a/writerfilter/source/ooxml/Handler.cxx
+++ b/writerfilter/source/ooxml/Handler.cxx
@@ -126,7 +126,7 @@ void OOXMLOLEHandler::attribute(Id name, Value & val)
     switch (name)
     {
     case NS_ooxml::LN_CT_OLEObject_r_id:
-        mpFastContext->resolveOLE(val.getString());
+        mpFastContext->resolveData(val.getString());
         break;
     default:
         ;
@@ -137,6 +137,31 @@ void OOXMLOLEHandler::sprm(Sprm & /*sprm*/)
 {
 }
 
+OOXMLEmbeddedFontHandler::OOXMLEmbeddedFontHandler(OOXMLFastContextHandler * pContext)
+: mpFastContext(pContext)
+{
+}
+
+OOXMLEmbeddedFontHandler::~OOXMLEmbeddedFontHandler()
+{
+}
+
+void OOXMLEmbeddedFontHandler::attribute(Id name, Value & val)
+{
+    switch (name)
+    {
+    case NS_ooxml::LN_CT_Rel_id:
+        mpFastContext->resolveData(val.getString());
+        break;
+    default:
+        break;
+    }
+}
+
+void OOXMLEmbeddedFontHandler::sprm(Sprm & /*sprm*/)
+{
+}
+
 /*
   class OOXMLFooterHandler
  */
@@ -336,6 +361,7 @@ void OOXMLHyperlinkHandler::attribute(Id name, Value & val)
 void OOXMLHyperlinkHandler::sprm(Sprm & /*rSprm*/)
 {
 }
+
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/ooxml/Handler.hxx b/writerfilter/source/ooxml/Handler.hxx
index 23e3e9c..7fc7e01 100644
--- a/writerfilter/source/ooxml/Handler.hxx
+++ b/writerfilter/source/ooxml/Handler.hxx
@@ -95,6 +95,18 @@ public:
     virtual void sprm(Sprm & sprm);
 };
 
+class OOXMLEmbeddedFontHandler : public Properties
+{
+    OOXMLFastContextHandler * mpFastContext;
+
+public:
+    OOXMLEmbeddedFontHandler(OOXMLFastContextHandler * pContext);
+    virtual ~OOXMLEmbeddedFontHandler();
+
+    virtual void attribute(Id name, Value & val);
+    virtual void sprm(Sprm & sprm);
+};
+
 class OOXMLBreakHandler : public Properties
 {
     sal_Int32 mnType, mnClear;
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 531b394..a8112d6 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1133,7 +1133,8 @@ void OOXMLFastContextHandler::resolveFooter
     mpParserState->getDocument()->resolveFooter(*mpStream, type, rId);
 }
 
-void OOXMLFastContextHandler::resolveOLE(const OUString & rId)
+// Add the data pointed to by the reference as another property.
+void OOXMLFastContextHandler::resolveData(const OUString & rId)
 {
     uno::Reference<io::XInputStream> xInputStream
         (mpParserState->getDocument()->getInputStreamForId(rId));
@@ -1449,6 +1450,12 @@ void OOXMLFastContextHandlerProperties::handleOLE()
     getPropertySet()->resolve(aOLEHandler);
 }
 
+void OOXMLFastContextHandlerProperties::handleFontRel()
+{
+    OOXMLEmbeddedFontHandler handler(this);
+    getPropertySet()->resolve(handler);
+}
+
 void OOXMLFastContextHandlerProperties::setParent
 (OOXMLFastContextHandler * pParent)
 {
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index 6aae475..688a476 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -149,7 +149,7 @@ public:
                                 const OUString & rId);
     void resolveFooter(const sal_Int32 type,
                                 const OUString & rId);
-    void resolveOLE(const OUString & rId);
+    void resolveData(const OUString & rId);
 
     OUString getTargetForId(const OUString & rId);
 
@@ -332,6 +332,7 @@ public:
     void handlePicture();
     void handleBreak();
     void handleOLE();
+    void handleFontRel();
 
     virtual void setPropertySet(OOXMLPropertySet::Pointer_t pPropertySet);
     virtual OOXMLPropertySet::Pointer_t getPropertySet() const;
diff --git a/writerfilter/source/ooxml/factoryimpl_ns.xsl b/writerfilter/source/ooxml/factoryimpl_ns.xsl
index bc8e8c2..bd913d6 100644
--- a/writerfilter/source/ooxml/factoryimpl_ns.xsl
+++ b/writerfilter/source/ooxml/factoryimpl_ns.xsl
@@ -449,7 +449,8 @@ CreateElementMapPointer </xsl:text>
             @action='handleComment' or 
             @action='handlePicture' or 
             @action='handleBreak' or 
-            @action='handleOLE'">
+            @action='handleOLE' or
+            @action='handleFontRel'">
             <xsl:text>
     dynamic_cast<OOXMLFastContextHandlerProperties*>(pHandler)-></xsl:text>
             <xsl:value-of select="@action"/>
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index c98a691..e683be1 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -23511,6 +23511,7 @@
     <resource name="CT_FontRel" resource="Properties" tag="font">
       <attribute name="fontKey" tokenid="ooxml:CT_FontRel_fontKey"/>
       <attribute name="subsetted" tokenid="ooxml:CT_FontRel_subsetted"/>
+      <action name="start" action="handleFontRel"/>
     </resource>
     <resource name="CT_Font" resource="Properties" tag="font">
       <kind name="character"/>
commit b7e56788135c1c6179cbc5387e41a66a85a7460b
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Mon Sep 3 18:07:34 2012 +0200

    basic support for temporary fonts
    
    To be used when loading fonts embedded in documents.
    
    Change-Id: I634af1b35eba48872d045e726d1d879f455d6f2c

diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx
index 2a3d29a..7b9294a 100644
--- a/vcl/generic/fontmanager/fontmanager.cxx
+++ b/vcl/generic/fontmanager/fontmanager.cxx
@@ -43,6 +43,8 @@
 #include "vcl/fontmanager.hxx"
 #include "vcl/strhelper.hxx"
 #include "vcl/ppdparser.hxx"
+#include <vcl/svapp.hxx>
+#include <vcl/outdev.hxx>
 
 #include "tools/urlobj.hxx"
 #include "tools/stream.hxx"
@@ -51,6 +53,7 @@
 #include "osl/file.hxx"
 #include "osl/process.h"
 
+#include <rtl/bootstrap.hxx>
 #include "rtl/tencinfo.h"
 #include "rtl/ustrbuf.hxx"
 #include "rtl/strbuf.hxx"
@@ -1034,6 +1037,7 @@ PrintFontManager::~PrintFontManager()
     delete m_pAtoms;
     if( m_pFontCache )
         delete m_pFontCache;
+    cleanTemporaryFonts();
 }
 
 // -------------------------------------------------------------------------
@@ -1660,6 +1664,8 @@ void PrintFontManager::initialize()
     CALLGRIND_ZERO_STATS();
     #endif
 
+    cleanTemporaryFonts();
+
     long aDirEntBuffer[ (sizeof(struct dirent)+_PC_NAME_MAX)+1 ];
 
     if( ! m_pFontCache )
@@ -3057,4 +3063,41 @@ 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 6666f0f..81b4200 100644
--- a/vcl/inc/vcl/fontmanager.hxx
+++ b/vcl/inc/vcl/fontmanager.hxx
@@ -330,6 +330,8 @@ class VCL_PLUGIN_PUBLIC 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>
@@ -593,6 +595,27 @@ 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
commit c1c8adca05b561afbbf3346b73225d80f2b82ee4
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Mon Sep 3 18:03:46 2012 +0200

    temporarily set a substream as the document stream
    
    If this is not done, then mpStream still refers to the main stream,
    and so e.g. resolving references uses the main document instead
    of the substream (specifically, in a followup commit, w:embedRegular
    will use _rels/document.xml.rels instead of _rels/fontTable.xml.rels).
    
    Change-Id: Ibf250b82f38be0b24a6c2b6198b6c96ab7f0423c

diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
index fa77978..29c64ad 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
@@ -56,6 +56,8 @@ void OOXMLDocumentImpl::resolveFastSubStream(Stream & rStreamHandler,
 {
     OOXMLStream::Pointer_t pStream
         (OOXMLDocumentFactory::createStream(mpStream, nType));
+    OOXMLStream::Pointer_t savedStream = mpStream;
+    mpStream = pStream;
 
     uno::Reference< xml::sax::XFastParser > xParser
         (mpStream->getFastParser());
@@ -89,6 +91,8 @@ void OOXMLDocumentImpl::resolveFastSubStream(Stream & rStreamHandler,
             xInputStream->closeInput();
         }
     }
+
+    mpStream = savedStream;
 }
 
 void OOXMLDocumentImpl::resolveFastSubStreamWithId(Stream & rStream,


More information about the Libreoffice-commits mailing list