LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - copydlg.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 150 0.0 %
Date: 2014-11-03 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             : #include "copydlg.hxx"
      21             : #include <comphelper/string.hxx>
      22             : #include <svx/dlgutil.hxx>
      23             : #include <sfx2/module.hxx>
      24             : #include <svx/xcolit.hxx>
      25             : #include <svx/xflclit.hxx>
      26             : #include <svx/xdef.hxx>
      27             : #include <svx/xfillit0.hxx>
      28             : #include <svx/xenum.hxx>
      29             : 
      30             : #include <sfx2/app.hxx>
      31             : 
      32             : #include "sdattr.hxx"
      33             : 
      34             : #include "View.hxx"
      35             : #include "sdresid.hxx"
      36             : #include "drawdoc.hxx"
      37             : #include "res_bmp.hrc"
      38             : 
      39             : namespace sd {
      40             : 
      41             : #define TOKEN ';'
      42             : 
      43           0 : CopyDlg::CopyDlg(vcl::Window* pWindow, const SfxItemSet& rInAttrs,
      44             :     const XColorListRef &pColList, ::sd::View* pInView)
      45             :     : SfxModalDialog(pWindow, "DuplicateDialog", "modules/sdraw/ui/copydlg.ui")
      46             :     , mrOutAttrs(rInAttrs)
      47             :     , mpColorList(pColList)
      48           0 :     , maUIScale(pInView->GetDoc().GetUIScale())
      49           0 :     , mpView(pInView)
      50             : {
      51           0 :     get(m_pNumFldCopies, "copies");
      52           0 :     get(m_pBtnSetViewData, "viewdata");
      53           0 :     get(m_pMtrFldMoveX, "x");
      54           0 :     get(m_pMtrFldMoveY, "y");
      55           0 :     get(m_pMtrFldAngle, "angle");
      56           0 :     get(m_pMtrFldWidth, "width");
      57           0 :     get(m_pMtrFldHeight, "height");
      58           0 :     get(m_pLbStartColor, "start");
      59           0 :     get(m_pFtEndColor, "endlabel");
      60           0 :     get(m_pLbEndColor, "end");
      61           0 :     get(m_pBtnSetDefault, "default");
      62             : 
      63             :     // Set up the view data button (image and accessible name).
      64           0 :     m_pBtnSetViewData->SetAccessibleName (m_pBtnSetViewData->GetQuickHelpText());
      65             : 
      66             :     // color tables
      67             :     DBG_ASSERT( mpColorList.is(), "No colortable available !" );
      68           0 :     m_pLbStartColor->Fill( mpColorList );
      69           0 :     m_pLbEndColor->CopyEntries( *m_pLbStartColor );
      70             : 
      71           0 :     m_pLbStartColor->SetSelectHdl( LINK( this, CopyDlg, SelectColorHdl ) );
      72           0 :     m_pBtnSetViewData->SetClickHdl( LINK( this, CopyDlg, SetViewData ) );
      73           0 :     m_pBtnSetDefault->SetClickHdl( LINK( this, CopyDlg, SetDefault ) );
      74             : 
      75           0 :     FieldUnit eFUnit( SfxModule::GetCurrentFieldUnit() );
      76             : 
      77           0 :     SetFieldUnit( *m_pMtrFldMoveX, eFUnit, true );
      78           0 :     SetFieldUnit( *m_pMtrFldMoveY, eFUnit, true );
      79           0 :     SetFieldUnit( *m_pMtrFldWidth, eFUnit, true );
      80           0 :     SetFieldUnit( *m_pMtrFldHeight, eFUnit, true );
      81             : 
      82           0 :     Reset();
      83           0 : }
      84             : 
      85           0 : CopyDlg::~CopyDlg()
      86             : {
      87           0 :     OUString& rStr = GetExtraData();
      88             : 
      89           0 :     rStr = OUString::number(m_pNumFldCopies->GetValue());
      90           0 :     rStr += OUString(TOKEN);
      91             : 
      92           0 :     rStr += OUString::number(m_pMtrFldMoveX->GetValue());
      93           0 :     rStr += OUString( TOKEN );
      94             : 
      95           0 :     rStr += OUString::number(m_pMtrFldMoveY->GetValue());
      96           0 :     rStr += OUString( TOKEN );
      97             : 
      98           0 :     rStr += OUString::number(m_pMtrFldAngle->GetValue());
      99           0 :     rStr += OUString( TOKEN );
     100             : 
     101           0 :     rStr += OUString::number(m_pMtrFldWidth->GetValue());
     102           0 :     rStr += OUString( TOKEN );
     103             : 
     104           0 :     rStr += OUString::number(m_pMtrFldHeight->GetValue());
     105           0 :     rStr += OUString( TOKEN );
     106             : 
     107           0 :     rStr += OUString::number( m_pLbStartColor->GetSelectEntryColor().GetColor() );
     108           0 :     rStr += OUString( TOKEN );
     109             : 
     110           0 :     rStr += OUString::number( m_pLbEndColor->GetSelectEntryColor().GetColor() );
     111           0 : }
     112             : 
     113             : /**
     114             :  * reads provided item set or evaluate ini string
     115             :  */
     116           0 : void CopyDlg::Reset()
     117             : {
     118           0 :     const SfxPoolItem* pPoolItem = NULL;
     119           0 :     OUString aStr( GetExtraData() );
     120             : 
     121           0 :     if (comphelper::string::getTokenCount(aStr, TOKEN) < 8)
     122             :     {
     123           0 :         if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_NUMBER, true, &pPoolItem ) )
     124           0 :             m_pNumFldCopies->SetValue( ( ( const SfxUInt16Item* ) pPoolItem )->GetValue() );
     125             :         else
     126           0 :             m_pNumFldCopies->SetValue( 1L );
     127             : 
     128           0 :         long nMoveX = 500L;
     129           0 :         if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_MOVE_X, true, &pPoolItem ) )
     130           0 :             nMoveX = ( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() );
     131           0 :         SetMetricValue( *m_pMtrFldMoveX, Fraction(nMoveX) / maUIScale, SFX_MAPUNIT_100TH_MM);
     132             : 
     133           0 :         long nMoveY = 500L;
     134           0 :         if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_MOVE_Y, true, &pPoolItem ) )
     135           0 :             nMoveY = ( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() );
     136           0 :         SetMetricValue( *m_pMtrFldMoveY, Fraction(nMoveY) / maUIScale, SFX_MAPUNIT_100TH_MM);
     137             : 
     138           0 :         if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_ANGLE, true, &pPoolItem ) )
     139           0 :             m_pMtrFldAngle->SetValue( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() );
     140             :         else
     141           0 :             m_pMtrFldAngle->SetValue( 0L );
     142             : 
     143           0 :         long nWidth = 0L;
     144           0 :         if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_WIDTH, true, &pPoolItem ) )
     145           0 :             nWidth = ( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() );
     146           0 :         SetMetricValue( *m_pMtrFldWidth, Fraction(nWidth) / maUIScale, SFX_MAPUNIT_100TH_MM);
     147             : 
     148           0 :         long nHeight = 0L;
     149           0 :         if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_HEIGHT, true, &pPoolItem ) )
     150           0 :             nHeight = ( ( ( const SfxInt32Item* ) pPoolItem )->GetValue() );
     151           0 :         SetMetricValue( *m_pMtrFldHeight, Fraction(nHeight) / maUIScale, SFX_MAPUNIT_100TH_MM);
     152             : 
     153           0 :         if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_START_COLOR, true, &pPoolItem ) )
     154             :         {
     155           0 :             Color aColor = ( ( const XColorItem* ) pPoolItem )->GetColorValue();
     156           0 :             m_pLbStartColor->SelectEntry( aColor );
     157           0 :             m_pLbEndColor->SelectEntry( aColor );
     158             :         }
     159             :         else
     160             :         {
     161           0 :             m_pLbStartColor->SetNoSelection();
     162           0 :             m_pLbEndColor->SetNoSelection();
     163           0 :             m_pLbEndColor->Disable();
     164           0 :             m_pFtEndColor->Disable();
     165             :         }
     166             :     }
     167             :     else
     168             :     {
     169             :         long nTmp;
     170           0 :         nTmp = (long)aStr.getToken( 0, TOKEN ).toInt32();
     171           0 :         m_pNumFldCopies->SetValue( nTmp );
     172             : 
     173           0 :         nTmp = (long)aStr.getToken( 1, TOKEN ).toInt32();
     174           0 :         m_pMtrFldMoveX->SetValue( nTmp );
     175             : 
     176           0 :         nTmp = (long)aStr.getToken( 2, TOKEN ).toInt32();
     177           0 :         m_pMtrFldMoveY->SetValue( nTmp );
     178             : 
     179           0 :         nTmp = (long)aStr.getToken( 3, TOKEN ).toInt32();
     180           0 :         m_pMtrFldAngle->SetValue( nTmp );
     181             : 
     182           0 :         nTmp = (long)aStr.getToken( 4, TOKEN ).toInt32();
     183           0 :         m_pMtrFldWidth->SetValue( nTmp );
     184             : 
     185           0 :         nTmp = (long)aStr.getToken( 5, TOKEN ).toInt32();
     186           0 :         m_pMtrFldHeight->SetValue( nTmp );
     187             : 
     188           0 :         nTmp = (long)aStr.getToken( 6, TOKEN ).toInt32();
     189           0 :         m_pLbStartColor->SelectEntry( Color( nTmp ) );
     190             : 
     191           0 :         nTmp = (long)aStr.getToken( 7, TOKEN ).toInt32();
     192           0 :         m_pLbEndColor->SelectEntry( Color( nTmp ) );
     193           0 :     }
     194             : 
     195           0 : }
     196             : 
     197             : /**
     198             :  * fills provided item set with dialog box attributes
     199             :  */
     200           0 : void CopyDlg::GetAttr( SfxItemSet& rOutAttrs )
     201             : {
     202           0 :     long nMoveX = Fraction( GetCoreValue( *m_pMtrFldMoveX, SFX_MAPUNIT_100TH_MM) ) * maUIScale;
     203           0 :     long nMoveY = Fraction( GetCoreValue( *m_pMtrFldMoveY, SFX_MAPUNIT_100TH_MM) ) * maUIScale;
     204           0 :     long nHeight = Fraction( GetCoreValue( *m_pMtrFldHeight, SFX_MAPUNIT_100TH_MM) ) * maUIScale;
     205           0 :     long nWidth  = Fraction( GetCoreValue( *m_pMtrFldWidth, SFX_MAPUNIT_100TH_MM) ) * maUIScale;
     206             : 
     207           0 :     rOutAttrs.Put( SfxUInt16Item( ATTR_COPY_NUMBER, (sal_uInt16) m_pNumFldCopies->GetValue() ) );
     208           0 :     rOutAttrs.Put( SfxInt32Item( ATTR_COPY_MOVE_X, nMoveX ) );
     209           0 :     rOutAttrs.Put( SfxInt32Item( ATTR_COPY_MOVE_Y, nMoveY ) );
     210           0 :     rOutAttrs.Put( SfxInt32Item( ATTR_COPY_ANGLE, static_cast<sal_Int32>(m_pMtrFldAngle->GetValue()) ) );
     211           0 :     rOutAttrs.Put( SfxInt32Item( ATTR_COPY_WIDTH, nWidth ) );
     212           0 :     rOutAttrs.Put( SfxInt32Item( ATTR_COPY_HEIGHT, nHeight ) );
     213             : 
     214           0 :     if( m_pLbStartColor->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
     215             :     {
     216             :         XColorItem aXColorItem( ATTR_COPY_START_COLOR, m_pLbStartColor->GetSelectEntry(),
     217           0 :                                     m_pLbStartColor->GetSelectEntryColor() );
     218           0 :         rOutAttrs.Put( aXColorItem );
     219             :     }
     220           0 :     if( m_pLbEndColor->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
     221             :     {
     222             :         XColorItem aXColorItem( ATTR_COPY_END_COLOR, m_pLbEndColor->GetSelectEntry(),
     223           0 :                                     m_pLbEndColor->GetSelectEntryColor() );
     224           0 :         rOutAttrs.Put( aXColorItem );
     225             :     }
     226           0 : }
     227             : 
     228             : /**
     229             :  * enables and selects end color LB
     230             :  */
     231           0 : IMPL_LINK_NOARG(CopyDlg, SelectColorHdl)
     232             : {
     233           0 :     sal_Int32 nPos = m_pLbStartColor->GetSelectEntryPos();
     234             : 
     235           0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND &&
     236           0 :         !m_pLbEndColor->IsEnabled() )
     237             :     {
     238           0 :         m_pLbEndColor->SelectEntryPos( nPos );
     239           0 :         m_pLbEndColor->Enable();
     240           0 :         m_pFtEndColor->Enable();
     241             :     }
     242           0 :     return 0;
     243             : }
     244             : 
     245             : /**
     246             :  * sets values of selection
     247             :  */
     248           0 : IMPL_LINK_NOARG(CopyDlg, SetViewData)
     249             : {
     250           0 :     Rectangle aRect = mpView->GetAllMarkedRect();
     251             : 
     252           0 :     SetMetricValue( *m_pMtrFldMoveX, Fraction( aRect.GetWidth() ) /
     253           0 :                                     maUIScale, SFX_MAPUNIT_100TH_MM);
     254           0 :     SetMetricValue( *m_pMtrFldMoveY, Fraction( aRect.GetHeight() ) /
     255           0 :                                     maUIScale, SFX_MAPUNIT_100TH_MM);
     256             : 
     257             :     // sets color attribute
     258           0 :     const SfxPoolItem*  pPoolItem = NULL;
     259           0 :     if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_START_COLOR, true, &pPoolItem ) )
     260             :     {
     261           0 :         Color aColor = ( ( const XColorItem* ) pPoolItem )->GetColorValue();
     262           0 :         m_pLbStartColor->SelectEntry( aColor );
     263             :     }
     264             : 
     265           0 :     return 0;
     266             : }
     267             : 
     268             : /**
     269             :  * resets values to default
     270             :  */
     271           0 : IMPL_LINK_NOARG(CopyDlg, SetDefault)
     272             : {
     273           0 :     m_pNumFldCopies->SetValue( 1L );
     274             : 
     275           0 :     long nValue = 500L;
     276           0 :     SetMetricValue( *m_pMtrFldMoveX, Fraction(nValue) / maUIScale, SFX_MAPUNIT_100TH_MM);
     277           0 :     SetMetricValue( *m_pMtrFldMoveY, Fraction(nValue) / maUIScale, SFX_MAPUNIT_100TH_MM);
     278             : 
     279           0 :     nValue = 0L;
     280           0 :     m_pMtrFldAngle->SetValue( nValue );
     281           0 :     SetMetricValue( *m_pMtrFldWidth, Fraction(nValue) / maUIScale, SFX_MAPUNIT_100TH_MM);
     282           0 :     SetMetricValue( *m_pMtrFldHeight, Fraction(nValue) / maUIScale, SFX_MAPUNIT_100TH_MM);
     283             : 
     284             :     // set color attribute
     285           0 :     const SfxPoolItem*  pPoolItem = NULL;
     286           0 :     if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_START_COLOR, true, &pPoolItem ) )
     287             :     {
     288           0 :         Color aColor = ( ( const XColorItem* ) pPoolItem )->GetColorValue();
     289           0 :         m_pLbStartColor->SelectEntry( aColor );
     290           0 :         m_pLbEndColor->SelectEntry( aColor );
     291             :     }
     292             : 
     293           0 :     return 0;
     294             : }
     295             : 
     296           0 : } // end of namespace sd
     297             : 
     298             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10