summaryrefslogtreecommitdiffstats
path: root/binfilter/bf_sc/source/ui/view/sc_printfun.cxx
blob: a19fed8eeba8282953738ebd37d708f0efb773ad (plain)
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
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifdef _MSC_VER
#pragma hdrstop
#endif

#include "scitems.hxx"
#define ITEMID_FIELD EE_FEATURE_FIELD

#include <bf_svx/svxids.hrc>
#include <bf_svx/adjitem.hxx>
#include <bf_svx/boxitem.hxx>
#include <bf_svx/editstat.hxx>      // EE_CNTRL_RTFSTYLESHEETS
#include <bf_svx/lrspitem.hxx>
#include <bf_svx/paperinf.hxx>
#include <bf_svx/shaditem.hxx>
#include <bf_svx/sizeitem.hxx>
#include <bf_svx/ulspitem.hxx>
#include <bf_sfx2/printer.hxx>
#include <bf_sfx2/docfile.hxx>
#include <tools/urlobj.hxx>

#ifdef MAC
#define RGBColor MAC_RGBColor
#undef RGBColor
#else
#endif

#include "docsh.hxx"
#include "stlpool.hxx"
#include "attrib.hxx"
#include "patattr.hxx"
#include "docpool.hxx"
#include "dociter.hxx"
#include "cell.hxx"
#include "globstr.hrc"
#include "bf_sc.hrc"
#include "printopt.hxx"

#define _PRINTFUN_CXX
#include "printfun.hxx"
namespace binfilter {



#define ZOOM_MIN    10

#define GET_BOOL(set,which)   ((const SfxBoolItem&)(set)->Get((which))).GetValue()
#define GET_USHORT(set,which) ((const SfxUInt16Item&)(set)->Get((which))).GetValue()
#define GET_SHOW(set,which)   ( VOBJ_MODE_SHOW == ScVObjMode( ((const ScViewObjectModeItem&)(set)->Get((which))).GetValue()) )

//------------------------------------------------------------------------



/*N*/ void ScPageRowEntry::SetPagesX(USHORT nNew)
/*N*/ {
/*N*/   if (pHidden)
/*N*/   {
/*N*/       OSL_FAIL("SetPagesX nicht nach SetHidden");
/*N*/       delete[] pHidden;
/*N*/       pHidden = NULL;
/*N*/   }
/*N*/   nPagesX = nNew;
/*N*/ }




//------------------------------------------------------------------------

/*N*/ long lcl_LineTotal(const SvxBorderLine* pLine)
/*N*/ {
/*N*/   return pLine ? ( pLine->GetOutWidth() + pLine->GetInWidth() + pLine->GetDistance() ) : 0;
/*N*/ }

/*M*/ void ScPrintFunc::Construct( const ScPrintOptions* pOptions )
/*M*/ {
/*M*/   pDoc = pDocShell->GetDocument();
/*M*/
/*M*/   SfxPrinter* pDocPrinter = pDoc->GetPrinter();   // auch fuer Preview den Drucker nehmen
/*M*/   if (pDocPrinter)
/*M*/       aOldPrinterMode = pDocPrinter->GetMapMode();
/*M*/
/*M*/   //  einheitlicher MapMode ueber alle Aufrufe (z.B. Repaint !!!),
/*M*/   //  weil die EditEngine sonst unterschiedliche Texthoehen liefert
/*M*/   pDev->SetMapMode(MAP_PIXEL);
/*M*/
/*M*/   pPageEndX = NULL;
/*M*/   pPageEndY = NULL;
/*M*/   pPageRows = NULL;
/*M*/   pBorderItem = NULL;
/*M*/   pBackgroundItem = NULL;
/*M*/   pShadowItem = NULL;
/*M*/
/*M*/   pEditEngine = NULL;
/*M*/   pEditDefaults = NULL;
/*M*/
/*M*/   ScStyleSheetPool* pStylePool    = pDoc->GetStyleSheetPool();
/*M*/   SfxStyleSheetBase* pStyleSheet  = pStylePool->Find(
/*M*/                                           pDoc->GetPageStyle( nPrintTab ),
/*M*/                                           SFX_STYLE_FAMILY_PAGE );
/*M*/   if (pStyleSheet)
/*M*/       pParamSet = &pStyleSheet->GetItemSet();
/*M*/   else
/*M*/   {
/*M*/       OSL_FAIL("Seitenvorlage nicht gefunden" );
/*M*/       pParamSet = NULL;
/*M*/   }
/*M*/
/*M*/   if (!bState)
/*M*/       nZoom = 100;
/*M*/   nManualZoom = 100;
/*M*/   bClearWin = FALSE;
/*M*/   bUseStyleColor = FALSE;
/*M*/   bIsRender = FALSE;
/*M*/
/*M*/   InitParam(pOptions);
/*M*/
/*M*/   pPageData = NULL;       // wird nur zur Initialisierung gebraucht
/*M*/ }

/*N*/ ScPrintFunc::ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, USHORT nTab,
/*N*/                           long nPage, long nDocP, const ScRange* pArea,
/*N*/                           const ScPrintOptions* pOptions,
/*N*/                           ScPageBreakData* pData )
/*N*/   :   pDocShell           ( pShell ),
/*N*/       pPrinter            ( pNewPrinter ),
/*N*/       nPrintTab           ( nTab ),
/*N*/       nPageStart          ( nPage ),
/*N*/       nDocPages           ( nDocP ),
/*N*/       pUserArea           ( pArea ),
/*N*/       bState              ( FALSE ),
/*N*/       bSourceRangeValid   ( FALSE ),
/*N*/       bPrintCurrentTable  ( FALSE ),
/*N*/       bMultiArea          ( FALSE ),
/*N*/       nTabPages           ( 0 ),
/*N*/       nTotalPages         ( 0 ),
/*N*/       pPageData           ( pData )
/*N*/ {
/*N*/   pDev = pPrinter;
/*N*/   aSrcOffset = pPrinter->PixelToLogic( pPrinter->GetPageOffsetPixel(), MAP_100TH_MM );
/*N*/   Construct( pOptions );
/*N*/ }

