LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/sidebar - CellAppearancePropertyPanel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 360 0.3 %
Date: 2013-07-09 Functions: 2 32 6.2 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10