LCOV - code coverage report
Current view: top level - sw/source/filter/xml - xmlfonte.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 25 27 92.6 %
Date: 2015-06-13 12:38:46 Functions: 6 7 85.7 %
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             : #include <IDocumentSettingAccess.hxx>
      29             : 
      30             : using namespace ::com::sun::star::uno;
      31             : using namespace ::com::sun::star::lang;
      32             : using namespace ::com::sun::star::text;
      33             : 
      34         288 : class SwXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool
      35             : {
      36             :     public:
      37             :     SwXMLFontAutoStylePool_Impl( SwXMLExport& rExport, bool blockFontEmbedding );
      38             : };
      39             : 
      40         144 : SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(
      41             :     SwXMLExport& _rExport, bool blockFontEmbedding ) :
      42         144 :     XMLFontAutoStylePool( _rExport, blockFontEmbedding )
      43             : {
      44             :     sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
      45         144 :                                 RES_CHRATR_CTL_FONT };
      46             : 
      47         144 :     const SfxItemPool& rPool = _rExport.getDoc()->GetAttrPool();
      48             :     const SfxPoolItem* pItem;
      49         576 :     for( size_t i=0; i < SAL_N_ELEMENTS(aWhichIds); ++i )
      50             :     {
      51         432 :         const sal_uInt16 nWhichId = aWhichIds[i];
      52             : 
      53             :         const SvxFontItem& rFont =
      54         432 :             static_cast<const SvxFontItem&>(rPool.GetDefaultItem( nWhichId ));
      55         432 :         Add( rFont.GetFamilyName(), rFont.GetStyleName(),
      56             :              rFont.GetFamily(), rFont.GetPitch(),
      57         864 :              rFont.GetCharSet() );
      58         432 :         sal_uInt32 nItems = rPool.GetItemCount2( nWhichId );
      59        1831 :         for( sal_uInt32 j = 0; j < nItems; ++j )
      60             :         {
      61        1399 :             if( 0 != (pItem = rPool.GetItem2( nWhichId, j ) ) )
      62             :             {
      63             :                 const SvxFontItem *pFont =
      64        1120 :                             static_cast<const SvxFontItem *>(pItem);
      65        1120 :                 Add( pFont->GetFamilyName(), pFont->GetStyleName(),
      66             :                      pFont->GetFamily(), pFont->GetPitch(),
      67        2240 :                      pFont->GetCharSet() );
      68             :             }
      69             :         }
      70             :     }
      71         144 : }
      72             : 
      73         144 : XMLFontAutoStylePool* SwXMLExport::CreateFontAutoStylePool()
      74             : {
      75         144 :     bool blockFontEmbedding = false;
      76             :     // We write font info to both content.xml and styles.xml, but they are both
      77             :     // written by different SwXMLExport instance, and would therefore write each
      78             :     // font file twice without complicated checking for duplicates, so handle
      79             :     // the embedding only in one of them.
      80         144 :     if( !( getExportFlags() & SvXMLExportFlags::CONTENT) )
      81          71 :         blockFontEmbedding = true;
      82         144 :     if( !getDoc()->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_FONTS ))
      83         144 :         blockFontEmbedding = true;
      84         144 :     return new SwXMLFontAutoStylePool_Impl( *this, !blockFontEmbedding );
      85             : }
      86             : 
      87           0 : void SwXMLImport::NotifyEmbeddedFontRead()
      88             : {
      89           0 :     getDoc()->getIDocumentSettingAccess().set( DocumentSettingId::EMBED_FONTS, true );
      90         177 : }
      91             : 
      92             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
      93             : 

Generated by: LCOV version 1.11