/*N*/ ScPrintFunc::~ScPrintFunc()
/*N*/ {
/*N*/   ScTripel* pTripel = (ScTripel*) aNotePosList.First();
/*N*/   while (pTripel)
/*N*/   {
/*?*/       delete pTripel;
/*?*/       pTripel = (ScTripel*) aNotePosList.Next();
/*N*/   }
/*N*/   aNotePosList.Clear();
/*N*/
/*N*/   delete[] pPageEndX;
/*N*/   delete[] pPageEndY;
/*N*/   delete[] pPageRows;
/*N*/   delete pEditDefaults;
/*N*/   delete pEditEngine;
/*N*/
/*N*/   //  Druckereinstellungen werden jetzt von aussen wiederhergestellt
/*N*/
/*N*/   //  #64294# Fuer DrawingLayer/Charts muss der MapMode am Drucker (RefDevice) immer stimmen
/*N*/   SfxPrinter* pDocPrinter = pDoc->GetPrinter();   // auch fuer Preview den Drucker nehmen
/*N*/   if (pDocPrinter)
/*N*/       pDocPrinter->SetMapMode(aOldPrinterMode);
/*N*/ }

//
//          Drucken
//

/*N*/ void lcl_FillHFParam( ScPrintHFParam& rParam, const SfxItemSet* pHFSet )
/*N*/ {
/*N*/   //  nDistance muss vorher unterschiedlich initalisiert sein
/*N*/
/*N*/   if ( pHFSet == NULL )
/*N*/   {
/*N*/       rParam.bEnable  = FALSE;
/*N*/       rParam.pBorder  = NULL;
/*N*/       rParam.pBack    = NULL;
/*N*/       rParam.pShadow  = NULL;
/*N*/   }
/*N*/   else
/*N*/   {
/*N*/       rParam.bEnable  = ((const SfxBoolItem&) pHFSet->Get(ATTR_PAGE_ON)).GetValue();
/*N*/       rParam.bDynamic = ((const SfxBoolItem&) pHFSet->Get(ATTR_PAGE_DYNAMIC)).GetValue();
/*N*/       rParam.bShared  = ((const SfxBoolItem&) pHFSet->Get(ATTR_PAGE_SHARED)).GetValue();
/*N*/       rParam.nHeight  = ((const SvxSizeItem&) pHFSet->Get(ATTR_PAGE_SIZE)).GetSize().Height();
/*N*/       const SvxLRSpaceItem* pHFLR = &(const SvxLRSpaceItem&) pHFSet->Get(ATTR_LRSPACE);
/*N*/       long nTmp;
/*N*/       nTmp = pHFLR->GetLeft();
/*N*/       rParam.nLeft = nTmp < 0 ? 0 : USHORT(nTmp);
/*N*/       nTmp = pHFLR->GetRight();
/*N*/       rParam.nRight = nTmp < 0 ? 0 : USHORT(nTmp);
/*N*/       rParam.pBorder  = (const SvxBoxItem*)   &pHFSet->Get(ATTR_BORDER);
/*N*/       rParam.pBack    = (const SvxBrushItem*) &pHFSet->Get(ATTR_BACKGROUND);
/*N*/       rParam.pShadow  = (const SvxShadowItem*)&pHFSet->Get(ATTR_SHADOW);;
/*N*/
/*N*/ //    jetzt doch wieder schon im Dialog:
/*N*/ //        rParam.nHeight += rParam.nDistance;             // nicht mehr im Dialog ???
/*N*/
/*N*/       if (rParam.pBorder)
/*N*/           rParam.nHeight += lcl_LineTotal( rParam.pBorder->GetTop() ) +
/*N*/                             lcl_LineTotal( rParam.pBorder->GetBottom() );
/*N*/
/*N*/       rParam.nManHeight = rParam.nHeight;
/*N*/   }
/*N*/
/*N*/   if (!rParam.bEnable)
/*N*/       rParam.nHeight = 0;
/*N*/ }

//  bNew = TRUE:    benutzten Bereich aus dem Dokument suchen
//  bNew = FALSE:   nur ganze Zeilen/Spalten begrenzen

/*N*/ BOOL ScPrintFunc::AdjustPrintArea( BOOL bNew )
/*N*/ {
/*N*/   USHORT nOldEndCol = nEndCol;    // nur wichtig bei !bNew
/*N*/   USHORT nOldEndRow = nEndRow;
/*N*/   BOOL bChangeCol = TRUE;         // bei bNew werden beide angepasst
/*N*/   BOOL bChangeRow = TRUE;
/*N*/
/*N*/   BOOL bNotes = aTableParam.bNotes;
/*N*/   if ( bNew )
/*N*/   {
/*N*/       nStartCol = nStartRow = 0;
/*N*/       if (!pDoc->GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes ))
/*N*/           return FALSE;   // nix
/*N*/   }
/*N*/   else
/*N*/   {
/*N*/       BOOL bFound = TRUE;
/*N*/       bChangeCol = ( nStartCol == 0 && nEndCol == MAXCOL );
/*N*/       bChangeRow = ( nStartRow == 0 && nEndRow == MAXROW );
/*N*/       if ( bChangeCol && bChangeRow )
/*?*/           bFound = pDoc->GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes );
/*N*/
/*N*/       if (!bFound)
/*N*/           return FALSE;   // leer
/*N*/   }
/*N*/
/*N*/   pDoc->ExtendMerge( nStartCol,nStartRow, nEndCol,nEndRow, nPrintTab,
/*N*/                       FALSE, TRUE );      // kein Refresh, incl. Attrs
/*N*/
/*N*/   if ( bChangeCol )
/*N*/   {
/*N*/       OutputDevice* pRefDev = pDoc->GetPrinter();     // auch fuer Preview den Drucker nehmen
/*N*/       pRefDev->SetMapMode( MAP_PIXEL );               // wichtig fuer GetNeededSize
/*N*/
/*N*/       pDoc->ExtendPrintArea( pRefDev,
/*N*/                           nPrintTab, nStartCol, nStartRow, nEndCol, nEndRow );
/*N*/       //  nEndCol wird veraendert
/*N*/   }
/*N*/
/*N*/   if ( nEndCol < MAXCOL && pDoc->HasAttrib(
/*N*/                   nEndCol,nStartRow,nPrintTab, nEndCol,nEndRow,nPrintTab, HASATTR_SHADOW_RIGHT ) )
/*N*/       ++nEndCol;
/*N*/   if ( nEndRow < MAXROW && pDoc->HasAttrib(
/*N*/                   nStartCol,nEndRow,nPrintTab, nEndCol,nEndRow,nPrintTab, HASATTR_SHADOW_DOWN ) )
/*N*/       ++nEndRow;
/*N*/
/*N*/   if (!bChangeCol) nEndCol = nOldEndCol;
/*N*/   if (!bChangeRow) nEndRow = nOldEndRow;
/*N*/
/*N*/   return TRUE;
/*N*/ }

