LCOV - code coverage report
Current view: top level - svx/source/sidebar/text - TextUnderlineControl.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 150 0.7 %
Date: 2015-06-13 12:38:46 Functions: 2 12 16.7 %
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(VclPtr<ValueSet>::Create(this, SVX_RES(VS_UNDERLINE)))
      39           0 : ,   maPBOptions (VclPtr<PushButton>::Create(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 : TextUnderlineControl::~TextUnderlineControl()
      69             : {
      70           0 :     disposeOnce();
      71           0 : }
      72             : 
      73           0 : void TextUnderlineControl::dispose()
      74             : {
      75           0 :     maVSUnderline.disposeAndClear();
      76           0 :     maPBOptions.disposeAndClear();
      77           0 :     svx::sidebar::PopupControl::dispose();
      78           0 : }
      79             : 
      80           0 : void TextUnderlineControl::initial()
      81             : {
      82           0 :     maVSUnderline->SetColor(GetSettings().GetStyleSettings().GetHighContrastMode() ?
      83           0 :         GetSettings().GetStyleSettings().GetMenuColor() :
      84           0 :         sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
      85           0 :     maVSUnderline->SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode() ?
      86           0 :         GetSettings().GetStyleSettings().GetMenuColor() :
      87           0 :         sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
      88             : 
      89           0 :     Link<> aLink = LINK( this, TextUnderlineControl, PBClickHdl ) ;
      90           0 :     maPBOptions->SetClickHdl(aLink);
      91             : 
      92           0 :     maVSUnderline->SetStyle( maVSUnderline->GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT );
      93             : 
      94             :     // 'none' item
      95           0 :     maVSUnderline->SetStyle( maVSUnderline->GetStyle()| WB_NONEFIELD | WB_MENUSTYLEVALUESET );
      96           0 :     maVSUnderline->SetText( SVX_RESSTR(STR_WITHOUT) );
      97             : 
      98           0 :     maVSUnderline->InsertItem(1, maIMGSingle, SVX_RESSTR(STR_SINGLE));
      99           0 :     maVSUnderline->SetItemData(1, reinterpret_cast<void*>(UNDERLINE_SINGLE));
     100             : 
     101           0 :     maVSUnderline->InsertItem(2, maIMGDouble, SVX_RESSTR(STR_DOUBLE));
     102           0 :     maVSUnderline->SetItemData(2, reinterpret_cast<void*>(UNDERLINE_DOUBLE));
     103             : 
     104           0 :     maVSUnderline->InsertItem(3, maIMGBold, SVX_RESSTR(STR_BOLD));
     105           0 :     maVSUnderline->SetItemData(3, reinterpret_cast<void*>(UNDERLINE_BOLD));
     106             : 
     107           0 :     maVSUnderline->InsertItem(4, maIMGDot, SVX_RESSTR(STR_DOT));
     108           0 :     maVSUnderline->SetItemData(4, reinterpret_cast<void*>(UNDERLINE_DOTTED));
     109             : 
     110           0 :     maVSUnderline->InsertItem(5, maIMGDotBold, SVX_RESSTR(STR_DOT_BOLD));
     111           0 :     maVSUnderline->SetItemData(5, reinterpret_cast<void*>(UNDERLINE_BOLDDOTTED));
     112             : 
     113           0 :     maVSUnderline->InsertItem(6, maIMGDash, SVX_RESSTR(STR_DASH));
     114           0 :     maVSUnderline->SetItemData(6, reinterpret_cast<void*>(UNDERLINE_DASH));
     115             : 
     116           0 :     maVSUnderline->InsertItem(7, maIMGDashLong, SVX_RESSTR(STR_DASH_LONG));
     117           0 :     maVSUnderline->SetItemData(7, reinterpret_cast<void*>(UNDERLINE_LONGDASH));
     118             : 
     119           0 :     maVSUnderline->InsertItem(8, maIMGDashDot, SVX_RESSTR(STR_DASH_DOT));
     120           0 :     maVSUnderline->SetItemData(8, reinterpret_cast<void*>(UNDERLINE_DASHDOT));
     121             : 
     122           0 :     maVSUnderline->InsertItem(9, maIMGDashDotDot, SVX_RESSTR(STR_DASH_DOT_DOT));
     123           0 :     maVSUnderline->SetItemData(9, reinterpret_cast<void*>(UNDERLINE_DASHDOTDOT));
     124             : 
     125           0 :     maVSUnderline->InsertItem(10, maIMGWave, SVX_RESSTR(STR_WAVE));
     126           0 :     maVSUnderline->SetItemData(10, reinterpret_cast<void*>(UNDERLINE_WAVE));
     127             : 
     128           0 :     maVSUnderline->SetColCount( 1 );
     129           0 :     aLink =  LINK( this, TextUnderlineControl, VSSelectHdl ) ;
     130           0 :     maVSUnderline->SetSelectHdl(aLink);
     131             : 
     132           0 :     maVSUnderline->StartSelection();
     133           0 :     maVSUnderline->Show();
     134           0 : }
     135             : 
     136             : 
     137           0 : void TextUnderlineControl::Rearrange(FontUnderline eLine)
     138             : {
     139           0 :     maVSUnderline->SetItemImage(1, maIMGSingle);
     140           0 :     maVSUnderline->SetItemImage(2, maIMGDouble );
     141           0 :     maVSUnderline->SetItemImage(3, maIMGBold);
     142           0 :     maVSUnderline->SetItemImage(4, maIMGDot);
     143           0 :     maVSUnderline->SetItemImage(5, maIMGDotBold);
     144           0 :     maVSUnderline->SetItemImage(6, maIMGDash);
     145           0 :     maVSUnderline->SetItemImage(7, maIMGDashLong);
     146           0 :     maVSUnderline->SetItemImage(8, maIMGDashDot);
     147           0 :     maVSUnderline->SetItemImage(9, maIMGDashDotDot);
     148           0 :     maVSUnderline->SetItemImage(10, maIMGWave);
     149             : 
     150           0 :     switch(eLine)
     151             :     {
     152             :     case UNDERLINE_SINGLE:
     153           0 :         maVSUnderline->SetItemImage(1, maIMGSingleSel);
     154           0 :         maVSUnderline->SelectItem(1);
     155           0 :         maVSUnderline->GrabFocus();
     156           0 :         break;
     157             :     case UNDERLINE_DOUBLE:
     158           0 :         maVSUnderline->SetItemImage(2, maIMGDoubleSel);
     159           0 :         maVSUnderline->SelectItem(2);
     160           0 :         maVSUnderline->GrabFocus();
     161           0 :         break;
     162             :     case UNDERLINE_BOLD:
     163           0 :         maVSUnderline->SetItemImage(3, maIMGBoldSel);
     164           0 :         maVSUnderline->SelectItem(3);
     165           0 :         maVSUnderline->GrabFocus();
     166           0 :         break;
     167             :     case UNDERLINE_DOTTED:
     168           0 :         maVSUnderline->SetItemImage(4, maIMGDotSel);
     169           0 :         maVSUnderline->SelectItem(4);
     170           0 :         maVSUnderline->GrabFocus();
     171           0 :         break;
     172             :     case UNDERLINE_BOLDDOTTED:
     173           0 :         maVSUnderline->SetItemImage(5, maIMGDotBoldSel);
     174           0 :         maVSUnderline->SelectItem(5);
     175           0 :         maVSUnderline->GrabFocus();
     176           0 :         break;
     177             :     case UNDERLINE_DASH:
     178           0 :         maVSUnderline->SetItemImage(6, maIMGDashSel);
     179           0 :         maVSUnderline->SelectItem(6);
     180           0 :         maVSUnderline->GrabFocus();
     181           0 :         break;
     182             :     case UNDERLINE_LONGDASH:
     183           0 :         maVSUnderline->SetItemImage(7, maIMGDashLongSel);
     184           0 :         maVSUnderline->SelectItem(7);
     185           0 :         maVSUnderline->GrabFocus();
     186           0 :         break;
     187             :     case UNDERLINE_DASHDOT:
     188           0 :         maVSUnderline->SetItemImage(8, maIMGDashDotSel);
     189           0 :         maVSUnderline->SelectItem(8);
     190           0 :         maVSUnderline->GrabFocus();
     191           0 :         break;
     192             :     case UNDERLINE_DASHDOTDOT:
     193           0 :         maVSUnderline->SetItemImage(9, maIMGDashDotDotSel);
     194           0 :         maVSUnderline->SelectItem(9);
     195           0 :         maVSUnderline->GrabFocus();
     196           0 :         break;
     197             :     case UNDERLINE_WAVE:
     198           0 :         maVSUnderline->SetItemImage(10, maIMGWaveSel);
     199           0 :         maVSUnderline->SelectItem(10);
     200           0 :         maVSUnderline->GrabFocus();
     201           0 :         break;
     202             :     case UNDERLINE_NONE:
     203           0 :         maVSUnderline->SelectItem(0);
     204           0 :         maVSUnderline->GrabFocus();
     205           0 :         break;
     206             :     default:
     207           0 :         maVSUnderline->SelectItem(1);
     208           0 :         maVSUnderline->SetNoSelection();
     209           0 :         maPBOptions->GrabFocus();
     210             :     }
     211           0 :     maVSUnderline->StartSelection();
     212           0 : }
     213             : 
     214             : 
     215           0 : IMPL_LINK(TextUnderlineControl, VSSelectHdl, void *, pControl)
     216             : {
     217           0 :     if ( pControl == maVSUnderline.get() )
     218             :     {
     219           0 :         const sal_uInt16 iPos = maVSUnderline->GetSelectItemId();
     220             :         const FontUnderline eUnderline = ( iPos == 0 )
     221             :                                          ? UNDERLINE_NONE
     222           0 :                                          : static_cast<FontUnderline>(reinterpret_cast<sal_uInt64>(maVSUnderline->GetItemData( iPos )));
     223             : 
     224           0 :         SvxUnderlineItem aLineItem(eUnderline, SID_ATTR_CHAR_UNDERLINE);
     225             : 
     226           0 :         aLineItem.SetColor(mrTextPropertyPanel.GetUnderlineColor());
     227           0 :         mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SfxCallMode::RECORD, &aLineItem, 0L);
     228           0 :         mrTextPropertyPanel.EndUnderlinePopupMode();
     229             :     }
     230           0 :     return 0L;
     231             : }
     232             : 
     233           0 : IMPL_LINK(TextUnderlineControl, PBClickHdl, PushButton *, pPBtn)
     234             : {
     235           0 :     if(pPBtn == maPBOptions.get())
     236             :     {
     237           0 :         if (mpBindings)
     238             :         {
     239           0 :             SfxDispatcher* pDisp = mpBindings->GetDispatcher();
     240           0 :             pDisp->Execute( SID_CHAR_DLG_EFFECT, SfxCallMode::ASYNCHRON );
     241             :         }
     242           0 :         mrTextPropertyPanel.EndUnderlinePopupMode();
     243             :     }
     244           0 :     return 0;
     245             : }
     246             : 
     247         390 : }}
     248             : 
     249             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11