LCOV - code coverage report
Current view: top level - sw/source/core/uibase/ribbar - concustomshape.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 79 0.0 %
Date: 2014-04-14 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 <sfx2/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/adjustitem.hxx>
      45             : 
      46             : #include <math.h>
      47             : 
      48           0 : ConstCustomShape::ConstCustomShape( SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView, SfxRequest& rReq )
      49           0 :     : SwDrawBase( pWrtShell, pEditWin, pSwView )
      50             : {
      51           0 :     aCustomShape = ConstCustomShape::GetShapeTypeFromRequest( rReq );
      52           0 : }
      53             : 
      54           0 : OUString ConstCustomShape::GetShapeType() const
      55             : {
      56           0 :     return aCustomShape;
      57             : }
      58             : 
      59           0 : OUString ConstCustomShape::GetShapeTypeFromRequest( SfxRequest& rReq )
      60             : {
      61           0 :     OUString aRet;
      62           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
      63           0 :     if ( pArgs )
      64             :     {
      65           0 :         const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() );
      66           0 :         aRet = rItm.GetValue();
      67             :     }
      68           0 :     return aRet;
      69             : }
      70             : 
      71           0 : sal_Bool ConstCustomShape::MouseButtonDown(const MouseEvent& rMEvt)
      72             : {
      73           0 :     sal_Bool bReturn = SwDrawBase::MouseButtonDown(rMEvt);
      74           0 :     if ( bReturn )
      75             :     {
      76           0 :         SdrView *pSdrView = m_pSh->GetDrawView();
      77           0 :         if ( pSdrView )
      78             :         {
      79           0 :             SdrObject* pObj = pSdrView->GetCreateObj();
      80           0 :             if ( pObj )
      81             :             {
      82           0 :                 SetAttributes( pObj );
      83           0 :                 bool bForceNoFillStyle = false;
      84           0 :                 if ( ((SdrObjCustomShape*)pObj)->UseNoFillStyle() )
      85           0 :                     bForceNoFillStyle = true;
      86             : 
      87           0 :                 SfxItemSet aAttr( m_pView->GetPool() );
      88           0 :                 if ( bForceNoFillStyle )
      89           0 :                     aAttr.Put( XFillStyleItem( XFILL_NONE ) );
      90           0 :                 pObj->SetMergedItemSet(aAttr);
      91             :             }
      92             :         }
      93             :     }
      94           0 :     return bReturn;
      95             : }
      96             : 
      97           0 : sal_Bool ConstCustomShape::MouseButtonUp(const MouseEvent& rMEvt)
      98             : {
      99           0 :     return SwDrawBase::MouseButtonUp(rMEvt);
     100             : }
     101             : 
     102           0 : void ConstCustomShape::Activate(const sal_uInt16 nSlotId)
     103             : {
     104           0 :     m_pWin->SetSdrDrawMode( OBJ_CUSTOMSHAPE );
     105             : 
     106           0 :     SwDrawBase::Activate(nSlotId);
     107           0 : }
     108             : 
     109             : // applying attributes
     110             : 
     111           0 : void ConstCustomShape::SetAttributes( SdrObject* pObj )
     112             : {
     113           0 :     bool bAttributesAppliedFromGallery = false;
     114             : 
     115           0 :     if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
     116             :     {
     117           0 :         std::vector< OUString > aObjList;
     118           0 :         if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
     119             :         {
     120             :             sal_uInt16 i;
     121           0 :             for ( i = 0; i < aObjList.size(); i++ )
     122             :             {
     123           0 :                 if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) )
     124             :                 {
     125           0 :                     FmFormModel aFormModel;
     126           0 :                     SfxItemPool& rPool = aFormModel.GetItemPool();
     127           0 :                     rPool.FreezeIdRanges();
     128           0 :                     if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) )
     129             :                     {
     130           0 :                         const SdrObject* pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 );
     131           0 :                         if( pSourceObj )
     132             :                         {
     133           0 :                             const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
     134           0 :                             SfxItemSet aDest( pObj->GetModel()->GetItemPool(),              // ranges from SdrAttrObj
     135             :                             SDRATTR_START, SDRATTR_SHADOW_LAST,
     136             :                             SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
     137             :                             SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
     138             :                             // Graphic Attributes
     139             :                             SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
     140             :                             // 3d Properties
     141             :                             SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
     142             :                             // CustomShape properties
     143             :                             SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
     144             :                             // range from SdrTextObj
     145             :                             EE_ITEMS_START, EE_ITEMS_END,
     146             :                             // end
     147           0 :                             0, 0);
     148           0 :                             aDest.Set( rSource );
     149           0 :                             pObj->SetMergedItemSet( aDest );
     150           0 :                             sal_Int32 nAngle = pSourceObj->GetRotateAngle();
     151           0 :                             if ( nAngle )
     152             :                             {
     153           0 :                                 double a = nAngle * F_PI18000;
     154           0 :                                 pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
     155             :                             }
     156           0 :                             bAttributesAppliedFromGallery = true;
     157             :                         }
     158             :                     }
     159           0 :                     break;
     160             :                 }
     161             :             }
     162           0 :         }
     163             :     }
     164           0 :     if ( !bAttributesAppliedFromGallery )
     165             :     {
     166           0 :         pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, RES_PARATR_ADJUST ) );
     167           0 :         pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
     168           0 :         pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
     169           0 :         pObj->SetMergedItem( SdrTextAutoGrowHeightItem( false ) );
     170           0 :         ((SdrObjCustomShape*)pObj)->MergeDefaultAttributes( &aCustomShape );
     171             :     }
     172           0 : }
     173             : 
     174           0 : void ConstCustomShape::CreateDefaultObject()
     175             : {
     176           0 :     SwDrawBase::CreateDefaultObject();
     177           0 :     SdrView *pSdrView = m_pSh->GetDrawView();
     178           0 :     if ( pSdrView )
     179             :     {
     180           0 :         const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
     181           0 :         if ( rMarkList.GetMarkCount() == 1 )
     182             :         {
     183           0 :             SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     184           0 :             if ( pObj && pObj->ISA( SdrObjCustomShape ) )
     185           0 :                 SetAttributes( pObj );
     186             :         }
     187             :     }
     188           0 : }
     189             : 
     190             : // #i33136#
     191           0 : bool ConstCustomShape::doConstructOrthogonal() const
     192             : {
     193           0 :     return SdrObjCustomShape::doConstructOrthogonal(aCustomShape);
     194             : }
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10