Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / sidebar / CellAppearancePropertyPanel.cxx
blob34b823b48afa791c69064c639bac6a336b3d9d22
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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 <svx/sidebar/ColorControl.hxx>
38 #include <boost/bind.hpp>
39 #include <svx/sidebar/PopupContainer.hxx>
40 #include <CellLineStyleControl.hxx>
41 #include <CellLineStylePopup.hxx>
42 #include <CellBorderUpdater.hxx>
43 #include <CellBorderStyleControl.hxx>
44 #include <CellBorderStylePopup.hxx>
46 using namespace css;
47 using namespace cssu;
49 const char UNO_BACKGROUNDCOLOR[] = ".uno:BackgroundColor";
50 const char UNO_SETBORDERSTYLE[] = ".uno:SetBorderStyle";
51 const char UNO_LINESTYLE[] = ".uno:LineStyle";
52 const char UNO_FRAMELINECOLOR[] = ".uno:FrameLineColor";
54 //////////////////////////////////////////////////////////////////////////////
55 // helpers
57 namespace
59 Color GetTransparentColor(void)
61 return COL_TRANSPARENT;
63 } // end of anonymous namespace
65 //////////////////////////////////////////////////////////////////////////////
66 // namespace open
68 namespace sc { namespace sidebar {
70 //////////////////////////////////////////////////////////////////////////////
72 svx::sidebar::PopupControl* CellAppearancePropertyPanel::CreateFillColorPopupControl(svx::sidebar::PopupContainer* pParent)
74 const ScResId aResId(VS_NOFILLCOLOR);
76 return new svx::sidebar::ColorControl(
77 pParent,
78 mpBindings,
79 ScResId(RID_POPUPPANEL_CELLAPPEARANCE_FILLCOLOR),
80 ScResId(VS_FILLCOLOR),
81 ::boost::bind(GetTransparentColor),
82 ::boost::bind(&CellAppearancePropertyPanel::SetFillColor, this, _1, _2),
83 pParent,
84 &aResId);
87 void CellAppearancePropertyPanel::SetFillColor(
88 const OUString& /*rsColorName*/,
89 const Color aColor)
91 const SvxColorItem aColorItem(aColor, SID_BACKGROUND_COLOR);
92 mpBindings->GetDispatcher()->Execute(SID_BACKGROUND_COLOR, SFX_CALLMODE_RECORD, &aColorItem, 0L);
93 maBackColor = aColor;
96 //////////////////////////////////////////////////////////////////////////////
98 svx::sidebar::PopupControl* CellAppearancePropertyPanel::CreateLineColorPopupControl(svx::sidebar::PopupContainer* pParent)
100 return new svx::sidebar::ColorControl(
101 pParent,
102 mpBindings,
103 ScResId(RID_POPUPPANEL_CELLAPPEARANCE_LINECOLOR),
104 ScResId(VS_LINECOLOR),
105 ::boost::bind(GetTransparentColor),
106 ::boost::bind(&CellAppearancePropertyPanel::SetLineColor, this, _1, _2),
107 pParent,
111 void CellAppearancePropertyPanel::SetLineColor(
112 const OUString& /*rsColorName*/,
113 const Color aColor)
115 const SvxColorItem aColorItem(aColor, SID_FRAME_LINECOLOR);
116 mpBindings->GetDispatcher()->Execute(SID_FRAME_LINECOLOR, SFX_CALLMODE_RECORD, &aColorItem, 0L);
117 maLineColor = aColor;
120 //////////////////////////////////////////////////////////////////////////////
122 svx::sidebar::PopupControl* CellAppearancePropertyPanel::CreateCellLineStylePopupControl(svx::sidebar::PopupContainer* pParent)
124 return new CellLineStyleControl(pParent, *this);
127 void CellAppearancePropertyPanel::EndCellLineStylePopupMode(void)
129 if(mpCellLineStylePopup.get())
131 mpCellLineStylePopup->Hide();
135 //////////////////////////////////////////////////////////////////////////////
137 svx::sidebar::PopupControl* CellAppearancePropertyPanel::CreateCellBorderStylePopupControl(svx::sidebar::PopupContainer* pParent)
139 return new CellBorderStyleControl(pParent, *this);
142 void CellAppearancePropertyPanel::EndCellBorderStylePopupMode(void)
144 if(mpCellBorderStylePopup.get())
146 mpCellBorderStylePopup->Hide();
150 //////////////////////////////////////////////////////////////////////////////
152 CellAppearancePropertyPanel::CellAppearancePropertyPanel(
153 Window* pParent,
154 const cssu::Reference<css::frame::XFrame>& rxFrame,
155 SfxBindings* pBindings)
156 : PanelLayout(pParent, "CellAppearancePropertyPanel", "modules/scalc/ui/sidebarcellappearance.ui", rxFrame),
158 maBackColorControl(SID_BACKGROUND_COLOR, *pBindings, *this),
159 maLineColorControl(SID_FRAME_LINECOLOR, *pBindings, *this),
160 maLineStyleControl(SID_FRAME_LINESTYLE, *pBindings, *this),
161 maBorderOuterControl(SID_ATTR_BORDER_OUTER, *pBindings, *this),
162 maBorderInnerControl(SID_ATTR_BORDER_INNER, *pBindings, *this),
163 maGridShowControl(SID_SCGRIDSHOW, *pBindings, *this),
164 maBorderTLBRControl(SID_ATTR_BORDER_DIAG_TLBR, *pBindings, *this),
165 maBorderBLTRControl(SID_ATTR_BORDER_DIAG_BLTR, *pBindings, *this),
167 maIMGCellBorder(ScResId(IMG_CELL_BORDER)),
168 maIMGLineStyle1(ScResId(IMG_LINE_STYLE1)),
169 maIMGLineStyle2(ScResId(IMG_LINE_STYLE2)),
170 maIMGLineStyle3(ScResId(IMG_LINE_STYLE3)),
171 maIMGLineStyle4(ScResId(IMG_LINE_STYLE4)),
172 maIMGLineStyle5(ScResId(IMG_LINE_STYLE5)),
173 maIMGLineStyle6(ScResId(IMG_LINE_STYLE6)),
174 maIMGLineStyle7(ScResId(IMG_LINE_STYLE7)),
175 maIMGLineStyle8(ScResId(IMG_LINE_STYLE8)),
176 maIMGLineStyle9(ScResId(IMG_LINE_STYLE9)),
178 maBackColor(COL_TRANSPARENT),
179 maLineColor(COL_BLACK),
180 maTLBRColor(COL_BLACK),
181 maBLTRColor(COL_BLACK),
182 mnIn(0),
183 mnOut(0),
184 mnDis(0),
185 mnTLBRIn(0),
186 mnTLBROut(0),
187 mnTLBRDis(0),
188 mnBLTRIn(0),
189 mnBLTROut(0),
190 mnBLTRDis(0),
191 mbBackColorAvailable(true),
192 mbLineColorAvailable(true),
193 mbBorderStyleAvailable(true),
194 mbLeft(false),
195 mbRight(false),
196 mbTop(false),
197 mbBottom(false),
198 mbVer(false),
199 mbHor(false),
200 mbOuterBorder(false),
201 mbInnerBorder(false),
202 mbTLBR(false),
203 mbBLTR(false),
205 maFillColorPopup(this, ::boost::bind(&CellAppearancePropertyPanel::CreateFillColorPopupControl, this, _1)),
206 maLineColorPopup(this, ::boost::bind(&CellAppearancePropertyPanel::CreateLineColorPopupControl, this, _1)),
207 mpCellLineStylePopup(),
208 mpCellBorderStylePopup(),
210 mxFrame(rxFrame),
211 maContext(),
212 mpBindings(pBindings)
214 get(mpTBFillColor, "cellbackgroundcolor");
215 get(mpTBCellBorder, "cellbordertype");
216 get(mpTBLineStyle, "borderlinestyle");
217 get(mpTBLineColor, "borderlinecolor");
218 get(mpCBXShowGrid, "cellgridlines");
220 mpFillColorUpdater.reset( new ::svx::ToolboxButtonColorUpdater(SID_ATTR_BRUSH,
221 mpTBFillColor->GetItemId( UNO_BACKGROUNDCOLOR ),
222 mpTBFillColor) );
223 mpLineColorUpdater.reset( new ::svx::ToolboxButtonColorUpdater(SID_FRAME_LINECOLOR,
224 mpTBLineColor->GetItemId( UNO_FRAMELINECOLOR ),
225 mpTBLineColor) );
226 mpCellBorderUpdater.reset( new CellBorderUpdater(
227 mpTBCellBorder->GetItemId( UNO_SETBORDERSTYLE ), *mpTBCellBorder) );
229 Initialize();
232 //////////////////////////////////////////////////////////////////////////////
234 CellAppearancePropertyPanel::~CellAppearancePropertyPanel()
238 //////////////////////////////////////////////////////////////////////////////
240 void CellAppearancePropertyPanel::Initialize()
242 const sal_uInt16 nIdBkColor = mpTBFillColor->GetItemId( UNO_BACKGROUNDCOLOR );
243 mpTBFillColor->SetItemBits( nIdBkColor, mpTBFillColor->GetItemBits( nIdBkColor ) | TIB_DROPDOWNONLY );
244 Link aLink = LINK(this, CellAppearancePropertyPanel, TbxBKColorSelectHdl);
245 mpTBFillColor->SetDropdownClickHdl ( aLink );
246 mpTBFillColor->SetSelectHdl ( aLink );
248 const sal_uInt16 nIdBorderType = mpTBCellBorder->GetItemId( UNO_SETBORDERSTYLE );
249 mpTBCellBorder->SetItemImage( nIdBorderType, maIMGCellBorder );
250 mpTBCellBorder->SetItemBits( nIdBorderType, mpTBCellBorder->GetItemBits( nIdBorderType ) | TIB_DROPDOWNONLY );
251 aLink = LINK(this, CellAppearancePropertyPanel, TbxCellBorderSelectHdl);
252 mpTBCellBorder->SetDropdownClickHdl ( aLink );
253 mpTBCellBorder->SetSelectHdl ( aLink );
255 const sal_uInt16 nIdBorderLineStyle = mpTBLineStyle->GetItemId( UNO_LINESTYLE );
256 mpTBLineStyle->SetItemImage( nIdBorderLineStyle, maIMGLineStyle1 );
257 mpTBLineStyle->SetItemBits( nIdBorderLineStyle, mpTBLineStyle->GetItemBits( nIdBorderLineStyle ) | TIB_DROPDOWNONLY );
258 aLink = LINK(this, CellAppearancePropertyPanel, TbxLineStyleSelectHdl);
259 mpTBLineStyle->SetDropdownClickHdl ( aLink );
260 mpTBLineStyle->SetSelectHdl ( aLink );
261 mpTBLineStyle->Disable();
263 const sal_uInt16 nIdBorderLinecolor = mpTBLineColor->GetItemId( UNO_FRAMELINECOLOR );
264 mpTBLineColor->SetItemBits( nIdBorderLinecolor, mpTBLineColor->GetItemBits( nIdBorderLinecolor ) | TIB_DROPDOWNONLY );
265 aLink = LINK(this, CellAppearancePropertyPanel, TbxLineColorSelectHdl);
266 mpTBLineColor->SetDropdownClickHdl ( aLink );
267 mpTBLineColor->SetSelectHdl ( aLink );
268 mpTBLineColor->Disable();
270 aLink = LINK(this, CellAppearancePropertyPanel, CBOXGridShowClkHdl);
271 mpCBXShowGrid->SetClickHdl ( aLink );
273 mpTBLineColor->SetAccessibleRelationLabeledBy(mpTBLineColor);
274 mpTBLineStyle->SetAccessibleRelationLabeledBy(mpTBLineStyle);
277 //////////////////////////////////////////////////////////////////////////////
279 IMPL_LINK(CellAppearancePropertyPanel, TbxBKColorSelectHdl, ToolBox*, pToolBox)
281 const OUString aCommand(pToolBox->GetItemCommand(pToolBox->GetCurItemId()));
283 if(aCommand == UNO_BACKGROUNDCOLOR)
285 maFillColorPopup.Show(*pToolBox);
286 maFillColorPopup.SetCurrentColor(maBackColor, mbBackColorAvailable);
288 return 0;
291 //////////////////////////////////////////////////////////////////////////////
293 IMPL_LINK(CellAppearancePropertyPanel, TbxLineColorSelectHdl, ToolBox*, pToolBox)
295 const OUString aCommand(pToolBox->GetItemCommand(pToolBox->GetCurItemId()));
297 if(aCommand == UNO_FRAMELINECOLOR)
299 maLineColorPopup.Show(*pToolBox);
300 maLineColorPopup.SetCurrentColor(maLineColor, mbLineColorAvailable);
302 return 0;
305 //////////////////////////////////////////////////////////////////////////////
307 IMPL_LINK(CellAppearancePropertyPanel, TbxCellBorderSelectHdl, ToolBox*, pToolBox)
309 const OUString aCommand(pToolBox->GetItemCommand(pToolBox->GetCurItemId()));
311 if(aCommand == UNO_SETBORDERSTYLE)
313 // create popup on demand
314 if(!mpCellBorderStylePopup.get())
316 mpCellBorderStylePopup.reset(
317 new CellBorderStylePopup(
318 this,
319 ::boost::bind(&CellAppearancePropertyPanel::CreateCellBorderStylePopupControl, this, _1)));
322 if(mpCellBorderStylePopup.get())
324 mpCellBorderStylePopup->Show(*pToolBox);
327 return 0;
330 //////////////////////////////////////////////////////////////////////////////
332 IMPL_LINK(CellAppearancePropertyPanel, TbxLineStyleSelectHdl, ToolBox*, pToolBox)
334 const OUString aCommand(pToolBox->GetItemCommand(pToolBox->GetCurItemId()));
336 if(aCommand == UNO_LINESTYLE)
338 // create popup on demand
339 if(!mpCellLineStylePopup.get())
341 mpCellLineStylePopup.reset(
342 new CellLineStylePopup(
343 this,
344 ::boost::bind(&CellAppearancePropertyPanel::CreateCellLineStylePopupControl, this, _1)));
347 if(mpCellLineStylePopup.get())
349 mpCellLineStylePopup->SetLineStyleSelect(mnOut, mnIn, mnDis);
350 mpCellLineStylePopup->Show(*pToolBox);
353 return 0;
356 //////////////////////////////////////////////////////////////////////////////
358 IMPL_LINK(CellAppearancePropertyPanel, CBOXGridShowClkHdl, void*, EMPTYARG)
360 bool bState = mpCBXShowGrid->IsChecked();
361 SfxBoolItem aItem( SID_SCGRIDSHOW , bState);
362 GetBindings()->GetDispatcher()->Execute(SID_SCGRIDSHOW, SFX_CALLMODE_RECORD, &aItem, false, 0L);
363 return 0;
366 //////////////////////////////////////////////////////////////////////////////
368 CellAppearancePropertyPanel* CellAppearancePropertyPanel::Create (
369 Window* pParent,
370 const cssu::Reference<css::frame::XFrame>& rxFrame,
371 SfxBindings* pBindings)
373 if (pParent == NULL)
374 throw lang::IllegalArgumentException("no parent Window given to CellAppearancePropertyPanel::Create", NULL, 0);
375 if ( ! rxFrame.is())
376 throw lang::IllegalArgumentException("no XFrame given to CellAppearancePropertyPanel::Create", NULL, 1);
377 if (pBindings == NULL)
378 throw lang::IllegalArgumentException("no SfxBindings given to CellAppearancePropertyPanel::Create", NULL, 2);
380 return new CellAppearancePropertyPanel(
381 pParent,
382 rxFrame,
383 pBindings);
386 //////////////////////////////////////////////////////////////////////////////
388 void CellAppearancePropertyPanel::DataChanged(
389 const DataChangedEvent& rEvent)
391 (void)rEvent;
394 //////////////////////////////////////////////////////////////////////////////
396 void CellAppearancePropertyPanel::HandleContextChange(
397 const ::sfx2::sidebar::EnumContext aContext)
399 if(maContext == aContext)
401 // Nothing to do.
402 return;
405 maContext = aContext;
409 // todo
412 //////////////////////////////////////////////////////////////////////////////
414 void CellAppearancePropertyPanel::NotifyItemUpdate(
415 sal_uInt16 nSID,
416 SfxItemState eState,
417 const SfxPoolItem* pState,
418 const bool bIsEnabled)
420 (void)bIsEnabled;
422 switch(nSID)
424 case SID_BACKGROUND_COLOR:
425 if(eState >= SFX_ITEM_DEFAULT)
427 const SvxColorItem* pSvxColorItem = dynamic_cast< const SvxColorItem* >(pState);
429 if(pSvxColorItem)
431 maBackColor = ((const SvxColorItem*)pState)->GetValue();
432 mbBackColorAvailable = true;
433 mpFillColorUpdater->Update(maBackColor);
434 break;
438 mbBackColorAvailable = false;
439 maBackColor.SetColor(COL_TRANSPARENT);
440 mpFillColorUpdater->Update(COL_TRANSPARENT);
441 break;
442 case SID_FRAME_LINECOLOR:
443 if( eState == SFX_ITEM_DONTCARE)
445 mbLineColorAvailable = true;
446 maLineColor.SetColor( COL_TRANSPARENT );
447 UpdateControlState();
448 break;
451 if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SvxColorItem) )
453 const SvxColorItem* pSvxColorItem = dynamic_cast< const SvxColorItem* >(pState);
455 if(pSvxColorItem)
457 maLineColor = ((const SvxColorItem*)pState)->GetValue();
458 if(maLineColor == COL_AUTO)
459 mbLineColorAvailable = false;
460 else
462 mbLineColorAvailable = true;
463 // mpLineColorUpdater->Update(maLineColor);
466 UpdateControlState();
467 break;
471 mbLineColorAvailable = false;
472 maLineColor.SetColor(COL_AUTO);
473 // mpLineColorUpdater->Update(maLineColor);
474 UpdateControlState();
475 break;
476 case SID_FRAME_LINESTYLE:
477 if( eState == SFX_ITEM_DONTCARE )
479 mbBorderStyleAvailable = true;
480 mnIn = 0;
481 mnOut = 0;
482 mnDis = 0;
483 SetStyleIcon();
484 break;
487 if(eState >= SFX_ITEM_DEFAULT)
489 const SvxLineItem* pSvxLineItem = dynamic_cast< const SvxLineItem* >(pState);
491 if(pSvxLineItem)
493 const editeng::SvxBorderLine* mbLineItem = pSvxLineItem->GetLine();
494 mnIn = mbLineItem->GetInWidth();
495 mnOut = mbLineItem->GetOutWidth();
496 mnDis = mbLineItem->GetDistance();
498 if(mnIn == 0 && mnOut == 0 && mnDis == 0)
499 mbBorderStyleAvailable = false;
500 else
501 mbBorderStyleAvailable = true;
503 SetStyleIcon();
504 break;
508 mbBorderStyleAvailable = false;
509 SetStyleIcon();
510 break;
511 case SID_ATTR_BORDER_OUTER:
512 if(eState >= SFX_ITEM_DEFAULT)
514 const SvxBoxItem* pBoxItem = dynamic_cast< const SvxBoxItem* >(pState);
516 if(pBoxItem)
518 mbLeft=false, mbRight=false, mbTop=false, mbBottom=false;
520 if(pBoxItem->GetLeft())
521 mbLeft = true;
523 if(pBoxItem->GetRight())
524 mbRight = true;
526 if(pBoxItem->GetTop())
527 mbTop = true;
529 if(pBoxItem->GetBottom())
530 mbBottom = true;
532 if(!Application::GetSettings().GetLayoutRTL())
533 mpCellBorderUpdater->UpdateCellBorder(mbTop, mbBottom, mbLeft, mbRight, maIMGCellBorder, mbVer, mbHor);
534 else
535 mpCellBorderUpdater->UpdateCellBorder(mbTop, mbBottom, mbRight, mbLeft, maIMGCellBorder, mbVer, mbHor);
537 if(mbLeft || mbRight || mbTop || mbBottom)
538 mbOuterBorder = true;
539 else
540 mbOuterBorder = false;
542 UpdateControlState();
545 break;
546 case SID_ATTR_BORDER_INNER:
547 if(eState >= SFX_ITEM_DEFAULT)
549 const SvxBoxInfoItem* pBoxInfoItem = dynamic_cast< const SvxBoxInfoItem* >(pState);
551 if(pBoxInfoItem)
553 bool bLeft(false), bRight(false), bTop(false), bBottom(false);
555 mbVer = false, mbHor = false;
557 if(!pBoxInfoItem->IsValid( VALID_VERT ) || pBoxInfoItem->GetVert())
558 mbVer = true;
560 if(!pBoxInfoItem->IsValid( VALID_HORI ) || pBoxInfoItem->GetHori())
561 mbHor = true;
563 if(!pBoxInfoItem->IsValid( VALID_LEFT ) || mbLeft)
564 bLeft = true;
566 if(!pBoxInfoItem->IsValid( VALID_RIGHT ) || mbRight)
567 bRight = true;
569 if(!pBoxInfoItem->IsValid( VALID_TOP ) || mbTop)
570 bTop = true;
572 if(!pBoxInfoItem->IsValid( VALID_BOTTOM ) || mbBottom)
573 bBottom = true;
575 if(!Application::GetSettings().GetLayoutRTL())
576 mpCellBorderUpdater->UpdateCellBorder(bTop, bBottom, bLeft, bRight, maIMGCellBorder, mbVer, mbHor);
577 else
578 mpCellBorderUpdater->UpdateCellBorder(bTop, bBottom, bRight, bLeft, maIMGCellBorder, mbVer, mbHor);
580 if(mbVer || mbHor || bLeft || bRight || bTop || bBottom)
581 mbInnerBorder = true;
582 else
583 mbInnerBorder = false;
585 UpdateControlState();
588 break;
589 case SID_ATTR_BORDER_DIAG_TLBR:
590 if( eState == SFX_ITEM_DONTCARE )
592 mbTLBR = true;
593 maTLBRColor.SetColor(COL_TRANSPARENT);
594 mnTLBRIn = mnTLBROut = mnTLBRDis = 0;
595 UpdateControlState();
596 break;
599 if(eState >= SFX_ITEM_DEFAULT)
601 const SvxLineItem* pItem = dynamic_cast< const SvxLineItem* >(pState);
603 if(pItem)
605 const editeng::SvxBorderLine* aLine = pItem->GetLine();
607 if(!aLine)
609 mbTLBR = false;
611 else
613 mbTLBR = true;
614 maTLBRColor = aLine->GetColor();
615 mnTLBRIn = aLine->GetInWidth();
616 mnTLBROut = aLine->GetOutWidth();
617 mnTLBRDis = aLine->GetDistance();
619 if(mnTLBRIn == 0 && mnTLBROut == 0 && mnTLBRDis == 0)
620 mbTLBR = false;
623 UpdateControlState();
624 break;
628 mbTLBR = false;
629 UpdateControlState();
630 break;
631 case SID_ATTR_BORDER_DIAG_BLTR:
632 if( eState == SFX_ITEM_DONTCARE )
634 mbBLTR = true;
635 maBLTRColor.SetColor( COL_TRANSPARENT );
636 mnBLTRIn = mnBLTROut = mnBLTRDis = 0;
637 UpdateControlState();
638 break;
641 if(eState >= SFX_ITEM_DEFAULT)
643 const SvxLineItem* pItem = dynamic_cast< const SvxLineItem* >(pState);
645 if(pItem)
647 const editeng::SvxBorderLine* aLine = pItem->GetLine();
649 if(!aLine)
651 mbBLTR = false;
653 else
655 mbBLTR = true;
656 maBLTRColor = aLine->GetColor();
657 mnBLTRIn = aLine->GetInWidth();
658 mnBLTROut = aLine->GetOutWidth();
659 mnBLTRDis = aLine->GetDistance();
661 if(mnBLTRIn == 0 && mnBLTROut == 0 && mnBLTRDis == 0)
662 mbBLTR = false;
665 UpdateControlState();
667 break;
670 mbBLTR = false;
671 UpdateControlState();
672 break;
673 case SID_SCGRIDSHOW:
674 if(eState >= SFX_ITEM_DEFAULT)
676 const SfxBoolItem* pItem = dynamic_cast< const SfxBoolItem* >(pState);
678 if(pItem)
680 const bool bVal = pItem->GetValue();
682 if(bVal)
683 mpCBXShowGrid->Check(true);
684 else
685 mpCBXShowGrid->Check(false);
688 break;
692 //////////////////////////////////////////////////////////////////////////////
694 SfxBindings* CellAppearancePropertyPanel::GetBindings()
696 return mpBindings;
699 //////////////////////////////////////////////////////////////////////////////
701 void CellAppearancePropertyPanel::SetStyleIcon()
703 const sal_uInt16 nIdBorderLineStyle = mpTBLineStyle->GetItemId( UNO_LINESTYLE );
705 //FIXME: update for new line border possibilities
706 if(mnOut == DEF_LINE_WIDTH_0 && mnIn == 0 && mnDis == 0) //1
707 mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle1);
708 else if(mnOut == DEF_LINE_WIDTH_2 && mnIn == 0 && mnDis == 0) //2
709 mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle2);
710 else if(mnOut == DEF_LINE_WIDTH_3 && mnIn == 0 && mnDis == 0) //3
711 mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle3);
712 else if(mnOut == DEF_LINE_WIDTH_4 && mnIn == 0 && mnDis == 0) //4
713 mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle4);
714 else if(mnOut == DEF_LINE_WIDTH_0 && mnIn == DEF_LINE_WIDTH_0 && mnDis == DEF_LINE_WIDTH_1) //5
715 mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle5);
716 else if(mnOut == DEF_LINE_WIDTH_0 && mnIn == DEF_LINE_WIDTH_0 && mnDis == DEF_LINE_WIDTH_2) //6
717 mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle6);
718 else if(mnOut == DEF_LINE_WIDTH_1 && mnIn == DEF_LINE_WIDTH_2 && mnDis == DEF_LINE_WIDTH_1) //7
719 mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle7);
720 else if(mnOut == DEF_LINE_WIDTH_2 && mnIn == DEF_LINE_WIDTH_0 && mnDis == DEF_LINE_WIDTH_2) //8
721 mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle8);
722 else if(mnOut == DEF_LINE_WIDTH_2 && mnIn == DEF_LINE_WIDTH_2 && mnDis == DEF_LINE_WIDTH_2) //9
723 mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle9);
724 else
725 mpTBLineStyle->SetItemImage(nIdBorderLineStyle, maIMGLineStyle1);
728 void CellAppearancePropertyPanel::UpdateControlState()
730 if(mbOuterBorder || mbInnerBorder || mbTLBR || mbBLTR)
732 mpTBLineColor->Enable();
733 mpTBLineStyle->Enable();
735 //set line color state
736 if( mbLineColorAvailable && !mbTLBR && !mbBLTR )
737 mpLineColorUpdater->Update(maLineColor);
738 else if( !mbLineColorAvailable && mbTLBR && !mbBLTR )
739 mpLineColorUpdater->Update(maTLBRColor);
740 else if ( !mbLineColorAvailable && !mbTLBR && mbBLTR )
741 mpLineColorUpdater->Update(maBLTRColor);
742 else if( !mbLineColorAvailable && mbTLBR && mbBLTR)
744 if( maTLBRColor == maBLTRColor)
745 mpLineColorUpdater->Update(maBLTRColor);
746 else
747 mpLineColorUpdater->Update(COL_TRANSPARENT);
749 else if( mbLineColorAvailable && mbTLBR && !mbBLTR )
751 if( maTLBRColor == maLineColor)
752 mpLineColorUpdater->Update(maLineColor);
753 else
754 mpLineColorUpdater->Update(COL_TRANSPARENT);
756 else if( mbLineColorAvailable && !mbTLBR && mbBLTR )
758 if( maBLTRColor == maLineColor)
759 mpLineColorUpdater->Update(maLineColor);
760 else
761 mpLineColorUpdater->Update(COL_TRANSPARENT);
763 else
764 mpLineColorUpdater->Update(COL_TRANSPARENT);
766 //set line style state
767 if( mbBorderStyleAvailable && !mbTLBR && !mbBLTR )
770 else if( !mbBorderStyleAvailable && mbTLBR && !mbBLTR )
772 mnIn = mnTLBRIn;
773 mnOut = mnTLBROut;
774 mnDis = mnTLBRDis;
776 else if ( !mbBorderStyleAvailable && !mbTLBR && mbBLTR )
778 mnIn = mnBLTRIn;
779 mnOut = mnBLTROut;
780 mnDis = mnBLTRDis;
782 else if( !mbBorderStyleAvailable && mbTLBR && mbBLTR)
784 if( mnTLBRIn == mnBLTRIn && mnTLBROut == mnBLTROut && mnTLBRDis == mnBLTRDis)
786 mnIn = mnTLBRIn;
787 mnOut = mnTLBROut;
788 mnDis = mnTLBRDis;
790 else
792 mnIn = 0;
793 mnOut = 0;
794 mnDis = 0;
797 else if( mbBorderStyleAvailable && mbTLBR && !mbBLTR )
799 if( mnTLBRIn != mnIn || mnTLBROut != mnOut || mnTLBRDis != mnDis)
801 mnIn = 0;
802 mnOut = 0;
803 mnDis = 0;
806 else if( mbBorderStyleAvailable && !mbTLBR && mbBLTR )
808 if( mnBLTRIn != mnIn || mnBLTROut != mnOut || mnBLTRDis != mnDis )
810 mnIn = 0;
811 mnOut = 0;
812 mnDis = 0;
815 else
817 mnIn = 0;
818 mnOut = 0;
819 mnDis = 0;
821 SetStyleIcon();
823 else
825 mpTBLineColor->Disable();
826 mpTBLineStyle->Disable();
830 //////////////////////////////////////////////////////////////////////////////
831 // namespace close
833 }} // end of namespace ::sc::sidebar
835 //////////////////////////////////////////////////////////////////////////////
836 // eof
838 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */