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

Generated by: LCOV version 1.10