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