LCOV - code coverage report
Current view: top level - libreoffice/drawinglayer/source/primitive3d - baseprimitive3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 92 0.0 %
Date: 2012-12-27 Functions: 0 17 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/primitive3d/baseprimitive3d.hxx>
      21             : #include <drawinglayer/geometry/viewinformation3d.hxx>
      22             : #include <basegfx/tools/canvastools.hxx>
      23             : 
      24             : //////////////////////////////////////////////////////////////////////////////
      25             : 
      26             : using namespace com::sun::star;
      27             : 
      28             : //////////////////////////////////////////////////////////////////////////////
      29             : 
      30             : namespace drawinglayer
      31             : {
      32             :     namespace primitive3d
      33             :     {
      34           0 :         BasePrimitive3D::BasePrimitive3D()
      35           0 :         :   BasePrimitive3DImplBase(m_aMutex)
      36             :         {
      37           0 :         }
      38             : 
      39           0 :         BasePrimitive3D::~BasePrimitive3D()
      40             :         {
      41           0 :         }
      42             : 
      43           0 :         bool BasePrimitive3D::operator==( const BasePrimitive3D& rPrimitive ) const
      44             :         {
      45           0 :             return (getPrimitive3DID() == rPrimitive.getPrimitive3DID());
      46             :         }
      47             : 
      48           0 :         basegfx::B3DRange BasePrimitive3D::getB3DRange(const geometry::ViewInformation3D& rViewInformation) const
      49             :         {
      50           0 :             return getB3DRangeFromPrimitive3DSequence(get3DDecomposition(rViewInformation), rViewInformation);
      51             :         }
      52             : 
      53           0 :         Primitive3DSequence BasePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
      54             :         {
      55           0 :             return Primitive3DSequence();
      56             :         }
      57             : 
      58           0 :         Primitive3DSequence SAL_CALL BasePrimitive3D::getDecomposition( const uno::Sequence< beans::PropertyValue >& rViewParameters ) throw ( uno::RuntimeException )
      59             :         {
      60           0 :             const geometry::ViewInformation3D aViewInformation(rViewParameters);
      61           0 :             return get3DDecomposition(aViewInformation);
      62             :         }
      63             : 
      64           0 :         com::sun::star::geometry::RealRectangle3D SAL_CALL BasePrimitive3D::getRange( const uno::Sequence< beans::PropertyValue >& rViewParameters ) throw ( uno::RuntimeException )
      65             :         {
      66           0 :             const geometry::ViewInformation3D aViewInformation(rViewParameters);
      67           0 :             return basegfx::unotools::rectangle3DFromB3DRectangle(getB3DRange(aViewInformation));
      68             :         }
      69             :     } // end of namespace primitive3d
      70             : } // end of namespace drawinglayer
      71             : 
      72             : //////////////////////////////////////////////////////////////////////////////
      73             : 
      74             : namespace drawinglayer
      75             : {
      76             :     namespace primitive3d
      77             :     {
      78           0 :         Primitive3DSequence BufferedDecompositionPrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const
      79             :         {
      80           0 :             return Primitive3DSequence();
      81             :         }
      82             : 
      83           0 :         BufferedDecompositionPrimitive3D::BufferedDecompositionPrimitive3D()
      84             :         :   BasePrimitive3D(),
      85           0 :             maBuffered3DDecomposition()
      86             :         {
      87           0 :         }
      88             : 
      89           0 :         Primitive3DSequence BufferedDecompositionPrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const
      90             :         {
      91           0 :             ::osl::MutexGuard aGuard( m_aMutex );
      92             : 
      93           0 :             if(!getBuffered3DDecomposition().hasElements())
      94             :             {
      95           0 :                 const Primitive3DSequence aNewSequence(create3DDecomposition(rViewInformation));
      96           0 :                 const_cast< BufferedDecompositionPrimitive3D* >(this)->setBuffered3DDecomposition(aNewSequence);
      97             :             }
      98             : 
      99           0 :             return getBuffered3DDecomposition();
     100             :         }
     101             :     } // end of namespace primitive3d
     102             : } // end of namespace drawinglayer
     103             : 
     104             : //////////////////////////////////////////////////////////////////////////////
     105             : // tooling
     106             : 
     107             : namespace drawinglayer
     108             : {
     109             :     namespace primitive3d
     110             :     {
     111             :         // get range3D from a given Primitive3DReference
     112           0 :         basegfx::B3DRange getB3DRangeFromPrimitive3DReference(const Primitive3DReference& rCandidate, const geometry::ViewInformation3D& aViewInformation)
     113             :         {
     114           0 :             basegfx::B3DRange aRetval;
     115             : 
     116           0 :             if(rCandidate.is())
     117             :             {
     118             :                 // try to get C++ implementation base
     119           0 :                 const BasePrimitive3D* pCandidate(dynamic_cast< BasePrimitive3D* >(rCandidate.get()));
     120             : 
     121           0 :                 if(pCandidate)
     122             :                 {
     123             :                     // use it if possible
     124           0 :                     aRetval.expand(pCandidate->getB3DRange(aViewInformation));
     125             :                 }
     126             :                 else
     127             :                 {
     128             :                     // use UNO API call instead
     129           0 :                     const uno::Sequence< beans::PropertyValue >& rViewParameters(aViewInformation.getViewInformationSequence());
     130           0 :                     aRetval.expand(basegfx::unotools::b3DRectangleFromRealRectangle3D(rCandidate->getRange(rViewParameters)));
     131             :                 }
     132             :             }
     133             : 
     134           0 :             return aRetval;
     135             :         }
     136             : 
     137             :         // get range3D from a given Primitive3DSequence
     138           0 :         basegfx::B3DRange getB3DRangeFromPrimitive3DSequence(const Primitive3DSequence& rCandidate, const geometry::ViewInformation3D& aViewInformation)
     139             :         {
     140           0 :             basegfx::B3DRange aRetval;
     141             : 
     142           0 :             if(rCandidate.hasElements())
     143             :             {
     144           0 :                 const sal_Int32 nCount(rCandidate.getLength());
     145             : 
     146           0 :                 for(sal_Int32 a(0L); a < nCount; a++)
     147             :                 {
     148           0 :                     aRetval.expand(getB3DRangeFromPrimitive3DReference(rCandidate[a], aViewInformation));
     149             :                 }
     150             :             }
     151             : 
     152           0 :             return aRetval;
     153             :         }
     154             : 
     155           0 :         bool arePrimitive3DReferencesEqual(const Primitive3DReference& rxA, const Primitive3DReference& rxB)
     156             :         {
     157           0 :             const sal_Bool bAIs(rxA.is());
     158             : 
     159           0 :             if(bAIs != rxB.is())
     160             :             {
     161           0 :                 return false;
     162             :             }
     163             : 
     164           0 :             if(!bAIs)
     165             :             {
     166           0 :                 return true;
     167             :             }
     168             : 
     169           0 :             const BasePrimitive3D* pA(dynamic_cast< const BasePrimitive3D* >(rxA.get()));
     170           0 :             const BasePrimitive3D* pB(dynamic_cast< const BasePrimitive3D* >(rxB.get()));
     171           0 :             const bool bAEqualZero(pA == 0L);
     172             : 
     173           0 :             if(bAEqualZero != (pB == 0L))
     174             :             {
     175           0 :                 return false;
     176             :             }
     177             : 
     178           0 :             if(bAEqualZero)
     179             :             {
     180           0 :                 return false;
     181             :             }
     182             : 
     183           0 :             return (pA->operator==(*pB));
     184             :         }
     185             : 
     186           0 :         bool arePrimitive3DSequencesEqual(const Primitive3DSequence& rA, const Primitive3DSequence& rB)
     187             :         {
     188           0 :             const sal_Bool bAHasElements(rA.hasElements());
     189             : 
     190           0 :             if(bAHasElements != rB.hasElements())
     191             :             {
     192           0 :                 return false;
     193             :             }
     194             : 
     195           0 :             if(!bAHasElements)
     196             :             {
     197           0 :                 return true;
     198             :             }
     199             : 
     200           0 :             const sal_Int32 nCount(rA.getLength());
     201             : 
     202           0 :             if(nCount != rB.getLength())
     203             :             {
     204           0 :                 return false;
     205             :             }
     206             : 
     207           0 :             for(sal_Int32 a(0L); a < nCount; a++)
     208             :             {
     209           0 :                 if(!arePrimitive3DReferencesEqual(rA[a], rB[a]))
     210             :                 {
     211           0 :                     return false;
     212             :                 }
     213             :             }
     214             : 
     215           0 :             return true;
     216             :         }
     217             : 
     218             :         // concatenate sequence
     219           0 :         void appendPrimitive3DSequenceToPrimitive3DSequence(Primitive3DSequence& rDest, const Primitive3DSequence& rSource)
     220             :         {
     221           0 :             if(rSource.hasElements())
     222             :             {
     223           0 :                 if(rDest.hasElements())
     224             :                 {
     225           0 :                     const sal_Int32 nSourceCount(rSource.getLength());
     226           0 :                     const sal_Int32 nDestCount(rDest.getLength());
     227           0 :                     const sal_Int32 nTargetCount(nSourceCount + nDestCount);
     228           0 :                     sal_Int32 nInsertPos(nDestCount);
     229             : 
     230           0 :                     rDest.realloc(nTargetCount);
     231             : 
     232           0 :                     for(sal_Int32 a(0L); a < nSourceCount; a++)
     233             :                     {
     234           0 :                         if(rSource[a].is())
     235             :                         {
     236           0 :                             rDest[nInsertPos++] = rSource[a];
     237             :                         }
     238             :                     }
     239             : 
     240           0 :                     if(nInsertPos != nTargetCount)
     241             :                     {
     242           0 :                         rDest.realloc(nInsertPos);
     243             :                     }
     244             :                 }
     245             :                 else
     246             :                 {
     247           0 :                     rDest = rSource;
     248             :                 }
     249             :             }
     250           0 :         }
     251             : 
     252             :         // concatenate single Primitive3D
     253           0 :         void appendPrimitive3DReferenceToPrimitive3DSequence(Primitive3DSequence& rDest, const Primitive3DReference& rSource)
     254             :         {
     255           0 :             if(rSource.is())
     256             :             {
     257           0 :                 const sal_Int32 nDestCount(rDest.getLength());
     258           0 :                 rDest.realloc(nDestCount + 1L);
     259           0 :                 rDest[nDestCount] = rSource;
     260             :             }
     261           0 :         }
     262             : 
     263             :     } // end of namespace primitive3d
     264             : } // end of namespace drawinglayer
     265             : 
     266             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10