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 #include "svx/ofaitem.hxx" // add CHINA001
32 #include <sfx2/request.hxx> // add CHINA001
33 #include <svx/dialogs.hrc>
34
35 #define _SVX_CONNECT_CXX
36
37 #include <svx/svdoedge.hxx>
38 #include <svx/svdattr.hxx>
39 #include <svx/svdattrx.hxx>
40 #include <svx/svdview.hxx>
41
42 #include "svx/connctrl.hxx"
43 #include "connect.hxx"
44 #include "connect.hrc"
45 #include <dialmgr.hxx>
46 #include "svx/dlgutil.hxx"
47
48 #include "paragrph.hrc"
49 #include <cuires.hrc>
50
51 static sal_uInt16 pRanges[] =
52 {
53 SDRATTR_EDGE_FIRST,
54 SDRATTR_EDGE_LAST,
55 0
56 };
57
58 /*************************************************************************
59 |*
60 |* Dialog zum Aendern von Konnektoren (Connectors)
61 |*
62 \************************************************************************/
63
SvxConnectionDialog(Window * pParent,const SfxItemSet & rInAttrs,const SdrView * pSdrView)64 SvxConnectionDialog::SvxConnectionDialog( Window* pParent, const SfxItemSet& rInAttrs,
65 const SdrView* pSdrView ) :
66 SfxSingleTabDialog( pParent, rInAttrs, RID_SVXPAGE_CONNECTION )
67 {
68 SvxConnectionPage* _pPage = new SvxConnectionPage( 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
~SvxConnectionDialog()83 SvxConnectionDialog::~SvxConnectionDialog()
84 {
85 }
86
87 /*************************************************************************
88 |*
89 |* Seite zum Aendern von Konnektoren (Connectors)
90 |*
91 \************************************************************************/
92
SvxConnectionPage(Window * pWindow,const SfxItemSet & rInAttrs)93 SvxConnectionPage::SvxConnectionPage( Window* pWindow, const SfxItemSet& rInAttrs ) :
94 SfxTabPage ( pWindow, CUI_RES( RID_SVXPAGE_CONNECTION ),
95 rInAttrs ),
96
97 aFtType ( this, CUI_RES( FT_TYPE ) ),
98 aLbType ( this, CUI_RES( LB_TYPE ) ),
99
100 aFlDelta ( this, CUI_RES( FL_DELTA ) ),
101 aFtLine1 ( this, CUI_RES( FT_LINE_1 ) ),
102 aMtrFldLine1 ( this, CUI_RES( MTR_FLD_LINE_1 ) ),
103 aFtLine2 ( this, CUI_RES( FT_LINE_2 ) ),
104 aMtrFldLine2 ( this, CUI_RES( MTR_FLD_LINE_2 ) ),
105 aFtLine3 ( this, CUI_RES( FT_LINE_3 ) ),
106 aMtrFldLine3 ( this, CUI_RES( MTR_FLD_LINE_3 ) ),
107
108 aFlDistance ( this, CUI_RES( FL_DISTANCE ) ),
109 aFtHorz1 ( this, CUI_RES( FT_HORZ_1 ) ),
110 aMtrFldHorz1 ( this, CUI_RES( MTR_FLD_HORZ_1 ) ),
111 aFtVert1 ( this, CUI_RES( FT_VERT_1 ) ),
112 aMtrFldVert1 ( this, CUI_RES( MTR_FLD_VERT_1 ) ),
113 aFtHorz2 ( this, CUI_RES( FT_HORZ_2 ) ),
114 aMtrFldHorz2 ( this, CUI_RES( MTR_FLD_HORZ_2 ) ),
115 aFtVert2 ( this, CUI_RES( FT_VERT_2 ) ),
116 aMtrFldVert2 ( this, CUI_RES( MTR_FLD_VERT_2 ) ),
117
118 aCtlPreview ( this, CUI_RES( CTL_PREVIEW ), rInAttrs ),
119 rOutAttrs ( rInAttrs ),
120 aAttrSet ( *rInAttrs.GetPool() )
121 {
122 FreeResource();
123
124 aCtlPreview.SetAccessibleName(String(CUI_RES(STR_EXAMPLE)));
125
126 SfxItemPool* pPool = rOutAttrs.GetPool();
127 DBG_ASSERT( pPool, "Wo ist der Pool" );
128 eUnit = pPool->GetMetric( SDRATTR_EDGENODE1HORZDIST );
129
130 FillTypeLB();
131
132 const FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
133 SetFieldUnit( aMtrFldHorz1, eFUnit );
134 SetFieldUnit( aMtrFldHorz2, eFUnit );
135 SetFieldUnit( aMtrFldVert1, eFUnit );
136 SetFieldUnit( aMtrFldVert2, eFUnit );
137 SetFieldUnit( aMtrFldLine1, eFUnit );
138 SetFieldUnit( aMtrFldLine2, eFUnit );
139 SetFieldUnit( aMtrFldLine3, eFUnit );
140 if( eFUnit == FUNIT_MM )
141 {
142 aMtrFldHorz1.SetSpinSize( 50 );
143 aMtrFldHorz2.SetSpinSize( 50 );
144 aMtrFldVert1.SetSpinSize( 50 );
145 aMtrFldVert2.SetSpinSize( 50 );
146 aMtrFldLine1.SetSpinSize( 50 );
147 aMtrFldLine2.SetSpinSize( 50 );
148 aMtrFldLine3.SetSpinSize( 50 );
149 }
150
151 // disable 3D border
152 aCtlPreview.SetBorderStyle(WINDOW_BORDER_MONO);
153
154 Link aLink( LINK( this, SvxConnectionPage, ChangeAttrHdl_Impl ) );
155 aMtrFldHorz1.SetModifyHdl( aLink );
156 aMtrFldVert1.SetModifyHdl( aLink );
157 aMtrFldHorz2.SetModifyHdl( aLink );
158 aMtrFldVert2.SetModifyHdl( aLink );
159 aMtrFldLine1.SetModifyHdl( aLink );
160 aMtrFldLine2.SetModifyHdl( aLink );
161 aMtrFldLine3.SetModifyHdl( aLink );
162 aLbType.SetSelectHdl( aLink );
163 }
164
165 /*************************************************************************
166 |*
167 |* Dtor
168 |*
169 \************************************************************************/
170
~SvxConnectionPage()171 SvxConnectionPage::~SvxConnectionPage()
172 {
173 }
174
175 /*************************************************************************
176 |*
177 |* Liest uebergebenen Item-Set
178 |*
179 \************************************************************************/
180
Reset(const SfxItemSet & rAttrs)181 void __EXPORT SvxConnectionPage::Reset( const SfxItemSet& rAttrs )
182 {
183 const SfxPoolItem* pItem = GetItem( rAttrs, SDRATTR_EDGENODE1HORZDIST );
184 const SfxItemPool* pPool = rAttrs.GetPool();
185
186 // SdrEdgeNode1HorzDistItem
187 if( !pItem )
188 pItem = &pPool->GetDefaultItem( SDRATTR_EDGENODE1HORZDIST );
189 if( pItem )
190 {
191 long nValue = ( ( const SdrEdgeNode1HorzDistItem* )pItem )->GetValue();
192 SetMetricValue( aMtrFldHorz1, nValue, eUnit );
193 }
194 else
195 aMtrFldHorz1.SetEmptyFieldValue();
196
197 aMtrFldHorz1.SaveValue();
198
199 // SdrEdgeNode2HorzDistItem
200 pItem = GetItem( rAttrs, SDRATTR_EDGENODE2HORZDIST );
201 if( !pItem )
202 pItem = &pPool->GetDefaultItem( SDRATTR_EDGENODE2HORZDIST );
203 if( pItem )
204 {
205 long nValue = ( ( const SdrEdgeNode2HorzDistItem* )pItem )->GetValue();
206 SetMetricValue( aMtrFldHorz2, nValue, eUnit );
207 }
208 else
209 aMtrFldHorz2.SetEmptyFieldValue();
210
211 aMtrFldHorz2.SaveValue();
212
213 // SdrEdgeNode1VertDistItem
214 pItem = GetItem( rAttrs, SDRATTR_EDGENODE1VERTDIST );
215 if( !pItem )
216 pItem = &pPool->GetDefaultItem( SDRATTR_EDGENODE1VERTDIST );
217 if( pItem )
218 {
219 long nValue = ( ( const SdrEdgeNode1VertDistItem* )pItem )->GetValue();
220 SetMetricValue( aMtrFldVert1, nValue, eUnit );
221 }
222 else
223 aMtrFldVert1.SetEmptyFieldValue();
224
225 aMtrFldVert1.SaveValue();
226
227 // SdrEdgeNode2VertDistItem
228 pItem = GetItem( rAttrs, SDRATTR_EDGENODE2VERTDIST );
229 if( !pItem )
230 pItem = &pPool->GetDefaultItem( SDRATTR_EDGENODE2VERTDIST );
231 if( pItem )
232 {
233 long nValue = ( ( const SdrEdgeNode2VertDistItem* )pItem )->GetValue();
234 SetMetricValue( aMtrFldVert2, nValue, eUnit );
235 }
236 else
237 aMtrFldVert2.SetEmptyFieldValue();
238
239 aMtrFldVert2.SaveValue();
240
241 // SdrEdgeLine1DeltaItem
242 pItem = GetItem( rAttrs, SDRATTR_EDGELINE1DELTA );
243 if( !pItem )
244 pItem = &pPool->GetDefaultItem( SDRATTR_EDGELINE1DELTA );
245 if( pItem )
246 {
247 long nValue = ( ( const SdrEdgeLine1DeltaItem* )pItem )->GetValue();
248 SetMetricValue( aMtrFldLine1, nValue, eUnit );
249 }
250 else
251 aMtrFldLine1.SetEmptyFieldValue();
252
253 aMtrFldLine1.SaveValue();
254
255 // SdrEdgeLine2DeltaItem
256 pItem = GetItem( rAttrs, SDRATTR_EDGELINE2DELTA );
257 if( !pItem )
258 pItem = &pPool->GetDefaultItem( SDRATTR_EDGELINE2DELTA );
259 if( pItem )
260 {
261 long nValue = ( ( const SdrEdgeLine2DeltaItem* )pItem )->GetValue();
262 SetMetricValue( aMtrFldLine2, nValue, eUnit );
263 }
264 else
265 aMtrFldLine2.SetEmptyFieldValue();
266
267 aMtrFldLine2.SaveValue();
268
269 // SdrEdgeLine3DeltaItem
270 pItem = GetItem( rAttrs, SDRATTR_EDGELINE3DELTA );
271 if( !pItem )
272 pItem = &pPool->GetDefaultItem( SDRATTR_EDGELINE3DELTA );
273 if( pItem )
274 {
275 long nValue = ( ( const SdrEdgeLine3DeltaItem* )pItem )->GetValue();
276 SetMetricValue( aMtrFldLine3, nValue, eUnit );
277 }
278 else
279 aMtrFldLine3.SetEmptyFieldValue();
280
281 aMtrFldLine3.SaveValue();
282
283 // SdrEdgeLineDeltaAnzItem
284 pItem = GetItem( rAttrs, SDRATTR_EDGELINEDELTAANZ );
285 if( !pItem )
286 pItem = &pPool->GetDefaultItem( SDRATTR_EDGELINEDELTAANZ );
287 if( pItem )
288 {
289 sal_uInt16 nValue = ( ( const SdrEdgeLineDeltaAnzItem* )pItem )->GetValue();
290 if( nValue <= 2 )
291 {
292 aFtLine3.Enable( sal_False );
293 aMtrFldLine3.Enable( sal_False );
294 aMtrFldLine3.SetEmptyFieldValue();
295 }
296 if( nValue <= 1 )
297 {
298 aFtLine2.Enable( sal_False );
299 aMtrFldLine2.Enable( sal_False );
300 aMtrFldLine2.SetEmptyFieldValue();
301 }
302 if( nValue == 0 )
303 {
304 aFtLine1.Enable( sal_False );
305 aMtrFldLine1.Enable( sal_False );
306 aMtrFldLine1.SetEmptyFieldValue();
307 }
308 }
309
310 // SdrEdgeKindItem
311 pItem = GetItem( rAttrs, SDRATTR_EDGEKIND );
312 if( !pItem )
313 pItem = &pPool->GetDefaultItem( SDRATTR_EDGEKIND );
314 if( pItem )
315 {
316 SdrEdgeKind nValue = ( ( const SdrEdgeKindItem* )pItem )->GetValue();
317 aLbType.SelectEntryPos( sal::static_int_cast< sal_uInt16 >(nValue) );
318 }
319 else
320 aLbType.SetNoSelection();
321 aLbType.SaveValue();
322 }
323
324 /*************************************************************************
325 |*
326 |* Fuellt uebergebenen Item-Set mit Dialogbox-Attributen
327 |*
328 \************************************************************************/
329
FillItemSet(SfxItemSet & rAttrs)330 sal_Bool SvxConnectionPage::FillItemSet( SfxItemSet& rAttrs)
331 {
332 sal_Bool bModified = sal_False;
333 sal_Int32 nValue;
334
335 if( aMtrFldHorz1.GetText() != aMtrFldHorz1.GetSavedValue() )
336 {
337 nValue = GetCoreValue( aMtrFldHorz1, eUnit );
338 rAttrs.Put( SdrEdgeNode1HorzDistItem( nValue ) );
339 bModified = sal_True;
340 }
341
342 if( aMtrFldHorz2.GetText() != aMtrFldHorz2.GetSavedValue() )
343 {
344 nValue = GetCoreValue( aMtrFldHorz2, eUnit );
345 rAttrs.Put( SdrEdgeNode2HorzDistItem( nValue ) );
346 bModified = sal_True;
347 }
348
349 if( aMtrFldVert1.GetText() != aMtrFldVert1.GetSavedValue() )
350 {
351 nValue = GetCoreValue( aMtrFldVert1, eUnit );
352 rAttrs.Put( SdrEdgeNode1VertDistItem( nValue ) );
353 bModified = sal_True;
354 }
355
356 if( aMtrFldVert2.GetText() != aMtrFldVert2.GetSavedValue() )
357 {
358 nValue = GetCoreValue( aMtrFldVert2, eUnit );
359 rAttrs.Put( SdrEdgeNode2VertDistItem( nValue ) );
360 bModified = sal_True;
361 }
362
363 if( aMtrFldLine1.GetText() != aMtrFldLine1.GetSavedValue() )
364 {
365 nValue = GetCoreValue( aMtrFldLine1, eUnit );
366 rAttrs.Put( SdrEdgeLine1DeltaItem( nValue ) );
367 bModified = sal_True;
368 }
369
370 if( aMtrFldLine2.GetText() != aMtrFldLine2.GetSavedValue() )
371 {
372 nValue = GetCoreValue( aMtrFldLine2, eUnit );
373 rAttrs.Put( SdrEdgeLine2DeltaItem( nValue ) );
374 bModified = sal_True;
375 }
376
377 if( aMtrFldLine3.GetText() != aMtrFldLine3.GetSavedValue() )
378 {
379 nValue = GetCoreValue( aMtrFldLine3, eUnit );
380 rAttrs.Put( SdrEdgeLine3DeltaItem( nValue ) );
381 bModified = sal_True;
382 }
383
384
385 sal_uInt16 nPos = aLbType.GetSelectEntryPos();
386 if( nPos != aLbType.GetSavedValue() )
387 {
388 if( nPos != LISTBOX_ENTRY_NOTFOUND )
389 {
390 rAttrs.Put( SdrEdgeKindItem( (SdrEdgeKind) nPos ) );
391 bModified = sal_True;
392 }
393 }
394
395 return( bModified );
396 }
397
398 /*************************************************************************
399 |*
400 |*
401 |*
402 \************************************************************************/
403
Construct()404 void SvxConnectionPage::Construct()
405 {
406 DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
407
408 aCtlPreview.SetView( pView );
409 aCtlPreview.Construct();
410 }
411
412 /*************************************************************************
413 |*
414 |* Erzeugt die Seite
415 |*
416 \************************************************************************/
417
Create(Window * pWindow,const SfxItemSet & rAttrs)418 SfxTabPage* SvxConnectionPage::Create( Window* pWindow,
419 const SfxItemSet& rAttrs )
420 {
421 return( new SvxConnectionPage( pWindow, rAttrs ) );
422 }
423
424 /*************************************************************************
425 |*
426 |*
427 |*
428 \************************************************************************/
429
GetRanges()430 sal_uInt16* SvxConnectionPage::GetRanges()
431 {
432 return( pRanges );
433 }
434
435 /*************************************************************************
436 |*
437 |*
438 |*
439 \************************************************************************/
440
IMPL_LINK(SvxConnectionPage,ChangeAttrHdl_Impl,void *,p)441 IMPL_LINK( SvxConnectionPage, ChangeAttrHdl_Impl, void *, p )
442 {
443 if( p == &aMtrFldHorz1 )
444 {
445 sal_Int32 nValue = GetCoreValue( aMtrFldHorz1, eUnit );
446 aAttrSet.Put( SdrEdgeNode1HorzDistItem( nValue ) );
447 }
448
449 if( p == &aMtrFldHorz2 )
450 {
451 sal_Int32 nValue = GetCoreValue( aMtrFldHorz2, eUnit );
452 aAttrSet.Put( SdrEdgeNode2HorzDistItem( nValue ) );
453 }
454
455 if( p == &aMtrFldVert1 )
456 {
457 sal_Int32 nValue = GetCoreValue( aMtrFldVert1, eUnit );
458 aAttrSet.Put( SdrEdgeNode1VertDistItem( nValue ) );
459 }
460
461 if( p == &aMtrFldVert2 )
462 {
463 sal_Int32 nValue = GetCoreValue( aMtrFldVert2, eUnit );
464 aAttrSet.Put( SdrEdgeNode2VertDistItem( nValue ) );
465 }
466
467 if( p == &aMtrFldLine1 )
468 {
469 sal_Int32 nValue = GetCoreValue( aMtrFldLine1, eUnit );
470 aAttrSet.Put( SdrEdgeLine1DeltaItem( nValue ) );
471 }
472
473 if( p == &aMtrFldLine2 )
474 {
475 sal_Int32 nValue = GetCoreValue( aMtrFldLine2, eUnit );
476 aAttrSet.Put( SdrEdgeLine2DeltaItem( nValue ) );
477 }
478
479 if( p == &aMtrFldLine3 )
480 {
481 sal_Int32 nValue = GetCoreValue( aMtrFldLine3, eUnit );
482 aAttrSet.Put( SdrEdgeLine3DeltaItem( nValue ) );
483 }
484
485
486 if( p == &aLbType )
487 {
488 sal_uInt16 nPos = aLbType.GetSelectEntryPos();
489 if( nPos != LISTBOX_ENTRY_NOTFOUND )
490 {
491 aAttrSet.Put( SdrEdgeKindItem( (SdrEdgeKind) nPos ) );
492 }
493 }
494
495 aCtlPreview.SetAttributes( aAttrSet );
496
497 if( p == &aLbType )
498 {
499 // Anzahl der Linienversaetze ermitteln
500 sal_uInt16 nCount = aCtlPreview.GetLineDeltaAnz();
501
502 aFtLine3.Enable( nCount > 2 );
503 aMtrFldLine3.Enable( nCount > 2 );
504 if( nCount > 2 )
505 aMtrFldLine3.SetValue( aMtrFldLine3.GetValue() );
506 else
507 aMtrFldLine3.SetEmptyFieldValue();
508
509 aFtLine2.Enable( nCount > 1 );
510 aMtrFldLine2.Enable( nCount > 1 );
511 if( nCount > 1 )
512 aMtrFldLine2.SetValue( aMtrFldLine2.GetValue() );
513 else
514 aMtrFldLine2.SetEmptyFieldValue();
515
516 aFtLine1.Enable( nCount > 0 );
517 aMtrFldLine1.Enable( nCount > 0 );
518 if( nCount > 0 )
519 aMtrFldLine1.SetValue( aMtrFldLine1.GetValue() );
520 else
521 aMtrFldLine1.SetEmptyFieldValue();
522
523 }
524
525 return( 0L );
526 }
527
528 /*************************************************************************
529 |*
530 |*
531 |*
532 \************************************************************************/
533
FillTypeLB()534 void SvxConnectionPage::FillTypeLB()
535 {
536 // ListBox mit Verbindernamen fuellen
537 const SfxPoolItem* pItem = GetItem( rOutAttrs, SDRATTR_EDGEKIND );
538 const SfxItemPool* pPool = rOutAttrs.GetPool();
539
540 if( !pItem )
541 pItem = &pPool->GetDefaultItem( SDRATTR_EDGEKIND );
542 if( pItem )
543 {
544 const SdrEdgeKindItem* pEdgeKindItem = (const SdrEdgeKindItem*) pItem;
545 sal_uInt16 nCount = pEdgeKindItem->GetValueCount();
546 String aStr;
547
548 for( sal_uInt16 i = 0; i < nCount; i++ )
549 {
550 aStr = pEdgeKindItem->GetValueTextByPos( i );
551 aLbType.InsertEntry( aStr );
552 }
553 }
554 }
PageCreated(SfxAllItemSet aSet)555 void SvxConnectionPage::PageCreated (SfxAllItemSet aSet) //add CHINA001
556 {
557 SFX_ITEMSET_ARG(&aSet,pOfaPtrItem,OfaPtrItem,SID_OBJECT_LIST,sal_False);
558 if (pOfaPtrItem)
559 SetView( static_cast<SdrView *>(pOfaPtrItem->GetValue()) );
560
561 Construct();
562 }
563
564