Update ooo320-m1
[ooovba.git] / sd / source / ui / app / sdmod2.cxx
blob75d5dcbbb3affe4a9eed433872e268ea6dab648b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdmod2.cxx,v $
10 * $Revision: 1.55 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <svx/eeitem.hxx>
34 #include <svx/flditem.hxx>
35 #include <sfx2/printer.hxx>
36 #include <svtools/inethist.hxx>
37 #include <svtools/poolitem.hxx>
38 #include <svtools/flagitem.hxx>
39 #include <svtools/useroptions.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <vcl/msgbox.hxx>
42 #include <sfx2/viewfrm.hxx>
43 #include <sfx2/docfile.hxx>
44 #include <sfx2/request.hxx>
46 #include <svx/svdfield.hxx>
47 #include <svx/editstat.hxx>
48 #include <svx/editeng.hxx>
50 #include <svx/dialogs.hrc>
51 #include <svx/svdotext.hxx>
52 #include <svx/svdpagv.hxx>
53 #include <svx/svdopage.hxx>
55 #include <sfx2/sfxdlg.hxx>
58 #include <svx/sdr/contact/displayinfo.hxx>
60 #define _SD_DLL // fuer SD_MOD()
61 #include "sdmod.hxx"
62 #include "sddll.hxx"
63 #include "app.hrc"
64 #include "glob.hrc"
65 #include "strings.hrc"
66 #include "res_bmp.hrc"
67 #include "ViewShell.hxx"
68 #ifndef SD_FRAMW_VIEW_HXX
69 #include "FrameView.hxx"
70 #endif
71 #include "sdattr.hxx"
72 #include "tpoption.hrc"
73 #include "optsitem.hxx"
74 #include "DrawDocShell.hxx"
75 #include "drawdoc.hxx"
76 #include "Outliner.hxx"
77 #include "sdresid.hxx"
78 #include "pres.hxx"
79 #include "DrawViewShell.hxx"
80 #include "OutlineViewShell.hxx"
81 #include "OutlineView.hxx"
82 #include "ViewShellBase.hxx"
83 #include "sdpage.hxx"
84 #include "sdxfer.hxx"
85 #include "sdabstdlg.hxx"
86 #include "tpoption.hrc"
87 #include "prntopts.hrc"
88 #include <svtools/intitem.hxx>
90 /** retrieves the page that is currently painted. This will only be the master page
91 if the current drawn view only shows the master page*/
92 static SdPage* GetCurrentPage( sd::ViewShell* pViewSh, EditFieldInfo* pInfo, bool& bMasterView )
94 if( !pInfo )
95 return 0;
97 bMasterView = false;
98 SdPage* pPage = dynamic_cast< SdPage* >( pInfo->GetSdrPage() );
99 SdrOutliner* pOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
101 // special case, someone already set the current page on the EditFieldInfo
102 // This is used from the svx::UnoGraphicsExporter f.e.
103 if( pPage )
105 bMasterView = false;
106 return pPage;
109 // first try to check if we are inside the outline view
110 sd::OutlineView* pSdView = NULL;
111 if( pViewSh && pViewSh->ISA(sd::OutlineViewShell))
112 pSdView = static_cast<sd::OutlineView*> (static_cast<sd::OutlineViewShell*>(pViewSh)->GetView());
114 if (pSdView != NULL && (pOutliner == pSdView->GetOutliner()))
116 // outline mode
117 int nPgNum = 0;
118 Outliner* pOutl = pSdView->GetOutliner();
119 long nPos = pInfo->GetPara();
120 ULONG nParaPos = 0;
122 for( Paragraph* pPara = pOutl->GetParagraph( 0 ); pPara && nPos >= 0; pPara = pOutl->GetParagraph( ++nParaPos ), nPos-- )
124 if( pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
125 nPgNum++;
128 pPage = pViewSh->GetDoc()->GetSdPage( (USHORT)nPgNum, PK_STANDARD );
130 else
132 // draw mode, slide mode and preview. Get the processed page from the outliner
133 if(pOutliner)
135 pPage = dynamic_cast< SdPage* >(const_cast< SdrPage* >(pOutliner->getVisualizedPage()));
138 // The path using GetPaintingPageView() and GetCurrentPaintingDisplayInfo()
139 // is no longer needed. I debugged and checked all usages of PageNumber decompositions
140 // which all use the new possibility of setting the visualized page at the SdrOutliner.
142 // if all else failed, geht the current page from the object that is
143 // currently formated from the document
144 if(!pPage)
146 const SdrTextObj* pTextObj = (pViewSh && pViewSh->GetDoc()) ? pViewSh->GetDoc()->GetFormattingTextObj() : NULL;
148 if( pTextObj )
150 pPage = dynamic_cast< SdPage* >( pTextObj->GetPage() );
154 if(pPage)
156 bMasterView = pPage && pPage->IsMasterPage();
160 return pPage;
163 /*************************************************************************
165 |* Link fuer CalcFieldValue des Outliners
167 \************************************************************************/
169 IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo)
171 if (pInfo)
173 const SvxFieldData* pField = pInfo->GetField().GetField();
174 ::sd::DrawDocShell* pDocShell = NULL;
175 SdDrawDocument* pDoc = 0;
177 if( pInfo->GetOutliner() )
179 const SdrTextObj* pTextObj = static_cast< SdrOutliner* >( pInfo->GetOutliner() )->GetTextObj();
181 if( pTextObj )
182 pDoc = dynamic_cast< SdDrawDocument* >( pTextObj->GetModel() );
184 if( pDoc )
185 pDocShell = pDoc->GetDocSh();
188 if( !pDocShell )
189 pDocShell = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
191 const SvxDateField* pDateField = 0;
192 const SvxExtTimeField* pExtTimeField = 0;
193 const SvxExtFileField* pExtFileField = 0;
194 const SvxAuthorField* pAuthorField = 0;
195 const SvxURLField* pURLField = 0;
197 if( (pDateField = dynamic_cast< const SvxDateField* >(pField)) != 0 )
199 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
200 pInfo->SetRepresentation( pDateField->GetFormatted( *GetNumberFormatter(), eLang ) );
202 else if( (pExtTimeField = dynamic_cast< const SvxExtTimeField *>(pField)) != 0 )
204 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
205 pInfo->SetRepresentation( pExtTimeField->GetFormatted( *GetNumberFormatter(), eLang ) );
207 else if( (pExtFileField = dynamic_cast< const SvxExtFileField * >(pField)) != 0 )
209 if( pDocShell && (pExtFileField->GetType() != SVXFILETYPE_FIX) )
211 String aName;
212 if( pDocShell->HasName() )
213 aName = pDocShell->GetMedium()->GetName();
214 else
215 aName = pDocShell->GetName();
217 const_cast< SvxExtFileField* >(pExtFileField)->SetFile( aName );
219 pInfo->SetRepresentation( pExtFileField->GetFormatted() );
222 else if( (pAuthorField = dynamic_cast< const SvxAuthorField* >( pField )) != 0 )
224 if( pAuthorField->GetType() != SVXAUTHORTYPE_FIX )
226 SvtUserOptions aUserOptions;
227 SvxAuthorField aAuthorField(
228 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID(),
229 pAuthorField->GetType(), pAuthorField->GetFormat() );
231 *(const_cast< SvxAuthorField* >(pAuthorField)) = aAuthorField;
233 pInfo->SetRepresentation( pAuthorField->GetFormatted() );
236 else if( dynamic_cast< const SvxPageField* >(pField) )
238 String aRepresentation;
239 aRepresentation += sal_Unicode( ' ' );
241 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
242 if(pViewSh == NULL)
244 ::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
245 if(pBase)
246 pViewSh = pBase->GetMainViewShell().get();
248 if( !pDoc && pViewSh )
249 pDoc = pViewSh->GetDoc();
251 bool bMasterView;
252 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
254 if( pPage && pDoc && !bMasterView )
256 int nPgNum;
258 if( (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
260 nPgNum = pViewSh->GetPrintedHandoutPageNum();
262 else
264 nPgNum = (pPage->GetPageNum() - 1) / 2 + 1;
266 aRepresentation = pDoc->CreatePageNumValue((USHORT)nPgNum);
268 else
270 static String aNumberText( SdResId( STR_FIELD_PLACEHOLDER_NUMBER ) );
271 aRepresentation = aNumberText;
274 pInfo->SetRepresentation( aRepresentation );
276 else if( dynamic_cast< const SvxPagesField* >(pField) )
278 String aRepresentation;
279 aRepresentation += sal_Unicode( ' ' );
281 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
282 if(pViewSh == NULL)
284 ::sd::ViewShellBase* pBase = PTR_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 USHORT nPageCount = 0;
296 if( !bMasterView )
298 if( pPage && (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
300 nPageCount = pViewSh->GetPrintedHandoutPageCount();
302 else if( pDoc )
304 nPageCount = (USHORT)pDoc->GetSdPageCount(PK_STANDARD);
308 if( nPageCount > 0 )
310 aRepresentation = pDoc->CreatePageNumValue(nPageCount);
312 else
314 static String aNumberText( SdResId( STR_FIELD_PLACEHOLDER_COUNT ) );
315 aRepresentation = aNumberText;
318 pInfo->SetRepresentation( aRepresentation );
320 else if( (pURLField = dynamic_cast< const SvxURLField* >(pField)) != 0 )
322 switch ( pURLField->GetFormat() )
324 case SVXURLFORMAT_APPDEFAULT: //!!! einstellbar an App???
325 case SVXURLFORMAT_REPR:
326 pInfo->SetRepresentation( pURLField->GetRepresentation() );
327 break;
329 case SVXURLFORMAT_URL:
330 pInfo->SetRepresentation( pURLField->GetURL() );
331 break;
334 String aURL = pURLField->GetURL();
336 svtools::ColorConfig aConfig;
337 svtools::ColorConfigEntry eEntry =
338 INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS;
339 pInfo->SetTxtColor( aConfig.GetColorValue(eEntry).nColor );
341 else if ( dynamic_cast< const SdrMeasureField* >(pField))
343 pInfo->ClearFldColor();
345 else
347 String aRepresentation;
349 bool bHeaderField = dynamic_cast< const SvxHeaderField* >( pField ) != 0;
350 bool bFooterField = !bHeaderField && (dynamic_cast< const SvxFooterField* >( pField ) != 0 );
351 bool bDateTimeField = !bHeaderField && !bFooterField && (dynamic_cast< const SvxDateTimeField* >( pField ) != 0);
353 if( bHeaderField || bFooterField || bDateTimeField )
355 sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
356 bool bMasterView = false;
357 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
359 if( (pPage == NULL) || bMasterView )
361 if( bHeaderField )
363 static String aHeaderStr( SdResId( STR_FIELD_PLACEHOLDER_HEADER ) );
364 aRepresentation = aHeaderStr;
366 else if (bFooterField )
368 static String aFooterStr( SdResId( STR_FIELD_PLACEHOLDER_FOOTER ) );
369 aRepresentation = aFooterStr;
371 else if (bDateTimeField )
373 static String aDateTimeStr( SdResId( STR_FIELD_PLACEHOLDER_DATETIME ) );
374 aRepresentation = aDateTimeStr;
377 else
379 const sd::HeaderFooterSettings &rSettings = pPage->getHeaderFooterSettings();
381 if( bHeaderField )
383 aRepresentation = rSettings.maHeaderText;
385 else if( bFooterField )
387 aRepresentation = rSettings.maFooterText;
389 else if( bDateTimeField )
391 if( rSettings.mbDateTimeIsFixed )
393 aRepresentation = rSettings.maDateTimeText;
395 else
397 Date aDate;
398 Time aTime;
399 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
400 aRepresentation = SvxDateTimeField::GetFormatted( aDate, aTime, (SvxDateFormat)rSettings.meDateTimeFormat, *GetNumberFormatter(), eLang );
405 else
407 DBG_ERROR("sd::SdModule::CalcFieldValueHdl(), unknown field type!");
410 if( aRepresentation.Len() == 0 ) // TODO: Edit engine doesn't handle empty fields?
411 aRepresentation += sal_Unicode( ' ' );
412 pInfo->SetRepresentation( aRepresentation );
416 return(0);
421 /*************************************************************************
423 |* virt. Methoden fuer Optionendialog
425 \************************************************************************/
426 SfxItemSet* SdModule::CreateItemSet( USHORT nSlot )
428 ::sd::FrameView* pFrameView = NULL;
429 ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
430 SdDrawDocument* pDoc = NULL;
432 // Hier wird der DocType vom Optionsdialog gesetzt (nicht Dokument!)
433 DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
434 if( nSlot == SID_SD_GRAPHIC_OPTIONS )
435 eDocType = DOCUMENT_TYPE_DRAW;
437 ::sd::ViewShell* pViewShell = NULL;
439 if (pDocSh)
441 pDoc = pDocSh->GetDoc();
443 // Wenn der Optionsdialog zum Dokumenttyp identisch ist,
444 // kann auch die FrameView mit uebergeben werden:
445 if( pDoc && eDocType == pDoc->GetDocumentType() )
446 pFrameView = pDocSh->GetFrameView();
448 pViewShell = pDocSh->GetViewShell();
449 if (pViewShell != NULL)
450 pViewShell->WriteFrameViewData();
453 SdOptions* pOptions = GetSdOptions(eDocType);
455 // Pool hat standardmaessig MapUnit Twips (Baeh!)
456 SfxItemPool& rPool = GetPool();
457 rPool.SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
459 SfxItemSet* pRet = new SfxItemSet( rPool,
460 SID_ATTR_METRIC, SID_ATTR_METRIC,
461 SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP,
463 ATTR_OPTIONS_LAYOUT, ATTR_OPTIONS_LAYOUT,
464 ATTR_OPTIONS_CONTENTS, ATTR_OPTIONS_CONTENTS,
465 ATTR_OPTIONS_MISC, ATTR_OPTIONS_MISC,
467 ATTR_OPTIONS_SNAP, ATTR_OPTIONS_SNAP,
469 ATTR_OPTIONS_SCALE_START, ATTR_OPTIONS_SCALE_END,
471 ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT,
473 SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS,
474 0 );
476 // TP_OPTIONS_LAYOUT:
477 pRet->Put( SdOptionsLayoutItem( ATTR_OPTIONS_LAYOUT, pOptions, pFrameView ) );
479 UINT16 nDefTab = 0;
480 if( pFrameView)
481 nDefTab = pDoc->GetDefaultTabulator();
482 else
483 nDefTab = pOptions->GetDefTab();
484 pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, nDefTab ) );
486 FieldUnit nMetric = (FieldUnit)0xffff;
487 if( pFrameView)
488 nMetric = pDoc->GetUIUnit();
489 else
490 nMetric = (FieldUnit)pOptions->GetMetric();
492 if( nMetric == (FieldUnit)0xffff )
493 nMetric = GetModuleFieldUnit();
495 pRet->Put( SfxUInt16Item( SID_ATTR_METRIC, (UINT16)nMetric ) );
497 // TP_OPTIONS_CONTENTS:
498 pRet->Put( SdOptionsContentsItem( ATTR_OPTIONS_CONTENTS, pOptions, pFrameView ) );
500 // TP_OPTIONS_MISC:
501 SdOptionsMiscItem aSdOptionsMiscItem( ATTR_OPTIONS_MISC, pOptions, pFrameView );
502 if ( pFrameView )
504 aSdOptionsMiscItem.GetOptionsMisc().SetSummationOfParagraphs( pDoc->IsSummationOfParagraphs() );
505 aSdOptionsMiscItem.GetOptionsMisc().SetPrinterIndependentLayout (
506 (USHORT)pDoc->GetPrinterIndependentLayout());
508 pRet->Put( aSdOptionsMiscItem );
511 // TP_OPTIONS_SNAP:
512 pRet->Put( SdOptionsSnapItem( ATTR_OPTIONS_SNAP, pOptions, pFrameView ) );
514 // TP_SCALE:
515 UINT32 nW = 10L;
516 UINT32 nH = 10L;
517 INT32 nX;
518 INT32 nY;
519 if( pDocSh )
521 SdrPage* pPage = (SdrPage*) pDoc->GetSdPage(0, PK_STANDARD);
522 Size aSize(pPage->GetSize());
523 nW = aSize.Width();
524 nH = aSize.Height();
527 if(pFrameView)
529 const Fraction& rFraction = pDoc->GetUIScale();
530 nX=rFraction.GetNumerator();
531 nY=rFraction.GetDenominator();
533 else
535 // Optionen aus Configdatei holen
536 pOptions->GetScale( nX, nY );
539 pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
540 pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
541 pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_WIDTH, nW ) );
542 pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_HEIGHT, nH ) );
545 // TP_OPTIONS_PRINT:
546 pRet->Put( SdOptionsPrintItem( ATTR_OPTIONS_PRINT, pOptions ) );
548 // RID_SVXPAGE_GRID:
549 pRet->Put( SdOptionsGridItem( SID_ATTR_GRID_OPTIONS, pOptions ) );
551 return pRet;
553 void SdModule::ApplyItemSet( USHORT nSlot, const SfxItemSet& rSet )
555 const SfxPoolItem* pItem = NULL;
556 BOOL bNewDefTab = FALSE;
557 BOOL bNewPrintOptions = FALSE;
558 BOOL bMiscOptions = FALSE;
560 ::sd::FrameView* pFrameView = NULL;
561 ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
562 SdDrawDocument* pDoc = NULL;
563 // Hier wird der DocType vom Optionsdialog gesetzt (nicht Dokument!)
564 DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
565 if( nSlot == SID_SD_GRAPHIC_OPTIONS )
566 eDocType = DOCUMENT_TYPE_DRAW;
568 ::sd::ViewShell* pViewShell = NULL;
570 if (pDocSh)
572 pDoc = pDocSh->GetDoc();
574 // Wenn der Optionsdialog zum Dokumenttyp identisch ist,
575 // kann auch die FrameView mit uebergeben werden:
576 if( pDoc && eDocType == pDoc->GetDocumentType() )
577 pFrameView = pDocSh->GetFrameView();
579 pViewShell = pDocSh->GetViewShell();
580 if (pViewShell != NULL)
581 pViewShell->WriteFrameViewData();
583 SdOptions* pOptions = GetSdOptions(eDocType);
584 // Raster
585 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS ,
586 FALSE, (const SfxPoolItem**) &pItem ))
588 const SdOptionsGridItem* pGridItem = (SdOptionsGridItem*) pItem;
589 pGridItem->SetOptions( pOptions );
592 // Layout
593 const SdOptionsLayoutItem* pLayoutItem = NULL;
594 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_LAYOUT,
595 FALSE, (const SfxPoolItem**) &pLayoutItem ))
597 pLayoutItem->SetOptions( pOptions );
600 // Metric
601 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC, FALSE, &pItem ) )
603 if( pDoc && eDocType == pDoc->GetDocumentType() )
604 PutItem( *pItem );
605 pOptions->SetMetric( ( (SfxUInt16Item*) pItem )->GetValue() );
607 UINT16 nDefTab = pOptions->GetDefTab();
608 // Default-Tabulator
609 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_DEFTABSTOP, FALSE, &pItem ) )
611 nDefTab = ( (SfxUInt16Item*) pItem )->GetValue();
612 pOptions->SetDefTab( nDefTab );
614 bNewDefTab = TRUE;
617 // Massstab
618 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_X, FALSE, &pItem ) )
620 INT32 nX = ( (SfxInt32Item*) pItem )->GetValue();
621 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_Y, FALSE, &pItem ) )
623 INT32 nY = ( (SfxInt32Item*) pItem )->GetValue();
624 pOptions->SetScale( nX, nY );
626 // #92067# Apply to document only if doc type match
627 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
629 pDoc->SetUIScale( Fraction( nX, nY ) );
630 if( pViewShell )
631 pViewShell->SetRuler( pViewShell->HasRuler() );
636 // Contents (Inhalte)
637 const SdOptionsContentsItem* pContentsItem = NULL;
638 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_CONTENTS,
639 FALSE, (const SfxPoolItem**) &pContentsItem ))
641 pContentsItem->SetOptions( pOptions );
644 // Misc (Sonstiges)
645 const SdOptionsMiscItem* pMiscItem = NULL;
646 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_MISC,
647 FALSE, (const SfxPoolItem**) &pMiscItem ))
649 pMiscItem->SetOptions( pOptions );
650 bMiscOptions = TRUE;
653 // Fangen/Einrasten
654 const SdOptionsSnapItem* pSnapItem = NULL;
655 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SNAP,
656 FALSE, (const SfxPoolItem**) &pSnapItem ))
658 pSnapItem->SetOptions( pOptions );
661 SfxItemSet aPrintSet( GetPool(),
662 SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
663 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
664 ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT,
665 0 );
667 // Drucken
668 const SdOptionsPrintItem* pPrintItem = NULL;
669 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_PRINT,
670 FALSE, (const SfxPoolItem**) &pPrintItem ))
672 pPrintItem->SetOptions( pOptions );
674 // PrintOptionsSet setzen
675 SdOptionsPrintItem aPrintItem( ATTR_OPTIONS_PRINT, pOptions );
676 SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC );
677 USHORT nFlags = 0;
679 nFlags = (aPrintItem.GetOptionsPrint().IsWarningSize() ? SFX_PRINTER_CHG_SIZE : 0) |
680 (aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SFX_PRINTER_CHG_ORIENTATION : 0);
681 aFlagItem.SetValue( nFlags );
683 aPrintSet.Put( aPrintItem );
684 aPrintSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
685 aPrintSet.Put( aFlagItem );
687 bNewPrintOptions = TRUE;
690 // Nur, wenn auch der Dokumenttyp uebereinstimmt...
691 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
693 if( bNewPrintOptions )
695 pDocSh->GetPrinter(TRUE)->SetOptions( aPrintSet );
698 // Am Model den DefTab setzen
699 if( bNewDefTab )
701 SdDrawDocument* pDocument = pDocSh->GetDoc();
702 pDocument->SetDefaultTabulator( nDefTab );
704 ::sd::Outliner* pOutl = pDocument->GetOutliner( FALSE );
705 if( pOutl )
706 pOutl->SetDefTab( nDefTab );
708 ::sd::Outliner* pInternalOutl = pDocument->GetInternalOutliner( FALSE );
709 if( pInternalOutl )
710 pInternalOutl->SetDefTab( nDefTab );
712 if ( bMiscOptions )
714 pDoc->SetSummationOfParagraphs( pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() );
715 sal_uInt32 nSum = pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() ? EE_CNTRL_ULSPACESUMMATION : 0;
716 sal_uInt32 nCntrl;
718 SdDrawDocument* pDocument = pDocSh->GetDoc();
719 SdrOutliner& rOutl = pDocument->GetDrawOutliner( FALSE );
720 nCntrl = rOutl.GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
721 rOutl.SetControlWord( nCntrl | nSum );
722 ::sd::Outliner* pOutl = pDocument->GetOutliner( FALSE );
723 if( pOutl )
725 nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
726 pOutl->SetControlWord( nCntrl | nSum );
728 pOutl = pDocument->GetInternalOutliner( FALSE );
729 if( pOutl )
731 nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
732 pOutl->SetControlWord( nCntrl | nSum );
735 // Set printer independent layout mode.
736 if( pDoc->GetPrinterIndependentLayout() != pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout() )
737 pDoc->SetPrinterIndependentLayout (pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout());
741 pOptions->StoreConfig();
743 // Nur, wenn auch der Dokumenttyp uebereinstimmt...
744 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
746 FieldUnit eUIUnit = (FieldUnit) pOptions->GetMetric();
747 pDoc->SetUIUnit(eUIUnit);
749 if (pViewShell)
751 // #74495# make sure no one is in text edit mode, cause there
752 // are some pointers remembered else (!)
753 if(pViewShell->GetView())
754 pViewShell->GetView()->SdrEndTextEdit();
756 ::sd::FrameView* pFrame = pViewShell->GetFrameView();
757 pFrame->Update(pOptions);
758 pViewShell->ReadFrameViewData(pFrame);
759 pViewShell->SetUIUnit(eUIUnit);
760 pViewShell->SetDefTabHRuler( nDefTab );
764 if( pViewShell && pViewShell->GetViewFrame() )
765 pViewShell->GetViewFrame()->GetBindings().InvalidateAll( TRUE );
768 SfxTabPage* SdModule::CreateTabPage( USHORT nId, Window* pParent, const SfxItemSet& rSet )
770 SfxTabPage* pRet = NULL;
771 SfxAllItemSet aSet(*(rSet.GetPool()));
772 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
773 if( pFact )
775 switch(nId)
777 case SID_SD_TP_CONTENTS:
778 case SID_SI_TP_CONTENTS:
779 { ::CreateTabPage fnCreatePage = pFact->GetSdOptionsContentsTabPageCreatorFunc();
780 if( fnCreatePage )
781 pRet = (*fnCreatePage)( pParent, rSet );
783 break;
784 case SID_SD_TP_SNAP:
785 case SID_SI_TP_SNAP:
786 { ::CreateTabPage fnCreatePage = pFact->GetSdOptionsSnapTabPageCreatorFunc();
787 if( fnCreatePage )
788 pRet = (*fnCreatePage)( pParent, rSet );
790 break;
791 case SID_SD_TP_PRINT:
792 case SID_SI_TP_PRINT:
794 ::CreateTabPage fnCreatePage = pFact->GetSdPrintOptionsTabPageCreatorFunc();
795 if( fnCreatePage )
797 pRet = (*fnCreatePage)( pParent, rSet );
798 if(SID_SD_TP_PRINT == nId)
799 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
800 pRet->PageCreated(aSet);
803 break;
804 case SID_SI_TP_MISC:
805 case SID_SD_TP_MISC:
807 ::CreateTabPage fnCreatePage = pFact->GetSdOptionsMiscTabPageCreatorFunc();
808 if( fnCreatePage )
810 pRet = (*fnCreatePage)( pParent, rSet );
811 if(SID_SD_TP_MISC == nId)
812 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
813 else
814 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_IMPRESS_MODE));
815 pRet->PageCreated(aSet);
818 break;
819 case RID_OFA_TP_INTERNATIONAL_SD:
820 case RID_OFA_TP_INTERNATIONAL_IMPR:
821 case RID_SVXPAGE_TEXTANIMATION :
823 SfxAbstractDialogFactory* pSfxFact = SfxAbstractDialogFactory::Create();
824 if ( pSfxFact )
826 ::CreateTabPage fnCreatePage = pSfxFact->GetTabPageCreatorFunc( nId );
827 if ( fnCreatePage )
828 pRet = (*fnCreatePage)( pParent, rSet );
831 break;
833 DBG_ASSERT( pRet, "SdModule::CreateTabPage(): no valid ID for TabPage!" );
836 return pRet;