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" 23*d4aefcaeSZheng Fan #include "TextCharacterSpacingControl.hxx" 24*d4aefcaeSZheng Fan #include "TextPropertyPanel.hrc" 25*d4aefcaeSZheng Fan #include <sfx2/sidebar/propertypanel.hrc> 26*d4aefcaeSZheng Fan #include <svx/dialogs.hrc> 27*d4aefcaeSZheng Fan #include <svx/dialmgr.hxx> 28*d4aefcaeSZheng Fan #include <unotools/viewoptions.hxx> 29*d4aefcaeSZheng Fan #include <editeng/kernitem.hxx> 30*d4aefcaeSZheng Fan #include <sfx2/bindings.hxx> 31*d4aefcaeSZheng Fan #include <sfx2/dispatch.hxx> 32*d4aefcaeSZheng Fan #include <sfx2/sidebar/Theme.hxx> 33*d4aefcaeSZheng Fan 34*d4aefcaeSZheng Fan namespace svx { namespace sidebar { 35*d4aefcaeSZheng Fan TextCharacterSpacingControl::TextCharacterSpacingControl(Window* pParent, svx::sidebar::TextPropertyPanel& rPanel) 36*d4aefcaeSZheng Fan : PopupControl( pParent,SVX_RES(RID_POPUPPANEL_TEXTPAGE_SPACING)) 37*d4aefcaeSZheng Fan , mrTextPropertyPanel(rPanel) 38b9e67834SAndre Fischer , mpBindings(NULL) 39*d4aefcaeSZheng 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(); 67*d4aefcaeSZheng Fan mpBindings = mrTextPropertyPanel.GetBindings(); 68*d4aefcaeSZheng Fan Link aLink = LINK(this, TextCharacterSpacingControl, KerningSelectHdl); 69b9e67834SAndre Fischer maLBKerning.SetSelectHdl(aLink); 70*d4aefcaeSZheng Fan aLink =LINK(this, TextCharacterSpacingControl, KerningModifyHdl); 71b9e67834SAndre Fischer maEditKerning.SetModifyHdl(aLink); 72b9e67834SAndre Fischer 73b9e67834SAndre Fischer } 74*d4aefcaeSZheng Fan TextCharacterSpacingControl::~TextCharacterSpacingControl() 75b9e67834SAndre Fischer { 76b9e67834SAndre Fischer delete[] mpImg; 77b9e67834SAndre Fischer delete[] mpImgSel; 78b9e67834SAndre Fischer delete[] mpStr; 79b9e67834SAndre Fischer delete[] mpStrTip; 80b9e67834SAndre Fischer } 81*d4aefcaeSZheng Fan /*void TextCharacterSpacingControl::Paint(const Rectangle& rect) 82b9e67834SAndre Fischer { 83*d4aefcaeSZheng Fan svx::sidebar::PopupControl::Paint(rect); 84b9e67834SAndre Fischer Color aOldLineColor = GetLineColor(); 85b9e67834SAndre Fischer Color aOldFillColor = GetFillColor(); 86b9e67834SAndre Fischer 87b9e67834SAndre Fischer //Point aPos = maBorder.GetPosPixel(); 88b9e67834SAndre Fischer //Size aSize = maBorder.GetSizePixel(); 89b9e67834SAndre Fischer Point aPos( LogicToPixel( Point( CUSTOM_X, CUSTOM_Y), MAP_APPFONT )); 90b9e67834SAndre Fischer Size aSize( LogicToPixel( Size( CUSTOM_WIDTH, CUSTOM_HEIGHT ), MAP_APPFONT )); 91b9e67834SAndre Fischer Rectangle aRect( aPos, aSize ); 92b9e67834SAndre Fischer aRect.Left() -= 1; 93b9e67834SAndre Fischer aRect.Top() -= 1; 94b9e67834SAndre Fischer aRect.Right() += 1; 95b9e67834SAndre Fischer aRect.Bottom() += 1; 96b9e67834SAndre Fischer 97b9e67834SAndre Fischer 98b9e67834SAndre Fischer Color aLineColor(189,201,219); 99b9e67834SAndre Fischer if(!GetSettings().GetStyleSettings().GetHighContrastMode()) 100b9e67834SAndre Fischer SetLineColor(aLineColor); 101b9e67834SAndre Fischer else 102b9e67834SAndre Fischer SetLineColor(GetSettings().GetStyleSettings().GetShadowColor()); 103b9e67834SAndre Fischer SetFillColor(COL_TRANSPARENT); 104b9e67834SAndre Fischer //add for high contract 105b9e67834SAndre Fischer //if(GetSettings().GetStyleSettings().GetHighContrastMode()) 106b9e67834SAndre Fischer //{ 107b9e67834SAndre Fischer // maBorder.SetBackground(GetSettings().GetStyleSettings().GetMenuColor()); 108b9e67834SAndre Fischer // maFTSpacing.SetBackground(GetSettings().GetStyleSettings().GetMenuColor()); 109b9e67834SAndre Fischer // maFTBy.SetBackground(GetSettings().GetStyleSettings().GetMenuColor()); 110b9e67834SAndre Fischer //} 111b9e67834SAndre Fischer DrawRect(aRect); 112b9e67834SAndre Fischer 113b9e67834SAndre Fischer 114b9e67834SAndre Fischer SetLineColor(aOldLineColor); 115b9e67834SAndre Fischer SetFillColor(aOldFillColor); 116*d4aefcaeSZheng Fan }*/ 117*d4aefcaeSZheng Fan void TextCharacterSpacingControl::initial() 118b9e67834SAndre Fischer { 119b9e67834SAndre Fischer maVSSpacing.SetStyle( maVSSpacing.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT ); 120b9e67834SAndre Fischer //for high contract 121*d4aefcaeSZheng Fan //if(GetSettings().GetStyleSettings().GetHighContrastMode()) 122b9e67834SAndre Fischer { 123*d4aefcaeSZheng Fan maVSSpacing.SetControlBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 124*d4aefcaeSZheng Fan GetSettings().GetStyleSettings().GetMenuColor(): 125*d4aefcaeSZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 126*d4aefcaeSZheng Fan maVSSpacing.SetColor(GetSettings().GetStyleSettings().GetHighContrastMode()? 127*d4aefcaeSZheng Fan GetSettings().GetStyleSettings().GetMenuColor(): 128*d4aefcaeSZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 129*d4aefcaeSZheng Fan maVSSpacing.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 130*d4aefcaeSZheng Fan GetSettings().GetStyleSettings().GetMenuColor(): 131*d4aefcaeSZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 132*d4aefcaeSZheng Fan maFTSpacing.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 133*d4aefcaeSZheng Fan GetSettings().GetStyleSettings().GetMenuColor(): 134*d4aefcaeSZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 135*d4aefcaeSZheng Fan maFTBy.SetBackground(GetSettings().GetStyleSettings().GetHighContrastMode()? 136*d4aefcaeSZheng Fan GetSettings().GetStyleSettings().GetMenuColor(): 137*d4aefcaeSZheng Fan sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Paint_PanelBackground )); 138b9e67834SAndre Fischer } 139b9e67834SAndre Fischer mpImg = new Image[5]; 140b9e67834SAndre Fischer mpImg[0] = Image(SVX_RES(IMG_VERY_TIGHT)); 141b9e67834SAndre Fischer mpImg[1] = Image(SVX_RES(IMG_TIGHT)); 142b9e67834SAndre Fischer mpImg[2] = Image(SVX_RES(IMG_NORMAL)); 143b9e67834SAndre Fischer mpImg[3] = Image(SVX_RES(IMG_LOOSE)); 144b9e67834SAndre Fischer mpImg[4] = Image(SVX_RES(IMG_VERY_LOOSE)); 145b9e67834SAndre Fischer 146b9e67834SAndre Fischer mpImgSel = new Image[5]; 147b9e67834SAndre Fischer mpImgSel[0] = Image(SVX_RES(IMG_VERY_TIGHT_S)); 148b9e67834SAndre Fischer mpImgSel[1] = Image(SVX_RES(IMG_TIGHT_S)); 149b9e67834SAndre Fischer mpImgSel[2] = Image(SVX_RES(IMG_NORMAL_S)); 150b9e67834SAndre Fischer mpImgSel[3] = Image(SVX_RES(IMG_LOOSE_S)); 151b9e67834SAndre Fischer mpImgSel[4] = Image(SVX_RES(IMG_VERY_LOOSE_S)); 152b9e67834SAndre Fischer 153b9e67834SAndre Fischer mpStr = new XubString[5]; 154b9e67834SAndre Fischer mpStr[0] = XubString(SVX_RES(STR_VERY_TIGHT)); 155b9e67834SAndre Fischer mpStr[1] = XubString(SVX_RES(STR_TIGHT)); 156b9e67834SAndre Fischer mpStr[2] = XubString(SVX_RES(STR_NORMAL)); 157b9e67834SAndre Fischer mpStr[3] = XubString(SVX_RES(STR_LOOSE)); 158b9e67834SAndre Fischer mpStr[4] = XubString(SVX_RES(STR_VERY_LOOSE)); 159*d4aefcaeSZheng Fan 160b9e67834SAndre Fischer 161b9e67834SAndre Fischer mpStrTip = new XubString[5]; 162b9e67834SAndre Fischer mpStrTip[0] = XubString(SVX_RES(STR_VERY_TIGHT_TIP)); 163b9e67834SAndre Fischer mpStrTip[1] = XubString(SVX_RES(STR_TIGHT_TIP)); 164b9e67834SAndre Fischer mpStrTip[2] = XubString(SVX_RES(STR_NORMAL_TIP)); 165b9e67834SAndre Fischer mpStrTip[3] = XubString(SVX_RES(STR_LOOSE_TIP)); 166b9e67834SAndre Fischer mpStrTip[4] = XubString(SVX_RES(STR_VERY_LOOSE_TIP)); 167*d4aefcaeSZheng Fan //maVSSpacing.SetDefaultTip(mpStr); //modify 168*d4aefcaeSZheng Fan //maVSSpacing.SetDefaultTip(mpStrTip, TRUE); //Add 169*d4aefcaeSZheng Fan 170*d4aefcaeSZheng Fan for (int i=0;i<5;i++) 171*d4aefcaeSZheng Fan maVSSpacing.AddItem(mpImg[i], &mpImgSel[i],mpStr[i],&mpStrTip[i]); 172b9e67834SAndre Fischer 173b9e67834SAndre Fischer maVSSpacing.InsertCustom(maImgCus, maImgCusGrey, maStrCus); 174b9e67834SAndre Fischer maVSSpacing.SetCustomTip(maStrCus); //Add 175b9e67834SAndre Fischer 176b9e67834SAndre Fischer maVSSpacing.SetSelItem(0); 177*d4aefcaeSZheng Fan Link aLink = LINK(this, TextCharacterSpacingControl,VSSelHdl ); 178b9e67834SAndre Fischer maVSSpacing.SetSelectHdl(aLink); 179b9e67834SAndre Fischer maVSSpacing.StartSelection(); 180b9e67834SAndre Fischer maVSSpacing.Show(); 181b9e67834SAndre Fischer } 182*d4aefcaeSZheng Fan void TextCharacterSpacingControl::ToGetFocus() 183b9e67834SAndre Fischer { 184b9e67834SAndre Fischer if(!mbVS) 185b9e67834SAndre Fischer maLBKerning.GrabFocus(); 186b9e67834SAndre Fischer else 187b9e67834SAndre Fischer maVSSpacing.GrabFocus(); 188b9e67834SAndre Fischer } 189*d4aefcaeSZheng Fan 190*d4aefcaeSZheng Fan void TextCharacterSpacingControl::Rearrange(bool bLBAvailable,bool bAvailable, long nKerning) 191b9e67834SAndre Fischer { 192b9e67834SAndre Fischer mbVS = true; 193b9e67834SAndre Fischer maVSSpacing.SetSelItem(0); 194b9e67834SAndre Fischer SvtViewOptions aWinOpt( E_WINDOW, SIDEBAR_SPACING_GLOBAL_VALUE ); 195b9e67834SAndre Fischer if ( aWinOpt.Exists() ) 196b9e67834SAndre Fischer { 197b9e67834SAndre Fischer ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData(); 198b9e67834SAndre Fischer ::rtl::OUString aTmp; 199b9e67834SAndre Fischer if ( aSeq.getLength()) 200b9e67834SAndre Fischer aSeq[0].Value >>= aTmp; 201b9e67834SAndre Fischer 202b9e67834SAndre Fischer String aWinData( aTmp ); 203b9e67834SAndre Fischer mnCustomKern = aWinData.ToInt32(); 204b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CUS_EDIT; 205b9e67834SAndre Fischer mbCusEnable = true; 206b9e67834SAndre Fischer } 207b9e67834SAndre Fischer else 208b9e67834SAndre Fischer { 209b9e67834SAndre Fischer mnLastCus = SPACING_NOCUSTOM; 210b9e67834SAndre Fischer mbCusEnable = false; 211b9e67834SAndre Fischer } 212b9e67834SAndre Fischer 213b9e67834SAndre Fischer if( !mnLastCus ) 214b9e67834SAndre Fischer { 215b9e67834SAndre Fischer maVSSpacing.SetCusEnable(false); 216*d4aefcaeSZheng Fan maVSSpacing.SetCustomTip(maStrCus,true); //LAST CUSTOM no tip defect //add 217b9e67834SAndre Fischer } 218b9e67834SAndre Fischer else 219b9e67834SAndre Fischer { 220b9e67834SAndre Fischer //set custom tips 221b9e67834SAndre Fischer maVSSpacing.SetCusEnable(true); 222b9e67834SAndre Fischer if(mnCustomKern > 0) 223b9e67834SAndre Fischer { 224b9e67834SAndre Fischer String aStrTip( maStrCusE); //LAST CUSTOM no tip defect //add 225b9e67834SAndre Fischer aStrTip.Append( String::CreateFromDouble( (double)mnCustomKern / 10)); 226*d4aefcaeSZheng Fan aStrTip.Append(String("pt", 2, RTL_TEXTENCODING_ASCII_US)); 227b9e67834SAndre Fischer aStrTip.Append(maStrUnit); // modify 228*d4aefcaeSZheng Fan maVSSpacing.SetCustomTip(aStrTip,true); 229b9e67834SAndre Fischer } 230b9e67834SAndre Fischer else if(mnCustomKern < 0) 231b9e67834SAndre Fischer { 232b9e67834SAndre Fischer String aStrTip(maStrCusC) ; //LAST CUSTOM no tip defect //add 233b9e67834SAndre Fischer aStrTip.Append( String::CreateFromDouble( (double)-mnCustomKern / 10)); 234*d4aefcaeSZheng Fan aStrTip.Append(String("pt", 2, RTL_TEXTENCODING_ASCII_US)); 235b9e67834SAndre Fischer aStrTip.Append(maStrUnit); // modify 236*d4aefcaeSZheng Fan maVSSpacing.SetCustomTip(aStrTip,true); 237b9e67834SAndre Fischer } 238b9e67834SAndre Fischer else 239b9e67834SAndre Fischer { 240b9e67834SAndre Fischer String aStrTip(maStrCusN) ; //LAST CUSTOM no tip defect //add 241*d4aefcaeSZheng Fan maVSSpacing.SetCustomTip(aStrTip,true); 242b9e67834SAndre Fischer } 243b9e67834SAndre Fischer 244b9e67834SAndre Fischer } 245b9e67834SAndre Fischer 246b9e67834SAndre Fischer if(bLBAvailable && bAvailable) 247b9e67834SAndre Fischer { 248b9e67834SAndre Fischer maLBKerning.Enable(); 249b9e67834SAndre Fischer maFTSpacing.Enable(); 250*d4aefcaeSZheng Fan 251*d4aefcaeSZheng Fan SfxMapUnit eUnit = mrTextPropertyPanel.GetSpaceController().GetCoreMetric(); 252b9e67834SAndre Fischer MapUnit eOrgUnit = (MapUnit)eUnit; 253b9e67834SAndre Fischer MapUnit ePntUnit( MAP_POINT ); 254b9e67834SAndre Fischer long nBig = maEditKerning.Normalize(nKerning); 255b9e67834SAndre Fischer nKerning = LogicToLogic( nBig, eOrgUnit, ePntUnit ); 256b9e67834SAndre Fischer 257b9e67834SAndre Fischer if ( nKerning > 0 ) 258b9e67834SAndre Fischer { 259b9e67834SAndre Fischer maFTBy.Enable(); 260b9e67834SAndre Fischer maEditKerning.Enable(); 261b9e67834SAndre Fischer maEditKerning.SetMax( 9999 ); 262b9e67834SAndre Fischer maEditKerning.SetLast( 9999 ); 263b9e67834SAndre Fischer maEditKerning.SetValue( nKerning ); 264b9e67834SAndre Fischer maLBKerning.SelectEntryPos( SIDEBAR_SPACE_EXPAND ); 265b9e67834SAndre Fischer if(nKerning == 30) 266b9e67834SAndre Fischer { 267b9e67834SAndre Fischer maVSSpacing.SetSelItem(4); 268b9e67834SAndre Fischer } 269b9e67834SAndre Fischer else if(nKerning == 60) 270b9e67834SAndre Fischer { 271b9e67834SAndre Fischer maVSSpacing.SetSelItem(5); 272b9e67834SAndre Fischer } 273b9e67834SAndre Fischer else 274b9e67834SAndre Fischer { 275b9e67834SAndre Fischer maVSSpacing.SetSelItem(0); 276b9e67834SAndre Fischer mbVS = false; 277b9e67834SAndre Fischer } 278b9e67834SAndre Fischer } 279b9e67834SAndre Fischer else if ( nKerning < 0 ) 280b9e67834SAndre Fischer { 281b9e67834SAndre Fischer maFTBy.Enable(); 282b9e67834SAndre Fischer maEditKerning.Enable(); 283b9e67834SAndre Fischer maEditKerning.SetValue( -nKerning ); 284b9e67834SAndre Fischer maLBKerning.SelectEntryPos( SIDEBAR_SPACE_CONDENSED ); 285*d4aefcaeSZheng Fan long nMax = mrTextPropertyPanel.GetSelFontSize()/6; 286b9e67834SAndre Fischer maEditKerning.SetMax( maEditKerning.Normalize( nMax ), FUNIT_POINT ); 287b9e67834SAndre Fischer maEditKerning.SetLast( maEditKerning.GetMax( maEditKerning.GetUnit() ) ); 288b9e67834SAndre Fischer if( nKerning == -30 ) 289b9e67834SAndre Fischer { 290b9e67834SAndre Fischer maVSSpacing.SetSelItem(1); 291b9e67834SAndre Fischer } 292b9e67834SAndre Fischer else if( nKerning == -15 ) 293b9e67834SAndre Fischer { 294b9e67834SAndre Fischer maVSSpacing.SetSelItem(2); 295b9e67834SAndre Fischer } 296b9e67834SAndre Fischer else 297b9e67834SAndre Fischer { 298b9e67834SAndre Fischer maVSSpacing.SetSelItem(0); 299b9e67834SAndre Fischer mbVS = false; 300b9e67834SAndre Fischer } 301b9e67834SAndre Fischer } 302b9e67834SAndre Fischer else 303b9e67834SAndre Fischer { 304b9e67834SAndre Fischer maVSSpacing.SetSelItem(3); 305b9e67834SAndre Fischer maLBKerning.SelectEntryPos( SIDEBAR_SPACE_NORMAL ); 306b9e67834SAndre Fischer maFTBy.Disable(); 307b9e67834SAndre Fischer maEditKerning.Disable(); 308b9e67834SAndre Fischer maEditKerning.SetValue( 0 ); 309b9e67834SAndre Fischer maEditKerning.SetMax( 9999 ); 310b9e67834SAndre Fischer maEditKerning.SetLast( 9999 ); 311b9e67834SAndre Fischer } 312b9e67834SAndre Fischer } 313b9e67834SAndre Fischer else if(bLBAvailable && !bAvailable) 314b9e67834SAndre Fischer { 315b9e67834SAndre Fischer //modified 316b9e67834SAndre Fischer maVSSpacing.SetSelItem(0); 317b9e67834SAndre Fischer mbVS = false; 318b9e67834SAndre Fischer maLBKerning.Enable(); 319b9e67834SAndre Fischer maFTSpacing.Enable(); 320b9e67834SAndre Fischer maLBKerning.SetNoSelection(); 321b9e67834SAndre Fischer maEditKerning.SetText(String()); 322b9e67834SAndre Fischer maEditKerning.Disable(); 323b9e67834SAndre Fischer maFTBy.Disable(); 324b9e67834SAndre Fischer } 325b9e67834SAndre Fischer else 326b9e67834SAndre Fischer { 327b9e67834SAndre Fischer maVSSpacing.SetSelItem(0); 328b9e67834SAndre Fischer mbVS = false; 329b9e67834SAndre Fischer maEditKerning.SetText(String()); 330b9e67834SAndre Fischer maLBKerning.SetNoSelection(); 331b9e67834SAndre Fischer maLBKerning.Disable(); 332b9e67834SAndre Fischer maFTSpacing.Disable(); 333b9e67834SAndre Fischer maEditKerning.Disable(); 334b9e67834SAndre Fischer maFTBy.Disable(); 335b9e67834SAndre Fischer } 336b9e67834SAndre Fischer GetFocus(); 337b9e67834SAndre Fischer maVSSpacing.Format(); 338b9e67834SAndre Fischer maVSSpacing.StartSelection(); 339b9e67834SAndre Fischer } 340*d4aefcaeSZheng Fan IMPL_LINK(TextCharacterSpacingControl, VSSelHdl, void *, pControl) 341b9e67834SAndre Fischer { 342*d4aefcaeSZheng Fan mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 343b9e67834SAndre Fischer 344b9e67834SAndre Fischer if(pControl == &maVSSpacing) 345b9e67834SAndre Fischer { 346*d4aefcaeSZheng Fan sal_uInt16 iPos = maVSSpacing.GetSelectItemId(); 347b9e67834SAndre Fischer short nKern = 0; 348*d4aefcaeSZheng Fan SfxMapUnit eUnit = mrTextPropertyPanel.GetSpaceController().GetCoreMetric(); 349b9e67834SAndre Fischer long nVal = 0; 350b9e67834SAndre Fischer if(iPos == 1) 351b9e67834SAndre Fischer { 352b9e67834SAndre Fischer nVal = LogicToLogic(30, MAP_POINT, (MapUnit)eUnit); 353b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal); 354b9e67834SAndre Fischer SvxKerningItem aKernItem(-nKern, SID_ATTR_CHAR_KERNING); 355b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 356*d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(-nKern); 357b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 358b9e67834SAndre Fischer } 359b9e67834SAndre Fischer else if(iPos == 2) 360b9e67834SAndre Fischer { 361b9e67834SAndre Fischer nVal = LogicToLogic(15, MAP_POINT, (MapUnit)eUnit); 362b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal); 363b9e67834SAndre Fischer SvxKerningItem aKernItem(-nKern, SID_ATTR_CHAR_KERNING); 364b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 365*d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(-nKern); 366b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 367b9e67834SAndre Fischer } 368b9e67834SAndre Fischer else if(iPos == 3) 369b9e67834SAndre Fischer { 370b9e67834SAndre Fischer SvxKerningItem aKernItem(0, SID_ATTR_CHAR_KERNING); 371b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 372*d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(0); 373b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 374b9e67834SAndre Fischer } 375b9e67834SAndre Fischer else if(iPos == 4) 376b9e67834SAndre Fischer { 377b9e67834SAndre Fischer nVal = LogicToLogic(30, MAP_POINT, (MapUnit)eUnit); 378b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal); 379b9e67834SAndre Fischer SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING); 380b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 381*d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(nKern); 382b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 383b9e67834SAndre Fischer } 384b9e67834SAndre Fischer else if(iPos == 5) 385b9e67834SAndre Fischer { 386b9e67834SAndre Fischer nVal = LogicToLogic(60, MAP_POINT, (MapUnit)eUnit); 387b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal); 388b9e67834SAndre Fischer SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING); 389b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 390*d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(nKern); 391b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 392b9e67834SAndre Fischer } 393b9e67834SAndre Fischer else if(iPos == 6) 394b9e67834SAndre Fischer { 395b9e67834SAndre Fischer //modified 396b9e67834SAndre Fischer if(mbCusEnable) 397b9e67834SAndre Fischer { 398b9e67834SAndre Fischer nVal = LogicToLogic(mnCustomKern, MAP_POINT, (MapUnit)eUnit); 399b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal); 400b9e67834SAndre Fischer SvxKerningItem aKernItem(nKern , SID_ATTR_CHAR_KERNING); 401b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 402*d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(nKern); 403b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON; 404b9e67834SAndre Fischer } 405b9e67834SAndre Fischer else 406b9e67834SAndre Fischer { 407b9e67834SAndre Fischer maVSSpacing.SetNoSelection(); //add , set no selection and keep the last select item 408b9e67834SAndre Fischer maVSSpacing.Format(); 409b9e67834SAndre Fischer Invalidate(); 410b9e67834SAndre Fischer maVSSpacing.StartSelection(); 411b9e67834SAndre Fischer } 412b9e67834SAndre Fischer //modify end 413b9e67834SAndre Fischer } 414b9e67834SAndre Fischer 415b9e67834SAndre Fischer if(iPos < 6 || (iPos == 6 && mbCusEnable)) //add 416*d4aefcaeSZheng Fan mrTextPropertyPanel.EndSpacingPopupMode(); 417b9e67834SAndre Fischer } 418b9e67834SAndre Fischer 419b9e67834SAndre Fischer 420b9e67834SAndre Fischer 421b9e67834SAndre Fischer return 0; 422b9e67834SAndre Fischer } 423b9e67834SAndre Fischer 424*d4aefcaeSZheng Fan IMPL_LINK(TextCharacterSpacingControl, KerningSelectHdl, ListBox*, EMPTYARG) 425b9e67834SAndre Fischer { 426b9e67834SAndre Fischer if ( maLBKerning.GetSelectEntryPos() > 0 ) 427b9e67834SAndre Fischer { 428b9e67834SAndre Fischer maFTBy.Enable(); 429b9e67834SAndre Fischer maEditKerning.Enable(); 430b9e67834SAndre Fischer } 431b9e67834SAndre Fischer else 432b9e67834SAndre Fischer { 433b9e67834SAndre Fischer maEditKerning.SetValue( 0 ); 434b9e67834SAndre Fischer maFTBy.Disable(); 435b9e67834SAndre Fischer maEditKerning.Disable(); 436b9e67834SAndre Fischer } 437b9e67834SAndre Fischer 438b9e67834SAndre Fischer if(maVSSpacing.GetSelItem()) 439b9e67834SAndre Fischer { 440b9e67834SAndre Fischer maVSSpacing.SetSelItem(0); //modify 441b9e67834SAndre Fischer maVSSpacing.Format(); 442b9e67834SAndre Fischer Invalidate(); 443b9e67834SAndre Fischer maVSSpacing.StartSelection(); 444b9e67834SAndre Fischer } 445b9e67834SAndre Fischer KerningModifyHdl( NULL ); 446b9e67834SAndre Fischer return 0; 447b9e67834SAndre Fischer } 448*d4aefcaeSZheng Fan IMPL_LINK(TextCharacterSpacingControl, KerningModifyHdl, MetricField*, EMPTYARG) 449b9e67834SAndre Fischer { 450b9e67834SAndre Fischer if(maVSSpacing.GetSelItem()) 451b9e67834SAndre Fischer { 452b9e67834SAndre Fischer maVSSpacing.SetSelItem(0); //modify 453b9e67834SAndre Fischer maVSSpacing.Format(); 454b9e67834SAndre Fischer Invalidate(); 455b9e67834SAndre Fischer maVSSpacing.StartSelection(); 456b9e67834SAndre Fischer } 457*d4aefcaeSZheng Fan sal_uInt16 nPos = maLBKerning.GetSelectEntryPos(); 458b9e67834SAndre Fischer short nKern = 0; 459*d4aefcaeSZheng Fan SfxMapUnit eUnit = mrTextPropertyPanel.GetSpaceController().GetCoreMetric(); 460b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CUS_EDIT; 461b9e67834SAndre Fischer if ( nPos == SIDEBAR_SPACE_EXPAND || nPos == SIDEBAR_SPACE_CONDENSED ) 462b9e67834SAndre Fischer { 463b9e67834SAndre Fischer long nTmp = static_cast<long>(maEditKerning.GetValue()); 464b9e67834SAndre Fischer if ( nPos == SIDEBAR_SPACE_CONDENSED ) 465b9e67834SAndre Fischer { 466*d4aefcaeSZheng Fan long nMax = mrTextPropertyPanel.GetSelFontSize()/6; 467b9e67834SAndre Fischer maEditKerning.SetMax( maEditKerning.Normalize( nMax ), FUNIT_TWIP ); 468b9e67834SAndre Fischer maEditKerning.SetLast( maEditKerning.GetMax( maEditKerning.GetUnit() ) ); 469b9e67834SAndre Fischer if(nTmp > maEditKerning.GetMax()) 470b9e67834SAndre Fischer nTmp = maEditKerning.GetMax(); 471b9e67834SAndre Fischer mnCustomKern = -nTmp; 472b9e67834SAndre Fischer long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit ); 473b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize( nVal ); 474b9e67834SAndre Fischer nKern *= - 1; 475b9e67834SAndre Fischer } 476b9e67834SAndre Fischer else 477b9e67834SAndre Fischer { 478b9e67834SAndre Fischer maEditKerning.SetMax( 9999 ); 479b9e67834SAndre Fischer maEditKerning.SetLast( 9999 ); 480b9e67834SAndre Fischer if(nTmp > maEditKerning.GetMax(FUNIT_TWIP)) 481b9e67834SAndre Fischer nTmp = maEditKerning.GetMax(FUNIT_TWIP); 482b9e67834SAndre Fischer mnCustomKern = nTmp; 483b9e67834SAndre Fischer long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit ); 484b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize( nVal ); 485b9e67834SAndre Fischer } 486b9e67834SAndre Fischer } 487b9e67834SAndre Fischer else 488b9e67834SAndre Fischer { 489b9e67834SAndre Fischer mnCustomKern = 0; 490b9e67834SAndre Fischer } 491b9e67834SAndre Fischer SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING); 492b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L); 493*d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(nKern); 494b9e67834SAndre Fischer return 0; 495b9e67834SAndre Fischer } 496*d4aefcaeSZheng Fan short TextCharacterSpacingControl::GetLastCustomState() 497b9e67834SAndre Fischer { 498b9e67834SAndre Fischer return mnLastCus; 499b9e67834SAndre Fischer } 500*d4aefcaeSZheng Fan long TextCharacterSpacingControl::GetLastCustomValue() 501b9e67834SAndre Fischer { 502b9e67834SAndre Fischer return mnCustomKern; 503b9e67834SAndre Fischer } 504b9e67834SAndre Fischer 505*d4aefcaeSZheng Fan }} // end of namespace sidebar 506