1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_SLIDESHOW_SHAPESUBSET_HXX 29 #define INCLUDED_SLIDESHOW_SHAPESUBSET_HXX 30 31 #include "attributableshape.hxx" 32 #include "subsettableshapemanager.hxx" 33 #include "doctreenode.hxx" 34 35 #include <boost/shared_ptr.hpp> 36 37 namespace slideshow 38 { 39 namespace internal 40 { 41 class ShapeSubset; 42 typedef ::boost::shared_ptr< ShapeSubset > ShapeSubsetSharedPtr; 43 44 /* Definition of ShapeSubset class */ 45 46 /** Subset RAII wrapper for shapes. 47 48 This class wraps the plain Shape with a wrapper for subset 49 functionality. Subsetting can be turned on and off. Note 50 that the reason to have shape subsetting RAII implemented 51 separately (i.e. not within the DrawShape) was that 52 subsetting (and de-subsetting) needs the 53 SubsettableShapeManager. And holding that at the DrawShape 54 creates one heck of a circular reference. 55 */ 56 class ShapeSubset 57 { 58 public: 59 /** Create a subset directly from a Shape. 60 61 @param rOriginalShape 62 Original shape to subset 63 64 @param rTreeNode 65 Subset this object should represent 66 67 @param rShapeManager 68 Manager object, where subsets are 69 registered/unregistered 70 */ 71 ShapeSubset( const AttributableShapeSharedPtr& rOriginalShape, 72 const DocTreeNode& rTreeNode, 73 const SubsettableShapeManagerSharedPtr& rSubsetManager ); 74 75 /** Create a subset from another subset. 76 77 Note: if you want this subset to subtract from the 78 passed subset reference (and not from the original, 79 unsubsetted shape), the passed subset must be enabled 80 (enableSubsetShape() must have been called) 81 82 @param rOriginalSubset 83 Original subset, which to subset again. 84 85 @param rTreeNode 86 Subset of the original subset 87 */ 88 ShapeSubset( const ShapeSubsetSharedPtr& rOriginalSubset, 89 const DocTreeNode& rTreeNode ); 90 91 /** Create full set for the given shape. 92 93 @param rOriginalShape 94 Original shape, which will be represented as a whole 95 by this object 96 */ 97 ShapeSubset( const AttributableShapeSharedPtr& rOriginalShape, 98 const SubsettableShapeManagerSharedPtr& rShapeManager ); 99 100 ~ShapeSubset(); 101 102 /** Get the actual subset shape. 103 104 If the subset is currently revoked, this method 105 returns the original shape. 106 */ 107 AttributableShapeSharedPtr getSubsetShape() const; 108 109 /** Enable the subset shape. 110 111 This method enables the subset. That means, on 112 successful completion of this method, the original 113 shape will cease to show the subset range, and 114 getSubsetShape() will return a valid shape. 115 116 @return true, if subsetting was successfully enabled. 117 */ 118 bool enableSubsetShape(); 119 120 /** Disable the subset shape. 121 122 This method revokes the subset from the original 123 shape. That means, the original shape will again show 124 the hidden range. 125 */ 126 void disableSubsetShape(); 127 128 /** Query whether this subset actually is none, but 129 contains the whole original shape's content 130 */ 131 bool isFullSet() const; 132 133 /** Query subset this object represents 134 */ 135 DocTreeNode getSubset() const; 136 137 private: 138 // default copy/assignment are okay 139 //ShapeSubset(const ShapeSubset&); 140 //ShapeSubset& operator=( const ShapeSubset& ); 141 142 AttributableShapeSharedPtr mpOriginalShape; 143 AttributableShapeSharedPtr mpSubsetShape; 144 DocTreeNode maTreeNode; 145 SubsettableShapeManagerSharedPtr mpShapeManager; 146 }; 147 } 148 } 149 150 #endif /* INCLUDED_SLIDESHOW_SHAPESUBSET_HXX */ 151