LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/filter/xml - xmlfonte.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 25 27 92.6 %
Date: 2013-07-09 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             : 
      21             : #include "hintids.hxx"
      22             : #include <com/sun/star/text/XTextDocument.hpp>
      23             : #include <xmloff/XMLFontAutoStylePool.hxx>
      24             : #include <editeng/fontitem.hxx>
      25             : #include <unotext.hxx>
      26             : #include <doc.hxx>
      27             : #include <xmlexp.hxx>
      28             : #include <xmlimp.hxx>
      29             : 
      30             : 
      31             : using namespace ::com::sun::star::uno;
      32             : using namespace ::com::sun::star::lang;
      33             : using namespace ::com::sun::star::text;
      34             : 
      35          64 : class SwXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool
      36             : {
      37             :     public:
      38             : 
      39             :     SwXMLFontAutoStylePool_Impl( SwXMLExport& rExport, bool blockFontEmbedding );
      40             : 
      41             : };
      42             : 
      43          32 : SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(
      44             :     SwXMLExport& _rExport, bool blockFontEmbedding ) :
      45          32 :     XMLFontAutoStylePool( _rExport, blockFontEmbedding )
      46             : {
      47             :     sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
      48          32 :                                 RES_CHRATR_CTL_FONT };
      49             : 
      50          32 :     const SfxItemPool& rPool = _rExport.getDoc()->GetAttrPool();
      51             :     const SfxPoolItem* pItem;
      52         128 :     for( sal_uInt16 i=0; i<3; i++ )
      53             :     {
      54          96 :         sal_uInt16 nWhichId = aWhichIds[i];
      55             : 
      56             :         const SvxFontItem& rFont =
      57          96 :             (const SvxFontItem&)rPool.GetDefaultItem( nWhichId );
      58         192 :         Add( rFont.GetFamilyName(), rFont.GetStyleName(),
      59             :              rFont.GetFamily(), rFont.GetPitch(),
      60         288 :              rFont.GetCharSet() );
      61          96 :         sal_uInt32 nItems = rPool.GetItemCount2( nWhichId );
      62         422 :         for( sal_uInt32 j = 0; j < nItems; ++j )
      63             :         {
      64         326 :             if( 0 != (pItem = rPool.GetItem2( nWhichId, j ) ) )
      65             :             {
      66             :                 const SvxFontItem *pFont =
      67         270 :                             (const SvxFontItem *)pItem;
      68         540 :                 Add( pFont->GetFamilyName(), pFont->GetStyleName(),
      69             :                      pFont->GetFamily(), pFont->GetPitch(),
      70         810 :                      pFont->GetCharSet() );
      71             :             }
      72             :         }
      73             :     }
      74          32 : }
      75             : 
      76             : 
      77          32 : XMLFontAutoStylePool* SwXMLExport::CreateFontAutoStylePool()
      78             : {
      79          32 :     bool blockFontEmbedding = false;
      80             :     // We write font info to both content.xml and styles.xml, but they are both
      81             :     // written by different SwXMLExport instance, and would therefore write each
      82             :     // font file twice without complicated checking for duplicates, so handle
      83             :     // the embedding only in one of them.
      84          32 :     if(( getExportFlags() & EXPORT_CONTENT ) == 0 )
      85          16 :         blockFontEmbedding = true;
      86          32 :     if( !getDoc()->get( IDocumentSettingAccess::EMBED_FONTS ))
      87          32 :         blockFontEmbedding = true;
      88          32 :     return new SwXMLFontAutoStylePool_Impl( *this, !blockFontEmbedding );
      89             : }
      90             : 
      91           0 : void SwXMLImport::NotifyEmbeddedFontRead()
      92             : {
      93           0 :     getDoc()->set( IDocumentSettingAccess::EMBED_FONTS, true );
      94          99 : }
      95             : 
      96             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10