Bug Summary

File:home/maarten/src/libreoffice/core/sc/source/ui/miscdlgs/redcom.cxx
Warning:line 139, column 23
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 redcom.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 SC_DLLIMPLEMENTATION -D SC_INFO_OSVERSION="LINUX" -D SYSTEM_LIBXML -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/liborcus/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/mdds/include -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/clew/source/include -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/sc/source/core/inc -I /home/maarten/src/libreoffice/core/sc/source/filter/inc -I /home/maarten/src/libreoffice/core/sc/source/ui/inc -I /home/maarten/src/libreoffice/core/sc/inc -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/sc/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/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/sc/source/ui/miscdlgs/redcom.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 <unotools/localedatawrapper.hxx>
21
22#include <chgtrack.hxx>
23#include <redcom.hxx>
24#include <docsh.hxx>
25#include <dbfunc.hxx>
26#include <tabview.hxx>
27#include <viewutil.hxx>
28#include <svx/svxdlg.hxx>
29
30ScRedComDialog::ScRedComDialog( weld::Window* pParent, const SfxItemSet& rCoreSet,
31 ScDocShell *pShell, ScChangeAction *pAction, bool bPrevNext)
32 : pChangeAction(nullptr)
33 , pDocShell(nullptr)
34 , pDlg(nullptr)
35{
36 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
37 pDlg = pFact->CreateSvxPostItDialog( pParent, rCoreSet, bPrevNext );
38 pDocShell=pShell;
39 pDlg->DontChangeAuthor();
40 pDlg->HideAuthor();
41
42 pDlg->SetPrevHdl(LINK( this, ScRedComDialog, PrevHdl)::tools::detail::makeLink( ::tools::detail::castTo<ScRedComDialog
*>(this), &ScRedComDialog::LinkStubPrevHdl)
);
43 pDlg->SetNextHdl(LINK( this, ScRedComDialog, NextHdl)::tools::detail::makeLink( ::tools::detail::castTo<ScRedComDialog
*>(this), &ScRedComDialog::LinkStubNextHdl)
);
44
45 ReInit(pAction);
46}
47
48ScRedComDialog::~ScRedComDialog()
49{
50 pDlg.disposeAndClear();
51}
52
53ScChangeAction *ScRedComDialog::FindPrev(ScChangeAction *pAction)
54{
55 if(pAction!=nullptr && pDocShell !=nullptr)
56 {
57 ScDocument& rDoc = pDocShell->GetDocument();
58 ScChangeViewSettings* pSettings = rDoc.GetChangeViewSettings();
59
60 pAction=pAction->GetPrev();
61
62 while(pAction!=nullptr)
63 {
64 if( pAction->GetState()==SC_CAS_VIRGIN &&
65 pAction->IsDialogRoot() &&
66 ScViewUtil::IsActionShown(*pAction,*pSettings,rDoc)) break;
67
68 pAction=pAction->GetPrev();
69 }
70 }
71 return pAction;
72}
73
74ScChangeAction *ScRedComDialog::FindNext(ScChangeAction *pAction)
75{
76 if(pAction!=nullptr && pDocShell !=nullptr)
77 {
78 ScDocument& rDoc = pDocShell->GetDocument();
79 ScChangeViewSettings* pSettings = rDoc.GetChangeViewSettings();
80
81 pAction=pAction->GetNext();
82
83 while(pAction!=nullptr)
84 {
85 if( pAction->GetState()==SC_CAS_VIRGIN &&
86 pAction->IsDialogRoot() &&
87 ScViewUtil::IsActionShown(*pAction,*pSettings,rDoc)) break;
88
89 pAction=pAction->GetNext();
90 }
91 }
92 return pAction;
93}
94
95void ScRedComDialog::ReInit(ScChangeAction *pAction)
96{
97 pChangeAction=pAction;
98 if(pChangeAction==nullptr || pDocShell ==nullptr)
99 return;
100
101 OUString aTitle;
102 pChangeAction->GetDescription(aTitle, pDocShell->GetDocument());
103 pDlg->SetText(aTitle);
104 aComment=pChangeAction->GetComment();
105
106 bool bNext=FindNext(pChangeAction)!=nullptr;
107 bool bPrev=FindPrev(pChangeAction)!=nullptr;
108 pDlg->EnableTravel(bNext,bPrev);
109
110 OUString aAuthor = pChangeAction->GetUser();
111
112 DateTime aDT = pChangeAction->GetDateTime();
113 OUString aDate = ScGlobal::getLocaleDataPtr()->getDate( aDT ) + " " +
114 ScGlobal::getLocaleDataPtr()->getTime( aDT, false );
115
116 pDlg->ShowLastAuthor(aAuthor, aDate);
117 pDlg->SetNote(aComment);
118}
119
120void ScRedComDialog::Execute()
121{
122 short nRet=pDlg->Execute();
123
124 if(nRet== RET_OK )
125 {
126 if ( pDocShell!=nullptr && pDlg->GetNote() != aComment )
127 pDocShell->SetChangeComment( pChangeAction, pDlg->GetNote());
128 }
129}
130
131void ScRedComDialog::SelectCell()
132{
133 if(pChangeAction==nullptr)
6
Taking false branch
134 return;
135
136 const ScChangeAction* pAction=pChangeAction;
137 const ScBigRange& rRange = pAction->GetBigRange();
138
139 if(rRange.IsValid(pDocShell->GetDocument()))
7
Called C++ object pointer is null
140 {
141 ScViewData* pViewData=ScDocShell::GetViewData();
142 ScRange aRef=rRange.MakeRange();
143 ScTabView* pTabView=pViewData->GetView();
144 pTabView->MarkRange(aRef);
145 }
146}
147
148IMPL_LINK(ScRedComDialog, PrevHdl, AbstractSvxPostItDialog&, rDlgP, void )void ScRedComDialog::LinkStubPrevHdl(void * instance, AbstractSvxPostItDialog
& data) { return static_cast<ScRedComDialog *>(instance
)->PrevHdl(data); } void ScRedComDialog::PrevHdl(AbstractSvxPostItDialog
& rDlgP)
149{
150 if (pDocShell!=nullptr && rDlgP.GetNote() != aComment )
151 pDocShell->SetChangeComment( pChangeAction, rDlgP.GetNote());
152
153 ReInit(FindPrev(pChangeAction));
154 SelectCell();
155}
156
157IMPL_LINK(ScRedComDialog, NextHdl, AbstractSvxPostItDialog&, rDlgP, void )void ScRedComDialog::LinkStubNextHdl(void * instance, AbstractSvxPostItDialog
& data) { return static_cast<ScRedComDialog *>(instance
)->NextHdl(data); } void ScRedComDialog::NextHdl(AbstractSvxPostItDialog
& rDlgP)
1
Calling 'ScRedComDialog::NextHdl'
158{
159 if ( pDocShell!=nullptr && rDlgP.GetNote() != aComment )
2
Assuming the condition is false
3
Assuming pointer value is null
4
Taking false branch
160 pDocShell->SetChangeComment( pChangeAction, rDlgP.GetNote());
161
162 ReInit(FindNext(pChangeAction));
163 SelectCell();
5
Calling 'ScRedComDialog::SelectCell'
164}
165
166/* vim:set shiftwidth=4 softtabstop=4 expandtab: */