LCOV - code coverage report
Current view: top level - chart2/source/controller/main - ChartController_Position.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 78 0.0 %
Date: 2012-08-25 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 114 0.0 %

           Branch data     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 "ChartController.hxx"
      21                 :            : 
      22                 :            : #include "macros.hxx"
      23                 :            : #include "ChartWindow.hxx"
      24                 :            : #include "DrawViewWrapper.hxx"
      25                 :            : #include "PositionAndSizeHelper.hxx"
      26                 :            : #include "ChartModelHelper.hxx"
      27                 :            : #include "UndoGuard.hxx"
      28                 :            : #include "Strings.hrc"
      29                 :            : #include "ObjectNameProvider.hxx"
      30                 :            : #include "DiagramHelper.hxx"
      31                 :            : #include "chartview/ExplicitValueProvider.hxx"
      32                 :            : #include "CommonConverters.hxx"
      33                 :            : #include <svx/ActionDescriptionProvider.hxx>
      34                 :            : 
      35                 :            : // header for define RET_OK
      36                 :            : #include <vcl/msgbox.hxx>
      37                 :            : #include <svx/svxids.hrc>
      38                 :            : #include <svx/rectenum.hxx>
      39                 :            : #include <svl/aeitem.hxx>
      40                 :            : #include <svx/svxdlg.hxx>
      41                 :            : #include <svx/dialogs.hrc>
      42                 :            : #include <vcl/svapp.hxx>
      43                 :            : #include <osl/mutex.hxx>
      44                 :            : 
      45                 :            : //.............................................................................
      46                 :            : namespace chart
      47                 :            : {
      48                 :            : //.............................................................................
      49                 :            : using namespace ::com::sun::star;
      50                 :            : using namespace ::com::sun::star::chart2;
      51                 :            : 
      52                 :            : //-----------------------------------------------------------------------------
      53                 :            : //-----------------------------------------------------------------------------
      54                 :            : 
      55                 :          0 : void lcl_getPositionAndSizeFromItemSet( const SfxItemSet& rItemSet, awt::Rectangle& rPosAndSize, const awt::Size aOriginalSize )
      56                 :            : {
      57                 :          0 :     long nPosX(0);
      58                 :          0 :     long nPosY(0);
      59                 :          0 :     long nSizX(0);
      60                 :          0 :     long nSizY(0);
      61                 :            : 
      62                 :          0 :     RECT_POINT eRP = (RECT_POINT)RP_LT;
      63                 :            : 
      64                 :          0 :     const SfxPoolItem* pPoolItem=NULL;
      65                 :            :     //read position
      66 [ #  # ][ #  # ]:          0 :     if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_X,sal_True,&pPoolItem))
      67                 :          0 :         nPosX=((const SfxInt32Item*)pPoolItem)->GetValue();
      68 [ #  # ][ #  # ]:          0 :     if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_Y,sal_True,&pPoolItem))
      69                 :          0 :         nPosY=((const SfxInt32Item*)pPoolItem)->GetValue();
      70                 :            :     //read size
      71 [ #  # ][ #  # ]:          0 :     if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_WIDTH,sal_True,&pPoolItem))
      72                 :          0 :         nSizX=((const SfxUInt32Item*)pPoolItem)->GetValue();
      73 [ #  # ][ #  # ]:          0 :     if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_HEIGHT,sal_True,&pPoolItem))
      74                 :          0 :         nSizY=((const SfxUInt32Item*)pPoolItem)->GetValue();
      75 [ #  # ][ #  # ]:          0 :     if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_SIZE_POINT,sal_True,&pPoolItem))
      76                 :          0 :         eRP=(RECT_POINT)((const SfxAllEnumItem*)pPoolItem)->GetValue();
      77                 :            : 
      78   [ #  #  #  #  :          0 :     switch( eRP )
          #  #  #  #  #  
                      # ]
      79                 :            :     {
      80                 :            :         case RP_LT:
      81                 :          0 :             break;
      82                 :            :         case RP_MT:
      83                 :          0 :             nPosX += ( aOriginalSize.Width - nSizX ) / 2;
      84                 :          0 :             break;
      85                 :            :         case RP_RT:
      86                 :          0 :             nPosX += aOriginalSize.Width - nSizX;
      87                 :          0 :             break;
      88                 :            :         case RP_LM:
      89                 :          0 :             nPosY += ( aOriginalSize.Height - nSizY ) / 2;
      90                 :          0 :             break;
      91                 :            :         case RP_MM:
      92                 :          0 :             nPosX += ( aOriginalSize.Width  - nSizX ) / 2;
      93                 :          0 :             nPosY += ( aOriginalSize.Height - nSizY ) / 2;
      94                 :          0 :             break;
      95                 :            :         case RP_RM:
      96                 :          0 :             nPosX += aOriginalSize.Width - nSizX;
      97                 :          0 :             nPosY += ( aOriginalSize.Height - nSizY ) / 2;
      98                 :          0 :             break;
      99                 :            :         case RP_LB:
     100                 :          0 :             nPosY += aOriginalSize.Height - nSizY;
     101                 :          0 :             break;
     102                 :            :         case RP_MB:
     103                 :          0 :             nPosX += ( aOriginalSize.Width - nSizX ) / 2;
     104                 :          0 :             nPosY += aOriginalSize.Height - nSizY;
     105                 :          0 :             break;
     106                 :            :         case RP_RB:
     107                 :          0 :             nPosX += aOriginalSize.Width - nSizX;
     108                 :          0 :             nPosY += aOriginalSize.Height - nSizY;
     109                 :          0 :             break;
     110                 :            :         default:
     111                 :          0 :             break;
     112                 :            :     }
     113                 :            : 
     114                 :          0 :     rPosAndSize = awt::Rectangle(nPosX,nPosY,nSizX,nSizY);
     115                 :          0 : }
     116                 :            : 
     117                 :          0 : void SAL_CALL ChartController::executeDispatch_PositionAndSize()
     118                 :            : {
     119         [ #  # ]:          0 :     const ::rtl::OUString aCID( m_aSelection.getSelectedCID() );
     120                 :            : 
     121         [ #  # ]:          0 :     if( aCID.isEmpty() )
     122                 :          0 :         return;
     123                 :            : 
     124                 :          0 :     awt::Size aSelectedSize;
     125         [ #  # ]:          0 :     ExplicitValueProvider* pProvider( ExplicitValueProvider::getExplicitValueProvider( m_xChartView ) );
     126         [ #  # ]:          0 :     if( pProvider )
     127 [ #  # ][ #  # ]:          0 :         aSelectedSize = ToSize( ( pProvider->getRectangleOfObject( aCID ) ) );
     128                 :            : 
     129         [ #  # ]:          0 :     ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID );
     130                 :            : 
     131                 :            :     UndoGuard aUndoGuard(
     132                 :            :         ActionDescriptionProvider::createDescription(
     133                 :            :             ActionDescriptionProvider::POS_SIZE,
     134                 :            :             ObjectNameProvider::getName( eObjectType)),
     135 [ #  # ][ #  # ]:          0 :         m_xUndoManager );
                 [ #  # ]
     136                 :            : 
     137                 :          0 :     SfxAbstractTabDialog * pDlg = NULL;
     138                 :            :     try
     139                 :            :     {
     140         [ #  # ]:          0 :         SfxItemSet aItemSet = m_pDrawViewWrapper->getPositionAndSizeItemSetFromMarkedObject();
     141                 :            : 
     142                 :            :         //prepare and open dialog
     143                 :          0 :         SdrView* pSdrView = m_pDrawViewWrapper;
     144         [ #  # ]:          0 :         bool bResizePossible = m_aSelection.isResizeableObjectSelected();
     145                 :            : 
     146         [ #  # ]:          0 :         SolarMutexGuard aGuard;
     147         [ #  # ]:          0 :         SvxAbstractDialogFactory * pFact = SvxAbstractDialogFactory::Create();
     148                 :            :         OSL_ENSURE( pFact, "No dialog factory" );
     149                 :            :         pDlg = pFact->CreateSchTransformTabDialog(
     150         [ #  # ]:          0 :             m_pChartWindow, &aItemSet, pSdrView, RID_SCH_TransformTabDLG_SVXPAGE_ANGLE, bResizePossible );
     151                 :            :         OSL_ENSURE( pDlg, "Couldn't create SchTransformTabDialog" );
     152                 :            : 
     153                 :            : 
     154 [ #  # ][ #  # ]:          0 :         if( pDlg->Execute() == RET_OK )
     155                 :            :         {
     156         [ #  # ]:          0 :             const SfxItemSet* pOutItemSet = pDlg->GetOutputItemSet();
     157         [ #  # ]:          0 :             if(pOutItemSet)
     158                 :            :             {
     159                 :          0 :                 awt::Rectangle aObjectRect;
     160         [ #  # ]:          0 :                 aItemSet.Put(*pOutItemSet);//overwrite old values with new values (-> all items are set)
     161         [ #  # ]:          0 :                 lcl_getPositionAndSizeFromItemSet( aItemSet, aObjectRect, aSelectedSize );
     162 [ #  # ][ #  # ]:          0 :                 awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) );
     163                 :          0 :                 awt::Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height );
     164                 :            : 
     165                 :          0 :                 bool bChanged = false;
     166         [ #  # ]:          0 :                 if ( eObjectType == OBJECTTYPE_LEGEND )
     167 [ #  # ][ #  # ]:          0 :                     bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning( getModel(), false , true );
     168                 :            : 
     169                 :          0 :                 bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID(), getModel()
     170 [ #  # ][ #  # ]:          0 :                             , aObjectRect, aPageRect );
                 [ #  # ]
     171 [ #  # ][ #  # ]:          0 :                 if( bMoved || bChanged )
     172         [ #  # ]:          0 :                     aUndoGuard.commit();
     173                 :            :             }
     174                 :            :         }
     175 [ #  # ][ #  # ]:          0 :         delete pDlg;
         [ #  # ][ #  # ]
     176                 :            :     }
     177   [ #  #  #  # ]:          0 :     catch(const uno::Exception& e)
     178                 :            :     {
     179   [ #  #  #  # ]:          0 :         delete pDlg;
     180                 :            :         ASSERT_EXCEPTION( e );
     181 [ #  # ][ #  # ]:          0 :     }
     182                 :            : }
     183                 :            : 
     184                 :            : //.............................................................................
     185                 :            : } //namespace chart
     186                 :            : //.............................................................................
     187                 :            : 
     188                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10