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