LCOV - code coverage report
Current view: top level - sw/source/filter/xml - xmlfonte.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 27 27 100.0 %
Date: 2012-08-25 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 30 54 55.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "hintids.hxx"
      31                 :            : #include <com/sun/star/text/XTextDocument.hpp>
      32                 :            : #include <xmloff/XMLFontAutoStylePool.hxx>
      33                 :            : #include <editeng/fontitem.hxx>
      34                 :            : #include <unotext.hxx>
      35                 :            : #include <doc.hxx>
      36                 :            : #include <xmlexp.hxx>
      37                 :            : 
      38                 :            : 
      39                 :            : using namespace ::com::sun::star::uno;
      40                 :            : using namespace ::com::sun::star::lang;
      41                 :            : using namespace ::com::sun::star::text;
      42                 :            : 
      43         [ -  + ]:         84 : class SwXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool
      44                 :            : {
      45                 :            :     public:
      46                 :            : 
      47                 :            :     SwXMLFontAutoStylePool_Impl( SwXMLExport& rExport );
      48                 :            : 
      49                 :            : };
      50                 :            : 
      51                 :         42 : SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(
      52                 :            :     SwXMLExport& _rExport ) :
      53                 :         42 :     XMLFontAutoStylePool( _rExport )
      54                 :            : {
      55                 :            :     sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
      56                 :         42 :                                 RES_CHRATR_CTL_FONT };
      57                 :            : 
      58         [ +  - ]:         42 :     Reference < XTextDocument > xTextDoc( _rExport.GetModel(), UNO_QUERY );
      59 [ +  - ][ +  - ]:         42 :     Reference < XText > xText = xTextDoc->getText();
      60         [ +  - ]:         42 :     Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
      61                 :            :     OSL_ENSURE( xTextTunnel.is(), "missing XUnoTunnel for Cursor" );
      62         [ -  + ]:         42 :     if( !xTextTunnel.is() )
      63                 :            :         return;
      64                 :            : 
      65                 :            :     SwXText *pText = reinterpret_cast< SwXText *>(
      66 [ +  - ][ +  - ]:         42 :             sal::static_int_cast< sal_IntPtr >( xTextTunnel->getSomething( SwXText::getUnoTunnelId() )));
                 [ +  - ]
      67                 :            :     OSL_ENSURE( pText, "SwXText missing" );
      68         [ -  + ]:         42 :     if( !pText )
      69                 :            :         return;
      70                 :            : 
      71         [ +  - ]:         42 :     const SfxItemPool& rPool = pText->GetDoc()->GetAttrPool();
      72                 :            :     const SfxPoolItem* pItem;
      73         [ +  + ]:        168 :     for( sal_uInt16 i=0; i<3; i++ )
      74                 :            :     {
      75                 :        126 :         sal_uInt16 nWhichId = aWhichIds[i];
      76                 :            : 
      77                 :            :         const SvxFontItem& rFont =
      78         [ +  - ]:        126 :             (const SvxFontItem&)rPool.GetDefaultItem( nWhichId );
      79                 :        252 :         Add( rFont.GetFamilyName(), rFont.GetStyleName(),
      80                 :        126 :              static_cast< sal_uInt16 >(rFont.GetFamily()), static_cast< sal_uInt16 >(rFont.GetPitch()),
      81   [ +  -  +  - ]:        378 :              rFont.GetCharSet() );
                 [ +  - ]
      82         [ +  - ]:        126 :         sal_uInt32 nItems = rPool.GetItemCount2( nWhichId );
      83         [ +  + ]:        486 :         for( sal_uInt32 j = 0; j < nItems; ++j )
      84                 :            :         {
      85 [ +  - ][ +  + ]:        360 :             if( 0 != (pItem = rPool.GetItem2( nWhichId, j ) ) )
      86                 :            :             {
      87                 :            :                 const SvxFontItem *pFont =
      88                 :        284 :                             (const SvxFontItem *)pItem;
      89                 :        568 :                 Add( pFont->GetFamilyName(), pFont->GetStyleName(),
      90                 :        284 :                      static_cast< sal_uInt16 >(pFont->GetFamily()), static_cast< sal_uInt16 >(pFont->GetPitch()),
      91   [ +  -  +  - ]:        852 :                      pFont->GetCharSet() );
                 [ +  - ]
      92                 :            :             }
      93                 :            :         }
      94 [ -  + ][ -  + ]:         42 :     }
                 [ +  - ]
      95                 :            : }
      96                 :            : 
      97                 :            : 
      98                 :         42 : XMLFontAutoStylePool* SwXMLExport::CreateFontAutoStylePool()
      99                 :            : {
     100         [ +  - ]:         42 :     return new SwXMLFontAutoStylePool_Impl( *this );
     101                 :            : }
     102                 :            : 
     103                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10