LCOV - code coverage report
Current view: top level - libreoffice/sw/source/filter/xml - xmlfonte.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 27 27 100.0 %
Date: 2012-12-27 Functions: 4 4 100.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             : 
      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             : 
      29             : 
      30             : using namespace ::com::sun::star::uno;
      31             : using namespace ::com::sun::star::lang;
      32             : using namespace ::com::sun::star::text;
      33             : 
      34           8 : class SwXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool
      35             : {
      36             :     public:
      37             : 
      38             :     SwXMLFontAutoStylePool_Impl( SwXMLExport& rExport );
      39             : 
      40             : };
      41             : 
      42           4 : SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(
      43             :     SwXMLExport& _rExport ) :
      44           4 :     XMLFontAutoStylePool( _rExport )
      45             : {
      46             :     sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
      47           4 :                                 RES_CHRATR_CTL_FONT };
      48             : 
      49           4 :     Reference < XTextDocument > xTextDoc( _rExport.GetModel(), UNO_QUERY );
      50           4 :     Reference < XText > xText = xTextDoc->getText();
      51           4 :     Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
      52             :     OSL_ENSURE( xTextTunnel.is(), "missing XUnoTunnel for Cursor" );
      53           4 :     if( !xTextTunnel.is() )
      54             :         return;
      55             : 
      56             :     SwXText *pText = reinterpret_cast< SwXText *>(
      57           4 :             sal::static_int_cast< sal_IntPtr >( xTextTunnel->getSomething( SwXText::getUnoTunnelId() )));
      58             :     OSL_ENSURE( pText, "SwXText missing" );
      59           4 :     if( !pText )
      60             :         return;
      61             : 
      62           4 :     const SfxItemPool& rPool = pText->GetDoc()->GetAttrPool();
      63             :     const SfxPoolItem* pItem;
      64          16 :     for( sal_uInt16 i=0; i<3; i++ )
      65             :     {
      66          12 :         sal_uInt16 nWhichId = aWhichIds[i];
      67             : 
      68             :         const SvxFontItem& rFont =
      69          12 :             (const SvxFontItem&)rPool.GetDefaultItem( nWhichId );
      70          24 :         Add( rFont.GetFamilyName(), rFont.GetStyleName(),
      71          24 :              static_cast< sal_uInt16 >(rFont.GetFamily()), static_cast< sal_uInt16 >(rFont.GetPitch()),
      72          60 :              rFont.GetCharSet() );
      73          12 :         sal_uInt32 nItems = rPool.GetItemCount2( nWhichId );
      74          54 :         for( sal_uInt32 j = 0; j < nItems; ++j )
      75             :         {
      76          42 :             if( 0 != (pItem = rPool.GetItem2( nWhichId, j ) ) )
      77             :             {
      78             :                 const SvxFontItem *pFont =
      79          34 :                             (const SvxFontItem *)pItem;
      80          68 :                 Add( pFont->GetFamilyName(), pFont->GetStyleName(),
      81          68 :                      static_cast< sal_uInt16 >(pFont->GetFamily()), static_cast< sal_uInt16 >(pFont->GetPitch()),
      82         170 :                      pFont->GetCharSet() );
      83             :             }
      84             :         }
      85           4 :     }
      86             : }
      87             : 
      88             : 
      89           4 : XMLFontAutoStylePool* SwXMLExport::CreateFontAutoStylePool()
      90             : {
      91           4 :     return new SwXMLFontAutoStylePool_Impl( *this );
      92             : }
      93             : 
      94             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10