xref: /aoo41x/main/cui/source/tabpages/tabstpge.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
30 
31 // include ---------------------------------------------------------------
32 
33 #include <sfx2/app.hxx>
34 #include <tools/shl.hxx>
35 #include <svtools/ruler.hxx>
36 #include <svx/dialogs.hrc>
37 #include <svx/dialogs.hrc>
38 
39 #define _SVX_TABSTPGE_CXX
40 
41 #include <cuires.hrc>
42 #include "tabstpge.hrc"
43 #include <editeng/lrspitem.hxx>
44 #include "tabstpge.hxx"
45 #include <dialmgr.hxx>
46 #include "svx/dlgutil.hxx"
47 #include <sfx2/module.hxx>
48 #include <svl/cjkoptions.hxx>
49 #include <unotools/localedatawrapper.hxx>
50 #include <comphelper/processfactory.hxx>
51 #include <sfx2/request.hxx> //CHINA001
52 #include <svl/intitem.hxx> //add CHINA001
53 
54 // class TabWin_Impl -----------------------------------------------------
55 
56 class TabWin_Impl : public Window
57 {
58 private:
59 	sal_uInt16  nTabStyle;
60 
61 public:
62 	TabWin_Impl( Window* pParent, const ResId& rId, sal_uInt16 nStyle ) :
63 		Window( pParent, rId ),
64 		nTabStyle( nStyle ) {}
65 
66 	virtual void    Paint( const Rectangle& rRect );
67 };
68 
69 // static ----------------------------------------------------------------
70 
71 static sal_uInt16 pRanges[] =
72 {
73 	SID_ATTR_TABSTOP,
74 	SID_ATTR_TABSTOP_OFFSET,
75 	0
76 };
77 
78 // C-Funktion ------------------------------------------------------------
79 
80 void FillUpWithDefTabs_Impl( long nDefDist, SvxTabStopItem& rTabs )
81 {
82 	if( rTabs.Count() )
83 		return;
84 	{
85 		SvxTabStop aSwTabStop( nDefDist, SVX_TAB_ADJUST_DEFAULT );
86 		rTabs.Insert( aSwTabStop );
87 	}
88 }
89 
90 // class TabWin_Impl -----------------------------------------------------
91 
92 void TabWin_Impl::Paint( const Rectangle& )
93 {
94 	// Tabulatoren malen
95 	Point aPnt;
96 	Size aSize = GetOutputSizePixel();
97 	aPnt.X() = aSize.Width() / 2;
98 	aPnt.Y() = aSize.Height() / 2;
99 	Ruler::DrawTab( this, aPnt, nTabStyle );
100 }
101 
102 // class SvxTabulatorTabPage ---------------------------------------------
103 
104 SvxTabulatorTabPage::SvxTabulatorTabPage( Window* pParent,
105 										  const SfxItemSet& rAttr ):
106 
107 	SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_TABULATOR ), rAttr ),
108 
109     aTabLabel       ( this, CUI_RES( FL_TABPOS ) ),
110 	aTabBox         ( this, CUI_RES( ED_TABPOS ) ),
111     aTabLabelVert   ( this, CUI_RES( FL_TABPOS_VERT ) ),
112     aTabTypeLabel   ( this, CUI_RES( FL_TABTYPE ) ),
113 	aLeftTab        ( this, CUI_RES( BTN_TABTYPE_LEFT ) ),
114 	aRightTab       ( this, CUI_RES( BTN_TABTYPE_RIGHT ) ),
115 	aCenterTab      ( this, CUI_RES( BTN_TABTYPE_CENTER ) ),
116 	aDezTab         ( this, CUI_RES( BTN_TABTYPE_DECIMAL ) ),
117     pLeftWin        ( new TabWin_Impl( this, CUI_RES( WIN_TABLEFT ), (sal_uInt16)(RULER_TAB_LEFT|WB_HORZ) ) ),
118     pRightWin       ( new TabWin_Impl( this, CUI_RES( WIN_TABRIGHT ), (sal_uInt16)(RULER_TAB_RIGHT|WB_HORZ) ) ),
119     pCenterWin      ( new TabWin_Impl( this, CUI_RES( WIN_TABCENTER ), (sal_uInt16)(RULER_TAB_CENTER|WB_HORZ) ) ),
120     pDezWin         ( new TabWin_Impl( this, CUI_RES( WIN_TABDECIMAL ), (sal_uInt16)(RULER_TAB_DECIMAL|WB_HORZ) ) ),
121     aDezCharLabel   ( this, CUI_RES( FT_TABTYPE_DECCHAR ) ),
122     aDezChar        ( this, CUI_RES( ED_TABTYPE_DECCHAR ) ),
123     aFillLabel      ( this, CUI_RES( FL_FILLCHAR ) ),
124 	aNoFillChar     ( this, CUI_RES( BTN_FILLCHAR_NO ) ),
125 	aFillPoints     ( this, CUI_RES( BTN_FILLCHAR_POINTS ) ),
126 	aFillDashLine   ( this, CUI_RES( BTN_FILLCHAR_DASHLINE ) ),
127 	aFillSolidLine  ( this, CUI_RES( BTN_FILLCHAR_UNDERSCORE ) ),
128 	aFillSpecial    ( this, CUI_RES( BTN_FILLCHAR_OTHER ) ),
129 	aFillChar       ( this, CUI_RES( ED_FILLCHAR_OTHER ) ),
130 	aNewBtn         ( this, CUI_RES( BTN_NEW ) ),
131 	aDelAllBtn      ( this, CUI_RES( BTN_DELALL ) ),
132 	aDelBtn         ( this, CUI_RES( BTN_DEL ) ),
133 
134     aAktTab     ( 0 ),
135     aNewTabs    ( 0, 0, SVX_TAB_ADJUST_LEFT, GetWhich( SID_ATTR_TABSTOP ) ),
136     nDefDist    ( 0 ),
137     eDefUnit( FUNIT_100TH_MM ),
138     bCheck      ( sal_False )
139 
140 {
141     SvtCJKOptions aCJKOptions;
142     if(aCJKOptions.IsAsianTypographyEnabled())
143     {
144         aLeftTab  .SetText(String(CUI_RES(   ST_LEFTTAB_ASIAN )));
145         aRightTab .SetText(String(CUI_RES(   ST_RIGHTTAB_ASIAN )));
146     }
147 
148 	aFillChar.SetAccessibleName(String(CUI_RES(   ST_FILLCHAR_OTHER )));
149     // diese Page braucht ExchangeSupport
150 	SetExchangeSupport();
151 
152 
153 	// Metrik einstellen
154 	FieldUnit eFUnit = GetModuleFieldUnit( rAttr );
155 	SetFieldUnit( aTabBox, eFUnit );
156 
157 	// Buttons initialisieren
158 	aNewBtn.SetClickHdl( LINK( this,SvxTabulatorTabPage, NewHdl_Impl ) );
159 	aDelBtn.SetClickHdl( LINK( this,SvxTabulatorTabPage, DelHdl_Impl ) );
160 	aDelAllBtn.SetClickHdl( LINK( this,SvxTabulatorTabPage, DelAllHdl_Impl ) );
161 
162 	Link aLink = LINK( this, SvxTabulatorTabPage, TabTypeCheckHdl_Impl );
163 	aLeftTab.SetClickHdl( aLink );
164 	aRightTab.SetClickHdl( aLink );
165 	aDezTab.SetClickHdl( aLink );
166 	aCenterTab.SetClickHdl( aLink );
167 
168 	aDezChar.SetLoseFocusHdl( LINK( this,  SvxTabulatorTabPage, GetDezCharHdl_Impl ) );
169 	aDezChar.SetMaxTextLen(1);
170 	aDezChar.Disable();
171 	aDezCharLabel.Disable();
172 
173 	aLink = LINK( this, SvxTabulatorTabPage, FillTypeCheckHdl_Impl );
174 	aNoFillChar.SetClickHdl( aLink );
175 	aFillPoints.SetClickHdl( aLink );
176 	aFillDashLine.SetClickHdl( aLink );
177 	aFillSolidLine.SetClickHdl( aLink );
178 	aFillSpecial.SetClickHdl( aLink );
179 	aFillChar.SetLoseFocusHdl( LINK( this,  SvxTabulatorTabPage, GetFillCharHdl_Impl ) );
180 	aFillChar.SetMaxTextLen(1);
181 	aFillChar.Disable();
182 
183 	aTabBox.SetDoubleClickHdl( LINK( this, SvxTabulatorTabPage, SelectHdl_Impl ) );
184 	aTabBox.SetModifyHdl( LINK( this, SvxTabulatorTabPage, ModifyHdl_Impl ) );
185 
186 	aLeftTab.SetAccessibleRelationMemberOf( &aTabTypeLabel );
187 	aRightTab.SetAccessibleRelationMemberOf( &aTabTypeLabel );
188 	aCenterTab.SetAccessibleRelationMemberOf( &aTabTypeLabel );
189 	aDezTab.SetAccessibleRelationMemberOf( &aTabTypeLabel );
190 	aDezCharLabel.SetAccessibleRelationMemberOf( &aTabTypeLabel );
191 	aDezChar.SetAccessibleRelationMemberOf( &aTabTypeLabel );
192 
193 	aNoFillChar.SetAccessibleRelationMemberOf( &aFillLabel );
194 	aFillPoints.SetAccessibleRelationMemberOf( &aFillLabel );
195 	aFillDashLine.SetAccessibleRelationMemberOf( &aFillLabel );
196 	aFillSolidLine.SetAccessibleRelationMemberOf( &aFillLabel );
197 	aFillSpecial.SetAccessibleRelationMemberOf( &aFillLabel );
198 	aFillChar.SetAccessibleRelationMemberOf( &aFillLabel );
199 
200 	aFillChar.SetAccessibleRelationLabeledBy(&aFillSpecial);
201 
202     // das Default-Dezimalzeichen vom System holen
203 	LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
204 	aAktTab.GetDecimal() = aLocaleWrapper.getNumDecimalSep().GetChar(0);
205 	FreeResource();
206 }
207 
208 // -----------------------------------------------------------------------
209 
210 SvxTabulatorTabPage::~SvxTabulatorTabPage()
211 {
212 	delete pLeftWin;
213 	delete pRightWin;
214 	delete pCenterWin;
215 	delete pDezWin;
216 }
217 
218 // -----------------------------------------------------------------------
219 
220 sal_uInt16* SvxTabulatorTabPage::GetRanges()
221 {
222 	return pRanges;
223 }
224 
225 // -----------------------------------------------------------------------
226 
227 sal_Bool SvxTabulatorTabPage::FillItemSet( SfxItemSet& rSet )
228 {
229 	sal_Bool bModified = sal_False;
230 
231 	// Hier die Werte aus den Controls eintueten
232 	if ( aNewBtn.IsEnabled() )
233 		NewHdl_Impl( 0 );
234 
235 	// call at first the LoseFocus-Handler
236 	GetDezCharHdl_Impl( &aDezChar );
237 	GetFillCharHdl_Impl( &aFillChar );
238 
239 	FillUpWithDefTabs_Impl( nDefDist, aNewTabs );
240 	SfxItemPool* pPool = rSet.GetPool();
241 	MapUnit eUnit = (MapUnit)pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
242 	const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_TABSTOP );
243 
244     if ( MAP_100TH_MM != eUnit )
245 	{
246 		// Wenn sich im ItemSet ein LRSpaceItem mit negativen Erstzeileneinzug
247 		// befindet, muss im TabStopItem auf der Position 0 ein DefTab sein.
248 		const SfxPoolItem* pLRSpace;
249 		// wenn nicht im neuen Set, dann vielleicht im alten
250 		if ( SFX_ITEM_SET !=
251 			 rSet.GetItemState( GetWhich( SID_ATTR_LRSPACE ), sal_True, &pLRSpace ) )
252 			pLRSpace = GetOldItem( rSet, SID_ATTR_LRSPACE );
253 
254 		if ( pLRSpace && ( (SvxLRSpaceItem*)pLRSpace )->GetTxtFirstLineOfst() < 0 )
255 		{
256 			SvxTabStop aNull( 0, SVX_TAB_ADJUST_DEFAULT );
257 			aNewTabs.Insert( aNull );
258 		}
259 
260 		SvxTabStopItem aTmp( aNewTabs );
261 		aTmp.Remove( 0, aTmp.Count() );
262 
263 		for ( sal_uInt16 i = 0; i < aNewTabs.Count(); ++i )
264 		{
265 			SvxTabStop aTmpStop = aNewTabs[i];
266 			aTmpStop.GetTabPos() =
267                 LogicToLogic( aTmpStop.GetTabPos(), MAP_100TH_MM, eUnit );
268 			aTmp.Insert( aTmpStop );
269 		}
270 
271 		if ( !pOld || !( *( (SvxTabStopItem*)pOld ) == aTmp ) )
272 		{
273 			rSet.Put( aTmp );
274 			bModified = sal_True;
275 		}
276 	}
277 	else if ( !pOld || !( *( (SvxTabStopItem*)pOld ) == aNewTabs ) )
278 	{
279 		rSet.Put( aNewTabs );
280 		bModified = sal_True;
281 	}
282 	return bModified;
283 }
284 
285 // -----------------------------------------------------------------------
286 
287 SfxTabPage* SvxTabulatorTabPage::Create( Window* pParent,
288 										 const SfxItemSet& rSet)
289 {
290 	return ( new SvxTabulatorTabPage( pParent, rSet ) );
291 }
292 
293 // -----------------------------------------------------------------------
294 
295 void SvxTabulatorTabPage::Reset( const SfxItemSet& rSet )
296 {
297 	SfxItemPool* pPool = rSet.GetPool();
298 	MapUnit eUnit = (MapUnit)pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
299 
300 	// Aktuelle Tabs
301 	const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_TABSTOP );
302 
303 	if ( pItem )
304 	{
305         if ( MAP_100TH_MM != eUnit )
306 		{
307 			SvxTabStopItem aTmp( *( (const SvxTabStopItem*)pItem ) );
308 			aNewTabs.Remove( 0, aNewTabs.Count() );
309 
310 			for ( sal_uInt16 i = 0; i < aTmp.Count(); ++i )
311 			{
312 				SvxTabStop aTmpStop = aTmp[i];
313 				aTmpStop.GetTabPos() =
314                     LogicToLogic( aTmpStop.GetTabPos(), eUnit, MAP_100TH_MM );
315 				aNewTabs.Insert( aTmpStop );
316 			}
317 		}
318 		else
319 			aNewTabs = *( (const SvxTabStopItem*)pItem );
320 	}
321 	else
322 		aNewTabs.Remove( 0, aNewTabs.Count() );
323 
324 	// Default-Tab - Abstand
325 	nDefDist = SVX_TAB_DEFDIST;
326 	pItem = GetItem( rSet, SID_ATTR_TABSTOP_DEFAULTS );
327 
328 	if ( pItem )
329 		nDefDist = LogicToLogic(
330             (long)((const SfxUInt16Item*)pItem)->GetValue(), eUnit, MAP_100TH_MM );
331 
332 	// Aktuell selektierte Tab-Pos
333 	sal_uInt16 nTabPos = 0;
334 	pItem = GetItem( rSet, SID_ATTR_TABSTOP_POS );
335 
336 	if ( pItem )
337 		nTabPos = ( (const SfxUInt16Item*)pItem )->GetValue();
338 
339 	InitTabPos_Impl( nTabPos );
340 }
341 
342 // -----------------------------------------------------------------------
343 
344 void SvxTabulatorTabPage::DisableControls( const sal_uInt16 nFlag )
345 {
346 	if ( ( TABTYPE_LEFT & nFlag ) == TABTYPE_LEFT )
347 	{
348 		aLeftTab.Disable();
349 		pLeftWin->Disable();
350 	}
351 	if ( ( TABTYPE_RIGHT & nFlag ) == TABTYPE_RIGHT )
352 	{
353 		aRightTab.Disable();
354 		pRightWin->Disable();
355 	}
356 	if ( ( TABTYPE_CENTER & nFlag ) == TABTYPE_CENTER )
357 	{
358 		aCenterTab.Disable();
359 		pCenterWin->Disable();
360 	}
361 	if ( ( TABTYPE_DEZIMAL & nFlag ) == TABTYPE_DEZIMAL )
362 	{
363 		aDezTab.Disable();
364 		pDezWin->Disable();
365 		aDezCharLabel.Disable();
366 		aDezChar.Disable();
367 	}
368 	if ( ( TABTYPE_ALL & nFlag ) == TABTYPE_ALL )
369 		aTabTypeLabel.Disable();
370 	if ( ( TABFILL_NONE & nFlag ) == TABFILL_NONE )
371 		aNoFillChar.Disable();
372 	if ( ( TABFILL_POINT & nFlag ) == TABFILL_POINT )
373 		aFillPoints.Disable();
374 	if ( ( TABFILL_DASHLINE & nFlag ) == TABFILL_DASHLINE )
375 		aFillDashLine.Disable();
376 	if ( ( TABFILL_SOLIDLINE & nFlag ) == TABFILL_SOLIDLINE )
377 		aFillSolidLine.Disable();
378 	if ( ( TABFILL_SPECIAL & nFlag ) == TABFILL_SPECIAL )
379 	{
380 		aFillSpecial.Disable();
381 		aFillChar.Disable();
382 	}
383 	if ( ( TABFILL_ALL & nFlag ) == TABFILL_ALL )
384 		aFillLabel.Disable();
385 }
386 
387 // -----------------------------------------------------------------------
388 
389 int SvxTabulatorTabPage::DeactivatePage( SfxItemSet* _pSet )
390 {
391     if ( _pSet )
392         FillItemSet( *_pSet );
393 	return LEAVE_PAGE;
394 }
395 
396 // -----------------------------------------------------------------------
397 
398 void SvxTabulatorTabPage::InitTabPos_Impl( sal_uInt16 nTabPos )
399 {
400 	aTabBox.Clear();
401 
402     long nOffset = 0;
403     const SfxPoolItem* pItem = 0;
404     if ( GetItemSet().GetItemState( SID_ATTR_TABSTOP_OFFSET, sal_True, &pItem )
405             == SFX_ITEM_SET )
406     {
407         nOffset = ( (const SfxInt32Item*)pItem )->GetValue();
408         MapUnit eUnit = (MapUnit)GetItemSet().GetPool()->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
409         nOffset = OutputDevice::LogicToLogic( nOffset, eUnit, MAP_100TH_MM  );
410     }
411 
412     // Aktuelle TabPos korrigieren und Defaults-Tabs
413 	for ( sal_uInt16 i = 0; i < aNewTabs.Count(); i++ )
414 	{
415 		if ( aNewTabs[i].GetAdjustment() != SVX_TAB_ADJUST_DEFAULT )
416 		{
417             aTabBox.InsertValue( aTabBox.Normalize(
418 				aNewTabs[i].GetTabPos() + nOffset ), eDefUnit );
419 		}
420 		else
421 			aNewTabs.Remove( i-- );
422 	}
423 
424 	// aktuellen Tabulator auswaehlen
425 	const sal_uInt16 nSize = aNewTabs.Count();
426 
427 	if ( nTabPos >= nSize )
428 		nTabPos = 0;
429 
430 	// alle RadioButtons erstmal ausschalten
431 	aLeftTab.Check( sal_True );
432 	aNoFillChar.Check( sal_True );
433 
434 	if( aTabBox.GetEntryCount() > 0 )
435 	{
436 		aTabBox.SetText( aTabBox.GetEntry( nTabPos ) );
437 		aAktTab = aNewTabs[nTabPos];
438 
439 		SetFillAndTabType_Impl();
440 		aNewBtn.Disable();
441 		aDelBtn.Enable();
442 	}
443 	else
444 	{   // kein Eintrag dann ist 0 der Default-Wert
445 		aTabBox.SetValue( 0, eDefUnit );
446 
447 		aNewBtn.Enable();
448 		aDelBtn.Disable();
449 	}
450 }
451 
452 // -----------------------------------------------------------------------
453 
454 void SvxTabulatorTabPage::SetFillAndTabType_Impl()
455 {
456 	RadioButton* pTypeBtn = 0;
457 	RadioButton* pFillBtn = 0;
458 
459 	aDezChar.Disable();
460 	aDezCharLabel.Disable();
461 
462 	if ( aAktTab.GetAdjustment() == SVX_TAB_ADJUST_LEFT )
463 		pTypeBtn = &aLeftTab;
464 	else if ( aAktTab.GetAdjustment() == SVX_TAB_ADJUST_RIGHT )
465 		pTypeBtn = &aRightTab;
466 	else if ( aAktTab.GetAdjustment() == SVX_TAB_ADJUST_DECIMAL )
467 	{
468 		pTypeBtn = &aDezTab;
469 		aDezChar.Enable();
470 		aDezCharLabel.Enable();
471 		aDezChar.SetText( String( (sal_Unicode)aAktTab.GetDecimal() ) );
472 	}
473 	else if ( aAktTab.GetAdjustment() == SVX_TAB_ADJUST_CENTER )
474 		pTypeBtn = &aCenterTab;
475 
476 	if ( pTypeBtn )
477 		pTypeBtn->Check();
478 
479 	aFillChar.Disable();
480 	aFillChar.SetText( String() );
481 
482 	if ( aAktTab.GetFill() == ' ' )
483 		pFillBtn = &aNoFillChar;
484 	else if ( aAktTab.GetFill() == '-' )
485 		pFillBtn = &aFillDashLine;
486 	else if ( aAktTab.GetFill() == '_' )
487 		pFillBtn = &aFillSolidLine;
488 	else if ( aAktTab.GetFill() == '.' )
489 		pFillBtn = &aFillPoints;
490 	else
491 	{
492 		pFillBtn = &aFillSpecial;
493 		aFillChar.Enable();
494 		aFillChar.SetText( String( (sal_Unicode)aAktTab.GetFill() ) );
495 	}
496 	pFillBtn->Check();
497 }
498 
499 // -----------------------------------------------------------------------
500 
501 IMPL_LINK( SvxTabulatorTabPage, NewHdl_Impl, Button *, pBtn )
502 {
503 	// Einen neuen Hinzufuegen und Selectieren
504 	// Wert aus der Anzeige holen
505 	long nVal = static_cast<long>(aTabBox.Denormalize( aTabBox.GetValue( eDefUnit ) ));
506 
507 	// Wenn der pBtn == 0 && der Value == 0 dann keinen Tab Erzeugen
508 	// weil ueber OK erzeugt
509 	if ( nVal == 0 && pBtn == 0 )
510 		return 0;
511 
512 	long nOffset = 0;
513 	const SfxPoolItem* pItem = 0;
514 
515 	if ( GetItemSet().GetItemState( SID_ATTR_TABSTOP_OFFSET, sal_True, &pItem ) ==
516 		 SFX_ITEM_SET )
517 	{
518 		nOffset = ( (const SfxInt32Item*)pItem )->GetValue();
519         MapUnit eUnit = (MapUnit)GetItemSet().GetPool()->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
520         nOffset = OutputDevice::LogicToLogic( nOffset, eUnit, MAP_100TH_MM  );
521 	}
522 	const long nReal = nVal - nOffset;
523 	sal_uInt16 nSize = aTabBox.GetEntryCount();
524 
525 	sal_uInt16 i;
526 	for( i = 0; i < nSize; i++ )
527 	{
528 		if ( nReal < aNewTabs[i].GetTabPos() )
529 			break;
530 	}
531 
532 	// ListBox-Eintrag vornehmen
533 	aTabBox.InsertValue( aTabBox.Normalize( nVal ), eDefUnit, i );
534 	aAktTab.GetTabPos() = nReal;
535 	SvxTabAdjust eAdj = SVX_TAB_ADJUST_LEFT;
536 
537 	if ( aRightTab.IsChecked() )
538 		eAdj = SVX_TAB_ADJUST_RIGHT;
539 	else if ( aCenterTab.IsChecked() )
540 		eAdj = SVX_TAB_ADJUST_CENTER;
541 	else if ( aDezTab.IsChecked() )
542 		eAdj = SVX_TAB_ADJUST_DECIMAL;
543 
544 	aAktTab.GetAdjustment() = eAdj;
545 	aNewTabs.Insert( aAktTab );
546 
547 	aNewBtn.Disable();
548 	aDelBtn.Enable();
549 	aTabBox.GrabFocus();
550 
551 	// falls kein RadioButton geclickt wurde,
552 	// muss trotzdem geputtet werden
553 	bCheck |= sal_True;
554     // set the selection into the position Edit
555     aTabBox.SetSelection(Selection(0, aTabBox.GetText().Len()));
556 	return 0;
557 }
558 
559 // -----------------------------------------------------------------------
560 
561 IMPL_LINK( SvxTabulatorTabPage, DelHdl_Impl, Button *, EMPTYARG )
562 {
563 	sal_uInt16 nPos = aTabBox.GetValuePos( aTabBox.GetValue() );
564 
565 	if ( nPos == COMBOBOX_ENTRY_NOTFOUND )
566 		return 0;
567 
568 	if ( aTabBox.GetEntryCount() == 1 )
569 	{
570 		DelAllHdl_Impl( 0 );
571 		return 0;
572 	}
573 
574 	// Tab loeschen
575 	aTabBox.RemoveEntry( nPos );
576 	aNewTabs.Remove( nPos );
577 
578 	// aAktTab neu setzen
579 	const sal_uInt16 nSize = aNewTabs.Count();
580 
581 	if ( nSize > 0 )
582 	{
583 		// Pos korrigieren
584 		nPos = ( ( nSize - 1 ) >= nPos) ? nPos : nPos - 1;
585 		aTabBox.SetValue( aTabBox.GetValue( nPos ) );
586 		aAktTab = aNewTabs[nPos];
587 	}
588 
589 	// Falls keine Tabs Enable Disable Controls
590 	if ( aTabBox.GetEntryCount() == 0 )
591 	{
592 		aDelBtn.Disable();
593 		aNewBtn.Enable();
594 		aTabBox.GrabFocus();
595 	}
596 
597 	// falls kein RadioButton geclickt wurde,
598 	// muss trotzdem geputtet werden
599 	bCheck |= sal_True;
600 	return 0;
601 }
602 
603 // -----------------------------------------------------------------------
604 
605 IMPL_LINK( SvxTabulatorTabPage, DelAllHdl_Impl, Button *, EMPTYARG )
606 {
607 	if ( aNewTabs.Count() )
608 	{
609 		aNewTabs = SvxTabStopItem( 0 );
610 		InitTabPos_Impl();
611 
612 		// damit in FillItemSet() geputtet wird
613 		bCheck |= sal_True;
614 	}
615 	return 0;
616 }
617 
618 // -----------------------------------------------------------------------
619 
620 IMPL_LINK( SvxTabulatorTabPage, TabTypeCheckHdl_Impl, RadioButton *, pBox )
621 {
622 	bCheck |= sal_True;
623 	SvxTabAdjust eAdj;
624 	aDezChar.Disable();
625 	aDezCharLabel.Disable();
626 	aDezChar.SetText( String() );
627 
628 	if ( pBox == &aLeftTab )
629 		eAdj = SVX_TAB_ADJUST_LEFT;
630 	else if ( pBox == &aRightTab )
631 		eAdj = SVX_TAB_ADJUST_RIGHT;
632 	else if ( pBox == &aCenterTab )
633 		eAdj = SVX_TAB_ADJUST_CENTER;
634 	else
635 	{
636 		eAdj = SVX_TAB_ADJUST_DECIMAL;
637 		aDezChar.Enable();
638 		aDezCharLabel.Enable();
639 		aDezChar.SetText( String( (sal_Unicode)aAktTab.GetDecimal() ) );
640 	}
641 
642 	aAktTab.GetAdjustment() = eAdj;
643 	sal_uInt16 nPos = aTabBox.GetValuePos( aTabBox.GetValue( eDefUnit ), eDefUnit );
644 
645 	if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
646 	{
647 		aNewTabs.Remove( nPos );
648 		aNewTabs.Insert( aAktTab );
649 	}
650 	return 0;
651 }
652 
653 // -----------------------------------------------------------------------
654 
655 IMPL_LINK( SvxTabulatorTabPage, FillTypeCheckHdl_Impl, RadioButton *, pBox )
656 {
657 	bCheck |= sal_True;
658 	sal_uInt8 cFill = ' ';
659 	aFillChar.SetText( String() );
660 	aFillChar.Disable();
661 
662 	if( pBox == &aFillSpecial )
663 		aFillChar.Enable();
664 	else if ( pBox == &aNoFillChar )
665 		cFill = ' ';
666 	else if ( pBox == &aFillSolidLine )
667 		cFill = '_';
668 	else if ( pBox == &aFillPoints )
669 		cFill = '.';
670 	else if ( pBox == &aFillDashLine )
671 		cFill = '-';
672 
673 	aAktTab.GetFill() = cFill;
674 	sal_uInt16 nPos = aTabBox.GetValuePos( aTabBox.GetValue( eDefUnit ), eDefUnit );
675 
676 	if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
677 	{
678 		aNewTabs.Remove( nPos );
679 		aNewTabs.Insert( aAktTab );
680 	}
681 	return 0;
682 }
683 
684 // -----------------------------------------------------------------------
685 
686 IMPL_LINK( SvxTabulatorTabPage, GetFillCharHdl_Impl, Edit *, pEdit )
687 {
688 	String aChar( pEdit->GetText() );
689 
690 	if ( aChar.Len() > 0 )
691 		aAktTab.GetFill() = aChar.GetChar( 0 );
692 
693 	const sal_uInt16 nPos = aTabBox.GetValuePos( aTabBox.GetValue( eDefUnit ), eDefUnit);
694 	if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
695 	{
696 		aNewTabs.Remove( nPos );
697 		aNewTabs.Insert( aAktTab );
698 	}
699 	return 0;
700 }
701 
702 // -----------------------------------------------------------------------
703 
704 IMPL_LINK( SvxTabulatorTabPage, GetDezCharHdl_Impl, Edit *, pEdit )
705 {
706 	String aChar( pEdit->GetText() );
707     if ( aChar.Len() > 0 && ( aChar.GetChar( 0 ) >= ' '))
708 		aAktTab.GetDecimal() = aChar.GetChar( 0 );
709 
710 	sal_uInt16 nPos = aTabBox.GetValuePos( aTabBox.GetValue( eDefUnit ), eDefUnit );
711 	if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
712 	{
713 		aNewTabs.Remove( nPos );
714 		aNewTabs.Insert( aAktTab );
715 	}
716 	return 0;
717 }
718 
719 // -----------------------------------------------------------------------
720 
721 IMPL_LINK( SvxTabulatorTabPage, SelectHdl_Impl, MetricBox *, EMPTYARG )
722 {
723 	sal_uInt16 nPos = aTabBox.GetValuePos( aTabBox.GetValue( eDefUnit ), eDefUnit );
724 	if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
725 	{
726 		aAktTab = aNewTabs[nPos];
727 		aNewBtn.Disable();
728 		SetFillAndTabType_Impl();
729 	}
730 	return 0;
731 }
732 
733 // -----------------------------------------------------------------------
734 
735 IMPL_LINK( SvxTabulatorTabPage, ModifyHdl_Impl, MetricBox *, EMPTYARG )
736 {
737 	sal_uInt16 nPos = aTabBox.GetValuePos( aTabBox.GetValue( eDefUnit ), eDefUnit );
738 	if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
739 	{
740 		aAktTab = aNewTabs[nPos];
741 		SetFillAndTabType_Impl();
742 
743 		aAktTab.GetTabPos() =
744 			static_cast<long>(aTabBox.Denormalize( aTabBox.GetValue( eDefUnit ) ));
745 
746 		aNewBtn.Disable();
747 		aDelBtn.Enable();
748 		return 0;
749 	}
750 	aNewBtn.Enable();
751 	aDelBtn.Disable();
752 	return 0;
753 }
754 //add CHINA001 Begin
755 void		SvxTabulatorTabPage::PageCreated(SfxAllItemSet aSet)
756 {
757 	SFX_ITEMSET_ARG	(&aSet,pControlItem,SfxUInt16Item,SID_SVXTABULATORTABPAGE_CONTROLFLAGS,sal_False);
758 	if (pControlItem)
759 		DisableControls(pControlItem->GetValue());
760 }
761 //end of CHINA001
762