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 "TextCharacterSpacingControl.hxx" 24d4aefcaeSZheng Fan #include "TextPropertyPanel.hrc" 25d4aefcaeSZheng Fan #include <sfx2/sidebar/propertypanel.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 34d4aefcaeSZheng Fan namespace svx { namespace sidebar { 35d4aefcaeSZheng Fan TextCharacterSpacingControl::TextCharacterSpacingControl(Window* pParent, svx::sidebar::TextPropertyPanel& rPanel) 36d4aefcaeSZheng Fan : PopupControl( pParent,SVX_RES(RID_POPUPPANEL_TEXTPAGE_SPACING)) 37d4aefcaeSZheng Fan , mrTextPropertyPanel(rPanel) 38b9e67834SAndre Fischer , mpBindings(NULL) 39d4aefcaeSZheng Fan , maVSSpacing (ValueSetWithTextControl::IMAGE_TEXT,this, SVX_RES(VS_SPACING)) 40b9e67834SAndre Fischer , maLastCus (this, SVX_RES(FT_LASTCUSTOM)) 41b9e67834SAndre Fischer //, maBorder (this, SVX_RES(CT_BORDER)) 42b9e67834SAndre Fischer , maFTSpacing (this, SVX_RES(FT_SPACING)) 43b9e67834SAndre Fischer , maLBKerning (this, SVX_RES(LB_KERNING)) 44b9e67834SAndre Fischer , maFTBy (this, SVX_RES(FT_BY)) 45b9e67834SAndre Fischer , maEditKerning (this, SVX_RES(ED_KERNING)) 46b9e67834SAndre Fischer 47b9e67834SAndre Fischer , mpImg (NULL) 48b9e67834SAndre Fischer , mpImgSel (NULL) 49b9e67834SAndre Fischer , mpStr (NULL) 50b9e67834SAndre Fischer , mpStrTip (NULL) 51b9e67834SAndre Fischer 52b9e67834SAndre Fischer , maImgCus (SVX_RES(IMG_CUSTOM)) 53b9e67834SAndre Fischer , maImgCusGrey (SVX_RES(IMG_CUSTOM_GRAY)) 54b9e67834SAndre Fischer , maStrCus (SVX_RES(STR_CUSTOM)) 55b9e67834SAndre Fischer , maStrCusE (SVX_RES(STR_CUSTOM_E_TIP)) //add 56b9e67834SAndre Fischer , maStrCusC (SVX_RES(STR_CUSTOM_C_TIP)) //add 57b9e67834SAndre Fischer , maStrCusN (SVX_RES(STR_NORMAL_TIP)) //add 58b9e67834SAndre Fischer , maStrUnit (SVX_RES(STR_PT)) //add 59b9e67834SAndre Fischer 60b9e67834SAndre Fischer , mnCustomKern(0) 61b9e67834SAndre Fischer , mnLastCus ( SPACING_NOCUSTOM ) 62b9e67834SAndre Fischer , mbCusEnable(false) 63b9e67834SAndre Fischer , mbVS(true) 64b9e67834SAndre Fischer { 65b9e67834SAndre Fischer initial(); 66b9e67834SAndre Fischer FreeResource(); 67d4aefcaeSZheng Fan mpBindings = mrTextPropertyPanel.GetBindings(); 68d4aefcaeSZheng Fan Link aLink = LINK(this, TextCharacterSpacingControl, KerningSelectHdl); 69b9e67834SAndre Fischer maLBKerning.SetSelectHdl(aLink); 70d4aefcaeSZheng Fan aLink =LINK(this, TextCharacterSpacingControl, KerningModifyHdl); 71b9e67834SAndre Fischer maEditKerning.SetModifyHdl(aLink); 72b9e67834SAndre Fischer 73b9e67834SAndre Fischer } 74d4aefcaeSZheng Fan TextCharacterSpacingControl::~TextCharacterSpacingControl() 75b9e67834SAndre Fischer { 76b9e67834SAndre Fischer delete[] mpImg; 77b9e67834SAndre Fischer delete[] mpImgSel; 78b9e67834SAndre Fischer delete[] mpStr; 79b9e67834SAndre Fischer delete[] mpStrTip; 80b9e67834SAndre Fischer } 81b9e67834SAndre Fischer 82d4aefcaeSZheng Fan void TextCharacterSpacingControl::initial() 83b9e67834SAndre Fischer { 84b9e67834SAndre Fischer maVSSpacing.SetStyle( maVSSpacing.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT ); 85b9e67834SAndre Fischer { 86d4aefcaeSZheng Fan maVSSpacing.SetControlBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 87d4aefcaeSZheng Fan GetSettings().GetStyleSettings().GetMenuColor(): 88d4aefcaeSZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 89d4aefcaeSZheng Fan maVSSpacing.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()? 90d4aefcaeSZheng Fan GetSettings().GetStyleSettings().GetMenuColor(): 91d4aefcaeSZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 92d4aefcaeSZheng Fan maVSSpacing.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 93d4aefcaeSZheng Fan GetSettings().GetStyleSettings().GetMenuColor(): 94d4aefcaeSZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 95d4aefcaeSZheng Fan maFTSpacing.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 96d4aefcaeSZheng Fan GetSettings().GetStyleSettings().GetMenuColor(): 97d4aefcaeSZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 98d4aefcaeSZheng Fan maFTBy.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 99d4aefcaeSZheng Fan GetSettings().GetStyleSettings().GetMenuColor(): 100d4aefcaeSZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 101b9e67834SAndre Fischer } 102b9e67834SAndre Fischer mpImg = new Image[5]; 103b9e67834SAndre Fischer mpImg[0] = Image(SVX_RES(IMG_VERY_TIGHT)); 104b9e67834SAndre Fischer mpImg[1] = Image(SVX_RES(IMG_TIGHT)); 105b9e67834SAndre Fischer mpImg[2] = Image(SVX_RES(IMG_NORMAL)); 106b9e67834SAndre Fischer mpImg[3] = Image(SVX_RES(IMG_LOOSE)); 107b9e67834SAndre Fischer mpImg[4] = Image(SVX_RES(IMG_VERY_LOOSE)); 108b9e67834SAndre Fischer 109b9e67834SAndre Fischer mpImgSel = new Image[5]; 110b9e67834SAndre Fischer mpImgSel[0] = Image(SVX_RES(IMG_VERY_TIGHT_S)); 111b9e67834SAndre Fischer mpImgSel[1] = Image(SVX_RES(IMG_TIGHT_S)); 112b9e67834SAndre Fischer mpImgSel[2] = Image(SVX_RES(IMG_NORMAL_S)); 113b9e67834SAndre Fischer mpImgSel[3] = Image(SVX_RES(IMG_LOOSE_S)); 114b9e67834SAndre Fischer mpImgSel[4] = Image(SVX_RES(IMG_VERY_LOOSE_S)); 115b9e67834SAndre Fischer 116b9e67834SAndre Fischer mpStr = new XubString[5]; 117b9e67834SAndre Fischer mpStr[0] = XubString(SVX_RES(STR_VERY_TIGHT)); 118b9e67834SAndre Fischer mpStr[1] = XubString(SVX_RES(STR_TIGHT)); 119b9e67834SAndre Fischer mpStr[2] = XubString(SVX_RES(STR_NORMAL)); 120b9e67834SAndre Fischer mpStr[3] = XubString(SVX_RES(STR_LOOSE)); 121b9e67834SAndre Fischer mpStr[4] = XubString(SVX_RES(STR_VERY_LOOSE)); 122d4aefcaeSZheng Fan 123b9e67834SAndre Fischer 124b9e67834SAndre Fischer mpStrTip = new XubString[5]; 125b9e67834SAndre Fischer mpStrTip[0] = XubString(SVX_RES(STR_VERY_TIGHT_TIP)); 126b9e67834SAndre Fischer mpStrTip[1] = XubString(SVX_RES(STR_TIGHT_TIP)); 127b9e67834SAndre Fischer mpStrTip[2] = XubString(SVX_RES(STR_NORMAL_TIP)); 128b9e67834SAndre Fischer mpStrTip[3] = XubString(SVX_RES(STR_LOOSE_TIP)); 129b9e67834SAndre Fischer mpStrTip[4] = XubString(SVX_RES(STR_VERY_LOOSE_TIP)); 130d4aefcaeSZheng Fan 131d4aefcaeSZheng Fan for (int i=0;i<5;i++) 132d4aefcaeSZheng Fan maVSSpacing.AddItem(mpImg[i], &mpImgSel[i],mpStr[i],&mpStrTip[i]); 133b9e67834SAndre Fischer 1340a759ee0SZheng Fan maVSSpacing.AddItem( maImgCus, 0, maStrCus, 0 ); 135b9e67834SAndre Fischer 1360a759ee0SZheng Fan maVSSpacing.SetNoSelection(); 137d4aefcaeSZheng Fan Link aLink = LINK(this, TextCharacterSpacingControl,VSSelHdl ); 138b9e67834SAndre Fischer maVSSpacing.SetSelectHdl(aLink); 139b9e67834SAndre Fischer maVSSpacing.StartSelection(); 140b9e67834SAndre Fischer maVSSpacing.Show(); 141b9e67834SAndre Fischer } 142d4aefcaeSZheng Fan void TextCharacterSpacingControl::ToGetFocus() 143b9e67834SAndre Fischer { 144b9e67834SAndre Fischer if(!mbVS) 145b9e67834SAndre Fischer maLBKerning.GrabFocus(); 146b9e67834SAndre Fischer else 147b9e67834SAndre Fischer maVSSpacing.GrabFocus(); 148b9e67834SAndre Fischer } 149d4aefcaeSZheng Fan 150d4aefcaeSZheng Fan void TextCharacterSpacingControl::Rearrange(bool bLBAvailable,bool bAvailable, long nKerning) 151b9e67834SAndre Fischer { 152b9e67834SAndre Fischer mbVS = true; 1530a759ee0SZheng Fan maVSSpacing.SetNoSelection(); 154b9e67834SAndre Fischer SvtViewOptions aWinOpt( E_WINDOW, SIDEBAR_SPACING_GLOBAL_VALUE ); 155b9e67834SAndre Fischer if ( aWinOpt.Exists() ) 156b9e67834SAndre Fischer { 157b9e67834SAndre Fischer ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData(); 158b9e67834SAndre Fischer ::rtl::OUString aTmp; 159b9e67834SAndre Fischer if ( aSeq.getLength()) 160b9e67834SAndre Fischer aSeq[0].Value >>= aTmp; 161b9e67834SAndre Fischer 162b9e67834SAndre Fischer String aWinData( aTmp ); 163b9e67834SAndre Fischer mnCustomKern = aWinData.ToInt32(); 164b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CUS_EDIT; 165b9e67834SAndre Fischer mbCusEnable = true; 166b9e67834SAndre Fischer } 167b9e67834SAndre Fischer else 168b9e67834SAndre Fischer { 169b9e67834SAndre Fischer mnLastCus = SPACING_NOCUSTOM; 170b9e67834SAndre Fischer mbCusEnable = false; 171b9e67834SAndre Fischer } 172b9e67834SAndre Fischer 173b9e67834SAndre Fischer if( !mnLastCus ) 174b9e67834SAndre Fischer { 1750a759ee0SZheng Fan maVSSpacing.ReplaceItemImages(6, maImgCusGrey,0); 176b9e67834SAndre Fischer } 177b9e67834SAndre Fischer else 178b9e67834SAndre Fischer { 179b9e67834SAndre Fischer //set custom tips 1800a759ee0SZheng Fan maVSSpacing.ReplaceItemImages(6, maImgCus,0); 181b9e67834SAndre Fischer if(mnCustomKern > 0) 182b9e67834SAndre Fischer { 183b9e67834SAndre Fischer String aStrTip( maStrCusE); //LAST CUSTOM no tip defect //add 184b9e67834SAndre Fischer aStrTip.Append( String::CreateFromDouble( (double)mnCustomKern / 10)); 185b9e67834SAndre Fischer aStrTip.Append(maStrUnit); // modify 1860a759ee0SZheng Fan maVSSpacing.SetItemText(6,aStrTip); 187b9e67834SAndre Fischer } 188b9e67834SAndre Fischer else if(mnCustomKern < 0) 189b9e67834SAndre Fischer { 190b9e67834SAndre Fischer String aStrTip(maStrCusC) ; //LAST CUSTOM no tip defect //add 191b9e67834SAndre Fischer aStrTip.Append( String::CreateFromDouble( (double)-mnCustomKern / 10)); 192b9e67834SAndre Fischer aStrTip.Append(maStrUnit); // modify 1930a759ee0SZheng Fan maVSSpacing.SetItemText( 6, aStrTip ); 194b9e67834SAndre Fischer } 195b9e67834SAndre Fischer else 196b9e67834SAndre Fischer { 197b9e67834SAndre Fischer String aStrTip(maStrCusN) ; //LAST CUSTOM no tip defect //add 1980a759ee0SZheng Fan maVSSpacing.SetItemText( 6, aStrTip ); 199b9e67834SAndre Fischer } 200b9e67834SAndre Fischer 201b9e67834SAndre Fischer } 202b9e67834SAndre Fischer 203b9e67834SAndre Fischer if(bLBAvailable && bAvailable) 204b9e67834SAndre Fischer { 205b9e67834SAndre Fischer maLBKerning.Enable(); 206b9e67834SAndre Fischer maFTSpacing.Enable(); 207d4aefcaeSZheng Fan 208d4aefcaeSZheng Fan SfxMapUnit eUnit = mrTextPropertyPanel.GetSpaceController().GetCoreMetric(); 209b9e67834SAndre Fischer MapUnit eOrgUnit = (MapUnit)eUnit; 210b9e67834SAndre Fischer MapUnit ePntUnit( MAP_POINT ); 211b9e67834SAndre Fischer long nBig = maEditKerning.Normalize(nKerning); 212b9e67834SAndre Fischer nKerning = LogicToLogic( nBig, eOrgUnit, ePntUnit ); 213b9e67834SAndre Fischer 214*61a625e4SOliver-Rainer Wittmann if ( nKerning > 0 ) 215b9e67834SAndre Fischer { 216*61a625e4SOliver-Rainer Wittmann maFTBy.Enable(); 217b9e67834SAndre Fischer maEditKerning.Enable(); 218b9e67834SAndre Fischer maEditKerning.SetMax( 9999 ); 219b9e67834SAndre Fischer maEditKerning.SetLast( 9999 ); 220b9e67834SAndre Fischer maEditKerning.SetValue( nKerning ); 221b9e67834SAndre Fischer maLBKerning.SelectEntryPos( SIDEBAR_SPACE_EXPAND ); 222b9e67834SAndre Fischer if(nKerning == 30) 223b9e67834SAndre Fischer { 2240a759ee0SZheng Fan maVSSpacing.SelectItem(4); 225b9e67834SAndre Fischer } 226b9e67834SAndre Fischer else if(nKerning == 60) 227b9e67834SAndre Fischer { 2280a759ee0SZheng Fan maVSSpacing.SelectItem(5); 229b9e67834SAndre Fischer } 230b9e67834SAndre Fischer else 231b9e67834SAndre Fischer { 232*61a625e4SOliver-Rainer Wittmann maVSSpacing.SetNoSelection(); 233*61a625e4SOliver-Rainer Wittmann maVSSpacing.SelectItem(0); 234b9e67834SAndre Fischer mbVS = false; 235b9e67834SAndre Fischer } 236b9e67834SAndre Fischer } 237b9e67834SAndre Fischer else if ( nKerning < 0 ) 238b9e67834SAndre Fischer { 239b9e67834SAndre Fischer maFTBy.Enable(); 240b9e67834SAndre Fischer maEditKerning.Enable(); 241b9e67834SAndre Fischer maEditKerning.SetValue( -nKerning ); 242b9e67834SAndre Fischer maLBKerning.SelectEntryPos( SIDEBAR_SPACE_CONDENSED ); 243d4aefcaeSZheng Fan long nMax = mrTextPropertyPanel.GetSelFontSize()/6; 244b9e67834SAndre Fischer maEditKerning.SetMax( maEditKerning.Normalize( nMax ), FUNIT_POINT ); 245b9e67834SAndre Fischer maEditKerning.SetLast( maEditKerning.GetMax( maEditKerning.GetUnit() ) ); 246b9e67834SAndre Fischer if( nKerning == -30 ) 247b9e67834SAndre Fischer { 2480a759ee0SZheng Fan maVSSpacing.SelectItem(1); 249b9e67834SAndre Fischer } 250b9e67834SAndre Fischer else if( nKerning == -15 ) 251b9e67834SAndre Fischer { 2520a759ee0SZheng Fan maVSSpacing.SelectItem(2); 253b9e67834SAndre Fischer } 254b9e67834SAndre Fischer else 255b9e67834SAndre Fischer { 256*61a625e4SOliver-Rainer Wittmann maVSSpacing.SetNoSelection(); 257*61a625e4SOliver-Rainer Wittmann maVSSpacing.SelectItem(0); 258b9e67834SAndre Fischer mbVS = false; 259b9e67834SAndre Fischer } 260b9e67834SAndre Fischer } 261b9e67834SAndre Fischer else 262b9e67834SAndre Fischer { 2630a759ee0SZheng Fan maVSSpacing.SelectItem(3); 264b9e67834SAndre Fischer maLBKerning.SelectEntryPos( SIDEBAR_SPACE_NORMAL ); 265b9e67834SAndre Fischer maFTBy.Disable(); 266b9e67834SAndre Fischer maEditKerning.Disable(); 267b9e67834SAndre Fischer maEditKerning.SetValue( 0 ); 268b9e67834SAndre Fischer maEditKerning.SetMax( 9999 ); 269b9e67834SAndre Fischer maEditKerning.SetLast( 9999 ); 270b9e67834SAndre Fischer } 271b9e67834SAndre Fischer } 272b9e67834SAndre Fischer else if(bLBAvailable && !bAvailable) 273b9e67834SAndre Fischer { 274b9e67834SAndre Fischer //modified 275*61a625e4SOliver-Rainer Wittmann maVSSpacing.SetNoSelection(); 276*61a625e4SOliver-Rainer Wittmann maVSSpacing.SelectItem(0); 277b9e67834SAndre Fischer mbVS = false; 278b9e67834SAndre Fischer maLBKerning.Enable(); 279b9e67834SAndre Fischer maFTSpacing.Enable(); 280b9e67834SAndre Fischer maLBKerning.SetNoSelection(); 281b9e67834SAndre Fischer maEditKerning.SetText(String()); 282b9e67834SAndre Fischer maEditKerning.Disable(); 283b9e67834SAndre Fischer maFTBy.Disable(); 284b9e67834SAndre Fischer } 285b9e67834SAndre Fischer else 286b9e67834SAndre Fischer { 287*61a625e4SOliver-Rainer Wittmann maVSSpacing.SetNoSelection(); 288*61a625e4SOliver-Rainer Wittmann maVSSpacing.SelectItem(0); 289b9e67834SAndre Fischer mbVS = false; 290b9e67834SAndre Fischer maEditKerning.SetText(String()); 291b9e67834SAndre Fischer maLBKerning.SetNoSelection(); 292b9e67834SAndre Fischer maLBKerning.Disable(); 293b9e67834SAndre Fischer maFTSpacing.Disable(); 294b9e67834SAndre Fischer maEditKerning.Disable(); 295b9e67834SAndre Fischer maFTBy.Disable(); 296b9e67834SAndre Fischer } 297b9e67834SAndre Fischer GetFocus(); 298b9e67834SAndre Fischer maVSSpacing.Format(); 299b9e67834SAndre Fischer maVSSpacing.StartSelection(); 300b9e67834SAndre Fischer } 301d4aefcaeSZheng Fan IMPL_LINK(TextCharacterSpacingControl, VSSelHdl, void *, pControl) 302b9e67834SAndre Fischer { 303d4aefcaeSZheng Fan mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 304b9e67834SAndre Fischer 305b9e67834SAndre Fischer if(pControl == &maVSSpacing) 306b9e67834SAndre Fischer { 307d4aefcaeSZheng Fan sal_uInt16 iPos = maVSSpacing.GetSelectItemId(); 308b9e67834SAndre Fischer short nKern = 0; 309d4aefcaeSZheng Fan SfxMapUnit eUnit = mrTextPropertyPanel.GetSpaceController().GetCoreMetric(); 310b9e67834SAndre Fischer long nVal = 0; 311b9e67834SAndre Fischer if(iPos == 1) 312b9e67834SAndre Fischer { 313b9e67834SAndre Fischer nVal = LogicToLogic(30, MAP_POINT, (MapUnit)eUnit); 314b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal); 315b9e67834SAndre Fischer SvxKerningItem aKernItem(-nKern, SID_ATTR_CHAR_KERNING); 316b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 317d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(-nKern); 318b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 319b9e67834SAndre Fischer } 320b9e67834SAndre Fischer else if(iPos == 2) 321b9e67834SAndre Fischer { 322b9e67834SAndre Fischer nVal = LogicToLogic(15, MAP_POINT, (MapUnit)eUnit); 323b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal); 324b9e67834SAndre Fischer SvxKerningItem aKernItem(-nKern, SID_ATTR_CHAR_KERNING); 325b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 326d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(-nKern); 327b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 328b9e67834SAndre Fischer } 329b9e67834SAndre Fischer else if(iPos == 3) 330b9e67834SAndre Fischer { 331b9e67834SAndre Fischer SvxKerningItem aKernItem(0, SID_ATTR_CHAR_KERNING); 332b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 333d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(0); 334b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 335b9e67834SAndre Fischer } 336b9e67834SAndre Fischer else if(iPos == 4) 337b9e67834SAndre Fischer { 338b9e67834SAndre Fischer nVal = LogicToLogic(30, MAP_POINT, (MapUnit)eUnit); 339b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal); 340b9e67834SAndre Fischer SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING); 341b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 342d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(nKern); 343b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 344b9e67834SAndre Fischer } 345b9e67834SAndre Fischer else if(iPos == 5) 346b9e67834SAndre Fischer { 347b9e67834SAndre Fischer nVal = LogicToLogic(60, MAP_POINT, (MapUnit)eUnit); 348b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal); 349b9e67834SAndre Fischer SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING); 350b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 351d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(nKern); 352b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 353b9e67834SAndre Fischer } 354b9e67834SAndre Fischer else if(iPos == 6) 355b9e67834SAndre Fischer { 356b9e67834SAndre Fischer //modified 357b9e67834SAndre Fischer if(mbCusEnable) 358b9e67834SAndre Fischer { 359b9e67834SAndre Fischer nVal = LogicToLogic(mnCustomKern, MAP_POINT, (MapUnit)eUnit); 360b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal); 361b9e67834SAndre Fischer SvxKerningItem aKernItem(nKern , SID_ATTR_CHAR_KERNING); 362b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 363d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(nKern); 364b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 365b9e67834SAndre Fischer } 366b9e67834SAndre Fischer else 367b9e67834SAndre Fischer { 368b9e67834SAndre Fischer maVSSpacing.SetNoSelection(); //add , set no selection and keep the last select item 369b9e67834SAndre Fischer maVSSpacing.Format(); 370b9e67834SAndre Fischer Invalidate(); 371b9e67834SAndre Fischer maVSSpacing.StartSelection(); 372b9e67834SAndre Fischer } 373b9e67834SAndre Fischer //modify end 374b9e67834SAndre Fischer } 375b9e67834SAndre Fischer 376b9e67834SAndre Fischer if(iPos < 6 || (iPos == 6 && mbCusEnable)) //add 377d4aefcaeSZheng Fan mrTextPropertyPanel.EndSpacingPopupMode(); 378b9e67834SAndre Fischer } 379b9e67834SAndre Fischer 380b9e67834SAndre Fischer 381b9e67834SAndre Fischer 382b9e67834SAndre Fischer return 0; 383b9e67834SAndre Fischer } 384b9e67834SAndre Fischer 385d4aefcaeSZheng Fan IMPL_LINK(TextCharacterSpacingControl, KerningSelectHdl, ListBox*, EMPTYARG) 386b9e67834SAndre Fischer { 387b9e67834SAndre Fischer if ( maLBKerning.GetSelectEntryPos() > 0 ) 388b9e67834SAndre Fischer { 389b9e67834SAndre Fischer maFTBy.Enable(); 390b9e67834SAndre Fischer maEditKerning.Enable(); 391b9e67834SAndre Fischer } 392b9e67834SAndre Fischer else 393b9e67834SAndre Fischer { 394b9e67834SAndre Fischer maEditKerning.SetValue( 0 ); 395b9e67834SAndre Fischer maFTBy.Disable(); 396b9e67834SAndre Fischer maEditKerning.Disable(); 397b9e67834SAndre Fischer } 398b9e67834SAndre Fischer 3990a759ee0SZheng Fan if ( maVSSpacing.GetSelectItemId() > 0 ) 400b9e67834SAndre Fischer { 401*61a625e4SOliver-Rainer Wittmann maVSSpacing.SetNoSelection(); 402*61a625e4SOliver-Rainer Wittmann maVSSpacing.SelectItem(0); 403b9e67834SAndre Fischer maVSSpacing.Format(); 404b9e67834SAndre Fischer Invalidate(); 405b9e67834SAndre Fischer maVSSpacing.StartSelection(); 406b9e67834SAndre Fischer } 407b9e67834SAndre Fischer KerningModifyHdl( NULL ); 408b9e67834SAndre Fischer return 0; 409b9e67834SAndre Fischer } 410d4aefcaeSZheng Fan IMPL_LINK(TextCharacterSpacingControl, KerningModifyHdl, MetricField*, EMPTYARG) 411b9e67834SAndre Fischer { 4120a759ee0SZheng Fan if ( maVSSpacing.GetSelectItemId() > 0 ) 413b9e67834SAndre Fischer { 414*61a625e4SOliver-Rainer Wittmann maVSSpacing.SetNoSelection(); 415*61a625e4SOliver-Rainer Wittmann maVSSpacing.SelectItem(0); 416b9e67834SAndre Fischer maVSSpacing.Format(); 417b9e67834SAndre Fischer Invalidate(); 418b9e67834SAndre Fischer maVSSpacing.StartSelection(); 419b9e67834SAndre Fischer } 420d4aefcaeSZheng Fan sal_uInt16 nPos = maLBKerning.GetSelectEntryPos(); 421b9e67834SAndre Fischer short nKern = 0; 422d4aefcaeSZheng Fan SfxMapUnit eUnit = mrTextPropertyPanel.GetSpaceController().GetCoreMetric(); 423b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CUS_EDIT; 424b9e67834SAndre Fischer if ( nPos == SIDEBAR_SPACE_EXPAND || nPos == SIDEBAR_SPACE_CONDENSED ) 425b9e67834SAndre Fischer { 426b9e67834SAndre Fischer long nTmp = static_cast<long>(maEditKerning.GetValue()); 427b9e67834SAndre Fischer if ( nPos == SIDEBAR_SPACE_CONDENSED ) 428b9e67834SAndre Fischer { 429d4aefcaeSZheng Fan long nMax = mrTextPropertyPanel.GetSelFontSize()/6; 430b9e67834SAndre Fischer maEditKerning.SetMax( maEditKerning.Normalize( nMax ), FUNIT_TWIP ); 431b9e67834SAndre Fischer maEditKerning.SetLast( maEditKerning.GetMax( maEditKerning.GetUnit() ) ); 432b9e67834SAndre Fischer if(nTmp > maEditKerning.GetMax()) 433b9e67834SAndre Fischer nTmp = maEditKerning.GetMax(); 434b9e67834SAndre Fischer mnCustomKern = -nTmp; 435b9e67834SAndre Fischer long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit ); 436b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize( nVal ); 437b9e67834SAndre Fischer nKern *= - 1; 438b9e67834SAndre Fischer } 439b9e67834SAndre Fischer else 440b9e67834SAndre Fischer { 441b9e67834SAndre Fischer maEditKerning.SetMax( 9999 ); 442b9e67834SAndre Fischer maEditKerning.SetLast( 9999 ); 443b9e67834SAndre Fischer if(nTmp > maEditKerning.GetMax(FUNIT_TWIP)) 444b9e67834SAndre Fischer nTmp = maEditKerning.GetMax(FUNIT_TWIP); 445b9e67834SAndre Fischer mnCustomKern = nTmp; 446b9e67834SAndre Fischer long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit ); 447b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize( nVal ); 448b9e67834SAndre Fischer } 449b9e67834SAndre Fischer } 450b9e67834SAndre Fischer else 451b9e67834SAndre Fischer { 452b9e67834SAndre Fischer mnCustomKern = 0; 453b9e67834SAndre Fischer } 454b9e67834SAndre Fischer SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING); 455b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 456d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(nKern); 457b9e67834SAndre Fischer return 0; 458b9e67834SAndre Fischer } 459d4aefcaeSZheng Fan short TextCharacterSpacingControl::GetLastCustomState() 460b9e67834SAndre Fischer { 461b9e67834SAndre Fischer return mnLastCus; 462b9e67834SAndre Fischer } 463d4aefcaeSZheng Fan long TextCharacterSpacingControl::GetLastCustomValue() 464b9e67834SAndre Fischer { 465b9e67834SAndre Fischer return mnCustomKern; 466b9e67834SAndre Fischer } 467b9e67834SAndre Fischer 468d4aefcaeSZheng Fan }} // end of namespace sidebar 469