Bug Summary

File:home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx
Warning:line 275, column 13
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name ssfrm.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -isystem /usr/include/libxml2 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D SW_DLLIMPLEMENTATION -D SWUI_DLL_NAME="libswuilo.so" -D SYSTEM_LIBXML -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/common -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/sw/source/core/inc -I /home/maarten/src/libreoffice/core/sw/source/filter/inc -I /home/maarten/src/libreoffice/core/sw/source/uibase/inc -I /home/maarten/src/libreoffice/core/sw/inc -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/sw/sdi -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/sw/generated -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/oovbaapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx
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#include <pagefrm.hxx>
21#include <rootfrm.hxx>
22#include <dcontact.hxx>
23#include <flyfrm.hxx>
24#include <txtfrm.hxx>
25#include <cellfrm.hxx>
26#include <swtable.hxx>
27#include <fmtfsize.hxx>
28#include <editeng/boxitem.hxx>
29#include <editeng/shaditem.hxx>
30#include <IDocumentRedlineAccess.hxx>
31#include <fmtclds.hxx>
32#include <viewimp.hxx>
33#include <sortedobjs.hxx>
34#include <hints.hxx>
35#include <frmtool.hxx>
36#include <ndtxt.hxx>
37
38 // No inline cause we need the function pointers
39long SwFrame::GetTopMargin() const
40 { return getFramePrintArea().Top(); }
41long SwFrame::GetBottomMargin() const
42 { return getFrameArea().Height() -getFramePrintArea().Height() -getFramePrintArea().Top(); }
43long SwFrame::GetLeftMargin() const
44 { return getFramePrintArea().Left(); }
45long SwFrame::GetRightMargin() const
46 { return getFrameArea().Width() - getFramePrintArea().Width() - getFramePrintArea().Left(); }
47long SwFrame::GetPrtLeft() const
48 { return getFrameArea().Left() + getFramePrintArea().Left(); }
49long SwFrame::GetPrtBottom() const
50 { return getFrameArea().Top() + getFramePrintArea().Height() + getFramePrintArea().Top(); }
51long SwFrame::GetPrtRight() const
52 { return getFrameArea().Left() + getFramePrintArea().Width() + getFramePrintArea().Left(); }
53long SwFrame::GetPrtTop() const
54 { return getFrameArea().Top() + getFramePrintArea().Top(); }
55
56bool SwFrame::SetMinLeft( long nDeadline )
57{
58 SwTwips nDiff = nDeadline - getFrameArea().Left();
59 if( nDiff > 0 )
60 {
61 SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
62 aFrm.Left( nDeadline );
63
64 SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
65 aPrt.Width( aPrt.Width() - nDiff );
66
67 return true;
68 }
69 return false;
70}
71
72bool SwFrame::SetMaxBottom( long nDeadline )
73{
74 SwTwips nDiff = getFrameArea().Top() + getFrameArea().Height() - nDeadline;
75 if( nDiff > 0 )
76 {
77 SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
78 aFrm.Height( aFrm.Height() - nDiff );
79
80 SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
81 aPrt.Height( aPrt.Height() - nDiff );
82
83 return true;
84 }
85 return false;
86}
87
88bool SwFrame::SetMaxRight( long nDeadline )
89{
90 SwTwips nDiff = getFrameArea().Left() + getFrameArea().Width() - nDeadline;
91 if( nDiff > 0 )
92 {
93 SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
94 aFrm.Width( aFrm.Width() - nDiff );
95
96 SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
97 aPrt.Width( aPrt.Width() - nDiff );
98
99 return true;
100 }
101 return false;
102}
103
104void SwFrame::MakeBelowPos( const SwFrame* pUp, const SwFrame* pPrv, bool bNotify )
105{
106 SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
107
108 if( pPrv )
109 {
110 aFrm.Pos( pPrv->getFrameArea().Pos() );
111 aFrm.Pos().AdjustY(pPrv->getFrameArea().Height() );
112 }
113 else
114 {
115 aFrm.Pos( pUp->getFrameArea().Pos() );
116 aFrm.Pos() += pUp->getFramePrintArea().Pos();
117 }
118
119 if( bNotify )
120 {
121 aFrm.Pos().AdjustY(1 );
122 }
123}
124
125void SwFrame::MakeLeftPos( const SwFrame* pUp, const SwFrame* pPrv, bool bNotify )
126{
127 SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
128
129 if( pPrv )
130 {
131 aFrm.Pos( pPrv->getFrameArea().Pos() );
132 aFrm.Pos().AdjustX( -(aFrm.Width()) );
133 }
134 else
135 {
136 aFrm.Pos( pUp->getFrameArea().Pos() );
137 aFrm.Pos() += pUp->getFramePrintArea().Pos();
138 aFrm.Pos().AdjustX(pUp->getFramePrintArea().Width() - aFrm.Width() );
139 }
140
141 if( bNotify )
142 {
143 aFrm.Pos().AdjustX( -1 );
144 }
145}
146
147void SwFrame::MakeRightPos( const SwFrame* pUp, const SwFrame* pPrv, bool bNotify )
148{
149 SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this);
150
151 if( pPrv )
152 {
153 aFrm.Pos( pPrv->getFrameArea().Pos() );
154 aFrm.Pos().AdjustX(pPrv->getFrameArea().Width() );
155 }
156 else
157 {
158 aFrm.Pos( pUp->getFrameArea().Pos() );
159 aFrm.Pos() += pUp->getFramePrintArea().Pos();
160 }
161
162 if( bNotify )
163 {
164 aFrm.Pos().AdjustX(1 );
165 }
166}
167
168void SwFrame::SetTopBottomMargins( long nTop, long nBot )
169{
170 SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
171 aPrt.Top( nTop );
172 aPrt.Height( getFrameArea().Height() - nTop - nBot );
173}
174
175void SwFrame::SetLeftRightMargins( long nLeft, long nRight)
176{
177 SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
178 aPrt.Left( nLeft );
179 aPrt.Width( getFrameArea().Width() - nLeft - nRight );
180}
181
182void SwFrame::SetRightLeftMargins( long nRight, long nLeft)
183{
184 SwFrameAreaDefinition::FramePrintAreaWriteAccess aPrt(*this);
185 aPrt.Left( nLeft );
186 aPrt.Width( getFrameArea().Width() - nLeft - nRight );
187}
188
189/// checks the layout direction and invalidates the lower frames recursively, if necessary.
190void SwFrame::CheckDirChange()
191{
192 bool bOldVert = mbVertical;
193 bool bOldR2L = mbRightToLeft;
194 SetInvalidVert( true );
195 mbInvalidR2L = true;
196 bool bChg = bOldR2L != IsRightToLeft();
1
Assuming the condition is false
197 bool bOldVertL2R = IsVertLR();
198 if( !(( IsVertical() != bOldVert ) || bChg || bOldVertL2R != IsVertLR()) )
2
Assuming the condition is true
3
Taking false branch
199 return;
200
201 InvalidateAll();
202 if( IsLayoutFrame() )
4
Taking false branch
203 {
204 // set minimum row height for vertical cells in horizontal table:
205 if ( IsCellFrame() && GetUpper() )
206 {
207 if ( IsVertical() != GetUpper()->IsVertical() &&
208 static_cast<SwCellFrame*>(this)->GetTabBox()->getRowSpan() == 1 )
209 {
210 enum {
211 MIN_VERT_CELL_HEIGHT = 1135
212 };
213
214 SwTableLine* pLine = const_cast<SwTableLine*>(static_cast<SwCellFrame*>(this)->GetTabBox()->GetUpper());
215 SwFrameFormat* pFrameFormat = pLine->GetFrameFormat();
216 SwFormatFrameSize aNew( pFrameFormat->GetFrameSize() );
217 if ( SwFrameSize::Fixed != aNew.GetHeightSizeType() )
218 aNew.SetHeightSizeType( SwFrameSize::Minimum );
219 if ( aNew.GetHeight() < MIN_VERT_CELL_HEIGHT )
220 aNew.SetHeight( MIN_VERT_CELL_HEIGHT );
221 SwDoc* pDoc = pFrameFormat->GetDoc();
222 pDoc->SetAttr( aNew, *pLine->ClaimFrameFormat() );
223 }
224 }
225
226 SwFrame* pFrame = static_cast<SwLayoutFrame*>(this)->Lower();
227 const SwFormatCol* pCol = nullptr;
228 SwLayoutFrame* pBody = nullptr;
229 if( pFrame )
230 {
231 if( IsPageFrame() )
232 {
233 // If we're a page frame and we change our layout direction,
234 // we have to look for columns and rearrange them.
235 pBody = static_cast<SwPageFrame*>(this)->FindBodyCont();
236 if(pBody && pBody->Lower() && pBody->Lower()->IsColumnFrame())
237 pCol = &static_cast<SwPageFrame*>(this)->GetFormat()->GetCol();
238 }
239 else if( pFrame->IsColumnFrame() )
240 {
241 pBody = static_cast<SwLayoutFrame*>(this);
242 const SwFrameFormat *pFormat = pBody->GetFormat();
243 if( pFormat )
244 pCol = &pFormat->GetCol();
245 }
246 }
247 while( pFrame )
248 {
249 pFrame->CheckDirChange();
250 pFrame = pFrame->GetNext();
251 }
252 if( pCol )
253 pBody->AdjustColumns( pCol, true );
254 }
255 else if( IsTextFrame() )
5
Taking false branch
256 static_cast<SwTextFrame*>(this)->Prepare();
257
258 // #i31698# - notify anchored objects also for page frames.
259 // Remove code above for special handling of page frames
260 if ( !GetDrawObjs() )
6
Assuming the condition is false
7
Taking false branch
261 return;
262
263 const SwSortedObjs *pObjs = GetDrawObjs();
264 const size_t nCnt = pObjs->size();
265 for ( size_t i = 0; i < nCnt; ++i )
8
Assuming 'i' is < 'nCnt'
9
Loop condition is true. Entering loop body
266 {
267 SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
10
'pAnchoredObj' initialized here
268 if( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
11
Assuming pointer value is null
12
Taking false branch
269 static_cast<SwFlyFrame*>(pAnchoredObj)->CheckDirChange();
270 else
271 {
272 // OD 2004-04-06 #i26791# - direct object
273 // positioning no longer needed. Instead
274 // invalidate
275 pAnchoredObj->InvalidateObjPos();
13
Called C++ object pointer is null
276 }
277 // #i31698# - update layout direction of
278 // anchored object
279 {
280 ::setContextWritingMode( pAnchoredObj->DrawObj(), pAnchoredObj->GetAnchorFrameContainingAnchPos() );
281 pAnchoredObj->UpdateLayoutDir();
282 }
283 }
284}
285
286/// returns the position for anchors based on frame direction
287// OD 2004-03-10 #i11860# - consider lower space and line spacing of
288// previous frame according to new option 'Use former object positioning'
289Point SwFrame::GetFrameAnchorPos( bool bIgnoreFlysAnchoredAtThisFrame ) const
290{
291 Point aAnchor = getFrameArea().Pos();
292
293 if ( ( IsVertical() && !IsVertLR() ) || IsRightToLeft() )
294 aAnchor.AdjustX(getFrameArea().Width() );
295
296 if ( IsTextFrame() )
297 {
298 SwTwips nBaseOfstForFly =
299 static_cast<const SwTextFrame*>(this)->GetBaseOffsetForFly( bIgnoreFlysAnchoredAtThisFrame );
300 if ( IsVertical() )
301 aAnchor.AdjustY(nBaseOfstForFly );
302 else
303 aAnchor.AdjustX(nBaseOfstForFly );
304
305 // OD 2004-03-10 #i11860# - if option 'Use former object positioning'
306 // is OFF, consider the lower space and the line spacing of the
307 // previous frame and the spacing considered for the page grid
308 const SwTextFrame* pThisTextFrame = static_cast<const SwTextFrame*>(this);
309 const SwTwips nUpperSpaceAmountConsideredForPrevFrameAndPageGrid =
310 pThisTextFrame->GetUpperSpaceAmountConsideredForPrevFrameAndPageGrid();
311 if ( IsVertical() )
312 {
313 aAnchor.AdjustX( -nUpperSpaceAmountConsideredForPrevFrameAndPageGrid );
314 }
315 else
316 {
317 aAnchor.AdjustY(nUpperSpaceAmountConsideredForPrevFrameAndPageGrid );
318 }
319 }
320
321 return aAnchor;
322}
323
324void SwFrame::DestroyImpl()
325{
326 mbInDtor = true;
327
328 // accessible objects for fly and cell frames have been already disposed
329 // by the destructors of the derived classes.
330 if (IsAccessibleFrame() && !(IsFlyFrame() || IsCellFrame())
331 && (GetDep() || IsTextFrame())) // sw_redlinehide: text frame may not have Dep!
332 {
333 assert(!IsTextFrame() || GetDep() || static_cast<SwTextFrame*>(this)->GetMergedPara())(static_cast <bool> (!IsTextFrame() || GetDep() || static_cast
<SwTextFrame*>(this)->GetMergedPara()) ? void (0) : __assert_fail
("!IsTextFrame() || GetDep() || static_cast<SwTextFrame*>(this)->GetMergedPara()"
, "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 333, __extension__ __PRETTY_FUNCTION__))
;
334 SwRootFrame *pRootFrame = getRootFrame();
335 if( pRootFrame && pRootFrame->IsAnyShellAccessible() )
336 {
337 SwViewShell *pVSh = pRootFrame->GetCurrShell();
338 if( pVSh && pVSh->Imp() )
339 {
340 OSL_ENSURE( !GetLower(), "Lowers should be dispose already!" )do { if (true && (!(!GetLower()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
":" "340" ": "), "%s", "Lowers should be dispose already!");
} } while (false)
;
341 pVSh->Imp()->DisposeAccessibleFrame( this );
342 }
343 }
344 }
345
346 if (!m_pDrawObjs)
347 return;
348
349 for (size_t i = m_pDrawObjs->size(); i; )
350 {
351 SwAnchoredObject* pAnchoredObj = (*m_pDrawObjs)[--i];
352 if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
353 {
354 SwFrame::DestroyFrame(static_cast<SwFlyFrame*>(pAnchoredObj));
355 }
356 else
357 {
358 SdrObject* pSdrObj = pAnchoredObj->DrawObj();
359 SwDrawContact* pContact =
360 static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
361 OSL_ENSURE( pContact,do { if (true && (!(pContact))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
":" "362" ": "), "%s", "<SwFrame::~SwFrame> - missing contact for drawing object"
); } } while (false)
362 "<SwFrame::~SwFrame> - missing contact for drawing object" )do { if (true && (!(pContact))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
":" "362" ": "), "%s", "<SwFrame::~SwFrame> - missing contact for drawing object"
); } } while (false)
;
363 if ( pContact )
364 {
365 pContact->DisconnectObjFromLayout( pSdrObj );
366 }
367 }
368 }
369 m_pDrawObjs.reset();
370}
371
372SwFrame::~SwFrame()
373{
374 assert(m_isInDestroy)(static_cast <bool> (m_isInDestroy) ? void (0) : __assert_fail
("m_isInDestroy", "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 374, __extension__ __PRETTY_FUNCTION__))
; // check that only DestroySwFrame does "delete"
375 assert(!IsDeleteForbidden())(static_cast <bool> (!IsDeleteForbidden()) ? void (0) :
__assert_fail ("!IsDeleteForbidden()", "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 375, __extension__ __PRETTY_FUNCTION__))
; // check that it's not deleted while deletes are forbidden
376#if OSL_DEBUG_LEVEL1 > 0
377 // JP 15.10.2001: for detection of access to deleted frames
378 mpRoot = reinterpret_cast<SwRootFrame*>(0x33333333);
379#endif
380}
381
382void SwFrame::DestroyFrame(SwFrame *const pFrame)
383{
384 if (pFrame)
385 {
386 pFrame->m_isInDestroy = true;
387 pFrame->DestroyImpl();
388 assert(pFrame->mbInDtor)(static_cast <bool> (pFrame->mbInDtor) ? void (0) : __assert_fail
("pFrame->mbInDtor", "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 388, __extension__ __PRETTY_FUNCTION__))
; // check that nobody forgot to call base class
389 delete pFrame;
390 }
391}
392
393const SwFrameFormat * SwLayoutFrame::GetFormat() const
394{
395 return static_cast< const SwFrameFormat * >( GetDep() );
396}
397
398SwFrameFormat * SwLayoutFrame::GetFormat()
399{
400 return static_cast< SwFrameFormat * >( GetDep() );
401}
402
403void SwLayoutFrame::SetFrameFormat( SwFrameFormat *pNew )
404{
405 if ( pNew != GetFormat() )
406 {
407 SwFormatChg aOldFormat( GetFormat() );
408 pNew->Add( this );
409 SwFormatChg aNewFormat( pNew );
410 ModifyNotification( &aOldFormat, &aNewFormat );
411 }
412}
413
414SwContentFrame::SwContentFrame( SwContentNode * const pContent, SwFrame* pSib ) :
415 SwFrame( pContent, pSib ),
416 SwFlowFrame( static_cast<SwFrame&>(*this) )
417{
418 assert(!getRootFrame()->IsHideRedlines() || pContent->IsCreateFrameWhenHidingRedlines())(static_cast <bool> (!getRootFrame()->IsHideRedlines
() || pContent->IsCreateFrameWhenHidingRedlines()) ? void (
0) : __assert_fail ("!getRootFrame()->IsHideRedlines() || pContent->IsCreateFrameWhenHidingRedlines()"
, "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 418, __extension__ __PRETTY_FUNCTION__))
;
419}
420
421void SwContentFrame::DestroyImpl()
422{
423 const SwContentNode* pCNd(dynamic_cast<SwContentNode*>(GetDep()));
424 if (nullptr == pCNd && IsTextFrame())
425 {
426 pCNd = static_cast<SwTextFrame*>(this)->GetTextNodeFirst();
427 }
428 // IsInDtor shouldn't be happening with ViewShell owning layout
429 assert(nullptr == pCNd || !pCNd->GetDoc().IsInDtor())(static_cast <bool> (nullptr == pCNd || !pCNd->GetDoc
().IsInDtor()) ? void (0) : __assert_fail ("nullptr == pCNd || !pCNd->GetDoc().IsInDtor()"
, "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 429, __extension__ __PRETTY_FUNCTION__))
;
430 if (nullptr != pCNd && !pCNd->GetDoc().IsInDtor())
431 {
432 //Unregister from root if I'm still in turbo there.
433 SwRootFrame *pRoot = getRootFrame();
434 if( pRoot && pRoot->GetTurbo() == this )
435 {
436 pRoot->DisallowTurbo();
437 pRoot->ResetTurbo();
438 }
439 }
440
441 SwFrame::DestroyImpl();
442}
443
444SwContentFrame::~SwContentFrame()
445{
446}
447
448void SwTextFrame::RegisterToNode(SwTextNode & rNode, bool const isForceNodeAsFirst)
449{
450 if (isForceNodeAsFirst && m_pMergedPara)
451 { // nothing registered here, in particular no delete redlines (insert
452 // redline might end on empty node where delete rl starts, should be ok)
453 assert(m_pMergedPara->pFirstNode->GetIndex() + 1 == rNode.GetIndex())(static_cast <bool> (m_pMergedPara->pFirstNode->GetIndex
() + 1 == rNode.GetIndex()) ? void (0) : __assert_fail ("m_pMergedPara->pFirstNode->GetIndex() + 1 == rNode.GetIndex()"
, "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 453, __extension__ __PRETTY_FUNCTION__))
;
454 assert(rNode.GetDoc().getIDocumentRedlineAccess().GetRedlinePos((static_cast <bool> (rNode.GetDoc().getIDocumentRedlineAccess
().GetRedlinePos( *m_pMergedPara->pFirstNode, RedlineType::
Delete) == SwRedlineTable::npos) ? void (0) : __assert_fail (
"rNode.GetDoc().getIDocumentRedlineAccess().GetRedlinePos( *m_pMergedPara->pFirstNode, RedlineType::Delete) == SwRedlineTable::npos"
, "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 455, __extension__ __PRETTY_FUNCTION__))
455 *m_pMergedPara->pFirstNode, RedlineType::Delete) == SwRedlineTable::npos)(static_cast <bool> (rNode.GetDoc().getIDocumentRedlineAccess
().GetRedlinePos( *m_pMergedPara->pFirstNode, RedlineType::
Delete) == SwRedlineTable::npos) ? void (0) : __assert_fail (
"rNode.GetDoc().getIDocumentRedlineAccess().GetRedlinePos( *m_pMergedPara->pFirstNode, RedlineType::Delete) == SwRedlineTable::npos"
, "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 455, __extension__ __PRETTY_FUNCTION__))
;
456 }
457 assert(&rNode != GetDep())(static_cast <bool> (&rNode != GetDep()) ? void (0)
: __assert_fail ("&rNode != GetDep()", "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 457, __extension__ __PRETTY_FUNCTION__))
;
458 assert(!m_pMergedPara(static_cast <bool> (!m_pMergedPara || (m_pMergedPara->
pFirstNode->GetIndex() < rNode.GetIndex()) || (rNode.GetIndex
() + 1 == m_pMergedPara->pFirstNode->GetIndex())) ? void
(0) : __assert_fail ("!m_pMergedPara || (m_pMergedPara->pFirstNode->GetIndex() < rNode.GetIndex()) || (rNode.GetIndex() + 1 == m_pMergedPara->pFirstNode->GetIndex())"
, "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 460, __extension__ __PRETTY_FUNCTION__))
459 || (m_pMergedPara->pFirstNode->GetIndex() < rNode.GetIndex())(static_cast <bool> (!m_pMergedPara || (m_pMergedPara->
pFirstNode->GetIndex() < rNode.GetIndex()) || (rNode.GetIndex
() + 1 == m_pMergedPara->pFirstNode->GetIndex())) ? void
(0) : __assert_fail ("!m_pMergedPara || (m_pMergedPara->pFirstNode->GetIndex() < rNode.GetIndex()) || (rNode.GetIndex() + 1 == m_pMergedPara->pFirstNode->GetIndex())"
, "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 460, __extension__ __PRETTY_FUNCTION__))
460 || (rNode.GetIndex() + 1 == m_pMergedPara->pFirstNode->GetIndex()))(static_cast <bool> (!m_pMergedPara || (m_pMergedPara->
pFirstNode->GetIndex() < rNode.GetIndex()) || (rNode.GetIndex
() + 1 == m_pMergedPara->pFirstNode->GetIndex())) ? void
(0) : __assert_fail ("!m_pMergedPara || (m_pMergedPara->pFirstNode->GetIndex() < rNode.GetIndex()) || (rNode.GetIndex() + 1 == m_pMergedPara->pFirstNode->GetIndex())"
, "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 460, __extension__ __PRETTY_FUNCTION__))
;
461 SwTextNode & rFirstNode(
462 (!isForceNodeAsFirst && m_pMergedPara && m_pMergedPara->pFirstNode->GetIndex() < rNode.GetIndex())
463 ? *m_pMergedPara->pFirstNode
464 : rNode);
465 // sw_redlinehide: use New here, because the only caller also calls lcl_ChangeFootnoteRef
466 m_pMergedPara = sw::CheckParaRedlineMerge(*this, rFirstNode, sw::FrameMode::New);
467 if (!m_pMergedPara)
468 {
469 rNode.Add(this);
470 }
471}
472
473void SwLayoutFrame::DestroyImpl()
474{
475 while (!m_VertPosOrientFramesFor.empty())
476 {
477 SwAnchoredObject *pObj = *m_VertPosOrientFramesFor.begin();
478 pObj->ClearVertPosOrientFrame();
479 }
480
481 assert(m_VertPosOrientFramesFor.empty())(static_cast <bool> (m_VertPosOrientFramesFor.empty()) ?
void (0) : __assert_fail ("m_VertPosOrientFramesFor.empty()"
, "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 481, __extension__ __PRETTY_FUNCTION__))
;
482
483 SwFrame *pFrame = m_pLower;
484
485 if( GetFormat() && !GetFormat()->GetDoc()->IsInDtor() )
486 {
487 while ( pFrame )
488 {
489 //First delete the Objs of the Frame because they can't unregister
490 //from the page after remove.
491 //We don't want to create an endless loop only because one couldn't
492 //unregister.
493
494 while ( pFrame->GetDrawObjs() && pFrame->GetDrawObjs()->size() )
495 {
496 const size_t nCnt = pFrame->GetDrawObjs()->size();
497 // #i28701#
498 SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[0];
499 if (SwFlyFrame* pFlyFrame = dynamic_cast<SwFlyFrame*>(pAnchoredObj))
500 {
501 SwFrame::DestroyFrame(pFlyFrame);
502 assert(!pFrame->GetDrawObjs() || nCnt > pFrame->GetDrawObjs()->size())(static_cast <bool> (!pFrame->GetDrawObjs() || nCnt >
pFrame->GetDrawObjs()->size()) ? void (0) : __assert_fail
("!pFrame->GetDrawObjs() || nCnt > pFrame->GetDrawObjs()->size()"
, "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 502, __extension__ __PRETTY_FUNCTION__))
;
503 }
504 else
505 {
506 pAnchoredObj->ClearTmpConsiderWrapInfluence();
507 SdrObject* pSdrObj = pAnchoredObj->DrawObj();
508 SwDrawContact* pContact =
509 static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
510 OSL_ENSURE( pContact,do { if (true && (!(pContact))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
":" "511" ": "), "%s", "<SwFrame::~SwFrame> - missing contact for drawing object"
); } } while (false)
511 "<SwFrame::~SwFrame> - missing contact for drawing object" )do { if (true && (!(pContact))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
":" "511" ": "), "%s", "<SwFrame::~SwFrame> - missing contact for drawing object"
); } } while (false)
;
512 if ( pContact )
513 {
514 pContact->DisconnectObjFromLayout( pSdrObj );
515 }
516
517 if ( pFrame->GetDrawObjs() &&
518 nCnt == pFrame->GetDrawObjs()->size() )
519 {
520 pFrame->GetDrawObjs()->Remove( *pAnchoredObj );
521 }
522 }
523 }
524 pFrame->RemoveFromLayout();
525 SwFrame::DestroyFrame(pFrame);
526 pFrame = m_pLower;
527 }
528 //Delete the Flys, the last one also deletes the array.
529 while ( GetDrawObjs() && GetDrawObjs()->size() )
530 {
531 const size_t nCnt = GetDrawObjs()->size();
532
533 // #i28701#
534 SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[0];
535 if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr )
536 {
537 SwFrame::DestroyFrame(static_cast<SwFlyFrame*>(pAnchoredObj));
538 assert(!GetDrawObjs() || nCnt > GetDrawObjs()->size())(static_cast <bool> (!GetDrawObjs() || nCnt > GetDrawObjs
()->size()) ? void (0) : __assert_fail ("!GetDrawObjs() || nCnt > GetDrawObjs()->size()"
, "/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
, 538, __extension__ __PRETTY_FUNCTION__))
;
539 }
540 else
541 {
542 SdrObject* pSdrObj = pAnchoredObj->DrawObj();
543 SwDrawContact* pContact =
544 static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
545 OSL_ENSURE( pContact,do { if (true && (!(pContact))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
":" "546" ": "), "%s", "<SwFrame::~SwFrame> - missing contact for drawing object"
); } } while (false)
546 "<SwFrame::~SwFrame> - missing contact for drawing object" )do { if (true && (!(pContact))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
":" "546" ": "), "%s", "<SwFrame::~SwFrame> - missing contact for drawing object"
); } } while (false)
;
547 if ( pContact )
548 {
549 pContact->DisconnectObjFromLayout( pSdrObj );
550 }
551
552 if ( GetDrawObjs() && nCnt == GetDrawObjs()->size() )
553 {
554 GetDrawObjs()->Remove( *pAnchoredObj );
555 }
556 }
557 }
558 }
559 else
560 {
561 while( pFrame )
562 {
563 SwFrame *pNxt = pFrame->GetNext();
564 SwFrame::DestroyFrame(pFrame);
565 pFrame = pNxt;
566 }
567 }
568
569 SwFrame::DestroyImpl();
570}
571
572SwLayoutFrame::~SwLayoutFrame()
573{
574}
575
576/**
577|* The paintarea is the area, in which the content of a frame is allowed
578|* to be displayed. This region could be larger than the printarea (getFramePrintArea())
579|* of the upper, it includes e.g. often the margin of the page.
580|*/
581SwRect SwFrame::GetPaintArea() const
582{
583 // NEW TABLES
584 // Cell frames may not leave their upper:
585 SwRect aRect = IsRowFrame() ? GetUpper()->getFrameArea() : getFrameArea();
586 const bool bVert = IsVertical();
587 SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
588 SwRectFnSet aRectFnSet(this);
589 long nRight = (aRect.*fnRect->fnGetRight)();
590 long nLeft = (aRect.*fnRect->fnGetLeft)();
591 const SwFrame* pTmp = this;
592 bool bLeft = true;
593 bool bRight = true;
594 long nRowSpan = 0;
595 while( pTmp )
596 {
597 if( pTmp->IsCellFrame() && pTmp->GetUpper() &&
598 pTmp->GetUpper()->IsVertical() != pTmp->IsVertical() )
599 nRowSpan = static_cast<const SwCellFrame*>(pTmp)->GetTabBox()->getRowSpan();
600 long nTmpRight = (pTmp->getFrameArea().*fnRect->fnGetRight)();
601 long nTmpLeft = (pTmp->getFrameArea().*fnRect->fnGetLeft)();
602 if( pTmp->IsRowFrame() && nRowSpan > 1 )
603 {
604 const SwFrame* pNxt = pTmp;
605 while( --nRowSpan > 0 && pNxt->GetNext() )
606 pNxt = pNxt->GetNext();
607 if( pTmp->IsVertical() )
608 nTmpLeft = (pNxt->getFrameArea().*fnRect->fnGetLeft)();
609 else
610 {
611 // pTmp is a row frame, but it's not vertical.
612 if (IsVertLRBT())
613 {
614 // This frame cell is OK to expand towards the physical down direction.
615 // Physical down is left.
616 nTmpLeft = (pNxt->getFrameArea().*fnRect->fnGetLeft)();
617 }
618 else
619 {
620 nTmpRight = (pNxt->getFrameArea().*fnRect->fnGetRight)();
621 }
622 }
623 }
624 OSL_ENSURE( pTmp, "GetPaintArea lost in time and space" )do { if (true && (!(pTmp))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/ssfrm.cxx"
":" "624" ": "), "%s", "GetPaintArea lost in time and space"
); } } while (false)
;
625 if( pTmp->IsPageFrame() || pTmp->IsFlyFrame() ||
626 pTmp->IsCellFrame() || pTmp->IsRowFrame() || //nobody leaves a table!
627 pTmp->IsRootFrame() )
628 {
629 if( bLeft || aRectFnSet.XDiff(nTmpLeft, nLeft) > 0 )
630 nLeft = nTmpLeft;
631 if( bRight || aRectFnSet.XDiff(nRight, nTmpRight) > 0 )
632 nRight = nTmpRight;
633 if( pTmp->IsPageFrame() || pTmp->IsFlyFrame() || pTmp->IsRootFrame() )
634 break;
635 bLeft = false;
636 bRight = false;
637 }
638 else if( pTmp->IsColumnFrame() ) // nobody enters neighbour columns
639 {
640 bool bR2L = pTmp->IsRightToLeft();
641 // the first column has _no_ influence to the left range
642 if( bR2L ? pTmp->GetNext() : pTmp->GetPrev() )
643 {
644 if( bLeft || aRectFnSet.XDiff(nTmpLeft, nLeft) > 0 )
645 nLeft = nTmpLeft;
646 bLeft = false;
647 }
648 // the last column has _no_ influence to the right range
649 if( bR2L ? pTmp->GetPrev() : pTmp->GetNext() )
650 {
651 if( bRight || aRectFnSet.XDiff(nRight, nTmpRight) > 0 )
652 nRight = nTmpRight;
653 bRight = false;
654 }
655 }
656 else if( bVert && pTmp->IsBodyFrame() )
657 {
658 // Header and footer frames have always horizontal direction and
659 // limit the body frame.
660 // A previous frame of a body frame must be a header,
661 // the next frame of a body frame may be a footnotecontainer or
662 // a footer. The footnotecontainer has the same direction like
663 // the body frame.
664 if( pTmp->GetPrev() && ( bLeft || aRectFnSet.XDiff(nTmpLeft, nLeft) > 0 ) )
665 {
666 nLeft = nTmpLeft;
667 bLeft = false;
668 }
669 if( pTmp->GetNext() &&
670 ( pTmp->GetNext()->IsFooterFrame() || pTmp->GetNext()->GetNext() )
671 && ( bRight || aRectFnSet.XDiff(nRight, nTmpRight) > 0 ) )
672 {
673 nRight = nTmpRight;
674 bRight = false;
675 }
676 }
677 pTmp = pTmp->GetUpper();
678 }
679 (aRect.*fnRect->fnSetLeft)( nLeft );
680 (aRect.*fnRect->fnSetRight)( nRight );
681 return aRect;
682}
683
684/**
685|* The unionframe is the framearea (getFrameArea()) of a frame expanded by the
686|* printarea, if there's a negative margin at the left or right side.
687|*/
688SwRect SwFrame::UnionFrame( bool bBorder ) const
689{
690 bool bVert = IsVertical();
691 SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
692 long nLeft = (getFrameArea().*fnRect->fnGetLeft)();
693 long nWidth = (getFrameArea().*fnRect->fnGetWidth)();
694 long nPrtLeft = (getFramePrintArea().*fnRect->fnGetLeft)();
695 long nPrtWidth = (getFramePrintArea().*fnRect->fnGetWidth)();
696 SwRectFnSet aRectFnSet(this);
697 if (aRectFnSet.XInc(nPrtLeft, nPrtWidth) > nWidth)
698 nWidth = nPrtLeft + nPrtWidth;
699 if( nPrtLeft < 0 )
700 {
701 nLeft += nPrtLeft;
702 nWidth -= nPrtLeft;
703 }
704 SwTwips nRight = aRectFnSet.XInc(nLeft, nWidth);
705 long nAdd = 0;
706 if( bBorder )
707 {
708 SwBorderAttrAccess aAccess( SwFrame::GetCache(), this );
709 const SwBorderAttrs &rAttrs = *aAccess.Get();
710 const SvxBoxItem &rBox = rAttrs.GetBox();
711 if ( rBox.GetLeft() )
712 nLeft -= rBox.CalcLineSpace( SvxBoxItemLine::LEFT );
713 else
714 nLeft -= rBox.GetDistance( SvxBoxItemLine::LEFT ) + 1;
715 if ( rBox.GetRight() )
716 nAdd += rBox.CalcLineSpace( SvxBoxItemLine::RIGHT );
717 else
718 nAdd += rBox.GetDistance( SvxBoxItemLine::RIGHT ) + 1;
719 if( rAttrs.GetShadow().GetLocation() != SvxShadowLocation::NONE )
720 {
721 const SvxShadowItem &rShadow = rAttrs.GetShadow();
722 nLeft -= rShadow.CalcShadowSpace( SvxShadowItemSide::LEFT );
723 nAdd += rShadow.CalcShadowSpace( SvxShadowItemSide::RIGHT );
724 }
725 }
726 if( IsTextFrame() && static_cast<const SwTextFrame*>(this)->HasPara() )
727 {
728 long nTmp = static_cast<const SwTextFrame*>(this)->HangingMargin();
729 if( nTmp > nAdd )
730 nAdd = nTmp;
731 }
732 nWidth = aRectFnSet.XDiff(aRectFnSet.XInc(nRight, nAdd), nLeft);
733 SwRect aRet( getFrameArea() );
734 (aRet.*fnRect->fnSetLeft)(nLeft);
735 (aRet.*fnRect->fnSetWidth)( nWidth );
736 return aRet;
737}
738
739/* vim:set shiftwidth=4 softtabstop=4 expandtab: */