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

Generated by: LCOV version 1.11