/*N*/ long ScPrintFunc::TextHeight( const EditTextObject* pObject )
/*N*/ {
/*N*/   if (!pObject)
/*N*/       return 0;
/*N*/
/*N*/ //    pEditEngine->SetPageNo( nTotalPages );
/*N*/   pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, FALSE );
/*N*/
/*N*/   return (long) pEditEngine->GetTextHeight();
/*N*/ }

//  nZoom muss gesetzt sein !!!
//  und der entsprechende Twip-MapMode eingestellt

/*N*/ void ScPrintFunc::UpdateHFHeight( ScPrintHFParam& rParam )
/*N*/ {
/*N*/   DBG_ASSERT( aPageSize.Width(), "UpdateHFHeight ohne aPageSize");
/*N*/
/*N*/   if (rParam.bEnable && rParam.bDynamic)
/*N*/   {
/*N*/       //  nHeight aus Inhalten berechnen
/*N*/
/*N*/       MakeEditEngine();
/*N*/       long nPaperWidth = ( aPageSize.Width() - nLeftMargin - nRightMargin -
/*N*/                               rParam.nLeft - rParam.nRight ) * 100 / nZoom;
/*N*/       if (rParam.pBorder)
/*N*/           nPaperWidth -= ( rParam.pBorder->GetDistance(BOX_LINE_LEFT) +
/*N*/                            rParam.pBorder->GetDistance(BOX_LINE_RIGHT) +
/*N*/                            lcl_LineTotal(rParam.pBorder->GetLeft()) +
/*N*/                            lcl_LineTotal(rParam.pBorder->GetRight()) ) * 100 / nZoom;
/*N*/
/*N*/       if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE)
/*N*/           nPaperWidth -= ( rParam.pShadow->CalcShadowSpace(SHADOW_LEFT) +
/*N*/                            rParam.pShadow->CalcShadowSpace(SHADOW_RIGHT) ) * 100L / nZoom;
/*N*/
/*N*/       pEditEngine->SetPaperSize( Size( nPaperWidth, 10000 ) );
/*N*/
/*N*/       long nMaxHeight = 0;
/*N*/       if ( rParam.pLeft )
/*N*/       {
/*N*/           nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pLeft->GetLeftArea() ) );
/*N*/           nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pLeft->GetCenterArea() ) );
/*N*/           nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pLeft->GetRightArea() ) );
/*N*/       }
/*N*/       if ( rParam.pRight )
/*N*/       {
/*N*/           nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pRight->GetLeftArea() ) );
/*N*/           nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pRight->GetCenterArea() ) );
/*N*/           nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pRight->GetRightArea() ) );
/*N*/       }
/*N*/
/*N*/       rParam.nHeight = nMaxHeight + rParam.nDistance;
/*N*/       if (rParam.pBorder)
/*N*/           rParam.nHeight += rParam.pBorder->GetDistance(BOX_LINE_TOP) +
/*N*/                             rParam.pBorder->GetDistance(BOX_LINE_BOTTOM) +
/*N*/                             lcl_LineTotal( rParam.pBorder->GetTop() ) +
/*N*/                             lcl_LineTotal( rParam.pBorder->GetBottom() );
/*N*/       if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE)
/*N*/           rParam.nHeight += rParam.pShadow->CalcShadowSpace(SHADOW_TOP) +
/*N*/                             rParam.pShadow->CalcShadowSpace(SHADOW_BOTTOM);
/*N*/
/*N*/       if (rParam.nHeight < rParam.nManHeight)
/*N*/           rParam.nHeight = rParam.nManHeight;         // eingestelltes Minimum
/*N*/   }
/*N*/ }

