1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 #include "precompiled_svx.hxx"
23 #include "TextUnderlineControl.hxx"
24 #include "TextPropertyPanel.hrc"
25 #include <sfx2/sidebar/ResourceDefinitions.hrc>
26 #include <svx/dialogs.hrc>
27 #include <svx/dialmgr.hxx>
28 #include <unotools/viewoptions.hxx>
29 #include <editeng/kernitem.hxx>
30 #include <sfx2/bindings.hxx>
31 #include <sfx2/dispatch.hxx>
32 #include <sfx2/sidebar/Theme.hxx>
33 #include <editeng/udlnitem.hxx>
34
35 namespace svx { namespace sidebar {
36
TextUnderlineControl(Window * pParent,svx::sidebar::TextPropertyPanel & rPanel,SfxBindings * pBindings)37 TextUnderlineControl::TextUnderlineControl (
38 Window* pParent,
39 svx::sidebar::TextPropertyPanel& rPanel,
40 SfxBindings* pBindings)
41 : svx::sidebar::PopupControl( pParent,SVX_RES(RID_POPUPPANEL_TEXTPAGE_UNDERLINE))
42 , mrTextPropertyPanel(rPanel)
43 , mpBindings(pBindings)
44 , maVSUnderline( this, SVX_RES(VS_UNDERLINE))
45 , maPBOptions (this, SVX_RES(PB_OPTIONS) )
46
47 , maIMGSingle (SVX_RES(IMG_SINGLE))
48 , maIMGDouble (SVX_RES(IMG_DOUBLE))
49 , maIMGBold (SVX_RES(IMG_BOLD2))
50 , maIMGDot (SVX_RES(IMG_DOT))
51 , maIMGDotBold (SVX_RES(IMG_DOT_BOLD))
52 , maIMGDash (SVX_RES(IMG_DASH))
53 , maIMGDashLong (SVX_RES(IMG_DASH_LONG))
54 , maIMGDashDot (SVX_RES(IMG_DASH_DOT))
55 , maIMGDashDotDot (SVX_RES(IMG_DASH_DOT_DOT))
56 , maIMGWave (SVX_RES(IMG_WAVE))
57
58 // high contrast
59 , maIMGSingleH (SVX_RES(IMG_SINGLE_H))
60 , maIMGDoubleH (SVX_RES(IMG_DOUBLE_H))
61 , maIMGBoldH (SVX_RES(IMG_BOLD2_H))
62 , maIMGDotH (SVX_RES(IMG_DOT_H))
63 , maIMGDotBoldH (SVX_RES(IMG_DOT_BOLD_H))
64 , maIMGDashH (SVX_RES(IMG_DASH_H))
65 , maIMGDashLongH (SVX_RES(IMG_DASH_LONG_H))
66 , maIMGDashDotH (SVX_RES(IMG_DASH_DOT_H))
67 , maIMGDashDotDotH(SVX_RES(IMG_DASH_DOT_DOT_H))
68 , maIMGWaveH (SVX_RES(IMG_WAVE_H))
69
70 , maIMGSingleSel (SVX_RES(IMG_SINGLE_SEL))
71 , maIMGDoubleSel (SVX_RES(IMG_DOUBLE_SEL))
72 , maIMGBoldSel (SVX_RES(IMG_BOLD2_SEL))
73 , maIMGDotSel (SVX_RES(IMG_DOT_SEL))
74 , maIMGDotBoldSel (SVX_RES(IMG_DOT_BOLD_SEL))
75 , maIMGDashSel (SVX_RES(IMG_DASH_SEL))
76 , maIMGDashLongSel (SVX_RES(IMG_DASH_LONG_SEL))
77 , maIMGDashDotSel (SVX_RES(IMG_DASH_DOT_SEL))
78 , maIMGDashDotDotSel (SVX_RES(IMG_DASH_DOT_DOT_SEL))
79 , maIMGWaveSel (SVX_RES(IMG_WAVE_SEL))
80
81 {
82 initial();
83 FreeResource();
84 }
85
initial()86 void TextUnderlineControl::initial()
87 {
88 maVSUnderline.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
89 GetSettings().GetStyleSettings().GetMenuColor():
90 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
91 maVSUnderline.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()?
92 GetSettings().GetStyleSettings().GetMenuColor():
93 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
94
95 Link aLink = LINK( this, TextUnderlineControl, PBClickHdl ) ;
96 maPBOptions.SetClickHdl(aLink);
97
98 maVSUnderline.SetStyle( maVSUnderline.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT );
99
100 // 'none' item
101 maVSUnderline.SetStyle( maVSUnderline.GetStyle()| WB_NONEFIELD | WB_MENUSTYLEVALUESET );
102 maVSUnderline.SetText( String(SVX_RES(STR_WITHOUT) ) );
103
104 maVSUnderline.InsertItem(1, maIMGSingle ,String(SVX_RES(STR_SINGLE)));
105 maVSUnderline.SetItemData(1, (void*)(sal_uInt64)UNDERLINE_SINGLE);
106
107 maVSUnderline.InsertItem(2, maIMGDouble ,String(SVX_RES(STR_DOUBLE)));
108 maVSUnderline.SetItemData(2, (void*)(sal_uInt64)UNDERLINE_DOUBLE);
109
110 maVSUnderline.InsertItem(3, maIMGBold, String(SVX_RES(STR_BOLD)));
111 maVSUnderline.SetItemData(3,(void*)(sal_uInt64)UNDERLINE_BOLD);
112
113 maVSUnderline.InsertItem(4, maIMGDot, String(SVX_RES(STR_DOT)));
114 maVSUnderline.SetItemData(4,(void*)(sal_uInt64)UNDERLINE_DOTTED);
115
116 maVSUnderline.InsertItem(5, maIMGDotBold, String(SVX_RES(STR_DOT_BOLD)));
117 maVSUnderline.SetItemData(5,(void*)(sal_uInt64)UNDERLINE_BOLDDOTTED);
118
119 maVSUnderline.InsertItem(6, maIMGDash, String(SVX_RES(STR_DASH)));
120 maVSUnderline.SetItemData(6,(void*)(sal_uInt64)UNDERLINE_DASH);
121
122 maVSUnderline.InsertItem(7, maIMGDashLong,String(SVX_RES(STR_DASH_LONG)));
123 maVSUnderline.SetItemData(7,(void*)(sal_uInt64)UNDERLINE_LONGDASH);
124
125 maVSUnderline.InsertItem(8, maIMGDashDot, String(SVX_RES(STR_DASH_DOT)));
126 maVSUnderline.SetItemData(8,(void*)(sal_uInt64)UNDERLINE_DASHDOT);
127
128 maVSUnderline.InsertItem(9, maIMGDashDotDot, String(SVX_RES(STR_DASH_DOT_DOT)));
129 maVSUnderline.SetItemData(9,(void*)(sal_uInt64)UNDERLINE_DASHDOTDOT);
130
131 maVSUnderline.InsertItem(10, maIMGWave, String(SVX_RES(STR_WAVE)));
132 maVSUnderline.SetItemData(10,(void*)(sal_uInt64)UNDERLINE_WAVE);
133
134 maVSUnderline.SetColCount( 1 );
135 aLink = LINK( this, TextUnderlineControl, VSSelectHdl ) ;
136 maVSUnderline.SetSelectHdl(aLink);
137
138 maVSUnderline.StartSelection();
139 maVSUnderline.Show();
140 }
141
142
Rearrange(FontUnderline eLine)143 void TextUnderlineControl::Rearrange(FontUnderline eLine)
144 {
145 // high contrast
146 maVSUnderline.SetItemImage(1, GetDisplayBackground().GetColor().IsDark()? maIMGSingleH :maIMGSingle);
147 maVSUnderline.SetItemImage(2, GetDisplayBackground().GetColor().IsDark()? maIMGDoubleH : maIMGDouble );
148 maVSUnderline.SetItemImage(3, GetDisplayBackground().GetColor().IsDark()? maIMGBoldH : maIMGBold);
149 maVSUnderline.SetItemImage(4, GetDisplayBackground().GetColor().IsDark()? maIMGDotH : maIMGDot);
150 maVSUnderline.SetItemImage(5, GetDisplayBackground().GetColor().IsDark()? maIMGDotBoldH :maIMGDotBold);
151 maVSUnderline.SetItemImage(6, GetDisplayBackground().GetColor().IsDark()? maIMGDashH :maIMGDash);
152 maVSUnderline.SetItemImage(7, GetDisplayBackground().GetColor().IsDark()? maIMGDashLongH : maIMGDashLong);
153 maVSUnderline.SetItemImage(8, GetDisplayBackground().GetColor().IsDark()? maIMGDashDotH : maIMGDashDot);
154 maVSUnderline.SetItemImage(9, GetDisplayBackground().GetColor().IsDark()? maIMGDashDotDotH : maIMGDashDotDot);
155 maVSUnderline.SetItemImage(10, GetDisplayBackground().GetColor().IsDark()? maIMGWaveH : maIMGWave);
156
157 switch(eLine)
158 {
159 case UNDERLINE_SINGLE:
160 maVSUnderline.SetItemImage(1, maIMGSingleSel);
161 maVSUnderline.SelectItem(1);
162 maVSUnderline.GrabFocus();
163 break;
164 case UNDERLINE_DOUBLE:
165 maVSUnderline.SetItemImage(2, maIMGDoubleSel);
166 maVSUnderline.SelectItem(2);
167 maVSUnderline.GrabFocus();
168 break;
169 case UNDERLINE_BOLD:
170 maVSUnderline.SetItemImage(3, maIMGBoldSel);
171 maVSUnderline.SelectItem(3);
172 maVSUnderline.GrabFocus();
173 break;
174 case UNDERLINE_DOTTED:
175 maVSUnderline.SetItemImage(4, maIMGDotSel);
176 maVSUnderline.SelectItem(4);
177 maVSUnderline.GrabFocus();
178 break;
179 case UNDERLINE_BOLDDOTTED:
180 maVSUnderline.SetItemImage(5, maIMGDotBoldSel);
181 maVSUnderline.SelectItem(5);
182 maVSUnderline.GrabFocus();
183 break;
184 case UNDERLINE_DASH:
185 maVSUnderline.SetItemImage(6, maIMGDashSel);
186 maVSUnderline.SelectItem(6);
187 maVSUnderline.GrabFocus();
188 break;
189 case UNDERLINE_LONGDASH:
190 maVSUnderline.SetItemImage(7, maIMGDashLongSel);
191 maVSUnderline.SelectItem(7);
192 maVSUnderline.GrabFocus();
193 break;
194 case UNDERLINE_DASHDOT:
195 maVSUnderline.SetItemImage(8, maIMGDashDotSel);
196 maVSUnderline.SelectItem(8);
197 maVSUnderline.GrabFocus();
198 break;
199 case UNDERLINE_DASHDOTDOT:
200 maVSUnderline.SetItemImage(9, maIMGDashDotDotSel);
201 maVSUnderline.SelectItem(9);
202 maVSUnderline.GrabFocus();
203 break;
204 case UNDERLINE_WAVE:
205 maVSUnderline.SetItemImage(10, maIMGWaveSel);
206 maVSUnderline.SelectItem(10);
207 maVSUnderline.GrabFocus();
208 break;
209 case UNDERLINE_NONE:
210 maVSUnderline.SelectItem(0);
211 maVSUnderline.GrabFocus();
212 break;
213 default:
214 maVSUnderline.SelectItem(1);
215 maVSUnderline.SetNoSelection();
216 maPBOptions.GrabFocus();
217 }
218 maVSUnderline.StartSelection();
219 }
220
221
IMPL_LINK(TextUnderlineControl,VSSelectHdl,void *,pControl)222 IMPL_LINK(TextUnderlineControl, VSSelectHdl, void *, pControl)
223 {
224 if ( pControl == &maVSUnderline )
225 {
226 const sal_uInt16 iPos = maVSUnderline.GetSelectItemId();
227 const FontUnderline eUnderline = ( iPos == 0 )
228 ? UNDERLINE_NONE
229 : (FontUnderline)(sal_uInt64)maVSUnderline.GetItemData( iPos );
230
231 SvxUnderlineItem aLineItem(eUnderline, SID_ATTR_CHAR_UNDERLINE);
232
233 aLineItem.SetColor(mrTextPropertyPanel.GetUnderlineColor());
234 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L);
235
236 mrTextPropertyPanel.SetUnderline(eUnderline);
237
238 mrTextPropertyPanel.EndUnderlinePopupMode();
239 }
240 return( 0L );
241 }
242
IMPL_LINK(TextUnderlineControl,PBClickHdl,PushButton *,pPBtn)243 IMPL_LINK(TextUnderlineControl, PBClickHdl, PushButton *, pPBtn)
244 {
245 if(pPBtn == &maPBOptions)
246 {
247 if (mpBindings)
248 {
249 SfxDispatcher* pDisp = mpBindings->GetDispatcher();
250 pDisp->Execute( SID_CHAR_DLG_EFFECT, SFX_CALLMODE_ASYNCHRON );
251 }
252 mrTextPropertyPanel.EndUnderlinePopupMode();
253 }
254 return 0;
255 }
256
257 }}
258