LCOV - code coverage report
Current view: top level - svx/source/sidebar/text - TextUnderlineControl.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 142 0.7 %
Date: 2014-11-03 Functions: 2 9 22.2 %
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             : #include "TextUnderlineControl.hxx"
      20             : #include "TextPropertyPanel.hrc"
      21             : #include <sfx2/sidebar/ResourceDefinitions.hrc>
      22             : #include <svx/dialogs.hrc>
      23             : #include <svx/dialmgr.hxx>
      24             : #include <sfx2/dispatch.hxx>
      25             : #include <sfx2/sidebar/Theme.hxx>
      26             : #include <editeng/udlnitem.hxx>
      27             : #include <vcl/settings.hxx>
      28             : 
      29             : namespace svx { namespace sidebar {
      30             : 
      31           0 : TextUnderlineControl::TextUnderlineControl (
      32             :     vcl::Window* pParent,
      33             :     svx::sidebar::TextPropertyPanel& rPanel,
      34             :     SfxBindings* pBindings)
      35           0 : :   svx::sidebar::PopupControl( pParent,SVX_RES(RID_POPUPPANEL_TEXTPAGE_UNDERLINE))
      36             : ,   mrTextPropertyPanel(rPanel)
      37             : ,   mpBindings(pBindings)
      38           0 : ,   maVSUnderline( this, SVX_RES(VS_UNDERLINE))
      39           0 : ,   maPBOptions (this, SVX_RES(PB_OPTIONS) )
      40             : 
      41           0 : ,   maIMGSingle     (SVX_RES(IMG_SINGLE))
      42           0 : ,   maIMGDouble     (SVX_RES(IMG_DOUBLE))
      43           0 : ,   maIMGBold       (SVX_RES(IMG_BOLD2))
      44           0 : ,   maIMGDot        (SVX_RES(IMG_DOT))
      45           0 : ,   maIMGDotBold    (SVX_RES(IMG_DOT_BOLD))
      46           0 : ,   maIMGDash       (SVX_RES(IMG_DASH))
      47           0 : ,   maIMGDashLong   (SVX_RES(IMG_DASH_LONG))
      48           0 : ,   maIMGDashDot    (SVX_RES(IMG_DASH_DOT))
      49           0 : ,   maIMGDashDotDot (SVX_RES(IMG_DASH_DOT_DOT))
      50           0 : ,   maIMGWave       (SVX_RES(IMG_WAVE))
      51             : 
      52           0 : ,   maIMGSingleSel      (SVX_RES(IMG_SINGLE_SEL))
      53           0 : ,   maIMGDoubleSel      (SVX_RES(IMG_DOUBLE_SEL))
      54           0 : ,   maIMGBoldSel        (SVX_RES(IMG_BOLD2_SEL))
      55           0 : ,   maIMGDotSel         (SVX_RES(IMG_DOT_SEL))
      56           0 : ,   maIMGDotBoldSel     (SVX_RES(IMG_DOT_BOLD_SEL))
      57           0 : ,   maIMGDashSel        (SVX_RES(IMG_DASH_SEL))
      58           0 : ,   maIMGDashLongSel    (SVX_RES(IMG_DASH_LONG_SEL))
      59           0 : ,   maIMGDashDotSel     (SVX_RES(IMG_DASH_DOT_SEL))
      60           0 : ,   maIMGDashDotDotSel  (SVX_RES(IMG_DASH_DOT_DOT_SEL))
      61           0 : ,   maIMGWaveSel        (SVX_RES(IMG_WAVE_SEL))
      62             : 
      63             : {
      64           0 :     initial();
      65           0 :     FreeResource();
      66           0 : }
      67             : 
      68           0 : void TextUnderlineControl::initial()
      69             : {
      70           0 :     maVSUnderline.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
      71           0 :         GetSettings().GetStyleSettings().GetMenuColor():
      72           0 :         sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
      73           0 :     maVSUnderline.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()?
      74           0 :         GetSettings().GetStyleSettings().GetMenuColor():
      75           0 :         sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
      76             : 
      77           0 :     Link aLink = LINK( this, TextUnderlineControl, PBClickHdl ) ;
      78           0 :     maPBOptions.SetClickHdl(aLink);
      79             : 
      80           0 :     maVSUnderline.SetStyle( maVSUnderline.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT );
      81             : 
      82             :     // 'none' item
      83           0 :     maVSUnderline.SetStyle( maVSUnderline.GetStyle()| WB_NONEFIELD | WB_MENUSTYLEVALUESET );
      84           0 :     maVSUnderline.SetText( SVX_RESSTR(STR_WITHOUT) );
      85             : 
      86           0 :     maVSUnderline.InsertItem(1, maIMGSingle, SVX_RESSTR(STR_SINGLE));
      87           0 :     maVSUnderline.SetItemData(1, reinterpret_cast<void*>(UNDERLINE_SINGLE));
      88             : 
      89           0 :     maVSUnderline.InsertItem(2, maIMGDouble, SVX_RESSTR(STR_DOUBLE));
      90           0 :     maVSUnderline.SetItemData(2, reinterpret_cast<void*>(UNDERLINE_DOUBLE));
      91             : 
      92           0 :     maVSUnderline.InsertItem(3, maIMGBold, SVX_RESSTR(STR_BOLD));
      93           0 :     maVSUnderline.SetItemData(3, reinterpret_cast<void*>(UNDERLINE_BOLD));
      94             : 
      95           0 :     maVSUnderline.InsertItem(4, maIMGDot, SVX_RESSTR(STR_DOT));
      96           0 :     maVSUnderline.SetItemData(4, reinterpret_cast<void*>(UNDERLINE_DOTTED));
      97             : 
      98           0 :     maVSUnderline.InsertItem(5, maIMGDotBold, SVX_RESSTR(STR_DOT_BOLD));
      99           0 :     maVSUnderline.SetItemData(5, reinterpret_cast<void*>(UNDERLINE_BOLDDOTTED));
     100             : 
     101           0 :     maVSUnderline.InsertItem(6, maIMGDash, SVX_RESSTR(STR_DASH));
     102           0 :     maVSUnderline.SetItemData(6, reinterpret_cast<void*>(UNDERLINE_DASH));
     103             : 
     104           0 :     maVSUnderline.InsertItem(7, maIMGDashLong, SVX_RESSTR(STR_DASH_LONG));
     105           0 :     maVSUnderline.SetItemData(7, reinterpret_cast<void*>(UNDERLINE_LONGDASH));
     106             : 
     107           0 :     maVSUnderline.InsertItem(8, maIMGDashDot, SVX_RESSTR(STR_DASH_DOT));
     108           0 :     maVSUnderline.SetItemData(8, reinterpret_cast<void*>(UNDERLINE_DASHDOT));
     109             : 
     110           0 :     maVSUnderline.InsertItem(9, maIMGDashDotDot, SVX_RESSTR(STR_DASH_DOT_DOT));
     111           0 :     maVSUnderline.SetItemData(9, reinterpret_cast<void*>(UNDERLINE_DASHDOTDOT));
     112             : 
     113           0 :     maVSUnderline.InsertItem(10, maIMGWave, SVX_RESSTR(STR_WAVE));
     114           0 :     maVSUnderline.SetItemData(10, reinterpret_cast<void*>(UNDERLINE_WAVE));
     115             : 
     116           0 :     maVSUnderline.SetColCount( 1 );
     117           0 :     aLink =  LINK( this, TextUnderlineControl, VSSelectHdl ) ;
     118           0 :     maVSUnderline.SetSelectHdl(aLink);
     119             : 
     120           0 :     maVSUnderline.StartSelection();
     121           0 :     maVSUnderline.Show();
     122           0 : }
     123             : 
     124             : 
     125           0 : void TextUnderlineControl::Rearrange(FontUnderline eLine)
     126             : {
     127           0 :     maVSUnderline.SetItemImage(1, maIMGSingle);
     128           0 :     maVSUnderline.SetItemImage(2, maIMGDouble );
     129           0 :     maVSUnderline.SetItemImage(3, maIMGBold);
     130           0 :     maVSUnderline.SetItemImage(4, maIMGDot);
     131           0 :     maVSUnderline.SetItemImage(5, maIMGDotBold);
     132           0 :     maVSUnderline.SetItemImage(6, maIMGDash);
     133           0 :     maVSUnderline.SetItemImage(7, maIMGDashLong);
     134           0 :     maVSUnderline.SetItemImage(8, maIMGDashDot);
     135           0 :     maVSUnderline.SetItemImage(9, maIMGDashDotDot);
     136           0 :     maVSUnderline.SetItemImage(10, maIMGWave);
     137             : 
     138           0 :     switch(eLine)
     139             :     {
     140             :     case UNDERLINE_SINGLE:
     141           0 :         maVSUnderline.SetItemImage(1, maIMGSingleSel);
     142           0 :         maVSUnderline.SelectItem(1);
     143           0 :         maVSUnderline.GrabFocus();
     144           0 :         break;
     145             :     case UNDERLINE_DOUBLE:
     146           0 :         maVSUnderline.SetItemImage(2, maIMGDoubleSel);
     147           0 :         maVSUnderline.SelectItem(2);
     148           0 :         maVSUnderline.GrabFocus();
     149           0 :         break;
     150             :     case UNDERLINE_BOLD:
     151           0 :         maVSUnderline.SetItemImage(3, maIMGBoldSel);
     152           0 :         maVSUnderline.SelectItem(3);
     153           0 :         maVSUnderline.GrabFocus();
     154           0 :         break;
     155             :     case UNDERLINE_DOTTED:
     156           0 :         maVSUnderline.SetItemImage(4, maIMGDotSel);
     157           0 :         maVSUnderline.SelectItem(4);
     158           0 :         maVSUnderline.GrabFocus();
     159           0 :         break;
     160             :     case UNDERLINE_BOLDDOTTED:
     161           0 :         maVSUnderline.SetItemImage(5, maIMGDotBoldSel);
     162           0 :         maVSUnderline.SelectItem(5);
     163           0 :         maVSUnderline.GrabFocus();
     164           0 :         break;
     165             :     case UNDERLINE_DASH:
     166           0 :         maVSUnderline.SetItemImage(6, maIMGDashSel);
     167           0 :         maVSUnderline.SelectItem(6);
     168           0 :         maVSUnderline.GrabFocus();
     169           0 :         break;
     170             :     case UNDERLINE_LONGDASH:
     171           0 :         maVSUnderline.SetItemImage(7, maIMGDashLongSel);
     172           0 :         maVSUnderline.SelectItem(7);
     173           0 :         maVSUnderline.GrabFocus();
     174           0 :         break;
     175             :     case UNDERLINE_DASHDOT:
     176           0 :         maVSUnderline.SetItemImage(8, maIMGDashDotSel);
     177           0 :         maVSUnderline.SelectItem(8);
     178           0 :         maVSUnderline.GrabFocus();
     179           0 :         break;
     180             :     case UNDERLINE_DASHDOTDOT:
     181           0 :         maVSUnderline.SetItemImage(9, maIMGDashDotDotSel);
     182           0 :         maVSUnderline.SelectItem(9);
     183           0 :         maVSUnderline.GrabFocus();
     184           0 :         break;
     185             :     case UNDERLINE_WAVE:
     186           0 :         maVSUnderline.SetItemImage(10, maIMGWaveSel);
     187           0 :         maVSUnderline.SelectItem(10);
     188           0 :         maVSUnderline.GrabFocus();
     189           0 :         break;
     190             :     case UNDERLINE_NONE:
     191           0 :         maVSUnderline.SelectItem(0);
     192           0 :         maVSUnderline.GrabFocus();
     193           0 :         break;
     194             :     default:
     195           0 :         maVSUnderline.SelectItem(1);
     196           0 :         maVSUnderline.SetNoSelection();
     197           0 :         maPBOptions.GrabFocus();
     198             :     }
     199           0 :     maVSUnderline.StartSelection();
     200           0 : }
     201             : 
     202             : 
     203           0 : IMPL_LINK(TextUnderlineControl, VSSelectHdl, void *, pControl)
     204             : {
     205           0 :     if ( pControl == &maVSUnderline )
     206             :     {
     207           0 :         const sal_uInt16 iPos = maVSUnderline.GetSelectItemId();
     208             :         const FontUnderline eUnderline = ( iPos == 0 )
     209             :                                          ? UNDERLINE_NONE
     210           0 :                                          : static_cast<FontUnderline>(reinterpret_cast<sal_uInt64>(maVSUnderline.GetItemData( iPos )));
     211             : 
     212           0 :         SvxUnderlineItem aLineItem(eUnderline, SID_ATTR_CHAR_UNDERLINE);
     213             : 
     214           0 :         aLineItem.SetColor(mrTextPropertyPanel.GetUnderlineColor());
     215           0 :         mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SfxCallMode::RECORD, &aLineItem, 0L);
     216           0 :         mrTextPropertyPanel.EndUnderlinePopupMode();
     217             :     }
     218           0 :     return( 0L );
     219             : }
     220             : 
     221           0 : IMPL_LINK(TextUnderlineControl, PBClickHdl, PushButton *, pPBtn)
     222             : {
     223           0 :     if(pPBtn == &maPBOptions)
     224             :     {
     225           0 :         if (mpBindings)
     226             :         {
     227           0 :             SfxDispatcher* pDisp = mpBindings->GetDispatcher();
     228           0 :             pDisp->Execute( SID_CHAR_DLG_EFFECT, SfxCallMode::ASYNCHRON );
     229             :         }
     230           0 :         mrTextPropertyPanel.EndUnderlinePopupMode();
     231             :     }
     232           0 :     return 0;
     233             : }
     234             : 
     235         594 : }}
     236             : 
     237             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10