/*N*/ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
/*N*/ {
/*N*/   if (!pParamSet)
/*N*/       return;
/*N*/
/*N*/                               // TabPage "Seite"
/*N*/   const SvxLRSpaceItem* pLRItem = (const SvxLRSpaceItem*) &pParamSet->Get( ATTR_LRSPACE );
/*N*/   long nTmp;
/*N*/   nTmp = pLRItem->GetLeft();
/*N*/   nLeftMargin = nTmp < 0 ? 0 : USHORT(nTmp);
/*N*/   nTmp = pLRItem->GetRight();
/*N*/   nRightMargin = nTmp < 0 ? 0 : USHORT(nTmp);
/*N*/   const SvxULSpaceItem* pULItem = (const SvxULSpaceItem*) &pParamSet->Get( ATTR_ULSPACE );
/*N*/   nTopMargin    = pULItem->GetUpper();
/*N*/   nBottomMargin = pULItem->GetLower();
/*N*/
/*N*/   const SvxPageItem* pPageItem = (const SvxPageItem*) &pParamSet->Get( ATTR_PAGE );
/*N*/   nPageUsage          = pPageItem->GetPageUsage();
/*N*/   bLandscape          = pPageItem->IsLandscape();
/*N*/   aFieldData.eNumType = pPageItem->GetNumType();
/*N*/
/*N*/   bCenterHor = ((const SfxBoolItem&) pParamSet->Get(ATTR_PAGE_HORCENTER)).GetValue();
/*N*/   bCenterVer = ((const SfxBoolItem&) pParamSet->Get(ATTR_PAGE_VERCENTER)).GetValue();
/*N*/
/*N*/   aPageSize = ((const SvxSizeItem&) pParamSet->Get(ATTR_PAGE_SIZE)).GetSize();
/*N*/   if ( !aPageSize.Width() || !aPageSize.Height() )
/*N*/   {
/*?*/       OSL_FAIL("PageSize Null ?!?!?");
/*?*/       aPageSize = SvxPaperInfo::GetPaperSize( SVX_PAPER_A4 );
/*N*/   }
/*N*/
/*N*/   pBorderItem     = (const SvxBoxItem*)    &pParamSet->Get(ATTR_BORDER);
/*N*/   pBackgroundItem = (const SvxBrushItem*)  &pParamSet->Get(ATTR_BACKGROUND);
/*N*/   pShadowItem     = (const SvxShadowItem*) &pParamSet->Get(ATTR_SHADOW);
/*N*/
/*N*/                               // TabPage "Kopfzeile"
/*N*/
/*N*/   aHdr.pLeft      = (const ScPageHFItem*) &pParamSet->Get(ATTR_PAGE_HEADERLEFT);      // Inhalt
/*N*/   aHdr.pRight     = (const ScPageHFItem*) &pParamSet->Get(ATTR_PAGE_HEADERRIGHT);
/*N*/
/*N*/   const SvxSetItem* pHeaderSetItem;
/*N*/   const SfxItemSet* pHeaderSet = NULL;
/*N*/   if ( pParamSet->GetItemState( ATTR_PAGE_HEADERSET, FALSE,
/*N*/                           (const SfxPoolItem**)&pHeaderSetItem ) == SFX_ITEM_SET )
/*N*/   {
/*N*/       pHeaderSet = &pHeaderSetItem->GetItemSet();
/*N*/                                                       // Kopfzeile hat unteren Abstand
/*N*/       aHdr.nDistance  = ((const SvxULSpaceItem&) pHeaderSet->Get(ATTR_ULSPACE)).GetLower();
/*N*/   }
/*N*/   lcl_FillHFParam( aHdr, pHeaderSet );
/*N*/
/*N*/                               // TabPage "Fusszeile"
/*N*/
/*N*/   aFtr.pLeft      = (const ScPageHFItem*) &pParamSet->Get(ATTR_PAGE_FOOTERLEFT);      // Inhalt
/*N*/   aFtr.pRight     = (const ScPageHFItem*) &pParamSet->Get(ATTR_PAGE_FOOTERRIGHT);
/*N*/
/*N*/   const SvxSetItem* pFooterSetItem;
/*N*/   const SfxItemSet* pFooterSet = NULL;
/*N*/   if ( pParamSet->GetItemState( ATTR_PAGE_FOOTERSET, FALSE,
/*N*/                           (const SfxPoolItem**)&pFooterSetItem ) == SFX_ITEM_SET )
/*N*/   {
/*N*/       pFooterSet = &pFooterSetItem->GetItemSet();
/*N*/                                                       // Fusszeile hat oberen Abstand
/*N*/       aFtr.nDistance  = ((const SvxULSpaceItem&) pFooterSet->Get(ATTR_ULSPACE)).GetUpper();
/*N*/   }
/*N*/   lcl_FillHFParam( aFtr, pFooterSet );
/*N*/
/*N*/   //------------------------------------------------------
/*N*/   // Table-/Area-Params aus einzelnen Items zusammenbauen:
/*N*/   //------------------------------------------------------
/*N*/   // TabPage "Tabelle"
/*N*/
/*N*/   const SfxUInt16Item* pScaleItem         = NULL;
/*N*/   const SfxUInt16Item* pScaleToPagesItem  = NULL;
/*N*/   SfxItemState         eState;
/*N*/
/*N*/   eState = pParamSet->GetItemState( ATTR_PAGE_SCALE, FALSE,
/*N*/                                     (const SfxPoolItem**)&pScaleItem );
/*N*/   if ( SFX_ITEM_DEFAULT == eState )
/*N*/       pScaleItem = (const SfxUInt16Item*)
/*N*/                    &pParamSet->GetPool()->
/*N*/                       GetDefaultItem( ATTR_PAGE_SCALE );
/*N*/
/*N*/   eState = pParamSet->GetItemState( ATTR_PAGE_SCALETOPAGES, FALSE,
/*N*/                                     (const SfxPoolItem**)&pScaleToPagesItem );
/*N*/   if ( SFX_ITEM_DEFAULT == eState )
/*N*/       pScaleToPagesItem = (const SfxUInt16Item*)
/*N*/                           &pParamSet->GetPool()->
/*N*/                               GetDefaultItem( ATTR_PAGE_SCALETOPAGES );
/*N*/
/*N*/   DBG_ASSERT( pScaleItem && pScaleToPagesItem, "Missing ScaleItem! :-/" );
/*N*/
/*N*/   aTableParam.bNotes          = GET_BOOL(pParamSet,ATTR_PAGE_NOTES);
/*N*/   aTableParam.bGrid           = GET_BOOL(pParamSet,ATTR_PAGE_GRID);
/*N*/   aTableParam.bHeaders        = GET_BOOL(pParamSet,ATTR_PAGE_HEADERS);
/*N*/   aTableParam.bFormulas       = GET_BOOL(pParamSet,ATTR_PAGE_FORMULAS);
/*N*/   aTableParam.bNullVals       = GET_BOOL(pParamSet,ATTR_PAGE_NULLVALS);
/*N*/   aTableParam.bCharts         = GET_SHOW(pParamSet,ATTR_PAGE_CHARTS);
/*N*/   aTableParam.bObjects        = GET_SHOW(pParamSet,ATTR_PAGE_OBJECTS);
/*N*/   aTableParam.bDrawings       = GET_SHOW(pParamSet,ATTR_PAGE_DRAWINGS);
/*N*/   aTableParam.bTopDown        = GET_BOOL(pParamSet,ATTR_PAGE_TOPDOWN);
/*N*/   aTableParam.bLeftRight      = !aTableParam.bLeftRight;
/*N*/   aTableParam.nFirstPageNo    = GET_USHORT(pParamSet,ATTR_PAGE_FIRSTPAGENO);
/*N*/   if (!aTableParam.nFirstPageNo)
/*N*/       aTableParam.nFirstPageNo = (USHORT) nPageStart;     // von vorheriger Tabelle
/*N*/
/*N*/   if ( pScaleItem && pScaleToPagesItem )
/*N*/   {
/*N*/       UINT16  nScaleAll     = pScaleItem->GetValue();
/*N*/       UINT16  nScaleToPages = pScaleToPagesItem->GetValue();
/*N*/
/*N*/       aTableParam.bScaleNone      = (nScaleAll     == 100);
/*N*/       aTableParam.bScaleAll       = (nScaleAll      > 0  );
/*N*/       aTableParam.bScalePageNum   = (nScaleToPages  > 0  );
/*N*/       aTableParam.nScaleAll       = nScaleAll;
/*N*/       aTableParam.nScalePageNum   = nScaleToPages;
/*N*/   }
/*N*/   else
/*N*/   {
/*N*/       aTableParam.bScaleNone      = TRUE;
/*N*/       aTableParam.bScaleAll       = FALSE;
/*N*/       aTableParam.bScalePageNum   = FALSE;
/*N*/       aTableParam.nScaleAll       = 0;
/*N*/       aTableParam.nScalePageNum   = 0;
/*N*/   }
/*N*/
/*N*/   //  skip empty pages only if options with that flag are passed
/*N*/   aTableParam.bSkipEmpty = pOptions && pOptions->GetSkipEmpty();
/*N*/   if ( pPageData )
/*N*/       aTableParam.bSkipEmpty = FALSE;
/*N*/   // Wenn pPageData gesetzt ist, interessieren fuer die Umbruch-Vorschau
/*N*/   // nur die Umbrueche, leere Seiten werden nicht speziell behandelt
/*N*/
/*N*/   //------------------------------------------------------
/*N*/   // TabPage "Bereiche":
/*N*/   //------------------------------------------------------
/*N*/
/*N*/   //! alle PrintAreas der Tabelle durchgehen !!!
/*N*/   const ScRange*  pPrintArea = pDoc->GetPrintRange( nPrintTab, 0 );
/*N*/   const ScRange*  pRepeatCol = pDoc->GetRepeatColRange( nPrintTab );
/*N*/   const ScRange*  pRepeatRow = pDoc->GetRepeatRowRange( nPrintTab );
/*N*/
/*N*/   //  ATTR_PAGE_PRINTTABLES wird ignoriert
/*N*/
/*N*/   if ( pUserArea )                // UserArea (Selektion) hat Vorrang
/*N*/   {
/*?*/       bPrintCurrentTable    =
/*?*/       aAreaParam.bPrintArea = TRUE;                   // Selektion
/*?*/       aAreaParam.aPrintArea = *pUserArea;
/*?*/
/*?*/       //  Die Tabellen-Abfrage ist schon in DocShell::Print, hier immer
/*?*/       aAreaParam.aPrintArea.aStart.SetTab(nPrintTab);
/*?*/       aAreaParam.aPrintArea.aEnd.SetTab(nPrintTab);
/*?*/
/*?*/ //        lcl_LimitRange( aAreaParam.aPrintArea, nPrintTab );         // ganze Zeilen/Spalten...
/*N*/   }
/*N*/   else if ( pDoc->HasPrintRange() )
/*N*/   {
/*N*/       if ( pPrintArea )                               // mindestens eine gesetzt ?
/*N*/       {
/*N*/           bPrintCurrentTable    =
/*N*/           aAreaParam.bPrintArea = TRUE;
/*N*/           aAreaParam.aPrintArea = *pPrintArea;
/*N*/
/*N*/           bMultiArea = ( pDoc->GetPrintRangeCount(nPrintTab) > 1 );
/*N*/       }
/*N*/       else
/*N*/       {
/*N*/           aAreaParam.bPrintArea = TRUE;
/*N*/           bPrintCurrentTable = FALSE;
/*N*/       }
/*N*/   }
/*N*/   else
/*N*/   {
/*N*/       //  #74834# don't print hidden tables if there's no print range defined there
/*N*/       if ( pDoc->IsVisible( nPrintTab ) )
/*N*/       {
/*N*/           aAreaParam.bPrintArea = FALSE;
/*N*/           bPrintCurrentTable = TRUE;
/*N*/       }
/*N*/       else
/*N*/       {
/*N*/           aAreaParam.bPrintArea = TRUE;   // otherwise the table is always counted
/*N*/           bPrintCurrentTable = FALSE;
/*N*/       }
/*N*/   }
/*N*/
/*N*/   if ( pRepeatCol )
/*N*/   {
/*N*/       aAreaParam.bRepeatCol = TRUE;
/*N*/       aAreaParam.aRepeatCol = *pRepeatCol;
/*N*/       nRepeatStartCol = pRepeatCol->aStart.Col();
/*N*/       nRepeatEndCol   = pRepeatCol->aEnd  .Col();
/*N*/   }
/*N*/   else
/*N*/   {
/*N*/       aAreaParam.bRepeatCol = FALSE;
/*N*/       nRepeatStartCol = nRepeatEndCol = REPEAT_NONE;
/*N*/   }
/*N*/
/*N*/   if ( pRepeatRow )
/*N*/   {
/*?*/       aAreaParam.bRepeatRow = TRUE;
/*?*/       aAreaParam.aRepeatRow = *pRepeatRow;
/*?*/       nRepeatStartRow = pRepeatRow->aStart.Row();
/*?*/       nRepeatEndRow   = pRepeatRow->aEnd  .Row();
/*N*/   }
/*N*/   else
/*N*/   {
/*N*/       aAreaParam.bRepeatRow = FALSE;
/*N*/       nRepeatStartRow = nRepeatEndRow = REPEAT_NONE;
/*N*/   }
/*N*/
/*N*/           //
/*N*/           //  Seiten aufteilen
/*N*/           //
/*N*/
/*N*/   if (!bState)
/*N*/   {
/*N*/       nTabPages = CountPages();                                   // berechnet auch Zoom
/*N*/       nTotalPages = nTabPages;
/*N*/       nTotalPages += CountNotePages();
/*N*/   }
/*N*/   else
/*N*/   {
/*?*/       CalcPages();            // nur Umbrueche suchen
/*?*/       CountNotePages();       // Notizen zaehlen, auch wenn Seitenzahl schon bekannt
/*N*/   }
/*N*/
/*N*/   if (nDocPages)
/*N*/       aFieldData.nTotalPages = nDocPages;
/*N*/   else
/*N*/       aFieldData.nTotalPages = nTotalPages;
/*N*/
/*N*/   SetDateTime( Date(), Time() );
/*N*/
/*N*/   aFieldData.aTitle       = pDocShell->GetTitle();
/*N*/   const INetURLObject& rURLObj = pDocShell->GetMedium()->GetURLObject();
/*N*/   aFieldData.aLongDocName = rURLObj.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
/*N*/   if ( aFieldData.aLongDocName.Len() )
/*?*/       aFieldData.aShortDocName = rURLObj.GetName( INetURLObject::DECODE_UNAMBIGUOUS );
/*N*/   else
/*N*/       aFieldData.aShortDocName = aFieldData.aLongDocName = aFieldData.aTitle;
/*N*/
/*N*/ }



