LibreOffice Module cui (master)  1
measure.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 <strings.hrc>
21 #include <dialmgr.hxx>
22 
23 #include <svx/svxids.hrc>
24 #include <svx/dlgutil.hxx>
25 #include <svx/measctrl.hxx>
26 #include <svx/ofaitem.hxx>
27 #include <svx/strarray.hxx>
28 #include <svx/svdview.hxx>
29 #include <svx/sxmbritm.hxx>
30 #include <svx/sxmlhitm.hxx>
31 #include <svx/sxmtfitm.hxx>
32 #include <svx/sxmtpitm.hxx>
33 #include <svx/sxmtritm.hxx>
34 #include <svx/sxmuitm.hxx>
35 #include <svtools/unitconv.hxx>
36 
37 #include <measure.hxx>
38 
40  svl::Items<SDRATTR_MEASURE_FIRST, SDRATTR_MEASURE_LAST>);
41 
42 /*************************************************************************
43 |*
44 |* Dialog to change measure-attributes
45 |*
46 \************************************************************************/
48  const SdrView* pSdrView)
49  : SfxSingleTabDialogController(pParent, &rInAttrs)
50 {
51  auto xPage = std::make_unique<SvxMeasurePage>(get_content_area(), this, rInAttrs);
52 
53  xPage->SetView(pSdrView);
54  xPage->Construct();
55 
56  SetTabPage(std::move(xPage));
57  m_xDialog->set_title(CuiResId(RID_CUISTR_DIMENSION_LINE));
58 }
59 
60 /*************************************************************************
61 |*
62 |* Tabpage for changing measure-attributes
63 |*
64 \************************************************************************/
65 
67  : SvxTabPage(pPage, pController, "cui/ui/dimensionlinestabpage.ui", "DimensionLinesTabPage", rInAttrs)
68  , rOutAttrs(rInAttrs)
69  , aAttrSet(*rInAttrs.GetPool())
70  , pView(nullptr)
71  , eUnit(MapUnit::Map100thMM)
72  , bPositionModified(false)
73  , m_aCtlPosition(this)
74  , m_xMtrFldLineDist(m_xBuilder->weld_metric_spin_button("MTR_LINE_DIST", FieldUnit::MM))
75  , m_xMtrFldHelplineOverhang(m_xBuilder->weld_metric_spin_button("MTR_FLD_HELPLINE_OVERHANG", FieldUnit::MM))
76  , m_xMtrFldHelplineDist(m_xBuilder->weld_metric_spin_button("MTR_FLD_HELPLINE_DIST", FieldUnit::MM))
77  , m_xMtrFldHelpline1Len(m_xBuilder->weld_metric_spin_button("MTR_FLD_HELPLINE1_LEN", FieldUnit::MM))
78  , m_xMtrFldHelpline2Len(m_xBuilder->weld_metric_spin_button("MTR_FLD_HELPLINE2_LEN", FieldUnit::MM))
79  , m_xTsbBelowRefEdge(m_xBuilder->weld_check_button("TSB_BELOW_REF_EDGE"))
80  , m_xMtrFldDecimalPlaces(m_xBuilder->weld_spin_button("MTR_FLD_DECIMALPLACES"))
81  , m_xTsbAutoPosV(m_xBuilder->weld_check_button("TSB_AUTOPOSV"))
82  , m_xTsbAutoPosH(m_xBuilder->weld_check_button("TSB_AUTOPOSH"))
83  , m_xTsbShowUnit(m_xBuilder->weld_check_button("TSB_SHOW_UNIT"))
84  , m_xLbUnit(m_xBuilder->weld_combo_box("LB_UNIT"))
85  , m_xTsbParallel(m_xBuilder->weld_check_button("TSB_PARALLEL"))
86  , m_xFtAutomatic(m_xBuilder->weld_label("STR_MEASURE_AUTOMATIC"))
87  , m_xCtlPosition(new weld::CustomWeld(*m_xBuilder, "CTL_POSITION", m_aCtlPosition))
88  , m_xCtlPreview(new weld::CustomWeld(*m_xBuilder, "CTL_PREVIEW", m_aCtlPreview))
89 {
90  m_aCtlPreview.SetAttributes(rInAttrs);
91 
92  FillUnitLB();
93 
94  const FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
95  SetFieldUnit( *m_xMtrFldLineDist, eFUnit );
100  if( eFUnit == FieldUnit::MM )
101  {
102  m_xMtrFldLineDist->set_increments(50, 500, FieldUnit::NONE);
103  m_xMtrFldHelplineOverhang->set_increments(50, 500, FieldUnit::NONE);
104  m_xMtrFldHelplineDist->set_increments(50, 500, FieldUnit::NONE);
105  m_xMtrFldHelpline1Len->set_increments(50, 500, FieldUnit::NONE);
106  m_xMtrFldHelpline2Len->set_increments(50, 500, FieldUnit::NONE);
107  }
108 
109  m_xTsbAutoPosV->connect_toggled(LINK( this, SvxMeasurePage, ClickAutoPosHdl_Impl));
110  m_xTsbAutoPosH->connect_toggled(LINK(this, SvxMeasurePage, ClickAutoPosHdl_Impl));
111 
112  Link<weld::MetricSpinButton&,void> aLink(LINK(this, SvxMeasurePage, ChangeAttrEditHdl_Impl));
113  m_xMtrFldLineDist->connect_value_changed(aLink);
114  m_xMtrFldHelplineOverhang->connect_value_changed(aLink);
115  m_xMtrFldHelplineDist->connect_value_changed(aLink);
116  m_xMtrFldHelpline1Len->connect_value_changed(aLink);
117  m_xMtrFldHelpline2Len->connect_value_changed(aLink);
118  m_xMtrFldDecimalPlaces->connect_value_changed(LINK(this, SvxMeasurePage, ChangeAttrSpinHdl_Impl));
119  m_xTsbBelowRefEdge->connect_toggled(LINK(this, SvxMeasurePage, ChangeAttrClickHdl_Impl));
120  m_xTsbParallel->connect_toggled( LINK( this, SvxMeasurePage, ChangeAttrClickHdl_Impl));
121  m_xTsbShowUnit->connect_toggled(LINK(this, SvxMeasurePage, ChangeAttrClickHdl_Impl));
122  m_xLbUnit->connect_changed(LINK(this, SvxMeasurePage, ChangeAttrListBoxHdl_Impl));
123 }
124 
126 {
127  m_xCtlPreview.reset();
128  m_xCtlPosition.reset();
129 }
130 
131 /*************************************************************************
132 |*
133 |* read the delivered Item-Set
134 |*
135 \************************************************************************/
136 
137 void SvxMeasurePage::Reset( const SfxItemSet* rAttrs )
138 {
139  SfxItemPool* pPool = rAttrs->GetPool();
140  DBG_ASSERT( pPool, "Where is the pool?" );
142 
143  const SfxPoolItem* pItem = GetItem( *rAttrs, SDRATTR_MEASURELINEDIST );
144 
145  // SdrMeasureLineDistItem
146  if( pItem == nullptr )
147  pItem = &pPool->GetDefaultItem( SDRATTR_MEASURELINEDIST );
148  SetMetricValue(*m_xMtrFldLineDist, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit);
149  m_xMtrFldLineDist->save_value();
150 
151  // SdrMeasureHelplineOverhangItem
152  pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEOVERHANG );
153  if( pItem == nullptr )
155  SetMetricValue(*m_xMtrFldHelplineOverhang, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
156  eUnit);
157  m_xMtrFldHelplineOverhang->save_value();
158 
159  // SdrMeasureHelplineDistItem
160  pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEDIST );
161  if( pItem == nullptr )
162  pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST );
163  SetMetricValue(*m_xMtrFldHelplineDist, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
164  eUnit);
165  m_xMtrFldHelplineDist->save_value();
166 
167  // SdrMeasureHelpline1LenItem
168  pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE1LEN );
169  if( pItem == nullptr )
170  pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN );
171  SetMetricValue(*m_xMtrFldHelpline1Len, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
172  eUnit);
173  m_xMtrFldHelpline1Len->save_value();
174 
175  // SdrMeasureHelpline2LenItem
176  pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE2LEN );
177  if( pItem == nullptr )
178  pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN );
179  SetMetricValue(*m_xMtrFldHelpline2Len, static_cast<const SdrMetricItem*>(pItem)->GetValue(),
180  eUnit);
181  m_xMtrFldHelpline2Len->save_value();
182 
183  // SdrMeasureBelowRefEdgeItem
184  if( rAttrs->GetItemState( SDRATTR_MEASUREBELOWREFEDGE ) != SfxItemState::DONTCARE )
185  {
186  m_xTsbBelowRefEdge->set_state( rAttrs->Get( SDRATTR_MEASUREBELOWREFEDGE ).
188  }
189  else
190  {
191  m_xTsbBelowRefEdge->set_state( TRISTATE_INDET );
192  }
193  m_xTsbBelowRefEdge->save_state();
194 
195  // SdrMeasureDecimalPlacesItem
196  pItem = GetItem( *rAttrs, SDRATTR_MEASUREDECIMALPLACES );
197  if( pItem == nullptr )
198  pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES );
199  m_xMtrFldDecimalPlaces->set_value(
200  static_cast<const SdrMeasureDecimalPlacesItem*>(pItem)->GetValue());
201  m_xMtrFldDecimalPlaces->save_value();
202 
203  // SdrMeasureTextRota90Item
204  // Attention: negate !
205  if( rAttrs->GetItemState( SDRATTR_MEASURETEXTROTA90 ) != SfxItemState::DONTCARE )
206  {
207  m_xTsbParallel->set_state( rAttrs->Get( SDRATTR_MEASURETEXTROTA90 ).
209  }
210  else
211  {
212  m_xTsbParallel->set_state( TRISTATE_INDET );
213  }
214  m_xTsbParallel->save_state();
215 
216  // SdrMeasureShowUnitItem
217  if( rAttrs->GetItemState( SDRATTR_MEASURESHOWUNIT ) != SfxItemState::DONTCARE )
218  {
219  m_xTsbShowUnit->set_state( rAttrs->Get( SDRATTR_MEASURESHOWUNIT ).
221  }
222  else
223  {
224  m_xTsbShowUnit->set_state( TRISTATE_INDET );
225  }
226  m_xTsbShowUnit->save_state();
227 
228  // SdrMeasureUnitItem
229  if( rAttrs->GetItemState( SDRATTR_MEASUREUNIT ) != SfxItemState::DONTCARE )
230  {
231  tools::Long nFieldUnit = static_cast<tools::Long>(rAttrs->Get( SDRATTR_MEASUREUNIT ).GetValue());
232 
233  for (sal_Int32 i = 0; i < m_xLbUnit->get_count(); ++i)
234  {
235  if (m_xLbUnit->get_id(i).toInt32() == nFieldUnit)
236  {
237  m_xLbUnit->set_active(i);
238  break;
239  }
240  }
241  }
242  else
243  {
244  m_xLbUnit->set_active(-1);
245  }
246  m_xLbUnit->save_value();
247 
248  // Position
249  if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::DONTCARE )
250  {
251  css::drawing::MeasureTextVertPos eVPos =
252  rAttrs->Get( SDRATTR_MEASURETEXTVPOS ).GetValue();
253  {
254  if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE )
255  {
256  css::drawing::MeasureTextHorzPos eHPos =
257  rAttrs->Get( SDRATTR_MEASURETEXTHPOS ).GetValue();
258  RectPoint eRP = RectPoint::MM;
259  switch( eVPos )
260  {
261  case css::drawing::MeasureTextVertPos_EAST:
262  switch( eHPos )
263  {
264  case css::drawing::MeasureTextHorzPos_LEFTOUTSIDE: eRP = RectPoint::LT; break;
265  case css::drawing::MeasureTextHorzPos_INSIDE: eRP = RectPoint::MT; break;
266  case css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE: eRP = RectPoint::RT; break;
267  case css::drawing::MeasureTextHorzPos_AUTO: eRP = RectPoint::MT; break;
268  default: break;
269  }
270  break;
271  case css::drawing::MeasureTextVertPos_CENTERED:
272  switch( eHPos )
273  {
274  case css::drawing::MeasureTextHorzPos_LEFTOUTSIDE: eRP = RectPoint::LM; break;
275  case css::drawing::MeasureTextHorzPos_INSIDE: eRP = RectPoint::MM; break;
276  case css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE: eRP = RectPoint::RM; break;
277  case css::drawing::MeasureTextHorzPos_AUTO: eRP = RectPoint::MM; break;
278  default: break;
279  }
280  break;
281  case css::drawing::MeasureTextVertPos_WEST:
282  switch( eHPos )
283  {
284  case css::drawing::MeasureTextHorzPos_LEFTOUTSIDE: eRP = RectPoint::LB; break;
285  case css::drawing::MeasureTextHorzPos_INSIDE: eRP = RectPoint::MB; break;
286  case css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE: eRP = RectPoint::RB; break;
287  case css::drawing::MeasureTextHorzPos_AUTO: eRP = RectPoint::MB; break;
288  default: break;
289  }
290  break;
291  case css::drawing::MeasureTextVertPos_AUTO:
292  switch( eHPos )
293  {
294  case css::drawing::MeasureTextHorzPos_LEFTOUTSIDE: eRP = RectPoint::LM; break;
295  case css::drawing::MeasureTextHorzPos_INSIDE: eRP = RectPoint::MM; break;
296  case css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE: eRP = RectPoint::RM; break;
297  case css::drawing::MeasureTextHorzPos_AUTO: eRP = RectPoint::MM; break;
298  default: break;
299  }
300  break;
301  default: ;//prevent warning
302  }
303 
304  CTL_STATE nState = CTL_STATE::NONE;
305 
306  if (eHPos == css::drawing::MeasureTextHorzPos_AUTO)
307  {
308  m_xTsbAutoPosH->set_state( TRISTATE_TRUE );
309  nState = CTL_STATE::NOHORZ;
310  }
311 
312  if (eVPos == css::drawing::MeasureTextVertPos_AUTO)
313  {
314  m_xTsbAutoPosV->set_state( TRISTATE_TRUE );
315  nState |= CTL_STATE::NOVERT;
316  }
317 
318  m_aCtlPosition.SetState(nState);
320  }
321  }
322  }
323  else
324  {
326  m_xTsbAutoPosV->set_state( TRISTATE_INDET );
327  m_xTsbAutoPosH->set_state( TRISTATE_INDET );
328  }
329 
330  // put the attributes to the preview-control,
331  // otherwise the control don't know about
332  // the settings of the dialog (#67930)
334  m_aCtlPreview.SetAttributes(*rAttrs);
335 
336  bPositionModified = false;
337 }
338 
339 /*************************************************************************
340 |*
341 |* Fill the delivered Item-Set with dialogbox-attributes
342 |*
343 \************************************************************************/
344 
346 {
347  bool bModified = false;
348  sal_Int32 nValue;
349  TriState eState;
350 
351  if( m_xMtrFldLineDist->get_value_changed_from_saved() )
352  {
353  nValue = GetCoreValue( *m_xMtrFldLineDist, eUnit );
354  rAttrs->Put( makeSdrMeasureLineDistItem( nValue ) );
355  bModified = true;
356  }
357 
358  if( m_xMtrFldHelplineOverhang->get_value_changed_from_saved() )
359  {
361  rAttrs->Put( makeSdrMeasureHelplineOverhangItem( nValue ) );
362  bModified = true;
363  }
364 
365  if( m_xMtrFldHelplineDist->get_value_changed_from_saved() )
366  {
368  rAttrs->Put( makeSdrMeasureHelplineDistItem( nValue ) );
369  bModified = true;
370  }
371 
372  if( m_xMtrFldHelpline1Len->get_value_changed_from_saved() )
373  {
375  rAttrs->Put( makeSdrMeasureHelpline1LenItem( nValue ) );
376  bModified = true;
377  }
378 
379  if( m_xMtrFldHelpline2Len->get_value_changed_from_saved() )
380  {
382  rAttrs->Put( makeSdrMeasureHelpline2LenItem( nValue ) );
383  bModified = true;
384  }
385 
386  eState = m_xTsbBelowRefEdge->get_state();
387  if( m_xTsbBelowRefEdge->get_state_changed_from_saved() )
388  {
389  rAttrs->Put( SdrMeasureBelowRefEdgeItem( TRISTATE_TRUE == eState ) );
390  bModified = true;
391  }
392 
393  if( m_xMtrFldDecimalPlaces->get_value_changed_from_saved() )
394  {
395  nValue = m_xMtrFldDecimalPlaces->get_value();
396  rAttrs->Put(
398  sal::static_int_cast< sal_Int16 >( nValue ) ) );
399  bModified = true;
400  }
401 
402  eState = m_xTsbParallel->get_state();
403  if( m_xTsbParallel->get_state_changed_from_saved() )
404  {
405  rAttrs->Put( SdrMeasureTextRota90Item( TRISTATE_FALSE == eState ) );
406  bModified = true;
407  }
408 
409  eState = m_xTsbShowUnit->get_state();
410  if( m_xTsbShowUnit->get_state_changed_from_saved() )
411  {
412  rAttrs->Put( SdrYesNoItem(SDRATTR_MEASURESHOWUNIT, TRISTATE_TRUE == eState ) );
413  bModified = true;
414  }
415 
416  int nPos = m_xLbUnit->get_active();
417  if( m_xLbUnit->get_value_changed_from_saved() )
418  {
419  if (nPos != -1)
420  {
421  sal_uInt16 nFieldUnit = m_xLbUnit->get_id(nPos).toUInt32();
422  FieldUnit _eUnit = static_cast<FieldUnit>(nFieldUnit);
423  rAttrs->Put( SdrMeasureUnitItem( _eUnit ) );
424  bModified = true;
425  }
426  }
427 
428  if( bPositionModified )
429  {
430  // Position
431  css::drawing::MeasureTextVertPos eVPos;
432  css::drawing::MeasureTextHorzPos eHPos;
433 
435  switch( eRP )
436  {
437  default:
438  case RectPoint::LT: eVPos = css::drawing::MeasureTextVertPos_EAST;
439  eHPos = css::drawing::MeasureTextHorzPos_LEFTOUTSIDE; break;
440  case RectPoint::LM: eVPos = css::drawing::MeasureTextVertPos_CENTERED;
441  eHPos = css::drawing::MeasureTextHorzPos_LEFTOUTSIDE; break;
442  case RectPoint::LB: eVPos = css::drawing::MeasureTextVertPos_WEST;
443  eHPos = css::drawing::MeasureTextHorzPos_LEFTOUTSIDE; break;
444  case RectPoint::MT: eVPos = css::drawing::MeasureTextVertPos_EAST;
445  eHPos = css::drawing::MeasureTextHorzPos_INSIDE; break;
446  case RectPoint::MM: eVPos = css::drawing::MeasureTextVertPos_CENTERED;
447  eHPos = css::drawing::MeasureTextHorzPos_INSIDE; break;
448  case RectPoint::MB: eVPos = css::drawing::MeasureTextVertPos_WEST;
449  eHPos = css::drawing::MeasureTextHorzPos_INSIDE; break;
450  case RectPoint::RT: eVPos = css::drawing::MeasureTextVertPos_EAST;
451  eHPos = css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE; break;
452  case RectPoint::RM: eVPos = css::drawing::MeasureTextVertPos_CENTERED;
453  eHPos = css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE; break;
454  case RectPoint::RB: eVPos = css::drawing::MeasureTextVertPos_WEST;
455  eHPos = css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE; break;
456  }
457  if (m_xTsbAutoPosH->get_state() == TRISTATE_TRUE)
458  eHPos = css::drawing::MeasureTextHorzPos_AUTO;
459 
460  if (m_xTsbAutoPosV->get_state() == TRISTATE_TRUE)
461  eVPos = css::drawing::MeasureTextVertPos_AUTO;
462 
463  if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::DONTCARE )
464  {
465  css::drawing::MeasureTextVertPos eOldVPos = rOutAttrs.Get(SDRATTR_MEASURETEXTVPOS).GetValue();
466  if( eOldVPos != eVPos )
467  {
468  rAttrs->Put( SdrMeasureTextVPosItem( eVPos ) );
469  bModified = true;
470  }
471  }
472  else
473  {
474  rAttrs->Put( SdrMeasureTextVPosItem( eVPos ) );
475  bModified = true;
476  }
477 
478  if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE )
479  {
480  css::drawing::MeasureTextHorzPos eOldHPos = rOutAttrs.Get( SDRATTR_MEASURETEXTHPOS ).GetValue();
481  if( eOldHPos != eHPos )
482  {
483  rAttrs->Put( SdrMeasureTextHPosItem( eHPos ) );
484  bModified = true;
485  }
486  }
487  else
488  {
489  rAttrs->Put( SdrMeasureTextHPosItem( eHPos ) );
490  bModified = true;
491  }
492  }
493 
494  return bModified;
495 }
496 
497 /*************************************************************************
498 |*
499 |* The View have to set at the measure-object to be able to notify
500 |* unit and floatingpoint-values
501 |*
502 \************************************************************************/
503 
505 {
506  DBG_ASSERT( pView, "No valid View transferred!" );
507 
508  // TTTT
509  // pMeasureObj is member of SvxXMeasurePreview and can only be accessed due to
510  // SvxMeasurePage being a friend. It has its own SdrModel (also in SvxXMeasurePreview)
511  // and 'setting' the SdrModel is a hack. The comment above about 'notify unit and
512  // floatingpoint-values' is not clear, but has to be done another way - if needed.
513  // Checked on original aw080, is just commented out there, too.
514 
515  m_aCtlPreview.Invalidate();
516 }
517 
518 std::unique_ptr<SfxTabPage> SvxMeasurePage::Create(weld::Container* pPage, weld::DialogController* pController,
519  const SfxItemSet* rAttrs)
520 {
521  return std::make_unique<SvxMeasurePage>(pPage, pController, *rAttrs);
522 }
523 
525 {
526  ChangeAttrHdl_Impl(pDrawingArea);
527 }
528 
529 IMPL_LINK( SvxMeasurePage, ClickAutoPosHdl_Impl, weld::Toggleable&, rBox, void )
530 {
531  if (m_xTsbAutoPosH->get_state() == TRISTATE_TRUE)
532  {
533  switch( m_aCtlPosition.GetActualRP() )
534  {
535  case RectPoint::LT:
536  case RectPoint::RT:
537  m_aCtlPosition.SetActualRP( RectPoint::MT );
538  break;
539 
540  case RectPoint::LM:
541  case RectPoint::RM:
542  m_aCtlPosition.SetActualRP( RectPoint::MM );
543  break;
544 
545  case RectPoint::LB:
546  case RectPoint::RB:
547  m_aCtlPosition.SetActualRP( RectPoint::MB );
548  break;
549  default: ;//prevent warning
550  }
551  }
552  if (m_xTsbAutoPosV->get_state() == TRISTATE_TRUE)
553  {
554  switch( m_aCtlPosition.GetActualRP() )
555  {
556  case RectPoint::LT:
557  case RectPoint::LB:
558  m_aCtlPosition.SetActualRP( RectPoint::LM );
559  break;
560 
561  case RectPoint::MT:
562  case RectPoint::MB:
563  m_aCtlPosition.SetActualRP( RectPoint::MM );
564  break;
565 
566  case RectPoint::RT:
567  case RectPoint::RB:
568  m_aCtlPosition.SetActualRP( RectPoint::RM );
569  break;
570  default: ;//prevent warning
571  }
572  }
573  ChangeAttrHdl_Impl(&rBox);
574 }
575 
576 IMPL_LINK(SvxMeasurePage, ChangeAttrClickHdl_Impl, weld::Toggleable&, r, void)
577 {
578  ChangeAttrHdl_Impl(&r);
579 }
580 
581 IMPL_LINK(SvxMeasurePage, ChangeAttrListBoxHdl_Impl, weld::ComboBox&, rBox, void)
582 {
583  ChangeAttrHdl_Impl(&rBox);
584 }
585 
586 IMPL_LINK(SvxMeasurePage, ChangeAttrEditHdl_Impl, weld::MetricSpinButton&, rBox, void)
587 {
588  ChangeAttrHdl_Impl(&rBox);
589 }
590 
591 IMPL_LINK( SvxMeasurePage, ChangeAttrSpinHdl_Impl, weld::SpinButton&, rBox, void )
592 {
593  ChangeAttrHdl_Impl(&rBox);
594 }
595 
597 {
598  if (p == m_xMtrFldLineDist.get())
599  {
600  sal_Int32 nValue = GetCoreValue( *m_xMtrFldLineDist, eUnit );
602  }
603 
604  if (p == m_xMtrFldHelplineOverhang.get())
605  {
608  }
609 
610  if (p == m_xMtrFldHelplineDist.get())
611  {
614  }
615 
616  if (p == m_xMtrFldHelpline1Len.get())
617  {
620  }
621 
622  if (p == m_xMtrFldHelpline2Len.get())
623  {
626  }
627 
628  if (p == m_xTsbBelowRefEdge.get())
629  {
630  TriState eState = m_xTsbBelowRefEdge->get_state();
631  if( eState != TRISTATE_INDET )
633  }
634 
635  if (p == m_xMtrFldDecimalPlaces.get())
636  {
637  sal_Int16 nValue = sal::static_int_cast< sal_Int16 >(
638  m_xMtrFldDecimalPlaces->get_value() );
640  }
641 
642  if (p == m_xTsbParallel.get())
643  {
644  TriState eState = m_xTsbParallel->get_state();
645  if( eState != TRISTATE_INDET )
647  }
648 
649  if (p == m_xTsbShowUnit.get())
650  {
651  TriState eState = m_xTsbShowUnit->get_state();
652  if( eState != TRISTATE_INDET )
654  }
655 
656  if (p == m_xLbUnit.get())
657  {
658  int nPos = m_xLbUnit->get_active();
659  if (nPos != -1)
660  {
661  sal_uInt16 nFieldUnit = m_xLbUnit->get_id(nPos).toUInt32();
662  FieldUnit _eUnit = static_cast<FieldUnit>(nFieldUnit);
663  aAttrSet.Put( SdrMeasureUnitItem( _eUnit ) );
664  }
665  }
666 
667  if (p == m_xTsbAutoPosV.get() || p == m_xTsbAutoPosH.get() || p == m_aCtlPosition.GetDrawingArea())
668  {
669  bPositionModified = true;
670 
671  // Position
673  css::drawing::MeasureTextVertPos eVPos;
674  css::drawing::MeasureTextHorzPos eHPos;
675 
676  switch( eRP )
677  {
678  default:
679  case RectPoint::LT: eVPos = css::drawing::MeasureTextVertPos_EAST;
680  eHPos = css::drawing::MeasureTextHorzPos_LEFTOUTSIDE; break;
681  case RectPoint::LM: eVPos = css::drawing::MeasureTextVertPos_CENTERED;
682  eHPos = css::drawing::MeasureTextHorzPos_LEFTOUTSIDE; break;
683  case RectPoint::LB: eVPos = css::drawing::MeasureTextVertPos_WEST;
684  eHPos = css::drawing::MeasureTextHorzPos_LEFTOUTSIDE; break;
685  case RectPoint::MT: eVPos = css::drawing::MeasureTextVertPos_EAST;
686  eHPos = css::drawing::MeasureTextHorzPos_INSIDE; break;
687  case RectPoint::MM: eVPos = css::drawing::MeasureTextVertPos_CENTERED;
688  eHPos = css::drawing::MeasureTextHorzPos_INSIDE; break;
689  case RectPoint::MB: eVPos = css::drawing::MeasureTextVertPos_WEST;
690  eHPos = css::drawing::MeasureTextHorzPos_INSIDE; break;
691  case RectPoint::RT: eVPos = css::drawing::MeasureTextVertPos_EAST;
692  eHPos = css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE; break;
693  case RectPoint::RM: eVPos = css::drawing::MeasureTextVertPos_CENTERED;
694  eHPos = css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE; break;
695  case RectPoint::RB: eVPos = css::drawing::MeasureTextVertPos_WEST;
696  eHPos = css::drawing::MeasureTextHorzPos_RIGHTOUTSIDE; break;
697  }
698 
699  CTL_STATE nState = CTL_STATE::NONE;
700 
701  if (m_xTsbAutoPosH->get_state() == TRISTATE_TRUE)
702  {
703  eHPos = css::drawing::MeasureTextHorzPos_AUTO;
704  nState = CTL_STATE::NOHORZ;
705  }
706 
707  if (m_xTsbAutoPosV->get_state() == TRISTATE_TRUE)
708  {
709  eVPos = css::drawing::MeasureTextVertPos_AUTO;
710  nState |= CTL_STATE::NOVERT;
711  }
712 
713  if (p == m_xTsbAutoPosV.get() || p == m_xTsbAutoPosH.get())
714  m_aCtlPosition.SetState( nState );
715 
716  aAttrSet.Put( SdrMeasureTextVPosItem( eVPos ) );
717  aAttrSet.Put( SdrMeasureTextHPosItem( eHPos ) );
718  }
719 
721  m_aCtlPreview.Invalidate();
722 }
723 
725 {
726  // fill ListBox with metrics
727 
728  FieldUnit nUnit = FieldUnit::NONE;
729  OUString aStrMetric(m_xFtAutomatic->get_label());
730  m_xLbUnit->append(OUString::number(sal_uInt32(nUnit)), aStrMetric);
731 
732  for( sal_uInt32 i = 0; i < SvxFieldUnitTable::Count(); ++i )
733  {
734  aStrMetric = SvxFieldUnitTable::GetString(i);
736  m_xLbUnit->append(OUString::number(sal_uInt32(nUnit)), aStrMetric);
737  }
738 }
739 
741 {
742  const OfaPtrItem* pOfaPtrItem = aSet.GetItem<OfaPtrItem>(SID_OBJECT_LIST, false);
743 
744  if (pOfaPtrItem)
745  SetView( static_cast<SdrView *>(pOfaPtrItem->GetValue()));
746 
747  Construct();
748 }
749 
750 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
FieldUnit
void SetActualRP(RectPoint eNewRP)
void ChangeAttrHdl_Impl(void const *)
Definition: measure.cxx:596
std::unique_ptr< weld::CustomWeld > m_xCtlPreview
Definition: measure.hxx:56
SdrMetricItem makeSdrMeasureHelpline1LenItem(tools::Long nVal)
std::unique_ptr< weld::SpinButton > m_xMtrFldDecimalPlaces
Definition: measure.hxx:48
void SetView(const SdrView *pSdrView)
Definition: measure.hxx:81
void Construct()
Definition: measure.cxx:504
void Reset()
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
std::unique_ptr< weld::CheckButton > m_xTsbShowUnit
Definition: measure.hxx:51
long Long
constexpr TypedWhichId< SdrMetricItem > SDRATTR_MEASUREHELPLINE1LEN(SDRATTR_MEASURE_FIRST+6)
RectPoint GetActualRP() const
weld::Container * get_content_area()
constexpr TypedWhichId< SdrMeasureUnitItem > SDRATTR_MEASUREUNIT(SDRATTR_MEASURE_FIRST+12)
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldLineDist
Definition: measure.hxx:42
SvxMeasurePage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
Definition: measure.cxx:66
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldHelpline1Len
Definition: measure.hxx:45
SdrMetricItem makeSdrMeasureHelpline2LenItem(tools::Long nVal)
TRISTATE_TRUE
static FieldUnit GetValue(sal_uInt32 i)
static const WhichRangesContainer pRanges
Definition: measure.hxx:31
FieldUnit GetModuleFieldUnit(const SfxItemSet &rSet)
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
SvxXMeasurePreview m_aCtlPreview
Definition: measure.hxx:41
virtual ~SvxMeasurePage() override
Definition: measure.cxx:125
void SetState(CTL_STATE nState)
TRISTATE_INDET
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldHelplineOverhang
Definition: measure.hxx:43
constexpr TypedWhichId< SdrMeasureTextHPosItem > SDRATTR_MEASURETEXTHPOS(SDRATTR_MEASURE_FIRST+1)
constexpr TypedWhichId< SdrMeasureDecimalPlacesItem > SDRATTR_MEASUREDECIMALPLACES(SDRATTR_MEASURE_FIRST+20)
virtual tools::Long GetValue() const override
virtual void PointChanged(weld::DrawingArea *pWindow, RectPoint eRP) override
Definition: measure.cxx:524
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: measure.cxx:740
constexpr TypedWhichId< SdrMetricItem > SDRATTR_MEASUREHELPLINEDIST(SDRATTR_MEASURE_FIRST+5)
OUString CuiResId(TranslateId aKey)
Definition: cuiresmgr.cxx:23
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldHelpline2Len
Definition: measure.hxx:46
RectPoint
void FillUnitLB()
Definition: measure.cxx:724
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
int i
SvxMeasureDialog(weld::Window *pParent, const SfxItemSet &rAttr, const SdrView *pView)
Definition: measure.cxx:47
const SdrView * pView
Definition: measure.hxx:35
static OUString GetString(sal_uInt32 i)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_MEASUREHELPLINE2LEN(SDRATTR_MEASURE_FIRST+7)
TRISTATE_FALSE
int GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
virtual bool FillItemSet(SfxItemSet *) override
Definition: measure.cxx:345
std::unique_ptr< weld::CheckButton > m_xTsbBelowRefEdge
Definition: measure.hxx:47
std::unique_ptr< weld::MetricSpinButton > m_xMtrFldHelplineDist
Definition: measure.hxx:44
std::unique_ptr< weld::ComboBox > m_xLbUnit
Definition: measure.hxx:52
void SetTabPage(std::unique_ptr< SfxTabPage > xTabPage)
static sal_uInt32 Count()
virtual void Reset(const SfxItemSet *) override
Definition: measure.cxx:137
void SetMetricValue(weld::MetricSpinButton &rField, int nCoreValue, MapUnit eUnit)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
std::unique_ptr< weld::CheckButton > m_xTsbAutoPosV
Definition: measure.hxx:49
const SfxItemSet & rOutAttrs
Definition: measure.hxx:33
std::unique_ptr< weld::CustomWeld > m_xCtlPosition
Definition: measure.hxx:55
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
std::unique_ptr< weld::CheckButton > m_xTsbAutoPosH
Definition: measure.hxx:50
SvxRectCtl m_aCtlPosition
Definition: measure.hxx:40
constexpr TypedWhichId< SdrYesNoItem > SDRATTR_MEASURESHOWUNIT(SDRATTR_MEASURE_FIRST+14)
SfxItemSet aAttrSet
Definition: measure.hxx:34
MapUnit eUnit
Definition: measure.hxx:36
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
bool bPositionModified
Definition: measure.hxx:38
constexpr TypedWhichId< SdrMeasureTextVPosItem > SDRATTR_MEASURETEXTVPOS(SDRATTR_MEASURE_FIRST+2)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
Definition: measure.cxx:518
Dialog for changing TextAttributes.
Definition: measure.hxx:28
Reference< XExecutableDialog > m_xDialog
MapUnit
constexpr TypedWhichId< SdrMeasureBelowRefEdgeItem > SDRATTR_MEASUREBELOWREFEDGE(SDRATTR_MEASURE_FIRST+8)
SdrMetricItem makeSdrMeasureHelplineOverhangItem(tools::Long nVal)
constexpr TypedWhichId< SdrMeasureTextRota90Item > SDRATTR_MEASURETEXTROTA90(SDRATTR_MEASURE_FIRST+9)
void * GetValue() const
std::unique_ptr< weld::CheckButton > m_xTsbParallel
Definition: measure.hxx:53
void SetAttributes(const SfxItemSet &rInAttrs)
TriState
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
sal_Int32 nState
constexpr TypedWhichId< SdrMetricItem > SDRATTR_MEASUREHELPLINEOVERHANG(SDRATTR_MEASURE_FIRST+4)
IMPL_LINK(SvxMeasurePage, ClickAutoPosHdl_Impl, weld::Toggleable &, rBox, void)
Definition: measure.cxx:529
SdrMetricItem makeSdrMeasureLineDistItem(tools::Long nVal)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_MEASURELINEDIST(SDRATTR_MEASURE_FIRST+3)
sal_uInt16 nPos
std::unique_ptr< weld::Label > m_xFtAutomatic
Definition: measure.hxx:54
sal_Int16 nValue
CTL_STATE
SdrMetricItem makeSdrMeasureHelplineDistItem(tools::Long nVal)