LCOV - code coverage report
Current view: top level - slideshow/source/inc - shape.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 8 0.0 %
Date: 2014-11-03 Functions: 0 5 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             : #ifndef INCLUDED_SLIDESHOW_SOURCE_INC_SHAPE_HXX
      21             : #define INCLUDED_SLIDESHOW_SOURCE_INC_SHAPE_HXX
      22             : 
      23             : #include <com/sun/star/uno/Reference.hxx>
      24             : #include <com/sun/star/drawing/XShape.hpp>
      25             : #include <com/sun/star/drawing/XDrawPage.hpp>
      26             : 
      27             : #include <basegfx/range/b2drectangle.hxx>
      28             : 
      29             : #include "viewlayer.hxx"
      30             : 
      31             : #include <boost/shared_ptr.hpp>
      32             : #include <boost/noncopyable.hpp>
      33             : #include <set>
      34             : #include <vector>
      35             : 
      36             : namespace basegfx {
      37             :     class B2DRange;
      38             : }
      39             : 
      40             : namespace slideshow
      41             : {
      42             :     namespace internal
      43             :     {
      44             :         // forward declaration necessary, because methods use ShapeSharedPtr
      45             :         class Shape;
      46             : 
      47             :         typedef ::boost::shared_ptr< Shape > ShapeSharedPtr;
      48             : 
      49             :         /** Represents a slide's shape object.
      50             : 
      51             :             This interface represents the view-independent aspects of a
      52             :             slide's shape, providing bound rect, underlying XShape and
      53             :             basic paint methods.
      54             :          */
      55           0 :         class Shape : private boost::noncopyable
      56             :         {
      57             :         public:
      58           0 :             virtual ~Shape() {}
      59             : 
      60             :             /** Get the associated XShape of this shape.
      61             : 
      62             :                 @return the associated XShape. If this method returns
      63             :                 an empty reference, this object might be one of the
      64             :                 special-purpose shapes of a slide, which have no
      65             :                 direct corresponding XShape (the background comes to
      66             :                 mind here).
      67             :              */
      68             :             virtual ::com::sun::star::uno::Reference<
      69             :                 ::com::sun::star::drawing::XShape > getXShape() const = 0;
      70             : 
      71             : 
      72             :             // View layer methods
      73             : 
      74             : 
      75             :             /** Add a new view layer.
      76             : 
      77             :                 This method adds a new view layer, this shape shall
      78             :                 show itself on.
      79             : 
      80             :                 @param rNewLayer
      81             :                 New layer to show on
      82             : 
      83             :                 @param bRedrawLayer
      84             :                 Redraw shape on given layer
      85             :              */
      86             :             virtual void addViewLayer( const ViewLayerSharedPtr&    rNewLayer,
      87             :                                        bool                         bRedrawLayer ) = 0;
      88             : 
      89             :             /** Withdraw the shape from a view layer
      90             : 
      91             :                 This method removes the shape from the given view
      92             :                 layer.
      93             : 
      94             :                 @return true, if the shape was successfully removed
      95             :              */
      96             :             virtual bool removeViewLayer( const ViewLayerSharedPtr& rNewLayer ) = 0;
      97             : 
      98             :             /** Withdraw all view layers at once
      99             : 
     100             :                 This method will be faster than repeated
     101             :                 removeViewLayer() calls.
     102             :              */
     103             :             virtual bool clearAllViewLayers() = 0;
     104             : 
     105             :             // render methods
     106             : 
     107             : 
     108             :             /** Update the shape
     109             : 
     110             :                 This method updates the Shape on all registered view
     111             :                 layers, but only if shape content has actually
     112             :                 changed.
     113             : 
     114             :                 @return whether the update finished successfully.
     115             :             */
     116             :             virtual bool update() const = 0;
     117             : 
     118             :             /** Render the shape.
     119             : 
     120             :                 This method renders the shape on all registered view
     121             :                 layers, regardless of whether shape content has
     122             :                 changed or not.
     123             : 
     124             :                 @return whether the rendering finished successfully.
     125             :             */
     126             :             virtual bool render() const = 0;
     127             : 
     128             :             /** Query whether shape content changed
     129             : 
     130             :                 This method returns true, if shape content changed
     131             :                 since the last rendering (i.e. the shape needs an
     132             :                 update to reflect that changed content on the views).
     133             :              */
     134             :             virtual bool isContentChanged() const = 0;
     135             : 
     136             : 
     137             :             // Shape attributes
     138             : 
     139             : 
     140             :             /** Get the current shape position and size.
     141             : 
     142             :                 This method yields the currently effective shape
     143             :                 bounds (which might change over time, for animated
     144             :                 shapes). Please note that possibly shape rotations
     145             :                 from its original document state must not be taken
     146             :                 into account here: if you need the screen bounding
     147             :                 box, use getUpdateArea() instead. Note further that
     148             :                 shape rotations, which are already contained in the
     149             :                 shape as displayed in the original document
     150             :                 <em>are</em> included herein (we currently take the
     151             :                 shape as-is from the document, assuming a rotation
     152             :                 angle of 0).
     153             :              */
     154             :             virtual ::basegfx::B2DRange getBounds() const = 0;
     155             : 
     156             :             /** Get the DOM position and size of the shape.
     157             : 
     158             :                 This method yields the underlying DOM shape bounds,
     159             :                 i.e. the original shape bounds from the document
     160             :                 model. This value is <em>always</em> unaffected by any
     161             :                 animation activity. Note that shape rotations, which
     162             :                 are already contained in the shape as displayed in the
     163             :                 original document are already included herein (we
     164             :                 currently take the shape as-is from the document,
     165             :                 assuming a rotation angle of 0).
     166             :              */
     167             :             virtual ::basegfx::B2DRange getDomBounds() const = 0;
     168             : 
     169             :             /** Get the current shape update area.
     170             : 
     171             :                 This method yields the currently effective update area
     172             :                 for the shape, i.e. the area that needs to be updated,
     173             :                 should the shape be painted. Normally, this will be
     174             :                 the (possibly rotated and sheared) area returned by
     175             :                 getBounds().
     176             :              */
     177             :             virtual ::basegfx::B2DRange getUpdateArea() const = 0;
     178             : 
     179             :             /** Query whether the shape is visible at all.
     180             : 
     181             :                 @return true, if this shape is visible, false
     182             :                 otherwise.
     183             :              */
     184             :             virtual bool isVisible() const = 0;
     185             : 
     186             :             /** Get the shape priority.
     187             : 
     188             :                 The shape priority defines the relative order of the
     189             :                 shapes on the slide.
     190             : 
     191             :                 @return the priority. Will be in the [0,+infty) range.
     192             :              */
     193             :             virtual double getPriority() const = 0;
     194             : 
     195             :             /** Query whether the Shape is currently detached from the
     196             :                 background.
     197             : 
     198             :                 This method checks whether the Shape is currently
     199             :                 detached from the slide background, i.e. whether shape
     200             :                 updates affect the underlying slide background or
     201             :                 not. A shape that returnes true here must not alter
     202             :                 slide content in any way when called render() or
     203             :                 update() (this is normally achieved by making this
     204             :                 shape a sprite).
     205             :              */
     206             :             virtual bool isBackgroundDetached() const = 0;
     207             : 
     208             :             // Misc
     209             : 
     210             : 
     211             :             /** Functor struct, for shape ordering
     212             : 
     213             :                 This defines a strict weak ordering of shapes, primary
     214             :                 sort key is the shape priority, and secondy sort key
     215             :                 the object ptr value. Most typical use is for
     216             :                 associative containers holding shapes (and which also
     217             :                 have to maintain something like a paint order).
     218             :              */
     219             :             struct lessThanShape
     220             :             {
     221             :                 // make functor adaptable (to boost::bind)
     222             :                 typedef bool result_type;
     223             : 
     224             :                 // since the ZOrder property on the XShape has somewhat
     225             :                 // peculiar attributes (it's basically the index of the shapes
     226             :                 // in the drawing layer's SdrObjList - which means, it starts
     227             :                 // from 0 for children of group objects), we cannot use it to determine
     228             :                 // drawing order. Thus, we rely on importer-provided order values here,
     229             :                 // which is basically a running counter during shape import (i.e. denotes
     230             :                 // the order of shape import). This is the correct order, at least for the
     231             :                 // current drawing core.
     232             : 
     233             :                 // If, someday, the above proposition is no longer true, one directly use
     234             :                 // the shape's ZOrder property
     235             : 
     236           0 :                 static bool compare(const Shape* pLHS, const Shape* pRHS)
     237             :                 {
     238           0 :                     const double nPrioL( pLHS->getPriority() );
     239           0 :                     const double nPrioR( pRHS->getPriority() );
     240             : 
     241             :                     // if prios are equal, tie-break on ptr value
     242           0 :                     return nPrioL == nPrioR ? pLHS < pRHS : nPrioL < nPrioR;
     243             :                 }
     244             : 
     245           0 :                 bool operator()(const ShapeSharedPtr& rLHS, const ShapeSharedPtr& rRHS) const
     246             :                 {
     247           0 :                     return compare(rLHS.get(),rRHS.get());
     248             :                 }
     249             : 
     250             :                 bool operator()(const Shape* pLHS, const Shape* pRHS) const
     251             :                 {
     252             :                     return compare(pLHS, pRHS);
     253             :                 }
     254             :             };
     255             :         };
     256             : 
     257             :         typedef ::boost::shared_ptr< Shape > ShapeSharedPtr;
     258             : 
     259             :         /** A set which contains all shapes in an ordered fashion.
     260             :          */
     261             :         typedef ::std::set< ShapeSharedPtr, Shape::lessThanShape >  ShapeSet;
     262             :     }
     263             : }
     264             : 
     265             : #endif // INCLUDED_SLIDESHOW_SOURCE_INC_SHAPE_HXX
     266             : 
     267             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10