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/eeitem.hxx>
21 #include <editeng/flditem.hxx>
22 #include <editeng/CustomPropertyField.hxx>
23 #include <o3tl/make_unique.hxx>
24 #include <sfx2/printer.hxx>
25 #include <sfx2/styfitem.hxx>
26 #include <svl/inethist.hxx>
27 #include <svl/poolitem.hxx>
28 #include <svl/flagitem.hxx>
29 #include <unotools/useroptions.hxx>
30 #include <sfx2/bindings.hxx>
31 #include <sfx2/viewfrm.hxx>
32 #include <sfx2/docfile.hxx>
33 #include <sfx2/request.hxx>
35 #include <editeng/measfld.hxx>
36 #include <editeng/editstat.hxx>
37 #include <editeng/editeng.hxx>
39 #include <svx/dialogs.hrc>
40 #include <svx/svdotext.hxx>
41 #include <svx/svdpagv.hxx>
42 #include <svx/svdopage.hxx>
44 #include <sfx2/sfxdlg.hxx>
46 #include <svx/sdr/contact/displayinfo.hxx>
51 #include <strings.hrc>
53 #include <bitmaps.hlst>
54 #include <ViewShell.hxx>
55 #include <FrameView.hxx>
57 #include <optsitem.hxx>
58 #include <DrawDocShell.hxx>
59 #include <drawdoc.hxx>
60 #include <Outliner.hxx>
61 #include <sdresid.hxx>
63 #include <DrawViewShell.hxx>
64 #include <OutlineViewShell.hxx>
65 #include <OutlineView.hxx>
66 #include <ViewShellBase.hxx>
69 #include <sdabstdlg.hxx>
70 #include <svl/intitem.hxx>
72 /** retrieves the page that is currently painted. This will only be the master page
73 if the current drawn view only shows the master page*/
74 static SdPage
* GetCurrentPage( sd::ViewShell
const * pViewSh
, EditFieldInfo
const * pInfo
, bool& bMasterView
)
80 SdPage
* pPage
= dynamic_cast< SdPage
* >( pInfo
->GetSdrPage() );
81 SdrOutliner
* pOutliner
= dynamic_cast< SdrOutliner
* >( pInfo
->GetOutliner() );
83 // special case, someone already set the current page on the EditFieldInfo
84 // This is used from the svx::UnoGraphicsExporter f.e.
91 // first try to check if we are inside the outline view
92 sd::OutlineView
* pSdView
= nullptr;
93 if( auto pOutlineViewShell
= dynamic_cast<const sd::OutlineViewShell
* >(pViewSh
) )
94 pSdView
= static_cast<sd::OutlineView
*>(pOutlineViewShell
->GetView());
96 if (pSdView
!= nullptr && (pOutliner
== &pSdView
->GetOutliner()))
100 Outliner
& rOutl
= pSdView
->GetOutliner();
101 long nPos
= pInfo
->GetPara();
102 sal_Int32 nParaPos
= 0;
104 for( Paragraph
* pPara
= rOutl
.GetParagraph( 0 ); pPara
&& nPos
>= 0; pPara
= rOutl
.GetParagraph( ++nParaPos
), nPos
-- )
106 if( Outliner::HasParaFlag( pPara
, ParaFlag::ISPAGE
) )
110 pPage
= pViewSh
->GetDoc()->GetSdPage( static_cast<sal_uInt16
>(nPgNum
), PageKind::Standard
);
114 // draw mode, slide mode and preview. Get the processed page from the outliner
117 pPage
= dynamic_cast< SdPage
* >(const_cast< SdrPage
* >(pOutliner
->getVisualizedPage()));
120 // The path using GetPaintingPageView() and GetCurrentPaintingDisplayInfo()
121 // is no longer needed. I debugged and checked all usages of PageNumber decompositions
122 // which all use the new possibility of setting the visualized page at the SdrOutliner.
124 // if all else failed, geht the current page from the object that is
125 // currently formatted from the document
128 const SdrTextObj
* pTextObj
= (pViewSh
&& pViewSh
->GetDoc()) ? pViewSh
->GetDoc()->GetFormattingTextObj() : nullptr;
132 pPage
= dynamic_cast< SdPage
* >( pTextObj
->GetPage() );
138 bMasterView
= pPage
&& pPage
->IsMasterPage();
146 * Link for CalcFieldValue of Outliners
148 IMPL_LINK(SdModule
, CalcFieldValueHdl
, EditFieldInfo
*, pInfo
, void)
153 const SvxFieldData
* pField
= pInfo
->GetField().GetField();
154 ::sd::DrawDocShell
* pDocShell
= nullptr;
155 SdDrawDocument
* pDoc
= nullptr;
157 SdrOutliner
* pSdrOutliner
= dynamic_cast< SdrOutliner
* >( pInfo
->GetOutliner() );
160 const SdrTextObj
* pTextObj
= pSdrOutliner
->GetTextObj();
163 pDoc
= dynamic_cast< SdDrawDocument
* >( &pTextObj
->getSdrModelFromSdrObject() );
166 pDocShell
= pDoc
->GetDocSh();
170 pDocShell
= dynamic_cast< ::sd::DrawDocShell
*>( SfxObjectShell::Current() );
172 const SvxDateField
* pDateField
= nullptr;
173 const SvxExtTimeField
* pExtTimeField
= nullptr;
174 const SvxExtFileField
* pExtFileField
= nullptr;
175 const SvxAuthorField
* pAuthorField
= nullptr;
176 const SvxURLField
* pURLField
= nullptr;
178 const editeng::CustomPropertyField
* pCustomPropertyField
= nullptr;
180 if( (pDateField
= dynamic_cast< const SvxDateField
* >(pField
)) != nullptr )
182 LanguageType eLang
= pInfo
->GetOutliner()->GetLanguage( pInfo
->GetPara(), pInfo
->GetPos() );
183 pInfo
->SetRepresentation( pDateField
->GetFormatted( *GetNumberFormatter(), eLang
) );
185 else if( (pExtTimeField
= dynamic_cast< const SvxExtTimeField
*>(pField
)) != nullptr )
187 LanguageType eLang
= pInfo
->GetOutliner()->GetLanguage( pInfo
->GetPara(), pInfo
->GetPos() );
188 pInfo
->SetRepresentation( pExtTimeField
->GetFormatted( *GetNumberFormatter(), eLang
) );
190 else if( (pExtFileField
= dynamic_cast< const SvxExtFileField
* >(pField
)) != nullptr )
192 if( pDocShell
&& (pExtFileField
->GetType() != SvxFileType::Fix
) )
195 if( pDocShell
->HasName() )
196 aName
= pDocShell
->GetMedium()->GetName();
198 aName
= pDocShell
->GetName();
200 const_cast< SvxExtFileField
* >(pExtFileField
)->SetFile( aName
);
202 pInfo
->SetRepresentation( pExtFileField
->GetFormatted() );
205 else if( (pAuthorField
= dynamic_cast< const SvxAuthorField
* >( pField
)) != nullptr )
207 if( pAuthorField
->GetType() != SvxAuthorType::Fix
)
209 SvtUserOptions aUserOptions
;
210 SvxAuthorField
aAuthorField(
211 aUserOptions
.GetFirstName(), aUserOptions
.GetLastName(), aUserOptions
.GetID(),
212 pAuthorField
->GetType(), pAuthorField
->GetFormat() );
214 *const_cast< SvxAuthorField
* >(pAuthorField
) = aAuthorField
;
216 pInfo
->SetRepresentation( pAuthorField
->GetFormatted() );
219 else if( dynamic_cast< const SvxPageField
* >(pField
) )
221 OUString
aRepresentation(" ");
223 ::sd::ViewShell
* pViewSh
= pDocShell
? pDocShell
->GetViewShell() : nullptr;
224 if(pViewSh
== nullptr)
226 ::sd::ViewShellBase
* pBase
= dynamic_cast< ::sd::ViewShellBase
*>( SfxViewShell::Current() );
228 pViewSh
= pBase
->GetMainViewShell().get();
230 if( !pDoc
&& pViewSh
)
231 pDoc
= pViewSh
->GetDoc();
234 SdPage
* pPage
= GetCurrentPage( pViewSh
, pInfo
, bMasterView
);
236 if( pPage
&& pDoc
&& !bMasterView
)
240 if( (pPage
->GetPageKind() == PageKind::Handout
) && pViewSh
)
242 nPgNum
= pViewSh
->GetPrintedHandoutPageNum();
246 nPgNum
= (pPage
->GetPageNum() - 1) / 2 + 1;
248 aRepresentation
= pDoc
->CreatePageNumValue(static_cast<sal_uInt16
>(nPgNum
));
251 aRepresentation
= SdResId(STR_FIELD_PLACEHOLDER_NUMBER
);
253 pInfo
->SetRepresentation( aRepresentation
);
255 else if( dynamic_cast< const SvxPageTitleField
* >(pField
) )
257 OUString
aRepresentation(" ");
259 ::sd::ViewShell
* pViewSh
= pDocShell
? pDocShell
->GetViewShell() : nullptr;
260 if(pViewSh
== nullptr)
262 ::sd::ViewShellBase
* pBase
= dynamic_cast< ::sd::ViewShellBase
*>( SfxViewShell::Current() );
264 pViewSh
= pBase
->GetMainViewShell().get();
266 if( !pDoc
&& pViewSh
)
267 pDoc
= pViewSh
->GetDoc();
270 SdPage
* pPage
= GetCurrentPage( pViewSh
, pInfo
, bMasterView
);
272 if( pPage
&& pDoc
&& !bMasterView
)
274 aRepresentation
= pPage
->GetName();
278 DocumentType eDocType
= pDoc
? pDoc
->GetDocumentType() : DocumentType::Impress
;
279 aRepresentation
= ( ( eDocType
== DocumentType::Impress
)
280 ? SdResId(STR_FIELD_PLACEHOLDER_SLIDENAME
)
281 : SdResId(STR_FIELD_PLACEHOLDER_PAGENAME
) );
284 pInfo
->SetRepresentation( aRepresentation
);
286 else if( dynamic_cast< const SvxPagesField
* >(pField
) )
288 OUString
aRepresentation(" ");
290 ::sd::ViewShell
* pViewSh
= pDocShell
? pDocShell
->GetViewShell() : nullptr;
291 if(pViewSh
== nullptr)
293 ::sd::ViewShellBase
* pBase
= dynamic_cast< ::sd::ViewShellBase
*>( SfxViewShell::Current() );
295 pViewSh
= pBase
->GetMainViewShell().get();
297 if( !pDoc
&& pViewSh
)
298 pDoc
= pViewSh
->GetDoc();
301 SdPage
* pPage
= GetCurrentPage( pViewSh
, pInfo
, bMasterView
);
303 sal_uInt16 nPageCount
= 0;
307 if( pPage
&& (pPage
->GetPageKind() == PageKind::Handout
) && pViewSh
)
309 nPageCount
= pViewSh
->GetPrintedHandoutPageCount();
313 nPageCount
= pDoc
->GetActiveSdPageCount();
318 aRepresentation
= pDoc
->CreatePageNumValue(nPageCount
);
320 aRepresentation
= SdResId(STR_FIELD_PLACEHOLDER_COUNT
);
322 pInfo
->SetRepresentation( aRepresentation
);
324 else if( (pURLField
= dynamic_cast< const SvxURLField
* >(pField
)) != nullptr )
326 switch ( pURLField
->GetFormat() )
328 case SvxURLFormat::AppDefault
: //!!! adjustable at App???
329 case SvxURLFormat::Repr
:
330 pInfo
->SetRepresentation( pURLField
->GetRepresentation() );
333 case SvxURLFormat::Url
:
334 pInfo
->SetRepresentation( pURLField
->GetURL() );
338 OUString aURL
= pURLField
->GetURL();
340 svtools::ColorConfig aConfig
;
341 svtools::ColorConfigEntry eEntry
=
342 INetURLHistory::GetOrCreate()->QueryUrl( aURL
) ? svtools::LINKSVISITED
: svtools::LINKS
;
343 pInfo
->SetTextColor( aConfig
.GetColorValue(eEntry
).nColor
);
345 else if ( dynamic_cast< const SdrMeasureField
* >(pField
))
347 pInfo
->ClearFieldColor();
349 else if ((pCustomPropertyField
= dynamic_cast<const editeng::CustomPropertyField
*>(pField
)) != nullptr)
353 if (SfxObjectShell::Current() && SfxObjectShell::Current()->IsLoadingFinished())
355 auto pNonConstCustomPropertyField
= const_cast<editeng::CustomPropertyField
*>(pCustomPropertyField
);
356 OUString sCurrent
= pNonConstCustomPropertyField
->GetFormatted(SfxObjectShell::Current()->getDocProperties());
357 pInfo
->SetRepresentation(sCurrent
);
360 pInfo
->SetRepresentation(pCustomPropertyField
->GetCurrentPresentation());
364 pInfo
->SetRepresentation(pCustomPropertyField
->GetCurrentPresentation());
369 OUString aRepresentation
;
371 bool bHeaderField
= dynamic_cast< const SvxHeaderField
* >( pField
) != nullptr;
372 bool bFooterField
= !bHeaderField
&& (dynamic_cast< const SvxFooterField
* >( pField
) != nullptr );
373 bool bDateTimeField
= !bHeaderField
&& !bFooterField
&& (dynamic_cast< const SvxDateTimeField
* >( pField
) != nullptr);
375 if( bHeaderField
|| bFooterField
|| bDateTimeField
)
377 sd::ViewShell
* pViewSh
= pDocShell
? pDocShell
->GetViewShell() : nullptr;
378 bool bMasterView
= false;
379 SdPage
* pPage
= GetCurrentPage( pViewSh
, pInfo
, bMasterView
);
381 if( (pPage
== nullptr) || bMasterView
)
384 aRepresentation
= SdResId(STR_FIELD_PLACEHOLDER_HEADER
);
385 else if (bFooterField
)
386 aRepresentation
= SdResId(STR_FIELD_PLACEHOLDER_FOOTER
);
387 else if (bDateTimeField
)
388 aRepresentation
= SdResId(STR_FIELD_PLACEHOLDER_DATETIME
);
392 const sd::HeaderFooterSettings
&rSettings
= pPage
->getHeaderFooterSettings();
396 aRepresentation
= rSettings
.maHeaderText
;
398 else if( bFooterField
)
400 aRepresentation
= rSettings
.maFooterText
;
402 else if( bDateTimeField
)
404 if( rSettings
.mbDateTimeIsFixed
)
406 aRepresentation
= rSettings
.maDateTimeText
;
410 DateTime
aDateTime( DateTime::SYSTEM
);
411 LanguageType eLang
= pInfo
->GetOutliner()->GetLanguage( pInfo
->GetPara(), pInfo
->GetPos() );
412 aRepresentation
= SvxDateTimeField::GetFormatted( aDateTime
, aDateTime
,
413 rSettings
.meDateFormat
, rSettings
.meTimeFormat
, *GetNumberFormatter(), eLang
);
420 OSL_FAIL("sd::SdModule::CalcFieldValueHdl(), unknown field type!");
423 if( aRepresentation
.isEmpty() ) // TODO: Edit engine doesn't handle empty fields?
424 aRepresentation
= " ";
425 pInfo
->SetRepresentation( aRepresentation
);
430 * virtual methods for option dialog
432 std::unique_ptr
<SfxItemSet
> SdModule::CreateItemSet( sal_uInt16 nSlot
)
434 ::sd::FrameView
* pFrameView
= nullptr;
435 ::sd::DrawDocShell
* pDocSh
= dynamic_cast< ::sd::DrawDocShell
*>( SfxObjectShell::Current() );
436 SdDrawDocument
* pDoc
= nullptr;
438 // Here we set the DocType of the option dialog (not document!)
439 DocumentType eDocType
= DocumentType::Impress
;
440 if( nSlot
== SID_SD_GRAPHIC_OPTIONS
)
441 eDocType
= DocumentType::Draw
;
445 pDoc
= pDocSh
->GetDoc();
447 // If the option dialog is identical to the document type,
448 // we can pass the FrameView too:
449 if( pDoc
&& eDocType
== pDoc
->GetDocumentType() )
450 pFrameView
= pDocSh
->GetFrameView();
452 ::sd::ViewShell
* pViewShell
= pDocSh
->GetViewShell();
453 if (pViewShell
!= nullptr)
454 pViewShell
->WriteFrameViewData();
457 SdOptions
* pOptions
= GetSdOptions(eDocType
);
459 // Pool has by default MapUnit Twips (Awgh!)
460 SfxItemPool
& rPool
= GetPool();
461 rPool
.SetDefaultMetric( MapUnit::Map100thMM
);
463 auto pRet
= o3tl::make_unique
<SfxItemSet
>(
466 SID_ATTR_GRID_OPTIONS
, SID_ATTR_GRID_OPTIONS
,
467 SID_ATTR_METRIC
, SID_ATTR_METRIC
,
468 SID_ATTR_DEFTABSTOP
, SID_ATTR_DEFTABSTOP
,
469 ATTR_OPTIONS_LAYOUT
, ATTR_OPTIONS_SCALE_END
>{});
471 // TP_OPTIONS_LAYOUT:
472 pRet
->Put( SdOptionsLayoutItem( pOptions
, pFrameView
) );
474 sal_uInt16 nDefTab
= 0;
476 nDefTab
= pDoc
->GetDefaultTabulator();
478 nDefTab
= pOptions
->GetDefTab();
479 pRet
->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP
, nDefTab
) );
481 FieldUnit nMetric
= FieldUnit(0xffff);
483 nMetric
= pDoc
->GetUIUnit();
485 nMetric
= static_cast<FieldUnit
>(pOptions
->GetMetric());
487 if( nMetric
== FieldUnit(0xffff) )
488 nMetric
= GetFieldUnit();
490 pRet
->Put( SfxUInt16Item( SID_ATTR_METRIC
, static_cast<sal_uInt16
>(nMetric
) ) );
493 SdOptionsMiscItem
aSdOptionsMiscItem( pOptions
, pFrameView
);
496 aSdOptionsMiscItem
.GetOptionsMisc().SetSummationOfParagraphs( pDoc
->IsSummationOfParagraphs() );
497 aSdOptionsMiscItem
.GetOptionsMisc().SetPrinterIndependentLayout (
498 static_cast<sal_uInt16
>(pDoc
->GetPrinterIndependentLayout()));
500 pRet
->Put( aSdOptionsMiscItem
);
503 pRet
->Put( SdOptionsSnapItem( pOptions
, pFrameView
) );
512 SdrPage
* pPage
= static_cast<SdrPage
*>(pDoc
->GetSdPage(0, PageKind::Standard
));
513 Size
aSize(pPage
->GetSize());
520 const Fraction
& rFraction
= pDoc
->GetUIScale();
521 nX
=rFraction
.GetNumerator();
522 nY
=rFraction
.GetDenominator();
526 // Get options from configuration file
527 pOptions
->GetScale( nX
, nY
);
530 pRet
->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X
, nX
) );
531 pRet
->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y
, nY
) );
532 pRet
->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_WIDTH
, nW
) );
533 pRet
->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_HEIGHT
, nH
) );
536 pRet
->Put( SdOptionsPrintItem( pOptions
) );
539 pRet
->Put( SdOptionsGridItem( pOptions
) );
543 void SdModule::ApplyItemSet( sal_uInt16 nSlot
, const SfxItemSet
& rSet
)
545 const SfxPoolItem
* pItem
= nullptr;
546 bool bNewDefTab
= false;
547 bool bNewPrintOptions
= false;
548 bool bMiscOptions
= false;
550 ::sd::DrawDocShell
* pDocSh
= dynamic_cast< ::sd::DrawDocShell
*>( SfxObjectShell::Current() );
551 SdDrawDocument
* pDoc
= nullptr;
552 // Here we set the DocType of the option dialog (not document!)
553 DocumentType eDocType
= DocumentType::Impress
;
554 if( nSlot
== SID_SD_GRAPHIC_OPTIONS
)
555 eDocType
= DocumentType::Draw
;
557 ::sd::ViewShell
* pViewShell
= nullptr;
561 pDoc
= pDocSh
->GetDoc();
563 pViewShell
= pDocSh
->GetViewShell();
564 if (pViewShell
!= nullptr)
565 pViewShell
->WriteFrameViewData();
567 SdOptions
* pOptions
= GetSdOptions(eDocType
);
569 if( SfxItemState::SET
== rSet
.GetItemState( SID_ATTR_GRID_OPTIONS
,
572 const SdOptionsGridItem
* pGridItem
= static_cast<const SdOptionsGridItem
*>(pItem
);
573 pGridItem
->SetOptions( pOptions
);
577 const SdOptionsLayoutItem
* pLayoutItem
= nullptr;
578 if( SfxItemState::SET
== rSet
.GetItemState( ATTR_OPTIONS_LAYOUT
,
579 false, reinterpret_cast<const SfxPoolItem
**>(&pLayoutItem
) ))
581 pLayoutItem
->SetOptions( pOptions
);
585 if( SfxItemState::SET
== rSet
.GetItemState( SID_ATTR_METRIC
, false, &pItem
) )
587 if( pDoc
&& eDocType
== pDoc
->GetDocumentType() )
589 pOptions
->SetMetric( static_cast<const SfxUInt16Item
*>( pItem
)->GetValue() );
591 sal_uInt16 nDefTab
= pOptions
->GetDefTab();
593 if( SfxItemState::SET
== rSet
.GetItemState( SID_ATTR_DEFTABSTOP
, false, &pItem
) )
595 nDefTab
= static_cast<const SfxUInt16Item
*>( pItem
)->GetValue();
596 pOptions
->SetDefTab( nDefTab
);
602 if( SfxItemState::SET
== rSet
.GetItemState( ATTR_OPTIONS_SCALE_X
, false, &pItem
) )
604 sal_Int32 nX
= static_cast<const SfxInt32Item
*>( pItem
)->GetValue();
605 if( SfxItemState::SET
== rSet
.GetItemState( ATTR_OPTIONS_SCALE_Y
, false, &pItem
) )
607 sal_Int32 nY
= static_cast<const SfxInt32Item
*>( pItem
)->GetValue();
608 pOptions
->SetScale( nX
, nY
);
610 // Apply to document only if doc type match
611 if( pDocSh
&& pDoc
&& eDocType
== pDoc
->GetDocumentType() )
613 pDoc
->SetUIScale( Fraction( nX
, nY
) );
615 pViewShell
->SetRuler( pViewShell
->HasRuler() );
621 const SdOptionsMiscItem
* pMiscItem
= nullptr;
622 if( SfxItemState::SET
== rSet
.GetItemState( ATTR_OPTIONS_MISC
,
623 false, reinterpret_cast<const SfxPoolItem
**>(&pMiscItem
) ))
625 pMiscItem
->SetOptions( pOptions
);
630 const SdOptionsSnapItem
* pSnapItem
= nullptr;
631 if( SfxItemState::SET
== rSet
.GetItemState( ATTR_OPTIONS_SNAP
,
632 false, reinterpret_cast<const SfxPoolItem
**>(&pSnapItem
) ))
634 pSnapItem
->SetOptions( pOptions
);
637 SfxItemSet
aPrintSet( GetPool(),
638 svl::Items
<SID_PRINTER_NOTFOUND_WARN
, SID_PRINTER_NOTFOUND_WARN
,
639 SID_PRINTER_CHANGESTODOC
, SID_PRINTER_CHANGESTODOC
,
640 ATTR_OPTIONS_PRINT
, ATTR_OPTIONS_PRINT
>{} );
643 const SdOptionsPrintItem
* pPrintItem
= nullptr;
644 if( SfxItemState::SET
== rSet
.GetItemState( ATTR_OPTIONS_PRINT
,
645 false, reinterpret_cast<const SfxPoolItem
**>(&pPrintItem
) ))
647 pPrintItem
->SetOptions( pOptions
);
649 // set PrintOptionsSet
650 SdOptionsPrintItem
aPrintItem( pOptions
);
651 SfxFlagItem
aFlagItem( SID_PRINTER_CHANGESTODOC
);
652 SfxPrinterChangeFlags nFlags
=
653 (aPrintItem
.GetOptionsPrint().IsWarningSize() ? SfxPrinterChangeFlags::CHG_SIZE
: SfxPrinterChangeFlags::NONE
) |
654 (aPrintItem
.GetOptionsPrint().IsWarningOrientation() ? SfxPrinterChangeFlags::CHG_ORIENTATION
: SfxPrinterChangeFlags::NONE
);
655 aFlagItem
.SetValue( static_cast<int>(nFlags
) );
657 aPrintSet
.Put( aPrintItem
);
658 aPrintSet
.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN
, aPrintItem
.GetOptionsPrint().IsWarningPrinter() ) );
659 aPrintSet
.Put( aFlagItem
);
661 bNewPrintOptions
= true;
664 // Only if also the document type matches...
665 if( pDocSh
&& pDoc
&& eDocType
== pDoc
->GetDocumentType() )
667 if( bNewPrintOptions
)
669 pDocSh
->GetPrinter(true)->SetOptions( aPrintSet
);
672 // set DefTab at Model
675 SdDrawDocument
* pDocument
= pDocSh
->GetDoc();
676 pDocument
->SetDefaultTabulator( nDefTab
);
678 SdOutliner
* pOutl
= pDocument
->GetOutliner( false );
680 pOutl
->SetDefTab( nDefTab
);
682 SdOutliner
* pInternalOutl
= pDocument
->GetInternalOutliner( false );
684 pInternalOutl
->SetDefTab( nDefTab
);
688 pDoc
->SetSummationOfParagraphs( pMiscItem
->GetOptionsMisc().IsSummationOfParagraphs() );
689 EEControlBits nSum
= pMiscItem
->GetOptionsMisc().IsSummationOfParagraphs() ? EEControlBits::ULSPACESUMMATION
: EEControlBits::NONE
;
690 EEControlBits nCntrl
;
692 SdDrawDocument
* pDocument
= pDocSh
->GetDoc();
693 SdrOutliner
& rOutl
= pDocument
->GetDrawOutliner();
694 nCntrl
= rOutl
.GetControlWord() &~ EEControlBits::ULSPACESUMMATION
;
695 rOutl
.SetControlWord( nCntrl
| nSum
);
696 SdOutliner
* pOutl
= pDocument
->GetOutliner( false );
699 nCntrl
= pOutl
->GetControlWord() &~ EEControlBits::ULSPACESUMMATION
;
700 pOutl
->SetControlWord( nCntrl
| nSum
);
702 pOutl
= pDocument
->GetInternalOutliner( false );
705 nCntrl
= pOutl
->GetControlWord() &~ EEControlBits::ULSPACESUMMATION
;
706 pOutl
->SetControlWord( nCntrl
| nSum
);
709 // Set printer independent layout mode.
710 if( pDoc
->GetPrinterIndependentLayout() != pMiscItem
->GetOptionsMisc().GetPrinterIndependentLayout() )
711 pDoc
->SetPrinterIndependentLayout (pMiscItem
->GetOptionsMisc().GetPrinterIndependentLayout());
715 pOptions
->StoreConfig();
717 // Only if also the document type matches...
718 if( pDocSh
&& pDoc
&& eDocType
== pDoc
->GetDocumentType() )
720 FieldUnit eUIUnit
= static_cast<FieldUnit
>(pOptions
->GetMetric());
721 pDoc
->SetUIUnit(eUIUnit
);
725 // make sure no one is in text edit mode, cause there
726 // are some pointers remembered else (!)
727 if(pViewShell
->GetView())
728 pViewShell
->GetView()->SdrEndTextEdit();
730 ::sd::FrameView
* pFrame
= pViewShell
->GetFrameView();
731 pFrame
->Update(pOptions
);
732 pViewShell
->ReadFrameViewData(pFrame
);
733 pViewShell
->SetUIUnit(eUIUnit
);
734 pViewShell
->SetDefTabHRuler( nDefTab
);
738 if( pViewShell
&& pViewShell
->GetViewFrame() )
739 pViewShell
->GetViewFrame()->GetBindings().InvalidateAll( true );
742 VclPtr
<SfxTabPage
> SdModule::CreateTabPage( sal_uInt16 nId
, TabPageParent pParent
, const SfxItemSet
& rSet
)
744 VclPtr
<SfxTabPage
> pRet
;
745 SfxAllItemSet
aSet(*(rSet
.GetPool()));
746 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
751 case SID_SD_TP_CONTENTS
:
752 case SID_SI_TP_CONTENTS
:
753 { ::CreateTabPage fnCreatePage
= pFact
->GetSdOptionsContentsTabPageCreatorFunc();
755 pRet
= (*fnCreatePage
)( pParent
, &rSet
);
760 { ::CreateTabPage fnCreatePage
= pFact
->GetSdOptionsSnapTabPageCreatorFunc();
762 pRet
= (*fnCreatePage
)( pParent
, &rSet
);
765 case SID_SD_TP_PRINT
:
766 case SID_SI_TP_PRINT
:
768 ::CreateTabPage fnCreatePage
= pFact
->GetSdPrintOptionsTabPageCreatorFunc();
771 pRet
= (*fnCreatePage
)( pParent
, &rSet
);
772 if(SID_SD_TP_PRINT
== nId
)
773 aSet
.Put (SfxUInt32Item(SID_SDMODE_FLAG
,SD_DRAW_MODE
));
774 pRet
->PageCreated(aSet
);
781 ::CreateTabPage fnCreatePage
= pFact
->GetSdOptionsMiscTabPageCreatorFunc();
784 pRet
= (*fnCreatePage
)( pParent
, &rSet
);
785 if(SID_SD_TP_MISC
== nId
)
786 aSet
.Put (SfxUInt32Item(SID_SDMODE_FLAG
,SD_DRAW_MODE
));
788 aSet
.Put (SfxUInt32Item(SID_SDMODE_FLAG
,SD_IMPRESS_MODE
));
789 pRet
->PageCreated(aSet
);
793 case RID_SVXPAGE_TEXTANIMATION
:
795 SfxAbstractDialogFactory
* pSfxFact
= SfxAbstractDialogFactory::Create();
798 ::CreateTabPage fnCreatePage
= pSfxFact
->GetTabPageCreatorFunc( nId
);
800 pRet
= (*fnCreatePage
)( pParent
, &rSet
);
805 DBG_ASSERT( pRet
, "SdModule::CreateTabPage(): no valid ID for TabPage!" );
811 SfxStyleFamilies
* SdModule::CreateStyleFamilies()
813 SfxStyleFamilies
*pStyleFamilies
= new SfxStyleFamilies
;
815 pStyleFamilies
->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para
,
816 SdResId(STR_GRAPHICS_STYLE_FAMILY
),
817 Image(BitmapEx(BMP_STYLES_FAMILY_GRAPHICS
)),
818 RID_GRAPHICSTYLEFAMILY
, SD_MOD()->GetResLocale()));
820 pStyleFamilies
->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Pseudo
,
821 SdResId(STR_PRESENTATIONS_STYLE_FAMILY
),
822 Image(BitmapEx(BMP_STYLES_FAMILY_PRESENTATIONS
)),
823 RID_PRESENTATIONSTYLEFAMILY
, SD_MOD()->GetResLocale()));
825 return pStyleFamilies
;
828 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */