Bug Summary

File:home/maarten/src/libreoffice/core/sd/source/ui/func/fuexpand.cxx
Warning:line 107, column 28
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 fuexpand.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 -isystem /usr/include/dbus-1.0 -isystem /usr/lib64/dbus-1.0/include -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 SD_DLLIMPLEMENTATION -D SDUI_DLL_NAME="libsduilo.so" -D SYSTEM_LIBXML -D ENABLE_SDREMOTE -D ENABLE_SDREMOTE_BLUETOOTH -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/external/bluez_bluetooth/inc -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/sd/inc -I /home/maarten/src/libreoffice/core/sd/source/ui/inc -I /home/maarten/src/libreoffice/core/sd/source/ui/slidesorter/inc -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/sd/sdi -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/oox/generated -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -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/sd/source/ui/func/fuexpand.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 <fuexpand.hxx>
21
22#include <sfx2/viewfrm.hxx>
23#include <svx/svdotext.hxx>
24#include <svx/xfillit0.hxx>
25#include <svx/xlineit0.hxx>
26#include <svx/svdundo.hxx>
27#include <editeng/outlobj.hxx>
28#include <svx/svdetc.hxx>
29#include <xmloff/autolayout.hxx>
30#include <sal/log.hxx>
31
32#include <app.hrc>
33#include <strings.hrc>
34#include <pres.hxx>
35#include <View.hxx>
36#include <sdpage.hxx>
37#include <Outliner.hxx>
38#include <drawdoc.hxx>
39#include <ViewShell.hxx>
40#include <sdresid.hxx>
41#include <sdmod.hxx>
42#include <sfx2/dispatch.hxx>
43#include <editeng/eeitem.hxx>
44
45using namespace com::sun::star;
46
47namespace sd {
48
49
50FuExpandPage::FuExpandPage (
51 ViewShell* pViewSh,
52 ::sd::Window* pWin,
53 ::sd::View* pView,
54 SdDrawDocument* pDoc,
55 SfxRequest& rReq)
56 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
57{
58}
59
60rtl::Reference<FuPoor> FuExpandPage::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
61{
62 rtl::Reference<FuPoor> xFunc( new FuExpandPage( pViewSh, pWin, pView, pDoc, rReq ) );
63 xFunc->DoExecute(rReq);
64 return xFunc;
65}
66
67void FuExpandPage::DoExecute( SfxRequest& )
68{
69 if ( mpView && mpView->IsTextEdit() )
1
Assuming field 'mpView' is null
70 mpView->SdrEndTextEdit();
71
72 // find selected page (only standard pages)
73 SdPage* pActualPage = nullptr;
74 sal_uInt16 i = 0;
75 sal_uInt16 nCount = mpDoc->GetSdPageCount(PageKind::Standard);
76
77 while (!pActualPage
1.1
'pActualPage' is null
&& i < nCount)
2
Assuming 'i' is < 'nCount'
3
Loop condition is true. Entering loop body
6
Assuming 'pActualPage' is non-null
78 {
79 if (mpDoc->GetSdPage(i, PageKind::Standard)->IsSelected())
4
Assuming the condition is true
5
Taking true branch
80 {
81 pActualPage = mpDoc->GetSdPage(i, PageKind::Standard);
82 }
83
84 i++;
85 }
86
87 if (!pActualPage
6.1
'pActualPage' is non-null
)
7
Taking false branch
88 return;
89
90 SdOutliner aOutliner( mpDoc, OutlinerMode::OutlineObject );
91 aOutliner.SetUpdateMode(false);
92 aOutliner.EnableUndo(false);
93
94 if (mpDocSh)
8
Assuming field 'mpDocSh' is null
9
Taking false branch
95 aOutliner.SetRefDevice( SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->GetVirtualRefDevice() );
96
97 aOutliner.SetDefTab( mpDoc->GetDefaultTabulator() );
98 aOutliner.SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mpDoc->GetStyleSheetPool()));
99
100 SdrLayerIDSet aVisibleLayers = pActualPage->TRG_GetMasterPageVisibleLayers();
101 sal_uInt16 nActualPageNum = pActualPage->GetPageNum();
102 SdPage* pActualNotesPage = static_cast<SdPage*>(mpDoc->GetPage(nActualPageNum + 1));
103 SdrTextObj* pActualOutline = static_cast<SdrTextObj*>(pActualPage->GetPresObj(PresObjKind::Outline));
104
105 if (pActualOutline)
10
Assuming 'pActualOutline' is non-null
11
Taking true branch
106 {
107 const bool bUndo = mpView->IsUndoEnabled();
12
Called C++ object pointer is null
108
109 if( bUndo )
110 mpView->BegUndo(SdResId(STR_UNDO_EXPAND_PAGEreinterpret_cast<char const *>("STR_UNDO_EXPAND_PAGE" "\004"
u8"Expand Slide")
));
111
112 // set current structuring-object into outliner
113 OutlinerParaObject* pParaObj = pActualOutline->GetOutlinerParaObject();
114 aOutliner.SetText(*pParaObj);
115
116 // remove hard paragraph- and character attributes
117 SfxItemSet aEmptyEEAttr(mpDoc->GetPool(), svl::Items<EE_ITEMS_START, EE_ITEMS_END>{});
118 sal_Int32 nParaCount1 = aOutliner.GetParagraphCount();
119
120 for (sal_Int32 nPara = 0; nPara < nParaCount1; nPara++)
121 {
122 aOutliner.RemoveCharAttribs(nPara);
123 aOutliner.SetParaAttribs(nPara, aEmptyEEAttr);
124 }
125
126 sal_uInt16 nPos = 2;
127 Paragraph* pPara = aOutliner.GetParagraph( 0 );
128
129 while (pPara)
130 {
131 sal_Int32 nParaPos = aOutliner.GetAbsPos( pPara );
132 sal_Int16 nDepth = aOutliner.GetDepth( nParaPos );
133 if ( nDepth == 0 )
134 {
135 // page with title & structuring!
136 SdPage* pPage = mpDoc->AllocSdPage(false);
137 pPage->SetSize(pActualPage->GetSize() );
138 pPage->SetBorder(pActualPage->GetLeftBorder(),
139 pActualPage->GetUpperBorder(),
140 pActualPage->GetRightBorder(),
141 pActualPage->GetLowerBorder() );
142 pPage->SetName(OUString());
143
144 // insert page after current page
145 mpDoc->InsertPage(pPage, nActualPageNum + nPos);
146 nPos++;
147
148 if( bUndo )
149 mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pPage));
150
151 // use MasterPage of the current page
152 pPage->TRG_SetMasterPage(pActualPage->TRG_GetMasterPage());
153 pPage->SetLayoutName(pActualPage->GetLayoutName());
154 pPage->SetAutoLayout(AUTOLAYOUT_TITLE_CONTENT, true);
155 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
156
157 // notes-page
158 SdPage* pNotesPage = mpDoc->AllocSdPage(false);
159 pNotesPage->SetSize(pActualNotesPage->GetSize());
160 pNotesPage->SetBorder(pActualNotesPage->GetLeftBorder(),
161 pActualNotesPage->GetUpperBorder(),
162 pActualNotesPage->GetRightBorder(),
163 pActualNotesPage->GetLowerBorder() );
164 pNotesPage->SetPageKind(PageKind::Notes);
165 pNotesPage->SetName(OUString());
166
167 // insert page after current page
168 mpDoc->InsertPage(pNotesPage, nActualPageNum + nPos);
169 nPos++;
170
171 if( bUndo )
172 mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
173
174 // use MasterPage of the current page
175 pNotesPage->TRG_SetMasterPage(pActualNotesPage->TRG_GetMasterPage());
176 pNotesPage->SetLayoutName(pActualNotesPage->GetLayoutName());
177 pNotesPage->SetAutoLayout(pActualNotesPage->GetAutoLayout(), true);
178 pNotesPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
179
180 // create title text objects
181 SdrTextObj* pTextObj = static_cast<SdrTextObj*>(pPage->GetPresObj(PresObjKind::Title));
182 SAL_WARN_IF(!pTextObj, "sd.core", "worrying lack of PresObjKind::Title object")do { if (true && (!pTextObj)) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "sd.core")) { case SAL_DETAIL_LOG_ACTION_IGNORE
: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail
::getResult( ::sal::detail::StreamStart() << "worrying lack of PresObjKind::Title object"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd.core"
), ("/home/maarten/src/libreoffice/core/sd/source/ui/func/fuexpand.cxx"
":" "182" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "worrying lack of PresObjKind::Title object"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "worrying lack of PresObjKind::Title object"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd.core"), ("/home/maarten/src/libreoffice/core/sd/source/ui/func/fuexpand.cxx"
":" "182" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "worrying lack of PresObjKind::Title object") == 1
) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd.core"
), ("/home/maarten/src/libreoffice/core/sd/source/ui/func/fuexpand.cxx"
":" "182" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "worrying lack of PresObjKind::Title object"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "worrying lack of PresObjKind::Title object"; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd.core"), ("/home/maarten/src/libreoffice/core/sd/source/ui/func/fuexpand.cxx"
":" "182" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
183 if (!pTextObj)
184 continue;
185
186 std::unique_ptr<OutlinerParaObject> pOutlinerParaObject = aOutliner.CreateParaObject( nParaPos, 1);
187 pOutlinerParaObject->SetOutlinerMode(OutlinerMode::TitleObject);
188
189 if( pOutlinerParaObject->GetDepth(0) != -1 )
190 {
191 std::unique_ptr<SdrOutliner> pTempOutl = SdrMakeOutliner(OutlinerMode::TitleObject, *mpDoc);
192
193 pTempOutl->SetText( *pOutlinerParaObject );
194
195 pOutlinerParaObject.reset();
196
197 pTempOutl->SetDepth( pTempOutl->GetParagraph( 0 ), -1 );
198
199 pOutlinerParaObject = pTempOutl->CreateParaObject();
200 }
201
202 pTextObj->SetOutlinerParaObject(std::move(pOutlinerParaObject));
203
204 pTextObj->SetEmptyPresObj(false);
205
206 SfxStyleSheet* pSheet = pPage->GetStyleSheetForPresObj(PresObjKind::Title);
207 pTextObj->NbcSetStyleSheet(pSheet, false);
208
209 SdrTextObj* pOutlineObj = nullptr;
210 sal_Int32 nChildCount = aOutliner.GetChildCount(pPara);
211 if (nChildCount > 0)
212 pOutlineObj = static_cast<SdrTextObj*>( pPage->GetPresObj(PresObjKind::Outline) );
213 if (pOutlineObj)
214 {
215 // create structuring text objects
216 std::unique_ptr<OutlinerParaObject> pOPO = aOutliner.CreateParaObject(++nParaPos, nChildCount);
217
218 std::unique_ptr<SdrOutliner> pTempOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc);
219 pTempOutl->SetText( *pOPO );
220
221 sal_Int32 nParaCount2 = pTempOutl->GetParagraphCount();
222 sal_Int32 nPara;
223 for( nPara = 0; nPara < nParaCount2; nPara++ )
224 {
225 pTempOutl->SetDepth (
226 pTempOutl->GetParagraph( nPara ),
227 pTempOutl->GetDepth( nPara ) - 1);
228 }
229
230 pOPO = pTempOutl->CreateParaObject();
231 pTempOutl.reset();
232
233 pOutlineObj->SetOutlinerParaObject( std::move(pOPO) );
234 pOutlineObj->SetEmptyPresObj(false);
235
236 // remove hard attributes (Flag to sal_True)
237 SfxItemSet aAttr(mpDoc->GetPool());
238 aAttr.Put(XLineStyleItem(drawing::LineStyle_NONE));
239 aAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
240 pOutlineObj->SetMergedItemSet(aAttr);
241 }
242 }
243
244 pPara = aOutliner.GetParagraph( ++nParaPos );
245 }
246
247 if( bUndo )
248 mpView->EndUndo();
249 }
250
251 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_DELETE_PAGE(27000 +80), SfxCallMode::SYNCHRON | SfxCallMode::RECORD);
252}
253
254} // end of namespace sd
255
256/* vim:set shiftwidth=4 softtabstop=4 expandtab: */