1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pview.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #include <sfx2/objface.hxx>
37 #include <vcl/timer.hxx>
38 #include <vcl/field.hxx>
39 #include <vcl/fixed.hxx>
40 #include <vcl/help.hxx>
41 #include <vcl/cmdevt.hxx>
42 #ifndef _SV_BUTTON_HXX //autogen
43 #include <vcl/button.hxx>
45 #include <svtools/printdlg.hxx>
46 #include <svtools/whiter.hxx>
47 #include <svtools/stritem.hxx>
48 #include <svtools/eitem.hxx>
49 #include <sfx2/printer.hxx>
50 #include <sfx2/app.hxx>
51 #include <sfx2/topfrm.hxx>
52 #include <sfx2/bindings.hxx>
53 #include <sfx2/request.hxx>
54 #include <sfx2/dispatch.hxx>
55 #include <vcl/msgbox.hxx>
56 #include <svx/stddlg.hxx>
57 #include <svx/paperinf.hxx>
58 #include <svx/srchitem.hxx>
59 #include <svx/svdview.hxx>
60 #include <svx/dlgutil.hxx>
61 #include <svx/zoomslideritem.hxx>
62 #ifndef _SVX_SVXIDS_HRC //autogen
63 #include <svx/svxids.hrc>
68 #include <globdoc.hxx>
70 #include <pvprtdat.hxx>
71 #include <swmodule.hxx>
77 #include <viewopt.hxx>
89 #include <swprtopt.hxx>
90 #include <docstat.hxx>
91 #include <usrpref.hxx>
92 #include <viewfunc.hxx>
102 #include <globals.hrc>
111 #define SwPagePreView
113 #include <itemdef.hxx>
116 #include <swslots.hxx>
118 // OD 12.12.2002 #103492#
119 #include <pagepreviewlayout.hxx>
121 #include <svx/svxdlg.hxx>
122 #include <svx/dialogs.hrc>
123 #include <vos/mutex.hxx>
125 using namespace ::com::sun::star
;
128 SFX_IMPL_VIEWFACTORY(SwPagePreView
, SW_RES(STR_NONAME
))
130 SFX_VIEW_REGISTRATION(SwDocShell
);
131 SFX_VIEW_REGISTRATION(SwWebDocShell
);
132 SFX_VIEW_REGISTRATION(SwGlobalDocShell
);
135 SFX_IMPL_INTERFACE(SwPagePreView
, SfxViewShell
, SW_RES(RID_PVIEW_TOOLBOX
))
137 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_PPREVIEW_POPUPMENU
));
138 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT
|SFX_VISIBILITY_STANDARD
|
139 SFX_VISIBILITY_CLIENT
|SFX_VISIBILITY_FULLSCREEN
|
140 SFX_VISIBILITY_READONLYDOC
,
141 SW_RES(RID_PVIEW_TOOLBOX
));
145 TYPEINIT1(SwPagePreView
,SfxViewShell
)
147 #define SWVIEWFLAGS ( SFX_VIEW_MAXIMIZE_FIRST|SFX_VIEW_OPTIMIZE_EACH| \
148 SFX_VIEW_CAN_PRINT|SFX_VIEW_HAS_PRINTOPTIONS )
150 #define MIN_PREVIEW_ZOOM 25
151 #define MAX_PREVIEW_ZOOM 600
153 /* -----------------26.11.2002 10:41-----------------
155 * --------------------------------------------------*/
156 USHORT
lcl_GetNextZoomStep(USHORT nCurrentZoom
, BOOL bZoomIn
)
158 static USHORT aZoomArr
[] =
160 25, 50, 75, 100, 150, 200, 400, 600
162 const sal_uInt16 nZoomArrSize
= sizeof(aZoomArr
)/sizeof(USHORT
);
164 for(int i
= nZoomArrSize
- 1; i
>= 0; --i
)
166 if(nCurrentZoom
> aZoomArr
[i
] || !i
)
170 for(int i
= 0; i
< nZoomArrSize
; ++i
)
172 if(nCurrentZoom
< aZoomArr
[i
])
175 return bZoomIn
? MAX_PREVIEW_ZOOM
: MIN_PREVIEW_ZOOM
;
177 /* -----------------02.12.2002 09:11-----------------
179 * --------------------------------------------------*/
180 void lcl_InvalidateZoomSlots(SfxBindings
& rBindings
)
182 static USHORT __READONLY_DATA aInval
[] =
184 SID_ATTR_ZOOM
, SID_ZOOM_OUT
, SID_ZOOM_IN
, SID_ATTR_ZOOMSLIDER
, FN_PREVIEW_ZOOM
, FN_STAT_ZOOM
,
187 rBindings
.Invalidate( aInval
);
189 /*--------------------------------------------------------------------
191 --------------------------------------------------------------------*/
193 // erstmal der Zoom-Dialog
195 class SwPreViewZoomDlg
: public SvxStandardDialog
198 NumericField aRowEdit
;
200 NumericField aColEdit
;
203 CancelButton aCancelBtn
;
206 virtual void Apply();
209 SwPreViewZoomDlg( SwPagePreViewWin
& rParent
);
213 /*--------------------------------------------------------------------
215 --------------------------------------------------------------------*/
218 SwPreViewZoomDlg::SwPreViewZoomDlg( SwPagePreViewWin
& rParent
) :
219 SvxStandardDialog( &rParent
, SW_RES(DLG_PAGEPREVIEW_ZOOM
) ),
220 aRowLbl(this,SW_RES(FT_ROW
)),
221 aRowEdit(this,SW_RES(ED_ROW
)),
222 aColLbl(this,SW_RES(FT_COL
)),
223 aColEdit(this,SW_RES(ED_COL
)),
224 aOkBtn(this,SW_RES(BT_OK
)),
225 aCancelBtn(this,SW_RES(BT_CANCEL
)),
226 aHelpBtn(this,SW_RES(BT_HELP
))
230 aRowEdit
.SetValue( rParent
.GetRow() );
231 aColEdit
.SetValue( rParent
.GetCol() );
234 /*--------------------------------------------------------------------
236 --------------------------------------------------------------------*/
239 SwPreViewZoomDlg::~SwPreViewZoomDlg() {}
242 void SwPreViewZoomDlg::Apply()
244 ((SwPagePreViewWin
*)GetParent())->CalcWish(
245 BYTE(aRowEdit
.GetValue()),
246 BYTE(aColEdit
.GetValue()) );
250 /* -----------------20.08.98 15:25-------------------
251 * Vorschau fuer den Seitendruck
252 * --------------------------------------------------*/
253 struct PrintSettingsStruct
;
254 class PrtPrvWindow
: public Window
256 const PrintSettingsStruct
& rSettings
;
258 virtual void Paint(const Rectangle
&);
260 PrtPrvWindow(Window
* pParent
, const ResId
& rResId
, const PrintSettingsStruct
& rSett
) :
261 Window(pParent
, rResId
), rSettings(rSett
){}
263 /*--------------------------------------------------------------------
264 Beschreibung: Optionen fuer das Drucken der Preview
265 --------------------------------------------------------------------*/
266 struct PrintSettingsStruct
268 Size aPageMaxSize
; // groesste Seite
269 Size aPrtSize
; // Papiergroesse
270 Size aPrvPrtSize
; // Groesse innerhalb der LRTB-Raender
271 Size aGridSize
; // Groesse fuer jede Seite, enthaelt je
272 // die Haelfte von H- und V-Distance
284 BOOL bPrinterLandscape
; // Ausrichtung
287 class SwPreviewPrintOptionsDialog
: public SvxStandardDialog
291 NumericField aRowsNF
;
293 NumericField aColsNF
;
297 MetricField aLSpaceMF
;
299 MetricField aRSpaceMF
;
301 MetricField aTSpaceMF
;
303 MetricField aBSpaceMF
;
304 FixedLine aDistanceFL
;
306 MetricField aHSpaceMF
;
308 MetricField aVSpaceMF
;
310 RadioButton aLandscapeRB
;
311 RadioButton aPortraitRB
;
312 FixedLine aOrientationFL
;
314 PrtPrvWindow aPreviewWin
;
317 CancelButton aCancelBtn
;
320 PushButton aStandardPB
;
322 SwPagePreView
& rPreView
;
323 SwPagePreViewWin
& rParentWin
;
324 PrintSettingsStruct aSettings
;
325 /* Size aPageMaxSize;
332 virtual void Apply();
333 void FillControls(SwPagePreViewPrtData
& rData
);
335 DECL_LINK( ModifyHdl
, Edit
* );
336 DECL_LINK( StandardHdl
, PushButton
* );
339 SwPreviewPrintOptionsDialog(SwPagePreViewWin
& rParent
, SwPagePreView
& rView
);
340 ~SwPreviewPrintOptionsDialog();
343 /* -----------------19.08.98 13:35-------------------
345 * --------------------------------------------------*/
346 SwPreviewPrintOptionsDialog::SwPreviewPrintOptionsDialog( SwPagePreViewWin
& rParent
, SwPagePreView
& rView
) :
347 SvxStandardDialog( &rParent
, SW_RES(DLG_PAGEPREVIEW_PRINTOPTIONS
) ),
348 aRowColFL(this,SW_RES( FL_ROWCOL
)),
349 aRowsFT(this,SW_RES( FT_ROWS
)),
350 aRowsNF(this,SW_RES( NF_ROWS
)),
351 aColsFT(this,SW_RES( FT_COLS
)),
352 aColsNF(this,SW_RES( NF_COLS
)),
353 aMarginFL(this,SW_RES( FL_MARGINS
)),
354 aLSpaceFT(this,SW_RES( FT_LMARGIN
)),
355 aLSpaceMF(this,SW_RES( MF_LMARGIN
)),
356 aRSpaceFT(this,SW_RES( FT_RMARGIN
)),
357 aRSpaceMF(this,SW_RES( MF_RMARGIN
)),
358 aTSpaceFT(this,SW_RES( FT_TMARGIN
)),
359 aTSpaceMF(this,SW_RES( MF_TMARGIN
)),
360 aBSpaceFT(this,SW_RES( FT_BMARGIN
)),
361 aBSpaceMF(this,SW_RES( MF_BMARGIN
)),
362 aDistanceFL(this,SW_RES(FL_DISTANCE
)),
363 aHSpaceFT(this,SW_RES( FT_HMARGIN
)),
364 aHSpaceMF(this,SW_RES( MF_HMARGIN
)),
365 aVSpaceFT(this,SW_RES( FT_VMARGIN
)),
366 aVSpaceMF(this,SW_RES( MF_VMARGIN
)),
367 aLandscapeRB(this,SW_RES( RB_LANDSCAPE
)),
368 aPortraitRB(this,SW_RES( RB_PORTRAIT
)),
369 aOrientationFL(this,SW_RES( FL_ORIENTATION
)),
370 aPreviewWin(this,SW_RES( WIN_PREVIEW
), aSettings
),
371 aOkBtn(this,SW_RES(BT_OK
)),
372 aCancelBtn(this,SW_RES(BT_CANCEL
)),
373 aHelpBtn(this,SW_RES(BT_HELP
)),
374 aStandardPB(this,SW_RES(PB_STANDARD
)),
380 ViewShell
& rViewSh
= *rPreView
.GetViewShell();
381 // OD 18.12.2002 #103492#
382 aSettings
.aPageMaxSize
= rViewSh
.PagePreviewLayout()->GetMaxPageSize();
383 SfxPrinter
* pPrinter
= rViewSh
.getIDocumentDeviceAccess()->getPrinter( true );
384 aSettings
.aPrtSize
= pPrinter
->GetPaperSize();
385 //#97682# make sure that no division by zero occurs
386 if(!aSettings
.aPrtSize
.Width() || !aSettings
.aPrtSize
.Height())
387 aSettings
.aPrtSize
= Size(lA4Width
, lA4Height
);
388 aSettings
.bPrinterLandscape
= pPrinter
->GetOrientation() == ORIENTATION_LANDSCAPE
;
391 SwDocShell
* pDocShell
= rPreView
.GetDocShell();
392 const SwMasterUsrPref
*pUsrPref
= SW_MOD()->GetUsrPref(0 != PTR_CAST(SwWebDocShell
, pDocShell
));
393 FieldUnit eFieldUnit
= pUsrPref
->GetMetric();
394 ::SetFieldUnit( aLSpaceMF
, eFieldUnit
);
395 ::SetFieldUnit( aRSpaceMF
, eFieldUnit
);
396 ::SetFieldUnit( aTSpaceMF
, eFieldUnit
);
397 ::SetFieldUnit( aBSpaceMF
, eFieldUnit
);
398 ::SetFieldUnit( aHSpaceMF
, eFieldUnit
);
399 ::SetFieldUnit( aVSpaceMF
, eFieldUnit
);
401 SwDoc
* pDoc
= pDocShell
->GetDoc();
402 SwPagePreViewPrtData aData
;
403 if(pDoc
->GetPreViewPrtData())
405 aData
= *pDoc
->GetPreViewPrtData();
410 // Orientation der PreviewData an den Drucker anpassen
411 aData
.SetLandscape(aSettings
.bPrinterLandscape
);
412 aData
.SetRow(rParent
.GetRow());
413 aData
.SetCol(rParent
.GetCol());
417 aLSpaceMF
.SaveValue();
418 aRSpaceMF
.SaveValue();
419 aTSpaceMF
.SaveValue();
420 aBSpaceMF
.SaveValue();
421 aHSpaceMF
.SaveValue();
422 aVSpaceMF
.SaveValue();
425 aLandscapeRB
.SaveValue();
426 aPortraitRB
.SaveValue();
428 aStandardPB
.SetClickHdl(LINK(this, SwPreviewPrintOptionsDialog
, StandardHdl
));
429 Link aLk
= LINK(this, SwPreviewPrintOptionsDialog
, ModifyHdl
);
430 aLSpaceMF
.SetUpHdl(aLk
);
431 aRSpaceMF
.SetUpHdl(aLk
);
432 aTSpaceMF
.SetUpHdl(aLk
);
433 aBSpaceMF
.SetUpHdl(aLk
);
434 aHSpaceMF
.SetUpHdl(aLk
);
435 aVSpaceMF
.SetUpHdl(aLk
);
436 aRowsNF
.SetUpHdl(aLk
);
437 aColsNF
.SetUpHdl(aLk
);
438 aLSpaceMF
.SetDownHdl(aLk
);
439 aRSpaceMF
.SetDownHdl(aLk
);
440 aTSpaceMF
.SetDownHdl(aLk
);
441 aBSpaceMF
.SetDownHdl(aLk
);
442 aHSpaceMF
.SetDownHdl(aLk
);
443 aVSpaceMF
.SetDownHdl(aLk
);
444 aRowsNF
.SetDownHdl(aLk
);
445 aColsNF
.SetDownHdl(aLk
);
446 aLSpaceMF
.SetLoseFocusHdl(aLk
);
447 aRSpaceMF
.SetLoseFocusHdl(aLk
);
448 aTSpaceMF
.SetLoseFocusHdl(aLk
);
449 aBSpaceMF
.SetLoseFocusHdl(aLk
);
450 aHSpaceMF
.SetLoseFocusHdl(aLk
);
451 aVSpaceMF
.SetLoseFocusHdl(aLk
);
452 aRowsNF
.SetLoseFocusHdl(aLk
);
453 aColsNF
.SetLoseFocusHdl(aLk
);
454 aLandscapeRB
.SetClickHdl(aLk
);
455 aPortraitRB
.SetClickHdl(aLk
);
459 StandardHdl(&aStandardPB
);
463 /* -----------------19.08.98 13:36-------------------
465 * --------------------------------------------------*/
466 SwPreviewPrintOptionsDialog::~SwPreviewPrintOptionsDialog()
469 /* -----------------12.11.98 11:32-------------------
471 * --------------------------------------------------*/
472 void SwPreviewPrintOptionsDialog::FillControls(SwPagePreViewPrtData
& rData
)
474 aLSpaceMF
.SetValue(aLSpaceMF
.Normalize(rData
.GetLeftSpace() ), FUNIT_TWIP
);
475 aRSpaceMF
.SetValue(aRSpaceMF
.Normalize(rData
.GetRightSpace() ), FUNIT_TWIP
);
476 aTSpaceMF
.SetValue(aTSpaceMF
.Normalize(rData
.GetTopSpace() ), FUNIT_TWIP
);
477 aBSpaceMF
.SetValue(aBSpaceMF
.Normalize(rData
.GetBottomSpace()), FUNIT_TWIP
);
478 aHSpaceMF
.SetValue(aHSpaceMF
.Normalize(rData
.GetHorzSpace() ), FUNIT_TWIP
);
479 aVSpaceMF
.SetValue(aVSpaceMF
.Normalize(rData
.GetVertSpace() ), FUNIT_TWIP
);
480 aRowsNF
.SetValue(rData
.GetRow());
481 aColsNF
.SetValue(rData
.GetCol());
482 aSettings
.bPrinterLandscape
? aLandscapeRB
.Check() : aPortraitRB
.Check();
483 // wenn Drucker und Einstellungen nicht uebereinstimmen, dann Seiten tauschen
484 if( rData
.GetLandscape() != aSettings
.bPrinterLandscape
)
486 Size
aTmp(aSettings
.aPrtSize
.Height(), aSettings
.aPrtSize
.Width());
487 aSettings
.aPrtSize
= aTmp
;
488 aSettings
.bPrinterLandscape
= !aSettings
.bPrinterLandscape
;
489 // nochmal setzen, denn auch wenn nur die Default-Orientierung dem Drucker
490 // angepasst wurde, sollen die Einstellungen gespeichert werden
491 aSettings
.bPrinterLandscape
? aLandscapeRB
.Check() : aPortraitRB
.Check();
493 aLandscapeRB
.SaveValue();
494 aPortraitRB
.SaveValue();
496 aSettings
.nLeft
= rData
.GetLeftSpace() ;
497 aSettings
.nRight
= rData
.GetRightSpace() ;
498 aSettings
.nTop
= rData
.GetTopSpace() ;
499 aSettings
.nBottom
= rData
.GetBottomSpace();
500 aSettings
.nHori
= rData
.GetHorzSpace() ;
501 aSettings
.nVert
= rData
.GetVertSpace() ;
502 aSettings
.nRows
= rData
.GetRow() ;
503 aSettings
.nCols
= rData
.GetCol() ;
504 aSettings
.aPrvPrtSize
= aSettings
.aPrtSize
;
507 /* -----------------19.08.98 14:31-------------------
509 * --------------------------------------------------*/
510 void SwPreviewPrintOptionsDialog::Apply()
513 SwDoc
* pDoc
= rPreView
.GetDocShell()->GetDoc();
515 pDoc
->SetPreViewPrtData(0);
516 else if( aLSpaceMF
.GetSavedValue() != aLSpaceMF
.GetText() ||
517 aRSpaceMF
.GetSavedValue() != aRSpaceMF
.GetText() ||
518 aTSpaceMF
.GetSavedValue() != aTSpaceMF
.GetText() ||
519 aBSpaceMF
.GetSavedValue() != aBSpaceMF
.GetText() ||
520 aHSpaceMF
.GetSavedValue() != aHSpaceMF
.GetText() ||
521 aVSpaceMF
.GetSavedValue() != aVSpaceMF
.GetText() ||
522 aRowsNF
.GetSavedValue() != aRowsNF
.GetText() ||
523 aColsNF
.GetSavedValue() != aColsNF
.GetText() ||
524 aLandscapeRB
.GetSavedValue() != aLandscapeRB
.IsChecked() ||
525 aPortraitRB
.GetSavedValue() != aPortraitRB
.IsChecked() )
527 SwPagePreViewPrtData aData
;
528 if(pDoc
->GetPreViewPrtData())
529 aData
= *pDoc
->GetPreViewPrtData();
530 aData
.SetLeftSpace( static_cast< ULONG
>(aLSpaceMF
.Denormalize(aLSpaceMF
.GetValue(FUNIT_TWIP
))) );
531 aData
.SetRightSpace( static_cast< ULONG
>(aRSpaceMF
.Denormalize(aRSpaceMF
.GetValue(FUNIT_TWIP
))) );
532 aData
.SetTopSpace( static_cast< ULONG
>(aTSpaceMF
.Denormalize(aTSpaceMF
.GetValue(FUNIT_TWIP
))) );
533 aData
.SetBottomSpace( static_cast< ULONG
>(aBSpaceMF
.Denormalize(aBSpaceMF
.GetValue(FUNIT_TWIP
))) );
535 aData
.SetHorzSpace( static_cast< ULONG
>(aHSpaceMF
.Denormalize(aHSpaceMF
.GetValue(FUNIT_TWIP
))) );
536 aData
.SetVertSpace( static_cast< ULONG
>(aVSpaceMF
.Denormalize(aVSpaceMF
.GetValue(FUNIT_TWIP
))) );
537 aData
.SetRow((BYTE
)aRowsNF
.GetValue());
538 aData
.SetCol((BYTE
)aColsNF
.GetValue());
539 aData
.SetLandscape(aLandscapeRB
.IsChecked());
541 ViewShell
& rViewSh
= *rPreView
.GetViewShell();
542 SfxPrinter
* pPrinter
= rViewSh
.getIDocumentDeviceAccess()->getPrinter( true );
543 if((pPrinter
->GetOrientation() == ORIENTATION_LANDSCAPE
)
544 != aData
.GetLandscape())
545 pPrinter
->SetOrientation(aData
.GetLandscape() ? ORIENTATION_LANDSCAPE
: ORIENTATION_PORTRAIT
);
548 pDoc
->SetPreViewPrtData(&aData
);
552 /* -----------------20.08.98 08:48-------------------
554 * --------------------------------------------------*/
555 IMPL_LINK( SwPreviewPrintOptionsDialog
, ModifyHdl
, Edit
*, pEdit
)
557 if(bStandard
&& pEdit
)
559 aLSpaceMF
.SetUserValue(aLSpaceMF
.GetValue());
560 aRSpaceMF
.SetUserValue(aRSpaceMF
.GetValue());
561 aTSpaceMF
.SetUserValue(aTSpaceMF
.GetValue());
562 aBSpaceMF
.SetUserValue(aBSpaceMF
.GetValue());
563 aHSpaceMF
.SetUserValue(aHSpaceMF
.GetValue());
564 aVSpaceMF
.SetUserValue(aVSpaceMF
.GetValue());
565 aRowsNF
. SetUserValue(aRowsNF
.GetValue());
566 aColsNF
. SetUserValue(aColsNF
.GetValue());
570 BOOL bOrientChanged
= aSettings
.bPrinterLandscape
!= aLandscapeRB
.IsChecked();;
571 if(pEdit
== &aLSpaceMF
)
572 aSettings
.nLeft
= static_cast< long >(aLSpaceMF
.Denormalize(aLSpaceMF
.GetValue(FUNIT_TWIP
)));
573 else if(pEdit
== &aRSpaceMF
)
574 aSettings
.nRight
= static_cast< long >(aRSpaceMF
.Denormalize(aRSpaceMF
.GetValue(FUNIT_TWIP
)));
575 else if(pEdit
== &aTSpaceMF
)
576 aSettings
.nTop
= static_cast< long >(aTSpaceMF
.Denormalize(aTSpaceMF
.GetValue(FUNIT_TWIP
)));
577 else if(pEdit
== &aBSpaceMF
)
578 aSettings
.nBottom
= static_cast< long >(aBSpaceMF
.Denormalize(aBSpaceMF
.GetValue(FUNIT_TWIP
)));
579 else if(pEdit
== &aHSpaceMF
)
580 aSettings
.nHori
= static_cast< long >(aHSpaceMF
.Denormalize(aHSpaceMF
.GetValue(FUNIT_TWIP
)));
581 else if(pEdit
== &aVSpaceMF
)
582 aSettings
.nVert
= static_cast< long >(aVSpaceMF
.Denormalize(aVSpaceMF
.GetValue(FUNIT_TWIP
)));
583 else if(pEdit
== &aRowsNF
)
584 aSettings
.nRows
= (USHORT
)aRowsNF
.GetValue();
585 else if(pEdit
== &aColsNF
)
586 aSettings
.nCols
= (USHORT
)aColsNF
.GetValue();
587 else if(pEdit
== (Edit
*)&aLandscapeRB
)
588 aSettings
.bPrinterLandscape
= aLandscapeRB
.IsChecked();
589 else if(pEdit
== (Edit
*)&aPortraitRB
)
590 aSettings
.bPrinterLandscape
= aLandscapeRB
.IsChecked();
594 Size
aTmp(aSettings
.aPrtSize
.Height(), aSettings
.aPrtSize
.Width());
595 aSettings
.aPrtSize
= aTmp
;
599 aSettings
.aPrvPrtSize
= Size(aSettings
.aPrtSize
.Width() - aSettings
.nRight
- aSettings
.nLeft
,
600 aSettings
.aPrtSize
.Height() - aSettings
.nTop
- aSettings
.nBottom
);
601 aSettings
.aGridSize
= Size(aSettings
.aPrvPrtSize
.Width() / aSettings
.nCols
,
602 aSettings
.aPrvPrtSize
.Height() / aSettings
.nRows
);
603 // was fehlt noch: Orientation auswerten, minimalrand ausrechnen, Beispiel fuettern
606 //am Ende Maximalwerte setzen
607 long n20Percent
= aSettings
.aPrtSize
.Width() / 5;
608 aLSpaceMF
.SetMax(aLSpaceMF
.Normalize(aSettings
.aPrtSize
.Width() - aSettings
.nRight
- n20Percent
), FUNIT_TWIP
);
609 aRSpaceMF
.SetMax(aRSpaceMF
.Normalize(aSettings
.aPrtSize
.Width() - aSettings
.nLeft
- n20Percent
), FUNIT_TWIP
);
610 n20Percent
= aSettings
.aPrtSize
.Height() / 5;
611 aTSpaceMF
.SetMax(aTSpaceMF
.Normalize(aSettings
.aPrtSize
.Height() - aSettings
.nBottom
- n20Percent
), FUNIT_TWIP
);
612 aBSpaceMF
.SetMax(aBSpaceMF
.Normalize(aSettings
.aPrtSize
.Height() - aSettings
.nTop
- n20Percent
), FUNIT_TWIP
);
614 long n80Percent
= aSettings
.aPrvPrtSize
.Width() * 4 / 5;
615 aHSpaceMF
.SetMax(aHSpaceMF
.Normalize(n80Percent
/ aSettings
.nRows
), FUNIT_TWIP
);
616 n80Percent
= aSettings
.aPrvPrtSize
.Height()* 4 / 5;
617 aVSpaceMF
.SetMax(aVSpaceMF
.Normalize(n80Percent
/ aSettings
.nCols
), FUNIT_TWIP
);
618 aHSpaceMF
.Enable(aSettings
.nCols
> 1);
619 aVSpaceMF
.Enable(aSettings
.nRows
> 1);
620 aRowsNF
.SetMin(1);// nur damit auch nach Standard wieder der Inhalt angezeigt wird
624 aPreviewWin
.Invalidate();
627 /* -----------------28.08.98 14:59-------------------
629 * --------------------------------------------------*/
630 IMPL_LINK( SwPreviewPrintOptionsDialog
, StandardHdl
, PushButton
*, EMPTYARG
)
633 SwPagePreViewPrtData aData
;
634 aData
.SetRow(rParentWin
.GetRow());
635 aData
.SetCol(rParentWin
.GetCol());
638 aLSpaceMF
.SetText(aEmptyStr
);
639 aRSpaceMF
.SetText(aEmptyStr
);
640 aTSpaceMF
.SetText(aEmptyStr
);
641 aBSpaceMF
.SetText(aEmptyStr
);
642 aHSpaceMF
.SetText(aEmptyStr
);
643 aVSpaceMF
.SetText(aEmptyStr
);
644 aPreviewWin
.Invalidate();
645 SetUpdateMode(FALSE
);
648 /* -----------------20.08.98 15:28-------------------
650 * --------------------------------------------------*/
651 void PrtPrvWindow::Paint(const Rectangle
&)
653 Size
aWinSize(GetOutputSizePixel());
654 long nWidth
= rSettings
.aPrtSize
.Width();
655 long nHeight
= rSettings
.aPrtSize
.Height();
656 BOOL bHoriValid
= (aWinSize
.Width() * 100 / aWinSize
.Height()) <
657 (rSettings
.aPrtSize
.Width() * 100/ rSettings
.aPrtSize
.Height());
658 Fraction
aXScale( aWinSize
.Width(), Max( nWidth
, 1L ) );
659 Fraction
aYScale( aWinSize
.Height(), Max( nHeight
, 1L ) );
660 MapMode
aMapMode( GetMapMode() );
661 aMapMode
.SetScaleX( bHoriValid
? aXScale
: aYScale
);
662 aMapMode
.SetScaleY( bHoriValid
? aXScale
: aYScale
);
663 SetMapMode( aMapMode
);
665 aWinSize
= GetOutputSize();
669 aOffset
.Y() = (aWinSize
.Height() - rSettings
.aPrtSize
.Height()) / 2;
671 aOffset
.X() = (aWinSize
.Width() - rSettings
.aPrtSize
.Width()) / 2;;
674 BOOL bUseSystemColors
= SvtAccessibilityOptions().GetIsForPagePreviews()
675 && GetSettings().GetStyleSettings().GetHighContrastMode();
677 //der weisse Seitenhintergrund
678 Rectangle
aRect(aOffset
, rSettings
.aPrtSize
);
681 SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() );
682 SetLineColor( SwViewOption::GetFontColor() );
686 SetFillColor( Color( COL_WHITE
) );
687 SetLineColor(Color( COL_BLACK
) );
693 aTL
.X() += rSettings
.nLeft
;
694 aTL
.Y() += rSettings
.nTop
;
696 Size
aPrvPageSize((rSettings
.aPrvPrtSize
.Width() - (rSettings
.nCols
- 1) * rSettings
.nHori
) / rSettings
.nCols
,
697 (rSettings
.aPrvPrtSize
.Height() - (rSettings
.nRows
- 1) * rSettings
.nVert
) / rSettings
.nRows
);
698 // jetzt muss noch das unterschiedliche Groessenverhaeltnis berechnet werden, um es an
699 // der richtigen Seite abzuziehen.
701 long nSourceScale
= rSettings
.aPageMaxSize
.Width() * 100 / rSettings
.aPageMaxSize
.Height();
702 long nDestScale
= aPrvPageSize
.Width() * 100 / aPrvPageSize
.Height() ;
703 if(nSourceScale
> nDestScale
) // die Seite ist relativ breiter als das vorhandene Rechteck
705 aPrvPageSize
.Height() = aPrvPageSize
.Width() * 100 / nSourceScale
;
709 aPrvPageSize
.Width() = aPrvPageSize
.Height() * nSourceScale
/ 100;
713 SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() );
715 SetFillColor( Color( COL_GRAY
) );
718 aRect
= Rectangle(aTL
, aPrvPageSize
);
719 for(USHORT i
= 0; i
< rSettings
.nRows
; i
++)
721 for(USHORT j
= 0; j
< rSettings
.nCols
; j
++)
724 aRect
.Move(aPrvPageSize
.Width() + rSettings
.nHori
, 0);
727 aRect
.Move( 0, aPrvPageSize
.Height() + rSettings
.nVert
);
728 aRect
.SetPos(Point(aTL
.X(), aRect
.TopLeft().Y()));
734 /*--------------------------------------------------------------------
736 --------------------------------------------------------------------*/
738 // alles fuers SwPagePreViewWin
741 SwPagePreViewWin::SwPagePreViewWin( Window
*pParent
, SwPagePreView
& rPView
)
742 : Window( pParent
, WinBits( WB_CLIPCHILDREN
) ),
745 mbCalcScaleForPreviewLayout( true ),
746 maPaintedPreviewDocRect( Rectangle(0,0,0,0) )
748 SetOutDevViewType( OUTDEV_VIEWTYPE_PRINTPREVIEW
); //#106611#
749 SetHelpId(HID_PAGEPREVIEW
);
750 SetFillColor( GetBackground().GetColor() );
751 SetLineColor( GetBackground().GetColor());
752 SetMapMode( MapMode(MAP_TWIP
) );
754 const SwMasterUsrPref
*pUsrPref
= SW_MOD()->GetUsrPref(FALSE
);
755 mnRow
= pUsrPref
->GetPagePrevRow(); // 1 Zeile
756 mnCol
= pUsrPref
->GetPagePrevCol(); // 1 Spalte
757 // OD 24.03.2003 #108282# - member <mnVirtPage> no longer exists.
758 mnSttPage
= USHRT_MAX
;
761 /*--------------------------------------------------------------------
763 --------------------------------------------------------------------*/
766 SwPagePreViewWin::~SwPagePreViewWin()
772 /*--------------------------------------------------------------------
774 --------------------------------------------------------------------*/
777 void SwPagePreViewWin::Paint( const Rectangle
& rRect
)
779 if( !mpViewShell
|| !mpViewShell
->GetLayout() )
782 if( USHRT_MAX
== mnSttPage
) // wurde noch nie berechnet ? (Init-Phase!)
784 // das ist die Size, auf die ich mich immer beziehe
785 if( !maPxWinSize
.Height() || !maPxWinSize
.Width() )
786 maPxWinSize
= GetOutputSizePixel();
788 Rectangle
aRect( LogicToPixel( rRect
));
789 mpPgPrevwLayout
->Prepare( 1, Point(0,0), maPxWinSize
,
790 mnSttPage
, maPaintedPreviewDocRect
);
791 SetSelectedPage( 1 );
792 mpPgPrevwLayout
->Paint( PixelToLogic( aRect
) );
793 SetPagePreview(mnRow
, mnCol
);
797 MapMode
aMM( GetMapMode() );
798 aMM
.SetScaleX( maScale
);
799 aMM
.SetScaleY( maScale
);
801 mpPgPrevwLayout
->Paint( rRect
);
805 /*--------------------------------------------------------------------
807 --------------------------------------------------------------------*/
808 void SwPagePreViewWin::CalcWish( BYTE nNewRow
, BYTE nNewCol
)
810 if( !mpViewShell
|| !mpViewShell
->GetLayout() )
813 USHORT nOldCol
= mnCol
;
814 // OD 02.12.2002 #103492# - update <mnRow> and <mnCol>.
817 USHORT nPages
= mnRow
* mnCol
,
818 nLastSttPg
= mrView
.GetPageCount()+1 > nPages
819 ? mrView
.GetPageCount()+1 - nPages
: 0;
820 if( mnSttPage
> nLastSttPg
)
821 mnSttPage
= nLastSttPg
;
823 mpPgPrevwLayout
->Init( mnCol
, mnRow
, maPxWinSize
, true );
824 mpPgPrevwLayout
->Prepare( mnSttPage
, Point(0,0), maPxWinSize
,
825 mnSttPage
, maPaintedPreviewDocRect
);
826 SetSelectedPage( mnSttPage
);
827 SetPagePreview(mnRow
, mnCol
);
828 maScale
= GetMapMode().GetScaleX();
830 // falls an der Spaltigkeit gedreht wurde, so muss der Sonderfall
831 // Einspaltig beachtet und ggfs. der Scrollbar korrigiert werden
832 if( (1 == nOldCol
) ^ (1 == mnCol
) )
833 mrView
.ScrollDocSzChg();
835 // Sortierung muss eingehalten werden!!
836 // OD 24.03.2003 #108282# - additional invalidate page status.
837 static USHORT __READONLY_DATA aInval
[] =
839 SID_ATTR_ZOOM
, SID_ZOOM_OUT
, SID_ZOOM_IN
,
841 FN_START_OF_DOCUMENT
, FN_END_OF_DOCUMENT
, FN_PAGEUP
, FN_PAGEDOWN
,
842 FN_STAT_PAGE
, FN_STAT_ZOOM
,
843 FN_SHOW_TWO_PAGES
, FN_SHOW_MULTIPLE_PAGES
,
846 SfxBindings
& rBindings
= mrView
.GetViewFrame()->GetBindings();
847 rBindings
.Invalidate( aInval
);
848 rBindings
.Update( FN_SHOW_TWO_PAGES
);
849 rBindings
.Update( FN_SHOW_MULTIPLE_PAGES
);
850 // OD 18.12.2002 #103492# - adjust scrollbars
851 mrView
.ScrollViewSzChg();
853 /*--------------------------------------------------------------------
854 Beschreibung:, mnSttPage is Absolute
855 --------------------------------------------------------------------*/
858 int SwPagePreViewWin::MovePage( int eMoveMode
)
860 // soviele Seiten hoch
861 USHORT nPages
= mnRow
* mnCol
;
862 USHORT nNewSttPage
= mnSttPage
;
863 // OD 04.12.2002 #103492#
864 USHORT nPageCount
= mrView
.GetPageCount();
865 USHORT nDefSttPg
= GetDefSttPage();
866 // OD 06.12.2002 #103492#
867 bool bPaintPageAtFirstCol
= true;
873 const sal_uInt16 nRelSttPage
= mpPgPrevwLayout
->ConvertAbsoluteToRelativePageNum( mnSttPage
);
874 const sal_uInt16 nNewAbsSttPage
= nRelSttPage
- nPages
> 0 ?
875 mpPgPrevwLayout
->ConvertRelativeToAbsolutePageNum( nRelSttPage
- nPages
) :
877 nNewSttPage
= nNewAbsSttPage
;
879 const sal_uInt16 nRelSelPage
= mpPgPrevwLayout
->ConvertAbsoluteToRelativePageNum( SelectedPage() );
880 const sal_uInt16 nNewRelSelPage
= nRelSelPage
- nPages
> 0 ?
881 nRelSelPage
- nPages
:
883 SetSelectedPage( mpPgPrevwLayout
->ConvertRelativeToAbsolutePageNum( nNewRelSelPage
) );
889 const sal_uInt16 nRelSttPage
= mpPgPrevwLayout
->ConvertAbsoluteToRelativePageNum( mnSttPage
);
890 const sal_uInt16 nNewAbsSttPage
= mpPgPrevwLayout
->ConvertRelativeToAbsolutePageNum( nRelSttPage
+ nPages
);
891 nNewSttPage
= nNewAbsSttPage
< nPageCount
? nNewAbsSttPage
: nPageCount
;
893 const sal_uInt16 nRelSelPage
= mpPgPrevwLayout
->ConvertAbsoluteToRelativePageNum( SelectedPage() );
894 const sal_uInt16 nNewAbsSelPage
= mpPgPrevwLayout
->ConvertRelativeToAbsolutePageNum( nRelSelPage
+ nPages
);
895 SetSelectedPage( nNewAbsSelPage
< nPageCount
? nNewAbsSelPage
: nPageCount
);
900 nNewSttPage
= nDefSttPg
;
901 SetSelectedPage( mpPgPrevwLayout
->ConvertRelativeToAbsolutePageNum( nNewSttPage
? nNewSttPage
: 1 ) );
904 // OD 03.12.2002 #103492# - correct calculation of new start page.
905 nNewSttPage
= nPageCount
;
906 SetSelectedPage( nPageCount
);
908 // OD 12.12.2002 #103492# - add new move mode
910 // <nNewSttPage> and <SelectedPage()> are already set.
911 // OD 20.02.2003 #107369# - not start at first column, only if the
912 // complete preview layout columns doesn't fit into window.
913 if ( !mpPgPrevwLayout
->DoesPreviewLayoutColsFitIntoWindow() )
914 bPaintPageAtFirstCol
= false;
917 // OD 17.01.2003 #103492# - check, if paint page at first column
919 if ( !mpPgPrevwLayout
->DoesPreviewLayoutRowsFitIntoWindow() ||
920 !mpPgPrevwLayout
->DoesPreviewLayoutColsFitIntoWindow() )
921 bPaintPageAtFirstCol
= false;
924 // OD 18.12.2002 #103492# - nothing special to do.
927 // OD 18.12.2002 #103492# - re-init page preview layout.
928 mpPgPrevwLayout
->ReInit();
930 // OD 03.12.2002 #103492# - correct calculation of new start page.
931 if( nNewSttPage
> nPageCount
)
932 nNewSttPage
= nPageCount
;
934 // OD 18.12.2002 #103492# - correct selected page number
935 if( SelectedPage() > nPageCount
)
936 SetSelectedPage( nNewSttPage
? nNewSttPage
: 1 );
939 mpPgPrevwLayout
->Prepare( nNewSttPage
, Point(0,0), maPxWinSize
,
941 maPaintedPreviewDocRect
, bPaintPageAtFirstCol
);
942 if( nNewSttPage
== mnSttPage
&&
943 eMoveMode
!= MV_SELPAGE
)
946 SetPagePreview(mnRow
, mnCol
);
947 mnSttPage
= nNewSttPage
;
949 // OD 24.03.2003 #108282# - additional invalidate page status.
950 static USHORT __READONLY_DATA aInval
[] =
952 FN_START_OF_DOCUMENT
, FN_END_OF_DOCUMENT
, FN_PAGEUP
, FN_PAGEDOWN
,
956 SfxBindings
& rBindings
= mrView
.GetViewFrame()->GetBindings();
957 rBindings
.Invalidate( aInval
);
962 /*--------------------------------------------------------------------
964 --------------------------------------------------------------------*/
967 void SwPagePreViewWin::SetWinSize( const Size
& rNewSize
)
969 // die Size wollen wir aber immer in Pixel-Einheiten haben
970 maPxWinSize
= LogicToPixel( rNewSize
);
972 if( USHRT_MAX
== mnSttPage
)
974 mnSttPage
= GetDefSttPage();
975 SetSelectedPage( GetDefSttPage() );
978 if ( mbCalcScaleForPreviewLayout
)
980 mpPgPrevwLayout
->Init( mnCol
, mnRow
, maPxWinSize
, true );
981 maScale
= GetMapMode().GetScaleX();
983 mpPgPrevwLayout
->Prepare( mnSttPage
, Point(0,0), maPxWinSize
,
984 mnSttPage
, maPaintedPreviewDocRect
);
985 if ( mbCalcScaleForPreviewLayout
)
987 SetSelectedPage( mnSttPage
);
988 mbCalcScaleForPreviewLayout
= false;
990 SetPagePreview(mnRow
, mnCol
);
991 maScale
= GetMapMode().GetScaleX();
995 /*--------------------------------------------------------------------
997 --------------------------------------------------------------------*/
1000 void SwPagePreViewWin::GetStatusStr( String
& rStr
, USHORT nPageCnt
) const
1002 // OD 24.03.2003 #108282# - show physical and virtual page number of
1003 // selected page, if it's visible.
1004 sal_uInt16 nPageNum
;
1005 if ( mpPgPrevwLayout
->IsPageVisible( mpPgPrevwLayout
->SelectedPage() ) )
1007 nPageNum
= mpPgPrevwLayout
->SelectedPage();
1011 nPageNum
= mnSttPage
> 1 ? mnSttPage
: 1;
1013 sal_uInt16 nVirtPageNum
= mpPgPrevwLayout
->GetVirtPageNumByPageNum( nPageNum
);
1014 if( nVirtPageNum
&& nVirtPageNum
!= nPageNum
)
1016 rStr
+= String::CreateFromInt32( nVirtPageNum
);
1019 rStr
+= String::CreateFromInt32( nPageNum
);
1020 rStr
.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" / "));
1021 rStr
+= String::CreateFromInt32( nPageCnt
);
1024 /*--------------------------------------------------------------------
1026 --------------------------------------------------------------------*/
1029 void SwPagePreViewWin::KeyInput( const KeyEvent
&rKEvt
)
1031 const KeyCode
& rKeyCode
= rKEvt
.GetKeyCode();
1032 USHORT nKey
= rKeyCode
.GetCode();
1033 BOOL bHandled
= FALSE
;
1034 if(!rKeyCode
.GetModifier())
1039 case KEY_ADD
: nSlot
= SID_ZOOM_OUT
; break;
1040 case KEY_ESCAPE
: nSlot
= FN_CLOSE_PAGEPREVIEW
; break;
1041 case KEY_SUBTRACT
: nSlot
= SID_ZOOM_IN
; break;
1046 mrView
.GetViewFrame()->GetDispatcher()->Execute(
1047 nSlot
, SFX_CALLMODE_ASYNCHRON
);
1050 if( !bHandled
&& !mrView
.KeyInput( rKEvt
) )
1051 Window::KeyInput( rKEvt
);
1054 /******************************************************************************
1056 ******************************************************************************/
1058 void SwPagePreViewWin::Command( const CommandEvent
& rCEvt
)
1060 BOOL bCallBase
= TRUE
;
1061 switch( rCEvt
.GetCommand() )
1063 case COMMAND_CONTEXTMENU
:
1064 mrView
.GetViewFrame()->GetDispatcher()->ExecutePopup();
1069 case COMMAND_STARTAUTOSCROLL
:
1070 case COMMAND_AUTOSCROLL
:
1072 const CommandWheelData
* pData
= rCEvt
.GetWheelData();
1075 const CommandWheelData
aDataNew(pData
->GetDelta(),pData
->GetNotchDelta(),COMMAND_WHEEL_PAGESCROLL
,
1076 pData
->GetMode(),pData
->GetModifier(),pData
->IsHorz());
1077 const CommandEvent
aEvent( rCEvt
.GetMousePosPixel(),rCEvt
.GetCommand(),rCEvt
.IsMouseEvent(),&aDataNew
);
1078 bCallBase
= !mrView
.HandleWheelCommands( aEvent
);
1081 bCallBase
= !mrView
.HandleWheelCommands( rCEvt
);
1085 // OD 17.12.2002 #103492# - delete assertion
1090 Window::Command( rCEvt
);
1093 void SwPagePreViewWin::MouseButtonDown( const MouseEvent
& rMEvt
)
1095 // OD 17.12.2002 #103492# - consider single-click to set selected page
1096 if( MOUSE_LEFT
== ( rMEvt
.GetModifier() + rMEvt
.GetButtons() ) )
1098 Point
aPrevwPos( PixelToLogic( rMEvt
.GetPosPixel() ) );
1100 bool bPosInEmptyPage
;
1101 sal_uInt16 nNewSelectedPage
;
1103 mpPgPrevwLayout
->IsPrevwPosInDocPrevwPage( aPrevwPos
,
1104 aDocPos
, bPosInEmptyPage
, nNewSelectedPage
);
1105 if ( bIsDocPos
&& rMEvt
.GetClicks() == 2 )
1107 // close page preview, set new cursor position and switch to
1109 String
sNewCrsrPos( String::CreateFromInt32( aDocPos
.X() ));
1110 ((( sNewCrsrPos
+= ';' )
1111 += String::CreateFromInt32( aDocPos
.Y() )) )
1113 mrView
.SetNewCrsrPos( sNewCrsrPos
);
1115 SfxViewFrame
*pTmpFrm
= mrView
.GetViewFrame();
1116 pTmpFrm
->GetBindings().Execute( SID_VIEWSHELL0
, NULL
, 0,
1117 SFX_CALLMODE_ASYNCHRON
);
1119 else if ( bIsDocPos
|| bPosInEmptyPage
)
1120 // OD 2004-03-04 #i20684# - add missing parenthesis
1122 // show clicked page as the selected one
1123 mpPgPrevwLayout
->MarkNewSelectedPage( nNewSelectedPage
);
1124 GetViewShell()->ShowPreViewSelection( nNewSelectedPage
);
1125 // OD 19.02.2003 #107369# - adjust position at vertical scrollbar.
1126 if ( mpPgPrevwLayout
->DoesPreviewLayoutRowsFitIntoWindow() )
1128 mrView
.SetVScrollbarThumbPos( nNewSelectedPage
);
1130 // OD 24.03.2003 #108282# - invalidate page status.
1131 static USHORT __READONLY_DATA aInval
[] =
1135 SfxBindings
& rBindings
= mrView
.GetViewFrame()->GetBindings();
1136 rBindings
.Invalidate( aInval
);
1141 /******************************************************************************
1142 * Beschreibung: Userprefs bzw Viewoptions setzen
1143 ******************************************************************************/
1146 void SwPagePreViewWin::SetPagePreview( BYTE nRow
, BYTE nCol
)
1148 SwMasterUsrPref
*pOpt
= (SwMasterUsrPref
*)SW_MOD()->GetUsrPref(FALSE
);
1150 if (nRow
!= pOpt
->GetPagePrevRow() || nCol
!= pOpt
->GetPagePrevCol())
1152 pOpt
->SetPagePrevRow( nRow
);
1153 pOpt
->SetPagePrevCol( nCol
);
1154 pOpt
->SetModified();
1156 //Scrollbar updaten!
1157 mrView
.ScrollViewSzChg();
1161 /** get selected page in document preview
1163 OD 13.12.2002 #103492#
1167 sal_uInt16
SwPagePreViewWin::SelectedPage() const
1169 return mpPgPrevwLayout
->SelectedPage();
1172 /** set selected page number in document preview
1174 OD 13.12.2002 #103492#
1178 void SwPagePreViewWin::SetSelectedPage( sal_uInt16 _nSelectedPageNum
)
1180 mpPgPrevwLayout
->SetSelectedPage( _nSelectedPageNum
);
1183 /** method to enable/disable book preview
1185 OD 2004-03-05 #i18143#
1189 bool SwPagePreViewWin::SetBookPreviewMode( const bool _bBookPreview
)
1191 return mpPgPrevwLayout
->SetBookPreviewMode( _bBookPreview
,
1193 maPaintedPreviewDocRect
);
1196 void SwPagePreViewWin::DataChanged( const DataChangedEvent
& rDCEvt
)
1198 Window::DataChanged( rDCEvt
);
1200 switch( rDCEvt
.GetType() )
1202 case DATACHANGED_SETTINGS
:
1203 // ScrollBars neu anordnen bzw. Resize ausloesen, da sich
1204 // ScrollBar-Groesse geaendert haben kann. Dazu muss dann im
1205 // Resize-Handler aber auch die Groesse der ScrollBars aus
1206 // den Settings abgefragt werden.
1207 if( rDCEvt
.GetFlags() & SETTINGS_STYLE
)
1208 mrView
.InvalidateBorder(); //Scrollbarbreiten
1209 //#106746# zoom has to be disabled if Accessibility support is switched on
1210 lcl_InvalidateZoomSlots(mrView
.GetViewFrame()->GetBindings());
1213 case DATACHANGED_PRINTER
:
1214 case DATACHANGED_DISPLAY
:
1215 case DATACHANGED_FONTS
:
1216 case DATACHANGED_FONTSUBSTITUTION
:
1217 mrView
.GetDocShell()->UpdateFontList(); //Fontwechsel
1218 if ( mpViewShell
->GetWin() )
1219 mpViewShell
->GetWin()->Invalidate();
1224 /** help method to execute SfxRequest FN_PAGEUP and FN_PAGEDOWN
1226 OD 04.03.2003 #107369#
1230 void SwPagePreView::_ExecPgUpAndPgDown( const bool _bPgUp
,
1233 SwPagePreviewLayout
* pPagePrevwLay
= GetViewShell()->PagePreviewLayout();
1234 // check, if top/bottom of preview is *not* already visible.
1235 if( pPagePrevwLay
->GetWinPagesScrollAmount( _bPgUp
? -1 : 1 ) != 0 )
1237 if ( pPagePrevwLay
->DoesPreviewLayoutRowsFitIntoWindow() &&
1238 pPagePrevwLay
->DoesPreviewLayoutColsFitIntoWindow() )
1240 const int eMvMode
= _bPgUp
?
1241 SwPagePreViewWin::MV_PAGE_UP
:
1242 SwPagePreViewWin::MV_PAGE_DOWN
;
1243 if ( ChgPage( eMvMode
, TRUE
) )
1244 aViewWin
.Invalidate();
1248 SwTwips nScrollAmount
;
1249 sal_uInt16 nNewSelectedPageNum
= 0;
1250 const sal_uInt16 nVisPages
= aViewWin
.GetRow() * aViewWin
.GetCol();
1253 if ( pPagePrevwLay
->DoesPreviewLayoutRowsFitIntoWindow() )
1255 nScrollAmount
= pPagePrevwLay
->GetWinPagesScrollAmount( -1 );
1256 if ( (aViewWin
.SelectedPage() - nVisPages
) > 0 )
1257 nNewSelectedPageNum
= aViewWin
.SelectedPage() - nVisPages
;
1259 nNewSelectedPageNum
= 1;
1262 nScrollAmount
= - Min( aViewWin
.GetOutputSize().Height(),
1263 aViewWin
.GetPaintedPreviewDocRect().Top() );
1267 if ( pPagePrevwLay
->DoesPreviewLayoutRowsFitIntoWindow() )
1269 nScrollAmount
= pPagePrevwLay
->GetWinPagesScrollAmount( 1 );
1270 if ( (aViewWin
.SelectedPage() + nVisPages
) <= mnPageCount
)
1271 nNewSelectedPageNum
= aViewWin
.SelectedPage() + nVisPages
;
1273 nNewSelectedPageNum
= mnPageCount
;
1276 nScrollAmount
= Min( aViewWin
.GetOutputSize().Height(),
1277 ( pPagePrevwLay
->GetPrevwDocSize().Height() -
1278 aViewWin
.GetPaintedPreviewDocRect().Bottom() ) );
1280 aViewWin
.Scroll( 0, nScrollAmount
);
1281 if ( nNewSelectedPageNum
!= 0 )
1283 aViewWin
.SetSelectedPage( nNewSelectedPageNum
);
1286 // OD 24.03.2003 #108282# - additional invalidate page status.
1287 static USHORT __READONLY_DATA aInval
[] =
1289 FN_START_OF_DOCUMENT
, FN_END_OF_DOCUMENT
, FN_PAGEUP
, FN_PAGEDOWN
,
1292 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
1293 rBindings
.Invalidate( aInval
);
1294 aViewWin
.Invalidate();
1302 /*--------------------------------------------------------------------
1304 --------------------------------------------------------------------*/
1305 // dann mal alles fuer die SwPagePreView
1306 void SwPagePreView::Execute( SfxRequest
&rReq
)
1310 BOOL bRetVal
= FALSE
;
1311 bool bRefresh
= true;
1313 switch(rReq
.GetSlot())
1315 case FN_REFRESH_VIEW
:
1320 case FN_SHOW_MULTIPLE_PAGES
:
1322 const SfxItemSet
*pArgs
= rReq
.GetArgs();
1323 if( pArgs
&& pArgs
->Count() >= 2 )
1325 BYTE nCols
= (BYTE
)((SfxUInt16Item
&)pArgs
->Get(
1326 SID_ATTR_TABLE_COLUMN
)).GetValue();
1327 BYTE nRows
= (BYTE
)((SfxUInt16Item
&)pArgs
->Get(
1328 SID_ATTR_TABLE_ROW
)).GetValue();
1329 aViewWin
.CalcWish( nRows
, nCols
);
1333 SwPreViewZoomDlg( aViewWin
).Execute();
1337 case FN_SHOW_BOOKVIEW
:
1339 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1340 const SfxPoolItem
* pItem
;
1341 bool bBookPreview
= GetViewShell()->GetViewOptions()->IsPagePrevBookview();
1342 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( FN_SHOW_BOOKVIEW
, FALSE
, &pItem
) )
1344 bBookPreview
= static_cast< const SfxBoolItem
* >( pItem
)->GetValue();
1345 ( ( SwViewOption
* ) GetViewShell()->GetViewOptions() )->SetPagePrevBookview( bBookPreview
);
1346 // cast is not gentleman like, but it's common use in writer and in this case
1348 if ( aViewWin
.SetBookPreviewMode( bBookPreview
) )
1350 // book preview mode changed. Thus, adjust scrollbars and
1351 // invalidate corresponding states.
1353 static USHORT __READONLY_DATA aInval
[] =
1355 FN_START_OF_DOCUMENT
, FN_END_OF_DOCUMENT
, FN_PAGEUP
, FN_PAGEDOWN
,
1356 FN_STAT_PAGE
, FN_SHOW_BOOKVIEW
, 0
1358 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
1359 rBindings
.Invalidate( aInval
);
1360 aViewWin
.Invalidate();
1365 case FN_SHOW_TWO_PAGES
:
1366 aViewWin
.CalcWish( nRow
, 2 );
1369 case FN_PREVIEW_ZOOM
:
1372 const SfxItemSet
*pArgs
= rReq
.GetArgs();
1373 const SfxPoolItem
* pItem
;
1374 AbstractSvxZoomDialog
*pDlg
= 0;
1377 SfxItemSet
aCoreSet(GetPool(), SID_ATTR_ZOOM
, SID_ATTR_ZOOM
);
1378 const SwViewOption
* pVOpt
= GetViewShell()->GetViewOptions();
1379 SvxZoomItem
aZoom( (SvxZoomType
)pVOpt
->GetZoomType(),
1384 SVX_ZOOM_ENABLE_100
|
1385 SVX_ZOOM_ENABLE_150
|
1386 SVX_ZOOM_ENABLE_200
|
1387 SVX_ZOOM_ENABLE_WHOLEPAGE
);
1388 aCoreSet
.Put( aZoom
);
1390 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1393 pDlg
= pFact
->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet
, RID_SVXDLG_ZOOM
);
1394 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
1397 pDlg
->SetLimits( MINZOOM
, MAXZOOM
);
1399 if( pDlg
->Execute() != RET_CANCEL
)
1400 pArgs
= pDlg
->GetOutputItemSet();
1404 enum SvxZoomType eType
= SVX_ZOOM_PERCENT
;
1405 USHORT nZoomFactor
= USHRT_MAX
;
1406 if(SFX_ITEM_SET
== pArgs
->GetItemState(SID_ATTR_ZOOM
, TRUE
, &pItem
))
1408 eType
= ((const SvxZoomItem
*)pItem
)->GetType();
1409 nZoomFactor
= ((const SvxZoomItem
*)pItem
)->GetValue();
1411 else if(SFX_ITEM_SET
== pArgs
->GetItemState(FN_PREVIEW_ZOOM
, TRUE
, &pItem
))
1412 nZoomFactor
= ((const SfxUInt16Item
*)pItem
)->GetValue();
1413 if(USHRT_MAX
!= nZoomFactor
)
1414 SetZoom(eType
, nZoomFactor
);
1419 case SID_ATTR_ZOOMSLIDER
:
1421 const SfxItemSet
*pArgs
= rReq
.GetArgs();
1422 const SfxPoolItem
* pItem
;
1424 if ( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(SID_ATTR_ZOOMSLIDER
, TRUE
, &pItem
) )
1426 const USHORT nCurrentZoom
= ((const SvxZoomSliderItem
*)pItem
)->GetValue();
1427 SetZoom( SVX_ZOOM_PERCENT
, nCurrentZoom
);
1434 enum SvxZoomType eType
= SVX_ZOOM_PERCENT
;
1435 const SwViewOption
* pVOpt
= GetViewShell()->GetViewOptions();
1437 lcl_GetNextZoomStep(pVOpt
->GetZoom(), SID_ZOOM_IN
== rReq
.GetSlot()));
1445 SwPagePreviewLayout
* pPagePrevwLay
= GetViewShell()->PagePreviewLayout();
1446 sal_uInt16 nNewSelectedPage
;
1447 sal_uInt16 nNewStartPage
;
1449 sal_Int16 nHoriMove
= 0;
1450 sal_Int16 nVertMove
= 0;
1451 switch(rReq
.GetSlot())
1453 case FN_CHAR_LEFT
: nHoriMove
= -1; break;
1454 case FN_CHAR_RIGHT
: nHoriMove
= 1; break;
1455 case FN_LINE_UP
: nVertMove
= -1; break;
1456 case FN_LINE_DOWN
: nVertMove
= 1; break;
1458 pPagePrevwLay
->CalcStartValuesForSelectedPageMove( nHoriMove
, nVertMove
,
1459 nNewSelectedPage
, nNewStartPage
, aNewStartPos
);
1460 if ( aViewWin
.SelectedPage() != nNewSelectedPage
)
1462 if ( pPagePrevwLay
->IsPageVisible( nNewSelectedPage
) )
1464 pPagePrevwLay
->MarkNewSelectedPage( nNewSelectedPage
);
1465 // OD 19.02.2003 #107369# - adjust position at vertical scrollbar.
1466 SetVScrollbarThumbPos( nNewSelectedPage
);
1471 aViewWin
.SetSelectedPage( nNewSelectedPage
);
1472 aViewWin
.SetSttPage( nNewStartPage
);
1473 int nRet
= ChgPage( SwPagePreViewWin::MV_SELPAGE
, TRUE
);
1474 bRefresh
= 0 != nRet
;
1476 GetViewShell()->ShowPreViewSelection( nNewSelectedPage
);
1477 // OD 24.03.2003 #108282# - invalidate page status.
1478 static USHORT __READONLY_DATA aInval
[] =
1482 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
1483 rBindings
.Invalidate( aInval
);
1495 _ExecPgUpAndPgDown( rReq
.GetSlot() == FN_PAGEUP
, &rReq
);
1498 case FN_START_OF_LINE
:
1499 case FN_START_OF_DOCUMENT
:
1500 aViewWin
.SetSelectedPage( 1 );
1501 eMvMode
= SwPagePreViewWin::MV_DOC_STT
; bRetVal
= TRUE
; goto MOVEPAGE
;
1502 case FN_END_OF_LINE
:
1503 case FN_END_OF_DOCUMENT
:
1504 aViewWin
.SetSelectedPage( mnPageCount
);
1505 eMvMode
= SwPagePreViewWin::MV_DOC_END
; bRetVal
= TRUE
; goto MOVEPAGE
;
1508 int nRet
= ChgPage( eMvMode
, TRUE
);
1509 // return value fuer Basic
1511 rReq
.SetReturnValue(SfxBoolItem(rReq
.GetSlot(), nRet
== 0));
1513 bRefresh
= 0 != nRet
;
1518 case FN_PRINT_PAGEPREVIEW
:
1520 const SwPagePreViewPrtData
* pPPVPD
= aViewWin
.GetViewShell()->GetDoc()->GetPreViewPrtData();
1521 // die Sache mit der Orientation
1524 SfxPrinter
* pPrinter
= GetPrinter( TRUE
);
1525 if((pPrinter
->GetOrientation() == ORIENTATION_LANDSCAPE
)
1526 != pPPVPD
->GetLandscape())
1527 pPrinter
->SetOrientation(pPPVPD
->GetLandscape() ? ORIENTATION_LANDSCAPE
: ORIENTATION_PORTRAIT
);
1529 ::SetAppPrintOptions( aViewWin
.GetViewShell(), FALSE
);
1530 bNormalPrint
= FALSE
;
1531 USHORT nPrtSlot
= SID_PRINTDOC
;
1532 rReq
.SetSlot( nPrtSlot
);
1533 SfxViewShell::ExecuteSlot( rReq
, SfxViewShell::GetInterface() );
1534 rReq
.SetSlot( FN_PRINT_PAGEPREVIEW
);
1537 case FN_PREVIEW_PRINT_OPTIONS
:
1539 SwPreviewPrintOptionsDialog
aDlg(aViewWin
, *this);
1543 case SID_PRINTDOCDIRECT
:
1545 ::SetAppPrintOptions( aViewWin
.GetViewShell(), FALSE
);
1546 bNormalPrint
= TRUE
;
1547 SfxViewShell::ExecuteSlot( rReq
, SfxViewShell::GetInterface() );
1549 case FN_CLOSE_PAGEPREVIEW
:
1550 case SID_PRINTPREVIEW
:
1551 // print preview is now always in the same frame as the tab view
1552 // -> always switch this frame back to normal view
1553 // (ScTabViewShell ctor reads stored view data)
1554 GetViewFrame()->GetDispatcher()->Execute( SID_VIEWSHELL0
, 0, 0, SFX_CALLMODE_ASYNCHRON
);
1556 case FN_INSERT_BREAK
:
1558 USHORT nSelPage
= aViewWin
.SelectedPage();
1559 //if a dummy page is selected (e.g. a non-existing right/left page)
1560 //the direct neighbor is used
1561 if(GetViewShell()->IsDummyPage( nSelPage
) && GetViewShell()->IsDummyPage( --nSelPage
))
1563 SetNewPage( nSelPage
);
1564 SfxViewFrame
*pTmpFrm
= GetViewFrame();
1565 pTmpFrm
->GetBindings().Execute( SID_VIEWSHELL0
, NULL
, 0,
1566 SFX_CALLMODE_ASYNCHRON
);
1570 ASSERT(!this, falscher Dispatcher
);
1575 aViewWin
.Invalidate();
1578 /*--------------------------------------------------------------------
1580 --------------------------------------------------------------------*/
1583 void SwPagePreView::GetState( SfxItemSet
& rSet
)
1585 SfxWhichIter
aIter(rSet
);
1587 USHORT nWhich
= aIter
.FirstWhich();
1588 ASSERT(nWhich
, leeres Set
);
1589 SwPagePreviewLayout
* pPagePrevwLay
= GetViewShell()->PagePreviewLayout();
1590 //#106746# zoom has to be disabled if Accessibility support is switched on
1591 BOOL bZoomEnabled
= !Application::GetSettings().GetMiscSettings().GetEnableATToolSupport();
1597 case FN_START_OF_DOCUMENT
:
1599 if ( pPagePrevwLay
->IsPageVisible( 1 ) )
1600 rSet
.DisableItem(nWhich
);
1603 case FN_END_OF_DOCUMENT
:
1605 if ( pPagePrevwLay
->IsPageVisible( mnPageCount
) )
1606 rSet
.DisableItem(nWhich
);
1611 if( pPagePrevwLay
->GetWinPagesScrollAmount( -1 ) == 0 )
1612 rSet
.DisableItem(nWhich
);
1617 if( pPagePrevwLay
->GetWinPagesScrollAmount( 1 ) == 0 )
1618 rSet
.DisableItem(nWhich
);
1624 String
aStr( sPageStr
);
1625 aViewWin
.GetStatusStr( aStr
, mnPageCount
);
1626 rSet
.Put( SfxStringItem( nWhich
, aStr
) );
1635 const SwViewOption
* pVOpt
= GetViewShell()->GetViewOptions();
1636 SvxZoomItem
aZoom((SvxZoomType
)pVOpt
->GetZoomType(),
1641 SVX_ZOOM_ENABLE_100
|
1642 SVX_ZOOM_ENABLE_150
|
1643 SVX_ZOOM_ENABLE_200
);
1647 rSet
.DisableItem(nWhich
);
1650 case SID_ATTR_ZOOMSLIDER
:
1654 const SwViewOption
* pVOpt
= GetViewShell()->GetViewOptions();
1655 const USHORT nCurrentZoom
= pVOpt
->GetZoom();
1656 SvxZoomSliderItem
aZoomSliderItem( nCurrentZoom
, MINZOOM
, MAXZOOM
);
1657 aZoomSliderItem
.AddSnappingPoint( 100 );
1658 rSet
.Put( aZoomSliderItem
);
1661 rSet
.DisableItem(nWhich
);
1664 case FN_PREVIEW_ZOOM
:
1668 const SwViewOption
* pVOpt
= GetViewShell()->GetViewOptions();
1669 rSet
.Put(SfxUInt16Item(nWhich
, pVOpt
->GetZoom()));
1672 rSet
.DisableItem(nWhich
);
1678 const SwViewOption
* pVOpt
= GetViewShell()->GetViewOptions();
1679 if(!bZoomEnabled
|| (SID_ZOOM_OUT
== nWhich
&& pVOpt
->GetZoom() >= MAX_PREVIEW_ZOOM
)||
1680 (SID_ZOOM_IN
== nWhich
&& pVOpt
->GetZoom() <= MIN_PREVIEW_ZOOM
))
1682 rSet
.DisableItem(nWhich
);
1686 case FN_SHOW_MULTIPLE_PAGES
:
1687 //should never be disabled
1689 case FN_SHOW_BOOKVIEW
:
1691 BOOL b
= GetViewShell()->GetViewOptions()->IsPagePrevBookview();
1692 rSet
.Put(SfxBoolItem(nWhich
, b
));
1696 case FN_SHOW_TWO_PAGES
:
1697 if( 2 == aViewWin
.GetCol() && nRow
== aViewWin
.GetRow() )
1698 rSet
.DisableItem( nWhich
);
1701 case FN_PRINT_PAGEPREVIEW
:
1702 // hat den gleichen Status wie das normale Drucken
1704 const SfxPoolItem
* pItem
;
1705 SfxItemSet
aSet( *rSet
.GetPool(), SID_PRINTDOC
, SID_PRINTDOC
);
1706 GetSlotState( SID_PRINTDOC
, SfxViewShell::GetInterface(), &aSet
);
1707 if( SFX_ITEM_DISABLED
== aSet
.GetItemState( SID_PRINTDOC
,
1709 rSet
.DisableItem( nWhich
);
1710 else if( SFX_ITEM_SET
== aSet
.GetItemState( SID_PRINTDOC
,
1713 ((SfxPoolItem
*)pItem
)->SetWhich( FN_PRINT_PAGEPREVIEW
);
1719 case SID_PRINTPREVIEW
:
1720 rSet
.Put( SfxBoolItem( nWhich
, TRUE
) );
1724 case SID_PRINTDOCDIRECT
:
1725 GetSlotState( nWhich
, SfxViewShell::GetInterface(), &rSet
);
1728 nWhich
= aIter
.NextWhich();
1732 /*--------------------------------------------------------------------
1734 --------------------------------------------------------------------*/
1737 void SwPagePreView::StateUndo(SfxItemSet
& rSet
)
1739 SfxWhichIter
aIter(rSet
);
1740 USHORT nWhich
= aIter
.FirstWhich();
1744 rSet
.DisableItem(nWhich
);
1745 nWhich
= aIter
.NextWhich();
1749 /*--------------------------------------------------------------------
1751 --------------------------------------------------------------------*/
1754 void SwPagePreView::Init(const SwViewOption
* pPrefs
)
1756 if ( GetViewShell()->HasDrawView() )
1757 GetViewShell()->GetDrawView()->SetAnimationEnabled( FALSE
);
1759 bNormalPrint
= TRUE
;
1761 // Die DocSize erfragen und verarbeiten. Ueber die Handler konnte
1762 // die Shell nicht gefunden werden, weil die Shell innerhalb CTOR-Phase
1763 // nicht in der SFX-Verwaltung bekannt ist.
1766 pPrefs
= SW_MOD()->GetUsrPref(FALSE
);
1768 // die Felder aktualisieren
1769 // ACHTUNG: hochcasten auf die EditShell, um die SS zu nutzen.
1770 // In den Methoden wird auf die akt. Shell abgefragt!
1771 SwEditShell
* pESh
= (SwEditShell
*)GetViewShell();
1772 BOOL bIsModified
= pESh
->IsModified();
1775 SwViewOption
aOpt( *pPrefs
);
1776 aOpt
.SetPagePreview(TRUE
);
1777 aOpt
.SetTab( FALSE
);
1778 aOpt
.SetBlank( FALSE
);
1779 aOpt
.SetHardBlank( FALSE
);
1780 aOpt
.SetParagraph( FALSE
);
1781 aOpt
.SetLineBreak( FALSE
);
1782 aOpt
.SetPageBreak( FALSE
);
1783 aOpt
.SetColumnBreak( FALSE
);
1784 aOpt
.SetSoftHyph( FALSE
);
1785 aOpt
.SetFldName( FALSE
);
1786 aOpt
.SetPostIts( FALSE
);
1787 aOpt
.SetShowHiddenChar( FALSE
);
1788 aOpt
.SetShowHiddenField( FALSE
);
1789 aOpt
.SetShowHiddenPara( FALSE
);
1790 aOpt
.SetViewHRuler( FALSE
);
1791 aOpt
.SetViewVRuler( FALSE
);
1792 aOpt
.SetGraphic( TRUE
);
1793 aOpt
.SetTable( TRUE
);
1794 aOpt
.SetSnap( FALSE
);
1795 aOpt
.SetGridVisible( FALSE
);
1796 GetViewShell()->ApplyViewOptions( aOpt
);
1797 GetViewShell()->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
1799 // OD 09.01.2003 #i6467# - adjust view shell option to the same as for print
1800 SwPrtOptions
aPrintOptions( GetViewFrame()->GetObjectShell()->GetTitle(0) );
1801 SwView::MakeOptions( 0, aPrintOptions
, 0, 0, false, 0, 0 );
1802 GetViewShell()->AdjustOptionsForPagePreview( aPrintOptions
);
1804 IDocumentSettingAccess
* pIDSA
= pESh
->getIDocumentSettingAccess();
1805 if( pIDSA
->get(IDocumentSettingAccess::BROWSE_MODE
))
1807 pIDSA
->set(IDocumentSettingAccess::BROWSE_MODE
, false);
1808 pESh
->CheckBrowseView( TRUE
);
1811 GetViewShell()->CalcLayout();
1812 DocSzChgd( GetViewShell()->GetDocSize() );
1815 pESh
->ResetModified();
1817 pVScrollbar
->ExtendedShow(pPrefs
->IsViewVScrollBar());
1818 pHScrollbar
->ExtendedShow(pPrefs
->IsViewHScrollBar());
1819 pScrollFill
->Show(pPrefs
->IsViewVScrollBar() && pPrefs
->IsViewHScrollBar());
1823 /*--------------------------------------------------------------------
1825 --------------------------------------------------------------------*/
1828 SwPagePreView::SwPagePreView(SfxViewFrame
*pViewFrame
, SfxViewShell
* pOldSh
):
1829 SfxViewShell( pViewFrame
, SWVIEWFLAGS
),
1830 aViewWin( &pViewFrame
->GetWindow(), *this ),
1831 nNewPage(USHRT_MAX
),
1836 pScrollFill(new ScrollBarBox( &pViewFrame
->GetWindow(),
1837 pViewFrame
->GetFrame()->GetParentFrame() ? 0 : WB_SIZEABLE
)),
1839 // OD 09.01.2003 #106334#
1840 mbResetFormDesignMode( false ),
1841 mbFormDesignModeToReset( false )
1843 SetName(String::CreateFromAscii("PageView" ));
1844 SetWindow( &aViewWin
);
1845 SetHelpId(SW_PAGEPREVIEW
);
1846 _CreateScrollbar( TRUE
);
1847 _CreateScrollbar( FALSE
);
1849 SfxObjectShell
* pObjShell
= pViewFrame
->GetObjectShell();
1852 //Gibt es schon eine Sicht auf das Dokument?
1853 SfxViewFrame
*pF
= SfxViewFrame::GetFirst( pObjShell
);
1854 if ( pF
== pViewFrame
)
1855 pF
= SfxViewFrame::GetNext( *pF
, pObjShell
);
1857 pOldSh
= pF
->GetViewShell();
1860 ViewShell
*pVS
, *pNew
;
1862 if( pOldSh
&& pOldSh
->IsA( TYPE( SwPagePreView
) ) )
1863 pVS
= ((SwPagePreView
*)pOldSh
)->GetViewShell();
1866 if( pOldSh
&& pOldSh
->IsA( TYPE( SwView
) ) )
1868 pVS
= ((SwView
*)pOldSh
)->GetWrtShellPtr();
1869 // save the current ViewData of the previous SwView
1870 pOldSh
->WriteUserData( sSwViewData
, FALSE
);
1873 pVS
= GetDocShell()->GetWrtShell();
1876 // setze die akt. Seite als die erste
1877 USHORT nPhysPg
, nVirtPg
;
1878 ((SwCrsrShell
*)pVS
)->GetPageNum( nPhysPg
, nVirtPg
, /*FALSE*/TRUE
, FALSE
);
1879 if( 1 != aViewWin
.GetCol() && 1 == nPhysPg
)
1881 aViewWin
.SetSttPage( nPhysPg
);
1885 // OD 09.01.2003 #106334# - for form shell remember design mode of draw view
1886 // of previous view shell
1887 if ( pVS
&& pVS
->HasDrawView() )
1889 mbResetFormDesignMode
= true;
1890 mbFormDesignModeToReset
= pVS
->GetDrawView()->IsDesignMode();
1894 pNew
= new ViewShell( *pVS
, &aViewWin
, 0, VSHELLFLAG_ISPREVIEW
);
1896 pNew
= new ViewShell(
1897 *((SwDocShell
*)pViewFrame
->GetObjectShell())->GetDoc(),
1898 &aViewWin
, 0, 0, VSHELLFLAG_ISPREVIEW
);
1900 aViewWin
.SetViewShell( pNew
);
1901 pNew
->SetSfxViewShell( this );
1906 /*--------------------------------------------------------------------
1908 --------------------------------------------------------------------*/
1911 SwPagePreView::~SwPagePreView()
1919 delete pPageDownBtn
;
1921 /* SfxObjectShell* pDocSh = GetDocShell();
1922 TypeId aType = TYPE( SfxTopViewFrame );
1924 for( SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocSh, aType );
1925 pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pDocSh, aType ) )
1926 if( pFrame != GetViewFrame() )
1928 // es gibt noch eine weitere Sicht auf unser Dokument, also
1930 pFrame->GetFrame()->Appear();
1935 /*--------------------------------------------------------------------
1937 --------------------------------------------------------------------*/
1940 SwDocShell
* SwPagePreView::GetDocShell()
1942 return PTR_CAST(SwDocShell
, GetViewFrame()->GetObjectShell());
1945 /*--------------------------------------------------------------------
1947 --------------------------------------------------------------------*/
1950 int SwPagePreView::_CreateScrollbar( BOOL bHori
)
1952 Window
*pMDI
= &GetViewFrame()->GetWindow();
1953 SwScrollbar
** ppScrollbar
= bHori
? &pHScrollbar
: &pVScrollbar
;
1955 ASSERT( !*ppScrollbar
, "vorher abpruefen!" )
1960 pPageUpBtn
= new ImageButton(pMDI
, SW_RES( BTN_PAGEUP
) );
1961 pPageUpBtn
->SetHelpId(FN_PAGEUP
);
1962 pPageDownBtn
= new ImageButton(pMDI
, SW_RES( BTN_PAGEDOWN
) );
1963 pPageDownBtn
->SetHelpId(FN_PAGEDOWN
);
1964 Link
aLk( LINK( this, SwPagePreView
, BtnPage
) );
1965 pPageUpBtn
->SetClickHdl( aLk
);
1966 pPageDownBtn
->SetClickHdl( aLk
);
1968 pPageDownBtn
->Show();
1971 *ppScrollbar
= new SwScrollbar( pMDI
, bHori
);
1974 (*ppScrollbar
)->EnableDrag( TRUE
);
1975 (*ppScrollbar
)->SetEndScrollHdl( LINK( this, SwPagePreView
, EndScrollHdl
));
1978 (*ppScrollbar
)->SetScrollHdl( LINK( this, SwPagePreView
, ScrollHdl
));
1981 (*ppScrollbar
)->ExtendedShow();
1985 /*--------------------------------------------------------------------
1987 --------------------------------------------------------------------*/
1991 /*--------------------------------------------------------------------
1993 --------------------------------------------------------------------*/
1998 IMPL_LINK_INLINE_START( SwPagePreView
, BtnPage
, Button
*, pButton
)
2000 // OD 04.03.2003 #107369# - use new helper method to perform page up
2001 // respectively page down.
2002 _ExecPgUpAndPgDown( pButton
== pPageUpBtn
);
2005 IMPL_LINK_INLINE_END( SwPagePreView
, BtnPage
, Button
*, pButton
)
2007 /*--------------------------------------------------------------------
2009 --------------------------------------------------------------------*/
2012 int SwPagePreView::ChgPage( int eMvMode
, int bUpdateScrollbar
)
2014 Rectangle
aPixVisArea( aViewWin
.LogicToPixel( aVisArea
) );
2015 int bChg
= aViewWin
.MovePage( eMvMode
) ||
2016 eMvMode
== SwPagePreViewWin::MV_CALC
||
2017 eMvMode
== SwPagePreViewWin::MV_NEWWINSIZE
;
2018 aVisArea
= aViewWin
.PixelToLogic( aPixVisArea
);
2022 // Statusleiste updaten
2023 String
aStr( sPageStr
);
2024 aViewWin
.GetStatusStr( aStr
, mnPageCount
);
2025 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
2027 if( bUpdateScrollbar
)
2031 static USHORT __READONLY_DATA aInval
[] =
2033 FN_START_OF_DOCUMENT
, FN_END_OF_DOCUMENT
,
2034 FN_PAGEUP
, FN_PAGEDOWN
, 0
2036 rBindings
.Invalidate( aInval
);
2038 rBindings
.SetState( SfxStringItem( FN_STAT_PAGE
, aStr
) );
2045 /*--------------------------------------------------------------------
2047 --------------------------------------------------------------------*/
2050 // ab hier alles aus der SwView uebernommen
2053 void SwPagePreView::CalcAndSetBorderPixel( SvBorder
&rToFill
, BOOL
/*bInner*/ )
2055 // const long nAdd = bInner ? 0 : ScrollBar::GetWindowOverlapPixel();
2056 const StyleSettings
&rSet
= aViewWin
.GetSettings().GetStyleSettings();
2057 const long nTmp
= rSet
.GetScrollBarSize();// - nAdd;
2058 if ( pVScrollbar
->IsVisible( FALSE
))
2059 rToFill
.Right() = nTmp
;
2060 if ( pHScrollbar
->IsVisible( FALSE
) )
2061 rToFill
.Bottom() = nTmp
;
2062 SetBorderPixel( rToFill
);
2065 /*--------------------------------------------------------------------
2067 --------------------------------------------------------------------*/
2070 void SwPagePreView::InnerResizePixel( const Point
&rOfst
, const Size
&rSize
)
2073 CalcAndSetBorderPixel( aBorder
, TRUE
);
2074 Rectangle
aRect( rOfst
, rSize
);
2076 ViewResizePixel( aViewWin
, aRect
.TopLeft(), aRect
.GetSize(),
2077 aViewWin
.GetOutputSizePixel(),
2079 *pVScrollbar
, *pHScrollbar
, pPageUpBtn
, pPageDownBtn
, 0,
2082 //EditWin niemals einstellen!
2083 //VisArea niemals einstellen!
2086 /*--------------------------------------------------------------------
2088 --------------------------------------------------------------------*/
2091 void SwPagePreView::OuterResizePixel( const Point
&rOfst
, const Size
&rSize
)
2094 CalcAndSetBorderPixel( aBorder
, FALSE
);
2095 ViewResizePixel( aViewWin
, rOfst
, rSize
, aViewWin
.GetOutputSizePixel(),
2096 FALSE
, *pVScrollbar
,
2097 *pHScrollbar
, pPageUpBtn
, pPageDownBtn
, 0, *pScrollFill
);
2099 //EditWin niemals einstellen!
2101 Size
aTmpSize( aViewWin
.GetOutputSizePixel() );
2102 Point
aBottomRight( aViewWin
.PixelToLogic( Point( aTmpSize
.Width(), aTmpSize
.Height() ) ) );
2103 SetVisArea( Rectangle( Point(), aBottomRight
) );
2105 //Aufruf der DocSzChgd-Methode der Scrollbars ist noetig, da vom maximalen
2106 //Scrollrange immer die halbe Hoehe der VisArea abgezogen wird.
2111 /*--------------------------------------------------------------------
2113 --------------------------------------------------------------------*/
2116 void SwPagePreView::SetVisArea( const Rectangle
&rRect
, BOOL bUpdateScrollbar
)
2118 const Point
aTopLeft(AlignToPixel(rRect
.TopLeft()));
2119 const Point
aBottomRight(AlignToPixel(rRect
.BottomRight()));
2120 Rectangle
aLR(aTopLeft
,aBottomRight
);
2124 // keine negative Position, keine neg. Groesse
2128 aLR
.Bottom() += Abs(aLR
.Top());
2134 aLR
.Right() += Abs(aLR
.Left());
2137 if(aLR
.Right() < 0) aLR
.Right() = 0;
2138 if(aLR
.Bottom() < 0) aLR
.Bottom() = 0;
2139 if(aLR
== aVisArea
||
2140 // JP 29.10.97: Bug 45173 - Leeres Rechteck nicht beachten
2141 ( 0 == aLR
.Bottom() - aLR
.Top() && 0 == aLR
.Right() - aLR
.Left() ) )
2144 if( aLR
.Left() > aLR
.Right() || aLR
.Top() > aLR
.Bottom() )
2147 //Bevor die Daten veraendert werden ggf. ein Update rufen. Dadurch wird
2148 //sichergestellt, da? anliegende Paints korrekt in Dokumentkoordinaten
2149 //umgerechnet werden.
2150 //Vorsichtshalber tun wir das nur wenn an der Shell eine Action laeuft,
2151 //denn dann wir nicht wirklich gepaintet sondern die Rechtecke werden
2152 //lediglich (in Dokumentkoordinaten) vorgemerkt.
2153 if( GetViewShell()->ActionPend() )
2156 // setze am View-Win die aktuelle Size
2158 aViewWin
.SetWinSize( aLR
.GetSize() );
2159 // OD 18.12.2002 #103492# - use new mode
2160 ChgPage( SwPagePreViewWin::MV_NEWWINSIZE
, bUpdateScrollbar
);
2162 aViewWin
.Invalidate();
2165 /*--------------------------------------------------------------------
2167 --------------------------------------------------------------------*/
2170 IMPL_LINK( SwPagePreView
, ScrollHdl
, SwScrollbar
*, pScrollbar
)
2174 if( !pScrollbar
->IsHoriScroll() &&
2175 pScrollbar
->GetType() == SCROLL_DRAG
&&
2176 Help::IsQuickHelpEnabled() &&
2177 GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
2179 // wieviele Seiten scrollen ??
2180 String
sStateStr(sPageStr
);
2181 USHORT nThmbPos
= (USHORT
)pScrollbar
->GetThumbPos();
2182 if( 1 == aViewWin
.GetCol() || !nThmbPos
)
2184 sStateStr
+= String::CreateFromInt32( nThmbPos
);
2185 Point aPos
= pScrollbar
->GetParent()->OutputToScreenPixel(
2186 pScrollbar
->GetPosPixel());
2187 aPos
.Y() = pScrollbar
->OutputToScreenPixel(pScrollbar
->GetPointerPosPixel()).Y();
2188 Size aSize
= pScrollbar
->GetSizePixel();
2190 aRect
.Left() = aPos
.X() -8;
2191 aRect
.Right() = aRect
.Left();
2192 aRect
.Top() = aPos
.Y();
2193 aRect
.Bottom() = aRect
.Top();
2195 Help::ShowQuickHelp(pScrollbar
, aRect
, sStateStr
,
2196 QUICKHELP_RIGHT
|QUICKHELP_VCENTER
);
2200 EndScrollHdl( pScrollbar
);
2204 /*--------------------------------------------------------------------
2206 --------------------------------------------------------------------*/
2209 IMPL_LINK( SwPagePreView
, EndScrollHdl
, SwScrollbar
*, pScrollbar
)
2214 // OD 04.03.2003 #107369# - boolean to avoid unnecessary invalidation of the window.
2215 bool bInvalidateWin
= true;
2217 if( !pScrollbar
->IsHoriScroll() ) // scroll vertically
2219 if ( Help::IsQuickHelpEnabled() )
2220 Help::ShowQuickHelp(pScrollbar
, Rectangle(), aEmptyStr
, 0);
2221 if ( GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow() )
2223 // wieviele Seiten scrollen ??
2224 USHORT nThmbPos
= (USHORT
)pScrollbar
->GetThumbPos();
2225 // OD 05.12.2002 #103492# - adjust to new preview functionality
2226 if( nThmbPos
!= aViewWin
.SelectedPage() )
2228 // OD 17.01.2003 #103492# - consider case that page <nThmbPos>
2229 // is already visible
2230 SwPagePreviewLayout
* pPagePrevwLay
= GetViewShell()->PagePreviewLayout();
2231 if ( pPagePrevwLay
->IsPageVisible( nThmbPos
) )
2233 pPagePrevwLay
->MarkNewSelectedPage( nThmbPos
);
2234 // OD 04.03.2003 #107369# - invalidation of window is unnecessary
2235 bInvalidateWin
= false;
2239 // OD 17.01.2003 #103492# - consider whether layout columns
2241 if ( !pPagePrevwLay
->DoesPreviewLayoutColsFitIntoWindow() )
2243 aViewWin
.SetSttPage( nThmbPos
);
2244 aViewWin
.SetSelectedPage( nThmbPos
);
2245 ChgPage( SwPagePreViewWin::MV_SCROLL
, FALSE
);
2246 // OD 20.01.2003 #103492# - update scrollbars
2251 // OD 04.03.2003 #107369# - correct scroll amount
2252 const sal_Int16 nPageDiff
= nThmbPos
- aViewWin
.SelectedPage();
2253 const sal_uInt16 nVisPages
= aViewWin
.GetRow() * aViewWin
.GetCol();
2254 sal_Int16 nWinPagesToScroll
= nPageDiff
/ nVisPages
;
2255 if ( nPageDiff
% nVisPages
)
2257 // decrease/increase number of preview pages to scroll
2258 nPageDiff
< 0 ? --nWinPagesToScroll
: ++nWinPagesToScroll
;
2260 aViewWin
.SetSelectedPage( nThmbPos
);
2261 aViewWin
.Scroll( 0, pPagePrevwLay
->GetWinPagesScrollAmount( nWinPagesToScroll
) );
2264 // OD 17.01.2003 #103492# - update accessibility
2265 GetViewShell()->ShowPreViewSelection( nThmbPos
);
2269 // OD 04.03.2003 #107369# - invalidation of window is unnecessary
2270 bInvalidateWin
= false;
2275 long nThmbPos
= pScrollbar
->GetThumbPos();
2276 aViewWin
.Scroll(0, nThmbPos
- aViewWin
.GetPaintedPreviewDocRect().Top());
2281 long nThmbPos
= pScrollbar
->GetThumbPos();
2282 aViewWin
.Scroll(nThmbPos
- aViewWin
.GetPaintedPreviewDocRect().Left(), 0);
2284 // OD 24.03.2003 #108282# - additional invalidate page status.
2285 static USHORT __READONLY_DATA aInval
[] =
2287 FN_START_OF_DOCUMENT
, FN_END_OF_DOCUMENT
, FN_PAGEUP
, FN_PAGEDOWN
,
2290 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
2291 rBindings
.Invalidate( aInval
);
2292 // OD 04.03.2003 #107369# - control invalidation of window
2293 if ( bInvalidateWin
)
2295 aViewWin
.Invalidate();
2299 /*--------------------------------------------------------------------
2301 --------------------------------------------------------------------*/
2304 Point
SwPagePreView::AlignToPixel(const Point
&rPt
) const
2306 return aViewWin
.PixelToLogic( aViewWin
.LogicToPixel( rPt
) );
2309 /*--------------------------------------------------------------------
2311 --------------------------------------------------------------------*/
2314 void SwPagePreView::DocSzChgd( const Size
&rSz
)
2321 // die neue Anzahl von Seiten bestimmen
2322 USHORT nNewCnt
= GetViewShell()->GetNumPages();
2323 if( nNewCnt
== mnPageCount
)
2326 // dann eine neue Startseite berechnen
2327 mnPageCount
= nNewCnt
;
2328 if( aVisArea
.GetWidth() )
2330 ChgPage( SwPagePreViewWin::MV_CALC
, TRUE
);
2333 aViewWin
.Invalidate();
2337 /*--------------------------------------------------------------------
2339 --------------------------------------------------------------------*/
2342 void SwPagePreView::ScrollViewSzChg()
2348 if(GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
2350 //vertical scrolling by row
2351 // OD 04.12.2002 #103492# - adjust to new preview functionality
2352 USHORT nVisPages
= aViewWin
.GetRow() * aViewWin
.GetCol();
2353 pVScrollbar
->SetVisibleSize( nVisPages
);
2354 // OD 19.02.2003 #107369# - set selected page as scroll bar position,
2355 // if it is visible.
2356 SwPagePreviewLayout
* pPagePrevwLay
= GetViewShell()->PagePreviewLayout();
2357 if ( pPagePrevwLay
->IsPageVisible( aViewWin
.SelectedPage() ) )
2359 pVScrollbar
->SetThumbPos( aViewWin
.SelectedPage() );
2363 pVScrollbar
->SetThumbPos( aViewWin
.GetSttPage() );
2365 pVScrollbar
->SetLineSize( aViewWin
.GetCol() );
2366 pVScrollbar
->SetPageSize( nVisPages
);
2367 // calculate and set scrollbar range
2368 Range
aScrollbarRange( 1, mnPageCount
);
2369 // increase range by one, because left-top-corner is left blank.
2370 ++aScrollbarRange
.Max();
2371 // OD 17.01.2003 #103492# - increase range in order to access all pages
2372 aScrollbarRange
.Max() += ( nVisPages
- 1 );
2373 pVScrollbar
->SetRange( aScrollbarRange
);
2375 else //vertical scrolling by pixel
2377 const Rectangle
& rDocRect
= aViewWin
.GetPaintedPreviewDocRect();
2378 const Size
& rPreviewSize
=
2379 GetViewShell()->PagePreviewLayout()->GetPrevwDocSize();
2380 pVScrollbar
->SetRangeMax(rPreviewSize
.Height()) ;
2381 long nVisHeight
= rDocRect
.GetHeight();
2382 pVScrollbar
->SetVisibleSize( nVisHeight
);
2383 pVScrollbar
->SetThumbPos( rDocRect
.Top() );
2384 pVScrollbar
->SetLineSize( nVisHeight
/ 10 );
2385 pVScrollbar
->SetPageSize( nVisHeight
/ 2 );
2390 const Rectangle
& rDocRect
= aViewWin
.GetPaintedPreviewDocRect();
2391 const Size
& rPreviewSize
=
2392 GetViewShell()->PagePreviewLayout()->GetPrevwDocSize();
2397 if(rDocRect
.GetWidth() < rPreviewSize
.Width())
2399 nVisWidth
= rDocRect
.GetWidth();
2400 nThumb
= rDocRect
.Left();
2401 aRange
= Range(0, rPreviewSize
.Width());
2403 pHScrollbar
->SetRange( aRange
);
2404 pHScrollbar
->SetVisibleSize( nVisWidth
);
2405 pHScrollbar
->SetThumbPos( nThumb
);
2406 pHScrollbar
->SetLineSize( nVisWidth
/ 10 );
2407 pHScrollbar
->SetPageSize( nVisWidth
/ 2 );
2411 /*--------------------------------------------------------------------
2413 --------------------------------------------------------------------*/
2416 void SwPagePreView::ScrollDocSzChg()
2423 /*--------------------------------------------------------------------
2425 --------------------------------------------------------------------*/
2428 // alles zum Thema Drucken
2430 USHORT
SwPagePreView::Print( SfxProgress
&rProgress
, BOOL bIsAPI
, PrintDialog
*pDlg
)
2432 ViewShell
* pSh
= aViewWin
.GetViewShell();
2433 SfxPrinter
* pPrinter
= GetPrinter();
2434 if( !pPrinter
|| !pPrinter
->InitJob( &aViewWin
,
2435 pSh
->HasDrawView() && !bIsAPI
&& pSh
->GetDrawView()->GetModel()->HasTransparentObjects() ))
2436 return ERRCODE_IO_ABORT
;
2438 SwWait
aWait( *GetDocShell(), TRUE
);
2440 USHORT nRowCol
= ( aViewWin
.GetRow() << 8 ) +
2441 aViewWin
.GetCol(); // Zeilen / DoppelSeiten
2444 // die Felder aktualisieren
2445 // ACHTUNG: hochcasten auf die EditShell, um die SS zu nutzen.
2446 // In den Methoden wird auf die akt. Shell abgefragt!
2447 SwEditShell
* pESh
= (SwEditShell
*)pSh
;
2449 BOOL bIsModified
= pESh
->IsModified();
2451 pESh
->StartAllAction();
2452 pESh
->UpdateDocStat( aDocStat
);
2454 pESh
->EndAllAction();
2457 pESh
->ResetModified();
2460 // Druckauftrag starten
2461 SfxObjectShell
*pObjShell
= GetViewFrame()->GetObjectShell();
2462 SwPrtOptions
aOpts( pObjShell
->GetTitle(0) );
2466 SwView::MakeOptions( pDlg
, aOpts
, &bPrtPros
, &bPrtPros_RTL
, FALSE
, GetPrinter(), GetDocShell()->GetDoc()->getPrintData() );
2471 pSh
->PrintProspect( aOpts
, rProgress
, bPrtPros_RTL
);
2473 pSh
->Prt( aOpts
, &rProgress
);
2477 const SwPagePreViewPrtData
* pPPVPD
= pSh
->GetDoc()->GetPreViewPrtData();
2478 if( pPPVPD
&& pPPVPD
->GetCol() && pPPVPD
->GetRow() )
2481 nRowCol
= ( pPPVPD
->GetRow() << 8 ) + pPPVPD
->GetCol();
2485 pSh
->PrintPreViewPage( aOpts
, nRowCol
, rProgress
, pPPVPD
);
2491 /*--------------------------------------------------------------------
2493 --------------------------------------------------------------------*/
2496 SfxPrinter
* SwPagePreView::GetPrinter( BOOL bCreate
)
2498 return aViewWin
.GetViewShell()->getIDocumentDeviceAccess()->getPrinter( bCreate
);
2501 /*--------------------------------------------------------------------
2503 --------------------------------------------------------------------*/
2506 USHORT
SwPagePreView::SetPrinter( SfxPrinter
*pNew
, USHORT nDiffFlags
, bool )
2508 ViewShell
&rSh
= *GetViewShell();
2509 SwEditShell
&rESh
= (SwEditShell
&)rSh
; //Buh...
2510 if( ( SFX_PRINTER_PRINTER
| SFX_PRINTER_JOBSETUP
) & nDiffFlags
)
2512 rSh
.getIDocumentDeviceAccess()->setPrinter( pNew
, true, true );
2513 if( nDiffFlags
& SFX_PRINTER_PRINTER
)
2516 if ( ( nDiffFlags
& SFX_PRINTER_OPTIONS
) == SFX_PRINTER_OPTIONS
)
2517 ::SetPrinter( rSh
.getIDocumentDeviceAccess(), pNew
, FALSE
);
2519 const BOOL bChgOri
= nDiffFlags
& SFX_PRINTER_CHG_ORIENTATION
? TRUE
: FALSE
;
2520 const BOOL bChgSize
= nDiffFlags
& SFX_PRINTER_CHG_SIZE
? TRUE
: FALSE
;
2521 if ( bChgOri
|| bChgSize
)
2523 rESh
.StartAllAction();
2525 rSh
.ChgAllPageOrientation( USHORT(pNew
->GetOrientation()) );
2528 Size
aSz( SvxPaperInfo::GetPaperSize( pNew
) );
2529 rSh
.ChgAllPageSize( aSz
);
2532 aViewWin
.CalcWish( aViewWin
.GetRow(), aViewWin
.GetCol() );
2534 rESh
.EndAllAction();
2536 static USHORT __READONLY_DATA aInval
[] =
2538 SID_ATTR_LONG_ULSPACE
, SID_ATTR_LONG_LRSPACE
,
2539 SID_RULER_BORDERS
, SID_RULER_PAGE_POS
, 0
2543 const USHORT
* pPtr
= aInval
+ 1;
2545 ASSERT( *(pPtr
- 1) < *pPtr
, "falsche Sortierung!" );
2550 GetViewFrame()->GetBindings().Invalidate(aInval
);
2556 /*--------------------------------------------------------------------
2558 --------------------------------------------------------------------*/
2561 SfxTabPage
* SwPagePreView::CreatePrintOptionsPage( Window
*pParent
,
2562 const SfxItemSet
&rOptions
)
2564 return ::CreatePrintOptionsPage( pParent
, rOptions
, !bNormalPrint
);
2567 /*--------------------------------------------------------------------
2569 --------------------------------------------------------------------*/
2572 PrintDialog
* SwPagePreView::CreatePrintDialog( Window
*pParent
)
2574 PrintDialog
*pDlg
= ::CreatePrintDialog( pParent
, 1, 0 );
2575 pDlg
->DisableRange( PRINTDIALOG_SELECTION
);
2579 /*--------------------------------------------------------------------
2581 --------------------------------------------------------------------*/
2584 // OD 18.12.2002 #103492# - no longer needed ??
2585 Size
SwPagePreView::GetOptimalSizePixel() const
2587 ASSERT( false, "overloaded virtual method <SwPagePreView::GetOptimalSizePixel()> needed ??" )
2588 return Size( -1, -1 );
2590 //JP 09.06.99: was wird hier errechnet ?????
2592 // SfxApplicationWindow* pWin = SFX_APPWINDOW ;
2593 // Rectangle aRect = pWin->GetClientAreaPixel();
2595 Window& rWin = GetViewFrame()->GetWindow();
2596 Rectangle aRect( Point(0, 0), rWin.GetOutputSizePixel() );
2597 Size aMaxSize( aRect.GetWidth(), aRect.GetHeight() );
2598 Size aInSize = rWin.GetOutputSizePixel();
2599 Size aOutSize = rWin.GetSizePixel();
2600 USHORT nXBorder = USHORT(aOutSize.Width() - aInSize.Width());
2601 USHORT nYBorder = USHORT(aOutSize.Height() - aInSize.Height());
2602 aMaxSize.Width() -= nXBorder;
2603 //'auf Verdacht' etwas vom Border abziehen (Menue)
2604 nYBorder -= (nYBorder - nXBorder) / 2;
2605 aMaxSize.Height() -= nYBorder;
2606 //mit der max. moeglichen Outputsize guenstigstes Verhaeltnis ausrechnen
2607 aViewWin.GetOptimalSize(aMaxSize);
2608 // Border wieder dazuzaehlen
2609 aMaxSize.Height() += nYBorder;
2610 aMaxSize.Width() += nXBorder;
2615 /*--------------------------------------------------------------------
2617 --------------------------------------------------------------------*/
2619 // OD 12.12.2002 #103492#
2620 void SwPagePreViewWin::SetViewShell( ViewShell
* pShell
)
2622 mpViewShell
= pShell
;
2623 if ( mpViewShell
&& mpViewShell
->IsPreView() )
2625 mpPgPrevwLayout
= mpViewShell
->PagePreviewLayout();
2629 void SwPagePreViewWin::RepaintCoreRect( const SwRect
& rRect
)
2631 // OD 2004-03-04 #i24183#
2632 if ( mpPgPrevwLayout
->PreviewLayoutValid() )
2634 mpPgPrevwLayout
->Repaint( Rectangle( rRect
.Pos(), rRect
.SSize() ) );
2638 /** method to adjust preview to a new zoom factor
2640 OD 02.12.2002 #103492#
2641 OD 24.09.2003 #i19975# - also consider zoom type - adding parameter <_eZoomType>
2643 void SwPagePreViewWin::AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor
,
2644 const SvxZoomType _eZoomType
)
2646 // OD 24.09.2003 #i19975# - consider zoom type
2647 if ( _eZoomType
== SVX_ZOOM_WHOLEPAGE
)
2651 mpPgPrevwLayout
->Init( mnCol
, mnRow
, maPxWinSize
, true );
2652 mpPgPrevwLayout
->Prepare( mnSttPage
, Point(0,0), maPxWinSize
,
2653 mnSttPage
, maPaintedPreviewDocRect
);
2654 SetSelectedPage( mnSttPage
);
2655 SetPagePreview(mnRow
, mnCol
);
2656 maScale
= GetMapMode().GetScaleX();
2658 else if ( _nZoomFactor
!= 0 )
2660 // calculate new scaling and set mapping mode appropriately.
2661 Fraction
aNewScale( _nZoomFactor
, 100 );
2662 MapMode aNewMapMode
= GetMapMode();
2663 aNewMapMode
.SetScaleX( aNewScale
);
2664 aNewMapMode
.SetScaleY( aNewScale
);
2665 SetMapMode( aNewMapMode
);
2667 // calculate new start position for preview paint
2668 Size aNewWinSize
= PixelToLogic( maPxWinSize
);
2669 Point aNewPaintStartPos
=
2670 mpPgPrevwLayout
->GetPreviewStartPosForNewScale( aNewScale
, maScale
, aNewWinSize
);
2672 // remember new scaling and prepare preview paint
2673 // Note: paint of preview will be performed by a corresponding invalidate
2674 // due to property changes.
2675 maScale
= aNewScale
;
2676 mpPgPrevwLayout
->Prepare( 0, aNewPaintStartPos
, maPxWinSize
,
2677 mnSttPage
, maPaintedPreviewDocRect
);
2681 /* -----------------04.12.2002 10:46-----------------
2682 * pixel scrolling - horizontally always or vertically
2683 * when less than the desired number of rows fits into
2685 * --------------------------------------------------*/
2686 void SwPagePreViewWin::Scroll(long nXMove
, long nYMove
, USHORT
/*nFlags*/)
2688 maPaintedPreviewDocRect
.Move(nXMove
, nYMove
);
2689 mpPgPrevwLayout
->Prepare( 0, maPaintedPreviewDocRect
.TopLeft(),
2690 maPxWinSize
, mnSttPage
,
2691 maPaintedPreviewDocRect
);
2695 BOOL
SwPagePreView::HandleWheelCommands( const CommandEvent
& rCEvt
)
2698 const CommandWheelData
* pWData
= rCEvt
.GetWheelData();
2699 if( pWData
&& COMMAND_WHEEL_ZOOM
== pWData
->GetMode() )
2701 if(!Application::GetSettings().GetMiscSettings().GetEnableATToolSupport())
2703 USHORT nFactor
= GetViewShell()->GetViewOptions()->GetZoom();
2704 const USHORT nOffset
= 10;
2705 if( 0L > pWData
->GetDelta() )
2708 if(nFactor
< MIN_PREVIEW_ZOOM
)
2709 nFactor
= MIN_PREVIEW_ZOOM
;
2714 if(nFactor
> MAX_PREVIEW_ZOOM
)
2715 nFactor
= MAX_PREVIEW_ZOOM
;
2717 SetZoom(SVX_ZOOM_PERCENT
, nFactor
);
2722 bOk
= aViewWin
.HandleScrollCommand( rCEvt
, pHScrollbar
, pVScrollbar
);
2727 uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
2728 SwPagePreViewWin::CreateAccessible()
2730 vos::OGuard
aGuard(Application::GetSolarMutex()); // this should have
2731 // happend already!!!
2733 DBG_ASSERT( GetViewShell() != NULL
, "We need a view shell" );
2734 return GetViewShell()->CreateAccessiblePreview();
2737 /* -----------------------------06.05.2002 13:18------------------------------
2739 ---------------------------------------------------------------------------*/
2740 void SwPagePreView::ApplyAccessiblityOptions(SvtAccessibilityOptions
& rAccessibilityOptions
)
2742 GetViewShell()->ApplyAccessiblityOptions(rAccessibilityOptions
);
2744 /* -----------------------------2002/06/26 14:30------------------------------
2746 ---------------------------------------------------------------------------*/
2747 void SwPagePreView::ShowHScrollbar(sal_Bool bShow
)
2749 pHScrollbar
->Show(bShow
);
2753 /* -----------------------------2002/06/26 14:30------------------------------
2755 ---------------------------------------------------------------------------*/
2756 void SwPagePreView::ShowVScrollbar(sal_Bool bShow
)
2758 pVScrollbar
->Show(bShow
);
2762 /* -----------------25.11.2002 16:36-----------------
2764 * --------------------------------------------------*/
2765 void SwPagePreView::SetZoom(SvxZoomType eType
, USHORT nFactor
)
2767 ViewShell
& rSh
= *GetViewShell();
2768 SwViewOption
aOpt(*rSh
.GetViewOptions());
2769 // OD 16.12.2002 #103492# - perform action only on changes of zoom or zoom type.
2770 if ( aOpt
.GetZoom() != nFactor
||
2771 aOpt
.GetZoomType() != eType
)
2773 aOpt
.SetZoom(nFactor
);
2774 aOpt
.SetZoomType(eType
);
2775 rSh
.ApplyViewOptions( aOpt
);
2776 lcl_InvalidateZoomSlots(GetViewFrame()->GetBindings());
2777 // OD 02.12.2002 #103492#
2778 // OD 24.09.2003 #i19975# - also consider zoom type
2779 aViewWin
.AdjustPreviewToNewZoom( nFactor
, eType
);
2784 /** adjust position of vertical scrollbar
2786 OD 19.02.2003 #107369
2790 void SwPagePreView::SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos
)
2794 pVScrollbar
->SetThumbPos( _nNewThumbPos
);