LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - fuconpol.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 111 0.9 %
Date: 2014-04-11 Functions: 2 12 16.7 %
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 "fuconpol.hxx"
      22             : #include "tabvwsh.hxx"
      23             : #include "sc.hrc"
      24             : #include "drawview.hxx"
      25             : 
      26             : // Create default drawing objects via keyboard
      27             : #include <svx/svdopath.hxx>
      28             : #include <basegfx/polygon/b2dpolygon.hxx>
      29             : #include <basegfx/point/b2dpoint.hxx>
      30             : 
      31             : /*************************************************************************
      32             : |*
      33             : |* Konstruktor
      34             : |*
      35             : \************************************************************************/
      36             : 
      37           0 : FuConstPolygon::FuConstPolygon(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
      38             :                    SdrModel* pDoc, SfxRequest& rReq)
      39           0 :     : FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq)
      40             : {
      41           0 : }
      42             : 
      43             : /*************************************************************************
      44             : |*
      45             : |* Destruktor
      46             : |*
      47             : \************************************************************************/
      48             : 
      49           0 : FuConstPolygon::~FuConstPolygon()
      50             : {
      51           0 : }
      52             : 
      53             : /*************************************************************************
      54             : |*
      55             : |* MouseButtonDown-event
      56             : |*
      57             : \************************************************************************/
      58             : 
      59           0 : bool FuConstPolygon::MouseButtonDown(const MouseEvent& rMEvt)
      60             : {
      61             :     // remember button state for creation of own MouseEvents
      62           0 :     SetMouseButtonCode(rMEvt.GetButtons());
      63             : 
      64           0 :     bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
      65             : 
      66           0 :     SdrViewEvent aVEvt;
      67           0 :     (void)pView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
      68           0 :     if (aVEvt.eEvent == SDREVENT_BEGTEXTEDIT)
      69             :     {
      70             :         // Texteingabe hier nicht zulassen
      71           0 :         aVEvt.eEvent = SDREVENT_BEGDRAGOBJ;
      72           0 :         pView->EnableExtendedMouseEventDispatcher(false);
      73             :     }
      74             :     else
      75             :     {
      76           0 :         pView->EnableExtendedMouseEventDispatcher(true);
      77             :     }
      78             : 
      79           0 :     if ( pView->MouseButtonDown(rMEvt, pWindow) )
      80           0 :         bReturn = true;
      81             : 
      82           0 :     return bReturn;
      83             : }
      84             : 
      85             : /*************************************************************************
      86             : |*
      87             : |* MouseMove-event
      88             : |*
      89             : \************************************************************************/
      90             : 
      91           0 : bool FuConstPolygon::MouseMove(const MouseEvent& rMEvt)
      92             : {
      93           0 :     pView->MouseMove(rMEvt, pWindow);
      94           0 :     return FuConstruct::MouseMove(rMEvt);
      95             : }
      96             : 
      97             : /*************************************************************************
      98             : |*
      99             : |* MouseButtonUp-event
     100             : |*
     101             : \************************************************************************/
     102             : 
     103           0 : bool FuConstPolygon::MouseButtonUp(const MouseEvent& rMEvt)
     104             : {
     105             :     // remember button state for creation of own MouseEvents
     106           0 :     SetMouseButtonCode(rMEvt.GetButtons());
     107             : 
     108           0 :     bool bReturn = false;
     109           0 :     bool bSimple = false;
     110             : 
     111           0 :     SdrViewEvent aVEvt;
     112           0 :     (void)pView->PickAnything(rMEvt, SDRMOUSEBUTTONUP, aVEvt);
     113             : 
     114           0 :     pView->MouseButtonUp(rMEvt, pWindow);
     115             : 
     116           0 :     if (aVEvt.eEvent == SDREVENT_ENDCREATE)
     117             :     {
     118           0 :         bReturn = true;
     119           0 :         bSimple = true;         // Doppelklick nicht weiterreichen
     120             :     }
     121             : 
     122             :     bool bParent;
     123           0 :     if (bSimple)
     124           0 :         bParent = FuConstruct::SimpleMouseButtonUp(rMEvt);
     125             :     else
     126           0 :         bParent = FuConstruct::MouseButtonUp(rMEvt);
     127             : 
     128           0 :     return (bParent || bReturn);
     129             : }
     130             : 
     131             : /*************************************************************************
     132             : |*
     133             : |* Tastaturereignisse bearbeiten
     134             : |*
     135             : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
     136             : |* FALSE.
     137             : |*
     138             : \************************************************************************/
     139             : 
     140           0 : bool FuConstPolygon::KeyInput(const KeyEvent& rKEvt)
     141             : {
     142           0 :     return FuConstruct::KeyInput(rKEvt);
     143             : }
     144             : 
     145             : /*************************************************************************
     146             : |*
     147             : |* Function aktivieren
     148             : |*
     149             : \************************************************************************/
     150             : 
     151           0 : void FuConstPolygon::Activate()
     152             : {
     153           0 :     pView->EnableExtendedMouseEventDispatcher(true);
     154             : 
     155             :     SdrObjKind eKind;
     156             : 
     157           0 :     switch (GetSlotID())
     158             :     {
     159             :         case SID_DRAW_POLYGON_NOFILL:
     160             :         case SID_DRAW_XPOLYGON_NOFILL:
     161             :         {
     162           0 :             eKind = OBJ_PLIN;
     163             :         }
     164           0 :         break;
     165             : 
     166             :         case SID_DRAW_POLYGON:
     167             :         case SID_DRAW_XPOLYGON:
     168             :         {
     169           0 :             eKind = OBJ_POLY;
     170             :         }
     171           0 :         break;
     172             : 
     173             :         case SID_DRAW_BEZIER_NOFILL:
     174             :         {
     175           0 :             eKind = OBJ_PATHLINE;
     176             :         }
     177           0 :         break;
     178             : 
     179             :         case SID_DRAW_BEZIER_FILL:
     180             :         {
     181           0 :             eKind = OBJ_PATHFILL;
     182             :         }
     183           0 :         break;
     184             : 
     185             :         case SID_DRAW_FREELINE_NOFILL:
     186             :         {
     187           0 :             eKind = OBJ_FREELINE;
     188             :         }
     189           0 :         break;
     190             : 
     191             :         case SID_DRAW_FREELINE:
     192             :         {
     193           0 :             eKind = OBJ_FREEFILL;
     194             :         }
     195           0 :         break;
     196             : 
     197             :         default:
     198             :         {
     199           0 :             eKind = OBJ_PATHLINE;
     200             :         }
     201           0 :         break;
     202             :     }
     203             : 
     204           0 :     pView->SetCurrentObj(sal::static_int_cast<sal_uInt16>(eKind));
     205             : 
     206           0 :     pView->SetEditMode(SDREDITMODE_CREATE);
     207             : 
     208           0 :     FuConstruct::Activate();
     209             : 
     210           0 :     aNewPointer = Pointer( POINTER_DRAW_POLYGON );
     211           0 :     aOldPointer = pWindow->GetPointer();
     212           0 :     pViewShell->SetActivePointer( aNewPointer );
     213           0 : }
     214             : 
     215             : /*************************************************************************
     216             : |*
     217             : |* Function deaktivieren
     218             : |*
     219             : \************************************************************************/
     220             : 
     221           0 : void FuConstPolygon::Deactivate()
     222             : {
     223           0 :     pView->SetEditMode(SDREDITMODE_EDIT);
     224             : 
     225           0 :     pView->EnableExtendedMouseEventDispatcher(false);
     226             : 
     227           0 :     FuConstruct::Deactivate();
     228             : 
     229           0 :     pViewShell->SetActivePointer( aOldPointer );
     230           0 : }
     231             : 
     232             : // Create default drawing objects via keyboard
     233           0 : SdrObject* FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
     234             : {
     235             :     // case SID_DRAW_POLYGON:
     236             :     // case SID_DRAW_POLYGON_NOFILL:
     237             :     // case SID_DRAW_BEZIER_NOFILL:
     238             :     // case SID_DRAW_FREELINE_NOFILL:
     239             : 
     240             :     SdrObject* pObj = SdrObjFactory::MakeNewObject(
     241           0 :         pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
     242           0 :         0L, pDrDoc);
     243             : 
     244           0 :     if(pObj)
     245             :     {
     246           0 :         if(pObj->ISA(SdrPathObj))
     247             :         {
     248           0 :             basegfx::B2DPolyPolygon aPoly;
     249             : 
     250           0 :             switch(nID)
     251             :             {
     252             :                 case SID_DRAW_BEZIER_NOFILL:
     253             :                 {
     254           0 :                     basegfx::B2DPolygon aInnerPoly;
     255             : 
     256           0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
     257             : 
     258           0 :                     const basegfx::B2DPoint aCenterBottom(rRectangle.Center().X(), rRectangle.Bottom());
     259             :                     aInnerPoly.appendBezierSegment(
     260             :                         aCenterBottom,
     261             :                         aCenterBottom,
     262           0 :                         basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Center().Y()));
     263             : 
     264           0 :                     const basegfx::B2DPoint aCenterTop(rRectangle.Center().X(), rRectangle.Top());
     265             :                     aInnerPoly.appendBezierSegment(
     266             :                         aCenterTop,
     267             :                         aCenterTop,
     268           0 :                         basegfx::B2DPoint(rRectangle.Right(), rRectangle.Top()));
     269             : 
     270           0 :                     aPoly.append(aInnerPoly);
     271           0 :                     break;
     272             :                 }
     273             :                 case SID_DRAW_FREELINE_NOFILL:
     274             :                 {
     275           0 :                     basegfx::B2DPolygon aInnerPoly;
     276             : 
     277           0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
     278             : 
     279             :                     aInnerPoly.appendBezierSegment(
     280           0 :                         basegfx::B2DPoint(rRectangle.Left(), rRectangle.Top()),
     281           0 :                         basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Top()),
     282           0 :                         basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Center().Y()));
     283             : 
     284             :                     aInnerPoly.appendBezierSegment(
     285           0 :                         basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Bottom()),
     286           0 :                         basegfx::B2DPoint(rRectangle.Right(), rRectangle.Bottom()),
     287           0 :                         basegfx::B2DPoint(rRectangle.Right(), rRectangle.Top()));
     288             : 
     289           0 :                     aPoly.append(aInnerPoly);
     290           0 :                     break;
     291             :                 }
     292             :                 case SID_DRAW_POLYGON:
     293             :                 case SID_DRAW_POLYGON_NOFILL:
     294             :                 {
     295           0 :                     basegfx::B2DPolygon aInnerPoly;
     296           0 :                     const sal_Int32 nWdt(rRectangle.GetWidth());
     297           0 :                     const sal_Int32 nHgt(rRectangle.GetHeight());
     298             : 
     299           0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
     300           0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 30) / 100, rRectangle.Top() + (nHgt * 70) / 100));
     301           0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Top() + (nHgt * 15) / 100));
     302           0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 65) / 100, rRectangle.Top()));
     303           0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + nWdt, rRectangle.Top() + (nHgt * 30) / 100));
     304           0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 80) / 100, rRectangle.Top() + (nHgt * 50) / 100));
     305           0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 80) / 100, rRectangle.Top() + (nHgt * 75) / 100));
     306           0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Bottom(), rRectangle.Right()));
     307             : 
     308           0 :                     if(SID_DRAW_POLYGON_NOFILL == nID)
     309             :                     {
     310           0 :                         aInnerPoly.append(basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Bottom()));
     311             :                     }
     312             :                     else
     313             :                     {
     314           0 :                         aInnerPoly.setClosed(true);
     315             :                     }
     316             : 
     317           0 :                     aPoly.append(aInnerPoly);
     318           0 :                     break;
     319             :                 }
     320             :             }
     321             : 
     322           0 :             ((SdrPathObj*)pObj)->SetPathPoly(aPoly);
     323             :         }
     324             :         else
     325             :         {
     326             :             OSL_FAIL("Object is NO path object");
     327             :         }
     328             : 
     329           0 :         pObj->SetLogicRect(rRectangle);
     330             :     }
     331             : 
     332           0 :     return pObj;
     333         102 : }
     334             : 
     335             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10