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