Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <sfx2/app.hxx>
21 : #include <tools/shl.hxx>
22 : #include <svtools/ruler.hxx>
23 : #include <svx/dialogs.hrc>
24 :
25 : #include <cuires.hrc>
26 : #include <editeng/lrspitem.hxx>
27 : #include "tabstpge.hxx"
28 : #include <dialmgr.hxx>
29 : #include "svx/dlgutil.hxx"
30 : #include <sfx2/module.hxx>
31 : #include <svl/cjkoptions.hxx>
32 : #include <unotools/localedatawrapper.hxx>
33 : #include <comphelper/processfactory.hxx>
34 : #include <sfx2/request.hxx>
35 : #include <svl/intitem.hxx>
36 :
37 : // class TabWin_Impl -----------------------------------------------------
38 :
39 0 : class TabWin_Impl : public Window
40 : {
41 : SvxTabulatorTabPage* mpPage;
42 : private:
43 : sal_uInt16 nTabStyle;
44 :
45 : public:
46 :
47 0 : TabWin_Impl( Window* pParent, WinBits nBits) :
48 0 : Window( pParent, nBits )
49 : {
50 0 : }
51 :
52 : virtual void Paint( const Rectangle& rRect );
53 :
54 0 : void SetTabulatorTabPage(SvxTabulatorTabPage* pPage) { mpPage = pPage; }
55 0 : void SetTabStyle(sal_uInt16 nStyle) {nTabStyle = nStyle; }
56 : };
57 :
58 0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeTabWin_Impl(Window *pParent, VclBuilder::stringmap &)
59 : {
60 0 : return new TabWin_Impl(pParent, 0);
61 : }
62 : // static ----------------------------------------------------------------
63 :
64 : static sal_uInt16 pRanges[] =
65 : {
66 : SID_ATTR_TABSTOP,
67 : SID_ATTR_TABSTOP_OFFSET,
68 : 0
69 : };
70 :
71 : // C function ------------------------------------------------------------
72 :
73 0 : void FillUpWithDefTabs_Impl( long nDefDist, SvxTabStopItem& rTabs )
74 : {
75 0 : if( rTabs.Count() )
76 0 : return;
77 : {
78 0 : SvxTabStop aSwTabStop( nDefDist, SVX_TAB_ADJUST_DEFAULT );
79 0 : rTabs.Insert( aSwTabStop );
80 : }
81 : }
82 :
83 : // class TabWin_Impl -----------------------------------------------------
84 :
85 0 : void TabWin_Impl::Paint( const Rectangle& )
86 : {
87 : // Paint tabulators
88 0 : Point aPnt;
89 0 : Size aSize = GetOutputSizePixel();
90 0 : aPnt.X() = aSize.Width() / 2;
91 0 : aPnt.Y() = aSize.Height() / 2;
92 0 : Ruler::DrawTab( this, GetSettings().GetStyleSettings().GetFontColor(), aPnt, nTabStyle );
93 0 : }
94 :
95 : // class SvxTabulatorTabPage ---------------------------------------------
96 :
97 0 : SvxTabulatorTabPage::SvxTabulatorTabPage( Window* pParent, const SfxItemSet& rAttr ):
98 :
99 : SfxTabPage( pParent, "ParagraphTabsPage","cui/ui/paratabspage.ui", rAttr ),
100 :
101 : aAktTab ( 0 ),
102 0 : aNewTabs ( 0, 0, SVX_TAB_ADJUST_LEFT, GetWhich( SID_ATTR_TABSTOP ) ),
103 : nDefDist ( 0 ),
104 : eDefUnit ( FUNIT_100TH_MM ),
105 0 : bCheck ( sal_False )
106 :
107 : {
108 0 : get(m_pTabBox,"ED_TABPOS");
109 : //the tab images
110 0 : get(m_pLeftWin,"drawingareaWIN_TABLEFT");
111 0 : get(m_pRightWin,"drawingareaWIN_TABRIGHT");
112 0 : get(m_pCenterWin,"drawingareaWIN_TABCENTER");
113 0 : get(m_pDezWin,"drawingareaWIN_TABDECIMAL");
114 0 : m_pLeftWin->SetTabulatorTabPage(this);
115 0 : m_pRightWin->SetTabulatorTabPage(this);
116 0 : m_pCenterWin->SetTabulatorTabPage(this);
117 0 : m_pDezWin->SetTabulatorTabPage(this);
118 0 : m_pLeftWin->SetTabStyle((sal_uInt16)(RULER_TAB_LEFT|WB_HORZ));
119 0 : m_pRightWin->SetTabStyle((sal_uInt16)(RULER_TAB_RIGHT|WB_HORZ));
120 0 : m_pCenterWin->SetTabStyle((sal_uInt16)(RULER_TAB_CENTER|WB_HORZ));
121 0 : m_pDezWin->SetTabStyle((sal_uInt16)(RULER_TAB_DECIMAL|WB_HORZ));
122 : //upper radiobuttons
123 0 : SvtCJKOptions aCJKOptions;
124 0 : get(m_pLeftTab, aCJKOptions.IsAsianTypographyEnabled() ? "radiobuttonST_LEFTTAB_ASIAN" : "radiobuttonBTN_TABTYPE_LEFT");
125 0 : get(m_pRightTab, aCJKOptions.IsAsianTypographyEnabled() ? "radiobuttonST_RIGHTTAB_ASIAN" : "radiobuttonBTN_TABTYPE_RIGHT");
126 0 : m_pLeftTab->Show(true);
127 0 : m_pRightTab->Show(true);
128 0 : get(m_pCenterTab,"radiobuttonBTN_TABTYPE_CENTER");
129 0 : get(m_pDezTab,"radiobuttonBTN_TABTYPE_DECIMAL");
130 0 : get(m_pDezChar,"entryED_TABTYPE_DECCHAR");
131 0 : get(m_pDezCharLabel,"labelFT_TABTYPE_DECCHAR");
132 : //lower radio buttons
133 0 : get(m_pNoFillChar,"radiobuttonBTN_FILLCHAR_NO");
134 0 : get(m_pFillPoints,"radiobuttonBTN_FILLCHAR_POINTS");
135 0 : get(m_pFillDashLine,"radiobuttonBTN_FILLCHAR_DASHLINE");
136 0 : get(m_pFillSolidLine,"radiobuttonBTN_FILLCHAR_UNDERSCORE");
137 0 : get(m_pFillSpecial,"radiobuttonBTN_FILLCHAR_OTHER");
138 0 : get(m_pFillChar,"entryED_FILLCHAR_OTHER");
139 : //button bar
140 0 : get(m_pNewBtn,"buttonBTN_NEW");
141 0 : get(m_pDelAllBtn,"buttonBTN_DELALL");
142 0 : get(m_pDelBtn,"buttonBTN_DEL");
143 :
144 0 : get(m_pTypeFrame, "frameFL_TABTYPE");
145 0 : get(m_pFillFrame, "frameFL_FILLCHAR");
146 :
147 : // This page needs ExchangeSupport
148 0 : SetExchangeSupport();
149 :
150 : // Set metric
151 0 : FieldUnit eFUnit = GetModuleFieldUnit( rAttr );
152 0 : SetFieldUnit( *m_pTabBox, eFUnit );
153 :
154 : // Initialize buttons
155 0 : m_pNewBtn->SetClickHdl( LINK( this,SvxTabulatorTabPage, NewHdl_Impl ) );
156 0 : m_pDelBtn->SetClickHdl( LINK( this,SvxTabulatorTabPage, DelHdl_Impl ) );
157 0 : m_pDelAllBtn->SetClickHdl( LINK( this,SvxTabulatorTabPage, DelAllHdl_Impl ) );
158 :
159 0 : Link aLink = LINK( this, SvxTabulatorTabPage, TabTypeCheckHdl_Impl );
160 0 : m_pLeftTab->SetClickHdl( aLink );
161 0 : m_pRightTab->SetClickHdl( aLink );
162 0 : m_pDezTab->SetClickHdl( aLink );
163 0 : m_pCenterTab->SetClickHdl( aLink );
164 :
165 0 : m_pDezChar->SetLoseFocusHdl( LINK( this, SvxTabulatorTabPage, GetDezCharHdl_Impl ) );
166 0 : m_pDezChar->Disable();
167 0 : m_pDezCharLabel->Disable();
168 :
169 0 : aLink = LINK( this, SvxTabulatorTabPage, FillTypeCheckHdl_Impl );
170 0 : m_pNoFillChar->SetClickHdl( aLink );
171 0 : m_pFillPoints->SetClickHdl( aLink );
172 0 : m_pFillDashLine->SetClickHdl( aLink );
173 0 : m_pFillSolidLine->SetClickHdl( aLink );
174 0 : m_pFillSpecial->SetClickHdl( aLink );
175 0 : m_pFillChar->SetLoseFocusHdl( LINK( this, SvxTabulatorTabPage, GetFillCharHdl_Impl ) );
176 0 : m_pFillChar->Disable();
177 :
178 0 : m_pTabBox->SetDoubleClickHdl( LINK( this, SvxTabulatorTabPage, SelectHdl_Impl ) );
179 0 : m_pTabBox->SetModifyHdl( LINK( this, SvxTabulatorTabPage, ModifyHdl_Impl ) );
180 :
181 : // Get the default decimal char from the system
182 0 : const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
183 0 : aAktTab.GetDecimal() = rLocaleWrapper.getNumDecimalSep()[0];
184 0 : }
185 :
186 : // -----------------------------------------------------------------------
187 :
188 0 : SvxTabulatorTabPage::~SvxTabulatorTabPage()
189 : {
190 0 : }
191 :
192 : // -----------------------------------------------------------------------
193 :
194 0 : sal_uInt16* SvxTabulatorTabPage::GetRanges()
195 : {
196 0 : return pRanges;
197 : }
198 :
199 : // -----------------------------------------------------------------------
200 :
201 0 : sal_Bool SvxTabulatorTabPage::FillItemSet( SfxItemSet& rSet )
202 : {
203 0 : sal_Bool bModified = sal_False;
204 :
205 : // Put the controls' values in here
206 0 : if ( m_pNewBtn->IsEnabled() )
207 0 : NewHdl_Impl( 0 );
208 :
209 : // Call the LoseFocus-Handler first
210 0 : GetDezCharHdl_Impl( m_pDezChar );
211 0 : GetFillCharHdl_Impl( m_pFillChar );
212 :
213 0 : FillUpWithDefTabs_Impl( nDefDist, aNewTabs );
214 0 : SfxItemPool* pPool = rSet.GetPool();
215 0 : MapUnit eUnit = (MapUnit)pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
216 0 : const SfxPoolItem* pOld = GetOldItem( rSet, SID_ATTR_TABSTOP );
217 :
218 0 : if ( MAP_100TH_MM != eUnit )
219 : {
220 : // If the ItemSet contains a LRSpaceItem with negative first line indent,
221 : // the TabStopItem needs to have a DefTab at position 0.
222 : const SfxPoolItem* pLRSpace;
223 : // If not in the new set, then maybe in the old one
224 0 : if ( SFX_ITEM_SET != rSet.GetItemState( GetWhich( SID_ATTR_LRSPACE ), sal_True, &pLRSpace ) )
225 0 : pLRSpace = GetOldItem( rSet, SID_ATTR_LRSPACE );
226 :
227 0 : if ( pLRSpace && ( (SvxLRSpaceItem*)pLRSpace )->GetTxtFirstLineOfst() < 0 )
228 : {
229 0 : SvxTabStop aNull( 0, SVX_TAB_ADJUST_DEFAULT );
230 0 : aNewTabs.Insert( aNull );
231 : }
232 :
233 0 : SvxTabStopItem aTmp( aNewTabs );
234 0 : aTmp.Remove( 0, aTmp.Count() );
235 :
236 0 : for ( sal_uInt16 i = 0; i < aNewTabs.Count(); ++i )
237 : {
238 0 : SvxTabStop aTmpStop = aNewTabs[i];
239 0 : aTmpStop.GetTabPos() =
240 0 : LogicToLogic( aTmpStop.GetTabPos(), MAP_100TH_MM, eUnit );
241 0 : aTmp.Insert( aTmpStop );
242 : }
243 :
244 0 : if ( !pOld || !( *( (SvxTabStopItem*)pOld ) == aTmp ) )
245 : {
246 0 : rSet.Put( aTmp );
247 0 : bModified = sal_True;
248 0 : }
249 : }
250 0 : else if ( !pOld || !( *( (SvxTabStopItem*)pOld ) == aNewTabs ) )
251 : {
252 0 : rSet.Put( aNewTabs );
253 0 : bModified = sal_True;
254 : }
255 0 : return bModified;
256 : }
257 :
258 : // -----------------------------------------------------------------------
259 :
260 0 : SfxTabPage* SvxTabulatorTabPage::Create( Window* pParent,
261 : const SfxItemSet& rSet)
262 : {
263 0 : return ( new SvxTabulatorTabPage( pParent, rSet ) );
264 : }
265 :
266 : // -----------------------------------------------------------------------
267 :
268 0 : void SvxTabulatorTabPage::Reset( const SfxItemSet& rSet )
269 : {
270 0 : SfxItemPool* pPool = rSet.GetPool();
271 0 : MapUnit eUnit = (MapUnit)pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
272 :
273 : // Current tabs
274 0 : const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_TABSTOP );
275 :
276 0 : if ( pItem )
277 : {
278 0 : if ( MAP_100TH_MM != eUnit )
279 : {
280 0 : SvxTabStopItem aTmp( *( (const SvxTabStopItem*)pItem ) );
281 0 : aNewTabs.Remove( 0, aNewTabs.Count() );
282 :
283 0 : for ( sal_uInt16 i = 0; i < aTmp.Count(); ++i )
284 : {
285 0 : SvxTabStop aTmpStop = aTmp[i];
286 0 : aTmpStop.GetTabPos() = LogicToLogic( aTmpStop.GetTabPos(), eUnit, MAP_100TH_MM );
287 0 : aNewTabs.Insert( aTmpStop );
288 0 : }
289 : }
290 : else
291 0 : aNewTabs = *( (const SvxTabStopItem*)pItem );
292 : }
293 : else
294 0 : aNewTabs.Remove( 0, aNewTabs.Count() );
295 :
296 : // Defaul tab distance
297 0 : nDefDist = SVX_TAB_DEFDIST;
298 0 : pItem = GetItem( rSet, SID_ATTR_TABSTOP_DEFAULTS );
299 :
300 0 : if ( pItem )
301 : nDefDist = LogicToLogic(
302 0 : (long)((const SfxUInt16Item*)pItem)->GetValue(), eUnit, MAP_100TH_MM );
303 :
304 : // Tab pos currently selected
305 0 : sal_uInt16 nTabPos = 0;
306 0 : pItem = GetItem( rSet, SID_ATTR_TABSTOP_POS );
307 :
308 0 : if ( pItem )
309 0 : nTabPos = ( (const SfxUInt16Item*)pItem )->GetValue();
310 :
311 0 : InitTabPos_Impl( nTabPos );
312 0 : }
313 :
314 : // -----------------------------------------------------------------------
315 :
316 0 : void SvxTabulatorTabPage::DisableControls( const sal_uInt16 nFlag )
317 : {
318 0 : if ( ( TABTYPE_LEFT & nFlag ) == TABTYPE_LEFT )
319 : {
320 0 : m_pLeftTab->Disable();
321 0 : m_pLeftWin->Disable();
322 : }
323 0 : if ( ( TABTYPE_RIGHT & nFlag ) == TABTYPE_RIGHT )
324 : {
325 0 : m_pRightTab->Disable();
326 0 : m_pRightWin->Disable();
327 : }
328 0 : if ( ( TABTYPE_CENTER & nFlag ) == TABTYPE_CENTER )
329 : {
330 0 : m_pCenterTab->Disable();
331 0 : m_pCenterWin->Disable();
332 : }
333 0 : if ( ( TABTYPE_DEZIMAL & nFlag ) == TABTYPE_DEZIMAL )
334 : {
335 0 : m_pDezTab->Disable();
336 0 : m_pDezWin->Disable();
337 0 : m_pDezCharLabel->Disable();
338 0 : m_pDezChar->Disable();
339 : }
340 0 : if ( ( TABTYPE_ALL & nFlag ) == TABTYPE_ALL )
341 0 : m_pTypeFrame->Disable();
342 0 : if ( ( TABFILL_NONE & nFlag ) == TABFILL_NONE )
343 0 : m_pNoFillChar->Disable();
344 0 : if ( ( TABFILL_POINT & nFlag ) == TABFILL_POINT )
345 0 : m_pFillPoints->Disable();
346 0 : if ( ( TABFILL_DASHLINE & nFlag ) == TABFILL_DASHLINE )
347 0 : m_pFillDashLine->Disable();
348 0 : if ( ( TABFILL_SOLIDLINE & nFlag ) == TABFILL_SOLIDLINE )
349 0 : m_pFillSolidLine->Disable();
350 0 : if ( ( TABFILL_SPECIAL & nFlag ) == TABFILL_SPECIAL )
351 : {
352 0 : m_pFillSpecial->Disable();
353 0 : m_pFillChar->Disable();
354 : }
355 0 : if ( ( TABFILL_ALL & nFlag ) == TABFILL_ALL )
356 0 : m_pFillFrame->Disable();
357 0 : }
358 :
359 : // -----------------------------------------------------------------------
360 :
361 0 : int SvxTabulatorTabPage::DeactivatePage( SfxItemSet* _pSet )
362 : {
363 0 : if ( _pSet )
364 0 : FillItemSet( *_pSet );
365 0 : return LEAVE_PAGE;
366 : }
367 :
368 : // -----------------------------------------------------------------------
369 :
370 0 : void SvxTabulatorTabPage::InitTabPos_Impl( sal_uInt16 nTabPos )
371 : {
372 0 : m_pTabBox->Clear();
373 :
374 0 : long nOffset = 0;
375 0 : const SfxPoolItem* pItem = 0;
376 0 : if ( GetItemSet().GetItemState( SID_ATTR_TABSTOP_OFFSET, sal_True, &pItem )
377 : == SFX_ITEM_SET )
378 : {
379 0 : nOffset = ( (const SfxInt32Item*)pItem )->GetValue();
380 0 : MapUnit eUnit = (MapUnit)GetItemSet().GetPool()->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
381 0 : nOffset = OutputDevice::LogicToLogic( nOffset, eUnit, MAP_100TH_MM );
382 : }
383 :
384 : // Correct current TabPos and default tabs
385 0 : for ( sal_uInt16 i = 0; i < aNewTabs.Count(); i++ )
386 : {
387 0 : if ( aNewTabs[i].GetAdjustment() != SVX_TAB_ADJUST_DEFAULT )
388 : {
389 : m_pTabBox->InsertValue( m_pTabBox->Normalize(
390 0 : aNewTabs[i].GetTabPos() + nOffset ), eDefUnit );
391 : }
392 : else
393 0 : aNewTabs.Remove( i-- );
394 : }
395 :
396 : // Select current tabulator
397 0 : const sal_uInt16 nSize = aNewTabs.Count();
398 :
399 0 : if ( nTabPos >= nSize )
400 0 : nTabPos = 0;
401 :
402 : // Switch off all RadioButtons for a start
403 0 : m_pLeftTab->Check( sal_True );
404 0 : m_pNoFillChar->Check( sal_True );
405 :
406 0 : if( m_pTabBox->GetEntryCount() > 0 )
407 : {
408 0 : m_pTabBox->SetText( m_pTabBox->GetEntry( nTabPos ) );
409 0 : aAktTab = aNewTabs[nTabPos];
410 :
411 0 : SetFillAndTabType_Impl();
412 0 : m_pNewBtn->Disable();
413 0 : m_pDelBtn->Enable();
414 : }
415 : else
416 : { // If no entry, 0 is the default value
417 0 : m_pTabBox->SetValue( 0, eDefUnit );
418 :
419 0 : m_pNewBtn->Enable();
420 0 : m_pDelBtn->Disable();
421 : }
422 0 : }
423 :
424 : // -----------------------------------------------------------------------
425 :
426 0 : void SvxTabulatorTabPage::SetFillAndTabType_Impl()
427 : {
428 0 : RadioButton* pTypeBtn = 0;
429 0 : RadioButton* pFillBtn = 0;
430 :
431 0 : m_pDezChar->Disable();
432 0 : m_pDezCharLabel->Disable();
433 :
434 0 : if ( aAktTab.GetAdjustment() == SVX_TAB_ADJUST_LEFT )
435 0 : pTypeBtn = m_pLeftTab;
436 0 : else if ( aAktTab.GetAdjustment() == SVX_TAB_ADJUST_RIGHT )
437 0 : pTypeBtn = m_pRightTab;
438 0 : else if ( aAktTab.GetAdjustment() == SVX_TAB_ADJUST_DECIMAL )
439 : {
440 0 : pTypeBtn = m_pDezTab;
441 0 : m_pDezChar->Enable();
442 0 : m_pDezCharLabel->Enable();
443 0 : m_pDezChar->SetText( OUString( (sal_Unicode)aAktTab.GetDecimal() ) );
444 : }
445 0 : else if ( aAktTab.GetAdjustment() == SVX_TAB_ADJUST_CENTER )
446 0 : pTypeBtn = m_pCenterTab;
447 :
448 0 : if ( pTypeBtn )
449 0 : pTypeBtn->Check();
450 :
451 0 : m_pFillChar->Disable();
452 0 : m_pFillChar->SetText( "" );
453 :
454 0 : if ( aAktTab.GetFill() == ' ' )
455 0 : pFillBtn = m_pNoFillChar;
456 0 : else if ( aAktTab.GetFill() == '-' )
457 0 : pFillBtn = m_pFillDashLine;
458 0 : else if ( aAktTab.GetFill() == '_' )
459 0 : pFillBtn = m_pFillSolidLine;
460 0 : else if ( aAktTab.GetFill() == '.' )
461 0 : pFillBtn = m_pFillPoints;
462 : else
463 : {
464 0 : pFillBtn = m_pFillSpecial;
465 0 : m_pFillChar->Enable();
466 0 : m_pFillChar->SetText( OUString( (sal_Unicode)aAktTab.GetFill() ) );
467 : }
468 0 : pFillBtn->Check();
469 0 : }
470 :
471 : // -----------------------------------------------------------------------
472 :
473 0 : IMPL_LINK( SvxTabulatorTabPage, NewHdl_Impl, Button *, pBtn )
474 : {
475 : // Add a new one and select it
476 : // Get the value from the display
477 0 : long nVal = static_cast<long>(m_pTabBox->Denormalize( m_pTabBox->GetValue( eDefUnit ) ));
478 :
479 : // If the pBtn == 0 && the value == 0 then do not create a tab, because we create via OK
480 0 : if ( nVal == 0 && pBtn == 0 )
481 0 : return 0;
482 :
483 0 : long nOffset = 0;
484 0 : const SfxPoolItem* pItem = 0;
485 :
486 0 : if ( GetItemSet().GetItemState( SID_ATTR_TABSTOP_OFFSET, sal_True, &pItem ) ==
487 : SFX_ITEM_SET )
488 : {
489 0 : nOffset = ( (const SfxInt32Item*)pItem )->GetValue();
490 0 : MapUnit eUnit = (MapUnit)GetItemSet().GetPool()->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
491 0 : nOffset = OutputDevice::LogicToLogic( nOffset, eUnit, MAP_100TH_MM );
492 : }
493 0 : const long nReal = nVal - nOffset;
494 0 : sal_uInt16 nSize = m_pTabBox->GetEntryCount();
495 :
496 : sal_uInt16 i;
497 0 : for( i = 0; i < nSize; i++ )
498 : {
499 0 : if ( nReal < aNewTabs[i].GetTabPos() )
500 0 : break;
501 : }
502 :
503 : // Make ListBox entry
504 0 : m_pTabBox->InsertValue( m_pTabBox->Normalize( nVal ), eDefUnit, i );
505 0 : aAktTab.GetTabPos() = nReal;
506 0 : SvxTabAdjust eAdj = SVX_TAB_ADJUST_LEFT;
507 :
508 0 : if ( m_pRightTab->IsChecked() )
509 0 : eAdj = SVX_TAB_ADJUST_RIGHT;
510 0 : else if ( m_pCenterTab->IsChecked() )
511 0 : eAdj = SVX_TAB_ADJUST_CENTER;
512 0 : else if ( m_pDezTab->IsChecked() )
513 0 : eAdj = SVX_TAB_ADJUST_DECIMAL;
514 :
515 0 : aAktTab.GetAdjustment() = eAdj;
516 0 : aNewTabs.Insert( aAktTab );
517 :
518 0 : m_pNewBtn->Disable();
519 0 : m_pDelBtn->Enable();
520 0 : m_pTabBox->GrabFocus();
521 :
522 : // If no RadioButton was clicked, we need to put anyway
523 0 : bCheck |= sal_True;
524 : // Set the selection into the position Edit
525 0 : m_pTabBox->SetSelection(Selection(0, m_pTabBox->GetText().getLength()));
526 0 : return 0;
527 : }
528 :
529 : // -----------------------------------------------------------------------
530 :
531 0 : IMPL_LINK_NOARG(SvxTabulatorTabPage, DelHdl_Impl)
532 : {
533 0 : sal_uInt16 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue() );
534 :
535 0 : if ( nPos == COMBOBOX_ENTRY_NOTFOUND )
536 0 : return 0;
537 :
538 0 : if ( m_pTabBox->GetEntryCount() == 1 )
539 : {
540 0 : DelAllHdl_Impl( 0 );
541 0 : return 0;
542 : }
543 :
544 : // Delete Tab
545 0 : m_pTabBox->RemoveEntry( nPos );
546 0 : aNewTabs.Remove( nPos );
547 :
548 : // Reset aAktTab
549 0 : const sal_uInt16 nSize = aNewTabs.Count();
550 :
551 0 : if ( nSize > 0 )
552 : {
553 : // Correct Pos
554 0 : nPos = ( ( nSize - 1 ) >= nPos) ? nPos : nPos - 1;
555 0 : m_pTabBox->SetValue( m_pTabBox->GetValue( nPos ) );
556 0 : aAktTab = aNewTabs[nPos];
557 : }
558 :
559 : // If no Tabs Enable Disable Controls
560 0 : if ( m_pTabBox->GetEntryCount() == 0 )
561 : {
562 0 : m_pDelBtn->Disable();
563 0 : m_pNewBtn->Enable();
564 0 : m_pTabBox->GrabFocus();
565 : }
566 :
567 : // If no RadioButton was clicked, we need to put anyway
568 0 : bCheck |= sal_True;
569 0 : return 0;
570 : }
571 :
572 : // -----------------------------------------------------------------------
573 :
574 0 : IMPL_LINK_NOARG(SvxTabulatorTabPage, DelAllHdl_Impl)
575 : {
576 0 : if ( aNewTabs.Count() )
577 : {
578 0 : aNewTabs = SvxTabStopItem( 0 );
579 0 : InitTabPos_Impl();
580 :
581 : // So that we put in FillItemSet()
582 0 : bCheck |= sal_True;
583 : }
584 0 : return 0;
585 : }
586 :
587 : // -----------------------------------------------------------------------
588 :
589 0 : IMPL_LINK( SvxTabulatorTabPage, TabTypeCheckHdl_Impl, RadioButton *, pBox )
590 : {
591 0 : bCheck |= sal_True;
592 : SvxTabAdjust eAdj;
593 0 : m_pDezChar->Disable();
594 0 : m_pDezCharLabel->Disable();
595 0 : m_pDezChar->SetText( "" );
596 :
597 0 : if ( pBox == m_pLeftTab )
598 0 : eAdj = SVX_TAB_ADJUST_LEFT;
599 0 : else if ( pBox == m_pRightTab )
600 0 : eAdj = SVX_TAB_ADJUST_RIGHT;
601 0 : else if ( pBox == m_pCenterTab )
602 0 : eAdj = SVX_TAB_ADJUST_CENTER;
603 : else
604 : {
605 0 : eAdj = SVX_TAB_ADJUST_DECIMAL;
606 0 : m_pDezChar->Enable();
607 0 : m_pDezCharLabel->Enable();
608 0 : m_pDezChar->SetText( OUString( (sal_Unicode)aAktTab.GetDecimal() ) );
609 : }
610 :
611 0 : aAktTab.GetAdjustment() = eAdj;
612 0 : sal_uInt16 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue( eDefUnit ), eDefUnit );
613 :
614 0 : if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
615 : {
616 0 : aNewTabs.Remove( nPos );
617 0 : aNewTabs.Insert( aAktTab );
618 : }
619 0 : return 0;
620 : }
621 :
622 : // -----------------------------------------------------------------------
623 :
624 0 : IMPL_LINK( SvxTabulatorTabPage, FillTypeCheckHdl_Impl, RadioButton *, pBox )
625 : {
626 0 : bCheck |= sal_True;
627 0 : sal_uInt8 cFill = ' ';
628 0 : m_pFillChar->SetText( "" );
629 0 : m_pFillChar->Disable();
630 :
631 0 : if( pBox == m_pFillSpecial )
632 0 : m_pFillChar->Enable();
633 0 : else if ( pBox == m_pNoFillChar )
634 0 : cFill = ' ';
635 0 : else if ( pBox == m_pFillSolidLine )
636 0 : cFill = '_';
637 0 : else if ( pBox == m_pFillPoints )
638 0 : cFill = '.';
639 0 : else if ( pBox == m_pFillDashLine )
640 0 : cFill = '-';
641 :
642 0 : aAktTab.GetFill() = cFill;
643 0 : sal_uInt16 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue( eDefUnit ), eDefUnit );
644 :
645 0 : if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
646 : {
647 0 : aNewTabs.Remove( nPos );
648 0 : aNewTabs.Insert( aAktTab );
649 : }
650 0 : return 0;
651 : }
652 :
653 : // -----------------------------------------------------------------------
654 :
655 0 : IMPL_LINK( SvxTabulatorTabPage, GetFillCharHdl_Impl, Edit *, pEdit )
656 : {
657 0 : String aChar( pEdit->GetText() );
658 :
659 0 : if ( aChar.Len() > 0)
660 0 : aAktTab.GetFill() = aChar.GetChar( 0 );
661 :
662 0 : const sal_uInt16 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue( eDefUnit ), eDefUnit);
663 0 : if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
664 : {
665 0 : aNewTabs.Remove( nPos );
666 0 : aNewTabs.Insert( aAktTab );
667 : }
668 0 : return 0;
669 : }
670 :
671 : // -----------------------------------------------------------------------
672 :
673 0 : IMPL_LINK( SvxTabulatorTabPage, GetDezCharHdl_Impl, Edit *, pEdit )
674 : {
675 0 : String aChar( pEdit->GetText() );
676 0 : if ( aChar.Len() > 0 && ( aChar.GetChar( 0 ) >= ' '))
677 0 : aAktTab.GetDecimal() = aChar.GetChar( 0 );
678 :
679 0 : sal_uInt16 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue( eDefUnit ), eDefUnit );
680 0 : if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
681 : {
682 0 : aNewTabs.Remove( nPos );
683 0 : aNewTabs.Insert( aAktTab );
684 : }
685 0 : return 0;
686 : }
687 :
688 : // -----------------------------------------------------------------------
689 :
690 0 : IMPL_LINK_NOARG(SvxTabulatorTabPage, SelectHdl_Impl)
691 : {
692 0 : sal_uInt16 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue( eDefUnit ), eDefUnit );
693 0 : if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
694 : {
695 0 : aAktTab = aNewTabs[nPos];
696 0 : m_pNewBtn->Disable();
697 0 : SetFillAndTabType_Impl();
698 : }
699 0 : return 0;
700 : }
701 :
702 : // -----------------------------------------------------------------------
703 :
704 0 : IMPL_LINK_NOARG(SvxTabulatorTabPage, ModifyHdl_Impl)
705 : {
706 0 : sal_uInt16 nPos = m_pTabBox->GetValuePos( m_pTabBox->GetValue( eDefUnit ), eDefUnit );
707 0 : if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
708 : {
709 0 : aAktTab = aNewTabs[nPos];
710 0 : SetFillAndTabType_Impl();
711 :
712 0 : aAktTab.GetTabPos() =
713 0 : static_cast<long>(m_pTabBox->Denormalize( m_pTabBox->GetValue( eDefUnit ) ));
714 :
715 0 : m_pNewBtn->Disable();
716 0 : m_pDelBtn->Enable();
717 0 : return 0;
718 : }
719 0 : m_pNewBtn->Enable();
720 0 : m_pDelBtn->Disable();
721 0 : return 0;
722 : }
723 :
724 0 : void SvxTabulatorTabPage::PageCreated(SfxAllItemSet aSet)
725 : {
726 0 : SFX_ITEMSET_ARG (&aSet,pControlItem,SfxUInt16Item,SID_SVXTABULATORTABPAGE_CONTROLFLAGS,sal_False);
727 0 : if (pControlItem)
728 0 : DisableControls(pControlItem->GetValue());
729 0 : }
730 :
731 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|