LCOV - code coverage report
Current view: top level - cui/source/dialogs - cuigrfflt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 246 0.0 %
Date: 2012-08-25 Functions: 0 37 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 561 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                 :            : #include <dialmgr.hxx>
      36                 :            : #include "cuigrfflt.hxx"
      37                 :            : #include "grfflt.hrc"
      38                 :            : #include <cuires.hrc>
      39                 :            : #include <svx/dialogs.hrc> // RID_SVX_GRFFILTER_DLG_...
      40                 :            : 
      41                 :            : // --------------------------------------
      42                 :            : // - GraphicFilterDialog::PreviewWindow -
      43                 :            : // --------------------------------------
      44                 :            : 
      45                 :          0 : GraphicFilterDialog::PreviewWindow::PreviewWindow( Window* pParent, const ResId& rResId ) :
      46         [ #  # ]:          0 :     Control( pParent, rResId )
      47                 :            : {
      48                 :          0 : }
      49                 :            : 
      50                 :            : // -----------------------------------------------------------------------------
      51                 :            : 
      52         [ #  # ]:          0 : GraphicFilterDialog::PreviewWindow::~PreviewWindow()
      53                 :            : {
      54         [ #  # ]:          0 : }
      55                 :            : 
      56                 :            : // -----------------------------------------------------------------------------
      57                 :            : 
      58                 :          0 : void GraphicFilterDialog::PreviewWindow::Paint( const Rectangle& rRect )
      59                 :            : {
      60         [ #  # ]:          0 :     Control::Paint( rRect );
      61                 :            : 
      62                 :          0 :     const Size  aOutputSize( GetOutputSizePixel() );
      63                 :            : 
      64 [ #  # ][ #  # ]:          0 :     if( maGraphic.IsAnimated() )
      65                 :            :     {
      66 [ #  # ][ #  # ]:          0 :         const Size  aGraphicSize( LogicToPixel( maGraphic.GetPrefSize(), maGraphic.GetPrefMapMode() ) );
         [ #  # ][ #  # ]
      67                 :          0 :         const Point aGraphicPosition( ( aOutputSize.Width()  - aGraphicSize.Width()  ) >> 1,
      68                 :          0 :                                       ( aOutputSize.Height() - aGraphicSize.Height() ) >> 1 );
      69         [ #  # ]:          0 :         maGraphic.StartAnimation( this, aGraphicPosition, aGraphicSize );
      70                 :            :     }
      71                 :            :     else
      72                 :            :     {
      73         [ #  # ]:          0 :         const Size  aGraphicSize( maGraphic.GetSizePixel() );
      74                 :          0 :         const Point aGraphicPosition( ( aOutputSize.Width()  - aGraphicSize.Width()  ) >> 1,
      75                 :          0 :                                       ( aOutputSize.Height() - aGraphicSize.Height() ) >> 1 );
      76         [ #  # ]:          0 :         maGraphic.Draw( this, aGraphicPosition, aGraphicSize );
      77                 :            :     }
      78                 :          0 : }
      79                 :            : 
      80                 :            : // -----------------------------------------------------------------------------
      81                 :            : 
      82                 :          0 : void GraphicFilterDialog::PreviewWindow::SetGraphic( const Graphic& rGraphic )
      83                 :            : {
      84                 :          0 :     maGraphic = rGraphic;
      85                 :            : 
      86 [ #  # ][ #  # ]:          0 :     if( maGraphic.IsAnimated() || maGraphic.IsTransparent() )
                 [ #  # ]
      87                 :          0 :         Invalidate();
      88                 :            :     else
      89 [ #  # ][ #  # ]:          0 :         Paint( Rectangle( Point(), GetOutputSizePixel() ) );
      90                 :          0 : }
      91                 :            : 
      92                 :            : // -----------------------
      93                 :            : // - GraphicFilterDialog -
      94                 :            : // -----------------------
      95                 :            : 
      96                 :          0 : GraphicFilterDialog::GraphicFilterDialog( Window* pParent, const ResId& rResId, const Graphic& rGraphic ) :
      97                 :            :     ModalDialog     ( pParent, rResId ),
      98                 :            :     maModifyHdl     ( LINK( this, GraphicFilterDialog, ImplModifyHdl ) ),
      99                 :            :     mfScaleX        ( 0.0 ),
     100                 :            :     mfScaleY        ( 0.0 ),
     101 [ #  # ][ #  # ]:          0 :     maSizePixel     ( LogicToPixel( rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode() ) ),
                 [ #  # ]
     102         [ #  # ]:          0 :     maPreview       ( this, CUI_RES( CTL_PREVIEW ) ),
     103         [ #  # ]:          0 :     maBtnOK         ( this, CUI_RES( BTN_OK ) ),
     104         [ #  # ]:          0 :     maBtnCancel     ( this, CUI_RES( BTN_CANCEL ) ),
     105         [ #  # ]:          0 :     maBtnHelp       ( this, CUI_RES( BTN_HELP ) ),
     106 [ #  # ][ #  # ]:          0 :     maFlParameter   ( this, CUI_RES( FL_PARAMETER ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     107                 :            : {
     108                 :          0 :     const Size  aPreviewSize( maPreview.GetOutputSizePixel() );
     109                 :          0 :     Size        aGrfSize( maSizePixel );
     110                 :            : 
     111   [ #  #  #  #  :          0 :     if( rGraphic.GetType() == GRAPHIC_BITMAP &&
          #  #  #  #  #  
              # ][ #  # ]
                 [ #  # ]
     112                 :          0 :         aPreviewSize.Width() && aPreviewSize.Height() &&
     113                 :          0 :         aGrfSize.Width() && aGrfSize.Height() )
     114                 :            :     {
     115                 :          0 :         const double fGrfWH = (double) aGrfSize.Width() / aGrfSize.Height();
     116                 :          0 :         const double fPreWH = (double) aPreviewSize.Width() / aPreviewSize.Height();
     117                 :            : 
     118         [ #  # ]:          0 :         if( fGrfWH < fPreWH )
     119                 :            :         {
     120                 :          0 :             aGrfSize.Width()  = (long) ( aPreviewSize.Height() * fGrfWH );
     121                 :          0 :             aGrfSize.Height() = aPreviewSize.Height();
     122                 :            :         }
     123                 :            :         else
     124                 :            :         {
     125                 :          0 :             aGrfSize.Width()  = aPreviewSize.Width();
     126                 :          0 :             aGrfSize.Height() = (long) ( aPreviewSize.Width() / fGrfWH );
     127                 :            :         }
     128                 :            : 
     129                 :          0 :         mfScaleX = (double) aGrfSize.Width() / maSizePixel.Width();
     130                 :          0 :         mfScaleY = (double) aGrfSize.Height() / maSizePixel.Height();
     131                 :            : 
     132 [ #  # ][ #  # ]:          0 :         if( !rGraphic.IsAnimated() )
     133                 :            :         {
     134         [ #  # ]:          0 :             BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     135                 :            : 
     136 [ #  # ][ #  # ]:          0 :             if( aBmpEx.Scale( aGrfSize, BMP_SCALE_DEFAULT ) )
     137 [ #  # ][ #  # ]:          0 :                 maGraphic = aBmpEx;
         [ #  # ][ #  # ]
     138                 :            :         }
     139                 :            :     }
     140                 :            : 
     141         [ #  # ]:          0 :     maTimer.SetTimeoutHdl( LINK( this, GraphicFilterDialog, ImplPreviewTimeoutHdl ) );
     142         [ #  # ]:          0 :     maTimer.SetTimeout( 100 );
     143         [ #  # ]:          0 :     ImplModifyHdl( NULL );
     144                 :          0 : }
     145                 :            : 
     146                 :            : // -----------------------------------------------------------------------------
     147                 :            : 
     148 [ #  # ][ #  # ]:          0 : GraphicFilterDialog::~GraphicFilterDialog()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     149                 :            : {
     150         [ #  # ]:          0 : }
     151                 :            : 
     152                 :            : // -----------------------------------------------------------------------------
     153                 :            : 
     154                 :          0 : IMPL_LINK_NOARG(GraphicFilterDialog, ImplPreviewTimeoutHdl)
     155                 :            : {
     156                 :          0 :     maTimer.Stop();
     157         [ #  # ]:          0 :     maPreview.SetGraphic( GetFilteredGraphic( maGraphic, mfScaleX, mfScaleY ) );
     158                 :            : 
     159                 :          0 :     return 0;
     160                 :            : }
     161                 :            : 
     162                 :            : // -----------------------------------------------------------------------------
     163                 :            : 
     164                 :          0 : IMPL_LINK_NOARG(GraphicFilterDialog, ImplModifyHdl)
     165                 :            : {
     166         [ #  # ]:          0 :     if( maGraphic.GetType() == GRAPHIC_BITMAP )
     167                 :            :     {
     168                 :          0 :         maTimer.Stop();
     169                 :          0 :         maTimer.Start();
     170                 :            :     }
     171                 :            : 
     172                 :          0 :     return 0;
     173                 :            : }
     174                 :            : 
     175                 :            : // ----------------
     176                 :            : // - FilterMosaic -
     177                 :            : // ----------------
     178                 :            : 
     179                 :          0 : GraphicFilterMosaic::GraphicFilterMosaic( Window* pParent, const Graphic& rGraphic,
     180                 :            :                                           sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, sal_Bool bEnhanceEdges ) :
     181                 :          0 :     GraphicFilterDialog( pParent, CUI_RES( RID_SVX_GRFFILTER_DLG_MOSAIC ), rGraphic ),
     182         [ #  # ]:          0 :     maFtWidth   ( this, CUI_RES( DLG_FILTERMOSAIC_FT_WIDTH ) ),
     183         [ #  # ]:          0 :     maMtrWidth  ( this, CUI_RES( DLG_FILTERMOSAIC_MTR_WIDTH ) ),
     184         [ #  # ]:          0 :     maFtHeight  ( this, CUI_RES( DLG_FILTERMOSAIC_FT_HEIGHT ) ),
     185         [ #  # ]:          0 :     maMtrHeight ( this, CUI_RES( DLG_FILTERMOSAIC_MTR_HEIGHT ) ),
     186 [ #  # ][ #  # ]:          0 :     maCbxEdges  ( this, CUI_RES( DLG_FILTERMOSAIC_CBX_EDGES ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     187                 :            : {
     188         [ #  # ]:          0 :     FreeResource();
     189                 :            : 
     190         [ #  # ]:          0 :     maMtrWidth.SetValue( nTileWidth );
     191         [ #  # ]:          0 :     maMtrWidth.SetLast( GetGraphicSizePixel().Width() );
     192                 :          0 :     maMtrWidth.SetModifyHdl( GetModifyHdl() );
     193                 :            : 
     194         [ #  # ]:          0 :     maMtrHeight.SetValue( nTileHeight );
     195         [ #  # ]:          0 :     maMtrHeight.SetLast( GetGraphicSizePixel().Height() );
     196                 :          0 :     maMtrHeight.SetModifyHdl( GetModifyHdl() );
     197                 :            : 
     198         [ #  # ]:          0 :     maCbxEdges.Check( bEnhanceEdges );
     199                 :          0 :     maCbxEdges.SetToggleHdl( GetModifyHdl() );
     200                 :            : 
     201         [ #  # ]:          0 :     maMtrWidth.GrabFocus();
     202                 :            : 
     203         [ #  # ]:          0 :     maFtWidth.SetAccessibleRelationMemberOf(&maFlParameter);
     204         [ #  # ]:          0 :     maMtrWidth.SetAccessibleRelationMemberOf(&maFlParameter);
     205         [ #  # ]:          0 :     maFtHeight.SetAccessibleRelationMemberOf(&maFlParameter);
     206         [ #  # ]:          0 :     maMtrHeight.SetAccessibleRelationMemberOf(&maFlParameter);
     207         [ #  # ]:          0 :     maCbxEdges.SetAccessibleRelationMemberOf(&maFlParameter);
     208                 :          0 : }
     209                 :            : 
     210                 :            : // -----------------------------------------------------------------------------
     211                 :            : 
     212 [ #  # ][ #  # ]:          0 : GraphicFilterMosaic::~GraphicFilterMosaic()
         [ #  # ][ #  # ]
                 [ #  # ]
     213                 :            : {
     214         [ #  # ]:          0 : }
     215                 :            : 
     216                 :            : // -----------------------------------------------------------------------------
     217                 :            : 
     218                 :          0 : Graphic GraphicFilterMosaic::GetFilteredGraphic( const Graphic& rGraphic,
     219                 :            :                                                  double fScaleX, double fScaleY )
     220                 :            : {
     221         [ #  # ]:          0 :     Graphic         aRet;
     222         [ #  # ]:          0 :     const Size      aSize( Max( FRound( GetTileWidth() * fScaleX ), 1L ),
     223         [ #  # ]:          0 :                            Max( FRound( GetTileHeight() * fScaleY ), 1L ) );
     224                 :          0 :     BmpFilterParam  aParam( aSize );
     225                 :            : 
     226 [ #  # ][ #  # ]:          0 :     if( rGraphic.IsAnimated() )
     227                 :            :     {
     228         [ #  # ]:          0 :         Animation aAnim( rGraphic.GetAnimation() );
     229                 :            : 
     230 [ #  # ][ #  # ]:          0 :         if( aAnim.Filter( BMP_FILTER_MOSAIC, &aParam ) )
     231                 :            :         {
     232 [ #  # ][ #  # ]:          0 :             if( IsEnhanceEdges() )
     233         [ #  # ]:          0 :                 aAnim.Filter( BMP_FILTER_SHARPEN );
     234                 :            : 
     235 [ #  # ][ #  # ]:          0 :             aRet = aAnim;
                 [ #  # ]
     236         [ #  # ]:          0 :         }
     237                 :            :     }
     238                 :            :     else
     239                 :            :     {
     240         [ #  # ]:          0 :         BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     241                 :            : 
     242 [ #  # ][ #  # ]:          0 :         if( aBmpEx.Filter( BMP_FILTER_MOSAIC, &aParam ) )
     243                 :            :         {
     244 [ #  # ][ #  # ]:          0 :             if( IsEnhanceEdges() )
     245         [ #  # ]:          0 :                 aBmpEx.Filter( BMP_FILTER_SHARPEN );
     246                 :            : 
     247 [ #  # ][ #  # ]:          0 :             aRet = aBmpEx;
                 [ #  # ]
     248         [ #  # ]:          0 :         }
     249                 :            :     }
     250                 :            : 
     251                 :          0 :     return aRet;
     252                 :            : }
     253                 :            : 
     254                 :            : // ------------------
     255                 :            : // - GraphicFilterSmooth -
     256                 :            : // ------------------
     257                 :            : 
     258                 :          0 : GraphicFilterSmooth::GraphicFilterSmooth( Window* pParent, const Graphic& rGraphic, double nRadius) :
     259                 :          0 :     GraphicFilterDialog ( pParent, CUI_RES( RID_SVX_GRFFILTER_DLG_SMOOTH ), rGraphic ),
     260         [ #  # ]:          0 :     maFtRadius   ( this, CUI_RES( DLG_FILTERSMOOTH_FT_RADIUS ) ),
     261 [ #  # ][ #  # ]:          0 :     maMtrRadius  ( this, CUI_RES( DLG_FILTERSMOOTH_MTR_RADIUS ) )
         [ #  # ][ #  # ]
     262                 :            : {
     263         [ #  # ]:          0 :     FreeResource();
     264                 :            : 
     265         [ #  # ]:          0 :     maMtrRadius.SetValue( nRadius* 10  );
     266                 :          0 :     maMtrRadius.SetModifyHdl( GetModifyHdl() );
     267         [ #  # ]:          0 :     maMtrRadius.GrabFocus();
     268                 :          0 : }
     269                 :            : 
     270                 :            : // -----------------------------------------------------------------------------
     271                 :            : 
     272 [ #  # ][ #  # ]:          0 : GraphicFilterSmooth::~GraphicFilterSmooth()
     273                 :            : {
     274         [ #  # ]:          0 : }
     275                 :            : 
     276                 :            : // -----------------------------------------------------------------------------
     277                 :            : 
     278                 :          0 : Graphic GraphicFilterSmooth::GetFilteredGraphic( const Graphic& rGraphic, double /*fScaleX*/, double /*fScaleY*/ )
     279                 :            : {
     280         [ #  # ]:          0 :     Graphic         aRet;
     281         [ #  # ]:          0 :     BmpFilterParam  aParam( GetRadius() );
     282                 :            : 
     283 [ #  # ][ #  # ]:          0 :     if( rGraphic.IsAnimated() )
     284                 :            :     {
     285         [ #  # ]:          0 :         Animation aAnim( rGraphic.GetAnimation() );
     286                 :            : 
     287 [ #  # ][ #  # ]:          0 :         if( aAnim.Filter( BMP_FILTER_SMOOTH, &aParam ) )
     288                 :            :         {
     289 [ #  # ][ #  # ]:          0 :             aRet = aAnim;
                 [ #  # ]
     290         [ #  # ]:          0 :         }
     291                 :            :     }
     292                 :            :     else
     293                 :            :     {
     294         [ #  # ]:          0 :         BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     295                 :            : 
     296 [ #  # ][ #  # ]:          0 :         if( aBmpEx.Filter( BMP_FILTER_SMOOTH, &aParam ) )
     297                 :            :         {
     298 [ #  # ][ #  # ]:          0 :             aRet = aBmpEx;
                 [ #  # ]
     299         [ #  # ]:          0 :         }
     300                 :            :     }
     301                 :            : 
     302                 :          0 :     return aRet;
     303                 :            : }
     304                 :            : 
     305                 :            : // ------------------
     306                 :            : // - GraphicFilterSolarize -
     307                 :            : // ------------------
     308                 :            : 
     309                 :          0 : GraphicFilterSolarize::GraphicFilterSolarize( Window* pParent, const Graphic& rGraphic,
     310                 :            :                                               sal_uInt8 cGreyThreshold, sal_Bool bInvert ) :
     311                 :          0 :     GraphicFilterDialog ( pParent, CUI_RES( RID_SVX_GRFFILTER_DLG_SOLARIZE ), rGraphic ),
     312         [ #  # ]:          0 :     maFtThreshold   ( this, CUI_RES( DLG_FILTERSOLARIZE_FT_THRESHOLD ) ),
     313         [ #  # ]:          0 :     maMtrThreshold  ( this, CUI_RES( DLG_FILTERSOLARIZE_MTR_THRESHOLD ) ),
     314 [ #  # ][ #  # ]:          0 :     maCbxInvert     ( this, CUI_RES( DLG_FILTERSOLARIZE_CBX_INVERT ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     315                 :            : {
     316         [ #  # ]:          0 :     FreeResource();
     317                 :            : 
     318         [ #  # ]:          0 :     maMtrThreshold.SetValue( FRound( cGreyThreshold / 2.55 ) );
     319                 :          0 :     maMtrThreshold.SetModifyHdl( GetModifyHdl() );
     320                 :            : 
     321         [ #  # ]:          0 :     maCbxInvert.Check( bInvert );
     322                 :          0 :     maCbxInvert.SetToggleHdl( GetModifyHdl() );
     323                 :            : 
     324         [ #  # ]:          0 :     maMtrThreshold.GrabFocus();
     325                 :          0 : }
     326                 :            : 
     327                 :            : // -----------------------------------------------------------------------------
     328                 :            : 
     329 [ #  # ][ #  # ]:          0 : GraphicFilterSolarize::~GraphicFilterSolarize()
                 [ #  # ]
     330                 :            : {
     331         [ #  # ]:          0 : }
     332                 :            : 
     333                 :            : // -----------------------------------------------------------------------------
     334                 :            : 
     335                 :          0 : Graphic GraphicFilterSolarize::GetFilteredGraphic( const Graphic& rGraphic,
     336                 :            :                                                    double /*fScaleX*/, double /*fScaleY*/ )
     337                 :            : {
     338         [ #  # ]:          0 :     Graphic         aRet;
     339         [ #  # ]:          0 :     BmpFilterParam  aParam( GetGreyThreshold() );
     340                 :            : 
     341 [ #  # ][ #  # ]:          0 :     if( rGraphic.IsAnimated() )
     342                 :            :     {
     343         [ #  # ]:          0 :         Animation aAnim( rGraphic.GetAnimation() );
     344                 :            : 
     345 [ #  # ][ #  # ]:          0 :         if( aAnim.Filter( BMP_FILTER_SOLARIZE, &aParam ) )
     346                 :            :         {
     347 [ #  # ][ #  # ]:          0 :             if( IsInvert() )
     348         [ #  # ]:          0 :                 aAnim.Invert();
     349                 :            : 
     350 [ #  # ][ #  # ]:          0 :             aRet = aAnim;
                 [ #  # ]
     351         [ #  # ]:          0 :         }
     352                 :            :     }
     353                 :            :     else
     354                 :            :     {
     355         [ #  # ]:          0 :         BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     356                 :            : 
     357 [ #  # ][ #  # ]:          0 :         if( aBmpEx.Filter( BMP_FILTER_SOLARIZE, &aParam ) )
     358                 :            :         {
     359 [ #  # ][ #  # ]:          0 :             if( IsInvert() )
     360         [ #  # ]:          0 :                 aBmpEx.Invert();
     361                 :            : 
     362 [ #  # ][ #  # ]:          0 :             aRet = aBmpEx;
                 [ #  # ]
     363         [ #  # ]:          0 :         }
     364                 :            :     }
     365                 :            : 
     366                 :          0 :     return aRet;
     367                 :            : }
     368                 :            : 
     369                 :            : // ----------------------
     370                 :            : // - GraphicFilterSepia -
     371                 :            : // ----------------------
     372                 :            : 
     373                 :          0 : GraphicFilterSepia::GraphicFilterSepia( Window* pParent, const Graphic& rGraphic,
     374                 :            :                                         sal_uInt16 nSepiaPercent ) :
     375                 :          0 :     GraphicFilterDialog ( pParent, CUI_RES( RID_SVX_GRFFILTER_DLG_SEPIA ), rGraphic ),
     376         [ #  # ]:          0 :     maFtSepia       ( this, CUI_RES( DLG_FILTERSEPIA_FT_SEPIA ) ),
     377 [ #  # ][ #  # ]:          0 :     maMtrSepia      ( this, CUI_RES( DLG_FILTERSEPIA_MTR_SEPIA ) )
         [ #  # ][ #  # ]
     378                 :            : {
     379         [ #  # ]:          0 :     FreeResource();
     380                 :            : 
     381         [ #  # ]:          0 :     maMtrSepia.SetValue( nSepiaPercent );
     382                 :          0 :     maMtrSepia.SetModifyHdl( GetModifyHdl() );
     383                 :            : 
     384         [ #  # ]:          0 :     maMtrSepia.GrabFocus();
     385                 :          0 : }
     386                 :            : 
     387                 :            : // -----------------------------------------------------------------------------
     388                 :            : 
     389 [ #  # ][ #  # ]:          0 : GraphicFilterSepia::~GraphicFilterSepia()
     390                 :            : {
     391         [ #  # ]:          0 : }
     392                 :            : 
     393                 :            : // -----------------------------------------------------------------------------
     394                 :            : 
     395                 :          0 : Graphic GraphicFilterSepia::GetFilteredGraphic( const Graphic& rGraphic,
     396                 :            :                                                 double /*fScaleX*/, double /*fScaleY*/ )
     397                 :            : {
     398         [ #  # ]:          0 :     Graphic         aRet;
     399         [ #  # ]:          0 :     BmpFilterParam  aParam( GetSepiaPercent() );
     400                 :            : 
     401 [ #  # ][ #  # ]:          0 :     if( rGraphic.IsAnimated() )
     402                 :            :     {
     403         [ #  # ]:          0 :         Animation aAnim( rGraphic.GetAnimation() );
     404                 :            : 
     405 [ #  # ][ #  # ]:          0 :         if( aAnim.Filter( BMP_FILTER_SEPIA, &aParam ) )
     406 [ #  # ][ #  # ]:          0 :             aRet = aAnim;
         [ #  # ][ #  # ]
     407                 :            :     }
     408                 :            :     else
     409                 :            :     {
     410         [ #  # ]:          0 :         BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     411                 :            : 
     412 [ #  # ][ #  # ]:          0 :         if( aBmpEx.Filter( BMP_FILTER_SEPIA, &aParam ) )
     413 [ #  # ][ #  # ]:          0 :             aRet = aBmpEx;
         [ #  # ][ #  # ]
     414                 :            :     }
     415                 :            : 
     416                 :          0 :     return aRet;
     417                 :            : }
     418                 :            : 
     419                 :            : // -----------------------
     420                 :            : // - GraphicFilterPoster -
     421                 :            : // -----------------------
     422                 :            : 
     423                 :          0 : GraphicFilterPoster::GraphicFilterPoster( Window* pParent, const Graphic& rGraphic,
     424                 :            :                                           sal_uInt16 nPosterCount ) :
     425                 :          0 :     GraphicFilterDialog ( pParent, CUI_RES( RID_SVX_GRFFILTER_DLG_POSTER ), rGraphic ),
     426         [ #  # ]:          0 :     maFtPoster      ( this, CUI_RES( DLG_FILTERPOSTER_FT_POSTER ) ),
     427 [ #  # ][ #  # ]:          0 :     maNumPoster     ( this, CUI_RES( DLG_FILTERPOSTER_NUM_POSTER ) )
         [ #  # ][ #  # ]
     428                 :            : {
     429         [ #  # ]:          0 :     FreeResource();
     430                 :            : 
     431                 :          0 :     maNumPoster.SetFirst( 2 );
     432 [ #  # ][ #  # ]:          0 :     maNumPoster.SetLast( rGraphic.GetBitmapEx().GetBitCount() );
                 [ #  # ]
     433         [ #  # ]:          0 :     maNumPoster.SetValue( nPosterCount );
     434                 :          0 :     maNumPoster.SetModifyHdl( GetModifyHdl() );
     435         [ #  # ]:          0 :     maNumPoster.GrabFocus();
     436                 :          0 : }
     437                 :            : 
     438                 :            : // -----------------------------------------------------------------------------
     439                 :            : 
     440 [ #  # ][ #  # ]:          0 : GraphicFilterPoster::~GraphicFilterPoster()
     441                 :            : {
     442         [ #  # ]:          0 : }
     443                 :            : 
     444                 :            : // -----------------------------------------------------------------------------
     445                 :            : 
     446                 :          0 : Graphic GraphicFilterPoster::GetFilteredGraphic( const Graphic& rGraphic,
     447                 :            :                                                  double /*fScaleX*/, double /*fScaleY*/ )
     448                 :            : {
     449                 :          0 :     Graphic         aRet;
     450         [ #  # ]:          0 :     const sal_uInt16    nPosterCount = GetPosterColorCount();
     451                 :            : 
     452 [ #  # ][ #  # ]:          0 :     if( rGraphic.IsAnimated() )
     453                 :            :     {
     454         [ #  # ]:          0 :         Animation aAnim( rGraphic.GetAnimation() );
     455                 :            : 
     456 [ #  # ][ #  # ]:          0 :         if( aAnim.ReduceColors( nPosterCount, BMP_REDUCE_POPULAR ) )
     457 [ #  # ][ #  # ]:          0 :             aRet = aAnim;
         [ #  # ][ #  # ]
     458                 :            :     }
     459                 :            :     else
     460                 :            :     {
     461         [ #  # ]:          0 :         BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     462                 :            : 
     463 [ #  # ][ #  # ]:          0 :         if( aBmpEx.ReduceColors( nPosterCount, BMP_REDUCE_POPULAR ) )
     464 [ #  # ][ #  # ]:          0 :             aRet = aBmpEx;
         [ #  # ][ #  # ]
     465                 :            :     }
     466                 :            : 
     467                 :          0 :     return aRet;
     468                 :            : }
     469                 :            : 
     470                 :            : // -----------------------
     471                 :            : // - GraphicFilterEmboss -
     472                 :            : // -----------------------
     473                 :            : 
     474                 :          0 : void GraphicFilterEmboss::EmbossControl::MouseButtonDown( const MouseEvent& rEvt )
     475                 :            : {
     476                 :          0 :     const RECT_POINT eOldRP = GetActualRP();
     477                 :            : 
     478                 :          0 :     SvxRectCtl::MouseButtonDown( rEvt );
     479                 :            : 
     480         [ #  # ]:          0 :     if( GetActualRP() != eOldRP )
     481                 :          0 :         maModifyHdl.Call( this );
     482                 :          0 : }
     483                 :            : 
     484                 :            : // -----------------------------------------------------------------------------
     485                 :            : 
     486                 :          0 : GraphicFilterEmboss::GraphicFilterEmboss( Window* pParent, const Graphic& rGraphic,
     487                 :            :                                           RECT_POINT eLightSource ) :
     488                 :          0 :     GraphicFilterDialog ( pParent, CUI_RES( RID_SVX_GRFFILTER_DLG_EMBOSS ), rGraphic ),
     489         [ #  # ]:          0 :     maFtLight       ( this, CUI_RES( DLG_FILTEREMBOSS_FT_LIGHT ) ),
     490 [ #  # ][ #  # ]:          0 :     maCtlLight      ( this, CUI_RES( DLG_FILTEREMBOSS_CTL_LIGHT ), eLightSource )
         [ #  # ][ #  # ]
     491                 :            : {
     492         [ #  # ]:          0 :     FreeResource();
     493                 :            : 
     494                 :          0 :     maCtlLight.SetModifyHdl( GetModifyHdl() );
     495         [ #  # ]:          0 :     maCtlLight.GrabFocus();
     496                 :          0 : }
     497                 :            : 
     498                 :            : // -----------------------------------------------------------------------------
     499                 :            : 
     500 [ #  # ][ #  # ]:          0 : GraphicFilterEmboss::~GraphicFilterEmboss()
     501                 :            : {
     502         [ #  # ]:          0 : }
     503                 :            : 
     504                 :            : // -----------------------------------------------------------------------------
     505                 :            : 
     506                 :          0 : Graphic GraphicFilterEmboss::GetFilteredGraphic( const Graphic& rGraphic,
     507                 :            :                                                  double /*fScaleX*/, double /*fScaleY*/ )
     508                 :            : {
     509         [ #  # ]:          0 :     Graphic aRet;
     510                 :            :     sal_uInt16  nAzim, nElev;
     511                 :            : 
     512 [ #  # ][ #  #  :          0 :     switch( maCtlLight.GetActualRP() )
          #  #  #  #  #  
                   #  # ]
     513                 :            :     {
     514                 :            :         default:       OSL_FAIL("svx::GraphicFilterEmboss::GetFilteredGraphic(), unknown Reference Point!" );
     515                 :          0 :         case( RP_LT ): nAzim = 4500,    nElev = 4500; break;
     516                 :          0 :         case( RP_MT ): nAzim = 9000,    nElev = 4500; break;
     517                 :          0 :         case( RP_RT ): nAzim = 13500,   nElev = 4500; break;
     518                 :          0 :         case( RP_LM ): nAzim = 0,       nElev = 4500; break;
     519                 :          0 :         case( RP_MM ): nAzim = 0,       nElev = 9000; break;
     520                 :          0 :         case( RP_RM ): nAzim = 18000,   nElev = 4500; break;
     521                 :          0 :         case( RP_LB ): nAzim = 31500,   nElev = 4500; break;
     522                 :          0 :         case( RP_MB ): nAzim = 27000,   nElev = 4500; break;
     523                 :          0 :         case( RP_RB ): nAzim = 22500,   nElev = 4500; break;
     524                 :            :     }
     525                 :            : 
     526                 :          0 :     BmpFilterParam aParam( nAzim, nElev );
     527                 :            : 
     528 [ #  # ][ #  # ]:          0 :     if( rGraphic.IsAnimated() )
     529                 :            :     {
     530         [ #  # ]:          0 :         Animation aAnim( rGraphic.GetAnimation() );
     531                 :            : 
     532 [ #  # ][ #  # ]:          0 :         if( aAnim.Filter( BMP_FILTER_EMBOSS_GREY, &aParam ) )
     533 [ #  # ][ #  # ]:          0 :             aRet = aAnim;
         [ #  # ][ #  # ]
     534                 :            :     }
     535                 :            :     else
     536                 :            :     {
     537         [ #  # ]:          0 :         BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
     538                 :            : 
     539 [ #  # ][ #  # ]:          0 :         if( aBmpEx.Filter( BMP_FILTER_EMBOSS_GREY, &aParam ) )
     540 [ #  # ][ #  # ]:          0 :             aRet = aBmpEx;
         [ #  # ][ #  # ]
     541                 :            :     }
     542                 :            : 
     543                 :          0 :     return aRet;
     544                 :            : }
     545                 :            : 
     546                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10