LCOV - code coverage report
Current view: top level - svx/source/dialog - grfflt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 146 0.0 %
Date: 2012-08-25 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 383 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <tools/shl.hxx>
      30                 :            : #include <vcl/msgbox.hxx>
      31                 :            : #include <sfx2/viewfrm.hxx>
      32                 :            : #include <sfx2/viewsh.hxx>
      33                 :            : #include <sfx2/objsh.hxx>
      34                 :            : #include <sfx2/request.hxx>
      35                 :            : 
      36                 :            : #include <svx/dialmgr.hxx>
      37                 :            : #include <svx/grfflt.hxx>
      38                 :            : #include <svx/dialogs.hrc>
      39                 :            : #include <svx/svxdlg.hxx>
      40                 :            : 
      41                 :            : // --------------------
      42                 :            : // - SvxGraphicFilter -
      43                 :            : // --------------------
      44                 :            : 
      45                 :          0 : sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObject& rFilterObject )
      46                 :            : {
      47                 :          0 :     const Graphic&  rGraphic = rFilterObject.GetGraphic();
      48                 :          0 :     sal_uIntPtr         nRet = SVX_GRAPHICFILTER_UNSUPPORTED_GRAPHICTYPE;
      49                 :            : 
      50         [ #  # ]:          0 :     if( rGraphic.GetType() == GRAPHIC_BITMAP )
      51                 :            :     {
      52         [ #  # ]:          0 :         SfxViewFrame*   pViewFrame = SfxViewFrame::Current();
      53 [ #  # ][ #  # ]:          0 :         SfxObjectShell* pShell = pViewFrame ? pViewFrame->GetObjectShell() : NULL;
      54 [ #  # ][ #  # ]:          0 :         Window*         pWindow = ( pViewFrame && pViewFrame->GetViewShell() ) ? pViewFrame->GetViewShell()->GetWindow() : NULL;
         [ #  # ][ #  # ]
      55         [ #  # ]:          0 :         Graphic         aGraphic;
      56                 :            : 
      57   [ #  #  #  #  :          0 :         switch( rReq.GetSlot() )
          #  #  #  #  #  
             #  #  #  # ]
      58                 :            :         {
      59                 :            :             case( SID_GRFFILTER_INVERT ):
      60                 :            :             {
      61         [ #  # ]:          0 :                 if( pShell )
      62         [ #  # ]:          0 :                     pShell->SetWaitCursor( sal_True );
      63                 :            : 
      64 [ #  # ][ #  # ]:          0 :                 if( rGraphic.IsAnimated() )
      65                 :            :                 {
      66         [ #  # ]:          0 :                     Animation aAnimation( rGraphic.GetAnimation() );
      67                 :            : 
      68 [ #  # ][ #  # ]:          0 :                     if( aAnimation.Invert() )
      69 [ #  # ][ #  # ]:          0 :                         aGraphic = aAnimation;
         [ #  # ][ #  # ]
      70                 :            :                 }
      71                 :            :                 else
      72                 :            :                 {
      73         [ #  # ]:          0 :                     BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
      74                 :            : 
      75 [ #  # ][ #  # ]:          0 :                     if( aBmpEx.Invert() )
      76 [ #  # ][ #  # ]:          0 :                         aGraphic = aBmpEx;
         [ #  # ][ #  # ]
      77                 :            :                 }
      78                 :            : 
      79         [ #  # ]:          0 :                 if( pShell )
      80         [ #  # ]:          0 :                     pShell->SetWaitCursor( sal_False );
      81                 :            :             }
      82                 :          0 :             break;
      83                 :            : 
      84                 :            :             case( SID_GRFFILTER_SMOOTH ):
      85                 :            :             {
      86         [ #  # ]:          0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
      87         [ #  # ]:          0 :                 if(pFact)
      88                 :            :                 {
      89         [ #  # ]:          0 :                     AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSmooth( pWindow, rGraphic, 0.7, RID_SVX_GRFFILTER_DLG_SEPIA);
      90                 :            :                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
      91 [ #  # ][ #  # ]:          0 :                     if( aDlg->Execute() == RET_OK )
      92 [ #  # ][ #  # ]:          0 :                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
                 [ #  # ]
      93 [ #  # ][ #  # ]:          0 :                     delete aDlg;
      94                 :            :                 }
      95                 :            :             }
      96                 :          0 :             break;
      97                 :            : 
      98                 :            :             case( SID_GRFFILTER_SHARPEN ):
      99                 :            :             {
     100         [ #  # ]:          0 :                 if( pShell )
     101         [ #  # ]:          0 :                     pShell->SetWaitCursor( sal_True );
     102                 :            : 
     103 [ #  # ][ #  # ]:          0 :                 if( rGraphic.IsAnimated() )
     104                 :            :                 {
     105         [ #  # ]:          0 :                     Animation aAnimation( rGraphic.GetAnimation() );
     106                 :            : 
     107 [ #  # ][ #  # ]:          0 :                     if( aAnimation.Filter( BMP_FILTER_SHARPEN ) )
     108 [ #  # ][ #  # ]:          0 :                         aGraphic = aAnimation;
         [ #  # ][ #  # ]
     109                 :            :                 }
     110                 :            :                 else
     111                 :            :                 {
     112         [ #  # ]:          0 :                     BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     113                 :            : 
     114 [ #  # ][ #  # ]:          0 :                     if( aBmpEx.Filter( BMP_FILTER_SHARPEN ) )
     115 [ #  # ][ #  # ]:          0 :                         aGraphic = aBmpEx;
         [ #  # ][ #  # ]
     116                 :            :                 }
     117                 :            : 
     118         [ #  # ]:          0 :                 if( pShell )
     119         [ #  # ]:          0 :                     pShell->SetWaitCursor( sal_False );
     120                 :            :             }
     121                 :          0 :             break;
     122                 :            : 
     123                 :            :             case( SID_GRFFILTER_REMOVENOISE ):
     124                 :            :             {
     125         [ #  # ]:          0 :                 if( pShell )
     126         [ #  # ]:          0 :                     pShell->SetWaitCursor( sal_True );
     127                 :            : 
     128 [ #  # ][ #  # ]:          0 :                 if( rGraphic.IsAnimated() )
     129                 :            :                 {
     130         [ #  # ]:          0 :                     Animation aAnimation( rGraphic.GetAnimation() );
     131                 :            : 
     132 [ #  # ][ #  # ]:          0 :                     if( aAnimation.Filter( BMP_FILTER_REMOVENOISE ) )
     133 [ #  # ][ #  # ]:          0 :                         aGraphic = aAnimation;
         [ #  # ][ #  # ]
     134                 :            :                 }
     135                 :            :                 else
     136                 :            :                 {
     137         [ #  # ]:          0 :                     BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     138                 :            : 
     139 [ #  # ][ #  # ]:          0 :                     if( aBmpEx.Filter( BMP_FILTER_REMOVENOISE ) )
     140 [ #  # ][ #  # ]:          0 :                         aGraphic = aBmpEx;
         [ #  # ][ #  # ]
     141                 :            :                 }
     142                 :            : 
     143         [ #  # ]:          0 :                 if( pShell )
     144         [ #  # ]:          0 :                     pShell->SetWaitCursor( sal_False );
     145                 :            :             }
     146                 :          0 :             break;
     147                 :            : 
     148                 :            :             case( SID_GRFFILTER_SOBEL ):
     149                 :            :             {
     150         [ #  # ]:          0 :                 if( pShell )
     151         [ #  # ]:          0 :                     pShell->SetWaitCursor( sal_True );
     152                 :            : 
     153 [ #  # ][ #  # ]:          0 :                 if( rGraphic.IsAnimated() )
     154                 :            :                 {
     155         [ #  # ]:          0 :                     Animation aAnimation( rGraphic.GetAnimation() );
     156                 :            : 
     157 [ #  # ][ #  # ]:          0 :                     if( aAnimation.Filter( BMP_FILTER_SOBEL_GREY ) )
     158 [ #  # ][ #  # ]:          0 :                         aGraphic = aAnimation;
         [ #  # ][ #  # ]
     159                 :            :                 }
     160                 :            :                 else
     161                 :            :                 {
     162         [ #  # ]:          0 :                     BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     163                 :            : 
     164 [ #  # ][ #  # ]:          0 :                     if( aBmpEx.Filter( BMP_FILTER_SOBEL_GREY ) )
     165 [ #  # ][ #  # ]:          0 :                         aGraphic = aBmpEx;
         [ #  # ][ #  # ]
     166                 :            :                 }
     167                 :            : 
     168         [ #  # ]:          0 :                 if( pShell )
     169         [ #  # ]:          0 :                     pShell->SetWaitCursor( sal_False );
     170                 :            :             }
     171                 :          0 :             break;
     172                 :            : 
     173                 :            :             case( SID_GRFFILTER_MOSAIC ):
     174                 :            :             {
     175         [ #  # ]:          0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     176         [ #  # ]:          0 :                 if(pFact)
     177                 :            :                 {
     178         [ #  # ]:          0 :                     AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterMosaic( pWindow, rGraphic, 4, 4, sal_False, RID_SVX_GRFFILTER_DLG_MOSAIC);
     179                 :            :                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
     180 [ #  # ][ #  # ]:          0 :                     if( aDlg->Execute() == RET_OK )
     181 [ #  # ][ #  # ]:          0 :                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
                 [ #  # ]
     182 [ #  # ][ #  # ]:          0 :                     delete aDlg;
     183                 :            :                 }
     184                 :            :             }
     185                 :          0 :             break;
     186                 :            : 
     187                 :            :             case( SID_GRFFILTER_EMBOSS  ):
     188                 :            :             {
     189         [ #  # ]:          0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     190         [ #  # ]:          0 :                 if(pFact)
     191                 :            :                 {
     192         [ #  # ]:          0 :                     AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterEmboss( pWindow, rGraphic, RP_MM, RID_SVX_GRFFILTER_DLG_EMBOSS );
     193                 :            :                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
     194 [ #  # ][ #  # ]:          0 :                     if( aDlg->Execute() == RET_OK )
     195 [ #  # ][ #  # ]:          0 :                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
                 [ #  # ]
     196 [ #  # ][ #  # ]:          0 :                     delete aDlg;
     197                 :            :                 }
     198                 :            :             }
     199                 :          0 :             break;
     200                 :            : 
     201                 :            :             case( SID_GRFFILTER_POSTER  ):
     202                 :            :             {
     203         [ #  # ]:          0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     204         [ #  # ]:          0 :                 if(pFact)
     205                 :            :                 {
     206         [ #  # ]:          0 :                     AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterPosterSepia( pWindow, rGraphic, 16, RID_SVX_GRFFILTER_DLG_POSTER );
     207                 :            :                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
     208 [ #  # ][ #  # ]:          0 :                     if( aDlg->Execute() == RET_OK )
     209 [ #  # ][ #  # ]:          0 :                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
                 [ #  # ]
     210 [ #  # ][ #  # ]:          0 :                     delete aDlg;
     211                 :            :                 }
     212                 :            :             }
     213                 :          0 :             break;
     214                 :            : 
     215                 :            :             case( SID_GRFFILTER_POPART  ):
     216                 :            :             {
     217         [ #  # ]:          0 :                 if( pShell )
     218         [ #  # ]:          0 :                     pShell->SetWaitCursor( sal_True );
     219                 :            : 
     220 [ #  # ][ #  # ]:          0 :                 if( rGraphic.IsAnimated() )
     221                 :            :                 {
     222         [ #  # ]:          0 :                     Animation aAnimation( rGraphic.GetAnimation() );
     223                 :            : 
     224 [ #  # ][ #  # ]:          0 :                     if( aAnimation.Filter( BMP_FILTER_POPART ) )
     225 [ #  # ][ #  # ]:          0 :                         aGraphic = aAnimation;
         [ #  # ][ #  # ]
     226                 :            :                 }
     227                 :            :                 else
     228                 :            :                 {
     229         [ #  # ]:          0 :                     BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     230                 :            : 
     231 [ #  # ][ #  # ]:          0 :                     if( aBmpEx.Filter( BMP_FILTER_POPART ) )
     232 [ #  # ][ #  # ]:          0 :                         aGraphic = aBmpEx;
         [ #  # ][ #  # ]
     233                 :            :                 }
     234                 :            : 
     235         [ #  # ]:          0 :                 if( pShell )
     236         [ #  # ]:          0 :                     pShell->SetWaitCursor( sal_False );
     237                 :            :             }
     238                 :          0 :             break;
     239                 :            : 
     240                 :            :             case( SID_GRFFILTER_SEPIA ):
     241                 :            :             {
     242         [ #  # ]:          0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     243         [ #  # ]:          0 :                 if(pFact)
     244                 :            :                 {
     245         [ #  # ]:          0 :                     AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterPosterSepia( pWindow, rGraphic, 10, RID_SVX_GRFFILTER_DLG_SEPIA );
     246                 :            :                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
     247 [ #  # ][ #  # ]:          0 :                     if( aDlg->Execute() == RET_OK )
     248 [ #  # ][ #  # ]:          0 :                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
                 [ #  # ]
     249 [ #  # ][ #  # ]:          0 :                     delete aDlg;
     250                 :            :                 }
     251                 :            :             }
     252                 :          0 :             break;
     253                 :            : 
     254                 :            :             case( SID_GRFFILTER_SOLARIZE ):
     255                 :            :             {
     256         [ #  # ]:          0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     257         [ #  # ]:          0 :                 if(pFact)
     258                 :            :                 {
     259         [ #  # ]:          0 :                     AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSolarize( pWindow, rGraphic, 128, sal_False, RID_SVX_GRFFILTER_DLG_SOLARIZE );
     260                 :            :                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
     261 [ #  # ][ #  # ]:          0 :                     if( aDlg->Execute() == RET_OK )
     262 [ #  # ][ #  # ]:          0 :                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
                 [ #  # ]
     263 [ #  # ][ #  # ]:          0 :                     delete aDlg;
     264                 :            :                 }
     265                 :            :             }
     266                 :          0 :             break;
     267                 :            : 
     268                 :            :             case SID_GRFFILTER :
     269                 :            :             {
     270                 :            :                 // do nothing; no error
     271                 :          0 :                 nRet = SVX_GRAPHICFILTER_ERRCODE_NONE;
     272                 :          0 :                 break;
     273                 :            :             }
     274                 :            : 
     275                 :            :             default:
     276                 :            :             {
     277                 :            :                 OSL_FAIL( "SvxGraphicFilter: selected filter slot not yet implemented" );
     278                 :          0 :                 nRet = SVX_GRAPHICFILTER_UNSUPPORTED_SLOT;
     279                 :            :             }
     280                 :          0 :             break;
     281                 :            :         }
     282                 :            : 
     283 [ #  # ][ #  # ]:          0 :         if( aGraphic.GetType() != GRAPHIC_NONE )
     284                 :            :         {
     285         [ #  # ]:          0 :             rFilterObject.SetGraphic( aGraphic );
     286                 :          0 :             nRet = SVX_GRAPHICFILTER_ERRCODE_NONE;
     287         [ #  # ]:          0 :         }
     288                 :            :     }
     289                 :            : 
     290                 :          0 :     return nRet;
     291                 :            : }
     292                 :            : 
     293                 :            : // -----------------------------------------------------------------------------
     294                 :            : 
     295                 :          0 : void SvxGraphicFilter::DisableGraphicFilterSlots( SfxItemSet& rSet )
     296                 :            : {
     297         [ #  # ]:          0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER ) )
     298                 :          0 :         rSet.DisableItem( SID_GRFFILTER );
     299                 :            : 
     300         [ #  # ]:          0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_INVERT ) )
     301                 :          0 :         rSet.DisableItem( SID_GRFFILTER_INVERT );
     302                 :            : 
     303         [ #  # ]:          0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SMOOTH ) )
     304                 :          0 :         rSet.DisableItem( SID_GRFFILTER_SMOOTH );
     305                 :            : 
     306         [ #  # ]:          0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SHARPEN ) )
     307                 :          0 :         rSet.DisableItem( SID_GRFFILTER_SHARPEN );
     308                 :            : 
     309         [ #  # ]:          0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_REMOVENOISE ) )
     310                 :          0 :         rSet.DisableItem( SID_GRFFILTER_REMOVENOISE );
     311                 :            : 
     312         [ #  # ]:          0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SOBEL ) )
     313                 :          0 :         rSet.DisableItem( SID_GRFFILTER_SOBEL );
     314                 :            : 
     315         [ #  # ]:          0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_MOSAIC ) )
     316                 :          0 :         rSet.DisableItem( SID_GRFFILTER_MOSAIC );
     317                 :            : 
     318         [ #  # ]:          0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_EMBOSS ) )
     319                 :          0 :         rSet.DisableItem( SID_GRFFILTER_EMBOSS );
     320                 :            : 
     321         [ #  # ]:          0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_POSTER ) )
     322                 :          0 :         rSet.DisableItem( SID_GRFFILTER_POSTER );
     323                 :            : 
     324         [ #  # ]:          0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_POPART ) )
     325                 :          0 :         rSet.DisableItem( SID_GRFFILTER_POPART );
     326                 :            : 
     327         [ #  # ]:          0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SEPIA ) )
     328                 :          0 :         rSet.DisableItem( SID_GRFFILTER_SEPIA );
     329                 :            : 
     330         [ #  # ]:          0 :     if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SOLARIZE ) )
     331                 :          0 :         rSet.DisableItem( SID_GRFFILTER_SOLARIZE );
     332                 :          0 : };
     333                 :            : 
     334                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10