LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/func - fuconstr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 145 0.0 %
Date: 2012-12-27 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             : |*
      50             : |* Konstruktor
      51             : |*
      52             : \************************************************************************/
      53             : 
      54           0 : FuConstruct::FuConstruct (
      55             :     ViewShell*      pViewSh,
      56             :     ::sd::Window*           pWin,
      57             :     ::sd::View*         pView,
      58             :     SdDrawDocument* pDoc,
      59             :     SfxRequest&     rReq)
      60             :     : FuDraw(pViewSh, pWin, pView, pDoc, rReq),
      61           0 :       bSelectionChanged(sal_False)
      62             : {
      63           0 : }
      64             : 
      65           0 : void FuConstruct::DoExecute( SfxRequest& rReq )
      66             : {
      67           0 :     FuDraw::DoExecute( rReq );
      68           0 : }
      69             : 
      70             : /*************************************************************************
      71             : |*
      72             : |* MouseButtonDown-event
      73             : |*
      74             : \************************************************************************/
      75             : 
      76           0 : sal_Bool FuConstruct::MouseButtonDown(const MouseEvent& rMEvt)
      77             : {
      78           0 :     sal_Bool bReturn = FuDraw::MouseButtonDown(rMEvt);
      79             : 
      80           0 :     bMBDown = sal_True;
      81           0 :     bSelectionChanged = sal_False;
      82             : 
      83           0 :     if ( mpView->IsAction() )
      84             :     {
      85           0 :         return sal_True;
      86             :     }
      87             : 
      88           0 :     bFirstMouseMove = sal_True;
      89           0 :     aDragTimer.Start();
      90             : 
      91           0 :     aMDPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
      92           0 :     sal_uInt16 nHitLog = sal_uInt16 (mpWindow->PixelToLogic(Size(HITPIX,0)).Width());
      93             : 
      94           0 :     if (rMEvt.IsLeft() && mpView->IsExtendedMouseEventDispatcherEnabled())
      95             :     {
      96           0 :         mpWindow->CaptureMouse();
      97             : 
      98           0 :         SdrHdl* pHdl = mpView->PickHandle(aMDPos);
      99             : 
     100           0 :         if ( pHdl != NULL || mpView->IsMarkedHit(aMDPos, nHitLog) )
     101             :         {
     102           0 :             sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
     103           0 :             mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
     104           0 :             bReturn = sal_True;
     105             :         }
     106           0 :         else if ( mpView->AreObjectsMarked() )
     107             :         {
     108           0 :             mpView->UnmarkAll();
     109           0 :             bReturn = sal_True;
     110             :         }
     111             :     }
     112             : 
     113           0 :     return bReturn;
     114             : }
     115             : 
     116             : /*************************************************************************
     117             : |*
     118             : |* MouseMove-event
     119             : |*
     120             : \************************************************************************/
     121             : 
     122           0 : sal_Bool FuConstruct::MouseMove(const MouseEvent& rMEvt)
     123             : {
     124           0 :     FuDraw::MouseMove(rMEvt);
     125             : 
     126           0 :     if (aDragTimer.IsActive() )
     127             :     {
     128           0 :         if( bFirstMouseMove )
     129           0 :             bFirstMouseMove = sal_False;
     130             :         else
     131           0 :             aDragTimer.Stop();
     132             :     }
     133             : 
     134           0 :     Point aPix(rMEvt.GetPosPixel());
     135           0 :     Point aPnt( mpWindow->PixelToLogic(aPix) );
     136             : 
     137           0 :     if ( mpView->IsAction() )
     138             :     {
     139           0 :         ForceScroll(aPix);
     140           0 :         mpView->MovAction(aPnt);
     141             :     }
     142             : 
     143           0 :     return sal_True;
     144             : }
     145             : 
     146             : /*************************************************************************
     147             : |*
     148             : |* MouseButtonUp-event
     149             : |*
     150             : \************************************************************************/
     151             : 
     152           0 : sal_Bool FuConstruct::MouseButtonUp(const MouseEvent& rMEvt)
     153             : {
     154           0 :     sal_Bool bReturn = sal_True;
     155             : 
     156           0 :     if (aDragTimer.IsActive() )
     157             :     {
     158           0 :         aDragTimer.Stop();
     159           0 :         bIsInDragMode = sal_False;
     160             :     }
     161             : 
     162           0 :     FuDraw::MouseButtonUp(rMEvt);
     163             : 
     164           0 :     Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
     165             : 
     166           0 :     if ( mpView && mpView->IsDragObj() )
     167             :     {
     168           0 :         FrameView* pFrameView = mpViewShell->GetFrameView();
     169           0 :         sal_Bool bDragWithCopy = (rMEvt.IsMod1() && pFrameView->IsDragWithCopy());
     170             : 
     171           0 :         if (bDragWithCopy)
     172             :         {
     173           0 :             bDragWithCopy = !mpView->IsPresObjSelected(sal_False, sal_True);
     174             :         }
     175             : 
     176           0 :         mpView->SetDragWithCopy(bDragWithCopy);
     177           0 :         mpView->EndDragObj( mpView->IsDragWithCopy() );
     178             :     }
     179           0 :     else if ( mpView && mpView->IsMarkObj() )
     180             :     {
     181           0 :         mpView->EndMarkObj();
     182             :     }
     183             :     else
     184             :     {
     185           0 :         bReturn = sal_False;
     186             :     }
     187             : 
     188           0 :     if ( mpView &&  !mpView->IsAction() )
     189             :     {
     190           0 :         mpWindow->ReleaseMouse();
     191           0 :         sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
     192             : 
     193           0 :         if ( !mpView->AreObjectsMarked() )
     194             :         {
     195             :             SdrObject* pObj;
     196             :             SdrPageView* pPV;
     197           0 :             sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
     198             : 
     199           0 :             if (!mpView->PickObj(aPnt, mpView->getHitTolLog(), pObj, pPV))
     200             :             {
     201           0 :                 mpView->MarkObj(aPnt, nHitLog);
     202             :             }
     203             : 
     204           0 :             mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
     205             :         }
     206           0 :         else if (rMEvt.IsLeft() && !rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() &&
     207           0 :                  !bSelectionChanged                   &&
     208           0 :                  Abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
     209           0 :                  Abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
     210             :         {
     211             :             /**************************************************************
     212             :             * Toggle zw. Selektion und Rotation
     213             :             **************************************************************/
     214           0 :             SdrObject* pSingleObj = NULL;
     215           0 :             sal_uLong nMarkCount = mpView->GetMarkedObjectList().GetMarkCount();
     216             : 
     217           0 :             if (nMarkCount==1)
     218             :             {
     219           0 :                 pSingleObj = mpView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
     220             :             }
     221             : 
     222           0 :             if (mpView->GetDragMode() == SDRDRAG_MOVE && mpView->IsRotateAllowed() &&
     223           0 :                 (mpViewShell->GetFrameView()->IsClickChangeRotation() ||
     224           0 :                  (pSingleObj && pSingleObj->GetObjInventor()==E3dInventor)))
     225             :             {
     226           0 :                 mpView->SetDragMode(SDRDRAG_ROTATE);
     227             :             }
     228             :             else
     229             :             {
     230           0 :                 mpView->SetDragMode(SDRDRAG_MOVE);
     231             :             }
     232             :         }
     233             :     }
     234             : 
     235           0 :     sal_uInt16 nClicks = rMEvt.GetClicks();
     236             : 
     237           0 :     if (nClicks == 2 && rMEvt.IsLeft() && bMBDown &&
     238           0 :         !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsShift() )
     239             :     {
     240           0 :         DoubleClick(rMEvt);
     241             :     }
     242           0 :     bMBDown = sal_False;
     243             : 
     244           0 :     return bReturn;
     245             : }
     246             : 
     247             : /*************************************************************************
     248             : |*
     249             : |* Tastaturereignisse bearbeiten
     250             : |*
     251             : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
     252             : |* sal_False.
     253             : |*
     254             : \************************************************************************/
     255             : 
     256           0 : sal_Bool FuConstruct::KeyInput(const KeyEvent& rKEvt)
     257             : {
     258           0 :     sal_Bool bReturn = sal_False;
     259             : 
     260           0 :     if ( !bReturn )
     261           0 :         bReturn = FuDraw::KeyInput(rKEvt);
     262             : 
     263           0 :     return(bReturn);
     264             : }
     265             : 
     266             : /*************************************************************************
     267             : |*
     268             : |* Function aktivieren
     269             : |*
     270             : \************************************************************************/
     271             : 
     272           0 : void FuConstruct::Activate()
     273             : {
     274           0 :     mpView->SetEditMode(SDREDITMODE_CREATE);
     275           0 :     FuDraw::Activate();
     276           0 : }
     277             : 
     278             : /*************************************************************************
     279             : |*
     280             : |* Function deaktivieren
     281             : |*
     282             : \************************************************************************/
     283             : 
     284           0 : void FuConstruct::Deactivate()
     285             : {
     286           0 :     FuDraw::Deactivate();
     287           0 :     mpView->SetEditMode(SDREDITMODE_EDIT);
     288           0 : }
     289             : 
     290             : /*************************************************************************
     291             : |*
     292             : |* StyleSheet fuer das zu erzeugende Objekt setzen
     293             : |*
     294             : \************************************************************************/
     295             : 
     296           0 : void FuConstruct::SetStyleSheet(SfxItemSet& rAttr, SdrObject* pObj)
     297             : {
     298             :     sal_Bool bUseFillStyle, bUseNoFillStyle;
     299           0 :     bUseFillStyle = bUseNoFillStyle = sal_False;
     300             : 
     301           0 :     switch( nSlotId )
     302             :     {
     303             :     case SID_DRAW_RECT:
     304             :     case SID_DRAW_RECT_ROUND:
     305             :     case SID_DRAW_SQUARE:
     306             :     case SID_DRAW_SQUARE_ROUND:
     307             :     case SID_DRAW_ELLIPSE:
     308             :     case SID_DRAW_PIE:
     309             :     case SID_DRAW_ELLIPSECUT:
     310             :     case SID_DRAW_CIRCLE:
     311             :     case SID_DRAW_CIRCLEPIE:
     312             :     case SID_DRAW_CIRCLECUT:
     313             :     case SID_DRAW_POLYGON:
     314             :     case SID_DRAW_XPOLYGON:
     315             :     case SID_DRAW_FREELINE:
     316             :     case SID_DRAW_BEZIER_FILL:
     317             :     {
     318           0 :         bUseFillStyle = sal_True;
     319           0 :         break;
     320             :     }
     321             :     case  SID_DRAW_RECT_NOFILL:
     322             :     case SID_DRAW_RECT_ROUND_NOFILL:
     323             :     case SID_DRAW_SQUARE_NOFILL:
     324             :     case SID_DRAW_SQUARE_ROUND_NOFILL:
     325             :     case SID_DRAW_ELLIPSE_NOFILL:
     326             :     case SID_DRAW_PIE_NOFILL:
     327             :     case SID_DRAW_ELLIPSECUT_NOFILL:
     328             :     case SID_DRAW_CIRCLE_NOFILL:
     329             :     case SID_DRAW_CIRCLEPIE_NOFILL:
     330             :     case SID_DRAW_CIRCLECUT_NOFILL:
     331             :     case SID_DRAW_POLYGON_NOFILL:
     332             :     case SID_DRAW_XPOLYGON_NOFILL:
     333             :     case SID_DRAW_FREELINE_NOFILL:
     334             :     case SID_DRAW_LINE:
     335             :     case SID_DRAW_XLINE:
     336             :     case SID_CONNECTOR_ARROW_START:
     337             :     case SID_CONNECTOR_ARROW_END:
     338             :     case SID_CONNECTOR_ARROWS:
     339             :     case SID_CONNECTOR_CIRCLE_START:
     340             :     case SID_CONNECTOR_CIRCLE_END:
     341             :     case SID_CONNECTOR_CIRCLES:
     342             :     case SID_CONNECTOR_LINE:
     343             :     case SID_CONNECTOR_LINE_ARROW_START:
     344             :     case SID_CONNECTOR_LINE_ARROW_END:
     345             :     case SID_CONNECTOR_LINE_ARROWS:
     346             :     case SID_CONNECTOR_LINE_CIRCLE_START:
     347             :     case SID_CONNECTOR_LINE_CIRCLE_END:
     348             :     case SID_CONNECTOR_LINE_CIRCLES:
     349             :     case SID_CONNECTOR_CURVE:
     350             :     case SID_CONNECTOR_CURVE_ARROW_START:
     351             :     case SID_CONNECTOR_CURVE_ARROW_END:
     352             :     case SID_CONNECTOR_CURVE_ARROWS:
     353             :     case SID_CONNECTOR_CURVE_CIRCLE_START:
     354             :     case SID_CONNECTOR_CURVE_CIRCLE_END:
     355             :     case SID_CONNECTOR_CURVE_CIRCLES:
     356             :     case SID_CONNECTOR_LINES:
     357             :     case SID_CONNECTOR_LINES_ARROW_START:
     358             :     case SID_CONNECTOR_LINES_ARROW_END:
     359             :     case SID_CONNECTOR_LINES_ARROWS:
     360             :     case SID_CONNECTOR_LINES_CIRCLE_START:
     361             :     case SID_CONNECTOR_LINES_CIRCLE_END:
     362             :     case SID_CONNECTOR_LINES_CIRCLES:
     363             :     case SID_DRAW_BEZIER_NOFILL:
     364             :     case SID_LINE_ARROW_END:
     365             :     {
     366           0 :         bUseNoFillStyle = sal_True;
     367           0 :         break;
     368             :     }
     369             :     }
     370           0 :     SetStyleSheet( rAttr, pObj, bUseFillStyle, bUseNoFillStyle );
     371           0 : }
     372             : 
     373           0 : void FuConstruct::SetStyleSheet( SfxItemSet& rAttr, SdrObject* pObj,
     374             :         const sal_Bool bForceFillStyle, const sal_Bool bForceNoFillStyle )
     375             : {
     376           0 :     SdPage* pPage = (SdPage*)mpView->GetSdrPageView()->GetPage();
     377           0 :     if ( pPage->IsMasterPage() && pPage->GetPageKind() == PK_STANDARD &&
     378           0 :          mpDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS )
     379             :     {
     380             :         /**********************************************
     381             :         * Objects was created on the slide master page
     382             :         ***********************************************/
     383           0 :         String aName( pPage->GetLayoutName() );
     384           0 :         String aSep = rtl::OUString(SD_LT_SEPARATOR);
     385           0 :         sal_uInt16 n = aName.Search(aSep);
     386           0 :         n = n + aSep.Len();
     387           0 :         aName.Erase(n);
     388           0 :         aName.Append( String ( SdResId( STR_LAYOUT_BACKGROUNDOBJECTS ) ) );
     389           0 :         SfxStyleSheet* pSheet = (SfxStyleSheet*)pPage->GetModel()->
     390           0 :                                                 GetStyleSheetPool()->
     391           0 :                                                 Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
     392             :         DBG_ASSERT(pSheet, "Objektvorlage nicht gefunden");
     393           0 :         if (pSheet)
     394             :         {
     395             :             // applying style sheet for background objects
     396           0 :             pObj->SetStyleSheet(pSheet, sal_False);
     397           0 :             SfxItemSet& rSet = pSheet->GetItemSet();
     398           0 :             const XFillStyleItem& rFillStyle = (const XFillStyleItem&)rSet.Get(XATTR_FILLSTYLE);
     399           0 :             if ( bForceFillStyle )
     400             :             {
     401           0 :                 if (rFillStyle.GetValue() == XFILL_NONE)
     402           0 :                     rAttr.Put(XFillStyleItem(XFILL_SOLID));
     403             :             }
     404           0 :             else if ( bForceNoFillStyle )
     405             :             {
     406           0 :                 if (rFillStyle.GetValue() != XFILL_NONE)
     407           0 :                     rAttr.Put(XFillStyleItem(XFILL_NONE));
     408             :             }
     409           0 :         }
     410             :     }
     411             :     else
     412             :     {
     413             :         /***********************************
     414             :         * object was created on normal page
     415             :         ************************************/
     416           0 :         if ( bForceNoFillStyle )
     417             :         {
     418           0 :             String aName(SdResId(STR_POOLSHEET_OBJWITHOUTFILL));
     419           0 :             SfxStyleSheet* pSheet = (SfxStyleSheet*)pPage->GetModel()->
     420           0 :                                          GetStyleSheetPool()->
     421           0 :                                          Find(aName, SD_STYLE_FAMILY_GRAPHICS);
     422             :             DBG_ASSERT(pSheet, "Objektvorlage nicht gefunden");
     423           0 :             if (pSheet)
     424             :             {
     425           0 :                 pObj->SetStyleSheet(pSheet, sal_False);
     426           0 :                 SfxItemSet aAttr(*mpView->GetDefaultAttr().Clone());
     427           0 :                 aAttr.Put(pSheet->GetItemSet().Get(XATTR_FILLSTYLE));
     428           0 :                 pObj->SetMergedItemSet(aAttr);
     429             :             }
     430             :             else
     431             :             {
     432           0 :                 SfxItemSet aAttr(*mpView->GetDefaultAttr().Clone());
     433           0 :                 rAttr.Put(XFillStyleItem(XFILL_NONE));
     434           0 :                 pObj->SetMergedItemSet(aAttr);
     435           0 :             }
     436             :         }
     437             :     }
     438           0 : }
     439             : 
     440             : } // end of namespace sd
     441             : 
     442             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10