/*N*/ void ScPrintFunc::SetDateTime( const Date& rDate, const Time& rTime )
/*N*/ {
/*N*/   aFieldData.aDate = rDate;
/*N*/   aFieldData.aTime = rTime;
/*N*/ }



/*N*/ void ScPrintFunc::MakeEditEngine()
/*N*/ {
/*N*/   if (!pEditEngine)
/*N*/   {
/*N*/       //  can't use document's edit engine pool here,
/*N*/       //  because pool must have twips as default metric
/*N*/       pEditEngine = new ScHeaderEditEngine( EditEngine::CreatePool(), TRUE );
/*N*/
/*N*/       pEditEngine->EnableUndo(FALSE);
/*N*/       pEditEngine->SetRefDevice( pDev );
/*N*/       pEditEngine->SetWordDelimiters(
/*N*/               ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) );
/*N*/       pEditEngine->SetControlWord( pEditEngine->GetControlWord() & ~EE_CNTRL_RTFSTYLESHEETS );
/*N*/       pEditEngine->EnableAutoColor( bUseStyleColor );
/*N*/
/*N*/       //  Default-Set fuer Ausrichtung
/*N*/       pEditDefaults = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
/*N*/
/*N*/       const ScPatternAttr& rPattern = (const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN);
/*N*/       rPattern.FillEditItemSet( pEditDefaults );
/*N*/       //  FillEditItemSet adjusts font height to 1/100th mm,
/*N*/       //  but for header/footer twips is needed, as in the PatternAttr:
/*N*/       pEditDefaults->Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
/*N*/       pEditDefaults->Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
/*N*/       pEditDefaults->Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
/*N*/       //  #69193# dont use font color, because background color is not used
/*N*/       //! there's no way to set the background for note pages
/*N*/       pEditDefaults->ClearItem( EE_CHAR_COLOR );
/*N*/   }
/*N*/
/*N*/   pEditEngine->SetData( aFieldData );     // Seitennummer etc. setzen
/*N*/ }

