LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/dialog - fontlb.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 71 1.4 %
Date: 2013-07-09 Functions: 2 17 11.8 %
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 &rMap)
     101             : {
     102           0 :     WinBits nWinStyle = WB_TABSTOP;
     103           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     104           0 :     if (!sBorder.isEmpty())
     105           0 :         nWinStyle |= WB_BORDER;
     106           0 :     return new SvxFontListBox(pParent, nWinStyle);
     107             : }
     108             : 
     109           0 : void SvxFontListBox::InsertFontEntry( const String& rString, const Font& rFont, const Color* pColor )
     110             : {
     111           0 :     mbUseFont = true;           // InitEntry() will use maEntryFont
     112           0 :     maEntryFont = rFont;        // font to use in InitEntry() over InsertEntry()
     113           0 :     mpEntryColor = pColor;      // color to use in InitEntry() over InsertEntry()
     114           0 :     InsertEntry( rString );
     115           0 :     mbUseFont = false;
     116           0 : }
     117             : 
     118           0 : void SvxFontListBox::SelectEntryPos( sal_uInt16 nPos, bool bSelect )
     119             : {
     120           0 :     SvTreeListEntry* pEntry = GetEntry( nPos );
     121           0 :     if( pEntry )
     122             :     {
     123           0 :         Select( pEntry, bSelect );
     124           0 :         ShowEntry( pEntry );
     125             :     }
     126           0 : }
     127             : 
     128           0 : void SvxFontListBox::SetNoSelection()
     129             : {
     130           0 :     SelectAll( sal_False, sal_True );
     131           0 : }
     132             : 
     133           0 : sal_uLong SvxFontListBox::GetSelectEntryPos() const
     134             : {
     135           0 :     SvTreeListEntry* pSvLBoxEntry = FirstSelected();
     136           0 :     return pSvLBoxEntry ? GetModel()->GetAbsPos( pSvLBoxEntry ) : LIST_APPEND;
     137             : }
     138             : 
     139           0 : XubString SvxFontListBox::GetSelectEntry() const
     140             : {
     141           0 :     return GetEntryText( GetSelectEntryPos() );
     142             : }
     143             : 
     144           0 : void SvxFontListBox::InitEntry(
     145             :         SvTreeListEntry* pEntry, const OUString& rEntryText,
     146             :         const Image& rCollImg, const Image& rExpImg,
     147             :         SvLBoxButtonKind eButtonKind)
     148             : {
     149           0 :     if( mbUseFont )
     150             :     {
     151           0 :         if( nTreeFlags & TREEFLAG_CHKBTN )
     152             :             pEntry->AddItem( new SvLBoxButton( pEntry, eButtonKind, 0,
     153           0 :                                                pCheckButtonData ) );
     154           0 :         pEntry->AddItem( new SvLBoxContextBmp(pEntry, 0, rCollImg, rExpImg, true) );
     155           0 :         pEntry->AddItem( new SvLBoxFontString( pEntry, 0, rEntryText, maEntryFont, mpEntryColor ) );
     156             :     }
     157             :     else
     158             :         SvTreeListBox::InitEntry( pEntry, rEntryText, rCollImg, rExpImg,
     159           0 :                                   eButtonKind );
     160         216 : }
     161             : 
     162             : // ============================================================================
     163             : 
     164             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10