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/propertypanel.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 /*maPBOptions.SetDefBkColor(GetSettings().GetStyleSettings().GetHighContrastMode()? 89 GetSettings().GetStyleSettings().GetMenuColor(): 90 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_DropDownBackground ));//Color(244,245,249)//for high contract 91 maPBOptions.SetHoverBkColor(GetSettings().GetStyleSettings().GetHighContrastMode()? 92 GetSettings().GetStyleSettings().GetMenuColor(): 93 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground ) );//Color( 93, 120, 163 ) 94 maPBOptions.SetHoverTxtColor( sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Color_PanelTitleFont ) );//Color( 255, 255, 255 ) 95 maPBOptions.SetIcoPosX( 2);*/ 96 maVSUnderline.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()? 97 GetSettings().GetStyleSettings().GetMenuColor(): 98 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 99 maVSUnderline.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 100 GetSettings().GetStyleSettings().GetMenuColor(): 101 sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 102 103 Link aLink = LINK( this, TextUnderlineControl, PBClickHdl ) ; 104 maPBOptions.SetClickHdl(aLink); 105 106 maVSUnderline.SetStyle( maVSUnderline.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT );// WB_NAMEFIELD | WB_ITEMBORDER |WB_DOUBLEBORDER | WB_NONEFIELD | 107 108 maVSUnderline.InsertItem(1, maIMGSingle ,String(SVX_RES(STR_SINGLE))); 109 maVSUnderline.SetItemData(1, (void*)(sal_uInt64)UNDERLINE_SINGLE); 110 111 maVSUnderline.InsertItem(2, maIMGDouble ,String(SVX_RES(STR_DOUBLE))); 112 maVSUnderline.SetItemData(2, (void*)(sal_uInt64)UNDERLINE_DOUBLE); 113 114 maVSUnderline.InsertItem(3, maIMGBold, String(SVX_RES(STR_BOLD))); 115 maVSUnderline.SetItemData(3,(void*)(sal_uInt64)UNDERLINE_BOLD); 116 117 maVSUnderline.InsertItem(4, maIMGDot, String(SVX_RES(STR_DOT))); 118 maVSUnderline.SetItemData(4,(void*)(sal_uInt64)UNDERLINE_DOTTED); 119 120 maVSUnderline.InsertItem(5, maIMGDotBold, String(SVX_RES(STR_DOT_BOLD))); 121 maVSUnderline.SetItemData(5,(void*)(sal_uInt64)UNDERLINE_BOLDDOTTED); 122 123 maVSUnderline.InsertItem(6, maIMGDash, String(SVX_RES(STR_DASH))); 124 maVSUnderline.SetItemData(6,(void*)(sal_uInt64)UNDERLINE_DASH); 125 126 maVSUnderline.InsertItem(7, maIMGDashLong,String(SVX_RES(STR_DASH_LONG))); 127 maVSUnderline.SetItemData(7,(void*)(sal_uInt64)UNDERLINE_LONGDASH); 128 129 maVSUnderline.InsertItem(8, maIMGDashDot, String(SVX_RES(STR_DASH_DOT))); 130 maVSUnderline.SetItemData(8,(void*)(sal_uInt64)UNDERLINE_DASHDOT); 131 132 maVSUnderline.InsertItem(9, maIMGDashDotDot, String(SVX_RES(STR_DASH_DOT_DOT))); 133 maVSUnderline.SetItemData(9,(void*)(sal_uInt64)UNDERLINE_DASHDOTDOT); 134 135 maVSUnderline.InsertItem(10, maIMGWave, String(SVX_RES(STR_WAVE))); 136 maVSUnderline.SetItemData(10,(void*)(sal_uInt64)UNDERLINE_WAVE); 137 138 maVSUnderline.SetColCount( 1 ); 139 aLink = LINK( this, TextUnderlineControl, VSSelectHdl ) ; 140 maVSUnderline.SetSelectHdl(aLink); 141 142 maVSUnderline.StartSelection(); 143 maVSUnderline.Show(); 144 } 145 146 void TextUnderlineControl::GetFocus() 147 { 148 maVSUnderline.GrabFocus(); 149 } 150 void TextUnderlineControl::Rearrange(FontUnderline eLine) 151 { 152 // high contrast 153 maVSUnderline.SetItemImage(1, GetDisplayBackground().GetColor().IsDark()? maIMGSingleH :maIMGSingle); 154 maVSUnderline.SetItemImage(2, GetDisplayBackground().GetColor().IsDark()? maIMGDoubleH : maIMGDouble ); 155 maVSUnderline.SetItemImage(3, GetDisplayBackground().GetColor().IsDark()? maIMGBoldH : maIMGBold); 156 maVSUnderline.SetItemImage(4, GetDisplayBackground().GetColor().IsDark()? maIMGDotH : maIMGDot); 157 maVSUnderline.SetItemImage(5, GetDisplayBackground().GetColor().IsDark()? maIMGDotBoldH :maIMGDotBold); 158 maVSUnderline.SetItemImage(6, GetDisplayBackground().GetColor().IsDark()? maIMGDashH :maIMGDash); 159 maVSUnderline.SetItemImage(7, GetDisplayBackground().GetColor().IsDark()? maIMGDashLongH : maIMGDashLong); 160 maVSUnderline.SetItemImage(8, GetDisplayBackground().GetColor().IsDark()? maIMGDashDotH : maIMGDashDot); 161 maVSUnderline.SetItemImage(9, GetDisplayBackground().GetColor().IsDark()? maIMGDashDotDotH : maIMGDashDotDot); 162 maVSUnderline.SetItemImage(10, GetDisplayBackground().GetColor().IsDark()? maIMGWaveH : maIMGWave); 163 // maVSUnderline.SelectItem(0); //delete 164 // maVSUnderline.SetNoSelection(); 165 166 switch(eLine) 167 { 168 case UNDERLINE_SINGLE: 169 maVSUnderline.SetItemImage(1, maIMGSingleSel); 170 maVSUnderline.SelectItem(1); //add 171 maVSUnderline.GrabFocus(); 172 break; 173 case UNDERLINE_DOUBLE: 174 maVSUnderline.SetItemImage(2, maIMGDoubleSel); 175 maVSUnderline.SelectItem(2); //add 176 maVSUnderline.GrabFocus(); 177 break; 178 case UNDERLINE_BOLD: 179 maVSUnderline.SetItemImage(3, maIMGBoldSel); 180 maVSUnderline.SelectItem(3); //add 181 maVSUnderline.GrabFocus(); 182 break; 183 case UNDERLINE_DOTTED: 184 maVSUnderline.SetItemImage(4, maIMGDotSel); 185 maVSUnderline.SelectItem(4); //add 186 maVSUnderline.GrabFocus(); 187 break; 188 case UNDERLINE_BOLDDOTTED: 189 maVSUnderline.SetItemImage(5, maIMGDotBoldSel); 190 maVSUnderline.SelectItem(5); //add 191 maVSUnderline.GrabFocus(); 192 break; 193 case UNDERLINE_DASH: 194 maVSUnderline.SetItemImage(6, maIMGDashSel); 195 maVSUnderline.SelectItem(6); //add 196 maVSUnderline.GrabFocus(); 197 break; 198 case UNDERLINE_LONGDASH: 199 maVSUnderline.SetItemImage(7, maIMGDashLongSel); 200 maVSUnderline.SelectItem(7); //add 201 maVSUnderline.GrabFocus(); 202 break; 203 case UNDERLINE_DASHDOT: 204 maVSUnderline.SetItemImage(8, maIMGDashDotSel); 205 maVSUnderline.SelectItem(8); //add 206 maVSUnderline.GrabFocus(); 207 break; 208 case UNDERLINE_DASHDOTDOT: 209 maVSUnderline.SetItemImage(9, maIMGDashDotDotSel); 210 maVSUnderline.SelectItem(9); //add 211 maVSUnderline.GrabFocus(); 212 break; 213 case UNDERLINE_WAVE: 214 maVSUnderline.SetItemImage(10, maIMGWaveSel); 215 maVSUnderline.SelectItem(10); //add 216 maVSUnderline.GrabFocus(); 217 break; 218 case UNDERLINE_NONE: 219 default: 220 maVSUnderline.SelectItem(1); 221 maVSUnderline.SetNoSelection();//add 222 maPBOptions.GrabFocus(); 223 } 224 maVSUnderline.StartSelection(); 225 //removed 226 //if(mpPage->meContextType == PROPERTY_CONTEXT_SC_CELL) 227 // maPBOptions.Disable(); 228 //else 229 // maPBOptions.Enable(); 230 //removed end 231 } 232 ValueSet& TextUnderlineControl::GetValueSet() 233 { 234 return maVSUnderline; 235 } 236 Control& TextUnderlineControl::GetPB() 237 { 238 return maPBOptions; 239 } 240 IMPL_LINK(TextUnderlineControl, VSSelectHdl, void *, pControl) 241 { 242 if(pControl == &maVSUnderline) 243 { 244 sal_uInt16 iPos = maVSUnderline.GetSelectItemId(); 245 FontUnderline eUnderline = (FontUnderline)(sal_uInt64)maVSUnderline.GetItemData( iPos ); 246 247 //<<modified 248 //SvxTextLineItem aLineItem(eUnderline, SID_ATTR_CHAR_UNDERLINE); 249 SvxUnderlineItem aLineItem(eUnderline, SID_ATTR_CHAR_UNDERLINE); 250 //modify end>> 251 252 //<<add , this line of code will keep the new underline use pre-color 253 aLineItem.SetColor(mrTextPropertyPanel.GetUnderlineColor()); 254 //add end>> 255 mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L); 256 257 //add , for the popup page not update immediately 258 mrTextPropertyPanel.SetUnderline(eUnderline); 259 //add end 260 //mrTextPropertyPanel.SetDefaultUnderline(eUnderline); 261 262 mrTextPropertyPanel.EndUnderlinePopupMode(); 263 } 264 return( 0L ); 265 } 266 267 IMPL_LINK(TextUnderlineControl, PBClickHdl, PushButton *, pPBtn) 268 { 269 if(pPBtn == &maPBOptions) 270 { 271 if (mpBindings) 272 { 273 SfxDispatcher* pDisp = mpBindings->GetDispatcher(); 274 pDisp->Execute( SID_CHAR_DLG_EFFECT, SFX_CALLMODE_ASYNCHRON ); 275 } 276 //add 277 mrTextPropertyPanel.EndUnderlinePopupMode(); 278 //add end 279 } 280 return 0; 281 } 282 283 }} 284