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>
47ae13266dSAndre Fischer #include <sfx2/sidebar/ControllerFactory.hxx>
48b9e67834SAndre Fischer #include <sfx2/sidebar/Theme.hxx>
49ae13266dSAndre 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,
110ae13266dSAndre Fischer     SfxBindings* pBindings,
111ae13266dSAndre 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,
123ae13266dSAndre Fischer         pBindings,
124ae13266dSAndre 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,
136ae13266dSAndre Fischer     SfxBindings* pBindings,
137ae13266dSAndre 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(),
16410405e3bSAndre Fischer                 SVX_RES(TB_FONTCOLOR),
16510405e3bSAndre Fischer                 rxFrame)),
16610405e3bSAndre Fischer         mpToolBoxFontColorBackgroundSW(ControlFactory::CreateToolBoxBackground(this)),
16710405e3bSAndre Fischer         mpToolBoxFontColorSW(ControlFactory::CreateToolBox(
16810405e3bSAndre Fischer                 mpToolBoxFontColorBackgroundSW.get(),
16910405e3bSAndre Fischer                 SVX_RES(TB_FONTCOLOR_SW),
17010405e3bSAndre Fischer                 rxFrame)),
1717a32b0c8SAndre Fischer         mpToolBoxHighlightBackground(ControlFactory::CreateToolBoxBackground(this)),
1727a32b0c8SAndre Fischer         mpToolBoxHighlight(ControlFactory::CreateToolBox(
1737a32b0c8SAndre Fischer                 mpToolBoxHighlightBackground.get(),
174ae13266dSAndre Fischer                 SVX_RES(TB_HIGHLIGHT),
175ae13266dSAndre Fischer                 rxFrame)),
176b9e67834SAndre Fischer         mpFontColorUpdater(),
177b9e67834SAndre Fischer         mpHighlightUpdater(),
178b9e67834SAndre Fischer 
17945da7d5eSAndre Fischer         maFontNameControl	(SID_ATTR_CHAR_FONT,		*pBindings, *this, A2S("CharFontName"), rxFrame),
18045da7d5eSAndre Fischer         maFontSizeControl	(SID_ATTR_CHAR_FONTHEIGHT,	*pBindings, *this, A2S("FontHeight"),   rxFrame),
18145da7d5eSAndre Fischer         maWeightControl		(SID_ATTR_CHAR_WEIGHT,		*pBindings, *this, A2S("Bold"),         rxFrame),
18245da7d5eSAndre Fischer         maItalicControl		(SID_ATTR_CHAR_POSTURE,		*pBindings, *this, A2S("Italic"),       rxFrame),
18345da7d5eSAndre Fischer         maUnderlineControl	(SID_ATTR_CHAR_UNDERLINE,	*pBindings, *this, A2S("Underline"),    rxFrame),
18445da7d5eSAndre Fischer         maStrikeControl		(SID_ATTR_CHAR_STRIKEOUT,	*pBindings, *this, A2S("Strikeout"),    rxFrame),
18545da7d5eSAndre Fischer         maShadowControl		(SID_ATTR_CHAR_SHADOWED,	*pBindings, *this, A2S("Shadowed"),     rxFrame),
18645da7d5eSAndre Fischer         maScriptControlSw	(SID_ATTR_CHAR_ESCAPEMENT,	*pBindings, *this, A2S("Escapement"),   rxFrame),
18745da7d5eSAndre Fischer         maSuperScriptControl(SID_SET_SUPER_SCRIPT,		*pBindings, *this, A2S("SuperScript"),  rxFrame),
18845da7d5eSAndre Fischer         maSubScriptControl	(SID_SET_SUB_SCRIPT,		*pBindings, *this, A2S("SubScript"),    rxFrame),
18945da7d5eSAndre Fischer         maSpacingControl	(SID_ATTR_CHAR_KERNING,		*pBindings, *this, A2S("Spacing"),      rxFrame),
19045da7d5eSAndre Fischer         maSDFontGrow		(SID_GROW_FONT_SIZE,		*pBindings, *this, A2S("Grow"),         rxFrame),
19145da7d5eSAndre Fischer         maSDFontShrink		(SID_SHRINK_FONT_SIZE,		*pBindings, *this, A2S("Shrink"),       rxFrame),
192b9e67834SAndre Fischer 
193b9e67834SAndre Fischer         mpFontList			(NULL),
194b9e67834SAndre Fischer         mbMustDelete		(false),
195b9e67834SAndre Fischer         mbFocusOnFontSizeCtrl(false),
19645da7d5eSAndre Fischer         maCharSpacePopup(this, ::boost::bind(&TextPropertyPanel::CreateCharacterSpacingControl, this, _1)),
19745da7d5eSAndre Fischer         maUnderlinePopup(this, ::boost::bind(&TextPropertyPanel::CreateUnderlinePopupControl, this, _1)),
19895a18594SAndre Fischer         mxFrame(rxFrame),
199b9e67834SAndre Fischer         maContext(),
200f79579d2SAndre Fischer         mpBindings(pBindings)
201b9e67834SAndre Fischer {
202b9e67834SAndre Fischer 	Initialize();
203ae13266dSAndre Fischer 
204b9e67834SAndre Fischer 	FreeResource();
20510405e3bSAndre Fischer 
20610405e3bSAndre Fischer     UpdateFontColorToolbox(rContext);
207b9e67834SAndre Fischer }
208b9e67834SAndre Fischer 
209b9e67834SAndre Fischer 
210b9e67834SAndre Fischer 
211b9e67834SAndre Fischer 
212b9e67834SAndre Fischer TextPropertyPanel::~TextPropertyPanel (void)
213b9e67834SAndre Fischer {
214b9e67834SAndre Fischer     if(mbMustDelete)
215b9e67834SAndre Fischer         delete mpFontList;
216b9e67834SAndre Fischer 
2177a32b0c8SAndre Fischer     // Destroy the toolbox windows.
2187a32b0c8SAndre Fischer     mpToolBoxIncDec.reset();
2197a32b0c8SAndre Fischer     mpToolBoxFont.reset();
2207a32b0c8SAndre Fischer     mpToolBoxFontColor.reset();
22110405e3bSAndre Fischer     mpToolBoxFontColorSW.reset();
2227a32b0c8SAndre Fischer     mpToolBoxScript.reset();
2237a32b0c8SAndre Fischer     mpToolBoxScriptSw.reset();
2247a32b0c8SAndre Fischer     mpToolBoxSpacing.reset();
2257a32b0c8SAndre Fischer     mpToolBoxHighlight.reset();
2267a32b0c8SAndre Fischer 
2277a32b0c8SAndre Fischer     // Destroy the background windows of the toolboxes.
2287a32b0c8SAndre Fischer     mpToolBoxIncDecBackground.reset();
2297a32b0c8SAndre Fischer     mpToolBoxFontBackground.reset();
2307a32b0c8SAndre Fischer     mpToolBoxFontColorBackground.reset();
23110405e3bSAndre Fischer     mpToolBoxFontColorBackgroundSW.reset();
2327a32b0c8SAndre Fischer     mpToolBoxScriptBackground.reset();
2337a32b0c8SAndre Fischer     mpToolBoxScriptSwBackground.reset();
2347a32b0c8SAndre Fischer     mpToolBoxSpacingBackground.reset();
2357a32b0c8SAndre Fischer     mpToolBoxHighlightBackground.reset();
236b9e67834SAndre Fischer }
237b9e67834SAndre Fischer 
238b9e67834SAndre Fischer 
239b9e67834SAndre Fischer 
240b9e67834SAndre Fischer 
241d4aefcaeSZheng Fan void TextPropertyPanel::SetSpacing(long nKern)
242d4aefcaeSZheng Fan {
243d4aefcaeSZheng Fan 	mlKerning = nKern;
244d4aefcaeSZheng Fan }
24595a18594SAndre Fischer 
24695a18594SAndre Fischer 
247b9e67834SAndre Fischer void TextPropertyPanel::HandleContextChange (
248b9e67834SAndre Fischer     const ::sfx2::sidebar::EnumContext aContext)
249b9e67834SAndre Fischer {
250b9e67834SAndre Fischer     if (maContext == aContext)
251b9e67834SAndre Fischer     {
252b9e67834SAndre Fischer         // Nothing to do.
253b9e67834SAndre Fischer         return;
254b9e67834SAndre Fischer     }
255b9e67834SAndre Fischer 
256b9e67834SAndre Fischer     maContext = aContext;
25765be1ea2SAndre Fischer     switch (maContext.GetCombinedContext_DI())
258b9e67834SAndre Fischer     {
259b9e67834SAndre Fischer         case CombinedEnumContext(Application_Calc, Context_Cell):
260b9e67834SAndre Fischer         case CombinedEnumContext(Application_Calc, Context_Pivot):
2618ce66e53SOliver-Rainer Wittmann             mpToolBoxScriptSw->Hide();
262b9e67834SAndre Fischer             mpToolBoxHighlight->Hide();
263f79579d2SAndre Fischer             mpToolBoxScript->Disable();
264f79579d2SAndre Fischer             mpToolBoxSpacing->Disable();
265f79579d2SAndre Fischer             break;
266f79579d2SAndre Fischer 
267f79579d2SAndre Fischer         case CombinedEnumContext(Application_Calc, Context_EditCell):
268f79579d2SAndre Fischer         case CombinedEnumContext(Application_Calc, Context_DrawText):
269f79579d2SAndre Fischer             mpToolBoxScriptSw->Hide();
270f79579d2SAndre Fischer             mpToolBoxHighlight->Hide();
271f79579d2SAndre Fischer             mpToolBoxScript->Enable();
272f79579d2SAndre Fischer             mpToolBoxSpacing->Enable();
273b9e67834SAndre Fischer             break;
274b9e67834SAndre Fischer 
27585f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_Text):
27685f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_Table):
277b9e67834SAndre Fischer             mpToolBoxScriptSw->Show();
278b9e67834SAndre Fischer             mpToolBoxScript->Hide();
279b9e67834SAndre Fischer             mpToolBoxHighlight->Show();
280b9e67834SAndre Fischer             mpToolBoxSpacing->Show();
281b9e67834SAndre Fischer             break;
282b9e67834SAndre Fischer 
28385f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_DrawText):
28485f1aca2SAndre Fischer         case CombinedEnumContext(Application_WriterVariants, Context_Annotation):
285b9e67834SAndre Fischer             mpToolBoxScriptSw->Show();
286b9e67834SAndre Fischer             mpToolBoxScript->Hide();
287b9e67834SAndre Fischer             mpToolBoxSpacing->Show();
288b9e67834SAndre Fischer             mpToolBoxHighlight->Hide();
289b9e67834SAndre Fischer             break;
290b9e67834SAndre Fischer 
29137fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
29237fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Text):
29337fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Table):
29437fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
29537fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Draw):
29637fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
29737fee4fdSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
298b9e67834SAndre Fischer             mpToolBoxScriptSw->Hide();
299b9e67834SAndre Fischer             mpToolBoxScript->Show();
300b9e67834SAndre Fischer             mpToolBoxSpacing->Show();
301b9e67834SAndre Fischer             mpToolBoxHighlight->Hide();
302b9e67834SAndre Fischer             break;
303b9e67834SAndre Fischer 
304b9e67834SAndre Fischer         default:
305b9e67834SAndre Fischer             break;
306b9e67834SAndre Fischer     }
30710405e3bSAndre Fischer 
30810405e3bSAndre Fischer     UpdateFontColorToolbox(aContext);
30910405e3bSAndre Fischer }
31010405e3bSAndre Fischer 
31110405e3bSAndre Fischer 
31210405e3bSAndre Fischer 
31310405e3bSAndre Fischer 
31410405e3bSAndre Fischer void TextPropertyPanel::UpdateFontColorToolbox (
315*27d21f5dSPavel Janík     const ::sfx2::sidebar::EnumContext /* aContext */)
31610405e3bSAndre Fischer {
31710405e3bSAndre Fischer     bool bIsWriterFontColor (false);
31810405e3bSAndre Fischer     if (maContext.GetApplication_DI() == sfx2::sidebar::EnumContext::Application_WriterVariants)
31910405e3bSAndre Fischer         if (maContext.GetContext() != sfx2::sidebar::EnumContext::Context_DrawText)
32010405e3bSAndre Fischer             bIsWriterFontColor = true;
32110405e3bSAndre Fischer     if (bIsWriterFontColor)
32210405e3bSAndre Fischer     {
32310405e3bSAndre Fischer         mpToolBoxFontColor->Hide();
32410405e3bSAndre Fischer         mpToolBoxFontColorSW->Show();
32510405e3bSAndre Fischer     }
32610405e3bSAndre Fischer     else
32710405e3bSAndre Fischer     {
32810405e3bSAndre Fischer         mpToolBoxFontColor->Show();
32910405e3bSAndre Fischer         mpToolBoxFontColorSW->Hide();
33010405e3bSAndre Fischer     }
331b9e67834SAndre Fischer }
332b9e67834SAndre Fischer 
33345da7d5eSAndre Fischer 
334b9e67834SAndre Fischer 
335b9e67834SAndre Fischer 
336b9e67834SAndre Fischer void TextPropertyPanel::DataChanged (const DataChangedEvent& rEvent)
337b9e67834SAndre Fischer {
33895a18594SAndre Fischer     (void)rEvent;
33995a18594SAndre Fischer 
34045da7d5eSAndre Fischer     SetupToolboxItems();
341b9e67834SAndre Fischer }
342b9e67834SAndre Fischer 
343b9e67834SAndre Fischer 
344b9e67834SAndre Fischer 
345bc7f1831SAndre Fischer 
346b9e67834SAndre Fischer void TextPropertyPanel::Initialize (void)
347b9e67834SAndre Fischer {
34895a18594SAndre Fischer     //<<modify fill font list
34995a18594SAndre Fischer     SfxObjectShell* pDocSh = SfxObjectShell::Current();
350b9e67834SAndre Fischer     const SfxPoolItem* pItem = NULL;
351b9e67834SAndre Fischer 
352b9e67834SAndre Fischer     if (pDocSh != NULL)
353b9e67834SAndre Fischer         pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
354b9e67834SAndre Fischer     if (pItem != NULL)
355b9e67834SAndre Fischer         mpFontList = ( (SvxFontListItem*)pItem )->GetFontList();
356b9e67834SAndre Fischer     else
357b9e67834SAndre Fischer     {
358b9e67834SAndre Fischer         mpFontList = new FontList( Application::GetDefaultDevice() );
35945da7d5eSAndre Fischer         mbMustDelete = true;
360b9e67834SAndre Fischer     }
361b9e67834SAndre Fischer 
362b9e67834SAndre Fischer     mpFontNameBox->SetAccessibleName(mpFontNameBox->GetQuickHelpText());
36395a18594SAndre Fischer     const FontInfo aFontInfo (mpFontList->Get( String::CreateFromAscii( "" ), String::CreateFromAscii( "" )));
36495a18594SAndre Fischer     maFontSizeBox.Fill(&aFontInfo,mpFontList);
36595a18594SAndre Fischer     maFontSizeBox.SetAccessibleName(maFontSizeBox.GetQuickHelpText());
366b9e67834SAndre Fischer 
3678ce66e53SOliver-Rainer Wittmann     //toolbox
36845da7d5eSAndre Fischer     SetupToolboxItems();
36995a18594SAndre Fischer     InitToolBoxIncDec();
37095a18594SAndre Fischer     InitToolBoxFont();
37195a18594SAndre Fischer     InitToolBoxScript();
37295a18594SAndre Fischer     InitToolBoxSpacing();
373b9e67834SAndre Fischer 
374b9e67834SAndre Fischer #ifdef HAS_IA2
375d4aefcaeSZheng Fan     mpFontNameBox->SetAccRelationLabeledBy(&mpFontNameBox);
376d4aefcaeSZheng Fan     mpFontNameBox->SetMpSubEditAccLableBy(&mpFontNameBox);
377b9e67834SAndre Fischer     maFontSizeBox.SetAccRelationLabeledBy(&maFontSizeBox);
37895a18594SAndre Fischer     maFontSizeBox.SetMpSubEditAccLableBy(&maFontSizeBox);
379d4aefcaeSZheng Fan     mpToolBoxFont.SetAccRelationLabeledBy(&mpToolBoxFont);
380d4aefcaeSZheng Fan     mpToolBoxIncDec.SetAccRelationLabeledBy(&mpToolBoxIncDec);
381d4aefcaeSZheng Fan     mpToolBoxFontColor.SetAccRelationLabeledBy(&mpToolBoxFontColor);
382d4aefcaeSZheng Fan     mpToolBoxScript.SetAccRelationLabeledBy(&mpToolBoxScript);
383d4aefcaeSZheng Fan     mpToolBoxScriptSw.SetAccRelationLabeledBy(&mpToolBoxScriptSw);
384d4aefcaeSZheng Fan     mpToolBoxSpacing.SetAccRelationLabeledBy(&mpToolBoxSpacing);
385d4aefcaeSZheng Fan     mpToolBoxHighlight.SetAccRelationLabeledBy(&mpToolBoxHighlight);
386b9e67834SAndre Fischer #endif
387b9e67834SAndre Fischer 
38895a18594SAndre Fischer     //init state
38995a18594SAndre Fischer     mpHeightItem = NULL;
39095a18594SAndre Fischer     meWeight = WEIGHT_NORMAL;
39195a18594SAndre Fischer     meItalic = ITALIC_NONE;
39295a18594SAndre Fischer     mbShadow = false;
39395a18594SAndre Fischer     meStrike = STRIKEOUT_NONE;
39495a18594SAndre Fischer     mbPostureAvailable = true;
39595a18594SAndre Fischer     mbWeightAvailable = true;
39695a18594SAndre Fischer     meUnderline = UNDERLINE_NONE;
397ae13266dSAndre Fischer     meUnderlineColor = COL_AUTO;
39895a18594SAndre Fischer     meEscape = SVX_ESCAPEMENT_OFF;
39995a18594SAndre Fischer     mbSuper = false;
40095a18594SAndre Fischer     mbSub = false;
40195a18594SAndre Fischer     mbKernAvailable = true;
40295a18594SAndre Fischer     mbKernLBAvailable = true;
40395a18594SAndre Fischer     mlKerning = 0;
404ae13266dSAndre Fischer 
40595a18594SAndre Fischer     //set handler
40695a18594SAndre Fischer     mpFontNameBox->SetBindings(mpBindings);
40795a18594SAndre Fischer     Link aLink = LINK(this, TextPropertyPanel, FontSelHdl);
40895a18594SAndre Fischer     mpFontNameBox->SetSelectHdl(aLink);
40995a18594SAndre Fischer     aLink = LINK(this, TextPropertyPanel, FontSizeModifyHdl);
41095a18594SAndre Fischer     maFontSizeBox.SetModifyHdl(aLink);
41195a18594SAndre Fischer     aLink = LINK(this, TextPropertyPanel, FontSizeSelHdl);
41295a18594SAndre Fischer     maFontSizeBox.SetSelectHdl(aLink);
41395a18594SAndre Fischer     aLink = LINK(this, TextPropertyPanel, FontSizeLoseFocus);
41495a18594SAndre Fischer     maFontSizeBox.SetLoseFocusHdl(aLink);
415b9e67834SAndre Fischer }
416b9e67834SAndre Fischer 
417d4aefcaeSZheng Fan void TextPropertyPanel::EndSpacingPopupMode (void)
418d4aefcaeSZheng Fan {
419d4aefcaeSZheng Fan     maCharSpacePopup.Hide();
420d4aefcaeSZheng Fan }
421b9e67834SAndre Fischer 
422d4aefcaeSZheng Fan void TextPropertyPanel::EndUnderlinePopupMode (void)
423d4aefcaeSZheng Fan {
424d4aefcaeSZheng Fan 	maUnderlinePopup.Hide();
425d4aefcaeSZheng Fan }
426b9e67834SAndre Fischer 
427b9e67834SAndre Fischer 
428b9e67834SAndre Fischer void TextPropertyPanel::InitToolBoxFont()
429b9e67834SAndre Fischer {
430b9e67834SAndre Fischer 	mpToolBoxFont->SetBackground(Wallpaper());
431b9e67834SAndre Fischer 	mpToolBoxFont->SetPaintTransparent(true);
432b9e67834SAndre Fischer 
433b9e67834SAndre Fischer 	Size aTbxSize( mpToolBoxFont->CalcWindowSizePixel() );
434b9e67834SAndre Fischer 	mpToolBoxFont->SetOutputSizePixel( aTbxSize );
435b9e67834SAndre Fischer 
436b9e67834SAndre Fischer 	Link aLink  = LINK(this, TextPropertyPanel, ToolboxFontSelectHandler);
437b9e67834SAndre Fischer 	mpToolBoxFont->SetSelectHdl ( aLink );
438b9e67834SAndre Fischer 	aLink = LINK(this, TextPropertyPanel, ToolBoxUnderlineClickHdl);
439b9e67834SAndre Fischer 	mpToolBoxFont->SetDropdownClickHdl(aLink);
440b9e67834SAndre Fischer }
441b9e67834SAndre Fischer 
442b9e67834SAndre Fischer 
443b9e67834SAndre Fischer 
444b9e67834SAndre Fischer 
445b9e67834SAndre Fischer void TextPropertyPanel::InitToolBoxIncDec()
446b9e67834SAndre Fischer {
447b9e67834SAndre Fischer 	Size aTbxSize( mpToolBoxIncDec->CalcWindowSizePixel() );
448b9e67834SAndre Fischer 	mpToolBoxIncDec->SetOutputSizePixel( aTbxSize );
449b9e67834SAndre Fischer 
450b9e67834SAndre Fischer 	Link aLink = LINK(this, TextPropertyPanel, ToolboxIncDecSelectHdl);
451b9e67834SAndre Fischer     mpToolBoxIncDec->SetSelectHdl ( aLink );
452b9e67834SAndre Fischer }
453b9e67834SAndre Fischer 
454b9e67834SAndre Fischer 
455b9e67834SAndre Fischer 
456b9e67834SAndre Fischer 
457b9e67834SAndre Fischer void TextPropertyPanel::InitToolBoxScript()
458b9e67834SAndre Fischer {
459b9e67834SAndre Fischer 	Size aTbxSize( mpToolBoxScriptSw->CalcWindowSizePixel() );
460b9e67834SAndre Fischer 	mpToolBoxScriptSw->SetOutputSizePixel( aTbxSize );
461b9e67834SAndre Fischer 
462b9e67834SAndre Fischer 	Link aLink = LINK(this, TextPropertyPanel, ToolBoxSwScriptSelectHdl);
463b9e67834SAndre Fischer     mpToolBoxScriptSw->SetSelectHdl ( aLink );
464b9e67834SAndre Fischer 
465b9e67834SAndre Fischer 	aTbxSize = mpToolBoxScript->CalcWindowSizePixel() ;
466b9e67834SAndre Fischer 	mpToolBoxScript->SetOutputSizePixel( aTbxSize );
467b9e67834SAndre Fischer 
468b9e67834SAndre Fischer 	aLink = LINK(this, TextPropertyPanel, ToolBoxScriptSelectHdl);
469b9e67834SAndre Fischer     mpToolBoxScript->SetSelectHdl ( aLink );
470b9e67834SAndre Fischer }
471b9e67834SAndre Fischer void TextPropertyPanel::InitToolBoxSpacing()
472b9e67834SAndre Fischer {
473b9e67834SAndre Fischer 	Size aTbxSize( mpToolBoxSpacing->CalcWindowSizePixel() );
474b9e67834SAndre Fischer 	mpToolBoxSpacing->SetOutputSizePixel( aTbxSize );
475b9e67834SAndre Fischer 	mpToolBoxSpacing->SetItemBits( TBI_SPACING, mpToolBoxSpacing->GetItemBits( TBI_SPACING ) | TIB_DROPDOWNONLY );
476b9e67834SAndre Fischer 
477b9e67834SAndre Fischer 	Link aLink = LINK(this, TextPropertyPanel, SpacingClickHdl);
478b9e67834SAndre Fischer     mpToolBoxSpacing->SetDropdownClickHdl ( aLink );
479b9e67834SAndre Fischer 	mpToolBoxSpacing->SetSelectHdl( aLink );
480b9e67834SAndre Fischer }
481b9e67834SAndre Fischer 
482b9e67834SAndre Fischer 
483b9e67834SAndre Fischer 
484b9e67834SAndre Fischer 
48545da7d5eSAndre Fischer void TextPropertyPanel::SetupToolboxItems (void)
486b9e67834SAndre Fischer {
48745da7d5eSAndre Fischer     maSDFontGrow.SetupToolBoxItem(*mpToolBoxIncDec, TBI_INCREASE);
48845da7d5eSAndre Fischer     maSDFontShrink.SetupToolBoxItem(*mpToolBoxIncDec, TBI_DECREASE);
48945da7d5eSAndre Fischer 
49045da7d5eSAndre Fischer     maWeightControl.SetupToolBoxItem(*mpToolBoxFont, TBI_BOLD);
4918ce66e53SOliver-Rainer Wittmann     maItalicControl.SetupToolBoxItem(*mpToolBoxFont, TBI_ITALIC);
4928ce66e53SOliver-Rainer Wittmann     maUnderlineControl.SetupToolBoxItem(*mpToolBoxFont, TBI_UNDERLINE);
4938ce66e53SOliver-Rainer Wittmann     maStrikeControl.SetupToolBoxItem(*mpToolBoxFont, TBI_STRIKEOUT);
4948ce66e53SOliver-Rainer Wittmann     maShadowControl.SetupToolBoxItem(*mpToolBoxFont, TBI_SHADOWED);
49545da7d5eSAndre Fischer 
49645da7d5eSAndre Fischer     //for sw
49745da7d5eSAndre Fischer     maSuperScriptControl.SetupToolBoxItem(*mpToolBoxScriptSw, TBI_SUPER_SW);
49845da7d5eSAndre Fischer     maSubScriptControl.SetupToolBoxItem(*mpToolBoxScriptSw, TBI_SUB_SW);
49945da7d5eSAndre Fischer     //for sc and sd
500ccab7bc0SAndre Fischer     maSuperScriptControl.SetupToolBoxItem(*mpToolBoxScript, TBI_SUPER);
50145da7d5eSAndre Fischer     maSubScriptControl.SetupToolBoxItem(*mpToolBoxScript, TBI_SUB);
50245da7d5eSAndre Fischer     maSpacingControl.SetupToolBoxItem(*mpToolBoxSpacing, TBI_SPACING);
503b9e67834SAndre Fischer }
504b9e67834SAndre Fischer 
505b9e67834SAndre Fischer 
506b9e67834SAndre Fischer 
507b9e67834SAndre Fischer 
508b9e67834SAndre Fischer IMPL_LINK( TextPropertyPanel, FontSelHdl, FontNameBox*, pBox )
509b9e67834SAndre Fischer {
510b9e67834SAndre Fischer 	if ( !pBox->IsTravelSelect() )
511b9e67834SAndre Fischer 	{
512b9e67834SAndre Fischer 		if( SfxViewShell::Current() )
513b9e67834SAndre Fischer 		{
514b9e67834SAndre Fischer 			Window* pShellWnd = SfxViewShell::Current()->GetWindow();
515b9e67834SAndre Fischer 
516b9e67834SAndre Fischer 			if ( pShellWnd )
517b9e67834SAndre Fischer 				pShellWnd->GrabFocus();
518b9e67834SAndre Fischer 		}
519b9e67834SAndre Fischer 	}
520b9e67834SAndre Fischer 	return 0;
521b9e67834SAndre Fischer }
5228ce66e53SOliver-Rainer Wittmann 
523b9e67834SAndre Fischer IMPL_LINK( TextPropertyPanel, FontSizeModifyHdl, FontSizeBox*, pSizeBox )
524b9e67834SAndre Fischer {
525b9e67834SAndre Fischer 	if (pSizeBox == &maFontSizeBox)
526b9e67834SAndre Fischer 	{
527b9e67834SAndre Fischer 		long nSize = pSizeBox->GetValue();
528b9e67834SAndre Fischer 		mbFocusOnFontSizeCtrl = true;
529b9e67834SAndre Fischer 
530b9e67834SAndre Fischer 		float fSize = (float)nSize / 10;
531b9e67834SAndre Fischer 		SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric();
532b9e67834SAndre Fischer 		SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ;
533b9e67834SAndre Fischer 
534b9e67834SAndre Fischer 		mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L );
535b9e67834SAndre Fischer 		mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false);
536b9e67834SAndre Fischer 	}
537b9e67834SAndre Fischer 	return 0;
538b9e67834SAndre Fischer }
5398ce66e53SOliver-Rainer Wittmann 
540b9e67834SAndre Fischer IMPL_LINK( TextPropertyPanel, FontSizeSelHdl, FontSizeBox*, pSizeBox )
541b9e67834SAndre Fischer {
542b9e67834SAndre Fischer 	if ( !pSizeBox->IsTravelSelect() )
543b9e67834SAndre Fischer 	{
544b9e67834SAndre Fischer 		if( SfxViewShell::Current() )
545b9e67834SAndre Fischer 		{
546b9e67834SAndre Fischer 			Window* pShellWnd = SfxViewShell::Current()->GetWindow();
547b9e67834SAndre Fischer 
548b9e67834SAndre Fischer 			if ( pShellWnd )
549b9e67834SAndre Fischer 				pShellWnd->GrabFocus();
550b9e67834SAndre Fischer 		}
551b9e67834SAndre Fischer 	}
552b9e67834SAndre Fischer 
553b9e67834SAndre Fischer 	return 0;
554b9e67834SAndre Fischer }
5558ce66e53SOliver-Rainer Wittmann 
556b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, FontSizeLoseFocus, FontSizeBox*, pSizeBox)
557b9e67834SAndre Fischer {
558b9e67834SAndre Fischer 	if(pSizeBox == &maFontSizeBox)
559b9e67834SAndre Fischer 	{
560b9e67834SAndre Fischer 		mbFocusOnFontSizeCtrl = false;
561b9e67834SAndre Fischer 	}
562b9e67834SAndre Fischer 	return 0;
563b9e67834SAndre Fischer }
564b9e67834SAndre Fischer 
565b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, ToolboxFontSelectHandler, ToolBox*, pToolBox)
566b9e67834SAndre Fischer {
5678ce66e53SOliver-Rainer Wittmann     const sal_uInt16 nId = pToolBox->GetCurItemId();
568b9e67834SAndre Fischer 
5698ce66e53SOliver-Rainer Wittmann     switch (nId)
57045da7d5eSAndre Fischer     {
57145da7d5eSAndre Fischer         case TBI_BOLD:
57245da7d5eSAndre Fischer         {
57345da7d5eSAndre Fischer             EndTracking();
57445da7d5eSAndre Fischer             if(meWeight != WEIGHT_BOLD)
57545da7d5eSAndre Fischer                 meWeight = WEIGHT_BOLD;
57645da7d5eSAndre Fischer             else
57745da7d5eSAndre Fischer                 meWeight = WEIGHT_NORMAL;
57845da7d5eSAndre Fischer             SvxWeightItem aWeightItem(meWeight, SID_ATTR_CHAR_WEIGHT);
57945da7d5eSAndre Fischer             mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_WEIGHT, SFX_CALLMODE_RECORD, &aWeightItem, 0L);
58045da7d5eSAndre Fischer             UpdateItem(SID_ATTR_CHAR_WEIGHT);
58145da7d5eSAndre Fischer             break;
58245da7d5eSAndre Fischer         }
58345da7d5eSAndre Fischer         case TBI_ITALIC:
58445da7d5eSAndre Fischer         {
58545da7d5eSAndre Fischer             EndTracking();
58645da7d5eSAndre Fischer             if(meItalic != ITALIC_NORMAL)
58745da7d5eSAndre Fischer                 meItalic = ITALIC_NORMAL;
58845da7d5eSAndre Fischer             else
58945da7d5eSAndre Fischer                 meItalic = ITALIC_NONE;
59045da7d5eSAndre Fischer             SvxPostureItem aPostureItem(meItalic, SID_ATTR_CHAR_POSTURE);
59145da7d5eSAndre Fischer             mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_POSTURE, SFX_CALLMODE_RECORD, &aPostureItem, 0L);
59245da7d5eSAndre Fischer             UpdateItem(SID_ATTR_CHAR_POSTURE);
59345da7d5eSAndre Fischer             break;
59445da7d5eSAndre Fischer         }
59545da7d5eSAndre Fischer         case TBI_UNDERLINE:
59645da7d5eSAndre Fischer         {
59745da7d5eSAndre Fischer             EndTracking();
59845da7d5eSAndre Fischer             if(meUnderline == UNDERLINE_NONE)
59945da7d5eSAndre Fischer             {
60045da7d5eSAndre Fischer                 meUnderline = UNDERLINE_SINGLE;
60145da7d5eSAndre Fischer                 SvxUnderlineItem aLineItem(meUnderline, SID_ATTR_CHAR_UNDERLINE);
60245da7d5eSAndre Fischer                 aLineItem.SetColor(meUnderlineColor);
60345da7d5eSAndre Fischer                 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L);
60445da7d5eSAndre Fischer             }
60545da7d5eSAndre Fischer             else
60645da7d5eSAndre Fischer             {
60745da7d5eSAndre Fischer                 meUnderline = UNDERLINE_NONE;
60845da7d5eSAndre Fischer                 SvxUnderlineItem aLineItem(meUnderline, SID_ATTR_CHAR_UNDERLINE);
60945da7d5eSAndre Fischer                 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L);
61045da7d5eSAndre Fischer             }
61145da7d5eSAndre Fischer             UpdateItem(SID_ATTR_CHAR_UNDERLINE);
6128ce66e53SOliver-Rainer Wittmann             break;
61345da7d5eSAndre Fischer         }
61445da7d5eSAndre Fischer         case TBI_STRIKEOUT:
61545da7d5eSAndre Fischer         {
61645da7d5eSAndre Fischer             EndTracking();
61745da7d5eSAndre Fischer             if(meStrike !=  STRIKEOUT_NONE && meStrike != STRIKEOUT_DONTKNOW)
61845da7d5eSAndre Fischer                 meStrike = STRIKEOUT_NONE;
61945da7d5eSAndre Fischer             else
62045da7d5eSAndre Fischer                 meStrike = STRIKEOUT_SINGLE;
62145da7d5eSAndre Fischer             SvxCrossedOutItem aStrikeItem(meStrike,SID_ATTR_CHAR_STRIKEOUT);
62245da7d5eSAndre Fischer             mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_STRIKEOUT, SFX_CALLMODE_RECORD, &aStrikeItem, 0L);
62345da7d5eSAndre Fischer             UpdateItem(SID_ATTR_CHAR_STRIKEOUT);
62445da7d5eSAndre Fischer             break;
62545da7d5eSAndre Fischer         }
62645da7d5eSAndre Fischer         case TBI_SHADOWED:
62745da7d5eSAndre Fischer         {
62845da7d5eSAndre Fischer             EndTracking();
62945da7d5eSAndre Fischer             mbShadow = !mbShadow;
63045da7d5eSAndre Fischer             SvxShadowedItem aShadowItem(mbShadow, SID_ATTR_CHAR_SHADOWED);
63145da7d5eSAndre Fischer             mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_SHADOWED, SFX_CALLMODE_RECORD, &aShadowItem, 0L);
63245da7d5eSAndre Fischer             UpdateItem(SID_ATTR_CHAR_SHADOWED);
63345da7d5eSAndre Fischer             break;
63445da7d5eSAndre Fischer         }
6358ce66e53SOliver-Rainer Wittmann     }
6368ce66e53SOliver-Rainer Wittmann     return 0;
637b9e67834SAndre Fischer }
638b9e67834SAndre Fischer 
639b9e67834SAndre Fischer 
640b9e67834SAndre Fischer 
641b9e67834SAndre Fischer 
642b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, ToolboxIncDecSelectHdl, ToolBox*, pToolBox)
643b9e67834SAndre Fischer {
6448ce66e53SOliver-Rainer Wittmann     const sal_uInt16 nId = pToolBox->GetCurItemId();
645b9e67834SAndre Fischer 
6468ce66e53SOliver-Rainer Wittmann     // font size +/- enhancement in sd
64745da7d5eSAndre Fischer     switch (maContext.GetCombinedContext_DI())
648b9e67834SAndre Fischer     {
64945da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
65045da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Text):
65145da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Table):
65245da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
65345da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Draw):
65445da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
65545da7d5eSAndre Fischer         case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
656b9e67834SAndre Fischer             if(nId == TBI_INCREASE)
657b9e67834SAndre Fischer             {
658b9e67834SAndre Fischer                 EndTracking();
659b9e67834SAndre Fischer                 SfxVoidItem aItem(SID_GROW_FONT_SIZE);
660b9e67834SAndre Fischer                 mpBindings->GetDispatcher()->Execute( SID_GROW_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L );
661b9e67834SAndre Fischer             }
662b9e67834SAndre Fischer             else if(nId == TBI_DECREASE)
663b9e67834SAndre Fischer             {
664b9e67834SAndre Fischer                 EndTracking();
665b9e67834SAndre Fischer                 SfxVoidItem aItem(SID_SHRINK_FONT_SIZE);
666b9e67834SAndre Fischer                 mpBindings->GetDispatcher()->Execute( SID_SHRINK_FONT_SIZE, SFX_CALLMODE_RECORD, &aItem, 0L );
667b9e67834SAndre Fischer             }
668b9e67834SAndre Fischer             break;
669b9e67834SAndre Fischer 
670b9e67834SAndre Fischer         default:
671b9e67834SAndre Fischer             if(nId == TBI_INCREASE)
672b9e67834SAndre Fischer             {
673b9e67834SAndre Fischer                 EndTracking();
674b9e67834SAndre Fischer                 mbFocusOnFontSizeCtrl = false;
675b9e67834SAndre Fischer                 sal_Int64 iValue = maFontSizeBox.GetValue();
676b9e67834SAndre Fischer                 int iPos = maFontSizeBox.GetValuePos(iValue, FUNIT_NONE);
677b9e67834SAndre Fischer                 long nSize = iValue;
678b9e67834SAndre Fischer                 if(iPos != LISTBOX_ENTRY_NOTFOUND)
679b9e67834SAndre Fischer                     nSize = maFontSizeBox.GetValue(iPos+1 , FUNIT_NONE);
680b9e67834SAndre Fischer                 else if(iValue >= 100 && iValue < 105)
681b9e67834SAndre Fischer                     nSize = 105;
682b9e67834SAndre Fischer                 else if(iValue >= 105 && iValue < 110)
683b9e67834SAndre Fischer                     nSize = 110;
684b9e67834SAndre Fischer                 else if(iValue < 960)
685b9e67834SAndre Fischer                 {
686b9e67834SAndre Fischer                     nSize = (nSize / 10) * 10 + 10;
687b9e67834SAndre Fischer                     while(maFontSizeBox.GetValuePos(nSize, FUNIT_NONE) == LISTBOX_ENTRY_NOTFOUND)
688b9e67834SAndre Fischer                         nSize += 10;
689b9e67834SAndre Fischer                 }
690b9e67834SAndre Fischer                 else
691b9e67834SAndre Fischer                 {
692b9e67834SAndre Fischer                     nSize = iValue;
693b9e67834SAndre Fischer                 }
694b9e67834SAndre Fischer 
695b9e67834SAndre Fischer                 float fSize = (float)nSize / 10;
696b9e67834SAndre Fischer 
697b9e67834SAndre Fischer                 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric();
698b9e67834SAndre Fischer                 SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ;
699b9e67834SAndre Fischer 
700b9e67834SAndre Fischer                 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L );
701b9e67834SAndre Fischer                 mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false);
702b9e67834SAndre Fischer                 maFontSizeBox.SetValue( nSize );
703b9e67834SAndre Fischer             }
704b9e67834SAndre Fischer             else if(nId == TBI_DECREASE)
705b9e67834SAndre Fischer             {
706b9e67834SAndre Fischer                 EndTracking();
707b9e67834SAndre Fischer                 mbFocusOnFontSizeCtrl = false;
708b9e67834SAndre Fischer                 sal_Int64 iValue = maFontSizeBox.GetValue();
709b9e67834SAndre Fischer                 int iPos = maFontSizeBox.GetValuePos(iValue, FUNIT_NONE);
710b9e67834SAndre Fischer                 long nSize = iValue;
711b9e67834SAndre Fischer                 if(iPos != LISTBOX_ENTRY_NOTFOUND)
712b9e67834SAndre Fischer                     nSize = maFontSizeBox.GetValue(iPos-1 , FUNIT_NONE);
713b9e67834SAndre Fischer                 else if(iValue > 100 && iValue <= 105)
714b9e67834SAndre Fischer                     nSize = 100;
715b9e67834SAndre Fischer                 else if(iValue > 105 && iValue <= 110)
716b9e67834SAndre Fischer                     nSize = 105;
717b9e67834SAndre Fischer                 else if(iValue > 960)
718b9e67834SAndre Fischer                 {
719b9e67834SAndre Fischer                     nSize = 960;
720b9e67834SAndre Fischer                 }
721b9e67834SAndre Fischer                 else if(iValue > 60)
722b9e67834SAndre Fischer                 {
723b9e67834SAndre Fischer                     nSize = (nSize / 10) * 10 ;
724b9e67834SAndre Fischer                     while(maFontSizeBox.GetValuePos(nSize, FUNIT_NONE) == LISTBOX_ENTRY_NOTFOUND)
725b9e67834SAndre Fischer                         nSize -= 10;
726b9e67834SAndre Fischer                 }
727b9e67834SAndre Fischer                 else
728b9e67834SAndre Fischer                 {
729b9e67834SAndre Fischer                     nSize = iValue;
730b9e67834SAndre Fischer                 }
731b9e67834SAndre Fischer 
732b9e67834SAndre Fischer                 float fSize = (float)nSize / 10;
733b9e67834SAndre Fischer 
734b9e67834SAndre Fischer                 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric();
735b9e67834SAndre Fischer                 SvxFontHeightItem aItem( CalcToUnit( fSize, eUnit ), 100, SID_ATTR_CHAR_FONTHEIGHT ) ;
736b9e67834SAndre Fischer 
737b9e67834SAndre Fischer                 mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONTHEIGHT, SFX_CALLMODE_RECORD, &aItem, 0L );
738b9e67834SAndre Fischer                 mpBindings->Invalidate(SID_ATTR_CHAR_FONTHEIGHT,true,false);
739b9e67834SAndre Fischer                 maFontSizeBox.SetValue( nSize );
740b9e67834SAndre Fischer             }
741b9e67834SAndre Fischer 	}
74245da7d5eSAndre Fischer     UpdateItem(SID_ATTR_CHAR_FONTHEIGHT);
74345da7d5eSAndre Fischer 
744b9e67834SAndre Fischer 	return 0;
745b9e67834SAndre Fischer }
746b9e67834SAndre Fischer 
747b9e67834SAndre Fischer 
748b9e67834SAndre Fischer 
749b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, ToolBoxUnderlineClickHdl, ToolBox*, pToolBox)
750b9e67834SAndre Fischer {
751b9e67834SAndre Fischer 	const sal_uInt16 nId = pToolBox->GetCurItemId();
752d4aefcaeSZheng Fan 	OSL_ASSERT(nId == TBI_UNDERLINE);
753b9e67834SAndre Fischer 	if(nId == TBI_UNDERLINE)
754b9e67834SAndre Fischer 	{
755b9e67834SAndre Fischer 		pToolBox->SetItemDown( nId, true );
756d4aefcaeSZheng Fan 		maUnderlinePopup.Rearrange(meUnderline);
757d4aefcaeSZheng Fan 		maUnderlinePopup.Show(*pToolBox);
758b9e67834SAndre Fischer 
759b9e67834SAndre Fischer 	}
760d4aefcaeSZheng Fan 	return 0L;
761b9e67834SAndre Fischer }
762b9e67834SAndre Fischer 
763b9e67834SAndre Fischer 
764b9e67834SAndre Fischer 
765b9e67834SAndre Fischer 
766b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, ToolBoxSwScriptSelectHdl, ToolBox*, pToolBox)
767b9e67834SAndre Fischer {
768b9e67834SAndre Fischer 	const sal_uInt16 nId = pToolBox->GetCurItemId();
769b9e67834SAndre Fischer 	if( nId == TBI_SUPER_SW )
770b9e67834SAndre Fischer 	{
771b9e67834SAndre Fischer 		if(meEscape != SVX_ESCAPEMENT_SUPERSCRIPT)
772b9e67834SAndre Fischer 		{
773b9e67834SAndre Fischer 			meEscape = SVX_ESCAPEMENT_SUPERSCRIPT;
774b9e67834SAndre Fischer 			SvxEscapementItem aSupItem(DFLT_ESC_SUPER, DFLT_ESC_PROP, SID_ATTR_CHAR_ESCAPEMENT);
775b9e67834SAndre Fischer 			mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aSupItem, 0L );
776b9e67834SAndre Fischer 		}
777b9e67834SAndre Fischer 		else
778b9e67834SAndre Fischer 		{
779b9e67834SAndre Fischer 			meEscape = SVX_ESCAPEMENT_OFF;
780b9e67834SAndre Fischer 			SvxEscapementItem aNoneItem(0, 100, SID_ATTR_CHAR_ESCAPEMENT);
781b9e67834SAndre Fischer 			mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aNoneItem, 0L );
782b9e67834SAndre Fischer 		}
783b9e67834SAndre Fischer 	}
784b9e67834SAndre Fischer 	else if(TBI_SUB_SW == nId)
785b9e67834SAndre Fischer 	{
786b9e67834SAndre Fischer 		if(meEscape != SVX_ESCAPEMENT_SUBSCRIPT)
787b9e67834SAndre Fischer 		{
788b9e67834SAndre Fischer 			meEscape = (SvxEscapement)SVX_ESCAPEMENT_SUBSCRIPT;
789b9e67834SAndre Fischer 			SvxEscapementItem aSubItem(DFLT_ESC_SUB, DFLT_ESC_PROP, SID_ATTR_CHAR_ESCAPEMENT);
790b9e67834SAndre Fischer 			mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aSubItem, 0L );
791b9e67834SAndre Fischer 		}
792b9e67834SAndre Fischer 		else
793b9e67834SAndre Fischer 		{
794b9e67834SAndre Fischer 			meEscape = SVX_ESCAPEMENT_OFF;
795b9e67834SAndre Fischer 			SvxEscapementItem aNoneItem(0, 100, SID_ATTR_CHAR_ESCAPEMENT);
796b9e67834SAndre Fischer 			mpBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_ESCAPEMENT, SFX_CALLMODE_RECORD, &aNoneItem, 0L );
797b9e67834SAndre Fischer 		}
798b9e67834SAndre Fischer 	}
79945da7d5eSAndre Fischer     UpdateItem(SID_ATTR_CHAR_ESCAPEMENT);
800b9e67834SAndre Fischer 
801b9e67834SAndre Fischer 	return 0;
802b9e67834SAndre Fischer }
803b9e67834SAndre Fischer 
804b9e67834SAndre Fischer 
805b9e67834SAndre Fischer 
806b9e67834SAndre Fischer 
807b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, ToolBoxScriptSelectHdl, ToolBox*, pToolBox)
808b9e67834SAndre Fischer {
809b9e67834SAndre Fischer 	const sal_uInt16 nId = pToolBox->GetCurItemId();
810b9e67834SAndre Fischer 	if( nId == TBI_SUPER )
811b9e67834SAndre Fischer 	{
812b9e67834SAndre Fischer 		mbSuper = !mbSuper;
813b9e67834SAndre Fischer 		SfxBoolItem aSupItem(SID_SET_SUPER_SCRIPT, mbSuper);
814b9e67834SAndre Fischer 		mpBindings->GetDispatcher()->Execute( SID_SET_SUPER_SCRIPT, SFX_CALLMODE_RECORD, &aSupItem, 0L );
81545da7d5eSAndre Fischer         UpdateItem(SID_SET_SUPER_SCRIPT);
816b9e67834SAndre Fischer 	}
817b9e67834SAndre Fischer 	else if(TBI_SUB == nId)
818b9e67834SAndre Fischer 	{
819b9e67834SAndre Fischer 
820b9e67834SAndre Fischer 		mbSub = !mbSub;
821b9e67834SAndre Fischer 		SfxBoolItem aSubItem(SID_SET_SUB_SCRIPT, mbSub );
822b9e67834SAndre Fischer 		mpBindings->GetDispatcher()->Execute( SID_SET_SUB_SCRIPT, SFX_CALLMODE_RECORD, &aSubItem, 0L );
82345da7d5eSAndre Fischer         UpdateItem(SID_SET_SUB_SCRIPT);
824b9e67834SAndre Fischer 	}
825b9e67834SAndre Fischer 	return 0;
826b9e67834SAndre Fischer }
827b9e67834SAndre Fischer 
828b9e67834SAndre Fischer 
829b9e67834SAndre Fischer 
830b9e67834SAndre Fischer 
831b9e67834SAndre Fischer IMPL_LINK(TextPropertyPanel, SpacingClickHdl, ToolBox*, pToolBox)
832b9e67834SAndre Fischer {
833b9e67834SAndre Fischer 	const sal_uInt16 nId = pToolBox->GetCurItemId();
834d4aefcaeSZheng Fan 	OSL_ASSERT(nId == TBI_SPACING);
835b9e67834SAndre Fischer 	if(nId == TBI_SPACING)
836b9e67834SAndre Fischer 	{
837b9e67834SAndre Fischer 		pToolBox->SetItemDown( nId, true );
838d4aefcaeSZheng Fan 		maCharSpacePopup.Rearrange(mbKernLBAvailable,mbKernAvailable,mlKerning);
839d4aefcaeSZheng Fan 		maCharSpacePopup.Show(*pToolBox);
840b9e67834SAndre Fischer 
841b9e67834SAndre Fischer 	}
842d4aefcaeSZheng Fan 	return 0L;
843b9e67834SAndre Fischer }
844b9e67834SAndre Fischer 
845b9e67834SAndre Fischer 
846b9e67834SAndre Fischer 
847b9e67834SAndre Fischer 
848b9e67834SAndre Fischer void TextPropertyPanel::NotifyItemUpdate (
849b9e67834SAndre Fischer     const sal_uInt16 nSID,
850b9e67834SAndre Fischer     const SfxItemState eState,
85145da7d5eSAndre Fischer     const SfxPoolItem* pState,
85245da7d5eSAndre Fischer     const bool bIsEnabled)
853b9e67834SAndre Fischer {
8548ce66e53SOliver-Rainer Wittmann     switch(nSID)
8558ce66e53SOliver-Rainer Wittmann     {
856b9e67834SAndre Fischer         case SID_ATTR_CHAR_FONT:
85745da7d5eSAndre Fischer         {
85845da7d5eSAndre Fischer             bool bIsControlEnabled (bIsEnabled);
859b9e67834SAndre Fischer             if (  eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxFontItem) )
860b9e67834SAndre Fischer             {
861b9e67834SAndre Fischer                 const SvxFontItem* pFontItem = (const SvxFontItem*)pState;
862b9e67834SAndre Fischer                 mpFontNameBox->SetText( pFontItem->GetFamilyName() );
863b9e67834SAndre Fischer             }
864b9e67834SAndre Fischer             else
865b9e67834SAndre Fischer             {
866b9e67834SAndre Fischer                 mpFontNameBox->SetText( String() );
867b9e67834SAndre Fischer                 if (SFX_ITEM_DISABLED == eState)
86845da7d5eSAndre Fischer                     bIsControlEnabled = false;
869b9e67834SAndre Fischer             }
87045da7d5eSAndre Fischer             mpFontNameBox->Enable(bIsControlEnabled);
871b9e67834SAndre Fischer             break;
87245da7d5eSAndre Fischer         }
873b9e67834SAndre Fischer         case SID_ATTR_CHAR_FONTHEIGHT:
87445da7d5eSAndre Fischer         {
87545da7d5eSAndre Fischer             bool bIsControlEnabled (bIsEnabled);
876b9e67834SAndre Fischer             if (  eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxFontHeightItem) )
877b9e67834SAndre Fischer             {
878b9e67834SAndre Fischer                 mpHeightItem = (SvxFontHeightItem*)pState;//const SvxFontHeightItem*
879b9e67834SAndre Fischer                 SfxMapUnit eUnit = maFontSizeControl.GetCoreMetric();
880bc7f1831SAndre Fischer                 const sal_Int64 nValue (CalcToPoint(mpHeightItem->GetHeight(), eUnit, 10 ));
881b9e67834SAndre Fischer                 mpToolBoxIncDec->Enable();
882b9e67834SAndre Fischer 
883b9e67834SAndre Fischer                 mpToolBoxIncDec->SetItemState(TBI_INCREASE, STATE_NOCHECK);
884b9e67834SAndre Fischer                 mpToolBoxIncDec->SetItemState(TBI_DECREASE, STATE_NOCHECK);
885b9e67834SAndre Fischer 
886bc7f1831SAndre Fischer                 // For Writer we have to update the states of the
887bc7f1831SAndre Fischer                 // increase and decrease buttons here, because we have
888bc7f1831SAndre Fischer                 // no access to the slots used by Writer.
889bc7f1831SAndre Fischer                 switch(maContext.GetCombinedContext_DI())
890bc7f1831SAndre Fischer                 {
891bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
892bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Text):
893bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Table):
894bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
895bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Draw):
896bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
897bc7f1831SAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
898bc7f1831SAndre Fischer                         break;
899bc7f1831SAndre Fischer 
900bc7f1831SAndre Fischer                     default:
901bc7f1831SAndre Fischer                     {
902bc7f1831SAndre Fischer                         mpToolBoxIncDec->EnableItem(TBI_INCREASE, bIsEnabled && nValue<960);
903bc7f1831SAndre Fischer                         mpToolBoxIncDec->EnableItem(TBI_DECREASE, bIsEnabled && nValue>60);
904bc7f1831SAndre Fischer                         break;
905bc7f1831SAndre Fischer                     }
906bc7f1831SAndre Fischer                 }
907bc7f1831SAndre Fischer 
908b9e67834SAndre Fischer                 if( mbFocusOnFontSizeCtrl )
909b9e67834SAndre Fischer                     return;
910b9e67834SAndre Fischer 
911bc7f1831SAndre Fischer                 maFontSizeBox.SetValue(nValue);
912b9e67834SAndre Fischer                 maFontSizeBox.LoseFocus();
91345da7d5eSAndre Fischer 
91445da7d5eSAndre Fischer                 UpdateItem(SID_SHRINK_FONT_SIZE);
91545da7d5eSAndre Fischer                 UpdateItem(SID_GROW_FONT_SIZE);
916b9e67834SAndre Fischer             }
917b9e67834SAndre Fischer             else
9188ce66e53SOliver-Rainer Wittmann             {
919b9e67834SAndre Fischer                 mpHeightItem = NULL;
920b9e67834SAndre Fischer                 maFontSizeBox.SetText( String() );
921b9e67834SAndre Fischer                 //increase decrease diabled when multi-seletion have different font size
9228ce66e53SOliver-Rainer Wittmann 
923b9e67834SAndre Fischer                 // font size +/- enhancement in sd
92445da7d5eSAndre Fischer                 switch(maContext.GetCombinedContext_DI())
925b9e67834SAndre Fischer                 {
92645da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
92745da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Text):
92845da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Table):
92945da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
93045da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Draw):
93145da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
93245da7d5eSAndre Fischer                     case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
933b9e67834SAndre Fischer                         break;
934b9e67834SAndre Fischer 
935b9e67834SAndre Fischer                     default:
936b9e67834SAndre Fischer                         mpToolBoxIncDec->Disable();
937b9e67834SAndre Fischer                 }
938b9e67834SAndre Fischer                 if ( eState <= SFX_ITEM_READONLY )
93945da7d5eSAndre Fischer                     bIsControlEnabled = false;
940b9e67834SAndre Fischer             }
94145da7d5eSAndre Fischer             maFontSizeBox.Enable(bIsControlEnabled);
94245da7d5eSAndre Fischer             break;
94345da7d5eSAndre Fischer         }
94445da7d5eSAndre Fischer 
945b9e67834SAndre Fischer         case SID_ATTR_CHAR_WEIGHT:
946b9e67834SAndre Fischer             mbWeightAvailable = (eState >= SFX_ITEM_DONTCARE);
947b9e67834SAndre Fischer             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxWeightItem))
948b9e67834SAndre Fischer             {
949b9e67834SAndre Fischer                 const SvxWeightItem* pItem = (const SvxWeightItem*)pState;
950b9e67834SAndre Fischer                 meWeight = (FontWeight)pItem->GetValue();
951b9e67834SAndre Fischer             }
952b9e67834SAndre Fischer             else
953b9e67834SAndre Fischer             {
954b9e67834SAndre Fischer                 meWeight = WEIGHT_NORMAL;
955b9e67834SAndre Fischer             }
95645da7d5eSAndre Fischer             mpToolBoxFont->EnableItem(TBI_BOLD, mbWeightAvailable && bIsEnabled);
95745da7d5eSAndre Fischer             mpToolBoxFont->SetItemState(TBI_BOLD, meWeight==WEIGHT_BOLD ? STATE_CHECK : STATE_NOCHECK);
958b9e67834SAndre Fischer             break;
95945da7d5eSAndre Fischer 
960b9e67834SAndre Fischer         case SID_ATTR_CHAR_POSTURE:
961b9e67834SAndre Fischer             mbPostureAvailable = (eState >= SFX_ITEM_DONTCARE);
962b9e67834SAndre Fischer             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxPostureItem))
963b9e67834SAndre Fischer             {
964b9e67834SAndre Fischer                 const SvxPostureItem* pItem = (const SvxPostureItem*)pState;
965b9e67834SAndre Fischer                 meItalic = (FontItalic)pItem->GetValue();
966b9e67834SAndre Fischer             }
967b9e67834SAndre Fischer             else
968b9e67834SAndre Fischer             {
969b9e67834SAndre Fischer                 meItalic = ITALIC_NONE;
970b9e67834SAndre Fischer             }
97145da7d5eSAndre Fischer             mpToolBoxFont->EnableItem(TBI_ITALIC, mbPostureAvailable && bIsEnabled);
97245da7d5eSAndre Fischer             mpToolBoxFont->SetItemState(TBI_ITALIC,	meItalic==ITALIC_NORMAL ? STATE_CHECK : STATE_NOCHECK);
973b9e67834SAndre Fischer             break;
97445da7d5eSAndre Fischer 
975b9e67834SAndre Fischer         case SID_ATTR_CHAR_UNDERLINE:
97645da7d5eSAndre Fischer             if( eState >= SFX_ITEM_DEFAULT)
977b9e67834SAndre Fischer             {
978b9e67834SAndre Fischer                 if(pState->ISA(SvxUnderlineItem))
979b9e67834SAndre Fischer                 {
980b9e67834SAndre Fischer                     const SvxUnderlineItem* pItem = (const SvxUnderlineItem*)pState;
981b9e67834SAndre Fischer                     meUnderline = (FontUnderline)pItem->GetValue();
982b9e67834SAndre Fischer                     meUnderlineColor = pItem->GetColor();
983b9e67834SAndre Fischer                 }
984b9e67834SAndre Fischer             }
985b9e67834SAndre Fischer             else
986b9e67834SAndre Fischer             {
987b9e67834SAndre Fischer                 meUnderline = UNDERLINE_NONE;
988b9e67834SAndre Fischer             }
98945da7d5eSAndre Fischer             mpToolBoxFont->EnableItem(TBI_UNDERLINE, bIsEnabled);
99045da7d5eSAndre Fischer             mpToolBoxFont->SetItemState(TBI_UNDERLINE, meUnderline==UNDERLINE_NONE ? STATE_NOCHECK : STATE_CHECK);
991b9e67834SAndre Fischer             break;
99245da7d5eSAndre Fischer 
993b9e67834SAndre Fischer         case SID_ATTR_CHAR_SHADOWED:
994b9e67834SAndre Fischer             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxShadowedItem))
995b9e67834SAndre Fischer             {
996b9e67834SAndre Fischer                 const SvxShadowedItem* pItem = (const SvxShadowedItem*)pState;
997b9e67834SAndre Fischer                 mbShadow = pItem->GetValue();
998b9e67834SAndre Fischer             }
999b9e67834SAndre Fischer             else
1000b9e67834SAndre Fischer             {
1001b9e67834SAndre Fischer                 mbShadow = false;
1002b9e67834SAndre Fischer             }
100345da7d5eSAndre Fischer             mpToolBoxFont->EnableItem(TBI_SHADOWED, bIsEnabled);
100445da7d5eSAndre Fischer             mpToolBoxFont->SetItemState(TBI_SHADOWED, mbShadow ? STATE_CHECK : STATE_NOCHECK);
1005b9e67834SAndre Fischer             break;
100645da7d5eSAndre Fischer 
1007b9e67834SAndre Fischer         case SID_ATTR_CHAR_STRIKEOUT:
1008b9e67834SAndre Fischer             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SvxCrossedOutItem))
1009b9e67834SAndre Fischer             {
1010b9e67834SAndre Fischer                 const SvxCrossedOutItem* pItem = (const SvxCrossedOutItem*)pState;
1011b9e67834SAndre Fischer                 meStrike = (FontStrikeout)pItem->GetValue();
1012b9e67834SAndre Fischer             }
1013b9e67834SAndre Fischer             else
1014b9e67834SAndre Fischer             {
1015b9e67834SAndre Fischer                 meStrike = STRIKEOUT_NONE;
1016b9e67834SAndre Fischer             }
101745da7d5eSAndre Fischer             mpToolBoxFont->EnableItem(TBI_STRIKEOUT, bIsEnabled);
101845da7d5eSAndre Fischer             mpToolBoxFont->SetItemState(TBI_STRIKEOUT,
101945da7d5eSAndre Fischer                 meStrike!=STRIKEOUT_NONE && meStrike!=STRIKEOUT_DONTKNOW
102045da7d5eSAndre Fischer                     ? STATE_CHECK
102145da7d5eSAndre Fischer                     : STATE_NOCHECK);
1022b9e67834SAndre Fischer             break;
102345da7d5eSAndre Fischer 
1024b9e67834SAndre Fischer         case SID_ATTR_CHAR_ESCAPEMENT:
102545da7d5eSAndre Fischer         {
102645da7d5eSAndre Fischer             bool bIsItemEnabled (true);
102745da7d5eSAndre Fischer             if (eState == SFX_ITEM_AVAILABLE)
1028b9e67834SAndre Fischer             {
102945da7d5eSAndre Fischer                 if (pState->ISA(SvxEscapementItem))
1030b9e67834SAndre Fischer                 {
1031b9e67834SAndre Fischer                     const SvxEscapementItem* pItem = (const SvxEscapementItem *)pState;
1032b9e67834SAndre Fischer                     short nEsc = pItem->GetEsc();
1033b9e67834SAndre Fischer                     if(nEsc == 0)
103445da7d5eSAndre Fischer                     {
1035b9e67834SAndre Fischer                         meEscape = SVX_ESCAPEMENT_OFF;
103645da7d5eSAndre Fischer                         mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK);
103745da7d5eSAndre Fischer                         mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_NOCHECK);
103845da7d5eSAndre Fischer                     }
1039b9e67834SAndre Fischer                     else if(nEsc > 0)
104045da7d5eSAndre Fischer                     {
1041b9e67834SAndre Fischer                         meEscape = SVX_ESCAPEMENT_SUPERSCRIPT;
104245da7d5eSAndre Fischer                         mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_CHECK);
1043bc7f1831SAndre Fischer                         mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_NOCHECK);
104445da7d5eSAndre Fischer                     }
1045b9e67834SAndre Fischer                     else
104645da7d5eSAndre Fischer                     {
1047b9e67834SAndre Fischer                         meEscape = SVX_ESCAPEMENT_SUBSCRIPT;
104845da7d5eSAndre Fischer                         mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK);
104945da7d5eSAndre Fischer                         mpToolBoxScriptSw->SetItemState(TBI_SUB_SW, STATE_CHECK);
105045da7d5eSAndre Fischer                     }
1051b9e67834SAndre Fischer                 }
1052b9e67834SAndre Fischer                 else
1053b9e67834SAndre Fischer                 {
1054b9e67834SAndre Fischer                     meEscape = SVX_ESCAPEMENT_OFF;
105545da7d5eSAndre Fischer                     mpToolBoxScriptSw->SetItemState(TBI_SUPER_SW, STATE_NOCHECK);
105645da7d5eSAndre Fischer                     mpToolBoxScriptSw->SetItemState(TBI_SUB_SW,	STATE_NOCHECK);
1057b9e67834SAndre Fischer                 }
1058b9e67834SAndre Fischer             }
105945da7d5eSAndre Fischer             else if (eState == SFX_ITEM_DISABLED)
1060b9e67834SAndre Fischer             {
106145da7d5eSAndre Fischer                 bIsItemEnabled = false;
1062b9e67834SAndre Fischer             }
1063b9e67834SAndre Fischer             else
1064b9e67834SAndre Fischer             {
1065b9e67834SAndre Fischer                 meEscape = SVX_ESCAPEMENT_OFF;
1066b9e67834SAndre Fischer             }
1067bc7f1831SAndre Fischer             mpToolBoxScriptSw->EnableItem(TBI_SUPER_SW, bIsItemEnabled && bIsEnabled);
1068bc7f1831SAndre Fischer             mpToolBoxScriptSw->EnableItem(TBI_SUB_SW, bIsItemEnabled && bIsEnabled);
1069b9e67834SAndre Fischer             break;
107045da7d5eSAndre Fischer         }
107145da7d5eSAndre Fischer 
1072b9e67834SAndre Fischer         case SID_SET_SUB_SCRIPT:
1073b9e67834SAndre Fischer             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SfxBoolItem))
1074b9e67834SAndre Fischer             {
1075b9e67834SAndre Fischer                 const SfxBoolItem* pItem = (const SfxBoolItem*)pState;
1076b9e67834SAndre Fischer                 mbSub = pItem->GetValue();
1077b9e67834SAndre Fischer             }
1078b9e67834SAndre Fischer             else
1079b9e67834SAndre Fischer             {
1080b9e67834SAndre Fischer                 mbSub = false;
1081b9e67834SAndre Fischer             }
108245da7d5eSAndre Fischer             mpToolBoxScript->EnableItem(TBI_SUB, bIsEnabled);
108345da7d5eSAndre Fischer             mpToolBoxScript->SetItemState(TBI_SUB, mbSub ? STATE_CHECK : STATE_NOCHECK);
1084b9e67834SAndre Fischer             break;
108545da7d5eSAndre Fischer 
1086b9e67834SAndre Fischer         case SID_SET_SUPER_SCRIPT:
1087b9e67834SAndre Fischer             if( eState >= SFX_ITEM_DEFAULT && pState->ISA(SfxBoolItem))
1088b9e67834SAndre Fischer             {
1089b9e67834SAndre Fischer                 const SfxBoolItem* pItem = (const SfxBoolItem*)pState;
1090b9e67834SAndre Fischer                 mbSuper = pItem->GetValue();
1091b9e67834SAndre Fischer             }
1092b9e67834SAndre Fischer             else
1093b9e67834SAndre Fischer             {
1094b9e67834SAndre Fischer                 mbSuper = false;
1095b9e67834SAndre Fischer             }
109645da7d5eSAndre Fischer             mpToolBoxScript->EnableItem(TBI_SUPER, bIsEnabled);
109745da7d5eSAndre Fischer             mpToolBoxScript->SetItemState(TBI_SUPER, mbSuper ? STATE_CHECK : STATE_NOCHECK);
1098b9e67834SAndre Fischer             break;
109945da7d5eSAndre Fischer 
1100b9e67834SAndre Fischer         case SID_ATTR_CHAR_KERNING:
1101b9e67834SAndre Fischer             if ( SFX_ITEM_AVAILABLE == eState )
1102b9e67834SAndre Fischer             {
1103b9e67834SAndre Fischer                 mbKernLBAvailable = true;
1104b9e67834SAndre Fischer 
1105b9e67834SAndre Fischer                 if(pState->ISA(SvxKerningItem))
1106b9e67834SAndre Fischer                 {
1107b9e67834SAndre Fischer                     const SvxKerningItem* pKerningItem  = (const SvxKerningItem*)pState;
1108b9e67834SAndre Fischer                     mlKerning = (long)pKerningItem->GetValue();
1109b9e67834SAndre Fischer                     mbKernAvailable = true;
1110b9e67834SAndre Fischer                 }
1111b9e67834SAndre Fischer                 else
1112b9e67834SAndre Fischer                 {
1113b9e67834SAndre Fischer                     mlKerning = 0;
1114b9e67834SAndre Fischer                     mbKernAvailable =false;
1115b9e67834SAndre Fischer                 }
1116b9e67834SAndre Fischer             }
1117b9e67834SAndre Fischer             else if (SFX_ITEM_DISABLED == eState)
1118b9e67834SAndre Fischer             {
1119b9e67834SAndre Fischer                 mbKernLBAvailable = false;
1120b9e67834SAndre Fischer                 mbKernAvailable = false;
1121b9e67834SAndre Fischer                 mlKerning = 0;
1122b9e67834SAndre Fischer             }
1123b9e67834SAndre Fischer             else
1124b9e67834SAndre Fischer             {
1125b9e67834SAndre Fischer                 mbKernLBAvailable = true;
1126b9e67834SAndre Fischer                 mbKernAvailable = false;
1127b9e67834SAndre Fischer                 mlKerning = 0;
1128b9e67834SAndre Fischer             }
112945da7d5eSAndre Fischer             mpToolBoxSpacing->EnableItem(TBI_SPACING, bIsEnabled);
1130b9e67834SAndre Fischer             break;
1131b9e67834SAndre Fischer 
1132b9e67834SAndre Fischer             // font size +/- enhancement in sd
1133b9e67834SAndre Fischer         case SID_SHRINK_FONT_SIZE:
1134b9e67834SAndre Fischer         case SID_GROW_FONT_SIZE:
113545da7d5eSAndre Fischer             switch(maContext.GetCombinedContext_DI())
113645da7d5eSAndre Fischer             {
113745da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_DrawText):
113845da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_Text):
113945da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_Table):
114045da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_OutlineText):
114145da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_Draw):
114245da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_TextObject):
114345da7d5eSAndre Fischer                 case CombinedEnumContext(Application_DrawImpress, Context_Graphic):
1144bc7f1831SAndre Fischer                 {
114545da7d5eSAndre Fischer                     if(eState == SFX_ITEM_DISABLED)
114645da7d5eSAndre Fischer                         mpToolBoxIncDec->Disable();
114745da7d5eSAndre Fischer                     else
114845da7d5eSAndre Fischer                         mpToolBoxIncDec->Enable();
1149bc7f1831SAndre Fischer                     const sal_Int64 nSize (maFontSizeBox.GetValue());
1150bc7f1831SAndre Fischer                     switch(nSID)
1151bc7f1831SAndre Fischer                     {
1152bc7f1831SAndre Fischer                         case SID_GROW_FONT_SIZE:
1153bc7f1831SAndre Fischer                             mpToolBoxIncDec->EnableItem(TBI_INCREASE, bIsEnabled && nSize<960);
1154bc7f1831SAndre Fischer                             break;
1155bc7f1831SAndre Fischer 
1156bc7f1831SAndre Fischer                         case SID_SHRINK_FONT_SIZE:
1157bc7f1831SAndre Fischer                             mpToolBoxIncDec->EnableItem(TBI_DECREASE, bIsEnabled && nSize>60);
1158bc7f1831SAndre Fischer                             break;
1159bc7f1831SAndre Fischer 
1160bc7f1831SAndre Fischer                         default:
1161bc7f1831SAndre Fischer                             break;
1162bc7f1831SAndre Fischer                     }
1163bc7f1831SAndre Fischer                 }
116445da7d5eSAndre Fischer             }
116545da7d5eSAndre Fischer             break;
1166b9e67834SAndre Fischer     }
1167b9e67834SAndre Fischer }
1168b9e67834SAndre Fischer 
1169b9e67834SAndre Fischer 
1170b9e67834SAndre Fischer 
1171b9e67834SAndre Fischer 
117245da7d5eSAndre Fischer void TextPropertyPanel::UpdateItem (const sal_uInt16 nSlotId)
1173b9e67834SAndre Fischer {
117445da7d5eSAndre Fischer     switch (nSlotId)
117545da7d5eSAndre Fischer     {
117645da7d5eSAndre Fischer         case SID_ATTR_CHAR_FONT:
117745da7d5eSAndre Fischer             maFontNameControl.RequestUpdate();
117845da7d5eSAndre Fischer             break;
117945da7d5eSAndre Fischer         case SID_ATTR_CHAR_FONTHEIGHT:
118045da7d5eSAndre Fischer             maFontSizeControl.RequestUpdate();
118145da7d5eSAndre Fischer             break;
118245da7d5eSAndre Fischer         case SID_ATTR_CHAR_WEIGHT:
118345da7d5eSAndre Fischer             maWeightControl.RequestUpdate();
118445da7d5eSAndre Fischer             break;
118545da7d5eSAndre Fischer         case SID_ATTR_CHAR_POSTURE:
118645da7d5eSAndre Fischer             maItalicControl.RequestUpdate();
118745da7d5eSAndre Fischer             break;
118845da7d5eSAndre Fischer         case SID_ATTR_CHAR_UNDERLINE:
118945da7d5eSAndre Fischer             maUnderlineControl.RequestUpdate();
119045da7d5eSAndre Fischer             break;
119145da7d5eSAndre Fischer         case SID_ATTR_CHAR_STRIKEOUT:
119245da7d5eSAndre Fischer             maStrikeControl.RequestUpdate();
119345da7d5eSAndre Fischer             break;
119445da7d5eSAndre Fischer         case SID_ATTR_CHAR_SHADOWED:
119545da7d5eSAndre Fischer             maShadowControl.RequestUpdate();
119645da7d5eSAndre Fischer             break;
119745da7d5eSAndre Fischer         case SID_ATTR_CHAR_ESCAPEMENT:
119845da7d5eSAndre Fischer             maScriptControlSw.RequestUpdate();
119945da7d5eSAndre Fischer             break;
120045da7d5eSAndre Fischer         case SID_SET_SUPER_SCRIPT:
120145da7d5eSAndre Fischer             maSuperScriptControl.RequestUpdate();
120245da7d5eSAndre Fischer             break;
120345da7d5eSAndre Fischer         case SID_SET_SUB_SCRIPT:
120445da7d5eSAndre Fischer             maSubScriptControl.RequestUpdate();
120545da7d5eSAndre Fischer             break;
120645da7d5eSAndre Fischer         case SID_ATTR_CHAR_KERNING:
120745da7d5eSAndre Fischer             maSpacingControl.RequestUpdate();
120845da7d5eSAndre Fischer             break;
120945da7d5eSAndre Fischer         case SID_GROW_FONT_SIZE:
121045da7d5eSAndre Fischer             maSDFontGrow.RequestUpdate();
121145da7d5eSAndre Fischer             break;
121245da7d5eSAndre Fischer         case SID_SHRINK_FONT_SIZE:
121345da7d5eSAndre Fischer             maSDFontShrink.RequestUpdate();
121445da7d5eSAndre Fischer             break;
121545da7d5eSAndre Fischer     }
1216b9e67834SAndre Fischer }
1217b9e67834SAndre Fischer 
1218b9e67834SAndre Fischer 
1219b9e67834SAndre Fischer 
1220b9e67834SAndre Fischer 
1221b9e67834SAndre Fischer 
1222d4aefcaeSZheng Fan Color& TextPropertyPanel::GetUnderlineColor()
1223b9e67834SAndre Fischer {
1224d4aefcaeSZheng Fan 	return meUnderlineColor;
1225b9e67834SAndre Fischer }
1226d4aefcaeSZheng Fan 
1227da72173fSAndre Fischer void TextPropertyPanel::SetUnderline(FontUnderline	eUnderline)
1228da72173fSAndre Fischer {
1229da72173fSAndre Fischer 	meUnderline = eUnderline;
1230da72173fSAndre Fischer }
1231d4aefcaeSZheng Fan 
123245da7d5eSAndre Fischer 
123345da7d5eSAndre Fischer 
1234b9e67834SAndre Fischer } } // end of namespace svx::sidebar
1235