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 <tools/shl.hxx>
29 #include <tools/urlobj.hxx>
30 #include <vcl/msgbox.hxx>
31 #include <unotools/pathoptions.hxx>
32 #include <sfx2/app.hxx>
33 #include <sfx2/module.hxx>
34 #include <sfx2/filedlghelper.hxx>
35 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
36
37 #define _SVX_TPLNEDEF_CXX
38
39 #include <cuires.hrc>
40 #include "tabline.hrc"
41 //#include "dlgname.hrc"
42 #include "helpid.hrc"
43
44 #include "svx/xattr.hxx"
45 #include <svx/xpool.hxx>
46 #include <svx/xtable.hxx>
47
48 #include "svx/drawitem.hxx"
49 #include "cuitabline.hxx"
50 #include "defdlgname.hxx" //CHINA001 #include "dlgname.hxx"
51 #include <svx/svxdlg.hxx> //CHINA001
52 #include <dialmgr.hxx>
53 #include "svx/dlgutil.hxx"
54 #include <svx/dialmgr.hxx>
55 #include <svx/dialogs.hrc>
56
57 #define DLGWIN this->GetParent()->GetParent()
58
59 #define BITMAP_WIDTH 32
60 #define BITMAP_HEIGHT 12
61 #define XOUT_WIDTH 150
62
63 /*************************************************************************
64 |*
65 |* Dialog zum Definieren von Linienstilen
66 |*
67 \************************************************************************/
68
SvxLineDefTabPage(Window * pParent,const SfxItemSet & rInAttrs)69 SvxLineDefTabPage::SvxLineDefTabPage
70 (
71 Window* pParent,
72 const SfxItemSet& rInAttrs
73 ) :
74
75 SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_LINE_DEF ), rInAttrs ),
76
77 aFlDefinition ( this, CUI_RES( FL_DEFINITION ) ),
78 aFTLinestyle ( this, CUI_RES( FT_LINESTYLE ) ),
79 aLbLineStyles ( this, CUI_RES( LB_LINESTYLES ) ),
80 aFtType ( this, CUI_RES( FT_TYPE ) ),
81 aLbType1 ( this, CUI_RES( LB_TYPE_1 ) ),
82 aLbType2 ( this, CUI_RES( LB_TYPE_2 ) ),
83 aFtNumber ( this, CUI_RES( FT_NUMBER ) ),
84 aNumFldNumber1 ( this, CUI_RES( NUM_FLD_1 ) ),
85 aNumFldNumber2 ( this, CUI_RES( NUM_FLD_2 ) ),
86 aFtLength ( this, CUI_RES( FT_LENGTH ) ),
87 aMtrLength1 ( this, CUI_RES( MTR_FLD_LENGTH_1 ) ),
88 aMtrLength2 ( this, CUI_RES( MTR_FLD_LENGTH_2 ) ),
89 aFtDistance ( this, CUI_RES( FT_DISTANCE ) ),
90 aMtrDistance ( this, CUI_RES( MTR_FLD_DISTANCE ) ),
91 aCbxSynchronize ( this, CUI_RES( CBX_SYNCHRONIZE ) ),
92 aBtnAdd ( this, CUI_RES( BTN_ADD ) ),
93 aBtnModify ( this, CUI_RES( BTN_MODIFY ) ),
94 aBtnDelete ( this, CUI_RES( BTN_DELETE ) ),
95 aBtnLoad ( this, CUI_RES( BTN_LOAD ) ),
96 aBtnSave ( this, CUI_RES( BTN_SAVE ) ),
97 aCtlPreview ( this, CUI_RES( CTL_PREVIEW ) ),
98
99 rOutAttrs ( rInAttrs ),
100
101 pXPool ( (XOutdevItemPool*) rInAttrs.GetPool() ),
102 aXLStyle ( XLINE_DASH ),
103 aXWidth ( XOUT_WIDTH ),
104 aXDash ( String(), XDash( XDASH_RECT, 3, 7, 2, 40, 15 ) ),
105 aXColor ( String(), COL_BLACK ),
106 aXLineAttr ( pXPool ),
107 rXLSet ( aXLineAttr.GetItemSet() )
108 {
109 aBtnLoad.SetModeImage( Image( CUI_RES( RID_SVXIMG_LOAD_H ) ), BMP_COLOR_HIGHCONTRAST );
110 aBtnSave.SetModeImage( Image( CUI_RES( RID_SVXIMG_SAVE_H ) ), BMP_COLOR_HIGHCONTRAST );
111
112 aLbType1.SetAccessibleName(String(CUI_RES( STR_START_TYPE ) ) );
113 aLbType2.SetAccessibleName(String(CUI_RES( STR_END_TYPE ) ) );
114 aNumFldNumber1.SetAccessibleName(String(CUI_RES( STR_START_NUM ) ) );
115 aNumFldNumber2.SetAccessibleName(String(CUI_RES( STR_END_NUM ) ) );
116 aMtrLength1.SetAccessibleName(String(CUI_RES( STR_START_LENGTH ) ) );
117 aMtrLength2.SetAccessibleName(String(CUI_RES( STR_END_LENGTH ) ) );
118
119 FreeResource();
120
121 // diese Page braucht ExchangeSupport
122 SetExchangeSupport();
123
124 // Metrik einstellen
125 eFUnit = GetModuleFieldUnit( rInAttrs );
126
127 switch ( eFUnit )
128 {
129 case FUNIT_M:
130 case FUNIT_KM:
131 eFUnit = FUNIT_MM;
132 break;
133 default: ; //prevent warning
134 }
135 SetFieldUnit( aMtrDistance, eFUnit );
136 SetFieldUnit( aMtrLength1, eFUnit );
137 SetFieldUnit( aMtrLength2, eFUnit );
138
139 // PoolUnit ermitteln
140 SfxItemPool* pPool = rOutAttrs.GetPool();
141 DBG_ASSERT( pPool, "Wo ist der Pool?" );
142 ePoolUnit = pPool->GetMetric( SID_ATTR_LINE_WIDTH );
143
144 rXLSet.Put( aXLStyle );
145 rXLSet.Put( aXWidth );
146 rXLSet.Put( aXDash );
147 rXLSet.Put( aXColor );
148
149 // #i34740#
150 aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet());
151
152 aBtnAdd.SetClickHdl( LINK( this, SvxLineDefTabPage, ClickAddHdl_Impl ) );
153 aBtnModify.SetClickHdl(
154 LINK( this, SvxLineDefTabPage, ClickModifyHdl_Impl ) );
155 aBtnDelete.SetClickHdl(
156 LINK( this, SvxLineDefTabPage, ClickDeleteHdl_Impl ) );
157 aBtnLoad.SetClickHdl( LINK( this, SvxLineDefTabPage, ClickLoadHdl_Impl ) );
158 aBtnSave.SetClickHdl( LINK( this, SvxLineDefTabPage, ClickSaveHdl_Impl ) );
159
160 aNumFldNumber1.SetModifyHdl(
161 LINK( this, SvxLineDefTabPage, ChangeNumber1Hdl_Impl ) );
162 aNumFldNumber2.SetModifyHdl(
163 LINK( this, SvxLineDefTabPage, ChangeNumber2Hdl_Impl ) );
164 aLbLineStyles.SetSelectHdl(
165 LINK( this, SvxLineDefTabPage, SelectLinestyleHdl_Impl ) );
166
167 // #122042# switch off default adding of 'none' and 'solid' entries
168 // for this ListBox; we want to select only editable/dashed styles
169 aLbLineStyles.setAddStandardFields(false);
170
171 // Absolut (in mm) oder Relativ (in %)
172 aCbxSynchronize.SetClickHdl(
173 LINK( this, SvxLineDefTabPage, ChangeMetricHdl_Impl ) );
174
175 // Wenn sich etwas aendert, muss Preview upgedatet werden werden
176 Link aLink = LINK( this, SvxLineDefTabPage, SelectTypeHdl_Impl );
177 aLbType1.SetSelectHdl( aLink );
178 aLbType2.SetSelectHdl( aLink );
179 aLink = LINK( this, SvxLineDefTabPage, ChangePreviewHdl_Impl );
180 aMtrLength1.SetModifyHdl( aLink );
181 aMtrLength2.SetModifyHdl( aLink );
182 aMtrDistance.SetModifyHdl( aLink );
183
184 aBtnAdd.SetAccessibleRelationMemberOf( &aFlDefinition );
185 aBtnModify.SetAccessibleRelationMemberOf( &aFlDefinition );
186 aBtnDelete.SetAccessibleRelationMemberOf( &aFlDefinition );
187 aBtnLoad.SetAccessibleRelationMemberOf( &aFlDefinition );
188 aBtnSave.SetAccessibleRelationMemberOf( &aFlDefinition );
189 }
190
191
192 // -----------------------------------------------------------------------
193
Construct()194 void SvxLineDefTabPage::Construct()
195 {
196 // Line style fill; do *not* add default fields here
197 aLbLineStyles.Fill( maDashList );
198 }
199
200 // -----------------------------------------------------------------------
201
ActivatePage(const SfxItemSet &)202 void SvxLineDefTabPage::ActivatePage( const SfxItemSet& )
203 {
204 if( *pDlgType == 0 ) // Flaechen-Dialog
205 {
206 // ActivatePage() wird aufgerufen bevor der Dialog PageCreated() erhaelt !!!
207 if( maDashList.get() )
208 {
209 if( *pPageType == 1 &&
210 *pPosDashLb != LISTBOX_ENTRY_NOTFOUND )
211 {
212 aLbLineStyles.SelectEntryPos( *pPosDashLb );
213 }
214 // Damit evtl. vorhandener Linestyle verworfen wird
215 SelectLinestyleHdl_Impl( this );
216
217 // Ermitteln (evtl. abschneiden) des Namens und in
218 // der GroupBox darstellen
219 String aString( CUI_RES( RID_SVXSTR_TABLE ) ); aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
220 INetURLObject aURL( maDashList->GetPath() );
221
222 aURL.Append( maDashList->GetName() );
223 DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
224
225 /* if ( aURL.getBase().Len() > 18 )
226 {
227 aString += aURL.getBase().Copy( 0, 15 );
228 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
229 }
230 else
231 aString += aURL.getBase();
232
233 aFTLinestyle.SetText( aString );
234 */
235 *pPageType = 0; // 2
236 *pPosDashLb = LISTBOX_ENTRY_NOTFOUND;
237 }
238 }
239 }
240
241 // -----------------------------------------------------------------------
242
DeactivatePage(SfxItemSet * _pSet)243 int SvxLineDefTabPage::DeactivatePage( SfxItemSet* _pSet )
244 {
245 CheckChanges_Impl();
246
247 if( _pSet )
248 FillItemSet( *_pSet );
249
250 return( LEAVE_PAGE );
251 }
252
253 // -----------------------------------------------------------------------
254
CheckChanges_Impl()255 void SvxLineDefTabPage::CheckChanges_Impl()
256 {
257 // wird hier benutzt, um Aenderungen NICHT zu verlieren
258 //XDashStyle eXDS;
259
260 if( aNumFldNumber1.GetText() != aNumFldNumber1.GetSavedValue() ||
261 aMtrLength1.GetText() != aMtrLength1.GetSavedValue() ||
262 aLbType1.GetSelectEntryPos() != aLbType1.GetSavedValue() ||
263 aNumFldNumber2.GetText() != aNumFldNumber2.GetSavedValue() ||
264 aMtrLength2.GetText() != aMtrLength2.GetSavedValue() ||
265 aLbType2.GetSelectEntryPos() != aLbType2.GetSavedValue() ||
266 aMtrDistance.GetText() != aMtrDistance.GetSavedValue() )
267 {
268 ResMgr& rMgr = CUI_MGR();
269 Image aWarningBoxImage = WarningBox::GetStandardImage();
270 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
271 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
272 AbstractSvxMessDialog* aMessDlg = pFact->CreateSvxMessDialog( DLGWIN, RID_SVXDLG_MESSBOX,
273 SVX_RESSTR( RID_SVXSTR_LINESTYLE ),
274 String( ResId( RID_SVXSTR_ASK_CHANGE_LINESTYLE, rMgr ) ),
275 &aWarningBoxImage );
276 DBG_ASSERT(aMessDlg, "Dialogdiet fail!");//CHINA001
277 aMessDlg->SetButtonText( MESS_BTN_1, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_1,
278 String( ResId( RID_SVXSTR_CHANGE, rMgr ) ) );
279 aMessDlg->SetButtonText( MESS_BTN_2, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_2,
280 String( ResId( RID_SVXSTR_ADD, rMgr ) ) );
281
282 short nRet = aMessDlg->Execute(); //CHINA001 short nRet = aMessDlg.Execute();
283
284 switch( nRet )
285 {
286 case RET_BTN_1: // Aendern
287 {
288 ClickModifyHdl_Impl( this );
289 //aXDash = maDashList->Get( nPos )->GetDash();
290 }
291 break;
292
293 case RET_BTN_2: // Hinzufuegen
294 {
295 ClickAddHdl_Impl( this );
296 //nPos = aLbLineStyles.GetSelectEntryPos();
297 //aXDash = maDashList->Get( nPos )->GetDash();
298 }
299 break;
300
301 case RET_CANCEL:
302 break;
303 // return( sal_True ); // Abbruch
304 }
305 delete aMessDlg; //add by CHINA001
306 }
307
308
309
310 sal_uInt16 nPos = aLbLineStyles.GetSelectEntryPos();
311 if( nPos != LISTBOX_ENTRY_NOTFOUND )
312 {
313 *pPosDashLb = nPos;
314 }
315 }
316
317 // -----------------------------------------------------------------------
318
FillItemSet(SfxItemSet & rAttrs)319 sal_Bool SvxLineDefTabPage::FillItemSet( SfxItemSet& rAttrs )
320 {
321 if( *pDlgType == 0 ) // Linien-Dialog
322 {
323 if( *pPageType == 2 )
324 {
325 //CheckChanges_Impl();
326
327 FillDash_Impl();
328
329 String aString( aLbLineStyles.GetSelectEntry() );
330 rAttrs.Put( XLineStyleItem( XLINE_DASH ) );
331 rAttrs.Put( XLineDashItem( aString, aDash ) );
332 }
333 }
334 return( sal_True );
335 }
336
337 // -----------------------------------------------------------------------
338
Reset(const SfxItemSet & rAttrs)339 void SvxLineDefTabPage::Reset( const SfxItemSet& rAttrs )
340 {
341 if( rAttrs.GetItemState( GetWhich( XATTR_LINESTYLE ) ) != SFX_ITEM_DONTCARE )
342 {
343 XLineStyle eXLS = (XLineStyle) ( ( const XLineStyleItem& ) rAttrs.Get( GetWhich( XATTR_LINESTYLE ) ) ).GetValue();
344
345 switch( eXLS )
346 {
347 case XLINE_NONE:
348 case XLINE_SOLID:
349 aLbLineStyles.SelectEntryPos( 0 );
350 break;
351
352 case XLINE_DASH:
353 {
354 const XLineDashItem& rDashItem = ( const XLineDashItem& ) rAttrs.Get( XATTR_LINEDASH );
355 aDash = rDashItem.GetDashValue();
356
357 aLbLineStyles.SetNoSelection();
358 aLbLineStyles.SelectEntry( rDashItem.GetName() );
359 }
360 break;
361
362 default:
363 break;
364 }
365 }
366 SelectLinestyleHdl_Impl( NULL );
367
368 // Status der Buttons ermitteln
369 if( maDashList.get() && maDashList->Count() )
370 {
371 aBtnModify.Enable();
372 aBtnDelete.Enable();
373 aBtnSave.Enable();
374 }
375 else
376 {
377 aBtnModify.Disable();
378 aBtnDelete.Disable();
379 aBtnSave.Disable();
380 }
381 }
382
383 // -----------------------------------------------------------------------
384
Create(Window * pWindow,const SfxItemSet & rOutAttrs)385 SfxTabPage* SvxLineDefTabPage::Create( Window* pWindow,
386 const SfxItemSet& rOutAttrs )
387 {
388 return( new SvxLineDefTabPage( pWindow, rOutAttrs ) );
389 }
390
391 //------------------------------------------------------------------------
392
IMPL_LINK(SvxLineDefTabPage,SelectLinestyleHdl_Impl,void *,p)393 IMPL_LINK( SvxLineDefTabPage, SelectLinestyleHdl_Impl, void *, p )
394 {
395 if(maDashList.get() && maDashList->Count())
396 {
397 int nTmp = aLbLineStyles.GetSelectEntryPos();
398
399 if(LISTBOX_ENTRY_NOTFOUND == nTmp)
400 {
401 OSL_ENSURE(false, "OOps, non-existent LineDash selected (!)");
402 nTmp = 1;
403 }
404
405 aDash = maDashList->GetDash( nTmp )->GetDash();
406
407 FillDialog_Impl();
408
409 rXLSet.Put( XLineDashItem( String(), aDash ) );
410
411 // #i34740#
412 aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet());
413
414 aCtlPreview.Invalidate();
415
416 // Wird erst hier gesetzt, um den Style nur dann zu uebernehmen,
417 // wenn in der ListBox ein Eintrag ausgewaehlt wurde
418 // Wenn ueber Reset() gerufen wurde ist p == NULL
419 if( p )
420 *pPageType = 2;
421 }
422 return( 0L );
423 }
424
425 //------------------------------------------------------------------------
426
IMPL_LINK_INLINE_START(SvxLineDefTabPage,ChangePreviewHdl_Impl,void *,EMPTYARG)427 IMPL_LINK_INLINE_START( SvxLineDefTabPage, ChangePreviewHdl_Impl, void *, EMPTYARG )
428 {
429 FillDash_Impl();
430 aCtlPreview.Invalidate();
431
432 return( 0L );
433 }
IMPL_LINK_INLINE_END(SvxLineDefTabPage,ChangePreviewHdl_Impl,void *,EMPTYARG)434 IMPL_LINK_INLINE_END( SvxLineDefTabPage, ChangePreviewHdl_Impl, void *, EMPTYARG )
435
436 //------------------------------------------------------------------------
437
438 IMPL_LINK( SvxLineDefTabPage, ChangeNumber1Hdl_Impl, void *, EMPTYARG )
439 {
440 if( aNumFldNumber1.GetValue() == 0L )
441 {
442 aNumFldNumber2.SetMin( 1L );
443 aNumFldNumber2.SetFirst( 1L );
444 }
445 else
446 {
447 aNumFldNumber2.SetMin( 0L );
448 aNumFldNumber2.SetFirst( 0L );
449 }
450
451 ChangePreviewHdl_Impl( this );
452
453 return( 0L );
454 }
455
456 //------------------------------------------------------------------------
457
IMPL_LINK(SvxLineDefTabPage,ChangeNumber2Hdl_Impl,void *,EMPTYARG)458 IMPL_LINK( SvxLineDefTabPage, ChangeNumber2Hdl_Impl, void *, EMPTYARG )
459 {
460 if( aNumFldNumber2.GetValue() == 0L )
461 {
462 aNumFldNumber1.SetMin( 1L );
463 aNumFldNumber1.SetFirst( 1L );
464 }
465 else
466 {
467 aNumFldNumber1.SetMin( 0L );
468 aNumFldNumber1.SetFirst( 0L );
469 }
470
471 ChangePreviewHdl_Impl( this );
472
473 return( 0L );
474 }
475
476
477 //------------------------------------------------------------------------
478
IMPL_LINK(SvxLineDefTabPage,ChangeMetricHdl_Impl,void *,p)479 IMPL_LINK( SvxLineDefTabPage, ChangeMetricHdl_Impl, void *, p )
480 {
481 if( !aCbxSynchronize.IsChecked() && aMtrLength1.GetUnit() != eFUnit )
482 {
483 long nTmp1, nTmp2, nTmp3;
484
485 // Wurde ueber Control geaendert
486 if( p )
487 {
488 nTmp1 = GetCoreValue( aMtrLength1, ePoolUnit ) * XOUT_WIDTH / 100;
489 nTmp2 = GetCoreValue( aMtrLength2, ePoolUnit ) * XOUT_WIDTH / 100;
490 nTmp3 = GetCoreValue( aMtrDistance, ePoolUnit ) * XOUT_WIDTH / 100;
491 }
492 else
493 {
494 nTmp1 = GetCoreValue( aMtrLength1, ePoolUnit );
495 nTmp2 = GetCoreValue( aMtrLength2, ePoolUnit );
496 nTmp3 = GetCoreValue( aMtrDistance, ePoolUnit );
497 }
498 aMtrLength1.SetDecimalDigits( 2 );
499 aMtrLength2.SetDecimalDigits( 2 );
500 aMtrDistance.SetDecimalDigits( 2 );
501
502 // Metrik einstellen
503 aMtrLength1.SetUnit( eFUnit );
504 aMtrLength2.SetUnit( eFUnit );
505 aMtrDistance.SetUnit( eFUnit );
506
507 SetMetricValue( aMtrLength1, nTmp1, ePoolUnit );
508 SetMetricValue( aMtrLength2, nTmp2, ePoolUnit );
509 SetMetricValue( aMtrDistance, nTmp3, ePoolUnit );
510 }
511 else if( aCbxSynchronize.IsChecked() && aMtrLength1.GetUnit() != FUNIT_PERCENT )
512 {
513 long nTmp1, nTmp2, nTmp3;
514
515 // Wurde ueber Control geaendert
516 if( p )
517 {
518 nTmp1 = GetCoreValue( aMtrLength1, ePoolUnit ) * 100 / XOUT_WIDTH;
519 nTmp2 = GetCoreValue( aMtrLength2, ePoolUnit ) * 100 / XOUT_WIDTH;
520 nTmp3 = GetCoreValue( aMtrDistance, ePoolUnit ) * 100 / XOUT_WIDTH;
521 }
522 else
523 {
524 nTmp1 = GetCoreValue( aMtrLength1, ePoolUnit );
525 nTmp2 = GetCoreValue( aMtrLength2, ePoolUnit );
526 nTmp3 = GetCoreValue( aMtrDistance, ePoolUnit );
527 }
528
529 aMtrLength1.SetDecimalDigits( 0 );
530 aMtrLength2.SetDecimalDigits( 0 );
531 aMtrDistance.SetDecimalDigits( 0 );
532
533 aMtrLength1.SetUnit( FUNIT_PERCENT );
534 aMtrLength2.SetUnit( FUNIT_PERCENT );
535 aMtrDistance.SetUnit( FUNIT_PERCENT );
536
537
538 SetMetricValue( aMtrLength1, nTmp1, ePoolUnit );
539 SetMetricValue( aMtrLength2, nTmp2, ePoolUnit );
540 SetMetricValue( aMtrDistance, nTmp3, ePoolUnit );
541 }
542 SelectTypeHdl_Impl( NULL );
543
544 return( 0L );
545 }
546
547 //------------------------------------------------------------------------
548
IMPL_LINK(SvxLineDefTabPage,SelectTypeHdl_Impl,void *,p)549 IMPL_LINK( SvxLineDefTabPage, SelectTypeHdl_Impl, void *, p )
550 {
551 if ( p == &aLbType1 || !p )
552 {
553 if ( aLbType1.GetSelectEntryPos() == 0 )
554 {
555 aMtrLength1.Disable();
556 aMtrLength1.SetText( String() );
557 }
558 else if ( !aMtrLength1.IsEnabled() )
559 {
560 aMtrLength1.Enable();
561 aMtrLength1.Reformat();
562 }
563 }
564
565 if ( p == &aLbType2 || !p )
566 {
567 if ( aLbType2.GetSelectEntryPos() == 0 )
568 {
569 aMtrLength2.Disable();
570 aMtrLength2.SetText( String() );
571 }
572 else if ( !aMtrLength2.IsEnabled() )
573 {
574 aMtrLength2.Enable();
575 aMtrLength2.Reformat();
576 }
577 }
578 ChangePreviewHdl_Impl( p );
579 return( 0L );
580 }
581
582 //------------------------------------------------------------------------
583
IMPL_LINK(SvxLineDefTabPage,ClickAddHdl_Impl,void *,EMPTYARG)584 IMPL_LINK( SvxLineDefTabPage, ClickAddHdl_Impl, void *, EMPTYARG )
585 {
586 ResMgr& rMgr = CUI_MGR();
587 String aNewName( SVX_RES( RID_SVXSTR_LINESTYLE ) );
588 String aDesc( ResId( RID_SVXSTR_DESC_LINESTYLE, rMgr ) );
589 String aName;
590 XDashEntry* pEntry;
591
592 long nCount = maDashList.get() ? maDashList->Count() : 0;
593 long j = 1;
594 sal_Bool bDifferent = sal_False;
595
596 while ( !bDifferent )
597 {
598 aName = aNewName;
599 aName += sal_Unicode(' ');
600 aName += UniString::CreateFromInt32( j++ );
601 bDifferent = sal_True;
602
603 for ( long i = 0; i < nCount && bDifferent; i++ )
604 if ( aName == maDashList->GetDash( i )->GetName() )
605 bDifferent = sal_False;
606 }
607
608 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
609 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
610 AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc );
611 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
612 sal_Bool bLoop = sal_True;
613
614 while ( bLoop && pDlg->Execute() == RET_OK )
615 {
616 pDlg->GetName( aName );
617 bDifferent = sal_True;
618
619 for( long i = 0; i < nCount && bDifferent; i++ )
620 {
621 if( aName == maDashList->GetDash( i )->GetName() )
622 bDifferent = sal_False;
623 }
624
625 if( bDifferent )
626 {
627 bLoop = sal_False;
628 FillDash_Impl();
629
630 pEntry = new XDashEntry( aDash, aName );
631
632 long nDashCount = maDashList.get() ? maDashList->Count() : 0;
633 maDashList->Insert( pEntry, nDashCount );
634 aLbLineStyles.Append( *pEntry, maDashList->GetUiBitmap( nDashCount ) );
635
636 aLbLineStyles.SelectEntryPos( aLbLineStyles.GetEntryCount() - 1 );
637
638 // Flag fuer modifiziert setzen
639 *pnDashListState |= CT_MODIFIED;
640
641 *pPageType = 2;
642
643 // Werte sichern fuer Changes-Erkennung ( -> Methode )
644 aNumFldNumber1.SaveValue();
645 aMtrLength1.SaveValue();
646 aLbType1.SaveValue();
647 aNumFldNumber2.SaveValue();
648 aMtrLength2.SaveValue();
649 aLbType2.SaveValue();
650 aMtrDistance.SaveValue();
651 }
652 else
653 {
654 WarningBox aBox( DLGWIN, WinBits( WB_OK ),String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
655 aBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
656 aBox.Execute();
657 }
658 }
659 delete( pDlg );
660
661 // Status der Buttons ermitteln
662 if ( maDashList.get() && maDashList->Count() )
663 {
664 aBtnModify.Enable();
665 aBtnDelete.Enable();
666 aBtnSave.Enable();
667 }
668 return( 0L );
669 }
670
671 //------------------------------------------------------------------------
672
IMPL_LINK(SvxLineDefTabPage,ClickModifyHdl_Impl,void *,EMPTYARG)673 IMPL_LINK( SvxLineDefTabPage, ClickModifyHdl_Impl, void *, EMPTYARG )
674 {
675 sal_uInt16 nPos = aLbLineStyles.GetSelectEntryPos();
676
677 if( nPos != LISTBOX_ENTRY_NOTFOUND )
678 {
679 ResMgr& rMgr = CUI_MGR();
680 String aNewName( SVX_RES( RID_SVXSTR_LINESTYLE ) );
681 String aDesc( ResId( RID_SVXSTR_DESC_LINESTYLE, rMgr ) );
682 String aName( maDashList->GetDash( nPos )->GetName() );
683 String aOldName = aName;
684
685 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
686 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
687 AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc );
688 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
689
690 long nCount = maDashList.get() ? maDashList->Count() : 0;
691 sal_Bool bDifferent = sal_False;
692 sal_Bool bLoop = sal_True;
693
694 while ( bLoop && pDlg->Execute() == RET_OK )
695 {
696 pDlg->GetName( aName );
697 bDifferent = sal_True;
698
699 for( long i = 0; i < nCount && bDifferent; i++ )
700 {
701 if( aName == maDashList->GetDash( i )->GetName() &&
702 aName != aOldName )
703 bDifferent = sal_False;
704 }
705
706 if ( bDifferent )
707 {
708 bLoop = sal_False;
709 FillDash_Impl();
710
711 XDashEntry* pEntry = new XDashEntry( aDash, aName );
712
713 delete maDashList->Replace( pEntry, nPos );
714 aLbLineStyles.Modify( *pEntry, nPos, maDashList->GetUiBitmap( nPos ) );
715
716 aLbLineStyles.SelectEntryPos( nPos );
717
718 // Flag fuer modifiziert setzen
719 *pnDashListState |= CT_MODIFIED;
720
721 *pPageType = 2;
722
723 // Werte sichern fuer Changes-Erkennung ( -> Methode )
724 aNumFldNumber1.SaveValue();
725 aMtrLength1.SaveValue();
726 aLbType1.SaveValue();
727 aNumFldNumber2.SaveValue();
728 aMtrLength2.SaveValue();
729 aLbType2.SaveValue();
730 aMtrDistance.SaveValue();
731 }
732 else
733 {
734 WarningBox aBox( DLGWIN, WinBits( WB_OK ), String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
735 aBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
736 aBox.Execute();
737 }
738 }
739 delete( pDlg );
740 }
741 return( 0L );
742 }
743
744 //------------------------------------------------------------------------
745
IMPL_LINK(SvxLineDefTabPage,ClickDeleteHdl_Impl,void *,EMPTYARG)746 IMPL_LINK( SvxLineDefTabPage, ClickDeleteHdl_Impl, void *, EMPTYARG )
747 {
748 sal_uInt16 nPos = aLbLineStyles.GetSelectEntryPos();
749
750 if ( nPos != LISTBOX_ENTRY_NOTFOUND )
751 {
752 QueryBox aQueryBox( DLGWIN, WinBits( WB_YES_NO | WB_DEF_NO ),
753 String( CUI_RES( RID_SVXSTR_ASK_DEL_LINESTYLE ) ) );
754
755 if ( aQueryBox.Execute() == RET_YES )
756 {
757 delete maDashList->Remove( nPos );
758 aLbLineStyles.RemoveEntry( nPos );
759 aLbLineStyles.SelectEntryPos( 0 );
760
761 SelectLinestyleHdl_Impl( this );
762 *pPageType = 0; // Style soll nicht uebernommen werden
763
764 // Flag fuer modifiziert setzen
765 *pnDashListState |= CT_MODIFIED;
766
767 ChangePreviewHdl_Impl( this );
768 }
769 }
770
771 // Status der Buttons ermitteln
772 if ( !maDashList.get() || !maDashList->Count() )
773 {
774 aBtnModify.Disable();
775 aBtnDelete.Disable();
776 aBtnSave.Disable();
777 }
778 return( 0L );
779 }
780
781 // -----------------------------------------------------------------------
782
IMPL_LINK(SvxLineDefTabPage,ClickLoadHdl_Impl,void *,EMPTYARG)783 IMPL_LINK( SvxLineDefTabPage, ClickLoadHdl_Impl, void *, EMPTYARG )
784 {
785 ResMgr& rMgr = CUI_MGR();
786 sal_uInt16 nReturn = RET_YES;
787
788 if ( *pnDashListState & CT_MODIFIED )
789 {
790 nReturn = WarningBox( DLGWIN, WinBits( WB_YES_NO_CANCEL ),
791 String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute();
792
793 if ( nReturn == RET_YES )
794 maDashList->Save();
795 }
796
797 if ( nReturn != RET_CANCEL )
798 {
799 ::sfx2::FileDialogHelper aDlg(
800 com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
801 0 );
802 String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sod" ) );
803 aDlg.AddFilter( aStrFilterType, aStrFilterType );
804 INetURLObject aFile( SvtPathOptions().GetPalettePath() );
805 aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
806
807 if( aDlg.Execute() == ERRCODE_NONE )
808 {
809 INetURLObject aURL( aDlg.GetPath() );
810 INetURLObject aPathURL( aURL );
811
812 aPathURL.removeSegment();
813 aPathURL.removeFinalSlash();
814
815 // Liste speichern
816 XDashListSharedPtr aDshLst(XPropertyListFactory::CreateSharedXDashList(aPathURL.GetMainURL(INetURLObject::NO_DECODE)));
817 aDshLst->SetName( aURL.getName() );
818
819 if( aDshLst->Load() )
820 {
821 if( aDshLst.get() )
822 {
823 maDashList = aDshLst;
824 ( (SvxLineTabDialog*) DLGWIN )->SetNewDashList( maDashList );
825
826 aLbLineStyles.Clear();
827 aLbLineStyles.Fill( maDashList );
828 Reset( rOutAttrs );
829
830 maDashList->SetName( aURL.getName() );
831
832 /* // Ermitteln (evtl. abschneiden) des Namens und in
833 // der GroupBox darstellen
834 String aString( ResId( RID_SVXSTR_TABLE, rMgr ) );
835 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
836
837 if ( aURL.getBase().Len() > 18 )
838 {
839 aString += aURL.getBase().Copy( 0, 15 );
840 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
841 }
842 else
843 aString += aURL.getBase();
844
845 aGrpLinestyles.SetText( aString );
846 */
847 // Flag fuer gewechselt setzen
848 *pnDashListState |= CT_CHANGED;
849 // Flag fuer modifiziert entfernen
850 *pnDashListState &= ~CT_MODIFIED;
851 }
852 }
853 else
854 //aIStream.Close();
855 ErrorBox( DLGWIN, WinBits( WB_OK ),
856 String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute();
857 }
858 }
859
860 // Status der Buttons ermitteln
861 if ( maDashList.get() && maDashList->Count() )
862 {
863 aBtnModify.Enable();
864 aBtnDelete.Enable();
865 aBtnSave.Enable();
866 }
867 else
868 {
869 aBtnModify.Disable();
870 aBtnDelete.Disable();
871 aBtnSave.Disable();
872 }
873 return( 0L );
874 }
875
876 // -----------------------------------------------------------------------
877
IMPL_LINK(SvxLineDefTabPage,ClickSaveHdl_Impl,void *,EMPTYARG)878 IMPL_LINK( SvxLineDefTabPage, ClickSaveHdl_Impl, void *, EMPTYARG )
879 {
880 ::sfx2::FileDialogHelper aDlg(
881 com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
882 String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sod" ) );
883 aDlg.AddFilter( aStrFilterType, aStrFilterType );
884
885 INetURLObject aFile( SvtPathOptions().GetPalettePath() );
886 DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
887
888 if( maDashList->GetName().Len() )
889 {
890 aFile.Append( maDashList->GetName() );
891
892 if( !aFile.getExtension().getLength() )
893 aFile.SetExtension( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "sod" ) ) );
894 }
895
896 aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
897 if ( aDlg.Execute() == ERRCODE_NONE )
898 {
899 INetURLObject aURL( aDlg.GetPath() );
900 INetURLObject aPathURL( aURL );
901
902 aPathURL.removeSegment();
903 aPathURL.removeFinalSlash();
904
905 maDashList->SetName( aURL.getName() );
906 maDashList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
907
908 if( maDashList->Save() )
909 {
910 /* // Ermitteln (evtl. abschneiden) des Namens und in
911 // der GroupBox darstellen
912 String aString( CUI_RES( RID_SVXSTR_TABLE ) );
913 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
914
915 if ( aURL.getBase().Len() > 18 )
916 {
917 aString += aURL.getBase().Copy( 0, 15 );
918 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
919 }
920 else
921 aString += aURL.getBase();
922
923 aGrpLinestyles.SetText( aString );
924 */
925 // Flag fuer gespeichert setzen
926 *pnDashListState |= CT_SAVED;
927 // Flag fuer modifiziert entfernen
928 *pnDashListState &= ~CT_MODIFIED;
929 }
930 else
931 {
932 ErrorBox( DLGWIN, WinBits( WB_OK ),
933 String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) ).Execute();
934 }
935 }
936
937 return( 0L );
938 }
939
940 //------------------------------------------------------------------------
941
FillDash_Impl()942 void SvxLineDefTabPage::FillDash_Impl()
943 {
944 XDashStyle eXDS;
945
946 /* Alle Stile werden z.Z. nicht benutzt
947 if( aRbtEnds1.IsChecked() )
948 eXDS = XDASH_ROUND;
949 else if( aRbtEnds2.IsChecked() )
950 eXDS = XDASH_RECT;
951 else
952 eXDS = XDASH_RECT;
953 */
954 if( aCbxSynchronize.IsChecked() )
955 eXDS = XDASH_RECTRELATIVE;
956 else
957 eXDS = XDASH_RECT;
958
959 aDash.SetDashStyle( eXDS );
960 aDash.SetDots( (sal_uInt8) aNumFldNumber1.GetValue() );
961 aDash.SetDotLen( aLbType1.GetSelectEntryPos() == 0 ? 0 :
962 GetCoreValue( aMtrLength1, ePoolUnit ) );
963 aDash.SetDashes( (sal_uInt8) aNumFldNumber2.GetValue() );
964 aDash.SetDashLen( aLbType2.GetSelectEntryPos() == 0 ? 0 :
965 GetCoreValue( aMtrLength2, ePoolUnit ) );
966 aDash.SetDistance( GetCoreValue( aMtrDistance, ePoolUnit ) );
967
968 rXLSet.Put( XLineDashItem( String(), aDash ) );
969
970 // #i34740#
971 aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet());
972 }
973
974 //------------------------------------------------------------------------
975
FillDialog_Impl()976 void SvxLineDefTabPage::FillDialog_Impl()
977 {
978 XDashStyle eXDS = aDash.GetDashStyle(); // XDASH_RECT, XDASH_ROUND
979 if( eXDS == XDASH_RECTRELATIVE )
980 aCbxSynchronize.Check();
981 else
982 aCbxSynchronize.Check( sal_False );
983
984 aNumFldNumber1.SetValue( aDash.GetDots() );
985 //aMtrLength1.SetValue( aDash.GetDotLen() );
986 SetMetricValue( aMtrLength1, aDash.GetDotLen(), ePoolUnit );
987 aLbType1.SelectEntryPos( aDash.GetDotLen() == 0 ? 0 : 1 );
988 aNumFldNumber2.SetValue( aDash.GetDashes() );
989 //aMtrLength2.SetValue( aDash.GetDashLen() );
990 SetMetricValue( aMtrLength2, aDash.GetDashLen(), ePoolUnit );
991 aLbType2.SelectEntryPos( aDash.GetDashLen() == 0 ? 0 : 1 );
992 //aMtrDistance.SetValue( aDash.GetDistance() );
993 SetMetricValue( aMtrDistance, aDash.GetDistance(), ePoolUnit );
994
995 ChangeMetricHdl_Impl( NULL );
996
997 // Werte sichern fuer Changes-Erkennung ( -> Methode )
998 aNumFldNumber1.SaveValue();
999 aMtrLength1.SaveValue();
1000 aLbType1.SaveValue();
1001 aNumFldNumber2.SaveValue();
1002 aMtrLength2.SaveValue();
1003 aLbType2.SaveValue();
1004 aMtrDistance.SaveValue();
1005 }
1006
1007
DataChanged(const DataChangedEvent & rDCEvt)1008 void SvxLineDefTabPage::DataChanged( const DataChangedEvent& rDCEvt )
1009 {
1010 SfxTabPage::DataChanged( rDCEvt );
1011
1012 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1013 {
1014 sal_uInt16 nOldSelect = aLbLineStyles.GetSelectEntryPos();
1015 aLbLineStyles.Clear();
1016 aLbLineStyles.Fill( maDashList );
1017 aLbLineStyles.SelectEntryPos( nOldSelect );
1018 }
1019 }
1020
1021