LibreOffice Module svx (master)  1
viewobjectcontact.hxx
Go to the documentation of this file.
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_SVX_SDR_CONTACT_VIEWOBJECTCONTACT_HXX
21 #define INCLUDED_SVX_SDR_CONTACT_VIEWOBJECTCONTACT_HXX
22 
23 #include <memory>
24 #include <svx/svxdllapi.h>
26 
27 namespace vcl { class Region; }
28 
29 namespace sdr::animation {
30  class PrimitiveAnimation;
31 }
32 namespace drawinglayer::primitive2d { class Primitive2DDecompositionVisitor; }
33 
34 namespace sdr::contact {
35 
36 class DisplayInfo;
37 class ObjectContact;
38 class ViewContact;
39 class ViewObjectContactRedirector;
40 
42 {
43 private:
44  // must-exist and constant contacts
47 
48  // This range defines the object's BoundRect
50 
51  // PrimitiveSequence of the ViewContact. This contains all necessary information
52  // for the graphical visualisation and needs to be supported by all VCs which
53  // can be visualized.
55 
56  // the PrimitiveAnimation if Primitive2DContainer contains animations
57  std::unique_ptr<sdr::animation::PrimitiveAnimation> mpPrimitiveAnimation;
58 
59  // possible on-demand calculated GridOffset for non-linear ViewToDevice transformation (calc)
61 
62  // This bool gets set when the object gets invalidated by ActionChanged() and
63  // can be used from the OC to late-invalidates
64  bool mbLazyInvalidate : 1;
65 
66 protected:
67  // make redirector a protected friend, it needs to call createPrimitives as default action
69 
70  // Called from getPrimitive2DSequence() when vector has changed. Evaluate object animation
71  // and setup accordingly
72  void checkForPrimitive2DAnimations();
73 
74  // This method is responsible for creating the graphical visualisation data which is
75  // stored/cached in the local primitive. Default gets view-independent Primitive
76  // from the ViewContact using ViewContact::getViewIndependentPrimitive2DContainer(), takes care of
77  // visibility, handles glue and ghosted.
78  // This method will not handle included hierarchies and not check geometric visibility.
79  virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const;
80 
81  // method for flushing Primitive2DContainer for VOC implementations
82  void flushPrimitive2DSequence() { mxPrimitive2DSequence.clear(); }
83 
84 public:
85  // basic constructor.
86  ViewObjectContact(ObjectContact& rObjectContact, ViewContact& rViewContact);
87  virtual ~ViewObjectContact();
88 
89  // access to ObjectContact
90  ObjectContact& GetObjectContact() const { return mrObjectContact; }
91 
92  // access to ViewContact
93  ViewContact& GetViewContact() const { return mrViewContact; }
94 
95  // get the object size range
96  const basegfx::B2DRange& getObjectRange() const;
97 
98  // React on changes of the object of this ViewContact
99  virtual void ActionChanged();
100 
101  // LazyInvalidate handling
102  void triggerLazyInvalidate();
103 
104  // Check if this primitive is animated in any OC (View) which means it has
105  // generated a PrimitiveAnimation
106  bool isAnimated() const { return (nullptr != mpPrimitiveAnimation); }
107 
108  // Take some action when new objects are inserted
109  void ActionChildInserted(ViewContact& rChild);
110 
111  // access to the local primitive. This will ensure that the local primitive is
112  // current in comparing the local one with a fresh created incarnation
113  // This method will not handle included hierarchies and not check visibility.
114  drawinglayer::primitive2d::Primitive2DContainer const & getPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const;
115 
116  // test this VOC for visibility concerning model-view stuff like e.g. Layer
117  virtual bool isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const;
118 
119  // test this VOC for ghosted mode
120  virtual bool isPrimitiveGhosted(const DisplayInfo& rDisplayInfo) const;
121 
122  // process this primitive: Eventually also recursively travel an existing hierarchy,
123  // e.g. for group objects, scenes or pages. This method will test geometrical visibility.
124  virtual void getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo, drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) const;
125 
126  // just process the sub-hierarchy, used as tooling from getPrimitive2DSequenceHierarchy
127  drawinglayer::primitive2d::Primitive2DContainer getPrimitive2DSequenceSubHierarchy(DisplayInfo& rDisplayInfo) const;
128 
129  // interface to support GridOffset for non-linear ViewToDevice transformation (calc)
130  const basegfx::B2DVector& getGridOffset() const;
131  void resetGridOffset();
132 };
133 
134 }
135 
136 
137 #endif // INCLUDED_SVX_SDR_CONTACT_VIEWOBJECTCONTACT_HXX
138 
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
drawinglayer::primitive2d::Primitive2DContainer mxPrimitive2DSequence
ObjectContact & GetObjectContact() const
std::unique_ptr< sdr::animation::PrimitiveAnimation > mpPrimitiveAnimation
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
ViewContact & GetViewContact() const