Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <vcl/wrkwin.hxx>
30 : : #include <tools/shl.hxx>
31 : : #include <tools/urlobj.hxx>
32 : : #include <vcl/msgbox.hxx>
33 : : #include <unotools/pathoptions.hxx>
34 : : #include <sfx2/app.hxx>
35 : : #include <sfx2/filedlghelper.hxx>
36 : : #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
37 : :
38 : : #define _SVX_TPGRADNT_CXX
39 : :
40 : : #include <cuires.hrc>
41 : : #include "helpid.hrc"
42 : : #include "svx/xattr.hxx"
43 : : #include <svx/xtable.hxx>
44 : : #include <svx/xpool.hxx>
45 : : #include "svx/drawitem.hxx"
46 : : #include "cuitabarea.hxx"
47 : : #include "tabarea.hrc"
48 : : #include "defdlgname.hxx"
49 : : #include <svx/svxdlg.hxx>
50 : : #include <dialmgr.hxx>
51 : : #include <svx/dialmgr.hxx>
52 : : #include <svx/dialogs.hrc>
53 : : #include "paragrph.hrc"
54 : :
55 : 0 : SvxGradientTabPage::SvxGradientTabPage
56 : : (
57 : : Window* pParent,
58 : : const SfxItemSet& rInAttrs
59 : : ) :
60 : 0 : SfxTabPage ( pParent, CUI_RES( RID_SVXPAGE_GRADIENT ), rInAttrs ),
61 : :
62 [ # # ]: 0 : aFlProp ( this, CUI_RES( FL_PROP ) ),
63 [ # # ]: 0 : aFtType ( this, CUI_RES( FT_TYPE ) ),
64 [ # # ]: 0 : aLbGradientType ( this, CUI_RES( LB_GRADIENT_TYPES ) ),
65 [ # # ]: 0 : aFtCenterX ( this, CUI_RES( FT_CENTER_X ) ),
66 [ # # ]: 0 : aMtrCenterX ( this, CUI_RES( MTR_CENTER_X ) ),
67 [ # # ]: 0 : aFtCenterY ( this, CUI_RES( FT_CENTER_Y ) ),
68 [ # # ]: 0 : aMtrCenterY ( this, CUI_RES( MTR_CENTER_Y ) ),
69 [ # # ]: 0 : aFtAngle ( this, CUI_RES( FT_ANGLE ) ),
70 [ # # ]: 0 : aMtrAngle ( this, CUI_RES( MTR_ANGLE ) ),
71 [ # # ]: 0 : aFtBorder ( this, CUI_RES( FT_BORDER ) ),
72 [ # # ]: 0 : aMtrBorder ( this, CUI_RES( MTR_BORDER ) ),
73 [ # # ]: 0 : aFtColorFrom ( this, CUI_RES( FT_COLOR_FROM ) ),
74 [ # # ]: 0 : aLbColorFrom ( this, CUI_RES( LB_COLOR_FROM ) ),
75 [ # # ]: 0 : aMtrColorFrom ( this, CUI_RES( MTR_COLOR_FROM ) ),
76 [ # # ]: 0 : aFtColorTo ( this, CUI_RES( FT_COLOR_TO ) ),
77 [ # # ]: 0 : aLbColorTo ( this, CUI_RES( LB_COLOR_TO ) ),
78 [ # # ]: 0 : aMtrColorTo ( this, CUI_RES( MTR_COLOR_TO ) ),
79 [ # # ]: 0 : aLbGradients ( this, CUI_RES( LB_GRADIENTS ) ),
80 [ # # ]: 0 : aCtlPreview ( this, CUI_RES( CTL_PREVIEW ) ),
81 [ # # ]: 0 : aBtnAdd ( this, CUI_RES( BTN_ADD ) ),
82 [ # # ]: 0 : aBtnModify ( this, CUI_RES( BTN_MODIFY ) ),
83 [ # # ]: 0 : aBtnDelete ( this, CUI_RES( BTN_DELETE ) ),
84 [ # # ]: 0 : aBtnLoad ( this, CUI_RES( BTN_LOAD ) ),
85 [ # # ]: 0 : aBtnSave ( this, CUI_RES( BTN_SAVE ) ),
86 : :
87 : : rOutAttrs ( rInAttrs ),
88 : :
89 : 0 : pXPool ( (XOutdevItemPool*) rInAttrs.GetPool() ),
90 : : aXFStyleItem ( XFILL_GRADIENT ),
91 : : aXGradientItem ( String(), XGradient( COL_BLACK, COL_WHITE ) ),
92 : : aXFillAttr ( pXPool ),
93 [ # # ][ # # ]: 0 : rXFSet ( aXFillAttr.GetItemSet() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
94 : : {
95 [ # # ]: 0 : FreeResource();
96 : :
97 [ # # ][ # # ]: 0 : aCtlPreview.SetAccessibleName(String(CUI_RES(STR_EXAMPLE)));
[ # # ][ # # ]
98 [ # # ][ # # ]: 0 : aLbGradients.SetAccessibleName( GetText());
[ # # ]
99 : :
100 : :
101 : : // this page needs ExchangeSupport
102 : 0 : SetExchangeSupport();
103 : :
104 : : // as long as NOT supported by the item
105 : :
106 [ # # ]: 0 : aMtrColorTo.SetValue( 100 );
107 [ # # ]: 0 : aMtrColorFrom.SetValue( 100 );
108 : :
109 : : // setting the output device
110 [ # # ]: 0 : rXFSet.Put( aXFStyleItem );
111 [ # # ]: 0 : rXFSet.Put( aXGradientItem );
112 [ # # ]: 0 : aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
113 : :
114 : : // overload the handler
115 : : aLbGradients.SetSelectHdl(
116 [ # # ]: 0 : LINK( this, SvxGradientTabPage, ChangeGradientHdl_Impl ) );
117 [ # # ]: 0 : aBtnAdd.SetClickHdl( LINK( this, SvxGradientTabPage, ClickAddHdl_Impl ) );
118 : : aBtnModify.SetClickHdl(
119 [ # # ]: 0 : LINK( this, SvxGradientTabPage, ClickModifyHdl_Impl ) );
120 : : aBtnDelete.SetClickHdl(
121 [ # # ]: 0 : LINK( this, SvxGradientTabPage, ClickDeleteHdl_Impl ) );
122 : :
123 [ # # ]: 0 : Link aLink = LINK( this, SvxGradientTabPage, ModifiedHdl_Impl );
124 : 0 : aLbGradientType.SetSelectHdl( aLink );
125 : 0 : aMtrCenterX.SetModifyHdl( aLink );
126 : 0 : aMtrCenterY.SetModifyHdl( aLink );
127 : 0 : aMtrAngle.SetModifyHdl( aLink );
128 : 0 : aMtrBorder.SetModifyHdl( aLink );
129 : 0 : aMtrColorFrom.SetModifyHdl( aLink );
130 : 0 : aLbColorFrom.SetSelectHdl( aLink );
131 : 0 : aMtrColorTo.SetModifyHdl( aLink );
132 : 0 : aLbColorTo.SetSelectHdl( aLink );
133 : :
134 : : aBtnLoad.SetClickHdl(
135 [ # # ]: 0 : LINK( this, SvxGradientTabPage, ClickLoadHdl_Impl ) );
136 : : aBtnSave.SetClickHdl(
137 [ # # ]: 0 : LINK( this, SvxGradientTabPage, ClickSaveHdl_Impl ) );
138 : :
139 [ # # ]: 0 : aBtnAdd.SetAccessibleRelationMemberOf( &aFlProp );
140 [ # # ]: 0 : aBtnModify.SetAccessibleRelationMemberOf( &aFlProp );
141 [ # # ]: 0 : aBtnDelete.SetAccessibleRelationMemberOf( &aFlProp );
142 [ # # ]: 0 : aLbGradients.SetAccessibleRelationLabeledBy(&aLbGradients);
143 : :
144 : : // #i76307# always paint the preview in LTR, because this is what the document does
145 [ # # ]: 0 : aCtlPreview.EnableRTL( sal_False );
146 : 0 : }
147 : :
148 : : // -----------------------------------------------------------------------
149 : :
150 : 0 : void SvxGradientTabPage::Construct()
151 : : {
152 : 0 : aLbColorFrom.Fill( pColorList );
153 : 0 : aLbColorTo.CopyEntries( aLbColorFrom );
154 : :
155 : 0 : aLbGradients.Fill( pGradientList );
156 : 0 : }
157 : :
158 : : // -----------------------------------------------------------------------
159 : :
160 : 0 : void SvxGradientTabPage::ActivatePage( const SfxItemSet& )
161 : : {
162 : : sal_uInt16 nPos;
163 : : sal_uInt16 nCount;
164 : :
165 [ # # ]: 0 : if( *pDlgType == 0 ) // area dialog
166 : : {
167 : 0 : *pbAreaTP = sal_False;
168 : :
169 [ # # ]: 0 : if( pColorList.is() )
170 : : {
171 : : // ColorList
172 [ # # ][ # # ]: 0 : if( *pnColorListState & CT_CHANGED ||
173 : : *pnColorListState & CT_MODIFIED )
174 : : {
175 [ # # ]: 0 : if( *pnColorListState & CT_CHANGED )
176 [ # # ][ # # ]: 0 : pColorList = ( (SvxAreaTabDialog*) GetParentDialog() )->GetNewColorList();
[ # # ]
177 : :
178 : : // LbColorFrom
179 [ # # ]: 0 : nPos = aLbColorFrom.GetSelectEntryPos();
180 [ # # ]: 0 : aLbColorFrom.Clear();
181 [ # # ]: 0 : aLbColorFrom.Fill( pColorList );
182 [ # # ]: 0 : nCount = aLbColorFrom.GetEntryCount();
183 [ # # ]: 0 : if( nCount == 0 )
184 : : ; // this case should not occur
185 [ # # ]: 0 : else if( nCount <= nPos )
186 [ # # ]: 0 : aLbColorFrom.SelectEntryPos( 0 );
187 : : else
188 [ # # ]: 0 : aLbColorFrom.SelectEntryPos( nPos );
189 : :
190 : : // LbColorTo
191 [ # # ]: 0 : nPos = aLbColorTo.GetSelectEntryPos();
192 [ # # ]: 0 : aLbColorTo.Clear();
193 [ # # ]: 0 : aLbColorTo.CopyEntries( aLbColorFrom );
194 [ # # ]: 0 : nCount = aLbColorTo.GetEntryCount();
195 [ # # ]: 0 : if( nCount == 0 )
196 : : ; // this case should not occur
197 [ # # ]: 0 : else if( nCount <= nPos )
198 [ # # ]: 0 : aLbColorTo.SelectEntryPos( 0 );
199 : : else
200 [ # # ]: 0 : aLbColorTo.SelectEntryPos( nPos );
201 : :
202 [ # # ]: 0 : ModifiedHdl_Impl( this );
203 : : }
204 : :
205 : : // determining (and possibly cutting) the name and
206 : : // displaying it in the GroupBox
207 [ # # ][ # # ]: 0 : String aString( CUI_RES( RID_SVXSTR_TABLE ) ); aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
[ # # ]
208 [ # # ][ # # ]: 0 : INetURLObject aURL( pGradientList->GetPath() );
209 : :
210 [ # # ][ # # ]: 0 : aURL.Append( pGradientList->GetName() );
211 : : DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
212 : :
213 [ # # ][ # # ]: 0 : if ( aURL.getBase().getLength() > 18 )
214 : : {
215 [ # # ][ # # ]: 0 : aString += String(aURL.getBase()).Copy( 0, 15 );
[ # # ][ # # ]
[ # # ][ # # ]
216 [ # # ]: 0 : aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
217 : : }
218 : : else
219 [ # # ][ # # ]: 0 : aString += String(aURL.getBase());
[ # # ][ # # ]
220 : :
221 [ # # ][ # # ]: 0 : if ( *pPageType == PT_GRADIENT && *pPos != LISTBOX_ENTRY_NOTFOUND )
222 : : {
223 [ # # ]: 0 : aLbGradients.SelectEntryPos( *pPos );
224 : : }
225 : : // colors could have been deleted
226 [ # # ]: 0 : ChangeGradientHdl_Impl( this );
227 : :
228 : 0 : *pPageType = PT_GRADIENT;
229 [ # # ][ # # ]: 0 : *pPos = LISTBOX_ENTRY_NOTFOUND;
230 : : }
231 : : }
232 : 0 : }
233 : :
234 : : // -----------------------------------------------------------------------
235 : :
236 : 0 : int SvxGradientTabPage::DeactivatePage( SfxItemSet* _pSet )
237 : : {
238 [ # # ]: 0 : if( CheckChanges_Impl() == -1L )
239 : 0 : return KEEP_PAGE;
240 : :
241 [ # # ]: 0 : if( _pSet )
242 : 0 : FillItemSet( *_pSet );
243 : :
244 : 0 : return LEAVE_PAGE;
245 : : }
246 : :
247 : : // -----------------------------------------------------------------------
248 : :
249 : 0 : long SvxGradientTabPage::CheckChanges_Impl()
250 : : {
251 : : // is used here in order to NOT lose changes
252 : 0 : XGradient aTmpGradient( aLbColorFrom.GetSelectEntryColor(),
253 : 0 : aLbColorTo.GetSelectEntryColor(),
254 [ # # ]: 0 : (XGradientStyle) aLbGradientType.GetSelectEntryPos(),
255 [ # # ]: 0 : static_cast<long>(aMtrAngle.GetValue() * 10), // should be changed in resource
256 [ # # ]: 0 : (sal_uInt16) aMtrCenterX.GetValue(),
257 [ # # ]: 0 : (sal_uInt16) aMtrCenterY.GetValue(),
258 [ # # ]: 0 : (sal_uInt16) aMtrBorder.GetValue(),
259 [ # # ]: 0 : (sal_uInt16) aMtrColorFrom.GetValue(),
260 [ # # ][ # # ]: 0 : (sal_uInt16) aMtrColorTo.GetValue() );
[ # # ][ # # ]
261 : :
262 [ # # ]: 0 : sal_uInt16 nPos = aLbGradients.GetSelectEntryPos();
263 [ # # ]: 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
264 : : {
265 [ # # ]: 0 : XGradient aGradient = pGradientList->GetGradient( nPos )->GetGradient();
266 [ # # ]: 0 : String aString = aLbGradients.GetSelectEntry();
267 : :
268 [ # # ][ # # ]: 0 : if( !( aTmpGradient == aGradient ) )
269 : : {
270 [ # # ]: 0 : ResMgr& rMgr = CUI_MGR();
271 [ # # ]: 0 : Image aWarningBoxImage = WarningBox::GetStandardImage();
272 [ # # ]: 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
273 : : DBG_ASSERT(pFact, "Dialogdiet fail!");
274 : : AbstractSvxMessDialog* aMessDlg = pFact->CreateSvxMessDialog( GetParentDialog(), RID_SVXDLG_MESSBOX,
275 [ # # ]: 0 : SVX_RESSTR( RID_SVXSTR_GRADIENT ),
276 [ # # ]: 0 : CUI_RESSTR( RID_SVXSTR_ASK_CHANGE_GRADIENT ),
277 [ # # ][ # # ]: 0 : &aWarningBoxImage );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
278 : : DBG_ASSERT(aMessDlg, "Dialogdiet fail!");
279 : : aMessDlg->SetButtonText( MESS_BTN_1,
280 [ # # ][ # # ]: 0 : String( ResId( RID_SVXSTR_CHANGE, rMgr ) ) );
[ # # ]
281 : : aMessDlg->SetButtonText( MESS_BTN_2,
282 [ # # ][ # # ]: 0 : String( ResId( RID_SVXSTR_ADD, rMgr ) ) );
[ # # ]
283 : :
284 [ # # ]: 0 : short nRet = aMessDlg->Execute();
285 : :
286 [ # # # # ]: 0 : switch( nRet )
287 : : {
288 : : case RET_BTN_1:
289 : : {
290 [ # # ]: 0 : ClickModifyHdl_Impl( this );
291 [ # # ]: 0 : aGradient = pGradientList->GetGradient( nPos )->GetGradient();
292 : : }
293 : 0 : break;
294 : :
295 : : case RET_BTN_2:
296 : : {
297 [ # # ]: 0 : ClickAddHdl_Impl( this );
298 [ # # ]: 0 : nPos = aLbGradients.GetSelectEntryPos();
299 [ # # ]: 0 : aGradient = pGradientList->GetGradient( nPos )->GetGradient();
300 : : }
301 : 0 : break;
302 : :
303 : : case RET_CANCEL:
304 : 0 : break;
305 : : }
306 [ # # ][ # # ]: 0 : delete aMessDlg;
[ # # ]
307 [ # # ]: 0 : }
308 : : }
309 [ # # ]: 0 : nPos = aLbGradients.GetSelectEntryPos();
310 [ # # ]: 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
311 : : {
312 : 0 : *pPos = nPos;
313 : : }
314 : 0 : return 0L;
315 : : }
316 : :
317 : : // -----------------------------------------------------------------------
318 : :
319 : 0 : sal_Bool SvxGradientTabPage::FillItemSet( SfxItemSet& rSet )
320 : : {
321 [ # # ][ # # ]: 0 : if( *pDlgType == 0 && *pPageType == PT_GRADIENT && *pbAreaTP == sal_False )
[ # # ]
322 : : {
323 : : // CheckChanges(); <-- duplicate inquiry ?
324 : :
325 : 0 : XGradient* pXGradient = NULL;
326 [ # # ]: 0 : String aString;
327 [ # # ]: 0 : sal_uInt16 nPos = aLbGradients.GetSelectEntryPos();
328 [ # # ]: 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
329 : : {
330 [ # # ][ # # ]: 0 : pXGradient = new XGradient( pGradientList->GetGradient( nPos )->GetGradient() );
331 [ # # ][ # # ]: 0 : aString = aLbGradients.GetSelectEntry();
[ # # ]
332 : :
333 : : }
334 : : else
335 : : // gradient was passed (unidentified)
336 : : {
337 : 0 : pXGradient = new XGradient( aLbColorFrom.GetSelectEntryColor(),
338 : 0 : aLbColorTo.GetSelectEntryColor(),
339 [ # # ]: 0 : (XGradientStyle) aLbGradientType.GetSelectEntryPos(),
340 [ # # ]: 0 : static_cast<long>(aMtrAngle.GetValue() * 10), // should be changed in resource
341 [ # # ]: 0 : (sal_uInt16) aMtrCenterX.GetValue(),
342 [ # # ]: 0 : (sal_uInt16) aMtrCenterY.GetValue(),
343 [ # # ]: 0 : (sal_uInt16) aMtrBorder.GetValue(),
344 [ # # ]: 0 : (sal_uInt16) aMtrColorFrom.GetValue(),
345 [ # # ][ # # ]: 0 : (sal_uInt16) aMtrColorTo.GetValue() );
[ # # ][ # # ]
[ # # ]
346 : : }
347 : : DBG_ASSERT( pXGradient, "XGradient konnte nicht erzeugt werden" );
348 [ # # ][ # # ]: 0 : rSet.Put( XFillStyleItem( XFILL_GRADIENT ) );
[ # # ]
349 [ # # ][ # # ]: 0 : rSet.Put( XFillGradientItem( aString, *pXGradient ) );
[ # # ]
350 : :
351 [ # # ]: 0 : delete pXGradient;
352 : : }
353 : 0 : return sal_True;
354 : : }
355 : :
356 : : // -----------------------------------------------------------------------
357 : :
358 : 0 : void SvxGradientTabPage::Reset( const SfxItemSet& )
359 : : {
360 : : // aLbGradients.SelectEntryPos( 0 );
361 : 0 : ChangeGradientHdl_Impl( this );
362 : :
363 : : // determine state of the buttons
364 [ # # ]: 0 : if( pGradientList->Count() )
365 : : {
366 : 0 : aBtnModify.Enable();
367 : 0 : aBtnDelete.Enable();
368 : 0 : aBtnSave.Enable();
369 : : }
370 : : else
371 : : {
372 : 0 : aBtnModify.Disable();
373 : 0 : aBtnDelete.Disable();
374 : 0 : aBtnSave.Disable();
375 : : }
376 : 0 : }
377 : :
378 : : // -----------------------------------------------------------------------
379 : :
380 : 0 : SfxTabPage* SvxGradientTabPage::Create( Window* pWindow,
381 : : const SfxItemSet& rOutAttrs )
382 : : {
383 [ # # ]: 0 : return new SvxGradientTabPage( pWindow, rOutAttrs );
384 : : }
385 : :
386 : : //------------------------------------------------------------------------
387 : :
388 : 0 : IMPL_LINK( SvxGradientTabPage, ModifiedHdl_Impl, void *, pControl )
389 : : {
390 [ # # ]: 0 : XGradientStyle eXGS = (XGradientStyle) aLbGradientType.GetSelectEntryPos();
391 : :
392 : 0 : XGradient aXGradient( aLbColorFrom.GetSelectEntryColor(),
393 : 0 : aLbColorTo.GetSelectEntryColor(),
394 : : eXGS,
395 [ # # ]: 0 : static_cast<long>(aMtrAngle.GetValue() * 10), // should be changed in resource
396 [ # # ]: 0 : (sal_uInt16) aMtrCenterX.GetValue(),
397 [ # # ]: 0 : (sal_uInt16) aMtrCenterY.GetValue(),
398 [ # # ]: 0 : (sal_uInt16) aMtrBorder.GetValue(),
399 [ # # ]: 0 : (sal_uInt16) aMtrColorFrom.GetValue(),
400 [ # # ][ # # ]: 0 : (sal_uInt16) aMtrColorTo.GetValue() );
[ # # ][ # # ]
401 : :
402 : : // enable/disable controls
403 [ # # ][ # # ]: 0 : if( pControl == &aLbGradientType || pControl == this )
404 [ # # ]: 0 : SetControlState_Impl( eXGS );
405 : :
406 : : // displaying in XOutDev
407 [ # # ][ # # ]: 0 : rXFSet.Put( XFillGradientItem( String(), aXGradient ) );
[ # # ][ # # ]
[ # # ]
408 [ # # ]: 0 : aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
409 : :
410 [ # # ]: 0 : aCtlPreview.Invalidate();
411 : :
412 : 0 : return 0L;
413 : : }
414 : :
415 : : //------------------------------------------------------------------------
416 : :
417 : 0 : IMPL_LINK_NOARG(SvxGradientTabPage, ClickAddHdl_Impl)
418 : : {
419 [ # # ]: 0 : ResMgr& rMgr = CUI_MGR();
420 [ # # ][ # # ]: 0 : String aNewName( SVX_RES( RID_SVXSTR_GRADIENT ) );
421 [ # # ][ # # ]: 0 : String aDesc( CUI_RES( RID_SVXSTR_DESC_GRADIENT ) );
422 [ # # ]: 0 : String aName;
423 : :
424 [ # # ]: 0 : long nCount = pGradientList->Count();
425 : 0 : long j = 1;
426 : 0 : sal_Bool bDifferent = sal_False;
427 : :
428 [ # # ]: 0 : while( !bDifferent )
429 : : {
430 [ # # ]: 0 : aName = aNewName;
431 [ # # ]: 0 : aName += sal_Unicode(' ');
432 [ # # ][ # # ]: 0 : aName += UniString::CreateFromInt32( j++ );
[ # # ]
433 : 0 : bDifferent = sal_True;
434 : :
435 [ # # ][ # # ]: 0 : for( long i = 0; i < nCount && bDifferent; i++ )
[ # # ]
436 [ # # ][ # # ]: 0 : if( aName == pGradientList->GetGradient( i )->GetName() )
[ # # ]
437 : 0 : bDifferent = sal_False;
438 : : }
439 : :
440 [ # # ]: 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
441 : : DBG_ASSERT(pFact, "Dialogdiet fail!");
442 [ # # ][ # # ]: 0 : AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc );
443 : : DBG_ASSERT(pDlg, "Dialogdiet fail!");
444 : 0 : WarningBox* pWarnBox = NULL;
445 : 0 : sal_uInt16 nError = RID_SVXSTR_WARN_NAME_DUPLICATE;
446 : :
447 [ # # ][ # # ]: 0 : while( pDlg->Execute() == RET_OK )
448 : : {
449 [ # # ]: 0 : pDlg->GetName( aName );
450 : :
451 : 0 : bDifferent = sal_True;
452 : :
453 [ # # ][ # # ]: 0 : for( long i = 0; i < nCount && bDifferent; i++ )
[ # # ]
454 [ # # ][ # # ]: 0 : if( aName == pGradientList->GetGradient( i )->GetName() )
[ # # ]
455 : 0 : bDifferent = sal_False;
456 : :
457 [ # # ]: 0 : if( bDifferent )
458 : : {
459 : 0 : nError = 0;
460 : 0 : break;
461 : : }
462 : :
463 [ # # ]: 0 : if( !pWarnBox )
464 : : {
465 : 0 : pWarnBox = new WarningBox( GetParentDialog(),
466 : : WinBits( WB_OK_CANCEL ),
467 [ # # ][ # # ]: 0 : String( ResId( nError, rMgr ) ) );
[ # # ][ # # ]
[ # # ]
468 [ # # ]: 0 : pWarnBox->SetHelpId( HID_WARN_NAME_DUPLICATE );
469 : : }
470 : :
471 [ # # ][ # # ]: 0 : if( pWarnBox->Execute() != RET_OK )
472 : 0 : break;
473 : : }
474 [ # # ][ # # ]: 0 : delete pDlg;
475 [ # # ][ # # ]: 0 : delete pWarnBox;
476 : :
477 [ # # ]: 0 : if( !nError )
478 : : {
479 : 0 : XGradient aXGradient( aLbColorFrom.GetSelectEntryColor(),
480 : 0 : aLbColorTo.GetSelectEntryColor(),
481 [ # # ]: 0 : (XGradientStyle) aLbGradientType.GetSelectEntryPos(),
482 [ # # ]: 0 : static_cast<long>(aMtrAngle.GetValue() * 10), // should be changed in resource
483 [ # # ]: 0 : (sal_uInt16) aMtrCenterX.GetValue(),
484 [ # # ]: 0 : (sal_uInt16) aMtrCenterY.GetValue(),
485 [ # # ]: 0 : (sal_uInt16) aMtrBorder.GetValue(),
486 [ # # ]: 0 : (sal_uInt16) aMtrColorFrom.GetValue(),
487 [ # # ][ # # ]: 0 : (sal_uInt16) aMtrColorTo.GetValue() );
[ # # ][ # # ]
488 [ # # ][ # # ]: 0 : XGradientEntry* pEntry = new XGradientEntry( aXGradient, aName );
489 : :
490 [ # # ]: 0 : pGradientList->Insert( pEntry, nCount );
491 : :
492 [ # # ]: 0 : aLbGradients.Append( pEntry );
493 : :
494 [ # # ][ # # ]: 0 : aLbGradients.SelectEntryPos( aLbGradients.GetEntryCount() - 1 );
495 : :
496 : : #ifdef WNT
497 : : // hack: #31355# W.P.
498 : : Rectangle aRect( aLbGradients.GetPosPixel(), aLbGradients.GetSizePixel() );
499 : : if( sal_True ) { // ??? overlapped with pDlg
500 : : // and srolling
501 : : Invalidate( aRect );
502 : : }
503 : : #endif
504 : :
505 : 0 : *pnGradientListState |= CT_MODIFIED;
506 : :
507 [ # # ]: 0 : ChangeGradientHdl_Impl( this );
508 : : }
509 : :
510 : : // determine button state
511 [ # # ][ # # ]: 0 : if( pGradientList->Count() )
512 : : {
513 [ # # ]: 0 : aBtnModify.Enable();
514 [ # # ]: 0 : aBtnDelete.Enable();
515 [ # # ]: 0 : aBtnSave.Enable();
516 : : }
517 [ # # ][ # # ]: 0 : return 0L;
[ # # ]
518 : : }
519 : :
520 : : //------------------------------------------------------------------------
521 : :
522 : 0 : IMPL_LINK_NOARG(SvxGradientTabPage, ClickModifyHdl_Impl)
523 : : {
524 : 0 : sal_uInt16 nPos = aLbGradients.GetSelectEntryPos();
525 : :
526 [ # # ]: 0 : if ( nPos != LISTBOX_ENTRY_NOTFOUND )
527 : : {
528 [ # # ]: 0 : ResMgr& rMgr = CUI_MGR();
529 [ # # ][ # # ]: 0 : String aNewName( SVX_RES( RID_SVXSTR_GRADIENT ) );
530 [ # # ][ # # ]: 0 : String aDesc( CUI_RES( RID_SVXSTR_DESC_GRADIENT ) );
531 [ # # ][ # # ]: 0 : String aName( pGradientList->GetGradient( nPos )->GetName() );
532 [ # # ]: 0 : String aOldName = aName;
533 : :
534 [ # # ]: 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
535 : : DBG_ASSERT(pFact, "Dialogdiet fail!");
536 [ # # ][ # # ]: 0 : AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc );
537 : : DBG_ASSERT(pDlg, "Dialogdiet fail!");
538 : :
539 [ # # ]: 0 : long nCount = pGradientList->Count();
540 : 0 : sal_Bool bDifferent = sal_False;
541 : 0 : sal_Bool bLoop = sal_True;
542 : :
543 [ # # ][ # # ]: 0 : while( bLoop && pDlg->Execute() == RET_OK )
[ # # ][ # # ]
544 : : {
545 [ # # ]: 0 : pDlg->GetName( aName );
546 : 0 : bDifferent = sal_True;
547 : :
548 [ # # ][ # # ]: 0 : for( long i = 0; i < nCount && bDifferent; i++ )
[ # # ]
549 : : {
550 [ # # ][ # # ]: 0 : if( aName == pGradientList->GetGradient( i )->GetName() &&
[ # # ][ # # ]
[ # # ]
551 [ # # ]: 0 : aName != aOldName )
552 : 0 : bDifferent = sal_False;
553 : : }
554 : :
555 [ # # ]: 0 : if( bDifferent )
556 : : {
557 : 0 : bLoop = sal_False;
558 : 0 : XGradient aXGradient( aLbColorFrom.GetSelectEntryColor(),
559 : 0 : aLbColorTo.GetSelectEntryColor(),
560 [ # # ]: 0 : (XGradientStyle) aLbGradientType.GetSelectEntryPos(),
561 [ # # ]: 0 : static_cast<long>(aMtrAngle.GetValue() * 10), // should be changed in resource
562 [ # # ]: 0 : (sal_uInt16) aMtrCenterX.GetValue(),
563 [ # # ]: 0 : (sal_uInt16) aMtrCenterY.GetValue(),
564 [ # # ]: 0 : (sal_uInt16) aMtrBorder.GetValue(),
565 [ # # ]: 0 : (sal_uInt16) aMtrColorFrom.GetValue(),
566 [ # # ][ # # ]: 0 : (sal_uInt16) aMtrColorTo.GetValue() );
[ # # ][ # # ]
567 : :
568 [ # # ][ # # ]: 0 : XGradientEntry* pEntry = new XGradientEntry( aXGradient, aName );
569 : :
570 [ # # ][ # # ]: 0 : delete pGradientList->Replace( pEntry, nPos );
[ # # ]
571 : :
572 [ # # ]: 0 : aLbGradients.Modify( pEntry, nPos );
573 : :
574 [ # # ]: 0 : aLbGradients.SelectEntryPos( nPos );
575 : :
576 : 0 : *pnGradientListState |= CT_MODIFIED;
577 : : }
578 : : else
579 : : {
580 [ # # ][ # # ]: 0 : WarningBox aBox( GetParentDialog(), WinBits( WB_OK ),String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
[ # # ][ # # ]
581 [ # # ]: 0 : aBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
582 [ # # ][ # # ]: 0 : aBox.Execute();
583 : : }
584 : :
585 : : }
586 [ # # ][ # # ]: 0 : delete pDlg;
[ # # ][ # # ]
[ # # ][ # # ]
587 : : }
588 : 0 : return 0L;
589 : : }
590 : :
591 : : //------------------------------------------------------------------------
592 : :
593 : 0 : IMPL_LINK_NOARG(SvxGradientTabPage, ClickDeleteHdl_Impl)
594 : : {
595 : 0 : sal_uInt16 nPos = aLbGradients.GetSelectEntryPos();
596 : :
597 [ # # ]: 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
598 : : {
599 : : QueryBox aQueryBox( GetParentDialog(), WinBits( WB_YES_NO | WB_DEF_NO ),
600 [ # # ][ # # ]: 0 : String( CUI_RES( RID_SVXSTR_ASK_DEL_GRADIENT ) ) );
[ # # ][ # # ]
[ # # ]
601 : :
602 [ # # ][ # # ]: 0 : if ( aQueryBox.Execute() == RET_YES )
603 : : {
604 [ # # ][ # # ]: 0 : delete pGradientList->Remove( nPos );
[ # # ]
605 [ # # ]: 0 : aLbGradients.RemoveEntry( nPos );
606 [ # # ]: 0 : aLbGradients.SelectEntryPos( 0 );
607 : :
608 [ # # ]: 0 : aCtlPreview.Invalidate();
609 : :
610 [ # # ]: 0 : ChangeGradientHdl_Impl( this );
611 : :
612 : 0 : *pnGradientListState |= CT_MODIFIED;
613 [ # # ]: 0 : }
614 : : }
615 : : // determine button state
616 [ # # ]: 0 : if( !pGradientList->Count() )
617 : : {
618 : 0 : aBtnModify.Disable();
619 : 0 : aBtnDelete.Disable();
620 : 0 : aBtnSave.Disable();
621 : : }
622 : 0 : return 0L;
623 : : }
624 : :
625 : : // -----------------------------------------------------------------------
626 : :
627 : 0 : IMPL_LINK_NOARG(SvxGradientTabPage, ClickLoadHdl_Impl)
628 : : {
629 : 0 : ResMgr& rMgr = CUI_MGR();
630 : 0 : sal_uInt16 nReturn = RET_YES;
631 : :
632 [ # # ]: 0 : if ( *pnGradientListState & CT_MODIFIED )
633 : : {
634 : : nReturn = WarningBox( GetParentDialog(), WinBits( WB_YES_NO_CANCEL ),
635 [ # # ][ # # ]: 0 : String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute();
[ # # ][ # # ]
[ # # ][ # # ]
636 : :
637 [ # # ]: 0 : if ( nReturn == RET_YES )
638 : 0 : pGradientList->Save();
639 : : }
640 : :
641 [ # # ]: 0 : if ( nReturn != RET_CANCEL )
642 : : {
643 : : ::sfx2::FileDialogHelper aDlg(
644 : : com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
645 [ # # ]: 0 : 0 );
646 [ # # ]: 0 : String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sog" ) );
647 [ # # ]: 0 : aDlg.AddFilter( aStrFilterType, aStrFilterType );
648 [ # # ][ # # ]: 0 : INetURLObject aFile( SvtPathOptions().GetPalettePath() );
[ # # ][ # # ]
[ # # ]
649 [ # # ][ # # ]: 0 : aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
[ # # ][ # # ]
650 : :
651 [ # # ][ # # ]: 0 : if( aDlg.Execute() == ERRCODE_NONE )
652 : : {
653 [ # # ]: 0 : EnterWait();
654 : :
655 [ # # ][ # # ]: 0 : INetURLObject aURL( aDlg.GetPath() );
[ # # ][ # # ]
656 [ # # ]: 0 : INetURLObject aPathURL( aURL );
657 : :
658 [ # # ]: 0 : aPathURL.removeSegment();
659 [ # # ]: 0 : aPathURL.removeFinalSlash();
660 : :
661 : : // save list
662 : : XGradientListRef pGrdList = XPropertyList::CreatePropertyList(
663 [ # # ][ # # ]: 0 : XGRADIENT_LIST, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), pXPool )->AsGradientList();
[ # # ][ # # ]
[ # # ]
664 [ # # ][ # # ]: 0 : pGrdList->SetName( aURL.getName() );
[ # # ][ # # ]
665 : :
666 [ # # ][ # # ]: 0 : if ( pGrdList->Load() )
667 : : {
668 [ # # ]: 0 : pGradientList = pGrdList;
669 [ # # ]: 0 : ( (SvxAreaTabDialog*) GetParentDialog() )->
670 [ # # ]: 0 : SetNewGradientList( pGradientList );
671 : :
672 [ # # ]: 0 : aLbGradients.Clear();
673 [ # # ]: 0 : aLbGradients.Fill( pGradientList );
674 [ # # ]: 0 : Reset( rOutAttrs );
675 : :
676 [ # # ][ # # ]: 0 : pGradientList->SetName( aURL.getName() );
[ # # ][ # # ]
677 : :
678 : : // determining (possibly cutting) the name
679 : : // and displaying it in the GroupBox
680 [ # # ]: 0 : String aString( ResId( RID_SVXSTR_TABLE, rMgr ) );
681 [ # # ]: 0 : aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
682 : :
683 [ # # ][ # # ]: 0 : if ( aURL.getBase().getLength() > 18 )
684 : : {
685 [ # # ][ # # ]: 0 : aString += String(aURL.getBase()).Copy( 0, 15 );
[ # # ][ # # ]
[ # # ][ # # ]
686 [ # # ]: 0 : aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
687 : : }
688 : : else
689 [ # # ][ # # ]: 0 : aString += String(aURL.getBase());
[ # # ][ # # ]
690 : :
691 : 0 : *pnGradientListState |= CT_CHANGED;
692 : 0 : *pnGradientListState &= ~CT_MODIFIED;
693 [ # # ][ # # ]: 0 : LeaveWait();
694 : : }
695 : : else
696 : : {
697 [ # # ]: 0 : LeaveWait();
698 : : ErrorBox( GetParentDialog(), WinBits( WB_OK ),
699 [ # # ][ # # ]: 0 : String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute();
[ # # ][ # # ]
[ # # ][ # # ]
700 [ # # ][ # # ]: 0 : }
701 [ # # ][ # # ]: 0 : }
[ # # ]
702 : : }
703 : :
704 : : // determine button state
705 [ # # ]: 0 : if( pGradientList->Count() )
706 : : {
707 : 0 : aBtnModify.Enable();
708 : 0 : aBtnDelete.Enable();
709 : 0 : aBtnSave.Enable();
710 : : }
711 : : else
712 : : {
713 : 0 : aBtnModify.Disable();
714 : 0 : aBtnDelete.Disable();
715 : 0 : aBtnSave.Disable();
716 : : }
717 : 0 : return 0L;
718 : : }
719 : :
720 : : // -----------------------------------------------------------------------
721 : :
722 : 0 : IMPL_LINK_NOARG(SvxGradientTabPage, ClickSaveHdl_Impl)
723 : : {
724 : : ::sfx2::FileDialogHelper aDlg(
725 [ # # ]: 0 : com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
726 [ # # ]: 0 : String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sog" ) );
727 [ # # ]: 0 : aDlg.AddFilter( aStrFilterType, aStrFilterType );
728 : :
729 [ # # ][ # # ]: 0 : INetURLObject aFile( SvtPathOptions().GetPalettePath() );
[ # # ][ # # ]
[ # # ]
730 : : DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
731 : :
732 [ # # ]: 0 : if( pGradientList->GetName().Len() )
733 : : {
734 [ # # ][ # # ]: 0 : aFile.Append( pGradientList->GetName() );
735 : :
736 [ # # ][ # # ]: 0 : if( aFile.getExtension().isEmpty() )
737 [ # # ]: 0 : aFile.SetExtension(rtl::OUString("sog"));
738 : : }
739 : :
740 [ # # ][ # # ]: 0 : aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
[ # # ][ # # ]
741 [ # # ][ # # ]: 0 : if ( aDlg.Execute() == ERRCODE_NONE )
742 : : {
743 [ # # ][ # # ]: 0 : INetURLObject aURL( aDlg.GetPath() );
[ # # ][ # # ]
744 [ # # ]: 0 : INetURLObject aPathURL( aURL );
745 : :
746 [ # # ]: 0 : aPathURL.removeSegment();
747 [ # # ]: 0 : aPathURL.removeFinalSlash();
748 : :
749 [ # # ][ # # ]: 0 : pGradientList->SetName( aURL.getName() );
[ # # ][ # # ]
750 [ # # ][ # # ]: 0 : pGradientList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
[ # # ][ # # ]
751 : :
752 [ # # ][ # # ]: 0 : if( pGradientList->Save() )
753 : : {
754 : : // determining (possibly cutting) the name
755 : : // and displaying it in the GroupBox
756 [ # # ][ # # ]: 0 : String aString( CUI_RES( RID_SVXSTR_TABLE ) );
757 [ # # ]: 0 : aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
758 : :
759 [ # # ][ # # ]: 0 : if ( aURL.getBase().getLength() > 18 )
760 : : {
761 [ # # ][ # # ]: 0 : aString += String(aURL.getBase()).Copy( 0, 15 );
[ # # ][ # # ]
[ # # ][ # # ]
762 [ # # ]: 0 : aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
763 : : }
764 : : else
765 [ # # ][ # # ]: 0 : aString += String(aURL.getBase());
[ # # ][ # # ]
766 : :
767 : 0 : *pnGradientListState |= CT_SAVED;
768 [ # # ]: 0 : *pnGradientListState &= ~CT_MODIFIED;
769 : : }
770 : : else
771 : : {
772 : : ErrorBox( GetParentDialog(), WinBits( WB_OK ),
773 [ # # ][ # # ]: 0 : String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) ).Execute();
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
774 [ # # ][ # # ]: 0 : }
775 : : }
776 : :
777 [ # # ][ # # ]: 0 : return 0L;
[ # # ]
778 : : }
779 : :
780 : : //------------------------------------------------------------------------
781 : :
782 : 0 : IMPL_LINK_NOARG(SvxGradientTabPage, ChangeGradientHdl_Impl)
783 : : {
784 : 0 : XGradient* pGradient = NULL;
785 : 0 : int nPos = aLbGradients.GetSelectEntryPos();
786 : :
787 [ # # ]: 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
788 : 0 : pGradient = new XGradient( ( (XGradientEntry*) pGradientList->GetGradient( nPos ) )->GetGradient() );
789 : : else
790 : : {
791 : 0 : const SfxPoolItem* pPoolItem = NULL;
792 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLSTYLE ), sal_True, &pPoolItem ) )
[ # # ]
793 : : {
794 [ # # ][ # # ]: 0 : if( ( XFILL_GRADIENT == (XFillStyle) ( ( const XFillStyleItem* ) pPoolItem )->GetValue() ) &&
[ # # ]
795 [ # # ][ # # ]: 0 : ( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLGRADIENT ), sal_True, &pPoolItem ) ) )
796 : : {
797 [ # # ][ # # ]: 0 : pGradient = new XGradient( ( ( const XFillGradientItem* ) pPoolItem )->GetGradientValue() );
798 : : }
799 : : }
800 [ # # ]: 0 : if( !pGradient )
801 : : {
802 [ # # ]: 0 : aLbGradients.SelectEntryPos( 0 );
803 [ # # ]: 0 : nPos = aLbGradients.GetSelectEntryPos();
804 [ # # ]: 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
805 [ # # ][ # # ]: 0 : pGradient = new XGradient( ( (XGradientEntry*) pGradientList->GetGradient( nPos ) )->GetGradient() );
806 : : }
807 : : }
808 : :
809 [ # # ]: 0 : if( pGradient )
810 : : {
811 : 0 : XGradientStyle eXGS = pGradient->GetGradientStyle();
812 : :
813 : : aLbGradientType.SelectEntryPos(
814 : 0 : sal::static_int_cast< sal_uInt16 >( eXGS ) );
815 : : // if the entry is not in the listbox ist,
816 : : // colors are added temporarily
817 : 0 : aLbColorFrom.SetNoSelection();
818 [ # # ]: 0 : aLbColorFrom.SelectEntry( pGradient->GetStartColor() );
819 : :
820 [ # # ]: 0 : if ( aLbColorFrom.GetSelectEntryCount() == 0 )
821 : : {
822 : : aLbColorFrom.InsertEntry( pGradient->GetStartColor(),
823 [ # # ]: 0 : String() );
824 [ # # ]: 0 : aLbColorFrom.SelectEntry( pGradient->GetStartColor() );
825 : : }
826 : 0 : aLbColorTo.SetNoSelection();
827 [ # # ]: 0 : aLbColorTo.SelectEntry( pGradient->GetEndColor() );
828 : :
829 [ # # ]: 0 : if ( aLbColorTo.GetSelectEntryCount() == 0 )
830 : : {
831 [ # # ]: 0 : aLbColorTo.InsertEntry( pGradient->GetEndColor(), String() );
832 [ # # ]: 0 : aLbColorTo.SelectEntry( pGradient->GetEndColor() );
833 : : }
834 : :
835 : 0 : aMtrAngle.SetValue( pGradient->GetAngle() / 10 ); // should be changed in resource
836 : 0 : aMtrBorder.SetValue( pGradient->GetBorder() );
837 : 0 : aMtrCenterX.SetValue( pGradient->GetXOffset() );
838 : 0 : aMtrCenterY.SetValue( pGradient->GetYOffset() );
839 : 0 : aMtrColorFrom.SetValue( pGradient->GetStartIntens() );
840 : 0 : aMtrColorTo.SetValue( pGradient->GetEndIntens() );
841 : :
842 : : // disable/enable controls
843 : 0 : SetControlState_Impl( eXGS );
844 : :
845 : : // fill ItemSet and pass it on to aCtlPreview
846 [ # # ][ # # ]: 0 : rXFSet.Put( XFillGradientItem( String(), *pGradient ) );
[ # # ]
847 : 0 : aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
848 : :
849 : 0 : aCtlPreview.Invalidate();
850 : 0 : delete pGradient;
851 : : }
852 : 0 : return 0L;
853 : : }
854 : :
855 : : //------------------------------------------------------------------------
856 : :
857 : 0 : void SvxGradientTabPage::SetControlState_Impl( XGradientStyle eXGS )
858 : : {
859 [ # # # # : 0 : switch( eXGS )
# ]
860 : : {
861 : : case XGRAD_LINEAR:
862 : : case XGRAD_AXIAL:
863 : 0 : aFtCenterX.Disable();
864 : 0 : aMtrCenterX.Disable();
865 : 0 : aFtCenterY.Disable();
866 : 0 : aMtrCenterY.Disable();
867 : 0 : aFtAngle.Enable();
868 : 0 : aMtrAngle.Enable();
869 : 0 : break;
870 : :
871 : : case XGRAD_RADIAL:
872 : 0 : aFtCenterX.Enable();
873 : 0 : aMtrCenterX.Enable();
874 : 0 : aFtCenterY.Enable();
875 : 0 : aMtrCenterY.Enable();
876 : 0 : aFtAngle.Disable();
877 : 0 : aMtrAngle.Disable();
878 : 0 : break;
879 : :
880 : : case XGRAD_ELLIPTICAL:
881 : 0 : aFtCenterX.Enable();
882 : 0 : aMtrCenterX.Enable();
883 : 0 : aFtCenterY.Enable();
884 : 0 : aMtrCenterY.Enable();
885 : 0 : aFtAngle.Enable();
886 : 0 : aMtrAngle.Enable();
887 : 0 : break;
888 : :
889 : : case XGRAD_SQUARE:
890 : : case XGRAD_RECT:
891 : 0 : aFtCenterX.Enable();
892 : 0 : aMtrCenterX.Enable();
893 : 0 : aFtCenterY.Enable();
894 : 0 : aMtrCenterY.Enable();
895 : 0 : aFtAngle.Enable();
896 : 0 : aMtrAngle.Enable();
897 : 0 : break;
898 : : }
899 : 0 : }
900 : :
901 : :
902 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|