2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 #include "TextUnderlineControl.hxx"
19 #include "TextPropertyPanel.hrc"
20 #include <sfx2/sidebar/ResourceDefinitions.hrc>
21 #include <svx/dialogs.hrc>
22 #include <svx/dialmgr.hxx>
23 #include <unotools/viewoptions.hxx>
24 #include <editeng/kernitem.hxx>
25 #include <sfx2/bindings.hxx>
26 #include <sfx2/dispatch.hxx>
27 #include <sfx2/sidebar/Theme.hxx>
28 #include <editeng/udlnitem.hxx>
30 namespace svx
{ namespace sidebar
{
32 TextUnderlineControl::TextUnderlineControl (
34 svx::sidebar::TextPropertyPanel
& rPanel
,
35 SfxBindings
* pBindings
)
36 : svx::sidebar::PopupControl( pParent
,SVX_RES(RID_POPUPPANEL_TEXTPAGE_UNDERLINE
))
37 , mrTextPropertyPanel(rPanel
)
38 , mpBindings(pBindings
)
39 , maVSUnderline( this, SVX_RES(VS_UNDERLINE
))
40 , maPBOptions (this, SVX_RES(PB_OPTIONS
) )
42 , maIMGSingle (SVX_RES(IMG_SINGLE
))
43 , maIMGDouble (SVX_RES(IMG_DOUBLE
))
44 , maIMGBold (SVX_RES(IMG_BOLD2
))
45 , maIMGDot (SVX_RES(IMG_DOT
))
46 , maIMGDotBold (SVX_RES(IMG_DOT_BOLD
))
47 , maIMGDash (SVX_RES(IMG_DASH
))
48 , maIMGDashLong (SVX_RES(IMG_DASH_LONG
))
49 , maIMGDashDot (SVX_RES(IMG_DASH_DOT
))
50 , maIMGDashDotDot (SVX_RES(IMG_DASH_DOT_DOT
))
51 , maIMGWave (SVX_RES(IMG_WAVE
))
53 , maIMGSingleSel (SVX_RES(IMG_SINGLE_SEL
))
54 , maIMGDoubleSel (SVX_RES(IMG_DOUBLE_SEL
))
55 , maIMGBoldSel (SVX_RES(IMG_BOLD2_SEL
))
56 , maIMGDotSel (SVX_RES(IMG_DOT_SEL
))
57 , maIMGDotBoldSel (SVX_RES(IMG_DOT_BOLD_SEL
))
58 , maIMGDashSel (SVX_RES(IMG_DASH_SEL
))
59 , maIMGDashLongSel (SVX_RES(IMG_DASH_LONG_SEL
))
60 , maIMGDashDotSel (SVX_RES(IMG_DASH_DOT_SEL
))
61 , maIMGDashDotDotSel (SVX_RES(IMG_DASH_DOT_DOT_SEL
))
62 , maIMGWaveSel (SVX_RES(IMG_WAVE_SEL
))
69 void TextUnderlineControl::initial()
71 maVSUnderline
.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
72 GetSettings().GetStyleSettings().GetMenuColor():
73 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground
));
74 maVSUnderline
.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()?
75 GetSettings().GetStyleSettings().GetMenuColor():
76 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground
));
78 Link aLink
= LINK( this, TextUnderlineControl
, PBClickHdl
) ;
79 maPBOptions
.SetClickHdl(aLink
);
81 maVSUnderline
.SetStyle( maVSUnderline
.GetStyle()| WB_3DLOOK
| WB_NO_DIRECTSELECT
);
84 maVSUnderline
.SetStyle( maVSUnderline
.GetStyle()| WB_NONEFIELD
| WB_MENUSTYLEVALUESET
);
85 maVSUnderline
.SetText( String(SVX_RES(STR_WITHOUT
) ) );
87 maVSUnderline
.InsertItem(1, maIMGSingle
,String(SVX_RES(STR_SINGLE
)));
88 maVSUnderline
.SetItemData(1, (void*)(sal_uInt64
)UNDERLINE_SINGLE
);
90 maVSUnderline
.InsertItem(2, maIMGDouble
,String(SVX_RES(STR_DOUBLE
)));
91 maVSUnderline
.SetItemData(2, (void*)(sal_uInt64
)UNDERLINE_DOUBLE
);
93 maVSUnderline
.InsertItem(3, maIMGBold
, String(SVX_RES(STR_BOLD
)));
94 maVSUnderline
.SetItemData(3,(void*)(sal_uInt64
)UNDERLINE_BOLD
);
96 maVSUnderline
.InsertItem(4, maIMGDot
, String(SVX_RES(STR_DOT
)));
97 maVSUnderline
.SetItemData(4,(void*)(sal_uInt64
)UNDERLINE_DOTTED
);
99 maVSUnderline
.InsertItem(5, maIMGDotBold
, String(SVX_RES(STR_DOT_BOLD
)));
100 maVSUnderline
.SetItemData(5,(void*)(sal_uInt64
)UNDERLINE_BOLDDOTTED
);
102 maVSUnderline
.InsertItem(6, maIMGDash
, String(SVX_RES(STR_DASH
)));
103 maVSUnderline
.SetItemData(6,(void*)(sal_uInt64
)UNDERLINE_DASH
);
105 maVSUnderline
.InsertItem(7, maIMGDashLong
,String(SVX_RES(STR_DASH_LONG
)));
106 maVSUnderline
.SetItemData(7,(void*)(sal_uInt64
)UNDERLINE_LONGDASH
);
108 maVSUnderline
.InsertItem(8, maIMGDashDot
, String(SVX_RES(STR_DASH_DOT
)));
109 maVSUnderline
.SetItemData(8,(void*)(sal_uInt64
)UNDERLINE_DASHDOT
);
111 maVSUnderline
.InsertItem(9, maIMGDashDotDot
, String(SVX_RES(STR_DASH_DOT_DOT
)));
112 maVSUnderline
.SetItemData(9,(void*)(sal_uInt64
)UNDERLINE_DASHDOTDOT
);
114 maVSUnderline
.InsertItem(10, maIMGWave
, String(SVX_RES(STR_WAVE
)));
115 maVSUnderline
.SetItemData(10,(void*)(sal_uInt64
)UNDERLINE_WAVE
);
117 maVSUnderline
.SetColCount( 1 );
118 aLink
= LINK( this, TextUnderlineControl
, VSSelectHdl
) ;
119 maVSUnderline
.SetSelectHdl(aLink
);
121 maVSUnderline
.StartSelection();
122 maVSUnderline
.Show();
126 void TextUnderlineControl::Rearrange(FontUnderline eLine
)
128 maVSUnderline
.SetItemImage(1, maIMGSingle
);
129 maVSUnderline
.SetItemImage(2, maIMGDouble
);
130 maVSUnderline
.SetItemImage(3, maIMGBold
);
131 maVSUnderline
.SetItemImage(4, maIMGDot
);
132 maVSUnderline
.SetItemImage(5, maIMGDotBold
);
133 maVSUnderline
.SetItemImage(6, maIMGDash
);
134 maVSUnderline
.SetItemImage(7, maIMGDashLong
);
135 maVSUnderline
.SetItemImage(8, maIMGDashDot
);
136 maVSUnderline
.SetItemImage(9, maIMGDashDotDot
);
137 maVSUnderline
.SetItemImage(10, maIMGWave
);
141 case UNDERLINE_SINGLE
:
142 maVSUnderline
.SetItemImage(1, maIMGSingleSel
);
143 maVSUnderline
.SelectItem(1);
144 maVSUnderline
.GrabFocus();
146 case UNDERLINE_DOUBLE
:
147 maVSUnderline
.SetItemImage(2, maIMGDoubleSel
);
148 maVSUnderline
.SelectItem(2);
149 maVSUnderline
.GrabFocus();
152 maVSUnderline
.SetItemImage(3, maIMGBoldSel
);
153 maVSUnderline
.SelectItem(3);
154 maVSUnderline
.GrabFocus();
156 case UNDERLINE_DOTTED
:
157 maVSUnderline
.SetItemImage(4, maIMGDotSel
);
158 maVSUnderline
.SelectItem(4);
159 maVSUnderline
.GrabFocus();
161 case UNDERLINE_BOLDDOTTED
:
162 maVSUnderline
.SetItemImage(5, maIMGDotBoldSel
);
163 maVSUnderline
.SelectItem(5);
164 maVSUnderline
.GrabFocus();
167 maVSUnderline
.SetItemImage(6, maIMGDashSel
);
168 maVSUnderline
.SelectItem(6);
169 maVSUnderline
.GrabFocus();
171 case UNDERLINE_LONGDASH
:
172 maVSUnderline
.SetItemImage(7, maIMGDashLongSel
);
173 maVSUnderline
.SelectItem(7);
174 maVSUnderline
.GrabFocus();
176 case UNDERLINE_DASHDOT
:
177 maVSUnderline
.SetItemImage(8, maIMGDashDotSel
);
178 maVSUnderline
.SelectItem(8);
179 maVSUnderline
.GrabFocus();
181 case UNDERLINE_DASHDOTDOT
:
182 maVSUnderline
.SetItemImage(9, maIMGDashDotDotSel
);
183 maVSUnderline
.SelectItem(9);
184 maVSUnderline
.GrabFocus();
187 maVSUnderline
.SetItemImage(10, maIMGWaveSel
);
188 maVSUnderline
.SelectItem(10);
189 maVSUnderline
.GrabFocus();
192 maVSUnderline
.SelectItem(0);
193 maVSUnderline
.GrabFocus();
196 maVSUnderline
.SelectItem(1);
197 maVSUnderline
.SetNoSelection();
198 maPBOptions
.GrabFocus();
200 maVSUnderline
.StartSelection();
204 IMPL_LINK(TextUnderlineControl
, VSSelectHdl
, void *, pControl
)
206 if ( pControl
== &maVSUnderline
)
208 const sal_uInt16 iPos
= maVSUnderline
.GetSelectItemId();
209 const FontUnderline eUnderline
= ( iPos
== 0 )
211 : (FontUnderline
)(sal_uInt64
)maVSUnderline
.GetItemData( iPos
);
213 SvxUnderlineItem
aLineItem(eUnderline
, SID_ATTR_CHAR_UNDERLINE
);
215 aLineItem
.SetColor(mrTextPropertyPanel
.GetUnderlineColor());
216 mpBindings
->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE
, SFX_CALLMODE_RECORD
, &aLineItem
, 0L);
218 mrTextPropertyPanel
.SetUnderline(eUnderline
);
220 mrTextPropertyPanel
.EndUnderlinePopupMode();
225 IMPL_LINK(TextUnderlineControl
, PBClickHdl
, PushButton
*, pPBtn
)
227 if(pPBtn
== &maPBOptions
)
231 SfxDispatcher
* pDisp
= mpBindings
->GetDispatcher();
232 pDisp
->Execute( SID_CHAR_DLG_EFFECT
, SFX_CALLMODE_ASYNCHRON
);
234 mrTextPropertyPanel
.EndUnderlinePopupMode();