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 <svl/style.hxx>
21 : #include <sfx2/app.hxx>
22 : #include <sfx2/dialoghelper.hxx>
23 : #include <sfx2/objsh.hxx>
24 : #include <sfx2/module.hxx>
25 : #include <vcl/mnemonic.hxx>
26 : #include <svx/dialogs.hrc>
27 :
28 : #include <svl/languageoptions.hxx>
29 : #include <svl/cjkoptions.hxx>
30 : #include <editeng/pgrditem.hxx>
31 : #include <cuires.hrc>
32 : #include "paragrph.hrc"
33 : #include "paragrph.hxx"
34 : #include <editeng/frmdiritem.hxx>
35 : #include <editeng/lspcitem.hxx>
36 : #include <editeng/adjustitem.hxx>
37 : #include <editeng/orphitem.hxx>
38 : #include <editeng/widwitem.hxx>
39 : #include <editeng/tstpitem.hxx>
40 : #include <editeng/pmdlitem.hxx>
41 : #include <editeng/spltitem.hxx>
42 : #include <editeng/hyphenzoneitem.hxx>
43 : #include <editeng/ulspitem.hxx>
44 : #include <editeng/lrspitem.hxx>
45 : #include <editeng/formatbreakitem.hxx>
46 : #include <editeng/keepitem.hxx>
47 : #include "svx/dlgutil.hxx"
48 : #include <dialmgr.hxx>
49 : #include <sfx2/htmlmode.hxx>
50 : #include <editeng/paravertalignitem.hxx>
51 : #include <svl/eitem.hxx>
52 : #include <sfx2/request.hxx>
53 : #include <svl/intitem.hxx>
54 :
55 : // static ----------------------------------------------------------------
56 :
57 : static sal_uInt16 pStdRanges[] =
58 : {
59 : SID_ATTR_PARA_LINESPACE, // 10033
60 : SID_ATTR_PARA_LINESPACE,
61 : SID_ATTR_LRSPACE, // 10048 -
62 : SID_ATTR_ULSPACE, // 10049
63 : SID_ATTR_PARA_REGISTER, // 10413
64 : SID_ATTR_PARA_REGISTER,
65 : 0
66 : };
67 :
68 : static sal_uInt16 pAlignRanges[] =
69 : {
70 : SID_ATTR_PARA_ADJUST, // 10027
71 : SID_ATTR_PARA_ADJUST,
72 : 0
73 : };
74 :
75 : static sal_uInt16 pExtRanges[] =
76 : {
77 : SID_ATTR_PARA_PAGEBREAK, // 10037 -
78 : SID_ATTR_PARA_WIDOWS, // 10041
79 : SID_ATTR_PARA_MODEL, // 10065 -
80 : SID_ATTR_PARA_KEEP, // 10066
81 : 0
82 : };
83 :
84 : // define ----------------------------------------------------------------
85 :
86 : #define MAX_DURCH 5670 // 10 cm makes sense as maximum interline lead
87 : // according to BP
88 : #define FIX_DIST_DEF 283 // standard fix distance 0,5 cm
89 :
90 : // enum ------------------------------------------------------------------
91 :
92 : enum LineSpaceList
93 : {
94 : LLINESPACE_1 = 0,
95 : LLINESPACE_15 = 1,
96 : LLINESPACE_2 = 2,
97 : LLINESPACE_PROP = 3,
98 : LLINESPACE_MIN = 4,
99 : LLINESPACE_DURCH= 5,
100 : LLINESPACE_FIX = 6,
101 : LLINESPACE_END
102 : };
103 :
104 : // C-Function ------------------------------------------------------------
105 :
106 : void SetLineSpace_Impl( SvxLineSpacingItem&, int, long lValue = 0 );
107 :
108 0 : void SetLineSpace_Impl( SvxLineSpacingItem& rLineSpace,
109 : int eSpace, long lValue )
110 : {
111 0 : switch ( eSpace )
112 : {
113 : case LLINESPACE_1:
114 0 : rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
115 0 : rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
116 0 : break;
117 :
118 : case LLINESPACE_15:
119 0 : rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
120 0 : rLineSpace.SetPropLineSpace( 150 );
121 0 : break;
122 :
123 : case LLINESPACE_2:
124 0 : rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
125 0 : rLineSpace.SetPropLineSpace( 200 );
126 0 : break;
127 :
128 : case LLINESPACE_PROP:
129 0 : rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
130 0 : rLineSpace.SetPropLineSpace( (sal_uInt8)lValue );
131 0 : break;
132 :
133 : case LLINESPACE_MIN:
134 0 : rLineSpace.SetLineHeight( (sal_uInt16)lValue );
135 0 : rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
136 0 : break;
137 :
138 : case LLINESPACE_DURCH:
139 0 : rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
140 0 : rLineSpace.SetInterLineSpace( (sal_uInt16)lValue );
141 0 : break;
142 :
143 : case LLINESPACE_FIX:
144 0 : rLineSpace.SetLineHeight((sal_uInt16)lValue);
145 0 : rLineSpace.GetLineSpaceRule() = SVX_LINE_SPACE_FIX;
146 0 : rLineSpace.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
147 0 : break;
148 : }
149 0 : }
150 :
151 :
152 0 : sal_uInt16 GetHtmlMode_Impl(const SfxItemSet& rSet)
153 : {
154 0 : sal_uInt16 nHtmlMode = 0;
155 0 : const SfxPoolItem* pItem = 0;
156 : SfxObjectShell* pShell;
157 0 : if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem) ||
158 0 : ( 0 != (pShell = SfxObjectShell::Current()) &&
159 0 : 0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
160 : {
161 0 : nHtmlMode = ((SfxUInt16Item*)pItem)->GetValue();
162 : }
163 0 : return nHtmlMode;
164 :
165 : }
166 :
167 : // class SvxStdParagraphTabPage ------------------------------------------
168 :
169 0 : IMPL_LINK_NOARG(SvxStdParagraphTabPage, ELRLoseFocusHdl)
170 : {
171 0 : SfxItemPool* pPool = GetItemSet().GetPool();
172 : DBG_ASSERT( pPool, "Wo ist der Pool" );
173 : FieldUnit eUnit =
174 0 : MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
175 :
176 0 : sal_Int64 nL = m_pLeftIndent->Denormalize( m_pLeftIndent->GetValue( eUnit ) );
177 0 : sal_Int64 nR = m_pRightIndent->Denormalize( m_pRightIndent->GetValue( eUnit ) );
178 0 : OUString aTmp = m_pFLineIndent->GetText();
179 :
180 0 : if( m_pLeftIndent->GetMin() < 0 )
181 0 : m_pFLineIndent->SetMin( -99999, FUNIT_MM );
182 : else
183 0 : m_pFLineIndent->SetMin( m_pFLineIndent->Normalize( -nL ), eUnit );
184 :
185 : // Check only for concrete width (Shell)
186 0 : sal_Int64 nTmp = nWidth - nL - nR - MM50;
187 0 : m_pFLineIndent->SetMax( m_pFLineIndent->Normalize( nTmp ), eUnit );
188 :
189 0 : if ( aTmp.isEmpty() )
190 0 : m_pFLineIndent->SetEmptyFieldValue();
191 : // maximum left right
192 0 : aTmp = m_pLeftIndent->GetText();
193 0 : nTmp = nWidth - nR - MM50;
194 0 : m_pLeftIndent->SetMax( m_pLeftIndent->Normalize( nTmp ), eUnit );
195 :
196 0 : if ( aTmp.isEmpty() )
197 0 : m_pLeftIndent->SetEmptyFieldValue();
198 0 : aTmp = m_pRightIndent->GetText();
199 0 : nTmp = nWidth - nL - MM50;
200 0 : m_pRightIndent->SetMax( m_pRightIndent->Normalize( nTmp ), eUnit );
201 :
202 0 : if ( aTmp.isEmpty() )
203 0 : m_pRightIndent->SetEmptyFieldValue();
204 0 : return 0;
205 : }
206 :
207 : // -----------------------------------------------------------------------
208 :
209 0 : SfxTabPage* SvxStdParagraphTabPage::Create( Window* pParent, const SfxItemSet& rSet)
210 : {
211 0 : return new SvxStdParagraphTabPage( pParent, rSet );
212 : }
213 :
214 : // -----------------------------------------------------------------------
215 :
216 0 : sal_Bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet& rOutSet )
217 : {
218 0 : SfxItemState eState = SFX_ITEM_UNKNOWN;
219 0 : const SfxPoolItem* pOld = 0;
220 0 : SfxItemPool* pPool = rOutSet.GetPool();
221 : DBG_ASSERT( pPool, "Wo ist der Pool" );
222 :
223 0 : sal_Bool bModified = sal_False;
224 : sal_uInt16 nWhich;
225 0 : sal_uInt16 nPos = m_pLineDist->GetSelectEntryPos();
226 :
227 0 : if ( LISTBOX_ENTRY_NOTFOUND != nPos &&
228 0 : ( nPos != m_pLineDist->GetSavedValue() ||
229 0 : m_pLineDistAtPercentBox->IsValueModified() ||
230 0 : m_pLineDistAtMetricBox->IsValueModified() ) )
231 : {
232 0 : nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
233 0 : SfxMapUnit eUnit = pPool->GetMetric( nWhich );
234 : SvxLineSpacingItem aSpacing(
235 0 : (const SvxLineSpacingItem&)GetItemSet().Get( nWhich ) );
236 :
237 0 : switch ( nPos )
238 : {
239 : case LLINESPACE_1:
240 : case LLINESPACE_15:
241 : case LLINESPACE_2:
242 0 : SetLineSpace_Impl( aSpacing, nPos );
243 0 : break;
244 :
245 : case LLINESPACE_PROP:
246 : SetLineSpace_Impl( aSpacing, nPos,
247 : static_cast<long>(m_pLineDistAtPercentBox->Denormalize(
248 0 : m_pLineDistAtPercentBox->GetValue() )) );
249 0 : break;
250 :
251 : case LLINESPACE_MIN:
252 : case LLINESPACE_DURCH:
253 : case LLINESPACE_FIX:
254 : SetLineSpace_Impl( aSpacing, nPos,
255 0 : GetCoreValue( *m_pLineDistAtMetricBox, eUnit ) );
256 0 : break;
257 :
258 : default:
259 : OSL_FAIL( "unbekannter Type fuer Zeilenabstand." );
260 0 : break;
261 : }
262 0 : eState = GetItemSet().GetItemState( nWhich );
263 0 : pOld = GetOldItem( rOutSet, SID_ATTR_PARA_LINESPACE );
264 :
265 0 : if ( !pOld || !( *(const SvxLineSpacingItem*)pOld == aSpacing ) ||
266 : SFX_ITEM_DONTCARE == eState )
267 : {
268 0 : rOutSet.Put( aSpacing );
269 0 : bModified = sal_True;
270 0 : }
271 : }
272 :
273 0 : if ( m_pTopDist->IsValueModified() || m_pBottomDist->IsValueModified()
274 0 : || m_pContextualCB->GetSavedValue() != m_pContextualCB->IsChecked())
275 : {
276 0 : nWhich = GetWhich( SID_ATTR_ULSPACE );
277 0 : SfxMapUnit eUnit = pPool->GetMetric( nWhich );
278 0 : pOld = GetOldItem( rOutSet, SID_ATTR_ULSPACE );
279 0 : SvxULSpaceItem aMargin( nWhich );
280 :
281 0 : if ( bRelativeMode )
282 : {
283 : DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
284 :
285 : const SvxULSpaceItem& rOldItem =
286 0 : (const SvxULSpaceItem&)GetItemSet().GetParent()->Get( nWhich );
287 :
288 0 : if ( m_pTopDist->IsRelative() )
289 0 : aMargin.SetUpper( rOldItem.GetUpper(),
290 0 : (sal_uInt16)m_pTopDist->GetValue() );
291 : else
292 0 : aMargin.SetUpper( (sal_uInt16)GetCoreValue( *m_pTopDist, eUnit ) );
293 :
294 0 : if ( m_pBottomDist->IsRelative() )
295 0 : aMargin.SetLower( rOldItem.GetLower(),
296 0 : (sal_uInt16)m_pBottomDist->GetValue() );
297 : else
298 0 : aMargin.SetLower( (sal_uInt16)GetCoreValue( *m_pBottomDist, eUnit ) );
299 :
300 : }
301 : else
302 : {
303 0 : aMargin.SetUpper( (sal_uInt16)GetCoreValue( *m_pTopDist, eUnit ) );
304 0 : aMargin.SetLower( (sal_uInt16)GetCoreValue( *m_pBottomDist, eUnit ) );
305 : }
306 0 : aMargin.SetContextValue(m_pContextualCB->IsChecked());
307 0 : eState = GetItemSet().GetItemState( nWhich );
308 :
309 0 : if ( !pOld || !( *(const SvxULSpaceItem*)pOld == aMargin ) ||
310 : SFX_ITEM_DONTCARE == eState )
311 : {
312 0 : rOutSet.Put( aMargin );
313 0 : bModified = sal_True;
314 0 : }
315 : }
316 0 : bool bNullTab = false;
317 :
318 0 : if ( m_pLeftIndent->IsValueModified() ||
319 0 : m_pFLineIndent->IsValueModified() ||
320 0 : m_pRightIndent->IsValueModified()
321 0 : || m_pAutoCB->GetSavedValue() != m_pAutoCB->IsChecked() )
322 : {
323 0 : nWhich = GetWhich( SID_ATTR_LRSPACE );
324 0 : SfxMapUnit eUnit = pPool->GetMetric( nWhich );
325 0 : SvxLRSpaceItem aMargin( nWhich );
326 0 : pOld = GetOldItem( rOutSet, SID_ATTR_LRSPACE );
327 :
328 0 : if ( bRelativeMode )
329 : {
330 : DBG_ASSERT( GetItemSet().GetParent(), "No ParentSet" );
331 :
332 : const SvxLRSpaceItem& rOldItem =
333 0 : (const SvxLRSpaceItem&)GetItemSet().GetParent()->Get( nWhich );
334 :
335 0 : if ( m_pLeftIndent->IsRelative() )
336 : aMargin.SetTxtLeft( rOldItem.GetTxtLeft(),
337 0 : (sal_uInt16)m_pLeftIndent->GetValue() );
338 : else
339 0 : aMargin.SetTxtLeft( GetCoreValue( *m_pLeftIndent, eUnit ) );
340 :
341 0 : if ( m_pRightIndent->IsRelative() )
342 : aMargin.SetRight( rOldItem.GetRight(),
343 0 : (sal_uInt16)m_pRightIndent->GetValue() );
344 : else
345 0 : aMargin.SetRight( GetCoreValue( *m_pRightIndent, eUnit ) );
346 :
347 0 : if ( m_pFLineIndent->IsRelative() )
348 0 : aMargin.SetTxtFirstLineOfst( rOldItem.GetTxtFirstLineOfst(),
349 0 : (sal_uInt16)m_pFLineIndent->GetValue() );
350 : else
351 : aMargin.SetTxtFirstLineOfst(
352 0 : (sal_uInt16)GetCoreValue( *m_pFLineIndent, eUnit ) );
353 : }
354 : else
355 : {
356 0 : aMargin.SetTxtLeft( GetCoreValue( *m_pLeftIndent, eUnit ) );
357 0 : aMargin.SetRight( GetCoreValue( *m_pRightIndent, eUnit ) );
358 : aMargin.SetTxtFirstLineOfst(
359 0 : (sal_uInt16)GetCoreValue( *m_pFLineIndent, eUnit ) );
360 : }
361 0 : aMargin.SetAutoFirst(m_pAutoCB->IsChecked());
362 0 : if ( aMargin.GetTxtFirstLineOfst() < 0 )
363 0 : bNullTab = true;
364 0 : eState = GetItemSet().GetItemState( nWhich );
365 :
366 0 : if ( !pOld || !( *(const SvxLRSpaceItem*)pOld == aMargin ) ||
367 : SFX_ITEM_DONTCARE == eState )
368 : {
369 0 : rOutSet.Put( aMargin );
370 0 : bModified = sal_True;
371 0 : }
372 : }
373 :
374 0 : if ( bNullTab )
375 : {
376 0 : MapUnit eUnit = (MapUnit)pPool->GetMetric( GetWhich( SID_ATTR_TABSTOP ) );
377 0 : if ( MAP_100TH_MM != eUnit )
378 : {
379 :
380 : // negative first line indent -> set null default tabstob if applicable
381 0 : sal_uInt16 _nWhich = GetWhich( SID_ATTR_TABSTOP );
382 0 : const SfxItemSet& rInSet = GetItemSet();
383 :
384 0 : if ( rInSet.GetItemState( _nWhich ) >= SFX_ITEM_AVAILABLE )
385 : {
386 : const SvxTabStopItem& rTabItem =
387 0 : (const SvxTabStopItem&)rInSet.Get( _nWhich );
388 0 : SvxTabStopItem aNullTab( rTabItem );
389 0 : SvxTabStop aNull( 0, SVX_TAB_ADJUST_DEFAULT );
390 0 : aNullTab.Insert( aNull );
391 0 : rOutSet.Put( aNullTab );
392 : }
393 : }
394 : }
395 0 : if( m_pRegisterCB->IsVisible())
396 : {
397 : const SfxBoolItem* pBoolItem = (SfxBoolItem*)GetOldItem(
398 0 : rOutSet, SID_ATTR_PARA_REGISTER);
399 0 : SfxBoolItem* pRegItem = (SfxBoolItem*)pBoolItem->Clone();
400 0 : sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
401 0 : sal_Bool bSet = pRegItem->GetValue();
402 :
403 0 : if(m_pRegisterCB->IsChecked() != bSet )
404 : {
405 0 : pRegItem->SetValue(!bSet);
406 0 : rOutSet.Put(*pRegItem);
407 0 : bModified = sal_True;
408 : }
409 0 : else if ( SFX_ITEM_DEFAULT == GetItemSet().GetItemState( _nWhich, sal_False ) )
410 0 : rOutSet.ClearItem(_nWhich);
411 0 : delete pRegItem;
412 : }
413 :
414 0 : return bModified;
415 : }
416 :
417 : // -----------------------------------------------------------------------
418 :
419 0 : void SvxStdParagraphTabPage::Reset( const SfxItemSet& rSet )
420 : {
421 0 : SfxItemPool* pPool = rSet.GetPool();
422 : DBG_ASSERT( pPool, "Wo ist der Pool?" );
423 :
424 : // adjust metric
425 0 : FieldUnit eFUnit = GetModuleFieldUnit( rSet );
426 :
427 0 : bool bApplyCharUnit = GetApplyCharUnit( rSet );
428 :
429 0 : SvtCJKOptions aCJKOptions;
430 0 : if(aCJKOptions.IsAsianTypographyEnabled() && bApplyCharUnit )
431 0 : eFUnit = FUNIT_CHAR;
432 :
433 0 : SetFieldUnit( *m_pLeftIndent, eFUnit );
434 0 : SetFieldUnit( *m_pRightIndent, eFUnit );
435 0 : SetFieldUnit( *m_pFLineIndent, eFUnit );
436 0 : if ( eFUnit == FUNIT_CHAR )
437 : {
438 0 : SetFieldUnit( *m_pTopDist, FUNIT_LINE );
439 0 : SetFieldUnit( *m_pBottomDist, FUNIT_LINE );
440 0 : SetFieldUnit( *m_pLineDistAtMetricBox, FUNIT_POINT );
441 : }
442 : else
443 : {
444 0 : SetFieldUnit( *m_pTopDist, eFUnit );
445 0 : SetFieldUnit( *m_pBottomDist, eFUnit );
446 0 : SetFieldUnit( *m_pLineDistAtMetricBox, eFUnit );
447 : }
448 :
449 0 : sal_uInt16 _nWhich = GetWhich( SID_ATTR_LRSPACE );
450 0 : SfxItemState eItemState = rSet.GetItemState( _nWhich );
451 :
452 0 : if ( eItemState >= SFX_ITEM_AVAILABLE )
453 : {
454 0 : SfxMapUnit eUnit = pPool->GetMetric( _nWhich );
455 :
456 0 : if ( bRelativeMode )
457 : {
458 : const SvxLRSpaceItem& rOldItem =
459 0 : (const SvxLRSpaceItem&)rSet.Get( _nWhich );
460 :
461 0 : if ( rOldItem.GetPropLeft() != 100 )
462 : {
463 0 : m_pLeftIndent->SetRelative( sal_True );
464 0 : m_pLeftIndent->SetValue( rOldItem.GetPropLeft() );
465 : }
466 : else
467 : {
468 0 : m_pLeftIndent->SetRelative();
469 0 : SetFieldUnit( *m_pLeftIndent, eFUnit );
470 0 : SetMetricValue( *m_pLeftIndent, rOldItem.GetTxtLeft(), eUnit );
471 : }
472 :
473 0 : if ( rOldItem.GetPropRight() != 100 )
474 : {
475 0 : m_pRightIndent->SetRelative( sal_True );
476 0 : m_pRightIndent->SetValue( rOldItem.GetPropRight() );
477 : }
478 : else
479 : {
480 0 : m_pRightIndent->SetRelative();
481 0 : SetFieldUnit( *m_pRightIndent, eFUnit );
482 0 : SetMetricValue( *m_pRightIndent, rOldItem.GetRight(), eUnit );
483 : }
484 :
485 0 : if ( rOldItem.GetPropTxtFirstLineOfst() != 100 )
486 : {
487 0 : m_pFLineIndent->SetRelative( sal_True );
488 0 : m_pFLineIndent->SetValue( rOldItem.GetPropTxtFirstLineOfst() );
489 : }
490 : else
491 : {
492 0 : m_pFLineIndent->SetRelative();
493 0 : m_pFLineIndent->SetMin(-9999);
494 0 : SetFieldUnit( *m_pFLineIndent, eFUnit );
495 0 : SetMetricValue( *m_pFLineIndent, rOldItem.GetTxtFirstLineOfst(),
496 0 : eUnit );
497 : }
498 0 : m_pAutoCB->Check(rOldItem.IsAutoFirst());
499 : }
500 : else
501 : {
502 : const SvxLRSpaceItem& rSpace =
503 0 : (const SvxLRSpaceItem&)rSet.Get( _nWhich );
504 :
505 0 : SetMetricValue( *m_pLeftIndent, rSpace.GetTxtLeft(), eUnit );
506 0 : SetMetricValue( *m_pRightIndent, rSpace.GetRight(), eUnit );
507 0 : SetMetricValue( *m_pFLineIndent, rSpace.GetTxtFirstLineOfst(), eUnit );
508 0 : m_pAutoCB->Check(rSpace.IsAutoFirst());
509 : }
510 0 : AutoHdl_Impl(m_pAutoCB);
511 : }
512 : else
513 : {
514 0 : m_pLeftIndent->SetEmptyFieldValue();
515 0 : m_pRightIndent->SetEmptyFieldValue();
516 0 : m_pFLineIndent->SetEmptyFieldValue();
517 : }
518 :
519 0 : _nWhich = GetWhich( SID_ATTR_ULSPACE );
520 0 : eItemState = rSet.GetItemState( _nWhich );
521 :
522 0 : if ( eItemState >= SFX_ITEM_AVAILABLE )
523 : {
524 0 : SfxMapUnit eUnit = pPool->GetMetric( _nWhich );
525 :
526 : const SvxULSpaceItem& rOldItem =
527 0 : (const SvxULSpaceItem&)rSet.Get( _nWhich );
528 0 : if ( bRelativeMode )
529 : {
530 :
531 0 : if ( rOldItem.GetPropUpper() != 100 )
532 : {
533 0 : m_pTopDist->SetRelative( sal_True );
534 0 : m_pTopDist->SetValue( rOldItem.GetPropUpper() );
535 : }
536 : else
537 : {
538 0 : m_pTopDist->SetRelative();
539 0 : if ( eFUnit == FUNIT_CHAR )
540 0 : SetFieldUnit( *m_pTopDist, FUNIT_LINE );
541 : else
542 0 : SetFieldUnit( *m_pTopDist, eFUnit );
543 0 : SetMetricValue( *m_pTopDist, rOldItem.GetUpper(), eUnit );
544 : }
545 :
546 0 : if ( rOldItem.GetPropLower() != 100 )
547 : {
548 0 : m_pBottomDist->SetRelative( sal_True );
549 0 : m_pBottomDist->SetValue( rOldItem.GetPropLower() );
550 : }
551 : else
552 : {
553 0 : m_pBottomDist->SetRelative();
554 0 : if ( eFUnit == FUNIT_CHAR )
555 0 : SetFieldUnit( *m_pBottomDist, FUNIT_LINE );
556 : else
557 0 : SetFieldUnit( *m_pBottomDist, eFUnit );
558 0 : SetMetricValue( *m_pBottomDist, rOldItem.GetLower(), eUnit );
559 : }
560 : }
561 : else
562 : {
563 0 : SetMetricValue( *m_pTopDist, rOldItem.GetUpper(), eUnit );
564 0 : SetMetricValue( *m_pBottomDist, rOldItem.GetLower(), eUnit );
565 : }
566 0 : m_pContextualCB->Check(rOldItem.GetContext());
567 : }
568 : else
569 : {
570 0 : m_pTopDist->SetEmptyFieldValue();
571 0 : m_pBottomDist->SetEmptyFieldValue();
572 : }
573 :
574 0 : _nWhich = GetWhich( SID_ATTR_PARA_LINESPACE );
575 0 : eItemState = rSet.GetItemState( _nWhich );
576 :
577 0 : if ( eItemState >= SFX_ITEM_AVAILABLE )
578 0 : SetLineSpacing_Impl( (const SvxLineSpacingItem &)rSet.Get( _nWhich ) );
579 : else
580 0 : m_pLineDist->SetNoSelection();
581 :
582 :
583 0 : _nWhich = GetWhich( SID_ATTR_PARA_REGISTER );
584 0 : eItemState = rSet.GetItemState( _nWhich );
585 :
586 0 : if ( eItemState >= SFX_ITEM_AVAILABLE )
587 0 : m_pRegisterCB->Check( ((const SfxBoolItem &)rSet.Get( _nWhich )).GetValue());
588 0 : m_pRegisterCB->SaveValue();
589 0 : sal_uInt16 nHtmlMode = GetHtmlMode_Impl(rSet);
590 0 : if(nHtmlMode & HTMLMODE_ON)
591 : {
592 0 : m_pRegisterFL->Hide();
593 0 : m_pRegisterCB->Hide();
594 0 : m_pAutoCB->Hide();
595 :
596 0 : if(!(nHtmlMode & HTMLMODE_SOME_STYLES)) // IE or SW
597 : {
598 0 : m_pRightLabel->Disable();
599 0 : m_pRightIndent->Disable();
600 0 : m_pTopDist->Disable(); //HTML3.2 and NS 3.0
601 0 : m_pBottomDist->Disable();
602 0 : m_pFLineIndent->Disable();
603 0 : m_pFLineLabel->Disable();
604 : }
605 : }
606 :
607 0 : ELRLoseFocusHdl( NULL );
608 0 : m_pAutoCB->SaveValue();
609 0 : m_pContextualCB->SaveValue();
610 0 : m_pLineDist->SaveValue();
611 0 : }
612 :
613 : // -----------------------------------------------------------------------
614 :
615 0 : void SvxStdParagraphTabPage::EnableRelativeMode()
616 : {
617 : DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no parent-set!" );
618 :
619 0 : m_pLeftIndent->EnableRelativeMode( 0, 999 );
620 0 : m_pFLineIndent->EnableRelativeMode( 0, 999 );
621 0 : m_pRightIndent->EnableRelativeMode( 0, 999 );
622 0 : m_pTopDist->EnableRelativeMode( 0, 999 );
623 0 : m_pBottomDist->EnableRelativeMode( 0, 999 );
624 0 : bRelativeMode = sal_True;
625 0 : }
626 :
627 : // -----------------------------------------------------------------------
628 :
629 0 : int SvxStdParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
630 : {
631 0 : ELRLoseFocusHdl( NULL );
632 :
633 0 : if ( _pSet )
634 0 : FillItemSet( *_pSet );
635 0 : return LEAVE_PAGE;
636 : }
637 :
638 : // -----------------------------------------------------------------------
639 :
640 0 : SvxStdParagraphTabPage::SvxStdParagraphTabPage( Window* pParent, const SfxItemSet& rAttr ) :
641 : SfxTabPage( pParent, "ParaIndentSpacing","cui/ui/paraindentspacing.ui", rAttr ),
642 :
643 : nAbst ( MAX_DURCH ),
644 : nWidth ( 11905 /*567 * 50*/ ),
645 : nMinFixDist(0L),
646 :
647 : bRelativeMode ( sal_False ),
648 0 : bNegativeIndents(sal_False)
649 :
650 : {
651 0 : get(m_pLeftIndent,"spinED_LEFTINDENT");
652 0 : get(m_pRightIndent,"spinED_RIGHTINDENT");
653 0 : get(m_pRightLabel,"labelFT_RIGHTINDENT");
654 0 : get(m_pFLineLabel,"labelFT_FLINEINDENT");
655 0 : get(m_pFLineIndent,"spinED_FLINEINDENT");
656 0 : get(m_pAutoCB,"checkCB_AUTO");
657 :
658 0 : get(m_pTopDist,"spinED_TOPDIST");
659 0 : get(m_pBottomDist,"spinED_BOTTOMDIST");
660 0 : get(m_pContextualCB,"checkCB_CONTEXTUALSPACING");
661 :
662 0 : get(m_pLineDist,"comboLB_LINEDIST");
663 0 : get(m_pLineDistAtPercentBox,"spinED_LINEDISTPERCENT");
664 0 : get(m_pLineDistAtMetricBox,"spinED_LINEDISTMETRIC");
665 0 : get(m_pLineDistAtLabel,"labelFT_LINEDIST");
666 :
667 0 : get(m_pAbsDist,"labelST_LINEDIST_ABS");
668 0 : sAbsDist = m_pAbsDist->GetText();
669 :
670 0 : get(m_pRegisterFL,"frameFL_REGISTER");
671 0 : get(m_pRegisterCB,"checkCB_REGISTER");
672 :
673 0 : get(m_pExampleWin,"drawingareaWN_EXAMPLE");
674 :
675 : // this page needs ExchangeSupport
676 0 : SetExchangeSupport();
677 :
678 0 : m_pLineDistAtMetricBox->Hide();
679 :
680 0 : Init_Impl();
681 0 : m_pFLineIndent->SetMin(-9999); // is set to 0 on default
682 :
683 0 : setPreviewsToSamePlace(pParent, this);
684 0 : }
685 :
686 0 : SvxStdParagraphTabPage::~SvxStdParagraphTabPage()
687 0 : {}
688 :
689 : // -----------------------------------------------------------------------
690 :
691 0 : void SvxStdParagraphTabPage::EnableNegativeMode()
692 : {
693 0 : m_pLeftIndent->SetMin(-9999);
694 0 : m_pRightIndent->SetMin(-9999);
695 0 : m_pRightIndent->EnableNegativeMode();
696 0 : m_pLeftIndent->EnableNegativeMode();
697 0 : bNegativeIndents = sal_True;
698 0 : }
699 :
700 : // -----------------------------------------------------------------------
701 :
702 0 : sal_uInt16* SvxStdParagraphTabPage::GetRanges()
703 : {
704 0 : return pStdRanges;
705 : }
706 :
707 : // -----------------------------------------------------------------------
708 :
709 0 : void SvxStdParagraphTabPage::SetLineSpacing_Impl
710 : (
711 : const SvxLineSpacingItem &rAttr
712 : )
713 : {
714 0 : SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( rAttr.Which() );
715 :
716 0 : switch( rAttr.GetLineSpaceRule() )
717 : {
718 : case SVX_LINE_SPACE_AUTO:
719 : {
720 0 : SvxInterLineSpace eInter = rAttr.GetInterLineSpaceRule();
721 :
722 0 : switch( eInter )
723 : {
724 : // Default single line spacing
725 : case SVX_INTER_LINE_SPACE_OFF:
726 0 : m_pLineDist->SelectEntryPos( LLINESPACE_1 );
727 0 : break;
728 :
729 : // Default single line spacing
730 : case SVX_INTER_LINE_SPACE_PROP:
731 0 : if ( 100 == rAttr.GetPropLineSpace() )
732 : {
733 0 : m_pLineDist->SelectEntryPos( LLINESPACE_1 );
734 0 : break;
735 : }
736 : // 1.5 line spacing
737 0 : if ( 150 == rAttr.GetPropLineSpace() )
738 : {
739 0 : m_pLineDist->SelectEntryPos( LLINESPACE_15 );
740 0 : break;
741 : }
742 : // double line spacing
743 0 : if ( 200 == rAttr.GetPropLineSpace() )
744 : {
745 0 : m_pLineDist->SelectEntryPos( LLINESPACE_2 );
746 0 : break;
747 : }
748 : // the set per cent value
749 0 : m_pLineDistAtPercentBox->SetValue( m_pLineDistAtPercentBox->Normalize(rAttr.GetPropLineSpace() ) );
750 0 : m_pLineDist->SelectEntryPos( LLINESPACE_PROP );
751 0 : break;
752 :
753 : case SVX_INTER_LINE_SPACE_FIX:
754 0 : SetMetricValue( *m_pLineDistAtMetricBox, rAttr.GetInterLineSpace(), eUnit );
755 0 : m_pLineDist->SelectEntryPos( LLINESPACE_DURCH );
756 0 : break;
757 : default: ;//prevent warning
758 : }
759 : }
760 0 : break;
761 : case SVX_LINE_SPACE_FIX:
762 0 : SetMetricValue(*m_pLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
763 0 : m_pLineDist->SelectEntryPos( LLINESPACE_FIX );
764 0 : break;
765 :
766 : case SVX_LINE_SPACE_MIN:
767 0 : SetMetricValue(*m_pLineDistAtMetricBox, rAttr.GetLineHeight(), eUnit);
768 0 : m_pLineDist->SelectEntryPos( LLINESPACE_MIN );
769 0 : break;
770 : default: ;//prevent warning
771 : }
772 0 : LineDistHdl_Impl( m_pLineDist );
773 0 : }
774 :
775 : // -----------------------------------------------------------------------
776 :
777 0 : IMPL_LINK( SvxStdParagraphTabPage, LineDistHdl_Impl, ListBox *, pBox )
778 : {
779 0 : switch( pBox->GetSelectEntryPos() )
780 : {
781 : case LLINESPACE_1:
782 : case LLINESPACE_15:
783 : case LLINESPACE_2:
784 0 : m_pLineDistAtLabel->Enable(sal_False);
785 0 : m_pLineDistAtPercentBox->Enable(sal_False);
786 0 : m_pLineDistAtPercentBox->SetText( OUString() );
787 0 : m_pLineDistAtMetricBox->Enable(sal_False);
788 0 : m_pLineDistAtMetricBox->SetText( OUString() );
789 0 : break;
790 :
791 : case LLINESPACE_DURCH:
792 : // setting a sensible default?
793 : // limit MS min(10, aPageSize)
794 0 : m_pLineDistAtMetricBox->SetMin(0);
795 :
796 0 : if ( m_pLineDistAtMetricBox->GetText().isEmpty() )
797 0 : m_pLineDistAtMetricBox->SetValue( m_pLineDistAtMetricBox->Normalize( 1 ) );
798 0 : m_pLineDistAtPercentBox->Hide();
799 0 : m_pLineDistAtMetricBox->Show();
800 0 : m_pLineDistAtMetricBox->Enable();
801 0 : m_pLineDistAtLabel->Enable();
802 0 : break;
803 :
804 : case LLINESPACE_MIN:
805 0 : m_pLineDistAtMetricBox->SetMin(0);
806 :
807 0 : if ( m_pLineDistAtMetricBox->GetText().isEmpty() )
808 0 : m_pLineDistAtMetricBox->SetValue( m_pLineDistAtMetricBox->Normalize( 10 ), FUNIT_TWIP );
809 0 : m_pLineDistAtPercentBox->Hide();
810 0 : m_pLineDistAtMetricBox->Show();
811 0 : m_pLineDistAtMetricBox->Enable();
812 0 : m_pLineDistAtLabel->Enable();
813 0 : break;
814 :
815 : case LLINESPACE_PROP:
816 :
817 0 : if ( m_pLineDistAtPercentBox->GetText().isEmpty() )
818 0 : m_pLineDistAtPercentBox->SetValue( m_pLineDistAtPercentBox->Normalize( 100 ), FUNIT_TWIP );
819 0 : m_pLineDistAtMetricBox->Hide();
820 0 : m_pLineDistAtPercentBox->Show();
821 0 : m_pLineDistAtPercentBox->Enable();
822 0 : m_pLineDistAtLabel->Enable();
823 0 : break;
824 : case LLINESPACE_FIX:
825 : {
826 0 : sal_Int64 nTemp = m_pLineDistAtMetricBox->GetValue();
827 0 : m_pLineDistAtMetricBox->SetMin(m_pLineDistAtMetricBox->Normalize(nMinFixDist), FUNIT_TWIP);
828 :
829 : // if the value has been changed at SetMin,
830 : // it is time for the default
831 0 : if ( m_pLineDistAtMetricBox->GetValue() != nTemp )
832 0 : SetMetricValue( *m_pLineDistAtMetricBox, FIX_DIST_DEF, SFX_MAPUNIT_TWIP ); // fix is only in Writer
833 0 : m_pLineDistAtPercentBox->Hide();
834 0 : m_pLineDistAtMetricBox->Show();
835 0 : m_pLineDistAtMetricBox->Enable();
836 0 : m_pLineDistAtLabel->Enable();
837 : }
838 0 : break;
839 : }
840 0 : UpdateExample_Impl( sal_True );
841 0 : return 0;
842 : }
843 :
844 : // -----------------------------------------------------------------------
845 :
846 0 : IMPL_LINK_NOARG_INLINE_START(SvxStdParagraphTabPage, ModifyHdl_Impl)
847 : {
848 0 : UpdateExample_Impl();
849 0 : return 0;
850 : }
851 0 : IMPL_LINK_NOARG_INLINE_END(SvxStdParagraphTabPage, ModifyHdl_Impl)
852 :
853 : // -----------------------------------------------------------------------
854 :
855 0 : void SvxStdParagraphTabPage::Init_Impl()
856 : {
857 : m_pLineDist->SetSelectHdl(
858 0 : LINK( this, SvxStdParagraphTabPage, LineDistHdl_Impl ) );
859 :
860 0 : Link aLink = LINK( this, SvxStdParagraphTabPage, ELRLoseFocusHdl );
861 0 : m_pFLineIndent->SetLoseFocusHdl( aLink );
862 0 : m_pLeftIndent->SetLoseFocusHdl( aLink );
863 0 : m_pRightIndent->SetLoseFocusHdl( aLink );
864 :
865 0 : aLink = LINK( this, SvxStdParagraphTabPage, ModifyHdl_Impl );
866 0 : m_pFLineIndent->SetModifyHdl( aLink );
867 0 : m_pLeftIndent->SetModifyHdl( aLink );
868 0 : m_pRightIndent->SetModifyHdl( aLink );
869 0 : m_pTopDist->SetModifyHdl( aLink );
870 0 : m_pBottomDist->SetModifyHdl( aLink );
871 :
872 0 : m_pAutoCB->SetClickHdl( LINK( this, SvxStdParagraphTabPage, AutoHdl_Impl ));
873 0 : SfxItemPool* pPool = GetItemSet().GetPool();
874 : DBG_ASSERT( pPool, "Wo ist der Pool" );
875 0 : FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) );
876 :
877 0 : m_pTopDist->SetMax( m_pTopDist->Normalize( nAbst ), eUnit );
878 0 : m_pBottomDist->SetMax( m_pBottomDist->Normalize( nAbst ), eUnit );
879 0 : m_pLineDistAtMetricBox->SetMax( m_pLineDistAtMetricBox->Normalize( nAbst ), eUnit );
880 0 : }
881 :
882 : // -----------------------------------------------------------------------
883 :
884 0 : void SvxStdParagraphTabPage::UpdateExample_Impl( sal_Bool bAll )
885 : {
886 0 : m_pExampleWin->SetFirstLineOfst( (short)m_pFLineIndent->Denormalize( m_pFLineIndent->GetValue( FUNIT_TWIP ) ) );
887 0 : m_pExampleWin->SetLeftMargin( static_cast<long>(m_pLeftIndent->Denormalize( m_pLeftIndent->GetValue( FUNIT_TWIP ) ) ) );
888 0 : m_pExampleWin->SetRightMargin( static_cast<long>(m_pRightIndent->Denormalize( m_pRightIndent->GetValue( FUNIT_TWIP ) ) ) );
889 0 : m_pExampleWin->SetUpper( (sal_uInt16)m_pTopDist->Denormalize( m_pTopDist->GetValue( FUNIT_TWIP ) ) );
890 0 : m_pExampleWin->SetLower( (sal_uInt16)m_pBottomDist->Denormalize( m_pBottomDist->GetValue( FUNIT_TWIP ) ) );
891 :
892 0 : sal_uInt16 nPos = m_pLineDist->GetSelectEntryPos();
893 :
894 0 : switch ( nPos )
895 : {
896 : case LLINESPACE_1:
897 : case LLINESPACE_15:
898 : case LLINESPACE_2:
899 0 : m_pExampleWin->SetLineSpace( (SvxPrevLineSpace)nPos );
900 0 : break;
901 :
902 : case LLINESPACE_PROP:
903 : m_pExampleWin->SetLineSpace( (SvxPrevLineSpace)nPos,
904 0 : (sal_uInt16)m_pLineDistAtPercentBox->Denormalize( m_pLineDistAtPercentBox->GetValue() ) );
905 0 : break;
906 :
907 : case LLINESPACE_MIN:
908 : case LLINESPACE_DURCH:
909 : case LLINESPACE_FIX:
910 : m_pExampleWin->SetLineSpace( (SvxPrevLineSpace)nPos,
911 0 : (sal_uInt16)GetCoreValue( *m_pLineDistAtMetricBox, SFX_MAPUNIT_TWIP ) );
912 0 : break;
913 : }
914 0 : m_pExampleWin->Draw( bAll );
915 0 : }
916 :
917 : // -----------------------------------------------------------------------
918 :
919 0 : void SvxStdParagraphTabPage::EnableRegisterMode()
920 : {
921 0 : m_pRegisterCB->Show();
922 0 : m_pRegisterFL->Show();
923 0 : }
924 :
925 0 : void SvxStdParagraphTabPage::EnableContextualMode()
926 : {
927 0 : m_pContextualCB->Show();
928 0 : }
929 :
930 0 : IMPL_LINK( SvxStdParagraphTabPage, AutoHdl_Impl, CheckBox*, pBox )
931 : {
932 0 : sal_Bool bEnable = !pBox->IsChecked();
933 0 : m_pFLineLabel->Enable(bEnable);
934 0 : m_pFLineIndent->Enable(bEnable);
935 0 : return 0;
936 : }
937 :
938 0 : void SvxStdParagraphTabPage::SetPageWidth( sal_uInt16 nPageWidth )
939 : {
940 0 : nWidth = nPageWidth;
941 0 : }
942 :
943 :
944 0 : void SvxStdParagraphTabPage::EnableAutoFirstLine()
945 : {
946 0 : m_pAutoCB->Show();
947 0 : }
948 :
949 :
950 0 : void SvxStdParagraphTabPage::EnableAbsLineDist(long nMinTwip)
951 : {
952 0 : m_pLineDist->InsertEntry(sAbsDist);
953 0 : nMinFixDist = nMinTwip;
954 0 : }
955 :
956 :
957 0 : void SvxStdParagraphTabPage::PageCreated(SfxAllItemSet aSet)
958 : {
959 :
960 : /* different bit represent call to different method of SvxStdParagraphTabPage
961 : 0x0001 --->EnableRelativeMode()
962 : 0x0002 --->EnableRegisterMode()
963 : 0x0004 --->EnableAutoFirstLine()
964 : 0x0008 --->EnableNegativeMode()
965 : 0x0010 --->EnableContextualMode()
966 : */
967 0 : SFX_ITEMSET_ARG (&aSet,pPageWidthItem,SfxUInt16Item,SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH,sal_False);
968 0 : SFX_ITEMSET_ARG (&aSet,pFlagSetItem,SfxUInt32Item,SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET,sal_False);
969 0 : SFX_ITEMSET_ARG (&aSet,pLineDistItem,SfxUInt32Item,SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST,sal_False);
970 :
971 0 : if (pPageWidthItem)
972 0 : SetPageWidth(pPageWidthItem->GetValue());
973 :
974 0 : if (pFlagSetItem )
975 0 : if (( 0x0001 & pFlagSetItem->GetValue())== 0x0001 )
976 0 : EnableRelativeMode();
977 :
978 0 : if (pFlagSetItem)
979 0 : if (( 0x0002 & pFlagSetItem->GetValue())== 0x0002 )
980 0 : EnableRegisterMode();
981 :
982 0 : if (pFlagSetItem)
983 0 : if ( ( 0x0004 & pFlagSetItem->GetValue())== 0x0004 )
984 0 : EnableAutoFirstLine();
985 :
986 0 : if(pLineDistItem)
987 0 : EnableAbsLineDist(pLineDistItem->GetValue());
988 :
989 0 : if (pFlagSetItem)
990 0 : if (( 0x0008 & pFlagSetItem->GetValue()) == 0x0008 )
991 0 : EnableNegativeMode();
992 :
993 0 : if (pFlagSetItem)
994 0 : if (( 0x0010 & pFlagSetItem->GetValue()) == 0x0010 )
995 0 : EnableContextualMode();
996 0 : }
997 :
998 :
999 : #define LASTLINEPOS_DEFAULT 0
1000 : #define LASTLINEPOS_LEFT 1
1001 :
1002 : #define LASTLINECOUNT_OLD 3
1003 : #define LASTLINECOUNT_NEW 4
1004 :
1005 : // class SvxParaAlignTabPage ------------------------------------------------
1006 :
1007 0 : SvxParaAlignTabPage::SvxParaAlignTabPage( Window* pParent, const SfxItemSet& rSet )
1008 :
1009 0 : : SfxTabPage(pParent, "ParaAlignPage", "cui/ui/paragalignpage.ui",rSet)
1010 : {
1011 0 : get(m_pLeft,"radioBTN_LEFTALIGN");
1012 0 : get(m_pRight,"radioBTN_RIGHTALIGN");
1013 0 : get(m_pCenter,"radioBTN_CENTERALIGN");
1014 0 : get(m_pJustify,"radioBTN_JUSTIFYALIGN");
1015 0 : get(m_pLeftBottom,"labelST_LEFTALIGN_ASIAN");
1016 0 : get(m_pRightTop,"labelST_RIGHTALIGN_ASIAN");
1017 :
1018 0 : get(m_pLastLineFT,"labelLB_LASTLINE");
1019 0 : get(m_pLastLineLB,"comboLB_LASTLINE");
1020 0 : get(m_pExpandCB,"checkCB_EXPAND");
1021 0 : get(m_pSnapToGridCB,"checkCB_SNAP");
1022 0 : get(m_pExampleWin,"drawingareaWN_EXAMPLE");
1023 :
1024 0 : get(m_pVertAlignLB,"comboLB_VERTALIGN");
1025 0 : get(m_pVertAlignFL,"frameFL_VERTALIGN");
1026 :
1027 0 : get(m_pPropertiesFL,"framePROPERTIES");
1028 0 : get(m_pTextDirectionLB,"comboLB_TEXTDIRECTION");
1029 :
1030 0 : SvtLanguageOptions aLangOptions;
1031 0 : sal_uInt16 nLastLinePos = LASTLINEPOS_DEFAULT;
1032 :
1033 0 : if ( aLangOptions.IsAsianTypographyEnabled() )
1034 : {
1035 0 : m_pLeft->SetText(m_pLeftBottom->GetText());
1036 0 : m_pRight->SetText(m_pRightTop->GetText());
1037 :
1038 0 : OUString sLeft(m_pLeft->GetText());
1039 0 : sLeft = MnemonicGenerator::EraseAllMnemonicChars( sLeft );
1040 :
1041 0 : if ( m_pLastLineLB->GetEntryCount() == LASTLINECOUNT_OLD )
1042 : {
1043 0 : m_pLastLineLB->RemoveEntry( 0 );
1044 0 : m_pLastLineLB->InsertEntry( sLeft, 0 );
1045 : }
1046 : else
1047 0 : nLastLinePos = LASTLINEPOS_LEFT;
1048 : }
1049 :
1050 : // remove "Default" or "Left" entry, depends on CJKOptions
1051 0 : if ( m_pLastLineLB->GetEntryCount() == LASTLINECOUNT_NEW )
1052 0 : m_pLastLineLB->RemoveEntry( nLastLinePos );
1053 :
1054 0 : Link aLink = LINK( this, SvxParaAlignTabPage, AlignHdl_Impl );
1055 0 : m_pLeft->SetClickHdl( aLink );
1056 0 : m_pRight->SetClickHdl( aLink );
1057 0 : m_pCenter->SetClickHdl( aLink );
1058 0 : m_pJustify->SetClickHdl( aLink );
1059 0 : m_pLastLineLB->SetSelectHdl( LINK( this, SvxParaAlignTabPage, LastLineHdl_Impl ) );
1060 0 : m_pTextDirectionLB->SetSelectHdl( LINK( this, SvxParaAlignTabPage, TextDirectionHdl_Impl ) );
1061 :
1062 0 : sal_uInt16 nHtmlMode = GetHtmlMode_Impl(rSet);
1063 0 : if(!(nHtmlMode & HTMLMODE_ON) || (0 != (nHtmlMode & HTMLMODE_SOME_STYLES)) )
1064 : {
1065 0 : if( aLangOptions.IsCTLFontEnabled() )
1066 : {
1067 0 : m_pTextDirectionLB->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_FRAMEDIR_LTR ), FRMDIR_HORI_LEFT_TOP );
1068 0 : m_pTextDirectionLB->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_FRAMEDIR_RTL ), FRMDIR_HORI_RIGHT_TOP );
1069 0 : m_pTextDirectionLB->InsertEntryValue( CUI_RESSTR( RID_SVXSTR_FRAMEDIR_SUPER ), FRMDIR_ENVIRONMENT );
1070 :
1071 0 : m_pPropertiesFL->Show();
1072 : }
1073 : }
1074 :
1075 0 : setPreviewsToSamePlace(pParent, this);
1076 0 : }
1077 :
1078 0 : SvxParaAlignTabPage::~SvxParaAlignTabPage()
1079 : {
1080 0 : }
1081 :
1082 0 : int SvxParaAlignTabPage::DeactivatePage( SfxItemSet* _pSet )
1083 : {
1084 0 : if ( _pSet )
1085 0 : FillItemSet( *_pSet );
1086 0 : return LEAVE_PAGE;
1087 : }
1088 :
1089 0 : SfxTabPage* SvxParaAlignTabPage::Create( Window* pParent, const SfxItemSet& rSet )
1090 : {
1091 0 : return new SvxParaAlignTabPage(pParent, rSet);
1092 : }
1093 :
1094 0 : sal_uInt16* SvxParaAlignTabPage::GetRanges()
1095 : {
1096 0 : return pAlignRanges;
1097 :
1098 : }
1099 :
1100 0 : sal_Bool SvxParaAlignTabPage::FillItemSet( SfxItemSet& rOutSet )
1101 : {
1102 0 : sal_Bool bModified = sal_False;
1103 :
1104 0 : bool bAdj = false, bChecked = false;
1105 0 : SvxAdjust eAdjust = SVX_ADJUST_LEFT;
1106 :
1107 0 : if ( m_pLeft->IsChecked() )
1108 : {
1109 0 : eAdjust = SVX_ADJUST_LEFT;
1110 0 : bAdj = !m_pLeft->GetSavedValue();
1111 0 : bChecked = true;
1112 : }
1113 0 : else if ( m_pRight->IsChecked() )
1114 : {
1115 0 : eAdjust = SVX_ADJUST_RIGHT;
1116 0 : bAdj = !m_pRight->GetSavedValue();
1117 0 : bChecked = true;
1118 : }
1119 0 : else if ( m_pCenter->IsChecked() )
1120 : {
1121 0 : eAdjust = SVX_ADJUST_CENTER;
1122 0 : bAdj = !m_pCenter->GetSavedValue();
1123 0 : bChecked = true;
1124 : }
1125 0 : else if ( m_pJustify->IsChecked() )
1126 : {
1127 0 : eAdjust = SVX_ADJUST_BLOCK;
1128 0 : bAdj = !m_pJustify->GetSavedValue() ||
1129 0 : m_pExpandCB->IsChecked() != m_pExpandCB->GetSavedValue() ||
1130 0 : m_pLastLineLB->GetSelectEntryPos() != m_pLastLineLB->GetSavedValue();
1131 0 : bChecked = true;
1132 : }
1133 0 : sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1134 :
1135 0 : if ( bAdj )
1136 : {
1137 0 : const SvxAdjustItem* pOld = (const SvxAdjustItem*)GetOldItem( rOutSet, SID_ATTR_PARA_ADJUST );
1138 :
1139 0 : SvxAdjust eOneWord = m_pExpandCB->IsChecked() ? SVX_ADJUST_BLOCK : SVX_ADJUST_LEFT;
1140 :
1141 0 : sal_uInt16 nLBPos = m_pLastLineLB->GetSelectEntryPos();
1142 0 : SvxAdjust eLastBlock = SVX_ADJUST_LEFT;
1143 :
1144 0 : if ( 1 == nLBPos )
1145 0 : eLastBlock = SVX_ADJUST_CENTER;
1146 0 : else if ( 2 == nLBPos )
1147 0 : eLastBlock = SVX_ADJUST_BLOCK;
1148 :
1149 : bool bNothingWasChecked =
1150 0 : !m_pLeft->GetSavedValue() && !m_pRight->GetSavedValue() &&
1151 0 : !m_pCenter->GetSavedValue() && !m_pJustify->GetSavedValue();
1152 :
1153 0 : if ( !pOld || pOld->GetAdjust() != eAdjust ||
1154 0 : pOld->GetOneWord() != eOneWord ||
1155 0 : pOld->GetLastBlock() != eLastBlock ||
1156 0 : ( bChecked && bNothingWasChecked ) )
1157 : {
1158 0 : bModified = sal_True;
1159 : SvxAdjustItem aAdj(
1160 0 : (const SvxAdjustItem&)GetItemSet().Get( _nWhich ) );
1161 0 : aAdj.SetAdjust( eAdjust );
1162 0 : aAdj.SetOneWord( eOneWord );
1163 0 : aAdj.SetLastBlock( eLastBlock );
1164 0 : rOutSet.Put( aAdj );
1165 : }
1166 : }
1167 0 : if(m_pSnapToGridCB->IsChecked() != m_pSnapToGridCB->GetSavedValue())
1168 : {
1169 0 : rOutSet.Put(SvxParaGridItem(m_pSnapToGridCB->IsChecked(), GetWhich( SID_ATTR_PARA_SNAPTOGRID )));
1170 0 : bModified = sal_True;
1171 : }
1172 0 : if(m_pVertAlignLB->GetSavedValue() != m_pVertAlignLB->GetSelectEntryPos())
1173 : {
1174 0 : rOutSet.Put(SvxParaVertAlignItem(m_pVertAlignLB->GetSelectEntryPos(), GetWhich( SID_PARA_VERTALIGN )));
1175 0 : bModified = sal_True;
1176 : }
1177 :
1178 0 : if( m_pTextDirectionLB->IsVisible() )
1179 : {
1180 0 : SvxFrameDirection eDir = m_pTextDirectionLB->GetSelectEntryValue();
1181 0 : if( eDir != m_pTextDirectionLB->GetSavedValue() )
1182 : {
1183 0 : rOutSet.Put( SvxFrameDirectionItem( eDir, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) );
1184 0 : bModified = sal_True;
1185 : }
1186 : }
1187 :
1188 0 : return bModified;
1189 : }
1190 :
1191 0 : void SvxParaAlignTabPage::Reset( const SfxItemSet& rSet )
1192 : {
1193 0 : sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST );
1194 0 : SfxItemState eItemState = rSet.GetItemState( _nWhich );
1195 :
1196 0 : sal_uInt16 nLBSelect = 0;
1197 0 : if ( eItemState >= SFX_ITEM_AVAILABLE )
1198 : {
1199 0 : const SvxAdjustItem& rAdj = (const SvxAdjustItem&)rSet.Get( _nWhich );
1200 :
1201 0 : switch ( rAdj.GetAdjust() /*!!! ask VB rAdj.GetLastBlock()*/ )
1202 : {
1203 0 : case SVX_ADJUST_LEFT: m_pLeft->Check(); break;
1204 :
1205 0 : case SVX_ADJUST_RIGHT: m_pRight->Check(); break;
1206 :
1207 0 : case SVX_ADJUST_CENTER: m_pCenter->Check(); break;
1208 :
1209 0 : case SVX_ADJUST_BLOCK: m_pJustify->Check(); break;
1210 : default: ; //prevent warning
1211 : }
1212 0 : sal_Bool bEnable = m_pJustify->IsChecked();
1213 0 : m_pLastLineFT->Enable(bEnable);
1214 0 : m_pLastLineLB->Enable(bEnable);
1215 0 : m_pExpandCB->Enable(bEnable);
1216 :
1217 0 : m_pExpandCB->Check(SVX_ADJUST_BLOCK == rAdj.GetOneWord());
1218 0 : switch(rAdj.GetLastBlock())
1219 : {
1220 0 : case SVX_ADJUST_LEFT: nLBSelect = 0; break;
1221 :
1222 0 : case SVX_ADJUST_CENTER: nLBSelect = 1; break;
1223 :
1224 0 : case SVX_ADJUST_BLOCK: nLBSelect = 2; break;
1225 : default: ; //prevent warning
1226 : }
1227 : }
1228 : else
1229 : {
1230 0 : m_pLeft->Check( sal_False );
1231 0 : m_pRight->Check( sal_False );
1232 0 : m_pCenter->Check( sal_False );
1233 0 : m_pJustify->Check( sal_False );
1234 : }
1235 0 : m_pLastLineLB->SelectEntryPos(nLBSelect);
1236 :
1237 0 : sal_uInt16 nHtmlMode = GetHtmlMode_Impl(rSet);
1238 0 : if(nHtmlMode & HTMLMODE_ON)
1239 : {
1240 0 : m_pLastLineLB->Hide();
1241 0 : m_pLastLineFT->Hide();
1242 0 : m_pExpandCB->Hide();
1243 0 : if(!(nHtmlMode & HTMLMODE_FULL_STYLES) )
1244 0 : m_pJustify->Disable();
1245 0 : m_pSnapToGridCB->Show(sal_False);
1246 : }
1247 0 : _nWhich = GetWhich(SID_ATTR_PARA_SNAPTOGRID);
1248 0 : eItemState = rSet.GetItemState( _nWhich );
1249 0 : if ( eItemState >= SFX_ITEM_AVAILABLE )
1250 : {
1251 0 : const SvxParaGridItem& rSnap = (const SvxParaGridItem&)rSet.Get( _nWhich );
1252 0 : m_pSnapToGridCB->Check(rSnap.GetValue());
1253 : }
1254 :
1255 0 : _nWhich = GetWhich( SID_PARA_VERTALIGN );
1256 0 : eItemState = rSet.GetItemState( _nWhich );
1257 :
1258 0 : if ( eItemState >= SFX_ITEM_AVAILABLE )
1259 : {
1260 0 : m_pVertAlignFL->Show();
1261 :
1262 0 : const SvxParaVertAlignItem& rAlign = (const SvxParaVertAlignItem&)rSet.Get( _nWhich );
1263 :
1264 0 : m_pVertAlignLB->SelectEntryPos(rAlign.GetValue());
1265 : }
1266 :
1267 0 : _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION );
1268 : //text direction
1269 0 : if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( _nWhich ) )
1270 : {
1271 0 : const SvxFrameDirectionItem& rFrameDirItem = ( const SvxFrameDirectionItem& ) rSet.Get( _nWhich );
1272 0 : m_pTextDirectionLB->SelectEntryValue( (SvxFrameDirection)rFrameDirItem.GetValue() );
1273 0 : m_pTextDirectionLB->SaveValue();
1274 : }
1275 :
1276 0 : m_pSnapToGridCB->SaveValue();
1277 0 : m_pVertAlignLB->SaveValue();
1278 0 : m_pLeft->SaveValue();
1279 0 : m_pRight->SaveValue();
1280 0 : m_pCenter->SaveValue();
1281 0 : m_pJustify->SaveValue();
1282 0 : m_pLastLineLB->SaveValue();
1283 0 : m_pExpandCB->SaveValue();
1284 :
1285 0 : UpdateExample_Impl(sal_True);
1286 0 : }
1287 :
1288 0 : IMPL_LINK_NOARG(SvxParaAlignTabPage, AlignHdl_Impl)
1289 : {
1290 0 : sal_Bool bJustify = m_pJustify->IsChecked();
1291 0 : m_pLastLineFT->Enable(bJustify);
1292 0 : m_pLastLineLB->Enable(bJustify);
1293 0 : m_pExpandCB->Enable(bJustify);
1294 0 : UpdateExample_Impl(sal_False);
1295 0 : return 0;
1296 : }
1297 :
1298 0 : IMPL_LINK_NOARG(SvxParaAlignTabPage, LastLineHdl_Impl)
1299 : {
1300 0 : UpdateExample_Impl(sal_False);
1301 0 : return 0;
1302 : }
1303 :
1304 0 : IMPL_LINK_NOARG(SvxParaAlignTabPage, TextDirectionHdl_Impl)
1305 : {
1306 0 : SvxFrameDirection eDir = m_pTextDirectionLB->GetSelectEntryValue();
1307 0 : switch ( eDir )
1308 : {
1309 : // check the default alignment for this text direction
1310 0 : case FRMDIR_HORI_LEFT_TOP : m_pLeft->Check( sal_True ); break;
1311 0 : case FRMDIR_HORI_RIGHT_TOP : m_pRight->Check( sal_True ); break;
1312 0 : case FRMDIR_ENVIRONMENT : /* do nothing */ break;
1313 : default:
1314 : {
1315 : SAL_WARN( "cui.tabpages", "SvxParaAlignTabPage::TextDirectionHdl_Impl(): other directions not supported" );
1316 : }
1317 : }
1318 :
1319 0 : return 0;
1320 : }
1321 :
1322 0 : void SvxParaAlignTabPage::UpdateExample_Impl( sal_Bool bAll )
1323 : {
1324 0 : if ( m_pLeft->IsChecked() )
1325 0 : m_pExampleWin->SetAdjust( SVX_ADJUST_LEFT );
1326 0 : else if ( m_pRight->IsChecked() )
1327 0 : m_pExampleWin->SetAdjust( SVX_ADJUST_RIGHT );
1328 0 : else if ( m_pCenter->IsChecked() )
1329 0 : m_pExampleWin->SetAdjust( SVX_ADJUST_CENTER );
1330 0 : else if ( m_pJustify->IsChecked() )
1331 : {
1332 0 : m_pExampleWin->SetAdjust( SVX_ADJUST_BLOCK );
1333 0 : SvxAdjust eLastBlock = SVX_ADJUST_LEFT;
1334 0 : sal_uInt16 nLBPos = m_pLastLineLB->GetSelectEntryPos();
1335 0 : if(nLBPos == 1)
1336 0 : eLastBlock = SVX_ADJUST_CENTER;
1337 0 : else if(nLBPos == 2)
1338 0 : eLastBlock = SVX_ADJUST_BLOCK;
1339 0 : m_pExampleWin->SetLastLine( eLastBlock );
1340 : }
1341 :
1342 0 : m_pExampleWin->Draw( bAll );
1343 0 : }
1344 :
1345 0 : void SvxParaAlignTabPage::EnableJustifyExt()
1346 : {
1347 0 : m_pLastLineFT->Show();
1348 0 : m_pLastLineLB->Show();
1349 0 : m_pExpandCB->Show();
1350 0 : SvtLanguageOptions aCJKOptions;
1351 0 : if(aCJKOptions.IsAsianTypographyEnabled())
1352 0 : m_pSnapToGridCB->Show();
1353 :
1354 0 : }
1355 :
1356 0 : void SvxParaAlignTabPage::PageCreated (SfxAllItemSet aSet)
1357 : {
1358 0 : SFX_ITEMSET_ARG (&aSet,pBoolItem,SfxBoolItem,SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT,sal_False);
1359 0 : if (pBoolItem)
1360 0 : if(pBoolItem->GetValue())
1361 0 : EnableJustifyExt();
1362 0 : }
1363 :
1364 0 : SfxTabPage* SvxExtParagraphTabPage::Create( Window* pParent,
1365 : const SfxItemSet& rSet )
1366 : {
1367 0 : return new SvxExtParagraphTabPage( pParent, rSet );
1368 : }
1369 :
1370 : // -----------------------------------------------------------------------
1371 :
1372 0 : sal_Bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet& rOutSet )
1373 : {
1374 0 : sal_Bool bModified = sal_False;
1375 0 : sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1376 0 : const TriState eHyphenState = m_pHyphenBox->GetState();
1377 0 : const SfxPoolItem* pOld = GetOldItem( rOutSet, SID_ATTR_PARA_HYPHENZONE );
1378 :
1379 0 : if ( eHyphenState != m_pHyphenBox->GetSavedValue() ||
1380 0 : m_pExtHyphenBeforeBox->IsValueModified() ||
1381 0 : m_pExtHyphenAfterBox->IsValueModified() ||
1382 0 : m_pMaxHyphenEdit->IsValueModified() )
1383 : {
1384 : SvxHyphenZoneItem aHyphen(
1385 0 : (const SvxHyphenZoneItem&)GetItemSet().Get( _nWhich ) );
1386 0 : aHyphen.SetHyphen( eHyphenState == STATE_CHECK );
1387 :
1388 0 : if ( eHyphenState == STATE_CHECK )
1389 : {
1390 0 : aHyphen.GetMinLead() = (sal_uInt8)m_pExtHyphenBeforeBox->GetValue();
1391 0 : aHyphen.GetMinTrail() = (sal_uInt8)m_pExtHyphenAfterBox->GetValue();
1392 : }
1393 0 : aHyphen.GetMaxHyphens() = (sal_uInt8)m_pMaxHyphenEdit->GetValue();
1394 :
1395 0 : if ( !pOld ||
1396 0 : !( *(SvxHyphenZoneItem*)pOld == aHyphen ) ||
1397 0 : eHyphenState != m_pHyphenBox->GetSavedValue())
1398 : {
1399 0 : rOutSet.Put( aHyphen );
1400 0 : bModified = sal_True;
1401 0 : }
1402 : }
1403 :
1404 0 : if (m_pPagenumEdit->IsEnabled() && m_pPagenumEdit->IsValueModified())
1405 : {
1406 : SfxUInt16Item aPageNum( SID_ATTR_PARA_PAGENUM,
1407 0 : (sal_uInt16)m_pPagenumEdit->GetValue() );
1408 :
1409 0 : pOld = GetOldItem( rOutSet, SID_ATTR_PARA_PAGENUM );
1410 :
1411 0 : if ( !pOld || ( (const SfxUInt16Item*)pOld )->GetValue() != aPageNum.GetValue() )
1412 : {
1413 0 : rOutSet.Put( aPageNum );
1414 0 : bModified = sal_True;
1415 0 : }
1416 : }
1417 :
1418 : // pagebreak
1419 :
1420 0 : TriState eState = m_pApplyCollBtn->GetState();
1421 0 : bool bIsPageModel = false;
1422 :
1423 0 : _nWhich = GetWhich( SID_ATTR_PARA_MODEL );
1424 0 : String sPage;
1425 0 : if ( eState != m_pApplyCollBtn->GetSavedValue() ||
1426 0 : ( STATE_CHECK == eState &&
1427 0 : m_pApplyCollBox->GetSelectEntryPos() != m_pApplyCollBox->GetSavedValue() ) )
1428 : {
1429 0 : if ( eState == STATE_CHECK )
1430 : {
1431 0 : sPage = m_pApplyCollBox->GetSelectEntry();
1432 0 : bIsPageModel = 0 != sPage.Len();
1433 : }
1434 0 : pOld = GetOldItem( rOutSet, SID_ATTR_PARA_MODEL );
1435 :
1436 0 : if ( !pOld || ( (const SvxPageModelItem*)pOld )->GetValue() != sPage )
1437 : {
1438 0 : rOutSet.Put( SvxPageModelItem( sPage, sal_False, _nWhich ) );
1439 0 : bModified = sal_True;
1440 : }
1441 : else
1442 0 : bIsPageModel = false;
1443 : }
1444 0 : else if(STATE_CHECK == eState && m_pApplyCollBtn->IsEnabled())
1445 0 : bIsPageModel = true;
1446 : else
1447 0 : rOutSet.Put( SvxPageModelItem( sPage, sal_False, _nWhich ) );
1448 :
1449 0 : _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
1450 :
1451 0 : if ( bIsPageModel )
1452 : // if PageModel is turned on, always turn off PageBreak
1453 0 : rOutSet.Put( SvxFmtBreakItem( SVX_BREAK_NONE, _nWhich ) );
1454 : else
1455 : {
1456 0 : eState = m_pPageBreakBox->GetState();
1457 0 : SfxItemState eModelState = GetItemSet().GetItemState(SID_ATTR_PARA_MODEL, sal_False);
1458 :
1459 0 : if ( (eModelState == SFX_ITEM_SET && STATE_CHECK == m_pPageBreakBox->GetState()) ||
1460 0 : eState != m_pPageBreakBox->GetSavedValue() ||
1461 0 : m_pBreakTypeLB->GetSelectEntryPos() != m_pBreakTypeLB->GetSavedValue() ||
1462 0 : m_pBreakPositionLB->GetSelectEntryPos() != m_pBreakPositionLB->GetSavedValue() )
1463 : {
1464 : const SvxFmtBreakItem rOldBreak(
1465 0 : (const SvxFmtBreakItem&)GetItemSet().Get( _nWhich ));
1466 0 : SvxFmtBreakItem aBreak(rOldBreak.GetBreak(), rOldBreak.Which());
1467 :
1468 0 : switch ( eState )
1469 : {
1470 : case STATE_CHECK:
1471 : {
1472 0 : sal_Bool bBefore = m_pBreakPositionLB->GetSelectEntryPos() == 0;
1473 :
1474 0 : if ( m_pBreakTypeLB->GetSelectEntryPos() == 0 )
1475 : {
1476 0 : if ( bBefore )
1477 0 : aBreak.SetValue( SVX_BREAK_PAGE_BEFORE );
1478 : else
1479 0 : aBreak.SetValue( SVX_BREAK_PAGE_AFTER );
1480 : }
1481 : else
1482 : {
1483 0 : if ( bBefore )
1484 0 : aBreak.SetValue( SVX_BREAK_COLUMN_BEFORE );
1485 : else
1486 0 : aBreak.SetValue( SVX_BREAK_COLUMN_AFTER );
1487 : }
1488 0 : break;
1489 : }
1490 :
1491 : case STATE_NOCHECK:
1492 0 : aBreak.SetValue( SVX_BREAK_NONE );
1493 0 : break;
1494 : default: ; //prevent warning
1495 : }
1496 0 : pOld = GetOldItem( rOutSet, SID_ATTR_PARA_PAGEBREAK );
1497 :
1498 0 : if ( eState != m_pPageBreakBox->GetSavedValue() ||
1499 0 : !pOld || !( *(const SvxFmtBreakItem*)pOld == aBreak ) )
1500 : {
1501 0 : bModified = sal_True;
1502 0 : rOutSet.Put( aBreak );
1503 0 : }
1504 : }
1505 : }
1506 :
1507 :
1508 : // paragraph split
1509 0 : _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
1510 0 : eState = m_pKeepTogetherBox->GetState();
1511 :
1512 0 : if ( eState != m_pKeepTogetherBox->GetSavedValue() )
1513 : {
1514 0 : pOld = GetOldItem( rOutSet, SID_ATTR_PARA_SPLIT );
1515 :
1516 0 : if ( !pOld || ( (const SvxFmtSplitItem*)pOld )->GetValue() !=
1517 0 : ( eState == STATE_NOCHECK ) )
1518 : {
1519 0 : rOutSet.Put( SvxFmtSplitItem( eState == STATE_NOCHECK, _nWhich ) );
1520 0 : bModified = sal_True;
1521 : }
1522 : }
1523 :
1524 : // keep paragraphs
1525 0 : _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
1526 0 : eState = m_pKeepParaBox->GetState();
1527 :
1528 0 : if ( eState != m_pKeepParaBox->GetSavedValue() )
1529 : {
1530 0 : pOld = GetOldItem( rOutSet, SID_ATTR_PARA_KEEP );
1531 :
1532 : // if the status has changed, putting is necessary
1533 0 : rOutSet.Put( SvxFmtKeepItem( eState == STATE_CHECK, _nWhich ) );
1534 0 : bModified = sal_True;
1535 : }
1536 :
1537 : // widows and orphans
1538 0 : _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
1539 0 : eState = m_pWidowBox->GetState();
1540 :
1541 0 : if ( eState != m_pWidowBox->GetSavedValue() ||
1542 0 : m_pWidowRowNo->IsValueModified() )
1543 : {
1544 : SvxWidowsItem rItem( eState == STATE_CHECK ?
1545 0 : (sal_uInt8)m_pWidowRowNo->GetValue() : 0, _nWhich );
1546 0 : pOld = GetOldItem( rOutSet, SID_ATTR_PARA_WIDOWS );
1547 :
1548 0 : if ( eState != m_pWidowBox->GetSavedValue() || !pOld || !( *(const SvxWidowsItem*)pOld == rItem ) )
1549 : {
1550 0 : rOutSet.Put( rItem );
1551 0 : bModified = sal_True;
1552 0 : }
1553 : }
1554 :
1555 0 : _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
1556 0 : eState = m_pOrphanBox->GetState();
1557 :
1558 0 : if ( eState != m_pOrphanBox->GetSavedValue() ||
1559 0 : m_pOrphanRowNo->IsValueModified() )
1560 : {
1561 : SvxOrphansItem rItem( eState == STATE_CHECK ?
1562 0 : (sal_uInt8)m_pOrphanRowNo->GetValue() : 0, _nWhich );
1563 0 : pOld = GetOldItem( rOutSet, SID_ATTR_PARA_ORPHANS );
1564 :
1565 0 : if ( eState != m_pOrphanBox->GetSavedValue() ||
1566 0 : !pOld ||
1567 0 : !( *(const SvxOrphansItem*)pOld == rItem ) )
1568 : {
1569 0 : rOutSet.Put( rItem );
1570 0 : bModified = sal_True;
1571 0 : }
1572 : }
1573 :
1574 0 : return bModified;
1575 : }
1576 :
1577 : // -----------------------------------------------------------------------
1578 :
1579 0 : void SvxExtParagraphTabPage::Reset( const SfxItemSet& rSet )
1580 : {
1581 0 : sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE );
1582 0 : SfxItemState eItemState = rSet.GetItemState( _nWhich );
1583 :
1584 0 : sal_Bool bItemAvailable = eItemState >= SFX_ITEM_AVAILABLE;
1585 0 : sal_Bool bIsHyphen = sal_False;
1586 0 : if( !bHtmlMode && bItemAvailable )
1587 : {
1588 : const SvxHyphenZoneItem& rHyphen =
1589 0 : (const SvxHyphenZoneItem&)rSet.Get( _nWhich );
1590 0 : m_pHyphenBox->EnableTriState( sal_False );
1591 :
1592 0 : bIsHyphen = rHyphen.IsHyphen();
1593 0 : m_pHyphenBox->SetState( bIsHyphen ? STATE_CHECK : STATE_NOCHECK );
1594 :
1595 0 : m_pExtHyphenBeforeBox->SetValue( rHyphen.GetMinLead() );
1596 0 : m_pExtHyphenAfterBox->SetValue( rHyphen.GetMinTrail() );
1597 0 : m_pMaxHyphenEdit->SetValue( rHyphen.GetMaxHyphens() );
1598 : }
1599 : else
1600 : {
1601 0 : m_pHyphenBox->SetState( STATE_DONTKNOW );
1602 : }
1603 0 : sal_Bool bEnable = bItemAvailable && bIsHyphen;
1604 0 : m_pExtHyphenBeforeBox->Enable(bEnable);
1605 0 : m_pExtHyphenAfterBox->Enable(bEnable);
1606 0 : m_pBeforeText->Enable(bEnable);
1607 0 : m_pAfterText->Enable(bEnable);
1608 0 : m_pMaxHyphenLabel->Enable(bEnable);
1609 0 : m_pMaxHyphenEdit->Enable(bEnable);
1610 :
1611 0 : _nWhich = GetWhich( SID_ATTR_PARA_PAGENUM );
1612 :
1613 0 : if ( rSet.GetItemState(_nWhich) >= SFX_ITEM_AVAILABLE )
1614 : {
1615 : const sal_uInt16 nPageNum =
1616 0 : ( (const SfxUInt16Item&)rSet.Get( _nWhich ) ).GetValue();
1617 0 : m_pPagenumEdit->SetValue( nPageNum );
1618 : }
1619 :
1620 0 : if ( bPageBreak )
1621 : {
1622 : // first handle PageModel
1623 0 : _nWhich = GetWhich( SID_ATTR_PARA_MODEL );
1624 0 : sal_Bool bIsPageModel = sal_False;
1625 0 : eItemState = rSet.GetItemState( _nWhich );
1626 :
1627 0 : if ( eItemState >= SFX_ITEM_SET )
1628 : {
1629 0 : m_pApplyCollBtn->EnableTriState( sal_False );
1630 :
1631 : const SvxPageModelItem& rModel =
1632 0 : (const SvxPageModelItem&)rSet.Get( _nWhich );
1633 0 : String aStr( rModel.GetValue() );
1634 :
1635 0 : if ( aStr.Len() &&
1636 0 : m_pApplyCollBox->GetEntryPos( aStr ) != LISTBOX_ENTRY_NOTFOUND )
1637 : {
1638 0 : m_pApplyCollBox->SelectEntry( aStr );
1639 0 : m_pApplyCollBtn->SetState( STATE_CHECK );
1640 0 : bIsPageModel = sal_True;
1641 :
1642 0 : m_pPageBreakBox->Enable();
1643 0 : m_pPageBreakBox->EnableTriState( sal_False );
1644 0 : m_pBreakTypeFT->Enable();
1645 0 : m_pBreakTypeLB->Enable();
1646 0 : m_pBreakPositionFT->Enable();
1647 0 : m_pBreakPositionLB->Enable();
1648 0 : m_pApplyCollBtn->Enable();
1649 0 : m_pPageBreakBox->SetState( STATE_CHECK );
1650 :
1651 : //select page break
1652 0 : m_pBreakTypeLB->SelectEntryPos(0);
1653 : //select break before
1654 0 : m_pBreakPositionLB->SelectEntryPos(0);
1655 : }
1656 : else
1657 : {
1658 0 : m_pApplyCollBox->SetNoSelection();
1659 0 : m_pApplyCollBtn->SetState( STATE_NOCHECK );
1660 0 : }
1661 : }
1662 0 : else if ( SFX_ITEM_DONTCARE == eItemState )
1663 : {
1664 0 : m_pApplyCollBtn->EnableTriState( sal_True );
1665 0 : m_pApplyCollBtn->SetState( STATE_DONTKNOW );
1666 0 : m_pApplyCollBox->SetNoSelection();
1667 : }
1668 : else
1669 : {
1670 0 : m_pApplyCollBtn->Enable(sal_False);
1671 0 : m_pApplyCollBox->Enable(sal_False);
1672 0 : m_pPagenumEdit->Enable(sal_False);
1673 0 : m_pPagenumText->Enable(sal_False);
1674 : }
1675 :
1676 0 : if ( !bIsPageModel )
1677 : {
1678 0 : _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK );
1679 0 : eItemState = rSet.GetItemState( _nWhich );
1680 :
1681 0 : if ( eItemState >= SFX_ITEM_AVAILABLE )
1682 : {
1683 : const SvxFmtBreakItem& rPageBreak =
1684 0 : (const SvxFmtBreakItem&)rSet.Get( _nWhich );
1685 :
1686 0 : SvxBreak eBreak = (SvxBreak)rPageBreak.GetValue();
1687 :
1688 : // PageBreak not via CTRL-RETURN,
1689 : // then CheckBox can be freed
1690 0 : m_pPageBreakBox->Enable();
1691 0 : m_pPageBreakBox->EnableTriState( sal_False );
1692 0 : m_pBreakTypeFT->Enable();
1693 0 : m_pBreakTypeLB->Enable();
1694 0 : m_pBreakPositionFT->Enable();
1695 0 : m_pBreakPositionLB->Enable();
1696 :
1697 0 : m_pPageBreakBox->SetState( STATE_CHECK );
1698 :
1699 0 : sal_Bool _bEnable = eBreak != SVX_BREAK_NONE &&
1700 0 : eBreak != SVX_BREAK_COLUMN_BEFORE &&
1701 0 : eBreak != SVX_BREAK_COLUMN_AFTER;
1702 0 : m_pApplyCollBtn->Enable(_bEnable);
1703 0 : if(!_bEnable)
1704 : {
1705 0 : m_pApplyCollBox->Enable(_bEnable);
1706 0 : m_pPagenumEdit->Enable(_bEnable);
1707 : }
1708 :
1709 0 : if ( eBreak == SVX_BREAK_NONE )
1710 0 : m_pPageBreakBox->SetState( STATE_NOCHECK );
1711 :
1712 0 : sal_uInt16 nType = 0; // selection position in break type ListBox : Page
1713 0 : sal_uInt16 nPosition = 0; // selection position in break position ListBox : Before
1714 0 : switch ( eBreak )
1715 : {
1716 : case SVX_BREAK_PAGE_BEFORE:
1717 0 : break;
1718 : case SVX_BREAK_PAGE_AFTER:
1719 0 : nPosition = 1;
1720 0 : break;
1721 : case SVX_BREAK_COLUMN_BEFORE:
1722 0 : nType = 1;
1723 0 : break;
1724 : case SVX_BREAK_COLUMN_AFTER:
1725 0 : nType = 1;
1726 0 : nPosition = 1;
1727 0 : break;
1728 : default: ;//prevent warning
1729 : }
1730 0 : m_pBreakTypeLB->SelectEntryPos(nType);
1731 0 : m_pBreakPositionLB->SelectEntryPos(nPosition);
1732 : }
1733 0 : else if ( SFX_ITEM_DONTCARE == eItemState )
1734 0 : m_pPageBreakBox->SetState( STATE_DONTKNOW );
1735 : else
1736 : {
1737 0 : m_pPageBreakBox->Enable(sal_False);
1738 0 : m_pBreakTypeFT->Enable(sal_False);
1739 0 : m_pBreakTypeLB->Enable(sal_False);
1740 0 : m_pBreakPositionFT->Enable(sal_False);
1741 0 : m_pBreakPositionLB->Enable(sal_False);
1742 : }
1743 : }
1744 :
1745 0 : PageBreakPosHdl_Impl( m_pBreakPositionLB );
1746 0 : PageBreakHdl_Impl( m_pPageBreakBox );
1747 : }
1748 :
1749 0 : _nWhich = GetWhich( SID_ATTR_PARA_KEEP );
1750 0 : eItemState = rSet.GetItemState( _nWhich );
1751 :
1752 0 : if ( eItemState >= SFX_ITEM_AVAILABLE )
1753 : {
1754 0 : m_pKeepParaBox->EnableTriState( sal_False );
1755 : const SvxFmtKeepItem& rKeep =
1756 0 : (const SvxFmtKeepItem&)rSet.Get( _nWhich );
1757 :
1758 0 : if ( rKeep.GetValue() )
1759 0 : m_pKeepParaBox->SetState( STATE_CHECK );
1760 : else
1761 0 : m_pKeepParaBox->SetState( STATE_NOCHECK );
1762 : }
1763 0 : else if ( SFX_ITEM_DONTCARE == eItemState )
1764 0 : m_pKeepParaBox->SetState( STATE_DONTKNOW );
1765 : else
1766 0 : m_pKeepParaBox->Enable(sal_False);
1767 :
1768 0 : _nWhich = GetWhich( SID_ATTR_PARA_SPLIT );
1769 0 : eItemState = rSet.GetItemState( _nWhich );
1770 :
1771 0 : if ( eItemState >= SFX_ITEM_AVAILABLE )
1772 : {
1773 : const SvxFmtSplitItem& rSplit =
1774 0 : (const SvxFmtSplitItem&)rSet.Get( _nWhich );
1775 0 : m_pKeepTogetherBox->EnableTriState( sal_False );
1776 :
1777 0 : if ( !rSplit.GetValue() )
1778 0 : m_pKeepTogetherBox->SetState( STATE_CHECK );
1779 : else
1780 : {
1781 0 : m_pKeepTogetherBox->SetState( STATE_NOCHECK );
1782 :
1783 : // widows and orphans
1784 0 : m_pWidowBox->Enable();
1785 0 : _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS );
1786 0 : SfxItemState eTmpState = rSet.GetItemState( _nWhich );
1787 :
1788 0 : if ( eTmpState >= SFX_ITEM_AVAILABLE )
1789 : {
1790 : const SvxWidowsItem& rWidow =
1791 0 : (const SvxWidowsItem&)rSet.Get( _nWhich );
1792 0 : m_pWidowBox->EnableTriState( sal_False );
1793 0 : const sal_uInt16 nLines = rWidow.GetValue();
1794 :
1795 0 : sal_Bool _bEnable = nLines > 0;
1796 0 : m_pWidowRowNo->SetValue( m_pWidowRowNo->Normalize( nLines ) );
1797 0 : m_pWidowBox->SetState( _bEnable ? STATE_CHECK : STATE_NOCHECK);
1798 0 : m_pWidowRowNo->Enable(_bEnable);
1799 : //m_pWidowRowLabel->Enable(_bEnable);
1800 :
1801 : }
1802 0 : else if ( SFX_ITEM_DONTCARE == eTmpState )
1803 0 : m_pWidowBox->SetState( STATE_DONTKNOW );
1804 : else
1805 0 : m_pWidowBox->Enable(sal_False);
1806 :
1807 0 : m_pOrphanBox->Enable();
1808 0 : _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS );
1809 0 : eTmpState = rSet.GetItemState( _nWhich );
1810 :
1811 0 : if ( eTmpState >= SFX_ITEM_AVAILABLE )
1812 : {
1813 : const SvxOrphansItem& rOrphan =
1814 0 : (const SvxOrphansItem&)rSet.Get( _nWhich );
1815 0 : const sal_uInt16 nLines = rOrphan.GetValue();
1816 0 : m_pOrphanBox->EnableTriState( sal_False );
1817 :
1818 0 : sal_Bool _bEnable = nLines > 0;
1819 0 : m_pOrphanBox->SetState( _bEnable ? STATE_CHECK : STATE_NOCHECK);
1820 0 : m_pOrphanRowNo->SetValue( m_pOrphanRowNo->Normalize( nLines ) );
1821 0 : m_pOrphanRowNo->Enable(_bEnable);
1822 0 : m_pOrphanRowLabel->Enable(_bEnable);
1823 :
1824 : }
1825 0 : else if ( SFX_ITEM_DONTCARE == eTmpState )
1826 0 : m_pOrphanBox->SetState( STATE_DONTKNOW );
1827 : else
1828 0 : m_pOrphanBox->Enable(sal_False);
1829 : }
1830 : }
1831 0 : else if ( SFX_ITEM_DONTCARE == eItemState )
1832 0 : m_pKeepTogetherBox->SetState( STATE_DONTKNOW );
1833 : else
1834 0 : m_pKeepTogetherBox->Enable(sal_False);
1835 :
1836 : // so that everything is enabled correctly
1837 0 : KeepTogetherHdl_Impl( 0 );
1838 0 : WidowHdl_Impl( 0 );
1839 0 : OrphanHdl_Impl( 0 );
1840 :
1841 0 : m_pHyphenBox->SaveValue();
1842 0 : m_pExtHyphenBeforeBox->SaveValue();
1843 0 : m_pExtHyphenAfterBox->SaveValue();
1844 0 : m_pMaxHyphenEdit->SaveValue();
1845 0 : m_pPageBreakBox->SaveValue();
1846 0 : m_pBreakPositionLB->SaveValue();
1847 0 : m_pBreakTypeLB->SaveValue();
1848 0 : m_pApplyCollBtn->SaveValue();
1849 0 : m_pApplyCollBox->SaveValue();
1850 0 : m_pPagenumEdit->SaveValue();
1851 0 : m_pKeepTogetherBox->SaveValue();
1852 0 : m_pKeepParaBox->SaveValue();
1853 0 : m_pWidowBox->SaveValue();
1854 0 : m_pOrphanBox->SaveValue();
1855 0 : }
1856 :
1857 : // -----------------------------------------------------------------------
1858 :
1859 0 : int SvxExtParagraphTabPage::DeactivatePage( SfxItemSet* _pSet )
1860 : {
1861 0 : if ( _pSet )
1862 0 : FillItemSet( *_pSet );
1863 0 : return LEAVE_PAGE;
1864 : }
1865 :
1866 : // -----------------------------------------------------------------------
1867 :
1868 0 : void SvxExtParagraphTabPage::DisablePageBreak()
1869 : {
1870 0 : bPageBreak = sal_False;
1871 0 : m_pPageBreakBox->Enable(sal_False);
1872 0 : m_pBreakTypeLB->RemoveEntry(0);
1873 0 : m_pBreakPositionFT->Enable(sal_False);
1874 0 : m_pBreakPositionLB->Enable(sal_False);
1875 0 : m_pApplyCollBtn->Enable(sal_False);
1876 0 : m_pApplyCollBox->Enable(sal_False);
1877 0 : m_pPagenumEdit->Enable(sal_False);
1878 0 : }
1879 :
1880 : // -----------------------------------------------------------------------
1881 :
1882 0 : SvxExtParagraphTabPage::SvxExtParagraphTabPage( Window* pParent, const SfxItemSet& rAttr ) :
1883 : SfxTabPage( pParent, "TextFlowPage","cui/ui/textflowpage.ui", rAttr ),
1884 :
1885 : bPageBreak ( sal_True ),
1886 : bHtmlMode ( sal_False ),
1887 0 : nStdPos ( 0 )
1888 : {
1889 : // Hyphenation
1890 0 : get(m_pHyphenBox,"checkAuto");
1891 0 : get(m_pExtHyphenBeforeBox,"spinLineEnd");
1892 0 : get(m_pExtHyphenAfterBox,"spinLineBegin");
1893 0 : get(m_pMaxHyphenEdit,"spinMaxNum");
1894 0 : get(m_pBeforeText,"labelLineBegin");
1895 0 : get(m_pAfterText,"labelLineEnd");
1896 0 : get(m_pMaxHyphenLabel,"labelMaxNum");
1897 :
1898 : //Page break
1899 0 : get(m_pPageBreakBox,"checkInsert");
1900 0 : get(m_pBreakTypeLB,"comboBreakType");
1901 0 : get(m_pBreakPositionLB,"comboBreakPosition");
1902 0 : get(m_pApplyCollBtn,"checkPageStyle");
1903 0 : get(m_pApplyCollBox,"comboPageStyle");
1904 0 : get(m_pPagenumEdit,"spinPageNumber");
1905 0 : get(m_pBreakTypeFT,"labelType");
1906 0 : get(m_pBreakPositionFT,"labelPosition");
1907 0 : get(m_pPagenumText,"labelPageNum");
1908 :
1909 :
1910 : // Options
1911 0 : get(m_pKeepTogetherBox,"checkSplitPara");
1912 0 : get(m_pKeepParaBox,"checkKeepPara");
1913 :
1914 0 : get(m_pOrphanBox,"checkOrphan");
1915 0 : get(m_pOrphanRowNo,"spinOrphan");
1916 0 : get(m_pOrphanRowLabel,"labelOrphan");
1917 :
1918 0 : get(m_pWidowBox,"checkWidow");
1919 0 : get(m_pWidowRowNo,"spinWidow");
1920 0 : get(m_pWidowRowLabel,"labelWidow");
1921 :
1922 0 : m_pApplyCollBox->SetAccessibleRelationLabeledBy(m_pApplyCollBtn);
1923 0 : m_pApplyCollBox->SetAccessibleName(String(CUI_RES(STR_PAGE_STYLE)));
1924 :
1925 0 : m_pOrphanRowNo->SetAccessibleRelationLabeledBy(m_pOrphanBox);
1926 0 : m_pWidowRowNo->SetAccessibleRelationLabeledBy(m_pWidowBox);
1927 :
1928 : // this page needs ExchangeSupport
1929 0 : SetExchangeSupport();
1930 :
1931 0 : m_pHyphenBox->SetClickHdl( LINK( this, SvxExtParagraphTabPage, HyphenClickHdl_Impl ) );
1932 0 : m_pPageBreakBox->SetClickHdl( LINK( this, SvxExtParagraphTabPage, PageBreakHdl_Impl ) );
1933 0 : m_pKeepTogetherBox->SetClickHdl( LINK( this, SvxExtParagraphTabPage, KeepTogetherHdl_Impl ) );
1934 0 : m_pWidowBox->SetClickHdl( LINK( this, SvxExtParagraphTabPage, WidowHdl_Impl ) );
1935 0 : m_pOrphanBox->SetClickHdl( LINK( this, SvxExtParagraphTabPage, OrphanHdl_Impl ) );
1936 0 : m_pApplyCollBtn->SetClickHdl( LINK( this, SvxExtParagraphTabPage, ApplyCollClickHdl_Impl ) );
1937 0 : m_pBreakTypeLB->SetSelectHdl( LINK( this, SvxExtParagraphTabPage, PageBreakTypeHdl_Impl ) );
1938 0 : m_pBreakPositionLB->SetSelectHdl( LINK( this, SvxExtParagraphTabPage, PageBreakPosHdl_Impl ) );
1939 :
1940 0 : SfxObjectShell* pSh = SfxObjectShell::Current();
1941 0 : if ( pSh )
1942 : {
1943 0 : SfxStyleSheetBasePool* pPool = pSh->GetStyleSheetPool();
1944 0 : pPool->SetSearchMask( SFX_STYLE_FAMILY_PAGE );
1945 0 : SfxStyleSheetBase* pStyle = pPool->First();
1946 0 : String aStdName;
1947 :
1948 0 : while( pStyle )
1949 : {
1950 0 : if ( aStdName.Len() == 0 )
1951 : // first style == standard style
1952 0 : aStdName = pStyle->GetName();
1953 0 : m_pApplyCollBox->InsertEntry( pStyle->GetName() );
1954 0 : pStyle = pPool->Next();
1955 : }
1956 0 : nStdPos = m_pApplyCollBox->GetEntryPos( aStdName );
1957 : }
1958 :
1959 0 : sal_uInt16 nHtmlMode = GetHtmlMode_Impl( rAttr );
1960 0 : if ( nHtmlMode & HTMLMODE_ON )
1961 : {
1962 0 : bHtmlMode = sal_True;
1963 0 : m_pHyphenBox ->Enable(sal_False);
1964 0 : m_pBeforeText ->Enable(sal_False);
1965 0 : m_pExtHyphenBeforeBox ->Enable(sal_False);
1966 0 : m_pAfterText ->Enable(sal_False);
1967 0 : m_pExtHyphenAfterBox ->Enable(sal_False);
1968 0 : m_pMaxHyphenLabel ->Enable(sal_False);
1969 0 : m_pMaxHyphenEdit ->Enable(sal_False);
1970 0 : m_pPagenumText ->Enable(sal_False);
1971 0 : m_pPagenumEdit ->Enable(sal_False);
1972 : // no column break in HTML
1973 0 : m_pBreakTypeLB->RemoveEntry(1);
1974 : }
1975 0 : }
1976 :
1977 : // -----------------------------------------------------------------------
1978 :
1979 0 : SvxExtParagraphTabPage::~SvxExtParagraphTabPage()
1980 : {
1981 0 : }
1982 :
1983 : // -----------------------------------------------------------------------
1984 :
1985 0 : sal_uInt16* SvxExtParagraphTabPage::GetRanges()
1986 : {
1987 0 : return pExtRanges;
1988 : }
1989 :
1990 : // -----------------------------------------------------------------------
1991 :
1992 0 : IMPL_LINK_NOARG(SvxExtParagraphTabPage, PageBreakHdl_Impl)
1993 : {
1994 0 : switch ( m_pPageBreakBox->GetState() )
1995 : {
1996 : case STATE_CHECK:
1997 0 : m_pBreakTypeFT->Enable();
1998 0 : m_pBreakTypeLB->Enable();
1999 0 : m_pBreakPositionFT->Enable();
2000 0 : m_pBreakPositionLB->Enable();
2001 :
2002 0 : if ( 0 == m_pBreakTypeLB->GetSelectEntryPos()&&
2003 0 : 0 == m_pBreakPositionLB->GetSelectEntryPos() )
2004 : {
2005 0 : m_pApplyCollBtn->Enable();
2006 :
2007 0 : sal_Bool bEnable = STATE_CHECK == m_pApplyCollBtn->GetState() &&
2008 0 : m_pApplyCollBox->GetEntryCount();
2009 0 : m_pApplyCollBox->Enable(bEnable);
2010 0 : if(!bHtmlMode)
2011 : {
2012 0 : m_pPagenumText->Enable(bEnable);
2013 0 : m_pPagenumEdit->Enable(bEnable);
2014 : }
2015 : }
2016 0 : break;
2017 :
2018 : case STATE_NOCHECK:
2019 : case STATE_DONTKNOW:
2020 0 : m_pApplyCollBtn->SetState( STATE_NOCHECK );
2021 0 : m_pApplyCollBtn->Enable(sal_False);
2022 0 : m_pApplyCollBox->Enable(sal_False);
2023 0 : m_pPagenumText->Enable(sal_False);
2024 0 : m_pPagenumEdit->Enable(sal_False);
2025 0 : m_pBreakTypeFT->Enable(sal_False);
2026 0 : m_pBreakTypeLB->Enable(sal_False);
2027 0 : m_pBreakPositionFT->Enable(sal_False);
2028 0 : m_pBreakPositionLB->Enable(sal_False);
2029 0 : break;
2030 : }
2031 0 : return 0;
2032 : }
2033 :
2034 : // -----------------------------------------------------------------------
2035 :
2036 0 : IMPL_LINK_NOARG(SvxExtParagraphTabPage, KeepTogetherHdl_Impl)
2037 : {
2038 0 : sal_Bool bEnable = m_pKeepTogetherBox->GetState() == STATE_NOCHECK;
2039 0 : m_pWidowBox->Enable(bEnable);
2040 0 : m_pOrphanBox->Enable(bEnable);
2041 :
2042 0 : return 0;
2043 : }
2044 :
2045 : // -----------------------------------------------------------------------
2046 :
2047 0 : IMPL_LINK_NOARG(SvxExtParagraphTabPage, WidowHdl_Impl)
2048 : {
2049 0 : switch ( m_pWidowBox->GetState() )
2050 : {
2051 : case STATE_CHECK:
2052 0 : m_pWidowRowNo->Enable();
2053 0 : m_pWidowRowLabel->Enable();
2054 0 : m_pKeepTogetherBox->Enable(sal_False);
2055 0 : break;
2056 :
2057 : case STATE_NOCHECK:
2058 0 : if ( m_pOrphanBox->GetState() == STATE_NOCHECK )
2059 0 : m_pKeepTogetherBox->Enable();
2060 :
2061 : // no break
2062 : case STATE_DONTKNOW:
2063 0 : m_pWidowRowNo->Enable(sal_False);
2064 0 : m_pWidowRowLabel->Enable(sal_False);
2065 0 : break;
2066 : }
2067 0 : return 0;
2068 : }
2069 :
2070 : // -----------------------------------------------------------------------
2071 :
2072 0 : IMPL_LINK_NOARG(SvxExtParagraphTabPage, OrphanHdl_Impl)
2073 : {
2074 0 : switch( m_pOrphanBox->GetState() )
2075 : {
2076 : case STATE_CHECK:
2077 0 : m_pOrphanRowNo->Enable();
2078 0 : m_pOrphanRowLabel->Enable();
2079 0 : m_pKeepTogetherBox->Enable(sal_False);
2080 0 : break;
2081 :
2082 : case STATE_NOCHECK:
2083 0 : if ( m_pWidowBox->GetState() == STATE_NOCHECK )
2084 0 : m_pKeepTogetherBox->Enable();
2085 :
2086 : // kein break
2087 : case STATE_DONTKNOW:
2088 0 : m_pOrphanRowNo->Enable(sal_False);
2089 0 : m_pOrphanRowLabel->Enable(sal_False);
2090 0 : break;
2091 : }
2092 0 : return 0;
2093 : }
2094 :
2095 : // -----------------------------------------------------------------------
2096 :
2097 0 : IMPL_LINK_NOARG(SvxExtParagraphTabPage, HyphenClickHdl_Impl)
2098 : {
2099 :
2100 0 : sal_Bool bEnable = m_pHyphenBox->GetState() == STATE_CHECK;
2101 0 : m_pBeforeText->Enable(bEnable);
2102 0 : m_pExtHyphenBeforeBox->Enable(bEnable);
2103 0 : m_pAfterText->Enable(bEnable);
2104 0 : m_pExtHyphenAfterBox->Enable(bEnable);
2105 0 : m_pMaxHyphenLabel->Enable(bEnable);
2106 0 : m_pMaxHyphenEdit->Enable(bEnable);
2107 0 : m_pHyphenBox->SetState( bEnable ? STATE_CHECK : STATE_NOCHECK);
2108 :
2109 0 : return 0;
2110 : }
2111 :
2112 : // -----------------------------------------------------------------------
2113 :
2114 0 : IMPL_LINK_NOARG(SvxExtParagraphTabPage, ApplyCollClickHdl_Impl)
2115 : {
2116 0 : sal_Bool bEnable = sal_False;
2117 0 : if ( m_pApplyCollBtn->GetState() == STATE_CHECK &&
2118 0 : m_pApplyCollBox->GetEntryCount() )
2119 : {
2120 0 : bEnable = sal_True;
2121 0 : m_pApplyCollBox->SelectEntryPos( nStdPos );
2122 : }
2123 : else
2124 : {
2125 0 : m_pApplyCollBox->SetNoSelection();
2126 : }
2127 0 : m_pApplyCollBox->Enable(bEnable);
2128 0 : if(!bHtmlMode)
2129 : {
2130 0 : m_pPagenumText->Enable(bEnable);
2131 0 : m_pPagenumEdit->Enable(bEnable);
2132 : }
2133 0 : return 0;
2134 : }
2135 :
2136 : // -----------------------------------------------------------------------
2137 :
2138 0 : IMPL_LINK( SvxExtParagraphTabPage, PageBreakPosHdl_Impl, ListBox *, pListBox )
2139 : {
2140 0 : if ( 0 == pListBox->GetSelectEntryPos() )
2141 : {
2142 0 : m_pApplyCollBtn->Enable();
2143 :
2144 0 : sal_Bool bEnable = m_pApplyCollBtn->GetState() == STATE_CHECK &&
2145 0 : m_pApplyCollBox->GetEntryCount();
2146 :
2147 0 : m_pApplyCollBox->Enable(bEnable);
2148 0 : if(!bHtmlMode)
2149 : {
2150 0 : m_pPagenumText->Enable(bEnable);
2151 0 : m_pPagenumEdit->Enable(bEnable);
2152 : }
2153 : }
2154 0 : else if ( 1 == pListBox->GetSelectEntryPos() )
2155 : {
2156 0 : m_pApplyCollBtn->SetState( STATE_NOCHECK );
2157 0 : m_pApplyCollBtn->Enable(sal_False);
2158 0 : m_pApplyCollBox->Enable(sal_False);
2159 0 : m_pPagenumText->Enable(sal_False);
2160 0 : m_pPagenumEdit->Enable(sal_False);
2161 : }
2162 0 : return 0;
2163 : }
2164 :
2165 : // -----------------------------------------------------------------------
2166 :
2167 0 : IMPL_LINK( SvxExtParagraphTabPage, PageBreakTypeHdl_Impl, ListBox *, pListBox )
2168 : {
2169 : //column break or break break after
2170 0 : sal_uInt16 nBreakPos = m_pBreakPositionLB->GetSelectEntryPos();
2171 0 : if ( pListBox->GetSelectEntryPos() == 1 || 1 == nBreakPos)
2172 : {
2173 0 : m_pApplyCollBtn->SetState( STATE_NOCHECK );
2174 0 : m_pApplyCollBtn->Enable(sal_False);
2175 0 : m_pApplyCollBox->Enable(sal_False);
2176 0 : m_pPagenumText->Enable(sal_False);
2177 0 : m_pPagenumEdit->Enable(sal_False);
2178 : }
2179 : else
2180 0 : PageBreakPosHdl_Impl( m_pBreakPositionLB );
2181 0 : return 0;
2182 : }
2183 :
2184 0 : void SvxExtParagraphTabPage::PageCreated(SfxAllItemSet aSet)
2185 : {
2186 :
2187 :
2188 0 : SFX_ITEMSET_ARG (&aSet,pDisablePageBreakItem,SfxBoolItem,SID_DISABLE_SVXEXTPARAGRAPHTABPAGE_PAGEBREAK,sal_False);
2189 :
2190 0 : if (pDisablePageBreakItem)
2191 0 : if ( pDisablePageBreakItem->GetValue())
2192 0 : DisablePageBreak();
2193 :
2194 :
2195 0 : }
2196 :
2197 0 : SvxAsianTabPage::SvxAsianTabPage( Window* pParent, const SfxItemSet& rSet ) :
2198 0 : SfxTabPage(pParent, "AsianTypography","cui/ui/asiantypography.ui", rSet)
2199 :
2200 : {
2201 0 : get(m_pForbiddenRulesCB,"checkForbidList");
2202 0 : get(m_pHangingPunctCB,"checkHangPunct");
2203 0 : get(m_pScriptSpaceCB,"checkApplySpacing");
2204 :
2205 0 : Link aLink = LINK( this, SvxAsianTabPage, ClickHdl_Impl );
2206 0 : m_pHangingPunctCB->SetClickHdl( aLink );
2207 0 : m_pScriptSpaceCB->SetClickHdl( aLink );
2208 0 : m_pForbiddenRulesCB->SetClickHdl( aLink );
2209 :
2210 0 : }
2211 :
2212 0 : SvxAsianTabPage::~SvxAsianTabPage()
2213 : {
2214 0 : }
2215 :
2216 0 : SfxTabPage* SvxAsianTabPage::Create( Window* pParent, const SfxItemSet& rSet )
2217 : {
2218 0 : return new SvxAsianTabPage(pParent, rSet);
2219 : }
2220 :
2221 0 : sal_uInt16* SvxAsianTabPage::GetRanges()
2222 : {
2223 : static sal_uInt16 pRanges[] =
2224 : {
2225 : SID_ATTR_PARA_SCRIPTSPACE, SID_ATTR_PARA_FORBIDDEN_RULES,
2226 : 0
2227 : };
2228 0 : return pRanges;
2229 : }
2230 :
2231 0 : sal_Bool SvxAsianTabPage::FillItemSet( SfxItemSet& rSet )
2232 : {
2233 0 : sal_Bool bRet = sal_False;
2234 0 : SfxItemPool* pPool = rSet.GetPool();
2235 0 : if (m_pScriptSpaceCB->IsEnabled() && m_pScriptSpaceCB->IsChecked() != m_pScriptSpaceCB->GetSavedValue())
2236 : {
2237 : SfxBoolItem* pNewItem = (SfxBoolItem*)rSet.Get(
2238 0 : pPool->GetWhich(SID_ATTR_PARA_SCRIPTSPACE)).Clone();
2239 0 : pNewItem->SetValue(m_pScriptSpaceCB->IsChecked());
2240 0 : rSet.Put(*pNewItem);
2241 0 : delete pNewItem;
2242 0 : bRet = sal_True;
2243 : }
2244 0 : if (m_pHangingPunctCB->IsEnabled() && m_pHangingPunctCB->IsChecked() != m_pHangingPunctCB->GetSavedValue())
2245 : {
2246 : SfxBoolItem* pNewItem = (SfxBoolItem*)rSet.Get(
2247 0 : pPool->GetWhich(SID_ATTR_PARA_HANGPUNCTUATION)).Clone();
2248 0 : pNewItem->SetValue(m_pHangingPunctCB->IsChecked());
2249 0 : rSet.Put(*pNewItem);
2250 0 : delete pNewItem;
2251 0 : bRet = sal_True;
2252 : }
2253 0 : if (m_pForbiddenRulesCB->IsEnabled() && m_pForbiddenRulesCB->IsChecked() != m_pForbiddenRulesCB->GetSavedValue())
2254 : {
2255 : SfxBoolItem* pNewItem = (SfxBoolItem*)rSet.Get(
2256 0 : pPool->GetWhich(SID_ATTR_PARA_FORBIDDEN_RULES)).Clone();
2257 0 : pNewItem->SetValue(m_pForbiddenRulesCB->IsChecked());
2258 0 : rSet.Put(*pNewItem);
2259 0 : delete pNewItem;
2260 0 : bRet = sal_True;
2261 : }
2262 0 : return bRet;
2263 : }
2264 :
2265 0 : static void lcl_SetBox(const SfxItemSet& rSet, sal_uInt16 nSlotId, CheckBox& rBox)
2266 : {
2267 0 : sal_uInt16 _nWhich = rSet.GetPool()->GetWhich(nSlotId);
2268 0 : SfxItemState eState = rSet.GetItemState(_nWhich, sal_True);
2269 0 : if(!eState || eState == SFX_ITEM_DISABLED )
2270 0 : rBox.Enable(sal_False);
2271 0 : else if(eState >= SFX_ITEM_AVAILABLE)
2272 : {
2273 0 : rBox.EnableTriState( sal_False );
2274 0 : rBox.Check(((const SfxBoolItem&)rSet.Get(_nWhich)).GetValue());
2275 : }
2276 : else
2277 0 : rBox.SetState( STATE_DONTKNOW );
2278 0 : rBox.SaveValue();
2279 0 : }
2280 :
2281 :
2282 0 : void SvxAsianTabPage::Reset( const SfxItemSet& rSet )
2283 : {
2284 0 : lcl_SetBox(rSet, SID_ATTR_PARA_FORBIDDEN_RULES, *m_pForbiddenRulesCB );
2285 0 : lcl_SetBox(rSet, SID_ATTR_PARA_HANGPUNCTUATION, *m_pHangingPunctCB );
2286 :
2287 : //character distance not yet available
2288 0 : lcl_SetBox(rSet, SID_ATTR_PARA_SCRIPTSPACE, *m_pScriptSpaceCB );
2289 0 : }
2290 :
2291 0 : IMPL_LINK( SvxAsianTabPage, ClickHdl_Impl, CheckBox*, pBox )
2292 : {
2293 0 : pBox->EnableTriState( sal_False );
2294 0 : return 0;
2295 0 : }
2296 :
2297 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|