LCOV - code coverage report
Current view: top level - libreoffice/svx/source/dialog - fontlb.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 67 0.0 %
Date: 2012-12-27 Functions: 0 15 0.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 "svx/fontlb.hxx"
      21             : #include <vcl/builder.hxx>
      22             : #include <vcl/svapp.hxx>
      23             : #include "svtools/treelistentry.hxx"
      24             : #include "svtools/viewdataentry.hxx"
      25             : 
      26             : // ============================================================================
      27             : 
      28             : DBG_NAME( SvLBoxFontString );
      29             : 
      30           0 : SvLBoxFontString::SvLBoxFontString() :
      31           0 :     SvLBoxString()
      32             : {
      33             :     DBG_CTOR( SvLBoxFontString, 0 );
      34           0 : }
      35             : 
      36           0 : SvLBoxFontString::SvLBoxFontString(
      37             :         SvTreeListEntry* pEntry, sal_uInt16 nFlags, const XubString& rString,
      38             :         const Font& rFont, const Color* pColor ) :
      39             :     SvLBoxString( pEntry, nFlags, rString ),
      40             :     maFont( rFont ),
      41           0 :     mbUseColor( pColor != NULL )
      42             : {
      43             :     DBG_CTOR( SvLBoxFontString, 0 );
      44           0 :     SetText( rString );
      45           0 :     if( pColor )
      46           0 :         maFont.SetColor( *pColor );
      47           0 : }
      48             : 
      49           0 : SvLBoxFontString::~SvLBoxFontString()
      50             : {
      51             :     DBG_DTOR( SvLBoxFontString, 0 );
      52           0 : }
      53             : 
      54             : 
      55           0 : SvLBoxItem* SvLBoxFontString::Create() const
      56             : {
      57             :     DBG_CHKTHIS( SvLBoxFontString, 0 );
      58           0 :     return new SvLBoxFontString;
      59             : }
      60             : 
      61           0 : void SvLBoxFontString::Paint(
      62             :     const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry)
      63             : {
      64             :     DBG_CHKTHIS( SvLBoxFontString, 0 );
      65           0 :     Font aOldFont( rDev.GetFont() );
      66           0 :     Font aNewFont( maFont );
      67           0 :     bool bSel = pView->IsSelected();
      68           0 :     if( !mbUseColor || bSel )       // selection always gets highlight color
      69             :     {
      70           0 :         const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
      71           0 :         aNewFont.SetColor( bSel ? rSett.GetHighlightTextColor() : rSett.GetFieldTextColor() );
      72             :     }
      73             : 
      74           0 :     rDev.SetFont( aNewFont );
      75           0 :     SvLBoxString::Paint(rPos, rDev, pView, pEntry);
      76           0 :     rDev.SetFont( aOldFont );
      77           0 : }
      78             : 
      79           0 : void SvLBoxFontString::InitViewData( SvTreeListBox* pView, SvTreeListEntry* pEntry, SvViewDataItem* pViewData )
      80             : {
      81             :     DBG_CHKTHIS( SvLBoxFontString, 0 );
      82           0 :     Font aOldFont( pView->GetFont() );
      83           0 :     pView->Control::SetFont( maFont );
      84           0 :     SvLBoxString::InitViewData( pView, pEntry, pViewData);
      85           0 :     pView->Control::SetFont( aOldFont );
      86           0 : }
      87             : 
      88             : 
      89             : // ============================================================================
      90             : 
      91           0 : SvxFontListBox::SvxFontListBox(Window* pParent, WinBits nStyle)
      92             :     : SvTabListBox(pParent, nStyle)
      93           0 :     , maStdFont(GetFont())
      94           0 :     , mbUseFont(false)
      95             : {
      96           0 :     maStdFont.SetTransparent(sal_True);
      97           0 :     maEntryFont = maStdFont;
      98           0 : }
      99             : 
     100           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxFontListBox(Window *pParent, VclBuilder::stringmap &)
     101             : {
     102           0 :     return new SvxFontListBox(pParent, WB_TABSTOP);
     103             : }
     104             : 
     105           0 : void SvxFontListBox::InsertFontEntry( const String& rString, const Font& rFont, const Color* pColor )
     106             : {
     107           0 :     mbUseFont = true;           // InitEntry() will use maEntryFont
     108           0 :     maEntryFont = rFont;        // font to use in InitEntry() over InsertEntry()
     109           0 :     mpEntryColor = pColor;      // color to use in InitEntry() over InsertEntry()
     110           0 :     InsertEntry( rString );
     111           0 :     mbUseFont = false;
     112           0 : }
     113             : 
     114           0 : void SvxFontListBox::SelectEntryPos( sal_uInt16 nPos, bool bSelect )
     115             : {
     116           0 :     SvTreeListEntry* pEntry = GetEntry( nPos );
     117           0 :     if( pEntry )
     118             :     {
     119           0 :         Select( pEntry, bSelect );
     120           0 :         ShowEntry( pEntry );
     121             :     }
     122           0 : }
     123             : 
     124           0 : void SvxFontListBox::SetNoSelection()
     125             : {
     126           0 :     SelectAll( sal_False, sal_True );
     127           0 : }
     128             : 
     129           0 : sal_uLong SvxFontListBox::GetSelectEntryPos() const
     130             : {
     131           0 :     SvTreeListEntry* pSvLBoxEntry = FirstSelected();
     132           0 :     return pSvLBoxEntry ? GetModel()->GetAbsPos( pSvLBoxEntry ) : LIST_APPEND;
     133             : }
     134             : 
     135           0 : XubString SvxFontListBox::GetSelectEntry() const
     136             : {
     137           0 :     return GetEntryText( GetSelectEntryPos() );
     138             : }
     139             : 
     140           0 : void SvxFontListBox::InitEntry(
     141             :         SvTreeListEntry* pEntry, const OUString& rEntryText,
     142             :         const Image& rCollImg, const Image& rExpImg,
     143             :         SvLBoxButtonKind eButtonKind)
     144             : {
     145           0 :     if( mbUseFont )
     146             :     {
     147           0 :         if( nTreeFlags & TREEFLAG_CHKBTN )
     148             :             pEntry->AddItem( new SvLBoxButton( pEntry, eButtonKind, 0,
     149           0 :                                                pCheckButtonData ) );
     150           0 :         pEntry->AddItem( new SvLBoxContextBmp(pEntry, 0, rCollImg, rExpImg, true) );
     151           0 :         pEntry->AddItem( new SvLBoxFontString( pEntry, 0, rEntryText, maEntryFont, mpEntryColor ) );
     152             :     }
     153             :     else
     154             :         SvTreeListBox::InitEntry( pEntry, rEntryText, rCollImg, rExpImg,
     155           0 :                                   eButtonKind );
     156           0 : }
     157             : 
     158             : // ============================================================================
     159             : 
     160             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10