LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/dlg - copydlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 138 0.0 %
Date: 2012-12-17 Functions: 0 13 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10