Bug Summary

File:home/maarten/src/libreoffice/core/sd/source/ui/func/fuprlout.cxx
Warning:line 93, column 65
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 fuprlout.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/fuprlout.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 <fuprlout.hxx>
21#include <sfx2/dispatch.hxx>
22
23#include <sfx2/viewfrm.hxx>
24#include <sfx2/request.hxx>
25#include <svl/stritem.hxx>
26
27#include <sdattr.hrc>
28#include <drawdoc.hxx>
29#include <sdpage.hxx>
30#include <pres.hxx>
31#include <DrawViewShell.hxx>
32#include <View.hxx>
33#include <glob.hxx>
34#include <app.hrc>
35#include <DrawDocShell.hxx>
36#include <SlideSorterViewShell.hxx>
37#include <Window.hxx>
38#include <drawview.hxx>
39#include <sdabstdlg.hxx>
40#include <memory>
41
42namespace sd
43{
44
45
46#define DOCUMENT_TOKEN'#' '#'
47
48FuPresentationLayout::FuPresentationLayout (
49 ViewShell* pViewSh,
50 ::sd::Window* pWin,
51 ::sd::View* pView,
52 SdDrawDocument* pDoc,
53 SfxRequest& rReq)
54 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
55{
56}
57
58rtl::Reference<FuPoor> FuPresentationLayout::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
59{
60 rtl::Reference<FuPoor> xFunc( new FuPresentationLayout( pViewSh, pWin, pView, pDoc, rReq ) );
61 xFunc->DoExecute(rReq);
62 return xFunc;
63}
64
65void FuPresentationLayout::DoExecute( SfxRequest& rReq )
66{
67 // prevent selected objects or objects which are under editing from disappearing
68 mpView->SdrEndTextEdit();
69
70 if(mpView->GetSdrPageView())
1
Assuming the condition is false
2
Taking false branch
71 {
72 mpView->UnmarkAll();
73 }
74
75 bool bError = false;
76
77 /* if we are on a master page, the changes apply for all pages and notes-
78 pages who are using the relevant layout */
79 bool bOnMaster = false;
80 if (DrawViewShell *pShell = dynamic_cast<DrawViewShell*>(mpViewShell))
3
Assuming 'pShell' is null
4
Taking false branch
81 {
82 EditMode eEditMode = pShell->GetEditMode();
83 if (eEditMode == EditMode::MasterPage)
84 bOnMaster = true;
85 }
86
87 std::vector<SdPage*> aUnselect;
88 if (!bOnMaster
4.1
'bOnMaster' is false
)
5
Taking true branch
89 {
90 //We later rely on IsSelected, so transfer the selection here
91 //into the document
92 slidesorter::SlideSorterViewShell* pSlideSorterViewShell
93 = slidesorter::SlideSorterViewShell::GetSlideSorter(mpViewShell->GetViewShellBase());
6
Called C++ object pointer is null
94 if (pSlideSorterViewShell)
95 {
96 std::shared_ptr<slidesorter::SlideSorterViewShell::PageSelection> xSelection(
97 pSlideSorterViewShell->GetPageSelection());
98 if (xSelection)
99 {
100 for (SdPage *pPage : *xSelection)
101 {
102 if (pPage->IsSelected() || pPage->GetPageKind() != PageKind::Standard)
103 continue;
104 mpDoc->SetSelected(pPage, true);
105 aUnselect.push_back(pPage);
106 }
107 }
108 }
109 }
110
111 std::vector<SdPage*> aSelectedPages;
112 std::vector<sal_uInt16> aSelectedPageNums;
113 // determine the active pages
114 for (sal_uInt16 nPage = 0; nPage < mpDoc->GetSdPageCount(PageKind::Standard); nPage++)
115 {
116 SdPage* pPage = mpDoc->GetSdPage(nPage, PageKind::Standard);
117 if (pPage->IsSelected())
118 {
119 aSelectedPages.push_back(pPage);
120 aSelectedPageNums.push_back(nPage);
121 }
122 }
123
124 bool bMasterPage = bOnMaster;
125 bool bCheckMasters = false;
126
127 // call dialog
128 bool bLoad = false; // appear the new master pages?
129 OUString aFile;
130
131 SfxItemSet aSet(mpDoc->GetPool(), svl::Items<ATTR_PRESLAYOUT_START27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1
, ATTR_PRESLAYOUT_END27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 3
>{});
132
133 aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_LOAD27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 1
, bLoad));
134 aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_MASTER_PAGE27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 2
, bMasterPage ) );
135 aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_CHECK_MASTERS27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 3
, bCheckMasters ) );
136
137 if (!aSelectedPages.empty())
138 {
139 OUString aOldLayoutName(aSelectedPages.back()->GetLayoutName());
140 sal_Int32 nPos = aOldLayoutName.indexOf(SD_LT_SEPARATOR"~LT~");
141 if (nPos != -1)
142 aOldLayoutName = aOldLayoutName.copy(0, nPos);
143 aSet.Put(SfxStringItem(ATTR_PRESLAYOUT_NAME27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1
, aOldLayoutName));
144 }
145
146 const SfxItemSet *pArgs = rReq.GetArgs ();
147
148 if (pArgs)
149 {
150 if (pArgs->GetItemState(ATTR_PRESLAYOUT_LOAD27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 1
) == SfxItemState::SET)
151 bLoad = static_cast<const SfxBoolItem&>(pArgs->Get(ATTR_PRESLAYOUT_LOAD27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 1
)).GetValue();
152 if( pArgs->GetItemState( ATTR_PRESLAYOUT_MASTER_PAGE27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 2
) == SfxItemState::SET )
153 bMasterPage = static_cast<const SfxBoolItem&>( pArgs->Get( ATTR_PRESLAYOUT_MASTER_PAGE27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 2
) ).GetValue();
154 if( pArgs->GetItemState( ATTR_PRESLAYOUT_CHECK_MASTERS27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 3
) == SfxItemState::SET )
155 bCheckMasters = static_cast<const SfxBoolItem&>( pArgs->Get( ATTR_PRESLAYOUT_CHECK_MASTERS27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 3
) ).GetValue();
156 if (pArgs->GetItemState(ATTR_PRESLAYOUT_NAME27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1
) == SfxItemState::SET)
157 aFile = static_cast<const SfxStringItem&>(pArgs->Get(ATTR_PRESLAYOUT_NAME27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1
)).GetValue();
158 }
159 else
160 {
161 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
162 ScopedVclPtr<AbstractSdPresLayoutDlg> pDlg(pFact->CreateSdPresLayoutDlg(mpWindow ? mpWindow->GetFrameWeld() : nullptr, mpDocSh, aSet));
163
164 sal_uInt16 nResult = pDlg->Execute();
165
166 switch (nResult)
167 {
168 case RET_OK:
169 {
170 pDlg->GetAttr(aSet);
171 if (aSet.GetItemState(ATTR_PRESLAYOUT_LOAD27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 1
) == SfxItemState::SET)
172 bLoad = static_cast<const SfxBoolItem&>(aSet.Get(ATTR_PRESLAYOUT_LOAD27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 1
)).GetValue();
173 if( aSet.GetItemState( ATTR_PRESLAYOUT_MASTER_PAGE27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 2
) == SfxItemState::SET )
174 bMasterPage = static_cast<const SfxBoolItem&>(aSet.Get( ATTR_PRESLAYOUT_MASTER_PAGE27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 2
) ).GetValue();
175 if( aSet.GetItemState( ATTR_PRESLAYOUT_CHECK_MASTERS27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 3
) == SfxItemState::SET )
176 bCheckMasters = static_cast<const SfxBoolItem&>(aSet.Get( ATTR_PRESLAYOUT_CHECK_MASTERS27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1 + 3
) ).GetValue();
177 if (aSet.GetItemState(ATTR_PRESLAYOUT_NAME27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1
) == SfxItemState::SET)
178 aFile = static_cast<const SfxStringItem&>(aSet.Get(ATTR_PRESLAYOUT_NAME27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3 + 1
)).GetValue();
179 }
180 break;
181
182 default:
183 bError = true;
184 }
185 }
186
187 if (bError)
188 return;
189
190 mpDocSh->SetWaitCursor( true );
191
192 /* Here, we only exchange masterpages, therefore the current page
193 remains the current page. To prevent calling PageOrderChangedHint
194 during insertion and extraction of the masterpages, we block. */
195 /* That isn't quite right. If the masterpageview is active and you are
196 removing a masterpage, it's possible that you are removing the
197 current masterpage. So you have to call ResetActualPage ! */
198 if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr && !bCheckMasters )
199 static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(true);
200
201 if (bLoad)
202 {
203 sal_Int32 nIdx{ 0 };
204 OUString aFileName = aFile.getToken(0, DOCUMENT_TOKEN'#', nIdx);
205 SdDrawDocument* pTempDoc = mpDoc->OpenBookmarkDoc( aFileName );
206
207 // #69581: If I chose the standard-template I got no filename and so I get no
208 // SdDrawDocument-Pointer. But the method SetMasterPage is able to handle
209 // a NULL-pointer as a Standard-template ( look at SdDrawDocument::SetMasterPage )
210 OUString aLayoutName;
211 if( pTempDoc )
212 aLayoutName = aFile.getToken(0, DOCUMENT_TOKEN'#', nIdx);
213 for (auto nSelectedPage : aSelectedPageNums)
214 mpDoc->SetMasterPage(nSelectedPage, aLayoutName, pTempDoc, bMasterPage, bCheckMasters);
215 mpDoc->CloseBookmarkDoc();
216 }
217 else
218 {
219 // use master page with the layout name aFile from current Doc
220 for (auto nSelectedPage : aSelectedPageNums)
221 mpDoc->SetMasterPage(nSelectedPage, aFile, mpDoc, bMasterPage, bCheckMasters);
222 }
223
224 // remove blocking
225 if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr && !bCheckMasters )
226 static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(false);
227
228 // if the master page was visible, show it again
229 if (!aSelectedPages.empty())
230 {
231 if (bOnMaster)
232 {
233 if( dynamic_cast< const DrawViewShell *>( mpViewShell ) != nullptr)
234 {
235 ::sd::View* pView =
236 static_cast<DrawViewShell*>(mpViewShell)->GetView();
237 for (auto pSelectedPage : aSelectedPages)
238 {
239 sal_uInt16 nPgNum = pSelectedPage->TRG_GetMasterPage().GetPageNum();
240
241 if (static_cast<DrawViewShell*>(mpViewShell)->GetPageKind() == PageKind::Notes)
242 nPgNum++;
243
244 pView->HideSdrPage();
245 pView->ShowSdrPage(pView->GetModel()->GetMasterPage(nPgNum));
246 }
247 }
248
249 // force update of TabBar
250 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_MASTERPAGE(27000 +50), SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
251 }
252 else
253 {
254 for (auto pSelectedPage : aSelectedPages)
255 pSelectedPage->SetAutoLayout(pSelectedPage->GetAutoLayout());
256 }
257 }
258
259 //Undo transfer to document selection
260 for (auto pPage : aUnselect)
261 mpDoc->SetSelected(pPage, false);
262
263
264 // fake a mode change to repaint the page tab bar
265 if( auto pDrawViewSh = dynamic_cast<DrawViewShell *>( mpViewShell ) )
266 {
267 EditMode eMode = pDrawViewSh->GetEditMode();
268 bool bLayer = pDrawViewSh->IsLayerModeActive();
269 pDrawViewSh->ChangeEditMode( eMode, !bLayer );
270 pDrawViewSh->ChangeEditMode( eMode, bLayer );
271 }
272
273 mpDocSh->SetWaitCursor( false );
274}
275
276} // end of namespace sd
277
278/* vim:set shiftwidth=4 softtabstop=4 expandtab: */