Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
32 :
33 : #include <editeng/measfld.hxx>
34 : #include <editeng/editstat.hxx>
35 : #include <editeng/editeng.hxx>
36 :
37 : #include <svx/dialogs.hrc>
38 : #include <svx/svdotext.hxx>
39 : #include <svx/svdpagv.hxx>
40 : #include <svx/svdopage.hxx>
41 :
42 : #include <sfx2/sfxdlg.hxx>
43 :
44 :
45 : #include <svx/sdr/contact/displayinfo.hxx>
46 :
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 <svl/intitem.hxx>
70 :
71 : /** retrieves the page that is currently painted. This will only be the master page
72 : if the current drawn view only shows the master page*/
73 0 : static SdPage* GetCurrentPage( sd::ViewShell* pViewSh, EditFieldInfo* pInfo, bool& bMasterView )
74 : {
75 0 : if( !pInfo )
76 0 : return 0;
77 :
78 0 : bMasterView = false;
79 0 : SdPage* pPage = dynamic_cast< SdPage* >( pInfo->GetSdrPage() );
80 0 : SdrOutliner* pOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
81 :
82 : // special case, someone already set the current page on the EditFieldInfo
83 : // This is used from the svx::UnoGraphicsExporter f.e.
84 0 : if( pPage )
85 : {
86 0 : bMasterView = false;
87 0 : return pPage;
88 : }
89 :
90 : // first try to check if we are inside the outline view
91 0 : sd::OutlineView* pSdView = NULL;
92 0 : if( pViewSh && pViewSh->ISA(sd::OutlineViewShell))
93 0 : pSdView = static_cast<sd::OutlineView*> (static_cast<sd::OutlineViewShell*>(pViewSh)->GetView());
94 :
95 0 : if (pSdView != NULL && (pOutliner == pSdView->GetOutliner()))
96 : {
97 : // outline mode
98 0 : int nPgNum = 0;
99 0 : Outliner* pOutl = pSdView->GetOutliner();
100 0 : long nPos = pInfo->GetPara();
101 0 : sal_Int32 nParaPos = 0;
102 :
103 0 : for( Paragraph* pPara = pOutl->GetParagraph( 0 ); pPara && nPos >= 0; pPara = pOutl->GetParagraph( ++nParaPos ), nPos-- )
104 : {
105 0 : if( pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
106 0 : nPgNum++;
107 : }
108 :
109 0 : pPage = pViewSh->GetDoc()->GetSdPage( (sal_uInt16)nPgNum, PK_STANDARD );
110 : }
111 : else
112 : {
113 : // draw mode, slide mode and preview. Get the processed page from the outliner
114 0 : if(pOutliner)
115 : {
116 0 : pPage = dynamic_cast< SdPage* >(const_cast< SdrPage* >(pOutliner->getVisualizedPage()));
117 : }
118 :
119 : // The path using GetPaintingPageView() and GetCurrentPaintingDisplayInfo()
120 : // is no longer needed. I debugged and checked all usages of PageNumber decompositions
121 : // which all use the new possibility of setting the visualized page at the SdrOutliner.
122 :
123 : // if all else failed, geht the current page from the object that is
124 : // currently formated from the document
125 0 : if(!pPage)
126 : {
127 0 : const SdrTextObj* pTextObj = (pViewSh && pViewSh->GetDoc()) ? pViewSh->GetDoc()->GetFormattingTextObj() : NULL;
128 :
129 0 : if( pTextObj )
130 : {
131 0 : pPage = dynamic_cast< SdPage* >( pTextObj->GetPage() );
132 : }
133 : }
134 :
135 0 : if(pPage)
136 : {
137 0 : bMasterView = pPage && pPage->IsMasterPage();
138 : }
139 : }
140 :
141 0 : return pPage;
142 : }
143 :
144 : /**
145 : * Link for CalcFieldValue of Outliners
146 : */
147 0 : IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo)
148 : {
149 0 : if (pInfo)
150 : {
151 0 : const SvxFieldData* pField = pInfo->GetField().GetField();
152 0 : ::sd::DrawDocShell* pDocShell = NULL;
153 0 : SdDrawDocument* pDoc = 0;
154 :
155 0 : SdrOutliner* pSdrOutliner = dynamic_cast< SdrOutliner* >( pInfo->GetOutliner() );
156 0 : if( pSdrOutliner )
157 : {
158 0 : const SdrTextObj* pTextObj = pSdrOutliner->GetTextObj();
159 :
160 0 : if( pTextObj )
161 0 : pDoc = dynamic_cast< SdDrawDocument* >( pTextObj->GetModel() );
162 :
163 0 : if( pDoc )
164 0 : pDocShell = pDoc->GetDocSh();
165 : }
166 :
167 0 : if( !pDocShell )
168 0 : pDocShell = dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
169 :
170 0 : const SvxDateField* pDateField = 0;
171 0 : const SvxExtTimeField* pExtTimeField = 0;
172 0 : const SvxExtFileField* pExtFileField = 0;
173 0 : const SvxAuthorField* pAuthorField = 0;
174 0 : const SvxURLField* pURLField = 0;
175 :
176 0 : if( (pDateField = dynamic_cast< const SvxDateField* >(pField)) != 0 )
177 : {
178 0 : LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
179 0 : pInfo->SetRepresentation( pDateField->GetFormatted( *GetNumberFormatter(), eLang ) );
180 : }
181 0 : else if( (pExtTimeField = dynamic_cast< const SvxExtTimeField *>(pField)) != 0 )
182 : {
183 0 : LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
184 0 : pInfo->SetRepresentation( pExtTimeField->GetFormatted( *GetNumberFormatter(), eLang ) );
185 : }
186 0 : else if( (pExtFileField = dynamic_cast< const SvxExtFileField * >(pField)) != 0 )
187 : {
188 0 : if( pDocShell && (pExtFileField->GetType() != SVXFILETYPE_FIX) )
189 : {
190 0 : OUString aName;
191 0 : if( pDocShell->HasName() )
192 0 : aName = pDocShell->GetMedium()->GetName();
193 : else
194 0 : aName = pDocShell->GetName();
195 :
196 0 : const_cast< SvxExtFileField* >(pExtFileField)->SetFile( aName );
197 : }
198 0 : pInfo->SetRepresentation( pExtFileField->GetFormatted() );
199 :
200 : }
201 0 : else if( (pAuthorField = dynamic_cast< const SvxAuthorField* >( pField )) != 0 )
202 : {
203 0 : if( pAuthorField->GetType() != SVXAUTHORTYPE_FIX )
204 : {
205 0 : SvtUserOptions aUserOptions;
206 : SvxAuthorField aAuthorField(
207 : aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID(),
208 0 : pAuthorField->GetType(), pAuthorField->GetFormat() );
209 :
210 0 : *(const_cast< SvxAuthorField* >(pAuthorField)) = aAuthorField;
211 : }
212 0 : pInfo->SetRepresentation( pAuthorField->GetFormatted() );
213 :
214 : }
215 0 : else if( dynamic_cast< const SvxPageField* >(pField) )
216 : {
217 0 : OUString aRepresentation(" ");
218 :
219 0 : ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
220 0 : if(pViewSh == NULL)
221 : {
222 0 : ::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
223 0 : if(pBase)
224 0 : pViewSh = pBase->GetMainViewShell().get();
225 : }
226 0 : if( !pDoc && pViewSh )
227 0 : pDoc = pViewSh->GetDoc();
228 :
229 : bool bMasterView;
230 0 : SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
231 :
232 0 : if( pPage && pDoc && !bMasterView )
233 : {
234 : int nPgNum;
235 :
236 0 : if( (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
237 : {
238 0 : nPgNum = pViewSh->GetPrintedHandoutPageNum();
239 : }
240 : else
241 : {
242 0 : nPgNum = (pPage->GetPageNum() - 1) / 2 + 1;
243 : }
244 0 : aRepresentation = pDoc->CreatePageNumValue((sal_uInt16)nPgNum);
245 : }
246 : else
247 0 : aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_NUMBER).toString();
248 :
249 0 : pInfo->SetRepresentation( aRepresentation );
250 : }
251 0 : else if( dynamic_cast< const SvxPagesField* >(pField) )
252 : {
253 0 : OUString aRepresentation(" ");
254 :
255 0 : ::sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
256 0 : if(pViewSh == NULL)
257 : {
258 0 : ::sd::ViewShellBase* pBase = PTR_CAST(::sd::ViewShellBase, SfxViewShell::Current());
259 0 : if(pBase)
260 0 : pViewSh = pBase->GetMainViewShell().get();
261 : }
262 0 : if( !pDoc && pViewSh )
263 0 : pDoc = pViewSh->GetDoc();
264 :
265 : bool bMasterView;
266 0 : SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
267 :
268 0 : sal_uInt16 nPageCount = 0;
269 :
270 0 : if( !bMasterView )
271 : {
272 0 : if( pPage && (pPage->GetPageKind() == PK_HANDOUT) && pViewSh )
273 : {
274 0 : nPageCount = pViewSh->GetPrintedHandoutPageCount();
275 : }
276 0 : else if( pDoc )
277 : {
278 0 : nPageCount = (sal_uInt16)pDoc->GetActiveSdPageCount();
279 : }
280 : }
281 :
282 0 : if( nPageCount > 0 )
283 0 : aRepresentation = pDoc->CreatePageNumValue(nPageCount);
284 : else
285 0 : aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_COUNT).toString();
286 :
287 0 : pInfo->SetRepresentation( aRepresentation );
288 : }
289 0 : else if( (pURLField = dynamic_cast< const SvxURLField* >(pField)) != 0 )
290 : {
291 0 : switch ( pURLField->GetFormat() )
292 : {
293 : case SVXURLFORMAT_APPDEFAULT: //!!! adjustable at App???
294 : case SVXURLFORMAT_REPR:
295 0 : pInfo->SetRepresentation( pURLField->GetRepresentation() );
296 0 : break;
297 :
298 : case SVXURLFORMAT_URL:
299 0 : pInfo->SetRepresentation( pURLField->GetURL() );
300 0 : break;
301 : }
302 :
303 0 : OUString aURL = pURLField->GetURL();
304 :
305 0 : svtools::ColorConfig aConfig;
306 : svtools::ColorConfigEntry eEntry =
307 0 : INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS;
308 0 : pInfo->SetTxtColor( aConfig.GetColorValue(eEntry).nColor );
309 : }
310 0 : else if ( dynamic_cast< const SdrMeasureField* >(pField))
311 : {
312 0 : pInfo->ClearFldColor();
313 : }
314 : else
315 : {
316 0 : OUString aRepresentation;
317 :
318 0 : bool bHeaderField = dynamic_cast< const SvxHeaderField* >( pField ) != 0;
319 0 : bool bFooterField = !bHeaderField && (dynamic_cast< const SvxFooterField* >( pField ) != 0 );
320 0 : bool bDateTimeField = !bHeaderField && !bFooterField && (dynamic_cast< const SvxDateTimeField* >( pField ) != 0);
321 :
322 0 : if( bHeaderField || bFooterField || bDateTimeField )
323 : {
324 0 : sd::ViewShell* pViewSh = pDocShell ? pDocShell->GetViewShell() : NULL;
325 0 : bool bMasterView = false;
326 0 : SdPage* pPage = GetCurrentPage( pViewSh, pInfo, bMasterView );
327 :
328 0 : if( (pPage == NULL) || bMasterView )
329 : {
330 0 : if( bHeaderField )
331 0 : aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_HEADER).toString();
332 0 : else if (bFooterField )
333 0 : aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_FOOTER).toString();
334 0 : else if (bDateTimeField )
335 0 : aRepresentation = SdResId(STR_FIELD_PLACEHOLDER_DATETIME).toString();
336 : }
337 : else
338 : {
339 0 : const sd::HeaderFooterSettings &rSettings = pPage->getHeaderFooterSettings();
340 :
341 0 : if( bHeaderField )
342 : {
343 0 : aRepresentation = rSettings.maHeaderText;
344 : }
345 0 : else if( bFooterField )
346 : {
347 0 : aRepresentation = rSettings.maFooterText;
348 : }
349 0 : else if( bDateTimeField )
350 : {
351 0 : if( rSettings.mbDateTimeIsFixed )
352 : {
353 0 : aRepresentation = rSettings.maDateTimeText;
354 : }
355 : else
356 : {
357 0 : Date aDate( Date::SYSTEM );
358 0 : Time aTime( Time::SYSTEM );
359 0 : LanguageType eLang = pInfo->GetOutliner()->GetLanguage( pInfo->GetPara(), pInfo->GetPos() );
360 0 : aRepresentation = SvxDateTimeField::GetFormatted( aDate, aTime, (SvxDateFormat)rSettings.meDateTimeFormat, *GetNumberFormatter(), eLang );
361 : }
362 : }
363 : }
364 : }
365 : else
366 : {
367 : OSL_FAIL("sd::SdModule::CalcFieldValueHdl(), unknown field type!");
368 : }
369 :
370 0 : if( aRepresentation.isEmpty() ) // TODO: Edit engine doesn't handle empty fields?
371 0 : aRepresentation = " ";
372 0 : pInfo->SetRepresentation( aRepresentation );
373 : }
374 : }
375 :
376 0 : return(0);
377 : }
378 :
379 :
380 : /**
381 : * virtual methods for option dialog
382 : */
383 0 : SfxItemSet* SdModule::CreateItemSet( sal_uInt16 nSlot )
384 : {
385 0 : ::sd::FrameView* pFrameView = NULL;
386 0 : ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
387 0 : SdDrawDocument* pDoc = NULL;
388 :
389 : // Here we set the DocType of the option dialog (not document!)
390 0 : DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
391 0 : if( nSlot == SID_SD_GRAPHIC_OPTIONS )
392 0 : eDocType = DOCUMENT_TYPE_DRAW;
393 :
394 0 : if (pDocSh)
395 : {
396 0 : pDoc = pDocSh->GetDoc();
397 :
398 : // If the option dialog is identical to the document type,
399 : // we can pass the FrameView too:
400 0 : if( pDoc && eDocType == pDoc->GetDocumentType() )
401 0 : pFrameView = pDocSh->GetFrameView();
402 :
403 0 : ::sd::ViewShell* pViewShell = pDocSh->GetViewShell();
404 0 : if (pViewShell != NULL)
405 0 : pViewShell->WriteFrameViewData();
406 : }
407 :
408 0 : SdOptions* pOptions = GetSdOptions(eDocType);
409 :
410 : // Pool has by default MapUnit Twips (Awgh!)
411 0 : SfxItemPool& rPool = GetPool();
412 0 : rPool.SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
413 :
414 : SfxItemSet* pRet = new SfxItemSet( rPool,
415 : SID_ATTR_METRIC, SID_ATTR_METRIC,
416 : SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP,
417 :
418 : ATTR_OPTIONS_LAYOUT, ATTR_OPTIONS_LAYOUT,
419 : ATTR_OPTIONS_CONTENTS, ATTR_OPTIONS_CONTENTS,
420 : ATTR_OPTIONS_MISC, ATTR_OPTIONS_MISC,
421 :
422 : ATTR_OPTIONS_SNAP, ATTR_OPTIONS_SNAP,
423 :
424 : ATTR_OPTIONS_SCALE_START, ATTR_OPTIONS_SCALE_END,
425 :
426 : ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT,
427 :
428 : SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS,
429 0 : 0 );
430 :
431 : // TP_OPTIONS_LAYOUT:
432 0 : pRet->Put( SdOptionsLayoutItem( ATTR_OPTIONS_LAYOUT, pOptions, pFrameView ) );
433 :
434 0 : sal_uInt16 nDefTab = 0;
435 0 : if( pFrameView)
436 0 : nDefTab = pDoc->GetDefaultTabulator();
437 : else
438 0 : nDefTab = pOptions->GetDefTab();
439 0 : pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, nDefTab ) );
440 :
441 0 : FieldUnit nMetric = (FieldUnit)0xffff;
442 0 : if( pFrameView)
443 0 : nMetric = pDoc->GetUIUnit();
444 : else
445 0 : nMetric = (FieldUnit)pOptions->GetMetric();
446 :
447 0 : if( nMetric == (FieldUnit)0xffff )
448 0 : nMetric = GetFieldUnit();
449 :
450 0 : pRet->Put( SfxUInt16Item( SID_ATTR_METRIC, (sal_uInt16)nMetric ) );
451 :
452 : // TP_OPTIONS_CONTENTS:
453 0 : pRet->Put( SdOptionsContentsItem( ATTR_OPTIONS_CONTENTS, pOptions, pFrameView ) );
454 :
455 : // TP_OPTIONS_MISC:
456 0 : SdOptionsMiscItem aSdOptionsMiscItem( ATTR_OPTIONS_MISC, pOptions, pFrameView );
457 0 : if ( pFrameView )
458 : {
459 0 : aSdOptionsMiscItem.GetOptionsMisc().SetSummationOfParagraphs( pDoc->IsSummationOfParagraphs() );
460 0 : aSdOptionsMiscItem.GetOptionsMisc().SetPrinterIndependentLayout (
461 0 : (sal_uInt16)pDoc->GetPrinterIndependentLayout());
462 : }
463 0 : pRet->Put( aSdOptionsMiscItem );
464 :
465 :
466 : // TP_OPTIONS_SNAP:
467 0 : pRet->Put( SdOptionsSnapItem( ATTR_OPTIONS_SNAP, pOptions, pFrameView ) );
468 :
469 : // TP_SCALE:
470 0 : sal_uInt32 nW = 10L;
471 0 : sal_uInt32 nH = 10L;
472 : sal_Int32 nX;
473 : sal_Int32 nY;
474 0 : if( pDocSh )
475 : {
476 0 : SdrPage* pPage = (SdrPage*) pDoc->GetSdPage(0, PK_STANDARD);
477 0 : Size aSize(pPage->GetSize());
478 0 : nW = aSize.Width();
479 0 : nH = aSize.Height();
480 : }
481 :
482 0 : if(pFrameView)
483 : {
484 0 : const Fraction& rFraction = pDoc->GetUIScale();
485 0 : nX=rFraction.GetNumerator();
486 0 : nY=rFraction.GetDenominator();
487 : }
488 : else
489 : {
490 : // Get options from configuration file
491 0 : pOptions->GetScale( nX, nY );
492 : }
493 :
494 0 : pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
495 0 : pRet->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
496 0 : pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_WIDTH, nW ) );
497 0 : pRet->Put( SfxUInt32Item( ATTR_OPTIONS_SCALE_HEIGHT, nH ) );
498 :
499 :
500 : // TP_OPTIONS_PRINT:
501 0 : pRet->Put( SdOptionsPrintItem( ATTR_OPTIONS_PRINT, pOptions ) );
502 :
503 : // RID_SVXPAGE_GRID:
504 0 : pRet->Put( SdOptionsGridItem( SID_ATTR_GRID_OPTIONS, pOptions ) );
505 :
506 0 : return pRet;
507 : }
508 0 : void SdModule::ApplyItemSet( sal_uInt16 nSlot, const SfxItemSet& rSet )
509 : {
510 0 : const SfxPoolItem* pItem = NULL;
511 0 : sal_Bool bNewDefTab = sal_False;
512 0 : sal_Bool bNewPrintOptions = sal_False;
513 0 : sal_Bool bMiscOptions = sal_False;
514 :
515 0 : ::sd::DrawDocShell* pDocSh = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
516 0 : SdDrawDocument* pDoc = NULL;
517 : // Here we set the DocType of the option dialog (not document!)
518 0 : DocumentType eDocType = DOCUMENT_TYPE_IMPRESS;
519 0 : if( nSlot == SID_SD_GRAPHIC_OPTIONS )
520 0 : eDocType = DOCUMENT_TYPE_DRAW;
521 :
522 0 : ::sd::ViewShell* pViewShell = NULL;
523 :
524 0 : if (pDocSh)
525 : {
526 0 : pDoc = pDocSh->GetDoc();
527 :
528 0 : pViewShell = pDocSh->GetViewShell();
529 0 : if (pViewShell != NULL)
530 0 : pViewShell->WriteFrameViewData();
531 : }
532 0 : SdOptions* pOptions = GetSdOptions(eDocType);
533 : // Grid
534 0 : if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS ,
535 0 : false, (const SfxPoolItem**) &pItem ))
536 : {
537 0 : const SdOptionsGridItem* pGridItem = (SdOptionsGridItem*) pItem;
538 0 : pGridItem->SetOptions( pOptions );
539 : }
540 :
541 : // Layout
542 0 : const SdOptionsLayoutItem* pLayoutItem = NULL;
543 0 : if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_LAYOUT,
544 0 : false, (const SfxPoolItem**) &pLayoutItem ))
545 : {
546 0 : pLayoutItem->SetOptions( pOptions );
547 : }
548 :
549 : // Metric
550 0 : if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC, false, &pItem ) )
551 : {
552 0 : if( pDoc && eDocType == pDoc->GetDocumentType() )
553 0 : PutItem( *pItem );
554 0 : pOptions->SetMetric( ( (SfxUInt16Item*) pItem )->GetValue() );
555 : }
556 0 : sal_uInt16 nDefTab = pOptions->GetDefTab();
557 : // Default-Tabulator
558 0 : if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_DEFTABSTOP, false, &pItem ) )
559 : {
560 0 : nDefTab = ( (SfxUInt16Item*) pItem )->GetValue();
561 0 : pOptions->SetDefTab( nDefTab );
562 :
563 0 : bNewDefTab = sal_True;
564 : }
565 :
566 : // Scale
567 0 : if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_X, false, &pItem ) )
568 : {
569 0 : sal_Int32 nX = ( (SfxInt32Item*) pItem )->GetValue();
570 0 : if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SCALE_Y, false, &pItem ) )
571 : {
572 0 : sal_Int32 nY = ( (SfxInt32Item*) pItem )->GetValue();
573 0 : pOptions->SetScale( nX, nY );
574 :
575 : // Apply to document only if doc type match
576 0 : if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
577 : {
578 0 : pDoc->SetUIScale( Fraction( nX, nY ) );
579 0 : if( pViewShell )
580 0 : pViewShell->SetRuler( pViewShell->HasRuler() );
581 : }
582 : }
583 : }
584 :
585 : // Contents
586 0 : const SdOptionsContentsItem* pContentsItem = NULL;
587 0 : if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_CONTENTS,
588 0 : false, (const SfxPoolItem**) &pContentsItem ))
589 : {
590 0 : pContentsItem->SetOptions( pOptions );
591 : }
592 :
593 : // Misc
594 0 : const SdOptionsMiscItem* pMiscItem = NULL;
595 0 : if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_MISC,
596 0 : false, (const SfxPoolItem**) &pMiscItem ))
597 : {
598 0 : pMiscItem->SetOptions( pOptions );
599 0 : bMiscOptions = sal_True;
600 : }
601 :
602 : // Snap
603 0 : const SdOptionsSnapItem* pSnapItem = NULL;
604 0 : if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_SNAP,
605 0 : false, (const SfxPoolItem**) &pSnapItem ))
606 : {
607 0 : pSnapItem->SetOptions( pOptions );
608 : }
609 :
610 0 : SfxItemSet aPrintSet( GetPool(),
611 : SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
612 : SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
613 : ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT,
614 0 : 0 );
615 :
616 : // Print
617 0 : const SdOptionsPrintItem* pPrintItem = NULL;
618 0 : if( SFX_ITEM_SET == rSet.GetItemState( ATTR_OPTIONS_PRINT,
619 0 : false, (const SfxPoolItem**) &pPrintItem ))
620 : {
621 0 : pPrintItem->SetOptions( pOptions );
622 :
623 : // set PrintOptionsSet
624 0 : SdOptionsPrintItem aPrintItem( ATTR_OPTIONS_PRINT, pOptions );
625 0 : SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC );
626 0 : sal_uInt16 nFlags = 0;
627 :
628 0 : nFlags = (aPrintItem.GetOptionsPrint().IsWarningSize() ? SFX_PRINTER_CHG_SIZE : 0) |
629 0 : (aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SFX_PRINTER_CHG_ORIENTATION : 0);
630 0 : aFlagItem.SetValue( nFlags );
631 :
632 0 : aPrintSet.Put( aPrintItem );
633 0 : aPrintSet.Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
634 0 : aPrintSet.Put( aFlagItem );
635 :
636 0 : bNewPrintOptions = sal_True;
637 : }
638 :
639 : // Only if also the document type matches...
640 0 : if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
641 : {
642 0 : if( bNewPrintOptions )
643 : {
644 0 : pDocSh->GetPrinter(sal_True)->SetOptions( aPrintSet );
645 : }
646 :
647 : // set DefTab at Model
648 0 : if( bNewDefTab )
649 : {
650 0 : SdDrawDocument* pDocument = pDocSh->GetDoc();
651 0 : pDocument->SetDefaultTabulator( nDefTab );
652 :
653 0 : ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
654 0 : if( pOutl )
655 0 : pOutl->SetDefTab( nDefTab );
656 :
657 0 : ::sd::Outliner* pInternalOutl = pDocument->GetInternalOutliner( sal_False );
658 0 : if( pInternalOutl )
659 0 : pInternalOutl->SetDefTab( nDefTab );
660 : }
661 0 : if ( bMiscOptions )
662 : {
663 0 : pDoc->SetSummationOfParagraphs( pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() );
664 0 : sal_uInt32 nSum = pMiscItem->GetOptionsMisc().IsSummationOfParagraphs() ? EE_CNTRL_ULSPACESUMMATION : 0;
665 : sal_uInt32 nCntrl;
666 :
667 0 : SdDrawDocument* pDocument = pDocSh->GetDoc();
668 0 : SdrOutliner& rOutl = pDocument->GetDrawOutliner();
669 0 : nCntrl = rOutl.GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
670 0 : rOutl.SetControlWord( nCntrl | nSum );
671 0 : ::sd::Outliner* pOutl = pDocument->GetOutliner( sal_False );
672 0 : if( pOutl )
673 : {
674 0 : nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
675 0 : pOutl->SetControlWord( nCntrl | nSum );
676 : }
677 0 : pOutl = pDocument->GetInternalOutliner( sal_False );
678 0 : if( pOutl )
679 : {
680 0 : nCntrl = pOutl->GetControlWord() &~ EE_CNTRL_ULSPACESUMMATION;
681 0 : pOutl->SetControlWord( nCntrl | nSum );
682 : }
683 :
684 : // Set printer independent layout mode.
685 0 : if( pDoc->GetPrinterIndependentLayout() != pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout() )
686 0 : pDoc->SetPrinterIndependentLayout (pMiscItem->GetOptionsMisc().GetPrinterIndependentLayout());
687 : }
688 : }
689 :
690 0 : pOptions->StoreConfig();
691 :
692 : // Only if also the document type matches...
693 0 : if( pDocSh && pDoc && eDocType == pDoc->GetDocumentType() )
694 : {
695 0 : FieldUnit eUIUnit = (FieldUnit) pOptions->GetMetric();
696 0 : pDoc->SetUIUnit(eUIUnit);
697 :
698 0 : if (pViewShell)
699 : {
700 : // make sure no one is in text edit mode, cause there
701 : // are some pointers remembered else (!)
702 0 : if(pViewShell->GetView())
703 0 : pViewShell->GetView()->SdrEndTextEdit();
704 :
705 0 : ::sd::FrameView* pFrame = pViewShell->GetFrameView();
706 0 : pFrame->Update(pOptions);
707 0 : pViewShell->ReadFrameViewData(pFrame);
708 0 : pViewShell->SetUIUnit(eUIUnit);
709 0 : pViewShell->SetDefTabHRuler( nDefTab );
710 : }
711 : }
712 :
713 0 : if( pViewShell && pViewShell->GetViewFrame() )
714 0 : pViewShell->GetViewFrame()->GetBindings().InvalidateAll( true );
715 0 : }
716 :
717 0 : SfxTabPage* SdModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
718 : {
719 0 : SfxTabPage* pRet = NULL;
720 0 : SfxAllItemSet aSet(*(rSet.GetPool()));
721 0 : SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
722 0 : if( pFact )
723 : {
724 0 : switch(nId)
725 : {
726 : case SID_SD_TP_CONTENTS:
727 : case SID_SI_TP_CONTENTS:
728 0 : { ::CreateTabPage fnCreatePage = pFact->GetSdOptionsContentsTabPageCreatorFunc();
729 0 : if( fnCreatePage )
730 0 : pRet = (*fnCreatePage)( pParent, rSet );
731 : }
732 0 : break;
733 : case SID_SD_TP_SNAP:
734 : case SID_SI_TP_SNAP:
735 0 : { ::CreateTabPage fnCreatePage = pFact->GetSdOptionsSnapTabPageCreatorFunc();
736 0 : if( fnCreatePage )
737 0 : pRet = (*fnCreatePage)( pParent, rSet );
738 : }
739 0 : break;
740 : case SID_SD_TP_PRINT:
741 : case SID_SI_TP_PRINT:
742 : {
743 0 : ::CreateTabPage fnCreatePage = pFact->GetSdPrintOptionsTabPageCreatorFunc();
744 0 : if( fnCreatePage )
745 : {
746 0 : pRet = (*fnCreatePage)( pParent, rSet );
747 0 : if(SID_SD_TP_PRINT == nId)
748 0 : aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
749 0 : pRet->PageCreated(aSet);
750 : }
751 : }
752 0 : break;
753 : case SID_SI_TP_MISC:
754 : case SID_SD_TP_MISC:
755 : {
756 0 : ::CreateTabPage fnCreatePage = pFact->GetSdOptionsMiscTabPageCreatorFunc();
757 0 : if( fnCreatePage )
758 : {
759 0 : pRet = (*fnCreatePage)( pParent, rSet );
760 0 : if(SID_SD_TP_MISC == nId)
761 0 : aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_DRAW_MODE));
762 : else
763 0 : aSet.Put (SfxUInt32Item(SID_SDMODE_FLAG,SD_IMPRESS_MODE));
764 0 : pRet->PageCreated(aSet);
765 : }
766 : }
767 0 : break;
768 : case RID_SVXPAGE_TEXTANIMATION :
769 : {
770 0 : SfxAbstractDialogFactory* pSfxFact = SfxAbstractDialogFactory::Create();
771 0 : if ( pSfxFact )
772 : {
773 0 : ::CreateTabPage fnCreatePage = pSfxFact->GetTabPageCreatorFunc( nId );
774 0 : if ( fnCreatePage )
775 0 : pRet = (*fnCreatePage)( pParent, rSet );
776 : }
777 : }
778 0 : break;
779 : }
780 : DBG_ASSERT( pRet, "SdModule::CreateTabPage(): no valid ID for TabPage!" );
781 : }
782 :
783 0 : return pRet;
784 0 : }
785 :
786 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|