LibreOffice Module svx (master)  1
objectcontact.cxx
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 
21 #include <tools/debug.hxx>
24 
25 using namespace com::sun::star;
26 
27 namespace sdr::contact {
28 
29 bool ObjectContact::supportsGridOffsets() const
30 {
31  // default does not support GridOffset
32  return false;
33 }
34 
35 void ObjectContact::calculateGridOffsetForViewOjectContact(
36  basegfx::B2DVector& /*rTarget*/,
37  const ViewObjectContact& /*rClient*/) const
38 {
39  // default does not on-demand calculate GridOffset
40 }
41 
42 void ObjectContact::calculateGridOffsetForB2DRange(
43  basegfx::B2DVector& /*rTarget*/,
44  const basegfx::B2DRange& /*rB2DRange*/) const
45 {
46  // default does not on-demand calculate GridOffset
47 }
48 
49 ObjectContact::ObjectContact()
50 : mpViewObjectContactRedirector(nullptr),
51  mbIsPreviewRenderer(false)
52 {
53 }
54 
55 ObjectContact::~ObjectContact() COVERITY_NOEXCEPT_FALSE
56 {
57  // get rid of all registered contacts
58  // #i84257# To avoid that each 'delete pCandidate' again uses
59  // the local RemoveViewObjectContact with a search and removal in the
60  // vector, simply copy and clear local vector.
61  std::vector< ViewObjectContact* > aLocalVOCList;
62  aLocalVOCList.swap(maViewObjectContactVector);
63 
64  for (const auto & pCandidate : aLocalVOCList)
65  // ViewObjectContacts only make sense with View and Object contacts.
66  // When the contact to the SdrObject is deleted like in this case,
67  // all ViewObjectContacts can be deleted, too.
68  delete pCandidate;
69 
70  // assert when there were new entries added during deletion
71  DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList (!)");
72 }
73 
74 // LazyInvalidate request. Default implementation directly handles
75 // this by calling back triggerLazyInvalidate() at the VOC
77 {
78  rVOC.triggerLazyInvalidate();
79 }
80 
81 // call this to support evtl. preparations for repaint. Default does nothing
83 {
84 }
85 
86 // A new ViewObjectContact was created and shall be remembered.
88 {
89  maViewObjectContactVector.push_back(&rVOContact);
90 }
91 
92 // A ViewObjectContact was deleted and shall be forgotten.
94 {
95  std::vector< ViewObjectContact* >::iterator aFindResult = std::find(maViewObjectContactVector.begin(), maViewObjectContactVector.end(), &rVOContact);
96 
97  if(aFindResult != maViewObjectContactVector.end())
98  {
99  maViewObjectContactVector.erase(aFindResult);
100  }
101 }
102 
103 // Process the whole displaying
105 {
106  // default does nothing
107 }
108 
109 // test if visualizing of entered groups is switched on at all
111 {
112  // Do not do that as default
113  return false;
114 }
115 
116 // get active group's (the entered group) ViewContact
118 {
119  // default has no active VC
120  return nullptr;
121 }
122 
123 // Invalidate given rectangle at the window/output which is represented by
124 // this ObjectContact.
126 {
127  // nothing to do here in the default version
128 }
129 
130 // Get info about the need to visualize GluePoints
132 {
133  return false;
134 }
135 
136 // check if text animation is allowed. Default is sal_true.
138 {
139  return true;
140 }
141 
142 // check if graphic animation is allowed. Default is sal_true.
144 {
145  return true;
146 }
147 
149 {
151  {
153  }
154 }
155 
156 // print? Default is false
158 {
159  return false;
160 }
161 
162 // recording MetaFile? Default is false
164 {
165  return false;
166 }
167 
168 // pdf export? Default is false
170 {
171  return false;
172 }
173 
174 // gray display mode
176 {
177  return false;
178 }
179 
180 // high contrast display mode
182 {
183  return false;
184 }
185 
186 // access to SdrPageView. Default implementation returns NULL
188 {
189  return nullptr;
190 }
191 
192 // access to OutputDevice. Default implementation returns NULL
194 {
195  return nullptr;
196 }
197 
199 {
200  const sal_uInt32 nVOCCount(getViewObjectContactCount());
201 
202  for(sal_uInt32 a(0); a < nVOCCount; a++)
203  {
205  assert(pVOC && "ObjectContact: ViewObjectContact list Corrupt (!)");
206  pVOC->resetGridOffset();
207  }
208 }
209 
210 }
211 
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void InvalidatePartOfView(const basegfx::B2DRange &rRange) const
virtual bool isDrawModeHighContrast() const
virtual void PrepareProcessDisplay()
virtual bool AreGluePointsVisible() const
void RemoveViewObjectContact(ViewObjectContact &rVOContact)
virtual void setLazyInvalidate(ViewObjectContact &rVOC)
ViewObjectContactRedirector * mpViewObjectContactRedirector
virtual bool isOutputToPrinter() const
virtual bool isOutputToPDFFile() const
#define DBG_ASSERT(sCon, aError)
uno_Any a
void SetViewObjectContactRedirector(ViewObjectContactRedirector *pNew)
ViewObjectContact * getViewObjectContact(sal_uInt32 a) const
virtual bool IsTextAnimationAllowed() const
std::vector< ViewObjectContact * > maViewObjectContactVector
void AddViewObjectContact(ViewObjectContact &rVOContact)
virtual bool isOutputToRecordingMetaFile() const
sal_uInt32 getViewObjectContactCount() const
virtual bool DoVisualizeEnteredGroup() const
virtual void ProcessDisplay(DisplayInfo &rDisplayInfo)
virtual OutputDevice * TryToGetOutputDevice() const
access to OutputDevice. May return 0L like the default implementations do. Override as needed...
virtual bool isDrawModeGray() const
virtual bool IsGraphicAnimationAllowed() const
virtual const ViewContact * getActiveViewContact() const
virtual SdrPageView * TryToGetSdrPageView() const
access to SdrPageView. May return 0L like the default implementations do. Override as needed...
virtual ~ObjectContact() COVERITY_NOEXCEPT_FALSE