LCOV - code coverage report
Current view: top level - sd/source/ui/func - fusnapln.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 84 0.0 %
Date: 2014-04-14 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "fusnapln.hxx"
      22             : #include <svl/aeitem.hxx>
      23             : #include <vcl/msgbox.hxx>
      24             : #include <sfx2/request.hxx>
      25             : 
      26             : 
      27             : #include "strings.hrc"
      28             : 
      29             : #include "sdattr.hxx"
      30             : #include "View.hxx"
      31             : #include "ViewShell.hxx"
      32             : #include "DrawViewShell.hxx"
      33             : #include "Window.hxx"
      34             : #include "sdenumdef.hxx"
      35             : #include "sdresid.hxx"
      36             : #include "sdabstdlg.hxx"
      37             : #include "app.hrc"
      38             : #include <svx/svdpagv.hxx>
      39             : 
      40             : namespace sd {
      41             : 
      42           0 : TYPEINIT1( FuSnapLine, FuPoor );
      43             : 
      44           0 : FuSnapLine::FuSnapLine(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
      45             :                        SdDrawDocument* pDoc, SfxRequest& rReq) :
      46           0 :     FuPoor(pViewSh, pWin, pView, pDoc, rReq)
      47             : {
      48           0 : }
      49             : 
      50           0 : rtl::Reference<FuPoor> FuSnapLine::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      51             : {
      52           0 :     rtl::Reference<FuPoor> xFunc( new FuSnapLine( pViewSh, pWin, pView, pDoc, rReq ) );
      53           0 :     xFunc->DoExecute(rReq);
      54           0 :     return xFunc;
      55             : }
      56             : 
      57           0 : void FuSnapLine::DoExecute( SfxRequest& rReq )
      58             : {
      59           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
      60           0 :     sal_uInt16  nHelpLine = 0;
      61           0 :     sal_Bool    bCreateNew = sal_True;
      62             : 
      63             :     // Get index of snap line or snap point from the request.
      64           0 :     SFX_REQUEST_ARG (rReq, pHelpLineIndex, SfxUInt32Item, ID_VAL_INDEX, false);
      65           0 :     if (pHelpLineIndex != NULL)
      66             :     {
      67           0 :         nHelpLine = static_cast<sal_uInt16>(pHelpLineIndex->GetValue());
      68             :         // Reset the argument pointer to trigger the display of the dialog.
      69           0 :         pArgs = NULL;
      70             :     }
      71             : 
      72           0 :     SdrPageView* pPV = mpView->GetSdrPageView();
      73             : 
      74           0 :     if (!pArgs)
      75             :     {
      76           0 :         SfxItemSet aNewAttr(mpViewShell->GetPool(), ATTR_SNAPLINE_START, ATTR_SNAPLINE_END);
      77           0 :         bool bLineExist (false);
      78           0 :         Point aLinePos;
      79             : 
      80           0 :         if (pHelpLineIndex == NULL)
      81             :         {
      82             :             // The index of the snap line is not provided as argument to the
      83             :             // request.  Determine it from the mouse position.
      84             : 
      85           0 :             aLinePos = static_cast<DrawViewShell*>(mpViewShell)->GetMousePos();
      86           0 :             static_cast<DrawViewShell*>(mpViewShell)->SetMousePosFreezed( sal_False );
      87             : 
      88             : 
      89           0 :             if ( aLinePos.X() >= 0 )
      90             :             {
      91           0 :                 aLinePos = mpWindow->PixelToLogic(aLinePos);
      92           0 :                 sal_uInt16 nHitLog = (sal_uInt16) mpWindow->PixelToLogic(Size(HITPIX,0)).Width();
      93           0 :                 bLineExist = mpView->PickHelpLine(aLinePos, nHitLog, *mpWindow, nHelpLine, pPV);
      94           0 :                 if ( bLineExist )
      95           0 :                     aLinePos = (pPV->GetHelpLines())[nHelpLine].GetPos();
      96             :                 else
      97           0 :                     pPV = mpView->GetSdrPageView();
      98             : 
      99           0 :                 pPV->LogicToPagePos(aLinePos);
     100             :             }
     101             :             else
     102           0 :                 aLinePos = Point(0,0);
     103             :         }
     104             :         else
     105             :         {
     106             :             OSL_ASSERT(pPV!=NULL);
     107           0 :             aLinePos = (pPV->GetHelpLines())[nHelpLine].GetPos();
     108           0 :             pPV->LogicToPagePos(aLinePos);
     109           0 :             bLineExist = true;
     110             :         }
     111           0 :         aNewAttr.Put(SfxUInt32Item(ATTR_SNAPLINE_X, aLinePos.X()));
     112           0 :         aNewAttr.Put(SfxUInt32Item(ATTR_SNAPLINE_Y, aLinePos.Y()));
     113             : 
     114           0 :         SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
     115           0 :         AbstractSdSnapLineDlg* pDlg = pFact ? pFact->CreateSdSnapLineDlg( NULL, aNewAttr, mpView ) : 0;
     116             :         OSL_ASSERT(pDlg);
     117           0 :         if (!pDlg)
     118           0 :             return;
     119             : 
     120           0 :         if ( bLineExist )
     121             :         {
     122           0 :             pDlg->HideRadioGroup();
     123             : 
     124           0 :             const SdrHelpLine& rHelpLine = (pPV->GetHelpLines())[nHelpLine];
     125             : 
     126           0 :             if ( rHelpLine.GetKind() == SDRHELPLINE_POINT )
     127             :             {
     128           0 :                 pDlg->SetText(SD_RESSTR(STR_SNAPDLG_SETPOINT));
     129           0 :                 pDlg->SetInputFields(sal_True, sal_True);
     130             :             }
     131             :             else
     132             :             {
     133           0 :                 pDlg->SetText(SD_RESSTR(STR_SNAPDLG_SETLINE));
     134             : 
     135           0 :                 if ( rHelpLine.GetKind() == SDRHELPLINE_VERTICAL )
     136           0 :                     pDlg->SetInputFields(sal_True, sal_False);
     137             :                 else
     138           0 :                     pDlg->SetInputFields(sal_False, sal_True);
     139             :             }
     140           0 :             bCreateNew = sal_False;
     141             :         }
     142             :         else
     143           0 :             pDlg->HideDeleteBtn();
     144             : 
     145           0 :         sal_uInt16 nResult = pDlg->Execute();
     146             : 
     147           0 :         pDlg->GetAttr(aNewAttr);
     148           0 :         delete pDlg;
     149             : 
     150           0 :         switch( nResult )
     151             :         {
     152             :             case RET_OK:
     153           0 :                 rReq.Done(aNewAttr);
     154           0 :                 pArgs = rReq.GetArgs();
     155           0 :                 break;
     156             : 
     157             :             case RET_SNAP_DELETE:
     158             :                 // delete snap object
     159           0 :                 if ( !bCreateNew )
     160           0 :                     pPV->DeleteHelpLine(nHelpLine);
     161             :                 /*fall-through*/
     162             :             default:
     163           0 :                 return;
     164           0 :         }
     165             :     }
     166           0 :     Point aHlpPos;
     167             : 
     168           0 :     aHlpPos.X() = ((const SfxUInt32Item&) pArgs->Get(ATTR_SNAPLINE_X)).GetValue();
     169           0 :     aHlpPos.Y() = ((const SfxUInt32Item&) pArgs->Get(ATTR_SNAPLINE_Y)).GetValue();
     170           0 :     pPV->PagePosToLogic(aHlpPos);
     171             : 
     172           0 :     if ( bCreateNew )
     173             :     {
     174             :         SdrHelpLineKind eKind;
     175             : 
     176           0 :         pPV = mpView->GetSdrPageView();
     177             : 
     178           0 :         switch ( (SnapKind) ((const SfxAllEnumItem&)
     179           0 :                  pArgs->Get(ATTR_SNAPLINE_KIND)).GetValue() )
     180             :         {
     181           0 :             case SK_HORIZONTAL  : eKind = SDRHELPLINE_HORIZONTAL;   break;
     182           0 :             case SK_VERTICAL    : eKind = SDRHELPLINE_VERTICAL;     break;
     183           0 :             default             : eKind = SDRHELPLINE_POINT;        break;
     184             :         }
     185           0 :         pPV->InsertHelpLine(SdrHelpLine(eKind, aHlpPos));
     186             :     }
     187             :     else
     188             :     {
     189           0 :         const SdrHelpLine& rHelpLine = (pPV->GetHelpLines())[nHelpLine];
     190           0 :         pPV->SetHelpLine(nHelpLine, SdrHelpLine(rHelpLine.GetKind(), aHlpPos));
     191             :     }
     192             : }
     193             : 
     194           0 : void FuSnapLine::Activate()
     195             : {
     196           0 : }
     197             : 
     198           0 : void FuSnapLine::Deactivate()
     199             : {
     200           0 : }
     201             : 
     202           0 : } // end of namespace sd
     203             : 
     204             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10