1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 // include ---------------------------------------------------------------
32 #include <sfx2/app.hxx>
33 #include <sfx2/module.hxx>
34 #include <tools/shl.hxx>
35 #include "svx/ofaitem.hxx" // add CHINA001
36 #include <sfx2/request.hxx> // add CHINA001
37 #include <svx/dialogs.hrc>
39 #define _SVX_CONNECT_CXX
41 #include <svx/svdoedge.hxx>
42 #include <svx/svdattr.hxx>
43 #include <svx/svdattrx.hxx>
44 #include <svx/svdview.hxx>
46 #include "svx/connctrl.hxx"
47 #include "connect.hxx"
48 #include "connect.hrc"
49 #include <dialmgr.hxx>
50 #include "svx/dlgutil.hxx"
52 #include "paragrph.hrc"
55 static sal_uInt16 pRanges
[] =
62 /*************************************************************************
64 |* Dialog zum Aendern von Konnektoren (Connectors)
66 \************************************************************************/
68 SvxConnectionDialog::SvxConnectionDialog( Window
* pParent
, const SfxItemSet
& rInAttrs
,
69 const SdrView
* pSdrView
) :
70 SfxSingleTabDialog( pParent
, rInAttrs
, RID_SVXPAGE_CONNECTION
)
72 SvxConnectionPage
* _pPage
= new SvxConnectionPage( this, rInAttrs
);
74 _pPage
->SetView( pSdrView
);
78 SetText( _pPage
->GetText() );
81 /*************************************************************************
85 \************************************************************************/
87 SvxConnectionDialog::~SvxConnectionDialog()
91 /*************************************************************************
93 |* Seite zum Aendern von Konnektoren (Connectors)
95 \************************************************************************/
97 SvxConnectionPage::SvxConnectionPage( Window
* pWindow
, const SfxItemSet
& rInAttrs
) :
98 SfxTabPage ( pWindow
, CUI_RES( RID_SVXPAGE_CONNECTION
),
101 aFtType ( this, CUI_RES( FT_TYPE
) ),
102 aLbType ( this, CUI_RES( LB_TYPE
) ),
104 aFlDelta ( this, CUI_RES( FL_DELTA
) ),
105 aFtLine1 ( this, CUI_RES( FT_LINE_1
) ),
106 aMtrFldLine1 ( this, CUI_RES( MTR_FLD_LINE_1
) ),
107 aFtLine2 ( this, CUI_RES( FT_LINE_2
) ),
108 aMtrFldLine2 ( this, CUI_RES( MTR_FLD_LINE_2
) ),
109 aFtLine3 ( this, CUI_RES( FT_LINE_3
) ),
110 aMtrFldLine3 ( this, CUI_RES( MTR_FLD_LINE_3
) ),
112 aFlDistance ( this, CUI_RES( FL_DISTANCE
) ),
113 aFtHorz1 ( this, CUI_RES( FT_HORZ_1
) ),
114 aMtrFldHorz1 ( this, CUI_RES( MTR_FLD_HORZ_1
) ),
115 aFtVert1 ( this, CUI_RES( FT_VERT_1
) ),
116 aMtrFldVert1 ( this, CUI_RES( MTR_FLD_VERT_1
) ),
117 aFtHorz2 ( this, CUI_RES( FT_HORZ_2
) ),
118 aMtrFldHorz2 ( this, CUI_RES( MTR_FLD_HORZ_2
) ),
119 aFtVert2 ( this, CUI_RES( FT_VERT_2
) ),
120 aMtrFldVert2 ( this, CUI_RES( MTR_FLD_VERT_2
) ),
122 aCtlPreview ( this, CUI_RES( CTL_PREVIEW
), rInAttrs
),
123 rOutAttrs ( rInAttrs
),
124 aAttrSet ( *rInAttrs
.GetPool() )
128 aCtlPreview
.SetAccessibleName(String(CUI_RES(STR_EXAMPLE
)));
130 SfxItemPool
* pPool
= rOutAttrs
.GetPool();
131 DBG_ASSERT( pPool
, "Wo ist der Pool" );
132 eUnit
= pPool
->GetMetric( SDRATTR_EDGENODE1HORZDIST
);
136 const FieldUnit eFUnit
= GetModuleFieldUnit( rInAttrs
);
137 SetFieldUnit( aMtrFldHorz1
, eFUnit
);
138 SetFieldUnit( aMtrFldHorz2
, eFUnit
);
139 SetFieldUnit( aMtrFldVert1
, eFUnit
);
140 SetFieldUnit( aMtrFldVert2
, eFUnit
);
141 SetFieldUnit( aMtrFldLine1
, eFUnit
);
142 SetFieldUnit( aMtrFldLine2
, eFUnit
);
143 SetFieldUnit( aMtrFldLine3
, eFUnit
);
144 if( eFUnit
== FUNIT_MM
)
146 aMtrFldHorz1
.SetSpinSize( 50 );
147 aMtrFldHorz2
.SetSpinSize( 50 );
148 aMtrFldVert1
.SetSpinSize( 50 );
149 aMtrFldVert2
.SetSpinSize( 50 );
150 aMtrFldLine1
.SetSpinSize( 50 );
151 aMtrFldLine2
.SetSpinSize( 50 );
152 aMtrFldLine3
.SetSpinSize( 50 );
156 aCtlPreview
.SetBorderStyle(WINDOW_BORDER_MONO
);
158 Link
aLink( LINK( this, SvxConnectionPage
, ChangeAttrHdl_Impl
) );
159 aMtrFldHorz1
.SetModifyHdl( aLink
);
160 aMtrFldVert1
.SetModifyHdl( aLink
);
161 aMtrFldHorz2
.SetModifyHdl( aLink
);
162 aMtrFldVert2
.SetModifyHdl( aLink
);
163 aMtrFldLine1
.SetModifyHdl( aLink
);
164 aMtrFldLine2
.SetModifyHdl( aLink
);
165 aMtrFldLine3
.SetModifyHdl( aLink
);
166 aLbType
.SetSelectHdl( aLink
);
169 /*************************************************************************
173 \************************************************************************/
175 SvxConnectionPage::~SvxConnectionPage()
179 /*************************************************************************
181 |* Liest uebergebenen Item-Set
183 \************************************************************************/
185 void __EXPORT
SvxConnectionPage::Reset( const SfxItemSet
& rAttrs
)
187 const SfxPoolItem
* pItem
= GetItem( rAttrs
, SDRATTR_EDGENODE1HORZDIST
);
188 const SfxItemPool
* pPool
= rAttrs
.GetPool();
190 // SdrEdgeNode1HorzDistItem
192 pItem
= &pPool
->GetDefaultItem( SDRATTR_EDGENODE1HORZDIST
);
195 long nValue
= ( ( const SdrEdgeNode1HorzDistItem
* )pItem
)->GetValue();
196 SetMetricValue( aMtrFldHorz1
, nValue
, eUnit
);
199 aMtrFldHorz1
.SetEmptyFieldValue();
201 aMtrFldHorz1
.SaveValue();
203 // SdrEdgeNode2HorzDistItem
204 pItem
= GetItem( rAttrs
, SDRATTR_EDGENODE2HORZDIST
);
206 pItem
= &pPool
->GetDefaultItem( SDRATTR_EDGENODE2HORZDIST
);
209 long nValue
= ( ( const SdrEdgeNode2HorzDistItem
* )pItem
)->GetValue();
210 SetMetricValue( aMtrFldHorz2
, nValue
, eUnit
);
213 aMtrFldHorz2
.SetEmptyFieldValue();
215 aMtrFldHorz2
.SaveValue();
217 // SdrEdgeNode1VertDistItem
218 pItem
= GetItem( rAttrs
, SDRATTR_EDGENODE1VERTDIST
);
220 pItem
= &pPool
->GetDefaultItem( SDRATTR_EDGENODE1VERTDIST
);
223 long nValue
= ( ( const SdrEdgeNode1VertDistItem
* )pItem
)->GetValue();
224 SetMetricValue( aMtrFldVert1
, nValue
, eUnit
);
227 aMtrFldVert1
.SetEmptyFieldValue();
229 aMtrFldVert1
.SaveValue();
231 // SdrEdgeNode2VertDistItem
232 pItem
= GetItem( rAttrs
, SDRATTR_EDGENODE2VERTDIST
);
234 pItem
= &pPool
->GetDefaultItem( SDRATTR_EDGENODE2VERTDIST
);
237 long nValue
= ( ( const SdrEdgeNode2VertDistItem
* )pItem
)->GetValue();
238 SetMetricValue( aMtrFldVert2
, nValue
, eUnit
);
241 aMtrFldVert2
.SetEmptyFieldValue();
243 aMtrFldVert2
.SaveValue();
245 // SdrEdgeLine1DeltaItem
246 pItem
= GetItem( rAttrs
, SDRATTR_EDGELINE1DELTA
);
248 pItem
= &pPool
->GetDefaultItem( SDRATTR_EDGELINE1DELTA
);
251 long nValue
= ( ( const SdrEdgeLine1DeltaItem
* )pItem
)->GetValue();
252 SetMetricValue( aMtrFldLine1
, nValue
, eUnit
);
255 aMtrFldLine1
.SetEmptyFieldValue();
257 aMtrFldLine1
.SaveValue();
259 // SdrEdgeLine2DeltaItem
260 pItem
= GetItem( rAttrs
, SDRATTR_EDGELINE2DELTA
);
262 pItem
= &pPool
->GetDefaultItem( SDRATTR_EDGELINE2DELTA
);
265 long nValue
= ( ( const SdrEdgeLine2DeltaItem
* )pItem
)->GetValue();
266 SetMetricValue( aMtrFldLine2
, nValue
, eUnit
);
269 aMtrFldLine2
.SetEmptyFieldValue();
271 aMtrFldLine2
.SaveValue();
273 // SdrEdgeLine3DeltaItem
274 pItem
= GetItem( rAttrs
, SDRATTR_EDGELINE3DELTA
);
276 pItem
= &pPool
->GetDefaultItem( SDRATTR_EDGELINE3DELTA
);
279 long nValue
= ( ( const SdrEdgeLine3DeltaItem
* )pItem
)->GetValue();
280 SetMetricValue( aMtrFldLine3
, nValue
, eUnit
);
283 aMtrFldLine3
.SetEmptyFieldValue();
285 aMtrFldLine3
.SaveValue();
287 // SdrEdgeLineDeltaAnzItem
288 pItem
= GetItem( rAttrs
, SDRATTR_EDGELINEDELTAANZ
);
290 pItem
= &pPool
->GetDefaultItem( SDRATTR_EDGELINEDELTAANZ
);
293 sal_uInt16 nValue
= ( ( const SdrEdgeLineDeltaAnzItem
* )pItem
)->GetValue();
296 aFtLine3
.Enable( sal_False
);
297 aMtrFldLine3
.Enable( sal_False
);
298 aMtrFldLine3
.SetEmptyFieldValue();
302 aFtLine2
.Enable( sal_False
);
303 aMtrFldLine2
.Enable( sal_False
);
304 aMtrFldLine2
.SetEmptyFieldValue();
308 aFtLine1
.Enable( sal_False
);
309 aMtrFldLine1
.Enable( sal_False
);
310 aMtrFldLine1
.SetEmptyFieldValue();
315 pItem
= GetItem( rAttrs
, SDRATTR_EDGEKIND
);
317 pItem
= &pPool
->GetDefaultItem( SDRATTR_EDGEKIND
);
320 SdrEdgeKind nValue
= ( ( const SdrEdgeKindItem
* )pItem
)->GetValue();
321 aLbType
.SelectEntryPos( sal::static_int_cast
< sal_uInt16
>(nValue
) );
324 aLbType
.SetNoSelection();
328 /*************************************************************************
330 |* Fuellt uebergebenen Item-Set mit Dialogbox-Attributen
332 \************************************************************************/
334 sal_Bool
SvxConnectionPage::FillItemSet( SfxItemSet
& rAttrs
)
336 sal_Bool bModified
= sal_False
;
339 if( aMtrFldHorz1
.GetText() != aMtrFldHorz1
.GetSavedValue() )
341 nValue
= GetCoreValue( aMtrFldHorz1
, eUnit
);
342 rAttrs
.Put( SdrEdgeNode1HorzDistItem( nValue
) );
343 bModified
= sal_True
;
346 if( aMtrFldHorz2
.GetText() != aMtrFldHorz2
.GetSavedValue() )
348 nValue
= GetCoreValue( aMtrFldHorz2
, eUnit
);
349 rAttrs
.Put( SdrEdgeNode2HorzDistItem( nValue
) );
350 bModified
= sal_True
;
353 if( aMtrFldVert1
.GetText() != aMtrFldVert1
.GetSavedValue() )
355 nValue
= GetCoreValue( aMtrFldVert1
, eUnit
);
356 rAttrs
.Put( SdrEdgeNode1VertDistItem( nValue
) );
357 bModified
= sal_True
;
360 if( aMtrFldVert2
.GetText() != aMtrFldVert2
.GetSavedValue() )
362 nValue
= GetCoreValue( aMtrFldVert2
, eUnit
);
363 rAttrs
.Put( SdrEdgeNode2VertDistItem( nValue
) );
364 bModified
= sal_True
;
367 if( aMtrFldLine1
.GetText() != aMtrFldLine1
.GetSavedValue() )
369 nValue
= GetCoreValue( aMtrFldLine1
, eUnit
);
370 rAttrs
.Put( SdrEdgeLine1DeltaItem( nValue
) );
371 bModified
= sal_True
;
374 if( aMtrFldLine2
.GetText() != aMtrFldLine2
.GetSavedValue() )
376 nValue
= GetCoreValue( aMtrFldLine2
, eUnit
);
377 rAttrs
.Put( SdrEdgeLine2DeltaItem( nValue
) );
378 bModified
= sal_True
;
381 if( aMtrFldLine3
.GetText() != aMtrFldLine3
.GetSavedValue() )
383 nValue
= GetCoreValue( aMtrFldLine3
, eUnit
);
384 rAttrs
.Put( SdrEdgeLine3DeltaItem( nValue
) );
385 bModified
= sal_True
;
389 sal_uInt16 nPos
= aLbType
.GetSelectEntryPos();
390 if( nPos
!= aLbType
.GetSavedValue() )
392 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
394 rAttrs
.Put( SdrEdgeKindItem( (SdrEdgeKind
) nPos
) );
395 bModified
= sal_True
;
402 /*************************************************************************
406 \************************************************************************/
408 void SvxConnectionPage::Construct()
410 DBG_ASSERT( pView
, "Keine gueltige View Uebergeben!" );
412 aCtlPreview
.SetView( pView
);
413 aCtlPreview
.Construct();
416 /*************************************************************************
420 \************************************************************************/
422 SfxTabPage
* SvxConnectionPage::Create( Window
* pWindow
,
423 const SfxItemSet
& rAttrs
)
425 return( new SvxConnectionPage( pWindow
, rAttrs
) );
428 /*************************************************************************
432 \************************************************************************/
434 sal_uInt16
* SvxConnectionPage::GetRanges()
439 /*************************************************************************
443 \************************************************************************/
445 IMPL_LINK( SvxConnectionPage
, ChangeAttrHdl_Impl
, void *, p
)
447 if( p
== &aMtrFldHorz1
)
449 sal_Int32 nValue
= GetCoreValue( aMtrFldHorz1
, eUnit
);
450 aAttrSet
.Put( SdrEdgeNode1HorzDistItem( nValue
) );
453 if( p
== &aMtrFldHorz2
)
455 sal_Int32 nValue
= GetCoreValue( aMtrFldHorz2
, eUnit
);
456 aAttrSet
.Put( SdrEdgeNode2HorzDistItem( nValue
) );
459 if( p
== &aMtrFldVert1
)
461 sal_Int32 nValue
= GetCoreValue( aMtrFldVert1
, eUnit
);
462 aAttrSet
.Put( SdrEdgeNode1VertDistItem( nValue
) );
465 if( p
== &aMtrFldVert2
)
467 sal_Int32 nValue
= GetCoreValue( aMtrFldVert2
, eUnit
);
468 aAttrSet
.Put( SdrEdgeNode2VertDistItem( nValue
) );
471 if( p
== &aMtrFldLine1
)
473 sal_Int32 nValue
= GetCoreValue( aMtrFldLine1
, eUnit
);
474 aAttrSet
.Put( SdrEdgeLine1DeltaItem( nValue
) );
477 if( p
== &aMtrFldLine2
)
479 sal_Int32 nValue
= GetCoreValue( aMtrFldLine2
, eUnit
);
480 aAttrSet
.Put( SdrEdgeLine2DeltaItem( nValue
) );
483 if( p
== &aMtrFldLine3
)
485 sal_Int32 nValue
= GetCoreValue( aMtrFldLine3
, eUnit
);
486 aAttrSet
.Put( SdrEdgeLine3DeltaItem( nValue
) );
492 sal_uInt16 nPos
= aLbType
.GetSelectEntryPos();
493 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
495 aAttrSet
.Put( SdrEdgeKindItem( (SdrEdgeKind
) nPos
) );
499 aCtlPreview
.SetAttributes( aAttrSet
);
503 // Anzahl der Linienversaetze ermitteln
504 sal_uInt16 nCount
= aCtlPreview
.GetLineDeltaAnz();
506 aFtLine3
.Enable( nCount
> 2 );
507 aMtrFldLine3
.Enable( nCount
> 2 );
509 aMtrFldLine3
.SetValue( aMtrFldLine3
.GetValue() );
511 aMtrFldLine3
.SetEmptyFieldValue();
513 aFtLine2
.Enable( nCount
> 1 );
514 aMtrFldLine2
.Enable( nCount
> 1 );
516 aMtrFldLine2
.SetValue( aMtrFldLine2
.GetValue() );
518 aMtrFldLine2
.SetEmptyFieldValue();
520 aFtLine1
.Enable( nCount
> 0 );
521 aMtrFldLine1
.Enable( nCount
> 0 );
523 aMtrFldLine1
.SetValue( aMtrFldLine1
.GetValue() );
525 aMtrFldLine1
.SetEmptyFieldValue();
532 /*************************************************************************
536 \************************************************************************/
538 void SvxConnectionPage::FillTypeLB()
540 // ListBox mit Verbindernamen fuellen
541 const SfxPoolItem
* pItem
= GetItem( rOutAttrs
, SDRATTR_EDGEKIND
);
542 const SfxItemPool
* pPool
= rOutAttrs
.GetPool();
545 pItem
= &pPool
->GetDefaultItem( SDRATTR_EDGEKIND
);
548 const SdrEdgeKindItem
* pEdgeKindItem
= (const SdrEdgeKindItem
*) pItem
;
549 sal_uInt16 nCount
= pEdgeKindItem
->GetValueCount();
552 for( sal_uInt16 i
= 0; i
< nCount
; i
++ )
554 aStr
= pEdgeKindItem
->GetValueTextByPos( i
);
555 aLbType
.InsertEntry( aStr
);
559 void SvxConnectionPage::PageCreated (SfxAllItemSet aSet
) //add CHINA001
561 SFX_ITEMSET_ARG(&aSet
,pOfaPtrItem
,OfaPtrItem
,SID_OBJECT_LIST
,sal_False
);
563 SetView( static_cast<SdrView
*>(pOfaPtrItem
->GetValue()) );