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