12ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
32ee96f1cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
42ee96f1cSAndrew Rist * or more contributor license agreements. See the NOTICE file
52ee96f1cSAndrew Rist * distributed with this work for additional information
62ee96f1cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
72ee96f1cSAndrew Rist * to you under the Apache License, Version 2.0 (the
82ee96f1cSAndrew Rist * "License"); you may not use this file except in compliance
92ee96f1cSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
112ee96f1cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
132ee96f1cSAndrew Rist * Unless required by applicable law or agreed to in writing,
142ee96f1cSAndrew Rist * software distributed under the License is distributed on an
152ee96f1cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162ee96f1cSAndrew Rist * KIND, either express or implied. See the License for the
172ee96f1cSAndrew Rist * specific language governing permissions and limitations
182ee96f1cSAndrew Rist * under the License.
19cdf0e10cSrcweir *
202ee96f1cSAndrew Rist *************************************************************/
212ee96f1cSAndrew Rist
222ee96f1cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cui.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir #include <tools/shl.hxx>
29cdf0e10cSrcweir #include <tools/urlobj.hxx>
30cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
31cdf0e10cSrcweir #include <sfx2/app.hxx>
32cdf0e10cSrcweir #include <sfx2/module.hxx>
33cdf0e10cSrcweir #include <svtools/colrdlg.hxx>
34cdf0e10cSrcweir #include <vcl/msgbox.hxx>
35cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx>
36cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
37cdf0e10cSrcweir
38cdf0e10cSrcweir #define _SVX_TPCOLOR_CXX
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include <cuires.hrc>
41cdf0e10cSrcweir #include "helpid.hrc"
42cdf0e10cSrcweir #include "svx/xattr.hxx"
43cdf0e10cSrcweir #include <svx/xpool.hxx>
44cdf0e10cSrcweir #include <svx/xtable.hxx>
45cdf0e10cSrcweir #include "svx/drawitem.hxx"
46cdf0e10cSrcweir #include "cuitabarea.hxx"
47cdf0e10cSrcweir #include "tabarea.hrc"
48cdf0e10cSrcweir #include "defdlgname.hxx" //CHINA001 #include "dlgname.hxx"
49cdf0e10cSrcweir //#include "dlgname.hrc"
50cdf0e10cSrcweir #include <svx/svxdlg.hxx> //CHINA001
51cdf0e10cSrcweir #include <dialmgr.hxx>
52cdf0e10cSrcweir #include <cuitabline.hxx>
53cdf0e10cSrcweir #include <svx/dialmgr.hxx>
54cdf0e10cSrcweir #include <svx/dialogs.hrc>
55cdf0e10cSrcweir
56cdf0e10cSrcweir #define DLGWIN GetParentDialog( this )
57cdf0e10cSrcweir
58cdf0e10cSrcweir /*************************************************************************
59cdf0e10cSrcweir |*
60cdf0e10cSrcweir |* Dialog zum Aendern und Definieren der Farben
61cdf0e10cSrcweir |*
62cdf0e10cSrcweir \************************************************************************/
63cdf0e10cSrcweir
GetParentDialog(Window * pWindow)64cdf0e10cSrcweir static Window* GetParentDialog( Window* pWindow )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir while( pWindow )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir if( pWindow->IsDialog() )
69cdf0e10cSrcweir break;
70cdf0e10cSrcweir
71cdf0e10cSrcweir pWindow = pWindow->GetParent();
72cdf0e10cSrcweir }
73cdf0e10cSrcweir
74cdf0e10cSrcweir return pWindow;
75cdf0e10cSrcweir }
76cdf0e10cSrcweir
SvxColorTabPage(Window * pParent,const SfxItemSet & rInAttrs)77cdf0e10cSrcweir SvxColorTabPage::SvxColorTabPage
78cdf0e10cSrcweir (
79cdf0e10cSrcweir Window* pParent,
80cdf0e10cSrcweir const SfxItemSet& rInAttrs
81cdf0e10cSrcweir ) :
82cdf0e10cSrcweir
83cdf0e10cSrcweir SfxTabPage ( pParent, CUI_RES( RID_SVXPAGE_COLOR ), rInAttrs ),
84cdf0e10cSrcweir
85cdf0e10cSrcweir aFlProp ( this, CUI_RES( FL_PROP ) ),
86cdf0e10cSrcweir aFtName ( this, CUI_RES( FT_NAME ) ),
87cdf0e10cSrcweir aEdtName ( this, CUI_RES( EDT_NAME ) ),
88cdf0e10cSrcweir aFtColor ( this, CUI_RES( FT_COLOR ) ),
89cdf0e10cSrcweir aLbColor ( this, CUI_RES( LB_COLOR ) ),
90cdf0e10cSrcweir
91cdf0e10cSrcweir aTableNameFT ( this, CUI_RES( FT_TABLE_NAME ) ),
92cdf0e10cSrcweir aValSetColorTable ( this, CUI_RES( CTL_COLORTABLE ) ),
93cdf0e10cSrcweir
94cdf0e10cSrcweir aCtlPreviewOld ( this, CUI_RES( CTL_PREVIEW_OLD ) ),
95cdf0e10cSrcweir aCtlPreviewNew ( this, CUI_RES( CTL_PREVIEW_NEW ) ),
96cdf0e10cSrcweir
97cdf0e10cSrcweir aLbColorModel ( this, CUI_RES( LB_COLORMODEL ) ),
98cdf0e10cSrcweir aFtColorModel1 ( this, CUI_RES( FT_1 ) ),
99cdf0e10cSrcweir aMtrFldColorModel1 ( this, CUI_RES( MTR_FLD_1 ) ),
100cdf0e10cSrcweir aFtColorModel2 ( this, CUI_RES( FT_2 ) ),
101cdf0e10cSrcweir aMtrFldColorModel2 ( this, CUI_RES( MTR_FLD_2 ) ),
102cdf0e10cSrcweir aFtColorModel3 ( this, CUI_RES( FT_3 ) ),
103cdf0e10cSrcweir aMtrFldColorModel3 ( this, CUI_RES( MTR_FLD_3 ) ),
104cdf0e10cSrcweir aFtColorModel4 ( this, CUI_RES( FT_4 ) ),
105cdf0e10cSrcweir aMtrFldColorModel4 ( this, CUI_RES( MTR_FLD_4 ) ),
106cdf0e10cSrcweir aBtnAdd ( this, CUI_RES( BTN_ADD ) ),
107cdf0e10cSrcweir aBtnModify ( this, CUI_RES( BTN_MODIFY ) ),
108cdf0e10cSrcweir aBtnWorkOn ( this, CUI_RES( BTN_WORK_ON ) ),
109cdf0e10cSrcweir aBtnDelete ( this, CUI_RES( BTN_DELETE ) ),
110cdf0e10cSrcweir aBtnLoad ( this, CUI_RES( BTN_LOAD ) ),
111cdf0e10cSrcweir aBtnSave ( this, CUI_RES( BTN_SAVE ) ),
112cdf0e10cSrcweir
113cdf0e10cSrcweir rOutAttrs ( rInAttrs ),
114c7be74b1SArmin Le Grand maColorTab(),
115cdf0e10cSrcweir
116cdf0e10cSrcweir pXPool ( (XOutdevItemPool*) rInAttrs.GetPool() ),
117cdf0e10cSrcweir aXFStyleItem ( XFILL_SOLID ),
118cdf0e10cSrcweir aXFillColorItem ( String(), Color( COL_BLACK ) ),
119cdf0e10cSrcweir aXFillAttr ( pXPool ),
120cdf0e10cSrcweir rXFSet ( aXFillAttr.GetItemSet() ),
121cdf0e10cSrcweir
122cdf0e10cSrcweir eCM ( CM_RGB )
123cdf0e10cSrcweir
124cdf0e10cSrcweir {
125cdf0e10cSrcweir aBtnLoad.SetModeImage( Image( CUI_RES( RID_SVXIMG_LOAD_H ) ), BMP_COLOR_HIGHCONTRAST );
126cdf0e10cSrcweir aBtnSave.SetModeImage( Image( CUI_RES( RID_SVXIMG_SAVE_H ) ), BMP_COLOR_HIGHCONTRAST );
127cdf0e10cSrcweir
128cdf0e10cSrcweir FreeResource();
129cdf0e10cSrcweir
130cdf0e10cSrcweir // diese Page braucht ExchangeSupport
131cdf0e10cSrcweir SetExchangeSupport();
132cdf0e10cSrcweir
133cdf0e10cSrcweir // Setzen des Output-Devices
134cdf0e10cSrcweir rXFSet.Put( aXFStyleItem );
135cdf0e10cSrcweir rXFSet.Put( aXFillColorItem );
136cdf0e10cSrcweir aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
137cdf0e10cSrcweir aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
138cdf0e10cSrcweir
139cdf0e10cSrcweir // Handler ueberladen
140cdf0e10cSrcweir aLbColor.SetSelectHdl(
141cdf0e10cSrcweir LINK( this, SvxColorTabPage, SelectColorLBHdl_Impl ) );
142cdf0e10cSrcweir aValSetColorTable.SetSelectHdl(
143cdf0e10cSrcweir LINK( this, SvxColorTabPage, SelectValSetHdl_Impl ) );
144cdf0e10cSrcweir aLbColorModel.SetSelectHdl(
145cdf0e10cSrcweir LINK( this, SvxColorTabPage, SelectColorModelHdl_Impl ) );
146cdf0e10cSrcweir
147cdf0e10cSrcweir Link aLink = LINK( this, SvxColorTabPage, ModifiedHdl_Impl );
148cdf0e10cSrcweir aMtrFldColorModel1.SetModifyHdl( aLink );
149cdf0e10cSrcweir aMtrFldColorModel2.SetModifyHdl( aLink );
150cdf0e10cSrcweir aMtrFldColorModel3.SetModifyHdl( aLink );
151cdf0e10cSrcweir aMtrFldColorModel4.SetModifyHdl( aLink );
152cdf0e10cSrcweir
153cdf0e10cSrcweir aBtnAdd.SetClickHdl( LINK( this, SvxColorTabPage, ClickAddHdl_Impl ) );
154cdf0e10cSrcweir aBtnModify.SetClickHdl(
155cdf0e10cSrcweir LINK( this, SvxColorTabPage, ClickModifyHdl_Impl ) );
156cdf0e10cSrcweir aBtnWorkOn.SetClickHdl(
157cdf0e10cSrcweir LINK( this, SvxColorTabPage, ClickWorkOnHdl_Impl ) );
158cdf0e10cSrcweir aBtnDelete.SetClickHdl(
159cdf0e10cSrcweir LINK( this, SvxColorTabPage, ClickDeleteHdl_Impl ) );
160cdf0e10cSrcweir aBtnLoad.SetClickHdl( LINK( this, SvxColorTabPage, ClickLoadHdl_Impl ) );
161cdf0e10cSrcweir aBtnSave.SetClickHdl( LINK( this, SvxColorTabPage, ClickSaveHdl_Impl ) );
162cdf0e10cSrcweir
163cdf0e10cSrcweir // ValueSet
16428bcfa49SArmin Le Grand aValSetColorTable.SetStyle( aValSetColorTable.GetStyle() | WB_ITEMBORDER );
165cdf0e10cSrcweir aValSetColorTable.Show();
166cdf0e10cSrcweir
167cdf0e10cSrcweir aLbColorModel.SetAccessibleName( String( CUI_RES(STR_CUI_COLORMODEL) ) );
168cdf0e10cSrcweir aBtnAdd.SetAccessibleRelationMemberOf( &aFlProp );
169cdf0e10cSrcweir aBtnModify.SetAccessibleRelationMemberOf( &aFlProp );
170cdf0e10cSrcweir aBtnWorkOn.SetAccessibleRelationMemberOf( &aFlProp );
171cdf0e10cSrcweir aBtnDelete.SetAccessibleRelationMemberOf( &aFlProp );
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
174cdf0e10cSrcweir // -----------------------------------------------------------------------
175cdf0e10cSrcweir
ImpColorCountChanged()17628bcfa49SArmin Le Grand void SvxColorTabPage::ImpColorCountChanged()
17728bcfa49SArmin Le Grand {
178c7be74b1SArmin Le Grand if(maColorTab.get())
17928bcfa49SArmin Le Grand {
18028bcfa49SArmin Le Grand aValSetColorTable.SetColCount(aValSetColorTable.getColumnCount());
18128bcfa49SArmin Le Grand
18228bcfa49SArmin Le Grand // here we have enough space to the left, so layout with fixed column size
18328bcfa49SArmin Le Grand // and fixed height, adapt width. Apply the adapted width by moving the left
18428bcfa49SArmin Le Grand // edge of the control to the left, keeping the right edge aligned
18528bcfa49SArmin Le Grand // with the original position
18628bcfa49SArmin Le Grand const Point aCurrentPos(aValSetColorTable.GetPosPixel());
18728bcfa49SArmin Le Grand const Size aCurrentSize(aValSetColorTable.GetOutputSizePixel());
188c7be74b1SArmin Le Grand const long nColorCount(maColorTab->Count());
18928bcfa49SArmin Le Grand const Size aNewSize(aValSetColorTable.layoutToGivenHeight(aCurrentSize.Height(), nColorCount));
19028bcfa49SArmin Le Grand const Point aNewPos((aCurrentPos.X() + aCurrentSize.Width()) - aNewSize.Width(), aCurrentPos.Y());
19128bcfa49SArmin Le Grand
19228bcfa49SArmin Le Grand aValSetColorTable.SetOutputSizePixel(aNewSize);
19328bcfa49SArmin Le Grand aValSetColorTable.SetPosSizePixel(aNewPos, aNewSize);
19428bcfa49SArmin Le Grand }
19528bcfa49SArmin Le Grand }
19628bcfa49SArmin Le Grand
19728bcfa49SArmin Le Grand // -----------------------------------------------------------------------
19828bcfa49SArmin Le Grand
Construct()199cdf0e10cSrcweir void SvxColorTabPage::Construct()
200cdf0e10cSrcweir {
201c7be74b1SArmin Le Grand if(maColorTab.get())
20228bcfa49SArmin Le Grand {
203c7be74b1SArmin Le Grand aLbColor.Fill(maColorTab);
204c7be74b1SArmin Le Grand aValSetColorTable.addEntriesForXColorList(maColorTab);
20528bcfa49SArmin Le Grand ImpColorCountChanged();
20628bcfa49SArmin Le Grand }
207cdf0e10cSrcweir }
208cdf0e10cSrcweir
209cdf0e10cSrcweir // -----------------------------------------------------------------------
210cdf0e10cSrcweir
ActivatePage(const SfxItemSet &)211cdf0e10cSrcweir void SvxColorTabPage::ActivatePage( const SfxItemSet& )
212cdf0e10cSrcweir {
213cdf0e10cSrcweir if( *pDlgType == 0 ) // Flaechen-Dialog
214cdf0e10cSrcweir {
215cdf0e10cSrcweir *pbAreaTP = sal_False;
216cdf0e10cSrcweir
217c7be74b1SArmin Le Grand if( maColorTab.get() )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir if( *pPageType == PT_COLOR && *pPos != LISTBOX_ENTRY_NOTFOUND )
220cdf0e10cSrcweir {
221cdf0e10cSrcweir aLbColor.SelectEntryPos( *pPos );
222cdf0e10cSrcweir aValSetColorTable.SelectItem( aLbColor.GetSelectEntryPos() + 1 );
223cdf0e10cSrcweir aEdtName.SetText( aLbColor.GetSelectEntry() );
224cdf0e10cSrcweir
225cdf0e10cSrcweir ChangeColorHdl_Impl( this );
226cdf0e10cSrcweir }
227cdf0e10cSrcweir else if( *pPageType == PT_COLOR && *pPos == LISTBOX_ENTRY_NOTFOUND )
228cdf0e10cSrcweir {
229cdf0e10cSrcweir const SfxPoolItem* pPoolItem = NULL;
230cdf0e10cSrcweir if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), sal_True, &pPoolItem ) )
231cdf0e10cSrcweir {
232cdf0e10cSrcweir aLbColorModel.SelectEntryPos( CM_RGB );
233cdf0e10cSrcweir
234cdf0e10cSrcweir aAktuellColor.SetColor ( ( ( const XFillColorItem* ) pPoolItem )->GetColorValue().GetColor() );
235cdf0e10cSrcweir
236cdf0e10cSrcweir aEdtName.SetText( ( ( const XFillColorItem* ) pPoolItem )->GetName() );
237cdf0e10cSrcweir
238cdf0e10cSrcweir aMtrFldColorModel1.SetValue( ColorToPercent_Impl( aAktuellColor.GetRed() ) );
239cdf0e10cSrcweir aMtrFldColorModel2.SetValue( ColorToPercent_Impl( aAktuellColor.GetGreen() ) );
240cdf0e10cSrcweir aMtrFldColorModel3.SetValue( ColorToPercent_Impl( aAktuellColor.GetBlue() ) );
241cdf0e10cSrcweir
242cdf0e10cSrcweir // ItemSet fuellen und an XOut weiterleiten
243cdf0e10cSrcweir rXFSet.Put( XFillColorItem( String(), aAktuellColor ) );
244cdf0e10cSrcweir aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
245cdf0e10cSrcweir aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
246cdf0e10cSrcweir
247cdf0e10cSrcweir aCtlPreviewNew.Invalidate();
248cdf0e10cSrcweir aCtlPreviewOld.Invalidate();
249cdf0e10cSrcweir }
250cdf0e10cSrcweir }
251cdf0e10cSrcweir
252cdf0e10cSrcweir // Ermitteln (evtl. abschneiden) des Namens und in
253cdf0e10cSrcweir // der GroupBox darstellen
254cdf0e10cSrcweir String aString( CUI_RES( RID_SVXSTR_TABLE ) ); aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
255c7be74b1SArmin Le Grand INetURLObject aURL( maColorTab->GetPath() );
256cdf0e10cSrcweir
257c7be74b1SArmin Le Grand aURL.Append( maColorTab->GetName() );
258cdf0e10cSrcweir DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
259cdf0e10cSrcweir
260cdf0e10cSrcweir if ( aURL.getBase().getLength() > 18 )
261cdf0e10cSrcweir {
262cdf0e10cSrcweir aString += String(aURL.getBase()).Copy( 0, 15 );
263cdf0e10cSrcweir aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
264cdf0e10cSrcweir }
265cdf0e10cSrcweir else
266cdf0e10cSrcweir aString += String(aURL.getBase());
267cdf0e10cSrcweir
268cdf0e10cSrcweir aTableNameFT.SetText( aString );
269cdf0e10cSrcweir
270cdf0e10cSrcweir // Damit evtl. geaenderte Farbe verworfen wird
271cdf0e10cSrcweir SelectColorLBHdl_Impl( this );
272cdf0e10cSrcweir
273cdf0e10cSrcweir *pPageType = PT_COLOR;
274cdf0e10cSrcweir *pPos = LISTBOX_ENTRY_NOTFOUND;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir }
277cdf0e10cSrcweir else
278cdf0e10cSrcweir {
279cdf0e10cSrcweir // Buttons werden gehided, weil Paletten z.Z. nur
280cdf0e10cSrcweir // ueber den AreaDlg funktionieren!!!
281cdf0e10cSrcweir // ActivatePage() muss von anderen Dialogen explizit
282cdf0e10cSrcweir // gerufen werden, da ActivatePage() nicht gerufen wird,
283cdf0e10cSrcweir // wenn Seite als Erste im Dialog angezeigt wird
284cdf0e10cSrcweir aBtnLoad.Hide();
285cdf0e10cSrcweir aBtnSave.Hide();
286cdf0e10cSrcweir }
287cdf0e10cSrcweir }
288cdf0e10cSrcweir
289cdf0e10cSrcweir // -----------------------------------------------------------------------
290cdf0e10cSrcweir
DeactivatePage(SfxItemSet * _pSet)291cdf0e10cSrcweir int SvxColorTabPage::DeactivatePage( SfxItemSet* _pSet )
292cdf0e10cSrcweir {
293cdf0e10cSrcweir if ( CheckChanges_Impl() == -1L )
294cdf0e10cSrcweir return( KEEP_PAGE );
295cdf0e10cSrcweir
296cdf0e10cSrcweir if( _pSet )
297cdf0e10cSrcweir FillItemSet( *_pSet );
298cdf0e10cSrcweir
299cdf0e10cSrcweir return( LEAVE_PAGE );
300cdf0e10cSrcweir }
301cdf0e10cSrcweir
302cdf0e10cSrcweir // -----------------------------------------------------------------------
303cdf0e10cSrcweir
CheckChanges_Impl()304cdf0e10cSrcweir long SvxColorTabPage::CheckChanges_Impl()
305cdf0e10cSrcweir {
306cdf0e10cSrcweir // wird hier benutzt, um Aenderungen NICHT zu verlieren
307cdf0e10cSrcweir
308cdf0e10cSrcweir Color aTmpColor (aAktuellColor);
309cdf0e10cSrcweir if (eCM != CM_RGB)
310cdf0e10cSrcweir ConvertColorValues (aTmpColor, CM_RGB);
311cdf0e10cSrcweir
312cdf0e10cSrcweir sal_uInt16 nPos = aLbColor.GetSelectEntryPos();
313cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND )
314cdf0e10cSrcweir {
315c7be74b1SArmin Le Grand Color aColor = maColorTab->GetColor( nPos )->GetColor();
316cdf0e10cSrcweir String aString = aLbColor.GetSelectEntry();
317cdf0e10cSrcweir
318cdf0e10cSrcweir // aNewColor, da COL_USER != COL_irgendwas, auch wenn RGB-Werte gleich
319cdf0e10cSrcweir // Color aNewColor( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() );
320cdf0e10cSrcweir
321cdf0e10cSrcweir if( ColorToPercent_Impl( aTmpColor.GetRed() ) != ColorToPercent_Impl( aColor.GetRed() ) ||
322cdf0e10cSrcweir ColorToPercent_Impl( aTmpColor.GetGreen() ) != ColorToPercent_Impl( aColor.GetGreen() ) ||
323cdf0e10cSrcweir ColorToPercent_Impl( aTmpColor.GetBlue() ) != ColorToPercent_Impl( aColor.GetBlue() ) ||
324cdf0e10cSrcweir aString != aEdtName.GetText() )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir ResMgr& rMgr = CUI_MGR();
327cdf0e10cSrcweir Image aWarningBoxImage = WarningBox::GetStandardImage();
328cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
329cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
330cdf0e10cSrcweir AbstractSvxMessDialog* aMessDlg = pFact->CreateSvxMessDialog( DLGWIN, RID_SVXDLG_MESSBOX,
331cdf0e10cSrcweir SVX_RESSTR( RID_SVXSTR_COLOR ),
332cdf0e10cSrcweir String( ResId( RID_SVXSTR_ASK_CHANGE_COLOR, rMgr ) ),
333cdf0e10cSrcweir &aWarningBoxImage );
334cdf0e10cSrcweir DBG_ASSERT(aMessDlg, "Dialogdiet fail!");//CHINA001
335cdf0e10cSrcweir aMessDlg->SetButtonText( MESS_BTN_1, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_1,
336cdf0e10cSrcweir String( ResId( RID_SVXSTR_CHANGE, rMgr ) ) );
337cdf0e10cSrcweir aMessDlg->SetButtonText( MESS_BTN_2, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_2,
338cdf0e10cSrcweir String( ResId( RID_SVXSTR_ADD, rMgr ) ) );
339cdf0e10cSrcweir
340cdf0e10cSrcweir short nRet = aMessDlg->Execute(); //CHINA001 short nRet = aMessDlg.Execute();
341cdf0e10cSrcweir
342cdf0e10cSrcweir switch( nRet )
343cdf0e10cSrcweir {
344cdf0e10cSrcweir case RET_BTN_1: // Aendern
345cdf0e10cSrcweir {
346cdf0e10cSrcweir ClickModifyHdl_Impl( this );
347c7be74b1SArmin Le Grand aColor = maColorTab->GetColor( nPos )->GetColor();
348cdf0e10cSrcweir }
349cdf0e10cSrcweir break;
350cdf0e10cSrcweir
351cdf0e10cSrcweir case RET_BTN_2: // Hinzufuegen
352cdf0e10cSrcweir {
353cdf0e10cSrcweir ClickAddHdl_Impl( this );
354cdf0e10cSrcweir nPos = aLbColor.GetSelectEntryPos();
355c7be74b1SArmin Le Grand aColor = maColorTab->GetColor( nPos )->GetColor();
356cdf0e10cSrcweir }
357cdf0e10cSrcweir break;
358cdf0e10cSrcweir
359cdf0e10cSrcweir case RET_CANCEL:
360cdf0e10cSrcweir // return( -1L ); <-- wuerde die Seite nicht verlassen
361cdf0e10cSrcweir break;
362cdf0e10cSrcweir // return( sal_True ); // Abbruch
363cdf0e10cSrcweir }
364cdf0e10cSrcweir delete aMessDlg; //add by CHINA001
365cdf0e10cSrcweir }
366cdf0e10cSrcweir }
367cdf0e10cSrcweir if( *pDlgType == 0 ) // Flaechen-Dialog
368cdf0e10cSrcweir {
369cdf0e10cSrcweir nPos = aLbColor.GetSelectEntryPos();
370cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND )
371cdf0e10cSrcweir {
372cdf0e10cSrcweir *pPos = nPos;
373cdf0e10cSrcweir }
374cdf0e10cSrcweir }
375cdf0e10cSrcweir return( 0L );
376cdf0e10cSrcweir }
377cdf0e10cSrcweir
378cdf0e10cSrcweir // -----------------------------------------------------------------------
379cdf0e10cSrcweir
FillItemSet(SfxItemSet & rSet)380cdf0e10cSrcweir sal_Bool SvxColorTabPage::FillItemSet( SfxItemSet& rSet )
381cdf0e10cSrcweir {
382cdf0e10cSrcweir if( ( *pDlgType != 0 ) ||
383cdf0e10cSrcweir ( *pPageType == PT_COLOR && *pbAreaTP == sal_False ) )
384cdf0e10cSrcweir {
385cdf0e10cSrcweir String aString;
386cdf0e10cSrcweir Color aColor;
387cdf0e10cSrcweir
388cdf0e10cSrcweir // CheckChanges_Impl(); <-- doppelte Abfrage ?
389cdf0e10cSrcweir
390cdf0e10cSrcweir sal_uInt16 nPos = aLbColor.GetSelectEntryPos();
391cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND )
392cdf0e10cSrcweir {
393c7be74b1SArmin Le Grand aColor = maColorTab->GetColor( nPos )->GetColor();
394cdf0e10cSrcweir aString = aLbColor.GetSelectEntry();
395cdf0e10cSrcweir }
396cdf0e10cSrcweir else
397cdf0e10cSrcweir {
398cdf0e10cSrcweir aColor.SetColor (aAktuellColor.GetColor());
399cdf0e10cSrcweir if (eCM != CM_RGB)
400cdf0e10cSrcweir ConvertColorValues (aColor, CM_RGB);
401cdf0e10cSrcweir }
402cdf0e10cSrcweir rSet.Put( XFillColorItem( aString, aColor ) );
403cdf0e10cSrcweir rSet.Put( XFillStyleItem( XFILL_SOLID ) );
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
406cdf0e10cSrcweir return( sal_True );
407cdf0e10cSrcweir }
408cdf0e10cSrcweir
409cdf0e10cSrcweir // -----------------------------------------------------------------------
410cdf0e10cSrcweir
Reset(const SfxItemSet & rSet)411cdf0e10cSrcweir void SvxColorTabPage::Reset( const SfxItemSet& rSet )
412cdf0e10cSrcweir {
413cdf0e10cSrcweir sal_uInt16 nState = rSet.GetItemState( XATTR_FILLCOLOR );
414cdf0e10cSrcweir
415cdf0e10cSrcweir if ( nState >= SFX_ITEM_DEFAULT )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir XFillColorItem aColorItem( (const XFillColorItem&)rSet.Get( XATTR_FILLCOLOR ) );
418cdf0e10cSrcweir aLbColor.SelectEntry( aColorItem.GetColorValue() );
419cdf0e10cSrcweir aValSetColorTable.SelectItem( aLbColor.GetSelectEntryPos() + 1 );
420cdf0e10cSrcweir aEdtName.SetText( aLbColor.GetSelectEntry() );
421cdf0e10cSrcweir }
422cdf0e10cSrcweir
423cdf0e10cSrcweir // Farbmodell setzen
424cdf0e10cSrcweir String aStr = GetUserData();
425cdf0e10cSrcweir aLbColorModel.SelectEntryPos( (sal_uInt16) aStr.ToInt32() );
426cdf0e10cSrcweir
427cdf0e10cSrcweir ChangeColorHdl_Impl( this );
428cdf0e10cSrcweir SelectColorModelHdl_Impl( this );
429cdf0e10cSrcweir
430cdf0e10cSrcweir aCtlPreviewOld.Invalidate();
431cdf0e10cSrcweir
432cdf0e10cSrcweir // Status der Buttons ermitteln
433c7be74b1SArmin Le Grand if( maColorTab->Count() )
434cdf0e10cSrcweir {
435cdf0e10cSrcweir aBtnModify.Enable();
436cdf0e10cSrcweir aBtnWorkOn.Enable();
437cdf0e10cSrcweir aBtnDelete.Enable();
438cdf0e10cSrcweir aBtnSave.Enable();
439cdf0e10cSrcweir }
440cdf0e10cSrcweir else
441cdf0e10cSrcweir {
442cdf0e10cSrcweir aBtnModify.Disable();
443cdf0e10cSrcweir aBtnWorkOn.Disable();
444cdf0e10cSrcweir aBtnDelete.Disable();
445cdf0e10cSrcweir aBtnSave.Disable();
446cdf0e10cSrcweir }
447cdf0e10cSrcweir }
448cdf0e10cSrcweir
449cdf0e10cSrcweir // -----------------------------------------------------------------------
450cdf0e10cSrcweir
Create(Window * pWindow,const SfxItemSet & rOutAttrs)451cdf0e10cSrcweir SfxTabPage* SvxColorTabPage::Create( Window* pWindow,
452cdf0e10cSrcweir const SfxItemSet& rOutAttrs )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir return( new SvxColorTabPage( pWindow, rOutAttrs ) );
455cdf0e10cSrcweir }
456cdf0e10cSrcweir
457cdf0e10cSrcweir //------------------------------------------------------------------------
458cdf0e10cSrcweir
459cdf0e10cSrcweir //
460cdf0e10cSrcweir // Wird aufgerufen, wenn Inhalt der MtrFileds f�r Farbwerte ver�ndert wird
461cdf0e10cSrcweir //
IMPL_LINK(SvxColorTabPage,ModifiedHdl_Impl,void *,EMPTYARG)462cdf0e10cSrcweir IMPL_LINK( SvxColorTabPage, ModifiedHdl_Impl, void *, EMPTYARG )
463cdf0e10cSrcweir {
464cdf0e10cSrcweir // lese aktuelle MtrFields aus, wenn cmyk, dann k-Wert als Trans.-Farbe
465cdf0e10cSrcweir aAktuellColor.SetColor ( Color( (sal_uInt8)PercentToColor_Impl( (sal_uInt16) aMtrFldColorModel4.GetValue() ),
466cdf0e10cSrcweir (sal_uInt8)PercentToColor_Impl( (sal_uInt16) aMtrFldColorModel1.GetValue() ),
467cdf0e10cSrcweir (sal_uInt8)PercentToColor_Impl( (sal_uInt16) aMtrFldColorModel2.GetValue() ),
468cdf0e10cSrcweir (sal_uInt8)PercentToColor_Impl( (sal_uInt16) aMtrFldColorModel3.GetValue() ) ).GetColor() );
469cdf0e10cSrcweir
470cdf0e10cSrcweir Color aTmpColor(aAktuellColor);
471cdf0e10cSrcweir if (eCM != CM_RGB)
472cdf0e10cSrcweir ConvertColorValues (aTmpColor, CM_RGB);
473cdf0e10cSrcweir
474cdf0e10cSrcweir rXFSet.Put( XFillColorItem( String(), aTmpColor ) );
475cdf0e10cSrcweir aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
476cdf0e10cSrcweir
477cdf0e10cSrcweir aCtlPreviewNew.Invalidate();
478cdf0e10cSrcweir
479cdf0e10cSrcweir return( 0L );
480cdf0e10cSrcweir }
481cdf0e10cSrcweir
482cdf0e10cSrcweir //------------------------------------------------------------------------
483cdf0e10cSrcweir
484cdf0e10cSrcweir //
485cdf0e10cSrcweir // Button 'Hinzuf�gen'
486cdf0e10cSrcweir //
IMPL_LINK(SvxColorTabPage,ClickAddHdl_Impl,void *,EMPTYARG)487cdf0e10cSrcweir IMPL_LINK( SvxColorTabPage, ClickAddHdl_Impl, void *, EMPTYARG )
488cdf0e10cSrcweir {
489cdf0e10cSrcweir Window *pWindow = this;
490cdf0e10cSrcweir bool bEnabled;
491cdf0e10cSrcweir while( pWindow )
492cdf0e10cSrcweir {
493cdf0e10cSrcweir bEnabled = pWindow->IsEnabled();
494cdf0e10cSrcweir pWindow = pWindow->GetParent();
495cdf0e10cSrcweir }
496cdf0e10cSrcweir
497cdf0e10cSrcweir ResMgr& rMgr = CUI_MGR();
498cdf0e10cSrcweir String aDesc( ResId( RID_SVXSTR_DESC_COLOR, rMgr ) );
499cdf0e10cSrcweir String aName( aEdtName.GetText() );
500cdf0e10cSrcweir XColorEntry* pEntry;
501c7be74b1SArmin Le Grand long nCount = maColorTab->Count();
502cdf0e10cSrcweir sal_Bool bDifferent = sal_True;
503cdf0e10cSrcweir
504cdf0e10cSrcweir // Pruefen, ob Name schon vorhanden ist
505cdf0e10cSrcweir for ( long i = 0; i < nCount && bDifferent; i++ )
506c7be74b1SArmin Le Grand if ( aName == maColorTab->GetColor( i )->GetName() )
507cdf0e10cSrcweir bDifferent = sal_False;
508cdf0e10cSrcweir
509cdf0e10cSrcweir // Wenn ja, wird wiederholt ein neuer Name angefordert
510cdf0e10cSrcweir if ( !bDifferent )
511cdf0e10cSrcweir {
512cdf0e10cSrcweir WarningBox aWarningBox( DLGWIN, WinBits( WB_OK ),
513cdf0e10cSrcweir String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
514cdf0e10cSrcweir aWarningBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
515cdf0e10cSrcweir aWarningBox.Execute();
516cdf0e10cSrcweir
517cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
518cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
519cdf0e10cSrcweir AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc );
520cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
521cdf0e10cSrcweir sal_Bool bLoop = sal_True;
522cdf0e10cSrcweir
523cdf0e10cSrcweir while ( !bDifferent && bLoop && pDlg->Execute() == RET_OK )
524cdf0e10cSrcweir {
525cdf0e10cSrcweir pDlg->GetName( aName );
526cdf0e10cSrcweir bDifferent = sal_True;
527cdf0e10cSrcweir
528cdf0e10cSrcweir for( long i = 0; i < nCount && bDifferent; i++ )
529cdf0e10cSrcweir {
530c7be74b1SArmin Le Grand if( aName == maColorTab->GetColor( i )->GetName() )
531cdf0e10cSrcweir bDifferent = sal_False;
532cdf0e10cSrcweir }
533cdf0e10cSrcweir
534cdf0e10cSrcweir if( bDifferent )
535cdf0e10cSrcweir bLoop = sal_False;
536cdf0e10cSrcweir else
537cdf0e10cSrcweir aWarningBox.Execute();
538cdf0e10cSrcweir }
539cdf0e10cSrcweir delete( pDlg );
540cdf0e10cSrcweir }
541cdf0e10cSrcweir
542cdf0e10cSrcweir // Wenn nicht vorhanden, wird Eintrag aufgenommen
543cdf0e10cSrcweir if( bDifferent )
544cdf0e10cSrcweir {
545cdf0e10cSrcweir if (eCM != CM_RGB)
546cdf0e10cSrcweir ConvertColorValues (aAktuellColor, CM_RGB);
547cdf0e10cSrcweir pEntry = new XColorEntry( aAktuellColor, aName );
548cdf0e10cSrcweir
549c7be74b1SArmin Le Grand maColorTab->Insert( pEntry, maColorTab->Count() );
550cdf0e10cSrcweir
5513e407bd8SArmin Le Grand aLbColor.Append( *pEntry );
5523e407bd8SArmin Le Grand aValSetColorTable.InsertItem( aValSetColorTable.GetItemCount() + 1, pEntry->GetColor(), pEntry->GetName() );
55328bcfa49SArmin Le Grand ImpColorCountChanged();
554cdf0e10cSrcweir
555cdf0e10cSrcweir aLbColor.SelectEntryPos( aLbColor.GetEntryCount() - 1 );
556cdf0e10cSrcweir
557cdf0e10cSrcweir // Flag fuer modifiziert setzen
558cdf0e10cSrcweir *pnColorTableState |= CT_MODIFIED;
559cdf0e10cSrcweir
560cdf0e10cSrcweir SelectColorLBHdl_Impl( this );
561cdf0e10cSrcweir }
562cdf0e10cSrcweir // Status der Buttons ermitteln
563c7be74b1SArmin Le Grand if( maColorTab->Count() )
564cdf0e10cSrcweir {
565cdf0e10cSrcweir aBtnModify.Enable();
566cdf0e10cSrcweir aBtnWorkOn.Enable();
567cdf0e10cSrcweir aBtnDelete.Enable();
568cdf0e10cSrcweir aBtnSave.Enable();
569cdf0e10cSrcweir }
570cdf0e10cSrcweir return( 0L );
571cdf0e10cSrcweir }
572cdf0e10cSrcweir
573cdf0e10cSrcweir //------------------------------------------------------------------------
574cdf0e10cSrcweir
575cdf0e10cSrcweir //
576cdf0e10cSrcweir // Button '�ndern'
577cdf0e10cSrcweir //
IMPL_LINK(SvxColorTabPage,ClickModifyHdl_Impl,void *,EMPTYARG)578cdf0e10cSrcweir IMPL_LINK( SvxColorTabPage, ClickModifyHdl_Impl, void *, EMPTYARG )
579cdf0e10cSrcweir {
580cdf0e10cSrcweir sal_uInt16 nPos = aLbColor.GetSelectEntryPos();
581cdf0e10cSrcweir
582cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND )
583cdf0e10cSrcweir {
584cdf0e10cSrcweir ResMgr& rMgr = CUI_MGR();
585cdf0e10cSrcweir String aDesc( ResId( RID_SVXSTR_DESC_COLOR, rMgr ) );
586cdf0e10cSrcweir String aName( aEdtName.GetText() );
587c7be74b1SArmin Le Grand long nCount = maColorTab->Count();
588cdf0e10cSrcweir sal_Bool bDifferent = sal_True;
589cdf0e10cSrcweir
590cdf0e10cSrcweir // Pruefen, ob Name schon vorhanden ist
591cdf0e10cSrcweir for ( long i = 0; i < nCount && bDifferent; i++ )
592c7be74b1SArmin Le Grand if ( aName == maColorTab->GetColor( i )->GetName() && nPos != i )
593cdf0e10cSrcweir bDifferent = sal_False;
594cdf0e10cSrcweir
595cdf0e10cSrcweir // Wenn ja, wird wiederholt ein neuer Name angefordert
596cdf0e10cSrcweir if ( !bDifferent )
597cdf0e10cSrcweir {
598cdf0e10cSrcweir WarningBox aWarningBox( DLGWIN, WinBits( WB_OK ),
599cdf0e10cSrcweir String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
600cdf0e10cSrcweir aWarningBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
601cdf0e10cSrcweir aWarningBox.Execute();
602cdf0e10cSrcweir
603cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
604cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
605cdf0e10cSrcweir AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc );
606cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
607cdf0e10cSrcweir sal_Bool bLoop = sal_True;
608cdf0e10cSrcweir
609cdf0e10cSrcweir while ( !bDifferent && bLoop && pDlg->Execute() == RET_OK )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir pDlg->GetName( aName );
612cdf0e10cSrcweir bDifferent = sal_True;
613cdf0e10cSrcweir
614cdf0e10cSrcweir for ( long i = 0; i < nCount && bDifferent; i++ )
615c7be74b1SArmin Le Grand if( aName == maColorTab->GetColor( i )->GetName() && nPos != i )
616cdf0e10cSrcweir bDifferent = sal_False;
617cdf0e10cSrcweir
618cdf0e10cSrcweir if( bDifferent )
619cdf0e10cSrcweir bLoop = sal_False;
620cdf0e10cSrcweir else
621cdf0e10cSrcweir aWarningBox.Execute();
622cdf0e10cSrcweir }
623cdf0e10cSrcweir delete( pDlg );
624cdf0e10cSrcweir }
625cdf0e10cSrcweir
626cdf0e10cSrcweir // Wenn nicht vorhanden, wird Eintrag aufgenommen
627cdf0e10cSrcweir if( bDifferent )
628cdf0e10cSrcweir {
629cdf0e10cSrcweir Color aTmpColor (aAktuellColor);
6303e407bd8SArmin Le Grand
631cdf0e10cSrcweir if (eCM != CM_RGB)
632cdf0e10cSrcweir ConvertColorValues (aTmpColor, CM_RGB);
633cdf0e10cSrcweir
634*aa64976bSArmin Le Grand // #123497# Need to replace the existing entry with a new one (old returned needs to be deleted)
635*aa64976bSArmin Le Grand XColorEntry* pEntry = new XColorEntry(aTmpColor, aName);
636*aa64976bSArmin Le Grand delete maColorTab->Replace(pEntry, nPos);
637cdf0e10cSrcweir
638*aa64976bSArmin Le Grand aLbColor.Modify( *pEntry, nPos );
639cdf0e10cSrcweir aLbColor.SelectEntryPos( nPos );
6403e407bd8SArmin Le Grand
641*aa64976bSArmin Le Grand aValSetColorTable.SetItemColor( nPos + 1, pEntry->GetColor() );
642*aa64976bSArmin Le Grand aValSetColorTable.SetItemText( nPos + 1, pEntry->GetName() );
643cdf0e10cSrcweir aEdtName.SetText( aName );
644cdf0e10cSrcweir
645cdf0e10cSrcweir aCtlPreviewOld.Invalidate();
646cdf0e10cSrcweir
647cdf0e10cSrcweir // Flag fuer modifiziert setzen
648cdf0e10cSrcweir *pnColorTableState |= CT_MODIFIED;
649cdf0e10cSrcweir }
650cdf0e10cSrcweir }
651cdf0e10cSrcweir return( 0L );
652cdf0e10cSrcweir }
653cdf0e10cSrcweir
654cdf0e10cSrcweir //------------------------------------------------------------------------
655cdf0e10cSrcweir
656cdf0e10cSrcweir //
657cdf0e10cSrcweir // Button 'Bearbeiten'
658cdf0e10cSrcweir //
IMPL_LINK(SvxColorTabPage,ClickWorkOnHdl_Impl,void *,EMPTYARG)659cdf0e10cSrcweir IMPL_LINK( SvxColorTabPage, ClickWorkOnHdl_Impl, void *, EMPTYARG )
660cdf0e10cSrcweir {
661cdf0e10cSrcweir SvColorDialog* pColorDlg = new SvColorDialog( DLGWIN );
662cdf0e10cSrcweir
663cdf0e10cSrcweir Color aTmpColor (aAktuellColor);
664cdf0e10cSrcweir if (eCM != CM_RGB)
665cdf0e10cSrcweir ConvertColorValues (aTmpColor, CM_RGB);
666cdf0e10cSrcweir
667cdf0e10cSrcweir pColorDlg->SetColor (aTmpColor);
668b2b569f2SArmin Le Grand pColorDlg->SetMode( svtools::ColorPickerMode_MODIFY );
669cdf0e10cSrcweir
670cdf0e10cSrcweir if( pColorDlg->Execute() == RET_OK )
671cdf0e10cSrcweir {
672cdf0e10cSrcweir sal_uInt16 nK = 0;
673cdf0e10cSrcweir Color aPreviewColor = pColorDlg->GetColor();
674cdf0e10cSrcweir aAktuellColor = aPreviewColor;
675cdf0e10cSrcweir if (eCM != CM_RGB)
676cdf0e10cSrcweir ConvertColorValues (aAktuellColor, eCM);
677cdf0e10cSrcweir
678cdf0e10cSrcweir aMtrFldColorModel1.SetValue( ColorToPercent_Impl( aAktuellColor.GetRed() ) );
679cdf0e10cSrcweir aMtrFldColorModel2.SetValue( ColorToPercent_Impl( aAktuellColor.GetGreen() ) );
680cdf0e10cSrcweir aMtrFldColorModel3.SetValue( ColorToPercent_Impl( aAktuellColor.GetBlue() ) );
681cdf0e10cSrcweir aMtrFldColorModel4.SetValue( ColorToPercent_Impl( nK ) );
682cdf0e10cSrcweir
683cdf0e10cSrcweir // ItemSet fuellen und an XOut weiterleiten
684cdf0e10cSrcweir rXFSet.Put( XFillColorItem( String(), aPreviewColor ) );
685cdf0e10cSrcweir //aCtlPreviewOld.SetAttributes( aXFillAttr );
686cdf0e10cSrcweir aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
687cdf0e10cSrcweir
688cdf0e10cSrcweir aCtlPreviewNew.Invalidate();
689cdf0e10cSrcweir }
690cdf0e10cSrcweir delete( pColorDlg );
691cdf0e10cSrcweir
692cdf0e10cSrcweir return( 0L );
693cdf0e10cSrcweir }
694cdf0e10cSrcweir
695cdf0e10cSrcweir //------------------------------------------------------------------------
696cdf0e10cSrcweir
697cdf0e10cSrcweir //
698cdf0e10cSrcweir // Button 'Loeschen'
699cdf0e10cSrcweir //
IMPL_LINK(SvxColorTabPage,ClickDeleteHdl_Impl,void *,EMPTYARG)700cdf0e10cSrcweir IMPL_LINK( SvxColorTabPage, ClickDeleteHdl_Impl, void *, EMPTYARG )
701cdf0e10cSrcweir {
702cdf0e10cSrcweir sal_uInt16 nPos = aLbColor.GetSelectEntryPos();
703cdf0e10cSrcweir
704cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND )
705cdf0e10cSrcweir {
706cdf0e10cSrcweir QueryBox aQueryBox( DLGWIN, WinBits( WB_YES_NO | WB_DEF_NO ),
707cdf0e10cSrcweir String( CUI_RES( RID_SVXSTR_ASK_DEL_COLOR ) ) );
708cdf0e10cSrcweir
709cdf0e10cSrcweir if( aQueryBox.Execute() == RET_YES )
710cdf0e10cSrcweir {
711cdf0e10cSrcweir // Jetzt wird richtig geloescht
712c7be74b1SArmin Le Grand sal_uLong nCount = maColorTab->Count() - 1;
713cdf0e10cSrcweir XColorEntry* pEntry;
714cdf0e10cSrcweir
715c7be74b1SArmin Le Grand pEntry = maColorTab->Remove( nPos );
716cdf0e10cSrcweir DBG_ASSERT( pEntry, "ColorEntry nicht vorhanden (1) !" );
717cdf0e10cSrcweir delete pEntry;
718cdf0e10cSrcweir
719cdf0e10cSrcweir for( sal_uLong i = nPos; i < nCount; i++ )
720cdf0e10cSrcweir {
721c7be74b1SArmin Le Grand pEntry = maColorTab->Remove( i + 1 );
722cdf0e10cSrcweir DBG_ASSERT( pEntry, "ColorEntry nicht vorhanden (2) !" );
723c7be74b1SArmin Le Grand maColorTab->Insert( pEntry, i );
724cdf0e10cSrcweir }
725cdf0e10cSrcweir
726cdf0e10cSrcweir // Listbox und ValueSet aktualisieren
727cdf0e10cSrcweir aLbColor.RemoveEntry( nPos );
728cdf0e10cSrcweir aValSetColorTable.Clear();
729c7be74b1SArmin Le Grand aValSetColorTable.addEntriesForXColorList(maColorTab);
73028bcfa49SArmin Le Grand ImpColorCountChanged();
73128bcfa49SArmin Le Grand //FillValueSet_Impl( aValSetColorTable );
732cdf0e10cSrcweir
733cdf0e10cSrcweir // Positionieren
734cdf0e10cSrcweir aLbColor.SelectEntryPos( nPos );
735cdf0e10cSrcweir SelectColorLBHdl_Impl( this );
736cdf0e10cSrcweir
737cdf0e10cSrcweir aCtlPreviewOld.Invalidate();
738cdf0e10cSrcweir
739cdf0e10cSrcweir // Flag fuer modifiziert setzen
740cdf0e10cSrcweir *pnColorTableState |= CT_MODIFIED;
741cdf0e10cSrcweir }
742cdf0e10cSrcweir }
743cdf0e10cSrcweir // Status der Buttons ermitteln
744c7be74b1SArmin Le Grand if( !maColorTab->Count() )
745cdf0e10cSrcweir {
746cdf0e10cSrcweir aBtnModify.Disable();
747cdf0e10cSrcweir aBtnWorkOn.Disable();
748cdf0e10cSrcweir aBtnDelete.Disable();
749cdf0e10cSrcweir aBtnSave.Disable();
750cdf0e10cSrcweir }
751cdf0e10cSrcweir return( 0L );
752cdf0e10cSrcweir }
753cdf0e10cSrcweir
754cdf0e10cSrcweir // -----------------------------------------------------------------------
755cdf0e10cSrcweir
756cdf0e10cSrcweir //
757cdf0e10cSrcweir // Button 'Farbtabelle laden'
758cdf0e10cSrcweir //
IMPL_LINK(SvxColorTabPage,ClickLoadHdl_Impl,void *,EMPTYARG)759cdf0e10cSrcweir IMPL_LINK( SvxColorTabPage, ClickLoadHdl_Impl, void *, EMPTYARG )
760cdf0e10cSrcweir {
761cdf0e10cSrcweir ResMgr& rMgr = CUI_MGR();
762cdf0e10cSrcweir sal_uInt16 nReturn = RET_YES;
763cdf0e10cSrcweir
764cdf0e10cSrcweir if( *pnColorTableState & CT_MODIFIED )
765cdf0e10cSrcweir {
766cdf0e10cSrcweir nReturn = WarningBox( DLGWIN, WinBits( WB_YES_NO_CANCEL ),
767cdf0e10cSrcweir String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute();
768cdf0e10cSrcweir
769cdf0e10cSrcweir if ( nReturn == RET_YES )
770c7be74b1SArmin Le Grand maColorTab->Save();
771cdf0e10cSrcweir }
772cdf0e10cSrcweir
773cdf0e10cSrcweir if ( nReturn != RET_CANCEL )
774cdf0e10cSrcweir {
775cdf0e10cSrcweir ::sfx2::FileDialogHelper aDlg(
776cdf0e10cSrcweir com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
777cdf0e10cSrcweir 0 );
778cdf0e10cSrcweir String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soc" ) );
779cdf0e10cSrcweir aDlg.AddFilter( aStrFilterType, aStrFilterType );
780cdf0e10cSrcweir INetURLObject aFile( SvtPathOptions().GetPalettePath() );
781cdf0e10cSrcweir aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
782cdf0e10cSrcweir
783cdf0e10cSrcweir if ( aDlg.Execute() == ERRCODE_NONE )
784cdf0e10cSrcweir {
785cdf0e10cSrcweir INetURLObject aURL( aDlg.GetPath() );
786cdf0e10cSrcweir INetURLObject aPathURL( aURL );
787cdf0e10cSrcweir
788cdf0e10cSrcweir aPathURL.removeSegment();
789cdf0e10cSrcweir aPathURL.removeFinalSlash();
790cdf0e10cSrcweir
791cdf0e10cSrcweir // Tabelle speichern
792c7be74b1SArmin Le Grand XColorListSharedPtr aColTab(XPropertyListFactory::CreateSharedXColorList(aPathURL.GetMainURL(INetURLObject::NO_DECODE)));
793c7be74b1SArmin Le Grand aColTab->SetName( aURL.getName() ); // XXX
794c7be74b1SArmin Le Grand if( aColTab->Load() )
795cdf0e10cSrcweir {
796c7be74b1SArmin Le Grand if( aColTab.get() )
797cdf0e10cSrcweir {
798cdf0e10cSrcweir // Pruefen, ob Tabelle geloescht werden darf:
799c7be74b1SArmin Le Grand XColorListSharedPtr aTempTable;
800cdf0e10cSrcweir SvxAreaTabDialog* pArea = dynamic_cast< SvxAreaTabDialog* >( DLGWIN );
801cdf0e10cSrcweir SvxLineTabDialog* pLine = dynamic_cast< SvxLineTabDialog* >( DLGWIN );
802c7be74b1SArmin Le Grand
803cdf0e10cSrcweir if( pArea )
804cdf0e10cSrcweir {
805c7be74b1SArmin Le Grand aTempTable = pArea->GetColorTable();
806cdf0e10cSrcweir }
807cdf0e10cSrcweir else if( pLine )
808cdf0e10cSrcweir {
809c7be74b1SArmin Le Grand aTempTable = pLine->GetColorTable();
810cdf0e10cSrcweir }
811cdf0e10cSrcweir
812c7be74b1SArmin Le Grand maColorTab = aColTab;
813cdf0e10cSrcweir
814cdf0e10cSrcweir if( pArea )
815cdf0e10cSrcweir {
816c7be74b1SArmin Le Grand pArea->SetNewColorTable( maColorTab );
817cdf0e10cSrcweir }
818cdf0e10cSrcweir else if( pLine )
819cdf0e10cSrcweir {
820c7be74b1SArmin Le Grand pLine->SetNewColorTable( maColorTab );
821cdf0e10cSrcweir }
822cdf0e10cSrcweir
823cdf0e10cSrcweir aLbColor.Clear();
824cdf0e10cSrcweir aValSetColorTable.Clear();
825cdf0e10cSrcweir Construct();
826cdf0e10cSrcweir Reset( rOutAttrs );
827cdf0e10cSrcweir
828c7be74b1SArmin Le Grand maColorTab->SetName( aURL.getName() );
829cdf0e10cSrcweir
830cdf0e10cSrcweir // Ermitteln (evtl. abschneiden) des Namens und in
831cdf0e10cSrcweir // der GroupBox darstellen
832cdf0e10cSrcweir String aString( ResId( RID_SVXSTR_TABLE, rMgr ) );
833cdf0e10cSrcweir aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
834cdf0e10cSrcweir
835cdf0e10cSrcweir if ( aURL.getBase().getLength() > 18 )
836cdf0e10cSrcweir {
837cdf0e10cSrcweir aString += String(aURL.getBase()).Copy( 0, 15 );
838cdf0e10cSrcweir aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
839cdf0e10cSrcweir }
840cdf0e10cSrcweir else
841cdf0e10cSrcweir aString += String(aURL.getBase());
842cdf0e10cSrcweir
843cdf0e10cSrcweir aTableNameFT.SetText( aString );
844cdf0e10cSrcweir
845cdf0e10cSrcweir // Flag fuer gewechselt setzen
846cdf0e10cSrcweir *pnColorTableState |= CT_CHANGED;
847cdf0e10cSrcweir // Flag fuer modifiziert entfernen
848cdf0e10cSrcweir *pnColorTableState &= ~CT_MODIFIED;
849cdf0e10cSrcweir
850cdf0e10cSrcweir if( aLbColor.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND )
851cdf0e10cSrcweir aLbColor.SelectEntryPos( 0 );
852cdf0e10cSrcweir else
853cdf0e10cSrcweir aLbColor.SelectEntryPos( aLbColor.GetSelectEntryPos() );
854cdf0e10cSrcweir
855cdf0e10cSrcweir ChangeColorHdl_Impl( this );
856cdf0e10cSrcweir SelectColorLBHdl_Impl( this );
857cdf0e10cSrcweir }
858cdf0e10cSrcweir }
859cdf0e10cSrcweir else
860cdf0e10cSrcweir {
861cdf0e10cSrcweir //aIStream.Close();
862cdf0e10cSrcweir ErrorBox aErrorBox( DLGWIN, WinBits( WB_OK ),
863cdf0e10cSrcweir String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) );
864cdf0e10cSrcweir aErrorBox.Execute();
865cdf0e10cSrcweir }
866cdf0e10cSrcweir }
867cdf0e10cSrcweir }
868cdf0e10cSrcweir
869cdf0e10cSrcweir // Status der Buttons ermitteln
870c7be74b1SArmin Le Grand if ( maColorTab->Count() )
871cdf0e10cSrcweir {
872cdf0e10cSrcweir aBtnModify.Enable();
873cdf0e10cSrcweir aBtnWorkOn.Enable();
874cdf0e10cSrcweir aBtnDelete.Enable();
875cdf0e10cSrcweir aBtnSave.Enable();
876cdf0e10cSrcweir }
877cdf0e10cSrcweir else
878cdf0e10cSrcweir {
879cdf0e10cSrcweir aBtnModify.Disable();
880cdf0e10cSrcweir aBtnWorkOn.Disable();
881cdf0e10cSrcweir aBtnDelete.Disable();
882cdf0e10cSrcweir aBtnSave.Disable();
883cdf0e10cSrcweir }
884cdf0e10cSrcweir return( 0L );
885cdf0e10cSrcweir }
886cdf0e10cSrcweir
887cdf0e10cSrcweir // -----------------------------------------------------------------------
888cdf0e10cSrcweir
889cdf0e10cSrcweir //
890cdf0e10cSrcweir // Button 'Farbtabelle speichern'
891cdf0e10cSrcweir //
IMPL_LINK(SvxColorTabPage,ClickSaveHdl_Impl,void *,EMPTYARG)892cdf0e10cSrcweir IMPL_LINK( SvxColorTabPage, ClickSaveHdl_Impl, void *, EMPTYARG )
893cdf0e10cSrcweir {
894cdf0e10cSrcweir ::sfx2::FileDialogHelper aDlg(
895cdf0e10cSrcweir com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
896cdf0e10cSrcweir String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.soc" ) );
897cdf0e10cSrcweir aDlg.AddFilter( aStrFilterType, aStrFilterType );
898cdf0e10cSrcweir
899cdf0e10cSrcweir INetURLObject aFile( SvtPathOptions().GetPalettePath() );
900cdf0e10cSrcweir DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
901cdf0e10cSrcweir
902c7be74b1SArmin Le Grand if( maColorTab->GetName().Len() )
903cdf0e10cSrcweir {
904c7be74b1SArmin Le Grand aFile.Append( maColorTab->GetName() );
905cdf0e10cSrcweir
906cdf0e10cSrcweir if( !aFile.getExtension().getLength() )
907cdf0e10cSrcweir aFile.SetExtension( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "soc" ) ) );
908cdf0e10cSrcweir }
909cdf0e10cSrcweir
910cdf0e10cSrcweir aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
911cdf0e10cSrcweir if ( aDlg.Execute() == ERRCODE_NONE )
912cdf0e10cSrcweir {
913cdf0e10cSrcweir INetURLObject aURL( aDlg.GetPath() );
914cdf0e10cSrcweir INetURLObject aPathURL( aURL );
915cdf0e10cSrcweir
916cdf0e10cSrcweir aPathURL.removeSegment();
917cdf0e10cSrcweir aPathURL.removeFinalSlash();
918cdf0e10cSrcweir
919c7be74b1SArmin Le Grand maColorTab->SetName( aURL.getName() );
920c7be74b1SArmin Le Grand maColorTab->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
921cdf0e10cSrcweir
922c7be74b1SArmin Le Grand if( maColorTab->Save() )
923cdf0e10cSrcweir {
924cdf0e10cSrcweir // Ermitteln (evtl. abschneiden) des Namens und in
925cdf0e10cSrcweir // der GroupBox darstellen
926cdf0e10cSrcweir String aString( CUI_RES( RID_SVXSTR_TABLE ) );
927cdf0e10cSrcweir aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
928cdf0e10cSrcweir
929cdf0e10cSrcweir if ( aURL.getBase().getLength() > 18 )
930cdf0e10cSrcweir {
931cdf0e10cSrcweir aString += String(aURL.getBase()).Copy( 0, 15 );
932cdf0e10cSrcweir aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
933cdf0e10cSrcweir }
934cdf0e10cSrcweir else
935cdf0e10cSrcweir aString += String(aURL.getBase());
936cdf0e10cSrcweir aTableNameFT.SetText( aString );
937cdf0e10cSrcweir
938cdf0e10cSrcweir // Flag fuer gespeichert setzen
939cdf0e10cSrcweir *pnColorTableState |= CT_SAVED;
940cdf0e10cSrcweir // Flag fuer modifiziert entfernen
941cdf0e10cSrcweir *pnColorTableState &= ~CT_MODIFIED;
942cdf0e10cSrcweir }
943cdf0e10cSrcweir else
944cdf0e10cSrcweir {
945cdf0e10cSrcweir ErrorBox aErrorBox( DLGWIN, WinBits( WB_OK ),
946cdf0e10cSrcweir String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) );
947cdf0e10cSrcweir aErrorBox.Execute();
948cdf0e10cSrcweir }
949cdf0e10cSrcweir }
950cdf0e10cSrcweir return( 0L );
951cdf0e10cSrcweir }
952cdf0e10cSrcweir
953cdf0e10cSrcweir //------------------------------------------------------------------------
954cdf0e10cSrcweir
IMPL_LINK(SvxColorTabPage,SelectColorLBHdl_Impl,void *,EMPTYARG)955cdf0e10cSrcweir IMPL_LINK( SvxColorTabPage, SelectColorLBHdl_Impl, void *, EMPTYARG )
956cdf0e10cSrcweir {
957cdf0e10cSrcweir sal_uInt16 nPos = aLbColor.GetSelectEntryPos();
958cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir aValSetColorTable.SelectItem( nPos + 1 );
961cdf0e10cSrcweir aEdtName.SetText( aLbColor.GetSelectEntry() );
962cdf0e10cSrcweir
963cdf0e10cSrcweir rXFSet.Put( XFillColorItem( String(),
964cdf0e10cSrcweir aLbColor.GetSelectEntryColor() ) );
965cdf0e10cSrcweir aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
966cdf0e10cSrcweir aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
967cdf0e10cSrcweir
968cdf0e10cSrcweir aCtlPreviewOld.Invalidate();
969cdf0e10cSrcweir aCtlPreviewNew.Invalidate();
970cdf0e10cSrcweir
971cdf0e10cSrcweir ChangeColorHdl_Impl( this );
972cdf0e10cSrcweir }
973cdf0e10cSrcweir return( 0L );
974cdf0e10cSrcweir }
975cdf0e10cSrcweir
976cdf0e10cSrcweir //------------------------------------------------------------------------
977cdf0e10cSrcweir
IMPL_LINK(SvxColorTabPage,SelectValSetHdl_Impl,void *,EMPTYARG)978cdf0e10cSrcweir IMPL_LINK( SvxColorTabPage, SelectValSetHdl_Impl, void *, EMPTYARG )
979cdf0e10cSrcweir {
980cdf0e10cSrcweir sal_uInt16 nPos = aValSetColorTable.GetSelectItemId();
981cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND )
982cdf0e10cSrcweir {
983cdf0e10cSrcweir aLbColor.SelectEntryPos( nPos - 1 );
984cdf0e10cSrcweir aEdtName.SetText( aLbColor.GetSelectEntry() );
985cdf0e10cSrcweir
986cdf0e10cSrcweir rXFSet.Put( XFillColorItem( String(),
987cdf0e10cSrcweir aLbColor.GetSelectEntryColor() ) );
988cdf0e10cSrcweir aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
989cdf0e10cSrcweir aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
990cdf0e10cSrcweir
991cdf0e10cSrcweir aCtlPreviewOld.Invalidate();
992cdf0e10cSrcweir aCtlPreviewNew.Invalidate();
993cdf0e10cSrcweir
994cdf0e10cSrcweir ChangeColorHdl_Impl( this );
995cdf0e10cSrcweir }
996cdf0e10cSrcweir return( 0L );
997cdf0e10cSrcweir }
998cdf0e10cSrcweir
999cdf0e10cSrcweir //------------------------------------------------------------------------
1000cdf0e10cSrcweir
1001cdf0e10cSrcweir //
1002cdf0e10cSrcweir // Farbwerte je nach �bergebenes Farbmodell umrechnen
1003cdf0e10cSrcweir //
ConvertColorValues(Color & rColor,ColorModel eModell)1004cdf0e10cSrcweir void SvxColorTabPage::ConvertColorValues (Color& rColor, ColorModel eModell)
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir switch (eModell)
1007cdf0e10cSrcweir {
1008cdf0e10cSrcweir case CM_RGB:
1009cdf0e10cSrcweir {
1010cdf0e10cSrcweir CmykToRgb_Impl (rColor, (sal_uInt16)rColor.GetTransparency() );
1011cdf0e10cSrcweir rColor.SetTransparency ((sal_uInt8) 0);
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir break;
1014cdf0e10cSrcweir
1015cdf0e10cSrcweir case CM_CMYK:
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir sal_uInt16 nK;
1018cdf0e10cSrcweir RgbToCmyk_Impl (rColor, nK );
1019cdf0e10cSrcweir rColor.SetTransparency ((sal_uInt8) nK);
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir break;
1022cdf0e10cSrcweir }
1023cdf0e10cSrcweir }
1024cdf0e10cSrcweir
1025cdf0e10cSrcweir //
1026cdf0e10cSrcweir // Auswahl Listbox 'Farbmodell' (RGB/CMY)
1027cdf0e10cSrcweir //
IMPL_LINK(SvxColorTabPage,SelectColorModelHdl_Impl,void *,EMPTYARG)1028cdf0e10cSrcweir IMPL_LINK( SvxColorTabPage, SelectColorModelHdl_Impl, void *, EMPTYARG )
1029cdf0e10cSrcweir {
1030cdf0e10cSrcweir int nPos = aLbColorModel.GetSelectEntryPos();
1031cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND )
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir if (eCM != (ColorModel) nPos)
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir // wenn Farbmodell geaendert wurde, dann Werte umrechnen
1036cdf0e10cSrcweir ConvertColorValues (aAktuellColor, (ColorModel) nPos);
1037cdf0e10cSrcweir }
1038cdf0e10cSrcweir
1039cdf0e10cSrcweir eCM = (ColorModel) nPos;
1040cdf0e10cSrcweir
1041cdf0e10cSrcweir switch( eCM )
1042cdf0e10cSrcweir {
1043cdf0e10cSrcweir case CM_RGB:
1044cdf0e10cSrcweir {
1045cdf0e10cSrcweir String aStr( aLbColorModel.GetSelectEntry() );
1046cdf0e10cSrcweir String aColorStr( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "~X" ) ) );
1047cdf0e10cSrcweir xub_StrLen nIdx = 1;
1048cdf0e10cSrcweir aColorStr.SetChar( nIdx, aStr.GetChar( 0 ) );
1049cdf0e10cSrcweir aFtColorModel1.SetText( aColorStr );
1050cdf0e10cSrcweir aColorStr.SetChar( nIdx, aStr.GetChar( 1 ) );
1051cdf0e10cSrcweir aFtColorModel2.SetText( aColorStr );
1052cdf0e10cSrcweir aColorStr.SetChar( nIdx, aStr.GetChar( 2 ) );
1053cdf0e10cSrcweir aFtColorModel3.SetText( aColorStr );
1054cdf0e10cSrcweir
1055cdf0e10cSrcweir aFtColorModel4.Hide();
1056cdf0e10cSrcweir aMtrFldColorModel4.Hide();
1057cdf0e10cSrcweir aMtrFldColorModel4.SetValue( 0L );
1058cdf0e10cSrcweir
1059cdf0e10cSrcweir aMtrFldColorModel1.SetHelpId( HID_TPCOLOR_RGB_1 );
1060cdf0e10cSrcweir aMtrFldColorModel2.SetHelpId( HID_TPCOLOR_RGB_2 );
1061cdf0e10cSrcweir aMtrFldColorModel3.SetHelpId( HID_TPCOLOR_RGB_3 );
1062cdf0e10cSrcweir
1063cdf0e10cSrcweir // Da der alte HelpText noch am Control steht wuerde
1064cdf0e10cSrcweir // ein Umsetzen der HelpID alleine nichts bewirken
1065cdf0e10cSrcweir aMtrFldColorModel1.SetHelpText( String() );
1066cdf0e10cSrcweir aMtrFldColorModel2.SetHelpText( String() );
1067cdf0e10cSrcweir aMtrFldColorModel3.SetHelpText( String() );
1068cdf0e10cSrcweir
1069cdf0e10cSrcweir // RGB-Werte im Bereich 0..255 verarbeiten (nicht in %),
1070cdf0e10cSrcweir // dazu MetricField's entsprechend einstellen
1071cdf0e10cSrcweir aMtrFldColorModel1.SetUnit(FUNIT_NONE);
1072cdf0e10cSrcweir aMtrFldColorModel1.SetMin(0);
1073cdf0e10cSrcweir aMtrFldColorModel1.SetMax(255);
1074cdf0e10cSrcweir aMtrFldColorModel1.SetLast(255);
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir aMtrFldColorModel2.SetUnit(FUNIT_NONE);
1077cdf0e10cSrcweir aMtrFldColorModel2.SetMin(0);
1078cdf0e10cSrcweir aMtrFldColorModel2.SetMax(255);
1079cdf0e10cSrcweir aMtrFldColorModel2.SetLast(255);
1080cdf0e10cSrcweir
1081cdf0e10cSrcweir aMtrFldColorModel3.SetUnit(FUNIT_NONE);
1082cdf0e10cSrcweir aMtrFldColorModel3.SetMin(0);
1083cdf0e10cSrcweir aMtrFldColorModel3.SetMax(255);
1084cdf0e10cSrcweir aMtrFldColorModel3.SetLast(255);
1085cdf0e10cSrcweir }
1086cdf0e10cSrcweir break;
1087cdf0e10cSrcweir
1088cdf0e10cSrcweir case CM_CMYK:
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir String aStr( aLbColorModel.GetSelectEntry() );
1091cdf0e10cSrcweir String aColorStr( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "~X" ) ) );
1092cdf0e10cSrcweir xub_StrLen nIdx = 1;
1093cdf0e10cSrcweir aColorStr.SetChar( nIdx, aStr.GetChar( 0 ) );
1094cdf0e10cSrcweir aFtColorModel1.SetText( aColorStr );
1095cdf0e10cSrcweir aColorStr.SetChar( nIdx, aStr.GetChar( 1 ) );
1096cdf0e10cSrcweir aFtColorModel2.SetText( aColorStr );
1097cdf0e10cSrcweir aColorStr.SetChar( nIdx,aStr.GetChar( 2 ) );
1098cdf0e10cSrcweir aFtColorModel3.SetText( aColorStr );
1099cdf0e10cSrcweir aColorStr.SetChar( nIdx,aStr.GetChar( 3 ) );
1100cdf0e10cSrcweir aFtColorModel4.SetText( aColorStr );
1101cdf0e10cSrcweir
1102cdf0e10cSrcweir aFtColorModel4.Show();
1103cdf0e10cSrcweir aMtrFldColorModel4.Show();
1104cdf0e10cSrcweir
1105cdf0e10cSrcweir aMtrFldColorModel1.SetHelpId( HID_TPCOLOR_CMYK_1 );
1106cdf0e10cSrcweir aMtrFldColorModel2.SetHelpId( HID_TPCOLOR_CMYK_2 );
1107cdf0e10cSrcweir aMtrFldColorModel3.SetHelpId( HID_TPCOLOR_CMYK_3 );
1108cdf0e10cSrcweir
1109cdf0e10cSrcweir // s.o.
1110cdf0e10cSrcweir aMtrFldColorModel1.SetHelpText( String() );
1111cdf0e10cSrcweir aMtrFldColorModel2.SetHelpText( String() );
1112cdf0e10cSrcweir aMtrFldColorModel3.SetHelpText( String() );
1113cdf0e10cSrcweir
1114cdf0e10cSrcweir // CMYK-Werte im Bereich 0..100% verarbeiten,
1115cdf0e10cSrcweir // dazu MetricField's entsprechend einstellen
1116cdf0e10cSrcweir String aStrUnit( RTL_CONSTASCII_USTRINGPARAM( " %" ) );
1117cdf0e10cSrcweir
1118cdf0e10cSrcweir aMtrFldColorModel1.SetUnit(FUNIT_CUSTOM);
1119cdf0e10cSrcweir aMtrFldColorModel1.SetCustomUnitText( aStrUnit );
1120cdf0e10cSrcweir aMtrFldColorModel1.SetMin(0);
1121cdf0e10cSrcweir aMtrFldColorModel1.SetMax(100);
1122cdf0e10cSrcweir aMtrFldColorModel1.SetLast(100);
1123cdf0e10cSrcweir
1124cdf0e10cSrcweir aMtrFldColorModel2.SetUnit(FUNIT_CUSTOM);
1125cdf0e10cSrcweir aMtrFldColorModel2.SetCustomUnitText( aStrUnit );
1126cdf0e10cSrcweir aMtrFldColorModel2.SetMin(0);
1127cdf0e10cSrcweir aMtrFldColorModel2.SetMax(100);
1128cdf0e10cSrcweir aMtrFldColorModel2.SetLast(100);
1129cdf0e10cSrcweir
1130cdf0e10cSrcweir aMtrFldColorModel3.SetUnit(FUNIT_CUSTOM);
1131cdf0e10cSrcweir aMtrFldColorModel3.SetCustomUnitText( aStrUnit );
1132cdf0e10cSrcweir aMtrFldColorModel3.SetMin(0);
1133cdf0e10cSrcweir aMtrFldColorModel3.SetMax(100);
1134cdf0e10cSrcweir aMtrFldColorModel3.SetLast(100);
1135cdf0e10cSrcweir }
1136cdf0e10cSrcweir break;
1137cdf0e10cSrcweir }
1138cdf0e10cSrcweir
1139cdf0e10cSrcweir aMtrFldColorModel1.SetValue( ColorToPercent_Impl( aAktuellColor.GetRed() ) );
1140cdf0e10cSrcweir aMtrFldColorModel2.SetValue( ColorToPercent_Impl( aAktuellColor.GetGreen() ) );
1141cdf0e10cSrcweir aMtrFldColorModel3.SetValue( ColorToPercent_Impl( aAktuellColor.GetBlue() ) );
1142cdf0e10cSrcweir aMtrFldColorModel4.SetValue( ColorToPercent_Impl( aAktuellColor.GetTransparency() ) );
1143cdf0e10cSrcweir }
1144cdf0e10cSrcweir
1145cdf0e10cSrcweir aMtrFldColorModel1.SetAccessibleName( GetNonMnemonicString(aFtColorModel1.GetText()) );
1146cdf0e10cSrcweir aMtrFldColorModel2.SetAccessibleName( GetNonMnemonicString(aFtColorModel2.GetText()) );
1147cdf0e10cSrcweir aMtrFldColorModel3.SetAccessibleName( GetNonMnemonicString(aFtColorModel3.GetText()) );
1148cdf0e10cSrcweir aMtrFldColorModel4.SetAccessibleName( GetNonMnemonicString(aFtColorModel4.GetText()) );
1149cdf0e10cSrcweir
1150cdf0e10cSrcweir return( 0L );
1151cdf0e10cSrcweir }
1152cdf0e10cSrcweir
1153cdf0e10cSrcweir //------------------------------------------------------------------------
1154cdf0e10cSrcweir
ChangeColorHdl_Impl(void *)1155cdf0e10cSrcweir long SvxColorTabPage::ChangeColorHdl_Impl( void* )
1156cdf0e10cSrcweir {
1157cdf0e10cSrcweir int nPos = aLbColor.GetSelectEntryPos();
1158cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND )
1159cdf0e10cSrcweir {
1160c7be74b1SArmin Le Grand XColorEntry* pEntry = maColorTab->GetColor( nPos );
1161cdf0e10cSrcweir
1162cdf0e10cSrcweir aAktuellColor.SetColor ( pEntry->GetColor().GetColor() );
1163cdf0e10cSrcweir if (eCM != CM_RGB)
1164cdf0e10cSrcweir ConvertColorValues (aAktuellColor, eCM);
1165cdf0e10cSrcweir
1166cdf0e10cSrcweir aMtrFldColorModel1.SetValue( ColorToPercent_Impl( aAktuellColor.GetRed() ) );
1167cdf0e10cSrcweir aMtrFldColorModel2.SetValue( ColorToPercent_Impl( aAktuellColor.GetGreen() ) );
1168cdf0e10cSrcweir aMtrFldColorModel3.SetValue( ColorToPercent_Impl( aAktuellColor.GetBlue() ) );
1169cdf0e10cSrcweir aMtrFldColorModel4.SetValue( ColorToPercent_Impl( aAktuellColor.GetTransparency() ) );
1170cdf0e10cSrcweir
1171cdf0e10cSrcweir // ItemSet fuellen und an XOut weiterleiten
1172cdf0e10cSrcweir rXFSet.Put( XFillColorItem( String(), pEntry->GetColor() ) );
1173cdf0e10cSrcweir aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
1174cdf0e10cSrcweir aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
1175cdf0e10cSrcweir
1176cdf0e10cSrcweir aCtlPreviewNew.Invalidate();
1177cdf0e10cSrcweir }
1178cdf0e10cSrcweir return( 0L );
1179cdf0e10cSrcweir }
1180cdf0e10cSrcweir
1181cdf0e10cSrcweir //------------------------------------------------------------------------
1182cdf0e10cSrcweir
118328bcfa49SArmin Le Grand //void SvxColorTabPage::FillValueSet_Impl( ValueSet& rVs )
118428bcfa49SArmin Le Grand //{
1185c7be74b1SArmin Le Grand // long nCount = maColorTab->Count();
118628bcfa49SArmin Le Grand // XColorEntry* pColorEntry;
118728bcfa49SArmin Le Grand //
118828bcfa49SArmin Le Grand // for( long i = 0; i < nCount; i++ )
118928bcfa49SArmin Le Grand // {
1190c7be74b1SArmin Le Grand // pColorEntry = maColorTab->GetColor( i );
119128bcfa49SArmin Le Grand // rVs.InsertItem( (sal_uInt16) i + 1, pColorEntry->GetColor(), pColorEntry->GetName() );
119228bcfa49SArmin Le Grand // }
119328bcfa49SArmin Le Grand //}
1194cdf0e10cSrcweir
1195cdf0e10cSrcweir //------------------------------------------------------------------------
1196cdf0e10cSrcweir
1197cdf0e10cSrcweir // Ein RGB-Wert wird in einen CMYK-Wert konvertiert, wobei die Color-
1198cdf0e10cSrcweir // Klasse vergewaltigt wird, da R in C, G in M und B in Y umgewandelt
1199cdf0e10cSrcweir // wird. Der Wert K wird in einer Extra-Variablen gehalten.
1200cdf0e10cSrcweir // Bei weiteren Farbmodellen sollte man hierfuer eigene Klassen entwickeln,
1201cdf0e10cSrcweir // die dann auch entsprechende Casts enthalten.
1202cdf0e10cSrcweir
RgbToCmyk_Impl(Color & rColor,sal_uInt16 & rK)1203cdf0e10cSrcweir void SvxColorTabPage::RgbToCmyk_Impl( Color& rColor, sal_uInt16& rK )
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir sal_uInt16 nColor1, nColor2, nColor3;
1206cdf0e10cSrcweir sal_uInt16 nProzent; // nur temporaer !!!
1207cdf0e10cSrcweir
1208cdf0e10cSrcweir nColor1 = 255 - rColor.GetRed();
1209cdf0e10cSrcweir nProzent = ColorToPercent_Impl( nColor1 );
1210cdf0e10cSrcweir
1211cdf0e10cSrcweir nColor2 = 255 - rColor.GetGreen();
1212cdf0e10cSrcweir nProzent = ColorToPercent_Impl( nColor2 );
1213cdf0e10cSrcweir
1214cdf0e10cSrcweir nColor3 = 255 - rColor.GetBlue();
1215cdf0e10cSrcweir nProzent = ColorToPercent_Impl( nColor3 );
1216cdf0e10cSrcweir
1217cdf0e10cSrcweir rK = Min( Min( nColor1, nColor2 ), nColor3 );
1218cdf0e10cSrcweir
1219cdf0e10cSrcweir rColor.SetRed( sal::static_int_cast< sal_uInt8 >( nColor1 - rK ) );
1220cdf0e10cSrcweir rColor.SetGreen( sal::static_int_cast< sal_uInt8 >( nColor2 - rK ) );
1221cdf0e10cSrcweir rColor.SetBlue( sal::static_int_cast< sal_uInt8 >( nColor3 - rK ) );
1222cdf0e10cSrcweir }
1223cdf0e10cSrcweir
1224cdf0e10cSrcweir //------------------------------------------------------------------------
1225cdf0e10cSrcweir
1226cdf0e10cSrcweir // Umgekehrter Fall zu RgbToCmyk_Impl (s.o.)
1227cdf0e10cSrcweir
CmykToRgb_Impl(Color & rColor,const sal_uInt16 nK)1228cdf0e10cSrcweir void SvxColorTabPage::CmykToRgb_Impl( Color& rColor, const sal_uInt16 nK )
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir long lTemp;
1231cdf0e10cSrcweir
1232cdf0e10cSrcweir lTemp = 255 - ( rColor.GetRed() + nK );
1233cdf0e10cSrcweir
1234cdf0e10cSrcweir if( lTemp < 0L )
1235cdf0e10cSrcweir lTemp = 0L;
1236cdf0e10cSrcweir rColor.SetRed( (sal_uInt8)lTemp );
1237cdf0e10cSrcweir
1238cdf0e10cSrcweir lTemp = 255 - ( rColor.GetGreen() + nK );
1239cdf0e10cSrcweir
1240cdf0e10cSrcweir if( lTemp < 0L )
1241cdf0e10cSrcweir lTemp = 0L;
1242cdf0e10cSrcweir rColor.SetGreen( (sal_uInt8)lTemp );
1243cdf0e10cSrcweir
1244cdf0e10cSrcweir lTemp = 255 - ( rColor.GetBlue() + nK );
1245cdf0e10cSrcweir
1246cdf0e10cSrcweir if( lTemp < 0L )
1247cdf0e10cSrcweir lTemp = 0L;
1248cdf0e10cSrcweir rColor.SetBlue( (sal_uInt8)lTemp );
1249cdf0e10cSrcweir }
1250cdf0e10cSrcweir
1251cdf0e10cSrcweir //------------------------------------------------------------------------
1252cdf0e10cSrcweir
ColorToPercent_Impl(sal_uInt16 nColor)1253cdf0e10cSrcweir sal_uInt16 SvxColorTabPage::ColorToPercent_Impl( sal_uInt16 nColor )
1254cdf0e10cSrcweir {
1255cdf0e10cSrcweir sal_uInt16 nWert = 0;
1256cdf0e10cSrcweir
1257cdf0e10cSrcweir switch (eCM)
1258cdf0e10cSrcweir {
1259cdf0e10cSrcweir case CM_RGB :
1260cdf0e10cSrcweir nWert = nColor;
1261cdf0e10cSrcweir break;
1262cdf0e10cSrcweir
1263cdf0e10cSrcweir case CM_CMYK:
1264cdf0e10cSrcweir nWert = (sal_uInt16) ( (double) nColor * 100.0 / 255.0 + 0.5 );
1265cdf0e10cSrcweir break;
1266cdf0e10cSrcweir }
1267cdf0e10cSrcweir
1268cdf0e10cSrcweir return ( nWert );
1269cdf0e10cSrcweir }
1270cdf0e10cSrcweir
1271cdf0e10cSrcweir //------------------------------------------------------------------------
1272cdf0e10cSrcweir
PercentToColor_Impl(sal_uInt16 nPercent)1273cdf0e10cSrcweir sal_uInt16 SvxColorTabPage::PercentToColor_Impl( sal_uInt16 nPercent )
1274cdf0e10cSrcweir {
1275cdf0e10cSrcweir sal_uInt16 nWert = 0;
1276cdf0e10cSrcweir
1277cdf0e10cSrcweir switch (eCM)
1278cdf0e10cSrcweir {
1279cdf0e10cSrcweir case CM_RGB :
1280cdf0e10cSrcweir nWert = nPercent;
1281cdf0e10cSrcweir break;
1282cdf0e10cSrcweir
1283cdf0e10cSrcweir case CM_CMYK:
1284cdf0e10cSrcweir nWert = (sal_uInt16) ( (double) nPercent * 255.0 / 100.0 + 0.5 );
1285cdf0e10cSrcweir break;
1286cdf0e10cSrcweir }
1287cdf0e10cSrcweir
1288cdf0e10cSrcweir return ( nWert );
1289cdf0e10cSrcweir }
1290cdf0e10cSrcweir
1291cdf0e10cSrcweir //------------------------------------------------------------------------
1292cdf0e10cSrcweir
FillUserData()1293cdf0e10cSrcweir void SvxColorTabPage::FillUserData()
1294cdf0e10cSrcweir {
1295cdf0e10cSrcweir // Das Farbmodell wird in der Ini-Datei festgehalten
1296cdf0e10cSrcweir SetUserData( UniString::CreateFromInt32( eCM ) );
1297cdf0e10cSrcweir }
1298cdf0e10cSrcweir
1299cdf0e10cSrcweir
1300