Update ooo320-m1
[ooovba.git] / svx / source / cui / textattr.cxx
blob9c974999957bad6ecc94260767c0eb1189b2b6f9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: textattr.cxx,v $
10 * $Revision: 1.28 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
36 #endif
38 // include ---------------------------------------------------------------
39 #include <sfx2/app.hxx>
40 #include <sfx2/module.hxx>
41 #include <tools/shl.hxx>
43 #include <svx/dialogs.hrc>
44 #include <svx/svddef.hxx>
45 #include <svx/sdtditm.hxx>
46 #include <svx/sdtagitm.hxx>
47 #include <svx/sdtaitm.hxx>
48 #include <svx/sdtfsitm.hxx>
49 #include <svx/sdtcfitm.hxx>
50 #include <svx/svdobj.hxx>
51 #include <svx/svdmark.hxx>
52 #include <svx/svdview.hxx>
53 #include <svx/svdotext.hxx>
56 #ifndef _SVX_TEXTATTR_CXX
57 #define _SVX_TEXTATTR_CXX
58 #endif
59 #include "textattr.hxx"
60 #include "textattr.hrc"
61 #include <svx/dialmgr.hxx>
62 #include "dlgutil.hxx"
63 #include <sfx2/request.hxx> //add CHINA001
64 #include <ofaitem.hxx> //add CHINA001
65 #include <svx/svxids.hrc> //add CHINA001
66 #include <svx/writingmodeitem.hxx>
68 static USHORT pRanges[] =
70 SDRATTR_MISC_FIRST, SDRATTR_TEXT_HORZADJUST,
71 SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE,
75 /*************************************************************************
77 |* Dialog zum Kopieren von Objekten
79 \************************************************************************/
81 //CHINA001 SvxTextAttrDialog::SvxTextAttrDialog( Window* pParent, const SfxItemSet& rInAttrs,
82 //CHINA001 const SdrView* pSdrView ) :
83 //CHINA001 SfxSingleTabDialog( pParent, rInAttrs, RID_SVXPAGE_TEXTATTR )
84 //CHINA001 {
85 //CHINA001 SvxTextAttrPage* pPage = new SvxTextAttrPage( this, rInAttrs );
86 //CHINA001
87 //CHINA001 pPage->SetView( pSdrView );
88 //CHINA001 pPage->Construct();
89 //CHINA001
90 //CHINA001 SetTabPage( pPage );
91 //CHINA001 SetText( pPage->GetText() );
92 //CHINA001 }
93 //CHINA001
94 /*************************************************************************
96 |* Dtor
98 \************************************************************************/
100 //CHINA001 SvxTextAttrDialog::~SvxTextAttrDialog()
101 //CHINA001 {
102 //CHINA001 }
104 /*************************************************************************
106 |* Dialog (Seite) zum Kopieren von Objekten
108 \************************************************************************/
110 SvxTextAttrPage::SvxTextAttrPage( Window* pWindow, const SfxItemSet& rInAttrs ) :
111 SvxTabPage ( pWindow, SVX_RES( RID_SVXPAGE_TEXTATTR ),
112 rInAttrs ),
114 aFlText ( this, SVX_RES( FL_TEXT ) ),
115 aTsbAutoGrowWidth ( this, SVX_RES( TSB_AUTOGROW_WIDTH ) ),
116 aTsbAutoGrowHeight ( this, SVX_RES( TSB_AUTOGROW_HEIGHT ) ),
117 aTsbFitToSize ( this, SVX_RES( TSB_FIT_TO_SIZE ) ),
118 aTsbContour ( this, SVX_RES( TSB_CONTOUR ) ),
119 aTsbWordWrapText( this, SVX_RES( TSB_WORDWRAP_TEXT ) ),
120 aTsbAutoGrowSize( this, SVX_RES( TSB_AUTOGROW_SIZE ) ),
121 aFlDistance ( this, SVX_RES( FL_DISTANCE ) ),
122 aFtLeft ( this, SVX_RES( FT_LEFT ) ),
123 aMtrFldLeft ( this, SVX_RES( MTR_FLD_LEFT ) ),
124 aFtRight ( this, SVX_RES( FT_RIGHT ) ),
125 aMtrFldRight ( this, SVX_RES( MTR_FLD_RIGHT ) ),
126 aFtTop ( this, SVX_RES( FT_TOP ) ),
127 aMtrFldTop ( this, SVX_RES( MTR_FLD_TOP ) ),
128 aFtBottom ( this, SVX_RES( FT_BOTTOM ) ),
129 aMtrFldBottom ( this, SVX_RES( MTR_FLD_BOTTOM ) ),
131 aFlSeparator ( this, SVX_RES( FL_SEPARATOR ) ),
133 aFlPosition ( this, SVX_RES( FL_POSITION ) ),
134 aCtlPosition ( this, SVX_RES( CTL_POSITION ),
135 RP_MM, 240, 100 ),
136 aTsbFullWidth ( this, SVX_RES( TSB_FULL_WIDTH ) ),
138 rOutAttrs ( rInAttrs )
140 FreeResource();
142 FieldUnit eFUnit = GetModuleFieldUnit( &rInAttrs );
143 SetFieldUnit( aMtrFldLeft, eFUnit );
144 SetFieldUnit( aMtrFldRight, eFUnit );
145 SetFieldUnit( aMtrFldTop, eFUnit );
146 SetFieldUnit( aMtrFldBottom, eFUnit );
148 Link aLink( LINK( this, SvxTextAttrPage, ClickHdl_Impl ) );
149 aTsbAutoGrowWidth.SetClickHdl( aLink );
150 aTsbAutoGrowHeight.SetClickHdl( aLink );
151 aTsbFitToSize.SetClickHdl( aLink );
152 aTsbContour.SetClickHdl( aLink );
154 aTsbFullWidth.SetClickHdl(
155 LINK( this, SvxTextAttrPage, ClickFullWidthHdl_Impl ) );
158 /*************************************************************************
160 |* Dtor
162 \************************************************************************/
164 SvxTextAttrPage::~SvxTextAttrPage()
168 /*************************************************************************
170 |* Liest uebergebenen Item-Set
172 \************************************************************************/
174 void __EXPORT SvxTextAttrPage::Reset( const SfxItemSet& rAttrs )
176 SfxItemPool* pPool = rAttrs.GetPool();
177 DBG_ASSERT( pPool, "Wo ist der Pool" );
178 SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
180 // Linker Abstand vom Rahmen
181 const SfxPoolItem* pItem = GetItem( rAttrs, SDRATTR_TEXT_LEFTDIST );
183 if( !pItem )
184 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LEFTDIST );
185 if( pItem )
187 long nValue = ( ( const SdrTextLeftDistItem* )pItem )->GetValue();
188 SetMetricValue( aMtrFldLeft, nValue, eUnit );
190 else
191 aMtrFldLeft.SetText( String() );
192 aMtrFldLeft.SaveValue();
194 // Rechter Abstand vom Rahmen
195 pItem = GetItem( rAttrs, SDRATTR_TEXT_RIGHTDIST );
196 if( !pItem )
197 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST );
198 if( pItem )
200 long nValue = ( ( const SdrTextRightDistItem* )pItem )->GetValue();
201 SetMetricValue( aMtrFldRight, nValue, eUnit );
203 else
204 aMtrFldRight.SetText( String() );
205 aMtrFldRight.SaveValue();
207 // Oberer Abstand vom Rahmen
208 pItem = GetItem( rAttrs, SDRATTR_TEXT_UPPERDIST );
209 if( !pItem )
210 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_UPPERDIST );
211 if( pItem )
213 long nValue = ( ( const SdrTextUpperDistItem* )pItem )->GetValue();
214 SetMetricValue( aMtrFldTop, nValue, eUnit );
216 else
217 aMtrFldTop.SetText( String() );
218 aMtrFldTop.SaveValue();
220 // Unterer Abstand vom Rahmen
221 pItem = GetItem( rAttrs, SDRATTR_TEXT_LOWERDIST );
222 if( !pItem )
223 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LOWERDIST );
224 if( pItem )
226 long nValue = ( ( const SdrTextLowerDistItem* )pItem )->GetValue();
227 SetMetricValue( aMtrFldBottom, nValue, eUnit );
229 else
230 aMtrFldBottom.SetText( String() );
231 aMtrFldBottom.SaveValue();
233 // An Hoehe anpassen
234 if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SFX_ITEM_DONTCARE )
236 aTsbAutoGrowHeight.SetState( ( ( const SdrTextAutoGrowHeightItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWHEIGHT ) ).
237 GetValue() ? STATE_CHECK : STATE_NOCHECK );
238 aTsbAutoGrowHeight.EnableTriState( FALSE );
240 else
241 aTsbAutoGrowHeight.SetState( STATE_DONTKNOW );
242 aTsbAutoGrowHeight.SaveValue();
244 // An Breite anpassen
245 if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SFX_ITEM_DONTCARE )
247 aTsbAutoGrowWidth.SetState( ( ( const SdrTextAutoGrowWidthItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWWIDTH ) ).
248 GetValue() ? STATE_CHECK : STATE_NOCHECK );
249 aTsbAutoGrowWidth.EnableTriState( FALSE );
251 else
252 aTsbAutoGrowWidth.SetState( STATE_DONTKNOW );
253 aTsbAutoGrowWidth.SaveValue();
255 // autogrowsize
256 if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWSIZE ) != SFX_ITEM_DONTCARE )
258 aTsbAutoGrowSize.SetState( ( ( const SdrTextAutoGrowHeightItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWHEIGHT ) ).
259 GetValue() ? STATE_CHECK : STATE_NOCHECK );
260 aTsbAutoGrowSize.EnableTriState( FALSE );
262 else
263 aTsbAutoGrowSize.SetState( STATE_DONTKNOW );
264 aTsbAutoGrowSize.SaveValue();
266 // wordwrap text
267 if ( rAttrs.GetItemState( SDRATTR_TEXT_WORDWRAP ) != SFX_ITEM_DONTCARE )
269 aTsbWordWrapText.SetState( ( ( const SdrTextWordWrapItem& )rAttrs.Get( SDRATTR_TEXT_WORDWRAP ) ).
270 GetValue() ? STATE_CHECK : STATE_NOCHECK );
271 aTsbWordWrapText.EnableTriState( FALSE );
273 else
274 aTsbWordWrapText.SetState( STATE_DONTKNOW );
275 aTsbWordWrapText.SaveValue();
278 // #103516# Do the setup based on states of hor/ver adjust
279 // Setup center field and FullWidth
280 SfxItemState eVState = rAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
281 SfxItemState eHState = rAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
283 if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState)
285 // VertAdjust and HorAdjust are unequivocal, thus
286 SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)rAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
287 SdrTextHorzAdjust eTHA = (SdrTextHorzAdjust)((const SdrTextHorzAdjustItem&)rAttrs.Get(SDRATTR_TEXT_HORZADJUST)).GetValue();
288 RECT_POINT eRP = RP_LB;
290 aTsbFullWidth.EnableTriState( FALSE );
292 // Translate item values into local anchor position.
293 switch (eTVA)
295 case SDRTEXTVERTADJUST_TOP:
297 switch (eTHA)
299 case SDRTEXTHORZADJUST_LEFT: eRP = RP_LT; break;
300 case SDRTEXTHORZADJUST_BLOCK:
301 case SDRTEXTHORZADJUST_CENTER: eRP = RP_MT; break;
302 case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RT; break;
304 break;
306 case SDRTEXTVERTADJUST_BLOCK:
307 case SDRTEXTVERTADJUST_CENTER:
309 switch (eTHA)
311 case SDRTEXTHORZADJUST_LEFT: eRP = RP_LM; break;
312 case SDRTEXTHORZADJUST_BLOCK:
313 case SDRTEXTHORZADJUST_CENTER: eRP = RP_MM; break;
314 case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RM; break;
316 break;
318 case SDRTEXTVERTADJUST_BOTTOM:
320 switch (eTHA)
322 case SDRTEXTHORZADJUST_LEFT: eRP = RP_LB; break;
323 case SDRTEXTHORZADJUST_BLOCK:
324 case SDRTEXTHORZADJUST_CENTER: eRP = RP_MB; break;
325 case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RB; break;
327 break;
329 default:
330 break;
333 // See if we have to check the "full width" check button.
334 sal_Bool bLeftToRight(IsTextDirectionLeftToRight());
336 if((bLeftToRight && (SDRTEXTHORZADJUST_BLOCK == eTHA)) || (!bLeftToRight && (SDRTEXTVERTADJUST_BLOCK == eTVA)))
338 // Move anchor to valid position.
339 ClickFullWidthHdl_Impl(NULL);
340 aTsbFullWidth.SetState(STATE_CHECK);
343 aCtlPosition.SetActualRP( eRP );
345 else
347 // VertAdjust or HorAdjust is not unequivocal
348 aCtlPosition.Reset();
350 aCtlPosition.SetState(STATE_DONTKNOW);
351 aCtlPosition.DoCompletelyDisable(sal_True);
353 aTsbFullWidth.SetState(STATE_DONTKNOW);
354 aTsbFullWidth.Enable( sal_False );
355 aFlPosition.Enable( sal_False );
358 // Am Rahmen anpassen
359 if ( rAttrs.GetItemState( SDRATTR_TEXT_FITTOSIZE ) != SFX_ITEM_DONTCARE )
361 SdrFitToSizeType eFTS = (SdrFitToSizeType)
362 ( ( const SdrTextFitToSizeTypeItem& )rAttrs.Get( SDRATTR_TEXT_FITTOSIZE ) ).GetValue();
363 aTsbFitToSize.SetState( eFTS == SDRTEXTFIT_NONE ? STATE_NOCHECK : STATE_CHECK );
364 aTsbFitToSize.EnableTriState( FALSE );
366 else
367 aTsbFitToSize.SetState( STATE_DONTKNOW );
368 aTsbFitToSize.SaveValue();
370 // Konturfluss
371 if( rAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SFX_ITEM_DONTCARE )
373 BOOL bContour = ( ( const SdrTextContourFrameItem& )rAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
374 aTsbContour.SetState( bContour ? STATE_CHECK : STATE_NOCHECK );
375 aTsbContour.EnableTriState( FALSE );
377 else
378 aTsbContour.SetState( STATE_DONTKNOW );
379 aTsbContour.SaveValue();
381 ClickHdl_Impl( NULL );
384 /*************************************************************************
386 |* Fuellt uebergebenen Item-Set mit Dialogbox-Attributen
388 \************************************************************************/
390 BOOL SvxTextAttrPage::FillItemSet( SfxItemSet& rAttrs)
392 SfxItemPool* pPool = rAttrs.GetPool();
393 DBG_ASSERT( pPool, "Wo ist der Pool" );
394 SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
396 INT32 nValue;
397 TriState eState;
399 if( aMtrFldLeft.GetText() != aMtrFldLeft.GetSavedValue() )
401 nValue = GetCoreValue( aMtrFldLeft, eUnit );
402 rAttrs.Put( SdrTextLeftDistItem( nValue ) );
405 if( aMtrFldRight.GetText() != aMtrFldRight.GetSavedValue() )
407 nValue = GetCoreValue( aMtrFldRight, eUnit );
408 rAttrs.Put( SdrTextRightDistItem( nValue ) );
411 if( aMtrFldTop.GetText() != aMtrFldTop.GetSavedValue() )
413 nValue = GetCoreValue( aMtrFldTop, eUnit );
414 rAttrs.Put( SdrTextUpperDistItem( nValue ) );
417 if( aMtrFldBottom.GetText() != aMtrFldBottom.GetSavedValue() )
419 nValue = GetCoreValue( aMtrFldBottom, eUnit );
420 rAttrs.Put( SdrTextLowerDistItem( nValue ) );
423 eState = aTsbAutoGrowHeight.GetState();
424 if( eState != aTsbAutoGrowHeight.GetSavedValue() )
426 rAttrs.Put( SdrTextAutoGrowHeightItem( (BOOL) STATE_CHECK == eState ) );
429 eState = aTsbAutoGrowWidth.GetState();
430 if( eState != aTsbAutoGrowWidth.GetSavedValue() )
432 rAttrs.Put( SdrTextAutoGrowWidthItem( (BOOL) STATE_CHECK == eState ) );
435 eState = aTsbAutoGrowSize.GetState();
436 if( eState != aTsbAutoGrowSize.GetSavedValue() )
438 rAttrs.Put( SdrTextAutoGrowHeightItem( (BOOL) STATE_CHECK == eState ) );
441 eState = aTsbWordWrapText.GetState();
442 if( eState != aTsbWordWrapText.GetSavedValue() )
444 rAttrs.Put( SdrTextWordWrapItem( (BOOL) STATE_CHECK == eState ) );
447 // Konturfluss
448 eState = aTsbContour.GetState();
449 if( eState != aTsbContour.GetSavedValue() )
451 rAttrs.Put( SdrTextContourFrameItem( (BOOL) STATE_CHECK == eState ) );
454 eState = aTsbFitToSize.GetState();
455 if( eState != aTsbFitToSize.GetSavedValue() )
457 SdrFitToSizeType eFTS;
458 switch( eState )
460 default: ; //prevent warning
461 DBG_ERROR( "svx::SvxTextAttrPage::FillItemSet(), unhandled state!" );
462 case STATE_NOCHECK: eFTS = SDRTEXTFIT_NONE; break;
463 case STATE_CHECK: eFTS = SDRTEXTFIT_AUTOFIT; break;
465 rAttrs.Put( SdrTextFitToSizeTypeItem( eFTS ) );
468 // zentriert
469 RECT_POINT eRP = aCtlPosition.GetActualRP();
470 SdrTextVertAdjust eTVA, eOldTVA;
471 SdrTextHorzAdjust eTHA, eOldTHA;
473 switch( eRP )
475 default:
476 case RP_LT: eTVA = SDRTEXTVERTADJUST_TOP;
477 eTHA = SDRTEXTHORZADJUST_LEFT; break;
478 case RP_LM: eTVA = SDRTEXTVERTADJUST_CENTER;
479 eTHA = SDRTEXTHORZADJUST_LEFT; break;
480 case RP_LB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
481 eTHA = SDRTEXTHORZADJUST_LEFT; break;
482 case RP_MT: eTVA = SDRTEXTVERTADJUST_TOP;
483 eTHA = SDRTEXTHORZADJUST_CENTER; break;
484 case RP_MM: eTVA = SDRTEXTVERTADJUST_CENTER;
485 eTHA = SDRTEXTHORZADJUST_CENTER; break;
486 case RP_MB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
487 eTHA = SDRTEXTHORZADJUST_CENTER; break;
488 case RP_RT: eTVA = SDRTEXTVERTADJUST_TOP;
489 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
490 case RP_RM: eTVA = SDRTEXTVERTADJUST_CENTER;
491 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
492 case RP_RB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
493 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
496 // #103516# Do not change values if adjust controls were disabled.
497 sal_Bool bIsDisabled(aCtlPosition.IsCompletelyDisabled());
499 if(!bIsDisabled)
501 if( aTsbFullWidth.GetState() == STATE_CHECK )
503 if (IsTextDirectionLeftToRight())
504 eTHA = SDRTEXTHORZADJUST_BLOCK;
505 else
506 eTVA = SDRTEXTVERTADJUST_BLOCK;
509 if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SFX_ITEM_DONTCARE )
511 eOldTVA = (SdrTextVertAdjust)
512 ( ( const SdrTextVertAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ) ).GetValue();
513 if( eOldTVA != eTVA )
514 rAttrs.Put( SdrTextVertAdjustItem( eTVA ) );
516 else
517 rAttrs.Put( SdrTextVertAdjustItem( eTVA ) );
519 if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SFX_ITEM_DONTCARE )
521 eOldTHA = (SdrTextHorzAdjust)
522 ( ( const SdrTextHorzAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ) ).GetValue();
523 if( eOldTHA != eTHA )
524 rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) );
526 else
527 rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) );
530 return( TRUE );
533 /*************************************************************************
537 \************************************************************************/
539 void SvxTextAttrPage::Construct()
541 DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
543 bFitToSizeEnabled = bContourEnabled = TRUE;
544 bWordWrapTextEnabled = bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = FALSE;
546 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
547 if( rMarkList.GetMarkCount() == 1 )
549 const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
550 SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
551 if( pObj->GetObjInventor() == SdrInventor )
553 switch( eKind )
555 case OBJ_TEXT :
556 case OBJ_TITLETEXT :
557 case OBJ_OUTLINETEXT :
558 case OBJ_CAPTION :
560 if ( ((SdrTextObj*)pObj)->HasText() )
562 // Konturfluss ist NICHT bei reinen Textobjekten m�glich
563 bContourEnabled = FALSE;
565 // Breite und Hoehe anpassen ist NUR bei reinen Textobjekten m�glich
566 bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = TRUE;
569 break;
570 case OBJ_CUSTOMSHAPE :
572 bFitToSizeEnabled = bContourEnabled = FALSE;
573 bAutoGrowSizeEnabled = TRUE;
574 bWordWrapTextEnabled = TRUE;
576 break;
577 default: ;//prevent warning
581 aTsbAutoGrowHeight.Enable( bAutoGrowHeightEnabled );
582 aTsbAutoGrowWidth.Enable( bAutoGrowWidthEnabled );
583 aTsbFitToSize.Enable( bFitToSizeEnabled );
584 aTsbContour.Enable( bContourEnabled );
585 aTsbAutoGrowSize.Enable( bAutoGrowSizeEnabled );
586 aTsbWordWrapText.Enable( bWordWrapTextEnabled );
589 /*************************************************************************
591 |* Erzeugt die Seite
593 \************************************************************************/
595 SfxTabPage* SvxTextAttrPage::Create( Window* pWindow,
596 const SfxItemSet& rAttrs )
598 return( new SvxTextAttrPage( pWindow, rAttrs ) );
601 /*************************************************************************
605 \************************************************************************/
607 USHORT* SvxTextAttrPage::GetRanges()
609 return( pRanges );
612 /*************************************************************************
616 \************************************************************************/
618 /** Check whether we have to uncheck the "Full width" check box.
620 void SvxTextAttrPage::PointChanged( Window*, RECT_POINT eRP )
622 if (aTsbFullWidth.GetState() == STATE_CHECK)
624 // Depending on write direction and currently checked anchor we have
625 // to uncheck the "full width" button.
626 if (IsTextDirectionLeftToRight())
627 switch( eRP )
629 case RP_LT:
630 case RP_LM:
631 case RP_LB:
632 case RP_RT:
633 case RP_RM:
634 case RP_RB:
635 aTsbFullWidth.SetState( STATE_NOCHECK );
636 break;
637 default: ;//prevent warning
639 else
640 switch (eRP)
642 case RP_LT:
643 case RP_MT:
644 case RP_RT:
645 case RP_LB:
646 case RP_MB:
647 case RP_RB:
648 aTsbFullWidth.SetState( STATE_NOCHECK );
649 break;
650 default: ;//prevent warning
655 /*************************************************************************
657 |* Aendert evtl. die Position des Positions-Controls
659 \************************************************************************/
661 /** When switching the "full width" check button on the text anchor may have
662 to be moved to a valid and adjacent position. This position depends on
663 the current anchor position and the text writing direction.
665 IMPL_LINK( SvxTextAttrPage, ClickFullWidthHdl_Impl, void *, EMPTYARG )
667 if( aTsbFullWidth.GetState() == STATE_CHECK )
669 if (IsTextDirectionLeftToRight())
671 // Move text anchor to horizontal middle axis.
672 switch( aCtlPosition.GetActualRP() )
674 case RP_LT:
675 case RP_RT:
676 aCtlPosition.SetActualRP( RP_MT );
677 break;
679 case RP_LM:
680 case RP_RM:
681 aCtlPosition.SetActualRP( RP_MM );
682 break;
684 case RP_LB:
685 case RP_RB:
686 aCtlPosition.SetActualRP( RP_MB );
687 break;
688 default: ;//prevent warning
691 else
693 // Move text anchor to vertical middle axis.
694 switch( aCtlPosition.GetActualRP() )
696 case RP_LT:
697 case RP_LB:
698 aCtlPosition.SetActualRP( RP_LM );
699 break;
701 case RP_MT:
702 case RP_MB:
703 aCtlPosition.SetActualRP( RP_MM );
704 break;
706 case RP_RT:
707 case RP_RB:
708 aCtlPosition.SetActualRP( RP_RM );
709 break;
710 default: ;//prevent warning
714 return( 0L );
717 /*************************************************************************
719 |* Enabled/Disabled "Groesse an Text" oder "Am Rahmen Anpassen"
721 \************************************************************************/
723 IMPL_LINK( SvxTextAttrPage, ClickHdl_Impl, void *, EMPTYARG )
725 BOOL bAutoGrowWidth = aTsbAutoGrowWidth.GetState() == STATE_CHECK;
726 BOOL bAutoGrowHeight = aTsbAutoGrowHeight.GetState() == STATE_CHECK;
727 BOOL bFitToSize = aTsbFitToSize.GetState() == STATE_CHECK;
728 BOOL bContour = aTsbContour.GetState() == STATE_CHECK;
730 aTsbContour.Enable( !bFitToSize &&
731 !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
732 bContourEnabled );
734 aTsbAutoGrowWidth.Enable( !bFitToSize &&
735 !( bContour && bContourEnabled ) &&
736 bAutoGrowWidthEnabled );
738 aTsbAutoGrowHeight.Enable( !bFitToSize &&
739 !( bContour && bContourEnabled ) &&
740 bAutoGrowHeightEnabled );
742 aTsbFitToSize.Enable( !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
743 !( bContour && bContourEnabled ) &&
744 bFitToSizeEnabled );
746 // #101901# enable/disable metric fields and decorations dependent of contour
747 aMtrFldLeft.Enable(!bContour);
748 aMtrFldRight.Enable(!bContour);
749 aMtrFldTop.Enable(!bContour);
750 aMtrFldBottom.Enable(!bContour);
751 aFlDistance.Enable(!bContour);
752 aFtLeft.Enable(!bContour);
753 aFtRight.Enable(!bContour);
754 aFtTop.Enable(!bContour);
755 aFtBottom.Enable(!bContour);
757 if( bContour && bContourEnabled )
759 aMtrFldLeft.SetValue( 0 );
760 aMtrFldRight.SetValue( 0 );
761 aMtrFldTop.SetValue( 0 );
762 aMtrFldBottom.SetValue( 0 );
765 // #103516# Do the setup based on states of hor/ver adjust
766 SfxItemState eVState = rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
767 SfxItemState eHState = rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
768 sal_Bool bHorAndVer(SFX_ITEM_DONTCARE == eVState || SFX_ITEM_DONTCARE == eHState);
770 // #83698# enable/disable text anchoring dependent of contour
771 aCtlPosition.Enable(!bContour && !bHorAndVer);
772 aTsbFullWidth.Enable(!bContour && !bHorAndVer);
773 aFlPosition.Enable(!bContour && !bHorAndVer);
775 return( 0L );
779 bool SvxTextAttrPage::IsTextDirectionLeftToRight (void) const
781 // Determine the text writing direction with left to right as default.
782 bool bLeftToRightDirection = true;
783 SfxItemState eState = rOutAttrs.GetItemState(SDRATTR_TEXTDIRECTION);
785 if(SFX_ITEM_DONTCARE != eState)
787 const SvxWritingModeItem& rItem = static_cast<const SvxWritingModeItem&> (
788 rOutAttrs.Get (SDRATTR_TEXTDIRECTION));
789 if (rItem.GetValue() == com::sun::star::text::WritingMode_TB_RL)
790 bLeftToRightDirection = false;
792 return bLeftToRightDirection;
795 //add CHINA001 begin
796 void SvxTextAttrPage::PageCreated(SfxAllItemSet aSet)
798 SFX_ITEMSET_ARG (&aSet,pViewItem,OfaPtrItem,SID_SVXTEXTATTRPAGE_VIEW,sal_False);
800 if (pViewItem)
801 SetView( static_cast<SdrView *>(pViewItem->GetValue()));
803 Construct();
806 //end of CHINA001