LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive2d - baseprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 175 0.0 %
Date: 2014-04-14 Functions: 0 19 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             : #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
      21             : #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
      22             : #include <drawinglayer/geometry/viewinformation2d.hxx>
      23             : #include <basegfx/tools/canvastools.hxx>
      24             : 
      25             : 
      26             : 
      27             : using namespace com::sun::star;
      28             : 
      29             : 
      30             : 
      31             : namespace drawinglayer
      32             : {
      33             :     namespace primitive2d
      34             :     {
      35           0 :         BasePrimitive2D::BasePrimitive2D()
      36           0 :         :   BasePrimitive2DImplBase(m_aMutex)
      37             :         {
      38           0 :         }
      39             : 
      40           0 :         BasePrimitive2D::~BasePrimitive2D()
      41             :         {
      42           0 :         }
      43             : 
      44           0 :         bool BasePrimitive2D::operator==( const BasePrimitive2D& rPrimitive ) const
      45             :         {
      46           0 :             return (getPrimitive2DID() == rPrimitive.getPrimitive2DID());
      47             :         }
      48             : 
      49           0 :         basegfx::B2DRange BasePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
      50             :         {
      51           0 :             return getB2DRangeFromPrimitive2DSequence(get2DDecomposition(rViewInformation), rViewInformation);
      52             :         }
      53             : 
      54           0 :         Primitive2DSequence BasePrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
      55             :         {
      56           0 :             return Primitive2DSequence();
      57             :         }
      58             : 
      59           0 :         Primitive2DSequence SAL_CALL BasePrimitive2D::getDecomposition( const uno::Sequence< beans::PropertyValue >& rViewParameters ) throw ( uno::RuntimeException, std::exception )
      60             :         {
      61           0 :             const geometry::ViewInformation2D aViewInformation(rViewParameters);
      62           0 :             return get2DDecomposition(aViewInformation);
      63             :         }
      64             : 
      65           0 :         com::sun::star::geometry::RealRectangle2D SAL_CALL BasePrimitive2D::getRange( const uno::Sequence< beans::PropertyValue >& rViewParameters ) throw ( uno::RuntimeException, std::exception )
      66             :         {
      67           0 :             const geometry::ViewInformation2D aViewInformation(rViewParameters);
      68           0 :             return basegfx::unotools::rectangle2DFromB2DRectangle(getB2DRange(aViewInformation));
      69             :         }
      70             :     } // end of namespace primitive2d
      71             : } // end of namespace drawinglayer
      72             : 
      73             : 
      74             : 
      75             : namespace drawinglayer
      76             : {
      77             :     namespace primitive2d
      78             :     {
      79           0 :         Primitive2DSequence BufferedDecompositionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
      80             :         {
      81           0 :             return Primitive2DSequence();
      82             :         }
      83             : 
      84           0 :         BufferedDecompositionPrimitive2D::BufferedDecompositionPrimitive2D()
      85             :         :   BasePrimitive2D(),
      86           0 :             maBuffered2DDecomposition()
      87             :         {
      88           0 :         }
      89             : 
      90           0 :         Primitive2DSequence BufferedDecompositionPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      91             :         {
      92           0 :             ::osl::MutexGuard aGuard( m_aMutex );
      93             : 
      94           0 :             if(!getBuffered2DDecomposition().hasElements())
      95             :             {
      96           0 :                 const Primitive2DSequence aNewSequence(create2DDecomposition(rViewInformation));
      97           0 :                 const_cast< BufferedDecompositionPrimitive2D* >(this)->setBuffered2DDecomposition(aNewSequence);
      98             :             }
      99             : 
     100           0 :             return getBuffered2DDecomposition();
     101             :         }
     102             :     } // end of namespace primitive2d
     103             : } // end of namespace drawinglayer
     104             : 
     105             : 
     106             : // tooling
     107             : 
     108             : namespace drawinglayer
     109             : {
     110             :     namespace primitive2d
     111             :     {
     112             :         // convert helper stl vector of primitives to Primitive2DSequence
     113           0 :         Primitive2DSequence Primitive2DVectorToPrimitive2DSequence(const Primitive2DVector& rSource, bool bInvert)
     114             :         {
     115           0 :             const sal_uInt32 nSize(rSource.size());
     116           0 :             Primitive2DSequence aRetval;
     117             : 
     118           0 :             aRetval.realloc(nSize);
     119             : 
     120           0 :             for(sal_uInt32 a(0); a < nSize; a++)
     121             :             {
     122           0 :                 aRetval[bInvert ? nSize - 1 - a : a] = rSource[a];
     123             :             }
     124             : 
     125             :             // all entries taken over to Uno References as owners. To avoid
     126             :             // errors with users of this mechanism to delete pointers to BasePrimitive2D
     127             :             // itself, clear given vector
     128           0 :             const_cast< Primitive2DVector& >(rSource).clear();
     129             : 
     130           0 :             return aRetval;
     131             :         }
     132             : 
     133             :         // get B2DRange from a given Primitive2DReference
     134           0 :         basegfx::B2DRange getB2DRangeFromPrimitive2DReference(const Primitive2DReference& rCandidate, const geometry::ViewInformation2D& aViewInformation)
     135             :         {
     136           0 :             basegfx::B2DRange aRetval;
     137             : 
     138           0 :             if(rCandidate.is())
     139             :             {
     140             :                 // try to get C++ implementation base
     141           0 :                 const BasePrimitive2D* pCandidate(dynamic_cast< BasePrimitive2D* >(rCandidate.get()));
     142             : 
     143           0 :                 if(pCandidate)
     144             :                 {
     145             :                     // use it if possible
     146           0 :                     aRetval.expand(pCandidate->getB2DRange(aViewInformation));
     147             :                 }
     148             :                 else
     149             :                 {
     150             :                     // use UNO API call instead
     151           0 :                     const uno::Sequence< beans::PropertyValue >& rViewParameters(aViewInformation.getViewInformationSequence());
     152           0 :                     aRetval.expand(basegfx::unotools::b2DRectangleFromRealRectangle2D(rCandidate->getRange(rViewParameters)));
     153             :                 }
     154             :             }
     155             : 
     156           0 :             return aRetval;
     157             :         }
     158             : 
     159             :         // get B2DRange from a given Primitive2DSequence
     160           0 :         basegfx::B2DRange getB2DRangeFromPrimitive2DSequence(const Primitive2DSequence& rCandidate, const geometry::ViewInformation2D& aViewInformation)
     161             :         {
     162           0 :             basegfx::B2DRange aRetval;
     163             : 
     164           0 :             if(rCandidate.hasElements())
     165             :             {
     166           0 :                 const sal_Int32 nCount(rCandidate.getLength());
     167             : 
     168           0 :                 for(sal_Int32 a(0L); a < nCount; a++)
     169             :                 {
     170           0 :                     aRetval.expand(getB2DRangeFromPrimitive2DReference(rCandidate[a], aViewInformation));
     171             :                 }
     172             :             }
     173             : 
     174           0 :             return aRetval;
     175             :         }
     176             : 
     177           0 :         bool arePrimitive2DReferencesEqual(const Primitive2DReference& rxA, const Primitive2DReference& rxB)
     178             :         {
     179           0 :             const bool bAIs(rxA.is());
     180             : 
     181           0 :             if(bAIs != rxB.is())
     182             :             {
     183           0 :                 return false;
     184             :             }
     185             : 
     186           0 :             if(!bAIs)
     187             :             {
     188           0 :                 return true;
     189             :             }
     190             : 
     191           0 :             const BasePrimitive2D* pA(dynamic_cast< const BasePrimitive2D* >(rxA.get()));
     192           0 :             const BasePrimitive2D* pB(dynamic_cast< const BasePrimitive2D* >(rxB.get()));
     193           0 :             const bool bAEqualZero(pA == 0L);
     194             : 
     195           0 :             if(bAEqualZero != (pB == 0L))
     196             :             {
     197           0 :                 return false;
     198             :             }
     199             : 
     200           0 :             if(bAEqualZero)
     201             :             {
     202           0 :                 return false;
     203             :             }
     204             : 
     205           0 :             return (pA->operator==(*pB));
     206             :         }
     207             : 
     208           0 :         bool arePrimitive2DSequencesEqual(const Primitive2DSequence& rA, const Primitive2DSequence& rB)
     209             :         {
     210           0 :             const bool bAHasElements(rA.hasElements());
     211             : 
     212           0 :             if(bAHasElements != rB.hasElements())
     213             :             {
     214           0 :                 return false;
     215             :             }
     216             : 
     217           0 :             if(!bAHasElements)
     218             :             {
     219           0 :                 return true;
     220             :             }
     221             : 
     222           0 :             const sal_Int32 nCount(rA.getLength());
     223             : 
     224           0 :             if(nCount != rB.getLength())
     225             :             {
     226           0 :                 return false;
     227             :             }
     228             : 
     229           0 :             for(sal_Int32 a(0L); a < nCount; a++)
     230             :             {
     231           0 :                 if(!arePrimitive2DReferencesEqual(rA[a], rB[a]))
     232             :                 {
     233           0 :                     return false;
     234             :                 }
     235             :             }
     236             : 
     237           0 :             return true;
     238             :         }
     239             : 
     240             :         // concatenate sequence
     241           0 :         void appendPrimitive2DSequenceToPrimitive2DSequence(Primitive2DSequence& rDest, const Primitive2DSequence& rSource)
     242             :         {
     243           0 :             if(rSource.hasElements())
     244             :             {
     245           0 :                 if(rDest.hasElements())
     246             :                 {
     247           0 :                     const sal_Int32 nSourceCount(rSource.getLength());
     248           0 :                     const sal_Int32 nDestCount(rDest.getLength());
     249           0 :                     const sal_Int32 nTargetCount(nSourceCount + nDestCount);
     250           0 :                     sal_Int32 nInsertPos(nDestCount);
     251             : 
     252           0 :                     rDest.realloc(nTargetCount);
     253             : 
     254           0 :                     for(sal_Int32 a(0L); a < nSourceCount; a++)
     255             :                     {
     256           0 :                         if(rSource[a].is())
     257             :                         {
     258           0 :                             rDest[nInsertPos++] = rSource[a];
     259             :                         }
     260             :                     }
     261             : 
     262           0 :                     if(nInsertPos != nTargetCount)
     263             :                     {
     264           0 :                         rDest.realloc(nInsertPos);
     265             :                     }
     266             :                 }
     267             :                 else
     268             :                 {
     269           0 :                     rDest = rSource;
     270             :                 }
     271             :             }
     272           0 :         }
     273             : 
     274             :         // concatenate single Primitive2D
     275           0 :         void appendPrimitive2DReferenceToPrimitive2DSequence(Primitive2DSequence& rDest, const Primitive2DReference& rSource)
     276             :         {
     277           0 :             if(rSource.is())
     278             :             {
     279           0 :                 const sal_Int32 nDestCount(rDest.getLength());
     280           0 :                 rDest.realloc(nDestCount + 1L);
     281           0 :                 rDest[nDestCount] = rSource;
     282             :             }
     283           0 :         }
     284             : 
     285           0 :         OUString idToString(sal_uInt32 nId)
     286             :         {
     287           0 :             switch( nId )
     288             :             {
     289           0 :             case PRIMITIVE2D_ID_TRANSPARENCEPRIMITIVE2D: return OUString("TRANSPARENCE");
     290           0 :             case PRIMITIVE2D_ID_ANIMATEDSWITCHPRIMITIVE2D: return OUString("ANIMATEDSWITCH");
     291           0 :             case PRIMITIVE2D_ID_ANIMATEDBLINKPRIMITIVE2D: return OUString("ANIMATEDBLINK");
     292           0 :             case PRIMITIVE2D_ID_ANIMATEDINTERPOLATEPRIMITIVE2D: return OUString("ANIMATEDINTERPOLATE");
     293           0 :             case PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D: return OUString("BACKGROUNDCOLOR");
     294           0 :             case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D: return OUString("BITMAP");
     295           0 :             case PRIMITIVE2D_ID_CONTROLPRIMITIVE2D: return OUString("CONTROL");
     296           0 :             case PRIMITIVE2D_ID_EMBEDDED3DPRIMITIVE2D: return OUString("EMBEDDED3D");
     297           0 :             case PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D: return OUString("FILLGRAPHIC");
     298           0 :             case PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D: return OUString("FILLGRADIENT");
     299           0 :             case PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D: return OUString("FILLHATCH");
     300           0 :             case PRIMITIVE2D_ID_GRAPHICPRIMITIVE2D: return OUString("GRAPHIC");
     301           0 :             case PRIMITIVE2D_ID_GRIDPRIMITIVE2D: return OUString("GRID");
     302           0 :             case PRIMITIVE2D_ID_GROUPPRIMITIVE2D: return OUString("GROUP");
     303           0 :             case PRIMITIVE2D_ID_HELPLINEPRIMITIVE2D: return OUString("HELPLINE");
     304           0 :             case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D: return OUString("MARKERARRAY");
     305           0 :             case PRIMITIVE2D_ID_MASKPRIMITIVE2D: return OUString("MASK");
     306           0 :             case PRIMITIVE2D_ID_MEDIAPRIMITIVE2D: return OUString("MEDIA");
     307           0 :             case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D: return OUString("METAFILE");
     308           0 :             case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D: return OUString("MODIFIEDCOLOR");
     309           0 :             case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D: return OUString("POLYGONHAIRLINE");
     310           0 :             case PRIMITIVE2D_ID_POLYGONMARKERPRIMITIVE2D: return OUString("POLYGONMARKER");
     311           0 :             case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D: return OUString("POLYGONSTROKE");
     312           0 :             case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D: return OUString("POLYGONSTROKEARROW");
     313           0 :             case PRIMITIVE2D_ID_POLYPOLYGONSTROKEPRIMITIVE2D: return OUString("POLYPOLYGONSTROKE");
     314           0 :             case PRIMITIVE2D_ID_POLYPOLYGONSTROKEARROWPRIMITIVE2D: return OUString("POLYPOLYGONSTROKEARROW");
     315           0 :             case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D: return OUString("POLYPOLYGONCOLOR");
     316           0 :             case PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D: return OUString("POLYPOLYGONGRADIENT");
     317           0 :             case PRIMITIVE2D_ID_POLYPOLYGONHATCHPRIMITIVE2D: return OUString("POLYPOLYGONHATCH");
     318           0 :             case PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D: return OUString("POLYPOLYGONGRAPHIC");
     319           0 :             case PRIMITIVE2D_ID_SCENEPRIMITIVE2D: return OUString("SCENE");
     320           0 :             case PRIMITIVE2D_ID_SHADOWPRIMITIVE2D: return OUString("SHADOW");
     321           0 :             case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D: return OUString("TEXTSIMPLEPORTION");
     322           0 :             case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D: return OUString("TEXTDECORATEDPORTION");
     323           0 :             case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D: return OUString("TRANSFORM");
     324           0 :             case PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D: return OUString("UNIFIEDTRANSPARENCE");
     325           0 :             case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D: return OUString("POINTARRAY");
     326           0 :             case PRIMITIVE2D_ID_TEXTHIERARCHYFIELDPRIMITIVE2D: return OUString("TEXTHIERARCHYFIELD");
     327           0 :             case PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D: return OUString("TEXTHIERARCHYLINE");
     328           0 :             case PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D: return OUString("TEXTHIERARCHYPARAGRAPH");
     329           0 :             case PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D: return OUString("TEXTHIERARCHYBLOCK");
     330           0 :             case PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D: return OUString("TEXTHIERARCHYEDIT");
     331           0 :             case PRIMITIVE2D_ID_POLYGONWAVEPRIMITIVE2D: return OUString("POLYGONWAVE");
     332           0 :             case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D: return OUString("WRONGSPELL");
     333           0 :             case PRIMITIVE2D_ID_TEXTEFFECTPRIMITIVE2D: return OUString("TEXTEFFECT");
     334           0 :             case PRIMITIVE2D_ID_TEXTHIERARCHYBULLETPRIMITIVE2D: return OUString("TEXTHIERARCHYBULLET");
     335           0 :             case PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D: return OUString("POLYPOLYGONHAIRLINE");
     336           0 :             case PRIMITIVE2D_ID_EXECUTEPRIMITIVE2D: return OUString("EXECUTE");
     337           0 :             case PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D: return OUString("PAGEPREVIEW");
     338           0 :             case PRIMITIVE2D_ID_STRUCTURETAGPRIMITIVE2D: return OUString("STRUCTURETAG");
     339           0 :             case PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D: return OUString("BORDERLINE");
     340           0 :             case PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D: return OUString("POLYPOLYGONMARKER");
     341           0 :             case PRIMITIVE2D_ID_HITTESTPRIMITIVE2D: return OUString("HITTEST");
     342           0 :             case PRIMITIVE2D_ID_INVERTPRIMITIVE2D: return OUString("INVERT");
     343           0 :             case PRIMITIVE2D_ID_DISCRETEBITMAPPRIMITIVE2D: return OUString("DISCRETEBITMAP");
     344           0 :             case PRIMITIVE2D_ID_WALLPAPERBITMAPPRIMITIVE2D: return OUString("WALLPAPERBITMAP");
     345           0 :             case PRIMITIVE2D_ID_TEXTLINEPRIMITIVE2D: return OUString("TEXTLINE");
     346           0 :             case PRIMITIVE2D_ID_TEXTCHARACTERSTRIKEOUTPRIMITIVE2D: return OUString("TEXTCHARACTERSTRIKEOUT");
     347           0 :             case PRIMITIVE2D_ID_TEXTGEOMETRYSTRIKEOUTPRIMITIVE2D: return OUString("TEXTGEOMETRYSTRIKEOUT");
     348           0 :             case PRIMITIVE2D_ID_EPSPRIMITIVE2D: return OUString("EPS");
     349           0 :             case PRIMITIVE2D_ID_DISCRETESHADOWPRIMITIVE2D: return OUString("DISCRETESHADOW");
     350           0 :             case PRIMITIVE2D_ID_HIDDENGEOMETRYPRIMITIVE2D: return OUString("HIDDENGEOMETRY");
     351           0 :             case PRIMITIVE2D_ID_SVGLINEARGRADIENTPRIMITIVE2D: return OUString("SVGLINEARGRADIENT");
     352           0 :             case PRIMITIVE2D_ID_SVGRADIALGRADIENTPRIMITIVE2D: return OUString("SVGRADIALGRADIENT");
     353           0 :             case PRIMITIVE2D_ID_SVGLINEARATOMPRIMITIVE2D: return OUString("SVGLINEARATOM");
     354           0 :             case PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D: return OUString("SVGRADIALATOM");
     355           0 :             case PRIMITIVE2D_ID_CROPPRIMITIVE2D: return OUString("CROP");
     356           0 :             case PRIMITIVE2D_ID_PATTERNFILLPRIMITIVE2D: return OUString("PATTERNFILL");
     357           0 :             case PRIMITIVE2D_ID_OBJECTINFOPRIMITIVE2D: return OUString("OBJECTINFO");
     358           0 :             case PRIMITIVE2D_ID_POLYPOLYGONSELECTIONPRIMITIVE2D: return OUString("POLYPOLYGONSELECTION");
     359           0 :             case PRIMITIVE2D_ID_CLIPPEDBORDERLINEPRIMITIVE2D: return OUString("CLIPPEDBORDERLINE");
     360           0 :             case PRIMITIVE2D_ID_OPENGLPRIMITIVE2D: return OUString("OPENGL");
     361           0 :             default: return OUString::number((nId >> 16) & 0xFF) + "|" + OUString::number(nId & 0xFF);
     362             :             }
     363             :         }
     364             :     } // end of namespace primitive2d
     365             : } // end of namespace drawinglayer
     366             : 
     367             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10