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