//
//  UpdatePages wird nur von aussen gerufen, um die Umbrueche fuer die Anzeige
//  richtig zu setzen - immer ohne UserArea
//

/*N*/ BOOL ScPrintFunc::UpdatePages()
/*N*/ {
/*N*/   if (!pParamSet)
/*N*/       return FALSE;
/*N*/
/*N*/   //  Zoom
/*N*/
/*N*/   nZoom = 100;
/*N*/   if (aTableParam.bScalePageNum)
/*N*/       nZoom = ZOOM_MIN;                       // stimmt fuer Umbrueche
/*N*/   else if (aTableParam.bScaleAll)
/*N*/   {
/*N*/       nZoom = aTableParam.nScaleAll;
/*N*/       if ( nZoom <= ZOOM_MIN )
/*N*/           nZoom = ZOOM_MIN;
/*N*/   }
/*N*/
/*N*/   String aName = pDoc->GetPageStyle( nPrintTab );
/*N*/   USHORT nTabCount = pDoc->GetTableCount();
/*N*/   for (USHORT nTab=0; nTab<nTabCount; nTab++)
/*N*/       if ( nTab==nPrintTab || pDoc->GetPageStyle(nTab)==aName )
/*N*/       {
/*N*/           //  Wiederholungszeilen / Spalten
/*N*/           pDoc->SetRepeatArea( nTab, nRepeatStartCol,nRepeatEndCol, nRepeatStartRow,nRepeatEndRow );
/*N*/
/*N*/           //  Umbrueche setzen
/*N*/           ResetBreaks(nTab);
/*N*/           pDocShell->PostPaint(0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID);
/*N*/       }
/*N*/
/*N*/   return TRUE;
/*N*/ }

/*N*/ long ScPrintFunc::CountPages()                            // setzt auch nPagesX, nPagesY
/*N*/ {
/*N*/   BOOL bAreaOk = FALSE;
/*N*/
/*N*/   if (pDoc->HasTable( nPrintTab ))
/*N*/   {
/*N*/       if (aAreaParam.bPrintArea)                          // Druckbereich angegeben?
/*N*/       {
/*N*/           if ( bPrintCurrentTable )
/*N*/           {
/*N*/               ScRange& rRange = aAreaParam.aPrintArea;
/*N*/
/*N*/               //  hier kein Vergleich der Tabellen mehr, die Area gilt immer fuer diese Tabelle
/*N*/               //  wenn hier verglichen werden soll, muss die Tabelle der Druckbereiche beim
/*N*/               //  Einfuegen von Tabellen etc. angepasst werden !
/*N*/
/*N*/               nStartCol = rRange.aStart.Col();
/*N*/               nStartRow = rRange.aStart.Row();
/*N*/               nEndCol   = rRange.aEnd  .Col();
/*N*/               nEndRow   = rRange.aEnd  .Row();
/*N*/               bAreaOk   = AdjustPrintArea(FALSE);         // begrenzen
/*N*/           }
/*N*/           else
/*N*/               bAreaOk = FALSE;
/*N*/       }
/*N*/       else                                                // aus Dokument suchen
/*N*/           bAreaOk = AdjustPrintArea(TRUE);
/*N*/   }
/*N*/
/*N*/   if (bAreaOk)
/*N*/   {
/*N*/       long nPages = 0;
/*N*/       if (bMultiArea)
/*N*/       {
/*?*/           USHORT nRCount = pDoc->GetPrintRangeCount( nPrintTab );
/*?*/           for (USHORT i=0; i<nRCount; i++)
/*?*/           {
/*?*/               CalcZoom(i);
/*?*/               if ( !aTableParam.bSkipEmpty )
/*?*/                   nPages += ((long) nPagesX) * nPagesY;
/*?*/           }
/*N*/       }
/*N*/       else
/*N*/       {
/*N*/           CalcZoom(RANGENO_NORANGE);                      // Zoom berechnen
/*N*/           if ( !aTableParam.bSkipEmpty )
/*N*/               nPages += ((long) nPagesX) * nPagesY;
/*N*/       }
/*N*/       return nPages;
/*N*/   }
/*N*/   else
/*N*/   {
/*N*/       nPagesX = nPagesY = nTotalY = 0;
/*N*/       return 0;
/*N*/   }
/*N*/ }

