LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuconcs.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 105 0.0 %
Date: 2014-04-14 Functions: 0 16 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             : 
      21             : #include "fuconcs.hxx"
      22             : #include <svx/svdpagv.hxx>
      23             : 
      24             : 
      25             : #include <svx/svxids.hrc>
      26             : #include <svx/dialogs.hrc>
      27             : #include <svx/dialmgr.hxx>
      28             : 
      29             : #include "app.hrc"
      30             : #include <svl/aeitem.hxx>
      31             : #include <svx/xlnstwit.hxx>
      32             : #include <svx/xlnedwit.hxx>
      33             : #include <svx/xlnedit.hxx>
      34             : #include <svx/xlnstit.hxx>
      35             : #include <svx/xlnwtit.hxx>
      36             : #include <sfx2/viewfrm.hxx>
      37             : #include <svx/sdtmfitm.hxx>
      38             : #include <svx/sxekitm.hxx>
      39             : #include <svx/sderitm.hxx>
      40             : #include <sfx2/dispatch.hxx>
      41             : #include <svx/svdopath.hxx>
      42             : #include <svx/svdocirc.hxx>
      43             : #include <svl/intitem.hxx>
      44             : #include <sfx2/request.hxx>
      45             : #include <editeng/adjustitem.hxx>
      46             : #include <svx/xtable.hxx>
      47             : #include <svx/sdasitm.hxx>
      48             : #include <svx/tbxcustomshapes.hxx>
      49             : #include <svx/svdoashp.hxx>
      50             : #include <svx/sdtagitm.hxx>
      51             : 
      52             : #include <svx/svdocapt.hxx>
      53             : 
      54             : #include <svx/svdomeas.hxx>
      55             : #include "ViewShell.hxx"
      56             : #include "ViewShellBase.hxx"
      57             : #include "ToolBarManager.hxx"
      58             : #include <editeng/writingmodeitem.hxx>
      59             : #include <svx/gallery.hxx>
      60             : #include <svl/itempool.hxx>
      61             : #include <com/sun/star/uno/Any.hxx>
      62             : 
      63             : #include "sdresid.hxx"
      64             : #include "View.hxx"
      65             : #include "sdpage.hxx"
      66             : #include "Window.hxx"
      67             : #include "stlpool.hxx"
      68             : #include "drawdoc.hxx"
      69             : #include "res_bmp.hrc"
      70             : #include "glob.hrc"
      71             : 
      72             : namespace sd {
      73             : 
      74           0 : TYPEINIT1( FuConstructCustomShape, FuConstruct );
      75             : 
      76             : 
      77           0 : FuConstructCustomShape::FuConstructCustomShape (
      78             :         ViewShell*          pViewSh,
      79             :         ::sd::Window*       pWin,
      80             :         ::sd::View*         pView,
      81             :         SdDrawDocument*     pDoc,
      82             :         SfxRequest&         rReq ) :
      83           0 :     FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
      84             : {
      85           0 : }
      86             : 
      87           0 : rtl::Reference<FuPoor> FuConstructCustomShape::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
      88             : {
      89             :     FuConstructCustomShape* pFunc;
      90           0 :     rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructCustomShape( pViewSh, pWin, pView, pDoc, rReq ) );
      91           0 :     xFunc->DoExecute(rReq);
      92           0 :     pFunc->SetPermanent( bPermanent );
      93           0 :     return xFunc;
      94             : }
      95             : 
      96           0 : void FuConstructCustomShape::DoExecute( SfxRequest& rReq )
      97             : {
      98           0 :     FuConstruct::DoExecute( rReq );
      99             : 
     100           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     101           0 :     if ( pArgs )
     102             :     {
     103           0 :         const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() );
     104           0 :         aCustomShape = rItm.GetValue();
     105             :     }
     106             : 
     107           0 :     mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
     108             :         ToolBarManager::TBG_FUNCTION,
     109           0 :         ToolBarManager::msDrawingObjectToolBar);
     110           0 : }
     111             : 
     112             : 
     113           0 : sal_Bool FuConstructCustomShape::MouseButtonDown(const MouseEvent& rMEvt)
     114             : {
     115           0 :     sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
     116             : 
     117           0 :     if ( rMEvt.IsLeft() && !mpView->IsAction() )
     118             :     {
     119           0 :         Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
     120             : 
     121           0 :         mpWindow->CaptureMouse();
     122           0 :         sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
     123             : 
     124           0 :         mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog);
     125             : 
     126           0 :         SdrObject* pObj = mpView->GetCreateObj();
     127           0 :         if ( pObj )
     128             :         {
     129           0 :             SetAttributes( pObj );
     130           0 :             sal_Bool bForceFillStyle = sal_True;
     131           0 :             sal_Bool bForceNoFillStyle = sal_False;
     132           0 :             if ( ((SdrObjCustomShape*)pObj)->UseNoFillStyle() )
     133             :             {
     134           0 :                 bForceFillStyle = sal_False;
     135           0 :                 bForceNoFillStyle = sal_True;
     136             :             }
     137           0 :             SfxItemSet aAttr(mpDoc->GetPool());
     138           0 :             SetStyleSheet( aAttr, pObj, bForceFillStyle, bForceNoFillStyle );
     139           0 :             pObj->SetMergedItemSet(aAttr);
     140             :         }
     141             :     }
     142             : 
     143           0 :     return bReturn;
     144             : }
     145             : 
     146             : 
     147           0 : sal_Bool FuConstructCustomShape::MouseMove(const MouseEvent& rMEvt)
     148             : {
     149           0 :     return FuConstruct::MouseMove(rMEvt);
     150             : }
     151             : 
     152             : 
     153           0 : sal_Bool FuConstructCustomShape::MouseButtonUp(const MouseEvent& rMEvt)
     154             : {
     155           0 :     sal_Bool bReturn(sal_False);
     156             : 
     157           0 :     if(mpView->IsCreateObj() && rMEvt.IsLeft())
     158             :     {
     159           0 :         SdrObject* pObj = mpView->GetCreateObj();
     160           0 :         if( pObj && mpView->EndCreateObj( SDRCREATE_FORCEEND ) )
     161             :         {
     162           0 :             bReturn = sal_True;
     163             :         }
     164             :     }
     165           0 :     bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
     166             : 
     167           0 :     if (!bPermanent)
     168           0 :         mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
     169             : 
     170           0 :     return bReturn;
     171             : }
     172             : 
     173             : /**
     174             :  * Process keyboard input
     175             :  * @returns sal_True if a KeyEvent is being processed, sal_False otherwise
     176             :  */
     177           0 : sal_Bool FuConstructCustomShape::KeyInput(const KeyEvent& rKEvt)
     178             : {
     179           0 :     sal_Bool bReturn = FuConstruct::KeyInput(rKEvt);
     180           0 :     return(bReturn);
     181             : }
     182             : 
     183             : 
     184           0 : void FuConstructCustomShape::Activate()
     185             : {
     186           0 :     mpView->SetCurrentObj( OBJ_CUSTOMSHAPE );
     187           0 :     FuConstruct::Activate();
     188           0 : }
     189             : 
     190             : /**
     191             :  * set attribute for the object to be created
     192             :  */
     193           0 : void FuConstructCustomShape::SetAttributes( SdrObject* pObj )
     194             : {
     195           0 :     sal_Bool bAttributesAppliedFromGallery = sal_False;
     196             : 
     197           0 :     if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
     198             :     {
     199           0 :         std::vector< OUString > aObjList;
     200           0 :         if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
     201             :         {
     202             :             sal_uInt16 i;
     203           0 :             for ( i = 0; i < aObjList.size(); i++ )
     204             :             {
     205           0 :                 if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) )
     206             :                 {
     207           0 :                     FmFormModel aFormModel;
     208           0 :                     SfxItemPool& rPool = aFormModel.GetItemPool();
     209           0 :                     rPool.FreezeIdRanges();
     210           0 :                     if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) )
     211             :                     {
     212           0 :                         const SdrPage* pPage = aFormModel.GetPage( 0 );
     213           0 :                         if ( pPage )
     214             :                         {
     215           0 :                             const SdrObject* pSourceObj = pPage->GetObj( 0 );
     216           0 :                             if( pSourceObj )
     217             :                             {
     218           0 :                                 const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
     219           0 :                                 SfxItemSet aDest( pObj->GetModel()->GetItemPool(),              // ranges from SdrAttrObj
     220             :                                 SDRATTR_START, SDRATTR_SHADOW_LAST,
     221             :                                 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
     222             :                                 SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
     223             :                                 // Graphic Attributes
     224             :                                 SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
     225             :                                 // 3d Properties
     226             :                                 SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
     227             :                                 // CustomShape properties
     228             :                                 SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
     229             :                                 // range from SdrTextObj
     230             :                                 EE_ITEMS_START, EE_ITEMS_END,
     231             :                                 // end
     232           0 :                                 0, 0);
     233           0 :                                 aDest.Set( rSource );
     234           0 :                                 pObj->SetMergedItemSet( aDest );
     235           0 :                                 sal_Int32 nAngle = pSourceObj->GetRotateAngle();
     236           0 :                                 if ( nAngle )
     237             :                                 {
     238           0 :                                     double a = nAngle * F_PI18000;
     239           0 :                                     pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
     240             :                                 }
     241           0 :                                 bAttributesAppliedFromGallery = sal_True;
     242             : 
     243             : 
     244             :     /*
     245             :                                 com::sun::star::uno::Any aAny;
     246             :                                 if ( ((SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY )).QueryValue( aAny ) )
     247             :                                 {
     248             :                                     aGeometryItem.PutValue( aAny );
     249             :                                     pObj->SetMergedItem( aGeometryItem );
     250             :                                     bAttributesAppliedFromGallery = sal_True;
     251             :                                 }
     252             :     */
     253             :                             }
     254             :                         }
     255             :                     }
     256           0 :                     break;
     257             :                 }
     258             :             }
     259           0 :         }
     260             :     }
     261           0 :     if ( !bAttributesAppliedFromGallery )
     262             :     {
     263           0 :         pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
     264           0 :         pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
     265           0 :         pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
     266           0 :         pObj->SetMergedItem( SdrTextAutoGrowHeightItem( false ) );
     267           0 :         ((SdrObjCustomShape*)pObj)->MergeDefaultAttributes( &aCustomShape );
     268             :     }
     269           0 : }
     270             : 
     271           0 : SdrObject* FuConstructCustomShape::CreateDefaultObject(const sal_uInt16, const Rectangle& rRectangle)
     272             : {
     273             :     SdrObject* pObj = SdrObjFactory::MakeNewObject(
     274           0 :         mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
     275           0 :         0L, mpDoc);
     276             : 
     277           0 :     if( pObj )
     278             :     {
     279           0 :         Rectangle aRect( rRectangle );
     280           0 :         if ( doConstructOrthogonal() )
     281           0 :             ImpForceQuadratic( aRect );
     282           0 :         pObj->SetLogicRect( aRect );
     283           0 :         SetAttributes( pObj );
     284           0 :         SfxItemSet aAttr(mpDoc->GetPool());
     285           0 :         SetStyleSheet(aAttr, pObj);
     286           0 :         pObj->SetMergedItemSet(aAttr);
     287             :     }
     288           0 :     return pObj;
     289             : }
     290             : 
     291             : // #i33136#
     292           0 : bool FuConstructCustomShape::doConstructOrthogonal() const
     293             : {
     294           0 :     return SdrObjCustomShape::doConstructOrthogonal(aCustomShape);
     295             : }
     296             : 
     297             : } // end of namespace sd
     298             : 
     299             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10