xref: /AOO41X/main/slideshow/source/inc/shapesubset.hxx (revision aaef562f9b4401da6d8a910634bb68eaaacb4ebd)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_SLIDESHOW_SHAPESUBSET_HXX
25 #define INCLUDED_SLIDESHOW_SHAPESUBSET_HXX
26 
27 #include "attributableshape.hxx"
28 #include "subsettableshapemanager.hxx"
29 #include "doctreenode.hxx"
30 
31 #include <boost/shared_ptr.hpp>
32 
33 namespace slideshow
34 {
35     namespace internal
36     {
37         class ShapeSubset;
38         typedef ::boost::shared_ptr< ShapeSubset > ShapeSubsetSharedPtr;
39 
40         /* Definition of ShapeSubset class */
41 
42         /** Subset RAII wrapper for shapes.
43 
44             This class wraps the plain Shape with a wrapper for subset
45             functionality. Subsetting can be turned on and off. Note
46             that the reason to have shape subsetting RAII implemented
47             separately (i.e. not within the DrawShape) was that
48             subsetting (and de-subsetting) needs the
49             SubsettableShapeManager. And holding that at the DrawShape
50             creates one heck of a circular reference.
51          */
52         class ShapeSubset
53         {
54         public:
55             /** Create a subset directly from a Shape.
56 
57                 @param rOriginalShape
58                 Original shape to subset
59 
60                 @param rTreeNode
61                 Subset this object should represent
62 
63                 @param rShapeManager
64                 Manager object, where subsets are
65                 registered/unregistered
66              */
67             ShapeSubset( const AttributableShapeSharedPtr&       rOriginalShape,
68                          const DocTreeNode&                      rTreeNode,
69                          const SubsettableShapeManagerSharedPtr& rSubsetManager );
70 
71             /** Create a subset from another subset.
72 
73                 Note: if you want this subset to subtract from the
74                 passed subset reference (and not from the original,
75                 unsubsetted shape), the passed subset must be enabled
76                 (enableSubsetShape() must have been called)
77 
78                 @param rOriginalSubset
79                 Original subset, which to subset again.
80 
81                 @param rTreeNode
82                 Subset of the original subset
83              */
84             ShapeSubset( const ShapeSubsetSharedPtr&        rOriginalSubset,
85                          const DocTreeNode&                 rTreeNode );
86 
87             /** Create full set for the given shape.
88 
89                 @param rOriginalShape
90                 Original shape, which will be represented as a whole
91                 by this object
92              */
93             ShapeSubset( const AttributableShapeSharedPtr&       rOriginalShape,
94                          const SubsettableShapeManagerSharedPtr& rShapeManager );
95 
96             ~ShapeSubset();
97 
98             /** Get the actual subset shape.
99 
100                 If the subset is currently revoked, this method
101                 returns the original shape.
102              */
103             AttributableShapeSharedPtr  getSubsetShape() const;
104 
105             /** Enable the subset shape.
106 
107                 This method enables the subset. That means, on
108                 successful completion of this method, the original
109                 shape will cease to show the subset range, and
110                 getSubsetShape() will return a valid shape.
111 
112                 @return true, if subsetting was successfully enabled.
113              */
114             bool            enableSubsetShape();
115 
116             /** Disable the subset shape.
117 
118                 This method revokes the subset from the original
119                 shape. That means, the original shape will again show
120                 the hidden range.
121              */
122             void            disableSubsetShape();
123 
124             /** Query whether this subset actually is none, but
125                 contains the whole original shape's content
126              */
127             bool isFullSet() const;
128 
129             /** Query subset this object represents
130              */
131             DocTreeNode getSubset() const;
132 
133         private:
134             // default copy/assignment are okay
135             //ShapeSubset(const ShapeSubset&);
136             //ShapeSubset& operator=( const ShapeSubset& );
137 
138             AttributableShapeSharedPtr       mpOriginalShape;
139             AttributableShapeSharedPtr       mpSubsetShape;
140             DocTreeNode                      maTreeNode;
141             SubsettableShapeManagerSharedPtr mpShapeManager;
142         };
143     }
144 }
145 
146 #endif /* INCLUDED_SLIDESHOW_SHAPESUBSET_HXX */
147