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
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
|
/*************************************************************************
*
* $RCSfile: uitool.cxx,v $
*
* $Revision: 1.13 $
*
* last change: $Author: kz $ $Date: 2004-05-18 15:02:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (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.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#pragma hdrstop
#ifndef _HINTIDS_HXX
#include <hintids.hxx>
#endif
#ifndef _UIPARAM_HXX
#include <uiparam.hxx>
#endif
#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif
#ifndef _UNOTOOLS_COLLATORWRAPPER_HXX
#include <unotools/collatorwrapper.hxx>
#endif
#ifndef SVTOOLS_URIHELPER_HXX
#include <svtools/urihelper.hxx>
#endif
#ifndef _SFXSTRITEM_HXX //autogen
#include <svtools/stritem.hxx>
#endif
#ifndef _SFXAPP_HXX //autogen
#include <sfx2/app.hxx>
#endif
#ifndef _SFXDOCFILE_HXX //autogen
#include <sfx2/docfile.hxx>
#endif
#ifndef _SFX_DOCFILT_HACK_HXX //autogen
#include <sfx2/docfilt.hxx>
#endif
#ifndef _SVX_PMDLITEM_HXX //autogen
#include <svx/pmdlitem.hxx>
#endif
#ifndef _SVX_TSTPITEM_HXX //autogen
#include <svx/tstpitem.hxx>
#endif
#ifndef _SVX_BOXITEM_HXX //autogen
#include <svx/boxitem.hxx>
#endif
#ifndef _SVX_SIZEITEM_HXX //autogen
#include <svx/sizeitem.hxx>
#endif
#ifndef _SVX_PAGEITEM_HXX //autogen
#include <svx/pageitem.hxx>
#endif
#ifndef _SVX_LRSPITEM_HXX //autogen
#include <svx/lrspitem.hxx>
#endif
#ifndef _SFXSTYLE_HXX //autogen
#include <svtools/style.hxx>
#endif
#ifndef _VCL_LSTBOX_HXX //autogen
#include <vcl/lstbox.hxx>
#endif
#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX
#include <unotools/localedatawrapper.hxx>
#endif
#ifndef _FMTORNT_HXX //autogen
#include <fmtornt.hxx>
#endif
#ifndef _TABCOL_HXX //autogen
#include <tabcol.hxx>
#endif
#ifndef _FMTFSIZE_HXX //autogen
#include <fmtfsize.hxx>
#endif
#ifndef _FMTHDFT_HXX //autogen
#include <fmthdft.hxx>
#endif
#ifndef _FMTPDSC_HXX //autogen
#include <fmtpdsc.hxx>
#endif
#ifndef _SWWVIEW_HXX //autogen
#include <wview.hxx>
#endif
#ifndef _UIITEMS_HXX
#include <uiitems.hxx>
#endif
#ifndef _DOCSH_HXX
#include <docsh.hxx>
#endif
#ifndef _WRTSH_HXX
#include <wrtsh.hxx>
#endif
#ifndef _SWTYPES_HXX
#include <swtypes.hxx>
#endif
#ifndef _SWMODULE_HXX
#include <swmodule.hxx>
#endif
#ifndef _VIEW_HXX
#include <view.hxx>
#endif
#ifndef _UITOOL_HXX
#include <uitool.hxx>
#endif
#ifndef _PAGEDESC_HXX
#include <pagedesc.hxx>
#endif
#ifndef _FRMATR_HXX
#include <frmatr.hxx>
#endif
#ifndef _PARATR_HXX
#include <paratr.hxx>
#endif
#ifndef _FMTCOL_HXX
#include <fmtcol.hxx>
#endif
#ifndef _POOLFMT_HXX
#include <poolfmt.hxx>
#endif
#ifndef _USRPREF_HXX
#include "usrpref.hxx"
#endif
#ifndef _ERROR_H
#include <error.h>
#endif
#ifndef _CMDID_H
#include <cmdid.h>
#endif
#ifndef _GLOBALS_HRC
#include <globals.hrc>
#endif
#ifndef _UTLUI_HRC
#include <utlui.hrc>
#endif
#ifndef _DOC_HXX //autogen wg. SwDoc
#include <doc.hxx>
#endif
#ifndef _DOCARY_HXX
#include <docary.hxx>
#endif
#ifndef _CHARFMT_HXX //autogen wg. SwCharFmt
#include <charfmt.hxx>
#endif
#ifndef _SWSTYLENAMEMAPPER_HXX
#include <SwStyleNameMapper.hxx>
#endif
// 50 cm 28350
//
#define MAXHEIGHT 28350
#define MAXWIDTH 28350
/*--------------------------------------------------------------------
Beschreibung: Allgemeine List von StringPointern
--------------------------------------------------------------------*/
/*--------------------------------------------------------------------
Beschreibung: Metric umschalten
--------------------------------------------------------------------*/
void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit)
{
SwTwips nMin = rCtrl.GetMin(FUNIT_TWIP);
SwTwips nMax = rCtrl.GetMax(FUNIT_TWIP);
rCtrl.SetUnit(eUnit);
rCtrl.SetMin(nMin, FUNIT_TWIP);
rCtrl.SetMax(nMax, FUNIT_TWIP);
}
/*--------------------------------------------------------------------
Beschreibung: Boxinfo-Attribut setzen
--------------------------------------------------------------------*/
void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh)
{
SvxBoxInfoItem aBoxInfo;
const SfxPoolItem *pBoxInfo;
if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER,
TRUE, &pBoxInfo))
aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo;
// Tabellenvariante, wenn mehrere Tabellenzellen selektiert
rSh.GetCrsr(); //Damit GetCrsrCnt() auch das Richtige liefert
aBoxInfo.SetTable (rSh.IsTableMode() && rSh.GetCrsrCnt() > 1);
// Abstandsfeld immer anzeigen
aBoxInfo.SetDist ((BOOL) TRUE);
// Minimalgroesse in Tabellen und Absaetzen setzen
aBoxInfo.SetMinDist (rSh.IsTableMode() || rSh.GetSelectionType() & (SwWrtShell::SEL_TXT | SwWrtShell::SEL_TBL));
// Default-Abstand immer setzen
aBoxInfo.SetDefDist (MIN_BORDER_DIST);
// Einzelne Linien koennen nur in Tabellen DontCare-Status haben
aBoxInfo.SetValid(VALID_DISABLE, !rSh.IsTableMode());
rSet.Put(aBoxInfo);
}
/*--------------------------------------------------------------------
Beschreibung: Header Footer fuellen
--------------------------------------------------------------------*/
void FillHdFt(SwFrmFmt* pFmt, const SfxItemSet& rSet)
{
SwAttrSet aSet(pFmt->GetAttrSet());
aSet.Put(rSet);
const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE);
const SfxBoolItem& rDynamic = (const SfxBoolItem&)rSet.Get(SID_ATTR_PAGE_DYNAMIC);
// Groesse umsetzen
//
SwFmtFrmSize aFrmSize(rDynamic.GetValue() ? ATT_MIN_SIZE : ATT_FIX_SIZE,
rSize.GetSize().Width(),
rSize.GetSize().Height());
aSet.Put(aFrmSize);
pFmt->SetAttr(aSet);
}
/*--------------------------------------------------------------------
Beschreibung: PageDesc <-> in Sets wandeln und zurueck
--------------------------------------------------------------------*/
void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc )
{
SwFrmFmt& rMaster = rPageDesc.GetMaster();
// alle allgemeinen Rahmen-Attribute uebertragen
//
rMaster.SetAttr(rSet);
// PageData
//
if(rSet.GetItemState(SID_ATTR_PAGE) == SFX_ITEM_SET)
{
const SvxPageItem& rPageItem = (const SvxPageItem&)rSet.Get(SID_ATTR_PAGE);
USHORT nUse = (USHORT)rPageItem.GetPageUsage();
if(nUse & 0x04)
nUse |= 0x03;
if(nUse)
rPageDesc.SetUseOn( (UseOnPage) nUse );
rPageDesc.SetLandscape(rPageItem.IsLandscape());
SvxNumberType aNumType;
aNumType.SetNumberingType(rPageItem.GetNumType());
rPageDesc.SetNumType(aNumType);
}
// Groesse
//
if(rSet.GetItemState(SID_ATTR_PAGE_SIZE) == SFX_ITEM_SET)
{
const SvxSizeItem& rSizeItem = (const SvxSizeItem&)rSet.Get(SID_ATTR_PAGE_SIZE);
SwFmtFrmSize aSize(ATT_FIX_SIZE);
aSize.SetSize(rSizeItem.GetSize());
rMaster.SetAttr(aSize);
}
// Kopzeilen-Attribute auswerten
//
const SfxPoolItem* pItem;
if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_HEADERSET,
FALSE, &pItem ) )
{
const SfxItemSet& rHeaderSet = ((SvxSetItem*)pItem)->GetItemSet();
const SfxBoolItem& rHeaderOn = (const SfxBoolItem&)rHeaderSet.Get(SID_ATTR_PAGE_ON);
if(rHeaderOn.GetValue())
{
// Werte uebernehmen
if(!rMaster.GetHeader().IsActive())
rMaster.SetAttr(SwFmtHeader(TRUE));
// Das Headerformat rausholen und anpassen
//
SwFmtHeader aHeaderFmt(rMaster.GetHeader());
SwFrmFmt *pHeaderFmt = aHeaderFmt.GetHeaderFmt();
ASSERT(pHeaderFmt != 0, "kein HeaderFormat");
::FillHdFt(pHeaderFmt, rHeaderSet);
rPageDesc.ChgHeaderShare(((const SfxBoolItem&)
rHeaderSet.Get(SID_ATTR_PAGE_SHARED)).GetValue());
}
else
{ // Header ausschalten
//
if(rMaster.GetHeader().IsActive())
{
rMaster.SetAttr(SwFmtHeader(BOOL(FALSE)));
rPageDesc.ChgHeaderShare(FALSE);
}
}
}
// Fusszeilen-Attribute auswerten
//
if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_FOOTERSET,
FALSE, &pItem ) )
{
const SfxItemSet& rFooterSet = ((SvxSetItem*)pItem)->GetItemSet();
const SfxBoolItem& rFooterOn = (const SfxBoolItem&)rFooterSet.Get(SID_ATTR_PAGE_ON);
if(rFooterOn.GetValue())
{
// Werte uebernehmen
if(!rMaster.GetFooter().IsActive())
rMaster.SetAttr(SwFmtFooter(TRUE));
// Das Footerformat rausholen und anpassen
//
SwFmtFooter aFooterFmt(rMaster.GetFooter());
SwFrmFmt *pFooterFmt = aFooterFmt.GetFooterFmt();
ASSERT(pFooterFmt != 0, "kein FooterFormat");
::FillHdFt(pFooterFmt, rFooterSet);
rPageDesc.ChgFooterShare(((const SfxBoolItem&)
rFooterSet.Get(SID_ATTR_PAGE_SHARED)).GetValue());
}
else
{ // Footer ausschalten
//
if(rMaster.GetFooter().IsActive())
{
rMaster.SetAttr(SwFmtFooter(BOOL(FALSE)));
rPageDesc.ChgFooterShare(FALSE);
}
}
}
// Fussnoten
//
if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_FTN_INFO,
FALSE, &pItem ) )
rPageDesc.SetFtnInfo( ((SwPageFtnInfoItem*)pItem)->GetPageFtnInfo() );
//
// Columns
//
// Registerhaltigkeit
if(SFX_ITEM_SET == rSet.GetItemState(
SID_SWREGISTER_MODE, FALSE, &pItem))
{
BOOL bSet = ((const SfxBoolItem*)pItem)->GetValue();
if(!bSet)
rPageDesc.SetRegisterFmtColl(0);
else if(SFX_ITEM_SET == rSet.GetItemState(
SID_SWREGISTER_COLLECTION, FALSE, &pItem))
{
const String& rColl = ((const SfxStringItem*)pItem)->GetValue();
SwDoc& rDoc = *rMaster.GetDoc();
SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( rColl );
if( !pColl )
{
USHORT nId = SwStyleNameMapper::GetPoolIdFromUIName( rColl, GET_POOLID_TXTCOLL );
if( USHRT_MAX != nId )
pColl = rDoc.GetTxtCollFromPool( nId );
else
pColl = rDoc.MakeTxtFmtColl( rColl,
(SwTxtFmtColl*)rDoc.GetDfltTxtFmtColl() );
}
if( pColl )
pColl->SetAttr( SwRegisterItem ( TRUE ));
rPageDesc.SetRegisterFmtColl( pColl );
}
}
}
/*--------------------------------------------------------------------
Beschreibung:
--------------------------------------------------------------------*/
void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet)
{
const SwFrmFmt& rMaster = rPageDesc.GetMaster();
// Seitendaten
//
SvxPageItem aPageItem(SID_ATTR_PAGE);
aPageItem.SetDescName(rPageDesc.GetName());
aPageItem.SetPageUsage((SvxPageUsage)rPageDesc.GetUseOn());
aPageItem.SetLandscape(rPageDesc.GetLandscape());
aPageItem.SetNumType((SvxNumType)rPageDesc.GetNumType().GetNumberingType());
rSet.Put(aPageItem);
// Groesse
SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, rMaster.GetFrmSize().GetSize());
rSet.Put(aSizeItem);
// Maximale Groesse
SvxSizeItem aMaxSizeItem(SID_ATTR_PAGE_MAXSIZE, Size(MAXWIDTH, MAXHEIGHT));
rSet.Put(aMaxSizeItem);
// Raender, Umrandung und das andere Zeug
//
rSet.Put(rMaster.GetAttrSet());
SvxBoxInfoItem aBoxInfo;
const SfxPoolItem *pBoxInfo;
if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER,
TRUE, &pBoxInfo) )
aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo;
aBoxInfo.SetTable( FALSE );
// Abstandsfeld immer anzeigen
aBoxInfo.SetDist( TRUE);
// Minimalgroesse in Tabellen und Absaetzen setzen
aBoxInfo.SetMinDist( FALSE );
// Default-Abstand immer setzen
aBoxInfo.SetDefDist( MIN_BORDER_DIST );
// Einzelne Linien koennen nur in Tabellen DontCare-Status haben
aBoxInfo.SetValid( VALID_DISABLE );
rSet.Put( aBoxInfo );
SfxStringItem aFollow(SID_ATTR_PAGE_EXT1, aEmptyStr);
if(rPageDesc.GetFollow())
aFollow.SetValue(rPageDesc.GetFollow()->GetName());
rSet.Put(aFollow);
// Header
//
if(rMaster.GetHeader().IsActive())
{
const SwFmtHeader &rHeaderFmt = rMaster.GetHeader();
const SwFrmFmt *pHeaderFmt = rHeaderFmt.GetHeaderFmt();
ASSERT(pHeaderFmt != 0, kein HeaderFormat.);
// HeaderInfo, Raender, Hintergrund, Umrandung
//
SfxItemSet aHeaderSet( *rSet.GetPool(),
SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED,
SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
RES_FRMATR_BEGIN, RES_FRMATR_END-1,
0);
// dynamische oder feste Hoehe
//
SfxBoolItem aOn(SID_ATTR_PAGE_ON, TRUE);
aHeaderSet.Put(aOn);
const SwFmtFrmSize &rFrmSize = pHeaderFmt->GetFrmSize();
const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType();
SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE);
aHeaderSet.Put(aDynamic);
// Links gleich rechts
//
SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsHeaderShared());
aHeaderSet.Put(aShared);
// Groesse
SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize()));
aHeaderSet.Put(aSize);
// Rahmen-Attribute umschaufeln
//
aHeaderSet.Put(pHeaderFmt->GetAttrSet());
aHeaderSet.Put( aBoxInfo );
// SetItem erzeugen
//
SvxSetItem aSetItem(SID_ATTR_PAGE_HEADERSET, aHeaderSet);
rSet.Put(aSetItem);
}
// Footer
if(rMaster.GetFooter().IsActive())
{
const SwFmtFooter &rFooterFmt = rMaster.GetFooter();
const SwFrmFmt *pFooterFmt = rFooterFmt.GetFooterFmt();
ASSERT(pFooterFmt != 0, kein FooterFormat.);
// FooterInfo, Raender, Hintergrund, Umrandung
//
SfxItemSet aFooterSet( *rSet.GetPool(),
SID_ATTR_PAGE_ON, SID_ATTR_PAGE_SHARED,
SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
RES_FRMATR_BEGIN, RES_FRMATR_END-1,
0);
// dynamische oder feste Hoehe
//
SfxBoolItem aOn(SID_ATTR_PAGE_ON, TRUE);
aFooterSet.Put(aOn);
const SwFmtFrmSize &rFrmSize = pFooterFmt->GetFrmSize();
const SwFrmSize eSizeType = rFrmSize.GetHeightSizeType();
SfxBoolItem aDynamic(SID_ATTR_PAGE_DYNAMIC, eSizeType != ATT_FIX_SIZE);
aFooterSet.Put(aDynamic);
// Links gleich rechts
//
SfxBoolItem aShared(SID_ATTR_PAGE_SHARED, rPageDesc.IsFooterShared());
aFooterSet.Put(aShared);
// Groesse
SvxSizeItem aSize(SID_ATTR_PAGE_SIZE, Size(rFrmSize.GetSize()));
aFooterSet.Put(aSize);
// Rahmen-Attribute umschaufeln
//
aFooterSet.Put(pFooterFmt->GetAttrSet());
aFooterSet.Put( aBoxInfo );
// SetItem erzeugen
//
SvxSetItem aSetItem(SID_ATTR_PAGE_FOOTERSET, aFooterSet);
rSet.Put(aSetItem);
}
// Fussnoten einbauen
//
SwPageFtnInfo& rInfo = (SwPageFtnInfo&)rPageDesc.GetFtnInfo();
SwPageFtnInfoItem aFtnItem(FN_PARAM_FTN_INFO, rInfo);
rSet.Put(aFtnItem);
// Registerhaltigkeit
const SwTxtFmtColl* pCol = rPageDesc.GetRegisterFmtColl();
SwRegisterItem aReg(pCol != 0);
aReg.SetWhich(SID_SWREGISTER_MODE);
rSet.Put(aReg);
if(pCol)
rSet.Put(SfxStringItem(SID_SWREGISTER_COLLECTION, pCol->GetName()));
}
/*--------------------------------------------------------------------
Beschreibung: DefaultTabs setzen
--------------------------------------------------------------------*/
void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem& rTabs)
{
if( rTabs.Count() )
return;
{
SvxTabStop aSwTabStop( nDefDist, SVX_TAB_ADJUST_DEFAULT );
rTabs.Insert( aSwTabStop );
}
}
/*--------------------------------------------------------------------
Beschreibung: Abstand zwischen zwei Tabs
--------------------------------------------------------------------*/
USHORT GetTabDist(const SvxTabStopItem& rTabs)
{
USHORT nDefDist;
if( rTabs.Count() )
nDefDist = (USHORT)( rTabs[0].GetTabPos() );
else
nDefDist = 1134; // 2cm
return nDefDist;
}
// erfrage ob im Set eine Sfx-PageDesc-Kombination vorliegt und returne diese
void SfxToSwPageDescAttr( const SwWrtShell& rShell, SfxItemSet& rSet )
{
const SfxPoolItem* pItem;
SwFmtPageDesc aPgDesc;
BOOL bChanged = FALSE;
// Seitennummer
if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_PARA_PAGENUM, FALSE, &pItem))
{
aPgDesc.SetNumOffset(((SfxUInt16Item*)pItem)->GetValue());
bChanged = TRUE;
}
if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PARA_MODEL, FALSE, &pItem ))
{
const String& rDescName = ((SvxPageModelItem*)pItem)->GetValue();
if( rDescName.Len() ) // kein Name -> PageDesc ausschalten!
{
// nur loeschen, wenn PageDesc eingschaltet wird!
rSet.ClearItem( RES_BREAK );
SwPageDesc* pDesc = ((SwWrtShell&)rShell).FindPageDescByName(
rDescName, TRUE );
if( pDesc )
pDesc->Add( &aPgDesc );
}
rSet.ClearItem( SID_ATTR_PARA_MODEL );
bChanged = TRUE;
}
else
{
SfxItemSet aCoreSet(rShell.GetView().GetPool(), RES_PAGEDESC, RES_PAGEDESC );
rShell.GetAttr( aCoreSet );
if(SFX_ITEM_SET == aCoreSet.GetItemState( RES_PAGEDESC, TRUE, &pItem ) )
{
if( ((SwFmtPageDesc*)pItem)->GetPageDesc() )
{
((SwFmtPageDesc*)pItem)->GetPageDesc()->Add(&aPgDesc);
}
}
}
if(bChanged)
rSet.Put( aPgDesc );
}
// erfrage ob im Set eine Sfx-PageDesc-Kombination vorliegt und returne diese
void SwToSfxPageDescAttr( SfxItemSet& rCoreSet )
{
const SfxPoolItem* pItem = 0;
String aName;
USHORT nPageNum = 0;
BOOL bPut = TRUE;
switch( rCoreSet.GetItemState( RES_PAGEDESC, TRUE, &pItem ) )
{
case SFX_ITEM_SET:
{
if( ((SwFmtPageDesc*)pItem)->GetPageDesc() )
{
aName = ((SwFmtPageDesc*)pItem)->GetPageDesc()->GetName();
nPageNum = ((SwFmtPageDesc*)pItem)->GetNumOffset();
}
rCoreSet.ClearItem( RES_PAGEDESC );
// Seitennummer
}
break;
case SFX_ITEM_AVAILABLE:
break;
default:
bPut = FALSE;
}
SfxUInt16Item aPageNum( SID_ATTR_PARA_PAGENUM, nPageNum );
rCoreSet.Put( aPageNum );
if(bPut)
rCoreSet.Put( SvxPageModelItem( aName, TRUE, SID_ATTR_PARA_MODEL ) );
}
/*--------------------------------------------------------------------
Beschreibung: Metric ermitteln
--------------------------------------------------------------------*/
FieldUnit GetDfltMetric(BOOL bWeb)
{
return SW_MOD()->GetUsrPref(bWeb)->GetMetric();
}
/*--------------------------------------------------------------------
Beschreibung: Metric ermitteln
--------------------------------------------------------------------*/
void SetDfltMetric( FieldUnit eMetric, BOOL bWeb )
{
SW_MOD()->ApplyUserMetric(eMetric, bWeb);
}
/*-----------------15.07.97 10:49-------------------
--------------------------------------------------*/
// Umwandlung: Sub(LibName.ModulName) -> LibName.ModulName.Sub
String ConvertMacroFormat(const String& rInput )
{
String sTemp(rInput);
USHORT nFound = sTemp.Search('(');
USHORT nTokenCount = sTemp.GetTokenCount('.');
String sMac(rInput);
if( STRING_NOTFOUND != nFound || nTokenCount < 2)
{
if(nTokenCount < 2)
nFound = sTemp.Len();
// anderes Format: "Macro(Bibliothek.Modul)"
sMac = sTemp.Copy(0, nFound);
sTemp.Erase(0, nFound);
if(sTemp.Len() > 2)
{
sMac.Insert('.', 0);
sMac.Insert(sTemp.Copy(1, sTemp.Len() - 2), 0);
}
}
return sMac;
}
BOOL GetFileFilterNameDlg( Window& rParent, String& rFileName,
String* pPassword, String* pFilterName,
SfxMedium** ppMedium )
{
Window* pDefDlgParent = Application::GetDefDialogParent();
Application::SetDefDialogParent( &rParent );
SfxMedium* pMed = SFX_APP()->InsertDocumentDialog( 0, String::CreateFromAscii("swriter") );
if( pMed )
{
if( pFilterName )
*pFilterName = pMed->GetFilter()->GetFilterName();
rFileName = URIHelper::SmartRelToAbs( pMed->GetName() );
if( pPassword )
{
const SfxPoolItem* pItem;
if( SFX_ITEM_SET == pMed->GetItemSet()->GetItemState(
SID_PASSWORD, FALSE, &pItem ) )
*pPassword = ((SfxStringItem*)pItem)->GetValue();
}
if( ppMedium )
*ppMedium = pMed;
else
delete pMed; // das brauchen wir nicht mehr !
}
Application::SetDefDialogParent( pDefDlgParent );
return 0 != pMed;
}
/*-----------------09.04.98 16:58-------------------
--------------------------------------------------*/
USHORT InsertStringSorted(const String& rEntry, ListBox& rToFill, USHORT nOffset )
{
USHORT i = nOffset;
CollatorWrapper& rCaseColl = ::GetAppCaseCollator();
for( ; i < rToFill.GetEntryCount(); i++ )
{
if( 0 < rCaseColl.compareString( rToFill.GetEntry(i), rEntry ))
break;
}
return rToFill.InsertEntry(rEntry, i);
}
void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, BOOL bSorted, BOOL bWithDefault)
{
BOOL bHasOffset = rToFill.GetEntryCount() > 0;
SfxStyleSheetBasePool* pPool = pDocSh->GetStyleSheetPool();
pPool->SetSearchMask(SFX_STYLE_FAMILY_CHAR, SFXSTYLEBIT_ALL);
SwDoc* pDoc = pDocSh->GetDoc();
const SfxStyleSheetBase* pBase = pPool->First();
String sStandard;
SwStyleNameMapper::FillUIName( RES_POOLCOLL_STANDARD, sStandard );
while(pBase)
{
if(bWithDefault || pBase->GetName() != sStandard)
{
USHORT nPos;
if(bSorted)
nPos = InsertStringSorted(pBase->GetName(), rToFill, bHasOffset );
else
nPos = rToFill.InsertEntry(pBase->GetName());
long nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( pBase->GetName(), GET_POOLID_CHRFMT );
rToFill.SetEntryData( nPos, (void*) (nPoolId));
}
pBase = pPool->Next();
}
// non-pool styles
const SwCharFmts* pFmts = pDoc->GetCharFmts();
for(USHORT i = 0; i < pFmts->Count(); i++)
{
const SwCharFmt* pFmt = (*pFmts)[i];
if(pFmt->IsDefault())
continue;
const String& rName = pFmt->GetName();
if(rToFill.GetEntryPos(rName) == LISTBOX_ENTRY_NOTFOUND)
{
USHORT nPos;
if(bSorted)
nPos = InsertStringSorted(rName, rToFill, bHasOffset );
else
nPos = rToFill.InsertEntry(rName);
long nPoolId = USHRT_MAX;
rToFill.SetEntryData( nPos, (void*) (nPoolId));
}
}
};
/* -----------------27.04.98 08:26-------------------
*
* --------------------------------------------------*/
SwTwips GetTableWidth( SwFrmFmt* pFmt, SwTabCols& rCols, USHORT *pPercent,
SwWrtShell* pSh )
{
//Die Breite zu besorgen ist etwas komplizierter.
SwTwips nWidth;
const SwHoriOrient eOri = pFmt->GetHoriOrient().GetHoriOrient();
switch(eOri)
{
case HORI_FULL: nWidth = rCols.GetRight(); break;
case HORI_LEFT_AND_WIDTH:
case HORI_LEFT:
case HORI_RIGHT:
case HORI_CENTER:
nWidth = pFmt->GetFrmSize().GetWidth();
break;
default:
{
if(pSh)
{
const SwFrmFmt *pFlyFmt;
if ( 0 == (pFlyFmt = pSh->GetFlyFrmFmt()) )
{
nWidth = pSh->GetAnyCurRect(RECT_PAGE_PRT).Width();
}
else
{
nWidth = pSh->GetAnyCurRect(RECT_FLY_PRT_EMBEDDED).Width();
}
}
else
{
DBG_ERROR("wo soll die Breite denn herkommen?")
}
const SvxLRSpaceItem& rLRSpace = pFmt->GetLRSpace();
nWidth -= (rLRSpace.GetRight() + rLRSpace.GetLeft());
}
}
if (pPercent)
*pPercent = pFmt->GetFrmSize().GetWidthPercent();
return nWidth;
}
/*------------------------------------------------------------------------*/
String GetAppLangDateTimeString( const DateTime& rDT )
{
LocaleDataWrapper& rAppLclData = GetAppLocaleData();
String sRet( rAppLclData.getDate( rDT ));
( sRet += ' ' ) += rAppLclData.getTime( rDT, FALSE, FALSE );
return sRet;
}
|