Bump version to 4.3-4
[LibreOffice.git] / cui / source / tabpages / textattr.cxx
blobf349198f8ac415ff6fe0698e869780b007608d5c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sfx2/app.hxx>
21 #include <sfx2/module.hxx>
22 #include <tools/shl.hxx>
23 #include <cuires.hrc>
24 #include <svx/svddef.hxx>
25 #include <svx/sdtditm.hxx>
26 #include <svx/sdtagitm.hxx>
27 #include <svx/sdtaitm.hxx>
28 #include <svx/sdtfsitm.hxx>
29 #include <svx/sdtcfitm.hxx>
30 #include <svx/svdobj.hxx>
31 #include <svx/svdmark.hxx>
32 #include <svx/svdview.hxx>
33 #include <svx/svdotext.hxx>
34 #include <svx/dialogs.hrc>
36 #include "textattr.hxx"
37 #include <dialmgr.hxx>
38 #include "svx/dlgutil.hxx"
39 #include <sfx2/request.hxx>
40 #include <svx/ofaitem.hxx>
41 #include <editeng/writingmodeitem.hxx>
43 static const sal_uInt16 pRanges[] =
45 SDRATTR_MISC_FIRST
46 , SDRATTR_TEXT_HORZADJUST
47 , SDRATTR_TEXT_WORDWRAP
48 , SDRATTR_TEXT_AUTOGROWSIZE
49 , 0
52 /*************************************************************************
54 |* dialog (page) for copying objects
56 \************************************************************************/
57 SvxTextAttrPage::SvxTextAttrPage(Window* pWindow, const SfxItemSet& rInAttrs)
58 : SvxTabPage(pWindow,"TextAttributesPage","cui/ui/textattrtabpage.ui", rInAttrs)
59 , rOutAttrs(rInAttrs)
60 , pView(NULL)
61 , bAutoGrowSizeEnabled(false)
62 , bContourEnabled(false)
63 , bAutoGrowWidthEnabled(false)
64 , bAutoGrowHeightEnabled(false)
65 , bWordWrapTextEnabled(false)
66 , bFitToSizeEnabled(false)
68 get(m_pTsbAutoGrowWidth,"TSB_AUTOGROW_WIDTH");
69 get(m_pTsbAutoGrowHeight,"TSB_AUTOGROW_HEIGHT");
70 get(m_pTsbFitToSize,"TSB_FIT_TO_SIZE");
71 get(m_pTsbContour,"TSB_CONTOUR");
72 get(m_pTsbWordWrapText,"TSB_WORDWRAP_TEXT");
73 get(m_pTsbAutoGrowSize,"TSB_AUTOGROW_SIZE");
74 get(m_pFlDistance,"FL_DISTANCE");
75 get(m_pMtrFldLeft,"MTR_FLD_LEFT");
76 get(m_pMtrFldRight,"MTR_FLD_RIGHT");
77 get(m_pMtrFldTop,"MTR_FLD_TOP");
78 get(m_pMtrFldBottom,"MTR_FLD_BOTTOM");
79 get(m_pFlPosition,"FL_POSITION");
80 get(m_pCtlPosition,"CTL_POSITION");
81 m_pCtlPosition->SetControlSettings(RP_MM, 240, 100),
82 get(m_pTsbFullWidth,"TSB_FULL_WIDTH");
85 FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
86 SetFieldUnit( *m_pMtrFldLeft, eFUnit );
87 SetFieldUnit( *m_pMtrFldRight, eFUnit );
88 SetFieldUnit( *m_pMtrFldTop, eFUnit );
89 SetFieldUnit( *m_pMtrFldBottom, eFUnit );
91 Link aLink( LINK( this, SvxTextAttrPage, ClickHdl_Impl ) );
92 m_pTsbAutoGrowWidth->SetClickHdl( aLink );
93 m_pTsbAutoGrowHeight->SetClickHdl( aLink );
94 m_pTsbFitToSize->SetClickHdl( aLink );
95 m_pTsbContour->SetClickHdl( aLink );
97 m_pTsbFullWidth->SetClickHdl(LINK( this, SvxTextAttrPage, ClickFullWidthHdl_Impl ) );
100 /*************************************************************************
102 |* Dtor
104 \************************************************************************/
105 SvxTextAttrPage::~SvxTextAttrPage()
109 /*************************************************************************
111 |* reads the passed item set
113 \************************************************************************/
115 void SvxTextAttrPage::Reset( const SfxItemSet& rAttrs )
117 SfxItemPool* pPool = rAttrs.GetPool();
118 DBG_ASSERT( pPool, "Wo ist der Pool" );
119 SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
121 const SfxPoolItem* pItem = GetItem( rAttrs, SDRATTR_TEXT_LEFTDIST );
123 if( !pItem )
124 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LEFTDIST );
125 if( pItem )
127 long nValue = ( ( const SdrTextLeftDistItem* )pItem )->GetValue();
128 SetMetricValue( *m_pMtrFldLeft, nValue, eUnit );
130 else
131 m_pMtrFldLeft->SetText( "" );
132 m_pMtrFldLeft->SaveValue();
134 pItem = GetItem( rAttrs, SDRATTR_TEXT_RIGHTDIST );
135 if( !pItem )
136 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST );
137 if( pItem )
139 long nValue = ( ( const SdrTextRightDistItem* )pItem )->GetValue();
140 SetMetricValue( *m_pMtrFldRight, nValue, eUnit );
142 else
143 m_pMtrFldRight->SetText( "" );
144 m_pMtrFldRight->SaveValue();
146 pItem = GetItem( rAttrs, SDRATTR_TEXT_UPPERDIST );
147 if( !pItem )
148 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_UPPERDIST );
149 if( pItem )
151 long nValue = ( ( const SdrTextUpperDistItem* )pItem )->GetValue();
152 SetMetricValue( *m_pMtrFldTop, nValue, eUnit );
154 else
155 m_pMtrFldTop->SetText( "" );
156 m_pMtrFldTop->SaveValue();
158 pItem = GetItem( rAttrs, SDRATTR_TEXT_LOWERDIST );
159 if( !pItem )
160 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LOWERDIST );
161 if( pItem )
163 long nValue = ( ( const SdrTextLowerDistItem* )pItem )->GetValue();
164 SetMetricValue( *m_pMtrFldBottom, nValue, eUnit );
166 else
167 m_pMtrFldBottom->SetText( "" );
168 m_pMtrFldBottom->SaveValue();
170 // adjust to height
171 if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SFX_ITEM_DONTCARE )
173 m_pTsbAutoGrowHeight->SetState( ( ( const SdrTextAutoGrowHeightItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWHEIGHT ) ).
174 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
175 m_pTsbAutoGrowHeight->EnableTriState( false );
177 else
178 m_pTsbAutoGrowHeight->SetState( TRISTATE_INDET );
179 m_pTsbAutoGrowHeight->SaveValue();
181 // adjust to width
182 if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SFX_ITEM_DONTCARE )
184 m_pTsbAutoGrowWidth->SetState( ( ( const SdrTextAutoGrowWidthItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWWIDTH ) ).
185 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
186 m_pTsbAutoGrowWidth->EnableTriState( false );
188 else
189 m_pTsbAutoGrowWidth->SetState( TRISTATE_INDET );
190 m_pTsbAutoGrowWidth->SaveValue();
192 // autogrowsize
193 if ( rAttrs.GetItemState( SDRATTR_TEXT_AUTOGROWSIZE ) != SFX_ITEM_DONTCARE )
195 m_pTsbAutoGrowSize->SetState( ( ( const SdrTextAutoGrowHeightItem& )rAttrs.Get( SDRATTR_TEXT_AUTOGROWHEIGHT ) ).
196 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
197 m_pTsbAutoGrowSize->EnableTriState( false );
199 else
200 m_pTsbAutoGrowSize->SetState( TRISTATE_INDET );
201 m_pTsbAutoGrowSize->SaveValue();
203 // wordwrap text
204 if ( rAttrs.GetItemState( SDRATTR_TEXT_WORDWRAP ) != SFX_ITEM_DONTCARE )
206 m_pTsbWordWrapText->SetState( ( ( const SdrTextWordWrapItem& )rAttrs.Get( SDRATTR_TEXT_WORDWRAP ) ).
207 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
208 m_pTsbWordWrapText->EnableTriState( false );
210 else
211 m_pTsbWordWrapText->SetState( TRISTATE_INDET );
212 m_pTsbWordWrapText->SaveValue();
215 // #103516# Do the setup based on states of hor/ver adjust
216 // Setup center field and FullWidth
217 SfxItemState eVState = rAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
218 SfxItemState eHState = rAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
220 if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState)
222 // VertAdjust and HorAdjust are unequivocal, thus
223 SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)rAttrs.Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
224 SdrTextHorzAdjust eTHA = (SdrTextHorzAdjust)((const SdrTextHorzAdjustItem&)rAttrs.Get(SDRATTR_TEXT_HORZADJUST)).GetValue();
225 RECT_POINT eRP = RP_LB;
227 m_pTsbFullWidth->EnableTriState( false );
229 // Translate item values into local anchor position.
230 switch (eTVA)
232 case SDRTEXTVERTADJUST_TOP:
234 switch (eTHA)
236 case SDRTEXTHORZADJUST_LEFT: eRP = RP_LT; break;
237 case SDRTEXTHORZADJUST_BLOCK:
238 case SDRTEXTHORZADJUST_CENTER: eRP = RP_MT; break;
239 case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RT; break;
241 break;
243 case SDRTEXTVERTADJUST_BLOCK:
244 case SDRTEXTVERTADJUST_CENTER:
246 switch (eTHA)
248 case SDRTEXTHORZADJUST_LEFT: eRP = RP_LM; break;
249 case SDRTEXTHORZADJUST_BLOCK:
250 case SDRTEXTHORZADJUST_CENTER: eRP = RP_MM; break;
251 case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RM; break;
253 break;
255 case SDRTEXTVERTADJUST_BOTTOM:
257 switch (eTHA)
259 case SDRTEXTHORZADJUST_LEFT: eRP = RP_LB; break;
260 case SDRTEXTHORZADJUST_BLOCK:
261 case SDRTEXTHORZADJUST_CENTER: eRP = RP_MB; break;
262 case SDRTEXTHORZADJUST_RIGHT: eRP = RP_RB; break;
264 break;
266 default:
267 break;
270 // See if we have to check the "full width" check button.
271 bool bLeftToRight(IsTextDirectionLeftToRight());
273 if((bLeftToRight && (SDRTEXTHORZADJUST_BLOCK == eTHA)) || (!bLeftToRight && (SDRTEXTVERTADJUST_BLOCK == eTVA)))
275 // Move anchor to valid position.
276 ClickFullWidthHdl_Impl(NULL);
277 m_pTsbFullWidth->SetState(TRISTATE_TRUE);
280 m_pCtlPosition->SetActualRP( eRP );
282 else
284 // VertAdjust or HorAdjust is not unequivocal
285 m_pCtlPosition->Reset();
287 m_pCtlPosition->SetState(TRISTATE_INDET);
288 m_pCtlPosition->DoCompletelyDisable(true);
290 m_pTsbFullWidth->SetState(TRISTATE_INDET);
291 m_pFlPosition->Enable( false );
294 // adjust to border
295 if ( rAttrs.GetItemState( SDRATTR_TEXT_FITTOSIZE ) != SFX_ITEM_DONTCARE )
297 SdrFitToSizeType eFTS = (SdrFitToSizeType)
298 ( ( const SdrTextFitToSizeTypeItem& )rAttrs.Get( SDRATTR_TEXT_FITTOSIZE ) ).GetValue();
299 m_pTsbFitToSize->SetState( eFTS == SDRTEXTFIT_NONE ? TRISTATE_FALSE : TRISTATE_TRUE );
300 m_pTsbFitToSize->EnableTriState( false );
302 else
303 m_pTsbFitToSize->SetState( TRISTATE_INDET );
304 m_pTsbFitToSize->SaveValue();
306 if( rAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SFX_ITEM_DONTCARE )
308 bool bContour = ( ( const SdrTextContourFrameItem& )rAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
309 m_pTsbContour->SetState( bContour ? TRISTATE_TRUE : TRISTATE_FALSE );
310 m_pTsbContour->EnableTriState( false );
312 else
313 m_pTsbContour->SetState( TRISTATE_INDET );
314 m_pTsbContour->SaveValue();
316 ClickHdl_Impl( NULL );
319 /*************************************************************************
321 |* fills the passed item set with dialog box attributes
323 \************************************************************************/
325 bool SvxTextAttrPage::FillItemSet( SfxItemSet& rAttrs)
327 SfxItemPool* pPool = rAttrs.GetPool();
328 DBG_ASSERT( pPool, "Wo ist der Pool" );
329 SfxMapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
331 sal_Int32 nValue;
332 TriState eState;
334 if( m_pMtrFldLeft->IsValueChangedFromSaved() )
336 nValue = GetCoreValue( *m_pMtrFldLeft, eUnit );
337 rAttrs.Put( SdrTextLeftDistItem( nValue ) );
340 if( m_pMtrFldRight->IsValueChangedFromSaved() )
342 nValue = GetCoreValue( *m_pMtrFldRight, eUnit );
343 rAttrs.Put( SdrTextRightDistItem( nValue ) );
346 if( m_pMtrFldTop->IsValueChangedFromSaved() )
348 nValue = GetCoreValue( *m_pMtrFldTop, eUnit );
349 rAttrs.Put( SdrTextUpperDistItem( nValue ) );
352 if( m_pMtrFldBottom->IsValueChangedFromSaved() )
354 nValue = GetCoreValue( *m_pMtrFldBottom, eUnit );
355 rAttrs.Put( SdrTextLowerDistItem( nValue ) );
358 eState = m_pTsbAutoGrowHeight->GetState();
359 if( m_pTsbAutoGrowHeight->IsValueChangedFromSaved() )
361 rAttrs.Put( SdrTextAutoGrowHeightItem( TRISTATE_TRUE == eState ) );
364 eState = m_pTsbAutoGrowWidth->GetState();
365 if( m_pTsbAutoGrowWidth->IsValueChangedFromSaved() )
367 rAttrs.Put( SdrTextAutoGrowWidthItem( TRISTATE_TRUE == eState ) );
370 eState = m_pTsbAutoGrowSize->GetState();
371 if( m_pTsbAutoGrowSize->IsValueChangedFromSaved() )
373 rAttrs.Put( SdrTextAutoGrowHeightItem( TRISTATE_TRUE == eState ) );
376 eState = m_pTsbWordWrapText->GetState();
377 if( m_pTsbWordWrapText->IsValueChangedFromSaved() )
379 rAttrs.Put( SdrTextWordWrapItem( TRISTATE_TRUE == eState ) );
382 eState = m_pTsbContour->GetState();
383 if( m_pTsbContour->IsValueChangedFromSaved() )
385 rAttrs.Put( SdrTextContourFrameItem( TRISTATE_TRUE == eState ) );
388 eState = m_pTsbFitToSize->GetState();
389 if( m_pTsbFitToSize->IsValueChangedFromSaved() )
391 SdrFitToSizeType eFTS;
392 switch( eState )
394 default: ; //prevent warning
395 OSL_FAIL( "svx::SvxTextAttrPage::FillItemSet(), unhandled state!" );
396 /* Fall through */
397 case TRISTATE_FALSE: eFTS = SDRTEXTFIT_NONE; break;
398 case TRISTATE_TRUE: eFTS = SDRTEXTFIT_AUTOFIT; break;
400 rAttrs.Put( SdrTextFitToSizeTypeItem( eFTS ) );
403 // centered
404 RECT_POINT eRP = m_pCtlPosition->GetActualRP();
405 SdrTextVertAdjust eTVA, eOldTVA;
406 SdrTextHorzAdjust eTHA, eOldTHA;
408 switch( eRP )
410 default:
411 case RP_LT: eTVA = SDRTEXTVERTADJUST_TOP;
412 eTHA = SDRTEXTHORZADJUST_LEFT; break;
413 case RP_LM: eTVA = SDRTEXTVERTADJUST_CENTER;
414 eTHA = SDRTEXTHORZADJUST_LEFT; break;
415 case RP_LB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
416 eTHA = SDRTEXTHORZADJUST_LEFT; break;
417 case RP_MT: eTVA = SDRTEXTVERTADJUST_TOP;
418 eTHA = SDRTEXTHORZADJUST_CENTER; break;
419 case RP_MM: eTVA = SDRTEXTVERTADJUST_CENTER;
420 eTHA = SDRTEXTHORZADJUST_CENTER; break;
421 case RP_MB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
422 eTHA = SDRTEXTHORZADJUST_CENTER; break;
423 case RP_RT: eTVA = SDRTEXTVERTADJUST_TOP;
424 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
425 case RP_RM: eTVA = SDRTEXTVERTADJUST_CENTER;
426 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
427 case RP_RB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
428 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
431 // #103516# Do not change values if adjust controls were disabled.
432 bool bIsDisabled(m_pCtlPosition->IsCompletelyDisabled());
434 if(!bIsDisabled)
436 if( m_pTsbFullWidth->GetState() == TRISTATE_TRUE )
438 if (IsTextDirectionLeftToRight())
439 eTHA = SDRTEXTHORZADJUST_BLOCK;
440 else
441 eTVA = SDRTEXTVERTADJUST_BLOCK;
444 if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SFX_ITEM_DONTCARE )
446 eOldTVA = (SdrTextVertAdjust)
447 ( ( const SdrTextVertAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ) ).GetValue();
448 if( eOldTVA != eTVA )
449 rAttrs.Put( SdrTextVertAdjustItem( eTVA ) );
451 else
452 rAttrs.Put( SdrTextVertAdjustItem( eTVA ) );
454 if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SFX_ITEM_DONTCARE )
456 eOldTHA = (SdrTextHorzAdjust)
457 ( ( const SdrTextHorzAdjustItem& )rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ) ).GetValue();
458 if( eOldTHA != eTHA )
459 rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) );
461 else
462 rAttrs.Put( SdrTextHorzAdjustItem( eTHA ) );
465 return true;
468 void SvxTextAttrPage::Construct()
470 DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
472 bFitToSizeEnabled = bContourEnabled = true;
473 bWordWrapTextEnabled = bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = false;
475 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
476 if( rMarkList.GetMarkCount() == 1 )
478 const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
479 SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
480 if( pObj->GetObjInventor() == SdrInventor )
482 switch( eKind )
484 case OBJ_TEXT :
485 case OBJ_TITLETEXT :
486 case OBJ_OUTLINETEXT :
487 case OBJ_CAPTION :
489 if(pObj->HasText())
491 // contour NOT possible for pure text objects
492 bContourEnabled = false;
494 // adjusting width and height is ONLY possible for pure text objects
495 bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = true;
498 break;
499 case OBJ_CUSTOMSHAPE :
501 bFitToSizeEnabled = bContourEnabled = false;
502 bAutoGrowSizeEnabled = true;
503 bWordWrapTextEnabled = true;
505 break;
506 default: ;//prevent warning
510 m_pTsbAutoGrowHeight->Enable( bAutoGrowHeightEnabled );
511 m_pTsbAutoGrowWidth->Enable( bAutoGrowWidthEnabled );
512 m_pTsbFitToSize->Enable( bFitToSizeEnabled );
513 m_pTsbContour->Enable( bContourEnabled );
514 m_pTsbAutoGrowSize->Enable( bAutoGrowSizeEnabled );
515 m_pTsbWordWrapText->Enable( bWordWrapTextEnabled );
518 /*************************************************************************
520 |* creates the page
522 \************************************************************************/
524 SfxTabPage* SvxTextAttrPage::Create( Window* pWindow,
525 const SfxItemSet& rAttrs )
527 return( new SvxTextAttrPage( pWindow, rAttrs ) );
530 const sal_uInt16* SvxTextAttrPage::GetRanges()
532 return( pRanges );
535 /** Check whether we have to uncheck the "Full width" check box.
537 void SvxTextAttrPage::PointChanged( Window*, RECT_POINT eRP )
539 if (m_pTsbFullWidth->GetState() == TRISTATE_TRUE)
541 // Depending on write direction and currently checked anchor we have
542 // to uncheck the "full width" button.
543 if (IsTextDirectionLeftToRight())
544 switch( eRP )
546 case RP_LT:
547 case RP_LM:
548 case RP_LB:
549 case RP_RT:
550 case RP_RM:
551 case RP_RB:
552 m_pTsbFullWidth->SetState( TRISTATE_FALSE );
553 break;
554 default: ;//prevent warning
556 else
557 switch (eRP)
559 case RP_LT:
560 case RP_MT:
561 case RP_RT:
562 case RP_LB:
563 case RP_MB:
564 case RP_RB:
565 m_pTsbFullWidth->SetState( TRISTATE_FALSE );
566 break;
567 default: ;//prevent warning
572 /*************************************************************************
574 |* possibly changes the position of the position-control
576 \************************************************************************/
578 /** When switching the "full width" check button on the text anchor may have
579 to be moved to a valid and adjacent position. This position depends on
580 the current anchor position and the text writing direction.
582 IMPL_LINK_NOARG(SvxTextAttrPage, ClickFullWidthHdl_Impl)
584 if( m_pTsbFullWidth->GetState() == TRISTATE_TRUE )
586 if (IsTextDirectionLeftToRight())
588 // Move text anchor to horizontal middle axis.
589 switch( m_pCtlPosition->GetActualRP() )
591 case RP_LT:
592 case RP_RT:
593 m_pCtlPosition->SetActualRP( RP_MT );
594 break;
596 case RP_LM:
597 case RP_RM:
598 m_pCtlPosition->SetActualRP( RP_MM );
599 break;
601 case RP_LB:
602 case RP_RB:
603 m_pCtlPosition->SetActualRP( RP_MB );
604 break;
605 default: ;//prevent warning
608 else
610 // Move text anchor to vertical middle axis.
611 switch( m_pCtlPosition->GetActualRP() )
613 case RP_LT:
614 case RP_LB:
615 m_pCtlPosition->SetActualRP( RP_LM );
616 break;
618 case RP_MT:
619 case RP_MB:
620 m_pCtlPosition->SetActualRP( RP_MM );
621 break;
623 case RP_RT:
624 case RP_RB:
625 m_pCtlPosition->SetActualRP( RP_RM );
626 break;
627 default: ;//prevent warning
631 return( 0L );
634 /*************************************************************************
636 |* enables/disables "size at text" or "adjust to frame"
638 \************************************************************************/
640 IMPL_LINK_NOARG(SvxTextAttrPage, ClickHdl_Impl)
642 bool bAutoGrowWidth = m_pTsbAutoGrowWidth->GetState() == TRISTATE_TRUE;
643 bool bAutoGrowHeight = m_pTsbAutoGrowHeight->GetState() == TRISTATE_TRUE;
644 bool bFitToSize = m_pTsbFitToSize->GetState() == TRISTATE_TRUE;
645 bool bContour = m_pTsbContour->GetState() == TRISTATE_TRUE;
647 m_pTsbContour->Enable( !bFitToSize &&
648 !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
649 bContourEnabled );
651 m_pTsbAutoGrowWidth->Enable( !bFitToSize &&
652 !( bContour && bContourEnabled ) &&
653 bAutoGrowWidthEnabled );
655 m_pTsbAutoGrowHeight->Enable( !bFitToSize &&
656 !( bContour && bContourEnabled ) &&
657 bAutoGrowHeightEnabled );
659 m_pTsbFitToSize->Enable( !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
660 !( bContour && bContourEnabled ) &&
661 bFitToSizeEnabled );
663 // #101901# enable/disable metric fields and decorations dependent of contour
664 m_pFlDistance->Enable(!bContour);
666 if( bContour && bContourEnabled )
668 m_pMtrFldLeft->SetValue( 0 );
669 m_pMtrFldRight->SetValue( 0 );
670 m_pMtrFldTop->SetValue( 0 );
671 m_pMtrFldBottom->SetValue( 0 );
674 // #103516# Do the setup based on states of hor/ver adjust
675 SfxItemState eVState = rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
676 SfxItemState eHState = rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
677 bool bHorAndVer(SFX_ITEM_DONTCARE == eVState || SFX_ITEM_DONTCARE == eHState);
679 // #83698# enable/disable text anchoring dependent of contour
680 m_pFlPosition->Enable(!bContour && !bHorAndVer);
682 return( 0L );
686 bool SvxTextAttrPage::IsTextDirectionLeftToRight (void) const
688 // Determine the text writing direction with left to right as default.
689 bool bLeftToRightDirection = true;
690 SfxItemState eState = rOutAttrs.GetItemState(SDRATTR_TEXTDIRECTION);
692 if(SFX_ITEM_DONTCARE != eState)
694 const SvxWritingModeItem& rItem = static_cast<const SvxWritingModeItem&> (
695 rOutAttrs.Get (SDRATTR_TEXTDIRECTION));
696 if (rItem.GetValue() == com::sun::star::text::WritingMode_TB_RL)
697 bLeftToRightDirection = false;
699 return bLeftToRightDirection;
702 void SvxTextAttrPage::PageCreated(const SfxAllItemSet& aSet)
704 SFX_ITEMSET_ARG (&aSet,pViewItem,OfaPtrItem,SID_SVXTEXTATTRPAGE_VIEW,false);
706 if (pViewItem)
707 SetView( static_cast<SdrView *>(pViewItem->GetValue()));
709 Construct();
712 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */