LibreOffice Module sd (master) 1
sdmod2.cxx
Go to the documentation of this file.
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>
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>
28#include <sfx2/bindings.hxx>
29#include <sfx2/viewfrm.hxx>
30#include <sfx2/docfile.hxx>
31#include <osl/diagnose.h>
32
33#include <editeng/measfld.hxx>
34#include <editeng/editstat.hxx>
35
36#include <svx/svxids.hrc>
37#include <svx/dialogs.hrc>
38#include <svx/svdotext.hxx>
39
40#include <sfx2/sfxdlg.hxx>
41
42#include <sdmod.hxx>
43#include <app.hrc>
44#include <family.hrc>
45#include <strings.hrc>
46#include <sdattr.hrc>
47
48#include <bitmaps.hlst>
49#include <ViewShell.hxx>
50#include <FrameView.hxx>
51#include <optsitem.hxx>
52#include <DrawDocShell.hxx>
53#include <drawdoc.hxx>
54#include <Outliner.hxx>
55#include <sdresid.hxx>
56#include <pres.hxx>
57#include <OutlineViewShell.hxx>
58#include <OutlineView.hxx>
59#include <ViewShellBase.hxx>
60#include <sdpage.hxx>
61#include <sdabstdlg.hxx>
62#include <svl/intitem.hxx>
63
66static SdPage* GetCurrentPage( sd::ViewShell const * pViewSh, EditFieldInfo const * pInfo, bool& bMasterView )
67{
68 if( !pInfo )
69 return nullptr;
70
71 bMasterView = false;
72 SdPage* pPage = dynamic_cast< SdPage* >( pInfo->GetSdrPage() );
73 SdrOutliner* pOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
74
75 // special case, someone already set the current page on the EditFieldInfo
76 // This is used from the svx::UnoGraphicsExporter f.e.
77 if( pPage )
78 {
79 bMasterView = false;
80 return pPage;
81 }
82
83 // first try to check if we are inside the outline view
84 sd::OutlineView* pSdView = nullptr;
85 if( auto pOutlineViewShell = dynamic_cast<const sd::OutlineViewShell* >(pViewSh) )
86 pSdView = static_cast<sd::OutlineView*>(pOutlineViewShell->GetView());
87
88 if (pSdView != nullptr && (pOutliner == &pSdView->GetOutliner()))
89 {
90 // outline mode
91 int nPgNum = 0;
92 Outliner& rOutl = pSdView->GetOutliner();
93 tools::Long nPos = pInfo->GetPara();
94 sal_Int32 nParaPos = 0;
95
96 for( Paragraph* pPara = rOutl.GetParagraph( 0 ); pPara && nPos >= 0; pPara = rOutl.GetParagraph( ++nParaPos ), nPos-- )
97 {
98 if( Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ) )
99 nPgNum++;
100 }
101
102 pPage = pViewSh->GetDoc()->GetSdPage( static_cast<sal_uInt16>(nPgNum), PageKind::Standard );
103 }
104 else
105 {
106 // draw mode, slide mode and preview. Get the processed page from the outliner
107 if(pOutliner)
108 {
109 pPage = dynamic_cast< SdPage* >(const_cast< SdrPage* >(pOutliner->getVisualizedPage()));
110 }
111
112 // The path using GetPaintingPageView() and GetCurrentPaintingDisplayInfo()
113 // is no longer needed. I debugged and checked all usages of PageNumber decompositions
114 // which all use the new possibility of setting the visualized page at the SdrOutliner.
115
116 // if all else failed, geht the current page from the object that is
117 // currently formatted from the document
118 if(!pPage)
119 {
120 const SdrTextObj* pTextObj = (pViewSh && pViewSh->GetDoc()) ? pViewSh->GetDoc()->GetFormattingTextObj() : nullptr;
121
122 if( pTextObj )
123 {
124 pPage = dynamic_cast< SdPage* >( pTextObj->getSdrPageFromSdrObject() );
125 }
126 }
127
128 if(pPage)
129 {
130 bMasterView = pPage->IsMasterPage();
131 }
132 }
133
134 return pPage;
135}
136
140IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo, void)
141{
142 if (!pInfo)
143 return;
144
145 const SvxFieldData* pField = pInfo->GetField().GetField();
146 ::sd::DrawDocShell* pDocShell = nullptr;
147 SdDrawDocument* pDoc = nullptr;
148
149 SdrOutliner* pSdrOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
150 if( pSdrOutliner )
151 {
152 const SdrTextObj* pTextObj = pSdrOutliner->GetTextObj();
153
154 if( pTextObj )
155 pDoc = dynamic_cast< SdDrawDocument* >( &pTextObj->getSdrModelFromSdrObject() );
156
157 if( pDoc )
158 pDocShell = pDoc->GetDocSh();
159 }
160
161 if( !pDocShell )
162 pDocShell = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
163
164 const SvxDateField* pDateField = nullptr;
165 const SvxExtTimeField* pExtTimeField = nullptr;
166 const SvxExtFileField* pExtFileField = nullptr;
167 const SvxAuthorField* pAuthorField = nullptr;
168 const SvxURLField* pURLField = nullptr;
169
170 const editeng::CustomPropertyField* pCustomPropertyField = nullptr;
171
172 if( (pDateField = dynamic_cast< const SvxDateField* >(pField)) != nullptr )
173 {
174 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
175 pInfo->SetRepresentation( pDateField->GetFormatted( *GetNumberFormatter(), eLang ) );
176 }
177 else if( (pExtTimeField = dynamic_cast< const SvxExtTimeField *>(pField)) != nullptr )
178 {
179 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
180 pInfo->SetRepresentation( pExtTimeField->GetFormatted( *GetNumberFormatter(), eLang ) );
181 }
182 else if( (pExtFileField = dynamic_cast< const SvxExtFileField * >(pField)) != nullptr )
183 {
184 if( pDocShell && (pExtFileField->GetType() != SvxFileType::Fix) )
185 {
186 OUString aName;
187 if( pDocShell->HasName() )
188 aName = pDocShell->GetMedium()->GetName();
189 else
190 aName = pDocShell->GetName();
191
192 const_cast< SvxExtFileField* >(pExtFileField)->SetFile( aName );
193 }
194 pInfo->SetRepresentation( pExtFileField->GetFormatted() );
195
196 }
197 else if( (pAuthorField = dynamic_cast< const SvxAuthorField* >( pField )) != nullptr )
198 {
199 if( pAuthorField->GetType() != SvxAuthorType::Fix )
200 {
201 SvtUserOptions aUserOptions;
202 SvxAuthorField aAuthorField(
203 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID(),
204 pAuthorField->GetType(), pAuthorField->GetFormat() );
205
206 *const_cast< SvxAuthorField* >(pAuthorField) = aAuthorField;
207 }
208 pInfo->SetRepresentation( pAuthorField->GetFormatted() );
209
210 }
211 else if( dynamic_cast< const SvxPageField* >(pField) )
212 {
213 OUString aRepresentation(" ");
214
215 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : nullptr;
216 if(pViewSh == nullptr)
217 {
218 ::sd::ViewShellBase* pBase = dynamic_cast< ::sd::ViewShellBase *>( SfxViewShell::Current() );
219 if(pBase)
220 pViewSh = pBase->GetMainViewShell().get();
221 }
222 if( !pDoc && pViewSh )
223 pDoc = pViewSh->GetDoc();
224
225 bool bMasterView;
226 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
227
228 if( pPage && pDoc && !bMasterView )
229 {
230 int nPgNum;
231
232 if( (pPage->GetPageKind() == PageKind::Handout) && pViewSh )
233 {
234 nPgNum = pViewSh->GetPrintedHandoutPageNum();
235 }
236 else
237 {
238 nPgNum = (pPage->GetPageNum() - 1) / 2 + 1;
239 }
240 aRepresentation = pDoc->CreatePageNumValue(static_cast<sal_uInt16>(nPgNum));
241 }
242 else
243 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_NUMBER);
244
245 pInfo->SetRepresentation( aRepresentation );
246 }
247 else if( dynamic_cast< const SvxPageTitleField* >(pField) )
248 {
249 OUString aRepresentation(" ");
250
251 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : nullptr;
252 if(pViewSh == nullptr)
253 {
254 ::sd::ViewShellBase* pBase = dynamic_cast< ::sd::ViewShellBase *>( SfxViewShell::Current() );
255 if(pBase)
256 pViewSh = pBase->GetMainViewShell().get();
257 }
258 if( !pDoc && pViewSh )
259 pDoc = pViewSh->GetDoc();
260
261 bool bMasterView;
262 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
263
264 if( pPage && pDoc && !bMasterView )
265 {
266 aRepresentation = pPage->GetName();
267 }
268 else
269 {
270 DocumentType eDocType = pDoc ? pDoc->GetDocumentType() : DocumentType::Impress;
271 aRepresentation = ( ( eDocType == DocumentType::Impress )
272 ? SdResId(STR_FIELD_PLACEHOLDER_SLIDENAME)
273 : SdResId(STR_FIELD_PLACEHOLDER_PAGENAME) );
274 }
275
276 pInfo->SetRepresentation( aRepresentation );
277 }
278 else if( dynamic_cast< const SvxPagesField* >(pField) )
279 {
280 OUString aRepresentation(" ");
281
282 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : nullptr;
283 if(pViewSh == nullptr)
284 {
285 ::sd::ViewShellBase* pBase = dynamic_cast< ::sd::ViewShellBase *>( SfxViewShell::Current() );
286 if(pBase)
287 pViewSh = pBase->GetMainViewShell().get();
288 }
289 if( !pDoc && pViewSh )
290 pDoc = pViewSh->GetDoc();
291
292 bool bMasterView;
293 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
294
295 sal_uInt16 nPageCount = 0;
296
297 if( !bMasterView )
298 {
299 if( pPage && (pPage->GetPageKind() == PageKind::Handout) && pViewSh )
300 {
301 nPageCount = pViewSh->GetPrintedHandoutPageCount();
302 }
303 else if( pDoc )
304 {
305 nPageCount = pDoc->GetActiveSdPageCount();
306 }
307 }
308
309 if( nPageCount > 0 )
310 aRepresentation = pDoc->CreatePageNumValue(nPageCount);
311 else
312 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_COUNT);
313
314 pInfo->SetRepresentation( aRepresentation );
315 }
316 else if( (pURLField = dynamic_cast< const SvxURLField* >(pField)) != nullptr )
317 {
318 switch ( pURLField->GetFormat() )
319 {
320 case SvxURLFormat::AppDefault:
321 case SvxURLFormat::Repr:
322 pInfo->SetRepresentation( pURLField->GetRepresentation() );
323 break;
324
325 case SvxURLFormat::Url:
326 pInfo->SetRepresentation( pURLField->GetURL() );
327 break;
328 }
329
330 const OUString& aURL = pURLField->GetURL();
331
332 svtools::ColorConfig aConfig;
335 pInfo->SetTextColor( aConfig.GetColorValue(eEntry).nColor );
336 }
337 else if ( dynamic_cast< const SdrMeasureField* >(pField))
338 {
339 pInfo->SetFieldColor(std::optional<Color>()); // clear the field color
340 }
341 else if ((pCustomPropertyField = dynamic_cast<const editeng::CustomPropertyField*>(pField)) != nullptr)
342 {
343 try
344 {
346 if (pObjSh && pObjSh->IsLoadingFinished())
347 {
348 auto pNonConstCustomPropertyField = const_cast<editeng::CustomPropertyField*>(pCustomPropertyField);
349 OUString sCurrent = pNonConstCustomPropertyField->GetFormatted(pObjSh->getDocProperties());
350 pInfo->SetRepresentation(sCurrent);
351 }
352 else
353 pInfo->SetRepresentation(pCustomPropertyField->GetCurrentPresentation());
354 }
355 catch (...)
356 {
357 pInfo->SetRepresentation(pCustomPropertyField->GetCurrentPresentation());
358 }
359 }
360 else
361 {
362 OUString aRepresentation;
363
364 bool bHeaderField = dynamic_cast< const SvxHeaderField* >( pField ) != nullptr;
365 bool bFooterField = !bHeaderField && (dynamic_cast< const SvxFooterField* >( pField ) != nullptr );
366 bool bDateTimeField = !bHeaderField && !bFooterField && (dynamic_cast< const SvxDateTimeField* >( pField ) != nullptr);
367
368 if( bHeaderField || bFooterField || bDateTimeField )
369 {
370 sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : nullptr;
371 bool bMasterView = false;
372 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
373
374 if( (pPage == nullptr) || bMasterView )
375 {
376 if( bHeaderField )
377 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_HEADER);
378 else if (bFooterField )
379 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_FOOTER);
380 else if (bDateTimeField )
381 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_DATETIME);
382 }
383 else
384 {
385 const sd::HeaderFooterSettings &rSettings = pPage->getHeaderFooterSettings();
386
387 if( bHeaderField )
388 {
389 aRepresentation = rSettings.maHeaderText;
390 }
391 else if( bFooterField )
392 {
393 aRepresentation = rSettings.maFooterText;
394 }
395 else if( bDateTimeField )
396 {
397 if( rSettings.mbDateTimeIsFixed )
398 {
399 aRepresentation = rSettings.maDateTimeText;
400 }
401 else
402 {
403 DateTime aDateTime( DateTime::SYSTEM );
404 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
405 aRepresentation = SvxDateTimeField::GetFormatted( aDateTime, aDateTime,
406 rSettings.meDateFormat, rSettings.meTimeFormat, *GetNumberFormatter(), eLang );
407 }
408 }
409 }
410 }
411 else
412 {
413 OSL_FAIL("sd::SdModule::CalcFieldValueHdl(), unknown field type!");
414 }
415
416 if( aRepresentation.isEmpty() ) // TODO: Edit engine doesn't handle empty fields?
417 aRepresentation = " ";
418 pInfo->SetRepresentation( aRepresentation );
419 }
420}
421
425std::optional<SfxItemSet> SdModule::CreateItemSet( sal_uInt16 nSlot )
426{
427 ::sd::FrameView* pFrameView = nullptr;
428 ::sd::DrawDocShell* pDocSh = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
429 SdDrawDocument* pDoc = nullptr;
430
431 // Here we set the DocType of the option dialog (not document!)
433 if( nSlot == SID_SD_GRAPHIC_OPTIONS )
434 eDocType = DocumentType::Draw;
435
436 if (pDocSh)
437 {
438 pDoc = pDocSh->GetDoc();
439
440 // If the option dialog is identical to the document type,
441 // we can pass the FrameView too:
442 if( pDoc && eDocType == pDoc->GetDocumentType() )
443 pFrameView = pDocSh->GetFrameView();
444
445 ::sd::ViewShell* pViewShell = pDocSh->GetViewShell();
446 if (pViewShell != nullptr)
447 pViewShell->WriteFrameViewData();
448 }
449
450 SdOptions* pOptions = GetSdOptions(eDocType);
451
452 // Pool has by default MapUnit Twips (Awgh!)
453 SfxItemPool& rPool = GetPool();
454 rPool.SetDefaultMetric( MapUnit::Map100thMM );
455
457 SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS,
458 SID_ATTR_METRIC, SID_ATTR_METRIC,
459 SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP,
460 ATTR_OPTIONS_LAYOUT, ATTR_OPTIONS_SCALE_END> aRet(rPool);
461
462 // TP_OPTIONS_LAYOUT:
463 aRet.Put( SdOptionsLayoutItem( pOptions, pFrameView ) );
464
465 sal_uInt16 nDefTab = 0;
466 if( pFrameView)
467 nDefTab = pDoc->GetDefaultTabulator();
468 else
469 nDefTab = pOptions->GetDefTab();
470 aRet.Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, nDefTab ) );
471
472 FieldUnit nMetric = FieldUnit(0xffff);
473 if( pFrameView)
474 nMetric = pDoc->GetUIUnit();
475 else
476 nMetric = static_cast<FieldUnit>(pOptions->GetMetric());
477
478 if( nMetric == FieldUnit(0xffff) )
479 nMetric = GetFieldUnit();
480
481 aRet.Put( SfxUInt16Item( SID_ATTR_METRIC, static_cast<sal_uInt16>(nMetric) ) );
482
483 // TP_OPTIONS_MISC:
484 SdOptionsMiscItem aSdOptionsMiscItem( pOptions, pFrameView );
485 if ( pFrameView )
486 {
488 aSdOptionsMiscItem.GetOptionsMisc().SetPrinterIndependentLayout (
489 static_cast<sal_uInt16>(pDoc->GetPrinterIndependentLayout()));
490 }
491 aRet.Put( aSdOptionsMiscItem );
492
493 // TP_OPTIONS_SNAP:
494 aRet.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 )
502 {
503 SdrPage* pPage = pDoc->GetSdPage(0, PageKind::Standard);
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 aRet.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
522 aRet.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
523 aRet.Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_WIDTH, nW ) );
524 aRet.Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_HEIGHT, nH ) );
525
526 // TP_OPTIONS_PRINT:
527 aRet.Put( SdOptionsPrintItem( pOptions ) );
528
529 // RID_SVXPAGE_GRID:
530 aRet.Put( SdOptionsGridItem( pOptions ) );
531
532 return aRet;
533}
534
535void SdModule::ApplyItemSet( sal_uInt16 nSlot, const SfxItemSet& rSet )
536{
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!)
545 if( nSlot == SID_SD_GRAPHIC_OPTIONS )
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( const SdOptionsGridItem* pGridItem = static_cast<const SdOptionsGridItem*>(rSet.GetItemIfSet( SID_ATTR_GRID_OPTIONS, false )) )
561 {
562 pGridItem->SetOptions( pOptions );
563 }
564
565 // Layout
566 if( const SdOptionsLayoutItem* pLayoutItem = rSet.GetItemIfSet( ATTR_OPTIONS_LAYOUT, false ))
567 {
568 pLayoutItem->SetOptions( pOptions );
569 }
570
571 // Metric
572 if( const SfxUInt16Item* pItem = rSet.GetItemIfSet( SID_ATTR_METRIC, false ) )
573 {
574 if( pDoc && eDocType == pDoc->GetDocumentType() )
575 PutItem( *pItem );
576 pOptions->SetMetric( pItem->GetValue() );
577 }
578 sal_uInt16 nDefTab = pOptions->GetDefTab();
579 // Default-Tabulator
580 if( const SfxUInt16Item* pItem = rSet.GetItemIfSet( SID_ATTR_DEFTABSTOP, false ) )
581 {
582 nDefTab = pItem->GetValue();
583 pOptions->SetDefTab( nDefTab );
584
585 bNewDefTab = true;
586 }
587
588 // Scale
589 if( const SfxInt32Item* pItem = rSet.GetItemIfSet( ATTR_OPTIONS_SCALE_X, false ) )
590 {
591 sal_Int32 nX = pItem->GetValue();
592 pItem = rSet.GetItemIfSet( ATTR_OPTIONS_SCALE_Y, false );
593 if( pItem )
594 {
595 sal_Int32 nY = pItem->GetValue();
596 pOptions->SetScale( nX, nY );
597
598 // Apply to document only if doc type match
599 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
600 {
601 pDoc->SetUIScale( Fraction( nX, nY ) );
602 if( pViewShell )
603 pViewShell->SetRuler( pViewShell->HasRuler() );
604 }
605 }
606 }
607
608 // Misc
609 const SdOptionsMiscItem* pMiscItem = rSet.GetItemIfSet( ATTR_OPTIONS_MISC, false);
610 if( pMiscItem )
611 {
612 pMiscItem->SetOptions( pOptions );
613 bMiscOptions = true;
614 }
615
616 // Snap
617 const SdOptionsSnapItem* pSnapItem = rSet.GetItemIfSet( ATTR_OPTIONS_SNAP, false );
618 if( pSnapItem )
619 {
620 pSnapItem->SetOptions( pOptions );
621 }
622
623 SfxItemSetFixed<SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
624 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
625 ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT> aPrintSet( GetPool() );
626
627 // Print
628 const SdOptionsPrintItem* pPrintItem = rSet.GetItemIfSet( ATTR_OPTIONS_PRINT, false);
629 if( pPrintItem )
630 {
631 pPrintItem->SetOptions( pOptions );
632
633 // set PrintOptionsSet
634 SdOptionsPrintItem aPrintItem( pOptions );
635 SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC );
636 SfxPrinterChangeFlags nFlags =
637 (aPrintItem.GetOptionsPrint().IsWarningSize() ? SfxPrinterChangeFlags::CHG_SIZE : SfxPrinterChangeFlags::NONE) |
638 (aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SfxPrinterChangeFlags::CHG_ORIENTATION : SfxPrinterChangeFlags::NONE);
639 aFlagItem.SetValue( static_cast<int>(nFlags) );
640
641 aPrintSet.Put( aPrintItem );
642 aPrintSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
643 aPrintSet.Put( aFlagItem );
644
645 bNewPrintOptions = true;
646 }
647
648 // Only if also the document type matches...
649 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
650 {
651 if( bNewPrintOptions )
652 {
653 pDocSh->GetPrinter(true)->SetOptions( aPrintSet );
654 }
655
656 // set DefTab at Model
657 if( bNewDefTab )
658 {
659 SdDrawDocument* pDocument = pDocSh->GetDoc();
660 pDocument->SetDefaultTabulator( nDefTab );
661
662 SdOutliner* pOutl = pDocument->GetOutliner( false );
663 if( pOutl )
664 pOutl->SetDefTab( nDefTab );
665
666 SdOutliner* pInternalOutl = pDocument->GetInternalOutliner( false );
667 if( pInternalOutl )
668 pInternalOutl->SetDefTab( nDefTab );
669 }
670 if ( bMiscOptions )
671 {
673 EEControlBits nSum = pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() ? EEControlBits::ULSPACESUMMATION : EEControlBits::NONE;
674 EEControlBits nCntrl;
675
676 SdDrawDocument* pDocument = pDocSh->GetDoc();
677 SdrOutliner& rOutl = pDocument->GetDrawOutliner();
678 nCntrl = rOutl.GetControlWord() &~ EEControlBits::ULSPACESUMMATION;
679 rOutl.SetControlWord( nCntrl | nSum );
680 SdOutliner* pOutl = pDocument->GetOutliner( false );
681 if( pOutl )
682 {
683 nCntrl = pOutl->GetControlWord() &~ EEControlBits::ULSPACESUMMATION;
684 pOutl->SetControlWord( nCntrl | nSum );
685 }
686 pOutl = pDocument->GetInternalOutliner( false );
687 if( pOutl )
688 {
689 nCntrl = pOutl->GetControlWord() &~ EEControlBits::ULSPACESUMMATION;
690 pOutl->SetControlWord( nCntrl | nSum );
691 }
692
693 // Set printer independent layout mode.
696 }
697 }
698
699 pOptions->StoreConfig();
700
701 // Only if also the document type matches...
702 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
703 {
704 FieldUnit eUIUnit = static_cast<FieldUnit>(pOptions->GetMetric());
705 pDoc->SetUIUnit(eUIUnit);
706
707 if (pViewShell)
708 {
709 // make sure no one is in text edit mode, cause there
710 // are some pointers remembered else (!)
711 if(pViewShell->GetView())
712 pViewShell->GetView()->SdrEndTextEdit();
713
714 ::sd::FrameView* pFrame = pViewShell->GetFrameView();
715 pFrame->Update(pOptions);
716 pViewShell->ReadFrameViewData(pFrame);
717 pViewShell->SetUIUnit(eUIUnit);
718 pViewShell->SetDefTabHRuler( nDefTab );
719 }
720 }
721
722 if( pViewShell && pViewShell->GetViewFrame() )
723 pViewShell->GetViewFrame()->GetBindings().InvalidateAll( true );
724}
725
726std::unique_ptr<SfxTabPage> SdModule::CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet )
727{
728 std::unique_ptr<SfxTabPage> xRet;
729 SfxAllItemSet aSet(*(rSet.GetPool()));
731
732 switch(nId)
733 {
734 case SID_SD_TP_CONTENTS:
735 case SID_SI_TP_CONTENTS:
736 {
738 if( fnCreatePage )
739 xRet = (*fnCreatePage)( pPage, pController, &rSet );
740 }
741 break;
742 case SID_SD_TP_SNAP:
743 case SID_SI_TP_SNAP:
744 {
746 if( fnCreatePage )
747 xRet = (*fnCreatePage)( pPage, pController, &rSet );
748 }
749 break;
750 case SID_SD_TP_PRINT:
751 case SID_SI_TP_PRINT:
752 {
754 if( fnCreatePage )
755 {
756 xRet = (*fnCreatePage)( pPage, pController, &rSet );
757 if(SID_SD_TP_PRINT == nId)
758 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
759 xRet->PageCreated(aSet);
760 }
761 }
762 break;
763 case SID_SI_TP_MISC:
764 case SID_SD_TP_MISC:
765 {
767 if( fnCreatePage )
768 {
769 xRet = (*fnCreatePage)( pPage, pController, &rSet );
770 if(SID_SD_TP_MISC == nId)
771 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
772 else
773 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_IMPRESS_MODE));
774 xRet->PageCreated(aSet);
775 }
776 }
777 break;
778 case RID_SVXPAGE_TEXTANIMATION :
779 {
781 ::CreateTabPage fnCreatePage = pSfxFact->GetTabPageCreatorFunc( nId );
782 if ( fnCreatePage )
783 xRet = (*fnCreatePage)( pPage, pController, &rSet );
784 }
785 break;
786 }
787 DBG_ASSERT( xRet, "SdModule::CreateTabPage(): no valid ID for TabPage!" );
788
789 return xRet;
790}
791
792std::optional<SfxStyleFamilies> SdModule::CreateStyleFamilies()
793{
794 SfxStyleFamilies aStyleFamilies;
795
796 aStyleFamilies.emplace_back(SfxStyleFamily::Para,
797 SdResId(STR_GRAPHICS_STYLE_FAMILY),
798 BMP_STYLES_FAMILY_GRAPHICS,
799 RID_GRAPHICSTYLEFAMILY, SD_MOD()->GetResLocale());
800
801 aStyleFamilies.emplace_back(SfxStyleFamily::Pseudo,
802 SdResId(STR_PRESENTATIONS_STYLE_FAMILY),
803 BMP_STYLES_FAMILY_PRESENTATIONS,
804 RID_PRESENTATIONSTYLEFAMILY, SD_MOD()->GetResLocale());
805
806 return aStyleFamilies;
807}
808
809/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Outliner * GetOutliner() const
sal_Int32 GetPara() const
SdrPage * GetSdrPage() const
sal_Int32 GetNumerator() const
sal_Int32 GetDenominator() const
static INetURLHistory * GetOrCreate()
bool QueryUrl(const INetURLObject &rUrl) const
static bool HasParaFlag(const Paragraph *pPara, ParaFlag nFlag)
Paragraph * GetParagraph(sal_Int32 nAbsPos) const
virtual CreateTabPage GetSdPrintOptionsTabPageCreatorFunc()=0
virtual CreateTabPage GetSdOptionsContentsTabPageCreatorFunc()=0
static SD_DLLPUBLIC SdAbstractDialogFactory * Create()
Definition: sdabstdlg.cxx:38
virtual CreateTabPage GetSdOptionsMiscTabPageCreatorFunc()=0
virtual CreateTabPage GetSdOptionsSnapTabPageCreatorFunc()=0
SAL_DLLPRIVATE void SetPrinterIndependentLayout(sal_Int32 nMode)
Set the mode that controls whether (and later how) the formatting of the document depends on the curr...
Definition: drawdoc.cxx:1034
sal_uInt16 GetActiveSdPageCount() const
Definition: drawdoc2.cxx:227
SAL_DLLPRIVATE void SetSummationOfParagraphs(bool bOn=true)
Definition: drawdoc.hxx:405
SdPage * GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
Definition: drawdoc2.cxx:207
OUString CreatePageNumValue(sal_uInt16 nNum) const
Definition: drawdoc4.cxx:986
SAL_DLLPRIVATE bool IsSummationOfParagraphs() const
Definition: drawdoc.hxx:406
SdOutliner * GetInternalOutliner(bool bCreateOutliner=true)
Definition: drawdoc.cxx:930
SAL_DLLPRIVATE SdOutliner * GetOutliner(bool bCreateOutliner=true)
Definition: drawdoc.cxx:912
SAL_DLLPRIVATE sal_Int32 GetPrinterIndependentLayout() const
Get the flag that controls whether the formatting of the document depends on the current printer metr...
Definition: drawdoc.hxx:428
SAL_DLLPRIVATE::sd::DrawDocShell * GetDocSh() const
Definition: drawdoc.hxx:242
SAL_DLLPRIVATE DocumentType GetDocumentType() const
Definition: drawdoc.hxx:251
virtual std::unique_ptr< SfxTabPage > CreateTabPage(sal_uInt16 nId, weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet) override
Definition: sdmod2.cxx:726
virtual void ApplyItemSet(sal_uInt16 nId, const SfxItemSet &rSet) override
Definition: sdmod2.cxx:535
SdOptions * GetSdOptions(DocumentType eDocType)
Return options.
Definition: sdmod.cxx:126
virtual std::optional< SfxStyleFamilies > CreateStyleFamilies() override
Definition: sdmod2.cxx:792
virtual std::optional< SfxItemSet > CreateItemSet(sal_uInt16 nId) override
virtual methods for option dialog
Definition: sdmod2.cxx:425
void SetMetric(sal_uInt16 nInMetric)
Definition: optsitem.hxx:144
sal_uInt16 GetDefTab() const
Definition: optsitem.hxx:137
sal_uInt16 GetMetric() const
Definition: optsitem.hxx:136
void SetDefTab(sal_uInt16 nTab)
Definition: optsitem.hxx:145
SdOptionsMisc & GetOptionsMisc()
Definition: optsitem.hxx:334
void SetOptions(SdOptions *pOpts) const
Definition: optsitem.cxx:713
void SetSummationOfParagraphs(bool bOn)
Definition: optsitem.hxx:299
void SetPrinterIndependentLayout(sal_uInt16 nOn)
Set the printer independent layout mode.
Definition: optsitem.hxx:307
bool IsSummationOfParagraphs() const
Definition: optsitem.hxx:256
sal_uInt16 GetPrinterIndependentLayout() const
Return the currently selected printer independent layout mode.
Definition: optsitem.hxx:264
SdOptionsPrint & GetOptionsPrint()
Definition: optsitem.hxx:570
void SetOptions(SdOptions *pOpts) const
Definition: optsitem.cxx:1354
bool IsWarningSize() const
Definition: optsitem.hxx:524
bool IsWarningOrientation() const
Definition: optsitem.hxx:525
bool IsWarningPrinter() const
Definition: optsitem.hxx:523
void SetOptions(SdOptions *pOpts) const
Definition: optsitem.cxx:901
void GetScale(sal_Int32 &rX, sal_Int32 &rY) const
Definition: optsitem.hxx:424
void SetScale(sal_Int32 nInX, sal_Int32 nInY)
Definition: optsitem.hxx:425
void StoreConfig()
Definition: optsitem.cxx:1401
The main purpose of this class is searching and replacing as well as spelling of impress documents.
Definition: Outliner.hxx:123
PageKind GetPageKind() const
Definition: sdpage.hxx:205
const sd::HeaderFooterSettings & getHeaderFooterSettings() const
Definition: sdpage.cxx:2711
const OUString & GetName() const
Definition: sdpage.cxx:2505
void SetUIScale(const Fraction &rScale)
sal_uInt16 GetDefaultTabulator() const
void SetUIUnit(FieldUnit eUnit)
void SetDefaultTabulator(sal_uInt16 nVal)
SdrOutliner & GetDrawOutliner(const SdrTextObj *pObj=nullptr) const
FieldUnit GetUIUnit() const
const SdrTextObj * GetFormattingTextObj() const
const Fraction & GetUIScale() const
SdrModel & getSdrModelFromSdrObject() const
SdrPage * getSdrPageFromSdrObject() const
const SdrPage * getVisualizedPage() const
const SdrTextObj * GetTextObj() const
sal_uInt16 GetPageNum() const
bool IsMasterPage() const
Size GetSize() const
static SfxAbstractDialogFactory * Create()
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
void InvalidateAll(bool bWithMsg)
void SetValue(sal_uInt16 nNewVal)
void SetDefaultMetric(MapUnit eNewMetric)
SfxItemPool * GetPool() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const OUString & GetName() const
FieldUnit GetFieldUnit() const
std::locale GetResLocale() const
css::uno::Reference< css::document::XDocumentProperties > getDocProperties() const
bool IsLoadingFinished() const
bool HasName() const
SfxMedium * GetMedium() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
void SetOptions(const SfxItemSet &rNewOptions)
void PutItem(const SfxPoolItem &rItem)
SfxItemPool & GetPool() const
const OUString & GetName() const
SfxBindings & GetBindings()
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
constexpr tools::Long Height() const
constexpr tools::Long Width() const
OUString GetFirstName() const
OUString GetID() const
OUString GetLastName() const
SvxAuthorType GetType() const
OUString GetFormatted() const
SvxAuthorFormat GetFormat() const
OUString GetFormatted(SvNumberFormatter &rFormatter, LanguageType eLanguage) const
static OUString GetFormatted(Date const &rDate, tools::Time const &rTime, SvxDateFormat eDateFormat, SvxTimeFormat eTimeFormat, SvNumberFormatter &rFormatter, LanguageType eLanguage)
OUString GetFormatted() const
SvxFileType GetType() const
OUString GetFormatted(SvNumberFormatter &rFormatter, LanguageType eLanguage) const
const OUString & GetRepresentation() const
SvxURLFormat GetFormat() const
const OUString & GetURL() const
OUString GetFormatted(css::uno::Reference< css::document::XDocumentProperties > const &xDocumentProperties)
OUString const & GetCurrentPresentation() const
::sd::FrameView * GetFrameView()
Definition: docshel2.cxx:160
sd::ViewShell * GetViewShell()
SfxPrinter * GetPrinter(bool bCreate)
Creates (if necessary) and returns a SfxPrinter.
Definition: docshel4.cxx:95
SdDrawDocument * GetDoc()
View for MDIFrame.
Definition: FrameView.hxx:36
void Update(SdOptions const *pOptions)
Update with data from the specified SdOptions.
Definition: frmview.cxx:277
Show a textual overview of the text contents of all slides.
Derivative of sd::View for the outline mode |* .
Definition: OutlineView.hxx:55
SdrOutliner & GetOutliner()
Definition: OutlineView.hxx:82
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
std::shared_ptr< ViewShell > GetMainViewShell() const
Return the main view shell stacked on the called ViewShellBase object.
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
void SetUIUnit(FieldUnit eUnit)
Definition: viewshel.cxx:1054
SdDrawDocument * GetDoc() const
Definition: viewshel.cxx:1412
virtual void WriteFrameViewData()
Definition: viewshe2.cxx:620
sal_uInt16 GetPrintedHandoutPageNum() const
Definition: ViewShell.hxx:266
void SetRuler(bool bRuler)
Switch ruler on/off.
Definition: viewshe2.cxx:814
FrameView * GetFrameView()
Definition: ViewShell.hxx:221
::sd::View * GetView() const
Definition: ViewShell.hxx:144
virtual void ReadFrameViewData(FrameView *pView)
Definition: viewshe2.cxx:610
sal_uInt16 GetPrintedHandoutPageCount() const
Definition: ViewShell.hxx:269
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
void SetDefTabHRuler(sal_uInt16 nDefTab)
set DefTab at horizontal rulers
Definition: viewshel.cxx:1067
bool HasRuler() const
Definition: ViewShell.hxx:191
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false) override
ends current text editing
Definition: sdview.cxx:772
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
#define DBG_ASSERT(sCon, aError)
URL aURL
EEControlBits
FieldUnit
OUString aName
sal_uInt16 nPos
DocumentType
long Long
sal_Int16 nId
IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo *, pInfo, void)
Link for CalcFieldValue of Outliners.
Definition: sdmod2.cxx:140
static SdPage * GetCurrentPage(sd::ViewShell const *pViewSh, EditFieldInfo const *pInfo, bool &bMasterView)
retrieves the page that is currently painted.
Definition: sdmod2.cxx:66
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
#define SD_MOD()
Definition: sdmod.hxx:184
static SfxItemSet & rSet
SvxTimeFormat meTimeFormat
Definition: sdpage.hxx:75
SvxDateFormat meDateFormat
Definition: sdpage.hxx:74
std::vector< SfxStyleFamilyItem > SfxStyleFamilies
SfxPrinterChangeFlags