LCOV - code coverage report
Current view: top level - sd/source/ui/view - drviewsc.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 32 84 38.1 %
Date: 2015-06-13 12:38:46 Functions: 6 10 60.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 "DrawViewShell.hxx"
      21             : #include "ViewShellImplementation.hxx"
      22             : #include <vcl/waitobj.hxx>
      23             : 
      24             : #include <svx/svxids.hrc>
      25             : #include <svx/dialogs.hrc>
      26             : #include <svx/imapdlg.hxx>
      27             : #include <vcl/msgbox.hxx>
      28             : #include <sfx2/request.hxx>
      29             : #include <svx/svdogrp.hxx>
      30             : #include <svx/svdoole2.hxx>
      31             : #include <svx/svdograf.hxx>
      32             : #include <svx/svxdlg.hxx>
      33             : #include <sfx2/bindings.hxx>
      34             : #include <sfx2/dispatch.hxx>
      35             : #include <svl/style.hxx>
      36             : #include <svx/svdpagv.hxx>
      37             : #include <svx/grafctrl.hxx>
      38             : #include "stlsheet.hxx"
      39             : 
      40             : #include <sfx2/viewfrm.hxx>
      41             : 
      42             : #include "app.hrc"
      43             : #include "strings.hrc"
      44             : #include "helpids.h"
      45             : #include "Window.hxx"
      46             : #include "imapinfo.hxx"
      47             : #include "sdresid.hxx"
      48             : #include "drawdoc.hxx"
      49             : #include "DrawDocShell.hxx"
      50             : #include "drawview.hxx"
      51             : #include "sdabstdlg.hxx"
      52             : namespace sd {
      53             : 
      54             : /**
      55             :  * Returns the global/main ID, i.e. the ID, which is used to execute the toolbox
      56             :  */
      57        4748 : sal_uInt16 DrawViewShell::GetIdBySubId( sal_uInt16 nSId )
      58             : {
      59        4748 :     sal_uInt16 nMappedSId = 0;
      60        4748 :     switch( nSId )
      61             :     {
      62             :         case SID_OBJECT_ROTATE:
      63             :         case SID_OBJECT_MIRROR:
      64             :         case SID_OBJECT_TRANSPARENCE:
      65             :         case SID_OBJECT_GRADIENT:
      66             :         case SID_OBJECT_SHEAR:
      67             :         case SID_OBJECT_CROOK_ROTATE:
      68             :         case SID_OBJECT_CROOK_SLANT:
      69             :         case SID_OBJECT_CROOK_STRETCH:
      70             :         case SID_CONVERT_TO_3D_LATHE:
      71             :         {
      72           0 :             nMappedSId = SID_OBJECT_CHOOSE_MODE;
      73             :         }
      74           0 :         break;
      75             : 
      76             :         case SID_OBJECT_ALIGN_LEFT:
      77             :         case SID_OBJECT_ALIGN_CENTER:
      78             :         case SID_OBJECT_ALIGN_RIGHT:
      79             :         case SID_OBJECT_ALIGN_UP:
      80             :         case SID_OBJECT_ALIGN_MIDDLE:
      81             :         case SID_OBJECT_ALIGN_DOWN:
      82             :         {
      83           0 :             nMappedSId = SID_OBJECT_ALIGN;
      84             :         }
      85           0 :         break;
      86             : 
      87             :         case SID_FRAME_TO_TOP:
      88             :         case SID_MOREFRONT:
      89             :         case SID_MOREBACK:
      90             :         case SID_FRAME_TO_BOTTOM:
      91             :         case SID_BEFORE_OBJ:
      92             :         case SID_BEHIND_OBJ:
      93             :         case SID_REVERSE_ORDER:
      94             :         {
      95           0 :             nMappedSId = SID_POSITION;
      96             :         }
      97           0 :         break;
      98             : 
      99             :         case SID_ZOOM_OUT:
     100             :         case SID_ZOOM_IN:
     101             :         case SID_SIZE_REAL:
     102             :         case SID_ZOOM_PANNING:
     103             :         case SID_SIZE_PAGE:
     104             :         case SID_SIZE_PAGE_WIDTH:
     105             :         case SID_SIZE_ALL:
     106             :         case SID_SIZE_OPTIMAL:
     107             :         case SID_ZOOM_NEXT:
     108             :         case SID_ZOOM_PREV:
     109             :         case SID_ZOOM_MODE:
     110             :         {
     111         427 :             nMappedSId = SID_ZOOM_TOOLBOX;
     112             :         }
     113         427 :         break;
     114             : 
     115             :         case SID_ATTR_CHAR:
     116             :         case SID_TEXT_FITTOSIZE:
     117             :         case SID_DRAW_CAPTION:
     118             :         case SID_DRAW_FONTWORK:
     119             :         case SID_DRAW_FONTWORK_VERTICAL:
     120             :         {
     121           2 :             nMappedSId = SID_DRAWTBX_TEXT;
     122             :         }
     123           2 :         break;
     124             : 
     125             :         case SID_DRAW_RECT:
     126             :         case SID_DRAW_SQUARE:
     127             :         case SID_DRAW_RECT_ROUND:
     128             :         case SID_DRAW_SQUARE_ROUND:
     129             :         case SID_DRAW_RECT_NOFILL:
     130             :         case SID_DRAW_SQUARE_NOFILL:
     131             :         case SID_DRAW_RECT_ROUND_NOFILL:
     132             :         case SID_DRAW_SQUARE_ROUND_NOFILL:
     133             :         {
     134           0 :             nMappedSId = SID_DRAWTBX_RECTANGLES;
     135             :         }
     136           0 :         break;
     137             : 
     138             :         case SID_DRAW_ELLIPSE:
     139             :         case SID_DRAW_CIRCLE:
     140             :         case SID_DRAW_PIE:
     141             :         case SID_DRAW_CIRCLEPIE:
     142             :         case SID_DRAW_ELLIPSECUT:
     143             :         case SID_DRAW_CIRCLECUT:
     144             :         case SID_DRAW_ARC:
     145             :         case SID_DRAW_CIRCLEARC:
     146             :         case SID_DRAW_ELLIPSE_NOFILL:
     147             :         case SID_DRAW_CIRCLE_NOFILL:
     148             :         case SID_DRAW_PIE_NOFILL:
     149             :         case SID_DRAW_CIRCLEPIE_NOFILL:
     150             :         case SID_DRAW_ELLIPSECUT_NOFILL:
     151             :         case SID_DRAW_CIRCLECUT_NOFILL:
     152             :         {
     153           0 :             nMappedSId = SID_DRAWTBX_ELLIPSES;
     154             :         }
     155           0 :         break;
     156             : 
     157             :         case SID_DRAW_BEZIER_NOFILL:
     158             :         case SID_DRAW_POLYGON_NOFILL:
     159             :         case SID_DRAW_XPOLYGON_NOFILL:
     160             :         case SID_DRAW_FREELINE_NOFILL:
     161             :         case SID_DRAW_BEZIER_FILL:
     162             :         case SID_DRAW_POLYGON:
     163             :         case SID_DRAW_XPOLYGON:
     164             :         case SID_DRAW_FREELINE:
     165             :         {
     166           0 :             nMappedSId = SID_DRAWTBX_LINES;
     167             :         }
     168           0 :         break;
     169             : 
     170             :         case SID_DRAW_LINE:
     171             :         case SID_DRAW_XLINE:
     172             :         case SID_DRAW_MEASURELINE:
     173             :         case SID_LINE_ARROW_START:
     174             :         case SID_LINE_ARROW_END:
     175             :         case SID_LINE_ARROWS:
     176             :         case SID_LINE_ARROW_CIRCLE:
     177             :         case SID_LINE_CIRCLE_ARROW:
     178             :         case SID_LINE_ARROW_SQUARE:
     179             :         case SID_LINE_SQUARE_ARROW:
     180             :         {
     181           0 :             nMappedSId = SID_DRAWTBX_ARROWS;
     182             :         }
     183           0 :         break;
     184             : 
     185             :         case SID_3D_CUBE:
     186             :         case SID_3D_TORUS:
     187             :         case SID_3D_SPHERE:
     188             :         case SID_3D_SHELL:
     189             :         case SID_3D_HALF_SPHERE:
     190             :         case SID_3D_CYLINDER:
     191             :         case SID_3D_CONE:
     192             :         case SID_3D_PYRAMID:
     193             :         {
     194           0 :             nMappedSId = SID_DRAWTBX_3D_OBJECTS;
     195             :         }
     196           0 :         break;
     197             : 
     198             :         case SID_INSERT_DIAGRAM:
     199             :         case SID_ATTR_TABLE:
     200             :         case SID_INSERTFILE:
     201             :         case SID_INSERT_GRAPHIC:
     202             :         case SID_INSERT_AVMEDIA:
     203             :         case SID_INSERTPAGE:
     204             :         case SID_INSERT_MATH:
     205             :         case SID_INSERT_FLOATINGFRAME:
     206             :         case SID_INSERT_OBJECT:
     207             :         case SID_INSERT_PLUGIN:
     208             :         case SID_INSERT_SOUND:
     209             :         case SID_INSERT_VIDEO:
     210             :         case SID_INSERT_TABLE:
     211             :         {
     212           0 :             nMappedSId = SID_DRAWTBX_INSERT;
     213             :         }
     214           0 :         break;
     215             : 
     216             :         case SID_TOOL_CONNECTOR:
     217             :         case SID_CONNECTOR_ARROW_START:
     218             :         case SID_CONNECTOR_ARROW_END:
     219             :         case SID_CONNECTOR_ARROWS:
     220             :         case SID_CONNECTOR_CIRCLE_START:
     221             :         case SID_CONNECTOR_CIRCLE_END:
     222             :         case SID_CONNECTOR_CIRCLES:
     223             :         case SID_CONNECTOR_LINE:
     224             :         case SID_CONNECTOR_LINE_ARROW_START:
     225             :         case SID_CONNECTOR_LINE_ARROW_END:
     226             :         case SID_CONNECTOR_LINE_ARROWS:
     227             :         case SID_CONNECTOR_LINE_CIRCLE_START:
     228             :         case SID_CONNECTOR_LINE_CIRCLE_END:
     229             :         case SID_CONNECTOR_LINE_CIRCLES:
     230             :         case SID_CONNECTOR_CURVE:
     231             :         case SID_CONNECTOR_CURVE_ARROW_START:
     232             :         case SID_CONNECTOR_CURVE_ARROW_END:
     233             :         case SID_CONNECTOR_CURVE_ARROWS:
     234             :         case SID_CONNECTOR_CURVE_CIRCLE_START:
     235             :         case SID_CONNECTOR_CURVE_CIRCLE_END:
     236             :         case SID_CONNECTOR_CURVE_CIRCLES:
     237             :         case SID_CONNECTOR_LINES:
     238             :         case SID_CONNECTOR_LINES_ARROW_START:
     239             :         case SID_CONNECTOR_LINES_ARROW_END:
     240             :         case SID_CONNECTOR_LINES_ARROWS:
     241             :         case SID_CONNECTOR_LINES_CIRCLE_START:
     242             :         case SID_CONNECTOR_LINES_CIRCLE_END:
     243             :         case SID_CONNECTOR_LINES_CIRCLES:
     244             :         {
     245           0 :             nMappedSId = SID_DRAWTBX_CONNECTORS;
     246             :         }
     247             :     }
     248        4748 :     return nMappedSId;
     249             : }
     250             : 
     251             : /**
     252             :  * Fills the SlotArray in order to get the current mapping of the ToolboxSlots
     253             :  */
     254         574 : void DrawViewShell::MapSlot( sal_uInt16 nSId )
     255             : {
     256         574 :     sal_uInt16 nMappedSId = GetIdBySubId( nSId );
     257             : 
     258         574 :     if( nMappedSId > 0 )
     259             :     {
     260         429 :         sal_uInt16 nID = GetArrayId( nMappedSId ) + 1;
     261         429 :         mpSlotArray[ nID ] = nSId;
     262             :     }
     263         574 : }
     264             : 
     265             : /**
     266             :  * Allows a ImageMapping via SlotArray
     267             :  */
     268        8349 : void DrawViewShell::UpdateToolboxImages( SfxItemSet &rSet, bool bPermanent )
     269             : {
     270        8349 :     if( !bPermanent )
     271             :     {
     272        4175 :         sal_uInt16 nId = GetArrayId( SID_ZOOM_TOOLBOX ) + 1;
     273        4175 :         rSet.Put( TbxImageItem( SID_ZOOM_TOOLBOX, mpSlotArray[nId] ) );
     274             : 
     275        4175 :         nId = GetArrayId( SID_DRAWTBX_INSERT ) + 1;
     276        4175 :         rSet.Put( TbxImageItem( SID_DRAWTBX_INSERT, mpSlotArray[nId] ) );
     277             : 
     278        4175 :         nId = GetArrayId( SID_POSITION ) + 1;
     279        4175 :         rSet.Put( TbxImageItem( SID_POSITION, mpSlotArray[nId] ) );
     280             : 
     281        4175 :         nId = GetArrayId( SID_OBJECT_ALIGN ) + 1;
     282        4175 :         rSet.Put( TbxImageItem( SID_OBJECT_ALIGN, mpSlotArray[nId] ) );
     283             :     }
     284             :     else
     285             :     {
     286       54262 :         for( sal_uInt16 nId = 0; nId < SLOTARRAY_COUNT; nId += 2 )
     287             :         {
     288       50088 :             rSet.Put( TbxImageItem( mpSlotArray[nId], mpSlotArray[nId+1] ) );
     289             :         }
     290             :     }
     291        8349 : }
     292             : 
     293           0 : sal_uInt16 DrawViewShell::GetMappedSlot( sal_uInt16 nSId )
     294             : {
     295           0 :     sal_uInt16 nSlot = 0;
     296           0 :     sal_uInt16 nId = GetArrayId( nSId );
     297           0 :     if( nId != USHRT_MAX )
     298           0 :         nSlot = mpSlotArray[ nId+1 ];
     299             : 
     300             :     /* If the slot is mapped to itself, we have to return 0. Otherwise the slot
     301             :        would be executed over and over again. The slot is initial available in
     302             :        the array in order to show the image correct.  */
     303           0 :     if( nSId == nSlot )
     304           0 :         return 0;
     305             : 
     306           0 :     return nSlot;
     307             : }
     308             : 
     309             : /**
     310             :  * @returns number of the main slot in the slot array
     311             :  */
     312       17129 : sal_uInt16 DrawViewShell::GetArrayId( sal_uInt16 nSId )
     313             : {
     314      101489 :     for( sal_uInt16 i = 0; i < SLOTARRAY_COUNT; i += 2 )
     315             :     {
     316      101489 :         if( mpSlotArray[ i ] == nSId )
     317       17129 :             return i;
     318             :     }
     319             :     OSL_FAIL( "Slot in array not found!" );
     320           0 :     return USHRT_MAX;
     321             : }
     322             : 
     323           0 : void DrawViewShell::UpdateIMapDlg( SdrObject* pObj )
     324             : {
     325           0 :     if( ( pObj->ISA( SdrGrafObj ) || pObj->ISA( SdrOle2Obj ) ) && !mpDrawView->IsTextEdit() &&
     326           0 :          GetViewFrame()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
     327             :     {
     328           0 :         Graphic     aGraphic;
     329           0 :         ImageMap*   pIMap = NULL;
     330           0 :         TargetList* pTargetList = NULL;
     331           0 :         SdIMapInfo* pIMapInfo = GetDoc()->GetIMapInfo( pObj );
     332             : 
     333             :         // get graphic from shape
     334           0 :         SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >( pObj );
     335           0 :         if( pGrafObj )
     336           0 :             aGraphic = pGrafObj->GetGraphic();
     337             : 
     338           0 :         if ( pIMapInfo )
     339             :         {
     340           0 :             pIMap = const_cast<ImageMap*>(&pIMapInfo->GetImageMap());
     341           0 :             pTargetList = new TargetList;
     342           0 :             GetViewFrame()->GetTargetList( *pTargetList );
     343             :         }
     344             : 
     345           0 :         SvxIMapDlgChildWindow::UpdateIMapDlg( aGraphic, pIMap, pTargetList, pObj );
     346             : 
     347             :         // We can delete the target list
     348           0 :         if ( pTargetList )
     349             :         {
     350           0 :             delete pTargetList;
     351           0 :         }
     352             :     }
     353           0 : }
     354             : 
     355           0 : IMPL_LINK( DrawViewShell, NameObjectHdl, AbstractSvxNameDialog*, pDialog )
     356             : {
     357           0 :     OUString aName;
     358             : 
     359           0 :     if( pDialog )
     360           0 :         pDialog->GetName( aName );
     361             : 
     362           0 :     return ( aName.isEmpty() || ( GetDoc() && !GetDoc()->GetObj( aName ) ) ) ? 1 : 0;
     363             : }
     364             : 
     365          66 : } // end of namespace sd
     366             : 
     367             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11