xref: /aoo41x/main/sd/source/ui/app/sdmod2.cxx (revision 46d2a04e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 #include <editeng/eeitem.hxx>
27 #include <editeng/flditem.hxx>
28 #include <sfx2/printer.hxx>
29 #include <svl/inethist.hxx>
30 #include <svl/poolitem.hxx>
31 #include <svl/flagitem.hxx>
32 #include <unotools/useroptions.hxx>
33 #include <sfx2/bindings.hxx>
34 #include <vcl/msgbox.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #include <sfx2/docfile.hxx>
37 #include <sfx2/request.hxx>
38 
39 #include <editeng/measfld.hxx>
40 #include <editeng/editstat.hxx>
41 #include <editeng/editeng.hxx>
42 
43 #include <svx/dialogs.hrc>
44 #include <svx/svdotext.hxx>
45 #include <svx/svdpagv.hxx>
46 #include <svx/svdopage.hxx>
47 
48 #include <sfx2/sfxdlg.hxx>
49 
50 
51 #include <svx/sdr/contact/displayinfo.hxx>
52 
53 #define _SD_DLL                 // fuer SD_MOD()
54 #include "sdmod.hxx"
55 #include "sddll.hxx"
56 #include "app.hrc"
57 #include "glob.hrc"
58 #include "strings.hrc"
59 #include "res_bmp.hrc"
60 #include "ViewShell.hxx"
61 #ifndef SD_FRAMW_VIEW_HXX
62 #include "FrameView.hxx"
63 #endif
64 #include "sdattr.hxx"
65 #include "tpoption.hrc"
66 #include "optsitem.hxx"
67 #include "DrawDocShell.hxx"
68 #include "drawdoc.hxx"
69 #include "Outliner.hxx"
70 #include "sdresid.hxx"
71 #include "pres.hxx"
72 #include "DrawViewShell.hxx"
73 #include "OutlineViewShell.hxx"
74 #include "OutlineView.hxx"
75 #include "ViewShellBase.hxx"
76 #include "sdpage.hxx"
77 #include "sdxfer.hxx"
78 #include "sdabstdlg.hxx"
79 #include "tpoption.hrc"
80 #include "prntopts.hrc"
81 #include <svl/intitem.hxx>
82 
83 /** retrieves the page that is currently painted. This will only be the master page
84 	if the current drawn view only shows the master page*/
GetCurrentPage(sd::ViewShell * pViewSh,EditFieldInfo * pInfo,bool & bMasterView)85 static SdPage* GetCurrentPage( sd::ViewShell* pViewSh, EditFieldInfo* pInfo, bool& bMasterView )
86 {
87 	if( !pInfo )
88 		return 0;
89 
90 	bMasterView = false;
91 	SdPage* pPage = dynamic_cast< SdPage* >( pInfo->GetSdrPage() );
92 	SdrOutliner* pOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
93 
94 	// special case, someone already set the current page on the EditFieldInfo
95 	// This is used from the svx::UnoGraphicsExporter f.e.
96 	if( pPage )
97 	{
98 		bMasterView = false;
99 		return pPage;
100 	}
101 
102 	// first try to check if we are inside the outline view
103 	sd::OutlineView* pSdView = NULL;
104 	if( pViewSh && pViewSh->ISA(sd::OutlineViewShell))
105 		pSdView = static_cast<sd::OutlineView*> (static_cast<sd::OutlineViewShell*>(pViewSh)->GetView());
106 
107 	if (pSdView != NULL && (pOutliner ==  pSdView->GetOutliner()))
108     {
109         // outline mode
110         int nPgNum = 0;
111         Outliner* pOutl = pSdView->GetOutliner();
112         long nPos = pInfo->GetPara();
113         sal_uLong nParaPos = 0;
114 
115         for( Paragraph* pPara = pOutl->GetParagraph( 0 ); pPara && nPos >= 0; pPara = pOutl->GetParagraph( ++nParaPos ), nPos-- )
116         {
117             if( pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
118                 nPgNum++;
119         }
120 
121 		pPage = pViewSh->GetDoc()->GetSdPage( (sal_uInt16)nPgNum, PK_STANDARD );
122 	}
123 	else
124 	{
125 		// draw mode, slide mode and preview. Get the processed page from the outliner
126 		if(pOutliner)
127 		{
128 			pPage = dynamic_cast< SdPage* >(const_cast< SdrPage* >(pOutliner->getVisualizedPage()));
129 		}
130 
131 		// The path using GetPaintingPageView() and GetCurrentPaintingDisplayInfo()
132 		// is no longer needed. I debugged and checked all usages of PageNumber decompositions
133 		// which all use the new possibility of setting the visualized page at the SdrOutliner.
134 
135 		// if all else failed, geht the current page from the object that is
136 		// currently formated from the document
137 		if(!pPage)
138 		{
139 			const SdrTextObj* pTextObj = (pViewSh && pViewSh->GetDoc()) ? pViewSh->GetDoc()->GetFormattingTextObj() : NULL;
140 
141 			if( pTextObj )
142 			{
143 				pPage = dynamic_cast< SdPage* >( pTextObj->GetPage() );
144 			}
145 		}
146 
147 		if(pPage)
148 		{
149 			bMasterView = pPage && pPage->IsMasterPage();
150 		}
151 	}
152 
153 	return pPage;
154 }
155 
156 /*************************************************************************
157 |*
158 |* Link fuer CalcFieldValue des Outliners
159 |*
160 \************************************************************************/
161 
IMPL_LINK(SdModule,CalcFieldValueHdl,EditFieldInfo *,pInfo)162 IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo)
163 {
164 	if (pInfo)
165 	{
166 		const SvxFieldData* pField = pInfo->GetField().GetField();
167         ::sd::DrawDocShell*     pDocShell = NULL;
168 		SdDrawDocument* pDoc = 0;
169 
170 		SdrOutliner* pSdrOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
171         if( pSdrOutliner )
172         {
173             const SdrTextObj* pTextObj = pSdrOutliner->GetTextObj();
174 
175 			if( pTextObj )
176 				pDoc = dynamic_cast< SdDrawDocument* >( pTextObj->GetModel() );
177 
178 			if( pDoc )
179                 pDocShell = pDoc->GetDocSh();
180         }
181 
182         if( !pDocShell )
183             pDocShell = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
184 
185 		const SvxDateField* pDateField = 0;
186 		const SvxExtTimeField* pExtTimeField = 0;
187 		const SvxExtFileField* pExtFileField = 0;
188 		const SvxAuthorField* pAuthorField = 0;
189 		const SvxURLField* pURLField = 0;
190 
191 		if( (pDateField = dynamic_cast< const SvxDateField* >(pField)) != 0 )
192 		{
193 			LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
194 			pInfo->SetRepresentation( pDateField->GetFormatted( *GetNumberFormatter(), eLang ) );
195 		}
196 		else if( (pExtTimeField = dynamic_cast< const SvxExtTimeField *>(pField)) != 0 )
197 		{
198 			LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
199 			pInfo->SetRepresentation( pExtTimeField->GetFormatted( *GetNumberFormatter(), eLang ) );
200 		}
201 		else if( (pExtFileField = dynamic_cast< const SvxExtFileField * >(pField)) != 0 )
202 		{
203 			if( pDocShell && (pExtFileField->GetType() != SVXFILETYPE_FIX) )
204 			{
205 				String aName;
206 				if( pDocShell->HasName() )
207 					aName = pDocShell->GetMedium()->GetName();
208 				else
209 					aName = pDocShell->GetName();
210 
211 				const_cast< SvxExtFileField* >(pExtFileField)->SetFile( aName );
212 			}
213 			pInfo->SetRepresentation( pExtFileField->GetFormatted() );
214 
215 		}
216 		else if( (pAuthorField = dynamic_cast< const SvxAuthorField* >( pField )) != 0  )
217 		{
218 			if( pAuthorField->GetType() != SVXAUTHORTYPE_FIX )
219 			{
220                 SvtUserOptions aUserOptions;
221                 SvxAuthorField aAuthorField(
222                         aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID(),
223                         pAuthorField->GetType(), pAuthorField->GetFormat() );
224 
225                 *(const_cast< SvxAuthorField* >(pAuthorField)) = aAuthorField;
226 			}
227 			pInfo->SetRepresentation( pAuthorField->GetFormatted() );
228 
229 		}
230 		else if( dynamic_cast< const SvxPageField*  >(pField) )
231 		{
232 			String aRepresentation;
233 			aRepresentation += sal_Unicode( ' ' );
234 
235 			::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
236 			if(pViewSh == NULL)
237             {
238                 ::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
239                 if(pBase)
240                     pViewSh = pBase->GetMainViewShell().get();
241             }
242 			if( !pDoc && pViewSh )
243 				pDoc = pViewSh->GetDoc();
244 
245 			bool bMasterView;
246 			SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
247 
248 			if( pPage && pDoc && !bMasterView )
249 			{
250 				int nPgNum;
251 
252 				if( (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
253 				{
254 					nPgNum = pViewSh->GetPrintedHandoutPageNum();
255 				}
256 				else
257 				{
258 					nPgNum = (pPage->GetPageNum() - 1) / 2 + 1;
259 				}
260 				aRepresentation = pDoc->CreatePageNumValue((sal_uInt16)nPgNum);
261 			}
262 			else
263 			{
264 				static String aNumberText( SdResId( STR_FIELD_PLACEHOLDER_NUMBER ) );
265 				aRepresentation = aNumberText;
266 			}
267 
268 			pInfo->SetRepresentation( aRepresentation );
269 		}
270 		else if( dynamic_cast< const SvxPagesField*  >(pField) )
271 		{
272 			String aRepresentation;
273 			aRepresentation += sal_Unicode( ' ' );
274 
275 			::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
276 			if(pViewSh == NULL)
277             {
278                 ::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
279                 if(pBase)
280                     pViewSh = pBase->GetMainViewShell().get();
281             }
282 			if( !pDoc && pViewSh )
283 				pDoc = pViewSh->GetDoc();
284 
285 			bool bMasterView;
286 			SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
287 
288             sal_uInt16 nPageCount = 0;
289 
290             if( !bMasterView )
291             {
292 			    if( pPage && (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
293 			    {
294 				    nPageCount = pViewSh->GetPrintedHandoutPageCount();
295 			    }
296 			    else if( pDoc )
297 			    {
298                     nPageCount = (sal_uInt16)pDoc->GetSdPageCount(PK_STANDARD);
299                 }
300             }
301 
302             if( nPageCount > 0 )
303             {
304 				aRepresentation = pDoc->CreatePageNumValue(nPageCount);
305 			}
306 			else
307 			{
308 				static String aNumberText( SdResId( STR_FIELD_PLACEHOLDER_COUNT ) );
309 				aRepresentation = aNumberText;
310 			}
311 
312 			pInfo->SetRepresentation( aRepresentation );
313 		}
314 		else if( (pURLField = dynamic_cast< const SvxURLField* >(pField)) != 0 )
315 		{
316 			switch ( pURLField->GetFormat() )
317 			{
318 				case SVXURLFORMAT_APPDEFAULT: //!!! einstellbar an App???
319 				case SVXURLFORMAT_REPR:
320 					pInfo->SetRepresentation( pURLField->GetRepresentation() );
321 					break;
322 
323 				case SVXURLFORMAT_URL:
324 					pInfo->SetRepresentation( pURLField->GetURL() );
325 					break;
326 			}
327 
328 			String aURL = pURLField->GetURL();
329 
330             svtools::ColorConfig aConfig;
331             svtools::ColorConfigEntry eEntry =
332                 INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS;
333 			pInfo->SetTxtColor( aConfig.GetColorValue(eEntry).nColor );
334 		}
335 		else if ( dynamic_cast< const SdrMeasureField* >(pField))
336 		{
337 			pInfo->ClearFldColor();
338 		}
339 		else
340 		{
341 			String aRepresentation;
342 
343 			bool bHeaderField = dynamic_cast< const SvxHeaderField* >( pField ) != 0;
344 			bool bFooterField = !bHeaderField && (dynamic_cast< const SvxFooterField* >( pField ) != 0 );
345 			bool bDateTimeField = !bHeaderField && !bFooterField && (dynamic_cast< const SvxDateTimeField* >( pField ) != 0);
346 
347 			if( bHeaderField || bFooterField || bDateTimeField )
348 			{
349 				sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
350 				bool bMasterView = false;
351 				SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
352 
353 				if( (pPage == NULL) || bMasterView )
354 				{
355 					if( bHeaderField )
356 					{
357 						static String aHeaderStr( SdResId( STR_FIELD_PLACEHOLDER_HEADER ) );
358 						aRepresentation = aHeaderStr;
359 					}
360 					else if (bFooterField )
361 					{
362 						static String aFooterStr( SdResId( STR_FIELD_PLACEHOLDER_FOOTER ) );
363 						aRepresentation = aFooterStr;
364 					}
365 					else if (bDateTimeField )
366 					{
367 						static String aDateTimeStr( SdResId( STR_FIELD_PLACEHOLDER_DATETIME ) );
368 						aRepresentation = aDateTimeStr;
369 					}
370 				}
371 				else
372 				{
373 					const sd::HeaderFooterSettings &rSettings = pPage->getHeaderFooterSettings();
374 
375 					if( bHeaderField )
376 					{
377 						aRepresentation = rSettings.maHeaderText;
378 					}
379 					else if( bFooterField )
380 					{
381 						aRepresentation = rSettings.maFooterText;
382 					}
383 					else if( bDateTimeField )
384 					{
385 						if( rSettings.mbDateTimeIsFixed )
386 						{
387 							aRepresentation = rSettings.maDateTimeText;
388 						}
389 						else
390 						{
391 							Date aDate;
392 							Time aTime;
393 							LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
394 							aRepresentation = SvxDateTimeField::GetFormatted( aDate, aTime, (SvxDateFormat)rSettings.meDateTimeFormat, *GetNumberFormatter(), eLang );
395 						}
396 					}
397 				}
398 			}
399 			else
400 			{
401 				DBG_ERROR("sd::SdModule::CalcFieldValueHdl(), unknown field type!");
402 			}
403 
404 			if( aRepresentation.Len() == 0 )				// TODO: Edit engine doesn't handle empty fields?
405 				aRepresentation += sal_Unicode( ' ' );
406 			pInfo->SetRepresentation( aRepresentation );
407 		}
408 	}
409 
410 	return(0);
411 }
412 
413 
414 
415 /*************************************************************************
416 |*
417 |* virt. Methoden fuer Optionendialog
418 |*
419 \************************************************************************/
CreateItemSet(sal_uInt16 nSlot)420 SfxItemSet*	 SdModule::CreateItemSet( sal_uInt16 nSlot )
421 {
422 	::sd::FrameView* pFrameView = NULL;
423 	::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
424 	SdDrawDocument* pDoc = NULL;
425 
426 	// Hier wird der DocType vom Optionsdialog gesetzt (nicht Dokument!)
427 	DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
428 	if( nSlot == SID_SD_GRAPHIC_OPTIONS )
429 		eDocType = DOCUMENT_TYPE_DRAW;
430 
431 	::sd::ViewShell* pViewShell = NULL;
432 
433 	if (pDocSh)
434 	{
435 		pDoc = pDocSh->GetDoc();
436 
437 		// Wenn der Optionsdialog zum Dokumenttyp identisch ist,
438 		// kann auch die FrameView mit uebergeben werden:
439 		if( pDoc && eDocType == pDoc->GetDocumentType() )
440 			pFrameView = pDocSh->GetFrameView();
441 
442 		pViewShell = pDocSh->GetViewShell();
443 		if (pViewShell != NULL)
444             pViewShell->WriteFrameViewData();
445 	}
446 
447 	SdOptions* pOptions = GetSdOptions(eDocType);
448 
449 	// Pool hat standardmaessig MapUnit Twips (Baeh!)
450 	SfxItemPool& rPool = GetPool();
451 	rPool.SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
452 
453 	SfxItemSet*	 pRet = new SfxItemSet( rPool,
454 						SID_ATTR_METRIC, SID_ATTR_METRIC,
455 						SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP,
456 
457 						ATTR_OPTIONS_LAYOUT, ATTR_OPTIONS_LAYOUT,
458 						ATTR_OPTIONS_CONTENTS, ATTR_OPTIONS_CONTENTS,
459 						ATTR_OPTIONS_MISC, ATTR_OPTIONS_MISC,
460 
461 						ATTR_OPTIONS_SNAP, ATTR_OPTIONS_SNAP,
462 
463 						ATTR_OPTIONS_SCALE_START, ATTR_OPTIONS_SCALE_END,
464 
465 						ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT,
466 
467 						SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS,
468 						0 );
469 
470 	// TP_OPTIONS_LAYOUT:
471 	pRet->Put( SdOptionsLayoutItem( ATTR_OPTIONS_LAYOUT, pOptions, pFrameView ) );
472 
473 	sal_uInt16 nDefTab = 0;
474 	if( pFrameView)
475 		nDefTab = pDoc->GetDefaultTabulator();
476 	else
477 		nDefTab = pOptions->GetDefTab();
478 	pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, nDefTab ) );
479 
480 	FieldUnit nMetric = (FieldUnit)0xffff;
481 	if( pFrameView)
482 		nMetric = pDoc->GetUIUnit();
483 	else
484 		nMetric = (FieldUnit)pOptions->GetMetric();
485 
486 	if( nMetric == (FieldUnit)0xffff )
487 		nMetric = GetFieldUnit();
488 
489 	pRet->Put( SfxUInt16Item( SID_ATTR_METRIC, (sal_uInt16)nMetric ) );
490 
491 	// TP_OPTIONS_CONTENTS:
492 	pRet->Put( SdOptionsContentsItem( ATTR_OPTIONS_CONTENTS, pOptions, pFrameView ) );
493 
494 	// TP_OPTIONS_MISC:
495     SdOptionsMiscItem aSdOptionsMiscItem( ATTR_OPTIONS_MISC, pOptions, pFrameView );
496     if ( pFrameView )
497     {
498         aSdOptionsMiscItem.GetOptionsMisc().SetSummationOfParagraphs( pDoc->IsSummationOfParagraphs() );
499         aSdOptionsMiscItem.GetOptionsMisc().SetPrinterIndependentLayout (
500             (sal_uInt16)pDoc->GetPrinterIndependentLayout());
501     }
502 	pRet->Put( aSdOptionsMiscItem );
503 
504 
505 	// TP_OPTIONS_SNAP:
506 	pRet->Put( SdOptionsSnapItem( ATTR_OPTIONS_SNAP, pOptions, pFrameView ) );
507 
508 	// TP_SCALE:
509 	sal_uInt32 nW = 10L;
510 	sal_uInt32 nH = 10L;
511 	sal_Int32  nX;
512 	sal_Int32  nY;
513 	if( pDocSh )
514 	{
515 		SdrPage* pPage = (SdrPage*) pDoc->GetSdPage(0, PK_STANDARD);
516 		Size aSize(pPage->GetSize());
517 		nW = aSize.Width();
518 		nH = aSize.Height();
519 	}
520 
521 	if(pFrameView)
522 	{
523 		const Fraction& rFraction =  pDoc->GetUIScale();
524 		nX=rFraction.GetNumerator();
525 		nY=rFraction.GetDenominator();
526 	}
527 	else
528 	{
529 		// Optionen aus Configdatei holen
530 		pOptions->GetScale( nX, nY );
531 	}
532 
533 	pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
534 	pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
535 	pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_WIDTH, nW ) );
536 	pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_HEIGHT, nH ) );
537 
538 
539 	// TP_OPTIONS_PRINT:
540 	pRet->Put( SdOptionsPrintItem( ATTR_OPTIONS_PRINT, pOptions ) );
541 
542 	// RID_SVXPAGE_GRID:
543 	pRet->Put( SdOptionsGridItem( SID_ATTR_GRID_OPTIONS, pOptions ) );
544 
545 	return pRet;
546 }
ApplyItemSet(sal_uInt16 nSlot,const SfxItemSet & rSet)547 void SdModule::ApplyItemSet( sal_uInt16 nSlot, const SfxItemSet& rSet )
548 {
549 	const SfxPoolItem*	pItem = NULL;
550 	sal_Bool bNewDefTab = sal_False;
551 	sal_Bool bNewPrintOptions = sal_False;
552 	sal_Bool bMiscOptions = sal_False;
553 
554 	::sd::FrameView* pFrameView = NULL;
555 	::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
556 	SdDrawDocument* pDoc = NULL;
557 	// Hier wird der DocType vom Optionsdialog gesetzt (nicht Dokument!)
558 	DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
559 	if( nSlot == SID_SD_GRAPHIC_OPTIONS )
560 		eDocType = DOCUMENT_TYPE_DRAW;
561 
562 	::sd::ViewShell* pViewShell = NULL;
563 
564 	if (pDocSh)
565 	{
566 		pDoc = pDocSh->GetDoc();
567 
568 		// Wenn der Optionsdialog zum Dokumenttyp identisch ist,
569 		// kann auch die FrameView mit uebergeben werden:
570 		if( pDoc && eDocType == pDoc->GetDocumentType() )
571 			pFrameView = pDocSh->GetFrameView();
572 
573 		pViewShell = pDocSh->GetViewShell();
574         if (pViewShell != NULL)
575             pViewShell->WriteFrameViewData();
576 	}
577 	SdOptions* pOptions = GetSdOptions(eDocType);
578 	// Raster
579 	if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS ,
580 							sal_False, (const SfxPoolItem**) &pItem ))
581 	{
582 		const SdOptionsGridItem* pGridItem = (SdOptionsGridItem*) pItem;
583 		pGridItem->SetOptions( pOptions );
584 	}
585 
586 	// Layout
587 	const SdOptionsLayoutItem* pLayoutItem = NULL;
588 	if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_LAYOUT,
589 							sal_False, (const SfxPoolItem**) &pLayoutItem ))
590 	{
591 		pLayoutItem->SetOptions( pOptions );
592 	}
593 
594 	// Metric
595 	if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC, sal_False, &pItem ) )
596 	{
597 		if( pDoc && eDocType == pDoc->GetDocumentType() )
598 			PutItem( *pItem );
599 		pOptions->SetMetric( ( (SfxUInt16Item*) pItem )->GetValue() );
600 	}
601 	sal_uInt16 nDefTab = pOptions->GetDefTab();
602 	// Default-Tabulator
603 	if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_DEFTABSTOP, sal_False, &pItem ) )
604 	{
605 		nDefTab = ( (SfxUInt16Item*) pItem )->GetValue();
606 		pOptions->SetDefTab( nDefTab );
607 
608 		bNewDefTab = sal_True;
609 	}
610 
611     // Massstab
612     if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_X, sal_False, &pItem ) )
613     {
614         sal_Int32 nX = ( (SfxInt32Item*) pItem )->GetValue();
615         if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_Y, sal_False, &pItem ) )
616         {
617             sal_Int32 nY = ( (SfxInt32Item*) pItem )->GetValue();
618             pOptions->SetScale( nX, nY );
619 
620             // #92067# Apply to document only if doc type match
621             if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
622             {
623                 pDoc->SetUIScale( Fraction( nX, nY ) );
624                 if( pViewShell )
625                     pViewShell->SetRuler( pViewShell->HasRuler() );
626             }
627         }
628     }
629 
630 	// Contents (Inhalte)
631 	const SdOptionsContentsItem* pContentsItem = NULL;
632 	if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_CONTENTS,
633 							sal_False, (const SfxPoolItem**) &pContentsItem ))
634 	{
635 		pContentsItem->SetOptions( pOptions );
636 	}
637 
638 	// Misc (Sonstiges)
639 	const SdOptionsMiscItem* pMiscItem = NULL;
640 	if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_MISC,
641 							sal_False, (const SfxPoolItem**) &pMiscItem ))
642 	{
643 		pMiscItem->SetOptions( pOptions );
644 		bMiscOptions = sal_True;
645 	}
646 
647 	// Fangen/Einrasten
648 	const SdOptionsSnapItem* pSnapItem = NULL;
649 	if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SNAP,
650 							sal_False, (const SfxPoolItem**) &pSnapItem ))
651 	{
652 		pSnapItem->SetOptions( pOptions );
653 	}
654 
655 	SfxItemSet aPrintSet( GetPool(),
656 					SID_PRINTER_NOTFOUND_WARN,	SID_PRINTER_NOTFOUND_WARN,
657 					SID_PRINTER_CHANGESTODOC,	SID_PRINTER_CHANGESTODOC,
658 					ATTR_OPTIONS_PRINT, 		ATTR_OPTIONS_PRINT,
659 					0 );
660 
661 	// Drucken
662 	const SdOptionsPrintItem* pPrintItem = NULL;
663 	if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_PRINT,
664 							sal_False, (const SfxPoolItem**) &pPrintItem ))
665 	{
666 		pPrintItem->SetOptions( pOptions );
667 
668 		// PrintOptionsSet setzen
669 		SdOptionsPrintItem aPrintItem( ATTR_OPTIONS_PRINT, pOptions );
670 		SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC );
671 		sal_uInt16		nFlags = 0;
672 
673 		nFlags =  (aPrintItem.GetOptionsPrint().IsWarningSize() ? SFX_PRINTER_CHG_SIZE : 0) |
674 				(aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SFX_PRINTER_CHG_ORIENTATION : 0);
675 		aFlagItem.SetValue( nFlags );
676 
677 		aPrintSet.Put( aPrintItem );
678 		aPrintSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
679 		aPrintSet.Put( aFlagItem );
680 
681 		bNewPrintOptions = sal_True;
682 	}
683 
684 	// Nur, wenn auch der Dokumenttyp uebereinstimmt...
685 	if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
686 	{
687 		if( bNewPrintOptions )
688 		{
689 			pDocSh->GetPrinter(sal_True)->SetOptions( aPrintSet );
690 		}
691 
692 		// Am Model den DefTab setzen
693 		if( bNewDefTab )
694 		{
695 			SdDrawDocument* pDocument = pDocSh->GetDoc();
696 			pDocument->SetDefaultTabulator( nDefTab );
697 
698 			::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
699 			if( pOutl )
700 				pOutl->SetDefTab( nDefTab );
701 
702 			::sd::Outliner* pInternalOutl = pDocument->GetInternalOutliner( sal_False );
703 			if( pInternalOutl )
704 				pInternalOutl->SetDefTab( nDefTab );
705 		}
706 		if ( bMiscOptions )
707 		{
708             pDoc->SetSummationOfParagraphs( pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() );
709 			sal_uInt32 nSum = pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() ? EE_CNTRL_ULSPACESUMMATION : 0;
710 			sal_uInt32 nCntrl;
711 
712 			SdDrawDocument* pDocument = pDocSh->GetDoc();
713 			SdrOutliner& rOutl = pDocument->GetDrawOutliner( NULL );
714 			nCntrl = rOutl.GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
715 			rOutl.SetControlWord( nCntrl | nSum );
716 			::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
717 			if( pOutl )
718 			{
719 				nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
720 				pOutl->SetControlWord( nCntrl | nSum );
721 			}
722 			pOutl = pDocument->GetInternalOutliner( sal_False );
723 			if( pOutl )
724 			{
725 				nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
726 				pOutl->SetControlWord( nCntrl | nSum );
727 			}
728 
729             // Set printer independent layout mode.
730 			if( pDoc->GetPrinterIndependentLayout() != pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout() )
731 	            pDoc->SetPrinterIndependentLayout (pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout());
732 		}
733 	}
734 
735 	pOptions->StoreConfig();
736 
737 	// Nur, wenn auch der Dokumenttyp uebereinstimmt...
738 	if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
739 	{
740 		FieldUnit eUIUnit = (FieldUnit) pOptions->GetMetric();
741 		pDoc->SetUIUnit(eUIUnit);
742 
743 		if (pViewShell)
744 		{
745 			// #74495# make sure no one is in text edit mode, cause there
746 			// are some pointers remembered else (!)
747 			if(pViewShell->GetView())
748 				pViewShell->GetView()->SdrEndTextEdit();
749 
750 			::sd::FrameView* pFrame = pViewShell->GetFrameView();
751 			pFrame->Update(pOptions);
752 			pViewShell->ReadFrameViewData(pFrame);
753 			pViewShell->SetUIUnit(eUIUnit);
754 			pViewShell->SetDefTabHRuler( nDefTab );
755 		}
756 	}
757 
758 	if( pViewShell && pViewShell->GetViewFrame() )
759 		pViewShell->GetViewFrame()->GetBindings().InvalidateAll( sal_True );
760 }
761 
CreateTabPage(sal_uInt16 nId,Window * pParent,const SfxItemSet & rSet)762 SfxTabPage* SdModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
763 {
764 	SfxTabPage* pRet = NULL;
765 	SfxAllItemSet aSet(*(rSet.GetPool()));
766 	SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
767 	if( pFact )
768 	{
769 		switch(nId)
770 		{
771 			case SID_SD_TP_CONTENTS:
772 			case SID_SI_TP_CONTENTS:
773 			{	::CreateTabPage fnCreatePage = pFact->GetSdOptionsContentsTabPageCreatorFunc();
774 				if( fnCreatePage )
775 					pRet = (*fnCreatePage)( pParent, rSet );
776 			}
777 			break;
778 			case SID_SD_TP_SNAP:
779 			case SID_SI_TP_SNAP:
780 			{	::CreateTabPage fnCreatePage = pFact->GetSdOptionsSnapTabPageCreatorFunc();
781 				if( fnCreatePage )
782 					pRet = (*fnCreatePage)( pParent, rSet );
783 			}
784 			break;
785 			case SID_SD_TP_PRINT:
786 			case SID_SI_TP_PRINT:
787 			{
788 				::CreateTabPage fnCreatePage = pFact->GetSdPrintOptionsTabPageCreatorFunc();
789 				if( fnCreatePage )
790 				{
791 					pRet = (*fnCreatePage)( pParent, rSet );
792 					if(SID_SD_TP_PRINT == nId)
793 						aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
794 					pRet->PageCreated(aSet);
795 				}
796 			}
797 			break;
798 			case SID_SI_TP_MISC:
799 			case SID_SD_TP_MISC:
800 			{
801 				::CreateTabPage fnCreatePage = pFact->GetSdOptionsMiscTabPageCreatorFunc();
802 				if( fnCreatePage )
803 				{
804 					pRet = (*fnCreatePage)( pParent, rSet );
805 					if(SID_SD_TP_MISC == nId)
806 						aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
807 					else
808 						aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_IMPRESS_MODE));
809 					pRet->PageCreated(aSet);
810 				}
811 			}
812 			break;
813 			case RID_OFA_TP_INTERNATIONAL_SD:
814 			case RID_OFA_TP_INTERNATIONAL_IMPR:
815 			case RID_SVXPAGE_TEXTANIMATION :
816 			{
817 				SfxAbstractDialogFactory* pSfxFact = SfxAbstractDialogFactory::Create();
818 				if ( pSfxFact )
819 				{
820 					::CreateTabPage fnCreatePage = pSfxFact->GetTabPageCreatorFunc( nId );
821 					if ( fnCreatePage )
822 						pRet = (*fnCreatePage)( pParent, rSet );
823 				}
824 			}
825 			break;
826 		}
827 		DBG_ASSERT( pRet, "SdModule::CreateTabPage(): no valid ID for TabPage!" );
828 	}
829 
830 	return pRet;
831 }
832