xref: /aoo42x/main/cui/source/tabpages/textattr.cxx (revision 26734c99)
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 		SdrFitToSizeType eFTS = (SdrFitToSizeType)
351 					( ( const SdrTextFitToSizeTypeItem& )rAttrs.Get( SDRATTR_TEXT_FITTOSIZE ) ).GetValue();
352 		aTsbFitToSize.SetState( eFTS == SDRTEXTFIT_NONE ? STATE_NOCHECK : STATE_CHECK );
353 		aTsbFitToSize.EnableTriState( sal_False );
354 	}
355 	else
356 		aTsbFitToSize.SetState( STATE_DONTKNOW );
357 	aTsbFitToSize.SaveValue();
358 
359 	// Konturfluss
360 	if( rAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SFX_ITEM_DONTCARE )
361 	{
362 		sal_Bool bContour = ( ( const SdrTextContourFrameItem& )rAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
363 		aTsbContour.SetState( bContour ? STATE_CHECK : STATE_NOCHECK );
364 		aTsbContour.EnableTriState( sal_False );
365 	}
366 	else
367 		aTsbContour.SetState( STATE_DONTKNOW );
368 	aTsbContour.SaveValue();
369 
370 	ClickHdl_Impl( NULL );
371 }
372 
373 /*************************************************************************
374 |*
375 |* Fuellt uebergebenen Item-Set mit Dialogbox-Attributen
376 |*
377 \************************************************************************/
378 
379 sal_Bool SvxTextAttrPage::FillItemSet( SfxItemSet& rAttrs)
380 {
381 	SfxItemPool* pPool = rAttrs.GetPool();
382 	DBG_ASSERT( pPool, "Wo ist der Pool" );
383 	SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
384 
385 	sal_Int32	 nValue;
386 	TriState eState;
387 
388 	if( aMtrFldLeft.GetText() != aMtrFldLeft.GetSavedValue() )
389 	{
390 		nValue = GetCoreValue( aMtrFldLeft, eUnit );
391 		rAttrs.Put( SdrTextLeftDistItem( nValue ) );
392 	}
393 
394 	if( aMtrFldRight.GetText() != aMtrFldRight.GetSavedValue() )
395 	{
396 		nValue = GetCoreValue( aMtrFldRight, eUnit );
397 		rAttrs.Put( SdrTextRightDistItem( nValue ) );
398 	}
399 
400 	if( aMtrFldTop.GetText() != aMtrFldTop.GetSavedValue() )
401 	{
402 		nValue = GetCoreValue( aMtrFldTop, eUnit );
403 		rAttrs.Put( SdrTextUpperDistItem( nValue ) );
404 	}
405 
406 	if( aMtrFldBottom.GetText() != aMtrFldBottom.GetSavedValue() )
407 	{
408 		nValue = GetCoreValue( aMtrFldBottom, eUnit );
409 		rAttrs.Put( SdrTextLowerDistItem( nValue ) );
410 	}
411 
412 	eState = aTsbAutoGrowHeight.GetState();
413 	if( eState != aTsbAutoGrowHeight.GetSavedValue() )
414 	{
415 		rAttrs.Put( SdrTextAutoGrowHeightItem( (sal_Bool) STATE_CHECK == eState ) );
416 	}
417 
418 	eState = aTsbAutoGrowWidth.GetState();
419 	if( eState != aTsbAutoGrowWidth.GetSavedValue() )
420 	{
421 		rAttrs.Put( SdrTextAutoGrowWidthItem( (sal_Bool) STATE_CHECK == eState ) );
422 	}
423 
424 	eState = aTsbAutoGrowSize.GetState();
425 	if( eState != aTsbAutoGrowSize.GetSavedValue() )
426 	{
427 		rAttrs.Put( SdrTextAutoGrowHeightItem( (sal_Bool) STATE_CHECK == eState ) );
428 	}
429 
430 	eState = aTsbWordWrapText.GetState();
431 	if( eState != aTsbWordWrapText.GetSavedValue() )
432 	{
433 		rAttrs.Put( SdrTextWordWrapItem( (sal_Bool) STATE_CHECK == eState ) );
434 	}
435 
436 	// Konturfluss
437 	eState = aTsbContour.GetState();
438 	if( eState != aTsbContour.GetSavedValue() )
439 	{
440 		rAttrs.Put( SdrTextContourFrameItem( (sal_Bool) STATE_CHECK == eState ) );
441 	}
442 
443 	eState = aTsbFitToSize.GetState();
444 	if( eState != aTsbFitToSize.GetSavedValue() )
445 	{
446 		SdrFitToSizeType eFTS;
447 		switch( eState )
448 		{
449             default: ; //prevent warning
450 				DBG_ERROR( "svx::SvxTextAttrPage::FillItemSet(), unhandled state!" );
451 			case STATE_NOCHECK: eFTS = SDRTEXTFIT_NONE; break;
452 			//case STATE_CHECK: eFTS = SDRTEXTFIT_RESIZEATTR; break;
453 			case STATE_CHECK: eFTS = SDRTEXTFIT_PROPORTIONAL; break;
454 		}
455 		rAttrs.Put( SdrTextFitToSizeTypeItem( eFTS ) );
456 	}
457 
458 	// zentriert
459 	RECT_POINT eRP = aCtlPosition.GetActualRP();
460 	SdrTextVertAdjust eTVA, eOldTVA;
461 	SdrTextHorzAdjust eTHA, eOldTHA;
462 
463 	switch( eRP )
464 	{
465 		default:
466 		case RP_LT: eTVA = SDRTEXTVERTADJUST_TOP;
467 					eTHA = SDRTEXTHORZADJUST_LEFT; break;
468 		case RP_LM: eTVA = SDRTEXTVERTADJUST_CENTER;
469 					eTHA = SDRTEXTHORZADJUST_LEFT; break;
470 		case RP_LB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
471 					eTHA = SDRTEXTHORZADJUST_LEFT; break;
472 		case RP_MT: eTVA = SDRTEXTVERTADJUST_TOP;
473 					eTHA = SDRTEXTHORZADJUST_CENTER; break;
474 		case RP_MM: eTVA = SDRTEXTVERTADJUST_CENTER;
475 					eTHA = SDRTEXTHORZADJUST_CENTER; break;
476 		case RP_MB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
477 					eTHA = SDRTEXTHORZADJUST_CENTER; break;
478 		case RP_RT: eTVA = SDRTEXTVERTADJUST_TOP;
479 					eTHA = SDRTEXTHORZADJUST_RIGHT; break;
480 		case RP_RM: eTVA = SDRTEXTVERTADJUST_CENTER;
481 					eTHA = SDRTEXTHORZADJUST_RIGHT; break;
482 		case RP_RB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
483 					eTHA = SDRTEXTHORZADJUST_RIGHT; break;
484 	}
485 
486 	// #103516# Do not change values if adjust controls were disabled.
487 	sal_Bool bIsDisabled(aCtlPosition.IsCompletelyDisabled());
488 
489 	if(!bIsDisabled)
490 	{
491 		if( aTsbFullWidth.GetState() == STATE_CHECK )
492 		{
493 			if (IsTextDirectionLeftToRight())
494 				eTHA = SDRTEXTHORZADJUST_BLOCK;
495 			else
496 				eTVA = SDRTEXTVERTADJUST_BLOCK;
497 		}
498 
499 		if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SFX_ITEM_DONTCARE )
500 		{
501 			eOldTVA = (SdrTextVertAdjust)
502 						( ( const SdrTextVertAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ) ).GetValue();
503 			if( eOldTVA != eTVA )
504 				rAttrs.Put( SdrTextVertAdjustItem( eTVA ) );
505 		}
506 		else
507 			rAttrs.Put( SdrTextVertAdjustItem( eTVA ) );
508 
509 		if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SFX_ITEM_DONTCARE )
510 		{
511 			eOldTHA = (SdrTextHorzAdjust)
512 						( ( const SdrTextHorzAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ) ).GetValue();
513 			if( eOldTHA != eTHA )
514 				rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) );
515 		}
516 		else
517 			rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) );
518 	}
519 
520 	return( sal_True );
521 }
522 
523 /*************************************************************************
524 |*
525 |*
526 |*
527 \************************************************************************/
528 
529 void SvxTextAttrPage::Construct()
530 {
531 	DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
532 
533 	bFitToSizeEnabled = bContourEnabled = sal_True;
534 	bWordWrapTextEnabled = bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = sal_False;
535 
536 	const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
537 	if( rMarkList.GetMarkCount() == 1 )
538 	{
539 		const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
540 		SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
541 		if( pObj->GetObjInventor() == SdrInventor )
542 		{
543 			switch( eKind )
544 			{
545 				case OBJ_TEXT :
546 				case OBJ_TITLETEXT :
547 				case OBJ_OUTLINETEXT :
548 				case OBJ_CAPTION :
549 				{
550 					if ( ((SdrTextObj*)pObj)->HasText() )
551 					{
552 						// Konturfluss ist NICHT bei reinen Textobjekten m�glich
553 						bContourEnabled = sal_False;
554 
555 						// Breite und Hoehe anpassen ist NUR bei reinen Textobjekten m�glich
556 						bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = sal_True;
557 					}
558 				}
559 				break;
560 				case OBJ_CUSTOMSHAPE :
561 				{
562 					bFitToSizeEnabled = bContourEnabled = sal_False;
563 					bAutoGrowSizeEnabled = sal_True;
564 					bWordWrapTextEnabled = sal_True;
565 				}
566 				break;
567                 default: ;//prevent warning
568 			}
569 		}
570 	}
571 	aTsbAutoGrowHeight.Enable( bAutoGrowHeightEnabled );
572 	aTsbAutoGrowWidth.Enable( bAutoGrowWidthEnabled );
573 	aTsbFitToSize.Enable( bFitToSizeEnabled );
574 	aTsbContour.Enable( bContourEnabled );
575 	aTsbAutoGrowSize.Enable( bAutoGrowSizeEnabled );
576 	aTsbWordWrapText.Enable( bWordWrapTextEnabled );
577 }
578 
579 /*************************************************************************
580 |*
581 |* Erzeugt die Seite
582 |*
583 \************************************************************************/
584 
585 SfxTabPage* SvxTextAttrPage::Create( Window* pWindow,
586 				const SfxItemSet& rAttrs )
587 {
588 	return( new SvxTextAttrPage( pWindow, rAttrs ) );
589 }
590 
591 /*************************************************************************
592 |*
593 |*
594 |*
595 \************************************************************************/
596 
597 sal_uInt16*	SvxTextAttrPage::GetRanges()
598 {
599 	return( pRanges );
600 }
601 
602 /*************************************************************************
603 |*
604 |*
605 |*
606 \************************************************************************/
607 
608 /** Check whether we have to uncheck the "Full width" check box.
609 */
610 void SvxTextAttrPage::PointChanged( Window*, RECT_POINT eRP )
611 {
612     if (aTsbFullWidth.GetState() == STATE_CHECK)
613     {
614         // Depending on write direction and currently checked anchor we have
615         // to uncheck the "full width" button.
616         if (IsTextDirectionLeftToRight())
617             switch( eRP )
618             {
619                 case RP_LT:
620                 case RP_LM:
621                 case RP_LB:
622                 case RP_RT:
623                 case RP_RM:
624                 case RP_RB:
625                     aTsbFullWidth.SetState( STATE_NOCHECK );
626                 break;
627                 default: ;//prevent warning
628             }
629         else
630             switch (eRP)
631             {
632                 case RP_LT:
633                 case RP_MT:
634                 case RP_RT:
635                 case RP_LB:
636                 case RP_MB:
637                 case RP_RB:
638                     aTsbFullWidth.SetState( STATE_NOCHECK );
639                 break;
640                 default: ;//prevent warning
641             }
642 	}
643 }
644 
645 /*************************************************************************
646 |*
647 |* Aendert evtl. die Position des Positions-Controls
648 |*
649 \************************************************************************/
650 
651 /** When switching the "full width" check button on the text anchor may have
652     to be moved to a valid and adjacent position.  This position depends on
653     the current anchor position and the text writing direction.
654 */
655 IMPL_LINK( SvxTextAttrPage, ClickFullWidthHdl_Impl, void *, EMPTYARG )
656 {
657 	if( aTsbFullWidth.GetState() == STATE_CHECK )
658 	{
659         if (IsTextDirectionLeftToRight())
660         {
661             // Move text anchor to horizontal middle axis.
662             switch( aCtlPosition.GetActualRP() )
663             {
664                 case RP_LT:
665                 case RP_RT:
666                     aCtlPosition.SetActualRP( RP_MT );
667                     break;
668 
669                 case RP_LM:
670                 case RP_RM:
671                     aCtlPosition.SetActualRP( RP_MM );
672                     break;
673 
674                 case RP_LB:
675                 case RP_RB:
676                     aCtlPosition.SetActualRP( RP_MB );
677                     break;
678                 default: ;//prevent warning
679             }
680         }
681         else
682         {
683             // Move text anchor to vertical middle axis.
684             switch( aCtlPosition.GetActualRP() )
685             {
686                 case RP_LT:
687                 case RP_LB:
688                     aCtlPosition.SetActualRP( RP_LM );
689                     break;
690 
691                 case RP_MT:
692                 case RP_MB:
693                     aCtlPosition.SetActualRP( RP_MM );
694                     break;
695 
696                 case RP_RT:
697                 case RP_RB:
698                     aCtlPosition.SetActualRP( RP_RM );
699                 break;
700                 default: ;//prevent warning
701             }
702         }
703 	}
704 	return( 0L );
705 }
706 
707 /*************************************************************************
708 |*
709 |* Enabled/Disabled "Groesse an Text" oder "Am Rahmen Anpassen"
710 |*
711 \************************************************************************/
712 
713 IMPL_LINK( SvxTextAttrPage, ClickHdl_Impl, void *, EMPTYARG )
714 {
715 	sal_Bool bAutoGrowWidth  = aTsbAutoGrowWidth.GetState() == STATE_CHECK;
716 	sal_Bool bAutoGrowHeight = aTsbAutoGrowHeight.GetState() == STATE_CHECK;
717 	sal_Bool bFitToSize 	 = aTsbFitToSize.GetState() == STATE_CHECK;
718 	sal_Bool bContour		 = aTsbContour.GetState() == STATE_CHECK;
719 
720 	aTsbContour.Enable( !bFitToSize &&
721 						!( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
722 						bContourEnabled );
723 
724 	aTsbAutoGrowWidth.Enable( !bFitToSize &&
725 							  !( bContour && bContourEnabled ) &&
726 							  bAutoGrowWidthEnabled );
727 
728 	aTsbAutoGrowHeight.Enable( !bFitToSize &&
729 							   !( bContour && bContourEnabled ) &&
730 							   bAutoGrowHeightEnabled );
731 
732 	aTsbFitToSize.Enable( !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
733 						  !( bContour && bContourEnabled ) &&
734 						  bFitToSizeEnabled );
735 
736 	// #101901# enable/disable metric fields and decorations dependent of contour
737     aMtrFldLeft.Enable(!bContour);
738     aMtrFldRight.Enable(!bContour);
739     aMtrFldTop.Enable(!bContour);
740     aMtrFldBottom.Enable(!bContour);
741     aFlDistance.Enable(!bContour);
742     aFtLeft.Enable(!bContour);
743     aFtRight.Enable(!bContour);
744     aFtTop.Enable(!bContour);
745     aFtBottom.Enable(!bContour);
746 
747 	if( bContour && bContourEnabled )
748 	{
749 		aMtrFldLeft.SetValue( 0 );
750 		aMtrFldRight.SetValue( 0 );
751 		aMtrFldTop.SetValue( 0 );
752 		aMtrFldBottom.SetValue( 0 );
753 	}
754 
755 	// #103516# Do the setup based on states of hor/ver adjust
756 	SfxItemState eVState = rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
757 	SfxItemState eHState = rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
758 	sal_Bool bHorAndVer(SFX_ITEM_DONTCARE == eVState || SFX_ITEM_DONTCARE == eHState);
759 
760 	// #83698# enable/disable text anchoring dependent of contour
761 	aCtlPosition.Enable(!bContour && !bHorAndVer);
762 	aTsbFullWidth.Enable(!bContour && !bHorAndVer);
763 	aFlPosition.Enable(!bContour && !bHorAndVer);
764 
765 	return( 0L );
766 }
767 
768 
769 bool SvxTextAttrPage::IsTextDirectionLeftToRight (void) const
770 {
771     // Determine the text writing direction with left to right as default.
772     bool bLeftToRightDirection = true;
773 	SfxItemState eState = rOutAttrs.GetItemState(SDRATTR_TEXTDIRECTION);
774 
775     if(SFX_ITEM_DONTCARE != eState)
776     {
777         const SvxWritingModeItem& rItem = static_cast<const SvxWritingModeItem&> (
778             rOutAttrs.Get (SDRATTR_TEXTDIRECTION));
779         if (rItem.GetValue() == com::sun::star::text::WritingMode_TB_RL)
780             bLeftToRightDirection = false;
781     }
782     return bLeftToRightDirection;
783 }
784 
785 //add CHINA001 begin
786 void SvxTextAttrPage::PageCreated(SfxAllItemSet aSet)
787 {
788 	SFX_ITEMSET_ARG (&aSet,pViewItem,OfaPtrItem,SID_SVXTEXTATTRPAGE_VIEW,sal_False);
789 
790 	if (pViewItem)
791 		SetView( static_cast<SdrView *>(pViewItem->GetValue()));
792 
793 	Construct();
794 }
795 
796 //end of CHINA001
797