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 <sfx2/printer.hxx>
23 #include <svl/inethist.hxx>
24 #include <svl/poolitem.hxx>
25 #include <svl/flagitem.hxx>
26 #include <unotools/useroptions.hxx>
27 #include <sfx2/bindings.hxx>
28 #include <vcl/msgbox.hxx>
29 #include <sfx2/viewfrm.hxx>
30 #include <sfx2/docfile.hxx>
31 #include <sfx2/request.hxx>
33 #include <editeng/measfld.hxx>
34 #include <editeng/editstat.hxx>
35 #include <editeng/editeng.hxx>
37 #include <svx/dialogs.hrc>
38 #include <svx/svdotext.hxx>
39 #include <svx/svdpagv.hxx>
40 #include <svx/svdopage.hxx>
42 #include <sfx2/sfxdlg.hxx>
44 #include <svx/sdr/contact/displayinfo.hxx>
49 #include "strings.hrc"
50 #include "res_bmp.hrc"
51 #include "ViewShell.hxx"
52 #include "FrameView.hxx"
54 #include "optsitem.hxx"
55 #include "DrawDocShell.hxx"
56 #include "drawdoc.hxx"
57 #include "Outliner.hxx"
58 #include "sdresid.hxx"
60 #include "DrawViewShell.hxx"
61 #include "OutlineViewShell.hxx"
62 #include "OutlineView.hxx"
63 #include "ViewShellBase.hxx"
66 #include "sdabstdlg.hxx"
67 #include <svl/intitem.hxx>
69 /** retrieves the page that is currently painted. This will only be the master page
70 if the current drawn view only shows the master page*/
71 static SdPage
* GetCurrentPage( sd::ViewShell
* pViewSh
, EditFieldInfo
* pInfo
, bool& bMasterView
)
77 SdPage
* pPage
= dynamic_cast< SdPage
* >( pInfo
->GetSdrPage() );
78 SdrOutliner
* pOutliner
= dynamic_cast< SdrOutliner
* >( pInfo
->GetOutliner() );
80 // special case, someone already set the current page on the EditFieldInfo
81 // This is used from the svx::UnoGraphicsExporter f.e.
88 // first try to check if we are inside the outline view
89 sd::OutlineView
* pSdView
= NULL
;
90 if( pViewSh
&& pViewSh
->ISA(sd::OutlineViewShell
))
91 pSdView
= static_cast<sd::OutlineView
*> (static_cast<sd::OutlineViewShell
*>(pViewSh
)->GetView());
93 if (pSdView
!= NULL
&& (pOutliner
== &pSdView
->GetOutliner()))
97 Outliner
& rOutl
= pSdView
->GetOutliner();
98 long nPos
= pInfo
->GetPara();
99 sal_Int32 nParaPos
= 0;
101 for( Paragraph
* pPara
= rOutl
.GetParagraph( 0 ); pPara
&& nPos
>= 0; pPara
= rOutl
.GetParagraph( ++nParaPos
), nPos
-- )
103 if( Outliner::HasParaFlag( pPara
, ParaFlag::ISPAGE
) )
107 pPage
= pViewSh
->GetDoc()->GetSdPage( (sal_uInt16
)nPgNum
, PK_STANDARD
);
111 // draw mode, slide mode and preview. Get the processed page from the outliner
114 pPage
= dynamic_cast< SdPage
* >(const_cast< SdrPage
* >(pOutliner
->getVisualizedPage()));
117 // The path using GetPaintingPageView() and GetCurrentPaintingDisplayInfo()
118 // is no longer needed. I debugged and checked all usages of PageNumber decompositions
119 // which all use the new possibility of setting the visualized page at the SdrOutliner.
121 // if all else failed, geht the current page from the object that is
122 // currently formatted from the document
125 const SdrTextObj
* pTextObj
= (pViewSh
&& pViewSh
->GetDoc()) ? pViewSh
->GetDoc()->GetFormattingTextObj() : NULL
;
129 pPage
= dynamic_cast< SdPage
* >( pTextObj
->GetPage() );
135 bMasterView
= pPage
&& pPage
->IsMasterPage();
143 * Link for CalcFieldValue of Outliners
145 IMPL_LINK(SdModule
, CalcFieldValueHdl
, EditFieldInfo
*, pInfo
)
149 const SvxFieldData
* pField
= pInfo
->GetField().GetField();
150 ::sd::DrawDocShell
* pDocShell
= NULL
;
151 SdDrawDocument
* pDoc
= 0;
153 SdrOutliner
* pSdrOutliner
= dynamic_cast< SdrOutliner
* >( pInfo
->GetOutliner() );
156 const SdrTextObj
* pTextObj
= pSdrOutliner
->GetTextObj();
159 pDoc
= dynamic_cast< SdDrawDocument
* >( pTextObj
->GetModel() );
162 pDocShell
= pDoc
->GetDocSh();
166 pDocShell
= dynamic_cast< ::sd::DrawDocShell
*>( SfxObjectShell::Current() );
168 const SvxDateField
* pDateField
= 0;
169 const SvxExtTimeField
* pExtTimeField
= 0;
170 const SvxExtFileField
* pExtFileField
= 0;
171 const SvxAuthorField
* pAuthorField
= 0;
172 const SvxURLField
* pURLField
= 0;
174 if( (pDateField
= dynamic_cast< const SvxDateField
* >(pField
)) != 0 )
176 LanguageType eLang
= pInfo
->GetOutliner()->GetLanguage( pInfo
->GetPara(), pInfo
->GetPos() );
177 pInfo
->SetRepresentation( pDateField
->GetFormatted( *GetNumberFormatter(), eLang
) );
179 else if( (pExtTimeField
= dynamic_cast< const SvxExtTimeField
*>(pField
)) != 0 )
181 LanguageType eLang
= pInfo
->GetOutliner()->GetLanguage( pInfo
->GetPara(), pInfo
->GetPos() );
182 pInfo
->SetRepresentation( pExtTimeField
->GetFormatted( *GetNumberFormatter(), eLang
) );
184 else if( (pExtFileField
= dynamic_cast< const SvxExtFileField
* >(pField
)) != 0 )
186 if( pDocShell
&& (pExtFileField
->GetType() != SVXFILETYPE_FIX
) )
189 if( pDocShell
->HasName() )
190 aName
= pDocShell
->GetMedium()->GetName();
192 aName
= pDocShell
->GetName();
194 const_cast< SvxExtFileField
* >(pExtFileField
)->SetFile( aName
);
196 pInfo
->SetRepresentation( pExtFileField
->GetFormatted() );
199 else if( (pAuthorField
= dynamic_cast< const SvxAuthorField
* >( pField
)) != 0 )
201 if( pAuthorField
->GetType() != SVXAUTHORTYPE_FIX
)
203 SvtUserOptions aUserOptions
;
204 SvxAuthorField
aAuthorField(
205 aUserOptions
.GetFirstName(), aUserOptions
.GetLastName(), aUserOptions
.GetID(),
206 pAuthorField
->GetType(), pAuthorField
->GetFormat() );
208 *(const_cast< SvxAuthorField
* >(pAuthorField
)) = aAuthorField
;
210 pInfo
->SetRepresentation( pAuthorField
->GetFormatted() );
213 else if( dynamic_cast< const SvxPageField
* >(pField
) )
215 OUString
aRepresentation(" ");
217 ::sd::ViewShell
* pViewSh
= pDocShell
? pDocShell
->GetViewShell() : NULL
;
220 ::sd::ViewShellBase
* pBase
= PTR_CAST(::sd::ViewShellBase
, SfxViewShell::Current());
222 pViewSh
= pBase
->GetMainViewShell().get();
224 if( !pDoc
&& pViewSh
)
225 pDoc
= pViewSh
->GetDoc();
228 SdPage
* pPage
= GetCurrentPage( pViewSh
, pInfo
, bMasterView
);
230 if( pPage
&& pDoc
&& !bMasterView
)
234 if( (pPage
->GetPageKind() == PK_HANDOUT
) && pViewSh
)
236 nPgNum
= pViewSh
->GetPrintedHandoutPageNum();
240 nPgNum
= (pPage
->GetPageNum() - 1) / 2 + 1;
242 aRepresentation
= pDoc
->CreatePageNumValue((sal_uInt16
)nPgNum
);
245 aRepresentation
= SdResId(STR_FIELD_PLACEHOLDER_NUMBER
).toString();
247 pInfo
->SetRepresentation( aRepresentation
);
250 else if( dynamic_cast< const SvxPageTitleField
* >(pField
) )
252 OUString
aRepresentation(" ");
254 ::sd::ViewShell
* pViewSh
= pDocShell
? pDocShell
->GetViewShell() : NULL
;
257 ::sd::ViewShellBase
* pBase
= PTR_CAST(::sd::ViewShellBase
, SfxViewShell::Current());
259 pViewSh
= pBase
->GetMainViewShell().get();
261 if( !pDoc
&& pViewSh
)
262 pDoc
= pViewSh
->GetDoc();
265 SdPage
* pPage
= GetCurrentPage( pViewSh
, pInfo
, bMasterView
);
267 if( pPage
&& pDoc
&& !bMasterView
)
269 aRepresentation
= pPage
->GetName();
273 DocumentType eDocType
= pDoc
? pDoc
->GetDocumentType() : DOCUMENT_TYPE_IMPRESS
;
274 aRepresentation
= ( ( eDocType
== DOCUMENT_TYPE_IMPRESS
)
275 ? SdResId(STR_FIELD_PLACEHOLDER_SLIDENAME
).toString()
276 : SdResId(STR_FIELD_PLACEHOLDER_PAGENAME
).toString() );
279 pInfo
->SetRepresentation( aRepresentation
);
281 else if( dynamic_cast< const SvxPagesField
* >(pField
) )
283 OUString
aRepresentation(" ");
285 ::sd::ViewShell
* pViewSh
= pDocShell
? pDocShell
->GetViewShell() : NULL
;
288 ::sd::ViewShellBase
* pBase
= PTR_CAST(::sd::ViewShellBase
, SfxViewShell::Current());
290 pViewSh
= pBase
->GetMainViewShell().get();
292 if( !pDoc
&& pViewSh
)
293 pDoc
= pViewSh
->GetDoc();
296 SdPage
* pPage
= GetCurrentPage( pViewSh
, pInfo
, bMasterView
);
298 sal_uInt16 nPageCount
= 0;
302 if( pPage
&& (pPage
->GetPageKind() == PK_HANDOUT
) && pViewSh
)
304 nPageCount
= pViewSh
->GetPrintedHandoutPageCount();
308 nPageCount
= (sal_uInt16
)pDoc
->GetActiveSdPageCount();
313 aRepresentation
= pDoc
->CreatePageNumValue(nPageCount
);
315 aRepresentation
= SdResId(STR_FIELD_PLACEHOLDER_COUNT
).toString();
317 pInfo
->SetRepresentation( aRepresentation
);
319 else if( (pURLField
= dynamic_cast< const SvxURLField
* >(pField
)) != 0 )
321 switch ( pURLField
->GetFormat() )
323 case SVXURLFORMAT_APPDEFAULT
: //!!! adjustable at App???
324 case SVXURLFORMAT_REPR
:
325 pInfo
->SetRepresentation( pURLField
->GetRepresentation() );
328 case SVXURLFORMAT_URL
:
329 pInfo
->SetRepresentation( pURLField
->GetURL() );
333 OUString aURL
= pURLField
->GetURL();
335 svtools::ColorConfig aConfig
;
336 svtools::ColorConfigEntry eEntry
=
337 INetURLHistory::GetOrCreate()->QueryUrl( aURL
) ? svtools::LINKSVISITED
: svtools::LINKS
;
338 pInfo
->SetTextColor( aConfig
.GetColorValue(eEntry
).nColor
);
340 else if ( dynamic_cast< const SdrMeasureField
* >(pField
))
342 pInfo
->ClearFieldColor();
346 OUString aRepresentation
;
348 bool bHeaderField
= dynamic_cast< const SvxHeaderField
* >( pField
) != 0;
349 bool bFooterField
= !bHeaderField
&& (dynamic_cast< const SvxFooterField
* >( pField
) != 0 );
350 bool bDateTimeField
= !bHeaderField
&& !bFooterField
&& (dynamic_cast< const SvxDateTimeField
* >( pField
) != 0);
352 if( bHeaderField
|| bFooterField
|| bDateTimeField
)
354 sd::ViewShell
* pViewSh
= pDocShell
? pDocShell
->GetViewShell() : NULL
;
355 bool bMasterView
= false;
356 SdPage
* pPage
= GetCurrentPage( pViewSh
, pInfo
, bMasterView
);
358 if( (pPage
== NULL
) || bMasterView
)
361 aRepresentation
= SdResId(STR_FIELD_PLACEHOLDER_HEADER
).toString();
362 else if (bFooterField
)
363 aRepresentation
= SdResId(STR_FIELD_PLACEHOLDER_FOOTER
).toString();
364 else if (bDateTimeField
)
365 aRepresentation
= SdResId(STR_FIELD_PLACEHOLDER_DATETIME
).toString();
369 const sd::HeaderFooterSettings
&rSettings
= pPage
->getHeaderFooterSettings();
373 aRepresentation
= rSettings
.maHeaderText
;
375 else if( bFooterField
)
377 aRepresentation
= rSettings
.maFooterText
;
379 else if( bDateTimeField
)
381 if( rSettings
.mbDateTimeIsFixed
)
383 aRepresentation
= rSettings
.maDateTimeText
;
387 Date
aDate( Date::SYSTEM
);
388 tools::Time
aTime( tools::Time::SYSTEM
);
389 LanguageType eLang
= pInfo
->GetOutliner()->GetLanguage( pInfo
->GetPara(), pInfo
->GetPos() );
390 aRepresentation
= SvxDateTimeField::GetFormatted( aDate
, aTime
, (SvxDateFormat
)rSettings
.meDateTimeFormat
, *GetNumberFormatter(), eLang
);
397 OSL_FAIL("sd::SdModule::CalcFieldValueHdl(), unknown field type!");
400 if( aRepresentation
.isEmpty() ) // TODO: Edit engine doesn't handle empty fields?
401 aRepresentation
= " ";
402 pInfo
->SetRepresentation( aRepresentation
);
410 * virtual methods for option dialog
412 SfxItemSet
* SdModule::CreateItemSet( sal_uInt16 nSlot
)
414 ::sd::FrameView
* pFrameView
= NULL
;
415 ::sd::DrawDocShell
* pDocSh
= PTR_CAST(::sd::DrawDocShell
, SfxObjectShell::Current() );
416 SdDrawDocument
* pDoc
= NULL
;
418 // Here we set the DocType of the option dialog (not document!)
419 DocumentType eDocType
= DOCUMENT_TYPE_IMPRESS
;
420 if( nSlot
== SID_SD_GRAPHIC_OPTIONS
)
421 eDocType
= DOCUMENT_TYPE_DRAW
;
425 pDoc
= pDocSh
->GetDoc();
427 // If the option dialog is identical to the document type,
428 // we can pass the FrameView too:
429 if( pDoc
&& eDocType
== pDoc
->GetDocumentType() )
430 pFrameView
= pDocSh
->GetFrameView();
432 ::sd::ViewShell
* pViewShell
= pDocSh
->GetViewShell();
433 if (pViewShell
!= NULL
)
434 pViewShell
->WriteFrameViewData();
437 SdOptions
* pOptions
= GetSdOptions(eDocType
);
439 // Pool has by default MapUnit Twips (Awgh!)
440 SfxItemPool
& rPool
= GetPool();
441 rPool
.SetDefaultMetric( SFX_MAPUNIT_100TH_MM
);
443 SfxItemSet
* pRet
= new SfxItemSet( rPool
,
444 SID_ATTR_METRIC
, SID_ATTR_METRIC
,
445 SID_ATTR_DEFTABSTOP
, SID_ATTR_DEFTABSTOP
,
447 ATTR_OPTIONS_LAYOUT
, ATTR_OPTIONS_LAYOUT
,
448 ATTR_OPTIONS_CONTENTS
, ATTR_OPTIONS_CONTENTS
,
449 ATTR_OPTIONS_MISC
, ATTR_OPTIONS_MISC
,
451 ATTR_OPTIONS_SNAP
, ATTR_OPTIONS_SNAP
,
453 ATTR_OPTIONS_SCALE_START
, ATTR_OPTIONS_SCALE_END
,
455 ATTR_OPTIONS_PRINT
, ATTR_OPTIONS_PRINT
,
457 SID_ATTR_GRID_OPTIONS
, SID_ATTR_GRID_OPTIONS
,
460 // TP_OPTIONS_LAYOUT:
461 pRet
->Put( SdOptionsLayoutItem( ATTR_OPTIONS_LAYOUT
, pOptions
, pFrameView
) );
463 sal_uInt16 nDefTab
= 0;
465 nDefTab
= pDoc
->GetDefaultTabulator();
467 nDefTab
= pOptions
->GetDefTab();
468 pRet
->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP
, nDefTab
) );
470 FieldUnit nMetric
= (FieldUnit
)0xffff;
472 nMetric
= pDoc
->GetUIUnit();
474 nMetric
= (FieldUnit
)pOptions
->GetMetric();
476 if( nMetric
== (FieldUnit
)0xffff )
477 nMetric
= GetFieldUnit();
479 pRet
->Put( SfxUInt16Item( SID_ATTR_METRIC
, (sal_uInt16
)nMetric
) );
481 // TP_OPTIONS_CONTENTS:
482 pRet
->Put( SdOptionsContentsItem( ATTR_OPTIONS_CONTENTS
, pOptions
, pFrameView
) );
485 SdOptionsMiscItem
aSdOptionsMiscItem( ATTR_OPTIONS_MISC
, pOptions
, pFrameView
);
488 aSdOptionsMiscItem
.GetOptionsMisc().SetSummationOfParagraphs( pDoc
->IsSummationOfParagraphs() );
489 aSdOptionsMiscItem
.GetOptionsMisc().SetPrinterIndependentLayout (
490 (sal_uInt16
)pDoc
->GetPrinterIndependentLayout());
492 pRet
->Put( aSdOptionsMiscItem
);
495 pRet
->Put( SdOptionsSnapItem( ATTR_OPTIONS_SNAP
, pOptions
, pFrameView
) );
504 SdrPage
* pPage
= (SdrPage
*) pDoc
->GetSdPage(0, PK_STANDARD
);
505 Size
aSize(pPage
->GetSize());
512 const Fraction
& rFraction
= pDoc
->GetUIScale();
513 nX
=rFraction
.GetNumerator();
514 nY
=rFraction
.GetDenominator();
518 // Get options from configuration file
519 pOptions
->GetScale( nX
, nY
);
522 pRet
->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X
, nX
) );
523 pRet
->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y
, nY
) );
524 pRet
->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_WIDTH
, nW
) );
525 pRet
->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_HEIGHT
, nH
) );
528 pRet
->Put( SdOptionsPrintItem( ATTR_OPTIONS_PRINT
, pOptions
) );
531 pRet
->Put( SdOptionsGridItem( SID_ATTR_GRID_OPTIONS
, pOptions
) );
535 void SdModule::ApplyItemSet( sal_uInt16 nSlot
, const SfxItemSet
& rSet
)
537 const SfxPoolItem
* pItem
= NULL
;
538 bool bNewDefTab
= false;
539 bool bNewPrintOptions
= false;
540 bool bMiscOptions
= false;
542 ::sd::DrawDocShell
* pDocSh
= PTR_CAST(::sd::DrawDocShell
, SfxObjectShell::Current() );
543 SdDrawDocument
* pDoc
= NULL
;
544 // Here we set the DocType of the option dialog (not document!)
545 DocumentType eDocType
= DOCUMENT_TYPE_IMPRESS
;
546 if( nSlot
== SID_SD_GRAPHIC_OPTIONS
)
547 eDocType
= DOCUMENT_TYPE_DRAW
;
549 ::sd::ViewShell
* pViewShell
= NULL
;
553 pDoc
= pDocSh
->GetDoc();
555 pViewShell
= pDocSh
->GetViewShell();
556 if (pViewShell
!= NULL
)
557 pViewShell
->WriteFrameViewData();
559 SdOptions
* pOptions
= GetSdOptions(eDocType
);
561 if( SfxItemState::SET
== rSet
.GetItemState( SID_ATTR_GRID_OPTIONS
,
564 const SdOptionsGridItem
* pGridItem
= static_cast<const SdOptionsGridItem
*>(pItem
);
565 pGridItem
->SetOptions( pOptions
);
569 const SdOptionsLayoutItem
* pLayoutItem
= NULL
;
570 if( SfxItemState::SET
== rSet
.GetItemState( ATTR_OPTIONS_LAYOUT
,
571 false, reinterpret_cast<const SfxPoolItem
**>(&pLayoutItem
) ))
573 pLayoutItem
->SetOptions( pOptions
);
577 if( SfxItemState::SET
== rSet
.GetItemState( SID_ATTR_METRIC
, false, &pItem
) )
579 if( pDoc
&& eDocType
== pDoc
->GetDocumentType() )
581 pOptions
->SetMetric( static_cast<const SfxUInt16Item
*>( pItem
)->GetValue() );
583 sal_uInt16 nDefTab
= pOptions
->GetDefTab();
585 if( SfxItemState::SET
== rSet
.GetItemState( SID_ATTR_DEFTABSTOP
, false, &pItem
) )
587 nDefTab
= static_cast<const SfxUInt16Item
*>( pItem
)->GetValue();
588 pOptions
->SetDefTab( nDefTab
);
594 if( SfxItemState::SET
== rSet
.GetItemState( ATTR_OPTIONS_SCALE_X
, false, &pItem
) )
596 sal_Int32 nX
= static_cast<const SfxInt32Item
*>( pItem
)->GetValue();
597 if( SfxItemState::SET
== rSet
.GetItemState( ATTR_OPTIONS_SCALE_Y
, false, &pItem
) )
599 sal_Int32 nY
= static_cast<const SfxInt32Item
*>( pItem
)->GetValue();
600 pOptions
->SetScale( nX
, nY
);
602 // Apply to document only if doc type match
603 if( pDocSh
&& pDoc
&& eDocType
== pDoc
->GetDocumentType() )
605 pDoc
->SetUIScale( Fraction( nX
, nY
) );
607 pViewShell
->SetRuler( pViewShell
->HasRuler() );
613 const SdOptionsMiscItem
* pMiscItem
= NULL
;
614 if( SfxItemState::SET
== rSet
.GetItemState( ATTR_OPTIONS_MISC
,
615 false, reinterpret_cast<const SfxPoolItem
**>(&pMiscItem
) ))
617 pMiscItem
->SetOptions( pOptions
);
622 const SdOptionsSnapItem
* pSnapItem
= NULL
;
623 if( SfxItemState::SET
== rSet
.GetItemState( ATTR_OPTIONS_SNAP
,
624 false, reinterpret_cast<const SfxPoolItem
**>(&pSnapItem
) ))
626 pSnapItem
->SetOptions( pOptions
);
629 SfxItemSet
aPrintSet( GetPool(),
630 SID_PRINTER_NOTFOUND_WARN
, SID_PRINTER_NOTFOUND_WARN
,
631 SID_PRINTER_CHANGESTODOC
, SID_PRINTER_CHANGESTODOC
,
632 ATTR_OPTIONS_PRINT
, ATTR_OPTIONS_PRINT
,
636 const SdOptionsPrintItem
* pPrintItem
= NULL
;
637 if( SfxItemState::SET
== rSet
.GetItemState( ATTR_OPTIONS_PRINT
,
638 false, reinterpret_cast<const SfxPoolItem
**>(&pPrintItem
) ))
640 pPrintItem
->SetOptions( pOptions
);
642 // set PrintOptionsSet
643 SdOptionsPrintItem
aPrintItem( ATTR_OPTIONS_PRINT
, pOptions
);
644 SfxFlagItem
aFlagItem( SID_PRINTER_CHANGESTODOC
);
645 SfxPrinterChangeFlags nFlags
=
646 (aPrintItem
.GetOptionsPrint().IsWarningSize() ? SfxPrinterChangeFlags::CHG_SIZE
: SfxPrinterChangeFlags::NONE
) |
647 (aPrintItem
.GetOptionsPrint().IsWarningOrientation() ? SfxPrinterChangeFlags::CHG_ORIENTATION
: SfxPrinterChangeFlags::NONE
);
648 aFlagItem
.SetValue( static_cast<int>(nFlags
) );
650 aPrintSet
.Put( aPrintItem
);
651 aPrintSet
.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN
, aPrintItem
.GetOptionsPrint().IsWarningPrinter() ) );
652 aPrintSet
.Put( aFlagItem
);
654 bNewPrintOptions
= true;
657 // Only if also the document type matches...
658 if( pDocSh
&& pDoc
&& eDocType
== pDoc
->GetDocumentType() )
660 if( bNewPrintOptions
)
662 pDocSh
->GetPrinter(true)->SetOptions( aPrintSet
);
665 // set DefTab at Model
668 SdDrawDocument
* pDocument
= pDocSh
->GetDoc();
669 pDocument
->SetDefaultTabulator( nDefTab
);
671 ::sd::Outliner
* pOutl
= pDocument
->GetOutliner( false );
673 pOutl
->SetDefTab( nDefTab
);
675 ::sd::Outliner
* pInternalOutl
= pDocument
->GetInternalOutliner( false );
677 pInternalOutl
->SetDefTab( nDefTab
);
681 pDoc
->SetSummationOfParagraphs( pMiscItem
->GetOptionsMisc().IsSummationOfParagraphs() );
682 EEControlBits nSum
= pMiscItem
->GetOptionsMisc().IsSummationOfParagraphs() ? EEControlBits::ULSPACESUMMATION
: EEControlBits::NONE
;
683 EEControlBits nCntrl
;
685 SdDrawDocument
* pDocument
= pDocSh
->GetDoc();
686 SdrOutliner
& rOutl
= pDocument
->GetDrawOutliner();
687 nCntrl
= rOutl
.GetControlWord() &~ EEControlBits::ULSPACESUMMATION
;
688 rOutl
.SetControlWord( nCntrl
| nSum
);
689 ::sd::Outliner
* pOutl
= pDocument
->GetOutliner( false );
692 nCntrl
= pOutl
->GetControlWord() &~ EEControlBits::ULSPACESUMMATION
;
693 pOutl
->SetControlWord( nCntrl
| nSum
);
695 pOutl
= pDocument
->GetInternalOutliner( false );
698 nCntrl
= pOutl
->GetControlWord() &~ EEControlBits::ULSPACESUMMATION
;
699 pOutl
->SetControlWord( nCntrl
| nSum
);
702 // Set printer independent layout mode.
703 if( pDoc
->GetPrinterIndependentLayout() != pMiscItem
->GetOptionsMisc().GetPrinterIndependentLayout() )
704 pDoc
->SetPrinterIndependentLayout (pMiscItem
->GetOptionsMisc().GetPrinterIndependentLayout());
708 pOptions
->StoreConfig();
710 // Only if also the document type matches...
711 if( pDocSh
&& pDoc
&& eDocType
== pDoc
->GetDocumentType() )
713 FieldUnit eUIUnit
= (FieldUnit
) pOptions
->GetMetric();
714 pDoc
->SetUIUnit(eUIUnit
);
718 // make sure no one is in text edit mode, cause there
719 // are some pointers remembered else (!)
720 if(pViewShell
->GetView())
721 pViewShell
->GetView()->SdrEndTextEdit();
723 ::sd::FrameView
* pFrame
= pViewShell
->GetFrameView();
724 pFrame
->Update(pOptions
);
725 pViewShell
->ReadFrameViewData(pFrame
);
726 pViewShell
->SetUIUnit(eUIUnit
);
727 pViewShell
->SetDefTabHRuler( nDefTab
);
731 if( pViewShell
&& pViewShell
->GetViewFrame() )
732 pViewShell
->GetViewFrame()->GetBindings().InvalidateAll( true );
735 VclPtr
<SfxTabPage
> SdModule::CreateTabPage( sal_uInt16 nId
, vcl::Window
* pParent
, const SfxItemSet
& rSet
)
737 VclPtr
<SfxTabPage
> pRet
;
738 SfxAllItemSet
aSet(*(rSet
.GetPool()));
739 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
744 case SID_SD_TP_CONTENTS
:
745 case SID_SI_TP_CONTENTS
:
746 { ::CreateTabPage fnCreatePage
= pFact
->GetSdOptionsContentsTabPageCreatorFunc();
748 pRet
= (*fnCreatePage
)( pParent
, &rSet
);
753 { ::CreateTabPage fnCreatePage
= pFact
->GetSdOptionsSnapTabPageCreatorFunc();
755 pRet
= (*fnCreatePage
)( pParent
, &rSet
);
758 case SID_SD_TP_PRINT
:
759 case SID_SI_TP_PRINT
:
761 ::CreateTabPage fnCreatePage
= pFact
->GetSdPrintOptionsTabPageCreatorFunc();
764 pRet
= (*fnCreatePage
)( pParent
, &rSet
);
765 if(SID_SD_TP_PRINT
== nId
)
766 aSet
.Put (SfxUInt32Item(SID_SDMODE_FLAG
,SD_DRAW_MODE
));
767 pRet
->PageCreated(aSet
);
774 ::CreateTabPage fnCreatePage
= pFact
->GetSdOptionsMiscTabPageCreatorFunc();
777 pRet
= (*fnCreatePage
)( pParent
, &rSet
);
778 if(SID_SD_TP_MISC
== nId
)
779 aSet
.Put (SfxUInt32Item(SID_SDMODE_FLAG
,SD_DRAW_MODE
));
781 aSet
.Put (SfxUInt32Item(SID_SDMODE_FLAG
,SD_IMPRESS_MODE
));
782 pRet
->PageCreated(aSet
);
786 case RID_SVXPAGE_TEXTANIMATION
:
788 SfxAbstractDialogFactory
* pSfxFact
= SfxAbstractDialogFactory::Create();
791 ::CreateTabPage fnCreatePage
= pSfxFact
->GetTabPageCreatorFunc( nId
);
793 pRet
= (*fnCreatePage
)( pParent
, &rSet
);
798 DBG_ASSERT( pRet
, "SdModule::CreateTabPage(): no valid ID for TabPage!" );
804 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */