LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuconstr.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 142 0.0 %
Date: 2014-04-14 Functions: 0 15 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 "fuconstr.hxx"
      22             : 
      23             : #include <svx/svxids.hrc>
      24             : #include <svl/aeitem.hxx>
      25             : #include <svx/svdpagv.hxx>
      26             : #include <svx/xdef.hxx>
      27             : #include <svx/xfillit0.hxx>
      28             : #include <sfx2/dispatch.hxx>
      29             : #include <sfx2/viewfrm.hxx>
      30             : 
      31             : #include "app.hrc"
      32             : #include "glob.hrc"
      33             : #include "fudraw.hxx"
      34             : #include "View.hxx"
      35             : #include "Window.hxx"
      36             : #include "ViewShell.hxx"
      37             : #include "drawdoc.hxx"
      38             : #include "FrameView.hxx"
      39             : #include "sdpage.hxx"
      40             : #include "sdresid.hxx"
      41             : #include "stlpool.hxx"
      42             : #include <svx/globl3d.hxx>
      43             : 
      44             : namespace sd {
      45             : 
      46           0 : TYPEINIT1( FuConstruct, FuDraw );
      47             : 
      48             : 
      49           0 : FuConstruct::FuConstruct (
      50             :     ViewShell*      pViewSh,
      51             :     ::sd::Window*           pWin,
      52             :     ::sd::View*         pView,
      53             :     SdDrawDocument* pDoc,
      54             :     SfxRequest&     rReq)
      55             :     : FuDraw(pViewSh, pWin, pView, pDoc, rReq),
      56           0 :       bSelectionChanged(false)
      57             : {
      58           0 : }
      59             : 
      60           0 : void FuConstruct::DoExecute( SfxRequest& rReq )
      61             : {
      62           0 :     FuDraw::DoExecute( rReq );
      63           0 : }
      64             : 
      65             : 
      66           0 : sal_Bool FuConstruct::MouseButtonDown(const MouseEvent& rMEvt)
      67             : {
      68           0 :     sal_Bool bReturn = FuDraw::MouseButtonDown(rMEvt);
      69             : 
      70           0 :     bMBDown = sal_True;
      71           0 :     bSelectionChanged = false;
      72             : 
      73           0 :     if ( mpView->IsAction() )
      74             :     {
      75           0 :         return sal_True;
      76             :     }
      77             : 
      78           0 :     bFirstMouseMove = sal_True;
      79           0 :     aDragTimer.Start();
      80             : 
      81           0 :     aMDPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
      82           0 :     sal_uInt16 nHitLog = sal_uInt16 (mpWindow->PixelToLogic(Size(HITPIX,0)).Width());
      83             : 
      84           0 :     if (rMEvt.IsLeft() && mpView->IsExtendedMouseEventDispatcherEnabled())
      85             :     {
      86           0 :         mpWindow->CaptureMouse();
      87             : 
      88           0 :         SdrHdl* pHdl = mpView->PickHandle(aMDPos);
      89             : 
      90           0 :         if ( pHdl != NULL || mpView->IsMarkedHit(aMDPos, nHitLog) )
      91             :         {
      92           0 :             sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
      93           0 :             mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
      94           0 :             bReturn = sal_True;
      95             :         }
      96           0 :         else if ( mpView->AreObjectsMarked() )
      97             :         {
      98           0 :             mpView->UnmarkAll();
      99           0 :             bReturn = sal_True;
     100             :         }
     101             :     }
     102             : 
     103           0 :     return bReturn;
     104             : }
     105             : 
     106             : 
     107           0 : sal_Bool FuConstruct::MouseMove(const MouseEvent& rMEvt)
     108             : {
     109           0 :     FuDraw::MouseMove(rMEvt);
     110             : 
     111           0 :     if (aDragTimer.IsActive() )
     112             :     {
     113           0 :         if( bFirstMouseMove )
     114           0 :             bFirstMouseMove = sal_False;
     115             :         else
     116           0 :             aDragTimer.Stop();
     117             :     }
     118             : 
     119           0 :     Point aPix(rMEvt.GetPosPixel());
     120           0 :     Point aPnt( mpWindow->PixelToLogic(aPix) );
     121             : 
     122           0 :     if ( mpView->IsAction() )
     123             :     {
     124           0 :         ForceScroll(aPix);
     125           0 :         mpView->MovAction(aPnt);
     126             :     }
     127             : 
     128           0 :     return sal_True;
     129             : }
     130             : 
     131             : 
     132           0 : sal_Bool FuConstruct::MouseButtonUp(const MouseEvent& rMEvt)
     133             : {
     134           0 :     sal_Bool bReturn = sal_True;
     135             : 
     136           0 :     if (aDragTimer.IsActive() )
     137             :     {
     138           0 :         aDragTimer.Stop();
     139           0 :         bIsInDragMode = sal_False;
     140             :     }
     141             : 
     142           0 :     FuDraw::MouseButtonUp(rMEvt);
     143             : 
     144           0 :     Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
     145             : 
     146           0 :     if ( mpView && mpView->IsDragObj() )
     147             :     {
     148           0 :         FrameView* pFrameView = mpViewShell->GetFrameView();
     149           0 :         sal_Bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
     150             : 
     151           0 :         if (bDragWithCopy)
     152             :         {
     153           0 :             bDragWithCopy = !mpView->IsPresObjSelected(sal_False, sal_True);
     154             :         }
     155             : 
     156           0 :         mpView->SetDragWithCopy(bDragWithCopy);
     157           0 :         mpView->EndDragObj( mpView->IsDragWithCopy() );
     158             :     }
     159           0 :     else if ( mpView && mpView->IsMarkObj() )
     160             :     {
     161           0 :         mpView->EndMarkObj();
     162             :     }
     163             :     else
     164             :     {
     165           0 :         bReturn = sal_False;
     166             :     }
     167             : 
     168           0 :     if ( mpView &&  !mpView->IsAction() )
     169             :     {
     170           0 :         mpWindow->ReleaseMouse();
     171           0 :         sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
     172             : 
     173           0 :         if ( !mpView->AreObjectsMarked() )
     174             :         {
     175             :             SdrObject* pObj;
     176             :             SdrPageView* pPV;
     177           0 :             sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
     178             : 
     179           0 :             if (!mpView->PickObj(aPnt, mpView->getHitTolLog(), pObj, pPV))
     180             :             {
     181           0 :                 mpView->MarkObj(aPnt, nHitLog);
     182             :             }
     183             : 
     184           0 :             mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
     185             :         }
     186           0 :         else if (rMEvt.IsLeft() && !rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() &&
     187           0 :                  !bSelectionChanged                   &&
     188           0 :                  std::abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
     189           0 :                  std::abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
     190             :         {
     191             :             // toggle between selection and rotation
     192           0 :             SdrObject* pSingleObj = NULL;
     193           0 :             sal_uLong nMarkCount = mpView->GetMarkedObjectList().GetMarkCount();
     194             : 
     195           0 :             if (nMarkCount==1)
     196             :             {
     197           0 :                 pSingleObj = mpView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
     198             :             }
     199             : 
     200           0 :             if (mpView->GetDragMode() == SDRDRAG_MOVE && mpView->IsRotateAllowed() &&
     201           0 :                 (mpViewShell->GetFrameView()->IsClickChangeRotation() ||
     202           0 :                  (pSingleObj && pSingleObj->GetObjInventor()==E3dInventor)))
     203             :             {
     204           0 :                 mpView->SetDragMode(SDRDRAG_ROTATE);
     205             :             }
     206             :             else
     207             :             {
     208           0 :                 mpView->SetDragMode(SDRDRAG_MOVE);
     209             :             }
     210             :         }
     211             :     }
     212             : 
     213           0 :     sal_uInt16 nClicks = rMEvt.GetClicks();
     214             : 
     215           0 :     if (nClicks == 2 && rMEvt.IsLeft() && bMBDown &&
     216           0 :         !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsShift() )
     217             :     {
     218           0 :         DoubleClick(rMEvt);
     219             :     }
     220           0 :     bMBDown = sal_False;
     221             : 
     222           0 :     return bReturn;
     223             : }
     224             : 
     225             : /**
     226             :  * Process keyboard input
     227             :  * @returns sal_True if a KeyEvent is being processed, sal_False otherwise
     228             :  */
     229           0 : sal_Bool FuConstruct::KeyInput(const KeyEvent& rKEvt)
     230             : {
     231           0 :     sal_Bool bReturn = sal_False;
     232             : 
     233           0 :     if ( !bReturn )
     234           0 :         bReturn = FuDraw::KeyInput(rKEvt);
     235             : 
     236           0 :     return(bReturn);
     237             : }
     238             : 
     239             : 
     240           0 : void FuConstruct::Activate()
     241             : {
     242           0 :     mpView->SetEditMode(SDREDITMODE_CREATE);
     243           0 :     FuDraw::Activate();
     244           0 : }
     245             : 
     246             : 
     247           0 : void FuConstruct::Deactivate()
     248             : {
     249           0 :     FuDraw::Deactivate();
     250           0 :     mpView->SetEditMode(SDREDITMODE_EDIT);
     251           0 : }
     252             : 
     253             : /**
     254             :  * set style sheet for the object to be created
     255             :  */
     256           0 : void FuConstruct::SetStyleSheet(SfxItemSet& rAttr, SdrObject* pObj)
     257             : {
     258             :     sal_Bool bUseFillStyle, bUseNoFillStyle;
     259           0 :     bUseFillStyle = bUseNoFillStyle = sal_False;
     260             : 
     261           0 :     switch( nSlotId )
     262             :     {
     263             :     case SID_DRAW_RECT:
     264             :     case SID_DRAW_RECT_ROUND:
     265             :     case SID_DRAW_SQUARE:
     266             :     case SID_DRAW_SQUARE_ROUND:
     267             :     case SID_DRAW_ELLIPSE:
     268             :     case SID_DRAW_PIE:
     269             :     case SID_DRAW_ELLIPSECUT:
     270             :     case SID_DRAW_CIRCLE:
     271             :     case SID_DRAW_CIRCLEPIE:
     272             :     case SID_DRAW_CIRCLECUT:
     273             :     case SID_DRAW_POLYGON:
     274             :     case SID_DRAW_XPOLYGON:
     275             :     case SID_DRAW_FREELINE:
     276             :     case SID_DRAW_BEZIER_FILL:
     277             :     {
     278           0 :         bUseFillStyle = sal_True;
     279           0 :         break;
     280             :     }
     281             :     case  SID_DRAW_RECT_NOFILL:
     282             :     case SID_DRAW_RECT_ROUND_NOFILL:
     283             :     case SID_DRAW_SQUARE_NOFILL:
     284             :     case SID_DRAW_SQUARE_ROUND_NOFILL:
     285             :     case SID_DRAW_ELLIPSE_NOFILL:
     286             :     case SID_DRAW_PIE_NOFILL:
     287             :     case SID_DRAW_ELLIPSECUT_NOFILL:
     288             :     case SID_DRAW_CIRCLE_NOFILL:
     289             :     case SID_DRAW_CIRCLEPIE_NOFILL:
     290             :     case SID_DRAW_CIRCLECUT_NOFILL:
     291             :     case SID_DRAW_POLYGON_NOFILL:
     292             :     case SID_DRAW_XPOLYGON_NOFILL:
     293             :     case SID_DRAW_FREELINE_NOFILL:
     294             :     case SID_DRAW_LINE:
     295             :     case SID_DRAW_XLINE:
     296             :     case SID_CONNECTOR_ARROW_START:
     297             :     case SID_CONNECTOR_ARROW_END:
     298             :     case SID_CONNECTOR_ARROWS:
     299             :     case SID_CONNECTOR_CIRCLE_START:
     300             :     case SID_CONNECTOR_CIRCLE_END:
     301             :     case SID_CONNECTOR_CIRCLES:
     302             :     case SID_CONNECTOR_LINE:
     303             :     case SID_CONNECTOR_LINE_ARROW_START:
     304             :     case SID_CONNECTOR_LINE_ARROW_END:
     305             :     case SID_CONNECTOR_LINE_ARROWS:
     306             :     case SID_CONNECTOR_LINE_CIRCLE_START:
     307             :     case SID_CONNECTOR_LINE_CIRCLE_END:
     308             :     case SID_CONNECTOR_LINE_CIRCLES:
     309             :     case SID_CONNECTOR_CURVE:
     310             :     case SID_CONNECTOR_CURVE_ARROW_START:
     311             :     case SID_CONNECTOR_CURVE_ARROW_END:
     312             :     case SID_CONNECTOR_CURVE_ARROWS:
     313             :     case SID_CONNECTOR_CURVE_CIRCLE_START:
     314             :     case SID_CONNECTOR_CURVE_CIRCLE_END:
     315             :     case SID_CONNECTOR_CURVE_CIRCLES:
     316             :     case SID_CONNECTOR_LINES:
     317             :     case SID_CONNECTOR_LINES_ARROW_START:
     318             :     case SID_CONNECTOR_LINES_ARROW_END:
     319             :     case SID_CONNECTOR_LINES_ARROWS:
     320             :     case SID_CONNECTOR_LINES_CIRCLE_START:
     321             :     case SID_CONNECTOR_LINES_CIRCLE_END:
     322             :     case SID_CONNECTOR_LINES_CIRCLES:
     323             :     case SID_DRAW_BEZIER_NOFILL:
     324             :     case SID_LINE_ARROW_END:
     325             :     {
     326           0 :         bUseNoFillStyle = sal_True;
     327           0 :         break;
     328             :     }
     329             :     }
     330           0 :     SetStyleSheet( rAttr, pObj, bUseFillStyle, bUseNoFillStyle );
     331           0 : }
     332             : 
     333           0 : void FuConstruct::SetStyleSheet( SfxItemSet& rAttr, SdrObject* pObj,
     334             :         const sal_Bool bForceFillStyle, const sal_Bool bForceNoFillStyle )
     335             : {
     336           0 :     SdPage* pPage = (SdPage*)mpView->GetSdrPageView()->GetPage();
     337           0 :     if ( pPage->IsMasterPage() && pPage->GetPageKind() == PK_STANDARD &&
     338           0 :          mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
     339             :     {
     340             :         /**********************************************
     341             :         * Objects was created on the slide master page
     342             :         ***********************************************/
     343           0 :         OUString aName( pPage->GetLayoutName() );
     344           0 :         sal_Int32 n = aName.indexOf(SD_LT_SEPARATOR) + strlen(SD_LT_SEPARATOR);
     345           0 :         aName = aName.copy(0, n) + SD_RESSTR(STR_LAYOUT_BACKGROUNDOBJECTS);
     346           0 :         SfxStyleSheet* pSheet = (SfxStyleSheet*)pPage->GetModel()->
     347           0 :                                                 GetStyleSheetPool()->
     348           0 :                                                 Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
     349             :         DBG_ASSERT(pSheet, "StyleSheet missing");
     350           0 :         if (pSheet)
     351             :         {
     352             :             // applying style sheet for background objects
     353           0 :             pObj->SetStyleSheet(pSheet, false);
     354           0 :             SfxItemSet& rSet = pSheet->GetItemSet();
     355           0 :             const XFillStyleItem& rFillStyle = (const XFillStyleItem&)rSet.Get(XATTR_FILLSTYLE);
     356           0 :             if ( bForceFillStyle )
     357             :             {
     358           0 :                 if (rFillStyle.GetValue() == XFILL_NONE)
     359           0 :                     rAttr.Put(XFillStyleItem(XFILL_SOLID));
     360             :             }
     361           0 :             else if ( bForceNoFillStyle )
     362             :             {
     363           0 :                 if (rFillStyle.GetValue() != XFILL_NONE)
     364           0 :                     rAttr.Put(XFillStyleItem(XFILL_NONE));
     365             :             }
     366           0 :         }
     367             :     }
     368             :     else
     369             :     {
     370             :         /***********************************
     371             :         * object was created on normal page
     372             :         ************************************/
     373           0 :         if ( bForceNoFillStyle )
     374             :         {
     375           0 :             OUString aName(SD_RESSTR(STR_POOLSHEET_OBJWITHOUTFILL));
     376           0 :             SfxStyleSheet* pSheet = (SfxStyleSheet*)pPage->GetModel()->
     377           0 :                                          GetStyleSheetPool()->
     378           0 :                                          Find(aName, SD_STYLE_FAMILY_GRAPHICS);
     379             :             DBG_ASSERT(pSheet, "Stylesheet missing");
     380           0 :             if (pSheet)
     381             :             {
     382           0 :                 pObj->SetStyleSheet(pSheet, false);
     383           0 :                 SfxItemSet aAttr(*mpView->GetDefaultAttr().Clone());
     384           0 :                 aAttr.Put(pSheet->GetItemSet().Get(XATTR_FILLSTYLE));
     385           0 :                 pObj->SetMergedItemSet(aAttr);
     386             :             }
     387             :             else
     388             :             {
     389           0 :                 SfxItemSet aAttr(*mpView->GetDefaultAttr().Clone());
     390           0 :                 rAttr.Put(XFillStyleItem(XFILL_NONE));
     391           0 :                 pObj->SetMergedItemSet(aAttr);
     392           0 :             }
     393             :         }
     394             :     }
     395           0 : }
     396             : 
     397             : } // end of namespace sd
     398             : 
     399             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10