LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - copydlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 137 0.0 %
Date: 2012-08-25 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 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                 :            : 
      30                 :            : #ifdef SD_DLLIMPLEMENTATION
      31                 :            : #undef SD_DLLIMPLEMENTATION
      32                 :            : #endif
      33                 :            : 
      34                 :            : #include "copydlg.hxx"
      35                 :            : #include <comphelper/string.hxx>
      36                 :            : #include <svx/dlgutil.hxx>
      37                 :            : #include <sfx2/module.hxx>
      38                 :            : #include <svx/xcolit.hxx>
      39                 :            : #include <svx/xflclit.hxx>
      40                 :            : #include <svx/xdef.hxx>
      41                 :            : #include <svx/xfillit0.hxx>
      42                 :            : #include <svx/xenum.hxx>
      43                 :            : 
      44                 :            : #include <sfx2/app.hxx>
      45                 :            : 
      46                 :            : 
      47                 :            : 
      48                 :            : #include "sdattr.hxx"
      49                 :            : 
      50                 :            : #include "copydlg.hrc"
      51                 :            : #include "View.hxx"
      52                 :            : #include "sdresid.hxx"
      53                 :            : #include "drawdoc.hxx"
      54                 :            : #include "res_bmp.hrc"
      55                 :            : 
      56                 :            : namespace sd {
      57                 :            : 
      58                 :            : #define TOKEN (sal_Unicode(';'))
      59                 :            : 
      60                 :            : /*************************************************************************
      61                 :            : |*
      62                 :            : |* Dialog zum Kopieren von Objekten
      63                 :            : |*
      64                 :            : \************************************************************************/
      65                 :            : 
      66                 :          0 : CopyDlg::CopyDlg(
      67                 :            :     ::Window* pWindow,
      68                 :            :     const SfxItemSet& rInAttrs,
      69                 :            :     const XColorListRef &pColList,
      70                 :            :     ::sd::View* pInView )
      71                 :            :     : SfxModalDialog     ( pWindow, SdResId( DLG_COPY ) ),
      72                 :            :       maFtCopies           ( this, SdResId( FT_COPIES ) ),
      73                 :            :       maNumFldCopies       ( this, SdResId( NUM_FLD_COPIES ) ),
      74                 :            :       maBtnSetViewData     ( this, SdResId( BTN_SET_VIEWDATA ) ),
      75                 :            :       maGrpMovement        ( this, SdResId( GRP_MOVEMENT ) ),
      76                 :            :       maFtMoveX            ( this, SdResId( FT_MOVE_X ) ),
      77                 :            :       maMtrFldMoveX        ( this, SdResId( MTR_FLD_MOVE_X ) ),
      78                 :            :       maFtMoveY            ( this, SdResId( FT_MOVE_Y ) ),
      79                 :            :       maMtrFldMoveY        ( this, SdResId( MTR_FLD_MOVE_Y ) ),
      80                 :            :       maFtAngle            ( this, SdResId( FT_ANGLE ) ),
      81                 :            :       maMtrFldAngle        ( this, SdResId( MTR_FLD_ANGLE ) ),
      82                 :            :       maGrpEnlargement     ( this, SdResId( GRP_ENLARGEMENT ) ),
      83                 :            :       maFtWidth            ( this, SdResId( FT_WIDTH ) ),
      84                 :            :       maMtrFldWidth        ( this, SdResId( MTR_FLD_WIDTH ) ),
      85                 :            :       maFtHeight           ( this, SdResId( FT_HEIGHT ) ),
      86                 :            :       maMtrFldHeight       ( this, SdResId( MTR_FLD_HEIGHT ) ),
      87                 :            :       maGrpColor           ( this, SdResId( GRP_COLOR ) ),
      88                 :            :       maFtStartColor       ( this, SdResId( FT_START_COLOR ) ),
      89                 :            :       maLbStartColor       ( this, SdResId( LB_START_COLOR ) ),
      90                 :            :       maFtEndColor         ( this, SdResId( FT_END_COLOR ) ),
      91                 :            :       maLbEndColor         ( this, SdResId( LB_END_COLOR ) ),
      92                 :            :       maBtnOK              ( this, SdResId( BTN_OK ) ),
      93                 :            :       maBtnCancel          ( this, SdResId( BTN_CANCEL ) ),
      94                 :            :       maBtnHelp            ( this, SdResId( BTN_HELP ) ),
      95                 :            :       maBtnSetDefault      ( this, SdResId( BTN_SET_DEFAULT ) ),
      96                 :            :       mrOutAttrs           ( rInAttrs ),
      97                 :            :       mpColorList          ( pColList ),
      98                 :          0 :       maUIScale(pInView->GetDoc().GetUIScale()),
      99                 :          0 :       mpView               ( pInView )
     100                 :            : {
     101                 :          0 :     FreeResource();
     102                 :            : 
     103                 :            :     // Set up the view data button (image and accessible name).
     104                 :          0 :     maBtnSetViewData.SetAccessibleName (maBtnSetViewData.GetQuickHelpText());
     105                 :            : 
     106                 :            :     // Farbtabellen
     107                 :            :     DBG_ASSERT( mpColorList.is(), "No colortable available !" );
     108                 :          0 :     maLbStartColor.Fill( mpColorList );
     109                 :          0 :     maLbEndColor.CopyEntries( maLbStartColor );
     110                 :            : 
     111                 :          0 :     maLbStartColor.SetSelectHdl( LINK( this, CopyDlg, SelectColorHdl ) );
     112                 :          0 :     maBtnSetViewData.SetClickHdl( LINK( this, CopyDlg, SetViewData ) );
     113                 :          0 :     maBtnSetDefault.SetClickHdl( LINK( this, CopyDlg, SetDefault ) );
     114                 :            : 
     115                 :            : 
     116                 :          0 :     FieldUnit eFUnit( SfxModule::GetCurrentFieldUnit() );
     117                 :            : 
     118                 :          0 :     SetFieldUnit( maMtrFldMoveX, eFUnit, sal_True );
     119                 :          0 :     SetFieldUnit( maMtrFldMoveY, eFUnit, sal_True );
     120                 :          0 :     SetFieldUnit( maMtrFldWidth, eFUnit, sal_True );
     121                 :          0 :     SetFieldUnit( maMtrFldHeight, eFUnit, sal_True );
     122                 :            : 
     123                 :          0 :     Reset();
     124                 :          0 : }
     125                 :            : 
     126                 :            : /*************************************************************************
     127                 :            : |*
     128                 :            : |* Dtor
     129                 :            : |*
     130                 :            : \************************************************************************/
     131                 :            : 
     132                 :          0 : CopyDlg::~CopyDlg()
     133                 :            : {
     134                 :          0 :     String& rStr = GetExtraData();
     135                 :            : 
     136                 :          0 :     rStr = rtl::OUString::valueOf(static_cast<sal_Int64>(maNumFldCopies.GetValue()));
     137                 :          0 :     rStr.Append( TOKEN );
     138                 :            : 
     139                 :          0 :     rStr += rtl::OUString::valueOf(static_cast<sal_Int64>(maMtrFldMoveX.GetValue()));
     140                 :          0 :     rStr.Append( TOKEN );
     141                 :            : 
     142                 :          0 :     rStr += rtl::OUString::valueOf(static_cast<sal_Int64>(maMtrFldMoveY.GetValue()));
     143                 :          0 :     rStr.Append( TOKEN );
     144                 :            : 
     145                 :          0 :     rStr += rtl::OUString::valueOf(static_cast<sal_Int64>(maMtrFldAngle.GetValue()));
     146                 :          0 :     rStr.Append( TOKEN );
     147                 :            : 
     148                 :          0 :     rStr += rtl::OUString::valueOf(static_cast<sal_Int64>(maMtrFldWidth.GetValue()));
     149                 :          0 :     rStr.Append( TOKEN );
     150                 :            : 
     151                 :          0 :     rStr += rtl::OUString::valueOf(static_cast<sal_Int64>(maMtrFldHeight.GetValue()));
     152                 :          0 :     rStr.Append( TOKEN );
     153                 :            : 
     154                 :          0 :     rStr += UniString::CreateFromInt32( (long)maLbStartColor.GetSelectEntryColor().GetColor() );
     155                 :          0 :     rStr.Append( TOKEN );
     156                 :            : 
     157                 :          0 :     rStr += UniString::CreateFromInt32( (long)maLbEndColor.GetSelectEntryColor().GetColor() );
     158                 :          0 : }
     159                 :            : 
     160                 :            : /*************************************************************************
     161                 :            : |*
     162                 :            : |* Liest uebergebenen Item-Set oder wertet den INI-String aus
     163                 :            : |*
     164                 :            : \************************************************************************/
     165                 :            : 
     166                 :          0 : void CopyDlg::Reset()
     167                 :            : {
     168                 :          0 :     const SfxPoolItem* pPoolItem = NULL;
     169                 :          0 :     String aStr( GetExtraData() );
     170                 :            : 
     171                 :          0 :     if (comphelper::string::getTokenCount(aStr, TOKEN) < 8)
     172                 :            :     {
     173                 :          0 :         if( SFX_ITEM_SET == mrOutAttrs.GetItemState( ATTR_COPY_NUMBER, sal_True, &pPoolItem ) )
     174                 :          0 :             maNumFldCopies.SetValue( ( ( const SfxUInt16Item* ) pPoolItem )->GetValue() );
     175                 :            :         else
     176                 :          0 :             maNumFldCopies.SetValue( 1L );
     177                 :            : 
     178                 :          0 :         long nMoveX = 500L;
     179                 :          0 :         if( SFX_ITEM_SET == mrOutAttrs.GetItemState( ATTR_COPY_MOVE_X, sal_True, &pPoolItem ) )
     180                 :          0 :             nMoveX = ( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() );
     181                 :          0 :         SetMetricValue( maMtrFldMoveX, Fraction(nMoveX) / maUIScale, SFX_MAPUNIT_100TH_MM);
     182                 :            : 
     183                 :          0 :         long nMoveY = 500L;
     184                 :          0 :         if( SFX_ITEM_SET == mrOutAttrs.GetItemState( ATTR_COPY_MOVE_Y, sal_True, &pPoolItem ) )
     185                 :          0 :             nMoveY = ( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() );
     186                 :          0 :         SetMetricValue( maMtrFldMoveY, Fraction(nMoveY) / maUIScale, SFX_MAPUNIT_100TH_MM);
     187                 :            : 
     188                 :          0 :         if( SFX_ITEM_SET == mrOutAttrs.GetItemState( ATTR_COPY_ANGLE, sal_True, &pPoolItem ) )
     189                 :          0 :             maMtrFldAngle.SetValue( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() );
     190                 :            :         else
     191                 :          0 :             maMtrFldAngle.SetValue( 0L );
     192                 :            : 
     193                 :          0 :         long nWidth = 0L;
     194                 :          0 :         if( SFX_ITEM_SET == mrOutAttrs.GetItemState( ATTR_COPY_WIDTH, sal_True, &pPoolItem ) )
     195                 :          0 :             nWidth = ( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() );
     196                 :          0 :         SetMetricValue( maMtrFldWidth, Fraction(nWidth) / maUIScale, SFX_MAPUNIT_100TH_MM);
     197                 :            : 
     198                 :          0 :         long nHeight = 0L;
     199                 :          0 :         if( SFX_ITEM_SET == mrOutAttrs.GetItemState( ATTR_COPY_HEIGHT, sal_True, &pPoolItem ) )
     200                 :          0 :             nHeight = ( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() );
     201                 :          0 :         SetMetricValue( maMtrFldHeight, Fraction(nHeight) / maUIScale, SFX_MAPUNIT_100TH_MM);
     202                 :            : 
     203                 :          0 :         if( SFX_ITEM_SET == mrOutAttrs.GetItemState( ATTR_COPY_START_COLOR, sal_True, &pPoolItem ) )
     204                 :            :         {
     205                 :          0 :             Color aColor = ( ( const XColorItem* ) pPoolItem )->GetColorValue();
     206                 :          0 :             maLbStartColor.SelectEntry( aColor );
     207                 :          0 :             maLbEndColor.SelectEntry( aColor );
     208                 :            :         }
     209                 :            :         else
     210                 :            :         {
     211                 :          0 :             maLbStartColor.SetNoSelection();
     212                 :          0 :             maLbEndColor.SetNoSelection();
     213                 :          0 :             maLbEndColor.Disable();
     214                 :          0 :             maFtEndColor.Disable();
     215                 :            :         }
     216                 :            :     }
     217                 :            :     else
     218                 :            :     {
     219                 :            :         long nTmp;
     220                 :          0 :         nTmp = (long)aStr.GetToken( 0, TOKEN ).ToInt32();
     221                 :          0 :         maNumFldCopies.SetValue( nTmp );
     222                 :            : 
     223                 :          0 :         nTmp = (long)aStr.GetToken( 1, TOKEN ).ToInt32();
     224                 :          0 :         maMtrFldMoveX.SetValue( nTmp );
     225                 :            : 
     226                 :          0 :         nTmp = (long)aStr.GetToken( 2, TOKEN ).ToInt32();
     227                 :          0 :         maMtrFldMoveY.SetValue( nTmp );
     228                 :            : 
     229                 :          0 :         nTmp = (long)aStr.GetToken( 3, TOKEN ).ToInt32();
     230                 :          0 :         maMtrFldAngle.SetValue( nTmp );
     231                 :            : 
     232                 :          0 :         nTmp = (long)aStr.GetToken( 4, TOKEN ).ToInt32();
     233                 :          0 :         maMtrFldWidth.SetValue( nTmp );
     234                 :            : 
     235                 :          0 :         nTmp = (long)aStr.GetToken( 5, TOKEN ).ToInt32();
     236                 :          0 :         maMtrFldHeight.SetValue( nTmp );
     237                 :            : 
     238                 :          0 :         nTmp = (long)aStr.GetToken( 6, TOKEN ).ToInt32();
     239                 :          0 :         maLbStartColor.SelectEntry( Color( nTmp ) );
     240                 :            : 
     241                 :          0 :         nTmp = (long)aStr.GetToken( 7, TOKEN ).ToInt32();
     242                 :          0 :         maLbEndColor.SelectEntry( Color( nTmp ) );
     243                 :          0 :     }
     244                 :            : 
     245                 :          0 : }
     246                 :            : 
     247                 :            : /*************************************************************************
     248                 :            : |*
     249                 :            : |* Fuellt uebergebenen Item-Set mit Dialogbox-Attributen
     250                 :            : |*
     251                 :            : \************************************************************************/
     252                 :            : 
     253                 :          0 : void CopyDlg::GetAttr( SfxItemSet& rOutAttrs )
     254                 :            : {
     255                 :          0 :     long nMoveX = Fraction( GetCoreValue( maMtrFldMoveX, SFX_MAPUNIT_100TH_MM) ) * maUIScale;
     256                 :          0 :     long nMoveY = Fraction( GetCoreValue( maMtrFldMoveY, SFX_MAPUNIT_100TH_MM) ) * maUIScale;
     257                 :          0 :     long nHeight = Fraction( GetCoreValue( maMtrFldHeight, SFX_MAPUNIT_100TH_MM) ) * maUIScale;
     258                 :          0 :     long nWidth  = Fraction( GetCoreValue( maMtrFldWidth, SFX_MAPUNIT_100TH_MM) ) * maUIScale;
     259                 :            : 
     260                 :          0 :     rOutAttrs.Put( SfxUInt16Item( ATTR_COPY_NUMBER, (sal_uInt16) maNumFldCopies.GetValue() ) );
     261                 :          0 :     rOutAttrs.Put( SfxInt32Item( ATTR_COPY_MOVE_X, nMoveX ) );
     262                 :          0 :     rOutAttrs.Put( SfxInt32Item( ATTR_COPY_MOVE_Y, nMoveY ) );
     263                 :          0 :     rOutAttrs.Put( SfxInt32Item( ATTR_COPY_ANGLE, static_cast<sal_Int32>(maMtrFldAngle.GetValue()) ) );
     264                 :          0 :     rOutAttrs.Put( SfxInt32Item( ATTR_COPY_WIDTH, nWidth ) );
     265                 :          0 :     rOutAttrs.Put( SfxInt32Item( ATTR_COPY_HEIGHT, nHeight ) );
     266                 :            : 
     267                 :          0 :     if( maLbStartColor.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
     268                 :            :     {
     269                 :            :         XColorItem aXColorItem( ATTR_COPY_START_COLOR, maLbStartColor.GetSelectEntry(),
     270                 :          0 :                                     maLbStartColor.GetSelectEntryColor() );
     271                 :          0 :         rOutAttrs.Put( aXColorItem );
     272                 :            :     }
     273                 :          0 :     if( maLbEndColor.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
     274                 :            :     {
     275                 :            :         XColorItem aXColorItem( ATTR_COPY_END_COLOR, maLbEndColor.GetSelectEntry(),
     276                 :          0 :                                     maLbEndColor.GetSelectEntryColor() );
     277                 :          0 :         rOutAttrs.Put( aXColorItem );
     278                 :            :     }
     279                 :          0 : }
     280                 :            : 
     281                 :            : /*************************************************************************
     282                 :            : |*
     283                 :            : |* Enabled und selektiert Endfarben-LB
     284                 :            : |*
     285                 :            : \************************************************************************/
     286                 :            : 
     287                 :          0 : IMPL_LINK_NOARG(CopyDlg, SelectColorHdl)
     288                 :            : {
     289                 :          0 :     sal_uInt16 nPos = maLbStartColor.GetSelectEntryPos();
     290                 :            : 
     291                 :          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND &&
     292                 :          0 :         !maLbEndColor.IsEnabled() )
     293                 :            :     {
     294                 :          0 :         maLbEndColor.SelectEntryPos( nPos );
     295                 :          0 :         maLbEndColor.Enable();
     296                 :          0 :         maFtEndColor.Enable();
     297                 :            :     }
     298                 :          0 :     return 0;
     299                 :            : }
     300                 :            : 
     301                 :            : /*************************************************************************
     302                 :            : |* Setzt Werte der Selektion
     303                 :            : \************************************************************************/
     304                 :            : 
     305                 :          0 : IMPL_LINK_NOARG(CopyDlg, SetViewData)
     306                 :            : {
     307                 :          0 :     Rectangle aRect = mpView->GetAllMarkedRect();
     308                 :            : 
     309                 :            :     SetMetricValue( maMtrFldMoveX, Fraction( aRect.GetWidth() ) /
     310                 :          0 :                                     maUIScale, SFX_MAPUNIT_100TH_MM);
     311                 :            :     SetMetricValue( maMtrFldMoveY, Fraction( aRect.GetHeight() ) /
     312                 :          0 :                                     maUIScale, SFX_MAPUNIT_100TH_MM);
     313                 :            : 
     314                 :            :     // Farb-Attribut setzen
     315                 :          0 :     const SfxPoolItem*  pPoolItem = NULL;
     316                 :          0 :     if( SFX_ITEM_SET == mrOutAttrs.GetItemState( ATTR_COPY_START_COLOR, sal_True, &pPoolItem ) )
     317                 :            :     {
     318                 :          0 :         Color aColor = ( ( const XColorItem* ) pPoolItem )->GetColorValue();
     319                 :          0 :         maLbStartColor.SelectEntry( aColor );
     320                 :            :     }
     321                 :            : 
     322                 :          0 :     return 0;
     323                 :            : }
     324                 :            : 
     325                 :            : /*************************************************************************
     326                 :            : |* Setzt Werte auf Standard
     327                 :            : \************************************************************************/
     328                 :            : 
     329                 :          0 : IMPL_LINK_NOARG(CopyDlg, SetDefault)
     330                 :            : {
     331                 :          0 :     maNumFldCopies.SetValue( 1L );
     332                 :            : 
     333                 :          0 :     long nValue = 500L;
     334                 :          0 :     SetMetricValue( maMtrFldMoveX, Fraction(nValue) / maUIScale, SFX_MAPUNIT_100TH_MM);
     335                 :          0 :     SetMetricValue( maMtrFldMoveY, Fraction(nValue) / maUIScale, SFX_MAPUNIT_100TH_MM);
     336                 :            : 
     337                 :          0 :     nValue = 0L;
     338                 :          0 :     maMtrFldAngle.SetValue( nValue );
     339                 :          0 :     SetMetricValue( maMtrFldWidth, Fraction(nValue) / maUIScale, SFX_MAPUNIT_100TH_MM);
     340                 :          0 :     SetMetricValue( maMtrFldHeight, Fraction(nValue) / maUIScale, SFX_MAPUNIT_100TH_MM);
     341                 :            : 
     342                 :            :     // Farb-Attribut setzen
     343                 :          0 :     const SfxPoolItem*  pPoolItem = NULL;
     344                 :          0 :     if( SFX_ITEM_SET == mrOutAttrs.GetItemState( ATTR_COPY_START_COLOR, sal_True, &pPoolItem ) )
     345                 :            :     {
     346                 :          0 :         Color aColor = ( ( const XColorItem* ) pPoolItem )->GetColorValue();
     347                 :          0 :         maLbStartColor.SelectEntry( aColor );
     348                 :          0 :         maLbEndColor.SelectEntry( aColor );
     349                 :            :     }
     350                 :            : 
     351                 :          0 :     return 0;
     352                 :            : }
     353                 :            : 
     354                 :            : 
     355                 :            : } // end of namespace sd
     356                 :            : 
     357                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10