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