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_SHAPESUBSET_HXX
21 : #define INCLUDED_SLIDESHOW_SHAPESUBSET_HXX
22 :
23 : #include "attributableshape.hxx"
24 : #include "subsettableshapemanager.hxx"
25 : #include "doctreenode.hxx"
26 :
27 : #include <boost/shared_ptr.hpp>
28 :
29 : namespace slideshow
30 : {
31 : namespace internal
32 : {
33 : class ShapeSubset;
34 : typedef ::boost::shared_ptr< ShapeSubset > ShapeSubsetSharedPtr;
35 :
36 : /* Definition of ShapeSubset class */
37 :
38 : /** Subset RAII wrapper for shapes.
39 :
40 : This class wraps the plain Shape with a wrapper for subset
41 : functionality. Subsetting can be turned on and off. Note
42 : that the reason to have shape subsetting RAII implemented
43 : separately (i.e. not within the DrawShape) was that
44 : subsetting (and de-subsetting) needs the
45 : SubsettableShapeManager. And holding that at the DrawShape
46 : creates one heck of a circular reference.
47 : */
48 0 : class ShapeSubset
49 : {
50 : public:
51 : /** Create a subset directly from a Shape.
52 :
53 : @param rOriginalShape
54 : Original shape to subset
55 :
56 : @param rTreeNode
57 : Subset this object should represent
58 :
59 : @param rShapeManager
60 : Manager object, where subsets are
61 : registered/unregistered
62 : */
63 : ShapeSubset( const AttributableShapeSharedPtr& rOriginalShape,
64 : const DocTreeNode& rTreeNode,
65 : const SubsettableShapeManagerSharedPtr& rSubsetManager );
66 :
67 : /** Create a subset from another subset.
68 :
69 : Note: if you want this subset to subtract from the
70 : passed subset reference (and not from the original,
71 : unsubsetted shape), the passed subset must be enabled
72 : (enableSubsetShape() must have been called)
73 :
74 : @param rOriginalSubset
75 : Original subset, which to subset again.
76 :
77 : @param rTreeNode
78 : Subset of the original subset
79 : */
80 : ShapeSubset( const ShapeSubsetSharedPtr& rOriginalSubset,
81 : const DocTreeNode& rTreeNode );
82 :
83 : /** Create full set for the given shape.
84 :
85 : @param rOriginalShape
86 : Original shape, which will be represented as a whole
87 : by this object
88 : */
89 : ShapeSubset( const AttributableShapeSharedPtr& rOriginalShape,
90 : const SubsettableShapeManagerSharedPtr& rShapeManager );
91 :
92 : ~ShapeSubset();
93 :
94 : /** Get the actual subset shape.
95 :
96 : If the subset is currently revoked, this method
97 : returns the original shape.
98 : */
99 : AttributableShapeSharedPtr getSubsetShape() const;
100 :
101 : /** Enable the subset shape.
102 :
103 : This method enables the subset. That means, on
104 : successful completion of this method, the original
105 : shape will cease to show the subset range, and
106 : getSubsetShape() will return a valid shape.
107 :
108 : @return true, if subsetting was successfully enabled.
109 : */
110 : bool enableSubsetShape();
111 :
112 : /** Disable the subset shape.
113 :
114 : This method revokes the subset from the original
115 : shape. That means, the original shape will again show
116 : the hidden range.
117 : */
118 : void disableSubsetShape();
119 :
120 : /** Query whether this subset actually is none, but
121 : contains the whole original shape's content
122 : */
123 : bool isFullSet() const;
124 :
125 : /** Query subset this object represents
126 : */
127 : DocTreeNode getSubset() const;
128 :
129 : private:
130 : // default copy/assignment are okay
131 : //ShapeSubset(const ShapeSubset&);
132 : //ShapeSubset& operator=( const ShapeSubset& );
133 :
134 : AttributableShapeSharedPtr mpOriginalShape;
135 : AttributableShapeSharedPtr mpSubsetShape;
136 : DocTreeNode maTreeNode;
137 : SubsettableShapeManagerSharedPtr mpShapeManager;
138 : };
139 : }
140 : }
141 :
142 : #endif /* INCLUDED_SLIDESHOW_SHAPESUBSET_HXX */
143 :
144 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|