Line data Source code
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 <cuires.hrc>
21 : #include <dialmgr.hxx>
22 : #include <sfx2/app.hxx>
23 : #include <sfx2/module.hxx>
24 : #include <sfx2/request.hxx>
25 : #include <vcl/settings.hxx>
26 :
27 : #include <svx/dialmgr.hxx>
28 : #include <svx/dialogs.hrc>
29 : #include <svx/dlgutil.hxx>
30 : #include <svx/measctrl.hxx>
31 : #include <svx/ofaitem.hxx>
32 : #include <svx/strarray.hxx>
33 : #include <svx/svdattr.hxx>
34 : #include <svx/svdomeas.hxx>
35 : #include <svx/svdview.hxx>
36 : #include <svx/sxekitm.hxx>
37 : #include <svx/sxelditm.hxx>
38 : #include <svx/sxenditm.hxx>
39 : #include <svx/sxmbritm.hxx>
40 : #include <svx/sxmfsitm.hxx>
41 : #include <svx/sxmlhitm.hxx>
42 : #include <svx/sxmsuitm.hxx>
43 : #include <svx/sxmtfitm.hxx>
44 : #include <svx/sxmtpitm.hxx>
45 : #include <svx/sxmtritm.hxx>
46 : #include <svx/sxmuitm.hxx>
47 :
48 : #include "measure.hxx"
49 :
50 : const sal_uInt16 SvxMeasurePage::pRanges[] =
51 : {
52 : SDRATTR_MEASURE_FIRST,
53 : SDRATTR_MEASURE_LAST,
54 : 0
55 : };
56 :
57 : /*************************************************************************
58 : |*
59 : |* Dialog to change measure-attributes
60 : |*
61 : \************************************************************************/
62 :
63 0 : SvxMeasureDialog::SvxMeasureDialog( vcl::Window* pParent, const SfxItemSet& rInAttrs,
64 : const SdrView* pSdrView )
65 0 : : SfxSingleTabDialog(pParent, rInAttrs)
66 : {
67 0 : VclPtrInstance<SvxMeasurePage> _pPage( get_content_area(), rInAttrs );
68 :
69 0 : _pPage->SetView( pSdrView );
70 0 : _pPage->Construct();
71 :
72 0 : SetTabPage(_pPage );
73 0 : SetText(CUI_RESSTR(RID_SVXSTR_DIMENSION_LINE));
74 0 : }
75 :
76 : /*************************************************************************
77 : |*
78 : |* Tabpage for changing measure-attributes
79 : |*
80 : \************************************************************************/
81 :
82 0 : SvxMeasurePage::SvxMeasurePage( vcl::Window* pWindow, const SfxItemSet& rInAttrs ) :
83 : SvxTabPage ( pWindow
84 : ,"DimensionLinesTabPage"
85 : ,"cui/ui/dimensionlinestabpage.ui"
86 : ,rInAttrs ),
87 : rOutAttrs ( rInAttrs ),
88 0 : aAttrSet ( *rInAttrs.GetPool() ),
89 : pView( 0 ),
90 : eUnit( SFX_MAPUNIT_100TH_MM ),
91 0 : bPositionModified ( false )
92 : {
93 0 : get(m_pMtrFldLineDist, "MTR_LINE_DIST");
94 0 : get(m_pMtrFldHelplineOverhang, "MTR_FLD_HELPLINE_OVERHANG");
95 0 : get(m_pMtrFldHelplineDist, "MTR_FLD_HELPLINE_DIST");
96 0 : get(m_pMtrFldHelpline1Len, "MTR_FLD_HELPLINE1_LEN");
97 0 : get(m_pMtrFldHelpline2Len, "MTR_FLD_HELPLINE2_LEN");
98 0 : get(m_pTsbBelowRefEdge, "TSB_BELOW_REF_EDGE");
99 0 : get(m_pMtrFldDecimalPlaces, "MTR_FLD_DECIMALPLACES");
100 :
101 0 : get(m_pCtlPosition, "CTL_POSITION");
102 0 : get(m_pTsbAutoPosV, "TSB_AUTOPOSV");
103 0 : get(m_pTsbAutoPosH, "TSB_AUTOPOSH");
104 0 : get(m_pTsbShowUnit, "TSB_SHOW_UNIT");
105 0 : get(m_pLbUnit, "LB_UNIT");
106 0 : get(m_pTsbParallel, "TSB_PARALLEL");
107 :
108 0 : get(m_pCtlPreview, "CTL_PREVIEW");
109 0 : m_pCtlPreview->SetAttributes(rInAttrs);
110 :
111 0 : get(m_pFtAutomatic,"STR_MEASURE_AUTOMATIC");
112 :
113 0 : FillUnitLB();
114 :
115 0 : const FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
116 0 : SetFieldUnit( *m_pMtrFldLineDist, eFUnit );
117 0 : SetFieldUnit( *m_pMtrFldHelplineOverhang, eFUnit );
118 0 : SetFieldUnit( *m_pMtrFldHelplineDist, eFUnit );
119 0 : SetFieldUnit( *m_pMtrFldHelpline1Len, eFUnit );
120 0 : SetFieldUnit( *m_pMtrFldHelpline2Len, eFUnit );
121 0 : if( eFUnit == FUNIT_MM )
122 : {
123 0 : m_pMtrFldLineDist->SetSpinSize( 50 );
124 0 : m_pMtrFldHelplineOverhang->SetSpinSize( 50 );
125 0 : m_pMtrFldHelplineDist->SetSpinSize( 50 );
126 0 : m_pMtrFldHelpline1Len->SetSpinSize( 50 );
127 0 : m_pMtrFldHelpline2Len->SetSpinSize( 50 );
128 : }
129 :
130 0 : m_pTsbAutoPosV->SetClickHdl( LINK( this, SvxMeasurePage, ClickAutoPosHdl_Impl ) );
131 0 : m_pTsbAutoPosH->SetClickHdl( LINK( this, SvxMeasurePage, ClickAutoPosHdl_Impl ) );
132 :
133 : // set background and border of iconchoicectrl
134 0 : const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
135 0 : m_pCtlPreview->SetBackground ( rStyles.GetWindowColor() );
136 0 : m_pCtlPreview->SetBorderStyle(WindowBorderStyle::MONO);
137 :
138 0 : Link<> aLink( LINK( this, SvxMeasurePage, ChangeAttrHdl_Impl ) );
139 0 : m_pMtrFldLineDist->SetModifyHdl( aLink );
140 0 : m_pMtrFldHelplineOverhang->SetModifyHdl( aLink );
141 0 : m_pMtrFldHelplineDist->SetModifyHdl( aLink );
142 0 : m_pMtrFldHelpline1Len->SetModifyHdl( aLink );
143 0 : m_pMtrFldHelpline2Len->SetModifyHdl( aLink );
144 0 : m_pMtrFldDecimalPlaces->SetModifyHdl( aLink );
145 0 : m_pTsbBelowRefEdge->SetClickHdl( aLink );
146 0 : m_pTsbParallel->SetClickHdl( aLink );
147 0 : m_pTsbShowUnit->SetClickHdl( aLink );
148 0 : m_pLbUnit->SetSelectHdl( aLink );
149 0 : }
150 :
151 0 : SvxMeasurePage::~SvxMeasurePage()
152 : {
153 0 : disposeOnce();
154 0 : }
155 :
156 0 : void SvxMeasurePage::dispose()
157 : {
158 0 : m_pMtrFldLineDist.clear();
159 0 : m_pMtrFldHelplineOverhang.clear();
160 0 : m_pMtrFldHelplineDist.clear();
161 0 : m_pMtrFldHelpline1Len.clear();
162 0 : m_pMtrFldHelpline2Len.clear();
163 0 : m_pTsbBelowRefEdge.clear();
164 0 : m_pMtrFldDecimalPlaces.clear();
165 0 : m_pCtlPosition.clear();
166 0 : m_pTsbAutoPosV.clear();
167 0 : m_pTsbAutoPosH.clear();
168 0 : m_pTsbShowUnit.clear();
169 0 : m_pLbUnit.clear();
170 0 : m_pTsbParallel.clear();
171 0 : m_pFtAutomatic.clear();
172 0 : m_pCtlPreview.clear();
173 0 : SvxTabPage::dispose();
174 0 : }
175 :
176 : /*************************************************************************
177 : |*
178 : |* read the delivered Item-Set
179 : |*
180 : \************************************************************************/
181 :
182 0 : void SvxMeasurePage::Reset( const SfxItemSet* rAttrs )
183 : {
184 0 : SfxItemPool* pPool = rAttrs->GetPool();
185 : DBG_ASSERT( pPool, "Wo ist der Pool" );
186 0 : eUnit = pPool->GetMetric( SDRATTR_MEASURELINEDIST );
187 :
188 0 : const SfxPoolItem* pItem = GetItem( *rAttrs, SDRATTR_MEASURELINEDIST );
189 :
190 : // SdrMeasureLineDistItem
191 0 : if( pItem == NULL )
192 0 : pItem = &pPool->GetDefaultItem( SDRATTR_MEASURELINEDIST );
193 0 : if( pItem )
194 : {
195 0 : long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
196 0 : SetMetricValue( *m_pMtrFldLineDist, nValue, eUnit );
197 : }
198 : else
199 : {
200 0 : m_pMtrFldLineDist->SetText( OUString() );
201 : }
202 0 : m_pMtrFldLineDist->SaveValue();
203 :
204 : // SdrMeasureHelplineOverhangItem
205 0 : pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEOVERHANG );
206 0 : if( pItem == NULL )
207 0 : pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG );
208 0 : if( pItem )
209 : {
210 0 : long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
211 0 : SetMetricValue( *m_pMtrFldHelplineOverhang, nValue, eUnit );
212 : }
213 : else
214 : {
215 0 : m_pMtrFldHelplineOverhang->SetText( OUString() );
216 : }
217 0 : m_pMtrFldHelplineOverhang->SaveValue();
218 :
219 : // SdrMeasureHelplineDistItem
220 0 : pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEDIST );
221 0 : if( pItem == NULL )
222 0 : pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST );
223 0 : if( pItem )
224 : {
225 0 : long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
226 0 : SetMetricValue( *m_pMtrFldHelplineDist, nValue, eUnit );
227 : }
228 : else
229 : {
230 0 : m_pMtrFldHelplineDist->SetText( OUString() );
231 : }
232 0 : m_pMtrFldHelplineDist->SaveValue();
233 :
234 : // SdrMeasureHelpline1LenItem
235 0 : pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE1LEN );
236 0 : if( pItem == NULL )
237 0 : pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN );
238 0 : if( pItem )
239 : {
240 0 : long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
241 0 : SetMetricValue( *m_pMtrFldHelpline1Len, nValue, eUnit );
242 : }
243 : else
244 : {
245 0 : m_pMtrFldHelpline1Len->SetText( OUString() );
246 : }
247 0 : m_pMtrFldHelpline1Len->SaveValue();
248 :
249 : // SdrMeasureHelpline2LenItem
250 0 : pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE2LEN );
251 0 : if( pItem == NULL )
252 0 : pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN );
253 0 : if( pItem )
254 : {
255 0 : long nValue = static_cast<const SdrMetricItem*>( pItem )->GetValue();
256 0 : SetMetricValue( *m_pMtrFldHelpline2Len, nValue, eUnit );
257 : }
258 : else
259 : {
260 0 : m_pMtrFldHelpline2Len->SetText( OUString() );
261 : }
262 0 : m_pMtrFldHelpline2Len->SaveValue();
263 :
264 : // SdrMeasureBelowRefEdgeItem
265 0 : if( rAttrs->GetItemState( SDRATTR_MEASUREBELOWREFEDGE ) != SfxItemState::DONTCARE )
266 : {
267 0 : m_pTsbBelowRefEdge->SetState( static_cast<const SdrMeasureBelowRefEdgeItem&>( rAttrs->Get( SDRATTR_MEASUREBELOWREFEDGE ) ).
268 0 : GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
269 0 : m_pTsbBelowRefEdge->EnableTriState( false );
270 : }
271 : else
272 : {
273 0 : m_pTsbBelowRefEdge->SetState( TRISTATE_INDET );
274 : }
275 0 : m_pTsbBelowRefEdge->SaveValue();
276 :
277 : // SdrMeasureDecimalPlacesItem
278 0 : pItem = GetItem( *rAttrs, SDRATTR_MEASUREDECIMALPLACES );
279 0 : if( pItem == NULL )
280 0 : pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES );
281 0 : if( pItem )
282 : {
283 0 : sal_Int16 nValue = static_cast<const SdrMeasureDecimalPlacesItem*>( pItem )->GetValue();
284 0 : m_pMtrFldDecimalPlaces->SetValue( nValue );
285 : }
286 : else
287 : {
288 0 : m_pMtrFldDecimalPlaces->SetText( OUString() );
289 : }
290 0 : m_pMtrFldDecimalPlaces->SaveValue();
291 :
292 : // SdrMeasureTextRota90Item
293 : // Attention: negate !
294 0 : if( rAttrs->GetItemState( SDRATTR_MEASURETEXTROTA90 ) != SfxItemState::DONTCARE )
295 : {
296 0 : m_pTsbParallel->SetState( static_cast<const SdrMeasureTextRota90Item&>( rAttrs->Get( SDRATTR_MEASURETEXTROTA90 ) ).
297 0 : GetValue() ? TRISTATE_FALSE : TRISTATE_TRUE );
298 0 : m_pTsbParallel->EnableTriState( false );
299 : }
300 : else
301 : {
302 0 : m_pTsbParallel->SetState( TRISTATE_INDET );
303 : }
304 0 : m_pTsbParallel->SaveValue();
305 :
306 : // SdrMeasureShowUnitItem
307 0 : if( rAttrs->GetItemState( SDRATTR_MEASURESHOWUNIT ) != SfxItemState::DONTCARE )
308 : {
309 0 : m_pTsbShowUnit->SetState( static_cast<const SdrYesNoItem&>( rAttrs->Get( SDRATTR_MEASURESHOWUNIT ) ).
310 0 : GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE );
311 0 : m_pTsbShowUnit->EnableTriState( false );
312 : }
313 : else
314 : {
315 0 : m_pTsbShowUnit->SetState( TRISTATE_INDET );
316 : }
317 0 : m_pTsbShowUnit->SaveValue();
318 :
319 : // SdrMeasureUnitItem
320 0 : if( rAttrs->GetItemState( SDRATTR_MEASUREUNIT ) != SfxItemState::DONTCARE )
321 : {
322 : long nFieldUnit = (long) static_cast<const SdrMeasureUnitItem&>( rAttrs->
323 0 : Get( SDRATTR_MEASUREUNIT ) ).GetValue();
324 :
325 0 : for( sal_Int32 i = 0; i < m_pLbUnit->GetEntryCount(); ++i )
326 : {
327 0 : if ( reinterpret_cast<sal_IntPtr>(m_pLbUnit->GetEntryData( i )) == nFieldUnit )
328 : {
329 0 : m_pLbUnit->SelectEntryPos( i );
330 0 : break;
331 : }
332 : }
333 : }
334 : else
335 : {
336 0 : m_pLbUnit->SetNoSelection();
337 : }
338 0 : m_pLbUnit->SaveValue();
339 :
340 : // Position
341 0 : if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::DONTCARE )
342 : {
343 : SdrMeasureTextVPos eVPos = (SdrMeasureTextVPos)
344 0 : static_cast<const SdrMeasureTextVPosItem&>( rAttrs->Get( SDRATTR_MEASURETEXTVPOS ) ).GetValue();
345 : {
346 0 : if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE )
347 : {
348 0 : m_pTsbAutoPosV->EnableTriState( false );
349 0 : m_pTsbAutoPosH->EnableTriState( false );
350 :
351 : SdrMeasureTextHPos eHPos = (SdrMeasureTextHPos)
352 0 : static_cast<const SdrMeasureTextHPosItem&>( rAttrs->Get( SDRATTR_MEASURETEXTHPOS ) ).GetValue();
353 0 : RECT_POINT eRP = RP_MM;
354 0 : switch( eVPos )
355 : {
356 : case SDRMEASURE_ABOVE:
357 0 : switch( eHPos )
358 : {
359 0 : case SDRMEASURE_TEXTLEFTOUTSIDE: eRP = RP_LT; break;
360 0 : case SDRMEASURE_TEXTINSIDE: eRP = RP_MT; break;
361 0 : case SDRMEASURE_TEXTRIGHTOUTSIDE: eRP = RP_RT; break;
362 0 : case SDRMEASURE_TEXTHAUTO: eRP = RP_MT; break;
363 : }
364 0 : break;
365 : case SDRMEASURETEXT_VERTICALCENTERED:
366 0 : switch( eHPos )
367 : {
368 0 : case SDRMEASURE_TEXTLEFTOUTSIDE: eRP = RP_LM; break;
369 0 : case SDRMEASURE_TEXTINSIDE: eRP = RP_MM; break;
370 0 : case SDRMEASURE_TEXTRIGHTOUTSIDE: eRP = RP_RM; break;
371 0 : case SDRMEASURE_TEXTHAUTO: eRP = RP_MM; break;
372 : }
373 0 : break;
374 : case SDRMEASURE_BELOW:
375 0 : switch( eHPos )
376 : {
377 0 : case SDRMEASURE_TEXTLEFTOUTSIDE: eRP = RP_LB; break;
378 0 : case SDRMEASURE_TEXTINSIDE: eRP = RP_MB; break;
379 0 : case SDRMEASURE_TEXTRIGHTOUTSIDE: eRP = RP_RB; break;
380 0 : case SDRMEASURE_TEXTHAUTO: eRP = RP_MB; break;
381 : }
382 0 : break;
383 : case SDRMEASURE_TEXTVAUTO:
384 0 : switch( eHPos )
385 : {
386 0 : case SDRMEASURE_TEXTLEFTOUTSIDE: eRP = RP_LM; break;
387 0 : case SDRMEASURE_TEXTINSIDE: eRP = RP_MM; break;
388 0 : case SDRMEASURE_TEXTRIGHTOUTSIDE: eRP = RP_RM; break;
389 0 : case SDRMEASURE_TEXTHAUTO: eRP = RP_MM; break;
390 : }
391 0 : break;
392 : default: ;//prevent warning
393 : }
394 :
395 0 : CTL_STATE nState = CTL_STATE::NONE;
396 :
397 0 : if( eHPos == SDRMEASURE_TEXTHAUTO )
398 : {
399 0 : m_pTsbAutoPosH->SetState( TRISTATE_TRUE );
400 0 : nState = CTL_STATE::NOHORZ;
401 : }
402 :
403 0 : if( eVPos == SDRMEASURE_TEXTVAUTO )
404 : {
405 0 : m_pTsbAutoPosV->SetState( TRISTATE_TRUE );
406 0 : nState |= CTL_STATE::NOVERT;
407 : }
408 :
409 0 : m_pCtlPosition->SetState( nState );
410 0 : m_pCtlPosition->SetActualRP( eRP );
411 : }
412 : }
413 : }
414 : else
415 : {
416 0 : m_pCtlPosition->Reset();
417 0 : m_pTsbAutoPosV->SetState( TRISTATE_INDET );
418 0 : m_pTsbAutoPosH->SetState( TRISTATE_INDET );
419 : }
420 :
421 : // put the attributes to the preview-control,
422 : // otherwise the control don't know about
423 : // the settings of the dialog (#67930)
424 0 : ChangeAttrHdl_Impl( m_pTsbShowUnit );
425 0 : m_pCtlPreview->SetAttributes( *rAttrs );
426 :
427 0 : bPositionModified = false;
428 0 : }
429 :
430 : /*************************************************************************
431 : |*
432 : |* Fill the delivered Item-Set with dialogbox-attributes
433 : |*
434 : \************************************************************************/
435 :
436 0 : bool SvxMeasurePage::FillItemSet( SfxItemSet* rAttrs)
437 : {
438 0 : bool bModified = false;
439 : sal_Int32 nValue;
440 : TriState eState;
441 :
442 0 : if( m_pMtrFldLineDist->IsValueChangedFromSaved() )
443 : {
444 0 : nValue = GetCoreValue( *m_pMtrFldLineDist, eUnit );
445 0 : rAttrs->Put( makeSdrMeasureLineDistItem( nValue ) );
446 0 : bModified = true;
447 : }
448 :
449 0 : if( m_pMtrFldHelplineOverhang->IsValueChangedFromSaved() )
450 : {
451 0 : nValue = GetCoreValue( *m_pMtrFldHelplineOverhang, eUnit );
452 0 : rAttrs->Put( makeSdrMeasureHelplineOverhangItem( nValue ) );
453 0 : bModified = true;
454 : }
455 :
456 0 : if( m_pMtrFldHelplineDist->IsValueChangedFromSaved() )
457 : {
458 0 : nValue = GetCoreValue( *m_pMtrFldHelplineDist, eUnit );
459 0 : rAttrs->Put( makeSdrMeasureHelplineDistItem( nValue ) );
460 0 : bModified = true;
461 : }
462 :
463 0 : if( m_pMtrFldHelpline1Len->IsValueChangedFromSaved() )
464 : {
465 0 : nValue = GetCoreValue( *m_pMtrFldHelpline1Len, eUnit );
466 0 : rAttrs->Put( makeSdrMeasureHelpline1LenItem( nValue ) );
467 0 : bModified = true;
468 : }
469 :
470 0 : if( m_pMtrFldHelpline2Len->IsValueChangedFromSaved() )
471 : {
472 0 : nValue = GetCoreValue( *m_pMtrFldHelpline2Len, eUnit );
473 0 : rAttrs->Put( makeSdrMeasureHelpline2LenItem( nValue ) );
474 0 : bModified = true;
475 : }
476 :
477 0 : eState = m_pTsbBelowRefEdge->GetState();
478 0 : if( m_pTsbBelowRefEdge->IsValueChangedFromSaved() )
479 : {
480 0 : rAttrs->Put( SdrMeasureBelowRefEdgeItem( TRISTATE_TRUE == eState ) );
481 0 : bModified = true;
482 : }
483 :
484 0 : if( m_pMtrFldDecimalPlaces->IsValueChangedFromSaved() )
485 : {
486 0 : nValue = static_cast<sal_Int32>(m_pMtrFldDecimalPlaces->GetValue());
487 : rAttrs->Put(
488 : SdrMeasureDecimalPlacesItem(
489 0 : sal::static_int_cast< sal_Int16 >( nValue ) ) );
490 0 : bModified = true;
491 : }
492 :
493 0 : eState = m_pTsbParallel->GetState();
494 0 : if( m_pTsbParallel->IsValueChangedFromSaved() )
495 : {
496 0 : rAttrs->Put( SdrMeasureTextRota90Item( TRISTATE_FALSE == eState ) );
497 0 : bModified = true;
498 : }
499 :
500 0 : eState = m_pTsbShowUnit->GetState();
501 0 : if( m_pTsbShowUnit->IsValueChangedFromSaved() )
502 : {
503 0 : rAttrs->Put( makeSdrMeasureShowUnitItem( TRISTATE_TRUE == eState ) );
504 0 : bModified = true;
505 : }
506 :
507 0 : sal_Int32 nPos = m_pLbUnit->GetSelectEntryPos();
508 0 : if( m_pLbUnit->IsValueChangedFromSaved() )
509 : {
510 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
511 : {
512 0 : sal_uInt16 nFieldUnit = (sal_uInt16)reinterpret_cast<sal_IntPtr>(m_pLbUnit->GetEntryData( nPos ));
513 0 : FieldUnit _eUnit = (FieldUnit) nFieldUnit;
514 0 : rAttrs->Put( SdrMeasureUnitItem( _eUnit ) );
515 0 : bModified = true;
516 : }
517 : }
518 :
519 0 : if( bPositionModified )
520 : {
521 : // Position
522 : SdrMeasureTextVPos eVPos, eOldVPos;
523 : SdrMeasureTextHPos eHPos, eOldHPos;
524 :
525 0 : RECT_POINT eRP = m_pCtlPosition->GetActualRP();
526 0 : switch( eRP )
527 : {
528 : default:
529 0 : case RP_LT: eVPos = SDRMEASURE_ABOVE;
530 0 : eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
531 0 : case RP_LM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
532 0 : eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
533 0 : case RP_LB: eVPos = SDRMEASURE_BELOW;
534 0 : eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
535 0 : case RP_MT: eVPos = SDRMEASURE_ABOVE;
536 0 : eHPos = SDRMEASURE_TEXTINSIDE; break;
537 0 : case RP_MM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
538 0 : eHPos = SDRMEASURE_TEXTINSIDE; break;
539 0 : case RP_MB: eVPos = SDRMEASURE_BELOW;
540 0 : eHPos = SDRMEASURE_TEXTINSIDE; break;
541 0 : case RP_RT: eVPos = SDRMEASURE_ABOVE;
542 0 : eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
543 0 : case RP_RM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
544 0 : eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
545 0 : case RP_RB: eVPos = SDRMEASURE_BELOW;
546 0 : eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
547 : }
548 0 : if( m_pTsbAutoPosH->GetState() == TRISTATE_TRUE )
549 0 : eHPos = SDRMEASURE_TEXTHAUTO;
550 :
551 0 : if( m_pTsbAutoPosV->GetState() == TRISTATE_TRUE )
552 0 : eVPos = SDRMEASURE_TEXTVAUTO;
553 :
554 0 : if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::DONTCARE )
555 : {
556 : eOldVPos = (SdrMeasureTextVPos)
557 0 : static_cast<const SdrMeasureTextVPosItem&>( rOutAttrs.Get( SDRATTR_MEASURETEXTVPOS ) ).GetValue();
558 0 : if( eOldVPos != eVPos )
559 : {
560 0 : rAttrs->Put( SdrMeasureTextVPosItem( eVPos ) );
561 0 : bModified = true;
562 : }
563 : }
564 : else
565 : {
566 0 : rAttrs->Put( SdrMeasureTextVPosItem( eVPos ) );
567 0 : bModified = true;
568 : }
569 :
570 0 : if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE )
571 : {
572 : eOldHPos = (SdrMeasureTextHPos)
573 0 : static_cast<const SdrMeasureTextHPosItem&>( rOutAttrs.Get( SDRATTR_MEASURETEXTHPOS ) ).GetValue();
574 0 : if( eOldHPos != eHPos )
575 : {
576 0 : rAttrs->Put( SdrMeasureTextHPosItem( eHPos ) );
577 0 : bModified = true;
578 : }
579 : }
580 : else
581 : {
582 0 : rAttrs->Put( SdrMeasureTextHPosItem( eHPos ) );
583 0 : bModified = true;
584 : }
585 : }
586 :
587 0 : return bModified;
588 : }
589 :
590 : /*************************************************************************
591 : |*
592 : |* The View have to set at the measure-object to be able to notify
593 : |* unit and floatingpoint-values
594 : |*
595 : \************************************************************************/
596 :
597 0 : void SvxMeasurePage::Construct()
598 : {
599 : DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
600 :
601 0 : m_pCtlPreview->pMeasureObj->SetModel( pView->GetModel() );
602 0 : m_pCtlPreview->Invalidate();
603 0 : }
604 :
605 0 : VclPtr<SfxTabPage> SvxMeasurePage::Create( vcl::Window* pWindow,
606 : const SfxItemSet* rAttrs )
607 : {
608 0 : return VclPtr<SvxMeasurePage>::Create( pWindow, *rAttrs );
609 : }
610 :
611 0 : void SvxMeasurePage::PointChanged( vcl::Window* pWindow, RECT_POINT /*eRP*/ )
612 : {
613 0 : ChangeAttrHdl_Impl( pWindow );
614 0 : }
615 :
616 0 : IMPL_LINK( SvxMeasurePage, ClickAutoPosHdl_Impl, void *, p )
617 : {
618 0 : if( m_pTsbAutoPosH->GetState() == TRISTATE_TRUE )
619 : {
620 0 : switch( m_pCtlPosition->GetActualRP() )
621 : {
622 : case RP_LT:
623 : case RP_RT:
624 0 : m_pCtlPosition->SetActualRP( RP_MT );
625 0 : break;
626 :
627 : case RP_LM:
628 : case RP_RM:
629 0 : m_pCtlPosition->SetActualRP( RP_MM );
630 0 : break;
631 :
632 : case RP_LB:
633 : case RP_RB:
634 0 : m_pCtlPosition->SetActualRP( RP_MB );
635 0 : break;
636 : default: ;//prevent warning
637 : }
638 : }
639 0 : if( m_pTsbAutoPosV->GetState() == TRISTATE_TRUE )
640 : {
641 0 : switch( m_pCtlPosition->GetActualRP() )
642 : {
643 : case RP_LT:
644 : case RP_LB:
645 0 : m_pCtlPosition->SetActualRP( RP_LM );
646 0 : break;
647 :
648 : case RP_MT:
649 : case RP_MB:
650 0 : m_pCtlPosition->SetActualRP( RP_MM );
651 0 : break;
652 :
653 : case RP_RT:
654 : case RP_RB:
655 0 : m_pCtlPosition->SetActualRP( RP_RM );
656 0 : break;
657 : default: ;//prevent warning
658 : }
659 : }
660 0 : ChangeAttrHdl_Impl( p );
661 :
662 0 : return 0L;
663 : }
664 :
665 0 : IMPL_LINK( SvxMeasurePage, ChangeAttrHdl_Impl, void *, p )
666 : {
667 :
668 0 : if( p == m_pMtrFldLineDist )
669 : {
670 0 : sal_Int32 nValue = GetCoreValue( *m_pMtrFldLineDist, eUnit );
671 0 : aAttrSet.Put( makeSdrMeasureLineDistItem( nValue ) );
672 : }
673 :
674 0 : if( p == m_pMtrFldHelplineOverhang )
675 : {
676 0 : sal_Int32 nValue = GetCoreValue( *m_pMtrFldHelplineOverhang, eUnit );
677 0 : aAttrSet.Put( makeSdrMeasureHelplineOverhangItem( nValue) );
678 : }
679 :
680 0 : if( p == m_pMtrFldHelplineDist )
681 : {
682 0 : sal_Int32 nValue = GetCoreValue( *m_pMtrFldHelplineDist, eUnit );
683 0 : aAttrSet.Put( makeSdrMeasureHelplineDistItem( nValue) );
684 : }
685 :
686 0 : if( p == m_pMtrFldHelpline1Len )
687 : {
688 0 : sal_Int32 nValue = GetCoreValue( *m_pMtrFldHelpline1Len, eUnit );
689 0 : aAttrSet.Put( makeSdrMeasureHelpline1LenItem( nValue ) );
690 : }
691 :
692 0 : if( p == m_pMtrFldHelpline2Len )
693 : {
694 0 : sal_Int32 nValue = GetCoreValue( *m_pMtrFldHelpline2Len, eUnit );
695 0 : aAttrSet.Put( makeSdrMeasureHelpline2LenItem( nValue ) );
696 : }
697 :
698 0 : if( p == m_pTsbBelowRefEdge )
699 : {
700 0 : TriState eState = m_pTsbBelowRefEdge->GetState();
701 0 : if( eState != TRISTATE_INDET )
702 0 : aAttrSet.Put( SdrMeasureBelowRefEdgeItem( TRISTATE_TRUE == eState ) );
703 : }
704 :
705 0 : if( p == m_pMtrFldDecimalPlaces )
706 : {
707 : sal_Int16 nValue = sal::static_int_cast< sal_Int16 >(
708 0 : m_pMtrFldDecimalPlaces->GetValue() );
709 0 : aAttrSet.Put( SdrMeasureDecimalPlacesItem( nValue ) );
710 : }
711 :
712 0 : if( p == m_pTsbParallel )
713 : {
714 0 : TriState eState = m_pTsbParallel->GetState();
715 0 : if( eState != TRISTATE_INDET )
716 0 : aAttrSet.Put( SdrMeasureTextRota90Item( TRISTATE_FALSE == eState ) );
717 : }
718 :
719 0 : if( p == m_pTsbShowUnit )
720 : {
721 0 : TriState eState = m_pTsbShowUnit->GetState();
722 0 : if( eState != TRISTATE_INDET )
723 0 : aAttrSet.Put( makeSdrMeasureShowUnitItem( TRISTATE_TRUE == eState ) );
724 : }
725 :
726 0 : if( p == m_pLbUnit )
727 : {
728 0 : sal_Int32 nPos = m_pLbUnit->GetSelectEntryPos();
729 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
730 : {
731 0 : sal_uInt16 nFieldUnit = (sal_uInt16)reinterpret_cast<sal_IntPtr>(m_pLbUnit->GetEntryData( nPos ));
732 0 : FieldUnit _eUnit = (FieldUnit) nFieldUnit;
733 0 : aAttrSet.Put( SdrMeasureUnitItem( _eUnit ) );
734 : }
735 : }
736 :
737 0 : if( p == m_pTsbAutoPosV || p == m_pTsbAutoPosH || p == m_pCtlPosition )
738 : {
739 0 : bPositionModified = true;
740 :
741 : // Position
742 0 : RECT_POINT eRP = m_pCtlPosition->GetActualRP();
743 : SdrMeasureTextVPos eVPos;
744 : SdrMeasureTextHPos eHPos;
745 :
746 0 : switch( eRP )
747 : {
748 : default:
749 0 : case RP_LT: eVPos = SDRMEASURE_ABOVE;
750 0 : eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
751 0 : case RP_LM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
752 0 : eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
753 0 : case RP_LB: eVPos = SDRMEASURE_BELOW;
754 0 : eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
755 0 : case RP_MT: eVPos = SDRMEASURE_ABOVE;
756 0 : eHPos = SDRMEASURE_TEXTINSIDE; break;
757 0 : case RP_MM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
758 0 : eHPos = SDRMEASURE_TEXTINSIDE; break;
759 0 : case RP_MB: eVPos = SDRMEASURE_BELOW;
760 0 : eHPos = SDRMEASURE_TEXTINSIDE; break;
761 0 : case RP_RT: eVPos = SDRMEASURE_ABOVE;
762 0 : eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
763 0 : case RP_RM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
764 0 : eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
765 0 : case RP_RB: eVPos = SDRMEASURE_BELOW;
766 0 : eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
767 : }
768 :
769 0 : CTL_STATE nState = CTL_STATE::NONE;
770 :
771 0 : if( m_pTsbAutoPosH->GetState() == TRISTATE_TRUE )
772 : {
773 0 : eHPos = SDRMEASURE_TEXTHAUTO;
774 0 : nState = CTL_STATE::NOHORZ;
775 : }
776 :
777 0 : if( m_pTsbAutoPosV->GetState() == TRISTATE_TRUE )
778 : {
779 0 : eVPos = SDRMEASURE_TEXTVAUTO;
780 0 : nState |= CTL_STATE::NOVERT;
781 : }
782 :
783 0 : if( p == m_pTsbAutoPosV || p == m_pTsbAutoPosH )
784 0 : m_pCtlPosition->SetState( nState );
785 :
786 0 : aAttrSet.Put( SdrMeasureTextVPosItem( eVPos ) );
787 0 : aAttrSet.Put( SdrMeasureTextHPosItem( eHPos ) );
788 : }
789 :
790 0 : m_pCtlPreview->SetAttributes( aAttrSet );
791 0 : m_pCtlPreview->Invalidate();
792 :
793 0 : return 0L;
794 : }
795 :
796 0 : void SvxMeasurePage::FillUnitLB()
797 : {
798 : // fill ListBox with metrics
799 0 : SvxStringArray aMetricArr( SVX_RES( RID_SVXSTR_FIELDUNIT_TABLE ) );
800 :
801 0 : sal_IntPtr nUnit = FUNIT_NONE;
802 0 : OUString aStrMetric( m_pFtAutomatic->GetText());
803 0 : sal_Int32 nPos = m_pLbUnit->InsertEntry( aStrMetric );
804 0 : m_pLbUnit->SetEntryData( nPos, reinterpret_cast<void*>(nUnit) );
805 :
806 0 : for( sal_uInt32 i = 0; i < aMetricArr.Count(); ++i )
807 : {
808 0 : aStrMetric = aMetricArr.GetStringByPos( i );
809 0 : nUnit = aMetricArr.GetValue( i );
810 0 : nPos = m_pLbUnit->InsertEntry( aStrMetric );
811 0 : m_pLbUnit->SetEntryData( nPos, reinterpret_cast<void*>(nUnit) );
812 0 : }
813 0 : }
814 0 : void SvxMeasurePage::PageCreated(const SfxAllItemSet& aSet)
815 : {
816 0 : SFX_ITEMSET_ARG (&aSet,pOfaPtrItem,OfaPtrItem,SID_OBJECT_LIST,false);
817 :
818 0 : if (pOfaPtrItem)
819 0 : SetView( static_cast<SdrView *>(pOfaPtrItem->GetValue()));
820 :
821 0 : Construct();
822 0 : }
823 :
824 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|