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