LCOV - code coverage report
Current view: top level - svx/source/dialog - grfflt.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 146 0.0 %
Date: 2014-04-14 Functions: 0 4 0.0 %
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 <tools/shl.hxx>
      21             : #include <vcl/msgbox.hxx>
      22             : #include <sfx2/viewfrm.hxx>
      23             : #include <sfx2/viewsh.hxx>
      24             : #include <sfx2/objsh.hxx>
      25             : #include <sfx2/request.hxx>
      26             : 
      27             : #include <svx/dialmgr.hxx>
      28             : #include <svx/grfflt.hxx>
      29             : #include <svx/dialogs.hrc>
      30             : #include <svx/svxdlg.hxx>
      31             : 
      32             : 
      33             : // - SvxGraphicFilter -
      34             : 
      35             : 
      36           0 : sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObject& rFilterObject )
      37             : {
      38           0 :     const Graphic&  rGraphic = rFilterObject.GetGraphic();
      39           0 :     sal_uIntPtr         nRet = SVX_GRAPHICFILTER_UNSUPPORTED_GRAPHICTYPE;
      40             : 
      41           0 :     if( rGraphic.GetType() == GRAPHIC_BITMAP )
      42             :     {
      43           0 :         SfxViewFrame*   pViewFrame = SfxViewFrame::Current();
      44           0 :         SfxObjectShell* pShell = pViewFrame ? pViewFrame->GetObjectShell() : NULL;
      45           0 :         Window*         pWindow = ( pViewFrame && pViewFrame->GetViewShell() ) ? pViewFrame->GetViewShell()->GetWindow() : NULL;
      46           0 :         Graphic         aGraphic;
      47             : 
      48           0 :         switch( rReq.GetSlot() )
      49             :         {
      50             :             case( SID_GRFFILTER_INVERT ):
      51             :             {
      52           0 :                 if( pShell )
      53           0 :                     pShell->SetWaitCursor( true );
      54             : 
      55           0 :                 if( rGraphic.IsAnimated() )
      56             :                 {
      57           0 :                     Animation aAnimation( rGraphic.GetAnimation() );
      58             : 
      59           0 :                     if( aAnimation.Invert() )
      60           0 :                         aGraphic = aAnimation;
      61             :                 }
      62             :                 else
      63             :                 {
      64           0 :                     BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
      65             : 
      66           0 :                     if( aBmpEx.Invert() )
      67           0 :                         aGraphic = aBmpEx;
      68             :                 }
      69             : 
      70           0 :                 if( pShell )
      71           0 :                     pShell->SetWaitCursor( false );
      72             :             }
      73           0 :             break;
      74             : 
      75             :             case( SID_GRFFILTER_SMOOTH ):
      76             :             {
      77           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
      78           0 :                 if(pFact)
      79             :                 {
      80           0 :                     AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSmooth(pWindow, rGraphic, 0.7);
      81             :                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
      82           0 :                     if( aDlg->Execute() == RET_OK )
      83           0 :                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
      84           0 :                     delete aDlg;
      85             :                 }
      86             :             }
      87           0 :             break;
      88             : 
      89             :             case( SID_GRFFILTER_SHARPEN ):
      90             :             {
      91           0 :                 if( pShell )
      92           0 :                     pShell->SetWaitCursor( true );
      93             : 
      94           0 :                 if( rGraphic.IsAnimated() )
      95             :                 {
      96           0 :                     Animation aAnimation( rGraphic.GetAnimation() );
      97             : 
      98           0 :                     if( aAnimation.Filter( BMP_FILTER_SHARPEN ) )
      99           0 :                         aGraphic = aAnimation;
     100             :                 }
     101             :                 else
     102             :                 {
     103           0 :                     BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     104             : 
     105           0 :                     if( aBmpEx.Filter( BMP_FILTER_SHARPEN ) )
     106           0 :                         aGraphic = aBmpEx;
     107             :                 }
     108             : 
     109           0 :                 if( pShell )
     110           0 :                     pShell->SetWaitCursor( false );
     111             :             }
     112           0 :             break;
     113             : 
     114             :             case( SID_GRFFILTER_REMOVENOISE ):
     115             :             {
     116           0 :                 if( pShell )
     117           0 :                     pShell->SetWaitCursor( true );
     118             : 
     119           0 :                 if( rGraphic.IsAnimated() )
     120             :                 {
     121           0 :                     Animation aAnimation( rGraphic.GetAnimation() );
     122             : 
     123           0 :                     if( aAnimation.Filter( BMP_FILTER_REMOVENOISE ) )
     124           0 :                         aGraphic = aAnimation;
     125             :                 }
     126             :                 else
     127             :                 {
     128           0 :                     BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     129             : 
     130           0 :                     if( aBmpEx.Filter( BMP_FILTER_REMOVENOISE ) )
     131           0 :                         aGraphic = aBmpEx;
     132             :                 }
     133             : 
     134           0 :                 if( pShell )
     135           0 :                     pShell->SetWaitCursor( false );
     136             :             }
     137           0 :             break;
     138             : 
     139             :             case( SID_GRFFILTER_SOBEL ):
     140             :             {
     141           0 :                 if( pShell )
     142           0 :                     pShell->SetWaitCursor( true );
     143             : 
     144           0 :                 if( rGraphic.IsAnimated() )
     145             :                 {
     146           0 :                     Animation aAnimation( rGraphic.GetAnimation() );
     147             : 
     148           0 :                     if( aAnimation.Filter( BMP_FILTER_SOBEL_GREY ) )
     149           0 :                         aGraphic = aAnimation;
     150             :                 }
     151             :                 else
     152             :                 {
     153           0 :                     BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     154             : 
     155           0 :                     if( aBmpEx.Filter( BMP_FILTER_SOBEL_GREY ) )
     156           0 :                         aGraphic = aBmpEx;
     157             :                 }
     158             : 
     159           0 :                 if( pShell )
     160           0 :                     pShell->SetWaitCursor( false );
     161             :             }
     162           0 :             break;
     163             : 
     164             :             case( SID_GRFFILTER_MOSAIC ):
     165             :             {
     166           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     167           0 :                 if(pFact)
     168             :                 {
     169           0 :                     AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterMosaic(pWindow, rGraphic, 4, 4, false);
     170             :                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
     171           0 :                     if( aDlg->Execute() == RET_OK )
     172           0 :                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
     173           0 :                     delete aDlg;
     174             :                 }
     175             :             }
     176           0 :             break;
     177             : 
     178             :             case( SID_GRFFILTER_EMBOSS  ):
     179             :             {
     180           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     181           0 :                 if(pFact)
     182             :                 {
     183           0 :                     AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterEmboss(pWindow, rGraphic, RP_MM);
     184             :                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
     185           0 :                     if( aDlg->Execute() == RET_OK )
     186           0 :                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
     187           0 :                     delete aDlg;
     188             :                 }
     189             :             }
     190           0 :             break;
     191             : 
     192             :             case( SID_GRFFILTER_POSTER  ):
     193             :             {
     194           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     195           0 :                 if(pFact)
     196             :                 {
     197           0 :                     AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterPoster(pWindow, rGraphic, 16);
     198             :                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
     199           0 :                     if( aDlg->Execute() == RET_OK )
     200           0 :                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
     201           0 :                     delete aDlg;
     202             :                 }
     203             :             }
     204           0 :             break;
     205             : 
     206             :             case( SID_GRFFILTER_POPART  ):
     207             :             {
     208           0 :                 if( pShell )
     209           0 :                     pShell->SetWaitCursor( true );
     210             : 
     211           0 :                 if( rGraphic.IsAnimated() )
     212             :                 {
     213           0 :                     Animation aAnimation( rGraphic.GetAnimation() );
     214             : 
     215           0 :                     if( aAnimation.Filter( BMP_FILTER_POPART ) )
     216           0 :                         aGraphic = aAnimation;
     217             :                 }
     218             :                 else
     219             :                 {
     220           0 :                     BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     221             : 
     222           0 :                     if( aBmpEx.Filter( BMP_FILTER_POPART ) )
     223           0 :                         aGraphic = aBmpEx;
     224             :                 }
     225             : 
     226           0 :                 if( pShell )
     227           0 :                     pShell->SetWaitCursor( false );
     228             :             }
     229           0 :             break;
     230             : 
     231             :             case( SID_GRFFILTER_SEPIA ):
     232             :             {
     233           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     234           0 :                 if(pFact)
     235             :                 {
     236           0 :                     AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSepia(pWindow, rGraphic, 10);
     237             :                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
     238           0 :                     if( aDlg->Execute() == RET_OK )
     239           0 :                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
     240           0 :                     delete aDlg;
     241             :                 }
     242             :             }
     243           0 :             break;
     244             : 
     245             :             case( SID_GRFFILTER_SOLARIZE ):
     246             :             {
     247           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     248           0 :                 if(pFact)
     249             :                 {
     250           0 :                     AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSolarize(pWindow, rGraphic, 128, false);
     251             :                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
     252           0 :                     if( aDlg->Execute() == RET_OK )
     253           0 :                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
     254           0 :                     delete aDlg;
     255             :                 }
     256             :             }
     257           0 :             break;
     258             : 
     259             :             case SID_GRFFILTER :
     260             :             {
     261             :                 // do nothing; no error
     262           0 :                 nRet = SVX_GRAPHICFILTER_ERRCODE_NONE;
     263           0 :                 break;
     264             :             }
     265             : 
     266             :             default:
     267             :             {
     268             :                 OSL_FAIL( "SvxGraphicFilter: selected filter slot not yet implemented" );
     269           0 :                 nRet = SVX_GRAPHICFILTER_UNSUPPORTED_SLOT;
     270             :             }
     271           0 :             break;
     272             :         }
     273             : 
     274           0 :         if( aGraphic.GetType() != GRAPHIC_NONE )
     275             :         {
     276           0 :             rFilterObject.SetGraphic( aGraphic );
     277           0 :             nRet = SVX_GRAPHICFILTER_ERRCODE_NONE;
     278           0 :         }
     279             :     }
     280             : 
     281           0 :     return nRet;
     282             : }
     283             : 
     284             : 
     285             : 
     286           0 : void SvxGraphicFilter::DisableGraphicFilterSlots( SfxItemSet& rSet )
     287             : {
     288           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER ) )
     289           0 :         rSet.DisableItem( SID_GRFFILTER );
     290             : 
     291           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_INVERT ) )
     292           0 :         rSet.DisableItem( SID_GRFFILTER_INVERT );
     293             : 
     294           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SMOOTH ) )
     295           0 :         rSet.DisableItem( SID_GRFFILTER_SMOOTH );
     296             : 
     297           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SHARPEN ) )
     298           0 :         rSet.DisableItem( SID_GRFFILTER_SHARPEN );
     299             : 
     300           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_REMOVENOISE ) )
     301           0 :         rSet.DisableItem( SID_GRFFILTER_REMOVENOISE );
     302             : 
     303           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SOBEL ) )
     304           0 :         rSet.DisableItem( SID_GRFFILTER_SOBEL );
     305             : 
     306           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_MOSAIC ) )
     307           0 :         rSet.DisableItem( SID_GRFFILTER_MOSAIC );
     308             : 
     309           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_EMBOSS ) )
     310           0 :         rSet.DisableItem( SID_GRFFILTER_EMBOSS );
     311             : 
     312           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_POSTER ) )
     313           0 :         rSet.DisableItem( SID_GRFFILTER_POSTER );
     314             : 
     315           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_POPART ) )
     316           0 :         rSet.DisableItem( SID_GRFFILTER_POPART );
     317             : 
     318           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SEPIA ) )
     319           0 :         rSet.DisableItem( SID_GRFFILTER_SEPIA );
     320             : 
     321           0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SOLARIZE ) )
     322           0 :         rSet.DisableItem( SID_GRFFILTER_SOLARIZE );
     323           0 : };
     324             : 
     325             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10