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 _SDR_CONTACT_VIEWOBJECTCONTACT_HXX 25 #define _SDR_CONTACT_VIEWOBJECTCONTACT_HXX 26 27 #include <sal/types.h> 28 29 #include <vector> 30 #include <tools/debug.hxx> 31 #include <tools/gen.hxx> 32 #include "svx/svxdllapi.h" 33 #include <drawinglayer/primitive2d/baseprimitive2d.hxx> 34 35 ////////////////////////////////////////////////////////////////////////////// 36 // predeclarations 37 38 class Region; 39 40 namespace sdr { namespace contact { 41 class DisplayInfo; 42 class ObjectContact; 43 class ViewContact; 44 class ViewObjectContactRedirector; 45 }} 46 47 namespace sdr { namespace animation { 48 class PrimitiveAnimation; 49 }} 50 51 ////////////////////////////////////////////////////////////////////////////// 52 53 namespace sdr 54 { 55 namespace contact 56 { 57 class SVX_DLLPUBLIC ViewObjectContact 58 { 59 private: 60 // must-exist and constant contacts 61 ObjectContact& mrObjectContact; 62 ViewContact& mrViewContact; 63 64 // This range defines the object's BoundRect 65 basegfx::B2DRange maObjectRange; 66 67 // PrimitiveSequence of the ViewContact. This contains all necessary information 68 // for the graphical visualisation and needs to be supported by all VCs which 69 // can be visualized. 70 drawinglayer::primitive2d::Primitive2DSequence mxPrimitive2DSequence; 71 72 // the PrimitiveAnimation if Primitive2DSequence contains animations 73 sdr::animation::PrimitiveAnimation* mpPrimitiveAnimation; 74 75 // bitfield 76 // This bool gets set when the object gets invalidated by ActionChanged() and 77 // can be used from the OC to late-invalidates 78 unsigned mbLazyInvalidate : 1; 79 80 protected: 81 // make redirector a protected friend, it needs to call createPrimitives as default action 82 friend class ViewObjectContactRedirector; 83 84 // Called from getPrimitive2DSequence() when vector has changed. Evaluate object animation 85 // and setup accordingly 86 void checkForPrimitive2DAnimations(); 87 88 // This method is responsible for creating the graphical visualisation data which is 89 // stored/cached in the local primitive. Default gets view-independent Primitive 90 // from the ViewContact using ViewContact::getViewIndependentPrimitive2DSequence(), takes care of 91 // visibility, handles glue and ghosted. 92 // This method will not handle included hierarchies and not check geometric visibility. 93 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const; 94 95 // method for flushing Primitive2DSequence for VOC implementations flushPrimitive2DSequence()96 void flushPrimitive2DSequence() { mxPrimitive2DSequence.realloc(0); } 97 98 public: 99 // basic constructor. 100 ViewObjectContact(ObjectContact& rObjectContact, ViewContact& rViewContact); 101 virtual ~ViewObjectContact(); 102 103 // access to ObjectContact GetObjectContact() const104 ObjectContact& GetObjectContact() const { return mrObjectContact; } 105 106 // access to ViewContact GetViewContact() const107 ViewContact& GetViewContact() const { return mrViewContact; } 108 109 // get the oebject's size range 110 const basegfx::B2DRange& getObjectRange() const; 111 112 // A ViewObjectContact was deleted and shall be forgotten. 113 void RemoveViewObjectContact(ViewObjectContact& rVOContact); 114 115 // React on changes of the object of this ViewContact 116 virtual void ActionChanged(); 117 118 // LazyInvalidate handling 119 void triggerLazyInvalidate(); 120 121 // Check if this primitive is animated in any OC (View) which means it has 122 // generated a PrimitiveAnimation isAnimated() const123 bool isAnimated() const { return (0 != mpPrimitiveAnimation); } 124 125 // Take some action when new objects are inserted 126 virtual void ActionChildInserted(ViewContact& rChild); 127 128 // access to the local primitive. This will ensure that the local primitive is 129 // current in comparing the local one with a fresh created incarnation 130 // This method will not handle included hierarchies and not check visibility. 131 drawinglayer::primitive2d::Primitive2DSequence getPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const; 132 133 // test this VOC for visibility concerning model-view stuff like e.g. Layer 134 virtual bool isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const; 135 136 // test this VOC for ghosted mode 137 virtual bool isPrimitiveGhosted(const DisplayInfo& rDisplayInfo) const; 138 139 // process this primitive: Eventually also recursively travel an existing hierarchy, 140 // e.g. for group objects, scenes or pages. This method will test geometrical visibility. 141 virtual drawinglayer::primitive2d::Primitive2DSequence getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const; 142 143 // just process the sub-hierarchy, used as tooling from getPrimitive2DSequenceHierarchy 144 drawinglayer::primitive2d::Primitive2DSequence getPrimitive2DSequenceSubHierarchy(DisplayInfo& rDisplayInfo) const; 145 }; 146 } // end of namespace contact 147 } // end of namespace sdr 148 149 ////////////////////////////////////////////////////////////////////////////// 150 151 #endif //_SDR_CONTACT_VIEWOBJECTCONTACT_HXX 152 153 // eof 154