Line data Source code
1 : /*
2 : * This file is part of the LibreOffice project.
3 : *
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/.
7 : *
8 : * This file incorporates work covered by the following license notice:
9 : *
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 .
17 : */
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>
29 :
30 : namespace svx { namespace sidebar {
31 :
32 0 : TextUnderlineControl::TextUnderlineControl (
33 : Window* pParent,
34 : svx::sidebar::TextPropertyPanel& rPanel,
35 : SfxBindings* pBindings)
36 0 : : svx::sidebar::PopupControl( pParent,SVX_RES(RID_POPUPPANEL_TEXTPAGE_UNDERLINE))
37 : , mrTextPropertyPanel(rPanel)
38 : , mpBindings(pBindings)
39 0 : , maVSUnderline( this, SVX_RES(VS_UNDERLINE))
40 0 : , maPBOptions (this, SVX_RES(PB_OPTIONS) )
41 :
42 0 : , maIMGSingle (SVX_RES(IMG_SINGLE))
43 0 : , maIMGDouble (SVX_RES(IMG_DOUBLE))
44 0 : , maIMGBold (SVX_RES(IMG_BOLD2))
45 0 : , maIMGDot (SVX_RES(IMG_DOT))
46 0 : , maIMGDotBold (SVX_RES(IMG_DOT_BOLD))
47 0 : , maIMGDash (SVX_RES(IMG_DASH))
48 0 : , maIMGDashLong (SVX_RES(IMG_DASH_LONG))
49 0 : , maIMGDashDot (SVX_RES(IMG_DASH_DOT))
50 0 : , maIMGDashDotDot (SVX_RES(IMG_DASH_DOT_DOT))
51 0 : , maIMGWave (SVX_RES(IMG_WAVE))
52 :
53 0 : , maIMGSingleSel (SVX_RES(IMG_SINGLE_SEL))
54 0 : , maIMGDoubleSel (SVX_RES(IMG_DOUBLE_SEL))
55 0 : , maIMGBoldSel (SVX_RES(IMG_BOLD2_SEL))
56 0 : , maIMGDotSel (SVX_RES(IMG_DOT_SEL))
57 0 : , maIMGDotBoldSel (SVX_RES(IMG_DOT_BOLD_SEL))
58 0 : , maIMGDashSel (SVX_RES(IMG_DASH_SEL))
59 0 : , maIMGDashLongSel (SVX_RES(IMG_DASH_LONG_SEL))
60 0 : , maIMGDashDotSel (SVX_RES(IMG_DASH_DOT_SEL))
61 0 : , maIMGDashDotDotSel (SVX_RES(IMG_DASH_DOT_DOT_SEL))
62 0 : , maIMGWaveSel (SVX_RES(IMG_WAVE_SEL))
63 :
64 : {
65 0 : initial();
66 0 : FreeResource();
67 0 : }
68 :
69 0 : void TextUnderlineControl::initial()
70 : {
71 0 : maVSUnderline.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
72 0 : GetSettings().GetStyleSettings().GetMenuColor():
73 0 : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
74 0 : maVSUnderline.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()?
75 0 : GetSettings().GetStyleSettings().GetMenuColor():
76 0 : sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
77 :
78 0 : Link aLink = LINK( this, TextUnderlineControl, PBClickHdl ) ;
79 0 : maPBOptions.SetClickHdl(aLink);
80 :
81 0 : maVSUnderline.SetStyle( maVSUnderline.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT );
82 :
83 : // 'none' item
84 0 : maVSUnderline.SetStyle( maVSUnderline.GetStyle()| WB_NONEFIELD | WB_MENUSTYLEVALUESET );
85 0 : maVSUnderline.SetText( String(SVX_RES(STR_WITHOUT) ) );
86 :
87 0 : maVSUnderline.InsertItem(1, maIMGSingle ,String(SVX_RES(STR_SINGLE)));
88 0 : maVSUnderline.SetItemData(1, (void*)(sal_uInt64)UNDERLINE_SINGLE);
89 :
90 0 : maVSUnderline.InsertItem(2, maIMGDouble ,String(SVX_RES(STR_DOUBLE)));
91 0 : maVSUnderline.SetItemData(2, (void*)(sal_uInt64)UNDERLINE_DOUBLE);
92 :
93 0 : maVSUnderline.InsertItem(3, maIMGBold, String(SVX_RES(STR_BOLD)));
94 0 : maVSUnderline.SetItemData(3,(void*)(sal_uInt64)UNDERLINE_BOLD);
95 :
96 0 : maVSUnderline.InsertItem(4, maIMGDot, String(SVX_RES(STR_DOT)));
97 0 : maVSUnderline.SetItemData(4,(void*)(sal_uInt64)UNDERLINE_DOTTED);
98 :
99 0 : maVSUnderline.InsertItem(5, maIMGDotBold, String(SVX_RES(STR_DOT_BOLD)));
100 0 : maVSUnderline.SetItemData(5,(void*)(sal_uInt64)UNDERLINE_BOLDDOTTED);
101 :
102 0 : maVSUnderline.InsertItem(6, maIMGDash, String(SVX_RES(STR_DASH)));
103 0 : maVSUnderline.SetItemData(6,(void*)(sal_uInt64)UNDERLINE_DASH);
104 :
105 0 : maVSUnderline.InsertItem(7, maIMGDashLong,String(SVX_RES(STR_DASH_LONG)));
106 0 : maVSUnderline.SetItemData(7,(void*)(sal_uInt64)UNDERLINE_LONGDASH);
107 :
108 0 : maVSUnderline.InsertItem(8, maIMGDashDot, String(SVX_RES(STR_DASH_DOT)));
109 0 : maVSUnderline.SetItemData(8,(void*)(sal_uInt64)UNDERLINE_DASHDOT);
110 :
111 0 : maVSUnderline.InsertItem(9, maIMGDashDotDot, String(SVX_RES(STR_DASH_DOT_DOT)));
112 0 : maVSUnderline.SetItemData(9,(void*)(sal_uInt64)UNDERLINE_DASHDOTDOT);
113 :
114 0 : maVSUnderline.InsertItem(10, maIMGWave, String(SVX_RES(STR_WAVE)));
115 0 : maVSUnderline.SetItemData(10,(void*)(sal_uInt64)UNDERLINE_WAVE);
116 :
117 0 : maVSUnderline.SetColCount( 1 );
118 0 : aLink = LINK( this, TextUnderlineControl, VSSelectHdl ) ;
119 0 : maVSUnderline.SetSelectHdl(aLink);
120 :
121 0 : maVSUnderline.StartSelection();
122 0 : maVSUnderline.Show();
123 0 : }
124 :
125 :
126 0 : void TextUnderlineControl::Rearrange(FontUnderline eLine)
127 : {
128 0 : maVSUnderline.SetItemImage(1, maIMGSingle);
129 0 : maVSUnderline.SetItemImage(2, maIMGDouble );
130 0 : maVSUnderline.SetItemImage(3, maIMGBold);
131 0 : maVSUnderline.SetItemImage(4, maIMGDot);
132 0 : maVSUnderline.SetItemImage(5, maIMGDotBold);
133 0 : maVSUnderline.SetItemImage(6, maIMGDash);
134 0 : maVSUnderline.SetItemImage(7, maIMGDashLong);
135 0 : maVSUnderline.SetItemImage(8, maIMGDashDot);
136 0 : maVSUnderline.SetItemImage(9, maIMGDashDotDot);
137 0 : maVSUnderline.SetItemImage(10, maIMGWave);
138 :
139 0 : switch(eLine)
140 : {
141 : case UNDERLINE_SINGLE:
142 0 : maVSUnderline.SetItemImage(1, maIMGSingleSel);
143 0 : maVSUnderline.SelectItem(1);
144 0 : maVSUnderline.GrabFocus();
145 0 : break;
146 : case UNDERLINE_DOUBLE:
147 0 : maVSUnderline.SetItemImage(2, maIMGDoubleSel);
148 0 : maVSUnderline.SelectItem(2);
149 0 : maVSUnderline.GrabFocus();
150 0 : break;
151 : case UNDERLINE_BOLD:
152 0 : maVSUnderline.SetItemImage(3, maIMGBoldSel);
153 0 : maVSUnderline.SelectItem(3);
154 0 : maVSUnderline.GrabFocus();
155 0 : break;
156 : case UNDERLINE_DOTTED:
157 0 : maVSUnderline.SetItemImage(4, maIMGDotSel);
158 0 : maVSUnderline.SelectItem(4);
159 0 : maVSUnderline.GrabFocus();
160 0 : break;
161 : case UNDERLINE_BOLDDOTTED:
162 0 : maVSUnderline.SetItemImage(5, maIMGDotBoldSel);
163 0 : maVSUnderline.SelectItem(5);
164 0 : maVSUnderline.GrabFocus();
165 0 : break;
166 : case UNDERLINE_DASH:
167 0 : maVSUnderline.SetItemImage(6, maIMGDashSel);
168 0 : maVSUnderline.SelectItem(6);
169 0 : maVSUnderline.GrabFocus();
170 0 : break;
171 : case UNDERLINE_LONGDASH:
172 0 : maVSUnderline.SetItemImage(7, maIMGDashLongSel);
173 0 : maVSUnderline.SelectItem(7);
174 0 : maVSUnderline.GrabFocus();
175 0 : break;
176 : case UNDERLINE_DASHDOT:
177 0 : maVSUnderline.SetItemImage(8, maIMGDashDotSel);
178 0 : maVSUnderline.SelectItem(8);
179 0 : maVSUnderline.GrabFocus();
180 0 : break;
181 : case UNDERLINE_DASHDOTDOT:
182 0 : maVSUnderline.SetItemImage(9, maIMGDashDotDotSel);
183 0 : maVSUnderline.SelectItem(9);
184 0 : maVSUnderline.GrabFocus();
185 0 : break;
186 : case UNDERLINE_WAVE:
187 0 : maVSUnderline.SetItemImage(10, maIMGWaveSel);
188 0 : maVSUnderline.SelectItem(10);
189 0 : maVSUnderline.GrabFocus();
190 0 : break;
191 : case UNDERLINE_NONE:
192 0 : maVSUnderline.SelectItem(0);
193 0 : maVSUnderline.GrabFocus();
194 0 : break;
195 : default:
196 0 : maVSUnderline.SelectItem(1);
197 0 : maVSUnderline.SetNoSelection();
198 0 : maPBOptions.GrabFocus();
199 : }
200 0 : maVSUnderline.StartSelection();
201 0 : }
202 :
203 :
204 0 : IMPL_LINK(TextUnderlineControl, VSSelectHdl, void *, pControl)
205 : {
206 0 : if ( pControl == &maVSUnderline )
207 : {
208 0 : const sal_uInt16 iPos = maVSUnderline.GetSelectItemId();
209 : const FontUnderline eUnderline = ( iPos == 0 )
210 : ? UNDERLINE_NONE
211 0 : : (FontUnderline)(sal_uInt64)maVSUnderline.GetItemData( iPos );
212 :
213 0 : SvxUnderlineItem aLineItem(eUnderline, SID_ATTR_CHAR_UNDERLINE);
214 :
215 0 : aLineItem.SetColor(mrTextPropertyPanel.GetUnderlineColor());
216 0 : mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L);
217 :
218 0 : mrTextPropertyPanel.SetUnderline(eUnderline);
219 :
220 0 : mrTextPropertyPanel.EndUnderlinePopupMode();
221 : }
222 0 : return( 0L );
223 : }
224 :
225 0 : IMPL_LINK(TextUnderlineControl, PBClickHdl, PushButton *, pPBtn)
226 : {
227 0 : if(pPBtn == &maPBOptions)
228 : {
229 0 : if (mpBindings)
230 : {
231 0 : SfxDispatcher* pDisp = mpBindings->GetDispatcher();
232 0 : pDisp->Execute( SID_CHAR_DLG_EFFECT, SFX_CALLMODE_ASYNCHRON );
233 : }
234 0 : mrTextPropertyPanel.EndUnderlinePopupMode();
235 : }
236 0 : return 0;
237 : }
238 :
239 216 : }}
|