/*N*/ long ScPrintFunc::CountNotePages()
/*N*/ {
/*N*/   if ( !aTableParam.bNotes || !bPrintCurrentTable )
/*N*/       return 0;
/*N*/
/*?*/   long nCount=0;
/*?*/   USHORT nCol;
/*?*/   USHORT nRow;
/*?*/
/*?*/   BOOL bError = FALSE;
/*?*/   if (!aAreaParam.bPrintArea)
/*?*/       bError = !AdjustPrintArea(TRUE);            // komplett aus Dok suchen
/*?*/
/*?*/   USHORT nRepeats = 1;                            // wie oft durchgehen ?
/*?*/   if (bMultiArea)
/*?*/       nRepeats = pDoc->GetPrintRangeCount(nPrintTab);
/*?*/   if (bError)
/*?*/       nRepeats = 0;
/*?*/
/*?*/   for (USHORT nStep=0; nStep<nRepeats; nStep++)
/*?*/   {
/*?*/       BOOL bDoThis = TRUE;
/*?*/       if (bMultiArea)             // alle Areas durchgehen
/*?*/       {
/*?*/           const ScRange* pThisRange = pDoc->GetPrintRange( nPrintTab, nStep );
/*?*/           if ( pThisRange )
/*?*/           {
/*?*/               nStartCol = pThisRange->aStart.Col();
/*?*/               nStartRow = pThisRange->aStart.Row();
/*?*/               nEndCol   = pThisRange->aEnd  .Col();
/*?*/               nEndRow   = pThisRange->aEnd  .Row();
/*?*/               bDoThis = AdjustPrintArea(FALSE);
/*?*/           }
/*?*/       }
/*?*/
/*?*/       if (bDoThis)
/*?*/       {
/*?*/           ScHorizontalCellIterator aIter( pDoc, nPrintTab, nStartCol,nStartRow, nEndCol,nEndRow );
/*?*/           ScBaseCell* pCell = aIter.GetNext( nCol, nRow );
/*?*/           while (pCell)
/*?*/           {
/*?*/               if (pCell->GetNotePtr())
/*?*/               {
/*?*/                   aNotePosList.Insert( new ScTripel( nCol,nRow,nPrintTab ), LIST_APPEND );
/*?*/                   ++nCount;
/*?*/               }
/*?*/
/*?*/               pCell = aIter.GetNext( nCol, nRow );
/*?*/           }
/*?*/       }
/*?*/   }
/*?*/
/*?*/   long nPages = 0;
/*?*/   return nPages;
/*N*/ }

/*N*/ void ScPrintFunc::InitModes()             // aus nZoom etc. die MapModes setzen
/*N*/ {
/*N*/   aOffset = Point( aSrcOffset.X()*100/nZoom, aSrcOffset.Y()*100/nZoom );
/*N*/
/*N*/   long nEffZoom = nZoom * (long) nManualZoom;
/*N*/
/*N*/ //    nScaleX = nScaleY = 1.0;            // Ausgabe in Twips
/*N*/   nScaleX = nScaleY = HMM_PER_TWIPS;  // Ausgabe in 1/100 mm
/*N*/
/*N*/   Fraction aZoomFract( nEffZoom,10000 );
/*N*/   Fraction aHorFract = aZoomFract;
/*N*/
/*N*/   if ( !pPrinter && !bIsRender )                          // adjust scale for preview
/*N*/   {
/*?*/       double nFact = pDocShell->GetOutputFactor();
/*?*/       aHorFract = Fraction( (long)( nEffZoom / nFact ), 10000 );
/*N*/   }
/*N*/
/*N*/   aLogicMode = MapMode( MAP_100TH_MM, Point(), aHorFract, aZoomFract );
/*N*/
/*N*/   Point aLogicOfs( -aOffset.X(), -aOffset.Y() );
/*N*/   aOffsetMode = MapMode( MAP_100TH_MM, aLogicOfs, aHorFract, aZoomFract );
/*N*/
/*N*/   Point aTwipsOfs( (long) ( -aOffset.X() / nScaleX + 0.5 ), (long) ( -aOffset.Y() / nScaleY + 0.5 ) );
/*N*/   aTwipMode = MapMode( MAP_TWIP, aTwipsOfs, aHorFract, aZoomFract );
/*N*/ }

/*N*/ void ScPrintFunc::CalcZoom( USHORT nRangeNo )                     // Zoom berechnen
/*N*/ {
/*N*/   USHORT nRCount = pDoc->GetPrintRangeCount( nPrintTab );
/*N*/   const ScRange* pThisRange = NULL;
/*N*/   if ( nRangeNo != RANGENO_NORANGE || nRangeNo < nRCount )
/*?*/       pThisRange = pDoc->GetPrintRange( nPrintTab, nRangeNo );
/*N*/   if ( pThisRange )
/*N*/   {
/*?*/       nStartCol = pThisRange->aStart.Col();
/*?*/       nStartRow = pThisRange->aStart.Row();
/*?*/       nEndCol   = pThisRange->aEnd  .Col();
/*?*/       nEndRow   = pThisRange->aEnd  .Row();
/*N*/   }
/*N*/
/*N*/   if (!AdjustPrintArea(FALSE))                        // leer
/*N*/   {
/*N*/       nZoom = 100;
/*N*/       nPagesX = nPagesY = nTotalY = 0;
/*N*/       return;
/*N*/   }
/*N*/
/*N*/   pDoc->SetRepeatArea( nPrintTab, nRepeatStartCol,nRepeatEndCol, nRepeatStartRow,nRepeatEndRow );
/*N*/
/*N*/   if (aTableParam.bScalePageNum)
/*N*/   {
/*N*/       nZoom = 100;
/*N*/       BOOL bFound = FALSE;
/*N*/       USHORT nPagesToFit = aTableParam.nScalePageNum;
/*N*/       while (!bFound)
/*N*/       {
/*N*/           CalcPages();
/*N*/           if ( nPagesX * nPagesY <= nPagesToFit || nZoom <= ZOOM_MIN )
/*N*/               bFound = TRUE;
/*N*/           else
/*N*/               --nZoom;
/*N*/       }
/*N*/   }
/*N*/   else if (aTableParam.bScaleAll)
/*N*/   {
/*N*/       nZoom = aTableParam.nScaleAll;
/*N*/       if ( nZoom <= ZOOM_MIN )
/*N*/           nZoom = ZOOM_MIN;
/*N*/       CalcPages();
/*N*/   }
/*N*/   else
/*N*/   {
/*N*/       DBG_ASSERT( aTableParam.bScaleNone, "kein Scale-Flag gesetzt" );
/*N*/       nZoom = 100;
/*N*/       CalcPages();
/*N*/   }
/*N*/ }

