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 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 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 maVSUnderline.InsertItem(1, maIMGSingle ,String(SVX_RES(STR_SINGLE))); 101 maVSUnderline.SetItemData(1, (void*)(sal_uInt64)UNDERLINE_SINGLE); 102 103 maVSUnderline.InsertItem(2, maIMGDouble ,String(SVX_RES(STR_DOUBLE))); 104 maVSUnderline.SetItemData(2, (void*)(sal_uInt64)UNDERLINE_DOUBLE); 105 106 maVSUnderline.InsertItem(3, maIMGBold, String(SVX_RES(STR_BOLD))); 107 maVSUnderline.SetItemData(3,(void*)(sal_uInt64)UNDERLINE_BOLD); 108 109 maVSUnderline.InsertItem(4, maIMGDot, String(SVX_RES(STR_DOT))); 110 maVSUnderline.SetItemData(4,(void*)(sal_uInt64)UNDERLINE_DOTTED); 111 112 maVSUnderline.InsertItem(5, maIMGDotBold, String(SVX_RES(STR_DOT_BOLD))); 113 maVSUnderline.SetItemData(5,(void*)(sal_uInt64)UNDERLINE_BOLDDOTTED); 114 115 maVSUnderline.InsertItem(6, maIMGDash, String(SVX_RES(STR_DASH))); 116 maVSUnderline.SetItemData(6,(void*)(sal_uInt64)UNDERLINE_DASH); 117 118 maVSUnderline.InsertItem(7, maIMGDashLong,String(SVX_RES(STR_DASH_LONG))); 119 maVSUnderline.SetItemData(7,(void*)(sal_uInt64)UNDERLINE_LONGDASH); 120 121 maVSUnderline.InsertItem(8, maIMGDashDot, String(SVX_RES(STR_DASH_DOT))); 122 maVSUnderline.SetItemData(8,(void*)(sal_uInt64)UNDERLINE_DASHDOT); 123 124 maVSUnderline.InsertItem(9, maIMGDashDotDot, String(SVX_RES(STR_DASH_DOT_DOT))); 125 maVSUnderline.SetItemData(9,(void*)(sal_uInt64)UNDERLINE_DASHDOTDOT); 126 127 maVSUnderline.InsertItem(10, maIMGWave, String(SVX_RES(STR_WAVE))); 128 maVSUnderline.SetItemData(10,(void*)(sal_uInt64)UNDERLINE_WAVE); 129 130 maVSUnderline.SetColCount( 1 ); 131 aLink = LINK( this, TextUnderlineControl, VSSelectHdl ) ; 132 maVSUnderline.SetSelectHdl(aLink); 133 134 maVSUnderline.StartSelection(); 135 maVSUnderline.Show(); 136 } 137 138 139 void TextUnderlineControl::Rearrange(FontUnderline eLine) 140 { 141 // high contrast 142 maVSUnderline.SetItemImage(1, GetDisplayBackground().GetColor().IsDark()? maIMGSingleH :maIMGSingle); 143 maVSUnderline.SetItemImage(2, GetDisplayBackground().GetColor().IsDark()? maIMGDoubleH : maIMGDouble ); 144 maVSUnderline.SetItemImage(3, GetDisplayBackground().GetColor().IsDark()? maIMGBoldH : maIMGBold); 145 maVSUnderline.SetItemImage(4, GetDisplayBackground().GetColor().IsDark()? maIMGDotH : maIMGDot); 146 maVSUnderline.SetItemImage(5, GetDisplayBackground().GetColor().IsDark()? maIMGDotBoldH :maIMGDotBold); 147 maVSUnderline.SetItemImage(6, GetDisplayBackground().GetColor().IsDark()? maIMGDashH :maIMGDash); 148 maVSUnderline.SetItemImage(7, GetDisplayBackground().GetColor().IsDark()? maIMGDashLongH : maIMGDashLong); 149 maVSUnderline.SetItemImage(8, GetDisplayBackground().GetColor().IsDark()? maIMGDashDotH : maIMGDashDot); 150 maVSUnderline.SetItemImage(9, GetDisplayBackground().GetColor().IsDark()? maIMGDashDotDotH : maIMGDashDotDot); 151 maVSUnderline.SetItemImage(10, GetDisplayBackground().GetColor().IsDark()? maIMGWaveH : maIMGWave); 152 153 switch(eLine) 154 { 155 case UNDERLINE_SINGLE: 156 maVSUnderline.SetItemImage(1, maIMGSingleSel); 157 maVSUnderline.SelectItem(1); 158 maVSUnderline.GrabFocus(); 159 break; 160 case UNDERLINE_DOUBLE: 161 maVSUnderline.SetItemImage(2, maIMGDoubleSel); 162 maVSUnderline.SelectItem(2); 163 maVSUnderline.GrabFocus(); 164 break; 165 case UNDERLINE_BOLD: 166 maVSUnderline.SetItemImage(3, maIMGBoldSel); 167 maVSUnderline.SelectItem(3); 168 maVSUnderline.GrabFocus(); 169 break; 170 case UNDERLINE_DOTTED: 171 maVSUnderline.SetItemImage(4, maIMGDotSel); 172 maVSUnderline.SelectItem(4); 173 maVSUnderline.GrabFocus(); 174 break; 175 case UNDERLINE_BOLDDOTTED: 176 maVSUnderline.SetItemImage(5, maIMGDotBoldSel); 177 maVSUnderline.SelectItem(5); 178 maVSUnderline.GrabFocus(); 179 break; 180 case UNDERLINE_DASH: 181 maVSUnderline.SetItemImage(6, maIMGDashSel); 182 maVSUnderline.SelectItem(6); 183 maVSUnderline.GrabFocus(); 184 break; 185 case UNDERLINE_LONGDASH: 186 maVSUnderline.SetItemImage(7, maIMGDashLongSel); 187 maVSUnderline.SelectItem(7); 188 maVSUnderline.GrabFocus(); 189 break; 190 case UNDERLINE_DASHDOT: 191 maVSUnderline.SetItemImage(8, maIMGDashDotSel); 192 maVSUnderline.SelectItem(8); 193 maVSUnderline.GrabFocus(); 194 break; 195 case UNDERLINE_DASHDOTDOT: 196 maVSUnderline.SetItemImage(9, maIMGDashDotDotSel); 197 maVSUnderline.SelectItem(9); 198 maVSUnderline.GrabFocus(); 199 break; 200 case UNDERLINE_WAVE: 201 maVSUnderline.SetItemImage(10, maIMGWaveSel); 202 maVSUnderline.SelectItem(10); 203 maVSUnderline.GrabFocus(); 204 break; 205 case UNDERLINE_NONE: 206 default: 207 maVSUnderline.SelectItem(1); 208 maVSUnderline.SetNoSelection(); 209 maPBOptions.GrabFocus(); 210 } 211 maVSUnderline.StartSelection(); 212 } 213 214 215 IMPL_LINK(TextUnderlineControl, VSSelectHdl, void *, pControl) 216 { 217 if(pControl == &maVSUnderline) 218 { 219 sal_uInt16 iPos = maVSUnderline.GetSelectItemId(); 220 FontUnderline eUnderline = (FontUnderline)(sal_uInt64)maVSUnderline.GetItemData( iPos ); 221 222 SvxUnderlineItem aLineItem(eUnderline, SID_ATTR_CHAR_UNDERLINE); 223 224 aLineItem.SetColor(mrTextPropertyPanel.GetUnderlineColor()); 225 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L); 226 227 mrTextPropertyPanel.SetUnderline(eUnderline); 228 229 mrTextPropertyPanel.EndUnderlinePopupMode(); 230 } 231 return( 0L ); 232 } 233 234 IMPL_LINK(TextUnderlineControl, PBClickHdl, PushButton *, pPBtn) 235 { 236 if(pPBtn == &maPBOptions) 237 { 238 if (mpBindings) 239 { 240 SfxDispatcher* pDisp = mpBindings->GetDispatcher(); 241 pDisp->Execute( SID_CHAR_DLG_EFFECT, SFX_CALLMODE_ASYNCHRON ); 242 } 243 mrTextPropertyPanel.EndUnderlinePopupMode(); 244 } 245 return 0; 246 } 247 248 }} 249