LCOV - code coverage report
Current view: top level - sc/source/ui/sidebar - CellLineStyleControl.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 126 0.8 %
Date: 2014-11-03 Functions: 2 11 18.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             : 
      20             : #include "CellLineStyleControl.hxx"
      21             : #include "sc.hrc"
      22             : #include "scresid.hxx"
      23             : #include <CellAppearancePropertyPanel.hrc>
      24             : #include "CellLineStyleValueSet.hxx"
      25             : #include <vcl/i18nhelp.hxx>
      26             : #include <vcl/settings.hxx>
      27             : #include <editeng/boxitem.hxx>
      28             : #include <editeng/borderline.hxx>
      29             : #include <editeng/lineitem.hxx>
      30             : #include "CellAppearancePropertyPanel.hxx"
      31             : #include <sfx2/bindings.hxx>
      32             : #include <sfx2/dispatch.hxx>
      33             : 
      34             : namespace sc { namespace sidebar {
      35             : 
      36           0 : CellLineStyleControl::CellLineStyleControl(vcl::Window* pParent, CellAppearancePropertyPanel& rPanel)
      37             : :   svx::sidebar::PopupControl(pParent, ScResId(RID_POPUPPANEL_APPEARANCE_CELL_LINESTYLE)),
      38             :     mrCellAppearancePropertyPanel(rPanel),
      39             :     maPushButtonMoreOptions(this, ScResId(PB_OPTIONS)),
      40             :     maCellLineStyleValueSet(this, ScResId(VS_STYLE)),
      41           0 :     mbVSfocus(true)
      42             : {
      43           0 :     Initialize();
      44           0 :     FreeResource();
      45           0 : }
      46             : 
      47           0 : void CellLineStyleControl::Initialize()
      48             : {
      49             :     //maPushButtonMoreOptions.SetIcoPosX(2);
      50           0 :     Link aLink = LINK(this, CellLineStyleControl, PBClickHdl);
      51           0 :     maPushButtonMoreOptions.SetClickHdl(aLink);
      52             : 
      53           0 :     maCellLineStyleValueSet.SetStyle(maCellLineStyleValueSet.GetStyle()| WB_3DLOOK |  WB_NO_DIRECTSELECT);
      54           0 :     maCellLineStyleValueSet.SetControlBackground(GetSettings().GetStyleSettings().GetMenuColor());
      55           0 :     maCellLineStyleValueSet.SetColor(GetSettings().GetStyleSettings().GetMenuColor());
      56             : 
      57           0 :     for(sal_uInt16 i = 1 ; i <= 9 ; i++)
      58             :     {
      59           0 :         maCellLineStyleValueSet.InsertItem(i);
      60             :     }
      61             : 
      62           0 :     maStr[0] = GetSettings().GetLocaleI18nHelper().GetNum( 5, 2 ) + "pt";
      63           0 :     maStr[1] = GetSettings().GetLocaleI18nHelper().GetNum( 250, 2 ) + "pt";
      64           0 :     maStr[2] = GetSettings().GetLocaleI18nHelper().GetNum( 400, 2 ) + "pt";
      65           0 :     maStr[3] = GetSettings().GetLocaleI18nHelper().GetNum( 500, 2 ) + "pt";
      66           0 :     maStr[4] = GetSettings().GetLocaleI18nHelper().GetNum( 110, 2 ) + "pt";
      67           0 :     maStr[5] = GetSettings().GetLocaleI18nHelper().GetNum( 260, 2 ) + "pt";
      68           0 :     maStr[6] = GetSettings().GetLocaleI18nHelper().GetNum( 450, 2 ) + "pt";
      69           0 :     maStr[7] = GetSettings().GetLocaleI18nHelper().GetNum( 505, 2 ) + "pt";
      70           0 :     maStr[8] = GetSettings().GetLocaleI18nHelper().GetNum( 750, 2 ) + "pt";
      71           0 :     maCellLineStyleValueSet.SetUnit(&maStr[0]);
      72             : 
      73           0 :     for (sal_uInt16 i = 1; i <= CELL_LINE_STYLE_ENTRIES; ++i)
      74             :     {
      75           0 :         maCellLineStyleValueSet.SetItemText(i, maStr[i-1]);
      76             :     }
      77             : 
      78           0 :     SetAllNoSel();
      79           0 :     aLink = LINK(this, CellLineStyleControl, VSSelectHdl);
      80           0 :     maCellLineStyleValueSet.SetSelectHdl(aLink);
      81           0 :     maCellLineStyleValueSet.StartSelection();
      82           0 :     maCellLineStyleValueSet.Show();
      83           0 : }
      84             : 
      85           0 : void CellLineStyleControl::GetFocus()
      86             : {
      87           0 :     if(!mbVSfocus)
      88             :     {
      89           0 :         maPushButtonMoreOptions.GrabFocus();
      90             :     }
      91             :     else
      92             :     {
      93           0 :         maCellLineStyleValueSet.GrabFocus();
      94             :     }
      95           0 : }
      96             : 
      97           0 : void CellLineStyleControl::SetAllNoSel()
      98             : {
      99           0 :     maCellLineStyleValueSet.SelectItem(0);
     100           0 :     maCellLineStyleValueSet.SetNoSelection();
     101           0 :     maCellLineStyleValueSet.Format();
     102           0 :     Invalidate();
     103           0 :     maCellLineStyleValueSet.StartSelection();
     104           0 : }
     105             : 
     106           0 : IMPL_LINK(CellLineStyleControl, VSSelectHdl, void *, pControl)
     107             : {
     108           0 :     if(pControl == &maCellLineStyleValueSet)
     109             :     {
     110           0 :         const sal_uInt16 iPos(maCellLineStyleValueSet.GetSelectItemId());
     111           0 :         SvxLineItem aLineItem(SID_FRAME_LINESTYLE);
     112             :         using namespace ::com::sun::star::table::BorderLineStyle;
     113           0 :         editeng::SvxBorderStyle nStyle = SOLID;
     114           0 :         sal_uInt16 n1 = 0;
     115           0 :         sal_uInt16 n2 = 0;
     116           0 :         sal_uInt16 n3 = 0;
     117             : 
     118             :         //FIXME: fully for new border line possibilities
     119             : 
     120           0 :         switch(iPos)
     121             :         {
     122             :             case 1:
     123           0 :                 n1 = DEF_LINE_WIDTH_0;
     124           0 :                 break;
     125             :             case 2:
     126           0 :                 n1 = DEF_LINE_WIDTH_2;
     127           0 :                 break;
     128             :             case 3:
     129           0 :                 n1 = DEF_LINE_WIDTH_3;
     130           0 :                 break;
     131             :             case 4:
     132           0 :                 n1 = DEF_LINE_WIDTH_4;
     133           0 :                 break;
     134             :             case 5:
     135           0 :                 n1 = DEF_LINE_WIDTH_0;
     136           0 :                 n2 = DEF_LINE_WIDTH_0;
     137           0 :                 n3 = DEF_LINE_WIDTH_1;
     138           0 :                 nStyle = DOUBLE;
     139           0 :                 break;
     140             :             case 6:
     141           0 :                 n1 = DEF_LINE_WIDTH_0;
     142           0 :                 n2 = DEF_LINE_WIDTH_0;
     143           0 :                 n3 = DEF_LINE_WIDTH_2;
     144           0 :                 nStyle = DOUBLE;
     145           0 :                 break;
     146             :             case 7:
     147           0 :                 n1 = DEF_LINE_WIDTH_1;
     148           0 :                 n2 = DEF_LINE_WIDTH_2;
     149           0 :                 n3 = DEF_LINE_WIDTH_1;
     150           0 :                 nStyle = DOUBLE;
     151           0 :                 break;
     152             :             case 8:
     153           0 :                 n1 = DEF_LINE_WIDTH_2;
     154           0 :                 n2 = DEF_LINE_WIDTH_0;
     155           0 :                 n3 = DEF_LINE_WIDTH_2;
     156           0 :                 nStyle = DOUBLE;
     157           0 :                 break;
     158             :             case 9:
     159           0 :                 n1 = DEF_LINE_WIDTH_2;
     160           0 :                 n2 = DEF_LINE_WIDTH_2;
     161           0 :                 n3 = DEF_LINE_WIDTH_2;
     162           0 :                 nStyle = DOUBLE;
     163           0 :                 break;
     164             :             default:
     165           0 :                 break;
     166             :         }
     167             : 
     168           0 :         editeng::SvxBorderLine aTmp;
     169           0 :         aTmp.GuessLinesWidths(nStyle, n1, n2, n3);
     170           0 :         aLineItem.SetLine( &aTmp );
     171           0 :         mrCellAppearancePropertyPanel.GetBindings()->GetDispatcher()->Execute(SID_FRAME_LINESTYLE, SfxCallMode::RECORD, &aLineItem, 0L);
     172           0 :         SetAllNoSel();
     173           0 :         mrCellAppearancePropertyPanel.EndCellLineStylePopupMode();
     174             :     }
     175             : 
     176           0 :     return(0L);
     177             : }
     178             : 
     179           0 : IMPL_LINK(CellLineStyleControl, PBClickHdl, PushButton *, pPBtn)
     180             : {
     181           0 :     if(pPBtn == &maPushButtonMoreOptions)
     182             :     {
     183           0 :         if(mrCellAppearancePropertyPanel.GetBindings())
     184             :         {
     185           0 :             mrCellAppearancePropertyPanel.GetBindings()->GetDispatcher()->Execute(SID_CELL_FORMAT_BORDER, SfxCallMode::ASYNCHRON);
     186             :         }
     187             : 
     188           0 :         mrCellAppearancePropertyPanel.EndCellLineStylePopupMode();
     189             :     }
     190             : 
     191           0 :     return 0;
     192             : }
     193             : 
     194           0 : void CellLineStyleControl::SetLineStyleSelect(sal_uInt16 out, sal_uInt16 in, sal_uInt16 dis)
     195             : {
     196           0 :     SetAllNoSel();
     197           0 :     mbVSfocus = true;
     198             : 
     199             :     //FIXME: fully for new border line possibilities
     200             : 
     201           0 :     if(out == DEF_LINE_WIDTH_0 && in == 0 && dis == 0)  //1
     202             :     {
     203           0 :         maCellLineStyleValueSet.SetSelItem(1);
     204             :     }
     205           0 :     else if(out == DEF_LINE_WIDTH_2 && in == 0 && dis == 0) //2
     206             :     {
     207           0 :         maCellLineStyleValueSet.SetSelItem(2);
     208             :     }
     209           0 :     else if(out == DEF_LINE_WIDTH_3 && in == 0 && dis == 0) //3
     210             :     {
     211           0 :         maCellLineStyleValueSet.SetSelItem(3);
     212             :     }
     213           0 :     else if(out == DEF_LINE_WIDTH_4 && in == 0 && dis == 0) //4
     214             :     {
     215           0 :         maCellLineStyleValueSet.SetSelItem(4);
     216             :     }
     217           0 :     else if(out == DEF_LINE_WIDTH_0 && in == DEF_LINE_WIDTH_0 && dis == DEF_LINE_WIDTH_1) //5
     218             :     {
     219           0 :         maCellLineStyleValueSet.SetSelItem(5);
     220             :     }
     221           0 :     else if(out == DEF_LINE_WIDTH_0 && in == DEF_LINE_WIDTH_0 && dis == DEF_LINE_WIDTH_2) //6
     222             :     {
     223           0 :         maCellLineStyleValueSet.SetSelItem(6);
     224             :     }
     225           0 :     else if(out == DEF_LINE_WIDTH_1 && in == DEF_LINE_WIDTH_2 && dis == DEF_LINE_WIDTH_1) //7
     226             :     {
     227           0 :         maCellLineStyleValueSet.SetSelItem(7);
     228             :     }
     229           0 :     else if(out == DEF_LINE_WIDTH_2 && in == DEF_LINE_WIDTH_0 && dis == DEF_LINE_WIDTH_2) //8
     230             :     {
     231           0 :         maCellLineStyleValueSet.SetSelItem(8);
     232             :     }
     233           0 :     else if(out == DEF_LINE_WIDTH_2 && in == DEF_LINE_WIDTH_2 && dis == DEF_LINE_WIDTH_2) //9
     234             :     {
     235           0 :         maCellLineStyleValueSet.SetSelItem(9);
     236             :     }
     237             :     else
     238             :     {
     239           0 :         maCellLineStyleValueSet.SetSelItem(0);
     240           0 :         mbVSfocus = false;
     241             :     }
     242             : 
     243           0 :     maCellLineStyleValueSet.Format();
     244           0 :     maCellLineStyleValueSet.StartSelection();
     245           0 : }
     246             : 
     247         228 : } } // end of namespace svx::sidebar
     248             : 
     249             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10