/*N*/ Size ScPrintFunc::GetDocPageSize()
/*N*/ {
/*N*/                       // Hoehe Kopf-/Fusszeile anpassen
/*N*/
/*N*/   InitModes();                            // aTwipMode aus nZoom initialisieren
/*N*/   pDev->SetMapMode( aTwipMode );          // Kopf-/Fusszeilen in Twips
/*N*/   UpdateHFHeight( aHdr );
/*N*/   UpdateHFHeight( aFtr );
/*N*/
/*N*/                       // Seitengroesse in Document-Twips
/*N*/                       //  Berechnung Left / Right auch in PrintPage
/*N*/
/*N*/   aPageRect = Rectangle( Point(), aPageSize );
/*N*/   aPageRect.Left()   = ( aPageRect.Left()   + nLeftMargin                  ) * 100 / nZoom;
/*N*/   aPageRect.Right()  = ( aPageRect.Right()  - nRightMargin                 ) * 100 / nZoom;
/*N*/   aPageRect.Top()    = ( aPageRect.Top()    + nTopMargin    ) * 100 / nZoom + aHdr.nHeight;
/*N*/   aPageRect.Bottom() = ( aPageRect.Bottom() - nBottomMargin ) * 100 / nZoom - aFtr.nHeight;
/*N*/
/*N*/   Size aDocPageSize = aPageRect.GetSize();
/*N*/   if (aTableParam.bHeaders)
/*N*/   {
/*N*/       aDocPageSize.Width()  -= (long) PRINT_HEADER_WIDTH;
/*N*/       aDocPageSize.Height() -= (long) PRINT_HEADER_HEIGHT;
/*N*/   }
/*N*/   if (pBorderItem)
/*N*/   {
/*N*/       aDocPageSize.Width()  -= lcl_LineTotal(pBorderItem->GetLeft()) +
/*N*/                                lcl_LineTotal(pBorderItem->GetRight()) +
/*N*/                                pBorderItem->GetDistance(BOX_LINE_LEFT) +
/*N*/                                pBorderItem->GetDistance(BOX_LINE_RIGHT);
/*N*/       aDocPageSize.Height() -= lcl_LineTotal(pBorderItem->GetTop()) +
/*N*/                                lcl_LineTotal(pBorderItem->GetBottom()) +
/*N*/                                pBorderItem->GetDistance(BOX_LINE_TOP) +
/*N*/                                pBorderItem->GetDistance(BOX_LINE_BOTTOM);
/*N*/   }
/*N*/   if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
/*N*/   {
/*?*/       aDocPageSize.Width()  -= pShadowItem->CalcShadowSpace(SHADOW_LEFT) +
/*?*/                                pShadowItem->CalcShadowSpace(SHADOW_RIGHT);
/*?*/       aDocPageSize.Height() -= pShadowItem->CalcShadowSpace(SHADOW_TOP) +
/*?*/                                pShadowItem->CalcShadowSpace(SHADOW_BOTTOM);
/*N*/   }
/*N*/   return aDocPageSize;
/*N*/ }

/*N*/ void ScPrintFunc::ResetBreaks( USHORT nTab )          // Breaks fuer Anzeige richtig setzen
/*N*/ {
/*N*/   pDoc->SetPageSize( nTab, GetDocPageSize() );
/*N*/   pDoc->UpdatePageBreaks( nTab, NULL );
/*N*/ }


/*N*/ void ScPrintFunc::CalcPages()             // berechnet aPageRect und Seiten aus nZoom
/*N*/ {
/*N*/   if (!pPageEndX) pPageEndX = new USHORT[MAXCOL+1];
/*N*/   if (!pPageEndY) pPageEndY = new USHORT[MAXROW+1];
/*N*/   if (!pPageRows) pPageRows = new ScPageRowEntry[MAXROW+1];   //! vorher zaehlen !!!!
/*N*/
/*N*/   pDoc->SetPageSize( nPrintTab, GetDocPageSize() );
/*N*/   if (aAreaParam.bPrintArea)
/*N*/   {
/*N*/       ScRange aRange( nStartCol, nStartRow, nPrintTab, nEndCol, nEndRow, nPrintTab );
/*N*/       pDoc->UpdatePageBreaks( nPrintTab, &aRange );
/*N*/   }
/*N*/   else
/*N*/       pDoc->UpdatePageBreaks( nPrintTab, NULL );      // sonst wird das Ende markiert
/*N*/
/*N*/   //
/*N*/   //  Seiteneinteilung nach Umbruechen in Col/RowFlags
/*N*/   //  Von mehreren Umbruechen in einem ausgeblendeten Bereich zaehlt nur einer.
/*N*/   //
/*N*/
/*N*/   USHORT i;
/*N*/   nPagesX = 0;
/*N*/   nPagesY = 0;
/*N*/   nTotalY = 0;
/*N*/
/*N*/   BOOL bVisCol = FALSE;
/*N*/   for (i=nStartCol; i<=nEndCol; i++)
/*N*/   {
/*N*/       BYTE nFlags = pDoc->GetColFlags(i,nPrintTab);
/*N*/       if ( i>nStartCol && bVisCol && (nFlags & CR_PAGEBREAK) )
/*N*/       {
/*N*/           pPageEndX[nPagesX] = i-1;
/*N*/           ++nPagesX;
/*N*/           bVisCol = FALSE;
/*N*/       }
/*N*/       if (!(nFlags & CR_HIDDEN))
/*N*/           bVisCol = TRUE;
/*N*/   }
/*N*/   if (bVisCol)    // auch am Ende keine leeren Seiten
/*N*/   {
/*N*/       pPageEndX[nPagesX] = nEndCol;
/*N*/       ++nPagesX;
/*N*/   }
/*N*/
/*N*/   BOOL bVisRow = FALSE;
/*N*/   USHORT nPageStartRow = nStartRow;
/*N*/   for (i=nStartRow; i<=nEndRow; i++)
/*N*/   {
/*N*/       BYTE nFlags = pDoc->GetRowFlags(i,nPrintTab);
/*N*/       if ( i>nStartRow && bVisRow && (nFlags & CR_PAGEBREAK) )
/*N*/       {
/*N*/           pPageEndY[nTotalY] = i-1;
/*N*/           ++nTotalY;
/*N*/
/*N*/           if ( !aTableParam.bSkipEmpty )
/*N*/           {
/*N*/               pPageRows[nPagesY].SetStartRow( nPageStartRow );
/*N*/               pPageRows[nPagesY].SetEndRow( i-1 );
/*N*/               pPageRows[nPagesY].SetPagesX( nPagesX );
/*N*/               ++nPagesY;
/*N*/           }
/*N*/
/*N*/           nPageStartRow = i;
/*N*/           bVisRow = FALSE;
/*N*/       }
/*N*/       if (!(nFlags & CR_HIDDEN))
/*N*/           bVisRow = TRUE;
/*N*/   }
/*N*/   if (bVisRow)
/*N*/   {
/*N*/       pPageEndY[nTotalY] = nEndRow;
/*N*/       ++nTotalY;
/*N*/
/*N*/       if ( !aTableParam.bSkipEmpty )
/*N*/       {
/*N*/           pPageRows[nPagesY].SetStartRow( nPageStartRow );
/*N*/           pPageRows[nPagesY].SetEndRow( nEndRow );
/*N*/           pPageRows[nPagesY].SetPagesX( nPagesX );
/*N*/           ++nPagesY;
/*N*/       }
/*N*/   }
/*N*/ }

}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */