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

Generated by: LCOV version 1.11