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, get the current page from the object that is
136 // currently formatted 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 |* Link fuer CalcFieldValue des Outliners
158 \************************************************************************/
159
IMPL_LINK(SdModule,CalcFieldValueHdl,EditFieldInfo *,pInfo)160 IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo)
161 {
162 if (pInfo)
163 {
164 const SvxFieldData* pField = pInfo->GetField().GetField();
165 ::sd::DrawDocShell* pDocShell = NULL;
166 SdDrawDocument* pDoc = 0;
167
168 SdrOutliner* pSdrOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
169 if( pSdrOutliner )
170 {
171 const SdrTextObj* pTextObj = pSdrOutliner->GetTextObj();
172
173 if( pTextObj )
174 pDoc = dynamic_cast< SdDrawDocument* >( pTextObj->GetModel() );
175
176 if( pDoc )
177 pDocShell = pDoc->GetDocSh();
178 }
179
180 if( !pDocShell )
181 pDocShell = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
182
183 const SvxDateField* pDateField = 0;
184 const SvxExtTimeField* pExtTimeField = 0;
185 const SvxExtFileField* pExtFileField = 0;
186 const SvxAuthorField* pAuthorField = 0;
187 const SvxURLField* pURLField = 0;
188
189 if( (pDateField = dynamic_cast< const SvxDateField* >(pField)) != 0 )
190 {
191 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
192 pInfo->SetRepresentation( pDateField->GetFormatted( *GetNumberFormatter(), eLang ) );
193 }
194 else if( (pExtTimeField = dynamic_cast< const SvxExtTimeField *>(pField)) != 0 )
195 {
196 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
197 pInfo->SetRepresentation( pExtTimeField->GetFormatted( *GetNumberFormatter(), eLang ) );
198 }
199 else if( (pExtFileField = dynamic_cast< const SvxExtFileField * >(pField)) != 0 )
200 {
201 if( pDocShell && (pExtFileField->GetType() != SVXFILETYPE_FIX) )
202 {
203 String aName;
204 if( pDocShell->HasName() )
205 aName = pDocShell->GetMedium()->GetName();
206 else
207 aName = pDocShell->GetName();
208
209 const_cast< SvxExtFileField* >(pExtFileField)->SetFile( aName );
210 }
211 pInfo->SetRepresentation( pExtFileField->GetFormatted() );
212
213 }
214 else if( (pAuthorField = dynamic_cast< const SvxAuthorField* >( pField )) != 0 )
215 {
216 if( pAuthorField->GetType() != SVXAUTHORTYPE_FIX )
217 {
218 SvtUserOptions aUserOptions;
219 SvxAuthorField aAuthorField(
220 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID(),
221 pAuthorField->GetType(), pAuthorField->GetFormat() );
222
223 *(const_cast< SvxAuthorField* >(pAuthorField)) = aAuthorField;
224 }
225 pInfo->SetRepresentation( pAuthorField->GetFormatted() );
226
227 }
228 else if( dynamic_cast< const SvxPageField* >(pField) )
229 {
230 String aRepresentation;
231 aRepresentation += sal_Unicode( ' ' );
232
233 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
234 if(pViewSh == NULL)
235 {
236 ::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
237 if(pBase)
238 pViewSh = pBase->GetMainViewShell().get();
239 }
240 if( !pDoc && pViewSh )
241 pDoc = pViewSh->GetDoc();
242
243 bool bMasterView;
244 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
245
246 if( pPage && pDoc && !bMasterView )
247 {
248 int nPgNum;
249
250 if( (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
251 {
252 nPgNum = pViewSh->GetPrintedHandoutPageNum();
253 }
254 else
255 {
256 nPgNum = (pPage->GetPageNum() - 1) / 2 + 1;
257 }
258 aRepresentation = pDoc->CreatePageNumValue((sal_uInt16)nPgNum);
259 }
260 else
261 {
262 static String aNumberText( SdResId( STR_FIELD_PLACEHOLDER_NUMBER ) );
263 aRepresentation = aNumberText;
264 }
265
266 pInfo->SetRepresentation( aRepresentation );
267 }
268 else if( dynamic_cast< const SvxPagesField* >(pField) )
269 {
270 String aRepresentation;
271 aRepresentation += sal_Unicode( ' ' );
272
273 ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
274 if(pViewSh == NULL)
275 {
276 ::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
277 if(pBase)
278 pViewSh = pBase->GetMainViewShell().get();
279 }
280 if( !pDoc && pViewSh )
281 pDoc = pViewSh->GetDoc();
282
283 bool bMasterView;
284 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
285
286 sal_uInt16 nPageCount = 0;
287
288 if( !bMasterView )
289 {
290 if( pPage && (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
291 {
292 nPageCount = pViewSh->GetPrintedHandoutPageCount();
293 }
294 else if( pDoc )
295 {
296 nPageCount = (sal_uInt16)pDoc->GetSdPageCount(PK_STANDARD);
297 }
298 }
299
300 if( nPageCount > 0 )
301 {
302 aRepresentation = pDoc->CreatePageNumValue(nPageCount);
303 }
304 else
305 {
306 static String aNumberText( SdResId( STR_FIELD_PLACEHOLDER_COUNT ) );
307 aRepresentation = aNumberText;
308 }
309
310 pInfo->SetRepresentation( aRepresentation );
311 }
312 else if( (pURLField = dynamic_cast< const SvxURLField* >(pField)) != 0 )
313 {
314 switch ( pURLField->GetFormat() )
315 {
316 case SVXURLFORMAT_APPDEFAULT: //!!! einstellbar an App???
317 case SVXURLFORMAT_REPR:
318 pInfo->SetRepresentation( pURLField->GetRepresentation() );
319 break;
320
321 case SVXURLFORMAT_URL:
322 pInfo->SetRepresentation( pURLField->GetURL() );
323 break;
324 }
325
326 String aURL = pURLField->GetURL();
327
328 svtools::ColorConfig aConfig;
329 svtools::ColorConfigEntry eEntry =
330 INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS;
331 pInfo->SetTxtColor( aConfig.GetColorValue(eEntry).nColor );
332 }
333 else if ( dynamic_cast< const SdrMeasureField* >(pField))
334 {
335 pInfo->ClearFldColor();
336 }
337 else
338 {
339 String aRepresentation;
340
341 bool bHeaderField = dynamic_cast< const SvxHeaderField* >( pField ) != 0;
342 bool bFooterField = !bHeaderField && (dynamic_cast< const SvxFooterField* >( pField ) != 0 );
343 bool bDateTimeField = !bHeaderField && !bFooterField && (dynamic_cast< const SvxDateTimeField* >( pField ) != 0);
344
345 if( bHeaderField || bFooterField || bDateTimeField )
346 {
347 sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
348 bool bMasterView = false;
349 SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
350
351 if( (pPage == NULL) || bMasterView )
352 {
353 if( bHeaderField )
354 {
355 static String aHeaderStr( SdResId( STR_FIELD_PLACEHOLDER_HEADER ) );
356 aRepresentation = aHeaderStr;
357 }
358 else if (bFooterField )
359 {
360 static String aFooterStr( SdResId( STR_FIELD_PLACEHOLDER_FOOTER ) );
361 aRepresentation = aFooterStr;
362 }
363 else if (bDateTimeField )
364 {
365 static String aDateTimeStr( SdResId( STR_FIELD_PLACEHOLDER_DATETIME ) );
366 aRepresentation = aDateTimeStr;
367 }
368 }
369 else
370 {
371 const sd::HeaderFooterSettings &rSettings = pPage->getHeaderFooterSettings();
372
373 if( bHeaderField )
374 {
375 aRepresentation = rSettings.maHeaderText;
376 }
377 else if( bFooterField )
378 {
379 aRepresentation = rSettings.maFooterText;
380 }
381 else if( bDateTimeField )
382 {
383 if( rSettings.mbDateTimeIsFixed )
384 {
385 aRepresentation = rSettings.maDateTimeText;
386 }
387 else
388 {
389 Date aDate;
390 Time aTime;
391 LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
392 aRepresentation = SvxDateTimeField::GetFormatted( aDate, aTime, (SvxDateFormat)rSettings.meDateTimeFormat, *GetNumberFormatter(), eLang );
393 }
394 }
395 }
396 }
397 else
398 {
399 DBG_ERROR("sd::SdModule::CalcFieldValueHdl(), unknown field type!");
400 }
401
402 if( aRepresentation.Len() == 0 ) // TODO: Edit engine doesn't handle empty fields?
403 aRepresentation += sal_Unicode( ' ' );
404 pInfo->SetRepresentation( aRepresentation );
405 }
406 }
407
408 return(0);
409 }
410
411
412
413 /*************************************************************************
414 |* virt. Methoden fuer Optionendialog
415 \************************************************************************/
CreateItemSet(sal_uInt16 nSlot)416 SfxItemSet* SdModule::CreateItemSet( sal_uInt16 nSlot )
417 {
418 ::sd::FrameView* pFrameView = NULL;
419 ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
420 SdDrawDocument* pDoc = NULL;
421
422 // Hier wird der DocType vom Optionsdialog gesetzt (nicht Dokument!)
423 DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
424 if( nSlot == SID_SD_GRAPHIC_OPTIONS )
425 eDocType = DOCUMENT_TYPE_DRAW;
426
427 ::sd::ViewShell* pViewShell = NULL;
428
429 if (pDocSh)
430 {
431 pDoc = pDocSh->GetDoc();
432
433 // Wenn der Optionsdialog zum Dokumenttyp identisch ist,
434 // kann auch die FrameView mit uebergeben werden:
435 if( pDoc && eDocType == pDoc->GetDocumentType() )
436 pFrameView = pDocSh->GetFrameView();
437
438 pViewShell = pDocSh->GetViewShell();
439 if (pViewShell != NULL)
440 pViewShell->WriteFrameViewData();
441 }
442
443 SdOptions* pOptions = GetSdOptions(eDocType);
444
445 // Pool hat standardmaessig MapUnit Twips (Baeh!)
446 SfxItemPool& rPool = GetPool();
447 rPool.SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
448
449 SfxItemSet* pRet = new SfxItemSet( rPool,
450 SID_ATTR_METRIC, SID_ATTR_METRIC,
451 SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP,
452
453 ATTR_OPTIONS_LAYOUT, ATTR_OPTIONS_LAYOUT,
454 ATTR_OPTIONS_CONTENTS, ATTR_OPTIONS_CONTENTS,
455 ATTR_OPTIONS_MISC, ATTR_OPTIONS_MISC,
456
457 ATTR_OPTIONS_SNAP, ATTR_OPTIONS_SNAP,
458
459 ATTR_OPTIONS_SCALE_START, ATTR_OPTIONS_SCALE_END,
460
461 ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT,
462
463 SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS,
464 0 );
465
466 // TP_OPTIONS_LAYOUT:
467 pRet->Put( SdOptionsLayoutItem( ATTR_OPTIONS_LAYOUT, pOptions, pFrameView ) );
468
469 sal_uInt16 nDefTab = 0;
470 if( pFrameView)
471 nDefTab = pDoc->GetDefaultTabulator();
472 else
473 nDefTab = pOptions->GetDefTab();
474 pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, nDefTab ) );
475
476 FieldUnit nMetric = (FieldUnit)0xffff;
477 if( pFrameView)
478 nMetric = pDoc->GetUIUnit();
479 else
480 nMetric = (FieldUnit)pOptions->GetMetric();
481
482 if( nMetric == (FieldUnit)0xffff )
483 nMetric = GetFieldUnit();
484
485 pRet->Put( SfxUInt16Item( SID_ATTR_METRIC, (sal_uInt16)nMetric ) );
486
487 // TP_OPTIONS_CONTENTS:
488 pRet->Put( SdOptionsContentsItem( ATTR_OPTIONS_CONTENTS, pOptions, pFrameView ) );
489
490 // TP_OPTIONS_MISC:
491 SdOptionsMiscItem aSdOptionsMiscItem( ATTR_OPTIONS_MISC, pOptions, pFrameView );
492 if ( pFrameView )
493 {
494 aSdOptionsMiscItem.GetOptionsMisc().SetSummationOfParagraphs( pDoc->IsSummationOfParagraphs() );
495 aSdOptionsMiscItem.GetOptionsMisc().SetPrinterIndependentLayout (
496 (sal_uInt16)pDoc->GetPrinterIndependentLayout());
497 }
498 pRet->Put( aSdOptionsMiscItem );
499
500
501 // TP_OPTIONS_SNAP:
502 pRet->Put( SdOptionsSnapItem( ATTR_OPTIONS_SNAP, pOptions, pFrameView ) );
503
504 // TP_SCALE:
505 sal_uInt32 nW = 10L;
506 sal_uInt32 nH = 10L;
507 sal_Int32 nX;
508 sal_Int32 nY;
509 if( pDocSh )
510 {
511 SdrPage* pPage = (SdrPage*) pDoc->GetSdPage(0, PK_STANDARD);
512 Size aSize(pPage->GetSize());
513 nW = aSize.Width();
514 nH = aSize.Height();
515 }
516
517 if(pFrameView)
518 {
519 const Fraction& rFraction = pDoc->GetUIScale();
520 nX=rFraction.GetNumerator();
521 nY=rFraction.GetDenominator();
522 }
523 else
524 {
525 // Optionen aus Configdatei holen
526 pOptions->GetScale( nX, nY );
527 }
528
529 pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
530 pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
531 pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_WIDTH, nW ) );
532 pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_HEIGHT, nH ) );
533
534
535 // TP_OPTIONS_PRINT:
536 pRet->Put( SdOptionsPrintItem( ATTR_OPTIONS_PRINT, pOptions ) );
537
538 // RID_SVXPAGE_GRID:
539 pRet->Put( SdOptionsGridItem( SID_ATTR_GRID_OPTIONS, pOptions ) );
540
541 return pRet;
542 }
ApplyItemSet(sal_uInt16 nSlot,const SfxItemSet & rSet)543 void SdModule::ApplyItemSet( sal_uInt16 nSlot, const SfxItemSet& rSet )
544 {
545 const SfxPoolItem* pItem = NULL;
546 sal_Bool bNewDefTab = sal_False;
547 sal_Bool bNewPrintOptions = sal_False;
548 sal_Bool bMiscOptions = sal_False;
549
550 ::sd::FrameView* pFrameView = NULL;
551 ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
552 SdDrawDocument* pDoc = NULL;
553 // Hier wird der DocType vom Optionsdialog gesetzt (nicht Dokument!)
554 DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
555 if( nSlot == SID_SD_GRAPHIC_OPTIONS )
556 eDocType = DOCUMENT_TYPE_DRAW;
557
558 ::sd::ViewShell* pViewShell = NULL;
559
560 if (pDocSh)
561 {
562 pDoc = pDocSh->GetDoc();
563
564 // Wenn der Optionsdialog zum Dokumenttyp identisch ist,
565 // kann auch die FrameView mit uebergeben werden:
566 if( pDoc && eDocType == pDoc->GetDocumentType() )
567 pFrameView = pDocSh->GetFrameView();
568
569 pViewShell = pDocSh->GetViewShell();
570 if (pViewShell != NULL)
571 pViewShell->WriteFrameViewData();
572 }
573 SdOptions* pOptions = GetSdOptions(eDocType);
574 // Raster
575 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS ,
576 sal_False, (const SfxPoolItem**) &pItem ))
577 {
578 const SdOptionsGridItem* pGridItem = (SdOptionsGridItem*) pItem;
579 pGridItem->SetOptions( pOptions );
580 }
581
582 // Layout
583 const SdOptionsLayoutItem* pLayoutItem = NULL;
584 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_LAYOUT,
585 sal_False, (const SfxPoolItem**) &pLayoutItem ))
586 {
587 pLayoutItem->SetOptions( pOptions );
588 }
589
590 // Metric
591 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC, sal_False, &pItem ) )
592 {
593 if( pDoc && eDocType == pDoc->GetDocumentType() )
594 PutItem( *pItem );
595 pOptions->SetMetric( ( (SfxUInt16Item*) pItem )->GetValue() );
596 }
597 sal_uInt16 nDefTab = pOptions->GetDefTab();
598 // Default-Tabulator
599 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_DEFTABSTOP, sal_False, &pItem ) )
600 {
601 nDefTab = ( (SfxUInt16Item*) pItem )->GetValue();
602 pOptions->SetDefTab( nDefTab );
603
604 bNewDefTab = sal_True;
605 }
606
607 // Massstab
608 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_X, sal_False, &pItem ) )
609 {
610 sal_Int32 nX = ( (SfxInt32Item*) pItem )->GetValue();
611 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_Y, sal_False, &pItem ) )
612 {
613 sal_Int32 nY = ( (SfxInt32Item*) pItem )->GetValue();
614 pOptions->SetScale( nX, nY );
615
616 // #92067# Apply to document only if doc type match
617 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
618 {
619 pDoc->SetUIScale( Fraction( nX, nY ) );
620 if( pViewShell )
621 pViewShell->SetRuler( pViewShell->HasRuler() );
622 }
623 }
624 }
625
626 // Contents
627 const SdOptionsContentsItem* pContentsItem = NULL;
628 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_CONTENTS,
629 sal_False, (const SfxPoolItem**) &pContentsItem ))
630 {
631 pContentsItem->SetOptions( pOptions );
632 }
633
634 // Misc
635 const SdOptionsMiscItem* pMiscItem = NULL;
636 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_MISC,
637 sal_False, (const SfxPoolItem**) &pMiscItem ))
638 {
639 pMiscItem->SetOptions( pOptions );
640 bMiscOptions = sal_True;
641 }
642
643 // Fangen/Einrasten
644 const SdOptionsSnapItem* pSnapItem = NULL;
645 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SNAP,
646 sal_False, (const SfxPoolItem**) &pSnapItem ))
647 {
648 pSnapItem->SetOptions( pOptions );
649 }
650
651 SfxItemSet aPrintSet( GetPool(),
652 SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
653 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
654 ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT,
655 0 );
656
657 // Drucken
658 const SdOptionsPrintItem* pPrintItem = NULL;
659 if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_PRINT,
660 sal_False, (const SfxPoolItem**) &pPrintItem ))
661 {
662 pPrintItem->SetOptions( pOptions );
663
664 // PrintOptionsSet setzen
665 SdOptionsPrintItem aPrintItem( ATTR_OPTIONS_PRINT, pOptions );
666 SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC );
667 sal_uInt16 nFlags = 0;
668
669 nFlags = (aPrintItem.GetOptionsPrint().IsWarningSize() ? SFX_PRINTER_CHG_SIZE : 0) |
670 (aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SFX_PRINTER_CHG_ORIENTATION : 0);
671 aFlagItem.SetValue( nFlags );
672
673 aPrintSet.Put( aPrintItem );
674 aPrintSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
675 aPrintSet.Put( aFlagItem );
676
677 bNewPrintOptions = sal_True;
678 }
679
680 // Nur, wenn auch der Dokumenttyp uebereinstimmt...
681 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
682 {
683 if( bNewPrintOptions )
684 {
685 pDocSh->GetPrinter(sal_True)->SetOptions( aPrintSet );
686 }
687
688 // Am Modell den DefTab setzen
689 if( bNewDefTab )
690 {
691 SdDrawDocument* pDocument = pDocSh->GetDoc();
692 pDocument->SetDefaultTabulator( nDefTab );
693
694 ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
695 if( pOutl )
696 pOutl->SetDefTab( nDefTab );
697
698 ::sd::Outliner* pInternalOutl = pDocument->GetInternalOutliner( sal_False );
699 if( pInternalOutl )
700 pInternalOutl->SetDefTab( nDefTab );
701 }
702 if ( bMiscOptions )
703 {
704 pDoc->SetSummationOfParagraphs( pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() );
705 sal_uInt32 nSum = pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() ? EE_CNTRL_ULSPACESUMMATION : 0;
706 sal_uInt32 nCntrl;
707
708 SdDrawDocument* pDocument = pDocSh->GetDoc();
709 SdrOutliner& rOutl = pDocument->GetDrawOutliner( NULL );
710 nCntrl = rOutl.GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
711 rOutl.SetControlWord( nCntrl | nSum );
712 ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
713 if( pOutl )
714 {
715 nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
716 pOutl->SetControlWord( nCntrl | nSum );
717 }
718 pOutl = pDocument->GetInternalOutliner( sal_False );
719 if( pOutl )
720 {
721 nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
722 pOutl->SetControlWord( nCntrl | nSum );
723 }
724
725 // Set printer independent layout mode.
726 if( pDoc->GetPrinterIndependentLayout() != pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout() )
727 pDoc->SetPrinterIndependentLayout (pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout());
728 }
729 }
730
731 pOptions->StoreConfig();
732
733 // Nur, wenn auch der Dokumenttyp uebereinstimmt...
734 if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
735 {
736 FieldUnit eUIUnit = (FieldUnit) pOptions->GetMetric();
737 pDoc->SetUIUnit(eUIUnit);
738
739 if (pViewShell)
740 {
741 // #74495# make sure no one is in text edit mode, cause there
742 // are some pointers remembered else (!)
743 if(pViewShell->GetView())
744 pViewShell->GetView()->SdrEndTextEdit();
745
746 ::sd::FrameView* pFrame = pViewShell->GetFrameView();
747 pFrame->Update(pOptions);
748 pViewShell->ReadFrameViewData(pFrame);
749 pViewShell->SetUIUnit(eUIUnit);
750 pViewShell->SetDefTabHRuler( nDefTab );
751 }
752 }
753
754 if( pViewShell && pViewShell->GetViewFrame() )
755 pViewShell->GetViewFrame()->GetBindings().InvalidateAll( sal_True );
756 }
757
CreateTabPage(sal_uInt16 nId,Window * pParent,const SfxItemSet & rSet)758 SfxTabPage* SdModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
759 {
760 SfxTabPage* pRet = NULL;
761 SfxAllItemSet aSet(*(rSet.GetPool()));
762 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
763 if( pFact )
764 {
765 switch(nId)
766 {
767 case SID_SD_TP_CONTENTS:
768 case SID_SI_TP_CONTENTS:
769 { ::CreateTabPage fnCreatePage = pFact->GetSdOptionsContentsTabPageCreatorFunc();
770 if( fnCreatePage )
771 pRet = (*fnCreatePage)( pParent, rSet );
772 }
773 break;
774 case SID_SD_TP_SNAP:
775 case SID_SI_TP_SNAP:
776 { ::CreateTabPage fnCreatePage = pFact->GetSdOptionsSnapTabPageCreatorFunc();
777 if( fnCreatePage )
778 pRet = (*fnCreatePage)( pParent, rSet );
779 }
780 break;
781 case SID_SD_TP_PRINT:
782 case SID_SI_TP_PRINT:
783 {
784 ::CreateTabPage fnCreatePage = pFact->GetSdPrintOptionsTabPageCreatorFunc();
785 if( fnCreatePage )
786 {
787 pRet = (*fnCreatePage)( pParent, rSet );
788 if(SID_SD_TP_PRINT == nId)
789 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
790 pRet->PageCreated(aSet);
791 }
792 }
793 break;
794 case SID_SI_TP_MISC:
795 case SID_SD_TP_MISC:
796 {
797 ::CreateTabPage fnCreatePage = pFact->GetSdOptionsMiscTabPageCreatorFunc();
798 if( fnCreatePage )
799 {
800 pRet = (*fnCreatePage)( pParent, rSet );
801 if(SID_SD_TP_MISC == nId)
802 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
803 else
804 aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_IMPRESS_MODE));
805 pRet->PageCreated(aSet);
806 }
807 }
808 break;
809 case RID_OFA_TP_INTERNATIONAL_SD:
810 case RID_OFA_TP_INTERNATIONAL_IMPR:
811 case RID_SVXPAGE_TEXTANIMATION :
812 {
813 SfxAbstractDialogFactory* pSfxFact = SfxAbstractDialogFactory::Create();
814 if ( pSfxFact )
815 {
816 ::CreateTabPage fnCreatePage = pSfxFact->GetTabPageCreatorFunc( nId );
817 if ( fnCreatePage )
818 pRet = (*fnCreatePage)( pParent, rSet );
819 }
820 }
821 break;
822 }
823 DBG_ASSERT( pRet, "SdModule::CreateTabPage(): no valid ID for TabPage!" );
824 }
825
826 return pRet;
827 }
828