LCOV - code coverage report
Current view: top level - sw/source/filter/xml - xmlfonte.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 24 27 88.9 %
Date: 2014-04-11 Functions: 4 5 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "hintids.hxx"
      21             : #include <com/sun/star/text/XTextDocument.hpp>
      22             : #include <xmloff/XMLFontAutoStylePool.hxx>
      23             : #include <editeng/fontitem.hxx>
      24             : #include <unotext.hxx>
      25             : #include <doc.hxx>
      26             : #include <xmlexp.hxx>
      27             : #include <xmlimp.hxx>
      28             : 
      29             : using namespace ::com::sun::star::uno;
      30             : using namespace ::com::sun::star::lang;
      31             : using namespace ::com::sun::star::text;
      32             : 
      33          84 : class SwXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool
      34             : {
      35             :     public:
      36             :     SwXMLFontAutoStylePool_Impl( SwXMLExport& rExport, bool blockFontEmbedding );
      37             : };
      38             : 
      39          42 : SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(
      40             :     SwXMLExport& _rExport, bool blockFontEmbedding ) :
      41          42 :     XMLFontAutoStylePool( _rExport, blockFontEmbedding )
      42             : {
      43             :     sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
      44          42 :                                 RES_CHRATR_CTL_FONT };
      45             : 
      46          42 :     const SfxItemPool& rPool = _rExport.getDoc()->GetAttrPool();
      47             :     const SfxPoolItem* pItem;
      48         168 :     for( sal_uInt16 i=0; i<3; i++ )
      49             :     {
      50         126 :         sal_uInt16 nWhichId = aWhichIds[i];
      51             : 
      52             :         const SvxFontItem& rFont =
      53         126 :             (const SvxFontItem&)rPool.GetDefaultItem( nWhichId );
      54         126 :         Add( rFont.GetFamilyName(), rFont.GetStyleName(),
      55             :              rFont.GetFamily(), rFont.GetPitch(),
      56         252 :              rFont.GetCharSet() );
      57         126 :         sal_uInt32 nItems = rPool.GetItemCount2( nWhichId );
      58         562 :         for( sal_uInt32 j = 0; j < nItems; ++j )
      59             :         {
      60         436 :             if( 0 != (pItem = rPool.GetItem2( nWhichId, j ) ) )
      61             :             {
      62             :                 const SvxFontItem *pFont =
      63         348 :                             (const SvxFontItem *)pItem;
      64         348 :                 Add( pFont->GetFamilyName(), pFont->GetStyleName(),
      65             :                      pFont->GetFamily(), pFont->GetPitch(),
      66         696 :                      pFont->GetCharSet() );
      67             :             }
      68             :         }
      69             :     }
      70          42 : }
      71             : 
      72          42 : XMLFontAutoStylePool* SwXMLExport::CreateFontAutoStylePool()
      73             : {
      74          42 :     bool blockFontEmbedding = false;
      75             :     // We write font info to both content.xml and styles.xml, but they are both
      76             :     // written by different SwXMLExport instance, and would therefore write each
      77             :     // font file twice without complicated checking for duplicates, so handle
      78             :     // the embedding only in one of them.
      79          42 :     if(( getExportFlags() & EXPORT_CONTENT ) == 0 )
      80          21 :         blockFontEmbedding = true;
      81          42 :     if( !getDoc()->get( IDocumentSettingAccess::EMBED_FONTS ))
      82          42 :         blockFontEmbedding = true;
      83          42 :     return new SwXMLFontAutoStylePool_Impl( *this, !blockFontEmbedding );
      84             : }
      85             : 
      86           0 : void SwXMLImport::NotifyEmbeddedFontRead()
      87             : {
      88           0 :     getDoc()->set( IDocumentSettingAccess::EMBED_FONTS, true );
      89           0 : }
      90             : 
      91             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10