1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cui.hxx"
26
27 // include ---------------------------------------------------------------
28 #include <sfx2/app.hxx>
29 #include <sfx2/module.hxx>
30 #include <tools/shl.hxx>
31
32 #include <cuires.hrc>
33
34 #define _SVX_MEASURE_CXX
35
36 #include <svx/svdomeas.hxx>
37 #include <svx/svdattr.hxx>
38 #include <svx/svdattrx.hxx>
39 #include <svx/svdview.hxx>
40 #include <svx/dialogs.hrc>
41 #include <svx/dialmgr.hxx>
42 #include "svx/measctrl.hxx"
43 #include "measure.hxx"
44 #include "measure.hrc"
45 #include <dialmgr.hxx>
46 #include "svx/dlgutil.hxx"
47 #include <svx/strarray.hxx>
48 #include <sfx2/request.hxx> //add CHINA001
49 #include "svx/ofaitem.hxx" //add CHINA001
50
51 static sal_uInt16 pRanges[] =
52 {
53 SDRATTR_MEASURE_FIRST,
54 SDRATTR_MEASURE_LAST,
55 0
56 };
57
58 /*************************************************************************
59 |*
60 |* Dialog to change measure-attributes
61 |*
62 \************************************************************************/
63
SvxMeasureDialog(Window * pParent,const SfxItemSet & rInAttrs,const SdrView * pSdrView)64 SvxMeasureDialog::SvxMeasureDialog( Window* pParent, const SfxItemSet& rInAttrs,
65 const SdrView* pSdrView ) :
66 SfxSingleTabDialog( pParent, rInAttrs, RID_SVXPAGE_MEASURE )
67 {
68 SvxMeasurePage* _pPage = new SvxMeasurePage( this, rInAttrs );
69
70 _pPage->SetView( pSdrView );
71 _pPage->Construct();
72
73 SetTabPage( _pPage );
74 SetText( _pPage->GetText() );
75 }
76
77 /*************************************************************************
78 |*
79 |* Dtor
80 |*
81 \************************************************************************/
82
~SvxMeasureDialog()83 SvxMeasureDialog::~SvxMeasureDialog()
84 {
85 }
86
87 /*************************************************************************
88 |*
89 |* Tabpage for changing measure-attributes
90 |*
91 \************************************************************************/
92
SvxMeasurePage(Window * pWindow,const SfxItemSet & rInAttrs)93 SvxMeasurePage::SvxMeasurePage( Window* pWindow, const SfxItemSet& rInAttrs ) :
94 SvxTabPage ( pWindow, CUI_RES( RID_SVXPAGE_MEASURE ),
95 rInAttrs ),
96
97 aFlLine ( this, CUI_RES( FL_LINE ) ),
98 aFtLineDist ( this, CUI_RES( FT_LINE_DIST ) ),
99 aMtrFldLineDist ( this, CUI_RES( MTR_LINE_DIST ) ),
100 aFtHelplineOverhang ( this, CUI_RES( FT_HELPLINE_OVERHANG ) ),
101 aMtrFldHelplineOverhang ( this, CUI_RES( MTR_FLD_HELPLINE_OVERHANG ) ),
102 aFtHelplineDist ( this, CUI_RES( FT_HELPLINE_DIST ) ),
103 aMtrFldHelplineDist ( this, CUI_RES( MTR_FLD_HELPLINE_DIST ) ),
104 aFtHelpline1Len ( this, CUI_RES( FT_HELPLINE1_LEN ) ),
105 aMtrFldHelpline1Len ( this, CUI_RES( MTR_FLD_HELPLINE1_LEN ) ),
106 aFtHelpline2Len ( this, CUI_RES( FT_HELPLINE2_LEN ) ),
107 aMtrFldHelpline2Len ( this, CUI_RES( MTR_FLD_HELPLINE2_LEN ) ),
108 aTsbBelowRefEdge ( this, CUI_RES( TSB_BELOW_REF_EDGE ) ),
109 aFtDecimalPlaces ( this, CUI_RES( FT_DECIMALPLACES ) ),
110 aMtrFldDecimalPlaces ( this, CUI_RES( MTR_FLD_DECIMALPLACES ) ),
111
112 aFlLabel ( this, CUI_RES( FL_LABEL ) ),
113 aFtPosition ( this, CUI_RES( FT_POSITION ) ),
114 aCtlPosition ( this, CUI_RES( CTL_POSITION ) ),
115 aTsbAutoPosV ( this, CUI_RES( TSB_AUTOPOSV ) ),
116 aTsbAutoPosH ( this, CUI_RES( TSB_AUTOPOSH ) ),
117 aTsbShowUnit ( this, CUI_RES( TSB_SHOW_UNIT ) ),
118 aLbUnit ( this, CUI_RES( LB_UNIT ) ),
119 aTsbParallel ( this, CUI_RES( TSB_PARALLEL ) ),
120 aCtlPreview ( this, CUI_RES( CTL_PREVIEW ), rInAttrs ),
121
122 aFlVert ( this, CUI_RES( FL_VERT ) ),
123 rOutAttrs ( rInAttrs ),
124 aAttrSet ( *rInAttrs.GetPool() ),
125 pView( 0 ),
126
127 bPositionModified ( sal_False )
128 {
129 aCtlPreview.SetAccessibleName(aCtlPreview.GetHelpText());
130 FillUnitLB();
131
132 FreeResource();
133
134 const FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
135 SetFieldUnit( aMtrFldLineDist, eFUnit );
136 SetFieldUnit( aMtrFldHelplineOverhang, eFUnit );
137 SetFieldUnit( aMtrFldHelplineDist, eFUnit );
138 SetFieldUnit( aMtrFldHelpline1Len, eFUnit );
139 SetFieldUnit( aMtrFldHelpline2Len, eFUnit );
140 if( eFUnit == FUNIT_MM )
141 {
142 aMtrFldLineDist.SetSpinSize( 50 );
143 aMtrFldHelplineOverhang.SetSpinSize( 50 );
144 aMtrFldHelplineDist.SetSpinSize( 50 );
145 aMtrFldHelpline1Len.SetSpinSize( 50 );
146 aMtrFldHelpline2Len.SetSpinSize( 50 );
147 }
148
149 aTsbAutoPosV.SetClickHdl( LINK( this, SvxMeasurePage, ClickAutoPosHdl_Impl ) );
150 aTsbAutoPosH.SetClickHdl( LINK( this, SvxMeasurePage, ClickAutoPosHdl_Impl ) );
151
152 // set background and border of iconchoicectrl
153 const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
154 aCtlPreview.SetBackground ( rStyles.GetWindowColor() );
155 aCtlPreview.SetBorderStyle(WINDOW_BORDER_MONO);
156
157 Link aLink( LINK( this, SvxMeasurePage, ChangeAttrHdl_Impl ) );
158 aMtrFldLineDist.SetModifyHdl( aLink );
159 aMtrFldHelplineOverhang.SetModifyHdl( aLink );
160 aMtrFldHelplineDist.SetModifyHdl( aLink );
161 aMtrFldHelpline1Len.SetModifyHdl( aLink );
162 aMtrFldHelpline2Len.SetModifyHdl( aLink );
163 aMtrFldDecimalPlaces.SetModifyHdl( aLink );
164 aTsbBelowRefEdge.SetClickHdl( aLink );
165 aTsbParallel.SetClickHdl( aLink );
166 aTsbShowUnit.SetClickHdl( aLink );
167 aLbUnit.SetSelectHdl( aLink );
168 aLbUnit.SetAccessibleName(GetNonMnemonicString(aTsbShowUnit.GetText()));
169 aCtlPosition.SetAccessibleRelationMemberOf( &aFlLabel );
170 aLbUnit.SetAccessibleRelationLabeledBy( &aTsbShowUnit );
171 }
172
173 /*************************************************************************
174 |*
175 |* Dtor
176 |*
177 \************************************************************************/
178
~SvxMeasurePage()179 SvxMeasurePage::~SvxMeasurePage()
180 {
181 }
182
183 /*************************************************************************
184 |*
185 |* read the delivered Item-Set
186 |*
187 \************************************************************************/
188
Reset(const SfxItemSet & rAttrs)189 void __EXPORT SvxMeasurePage::Reset( const SfxItemSet& rAttrs )
190 {
191 SfxItemPool* pPool = rAttrs.GetPool();
192 DBG_ASSERT( pPool, "Wo ist der Pool" );
193 eUnit = pPool->GetMetric( SDRATTR_MEASURELINEDIST );
194
195 const SfxPoolItem* pItem = GetItem( rAttrs, SDRATTR_MEASURELINEDIST );
196
197 // SdrMeasureLineDistItem
198 if( pItem == NULL )
199 pItem = &pPool->GetDefaultItem( SDRATTR_MEASURELINEDIST );
200 if( pItem )
201 {
202 long nValue = ( ( const SdrMeasureLineDistItem* )pItem )->GetValue();
203 SetMetricValue( aMtrFldLineDist, nValue, eUnit );
204 }
205 else
206 {
207 aMtrFldLineDist.SetText( String() );
208 }
209 aMtrFldLineDist.SaveValue();
210
211 // SdrMeasureHelplineOverhangItem
212 pItem = GetItem( rAttrs, SDRATTR_MEASUREHELPLINEOVERHANG );
213 if( pItem == NULL )
214 pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG );
215 if( pItem )
216 {
217 long nValue = ( ( const SdrMeasureHelplineOverhangItem* )pItem )->GetValue();
218 SetMetricValue( aMtrFldHelplineOverhang, nValue, eUnit );
219 }
220 else
221 {
222 aMtrFldHelplineOverhang.SetText( String() );
223 }
224 aMtrFldHelplineOverhang.SaveValue();
225
226 // SdrMeasureHelplineDistItem
227 pItem = GetItem( rAttrs, SDRATTR_MEASUREHELPLINEDIST );
228 if( pItem == NULL )
229 pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST );
230 if( pItem )
231 {
232 long nValue = ( ( const SdrMeasureHelplineDistItem* )pItem )->GetValue();
233 SetMetricValue( aMtrFldHelplineDist, nValue, eUnit );
234 }
235 else
236 {
237 aMtrFldHelplineDist.SetText( String() );
238 }
239 aMtrFldHelplineDist.SaveValue();
240
241 // SdrMeasureHelpline1LenItem
242 pItem = GetItem( rAttrs, SDRATTR_MEASUREHELPLINE1LEN );
243 if( pItem == NULL )
244 pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN );
245 if( pItem )
246 {
247 long nValue = ( ( const SdrMeasureHelpline1LenItem* )pItem )->GetValue();
248 SetMetricValue( aMtrFldHelpline1Len, nValue, eUnit );
249 }
250 else
251 {
252 aMtrFldHelpline1Len.SetText( String() );
253 }
254 aMtrFldHelpline1Len.SaveValue();
255
256 // SdrMeasureHelpline2LenItem
257 pItem = GetItem( rAttrs, SDRATTR_MEASUREHELPLINE2LEN );
258 if( pItem == NULL )
259 pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN );
260 if( pItem )
261 {
262 long nValue = ( ( const SdrMeasureHelpline2LenItem* )pItem )->GetValue();
263 SetMetricValue( aMtrFldHelpline2Len, nValue, eUnit );
264 }
265 else
266 {
267 aMtrFldHelpline2Len.SetText( String() );
268 }
269 aMtrFldHelpline2Len.SaveValue();
270
271 // SdrMeasureBelowRefEdgeItem
272 if( rAttrs.GetItemState( SDRATTR_MEASUREBELOWREFEDGE ) != SFX_ITEM_DONTCARE )
273 {
274 aTsbBelowRefEdge.SetState( ( ( const SdrMeasureBelowRefEdgeItem& )rAttrs.Get( SDRATTR_MEASUREBELOWREFEDGE ) ).
275 GetValue() ? STATE_CHECK : STATE_NOCHECK );
276 aTsbBelowRefEdge.EnableTriState( sal_False );
277 }
278 else
279 {
280 aTsbBelowRefEdge.SetState( STATE_DONTKNOW );
281 }
282 aTsbBelowRefEdge.SaveValue();
283
284 // SdrMeasureDecimalPlacesItem
285 pItem = GetItem( rAttrs, SDRATTR_MEASUREDECIMALPLACES );
286 if( pItem == NULL )
287 pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES );
288 if( pItem )
289 {
290 sal_Int16 nValue = ( ( const SdrMeasureDecimalPlacesItem* )pItem )->GetValue();
291 aMtrFldDecimalPlaces.SetValue( nValue );
292 }
293 else
294 {
295 aMtrFldDecimalPlaces.SetText( String() );
296 }
297 aMtrFldDecimalPlaces.SaveValue();
298
299 // SdrMeasureTextRota90Item
300 // Attention: negate !
301 if( rAttrs.GetItemState( SDRATTR_MEASURETEXTROTA90 ) != SFX_ITEM_DONTCARE )
302 {
303 aTsbParallel.SetState( ( ( const SdrMeasureTextRota90Item& )rAttrs.Get( SDRATTR_MEASURETEXTROTA90 ) ).
304 GetValue() ? STATE_NOCHECK : STATE_CHECK );
305 aTsbParallel.EnableTriState( sal_False );
306 }
307 else
308 {
309 aTsbParallel.SetState( STATE_DONTKNOW );
310 }
311 aTsbParallel.SaveValue();
312
313 // SdrMeasureShowUnitItem
314 if( rAttrs.GetItemState( SDRATTR_MEASURESHOWUNIT ) != SFX_ITEM_DONTCARE )
315 {
316 aTsbShowUnit.SetState( ( ( const SdrMeasureShowUnitItem& )rAttrs.Get( SDRATTR_MEASURESHOWUNIT ) ).
317 GetValue() ? STATE_CHECK : STATE_NOCHECK );
318 aTsbShowUnit.EnableTriState( sal_False );
319 }
320 else
321 {
322 aTsbShowUnit.SetState( STATE_DONTKNOW );
323 }
324 aTsbShowUnit.SaveValue();
325
326 // SdrMeasureUnitItem
327 if( rAttrs.GetItemState( SDRATTR_MEASUREUNIT ) != SFX_ITEM_DONTCARE )
328 {
329 long nFieldUnit = (long) ( ( const SdrMeasureUnitItem& )rAttrs.
330 Get( SDRATTR_MEASUREUNIT ) ).GetValue();
331
332 for( sal_uInt16 i = 0; i < aLbUnit.GetEntryCount(); ++i )
333 {
334 if ( (long)aLbUnit.GetEntryData( i ) == nFieldUnit )
335 {
336 aLbUnit.SelectEntryPos( i );
337 break;
338 }
339 }
340 }
341 else
342 {
343 aLbUnit.SetNoSelection();
344 }
345 aLbUnit.SaveValue();
346
347 // Position
348 if ( rAttrs.GetItemState( SDRATTR_MEASURETEXTVPOS ) != SFX_ITEM_DONTCARE )
349 {
350 SdrMeasureTextVPos eVPos = (SdrMeasureTextVPos)
351 ( ( const SdrMeasureTextVPosItem& )rAttrs.Get( SDRATTR_MEASURETEXTVPOS ) ).GetValue();
352 {
353 if ( rAttrs.GetItemState( SDRATTR_MEASURETEXTHPOS ) != SFX_ITEM_DONTCARE )
354 {
355 aTsbAutoPosV.EnableTriState( sal_False );
356 aTsbAutoPosH.EnableTriState( sal_False );
357
358 SdrMeasureTextHPos eHPos = (SdrMeasureTextHPos)
359 ( ( const SdrMeasureTextHPosItem& )rAttrs.Get( SDRATTR_MEASURETEXTHPOS ) ).GetValue();
360 RECT_POINT eRP = RP_MM;
361 switch( eVPos )
362 {
363 case SDRMEASURE_ABOVE:
364 switch( eHPos )
365 {
366 case SDRMEASURE_TEXTLEFTOUTSIDE: eRP = RP_LT; break;
367 case SDRMEASURE_TEXTINSIDE: eRP = RP_MT; break;
368 case SDRMEASURE_TEXTRIGHTOUTSIDE: eRP = RP_RT; break;
369 case SDRMEASURE_TEXTHAUTO: eRP = RP_MT; break;
370 }
371 break;
372 case SDRMEASURETEXT_VERTICALCENTERED:
373 switch( eHPos )
374 {
375 case SDRMEASURE_TEXTLEFTOUTSIDE: eRP = RP_LM; break;
376 case SDRMEASURE_TEXTINSIDE: eRP = RP_MM; break;
377 case SDRMEASURE_TEXTRIGHTOUTSIDE: eRP = RP_RM; break;
378 case SDRMEASURE_TEXTHAUTO: eRP = RP_MM; break;
379 }
380 break;
381 case SDRMEASURE_BELOW:
382 switch( eHPos )
383 {
384 case SDRMEASURE_TEXTLEFTOUTSIDE: eRP = RP_LB; break;
385 case SDRMEASURE_TEXTINSIDE: eRP = RP_MB; break;
386 case SDRMEASURE_TEXTRIGHTOUTSIDE: eRP = RP_RB; break;
387 case SDRMEASURE_TEXTHAUTO: eRP = RP_MB; break;
388 }
389 break;
390 case SDRMEASURE_TEXTVAUTO:
391 switch( eHPos )
392 {
393 case SDRMEASURE_TEXTLEFTOUTSIDE: eRP = RP_LM; break;
394 case SDRMEASURE_TEXTINSIDE: eRP = RP_MM; break;
395 case SDRMEASURE_TEXTRIGHTOUTSIDE: eRP = RP_RM; break;
396 case SDRMEASURE_TEXTHAUTO: eRP = RP_MM; break;
397 }
398 break;
399 default: ;//prevent warning
400 }
401
402 CTL_STATE nState = 0;
403
404 if( eHPos == SDRMEASURE_TEXTHAUTO )
405 {
406 aTsbAutoPosH.SetState( STATE_CHECK );
407 nState = CS_NOHORZ;
408 }
409
410 if( eVPos == SDRMEASURE_TEXTVAUTO )
411 {
412 aTsbAutoPosV.SetState( STATE_CHECK );
413 nState |= CS_NOVERT;
414 }
415
416 aCtlPosition.SetState( nState );
417 aCtlPosition.SetActualRP( eRP );
418 }
419 }
420 }
421 else
422 {
423 aCtlPosition.Reset();
424 aTsbAutoPosV.SetState( STATE_DONTKNOW );
425 aTsbAutoPosH.SetState( STATE_DONTKNOW );
426 }
427
428 // put the attributes to the preview-control,
429 // otherwise the control don't know about
430 // the settings of the dialog (#67930)
431 ChangeAttrHdl_Impl( &aTsbShowUnit );
432 aCtlPreview.SetAttributes( rAttrs );
433
434 bPositionModified = sal_False;
435 }
436
437 /*************************************************************************
438 |*
439 |* Fill the delivered Item-Set with dialogbox-attributes
440 |*
441 \************************************************************************/
442
FillItemSet(SfxItemSet & rAttrs)443 sal_Bool SvxMeasurePage::FillItemSet( SfxItemSet& rAttrs)
444 {
445 sal_Bool bModified = sal_False;
446 sal_Int32 nValue;
447 TriState eState;
448
449 if( aMtrFldLineDist.GetText() != aMtrFldLineDist.GetSavedValue() )
450 {
451 nValue = GetCoreValue( aMtrFldLineDist, eUnit );
452 rAttrs.Put( SdrMeasureLineDistItem( nValue ) );
453 bModified = sal_True;
454 }
455
456 if( aMtrFldHelplineOverhang.GetText() != aMtrFldHelplineOverhang.GetSavedValue() )
457 {
458 nValue = GetCoreValue( aMtrFldHelplineOverhang, eUnit );
459 rAttrs.Put( SdrMeasureHelplineOverhangItem( nValue ) );
460 bModified = sal_True;
461 }
462
463 if( aMtrFldHelplineDist.GetText() != aMtrFldHelplineDist.GetSavedValue() )
464 {
465 nValue = GetCoreValue( aMtrFldHelplineDist, eUnit );
466 rAttrs.Put( SdrMeasureHelplineDistItem( nValue ) );
467 bModified = sal_True;
468 }
469
470 if( aMtrFldHelpline1Len.GetText() != aMtrFldHelpline1Len.GetSavedValue() )
471 {
472 nValue = GetCoreValue( aMtrFldHelpline1Len, eUnit );
473 rAttrs.Put( SdrMeasureHelpline1LenItem( nValue ) );
474 bModified = sal_True;
475 }
476
477 if( aMtrFldHelpline2Len.GetText() != aMtrFldHelpline2Len.GetSavedValue() )
478 {
479 nValue = GetCoreValue( aMtrFldHelpline2Len, eUnit );
480 rAttrs.Put( SdrMeasureHelpline2LenItem( nValue ) );
481 bModified = sal_True;
482 }
483
484 eState = aTsbBelowRefEdge.GetState();
485 if( eState != aTsbBelowRefEdge.GetSavedValue() )
486 {
487 rAttrs.Put( SdrMeasureBelowRefEdgeItem( (sal_Bool) STATE_CHECK == eState ) );
488 bModified = sal_True;
489 }
490
491 if( aMtrFldDecimalPlaces.GetText() != aMtrFldDecimalPlaces.GetSavedValue() )
492 {
493 nValue = static_cast<sal_Int32>(aMtrFldDecimalPlaces.GetValue());
494 rAttrs.Put(
495 SdrMeasureDecimalPlacesItem(
496 sal::static_int_cast< sal_Int16 >( nValue ) ) );
497 bModified = sal_True;
498 }
499
500 eState = aTsbParallel.GetState();
501 if( eState != aTsbParallel.GetSavedValue() )
502 {
503 rAttrs.Put( SdrMeasureTextRota90Item( (sal_Bool) STATE_NOCHECK == eState ) );
504 bModified = sal_True;
505 }
506
507 eState = aTsbShowUnit.GetState();
508 if( eState != aTsbShowUnit.GetSavedValue() )
509 {
510 rAttrs.Put( SdrMeasureShowUnitItem( (sal_Bool) STATE_CHECK == eState ) );
511 bModified = sal_True;
512 }
513
514 sal_uInt16 nPos = aLbUnit.GetSelectEntryPos();
515 if( nPos != aLbUnit.GetSavedValue() )
516 {
517 if( nPos != LISTBOX_ENTRY_NOTFOUND )
518 {
519 sal_uInt16 nFieldUnit = (sal_uInt16)(long)aLbUnit.GetEntryData( nPos );
520 FieldUnit _eUnit = (FieldUnit) nFieldUnit;
521 rAttrs.Put( SdrMeasureUnitItem( _eUnit ) );
522 bModified = sal_True;
523 }
524 }
525
526 //enum SdrMeasureTextHPos {SDRMEASURE_TEXTHAUTO,SDRMEASURE_TEXTLEFTOUTSIDE,SDRMEASURE_TEXTINSIDE,SDRMEASURE_TEXTRIGHTOUTSIDE};
527 //enum SdrMeasureTextVPos {SDRMEASURE_TEXTVAUTO,SDRMEASURE_ABOVE,SDRMEASURETEXT_VERTICALCENTERED,SDRMEASURE_BELOW};
528
529 if( bPositionModified )
530 {
531 // Position
532 SdrMeasureTextVPos eVPos, eOldVPos;
533 SdrMeasureTextHPos eHPos, eOldHPos;
534
535 RECT_POINT eRP = aCtlPosition.GetActualRP();
536 switch( eRP )
537 {
538 default:
539 case RP_LT: eVPos = SDRMEASURE_ABOVE;
540 eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
541 case RP_LM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
542 eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
543 case RP_LB: eVPos = SDRMEASURE_BELOW;
544 eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
545 case RP_MT: eVPos = SDRMEASURE_ABOVE;
546 eHPos = SDRMEASURE_TEXTINSIDE; break;
547 case RP_MM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
548 eHPos = SDRMEASURE_TEXTINSIDE; break;
549 case RP_MB: eVPos = SDRMEASURE_BELOW;
550 eHPos = SDRMEASURE_TEXTINSIDE; break;
551 case RP_RT: eVPos = SDRMEASURE_ABOVE;
552 eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
553 case RP_RM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
554 eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
555 case RP_RB: eVPos = SDRMEASURE_BELOW;
556 eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
557 }
558 if( aTsbAutoPosH.GetState() == STATE_CHECK )
559 eHPos = SDRMEASURE_TEXTHAUTO;
560
561 if( aTsbAutoPosV.GetState() == STATE_CHECK )
562 eVPos = SDRMEASURE_TEXTVAUTO;
563
564 if ( rAttrs.GetItemState( SDRATTR_MEASURETEXTVPOS ) != SFX_ITEM_DONTCARE )
565 {
566 eOldVPos = (SdrMeasureTextVPos)
567 ( ( const SdrMeasureTextVPosItem& )rOutAttrs.Get( SDRATTR_MEASURETEXTVPOS ) ).GetValue();
568 if( eOldVPos != eVPos )
569 {
570 rAttrs.Put( SdrMeasureTextVPosItem( eVPos ) );
571 bModified = sal_True;
572 }
573 }
574 else
575 {
576 rAttrs.Put( SdrMeasureTextVPosItem( eVPos ) );
577 bModified = sal_True;
578 }
579
580 if ( rAttrs.GetItemState( SDRATTR_MEASURETEXTHPOS ) != SFX_ITEM_DONTCARE )
581 {
582 eOldHPos = (SdrMeasureTextHPos)
583 ( ( const SdrMeasureTextHPosItem& )rOutAttrs.Get( SDRATTR_MEASURETEXTHPOS ) ).GetValue();
584 if( eOldHPos != eHPos )
585 {
586 rAttrs.Put( SdrMeasureTextHPosItem( eHPos ) );
587 bModified = sal_True;
588 }
589 }
590 else
591 {
592 rAttrs.Put( SdrMeasureTextHPosItem( eHPos ) );
593 bModified = sal_True;
594 }
595 }
596
597 return( bModified );
598 }
599
600 /*************************************************************************
601 |*
602 |* The View have to set at the measure-object to be able to notify
603 |* unit and floatingpoint-values
604 |*
605 \************************************************************************/
606
Construct()607 void SvxMeasurePage::Construct()
608 {
609 DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
610
611 aCtlPreview.pMeasureObj->SetModel( pView->GetModel() );
612 aCtlPreview.Invalidate();
613 }
614
615 /*************************************************************************
616 |*
617 |* create the tabpage
618 |*
619 \************************************************************************/
620
Create(Window * pWindow,const SfxItemSet & rAttrs)621 SfxTabPage* SvxMeasurePage::Create( Window* pWindow,
622 const SfxItemSet& rAttrs )
623 {
624 return( new SvxMeasurePage( pWindow, rAttrs ) );
625 }
626
627 /*************************************************************************
628 |*
629 |*
630 |*
631 \************************************************************************/
632
GetRanges()633 sal_uInt16* SvxMeasurePage::GetRanges()
634 {
635 return( pRanges );
636 }
637
638 /*************************************************************************
639 |*
640 |*
641 |*
642 \************************************************************************/
643
PointChanged(Window * pWindow,RECT_POINT)644 void SvxMeasurePage::PointChanged( Window* pWindow, RECT_POINT /*eRP*/ )
645 {
646 ChangeAttrHdl_Impl( pWindow );
647 }
648
649 /*************************************************************************
650 |*
651 |*
652 |*
653 \************************************************************************/
654
IMPL_LINK(SvxMeasurePage,ClickAutoPosHdl_Impl,void *,p)655 IMPL_LINK( SvxMeasurePage, ClickAutoPosHdl_Impl, void *, p )
656 {
657 if( aTsbAutoPosH.GetState() == STATE_CHECK )
658 {
659 switch( aCtlPosition.GetActualRP() )
660 {
661 case RP_LT:
662 case RP_RT:
663 aCtlPosition.SetActualRP( RP_MT );
664 break;
665
666 case RP_LM:
667 case RP_RM:
668 aCtlPosition.SetActualRP( RP_MM );
669 break;
670
671 case RP_LB:
672 case RP_RB:
673 aCtlPosition.SetActualRP( RP_MB );
674 break;
675 default: ;//prevent warning
676 }
677 }
678 if( aTsbAutoPosV.GetState() == STATE_CHECK )
679 {
680 switch( aCtlPosition.GetActualRP() )
681 {
682 case RP_LT:
683 case RP_LB:
684 aCtlPosition.SetActualRP( RP_LM );
685 break;
686
687 case RP_MT:
688 case RP_MB:
689 aCtlPosition.SetActualRP( RP_MM );
690 break;
691
692 case RP_RT:
693 case RP_RB:
694 aCtlPosition.SetActualRP( RP_RM );
695 break;
696 default: ;//prevent warning
697 }
698 }
699 ChangeAttrHdl_Impl( p );
700
701 return( 0L );
702 }
703
704 /*************************************************************************
705 |*
706 |*
707 |*
708 \************************************************************************/
709
IMPL_LINK(SvxMeasurePage,ChangeAttrHdl_Impl,void *,p)710 IMPL_LINK( SvxMeasurePage, ChangeAttrHdl_Impl, void *, p )
711 {
712
713 if( p == &aMtrFldLineDist )
714 {
715 sal_Int32 nValue = GetCoreValue( aMtrFldLineDist, eUnit );
716 aAttrSet.Put( SdrMeasureLineDistItem( nValue ) );
717 }
718
719 if( p == &aMtrFldHelplineOverhang )
720 {
721 sal_Int32 nValue = GetCoreValue( aMtrFldHelplineOverhang, eUnit );
722 aAttrSet.Put( SdrMeasureHelplineOverhangItem( nValue) );
723 }
724
725 if( p == &aMtrFldHelplineDist )
726 {
727 sal_Int32 nValue = GetCoreValue( aMtrFldHelplineDist, eUnit );
728 aAttrSet.Put( SdrMeasureHelplineDistItem( nValue) );
729 }
730
731 if( p == &aMtrFldHelpline1Len )
732 {
733 sal_Int32 nValue = GetCoreValue( aMtrFldHelpline1Len, eUnit );
734 aAttrSet.Put( SdrMeasureHelpline1LenItem( nValue ) );
735 }
736
737 if( p == &aMtrFldHelpline2Len )
738 {
739 sal_Int32 nValue = GetCoreValue( aMtrFldHelpline2Len, eUnit );
740 aAttrSet.Put( SdrMeasureHelpline2LenItem( nValue ) );
741 }
742
743 if( p == &aTsbBelowRefEdge )
744 {
745 TriState eState = aTsbBelowRefEdge.GetState();
746 if( eState != STATE_DONTKNOW )
747 aAttrSet.Put( SdrMeasureBelowRefEdgeItem( (sal_Bool) STATE_CHECK == eState ) );
748 }
749
750 if( p == &aMtrFldDecimalPlaces )
751 {
752 sal_Int16 nValue = sal::static_int_cast< sal_Int16 >(
753 aMtrFldDecimalPlaces.GetValue() );
754 aAttrSet.Put( SdrMeasureDecimalPlacesItem( nValue ) );
755 }
756
757 if( p == &aTsbParallel )
758 {
759 TriState eState = aTsbParallel.GetState();
760 if( eState != STATE_DONTKNOW )
761 aAttrSet.Put( SdrMeasureTextRota90Item( (sal_Bool) !STATE_CHECK == eState ) );
762 }
763
764 if( p == &aTsbShowUnit )
765 {
766 TriState eState = aTsbShowUnit.GetState();
767 if( eState != STATE_DONTKNOW )
768 aAttrSet.Put( SdrMeasureShowUnitItem( (sal_Bool) STATE_CHECK == eState ) );
769 }
770
771 if( p == &aLbUnit )
772 {
773 sal_uInt16 nPos = aLbUnit.GetSelectEntryPos();
774 if( nPos != LISTBOX_ENTRY_NOTFOUND )
775 {
776 sal_uInt16 nFieldUnit = (sal_uInt16)(long)aLbUnit.GetEntryData( nPos );
777 FieldUnit _eUnit = (FieldUnit) nFieldUnit;
778 aAttrSet.Put( SdrMeasureUnitItem( _eUnit ) );
779 }
780 }
781
782 if( p == &aTsbAutoPosV || p == &aTsbAutoPosH || p == &aCtlPosition )
783 {
784 bPositionModified = sal_True;
785
786 // Position
787 RECT_POINT eRP = aCtlPosition.GetActualRP();
788 SdrMeasureTextVPos eVPos;
789 SdrMeasureTextHPos eHPos;
790
791 switch( eRP )
792 {
793 default:
794 case RP_LT: eVPos = SDRMEASURE_ABOVE;
795 eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
796 case RP_LM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
797 eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
798 case RP_LB: eVPos = SDRMEASURE_BELOW;
799 eHPos = SDRMEASURE_TEXTLEFTOUTSIDE; break;
800 case RP_MT: eVPos = SDRMEASURE_ABOVE;
801 eHPos = SDRMEASURE_TEXTINSIDE; break;
802 case RP_MM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
803 eHPos = SDRMEASURE_TEXTINSIDE; break;
804 case RP_MB: eVPos = SDRMEASURE_BELOW;
805 eHPos = SDRMEASURE_TEXTINSIDE; break;
806 case RP_RT: eVPos = SDRMEASURE_ABOVE;
807 eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
808 case RP_RM: eVPos = SDRMEASURETEXT_VERTICALCENTERED;
809 eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
810 case RP_RB: eVPos = SDRMEASURE_BELOW;
811 eHPos = SDRMEASURE_TEXTRIGHTOUTSIDE; break;
812 }
813
814 CTL_STATE nState = 0;
815
816 if( aTsbAutoPosH.GetState() == STATE_CHECK )
817 {
818 eHPos = SDRMEASURE_TEXTHAUTO;
819 nState = CS_NOHORZ;
820 }
821
822 if( aTsbAutoPosV.GetState() == STATE_CHECK )
823 {
824 eVPos = SDRMEASURE_TEXTVAUTO;
825 nState |= CS_NOVERT;
826 }
827
828 if( p == &aTsbAutoPosV || p == &aTsbAutoPosH )
829 aCtlPosition.SetState( nState );
830
831 aAttrSet.Put( SdrMeasureTextVPosItem( eVPos ) );
832 aAttrSet.Put( SdrMeasureTextHPosItem( eHPos ) );
833 }
834
835 aCtlPreview.SetAttributes( aAttrSet );
836 aCtlPreview.Invalidate();
837
838 return( 0L );
839 }
840
841 /*************************************************************************
842 |*
843 |*
844 |*
845 \************************************************************************/
846
FillUnitLB()847 void SvxMeasurePage::FillUnitLB()
848 {
849 // fill ListBox with metrics
850 SvxStringArray aMetricArr( SVX_RES( RID_SVXSTR_FIELDUNIT_TABLE ) );
851
852 long nUnit = FUNIT_NONE;
853 String aStrMetric( CUI_RES( STR_MEASURE_AUTOMATIC ) );
854 sal_uInt16 nPos = aLbUnit.InsertEntry( aStrMetric );
855 aLbUnit.SetEntryData( nPos, (void*)nUnit );
856
857 for( sal_uInt16 i = 0; i < aMetricArr.Count(); ++i )
858 {
859 aStrMetric = aMetricArr.GetStringByPos( i );
860 nUnit = aMetricArr.GetValue( i );
861 nPos = aLbUnit.InsertEntry( aStrMetric );
862 aLbUnit.SetEntryData( nPos, (void*)nUnit );
863 }
864 }
PageCreated(SfxAllItemSet aSet)865 void SvxMeasurePage::PageCreated (SfxAllItemSet aSet) //add CHINA001
866 {
867 SFX_ITEMSET_ARG (&aSet,pOfaPtrItem,OfaPtrItem,SID_OBJECT_LIST,sal_False);
868
869 if (pOfaPtrItem)
870 SetView( static_cast<SdrView *>(pOfaPtrItem->GetValue()));
871
872 Construct();
873 }
874
875