LibreOffice Module cui (master)  1
textattr.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
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>
29 
30 #include <textattr.hxx>
31 #include <svx/dlgutil.hxx>
33 #include <svtools/unitconv.hxx>
34 #include <osl/diagnose.h>
35 
36 using namespace ::com::sun::star;
37 
39  svl::Items<
40  SDRATTR_MISC_FIRST ,SDRATTR_TEXT_HORZADJUST,
41  SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_WORDWRAP
42 >);
43 
44 /*************************************************************************
45 |*
46 |* dialog (page) for copying objects
47 |*
48 \************************************************************************/
50  : SvxTabPage(pPage, pController, "cui/ui/textattrtabpage.ui", "TextAttributesPage", rInAttrs)
51  , rOutAttrs(rInAttrs)
52  , m_eObjKind(OBJ_NONE)
53  , bAutoGrowSizeEnabled(false)
54  , bContourEnabled(false)
55  , bAutoGrowWidthEnabled(false)
56  , bAutoGrowHeightEnabled(false)
57  , bWordWrapTextEnabled(false)
58  , bFitToSizeEnabled(false)
59  , m_aCtlPosition(this)
60  , m_xDrawingText(m_xBuilder->weld_widget("drawingtext"))
61  , m_xCustomShapeText(m_xBuilder->weld_widget("customshapetext"))
62  , m_xTsbAutoGrowWidth(m_xBuilder->weld_check_button("TSB_AUTOGROW_WIDTH"))
63  , m_xTsbAutoGrowHeight(m_xBuilder->weld_check_button("TSB_AUTOGROW_HEIGHT"))
64  , m_xTsbFitToSize(m_xBuilder->weld_check_button("TSB_FIT_TO_SIZE"))
65  , m_xTsbContour(m_xBuilder->weld_check_button("TSB_CONTOUR"))
66  , m_xTsbWordWrapText(m_xBuilder->weld_check_button("TSB_WORDWRAP_TEXT"))
67  , m_xTsbAutoGrowSize(m_xBuilder->weld_check_button("TSB_AUTOGROW_SIZE"))
68  , m_xFlDistance(m_xBuilder->weld_frame("FL_DISTANCE"))
69  , m_xMtrFldLeft(m_xBuilder->weld_metric_spin_button("MTR_FLD_LEFT", FieldUnit::CM))
70  , m_xMtrFldRight(m_xBuilder->weld_metric_spin_button("MTR_FLD_RIGHT", FieldUnit::CM))
71  , m_xMtrFldTop(m_xBuilder->weld_metric_spin_button("MTR_FLD_TOP", FieldUnit::CM))
72  , m_xMtrFldBottom(m_xBuilder->weld_metric_spin_button("MTR_FLD_BOTTOM", FieldUnit::CM))
73  , m_xFlPosition(m_xBuilder->weld_frame("FL_POSITION"))
74  , m_xCtlPosition(new weld::CustomWeld(*m_xBuilder, "CTL_POSITION", m_aCtlPosition))
75  , m_xTsbFullWidth(m_xBuilder->weld_check_button("TSB_FULL_WIDTH"))
76 {
77  m_aCtlPosition.SetControlSettings(RectPoint::MM, 240);
78 
79  FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
80  SetFieldUnit( *m_xMtrFldLeft, eFUnit );
81  SetFieldUnit( *m_xMtrFldRight, eFUnit );
82  SetFieldUnit( *m_xMtrFldTop, eFUnit );
83  SetFieldUnit( *m_xMtrFldBottom, eFUnit );
84 
85  Link<weld::Toggleable&,void> aLink( LINK( this, SvxTextAttrPage, ClickHdl_Impl ) );
86  m_xTsbAutoGrowWidth->connect_toggled( aLink );
87  m_xTsbAutoGrowHeight->connect_toggled( aLink );
88  m_xTsbAutoGrowSize->connect_toggled( aLink );
89  m_xTsbFitToSize->connect_toggled( aLink );
90  m_xTsbContour->connect_toggled( aLink );
91 
92  m_xTsbFullWidth->connect_toggled(LINK( this, SvxTextAttrPage, ClickFullWidthHdl_Impl ) );
93 }
94 
96 {
97 }
98 
99 /*************************************************************************
100 |*
101 |* reads the passed item set
102 |*
103 \************************************************************************/
104 
105 void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs )
106 {
107  SfxItemPool* pPool = rAttrs->GetPool();
108  DBG_ASSERT( pPool, "Where is the pool?" );
109  MapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
110 
111  const SdrMetricItem* pItem = GetItem(*rAttrs, SDRATTR_TEXT_LEFTDIST);
112  if( !pItem )
113  pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LEFTDIST );
114 
115  SetMetricValue(*m_xMtrFldLeft, pItem->GetValue(), eUnit);
116  m_xMtrFldLeft->save_value();
117 
118  pItem = GetItem( *rAttrs, SDRATTR_TEXT_RIGHTDIST );
119  if( !pItem )
120  pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST );
121 
122  SetMetricValue(*m_xMtrFldRight, pItem->GetValue(), eUnit);
123  m_xMtrFldRight->save_value();
124 
125  pItem = GetItem( *rAttrs, SDRATTR_TEXT_UPPERDIST );
126  if( !pItem )
127  pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_UPPERDIST );
128 
129  SetMetricValue(*m_xMtrFldTop, pItem->GetValue(), eUnit);
130  m_xMtrFldTop->save_value();
131 
132  pItem = GetItem( *rAttrs, SDRATTR_TEXT_LOWERDIST );
133  if( !pItem )
134  pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LOWERDIST );
135 
136  SetMetricValue(*m_xMtrFldBottom, pItem->GetValue(), eUnit);
137  m_xMtrFldBottom->save_value();
138 
139  // adjust to height and autogrowsize
140  if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SfxItemState::DONTCARE )
141  {
144 
145  m_xTsbAutoGrowSize->set_state( rAttrs->Get( SDRATTR_TEXT_AUTOGROWHEIGHT ).
147  }
148  else
149  {
150  m_xTsbAutoGrowHeight->set_state( TRISTATE_INDET );
151  m_xTsbAutoGrowSize->set_state( TRISTATE_INDET );
152  }
153  m_xTsbAutoGrowHeight->save_state();
154  m_xTsbAutoGrowSize->save_state();
155 
156  // adjust to width
157  if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SfxItemState::DONTCARE )
158  {
159  m_xTsbAutoGrowWidth->set_state( rAttrs->Get( SDRATTR_TEXT_AUTOGROWWIDTH ).
161  }
162  else
163  m_xTsbAutoGrowWidth->set_state( TRISTATE_INDET );
164  m_xTsbAutoGrowWidth->save_state();
165 
166  // wordwrap text
167  if ( rAttrs->GetItemState( SDRATTR_TEXT_WORDWRAP ) != SfxItemState::DONTCARE )
168  {
169  m_xTsbWordWrapText->set_state( rAttrs->Get( SDRATTR_TEXT_WORDWRAP ).
171  }
172  else
173  m_xTsbWordWrapText->set_state( TRISTATE_INDET );
174  m_xTsbWordWrapText->save_state();
175 
176 
177  // #103516# Do the setup based on states of hor/ver adjust
178  // Setup center field and FullWidth
181 
182  if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState)
183  {
184  // VertAdjust and HorAdjust are unequivocal, thus
185  SdrTextVertAdjust eTVA = rAttrs->Get(SDRATTR_TEXT_VERTADJUST).GetValue();
186  SdrTextHorzAdjust eTHA = rAttrs->Get(SDRATTR_TEXT_HORZADJUST).GetValue();
187  RectPoint eRP = RectPoint::LB;
188 
189  if (m_xTsbFullWidth->get_state() == TRISTATE_INDET)
190  m_xTsbFullWidth->set_state(TRISTATE_FALSE);
191 
192  // Translate item values into local anchor position.
193  switch (eTVA)
194  {
196  {
197  switch (eTHA)
198  {
199  case SDRTEXTHORZADJUST_LEFT: eRP = RectPoint::LT; break;
201  case SDRTEXTHORZADJUST_CENTER: eRP = RectPoint::MT; break;
202  case SDRTEXTHORZADJUST_RIGHT: eRP = RectPoint::RT; break;
203  }
204  break;
205  }
208  {
209  switch (eTHA)
210  {
211  case SDRTEXTHORZADJUST_LEFT: eRP = RectPoint::LM; break;
213  case SDRTEXTHORZADJUST_CENTER: eRP = RectPoint::MM; break;
214  case SDRTEXTHORZADJUST_RIGHT: eRP = RectPoint::RM; break;
215  }
216  break;
217  }
219  {
220  switch (eTHA)
221  {
222  case SDRTEXTHORZADJUST_LEFT: eRP = RectPoint::LB; break;
224  case SDRTEXTHORZADJUST_CENTER: eRP = RectPoint::MB; break;
225  case SDRTEXTHORZADJUST_RIGHT: eRP = RectPoint::RB; break;
226  }
227  break;
228  }
229  default:
230  break;
231  }
232 
233  // See if we have to check the "full width" check button.
234  bool bLeftToRight(IsTextDirectionLeftToRight());
235 
236  if((bLeftToRight && (SDRTEXTHORZADJUST_BLOCK == eTHA)) || (!bLeftToRight && (SDRTEXTVERTADJUST_BLOCK == eTVA)))
237  {
238  // Move anchor to valid position.
239  ClickFullWidthHdl_Impl(*m_xTsbFullWidth);
240  m_xTsbFullWidth->set_state(TRISTATE_TRUE);
241  }
242 
244  }
245  else
246  {
247  // VertAdjust or HorAdjust is not unequivocal
249 
250  m_aCtlPosition.SetState(CTL_STATE::NOVERT);
252 
253  m_xTsbFullWidth->set_state(TRISTATE_INDET);
254  m_xFlPosition->set_sensitive( false );
255  }
256 
257  // adjust to border
258  if (rAttrs->GetItemState(SDRATTR_TEXT_FITTOSIZE) != SfxItemState::DONTCARE)
259  {
260  drawing::TextFitToSizeType const eFTS =
261  rAttrs->Get( SDRATTR_TEXT_FITTOSIZE ).GetValue();
262  if (eFTS == drawing::TextFitToSizeType_AUTOFIT || eFTS == drawing::TextFitToSizeType_NONE)
263  m_xTsbFitToSize->set_state( TRISTATE_FALSE );
264  else
265  m_xTsbFitToSize->set_state( TRISTATE_TRUE );
266  }
267  else
268  m_xTsbFitToSize->set_state( TRISTATE_INDET );
269  m_xTsbFitToSize->save_state();
270 
271  if( rAttrs->GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SfxItemState::DONTCARE )
272  {
273  bool bContour = rAttrs->Get( SDRATTR_TEXT_CONTOURFRAME ).GetValue();
274  m_xTsbContour->set_state( bContour ? TRISTATE_TRUE : TRISTATE_FALSE );
275  }
276  else
277  m_xTsbContour->set_state( TRISTATE_INDET );
278  m_xTsbContour->save_state();
279 
280  ClickHdl_Impl(*m_xTsbContour);
281 }
282 
283 /*************************************************************************
284 |*
285 |* fills the passed item set with dialog box attributes
286 |*
287 \************************************************************************/
288 
290 {
291  SfxItemPool* pPool = rAttrs->GetPool();
292  DBG_ASSERT( pPool, "Where is the pool?" );
293  MapUnit eUnit = pPool->GetMetric( SDRATTR_TEXT_LEFTDIST );
294 
295  sal_Int32 nValue;
296  TriState eState;
297 
298  if( m_xMtrFldLeft->get_value_changed_from_saved() )
299  {
300  nValue = GetCoreValue( *m_xMtrFldLeft, eUnit );
301  rAttrs->Put( makeSdrTextLeftDistItem( nValue ) );
302  }
303 
304  if( m_xMtrFldRight->get_value_changed_from_saved() )
305  {
306  nValue = GetCoreValue( *m_xMtrFldRight, eUnit );
307  rAttrs->Put( makeSdrTextRightDistItem( nValue ) );
308  }
309 
310  if( m_xMtrFldTop->get_value_changed_from_saved() )
311  {
312  nValue = GetCoreValue( *m_xMtrFldTop, eUnit );
313  rAttrs->Put( makeSdrTextUpperDistItem( nValue ) );
314  }
315 
316  if( m_xMtrFldBottom->get_value_changed_from_saved() )
317  {
318  nValue = GetCoreValue( *m_xMtrFldBottom, eUnit );
319  rAttrs->Put( makeSdrTextLowerDistItem( nValue ) );
320  }
321 
322  eState = m_xTsbAutoGrowHeight->get_state();
323  if( m_xTsbAutoGrowHeight->get_state_changed_from_saved() )
324  {
325  rAttrs->Put( makeSdrTextAutoGrowHeightItem( TRISTATE_TRUE == eState ) );
326  }
327 
328  eState = m_xTsbAutoGrowWidth->get_state();
329  if( m_xTsbAutoGrowWidth->get_state_changed_from_saved() )
330  {
331  rAttrs->Put( makeSdrTextAutoGrowWidthItem( TRISTATE_TRUE == eState ) );
332  }
333 
334  eState = m_xTsbAutoGrowSize->get_state();
335  if( m_xTsbAutoGrowSize->get_state_changed_from_saved() )
336  {
337  rAttrs->Put( makeSdrTextAutoGrowHeightItem( TRISTATE_TRUE == eState ) );
338  }
339 
340  eState = m_xTsbWordWrapText->get_state();
341  if( m_xTsbWordWrapText->get_state_changed_from_saved() )
342  {
343  rAttrs->Put( makeSdrTextWordWrapItem( TRISTATE_TRUE == eState ) );
344  }
345 
346  eState = m_xTsbContour->get_state();
347  if( m_xTsbContour->get_state_changed_from_saved() )
348  {
349  rAttrs->Put( makeSdrTextContourFrameItem( TRISTATE_TRUE == eState ) );
350  }
351 
352  eState = m_xTsbFitToSize->get_state();
353  if( m_xTsbFitToSize->get_state_changed_from_saved() )
354  {
355  drawing::TextFitToSizeType eFTS;
356  switch( eState )
357  {
358  default: ; //prevent warning
359  OSL_FAIL( "svx::SvxTextAttrPage::FillItemSet(), unhandled state!" );
360  [[fallthrough]];
361  case TRISTATE_FALSE: eFTS = drawing::TextFitToSizeType_AUTOFIT; break;
362  case TRISTATE_TRUE: eFTS = drawing::TextFitToSizeType_PROPORTIONAL; break;
363  }
364  rAttrs->Put( SdrTextFitToSizeTypeItem( eFTS ) );
365  }
366 
367  // centered
369  SdrTextVertAdjust eTVA;
370  SdrTextHorzAdjust eTHA;
371 
372  switch( eRP )
373  {
374  default:
375  case RectPoint::LT: eTVA = SDRTEXTVERTADJUST_TOP;
376  eTHA = SDRTEXTHORZADJUST_LEFT; break;
377  case RectPoint::LM: eTVA = SDRTEXTVERTADJUST_CENTER;
378  eTHA = SDRTEXTHORZADJUST_LEFT; break;
379  case RectPoint::LB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
380  eTHA = SDRTEXTHORZADJUST_LEFT; break;
381  case RectPoint::MT: eTVA = SDRTEXTVERTADJUST_TOP;
382  eTHA = SDRTEXTHORZADJUST_CENTER; break;
383  case RectPoint::MM: eTVA = SDRTEXTVERTADJUST_CENTER;
384  eTHA = SDRTEXTHORZADJUST_CENTER; break;
385  case RectPoint::MB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
386  eTHA = SDRTEXTHORZADJUST_CENTER; break;
387  case RectPoint::RT: eTVA = SDRTEXTVERTADJUST_TOP;
388  eTHA = SDRTEXTHORZADJUST_RIGHT; break;
389  case RectPoint::RM: eTVA = SDRTEXTVERTADJUST_CENTER;
390  eTHA = SDRTEXTHORZADJUST_RIGHT; break;
391  case RectPoint::RB: eTVA = SDRTEXTVERTADJUST_BOTTOM;
392  eTHA = SDRTEXTHORZADJUST_RIGHT; break;
393  }
394 
395  // #103516# Do not change values if adjust controls were disabled.
396  bool bIsDisabled(m_aCtlPosition.IsCompletelyDisabled());
397 
398  if(!bIsDisabled)
399  {
400  if( m_xTsbFullWidth->get_state() == TRISTATE_TRUE )
401  {
404  else
406  }
407 
408  if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SfxItemState::DONTCARE )
409  {
410  SdrTextVertAdjust eOldTVA = rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ).GetValue();
411  if( eOldTVA != eTVA )
412  rAttrs->Put( SdrTextVertAdjustItem( eTVA ) );
413  }
414  else
415  rAttrs->Put( SdrTextVertAdjustItem( eTVA ) );
416 
417  if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SfxItemState::DONTCARE )
418  {
419  SdrTextHorzAdjust eOldTHA = rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ).GetValue();
420  if( eOldTHA != eTHA )
421  rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) );
422  }
423  else
424  rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) );
425  }
426 
427  return true;
428 }
429 
431 {
432  switch (m_eObjKind)
433  {
434  case OBJ_NONE:
435  // indeterminate, show them all
438  m_xCustomShapeText->show();
439  m_xDrawingText->show();
440  break;
441  case OBJ_TEXT:
442  case OBJ_TITLETEXT:
443  case OBJ_OUTLINETEXT:
444  case OBJ_CAPTION:
445  // contour NOT possible for pure text objects
447 
448  // adjusting width and height is ONLY possible for pure text objects
450  m_xCustomShapeText->hide();
451  m_xDrawingText->show();
452  break;
453  case OBJ_CUSTOMSHAPE:
456  m_xDrawingText->hide();
457  m_xCustomShapeText->show();
458  break;
459  default:
462  m_xCustomShapeText->hide();
463  m_xDrawingText->show();
464  break;
465  }
466 
469  m_xTsbFitToSize->set_visible( bFitToSizeEnabled );
470  m_xTsbContour->set_visible( bContourEnabled );
473 }
474 
475 std::unique_ptr<SfxTabPage> SvxTextAttrPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrs)
476 {
477  return std::make_unique<SvxTextAttrPage>(pPage, pController, *rAttrs);
478 }
479 
483 {
484  if (m_xTsbFullWidth->get_state() != TRISTATE_TRUE)
485  return;
486 
487  // Depending on write direction and currently checked anchor we have
488  // to uncheck the "full width" button.
490  switch( eRP )
491  {
492  case RectPoint::LT:
493  case RectPoint::LM:
494  case RectPoint::LB:
495  case RectPoint::RT:
496  case RectPoint::RM:
497  case RectPoint::RB:
498  m_xTsbFullWidth->set_state( TRISTATE_FALSE );
499  break;
500  default: ;//prevent warning
501  }
502  else
503  switch (eRP)
504  {
505  case RectPoint::LT:
506  case RectPoint::MT:
507  case RectPoint::RT:
508  case RectPoint::LB:
509  case RectPoint::MB:
510  case RectPoint::RB:
511  m_xTsbFullWidth->set_state( TRISTATE_FALSE );
512  break;
513  default: ;//prevent warning
514  }
515 }
516 
517 
518 /*************************************************************************
519 |*
520 |* possibly changes the position of the position-control
521 |*
522 \************************************************************************/
523 
528 IMPL_LINK_NOARG(SvxTextAttrPage, ClickFullWidthHdl_Impl, weld::Toggleable&, void)
529 {
530  if( m_xTsbFullWidth->get_state() != TRISTATE_TRUE )
531  return;
532 
533  if (IsTextDirectionLeftToRight())
534  {
535  // Move text anchor to horizontal middle axis.
536  switch( m_aCtlPosition.GetActualRP() )
537  {
538  case RectPoint::LT:
539  case RectPoint::RT:
540  m_aCtlPosition.SetActualRP( RectPoint::MT );
541  break;
542 
543  case RectPoint::LM:
544  case RectPoint::RM:
545  m_aCtlPosition.SetActualRP( RectPoint::MM );
546  break;
547 
548  case RectPoint::LB:
549  case RectPoint::RB:
550  m_aCtlPosition.SetActualRP( RectPoint::MB );
551  break;
552  default: ;//prevent warning
553  }
554  }
555  else
556  {
557  // Move text anchor to vertical middle axis.
558  switch( m_aCtlPosition.GetActualRP() )
559  {
560  case RectPoint::LT:
561  case RectPoint::LB:
562  m_aCtlPosition.SetActualRP( RectPoint::LM );
563  break;
564 
565  case RectPoint::MT:
566  case RectPoint::MB:
567  m_aCtlPosition.SetActualRP( RectPoint::MM );
568  break;
569 
570  case RectPoint::RT:
571  case RectPoint::RB:
572  m_aCtlPosition.SetActualRP( RectPoint::RM );
573  break;
574  default: ;//prevent warning
575  }
576  }
577 }
578 
579 /*************************************************************************
580 |*
581 |* enables/disables "size at text" or "adjust to frame"
582 |*
583 \************************************************************************/
584 
585 IMPL_LINK(SvxTextAttrPage, ClickHdl_Impl, weld::Toggleable&, rButton, void)
586 {
587  if (&rButton == m_xTsbAutoGrowSize.get())
588  {
589  m_xTsbAutoGrowHeight->set_state(m_xTsbAutoGrowSize->get_state());
590  if (m_xTsbAutoGrowSize->get_state() == TRISTATE_TRUE)
591  {
592  m_xTsbFitToSize->set_state(TRISTATE_FALSE);
593  m_xTsbContour->set_state(TRISTATE_FALSE);
594  }
595  }
596  else if (&rButton == m_xTsbAutoGrowHeight.get())
597  m_xTsbAutoGrowSize->set_state(m_xTsbAutoGrowHeight->get_state());
598 
599  bool bAutoGrowWidth = m_xTsbAutoGrowWidth->get_state() == TRISTATE_TRUE;
600  bool bAutoGrowHeight = m_xTsbAutoGrowHeight->get_state() == TRISTATE_TRUE;
601  bool bFitToSize = m_xTsbFitToSize->get_state() == TRISTATE_TRUE;
602  bool bContour = m_xTsbContour->get_state() == TRISTATE_TRUE;
603 
604  m_xTsbContour->set_sensitive( !bFitToSize &&
605  !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
606  bContourEnabled );
607 
608  m_xTsbAutoGrowWidth->set_sensitive( !bFitToSize &&
609  !( bContour && bContourEnabled ) &&
610  bAutoGrowWidthEnabled );
611 
612  m_xTsbAutoGrowHeight->set_sensitive( !bFitToSize &&
613  !( bContour && bContourEnabled ) &&
614  bAutoGrowHeightEnabled );
615 
616  m_xTsbFitToSize->set_sensitive( !( ( bAutoGrowWidth && bAutoGrowWidthEnabled ) || ( bAutoGrowHeight && bAutoGrowHeightEnabled ) ) &&
617  !( bContour && bContourEnabled ) &&
618  bFitToSizeEnabled );
619 
620  // #101901# enable/disable metric fields and decorations dependent of contour
621  m_xFlDistance->set_sensitive(!bContour);
622 
623  if( bContour && bContourEnabled )
624  {
625  m_xMtrFldLeft->set_value(0, FieldUnit::NONE);
626  m_xMtrFldRight->set_value(0, FieldUnit::NONE);
627  m_xMtrFldTop->set_value(0, FieldUnit::NONE);
628  m_xMtrFldBottom->set_value(0, FieldUnit::NONE);
629  }
630 
631  // #103516# Do the setup based on states of hor/ver adjust
632  SfxItemState eVState = rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
633  SfxItemState eHState = rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
634  bool bHorAndVer(SfxItemState::DONTCARE == eVState || SfxItemState::DONTCARE == eHState);
635 
636  // #83698# enable/disable text anchoring dependent of contour
637  m_xFlPosition->set_sensitive(!bContour && !bHorAndVer);
638 }
639 
640 
642 {
643  // Determine the text writing direction with left to right as default.
644  bool bLeftToRightDirection = true;
646 
647  if(SfxItemState::DONTCARE != eState)
648  {
650  if (rItem.GetValue() == css::text::WritingMode_TB_RL)
651  bLeftToRightDirection = false;
652  }
653  return bLeftToRightDirection;
654 }
655 
657 {
658  const CntUInt16Item* pObjTypeItem = aSet.GetItem<CntUInt16Item>(SID_SVXTEXTATTRPAGE_OBJKIND, false);
659 
660  if (pObjTypeItem)
661  SetObjKind(static_cast<SdrObjKind>(pObjTypeItem->GetValue()));
662 
663  Construct();
664 }
665 
666 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr TypedWhichId< SdrOnOffItem > SDRATTR_TEXT_AUTOGROWHEIGHT(SDRATTR_MISC_FIRST+2)
bool bAutoGrowSizeEnabled
Definition: textattr.hxx:40
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
SdrMetricItem makeSdrTextUpperDistItem(tools::Long mnHeight)
FieldUnit
bool bWordWrapTextEnabled
Definition: textattr.hxx:44
constexpr TypedWhichId< SdrTextHorzAdjustItem > SDRATTR_TEXT_HORZADJUST(SDRATTR_MISC_FIRST+13)
void SetActualRP(RectPoint eNewRP)
SDRTEXTVERTADJUST_TOP
std::unique_ptr< weld::Frame > m_xFlPosition
Definition: textattr.hxx:62
static constexpr auto Items
SvxTextAttrPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
Definition: textattr.cxx:49
virtual bool FillItemSet(SfxItemSet *) override
Definition: textattr.cxx:289
constexpr TypedWhichId< SdrOnOffItem > SDRATTR_TEXT_AUTOGROWWIDTH(SDRATTR_MISC_FIRST+12)
void SetControlSettings(RectPoint eRpt, sal_uInt16 nBorder)
void Reset()
void DoCompletelyDisable(bool bNew)
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
SdrTextHorzAdjust
constexpr TypedWhichId< SdrOnOffItem > SDRATTR_TEXT_CONTOURFRAME(SDRATTR_MISC_FIRST+21)
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldBottom
Definition: textattr.hxx:61
std::unique_ptr< weld::CheckButton > m_xTsbAutoGrowHeight
Definition: textattr.hxx:52
bool bContourEnabled
Definition: textattr.hxx:41
sal_uInt16 GetValue() const
RectPoint GetActualRP() const
SDRTEXTVERTADJUST_BLOCK
SdrOnOffItem makeSdrTextWordWrapItem(bool bAuto)
SdrMetricItem makeSdrTextRightDistItem(tools::Long mnHeight)
SdrMetricItem makeSdrTextLowerDistItem(tools::Long mnHeight)
TRISTATE_TRUE
SdrOnOffItem makeSdrTextAutoGrowHeightItem(bool bAuto)
FieldUnit GetModuleFieldUnit(const SfxItemSet &rSet)
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
SdrObjKind m_eObjKind
Definition: textattr.hxx:38
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldLeft
Definition: textattr.hxx:58
std::unique_ptr< weld::CheckButton > m_xTsbFitToSize
Definition: textattr.hxx:53
bool bFitToSizeEnabled
Definition: textattr.hxx:45
css::text::WritingMode GetValue() const
constexpr TypedWhichId< SdrOnOffItem > SDRATTR_TEXT_WORDWRAP(SDRATTR_MISC_FIRST+24)
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: textattr.cxx:656
SDRTEXTHORZADJUST_CENTER
SdrOnOffItem makeSdrTextAutoGrowWidthItem(bool bAuto)
bool bAutoGrowHeightEnabled
Definition: textattr.hxx:43
void SetState(CTL_STATE nState)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXT_LOWERDIST(SDRATTR_MISC_FIRST+7)
TRISTATE_INDET
const SfxItemSet & rOutAttrs
Definition: textattr.hxx:37
std::unique_ptr< weld::CheckButton > m_xTsbFullWidth
Definition: textattr.hxx:64
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldTop
Definition: textattr.hxx:60
void Construct()
Definition: textattr.cxx:430
SdrOnOffItem makeSdrTextContourFrameItem(bool bOn)
virtual tools::Long GetValue() const override
std::unique_ptr< weld::CheckButton > m_xTsbWordWrapText
Definition: textattr.hxx:55
virtual void PointChanged(weld::DrawingArea *pWindow, RectPoint eRP) override
Check whether we have to uncheck the "Full width" check box.
Definition: textattr.cxx:482
SDRTEXTVERTADJUST_BOTTOM
SDRTEXTHORZADJUST_BLOCK
RectPoint
constexpr TypedWhichId< SvxWritingModeItem > SDRATTR_TEXTDIRECTION(SDRATTR_NOTPERSIST_FIRST+34)
constexpr TypedWhichId< SdrTextFitToSizeTypeItem > SDRATTR_TEXT_FITTOSIZE(SDRATTR_MISC_FIRST+3)
SDRTEXTHORZADJUST_LEFT
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
OBJ_CAPTION
constexpr TypedWhichId< SdrTextVertAdjustItem > SDRATTR_TEXT_VERTADJUST(SDRATTR_MISC_FIRST+8)
TRISTATE_FALSE
int GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
bool IsCompletelyDisabled() const
bool IsTextDirectionLeftToRight() const
Return whether the text direction is from left to right () or top to bottom ()...
Definition: textattr.cxx:641
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXT_LEFTDIST(SDRATTR_MISC_FIRST+4)
std::unique_ptr< weld::CheckButton > m_xTsbContour
Definition: textattr.hxx:54
IMPL_LINK(SvxTextAttrPage, ClickHdl_Impl, weld::Toggleable &, rButton, void)
Definition: textattr.cxx:585
IMPL_LINK_NOARG(SvxTextAttrPage, ClickFullWidthHdl_Impl, weld::Toggleable &, void)
When switching the "full width" check button on the text anchor may have to be moved to a valid and a...
Definition: textattr.cxx:528
void SetMetricValue(weld::MetricSpinButton &rField, int nCoreValue, MapUnit eUnit)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldRight
Definition: textattr.hxx:59
std::unique_ptr< weld::CheckButton > m_xTsbAutoGrowWidth
Definition: textattr.hxx:51
SdrMetricItem makeSdrTextLeftDistItem(tools::Long mnHeight)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXT_UPPERDIST(SDRATTR_MISC_FIRST+6)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
Definition: textattr.cxx:475
SDRTEXTHORZADJUST_RIGHT
virtual ~SvxTextAttrPage() override
Definition: textattr.cxx:95
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
std::unique_ptr< weld::Widget > m_xDrawingText
Definition: textattr.hxx:49
void SetObjKind(SdrObjKind eObjKind)
Definition: textattr.hxx:88
SfxItemState
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXT_RIGHTDIST(SDRATTR_MISC_FIRST+5)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual void Reset(const SfxItemSet *) override
Definition: textattr.cxx:105
bool bAutoGrowWidthEnabled
Definition: textattr.hxx:42
OBJ_TITLETEXT
OBJ_CUSTOMSHAPE
MapUnit
std::unique_ptr< weld::Widget > m_xCustomShapeText
Definition: textattr.hxx:50
OBJ_OUTLINETEXT
TriState
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
std::unique_ptr< weld::CheckButton > m_xTsbAutoGrowSize
Definition: textattr.hxx:56
OBJ_NONE
OBJ_TEXT
SvxRectCtl m_aCtlPosition
Definition: textattr.hxx:47
SdrTextVertAdjust
sal_Int16 nValue
SDRTEXTVERTADJUST_CENTER
static const WhichRangesContainer pRanges
Definition: textattr.hxx:35