LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - fuconpol.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 112 0.0 %
Date: 2012-08-25 Functions: 0 10 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 131 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "fuconpol.hxx"
      31                 :            : #include "tabvwsh.hxx"
      32                 :            : #include "sc.hrc"
      33                 :            : #include "drawview.hxx"
      34                 :            : 
      35                 :            : // Create default drawing objects via keyboard
      36                 :            : #include <svx/svdopath.hxx>
      37                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      38                 :            : #include <basegfx/point/b2dpoint.hxx>
      39                 :            : 
      40                 :            : //  Pixelabstand zum Schliessen von Freihand-Zeichnungen
      41                 :            : #ifndef CLOSE_PIXDIST
      42                 :            : #define CLOSE_PIXDIST 5
      43                 :            : #endif
      44                 :            : 
      45                 :            : //------------------------------------------------------------------------
      46                 :            : 
      47                 :            : /*************************************************************************
      48                 :            : |*
      49                 :            : |* Konstruktor
      50                 :            : |*
      51                 :            : \************************************************************************/
      52                 :            : 
      53                 :          0 : FuConstPolygon::FuConstPolygon(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
      54                 :            :                    SdrModel* pDoc, SfxRequest& rReq)
      55                 :          0 :     : FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq)
      56                 :            : {
      57                 :          0 : }
      58                 :            : 
      59                 :            : /*************************************************************************
      60                 :            : |*
      61                 :            : |* Destruktor
      62                 :            : |*
      63                 :            : \************************************************************************/
      64                 :            : 
      65                 :          0 : FuConstPolygon::~FuConstPolygon()
      66                 :            : {
      67         [ #  # ]:          0 : }
      68                 :            : 
      69                 :            : /*************************************************************************
      70                 :            : |*
      71                 :            : |* MouseButtonDown-event
      72                 :            : |*
      73                 :            : \************************************************************************/
      74                 :            : 
      75                 :          0 : sal_Bool FuConstPolygon::MouseButtonDown(const MouseEvent& rMEvt)
      76                 :            : {
      77                 :            :     // remember button state for creation of own MouseEvents
      78                 :          0 :     SetMouseButtonCode(rMEvt.GetButtons());
      79                 :            : 
      80         [ #  # ]:          0 :     sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
      81                 :            : 
      82         [ #  # ]:          0 :     SdrViewEvent aVEvt;
      83         [ #  # ]:          0 :     (void)pView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
      84         [ #  # ]:          0 :     if (aVEvt.eEvent == SDREVENT_BEGTEXTEDIT)
      85                 :            :     {
      86                 :            :         // Texteingabe hier nicht zulassen
      87                 :          0 :         aVEvt.eEvent = SDREVENT_BEGDRAGOBJ;
      88                 :          0 :         pView->EnableExtendedMouseEventDispatcher(false);
      89                 :            :     }
      90                 :            :     else
      91                 :            :     {
      92                 :          0 :         pView->EnableExtendedMouseEventDispatcher(sal_True);
      93                 :            :     }
      94                 :            : 
      95 [ #  # ][ #  # ]:          0 :     if ( pView->MouseButtonDown(rMEvt, pWindow) )
      96                 :          0 :         bReturn = sal_True;
      97                 :            : 
      98         [ #  # ]:          0 :     return bReturn;
      99                 :            : }
     100                 :            : 
     101                 :            : /*************************************************************************
     102                 :            : |*
     103                 :            : |* MouseMove-event
     104                 :            : |*
     105                 :            : \************************************************************************/
     106                 :            : 
     107                 :          0 : sal_Bool FuConstPolygon::MouseMove(const MouseEvent& rMEvt)
     108                 :            : {
     109                 :          0 :     pView->MouseMove(rMEvt, pWindow);
     110                 :          0 :     sal_Bool bReturn = FuConstruct::MouseMove(rMEvt);
     111                 :          0 :     return bReturn;
     112                 :            : }
     113                 :            : 
     114                 :            : /*************************************************************************
     115                 :            : |*
     116                 :            : |* MouseButtonUp-event
     117                 :            : |*
     118                 :            : \************************************************************************/
     119                 :            : 
     120                 :          0 : sal_Bool FuConstPolygon::MouseButtonUp(const MouseEvent& rMEvt)
     121                 :            : {
     122                 :            :     // remember button state for creation of own MouseEvents
     123                 :          0 :     SetMouseButtonCode(rMEvt.GetButtons());
     124                 :            : 
     125                 :          0 :     sal_Bool bReturn = false;
     126                 :          0 :     sal_Bool bSimple = false;
     127                 :            : 
     128         [ #  # ]:          0 :     SdrViewEvent aVEvt;
     129         [ #  # ]:          0 :     (void)pView->PickAnything(rMEvt, SDRMOUSEBUTTONUP, aVEvt);
     130                 :            : 
     131         [ #  # ]:          0 :     pView->MouseButtonUp(rMEvt, pWindow);
     132                 :            : 
     133         [ #  # ]:          0 :     if (aVEvt.eEvent == SDREVENT_ENDCREATE)
     134                 :            :     {
     135                 :          0 :         bReturn = sal_True;
     136                 :          0 :         bSimple = sal_True;         // Doppelklick nicht weiterreichen
     137                 :            :     }
     138                 :            : 
     139                 :            :     sal_Bool bParent;
     140         [ #  # ]:          0 :     if (bSimple)
     141         [ #  # ]:          0 :         bParent = FuConstruct::SimpleMouseButtonUp(rMEvt);
     142                 :            :     else
     143         [ #  # ]:          0 :         bParent = FuConstruct::MouseButtonUp(rMEvt);
     144                 :            : 
     145 [ #  # ][ #  # ]:          0 :     return (bParent || bReturn);
                 [ #  # ]
     146                 :            : }
     147                 :            : 
     148                 :            : /*************************************************************************
     149                 :            : |*
     150                 :            : |* Tastaturereignisse bearbeiten
     151                 :            : |*
     152                 :            : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
     153                 :            : |* FALSE.
     154                 :            : |*
     155                 :            : \************************************************************************/
     156                 :            : 
     157                 :          0 : sal_Bool FuConstPolygon::KeyInput(const KeyEvent& rKEvt)
     158                 :            : {
     159                 :          0 :     sal_Bool bReturn = FuConstruct::KeyInput(rKEvt);
     160                 :            : 
     161                 :          0 :     return(bReturn);
     162                 :            : }
     163                 :            : 
     164                 :            : /*************************************************************************
     165                 :            : |*
     166                 :            : |* Function aktivieren
     167                 :            : |*
     168                 :            : \************************************************************************/
     169                 :            : 
     170                 :          0 : void FuConstPolygon::Activate()
     171                 :            : {
     172                 :          0 :     pView->EnableExtendedMouseEventDispatcher(sal_True);
     173                 :            : 
     174                 :            :     SdrObjKind eKind;
     175                 :            : 
     176   [ #  #  #  #  :          0 :     switch (GetSlotID())
                #  #  # ]
     177                 :            :     {
     178                 :            :         case SID_DRAW_POLYGON_NOFILL:
     179                 :            :         case SID_DRAW_XPOLYGON_NOFILL:
     180                 :            :         {
     181                 :          0 :             eKind = OBJ_PLIN;
     182                 :            :         }
     183                 :          0 :         break;
     184                 :            : 
     185                 :            :         case SID_DRAW_POLYGON:
     186                 :            :         case SID_DRAW_XPOLYGON:
     187                 :            :         {
     188                 :          0 :             eKind = OBJ_POLY;
     189                 :            :         }
     190                 :          0 :         break;
     191                 :            : 
     192                 :            :         case SID_DRAW_BEZIER_NOFILL:
     193                 :            :         {
     194                 :          0 :             eKind = OBJ_PATHLINE;
     195                 :            :         }
     196                 :          0 :         break;
     197                 :            : 
     198                 :            :         case SID_DRAW_BEZIER_FILL:
     199                 :            :         {
     200                 :          0 :             eKind = OBJ_PATHFILL;
     201                 :            :         }
     202                 :          0 :         break;
     203                 :            : 
     204                 :            :         case SID_DRAW_FREELINE_NOFILL:
     205                 :            :         {
     206                 :          0 :             eKind = OBJ_FREELINE;
     207                 :            :         }
     208                 :          0 :         break;
     209                 :            : 
     210                 :            :         case SID_DRAW_FREELINE:
     211                 :            :         {
     212                 :          0 :             eKind = OBJ_FREEFILL;
     213                 :            :         }
     214                 :          0 :         break;
     215                 :            : 
     216                 :            :         default:
     217                 :            :         {
     218                 :          0 :             eKind = OBJ_PATHLINE;
     219                 :            :         }
     220                 :          0 :         break;
     221                 :            :     }
     222                 :            : 
     223                 :          0 :     pView->SetCurrentObj(sal::static_int_cast<sal_uInt16>(eKind));
     224                 :            : 
     225                 :          0 :     pView->SetEditMode(SDREDITMODE_CREATE);
     226                 :            : 
     227                 :          0 :     FuConstruct::Activate();
     228                 :            : 
     229                 :          0 :     aNewPointer = Pointer( POINTER_DRAW_POLYGON );
     230                 :          0 :     aOldPointer = pWindow->GetPointer();
     231                 :          0 :     pViewShell->SetActivePointer( aNewPointer );
     232                 :          0 : }
     233                 :            : 
     234                 :            : /*************************************************************************
     235                 :            : |*
     236                 :            : |* Function deaktivieren
     237                 :            : |*
     238                 :            : \************************************************************************/
     239                 :            : 
     240                 :          0 : void FuConstPolygon::Deactivate()
     241                 :            : {
     242                 :          0 :     pView->SetEditMode(SDREDITMODE_EDIT);
     243                 :            : 
     244                 :          0 :     pView->EnableExtendedMouseEventDispatcher(false);
     245                 :            : 
     246                 :          0 :     FuConstruct::Deactivate();
     247                 :            : 
     248                 :          0 :     pViewShell->SetActivePointer( aOldPointer );
     249                 :          0 : }
     250                 :            : 
     251                 :            : // Create default drawing objects via keyboard
     252                 :          0 : SdrObject* FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
     253                 :            : {
     254                 :            :     // case SID_DRAW_POLYGON:
     255                 :            :     // case SID_DRAW_POLYGON_NOFILL:
     256                 :            :     // case SID_DRAW_BEZIER_NOFILL:
     257                 :            :     // case SID_DRAW_FREELINE_NOFILL:
     258                 :            : 
     259                 :            :     SdrObject* pObj = SdrObjFactory::MakeNewObject(
     260                 :          0 :         pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
     261                 :          0 :         0L, pDrDoc);
     262                 :            : 
     263         [ #  # ]:          0 :     if(pObj)
     264                 :            :     {
     265         [ #  # ]:          0 :         if(pObj->ISA(SdrPathObj))
     266                 :            :         {
     267         [ #  # ]:          0 :             basegfx::B2DPolyPolygon aPoly;
     268                 :            : 
     269   [ #  #  #  # ]:          0 :             switch(nID)
     270                 :            :             {
     271                 :            :                 case SID_DRAW_BEZIER_NOFILL:
     272                 :            :                 {
     273         [ #  # ]:          0 :                     basegfx::B2DPolygon aInnerPoly;
     274                 :            : 
     275         [ #  # ]:          0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
     276                 :            : 
     277         [ #  # ]:          0 :                     const basegfx::B2DPoint aCenterBottom(rRectangle.Center().X(), rRectangle.Bottom());
     278                 :            :                     aInnerPoly.appendBezierSegment(
     279                 :            :                         aCenterBottom,
     280                 :            :                         aCenterBottom,
     281 [ #  # ][ #  # ]:          0 :                         basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Center().Y()));
                 [ #  # ]
     282                 :            : 
     283         [ #  # ]:          0 :                     const basegfx::B2DPoint aCenterTop(rRectangle.Center().X(), rRectangle.Top());
     284                 :            :                     aInnerPoly.appendBezierSegment(
     285                 :            :                         aCenterTop,
     286                 :            :                         aCenterTop,
     287         [ #  # ]:          0 :                         basegfx::B2DPoint(rRectangle.Right(), rRectangle.Top()));
     288                 :            : 
     289         [ #  # ]:          0 :                     aPoly.append(aInnerPoly);
     290         [ #  # ]:          0 :                     break;
     291                 :            :                 }
     292                 :            :                 case SID_DRAW_FREELINE_NOFILL:
     293                 :            :                 {
     294         [ #  # ]:          0 :                     basegfx::B2DPolygon aInnerPoly;
     295                 :            : 
     296         [ #  # ]:          0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
     297                 :            : 
     298                 :            :                     aInnerPoly.appendBezierSegment(
     299                 :          0 :                         basegfx::B2DPoint(rRectangle.Left(), rRectangle.Top()),
     300         [ #  # ]:          0 :                         basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Top()),
     301 [ #  # ][ #  # ]:          0 :                         basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Center().Y()));
                 [ #  # ]
     302                 :            : 
     303                 :            :                     aInnerPoly.appendBezierSegment(
     304         [ #  # ]:          0 :                         basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Bottom()),
     305                 :          0 :                         basegfx::B2DPoint(rRectangle.Right(), rRectangle.Bottom()),
     306         [ #  # ]:          0 :                         basegfx::B2DPoint(rRectangle.Right(), rRectangle.Top()));
     307                 :            : 
     308         [ #  # ]:          0 :                     aPoly.append(aInnerPoly);
     309         [ #  # ]:          0 :                     break;
     310                 :            :                 }
     311                 :            :                 case SID_DRAW_POLYGON:
     312                 :            :                 case SID_DRAW_POLYGON_NOFILL:
     313                 :            :                 {
     314         [ #  # ]:          0 :                     basegfx::B2DPolygon aInnerPoly;
     315         [ #  # ]:          0 :                     const sal_Int32 nWdt(rRectangle.GetWidth());
     316         [ #  # ]:          0 :                     const sal_Int32 nHgt(rRectangle.GetHeight());
     317                 :            : 
     318         [ #  # ]:          0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
     319         [ #  # ]:          0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 30) / 100, rRectangle.Top() + (nHgt * 70) / 100));
     320         [ #  # ]:          0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Top() + (nHgt * 15) / 100));
     321         [ #  # ]:          0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 65) / 100, rRectangle.Top()));
     322         [ #  # ]:          0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + nWdt, rRectangle.Top() + (nHgt * 30) / 100));
     323         [ #  # ]:          0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 80) / 100, rRectangle.Top() + (nHgt * 50) / 100));
     324         [ #  # ]:          0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 80) / 100, rRectangle.Top() + (nHgt * 75) / 100));
     325         [ #  # ]:          0 :                     aInnerPoly.append(basegfx::B2DPoint(rRectangle.Bottom(), rRectangle.Right()));
     326                 :            : 
     327         [ #  # ]:          0 :                     if(SID_DRAW_POLYGON_NOFILL == nID)
     328                 :            :                     {
     329 [ #  # ][ #  # ]:          0 :                         aInnerPoly.append(basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Bottom()));
     330                 :            :                     }
     331                 :            :                     else
     332                 :            :                     {
     333         [ #  # ]:          0 :                         aInnerPoly.setClosed(true);
     334                 :            :                     }
     335                 :            : 
     336         [ #  # ]:          0 :                     aPoly.append(aInnerPoly);
     337         [ #  # ]:          0 :                     break;
     338                 :            :                 }
     339                 :            :             }
     340                 :            : 
     341 [ #  # ][ #  # ]:          0 :             ((SdrPathObj*)pObj)->SetPathPoly(aPoly);
     342                 :            :         }
     343                 :            :         else
     344                 :            :         {
     345                 :            :             OSL_FAIL("Object is NO path object");
     346                 :            :         }
     347                 :            : 
     348                 :          0 :         pObj->SetLogicRect(rRectangle);
     349                 :            :     }
     350                 :            : 
     351                 :          0 :     return pObj;
     352                 :            : }
     353                 :            : 
     354                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10