Bump version to 4.3-4
[LibreOffice.git] / cui / source / tabpages / tparea.cxx
blob35db8ef9a85acd483af5cc456eaafa9ae27dd18f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <stdlib.h>
22 #include <tools/shl.hxx>
23 #include <tools/urlobj.hxx>
24 #include <sfx2/app.hxx>
25 #include <sfx2/module.hxx>
26 #include <svx/dialogs.hrc>
28 #include "svx/xattr.hxx"
29 #include <svx/xpool.hxx>
30 #include <cuires.hrc>
31 #include <svx/xflbckit.hxx>
32 #include <svx/svdattr.hxx>
33 #include <svx/xtable.hxx>
34 #include <svx/xlineit0.hxx>
35 #include "svx/drawitem.hxx"
36 #include "cuitabarea.hxx"
37 #include "dlgname.hxx"
38 #include <dialmgr.hxx>
39 #include "svx/dlgutil.hxx"
40 #include <svl/intitem.hxx>
41 #include <sfx2/request.hxx>
42 #include "paragrph.hrc"
44 // static ----------------------------------------------------------------
46 static const sal_uInt16 pAreaRanges[] =
48 XATTR_GRADIENTSTEPCOUNT,
49 XATTR_GRADIENTSTEPCOUNT,
50 SID_ATTR_FILL_STYLE,
51 SID_ATTR_FILL_BITMAP,
55 static const sal_uInt16 pTransparenceRanges[] =
57 XATTR_FILLTRANSPARENCE,
58 XATTR_FILLTRANSPARENCE,
59 SDRATTR_SHADOWTRANSPARENCE,
60 SDRATTR_SHADOWTRANSPARENCE,
61 XATTR_FILLFLOATTRANSPARENCE,
62 XATTR_FILLFLOATTRANSPARENCE,
66 /*************************************************************************
68 |* Dialog for transparence
70 \************************************************************************/
72 IMPL_LINK_NOARG(SvxTransparenceTabPage, ClickTransOffHdl_Impl)
74 // disable all other controls
75 ActivateLinear(false);
76 ActivateGradient(false);
78 // Preview
79 rXFSet.ClearItem (XATTR_FILLTRANSPARENCE);
80 rXFSet.ClearItem (XATTR_FILLFLOATTRANSPARENCE);
81 m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() );
82 m_pCtlBitmapPreview->SetAttributes( aXFillAttr.GetItemSet() );
84 InvalidatePreview( false );
86 return( 0L );
89 IMPL_LINK_NOARG(SvxTransparenceTabPage, ClickTransLinearHdl_Impl)
91 // enable linear, disable other
92 ActivateLinear(true);
93 ActivateGradient(false);
95 // preview
96 rXFSet.ClearItem (XATTR_FILLFLOATTRANSPARENCE);
97 ModifyTransparentHdl_Impl (NULL);
99 return( 0L );
102 IMPL_LINK_NOARG(SvxTransparenceTabPage, ClickTransGradientHdl_Impl)
104 // enable gradient, disable other
105 ActivateLinear(false);
106 ActivateGradient(true);
108 // preview
109 rXFSet.ClearItem (XATTR_FILLTRANSPARENCE);
110 ModifiedTrgrHdl_Impl (NULL);
112 return( 0L );
115 void SvxTransparenceTabPage::ActivateLinear(bool bActivate)
117 m_pMtrTransparent->Enable(bActivate);
120 IMPL_LINK_NOARG(SvxTransparenceTabPage, ModifyTransparentHdl_Impl)
122 sal_uInt16 nPos = (sal_uInt16)m_pMtrTransparent->GetValue();
123 XFillTransparenceItem aItem(nPos);
124 rXFSet.Put(XFillTransparenceItem(aItem));
126 // preview
127 InvalidatePreview();
129 return 0L;
132 IMPL_LINK(SvxTransparenceTabPage, ModifiedTrgrHdl_Impl, void *, pControl)
134 if(pControl == m_pLbTrgrGradientType || pControl == this)
136 XGradientStyle eXGS = (XGradientStyle)m_pLbTrgrGradientType->GetSelectEntryPos();
137 SetControlState_Impl( eXGS );
140 // preview
141 sal_uInt8 nStartCol = (sal_uInt8)(((sal_uInt16)m_pMtrTrgrStartValue->GetValue() * 255) / 100);
142 sal_uInt8 nEndCol = (sal_uInt8)(((sal_uInt16)m_pMtrTrgrEndValue->GetValue() * 255) / 100);
143 XGradient aTmpGradient(
144 Color(nStartCol, nStartCol, nStartCol),
145 Color(nEndCol, nEndCol, nEndCol),
146 (XGradientStyle)m_pLbTrgrGradientType->GetSelectEntryPos(),
147 (sal_uInt16)m_pMtrTrgrAngle->GetValue() * 10,
148 (sal_uInt16)m_pMtrTrgrCenterX->GetValue(),
149 (sal_uInt16)m_pMtrTrgrCenterY->GetValue(),
150 (sal_uInt16)m_pMtrTrgrBorder->GetValue(),
151 100, 100);
153 XFillFloatTransparenceItem aItem( rXFSet.GetPool()/*aString*/, aTmpGradient);
154 rXFSet.Put ( aItem );
156 InvalidatePreview();
158 return( 0L );
161 void SvxTransparenceTabPage::ActivateGradient(bool bActivate)
163 m_pGridGradient->Enable(bActivate);
165 if(bActivate)
167 XGradientStyle eXGS = (XGradientStyle)m_pLbTrgrGradientType->GetSelectEntryPos();
168 SetControlState_Impl( eXGS );
172 IMPL_LINK_NOARG(SvxTransparenceTabPage, ChangeTrgrTypeHdl_Impl)
174 return( 0L );
177 void SvxTransparenceTabPage::SetControlState_Impl(XGradientStyle eXGS)
179 switch(eXGS)
181 case XGRAD_LINEAR:
182 case XGRAD_AXIAL:
183 m_pFtTrgrCenterX->Disable();
184 m_pMtrTrgrCenterX->Disable();
185 m_pFtTrgrCenterY->Disable();
186 m_pMtrTrgrCenterY->Disable();
187 m_pFtTrgrAngle->Enable();
188 m_pMtrTrgrAngle->Enable();
189 break;
191 case XGRAD_RADIAL:
192 m_pFtTrgrCenterX->Enable();
193 m_pMtrTrgrCenterX->Enable();
194 m_pFtTrgrCenterY->Enable();
195 m_pMtrTrgrCenterY->Enable();
196 m_pFtTrgrAngle->Disable();
197 m_pMtrTrgrAngle->Disable();
198 break;
200 case XGRAD_ELLIPTICAL:
201 m_pFtTrgrCenterX->Enable();
202 m_pMtrTrgrCenterX->Enable();
203 m_pFtTrgrCenterY->Enable();
204 m_pMtrTrgrCenterY->Enable();
205 m_pFtTrgrAngle->Enable();
206 m_pMtrTrgrAngle->Enable();
207 break;
209 case XGRAD_SQUARE:
210 case XGRAD_RECT:
211 m_pFtTrgrCenterX->Enable();
212 m_pMtrTrgrCenterX->Enable();
213 m_pFtTrgrCenterY->Enable();
214 m_pMtrTrgrCenterY->Enable();
215 m_pFtTrgrAngle->Enable();
216 m_pMtrTrgrAngle->Enable();
217 break;
221 SvxTransparenceTabPage::SvxTransparenceTabPage(Window* pParent, const SfxItemSet& rInAttrs)
222 : SvxTabPage ( pParent,
223 "TransparencyTabPage",
224 "cui/ui/transparencytabpage.ui",
225 rInAttrs),
226 rOutAttrs ( rInAttrs ),
227 eRP ( RP_LT ),
228 nPageType (0),
229 nDlgType (0),
230 bBitmap ( false ),
231 pXPool ( (XOutdevItemPool*) rInAttrs.GetPool() ),
232 aXFillAttr ( pXPool ),
233 rXFSet ( aXFillAttr.GetItemSet() )
235 get(m_pRbtTransOff,"RBT_TRANS_OFF");
236 get(m_pRbtTransLinear,"RBT_TRANS_LINEAR");
237 get(m_pRbtTransGradient,"RBT_TRANS_GRADIENT");
239 get(m_pMtrTransparent,"MTR_TRANSPARENT");
241 get(m_pGridGradient,"gridGradient");
242 get(m_pLbTrgrGradientType,"LB_TRGR_GRADIENT_TYPES");
243 get(m_pFtTrgrCenterX,"FT_TRGR_CENTER_X");
244 get(m_pMtrTrgrCenterX,"MTR_TRGR_CENTER_X");
245 get(m_pFtTrgrCenterY,"FT_TRGR_CENTER_Y");
246 get(m_pMtrTrgrCenterY,"MTR_TRGR_CENTER_Y");
247 get(m_pFtTrgrAngle,"FT_TRGR_ANGLE"),
248 get(m_pMtrTrgrAngle,"MTR_TRGR_ANGLE");
249 get(m_pMtrTrgrBorder,"MTR_TRGR_BORDER");
250 get(m_pMtrTrgrStartValue,"MTR_TRGR_START_VALUE");
251 get(m_pMtrTrgrEndValue,"MTR_TRGR_END_VALUE");
253 get(m_pCtlBitmapPreview,"CTL_BITMAP_PREVIEW");
254 get(m_pCtlXRectPreview,"CTL_TRANS_PREVIEW");
256 // main selection
257 m_pRbtTransOff->SetClickHdl(LINK(this, SvxTransparenceTabPage, ClickTransOffHdl_Impl));
258 m_pRbtTransLinear->SetClickHdl(LINK(this, SvxTransparenceTabPage, ClickTransLinearHdl_Impl));
259 m_pRbtTransGradient->SetClickHdl(LINK(this, SvxTransparenceTabPage, ClickTransGradientHdl_Impl));
261 // linear transparency
262 m_pMtrTransparent->SetValue( 50 );
263 m_pMtrTransparent->SetModifyHdl(LINK(this, SvxTransparenceTabPage, ModifyTransparentHdl_Impl));
265 // gradient transparency
266 m_pMtrTrgrEndValue->SetValue( 100 );
267 m_pMtrTrgrStartValue->SetValue( 0 );
268 m_pLbTrgrGradientType->SetSelectHdl(LINK(this, SvxTransparenceTabPage, ChangeTrgrTypeHdl_Impl));
269 Link aLink = LINK( this, SvxTransparenceTabPage, ModifiedTrgrHdl_Impl);
270 m_pLbTrgrGradientType->SetSelectHdl( aLink );
271 m_pMtrTrgrCenterX->SetModifyHdl( aLink );
272 m_pMtrTrgrCenterY->SetModifyHdl( aLink );
273 m_pMtrTrgrAngle->SetModifyHdl( aLink );
274 m_pMtrTrgrBorder->SetModifyHdl( aLink );
275 m_pMtrTrgrStartValue->SetModifyHdl( aLink );
276 m_pMtrTrgrEndValue->SetModifyHdl( aLink );
278 // this page needs ExchangeSupport
279 SetExchangeSupport();
282 void SvxTransparenceTabPage::Construct()
286 SfxTabPage* SvxTransparenceTabPage::Create(Window* pWindow, const SfxItemSet& rAttrs)
288 return(new SvxTransparenceTabPage(pWindow, rAttrs));
291 const sal_uInt16* SvxTransparenceTabPage::GetRanges()
293 return(pTransparenceRanges);
296 bool SvxTransparenceTabPage::FillItemSet(SfxItemSet& rAttrs)
298 const SfxPoolItem* pGradientItem = NULL;
299 const SfxPoolItem* pLinearItem = NULL;
300 SfxItemState eStateGradient(rOutAttrs.GetItemState(XATTR_FILLFLOATTRANSPARENCE, true, &pGradientItem));
301 SfxItemState eStateLinear(rOutAttrs.GetItemState(XATTR_FILLTRANSPARENCE, true, &pLinearItem));
302 bool bGradActive = (eStateGradient == SFX_ITEM_SET && ((XFillFloatTransparenceItem*)pGradientItem)->IsEnabled());
303 bool bLinearActive = (eStateLinear == SFX_ITEM_SET && ((XFillTransparenceItem*)pLinearItem)->GetValue() != 0);
305 // #103765#
306 bool bGradUsed = (eStateGradient == SFX_ITEM_DONTCARE);
307 bool bLinearUsed = (eStateLinear == SFX_ITEM_DONTCARE);
309 bool bModified(false);
310 bool bSwitchOffLinear(false);
311 bool bSwitchOffGradient(false);
313 if(m_pMtrTransparent->IsEnabled())
315 // linear transparence
316 sal_uInt16 nPos = (sal_uInt16)m_pMtrTransparent->GetValue();
317 if(m_pMtrTransparent->IsValueChangedFromSaved() || !bLinearActive)
319 XFillTransparenceItem aItem(nPos);
320 SdrShadowTransparenceItem aShadowItem(nPos);
321 const SfxPoolItem* pOld = GetOldItem(rAttrs, XATTR_FILLTRANSPARENCE);
322 if(!pOld || !(*(const XFillTransparenceItem*)pOld == aItem) || !bLinearActive)
324 rAttrs.Put(aItem);
325 rAttrs.Put(aShadowItem);
326 bModified = true;
327 bSwitchOffGradient = true;
331 else if(m_pLbTrgrGradientType->IsEnabled())
333 // transparence gradient, fill ItemSet from values
334 if(!bGradActive
335 || m_pLbTrgrGradientType->IsValueChangedFromSaved()
336 || m_pMtrTrgrAngle->IsValueChangedFromSaved()
337 || m_pMtrTrgrCenterX->IsValueChangedFromSaved()
338 || m_pMtrTrgrCenterY->IsValueChangedFromSaved()
339 || m_pMtrTrgrBorder->IsValueChangedFromSaved()
340 || m_pMtrTrgrStartValue->IsValueChangedFromSaved()
341 || m_pMtrTrgrEndValue->IsValueChangedFromSaved() )
343 sal_uInt8 nStartCol = (sal_uInt8)(((sal_uInt16)m_pMtrTrgrStartValue->GetValue() * 255) / 100);
344 sal_uInt8 nEndCol = (sal_uInt8)(((sal_uInt16)m_pMtrTrgrEndValue->GetValue() * 255) / 100);
345 XGradient aTmpGradient(
346 Color(nStartCol, nStartCol, nStartCol),
347 Color(nEndCol, nEndCol, nEndCol),
348 (XGradientStyle)m_pLbTrgrGradientType->GetSelectEntryPos(),
349 (sal_uInt16)m_pMtrTrgrAngle->GetValue() * 10,
350 (sal_uInt16)m_pMtrTrgrCenterX->GetValue(),
351 (sal_uInt16)m_pMtrTrgrCenterY->GetValue(),
352 (sal_uInt16)m_pMtrTrgrBorder->GetValue(),
353 100, 100);
355 XFillFloatTransparenceItem aItem( rXFSet.GetPool()/*aString*/, aTmpGradient);
356 const SfxPoolItem* pOld = GetOldItem(rAttrs, XATTR_FILLFLOATTRANSPARENCE);
358 if(!pOld || !(*(const XFillFloatTransparenceItem*)pOld == aItem) || !bGradActive)
360 rAttrs.Put(aItem);
361 bModified = true;
362 bSwitchOffLinear = true;
366 else
368 // no transparence
369 bSwitchOffGradient = true;
370 bSwitchOffLinear = true;
373 // disable unused XFillFloatTransparenceItem
374 if(bSwitchOffGradient && (bGradActive || bGradUsed))
376 Color aColor(COL_BLACK);
377 XGradient aGrad(aColor, Color(COL_WHITE));
378 aGrad.SetStartIntens(100);
379 aGrad.SetEndIntens(100);
380 XFillFloatTransparenceItem aItem( rXFSet.GetPool()/*aString*/, aGrad);
381 aItem.SetEnabled(false);
382 rAttrs.Put(aItem);
383 bModified = true;
386 // disable unused XFillFloatTransparenceItem
387 if(bSwitchOffLinear && (bLinearActive || bLinearUsed))
389 XFillTransparenceItem aItem(0);
390 SdrShadowTransparenceItem aShadowItem(0);
391 rAttrs.Put(aItem);
392 rAttrs.Put(aShadowItem);
393 bModified = true;
395 rAttrs.Put (CntUInt16Item(SID_PAGE_TYPE,nPageType));
396 return bModified;
399 void SvxTransparenceTabPage::Reset(const SfxItemSet& rAttrs)
401 const SfxPoolItem* pGradientItem = NULL;
402 SfxItemState eStateGradient(rAttrs.GetItemState(XATTR_FILLFLOATTRANSPARENCE, true, &pGradientItem));
403 if(!pGradientItem)
404 pGradientItem = &rAttrs.Get(XATTR_FILLFLOATTRANSPARENCE);
405 bool bGradActive = (eStateGradient == SFX_ITEM_SET && ((XFillFloatTransparenceItem*)pGradientItem)->IsEnabled());
407 const SfxPoolItem* pLinearItem = NULL;
408 SfxItemState eStateLinear(rAttrs.GetItemState(XATTR_FILLTRANSPARENCE, true, &pLinearItem));
409 if(!pLinearItem)
410 pLinearItem = &rAttrs.Get(XATTR_FILLTRANSPARENCE);
411 bool bLinearActive = (eStateLinear == SFX_ITEM_SET && ((XFillTransparenceItem*)pLinearItem)->GetValue() != 0);
413 // transparence gradient
414 const XGradient& rGradient = ((XFillFloatTransparenceItem*)pGradientItem)->GetGradientValue();
415 XGradientStyle eXGS(rGradient.GetGradientStyle());
416 m_pLbTrgrGradientType->SelectEntryPos(sal::static_int_cast< sal_Int32 >(eXGS));
417 m_pMtrTrgrAngle->SetValue(rGradient.GetAngle() / 10);
418 m_pMtrTrgrBorder->SetValue(rGradient.GetBorder());
419 m_pMtrTrgrCenterX->SetValue(rGradient.GetXOffset());
420 m_pMtrTrgrCenterY->SetValue(rGradient.GetYOffset());
421 m_pMtrTrgrStartValue->SetValue((sal_uInt16)((((sal_uInt16)rGradient.GetStartColor().GetRed() + 1) * 100) / 255));
422 m_pMtrTrgrEndValue->SetValue((sal_uInt16)((((sal_uInt16)rGradient.GetEndColor().GetRed() + 1) * 100) / 255));
424 // linear transparence
425 sal_uInt16 nTransp = ((XFillTransparenceItem*)pLinearItem)->GetValue();
426 m_pMtrTransparent->SetValue(bLinearActive ? nTransp : 50);
427 ModifyTransparentHdl_Impl(NULL);
429 // select the correct radio button
430 if(bGradActive)
432 // transparence gradient, set controls appropriate to item
433 m_pRbtTransGradient->Check();
434 ClickTransGradientHdl_Impl(NULL);
436 else if(bLinearActive)
438 // linear transparence
439 m_pRbtTransLinear->Check();
440 ClickTransLinearHdl_Impl(NULL);
442 else
444 // no transparence
445 m_pRbtTransOff->Check();
446 ClickTransOffHdl_Impl(NULL);
447 ModifiedTrgrHdl_Impl(NULL);
450 // save values
451 m_pMtrTransparent->SaveValue();
452 m_pLbTrgrGradientType->SaveValue();
453 m_pMtrTrgrCenterX->SaveValue();
454 m_pMtrTrgrCenterY->SaveValue();
455 m_pMtrTrgrAngle->SaveValue();
456 m_pMtrTrgrBorder->SaveValue();
457 m_pMtrTrgrStartValue->SaveValue();
458 m_pMtrTrgrEndValue->SaveValue();
460 bool bActive = InitPreview ( rAttrs );
461 InvalidatePreview ( bActive );
464 void SvxTransparenceTabPage::ActivatePage(const SfxItemSet& rSet)
466 SFX_ITEMSET_ARG (&rSet,pPageTypeItem,CntUInt16Item,SID_PAGE_TYPE,false);
467 if (pPageTypeItem)
468 SetPageType(pPageTypeItem->GetValue());
470 if(nDlgType == 0) // area dialog
471 nPageType = PT_TRANSPARENCE;
473 InitPreview ( rSet );
476 int SvxTransparenceTabPage::DeactivatePage(SfxItemSet* _pSet)
478 if( _pSet )
479 FillItemSet( *_pSet );
480 return(LEAVE_PAGE);
483 void SvxTransparenceTabPage::PointChanged(Window* , RECT_POINT eRcPt)
485 eRP = eRcPt;
489 // Preview-Methods
491 bool SvxTransparenceTabPage::InitPreview ( const SfxItemSet& rSet )
493 // set transparencetyp for preview
494 if ( m_pRbtTransOff->IsChecked() )
496 ClickTransOffHdl_Impl(NULL);
497 } else if ( m_pRbtTransLinear->IsChecked() )
499 ClickTransLinearHdl_Impl(NULL);
500 } else if ( m_pRbtTransGradient->IsChecked() )
502 ClickTransGradientHdl_Impl(NULL);
505 // Get fillstyle for preview
506 rXFSet.Put ( ( XFillStyleItem& ) rSet.Get(XATTR_FILLSTYLE) );
507 rXFSet.Put ( ( XFillColorItem& ) rSet.Get(XATTR_FILLCOLOR) );
508 rXFSet.Put ( ( XFillGradientItem& ) rSet.Get(XATTR_FILLGRADIENT) );
509 rXFSet.Put ( ( XFillHatchItem& ) rSet.Get(XATTR_FILLHATCH) );
510 rXFSet.Put ( ( XFillBackgroundItem&)rSet.Get(XATTR_FILLBACKGROUND) );
511 rXFSet.Put ( ( XFillBitmapItem& ) rSet.Get(XATTR_FILLBITMAP) );
513 m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() );
514 m_pCtlBitmapPreview->SetAttributes( aXFillAttr.GetItemSet() );
516 bBitmap = ( ( ( XFillStyleItem& )rSet.Get(XATTR_FILLSTYLE) ).GetValue() == XFILL_BITMAP );
518 // show the right preview window
519 if ( bBitmap )
521 m_pCtlBitmapPreview->Show();
522 m_pCtlXRectPreview->Hide();
524 else
526 m_pCtlBitmapPreview->Hide();
527 m_pCtlXRectPreview->Show();
530 return !m_pRbtTransOff->IsChecked();
533 void SvxTransparenceTabPage::InvalidatePreview (bool bEnable)
535 if ( bBitmap )
537 if ( bEnable )
539 m_pCtlBitmapPreview->Enable();
540 m_pCtlBitmapPreview->SetAttributes( aXFillAttr.GetItemSet() );
542 else
543 m_pCtlBitmapPreview->Disable();
544 m_pCtlBitmapPreview->Invalidate();
546 else
548 if ( bEnable )
550 m_pCtlXRectPreview->Enable();
551 m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() );
553 else
554 m_pCtlXRectPreview->Disable();
555 m_pCtlXRectPreview->Invalidate();
559 void SvxTransparenceTabPage::PageCreated(const SfxAllItemSet& aSet)
561 SFX_ITEMSET_ARG (&aSet,pPageTypeItem,SfxUInt16Item,SID_PAGE_TYPE,false);
562 SFX_ITEMSET_ARG (&aSet,pDlgTypeItem,SfxUInt16Item,SID_DLG_TYPE,false);
564 if (pPageTypeItem)
565 SetPageType(pPageTypeItem->GetValue());
566 if (pDlgTypeItem)
567 SetDlgType(pDlgTypeItem->GetValue());
568 Construct();
570 /*************************************************************************
572 |* Dialog to modify fill-attributes
574 \************************************************************************/
576 SvxAreaTabPage::SvxAreaTabPage( Window* pParent, const SfxItemSet& rInAttrs ) :
578 SvxTabPage( pParent,
579 "AreaTabPage",
580 "cui/ui/areatabpage.ui",
581 rInAttrs ),
582 rOutAttrs (rInAttrs ),
583 eRP( RP_LT ),
585 pColorList( NULL ),
586 pGradientList( NULL ),
587 pHatchingList( NULL ),
588 pBitmapList( NULL ),
590 pnColorListState( 0 ),
591 pnBitmapListState( 0 ),
592 pnGradientListState( 0 ),
593 pnHatchingListState( 0 ),
595 nPageType( 0 ),
596 nDlgType( 0 ),
597 nPos( LISTBOX_ENTRY_NOTFOUND ),
599 pbAreaTP( 0 ),
601 pXPool ( (XOutdevItemPool*) rInAttrs.GetPool() ),
602 aXFillAttr ( pXPool ),
603 rXFSet ( aXFillAttr.GetItemSet() )
605 get(m_pTypeLB,"LB_AREA_TYPE");
606 get(m_pFillLB,"boxLB_FILL");
607 get(m_pLbColor,"LB_COLOR");
608 get(m_pLbGradient,"LB_GRADIENT");
609 get(m_pLbHatching,"LB_HATCHING");
610 get(m_pLbBitmap,"LB_BITMAP");
611 get(m_pCtlBitmapPreview,"CTL_BITMAP_PREVIEW");
613 get(m_pTsbStepCount,"TSB_STEPCOUNT");
614 get(m_pFlStepCount,"FL_STEPCOUNT");
615 get(m_pNumFldStepCount,"NUM_FLD_STEPCOUNT");
617 get(m_pFlHatchBckgrd,"FL_HATCHCOLORS");
618 get(m_pLbHatchBckgrdColor,"LB_HATCHBCKGRDCOLOR");
619 get(m_pCbxHatchBckgrd,"CB_HATCHBCKGRD");
621 get(m_pBxBitmap,"boxBITMAP");
623 get(m_pFlSize,"FL_SIZE");
624 get(m_pGridX_Y,"gridX_Y");
625 get(m_pTsbOriginal,"TSB_ORIGINAL");
626 get(m_pTsbScale,"TSB_SCALE");
627 get(m_pFtXSize,"FT_X_SIZE");
628 get(m_pMtrFldXSize,"MTR_FLD_X_SIZE");
629 get(m_pFtYSize,"FT_Y_SIZE");
630 get(m_pMtrFldYSize,"MTR_FLD_Y_SIZE");
632 get(m_pFlPosition,"framePOSITION");
633 get(m_pCtlPosition,"CTL_POSITION");
634 get(m_pGridOffset,"gridOFFSET");
635 get(m_pMtrFldXOffset,"MTR_FLD_X_OFFSET");
636 get(m_pMtrFldYOffset,"MTR_FLD_Y_OFFSET");
637 get(m_pBxTile,"boxTILE");
638 get(m_pTsbTile,"TSB_TILE");
639 get(m_pTsbStretch,"TSB_STRETCH");
641 get(m_pFlOffset,"FL_OFFSET");
642 get(m_pRbtRow,"RBT_ROW");
643 get(m_pRbtColumn,"RBT_COLUMN");
644 get(m_pMtrFldOffset,"MTR_FLD_OFFSET");
646 get(m_pCtlXRectPreview,"CTL_COLOR_PREVIEW");
648 //so that even for "none" the size requested is the largest
649 //size required for any of the areas which might be selected
650 //later, so that there's sufficient space
651 VclContainer *pMainFrame = get<VclContainer>("mainframe");
652 Size aIncrementsSize(m_pFlStepCount->get_preferred_size());
653 Size aHatchSize(m_pFlHatchBckgrd->get_preferred_size());
654 Size aBitmapSize(m_pBxBitmap->get_preferred_size());
655 Size aMainFrame(
656 std::max(std::max(aIncrementsSize.Width(), aHatchSize.Width()), aBitmapSize.Width()),
657 std::max(std::max(aIncrementsSize.Height(), aHatchSize.Height()), aBitmapSize.Height()));
658 pMainFrame->set_width_request(aMainFrame.Width());
659 pMainFrame->set_height_request(aMainFrame.Height());
663 // groups that overlay each other
664 m_pLbBitmap->Hide();
665 m_pCtlBitmapPreview->Hide();
667 m_pFlStepCount->Hide();
669 m_pBxBitmap->Hide();
671 // Controls for Hatch-Background
672 m_pFlHatchBckgrd->Hide();
674 m_pTsbOriginal->EnableTriState( false );
676 // this page needs ExchangeSupport
677 SetExchangeSupport();
679 // set Metrics
680 eFUnit = GetModuleFieldUnit( rInAttrs );
682 switch ( eFUnit )
684 case FUNIT_M:
685 case FUNIT_KM:
686 eFUnit = FUNIT_MM;
687 break;
688 default: ;//prevent warning
690 SetFieldUnit( *m_pMtrFldXSize, eFUnit, true );
691 SetFieldUnit( *m_pMtrFldYSize, eFUnit, true );
693 // get PoolUnit
694 SfxItemPool* pPool = rOutAttrs.GetPool();
695 DBG_ASSERT( pPool, "Wo ist der Pool?" );
696 ePoolUnit = pPool->GetMetric( XATTR_FILLBMP_SIZEX );
698 // setting the output device
699 rXFSet.Put( XFillStyleItem( XFILL_SOLID ) );
700 rXFSet.Put( XFillColorItem( OUString(), COL_BLACK ) );
701 m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() );
702 m_pCtlBitmapPreview->SetAttributes( aXFillAttr.GetItemSet() );
704 m_pLbColor->SetSelectHdl( LINK( this, SvxAreaTabPage, ModifyColorHdl_Impl ) );
705 m_pLbHatchBckgrdColor->SetSelectHdl( LINK( this, SvxAreaTabPage, ModifyHatchBckgrdColorHdl_Impl ) );
706 m_pCbxHatchBckgrd->SetToggleHdl( LINK( this, SvxAreaTabPage, ToggleHatchBckgrdColorHdl_Impl ) );
708 m_pLbGradient->SetSelectHdl( LINK( this, SvxAreaTabPage, ModifyGradientHdl_Impl ) );
709 m_pLbHatching->SetSelectHdl( LINK( this, SvxAreaTabPage, ModifyHatchingHdl_Impl ) );
710 m_pLbBitmap->SetSelectHdl( LINK( this, SvxAreaTabPage, ModifyBitmapHdl_Impl ) );
712 m_pTsbStepCount->SetClickHdl( LINK( this, SvxAreaTabPage, ModifyStepCountHdl_Impl ) );
713 m_pNumFldStepCount->SetModifyHdl( LINK( this, SvxAreaTabPage, ModifyStepCountHdl_Impl ) );
715 Link aLink( LINK( this, SvxAreaTabPage, ModifyTileHdl_Impl ) );
716 m_pTsbTile->SetClickHdl( aLink );
717 m_pTsbStretch->SetClickHdl( aLink );
718 m_pTsbOriginal->SetClickHdl( aLink );
719 m_pMtrFldXSize->SetModifyHdl( aLink );
720 m_pMtrFldYSize->SetModifyHdl( aLink );
721 m_pRbtRow->SetClickHdl( aLink );
722 m_pRbtColumn->SetClickHdl( aLink );
723 m_pMtrFldOffset->SetModifyHdl( aLink );
724 m_pMtrFldXOffset->SetModifyHdl( aLink );
725 m_pMtrFldYOffset->SetModifyHdl( aLink );
726 m_pTsbScale->SetClickHdl( LINK( this, SvxAreaTabPage, ClickScaleHdl_Impl ) );
728 m_pTypeLB->SetSelectHdl( LINK( this, SvxAreaTabPage, SelectDialogTypeHdl_Impl ) );
730 // #i76307# always paint the preview in LTR, because this is what the document does
731 m_pCtlXRectPreview->EnableRTL(false);
733 // Calcualte size of dropdown listboxes
734 Size aSize = LogicToPixel(Size(108, 103), MAP_APPFONT);
736 m_pLbColor->set_width_request(aSize.Width());
737 m_pLbColor->set_height_request(aSize.Height());
738 //m_pLbColor->
740 m_pLbGradient->set_width_request(aSize.Width());
741 m_pLbGradient->set_height_request(aSize.Height());
742 m_pLbHatching->set_width_request(aSize.Width());
743 m_pLbHatching->set_height_request(aSize.Height());
744 m_pLbBitmap->set_width_request(aSize.Width());
745 m_pLbBitmap->set_height_request(aSize.Height());
747 // Calculate size of display boxes
748 Size aSize2 = LogicToPixel(Size(110, 42), MAP_APPFONT);
749 m_pCtlBitmapPreview->set_width_request(aSize2.Width());
750 m_pCtlBitmapPreview->set_height_request(aSize2.Height());
751 m_pCtlXRectPreview->set_width_request(aSize2.Width());
752 m_pCtlXRectPreview->set_height_request(aSize2.Height());
757 void SvxAreaTabPage::Construct()
759 // fill colortables / lists
760 m_pLbColor->Fill( pColorList );
761 m_pLbHatchBckgrdColor->Fill ( pColorList );
763 m_pLbGradient->Fill( pGradientList );
764 m_pLbHatching->Fill( pHatchingList );
765 m_pLbBitmap->Fill( pBitmapList );
770 void SvxAreaTabPage::ActivatePage( const SfxItemSet& rSet )
772 sal_Int32 nCount;
773 SFX_ITEMSET_ARG (&rSet,pPageTypeItem,SfxUInt16Item,SID_PAGE_TYPE,false);
774 SFX_ITEMSET_ARG (&rSet,pPosItem,SfxUInt16Item,SID_TABPAGE_POS,false);
775 if (pPageTypeItem)
776 SetPageType(pPageTypeItem->GetValue());
777 if (pPosItem)
778 SetPos(pPosItem->GetValue());
779 if( nDlgType == 0 ) // area dialog
781 *pbAreaTP = true;
783 if( pColorList.is() )
785 sal_Int32 _nPos = 0;
787 if( *pnBitmapListState )
789 if( *pnBitmapListState & CT_CHANGED )
790 pBitmapList = ( (SvxAreaTabDialog*) GetParentDialog() )->GetNewBitmapList();
792 _nPos = m_pLbBitmap->GetSelectEntryPos();
794 m_pLbBitmap->Clear();
795 m_pLbBitmap->Fill( pBitmapList );
796 nCount = m_pLbBitmap->GetEntryCount();
797 if( nCount == 0 )
798 ; // This case should never occur
799 else if( nCount <= _nPos )
800 m_pLbBitmap->SelectEntryPos( 0 );
801 else
802 m_pLbBitmap->SelectEntryPos( _nPos );
803 ModifyBitmapHdl_Impl( this );
806 if( *pnHatchingListState )
808 if( *pnHatchingListState & CT_CHANGED )
809 pHatchingList = ( (SvxAreaTabDialog*) GetParentDialog() )->GetNewHatchingList();
811 _nPos = m_pLbHatching->GetSelectEntryPos();
813 m_pLbHatching->Clear();
814 m_pLbHatching->Fill( pHatchingList );
815 nCount = m_pLbHatching->GetEntryCount();
816 if( nCount == 0 )
817 ; // This case should never occur
818 else if( nCount <= _nPos )
819 m_pLbHatching->SelectEntryPos( 0 );
820 else
821 m_pLbHatching->SelectEntryPos( _nPos );
822 ModifyHatchingHdl_Impl( this );
824 ModifyHatchBckgrdColorHdl_Impl( this );
827 if( *pnGradientListState )
829 if( *pnGradientListState & CT_CHANGED )
830 pGradientList = ( (SvxAreaTabDialog*) GetParentDialog() )->GetNewGradientList();
832 _nPos = m_pLbGradient->GetSelectEntryPos();
834 m_pLbGradient->Clear();
835 m_pLbGradient->Fill( pGradientList );
836 nCount = m_pLbGradient->GetEntryCount();
837 if( nCount == 0 )
838 ; // This case should never occur
839 else if( nCount <= _nPos )
840 m_pLbGradient->SelectEntryPos( 0 );
841 else
842 m_pLbGradient->SelectEntryPos( _nPos );
843 ModifyGradientHdl_Impl( this );
846 if( *pnColorListState )
848 if( *pnColorListState & CT_CHANGED )
849 pColorList = ( (SvxAreaTabDialog*) GetParentDialog() )->GetNewColorList();
850 // aLbColor
851 _nPos = m_pLbColor->GetSelectEntryPos();
852 m_pLbColor->Clear();
853 m_pLbColor->Fill( pColorList );
854 nCount = m_pLbColor->GetEntryCount();
855 if( nCount == 0 )
856 ; // This case should never occur
857 else if( nCount <= _nPos )
858 m_pLbColor->SelectEntryPos( 0 );
859 else
860 m_pLbColor->SelectEntryPos( _nPos );
862 ModifyColorHdl_Impl( this );
864 // Backgroundcolor of hatch
865 _nPos = m_pLbHatchBckgrdColor->GetSelectEntryPos();
866 m_pLbHatchBckgrdColor->Clear();
867 m_pLbHatchBckgrdColor->Fill( pColorList );
868 nCount = m_pLbHatchBckgrdColor->GetEntryCount();
869 if( nCount == 0 )
870 ; // This case should never occur
871 else if( nCount <= _nPos )
872 m_pLbHatchBckgrdColor->SelectEntryPos( 0 );
873 else
874 m_pLbHatchBckgrdColor->SelectEntryPos( _nPos );
876 ModifyHatchBckgrdColorHdl_Impl( this );
879 // evaluate if any other Tabpage set another filltype
880 if( m_pTypeLB->GetSelectEntryPos() > XFILL_NONE)
882 switch( nPageType )
884 case PT_GRADIENT:
885 m_pTypeLB->SelectEntryPos( XFILL_GRADIENT );
886 m_pLbGradient->SelectEntryPos( _nPos );
887 ClickGradientHdl_Impl();
888 break;
890 case PT_HATCH:
891 m_pTypeLB->SelectEntryPos( XFILL_HATCH );
892 m_pLbHatching->SelectEntryPos( _nPos );
893 ClickHatchingHdl_Impl();
894 break;
896 case PT_BITMAP:
897 m_pTypeLB->SelectEntryPos( XFILL_BITMAP );
898 m_pLbBitmap->SelectEntryPos( _nPos );
899 ClickBitmapHdl_Impl();
900 break;
902 case PT_COLOR:
903 m_pTypeLB->SelectEntryPos( XFILL_SOLID );
904 m_pLbColor->SelectEntryPos( _nPos );
905 m_pLbHatchBckgrdColor->SelectEntryPos( _nPos );
906 ClickColorHdl_Impl();
907 break;
910 nPageType = PT_AREA;
917 int SvxAreaTabPage::DeactivatePage( SfxItemSet* _pSet )
919 if( nDlgType == 0 ) // area dialog
921 sal_Int32 nPosOrig = nPos;
922 XFillStyle eStyle = (XFillStyle) m_pTypeLB->GetSelectEntryPos();
923 switch( eStyle )
925 case XFILL_GRADIENT:
927 nPageType = PT_GRADIENT;
928 nPos = m_pLbGradient->GetSelectEntryPos();
929 if( nPosOrig != nPos )
930 *pnGradientListState |= CT_MODIFIED;
932 break;
933 case XFILL_HATCH:
935 nPageType = PT_HATCH;
936 nPos = m_pLbHatching->GetSelectEntryPos();
937 if( nPosOrig != nPos )
938 *pnHatchingListState |= CT_MODIFIED;
940 break;
941 case XFILL_BITMAP:
943 nPageType = PT_BITMAP;
944 nPos = m_pLbBitmap->GetSelectEntryPos();
945 if( nPosOrig != nPos )
946 *pnBitmapListState |= CT_MODIFIED;
948 break;
949 case XFILL_SOLID:
951 nPageType = PT_COLOR;
952 nPos = m_pLbColor->GetSelectEntryPos();
953 if( nPosOrig != nPos )
954 *pnColorListState |= CT_MODIFIED;
956 break;
957 default: ;//prevent warning
961 if( _pSet )
962 FillItemSet( *_pSet );
964 return( LEAVE_PAGE );
969 bool SvxAreaTabPage::FillItemSet( SfxItemSet& rAttrs )
971 sal_Int32 _nPos;
972 bool bModified = false;
974 if( nDlgType != 0 || *pbAreaTP )
976 const SfxPoolItem* pOld = NULL;
977 XFillStyle eStyle = (XFillStyle) m_pTypeLB->GetSelectEntryPos();
978 XFillStyle eSavedStyle = (XFillStyle) m_pTypeLB->GetSavedValue();
979 switch( eStyle )
981 case XFILL_NONE:
983 if( eSavedStyle != eStyle )
985 XFillStyleItem aStyleItem( XFILL_NONE );
986 pOld = GetOldItem( rAttrs, XATTR_FILLSTYLE );
987 if ( !pOld || !( *(const XFillStyleItem*)pOld == aStyleItem ) )
989 rAttrs.Put( aStyleItem );
990 bModified = true;
994 break;
995 case XFILL_SOLID:
997 _nPos = m_pLbColor->GetSelectEntryPos();
998 if( _nPos != LISTBOX_ENTRY_NOTFOUND &&
999 m_pLbColor->IsValueChangedFromSaved() )
1001 XFillColorItem aItem( m_pLbColor->GetSelectEntry(),
1002 m_pLbColor->GetSelectEntryColor() );
1003 pOld = GetOldItem( rAttrs, XATTR_FILLCOLOR );
1004 if ( !pOld || !( *(const XFillColorItem*)pOld == aItem ) )
1006 rAttrs.Put( aItem );
1007 bModified = true;
1010 // NEW
1011 if( (eSavedStyle != eStyle) &&
1012 ( bModified ||
1013 SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true ) ) )
1015 XFillStyleItem aStyleItem( XFILL_SOLID );
1016 pOld = GetOldItem( rAttrs, XATTR_FILLSTYLE );
1017 if ( !pOld || !( *(const XFillStyleItem*)pOld == aStyleItem ) )
1019 rAttrs.Put( aStyleItem );
1020 bModified = true;
1024 break;
1025 case XFILL_GRADIENT:
1027 _nPos = m_pLbGradient->GetSelectEntryPos();
1028 if( _nPos != LISTBOX_ENTRY_NOTFOUND &&
1029 m_pLbGradient->IsValueChangedFromSaved() )
1031 XGradient aGradient = pGradientList->GetGradient( _nPos )->GetGradient();
1032 OUString aString = m_pLbGradient->GetSelectEntry();
1033 XFillGradientItem aItem( aString, aGradient );
1034 pOld = GetOldItem( rAttrs, XATTR_FILLGRADIENT );
1035 if ( !pOld || !( *(const XFillGradientItem*)pOld == aItem ) )
1037 rAttrs.Put( aItem );
1038 bModified = true;
1041 // NEW
1042 if( (eSavedStyle != eStyle) &&
1043 ( bModified ||
1044 SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLGRADIENT ), true ) ) )
1046 XFillStyleItem aStyleItem( XFILL_GRADIENT );
1047 pOld = GetOldItem( rAttrs, XATTR_FILLSTYLE );
1048 if ( !pOld || !( *(const XFillStyleItem*)pOld == aStyleItem ) )
1050 rAttrs.Put( aStyleItem );
1051 bModified = true;
1055 break;
1056 case XFILL_HATCH:
1058 _nPos = m_pLbHatching->GetSelectEntryPos();
1059 if( _nPos != LISTBOX_ENTRY_NOTFOUND &&
1060 m_pLbHatching->IsValueChangedFromSaved() )
1062 XHatch aHatching = pHatchingList->GetHatch( _nPos )->GetHatch();
1063 OUString aString = m_pLbHatching->GetSelectEntry();
1064 XFillHatchItem aItem( aString, aHatching );
1065 pOld = GetOldItem( rAttrs, XATTR_FILLHATCH );
1066 if ( !pOld || !( *(const XFillHatchItem*)pOld == aItem ) )
1068 rAttrs.Put( aItem );
1069 bModified = true;
1072 XFillBackgroundItem aItem ( m_pCbxHatchBckgrd->IsChecked() );
1073 rAttrs.Put( aItem );
1074 nPos = m_pLbHatchBckgrdColor->GetSelectEntryPos();
1075 if( nPos != LISTBOX_ENTRY_NOTFOUND &&
1076 m_pLbHatchBckgrdColor->IsValueChangedFromSaved() )
1078 XFillColorItem aFillColorItem( m_pLbHatchBckgrdColor->GetSelectEntry(),
1079 m_pLbHatchBckgrdColor->GetSelectEntryColor() );
1080 pOld = GetOldItem( rAttrs, XATTR_FILLCOLOR );
1081 if ( !pOld || !( *(const XFillColorItem*)pOld == aFillColorItem ) )
1083 rAttrs.Put( aFillColorItem );
1084 bModified = true;
1087 // NEW
1088 if( (eSavedStyle != eStyle) &&
1089 ( bModified ||
1090 SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLHATCH ), true ) ) )
1092 XFillStyleItem aStyleItem( XFILL_HATCH );
1093 pOld = GetOldItem( rAttrs, XATTR_FILLSTYLE );
1094 if ( !pOld || !( *(const XFillStyleItem*)pOld == aStyleItem ) )
1096 rAttrs.Put( aStyleItem );
1097 bModified = true;
1101 break;
1102 case XFILL_BITMAP:
1104 nPos = m_pLbBitmap->GetSelectEntryPos();
1105 if( nPos != LISTBOX_ENTRY_NOTFOUND &&
1106 nPos != m_pLbBitmap->GetSavedValue() )
1108 const XBitmapEntry* pXBitmapEntry = pBitmapList->GetBitmap(nPos);
1109 const OUString aString(m_pLbBitmap->GetSelectEntry());
1110 const XFillBitmapItem aFillBitmapItem(aString, pXBitmapEntry->GetGraphicObject());
1111 pOld = GetOldItem( rAttrs, XATTR_FILLBITMAP );
1112 if ( !pOld || !( *(const XFillBitmapItem*)pOld == aFillBitmapItem ) )
1114 rAttrs.Put( aFillBitmapItem );
1115 bModified = true;
1118 // NEW
1119 if( (eSavedStyle != eStyle) &&
1120 ( bModified ||
1121 SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLBITMAP ), true ) ) )
1123 XFillStyleItem aStyleItem( XFILL_BITMAP );
1124 pOld = GetOldItem( rAttrs, XATTR_FILLSTYLE );
1125 if ( !pOld || !( *(const XFillStyleItem*)pOld == aStyleItem ) )
1127 rAttrs.Put( aStyleItem );
1128 bModified = true;
1132 break;
1135 // step size
1136 if( m_pTsbStepCount->IsEnabled() )
1138 sal_uInt16 nValue = 0;
1139 bool bValueModified = false;
1140 TriState eState = m_pTsbStepCount->GetState();
1141 if( eState == TRISTATE_TRUE )
1143 if( m_pTsbStepCount->IsValueChangedFromSaved() )
1144 bValueModified = true;
1146 else
1148 // condition != Disabled ?
1149 if( !m_pNumFldStepCount->GetText().isEmpty() )
1151 nValue = (sal_uInt16) m_pNumFldStepCount->GetValue();
1152 if( m_pNumFldStepCount->IsValueChangedFromSaved() )
1153 bValueModified = true;
1156 if( bValueModified )
1158 XGradientStepCountItem aFillBitmapItem( nValue );
1159 pOld = GetOldItem( rAttrs, XATTR_GRADIENTSTEPCOUNT );
1160 if ( !pOld || !( *(const XGradientStepCountItem*)pOld == aFillBitmapItem ) )
1162 rAttrs.Put( aFillBitmapItem );
1163 bModified = true;
1168 if( m_pTsbTile->IsEnabled() )
1170 TriState eState = m_pTsbTile->GetState();
1171 if( m_pTsbTile->IsValueChangedFromSaved() )
1173 XFillBmpTileItem aFillBmpTileItem(
1174 sal::static_int_cast< sal_Bool >( eState ) );
1175 pOld = GetOldItem( rAttrs, XATTR_FILLBMP_TILE );
1176 if ( !pOld || !( *(const XFillBmpTileItem*)pOld == aFillBmpTileItem ) )
1178 rAttrs.Put( aFillBmpTileItem );
1179 bModified = true;
1184 if( m_pTsbStretch->IsEnabled() )
1186 TriState eState = m_pTsbStretch->GetState();
1187 if( m_pTsbStretch->IsValueChangedFromSaved() )
1189 XFillBmpStretchItem aFillBmpStretchItem(
1190 sal::static_int_cast< sal_Bool >( eState ) );
1191 pOld = GetOldItem( rAttrs, XATTR_FILLBMP_STRETCH );
1192 if ( !pOld || !( *(const XFillBmpStretchItem*)pOld == aFillBmpStretchItem ) )
1194 rAttrs.Put( aFillBmpStretchItem );
1195 bModified = true;
1200 // Original size (in the UI) is used as follows:
1201 // Controls are disabled, but have to be set.
1202 // SizeX = 0; SizeY = 0; Log = sal_True
1204 //aTsbScale
1205 TriState eState = m_pTsbScale->GetState();
1206 if( m_pTsbScale->IsValueChangedFromSaved() ||
1207 ( !m_pTsbScale->IsEnabled() &&
1208 m_pTsbOriginal->IsEnabled() &&
1209 m_pTsbScale->GetSavedValue() != TRISTATE_TRUE ) )
1211 XFillBmpSizeLogItem* pItem = NULL;
1212 if( m_pTsbScale->IsEnabled() )
1213 pItem = new XFillBmpSizeLogItem( eState == TRISTATE_FALSE );
1214 else if( m_pTsbOriginal->IsEnabled() && m_pTsbOriginal->GetState() == TRISTATE_TRUE )
1215 pItem = new XFillBmpSizeLogItem( true );
1217 if( pItem )
1219 pOld = GetOldItem( rAttrs, XATTR_FILLBMP_SIZELOG );
1220 if ( !pOld || !( *(const XFillBmpSizeLogItem*)pOld == *pItem ) )
1222 rAttrs.Put( *pItem );
1223 bModified = true;
1225 delete pItem;
1229 //aMtrFldXSize
1230 OUString aStr = m_pMtrFldXSize->GetText();
1232 XFillBmpSizeXItem* pItem = NULL;
1233 TriState eScaleState = m_pTsbScale->GetState();
1235 if( m_pMtrFldXSize->IsEnabled() &&
1236 !aStr.isEmpty() &&
1237 aStr != m_pMtrFldXSize->GetSavedValue() )
1239 if( eScaleState == TRISTATE_FALSE )
1240 pItem = new XFillBmpSizeXItem( GetCoreValue( *m_pMtrFldXSize, ePoolUnit ) );
1241 else
1243 // Percentage values are set negatively, so that
1244 // they aren't scaled; this is considered in the item.
1245 pItem = new XFillBmpSizeXItem( -labs( static_cast<long>(m_pMtrFldXSize->GetValue()) ) );
1248 else if( m_pTsbOriginal->IsEnabled() &&
1249 m_pTsbOriginal->GetState() == TRISTATE_TRUE &&
1250 !m_pMtrFldXSize->GetSavedValue().isEmpty() )
1251 pItem = new XFillBmpSizeXItem( 0 );
1253 if( pItem )
1255 pOld = GetOldItem( rAttrs, XATTR_FILLBMP_SIZEX );
1256 if ( !pOld || !( *(const XFillBmpSizeXItem*)pOld == *pItem ) )
1258 rAttrs.Put( *pItem );
1259 bModified = true;
1261 delete pItem;
1265 //aMtrFldYSize
1266 aStr = m_pMtrFldYSize->GetText();
1268 XFillBmpSizeYItem* pItem = NULL;
1269 TriState eScaleState = m_pTsbScale->GetState();
1271 if( m_pMtrFldYSize->IsEnabled() &&
1272 !aStr.isEmpty() &&
1273 aStr != m_pMtrFldYSize->GetSavedValue() )
1275 if( eScaleState == TRISTATE_FALSE )
1276 pItem = new XFillBmpSizeYItem( GetCoreValue( *m_pMtrFldYSize, ePoolUnit ) );
1277 else
1279 // Percentage values are set negatively, so that
1280 // they aren't scaled by the MetricItem;
1281 // this is considered in the item.
1282 pItem = new XFillBmpSizeYItem( -labs( static_cast<long>(m_pMtrFldYSize->GetValue()) ) );
1285 else if( m_pTsbOriginal->IsEnabled() &&
1286 m_pTsbOriginal->GetState() == TRISTATE_TRUE &&
1287 !m_pMtrFldYSize->GetSavedValue().isEmpty() )
1288 pItem = new XFillBmpSizeYItem( 0 );
1290 if( pItem )
1292 pOld = GetOldItem( rAttrs, XATTR_FILLBMP_SIZEY );
1293 if ( !pOld || !( *(const XFillBmpSizeYItem*)pOld == *pItem ) )
1295 rAttrs.Put( *pItem );
1296 bModified = true;
1298 delete pItem;
1302 //aRbtRow
1303 //aRbtColumn
1304 //aMtrFldOffset
1305 if( m_pMtrFldOffset->IsEnabled() )
1307 OUString aMtrString = m_pMtrFldOffset->GetText();
1308 if( ( !aMtrString.isEmpty() &&
1309 aMtrString != m_pMtrFldOffset->GetSavedValue() ) ||
1310 m_pRbtRow->IsValueChangedFromSaved() ||
1311 m_pRbtColumn->IsValueChangedFromSaved() )
1313 if( m_pRbtRow->IsChecked() )
1315 XFillBmpTileOffsetXItem aFillBmpTileOffsetXItem( (sal_uInt16) m_pMtrFldOffset->GetValue() );
1316 pOld = GetOldItem( rAttrs, XATTR_FILLBMP_TILEOFFSETX );
1317 if ( !pOld || !( *(const XFillBmpTileOffsetXItem*)pOld == aFillBmpTileOffsetXItem ) )
1319 rAttrs.Put( aFillBmpTileOffsetXItem );
1320 rAttrs.Put( XFillBmpTileOffsetYItem( 0 ) );
1321 bModified = true;
1324 else if( m_pRbtColumn->IsChecked() )
1326 XFillBmpTileOffsetYItem aFillBmpTileOffsetYItem( (sal_uInt16) m_pMtrFldOffset->GetValue() );
1327 pOld = GetOldItem( rAttrs, XATTR_FILLBMP_TILEOFFSETY );
1328 if ( !pOld || !( *(const XFillBmpTileOffsetYItem*)pOld == aFillBmpTileOffsetYItem ) )
1330 rAttrs.Put( aFillBmpTileOffsetYItem );
1331 rAttrs.Put( XFillBmpTileOffsetXItem( 0 ) );
1332 bModified = true;
1338 //aCtlPosition
1339 if( m_pCtlPosition->IsEnabled() )
1341 bool bPut = false;
1342 RECT_POINT _eRP = m_pCtlPosition->GetActualRP();
1344 if( SFX_ITEM_DONTCARE == rOutAttrs.GetItemState( XATTR_FILLBMP_POS ) )
1345 bPut = true;
1346 else
1348 RECT_POINT eValue = ( ( const XFillBmpPosItem& ) rOutAttrs.Get( XATTR_FILLBMP_POS ) ).GetValue();
1349 if( eValue != _eRP )
1350 bPut = true;
1352 if( bPut )
1354 XFillBmpPosItem aFillBmpPosItem( _eRP );
1355 pOld = GetOldItem( rAttrs, XATTR_FILLBMP_POS );
1356 if ( !pOld || !( *(const XFillBmpPosItem*)pOld == aFillBmpPosItem ) )
1358 rAttrs.Put( aFillBmpPosItem );
1359 bModified = true;
1364 //aMtrFldXOffset
1365 if( m_pMtrFldXOffset->IsEnabled() )
1367 OUString sMtrXOffset = m_pMtrFldXOffset->GetText();
1368 if( !sMtrXOffset.isEmpty() &&
1369 m_pMtrFldXOffset->IsValueChangedFromSaved() )
1371 XFillBmpPosOffsetXItem aFillBmpPosOffsetXItem( (sal_uInt16) m_pMtrFldXOffset->GetValue() );
1372 pOld = GetOldItem( rAttrs, XATTR_FILLBMP_POSOFFSETX );
1373 if ( !pOld || !( *(const XFillBmpPosOffsetXItem*)pOld == aFillBmpPosOffsetXItem ) )
1375 rAttrs.Put( aFillBmpPosOffsetXItem );
1376 bModified = true;
1381 //aMtrFldYOffset
1382 if( m_pMtrFldYOffset->IsEnabled() )
1384 OUString sMtrYOffset = m_pMtrFldYOffset->GetText();
1385 if( !sMtrYOffset.isEmpty() &&
1386 m_pMtrFldYOffset->IsValueChangedFromSaved() )
1388 XFillBmpPosOffsetYItem aFillBmpPosOffsetYItem( (sal_uInt16) m_pMtrFldYOffset->GetValue() );
1389 pOld = GetOldItem( rAttrs, XATTR_FILLBMP_POSOFFSETY );
1390 if ( !pOld || !( *(const XFillBmpPosOffsetYItem*)pOld == aFillBmpPosOffsetYItem ) )
1392 rAttrs.Put( aFillBmpPosOffsetYItem );
1393 bModified = true;
1397 rAttrs.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType));
1398 rAttrs.Put (SfxUInt16Item(SID_TABPAGE_POS,nPos));
1401 return( bModified );
1406 void SvxAreaTabPage::Reset( const SfxItemSet& rAttrs )
1408 bool isMissingHatching(false);
1409 bool isMissingGradient(false);
1410 bool isMissingBitmap(false);
1411 XFillStyle eXFS;
1412 if( rAttrs.GetItemState( XATTR_FILLSTYLE ) != SFX_ITEM_DONTCARE )
1414 eXFS = (XFillStyle) ( ( ( const XFillStyleItem& ) rAttrs.
1415 Get( GetWhich( XATTR_FILLSTYLE ) ) ).GetValue() );
1416 m_pTypeLB->SelectEntryPos( sal::static_int_cast< sal_Int32 >( eXFS ) );
1418 if (SFX_ITEM_DONTCARE != rAttrs.GetItemState(XATTR_FILLCOLOR))
1420 XFillColorItem const& rColorItem(static_cast<const XFillColorItem&>(
1421 rAttrs.Get(XATTR_FILLCOLOR)) );
1422 m_pLbColor->SelectEntry( rColorItem.GetColorValue() );
1423 m_pLbHatchBckgrdColor->SelectEntry( rColorItem.GetColorValue() );
1426 if (SFX_ITEM_DONTCARE != rAttrs.GetItemState(XATTR_FILLGRADIENT))
1428 XFillGradientItem const& rGradientItem(
1429 static_cast<const XFillGradientItem&>(
1430 rAttrs.Get(XATTR_FILLGRADIENT)) );
1431 OUString const aString( rGradientItem.GetName() );
1432 XGradient const aGradient( rGradientItem.GetGradientValue() );
1434 m_pLbGradient->SelectEntryByList(pGradientList, aString, aGradient);
1436 if (!m_pLbGradient->GetSelectEntryCount())
1437 { // avoid relying on pool default - cannot export that
1438 m_pLbGradient->SelectEntryPos(0); // anything better than nothing
1439 isMissingGradient = true;
1442 if (SFX_ITEM_DONTCARE != rAttrs.GetItemState(XATTR_FILLHATCH))
1444 m_pLbHatching->SelectEntry( static_cast<const XFillHatchItem&>(
1445 rAttrs.Get(XATTR_FILLHATCH)).GetName() );
1447 if (!m_pLbHatching->GetSelectEntryCount())
1448 { // avoid relying on pool default - cannot export that
1449 m_pLbHatching->SelectEntryPos(0); // anything better than nothing
1450 isMissingHatching = true;
1452 if (SFX_ITEM_DONTCARE != rAttrs.GetItemState(XATTR_FILLBACKGROUND))
1454 m_pCbxHatchBckgrd->Check( static_cast<const XFillBackgroundItem&>(
1455 rAttrs.Get(XATTR_FILLBACKGROUND)).GetValue() );
1458 if (SFX_ITEM_DONTCARE != rAttrs.GetItemState(XATTR_FILLBITMAP))
1460 XFillBitmapItem const& rBitmapItem(
1461 static_cast<const XFillBitmapItem&>(
1462 rAttrs.Get(XATTR_FILLBITMAP)));
1463 m_pLbBitmap->SelectEntry(rBitmapItem.GetName());
1465 if (!m_pLbBitmap->GetSelectEntryCount())
1466 { // avoid relying on pool default - cannot export that
1467 m_pLbBitmap->SelectEntryPos(0); // anything better than nothing
1468 isMissingBitmap = true;
1471 switch( eXFS )
1473 case XFILL_NONE:
1474 ClickInvisibleHdl_Impl();
1475 break;
1477 case XFILL_SOLID:
1478 ClickColorHdl_Impl();
1479 break;
1481 case XFILL_GRADIENT:
1482 ClickGradientHdl_Impl();
1483 break;
1485 case XFILL_HATCH:
1486 ClickHatchingHdl_Impl();
1487 ToggleHatchBckgrdColorHdl_Impl( this );
1488 break;
1490 case XFILL_BITMAP:
1492 ClickBitmapHdl_Impl();
1494 break;
1496 default:
1497 assert(false);
1498 break;
1501 else
1503 // make all LBs not accessible
1504 m_pFillLB->Hide();
1506 m_pCtlBitmapPreview->Hide();
1507 m_pLbColor->Disable();
1508 m_pLbColor->Show();
1510 // so that Reset() also works correctly with Back
1511 m_pTypeLB->SetNoSelection();
1514 // step size
1515 if( ( rAttrs.GetItemState( XATTR_GRADIENTSTEPCOUNT ) != SFX_ITEM_DONTCARE ) ||
1516 ( rAttrs.GetItemState( XATTR_FILLSTYLE ) != SFX_ITEM_DONTCARE ) )
1518 m_pTsbStepCount->EnableTriState( false );
1519 sal_uInt16 nValue = ( ( const XGradientStepCountItem& ) rAttrs.Get( XATTR_GRADIENTSTEPCOUNT ) ).GetValue();
1520 if( nValue == 0 )
1522 m_pTsbStepCount->SetState( TRISTATE_TRUE );
1523 m_pNumFldStepCount->SetText( "" );
1525 else
1527 m_pTsbStepCount->SetState( TRISTATE_FALSE );
1528 m_pNumFldStepCount->SetValue( nValue );
1530 ModifyStepCountHdl_Impl( m_pTsbStepCount );
1532 else
1534 m_pTsbStepCount->SetState( TRISTATE_INDET );
1535 m_pNumFldStepCount->SetText( "" );
1538 // attributes for the bitmap filling
1540 if( rAttrs.GetItemState( XATTR_FILLBMP_TILE ) != SFX_ITEM_DONTCARE )
1542 m_pTsbTile->EnableTriState( false );
1544 if( ( ( const XFillBmpTileItem& ) rAttrs.Get( XATTR_FILLBMP_TILE ) ).GetValue() )
1545 m_pTsbTile->SetState( TRISTATE_TRUE );
1546 else
1547 m_pTsbTile->SetState( TRISTATE_FALSE );
1549 else
1550 m_pTsbTile->SetState( TRISTATE_INDET );
1552 if( rAttrs.GetItemState( XATTR_FILLBMP_STRETCH ) != SFX_ITEM_DONTCARE )
1554 m_pTsbStretch->EnableTriState( false );
1556 if( ( ( const XFillBmpStretchItem& ) rAttrs.Get( XATTR_FILLBMP_STRETCH ) ).GetValue() )
1557 m_pTsbStretch->SetState( TRISTATE_TRUE );
1558 else
1559 m_pTsbStretch->SetState( TRISTATE_FALSE );
1561 else
1562 m_pTsbStretch->SetState( TRISTATE_INDET );
1565 //aTsbScale
1566 if( rAttrs.GetItemState( XATTR_FILLBMP_SIZELOG ) != SFX_ITEM_DONTCARE )
1568 m_pTsbScale->EnableTriState( false );
1570 if( ( ( const XFillBmpSizeLogItem& ) rAttrs.Get( XATTR_FILLBMP_SIZELOG ) ).GetValue() )
1571 m_pTsbScale->SetState( TRISTATE_FALSE );
1572 else
1573 m_pTsbScale->SetState( TRISTATE_TRUE );
1575 ClickScaleHdl_Impl( NULL );
1577 else
1578 m_pTsbScale->SetState( TRISTATE_INDET );
1581 // determine status for the original size
1582 TriState eOriginal = TRISTATE_FALSE;
1584 //aMtrFldXSize
1585 if( rAttrs.GetItemState( XATTR_FILLBMP_SIZEX ) != SFX_ITEM_DONTCARE )
1587 sal_Int32 nValue = ( ( const XFillBmpSizeXItem& ) rAttrs.Get( XATTR_FILLBMP_SIZEX ) ).GetValue();
1588 if( m_pTsbScale->GetState() == TRISTATE_TRUE )
1590 // If there's a percentage value in the item,
1591 // it is negative because of the MetricItems.
1592 m_pMtrFldXSize->SetValue( labs( nValue ) );
1594 else
1595 SetMetricValue( *m_pMtrFldXSize, nValue, ePoolUnit );
1596 m_pMtrFldXSize->SaveValue();
1598 if( nValue == 0 )
1600 eOriginal = TRISTATE_TRUE;
1601 // value would be too small otherwise when turning off the original size
1602 // (performance problem)
1603 m_pMtrFldXSize->SetValue( 100 );
1606 else
1608 m_pMtrFldXSize->SetText( "" );
1609 m_pMtrFldXSize->SaveValue();
1612 //aMtrFldYSize
1613 if( rAttrs.GetItemState( XATTR_FILLBMP_SIZEY ) != SFX_ITEM_DONTCARE )
1615 sal_Int32 nValue = ( ( const XFillBmpSizeYItem& ) rAttrs.Get( XATTR_FILLBMP_SIZEY ) ).GetValue();
1616 if( m_pTsbScale->GetState() == TRISTATE_TRUE )
1618 // If there's a percentage value in the item,
1619 // it is negative because of the MetricItems.
1620 m_pMtrFldYSize->SetValue( labs( nValue ) );
1622 else
1623 SetMetricValue( *m_pMtrFldYSize, nValue, ePoolUnit );
1624 m_pMtrFldYSize->SaveValue();
1626 if( nValue == 0 )
1627 m_pMtrFldYSize->SetValue( 100 ); //s.o.
1628 else
1629 eOriginal = TRISTATE_FALSE;
1631 else
1633 m_pMtrFldYSize->SetText( "" );
1634 m_pMtrFldYSize->SaveValue();
1635 eOriginal = TRISTATE_FALSE;
1638 // aTsbOriginal
1639 m_pTsbOriginal->SetState( eOriginal );
1641 // #93372# Setting proper state after changing button
1642 ModifyTileHdl_Impl( NULL );
1644 //aRbtRow
1645 //aRbtColumn
1646 //aMtrFldOffset
1647 if( rAttrs.GetItemState( XATTR_FILLBMP_TILEOFFSETX ) != SFX_ITEM_DONTCARE )
1649 sal_uInt16 nValue = ( ( const XFillBmpTileOffsetXItem& ) rAttrs.Get( XATTR_FILLBMP_TILEOFFSETX ) ).GetValue();
1650 if( nValue > 0 )
1652 m_pMtrFldOffset->SetValue( nValue );
1653 m_pRbtRow->Check();
1655 else if( rAttrs.GetItemState( XATTR_FILLBMP_TILEOFFSETY ) != SFX_ITEM_DONTCARE )
1657 nValue = ( ( const XFillBmpTileOffsetYItem& ) rAttrs.Get( XATTR_FILLBMP_TILEOFFSETY ) ).GetValue();
1658 if( nValue > 0 )
1660 m_pMtrFldOffset->SetValue( nValue );
1661 m_pRbtColumn->Check();
1664 else
1665 m_pMtrFldOffset->SetValue( 0 );
1667 else
1668 m_pMtrFldOffset->SetText( "" );
1671 //aCtlPosition
1672 if( rAttrs.GetItemState( XATTR_FILLBMP_POS ) != SFX_ITEM_DONTCARE )
1674 RECT_POINT eValue = ( ( const XFillBmpPosItem& ) rAttrs.Get( XATTR_FILLBMP_POS ) ).GetValue();
1675 m_pCtlPosition->SetActualRP( eValue );
1677 else
1678 m_pCtlPosition->Reset();
1680 //aMtrFldXOffset
1681 if( rAttrs.GetItemState( XATTR_FILLBMP_POSOFFSETX ) != SFX_ITEM_DONTCARE )
1683 sal_Int32 nValue = ( ( const XFillBmpPosOffsetXItem& ) rAttrs.Get( XATTR_FILLBMP_POSOFFSETX ) ).GetValue();
1684 m_pMtrFldXOffset->SetValue( nValue );
1686 else
1687 m_pMtrFldXOffset->SetText( "" );
1689 //aMtrFldYOffset
1690 if( rAttrs.GetItemState( XATTR_FILLBMP_POSOFFSETY ) != SFX_ITEM_DONTCARE )
1692 sal_Int32 nValue = ( ( const XFillBmpPosOffsetYItem& ) rAttrs.Get( XATTR_FILLBMP_POSOFFSETY ) ).GetValue();
1693 m_pMtrFldYOffset->SetValue( nValue );
1695 else
1696 m_pMtrFldYOffset->SetText( "" );
1698 // not earlier so that tile and stretch are considered
1699 if( m_pTypeLB->GetSelectEntryPos() == XFILL_BITMAP )
1700 ClickBitmapHdl_Impl();
1702 m_pTypeLB->SaveValue();
1703 m_pLbColor->SaveValue();
1704 if (!isMissingGradient)
1705 m_pLbGradient->SaveValue();
1706 if (!isMissingHatching)
1707 m_pLbHatching->SaveValue();
1708 m_pLbHatchBckgrdColor->SaveValue();
1709 if (!isMissingBitmap)
1710 m_pLbBitmap->SaveValue();
1711 m_pTsbStepCount->SaveValue();
1712 m_pNumFldStepCount->SaveValue();
1713 m_pTsbTile->SaveValue();
1714 m_pTsbStretch->SaveValue();
1715 m_pTsbScale->SaveValue();
1716 m_pRbtRow->SaveValue();
1717 m_pRbtColumn->SaveValue();
1718 m_pMtrFldOffset->SaveValue();
1719 m_pMtrFldXOffset->SaveValue();
1720 m_pMtrFldYOffset->SaveValue();
1725 SfxTabPage* SvxAreaTabPage::Create( Window* pWindow,
1726 const SfxItemSet& rAttrs )
1728 return( new SvxAreaTabPage( pWindow, rAttrs ) );
1733 const sal_uInt16* SvxAreaTabPage::GetRanges()
1735 return( pAreaRanges );
1739 IMPL_LINK_NOARG(SvxAreaTabPage, SelectDialogTypeHdl_Impl)
1741 switch( (XFillStyle)m_pTypeLB->GetSelectEntryPos() )
1743 case XFILL_NONE: ClickInvisibleHdl_Impl(); break;
1744 case XFILL_SOLID: ClickColorHdl_Impl(); break;
1745 case XFILL_GRADIENT: ClickGradientHdl_Impl(); break;
1746 case XFILL_HATCH: ClickHatchingHdl_Impl(); break;
1747 case XFILL_BITMAP: ClickBitmapHdl_Impl(); break;
1750 return 0;
1753 void SvxAreaTabPage::ClickInvisibleHdl_Impl()
1755 m_pBxBitmap->Hide();
1757 m_pFillLB->Hide();
1759 m_pCtlXRectPreview->Hide();
1760 m_pCtlBitmapPreview->Hide();
1762 m_pFlStepCount->Hide();
1764 // Controls for Hatch-Background
1765 m_pFlHatchBckgrd->Hide();
1767 rXFSet.Put( XFillStyleItem( XFILL_NONE ) );
1768 m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() );
1769 m_pCtlBitmapPreview->SetAttributes( aXFillAttr.GetItemSet() );
1771 m_pCtlXRectPreview->Invalidate();
1772 m_pCtlBitmapPreview->Invalidate();
1777 void SvxAreaTabPage::ClickColorHdl_Impl()
1779 m_pBxBitmap->Hide();
1781 m_pFillLB->Show();
1782 m_pLbColor->Enable();
1783 m_pLbColor->Show();
1784 m_pLbGradient->Hide();
1785 m_pLbHatching->Hide();
1786 m_pLbBitmap->Hide();
1787 m_pCtlXRectPreview->Enable();
1788 m_pCtlXRectPreview->Show();
1789 m_pCtlBitmapPreview->Hide();
1791 m_pFlStepCount->Hide();
1793 // Controls for Hatch-Background
1794 m_pFlHatchBckgrd->Hide();
1796 // set table text
1797 OUString aString( CUI_RES( RID_SVXSTR_TABLE ) ); aString += ": ";
1798 INetURLObject aURL( pColorList->GetPath() );
1800 aURL.Append( pColorList->GetName() );
1801 DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
1803 if( aURL.getBase().getLength() > 18 )
1805 aString += aURL.getBase().copy( 0, 15 );
1806 aString += "...";
1808 else
1809 aString += aURL.getBase();
1811 ModifyColorHdl_Impl( this );
1816 IMPL_LINK_NOARG(SvxAreaTabPage, ModifyColorHdl_Impl)
1818 const SfxPoolItem* pPoolItem = NULL;
1819 sal_Int32 _nPos = m_pLbColor->GetSelectEntryPos();
1820 m_pLbHatchBckgrdColor->SelectEntryPos( _nPos );
1821 if( _nPos != LISTBOX_ENTRY_NOTFOUND )
1823 rXFSet.Put( XFillStyleItem( XFILL_SOLID ) );
1824 rXFSet.Put( XFillColorItem( OUString(), m_pLbColor->GetSelectEntryColor() ) );
1826 // NEW
1827 else if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) )
1829 rXFSet.Put( XFillStyleItem( XFILL_SOLID ) );
1830 Color aColor( ( ( const XFillColorItem* ) pPoolItem )->GetColorValue() );
1831 rXFSet.Put( XFillColorItem( OUString(), aColor ) );
1833 else
1834 rXFSet.Put( XFillStyleItem( XFILL_NONE ) );
1836 m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() );
1837 m_pCtlXRectPreview->Invalidate();
1839 return( 0L );
1843 void SvxAreaTabPage::ClickGradientHdl_Impl()
1845 m_pBxBitmap->Hide();
1847 m_pFillLB->Show();
1848 m_pLbColor->Hide();
1849 m_pLbGradient->Enable();
1850 m_pLbGradient->Show();
1851 m_pLbHatching->Hide();
1852 m_pLbBitmap->Hide();
1853 m_pCtlXRectPreview->Enable();
1854 m_pCtlXRectPreview->Show();
1855 m_pCtlBitmapPreview->Hide();
1857 m_pFlStepCount->Enable();
1858 m_pFlStepCount->Show();
1859 m_pTsbStepCount->Enable();
1860 m_pTsbStepCount->Show();
1861 m_pNumFldStepCount->Show();
1863 // Controls for Hatch-Background
1864 m_pFlHatchBckgrd->Hide();
1866 // set table text
1867 OUString aString( CUI_RES( RID_SVXSTR_TABLE ) ); aString += ": ";
1868 INetURLObject aURL( pGradientList->GetPath() );
1870 aURL.Append( pGradientList->GetName() );
1871 DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
1873 if( aURL.getBase().getLength() > 18 )
1875 aString += aURL.getBase().copy( 0, 15 );
1876 aString += "...";
1878 else
1879 aString += aURL.getBase();
1881 ModifyGradientHdl_Impl( this );
1882 ModifyStepCountHdl_Impl( m_pTsbStepCount );
1887 IMPL_LINK_NOARG(SvxAreaTabPage, ModifyGradientHdl_Impl)
1889 const SfxPoolItem* pPoolItem = NULL;
1890 sal_Int32 _nPos = m_pLbGradient->GetSelectEntryPos();
1891 if( _nPos != LISTBOX_ENTRY_NOTFOUND )
1893 // fill ItemSet and pass it on to aCtlXRectPreview
1894 XGradientEntry* pEntry = pGradientList->GetGradient( _nPos );
1896 rXFSet.Put( XFillStyleItem( XFILL_GRADIENT ) );
1897 rXFSet.Put( XFillGradientItem( OUString(), pEntry->GetGradient() ) );
1899 else if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLGRADIENT ), true, &pPoolItem ) )
1901 rXFSet.Put( XFillStyleItem( XFILL_GRADIENT ) );
1902 rXFSet.Put( XFillGradientItem( OUString(), ( ( const XFillGradientItem* ) pPoolItem )->GetGradientValue() ) );
1904 else
1905 rXFSet.Put( XFillStyleItem( XFILL_NONE ) );
1907 m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() );
1908 m_pCtlXRectPreview->Invalidate();
1910 return( 0L );
1915 void SvxAreaTabPage::ClickHatchingHdl_Impl()
1917 m_pFillLB->Show();
1918 m_pLbColor->Hide();
1919 m_pLbGradient->Hide();
1920 m_pLbHatching->Enable();
1921 m_pLbHatching->Show();
1922 m_pLbBitmap->Hide();
1923 m_pCtlXRectPreview->Enable();
1924 m_pCtlXRectPreview->Show();
1925 m_pCtlBitmapPreview->Hide();
1927 m_pFlStepCount->Hide();
1929 m_pBxBitmap->Hide();
1931 // Controls for Hatch-Background
1932 m_pFlHatchBckgrd->Show();
1933 m_pCbxHatchBckgrd->Enable();
1934 m_pLbHatchBckgrdColor->Enable();
1936 // set table text
1937 OUString aString( CUI_RES( RID_SVXSTR_TABLE ) ); aString += ": ";
1938 INetURLObject aURL( pHatchingList->GetPath() );
1940 aURL.Append( pHatchingList->GetName() );
1941 DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
1943 if( aURL.getBase().getLength() > 18 )
1945 aString += aURL.getBase().copy( 0, 15 );
1946 aString += "...";
1948 else
1949 aString += aURL.getBase();
1951 ModifyHatchingHdl_Impl( this );
1952 ModifyHatchBckgrdColorHdl_Impl( this );
1953 ToggleHatchBckgrdColorHdl_Impl( this );
1958 IMPL_LINK_NOARG(SvxAreaTabPage, ModifyHatchingHdl_Impl)
1960 const SfxPoolItem* pPoolItem = NULL;
1961 sal_Int32 _nPos = m_pLbHatching->GetSelectEntryPos();
1962 if( _nPos != LISTBOX_ENTRY_NOTFOUND )
1964 // fill ItemSet and pass it on to aCtlXRectPreview
1965 XHatchEntry* pEntry = pHatchingList->GetHatch( _nPos );
1967 rXFSet.Put( XFillStyleItem( XFILL_HATCH ) );
1968 rXFSet.Put( XFillHatchItem( OUString(), pEntry->GetHatch() ) );
1970 else if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLHATCH ), true, &pPoolItem ) )
1972 rXFSet.Put( XFillStyleItem( XFILL_HATCH ) );
1973 rXFSet.Put( XFillHatchItem( OUString(), ( ( const XFillHatchItem* ) pPoolItem )->GetHatchValue() ) );
1975 else
1976 rXFSet.Put( XFillStyleItem( XFILL_NONE ) );
1978 m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() );
1979 m_pCtlXRectPreview->Invalidate();
1981 return( 0L );
1986 IMPL_LINK_NOARG(SvxAreaTabPage, ModifyHatchBckgrdColorHdl_Impl)
1988 const SfxPoolItem* pPoolItem = NULL;
1989 sal_Int32 _nPos = m_pLbHatchBckgrdColor->GetSelectEntryPos();
1990 m_pLbColor->SelectEntryPos( _nPos );
1991 if( _nPos != LISTBOX_ENTRY_NOTFOUND )
1993 rXFSet.Put( XFillColorItem( OUString(), m_pLbHatchBckgrdColor->GetSelectEntryColor() ) );
1995 else if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) )
1997 Color aColor( ( ( const XFillColorItem* ) pPoolItem )->GetColorValue() );
1998 rXFSet.Put( XFillColorItem( OUString(), aColor ) );
2000 else
2001 rXFSet.Put( XFillStyleItem( XFILL_NONE ) );
2003 m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() );
2004 m_pCtlXRectPreview->Invalidate();
2006 return( 0L );
2011 IMPL_LINK_NOARG(SvxAreaTabPage, ToggleHatchBckgrdColorHdl_Impl)
2013 // switch on/off backgroundcolor for hatches
2014 m_pLbHatchBckgrdColor->Enable( m_pCbxHatchBckgrd->IsChecked() );
2016 XFillBackgroundItem aItem( m_pCbxHatchBckgrd->IsChecked() );
2017 rXFSet.Put ( aItem, XATTR_FILLBACKGROUND );
2019 m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() );
2020 m_pCtlXRectPreview->Invalidate();
2022 if( m_pLbHatchBckgrdColor->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND )
2024 if ( SFX_ITEM_SET == rOutAttrs.GetItemState( XATTR_FILLCOLOR ) )//>= SFX_ITEM_DEFAULT )
2026 XFillColorItem aColorItem( (const XFillColorItem&)rOutAttrs.Get( XATTR_FILLCOLOR ) );
2027 m_pLbHatchBckgrdColor->SelectEntry( aColorItem.GetColorValue() );
2031 return( 0L );
2036 void SvxAreaTabPage::ClickBitmapHdl_Impl()
2038 m_pFillLB->Show();
2039 m_pLbColor->Hide();
2040 m_pLbGradient->Hide();
2041 m_pLbHatching->Hide();
2042 m_pLbBitmap->Enable();
2043 m_pLbBitmap->Show();
2044 m_pCtlBitmapPreview->Enable();
2045 m_pCtlBitmapPreview->Show();
2046 m_pCtlXRectPreview->Hide();
2048 m_pFlStepCount->Hide();
2050 m_pBxTile->Enable();
2052 m_pFlSize->Enable();
2053 m_pFlPosition->Enable();
2054 m_pFlOffset->Enable();
2056 if (!m_pRbtRow->IsChecked() && !m_pRbtColumn->IsChecked())
2057 m_pRbtRow->Check();
2059 // Controls for Hatch-Background
2060 m_pFlHatchBckgrd->Hide();
2062 m_pBxBitmap->Show();
2064 // set table text
2065 OUString aString( CUI_RES( RID_SVXSTR_TABLE ) ); aString += ": ";
2066 INetURLObject aURL( pBitmapList->GetPath() );
2068 aURL.Append( pBitmapList->GetName() );
2069 DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
2071 if( aURL.getBase().getLength() > 18 )
2073 aString += aURL.getBase().copy( 0, 15 );
2074 aString += "...";
2076 else
2077 aString += aURL.getBase();
2079 ModifyBitmapHdl_Impl( this );
2080 ModifyTileHdl_Impl( m_pTsbOriginal );
2085 IMPL_LINK_NOARG(SvxAreaTabPage, ModifyBitmapHdl_Impl)
2087 const SfxPoolItem* pPoolItem = NULL;
2088 sal_Int32 _nPos = m_pLbBitmap->GetSelectEntryPos();
2089 if( _nPos != LISTBOX_ENTRY_NOTFOUND )
2091 // fill ItemSet and pass it on to aCtlXRectPreview
2092 const XBitmapEntry* pEntry = pBitmapList->GetBitmap(_nPos);
2094 rXFSet.Put(XFillStyleItem(XFILL_BITMAP));
2095 rXFSet.Put(XFillBitmapItem(OUString(), pEntry->GetGraphicObject()));
2097 else if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLBITMAP ), true, &pPoolItem ) )
2099 rXFSet.Put(XFillStyleItem(XFILL_BITMAP));
2100 rXFSet.Put(XFillBitmapItem(OUString(), ((const XFillBitmapItem*)pPoolItem)->GetGraphicObject()));
2102 else
2103 rXFSet.Put( XFillStyleItem( XFILL_NONE ) );
2105 m_pCtlBitmapPreview->SetAttributes( aXFillAttr.GetItemSet() );
2106 m_pCtlBitmapPreview->Invalidate();
2108 return( 0L );
2113 IMPL_LINK( SvxAreaTabPage, ModifyStepCountHdl_Impl, void *, p )
2115 if( p == m_pTsbStepCount )
2117 if( m_pTsbStepCount->GetState() == TRISTATE_FALSE )
2119 if( m_pNumFldStepCount->GetText().isEmpty() )
2120 m_pNumFldStepCount->SetText("64");
2122 m_pNumFldStepCount->Enable();
2124 else
2125 m_pNumFldStepCount->Disable();
2128 sal_uInt16 nValue = 0;
2129 if( m_pTsbStepCount->GetState() != TRISTATE_TRUE )
2131 // condition != Disabled ?
2132 if( !m_pNumFldStepCount->GetText().isEmpty() )
2133 nValue = (sal_uInt16) m_pNumFldStepCount->GetValue();
2135 rXFSet.Put( XGradientStepCountItem( nValue ) );
2136 m_pCtlXRectPreview->SetAttributes( aXFillAttr.GetItemSet() );
2137 m_pCtlXRectPreview->Invalidate();
2139 return( 0L );
2144 IMPL_LINK_NOARG(SvxAreaTabPage, ModifyTileHdl_Impl)
2146 TriState eState = m_pTsbTile->GetState();
2147 if( eState == TRISTATE_TRUE )
2149 m_pTsbStretch->Disable();
2150 m_pFlOffset->Enable();
2152 m_pCtlPosition->Invalidate();
2153 m_pFlPosition->Enable();
2155 m_pFlSize->Enable();
2157 else if( eState == TRISTATE_FALSE )
2159 m_pTsbStretch->Enable();
2160 m_pFlOffset->Disable();
2162 m_pCtlPosition->Invalidate();
2163 m_pFlPosition->Disable();
2165 if( m_pTsbStretch->GetState() != TRISTATE_FALSE )
2168 m_pFlSize->Disable();
2170 else
2172 m_pFlSize->Enable();
2175 else
2177 m_pTsbStretch->Disable();
2178 m_pFlOffset->Disable();
2180 m_pCtlPosition->Invalidate();
2181 m_pFlPosition->Disable();
2183 m_pFlSize->Disable();
2186 if( m_pTsbOriginal->GetState() == TRISTATE_TRUE )
2188 m_pMtrFldXSize->SetText( "" );
2189 m_pMtrFldYSize->SetText( "" );
2190 m_pGridX_Y->Disable();
2191 m_pTsbScale->Disable();
2193 else
2195 m_pMtrFldXSize->SetValue( m_pMtrFldXSize->GetValue() );
2196 m_pMtrFldYSize->SetValue( m_pMtrFldYSize->GetValue() );
2199 rXFSet.Put( XFillBmpTileItem( sal::static_int_cast< sal_Bool >( eState ) ) );
2201 if( m_pTsbStretch->IsEnabled() )
2202 rXFSet.Put(
2203 XFillBmpStretchItem(
2204 sal::static_int_cast< sal_Bool >( m_pTsbStretch->GetState() ) ) );
2206 if( m_pTsbScale->IsEnabled() )
2207 rXFSet.Put( XFillBmpSizeLogItem( m_pTsbScale->GetState() == TRISTATE_FALSE ) );
2209 if( m_pMtrFldXSize->IsEnabled() )
2211 XFillBmpSizeXItem* pItem = NULL;
2212 TriState eScaleState = m_pTsbScale->GetState();
2214 if( eScaleState == TRISTATE_FALSE )
2215 pItem = new XFillBmpSizeXItem( GetCoreValue( *m_pMtrFldXSize, ePoolUnit ) );
2216 else
2217 pItem = new XFillBmpSizeXItem( -labs( static_cast<long>(m_pMtrFldXSize->GetValue()) ) );
2219 rXFSet.Put( *pItem );
2221 delete pItem;
2223 else if( m_pTsbOriginal->IsEnabled() && m_pTsbOriginal->GetState() == TRISTATE_TRUE )
2225 // original size -> size == 0
2226 rXFSet.Put( XFillBmpSizeXItem( 0 ) );
2227 rXFSet.Put( XFillBmpSizeLogItem( true ) );
2230 if( m_pMtrFldYSize->IsEnabled() )
2232 XFillBmpSizeYItem* pItem = NULL;
2233 TriState eScaleState = m_pTsbScale->GetState();
2235 if( eScaleState == TRISTATE_FALSE )
2236 pItem = new XFillBmpSizeYItem( GetCoreValue( *m_pMtrFldYSize, ePoolUnit ) );
2237 else
2238 pItem = new XFillBmpSizeYItem( -labs( static_cast<long>(m_pMtrFldYSize->GetValue()) ) );
2240 rXFSet.Put( *pItem );
2242 delete pItem;
2244 else if( m_pTsbOriginal->IsEnabled() && m_pTsbOriginal->GetState() == TRISTATE_TRUE )
2246 // original size -> size == 0
2247 rXFSet.Put( XFillBmpSizeYItem( 0 ) );
2248 rXFSet.Put( XFillBmpSizeLogItem( true ) );
2251 if( m_pMtrFldOffset->IsEnabled() )
2253 if( m_pRbtRow->IsChecked() )
2255 rXFSet.Put( XFillBmpTileOffsetXItem( (sal_uInt16) m_pMtrFldOffset->GetValue() ) );
2256 rXFSet.Put( XFillBmpTileOffsetYItem( (sal_uInt16) 0 ) );
2258 else if( m_pRbtColumn->IsChecked() )
2260 rXFSet.Put( XFillBmpTileOffsetXItem( (sal_uInt16) 0 ) );
2261 rXFSet.Put( XFillBmpTileOffsetYItem( (sal_uInt16) m_pMtrFldOffset->GetValue() ) );
2265 if( m_pCtlPosition->IsEnabled() )
2266 rXFSet.Put( XFillBmpPosItem( m_pCtlPosition->GetActualRP() ) );
2268 if( m_pMtrFldXOffset->IsEnabled() )
2269 rXFSet.Put( XFillBmpPosOffsetXItem( (sal_uInt16) m_pMtrFldXOffset->GetValue() ) );
2271 if( m_pMtrFldYOffset->IsEnabled() )
2272 rXFSet.Put( XFillBmpPosOffsetYItem( (sal_uInt16) m_pMtrFldYOffset->GetValue() ) );
2275 m_pCtlBitmapPreview->SetAttributes( aXFillAttr.GetItemSet() );
2276 m_pCtlBitmapPreview->Invalidate();
2278 return( 0L );
2283 IMPL_LINK_NOARG(SvxAreaTabPage, ClickScaleHdl_Impl)
2285 if( m_pTsbScale->GetState() == TRISTATE_TRUE )
2287 m_pMtrFldXSize->SetDecimalDigits( 0 );
2288 m_pMtrFldXSize->SetUnit(FUNIT_PERCENT);
2289 m_pMtrFldXSize->SetValue( 100 );
2290 m_pMtrFldXSize->SetMax( 100 );
2291 m_pMtrFldXSize->SetLast( 100 );
2293 m_pMtrFldYSize->SetDecimalDigits( 0 );
2294 m_pMtrFldYSize->SetUnit(FUNIT_PERCENT);
2295 m_pMtrFldYSize->SetValue( 100 );
2296 m_pMtrFldYSize->SetMax( 100 );
2297 m_pMtrFldYSize->SetLast( 100 );
2299 else
2301 m_pMtrFldXSize->SetDecimalDigits( 2 );
2302 m_pMtrFldXSize->SetUnit( eFUnit );
2303 m_pMtrFldXSize->SetValue( 100 );
2304 m_pMtrFldXSize->SetMax( 999900 );
2305 m_pMtrFldXSize->SetLast( 100000 );
2307 m_pMtrFldYSize->SetDecimalDigits( 2 );
2308 m_pMtrFldYSize->SetUnit( eFUnit );
2309 m_pMtrFldYSize->SetValue( 100 );
2310 m_pMtrFldYSize->SetMax( 999900 );
2311 m_pMtrFldYSize->SetLast( 100000 );
2314 ModifyTileHdl_Impl( NULL );
2316 return( 0L );
2321 void SvxAreaTabPage::PointChanged( Window* pWindow, RECT_POINT eRcPt )
2323 eRP = eRcPt;
2325 // alignment of the bitmap fill
2326 ModifyTileHdl_Impl( pWindow );
2329 void SvxAreaTabPage::PageCreated(const SfxAllItemSet& aSet)
2331 SFX_ITEMSET_ARG (&aSet,pColorListItem,SvxColorListItem,SID_COLOR_TABLE,false);
2332 SFX_ITEMSET_ARG (&aSet,pGradientListItem,SvxGradientListItem,SID_GRADIENT_LIST,false);
2333 SFX_ITEMSET_ARG (&aSet,pHatchingListItem,SvxHatchListItem,SID_HATCH_LIST,false);
2334 SFX_ITEMSET_ARG (&aSet,pBitmapListItem,SvxBitmapListItem,SID_BITMAP_LIST,false);
2335 SFX_ITEMSET_ARG (&aSet,pPageTypeItem,SfxUInt16Item,SID_PAGE_TYPE,false);
2336 SFX_ITEMSET_ARG (&aSet,pDlgTypeItem,SfxUInt16Item,SID_DLG_TYPE,false);
2337 SFX_ITEMSET_ARG (&aSet,pPosItem,SfxUInt16Item,SID_TABPAGE_POS,false);
2339 if (pColorListItem)
2340 SetColorList(pColorListItem->GetColorList());
2341 if (pGradientListItem)
2342 SetGradientList(pGradientListItem->GetGradientList());
2343 if (pHatchingListItem)
2344 SetHatchingList(pHatchingListItem->GetHatchList());
2345 if (pBitmapListItem)
2346 SetBitmapList(pBitmapListItem->GetBitmapList());
2347 if (pPageTypeItem)
2348 SetPageType(pPageTypeItem->GetValue());
2349 if (pDlgTypeItem)
2350 SetDlgType(pDlgTypeItem->GetValue());
2351 if (pPosItem)
2352 SetPos(pPosItem->GetValue());
2353 Construct();
2356 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */