xref: /aoo41x/main/cui/source/tabpages/textattr.cxx (revision c0739476)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cui.hxx"
26 
27 // include ---------------------------------------------------------------
28 #include <sfx2/app.hxx>
29 #include <sfx2/module.hxx>
30 #include <tools/shl.hxx>
31 #include <cuires.hrc>
32 #include <svx/svddef.hxx>
33 #include <svx/sdtditm.hxx>
34 #include <svx/sdtagitm.hxx>
35 #include <svx/sdtaitm.hxx>
36 #include <svx/sdtfsitm.hxx>
37 #include <svx/sdtcfitm.hxx>
38 #include <svx/svdobj.hxx>
39 #include <svx/svdmark.hxx>
40 #include <svx/svdview.hxx>
41 #include <svx/svdotext.hxx>
42 #include <svx/dialogs.hrc>
43 
44 #ifndef _SVX_TEXTATTR_CXX
45 #define _SVX_TEXTATTR_CXX
46 #endif
47 #include "textattr.hxx"
48 #include "textattr.hrc"
49 #include <dialmgr.hxx>
50 #include "svx/dlgutil.hxx"
51 #include <sfx2/request.hxx> //add CHINA001
52 #include <svx/ofaitem.hxx> //add CHINA001
53 #include <editeng/writingmodeitem.hxx>
54 
55 static sal_uInt16 pRanges[] =
56 {
57 	SDRATTR_MISC_FIRST, SDRATTR_TEXT_HORZADJUST,
58 	SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE,
59 	0
60 };
61 
62 /*************************************************************************
63 |*
64 |* Dialog zum Kopieren von Objekten
65 |*
66 \************************************************************************/
67 
68 //CHINA001 SvxTextAttrDialog::SvxTextAttrDialog( Window* pParent, const SfxItemSet& rInAttrs,
69 //CHINA001 								const SdrView* pSdrView ) :
70 //CHINA001 		SfxSingleTabDialog( pParent, rInAttrs, RID_SVXPAGE_TEXTATTR )
71 //CHINA001 {
72 //CHINA001 SvxTextAttrPage* pPage = new SvxTextAttrPage( this, rInAttrs );
73 //CHINA001
74 //CHINA001 pPage->SetView( pSdrView );
75 //CHINA001 pPage->Construct();
76 //CHINA001
77 //CHINA001 SetTabPage( pPage );
78 //CHINA001 SetText( pPage->GetText() );
79 //CHINA001 }
80 //CHINA001
81 /*************************************************************************
82 |*
83 |* Dtor
84 |*
85 \************************************************************************/
86 
87 //CHINA001 SvxTextAttrDialog::~SvxTextAttrDialog()
88 //CHINA001 {
89 //CHINA001 }
90 
91 /*************************************************************************
92 |*
93 |* Dialog (Seite) zum Kopieren von Objekten
94 |*
95 \************************************************************************/
96 
97 SvxTextAttrPage::SvxTextAttrPage( Window* pWindow, const SfxItemSet& rInAttrs ) :
98 				SvxTabPage		( pWindow, CUI_RES( RID_SVXPAGE_TEXTATTR ),
99 								  rInAttrs ),
100 
101 				aFlText			( this, CUI_RES( FL_TEXT ) ),
102 				aTsbAutoGrowWidth  ( this, CUI_RES( TSB_AUTOGROW_WIDTH ) ),
103 				aTsbAutoGrowHeight ( this, CUI_RES( TSB_AUTOGROW_HEIGHT ) ),
104 				aTsbFitToSize	( this, CUI_RES( TSB_FIT_TO_SIZE ) ),
105 				aTsbContour  	( this, CUI_RES( TSB_CONTOUR ) ),
106 				aTsbWordWrapText( this, CUI_RES( TSB_WORDWRAP_TEXT ) ),
107 				aTsbAutoGrowSize( this, CUI_RES( TSB_AUTOGROW_SIZE ) ),
108 				aFlDistance		( this, CUI_RES( FL_DISTANCE ) ),
109 				aFtLeft			( this, CUI_RES( FT_LEFT ) ),
110 				aMtrFldLeft		( this, CUI_RES( MTR_FLD_LEFT ) ),
111 				aFtRight		( this, CUI_RES( FT_RIGHT ) ),
112 				aMtrFldRight	( this, CUI_RES( MTR_FLD_RIGHT ) ),
113 				aFtTop			( this, CUI_RES( FT_TOP ) ),
114 				aMtrFldTop		( this, CUI_RES( MTR_FLD_TOP ) ),
115 				aFtBottom		( this, CUI_RES( FT_BOTTOM ) ),
116 				aMtrFldBottom	( this, CUI_RES( MTR_FLD_BOTTOM ) ),
117 
118 				aFlSeparator	( this, CUI_RES( FL_SEPARATOR ) ),
119 
120 				aFlPosition		( this, CUI_RES( FL_POSITION ) ),
121 				aCtlPosition 	( this, CUI_RES( CTL_POSITION ),
122 											RP_MM, 240, 100 ),
123 				aTsbFullWidth 	( this, CUI_RES( TSB_FULL_WIDTH ) ),
124 
125 				rOutAttrs		( rInAttrs )
126 {
127 	FreeResource();
128 
129 	FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
130 	SetFieldUnit( aMtrFldLeft, eFUnit );
131 	SetFieldUnit( aMtrFldRight, eFUnit );
132 	SetFieldUnit( aMtrFldTop, eFUnit );
133 	SetFieldUnit( aMtrFldBottom, eFUnit );
134 
135 	Link aLink( LINK( this, SvxTextAttrPage, ClickHdl_Impl ) );
136 	aTsbAutoGrowWidth.SetClickHdl( aLink );
137 	aTsbAutoGrowHeight.SetClickHdl( aLink );
138 	aTsbFitToSize.SetClickHdl( aLink );
139 	aTsbContour.SetClickHdl( aLink );
140 
141 	aTsbFullWidth.SetClickHdl(
142 		LINK( this, SvxTextAttrPage, ClickFullWidthHdl_Impl ) );
143 
144 	aCtlPosition.SetAccessibleRelationMemberOf( &aFlPosition );
145 }
146 
147 /*************************************************************************
148 |*
149 |* Dtor
150 |*
151 \************************************************************************/
152 
153 SvxTextAttrPage::~SvxTextAttrPage()
154 {
155 }
156 
157 /*************************************************************************
158 |*
159 |* Liest uebergebenen Item-Set
160 |*
161 \************************************************************************/
162 
163 void __EXPORT SvxTextAttrPage::Reset( const SfxItemSet& rAttrs )
164 {
165 	SfxItemPool* pPool = rAttrs.GetPool();
166 	DBG_ASSERT( pPool, "Wo ist der Pool" );
167 	SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
168 
169 	// Linker Abstand vom Rahmen
170 	const SfxPoolItem* pItem = GetItem( rAttrs, SDRATTR_TEXT_LEFTDIST );
171 
172 	if( !pItem )
173 		pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LEFTDIST );
174 	if( pItem )
175 	{
176 		long nValue = ( ( const SdrTextLeftDistItem* )pItem )->GetValue();
177 		SetMetricValue( aMtrFldLeft, nValue, eUnit );
178 	}
179 	else
180 		aMtrFldLeft.SetText( String() );
181 	aMtrFldLeft.SaveValue();
182 
183 	// Rechter Abstand vom Rahmen
184 	pItem = GetItem( rAttrs, SDRATTR_TEXT_RIGHTDIST );
185 	if( !pItem )
186 		pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST );
187 	if( pItem )
188 	{
189 		long nValue = ( ( const SdrTextRightDistItem* )pItem )->GetValue();
190 		SetMetricValue( aMtrFldRight, nValue, eUnit );
191 	}
192 	else
193 		aMtrFldRight.SetText( String() );
194 	aMtrFldRight.SaveValue();
195 
196 	// Oberer Abstand vom Rahmen
197 	pItem = GetItem( rAttrs, SDRATTR_TEXT_UPPERDIST );
198 	if( !pItem )
199 		pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_UPPERDIST );
200 	if( pItem )
201 	{
202 		long nValue = ( ( const SdrTextUpperDistItem* )pItem )->GetValue();
203 		SetMetricValue( aMtrFldTop, nValue, eUnit );
204 	}
205 	else
206 		aMtrFldTop.SetText( String() );
207 	aMtrFldTop.SaveValue();
208 
209 	// Unterer Abstand vom Rahmen
210 	pItem = GetItem( rAttrs, SDRATTR_TEXT_LOWERDIST );
211 	if( !pItem )
212 		pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LOWERDIST );
213 	if( pItem )
214 	{
215 		long nValue = ( ( const SdrTextLowerDistItem* )pItem )->GetValue();
216 		SetMetricValue( aMtrFldBottom, nValue, eUnit );
217 	}
218 	else
219 		aMtrFldBottom.SetText( String() );
220 	aMtrFldBottom.SaveValue();
221 
222 	// An Hoehe anpassen
223 	if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SFX_ITEM_DONTCARE )
224 	{
225 		aTsbAutoGrowHeight.SetState( ( ( const SdrTextAutoGrowHeightItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWHEIGHT ) ).
226 						GetValue() ? STATE_CHECK : STATE_NOCHECK );
227 		aTsbAutoGrowHeight.EnableTriState( sal_False );
228 	}
229 	else
230 		aTsbAutoGrowHeight.SetState( STATE_DONTKNOW );
231 	aTsbAutoGrowHeight.SaveValue();
232 
233 	// An Breite anpassen
234 	if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SFX_ITEM_DONTCARE )
235 	{
236 		aTsbAutoGrowWidth.SetState( ( ( const SdrTextAutoGrowWidthItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWWIDTH ) ).
237 						GetValue() ? STATE_CHECK : STATE_NOCHECK );
238 		aTsbAutoGrowWidth.EnableTriState( sal_False );
239 	}
240 	else
241 		aTsbAutoGrowWidth.SetState( STATE_DONTKNOW );
242 	aTsbAutoGrowWidth.SaveValue();
243 
244 	// autogrowsize
245 	if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWSIZE ) != SFX_ITEM_DONTCARE )
246 	{
247 		aTsbAutoGrowSize.SetState( ( ( const SdrTextAutoGrowHeightItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWHEIGHT ) ).
248 						GetValue() ? STATE_CHECK : STATE_NOCHECK );
249 		aTsbAutoGrowSize.EnableTriState( sal_False );
250 	}
251 	else
252 		aTsbAutoGrowSize.SetState( STATE_DONTKNOW );
253 	aTsbAutoGrowSize.SaveValue();
254 
255 	// wordwrap text
256 	if ( rAttrs.GetItemState( SDRATTR_TEXT_WORDWRAP ) != SFX_ITEM_DONTCARE )
257 	{
258 		aTsbWordWrapText.SetState( ( ( const SdrTextWordWrapItem& )rAttrs.Get( SDRATTR_TEXT_WORDWRAP ) ).
259 						GetValue() ? STATE_CHECK : STATE_NOCHECK );
260 		aTsbWordWrapText.EnableTriState( sal_False );
261 	}
262 	else
263 		aTsbWordWrapText.SetState( STATE_DONTKNOW );
264 	aTsbWordWrapText.SaveValue();
265 
266 
267 	// #103516# Do the setup based on states of hor/ver adjust
268 	// Setup center field and FullWidth
269 	SfxItemState eVState = rAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
270 	SfxItemState eHState = rAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
271 
272 	if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState)
273 	{
274 		// VertAdjust and HorAdjust are unequivocal, thus
275 		SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)rAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
276 		SdrTextHorzAdjust eTHA = (SdrTextHorzAdjust)((const SdrTextHorzAdjustItem&)rAttrs.Get(SDRATTR_TEXT_HORZADJUST)).GetValue();
277 		RECT_POINT eRP = RP_LB;
278 
279 		aTsbFullWidth.EnableTriState( sal_False );
280 
281         // Translate item values into local anchor position.
282 		switch (eTVA)
283         {
284             case SDRTEXTVERTADJUST_TOP:
285 			{
286                 switch (eTHA)
287                 {
288                     case SDRTEXTHORZADJUST_LEFT: eRP = RP_LT; break;
289                     case SDRTEXTHORZADJUST_BLOCK:
290                     case SDRTEXTHORZADJUST_CENTER: eRP = RP_MT; break;
291                     case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RT; break;
292                 }
293                 break;
294 			}
295             case SDRTEXTVERTADJUST_BLOCK:
296             case SDRTEXTVERTADJUST_CENTER:
297 			{
298                 switch (eTHA)
299                 {
300                     case SDRTEXTHORZADJUST_LEFT: eRP = RP_LM; break;
301                     case SDRTEXTHORZADJUST_BLOCK:
302                     case SDRTEXTHORZADJUST_CENTER: eRP = RP_MM; break;
303                     case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RM; break;
304                 }
305                 break;
306 			}
307             case SDRTEXTVERTADJUST_BOTTOM:
308 			{
309                 switch (eTHA)
310                 {
311                     case SDRTEXTHORZADJUST_LEFT: eRP = RP_LB; break;
312                     case SDRTEXTHORZADJUST_BLOCK:
313                     case SDRTEXTHORZADJUST_CENTER: eRP = RP_MB; break;
314                     case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RB; break;
315                 }
316 				break;
317 			}
318 			default:
319 				break;
320 		}
321 
322         // See if we have to check the "full width" check button.
323         sal_Bool bLeftToRight(IsTextDirectionLeftToRight());
324 
325 		if((bLeftToRight && (SDRTEXTHORZADJUST_BLOCK == eTHA)) || (!bLeftToRight && (SDRTEXTVERTADJUST_BLOCK == eTVA)))
326         {
327             // Move anchor to valid position.
328             ClickFullWidthHdl_Impl(NULL);
329             aTsbFullWidth.SetState(STATE_CHECK);
330         }
331 
332 		aCtlPosition.SetActualRP( eRP );
333 	}
334 	else
335 	{
336 		// VertAdjust or HorAdjust is not unequivocal
337 		aCtlPosition.Reset();
338 
339 		aCtlPosition.SetState(STATE_DONTKNOW);
340 		aCtlPosition.DoCompletelyDisable(sal_True);
341 
342 		aTsbFullWidth.SetState(STATE_DONTKNOW);
343 		aTsbFullWidth.Enable( sal_False );
344 		aFlPosition.Enable( sal_False );
345 	}
346 
347 	// Am Rahmen anpassen
348 	if ( rAttrs.GetItemState( SDRATTR_TEXT_FITTOSIZE ) != SFX_ITEM_DONTCARE )
349 	{
350 		const sal_Bool bFTS = ( ( const SdrTextFitToSizeTypeItem& )rAttrs.Get( SDRATTR_TEXT_FITTOSIZE ) ).GetValue();
351 		aTsbFitToSize.SetState( bFTS ? STATE_CHECK : STATE_NOCHECK );
352 		aTsbFitToSize.EnableTriState( sal_False );
353 	}
354 	else
355 		aTsbFitToSize.SetState( STATE_DONTKNOW );
356 	aTsbFitToSize.SaveValue();
357 
358 	// Konturfluss
359 	if( rAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SFX_ITEM_DONTCARE )
360 	{
361 		sal_Bool bContour = ( ( const SdrTextContourFrameItem& )rAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
362 		aTsbContour.SetState( bContour ? STATE_CHECK : STATE_NOCHECK );
363 		aTsbContour.EnableTriState( sal_False );
364 	}
365 	else
366 		aTsbContour.SetState( STATE_DONTKNOW );
367 	aTsbContour.SaveValue();
368 
369 	ClickHdl_Impl( NULL );
370 }
371 
372 /*************************************************************************
373 |*
374 |* Fuellt uebergebenen Item-Set mit Dialogbox-Attributen
375 |*
376 \************************************************************************/
377 
378 sal_Bool SvxTextAttrPage::FillItemSet( SfxItemSet& rAttrs)
379 {
380 	SfxItemPool* pPool = rAttrs.GetPool();
381 	DBG_ASSERT( pPool, "Wo ist der Pool" );
382 	SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
383 
384 	sal_Int32	 nValue;
385 	TriState eState;
386 
387 	if( aMtrFldLeft.GetText() != aMtrFldLeft.GetSavedValue() )
388 	{
389 		nValue = GetCoreValue( aMtrFldLeft, eUnit );
390 		rAttrs.Put( SdrTextLeftDistItem( nValue ) );
391 	}
392 
393 	if( aMtrFldRight.GetText() != aMtrFldRight.GetSavedValue() )
394 	{
395 		nValue = GetCoreValue( aMtrFldRight, eUnit );
396 		rAttrs.Put( SdrTextRightDistItem( nValue ) );
397 	}
398 
399 	if( aMtrFldTop.GetText() != aMtrFldTop.GetSavedValue() )
400 	{
401 		nValue = GetCoreValue( aMtrFldTop, eUnit );
402 		rAttrs.Put( SdrTextUpperDistItem( nValue ) );
403 	}
404 
405 	if( aMtrFldBottom.GetText() != aMtrFldBottom.GetSavedValue() )
406 	{
407 		nValue = GetCoreValue( aMtrFldBottom, eUnit );
408 		rAttrs.Put( SdrTextLowerDistItem( nValue ) );
409 	}
410 
411 	eState = aTsbAutoGrowHeight.GetState();
412 	if( eState != aTsbAutoGrowHeight.GetSavedValue() )
413 	{
414 		rAttrs.Put( SdrTextAutoGrowHeightItem( (sal_Bool) STATE_CHECK == eState ) );
415 	}
416 
417 	eState = aTsbAutoGrowWidth.GetState();
418 	if( eState != aTsbAutoGrowWidth.GetSavedValue() )
419 	{
420 		rAttrs.Put( SdrTextAutoGrowWidthItem( (sal_Bool) STATE_CHECK == eState ) );
421 	}
422 
423 	eState = aTsbAutoGrowSize.GetState();
424 	if( eState != aTsbAutoGrowSize.GetSavedValue() )
425 	{
426 		rAttrs.Put( SdrTextAutoGrowHeightItem( (sal_Bool) STATE_CHECK == eState ) );
427 	}
428 
429 	eState = aTsbWordWrapText.GetState();
430 	if( eState != aTsbWordWrapText.GetSavedValue() )
431 	{
432 		rAttrs.Put( SdrTextWordWrapItem( (sal_Bool) STATE_CHECK == eState ) );
433 	}
434 
435 	// Konturfluss
436 	eState = aTsbContour.GetState();
437 	if( eState != aTsbContour.GetSavedValue() )
438 	{
439 		rAttrs.Put( SdrTextContourFrameItem( (sal_Bool) STATE_CHECK == eState ) );
440 	}
441 
442 	eState = aTsbFitToSize.GetState();
443 	if( eState != aTsbFitToSize.GetSavedValue() )
444 	{
445 		sal_Bool bFTS;
446 		switch( eState )
447 		{
448             default: ; //prevent warning
449 				DBG_ERROR( "svx::SvxTextAttrPage::FillItemSet(), unhandled state!" );
450 			case STATE_NOCHECK: bFTS = sal_False; break;
451 			case STATE_CHECK: bFTS = sal_True; break;
452 		}
453 		rAttrs.Put( SdrTextFitToSizeTypeItem( bFTS ) );
454 	}
455 
456 	// zentriert
457 	RECT_POINT eRP = aCtlPosition.GetActualRP();
458 	SdrTextVertAdjust eTVA, eOldTVA;
459 	SdrTextHorzAdjust eTHA, eOldTHA;
460 
461 	switch( eRP )
462 	{
463 		default:
464 		case RP_LT: eTVA = SDRTEXTVERTADJUST_TOP;
465 					eTHA = SDRTEXTHORZADJUST_LEFT; break;
466 		case RP_LM: eTVA = SDRTEXTVERTADJUST_CENTER;
467 					eTHA = SDRTEXTHORZADJUST_LEFT; break;
468 		case RP_LB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
469 					eTHA = SDRTEXTHORZADJUST_LEFT; break;
470 		case RP_MT: eTVA = SDRTEXTVERTADJUST_TOP;
471 					eTHA = SDRTEXTHORZADJUST_CENTER; break;
472 		case RP_MM: eTVA = SDRTEXTVERTADJUST_CENTER;
473 					eTHA = SDRTEXTHORZADJUST_CENTER; break;
474 		case RP_MB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
475 					eTHA = SDRTEXTHORZADJUST_CENTER; break;
476 		case RP_RT: eTVA = SDRTEXTVERTADJUST_TOP;
477 					eTHA = SDRTEXTHORZADJUST_RIGHT; break;
478 		case RP_RM: eTVA = SDRTEXTVERTADJUST_CENTER;
479 					eTHA = SDRTEXTHORZADJUST_RIGHT; break;
480 		case RP_RB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
481 					eTHA = SDRTEXTHORZADJUST_RIGHT; break;
482 	}
483 
484 	// #103516# Do not change values if adjust controls were disabled.
485 	sal_Bool bIsDisabled(aCtlPosition.IsCompletelyDisabled());
486 
487 	if(!bIsDisabled)
488 	{
489 		if( aTsbFullWidth.GetState() == STATE_CHECK )
490 		{
491 			if (IsTextDirectionLeftToRight())
492 				eTHA = SDRTEXTHORZADJUST_BLOCK;
493 			else
494 				eTVA = SDRTEXTVERTADJUST_BLOCK;
495 		}
496 
497 		if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SFX_ITEM_DONTCARE )
498 		{
499 			eOldTVA = (SdrTextVertAdjust)
500 						( ( const SdrTextVertAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ) ).GetValue();
501 			if( eOldTVA != eTVA )
502 				rAttrs.Put( SdrTextVertAdjustItem( eTVA ) );
503 		}
504 		else
505 			rAttrs.Put( SdrTextVertAdjustItem( eTVA ) );
506 
507 		if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SFX_ITEM_DONTCARE )
508 		{
509 			eOldTHA = (SdrTextHorzAdjust)
510 						( ( const SdrTextHorzAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ) ).GetValue();
511 			if( eOldTHA != eTHA )
512 				rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) );
513 		}
514 		else
515 			rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) );
516 	}
517 
518 	return( sal_True );
519 }
520 
521 /*************************************************************************
522 |*
523 |*
524 |*
525 \************************************************************************/
526 
527 void SvxTextAttrPage::Construct()
528 {
529 	DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
530 
531 	bFitToSizeEnabled = bContourEnabled = sal_True;
532 	bWordWrapTextEnabled = bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = sal_False;
533 
534 	const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
535 	if( rMarkList.GetMarkCount() == 1 )
536 	{
537 		const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
538 		SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
539 		if( pObj->GetObjInventor() == SdrInventor )
540 		{
541 			switch( eKind )
542 			{
543 				case OBJ_TEXT :
544 				case OBJ_TITLETEXT :
545 				case OBJ_OUTLINETEXT :
546 				case OBJ_CAPTION :
547 				{
548 					if ( ((SdrTextObj*)pObj)->HasText() )
549 					{
550 						// Konturfluss ist NICHT bei reinen Textobjekten m�glich
551 						bContourEnabled = sal_False;
552 
553 						// Breite und Hoehe anpassen ist NUR bei reinen Textobjekten m�glich
554 						bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = sal_True;
555 					}
556 				}
557 				break;
558 				case OBJ_CUSTOMSHAPE :
559 				{
560 					bFitToSizeEnabled = bContourEnabled = sal_False;
561 					bAutoGrowSizeEnabled = sal_True;
562 					bWordWrapTextEnabled = sal_True;
563 				}
564 				break;
565                 default: ;//prevent warning
566 			}
567 		}
568 	}
569 	aTsbAutoGrowHeight.Enable( bAutoGrowHeightEnabled );
570 	aTsbAutoGrowWidth.Enable( bAutoGrowWidthEnabled );
571 	aTsbFitToSize.Enable( bFitToSizeEnabled );
572 	aTsbContour.Enable( bContourEnabled );
573 	aTsbAutoGrowSize.Enable( bAutoGrowSizeEnabled );
574 	aTsbWordWrapText.Enable( bWordWrapTextEnabled );
575 }
576 
577 /*************************************************************************
578 |*
579 |* Erzeugt die Seite
580 |*
581 \************************************************************************/
582 
583 SfxTabPage* SvxTextAttrPage::Create( Window* pWindow,
584 				const SfxItemSet& rAttrs )
585 {
586 	return( new SvxTextAttrPage( pWindow, rAttrs ) );
587 }
588 
589 /*************************************************************************
590 |*
591 |*
592 |*
593 \************************************************************************/
594 
595 sal_uInt16*	SvxTextAttrPage::GetRanges()
596 {
597 	return( pRanges );
598 }
599 
600 /*************************************************************************
601 |*
602 |*
603 |*
604 \************************************************************************/
605 
606 /** Check whether we have to uncheck the "Full width" check box.
607 */
608 void SvxTextAttrPage::PointChanged( Window*, RECT_POINT eRP )
609 {
610     if (aTsbFullWidth.GetState() == STATE_CHECK)
611     {
612         // Depending on write direction and currently checked anchor we have
613         // to uncheck the "full width" button.
614         if (IsTextDirectionLeftToRight())
615             switch( eRP )
616             {
617                 case RP_LT:
618                 case RP_LM:
619                 case RP_LB:
620                 case RP_RT:
621                 case RP_RM:
622                 case RP_RB:
623                     aTsbFullWidth.SetState( STATE_NOCHECK );
624                 break;
625                 default: ;//prevent warning
626             }
627         else
628             switch (eRP)
629             {
630                 case RP_LT:
631                 case RP_MT:
632                 case RP_RT:
633                 case RP_LB:
634                 case RP_MB:
635                 case RP_RB:
636                     aTsbFullWidth.SetState( STATE_NOCHECK );
637                 break;
638                 default: ;//prevent warning
639             }
640 	}
641 }
642 
643 /*************************************************************************
644 |*
645 |* Aendert evtl. die Position des Positions-Controls
646 |*
647 \************************************************************************/
648 
649 /** When switching the "full width" check button on the text anchor may have
650     to be moved to a valid and adjacent position.  This position depends on
651     the current anchor position and the text writing direction.
652 */
653 IMPL_LINK( SvxTextAttrPage, ClickFullWidthHdl_Impl, void *, EMPTYARG )
654 {
655 	if( aTsbFullWidth.GetState() == STATE_CHECK )
656 	{
657         if (IsTextDirectionLeftToRight())
658         {
659             // Move text anchor to horizontal middle axis.
660             switch( aCtlPosition.GetActualRP() )
661             {
662                 case RP_LT:
663                 case RP_RT:
664                     aCtlPosition.SetActualRP( RP_MT );
665                     break;
666 
667                 case RP_LM:
668                 case RP_RM:
669                     aCtlPosition.SetActualRP( RP_MM );
670                     break;
671 
672                 case RP_LB:
673                 case RP_RB:
674                     aCtlPosition.SetActualRP( RP_MB );
675                     break;
676                 default: ;//prevent warning
677             }
678         }
679         else
680         {
681             // Move text anchor to vertical middle axis.
682             switch( aCtlPosition.GetActualRP() )
683             {
684                 case RP_LT:
685                 case RP_LB:
686                     aCtlPosition.SetActualRP( RP_LM );
687                     break;
688 
689                 case RP_MT:
690                 case RP_MB:
691                     aCtlPosition.SetActualRP( RP_MM );
692                     break;
693 
694                 case RP_RT:
695                 case RP_RB:
696                     aCtlPosition.SetActualRP( RP_RM );
697                 break;
698                 default: ;//prevent warning
699             }
700         }
701 	}
702 	return( 0L );
703 }
704 
705 /*************************************************************************
706 |*
707 |* Enabled/Disabled "Groesse an Text" oder "Am Rahmen Anpassen"
708 |*
709 \************************************************************************/
710 
711 IMPL_LINK( SvxTextAttrPage, ClickHdl_Impl, void *, EMPTYARG )
712 {
713 	sal_Bool bAutoGrowWidth  = aTsbAutoGrowWidth.GetState() == STATE_CHECK;
714 	sal_Bool bAutoGrowHeight = aTsbAutoGrowHeight.GetState() == STATE_CHECK;
715 	sal_Bool bFitToSize 	 = aTsbFitToSize.GetState() == STATE_CHECK;
716 	sal_Bool bContour		 = aTsbContour.GetState() == STATE_CHECK;
717 
718 	aTsbContour.Enable( !bFitToSize &&
719 						!( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
720 						bContourEnabled );
721 
722 	aTsbAutoGrowWidth.Enable( !bFitToSize &&
723 							  !( bContour && bContourEnabled ) &&
724 							  bAutoGrowWidthEnabled );
725 
726 	aTsbAutoGrowHeight.Enable( !bFitToSize &&
727 							   !( bContour && bContourEnabled ) &&
728 							   bAutoGrowHeightEnabled );
729 
730 	aTsbFitToSize.Enable( !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
731 						  !( bContour && bContourEnabled ) &&
732 						  bFitToSizeEnabled );
733 
734 	// #101901# enable/disable metric fields and decorations dependent of contour
735     aMtrFldLeft.Enable(!bContour);
736     aMtrFldRight.Enable(!bContour);
737     aMtrFldTop.Enable(!bContour);
738     aMtrFldBottom.Enable(!bContour);
739     aFlDistance.Enable(!bContour);
740     aFtLeft.Enable(!bContour);
741     aFtRight.Enable(!bContour);
742     aFtTop.Enable(!bContour);
743     aFtBottom.Enable(!bContour);
744 
745 	if( bContour && bContourEnabled )
746 	{
747 		aMtrFldLeft.SetValue( 0 );
748 		aMtrFldRight.SetValue( 0 );
749 		aMtrFldTop.SetValue( 0 );
750 		aMtrFldBottom.SetValue( 0 );
751 	}
752 
753 	// #103516# Do the setup based on states of hor/ver adjust
754 	SfxItemState eVState = rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
755 	SfxItemState eHState = rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
756 	sal_Bool bHorAndVer(SFX_ITEM_DONTCARE == eVState || SFX_ITEM_DONTCARE == eHState);
757 
758 	// #83698# enable/disable text anchoring dependent of contour
759 	aCtlPosition.Enable(!bContour && !bHorAndVer);
760 	aTsbFullWidth.Enable(!bContour && !bHorAndVer);
761 	aFlPosition.Enable(!bContour && !bHorAndVer);
762 
763 	return( 0L );
764 }
765 
766 
767 bool SvxTextAttrPage::IsTextDirectionLeftToRight (void) const
768 {
769     // Determine the text writing direction with left to right as default.
770     bool bLeftToRightDirection = true;
771 	SfxItemState eState = rOutAttrs.GetItemState(SDRATTR_TEXTDIRECTION);
772 
773     if(SFX_ITEM_DONTCARE != eState)
774     {
775         const SvxWritingModeItem& rItem = static_cast<const SvxWritingModeItem&> (
776             rOutAttrs.Get (SDRATTR_TEXTDIRECTION));
777         if (rItem.GetValue() == com::sun::star::text::WritingMode_TB_RL)
778             bLeftToRightDirection = false;
779     }
780     return bLeftToRightDirection;
781 }
782 
783 //add CHINA001 begin
784 void SvxTextAttrPage::PageCreated(SfxAllItemSet aSet)
785 {
786 	SFX_ITEMSET_ARG (&aSet,pViewItem,OfaPtrItem,SID_SVXTEXTATTRPAGE_VIEW,sal_False);
787 
788 	if (pViewItem)
789 		SetView( static_cast<SdrView *>(pViewItem->GetValue()));
790 
791 	Construct();
792 }
793 
794 //end of CHINA001
795