LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/func - fuconcs.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 105 0.0 %
Date: 2012-12-27 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/adjitem.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             : |*
      78             : |* Konstruktor
      79             : |*
      80             : \************************************************************************/
      81             : 
      82           0 : FuConstructCustomShape::FuConstructCustomShape (
      83             :         ViewShell*          pViewSh,
      84             :         ::sd::Window*       pWin,
      85             :         ::sd::View*         pView,
      86             :         SdDrawDocument*     pDoc,
      87             :         SfxRequest&         rReq ) :
      88           0 :     FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
      89             : {
      90           0 : }
      91             : 
      92           0 : FunctionReference FuConstructCustomShape::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
      93             : {
      94             :     FuConstructCustomShape* pFunc;
      95           0 :     FunctionReference xFunc( pFunc = new FuConstructCustomShape( pViewSh, pWin, pView, pDoc, rReq ) );
      96           0 :     xFunc->DoExecute(rReq);
      97           0 :     pFunc->SetPermanent( bPermanent );
      98           0 :     return xFunc;
      99             : }
     100             : 
     101           0 : void FuConstructCustomShape::DoExecute( SfxRequest& rReq )
     102             : {
     103           0 :     FuConstruct::DoExecute( rReq );
     104             : 
     105           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     106           0 :     if ( pArgs )
     107             :     {
     108           0 :         const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() );
     109           0 :         aCustomShape = rItm.GetValue();
     110             :     }
     111             : 
     112           0 :     mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
     113             :         ToolBarManager::TBG_FUNCTION,
     114           0 :         ToolBarManager::msDrawingObjectToolBar);
     115           0 : }
     116             : 
     117             : /*************************************************************************
     118             : |*
     119             : |* MouseButtonDown-event
     120             : |*
     121             : \************************************************************************/
     122             : 
     123           0 : sal_Bool FuConstructCustomShape::MouseButtonDown(const MouseEvent& rMEvt)
     124             : {
     125           0 :     sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
     126             : 
     127           0 :     if ( rMEvt.IsLeft() && !mpView->IsAction() )
     128             :     {
     129           0 :         Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
     130             : 
     131           0 :         mpWindow->CaptureMouse();
     132           0 :         sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
     133             : 
     134           0 :         mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog);
     135             : 
     136           0 :         SdrObject* pObj = mpView->GetCreateObj();
     137           0 :         if ( pObj )
     138             :         {
     139           0 :             SetAttributes( pObj );
     140           0 :             sal_Bool bForceFillStyle = sal_True;
     141           0 :             sal_Bool bForceNoFillStyle = sal_False;
     142           0 :             if ( ((SdrObjCustomShape*)pObj)->UseNoFillStyle() )
     143             :             {
     144           0 :                 bForceFillStyle = sal_False;
     145           0 :                 bForceNoFillStyle = sal_True;
     146             :             }
     147           0 :             SfxItemSet aAttr(mpDoc->GetPool());
     148           0 :             SetStyleSheet( aAttr, pObj, bForceFillStyle, bForceNoFillStyle );
     149           0 :             pObj->SetMergedItemSet(aAttr);
     150             :         }
     151             :     }
     152             : 
     153           0 :     return bReturn;
     154             : }
     155             : 
     156             : /*************************************************************************
     157             : |*
     158             : |* MouseMove-event
     159             : |*
     160             : \************************************************************************/
     161             : 
     162           0 : sal_Bool FuConstructCustomShape::MouseMove(const MouseEvent& rMEvt)
     163             : {
     164           0 :     return FuConstruct::MouseMove(rMEvt);
     165             : }
     166             : 
     167             : /*************************************************************************
     168             : |*
     169             : |* MouseButtonUp-event
     170             : |*
     171             : \************************************************************************/
     172             : 
     173           0 : sal_Bool FuConstructCustomShape::MouseButtonUp(const MouseEvent& rMEvt)
     174             : {
     175           0 :     sal_Bool bReturn(sal_False);
     176             : 
     177           0 :     if(mpView->IsCreateObj() && rMEvt.IsLeft())
     178             :     {
     179           0 :         SdrObject* pObj = mpView->GetCreateObj();
     180           0 :         if( pObj && mpView->EndCreateObj( SDRCREATE_FORCEEND ) )
     181             :         {
     182           0 :             bReturn = sal_True;
     183             :         }
     184             :     }
     185           0 :     bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
     186             : 
     187           0 :     if (!bPermanent)
     188           0 :         mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
     189             : 
     190           0 :     return bReturn;
     191             : }
     192             : 
     193             : /*************************************************************************
     194             : |*
     195             : |* Tastaturereignisse bearbeiten
     196             : |*
     197             : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
     198             : |* sal_False.
     199             : |*
     200             : \************************************************************************/
     201             : 
     202           0 : sal_Bool FuConstructCustomShape::KeyInput(const KeyEvent& rKEvt)
     203             : {
     204           0 :     sal_Bool bReturn = FuConstruct::KeyInput(rKEvt);
     205           0 :     return(bReturn);
     206             : }
     207             : 
     208             : /*************************************************************************
     209             : |*
     210             : |* Function aktivieren
     211             : |*
     212             : \************************************************************************/
     213             : 
     214           0 : void FuConstructCustomShape::Activate()
     215             : {
     216           0 :     mpView->SetCurrentObj( OBJ_CUSTOMSHAPE );
     217           0 :     FuConstruct::Activate();
     218           0 : }
     219             : 
     220             : /*************************************************************************
     221             : |*
     222             : |* Attribute fuer das zu erzeugende Objekt setzen
     223             : |*
     224             : \************************************************************************/
     225             : 
     226           0 : void FuConstructCustomShape::SetAttributes( SdrObject* pObj )
     227             : {
     228           0 :     sal_Bool bAttributesAppliedFromGallery = sal_False;
     229             : 
     230           0 :     if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
     231             :     {
     232           0 :         std::vector< rtl::OUString > aObjList;
     233           0 :         if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
     234             :         {
     235             :             sal_uInt16 i;
     236           0 :             for ( i = 0; i < aObjList.size(); i++ )
     237             :             {
     238           0 :                 if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) )
     239             :                 {
     240           0 :                     FmFormModel aFormModel;
     241           0 :                     SfxItemPool& rPool = aFormModel.GetItemPool();
     242           0 :                     rPool.FreezeIdRanges();
     243           0 :                     if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) )
     244             :                     {
     245           0 :                         const SdrPage* pPage = aFormModel.GetPage( 0 );
     246           0 :                         if ( pPage )
     247             :                         {
     248           0 :                             const SdrObject* pSourceObj = pPage->GetObj( 0 );
     249           0 :                             if( pSourceObj )
     250             :                             {
     251           0 :                                 const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
     252           0 :                                 SfxItemSet aDest( pObj->GetModel()->GetItemPool(),              // ranges from SdrAttrObj
     253             :                                 SDRATTR_START, SDRATTR_SHADOW_LAST,
     254             :                                 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
     255             :                                 SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
     256             :                                 // Graphic Attributes
     257             :                                 SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
     258             :                                 // 3d Properties
     259             :                                 SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
     260             :                                 // CustomShape properties
     261             :                                 SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
     262             :                                 // range from SdrTextObj
     263             :                                 EE_ITEMS_START, EE_ITEMS_END,
     264             :                                 // end
     265           0 :                                 0, 0);
     266           0 :                                 aDest.Set( rSource );
     267           0 :                                 pObj->SetMergedItemSet( aDest );
     268           0 :                                 sal_Int32 nAngle = pSourceObj->GetRotateAngle();
     269           0 :                                 if ( nAngle )
     270             :                                 {
     271           0 :                                     double a = nAngle * F_PI18000;
     272           0 :                                     pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
     273             :                                 }
     274           0 :                                 bAttributesAppliedFromGallery = sal_True;
     275             : 
     276             : 
     277             :     /*
     278             :                                 com::sun::star::uno::Any aAny;
     279             :                                 if ( ((SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY )).QueryValue( aAny ) )
     280             :                                 {
     281             :                                     aGeometryItem.PutValue( aAny );
     282             :                                     pObj->SetMergedItem( aGeometryItem );
     283             :                                     bAttributesAppliedFromGallery = sal_True;
     284             :                                 }
     285             :     */
     286             :                             }
     287             :                         }
     288             :                     }
     289           0 :                     break;
     290             :                 }
     291             :             }
     292           0 :         }
     293             :     }
     294           0 :     if ( !bAttributesAppliedFromGallery )
     295             :     {
     296           0 :         pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
     297           0 :         pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
     298           0 :         pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
     299           0 :         pObj->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) );
     300           0 :         ((SdrObjCustomShape*)pObj)->MergeDefaultAttributes( &aCustomShape );
     301             :     }
     302           0 : }
     303             : 
     304           0 : SdrObject* FuConstructCustomShape::CreateDefaultObject(const sal_uInt16, const Rectangle& rRectangle)
     305             : {
     306             :     SdrObject* pObj = SdrObjFactory::MakeNewObject(
     307           0 :         mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
     308           0 :         0L, mpDoc);
     309             : 
     310           0 :     if( pObj )
     311             :     {
     312           0 :         Rectangle aRect( rRectangle );
     313           0 :         if ( doConstructOrthogonal() )
     314           0 :             ImpForceQuadratic( aRect );
     315           0 :         pObj->SetLogicRect( aRect );
     316           0 :         SetAttributes( pObj );
     317           0 :         SfxItemSet aAttr(mpDoc->GetPool());
     318           0 :         SetStyleSheet(aAttr, pObj);
     319           0 :         pObj->SetMergedItemSet(aAttr);
     320             :     }
     321           0 :     return pObj;
     322             : }
     323             : 
     324             : // #i33136#
     325           0 : bool FuConstructCustomShape::doConstructOrthogonal() const
     326             : {
     327           0 :     return SdrObjCustomShape::doConstructOrthogonal(aCustomShape);
     328             : }
     329             : 
     330             : } // end of namespace sd
     331             : 
     332             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10