cid#1606940 Check of thread-shared field evades lock acquisition
[LibreOffice.git] / svx / source / sdr / contact / objectcontact.cxx
blobf36c5412b1823fa6d8456631e691b0dca842aaca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/sdr/contact/objectcontact.hxx>
21 #include <tools/debug.hxx>
22 #include <svx/sdr/contact/viewobjectcontact.hxx>
23 #include <svx/sdr/contact/viewcontact.hxx>
25 using namespace com::sun::star;
27 namespace sdr::contact {
29 bool ObjectContact::supportsGridOffsets() const
31 // default does not support GridOffset
32 return false;
35 void ObjectContact::calculateGridOffsetForViewObjectContact(
36 basegfx::B2DVector& /*rTarget*/,
37 const ViewObjectContact& /*rClient*/) const
39 // default does not on-demand calculate GridOffset
42 void ObjectContact::calculateGridOffsetForB2DRange(
43 basegfx::B2DVector& /*rTarget*/,
44 const basegfx::B2DRange& /*rB2DRange*/) const
46 // default does not on-demand calculate GridOffset
49 ObjectContact::ObjectContact()
50 : mpViewObjectContactRedirector(nullptr),
51 mbIsPreviewRenderer(false)
55 ObjectContact::~ObjectContact() COVERITY_NOEXCEPT_FALSE
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);
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;
70 // assert when there were new entries added during deletion
71 DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList (!)");
74 // LazyInvalidate request. Default implementation directly handles
75 // this by calling back triggerLazyInvalidate() at the VOC
76 void ObjectContact::setLazyInvalidate(ViewObjectContact& rVOC)
78 rVOC.triggerLazyInvalidate();
81 // call this to support evtl. preparations for repaint. Default does nothing
82 void ObjectContact::PrepareProcessDisplay()
86 // A new ViewObjectContact was created and shall be remembered.
87 void ObjectContact::AddViewObjectContact(ViewObjectContact& rVOContact)
89 maViewObjectContactVector.push_back(&rVOContact);
92 // A ViewObjectContact was deleted and shall be forgotten.
93 void ObjectContact::RemoveViewObjectContact(ViewObjectContact& rVOContact)
95 std::vector< ViewObjectContact* >::iterator aFindResult = std::find(maViewObjectContactVector.begin(), maViewObjectContactVector.end(), &rVOContact);
97 if(aFindResult != maViewObjectContactVector.end())
99 maViewObjectContactVector.erase(aFindResult);
103 // Process the whole displaying
104 void ObjectContact::ProcessDisplay(DisplayInfo& /*rDisplayInfo*/)
106 // default does nothing
109 // test if visualizing of entered groups is switched on at all
110 bool ObjectContact::DoVisualizeEnteredGroup() const
112 // Do not do that as default
113 return false;
116 // get active group's (the entered group) ViewContact
117 const ViewContact* ObjectContact::getActiveViewContact() const
119 // default has no active VC
120 return nullptr;
123 // Invalidate given rectangle at the window/output which is represented by
124 // this ObjectContact.
125 void ObjectContact::InvalidatePartOfView(const basegfx::B2DRange& /*rRange*/) const
127 // nothing to do here in the default version
130 // Get info about the need to visualize GluePoints
131 bool ObjectContact::AreGluePointsVisible() const
133 return false;
136 // check if text animation is allowed. Default is sal_true.
137 bool ObjectContact::IsTextAnimationAllowed() const
139 return true;
142 // check if graphic animation is allowed. Default is sal_true.
143 bool ObjectContact::IsGraphicAnimationAllowed() const
145 return true;
148 void ObjectContact::SetViewObjectContactRedirector(ViewObjectContactRedirector* pNew)
150 if(mpViewObjectContactRedirector != pNew)
152 mpViewObjectContactRedirector = pNew;
156 // print? Default is false
157 bool ObjectContact::isOutputToPrinter() const
159 return false;
162 // display page decoration? Default is true
163 bool ObjectContact::isPageDecorationActive() const
165 return true;
168 // display mster page content (ViewContactOfMasterPage)? Default is true
169 bool ObjectContact::isMasterPageActive() const
171 return true;
174 // recording MetaFile? Default is false
175 bool ObjectContact::isOutputToRecordingMetaFile() const
177 return false;
180 // pdf export? Default is false
181 bool ObjectContact::isOutputToPDFFile() const
183 return false;
186 bool ObjectContact::isExportTaggedPDF() const
188 return false;
191 ::vcl::PDFExtOutDevData const* ObjectContact::GetPDFExtOutDevData() const
193 return nullptr;
196 // gray display mode
197 bool ObjectContact::isDrawModeGray() const
199 return false;
202 // high contrast display mode
203 bool ObjectContact::isDrawModeHighContrast() const
205 return false;
208 // access to SdrPageView. Default implementation returns NULL
209 SdrPageView* ObjectContact::TryToGetSdrPageView() const
211 return nullptr;
214 // access to OutputDevice. Default implementation returns NULL
215 OutputDevice* ObjectContact::TryToGetOutputDevice() const
217 return nullptr;
220 void ObjectContact::resetAllGridOffsets()
222 const sal_uInt32 nVOCCount(getViewObjectContactCount());
224 for(sal_uInt32 a(0); a < nVOCCount; a++)
226 ViewObjectContact* pVOC(getViewObjectContact(a));
227 assert(pVOC && "ObjectContact: ViewObjectContact list Corrupt (!)");
228 pVOC->resetGridOffset();
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */