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