Bug Summary

File:home/maarten/src/libreoffice/core/sd/source/ui/app/sdmod2.cxx
Warning:line 503, column 26
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 sdmod2.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/app/sdmod2.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 <editeng/flditem.hxx>
21#include <editeng/CustomPropertyField.hxx>
22#include <sfx2/printer.hxx>
23#include <sfx2/styfitem.hxx>
24#include <svl/inethist.hxx>
25#include <svl/poolitem.hxx>
26#include <svl/flagitem.hxx>
27#include <unotools/useroptions.hxx>
28#include <sfx2/bindings.hxx>
29#include <sfx2/viewfrm.hxx>
30#include <sfx2/docfile.hxx>
31
32#include <editeng/measfld.hxx>
33#include <editeng/editstat.hxx>
34
35#include <svx/svxids.hrc>
36#include <svx/dialogs.hrc>
37#include <svx/svdotext.hxx>
38
39#include <sfx2/sfxdlg.hxx>
40
41#include <sdmod.hxx>
42#include <app.hrc>
43#include <family.hrc>
44#include <strings.hrc>
45#include <sdattr.hrc>
46
47#include <bitmaps.hlst>
48#include <ViewShell.hxx>
49#include <FrameView.hxx>
50#include <optsitem.hxx>
51#include <DrawDocShell.hxx>
52#include <drawdoc.hxx>
53#include <Outliner.hxx>
54#include <sdresid.hxx>
55#include <pres.hxx>
56#include <OutlineViewShell.hxx>
57#include <OutlineView.hxx>
58#include <ViewShellBase.hxx>
59#include <sdpage.hxx>
60#include <sdabstdlg.hxx>
61#include <svl/intitem.hxx>
62
63/** retrieves the page that is currently painted. This will only be the master page
64 if the current drawn view only shows the master page*/
65static SdPage* GetCurrentPage( sd::ViewShell const * pViewSh, EditFieldInfo const * pInfo, bool& bMasterView )
66{
67 if( !pInfo )
68 return nullptr;
69
70 bMasterView = false;
71 SdPage* pPage = dynamic_cast< SdPage* >( pInfo->GetSdrPage() );
72 SdrOutliner* pOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
73
74 // special case, someone already set the current page on the EditFieldInfo
75 // This is used from the svx::UnoGraphicsExporter f.e.
76 if( pPage )
77 {
78 bMasterView = false;
79 return pPage;
80 }
81
82 // first try to check if we are inside the outline view
83 sd::OutlineView* pSdView = nullptr;
84 if( auto pOutlineViewShell = dynamic_cast<const sd::OutlineViewShell* >(pViewSh) )
85 pSdView = static_cast<sd::OutlineView*>(pOutlineViewShell->GetView());
86
87 if (pSdView != nullptr && (pOutliner == &pSdView->GetOutliner()))
88 {
89 // outline mode
90 int nPgNum = 0;
91 Outliner& rOutl = pSdView->GetOutliner();
92 long nPos = pInfo->GetPara();
93 sal_Int32 nParaPos = 0;
94
95 for( Paragraph* pPara = rOutl.GetParagraph( 0 ); pPara && nPos >= 0; pPara = rOutl.GetParagraph( ++nParaPos ), nPos-- )
96 {
97 if( Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ) )
98 nPgNum++;
99 }
100
101 pPage = pViewSh->GetDoc()->GetSdPage( static_cast<sal_uInt16>(nPgNum), PageKind::Standard );
102 }
103 else
104 {
105 // draw mode, slide mode and preview. Get the processed page from the outliner
106 if(pOutliner)
107 {
108 pPage = dynamic_cast< SdPage* >(const_cast< SdrPage* >(pOutliner->getVisualizedPage()));
109 }
110
111 // The path using GetPaintingPageView() and GetCurrentPaintingDisplayInfo()
112 // is no longer needed. I debugged and checked all usages of PageNumber decompositions
113 // which all use the new possibility of setting the visualized page at the SdrOutliner.
114
115 // if all else failed, geht the current page from the object that is
116 // currently formatted from the document
117 if(!pPage)
118 {
119 const SdrTextObj* pTextObj = (pViewSh && pViewSh->GetDoc()) ? pViewSh->GetDoc()->GetFormattingTextObj() : nullptr;
120
121 if( pTextObj )
122 {
123 pPage = dynamic_cast< SdPage* >( pTextObj->getSdrPageFromSdrObject() );
124 }
125 }
126
127 if(pPage)
128 {
129 bMasterView = pPage->IsMasterPage();
130 }
131 }
132
133 return pPage;
134}
135
136/**
137 * Link for CalcFieldValue of Outliners
138 */
139IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo, void)void SdModule::LinkStubCalcFieldValueHdl(void * instance, EditFieldInfo
* data) { return static_cast<SdModule *>(instance)->
CalcFieldValueHdl(data); } void SdModule::CalcFieldValueHdl(EditFieldInfo
* pInfo)
140{
141 if (!pInfo)
142 return;
143
144 const SvxFieldData* pField = pInfo->GetField().GetField();
145 ::sd::DrawDocShell* pDocShell = nullptr;
146 SdDrawDocument* pDoc = nullptr;
147
148 SdrOutliner* pSdrOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
149 if( pSdrOutliner )
150 {
151 const SdrTextObj* pTextObj = pSdrOutliner->GetTextObj();
152
153 if( pTextObj )
154 pDoc = dynamic_cast< SdDrawDocument* >( &pTextObj->getSdrModelFromSdrObject() );
155
156 if( pDoc )
157 pDocShell = pDoc->GetDocSh();
158 }
159
160 if( !pDocShell )
161 pDocShell = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
162
163 const SvxDateField* pDateField = nullptr;
164 const SvxExtTimeField* pExtTimeField = nullptr;
165 const SvxExtFileField* pExtFileField = nullptr;
166 const SvxAuthorField* pAuthorField = nullptr;
167 const SvxURLField* pURLField = nullptr;
168
169 const editeng::CustomPropertyField* pCustomPropertyField = nullptr;
170
171 if( (pDateField = dynamic_cast< const SvxDateField* >(pField)) != nullptr )
172 {
173 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
174 pInfo->SetRepresentation( pDateField->GetFormatted( *GetNumberFormatter(), eLang ) );
175 }
176 else if( (pExtTimeField = dynamic_cast< const SvxExtTimeField *>(pField)) != nullptr )
177 {
178 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
179 pInfo->SetRepresentation( pExtTimeField->GetFormatted( *GetNumberFormatter(), eLang ) );
180 }
181 else if( (pExtFileField = dynamic_cast< const SvxExtFileField * >(pField)) != nullptr )
182 {
183 if( pDocShell && (pExtFileField->GetType() != SvxFileType::Fix) )
184 {
185 OUString aName;
186 if( pDocShell->HasName() )
187 aName = pDocShell->GetMedium()->GetName();
188 else
189 aName = pDocShell->GetName();
190
191 const_cast< SvxExtFileField* >(pExtFileField)->SetFile( aName );
192 }
193 pInfo->SetRepresentation( pExtFileField->GetFormatted() );
194
195 }
196 else if( (pAuthorField = dynamic_cast< const SvxAuthorField* >( pField )) != nullptr )
197 {
198 if( pAuthorField->GetType() != SvxAuthorType::Fix )
199 {
200 SvtUserOptions aUserOptions;
201 SvxAuthorField aAuthorField(
202 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID(),
203 pAuthorField->GetType(), pAuthorField->GetFormat() );
204
205 *const_cast< SvxAuthorField* >(pAuthorField) = aAuthorField;
206 }
207 pInfo->SetRepresentation( pAuthorField->GetFormatted() );
208
209 }
210 else if( dynamic_cast< const SvxPageField* >(pField) )
211 {
212 OUString aRepresentation(" ");
213
214 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : nullptr;
215 if(pViewSh == nullptr)
216 {
217 ::sd::ViewShellBase* pBase = dynamic_cast< ::sd::ViewShellBase *>( SfxViewShell::Current() );
218 if(pBase)
219 pViewSh = pBase->GetMainViewShell().get();
220 }
221 if( !pDoc && pViewSh )
222 pDoc = pViewSh->GetDoc();
223
224 bool bMasterView;
225 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
226
227 if( pPage && pDoc && !bMasterView )
228 {
229 int nPgNum;
230
231 if( (pPage->GetPageKind() == PageKind::Handout) && pViewSh )
232 {
233 nPgNum = pViewSh->GetPrintedHandoutPageNum();
234 }
235 else
236 {
237 nPgNum = (pPage->GetPageNum() - 1) / 2 + 1;
238 }
239 aRepresentation = pDoc->CreatePageNumValue(static_cast<sal_uInt16>(nPgNum));
240 }
241 else
242 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_NUMBERreinterpret_cast<char const *>("STR_FIELD_PLACEHOLDER_NUMBER"
"\004" u8"<number>")
);
243
244 pInfo->SetRepresentation( aRepresentation );
245 }
246 else if( dynamic_cast< const SvxPageTitleField* >(pField) )
247 {
248 OUString aRepresentation(" ");
249
250 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : nullptr;
251 if(pViewSh == nullptr)
252 {
253 ::sd::ViewShellBase* pBase = dynamic_cast< ::sd::ViewShellBase *>( SfxViewShell::Current() );
254 if(pBase)
255 pViewSh = pBase->GetMainViewShell().get();
256 }
257 if( !pDoc && pViewSh )
258 pDoc = pViewSh->GetDoc();
259
260 bool bMasterView;
261 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
262
263 if( pPage && pDoc && !bMasterView )
264 {
265 aRepresentation = pPage->GetName();
266 }
267 else
268 {
269 DocumentType eDocType = pDoc ? pDoc->GetDocumentType() : DocumentType::Impress;
270 aRepresentation = ( ( eDocType == DocumentType::Impress )
271 ? SdResId(STR_FIELD_PLACEHOLDER_SLIDENAMEreinterpret_cast<char const *>("STR_FIELD_PLACEHOLDER_SLIDENAME"
"\004" u8"<slide-name>")
)
272 : SdResId(STR_FIELD_PLACEHOLDER_PAGENAMEreinterpret_cast<char const *>("STR_FIELD_PLACEHOLDER_PAGENAME"
"\004" u8"<page-name>")
) );
273 }
274
275 pInfo->SetRepresentation( aRepresentation );
276 }
277 else if( dynamic_cast< const SvxPagesField* >(pField) )
278 {
279 OUString aRepresentation(" ");
280
281 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : nullptr;
282 if(pViewSh == nullptr)
283 {
284 ::sd::ViewShellBase* pBase = dynamic_cast< ::sd::ViewShellBase *>( SfxViewShell::Current() );
285 if(pBase)
286 pViewSh = pBase->GetMainViewShell().get();
287 }
288 if( !pDoc && pViewSh )
289 pDoc = pViewSh->GetDoc();
290
291 bool bMasterView;
292 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
293
294 sal_uInt16 nPageCount = 0;
295
296 if( !bMasterView )
297 {
298 if( pPage && (pPage->GetPageKind() == PageKind::Handout) && pViewSh )
299 {
300 nPageCount = pViewSh->GetPrintedHandoutPageCount();
301 }
302 else if( pDoc )
303 {
304 nPageCount = pDoc->GetActiveSdPageCount();
305 }
306 }
307
308 if( nPageCount > 0 )
309 aRepresentation = pDoc->CreatePageNumValue(nPageCount);
310 else
311 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_COUNTreinterpret_cast<char const *>("STR_FIELD_PLACEHOLDER_COUNT"
"\004" u8"<count>")
);
312
313 pInfo->SetRepresentation( aRepresentation );
314 }
315 else if( (pURLField = dynamic_cast< const SvxURLField* >(pField)) != nullptr )
316 {
317 switch ( pURLField->GetFormat() )
318 {
319 case SvxURLFormat::AppDefault: //!!! adjustable at App???
320 case SvxURLFormat::Repr:
321 pInfo->SetRepresentation( pURLField->GetRepresentation() );
322 break;
323
324 case SvxURLFormat::Url:
325 pInfo->SetRepresentation( pURLField->GetURL() );
326 break;
327 }
328
329 const OUString& aURL = pURLField->GetURL();
330
331 svtools::ColorConfig aConfig;
332 svtools::ColorConfigEntry eEntry =
333 INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS;
334 pInfo->SetTextColor( aConfig.GetColorValue(eEntry).nColor );
335 }
336 else if ( dynamic_cast< const SdrMeasureField* >(pField))
337 {
338 pInfo->SetFieldColor(std::optional<Color>()); // clear the field color
339 }
340 else if ((pCustomPropertyField = dynamic_cast<const editeng::CustomPropertyField*>(pField)) != nullptr)
341 {
342 try
343 {
344 if (SfxObjectShell::Current() && SfxObjectShell::Current()->IsLoadingFinished())
345 {
346 auto pNonConstCustomPropertyField = const_cast<editeng::CustomPropertyField*>(pCustomPropertyField);
347 OUString sCurrent = pNonConstCustomPropertyField->GetFormatted(SfxObjectShell::Current()->getDocProperties());
348 pInfo->SetRepresentation(sCurrent);
349 }
350 else
351 pInfo->SetRepresentation(pCustomPropertyField->GetCurrentPresentation());
352 }
353 catch (...)
354 {
355 pInfo->SetRepresentation(pCustomPropertyField->GetCurrentPresentation());
356 }
357 }
358 else
359 {
360 OUString aRepresentation;
361
362 bool bHeaderField = dynamic_cast< const SvxHeaderField* >( pField ) != nullptr;
363 bool bFooterField = !bHeaderField && (dynamic_cast< const SvxFooterField* >( pField ) != nullptr );
364 bool bDateTimeField = !bHeaderField && !bFooterField && (dynamic_cast< const SvxDateTimeField* >( pField ) != nullptr);
365
366 if( bHeaderField || bFooterField || bDateTimeField )
367 {
368 sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : nullptr;
369 bool bMasterView = false;
370 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
371
372 if( (pPage == nullptr) || bMasterView )
373 {
374 if( bHeaderField )
375 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_HEADERreinterpret_cast<char const *>("STR_FIELD_PLACEHOLDER_HEADER"
"\004" u8"<header>")
);
376 else if (bFooterField )
377 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_FOOTERreinterpret_cast<char const *>("STR_FIELD_PLACEHOLDER_FOOTER"
"\004" u8"<footer>")
);
378 else if (bDateTimeField )
379 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_DATETIMEreinterpret_cast<char const *>("STR_FIELD_PLACEHOLDER_DATETIME"
"\004" u8"<date/time>")
);
380 }
381 else
382 {
383 const sd::HeaderFooterSettings &rSettings = pPage->getHeaderFooterSettings();
384
385 if( bHeaderField )
386 {
387 aRepresentation = rSettings.maHeaderText;
388 }
389 else if( bFooterField )
390 {
391 aRepresentation = rSettings.maFooterText;
392 }
393 else if( bDateTimeField )
394 {
395 if( rSettings.mbDateTimeIsFixed )
396 {
397 aRepresentation = rSettings.maDateTimeText;
398 }
399 else
400 {
401 DateTime aDateTime( DateTime::SYSTEM );
402 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
403 aRepresentation = SvxDateTimeField::GetFormatted( aDateTime, aDateTime,
404 rSettings.meDateFormat, rSettings.meTimeFormat, *GetNumberFormatter(), eLang );
405 }
406 }
407 }
408 }
409 else
410 {
411 OSL_FAIL("sd::SdModule::CalcFieldValueHdl(), unknown field type!")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/app/sdmod2.cxx"
":" "411" ": "), "%s", "sd::SdModule::CalcFieldValueHdl(), unknown field type!"
); } } while (false)
;
412 }
413
414 if( aRepresentation.isEmpty() ) // TODO: Edit engine doesn't handle empty fields?
415 aRepresentation = " ";
416 pInfo->SetRepresentation( aRepresentation );
417 }
418}
419
420/**
421 * virtual methods for option dialog
422 */
423std::unique_ptr<SfxItemSet> SdModule::CreateItemSet( sal_uInt16 nSlot )
424{
425 ::sd::FrameView* pFrameView = nullptr;
426 ::sd::DrawDocShell* pDocSh = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
427 SdDrawDocument* pDoc = nullptr;
428
429 // Here we set the DocType of the option dialog (not document!)
430 DocumentType eDocType = DocumentType::Impress;
431 if( nSlot == SID_SD_GRAPHIC_OPTIONS( 10000 + 447 ) )
1
Assuming the condition is false
2
Taking false branch
432 eDocType = DocumentType::Draw;
433
434 if (pDocSh)
3
Assuming 'pDocSh' is non-null
4
Taking true branch
435 {
436 pDoc = pDocSh->GetDoc();
5
Value assigned to 'pDoc'
437
438 // If the option dialog is identical to the document type,
439 // we can pass the FrameView too:
440 if( pDoc && eDocType == pDoc->GetDocumentType() )
6
Assuming 'pDoc' is null
441 pFrameView = pDocSh->GetFrameView();
442
443 ::sd::ViewShell* pViewShell = pDocSh->GetViewShell();
444 if (pViewShell != nullptr)
7
Assuming the condition is false
8
Taking false branch
445 pViewShell->WriteFrameViewData();
446 }
447
448 SdOptions* pOptions = GetSdOptions(eDocType);
449
450 // Pool has by default MapUnit Twips (Awgh!)
451 SfxItemPool& rPool = GetPool();
452 rPool.SetDefaultMetric( MapUnit::Map100thMM );
453
454 auto pRet = std::make_unique<SfxItemSet>(
455 rPool,
456 svl::Items<
457 SID_ATTR_GRID_OPTIONS( 10000 + 298 ), SID_ATTR_GRID_OPTIONS( 10000 + 298 ),
458 SID_ATTR_METRICTypedWhichId<SfxUInt16Item>(((((10000 + 1499) + 1) + 499
) + 1) + 8)
, SID_ATTR_METRICTypedWhichId<SfxUInt16Item>(((((10000 + 1499) + 1) + 499
) + 1) + 8)
,
459 SID_ATTR_DEFTABSTOP(((((10000 + 1499) + 1) + 499) + 1) + 14), SID_ATTR_DEFTABSTOP(((((10000 + 1499) + 1) + 499) + 1) + 14),
460 ATTR_OPTIONS_LAYOUT27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 1
, ATTR_OPTIONS_SCALE_END27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3
>{});
461
462 // TP_OPTIONS_LAYOUT:
463 pRet->Put( SdOptionsLayoutItem( pOptions, pFrameView ) );
464
465 sal_uInt16 nDefTab = 0;
466 if( pFrameView
8.1
'pFrameView' is null
)
9
Taking false branch
467 nDefTab = pDoc->GetDefaultTabulator();
468 else
469 nDefTab = pOptions->GetDefTab();
470 pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP(((((10000 + 1499) + 1) + 499) + 1) + 14), nDefTab ) );
471
472 FieldUnit nMetric = FieldUnit(0xffff);
473 if( pFrameView
9.1
'pFrameView' is null
)
10
Taking false branch
474 nMetric = pDoc->GetUIUnit();
475 else
476 nMetric = static_cast<FieldUnit>(pOptions->GetMetric());
477
478 if( nMetric
10.1
'nMetric' is not equal to 65535
== FieldUnit(0xffff) )
11
Taking false branch
479 nMetric = GetFieldUnit();
480
481 pRet->Put( SfxUInt16Item( SID_ATTR_METRICTypedWhichId<SfxUInt16Item>(((((10000 + 1499) + 1) + 499
) + 1) + 8)
, static_cast<sal_uInt16>(nMetric) ) );
482
483 // TP_OPTIONS_MISC:
484 SdOptionsMiscItem aSdOptionsMiscItem( pOptions, pFrameView );
485 if ( pFrameView
11.1
'pFrameView' is null
)
12
Taking false branch
486 {
487 aSdOptionsMiscItem.GetOptionsMisc().SetSummationOfParagraphs( pDoc->IsSummationOfParagraphs() );
488 aSdOptionsMiscItem.GetOptionsMisc().SetPrinterIndependentLayout (
489 static_cast<sal_uInt16>(pDoc->GetPrinterIndependentLayout()));
490 }
491 pRet->Put( aSdOptionsMiscItem );
492
493 // TP_OPTIONS_SNAP:
494 pRet->Put( SdOptionsSnapItem( pOptions, pFrameView ) );
495
496 // TP_SCALE:
497 sal_uInt32 nW = 10;
498 sal_uInt32 nH = 10;
499 sal_Int32 nX;
500 sal_Int32 nY;
501 if( pDocSh
12.1
'pDocSh' is non-null
)
13
Taking true branch
502 {
503 SdrPage* pPage = pDoc->GetSdPage(0, PageKind::Standard);
14
Called C++ object pointer is null
504 Size aSize(pPage->GetSize());
505 nW = aSize.Width();
506 nH = aSize.Height();
507 }
508
509 if(pFrameView)
510 {
511 const Fraction& rFraction = pDoc->GetUIScale();
512 nX=rFraction.GetNumerator();
513 nY=rFraction.GetDenominator();
514 }
515 else
516 {
517 // Get options from configuration file
518 pOptions->GetScale( nX, nY );
519 }
520
521 pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1
, nX ) );
522 pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 1
, nY ) );
523 pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_WIDTH27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 2
, nW ) );
524 pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_HEIGHT27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 3
, nH ) );
525
526 // TP_OPTIONS_PRINT:
527 pRet->Put( SdOptionsPrintItem( pOptions ) );
528
529 // RID_SVXPAGE_GRID:
530 pRet->Put( SdOptionsGridItem( pOptions ) );
531
532 return pRet;
533}
534void SdModule::ApplyItemSet( sal_uInt16 nSlot, const SfxItemSet& rSet )
535{
536 const SfxPoolItem* pItem = nullptr;
537 bool bNewDefTab = false;
538 bool bNewPrintOptions = false;
539 bool bMiscOptions = false;
540
541 ::sd::DrawDocShell* pDocSh = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
542 SdDrawDocument* pDoc = nullptr;
543 // Here we set the DocType of the option dialog (not document!)
544 DocumentType eDocType = DocumentType::Impress;
545 if( nSlot == SID_SD_GRAPHIC_OPTIONS( 10000 + 447 ) )
546 eDocType = DocumentType::Draw;
547
548 ::sd::ViewShell* pViewShell = nullptr;
549
550 if (pDocSh)
551 {
552 pDoc = pDocSh->GetDoc();
553
554 pViewShell = pDocSh->GetViewShell();
555 if (pViewShell != nullptr)
556 pViewShell->WriteFrameViewData();
557 }
558 SdOptions* pOptions = GetSdOptions(eDocType);
559 // Grid
560 if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS( 10000 + 298 ) ,
561 false, &pItem ))
562 {
563 const SdOptionsGridItem* pGridItem = static_cast<const SdOptionsGridItem*>(pItem);
564 pGridItem->SetOptions( pOptions );
565 }
566
567 // Layout
568 const SdOptionsLayoutItem* pLayoutItem = nullptr;
569 if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_LAYOUT27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 1
,
570 false, reinterpret_cast<const SfxPoolItem**>(&pLayoutItem) ))
571 {
572 pLayoutItem->SetOptions( pOptions );
573 }
574
575 // Metric
576 if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_METRICTypedWhichId<SfxUInt16Item>(((((10000 + 1499) + 1) + 499
) + 1) + 8)
, false, &pItem ) )
577 {
578 if( pDoc && eDocType == pDoc->GetDocumentType() )
579 PutItem( *pItem );
580 pOptions->SetMetric( static_cast<const SfxUInt16Item*>( pItem )->GetValue() );
581 }
582 sal_uInt16 nDefTab = pOptions->GetDefTab();
583 // Default-Tabulator
584 if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_DEFTABSTOP(((((10000 + 1499) + 1) + 499) + 1) + 14), false, &pItem ) )
585 {
586 nDefTab = static_cast<const SfxUInt16Item*>( pItem )->GetValue();
587 pOptions->SetDefTab( nDefTab );
588
589 bNewDefTab = true;
590 }
591
592 // Scale
593 if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_X27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1
, false, &pItem ) )
594 {
595 sal_Int32 nX = static_cast<const SfxInt32Item*>( pItem )->GetValue();
596 if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_Y27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4 + 1 + 1
, false, &pItem ) )
597 {
598 sal_Int32 nY = static_cast<const SfxInt32Item*>( pItem )->GetValue();
599 pOptions->SetScale( nX, nY );
600
601 // Apply to document only if doc type match
602 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
603 {
604 pDoc->SetUIScale( Fraction( nX, nY ) );
605 if( pViewShell )
606 pViewShell->SetRuler( pViewShell->HasRuler() );
607 }
608 }
609 }
610
611 // Misc
612 const SdOptionsMiscItem* pMiscItem = nullptr;
613 if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_MISC27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 2
,
614 false, reinterpret_cast<const SfxPoolItem**>(&pMiscItem) ))
615 {
616 pMiscItem->SetOptions( pOptions );
617 bMiscOptions = true;
618 }
619
620 // Snap
621 const SdOptionsSnapItem* pSnapItem = nullptr;
622 if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_SNAP27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 3
,
623 false, reinterpret_cast<const SfxPoolItem**>(&pSnapItem) ))
624 {
625 pSnapItem->SetOptions( pOptions );
626 }
627
628 SfxItemSet aPrintSet( GetPool(),
629 svl::Items<SID_PRINTER_NOTFOUND_WARN(5000 + 320), SID_PRINTER_NOTFOUND_WARN(5000 + 320),
630 SID_PRINTER_CHANGESTODOC(5000 + 324), SID_PRINTER_CHANGESTODOC(5000 + 324),
631 ATTR_OPTIONS_PRINT27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4
, ATTR_OPTIONS_PRINT27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4
>{} );
632
633 // Print
634 const SdOptionsPrintItem* pPrintItem = nullptr;
635 if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_PRINT27000 + 1234 + 6 + 1 + 15 + 1 + 10 + 1 + 5 + 1 + 7 + 1 + 2 + 1
+ 4
,
636 false, reinterpret_cast<const SfxPoolItem**>(&pPrintItem) ))
637 {
638 pPrintItem->SetOptions( pOptions );
639
640 // set PrintOptionsSet
641 SdOptionsPrintItem aPrintItem( pOptions );
642 SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC(5000 + 324) );
643 SfxPrinterChangeFlags nFlags =
644 (aPrintItem.GetOptionsPrint().IsWarningSize() ? SfxPrinterChangeFlags::CHG_SIZE : SfxPrinterChangeFlags::NONE) |
645 (aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SfxPrinterChangeFlags::CHG_ORIENTATION : SfxPrinterChangeFlags::NONE);
646 aFlagItem.SetValue( static_cast<int>(nFlags) );
647
648 aPrintSet.Put( aPrintItem );
649 aPrintSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN(5000 + 320), aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
650 aPrintSet.Put( aFlagItem );
651
652 bNewPrintOptions = true;
653 }
654
655 // Only if also the document type matches...
656 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
657 {
658 if( bNewPrintOptions )
659 {
660 pDocSh->GetPrinter(true)->SetOptions( aPrintSet );
661 }
662
663 // set DefTab at Model
664 if( bNewDefTab )
665 {
666 SdDrawDocument* pDocument = pDocSh->GetDoc();
667 pDocument->SetDefaultTabulator( nDefTab );
668
669 SdOutliner* pOutl = pDocument->GetOutliner( false );
670 if( pOutl )
671 pOutl->SetDefTab( nDefTab );
672
673 SdOutliner* pInternalOutl = pDocument->GetInternalOutliner( false );
674 if( pInternalOutl )
675 pInternalOutl->SetDefTab( nDefTab );
676 }
677 if ( bMiscOptions )
678 {
679 pDoc->SetSummationOfParagraphs( pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() );
680 EEControlBits nSum = pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() ? EEControlBits::ULSPACESUMMATION : EEControlBits::NONE;
681 EEControlBits nCntrl;
682
683 SdDrawDocument* pDocument = pDocSh->GetDoc();
684 SdrOutliner& rOutl = pDocument->GetDrawOutliner();
685 nCntrl = rOutl.GetControlWord() &~ EEControlBits::ULSPACESUMMATION;
686 rOutl.SetControlWord( nCntrl | nSum );
687 SdOutliner* pOutl = pDocument->GetOutliner( false );
688 if( pOutl )
689 {
690 nCntrl = pOutl->GetControlWord() &~ EEControlBits::ULSPACESUMMATION;
691 pOutl->SetControlWord( nCntrl | nSum );
692 }
693 pOutl = pDocument->GetInternalOutliner( false );
694 if( pOutl )
695 {
696 nCntrl = pOutl->GetControlWord() &~ EEControlBits::ULSPACESUMMATION;
697 pOutl->SetControlWord( nCntrl | nSum );
698 }
699
700 // Set printer independent layout mode.
701 if( pDoc->GetPrinterIndependentLayout() != pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout() )
702 pDoc->SetPrinterIndependentLayout (pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout());
703 }
704 }
705
706 pOptions->StoreConfig();
707
708 // Only if also the document type matches...
709 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
710 {
711 FieldUnit eUIUnit = static_cast<FieldUnit>(pOptions->GetMetric());
712 pDoc->SetUIUnit(eUIUnit);
713
714 if (pViewShell)
715 {
716 // make sure no one is in text edit mode, cause there
717 // are some pointers remembered else (!)
718 if(pViewShell->GetView())
719 pViewShell->GetView()->SdrEndTextEdit();
720
721 ::sd::FrameView* pFrame = pViewShell->GetFrameView();
722 pFrame->Update(pOptions);
723 pViewShell->ReadFrameViewData(pFrame);
724 pViewShell->SetUIUnit(eUIUnit);
725 pViewShell->SetDefTabHRuler( nDefTab );
726 }
727 }
728
729 if( pViewShell && pViewShell->GetViewFrame() )
730 pViewShell->GetViewFrame()->GetBindings().InvalidateAll( true );
731}
732
733std::unique_ptr<SfxTabPage> SdModule::CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet )
734{
735 std::unique_ptr<SfxTabPage> xRet;
736 SfxAllItemSet aSet(*(rSet.GetPool()));
737 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
738
739 switch(nId)
740 {
741 case SID_SD_TP_CONTENTS((10000 +6900) + 225):
742 case SID_SI_TP_CONTENTS((10000 +6900) + 232):
743 {
744 ::CreateTabPage fnCreatePage = pFact->GetSdOptionsContentsTabPageCreatorFunc();
745 if( fnCreatePage )
746 xRet = (*fnCreatePage)( pPage, pController, &rSet );
747 }
748 break;
749 case SID_SD_TP_SNAP((10000 +6900) + 227):
750 case SID_SI_TP_SNAP((10000 +6900) + 234):
751 {
752 ::CreateTabPage fnCreatePage = pFact->GetSdOptionsSnapTabPageCreatorFunc();
753 if( fnCreatePage )
754 xRet = (*fnCreatePage)( pPage, pController, &rSet );
755 }
756 break;
757 case SID_SD_TP_PRINT((10000 +6900) + 220):
758 case SID_SI_TP_PRINT((10000 +6900) + 236):
759 {
760 ::CreateTabPage fnCreatePage = pFact->GetSdPrintOptionsTabPageCreatorFunc();
761 if( fnCreatePage )
762 {
763 xRet = (*fnCreatePage)( pPage, pController, &rSet );
764 if(SID_SD_TP_PRINT((10000 +6900) + 220) == nId)
765 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG(27000 +413),SD_DRAW_MODE1));
766 xRet->PageCreated(aSet);
767 }
768 }
769 break;
770 case SID_SI_TP_MISC((10000 +6900) + 237):
771 case SID_SD_TP_MISC((10000 +6900) + 231):
772 {
773 ::CreateTabPage fnCreatePage = pFact->GetSdOptionsMiscTabPageCreatorFunc();
774 if( fnCreatePage )
775 {
776 xRet = (*fnCreatePage)( pPage, pController, &rSet );
777 if(SID_SD_TP_MISC((10000 +6900) + 231) == nId)
778 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG(27000 +413),SD_DRAW_MODE1));
779 else
780 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG(27000 +413),SD_IMPRESS_MODE2));
781 xRet->PageCreated(aSet);
782 }
783 }
784 break;
785 case RID_SVXPAGE_TEXTANIMATION((10000) + 184) :
786 {
787 SfxAbstractDialogFactory* pSfxFact = SfxAbstractDialogFactory::Create();
788 ::CreateTabPage fnCreatePage = pSfxFact->GetTabPageCreatorFunc( nId );
789 if ( fnCreatePage )
790 xRet = (*fnCreatePage)( pPage, pController, &rSet );
791 }
792 break;
793 }
794 DBG_ASSERT( xRet, "SdModule::CreateTabPage(): no valid ID for TabPage!" )do { if (true && (!(xRet))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/app/sdmod2.cxx"
":" "794" ": "), "%s", "SdModule::CreateTabPage(): no valid ID for TabPage!"
); } } while (false)
;
795
796 return xRet;
797}
798
799std::unique_ptr<SfxStyleFamilies> SdModule::CreateStyleFamilies()
800{
801 std::unique_ptr<SfxStyleFamilies> pStyleFamilies(new SfxStyleFamilies);
802
803 pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para,
804 SdResId(STR_GRAPHICS_STYLE_FAMILYreinterpret_cast<char const *>("STR_GRAPHICS_STYLE_FAMILY"
"\004" u8"Drawing Styles")
),
805 BMP_STYLES_FAMILY_GRAPHICS"sd/res/sf01.png",
806 RID_GRAPHICSTYLEFAMILY, SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->GetResLocale()));
807
808 pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Pseudo,
809 SdResId(STR_PRESENTATIONS_STYLE_FAMILYreinterpret_cast<char const *>("STR_PRESENTATIONS_STYLE_FAMILY"
"\004" u8"Presentation Styles")
),
810 BMP_STYLES_FAMILY_PRESENTATIONS"sd/res/sf02.png",
811 RID_PRESENTATIONSTYLEFAMILY, SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule
::Draw)) )
->GetResLocale()));
812
813 return pStyleFamilies;
814}
815
816/* vim:set shiftwidth=4 softtabstop=4 expandtab: */