bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / app / sdmod2.cxx
blobed8e7c29a5d99c302e2b074d3fd28ca87df7a350
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <editeng/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>
45 #include <svx/sdr/contact/displayinfo.hxx>
47 #include "sdmod.hxx"
48 #include "app.hrc"
49 #include "glob.hrc"
50 #include "strings.hrc"
51 #include "res_bmp.hrc"
52 #include "ViewShell.hxx"
53 #include "FrameView.hxx"
54 #include "sdattr.hxx"
55 #include "tpoption.hrc"
56 #include "optsitem.hxx"
57 #include "DrawDocShell.hxx"
58 #include "drawdoc.hxx"
59 #include "Outliner.hxx"
60 #include "sdresid.hxx"
61 #include "pres.hxx"
62 #include "DrawViewShell.hxx"
63 #include "OutlineViewShell.hxx"
64 #include "OutlineView.hxx"
65 #include "ViewShellBase.hxx"
66 #include "sdpage.hxx"
67 #include "sdxfer.hxx"
68 #include "sdabstdlg.hxx"
69 #include "prntopts.hrc"
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* pViewSh, EditFieldInfo* pInfo, bool& bMasterView )
76 if( !pInfo )
77 return 0;
79 bMasterView = false;
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.
85 if( pPage )
87 bMasterView = false;
88 return pPage;
91 // first try to check if we are inside the outline view
92 sd::OutlineView* pSdView = NULL;
93 if( pViewSh && pViewSh->ISA(sd::OutlineViewShell))
94 pSdView = static_cast<sd::OutlineView*> (static_cast<sd::OutlineViewShell*>(pViewSh)->GetView());
96 if (pSdView != NULL && (pOutliner == pSdView->GetOutliner()))
98 // outline mode
99 int nPgNum = 0;
100 Outliner* pOutl = pSdView->GetOutliner();
101 long nPos = pInfo->GetPara();
102 sal_Int32 nParaPos = 0;
104 for( Paragraph* pPara = pOutl->GetParagraph( 0 ); pPara && nPos >= 0; pPara = pOutl->GetParagraph( ++nParaPos ), nPos-- )
106 if( pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
107 nPgNum++;
110 pPage = pViewSh->GetDoc()->GetSdPage( (sal_uInt16)nPgNum, PK_STANDARD );
112 else
114 // draw mode, slide mode and preview. Get the processed page from the outliner
115 if(pOutliner)
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 formated from the document
126 if(!pPage)
128 const SdrTextObj* pTextObj = (pViewSh && pViewSh->GetDoc()) ? pViewSh->GetDoc()->GetFormattingTextObj() : NULL;
130 if( pTextObj )
132 pPage = dynamic_cast< SdPage* >( pTextObj->GetPage() );
136 if(pPage)
138 bMasterView = pPage && pPage->IsMasterPage();
142 return pPage;
146 * Link for CalcFieldValue of Outliners
148 IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo)
150 if (pInfo)
152 const SvxFieldData* pField = pInfo->GetField().GetField();
153 ::sd::DrawDocShell* pDocShell = NULL;
154 SdDrawDocument* pDoc = 0;
156 SdrOutliner* pSdrOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
157 if( pSdrOutliner )
159 const SdrTextObj* pTextObj = pSdrOutliner->GetTextObj();
161 if( pTextObj )
162 pDoc = dynamic_cast< SdDrawDocument* >( pTextObj->GetModel() );
164 if( pDoc )
165 pDocShell = pDoc->GetDocSh();
168 if( !pDocShell )
169 pDocShell = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
171 const SvxDateField* pDateField = 0;
172 const SvxExtTimeField* pExtTimeField = 0;
173 const SvxExtFileField* pExtFileField = 0;
174 const SvxAuthorField* pAuthorField = 0;
175 const SvxURLField* pURLField = 0;
177 if( (pDateField = dynamic_cast< const SvxDateField* >(pField)) != 0 )
179 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
180 pInfo->SetRepresentation( pDateField->GetFormatted( *GetNumberFormatter(), eLang ) );
182 else if( (pExtTimeField = dynamic_cast< const SvxExtTimeField *>(pField)) != 0 )
184 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
185 pInfo->SetRepresentation( pExtTimeField->GetFormatted( *GetNumberFormatter(), eLang ) );
187 else if( (pExtFileField = dynamic_cast< const SvxExtFileField * >(pField)) != 0 )
189 if( pDocShell && (pExtFileField->GetType() != SVXFILETYPE_FIX) )
191 String aName;
192 if( pDocShell->HasName() )
193 aName = pDocShell->GetMedium()->GetName();
194 else
195 aName = pDocShell->GetName();
197 const_cast< SvxExtFileField* >(pExtFileField)->SetFile( aName );
199 pInfo->SetRepresentation( pExtFileField->GetFormatted() );
202 else if( (pAuthorField = dynamic_cast< const SvxAuthorField* >( pField )) != 0 )
204 if( pAuthorField->GetType() != SVXAUTHORTYPE_FIX )
206 SvtUserOptions aUserOptions;
207 SvxAuthorField aAuthorField(
208 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID(),
209 pAuthorField->GetType(), pAuthorField->GetFormat() );
211 *(const_cast< SvxAuthorField* >(pAuthorField)) = aAuthorField;
213 pInfo->SetRepresentation( pAuthorField->GetFormatted() );
216 else if( dynamic_cast< const SvxPageField* >(pField) )
218 String aRepresentation;
219 aRepresentation += sal_Unicode( ' ' );
221 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
222 if(pViewSh == NULL)
224 ::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
225 if(pBase)
226 pViewSh = pBase->GetMainViewShell().get();
228 if( !pDoc && pViewSh )
229 pDoc = pViewSh->GetDoc();
231 bool bMasterView;
232 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
234 if( pPage && pDoc && !bMasterView )
236 int nPgNum;
238 if( (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
240 nPgNum = pViewSh->GetPrintedHandoutPageNum();
242 else
244 nPgNum = (pPage->GetPageNum() - 1) / 2 + 1;
246 aRepresentation = pDoc->CreatePageNumValue((sal_uInt16)nPgNum);
248 else
249 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_NUMBER).toString();
251 pInfo->SetRepresentation( aRepresentation );
253 else if( dynamic_cast< const SvxPagesField* >(pField) )
255 String aRepresentation;
256 aRepresentation += sal_Unicode( ' ' );
258 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
259 if(pViewSh == NULL)
261 ::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
262 if(pBase)
263 pViewSh = pBase->GetMainViewShell().get();
265 if( !pDoc && pViewSh )
266 pDoc = pViewSh->GetDoc();
268 bool bMasterView;
269 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
271 sal_uInt16 nPageCount = 0;
273 if( !bMasterView )
275 if( pPage && (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
277 nPageCount = pViewSh->GetPrintedHandoutPageCount();
279 else if( pDoc )
281 nPageCount = (sal_uInt16)pDoc->GetSdPageCount(PK_STANDARD);
285 if( nPageCount > 0 )
286 aRepresentation = pDoc->CreatePageNumValue(nPageCount);
287 else
288 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_COUNT).toString();
290 pInfo->SetRepresentation( aRepresentation );
292 else if( (pURLField = dynamic_cast< const SvxURLField* >(pField)) != 0 )
294 switch ( pURLField->GetFormat() )
296 case SVXURLFORMAT_APPDEFAULT: //!!! adjustable at App???
297 case SVXURLFORMAT_REPR:
298 pInfo->SetRepresentation( pURLField->GetRepresentation() );
299 break;
301 case SVXURLFORMAT_URL:
302 pInfo->SetRepresentation( pURLField->GetURL() );
303 break;
306 String aURL = pURLField->GetURL();
308 svtools::ColorConfig aConfig;
309 svtools::ColorConfigEntry eEntry =
310 INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS;
311 pInfo->SetTxtColor( aConfig.GetColorValue(eEntry).nColor );
313 else if ( dynamic_cast< const SdrMeasureField* >(pField))
315 pInfo->ClearFldColor();
317 else
319 String aRepresentation;
321 bool bHeaderField = dynamic_cast< const SvxHeaderField* >( pField ) != 0;
322 bool bFooterField = !bHeaderField && (dynamic_cast< const SvxFooterField* >( pField ) != 0 );
323 bool bDateTimeField = !bHeaderField && !bFooterField && (dynamic_cast< const SvxDateTimeField* >( pField ) != 0);
325 if( bHeaderField || bFooterField || bDateTimeField )
327 sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
328 bool bMasterView = false;
329 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
331 if( (pPage == NULL) || bMasterView )
333 if( bHeaderField )
334 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_HEADER).toString();
335 else if (bFooterField )
336 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_FOOTER).toString();
337 else if (bDateTimeField )
338 aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_DATETIME).toString();
340 else
342 const sd::HeaderFooterSettings &rSettings = pPage->getHeaderFooterSettings();
344 if( bHeaderField )
346 aRepresentation = rSettings.maHeaderText;
348 else if( bFooterField )
350 aRepresentation = rSettings.maFooterText;
352 else if( bDateTimeField )
354 if( rSettings.mbDateTimeIsFixed )
356 aRepresentation = rSettings.maDateTimeText;
358 else
360 Date aDate( Date::SYSTEM );
361 Time aTime( Time::SYSTEM );
362 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
363 aRepresentation = SvxDateTimeField::GetFormatted( aDate, aTime, (SvxDateFormat)rSettings.meDateTimeFormat, *GetNumberFormatter(), eLang );
368 else
370 OSL_FAIL("sd::SdModule::CalcFieldValueHdl(), unknown field type!");
373 if( aRepresentation.Len() == 0 ) // TODO: Edit engine doesn't handle empty fields?
374 aRepresentation += sal_Unicode( ' ' );
375 pInfo->SetRepresentation( aRepresentation );
379 return(0);
384 * virtual methods for option dialog
386 SfxItemSet* SdModule::CreateItemSet( sal_uInt16 nSlot )
388 ::sd::FrameView* pFrameView = NULL;
389 ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
390 SdDrawDocument* pDoc = NULL;
392 // Here we set the DocType of the option dialog (not document!)
393 DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
394 if( nSlot == SID_SD_GRAPHIC_OPTIONS )
395 eDocType = DOCUMENT_TYPE_DRAW;
397 if (pDocSh)
399 pDoc = pDocSh->GetDoc();
401 // If the option dialog is identical to the document type,
402 // we can pass the FrameView too:
403 if( pDoc && eDocType == pDoc->GetDocumentType() )
404 pFrameView = pDocSh->GetFrameView();
406 ::sd::ViewShell* pViewShell = pDocSh->GetViewShell();
407 if (pViewShell != NULL)
408 pViewShell->WriteFrameViewData();
411 SdOptions* pOptions = GetSdOptions(eDocType);
413 // Pool has by default MapUnit Twips (Awgh!)
414 SfxItemPool& rPool = GetPool();
415 rPool.SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
417 SfxItemSet* pRet = new SfxItemSet( rPool,
418 SID_ATTR_METRIC, SID_ATTR_METRIC,
419 SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP,
421 ATTR_OPTIONS_LAYOUT, ATTR_OPTIONS_LAYOUT,
422 ATTR_OPTIONS_CONTENTS, ATTR_OPTIONS_CONTENTS,
423 ATTR_OPTIONS_MISC, ATTR_OPTIONS_MISC,
425 ATTR_OPTIONS_SNAP, ATTR_OPTIONS_SNAP,
427 ATTR_OPTIONS_SCALE_START, ATTR_OPTIONS_SCALE_END,
429 ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT,
431 SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS,
432 0 );
434 // TP_OPTIONS_LAYOUT:
435 pRet->Put( SdOptionsLayoutItem( ATTR_OPTIONS_LAYOUT, pOptions, pFrameView ) );
437 sal_uInt16 nDefTab = 0;
438 if( pFrameView)
439 nDefTab = pDoc->GetDefaultTabulator();
440 else
441 nDefTab = pOptions->GetDefTab();
442 pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, nDefTab ) );
444 FieldUnit nMetric = (FieldUnit)0xffff;
445 if( pFrameView)
446 nMetric = pDoc->GetUIUnit();
447 else
448 nMetric = (FieldUnit)pOptions->GetMetric();
450 if( nMetric == (FieldUnit)0xffff )
451 nMetric = GetFieldUnit();
453 pRet->Put( SfxUInt16Item( SID_ATTR_METRIC, (sal_uInt16)nMetric ) );
455 // TP_OPTIONS_CONTENTS:
456 pRet->Put( SdOptionsContentsItem( ATTR_OPTIONS_CONTENTS, pOptions, pFrameView ) );
458 // TP_OPTIONS_MISC:
459 SdOptionsMiscItem aSdOptionsMiscItem( ATTR_OPTIONS_MISC, pOptions, pFrameView );
460 if ( pFrameView )
462 aSdOptionsMiscItem.GetOptionsMisc().SetSummationOfParagraphs( pDoc->IsSummationOfParagraphs() );
463 aSdOptionsMiscItem.GetOptionsMisc().SetPrinterIndependentLayout (
464 (sal_uInt16)pDoc->GetPrinterIndependentLayout());
466 pRet->Put( aSdOptionsMiscItem );
469 // TP_OPTIONS_SNAP:
470 pRet->Put( SdOptionsSnapItem( ATTR_OPTIONS_SNAP, pOptions, pFrameView ) );
472 // TP_SCALE:
473 sal_uInt32 nW = 10L;
474 sal_uInt32 nH = 10L;
475 sal_Int32 nX;
476 sal_Int32 nY;
477 if( pDocSh )
479 SdrPage* pPage = (SdrPage*) pDoc->GetSdPage(0, PK_STANDARD);
480 Size aSize(pPage->GetSize());
481 nW = aSize.Width();
482 nH = aSize.Height();
485 if(pFrameView)
487 const Fraction& rFraction = pDoc->GetUIScale();
488 nX=rFraction.GetNumerator();
489 nY=rFraction.GetDenominator();
491 else
493 // Get options from configuration file
494 pOptions->GetScale( nX, nY );
497 pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
498 pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
499 pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_WIDTH, nW ) );
500 pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_HEIGHT, nH ) );
503 // TP_OPTIONS_PRINT:
504 pRet->Put( SdOptionsPrintItem( ATTR_OPTIONS_PRINT, pOptions ) );
506 // RID_SVXPAGE_GRID:
507 pRet->Put( SdOptionsGridItem( SID_ATTR_GRID_OPTIONS, pOptions ) );
509 return pRet;
511 void SdModule::ApplyItemSet( sal_uInt16 nSlot, const SfxItemSet& rSet )
513 const SfxPoolItem* pItem = NULL;
514 sal_Bool bNewDefTab = sal_False;
515 sal_Bool bNewPrintOptions = sal_False;
516 sal_Bool bMiscOptions = sal_False;
518 ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
519 SdDrawDocument* pDoc = NULL;
520 // Here we set the DocType of the option dialog (not document!)
521 DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
522 if( nSlot == SID_SD_GRAPHIC_OPTIONS )
523 eDocType = DOCUMENT_TYPE_DRAW;
525 ::sd::ViewShell* pViewShell = NULL;
527 if (pDocSh)
529 pDoc = pDocSh->GetDoc();
531 pViewShell = pDocSh->GetViewShell();
532 if (pViewShell != NULL)
533 pViewShell->WriteFrameViewData();
535 SdOptions* pOptions = GetSdOptions(eDocType);
536 // Grid
537 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS ,
538 sal_False, (const SfxPoolItem**) &pItem ))
540 const SdOptionsGridItem* pGridItem = (SdOptionsGridItem*) pItem;
541 pGridItem->SetOptions( pOptions );
544 // Layout
545 const SdOptionsLayoutItem* pLayoutItem = NULL;
546 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_LAYOUT,
547 sal_False, (const SfxPoolItem**) &pLayoutItem ))
549 pLayoutItem->SetOptions( pOptions );
552 // Metric
553 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC, sal_False, &pItem ) )
555 if( pDoc && eDocType == pDoc->GetDocumentType() )
556 PutItem( *pItem );
557 pOptions->SetMetric( ( (SfxUInt16Item*) pItem )->GetValue() );
559 sal_uInt16 nDefTab = pOptions->GetDefTab();
560 // Default-Tabulator
561 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_DEFTABSTOP, sal_False, &pItem ) )
563 nDefTab = ( (SfxUInt16Item*) pItem )->GetValue();
564 pOptions->SetDefTab( nDefTab );
566 bNewDefTab = sal_True;
569 // Scale
570 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_X, sal_False, &pItem ) )
572 sal_Int32 nX = ( (SfxInt32Item*) pItem )->GetValue();
573 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_Y, sal_False, &pItem ) )
575 sal_Int32 nY = ( (SfxInt32Item*) pItem )->GetValue();
576 pOptions->SetScale( nX, nY );
578 // Apply to document only if doc type match
579 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
581 pDoc->SetUIScale( Fraction( nX, nY ) );
582 if( pViewShell )
583 pViewShell->SetRuler( pViewShell->HasRuler() );
588 // Contents
589 const SdOptionsContentsItem* pContentsItem = NULL;
590 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_CONTENTS,
591 sal_False, (const SfxPoolItem**) &pContentsItem ))
593 pContentsItem->SetOptions( pOptions );
596 // Misc
597 const SdOptionsMiscItem* pMiscItem = NULL;
598 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_MISC,
599 sal_False, (const SfxPoolItem**) &pMiscItem ))
601 pMiscItem->SetOptions( pOptions );
602 bMiscOptions = sal_True;
605 // Snap
606 const SdOptionsSnapItem* pSnapItem = NULL;
607 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SNAP,
608 sal_False, (const SfxPoolItem**) &pSnapItem ))
610 pSnapItem->SetOptions( pOptions );
613 SfxItemSet aPrintSet( GetPool(),
614 SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
615 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
616 ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT,
617 0 );
619 // Print
620 const SdOptionsPrintItem* pPrintItem = NULL;
621 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_PRINT,
622 sal_False, (const SfxPoolItem**) &pPrintItem ))
624 pPrintItem->SetOptions( pOptions );
626 // set PrintOptionsSet
627 SdOptionsPrintItem aPrintItem( ATTR_OPTIONS_PRINT, pOptions );
628 SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC );
629 sal_uInt16 nFlags = 0;
631 nFlags = (aPrintItem.GetOptionsPrint().IsWarningSize() ? SFX_PRINTER_CHG_SIZE : 0) |
632 (aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SFX_PRINTER_CHG_ORIENTATION : 0);
633 aFlagItem.SetValue( nFlags );
635 aPrintSet.Put( aPrintItem );
636 aPrintSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
637 aPrintSet.Put( aFlagItem );
639 bNewPrintOptions = sal_True;
642 // Only if also the document type matches...
643 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
645 if( bNewPrintOptions )
647 pDocSh->GetPrinter(sal_True)->SetOptions( aPrintSet );
650 // set DefTab at Model
651 if( bNewDefTab )
653 SdDrawDocument* pDocument = pDocSh->GetDoc();
654 pDocument->SetDefaultTabulator( nDefTab );
656 ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
657 if( pOutl )
658 pOutl->SetDefTab( nDefTab );
660 ::sd::Outliner* pInternalOutl = pDocument->GetInternalOutliner( sal_False );
661 if( pInternalOutl )
662 pInternalOutl->SetDefTab( nDefTab );
664 if ( bMiscOptions )
666 pDoc->SetSummationOfParagraphs( pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() );
667 sal_uInt32 nSum = pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() ? EE_CNTRL_ULSPACESUMMATION : 0;
668 sal_uInt32 nCntrl;
670 SdDrawDocument* pDocument = pDocSh->GetDoc();
671 SdrOutliner& rOutl = pDocument->GetDrawOutliner();
672 nCntrl = rOutl.GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
673 rOutl.SetControlWord( nCntrl | nSum );
674 ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
675 if( pOutl )
677 nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
678 pOutl->SetControlWord( nCntrl | nSum );
680 pOutl = pDocument->GetInternalOutliner( sal_False );
681 if( pOutl )
683 nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
684 pOutl->SetControlWord( nCntrl | nSum );
687 // Set printer independent layout mode.
688 if( pDoc->GetPrinterIndependentLayout() != pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout() )
689 pDoc->SetPrinterIndependentLayout (pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout());
693 pOptions->StoreConfig();
695 // Only if also the document type matches...
696 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
698 FieldUnit eUIUnit = (FieldUnit) pOptions->GetMetric();
699 pDoc->SetUIUnit(eUIUnit);
701 if (pViewShell)
703 // make sure no one is in text edit mode, cause there
704 // are some pointers remembered else (!)
705 if(pViewShell->GetView())
706 pViewShell->GetView()->SdrEndTextEdit();
708 ::sd::FrameView* pFrame = pViewShell->GetFrameView();
709 pFrame->Update(pOptions);
710 pViewShell->ReadFrameViewData(pFrame);
711 pViewShell->SetUIUnit(eUIUnit);
712 pViewShell->SetDefTabHRuler( nDefTab );
716 if( pViewShell && pViewShell->GetViewFrame() )
717 pViewShell->GetViewFrame()->GetBindings().InvalidateAll( sal_True );
720 SfxTabPage* SdModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
722 SfxTabPage* pRet = NULL;
723 SfxAllItemSet aSet(*(rSet.GetPool()));
724 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
725 if( pFact )
727 switch(nId)
729 case SID_SD_TP_CONTENTS:
730 case SID_SI_TP_CONTENTS:
731 { ::CreateTabPage fnCreatePage = pFact->GetSdOptionsContentsTabPageCreatorFunc();
732 if( fnCreatePage )
733 pRet = (*fnCreatePage)( pParent, rSet );
735 break;
736 case SID_SD_TP_SNAP:
737 case SID_SI_TP_SNAP:
738 { ::CreateTabPage fnCreatePage = pFact->GetSdOptionsSnapTabPageCreatorFunc();
739 if( fnCreatePage )
740 pRet = (*fnCreatePage)( pParent, rSet );
742 break;
743 case SID_SD_TP_PRINT:
744 case SID_SI_TP_PRINT:
746 ::CreateTabPage fnCreatePage = pFact->GetSdPrintOptionsTabPageCreatorFunc();
747 if( fnCreatePage )
749 pRet = (*fnCreatePage)( pParent, rSet );
750 if(SID_SD_TP_PRINT == nId)
751 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
752 pRet->PageCreated(aSet);
755 break;
756 case SID_SI_TP_MISC:
757 case SID_SD_TP_MISC:
759 ::CreateTabPage fnCreatePage = pFact->GetSdOptionsMiscTabPageCreatorFunc();
760 if( fnCreatePage )
762 pRet = (*fnCreatePage)( pParent, rSet );
763 if(SID_SD_TP_MISC == nId)
764 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
765 else
766 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_IMPRESS_MODE));
767 pRet->PageCreated(aSet);
770 break;
771 case RID_OFA_TP_INTERNATIONAL_SD:
772 case RID_OFA_TP_INTERNATIONAL_IMPR:
773 case RID_SVXPAGE_TEXTANIMATION :
775 SfxAbstractDialogFactory* pSfxFact = SfxAbstractDialogFactory::Create();
776 if ( pSfxFact )
778 ::CreateTabPage fnCreatePage = pSfxFact->GetTabPageCreatorFunc( nId );
779 if ( fnCreatePage )
780 pRet = (*fnCreatePage)( pParent, rSet );
783 break;
785 DBG_ASSERT( pRet, "SdModule::CreateTabPage(): no valid ID for TabPage!" );
788 return pRet;
791 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */