bump product version to 6.4.0.3
[LibreOffice.git] / cui / source / tabpages / textattr.cxx
blobb82e57ba323308f1d1f7e484cc5766fd0d86a7b1
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 <svx/svddef.hxx>
21 #include <svx/sdasitm.hxx>
22 #include <svx/sdtditm.hxx>
23 #include <svx/sdtagitm.hxx>
24 #include <svx/sdtaitm.hxx>
25 #include <svx/sdtfsitm.hxx>
26 #include <svx/sdtcfitm.hxx>
27 #include <svx/svdobj.hxx>
28 #include <svx/svxids.hrc>
30 #include <textattr.hxx>
31 #include <svx/dlgutil.hxx>
32 #include <editeng/writingmodeitem.hxx>
33 #include <svtools/unitconv.hxx>
35 using namespace ::com::sun::star;
37 const sal_uInt16 SvxTextAttrPage::pRanges[] =
39 SDRATTR_MISC_FIRST
40 , SDRATTR_TEXT_HORZADJUST
41 , SDRATTR_TEXT_WORDWRAP
42 , SDRATTR_TEXT_WORDWRAP
43 , 0
46 /*************************************************************************
48 |* dialog (page) for copying objects
50 \************************************************************************/
51 SvxTextAttrPage::SvxTextAttrPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs)
52 : SvxTabPage(pPage, pController, "cui/ui/textattrtabpage.ui", "TextAttributesPage", rInAttrs)
53 , rOutAttrs(rInAttrs)
54 , m_eObjKind(OBJ_NONE)
55 , bAutoGrowSizeEnabled(false)
56 , bContourEnabled(false)
57 , bAutoGrowWidthEnabled(false)
58 , bAutoGrowHeightEnabled(false)
59 , bWordWrapTextEnabled(false)
60 , bFitToSizeEnabled(false)
61 , m_aCtlPosition(this)
62 , m_xDrawingText(m_xBuilder->weld_widget("drawingtext"))
63 , m_xCustomShapeText(m_xBuilder->weld_widget("customshapetext"))
64 , m_xTsbAutoGrowWidth(m_xBuilder->weld_check_button("TSB_AUTOGROW_WIDTH"))
65 , m_xTsbAutoGrowHeight(m_xBuilder->weld_check_button("TSB_AUTOGROW_HEIGHT"))
66 , m_xTsbFitToSize(m_xBuilder->weld_check_button("TSB_FIT_TO_SIZE"))
67 , m_xTsbContour(m_xBuilder->weld_check_button("TSB_CONTOUR"))
68 , m_xTsbWordWrapText(m_xBuilder->weld_check_button("TSB_WORDWRAP_TEXT"))
69 , m_xTsbAutoGrowSize(m_xBuilder->weld_check_button("TSB_AUTOGROW_SIZE"))
70 , m_xFlDistance(m_xBuilder->weld_frame("FL_DISTANCE"))
71 , m_xMtrFldLeft(m_xBuilder->weld_metric_spin_button("MTR_FLD_LEFT", FieldUnit::CM))
72 , m_xMtrFldRight(m_xBuilder->weld_metric_spin_button("MTR_FLD_RIGHT", FieldUnit::CM))
73 , m_xMtrFldTop(m_xBuilder->weld_metric_spin_button("MTR_FLD_TOP", FieldUnit::CM))
74 , m_xMtrFldBottom(m_xBuilder->weld_metric_spin_button("MTR_FLD_BOTTOM", FieldUnit::CM))
75 , m_xFlPosition(m_xBuilder->weld_frame("FL_POSITION"))
76 , m_xCtlPosition(new weld::CustomWeld(*m_xBuilder, "CTL_POSITION", m_aCtlPosition))
77 , m_xTsbFullWidth(m_xBuilder->weld_check_button("TSB_FULL_WIDTH"))
79 m_aCtlPosition.SetControlSettings(RectPoint::MM, 240);
81 FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
82 SetFieldUnit( *m_xMtrFldLeft, eFUnit );
83 SetFieldUnit( *m_xMtrFldRight, eFUnit );
84 SetFieldUnit( *m_xMtrFldTop, eFUnit );
85 SetFieldUnit( *m_xMtrFldBottom, eFUnit );
87 Link<weld::Button&,void> aLink( LINK( this, SvxTextAttrPage, ClickHdl_Impl ) );
88 m_xTsbAutoGrowWidth->connect_clicked( aLink );
89 m_xTsbAutoGrowHeight->connect_clicked( aLink );
90 m_xTsbAutoGrowSize->connect_clicked( aLink );
91 m_xTsbFitToSize->connect_clicked( aLink );
92 m_xTsbContour->connect_clicked( aLink );
94 m_xTsbFullWidth->connect_clicked(LINK( this, SvxTextAttrPage, ClickFullWidthHdl_Impl ) );
97 SvxTextAttrPage::~SvxTextAttrPage()
101 /*************************************************************************
103 |* reads the passed item set
105 \************************************************************************/
107 void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs )
109 SfxItemPool* pPool = rAttrs->GetPool();
110 DBG_ASSERT( pPool, "Where is the pool?" );
111 MapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
113 const SfxPoolItem* pItem = GetItem( *rAttrs, SDRATTR_TEXT_LEFTDIST );
114 if( !pItem )
115 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LEFTDIST );
117 SetMetricValue(*m_xMtrFldLeft, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit);
118 m_xMtrFldLeft->save_value();
120 pItem = GetItem( *rAttrs, SDRATTR_TEXT_RIGHTDIST );
121 if( !pItem )
122 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST );
124 SetMetricValue(*m_xMtrFldRight, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit);
125 m_xMtrFldRight->save_value();
127 pItem = GetItem( *rAttrs, SDRATTR_TEXT_UPPERDIST );
128 if( !pItem )
129 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_UPPERDIST );
131 SetMetricValue(*m_xMtrFldTop, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit);
132 m_xMtrFldTop->save_value();
134 pItem = GetItem( *rAttrs, SDRATTR_TEXT_LOWERDIST );
135 if( !pItem )
136 pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LOWERDIST );
138 SetMetricValue(*m_xMtrFldBottom, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit);
139 m_xMtrFldBottom->save_value();
141 // adjust to height and autogrowsize
142 if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SfxItemState::DONTCARE )
144 m_xTsbAutoGrowHeight->set_state( rAttrs->Get( SDRATTR_TEXT_AUTOGROWHEIGHT ).
145 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
147 m_xTsbAutoGrowSize->set_state( rAttrs->Get( SDRATTR_TEXT_AUTOGROWHEIGHT ).
148 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
150 else
152 m_xTsbAutoGrowHeight->set_state( TRISTATE_INDET );
153 m_xTsbAutoGrowSize->set_state( TRISTATE_INDET );
155 m_xTsbAutoGrowHeight->save_state();
156 m_xTsbAutoGrowSize->save_state();
158 // adjust to width
159 if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SfxItemState::DONTCARE )
161 m_xTsbAutoGrowWidth->set_state( rAttrs->Get( SDRATTR_TEXT_AUTOGROWWIDTH ).
162 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
164 else
165 m_xTsbAutoGrowWidth->set_state( TRISTATE_INDET );
166 m_xTsbAutoGrowWidth->save_state();
168 // wordwrap text
169 if ( rAttrs->GetItemState( SDRATTR_TEXT_WORDWRAP ) != SfxItemState::DONTCARE )
171 m_xTsbWordWrapText->set_state( rAttrs->Get( SDRATTR_TEXT_WORDWRAP ).
172 GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
174 else
175 m_xTsbWordWrapText->set_state( TRISTATE_INDET );
176 m_xTsbWordWrapText->save_state();
179 // #103516# Do the setup based on states of hor/ver adjust
180 // Setup center field and FullWidth
181 SfxItemState eVState = rAttrs->GetItemState( SDRATTR_TEXT_VERTADJUST );
182 SfxItemState eHState = rAttrs->GetItemState( SDRATTR_TEXT_HORZADJUST );
184 if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState)
186 // VertAdjust and HorAdjust are unequivocal, thus
187 SdrTextVertAdjust eTVA = rAttrs->Get(SDRATTR_TEXT_VERTADJUST).GetValue();
188 SdrTextHorzAdjust eTHA = rAttrs->Get(SDRATTR_TEXT_HORZADJUST).GetValue();
189 RectPoint eRP = RectPoint::LB;
191 if (m_xTsbFullWidth->get_state() == TRISTATE_INDET)
192 m_xTsbFullWidth->set_state(TRISTATE_FALSE);
194 // Translate item values into local anchor position.
195 switch (eTVA)
197 case SDRTEXTVERTADJUST_TOP:
199 switch (eTHA)
201 case SDRTEXTHORZADJUST_LEFT: eRP = RectPoint::LT; break;
202 case SDRTEXTHORZADJUST_BLOCK:
203 case SDRTEXTHORZADJUST_CENTER: eRP = RectPoint::MT; break;
204 case SDRTEXTHORZADJUST_RIGHT: eRP = RectPoint::RT; break;
206 break;
208 case SDRTEXTVERTADJUST_BLOCK:
209 case SDRTEXTVERTADJUST_CENTER:
211 switch (eTHA)
213 case SDRTEXTHORZADJUST_LEFT: eRP = RectPoint::LM; break;
214 case SDRTEXTHORZADJUST_BLOCK:
215 case SDRTEXTHORZADJUST_CENTER: eRP = RectPoint::MM; break;
216 case SDRTEXTHORZADJUST_RIGHT: eRP = RectPoint::RM; break;
218 break;
220 case SDRTEXTVERTADJUST_BOTTOM:
222 switch (eTHA)
224 case SDRTEXTHORZADJUST_LEFT: eRP = RectPoint::LB; break;
225 case SDRTEXTHORZADJUST_BLOCK:
226 case SDRTEXTHORZADJUST_CENTER: eRP = RectPoint::MB; break;
227 case SDRTEXTHORZADJUST_RIGHT: eRP = RectPoint::RB; break;
229 break;
231 default:
232 break;
235 // See if we have to check the "full width" check button.
236 bool bLeftToRight(IsTextDirectionLeftToRight());
238 if((bLeftToRight && (SDRTEXTHORZADJUST_BLOCK == eTHA)) || (!bLeftToRight && (SDRTEXTVERTADJUST_BLOCK == eTVA)))
240 // Move anchor to valid position.
241 ClickFullWidthHdl_Impl(*m_xTsbFullWidth);
242 m_xTsbFullWidth->set_state(TRISTATE_TRUE);
245 m_aCtlPosition.SetActualRP( eRP );
247 else
249 // VertAdjust or HorAdjust is not unequivocal
250 m_aCtlPosition.Reset();
252 m_aCtlPosition.SetState(CTL_STATE::NOVERT);
253 m_aCtlPosition.DoCompletelyDisable(true);
255 m_xTsbFullWidth->set_state(TRISTATE_INDET);
256 m_xFlPosition->set_sensitive( false );
259 // adjust to border
260 if (rAttrs->GetItemState(SDRATTR_TEXT_FITTOSIZE) != SfxItemState::DONTCARE)
262 drawing::TextFitToSizeType const eFTS =
263 rAttrs->Get( SDRATTR_TEXT_FITTOSIZE ).GetValue();
264 if (eFTS == drawing::TextFitToSizeType_AUTOFIT || eFTS == drawing::TextFitToSizeType_NONE)
265 m_xTsbFitToSize->set_state( TRISTATE_FALSE );
266 else
267 m_xTsbFitToSize->set_state( TRISTATE_TRUE );
269 else
270 m_xTsbFitToSize->set_state( TRISTATE_INDET );
271 m_xTsbFitToSize->save_state();
273 if( rAttrs->GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SfxItemState::DONTCARE )
275 bool bContour = rAttrs->Get( SDRATTR_TEXT_CONTOURFRAME ).GetValue();
276 m_xTsbContour->set_state( bContour ? TRISTATE_TRUE : TRISTATE_FALSE );
278 else
279 m_xTsbContour->set_state( TRISTATE_INDET );
280 m_xTsbContour->save_state();
282 ClickHdl_Impl(*m_xTsbContour);
285 /*************************************************************************
287 |* fills the passed item set with dialog box attributes
289 \************************************************************************/
291 bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs)
293 SfxItemPool* pPool = rAttrs->GetPool();
294 DBG_ASSERT( pPool, "Where is the pool?" );
295 MapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
297 sal_Int32 nValue;
298 TriState eState;
300 if( m_xMtrFldLeft->get_value_changed_from_saved() )
302 nValue = GetCoreValue( *m_xMtrFldLeft, eUnit );
303 rAttrs->Put( makeSdrTextLeftDistItem( nValue ) );
306 if( m_xMtrFldRight->get_value_changed_from_saved() )
308 nValue = GetCoreValue( *m_xMtrFldRight, eUnit );
309 rAttrs->Put( makeSdrTextRightDistItem( nValue ) );
312 if( m_xMtrFldTop->get_value_changed_from_saved() )
314 nValue = GetCoreValue( *m_xMtrFldTop, eUnit );
315 rAttrs->Put( makeSdrTextUpperDistItem( nValue ) );
318 if( m_xMtrFldBottom->get_value_changed_from_saved() )
320 nValue = GetCoreValue( *m_xMtrFldBottom, eUnit );
321 rAttrs->Put( makeSdrTextLowerDistItem( nValue ) );
324 eState = m_xTsbAutoGrowHeight->get_state();
325 if( m_xTsbAutoGrowHeight->get_state_changed_from_saved() )
327 rAttrs->Put( makeSdrTextAutoGrowHeightItem( TRISTATE_TRUE == eState ) );
330 eState = m_xTsbAutoGrowWidth->get_state();
331 if( m_xTsbAutoGrowWidth->get_state_changed_from_saved() )
333 rAttrs->Put( makeSdrTextAutoGrowWidthItem( TRISTATE_TRUE == eState ) );
336 eState = m_xTsbAutoGrowSize->get_state();
337 if( m_xTsbAutoGrowSize->get_state_changed_from_saved() )
339 rAttrs->Put( makeSdrTextAutoGrowHeightItem( TRISTATE_TRUE == eState ) );
342 eState = m_xTsbWordWrapText->get_state();
343 if( m_xTsbWordWrapText->get_state_changed_from_saved() )
345 rAttrs->Put( makeSdrTextWordWrapItem( TRISTATE_TRUE == eState ) );
348 eState = m_xTsbContour->get_state();
349 if( m_xTsbContour->get_state_changed_from_saved() )
351 rAttrs->Put( makeSdrTextContourFrameItem( TRISTATE_TRUE == eState ) );
354 eState = m_xTsbFitToSize->get_state();
355 if( m_xTsbFitToSize->get_state_changed_from_saved() )
357 drawing::TextFitToSizeType eFTS;
358 switch( eState )
360 default: ; //prevent warning
361 OSL_FAIL( "svx::SvxTextAttrPage::FillItemSet(), unhandled state!" );
362 [[fallthrough]];
363 case TRISTATE_FALSE: eFTS = drawing::TextFitToSizeType_AUTOFIT; break;
364 case TRISTATE_TRUE: eFTS = drawing::TextFitToSizeType_PROPORTIONAL; break;
366 rAttrs->Put( SdrTextFitToSizeTypeItem( eFTS ) );
369 // centered
370 RectPoint eRP = m_aCtlPosition.GetActualRP();
371 SdrTextVertAdjust eTVA, eOldTVA;
372 SdrTextHorzAdjust eTHA, eOldTHA;
374 switch( eRP )
376 default:
377 case RectPoint::LT: eTVA = SDRTEXTVERTADJUST_TOP;
378 eTHA = SDRTEXTHORZADJUST_LEFT; break;
379 case RectPoint::LM: eTVA = SDRTEXTVERTADJUST_CENTER;
380 eTHA = SDRTEXTHORZADJUST_LEFT; break;
381 case RectPoint::LB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
382 eTHA = SDRTEXTHORZADJUST_LEFT; break;
383 case RectPoint::MT: eTVA = SDRTEXTVERTADJUST_TOP;
384 eTHA = SDRTEXTHORZADJUST_CENTER; break;
385 case RectPoint::MM: eTVA = SDRTEXTVERTADJUST_CENTER;
386 eTHA = SDRTEXTHORZADJUST_CENTER; break;
387 case RectPoint::MB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
388 eTHA = SDRTEXTHORZADJUST_CENTER; break;
389 case RectPoint::RT: eTVA = SDRTEXTVERTADJUST_TOP;
390 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
391 case RectPoint::RM: eTVA = SDRTEXTVERTADJUST_CENTER;
392 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
393 case RectPoint::RB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
394 eTHA = SDRTEXTHORZADJUST_RIGHT; break;
397 // #103516# Do not change values if adjust controls were disabled.
398 bool bIsDisabled(m_aCtlPosition.IsCompletelyDisabled());
400 if(!bIsDisabled)
402 if( m_xTsbFullWidth->get_state() == TRISTATE_TRUE )
404 if (IsTextDirectionLeftToRight())
405 eTHA = SDRTEXTHORZADJUST_BLOCK;
406 else
407 eTVA = SDRTEXTVERTADJUST_BLOCK;
410 if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SfxItemState::DONTCARE )
412 eOldTVA = rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ).GetValue();
413 if( eOldTVA != eTVA )
414 rAttrs->Put( SdrTextVertAdjustItem( eTVA ) );
416 else
417 rAttrs->Put( SdrTextVertAdjustItem( eTVA ) );
419 if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SfxItemState::DONTCARE )
421 eOldTHA = rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ).GetValue();
422 if( eOldTHA != eTHA )
423 rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) );
425 else
426 rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) );
429 return true;
432 void SvxTextAttrPage::Construct()
434 switch (m_eObjKind)
436 case OBJ_NONE:
437 // indeterminate, show them all
438 bFitToSizeEnabled = bContourEnabled = bWordWrapTextEnabled =
439 bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = true;
440 m_xCustomShapeText->show();
441 m_xDrawingText->show();
442 break;
443 case OBJ_TEXT:
444 case OBJ_TITLETEXT:
445 case OBJ_OUTLINETEXT:
446 case OBJ_CAPTION:
447 // contour NOT possible for pure text objects
448 bContourEnabled = bWordWrapTextEnabled = bAutoGrowSizeEnabled = false;
450 // adjusting width and height is ONLY possible for pure text objects
451 bFitToSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = true;
452 m_xCustomShapeText->hide();
453 m_xDrawingText->show();
454 break;
455 case OBJ_CUSTOMSHAPE:
456 bFitToSizeEnabled = bContourEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = false;
457 bWordWrapTextEnabled = bAutoGrowSizeEnabled = true;
458 m_xDrawingText->hide();
459 m_xCustomShapeText->show();
460 break;
461 default:
462 bFitToSizeEnabled = bContourEnabled = true;
463 bWordWrapTextEnabled = bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = false;
464 m_xCustomShapeText->hide();
465 m_xDrawingText->show();
466 break;
469 m_xTsbAutoGrowHeight->set_visible( bAutoGrowHeightEnabled );
470 m_xTsbAutoGrowWidth->set_visible( bAutoGrowWidthEnabled );
471 m_xTsbFitToSize->set_visible( bFitToSizeEnabled );
472 m_xTsbContour->set_visible( bContourEnabled );
473 m_xTsbAutoGrowSize->set_visible( bAutoGrowSizeEnabled );
474 m_xTsbWordWrapText->set_visible( bWordWrapTextEnabled );
477 std::unique_ptr<SfxTabPage> SvxTextAttrPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrs)
479 return std::make_unique<SvxTextAttrPage>(pPage, pController, *rAttrs);
482 /** Check whether we have to uncheck the "Full width" check box.
484 void SvxTextAttrPage::PointChanged(weld::DrawingArea*, RectPoint eRP)
486 if (m_xTsbFullWidth->get_state() == TRISTATE_TRUE)
488 // Depending on write direction and currently checked anchor we have
489 // to uncheck the "full width" button.
490 if (IsTextDirectionLeftToRight())
491 switch( eRP )
493 case RectPoint::LT:
494 case RectPoint::LM:
495 case RectPoint::LB:
496 case RectPoint::RT:
497 case RectPoint::RM:
498 case RectPoint::RB:
499 m_xTsbFullWidth->set_state( TRISTATE_FALSE );
500 break;
501 default: ;//prevent warning
503 else
504 switch (eRP)
506 case RectPoint::LT:
507 case RectPoint::MT:
508 case RectPoint::RT:
509 case RectPoint::LB:
510 case RectPoint::MB:
511 case RectPoint::RB:
512 m_xTsbFullWidth->set_state( TRISTATE_FALSE );
513 break;
514 default: ;//prevent warning
520 /*************************************************************************
522 |* possibly changes the position of the position-control
524 \************************************************************************/
526 /** When switching the "full width" check button on the text anchor may have
527 to be moved to a valid and adjacent position. This position depends on
528 the current anchor position and the text writing direction.
530 IMPL_LINK_NOARG(SvxTextAttrPage, ClickFullWidthHdl_Impl, weld::Button&, void)
532 if( m_xTsbFullWidth->get_state() == TRISTATE_TRUE )
534 if (IsTextDirectionLeftToRight())
536 // Move text anchor to horizontal middle axis.
537 switch( m_aCtlPosition.GetActualRP() )
539 case RectPoint::LT:
540 case RectPoint::RT:
541 m_aCtlPosition.SetActualRP( RectPoint::MT );
542 break;
544 case RectPoint::LM:
545 case RectPoint::RM:
546 m_aCtlPosition.SetActualRP( RectPoint::MM );
547 break;
549 case RectPoint::LB:
550 case RectPoint::RB:
551 m_aCtlPosition.SetActualRP( RectPoint::MB );
552 break;
553 default: ;//prevent warning
556 else
558 // Move text anchor to vertical middle axis.
559 switch( m_aCtlPosition.GetActualRP() )
561 case RectPoint::LT:
562 case RectPoint::LB:
563 m_aCtlPosition.SetActualRP( RectPoint::LM );
564 break;
566 case RectPoint::MT:
567 case RectPoint::MB:
568 m_aCtlPosition.SetActualRP( RectPoint::MM );
569 break;
571 case RectPoint::RT:
572 case RectPoint::RB:
573 m_aCtlPosition.SetActualRP( RectPoint::RM );
574 break;
575 default: ;//prevent warning
581 /*************************************************************************
583 |* enables/disables "size at text" or "adjust to frame"
585 \************************************************************************/
587 IMPL_LINK(SvxTextAttrPage, ClickHdl_Impl, weld::Button&, rButton, void)
589 if (&rButton == m_xTsbAutoGrowSize.get())
591 m_xTsbAutoGrowHeight->set_state(m_xTsbAutoGrowSize->get_state());
592 if (m_xTsbAutoGrowSize->get_state() == TRISTATE_TRUE)
594 m_xTsbFitToSize->set_state(TRISTATE_FALSE);
595 m_xTsbContour->set_state(TRISTATE_FALSE);
598 else if (&rButton == m_xTsbAutoGrowHeight.get())
599 m_xTsbAutoGrowSize->set_state(m_xTsbAutoGrowHeight->get_state());
601 bool bAutoGrowWidth = m_xTsbAutoGrowWidth->get_state() == TRISTATE_TRUE;
602 bool bAutoGrowHeight = m_xTsbAutoGrowHeight->get_state() == TRISTATE_TRUE;
603 bool bFitToSize = m_xTsbFitToSize->get_state() == TRISTATE_TRUE;
604 bool bContour = m_xTsbContour->get_state() == TRISTATE_TRUE;
606 m_xTsbContour->set_sensitive( !bFitToSize &&
607 !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
608 bContourEnabled );
610 m_xTsbAutoGrowWidth->set_sensitive( !bFitToSize &&
611 !( bContour && bContourEnabled ) &&
612 bAutoGrowWidthEnabled );
614 m_xTsbAutoGrowHeight->set_sensitive( !bFitToSize &&
615 !( bContour && bContourEnabled ) &&
616 bAutoGrowHeightEnabled );
618 m_xTsbFitToSize->set_sensitive( !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
619 !( bContour && bContourEnabled ) &&
620 bFitToSizeEnabled );
622 // #101901# enable/disable metric fields and decorations dependent of contour
623 m_xFlDistance->set_sensitive(!bContour);
625 if( bContour && bContourEnabled )
627 m_xMtrFldLeft->set_value(0, FieldUnit::NONE);
628 m_xMtrFldRight->set_value(0, FieldUnit::NONE);
629 m_xMtrFldTop->set_value(0, FieldUnit::NONE);
630 m_xMtrFldBottom->set_value(0, FieldUnit::NONE);
633 // #103516# Do the setup based on states of hor/ver adjust
634 SfxItemState eVState = rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
635 SfxItemState eHState = rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
636 bool bHorAndVer(SfxItemState::DONTCARE == eVState || SfxItemState::DONTCARE == eHState);
638 // #83698# enable/disable text anchoring dependent of contour
639 m_xFlPosition->set_sensitive(!bContour && !bHorAndVer);
643 bool SvxTextAttrPage::IsTextDirectionLeftToRight() const
645 // Determine the text writing direction with left to right as default.
646 bool bLeftToRightDirection = true;
647 SfxItemState eState = rOutAttrs.GetItemState(SDRATTR_TEXTDIRECTION);
649 if(SfxItemState::DONTCARE != eState)
651 const SvxWritingModeItem& rItem = rOutAttrs.Get(SDRATTR_TEXTDIRECTION);
652 if (rItem.GetValue() == css::text::WritingMode_TB_RL)
653 bLeftToRightDirection = false;
655 return bLeftToRightDirection;
658 void SvxTextAttrPage::PageCreated(const SfxAllItemSet& aSet)
660 const CntUInt16Item* pObjTypeItem = aSet.GetItem<CntUInt16Item>(SID_SVXTEXTATTRPAGE_OBJKIND, false);
662 if (pObjTypeItem)
663 SetObjKind(static_cast<SdrObjKind>(pObjTypeItem->GetValue()));
665 Construct();
668 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */