LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/ribbar - concustomshape.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 79 0.0 %
Date: 2012-12-27 Functions: 0 9 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 <sfx2/bindings.hxx>
      21             : #include <svx/htmlmode.hxx>
      22             : #include <svx/sdtacitm.hxx>
      23             : #include <svx/svdobj.hxx>
      24             : #include <svx/sdtagitm.hxx>
      25             : #include <svx/sdtakitm.hxx>
      26             : #include <svx/sdtaditm.hxx>
      27             : #include <svx/sdtaaitm.hxx>
      28             : #include <svx/svdview.hxx>
      29             : #include <svx/svdocapt.hxx>
      30             : #include <editeng/outlobj.hxx>
      31             : #include <cmdid.h>
      32             : #include <view.hxx>
      33             : #include <edtwin.hxx>
      34             : #include <wrtsh.hxx>
      35             : #include <viewopt.hxx>
      36             : #include <drawbase.hxx>
      37             : #include <concustomshape.hxx>
      38             : #include <svx/gallery.hxx>
      39             : #include <sfx2/request.hxx>
      40             : #include <svx/fmmodel.hxx>
      41             : #include <svl/itempool.hxx>
      42             : #include <svx/svdpage.hxx>
      43             : #include <svx/svdoashp.hxx>
      44             : #include <editeng/adjitem.hxx>
      45             : 
      46             : #include <math.h>
      47             : 
      48             : /*************************************************************************
      49             : |*
      50             : |* C'Tor
      51             : |*
      52             : \************************************************************************/
      53           0 : ConstCustomShape::ConstCustomShape( SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView, SfxRequest& rReq )
      54           0 :     : SwDrawBase( pWrtShell, pEditWin, pSwView )
      55             : {
      56           0 :     aCustomShape = ConstCustomShape::GetShapeTypeFromRequest( rReq );
      57           0 : }
      58             : 
      59           0 : rtl::OUString ConstCustomShape::GetShapeType() const
      60             : {
      61           0 :     return aCustomShape;
      62             : }
      63             : 
      64             : //static
      65           0 : rtl::OUString ConstCustomShape::GetShapeTypeFromRequest( SfxRequest& rReq )
      66             : {
      67           0 :     rtl::OUString aRet;
      68           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
      69           0 :     if ( pArgs )
      70             :     {
      71           0 :         const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() );
      72           0 :         aRet = rItm.GetValue();
      73             :     }
      74           0 :     return aRet;
      75             : }
      76             : 
      77             : /*************************************************************************
      78             : |*
      79             : |* MouseButtonDown-event
      80             : |*
      81             : \************************************************************************/
      82             : 
      83           0 : sal_Bool ConstCustomShape::MouseButtonDown(const MouseEvent& rMEvt)
      84             : {
      85           0 :     sal_Bool bReturn = SwDrawBase::MouseButtonDown(rMEvt);
      86           0 :     if ( bReturn )
      87             :     {
      88           0 :         SdrView *pSdrView = m_pSh->GetDrawView();
      89           0 :         if ( pSdrView )
      90             :         {
      91           0 :             SdrObject* pObj = pSdrView->GetCreateObj();
      92           0 :             if ( pObj )
      93             :             {
      94           0 :                 SetAttributes( pObj );
      95           0 :                 sal_Bool bForceNoFillStyle = sal_False;
      96           0 :                 if ( ((SdrObjCustomShape*)pObj)->UseNoFillStyle() )
      97           0 :                     bForceNoFillStyle = sal_True;
      98             : 
      99           0 :                 SfxItemSet aAttr( m_pView->GetPool() );
     100           0 :                 if ( bForceNoFillStyle )
     101           0 :                     aAttr.Put( XFillStyleItem( XFILL_NONE ) );
     102           0 :                 pObj->SetMergedItemSet(aAttr);
     103             :             }
     104             :         }
     105             :     }
     106           0 :     return bReturn;
     107             : }
     108             : 
     109             : /*************************************************************************
     110             : |*
     111             : |* MouseButtonUp-event
     112             : |*
     113             : \************************************************************************/
     114             : 
     115           0 : sal_Bool ConstCustomShape::MouseButtonUp(const MouseEvent& rMEvt)
     116             : {
     117           0 :     return SwDrawBase::MouseButtonUp(rMEvt);
     118             : }
     119             : 
     120             : /*************************************************************************
     121             : |*
     122             : |* activate function
     123             : |*
     124             : \************************************************************************/
     125             : 
     126           0 : void ConstCustomShape::Activate(const sal_uInt16 nSlotId)
     127             : {
     128           0 :     m_pWin->SetSdrDrawMode( OBJ_CUSTOMSHAPE );
     129             : 
     130           0 :     SwDrawBase::Activate(nSlotId);
     131           0 : }
     132             : 
     133             : /*************************************************************************
     134             : |*
     135             : |* applying attributes
     136             : |*
     137             : \************************************************************************/
     138             : 
     139           0 : void ConstCustomShape::SetAttributes( SdrObject* pObj )
     140             : {
     141           0 :     sal_Bool bAttributesAppliedFromGallery = sal_False;
     142             : 
     143           0 :     if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
     144             :     {
     145           0 :         std::vector< rtl::OUString > aObjList;
     146           0 :         if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
     147             :         {
     148             :             sal_uInt16 i;
     149           0 :             for ( i = 0; i < aObjList.size(); i++ )
     150             :             {
     151           0 :                 if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) )
     152             :                 {
     153           0 :                     FmFormModel aFormModel;
     154           0 :                     SfxItemPool& rPool = aFormModel.GetItemPool();
     155           0 :                     rPool.FreezeIdRanges();
     156           0 :                     if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) )
     157             :                     {
     158           0 :                         const SdrObject* pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 );
     159           0 :                         if( pSourceObj )
     160             :                         {
     161           0 :                             const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
     162           0 :                             SfxItemSet aDest( pObj->GetModel()->GetItemPool(),              // ranges from SdrAttrObj
     163             :                             SDRATTR_START, SDRATTR_SHADOW_LAST,
     164             :                             SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
     165             :                             SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
     166             :                             // Graphic Attributes
     167             :                             SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
     168             :                             // 3d Properties
     169             :                             SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
     170             :                             // CustomShape properties
     171             :                             SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
     172             :                             // range from SdrTextObj
     173             :                             EE_ITEMS_START, EE_ITEMS_END,
     174             :                             // end
     175           0 :                             0, 0);
     176           0 :                             aDest.Set( rSource );
     177           0 :                             pObj->SetMergedItemSet( aDest );
     178           0 :                             sal_Int32 nAngle = pSourceObj->GetRotateAngle();
     179           0 :                             if ( nAngle )
     180             :                             {
     181           0 :                                 double a = nAngle * F_PI18000;
     182           0 :                                 pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
     183             :                             }
     184           0 :                             bAttributesAppliedFromGallery = sal_True;
     185             :                         }
     186             :                     }
     187           0 :                     break;
     188             :                 }
     189             :             }
     190           0 :         }
     191             :     }
     192           0 :     if ( !bAttributesAppliedFromGallery )
     193             :     {
     194           0 :         pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, RES_PARATR_ADJUST ) );
     195           0 :         pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
     196           0 :         pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
     197           0 :         pObj->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) );
     198           0 :         ((SdrObjCustomShape*)pObj)->MergeDefaultAttributes( &aCustomShape );
     199             :     }
     200           0 : }
     201             : 
     202           0 : void ConstCustomShape::CreateDefaultObject()
     203             : {
     204           0 :     SwDrawBase::CreateDefaultObject();
     205           0 :     SdrView *pSdrView = m_pSh->GetDrawView();
     206           0 :     if ( pSdrView )
     207             :     {
     208           0 :         const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
     209           0 :         if ( rMarkList.GetMarkCount() == 1 )
     210             :         {
     211           0 :             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     212           0 :             if ( pObj && pObj->ISA( SdrObjCustomShape ) )
     213           0 :                 SetAttributes( pObj );
     214             :         }
     215             :     }
     216           0 : }
     217             : 
     218             : // #i33136#
     219           0 : bool ConstCustomShape::doConstructOrthogonal() const
     220             : {
     221           0 :     return SdrObjCustomShape::doConstructOrthogonal(aCustomShape);
     222             : }
     223             : 
     224             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10