LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuediglu.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 148 0.0 %
Date: 2012-08-25 Functions: 0 18 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 193 0.0 %

           Branch data     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 "fuediglu.hxx"
      22                 :            : #include <svl/eitem.hxx>
      23                 :            : #include <svx/dialogs.hrc>
      24                 :            : #include <svx/svdglue.hxx>
      25                 :            : #include <sfx2/request.hxx>
      26                 :            : 
      27                 :            : 
      28                 :            : #include "app.hrc"
      29                 :            : #include "strings.hrc"
      30                 :            : #include "res_bmp.hrc"
      31                 :            : #include "Window.hxx"
      32                 :            : #include "drawdoc.hxx"
      33                 :            : #include "FrameView.hxx"
      34                 :            : #include "View.hxx"
      35                 :            : #include "ViewShell.hxx"
      36                 :            : #include "ViewShellBase.hxx"
      37                 :            : #include "ToolBarManager.hxx"
      38                 :            : 
      39                 :            : namespace sd {
      40                 :            : 
      41 [ #  # ][ #  # ]:          0 : TYPEINIT1( FuEditGluePoints, FuDraw );
      42                 :            : 
      43                 :            : /*************************************************************************
      44                 :            : |*
      45                 :            : |* Konstruktor
      46                 :            : |*
      47                 :            : \************************************************************************/
      48                 :            : 
      49                 :          0 : FuEditGluePoints::FuEditGluePoints (
      50                 :            :     ViewShell* pViewSh,
      51                 :            :     ::sd::Window* pWin,
      52                 :            :     ::sd::View* pView,
      53                 :            :     SdDrawDocument* pDoc,
      54                 :            :     SfxRequest& rReq)
      55                 :          0 :     : FuDraw(pViewSh, pWin, pView, pDoc, rReq)
      56                 :            : {
      57                 :          0 : }
      58                 :            : 
      59                 :          0 : FunctionReference FuEditGluePoints::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
      60                 :            : {
      61                 :            :     FuEditGluePoints* pFunc;
      62 [ #  # ][ #  # ]:          0 :     FunctionReference xFunc( pFunc = new FuEditGluePoints( pViewSh, pWin, pView, pDoc, rReq ) );
      63         [ #  # ]:          0 :     xFunc->DoExecute(rReq);
      64                 :          0 :     pFunc->SetPermanent( bPermanent );
      65                 :          0 :     return xFunc;
      66                 :            : }
      67                 :            : 
      68                 :          0 : void FuEditGluePoints::DoExecute( SfxRequest& rReq )
      69                 :            : {
      70                 :          0 :     FuDraw::DoExecute( rReq );
      71                 :          0 :     mpView->SetInsGluePointMode(sal_False);
      72                 :          0 :     mpViewShell->GetViewShellBase().GetToolBarManager()->AddToolBar(
      73                 :            :         ToolBarManager::TBG_FUNCTION,
      74         [ #  # ]:          0 :         ToolBarManager::msGluePointsToolBar);
      75                 :          0 : }
      76                 :            : 
      77                 :            : /*************************************************************************
      78                 :            : |*
      79                 :            : |* Destruktor
      80                 :            : |*
      81                 :            : \************************************************************************/
      82                 :            : 
      83                 :          0 : FuEditGluePoints::~FuEditGluePoints()
      84                 :            : {
      85         [ #  # ]:          0 :     mpView->BrkAction();
      86         [ #  # ]:          0 :     mpView->UnmarkAllGluePoints();
      87                 :          0 :     mpView->SetInsGluePointMode(sal_False);
      88         [ #  # ]:          0 : }
      89                 :            : 
      90                 :            : /*************************************************************************
      91                 :            : |*
      92                 :            : |* MouseButtonDown-event
      93                 :            : |*
      94                 :            : \************************************************************************/
      95                 :            : 
      96                 :          0 : sal_Bool FuEditGluePoints::MouseButtonDown(const MouseEvent& rMEvt)
      97                 :            : {
      98                 :          0 :     mpView->SetActualWin( mpWindow );
      99                 :            : 
     100                 :          0 :     sal_Bool bReturn = FuDraw::MouseButtonDown(rMEvt);
     101                 :            : 
     102         [ #  # ]:          0 :     if (mpView->IsAction())
     103                 :            :     {
     104         [ #  # ]:          0 :         if (rMEvt.IsRight())
     105                 :          0 :             mpView->BckAction();
     106                 :            : 
     107                 :          0 :         return sal_True;
     108                 :            :     }
     109                 :            : 
     110         [ #  # ]:          0 :     if (rMEvt.IsLeft())
     111                 :            :     {
     112                 :          0 :         bReturn = sal_True;
     113         [ #  # ]:          0 :         sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
     114         [ #  # ]:          0 :         sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
     115         [ #  # ]:          0 :         mpWindow->CaptureMouse();
     116                 :            : 
     117         [ #  # ]:          0 :         SdrViewEvent aVEvt;
     118         [ #  # ]:          0 :         SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
     119                 :            : 
     120         [ #  # ]:          0 :         if (eHit == SDRHIT_HANDLE)
     121                 :            :         {
     122                 :            :             /******************************************************************
     123                 :            :             * Handle draggen
     124                 :            :             ******************************************************************/
     125                 :          0 :             SdrHdl* pHdl = aVEvt.pHdl;
     126                 :            : 
     127 [ #  # ][ #  # ]:          0 :             if (mpView->IsGluePointMarked(aVEvt.pObj, aVEvt.nGlueId) && rMEvt.IsShift())
         [ #  # ][ #  # ]
     128                 :            :             {
     129         [ #  # ]:          0 :                 mpView->UnmarkGluePoint(aVEvt.pObj, aVEvt.nGlueId, aVEvt.pPV);
     130                 :          0 :                 pHdl = NULL;
     131                 :            :             }
     132                 :            : 
     133         [ #  # ]:          0 :             if (pHdl)
     134                 :            :             {
     135                 :            :                 // Handle draggen
     136         [ #  # ]:          0 :                 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
     137                 :            :             }
     138                 :            :         }
     139 [ #  # ][ #  # ]:          0 :         else if (eHit == SDRHIT_MARKEDOBJECT && mpView->IsInsGluePointMode())
                 [ #  # ]
     140                 :            :         {
     141                 :            :             /******************************************************************
     142                 :            :             * Klebepunkt einfuegen
     143                 :            :             ******************************************************************/
     144         [ #  # ]:          0 :             mpView->BegInsGluePoint(aMDPos);
     145                 :            :         }
     146 [ #  # ][ #  # ]:          0 :         else if (eHit == SDRHIT_MARKEDOBJECT && rMEvt.IsMod1())
                 [ #  # ]
     147                 :            :         {
     148                 :            :             /******************************************************************
     149                 :            :             * Klebepunkt selektieren
     150                 :            :             ******************************************************************/
     151         [ #  # ]:          0 :             if (!rMEvt.IsShift())
     152         [ #  # ]:          0 :                 mpView->UnmarkAllGluePoints();
     153                 :            : 
     154         [ #  # ]:          0 :             mpView->BegMarkGluePoints(aMDPos);
     155                 :            :         }
     156 [ #  # ][ #  # ]:          0 :         else if (eHit == SDRHIT_MARKEDOBJECT && !rMEvt.IsShift() && !rMEvt.IsMod2())
         [ #  # ][ #  # ]
     157                 :            :         {
     158                 :            :             /******************************************************************
     159                 :            :             * Objekt verschieben
     160                 :            :             ******************************************************************/
     161         [ #  # ]:          0 :             mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, NULL, nDrgLog);
     162                 :            :         }
     163         [ #  # ]:          0 :         else if (eHit == SDRHIT_GLUEPOINT)
     164                 :            :         {
     165                 :            :             /******************************************************************
     166                 :            :             * Klebepunkt selektieren
     167                 :            :             ******************************************************************/
     168         [ #  # ]:          0 :             if (!rMEvt.IsShift())
     169         [ #  # ]:          0 :                 mpView->UnmarkAllGluePoints();
     170                 :            : 
     171         [ #  # ]:          0 :             mpView->MarkGluePoint(aVEvt.pObj, aVEvt.nGlueId, aVEvt.pPV);
     172         [ #  # ]:          0 :             SdrHdl* pHdl = mpView->GetGluePointHdl(aVEvt.pObj, aVEvt.nGlueId);
     173                 :            : 
     174         [ #  # ]:          0 :             if (pHdl)
     175                 :            :             {
     176         [ #  # ]:          0 :                 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
     177                 :            :             }
     178                 :            :         }
     179                 :            :         else
     180                 :            :         {
     181                 :            :             /******************************************************************
     182                 :            :             * Objekt selektieren oder draggen
     183                 :            :             ******************************************************************/
     184 [ #  # ][ #  # ]:          0 :             if (!rMEvt.IsShift() && !rMEvt.IsMod2() && eHit == SDRHIT_UNMARKEDOBJECT)
         [ #  # ][ #  # ]
     185                 :            :             {
     186         [ #  # ]:          0 :                mpView->UnmarkAllObj();
     187                 :            :             }
     188                 :            : 
     189                 :          0 :             sal_Bool bMarked = sal_False;
     190                 :            : 
     191         [ #  # ]:          0 :             if (!rMEvt.IsMod1())
     192                 :            :             {
     193         [ #  # ]:          0 :                 if (rMEvt.IsMod2())
     194                 :            :                 {
     195         [ #  # ]:          0 :                     bMarked = mpView->MarkNextObj(aMDPos, nHitLog, rMEvt.IsShift());
     196                 :            :                 }
     197                 :            :                 else
     198                 :            :                 {
     199         [ #  # ]:          0 :                     bMarked = mpView->MarkObj(aMDPos, nHitLog, rMEvt.IsShift());
     200                 :            :                 }
     201                 :            :             }
     202                 :            : 
     203   [ #  #  #  # ]:          0 :             if (bMarked &&
         [ #  # ][ #  # ]
     204                 :          0 :                 (!rMEvt.IsShift() || eHit == SDRHIT_MARKEDOBJECT))
     205                 :            :             {
     206                 :            :                 // Objekt verschieben
     207         [ #  # ]:          0 :                 mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
     208                 :            :             }
     209         [ #  # ]:          0 :             else if (mpView->AreObjectsMarked())
     210                 :            :             {
     211                 :            :                 /**************************************************************
     212                 :            :                 * Klebepunkt selektieren
     213                 :            :                 **************************************************************/
     214         [ #  # ]:          0 :                 if (!rMEvt.IsShift())
     215         [ #  # ]:          0 :                     mpView->UnmarkAllGluePoints();
     216                 :            : 
     217         [ #  # ]:          0 :                 mpView->BegMarkGluePoints(aMDPos);
     218                 :            :             }
     219                 :            :             else
     220                 :            :             {
     221                 :            :                 /**************************************************************
     222                 :            :                 * Objekt selektieren
     223                 :            :                 **************************************************************/
     224         [ #  # ]:          0 :                 mpView->BegMarkObj(aMDPos);
     225                 :            :             }
     226                 :            :         }
     227                 :            : 
     228 [ #  # ][ #  # ]:          0 :         ForcePointer(&rMEvt);
     229                 :            :     }
     230                 :            : 
     231                 :          0 :     return bReturn;
     232                 :            : }
     233                 :            : 
     234                 :            : /*************************************************************************
     235                 :            : |*
     236                 :            : |* MouseMove-event
     237                 :            : |*
     238                 :            : \************************************************************************/
     239                 :            : 
     240                 :          0 : sal_Bool FuEditGluePoints::MouseMove(const MouseEvent& rMEvt)
     241                 :            : {
     242                 :          0 :     mpView->SetActualWin( mpWindow );
     243                 :            : 
     244                 :          0 :     FuDraw::MouseMove(rMEvt);
     245                 :            : 
     246         [ #  # ]:          0 :     if (mpView->IsAction())
     247                 :            :     {
     248                 :          0 :         Point aPix(rMEvt.GetPosPixel());
     249         [ #  # ]:          0 :         Point aPnt( mpWindow->PixelToLogic(aPix) );
     250         [ #  # ]:          0 :         ForceScroll(aPix);
     251         [ #  # ]:          0 :         mpView->MovAction(aPnt);
     252                 :            :     }
     253                 :            : 
     254                 :          0 :     ForcePointer(&rMEvt);
     255                 :            : 
     256                 :          0 :     return sal_True;
     257                 :            : }
     258                 :            : 
     259                 :            : /*************************************************************************
     260                 :            : |*
     261                 :            : |* MouseButtonUp-event
     262                 :            : |*
     263                 :            : \************************************************************************/
     264                 :            : 
     265                 :          0 : sal_Bool FuEditGluePoints::MouseButtonUp(const MouseEvent& rMEvt)
     266                 :            : {
     267         [ #  # ]:          0 :     mpView->SetActualWin( mpWindow );
     268                 :            : 
     269                 :          0 :     sal_Bool bReturn = sal_False;
     270                 :            : 
     271 [ #  # ][ #  # ]:          0 :     if (mpView->IsAction())
     272                 :            :     {
     273                 :          0 :         bReturn = sal_True;
     274         [ #  # ]:          0 :         mpView->EndAction();
     275                 :            :     }
     276                 :            : 
     277         [ #  # ]:          0 :     FuDraw::MouseButtonUp(rMEvt);
     278                 :            : 
     279         [ #  # ]:          0 :     sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
     280         [ #  # ]:          0 :     Point aPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
     281                 :            : 
     282   [ #  #  #  #  :          0 :     if (Abs(aMDPos.X() - aPos.X()) < nDrgLog &&
             #  #  #  # ]
                 [ #  # ]
     283                 :          0 :         Abs(aMDPos.Y() - aPos.Y()) < nDrgLog &&
     284                 :          0 :         !rMEvt.IsShift() && !rMEvt.IsMod2())
     285                 :            :     {
     286         [ #  # ]:          0 :         SdrViewEvent aVEvt;
     287         [ #  # ]:          0 :         SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
     288                 :            : 
     289         [ #  # ]:          0 :         if (eHit == SDRHIT_NONE)
     290                 :            :         {
     291                 :            :             // Klick auf der Stelle: deselektieren
     292         [ #  # ]:          0 :             mpView->UnmarkAllObj();
     293         [ #  # ]:          0 :         }
     294                 :            :     }
     295                 :            : 
     296         [ #  # ]:          0 :     mpWindow->ReleaseMouse();
     297                 :            : 
     298                 :          0 :     return bReturn;
     299                 :            : }
     300                 :            : 
     301                 :            : /*************************************************************************
     302                 :            : |*
     303                 :            : |* Tastaturereignisse bearbeiten
     304                 :            : |*
     305                 :            : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
     306                 :            : |* sal_False.
     307                 :            : |*
     308                 :            : \************************************************************************/
     309                 :            : 
     310                 :          0 : sal_Bool FuEditGluePoints::KeyInput(const KeyEvent& rKEvt)
     311                 :            : {
     312                 :          0 :     mpView->SetActualWin( mpWindow );
     313                 :            : 
     314                 :          0 :     sal_Bool bReturn = FuDraw::KeyInput(rKEvt);
     315                 :            : 
     316                 :          0 :     return bReturn;
     317                 :            : }
     318                 :            : 
     319                 :            : /*************************************************************************
     320                 :            : |*
     321                 :            : |* Command-event
     322                 :            : |*
     323                 :            : \************************************************************************/
     324                 :            : 
     325                 :          0 : sal_Bool FuEditGluePoints::Command(const CommandEvent& rCEvt)
     326                 :            : {
     327                 :          0 :     mpView->SetActualWin( mpWindow );
     328                 :          0 :     return FuPoor::Command( rCEvt );
     329                 :            : }
     330                 :            : 
     331                 :            : /*************************************************************************
     332                 :            : |*
     333                 :            : |* Funktion aktivieren
     334                 :            : |*
     335                 :            : \************************************************************************/
     336                 :            : 
     337                 :          0 : void FuEditGluePoints::Activate()
     338                 :            : {
     339                 :          0 :     mpView->SetGluePointEditMode();
     340                 :          0 :     FuDraw::Activate();
     341                 :          0 : }
     342                 :            : 
     343                 :            : /*************************************************************************
     344                 :            : |*
     345                 :            : |* Funktion deaktivieren
     346                 :            : |*
     347                 :            : \************************************************************************/
     348                 :            : 
     349                 :          0 : void FuEditGluePoints::Deactivate()
     350                 :            : {
     351                 :          0 :     mpView->SetGluePointEditMode( sal_False );
     352                 :          0 :     FuDraw::Deactivate();
     353                 :          0 : }
     354                 :            : 
     355                 :            : /*************************************************************************
     356                 :            : |*
     357                 :            : |* Request verarbeiten
     358                 :            : |*
     359                 :            : \************************************************************************/
     360                 :            : 
     361                 :          0 : void FuEditGluePoints::ReceiveRequest(SfxRequest& rReq)
     362                 :            : {
     363   [ #  #  #  #  :          0 :     switch (rReq.GetSlot())
          #  #  #  #  #  
             #  #  #  # ]
     364                 :            :     {
     365                 :            :         case SID_GLUE_INSERT_POINT:
     366                 :            :         {
     367                 :          0 :             mpView->SetInsGluePointMode(!mpView->IsInsGluePointMode());
     368                 :            :         }
     369                 :          0 :         break;
     370                 :            : 
     371                 :            :         case SID_GLUE_ESCDIR_LEFT:
     372                 :            :         {
     373                 :            :             mpView->SetMarkedGluePointsEscDir( SDRESC_LEFT,
     374                 :          0 :                     !mpView->IsMarkedGluePointsEscDir( SDRESC_LEFT ) );
     375                 :            :         }
     376                 :          0 :         break;
     377                 :            : 
     378                 :            :         case SID_GLUE_ESCDIR_RIGHT:
     379                 :            :         {
     380                 :            :             mpView->SetMarkedGluePointsEscDir( SDRESC_RIGHT,
     381                 :          0 :                     !mpView->IsMarkedGluePointsEscDir( SDRESC_RIGHT ) );
     382                 :            :         }
     383                 :          0 :         break;
     384                 :            : 
     385                 :            :         case SID_GLUE_ESCDIR_TOP:
     386                 :            :         {
     387                 :            :             mpView->SetMarkedGluePointsEscDir( SDRESC_TOP,
     388                 :          0 :                     !mpView->IsMarkedGluePointsEscDir( SDRESC_TOP ) );
     389                 :            :         }
     390                 :          0 :         break;
     391                 :            : 
     392                 :            :         case SID_GLUE_ESCDIR_BOTTOM:
     393                 :            :         {
     394                 :            :             mpView->SetMarkedGluePointsEscDir( SDRESC_BOTTOM,
     395                 :          0 :                     !mpView->IsMarkedGluePointsEscDir( SDRESC_BOTTOM ) );
     396                 :            :         }
     397                 :          0 :         break;
     398                 :            : 
     399                 :            :         case SID_GLUE_PERCENT:
     400                 :            :         {
     401                 :          0 :             const SfxItemSet* pSet = rReq.GetArgs();
     402                 :          0 :             const SfxPoolItem& rItem = pSet->Get(SID_GLUE_PERCENT);
     403                 :          0 :             sal_Bool bPercent = ((const SfxBoolItem&) rItem).GetValue();
     404                 :          0 :             mpView->SetMarkedGluePointsPercent(bPercent);
     405                 :            :         }
     406                 :          0 :         break;
     407                 :            : 
     408                 :            :         case SID_GLUE_HORZALIGN_CENTER:
     409                 :            :         {
     410                 :          0 :             mpView->SetMarkedGluePointsAlign(sal_False, SDRHORZALIGN_CENTER);
     411                 :            :         }
     412                 :          0 :         break;
     413                 :            : 
     414                 :            :         case SID_GLUE_HORZALIGN_LEFT:
     415                 :            :         {
     416                 :          0 :             mpView->SetMarkedGluePointsAlign(sal_False, SDRHORZALIGN_LEFT);
     417                 :            :         }
     418                 :          0 :         break;
     419                 :            : 
     420                 :            :         case SID_GLUE_HORZALIGN_RIGHT:
     421                 :            :         {
     422                 :          0 :             mpView->SetMarkedGluePointsAlign(sal_False, SDRHORZALIGN_RIGHT);
     423                 :            :         }
     424                 :          0 :         break;
     425                 :            : 
     426                 :            :         case SID_GLUE_VERTALIGN_CENTER:
     427                 :            :         {
     428                 :          0 :             mpView->SetMarkedGluePointsAlign(sal_True, SDRVERTALIGN_CENTER);
     429                 :            :         }
     430                 :          0 :         break;
     431                 :            : 
     432                 :            :         case SID_GLUE_VERTALIGN_TOP:
     433                 :            :         {
     434                 :          0 :             mpView->SetMarkedGluePointsAlign(sal_True, SDRVERTALIGN_TOP);
     435                 :            :         }
     436                 :          0 :         break;
     437                 :            : 
     438                 :            :         case SID_GLUE_VERTALIGN_BOTTOM:
     439                 :            :         {
     440                 :          0 :             mpView->SetMarkedGluePointsAlign(sal_True, SDRVERTALIGN_BOTTOM);
     441                 :            :         }
     442                 :          0 :         break;
     443                 :            :     }
     444                 :            : 
     445                 :            :     // Zum Schluss Basisklasse rufen
     446                 :          0 :     FuPoor::ReceiveRequest(rReq);
     447                 :          0 : }
     448                 :            : 
     449                 :            : 
     450                 :            : } // end of namespace sd
     451                 :            : 
     452                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10