LCOV - code coverage report
Current view: top level - libreoffice/svx/source/sdr/contact - viewcontactofsdrcircobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 28 17.9 %
Date: 2012-12-27 Functions: 3 4 75.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 <svx/sdr/contact/viewcontactofsdrcircobj.hxx>
      22             : #include <svx/svdocirc.hxx>
      23             : #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
      24             : #include <svx/sdr/primitive2d/sdrellipseprimitive2d.hxx>
      25             : #include <svl/itemset.hxx>
      26             : #include <svx/sxciaitm.hxx>
      27             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      28             : 
      29             : //////////////////////////////////////////////////////////////////////////////
      30             : 
      31             : namespace sdr
      32             : {
      33             :     namespace contact
      34             :     {
      35           4 :         ViewContactOfSdrCircObj::ViewContactOfSdrCircObj(SdrCircObj& rCircObj)
      36           4 :         :   ViewContactOfSdrRectObj(rCircObj)
      37             :         {
      38           4 :         }
      39             : 
      40           6 :         ViewContactOfSdrCircObj::~ViewContactOfSdrCircObj()
      41             :         {
      42           6 :         }
      43             : 
      44           0 :         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrCircObj::createViewIndependentPrimitive2DSequence() const
      45             :         {
      46           0 :             const SfxItemSet& rItemSet = GetCircObj().GetMergedItemSet();
      47             :             const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
      48             :                 drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
      49             :                     rItemSet,
      50           0 :                     GetCircObj().getText(0)));
      51             : 
      52             :             // take unrotated snap rect (direct model data) for position and size
      53           0 :             Rectangle aRectangle = GetCircObj().GetGeoRect();
      54             :             // Hack for calc, transform position of object according
      55             :             // to current zoom so as objects relative position to grid
      56             :             // appears stable
      57           0 :             aRectangle += GetRectObj().GetGridOffset();
      58             :             const basegfx::B2DRange aObjectRange(
      59           0 :                 aRectangle.Left(), aRectangle.Top(),
      60           0 :                 aRectangle.Right(), aRectangle.Bottom() );
      61           0 :             const GeoStat& rGeoStat(GetCircObj().GetGeoStat());
      62             : 
      63             :             // fill object matrix
      64             :             const basegfx::B2DHomMatrix aObjectMatrix(
      65             :                 basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
      66             :                     aObjectRange.getWidth(), aObjectRange.getHeight(),
      67           0 :                     rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0,
      68             :                     rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0,
      69           0 :                     aObjectRange.getMinX(), aObjectRange.getMinY()));
      70             : 
      71             :             // create primitive data
      72           0 :             const sal_uInt16 nIdentifier(GetCircObj().GetObjIdentifier());
      73             : 
      74             :             // always create primitives to allow the decomposition of SdrEllipsePrimitive2D
      75             :             // or SdrEllipseSegmentPrimitive2D to create needed invisible elements for HitTest
      76             :             // and/or BoundRect
      77           0 :             if(OBJ_CIRC == nIdentifier)
      78             :             {
      79             :                 const drawinglayer::primitive2d::Primitive2DReference xReference(
      80             :                     new drawinglayer::primitive2d::SdrEllipsePrimitive2D(
      81             :                         aObjectMatrix,
      82           0 :                         aAttribute));
      83             : 
      84           0 :                 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
      85             :             }
      86             :             else
      87             :             {
      88           0 :                 const sal_Int32 nNewStart(((SdrCircStartAngleItem&)rItemSet.Get(SDRATTR_CIRCSTARTANGLE)).GetValue());
      89           0 :                 const sal_Int32 nNewEnd(((SdrCircEndAngleItem&)rItemSet.Get(SDRATTR_CIRCENDANGLE)).GetValue());
      90           0 :                 const double fStart(((36000 - nNewEnd) % 36000) * F_PI18000);
      91           0 :                 const double fEnd(((36000 - nNewStart) % 36000) * F_PI18000);
      92           0 :                 const bool bCloseSegment(OBJ_CARC != nIdentifier);
      93           0 :                 const bool bCloseUsingCenter(OBJ_SECT == nIdentifier);
      94             : 
      95             :                 const drawinglayer::primitive2d::Primitive2DReference xReference(
      96             :                     new drawinglayer::primitive2d::SdrEllipseSegmentPrimitive2D(
      97             :                         aObjectMatrix,
      98             :                         aAttribute,
      99             :                         fStart,
     100             :                         fEnd,
     101             :                         bCloseSegment,
     102           0 :                         bCloseUsingCenter));
     103             : 
     104           0 :                 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
     105           0 :             }
     106             :         }
     107             :     } // end of namespace contact
     108             : } // end of namespace sdr
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10