LCOV - code coverage report
Current view: top level - svx/source/dialog - fontlb.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 71 0.0 %
Date: 2014-04-11 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 <vcl/settings.hxx>
      24             : #include "svtools/treelistentry.hxx"
      25             : #include "svtools/viewdataentry.hxx"
      26             : 
      27             : 
      28             : 
      29             : 
      30           0 : SvLBoxFontString::SvLBoxFontString()
      31             :     : SvLBoxString()
      32           0 :     , mbUseColor(false)
      33             : {
      34           0 : }
      35             : 
      36           0 : SvLBoxFontString::SvLBoxFontString(
      37             :         SvTreeListEntry* pEntry, sal_uInt16 nFlags, const OUString& rString,
      38             :         const Font& rFont, const Color* pColor ) :
      39             :     SvLBoxString( pEntry, nFlags, rString ),
      40             :     maFont( rFont ),
      41           0 :     mbUseColor( pColor != NULL )
      42             : {
      43           0 :     SetText( rString );
      44           0 :     if( pColor )
      45           0 :         maFont.SetColor( *pColor );
      46           0 : }
      47             : 
      48           0 : SvLBoxFontString::~SvLBoxFontString()
      49             : {
      50           0 : }
      51             : 
      52             : 
      53           0 : SvLBoxItem* SvLBoxFontString::Create() const
      54             : {
      55           0 :     return new SvLBoxFontString;
      56             : }
      57             : 
      58           0 : void SvLBoxFontString::Paint(
      59             :     const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry)
      60             : {
      61           0 :     Font aOldFont( rDev.GetFont() );
      62           0 :     Font aNewFont( maFont );
      63           0 :     bool bSel = pView->IsSelected();
      64           0 :     if( !mbUseColor || bSel )       // selection always gets highlight color
      65             :     {
      66           0 :         const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
      67           0 :         aNewFont.SetColor( bSel ? rSett.GetHighlightTextColor() : rSett.GetFieldTextColor() );
      68             :     }
      69             : 
      70           0 :     rDev.SetFont( aNewFont );
      71           0 :     SvLBoxString::Paint(rPos, rDev, pView, pEntry);
      72           0 :     rDev.SetFont( aOldFont );
      73           0 : }
      74             : 
      75           0 : void SvLBoxFontString::InitViewData( SvTreeListBox* pView, SvTreeListEntry* pEntry, SvViewDataItem* pViewData )
      76             : {
      77           0 :     Font aOldFont( pView->GetFont() );
      78           0 :     pView->Control::SetFont( maFont );
      79           0 :     SvLBoxString::InitViewData( pView, pEntry, pViewData);
      80           0 :     pView->Control::SetFont( aOldFont );
      81           0 : }
      82             : 
      83             : 
      84             : 
      85             : 
      86           0 : SvxFontListBox::SvxFontListBox(Window* pParent, WinBits nStyle)
      87             :     : SvTabListBox(pParent, nStyle)
      88           0 :     , maStdFont(GetFont())
      89             :     , mpEntryColor(NULL)
      90           0 :     , mbUseFont(false)
      91             : {
      92           0 :     maStdFont.SetTransparent(true);
      93           0 :     maEntryFont = maStdFont;
      94           0 : }
      95             : 
      96           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxFontListBox(Window *pParent, VclBuilder::stringmap &rMap)
      97             : {
      98           0 :     WinBits nWinStyle = WB_TABSTOP;
      99           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     100           0 :     if (!sBorder.isEmpty())
     101           0 :         nWinStyle |= WB_BORDER;
     102           0 :     return new SvxFontListBox(pParent, nWinStyle);
     103             : }
     104             : 
     105           0 : void SvxFontListBox::InsertFontEntry( const OUString& 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_uLong 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( false, true );
     127           0 : }
     128             : 
     129           0 : sal_uLong SvxFontListBox::GetSelectEntryPos() const
     130             : {
     131           0 :     SvTreeListEntry* pSvLBoxEntry = FirstSelected();
     132           0 :     return pSvLBoxEntry ? GetModel()->GetAbsPos( pSvLBoxEntry ) : TREELIST_ENTRY_NOTFOUND;
     133             : }
     134             : 
     135           0 : OUString 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