Bug Summary

File:home/maarten/src/libreoffice/core/sw/source/core/layout/objectformatter.cxx
Warning:line 175, column 5
Dereference of null pointer

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 objectformatter.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/objectformatter.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 "objectformattertxtfrm.hxx"
21#include "objectformatterlayfrm.hxx"
22#include <anchoreddrawobject.hxx>
23#include <sortedobjs.hxx>
24#include <rootfrm.hxx>
25#include <pagefrm.hxx>
26#include <flyfrms.hxx>
27#include <txtfrm.hxx>
28#include <layact.hxx>
29#include <IDocumentSettingAccess.hxx>
30
31#include <vector>
32
33// --> #i26945# - Additionally the type of the anchor text frame
34// is collected - by type is meant 'master' or 'follow'.
35class SwPageNumAndTypeOfAnchors
36{
37 private:
38 struct tEntry
39 {
40 SwAnchoredObject* mpAnchoredObj;
41 sal_uInt32 mnPageNumOfAnchor;
42 bool mbAnchoredAtMaster;
43 };
44
45 std::vector< tEntry > maObjList;
46
47 public:
48 SwPageNumAndTypeOfAnchors()
49 {
50 }
51
52 void Collect( SwAnchoredObject& _rAnchoredObj )
53 {
54 tEntry aNewEntry;
55 aNewEntry.mpAnchoredObj = &_rAnchoredObj;
56 // #i33751#, #i34060# - method <GetPageFrameOfAnchor()>
57 // is replaced by method <FindPageFrameOfAnchor()>. It's return value
58 // have to be checked.
59 SwPageFrame* pPageFrameOfAnchor = _rAnchoredObj.FindPageFrameOfAnchor();
60 if ( pPageFrameOfAnchor )
61 {
62 aNewEntry.mnPageNumOfAnchor = pPageFrameOfAnchor->GetPhyPageNum();
63 }
64 else
65 {
66 aNewEntry.mnPageNumOfAnchor = 0;
67 }
68 // --> #i26945# - collect type of anchor
69 SwTextFrame* pAnchorCharFrame = _rAnchoredObj.FindAnchorCharFrame();
70 if ( pAnchorCharFrame )
71 {
72 aNewEntry.mbAnchoredAtMaster = !pAnchorCharFrame->IsFollow();
73 }
74 else
75 {
76 aNewEntry.mbAnchoredAtMaster = true;
77 }
78 maObjList.push_back( aNewEntry );
79 }
80
81 SwAnchoredObject* operator[]( sal_uInt32 _nIndex )
82 {
83 return maObjList[_nIndex].mpAnchoredObj;
84 }
85
86 sal_uInt32 GetPageNum( sal_uInt32 _nIndex ) const
87 {
88 return maObjList[_nIndex].mnPageNumOfAnchor;
89 }
90
91 // --> #i26945#
92 bool AnchoredAtMaster( sal_uInt32 _nIndex )
93 {
94 return maObjList[_nIndex].mbAnchoredAtMaster;
95 }
96
97 sal_uInt32 Count() const
98 {
99 return maObjList.size();
100 }
101};
102
103SwObjectFormatter::SwObjectFormatter( const SwPageFrame& _rPageFrame,
104 SwLayAction* _pLayAction,
105 const bool _bCollectPgNumOfAnchors )
106 : mrPageFrame( _rPageFrame ),
107 mbConsiderWrapOnObjPos( _rPageFrame.GetFormat()->getIDocumentSettingAccess().get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION) ),
108 mpLayAction( _pLayAction ),
109 // --> #i26945#
110 mpPgNumAndTypeOfAnchors( _bCollectPgNumOfAnchors ? new SwPageNumAndTypeOfAnchors() : nullptr )
111{
112}
113
114SwObjectFormatter::~SwObjectFormatter()
115{
116}
117
118std::unique_ptr<SwObjectFormatter> SwObjectFormatter::CreateObjFormatter(
119 SwFrame& _rAnchorFrame,
120 const SwPageFrame& _rPageFrame,
121 SwLayAction* _pLayAction )
122{
123 std::unique_ptr<SwObjectFormatter> pObjFormatter;
124 if ( _rAnchorFrame.IsTextFrame() )
125 {
126 pObjFormatter = SwObjectFormatterTextFrame::CreateObjFormatter(
127 static_cast<SwTextFrame&>(_rAnchorFrame),
128 _rPageFrame, _pLayAction );
129 }
130 else if ( _rAnchorFrame.IsLayoutFrame() )
131 {
132 pObjFormatter = SwObjectFormatterLayFrame::CreateObjFormatter(
133 static_cast<SwLayoutFrame&>(_rAnchorFrame),
134 _rPageFrame, _pLayAction );
135 }
136 else
137 {
138 OSL_FAIL( "<SwObjectFormatter::CreateObjFormatter(..)> - unexpected type of anchor frame" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/objectformatter.cxx"
":" "138" ": "), "%s", "<SwObjectFormatter::CreateObjFormatter(..)> - unexpected type of anchor frame"
); } } while (false)
;
139 }
140
141 return pObjFormatter;
142}
143
144/** method to format all floating screen objects at the given anchor frame
145*/
146bool SwObjectFormatter::FormatObjsAtFrame( SwFrame& _rAnchorFrame,
147 const SwPageFrame& _rPageFrame,
148 SwLayAction* _pLayAction )
149{
150 bool bSuccess( true );
151
152 // create corresponding object formatter
153 std::unique_ptr<SwObjectFormatter> pObjFormatter =
154 SwObjectFormatter::CreateObjFormatter( _rAnchorFrame, _rPageFrame, _pLayAction );
155
156 if ( pObjFormatter )
157 {
158 // format anchored floating screen objects
159 bSuccess = pObjFormatter->DoFormatObjs();
160 }
161
162 return bSuccess;
163}
164
165/** method to format a given floating screen object
166*/
167bool SwObjectFormatter::FormatObj( SwAnchoredObject& _rAnchoredObj,
168 SwFrame* _pAnchorFrame,
169 const SwPageFrame* _pPageFrame )
170{
171 bool bSuccess( true );
172
173 OSL_ENSURE( _pAnchorFrame || _rAnchoredObj.GetAnchorFrame(),do { if (true && (!(_pAnchorFrame || _rAnchoredObj.GetAnchorFrame
()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/objectformatter.cxx"
":" "174" ": "), "%s", "<SwObjectFormatter::FormatObj(..)> - missing anchor frame"
); } } while (false)
1
Assuming '_pAnchorFrame' is null
2
Assuming the condition is true
3
Taking true branch
4
Loop condition is false. Exiting loop
174 "<SwObjectFormatter::FormatObj(..)> - missing anchor frame" )do { if (true && (!(_pAnchorFrame || _rAnchoredObj.GetAnchorFrame
()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/objectformatter.cxx"
":" "174" ": "), "%s", "<SwObjectFormatter::FormatObj(..)> - missing anchor frame"
); } } while (false)
;
175 SwFrame& rAnchorFrame = _pAnchorFrame
4.1
'_pAnchorFrame' is null
? *_pAnchorFrame : *(_rAnchoredObj.AnchorFrame());
5
'?' condition is false
6
Dereference of null pointer
176
177 OSL_ENSURE( _pPageFrame || rAnchorFrame.FindPageFrame(),do { if (true && (!(_pPageFrame || rAnchorFrame.FindPageFrame
()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/objectformatter.cxx"
":" "178" ": "), "%s", "<SwObjectFormatter::FormatObj(..)> - missing page frame"
); } } while (false)
178 "<SwObjectFormatter::FormatObj(..)> - missing page frame" )do { if (true && (!(_pPageFrame || rAnchorFrame.FindPageFrame
()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/objectformatter.cxx"
":" "178" ": "), "%s", "<SwObjectFormatter::FormatObj(..)> - missing page frame"
); } } while (false)
;
179 const SwPageFrame& rPageFrame = _pPageFrame ? *_pPageFrame : *(rAnchorFrame.FindPageFrame());
180
181 // create corresponding object formatter
182 std::unique_ptr<SwObjectFormatter> pObjFormatter =
183 SwObjectFormatter::CreateObjFormatter( rAnchorFrame, rPageFrame, nullptr/*_pLayAction*/ );
184
185 if ( pObjFormatter )
186 {
187 // format given floating screen object
188 // --> #i40147# - check for moved forward anchor frame
189 bSuccess = pObjFormatter->DoFormatObj( _rAnchoredObj, true );
190 }
191
192 return bSuccess;
193}
194
195/** helper method for method <FormatObj_(..)> - performs the intrinsic format
196 of the layout of the given layout frame and all its lower layout frames.
197
198 #i28701#
199 IMPORTANT NOTE:
200 Method corresponds to methods <SwLayAction::FormatLayoutFly(..)> and
201 <SwLayAction::FormatLayout(..)>. Thus, its code for the formatting have
202 to be synchronised.
203*/
204void SwObjectFormatter::FormatLayout_( SwLayoutFrame& _rLayoutFrame )
205{
206 _rLayoutFrame.Calc(_rLayoutFrame.getRootFrame()->GetCurrShell()->GetOut());
207
208 SwFrame* pLowerFrame = _rLayoutFrame.Lower();
209 while ( pLowerFrame )
210 {
211 if ( pLowerFrame->IsLayoutFrame() )
212 {
213 FormatLayout_( *static_cast<SwLayoutFrame*>(pLowerFrame) );
214 }
215 pLowerFrame = pLowerFrame->GetNext();
216 }
217}
218
219/** helper method for method <FormatObj_(..)> - performs the intrinsic
220 format of the content of the given floating screen object.
221
222 #i28701#
223*/
224void SwObjectFormatter::FormatObjContent( SwAnchoredObject& _rAnchoredObj )
225{
226 if ( dynamic_cast<const SwFlyFrame*>( &_rAnchoredObj) == nullptr )
227 {
228 // only Writer fly frames have content
229 return;
230 }
231
232 SwFlyFrame& rFlyFrame = static_cast<SwFlyFrame&>(_rAnchoredObj);
233 SwContentFrame* pContent = rFlyFrame.ContainsContent();
234
235 while ( pContent )
236 {
237 // format content
238 pContent->OptCalc();
239
240 // format floating screen objects at content text frame
241 // #i23129#, #i36347# - pass correct page frame to
242 // the object formatter
243 if ( pContent->IsTextFrame() &&
244 !SwObjectFormatter::FormatObjsAtFrame( *pContent,
245 *(pContent->FindPageFrame()),
246 GetLayAction() ) )
247 {
248 // restart format with first content
249 pContent = rFlyFrame.ContainsContent();
250 continue;
251 }
252
253 // continue with next content
254 pContent = pContent->GetNextContentFrame();
255 }
256}
257
258/** performs the intrinsic format of a given floating screen object and its content.
259
260 #i28701#
261*/
262void SwObjectFormatter::FormatObj_( SwAnchoredObject& _rAnchoredObj )
263{
264 // collect anchor object and its 'anchor' page number, if requested
265 if ( mpPgNumAndTypeOfAnchors )
266 {
267 mpPgNumAndTypeOfAnchors->Collect( _rAnchoredObj );
268 }
269
270 if ( dynamic_cast<const SwFlyFrame*>( &_rAnchoredObj) != nullptr )
271 {
272 SwFlyFrame& rFlyFrame = static_cast<SwFlyFrame&>(_rAnchoredObj);
273 // --> #i34753# - reset flag, which prevents a positioning
274 if ( rFlyFrame.IsFlyLayFrame() )
275 {
276 static_cast<SwFlyLayFrame&>(rFlyFrame).SetNoMakePos( false );
277 }
278
279 // #i81146# new loop control
280 int nLoopControlRuns = 0;
281 const int nLoopControlMax = 15;
282
283 do {
284 if ( mpLayAction )
285 {
286 mpLayAction->FormatLayoutFly( &rFlyFrame );
287 // --> consider, if the layout action
288 // has to be restarted due to a delete of a page frame.
289 if ( mpLayAction->IsAgain() )
290 {
291 break;
292 }
293 }
294 else
295 {
296 FormatLayout_( rFlyFrame );
297 }
298 // --> #i34753# - prevent further positioning, if
299 // to-page|to-fly anchored Writer fly frame is already clipped.
300 if ( rFlyFrame.IsFlyLayFrame() && rFlyFrame.IsClipped() )
301 {
302 static_cast<SwFlyLayFrame&>(rFlyFrame).SetNoMakePos( true );
303 }
304 // #i23129#, #i36347# - pass correct page frame
305 // to the object formatter
306 SwObjectFormatter::FormatObjsAtFrame( rFlyFrame,
307 *(rFlyFrame.FindPageFrame()),
308 mpLayAction );
309 if ( mpLayAction )
310 {
311 mpLayAction->FormatFlyContent( &rFlyFrame );
312 // --> consider, if the layout action
313 // has to be restarted due to a delete of a page frame.
314 if ( mpLayAction->IsAgain() )
315 {
316 break;
317 }
318 }
319 else
320 {
321 FormatObjContent( rFlyFrame );
322 }
323
324 if ( ++nLoopControlRuns >= nLoopControlMax )
325 {
326 OSL_FAIL( "LoopControl in SwObjectFormatter::FormatObj_: Stage 3!!!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/objectformatter.cxx"
":" "326" ": "), "%s", "LoopControl in SwObjectFormatter::FormatObj_: Stage 3!!!"
); } } while (false)
;
327 rFlyFrame.ValidateThisAndAllLowers( 2 );
328 nLoopControlRuns = 0;
329 }
330
331 // --> #i57917#
332 // stop formatting of anchored object, if restart of layout process is requested.
333 } while ( !rFlyFrame.isFrameAreaDefinitionValid() &&
334 !_rAnchoredObj.RestartLayoutProcess() &&
335 rFlyFrame.GetAnchorFrame() == &GetAnchorFrame() );
336 }
337 else if ( dynamic_cast<const SwAnchoredDrawObject*>( &_rAnchoredObj) != nullptr )
338 {
339 _rAnchoredObj.MakeObjPos();
340 }
341}
342
343/** invokes the intrinsic format method for all floating screen objects,
344 anchored at anchor frame on the given page frame
345
346 #i28701#
347 #i26945# - for format of floating screen objects for
348 follow text frames, the 'master' text frame is passed to the method.
349 Thus, the objects, whose anchor character is inside the follow text
350 frame can be formatted.
351*/
352bool SwObjectFormatter::FormatObjsAtFrame_( SwTextFrame* _pMasterTextFrame )
353{
354 // --> #i26945#
355 SwFrame* pAnchorFrame( nullptr );
356 if ( GetAnchorFrame().IsTextFrame() &&
357 static_cast<SwTextFrame&>(GetAnchorFrame()).IsFollow() &&
358 _pMasterTextFrame )
359 {
360 pAnchorFrame = _pMasterTextFrame;
361 }
362 else
363 {
364 pAnchorFrame = &GetAnchorFrame();
365 }
366 if ( !pAnchorFrame->GetDrawObjs() )
367 {
368 // nothing to do, if no floating screen object is registered at the anchor frame.
369 return true;
370 }
371
372 bool bSuccess( true );
373
374 for ( size_t i = 0; i < pAnchorFrame->GetDrawObjs()->size(); ++i )
375 {
376 SwAnchoredObject* pAnchoredObj = (*pAnchorFrame->GetDrawObjs())[i];
377
378 // check, if object's anchor is on the given page frame or
379 // object is registered at the given page frame.
380 // --> #i26945# - check, if the anchor character of the
381 // anchored object is located in a follow text frame. If this anchor
382 // follow text frame differs from the given anchor frame, the given
383 // anchor frame is a 'master' text frame of the anchor follow text frame.
384 // If the anchor follow text frame is in the same body as its 'master'
385 // text frame, do not format the anchored object.
386 // E.g., this situation can occur during the table row splitting algorithm.
387 SwTextFrame* pAnchorCharFrame = pAnchoredObj->FindAnchorCharFrame();
388 const bool bAnchoredAtFollowInSameBodyAsMaster =
389 pAnchorCharFrame && pAnchorCharFrame->IsFollow() &&
390 pAnchorCharFrame != pAnchoredObj->GetAnchorFrame() &&
391 pAnchorCharFrame->FindBodyFrame() ==
392 static_cast<SwTextFrame*>(pAnchoredObj->AnchorFrame())->FindBodyFrame();
393 if ( bAnchoredAtFollowInSameBodyAsMaster )
394 {
395 continue;
396 }
397 // #i33751#, #i34060# - method <GetPageFrameOfAnchor()>
398 // is replaced by method <FindPageFrameOfAnchor()>. It's return value
399 // have to be checked.
400 SwPageFrame* pPageFrameOfAnchor = pAnchoredObj->FindPageFrameOfAnchor();
401 OSL_ENSURE( pPageFrameOfAnchor,do { if (true && (!(pPageFrameOfAnchor))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/objectformatter.cxx"
":" "402" ": "), "%s", "<SwObjectFormatter::FormatObjsAtFrame_()> - missing page frame."
); } } while (false)
402 "<SwObjectFormatter::FormatObjsAtFrame_()> - missing page frame." )do { if (true && (!(pPageFrameOfAnchor))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/layout/objectformatter.cxx"
":" "402" ": "), "%s", "<SwObjectFormatter::FormatObjsAtFrame_()> - missing page frame."
); } } while (false)
;
403 // --> #i26945#
404 if ( pPageFrameOfAnchor && pPageFrameOfAnchor == &mrPageFrame )
405 {
406 // if format of object fails, stop formatting and pass fail to
407 // calling method via the return value.
408 if ( !DoFormatObj( *pAnchoredObj ) )
409 {
410 bSuccess = false;
411 break;
412 }
413
414 // considering changes at <pAnchorFrame->GetDrawObjs()> during
415 // format of the object.
416 if ( !pAnchorFrame->GetDrawObjs() ||
417 i > pAnchorFrame->GetDrawObjs()->size() )
418 {
419 break;
420 }
421 else
422 {
423 const size_t nActPosOfObj =
424 pAnchorFrame->GetDrawObjs()->ListPosOf( *pAnchoredObj );
425 if ( nActPosOfObj == pAnchorFrame->GetDrawObjs()->size() ||
426 nActPosOfObj > i )
427 {
428 --i;
429 }
430 else if ( nActPosOfObj < i )
431 {
432 i = nActPosOfObj;
433 }
434 }
435 }
436 } // end of loop on <pAnchorFrame->.GetDrawObjs()>
437
438 return bSuccess;
439}
440
441/** accessor to collected anchored object
442
443 #i28701#
444*/
445SwAnchoredObject* SwObjectFormatter::GetCollectedObj( const sal_uInt32 _nIndex )
446{
447 return mpPgNumAndTypeOfAnchors ? (*mpPgNumAndTypeOfAnchors)[_nIndex] : nullptr;
448}
449
450/** accessor to 'anchor' page number of collected anchored object
451
452 #i28701#
453*/
454sal_uInt32 SwObjectFormatter::GetPgNumOfCollected( const sal_uInt32 _nIndex )
455{
456 return mpPgNumAndTypeOfAnchors ? mpPgNumAndTypeOfAnchors->GetPageNum(_nIndex) : 0;
457}
458
459/** accessor to 'anchor' type of collected anchored object
460
461 #i26945#
462*/
463bool SwObjectFormatter::IsCollectedAnchoredAtMaster( const sal_uInt32 _nIndex )
464{
465 return mpPgNumAndTypeOfAnchors == nullptr
466 || mpPgNumAndTypeOfAnchors->AnchoredAtMaster(_nIndex);
467}
468
469/** accessor to total number of collected anchored objects
470
471 #i28701#
472*/
473sal_uInt32 SwObjectFormatter::CountOfCollected()
474{
475 return mpPgNumAndTypeOfAnchors ? mpPgNumAndTypeOfAnchors->Count() : 0;
476}
477
478/* vim:set shiftwidth=4 softtabstop=4 expandtab: */