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