1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
31 #include <osl/diagnose.h>
33 #include <editeng/measfld.hxx>
34 #include <editeng/editstat.hxx>
36 #include <svx/svxids.hrc>
37 #include <svx/dialogs.hrc>
38 #include <svx/svdotext.hxx>
40 #include <sfx2/sfxdlg.hxx>
45 #include <strings.hrc>
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>
57 #include <OutlineViewShell.hxx>
58 #include <OutlineView.hxx>
59 #include <ViewShellBase.hxx>
61 #include <sdabstdlg.hxx>
62 #include <svl/intitem.hxx>
64 /** retrieves the page that is currently painted. This will only be the master page
65 if the current drawn view only shows the master page*/
66 static SdPage
* GetCurrentPage( sd::ViewShell
const * pViewSh
, EditFieldInfo
const * pInfo
, bool& bMasterView
)
72 SdPage
* pPage
= dynamic_cast< SdPage
* >( pInfo
->GetSdrPage() );
73 SdrOutliner
* pOutliner
= dynamic_cast< SdrOutliner
* >( pInfo
->GetOutliner() );
75 // special case, someone already set the current page on the EditFieldInfo
76 // This is used from the svx::UnoGraphicsExporter f.e.
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());
88 if (pSdView
!= nullptr && (pOutliner
== &pSdView
->GetOutliner()))
92 Outliner
& rOutl
= pSdView
->GetOutliner();
93 tools::Long nPos
= pInfo
->GetPara();
94 sal_Int32 nParaPos
= 0;
96 for( Paragraph
* pPara
= rOutl
.GetParagraph( 0 ); pPara
&& nPos
>= 0; pPara
= rOutl
.GetParagraph( ++nParaPos
), nPos
-- )
98 if( Outliner::HasParaFlag( pPara
, ParaFlag::ISPAGE
) )
102 pPage
= pViewSh
->GetDoc()->GetSdPage( static_cast<sal_uInt16
>(nPgNum
), PageKind::Standard
);
106 // draw mode, slide mode and preview. Get the processed page from the outliner
109 pPage
= dynamic_cast< SdPage
* >(const_cast< SdrPage
* >(pOutliner
->getVisualizedPage()));
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.
116 // if all else failed, geht the current page from the object that is
117 // currently formatted from the document
120 const SdrTextObj
* pTextObj
= (pViewSh
&& pViewSh
->GetDoc()) ? pViewSh
->GetDoc()->GetFormattingTextObj() : nullptr;
124 pPage
= dynamic_cast< SdPage
* >( pTextObj
->getSdrPageFromSdrObject() );
130 bMasterView
= pPage
->IsMasterPage();
138 * Link for CalcFieldValue of Outliners
140 IMPL_LINK(SdModule
, CalcFieldValueHdl
, EditFieldInfo
*, pInfo
, void)
145 const SvxFieldData
* pField
= pInfo
->GetField().GetField();
146 ::sd::DrawDocShell
* pDocShell
= nullptr;
147 SdDrawDocument
* pDoc
= nullptr;
149 SdrOutliner
* pSdrOutliner
= dynamic_cast< SdrOutliner
* >( pInfo
->GetOutliner() );
152 const SdrTextObj
* pTextObj
= pSdrOutliner
->GetTextObj();
155 pDoc
= dynamic_cast< SdDrawDocument
* >( &pTextObj
->getSdrModelFromSdrObject() );
158 pDocShell
= pDoc
->GetDocSh();
162 pDocShell
= dynamic_cast< ::sd::DrawDocShell
*>( SfxObjectShell::Current() );
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;
170 const editeng::CustomPropertyField
* pCustomPropertyField
= nullptr;
172 if( (pDateField
= dynamic_cast< const SvxDateField
* >(pField
)) != nullptr )
174 LanguageType eLang
= pInfo
->GetOutliner()->GetLanguage( pInfo
->GetPara(), pInfo
->GetPos() );
175 pInfo
->SetRepresentation( pDateField
->GetFormatted( *GetNumberFormatter(), eLang
) );
177 else if( (pExtTimeField
= dynamic_cast< const SvxExtTimeField
*>(pField
)) != nullptr )
179 LanguageType eLang
= pInfo
->GetOutliner()->GetLanguage( pInfo
->GetPara(), pInfo
->GetPos() );
180 pInfo
->SetRepresentation( pExtTimeField
->GetFormatted( *GetNumberFormatter(), eLang
) );
182 else if( (pExtFileField
= dynamic_cast< const SvxExtFileField
* >(pField
)) != nullptr )
184 if( pDocShell
&& (pExtFileField
->GetType() != SvxFileType::Fix
) )
187 if( pDocShell
->HasName() )
188 aName
= pDocShell
->GetMedium()->GetName();
190 aName
= pDocShell
->GetName();
192 const_cast< SvxExtFileField
* >(pExtFileField
)->SetFile( aName
);
194 pInfo
->SetRepresentation( pExtFileField
->GetFormatted() );
197 else if( (pAuthorField
= dynamic_cast< const SvxAuthorField
* >( pField
)) != nullptr )
199 if( pAuthorField
->GetType() != SvxAuthorType::Fix
)
201 SvtUserOptions aUserOptions
;
202 SvxAuthorField
aAuthorField(
203 aUserOptions
.GetFirstName(), aUserOptions
.GetLastName(), aUserOptions
.GetID(),
204 pAuthorField
->GetType(), pAuthorField
->GetFormat() );
206 *const_cast< SvxAuthorField
* >(pAuthorField
) = aAuthorField
;
208 pInfo
->SetRepresentation( pAuthorField
->GetFormatted() );
211 else if( dynamic_cast< const SvxPageField
* >(pField
) )
213 OUString
aRepresentation(" ");
215 ::sd::ViewShell
* pViewSh
= pDocShell
? pDocShell
->GetViewShell() : nullptr;
216 if(pViewSh
== nullptr)
218 ::sd::ViewShellBase
* pBase
= dynamic_cast< ::sd::ViewShellBase
*>( SfxViewShell::Current() );
220 pViewSh
= pBase
->GetMainViewShell().get();
222 if( !pDoc
&& pViewSh
)
223 pDoc
= pViewSh
->GetDoc();
226 SdPage
* pPage
= GetCurrentPage( pViewSh
, pInfo
, bMasterView
);
228 if( pPage
&& pDoc
&& !bMasterView
)
232 if( (pPage
->GetPageKind() == PageKind::Handout
) && pViewSh
)
234 nPgNum
= pViewSh
->GetPrintedHandoutPageNum();
238 nPgNum
= (pPage
->GetPageNum() - 1) / 2 + 1;
240 aRepresentation
= pDoc
->CreatePageNumValue(static_cast<sal_uInt16
>(nPgNum
));
243 aRepresentation
= SdResId(STR_FIELD_PLACEHOLDER_NUMBER
);
245 pInfo
->SetRepresentation( aRepresentation
);
247 else if( dynamic_cast< const SvxPageTitleField
* >(pField
) )
249 OUString
aRepresentation(" ");
251 ::sd::ViewShell
* pViewSh
= pDocShell
? pDocShell
->GetViewShell() : nullptr;
252 if(pViewSh
== nullptr)
254 ::sd::ViewShellBase
* pBase
= dynamic_cast< ::sd::ViewShellBase
*>( SfxViewShell::Current() );
256 pViewSh
= pBase
->GetMainViewShell().get();
258 if( !pDoc
&& pViewSh
)
259 pDoc
= pViewSh
->GetDoc();
262 SdPage
* pPage
= GetCurrentPage( pViewSh
, pInfo
, bMasterView
);
264 if( pPage
&& pDoc
&& !bMasterView
)
266 aRepresentation
= pPage
->GetName();
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
) );
276 pInfo
->SetRepresentation( aRepresentation
);
278 else if( dynamic_cast< const SvxPagesField
* >(pField
) )
280 OUString
aRepresentation(" ");
282 ::sd::ViewShell
* pViewSh
= pDocShell
? pDocShell
->GetViewShell() : nullptr;
283 if(pViewSh
== nullptr)
285 ::sd::ViewShellBase
* pBase
= dynamic_cast< ::sd::ViewShellBase
*>( SfxViewShell::Current() );
287 pViewSh
= pBase
->GetMainViewShell().get();
289 if( !pDoc
&& pViewSh
)
290 pDoc
= pViewSh
->GetDoc();
293 SdPage
* pPage
= GetCurrentPage( pViewSh
, pInfo
, bMasterView
);
295 sal_uInt16 nPageCount
= 0;
299 if( pPage
&& (pPage
->GetPageKind() == PageKind::Handout
) && pViewSh
)
301 nPageCount
= pViewSh
->GetPrintedHandoutPageCount();
305 nPageCount
= pDoc
->GetActiveSdPageCount();
310 aRepresentation
= pDoc
->CreatePageNumValue(nPageCount
);
312 aRepresentation
= SdResId(STR_FIELD_PLACEHOLDER_COUNT
);
314 pInfo
->SetRepresentation( aRepresentation
);
316 else if( (pURLField
= dynamic_cast< const SvxURLField
* >(pField
)) != nullptr )
318 switch ( pURLField
->GetFormat() )
320 case SvxURLFormat::AppDefault
: //!!! adjustable at App???
321 case SvxURLFormat::Repr
:
322 pInfo
->SetRepresentation( pURLField
->GetRepresentation() );
325 case SvxURLFormat::Url
:
326 pInfo
->SetRepresentation( pURLField
->GetURL() );
330 const OUString
& aURL
= pURLField
->GetURL();
332 svtools::ColorConfig aConfig
;
333 svtools::ColorConfigEntry eEntry
=
334 INetURLHistory::GetOrCreate()->QueryUrl( aURL
) ? svtools::LINKSVISITED
: svtools::LINKS
;
335 pInfo
->SetTextColor( aConfig
.GetColorValue(eEntry
).nColor
);
337 else if ( dynamic_cast< const SdrMeasureField
* >(pField
))
339 pInfo
->SetFieldColor(std::optional
<Color
>()); // clear the field color
341 else if ((pCustomPropertyField
= dynamic_cast<const editeng::CustomPropertyField
*>(pField
)) != nullptr)
345 SfxObjectShell
* pObjSh
= SfxObjectShell::Current();
346 if (pObjSh
&& pObjSh
->IsLoadingFinished())
348 auto pNonConstCustomPropertyField
= const_cast<editeng::CustomPropertyField
*>(pCustomPropertyField
);
349 OUString sCurrent
= pNonConstCustomPropertyField
->GetFormatted(pObjSh
->getDocProperties());
350 pInfo
->SetRepresentation(sCurrent
);
353 pInfo
->SetRepresentation(pCustomPropertyField
->GetCurrentPresentation());
357 pInfo
->SetRepresentation(pCustomPropertyField
->GetCurrentPresentation());
362 OUString aRepresentation
;
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);
368 if( bHeaderField
|| bFooterField
|| bDateTimeField
)
370 sd::ViewShell
* pViewSh
= pDocShell
? pDocShell
->GetViewShell() : nullptr;
371 bool bMasterView
= false;
372 SdPage
* pPage
= GetCurrentPage( pViewSh
, pInfo
, bMasterView
);
374 if( (pPage
== nullptr) || bMasterView
)
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
);
385 const sd::HeaderFooterSettings
&rSettings
= pPage
->getHeaderFooterSettings();
389 aRepresentation
= rSettings
.maHeaderText
;
391 else if( bFooterField
)
393 aRepresentation
= rSettings
.maFooterText
;
395 else if( bDateTimeField
)
397 if( rSettings
.mbDateTimeIsFixed
)
399 aRepresentation
= rSettings
.maDateTimeText
;
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
);
413 OSL_FAIL("sd::SdModule::CalcFieldValueHdl(), unknown field type!");
416 if( aRepresentation
.isEmpty() ) // TODO: Edit engine doesn't handle empty fields?
417 aRepresentation
= " ";
418 pInfo
->SetRepresentation( aRepresentation
);
423 * virtual methods for option dialog
425 std::optional
<SfxItemSet
> SdModule::CreateItemSet( sal_uInt16 nSlot
)
427 ::sd::FrameView
* pFrameView
= nullptr;
428 ::sd::DrawDocShell
* pDocSh
= dynamic_cast< ::sd::DrawDocShell
*>( SfxObjectShell::Current() );
429 SdDrawDocument
* pDoc
= nullptr;
431 // Here we set the DocType of the option dialog (not document!)
432 DocumentType eDocType
= DocumentType::Impress
;
433 if( nSlot
== SID_SD_GRAPHIC_OPTIONS
)
434 eDocType
= DocumentType::Draw
;
438 pDoc
= pDocSh
->GetDoc();
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();
445 ::sd::ViewShell
* pViewShell
= pDocSh
->GetViewShell();
446 if (pViewShell
!= nullptr)
447 pViewShell
->WriteFrameViewData();
450 SdOptions
* pOptions
= GetSdOptions(eDocType
);
452 // Pool has by default MapUnit Twips (Awgh!)
453 SfxItemPool
& rPool
= GetPool();
454 rPool
.SetDefaultMetric( MapUnit::Map100thMM
);
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
);
462 // TP_OPTIONS_LAYOUT:
463 aRet
.Put( SdOptionsLayoutItem( pOptions
, pFrameView
) );
465 sal_uInt16 nDefTab
= 0;
467 nDefTab
= pDoc
->GetDefaultTabulator();
469 nDefTab
= pOptions
->GetDefTab();
470 aRet
.Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP
, nDefTab
) );
472 FieldUnit nMetric
= FieldUnit(0xffff);
474 nMetric
= pDoc
->GetUIUnit();
476 nMetric
= static_cast<FieldUnit
>(pOptions
->GetMetric());
478 if( nMetric
== FieldUnit(0xffff) )
479 nMetric
= GetFieldUnit();
481 aRet
.Put( SfxUInt16Item( SID_ATTR_METRIC
, static_cast<sal_uInt16
>(nMetric
) ) );
484 SdOptionsMiscItem
aSdOptionsMiscItem( pOptions
, pFrameView
);
487 aSdOptionsMiscItem
.GetOptionsMisc().SetSummationOfParagraphs( pDoc
->IsSummationOfParagraphs() );
488 aSdOptionsMiscItem
.GetOptionsMisc().SetPrinterIndependentLayout (
489 static_cast<sal_uInt16
>(pDoc
->GetPrinterIndependentLayout()));
491 aRet
.Put( aSdOptionsMiscItem
);
494 aRet
.Put( SdOptionsSnapItem( pOptions
, pFrameView
) );
503 SdrPage
* pPage
= pDoc
->GetSdPage(0, PageKind::Standard
);
504 Size
aSize(pPage
->GetSize());
511 const Fraction
& rFraction
= pDoc
->GetUIScale();
512 nX
=rFraction
.GetNumerator();
513 nY
=rFraction
.GetDenominator();
517 // Get options from configuration file
518 pOptions
->GetScale( nX
, nY
);
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
) );
527 aRet
.Put( SdOptionsPrintItem( pOptions
) );
530 aRet
.Put( SdOptionsGridItem( pOptions
) );
535 void SdModule::ApplyItemSet( sal_uInt16 nSlot
, const SfxItemSet
& rSet
)
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;
552 pDoc
= pDocSh
->GetDoc();
554 pViewShell
= pDocSh
->GetViewShell();
555 if (pViewShell
!= nullptr)
556 pViewShell
->WriteFrameViewData();
558 SdOptions
* pOptions
= GetSdOptions(eDocType
);
560 if( const SdOptionsGridItem
* pGridItem
= static_cast<const SdOptionsGridItem
*>(rSet
.GetItemIfSet( SID_ATTR_GRID_OPTIONS
, false )) )
562 pGridItem
->SetOptions( pOptions
);
566 if( const SdOptionsLayoutItem
* pLayoutItem
= rSet
.GetItemIfSet( ATTR_OPTIONS_LAYOUT
, false ))
568 pLayoutItem
->SetOptions( pOptions
);
572 if( const SfxUInt16Item
* pItem
= rSet
.GetItemIfSet( SID_ATTR_METRIC
, false ) )
574 if( pDoc
&& eDocType
== pDoc
->GetDocumentType() )
576 pOptions
->SetMetric( pItem
->GetValue() );
578 sal_uInt16 nDefTab
= pOptions
->GetDefTab();
580 if( const SfxUInt16Item
* pItem
= rSet
.GetItemIfSet( SID_ATTR_DEFTABSTOP
, false ) )
582 nDefTab
= pItem
->GetValue();
583 pOptions
->SetDefTab( nDefTab
);
589 if( const SfxInt32Item
* pItem
= rSet
.GetItemIfSet( ATTR_OPTIONS_SCALE_X
, false ) )
591 sal_Int32 nX
= pItem
->GetValue();
592 pItem
= rSet
.GetItemIfSet( ATTR_OPTIONS_SCALE_Y
, false );
595 sal_Int32 nY
= pItem
->GetValue();
596 pOptions
->SetScale( nX
, nY
);
598 // Apply to document only if doc type match
599 if( pDocSh
&& pDoc
&& eDocType
== pDoc
->GetDocumentType() )
601 pDoc
->SetUIScale( Fraction( nX
, nY
) );
603 pViewShell
->SetRuler( pViewShell
->HasRuler() );
609 const SdOptionsMiscItem
* pMiscItem
= rSet
.GetItemIfSet( ATTR_OPTIONS_MISC
, false);
612 pMiscItem
->SetOptions( pOptions
);
617 const SdOptionsSnapItem
* pSnapItem
= rSet
.GetItemIfSet( ATTR_OPTIONS_SNAP
, false );
620 pSnapItem
->SetOptions( pOptions
);
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() );
628 const SdOptionsPrintItem
* pPrintItem
= rSet
.GetItemIfSet( ATTR_OPTIONS_PRINT
, false);
631 pPrintItem
->SetOptions( pOptions
);
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
) );
641 aPrintSet
.Put( aPrintItem
);
642 aPrintSet
.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN
, aPrintItem
.GetOptionsPrint().IsWarningPrinter() ) );
643 aPrintSet
.Put( aFlagItem
);
645 bNewPrintOptions
= true;
648 // Only if also the document type matches...
649 if( pDocSh
&& pDoc
&& eDocType
== pDoc
->GetDocumentType() )
651 if( bNewPrintOptions
)
653 pDocSh
->GetPrinter(true)->SetOptions( aPrintSet
);
656 // set DefTab at Model
659 SdDrawDocument
* pDocument
= pDocSh
->GetDoc();
660 pDocument
->SetDefaultTabulator( nDefTab
);
662 SdOutliner
* pOutl
= pDocument
->GetOutliner( false );
664 pOutl
->SetDefTab( nDefTab
);
666 SdOutliner
* pInternalOutl
= pDocument
->GetInternalOutliner( false );
668 pInternalOutl
->SetDefTab( nDefTab
);
672 pDoc
->SetSummationOfParagraphs( pMiscItem
->GetOptionsMisc().IsSummationOfParagraphs() );
673 EEControlBits nSum
= pMiscItem
->GetOptionsMisc().IsSummationOfParagraphs() ? EEControlBits::ULSPACESUMMATION
: EEControlBits::NONE
;
674 EEControlBits nCntrl
;
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 );
683 nCntrl
= pOutl
->GetControlWord() &~ EEControlBits::ULSPACESUMMATION
;
684 pOutl
->SetControlWord( nCntrl
| nSum
);
686 pOutl
= pDocument
->GetInternalOutliner( false );
689 nCntrl
= pOutl
->GetControlWord() &~ EEControlBits::ULSPACESUMMATION
;
690 pOutl
->SetControlWord( nCntrl
| nSum
);
693 // Set printer independent layout mode.
694 if( pDoc
->GetPrinterIndependentLayout() != pMiscItem
->GetOptionsMisc().GetPrinterIndependentLayout() )
695 pDoc
->SetPrinterIndependentLayout (pMiscItem
->GetOptionsMisc().GetPrinterIndependentLayout());
699 pOptions
->StoreConfig();
701 // Only if also the document type matches...
702 if( pDocSh
&& pDoc
&& eDocType
== pDoc
->GetDocumentType() )
704 FieldUnit eUIUnit
= static_cast<FieldUnit
>(pOptions
->GetMetric());
705 pDoc
->SetUIUnit(eUIUnit
);
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();
714 ::sd::FrameView
* pFrame
= pViewShell
->GetFrameView();
715 pFrame
->Update(pOptions
);
716 pViewShell
->ReadFrameViewData(pFrame
);
717 pViewShell
->SetUIUnit(eUIUnit
);
718 pViewShell
->SetDefTabHRuler( nDefTab
);
722 if( pViewShell
&& pViewShell
->GetViewFrame() )
723 pViewShell
->GetViewFrame()->GetBindings().InvalidateAll( true );
726 std::unique_ptr
<SfxTabPage
> SdModule::CreateTabPage( sal_uInt16 nId
, weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
)
728 std::unique_ptr
<SfxTabPage
> xRet
;
729 SfxAllItemSet
aSet(*(rSet
.GetPool()));
730 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
734 case SID_SD_TP_CONTENTS
:
735 case SID_SI_TP_CONTENTS
:
737 ::CreateTabPage fnCreatePage
= pFact
->GetSdOptionsContentsTabPageCreatorFunc();
739 xRet
= (*fnCreatePage
)( pPage
, pController
, &rSet
);
745 ::CreateTabPage fnCreatePage
= pFact
->GetSdOptionsSnapTabPageCreatorFunc();
747 xRet
= (*fnCreatePage
)( pPage
, pController
, &rSet
);
750 case SID_SD_TP_PRINT
:
751 case SID_SI_TP_PRINT
:
753 ::CreateTabPage fnCreatePage
= pFact
->GetSdPrintOptionsTabPageCreatorFunc();
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
);
766 ::CreateTabPage fnCreatePage
= pFact
->GetSdOptionsMiscTabPageCreatorFunc();
769 xRet
= (*fnCreatePage
)( pPage
, pController
, &rSet
);
770 if(SID_SD_TP_MISC
== nId
)
771 aSet
.Put (SfxUInt32Item(SID_SDMODE_FLAG
,SD_DRAW_MODE
));
773 aSet
.Put (SfxUInt32Item(SID_SDMODE_FLAG
,SD_IMPRESS_MODE
));
774 xRet
->PageCreated(aSet
);
778 case RID_SVXPAGE_TEXTANIMATION
:
780 SfxAbstractDialogFactory
* pSfxFact
= SfxAbstractDialogFactory::Create();
781 ::CreateTabPage fnCreatePage
= pSfxFact
->GetTabPageCreatorFunc( nId
);
783 xRet
= (*fnCreatePage
)( pPage
, pController
, &rSet
);
787 DBG_ASSERT( xRet
, "SdModule::CreateTabPage(): no valid ID for TabPage!" );
792 std::optional
<SfxStyleFamilies
> SdModule::CreateStyleFamilies()
794 SfxStyleFamilies aStyleFamilies
;
796 aStyleFamilies
.emplace_back(SfxStyleFamily::Para
,
797 SdResId(STR_GRAPHICS_STYLE_FAMILY
),
798 BMP_STYLES_FAMILY_GRAPHICS
,
799 RID_GRAPHICSTYLEFAMILY
, SD_MOD()->GetResLocale());
801 aStyleFamilies
.emplace_back(SfxStyleFamily::Pseudo
,
802 SdResId(STR_PRESENTATIONS_STYLE_FAMILY
),
803 BMP_STYLES_FAMILY_PRESENTATIONS
,
804 RID_PRESENTATIONSTYLEFAMILY
, SD_MOD()->GetResLocale());
806 return aStyleFamilies
;
809 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */