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"
25d29c2fc2SAndre 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
TextCharacterSpacingControl(Window * pParent,svx::sidebar::TextPropertyPanel & rPanel,SfxBindings * pBindings)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 }
~TextCharacterSpacingControl()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
initial()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 }
ToGetFocus()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
Rearrange(bool bLBAvailable,bool bAvailable,long nKerning)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));
188*ae2dc0faSTsutomu Uchino aStrTip.Append( xub_Unicode(' ') );
189b9e67834SAndre Fischer aStrTip.Append(maStrUnit); // modify
1900a759ee0SZheng Fan maVSSpacing.SetItemText(6,aStrTip);
191b9e67834SAndre Fischer }
192b9e67834SAndre Fischer else if(mnCustomKern < 0)
193b9e67834SAndre Fischer {
194b9e67834SAndre Fischer String aStrTip(maStrCusC) ; //LAST CUSTOM no tip defect //add
195b9e67834SAndre Fischer aStrTip.Append( String::CreateFromDouble( (double)-mnCustomKern / 10));
196*ae2dc0faSTsutomu Uchino aStrTip.Append( xub_Unicode( ' ' ) );
197b9e67834SAndre Fischer aStrTip.Append(maStrUnit); // modify
1980a759ee0SZheng Fan maVSSpacing.SetItemText( 6, aStrTip );
199b9e67834SAndre Fischer }
200b9e67834SAndre Fischer else
201b9e67834SAndre Fischer {
202b9e67834SAndre Fischer String aStrTip(maStrCusN) ; //LAST CUSTOM no tip defect //add
2030a759ee0SZheng Fan maVSSpacing.SetItemText( 6, aStrTip );
204b9e67834SAndre Fischer }
205b9e67834SAndre Fischer
206b9e67834SAndre Fischer }
207b9e67834SAndre Fischer
208b9e67834SAndre Fischer if(bLBAvailable && bAvailable)
209b9e67834SAndre Fischer {
210b9e67834SAndre Fischer maLBKerning.Enable();
211b9e67834SAndre Fischer maFTSpacing.Enable();
212d4aefcaeSZheng Fan
213d4aefcaeSZheng Fan SfxMapUnit eUnit = mrTextPropertyPanel.GetSpaceController().GetCoreMetric();
214b9e67834SAndre Fischer MapUnit eOrgUnit = (MapUnit)eUnit;
215b9e67834SAndre Fischer MapUnit ePntUnit( MAP_POINT );
216b9e67834SAndre Fischer long nBig = maEditKerning.Normalize(nKerning);
217b9e67834SAndre Fischer nKerning = LogicToLogic( nBig, eOrgUnit, ePntUnit );
218b9e67834SAndre Fischer
21961a625e4SOliver-Rainer Wittmann if ( nKerning > 0 )
220b9e67834SAndre Fischer {
22161a625e4SOliver-Rainer Wittmann maFTBy.Enable();
222b9e67834SAndre Fischer maEditKerning.Enable();
223b9e67834SAndre Fischer maEditKerning.SetMax( 9999 );
224b9e67834SAndre Fischer maEditKerning.SetLast( 9999 );
225b9e67834SAndre Fischer maEditKerning.SetValue( nKerning );
226b9e67834SAndre Fischer maLBKerning.SelectEntryPos( SIDEBAR_SPACE_EXPAND );
227b9e67834SAndre Fischer if(nKerning == 30)
228b9e67834SAndre Fischer {
2290a759ee0SZheng Fan maVSSpacing.SelectItem(4);
230b9e67834SAndre Fischer }
231b9e67834SAndre Fischer else if(nKerning == 60)
232b9e67834SAndre Fischer {
2330a759ee0SZheng Fan maVSSpacing.SelectItem(5);
234b9e67834SAndre Fischer }
235b9e67834SAndre Fischer else
236b9e67834SAndre Fischer {
23761a625e4SOliver-Rainer Wittmann maVSSpacing.SetNoSelection();
23861a625e4SOliver-Rainer Wittmann maVSSpacing.SelectItem(0);
239b9e67834SAndre Fischer mbVS = false;
240b9e67834SAndre Fischer }
241b9e67834SAndre Fischer }
242b9e67834SAndre Fischer else if ( nKerning < 0 )
243b9e67834SAndre Fischer {
244b9e67834SAndre Fischer maFTBy.Enable();
245b9e67834SAndre Fischer maEditKerning.Enable();
246b9e67834SAndre Fischer maEditKerning.SetValue( -nKerning );
247b9e67834SAndre Fischer maLBKerning.SelectEntryPos( SIDEBAR_SPACE_CONDENSED );
248d4aefcaeSZheng Fan long nMax = mrTextPropertyPanel.GetSelFontSize()/6;
249b9e67834SAndre Fischer maEditKerning.SetMax( maEditKerning.Normalize( nMax ), FUNIT_POINT );
250b9e67834SAndre Fischer maEditKerning.SetLast( maEditKerning.GetMax( maEditKerning.GetUnit() ) );
251b9e67834SAndre Fischer if( nKerning == -30 )
252b9e67834SAndre Fischer {
2530a759ee0SZheng Fan maVSSpacing.SelectItem(1);
254b9e67834SAndre Fischer }
255b9e67834SAndre Fischer else if( nKerning == -15 )
256b9e67834SAndre Fischer {
2570a759ee0SZheng Fan maVSSpacing.SelectItem(2);
258b9e67834SAndre Fischer }
259b9e67834SAndre Fischer else
260b9e67834SAndre Fischer {
26161a625e4SOliver-Rainer Wittmann maVSSpacing.SetNoSelection();
26261a625e4SOliver-Rainer Wittmann maVSSpacing.SelectItem(0);
263b9e67834SAndre Fischer mbVS = false;
264b9e67834SAndre Fischer }
265b9e67834SAndre Fischer }
266b9e67834SAndre Fischer else
267b9e67834SAndre Fischer {
2680a759ee0SZheng Fan maVSSpacing.SelectItem(3);
269b9e67834SAndre Fischer maLBKerning.SelectEntryPos( SIDEBAR_SPACE_NORMAL );
270b9e67834SAndre Fischer maFTBy.Disable();
271b9e67834SAndre Fischer maEditKerning.Disable();
272b9e67834SAndre Fischer maEditKerning.SetValue( 0 );
273b9e67834SAndre Fischer maEditKerning.SetMax( 9999 );
274b9e67834SAndre Fischer maEditKerning.SetLast( 9999 );
275b9e67834SAndre Fischer }
276b9e67834SAndre Fischer }
277b9e67834SAndre Fischer else if(bLBAvailable && !bAvailable)
278b9e67834SAndre Fischer {
279b9e67834SAndre Fischer //modified
28061a625e4SOliver-Rainer Wittmann maVSSpacing.SetNoSelection();
28161a625e4SOliver-Rainer Wittmann maVSSpacing.SelectItem(0);
282b9e67834SAndre Fischer mbVS = false;
283b9e67834SAndre Fischer maLBKerning.Enable();
284b9e67834SAndre Fischer maFTSpacing.Enable();
285b9e67834SAndre Fischer maLBKerning.SetNoSelection();
286b9e67834SAndre Fischer maEditKerning.SetText(String());
287b9e67834SAndre Fischer maEditKerning.Disable();
288b9e67834SAndre Fischer maFTBy.Disable();
289b9e67834SAndre Fischer }
290b9e67834SAndre Fischer else
291b9e67834SAndre Fischer {
29261a625e4SOliver-Rainer Wittmann maVSSpacing.SetNoSelection();
29361a625e4SOliver-Rainer Wittmann maVSSpacing.SelectItem(0);
294b9e67834SAndre Fischer mbVS = false;
295b9e67834SAndre Fischer maEditKerning.SetText(String());
296b9e67834SAndre Fischer maLBKerning.SetNoSelection();
297b9e67834SAndre Fischer maLBKerning.Disable();
298b9e67834SAndre Fischer maFTSpacing.Disable();
299b9e67834SAndre Fischer maEditKerning.Disable();
300b9e67834SAndre Fischer maFTBy.Disable();
301b9e67834SAndre Fischer }
302b9e67834SAndre Fischer GetFocus();
303b9e67834SAndre Fischer maVSSpacing.Format();
304b9e67834SAndre Fischer maVSSpacing.StartSelection();
305b9e67834SAndre Fischer }
IMPL_LINK(TextCharacterSpacingControl,VSSelHdl,void *,pControl)306d4aefcaeSZheng Fan IMPL_LINK(TextCharacterSpacingControl, VSSelHdl, void *, pControl)
307b9e67834SAndre Fischer {
308d4aefcaeSZheng Fan mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
309b9e67834SAndre Fischer
310b9e67834SAndre Fischer if(pControl == &maVSSpacing)
311b9e67834SAndre Fischer {
312d4aefcaeSZheng Fan sal_uInt16 iPos = maVSSpacing.GetSelectItemId();
313b9e67834SAndre Fischer short nKern = 0;
314d4aefcaeSZheng Fan SfxMapUnit eUnit = mrTextPropertyPanel.GetSpaceController().GetCoreMetric();
315b9e67834SAndre Fischer long nVal = 0;
316b9e67834SAndre Fischer if(iPos == 1)
317b9e67834SAndre Fischer {
318b9e67834SAndre Fischer nVal = LogicToLogic(30, MAP_POINT, (MapUnit)eUnit);
319b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal);
320b9e67834SAndre Fischer SvxKerningItem aKernItem(-nKern, SID_ATTR_CHAR_KERNING);
321b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L);
322d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(-nKern);
323b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
324b9e67834SAndre Fischer }
325b9e67834SAndre Fischer else if(iPos == 2)
326b9e67834SAndre Fischer {
327b9e67834SAndre Fischer nVal = LogicToLogic(15, MAP_POINT, (MapUnit)eUnit);
328b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal);
329b9e67834SAndre Fischer SvxKerningItem aKernItem(-nKern, SID_ATTR_CHAR_KERNING);
330b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L);
331d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(-nKern);
332b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
333b9e67834SAndre Fischer }
334b9e67834SAndre Fischer else if(iPos == 3)
335b9e67834SAndre Fischer {
336b9e67834SAndre Fischer SvxKerningItem aKernItem(0, SID_ATTR_CHAR_KERNING);
337b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L);
338d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(0);
339b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
340b9e67834SAndre Fischer }
341b9e67834SAndre Fischer else if(iPos == 4)
342b9e67834SAndre Fischer {
343b9e67834SAndre Fischer nVal = LogicToLogic(30, MAP_POINT, (MapUnit)eUnit);
344b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal);
345b9e67834SAndre Fischer SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING);
346b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L);
347d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(nKern);
348b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
349b9e67834SAndre Fischer }
350b9e67834SAndre Fischer else if(iPos == 5)
351b9e67834SAndre Fischer {
352b9e67834SAndre Fischer nVal = LogicToLogic(60, 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);
356d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(nKern);
357b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
358b9e67834SAndre Fischer }
359b9e67834SAndre Fischer else if(iPos == 6)
360b9e67834SAndre Fischer {
361b9e67834SAndre Fischer //modified
362b9e67834SAndre Fischer if(mbCusEnable)
363b9e67834SAndre Fischer {
364b9e67834SAndre Fischer nVal = LogicToLogic(mnCustomKern, MAP_POINT, (MapUnit)eUnit);
365b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize(nVal);
366b9e67834SAndre Fischer SvxKerningItem aKernItem(nKern , SID_ATTR_CHAR_KERNING);
367b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L);
368d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(nKern);
369b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
370b9e67834SAndre Fischer }
371b9e67834SAndre Fischer else
372b9e67834SAndre Fischer {
373b9e67834SAndre Fischer maVSSpacing.SetNoSelection(); //add , set no selection and keep the last select item
374b9e67834SAndre Fischer maVSSpacing.Format();
375b9e67834SAndre Fischer Invalidate();
376b9e67834SAndre Fischer maVSSpacing.StartSelection();
377b9e67834SAndre Fischer }
378b9e67834SAndre Fischer //modify end
379b9e67834SAndre Fischer }
380b9e67834SAndre Fischer
381b9e67834SAndre Fischer if(iPos < 6 || (iPos == 6 && mbCusEnable)) //add
382d4aefcaeSZheng Fan mrTextPropertyPanel.EndSpacingPopupMode();
383b9e67834SAndre Fischer }
384b9e67834SAndre Fischer
385b9e67834SAndre Fischer
386b9e67834SAndre Fischer
387b9e67834SAndre Fischer return 0;
388b9e67834SAndre Fischer }
389b9e67834SAndre Fischer
IMPL_LINK(TextCharacterSpacingControl,KerningSelectHdl,ListBox *,EMPTYARG)390d4aefcaeSZheng Fan IMPL_LINK(TextCharacterSpacingControl, KerningSelectHdl, ListBox*, EMPTYARG)
391b9e67834SAndre Fischer {
392b9e67834SAndre Fischer if ( maLBKerning.GetSelectEntryPos() > 0 )
393b9e67834SAndre Fischer {
394b9e67834SAndre Fischer maFTBy.Enable();
395b9e67834SAndre Fischer maEditKerning.Enable();
396b9e67834SAndre Fischer }
397b9e67834SAndre Fischer else
398b9e67834SAndre Fischer {
399b9e67834SAndre Fischer maEditKerning.SetValue( 0 );
400b9e67834SAndre Fischer maFTBy.Disable();
401b9e67834SAndre Fischer maEditKerning.Disable();
402b9e67834SAndre Fischer }
403b9e67834SAndre Fischer
4040a759ee0SZheng Fan if ( maVSSpacing.GetSelectItemId() > 0 )
405b9e67834SAndre Fischer {
40661a625e4SOliver-Rainer Wittmann maVSSpacing.SetNoSelection();
40761a625e4SOliver-Rainer Wittmann maVSSpacing.SelectItem(0);
408b9e67834SAndre Fischer maVSSpacing.Format();
409b9e67834SAndre Fischer Invalidate();
410b9e67834SAndre Fischer maVSSpacing.StartSelection();
411b9e67834SAndre Fischer }
412b9e67834SAndre Fischer KerningModifyHdl( NULL );
413b9e67834SAndre Fischer return 0;
414b9e67834SAndre Fischer }
IMPL_LINK(TextCharacterSpacingControl,KerningModifyHdl,MetricField *,EMPTYARG)415d4aefcaeSZheng Fan IMPL_LINK(TextCharacterSpacingControl, KerningModifyHdl, MetricField*, EMPTYARG)
416b9e67834SAndre Fischer {
4170a759ee0SZheng Fan if ( maVSSpacing.GetSelectItemId() > 0 )
418b9e67834SAndre Fischer {
41961a625e4SOliver-Rainer Wittmann maVSSpacing.SetNoSelection();
42061a625e4SOliver-Rainer Wittmann maVSSpacing.SelectItem(0);
421b9e67834SAndre Fischer maVSSpacing.Format();
422b9e67834SAndre Fischer Invalidate();
423b9e67834SAndre Fischer maVSSpacing.StartSelection();
424b9e67834SAndre Fischer }
425d4aefcaeSZheng Fan sal_uInt16 nPos = maLBKerning.GetSelectEntryPos();
426b9e67834SAndre Fischer short nKern = 0;
427d4aefcaeSZheng Fan SfxMapUnit eUnit = mrTextPropertyPanel.GetSpaceController().GetCoreMetric();
428b9e67834SAndre Fischer mnLastCus = SPACING_CLOSE_BY_CUS_EDIT;
429b9e67834SAndre Fischer if ( nPos == SIDEBAR_SPACE_EXPAND || nPos == SIDEBAR_SPACE_CONDENSED )
430b9e67834SAndre Fischer {
431b9e67834SAndre Fischer long nTmp = static_cast<long>(maEditKerning.GetValue());
432b9e67834SAndre Fischer if ( nPos == SIDEBAR_SPACE_CONDENSED )
433b9e67834SAndre Fischer {
434d4aefcaeSZheng Fan long nMax = mrTextPropertyPanel.GetSelFontSize()/6;
435b9e67834SAndre Fischer maEditKerning.SetMax( maEditKerning.Normalize( nMax ), FUNIT_TWIP );
436b9e67834SAndre Fischer maEditKerning.SetLast( maEditKerning.GetMax( maEditKerning.GetUnit() ) );
437b9e67834SAndre Fischer if(nTmp > maEditKerning.GetMax())
438b9e67834SAndre Fischer nTmp = maEditKerning.GetMax();
439b9e67834SAndre Fischer mnCustomKern = -nTmp;
440b9e67834SAndre Fischer long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit );
441b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize( nVal );
442b9e67834SAndre Fischer nKern *= - 1;
443b9e67834SAndre Fischer }
444b9e67834SAndre Fischer else
445b9e67834SAndre Fischer {
446b9e67834SAndre Fischer maEditKerning.SetMax( 9999 );
447b9e67834SAndre Fischer maEditKerning.SetLast( 9999 );
448b9e67834SAndre Fischer if(nTmp > maEditKerning.GetMax(FUNIT_TWIP))
449b9e67834SAndre Fischer nTmp = maEditKerning.GetMax(FUNIT_TWIP);
450b9e67834SAndre Fischer mnCustomKern = nTmp;
451b9e67834SAndre Fischer long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit );
452b9e67834SAndre Fischer nKern = (short)maEditKerning.Denormalize( nVal );
453b9e67834SAndre Fischer }
454b9e67834SAndre Fischer }
455b9e67834SAndre Fischer else
456b9e67834SAndre Fischer {
457b9e67834SAndre Fischer mnCustomKern = 0;
458b9e67834SAndre Fischer }
459b9e67834SAndre Fischer SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING);
460b9e67834SAndre Fischer mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L);
461d4aefcaeSZheng Fan mrTextPropertyPanel.SetSpacing(nKern);
462b9e67834SAndre Fischer return 0;
463b9e67834SAndre Fischer }
GetLastCustomState()464d4aefcaeSZheng Fan short TextCharacterSpacingControl::GetLastCustomState()
465b9e67834SAndre Fischer {
466b9e67834SAndre Fischer return mnLastCus;
467b9e67834SAndre Fischer }
GetLastCustomValue()468d4aefcaeSZheng Fan long TextCharacterSpacingControl::GetLastCustomValue()
469b9e67834SAndre Fischer {
470b9e67834SAndre Fischer return mnCustomKern;
471b9e67834SAndre Fischer }
472b9e67834SAndre Fischer
473d4aefcaeSZheng Fan }} // end of namespace sidebar
474