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_svx.hxx"
23 
24 #include "TextPropertyPanel.hrc"
25 #include "TextPropertyPanel.hxx"
26 #include "SvxSBFontNameBox.hxx"
27 
28 #include "svx/dialmgr.hxx"
29 
30 #include <editeng/brshitem.hxx>
31 #include <editeng/colritem.hxx>
32 #include <editeng/crsditem.hxx>
33 #include <editeng/escpitem.hxx>
34 #include <editeng/flstitem.hxx>
35 #include <editeng/fontitem.hxx>
36 #include <editeng/kernitem.hxx>
37 #include <editeng/postitem.hxx>
38 #include <editeng/shdditem.hxx>
39 #include <editeng/udlnitem.hxx>
40 #include <editeng/wghtitem.hxx>
41 #include <rtl/ref.hxx>
42 #include <sfx2/dispatch.hxx>
43 #include <sfx2/objsh.hxx>
44 #include <sfx2/viewsh.hxx>
45 #include <sfx2/sidebar/ResourceDefinitions.hrc>
46 #include <sfx2/sidebar/ControlFactory.hxx>
47 #include <sfx2/sidebar/Theme.hxx>
48 #include "sfx2/imagemgr.hxx"
49 #include <svtools/ctrltool.hxx>
50 #include <svtools/unitconv.hxx>
51 
52 #include <vcl/gradient.hxx>
53 #include <vcl/svapp.hxx>
54 #include <vcl/toolbox.hxx>
55 #include "TextCharacterSpacingControl.hxx"
56 #include "TextCharacterSpacingPopup.hxx"
57 #include "TextUnderlineControl.hxx"
58 #include "TextUnderlinePopup.hxx"
59 #include <svx/sidebar/ColorControl.hxx>
60 #include <svx/sidebar/PopupContainer.hxx>
61 
62 #include <boost/bind.hpp>
63 
64 using namespace css;
65 using namespace cssu;
66 using ::sfx2::sidebar::Theme;
67 using ::sfx2::sidebar::ControlFactory;
68 
69 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
70 
71 namespace svx { namespace sidebar {
72 
73 #undef HAS_IA2
74 
75 
76 #define FONT_CONTROL_WIDTH 		160
77 #define SIZE_CONTROL_WIDTH 		80
78 #define CONTROL_COMBOX_HEIGHT	20
79 #define CONTROL_HEIGHT_5X  		120
80 
81 
82 #define TEXT_SECTIONPAGE_HEIGHT_S   SECTIONPAGE_MARGIN_VERTICAL_TOP + CBOX_HEIGHT  + ( TOOLBOX_ITEM_HEIGHT + 2 ) + CONTROL_SPACING_VERTICAL * 1 + SECTIONPAGE_MARGIN_VERTICAL_BOT
83 #define TEXT_SECTIONPAGE_HEIGHT		SECTIONPAGE_MARGIN_VERTICAL_TOP + CBOX_HEIGHT  + ( TOOLBOX_ITEM_HEIGHT + 2 ) * 2 + CONTROL_SPACING_VERTICAL * 2 + SECTIONPAGE_MARGIN_VERTICAL_BOT
84 
85 
86     PopupControl* TextPropertyPanel::CreateCharacterSpacingControl (PopupContainer* pParent)
87 {
88     return new TextCharacterSpacingControl(pParent, *this, mpBindings);
89 }
90 
91 PopupControl* TextPropertyPanel::CreateUnderlinePopupControl (PopupContainer* pParent)
92 {
93 	return new TextUnderlineControl(pParent, *this, mpBindings);
94 }
95 
96 namespace
97 {
98     Color GetAutomaticColor(void)
99     {
100         return COL_AUTO;
101     }
102 } // end of anonymous namespace
103 
104 PopupControl* TextPropertyPanel::CreateFontColorPopupControl (PopupContainer* pParent)
105 {
106     const ResId aResId(SVX_RES(STR_AUTOMATICE));
107 
108     return new ColorControl(
109         pParent,
110         mpBindings,
111         SVX_RES(RID_POPUPPANEL_TEXTPAGE_FONT_COLOR),
112         SVX_RES(VS_FONT_COLOR),
113         ::boost::bind(GetAutomaticColor),
114         ::boost::bind(&TextPropertyPanel::SetFontColor, this, _1,_2),
115         pParent,
116         &aResId);
117 }
118 
119 PopupControl* TextPropertyPanel::CreateBrushColorPopupControl (PopupContainer* pParent)
120 {
121     const ResId aResId(SVX_RES(STR_AUTOMATICE));
122 
123     return new ColorControl(
124         pParent,
125         mpBindings,
126         SVX_RES(RID_POPUPPANEL_TEXTPAGE_FONT_COLOR),
127         SVX_RES(VS_FONT_COLOR),
128         ::boost::bind(GetAutomaticColor),
129         ::boost::bind(&TextPropertyPanel::SetBrushColor, this, _1,_2),
130         pParent,
131         &aResId);
132 }
133 
134 long TextPropertyPanel::GetSelFontSize()
135 {
136     long nH = 240;
137     SfxMapUnit eUnit = maSpacingControl.GetCoreMetric();
138     if (mpHeightItem)
139         nH = LogicToLogic(  mpHeightItem->GetHeight(), (MapUnit)eUnit, MAP_TWIP );
140     return nH;
141 }
142 
143 
144 TextPropertyPanel* TextPropertyPanel::Create (
145     Window* pParent,
146     const cssu::Reference<css::frame::XFrame>& rxFrame,
147     SfxBindings* pBindings)
148 {
149     if (pParent == NULL)
150         throw lang::IllegalArgumentException(A2S("no parent Window given to TextPropertyPanel::Create"), NULL, 0);
151     if ( ! rxFrame.is())
152         throw lang::IllegalArgumentException(A2S("no XFrame given to TextPropertyPanel::Create"), NULL, 1);
153     if (pBindings == NULL)
154         throw lang::IllegalArgumentException(A2S("no SfxBindings given to TextPropertyPanel::Create"), NULL, 2);
155 
156     return new TextPropertyPanel(
157         pParent,
158         rxFrame,
159         pBindings);
160 }
161 
162 
163 ::sfx2::sidebar::ControllerItem& TextPropertyPanel::GetSpaceController()
164 {
165 	return maSpacingControl;
166 }
167 
168 TextPropertyPanel::TextPropertyPanel (
169     Window* pParent,
170     const cssu::Reference<css::frame::XFrame>& rxFrame,
171     SfxBindings* pBindings)
172     :   Control(pParent, SVX_RES(RID_SIDEBAR_TEXT_PANEL)),
173         mpFontNameBox (new SvxSBFontNameBox(this, SVX_RES(CB_SBFONT_FONT))),
174         maFontSizeBox		(this, SVX_RES(MB_SBFONT_FONTSIZE)),
175         mpToolBoxIncDecBackground(ControlFactory::CreateToolBoxBackground(this)),
176         mpToolBoxIncDec(ControlFactory::CreateToolBox(
177                 mpToolBoxIncDecBackground.get(),
178                 SVX_RES(TB_INCREASE_DECREASE))),
179         mpToolBoxFontBackground(ControlFactory::CreateToolBoxBackground(this)),
180         mpToolBoxFont(ControlFactory::CreateToolBox(
181                 mpToolBoxFontBackground.get(),
182                 SVX_RES(TB_FONT))),
183         mpToolBoxFontColorBackground(ControlFactory::CreateToolBoxBackground(this)),
184         mpToolBoxFontColor(ControlFactory::CreateToolBox(
185                 mpToolBoxFontColorBackground.get(),
186                 SVX_RES(TB_FONTCOLOR))),
187         mpToolBoxScriptBackground(ControlFactory::CreateToolBoxBackground(this)),
188         mpToolBoxScript(ControlFactory::CreateToolBox(
189                 mpToolBoxScriptBackground.get(),
190                 SVX_RES(TB_SCRIPT))),
191         mpToolBoxScriptSwBackground(ControlFactory::CreateToolBoxBackground(this)),
192         mpToolBoxScriptSw(ControlFactory::CreateToolBox(
193                 mpToolBoxScriptSwBackground.get(),
194                 SVX_RES(TB_SCRIPT_SW))),
195         mpToolBoxSpacingBackground(ControlFactory::CreateToolBoxBackground(this)),
196         mpToolBoxSpacing(ControlFactory::CreateToolBox(
197                 mpToolBoxSpacingBackground.get(),
198                 SVX_RES(TB_SPACING))),
199         mpToolBoxHighlightBackground(ControlFactory::CreateToolBoxBackground(this)),
200         mpToolBoxHighlight(ControlFactory::CreateToolBox(
201                 mpToolBoxHighlightBackground.get(),
202                 SVX_RES(TB_HIGHLIGHT))),
203         mpFontColorUpdater(),
204         mpHighlightUpdater(),
205 
206         maFontNameControl	(SID_ATTR_CHAR_FONT,		*pBindings, *this, A2S("CharFontName"), rxFrame),
207         maFontSizeControl	(SID_ATTR_CHAR_FONTHEIGHT,	*pBindings, *this, A2S("FontHeight"),   rxFrame),
208         maWeightControl		(SID_ATTR_CHAR_WEIGHT,		*pBindings, *this, A2S("Bold"),         rxFrame),
209         maItalicControl		(SID_ATTR_CHAR_POSTURE,		*pBindings, *this, A2S("Italic"),       rxFrame),
210         maUnderlineControl	(SID_ATTR_CHAR_UNDERLINE,	*pBindings, *this, A2S("Underline"),    rxFrame),
211         maStrikeControl		(SID_ATTR_CHAR_STRIKEOUT,	*pBindings, *this, A2S("Strikeout"),    rxFrame),
212         maShadowControl		(SID_ATTR_CHAR_SHADOWED,	*pBindings, *this, A2S("Shadowed"),     rxFrame),
213         maFontColorControl	(SID_ATTR_CHAR_COLOR,		*pBindings, *this, A2S("Color"),        rxFrame),
214         maScriptControlSw	(SID_ATTR_CHAR_ESCAPEMENT,	*pBindings, *this, A2S("Escapement"),   rxFrame),
215         maSuperScriptControl(SID_SET_SUPER_SCRIPT,		*pBindings, *this, A2S("SuperScript"),  rxFrame),
216         maSubScriptControl	(SID_SET_SUB_SCRIPT,		*pBindings, *this, A2S("SubScript"),    rxFrame),
217         maSpacingControl	(SID_ATTR_CHAR_KERNING,		*pBindings, *this, A2S("Spacing"),      rxFrame),
218         maHighlightControl	(SID_ATTR_BRUSH_CHAR, *pBindings, *this, A2S("CharacterBackgroundPattern"),rxFrame),
219         maSDFontGrow		(SID_GROW_FONT_SIZE,		*pBindings, *this, A2S("Grow"),         rxFrame),
220         maSDFontShrink		(SID_SHRINK_FONT_SIZE,		*pBindings, *this, A2S("Shrink"),       rxFrame),
221 
222         mpFontList			(NULL),
223         mbMustDelete		(false),
224         mbFocusOnFontSizeCtrl(false),
225         maCharSpacePopup(this, ::boost::bind(&TextPropertyPanel::CreateCharacterSpacingControl, this, _1)),
226         maUnderlinePopup(this, ::boost::bind(&TextPropertyPanel::CreateUnderlinePopupControl, this, _1)),
227         maFontColorPopup(this, ::boost::bind(&TextPropertyPanel::CreateFontColorPopupControl, this, _1)),
228         maBrushColorPopup(this, ::boost::bind(&TextPropertyPanel::CreateBrushColorPopupControl, this, _1)),
229         mxFrame(rxFrame),
230         maContext(),
231         mpBindings(pBindings)
232 {
233 	Initialize();
234 	FreeResource();
235 }
236 
237 
238 
239 
240 TextPropertyPanel::~TextPropertyPanel (void)
241 {
242     if(mbMustDelete)
243         delete mpFontList;
244 
245     // Destroy the toolbox windows.
246     mpToolBoxIncDec.reset();
247     mpToolBoxFont.reset();
248     mpToolBoxFontColor.reset();
249     mpToolBoxScript.reset();
250     mpToolBoxScriptSw.reset();
251     mpToolBoxSpacing.reset();
252     mpToolBoxHighlight.reset();
253 
254     // Destroy the background windows of the toolboxes.
255     mpToolBoxIncDecBackground.reset();
256     mpToolBoxFontBackground.reset();
257     mpToolBoxFontColorBackground.reset();
258     mpToolBoxScriptBackground.reset();
259     mpToolBoxScriptSwBackground.reset();
260     mpToolBoxSpacingBackground.reset();
261     mpToolBoxHighlightBackground.reset();
262 }
263 
264 
265 
266 
267 void TextPropertyPanel::SetSpacing(long nKern)
268 {
269 	mlKerning = nKern;
270 }
271 
272 
273 void TextPropertyPanel::HandleContextChange (
274     const ::sfx2::sidebar::EnumContext aContext)
275 {
276     if (maContext == aContext)
277     {
278         // Nothing to do.
279         return;
280     }
281 
282     maContext = aContext;
283     switch (maContext.GetCombinedContext_DI())
284     {
285         case CombinedEnumContext(Application_Calc, Context_Cell):
286         case CombinedEnumContext(Application_Calc, Context_Pivot):
287             mpToolBoxScriptSw->Hide();
288             mpToolBoxHighlight->Hide();
289             mpToolBoxScript->Disable();
290             mpToolBoxSpacing->Disable();
291             break;
292 
293         case CombinedEnumContext(Application_Calc, Context_EditCell):
294         case CombinedEnumContext(Application_Calc, Context_DrawText):
295             mpToolBoxScriptSw->Hide();
296             mpToolBoxHighlight->Hide();
297             mpToolBoxScript->Enable();
298             mpToolBoxSpacing->Enable();
299             break;
300 
301         case CombinedEnumContext(Application_WriterVariants, Context_Text):
302         case CombinedEnumContext(Application_WriterVariants, Context_Table):
303             mpToolBoxScriptSw->Show();
304             mpToolBoxScript->Hide();
305             mpToolBoxHighlight->Show();
306             mpToolBoxSpacing->Show();
307             break;
308 
309         case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
310         case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
311             mpToolBoxScriptSw->Show();
312             mpToolBoxScript->Hide();
313             mpToolBoxSpacing->Show();
314             mpToolBoxHighlight->Hide();
315             break;
316 
317         case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
318         case CombinedEnumContext(Application_DrawImpress, Context_Text):
319         case CombinedEnumContext(Application_DrawImpress, Context_Table):
320         case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
321         case CombinedEnumContext(Application_DrawImpress, Context_Draw):
322         case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
323         case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
324             mpToolBoxScriptSw->Hide();
325             mpToolBoxScript->Show();
326             mpToolBoxSpacing->Show();
327             mpToolBoxHighlight->Hide();
328             break;
329 
330         default:
331             break;
332     }
333 }
334 
335 
336 
337 
338 void TextPropertyPanel::DataChanged (const DataChangedEvent& rEvent)
339 {
340     (void)rEvent;
341 
342     SetupToolboxItems();
343 }
344 
345 
346 
347 void TextPropertyPanel::Initialize (void)
348 {
349     //<<modify fill font list
350     SfxObjectShell* pDocSh = SfxObjectShell::Current();
351     const SfxPoolItem* pItem = NULL;
352 
353     if (pDocSh != NULL)
354         pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
355     if (pItem != NULL)
356         mpFontList = ( (SvxFontListItem*)pItem )->GetFontList();
357     else
358     {
359         mpFontList = new FontList( Application::GetDefaultDevice() );
360         mbMustDelete = true;
361     }
362 
363     mpFontNameBox->SetAccessibleName(mpFontNameBox->GetQuickHelpText());
364     const FontInfo aFontInfo (mpFontList->Get( String::CreateFromAscii( "" ), String::CreateFromAscii( "" )));
365     maFontSizeBox.Fill(&aFontInfo,mpFontList);
366     maFontSizeBox.SetAccessibleName(maFontSizeBox.GetQuickHelpText());
367 
368     //toolbox
369     SetupToolboxItems();
370     InitToolBoxIncDec();
371     InitToolBoxFont();
372     InitToolBoxFontColor();
373     InitToolBoxScript();
374     InitToolBoxSpacing();
375     InitToolBoxHighlight();
376 
377 #ifdef HAS_IA2
378     mpFontNameBox->SetAccRelationLabeledBy(&mpFontNameBox);
379     mpFontNameBox->SetMpSubEditAccLableBy(&mpFontNameBox);
380     maFontSizeBox.SetAccRelationLabeledBy(&maFontSizeBox);
381     maFontSizeBox.SetMpSubEditAccLableBy(&maFontSizeBox);
382     mpToolBoxFont.SetAccRelationLabeledBy(&mpToolBoxFont);
383     mpToolBoxIncDec.SetAccRelationLabeledBy(&mpToolBoxIncDec);
384     mpToolBoxFontColor.SetAccRelationLabeledBy(&mpToolBoxFontColor);
385     mpToolBoxScript.SetAccRelationLabeledBy(&mpToolBoxScript);
386     mpToolBoxScriptSw.SetAccRelationLabeledBy(&mpToolBoxScriptSw);
387     mpToolBoxSpacing.SetAccRelationLabeledBy(&mpToolBoxSpacing);
388     mpToolBoxHighlight.SetAccRelationLabeledBy(&mpToolBoxHighlight);
389 #endif
390 
391     //init state
392     mpHeightItem = NULL;
393     meWeight = WEIGHT_NORMAL;
394     meItalic = ITALIC_NONE;
395     mbShadow = false;
396     meStrike = STRIKEOUT_NONE;
397     mbPostureAvailable = true;
398     mbWeightAvailable = true;
399     meUnderline = UNDERLINE_NONE;
400     meUnderlineColor = COL_AUTO;   //
401     maColor = COL_BLACK;
402     mbColorAvailable = true;
403     maBackColor = COL_AUTO;
404     mbBackColorAvailable = true;
405     meEscape = SVX_ESCAPEMENT_OFF;
406     mbSuper = false;
407     mbSub = false;
408     mbKernAvailable = true;
409     mbKernLBAvailable = true;
410     mlKerning = 0;
411     mpFontColorUpdater.reset(new ToolboxButtonColorUpdater(
412             SID_ATTR_CHAR_COLOR,
413             TBI_FONTCOLOR,
414             mpToolBoxFontColor.get(),
415             TBX_UPDATER_MODE_CHAR_COLOR_NEW));
416     mpHighlightUpdater.reset(new ToolboxButtonColorUpdater(
417             SID_ATTR_BRUSH_CHAR,
418             TBI_HIGHLIGHT,
419             mpToolBoxHighlight.get(),
420             TBX_UPDATER_MODE_CHAR_COLOR_NEW));
421 
422     //set handler
423     mpFontNameBox->SetBindings(mpBindings);
424     Link aLink = LINK(this, TextPropertyPanel, FontSelHdl);
425     mpFontNameBox->SetSelectHdl(aLink);
426     aLink = LINK(this, TextPropertyPanel, FontSizeModifyHdl);
427     maFontSizeBox.SetModifyHdl(aLink);
428     aLink = LINK(this, TextPropertyPanel, FontSizeSelHdl);
429     maFontSizeBox.SetSelectHdl(aLink);
430     aLink = LINK(this, TextPropertyPanel, FontSizeLoseFocus);
431     maFontSizeBox.SetLoseFocusHdl(aLink);
432 
433     Size aSize(PROPERTYPAGE_WIDTH, TEXT_SECTIONPAGE_HEIGHT);
434     aSize = LogicToPixel( aSize, MapMode(MAP_APPFONT) );
435     aSize.setWidth(GetOutputSizePixel().Width());
436     SetSizePixel(aSize);
437 }
438 
439 void TextPropertyPanel::EndSpacingPopupMode (void)
440 {
441     maCharSpacePopup.Hide();
442 }
443 
444 void TextPropertyPanel::EndUnderlinePopupMode (void)
445 {
446 	maUnderlinePopup.Hide();
447 }
448 
449 
450 void TextPropertyPanel::InitToolBoxFont()
451 {
452 	mpToolBoxFont->SetBackground(Wallpaper());
453 	mpToolBoxFont->SetPaintTransparent(true);
454 
455 	Size aTbxSize( mpToolBoxFont->CalcWindowSizePixel() );
456 	mpToolBoxFont->SetOutputSizePixel( aTbxSize );
457 
458 	Link aLink  = LINK(this, TextPropertyPanel, ToolboxFontSelectHandler);
459 	mpToolBoxFont->SetSelectHdl ( aLink );
460 	aLink = LINK(this, TextPropertyPanel, ToolBoxUnderlineClickHdl);
461 	mpToolBoxFont->SetDropdownClickHdl(aLink);
462 }
463 
464 
465 
466 
467 void TextPropertyPanel::InitToolBoxIncDec()
468 {
469 	Size aTbxSize( mpToolBoxIncDec->CalcWindowSizePixel() );
470 	mpToolBoxIncDec->SetOutputSizePixel( aTbxSize );
471 
472 	Link aLink = LINK(this, TextPropertyPanel, ToolboxIncDecSelectHdl);
473     mpToolBoxIncDec->SetSelectHdl ( aLink );
474 }
475 
476 
477 
478 
479 void TextPropertyPanel::InitToolBoxFontColor()
480 {
481 	Size aTbxSize( mpToolBoxFontColor->CalcWindowSizePixel() );
482 	mpToolBoxFontColor->SetOutputSizePixel( aTbxSize );
483 	mpToolBoxFontColor->SetItemBits( TBI_FONTCOLOR, mpToolBoxFontColor->GetItemBits( TBI_FONTCOLOR ) | TIB_DROPDOWNONLY );
484 
485 	Link aLink = LINK(this, TextPropertyPanel, ToolBoxFontColorDropHdl);
486     mpToolBoxFontColor->SetDropdownClickHdl ( aLink );
487 	mpToolBoxFontColor->SetSelectHdl ( aLink );
488 
489 }
490 void TextPropertyPanel::InitToolBoxScript()
491 {
492 	Size aTbxSize( mpToolBoxScriptSw->CalcWindowSizePixel() );
493 	mpToolBoxScriptSw->SetOutputSizePixel( aTbxSize );
494 
495 	Link aLink = LINK(this, TextPropertyPanel, ToolBoxSwScriptSelectHdl);
496     mpToolBoxScriptSw->SetSelectHdl ( aLink );
497 
498 	aTbxSize = mpToolBoxScript->CalcWindowSizePixel() ;
499 	mpToolBoxScript->SetOutputSizePixel( aTbxSize );
500 
501 	aLink = LINK(this, TextPropertyPanel, ToolBoxScriptSelectHdl);
502     mpToolBoxScript->SetSelectHdl ( aLink );
503 }
504 void TextPropertyPanel::InitToolBoxSpacing()
505 {
506 	Size aTbxSize( mpToolBoxSpacing->CalcWindowSizePixel() );
507 	mpToolBoxSpacing->SetOutputSizePixel( aTbxSize );
508 	mpToolBoxSpacing->SetItemBits( TBI_SPACING, mpToolBoxSpacing->GetItemBits( TBI_SPACING ) | TIB_DROPDOWNONLY );
509 
510 	Link aLink = LINK(this, TextPropertyPanel, SpacingClickHdl);
511     mpToolBoxSpacing->SetDropdownClickHdl ( aLink );
512 	mpToolBoxSpacing->SetSelectHdl( aLink );
513 }
514 void TextPropertyPanel::InitToolBoxHighlight()
515 {
516 	Size aTbxSize( mpToolBoxHighlight->CalcWindowSizePixel() );
517 	mpToolBoxHighlight->SetOutputSizePixel( aTbxSize );
518 	mpToolBoxHighlight->SetItemBits( TBI_HIGHLIGHT, mpToolBoxHighlight->GetItemBits( TBI_HIGHLIGHT ) | TIB_DROPDOWNONLY );
519 
520 	Link aLink = LINK(this, TextPropertyPanel, ToolBoxHighlightDropHdl);
521     mpToolBoxHighlight->SetDropdownClickHdl ( aLink );
522 	mpToolBoxHighlight->SetSelectHdl( aLink );
523 }
524 
525 
526 
527 
528 void TextPropertyPanel::SetupToolboxItems (void)
529 {
530     maSDFontGrow.SetupToolBoxItem(*mpToolBoxIncDec, TBI_INCREASE);
531     maSDFontShrink.SetupToolBoxItem(*mpToolBoxIncDec, TBI_DECREASE);
532 
533     maWeightControl.SetupToolBoxItem(*mpToolBoxFont, TBI_BOLD);
534     maItalicControl.SetupToolBoxItem(*mpToolBoxFont, TBI_ITALIC);
535     maUnderlineControl.SetupToolBoxItem(*mpToolBoxFont, TBI_UNDERLINE);
536     maStrikeControl.SetupToolBoxItem(*mpToolBoxFont, TBI_STRIKEOUT);
537     maShadowControl.SetupToolBoxItem(*mpToolBoxFont, TBI_SHADOWED);
538 
539     maFontColorControl.SetupToolBoxItem(*mpToolBoxFontColor, TBI_FONTCOLOR);
540     //for sw
541     maSuperScriptControl.SetupToolBoxItem(*mpToolBoxScriptSw, TBI_SUPER_SW);
542     maSubScriptControl.SetupToolBoxItem(*mpToolBoxScriptSw, TBI_SUB_SW);
543     //for sc and sd
544     maSuperScriptControl.SetupToolBoxItem(*mpToolBoxScript, TBI_SUPER);
545     maSubScriptControl.SetupToolBoxItem(*mpToolBoxScript, TBI_SUB);
546     maSpacingControl.SetupToolBoxItem(*mpToolBoxSpacing, TBI_SPACING);
547     maHighlightControl.SetupToolBoxItem(*mpToolBoxHighlight, TBI_HIGHLIGHT);
548 }
549 
550 
551 
552 
553 IMPL_LINK( TextPropertyPanel, FontSelHdl, FontNameBox*, pBox )
554 {
555 	if ( !pBox->IsTravelSelect() )
556 	{
557 		if( SfxViewShell::Current() )
558 		{
559 			Window* pShellWnd = SfxViewShell::Current()->GetWindow();
560 
561 			if ( pShellWnd )
562 				pShellWnd->GrabFocus();
563 		}
564 	}
565 	return 0;
566 }
567 
568 IMPL_LINK( TextPropertyPanel, FontSizeModifyHdl, FontSizeBox*, pSizeBox )
569 {
570 	if (pSizeBox == &maFontSizeBox)
571 	{
572 		long nSize = pSizeBox->GetValue();
573 		mbFocusOnFontSizeCtrl = true;
574 
575 		float fSize = (float)nSize / 10;
576 		SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric();
577 		SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ;
578 
579 		mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L );
580 		mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false);
581 	}
582 	return 0;
583 }
584 
585 IMPL_LINK( TextPropertyPanel, FontSizeSelHdl, FontSizeBox*, pSizeBox )
586 {
587 	if ( !pSizeBox->IsTravelSelect() )
588 	{
589 		if( SfxViewShell::Current() )
590 		{
591 			Window* pShellWnd = SfxViewShell::Current()->GetWindow();
592 
593 			if ( pShellWnd )
594 				pShellWnd->GrabFocus();
595 		}
596 	}
597 
598 	return 0;
599 }
600 
601 IMPL_LINK(TextPropertyPanel, FontSizeLoseFocus, FontSizeBox*, pSizeBox)
602 {
603 	if(pSizeBox == &maFontSizeBox)
604 	{
605 		mbFocusOnFontSizeCtrl = false;
606 	}
607 	return 0;
608 }
609 
610 IMPL_LINK(TextPropertyPanel, ToolboxFontSelectHandler, ToolBox*, pToolBox)
611 {
612     const sal_uInt16 nId = pToolBox->GetCurItemId();
613 
614     switch (nId)
615     {
616         case TBI_BOLD:
617         {
618             EndTracking();
619             if(meWeight != WEIGHT_BOLD)
620                 meWeight = WEIGHT_BOLD;
621             else
622                 meWeight = WEIGHT_NORMAL;
623             SvxWeightItem aWeightItem(meWeight, SID_ATTR_CHAR_WEIGHT);
624             mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_WEIGHT, SFX_CALLMODE_RECORD, &aWeightItem, 0L);
625             UpdateItem(SID_ATTR_CHAR_WEIGHT);
626             break;
627         }
628         case TBI_ITALIC:
629         {
630             EndTracking();
631             if(meItalic != ITALIC_NORMAL)
632                 meItalic = ITALIC_NORMAL;
633             else
634                 meItalic = ITALIC_NONE;
635             SvxPostureItem aPostureItem(meItalic, SID_ATTR_CHAR_POSTURE);
636             mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_POSTURE, SFX_CALLMODE_RECORD, &aPostureItem, 0L);
637             UpdateItem(SID_ATTR_CHAR_POSTURE);
638             break;
639         }
640         case TBI_UNDERLINE:
641         {
642             EndTracking();
643             if(meUnderline == UNDERLINE_NONE)
644             {
645                 meUnderline = UNDERLINE_SINGLE;
646                 SvxUnderlineItem aLineItem(meUnderline, SID_ATTR_CHAR_UNDERLINE);
647                 aLineItem.SetColor(meUnderlineColor);
648                 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L);
649             }
650             else
651             {
652                 meUnderline = UNDERLINE_NONE;
653                 SvxUnderlineItem aLineItem(meUnderline, SID_ATTR_CHAR_UNDERLINE);
654                 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L);
655             }
656             UpdateItem(SID_ATTR_CHAR_UNDERLINE);
657             break;
658         }
659         case TBI_STRIKEOUT:
660         {
661             EndTracking();
662             if(meStrike !=  STRIKEOUT_NONE && meStrike != STRIKEOUT_DONTKNOW)
663                 meStrike = STRIKEOUT_NONE;
664             else
665                 meStrike = STRIKEOUT_SINGLE;
666             SvxCrossedOutItem aStrikeItem(meStrike,SID_ATTR_CHAR_STRIKEOUT);
667             mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_STRIKEOUT, SFX_CALLMODE_RECORD, &aStrikeItem, 0L);
668             UpdateItem(SID_ATTR_CHAR_STRIKEOUT);
669             break;
670         }
671         case TBI_SHADOWED:
672         {
673             EndTracking();
674             mbShadow = !mbShadow;
675             SvxShadowedItem aShadowItem(mbShadow, SID_ATTR_CHAR_SHADOWED);
676             mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_SHADOWED, SFX_CALLMODE_RECORD, &aShadowItem, 0L);
677             UpdateItem(SID_ATTR_CHAR_SHADOWED);
678             break;
679         }
680     }
681     return 0;
682 }
683 
684 
685 
686 
687 IMPL_LINK(TextPropertyPanel, ToolboxIncDecSelectHdl, ToolBox*, pToolBox)
688 {
689     const sal_uInt16 nId = pToolBox->GetCurItemId();
690 
691     // font size +/- enhancement in sd
692     switch (maContext.GetCombinedContext_DI())
693     {
694         case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
695         case CombinedEnumContext(Application_DrawImpress, Context_Text):
696         case CombinedEnumContext(Application_DrawImpress, Context_Table):
697         case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
698         case CombinedEnumContext(Application_DrawImpress, Context_Draw):
699         case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
700         case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
701             if(nId == TBI_INCREASE)
702             {
703                 EndTracking();
704                 SfxVoidItem aItem(SID_GROW_FONT_SIZE);
705                 mpBindings->GetDispatcher()->Execute( SID_GROW_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L );
706             }
707             else if(nId == TBI_DECREASE)
708             {
709                 EndTracking();
710                 SfxVoidItem aItem(SID_SHRINK_FONT_SIZE);
711                 mpBindings->GetDispatcher()->Execute( SID_SHRINK_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L );
712             }
713             break;
714 
715         default:
716             if(nId == TBI_INCREASE)
717             {
718                 EndTracking();
719                 mbFocusOnFontSizeCtrl = false;
720                 sal_Int64 iValue = maFontSizeBox.GetValue();
721                 int iPos = maFontSizeBox.GetValuePos(iValue, FUNIT_NONE);
722                 long nSize = iValue;
723                 if(iPos != LISTBOX_ENTRY_NOTFOUND)
724                     nSize = maFontSizeBox.GetValue(iPos+1 , FUNIT_NONE);
725                 else if(iValue >= 100 && iValue < 105)
726                     nSize = 105;
727                 else if(iValue >= 105 && iValue < 110)
728                     nSize = 110;
729                 else if(iValue < 960)
730                 {
731                     nSize = (nSize / 10) * 10 + 10;
732                     while(maFontSizeBox.GetValuePos(nSize, FUNIT_NONE) == LISTBOX_ENTRY_NOTFOUND)
733                         nSize += 10;
734                 }
735                 else
736                 {
737                     nSize = iValue;
738                 }
739 
740                 float fSize = (float)nSize / 10;
741 
742                 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric();
743                 SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ;
744 
745                 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L );
746                 mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false);
747                 maFontSizeBox.SetValue( nSize );
748             }
749             else if(nId == TBI_DECREASE)
750             {
751                 EndTracking();
752                 mbFocusOnFontSizeCtrl = false;
753                 sal_Int64 iValue = maFontSizeBox.GetValue();
754                 int iPos = maFontSizeBox.GetValuePos(iValue, FUNIT_NONE);
755                 long nSize = iValue;
756                 if(iPos != LISTBOX_ENTRY_NOTFOUND)
757                     nSize = maFontSizeBox.GetValue(iPos-1 , FUNIT_NONE);
758                 else if(iValue > 100 && iValue <= 105)
759                     nSize = 100;
760                 else if(iValue > 105 && iValue <= 110)
761                     nSize = 105;
762                 else if(iValue > 960)
763                 {
764                     nSize = 960;
765                 }
766                 else if(iValue > 60)
767                 {
768                     nSize = (nSize / 10) * 10 ;
769                     while(maFontSizeBox.GetValuePos(nSize, FUNIT_NONE) == LISTBOX_ENTRY_NOTFOUND)
770                         nSize -= 10;
771                 }
772                 else
773                 {
774                     nSize = iValue;
775                 }
776 
777                 float fSize = (float)nSize / 10;
778 
779                 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric();
780                 SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ;
781 
782                 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L );
783                 mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false);
784                 maFontSizeBox.SetValue( nSize );
785             }
786 	}
787     UpdateItem(SID_ATTR_CHAR_FONTHEIGHT);
788 
789 	return 0;
790 }
791 
792 
793 
794 IMPL_LINK(TextPropertyPanel, ToolBoxUnderlineClickHdl, ToolBox*, pToolBox)
795 {
796 	const sal_uInt16 nId = pToolBox->GetCurItemId();
797 	OSL_ASSERT(nId == TBI_UNDERLINE);
798 	if(nId == TBI_UNDERLINE)
799 	{
800 		pToolBox->SetItemDown( nId, true );
801 		maUnderlinePopup.Rearrange(meUnderline);
802 		maUnderlinePopup.Show(*pToolBox);
803 
804 	}
805 	return 0L;
806 }
807 
808 
809 
810 
811 IMPL_LINK(TextPropertyPanel, ToolBoxFontColorDropHdl,ToolBox*, pToolBox)
812 {
813 	const sal_uInt16 nId = pToolBox->GetCurItemId();
814 	if(nId == TBI_FONTCOLOR)
815 	{
816 		pToolBox->SetItemDown( nId, true );
817 
818 		maFontColorPopup.Show(*pToolBox);
819 		maFontColorPopup.SetCurrentColor(maColor, mbColorAvailable);
820 	}
821 	return 0;
822 }
823 
824 
825 
826 
827 IMPL_LINK(TextPropertyPanel, ToolBoxSwScriptSelectHdl, ToolBox*, pToolBox)
828 {
829 	const sal_uInt16 nId = pToolBox->GetCurItemId();
830 	if( nId == TBI_SUPER_SW )
831 	{
832 		if(meEscape != SVX_ESCAPEMENT_SUPERSCRIPT)
833 		{
834 			meEscape = SVX_ESCAPEMENT_SUPERSCRIPT;
835 			SvxEscapementItem aSupItem(DFLT_ESC_SUPER, DFLT_ESC_PROP, SID_ATTR_CHAR_ESCAPEMENT);
836 			mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aSupItem, 0L );
837 		}
838 		else
839 		{
840 			meEscape = SVX_ESCAPEMENT_OFF;
841 			SvxEscapementItem aNoneItem(0, 100, SID_ATTR_CHAR_ESCAPEMENT);
842 			mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aNoneItem, 0L );
843 		}
844 	}
845 	else if(TBI_SUB_SW == nId)
846 	{
847 		if(meEscape != SVX_ESCAPEMENT_SUBSCRIPT)
848 		{
849 			meEscape = (SvxEscapement)SVX_ESCAPEMENT_SUBSCRIPT;
850 			SvxEscapementItem aSubItem(DFLT_ESC_SUB, DFLT_ESC_PROP, SID_ATTR_CHAR_ESCAPEMENT);
851 			mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aSubItem, 0L );
852 		}
853 		else
854 		{
855 			meEscape = SVX_ESCAPEMENT_OFF;
856 			SvxEscapementItem aNoneItem(0, 100, SID_ATTR_CHAR_ESCAPEMENT);
857 			mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aNoneItem, 0L );
858 		}
859 	}
860     UpdateItem(SID_ATTR_CHAR_ESCAPEMENT);
861 
862 	return 0;
863 }
864 
865 
866 
867 
868 IMPL_LINK(TextPropertyPanel, ToolBoxScriptSelectHdl, ToolBox*, pToolBox)
869 {
870 	const sal_uInt16 nId = pToolBox->GetCurItemId();
871 	if( nId == TBI_SUPER )
872 	{
873 		mbSuper = !mbSuper;
874 		SfxBoolItem aSupItem(SID_SET_SUPER_SCRIPT, mbSuper);
875 		mpBindings->GetDispatcher()->Execute( SID_SET_SUPER_SCRIPT, SFX_CALLMODE_RECORD, &aSupItem, 0L );
876         UpdateItem(SID_SET_SUPER_SCRIPT);
877 	}
878 	else if(TBI_SUB == nId)
879 	{
880 
881 		mbSub = !mbSub;
882 		SfxBoolItem aSubItem(SID_SET_SUB_SCRIPT, mbSub );
883 		mpBindings->GetDispatcher()->Execute( SID_SET_SUB_SCRIPT, SFX_CALLMODE_RECORD, &aSubItem, 0L );
884         UpdateItem(SID_SET_SUB_SCRIPT);
885 	}
886 	return 0;
887 }
888 
889 
890 
891 
892 IMPL_LINK(TextPropertyPanel, ToolBoxHighlightDropHdl, ToolBox*, pToolBox)
893 {
894 	const sal_uInt16 nId = pToolBox->GetCurItemId();
895 	if(nId == TBI_HIGHLIGHT)
896 	{
897 		pToolBox->SetItemDown( nId, true );
898 		maBrushColorPopup.Show(*pToolBox);
899 		maBrushColorPopup.SetCurrentColor(maBackColor, mbBackColorAvailable);
900 
901 	}
902 	return 0;
903 }
904 
905 
906 
907 IMPL_LINK(TextPropertyPanel, SpacingClickHdl, ToolBox*, pToolBox)
908 {
909 	const sal_uInt16 nId = pToolBox->GetCurItemId();
910 	OSL_ASSERT(nId == TBI_SPACING);
911 	if(nId == TBI_SPACING)
912 	{
913 		pToolBox->SetItemDown( nId, true );
914 		maCharSpacePopup.Rearrange(mbKernLBAvailable,mbKernAvailable,mlKerning);
915 		maCharSpacePopup.Show(*pToolBox);
916 
917 	}
918 	return 0L;
919 }
920 
921 
922 
923 
924 void TextPropertyPanel::NotifyItemUpdate (
925     const sal_uInt16 nSID,
926     const SfxItemState eState,
927     const SfxPoolItem* pState,
928     const bool bIsEnabled)
929 {
930     switch(nSID)
931     {
932         case SID_ATTR_CHAR_FONT:
933         {
934             bool bIsControlEnabled (bIsEnabled);
935             if (  eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxFontItem) )
936             {
937                 const SvxFontItem* pFontItem = (const SvxFontItem*)pState;
938                 mpFontNameBox->SetText( pFontItem->GetFamilyName() );
939             }
940             else
941             {
942                 mpFontNameBox->SetText( String() );
943                 if (SFX_ITEM_DISABLED == eState)
944                     bIsControlEnabled = false;
945             }
946             mpFontNameBox->Enable(bIsControlEnabled);
947             break;
948         }
949         case SID_ATTR_CHAR_FONTHEIGHT:
950         {
951             bool bIsControlEnabled (bIsEnabled);
952             if (  eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxFontHeightItem) )
953             {
954                 mpHeightItem = (SvxFontHeightItem*)pState;//const SvxFontHeightItem*
955                 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric();
956                 long iValue = (long)CalcToPoint( mpHeightItem->GetHeight(), eUnit, 10 );
957                 mpToolBoxIncDec->Enable();
958 
959                 mpToolBoxIncDec->SetItemState(TBI_INCREASE, STATE_NOCHECK);
960                 mpToolBoxIncDec->SetItemState(TBI_DECREASE, STATE_NOCHECK);
961 
962                 if( mbFocusOnFontSizeCtrl )
963                     return;
964 
965                 maFontSizeBox.SetValue( iValue );
966                 maFontSizeBox.LoseFocus();
967 
968                 UpdateItem(SID_SHRINK_FONT_SIZE);
969                 UpdateItem(SID_GROW_FONT_SIZE);
970             }
971             else
972             {
973                 mpHeightItem = NULL;
974                 maFontSizeBox.SetText( String() );
975                 //increase decrease diabled when multi-seletion have different font size
976 
977                 // font size +/- enhancement in sd
978                 switch(maContext.GetCombinedContext_DI())
979                 {
980                     case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
981                     case CombinedEnumContext(Application_DrawImpress, Context_Text):
982                     case CombinedEnumContext(Application_DrawImpress, Context_Table):
983                     case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
984                     case CombinedEnumContext(Application_DrawImpress, Context_Draw):
985                     case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
986                     case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
987                         break;
988 
989                     default:
990                         mpToolBoxIncDec->Disable();
991                 }
992                 if ( eState <= SFX_ITEM_READONLY )
993                     bIsControlEnabled = false;
994             }
995             maFontSizeBox.Enable(bIsControlEnabled);
996             break;
997         }
998 
999         case SID_ATTR_CHAR_WEIGHT:
1000             mbWeightAvailable = (eState >= SFX_ITEM_DONTCARE);
1001             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxWeightItem))
1002             {
1003                 const SvxWeightItem* pItem = (const SvxWeightItem*)pState;
1004                 meWeight = (FontWeight)pItem->GetValue();
1005             }
1006             else
1007             {
1008                 meWeight = WEIGHT_NORMAL;
1009             }
1010             mpToolBoxFont->EnableItem(TBI_BOLD, mbWeightAvailable && bIsEnabled);
1011             mpToolBoxFont->SetItemState(TBI_BOLD, meWeight==WEIGHT_BOLD ? STATE_CHECK : STATE_NOCHECK);
1012             break;
1013 
1014         case SID_ATTR_CHAR_POSTURE:
1015             mbPostureAvailable = (eState >= SFX_ITEM_DONTCARE);
1016             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxPostureItem))
1017             {
1018                 const SvxPostureItem* pItem = (const SvxPostureItem*)pState;
1019                 meItalic = (FontItalic)pItem->GetValue();
1020             }
1021             else
1022             {
1023                 meItalic = ITALIC_NONE;
1024             }
1025             mpToolBoxFont->EnableItem(TBI_ITALIC, mbPostureAvailable && bIsEnabled);
1026             mpToolBoxFont->SetItemState(TBI_ITALIC,	meItalic==ITALIC_NORMAL ? STATE_CHECK : STATE_NOCHECK);
1027             break;
1028 
1029         case SID_ATTR_CHAR_UNDERLINE:
1030             if( eState >= SFX_ITEM_DEFAULT)
1031             {
1032                 if(pState->ISA(SvxUnderlineItem))
1033                 {
1034                     const SvxUnderlineItem* pItem = (const SvxUnderlineItem*)pState;
1035                     meUnderline = (FontUnderline)pItem->GetValue();
1036                     meUnderlineColor = pItem->GetColor();
1037                 }
1038             }
1039             else
1040             {
1041                 meUnderline = UNDERLINE_NONE;
1042             }
1043             mpToolBoxFont->EnableItem(TBI_UNDERLINE, bIsEnabled);
1044             mpToolBoxFont->SetItemState(TBI_UNDERLINE, meUnderline==UNDERLINE_NONE ? STATE_NOCHECK : STATE_CHECK);
1045             break;
1046 
1047         case SID_ATTR_CHAR_SHADOWED:
1048             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxShadowedItem))
1049             {
1050                 const SvxShadowedItem* pItem = (const SvxShadowedItem*)pState;
1051                 mbShadow = pItem->GetValue();
1052             }
1053             else
1054             {
1055                 mbShadow = false;
1056             }
1057             mpToolBoxFont->EnableItem(TBI_SHADOWED, bIsEnabled);
1058             mpToolBoxFont->SetItemState(TBI_SHADOWED, mbShadow ? STATE_CHECK : STATE_NOCHECK);
1059             break;
1060 
1061         case SID_ATTR_CHAR_STRIKEOUT:
1062             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxCrossedOutItem))
1063             {
1064                 const SvxCrossedOutItem* pItem = (const SvxCrossedOutItem*)pState;
1065                 meStrike = (FontStrikeout)pItem->GetValue();
1066             }
1067             else
1068             {
1069                 meStrike = STRIKEOUT_NONE;
1070             }
1071             mpToolBoxFont->EnableItem(TBI_STRIKEOUT, bIsEnabled);
1072             mpToolBoxFont->SetItemState(TBI_STRIKEOUT,
1073                 meStrike!=STRIKEOUT_NONE && meStrike!=STRIKEOUT_DONTKNOW
1074                     ? STATE_CHECK
1075                     : STATE_NOCHECK);
1076             break;
1077 
1078         case SID_ATTR_CHAR_COLOR:
1079             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxColorItem))
1080             {
1081                 const SvxColorItem* pItem =  (const SvxColorItem*)pState;
1082                 maColor = pItem->GetValue();
1083                 mbColorAvailable = true;
1084                 if (mpFontColorUpdater)
1085                     mpFontColorUpdater->Update(maColor);
1086             }
1087             else
1088             {
1089                 mbColorAvailable = false;
1090                 maColor.SetColor(COL_AUTO);
1091                 if (mpFontColorUpdater)
1092                     mpFontColorUpdater->Update(maColor);
1093             }
1094             mpToolBoxFontColor->EnableItem(TBI_FONTCOLOR, bIsEnabled);
1095             break;
1096 
1097         case SID_ATTR_BRUSH_CHAR:
1098             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxBrushItem))
1099             {
1100                 const SvxBrushItem* pItem =  (const SvxBrushItem*)pState;
1101                 maBackColor = pItem->GetColor();
1102                 mbBackColorAvailable = true;
1103                 if (mpHighlightUpdater)
1104                     mpHighlightUpdater->Update(maBackColor);
1105             }
1106             else
1107             {
1108                 mbBackColorAvailable = false;
1109                 maBackColor.SetColor(COL_AUTO);
1110                 if (mpHighlightUpdater)
1111                     mpHighlightUpdater->Update(maBackColor);
1112             }
1113             mpToolBoxHighlight->EnableItem(TBI_HIGHLIGHT, bIsEnabled);
1114             break;
1115 
1116         case SID_ATTR_CHAR_ESCAPEMENT:
1117         {
1118             bool bIsItemEnabled (true);
1119             if (eState == SFX_ITEM_AVAILABLE)
1120             {
1121                 if (pState->ISA(SvxEscapementItem))
1122                 {
1123                     const SvxEscapementItem* pItem = (const SvxEscapementItem *)pState;
1124                     short nEsc = pItem->GetEsc();
1125                     if(nEsc == 0)
1126                     {
1127                         meEscape = SVX_ESCAPEMENT_OFF;
1128                         mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK);
1129                         mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_NOCHECK);
1130                     }
1131                     else if(nEsc > 0)
1132                     {
1133                         meEscape = SVX_ESCAPEMENT_SUPERSCRIPT;
1134                         mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_CHECK);
1135                         mpToolBoxScriptSw->SetItemState(TBI_SUB_SW,	STATE_NOCHECK);
1136                     }
1137                     else
1138                     {
1139                         meEscape = SVX_ESCAPEMENT_SUBSCRIPT;
1140                         mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK);
1141                         mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_CHECK);
1142                     }
1143                 }
1144                 else
1145                 {
1146                     meEscape = SVX_ESCAPEMENT_OFF;
1147                     mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK);
1148                     mpToolBoxScriptSw->SetItemState(TBI_SUB_SW,	STATE_NOCHECK);
1149                 }
1150             }
1151             else if (eState == SFX_ITEM_DISABLED)
1152             {
1153                 bIsItemEnabled = false;
1154             }
1155             else
1156             {
1157                 meEscape = SVX_ESCAPEMENT_OFF;
1158             }
1159             mpToolBoxScriptSw->EnableItem(TBI_SUPER, bIsItemEnabled && bIsEnabled);
1160             mpToolBoxScriptSw->EnableItem(TBI_SUB, bIsItemEnabled && bIsEnabled);
1161             break;
1162         }
1163 
1164         case SID_SET_SUB_SCRIPT:
1165             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SfxBoolItem))
1166             {
1167                 const SfxBoolItem* pItem = (const SfxBoolItem*)pState;
1168                 mbSub = pItem->GetValue();
1169             }
1170             else
1171             {
1172                 mbSub = false;
1173             }
1174             mpToolBoxScript->EnableItem(TBI_SUB, bIsEnabled);
1175             mpToolBoxScript->SetItemState(TBI_SUB, mbSub ? STATE_CHECK : STATE_NOCHECK);
1176             break;
1177 
1178         case SID_SET_SUPER_SCRIPT:
1179             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SfxBoolItem))
1180             {
1181                 const SfxBoolItem* pItem = (const SfxBoolItem*)pState;
1182                 mbSuper = pItem->GetValue();
1183             }
1184             else
1185             {
1186                 mbSuper = false;
1187             }
1188             mpToolBoxScript->EnableItem(TBI_SUPER, bIsEnabled);
1189             mpToolBoxScript->SetItemState(TBI_SUPER, mbSuper ? STATE_CHECK : STATE_NOCHECK);
1190             break;
1191 
1192         case SID_ATTR_CHAR_KERNING:
1193             if ( SFX_ITEM_AVAILABLE == eState )
1194             {
1195                 mbKernLBAvailable = true;
1196 
1197                 if(pState->ISA(SvxKerningItem))
1198                 {
1199                     const SvxKerningItem* pKerningItem  = (const SvxKerningItem*)pState;
1200                     mlKerning = (long)pKerningItem->GetValue();
1201                     mbKernAvailable = true;
1202                 }
1203                 else
1204                 {
1205                     mlKerning = 0;
1206                     mbKernAvailable =false;
1207                 }
1208             }
1209             else if (SFX_ITEM_DISABLED == eState)
1210             {
1211                 mbKernLBAvailable = false;
1212                 mbKernAvailable = false;
1213                 mlKerning = 0;
1214             }
1215             else
1216             {
1217                 mbKernLBAvailable = true;
1218                 mbKernAvailable = false;
1219                 mlKerning = 0;
1220             }
1221             mpToolBoxSpacing->EnableItem(TBI_SPACING, bIsEnabled);
1222             break;
1223 
1224             // font size +/- enhancement in sd
1225         case SID_SHRINK_FONT_SIZE:
1226         case SID_GROW_FONT_SIZE:
1227             switch(maContext.GetCombinedContext_DI())
1228             {
1229                 case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
1230                 case CombinedEnumContext(Application_DrawImpress, Context_Text):
1231                 case CombinedEnumContext(Application_DrawImpress, Context_Table):
1232                 case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
1233                 case CombinedEnumContext(Application_DrawImpress, Context_Draw):
1234                 case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
1235                 case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
1236                     if(eState == SFX_ITEM_DISABLED)
1237                         mpToolBoxIncDec->Disable();
1238                     else
1239                         mpToolBoxIncDec->Enable();
1240                 break;
1241             }
1242             const sal_Int32 nSize (maFontSizeBox.GetValue());
1243             if (nSID == SID_GROW_FONT_SIZE)
1244                 mpToolBoxIncDec->EnableItem(TBI_INCREASE, bIsEnabled && nSize<960);
1245             else
1246                 mpToolBoxIncDec->EnableItem(TBI_DECREASE, bIsEnabled && nSize>60);
1247             break;
1248     }
1249 }
1250 
1251 
1252 
1253 
1254 void TextPropertyPanel::UpdateItem (const sal_uInt16 nSlotId)
1255 {
1256     switch (nSlotId)
1257     {
1258         case SID_ATTR_CHAR_FONT:
1259             maFontNameControl.RequestUpdate();
1260             break;
1261         case SID_ATTR_CHAR_FONTHEIGHT:
1262             maFontSizeControl.RequestUpdate();
1263             break;
1264         case SID_ATTR_CHAR_WEIGHT:
1265             maWeightControl.RequestUpdate();
1266             break;
1267         case SID_ATTR_CHAR_POSTURE:
1268             maItalicControl.RequestUpdate();
1269             break;
1270         case SID_ATTR_CHAR_UNDERLINE:
1271             maUnderlineControl.RequestUpdate();
1272             break;
1273         case SID_ATTR_CHAR_STRIKEOUT:
1274             maStrikeControl.RequestUpdate();
1275             break;
1276         case SID_ATTR_CHAR_SHADOWED:
1277             maShadowControl.RequestUpdate();
1278             break;
1279         case SID_ATTR_CHAR_COLOR:
1280             maFontColorControl.RequestUpdate();
1281             break;
1282         case SID_ATTR_CHAR_ESCAPEMENT:
1283             maScriptControlSw.RequestUpdate();
1284             break;
1285         case SID_SET_SUPER_SCRIPT:
1286             maSuperScriptControl.RequestUpdate();
1287             break;
1288         case SID_SET_SUB_SCRIPT:
1289             maSubScriptControl.RequestUpdate();
1290             break;
1291         case SID_ATTR_CHAR_KERNING:
1292             maSpacingControl.RequestUpdate();
1293             break;
1294         case SID_ATTR_BRUSH_CHAR:
1295             maHighlightControl.RequestUpdate();
1296             break;
1297         case SID_GROW_FONT_SIZE:
1298             maSDFontGrow.RequestUpdate();
1299             break;
1300         case SID_SHRINK_FONT_SIZE:
1301             maSDFontShrink.RequestUpdate();
1302             break;
1303     }
1304 }
1305 
1306 
1307 
1308 
1309 
1310 void TextPropertyPanel::SetFontColor (
1311     const String& /* rsColorName */,
1312     const Color aColor)
1313 {
1314 	SvxColorItem aColorItem(aColor, SID_ATTR_CHAR_COLOR);
1315 	mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR, SFX_CALLMODE_RECORD, &aColorItem, 0L);
1316 	maColor = aColor;
1317 }
1318 
1319 void TextPropertyPanel::SetBrushColor (
1320     const String& /* rsColorName */,
1321     const Color aColor)
1322 {
1323 	SvxBrushItem aBrushItem(aColor, SID_ATTR_BRUSH_CHAR);
1324 	mpBindings->GetDispatcher()->Execute(SID_ATTR_BRUSH_CHAR, SFX_CALLMODE_RECORD, &aBrushItem, 0L);
1325 	maBackColor = aColor;
1326 }
1327 
1328 Color& TextPropertyPanel::GetUnderlineColor()
1329 {
1330 	return meUnderlineColor;
1331 }
1332 
1333 void TextPropertyPanel::SetUnderline(FontUnderline	eUnderline)
1334 {
1335 	meUnderline = eUnderline;
1336 }
1337 
1338 
1339 
1340 } } // end of namespace svx::sidebar
1341