1b9e67834SAndre Fischer /**************************************************************
2b9e67834SAndre Fischer  *
3b9e67834SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4b9e67834SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5b9e67834SAndre Fischer  * distributed with this work for additional information
6b9e67834SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7b9e67834SAndre Fischer  * to you under the Apache License, Version 2.0 (the
8b9e67834SAndre Fischer  * "License"); you may not use this file except in compliance
9b9e67834SAndre Fischer  * with the License.  You may obtain a copy of the License at
10b9e67834SAndre Fischer  *
11b9e67834SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12b9e67834SAndre Fischer  *
13b9e67834SAndre Fischer  * Unless required by applicable law or agreed to in writing,
14b9e67834SAndre Fischer  * software distributed under the License is distributed on an
15b9e67834SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b9e67834SAndre Fischer  * KIND, either express or implied.  See the License for the
17b9e67834SAndre Fischer  * specific language governing permissions and limitations
18b9e67834SAndre Fischer  * under the License.
19b9e67834SAndre Fischer  *
20b9e67834SAndre Fischer  *************************************************************/
21b9e67834SAndre Fischer 
22b9e67834SAndre Fischer #include "precompiled_svx.hxx"
23b9e67834SAndre Fischer 
24b9e67834SAndre Fischer #include "TextPropertyPanel.hrc"
25b9e67834SAndre Fischer #include "TextPropertyPanel.hxx"
26b9e67834SAndre Fischer #include "SvxSBFontNameBox.hxx"
27b9e67834SAndre Fischer 
28b9e67834SAndre Fischer #include "svx/dialmgr.hxx"
29b9e67834SAndre Fischer 
30b9e67834SAndre Fischer #include <editeng/brshitem.hxx>
31b9e67834SAndre Fischer #include <editeng/colritem.hxx>
32b9e67834SAndre Fischer #include <editeng/crsditem.hxx>
33b9e67834SAndre Fischer #include <editeng/escpitem.hxx>
34b9e67834SAndre Fischer #include <editeng/flstitem.hxx>
35b9e67834SAndre Fischer #include <editeng/fontitem.hxx>
36b9e67834SAndre Fischer #include <editeng/kernitem.hxx>
37b9e67834SAndre Fischer #include <editeng/postitem.hxx>
38b9e67834SAndre Fischer #include <editeng/shdditem.hxx>
39b9e67834SAndre Fischer #include <editeng/udlnitem.hxx>
40b9e67834SAndre Fischer #include <editeng/wghtitem.hxx>
41b9e67834SAndre Fischer #include <rtl/ref.hxx>
42b9e67834SAndre Fischer #include <sfx2/dispatch.hxx>
43b9e67834SAndre Fischer #include <sfx2/objsh.hxx>
44b9e67834SAndre Fischer #include <sfx2/viewsh.hxx>
45d29c2fc2SAndre Fischer #include <sfx2/sidebar/ResourceDefinitions.hrc>
46b9e67834SAndre Fischer #include <sfx2/sidebar/ControlFactory.hxx>
47*ae13266dSAndre Fischer #include <sfx2/sidebar/ControllerFactory.hxx>
48b9e67834SAndre Fischer #include <sfx2/sidebar/Theme.hxx>
49*ae13266dSAndre Fischer #include <sfx2/sidebar/SidebarToolBox.hxx>
5095a18594SAndre Fischer #include "sfx2/imagemgr.hxx"
51b9e67834SAndre Fischer #include <svtools/ctrltool.hxx>
52b9e67834SAndre Fischer #include <svtools/unitconv.hxx>
53b9e67834SAndre Fischer 
54b9e67834SAndre Fischer #include <vcl/gradient.hxx>
55b9e67834SAndre Fischer #include <vcl/svapp.hxx>
5695a18594SAndre Fischer #include <vcl/toolbox.hxx>
57d4aefcaeSZheng Fan #include "TextCharacterSpacingControl.hxx"
58d4aefcaeSZheng Fan #include "TextCharacterSpacingPopup.hxx"
59d4aefcaeSZheng Fan #include "TextUnderlineControl.hxx"
60d4aefcaeSZheng Fan #include "TextUnderlinePopup.hxx"
61facb16e7SArmin Le Grand #include <svx/sidebar/ColorControl.hxx>
62facb16e7SArmin Le Grand #include <svx/sidebar/PopupContainer.hxx>
63d4aefcaeSZheng Fan 
64d4aefcaeSZheng Fan #include <boost/bind.hpp>
65b9e67834SAndre Fischer 
66b9e67834SAndre Fischer using namespace css;
67b9e67834SAndre Fischer using namespace cssu;
68b9e67834SAndre Fischer using ::sfx2::sidebar::Theme;
697a32b0c8SAndre Fischer using ::sfx2::sidebar::ControlFactory;
70b9e67834SAndre Fischer 
71b9e67834SAndre Fischer #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
72b9e67834SAndre Fischer 
73b9e67834SAndre Fischer namespace svx { namespace sidebar {
74b9e67834SAndre Fischer 
75b9e67834SAndre Fischer #undef HAS_IA2
76b9e67834SAndre Fischer 
77b9e67834SAndre Fischer 
78d4aefcaeSZheng Fan 
79bc7f1831SAndre Fischer PopupControl* TextPropertyPanel::CreateCharacterSpacingControl (PopupContainer* pParent)
80d4aefcaeSZheng Fan {
8145da7d5eSAndre Fischer     return new TextCharacterSpacingControl(pParent, *this, mpBindings);
82d4aefcaeSZheng Fan }
83b9e67834SAndre Fischer 
84d4aefcaeSZheng Fan PopupControl* TextPropertyPanel::CreateUnderlinePopupControl (PopupContainer* pParent)
85d4aefcaeSZheng Fan {
8645da7d5eSAndre Fischer 	return new TextUnderlineControl(pParent, *this, mpBindings);
87d4aefcaeSZheng Fan }
88b9e67834SAndre Fischer 
89b7a56e95SArmin Le Grand namespace
90b7a56e95SArmin Le Grand {
91b7a56e95SArmin Le Grand     Color GetAutomaticColor(void)
92b7a56e95SArmin Le Grand     {
93b7a56e95SArmin Le Grand         return COL_AUTO;
94b7a56e95SArmin Le Grand     }
95b7a56e95SArmin Le Grand } // end of anonymous namespace
96b7a56e95SArmin Le Grand 
97d4aefcaeSZheng Fan long TextPropertyPanel::GetSelFontSize()
98d4aefcaeSZheng Fan {
99d4aefcaeSZheng Fan     long nH = 240;
100d4aefcaeSZheng Fan     SfxMapUnit eUnit = maSpacingControl.GetCoreMetric();
101d4aefcaeSZheng Fan     if (mpHeightItem)
102d4aefcaeSZheng Fan         nH = LogicToLogic(  mpHeightItem->GetHeight(), (MapUnit)eUnit, MAP_TWIP );
103d4aefcaeSZheng Fan     return nH;
104d4aefcaeSZheng Fan }
105b9e67834SAndre Fischer 
106b9e67834SAndre Fischer 
10795a18594SAndre Fischer TextPropertyPanel* TextPropertyPanel::Create (
108b9e67834SAndre Fischer     Window* pParent,
109b9e67834SAndre Fischer     const cssu::Reference<css::frame::XFrame>& rxFrame,
110*ae13266dSAndre Fischer     SfxBindings* pBindings,
111*ae13266dSAndre Fischer     const ::sfx2::sidebar::EnumContext& rContext)
112b9e67834SAndre Fischer {
113b9e67834SAndre Fischer     if (pParent == NULL)
114b9e67834SAndre Fischer         throw lang::IllegalArgumentException(A2S("no parent Window given to TextPropertyPanel::Create"), NULL, 0);
115b9e67834SAndre Fischer     if ( ! rxFrame.is())
116b9e67834SAndre Fischer         throw lang::IllegalArgumentException(A2S("no XFrame given to TextPropertyPanel::Create"), NULL, 1);
117b9e67834SAndre Fischer     if (pBindings == NULL)
118b9e67834SAndre Fischer         throw lang::IllegalArgumentException(A2S("no SfxBindings given to TextPropertyPanel::Create"), NULL, 2);
119b9e67834SAndre Fischer 
12095a18594SAndre Fischer     return new TextPropertyPanel(
12195a18594SAndre Fischer         pParent,
12295a18594SAndre Fischer         rxFrame,
123*ae13266dSAndre Fischer         pBindings,
124*ae13266dSAndre Fischer         rContext);
125b9e67834SAndre Fischer }
126b9e67834SAndre Fischer 
127b9e67834SAndre Fischer 
128d4aefcaeSZheng Fan ::sfx2::sidebar::ControllerItem& TextPropertyPanel::GetSpaceController()
129d4aefcaeSZheng Fan {
130d4aefcaeSZheng Fan 	return maSpacingControl;
131d4aefcaeSZheng Fan }
132b9e67834SAndre Fischer 
133b9e67834SAndre Fischer TextPropertyPanel::TextPropertyPanel (
134b9e67834SAndre Fischer     Window* pParent,
135b9e67834SAndre Fischer     const cssu::Reference<css::frame::XFrame>& rxFrame,
136*ae13266dSAndre Fischer     SfxBindings* pBindings,
137*ae13266dSAndre Fischer     const ::sfx2::sidebar::EnumContext& rContext)
1388ce66e53SOliver-Rainer Wittmann     :   Control(pParent, SVX_RES(RID_SIDEBAR_TEXT_PANEL)),
139b9e67834SAndre Fischer         mpFontNameBox (new SvxSBFontNameBox(this, SVX_RES(CB_SBFONT_FONT))),
1408ce66e53SOliver-Rainer Wittmann         maFontSizeBox		(this, SVX_RES(MB_SBFONT_FONTSIZE)),
1417a32b0c8SAndre Fischer         mpToolBoxFontBackground(ControlFactory::CreateToolBoxBackground(this)),
1427a32b0c8SAndre Fischer         mpToolBoxFont(ControlFactory::CreateToolBox(
1437a32b0c8SAndre Fischer                 mpToolBoxFontBackground.get(),
1447a32b0c8SAndre Fischer                 SVX_RES(TB_FONT))),
14552d13b84SAndre Fischer         mpToolBoxIncDecBackground(ControlFactory::CreateToolBoxBackground(this)),
14652d13b84SAndre Fischer         mpToolBoxIncDec(ControlFactory::CreateToolBox(
14752d13b84SAndre Fischer                 mpToolBoxIncDecBackground.get(),
14852d13b84SAndre Fischer                 SVX_RES(TB_INCREASE_DECREASE))),
1497a32b0c8SAndre Fischer         mpToolBoxScriptBackground(ControlFactory::CreateToolBoxBackground(this)),
1507a32b0c8SAndre Fischer         mpToolBoxScript(ControlFactory::CreateToolBox(
1517a32b0c8SAndre Fischer                 mpToolBoxScriptBackground.get(),
1527a32b0c8SAndre Fischer                 SVX_RES(TB_SCRIPT))),
1537a32b0c8SAndre Fischer         mpToolBoxScriptSwBackground(ControlFactory::CreateToolBoxBackground(this)),
1547a32b0c8SAndre Fischer         mpToolBoxScriptSw(ControlFactory::CreateToolBox(
1557a32b0c8SAndre Fischer                 mpToolBoxScriptSwBackground.get(),
1567a32b0c8SAndre Fischer                 SVX_RES(TB_SCRIPT_SW))),
1577a32b0c8SAndre Fischer         mpToolBoxSpacingBackground(ControlFactory::CreateToolBoxBackground(this)),
1587a32b0c8SAndre Fischer         mpToolBoxSpacing(ControlFactory::CreateToolBox(
1597a32b0c8SAndre Fischer                 mpToolBoxSpacingBackground.get(),
1607a32b0c8SAndre Fischer                 SVX_RES(TB_SPACING))),
16152d13b84SAndre Fischer         mpToolBoxFontColorBackground(ControlFactory::CreateToolBoxBackground(this)),
16252d13b84SAndre Fischer         mpToolBoxFontColor(ControlFactory::CreateToolBox(
16352d13b84SAndre Fischer                 mpToolBoxFontColorBackground.get(),
164*ae13266dSAndre Fischer                 rContext.GetApplication_DI() == sfx2::sidebar::EnumContext::Application_WriterVariants
165*ae13266dSAndre Fischer                     ? SVX_RES(TB_FONTCOLOR_SW)
166*ae13266dSAndre Fischer                     : SVX_RES(TB_FONTCOLOR),
167*ae13266dSAndre Fischer                 rxFrame)),
1687a32b0c8SAndre Fischer         mpToolBoxHighlightBackground(ControlFactory::CreateToolBoxBackground(this)),
1697a32b0c8SAndre Fischer         mpToolBoxHighlight(ControlFactory::CreateToolBox(
1707a32b0c8SAndre Fischer                 mpToolBoxHighlightBackground.get(),
171*ae13266dSAndre Fischer                 SVX_RES(TB_HIGHLIGHT),
172*ae13266dSAndre Fischer                 rxFrame)),
173b9e67834SAndre Fischer         mpFontColorUpdater(),
174b9e67834SAndre Fischer         mpHighlightUpdater(),
175b9e67834SAndre Fischer 
17645da7d5eSAndre Fischer         maFontNameControl	(SID_ATTR_CHAR_FONT,		*pBindings, *this, A2S("CharFontName"), rxFrame),
17745da7d5eSAndre Fischer         maFontSizeControl	(SID_ATTR_CHAR_FONTHEIGHT,	*pBindings, *this, A2S("FontHeight"),   rxFrame),
17845da7d5eSAndre Fischer         maWeightControl		(SID_ATTR_CHAR_WEIGHT,		*pBindings, *this, A2S("Bold"),         rxFrame),
17945da7d5eSAndre Fischer         maItalicControl		(SID_ATTR_CHAR_POSTURE,		*pBindings, *this, A2S("Italic"),       rxFrame),
18045da7d5eSAndre Fischer         maUnderlineControl	(SID_ATTR_CHAR_UNDERLINE,	*pBindings, *this, A2S("Underline"),    rxFrame),
18145da7d5eSAndre Fischer         maStrikeControl		(SID_ATTR_CHAR_STRIKEOUT,	*pBindings, *this, A2S("Strikeout"),    rxFrame),
18245da7d5eSAndre Fischer         maShadowControl		(SID_ATTR_CHAR_SHADOWED,	*pBindings, *this, A2S("Shadowed"),     rxFrame),
18345da7d5eSAndre Fischer         maScriptControlSw	(SID_ATTR_CHAR_ESCAPEMENT,	*pBindings, *this, A2S("Escapement"),   rxFrame),
18445da7d5eSAndre Fischer         maSuperScriptControl(SID_SET_SUPER_SCRIPT,		*pBindings, *this, A2S("SuperScript"),  rxFrame),
18545da7d5eSAndre Fischer         maSubScriptControl	(SID_SET_SUB_SCRIPT,		*pBindings, *this, A2S("SubScript"),    rxFrame),
18645da7d5eSAndre Fischer         maSpacingControl	(SID_ATTR_CHAR_KERNING,		*pBindings, *this, A2S("Spacing"),      rxFrame),
18745da7d5eSAndre Fischer         maSDFontGrow		(SID_GROW_FONT_SIZE,		*pBindings, *this, A2S("Grow"),         rxFrame),
18845da7d5eSAndre Fischer         maSDFontShrink		(SID_SHRINK_FONT_SIZE,		*pBindings, *this, A2S("Shrink"),       rxFrame),
189b9e67834SAndre Fischer 
190b9e67834SAndre Fischer         mpFontList			(NULL),
191b9e67834SAndre Fischer         mbMustDelete		(false),
192b9e67834SAndre Fischer         mbFocusOnFontSizeCtrl(false),
19345da7d5eSAndre Fischer         maCharSpacePopup(this, ::boost::bind(&TextPropertyPanel::CreateCharacterSpacingControl, this, _1)),
19445da7d5eSAndre Fischer         maUnderlinePopup(this, ::boost::bind(&TextPropertyPanel::CreateUnderlinePopupControl, this, _1)),
19595a18594SAndre Fischer         mxFrame(rxFrame),
196b9e67834SAndre Fischer         maContext(),
197f79579d2SAndre Fischer         mpBindings(pBindings)
198b9e67834SAndre Fischer {
199b9e67834SAndre Fischer 	Initialize();
200*ae13266dSAndre Fischer 
201b9e67834SAndre Fischer 	FreeResource();
202b9e67834SAndre Fischer }
203b9e67834SAndre Fischer 
204b9e67834SAndre Fischer 
205b9e67834SAndre Fischer 
206b9e67834SAndre Fischer 
207b9e67834SAndre Fischer TextPropertyPanel::~TextPropertyPanel (void)
208b9e67834SAndre Fischer {
209b9e67834SAndre Fischer     if(mbMustDelete)
210b9e67834SAndre Fischer         delete mpFontList;
211b9e67834SAndre Fischer 
2127a32b0c8SAndre Fischer     // Destroy the toolbox windows.
2137a32b0c8SAndre Fischer     mpToolBoxIncDec.reset();
2147a32b0c8SAndre Fischer     mpToolBoxFont.reset();
2157a32b0c8SAndre Fischer     mpToolBoxFontColor.reset();
2167a32b0c8SAndre Fischer     mpToolBoxScript.reset();
2177a32b0c8SAndre Fischer     mpToolBoxScriptSw.reset();
2187a32b0c8SAndre Fischer     mpToolBoxSpacing.reset();
2197a32b0c8SAndre Fischer     mpToolBoxHighlight.reset();
2207a32b0c8SAndre Fischer 
2217a32b0c8SAndre Fischer     // Destroy the background windows of the toolboxes.
2227a32b0c8SAndre Fischer     mpToolBoxIncDecBackground.reset();
2237a32b0c8SAndre Fischer     mpToolBoxFontBackground.reset();
2247a32b0c8SAndre Fischer     mpToolBoxFontColorBackground.reset();
2257a32b0c8SAndre Fischer     mpToolBoxScriptBackground.reset();
2267a32b0c8SAndre Fischer     mpToolBoxScriptSwBackground.reset();
2277a32b0c8SAndre Fischer     mpToolBoxSpacingBackground.reset();
2287a32b0c8SAndre Fischer     mpToolBoxHighlightBackground.reset();
229b9e67834SAndre Fischer }
230b9e67834SAndre Fischer 
231b9e67834SAndre Fischer 
232b9e67834SAndre Fischer 
233b9e67834SAndre Fischer 
234d4aefcaeSZheng Fan void TextPropertyPanel::SetSpacing(long nKern)
235d4aefcaeSZheng Fan {
236d4aefcaeSZheng Fan 	mlKerning = nKern;
237d4aefcaeSZheng Fan }
23895a18594SAndre Fischer 
23995a18594SAndre Fischer 
240b9e67834SAndre Fischer void TextPropertyPanel::HandleContextChange (
241b9e67834SAndre Fischer     const ::sfx2::sidebar::EnumContext aContext)
242b9e67834SAndre Fischer {
243b9e67834SAndre Fischer     if (maContext == aContext)
244b9e67834SAndre Fischer     {
245b9e67834SAndre Fischer         // Nothing to do.
246b9e67834SAndre Fischer         return;
247b9e67834SAndre Fischer     }
248b9e67834SAndre Fischer 
249b9e67834SAndre Fischer     maContext = aContext;
25065be1ea2SAndre Fischer     switch (maContext.GetCombinedContext_DI())
251b9e67834SAndre Fischer     {
252b9e67834SAndre Fischer         case CombinedEnumContext(Application_Calc, Context_Cell):
253b9e67834SAndre Fischer         case CombinedEnumContext(Application_Calc, Context_Pivot):
2548ce66e53SOliver-Rainer Wittmann             mpToolBoxScriptSw->Hide();
255b9e67834SAndre Fischer             mpToolBoxHighlight->Hide();
256f79579d2SAndre Fischer             mpToolBoxScript->Disable();
257f79579d2SAndre Fischer             mpToolBoxSpacing->Disable();
258f79579d2SAndre Fischer             break;
259f79579d2SAndre Fischer 
260f79579d2SAndre Fischer         case CombinedEnumContext(Application_Calc, Context_EditCell):
261f79579d2SAndre Fischer         case CombinedEnumContext(Application_Calc, Context_DrawText):
262f79579d2SAndre Fischer             mpToolBoxScriptSw->Hide();
263f79579d2SAndre Fischer             mpToolBoxHighlight->Hide();
264f79579d2SAndre Fischer             mpToolBoxScript->Enable();
265f79579d2SAndre Fischer             mpToolBoxSpacing->Enable();
266b9e67834SAndre Fischer             break;
267b9e67834SAndre Fischer 
26885f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_Text):
26985f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_Table):
270b9e67834SAndre Fischer             mpToolBoxScriptSw->Show();
271b9e67834SAndre Fischer             mpToolBoxScript->Hide();
272b9e67834SAndre Fischer             mpToolBoxHighlight->Show();
273b9e67834SAndre Fischer             mpToolBoxSpacing->Show();
274b9e67834SAndre Fischer             break;
275b9e67834SAndre Fischer 
27685f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
27785f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
278b9e67834SAndre Fischer             mpToolBoxScriptSw->Show();
279b9e67834SAndre Fischer             mpToolBoxScript->Hide();
280b9e67834SAndre Fischer             mpToolBoxSpacing->Show();
281b9e67834SAndre Fischer             mpToolBoxHighlight->Hide();
282b9e67834SAndre Fischer             break;
283b9e67834SAndre Fischer 
28437fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
28537fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Text):
28637fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Table):
28737fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
28837fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Draw):
28937fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
29037fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
291b9e67834SAndre Fischer             mpToolBoxScriptSw->Hide();
292b9e67834SAndre Fischer             mpToolBoxScript->Show();
293b9e67834SAndre Fischer             mpToolBoxSpacing->Show();
294b9e67834SAndre Fischer             mpToolBoxHighlight->Hide();
295b9e67834SAndre Fischer             break;
296b9e67834SAndre Fischer 
297b9e67834SAndre Fischer         default:
298b9e67834SAndre Fischer             break;
299b9e67834SAndre Fischer     }
300b9e67834SAndre Fischer }
301b9e67834SAndre Fischer 
30245da7d5eSAndre Fischer 
303b9e67834SAndre Fischer 
304b9e67834SAndre Fischer 
305b9e67834SAndre Fischer void TextPropertyPanel::DataChanged (const DataChangedEvent& rEvent)
306b9e67834SAndre Fischer {
30795a18594SAndre Fischer     (void)rEvent;
30895a18594SAndre Fischer 
30945da7d5eSAndre Fischer     SetupToolboxItems();
310b9e67834SAndre Fischer }
311b9e67834SAndre Fischer 
312b9e67834SAndre Fischer 
313b9e67834SAndre Fischer 
314bc7f1831SAndre Fischer 
315b9e67834SAndre Fischer void TextPropertyPanel::Initialize (void)
316b9e67834SAndre Fischer {
31795a18594SAndre Fischer     //<<modify fill font list
31895a18594SAndre Fischer     SfxObjectShell* pDocSh = SfxObjectShell::Current();
319b9e67834SAndre Fischer     const SfxPoolItem* pItem = NULL;
320b9e67834SAndre Fischer 
321b9e67834SAndre Fischer     if (pDocSh != NULL)
322b9e67834SAndre Fischer         pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
323b9e67834SAndre Fischer     if (pItem != NULL)
324b9e67834SAndre Fischer         mpFontList = ( (SvxFontListItem*)pItem )->GetFontList();
325b9e67834SAndre Fischer     else
326b9e67834SAndre Fischer     {
327b9e67834SAndre Fischer         mpFontList = new FontList( Application::GetDefaultDevice() );
32845da7d5eSAndre Fischer         mbMustDelete = true;
329b9e67834SAndre Fischer     }
330b9e67834SAndre Fischer 
331b9e67834SAndre Fischer     mpFontNameBox->SetAccessibleName(mpFontNameBox->GetQuickHelpText());
33295a18594SAndre Fischer     const FontInfo aFontInfo (mpFontList->Get( String::CreateFromAscii( "" ), String::CreateFromAscii( "" )));
33395a18594SAndre Fischer     maFontSizeBox.Fill(&aFontInfo,mpFontList);
33495a18594SAndre Fischer     maFontSizeBox.SetAccessibleName(maFontSizeBox.GetQuickHelpText());
335b9e67834SAndre Fischer 
3368ce66e53SOliver-Rainer Wittmann     //toolbox
33745da7d5eSAndre Fischer     SetupToolboxItems();
33895a18594SAndre Fischer     InitToolBoxIncDec();
33995a18594SAndre Fischer     InitToolBoxFont();
34095a18594SAndre Fischer     InitToolBoxScript();
34195a18594SAndre Fischer     InitToolBoxSpacing();
342b9e67834SAndre Fischer 
343b9e67834SAndre Fischer #ifdef HAS_IA2
344d4aefcaeSZheng Fan     mpFontNameBox->SetAccRelationLabeledBy(&mpFontNameBox);
345d4aefcaeSZheng Fan     mpFontNameBox->SetMpSubEditAccLableBy(&mpFontNameBox);
346b9e67834SAndre Fischer     maFontSizeBox.SetAccRelationLabeledBy(&maFontSizeBox);
34795a18594SAndre Fischer     maFontSizeBox.SetMpSubEditAccLableBy(&maFontSizeBox);
348d4aefcaeSZheng Fan     mpToolBoxFont.SetAccRelationLabeledBy(&mpToolBoxFont);
349d4aefcaeSZheng Fan     mpToolBoxIncDec.SetAccRelationLabeledBy(&mpToolBoxIncDec);
350d4aefcaeSZheng Fan     mpToolBoxFontColor.SetAccRelationLabeledBy(&mpToolBoxFontColor);
351d4aefcaeSZheng Fan     mpToolBoxScript.SetAccRelationLabeledBy(&mpToolBoxScript);
352d4aefcaeSZheng Fan     mpToolBoxScriptSw.SetAccRelationLabeledBy(&mpToolBoxScriptSw);
353d4aefcaeSZheng Fan     mpToolBoxSpacing.SetAccRelationLabeledBy(&mpToolBoxSpacing);
354d4aefcaeSZheng Fan     mpToolBoxHighlight.SetAccRelationLabeledBy(&mpToolBoxHighlight);
355b9e67834SAndre Fischer #endif
356b9e67834SAndre Fischer 
35795a18594SAndre Fischer     //init state
35895a18594SAndre Fischer     mpHeightItem = NULL;
35995a18594SAndre Fischer     meWeight = WEIGHT_NORMAL;
36095a18594SAndre Fischer     meItalic = ITALIC_NONE;
36195a18594SAndre Fischer     mbShadow = false;
36295a18594SAndre Fischer     meStrike = STRIKEOUT_NONE;
36395a18594SAndre Fischer     mbPostureAvailable = true;
36495a18594SAndre Fischer     mbWeightAvailable = true;
36595a18594SAndre Fischer     meUnderline = UNDERLINE_NONE;
366*ae13266dSAndre Fischer     meUnderlineColor = COL_AUTO;
36795a18594SAndre Fischer     meEscape = SVX_ESCAPEMENT_OFF;
36895a18594SAndre Fischer     mbSuper = false;
36995a18594SAndre Fischer     mbSub = false;
37095a18594SAndre Fischer     mbKernAvailable = true;
37195a18594SAndre Fischer     mbKernLBAvailable = true;
37295a18594SAndre Fischer     mlKerning = 0;
373*ae13266dSAndre Fischer 
37495a18594SAndre Fischer     //set handler
37595a18594SAndre Fischer     mpFontNameBox->SetBindings(mpBindings);
37695a18594SAndre Fischer     Link aLink = LINK(this, TextPropertyPanel, FontSelHdl);
37795a18594SAndre Fischer     mpFontNameBox->SetSelectHdl(aLink);
37895a18594SAndre Fischer     aLink = LINK(this, TextPropertyPanel, FontSizeModifyHdl);
37995a18594SAndre Fischer     maFontSizeBox.SetModifyHdl(aLink);
38095a18594SAndre Fischer     aLink = LINK(this, TextPropertyPanel, FontSizeSelHdl);
38195a18594SAndre Fischer     maFontSizeBox.SetSelectHdl(aLink);
38295a18594SAndre Fischer     aLink = LINK(this, TextPropertyPanel, FontSizeLoseFocus);
38395a18594SAndre Fischer     maFontSizeBox.SetLoseFocusHdl(aLink);
384b9e67834SAndre Fischer }
385b9e67834SAndre Fischer 
386d4aefcaeSZheng Fan void TextPropertyPanel::EndSpacingPopupMode (void)
387d4aefcaeSZheng Fan {
388d4aefcaeSZheng Fan     maCharSpacePopup.Hide();
389d4aefcaeSZheng Fan }
390b9e67834SAndre Fischer 
391d4aefcaeSZheng Fan void TextPropertyPanel::EndUnderlinePopupMode (void)
392d4aefcaeSZheng Fan {
393d4aefcaeSZheng Fan 	maUnderlinePopup.Hide();
394d4aefcaeSZheng Fan }
395b9e67834SAndre Fischer 
396b9e67834SAndre Fischer 
397b9e67834SAndre Fischer void TextPropertyPanel::InitToolBoxFont()
398b9e67834SAndre Fischer {
399b9e67834SAndre Fischer 	mpToolBoxFont->SetBackground(Wallpaper());
400b9e67834SAndre Fischer 	mpToolBoxFont->SetPaintTransparent(true);
401b9e67834SAndre Fischer 
402b9e67834SAndre Fischer 	Size aTbxSize( mpToolBoxFont->CalcWindowSizePixel() );
403b9e67834SAndre Fischer 	mpToolBoxFont->SetOutputSizePixel( aTbxSize );
404b9e67834SAndre Fischer 
405b9e67834SAndre Fischer 	Link aLink  = LINK(this, TextPropertyPanel, ToolboxFontSelectHandler);
406b9e67834SAndre Fischer 	mpToolBoxFont->SetSelectHdl ( aLink );
407b9e67834SAndre Fischer 	aLink = LINK(this, TextPropertyPanel, ToolBoxUnderlineClickHdl);
408b9e67834SAndre Fischer 	mpToolBoxFont->SetDropdownClickHdl(aLink);
409b9e67834SAndre Fischer }
410b9e67834SAndre Fischer 
411b9e67834SAndre Fischer 
412b9e67834SAndre Fischer 
413b9e67834SAndre Fischer 
414b9e67834SAndre Fischer void TextPropertyPanel::InitToolBoxIncDec()
415b9e67834SAndre Fischer {
416b9e67834SAndre Fischer 	Size aTbxSize( mpToolBoxIncDec->CalcWindowSizePixel() );
417b9e67834SAndre Fischer 	mpToolBoxIncDec->SetOutputSizePixel( aTbxSize );
418b9e67834SAndre Fischer 
419b9e67834SAndre Fischer 	Link aLink = LINK(this, TextPropertyPanel, ToolboxIncDecSelectHdl);
420b9e67834SAndre Fischer     mpToolBoxIncDec->SetSelectHdl ( aLink );
421b9e67834SAndre Fischer }
422b9e67834SAndre Fischer 
423b9e67834SAndre Fischer 
424b9e67834SAndre Fischer 
425b9e67834SAndre Fischer 
426b9e67834SAndre Fischer void TextPropertyPanel::InitToolBoxScript()
427b9e67834SAndre Fischer {
428b9e67834SAndre Fischer 	Size aTbxSize( mpToolBoxScriptSw->CalcWindowSizePixel() );
429b9e67834SAndre Fischer 	mpToolBoxScriptSw->SetOutputSizePixel( aTbxSize );
430b9e67834SAndre Fischer 
431b9e67834SAndre Fischer 	Link aLink = LINK(this, TextPropertyPanel, ToolBoxSwScriptSelectHdl);
432b9e67834SAndre Fischer     mpToolBoxScriptSw->SetSelectHdl ( aLink );
433b9e67834SAndre Fischer 
434b9e67834SAndre Fischer 	aTbxSize = mpToolBoxScript->CalcWindowSizePixel() ;
435b9e67834SAndre Fischer 	mpToolBoxScript->SetOutputSizePixel( aTbxSize );
436b9e67834SAndre Fischer 
437b9e67834SAndre Fischer 	aLink = LINK(this, TextPropertyPanel, ToolBoxScriptSelectHdl);
438b9e67834SAndre Fischer     mpToolBoxScript->SetSelectHdl ( aLink );
439b9e67834SAndre Fischer }
440b9e67834SAndre Fischer void TextPropertyPanel::InitToolBoxSpacing()
441b9e67834SAndre Fischer {
442b9e67834SAndre Fischer 	Size aTbxSize( mpToolBoxSpacing->CalcWindowSizePixel() );
443b9e67834SAndre Fischer 	mpToolBoxSpacing->SetOutputSizePixel( aTbxSize );
444b9e67834SAndre Fischer 	mpToolBoxSpacing->SetItemBits( TBI_SPACING, mpToolBoxSpacing->GetItemBits( TBI_SPACING ) | TIB_DROPDOWNONLY );
445b9e67834SAndre Fischer 
446b9e67834SAndre Fischer 	Link aLink = LINK(this, TextPropertyPanel, SpacingClickHdl);
447b9e67834SAndre Fischer     mpToolBoxSpacing->SetDropdownClickHdl ( aLink );
448b9e67834SAndre Fischer 	mpToolBoxSpacing->SetSelectHdl( aLink );
449b9e67834SAndre Fischer }
450b9e67834SAndre Fischer 
451b9e67834SAndre Fischer 
452b9e67834SAndre Fischer 
453b9e67834SAndre Fischer 
45445da7d5eSAndre Fischer void TextPropertyPanel::SetupToolboxItems (void)
455b9e67834SAndre Fischer {
45645da7d5eSAndre Fischer     maSDFontGrow.SetupToolBoxItem(*mpToolBoxIncDec, TBI_INCREASE);
45745da7d5eSAndre Fischer     maSDFontShrink.SetupToolBoxItem(*mpToolBoxIncDec, TBI_DECREASE);
45845da7d5eSAndre Fischer 
45945da7d5eSAndre Fischer     maWeightControl.SetupToolBoxItem(*mpToolBoxFont, TBI_BOLD);
4608ce66e53SOliver-Rainer Wittmann     maItalicControl.SetupToolBoxItem(*mpToolBoxFont, TBI_ITALIC);
4618ce66e53SOliver-Rainer Wittmann     maUnderlineControl.SetupToolBoxItem(*mpToolBoxFont, TBI_UNDERLINE);
4628ce66e53SOliver-Rainer Wittmann     maStrikeControl.SetupToolBoxItem(*mpToolBoxFont, TBI_STRIKEOUT);
4638ce66e53SOliver-Rainer Wittmann     maShadowControl.SetupToolBoxItem(*mpToolBoxFont, TBI_SHADOWED);
46445da7d5eSAndre Fischer 
46545da7d5eSAndre Fischer     //for sw
46645da7d5eSAndre Fischer     maSuperScriptControl.SetupToolBoxItem(*mpToolBoxScriptSw, TBI_SUPER_SW);
46745da7d5eSAndre Fischer     maSubScriptControl.SetupToolBoxItem(*mpToolBoxScriptSw, TBI_SUB_SW);
46845da7d5eSAndre Fischer     //for sc and sd
469ccab7bc0SAndre Fischer     maSuperScriptControl.SetupToolBoxItem(*mpToolBoxScript, TBI_SUPER);
47045da7d5eSAndre Fischer     maSubScriptControl.SetupToolBoxItem(*mpToolBoxScript, TBI_SUB);
47145da7d5eSAndre Fischer     maSpacingControl.SetupToolBoxItem(*mpToolBoxSpacing, TBI_SPACING);
472b9e67834SAndre Fischer }
473b9e67834SAndre Fischer 
474b9e67834SAndre Fischer 
475b9e67834SAndre Fischer 
476b9e67834SAndre Fischer 
477b9e67834SAndre Fischer IMPL_LINK( TextPropertyPanel, FontSelHdl, FontNameBox*, pBox )
478b9e67834SAndre Fischer {
479b9e67834SAndre Fischer 	if ( !pBox->IsTravelSelect() )
480b9e67834SAndre Fischer 	{
481b9e67834SAndre Fischer 		if( SfxViewShell::Current() )
482b9e67834SAndre Fischer 		{
483b9e67834SAndre Fischer 			Window* pShellWnd = SfxViewShell::Current()->GetWindow();
484b9e67834SAndre Fischer 
485b9e67834SAndre Fischer 			if ( pShellWnd )
486b9e67834SAndre Fischer 				pShellWnd->GrabFocus();
487b9e67834SAndre Fischer 		}
488b9e67834SAndre Fischer 	}
489b9e67834SAndre Fischer 	return 0;
490b9e67834SAndre Fischer }
4918ce66e53SOliver-Rainer Wittmann 
492b9e67834SAndre Fischer IMPL_LINK( TextPropertyPanel, FontSizeModifyHdl, FontSizeBox*, pSizeBox )
493b9e67834SAndre Fischer {
494b9e67834SAndre Fischer 	if (pSizeBox == &maFontSizeBox)
495b9e67834SAndre Fischer 	{
496b9e67834SAndre Fischer 		long nSize = pSizeBox->GetValue();
497b9e67834SAndre Fischer 		mbFocusOnFontSizeCtrl = true;
498b9e67834SAndre Fischer 
499b9e67834SAndre Fischer 		float fSize = (float)nSize / 10;
500b9e67834SAndre Fischer 		SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric();
501b9e67834SAndre Fischer 		SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ;
502b9e67834SAndre Fischer 
503b9e67834SAndre Fischer 		mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L );
504b9e67834SAndre Fischer 		mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false);
505b9e67834SAndre Fischer 	}
506b9e67834SAndre Fischer 	return 0;
507b9e67834SAndre Fischer }
5088ce66e53SOliver-Rainer Wittmann 
509b9e67834SAndre Fischer IMPL_LINK( TextPropertyPanel, FontSizeSelHdl, FontSizeBox*, pSizeBox )
510b9e67834SAndre Fischer {
511b9e67834SAndre Fischer 	if ( !pSizeBox->IsTravelSelect() )
512b9e67834SAndre Fischer 	{
513b9e67834SAndre Fischer 		if( SfxViewShell::Current() )
514b9e67834SAndre Fischer 		{
515b9e67834SAndre Fischer 			Window* pShellWnd = SfxViewShell::Current()->GetWindow();
516b9e67834SAndre Fischer 
517b9e67834SAndre Fischer 			if ( pShellWnd )
518b9e67834SAndre Fischer 				pShellWnd->GrabFocus();
519b9e67834SAndre Fischer 		}
520b9e67834SAndre Fischer 	}
521b9e67834SAndre Fischer 
522b9e67834SAndre Fischer 	return 0;
523b9e67834SAndre Fischer }
5248ce66e53SOliver-Rainer Wittmann 
525b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, FontSizeLoseFocus, FontSizeBox*, pSizeBox)
526b9e67834SAndre Fischer {
527b9e67834SAndre Fischer 	if(pSizeBox == &maFontSizeBox)
528b9e67834SAndre Fischer 	{
529b9e67834SAndre Fischer 		mbFocusOnFontSizeCtrl = false;
530b9e67834SAndre Fischer 	}
531b9e67834SAndre Fischer 	return 0;
532b9e67834SAndre Fischer }
533b9e67834SAndre Fischer 
534b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, ToolboxFontSelectHandler, ToolBox*, pToolBox)
535b9e67834SAndre Fischer {
5368ce66e53SOliver-Rainer Wittmann     const sal_uInt16 nId = pToolBox->GetCurItemId();
537b9e67834SAndre Fischer 
5388ce66e53SOliver-Rainer Wittmann     switch (nId)
53945da7d5eSAndre Fischer     {
54045da7d5eSAndre Fischer         case TBI_BOLD:
54145da7d5eSAndre Fischer         {
54245da7d5eSAndre Fischer             EndTracking();
54345da7d5eSAndre Fischer             if(meWeight != WEIGHT_BOLD)
54445da7d5eSAndre Fischer                 meWeight = WEIGHT_BOLD;
54545da7d5eSAndre Fischer             else
54645da7d5eSAndre Fischer                 meWeight = WEIGHT_NORMAL;
54745da7d5eSAndre Fischer             SvxWeightItem aWeightItem(meWeight, SID_ATTR_CHAR_WEIGHT);
54845da7d5eSAndre Fischer             mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_WEIGHT, SFX_CALLMODE_RECORD, &aWeightItem, 0L);
54945da7d5eSAndre Fischer             UpdateItem(SID_ATTR_CHAR_WEIGHT);
55045da7d5eSAndre Fischer             break;
55145da7d5eSAndre Fischer         }
55245da7d5eSAndre Fischer         case TBI_ITALIC:
55345da7d5eSAndre Fischer         {
55445da7d5eSAndre Fischer             EndTracking();
55545da7d5eSAndre Fischer             if(meItalic != ITALIC_NORMAL)
55645da7d5eSAndre Fischer                 meItalic = ITALIC_NORMAL;
55745da7d5eSAndre Fischer             else
55845da7d5eSAndre Fischer                 meItalic = ITALIC_NONE;
55945da7d5eSAndre Fischer             SvxPostureItem aPostureItem(meItalic, SID_ATTR_CHAR_POSTURE);
56045da7d5eSAndre Fischer             mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_POSTURE, SFX_CALLMODE_RECORD, &aPostureItem, 0L);
56145da7d5eSAndre Fischer             UpdateItem(SID_ATTR_CHAR_POSTURE);
56245da7d5eSAndre Fischer             break;
56345da7d5eSAndre Fischer         }
56445da7d5eSAndre Fischer         case TBI_UNDERLINE:
56545da7d5eSAndre Fischer         {
56645da7d5eSAndre Fischer             EndTracking();
56745da7d5eSAndre Fischer             if(meUnderline == UNDERLINE_NONE)
56845da7d5eSAndre Fischer             {
56945da7d5eSAndre Fischer                 meUnderline = UNDERLINE_SINGLE;
57045da7d5eSAndre Fischer                 SvxUnderlineItem aLineItem(meUnderline, SID_ATTR_CHAR_UNDERLINE);
57145da7d5eSAndre Fischer                 aLineItem.SetColor(meUnderlineColor);
57245da7d5eSAndre Fischer                 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L);
57345da7d5eSAndre Fischer             }
57445da7d5eSAndre Fischer             else
57545da7d5eSAndre Fischer             {
57645da7d5eSAndre Fischer                 meUnderline = UNDERLINE_NONE;
57745da7d5eSAndre Fischer                 SvxUnderlineItem aLineItem(meUnderline, SID_ATTR_CHAR_UNDERLINE);
57845da7d5eSAndre Fischer                 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L);
57945da7d5eSAndre Fischer             }
58045da7d5eSAndre Fischer             UpdateItem(SID_ATTR_CHAR_UNDERLINE);
5818ce66e53SOliver-Rainer Wittmann             break;
58245da7d5eSAndre Fischer         }
58345da7d5eSAndre Fischer         case TBI_STRIKEOUT:
58445da7d5eSAndre Fischer         {
58545da7d5eSAndre Fischer             EndTracking();
58645da7d5eSAndre Fischer             if(meStrike !=  STRIKEOUT_NONE && meStrike != STRIKEOUT_DONTKNOW)
58745da7d5eSAndre Fischer                 meStrike = STRIKEOUT_NONE;
58845da7d5eSAndre Fischer             else
58945da7d5eSAndre Fischer                 meStrike = STRIKEOUT_SINGLE;
59045da7d5eSAndre Fischer             SvxCrossedOutItem aStrikeItem(meStrike,SID_ATTR_CHAR_STRIKEOUT);
59145da7d5eSAndre Fischer             mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_STRIKEOUT, SFX_CALLMODE_RECORD, &aStrikeItem, 0L);
59245da7d5eSAndre Fischer             UpdateItem(SID_ATTR_CHAR_STRIKEOUT);
59345da7d5eSAndre Fischer             break;
59445da7d5eSAndre Fischer         }
59545da7d5eSAndre Fischer         case TBI_SHADOWED:
59645da7d5eSAndre Fischer         {
59745da7d5eSAndre Fischer             EndTracking();
59845da7d5eSAndre Fischer             mbShadow = !mbShadow;
59945da7d5eSAndre Fischer             SvxShadowedItem aShadowItem(mbShadow, SID_ATTR_CHAR_SHADOWED);
60045da7d5eSAndre Fischer             mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_SHADOWED, SFX_CALLMODE_RECORD, &aShadowItem, 0L);
60145da7d5eSAndre Fischer             UpdateItem(SID_ATTR_CHAR_SHADOWED);
60245da7d5eSAndre Fischer             break;
60345da7d5eSAndre Fischer         }
6048ce66e53SOliver-Rainer Wittmann     }
6058ce66e53SOliver-Rainer Wittmann     return 0;
606b9e67834SAndre Fischer }
607b9e67834SAndre Fischer 
608b9e67834SAndre Fischer 
609b9e67834SAndre Fischer 
610b9e67834SAndre Fischer 
611b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, ToolboxIncDecSelectHdl, ToolBox*, pToolBox)
612b9e67834SAndre Fischer {
6138ce66e53SOliver-Rainer Wittmann     const sal_uInt16 nId = pToolBox->GetCurItemId();
614b9e67834SAndre Fischer 
6158ce66e53SOliver-Rainer Wittmann     // font size +/- enhancement in sd
61645da7d5eSAndre Fischer     switch (maContext.GetCombinedContext_DI())
617b9e67834SAndre Fischer     {
61845da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
61945da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Text):
62045da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Table):
62145da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
62245da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Draw):
62345da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
62445da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
625b9e67834SAndre Fischer             if(nId == TBI_INCREASE)
626b9e67834SAndre Fischer             {
627b9e67834SAndre Fischer                 EndTracking();
628b9e67834SAndre Fischer                 SfxVoidItem aItem(SID_GROW_FONT_SIZE);
629b9e67834SAndre Fischer                 mpBindings->GetDispatcher()->Execute( SID_GROW_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L );
630b9e67834SAndre Fischer             }
631b9e67834SAndre Fischer             else if(nId == TBI_DECREASE)
632b9e67834SAndre Fischer             {
633b9e67834SAndre Fischer                 EndTracking();
634b9e67834SAndre Fischer                 SfxVoidItem aItem(SID_SHRINK_FONT_SIZE);
635b9e67834SAndre Fischer                 mpBindings->GetDispatcher()->Execute( SID_SHRINK_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L );
636b9e67834SAndre Fischer             }
637b9e67834SAndre Fischer             break;
638b9e67834SAndre Fischer 
639b9e67834SAndre Fischer         default:
640b9e67834SAndre Fischer             if(nId == TBI_INCREASE)
641b9e67834SAndre Fischer             {
642b9e67834SAndre Fischer                 EndTracking();
643b9e67834SAndre Fischer                 mbFocusOnFontSizeCtrl = false;
644b9e67834SAndre Fischer                 sal_Int64 iValue = maFontSizeBox.GetValue();
645b9e67834SAndre Fischer                 int iPos = maFontSizeBox.GetValuePos(iValue, FUNIT_NONE);
646b9e67834SAndre Fischer                 long nSize = iValue;
647b9e67834SAndre Fischer                 if(iPos != LISTBOX_ENTRY_NOTFOUND)
648b9e67834SAndre Fischer                     nSize = maFontSizeBox.GetValue(iPos+1 , FUNIT_NONE);
649b9e67834SAndre Fischer                 else if(iValue >= 100 && iValue < 105)
650b9e67834SAndre Fischer                     nSize = 105;
651b9e67834SAndre Fischer                 else if(iValue >= 105 && iValue < 110)
652b9e67834SAndre Fischer                     nSize = 110;
653b9e67834SAndre Fischer                 else if(iValue < 960)
654b9e67834SAndre Fischer                 {
655b9e67834SAndre Fischer                     nSize = (nSize / 10) * 10 + 10;
656b9e67834SAndre Fischer                     while(maFontSizeBox.GetValuePos(nSize, FUNIT_NONE) == LISTBOX_ENTRY_NOTFOUND)
657b9e67834SAndre Fischer                         nSize += 10;
658b9e67834SAndre Fischer                 }
659b9e67834SAndre Fischer                 else
660b9e67834SAndre Fischer                 {
661b9e67834SAndre Fischer                     nSize = iValue;
662b9e67834SAndre Fischer                 }
663b9e67834SAndre Fischer 
664b9e67834SAndre Fischer                 float fSize = (float)nSize / 10;
665b9e67834SAndre Fischer 
666b9e67834SAndre Fischer                 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric();
667b9e67834SAndre Fischer                 SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ;
668b9e67834SAndre Fischer 
669b9e67834SAndre Fischer                 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L );
670b9e67834SAndre Fischer                 mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false);
671b9e67834SAndre Fischer                 maFontSizeBox.SetValue( nSize );
672b9e67834SAndre Fischer             }
673b9e67834SAndre Fischer             else if(nId == TBI_DECREASE)
674b9e67834SAndre Fischer             {
675b9e67834SAndre Fischer                 EndTracking();
676b9e67834SAndre Fischer                 mbFocusOnFontSizeCtrl = false;
677b9e67834SAndre Fischer                 sal_Int64 iValue = maFontSizeBox.GetValue();
678b9e67834SAndre Fischer                 int iPos = maFontSizeBox.GetValuePos(iValue, FUNIT_NONE);
679b9e67834SAndre Fischer                 long nSize = iValue;
680b9e67834SAndre Fischer                 if(iPos != LISTBOX_ENTRY_NOTFOUND)
681b9e67834SAndre Fischer                     nSize = maFontSizeBox.GetValue(iPos-1 , FUNIT_NONE);
682b9e67834SAndre Fischer                 else if(iValue > 100 && iValue <= 105)
683b9e67834SAndre Fischer                     nSize = 100;
684b9e67834SAndre Fischer                 else if(iValue > 105 && iValue <= 110)
685b9e67834SAndre Fischer                     nSize = 105;
686b9e67834SAndre Fischer                 else if(iValue > 960)
687b9e67834SAndre Fischer                 {
688b9e67834SAndre Fischer                     nSize = 960;
689b9e67834SAndre Fischer                 }
690b9e67834SAndre Fischer                 else if(iValue > 60)
691b9e67834SAndre Fischer                 {
692b9e67834SAndre Fischer                     nSize = (nSize / 10) * 10 ;
693b9e67834SAndre Fischer                     while(maFontSizeBox.GetValuePos(nSize, FUNIT_NONE) == LISTBOX_ENTRY_NOTFOUND)
694b9e67834SAndre Fischer                         nSize -= 10;
695b9e67834SAndre Fischer                 }
696b9e67834SAndre Fischer                 else
697b9e67834SAndre Fischer                 {
698b9e67834SAndre Fischer                     nSize = iValue;
699b9e67834SAndre Fischer                 }
700b9e67834SAndre Fischer 
701b9e67834SAndre Fischer                 float fSize = (float)nSize / 10;
702b9e67834SAndre Fischer 
703b9e67834SAndre Fischer                 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric();
704b9e67834SAndre Fischer                 SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ;
705b9e67834SAndre Fischer 
706b9e67834SAndre Fischer                 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L );
707b9e67834SAndre Fischer                 mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false);
708b9e67834SAndre Fischer                 maFontSizeBox.SetValue( nSize );
709b9e67834SAndre Fischer             }
710b9e67834SAndre Fischer 	}
71145da7d5eSAndre Fischer     UpdateItem(SID_ATTR_CHAR_FONTHEIGHT);
71245da7d5eSAndre Fischer 
713b9e67834SAndre Fischer 	return 0;
714b9e67834SAndre Fischer }
715b9e67834SAndre Fischer 
716b9e67834SAndre Fischer 
717b9e67834SAndre Fischer 
718b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, ToolBoxUnderlineClickHdl, ToolBox*, pToolBox)
719b9e67834SAndre Fischer {
720b9e67834SAndre Fischer 	const sal_uInt16 nId = pToolBox->GetCurItemId();
721d4aefcaeSZheng Fan 	OSL_ASSERT(nId == TBI_UNDERLINE);
722b9e67834SAndre Fischer 	if(nId == TBI_UNDERLINE)
723b9e67834SAndre Fischer 	{
724b9e67834SAndre Fischer 		pToolBox->SetItemDown( nId, true );
725d4aefcaeSZheng Fan 		maUnderlinePopup.Rearrange(meUnderline);
726d4aefcaeSZheng Fan 		maUnderlinePopup.Show(*pToolBox);
727b9e67834SAndre Fischer 
728b9e67834SAndre Fischer 	}
729d4aefcaeSZheng Fan 	return 0L;
730b9e67834SAndre Fischer }
731b9e67834SAndre Fischer 
732b9e67834SAndre Fischer 
733b9e67834SAndre Fischer 
734b9e67834SAndre Fischer 
735b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, ToolBoxSwScriptSelectHdl, ToolBox*, pToolBox)
736b9e67834SAndre Fischer {
737b9e67834SAndre Fischer 	const sal_uInt16 nId = pToolBox->GetCurItemId();
738b9e67834SAndre Fischer 	if( nId == TBI_SUPER_SW )
739b9e67834SAndre Fischer 	{
740b9e67834SAndre Fischer 		if(meEscape != SVX_ESCAPEMENT_SUPERSCRIPT)
741b9e67834SAndre Fischer 		{
742b9e67834SAndre Fischer 			meEscape = SVX_ESCAPEMENT_SUPERSCRIPT;
743b9e67834SAndre Fischer 			SvxEscapementItem aSupItem(DFLT_ESC_SUPER, DFLT_ESC_PROP, SID_ATTR_CHAR_ESCAPEMENT);
744b9e67834SAndre Fischer 			mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aSupItem, 0L );
745b9e67834SAndre Fischer 		}
746b9e67834SAndre Fischer 		else
747b9e67834SAndre Fischer 		{
748b9e67834SAndre Fischer 			meEscape = SVX_ESCAPEMENT_OFF;
749b9e67834SAndre Fischer 			SvxEscapementItem aNoneItem(0, 100, SID_ATTR_CHAR_ESCAPEMENT);
750b9e67834SAndre Fischer 			mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aNoneItem, 0L );
751b9e67834SAndre Fischer 		}
752b9e67834SAndre Fischer 	}
753b9e67834SAndre Fischer 	else if(TBI_SUB_SW == nId)
754b9e67834SAndre Fischer 	{
755b9e67834SAndre Fischer 		if(meEscape != SVX_ESCAPEMENT_SUBSCRIPT)
756b9e67834SAndre Fischer 		{
757b9e67834SAndre Fischer 			meEscape = (SvxEscapement)SVX_ESCAPEMENT_SUBSCRIPT;
758b9e67834SAndre Fischer 			SvxEscapementItem aSubItem(DFLT_ESC_SUB, DFLT_ESC_PROP, SID_ATTR_CHAR_ESCAPEMENT);
759b9e67834SAndre Fischer 			mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aSubItem, 0L );
760b9e67834SAndre Fischer 		}
761b9e67834SAndre Fischer 		else
762b9e67834SAndre Fischer 		{
763b9e67834SAndre Fischer 			meEscape = SVX_ESCAPEMENT_OFF;
764b9e67834SAndre Fischer 			SvxEscapementItem aNoneItem(0, 100, SID_ATTR_CHAR_ESCAPEMENT);
765b9e67834SAndre Fischer 			mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aNoneItem, 0L );
766b9e67834SAndre Fischer 		}
767b9e67834SAndre Fischer 	}
76845da7d5eSAndre Fischer     UpdateItem(SID_ATTR_CHAR_ESCAPEMENT);
769b9e67834SAndre Fischer 
770b9e67834SAndre Fischer 	return 0;
771b9e67834SAndre Fischer }
772b9e67834SAndre Fischer 
773b9e67834SAndre Fischer 
774b9e67834SAndre Fischer 
775b9e67834SAndre Fischer 
776b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, ToolBoxScriptSelectHdl, ToolBox*, pToolBox)
777b9e67834SAndre Fischer {
778b9e67834SAndre Fischer 	const sal_uInt16 nId = pToolBox->GetCurItemId();
779b9e67834SAndre Fischer 	if( nId == TBI_SUPER )
780b9e67834SAndre Fischer 	{
781b9e67834SAndre Fischer 		mbSuper = !mbSuper;
782b9e67834SAndre Fischer 		SfxBoolItem aSupItem(SID_SET_SUPER_SCRIPT, mbSuper);
783b9e67834SAndre Fischer 		mpBindings->GetDispatcher()->Execute( SID_SET_SUPER_SCRIPT, SFX_CALLMODE_RECORD, &aSupItem, 0L );
78445da7d5eSAndre Fischer         UpdateItem(SID_SET_SUPER_SCRIPT);
785b9e67834SAndre Fischer 	}
786b9e67834SAndre Fischer 	else if(TBI_SUB == nId)
787b9e67834SAndre Fischer 	{
788b9e67834SAndre Fischer 
789b9e67834SAndre Fischer 		mbSub = !mbSub;
790b9e67834SAndre Fischer 		SfxBoolItem aSubItem(SID_SET_SUB_SCRIPT, mbSub );
791b9e67834SAndre Fischer 		mpBindings->GetDispatcher()->Execute( SID_SET_SUB_SCRIPT, SFX_CALLMODE_RECORD, &aSubItem, 0L );
79245da7d5eSAndre Fischer         UpdateItem(SID_SET_SUB_SCRIPT);
793b9e67834SAndre Fischer 	}
794b9e67834SAndre Fischer 	return 0;
795b9e67834SAndre Fischer }
796b9e67834SAndre Fischer 
797b9e67834SAndre Fischer 
798b9e67834SAndre Fischer 
799b9e67834SAndre Fischer 
800b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, SpacingClickHdl, ToolBox*, pToolBox)
801b9e67834SAndre Fischer {
802b9e67834SAndre Fischer 	const sal_uInt16 nId = pToolBox->GetCurItemId();
803d4aefcaeSZheng Fan 	OSL_ASSERT(nId == TBI_SPACING);
804b9e67834SAndre Fischer 	if(nId == TBI_SPACING)
805b9e67834SAndre Fischer 	{
806b9e67834SAndre Fischer 		pToolBox->SetItemDown( nId, true );
807d4aefcaeSZheng Fan 		maCharSpacePopup.Rearrange(mbKernLBAvailable,mbKernAvailable,mlKerning);
808d4aefcaeSZheng Fan 		maCharSpacePopup.Show(*pToolBox);
809b9e67834SAndre Fischer 
810b9e67834SAndre Fischer 	}
811d4aefcaeSZheng Fan 	return 0L;
812b9e67834SAndre Fischer }
813b9e67834SAndre Fischer 
814b9e67834SAndre Fischer 
815b9e67834SAndre Fischer 
816b9e67834SAndre Fischer 
817b9e67834SAndre Fischer void TextPropertyPanel::NotifyItemUpdate (
818b9e67834SAndre Fischer     const sal_uInt16 nSID,
819b9e67834SAndre Fischer     const SfxItemState eState,
82045da7d5eSAndre Fischer     const SfxPoolItem* pState,
82145da7d5eSAndre Fischer     const bool bIsEnabled)
822b9e67834SAndre Fischer {
8238ce66e53SOliver-Rainer Wittmann     switch(nSID)
8248ce66e53SOliver-Rainer Wittmann     {
825b9e67834SAndre Fischer         case SID_ATTR_CHAR_FONT:
82645da7d5eSAndre Fischer         {
82745da7d5eSAndre Fischer             bool bIsControlEnabled (bIsEnabled);
828b9e67834SAndre Fischer             if (  eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxFontItem) )
829b9e67834SAndre Fischer             {
830b9e67834SAndre Fischer                 const SvxFontItem* pFontItem = (const SvxFontItem*)pState;
831b9e67834SAndre Fischer                 mpFontNameBox->SetText( pFontItem->GetFamilyName() );
832b9e67834SAndre Fischer             }
833b9e67834SAndre Fischer             else
834b9e67834SAndre Fischer             {
835b9e67834SAndre Fischer                 mpFontNameBox->SetText( String() );
836b9e67834SAndre Fischer                 if (SFX_ITEM_DISABLED == eState)
83745da7d5eSAndre Fischer                     bIsControlEnabled = false;
838b9e67834SAndre Fischer             }
83945da7d5eSAndre Fischer             mpFontNameBox->Enable(bIsControlEnabled);
840b9e67834SAndre Fischer             break;
84145da7d5eSAndre Fischer         }
842b9e67834SAndre Fischer         case SID_ATTR_CHAR_FONTHEIGHT:
84345da7d5eSAndre Fischer         {
84445da7d5eSAndre Fischer             bool bIsControlEnabled (bIsEnabled);
845b9e67834SAndre Fischer             if (  eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxFontHeightItem) )
846b9e67834SAndre Fischer             {
847b9e67834SAndre Fischer                 mpHeightItem = (SvxFontHeightItem*)pState;//const SvxFontHeightItem*
848b9e67834SAndre Fischer                 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric();
849bc7f1831SAndre Fischer                 const sal_Int64 nValue (CalcToPoint(mpHeightItem->GetHeight(), eUnit, 10 ));
850b9e67834SAndre Fischer                 mpToolBoxIncDec->Enable();
851b9e67834SAndre Fischer 
852b9e67834SAndre Fischer                 mpToolBoxIncDec->SetItemState(TBI_INCREASE, STATE_NOCHECK);
853b9e67834SAndre Fischer                 mpToolBoxIncDec->SetItemState(TBI_DECREASE, STATE_NOCHECK);
854b9e67834SAndre Fischer 
855bc7f1831SAndre Fischer                 // For Writer we have to update the states of the
856bc7f1831SAndre Fischer                 // increase and decrease buttons here, because we have
857bc7f1831SAndre Fischer                 // no access to the slots used by Writer.
858bc7f1831SAndre Fischer                 switch(maContext.GetCombinedContext_DI())
859bc7f1831SAndre Fischer                 {
860bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
861bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Text):
862bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Table):
863bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
864bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Draw):
865bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
866bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
867bc7f1831SAndre Fischer                         break;
868bc7f1831SAndre Fischer 
869bc7f1831SAndre Fischer                     default:
870bc7f1831SAndre Fischer                     {
871bc7f1831SAndre Fischer                         mpToolBoxIncDec->EnableItem(TBI_INCREASE, bIsEnabled && nValue<960);
872bc7f1831SAndre Fischer                         mpToolBoxIncDec->EnableItem(TBI_DECREASE, bIsEnabled && nValue>60);
873bc7f1831SAndre Fischer                         break;
874bc7f1831SAndre Fischer                     }
875bc7f1831SAndre Fischer                 }
876bc7f1831SAndre Fischer 
877b9e67834SAndre Fischer                 if( mbFocusOnFontSizeCtrl )
878b9e67834SAndre Fischer                     return;
879b9e67834SAndre Fischer 
880bc7f1831SAndre Fischer                 maFontSizeBox.SetValue(nValue);
881b9e67834SAndre Fischer                 maFontSizeBox.LoseFocus();
88245da7d5eSAndre Fischer 
88345da7d5eSAndre Fischer                 UpdateItem(SID_SHRINK_FONT_SIZE);
88445da7d5eSAndre Fischer                 UpdateItem(SID_GROW_FONT_SIZE);
885b9e67834SAndre Fischer             }
886b9e67834SAndre Fischer             else
8878ce66e53SOliver-Rainer Wittmann             {
888b9e67834SAndre Fischer                 mpHeightItem = NULL;
889b9e67834SAndre Fischer                 maFontSizeBox.SetText( String() );
890b9e67834SAndre Fischer                 //increase decrease diabled when multi-seletion have different font size
8918ce66e53SOliver-Rainer Wittmann 
892b9e67834SAndre Fischer                 // font size +/- enhancement in sd
89345da7d5eSAndre Fischer                 switch(maContext.GetCombinedContext_DI())
894b9e67834SAndre Fischer                 {
89545da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
89645da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Text):
89745da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Table):
89845da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
89945da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Draw):
90045da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
90145da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
902b9e67834SAndre Fischer                         break;
903b9e67834SAndre Fischer 
904b9e67834SAndre Fischer                     default:
905b9e67834SAndre Fischer                         mpToolBoxIncDec->Disable();
906b9e67834SAndre Fischer                 }
907b9e67834SAndre Fischer                 if ( eState <= SFX_ITEM_READONLY )
90845da7d5eSAndre Fischer                     bIsControlEnabled = false;
909b9e67834SAndre Fischer             }
91045da7d5eSAndre Fischer             maFontSizeBox.Enable(bIsControlEnabled);
91145da7d5eSAndre Fischer             break;
91245da7d5eSAndre Fischer         }
91345da7d5eSAndre Fischer 
914b9e67834SAndre Fischer         case SID_ATTR_CHAR_WEIGHT:
915b9e67834SAndre Fischer             mbWeightAvailable = (eState >= SFX_ITEM_DONTCARE);
916b9e67834SAndre Fischer             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxWeightItem))
917b9e67834SAndre Fischer             {
918b9e67834SAndre Fischer                 const SvxWeightItem* pItem = (const SvxWeightItem*)pState;
919b9e67834SAndre Fischer                 meWeight = (FontWeight)pItem->GetValue();
920b9e67834SAndre Fischer             }
921b9e67834SAndre Fischer             else
922b9e67834SAndre Fischer             {
923b9e67834SAndre Fischer                 meWeight = WEIGHT_NORMAL;
924b9e67834SAndre Fischer             }
92545da7d5eSAndre Fischer             mpToolBoxFont->EnableItem(TBI_BOLD, mbWeightAvailable && bIsEnabled);
92645da7d5eSAndre Fischer             mpToolBoxFont->SetItemState(TBI_BOLD, meWeight==WEIGHT_BOLD ? STATE_CHECK : STATE_NOCHECK);
927b9e67834SAndre Fischer             break;
92845da7d5eSAndre Fischer 
929b9e67834SAndre Fischer         case SID_ATTR_CHAR_POSTURE:
930b9e67834SAndre Fischer             mbPostureAvailable = (eState >= SFX_ITEM_DONTCARE);
931b9e67834SAndre Fischer             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxPostureItem))
932b9e67834SAndre Fischer             {
933b9e67834SAndre Fischer                 const SvxPostureItem* pItem = (const SvxPostureItem*)pState;
934b9e67834SAndre Fischer                 meItalic = (FontItalic)pItem->GetValue();
935b9e67834SAndre Fischer             }
936b9e67834SAndre Fischer             else
937b9e67834SAndre Fischer             {
938b9e67834SAndre Fischer                 meItalic = ITALIC_NONE;
939b9e67834SAndre Fischer             }
94045da7d5eSAndre Fischer             mpToolBoxFont->EnableItem(TBI_ITALIC, mbPostureAvailable && bIsEnabled);
94145da7d5eSAndre Fischer             mpToolBoxFont->SetItemState(TBI_ITALIC,	meItalic==ITALIC_NORMAL ? STATE_CHECK : STATE_NOCHECK);
942b9e67834SAndre Fischer             break;
94345da7d5eSAndre Fischer 
944b9e67834SAndre Fischer         case SID_ATTR_CHAR_UNDERLINE:
94545da7d5eSAndre Fischer             if( eState >= SFX_ITEM_DEFAULT)
946b9e67834SAndre Fischer             {
947b9e67834SAndre Fischer                 if(pState->ISA(SvxUnderlineItem))
948b9e67834SAndre Fischer                 {
949b9e67834SAndre Fischer                     const SvxUnderlineItem* pItem = (const SvxUnderlineItem*)pState;
950b9e67834SAndre Fischer                     meUnderline = (FontUnderline)pItem->GetValue();
951b9e67834SAndre Fischer                     meUnderlineColor = pItem->GetColor();
952b9e67834SAndre Fischer                 }
953b9e67834SAndre Fischer             }
954b9e67834SAndre Fischer             else
955b9e67834SAndre Fischer             {
956b9e67834SAndre Fischer                 meUnderline = UNDERLINE_NONE;
957b9e67834SAndre Fischer             }
95845da7d5eSAndre Fischer             mpToolBoxFont->EnableItem(TBI_UNDERLINE, bIsEnabled);
95945da7d5eSAndre Fischer             mpToolBoxFont->SetItemState(TBI_UNDERLINE, meUnderline==UNDERLINE_NONE ? STATE_NOCHECK : STATE_CHECK);
960b9e67834SAndre Fischer             break;
96145da7d5eSAndre Fischer 
962b9e67834SAndre Fischer         case SID_ATTR_CHAR_SHADOWED:
963b9e67834SAndre Fischer             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxShadowedItem))
964b9e67834SAndre Fischer             {
965b9e67834SAndre Fischer                 const SvxShadowedItem* pItem = (const SvxShadowedItem*)pState;
966b9e67834SAndre Fischer                 mbShadow = pItem->GetValue();
967b9e67834SAndre Fischer             }
968b9e67834SAndre Fischer             else
969b9e67834SAndre Fischer             {
970b9e67834SAndre Fischer                 mbShadow = false;
971b9e67834SAndre Fischer             }
97245da7d5eSAndre Fischer             mpToolBoxFont->EnableItem(TBI_SHADOWED, bIsEnabled);
97345da7d5eSAndre Fischer             mpToolBoxFont->SetItemState(TBI_SHADOWED, mbShadow ? STATE_CHECK : STATE_NOCHECK);
974b9e67834SAndre Fischer             break;
97545da7d5eSAndre Fischer 
976b9e67834SAndre Fischer         case SID_ATTR_CHAR_STRIKEOUT:
977b9e67834SAndre Fischer             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxCrossedOutItem))
978b9e67834SAndre Fischer             {
979b9e67834SAndre Fischer                 const SvxCrossedOutItem* pItem = (const SvxCrossedOutItem*)pState;
980b9e67834SAndre Fischer                 meStrike = (FontStrikeout)pItem->GetValue();
981b9e67834SAndre Fischer             }
982b9e67834SAndre Fischer             else
983b9e67834SAndre Fischer             {
984b9e67834SAndre Fischer                 meStrike = STRIKEOUT_NONE;
985b9e67834SAndre Fischer             }
98645da7d5eSAndre Fischer             mpToolBoxFont->EnableItem(TBI_STRIKEOUT, bIsEnabled);
98745da7d5eSAndre Fischer             mpToolBoxFont->SetItemState(TBI_STRIKEOUT,
98845da7d5eSAndre Fischer                 meStrike!=STRIKEOUT_NONE && meStrike!=STRIKEOUT_DONTKNOW
98945da7d5eSAndre Fischer                     ? STATE_CHECK
99045da7d5eSAndre Fischer                     : STATE_NOCHECK);
991b9e67834SAndre Fischer             break;
99245da7d5eSAndre Fischer 
993b9e67834SAndre Fischer         case SID_ATTR_CHAR_ESCAPEMENT:
99445da7d5eSAndre Fischer         {
99545da7d5eSAndre Fischer             bool bIsItemEnabled (true);
99645da7d5eSAndre Fischer             if (eState == SFX_ITEM_AVAILABLE)
997b9e67834SAndre Fischer             {
99845da7d5eSAndre Fischer                 if (pState->ISA(SvxEscapementItem))
999b9e67834SAndre Fischer                 {
1000b9e67834SAndre Fischer                     const SvxEscapementItem* pItem = (const SvxEscapementItem *)pState;
1001b9e67834SAndre Fischer                     short nEsc = pItem->GetEsc();
1002b9e67834SAndre Fischer                     if(nEsc == 0)
100345da7d5eSAndre Fischer                     {
1004b9e67834SAndre Fischer                         meEscape = SVX_ESCAPEMENT_OFF;
100545da7d5eSAndre Fischer                         mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK);
100645da7d5eSAndre Fischer                         mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_NOCHECK);
100745da7d5eSAndre Fischer                     }
1008b9e67834SAndre Fischer                     else if(nEsc > 0)
100945da7d5eSAndre Fischer                     {
1010b9e67834SAndre Fischer                         meEscape = SVX_ESCAPEMENT_SUPERSCRIPT;
101145da7d5eSAndre Fischer                         mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_CHECK);
1012bc7f1831SAndre Fischer                         mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_NOCHECK);
101345da7d5eSAndre Fischer                     }
1014b9e67834SAndre Fischer                     else
101545da7d5eSAndre Fischer                     {
1016b9e67834SAndre Fischer                         meEscape = SVX_ESCAPEMENT_SUBSCRIPT;
101745da7d5eSAndre Fischer                         mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK);
101845da7d5eSAndre Fischer                         mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_CHECK);
101945da7d5eSAndre Fischer                     }
1020b9e67834SAndre Fischer                 }
1021b9e67834SAndre Fischer                 else
1022b9e67834SAndre Fischer                 {
1023b9e67834SAndre Fischer                     meEscape = SVX_ESCAPEMENT_OFF;
102445da7d5eSAndre Fischer                     mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK);
102545da7d5eSAndre Fischer                     mpToolBoxScriptSw->SetItemState(TBI_SUB_SW,	STATE_NOCHECK);
1026b9e67834SAndre Fischer                 }
1027b9e67834SAndre Fischer             }
102845da7d5eSAndre Fischer             else if (eState == SFX_ITEM_DISABLED)
1029b9e67834SAndre Fischer             {
103045da7d5eSAndre Fischer                 bIsItemEnabled = false;
1031b9e67834SAndre Fischer             }
1032b9e67834SAndre Fischer             else
1033b9e67834SAndre Fischer             {
1034b9e67834SAndre Fischer                 meEscape = SVX_ESCAPEMENT_OFF;
1035b9e67834SAndre Fischer             }
1036bc7f1831SAndre Fischer             mpToolBoxScriptSw->EnableItem(TBI_SUPER_SW, bIsItemEnabled && bIsEnabled);
1037bc7f1831SAndre Fischer             mpToolBoxScriptSw->EnableItem(TBI_SUB_SW, bIsItemEnabled && bIsEnabled);
1038b9e67834SAndre Fischer             break;
103945da7d5eSAndre Fischer         }
104045da7d5eSAndre Fischer 
1041b9e67834SAndre Fischer         case SID_SET_SUB_SCRIPT:
1042b9e67834SAndre Fischer             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SfxBoolItem))
1043b9e67834SAndre Fischer             {
1044b9e67834SAndre Fischer                 const SfxBoolItem* pItem = (const SfxBoolItem*)pState;
1045b9e67834SAndre Fischer                 mbSub = pItem->GetValue();
1046b9e67834SAndre Fischer             }
1047b9e67834SAndre Fischer             else
1048b9e67834SAndre Fischer             {
1049b9e67834SAndre Fischer                 mbSub = false;
1050b9e67834SAndre Fischer             }
105145da7d5eSAndre Fischer             mpToolBoxScript->EnableItem(TBI_SUB, bIsEnabled);
105245da7d5eSAndre Fischer             mpToolBoxScript->SetItemState(TBI_SUB, mbSub ? STATE_CHECK : STATE_NOCHECK);
1053b9e67834SAndre Fischer             break;
105445da7d5eSAndre Fischer 
1055b9e67834SAndre Fischer         case SID_SET_SUPER_SCRIPT:
1056b9e67834SAndre Fischer             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SfxBoolItem))
1057b9e67834SAndre Fischer             {
1058b9e67834SAndre Fischer                 const SfxBoolItem* pItem = (const SfxBoolItem*)pState;
1059b9e67834SAndre Fischer                 mbSuper = pItem->GetValue();
1060b9e67834SAndre Fischer             }
1061b9e67834SAndre Fischer             else
1062b9e67834SAndre Fischer             {
1063b9e67834SAndre Fischer                 mbSuper = false;
1064b9e67834SAndre Fischer             }
106545da7d5eSAndre Fischer             mpToolBoxScript->EnableItem(TBI_SUPER, bIsEnabled);
106645da7d5eSAndre Fischer             mpToolBoxScript->SetItemState(TBI_SUPER, mbSuper ? STATE_CHECK : STATE_NOCHECK);
1067b9e67834SAndre Fischer             break;
106845da7d5eSAndre Fischer 
1069b9e67834SAndre Fischer         case SID_ATTR_CHAR_KERNING:
1070b9e67834SAndre Fischer             if ( SFX_ITEM_AVAILABLE == eState )
1071b9e67834SAndre Fischer             {
1072b9e67834SAndre Fischer                 mbKernLBAvailable = true;
1073b9e67834SAndre Fischer 
1074b9e67834SAndre Fischer                 if(pState->ISA(SvxKerningItem))
1075b9e67834SAndre Fischer                 {
1076b9e67834SAndre Fischer                     const SvxKerningItem* pKerningItem  = (const SvxKerningItem*)pState;
1077b9e67834SAndre Fischer                     mlKerning = (long)pKerningItem->GetValue();
1078b9e67834SAndre Fischer                     mbKernAvailable = true;
1079b9e67834SAndre Fischer                 }
1080b9e67834SAndre Fischer                 else
1081b9e67834SAndre Fischer                 {
1082b9e67834SAndre Fischer                     mlKerning = 0;
1083b9e67834SAndre Fischer                     mbKernAvailable =false;
1084b9e67834SAndre Fischer                 }
1085b9e67834SAndre Fischer             }
1086b9e67834SAndre Fischer             else if (SFX_ITEM_DISABLED == eState)
1087b9e67834SAndre Fischer             {
1088b9e67834SAndre Fischer                 mbKernLBAvailable = false;
1089b9e67834SAndre Fischer                 mbKernAvailable = false;
1090b9e67834SAndre Fischer                 mlKerning = 0;
1091b9e67834SAndre Fischer             }
1092b9e67834SAndre Fischer             else
1093b9e67834SAndre Fischer             {
1094b9e67834SAndre Fischer                 mbKernLBAvailable = true;
1095b9e67834SAndre Fischer                 mbKernAvailable = false;
1096b9e67834SAndre Fischer                 mlKerning = 0;
1097b9e67834SAndre Fischer             }
109845da7d5eSAndre Fischer             mpToolBoxSpacing->EnableItem(TBI_SPACING, bIsEnabled);
1099b9e67834SAndre Fischer             break;
1100b9e67834SAndre Fischer 
1101b9e67834SAndre Fischer             // font size +/- enhancement in sd
1102b9e67834SAndre Fischer         case SID_SHRINK_FONT_SIZE:
1103b9e67834SAndre Fischer         case SID_GROW_FONT_SIZE:
110445da7d5eSAndre Fischer             switch(maContext.GetCombinedContext_DI())
110545da7d5eSAndre Fischer             {
110645da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
110745da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_Text):
110845da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_Table):
110945da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
111045da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_Draw):
111145da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
111245da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
1113bc7f1831SAndre Fischer                 {
111445da7d5eSAndre Fischer                     if(eState == SFX_ITEM_DISABLED)
111545da7d5eSAndre Fischer                         mpToolBoxIncDec->Disable();
111645da7d5eSAndre Fischer                     else
111745da7d5eSAndre Fischer                         mpToolBoxIncDec->Enable();
1118bc7f1831SAndre Fischer                     const sal_Int64 nSize (maFontSizeBox.GetValue());
1119bc7f1831SAndre Fischer                     switch(nSID)
1120bc7f1831SAndre Fischer                     {
1121bc7f1831SAndre Fischer                         case SID_GROW_FONT_SIZE:
1122bc7f1831SAndre Fischer                             mpToolBoxIncDec->EnableItem(TBI_INCREASE, bIsEnabled && nSize<960);
1123bc7f1831SAndre Fischer                             break;
1124bc7f1831SAndre Fischer 
1125bc7f1831SAndre Fischer                         case SID_SHRINK_FONT_SIZE:
1126bc7f1831SAndre Fischer                             mpToolBoxIncDec->EnableItem(TBI_DECREASE, bIsEnabled && nSize>60);
1127bc7f1831SAndre Fischer                             break;
1128bc7f1831SAndre Fischer 
1129bc7f1831SAndre Fischer                         default:
1130bc7f1831SAndre Fischer                             break;
1131bc7f1831SAndre Fischer                     }
1132bc7f1831SAndre Fischer                 }
113345da7d5eSAndre Fischer             }
113445da7d5eSAndre Fischer             break;
1135b9e67834SAndre Fischer     }
1136b9e67834SAndre Fischer }
1137b9e67834SAndre Fischer 
1138b9e67834SAndre Fischer 
1139b9e67834SAndre Fischer 
1140b9e67834SAndre Fischer 
114145da7d5eSAndre Fischer void TextPropertyPanel::UpdateItem (const sal_uInt16 nSlotId)
1142b9e67834SAndre Fischer {
114345da7d5eSAndre Fischer     switch (nSlotId)
114445da7d5eSAndre Fischer     {
114545da7d5eSAndre Fischer         case SID_ATTR_CHAR_FONT:
114645da7d5eSAndre Fischer             maFontNameControl.RequestUpdate();
114745da7d5eSAndre Fischer             break;
114845da7d5eSAndre Fischer         case SID_ATTR_CHAR_FONTHEIGHT:
114945da7d5eSAndre Fischer             maFontSizeControl.RequestUpdate();
115045da7d5eSAndre Fischer             break;
115145da7d5eSAndre Fischer         case SID_ATTR_CHAR_WEIGHT:
115245da7d5eSAndre Fischer             maWeightControl.RequestUpdate();
115345da7d5eSAndre Fischer             break;
115445da7d5eSAndre Fischer         case SID_ATTR_CHAR_POSTURE:
115545da7d5eSAndre Fischer             maItalicControl.RequestUpdate();
115645da7d5eSAndre Fischer             break;
115745da7d5eSAndre Fischer         case SID_ATTR_CHAR_UNDERLINE:
115845da7d5eSAndre Fischer             maUnderlineControl.RequestUpdate();
115945da7d5eSAndre Fischer             break;
116045da7d5eSAndre Fischer         case SID_ATTR_CHAR_STRIKEOUT:
116145da7d5eSAndre Fischer             maStrikeControl.RequestUpdate();
116245da7d5eSAndre Fischer             break;
116345da7d5eSAndre Fischer         case SID_ATTR_CHAR_SHADOWED:
116445da7d5eSAndre Fischer             maShadowControl.RequestUpdate();
116545da7d5eSAndre Fischer             break;
116645da7d5eSAndre Fischer         case SID_ATTR_CHAR_ESCAPEMENT:
116745da7d5eSAndre Fischer             maScriptControlSw.RequestUpdate();
116845da7d5eSAndre Fischer             break;
116945da7d5eSAndre Fischer         case SID_SET_SUPER_SCRIPT:
117045da7d5eSAndre Fischer             maSuperScriptControl.RequestUpdate();
117145da7d5eSAndre Fischer             break;
117245da7d5eSAndre Fischer         case SID_SET_SUB_SCRIPT:
117345da7d5eSAndre Fischer             maSubScriptControl.RequestUpdate();
117445da7d5eSAndre Fischer             break;
117545da7d5eSAndre Fischer         case SID_ATTR_CHAR_KERNING:
117645da7d5eSAndre Fischer             maSpacingControl.RequestUpdate();
117745da7d5eSAndre Fischer             break;
117845da7d5eSAndre Fischer         case SID_GROW_FONT_SIZE:
117945da7d5eSAndre Fischer             maSDFontGrow.RequestUpdate();
118045da7d5eSAndre Fischer             break;
118145da7d5eSAndre Fischer         case SID_SHRINK_FONT_SIZE:
118245da7d5eSAndre Fischer             maSDFontShrink.RequestUpdate();
118345da7d5eSAndre Fischer             break;
118445da7d5eSAndre Fischer     }
1185b9e67834SAndre Fischer }
1186b9e67834SAndre Fischer 
1187b9e67834SAndre Fischer 
1188b9e67834SAndre Fischer 
1189b9e67834SAndre Fischer 
1190b9e67834SAndre Fischer 
1191d4aefcaeSZheng Fan Color& TextPropertyPanel::GetUnderlineColor()
1192b9e67834SAndre Fischer {
1193d4aefcaeSZheng Fan 	return meUnderlineColor;
1194b9e67834SAndre Fischer }
1195d4aefcaeSZheng Fan 
1196da72173fSAndre Fischer void TextPropertyPanel::SetUnderline(FontUnderline	eUnderline)
1197da72173fSAndre Fischer {
1198da72173fSAndre Fischer 	meUnderline = eUnderline;
1199da72173fSAndre Fischer }
1200d4aefcaeSZheng Fan 
120145da7d5eSAndre Fischer 
120245da7d5eSAndre Fischer 
1203b9e67834SAndre Fischer } } // end of namespace svx::sidebar
1204