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