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
22d4aefcaeSZheng Fan #include "precompiled_svx.hxx"
23d4aefcaeSZheng Fan #include "TextUnderlineControl.hxx"
24d4aefcaeSZheng Fan #include "TextPropertyPanel.hrc"
25d29c2fc2SAndre Fischer #include <sfx2/sidebar/ResourceDefinitions.hrc>
26d4aefcaeSZheng Fan #include <svx/dialogs.hrc>
27d4aefcaeSZheng Fan #include <svx/dialmgr.hxx>
28d4aefcaeSZheng Fan #include <unotools/viewoptions.hxx>
29d4aefcaeSZheng Fan #include <editeng/kernitem.hxx>
30d4aefcaeSZheng Fan #include <sfx2/bindings.hxx>
31d4aefcaeSZheng Fan #include <sfx2/dispatch.hxx>
32d4aefcaeSZheng Fan #include <sfx2/sidebar/Theme.hxx>
33d4aefcaeSZheng Fan #include <editeng/udlnitem.hxx>
34d4aefcaeSZheng Fan
35d4aefcaeSZheng Fan namespace svx { namespace sidebar {
36d4aefcaeSZheng Fan
TextUnderlineControl(Window * pParent,svx::sidebar::TextPropertyPanel & rPanel,SfxBindings * pBindings)3745da7d5eSAndre Fischer TextUnderlineControl::TextUnderlineControl (
3845da7d5eSAndre Fischer Window* pParent,
3945da7d5eSAndre Fischer svx::sidebar::TextPropertyPanel& rPanel,
4045da7d5eSAndre Fischer SfxBindings* pBindings)
41d4aefcaeSZheng Fan : svx::sidebar::PopupControl( pParent,SVX_RES(RID_POPUPPANEL_TEXTPAGE_UNDERLINE))
42d4aefcaeSZheng Fan , mrTextPropertyPanel(rPanel)
4345da7d5eSAndre Fischer , mpBindings(pBindings)
44d4aefcaeSZheng Fan , maVSUnderline( this, SVX_RES(VS_UNDERLINE))
45d4aefcaeSZheng Fan , maPBOptions (this, SVX_RES(PB_OPTIONS) )
46d4aefcaeSZheng Fan
47d4aefcaeSZheng Fan , maIMGSingle (SVX_RES(IMG_SINGLE))
48d4aefcaeSZheng Fan , maIMGDouble (SVX_RES(IMG_DOUBLE))
49d4aefcaeSZheng Fan , maIMGBold (SVX_RES(IMG_BOLD2))
50d4aefcaeSZheng Fan , maIMGDot (SVX_RES(IMG_DOT))
51d4aefcaeSZheng Fan , maIMGDotBold (SVX_RES(IMG_DOT_BOLD))
52d4aefcaeSZheng Fan , maIMGDash (SVX_RES(IMG_DASH))
53d4aefcaeSZheng Fan , maIMGDashLong (SVX_RES(IMG_DASH_LONG))
54d4aefcaeSZheng Fan , maIMGDashDot (SVX_RES(IMG_DASH_DOT))
55d4aefcaeSZheng Fan , maIMGDashDotDot (SVX_RES(IMG_DASH_DOT_DOT))
56d4aefcaeSZheng Fan , maIMGWave (SVX_RES(IMG_WAVE))
57d4aefcaeSZheng Fan
58d4aefcaeSZheng Fan // high contrast
59d4aefcaeSZheng Fan , maIMGSingleH (SVX_RES(IMG_SINGLE_H))
60d4aefcaeSZheng Fan , maIMGDoubleH (SVX_RES(IMG_DOUBLE_H))
61d4aefcaeSZheng Fan , maIMGBoldH (SVX_RES(IMG_BOLD2_H))
62d4aefcaeSZheng Fan , maIMGDotH (SVX_RES(IMG_DOT_H))
63d4aefcaeSZheng Fan , maIMGDotBoldH (SVX_RES(IMG_DOT_BOLD_H))
64d4aefcaeSZheng Fan , maIMGDashH (SVX_RES(IMG_DASH_H))
65d4aefcaeSZheng Fan , maIMGDashLongH (SVX_RES(IMG_DASH_LONG_H))
66d4aefcaeSZheng Fan , maIMGDashDotH (SVX_RES(IMG_DASH_DOT_H))
67d4aefcaeSZheng Fan , maIMGDashDotDotH(SVX_RES(IMG_DASH_DOT_DOT_H))
68d4aefcaeSZheng Fan , maIMGWaveH (SVX_RES(IMG_WAVE_H))
69d4aefcaeSZheng Fan
70d4aefcaeSZheng Fan , maIMGSingleSel (SVX_RES(IMG_SINGLE_SEL))
71d4aefcaeSZheng Fan , maIMGDoubleSel (SVX_RES(IMG_DOUBLE_SEL))
72d4aefcaeSZheng Fan , maIMGBoldSel (SVX_RES(IMG_BOLD2_SEL))
73d4aefcaeSZheng Fan , maIMGDotSel (SVX_RES(IMG_DOT_SEL))
74d4aefcaeSZheng Fan , maIMGDotBoldSel (SVX_RES(IMG_DOT_BOLD_SEL))
75d4aefcaeSZheng Fan , maIMGDashSel (SVX_RES(IMG_DASH_SEL))
76d4aefcaeSZheng Fan , maIMGDashLongSel (SVX_RES(IMG_DASH_LONG_SEL))
77d4aefcaeSZheng Fan , maIMGDashDotSel (SVX_RES(IMG_DASH_DOT_SEL))
78d4aefcaeSZheng Fan , maIMGDashDotDotSel (SVX_RES(IMG_DASH_DOT_DOT_SEL))
79d4aefcaeSZheng Fan , maIMGWaveSel (SVX_RES(IMG_WAVE_SEL))
80d4aefcaeSZheng Fan
81d4aefcaeSZheng Fan {
82d4aefcaeSZheng Fan initial();
83d4aefcaeSZheng Fan FreeResource();
84d4aefcaeSZheng Fan }
85d4aefcaeSZheng Fan
initial()86d4aefcaeSZheng Fan void TextUnderlineControl::initial()
87d4aefcaeSZheng Fan {
88d4aefcaeSZheng Fan maVSUnderline.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
89d4aefcaeSZheng Fan GetSettings().GetStyleSettings().GetMenuColor():
90d4aefcaeSZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
91d4aefcaeSZheng Fan maVSUnderline.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()?
92d4aefcaeSZheng Fan GetSettings().GetStyleSettings().GetMenuColor():
93d4aefcaeSZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ));
94d4aefcaeSZheng Fan
95d4aefcaeSZheng Fan Link aLink = LINK( this, TextUnderlineControl, PBClickHdl ) ;
96d4aefcaeSZheng Fan maPBOptions.SetClickHdl(aLink);
97d4aefcaeSZheng Fan
98900fdb6dSOliver-Rainer Wittmann maVSUnderline.SetStyle( maVSUnderline.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT );
99d4aefcaeSZheng Fan
100*a3586beeSOliver-Rainer Wittmann // 'none' item
101*a3586beeSOliver-Rainer Wittmann maVSUnderline.SetStyle( maVSUnderline.GetStyle()| WB_NONEFIELD | WB_MENUSTYLEVALUESET );
102*a3586beeSOliver-Rainer Wittmann maVSUnderline.SetText( String(SVX_RES(STR_WITHOUT) ) );
103*a3586beeSOliver-Rainer Wittmann
104d4aefcaeSZheng Fan maVSUnderline.InsertItem(1, maIMGSingle ,String(SVX_RES(STR_SINGLE)));
105d4aefcaeSZheng Fan maVSUnderline.SetItemData(1, (void*)(sal_uInt64)UNDERLINE_SINGLE);
106d4aefcaeSZheng Fan
107d4aefcaeSZheng Fan maVSUnderline.InsertItem(2, maIMGDouble ,String(SVX_RES(STR_DOUBLE)));
108d4aefcaeSZheng Fan maVSUnderline.SetItemData(2, (void*)(sal_uInt64)UNDERLINE_DOUBLE);
109d4aefcaeSZheng Fan
110d4aefcaeSZheng Fan maVSUnderline.InsertItem(3, maIMGBold, String(SVX_RES(STR_BOLD)));
111d4aefcaeSZheng Fan maVSUnderline.SetItemData(3,(void*)(sal_uInt64)UNDERLINE_BOLD);
112d4aefcaeSZheng Fan
113d4aefcaeSZheng Fan maVSUnderline.InsertItem(4, maIMGDot, String(SVX_RES(STR_DOT)));
114d4aefcaeSZheng Fan maVSUnderline.SetItemData(4,(void*)(sal_uInt64)UNDERLINE_DOTTED);
115d4aefcaeSZheng Fan
116d4aefcaeSZheng Fan maVSUnderline.InsertItem(5, maIMGDotBold, String(SVX_RES(STR_DOT_BOLD)));
117d4aefcaeSZheng Fan maVSUnderline.SetItemData(5,(void*)(sal_uInt64)UNDERLINE_BOLDDOTTED);
118d4aefcaeSZheng Fan
119d4aefcaeSZheng Fan maVSUnderline.InsertItem(6, maIMGDash, String(SVX_RES(STR_DASH)));
120d4aefcaeSZheng Fan maVSUnderline.SetItemData(6,(void*)(sal_uInt64)UNDERLINE_DASH);
121d4aefcaeSZheng Fan
122d4aefcaeSZheng Fan maVSUnderline.InsertItem(7, maIMGDashLong,String(SVX_RES(STR_DASH_LONG)));
123d4aefcaeSZheng Fan maVSUnderline.SetItemData(7,(void*)(sal_uInt64)UNDERLINE_LONGDASH);
124d4aefcaeSZheng Fan
125d4aefcaeSZheng Fan maVSUnderline.InsertItem(8, maIMGDashDot, String(SVX_RES(STR_DASH_DOT)));
126d4aefcaeSZheng Fan maVSUnderline.SetItemData(8,(void*)(sal_uInt64)UNDERLINE_DASHDOT);
127d4aefcaeSZheng Fan
128d4aefcaeSZheng Fan maVSUnderline.InsertItem(9, maIMGDashDotDot, String(SVX_RES(STR_DASH_DOT_DOT)));
129d4aefcaeSZheng Fan maVSUnderline.SetItemData(9,(void*)(sal_uInt64)UNDERLINE_DASHDOTDOT);
130d4aefcaeSZheng Fan
131d4aefcaeSZheng Fan maVSUnderline.InsertItem(10, maIMGWave, String(SVX_RES(STR_WAVE)));
132d4aefcaeSZheng Fan maVSUnderline.SetItemData(10,(void*)(sal_uInt64)UNDERLINE_WAVE);
133d4aefcaeSZheng Fan
134d4aefcaeSZheng Fan maVSUnderline.SetColCount( 1 );
135d4aefcaeSZheng Fan aLink = LINK( this, TextUnderlineControl, VSSelectHdl ) ;
136d4aefcaeSZheng Fan maVSUnderline.SetSelectHdl(aLink);
137d4aefcaeSZheng Fan
138d4aefcaeSZheng Fan maVSUnderline.StartSelection();
139d4aefcaeSZheng Fan maVSUnderline.Show();
140d4aefcaeSZheng Fan }
141d4aefcaeSZheng Fan
142900fdb6dSOliver-Rainer Wittmann
Rearrange(FontUnderline eLine)143d4aefcaeSZheng Fan void TextUnderlineControl::Rearrange(FontUnderline eLine)
144d4aefcaeSZheng Fan {
145d4aefcaeSZheng Fan // high contrast
146d4aefcaeSZheng Fan maVSUnderline.SetItemImage(1, GetDisplayBackground().GetColor().IsDark()? maIMGSingleH :maIMGSingle);
147d4aefcaeSZheng Fan maVSUnderline.SetItemImage(2, GetDisplayBackground().GetColor().IsDark()? maIMGDoubleH : maIMGDouble );
148d4aefcaeSZheng Fan maVSUnderline.SetItemImage(3, GetDisplayBackground().GetColor().IsDark()? maIMGBoldH : maIMGBold);
149d4aefcaeSZheng Fan maVSUnderline.SetItemImage(4, GetDisplayBackground().GetColor().IsDark()? maIMGDotH : maIMGDot);
150d4aefcaeSZheng Fan maVSUnderline.SetItemImage(5, GetDisplayBackground().GetColor().IsDark()? maIMGDotBoldH :maIMGDotBold);
151d4aefcaeSZheng Fan maVSUnderline.SetItemImage(6, GetDisplayBackground().GetColor().IsDark()? maIMGDashH :maIMGDash);
152d4aefcaeSZheng Fan maVSUnderline.SetItemImage(7, GetDisplayBackground().GetColor().IsDark()? maIMGDashLongH : maIMGDashLong);
153d4aefcaeSZheng Fan maVSUnderline.SetItemImage(8, GetDisplayBackground().GetColor().IsDark()? maIMGDashDotH : maIMGDashDot);
154d4aefcaeSZheng Fan maVSUnderline.SetItemImage(9, GetDisplayBackground().GetColor().IsDark()? maIMGDashDotDotH : maIMGDashDotDot);
155d4aefcaeSZheng Fan maVSUnderline.SetItemImage(10, GetDisplayBackground().GetColor().IsDark()? maIMGWaveH : maIMGWave);
156d4aefcaeSZheng Fan
157d4aefcaeSZheng Fan switch(eLine)
158d4aefcaeSZheng Fan {
159d4aefcaeSZheng Fan case UNDERLINE_SINGLE:
160d4aefcaeSZheng Fan maVSUnderline.SetItemImage(1, maIMGSingleSel);
1618ce66e53SOliver-Rainer Wittmann maVSUnderline.SelectItem(1);
162d4aefcaeSZheng Fan maVSUnderline.GrabFocus();
163d4aefcaeSZheng Fan break;
164d4aefcaeSZheng Fan case UNDERLINE_DOUBLE:
165d4aefcaeSZheng Fan maVSUnderline.SetItemImage(2, maIMGDoubleSel);
1668ce66e53SOliver-Rainer Wittmann maVSUnderline.SelectItem(2);
167d4aefcaeSZheng Fan maVSUnderline.GrabFocus();
168d4aefcaeSZheng Fan break;
169d4aefcaeSZheng Fan case UNDERLINE_BOLD:
170d4aefcaeSZheng Fan maVSUnderline.SetItemImage(3, maIMGBoldSel);
1718ce66e53SOliver-Rainer Wittmann maVSUnderline.SelectItem(3);
172d4aefcaeSZheng Fan maVSUnderline.GrabFocus();
173d4aefcaeSZheng Fan break;
174d4aefcaeSZheng Fan case UNDERLINE_DOTTED:
175d4aefcaeSZheng Fan maVSUnderline.SetItemImage(4, maIMGDotSel);
1768ce66e53SOliver-Rainer Wittmann maVSUnderline.SelectItem(4);
177d4aefcaeSZheng Fan maVSUnderline.GrabFocus();
178d4aefcaeSZheng Fan break;
179d4aefcaeSZheng Fan case UNDERLINE_BOLDDOTTED:
180d4aefcaeSZheng Fan maVSUnderline.SetItemImage(5, maIMGDotBoldSel);
1818ce66e53SOliver-Rainer Wittmann maVSUnderline.SelectItem(5);
182d4aefcaeSZheng Fan maVSUnderline.GrabFocus();
183d4aefcaeSZheng Fan break;
184d4aefcaeSZheng Fan case UNDERLINE_DASH:
185d4aefcaeSZheng Fan maVSUnderline.SetItemImage(6, maIMGDashSel);
1868ce66e53SOliver-Rainer Wittmann maVSUnderline.SelectItem(6);
187d4aefcaeSZheng Fan maVSUnderline.GrabFocus();
188d4aefcaeSZheng Fan break;
189d4aefcaeSZheng Fan case UNDERLINE_LONGDASH:
190d4aefcaeSZheng Fan maVSUnderline.SetItemImage(7, maIMGDashLongSel);
1918ce66e53SOliver-Rainer Wittmann maVSUnderline.SelectItem(7);
192d4aefcaeSZheng Fan maVSUnderline.GrabFocus();
193d4aefcaeSZheng Fan break;
194d4aefcaeSZheng Fan case UNDERLINE_DASHDOT:
195d4aefcaeSZheng Fan maVSUnderline.SetItemImage(8, maIMGDashDotSel);
1968ce66e53SOliver-Rainer Wittmann maVSUnderline.SelectItem(8);
197d4aefcaeSZheng Fan maVSUnderline.GrabFocus();
198d4aefcaeSZheng Fan break;
199d4aefcaeSZheng Fan case UNDERLINE_DASHDOTDOT:
200d4aefcaeSZheng Fan maVSUnderline.SetItemImage(9, maIMGDashDotDotSel);
2018ce66e53SOliver-Rainer Wittmann maVSUnderline.SelectItem(9);
202d4aefcaeSZheng Fan maVSUnderline.GrabFocus();
203d4aefcaeSZheng Fan break;
204d4aefcaeSZheng Fan case UNDERLINE_WAVE:
205d4aefcaeSZheng Fan maVSUnderline.SetItemImage(10, maIMGWaveSel);
2068ce66e53SOliver-Rainer Wittmann maVSUnderline.SelectItem(10);
207d4aefcaeSZheng Fan maVSUnderline.GrabFocus();
208d4aefcaeSZheng Fan break;
209d4aefcaeSZheng Fan case UNDERLINE_NONE:
210*a3586beeSOliver-Rainer Wittmann maVSUnderline.SelectItem(0);
211*a3586beeSOliver-Rainer Wittmann maVSUnderline.GrabFocus();
212*a3586beeSOliver-Rainer Wittmann break;
213d4aefcaeSZheng Fan default:
214d4aefcaeSZheng Fan maVSUnderline.SelectItem(1);
2158ce66e53SOliver-Rainer Wittmann maVSUnderline.SetNoSelection();
216d4aefcaeSZheng Fan maPBOptions.GrabFocus();
217d4aefcaeSZheng Fan }
218d4aefcaeSZheng Fan maVSUnderline.StartSelection();
219d4aefcaeSZheng Fan }
220900fdb6dSOliver-Rainer Wittmann
221900fdb6dSOliver-Rainer Wittmann
IMPL_LINK(TextUnderlineControl,VSSelectHdl,void *,pControl)222d4aefcaeSZheng Fan IMPL_LINK(TextUnderlineControl, VSSelectHdl, void *, pControl)
223d4aefcaeSZheng Fan {
224d4aefcaeSZheng Fan if ( pControl == &maVSUnderline )
225d4aefcaeSZheng Fan {
226*a3586beeSOliver-Rainer Wittmann const sal_uInt16 iPos = maVSUnderline.GetSelectItemId();
227*a3586beeSOliver-Rainer Wittmann const FontUnderline eUnderline = ( iPos == 0 )
228*a3586beeSOliver-Rainer Wittmann ? UNDERLINE_NONE
229*a3586beeSOliver-Rainer Wittmann : (FontUnderline)(sal_uInt64)maVSUnderline.GetItemData( iPos );
230d4aefcaeSZheng Fan
231d4aefcaeSZheng Fan SvxUnderlineItem aLineItem(eUnderline, SID_ATTR_CHAR_UNDERLINE);
232d4aefcaeSZheng Fan
233d4aefcaeSZheng Fan aLineItem.SetColor(mrTextPropertyPanel.GetUnderlineColor());
234d4aefcaeSZheng Fan mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L);
235d4aefcaeSZheng Fan
236d4aefcaeSZheng Fan mrTextPropertyPanel.SetUnderline(eUnderline);
237d4aefcaeSZheng Fan
238d4aefcaeSZheng Fan mrTextPropertyPanel.EndUnderlinePopupMode();
239d4aefcaeSZheng Fan }
240d4aefcaeSZheng Fan return( 0L );
241d4aefcaeSZheng Fan }
242d4aefcaeSZheng Fan
IMPL_LINK(TextUnderlineControl,PBClickHdl,PushButton *,pPBtn)243d4aefcaeSZheng Fan IMPL_LINK(TextUnderlineControl, PBClickHdl, PushButton *, pPBtn)
244d4aefcaeSZheng Fan {
245d4aefcaeSZheng Fan if(pPBtn == &maPBOptions)
246d4aefcaeSZheng Fan {
247d4aefcaeSZheng Fan if (mpBindings)
248d4aefcaeSZheng Fan {
249d4aefcaeSZheng Fan SfxDispatcher* pDisp = mpBindings->GetDispatcher();
250d4aefcaeSZheng Fan pDisp->Execute( SID_CHAR_DLG_EFFECT, SFX_CALLMODE_ASYNCHRON );
251d4aefcaeSZheng Fan }
252d4aefcaeSZheng Fan mrTextPropertyPanel.EndUnderlinePopupMode();
253d4aefcaeSZheng Fan }
254d4aefcaeSZheng Fan return 0;
255d4aefcaeSZheng Fan }
256d4aefcaeSZheng Fan
257d4aefcaeSZheng Fan }}
258