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