LCOV - code coverage report
Current view: top level - svx/source/dialog - _contdlg.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 2 405 0.5 %
Date: 2014-04-11 Functions: 4 52 7.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <vcl/wrkwin.hxx>
      21             : #include <sot/factory.hxx>
      22             : #include <tools/shl.hxx>
      23             : #include <tools/helpers.hxx>
      24             : #include <vcl/msgbox.hxx>
      25             : #include <svl/eitem.hxx>
      26             : #include <sfx2/dispatch.hxx>
      27             : #include <sfx2/viewfrm.hxx>
      28             : #include <svtools/miscopt.hxx>
      29             : #include <unotools/localedatawrapper.hxx>
      30             : #include <comphelper/processfactory.hxx>
      31             : 
      32             : #include <svx/dialmgr.hxx>
      33             : #include "svx/xoutbmp.hxx"
      34             : #include <svx/dialogs.hrc>
      35             : #include <svx/svxids.hrc>
      36             : #include <svx/contdlg.hxx>
      37             : #include "contimp.hxx"
      38             : #include "contdlg.hrc"
      39             : #include "contwnd.hxx"
      40             : #include <svx/svdtrans.hxx>
      41             : #include <svx/svdopath.hxx>
      42             : #include "svx/dlgutil.hxx"
      43             : #include <vcl/svapp.hxx>
      44             : #include <vcl/settings.hxx>
      45             : #include <vcl/virdev.hxx>
      46             : #include "dlgunit.hxx"
      47             : #include <vcl/layout.hxx>
      48             : 
      49          74 : SFX_IMPL_FLOATINGWINDOW_WITHID( SvxContourDlgChildWindow, SID_CONTOUR_DLG );
      50             : 
      51             : 
      52             : /******************************************************************************/
      53             : 
      54           0 : SvxContourDlgItem::SvxContourDlgItem( sal_uInt16 _nId, SvxSuperContourDlg& rContourDlg, SfxBindings& rBindings ) :
      55             :             SfxControllerItem   ( _nId, rBindings ),
      56           0 :             rDlg                ( rContourDlg )
      57             : {
      58           0 : }
      59             : 
      60           0 : void SvxContourDlgItem::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/, const SfxPoolItem* pItem )
      61             : {
      62           0 :     if ( pItem && ( SID_CONTOUR_EXEC == nSID ) )
      63             :     {
      64           0 :         const SfxBoolItem* pStateItem = PTR_CAST( SfxBoolItem, pItem );
      65             : 
      66             :         DBG_ASSERT( pStateItem || pItem == 0, "SfxBoolItem expected ");
      67             : 
      68           0 :         rDlg.SetExecState( !pStateItem->GetValue() );
      69             :     }
      70           0 : }
      71             : 
      72             : 
      73             : /******************************************************************************/
      74             : 
      75           0 : SvxContourDlgChildWindow::SvxContourDlgChildWindow( Window* _pParent, sal_uInt16 nId,
      76             :                                                     SfxBindings* pBindings, SfxChildWinInfo* pInfo ) :
      77           0 :             SfxChildWindow( _pParent, nId )
      78             : {
      79           0 :     SvxSuperContourDlg* pDlg = new SvxSuperContourDlg( pBindings, this, _pParent, CONT_RESID( RID_SVXDLG_CONTOUR ) );
      80           0 :     pWindow = pDlg;
      81             : 
      82           0 :     if ( pInfo->nFlags & SFX_CHILDWIN_ZOOMIN )
      83           0 :         pDlg->RollUp();
      84             : 
      85           0 :     eChildAlignment = SFX_ALIGN_NOALIGNMENT;
      86             : 
      87           0 :     pDlg->Initialize( pInfo );
      88           0 : }
      89             : 
      90           0 : SvxContourDlg::SvxContourDlg( SfxBindings* _pBindings, SfxChildWindow* pCW,
      91             :                               Window* _pParent, const ResId& rResId )
      92             :     : SfxFloatingWindow(_pBindings, pCW, _pParent, rResId)
      93           0 :     , pSuperClass(NULL)
      94             : {
      95           0 : }
      96             : 
      97           0 : SvxContourDlg::~SvxContourDlg()
      98             : {
      99           0 : }
     100             : 
     101           0 : PolyPolygon SvxContourDlg::CreateAutoContour( const Graphic& rGraphic,
     102             :                                               const Rectangle* pRect,
     103             :                                               const sal_uIntPtr nFlags )
     104             : {
     105           0 :     Bitmap  aBmp;
     106           0 :     sal_uIntPtr nContourFlags = XOUTBMP_CONTOUR_HORZ;
     107             : 
     108           0 :     if ( rGraphic.GetType() == GRAPHIC_BITMAP )
     109             :     {
     110           0 :         if( rGraphic.IsAnimated() )
     111             :         {
     112           0 :             VirtualDevice       aVDev;
     113           0 :             MapMode             aTransMap;
     114           0 :             const Animation     aAnim( rGraphic.GetAnimation() );
     115           0 :             const Size&         rSizePix = aAnim.GetDisplaySizePixel();
     116           0 :             const sal_uInt16        nCount = aAnim.Count();
     117             : 
     118           0 :             if ( aVDev.SetOutputSizePixel( rSizePix ) )
     119             :             {
     120           0 :                 aVDev.SetLineColor( Color( COL_BLACK ) );
     121           0 :                 aVDev.SetFillColor( Color( COL_BLACK ) );
     122             : 
     123           0 :                 for( sal_uInt16 i = 0; i < nCount; i++ )
     124             :                 {
     125           0 :                     const AnimationBitmap& rStepBmp = aAnim.Get( i );
     126             : 
     127             :                     // Push Polygon output to the right place; this is the
     128             :                     // offset of the sub-image within the total animation
     129           0 :                     aTransMap.SetOrigin( Point( rStepBmp.aPosPix.X(), rStepBmp.aPosPix.Y() ) );
     130           0 :                     aVDev.SetMapMode( aTransMap );
     131           0 :                     aVDev.DrawPolyPolygon( CreateAutoContour( rStepBmp.aBmpEx, pRect, nFlags ) );
     132             :                 }
     133             : 
     134           0 :                 aTransMap.SetOrigin( Point() );
     135           0 :                 aVDev.SetMapMode( aTransMap );
     136           0 :                 aBmp = aVDev.GetBitmap( Point(), rSizePix );
     137           0 :                 aBmp.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
     138           0 :             }
     139             :         }
     140           0 :         else if( rGraphic.IsTransparent() )
     141           0 :             aBmp = rGraphic.GetBitmapEx().GetMask();
     142             :         else
     143             :         {
     144           0 :             aBmp = rGraphic.GetBitmap();
     145           0 :             nContourFlags |= XOUTBMP_CONTOUR_EDGEDETECT;
     146             :         }
     147             :     }
     148           0 :     else if( rGraphic.GetType() != GRAPHIC_NONE )
     149             :     {
     150           0 :         const Graphic   aTmpGrf( rGraphic.GetGDIMetaFile().GetMonochromeMtf( Color( COL_BLACK ) ) );
     151           0 :         VirtualDevice   aVDev;
     152           0 :         Size            aSizePix( aVDev.LogicToPixel( aTmpGrf.GetPrefSize(), aTmpGrf.GetPrefMapMode() ) );
     153             : 
     154           0 :         if( aSizePix.Width() && aSizePix.Height() && ( aSizePix.Width() > 512 || aSizePix.Height() > 512 ) )
     155             :         {
     156           0 :             double fWH = (double) aSizePix.Width() / aSizePix.Height();
     157             : 
     158           0 :             if( fWH <= 1.0 )
     159           0 :                 aSizePix.Width() = FRound( ( aSizePix.Height() = 512 ) * fWH );
     160             :             else
     161           0 :                 aSizePix.Height() = FRound( ( aSizePix.Width() = 512 ) / fWH );
     162             :         }
     163             : 
     164           0 :         if( aVDev.SetOutputSizePixel( aSizePix ) )
     165             :         {
     166           0 :             const Point aPt;
     167           0 :             aTmpGrf.Draw( &aVDev, aPt, aSizePix );
     168           0 :             aBmp = aVDev.GetBitmap( aPt, aSizePix );
     169             :         }
     170             : 
     171           0 :         nContourFlags |= XOUTBMP_CONTOUR_EDGEDETECT;
     172             :     }
     173             : 
     174           0 :     aBmp.SetPrefSize( rGraphic.GetPrefSize() );
     175           0 :     aBmp.SetPrefMapMode( rGraphic.GetPrefMapMode() );
     176             : 
     177           0 :     return PolyPolygon( XOutBitmap::GetCountour( aBmp, nContourFlags, 128, pRect ) );
     178             : }
     179             : 
     180             : // Loop through to super class, no virtual Methods to not become incompatible
     181             : // due to IF changes
     182             : 
     183           0 : const Graphic& SvxContourDlg::GetGraphic() const
     184             : {
     185           0 :     return pSuperClass->GetGraphic();
     186             : }
     187             : 
     188           0 : bool SvxContourDlg::IsGraphicChanged() const
     189             : {
     190           0 :     return pSuperClass->IsGraphicChanged();
     191             : }
     192             : 
     193           0 : PolyPolygon SvxContourDlg::GetPolyPolygon()
     194             : {
     195           0 :     return pSuperClass->GetPolyPolygon( true );
     196             : }
     197             : 
     198           0 : const void* SvxContourDlg::GetEditingObject() const
     199             : {
     200           0 :     return pSuperClass->GetEditingObject();
     201             : }
     202             : 
     203           0 : void SvxContourDlg::Update( const Graphic& rGraphic, bool bGraphicLinked,
     204             :                             const PolyPolygon* pPolyPoly, void* pEditingObj )
     205             : {
     206           0 :     pSuperClass->UpdateGraphic( rGraphic, bGraphicLinked, pPolyPoly, pEditingObj );
     207           0 : }
     208             : 
     209           0 : SvxSuperContourDlg::SvxSuperContourDlg( SfxBindings *_pBindings, SfxChildWindow *pCW,
     210             :                                         Window* _pParent, const ResId& rResId ) :
     211             :         SvxContourDlg       ( _pBindings, pCW, _pParent, rResId ),
     212             :         pUpdateEditingObject( NULL ),
     213             :         pCheckObj           ( NULL ),
     214             :         aContourItem        ( SID_CONTOUR_EXEC, *this, *_pBindings ),
     215           0 :         aTbx1               ( this, ResId( TBX1, *rResId.GetResMgr() ) ),
     216           0 :         aMtfTolerance       ( this, ResId( MTF_TOLERANCE, *rResId.GetResMgr() ) ),
     217           0 :         aContourWnd         ( this, ResId( CTL_CONTOUR, *rResId.GetResMgr() ) ),
     218             :         aStbStatus          ( this, WB_BORDER | WB_3DLOOK | WB_LEFT ),
     219             :         nGrfChanged         ( 0UL ),
     220             :         bExecState          ( sal_False ),
     221             :         bUpdateGraphicLinked( sal_False ),
     222             :         bGraphicLinked      ( sal_False ),
     223           0 :         maImageList         ( SVX_RES( CD_IMAPDLG ) )
     224             : {
     225           0 :     ApplyImageList();
     226             : 
     227           0 :     FreeResource();
     228             : 
     229           0 :     SvxContourDlg::SetSuperClass( *this );
     230             : 
     231           0 :     aContourWnd.SetMousePosLink( LINK( this, SvxSuperContourDlg, MousePosHdl ) );
     232           0 :     aContourWnd.SetGraphSizeLink( LINK( this, SvxSuperContourDlg, GraphSizeHdl ) );
     233           0 :     aContourWnd.SetUpdateLink( LINK( this, SvxSuperContourDlg, StateHdl ) );
     234           0 :     aContourWnd.SetPipetteHdl( LINK( this, SvxSuperContourDlg, PipetteHdl ) );
     235           0 :     aContourWnd.SetPipetteClickHdl( LINK( this, SvxSuperContourDlg, PipetteClickHdl ) );
     236           0 :     aContourWnd.SetWorkplaceClickHdl( LINK( this, SvxSuperContourDlg, WorkplaceClickHdl ) );
     237             : 
     238           0 :     const Size      aTbxSize( aTbx1.CalcWindowSizePixel() );
     239           0 :     Point           aPos( aTbx1.GetPosPixel() );
     240           0 :       SvtMiscOptions  aMiscOptions;
     241             : 
     242           0 :     aMiscOptions.AddListenerLink( LINK( this, SvxSuperContourDlg, MiscHdl ) );
     243             : 
     244           0 :     aTbx1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
     245           0 :     aTbx1.SetSizePixel( aTbxSize );
     246           0 :     aTbx1.SetSelectHdl( LINK( this, SvxSuperContourDlg, Tbx1ClickHdl ) );
     247             : 
     248           0 :     aPos.X() += aTbxSize.Width() + LogicToPixel( Size( 3, 0 ), MapMode( MAP_APPFONT ) ).Width();
     249           0 :     aMtfTolerance.SetPosPixel( aPos );
     250           0 :     aMtfTolerance.SetValue( 10L );
     251             : 
     252           0 :     SetMinOutputSizePixel( aLastSize = GetOutputSizePixel() );
     253             : 
     254           0 :     aStbStatus.InsertItem( 1, 130, SIB_LEFT | SIB_IN | SIB_AUTOSIZE );
     255           0 :     aStbStatus.InsertItem( 2, 10 + GetTextWidth( OUString(" 9999,99 cm / 9999,99 cm ") ), SIB_CENTER | SIB_IN );
     256           0 :     aStbStatus.InsertItem( 3, 10 + GetTextWidth( OUString(" 9999,99 cm x 9999,99 cm ") ), SIB_CENTER | SIB_IN );
     257           0 :     aStbStatus.InsertItem( 4, 20, SIB_CENTER | SIB_IN );
     258             : 
     259           0 :     Resize();
     260             : 
     261           0 :     aUpdateTimer.SetTimeout( 100 );
     262           0 :     aUpdateTimer.SetTimeoutHdl( LINK( this, SvxSuperContourDlg, UpdateHdl ) );
     263             : 
     264           0 :     aCreateTimer.SetTimeout( 50 );
     265           0 :     aCreateTimer.SetTimeoutHdl( LINK( this, SvxSuperContourDlg, CreateHdl ) );
     266           0 : }
     267             : 
     268           0 : SvxSuperContourDlg::~SvxSuperContourDlg()
     269             : {
     270           0 :     SvtMiscOptions aMiscOptions;
     271           0 :     aMiscOptions.RemoveListenerLink( LINK(this, SvxSuperContourDlg, MiscHdl) );
     272           0 : }
     273             : 
     274             : // Resize methods
     275             : 
     276           0 : void SvxSuperContourDlg::Resize()
     277             : {
     278           0 :     SfxFloatingWindow::Resize();
     279             : 
     280           0 :     Size aMinSize( GetMinOutputSizePixel() );
     281           0 :     Size aNewSize( GetOutputSizePixel() );
     282             : 
     283           0 :     if ( aNewSize.Height() >= aMinSize.Height() )
     284             :     {
     285           0 :         Size    _aSize( aStbStatus.GetSizePixel() );
     286           0 :         Point   aPoint( 0, aNewSize.Height() - _aSize.Height() );
     287             : 
     288             :         // Position the StatusBar
     289           0 :         aStbStatus.SetPosSizePixel( aPoint, Size( aNewSize.Width(), _aSize.Height() ) );
     290           0 :         aStbStatus.Show();
     291             : 
     292             :         // Position the EditWindow
     293           0 :         _aSize.Width() = aNewSize.Width() - 18;
     294           0 :         _aSize.Height() = aPoint.Y() - aContourWnd.GetPosPixel().Y() - 6;
     295           0 :         aContourWnd.SetSizePixel( _aSize );
     296             : 
     297           0 :         aLastSize = aNewSize;
     298             :     }
     299           0 : }
     300             : 
     301             : // Close methods
     302             : 
     303           0 : bool SvxSuperContourDlg::Close()
     304             : {
     305           0 :     sal_Bool bRet = sal_True;
     306             : 
     307           0 :     if ( aTbx1.IsItemEnabled( TBI_APPLY ) )
     308             :     {
     309           0 :         MessageDialog aQBox( this,"QuerySaveContourChangesDialog","svx/ui/querysavecontchangesdialog.ui");
     310           0 :         const long  nRet = aQBox.Execute();
     311             : 
     312           0 :         if ( nRet == RET_YES )
     313             :         {
     314           0 :             SfxBoolItem aBoolItem( SID_CONTOUR_EXEC, true );
     315           0 :             GetBindings().GetDispatcher()->Execute(
     316           0 :                 SID_CONTOUR_EXEC, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
     317             :         }
     318           0 :         else if ( nRet == RET_CANCEL )
     319           0 :             bRet = sal_False;
     320             :     }
     321             : 
     322           0 :     return( bRet ? SfxFloatingWindow::Close() : sal_False );
     323             : }
     324             : 
     325             : // Enabled or disabled all Controls
     326             : 
     327           0 : void SvxSuperContourDlg::SetExecState( sal_Bool bEnable )
     328             : {
     329           0 :     bExecState = bEnable;
     330           0 : }
     331             : 
     332           0 : void SvxSuperContourDlg::SetGraphic( const Graphic& rGraphic )
     333             : {
     334           0 :     aUndoGraphic = aRedoGraphic = Graphic();
     335           0 :     aGraphic = rGraphic;
     336           0 :     nGrfChanged = 0UL;
     337           0 :     aContourWnd.SetGraphic( aGraphic );
     338           0 : }
     339             : 
     340           0 : void SvxSuperContourDlg::SetPolyPolygon( const PolyPolygon& rPolyPoly )
     341             : {
     342             :     DBG_ASSERT(  aContourWnd.GetGraphic().GetType() != GRAPHIC_NONE, "Graphic must've been set first!" );
     343             : 
     344           0 :     PolyPolygon     aPolyPoly( rPolyPoly );
     345           0 :     const MapMode   aMap100( MAP_100TH_MM );
     346           0 :     const MapMode   aGrfMap( aGraphic.GetPrefMapMode() );
     347           0 :     OutputDevice*   pOutDev = Application::GetDefaultDevice();
     348           0 :     sal_Bool            bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
     349             : 
     350           0 :     for ( sal_uInt16 j = 0, nPolyCount = aPolyPoly.Count(); j < nPolyCount; j++ )
     351             :     {
     352           0 :         Polygon& rPoly = aPolyPoly[ j ];
     353             : 
     354           0 :         for ( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
     355             :         {
     356           0 :             Point& rPt = rPoly[ i ];
     357             : 
     358           0 :             if ( !bPixelMap )
     359           0 :                 rPt = pOutDev->LogicToPixel( rPt, aGrfMap );
     360             : 
     361           0 :             rPt = pOutDev->PixelToLogic( rPt, aMap100 );
     362             :         }
     363             :     }
     364             : 
     365           0 :     aContourWnd.SetPolyPolygon( aPolyPoly );
     366           0 :     aContourWnd.GetSdrModel()->SetChanged( true );
     367           0 : }
     368             : 
     369           0 : PolyPolygon SvxSuperContourDlg::GetPolyPolygon( bool bRescaleToGraphic )
     370             : {
     371           0 :     PolyPolygon aRetPolyPoly( aContourWnd.GetPolyPolygon() );
     372             : 
     373           0 :     if ( bRescaleToGraphic )
     374             :     {
     375           0 :         const MapMode   aMap100( MAP_100TH_MM );
     376           0 :         const MapMode   aGrfMap( aGraphic.GetPrefMapMode() );
     377           0 :         OutputDevice*   pOutDev = Application::GetDefaultDevice();
     378           0 :         sal_Bool            bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
     379             : 
     380           0 :         for ( sal_uInt16 j = 0, nPolyCount = aRetPolyPoly.Count(); j < nPolyCount; j++ )
     381             :         {
     382           0 :             Polygon& rPoly = aRetPolyPoly[ j ];
     383             : 
     384           0 :             for ( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
     385             :             {
     386           0 :                 Point& rPt = rPoly[ i ];
     387             : 
     388           0 :                 rPt = pOutDev->LogicToPixel( rPt, aMap100  );
     389             : 
     390           0 :                 if ( !bPixelMap )
     391           0 :                     rPt = pOutDev->PixelToLogic( rPt, aGrfMap  );
     392             :             }
     393           0 :         }
     394             :     }
     395             : 
     396           0 :     return aRetPolyPoly;
     397             : }
     398             : 
     399           0 : void SvxSuperContourDlg::UpdateGraphic( const Graphic& rGraphic, sal_Bool _bGraphicLinked,
     400             :                                  const PolyPolygon* pPolyPoly, void* pEditingObj )
     401             : {
     402           0 :     aUpdateGraphic = rGraphic;
     403           0 :     bUpdateGraphicLinked = _bGraphicLinked;
     404           0 :     pUpdateEditingObject = pEditingObj;
     405             : 
     406           0 :     if ( pPolyPoly )
     407           0 :         aUpdatePolyPoly = *pPolyPoly;
     408             :     else
     409           0 :         aUpdatePolyPoly = PolyPolygon();
     410             : 
     411           0 :     aUpdateTimer.Start();
     412           0 : }
     413             : 
     414           0 : bool SvxSuperContourDlg::IsUndoPossible() const
     415             : {
     416           0 :     return aUndoGraphic.GetType() != GRAPHIC_NONE;
     417             : }
     418             : 
     419           0 : bool SvxSuperContourDlg::IsRedoPossible() const
     420             : {
     421           0 :     return aRedoGraphic.GetType() != GRAPHIC_NONE;
     422             : }
     423             : 
     424             : // Click handler for ToolBox
     425             : 
     426           0 : IMPL_LINK( SvxSuperContourDlg, Tbx1ClickHdl, ToolBox*, pTbx )
     427             : {
     428           0 :     sal_uInt16 nNewItemId = pTbx->GetCurItemId();
     429             : 
     430           0 :     switch( pTbx->GetCurItemId() )
     431             :     {
     432             :         case( TBI_APPLY ):
     433             :         {
     434           0 :             SfxBoolItem aBoolItem( SID_CONTOUR_EXEC, true );
     435           0 :             GetBindings().GetDispatcher()->Execute(
     436           0 :                 SID_CONTOUR_EXEC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
     437             :         }
     438           0 :         break;
     439             : 
     440             :         case( TBI_WORKPLACE ):
     441             :         {
     442           0 :             if ( aTbx1.IsItemChecked( TBI_WORKPLACE ) )
     443             :             {
     444           0 :                 MessageDialog aQBox( this,"QueryDeleteContourDialog","svx/ui/querydeletecontourdialog.ui");
     445             : 
     446           0 :                 if ( !aContourWnd.IsContourChanged() || ( aQBox.Execute() == RET_YES ) )
     447           0 :                     aContourWnd.SetWorkplaceMode( sal_True );
     448             :                 else
     449           0 :                     aTbx1.CheckItem( TBI_WORKPLACE, false );
     450             :             }
     451             :             else
     452           0 :                 aContourWnd.SetWorkplaceMode( sal_False );
     453             :         }
     454           0 :         break;
     455             : 
     456             :         case( TBI_SELECT ):
     457             :         {
     458           0 :             pTbx->CheckItem( nNewItemId, true );
     459           0 :             aContourWnd.SetEditMode( true );
     460             :         }
     461           0 :         break;
     462             : 
     463             :         case( TBI_RECT ):
     464             :         {
     465           0 :             pTbx->CheckItem( nNewItemId, true );
     466           0 :             aContourWnd.SetObjKind( OBJ_RECT );
     467             :         }
     468           0 :         break;
     469             : 
     470             :         case( TBI_CIRCLE ):
     471             :         {
     472           0 :             pTbx->CheckItem( nNewItemId, true );
     473           0 :             aContourWnd.SetObjKind( OBJ_CIRC );
     474             : 
     475             :         }
     476           0 :         break;
     477             : 
     478             :         case( TBI_POLY ):
     479             :         {
     480           0 :             pTbx->CheckItem( nNewItemId, true );
     481           0 :             aContourWnd.SetObjKind( OBJ_POLY );
     482             :         }
     483           0 :         break;
     484             : 
     485             :         case( TBI_FREEPOLY ):
     486             :         {
     487           0 :             pTbx->CheckItem( nNewItemId, true );
     488           0 :             aContourWnd.SetObjKind( OBJ_FREEFILL );
     489             :         }
     490           0 :         break;
     491             : 
     492             :         case( TBI_POLYEDIT ):
     493           0 :             aContourWnd.SetPolyEditMode( pTbx->IsItemChecked( TBI_POLYEDIT ) ? SID_BEZIER_MOVE : 0 );
     494           0 :         break;
     495             : 
     496             :         case( TBI_POLYMOVE ):
     497           0 :             aContourWnd.SetPolyEditMode( SID_BEZIER_MOVE );
     498           0 :         break;
     499             : 
     500             :         case( TBI_POLYINSERT ):
     501           0 :             aContourWnd.SetPolyEditMode( SID_BEZIER_INSERT );
     502           0 :         break;
     503             : 
     504             :         case( TBI_POLYDELETE ):
     505           0 :             aContourWnd.GetSdrView()->DeleteMarkedPoints();
     506           0 :         break;
     507             : 
     508             :         case( TBI_UNDO ):
     509             :         {
     510           0 :             nGrfChanged = nGrfChanged ? nGrfChanged - 1 : 0UL;
     511           0 :             aRedoGraphic = aGraphic;
     512           0 :             aGraphic = aUndoGraphic;
     513           0 :             aUndoGraphic = Graphic();
     514           0 :             aContourWnd.SetGraphic( aGraphic, false );
     515             :         }
     516           0 :         break;
     517             : 
     518             :         case( TBI_REDO ):
     519             :         {
     520           0 :             nGrfChanged++;
     521           0 :             aUndoGraphic = aGraphic;
     522           0 :             aGraphic = aRedoGraphic;
     523           0 :             aRedoGraphic = Graphic();
     524           0 :             aContourWnd.SetGraphic( aGraphic, false );
     525             :         }
     526           0 :         break;
     527             : 
     528             :         case( TBI_AUTOCONTOUR ):
     529           0 :             aCreateTimer.Start();
     530           0 :         break;
     531             : 
     532             :         case( TBI_PIPETTE ):
     533             :         {
     534           0 :             sal_Bool bPipette = aTbx1.IsItemChecked( TBI_PIPETTE );
     535             : 
     536           0 :             if ( !bPipette )
     537           0 :                 aStbStatus.Invalidate();
     538           0 :             else if ( bGraphicLinked )
     539             :             {
     540             :                 MessageDialog aQBox(this, "QueryUnlinkGraphicsDialog",
     541           0 :                     "svx/ui/queryunlinkgraphicsdialog.ui");
     542             : 
     543           0 :                 if (aQBox.Execute() != RET_YES)
     544             :                 {
     545           0 :                     bPipette = false;
     546           0 :                     aTbx1.CheckItem(TBI_PIPETTE, bPipette);
     547           0 :                     aStbStatus.Invalidate();
     548           0 :                 }
     549             :             }
     550             : 
     551           0 :             aContourWnd.SetPipetteMode( bPipette );
     552             :         }
     553           0 :         break;
     554             : 
     555             :         default:
     556           0 :         break;
     557             :     }
     558             : 
     559           0 :     return 0L;
     560             : }
     561             : 
     562           0 : IMPL_LINK( SvxSuperContourDlg, MousePosHdl, ContourWindow*, pWnd )
     563             : {
     564           0 :     OUString aStr;
     565           0 :     const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
     566           0 :     const Point& rMousePos = pWnd->GetMousePos();
     567           0 :     const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
     568           0 :     const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0];
     569             : 
     570           0 :     aStr = GetUnitString( rMousePos.X(), eFieldUnit, cSep );
     571           0 :     aStr += " / ";
     572           0 :     aStr += GetUnitString( rMousePos.Y(), eFieldUnit, cSep );
     573             : 
     574           0 :     aStbStatus.SetItemText( 2, aStr );
     575             : 
     576           0 :     return 0L;
     577             : }
     578             : 
     579           0 : IMPL_LINK( SvxSuperContourDlg, GraphSizeHdl, ContourWindow*, pWnd )
     580             : {
     581           0 :     OUString aStr;
     582           0 :     const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
     583           0 :     const Size& rSize = pWnd->GetGraphicSize();
     584           0 :     const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
     585           0 :     const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0];
     586             : 
     587           0 :     aStr = GetUnitString( rSize.Width(), eFieldUnit, cSep );
     588           0 :     aStr += " x ";
     589           0 :     aStr += GetUnitString( rSize.Height(), eFieldUnit, cSep );
     590             : 
     591           0 :     aStbStatus.SetItemText( 3, aStr );
     592             : 
     593           0 :     return 0L;
     594             : }
     595             : 
     596           0 : IMPL_LINK_NOARG(SvxSuperContourDlg, UpdateHdl)
     597             : {
     598           0 :     aUpdateTimer.Stop();
     599             : 
     600           0 :     if ( pUpdateEditingObject != pCheckObj )
     601             :     {
     602           0 :         if( !GetEditingObject() )
     603           0 :             aContourWnd.GrabFocus();
     604             : 
     605           0 :         SetGraphic( aUpdateGraphic );
     606           0 :         SetPolyPolygon( aUpdatePolyPoly );
     607           0 :         SetEditingObject( pUpdateEditingObject );
     608           0 :         bGraphicLinked = bUpdateGraphicLinked;
     609             : 
     610           0 :         aUpdateGraphic = Graphic();
     611           0 :         aUpdatePolyPoly = PolyPolygon();
     612           0 :         bUpdateGraphicLinked = sal_False;
     613             : 
     614           0 :         aContourWnd.GetSdrModel()->SetChanged( false );
     615             :     }
     616             : 
     617           0 :     GetBindings().Invalidate( SID_CONTOUR_EXEC );
     618             : 
     619           0 :     return 0L;
     620             : }
     621             : 
     622           0 : IMPL_LINK_NOARG(SvxSuperContourDlg, CreateHdl)
     623             : {
     624           0 :     aCreateTimer.Stop();
     625             : 
     626           0 :     const Rectangle aWorkRect = aContourWnd.LogicToPixel( aContourWnd.GetWorkRect(), MapMode( MAP_100TH_MM ) );
     627           0 :     const Graphic&  rGraphic = aContourWnd.GetGraphic();
     628           0 :     const sal_Bool      bValid = aWorkRect.Left() != aWorkRect.Right() && aWorkRect.Top() != aWorkRect.Bottom();
     629             : 
     630           0 :     EnterWait();
     631           0 :     SetPolyPolygon( CreateAutoContour( rGraphic, bValid ? &aWorkRect : NULL ) );
     632           0 :     LeaveWait();
     633             : 
     634           0 :     return 0L;
     635             : }
     636             : 
     637           0 : IMPL_LINK( SvxSuperContourDlg, StateHdl, ContourWindow*, pWnd )
     638             : {
     639           0 :     const SdrObject*    pObj = pWnd->GetSelectedSdrObject();
     640           0 :     const SdrView*      pView = pWnd->GetSdrView();
     641           0 :     const sal_Bool          bPolyEdit = ( pObj != NULL ) && pObj->ISA( SdrPathObj );
     642           0 :     const sal_Bool          bDrawEnabled = !( bPolyEdit && aTbx1.IsItemChecked( TBI_POLYEDIT ) );
     643           0 :     const sal_Bool          bPipette = aTbx1.IsItemChecked( TBI_PIPETTE );
     644           0 :     const sal_Bool          bWorkplace = aTbx1.IsItemChecked( TBI_WORKPLACE );
     645           0 :     const sal_Bool          bDontHide = !( bPipette || bWorkplace );
     646           0 :     const sal_Bool          bBitmap = pWnd->GetGraphic().GetType() == GRAPHIC_BITMAP;
     647             : 
     648           0 :     aTbx1.EnableItem( TBI_APPLY, bDontHide && bExecState && pWnd->IsChanged() );
     649             : 
     650           0 :     aTbx1.EnableItem( TBI_WORKPLACE, !bPipette && bDrawEnabled );
     651             : 
     652           0 :     aTbx1.EnableItem( TBI_SELECT, bDontHide && bDrawEnabled );
     653           0 :     aTbx1.EnableItem( TBI_RECT, bDontHide && bDrawEnabled );
     654           0 :     aTbx1.EnableItem( TBI_CIRCLE, bDontHide && bDrawEnabled );
     655           0 :     aTbx1.EnableItem( TBI_POLY, bDontHide && bDrawEnabled );
     656           0 :     aTbx1.EnableItem( TBI_FREEPOLY, bDontHide && bDrawEnabled );
     657             : 
     658           0 :     aTbx1.EnableItem( TBI_POLYEDIT, bDontHide && bPolyEdit );
     659           0 :     aTbx1.EnableItem( TBI_POLYMOVE, bDontHide && !bDrawEnabled );
     660           0 :     aTbx1.EnableItem( TBI_POLYINSERT, bDontHide && !bDrawEnabled );
     661           0 :     aTbx1.EnableItem( TBI_POLYDELETE, bDontHide && !bDrawEnabled && pView->IsDeleteMarkedPointsPossible() );
     662             : 
     663           0 :     aTbx1.EnableItem( TBI_AUTOCONTOUR, bDontHide && bDrawEnabled );
     664           0 :     aTbx1.EnableItem( TBI_PIPETTE, !bWorkplace && bDrawEnabled && bBitmap );
     665             : 
     666           0 :     aTbx1.EnableItem( TBI_UNDO, bDontHide && IsUndoPossible() );
     667           0 :     aTbx1.EnableItem( TBI_REDO, bDontHide && IsRedoPossible() );
     668             : 
     669           0 :     if ( bPolyEdit )
     670             :     {
     671           0 :         sal_uInt16 nId = 0;
     672             : 
     673           0 :         switch( pWnd->GetPolyEditMode() )
     674             :         {
     675           0 :             case( SID_BEZIER_MOVE ): nId = TBI_POLYMOVE; break;
     676           0 :             case( SID_BEZIER_INSERT ): nId = TBI_POLYINSERT; break;
     677             : 
     678             :             default:
     679           0 :             break;
     680             :         }
     681             : 
     682           0 :         aTbx1.CheckItem( nId, true );
     683             :     }
     684             :     else
     685             :     {
     686           0 :         aTbx1.CheckItem( TBI_POLYEDIT, false );
     687           0 :         aTbx1.CheckItem( TBI_POLYMOVE, true );
     688           0 :         aTbx1.CheckItem( TBI_POLYINSERT, false );
     689           0 :         pWnd->SetPolyEditMode( 0 );
     690             :     }
     691             : 
     692           0 :     return 0L;
     693             : }
     694             : 
     695           0 : IMPL_LINK( SvxSuperContourDlg, PipetteHdl, ContourWindow*, pWnd )
     696             : {
     697           0 :     const Color& rOldLineColor = aStbStatus.GetLineColor();
     698           0 :     const Color& rOldFillColor = aStbStatus.GetFillColor();
     699             : 
     700           0 :     Rectangle       aRect( aStbStatus.GetItemRect( 4 ) );
     701           0 :     const Color&    rColor = pWnd->GetPipetteColor();
     702             : 
     703           0 :     aStbStatus.SetLineColor( rColor );
     704           0 :     aStbStatus.SetFillColor( rColor );
     705             : 
     706           0 :     aRect.Left() += 4;
     707           0 :     aRect.Top() += 4;
     708           0 :     aRect.Right() -= 4;
     709           0 :     aRect.Bottom() -= 4;
     710             : 
     711           0 :     aStbStatus.DrawRect( aRect );
     712             : 
     713           0 :     aStbStatus.SetLineColor( rOldLineColor );
     714           0 :     aStbStatus.SetFillColor( rOldFillColor );
     715             : 
     716           0 :     return 0L;
     717             : }
     718             : 
     719           0 : IMPL_LINK( SvxSuperContourDlg, PipetteClickHdl, ContourWindow*, pWnd )
     720             : {
     721           0 :     if ( pWnd->IsClickValid() )
     722             :     {
     723           0 :         Bitmap          aMask;
     724           0 :         const Color&    rColor = pWnd->GetPipetteColor();
     725             : 
     726           0 :         EnterWait();
     727             : 
     728           0 :         if( aGraphic.GetType() == GRAPHIC_BITMAP )
     729             :         {
     730           0 :             Bitmap      aBmp( aGraphic.GetBitmap() );
     731           0 :             const long  nTol = static_cast<long>(aMtfTolerance.GetValue() * 255L / 100L);
     732             : 
     733           0 :             aMask = aBmp.CreateMask( rColor, nTol );
     734             : 
     735           0 :             if( aGraphic.IsTransparent() )
     736           0 :                 aMask.CombineSimple( aGraphic.GetBitmapEx().GetMask(), BMP_COMBINE_OR );
     737             : 
     738           0 :             if( !!aMask )
     739             :             {
     740           0 :                 MessageDialog aQBox( this,"QueryNewContourDialog","svx/ui/querynewcontourdialog.ui");
     741             :                 sal_Bool        bNewContour;
     742             : 
     743           0 :                 aRedoGraphic = Graphic();
     744           0 :                 aUndoGraphic = aGraphic;
     745           0 :                 aGraphic = Graphic( BitmapEx( aBmp, aMask ) );
     746           0 :                 nGrfChanged++;
     747             : 
     748           0 :                 bNewContour = ( aQBox.Execute() == RET_YES );
     749           0 :                 pWnd->SetGraphic( aGraphic, bNewContour );
     750             : 
     751           0 :                 if( bNewContour )
     752           0 :                     aCreateTimer.Start();
     753           0 :             }
     754             :         }
     755             : 
     756           0 :         LeaveWait();
     757             :     }
     758             : 
     759           0 :     aTbx1.CheckItem( TBI_PIPETTE, false );
     760           0 :     pWnd->SetPipetteMode( sal_False );
     761           0 :     aStbStatus.Invalidate();
     762             : 
     763           0 :     return 0L;
     764             : }
     765             : 
     766           0 : IMPL_LINK( SvxSuperContourDlg, WorkplaceClickHdl, ContourWindow*, pWnd )
     767             : {
     768           0 :     aTbx1.CheckItem( TBI_WORKPLACE, false );
     769           0 :     aTbx1.CheckItem( TBI_SELECT, true );
     770           0 :     pWnd->SetWorkplaceMode( sal_False );
     771             : 
     772           0 :     return 0L;
     773             : }
     774             : 
     775           0 : void SvxSuperContourDlg::ApplyImageList()
     776             : {
     777           0 :     ImageList& rImgLst = maImageList;
     778             : 
     779           0 :     aTbx1.SetImageList( rImgLst );
     780           0 : }
     781             : 
     782           0 : void SvxSuperContourDlg::DataChanged( const DataChangedEvent& rDCEvt )
     783             : {
     784           0 :     SfxFloatingWindow::DataChanged( rDCEvt );
     785             : 
     786           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     787           0 :             ApplyImageList();
     788           0 : }
     789             : 
     790           0 : IMPL_LINK_NOARG(SvxSuperContourDlg, MiscHdl)
     791             : {
     792           0 :        SvtMiscOptions aMiscOptions;
     793           0 :     aTbx1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
     794             : 
     795           0 :     return 0L;
     796         255 : }
     797             : 
     798             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10