LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - fuconcustomshape.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 99 0.0 %
Date: 2012-08-25 Functions: 0 12 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 122 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                 :            : #include "fuconcustomshape.hxx"
      31                 :            : #include <editeng/svxenum.hxx>
      32                 :            : #include <svx/gallery.hxx>
      33                 :            : #include <sfx2/request.hxx>
      34                 :            : #include <svx/fmmodel.hxx>
      35                 :            : #include <svl/itempool.hxx>
      36                 :            : #include <svx/svdpage.hxx>
      37                 :            : #include <svx/svdoashp.hxx>
      38                 :            : #include <editeng/eeitem.hxx>
      39                 :            : #include <svx/sdtagitm.hxx>
      40                 :            : #include "fuconuno.hxx"
      41                 :            : #include "tabvwsh.hxx"
      42                 :            : #include "sc.hrc"
      43                 :            : #include "drawview.hxx"
      44                 :            : #include <editeng/adjitem.hxx>
      45                 :            : 
      46                 :            : #include <math.h>
      47                 :            : 
      48                 :            : //------------------------------------------------------------------------
      49                 :            : 
      50                 :          0 : FuConstCustomShape::FuConstCustomShape( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, SdrModel* pDoc, SfxRequest& rReq )
      51                 :          0 :     : FuConstruct( pViewSh, pWin, pViewP, pDoc, rReq )
      52                 :            : {
      53                 :          0 :     const SfxItemSet* pArgs = rReq.GetArgs();
      54         [ #  # ]:          0 :     if ( pArgs )
      55                 :            :     {
      56         [ #  # ]:          0 :         const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() );
      57         [ #  # ]:          0 :         aCustomShape = rItm.GetValue();
      58                 :            :     }
      59                 :          0 : }
      60                 :            : 
      61                 :            : /*************************************************************************
      62                 :            : |*
      63                 :            : |* Destruktor
      64                 :            : |*
      65                 :            : \************************************************************************/
      66                 :            : 
      67                 :          0 : FuConstCustomShape::~FuConstCustomShape()
      68                 :            : {
      69         [ #  # ]:          0 : }
      70                 :            : 
      71                 :            : /*************************************************************************
      72                 :            : |*
      73                 :            : |* MouseButtonDown-event
      74                 :            : |*
      75                 :            : \************************************************************************/
      76                 :            : 
      77                 :          0 : sal_Bool FuConstCustomShape::MouseButtonDown(const MouseEvent& rMEvt)
      78                 :            : {
      79                 :            :     // remember button state for creation of own MouseEvents
      80                 :          0 :     SetMouseButtonCode(rMEvt.GetButtons());
      81                 :            : 
      82                 :          0 :     sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
      83 [ #  # ][ #  # ]:          0 :     if ( rMEvt.IsLeft() && !pView->IsAction() )
                 [ #  # ]
      84                 :            :     {
      85         [ #  # ]:          0 :         Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
      86         [ #  # ]:          0 :         pWindow->CaptureMouse();
      87         [ #  # ]:          0 :         pView->BegCreateObj(aPnt);
      88                 :            : 
      89                 :          0 :         SdrObject* pObj = pView->GetCreateObj();
      90         [ #  # ]:          0 :         if ( pObj )
      91                 :            :         {
      92         [ #  # ]:          0 :             SetAttributes( pObj );
      93                 :          0 :             sal_Bool bForceNoFillStyle = false;
      94 [ #  # ][ #  # ]:          0 :             if ( ((SdrObjCustomShape*)pObj)->UseNoFillStyle() )
      95                 :          0 :                 bForceNoFillStyle = sal_True;
      96         [ #  # ]:          0 :             if ( bForceNoFillStyle )
      97 [ #  # ][ #  # ]:          0 :                 pObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) );
                 [ #  # ]
      98                 :            :         }
      99                 :            : 
     100                 :          0 :         bReturn = sal_True;
     101                 :            :     }
     102                 :          0 :     return bReturn;
     103                 :            : }
     104                 :            : 
     105                 :            : /*************************************************************************
     106                 :            : |*
     107                 :            : |* MouseMove-event
     108                 :            : |*
     109                 :            : \************************************************************************/
     110                 :            : 
     111                 :          0 : sal_Bool FuConstCustomShape::MouseMove(const MouseEvent& rMEvt)
     112                 :            : {
     113                 :          0 :     return FuConstruct::MouseMove(rMEvt);
     114                 :            : }
     115                 :            : 
     116                 :            : /*************************************************************************
     117                 :            : |*
     118                 :            : |* MouseButtonUp-event
     119                 :            : |*
     120                 :            : \************************************************************************/
     121                 :            : 
     122                 :          0 : sal_Bool FuConstCustomShape::MouseButtonUp(const MouseEvent& rMEvt)
     123                 :            : {
     124                 :            :     // remember button state for creation of own MouseEvents
     125                 :          0 :     SetMouseButtonCode(rMEvt.GetButtons());
     126                 :            : 
     127                 :          0 :     sal_Bool bReturn = false;
     128                 :            : 
     129 [ #  # ][ #  # ]:          0 :     if ( pView->IsCreateObj() && rMEvt.IsLeft() )
                 [ #  # ]
     130                 :            :     {
     131                 :          0 :         pView->EndCreateObj(SDRCREATE_FORCEEND);
     132                 :          0 :         bReturn = sal_True;
     133                 :            :     }
     134 [ #  # ][ #  # ]:          0 :     return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
     135                 :            : }
     136                 :            : 
     137                 :            : /*************************************************************************
     138                 :            : |*
     139                 :            : |* Tastaturereignisse bearbeiten
     140                 :            : |*
     141                 :            : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
     142                 :            : |* FALSE.
     143                 :            : |*
     144                 :            : \************************************************************************/
     145                 :            : 
     146                 :          0 : sal_Bool FuConstCustomShape::KeyInput(const KeyEvent& rKEvt)
     147                 :            : {
     148                 :          0 :     sal_Bool bReturn = FuConstruct::KeyInput(rKEvt);
     149                 :          0 :     return(bReturn);
     150                 :            : }
     151                 :            : 
     152                 :            : /*************************************************************************
     153                 :            : |*
     154                 :            : |* Function aktivieren
     155                 :            : |*
     156                 :            : \************************************************************************/
     157                 :            : 
     158                 :          0 : void FuConstCustomShape::Activate()
     159                 :            : {
     160                 :          0 :     pView->SetCurrentObj( OBJ_CUSTOMSHAPE, SdrInventor );
     161                 :            : 
     162                 :          0 :     aNewPointer = Pointer( POINTER_DRAW_RECT );
     163                 :          0 :     aOldPointer = pWindow->GetPointer();
     164                 :          0 :     pViewShell->SetActivePointer( aNewPointer );
     165                 :            : 
     166                 :          0 :     SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_CONTROLS);
     167         [ #  # ]:          0 :     if (pLayer)
     168                 :          0 :         pView->SetActiveLayer( pLayer->GetName() );
     169                 :            : 
     170                 :          0 :     FuConstruct::Activate();
     171                 :          0 : }
     172                 :            : 
     173                 :            : /*************************************************************************
     174                 :            : |*
     175                 :            : |* Function deaktivieren
     176                 :            : |*
     177                 :            : \************************************************************************/
     178                 :            : 
     179                 :          0 : void FuConstCustomShape::Deactivate()
     180                 :            : {
     181                 :          0 :     FuConstruct::Deactivate();
     182                 :            : 
     183                 :          0 :     SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_FRONT);
     184         [ #  # ]:          0 :     if (pLayer)
     185                 :          0 :         pView->SetActiveLayer( pLayer->GetName() );
     186                 :            : 
     187                 :          0 :     pViewShell->SetActivePointer( aOldPointer );
     188                 :          0 : }
     189                 :            : 
     190                 :            : // Create default drawing objects via keyboard
     191                 :          0 : SdrObject* FuConstCustomShape::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& rRectangle)
     192                 :            : {
     193                 :            :     SdrObject* pObj = SdrObjFactory::MakeNewObject(
     194                 :          0 :         pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
     195                 :          0 :         0L, pDrDoc);
     196         [ #  # ]:          0 :     if( pObj )
     197                 :            :     {
     198                 :          0 :         Rectangle aRectangle( rRectangle );
     199         [ #  # ]:          0 :         SetAttributes( pObj );
     200 [ #  # ][ #  # ]:          0 :         if ( SdrObjCustomShape::doConstructOrthogonal( aCustomShape ) )
     201         [ #  # ]:          0 :             ImpForceQuadratic( aRectangle );
     202         [ #  # ]:          0 :         pObj->SetLogicRect( aRectangle );
     203                 :            :     }
     204                 :          0 :     return pObj;
     205                 :            : }
     206                 :            : 
     207                 :            : /*************************************************************************
     208                 :            : |*
     209                 :            : |* applying attributes
     210                 :            : |*
     211                 :            : \************************************************************************/
     212                 :            : 
     213                 :          0 : void FuConstCustomShape::SetAttributes( SdrObject* pObj )
     214                 :            : {
     215                 :          0 :     sal_Bool bAttributesAppliedFromGallery = false;
     216                 :            : 
     217         [ #  # ]:          0 :     if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
     218                 :            :     {
     219         [ #  # ]:          0 :         std::vector< rtl::OUString > aObjList;
     220 [ #  # ][ #  # ]:          0 :         if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
     221                 :            :         {
     222                 :            :             sal_uInt16 i;
     223         [ #  # ]:          0 :             for ( i = 0; i < aObjList.size(); i++ )
     224                 :            :             {
     225         [ #  # ]:          0 :                 if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) )
     226                 :            :                 {
     227         [ #  # ]:          0 :                     FmFormModel aFormModel;
     228                 :          0 :                     SfxItemPool& rPool = aFormModel.GetItemPool();
     229         [ #  # ]:          0 :                     rPool.FreezeIdRanges();
     230 [ #  # ][ #  # ]:          0 :                     if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) )
     231                 :            :                     {
     232 [ #  # ][ #  # ]:          0 :                         const SdrObject* pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 );
     233         [ #  # ]:          0 :                         if( pSourceObj )
     234                 :            :                         {
     235         [ #  # ]:          0 :                             const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
     236         [ #  # ]:          0 :                             SfxItemSet aDest( pObj->GetModel()->GetItemPool(),              // ranges from SdrAttrObj
     237                 :            :                             SDRATTR_START, SDRATTR_SHADOW_LAST,
     238                 :            :                             SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
     239                 :            :                             SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
     240                 :            :                             // Graphic Attributes
     241                 :            :                             SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
     242                 :            :                             // 3d Properties
     243                 :            :                             SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
     244                 :            :                             // CustomShape properties
     245                 :            :                             SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
     246                 :            :                             // range from SdrTextObj
     247                 :            :                             EE_ITEMS_START, EE_ITEMS_END,
     248                 :            :                             // end
     249         [ #  # ]:          0 :                             0, 0);
     250         [ #  # ]:          0 :                             aDest.Set( rSource );
     251         [ #  # ]:          0 :                             pObj->SetMergedItemSet( aDest );
     252         [ #  # ]:          0 :                             sal_Int32 nAngle = pSourceObj->GetRotateAngle();
     253         [ #  # ]:          0 :                             if ( nAngle )
     254                 :            :                             {
     255                 :          0 :                                 double a = nAngle * F_PI18000;
     256 [ #  # ][ #  # ]:          0 :                                 pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
                 [ #  # ]
     257                 :            :                             }
     258         [ #  # ]:          0 :                             bAttributesAppliedFromGallery = sal_True;
     259                 :            :                         }
     260                 :            :                     }
     261         [ #  # ]:          0 :                     break;
     262                 :            :                 }
     263                 :            :             }
     264                 :          0 :         }
     265                 :            :     }
     266         [ #  # ]:          0 :     if ( !bAttributesAppliedFromGallery )
     267                 :            :     {
     268         [ #  # ]:          0 :         pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, 0 ) );
     269         [ #  # ]:          0 :         pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
     270         [ #  # ]:          0 :         pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
     271         [ #  # ]:          0 :         pObj->SetMergedItem( SdrTextAutoGrowHeightItem( false ) );
     272                 :          0 :         ((SdrObjCustomShape*)pObj)->MergeDefaultAttributes( &aCustomShape );
     273                 :            :     }
     274                 :          0 : }
     275                 :            : 
     276                 :            : // #i33136#
     277                 :          0 : bool FuConstCustomShape::doConstructOrthogonal() const
     278                 :            : {
     279                 :          0 :     return SdrObjCustomShape::doConstructOrthogonal(aCustomShape);
     280                 :            : }
     281                 :            : 
     282                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10