LCOV - code coverage report
Current view: top level - sc/source/ui/sidebar - CellAppearancePropertyPanel.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 360 0.3 %
Date: 2014-04-11 Functions: 2 32 6.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 <sfx2/sidebar/ResourceDefinitions.hrc>
      21             : #include <sfx2/sidebar/Theme.hxx>
      22             : #include <sfx2/sidebar/ControlFactory.hxx>
      23             : #include <CellAppearancePropertyPanel.hxx>
      24             : #include <CellAppearancePropertyPanel.hrc>
      25             : #include "sc.hrc"
      26             : #include "scresid.hxx"
      27             : #include <sfx2/bindings.hxx>
      28             : #include <sfx2/dispatch.hxx>
      29             : #include <vcl/fixed.hxx>
      30             : #include <svx/tbxcolorupdate.hxx>
      31             : #include <svl/eitem.hxx>
      32             : #include <editeng/borderline.hxx>
      33             : #include <editeng/boxitem.hxx>
      34             : #include <editeng/colritem.hxx>
      35             : #include <editeng/lineitem.hxx>
      36             : #include <vcl/svapp.hxx>
      37             : #include <vcl/settings.hxx>
      38             : #include <svx/sidebar/ColorControl.hxx>
      39             : #include <boost/bind.hpp>
      40             : #include <svx/sidebar/PopupContainer.hxx>
      41             : #include <CellLineStyleControl.hxx>
      42             : #include <CellLineStylePopup.hxx>
      43             : #include <CellBorderUpdater.hxx>
      44             : #include <CellBorderStyleControl.hxx>
      45             : #include <CellBorderStylePopup.hxx>
      46             : 
      47             : using namespace css;
      48             : using namespace cssu;
      49             : 
      50             : const char UNO_BACKGROUNDCOLOR[] = ".uno:BackgroundColor";
      51             : const char UNO_SETBORDERSTYLE[] = ".uno:SetBorderStyle";
      52             : const char UNO_LINESTYLE[] = ".uno:LineStyle";
      53             : const char UNO_FRAMELINECOLOR[] = ".uno:FrameLineColor";
      54             : 
      55             : 
      56             : // helpers
      57             : 
      58             : namespace
      59             : {
      60           0 :     Color GetTransparentColor(void)
      61             :     {
      62           0 :         return COL_TRANSPARENT;
      63             :     }
      64             : } // end of anonymous namespace
      65             : 
      66             : 
      67             : // namespace open
      68             : 
      69             : namespace sc { namespace sidebar {
      70             : 
      71           0 : svx::sidebar::PopupControl* CellAppearancePropertyPanel::CreateFillColorPopupControl(svx::sidebar::PopupContainer* pParent)
      72             : {
      73           0 :     const ScResId aResId(VS_NOFILLCOLOR);
      74             : 
      75             :     return new svx::sidebar::ColorControl(
      76             :         pParent,
      77             :         mpBindings,
      78             :         ScResId(RID_POPUPPANEL_CELLAPPEARANCE_FILLCOLOR),
      79             :         ScResId(VS_FILLCOLOR),
      80             :         ::boost::bind(GetTransparentColor),
      81             :         ::boost::bind(&CellAppearancePropertyPanel::SetFillColor, this, _1, _2),
      82             :         pParent,
      83           0 :         &aResId);
      84             : }
      85             : 
      86           0 : void CellAppearancePropertyPanel::SetFillColor(
      87             :     const OUString& /*rsColorName*/,
      88             :     const Color aColor)
      89             : {
      90           0 :     const SvxColorItem aColorItem(aColor, SID_BACKGROUND_COLOR);
      91           0 :     mpBindings->GetDispatcher()->Execute(SID_BACKGROUND_COLOR, SFX_CALLMODE_RECORD, &aColorItem, 0L);
      92           0 :     maBackColor = aColor;
      93           0 : }
      94             : 
      95           0 : svx::sidebar::PopupControl* CellAppearancePropertyPanel::CreateLineColorPopupControl(svx::sidebar::PopupContainer* pParent)
      96             : {
      97             :     return new svx::sidebar::ColorControl(
      98             :         pParent,
      99             :         mpBindings,
     100             :         ScResId(RID_POPUPPANEL_CELLAPPEARANCE_LINECOLOR),
     101             :         ScResId(VS_LINECOLOR),
     102             :         ::boost::bind(GetTransparentColor),
     103             :         ::boost::bind(&CellAppearancePropertyPanel::SetLineColor, this, _1, _2),
     104             :         pParent,
     105           0 :         0);
     106             : }
     107             : 
     108           0 : void CellAppearancePropertyPanel::SetLineColor(
     109             :     const OUString& /*rsColorName*/,
     110             :     const Color aColor)
     111             : {
     112           0 :     const SvxColorItem aColorItem(aColor, SID_FRAME_LINECOLOR);
     113           0 :     mpBindings->GetDispatcher()->Execute(SID_FRAME_LINECOLOR, SFX_CALLMODE_RECORD, &aColorItem, 0L);
     114           0 :     maLineColor = aColor;
     115           0 : }
     116             : 
     117           0 : svx::sidebar::PopupControl* CellAppearancePropertyPanel::CreateCellLineStylePopupControl(svx::sidebar::PopupContainer* pParent)
     118             : {
     119           0 :     return new CellLineStyleControl(pParent, *this);
     120             : }
     121             : 
     122           0 : void CellAppearancePropertyPanel::EndCellLineStylePopupMode(void)
     123             : {
     124           0 :     if(mpCellLineStylePopup.get())
     125             :     {
     126           0 :         mpCellLineStylePopup->Hide();
     127             :     }
     128           0 : }
     129             : 
     130           0 : svx::sidebar::PopupControl* CellAppearancePropertyPanel::CreateCellBorderStylePopupControl(svx::sidebar::PopupContainer* pParent)
     131             : {
     132           0 :     return new CellBorderStyleControl(pParent, *this);
     133             : }
     134             : 
     135           0 : void CellAppearancePropertyPanel::EndCellBorderStylePopupMode(void)
     136             : {
     137           0 :     if(mpCellBorderStylePopup.get())
     138             :     {
     139           0 :         mpCellBorderStylePopup->Hide();
     140             :     }
     141           0 : }
     142             : 
     143           0 : CellAppearancePropertyPanel::CellAppearancePropertyPanel(
     144             :     Window* pParent,
     145             :     const cssu::Reference<css::frame::XFrame>& rxFrame,
     146             :     SfxBindings* pBindings)
     147             : :   PanelLayout(pParent, "CellAppearancePropertyPanel", "modules/scalc/ui/sidebarcellappearance.ui", rxFrame),
     148             : 
     149             :     maBackColorControl(SID_BACKGROUND_COLOR, *pBindings, *this),
     150             :     maLineColorControl(SID_FRAME_LINECOLOR, *pBindings, *this),
     151             :     maLineStyleControl(SID_FRAME_LINESTYLE, *pBindings, *this),
     152             :     maBorderOuterControl(SID_ATTR_BORDER_OUTER, *pBindings, *this),
     153             :     maBorderInnerControl(SID_ATTR_BORDER_INNER, *pBindings, *this),
     154             :     maGridShowControl(FID_TAB_TOGGLE_GRID, *pBindings, *this),
     155             :     maBorderTLBRControl(SID_ATTR_BORDER_DIAG_TLBR, *pBindings, *this),
     156             :     maBorderBLTRControl(SID_ATTR_BORDER_DIAG_BLTR, *pBindings, *this),
     157             : 
     158             :     maIMGCellBorder(ScResId(IMG_CELL_BORDER)),
     159             :     maIMGLineStyle1(ScResId(IMG_LINE_STYLE1)),
     160             :     maIMGLineStyle2(ScResId(IMG_LINE_STYLE2)),
     161             :     maIMGLineStyle3(ScResId(IMG_LINE_STYLE3)),
     162             :     maIMGLineStyle4(ScResId(IMG_LINE_STYLE4)),
     163             :     maIMGLineStyle5(ScResId(IMG_LINE_STYLE5)),
     164             :     maIMGLineStyle6(ScResId(IMG_LINE_STYLE6)),
     165             :     maIMGLineStyle7(ScResId(IMG_LINE_STYLE7)),
     166             :     maIMGLineStyle8(ScResId(IMG_LINE_STYLE8)),
     167             :     maIMGLineStyle9(ScResId(IMG_LINE_STYLE9)),
     168             : 
     169             :     maBackColor(COL_TRANSPARENT),
     170             :     maLineColor(COL_BLACK),
     171             :     maTLBRColor(COL_BLACK),
     172             :     maBLTRColor(COL_BLACK),
     173             :     mnIn(0),
     174             :     mnOut(0),
     175             :     mnDis(0),
     176             :     mnTLBRIn(0),
     177             :     mnTLBROut(0),
     178             :     mnTLBRDis(0),
     179             :     mnBLTRIn(0),
     180             :     mnBLTROut(0),
     181             :     mnBLTRDis(0),
     182             :     mbBackColorAvailable(true),
     183             :     mbLineColorAvailable(true),
     184             :     mbBorderStyleAvailable(true),
     185             :     mbLeft(false),
     186             :     mbRight(false),
     187             :     mbTop(false),
     188             :     mbBottom(false),
     189             :     mbVer(false),
     190             :     mbHor(false),
     191             :     mbOuterBorder(false),
     192             :     mbInnerBorder(false),
     193             :     mbTLBR(false),
     194             :     mbBLTR(false),
     195             : 
     196             :     maFillColorPopup(this, ::boost::bind(&CellAppearancePropertyPanel::CreateFillColorPopupControl, this, _1)),
     197             :     maLineColorPopup(this, ::boost::bind(&CellAppearancePropertyPanel::CreateLineColorPopupControl, this, _1)),
     198             :     mpCellLineStylePopup(),
     199             :     mpCellBorderStylePopup(),
     200             : 
     201             :     mxFrame(rxFrame),
     202             :     maContext(),
     203           0 :     mpBindings(pBindings)
     204             : {
     205           0 :     get(mpTBFillColor,  "cellbackgroundcolor");
     206           0 :     get(mpTBCellBorder, "cellbordertype");
     207           0 :     get(mpTBLineStyle,  "borderlinestyle");
     208           0 :     get(mpTBLineColor,  "borderlinecolor");
     209           0 :     get(mpCBXShowGrid,  "cellgridlines");
     210             : 
     211             :     mpFillColorUpdater.reset( new ::svx::ToolboxButtonColorUpdater(SID_ATTR_BRUSH,
     212           0 :         mpTBFillColor->GetItemId( UNO_BACKGROUNDCOLOR ),
     213           0 :         mpTBFillColor) );
     214             :     mpLineColorUpdater.reset( new ::svx::ToolboxButtonColorUpdater(SID_FRAME_LINECOLOR,
     215           0 :         mpTBLineColor->GetItemId( UNO_FRAMELINECOLOR ),
     216           0 :         mpTBLineColor) );
     217             :     mpCellBorderUpdater.reset( new CellBorderUpdater(
     218           0 :         mpTBCellBorder->GetItemId( UNO_SETBORDERSTYLE ), *mpTBCellBorder) );
     219             : 
     220           0 :     Initialize();
     221           0 : }
     222             : 
     223           0 : CellAppearancePropertyPanel::~CellAppearancePropertyPanel()
     224             : {
     225           0 : }
     226             : 
     227           0 : void CellAppearancePropertyPanel::Initialize()
     228             : {
     229           0 :     const sal_uInt16 nIdBkColor = mpTBFillColor->GetItemId( UNO_BACKGROUNDCOLOR );
     230           0 :     mpTBFillColor->SetItemBits( nIdBkColor, mpTBFillColor->GetItemBits( nIdBkColor ) | TIB_DROPDOWNONLY );
     231           0 :     Link aLink = LINK(this, CellAppearancePropertyPanel, TbxBKColorSelectHdl);
     232           0 :     mpTBFillColor->SetDropdownClickHdl ( aLink );
     233           0 :     mpTBFillColor->SetSelectHdl ( aLink );
     234             : 
     235           0 :     const sal_uInt16 nIdBorderType  = mpTBCellBorder->GetItemId( UNO_SETBORDERSTYLE );
     236           0 :     mpTBCellBorder->SetItemImage( nIdBorderType, maIMGCellBorder );
     237           0 :     mpTBCellBorder->SetItemBits( nIdBorderType, mpTBCellBorder->GetItemBits( nIdBorderType ) | TIB_DROPDOWNONLY );
     238           0 :     aLink = LINK(this, CellAppearancePropertyPanel, TbxCellBorderSelectHdl);
     239           0 :     mpTBCellBorder->SetDropdownClickHdl ( aLink );
     240           0 :     mpTBCellBorder->SetSelectHdl ( aLink );
     241             : 
     242           0 :     const sal_uInt16 nIdBorderLineStyle = mpTBLineStyle->GetItemId( UNO_LINESTYLE );
     243           0 :     mpTBLineStyle->SetItemImage( nIdBorderLineStyle, maIMGLineStyle1 );
     244           0 :     mpTBLineStyle->SetItemBits( nIdBorderLineStyle, mpTBLineStyle->GetItemBits( nIdBorderLineStyle ) | TIB_DROPDOWNONLY );
     245           0 :     aLink = LINK(this, CellAppearancePropertyPanel, TbxLineStyleSelectHdl);
     246           0 :     mpTBLineStyle->SetDropdownClickHdl ( aLink );
     247           0 :     mpTBLineStyle->SetSelectHdl ( aLink );
     248           0 :     mpTBLineStyle->Disable();
     249             : 
     250           0 :     const sal_uInt16 nIdBorderLinecolor = mpTBLineColor->GetItemId( UNO_FRAMELINECOLOR );
     251           0 :     mpTBLineColor->SetItemBits( nIdBorderLinecolor, mpTBLineColor->GetItemBits( nIdBorderLinecolor ) | TIB_DROPDOWNONLY );
     252           0 :     aLink = LINK(this, CellAppearancePropertyPanel, TbxLineColorSelectHdl);
     253           0 :     mpTBLineColor->SetDropdownClickHdl ( aLink );
     254           0 :     mpTBLineColor->SetSelectHdl ( aLink );
     255           0 :     mpTBLineColor->Disable();
     256             : 
     257           0 :     aLink = LINK(this, CellAppearancePropertyPanel, CBOXGridShowClkHdl);
     258           0 :     mpCBXShowGrid->SetClickHdl ( aLink );
     259             : 
     260           0 :     mpTBLineColor->SetAccessibleRelationLabeledBy(mpTBLineColor);
     261           0 :     mpTBLineStyle->SetAccessibleRelationLabeledBy(mpTBLineStyle);
     262           0 : }
     263             : 
     264           0 : IMPL_LINK(CellAppearancePropertyPanel, TbxBKColorSelectHdl, ToolBox*, pToolBox)
     265             : {
     266           0 :     const OUString aCommand(pToolBox->GetItemCommand(pToolBox->GetCurItemId()));
     267             : 
     268           0 :     if(aCommand == UNO_BACKGROUNDCOLOR)
     269             :     {
     270           0 :         maFillColorPopup.Show(*pToolBox);
     271           0 :         maFillColorPopup.SetCurrentColor(maBackColor, mbBackColorAvailable);
     272             :     }
     273           0 :     return 0;
     274             : }
     275             : 
     276           0 : IMPL_LINK(CellAppearancePropertyPanel, TbxLineColorSelectHdl, ToolBox*, pToolBox)
     277             : {
     278           0 :     const OUString aCommand(pToolBox->GetItemCommand(pToolBox->GetCurItemId()));
     279             : 
     280           0 :     if(aCommand == UNO_FRAMELINECOLOR)
     281             :     {
     282           0 :         maLineColorPopup.Show(*pToolBox);
     283           0 :         maLineColorPopup.SetCurrentColor(maLineColor, mbLineColorAvailable);
     284             :     }
     285           0 :     return 0;
     286             : }
     287             : 
     288           0 : IMPL_LINK(CellAppearancePropertyPanel, TbxCellBorderSelectHdl, ToolBox*, pToolBox)
     289             : {
     290           0 :     const OUString aCommand(pToolBox->GetItemCommand(pToolBox->GetCurItemId()));
     291             : 
     292           0 :     if(aCommand == UNO_SETBORDERSTYLE)
     293             :     {
     294             :         // create popup on demand
     295           0 :         if(!mpCellBorderStylePopup.get())
     296             :         {
     297             :             mpCellBorderStylePopup.reset(
     298             :                 new CellBorderStylePopup(
     299             :                     this,
     300           0 :                     ::boost::bind(&CellAppearancePropertyPanel::CreateCellBorderStylePopupControl, this, _1)));
     301             :         }
     302             : 
     303           0 :         if(mpCellBorderStylePopup.get())
     304             :         {
     305           0 :             mpCellBorderStylePopup->Show(*pToolBox);
     306             :         }
     307             :     }
     308           0 :     return 0;
     309             : }
     310             : 
     311           0 : IMPL_LINK(CellAppearancePropertyPanel, TbxLineStyleSelectHdl, ToolBox*, pToolBox)
     312             : {
     313           0 :     const OUString aCommand(pToolBox->GetItemCommand(pToolBox->GetCurItemId()));
     314             : 
     315           0 :     if(aCommand == UNO_LINESTYLE)
     316             :     {
     317             :         // create popup on demand
     318           0 :         if(!mpCellLineStylePopup.get())
     319             :         {
     320             :             mpCellLineStylePopup.reset(
     321             :                 new CellLineStylePopup(
     322             :                     this,
     323           0 :                     ::boost::bind(&CellAppearancePropertyPanel::CreateCellLineStylePopupControl, this, _1)));
     324             :         }
     325             : 
     326           0 :         if(mpCellLineStylePopup.get())
     327             :         {
     328           0 :             mpCellLineStylePopup->SetLineStyleSelect(mnOut, mnIn, mnDis);
     329           0 :             mpCellLineStylePopup->Show(*pToolBox);
     330             :         }
     331             :     }
     332           0 :     return 0;
     333             : }
     334             : 
     335           0 : IMPL_LINK(CellAppearancePropertyPanel, CBOXGridShowClkHdl, void*, EMPTYARG)
     336             : {
     337           0 :     bool bState = mpCBXShowGrid->IsChecked();
     338           0 :     SfxBoolItem aItem( FID_TAB_TOGGLE_GRID , bState);
     339           0 :     GetBindings()->GetDispatcher()->Execute(FID_TAB_TOGGLE_GRID, SFX_CALLMODE_RECORD, &aItem, 0L);
     340           0 :     return 0;
     341             : }
     342             : 
     343           0 : CellAppearancePropertyPanel* CellAppearancePropertyPanel::Create (
     344             :     Window* pParent,
     345             :     const cssu::Reference<css::frame::XFrame>& rxFrame,
     346             :     SfxBindings* pBindings)
     347             : {
     348           0 :     if (pParent == NULL)
     349           0 :         throw lang::IllegalArgumentException("no parent Window given to CellAppearancePropertyPanel::Create", NULL, 0);
     350           0 :     if ( ! rxFrame.is())
     351           0 :         throw lang::IllegalArgumentException("no XFrame given to CellAppearancePropertyPanel::Create", NULL, 1);
     352           0 :     if (pBindings == NULL)
     353           0 :         throw lang::IllegalArgumentException("no SfxBindings given to CellAppearancePropertyPanel::Create", NULL, 2);
     354             : 
     355             :     return new CellAppearancePropertyPanel(
     356             :         pParent,
     357             :         rxFrame,
     358           0 :         pBindings);
     359             : }
     360             : 
     361           0 : void CellAppearancePropertyPanel::DataChanged(
     362             :     const DataChangedEvent& rEvent)
     363             : {
     364             :     (void)rEvent;
     365           0 : }
     366             : 
     367           0 : void CellAppearancePropertyPanel::HandleContextChange(
     368             :     const ::sfx2::sidebar::EnumContext aContext)
     369             : {
     370           0 :     if(maContext == aContext)
     371             :     {
     372             :         // Nothing to do.
     373           0 :         return;
     374             :     }
     375             : 
     376           0 :     maContext = aContext;
     377             : 
     378             :     // todo
     379             : }
     380             : 
     381           0 : void CellAppearancePropertyPanel::NotifyItemUpdate(
     382             :     sal_uInt16 nSID,
     383             :     SfxItemState eState,
     384             :     const SfxPoolItem* pState,
     385             :     const bool bIsEnabled)
     386             : {
     387             :     (void)bIsEnabled;
     388             : 
     389           0 :     switch(nSID)
     390             :     {
     391             :     case SID_BACKGROUND_COLOR:
     392           0 :         if(eState >= SFX_ITEM_DEFAULT)
     393             :         {
     394           0 :             const SvxColorItem* pSvxColorItem = dynamic_cast< const SvxColorItem* >(pState);
     395             : 
     396           0 :             if(pSvxColorItem)
     397             :             {
     398           0 :                 maBackColor = ((const SvxColorItem*)pState)->GetValue();
     399           0 :                 mbBackColorAvailable = true;
     400           0 :                 mpFillColorUpdater->Update(maBackColor);
     401           0 :                 break;
     402             :             }
     403             :         }
     404             : 
     405           0 :         mbBackColorAvailable = false;
     406           0 :         maBackColor.SetColor(COL_TRANSPARENT);
     407           0 :         mpFillColorUpdater->Update(COL_TRANSPARENT);
     408           0 :         break;
     409             :     case SID_FRAME_LINECOLOR:
     410           0 :         if( eState == SFX_ITEM_DONTCARE)
     411             :         {
     412           0 :             mbLineColorAvailable = true;
     413           0 :             maLineColor.SetColor( COL_TRANSPARENT );
     414           0 :             UpdateControlState();
     415           0 :             break;
     416             :         }
     417             : 
     418           0 :         if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SvxColorItem) )
     419             :         {
     420           0 :             const SvxColorItem* pSvxColorItem = dynamic_cast< const SvxColorItem* >(pState);
     421             : 
     422           0 :             if(pSvxColorItem)
     423             :             {
     424           0 :                 maLineColor = ((const SvxColorItem*)pState)->GetValue();
     425           0 :                 if(maLineColor == COL_AUTO)
     426           0 :                     mbLineColorAvailable = false;
     427             :                 else
     428             :                 {
     429           0 :                     mbLineColorAvailable = true;
     430             :                 //  mpLineColorUpdater->Update(maLineColor);
     431             :                 }
     432             : 
     433           0 :                 UpdateControlState();
     434           0 :                 break;
     435             :             }
     436             :         }
     437             : 
     438           0 :         mbLineColorAvailable = false;
     439           0 :         maLineColor.SetColor(COL_AUTO);
     440             :         //  mpLineColorUpdater->Update(maLineColor);
     441           0 :         UpdateControlState();
     442           0 :         break;
     443             :     case SID_FRAME_LINESTYLE:
     444           0 :         if( eState == SFX_ITEM_DONTCARE )
     445             :         {
     446           0 :             mbBorderStyleAvailable = true;
     447           0 :             mnIn = 0;
     448           0 :             mnOut = 0;
     449           0 :             mnDis = 0;
     450           0 :             SetStyleIcon();
     451           0 :             break;
     452             :         }
     453             : 
     454           0 :         if(eState >= SFX_ITEM_DEFAULT)
     455             :         {
     456           0 :             const SvxLineItem* pSvxLineItem = dynamic_cast< const SvxLineItem* >(pState);
     457             : 
     458           0 :             if(pSvxLineItem)
     459             :             {
     460           0 :                 const editeng::SvxBorderLine* mbLineItem = pSvxLineItem->GetLine();
     461           0 :                 mnIn = mbLineItem->GetInWidth();
     462           0 :                 mnOut = mbLineItem->GetOutWidth();
     463           0 :                 mnDis = mbLineItem->GetDistance();
     464             : 
     465           0 :                 if(mnIn == 0 && mnOut == 0 && mnDis == 0)
     466           0 :                     mbBorderStyleAvailable = false;
     467             :                 else
     468           0 :                     mbBorderStyleAvailable = true;
     469             : 
     470           0 :                 SetStyleIcon();
     471           0 :                 break;
     472             :             }
     473             :         }
     474             : 
     475           0 :         mbBorderStyleAvailable = false;
     476           0 :         SetStyleIcon();
     477           0 :         break;
     478             :     case SID_ATTR_BORDER_OUTER:
     479           0 :         if(eState >= SFX_ITEM_DEFAULT)
     480             :         {
     481           0 :             const SvxBoxItem* pBoxItem = dynamic_cast< const SvxBoxItem* >(pState);
     482             : 
     483           0 :             if(pBoxItem)
     484             :             {
     485           0 :                 mbLeft=false, mbRight=false, mbTop=false, mbBottom=false;
     486             : 
     487           0 :                 if(pBoxItem->GetLeft())
     488           0 :                     mbLeft = true;
     489             : 
     490           0 :                 if(pBoxItem->GetRight())
     491           0 :                     mbRight = true;
     492             : 
     493           0 :                 if(pBoxItem->GetTop())
     494           0 :                     mbTop = true;
     495             : 
     496           0 :                 if(pBoxItem->GetBottom())
     497           0 :                     mbBottom = true;
     498             : 
     499           0 :                 if(!Application::GetSettings().GetLayoutRTL())
     500           0 :                     mpCellBorderUpdater->UpdateCellBorder(mbTop, mbBottom, mbLeft, mbRight, maIMGCellBorder, mbVer, mbHor);
     501             :                 else
     502           0 :                     mpCellBorderUpdater->UpdateCellBorder(mbTop, mbBottom, mbRight, mbLeft, maIMGCellBorder, mbVer, mbHor);
     503             : 
     504           0 :                 if(mbLeft || mbRight || mbTop || mbBottom)
     505           0 :                     mbOuterBorder = true;
     506             :                 else
     507           0 :                     mbOuterBorder = false;
     508             : 
     509           0 :                 UpdateControlState();
     510             :             }
     511             :         }
     512           0 :         break;
     513             :     case SID_ATTR_BORDER_INNER:
     514           0 :         if(eState >= SFX_ITEM_DEFAULT)
     515             :         {
     516           0 :             const SvxBoxInfoItem* pBoxInfoItem = dynamic_cast< const SvxBoxInfoItem* >(pState);
     517             : 
     518           0 :             if(pBoxInfoItem)
     519             :             {
     520           0 :                 bool bLeft(false), bRight(false), bTop(false), bBottom(false);
     521             : 
     522           0 :                 mbVer = false, mbHor = false;
     523             : 
     524           0 :                 if(!pBoxInfoItem->IsValid( VALID_VERT )  || pBoxInfoItem->GetVert())
     525           0 :                     mbVer = true;
     526             : 
     527           0 :                 if(!pBoxInfoItem->IsValid( VALID_HORI )  || pBoxInfoItem->GetHori())
     528           0 :                     mbHor = true;
     529             : 
     530           0 :                 if(!pBoxInfoItem->IsValid( VALID_LEFT ) || mbLeft)
     531           0 :                     bLeft = true;
     532             : 
     533           0 :                 if(!pBoxInfoItem->IsValid( VALID_RIGHT ) || mbRight)
     534           0 :                     bRight = true;
     535             : 
     536           0 :                 if(!pBoxInfoItem->IsValid( VALID_TOP ) || mbTop)
     537           0 :                     bTop = true;
     538             : 
     539           0 :                 if(!pBoxInfoItem->IsValid( VALID_BOTTOM ) || mbBottom)
     540           0 :                     bBottom = true;
     541             : 
     542           0 :                 if(!Application::GetSettings().GetLayoutRTL())
     543           0 :                     mpCellBorderUpdater->UpdateCellBorder(bTop, bBottom, bLeft, bRight, maIMGCellBorder, mbVer, mbHor);
     544             :                 else
     545           0 :                     mpCellBorderUpdater->UpdateCellBorder(bTop, bBottom, bRight, bLeft, maIMGCellBorder, mbVer, mbHor);
     546             : 
     547           0 :                 if(mbVer || mbHor || bLeft || bRight || bTop || bBottom)
     548           0 :                     mbInnerBorder = true;
     549             :                 else
     550           0 :                     mbInnerBorder = false;
     551             : 
     552           0 :                 UpdateControlState();
     553             :             }
     554             :         }
     555           0 :         break;
     556             :     case SID_ATTR_BORDER_DIAG_TLBR:
     557           0 :         if( eState == SFX_ITEM_DONTCARE )
     558             :         {
     559           0 :             mbTLBR = true;
     560           0 :             maTLBRColor.SetColor(COL_TRANSPARENT);
     561           0 :             mnTLBRIn = mnTLBROut = mnTLBRDis = 0;
     562           0 :             UpdateControlState();
     563           0 :             break;
     564             :         }
     565             : 
     566           0 :         if(eState >= SFX_ITEM_DEFAULT)
     567             :         {
     568           0 :             const SvxLineItem* pItem = dynamic_cast< const SvxLineItem* >(pState);
     569             : 
     570           0 :             if(pItem)
     571             :             {
     572           0 :                 const editeng::SvxBorderLine* aLine = pItem->GetLine();
     573             : 
     574           0 :                 if(!aLine)
     575             :                 {
     576           0 :                     mbTLBR = false;
     577             :                 }
     578             :                 else
     579             :                 {
     580           0 :                     mbTLBR = true;
     581           0 :                     maTLBRColor = aLine->GetColor();
     582           0 :                     mnTLBRIn = aLine->GetInWidth();
     583           0 :                     mnTLBROut = aLine->GetOutWidth();
     584           0 :                     mnTLBRDis = aLine->GetDistance();
     585             : 
     586           0 :                     if(mnTLBRIn == 0 && mnTLBROut == 0 && mnTLBRDis == 0)
     587           0 :                         mbTLBR = false;
     588             :                 }
     589             : 
     590           0 :                 UpdateControlState();
     591           0 :                 break;
     592             :             }
     593             :         }
     594             : 
     595           0 :         mbTLBR = false;
     596           0 :         UpdateControlState();
     597           0 :         break;
     598             :     case SID_ATTR_BORDER_DIAG_BLTR:
     599           0 :         if( eState == SFX_ITEM_DONTCARE )
     600             :         {
     601           0 :             mbBLTR = true;
     602           0 :             maBLTRColor.SetColor( COL_TRANSPARENT );
     603           0 :             mnBLTRIn = mnBLTROut = mnBLTRDis = 0;
     604           0 :             UpdateControlState();
     605           0 :             break;
     606             :         }
     607             : 
     608           0 :         if(eState >= SFX_ITEM_DEFAULT)
     609             :         {
     610           0 :             const SvxLineItem* pItem = dynamic_cast< const SvxLineItem* >(pState);
     611             : 
     612           0 :             if(pItem)
     613             :             {
     614           0 :                 const editeng::SvxBorderLine* aLine = pItem->GetLine();
     615             : 
     616           0 :                 if(!aLine)
     617             :                 {
     618           0 :                     mbBLTR = false;
     619             :                 }
     620             :                 else
     621             :                 {
     622           0 :                     mbBLTR = true;
     623           0 :                     maBLTRColor = aLine->GetColor();
     624           0 :                     mnBLTRIn = aLine->GetInWidth();
     625           0 :                     mnBLTROut = aLine->GetOutWidth();
     626           0 :                     mnBLTRDis = aLine->GetDistance();
     627             : 
     628           0 :                     if(mnBLTRIn == 0 && mnBLTROut == 0 && mnBLTRDis == 0)
     629           0 :                         mbBLTR = false;
     630             :                 }
     631             : 
     632           0 :                 UpdateControlState();
     633             :             }
     634           0 :             break;
     635             :         }
     636             : 
     637           0 :         mbBLTR = false;
     638           0 :         UpdateControlState();
     639           0 :         break;
     640             :     case FID_TAB_TOGGLE_GRID:
     641           0 :         if(eState >= SFX_ITEM_DEFAULT)
     642             :         {
     643           0 :             const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
     644             : 
     645           0 :             if(pItem)
     646             :             {
     647           0 :                 const bool bVal = pItem->GetValue();
     648             : 
     649           0 :                 if(bVal)
     650           0 :                     mpCBXShowGrid->Check(true);
     651             :                 else
     652           0 :                     mpCBXShowGrid->Check(false);
     653             :             }
     654             :         }
     655           0 :         break;
     656             :     }
     657           0 : }
     658             : 
     659           0 : SfxBindings* CellAppearancePropertyPanel::GetBindings()
     660             : {
     661           0 :     return mpBindings;
     662             : }
     663             : 
     664           0 : void CellAppearancePropertyPanel::SetStyleIcon()
     665             : {
     666           0 :     const sal_uInt16 nIdBorderLineStyle = mpTBLineStyle->GetItemId( UNO_LINESTYLE );
     667             : 
     668             :     //FIXME: update for new line border possibilities
     669           0 :     if(mnOut == DEF_LINE_WIDTH_0 && mnIn == 0 && mnDis == 0)    //1
     670           0 :         mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle1);
     671           0 :     else if(mnOut == DEF_LINE_WIDTH_2 && mnIn == 0 && mnDis == 0) //2
     672           0 :         mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle2);
     673           0 :     else if(mnOut == DEF_LINE_WIDTH_3 && mnIn == 0 && mnDis == 0) //3
     674           0 :         mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle3);
     675           0 :     else if(mnOut == DEF_LINE_WIDTH_4 && mnIn == 0 && mnDis == 0) //4
     676           0 :         mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle4);
     677           0 :     else if(mnOut == DEF_LINE_WIDTH_0 && mnIn == DEF_LINE_WIDTH_0 && mnDis == DEF_LINE_WIDTH_1) //5
     678           0 :         mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle5);
     679           0 :     else if(mnOut == DEF_LINE_WIDTH_0 && mnIn == DEF_LINE_WIDTH_0 && mnDis == DEF_LINE_WIDTH_2) //6
     680           0 :         mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle6);
     681           0 :     else if(mnOut == DEF_LINE_WIDTH_1 && mnIn == DEF_LINE_WIDTH_2 && mnDis == DEF_LINE_WIDTH_1) //7
     682           0 :         mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle7);
     683           0 :     else if(mnOut == DEF_LINE_WIDTH_2 && mnIn == DEF_LINE_WIDTH_0 && mnDis == DEF_LINE_WIDTH_2) //8
     684           0 :         mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle8);
     685           0 :     else if(mnOut == DEF_LINE_WIDTH_2 && mnIn == DEF_LINE_WIDTH_2 && mnDis == DEF_LINE_WIDTH_2) //9
     686           0 :         mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle9);
     687             :     else
     688           0 :         mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle1);
     689           0 : }
     690             : 
     691           0 : void CellAppearancePropertyPanel::UpdateControlState()
     692             : {
     693           0 :     if(mbOuterBorder || mbInnerBorder || mbTLBR || mbBLTR)
     694             :     {
     695           0 :         mpTBLineColor->Enable();
     696           0 :         mpTBLineStyle->Enable();
     697             : 
     698             :         //set line color state
     699           0 :         if( mbLineColorAvailable && !mbTLBR && !mbBLTR )
     700           0 :             mpLineColorUpdater->Update(maLineColor);
     701           0 :         else if( !mbLineColorAvailable && mbTLBR && !mbBLTR )
     702           0 :             mpLineColorUpdater->Update(maTLBRColor);
     703           0 :         else if ( !mbLineColorAvailable && !mbTLBR && mbBLTR )
     704           0 :             mpLineColorUpdater->Update(maBLTRColor);
     705           0 :         else if( !mbLineColorAvailable && mbTLBR && mbBLTR)
     706             :         {
     707           0 :             if( maTLBRColor == maBLTRColor)
     708           0 :                 mpLineColorUpdater->Update(maBLTRColor);
     709             :             else
     710           0 :                 mpLineColorUpdater->Update(COL_TRANSPARENT);
     711             :         }
     712           0 :         else if( mbLineColorAvailable && mbTLBR && !mbBLTR )
     713             :         {
     714           0 :             if( maTLBRColor == maLineColor)
     715           0 :                 mpLineColorUpdater->Update(maLineColor);
     716             :             else
     717           0 :                 mpLineColorUpdater->Update(COL_TRANSPARENT);
     718             :         }
     719           0 :         else if( mbLineColorAvailable && !mbTLBR && mbBLTR )
     720             :         {
     721           0 :             if( maBLTRColor == maLineColor)
     722           0 :                 mpLineColorUpdater->Update(maLineColor);
     723             :             else
     724           0 :                 mpLineColorUpdater->Update(COL_TRANSPARENT);
     725             :         }
     726             :         else
     727           0 :             mpLineColorUpdater->Update(COL_TRANSPARENT);
     728             : 
     729             :         //set line style state
     730           0 :         if( mbBorderStyleAvailable && !mbTLBR && !mbBLTR )
     731             :         {
     732             :         }
     733           0 :         else if( !mbBorderStyleAvailable && mbTLBR && !mbBLTR )
     734             :         {
     735           0 :             mnIn = mnTLBRIn;
     736           0 :             mnOut = mnTLBROut;
     737           0 :             mnDis = mnTLBRDis;
     738             :         }
     739           0 :         else if ( !mbBorderStyleAvailable && !mbTLBR && mbBLTR )
     740             :         {
     741           0 :             mnIn = mnBLTRIn;
     742           0 :             mnOut = mnBLTROut;
     743           0 :             mnDis = mnBLTRDis;
     744             :         }
     745           0 :         else if( !mbBorderStyleAvailable && mbTLBR && mbBLTR)
     746             :         {
     747           0 :             if( mnTLBRIn == mnBLTRIn && mnTLBROut == mnBLTROut && mnTLBRDis == mnBLTRDis)
     748             :             {
     749           0 :                 mnIn = mnTLBRIn;
     750           0 :                 mnOut = mnTLBROut;
     751           0 :                 mnDis = mnTLBRDis;
     752             :             }
     753             :             else
     754             :             {
     755           0 :                 mnIn = 0;
     756           0 :                 mnOut = 0;
     757           0 :                 mnDis = 0;
     758             :             }
     759             :         }
     760           0 :         else if( mbBorderStyleAvailable && mbTLBR && !mbBLTR )
     761             :         {
     762           0 :             if( mnTLBRIn != mnIn || mnTLBROut != mnOut || mnTLBRDis != mnDis)
     763             :             {
     764           0 :                 mnIn = 0;
     765           0 :                 mnOut = 0;
     766           0 :                 mnDis = 0;
     767             :             }
     768             :         }
     769           0 :         else if( mbBorderStyleAvailable && !mbTLBR && mbBLTR )
     770             :         {
     771           0 :             if(  mnBLTRIn != mnIn || mnBLTROut != mnOut || mnBLTRDis != mnDis )
     772             :             {
     773           0 :                 mnIn = 0;
     774           0 :                 mnOut = 0;
     775           0 :                 mnDis = 0;
     776             :             }
     777             :         }
     778             :         else
     779             :         {
     780           0 :             mnIn = 0;
     781           0 :             mnOut = 0;
     782           0 :             mnDis = 0;
     783             :         }
     784           0 :         SetStyleIcon();
     785             :     }
     786             :     else
     787             :     {
     788           0 :         mpTBLineColor->Disable();
     789           0 :         mpTBLineStyle->Disable();
     790             :     }
     791           0 : }
     792             : 
     793             : 
     794             : // namespace close
     795             : 
     796         102 : }} // end of namespace ::sc::sidebar
     797             : 
     798             : 
     799             : // eof
     800             : 
     801             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10