xref: /trunk/main/svx/source/dialog/_contdlg.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svx.hxx"
30*cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
31*cdf0e10cSrcweir #include <sot/factory.hxx>
32*cdf0e10cSrcweir #include <tools/shl.hxx>
33*cdf0e10cSrcweir #include <vcl/salbtype.hxx>     // FRound
34*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
35*cdf0e10cSrcweir #include <svl/eitem.hxx>
36*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
37*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
38*cdf0e10cSrcweir #include <svtools/miscopt.hxx>
39*cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
40*cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
41*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
42*cdf0e10cSrcweir #endif
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #define _SDR_NOITEMS
45*cdf0e10cSrcweir #define _SDR_NOTOUCH
46*cdf0e10cSrcweir #define _SDR_NOTRANSFORM
47*cdf0e10cSrcweir #define _SDR_NOOBJECTS
48*cdf0e10cSrcweir #define _SDR_NOVIEWMARKER
49*cdf0e10cSrcweir #define _SDR_NODRAGMETHODS
50*cdf0e10cSrcweir #define _SDR_NOUNDO
51*cdf0e10cSrcweir #define _SDR_NOXOUTDEV
52*cdf0e10cSrcweir #define _XOUTBMP_STATICS_ONLY
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir #include <svx/dialmgr.hxx>
55*cdf0e10cSrcweir #include "svx/xoutbmp.hxx"
56*cdf0e10cSrcweir #include <svx/dialogs.hrc>
57*cdf0e10cSrcweir #include <svx/svxids.hrc>
58*cdf0e10cSrcweir #include <svx/contdlg.hxx>
59*cdf0e10cSrcweir #include "contimp.hxx"
60*cdf0e10cSrcweir #include "contdlg.hrc"
61*cdf0e10cSrcweir #include "contwnd.hxx"
62*cdf0e10cSrcweir #include <svx/svdtrans.hxx>
63*cdf0e10cSrcweir #include <svx/svdopath.hxx>
64*cdf0e10cSrcweir #include "svx/dlgutil.hxx"
65*cdf0e10cSrcweir #include <vcl/svapp.hxx>
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir /******************************************************************************/
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir inline String GetUnitString( long nVal_100, FieldUnit eFieldUnit, sal_Unicode cSep )
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir     String aVal = UniString::CreateFromInt64( MetricField::ConvertValue( nVal_100, 2, MAP_100TH_MM, eFieldUnit ) );
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir     while( aVal.Len() < 3 )
74*cdf0e10cSrcweir         aVal.Insert( sal_Unicode('0'), 0 );
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir     aVal.Insert( cSep, aVal.Len() - 2 );
77*cdf0e10cSrcweir     aVal += sal_Unicode(' ');
78*cdf0e10cSrcweir     aVal += SdrFormatter::GetUnitStr( eFieldUnit );
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     return aVal;
81*cdf0e10cSrcweir }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir /******************************************************************************/
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir SFX_IMPL_FLOATINGWINDOW( SvxContourDlgChildWindow, SID_CONTOUR_DLG );
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir /******************************************************************************/
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir /*************************************************************************
94*cdf0e10cSrcweir |*
95*cdf0e10cSrcweir |* ControllerItem
96*cdf0e10cSrcweir |*
97*cdf0e10cSrcweir \************************************************************************/
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir SvxContourDlgItem::SvxContourDlgItem( sal_uInt16 _nId, SvxSuperContourDlg& rContourDlg, SfxBindings& rBindings ) :
100*cdf0e10cSrcweir             SfxControllerItem   ( _nId, rBindings ),
101*cdf0e10cSrcweir             rDlg                ( rContourDlg )
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir }
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir /*************************************************************************
107*cdf0e10cSrcweir |*
108*cdf0e10cSrcweir |*
109*cdf0e10cSrcweir |*
110*cdf0e10cSrcweir \************************************************************************/
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir void SvxContourDlgItem::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/, const SfxPoolItem* pItem )
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir     if ( pItem && ( SID_CONTOUR_EXEC == nSID ) )
115*cdf0e10cSrcweir     {
116*cdf0e10cSrcweir         const SfxBoolItem* pStateItem = PTR_CAST( SfxBoolItem, pItem );
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir         DBG_ASSERT( pStateItem || pItem == 0, "SfxBoolItem erwartet");
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir         rDlg.SetExecState( !pStateItem->GetValue() );
121*cdf0e10cSrcweir     }
122*cdf0e10cSrcweir }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir /******************************************************************************/
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir /*************************************************************************
129*cdf0e10cSrcweir |*
130*cdf0e10cSrcweir |* Contour-Float
131*cdf0e10cSrcweir |*
132*cdf0e10cSrcweir \************************************************************************/
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir SvxContourDlgChildWindow::SvxContourDlgChildWindow( Window* _pParent, sal_uInt16 nId,
135*cdf0e10cSrcweir                                                     SfxBindings* pBindings, SfxChildWinInfo* pInfo ) :
136*cdf0e10cSrcweir             SfxChildWindow( _pParent, nId )
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir     SvxSuperContourDlg* pDlg = new SvxSuperContourDlg( pBindings, this, _pParent, CONT_RESID( RID_SVXDLG_CONTOUR ) );
139*cdf0e10cSrcweir     pWindow = pDlg;
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     if ( pInfo->nFlags & SFX_CHILDWIN_ZOOMIN )
142*cdf0e10cSrcweir         pDlg->RollUp();
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir     eChildAlignment = SFX_ALIGN_NOALIGNMENT;
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     pDlg->Initialize( pInfo );
147*cdf0e10cSrcweir }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir /*************************************************************************
150*cdf0e10cSrcweir |*
151*cdf0e10cSrcweir |*
152*cdf0e10cSrcweir |*
153*cdf0e10cSrcweir \************************************************************************/
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir void SvxContourDlgChildWindow::UpdateContourDlg( const Graphic& rGraphic, sal_Bool bGraphicLinked,
156*cdf0e10cSrcweir                                                  const PolyPolygon* pPolyPoly, void* pEditingObj )
157*cdf0e10cSrcweir {
158*cdf0e10cSrcweir     if ( SfxViewFrame::Current() &&
159*cdf0e10cSrcweir          SfxViewFrame::Current()->HasChildWindow( SvxContourDlgChildWindow::GetChildWindowId() ) )
160*cdf0e10cSrcweir         SVXCONTOURDLG()->Update( rGraphic, bGraphicLinked, pPolyPoly, pEditingObj );
161*cdf0e10cSrcweir }
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir /*************************************************************************
164*cdf0e10cSrcweir |*
165*cdf0e10cSrcweir |*
166*cdf0e10cSrcweir |*
167*cdf0e10cSrcweir \************************************************************************/
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir SvxContourDlg::SvxContourDlg( SfxBindings* _pBindings, SfxChildWindow* pCW,
170*cdf0e10cSrcweir                               Window* _pParent, const ResId& rResId ) :
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     SfxFloatingWindow   ( _pBindings, pCW, _pParent, rResId )
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir {
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir /*************************************************************************
178*cdf0e10cSrcweir |*
179*cdf0e10cSrcweir |*
180*cdf0e10cSrcweir |*
181*cdf0e10cSrcweir \************************************************************************/
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir SvxContourDlg::~SvxContourDlg()
184*cdf0e10cSrcweir {
185*cdf0e10cSrcweir }
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir /*************************************************************************
188*cdf0e10cSrcweir |*
189*cdf0e10cSrcweir |*
190*cdf0e10cSrcweir |*
191*cdf0e10cSrcweir \************************************************************************/
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir PolyPolygon SvxContourDlg::CreateAutoContour( const Graphic& rGraphic,
194*cdf0e10cSrcweir                                               const Rectangle* pRect,
195*cdf0e10cSrcweir                                               const sal_uIntPtr nFlags )
196*cdf0e10cSrcweir {
197*cdf0e10cSrcweir     Bitmap  aBmp;
198*cdf0e10cSrcweir     sal_uIntPtr nContourFlags = XOUTBMP_CONTOUR_HORZ;
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     if ( rGraphic.GetType() == GRAPHIC_BITMAP )
201*cdf0e10cSrcweir     {
202*cdf0e10cSrcweir         if( rGraphic.IsAnimated() )
203*cdf0e10cSrcweir         {
204*cdf0e10cSrcweir             VirtualDevice       aVDev;
205*cdf0e10cSrcweir             MapMode             aTransMap;
206*cdf0e10cSrcweir             PolyPolygon         aAnimPolyPoly;
207*cdf0e10cSrcweir             const Animation     aAnim( rGraphic.GetAnimation() );
208*cdf0e10cSrcweir             const Size&         rSizePix = aAnim.GetDisplaySizePixel();
209*cdf0e10cSrcweir             const sal_uInt16        nCount = aAnim.Count();
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir             if ( aVDev.SetOutputSizePixel( rSizePix ) )
212*cdf0e10cSrcweir             {
213*cdf0e10cSrcweir                 aVDev.SetLineColor( Color( COL_BLACK ) );
214*cdf0e10cSrcweir                 aVDev.SetFillColor( Color( COL_BLACK ) );
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir                 for( sal_uInt16 i = 0; i < nCount; i++ )
217*cdf0e10cSrcweir                 {
218*cdf0e10cSrcweir                     const AnimationBitmap& rStepBmp = aAnim.Get( i );
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir                     // Polygonausgabe an die richtige Stelle schieben;
221*cdf0e10cSrcweir                     // dies ist der Offset des Teilbildes innerhalb
222*cdf0e10cSrcweir                     // der Gesamtanimation
223*cdf0e10cSrcweir                     aTransMap.SetOrigin( Point( rStepBmp.aPosPix.X(), rStepBmp.aPosPix.Y() ) );
224*cdf0e10cSrcweir                     aVDev.SetMapMode( aTransMap );
225*cdf0e10cSrcweir                     aVDev.DrawPolyPolygon( CreateAutoContour( rStepBmp.aBmpEx, pRect, nFlags ) );
226*cdf0e10cSrcweir                 }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir                 aTransMap.SetOrigin( Point() );
229*cdf0e10cSrcweir                 aVDev.SetMapMode( aTransMap );
230*cdf0e10cSrcweir                 aBmp = aVDev.GetBitmap( Point(), rSizePix );
231*cdf0e10cSrcweir                 aBmp.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
232*cdf0e10cSrcweir             }
233*cdf0e10cSrcweir         }
234*cdf0e10cSrcweir         else if( rGraphic.IsTransparent() )
235*cdf0e10cSrcweir             aBmp = rGraphic.GetBitmapEx().GetMask();
236*cdf0e10cSrcweir         else
237*cdf0e10cSrcweir         {
238*cdf0e10cSrcweir             aBmp = rGraphic.GetBitmap();
239*cdf0e10cSrcweir             nContourFlags |= XOUTBMP_CONTOUR_EDGEDETECT;
240*cdf0e10cSrcweir         }
241*cdf0e10cSrcweir     }
242*cdf0e10cSrcweir     else if( rGraphic.GetType() != GRAPHIC_NONE )
243*cdf0e10cSrcweir     {
244*cdf0e10cSrcweir         const Graphic   aTmpGrf( rGraphic.GetGDIMetaFile().GetMonochromeMtf( Color( COL_BLACK ) ) );
245*cdf0e10cSrcweir         VirtualDevice   aVDev;
246*cdf0e10cSrcweir         Size            aSizePix( aVDev.LogicToPixel( aTmpGrf.GetPrefSize(), aTmpGrf.GetPrefMapMode() ) );
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir         if( aSizePix.Width() && aSizePix.Height() && ( aSizePix.Width() > 512 || aSizePix.Height() > 512 ) )
249*cdf0e10cSrcweir         {
250*cdf0e10cSrcweir             double fWH = (double) aSizePix.Width() / aSizePix.Height();
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir             if( fWH <= 1.0 )
253*cdf0e10cSrcweir                 aSizePix.Width() = FRound( ( aSizePix.Height() = 512 ) * fWH );
254*cdf0e10cSrcweir             else
255*cdf0e10cSrcweir                 aSizePix.Height() = FRound( ( aSizePix.Width() = 512 ) / fWH );
256*cdf0e10cSrcweir         }
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir         if( aVDev.SetOutputSizePixel( aSizePix ) )
259*cdf0e10cSrcweir         {
260*cdf0e10cSrcweir             const Point aPt;
261*cdf0e10cSrcweir             aTmpGrf.Draw( &aVDev, aPt, aSizePix );
262*cdf0e10cSrcweir             aBmp = aVDev.GetBitmap( aPt, aSizePix );
263*cdf0e10cSrcweir         }
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir         nContourFlags |= XOUTBMP_CONTOUR_EDGEDETECT;
266*cdf0e10cSrcweir     }
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir     aBmp.SetPrefSize( rGraphic.GetPrefSize() );
269*cdf0e10cSrcweir     aBmp.SetPrefMapMode( rGraphic.GetPrefMapMode() );
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir     return PolyPolygon( XOutBitmap::GetCountour( aBmp, nContourFlags, 128, pRect ) );
272*cdf0e10cSrcweir }
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir /*************************************************************************
276*cdf0e10cSrcweir |*
277*cdf0e10cSrcweir |*
278*cdf0e10cSrcweir |*
279*cdf0e10cSrcweir \************************************************************************/
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir void SvxContourDlg::ScaleContour( PolyPolygon& rContour, const Graphic& rGraphic,
282*cdf0e10cSrcweir                                   const MapUnit eUnit, const Size& rDisplaySize )
283*cdf0e10cSrcweir {
284*cdf0e10cSrcweir     DBG_ASSERT( rGraphic.GetType() != GRAPHIC_NONE, "Graphic is not valid!" );
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir     OutputDevice*   pOutDev = Application::GetDefaultDevice();
287*cdf0e10cSrcweir     const MapMode   aDispMap( eUnit );
288*cdf0e10cSrcweir     const MapMode   aGrfMap( rGraphic.GetPrefMapMode() );
289*cdf0e10cSrcweir     const Size      aGrfSize( rGraphic.GetPrefSize() );
290*cdf0e10cSrcweir     double          fScaleX;
291*cdf0e10cSrcweir     double          fScaleY;
292*cdf0e10cSrcweir     Size            aOrgSize;
293*cdf0e10cSrcweir     Point           aNewPoint;
294*cdf0e10cSrcweir     sal_Bool            bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir     if ( bPixelMap )
297*cdf0e10cSrcweir         aOrgSize = pOutDev->PixelToLogic( aGrfSize, aDispMap );
298*cdf0e10cSrcweir     else
299*cdf0e10cSrcweir         aOrgSize = pOutDev->LogicToLogic( aGrfSize, aGrfMap, aDispMap );
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir     if ( aOrgSize.Width() && aOrgSize.Height() )
302*cdf0e10cSrcweir     {
303*cdf0e10cSrcweir         fScaleX = (double) rDisplaySize.Width() / aOrgSize.Width();
304*cdf0e10cSrcweir         fScaleY = (double) rDisplaySize.Height() / aOrgSize.Height();
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir         for ( sal_uInt16 j = 0, nPolyCount = rContour.Count(); j < nPolyCount; j++ )
307*cdf0e10cSrcweir         {
308*cdf0e10cSrcweir             Polygon& rPoly = rContour[ j ];
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir             for ( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
311*cdf0e10cSrcweir             {
312*cdf0e10cSrcweir                 if ( bPixelMap )
313*cdf0e10cSrcweir                     aNewPoint = pOutDev->PixelToLogic( rPoly[ i ], aDispMap  );
314*cdf0e10cSrcweir                 else
315*cdf0e10cSrcweir                     aNewPoint = pOutDev->LogicToLogic( rPoly[ i ], aGrfMap, aDispMap  );
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir                 rPoly[ i ] = Point( FRound( aNewPoint.X() * fScaleX ), FRound( aNewPoint.Y() * fScaleY ) );
318*cdf0e10cSrcweir             }
319*cdf0e10cSrcweir         }
320*cdf0e10cSrcweir     }
321*cdf0e10cSrcweir }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir /*************************************************************************
325*cdf0e10cSrcweir |*
326*cdf0e10cSrcweir |* Durchschleifen an SuperClass; keine virt. Methoden, um
327*cdf0e10cSrcweir |* bei IF-Aenderungen nicht inkompatibel zu werden
328*cdf0e10cSrcweir |*
329*cdf0e10cSrcweir \************************************************************************/
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir void SvxContourDlg::SetExecState( sal_Bool bEnable )
332*cdf0e10cSrcweir {
333*cdf0e10cSrcweir     pSuperClass->SetExecState( bEnable );
334*cdf0e10cSrcweir }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir void SvxContourDlg::SetGraphic( const Graphic& rGraphic )
337*cdf0e10cSrcweir {
338*cdf0e10cSrcweir     pSuperClass->SetGraphic( rGraphic );
339*cdf0e10cSrcweir }
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir void SvxContourDlg::SetGraphicLinked( sal_Bool bGraphicLinked )
342*cdf0e10cSrcweir {
343*cdf0e10cSrcweir     pSuperClass->SetGraphicLinked( bGraphicLinked );
344*cdf0e10cSrcweir }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir const Graphic& SvxContourDlg::GetGraphic() const
347*cdf0e10cSrcweir {
348*cdf0e10cSrcweir     return pSuperClass->GetGraphic();
349*cdf0e10cSrcweir }
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir sal_Bool SvxContourDlg::IsGraphicChanged() const
352*cdf0e10cSrcweir {
353*cdf0e10cSrcweir     return pSuperClass->IsGraphicChanged();
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir void SvxContourDlg::SetPolyPolygon( const PolyPolygon& rPolyPoly )
357*cdf0e10cSrcweir {
358*cdf0e10cSrcweir     pSuperClass->SetPolyPolygon( rPolyPoly );
359*cdf0e10cSrcweir }
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir PolyPolygon SvxContourDlg::GetPolyPolygon()
362*cdf0e10cSrcweir {
363*cdf0e10cSrcweir     return pSuperClass->GetPolyPolygon( sal_True );
364*cdf0e10cSrcweir }
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir void SvxContourDlg::SetEditingObject( void* pObj )
367*cdf0e10cSrcweir {
368*cdf0e10cSrcweir     pSuperClass->SetEditingObject( pObj );
369*cdf0e10cSrcweir }
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir const void* SvxContourDlg::GetEditingObject() const
372*cdf0e10cSrcweir {
373*cdf0e10cSrcweir     return pSuperClass->GetEditingObject();
374*cdf0e10cSrcweir }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir void SvxContourDlg::Update( const Graphic& rGraphic, sal_Bool bGraphicLinked,
377*cdf0e10cSrcweir                             const PolyPolygon* pPolyPoly, void* pEditingObj )
378*cdf0e10cSrcweir {
379*cdf0e10cSrcweir     pSuperClass->UpdateGraphic( rGraphic, bGraphicLinked, pPolyPoly, pEditingObj );
380*cdf0e10cSrcweir }
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir /*************************************************************************
384*cdf0e10cSrcweir |*
385*cdf0e10cSrcweir |*
386*cdf0e10cSrcweir |*
387*cdf0e10cSrcweir \************************************************************************/
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir SvxSuperContourDlg::SvxSuperContourDlg( SfxBindings *_pBindings, SfxChildWindow *pCW,
390*cdf0e10cSrcweir                                         Window* _pParent, const ResId& rResId ) :
391*cdf0e10cSrcweir         SvxContourDlg       ( _pBindings, pCW, _pParent, rResId ),
392*cdf0e10cSrcweir         pCheckObj           ( NULL ),
393*cdf0e10cSrcweir         aContourItem        ( SID_CONTOUR_EXEC, *this, *_pBindings ),
394*cdf0e10cSrcweir         aTbx1               ( this, ResId( TBX1, *rResId.GetResMgr() ) ),
395*cdf0e10cSrcweir         aMtfTolerance       ( this, ResId( MTF_TOLERANCE, *rResId.GetResMgr() ) ),
396*cdf0e10cSrcweir         aContourWnd         ( this, ResId( CTL_CONTOUR, *rResId.GetResMgr() ) ),
397*cdf0e10cSrcweir         aStbStatus          ( this, WB_BORDER | WB_3DLOOK | WB_LEFT ),
398*cdf0e10cSrcweir         nGrfChanged         ( 0UL ),
399*cdf0e10cSrcweir         bExecState          ( sal_False ),
400*cdf0e10cSrcweir         bGraphicLinked      ( sal_False ),
401*cdf0e10cSrcweir         maImageList         ( SVX_RES( CD_IMAPDLG ) ),
402*cdf0e10cSrcweir         maImageListH        ( SVX_RES( CDH_IMAPDLG ) )
403*cdf0e10cSrcweir {
404*cdf0e10cSrcweir     ApplyImageList();
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir     FreeResource();
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir     SvxContourDlg::SetSuperClass( *this );
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir     aContourWnd.SetMousePosLink( LINK( this, SvxSuperContourDlg, MousePosHdl ) );
411*cdf0e10cSrcweir     aContourWnd.SetGraphSizeLink( LINK( this, SvxSuperContourDlg, GraphSizeHdl ) );
412*cdf0e10cSrcweir     aContourWnd.SetUpdateLink( LINK( this, SvxSuperContourDlg, StateHdl ) );
413*cdf0e10cSrcweir     aContourWnd.SetPipetteHdl( LINK( this, SvxSuperContourDlg, PipetteHdl ) );
414*cdf0e10cSrcweir     aContourWnd.SetPipetteClickHdl( LINK( this, SvxSuperContourDlg, PipetteClickHdl ) );
415*cdf0e10cSrcweir     aContourWnd.SetWorkplaceClickHdl( LINK( this, SvxSuperContourDlg, WorkplaceClickHdl ) );
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir     const Size      aTbxSize( aTbx1.CalcWindowSizePixel() );
418*cdf0e10cSrcweir     Point           aPos( aTbx1.GetPosPixel() );
419*cdf0e10cSrcweir     SvtMiscOptions  aMiscOptions;
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir     aMiscOptions.AddListenerLink( LINK( this, SvxSuperContourDlg, MiscHdl ) );
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir     aTbx1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
424*cdf0e10cSrcweir     aTbx1.SetSizePixel( aTbxSize );
425*cdf0e10cSrcweir     aTbx1.SetSelectHdl( LINK( this, SvxSuperContourDlg, Tbx1ClickHdl ) );
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir     aPos.X() += aTbxSize.Width() + LogicToPixel( Size( 3, 0 ), MapMode( MAP_APPFONT ) ).Width();
428*cdf0e10cSrcweir     aMtfTolerance.SetPosPixel( aPos );
429*cdf0e10cSrcweir     aMtfTolerance.SetValue( 10L );
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir     SetMinOutputSizePixel( aLastSize = GetOutputSizePixel() );
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir     aStbStatus.InsertItem( 1, 130, SIB_LEFT | SIB_IN | SIB_AUTOSIZE );
434*cdf0e10cSrcweir     aStbStatus.InsertItem( 2, 10 + GetTextWidth( String::CreateFromAscii( " 9999,99 cm / 9999,99 cm " ) ), SIB_CENTER | SIB_IN );
435*cdf0e10cSrcweir     aStbStatus.InsertItem( 3, 10 + GetTextWidth( String::CreateFromAscii( " 9999,99 cm x 9999,99 cm " ) ), SIB_CENTER | SIB_IN );
436*cdf0e10cSrcweir     aStbStatus.InsertItem( 4, 20, SIB_CENTER | SIB_IN );
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir     Resize();
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir     aUpdateTimer.SetTimeout( 100 );
441*cdf0e10cSrcweir     aUpdateTimer.SetTimeoutHdl( LINK( this, SvxSuperContourDlg, UpdateHdl ) );
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir     aCreateTimer.SetTimeout( 50 );
444*cdf0e10cSrcweir     aCreateTimer.SetTimeoutHdl( LINK( this, SvxSuperContourDlg, CreateHdl ) );
445*cdf0e10cSrcweir }
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir /*************************************************************************
449*cdf0e10cSrcweir |*
450*cdf0e10cSrcweir |* Dtor
451*cdf0e10cSrcweir |*
452*cdf0e10cSrcweir \************************************************************************/
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir SvxSuperContourDlg::~SvxSuperContourDlg()
455*cdf0e10cSrcweir {
456*cdf0e10cSrcweir }
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir /*************************************************************************
460*cdf0e10cSrcweir |*
461*cdf0e10cSrcweir |* Resize-Methode
462*cdf0e10cSrcweir |*
463*cdf0e10cSrcweir \************************************************************************/
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir void SvxSuperContourDlg::Resize()
466*cdf0e10cSrcweir {
467*cdf0e10cSrcweir     SfxFloatingWindow::Resize();
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir     Size aMinSize( GetMinOutputSizePixel() );
470*cdf0e10cSrcweir     Size aNewSize( GetOutputSizePixel() );
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir     if ( aNewSize.Height() >= aMinSize.Height() )
473*cdf0e10cSrcweir     {
474*cdf0e10cSrcweir         Size    _aSize( aStbStatus.GetSizePixel() );
475*cdf0e10cSrcweir         Point   aPoint( 0, aNewSize.Height() - _aSize.Height() );
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir         // StatusBar positionieren
478*cdf0e10cSrcweir         aStbStatus.SetPosSizePixel( aPoint, Size( aNewSize.Width(), _aSize.Height() ) );
479*cdf0e10cSrcweir         aStbStatus.Show();
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir         // EditWindow positionieren
482*cdf0e10cSrcweir         _aSize.Width() = aNewSize.Width() - 18;
483*cdf0e10cSrcweir         _aSize.Height() = aPoint.Y() - aContourWnd.GetPosPixel().Y() - 6;
484*cdf0e10cSrcweir         aContourWnd.SetSizePixel( _aSize );
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir         aLastSize = aNewSize;
487*cdf0e10cSrcweir     }
488*cdf0e10cSrcweir }
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir /*************************************************************************
492*cdf0e10cSrcweir |*
493*cdf0e10cSrcweir |* Close-Methode
494*cdf0e10cSrcweir |*
495*cdf0e10cSrcweir \************************************************************************/
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir sal_Bool SvxSuperContourDlg::Close()
498*cdf0e10cSrcweir {
499*cdf0e10cSrcweir     sal_Bool bRet = sal_True;
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir     if ( aTbx1.IsItemEnabled( TBI_APPLY ) )
502*cdf0e10cSrcweir     {
503*cdf0e10cSrcweir         QueryBox    aQBox( this, WB_YES_NO_CANCEL | WB_DEF_YES,
504*cdf0e10cSrcweir                            String( CONT_RESID( STR_CONTOURDLG_MODIFY ) ) );
505*cdf0e10cSrcweir         const long  nRet = aQBox.Execute();
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir         if ( nRet == RET_YES )
508*cdf0e10cSrcweir         {
509*cdf0e10cSrcweir             SfxBoolItem aBoolItem( SID_CONTOUR_EXEC, sal_True );
510*cdf0e10cSrcweir             GetBindings().GetDispatcher()->Execute(
511*cdf0e10cSrcweir                 SID_CONTOUR_EXEC, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
512*cdf0e10cSrcweir         }
513*cdf0e10cSrcweir         else if ( nRet == RET_CANCEL )
514*cdf0e10cSrcweir             bRet = sal_False;
515*cdf0e10cSrcweir     }
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir     return( bRet ? SfxFloatingWindow::Close() : sal_False );
518*cdf0e10cSrcweir }
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir /*************************************************************************
522*cdf0e10cSrcweir |*
523*cdf0e10cSrcweir |* Enabled oder disabled alle Controls
524*cdf0e10cSrcweir |*
525*cdf0e10cSrcweir \************************************************************************/
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir void SvxSuperContourDlg::SetExecState( sal_Bool bEnable )
528*cdf0e10cSrcweir {
529*cdf0e10cSrcweir     bExecState = bEnable;
530*cdf0e10cSrcweir }
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir /*************************************************************************
534*cdf0e10cSrcweir |*
535*cdf0e10cSrcweir |*
536*cdf0e10cSrcweir |*
537*cdf0e10cSrcweir \************************************************************************/
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir void SvxSuperContourDlg::SetGraphic( const Graphic& rGraphic )
540*cdf0e10cSrcweir {
541*cdf0e10cSrcweir     aUndoGraphic = aRedoGraphic = Graphic();
542*cdf0e10cSrcweir     aGraphic = rGraphic;
543*cdf0e10cSrcweir     nGrfChanged = 0UL;
544*cdf0e10cSrcweir     aContourWnd.SetGraphic( aGraphic );
545*cdf0e10cSrcweir }
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir /*************************************************************************
549*cdf0e10cSrcweir |*
550*cdf0e10cSrcweir |*
551*cdf0e10cSrcweir |*
552*cdf0e10cSrcweir \************************************************************************/
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir void SvxSuperContourDlg::SetPolyPolygon( const PolyPolygon& rPolyPoly )
555*cdf0e10cSrcweir {
556*cdf0e10cSrcweir     DBG_ASSERT(  aContourWnd.GetGraphic().GetType() != GRAPHIC_NONE, "Graphic must've been set first!" );
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir     PolyPolygon     aPolyPoly( rPolyPoly );
559*cdf0e10cSrcweir     const MapMode   aMap100( MAP_100TH_MM );
560*cdf0e10cSrcweir     const MapMode   aGrfMap( aGraphic.GetPrefMapMode() );
561*cdf0e10cSrcweir     OutputDevice*   pOutDev = Application::GetDefaultDevice();
562*cdf0e10cSrcweir     sal_Bool            bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir     for ( sal_uInt16 j = 0, nPolyCount = aPolyPoly.Count(); j < nPolyCount; j++ )
565*cdf0e10cSrcweir     {
566*cdf0e10cSrcweir         Polygon& rPoly = aPolyPoly[ j ];
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir         for ( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
569*cdf0e10cSrcweir         {
570*cdf0e10cSrcweir             Point& rPt = rPoly[ i ];
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir             if ( !bPixelMap )
573*cdf0e10cSrcweir                 rPt = pOutDev->LogicToPixel( rPt, aGrfMap );
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir             rPt = pOutDev->PixelToLogic( rPt, aMap100 );
576*cdf0e10cSrcweir         }
577*cdf0e10cSrcweir     }
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir     aContourWnd.SetPolyPolygon( aPolyPoly );
580*cdf0e10cSrcweir     aContourWnd.GetSdrModel()->SetChanged( sal_True );
581*cdf0e10cSrcweir }
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir /*************************************************************************
585*cdf0e10cSrcweir |*
586*cdf0e10cSrcweir |*
587*cdf0e10cSrcweir |*
588*cdf0e10cSrcweir \************************************************************************/
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir PolyPolygon SvxSuperContourDlg::GetPolyPolygon( sal_Bool bRescaleToGraphic )
591*cdf0e10cSrcweir {
592*cdf0e10cSrcweir     PolyPolygon aRetPolyPoly( aContourWnd.GetPolyPolygon() );
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir     if ( bRescaleToGraphic )
595*cdf0e10cSrcweir     {
596*cdf0e10cSrcweir         const MapMode   aMap100( MAP_100TH_MM );
597*cdf0e10cSrcweir         const MapMode   aGrfMap( aGraphic.GetPrefMapMode() );
598*cdf0e10cSrcweir         OutputDevice*   pOutDev = Application::GetDefaultDevice();
599*cdf0e10cSrcweir         sal_Bool            bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir         for ( sal_uInt16 j = 0, nPolyCount = aRetPolyPoly.Count(); j < nPolyCount; j++ )
602*cdf0e10cSrcweir         {
603*cdf0e10cSrcweir             Polygon& rPoly = aRetPolyPoly[ j ];
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir             for ( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
606*cdf0e10cSrcweir             {
607*cdf0e10cSrcweir                 Point& rPt = rPoly[ i ];
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir                 rPt = pOutDev->LogicToPixel( rPt, aMap100  );
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir                 if ( !bPixelMap )
612*cdf0e10cSrcweir                     rPt = pOutDev->PixelToLogic( rPt, aGrfMap  );
613*cdf0e10cSrcweir             }
614*cdf0e10cSrcweir         }
615*cdf0e10cSrcweir     }
616*cdf0e10cSrcweir 
617*cdf0e10cSrcweir     return aRetPolyPoly;
618*cdf0e10cSrcweir }
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir /*************************************************************************
622*cdf0e10cSrcweir |*
623*cdf0e10cSrcweir |*
624*cdf0e10cSrcweir |*
625*cdf0e10cSrcweir \************************************************************************/
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir void SvxSuperContourDlg::UpdateGraphic( const Graphic& rGraphic, sal_Bool _bGraphicLinked,
628*cdf0e10cSrcweir                                  const PolyPolygon* pPolyPoly, void* pEditingObj )
629*cdf0e10cSrcweir {
630*cdf0e10cSrcweir     aUpdateGraphic = rGraphic;
631*cdf0e10cSrcweir     bUpdateGraphicLinked = _bGraphicLinked;
632*cdf0e10cSrcweir     pUpdateEditingObject = pEditingObj;
633*cdf0e10cSrcweir 
634*cdf0e10cSrcweir     if ( pPolyPoly )
635*cdf0e10cSrcweir         aUpdatePolyPoly = *pPolyPoly;
636*cdf0e10cSrcweir     else
637*cdf0e10cSrcweir         aUpdatePolyPoly = PolyPolygon();
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir     aUpdateTimer.Start();
640*cdf0e10cSrcweir }
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir /*************************************************************************
644*cdf0e10cSrcweir |*
645*cdf0e10cSrcweir |*
646*cdf0e10cSrcweir |*
647*cdf0e10cSrcweir \************************************************************************/
648*cdf0e10cSrcweir 
649*cdf0e10cSrcweir sal_Bool SvxSuperContourDlg::IsUndoPossible() const
650*cdf0e10cSrcweir {
651*cdf0e10cSrcweir     return aUndoGraphic.GetType() != GRAPHIC_NONE;
652*cdf0e10cSrcweir }
653*cdf0e10cSrcweir 
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir /*************************************************************************
656*cdf0e10cSrcweir |*
657*cdf0e10cSrcweir |*
658*cdf0e10cSrcweir |*
659*cdf0e10cSrcweir \************************************************************************/
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir sal_Bool SvxSuperContourDlg::IsRedoPossible() const
662*cdf0e10cSrcweir {
663*cdf0e10cSrcweir     return aRedoGraphic.GetType() != GRAPHIC_NONE;
664*cdf0e10cSrcweir }
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir /*************************************************************************
668*cdf0e10cSrcweir |*
669*cdf0e10cSrcweir |*
670*cdf0e10cSrcweir |*
671*cdf0e10cSrcweir \************************************************************************/
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir void SvxSuperContourDlg::DoAutoCreate()
674*cdf0e10cSrcweir {
675*cdf0e10cSrcweir     aCreateTimer.Start();
676*cdf0e10cSrcweir }
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir 
679*cdf0e10cSrcweir /*************************************************************************
680*cdf0e10cSrcweir |*
681*cdf0e10cSrcweir |*
682*cdf0e10cSrcweir |*
683*cdf0e10cSrcweir \************************************************************************/
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir void SvxSuperContourDlg::ReducePoints( const long nTol )
686*cdf0e10cSrcweir {
687*cdf0e10cSrcweir     PolyPolygon aPolyPoly( GetPolyPolygon( sal_False ) );
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir     if ( aPolyPoly.Count() )
690*cdf0e10cSrcweir     {
691*cdf0e10cSrcweir         const MapMode   aMapMode( MAP_100TH_MM );
692*cdf0e10cSrcweir         const long      nTol2 = nTol * nTol;
693*cdf0e10cSrcweir         Polygon&        rPoly = aPolyPoly[ 0 ];
694*cdf0e10cSrcweir         OutputDevice*   pOutDev = Application::GetDefaultDevice();
695*cdf0e10cSrcweir         Point           aPtPix;
696*cdf0e10cSrcweir         const sal_uInt16    nSize = rPoly.GetSize();
697*cdf0e10cSrcweir         sal_uInt16          nCounter = 0;
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir         if ( nSize )
700*cdf0e10cSrcweir             aPtPix = pOutDev->LogicToPixel( rPoly[ 0 ], aMapMode );
701*cdf0e10cSrcweir 
702*cdf0e10cSrcweir         for( sal_uInt16 i = 1; i < nSize; i++ )
703*cdf0e10cSrcweir         {
704*cdf0e10cSrcweir             const Point&    rNewPt = rPoly[ i ];
705*cdf0e10cSrcweir             const Point     aNewPtPix( pOutDev->LogicToPixel( rNewPt, aMapMode ) );
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir             const long nDistX = aNewPtPix.X() - aPtPix.X();
708*cdf0e10cSrcweir             const long nDistY = aNewPtPix.Y() - aPtPix.Y();
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir             if( ( nDistX * nDistX + nDistY * nDistY ) >= nTol2 )
711*cdf0e10cSrcweir             {
712*cdf0e10cSrcweir                 rPoly[ ++nCounter ] = rNewPt;
713*cdf0e10cSrcweir                 aPtPix = aNewPtPix;
714*cdf0e10cSrcweir             }
715*cdf0e10cSrcweir         }
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir         rPoly.SetSize( nCounter );
718*cdf0e10cSrcweir         aContourWnd.SetPolyPolygon( aPolyPoly );
719*cdf0e10cSrcweir         aContourWnd.GetSdrModel()->SetChanged( sal_True );
720*cdf0e10cSrcweir     }
721*cdf0e10cSrcweir }
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir /*************************************************************************
725*cdf0e10cSrcweir |*
726*cdf0e10cSrcweir |* Click-Hdl fuer ToolBox
727*cdf0e10cSrcweir |*
728*cdf0e10cSrcweir \************************************************************************/
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, Tbx1ClickHdl, ToolBox*, pTbx )
731*cdf0e10cSrcweir {
732*cdf0e10cSrcweir     sal_uInt16 nNewItemId = pTbx->GetCurItemId();
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir     switch( pTbx->GetCurItemId() )
735*cdf0e10cSrcweir     {
736*cdf0e10cSrcweir         case( TBI_APPLY ):
737*cdf0e10cSrcweir         {
738*cdf0e10cSrcweir             SfxBoolItem aBoolItem( SID_CONTOUR_EXEC, sal_True );
739*cdf0e10cSrcweir             GetBindings().GetDispatcher()->Execute(
740*cdf0e10cSrcweir                 SID_CONTOUR_EXEC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
741*cdf0e10cSrcweir         }
742*cdf0e10cSrcweir         break;
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir         case( TBI_WORKPLACE ):
745*cdf0e10cSrcweir         {
746*cdf0e10cSrcweir             if ( aTbx1.IsItemChecked( TBI_WORKPLACE ) )
747*cdf0e10cSrcweir             {
748*cdf0e10cSrcweir                 QueryBox aQBox( this, WB_YES_NO | WB_DEF_NO, String( CONT_RESID( STR_CONTOURDLG_WORKPLACE ) ) );
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir                 if ( !aContourWnd.IsContourChanged() || ( aQBox.Execute() == RET_YES ) )
751*cdf0e10cSrcweir                     aContourWnd.SetWorkplaceMode( sal_True );
752*cdf0e10cSrcweir                 else
753*cdf0e10cSrcweir                     aTbx1.CheckItem( TBI_WORKPLACE, sal_False );
754*cdf0e10cSrcweir             }
755*cdf0e10cSrcweir             else
756*cdf0e10cSrcweir                 aContourWnd.SetWorkplaceMode( sal_False );
757*cdf0e10cSrcweir         }
758*cdf0e10cSrcweir         break;
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir         case( TBI_SELECT ):
761*cdf0e10cSrcweir         {
762*cdf0e10cSrcweir             pTbx->CheckItem( nNewItemId, sal_True );
763*cdf0e10cSrcweir             aContourWnd.SetEditMode( sal_True );
764*cdf0e10cSrcweir         }
765*cdf0e10cSrcweir         break;
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir         case( TBI_RECT ):
768*cdf0e10cSrcweir         {
769*cdf0e10cSrcweir             pTbx->CheckItem( nNewItemId, sal_True );
770*cdf0e10cSrcweir             aContourWnd.SetObjKind( OBJ_RECT );
771*cdf0e10cSrcweir         }
772*cdf0e10cSrcweir         break;
773*cdf0e10cSrcweir 
774*cdf0e10cSrcweir         case( TBI_CIRCLE ):
775*cdf0e10cSrcweir         {
776*cdf0e10cSrcweir             pTbx->CheckItem( nNewItemId, sal_True );
777*cdf0e10cSrcweir             aContourWnd.SetObjKind( OBJ_CIRC );
778*cdf0e10cSrcweir 
779*cdf0e10cSrcweir         }
780*cdf0e10cSrcweir         break;
781*cdf0e10cSrcweir 
782*cdf0e10cSrcweir         case( TBI_POLY ):
783*cdf0e10cSrcweir         {
784*cdf0e10cSrcweir             pTbx->CheckItem( nNewItemId, sal_True );
785*cdf0e10cSrcweir             aContourWnd.SetObjKind( OBJ_POLY );
786*cdf0e10cSrcweir         }
787*cdf0e10cSrcweir         break;
788*cdf0e10cSrcweir 
789*cdf0e10cSrcweir         case( TBI_FREEPOLY ):
790*cdf0e10cSrcweir         {
791*cdf0e10cSrcweir             pTbx->CheckItem( nNewItemId, sal_True );
792*cdf0e10cSrcweir             aContourWnd.SetObjKind( OBJ_FREEFILL );
793*cdf0e10cSrcweir         }
794*cdf0e10cSrcweir         break;
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir         case( TBI_POLYEDIT ):
797*cdf0e10cSrcweir             aContourWnd.SetPolyEditMode( pTbx->IsItemChecked( TBI_POLYEDIT ) ? SID_BEZIER_MOVE : 0 );
798*cdf0e10cSrcweir         break;
799*cdf0e10cSrcweir 
800*cdf0e10cSrcweir         case( TBI_POLYMOVE ):
801*cdf0e10cSrcweir             aContourWnd.SetPolyEditMode( SID_BEZIER_MOVE );
802*cdf0e10cSrcweir         break;
803*cdf0e10cSrcweir 
804*cdf0e10cSrcweir         case( TBI_POLYINSERT ):
805*cdf0e10cSrcweir             aContourWnd.SetPolyEditMode( SID_BEZIER_INSERT );
806*cdf0e10cSrcweir         break;
807*cdf0e10cSrcweir 
808*cdf0e10cSrcweir         case( TBI_POLYDELETE ):
809*cdf0e10cSrcweir             aContourWnd.GetSdrView()->DeleteMarkedPoints();
810*cdf0e10cSrcweir         break;
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir         case( TBI_UNDO ):
813*cdf0e10cSrcweir         {
814*cdf0e10cSrcweir             nGrfChanged = nGrfChanged ? nGrfChanged-- : 0UL;
815*cdf0e10cSrcweir             aRedoGraphic = aGraphic;
816*cdf0e10cSrcweir             aGraphic = aUndoGraphic;
817*cdf0e10cSrcweir             aUndoGraphic = Graphic();
818*cdf0e10cSrcweir             aContourWnd.SetGraphic( aGraphic, sal_False );
819*cdf0e10cSrcweir         }
820*cdf0e10cSrcweir         break;
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir         case( TBI_REDO ):
823*cdf0e10cSrcweir         {
824*cdf0e10cSrcweir             nGrfChanged++;
825*cdf0e10cSrcweir             aUndoGraphic = aGraphic;
826*cdf0e10cSrcweir             aGraphic = aRedoGraphic;
827*cdf0e10cSrcweir             aRedoGraphic = Graphic();
828*cdf0e10cSrcweir             aContourWnd.SetGraphic( aGraphic, sal_False );
829*cdf0e10cSrcweir         }
830*cdf0e10cSrcweir         break;
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir         case( TBI_AUTOCONTOUR ):
833*cdf0e10cSrcweir             aCreateTimer.Start();
834*cdf0e10cSrcweir         break;
835*cdf0e10cSrcweir 
836*cdf0e10cSrcweir         case( TBI_PIPETTE ):
837*cdf0e10cSrcweir         {
838*cdf0e10cSrcweir             sal_Bool bPipette = aTbx1.IsItemChecked( TBI_PIPETTE );
839*cdf0e10cSrcweir 
840*cdf0e10cSrcweir             if ( !bPipette )
841*cdf0e10cSrcweir                 aStbStatus.Invalidate();
842*cdf0e10cSrcweir             else if ( bGraphicLinked )
843*cdf0e10cSrcweir             {
844*cdf0e10cSrcweir                 QueryBox aQBox( this, WB_YES_NO | WB_DEF_YES, String( CONT_RESID( STR_CONTOURDLG_LINKED ) ) );
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir                 if ( aQBox.Execute() != RET_YES )
847*cdf0e10cSrcweir                 {
848*cdf0e10cSrcweir                     aTbx1.CheckItem( TBI_PIPETTE, bPipette = sal_False );
849*cdf0e10cSrcweir                     aStbStatus.Invalidate();
850*cdf0e10cSrcweir                 }
851*cdf0e10cSrcweir             }
852*cdf0e10cSrcweir 
853*cdf0e10cSrcweir             aContourWnd.SetPipetteMode( bPipette );
854*cdf0e10cSrcweir         }
855*cdf0e10cSrcweir         break;
856*cdf0e10cSrcweir 
857*cdf0e10cSrcweir         default:
858*cdf0e10cSrcweir         break;
859*cdf0e10cSrcweir     }
860*cdf0e10cSrcweir 
861*cdf0e10cSrcweir     return 0L;
862*cdf0e10cSrcweir }
863*cdf0e10cSrcweir 
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir /*************************************************************************
866*cdf0e10cSrcweir |*
867*cdf0e10cSrcweir |*
868*cdf0e10cSrcweir |*
869*cdf0e10cSrcweir \************************************************************************/
870*cdf0e10cSrcweir 
871*cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, MousePosHdl, ContourWindow*, pWnd )
872*cdf0e10cSrcweir {
873*cdf0e10cSrcweir     String aStr;
874*cdf0e10cSrcweir     const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
875*cdf0e10cSrcweir     const Point& rMousePos = pWnd->GetMousePos();
876*cdf0e10cSrcweir     LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
877*cdf0e10cSrcweir     const sal_Unicode cSep = aLocaleWrapper.getNumDecimalSep().GetChar(0);
878*cdf0e10cSrcweir 
879*cdf0e10cSrcweir     aStr.Assign( GetUnitString( rMousePos.X(), eFieldUnit, cSep ) );
880*cdf0e10cSrcweir     aStr.Append( String::CreateFromAscii( " / " ) );
881*cdf0e10cSrcweir     aStr.Append( GetUnitString( rMousePos.Y(), eFieldUnit, cSep ) );
882*cdf0e10cSrcweir 
883*cdf0e10cSrcweir     aStbStatus.SetItemText( 2, aStr );
884*cdf0e10cSrcweir 
885*cdf0e10cSrcweir     return 0L;
886*cdf0e10cSrcweir }
887*cdf0e10cSrcweir 
888*cdf0e10cSrcweir /*************************************************************************
889*cdf0e10cSrcweir |*
890*cdf0e10cSrcweir |*
891*cdf0e10cSrcweir |*
892*cdf0e10cSrcweir \************************************************************************/
893*cdf0e10cSrcweir 
894*cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, GraphSizeHdl, ContourWindow*, pWnd )
895*cdf0e10cSrcweir {
896*cdf0e10cSrcweir     String aStr;
897*cdf0e10cSrcweir     const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
898*cdf0e10cSrcweir     const Size& rSize = pWnd->GetGraphicSize();
899*cdf0e10cSrcweir     LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
900*cdf0e10cSrcweir     const sal_Unicode cSep = aLocaleWrapper.getNumDecimalSep().GetChar(0);
901*cdf0e10cSrcweir 
902*cdf0e10cSrcweir     aStr.Assign( GetUnitString( rSize.Width(), eFieldUnit, cSep ) );
903*cdf0e10cSrcweir     aStr.Append( String::CreateFromAscii( " x " ) );
904*cdf0e10cSrcweir     aStr.Append( GetUnitString( rSize.Height(), eFieldUnit, cSep ) );
905*cdf0e10cSrcweir 
906*cdf0e10cSrcweir     aStbStatus.SetItemText( 3, aStr );
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir     return 0L;
909*cdf0e10cSrcweir }
910*cdf0e10cSrcweir 
911*cdf0e10cSrcweir /*************************************************************************
912*cdf0e10cSrcweir |*
913*cdf0e10cSrcweir |*
914*cdf0e10cSrcweir |*
915*cdf0e10cSrcweir \************************************************************************/
916*cdf0e10cSrcweir 
917*cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, UpdateHdl, Timer*, EMPTYARG )
918*cdf0e10cSrcweir {
919*cdf0e10cSrcweir     aUpdateTimer.Stop();
920*cdf0e10cSrcweir 
921*cdf0e10cSrcweir     if ( pUpdateEditingObject != pCheckObj )
922*cdf0e10cSrcweir     {
923*cdf0e10cSrcweir         if( !GetEditingObject() )
924*cdf0e10cSrcweir             aContourWnd.GrabFocus();
925*cdf0e10cSrcweir 
926*cdf0e10cSrcweir         SetGraphic( aUpdateGraphic );
927*cdf0e10cSrcweir         SetPolyPolygon( aUpdatePolyPoly );
928*cdf0e10cSrcweir         SetEditingObject( pUpdateEditingObject );
929*cdf0e10cSrcweir         bGraphicLinked = bUpdateGraphicLinked;
930*cdf0e10cSrcweir 
931*cdf0e10cSrcweir         aUpdateGraphic = Graphic();
932*cdf0e10cSrcweir         aUpdatePolyPoly = PolyPolygon();
933*cdf0e10cSrcweir         bUpdateGraphicLinked = sal_False;
934*cdf0e10cSrcweir 
935*cdf0e10cSrcweir         aContourWnd.GetSdrModel()->SetChanged( sal_False );
936*cdf0e10cSrcweir     }
937*cdf0e10cSrcweir 
938*cdf0e10cSrcweir     GetBindings().Invalidate( SID_CONTOUR_EXEC );
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir     return 0L;
941*cdf0e10cSrcweir }
942*cdf0e10cSrcweir 
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir /*************************************************************************
945*cdf0e10cSrcweir |*
946*cdf0e10cSrcweir |*
947*cdf0e10cSrcweir |*
948*cdf0e10cSrcweir \************************************************************************/
949*cdf0e10cSrcweir 
950*cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, CreateHdl, Timer*, EMPTYARG )
951*cdf0e10cSrcweir {
952*cdf0e10cSrcweir     aCreateTimer.Stop();
953*cdf0e10cSrcweir 
954*cdf0e10cSrcweir     const Rectangle aWorkRect = aContourWnd.LogicToPixel( aContourWnd.GetWorkRect(), MapMode( MAP_100TH_MM ) );
955*cdf0e10cSrcweir     const Graphic&  rGraphic = aContourWnd.GetGraphic();
956*cdf0e10cSrcweir     const sal_Bool      bValid = aWorkRect.Left() != aWorkRect.Right() && aWorkRect.Top() != aWorkRect.Bottom();
957*cdf0e10cSrcweir 
958*cdf0e10cSrcweir     EnterWait();
959*cdf0e10cSrcweir     SetPolyPolygon( CreateAutoContour( rGraphic, bValid ? &aWorkRect : NULL ) );
960*cdf0e10cSrcweir     LeaveWait();
961*cdf0e10cSrcweir 
962*cdf0e10cSrcweir     return 0L;
963*cdf0e10cSrcweir }
964*cdf0e10cSrcweir 
965*cdf0e10cSrcweir 
966*cdf0e10cSrcweir /*************************************************************************
967*cdf0e10cSrcweir |*
968*cdf0e10cSrcweir |*
969*cdf0e10cSrcweir |*
970*cdf0e10cSrcweir \************************************************************************/
971*cdf0e10cSrcweir 
972*cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, StateHdl, ContourWindow*, pWnd )
973*cdf0e10cSrcweir {
974*cdf0e10cSrcweir     const SdrObject*    pObj = pWnd->GetSelectedSdrObject();
975*cdf0e10cSrcweir     const SdrView*      pView = pWnd->GetSdrView();
976*cdf0e10cSrcweir     const sal_Bool          bPolyEdit = ( pObj != NULL ) && pObj->ISA( SdrPathObj );
977*cdf0e10cSrcweir     const sal_Bool          bDrawEnabled = !( bPolyEdit && aTbx1.IsItemChecked( TBI_POLYEDIT ) );
978*cdf0e10cSrcweir     const sal_Bool          bPipette = aTbx1.IsItemChecked( TBI_PIPETTE );
979*cdf0e10cSrcweir     const sal_Bool          bWorkplace = aTbx1.IsItemChecked( TBI_WORKPLACE );
980*cdf0e10cSrcweir     const sal_Bool          bDontHide = !( bPipette || bWorkplace );
981*cdf0e10cSrcweir     const sal_Bool          bBitmap = pWnd->GetGraphic().GetType() == GRAPHIC_BITMAP;
982*cdf0e10cSrcweir 
983*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_APPLY, bDontHide && bExecState && pWnd->IsChanged() );
984*cdf0e10cSrcweir 
985*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_WORKPLACE, !bPipette && bDrawEnabled );
986*cdf0e10cSrcweir 
987*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_SELECT, bDontHide && bDrawEnabled );
988*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_RECT, bDontHide && bDrawEnabled );
989*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_CIRCLE, bDontHide && bDrawEnabled );
990*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_POLY, bDontHide && bDrawEnabled );
991*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_FREEPOLY, bDontHide && bDrawEnabled );
992*cdf0e10cSrcweir 
993*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_POLYEDIT, bDontHide && bPolyEdit );
994*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_POLYMOVE, bDontHide && !bDrawEnabled );
995*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_POLYINSERT, bDontHide && !bDrawEnabled );
996*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_POLYDELETE, bDontHide && !bDrawEnabled && pView->IsDeleteMarkedPointsPossible() );
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_AUTOCONTOUR, bDontHide && bDrawEnabled );
999*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_PIPETTE, !bWorkplace && bDrawEnabled && bBitmap );
1000*cdf0e10cSrcweir 
1001*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_UNDO, bDontHide && IsUndoPossible() );
1002*cdf0e10cSrcweir     aTbx1.EnableItem( TBI_REDO, bDontHide && IsRedoPossible() );
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir     if ( bPolyEdit )
1005*cdf0e10cSrcweir     {
1006*cdf0e10cSrcweir         sal_uInt16 nId = 0;
1007*cdf0e10cSrcweir 
1008*cdf0e10cSrcweir         switch( pWnd->GetPolyEditMode() )
1009*cdf0e10cSrcweir         {
1010*cdf0e10cSrcweir             case( SID_BEZIER_MOVE ): nId = TBI_POLYMOVE; break;
1011*cdf0e10cSrcweir             case( SID_BEZIER_INSERT ): nId = TBI_POLYINSERT; break;
1012*cdf0e10cSrcweir 
1013*cdf0e10cSrcweir             default:
1014*cdf0e10cSrcweir             break;
1015*cdf0e10cSrcweir         }
1016*cdf0e10cSrcweir 
1017*cdf0e10cSrcweir         aTbx1.CheckItem( nId, sal_True );
1018*cdf0e10cSrcweir     }
1019*cdf0e10cSrcweir     else
1020*cdf0e10cSrcweir     {
1021*cdf0e10cSrcweir         aTbx1.CheckItem( TBI_POLYEDIT, sal_False );
1022*cdf0e10cSrcweir         aTbx1.CheckItem( TBI_POLYMOVE, sal_True );
1023*cdf0e10cSrcweir         aTbx1.CheckItem( TBI_POLYINSERT, sal_False );
1024*cdf0e10cSrcweir         pWnd->SetPolyEditMode( 0 );
1025*cdf0e10cSrcweir     }
1026*cdf0e10cSrcweir 
1027*cdf0e10cSrcweir     return 0L;
1028*cdf0e10cSrcweir }
1029*cdf0e10cSrcweir 
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir /*************************************************************************
1032*cdf0e10cSrcweir |*
1033*cdf0e10cSrcweir |*
1034*cdf0e10cSrcweir |*
1035*cdf0e10cSrcweir \************************************************************************/
1036*cdf0e10cSrcweir 
1037*cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, PipetteHdl, ContourWindow*, pWnd )
1038*cdf0e10cSrcweir {
1039*cdf0e10cSrcweir     const Color& rOldLineColor = aStbStatus.GetLineColor();
1040*cdf0e10cSrcweir     const Color& rOldFillColor = aStbStatus.GetFillColor();
1041*cdf0e10cSrcweir 
1042*cdf0e10cSrcweir     Rectangle       aRect( aStbStatus.GetItemRect( 4 ) );
1043*cdf0e10cSrcweir     const Color&    rColor = pWnd->GetPipetteColor();
1044*cdf0e10cSrcweir 
1045*cdf0e10cSrcweir     aStbStatus.SetLineColor( rColor );
1046*cdf0e10cSrcweir     aStbStatus.SetFillColor( rColor );
1047*cdf0e10cSrcweir 
1048*cdf0e10cSrcweir     aRect.Left() += 4;
1049*cdf0e10cSrcweir     aRect.Top() += 4;
1050*cdf0e10cSrcweir     aRect.Right() -= 4;
1051*cdf0e10cSrcweir     aRect.Bottom() -= 4;
1052*cdf0e10cSrcweir 
1053*cdf0e10cSrcweir     aStbStatus.DrawRect( aRect );
1054*cdf0e10cSrcweir 
1055*cdf0e10cSrcweir     aStbStatus.SetLineColor( rOldLineColor );
1056*cdf0e10cSrcweir     aStbStatus.SetFillColor( rOldFillColor );
1057*cdf0e10cSrcweir 
1058*cdf0e10cSrcweir     return 0L;
1059*cdf0e10cSrcweir }
1060*cdf0e10cSrcweir 
1061*cdf0e10cSrcweir 
1062*cdf0e10cSrcweir /*************************************************************************
1063*cdf0e10cSrcweir |*
1064*cdf0e10cSrcweir |*
1065*cdf0e10cSrcweir |*
1066*cdf0e10cSrcweir \************************************************************************/
1067*cdf0e10cSrcweir 
1068*cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, PipetteClickHdl, ContourWindow*, pWnd )
1069*cdf0e10cSrcweir {
1070*cdf0e10cSrcweir     if ( pWnd->IsClickValid() )
1071*cdf0e10cSrcweir     {
1072*cdf0e10cSrcweir         Bitmap          aMask;
1073*cdf0e10cSrcweir         const Color&    rColor = pWnd->GetPipetteColor();
1074*cdf0e10cSrcweir 
1075*cdf0e10cSrcweir         EnterWait();
1076*cdf0e10cSrcweir 
1077*cdf0e10cSrcweir         if( aGraphic.GetType() == GRAPHIC_BITMAP )
1078*cdf0e10cSrcweir         {
1079*cdf0e10cSrcweir             Bitmap      aBmp( aGraphic.GetBitmap() );
1080*cdf0e10cSrcweir             const long  nTol = static_cast<long>(aMtfTolerance.GetValue() * 255L / 100L);
1081*cdf0e10cSrcweir 
1082*cdf0e10cSrcweir             aMask = aBmp.CreateMask( rColor, nTol );
1083*cdf0e10cSrcweir 
1084*cdf0e10cSrcweir             if( aGraphic.IsTransparent() )
1085*cdf0e10cSrcweir                 aMask.CombineSimple( aGraphic.GetBitmapEx().GetMask(), BMP_COMBINE_OR );
1086*cdf0e10cSrcweir 
1087*cdf0e10cSrcweir             if( !!aMask )
1088*cdf0e10cSrcweir             {
1089*cdf0e10cSrcweir                 QueryBox    aQBox( this, WB_YES_NO | WB_DEF_YES, String( CONT_RESID( STR_CONTOURDLG_NEWPIPETTE ) ) );
1090*cdf0e10cSrcweir                 sal_Bool        bNewContour;
1091*cdf0e10cSrcweir 
1092*cdf0e10cSrcweir                 aRedoGraphic = Graphic();
1093*cdf0e10cSrcweir                 aUndoGraphic = aGraphic;
1094*cdf0e10cSrcweir                 aGraphic = Graphic( BitmapEx( aBmp, aMask ) );
1095*cdf0e10cSrcweir                 nGrfChanged++;
1096*cdf0e10cSrcweir 
1097*cdf0e10cSrcweir                 bNewContour = ( aQBox.Execute() == RET_YES );
1098*cdf0e10cSrcweir                 pWnd->SetGraphic( aGraphic, bNewContour );
1099*cdf0e10cSrcweir 
1100*cdf0e10cSrcweir                 if( bNewContour )
1101*cdf0e10cSrcweir                     aCreateTimer.Start();
1102*cdf0e10cSrcweir             }
1103*cdf0e10cSrcweir         }
1104*cdf0e10cSrcweir 
1105*cdf0e10cSrcweir         LeaveWait();
1106*cdf0e10cSrcweir     }
1107*cdf0e10cSrcweir 
1108*cdf0e10cSrcweir     aTbx1.CheckItem( TBI_PIPETTE, sal_False );
1109*cdf0e10cSrcweir     pWnd->SetPipetteMode( sal_False );
1110*cdf0e10cSrcweir     aStbStatus.Invalidate();
1111*cdf0e10cSrcweir 
1112*cdf0e10cSrcweir     return 0L;
1113*cdf0e10cSrcweir }
1114*cdf0e10cSrcweir 
1115*cdf0e10cSrcweir 
1116*cdf0e10cSrcweir /*************************************************************************
1117*cdf0e10cSrcweir |*
1118*cdf0e10cSrcweir |*
1119*cdf0e10cSrcweir |*
1120*cdf0e10cSrcweir \************************************************************************/
1121*cdf0e10cSrcweir 
1122*cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, WorkplaceClickHdl, ContourWindow*, pWnd )
1123*cdf0e10cSrcweir {
1124*cdf0e10cSrcweir     aTbx1.CheckItem( TBI_WORKPLACE, sal_False );
1125*cdf0e10cSrcweir     aTbx1.CheckItem( TBI_SELECT, sal_True );
1126*cdf0e10cSrcweir     pWnd->SetWorkplaceMode( sal_False );
1127*cdf0e10cSrcweir 
1128*cdf0e10cSrcweir     return 0L;
1129*cdf0e10cSrcweir }
1130*cdf0e10cSrcweir 
1131*cdf0e10cSrcweir void SvxSuperContourDlg::ApplyImageList()
1132*cdf0e10cSrcweir {
1133*cdf0e10cSrcweir     bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
1134*cdf0e10cSrcweir 
1135*cdf0e10cSrcweir     ImageList& rImgLst = bHighContrast ? maImageListH : maImageList;
1136*cdf0e10cSrcweir 
1137*cdf0e10cSrcweir     aTbx1.SetImageList( rImgLst );
1138*cdf0e10cSrcweir }
1139*cdf0e10cSrcweir 
1140*cdf0e10cSrcweir void SvxSuperContourDlg::DataChanged( const DataChangedEvent& rDCEvt )
1141*cdf0e10cSrcweir {
1142*cdf0e10cSrcweir     SfxFloatingWindow::DataChanged( rDCEvt );
1143*cdf0e10cSrcweir 
1144*cdf0e10cSrcweir     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1145*cdf0e10cSrcweir             ApplyImageList();
1146*cdf0e10cSrcweir }
1147*cdf0e10cSrcweir 
1148*cdf0e10cSrcweir /*************************************************************************
1149*cdf0e10cSrcweir |*
1150*cdf0e10cSrcweir |*
1151*cdf0e10cSrcweir |*
1152*cdf0e10cSrcweir \************************************************************************/
1153*cdf0e10cSrcweir 
1154*cdf0e10cSrcweir IMPL_LINK( SvxSuperContourDlg, MiscHdl, void*, EMPTYARG )
1155*cdf0e10cSrcweir {
1156*cdf0e10cSrcweir     SvtMiscOptions aMiscOptions;
1157*cdf0e10cSrcweir     aTbx1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
1158*cdf0e10cSrcweir 
1159*cdf0e10cSrcweir     return 0L;
1160*cdf0e10cSrcweir }
1161*cdf0e10cSrcweir 
1162