Bump version to 21.06.18.1
[LibreOffice.git] / sd / source / ui / app / sdmod2.cxx
blobd749d2c736447004f7fa120e0b0730176f508a19
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
32 #include <editeng/measfld.hxx>
33 #include <editeng/editstat.hxx>
35 #include <svx/svxids.hrc>
36 #include <svx/dialogs.hrc>
37 #include <svx/svdotext.hxx>
39 #include <sfx2/sfxdlg.hxx>
41 #include <sdmod.hxx>
42 #include <app.hrc>
43 #include <family.hrc>
44 #include <strings.hrc>
45 #include <sdattr.hrc>
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>
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*/
65 static SdPage* GetCurrentPage( sd::ViewShell const * pViewSh, EditFieldInfo const * pInfo, bool& bMasterView )
67 if( !pInfo )
68 return nullptr;
70 bMasterView = false;
71 SdPage* pPage = dynamic_cast< SdPage* >( pInfo->GetSdrPage() );
72 SdrOutliner* pOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
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 )
78 bMasterView = false;
79 return pPage;
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());
87 if (pSdView != nullptr && (pOutliner == &pSdView->GetOutliner()))
89 // outline mode
90 int nPgNum = 0;
91 Outliner& rOutl = pSdView->GetOutliner();
92 tools::Long nPos = pInfo->GetPara();
93 sal_Int32 nParaPos = 0;
95 for( Paragraph* pPara = rOutl.GetParagraph( 0 ); pPara && nPos >= 0; pPara = rOutl.GetParagraph( ++nParaPos ), nPos-- )
97 if( Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ) )
98 nPgNum++;
101 pPage = pViewSh->GetDoc()->GetSdPage( static_cast<sal_uInt16>(nPgNum), PageKind::Standard );
103 else
105 // draw mode, slide mode and preview. Get the processed page from the outliner
106 if(pOutliner)
108 pPage = dynamic_cast< SdPage* >(const_cast< SdrPage* >(pOutliner->getVisualizedPage()));
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.
115 // if all else failed, geht the current page from the object that is
116 // currently formatted from the document
117 if(!pPage)
119 const SdrTextObj* pTextObj = (pViewSh && pViewSh->GetDoc()) ? pViewSh->GetDoc()->GetFormattingTextObj() : nullptr;
121 if( pTextObj )
123 pPage = dynamic_cast< SdPage* >( pTextObj->getSdrPageFromSdrObject() );
127 if(pPage)
129 bMasterView = pPage->IsMasterPage();
133 return pPage;
137 * Link for CalcFieldValue of Outliners
139 IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo, void)
141 if (!pInfo)
142 return;
144 const SvxFieldData* pField = pInfo->GetField().GetField();
145 ::sd::DrawDocShell* pDocShell = nullptr;
146 SdDrawDocument* pDoc = nullptr;
148 SdrOutliner* pSdrOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
149 if( pSdrOutliner )
151 const SdrTextObj* pTextObj = pSdrOutliner->GetTextObj();
153 if( pTextObj )
154 pDoc = dynamic_cast< SdDrawDocument* >( &pTextObj->getSdrModelFromSdrObject() );
156 if( pDoc )
157 pDocShell = pDoc->GetDocSh();
160 if( !pDocShell )
161 pDocShell = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
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;
169 const editeng::CustomPropertyField* pCustomPropertyField = nullptr;
171 if( (pDateField = dynamic_cast< const SvxDateField* >(pField)) != nullptr )
173 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
174 pInfo->SetRepresentation( pDateField->GetFormatted( *GetNumberFormatter(), eLang ) );
176 else if( (pExtTimeField = dynamic_cast< const SvxExtTimeField *>(pField)) != nullptr )
178 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
179 pInfo->SetRepresentation( pExtTimeField->GetFormatted( *GetNumberFormatter(), eLang ) );
181 else if( (pExtFileField = dynamic_cast< const SvxExtFileField * >(pField)) != nullptr )
183 if( pDocShell && (pExtFileField->GetType() != SvxFileType::Fix) )
185 OUString aName;
186 if( pDocShell->HasName() )
187 aName = pDocShell->GetMedium()->GetName();
188 else
189 aName = pDocShell->GetName();
191 const_cast< SvxExtFileField* >(pExtFileField)->SetFile( aName );
193 pInfo->SetRepresentation( pExtFileField->GetFormatted() );
196 else if( (pAuthorField = dynamic_cast< const SvxAuthorField* >( pField )) != nullptr )
198 if( pAuthorField->GetType() != SvxAuthorType::Fix )
200 SvtUserOptions aUserOptions;
201 SvxAuthorField aAuthorField(
202 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID(),
203 pAuthorField->GetType(), pAuthorField->GetFormat() );
205 *const_cast< SvxAuthorField* >(pAuthorField) = aAuthorField;
207 pInfo->SetRepresentation( pAuthorField->GetFormatted() );
210 else if( dynamic_cast< const SvxPageField* >(pField) )
212 OUString aRepresentation(" ");
214 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : nullptr;
215 if(pViewSh == nullptr)
217 ::sd::ViewShellBase* pBase = dynamic_cast< ::sd::ViewShellBase *>( SfxViewShell::Current() );
218 if(pBase)
219 pViewSh = pBase->GetMainViewShell().get();
221 if( !pDoc && pViewSh )
222 pDoc = pViewSh->GetDoc();
224 bool bMasterView;
225 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
227 if( pPage && pDoc && !bMasterView )
229 int nPgNum;
231 if( (pPage->GetPageKind() == PageKind::Handout) && pViewSh )
233 nPgNum = pViewSh->GetPrintedHandoutPageNum();
235 else
237 nPgNum = (pPage->GetPageNum() - 1) / 2 + 1;
239 aRepresentation = pDoc->CreatePageNumValue(static_cast<sal_uInt16>(nPgNum));
241 else
242 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_NUMBER);
244 pInfo->SetRepresentation( aRepresentation );
246 else if( dynamic_cast< const SvxPageTitleField* >(pField) )
248 OUString aRepresentation(" ");
250 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : nullptr;
251 if(pViewSh == nullptr)
253 ::sd::ViewShellBase* pBase = dynamic_cast< ::sd::ViewShellBase *>( SfxViewShell::Current() );
254 if(pBase)
255 pViewSh = pBase->GetMainViewShell().get();
257 if( !pDoc && pViewSh )
258 pDoc = pViewSh->GetDoc();
260 bool bMasterView;
261 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
263 if( pPage && pDoc && !bMasterView )
265 aRepresentation = pPage->GetName();
267 else
269 DocumentType eDocType = pDoc ? pDoc->GetDocumentType() : DocumentType::Impress;
270 aRepresentation = ( ( eDocType == DocumentType::Impress )
271 ? SdResId(STR_FIELD_PLACEHOLDER_SLIDENAME)
272 : SdResId(STR_FIELD_PLACEHOLDER_PAGENAME) );
275 pInfo->SetRepresentation( aRepresentation );
277 else if( dynamic_cast< const SvxPagesField* >(pField) )
279 OUString aRepresentation(" ");
281 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : nullptr;
282 if(pViewSh == nullptr)
284 ::sd::ViewShellBase* pBase = dynamic_cast< ::sd::ViewShellBase *>( SfxViewShell::Current() );
285 if(pBase)
286 pViewSh = pBase->GetMainViewShell().get();
288 if( !pDoc && pViewSh )
289 pDoc = pViewSh->GetDoc();
291 bool bMasterView;
292 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
294 sal_uInt16 nPageCount = 0;
296 if( !bMasterView )
298 if( pPage && (pPage->GetPageKind() == PageKind::Handout) && pViewSh )
300 nPageCount = pViewSh->GetPrintedHandoutPageCount();
302 else if( pDoc )
304 nPageCount = pDoc->GetActiveSdPageCount();
308 if( nPageCount > 0 )
309 aRepresentation = pDoc->CreatePageNumValue(nPageCount);
310 else
311 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_COUNT);
313 pInfo->SetRepresentation( aRepresentation );
315 else if( (pURLField = dynamic_cast< const SvxURLField* >(pField)) != nullptr )
317 switch ( pURLField->GetFormat() )
319 case SvxURLFormat::AppDefault: //!!! adjustable at App???
320 case SvxURLFormat::Repr:
321 pInfo->SetRepresentation( pURLField->GetRepresentation() );
322 break;
324 case SvxURLFormat::Url:
325 pInfo->SetRepresentation( pURLField->GetURL() );
326 break;
329 const OUString& aURL = pURLField->GetURL();
331 svtools::ColorConfig aConfig;
332 svtools::ColorConfigEntry eEntry =
333 INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS;
334 pInfo->SetTextColor( aConfig.GetColorValue(eEntry).nColor );
336 else if ( dynamic_cast< const SdrMeasureField* >(pField))
338 pInfo->SetFieldColor(std::optional<Color>()); // clear the field color
340 else if ((pCustomPropertyField = dynamic_cast<const editeng::CustomPropertyField*>(pField)) != nullptr)
344 if (SfxObjectShell::Current() && SfxObjectShell::Current()->IsLoadingFinished())
346 auto pNonConstCustomPropertyField = const_cast<editeng::CustomPropertyField*>(pCustomPropertyField);
347 OUString sCurrent = pNonConstCustomPropertyField->GetFormatted(SfxObjectShell::Current()->getDocProperties());
348 pInfo->SetRepresentation(sCurrent);
350 else
351 pInfo->SetRepresentation(pCustomPropertyField->GetCurrentPresentation());
353 catch (...)
355 pInfo->SetRepresentation(pCustomPropertyField->GetCurrentPresentation());
358 else
360 OUString aRepresentation;
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);
366 if( bHeaderField || bFooterField || bDateTimeField )
368 sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : nullptr;
369 bool bMasterView = false;
370 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
372 if( (pPage == nullptr) || bMasterView )
374 if( bHeaderField )
375 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_HEADER);
376 else if (bFooterField )
377 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_FOOTER);
378 else if (bDateTimeField )
379 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_DATETIME);
381 else
383 const sd::HeaderFooterSettings &rSettings = pPage->getHeaderFooterSettings();
385 if( bHeaderField )
387 aRepresentation = rSettings.maHeaderText;
389 else if( bFooterField )
391 aRepresentation = rSettings.maFooterText;
393 else if( bDateTimeField )
395 if( rSettings.mbDateTimeIsFixed )
397 aRepresentation = rSettings.maDateTimeText;
399 else
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 );
409 else
411 OSL_FAIL("sd::SdModule::CalcFieldValueHdl(), unknown field type!");
414 if( aRepresentation.isEmpty() ) // TODO: Edit engine doesn't handle empty fields?
415 aRepresentation = " ";
416 pInfo->SetRepresentation( aRepresentation );
421 * virtual methods for option dialog
423 std::unique_ptr<SfxItemSet> SdModule::CreateItemSet( sal_uInt16 nSlot )
425 ::sd::FrameView* pFrameView = nullptr;
426 ::sd::DrawDocShell* pDocSh = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
427 SdDrawDocument* pDoc = nullptr;
429 // Here we set the DocType of the option dialog (not document!)
430 DocumentType eDocType = DocumentType::Impress;
431 if( nSlot == SID_SD_GRAPHIC_OPTIONS )
432 eDocType = DocumentType::Draw;
434 if (pDocSh)
436 pDoc = pDocSh->GetDoc();
438 // If the option dialog is identical to the document type,
439 // we can pass the FrameView too:
440 if( pDoc && eDocType == pDoc->GetDocumentType() )
441 pFrameView = pDocSh->GetFrameView();
443 ::sd::ViewShell* pViewShell = pDocSh->GetViewShell();
444 if (pViewShell != nullptr)
445 pViewShell->WriteFrameViewData();
448 SdOptions* pOptions = GetSdOptions(eDocType);
450 // Pool has by default MapUnit Twips (Awgh!)
451 SfxItemPool& rPool = GetPool();
452 rPool.SetDefaultMetric( MapUnit::Map100thMM );
454 auto pRet = std::make_unique<SfxItemSet>(
455 rPool,
456 svl::Items<
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>{});
462 // TP_OPTIONS_LAYOUT:
463 pRet->Put( SdOptionsLayoutItem( pOptions, pFrameView ) );
465 sal_uInt16 nDefTab = 0;
466 if( pFrameView)
467 nDefTab = pDoc->GetDefaultTabulator();
468 else
469 nDefTab = pOptions->GetDefTab();
470 pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, nDefTab ) );
472 FieldUnit nMetric = FieldUnit(0xffff);
473 if( pFrameView)
474 nMetric = pDoc->GetUIUnit();
475 else
476 nMetric = static_cast<FieldUnit>(pOptions->GetMetric());
478 if( nMetric == FieldUnit(0xffff) )
479 nMetric = GetFieldUnit();
481 pRet->Put( SfxUInt16Item( SID_ATTR_METRIC, static_cast<sal_uInt16>(nMetric) ) );
483 // TP_OPTIONS_MISC:
484 SdOptionsMiscItem aSdOptionsMiscItem( pOptions, pFrameView );
485 if ( pFrameView )
487 aSdOptionsMiscItem.GetOptionsMisc().SetSummationOfParagraphs( pDoc->IsSummationOfParagraphs() );
488 aSdOptionsMiscItem.GetOptionsMisc().SetPrinterIndependentLayout (
489 static_cast<sal_uInt16>(pDoc->GetPrinterIndependentLayout()));
491 pRet->Put( aSdOptionsMiscItem );
493 // TP_OPTIONS_SNAP:
494 pRet->Put( SdOptionsSnapItem( pOptions, pFrameView ) );
496 // TP_SCALE:
497 sal_uInt32 nW = 10;
498 sal_uInt32 nH = 10;
499 sal_Int32 nX;
500 sal_Int32 nY;
501 if( pDocSh )
503 SdrPage* pPage = pDoc->GetSdPage(0, PageKind::Standard);
504 Size aSize(pPage->GetSize());
505 nW = aSize.Width();
506 nH = aSize.Height();
509 if(pFrameView)
511 const Fraction& rFraction = pDoc->GetUIScale();
512 nX=rFraction.GetNumerator();
513 nY=rFraction.GetDenominator();
515 else
517 // Get options from configuration file
518 pOptions->GetScale( nX, nY );
521 pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
522 pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
523 pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_WIDTH, nW ) );
524 pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_HEIGHT, nH ) );
526 // TP_OPTIONS_PRINT:
527 pRet->Put( SdOptionsPrintItem( pOptions ) );
529 // RID_SVXPAGE_GRID:
530 pRet->Put( SdOptionsGridItem( pOptions ) );
532 return pRet;
534 void SdModule::ApplyItemSet( sal_uInt16 nSlot, const SfxItemSet& rSet )
536 const SfxPoolItem* pItem = nullptr;
537 bool bNewDefTab = false;
538 bool bNewPrintOptions = false;
539 bool bMiscOptions = false;
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 )
546 eDocType = DocumentType::Draw;
548 ::sd::ViewShell* pViewShell = nullptr;
550 if (pDocSh)
552 pDoc = pDocSh->GetDoc();
554 pViewShell = pDocSh->GetViewShell();
555 if (pViewShell != nullptr)
556 pViewShell->WriteFrameViewData();
558 SdOptions* pOptions = GetSdOptions(eDocType);
559 // Grid
560 if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS ,
561 false, &pItem ))
563 const SdOptionsGridItem* pGridItem = static_cast<const SdOptionsGridItem*>(pItem);
564 pGridItem->SetOptions( pOptions );
567 // Layout
568 const SdOptionsLayoutItem* pLayoutItem = nullptr;
569 if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_LAYOUT,
570 false, reinterpret_cast<const SfxPoolItem**>(&pLayoutItem) ))
572 pLayoutItem->SetOptions( pOptions );
575 // Metric
576 if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_METRIC, false, &pItem ) )
578 if( pDoc && eDocType == pDoc->GetDocumentType() )
579 PutItem( *pItem );
580 pOptions->SetMetric( static_cast<const SfxUInt16Item*>( pItem )->GetValue() );
582 sal_uInt16 nDefTab = pOptions->GetDefTab();
583 // Default-Tabulator
584 if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_DEFTABSTOP, false, &pItem ) )
586 nDefTab = static_cast<const SfxUInt16Item*>( pItem )->GetValue();
587 pOptions->SetDefTab( nDefTab );
589 bNewDefTab = true;
592 // Scale
593 if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_X, false, &pItem ) )
595 sal_Int32 nX = static_cast<const SfxInt32Item*>( pItem )->GetValue();
596 if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_Y, false, &pItem ) )
598 sal_Int32 nY = static_cast<const SfxInt32Item*>( pItem )->GetValue();
599 pOptions->SetScale( nX, nY );
601 // Apply to document only if doc type match
602 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
604 pDoc->SetUIScale( Fraction( nX, nY ) );
605 if( pViewShell )
606 pViewShell->SetRuler( pViewShell->HasRuler() );
611 // Misc
612 const SdOptionsMiscItem* pMiscItem = nullptr;
613 if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_MISC,
614 false, reinterpret_cast<const SfxPoolItem**>(&pMiscItem) ))
616 pMiscItem->SetOptions( pOptions );
617 bMiscOptions = true;
620 // Snap
621 const SdOptionsSnapItem* pSnapItem = nullptr;
622 if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_SNAP,
623 false, reinterpret_cast<const SfxPoolItem**>(&pSnapItem) ))
625 pSnapItem->SetOptions( pOptions );
628 SfxItemSet aPrintSet( GetPool(),
629 svl::Items<SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
630 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
631 ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT>{} );
633 // Print
634 const SdOptionsPrintItem* pPrintItem = nullptr;
635 if( SfxItemState::SET == rSet.GetItemState( ATTR_OPTIONS_PRINT,
636 false, reinterpret_cast<const SfxPoolItem**>(&pPrintItem) ))
638 pPrintItem->SetOptions( pOptions );
640 // set PrintOptionsSet
641 SdOptionsPrintItem aPrintItem( pOptions );
642 SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC );
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) );
648 aPrintSet.Put( aPrintItem );
649 aPrintSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
650 aPrintSet.Put( aFlagItem );
652 bNewPrintOptions = true;
655 // Only if also the document type matches...
656 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
658 if( bNewPrintOptions )
660 pDocSh->GetPrinter(true)->SetOptions( aPrintSet );
663 // set DefTab at Model
664 if( bNewDefTab )
666 SdDrawDocument* pDocument = pDocSh->GetDoc();
667 pDocument->SetDefaultTabulator( nDefTab );
669 SdOutliner* pOutl = pDocument->GetOutliner( false );
670 if( pOutl )
671 pOutl->SetDefTab( nDefTab );
673 SdOutliner* pInternalOutl = pDocument->GetInternalOutliner( false );
674 if( pInternalOutl )
675 pInternalOutl->SetDefTab( nDefTab );
677 if ( bMiscOptions )
679 pDoc->SetSummationOfParagraphs( pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() );
680 EEControlBits nSum = pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() ? EEControlBits::ULSPACESUMMATION : EEControlBits::NONE;
681 EEControlBits nCntrl;
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 )
690 nCntrl = pOutl->GetControlWord() &~ EEControlBits::ULSPACESUMMATION;
691 pOutl->SetControlWord( nCntrl | nSum );
693 pOutl = pDocument->GetInternalOutliner( false );
694 if( pOutl )
696 nCntrl = pOutl->GetControlWord() &~ EEControlBits::ULSPACESUMMATION;
697 pOutl->SetControlWord( nCntrl | nSum );
700 // Set printer independent layout mode.
701 if( pDoc->GetPrinterIndependentLayout() != pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout() )
702 pDoc->SetPrinterIndependentLayout (pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout());
706 pOptions->StoreConfig();
708 // Only if also the document type matches...
709 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
711 FieldUnit eUIUnit = static_cast<FieldUnit>(pOptions->GetMetric());
712 pDoc->SetUIUnit(eUIUnit);
714 if (pViewShell)
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();
721 ::sd::FrameView* pFrame = pViewShell->GetFrameView();
722 pFrame->Update(pOptions);
723 pViewShell->ReadFrameViewData(pFrame);
724 pViewShell->SetUIUnit(eUIUnit);
725 pViewShell->SetDefTabHRuler( nDefTab );
729 if( pViewShell && pViewShell->GetViewFrame() )
730 pViewShell->GetViewFrame()->GetBindings().InvalidateAll( true );
733 std::unique_ptr<SfxTabPage> SdModule::CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet )
735 std::unique_ptr<SfxTabPage> xRet;
736 SfxAllItemSet aSet(*(rSet.GetPool()));
737 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
739 switch(nId)
741 case SID_SD_TP_CONTENTS:
742 case SID_SI_TP_CONTENTS:
744 ::CreateTabPage fnCreatePage = pFact->GetSdOptionsContentsTabPageCreatorFunc();
745 if( fnCreatePage )
746 xRet = (*fnCreatePage)( pPage, pController, &rSet );
748 break;
749 case SID_SD_TP_SNAP:
750 case SID_SI_TP_SNAP:
752 ::CreateTabPage fnCreatePage = pFact->GetSdOptionsSnapTabPageCreatorFunc();
753 if( fnCreatePage )
754 xRet = (*fnCreatePage)( pPage, pController, &rSet );
756 break;
757 case SID_SD_TP_PRINT:
758 case SID_SI_TP_PRINT:
760 ::CreateTabPage fnCreatePage = pFact->GetSdPrintOptionsTabPageCreatorFunc();
761 if( fnCreatePage )
763 xRet = (*fnCreatePage)( pPage, pController, &rSet );
764 if(SID_SD_TP_PRINT == nId)
765 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
766 xRet->PageCreated(aSet);
769 break;
770 case SID_SI_TP_MISC:
771 case SID_SD_TP_MISC:
773 ::CreateTabPage fnCreatePage = pFact->GetSdOptionsMiscTabPageCreatorFunc();
774 if( fnCreatePage )
776 xRet = (*fnCreatePage)( pPage, pController, &rSet );
777 if(SID_SD_TP_MISC == nId)
778 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
779 else
780 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_IMPRESS_MODE));
781 xRet->PageCreated(aSet);
784 break;
785 case RID_SVXPAGE_TEXTANIMATION :
787 SfxAbstractDialogFactory* pSfxFact = SfxAbstractDialogFactory::Create();
788 ::CreateTabPage fnCreatePage = pSfxFact->GetTabPageCreatorFunc( nId );
789 if ( fnCreatePage )
790 xRet = (*fnCreatePage)( pPage, pController, &rSet );
792 break;
794 DBG_ASSERT( xRet, "SdModule::CreateTabPage(): no valid ID for TabPage!" );
796 return xRet;
799 std::unique_ptr<SfxStyleFamilies> SdModule::CreateStyleFamilies()
801 std::unique_ptr<SfxStyleFamilies> pStyleFamilies(new SfxStyleFamilies);
803 pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para,
804 SdResId(STR_GRAPHICS_STYLE_FAMILY),
805 BMP_STYLES_FAMILY_GRAPHICS,
806 RID_GRAPHICSTYLEFAMILY, SD_MOD()->GetResLocale()));
808 pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Pseudo,
809 SdResId(STR_PRESENTATIONS_STYLE_FAMILY),
810 BMP_STYLES_FAMILY_PRESENTATIONS,
811 RID_PRESENTATIONSTYLEFAMILY, SD_MOD()->GetResLocale()));
813 return pStyleFamilies;
816 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */