merge the formfield patch from ooo-build
[ooovba.git] / svx / source / cui / tpcolor.cxx
bloba373c985f3338fbcc51bf105030d09605f882be4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tpcolor.cxx,v $
10 * $Revision: 1.33 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
36 #endif
38 // include ---------------------------------------------------------------
39 #include <tools/shl.hxx>
40 #include <tools/urlobj.hxx>
41 #include <svtools/pathoptions.hxx>
42 #include <sfx2/app.hxx>
43 #include <sfx2/module.hxx>
44 #include <svtools/colrdlg.hxx>
45 #include <vcl/msgbox.hxx>
46 #include <sfx2/filedlghelper.hxx>
47 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
49 #define _SVX_TPCOLOR_CXX
52 #include <svx/dialogs.hrc>
53 #include "helpid.hrc"
55 #include "xattr.hxx"
56 #include <svx/xpool.hxx>
57 #include <svx/xtable.hxx>
58 #include "drawitem.hxx"
59 #include "cuitabarea.hxx"
60 #include "tabarea.hrc"
61 #include "defdlgname.hxx" //CHINA001 #include "dlgname.hxx"
62 #include "dlgname.hrc"
63 #include <svx/svxdlg.hxx> //CHINA001
64 #include <svx/dialmgr.hxx>
65 #include <cuitabline.hxx>
67 #define DLGWIN GetParentDialog( this )
69 /*************************************************************************
71 |* Dialog zum Aendern und Definieren der Farben
73 \************************************************************************/
75 static Window* GetParentDialog( Window* pWindow )
77 while( pWindow )
79 if( pWindow->IsDialog() )
80 break;
82 pWindow = pWindow->GetParent();
85 return pWindow;
88 SvxColorTabPage::SvxColorTabPage
90 Window* pParent,
91 const SfxItemSet& rInAttrs
92 ) :
94 SfxTabPage ( pParent, SVX_RES( RID_SVXPAGE_COLOR ), rInAttrs ),
96 aFlProp ( this, SVX_RES( FL_PROP ) ),
97 aFtName ( this, SVX_RES( FT_NAME ) ),
98 aEdtName ( this, SVX_RES( EDT_NAME ) ),
99 aFtColor ( this, SVX_RES( FT_COLOR ) ),
100 aLbColor ( this, SVX_RES( LB_COLOR ) ),
102 aTableNameFT ( this, SVX_RES( FT_TABLE_NAME ) ),
103 aValSetColorTable ( this, SVX_RES( CTL_COLORTABLE ) ),
105 aCtlPreviewOld ( this, SVX_RES( CTL_PREVIEW_OLD ) ),
106 aCtlPreviewNew ( this, SVX_RES( CTL_PREVIEW_NEW ) ),
108 aLbColorModel ( this, SVX_RES( LB_COLORMODEL ) ),
109 aFtColorModel1 ( this, SVX_RES( FT_1 ) ),
110 aMtrFldColorModel1 ( this, SVX_RES( MTR_FLD_1 ) ),
111 aFtColorModel2 ( this, SVX_RES( FT_2 ) ),
112 aMtrFldColorModel2 ( this, SVX_RES( MTR_FLD_2 ) ),
113 aFtColorModel3 ( this, SVX_RES( FT_3 ) ),
114 aMtrFldColorModel3 ( this, SVX_RES( MTR_FLD_3 ) ),
115 aFtColorModel4 ( this, SVX_RES( FT_4 ) ),
116 aMtrFldColorModel4 ( this, SVX_RES( MTR_FLD_4 ) ),
117 aBtnAdd ( this, SVX_RES( BTN_ADD ) ),
118 aBtnModify ( this, SVX_RES( BTN_MODIFY ) ),
119 aBtnWorkOn ( this, SVX_RES( BTN_WORK_ON ) ),
120 aBtnDelete ( this, SVX_RES( BTN_DELETE ) ),
121 aBtnLoad ( this, SVX_RES( BTN_LOAD ) ),
122 aBtnSave ( this, SVX_RES( BTN_SAVE ) ),
124 rOutAttrs ( rInAttrs ),
125 pColorTab( NULL ),
127 bDeleteColorTable ( TRUE ),
129 pXPool ( (XOutdevItemPool*) rInAttrs.GetPool() ),
130 aXFStyleItem ( XFILL_SOLID ),
131 aXFillColorItem ( String(), Color( COL_BLACK ) ),
132 aXFillAttr ( pXPool ),
133 rXFSet ( aXFillAttr.GetItemSet() ),
135 eCM ( CM_RGB )
138 aBtnLoad.SetModeImage( Image( SVX_RES( RID_SVXIMG_LOAD_H ) ), BMP_COLOR_HIGHCONTRAST );
139 aBtnSave.SetModeImage( Image( SVX_RES( RID_SVXIMG_SAVE_H ) ), BMP_COLOR_HIGHCONTRAST );
141 FreeResource();
143 // diese Page braucht ExchangeSupport
144 SetExchangeSupport();
146 // Setzen des Output-Devices
147 rXFSet.Put( aXFStyleItem );
148 rXFSet.Put( aXFillColorItem );
149 aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
150 aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
152 // Handler ueberladen
153 aLbColor.SetSelectHdl(
154 LINK( this, SvxColorTabPage, SelectColorLBHdl_Impl ) );
155 aValSetColorTable.SetSelectHdl(
156 LINK( this, SvxColorTabPage, SelectValSetHdl_Impl ) );
157 aLbColorModel.SetSelectHdl(
158 LINK( this, SvxColorTabPage, SelectColorModelHdl_Impl ) );
160 Link aLink = LINK( this, SvxColorTabPage, ModifiedHdl_Impl );
161 aMtrFldColorModel1.SetModifyHdl( aLink );
162 aMtrFldColorModel2.SetModifyHdl( aLink );
163 aMtrFldColorModel3.SetModifyHdl( aLink );
164 aMtrFldColorModel4.SetModifyHdl( aLink );
166 aBtnAdd.SetClickHdl( LINK( this, SvxColorTabPage, ClickAddHdl_Impl ) );
167 aBtnModify.SetClickHdl(
168 LINK( this, SvxColorTabPage, ClickModifyHdl_Impl ) );
169 aBtnWorkOn.SetClickHdl(
170 LINK( this, SvxColorTabPage, ClickWorkOnHdl_Impl ) );
171 aBtnDelete.SetClickHdl(
172 LINK( this, SvxColorTabPage, ClickDeleteHdl_Impl ) );
173 aBtnLoad.SetClickHdl( LINK( this, SvxColorTabPage, ClickLoadHdl_Impl ) );
174 aBtnSave.SetClickHdl( LINK( this, SvxColorTabPage, ClickSaveHdl_Impl ) );
176 // ValueSet
177 aValSetColorTable.SetStyle( aValSetColorTable.GetStyle() | WB_VSCROLL | WB_ITEMBORDER );
178 aValSetColorTable.SetColCount( 8 );
179 aValSetColorTable.SetLineCount( 10 );
180 aValSetColorTable.SetExtraSpacing( 0 );
181 aValSetColorTable.Show();
185 // -----------------------------------------------------------------------
187 void SvxColorTabPage::Construct()
189 aLbColor.Fill( pColorTab );
190 FillValueSet_Impl( aValSetColorTable );
193 // -----------------------------------------------------------------------
195 void SvxColorTabPage::ActivatePage( const SfxItemSet& )
197 if( *pDlgType == 0 ) // Flaechen-Dialog
199 *pbAreaTP = FALSE;
201 if( pColorTab )
203 if( *pPageType == PT_COLOR && *pPos != LISTBOX_ENTRY_NOTFOUND )
205 aLbColor.SelectEntryPos( *pPos );
206 aValSetColorTable.SelectItem( aLbColor.GetSelectEntryPos() + 1 );
207 aEdtName.SetText( aLbColor.GetSelectEntry() );
209 ChangeColorHdl_Impl( this );
211 else if( *pPageType == PT_COLOR && *pPos == LISTBOX_ENTRY_NOTFOUND )
213 const SfxPoolItem* pPoolItem = NULL;
214 if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), TRUE, &pPoolItem ) )
216 aLbColorModel.SelectEntryPos( CM_RGB );
218 aAktuellColor.SetColor ( ( ( const XFillColorItem* ) pPoolItem )->GetColorValue().GetColor() );
220 aEdtName.SetText( ( ( const XFillColorItem* ) pPoolItem )->GetName() );
222 aMtrFldColorModel1.SetValue( ColorToPercent_Impl( aAktuellColor.GetRed() ) );
223 aMtrFldColorModel2.SetValue( ColorToPercent_Impl( aAktuellColor.GetGreen() ) );
224 aMtrFldColorModel3.SetValue( ColorToPercent_Impl( aAktuellColor.GetBlue() ) );
226 // ItemSet fuellen und an XOut weiterleiten
227 rXFSet.Put( XFillColorItem( String(), aAktuellColor ) );
228 aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
229 aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
231 aCtlPreviewNew.Invalidate();
232 aCtlPreviewOld.Invalidate();
236 // Ermitteln (evtl. abschneiden) des Namens und in
237 // der GroupBox darstellen
238 String aString( SVX_RES( RID_SVXSTR_TABLE ) ); aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
239 INetURLObject aURL( pColorTab->GetPath() );
241 aURL.Append( pColorTab->GetName() );
242 DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
244 if ( aURL.getBase().getLength() > 18 )
246 aString += String(aURL.getBase()).Copy( 0, 15 );
247 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
249 else
250 aString += String(aURL.getBase());
252 aTableNameFT.SetText( aString );
254 // Damit evtl. geaenderte Farbe verworfen wird
255 SelectColorLBHdl_Impl( this );
257 *pPageType = PT_COLOR;
258 *pPos = LISTBOX_ENTRY_NOTFOUND;
261 else
263 // Buttons werden gehided, weil Paletten z.Z. nur
264 // ueber den AreaDlg funktionieren!!!
265 // ActivatePage() muss von anderen Dialogen explizit
266 // gerufen werden, da ActivatePage() nicht gerufen wird,
267 // wenn Seite als Erste im Dialog angezeigt wird
268 aBtnLoad.Hide();
269 aBtnSave.Hide();
273 // -----------------------------------------------------------------------
275 int SvxColorTabPage::DeactivatePage( SfxItemSet* _pSet )
277 if ( CheckChanges_Impl() == -1L )
278 return( KEEP_PAGE );
280 if( _pSet )
281 FillItemSet( *_pSet );
283 return( LEAVE_PAGE );
286 // -----------------------------------------------------------------------
288 long SvxColorTabPage::CheckChanges_Impl()
290 // wird hier benutzt, um Aenderungen NICHT zu verlieren
292 Color aTmpColor (aAktuellColor);
293 if (eCM != CM_RGB)
294 ConvertColorValues (aTmpColor, CM_RGB);
296 USHORT nPos = aLbColor.GetSelectEntryPos();
297 if( nPos != LISTBOX_ENTRY_NOTFOUND )
299 Color aColor = pColorTab->GetColor( nPos )->GetColor();
300 String aString = aLbColor.GetSelectEntry();
302 // aNewColor, da COL_USER != COL_irgendwas, auch wenn RGB-Werte gleich
303 // Color aNewColor( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() );
305 if( ColorToPercent_Impl( aTmpColor.GetRed() ) != ColorToPercent_Impl( aColor.GetRed() ) ||
306 ColorToPercent_Impl( aTmpColor.GetGreen() ) != ColorToPercent_Impl( aColor.GetGreen() ) ||
307 ColorToPercent_Impl( aTmpColor.GetBlue() ) != ColorToPercent_Impl( aColor.GetBlue() ) ||
308 aString != aEdtName.GetText() )
310 ResMgr& rMgr = DIALOG_MGR();
311 Image aWarningBoxImage = WarningBox::GetStandardImage();
312 //CHINA001 SvxMessDialog aMessDlg( DLGWIN,
313 //CHINA001 String( SVX_RES( RID_SVXSTR_COLOR, pMgr ) ),
314 //CHINA001 String( ResId( RID_SVXSTR_ASK_CHANGE_COLOR, pMgr ) ),
315 //CHINA001 &aWarningBoxImage );
316 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
317 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
318 AbstractSvxMessDialog* aMessDlg = pFact->CreateSvxMessDialog( DLGWIN, RID_SVXDLG_MESSBOX,
319 String( ResId( RID_SVXSTR_COLOR, rMgr ) ),
320 String( ResId( RID_SVXSTR_ASK_CHANGE_COLOR, rMgr ) ),
321 &aWarningBoxImage );
322 DBG_ASSERT(aMessDlg, "Dialogdiet fail!");//CHINA001
323 aMessDlg->SetButtonText( MESS_BTN_1, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_1,
324 String( ResId( RID_SVXSTR_CHANGE, rMgr ) ) );
325 aMessDlg->SetButtonText( MESS_BTN_2, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_2,
326 String( ResId( RID_SVXSTR_ADD, rMgr ) ) );
328 short nRet = aMessDlg->Execute(); //CHINA001 short nRet = aMessDlg.Execute();
330 switch( nRet )
332 case RET_BTN_1: // Aendern
334 ClickModifyHdl_Impl( this );
335 aColor = pColorTab->GetColor( nPos )->GetColor();
337 break;
339 case RET_BTN_2: // Hinzufuegen
341 ClickAddHdl_Impl( this );
342 nPos = aLbColor.GetSelectEntryPos();
343 aColor = pColorTab->GetColor( nPos )->GetColor();
345 break;
347 case RET_CANCEL:
348 // return( -1L ); <-- wuerde die Seite nicht verlassen
349 break;
350 // return( TRUE ); // Abbruch
352 delete aMessDlg; //add by CHINA001
355 if( *pDlgType == 0 ) // Flaechen-Dialog
357 nPos = aLbColor.GetSelectEntryPos();
358 if( nPos != LISTBOX_ENTRY_NOTFOUND )
360 *pPos = nPos;
363 return( 0L );
366 // -----------------------------------------------------------------------
368 BOOL SvxColorTabPage::FillItemSet( SfxItemSet& rSet )
370 if( ( *pDlgType != 0 ) ||
371 ( *pPageType == PT_COLOR && *pbAreaTP == FALSE ) )
373 String aString;
374 Color aColor;
376 // CheckChanges_Impl(); <-- doppelte Abfrage ?
378 USHORT nPos = aLbColor.GetSelectEntryPos();
379 if( nPos != LISTBOX_ENTRY_NOTFOUND )
381 aColor = pColorTab->GetColor( nPos )->GetColor();
382 aString = aLbColor.GetSelectEntry();
384 else
386 aColor.SetColor (aAktuellColor.GetColor());
387 if (eCM != CM_RGB)
388 ConvertColorValues (aColor, CM_RGB);
390 rSet.Put( XFillColorItem( aString, aColor ) );
391 rSet.Put( XFillStyleItem( XFILL_SOLID ) );
394 return( TRUE );
397 // -----------------------------------------------------------------------
399 void SvxColorTabPage::Reset( const SfxItemSet& rSet )
401 USHORT nState = rSet.GetItemState( XATTR_FILLCOLOR );
403 if ( nState >= SFX_ITEM_DEFAULT )
405 XFillColorItem aColorItem( (const XFillColorItem&)rSet.Get( XATTR_FILLCOLOR ) );
406 aLbColor.SelectEntry( aColorItem.GetColorValue() );
407 aValSetColorTable.SelectItem( aLbColor.GetSelectEntryPos() + 1 );
408 aEdtName.SetText( aLbColor.GetSelectEntry() );
411 // Farbmodell setzen
412 String aStr = GetUserData();
413 aLbColorModel.SelectEntryPos( (USHORT) aStr.ToInt32() );
415 ChangeColorHdl_Impl( this );
416 SelectColorModelHdl_Impl( this );
418 aCtlPreviewOld.Invalidate();
420 // Status der Buttons ermitteln
421 if( pColorTab->Count() )
423 aBtnModify.Enable();
424 aBtnWorkOn.Enable();
425 aBtnDelete.Enable();
426 aBtnSave.Enable();
428 else
430 aBtnModify.Disable();
431 aBtnWorkOn.Disable();
432 aBtnDelete.Disable();
433 aBtnSave.Disable();
437 // -----------------------------------------------------------------------
439 SfxTabPage* SvxColorTabPage::Create( Window* pWindow,
440 const SfxItemSet& rOutAttrs )
442 return( new SvxColorTabPage( pWindow, rOutAttrs ) );
445 //------------------------------------------------------------------------
448 // Wird aufgerufen, wenn Inhalt der MtrFileds f�r Farbwerte ver�ndert wird
450 IMPL_LINK( SvxColorTabPage, ModifiedHdl_Impl, void *, EMPTYARG )
452 // lese aktuelle MtrFields aus, wenn cmyk, dann k-Wert als Trans.-Farbe
453 aAktuellColor.SetColor ( Color( (UINT8)PercentToColor_Impl( (USHORT) aMtrFldColorModel4.GetValue() ),
454 (UINT8)PercentToColor_Impl( (USHORT) aMtrFldColorModel1.GetValue() ),
455 (UINT8)PercentToColor_Impl( (USHORT) aMtrFldColorModel2.GetValue() ),
456 (UINT8)PercentToColor_Impl( (USHORT) aMtrFldColorModel3.GetValue() ) ).GetColor() );
458 Color aTmpColor(aAktuellColor);
459 if (eCM != CM_RGB)
460 ConvertColorValues (aTmpColor, CM_RGB);
462 rXFSet.Put( XFillColorItem( String(), aTmpColor ) );
463 aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
465 aCtlPreviewNew.Invalidate();
467 return( 0L );
470 //------------------------------------------------------------------------
473 // Button 'Hinzuf�gen'
475 IMPL_LINK( SvxColorTabPage, ClickAddHdl_Impl, void *, EMPTYARG )
477 Window *pWindow = this;
478 bool bEnabled;
479 while( pWindow )
481 bEnabled = pWindow->IsEnabled();
482 pWindow = pWindow->GetParent();
485 ResMgr& rMgr = DIALOG_MGR();
486 String aDesc( ResId( RID_SVXSTR_DESC_COLOR, rMgr ) );
487 String aName( aEdtName.GetText() );
488 XColorEntry* pEntry;
489 long nCount = pColorTab->Count();
490 BOOL bDifferent = TRUE;
492 // Pruefen, ob Name schon vorhanden ist
493 for ( long i = 0; i < nCount && bDifferent; i++ )
494 if ( aName == pColorTab->GetColor( i )->GetName() )
495 bDifferent = FALSE;
497 // Wenn ja, wird wiederholt ein neuer Name angefordert
498 if ( !bDifferent )
500 WarningBox aWarningBox( DLGWIN, WinBits( WB_OK ),
501 String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
502 aWarningBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
503 aWarningBox.Execute();
505 //CHINA001 SvxNameDialog* pDlg = new SvxNameDialog( DLGWIN, aName, aDesc );
506 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
507 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
508 AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc, RID_SVXDLG_NAME );
509 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
510 BOOL bLoop = TRUE;
512 while ( !bDifferent && bLoop && pDlg->Execute() == RET_OK )
514 pDlg->GetName( aName );
515 bDifferent = TRUE;
517 for( long i = 0; i < nCount && bDifferent; i++ )
519 if( aName == pColorTab->GetColor( i )->GetName() )
520 bDifferent = FALSE;
523 if( bDifferent )
524 bLoop = FALSE;
525 else
526 aWarningBox.Execute();
528 delete( pDlg );
531 // Wenn nicht vorhanden, wird Eintrag aufgenommen
532 if( bDifferent )
534 if (eCM != CM_RGB)
535 ConvertColorValues (aAktuellColor, CM_RGB);
536 pEntry = new XColorEntry( aAktuellColor, aName );
538 pColorTab->Insert( pColorTab->Count(), pEntry );
540 aLbColor.Append( pEntry );
541 aValSetColorTable.InsertItem( aValSetColorTable.GetItemCount() + 1,
542 pEntry->GetColor(), pEntry->GetName() );
544 aLbColor.SelectEntryPos( aLbColor.GetEntryCount() - 1 );
546 // Flag fuer modifiziert setzen
547 *pnColorTableState |= CT_MODIFIED;
549 SelectColorLBHdl_Impl( this );
551 // Status der Buttons ermitteln
552 if( pColorTab->Count() )
554 aBtnModify.Enable();
555 aBtnWorkOn.Enable();
556 aBtnDelete.Enable();
557 aBtnSave.Enable();
559 return( 0L );
562 //------------------------------------------------------------------------
565 // Button '�ndern'
567 IMPL_LINK( SvxColorTabPage, ClickModifyHdl_Impl, void *, EMPTYARG )
569 USHORT nPos = aLbColor.GetSelectEntryPos();
571 if( nPos != LISTBOX_ENTRY_NOTFOUND )
573 ResMgr& rMgr = DIALOG_MGR();
574 String aDesc( ResId( RID_SVXSTR_DESC_COLOR, rMgr ) );
575 String aName( aEdtName.GetText() );
576 long nCount = pColorTab->Count();
577 BOOL bDifferent = TRUE;
579 // Pruefen, ob Name schon vorhanden ist
580 for ( long i = 0; i < nCount && bDifferent; i++ )
581 if ( aName == pColorTab->GetColor( i )->GetName() && nPos != i )
582 bDifferent = FALSE;
584 // Wenn ja, wird wiederholt ein neuer Name angefordert
585 if ( !bDifferent )
587 WarningBox aWarningBox( DLGWIN, WinBits( WB_OK ),
588 String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
589 aWarningBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
590 aWarningBox.Execute();
592 //CHINA001 SvxNameDialog* pDlg = new SvxNameDialog( DLGWIN, aName, aDesc );
593 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
594 DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
595 AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc, RID_SVXDLG_NAME );
596 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
597 BOOL bLoop = TRUE;
599 while ( !bDifferent && bLoop && pDlg->Execute() == RET_OK )
601 pDlg->GetName( aName );
602 bDifferent = TRUE;
604 for ( long i = 0; i < nCount && bDifferent; i++ )
605 if( aName == pColorTab->GetColor( i )->GetName() && nPos != i )
606 bDifferent = FALSE;
608 if( bDifferent )
609 bLoop = FALSE;
610 else
611 aWarningBox.Execute();
613 delete( pDlg );
616 // Wenn nicht vorhanden, wird Eintrag aufgenommen
617 if( bDifferent )
619 XColorEntry* pEntry = pColorTab->GetColor( nPos );
621 Color aTmpColor (aAktuellColor);
622 if (eCM != CM_RGB)
623 ConvertColorValues (aTmpColor, CM_RGB);
625 pEntry->SetColor( aTmpColor );
626 pEntry->SetName( aName );
628 aLbColor.Modify( pEntry, nPos );
629 aLbColor.SelectEntryPos( nPos );
630 /////
631 aValSetColorTable.SetItemColor( nPos + 1, pEntry->GetColor() );
632 aValSetColorTable.SetItemText( nPos + 1, pEntry->GetName() );
633 aEdtName.SetText( aName );
635 aCtlPreviewOld.Invalidate();
637 // Flag fuer modifiziert setzen
638 *pnColorTableState |= CT_MODIFIED;
641 return( 0L );
644 //------------------------------------------------------------------------
647 // Button 'Bearbeiten'
649 IMPL_LINK( SvxColorTabPage, ClickWorkOnHdl_Impl, void *, EMPTYARG )
651 SvColorDialog* pColorDlg = new SvColorDialog( DLGWIN );
653 Color aTmpColor (aAktuellColor);
654 if (eCM != CM_RGB)
655 ConvertColorValues (aTmpColor, CM_RGB);
657 pColorDlg->SetColor (aTmpColor);
659 if( pColorDlg->Execute() == RET_OK )
661 USHORT nK = 0;
662 Color aPreviewColor = pColorDlg->GetColor();
663 aAktuellColor = aPreviewColor;
664 if (eCM != CM_RGB)
665 ConvertColorValues (aAktuellColor, eCM);
667 aMtrFldColorModel1.SetValue( ColorToPercent_Impl( aAktuellColor.GetRed() ) );
668 aMtrFldColorModel2.SetValue( ColorToPercent_Impl( aAktuellColor.GetGreen() ) );
669 aMtrFldColorModel3.SetValue( ColorToPercent_Impl( aAktuellColor.GetBlue() ) );
670 aMtrFldColorModel4.SetValue( ColorToPercent_Impl( nK ) );
672 // ItemSet fuellen und an XOut weiterleiten
673 rXFSet.Put( XFillColorItem( String(), aPreviewColor ) );
674 //aCtlPreviewOld.SetAttributes( aXFillAttr );
675 aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
677 aCtlPreviewNew.Invalidate();
679 delete( pColorDlg );
681 return( 0L );
684 //------------------------------------------------------------------------
687 // Button 'Loeschen'
689 IMPL_LINK( SvxColorTabPage, ClickDeleteHdl_Impl, void *, EMPTYARG )
691 USHORT nPos = aLbColor.GetSelectEntryPos();
693 if( nPos != LISTBOX_ENTRY_NOTFOUND )
695 QueryBox aQueryBox( DLGWIN, WinBits( WB_YES_NO | WB_DEF_NO ),
696 String( SVX_RES( RID_SVXSTR_ASK_DEL_COLOR ) ) );
698 if( aQueryBox.Execute() == RET_YES )
700 // Jetzt wird richtig geloescht
701 ULONG nCount = pColorTab->Count() - 1;
702 XColorEntry* pEntry;
704 pEntry = pColorTab->Remove( nPos );
705 DBG_ASSERT( pEntry, "ColorEntry nicht vorhanden (1) !" );
706 delete pEntry;
708 for( ULONG i = nPos; i < nCount; i++ )
710 pEntry = pColorTab->Remove( i + 1 );
711 DBG_ASSERT( pEntry, "ColorEntry nicht vorhanden (2) !" );
712 pColorTab->Insert( i, pEntry );
715 // Listbox und ValueSet aktualisieren
716 aLbColor.RemoveEntry( nPos );
717 aValSetColorTable.Clear();
718 FillValueSet_Impl( aValSetColorTable );
720 // Positionieren
721 aLbColor.SelectEntryPos( nPos );
722 SelectColorLBHdl_Impl( this );
724 aCtlPreviewOld.Invalidate();
726 // Flag fuer modifiziert setzen
727 *pnColorTableState |= CT_MODIFIED;
730 // Status der Buttons ermitteln
731 if( !pColorTab->Count() )
733 aBtnModify.Disable();
734 aBtnWorkOn.Disable();
735 aBtnDelete.Disable();
736 aBtnSave.Disable();
738 return( 0L );
741 // -----------------------------------------------------------------------
744 // Button 'Farbtabelle laden'
746 IMPL_LINK( SvxColorTabPage, ClickLoadHdl_Impl, void *, EMPTYARG )
748 ResMgr& rMgr = DIALOG_MGR();
749 USHORT nReturn = RET_YES;
751 if( *pnColorTableState & CT_MODIFIED )
753 nReturn = WarningBox( DLGWIN, WinBits( WB_YES_NO_CANCEL ),
754 String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute();
756 if ( nReturn == RET_YES )
757 pColorTab->Save();
760 if ( nReturn != RET_CANCEL )
762 ::sfx2::FileDialogHelper aDlg(
763 com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
764 0 );
765 String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soc" ) );
766 aDlg.AddFilter( aStrFilterType, aStrFilterType );
767 INetURLObject aFile( SvtPathOptions().GetPalettePath() );
768 aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
770 if ( aDlg.Execute() == ERRCODE_NONE )
772 INetURLObject aURL( aDlg.GetPath() );
773 INetURLObject aPathURL( aURL );
775 aPathURL.removeSegment();
776 aPathURL.removeFinalSlash();
778 // Tabelle speichern
779 XColorTable* pColTab = new XColorTable( aPathURL.GetMainURL( INetURLObject::NO_DECODE ), pXPool );
780 pColTab->SetName( aURL.getName() ); // XXX
781 if( pColTab->Load() )
783 if( pColTab )
785 // Pruefen, ob Tabelle geloescht werden darf:
786 const XColorTable *pTempTable = 0;
787 SvxAreaTabDialog* pArea = dynamic_cast< SvxAreaTabDialog* >( DLGWIN );
788 SvxLineTabDialog* pLine = dynamic_cast< SvxLineTabDialog* >( DLGWIN );
789 if( pArea )
791 pTempTable = pArea->GetColorTable();
793 else if( pLine )
795 pTempTable = pLine->GetColorTable();
798 if( pColorTab != pTempTable )
800 if( bDeleteColorTable )
801 delete pColorTab;
802 else
803 bDeleteColorTable = TRUE;
806 pColorTab = pColTab;
807 if( pArea )
809 pArea->SetNewColorTable( pColorTab );
811 else if( pLine )
813 pLine->SetNewColorTable( pColorTab );
816 aLbColor.Clear();
817 aValSetColorTable.Clear();
818 Construct();
819 Reset( rOutAttrs );
821 pColorTab->SetName( aURL.getName() );
823 // Ermitteln (evtl. abschneiden) des Namens und in
824 // der GroupBox darstellen
825 String aString( ResId( RID_SVXSTR_TABLE, rMgr ) );
826 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
828 if ( aURL.getBase().getLength() > 18 )
830 aString += String(aURL.getBase()).Copy( 0, 15 );
831 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
833 else
834 aString += String(aURL.getBase());
836 aTableNameFT.SetText( aString );
838 // Flag fuer gewechselt setzen
839 *pnColorTableState |= CT_CHANGED;
840 // Flag fuer modifiziert entfernen
841 *pnColorTableState &= ~CT_MODIFIED;
843 if( aLbColor.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND )
844 aLbColor.SelectEntryPos( 0 );
845 else
846 aLbColor.SelectEntryPos( aLbColor.GetSelectEntryPos() );
848 ChangeColorHdl_Impl( this );
849 SelectColorLBHdl_Impl( this );
852 else
854 //aIStream.Close();
855 ErrorBox aErrorBox( DLGWIN, WinBits( WB_OK ),
856 String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) );
857 aErrorBox.Execute();
862 // Status der Buttons ermitteln
863 if ( pColorTab->Count() )
865 aBtnModify.Enable();
866 aBtnWorkOn.Enable();
867 aBtnDelete.Enable();
868 aBtnSave.Enable();
870 else
872 aBtnModify.Disable();
873 aBtnWorkOn.Disable();
874 aBtnDelete.Disable();
875 aBtnSave.Disable();
877 return( 0L );
880 // -----------------------------------------------------------------------
883 // Button 'Farbtabelle speichern'
885 IMPL_LINK( SvxColorTabPage, ClickSaveHdl_Impl, void *, EMPTYARG )
887 ::sfx2::FileDialogHelper aDlg(
888 com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
889 String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soc" ) );
890 aDlg.AddFilter( aStrFilterType, aStrFilterType );
892 INetURLObject aFile( SvtPathOptions().GetPalettePath() );
893 DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
895 if( pColorTab->GetName().Len() )
897 aFile.Append( pColorTab->GetName() );
899 if( !aFile.getExtension().getLength() )
900 aFile.SetExtension( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "soc" ) ) );
903 aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
904 if ( aDlg.Execute() == ERRCODE_NONE )
906 INetURLObject aURL( aDlg.GetPath() );
907 INetURLObject aPathURL( aURL );
909 aPathURL.removeSegment();
910 aPathURL.removeFinalSlash();
912 pColorTab->SetName( aURL.getName() );
913 pColorTab->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
915 if( pColorTab->Save() )
917 // Ermitteln (evtl. abschneiden) des Namens und in
918 // der GroupBox darstellen
919 String aString( SVX_RES( RID_SVXSTR_TABLE ) );
920 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
922 if ( aURL.getBase().getLength() > 18 )
924 aString += String(aURL.getBase()).Copy( 0, 15 );
925 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
927 else
928 aString += String(aURL.getBase());
929 aTableNameFT.SetText( aString );
931 // Flag fuer gespeichert setzen
932 *pnColorTableState |= CT_SAVED;
933 // Flag fuer modifiziert entfernen
934 *pnColorTableState &= ~CT_MODIFIED;
936 else
938 ErrorBox aErrorBox( DLGWIN, WinBits( WB_OK ),
939 String( SVX_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) );
940 aErrorBox.Execute();
943 return( 0L );
946 //------------------------------------------------------------------------
948 IMPL_LINK( SvxColorTabPage, SelectColorLBHdl_Impl, void *, EMPTYARG )
950 USHORT nPos = aLbColor.GetSelectEntryPos();
951 if( nPos != LISTBOX_ENTRY_NOTFOUND )
953 aValSetColorTable.SelectItem( nPos + 1 );
954 aEdtName.SetText( aLbColor.GetSelectEntry() );
956 rXFSet.Put( XFillColorItem( String(),
957 aLbColor.GetSelectEntryColor() ) );
958 aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
959 aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
961 aCtlPreviewOld.Invalidate();
962 aCtlPreviewNew.Invalidate();
964 ChangeColorHdl_Impl( this );
966 return( 0L );
969 //------------------------------------------------------------------------
971 IMPL_LINK( SvxColorTabPage, SelectValSetHdl_Impl, void *, EMPTYARG )
973 USHORT nPos = aValSetColorTable.GetSelectItemId();
974 if( nPos != LISTBOX_ENTRY_NOTFOUND )
976 aLbColor.SelectEntryPos( nPos - 1 );
977 aEdtName.SetText( aLbColor.GetSelectEntry() );
979 rXFSet.Put( XFillColorItem( String(),
980 aLbColor.GetSelectEntryColor() ) );
981 aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
982 aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
984 aCtlPreviewOld.Invalidate();
985 aCtlPreviewNew.Invalidate();
987 ChangeColorHdl_Impl( this );
989 return( 0L );
992 //------------------------------------------------------------------------
995 // Farbwerte je nach �bergebenes Farbmodell umrechnen
997 void SvxColorTabPage::ConvertColorValues (Color& rColor, ColorModel eModell)
999 switch (eModell)
1001 case CM_RGB:
1003 CmykToRgb_Impl (rColor, (USHORT)rColor.GetTransparency() );
1004 rColor.SetTransparency ((UINT8) 0);
1006 break;
1008 case CM_CMYK:
1010 USHORT nK;
1011 RgbToCmyk_Impl (rColor, nK );
1012 rColor.SetTransparency ((UINT8) nK);
1014 break;
1019 // Auswahl Listbox 'Farbmodell' (RGB/CMY)
1021 IMPL_LINK( SvxColorTabPage, SelectColorModelHdl_Impl, void *, EMPTYARG )
1023 int nPos = aLbColorModel.GetSelectEntryPos();
1024 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1026 if (eCM != (ColorModel) nPos)
1028 // wenn Farbmodell geaendert wurde, dann Werte umrechnen
1029 ConvertColorValues (aAktuellColor, (ColorModel) nPos);
1032 eCM = (ColorModel) nPos;
1034 switch( eCM )
1036 case CM_RGB:
1038 String aStr( aLbColorModel.GetSelectEntry() );
1039 String aColorStr( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "~X" ) ) );
1040 xub_StrLen nIdx = 1;
1041 aColorStr.SetChar( nIdx, aStr.GetChar( 0 ) );
1042 aFtColorModel1.SetText( aColorStr );
1043 aColorStr.SetChar( nIdx, aStr.GetChar( 1 ) );
1044 aFtColorModel2.SetText( aColorStr );
1045 aColorStr.SetChar( nIdx, aStr.GetChar( 2 ) );
1046 aFtColorModel3.SetText( aColorStr );
1048 aFtColorModel4.Hide();
1049 aMtrFldColorModel4.Hide();
1050 aMtrFldColorModel4.SetValue( 0L );
1052 aMtrFldColorModel1.SetHelpId( HID_TPCOLOR_RGB_1 );
1053 aMtrFldColorModel2.SetHelpId( HID_TPCOLOR_RGB_2 );
1054 aMtrFldColorModel3.SetHelpId( HID_TPCOLOR_RGB_3 );
1056 // Da der alte HelpText noch am Control steht wuerde
1057 // ein Umsetzen der HelpID alleine nichts bewirken
1058 aMtrFldColorModel1.SetHelpText( String() );
1059 aMtrFldColorModel2.SetHelpText( String() );
1060 aMtrFldColorModel3.SetHelpText( String() );
1062 // RGB-Werte im Bereich 0..255 verarbeiten (nicht in %),
1063 // dazu MetricField's entsprechend einstellen
1064 aMtrFldColorModel1.SetUnit(FUNIT_NONE);
1065 aMtrFldColorModel1.SetMin(0);
1066 aMtrFldColorModel1.SetMax(255);
1067 aMtrFldColorModel1.SetLast(255);
1069 aMtrFldColorModel2.SetUnit(FUNIT_NONE);
1070 aMtrFldColorModel2.SetMin(0);
1071 aMtrFldColorModel2.SetMax(255);
1072 aMtrFldColorModel2.SetLast(255);
1074 aMtrFldColorModel3.SetUnit(FUNIT_NONE);
1075 aMtrFldColorModel3.SetMin(0);
1076 aMtrFldColorModel3.SetMax(255);
1077 aMtrFldColorModel3.SetLast(255);
1079 break;
1081 case CM_CMYK:
1083 String aStr( aLbColorModel.GetSelectEntry() );
1084 String aColorStr( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "~X" ) ) );
1085 xub_StrLen nIdx = 1;
1086 aColorStr.SetChar( nIdx, aStr.GetChar( 0 ) );
1087 aFtColorModel1.SetText( aColorStr );
1088 aColorStr.SetChar( nIdx, aStr.GetChar( 1 ) );
1089 aFtColorModel2.SetText( aColorStr );
1090 aColorStr.SetChar( nIdx,aStr.GetChar( 2 ) );
1091 aFtColorModel3.SetText( aColorStr );
1092 aColorStr.SetChar( nIdx,aStr.GetChar( 3 ) );
1093 aFtColorModel4.SetText( aColorStr );
1095 aFtColorModel4.Show();
1096 aMtrFldColorModel4.Show();
1098 aMtrFldColorModel1.SetHelpId( HID_TPCOLOR_CMYK_1 );
1099 aMtrFldColorModel2.SetHelpId( HID_TPCOLOR_CMYK_2 );
1100 aMtrFldColorModel3.SetHelpId( HID_TPCOLOR_CMYK_3 );
1102 // s.o.
1103 aMtrFldColorModel1.SetHelpText( String() );
1104 aMtrFldColorModel2.SetHelpText( String() );
1105 aMtrFldColorModel3.SetHelpText( String() );
1107 // CMYK-Werte im Bereich 0..100% verarbeiten,
1108 // dazu MetricField's entsprechend einstellen
1109 String aStrUnit( RTL_CONSTASCII_USTRINGPARAM( " %" ) );
1111 aMtrFldColorModel1.SetUnit(FUNIT_CUSTOM);
1112 aMtrFldColorModel1.SetCustomUnitText( aStrUnit );
1113 aMtrFldColorModel1.SetMin(0);
1114 aMtrFldColorModel1.SetMax(100);
1115 aMtrFldColorModel1.SetLast(100);
1117 aMtrFldColorModel2.SetUnit(FUNIT_CUSTOM);
1118 aMtrFldColorModel2.SetCustomUnitText( aStrUnit );
1119 aMtrFldColorModel2.SetMin(0);
1120 aMtrFldColorModel2.SetMax(100);
1121 aMtrFldColorModel2.SetLast(100);
1123 aMtrFldColorModel3.SetUnit(FUNIT_CUSTOM);
1124 aMtrFldColorModel3.SetCustomUnitText( aStrUnit );
1125 aMtrFldColorModel3.SetMin(0);
1126 aMtrFldColorModel3.SetMax(100);
1127 aMtrFldColorModel3.SetLast(100);
1129 break;
1132 aMtrFldColorModel1.SetValue( ColorToPercent_Impl( aAktuellColor.GetRed() ) );
1133 aMtrFldColorModel2.SetValue( ColorToPercent_Impl( aAktuellColor.GetGreen() ) );
1134 aMtrFldColorModel3.SetValue( ColorToPercent_Impl( aAktuellColor.GetBlue() ) );
1135 aMtrFldColorModel4.SetValue( ColorToPercent_Impl( aAktuellColor.GetTransparency() ) );
1137 return( 0L );
1140 //------------------------------------------------------------------------
1142 long SvxColorTabPage::ChangeColorHdl_Impl( void* )
1144 int nPos = aLbColor.GetSelectEntryPos();
1145 if( nPos != LISTBOX_ENTRY_NOTFOUND )
1147 XColorEntry* pEntry = pColorTab->GetColor( nPos );
1149 aAktuellColor.SetColor ( pEntry->GetColor().GetColor() );
1150 if (eCM != CM_RGB)
1151 ConvertColorValues (aAktuellColor, eCM);
1153 aMtrFldColorModel1.SetValue( ColorToPercent_Impl( aAktuellColor.GetRed() ) );
1154 aMtrFldColorModel2.SetValue( ColorToPercent_Impl( aAktuellColor.GetGreen() ) );
1155 aMtrFldColorModel3.SetValue( ColorToPercent_Impl( aAktuellColor.GetBlue() ) );
1156 aMtrFldColorModel4.SetValue( ColorToPercent_Impl( aAktuellColor.GetTransparency() ) );
1158 // ItemSet fuellen und an XOut weiterleiten
1159 rXFSet.Put( XFillColorItem( String(), pEntry->GetColor() ) );
1160 aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
1161 aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
1163 aCtlPreviewNew.Invalidate();
1165 return( 0L );
1168 //------------------------------------------------------------------------
1170 void SvxColorTabPage::FillValueSet_Impl( ValueSet& rVs )
1172 long nCount = pColorTab->Count();
1173 XColorEntry* pColorEntry;
1175 for( long i = 0; i < nCount; i++ )
1177 pColorEntry = pColorTab->GetColor( i );
1178 rVs.InsertItem( (USHORT) i + 1, pColorEntry->GetColor(), pColorEntry->GetName() );
1182 //------------------------------------------------------------------------
1184 // Ein RGB-Wert wird in einen CMYK-Wert konvertiert, wobei die Color-
1185 // Klasse vergewaltigt wird, da R in C, G in M und B in Y umgewandelt
1186 // wird. Der Wert K wird in einer Extra-Variablen gehalten.
1187 // Bei weiteren Farbmodellen sollte man hierfuer eigene Klassen entwickeln,
1188 // die dann auch entsprechende Casts enthalten.
1190 void SvxColorTabPage::RgbToCmyk_Impl( Color& rColor, USHORT& rK )
1192 USHORT nColor1, nColor2, nColor3;
1193 USHORT nProzent; // nur temporaer !!!
1195 nColor1 = 255 - rColor.GetRed();
1196 nProzent = ColorToPercent_Impl( nColor1 );
1198 nColor2 = 255 - rColor.GetGreen();
1199 nProzent = ColorToPercent_Impl( nColor2 );
1201 nColor3 = 255 - rColor.GetBlue();
1202 nProzent = ColorToPercent_Impl( nColor3 );
1204 rK = Min( Min( nColor1, nColor2 ), nColor3 );
1206 rColor.SetRed( sal::static_int_cast< UINT8 >( nColor1 - rK ) );
1207 rColor.SetGreen( sal::static_int_cast< UINT8 >( nColor2 - rK ) );
1208 rColor.SetBlue( sal::static_int_cast< UINT8 >( nColor3 - rK ) );
1211 //------------------------------------------------------------------------
1213 // Umgekehrter Fall zu RgbToCmyk_Impl (s.o.)
1215 void SvxColorTabPage::CmykToRgb_Impl( Color& rColor, const USHORT nK )
1217 long lTemp;
1219 lTemp = 255 - ( rColor.GetRed() + nK );
1221 if( lTemp < 0L )
1222 lTemp = 0L;
1223 rColor.SetRed( (BYTE)lTemp );
1225 lTemp = 255 - ( rColor.GetGreen() + nK );
1227 if( lTemp < 0L )
1228 lTemp = 0L;
1229 rColor.SetGreen( (BYTE)lTemp );
1231 lTemp = 255 - ( rColor.GetBlue() + nK );
1233 if( lTemp < 0L )
1234 lTemp = 0L;
1235 rColor.SetBlue( (BYTE)lTemp );
1238 //------------------------------------------------------------------------
1240 USHORT SvxColorTabPage::ColorToPercent_Impl( USHORT nColor )
1242 USHORT nWert = 0;
1244 switch (eCM)
1246 case CM_RGB :
1247 nWert = nColor;
1248 break;
1250 case CM_CMYK:
1251 nWert = (USHORT) ( (double) nColor * 100.0 / 255.0 + 0.5 );
1252 break;
1255 return ( nWert );
1258 //------------------------------------------------------------------------
1260 USHORT SvxColorTabPage::PercentToColor_Impl( USHORT nPercent )
1262 USHORT nWert = 0;
1264 switch (eCM)
1266 case CM_RGB :
1267 nWert = nPercent;
1268 break;
1270 case CM_CMYK:
1271 nWert = (USHORT) ( (double) nPercent * 255.0 / 100.0 + 0.5 );
1272 break;
1275 return ( nWert );
1278 //------------------------------------------------------------------------
1280 void SvxColorTabPage::FillUserData()
1282 // Das Farbmodell wird in der Ini-Datei festgehalten
1283 SetUserData( UniString::CreateFromInt32( eCM ) );