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