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 #include <vcl/button.hxx>
43 #include <svtools/printdlg.hxx>
44 #include <svtools/whiter.hxx>
45 #include <svtools/stritem.hxx>
46 #include <svtools/eitem.hxx>
47 #include <sfx2/printer.hxx>
48 #include <sfx2/app.hxx>
49 #include <sfx2/topfrm.hxx>
50 #include <sfx2/bindings.hxx>
51 #include <sfx2/request.hxx>
52 #include <sfx2/dispatch.hxx>
53 #include <vcl/msgbox.hxx>
54 #include <svx/stddlg.hxx>
55 #include <svx/paperinf.hxx>
56 #include <svx/srchitem.hxx>
57 #include <svx/svdview.hxx>
58 #include <svx/dlgutil.hxx>
59 #include <svx/zoomslideritem.hxx>
60 #ifndef _SVX_SVXIDS_HRC //autogen
61 #include <svx/svxids.hrc>
66 #include <globdoc.hxx>
68 #include <pvprtdat.hxx>
69 #include <swmodule.hxx>
73 #include <viewopt.hxx>
79 #include <swprtopt.hxx>
80 #include <docstat.hxx>
81 #include <usrpref.hxx>
82 #include <viewfunc.hxx>
92 #include <globals.hrc>
101 #define SwPagePreView
102 #include <sfx2/msg.hxx>
103 #include <swslots.hxx>
104 // OD 12.12.2002 #103492#
105 #include <pagepreviewlayout.hxx>
107 #include <svx/svxdlg.hxx>
108 #include <svx/dialogs.hrc>
109 #include <vos/mutex.hxx>
111 using namespace ::com::sun::star
;
114 SFX_IMPL_VIEWFACTORY(SwPagePreView
, SW_RES(STR_NONAME
))
116 SFX_VIEW_REGISTRATION(SwDocShell
);
117 SFX_VIEW_REGISTRATION(SwWebDocShell
);
118 SFX_VIEW_REGISTRATION(SwGlobalDocShell
);
121 SFX_IMPL_INTERFACE(SwPagePreView
, SfxViewShell
, SW_RES(RID_PVIEW_TOOLBOX
))
123 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_PPREVIEW_POPUPMENU
));
124 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT
|SFX_VISIBILITY_STANDARD
|
125 SFX_VISIBILITY_CLIENT
|SFX_VISIBILITY_FULLSCREEN
|
126 SFX_VISIBILITY_READONLYDOC
,
127 SW_RES(RID_PVIEW_TOOLBOX
));
131 TYPEINIT1(SwPagePreView
,SfxViewShell
)
133 #define SWVIEWFLAGS ( SFX_VIEW_MAXIMIZE_FIRST|SFX_VIEW_OPTIMIZE_EACH| \
134 SFX_VIEW_CAN_PRINT|SFX_VIEW_HAS_PRINTOPTIONS )
136 #define MIN_PREVIEW_ZOOM 25
137 #define MAX_PREVIEW_ZOOM 600
139 /* -----------------26.11.2002 10:41-----------------
141 * --------------------------------------------------*/
142 USHORT
lcl_GetNextZoomStep(USHORT nCurrentZoom
, BOOL bZoomIn
)
144 static USHORT aZoomArr
[] =
146 25, 50, 75, 100, 150, 200, 400, 600
148 const sal_uInt16 nZoomArrSize
= sizeof(aZoomArr
)/sizeof(USHORT
);
150 for(int i
= nZoomArrSize
- 1; i
>= 0; --i
)
152 if(nCurrentZoom
> aZoomArr
[i
] || !i
)
156 for(int i
= 0; i
< nZoomArrSize
; ++i
)
158 if(nCurrentZoom
< aZoomArr
[i
])
161 return bZoomIn
? MAX_PREVIEW_ZOOM
: MIN_PREVIEW_ZOOM
;
163 /* -----------------02.12.2002 09:11-----------------
165 * --------------------------------------------------*/
166 void lcl_InvalidateZoomSlots(SfxBindings
& rBindings
)
168 static USHORT __READONLY_DATA aInval
[] =
170 SID_ATTR_ZOOM
, SID_ZOOM_OUT
, SID_ZOOM_IN
, SID_ATTR_ZOOMSLIDER
, FN_PREVIEW_ZOOM
, FN_STAT_ZOOM
,
173 rBindings
.Invalidate( aInval
);
175 /*--------------------------------------------------------------------
177 --------------------------------------------------------------------*/
179 // erstmal der Zoom-Dialog
181 class SwPreViewZoomDlg
: public SvxStandardDialog
184 NumericField aRowEdit
;
186 NumericField aColEdit
;
189 CancelButton aCancelBtn
;
192 virtual void Apply();
195 SwPreViewZoomDlg( SwPagePreViewWin
& rParent
);
199 /*--------------------------------------------------------------------
201 --------------------------------------------------------------------*/
204 SwPreViewZoomDlg::SwPreViewZoomDlg( SwPagePreViewWin
& rParent
) :
205 SvxStandardDialog( &rParent
, SW_RES(DLG_PAGEPREVIEW_ZOOM
) ),
206 aRowLbl(this,SW_RES(FT_ROW
)),
207 aRowEdit(this,SW_RES(ED_ROW
)),
208 aColLbl(this,SW_RES(FT_COL
)),
209 aColEdit(this,SW_RES(ED_COL
)),
210 aOkBtn(this,SW_RES(BT_OK
)),
211 aCancelBtn(this,SW_RES(BT_CANCEL
)),
212 aHelpBtn(this,SW_RES(BT_HELP
))
216 aRowEdit
.SetValue( rParent
.GetRow() );
217 aColEdit
.SetValue( rParent
.GetCol() );
220 /*--------------------------------------------------------------------
222 --------------------------------------------------------------------*/
225 SwPreViewZoomDlg::~SwPreViewZoomDlg() {}
228 void SwPreViewZoomDlg::Apply()
230 ((SwPagePreViewWin
*)GetParent())->CalcWish(
231 BYTE(aRowEdit
.GetValue()),
232 BYTE(aColEdit
.GetValue()) );
236 /* -----------------20.08.98 15:25-------------------
237 * Vorschau fuer den Seitendruck
238 * --------------------------------------------------*/
239 struct PrintSettingsStruct
;
240 class PrtPrvWindow
: public Window
242 const PrintSettingsStruct
& rSettings
;
244 virtual void Paint(const Rectangle
&);
246 PrtPrvWindow(Window
* pParent
, const ResId
& rResId
, const PrintSettingsStruct
& rSett
) :
247 Window(pParent
, rResId
), rSettings(rSett
){}
249 /*--------------------------------------------------------------------
250 Beschreibung: Optionen fuer das Drucken der Preview
251 --------------------------------------------------------------------*/
252 struct PrintSettingsStruct
254 Size aPageMaxSize
; // groesste Seite
255 Size aPrtSize
; // Papiergroesse
256 Size aPrvPrtSize
; // Groesse innerhalb der LRTB-Raender
257 Size aGridSize
; // Groesse fuer jede Seite, enthaelt je
258 // die Haelfte von H- und V-Distance
270 BOOL bPrinterLandscape
; // Ausrichtung
273 class SwPreviewPrintOptionsDialog
: public SvxStandardDialog
277 NumericField aRowsNF
;
279 NumericField aColsNF
;
283 MetricField aLSpaceMF
;
285 MetricField aRSpaceMF
;
287 MetricField aTSpaceMF
;
289 MetricField aBSpaceMF
;
290 FixedLine aDistanceFL
;
292 MetricField aHSpaceMF
;
294 MetricField aVSpaceMF
;
296 RadioButton aLandscapeRB
;
297 RadioButton aPortraitRB
;
298 FixedLine aOrientationFL
;
300 PrtPrvWindow aPreviewWin
;
303 CancelButton aCancelBtn
;
306 PushButton aStandardPB
;
308 SwPagePreView
& rPreView
;
309 SwPagePreViewWin
& rParentWin
;
310 PrintSettingsStruct aSettings
;
311 /* Size aPageMaxSize;
318 virtual void Apply();
319 void FillControls(SwPagePreViewPrtData
& rData
);
321 DECL_LINK( ModifyHdl
, Edit
* );
322 DECL_LINK( StandardHdl
, PushButton
* );
325 SwPreviewPrintOptionsDialog(SwPagePreViewWin
& rParent
, SwPagePreView
& rView
);
326 ~SwPreviewPrintOptionsDialog();
329 /* -----------------19.08.98 13:35-------------------
331 * --------------------------------------------------*/
332 SwPreviewPrintOptionsDialog::SwPreviewPrintOptionsDialog( SwPagePreViewWin
& rParent
, SwPagePreView
& rView
) :
333 SvxStandardDialog( &rParent
, SW_RES(DLG_PAGEPREVIEW_PRINTOPTIONS
) ),
334 aRowColFL(this,SW_RES( FL_ROWCOL
)),
335 aRowsFT(this,SW_RES( FT_ROWS
)),
336 aRowsNF(this,SW_RES( NF_ROWS
)),
337 aColsFT(this,SW_RES( FT_COLS
)),
338 aColsNF(this,SW_RES( NF_COLS
)),
339 aMarginFL(this,SW_RES( FL_MARGINS
)),
340 aLSpaceFT(this,SW_RES( FT_LMARGIN
)),
341 aLSpaceMF(this,SW_RES( MF_LMARGIN
)),
342 aRSpaceFT(this,SW_RES( FT_RMARGIN
)),
343 aRSpaceMF(this,SW_RES( MF_RMARGIN
)),
344 aTSpaceFT(this,SW_RES( FT_TMARGIN
)),
345 aTSpaceMF(this,SW_RES( MF_TMARGIN
)),
346 aBSpaceFT(this,SW_RES( FT_BMARGIN
)),
347 aBSpaceMF(this,SW_RES( MF_BMARGIN
)),
348 aDistanceFL(this,SW_RES(FL_DISTANCE
)),
349 aHSpaceFT(this,SW_RES( FT_HMARGIN
)),
350 aHSpaceMF(this,SW_RES( MF_HMARGIN
)),
351 aVSpaceFT(this,SW_RES( FT_VMARGIN
)),
352 aVSpaceMF(this,SW_RES( MF_VMARGIN
)),
353 aLandscapeRB(this,SW_RES( RB_LANDSCAPE
)),
354 aPortraitRB(this,SW_RES( RB_PORTRAIT
)),
355 aOrientationFL(this,SW_RES( FL_ORIENTATION
)),
356 aPreviewWin(this,SW_RES( WIN_PREVIEW
), aSettings
),
357 aOkBtn(this,SW_RES(BT_OK
)),
358 aCancelBtn(this,SW_RES(BT_CANCEL
)),
359 aHelpBtn(this,SW_RES(BT_HELP
)),
360 aStandardPB(this,SW_RES(PB_STANDARD
)),
366 ViewShell
& rViewSh
= *rPreView
.GetViewShell();
367 // OD 18.12.2002 #103492#
368 aSettings
.aPageMaxSize
= rViewSh
.PagePreviewLayout()->GetMaxPageSize();
369 SfxPrinter
* pPrinter
= rViewSh
.getIDocumentDeviceAccess()->getPrinter( true );
370 aSettings
.aPrtSize
= pPrinter
->GetPaperSize();
371 //#97682# make sure that no division by zero occurs
372 if(!aSettings
.aPrtSize
.Width() || !aSettings
.aPrtSize
.Height())
373 aSettings
.aPrtSize
= SvxPaperInfo::GetPaperSize(PAPER_A4
);
374 aSettings
.bPrinterLandscape
= pPrinter
->GetOrientation() == ORIENTATION_LANDSCAPE
;
377 SwDocShell
* pDocShell
= rPreView
.GetDocShell();
378 const SwMasterUsrPref
*pUsrPref
= SW_MOD()->GetUsrPref(0 != PTR_CAST(SwWebDocShell
, pDocShell
));
379 FieldUnit eFieldUnit
= pUsrPref
->GetMetric();
380 ::SetFieldUnit( aLSpaceMF
, eFieldUnit
);
381 ::SetFieldUnit( aRSpaceMF
, eFieldUnit
);
382 ::SetFieldUnit( aTSpaceMF
, eFieldUnit
);
383 ::SetFieldUnit( aBSpaceMF
, eFieldUnit
);
384 ::SetFieldUnit( aHSpaceMF
, eFieldUnit
);
385 ::SetFieldUnit( aVSpaceMF
, eFieldUnit
);
387 SwDoc
* pDoc
= pDocShell
->GetDoc();
388 SwPagePreViewPrtData aData
;
389 if(pDoc
->GetPreViewPrtData())
391 aData
= *pDoc
->GetPreViewPrtData();
396 // Orientation der PreviewData an den Drucker anpassen
397 aData
.SetLandscape(aSettings
.bPrinterLandscape
);
398 aData
.SetRow(rParent
.GetRow());
399 aData
.SetCol(rParent
.GetCol());
403 aLSpaceMF
.SaveValue();
404 aRSpaceMF
.SaveValue();
405 aTSpaceMF
.SaveValue();
406 aBSpaceMF
.SaveValue();
407 aHSpaceMF
.SaveValue();
408 aVSpaceMF
.SaveValue();
411 aLandscapeRB
.SaveValue();
412 aPortraitRB
.SaveValue();
414 aStandardPB
.SetClickHdl(LINK(this, SwPreviewPrintOptionsDialog
, StandardHdl
));
415 Link aLk
= LINK(this, SwPreviewPrintOptionsDialog
, ModifyHdl
);
416 aLSpaceMF
.SetUpHdl(aLk
);
417 aRSpaceMF
.SetUpHdl(aLk
);
418 aTSpaceMF
.SetUpHdl(aLk
);
419 aBSpaceMF
.SetUpHdl(aLk
);
420 aHSpaceMF
.SetUpHdl(aLk
);
421 aVSpaceMF
.SetUpHdl(aLk
);
422 aRowsNF
.SetUpHdl(aLk
);
423 aColsNF
.SetUpHdl(aLk
);
424 aLSpaceMF
.SetDownHdl(aLk
);
425 aRSpaceMF
.SetDownHdl(aLk
);
426 aTSpaceMF
.SetDownHdl(aLk
);
427 aBSpaceMF
.SetDownHdl(aLk
);
428 aHSpaceMF
.SetDownHdl(aLk
);
429 aVSpaceMF
.SetDownHdl(aLk
);
430 aRowsNF
.SetDownHdl(aLk
);
431 aColsNF
.SetDownHdl(aLk
);
432 aLSpaceMF
.SetLoseFocusHdl(aLk
);
433 aRSpaceMF
.SetLoseFocusHdl(aLk
);
434 aTSpaceMF
.SetLoseFocusHdl(aLk
);
435 aBSpaceMF
.SetLoseFocusHdl(aLk
);
436 aHSpaceMF
.SetLoseFocusHdl(aLk
);
437 aVSpaceMF
.SetLoseFocusHdl(aLk
);
438 aRowsNF
.SetLoseFocusHdl(aLk
);
439 aColsNF
.SetLoseFocusHdl(aLk
);
440 aLandscapeRB
.SetClickHdl(aLk
);
441 aPortraitRB
.SetClickHdl(aLk
);
445 StandardHdl(&aStandardPB
);
449 /* -----------------19.08.98 13:36-------------------
451 * --------------------------------------------------*/
452 SwPreviewPrintOptionsDialog::~SwPreviewPrintOptionsDialog()
455 /* -----------------12.11.98 11:32-------------------
457 * --------------------------------------------------*/
458 void SwPreviewPrintOptionsDialog::FillControls(SwPagePreViewPrtData
& rData
)
460 aLSpaceMF
.SetValue(aLSpaceMF
.Normalize(rData
.GetLeftSpace() ), FUNIT_TWIP
);
461 aRSpaceMF
.SetValue(aRSpaceMF
.Normalize(rData
.GetRightSpace() ), FUNIT_TWIP
);
462 aTSpaceMF
.SetValue(aTSpaceMF
.Normalize(rData
.GetTopSpace() ), FUNIT_TWIP
);
463 aBSpaceMF
.SetValue(aBSpaceMF
.Normalize(rData
.GetBottomSpace()), FUNIT_TWIP
);
464 aHSpaceMF
.SetValue(aHSpaceMF
.Normalize(rData
.GetHorzSpace() ), FUNIT_TWIP
);
465 aVSpaceMF
.SetValue(aVSpaceMF
.Normalize(rData
.GetVertSpace() ), FUNIT_TWIP
);
466 aRowsNF
.SetValue(rData
.GetRow());
467 aColsNF
.SetValue(rData
.GetCol());
468 aSettings
.bPrinterLandscape
? aLandscapeRB
.Check() : aPortraitRB
.Check();
469 // wenn Drucker und Einstellungen nicht uebereinstimmen, dann Seiten tauschen
470 if( rData
.GetLandscape() != aSettings
.bPrinterLandscape
)
472 Size
aTmp(aSettings
.aPrtSize
.Height(), aSettings
.aPrtSize
.Width());
473 aSettings
.aPrtSize
= aTmp
;
474 aSettings
.bPrinterLandscape
= !aSettings
.bPrinterLandscape
;
475 // nochmal setzen, denn auch wenn nur die Default-Orientierung dem Drucker
476 // angepasst wurde, sollen die Einstellungen gespeichert werden
477 aSettings
.bPrinterLandscape
? aLandscapeRB
.Check() : aPortraitRB
.Check();
479 aLandscapeRB
.SaveValue();
480 aPortraitRB
.SaveValue();
482 aSettings
.nLeft
= rData
.GetLeftSpace() ;
483 aSettings
.nRight
= rData
.GetRightSpace() ;
484 aSettings
.nTop
= rData
.GetTopSpace() ;
485 aSettings
.nBottom
= rData
.GetBottomSpace();
486 aSettings
.nHori
= rData
.GetHorzSpace() ;
487 aSettings
.nVert
= rData
.GetVertSpace() ;
488 aSettings
.nRows
= rData
.GetRow() ;
489 aSettings
.nCols
= rData
.GetCol() ;
490 aSettings
.aPrvPrtSize
= aSettings
.aPrtSize
;
493 /* -----------------19.08.98 14:31-------------------
495 * --------------------------------------------------*/
496 void SwPreviewPrintOptionsDialog::Apply()
499 SwDoc
* pDoc
= rPreView
.GetDocShell()->GetDoc();
501 pDoc
->SetPreViewPrtData(0);
502 else if( aLSpaceMF
.GetSavedValue() != aLSpaceMF
.GetText() ||
503 aRSpaceMF
.GetSavedValue() != aRSpaceMF
.GetText() ||
504 aTSpaceMF
.GetSavedValue() != aTSpaceMF
.GetText() ||
505 aBSpaceMF
.GetSavedValue() != aBSpaceMF
.GetText() ||
506 aHSpaceMF
.GetSavedValue() != aHSpaceMF
.GetText() ||
507 aVSpaceMF
.GetSavedValue() != aVSpaceMF
.GetText() ||
508 aRowsNF
.GetSavedValue() != aRowsNF
.GetText() ||
509 aColsNF
.GetSavedValue() != aColsNF
.GetText() ||
510 aLandscapeRB
.GetSavedValue() != aLandscapeRB
.IsChecked() ||
511 aPortraitRB
.GetSavedValue() != aPortraitRB
.IsChecked() )
513 SwPagePreViewPrtData aData
;
514 if(pDoc
->GetPreViewPrtData())
515 aData
= *pDoc
->GetPreViewPrtData();
516 aData
.SetLeftSpace( static_cast< ULONG
>(aLSpaceMF
.Denormalize(aLSpaceMF
.GetValue(FUNIT_TWIP
))) );
517 aData
.SetRightSpace( static_cast< ULONG
>(aRSpaceMF
.Denormalize(aRSpaceMF
.GetValue(FUNIT_TWIP
))) );
518 aData
.SetTopSpace( static_cast< ULONG
>(aTSpaceMF
.Denormalize(aTSpaceMF
.GetValue(FUNIT_TWIP
))) );
519 aData
.SetBottomSpace( static_cast< ULONG
>(aBSpaceMF
.Denormalize(aBSpaceMF
.GetValue(FUNIT_TWIP
))) );
521 aData
.SetHorzSpace( static_cast< ULONG
>(aHSpaceMF
.Denormalize(aHSpaceMF
.GetValue(FUNIT_TWIP
))) );
522 aData
.SetVertSpace( static_cast< ULONG
>(aVSpaceMF
.Denormalize(aVSpaceMF
.GetValue(FUNIT_TWIP
))) );
523 aData
.SetRow((BYTE
)aRowsNF
.GetValue());
524 aData
.SetCol((BYTE
)aColsNF
.GetValue());
525 aData
.SetLandscape(aLandscapeRB
.IsChecked());
527 ViewShell
& rViewSh
= *rPreView
.GetViewShell();
528 SfxPrinter
* pPrinter
= rViewSh
.getIDocumentDeviceAccess()->getPrinter( true );
529 if((pPrinter
->GetOrientation() == ORIENTATION_LANDSCAPE
)
530 != aData
.GetLandscape())
531 pPrinter
->SetOrientation(aData
.GetLandscape() ? ORIENTATION_LANDSCAPE
: ORIENTATION_PORTRAIT
);
534 pDoc
->SetPreViewPrtData(&aData
);
538 /* -----------------20.08.98 08:48-------------------
540 * --------------------------------------------------*/
541 IMPL_LINK( SwPreviewPrintOptionsDialog
, ModifyHdl
, Edit
*, pEdit
)
543 if(bStandard
&& pEdit
)
545 aLSpaceMF
.SetUserValue(aLSpaceMF
.GetValue());
546 aRSpaceMF
.SetUserValue(aRSpaceMF
.GetValue());
547 aTSpaceMF
.SetUserValue(aTSpaceMF
.GetValue());
548 aBSpaceMF
.SetUserValue(aBSpaceMF
.GetValue());
549 aHSpaceMF
.SetUserValue(aHSpaceMF
.GetValue());
550 aVSpaceMF
.SetUserValue(aVSpaceMF
.GetValue());
551 aRowsNF
. SetUserValue(aRowsNF
.GetValue());
552 aColsNF
. SetUserValue(aColsNF
.GetValue());
556 BOOL bOrientChanged
= aSettings
.bPrinterLandscape
!= aLandscapeRB
.IsChecked();;
557 if(pEdit
== &aLSpaceMF
)
558 aSettings
.nLeft
= static_cast< long >(aLSpaceMF
.Denormalize(aLSpaceMF
.GetValue(FUNIT_TWIP
)));
559 else if(pEdit
== &aRSpaceMF
)
560 aSettings
.nRight
= static_cast< long >(aRSpaceMF
.Denormalize(aRSpaceMF
.GetValue(FUNIT_TWIP
)));
561 else if(pEdit
== &aTSpaceMF
)
562 aSettings
.nTop
= static_cast< long >(aTSpaceMF
.Denormalize(aTSpaceMF
.GetValue(FUNIT_TWIP
)));
563 else if(pEdit
== &aBSpaceMF
)
564 aSettings
.nBottom
= static_cast< long >(aBSpaceMF
.Denormalize(aBSpaceMF
.GetValue(FUNIT_TWIP
)));
565 else if(pEdit
== &aHSpaceMF
)
566 aSettings
.nHori
= static_cast< long >(aHSpaceMF
.Denormalize(aHSpaceMF
.GetValue(FUNIT_TWIP
)));
567 else if(pEdit
== &aVSpaceMF
)
568 aSettings
.nVert
= static_cast< long >(aVSpaceMF
.Denormalize(aVSpaceMF
.GetValue(FUNIT_TWIP
)));
569 else if(pEdit
== &aRowsNF
)
570 aSettings
.nRows
= (USHORT
)aRowsNF
.GetValue();
571 else if(pEdit
== &aColsNF
)
572 aSettings
.nCols
= (USHORT
)aColsNF
.GetValue();
573 else if(pEdit
== (Edit
*)&aLandscapeRB
)
574 aSettings
.bPrinterLandscape
= aLandscapeRB
.IsChecked();
575 else if(pEdit
== (Edit
*)&aPortraitRB
)
576 aSettings
.bPrinterLandscape
= aLandscapeRB
.IsChecked();
580 Size
aTmp(aSettings
.aPrtSize
.Height(), aSettings
.aPrtSize
.Width());
581 aSettings
.aPrtSize
= aTmp
;
585 aSettings
.aPrvPrtSize
= Size(aSettings
.aPrtSize
.Width() - aSettings
.nRight
- aSettings
.nLeft
,
586 aSettings
.aPrtSize
.Height() - aSettings
.nTop
- aSettings
.nBottom
);
587 aSettings
.aGridSize
= Size(aSettings
.aPrvPrtSize
.Width() / aSettings
.nCols
,
588 aSettings
.aPrvPrtSize
.Height() / aSettings
.nRows
);
589 // was fehlt noch: Orientation auswerten, minimalrand ausrechnen, Beispiel fuettern
592 //am Ende Maximalwerte setzen
593 long n20Percent
= aSettings
.aPrtSize
.Width() / 5;
594 aLSpaceMF
.SetMax(aLSpaceMF
.Normalize(aSettings
.aPrtSize
.Width() - aSettings
.nRight
- n20Percent
), FUNIT_TWIP
);
595 aRSpaceMF
.SetMax(aRSpaceMF
.Normalize(aSettings
.aPrtSize
.Width() - aSettings
.nLeft
- n20Percent
), FUNIT_TWIP
);
596 n20Percent
= aSettings
.aPrtSize
.Height() / 5;
597 aTSpaceMF
.SetMax(aTSpaceMF
.Normalize(aSettings
.aPrtSize
.Height() - aSettings
.nBottom
- n20Percent
), FUNIT_TWIP
);
598 aBSpaceMF
.SetMax(aBSpaceMF
.Normalize(aSettings
.aPrtSize
.Height() - aSettings
.nTop
- n20Percent
), FUNIT_TWIP
);
600 long n80Percent
= aSettings
.aPrvPrtSize
.Width() * 4 / 5;
601 aHSpaceMF
.SetMax(aHSpaceMF
.Normalize(n80Percent
/ aSettings
.nRows
), FUNIT_TWIP
);
602 n80Percent
= aSettings
.aPrvPrtSize
.Height()* 4 / 5;
603 aVSpaceMF
.SetMax(aVSpaceMF
.Normalize(n80Percent
/ aSettings
.nCols
), FUNIT_TWIP
);
604 aHSpaceMF
.Enable(aSettings
.nCols
> 1);
605 aVSpaceMF
.Enable(aSettings
.nRows
> 1);
606 aRowsNF
.SetMin(1);// nur damit auch nach Standard wieder der Inhalt angezeigt wird
610 aPreviewWin
.Invalidate();
613 /* -----------------28.08.98 14:59-------------------
615 * --------------------------------------------------*/
616 IMPL_LINK( SwPreviewPrintOptionsDialog
, StandardHdl
, PushButton
*, EMPTYARG
)
619 SwPagePreViewPrtData aData
;
620 aData
.SetRow(rParentWin
.GetRow());
621 aData
.SetCol(rParentWin
.GetCol());
624 aLSpaceMF
.SetText(aEmptyStr
);
625 aRSpaceMF
.SetText(aEmptyStr
);
626 aTSpaceMF
.SetText(aEmptyStr
);
627 aBSpaceMF
.SetText(aEmptyStr
);
628 aHSpaceMF
.SetText(aEmptyStr
);
629 aVSpaceMF
.SetText(aEmptyStr
);
630 aPreviewWin
.Invalidate();
631 SetUpdateMode(FALSE
);
634 /* -----------------20.08.98 15:28-------------------
636 * --------------------------------------------------*/
637 void PrtPrvWindow::Paint(const Rectangle
&)
639 Size
aWinSize(GetOutputSizePixel());
640 long nWidth
= rSettings
.aPrtSize
.Width();
641 long nHeight
= rSettings
.aPrtSize
.Height();
642 BOOL bHoriValid
= (aWinSize
.Width() * 100 / aWinSize
.Height()) <
643 (rSettings
.aPrtSize
.Width() * 100/ rSettings
.aPrtSize
.Height());
644 Fraction
aXScale( aWinSize
.Width(), Max( nWidth
, 1L ) );
645 Fraction
aYScale( aWinSize
.Height(), Max( nHeight
, 1L ) );
646 MapMode
aMapMode( GetMapMode() );
647 aMapMode
.SetScaleX( bHoriValid
? aXScale
: aYScale
);
648 aMapMode
.SetScaleY( bHoriValid
? aXScale
: aYScale
);
649 SetMapMode( aMapMode
);
651 aWinSize
= GetOutputSize();
655 aOffset
.Y() = (aWinSize
.Height() - rSettings
.aPrtSize
.Height()) / 2;
657 aOffset
.X() = (aWinSize
.Width() - rSettings
.aPrtSize
.Width()) / 2;;
660 BOOL bUseSystemColors
= SvtAccessibilityOptions().GetIsForPagePreviews()
661 && GetSettings().GetStyleSettings().GetHighContrastMode();
663 //der weisse Seitenhintergrund
664 Rectangle
aRect(aOffset
, rSettings
.aPrtSize
);
667 SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() );
668 SetLineColor( SwViewOption::GetFontColor() );
672 SetFillColor( Color( COL_WHITE
) );
673 SetLineColor(Color( COL_BLACK
) );
679 aTL
.X() += rSettings
.nLeft
;
680 aTL
.Y() += rSettings
.nTop
;
682 Size
aPrvPageSize((rSettings
.aPrvPrtSize
.Width() - (rSettings
.nCols
- 1) * rSettings
.nHori
) / rSettings
.nCols
,
683 (rSettings
.aPrvPrtSize
.Height() - (rSettings
.nRows
- 1) * rSettings
.nVert
) / rSettings
.nRows
);
684 // jetzt muss noch das unterschiedliche Groessenverhaeltnis berechnet werden, um es an
685 // der richtigen Seite abzuziehen.
687 long nSourceScale
= rSettings
.aPageMaxSize
.Width() * 100 / rSettings
.aPageMaxSize
.Height();
688 long nDestScale
= aPrvPageSize
.Width() * 100 / aPrvPageSize
.Height() ;
689 if(nSourceScale
> nDestScale
) // die Seite ist relativ breiter als das vorhandene Rechteck
691 aPrvPageSize
.Height() = aPrvPageSize
.Width() * 100 / nSourceScale
;
695 aPrvPageSize
.Width() = aPrvPageSize
.Height() * nSourceScale
/ 100;
699 SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() );
701 SetFillColor( Color( COL_GRAY
) );
704 aRect
= Rectangle(aTL
, aPrvPageSize
);
705 for(USHORT i
= 0; i
< rSettings
.nRows
; i
++)
707 for(USHORT j
= 0; j
< rSettings
.nCols
; j
++)
710 aRect
.Move(aPrvPageSize
.Width() + rSettings
.nHori
, 0);
713 aRect
.Move( 0, aPrvPageSize
.Height() + rSettings
.nVert
);
714 aRect
.SetPos(Point(aTL
.X(), aRect
.TopLeft().Y()));
720 /*--------------------------------------------------------------------
722 --------------------------------------------------------------------*/
724 // alles fuers SwPagePreViewWin
727 SwPagePreViewWin::SwPagePreViewWin( Window
*pParent
, SwPagePreView
& rPView
)
728 : Window( pParent
, WinBits( WB_CLIPCHILDREN
) ),
731 mbCalcScaleForPreviewLayout( true ),
732 maPaintedPreviewDocRect( Rectangle(0,0,0,0) )
734 SetOutDevViewType( OUTDEV_VIEWTYPE_PRINTPREVIEW
); //#106611#
735 SetHelpId(HID_PAGEPREVIEW
);
736 SetFillColor( GetBackground().GetColor() );
737 SetLineColor( GetBackground().GetColor());
738 SetMapMode( MapMode(MAP_TWIP
) );
740 const SwMasterUsrPref
*pUsrPref
= SW_MOD()->GetUsrPref(FALSE
);
741 mnRow
= pUsrPref
->GetPagePrevRow(); // 1 Zeile
742 mnCol
= pUsrPref
->GetPagePrevCol(); // 1 Spalte
743 // OD 24.03.2003 #108282# - member <mnVirtPage> no longer exists.
744 mnSttPage
= USHRT_MAX
;
747 /*--------------------------------------------------------------------
749 --------------------------------------------------------------------*/
752 SwPagePreViewWin::~SwPagePreViewWin()
758 /*--------------------------------------------------------------------
760 --------------------------------------------------------------------*/
763 void SwPagePreViewWin::Paint( const Rectangle
& rRect
)
765 if( !mpViewShell
|| !mpViewShell
->GetLayout() )
768 if( USHRT_MAX
== mnSttPage
) // wurde noch nie berechnet ? (Init-Phase!)
770 // das ist die Size, auf die ich mich immer beziehe
771 if( !maPxWinSize
.Height() || !maPxWinSize
.Width() )
772 maPxWinSize
= GetOutputSizePixel();
774 Rectangle
aRect( LogicToPixel( rRect
));
775 mpPgPrevwLayout
->Prepare( 1, Point(0,0), maPxWinSize
,
776 mnSttPage
, maPaintedPreviewDocRect
);
777 SetSelectedPage( 1 );
778 mpPgPrevwLayout
->Paint( PixelToLogic( aRect
) );
779 SetPagePreview(mnRow
, mnCol
);
783 MapMode
aMM( GetMapMode() );
784 aMM
.SetScaleX( maScale
);
785 aMM
.SetScaleY( maScale
);
787 mpPgPrevwLayout
->Paint( rRect
);
791 /*--------------------------------------------------------------------
793 --------------------------------------------------------------------*/
794 void SwPagePreViewWin::CalcWish( BYTE nNewRow
, BYTE nNewCol
)
796 if( !mpViewShell
|| !mpViewShell
->GetLayout() )
799 USHORT nOldCol
= mnCol
;
800 // OD 02.12.2002 #103492# - update <mnRow> and <mnCol>.
803 USHORT nPages
= mnRow
* mnCol
,
804 nLastSttPg
= mrView
.GetPageCount()+1 > nPages
805 ? mrView
.GetPageCount()+1 - nPages
: 0;
806 if( mnSttPage
> nLastSttPg
)
807 mnSttPage
= nLastSttPg
;
809 mpPgPrevwLayout
->Init( mnCol
, mnRow
, maPxWinSize
, true );
810 mpPgPrevwLayout
->Prepare( mnSttPage
, Point(0,0), maPxWinSize
,
811 mnSttPage
, maPaintedPreviewDocRect
);
812 SetSelectedPage( mnSttPage
);
813 SetPagePreview(mnRow
, mnCol
);
814 maScale
= GetMapMode().GetScaleX();
816 // falls an der Spaltigkeit gedreht wurde, so muss der Sonderfall
817 // Einspaltig beachtet und ggfs. der Scrollbar korrigiert werden
818 if( (1 == nOldCol
) ^ (1 == mnCol
) )
819 mrView
.ScrollDocSzChg();
821 // Sortierung muss eingehalten werden!!
822 // OD 24.03.2003 #108282# - additional invalidate page status.
823 static USHORT __READONLY_DATA aInval
[] =
825 SID_ATTR_ZOOM
, SID_ZOOM_OUT
, SID_ZOOM_IN
,
827 FN_START_OF_DOCUMENT
, FN_END_OF_DOCUMENT
, FN_PAGEUP
, FN_PAGEDOWN
,
828 FN_STAT_PAGE
, FN_STAT_ZOOM
,
829 FN_SHOW_TWO_PAGES
, FN_SHOW_MULTIPLE_PAGES
,
832 SfxBindings
& rBindings
= mrView
.GetViewFrame()->GetBindings();
833 rBindings
.Invalidate( aInval
);
834 rBindings
.Update( FN_SHOW_TWO_PAGES
);
835 rBindings
.Update( FN_SHOW_MULTIPLE_PAGES
);
836 // OD 18.12.2002 #103492# - adjust scrollbars
837 mrView
.ScrollViewSzChg();
839 /*--------------------------------------------------------------------
840 Beschreibung:, mnSttPage is Absolute
841 --------------------------------------------------------------------*/
844 int SwPagePreViewWin::MovePage( int eMoveMode
)
846 // soviele Seiten hoch
847 USHORT nPages
= mnRow
* mnCol
;
848 USHORT nNewSttPage
= mnSttPage
;
849 // OD 04.12.2002 #103492#
850 USHORT nPageCount
= mrView
.GetPageCount();
851 USHORT nDefSttPg
= GetDefSttPage();
852 // OD 06.12.2002 #103492#
853 bool bPaintPageAtFirstCol
= true;
859 const sal_uInt16 nRelSttPage
= mpPgPrevwLayout
->ConvertAbsoluteToRelativePageNum( mnSttPage
);
860 const sal_uInt16 nNewAbsSttPage
= nRelSttPage
- nPages
> 0 ?
861 mpPgPrevwLayout
->ConvertRelativeToAbsolutePageNum( nRelSttPage
- nPages
) :
863 nNewSttPage
= nNewAbsSttPage
;
865 const sal_uInt16 nRelSelPage
= mpPgPrevwLayout
->ConvertAbsoluteToRelativePageNum( SelectedPage() );
866 const sal_uInt16 nNewRelSelPage
= nRelSelPage
- nPages
> 0 ?
867 nRelSelPage
- nPages
:
869 SetSelectedPage( mpPgPrevwLayout
->ConvertRelativeToAbsolutePageNum( nNewRelSelPage
) );
875 const sal_uInt16 nRelSttPage
= mpPgPrevwLayout
->ConvertAbsoluteToRelativePageNum( mnSttPage
);
876 const sal_uInt16 nNewAbsSttPage
= mpPgPrevwLayout
->ConvertRelativeToAbsolutePageNum( nRelSttPage
+ nPages
);
877 nNewSttPage
= nNewAbsSttPage
< nPageCount
? nNewAbsSttPage
: nPageCount
;
879 const sal_uInt16 nRelSelPage
= mpPgPrevwLayout
->ConvertAbsoluteToRelativePageNum( SelectedPage() );
880 const sal_uInt16 nNewAbsSelPage
= mpPgPrevwLayout
->ConvertRelativeToAbsolutePageNum( nRelSelPage
+ nPages
);
881 SetSelectedPage( nNewAbsSelPage
< nPageCount
? nNewAbsSelPage
: nPageCount
);
886 nNewSttPage
= nDefSttPg
;
887 SetSelectedPage( mpPgPrevwLayout
->ConvertRelativeToAbsolutePageNum( nNewSttPage
? nNewSttPage
: 1 ) );
890 // OD 03.12.2002 #103492# - correct calculation of new start page.
891 nNewSttPage
= nPageCount
;
892 SetSelectedPage( nPageCount
);
894 // OD 12.12.2002 #103492# - add new move mode
896 // <nNewSttPage> and <SelectedPage()> are already set.
897 // OD 20.02.2003 #107369# - not start at first column, only if the
898 // complete preview layout columns doesn't fit into window.
899 if ( !mpPgPrevwLayout
->DoesPreviewLayoutColsFitIntoWindow() )
900 bPaintPageAtFirstCol
= false;
903 // OD 17.01.2003 #103492# - check, if paint page at first column
905 if ( !mpPgPrevwLayout
->DoesPreviewLayoutRowsFitIntoWindow() ||
906 !mpPgPrevwLayout
->DoesPreviewLayoutColsFitIntoWindow() )
907 bPaintPageAtFirstCol
= false;
910 // OD 18.12.2002 #103492# - nothing special to do.
913 // OD 18.12.2002 #103492# - re-init page preview layout.
914 mpPgPrevwLayout
->ReInit();
916 // OD 03.12.2002 #103492# - correct calculation of new start page.
917 if( nNewSttPage
> nPageCount
)
918 nNewSttPage
= nPageCount
;
920 // OD 18.12.2002 #103492# - correct selected page number
921 if( SelectedPage() > nPageCount
)
922 SetSelectedPage( nNewSttPage
? nNewSttPage
: 1 );
925 mpPgPrevwLayout
->Prepare( nNewSttPage
, Point(0,0), maPxWinSize
,
927 maPaintedPreviewDocRect
, bPaintPageAtFirstCol
);
928 if( nNewSttPage
== mnSttPage
&&
929 eMoveMode
!= MV_SELPAGE
)
932 SetPagePreview(mnRow
, mnCol
);
933 mnSttPage
= nNewSttPage
;
935 // OD 24.03.2003 #108282# - additional invalidate page status.
936 static USHORT __READONLY_DATA aInval
[] =
938 FN_START_OF_DOCUMENT
, FN_END_OF_DOCUMENT
, FN_PAGEUP
, FN_PAGEDOWN
,
942 SfxBindings
& rBindings
= mrView
.GetViewFrame()->GetBindings();
943 rBindings
.Invalidate( aInval
);
948 /*--------------------------------------------------------------------
950 --------------------------------------------------------------------*/
953 void SwPagePreViewWin::SetWinSize( const Size
& rNewSize
)
955 // die Size wollen wir aber immer in Pixel-Einheiten haben
956 maPxWinSize
= LogicToPixel( rNewSize
);
958 if( USHRT_MAX
== mnSttPage
)
960 mnSttPage
= GetDefSttPage();
961 SetSelectedPage( GetDefSttPage() );
964 if ( mbCalcScaleForPreviewLayout
)
966 mpPgPrevwLayout
->Init( mnCol
, mnRow
, maPxWinSize
, true );
967 maScale
= GetMapMode().GetScaleX();
969 mpPgPrevwLayout
->Prepare( mnSttPage
, Point(0,0), maPxWinSize
,
970 mnSttPage
, maPaintedPreviewDocRect
);
971 if ( mbCalcScaleForPreviewLayout
)
973 SetSelectedPage( mnSttPage
);
974 mbCalcScaleForPreviewLayout
= false;
976 SetPagePreview(mnRow
, mnCol
);
977 maScale
= GetMapMode().GetScaleX();
981 /*--------------------------------------------------------------------
983 --------------------------------------------------------------------*/
986 void SwPagePreViewWin::GetStatusStr( String
& rStr
, USHORT nPageCnt
) const
988 // OD 24.03.2003 #108282# - show physical and virtual page number of
989 // selected page, if it's visible.
991 if ( mpPgPrevwLayout
->IsPageVisible( mpPgPrevwLayout
->SelectedPage() ) )
993 nPageNum
= mpPgPrevwLayout
->SelectedPage();
997 nPageNum
= mnSttPage
> 1 ? mnSttPage
: 1;
999 sal_uInt16 nVirtPageNum
= mpPgPrevwLayout
->GetVirtPageNumByPageNum( nPageNum
);
1000 if( nVirtPageNum
&& nVirtPageNum
!= nPageNum
)
1002 rStr
+= String::CreateFromInt32( nVirtPageNum
);
1005 rStr
+= String::CreateFromInt32( nPageNum
);
1006 rStr
.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" / "));
1007 rStr
+= String::CreateFromInt32( nPageCnt
);
1010 /*--------------------------------------------------------------------
1012 --------------------------------------------------------------------*/
1015 void SwPagePreViewWin::KeyInput( const KeyEvent
&rKEvt
)
1017 const KeyCode
& rKeyCode
= rKEvt
.GetKeyCode();
1018 USHORT nKey
= rKeyCode
.GetCode();
1019 BOOL bHandled
= FALSE
;
1020 if(!rKeyCode
.GetModifier())
1025 case KEY_ADD
: nSlot
= SID_ZOOM_OUT
; break;
1026 case KEY_ESCAPE
: nSlot
= FN_CLOSE_PAGEPREVIEW
; break;
1027 case KEY_SUBTRACT
: nSlot
= SID_ZOOM_IN
; break;
1032 mrView
.GetViewFrame()->GetDispatcher()->Execute(
1033 nSlot
, SFX_CALLMODE_ASYNCHRON
);
1036 if( !bHandled
&& !mrView
.KeyInput( rKEvt
) )
1037 Window::KeyInput( rKEvt
);
1040 /******************************************************************************
1042 ******************************************************************************/
1044 void SwPagePreViewWin::Command( const CommandEvent
& rCEvt
)
1046 BOOL bCallBase
= TRUE
;
1047 switch( rCEvt
.GetCommand() )
1049 case COMMAND_CONTEXTMENU
:
1050 mrView
.GetViewFrame()->GetDispatcher()->ExecutePopup();
1055 case COMMAND_STARTAUTOSCROLL
:
1056 case COMMAND_AUTOSCROLL
:
1058 const CommandWheelData
* pData
= rCEvt
.GetWheelData();
1061 const CommandWheelData
aDataNew(pData
->GetDelta(),pData
->GetNotchDelta(),COMMAND_WHEEL_PAGESCROLL
,
1062 pData
->GetMode(),pData
->GetModifier(),pData
->IsHorz());
1063 const CommandEvent
aEvent( rCEvt
.GetMousePosPixel(),rCEvt
.GetCommand(),rCEvt
.IsMouseEvent(),&aDataNew
);
1064 bCallBase
= !mrView
.HandleWheelCommands( aEvent
);
1067 bCallBase
= !mrView
.HandleWheelCommands( rCEvt
);
1071 // OD 17.12.2002 #103492# - delete assertion
1076 Window::Command( rCEvt
);
1079 void SwPagePreViewWin::MouseButtonDown( const MouseEvent
& rMEvt
)
1081 // OD 17.12.2002 #103492# - consider single-click to set selected page
1082 if( MOUSE_LEFT
== ( rMEvt
.GetModifier() + rMEvt
.GetButtons() ) )
1084 Point
aPrevwPos( PixelToLogic( rMEvt
.GetPosPixel() ) );
1086 bool bPosInEmptyPage
;
1087 sal_uInt16 nNewSelectedPage
;
1089 mpPgPrevwLayout
->IsPrevwPosInDocPrevwPage( aPrevwPos
,
1090 aDocPos
, bPosInEmptyPage
, nNewSelectedPage
);
1091 if ( bIsDocPos
&& rMEvt
.GetClicks() == 2 )
1093 // close page preview, set new cursor position and switch to
1095 String
sNewCrsrPos( String::CreateFromInt32( aDocPos
.X() ));
1096 ((( sNewCrsrPos
+= ';' )
1097 += String::CreateFromInt32( aDocPos
.Y() )) )
1099 mrView
.SetNewCrsrPos( sNewCrsrPos
);
1101 SfxViewFrame
*pTmpFrm
= mrView
.GetViewFrame();
1102 pTmpFrm
->GetBindings().Execute( SID_VIEWSHELL0
, NULL
, 0,
1103 SFX_CALLMODE_ASYNCHRON
);
1105 else if ( bIsDocPos
|| bPosInEmptyPage
)
1106 // OD 2004-03-04 #i20684# - add missing parenthesis
1108 // show clicked page as the selected one
1109 mpPgPrevwLayout
->MarkNewSelectedPage( nNewSelectedPage
);
1110 GetViewShell()->ShowPreViewSelection( nNewSelectedPage
);
1111 // OD 19.02.2003 #107369# - adjust position at vertical scrollbar.
1112 if ( mpPgPrevwLayout
->DoesPreviewLayoutRowsFitIntoWindow() )
1114 mrView
.SetVScrollbarThumbPos( nNewSelectedPage
);
1116 // OD 24.03.2003 #108282# - invalidate page status.
1117 static USHORT __READONLY_DATA aInval
[] =
1121 SfxBindings
& rBindings
= mrView
.GetViewFrame()->GetBindings();
1122 rBindings
.Invalidate( aInval
);
1127 /******************************************************************************
1128 * Beschreibung: Userprefs bzw Viewoptions setzen
1129 ******************************************************************************/
1132 void SwPagePreViewWin::SetPagePreview( BYTE nRow
, BYTE nCol
)
1134 SwMasterUsrPref
*pOpt
= (SwMasterUsrPref
*)SW_MOD()->GetUsrPref(FALSE
);
1136 if (nRow
!= pOpt
->GetPagePrevRow() || nCol
!= pOpt
->GetPagePrevCol())
1138 pOpt
->SetPagePrevRow( nRow
);
1139 pOpt
->SetPagePrevCol( nCol
);
1140 pOpt
->SetModified();
1142 //Scrollbar updaten!
1143 mrView
.ScrollViewSzChg();
1147 /** get selected page in document preview
1149 OD 13.12.2002 #103492#
1153 sal_uInt16
SwPagePreViewWin::SelectedPage() const
1155 return mpPgPrevwLayout
->SelectedPage();
1158 /** set selected page number in document preview
1160 OD 13.12.2002 #103492#
1164 void SwPagePreViewWin::SetSelectedPage( sal_uInt16 _nSelectedPageNum
)
1166 mpPgPrevwLayout
->SetSelectedPage( _nSelectedPageNum
);
1169 /** method to enable/disable book preview
1171 OD 2004-03-05 #i18143#
1175 bool SwPagePreViewWin::SetBookPreviewMode( const bool _bBookPreview
)
1177 return mpPgPrevwLayout
->SetBookPreviewMode( _bBookPreview
,
1179 maPaintedPreviewDocRect
);
1182 void SwPagePreViewWin::DataChanged( const DataChangedEvent
& rDCEvt
)
1184 Window::DataChanged( rDCEvt
);
1186 switch( rDCEvt
.GetType() )
1188 case DATACHANGED_SETTINGS
:
1189 // ScrollBars neu anordnen bzw. Resize ausloesen, da sich
1190 // ScrollBar-Groesse geaendert haben kann. Dazu muss dann im
1191 // Resize-Handler aber auch die Groesse der ScrollBars aus
1192 // den Settings abgefragt werden.
1193 if( rDCEvt
.GetFlags() & SETTINGS_STYLE
)
1194 mrView
.InvalidateBorder(); //Scrollbarbreiten
1195 //#106746# zoom has to be disabled if Accessibility support is switched on
1196 lcl_InvalidateZoomSlots(mrView
.GetViewFrame()->GetBindings());
1199 case DATACHANGED_PRINTER
:
1200 case DATACHANGED_DISPLAY
:
1201 case DATACHANGED_FONTS
:
1202 case DATACHANGED_FONTSUBSTITUTION
:
1203 mrView
.GetDocShell()->UpdateFontList(); //Fontwechsel
1204 if ( mpViewShell
->GetWin() )
1205 mpViewShell
->GetWin()->Invalidate();
1210 /** help method to execute SfxRequest FN_PAGEUP and FN_PAGEDOWN
1212 OD 04.03.2003 #107369#
1216 void SwPagePreView::_ExecPgUpAndPgDown( const bool _bPgUp
,
1219 SwPagePreviewLayout
* pPagePrevwLay
= GetViewShell()->PagePreviewLayout();
1220 // check, if top/bottom of preview is *not* already visible.
1221 if( pPagePrevwLay
->GetWinPagesScrollAmount( _bPgUp
? -1 : 1 ) != 0 )
1223 if ( pPagePrevwLay
->DoesPreviewLayoutRowsFitIntoWindow() &&
1224 pPagePrevwLay
->DoesPreviewLayoutColsFitIntoWindow() )
1226 const int eMvMode
= _bPgUp
?
1227 SwPagePreViewWin::MV_PAGE_UP
:
1228 SwPagePreViewWin::MV_PAGE_DOWN
;
1229 if ( ChgPage( eMvMode
, TRUE
) )
1230 aViewWin
.Invalidate();
1234 SwTwips nScrollAmount
;
1235 sal_uInt16 nNewSelectedPageNum
= 0;
1236 const sal_uInt16 nVisPages
= aViewWin
.GetRow() * aViewWin
.GetCol();
1239 if ( pPagePrevwLay
->DoesPreviewLayoutRowsFitIntoWindow() )
1241 nScrollAmount
= pPagePrevwLay
->GetWinPagesScrollAmount( -1 );
1242 if ( (aViewWin
.SelectedPage() - nVisPages
) > 0 )
1243 nNewSelectedPageNum
= aViewWin
.SelectedPage() - nVisPages
;
1245 nNewSelectedPageNum
= 1;
1248 nScrollAmount
= - Min( aViewWin
.GetOutputSize().Height(),
1249 aViewWin
.GetPaintedPreviewDocRect().Top() );
1253 if ( pPagePrevwLay
->DoesPreviewLayoutRowsFitIntoWindow() )
1255 nScrollAmount
= pPagePrevwLay
->GetWinPagesScrollAmount( 1 );
1256 if ( (aViewWin
.SelectedPage() + nVisPages
) <= mnPageCount
)
1257 nNewSelectedPageNum
= aViewWin
.SelectedPage() + nVisPages
;
1259 nNewSelectedPageNum
= mnPageCount
;
1262 nScrollAmount
= Min( aViewWin
.GetOutputSize().Height(),
1263 ( pPagePrevwLay
->GetPrevwDocSize().Height() -
1264 aViewWin
.GetPaintedPreviewDocRect().Bottom() ) );
1266 aViewWin
.Scroll( 0, nScrollAmount
);
1267 if ( nNewSelectedPageNum
!= 0 )
1269 aViewWin
.SetSelectedPage( nNewSelectedPageNum
);
1272 // OD 24.03.2003 #108282# - additional invalidate page status.
1273 static USHORT __READONLY_DATA aInval
[] =
1275 FN_START_OF_DOCUMENT
, FN_END_OF_DOCUMENT
, FN_PAGEUP
, FN_PAGEDOWN
,
1278 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
1279 rBindings
.Invalidate( aInval
);
1280 aViewWin
.Invalidate();
1288 /*--------------------------------------------------------------------
1290 --------------------------------------------------------------------*/
1291 // dann mal alles fuer die SwPagePreView
1292 void SwPagePreView::Execute( SfxRequest
&rReq
)
1296 BOOL bRetVal
= FALSE
;
1297 bool bRefresh
= true;
1299 switch(rReq
.GetSlot())
1301 case FN_REFRESH_VIEW
:
1306 case FN_SHOW_MULTIPLE_PAGES
:
1308 const SfxItemSet
*pArgs
= rReq
.GetArgs();
1309 if( pArgs
&& pArgs
->Count() >= 2 )
1311 BYTE nCols
= (BYTE
)((SfxUInt16Item
&)pArgs
->Get(
1312 SID_ATTR_TABLE_COLUMN
)).GetValue();
1313 BYTE nRows
= (BYTE
)((SfxUInt16Item
&)pArgs
->Get(
1314 SID_ATTR_TABLE_ROW
)).GetValue();
1315 aViewWin
.CalcWish( nRows
, nCols
);
1319 SwPreViewZoomDlg( aViewWin
).Execute();
1323 case FN_SHOW_BOOKVIEW
:
1325 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1326 const SfxPoolItem
* pItem
;
1327 bool bBookPreview
= GetViewShell()->GetViewOptions()->IsPagePrevBookview();
1328 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( FN_SHOW_BOOKVIEW
, FALSE
, &pItem
) )
1330 bBookPreview
= static_cast< const SfxBoolItem
* >( pItem
)->GetValue();
1331 ( ( SwViewOption
* ) GetViewShell()->GetViewOptions() )->SetPagePrevBookview( bBookPreview
);
1332 // cast is not gentleman like, but it's common use in writer and in this case
1334 if ( aViewWin
.SetBookPreviewMode( bBookPreview
) )
1336 // book preview mode changed. Thus, adjust scrollbars and
1337 // invalidate corresponding states.
1339 static USHORT __READONLY_DATA aInval
[] =
1341 FN_START_OF_DOCUMENT
, FN_END_OF_DOCUMENT
, FN_PAGEUP
, FN_PAGEDOWN
,
1342 FN_STAT_PAGE
, FN_SHOW_BOOKVIEW
, 0
1344 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
1345 rBindings
.Invalidate( aInval
);
1346 aViewWin
.Invalidate();
1351 case FN_SHOW_TWO_PAGES
:
1352 aViewWin
.CalcWish( nRow
, 2 );
1355 case FN_PREVIEW_ZOOM
:
1358 const SfxItemSet
*pArgs
= rReq
.GetArgs();
1359 const SfxPoolItem
* pItem
;
1360 AbstractSvxZoomDialog
*pDlg
= 0;
1363 SfxItemSet
aCoreSet(GetPool(), SID_ATTR_ZOOM
, SID_ATTR_ZOOM
);
1364 const SwViewOption
* pVOpt
= GetViewShell()->GetViewOptions();
1365 SvxZoomItem
aZoom( (SvxZoomType
)pVOpt
->GetZoomType(),
1370 SVX_ZOOM_ENABLE_100
|
1371 SVX_ZOOM_ENABLE_150
|
1372 SVX_ZOOM_ENABLE_200
|
1373 SVX_ZOOM_ENABLE_WHOLEPAGE
);
1374 aCoreSet
.Put( aZoom
);
1376 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1379 pDlg
= pFact
->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet
, RID_SVXDLG_ZOOM
);
1380 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
1383 pDlg
->SetLimits( MINZOOM
, MAXZOOM
);
1385 if( pDlg
->Execute() != RET_CANCEL
)
1386 pArgs
= pDlg
->GetOutputItemSet();
1390 enum SvxZoomType eType
= SVX_ZOOM_PERCENT
;
1391 USHORT nZoomFactor
= USHRT_MAX
;
1392 if(SFX_ITEM_SET
== pArgs
->GetItemState(SID_ATTR_ZOOM
, TRUE
, &pItem
))
1394 eType
= ((const SvxZoomItem
*)pItem
)->GetType();
1395 nZoomFactor
= ((const SvxZoomItem
*)pItem
)->GetValue();
1397 else if(SFX_ITEM_SET
== pArgs
->GetItemState(FN_PREVIEW_ZOOM
, TRUE
, &pItem
))
1398 nZoomFactor
= ((const SfxUInt16Item
*)pItem
)->GetValue();
1399 if(USHRT_MAX
!= nZoomFactor
)
1400 SetZoom(eType
, nZoomFactor
);
1405 case SID_ATTR_ZOOMSLIDER
:
1407 const SfxItemSet
*pArgs
= rReq
.GetArgs();
1408 const SfxPoolItem
* pItem
;
1410 if ( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(SID_ATTR_ZOOMSLIDER
, TRUE
, &pItem
) )
1412 const USHORT nCurrentZoom
= ((const SvxZoomSliderItem
*)pItem
)->GetValue();
1413 SetZoom( SVX_ZOOM_PERCENT
, nCurrentZoom
);
1420 enum SvxZoomType eType
= SVX_ZOOM_PERCENT
;
1421 const SwViewOption
* pVOpt
= GetViewShell()->GetViewOptions();
1423 lcl_GetNextZoomStep(pVOpt
->GetZoom(), SID_ZOOM_IN
== rReq
.GetSlot()));
1431 SwPagePreviewLayout
* pPagePrevwLay
= GetViewShell()->PagePreviewLayout();
1432 sal_uInt16 nNewSelectedPage
;
1433 sal_uInt16 nNewStartPage
;
1435 sal_Int16 nHoriMove
= 0;
1436 sal_Int16 nVertMove
= 0;
1437 switch(rReq
.GetSlot())
1439 case FN_CHAR_LEFT
: nHoriMove
= -1; break;
1440 case FN_CHAR_RIGHT
: nHoriMove
= 1; break;
1441 case FN_LINE_UP
: nVertMove
= -1; break;
1442 case FN_LINE_DOWN
: nVertMove
= 1; break;
1444 pPagePrevwLay
->CalcStartValuesForSelectedPageMove( nHoriMove
, nVertMove
,
1445 nNewSelectedPage
, nNewStartPage
, aNewStartPos
);
1446 if ( aViewWin
.SelectedPage() != nNewSelectedPage
)
1448 if ( pPagePrevwLay
->IsPageVisible( nNewSelectedPage
) )
1450 pPagePrevwLay
->MarkNewSelectedPage( nNewSelectedPage
);
1451 // OD 19.02.2003 #107369# - adjust position at vertical scrollbar.
1452 SetVScrollbarThumbPos( nNewSelectedPage
);
1457 aViewWin
.SetSelectedPage( nNewSelectedPage
);
1458 aViewWin
.SetSttPage( nNewStartPage
);
1459 int nRet
= ChgPage( SwPagePreViewWin::MV_SELPAGE
, TRUE
);
1460 bRefresh
= 0 != nRet
;
1462 GetViewShell()->ShowPreViewSelection( nNewSelectedPage
);
1463 // OD 24.03.2003 #108282# - invalidate page status.
1464 static USHORT __READONLY_DATA aInval
[] =
1468 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
1469 rBindings
.Invalidate( aInval
);
1481 _ExecPgUpAndPgDown( rReq
.GetSlot() == FN_PAGEUP
, &rReq
);
1484 case FN_START_OF_LINE
:
1485 case FN_START_OF_DOCUMENT
:
1486 aViewWin
.SetSelectedPage( 1 );
1487 eMvMode
= SwPagePreViewWin::MV_DOC_STT
; bRetVal
= TRUE
; goto MOVEPAGE
;
1488 case FN_END_OF_LINE
:
1489 case FN_END_OF_DOCUMENT
:
1490 aViewWin
.SetSelectedPage( mnPageCount
);
1491 eMvMode
= SwPagePreViewWin::MV_DOC_END
; bRetVal
= TRUE
; goto MOVEPAGE
;
1494 int nRet
= ChgPage( eMvMode
, TRUE
);
1495 // return value fuer Basic
1497 rReq
.SetReturnValue(SfxBoolItem(rReq
.GetSlot(), nRet
== 0));
1499 bRefresh
= 0 != nRet
;
1504 case FN_PRINT_PAGEPREVIEW
:
1506 const SwPagePreViewPrtData
* pPPVPD
= aViewWin
.GetViewShell()->GetDoc()->GetPreViewPrtData();
1507 // die Sache mit der Orientation
1510 SfxPrinter
* pPrinter
= GetPrinter( TRUE
);
1511 if((pPrinter
->GetOrientation() == ORIENTATION_LANDSCAPE
)
1512 != pPPVPD
->GetLandscape())
1513 pPrinter
->SetOrientation(pPPVPD
->GetLandscape() ? ORIENTATION_LANDSCAPE
: ORIENTATION_PORTRAIT
);
1515 ::SetAppPrintOptions( aViewWin
.GetViewShell(), FALSE
);
1516 bNormalPrint
= FALSE
;
1517 USHORT nPrtSlot
= SID_PRINTDOC
;
1518 rReq
.SetSlot( nPrtSlot
);
1519 SfxViewShell::ExecuteSlot( rReq
, SfxViewShell::GetInterface() );
1520 rReq
.SetSlot( FN_PRINT_PAGEPREVIEW
);
1523 case FN_PREVIEW_PRINT_OPTIONS
:
1525 SwPreviewPrintOptionsDialog
aDlg(aViewWin
, *this);
1529 case SID_PRINTDOCDIRECT
:
1531 ::SetAppPrintOptions( aViewWin
.GetViewShell(), FALSE
);
1532 bNormalPrint
= TRUE
;
1533 SfxViewShell::ExecuteSlot( rReq
, SfxViewShell::GetInterface() );
1535 case FN_CLOSE_PAGEPREVIEW
:
1536 case SID_PRINTPREVIEW
:
1537 // print preview is now always in the same frame as the tab view
1538 // -> always switch this frame back to normal view
1539 // (ScTabViewShell ctor reads stored view data)
1540 GetViewFrame()->GetDispatcher()->Execute( SID_VIEWSHELL0
, 0, 0, SFX_CALLMODE_ASYNCHRON
);
1542 case FN_INSERT_BREAK
:
1544 USHORT nSelPage
= aViewWin
.SelectedPage();
1545 //if a dummy page is selected (e.g. a non-existing right/left page)
1546 //the direct neighbor is used
1547 if(GetViewShell()->IsDummyPage( nSelPage
) && GetViewShell()->IsDummyPage( --nSelPage
))
1549 SetNewPage( nSelPage
);
1550 SfxViewFrame
*pTmpFrm
= GetViewFrame();
1551 pTmpFrm
->GetBindings().Execute( SID_VIEWSHELL0
, NULL
, 0,
1552 SFX_CALLMODE_ASYNCHRON
);
1556 ASSERT(!this, falscher Dispatcher
);
1561 aViewWin
.Invalidate();
1564 /*--------------------------------------------------------------------
1566 --------------------------------------------------------------------*/
1569 void SwPagePreView::GetState( SfxItemSet
& rSet
)
1571 SfxWhichIter
aIter(rSet
);
1573 USHORT nWhich
= aIter
.FirstWhich();
1574 ASSERT(nWhich
, leeres Set
);
1575 SwPagePreviewLayout
* pPagePrevwLay
= GetViewShell()->PagePreviewLayout();
1576 //#106746# zoom has to be disabled if Accessibility support is switched on
1577 BOOL bZoomEnabled
= !Application::GetSettings().GetMiscSettings().GetEnableATToolSupport();
1583 case FN_START_OF_DOCUMENT
:
1585 if ( pPagePrevwLay
->IsPageVisible( 1 ) )
1586 rSet
.DisableItem(nWhich
);
1589 case FN_END_OF_DOCUMENT
:
1591 if ( pPagePrevwLay
->IsPageVisible( mnPageCount
) )
1592 rSet
.DisableItem(nWhich
);
1597 if( pPagePrevwLay
->GetWinPagesScrollAmount( -1 ) == 0 )
1598 rSet
.DisableItem(nWhich
);
1603 if( pPagePrevwLay
->GetWinPagesScrollAmount( 1 ) == 0 )
1604 rSet
.DisableItem(nWhich
);
1610 String
aStr( sPageStr
);
1611 aViewWin
.GetStatusStr( aStr
, mnPageCount
);
1612 rSet
.Put( SfxStringItem( nWhich
, aStr
) );
1621 const SwViewOption
* pVOpt
= GetViewShell()->GetViewOptions();
1622 SvxZoomItem
aZoom((SvxZoomType
)pVOpt
->GetZoomType(),
1627 SVX_ZOOM_ENABLE_100
|
1628 SVX_ZOOM_ENABLE_150
|
1629 SVX_ZOOM_ENABLE_200
);
1633 rSet
.DisableItem(nWhich
);
1636 case SID_ATTR_ZOOMSLIDER
:
1640 const SwViewOption
* pVOpt
= GetViewShell()->GetViewOptions();
1641 const USHORT nCurrentZoom
= pVOpt
->GetZoom();
1642 SvxZoomSliderItem
aZoomSliderItem( nCurrentZoom
, MINZOOM
, MAXZOOM
);
1643 aZoomSliderItem
.AddSnappingPoint( 100 );
1644 rSet
.Put( aZoomSliderItem
);
1647 rSet
.DisableItem(nWhich
);
1650 case FN_PREVIEW_ZOOM
:
1654 const SwViewOption
* pVOpt
= GetViewShell()->GetViewOptions();
1655 rSet
.Put(SfxUInt16Item(nWhich
, pVOpt
->GetZoom()));
1658 rSet
.DisableItem(nWhich
);
1664 const SwViewOption
* pVOpt
= GetViewShell()->GetViewOptions();
1665 if(!bZoomEnabled
|| (SID_ZOOM_OUT
== nWhich
&& pVOpt
->GetZoom() >= MAX_PREVIEW_ZOOM
)||
1666 (SID_ZOOM_IN
== nWhich
&& pVOpt
->GetZoom() <= MIN_PREVIEW_ZOOM
))
1668 rSet
.DisableItem(nWhich
);
1672 case FN_SHOW_MULTIPLE_PAGES
:
1673 //should never be disabled
1675 case FN_SHOW_BOOKVIEW
:
1677 BOOL b
= GetViewShell()->GetViewOptions()->IsPagePrevBookview();
1678 rSet
.Put(SfxBoolItem(nWhich
, b
));
1682 case FN_SHOW_TWO_PAGES
:
1683 if( 2 == aViewWin
.GetCol() && nRow
== aViewWin
.GetRow() )
1684 rSet
.DisableItem( nWhich
);
1687 case FN_PRINT_PAGEPREVIEW
:
1688 // hat den gleichen Status wie das normale Drucken
1690 const SfxPoolItem
* pItem
;
1691 SfxItemSet
aSet( *rSet
.GetPool(), SID_PRINTDOC
, SID_PRINTDOC
);
1692 GetSlotState( SID_PRINTDOC
, SfxViewShell::GetInterface(), &aSet
);
1693 if( SFX_ITEM_DISABLED
== aSet
.GetItemState( SID_PRINTDOC
,
1695 rSet
.DisableItem( nWhich
);
1696 else if( SFX_ITEM_SET
== aSet
.GetItemState( SID_PRINTDOC
,
1699 ((SfxPoolItem
*)pItem
)->SetWhich( FN_PRINT_PAGEPREVIEW
);
1705 case SID_PRINTPREVIEW
:
1706 rSet
.Put( SfxBoolItem( nWhich
, TRUE
) );
1710 case SID_PRINTDOCDIRECT
:
1711 GetSlotState( nWhich
, SfxViewShell::GetInterface(), &rSet
);
1714 nWhich
= aIter
.NextWhich();
1718 /*--------------------------------------------------------------------
1720 --------------------------------------------------------------------*/
1723 void SwPagePreView::StateUndo(SfxItemSet
& rSet
)
1725 SfxWhichIter
aIter(rSet
);
1726 USHORT nWhich
= aIter
.FirstWhich();
1730 rSet
.DisableItem(nWhich
);
1731 nWhich
= aIter
.NextWhich();
1735 /*--------------------------------------------------------------------
1737 --------------------------------------------------------------------*/
1740 void SwPagePreView::Init(const SwViewOption
* pPrefs
)
1742 if ( GetViewShell()->HasDrawView() )
1743 GetViewShell()->GetDrawView()->SetAnimationEnabled( FALSE
);
1745 bNormalPrint
= TRUE
;
1747 // Die DocSize erfragen und verarbeiten. Ueber die Handler konnte
1748 // die Shell nicht gefunden werden, weil die Shell innerhalb CTOR-Phase
1749 // nicht in der SFX-Verwaltung bekannt ist.
1752 pPrefs
= SW_MOD()->GetUsrPref(FALSE
);
1754 // die Felder aktualisieren
1755 // ACHTUNG: hochcasten auf die EditShell, um die SS zu nutzen.
1756 // In den Methoden wird auf die akt. Shell abgefragt!
1757 SwEditShell
* pESh
= (SwEditShell
*)GetViewShell();
1758 BOOL bIsModified
= pESh
->IsModified();
1761 SwViewOption
aOpt( *pPrefs
);
1762 aOpt
.SetPagePreview(TRUE
);
1763 aOpt
.SetTab( FALSE
);
1764 aOpt
.SetBlank( FALSE
);
1765 aOpt
.SetHardBlank( FALSE
);
1766 aOpt
.SetParagraph( FALSE
);
1767 aOpt
.SetLineBreak( FALSE
);
1768 aOpt
.SetPageBreak( FALSE
);
1769 aOpt
.SetColumnBreak( FALSE
);
1770 aOpt
.SetSoftHyph( FALSE
);
1771 aOpt
.SetFldName( FALSE
);
1772 aOpt
.SetPostIts( FALSE
);
1773 aOpt
.SetShowHiddenChar( FALSE
);
1774 aOpt
.SetShowHiddenField( FALSE
);
1775 aOpt
.SetShowHiddenPara( FALSE
);
1776 aOpt
.SetViewHRuler( FALSE
);
1777 aOpt
.SetViewVRuler( FALSE
);
1778 aOpt
.SetGraphic( TRUE
);
1779 aOpt
.SetTable( TRUE
);
1780 aOpt
.SetSnap( FALSE
);
1781 aOpt
.SetGridVisible( FALSE
);
1782 GetViewShell()->ApplyViewOptions( aOpt
);
1783 GetViewShell()->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
1785 // OD 09.01.2003 #i6467# - adjust view shell option to the same as for print
1786 SwPrtOptions
aPrintOptions( GetViewFrame()->GetObjectShell()->GetTitle(0) );
1787 SwView::MakeOptions( 0, aPrintOptions
, 0, 0, false, 0, 0 );
1788 GetViewShell()->AdjustOptionsForPagePreview( aPrintOptions
);
1790 IDocumentSettingAccess
* pIDSA
= pESh
->getIDocumentSettingAccess();
1791 if( pIDSA
->get(IDocumentSettingAccess::BROWSE_MODE
))
1793 pIDSA
->set(IDocumentSettingAccess::BROWSE_MODE
, false);
1794 pESh
->CheckBrowseView( TRUE
);
1797 GetViewShell()->CalcLayout();
1798 DocSzChgd( GetViewShell()->GetDocSize() );
1801 pESh
->ResetModified();
1803 pVScrollbar
->ExtendedShow(pPrefs
->IsViewVScrollBar());
1804 pHScrollbar
->ExtendedShow(pPrefs
->IsViewHScrollBar());
1805 pScrollFill
->Show(pPrefs
->IsViewVScrollBar() && pPrefs
->IsViewHScrollBar());
1809 /*--------------------------------------------------------------------
1811 --------------------------------------------------------------------*/
1814 SwPagePreView::SwPagePreView(SfxViewFrame
*pViewFrame
, SfxViewShell
* pOldSh
):
1815 SfxViewShell( pViewFrame
, SWVIEWFLAGS
),
1816 aViewWin( &pViewFrame
->GetWindow(), *this ),
1817 nNewPage(USHRT_MAX
),
1822 pScrollFill(new ScrollBarBox( &pViewFrame
->GetWindow(),
1823 pViewFrame
->GetFrame()->GetParentFrame() ? 0 : WB_SIZEABLE
)),
1825 // OD 09.01.2003 #106334#
1826 mbResetFormDesignMode( false ),
1827 mbFormDesignModeToReset( false )
1829 SetName(String::CreateFromAscii("PageView" ));
1830 SetWindow( &aViewWin
);
1831 SetHelpId(SW_PAGEPREVIEW
);
1832 _CreateScrollbar( TRUE
);
1833 _CreateScrollbar( FALSE
);
1835 SfxObjectShell
* pObjShell
= pViewFrame
->GetObjectShell();
1838 //Gibt es schon eine Sicht auf das Dokument?
1839 SfxViewFrame
*pF
= SfxViewFrame::GetFirst( pObjShell
);
1840 if ( pF
== pViewFrame
)
1841 pF
= SfxViewFrame::GetNext( *pF
, pObjShell
);
1843 pOldSh
= pF
->GetViewShell();
1846 ViewShell
*pVS
, *pNew
;
1848 if( pOldSh
&& pOldSh
->IsA( TYPE( SwPagePreView
) ) )
1849 pVS
= ((SwPagePreView
*)pOldSh
)->GetViewShell();
1852 if( pOldSh
&& pOldSh
->IsA( TYPE( SwView
) ) )
1854 pVS
= ((SwView
*)pOldSh
)->GetWrtShellPtr();
1855 // save the current ViewData of the previous SwView
1856 pOldSh
->WriteUserData( sSwViewData
, FALSE
);
1859 pVS
= GetDocShell()->GetWrtShell();
1862 // setze die akt. Seite als die erste
1863 USHORT nPhysPg
, nVirtPg
;
1864 ((SwCrsrShell
*)pVS
)->GetPageNum( nPhysPg
, nVirtPg
, /*FALSE*/TRUE
, FALSE
);
1865 if( 1 != aViewWin
.GetCol() && 1 == nPhysPg
)
1867 aViewWin
.SetSttPage( nPhysPg
);
1871 // OD 09.01.2003 #106334# - for form shell remember design mode of draw view
1872 // of previous view shell
1873 if ( pVS
&& pVS
->HasDrawView() )
1875 mbResetFormDesignMode
= true;
1876 mbFormDesignModeToReset
= pVS
->GetDrawView()->IsDesignMode();
1880 pNew
= new ViewShell( *pVS
, &aViewWin
, 0, VSHELLFLAG_ISPREVIEW
);
1882 pNew
= new ViewShell(
1883 *((SwDocShell
*)pViewFrame
->GetObjectShell())->GetDoc(),
1884 &aViewWin
, 0, 0, VSHELLFLAG_ISPREVIEW
);
1886 aViewWin
.SetViewShell( pNew
);
1887 pNew
->SetSfxViewShell( this );
1892 /*--------------------------------------------------------------------
1894 --------------------------------------------------------------------*/
1897 SwPagePreView::~SwPagePreView()
1905 delete pPageDownBtn
;
1907 /* SfxObjectShell* pDocSh = GetDocShell();
1908 TypeId aType = TYPE( SfxTopViewFrame );
1910 for( SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocSh, aType );
1911 pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pDocSh, aType ) )
1912 if( pFrame != GetViewFrame() )
1914 // es gibt noch eine weitere Sicht auf unser Dokument, also
1916 pFrame->GetFrame()->Appear();
1921 /*--------------------------------------------------------------------
1923 --------------------------------------------------------------------*/
1926 SwDocShell
* SwPagePreView::GetDocShell()
1928 return PTR_CAST(SwDocShell
, GetViewFrame()->GetObjectShell());
1931 /*--------------------------------------------------------------------
1933 --------------------------------------------------------------------*/
1936 int SwPagePreView::_CreateScrollbar( BOOL bHori
)
1938 Window
*pMDI
= &GetViewFrame()->GetWindow();
1939 SwScrollbar
** ppScrollbar
= bHori
? &pHScrollbar
: &pVScrollbar
;
1941 ASSERT( !*ppScrollbar
, "vorher abpruefen!" )
1946 pPageUpBtn
= new ImageButton(pMDI
, SW_RES( BTN_PAGEUP
) );
1947 pPageUpBtn
->SetHelpId(FN_PAGEUP
);
1948 pPageDownBtn
= new ImageButton(pMDI
, SW_RES( BTN_PAGEDOWN
) );
1949 pPageDownBtn
->SetHelpId(FN_PAGEDOWN
);
1950 Link
aLk( LINK( this, SwPagePreView
, BtnPage
) );
1951 pPageUpBtn
->SetClickHdl( aLk
);
1952 pPageDownBtn
->SetClickHdl( aLk
);
1954 pPageDownBtn
->Show();
1957 *ppScrollbar
= new SwScrollbar( pMDI
, bHori
);
1960 (*ppScrollbar
)->EnableDrag( TRUE
);
1961 (*ppScrollbar
)->SetEndScrollHdl( LINK( this, SwPagePreView
, EndScrollHdl
));
1964 (*ppScrollbar
)->SetScrollHdl( LINK( this, SwPagePreView
, ScrollHdl
));
1967 (*ppScrollbar
)->ExtendedShow();
1971 /*--------------------------------------------------------------------
1973 --------------------------------------------------------------------*/
1977 /*--------------------------------------------------------------------
1979 --------------------------------------------------------------------*/
1984 IMPL_LINK_INLINE_START( SwPagePreView
, BtnPage
, Button
*, pButton
)
1986 // OD 04.03.2003 #107369# - use new helper method to perform page up
1987 // respectively page down.
1988 _ExecPgUpAndPgDown( pButton
== pPageUpBtn
);
1991 IMPL_LINK_INLINE_END( SwPagePreView
, BtnPage
, Button
*, pButton
)
1993 /*--------------------------------------------------------------------
1995 --------------------------------------------------------------------*/
1998 int SwPagePreView::ChgPage( int eMvMode
, int bUpdateScrollbar
)
2000 Rectangle
aPixVisArea( aViewWin
.LogicToPixel( aVisArea
) );
2001 int bChg
= aViewWin
.MovePage( eMvMode
) ||
2002 eMvMode
== SwPagePreViewWin::MV_CALC
||
2003 eMvMode
== SwPagePreViewWin::MV_NEWWINSIZE
;
2004 aVisArea
= aViewWin
.PixelToLogic( aPixVisArea
);
2008 // Statusleiste updaten
2009 String
aStr( sPageStr
);
2010 aViewWin
.GetStatusStr( aStr
, mnPageCount
);
2011 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
2013 if( bUpdateScrollbar
)
2017 static USHORT __READONLY_DATA aInval
[] =
2019 FN_START_OF_DOCUMENT
, FN_END_OF_DOCUMENT
,
2020 FN_PAGEUP
, FN_PAGEDOWN
, 0
2022 rBindings
.Invalidate( aInval
);
2024 rBindings
.SetState( SfxStringItem( FN_STAT_PAGE
, aStr
) );
2031 /*--------------------------------------------------------------------
2033 --------------------------------------------------------------------*/
2036 // ab hier alles aus der SwView uebernommen
2039 void SwPagePreView::CalcAndSetBorderPixel( SvBorder
&rToFill
, BOOL
/*bInner*/ )
2041 // const long nAdd = bInner ? 0 : ScrollBar::GetWindowOverlapPixel();
2042 const StyleSettings
&rSet
= aViewWin
.GetSettings().GetStyleSettings();
2043 const long nTmp
= rSet
.GetScrollBarSize();// - nAdd;
2044 if ( pVScrollbar
->IsVisible( FALSE
))
2045 rToFill
.Right() = nTmp
;
2046 if ( pHScrollbar
->IsVisible( FALSE
) )
2047 rToFill
.Bottom() = nTmp
;
2048 SetBorderPixel( rToFill
);
2051 /*--------------------------------------------------------------------
2053 --------------------------------------------------------------------*/
2056 void SwPagePreView::InnerResizePixel( const Point
&rOfst
, const Size
&rSize
)
2059 CalcAndSetBorderPixel( aBorder
, TRUE
);
2060 Rectangle
aRect( rOfst
, rSize
);
2062 ViewResizePixel( aViewWin
, aRect
.TopLeft(), aRect
.GetSize(),
2063 aViewWin
.GetOutputSizePixel(),
2065 *pVScrollbar
, *pHScrollbar
, pPageUpBtn
, pPageDownBtn
, 0,
2068 //EditWin niemals einstellen!
2069 //VisArea niemals einstellen!
2072 /*--------------------------------------------------------------------
2074 --------------------------------------------------------------------*/
2077 void SwPagePreView::OuterResizePixel( const Point
&rOfst
, const Size
&rSize
)
2080 CalcAndSetBorderPixel( aBorder
, FALSE
);
2081 ViewResizePixel( aViewWin
, rOfst
, rSize
, aViewWin
.GetOutputSizePixel(),
2082 FALSE
, *pVScrollbar
,
2083 *pHScrollbar
, pPageUpBtn
, pPageDownBtn
, 0, *pScrollFill
);
2085 //EditWin niemals einstellen!
2087 Size
aTmpSize( aViewWin
.GetOutputSizePixel() );
2088 Point
aBottomRight( aViewWin
.PixelToLogic( Point( aTmpSize
.Width(), aTmpSize
.Height() ) ) );
2089 SetVisArea( Rectangle( Point(), aBottomRight
) );
2091 //Aufruf der DocSzChgd-Methode der Scrollbars ist noetig, da vom maximalen
2092 //Scrollrange immer die halbe Hoehe der VisArea abgezogen wird.
2097 /*--------------------------------------------------------------------
2099 --------------------------------------------------------------------*/
2102 void SwPagePreView::SetVisArea( const Rectangle
&rRect
, BOOL bUpdateScrollbar
)
2104 const Point
aTopLeft(AlignToPixel(rRect
.TopLeft()));
2105 const Point
aBottomRight(AlignToPixel(rRect
.BottomRight()));
2106 Rectangle
aLR(aTopLeft
,aBottomRight
);
2110 // keine negative Position, keine neg. Groesse
2114 aLR
.Bottom() += Abs(aLR
.Top());
2120 aLR
.Right() += Abs(aLR
.Left());
2123 if(aLR
.Right() < 0) aLR
.Right() = 0;
2124 if(aLR
.Bottom() < 0) aLR
.Bottom() = 0;
2125 if(aLR
== aVisArea
||
2126 // JP 29.10.97: Bug 45173 - Leeres Rechteck nicht beachten
2127 ( 0 == aLR
.Bottom() - aLR
.Top() && 0 == aLR
.Right() - aLR
.Left() ) )
2130 if( aLR
.Left() > aLR
.Right() || aLR
.Top() > aLR
.Bottom() )
2133 //Bevor die Daten veraendert werden ggf. ein Update rufen. Dadurch wird
2134 //sichergestellt, da? anliegende Paints korrekt in Dokumentkoordinaten
2135 //umgerechnet werden.
2136 //Vorsichtshalber tun wir das nur wenn an der Shell eine Action laeuft,
2137 //denn dann wir nicht wirklich gepaintet sondern die Rechtecke werden
2138 //lediglich (in Dokumentkoordinaten) vorgemerkt.
2139 if( GetViewShell()->ActionPend() )
2142 // setze am View-Win die aktuelle Size
2144 aViewWin
.SetWinSize( aLR
.GetSize() );
2145 // OD 18.12.2002 #103492# - use new mode
2146 ChgPage( SwPagePreViewWin::MV_NEWWINSIZE
, bUpdateScrollbar
);
2148 aViewWin
.Invalidate();
2151 /*--------------------------------------------------------------------
2153 --------------------------------------------------------------------*/
2156 IMPL_LINK( SwPagePreView
, ScrollHdl
, SwScrollbar
*, pScrollbar
)
2160 if( !pScrollbar
->IsHoriScroll() &&
2161 pScrollbar
->GetType() == SCROLL_DRAG
&&
2162 Help::IsQuickHelpEnabled() &&
2163 GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
2165 // wieviele Seiten scrollen ??
2166 String
sStateStr(sPageStr
);
2167 USHORT nThmbPos
= (USHORT
)pScrollbar
->GetThumbPos();
2168 if( 1 == aViewWin
.GetCol() || !nThmbPos
)
2170 sStateStr
+= String::CreateFromInt32( nThmbPos
);
2171 Point aPos
= pScrollbar
->GetParent()->OutputToScreenPixel(
2172 pScrollbar
->GetPosPixel());
2173 aPos
.Y() = pScrollbar
->OutputToScreenPixel(pScrollbar
->GetPointerPosPixel()).Y();
2174 Size aSize
= pScrollbar
->GetSizePixel();
2176 aRect
.Left() = aPos
.X() -8;
2177 aRect
.Right() = aRect
.Left();
2178 aRect
.Top() = aPos
.Y();
2179 aRect
.Bottom() = aRect
.Top();
2181 Help::ShowQuickHelp(pScrollbar
, aRect
, sStateStr
,
2182 QUICKHELP_RIGHT
|QUICKHELP_VCENTER
);
2186 EndScrollHdl( pScrollbar
);
2190 /*--------------------------------------------------------------------
2192 --------------------------------------------------------------------*/
2195 IMPL_LINK( SwPagePreView
, EndScrollHdl
, SwScrollbar
*, pScrollbar
)
2200 // OD 04.03.2003 #107369# - boolean to avoid unnecessary invalidation of the window.
2201 bool bInvalidateWin
= true;
2203 if( !pScrollbar
->IsHoriScroll() ) // scroll vertically
2205 if ( Help::IsQuickHelpEnabled() )
2206 Help::ShowQuickHelp(pScrollbar
, Rectangle(), aEmptyStr
, 0);
2207 if ( GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow() )
2209 // wieviele Seiten scrollen ??
2210 USHORT nThmbPos
= (USHORT
)pScrollbar
->GetThumbPos();
2211 // OD 05.12.2002 #103492# - adjust to new preview functionality
2212 if( nThmbPos
!= aViewWin
.SelectedPage() )
2214 // OD 17.01.2003 #103492# - consider case that page <nThmbPos>
2215 // is already visible
2216 SwPagePreviewLayout
* pPagePrevwLay
= GetViewShell()->PagePreviewLayout();
2217 if ( pPagePrevwLay
->IsPageVisible( nThmbPos
) )
2219 pPagePrevwLay
->MarkNewSelectedPage( nThmbPos
);
2220 // OD 04.03.2003 #107369# - invalidation of window is unnecessary
2221 bInvalidateWin
= false;
2225 // OD 17.01.2003 #103492# - consider whether layout columns
2227 if ( !pPagePrevwLay
->DoesPreviewLayoutColsFitIntoWindow() )
2229 aViewWin
.SetSttPage( nThmbPos
);
2230 aViewWin
.SetSelectedPage( nThmbPos
);
2231 ChgPage( SwPagePreViewWin::MV_SCROLL
, FALSE
);
2232 // OD 20.01.2003 #103492# - update scrollbars
2237 // OD 04.03.2003 #107369# - correct scroll amount
2238 const sal_Int16 nPageDiff
= nThmbPos
- aViewWin
.SelectedPage();
2239 const sal_uInt16 nVisPages
= aViewWin
.GetRow() * aViewWin
.GetCol();
2240 sal_Int16 nWinPagesToScroll
= nPageDiff
/ nVisPages
;
2241 if ( nPageDiff
% nVisPages
)
2243 // decrease/increase number of preview pages to scroll
2244 nPageDiff
< 0 ? --nWinPagesToScroll
: ++nWinPagesToScroll
;
2246 aViewWin
.SetSelectedPage( nThmbPos
);
2247 aViewWin
.Scroll( 0, pPagePrevwLay
->GetWinPagesScrollAmount( nWinPagesToScroll
) );
2250 // OD 17.01.2003 #103492# - update accessibility
2251 GetViewShell()->ShowPreViewSelection( nThmbPos
);
2255 // OD 04.03.2003 #107369# - invalidation of window is unnecessary
2256 bInvalidateWin
= false;
2261 long nThmbPos
= pScrollbar
->GetThumbPos();
2262 aViewWin
.Scroll(0, nThmbPos
- aViewWin
.GetPaintedPreviewDocRect().Top());
2267 long nThmbPos
= pScrollbar
->GetThumbPos();
2268 aViewWin
.Scroll(nThmbPos
- aViewWin
.GetPaintedPreviewDocRect().Left(), 0);
2270 // OD 24.03.2003 #108282# - additional invalidate page status.
2271 static USHORT __READONLY_DATA aInval
[] =
2273 FN_START_OF_DOCUMENT
, FN_END_OF_DOCUMENT
, FN_PAGEUP
, FN_PAGEDOWN
,
2276 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
2277 rBindings
.Invalidate( aInval
);
2278 // OD 04.03.2003 #107369# - control invalidation of window
2279 if ( bInvalidateWin
)
2281 aViewWin
.Invalidate();
2285 /*--------------------------------------------------------------------
2287 --------------------------------------------------------------------*/
2290 Point
SwPagePreView::AlignToPixel(const Point
&rPt
) const
2292 return aViewWin
.PixelToLogic( aViewWin
.LogicToPixel( rPt
) );
2295 /*--------------------------------------------------------------------
2297 --------------------------------------------------------------------*/
2300 void SwPagePreView::DocSzChgd( const Size
&rSz
)
2307 // --> OD 2009-08-20 #i96726#
2308 // Due to the multiple page layout it is needed to trigger recalculation
2309 // of the page preview layout, even if the count of pages is not changing.
2310 mnPageCount
= GetViewShell()->GetNumPages();
2312 if( aVisArea
.GetWidth() )
2314 ChgPage( SwPagePreViewWin::MV_CALC
, TRUE
);
2317 aViewWin
.Invalidate();
2322 /*--------------------------------------------------------------------
2324 --------------------------------------------------------------------*/
2327 void SwPagePreView::ScrollViewSzChg()
2333 if(GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
2335 //vertical scrolling by row
2336 // OD 04.12.2002 #103492# - adjust to new preview functionality
2337 USHORT nVisPages
= aViewWin
.GetRow() * aViewWin
.GetCol();
2338 pVScrollbar
->SetVisibleSize( nVisPages
);
2339 // OD 19.02.2003 #107369# - set selected page as scroll bar position,
2340 // if it is visible.
2341 SwPagePreviewLayout
* pPagePrevwLay
= GetViewShell()->PagePreviewLayout();
2342 if ( pPagePrevwLay
->IsPageVisible( aViewWin
.SelectedPage() ) )
2344 pVScrollbar
->SetThumbPos( aViewWin
.SelectedPage() );
2348 pVScrollbar
->SetThumbPos( aViewWin
.GetSttPage() );
2350 pVScrollbar
->SetLineSize( aViewWin
.GetCol() );
2351 pVScrollbar
->SetPageSize( nVisPages
);
2352 // calculate and set scrollbar range
2353 Range
aScrollbarRange( 1, mnPageCount
);
2354 // increase range by one, because left-top-corner is left blank.
2355 ++aScrollbarRange
.Max();
2356 // OD 17.01.2003 #103492# - increase range in order to access all pages
2357 aScrollbarRange
.Max() += ( nVisPages
- 1 );
2358 pVScrollbar
->SetRange( aScrollbarRange
);
2360 else //vertical scrolling by pixel
2362 const Rectangle
& rDocRect
= aViewWin
.GetPaintedPreviewDocRect();
2363 const Size
& rPreviewSize
=
2364 GetViewShell()->PagePreviewLayout()->GetPrevwDocSize();
2365 pVScrollbar
->SetRangeMax(rPreviewSize
.Height()) ;
2366 long nVisHeight
= rDocRect
.GetHeight();
2367 pVScrollbar
->SetVisibleSize( nVisHeight
);
2368 pVScrollbar
->SetThumbPos( rDocRect
.Top() );
2369 pVScrollbar
->SetLineSize( nVisHeight
/ 10 );
2370 pVScrollbar
->SetPageSize( nVisHeight
/ 2 );
2375 const Rectangle
& rDocRect
= aViewWin
.GetPaintedPreviewDocRect();
2376 const Size
& rPreviewSize
=
2377 GetViewShell()->PagePreviewLayout()->GetPrevwDocSize();
2382 if(rDocRect
.GetWidth() < rPreviewSize
.Width())
2384 nVisWidth
= rDocRect
.GetWidth();
2385 nThumb
= rDocRect
.Left();
2386 aRange
= Range(0, rPreviewSize
.Width());
2388 pHScrollbar
->SetRange( aRange
);
2389 pHScrollbar
->SetVisibleSize( nVisWidth
);
2390 pHScrollbar
->SetThumbPos( nThumb
);
2391 pHScrollbar
->SetLineSize( nVisWidth
/ 10 );
2392 pHScrollbar
->SetPageSize( nVisWidth
/ 2 );
2396 /*--------------------------------------------------------------------
2398 --------------------------------------------------------------------*/
2401 void SwPagePreView::ScrollDocSzChg()
2408 /*--------------------------------------------------------------------
2410 --------------------------------------------------------------------*/
2413 // alles zum Thema Drucken
2415 USHORT
SwPagePreView::Print( SfxProgress
&rProgress
, BOOL bIsAPI
, PrintDialog
*pDlg
)
2417 ViewShell
* pSh
= aViewWin
.GetViewShell();
2418 SfxPrinter
* pPrinter
= GetPrinter();
2419 if( !pPrinter
|| !pPrinter
->InitJob( &aViewWin
,
2420 pSh
->HasDrawView() && !bIsAPI
&& pSh
->GetDrawView()->GetModel()->HasTransparentObjects() ))
2421 return ERRCODE_IO_ABORT
;
2423 SwWait
aWait( *GetDocShell(), TRUE
);
2425 USHORT nRowCol
= ( aViewWin
.GetRow() << 8 ) +
2426 aViewWin
.GetCol(); // Zeilen / DoppelSeiten
2429 // die Felder aktualisieren
2430 // ACHTUNG: hochcasten auf die EditShell, um die SS zu nutzen.
2431 // In den Methoden wird auf die akt. Shell abgefragt!
2432 SwEditShell
* pESh
= (SwEditShell
*)pSh
;
2434 BOOL bIsModified
= pESh
->IsModified();
2436 pESh
->StartAllAction();
2437 pESh
->UpdateDocStat( aDocStat
);
2439 pESh
->EndAllAction();
2442 pESh
->ResetModified();
2445 // Druckauftrag starten
2446 SfxObjectShell
*pObjShell
= GetViewFrame()->GetObjectShell();
2447 SwPrtOptions
aOpts( pObjShell
->GetTitle(0) );
2451 SwView::MakeOptions( pDlg
, aOpts
, &bPrtPros
, &bPrtPros_RTL
, FALSE
, GetPrinter(), GetDocShell()->GetDoc()->getPrintData() );
2456 pSh
->PrintProspect( aOpts
, rProgress
, bPrtPros_RTL
);
2458 pSh
->Prt( aOpts
, &rProgress
);
2462 const SwPagePreViewPrtData
* pPPVPD
= pSh
->GetDoc()->GetPreViewPrtData();
2463 if( pPPVPD
&& pPPVPD
->GetCol() && pPPVPD
->GetRow() )
2466 nRowCol
= ( pPPVPD
->GetRow() << 8 ) + pPPVPD
->GetCol();
2470 pSh
->PrintPreViewPage( aOpts
, nRowCol
, rProgress
, pPPVPD
);
2476 /*--------------------------------------------------------------------
2478 --------------------------------------------------------------------*/
2481 SfxPrinter
* SwPagePreView::GetPrinter( BOOL bCreate
)
2483 return aViewWin
.GetViewShell()->getIDocumentDeviceAccess()->getPrinter( bCreate
);
2486 /*--------------------------------------------------------------------
2488 --------------------------------------------------------------------*/
2491 USHORT
SwPagePreView::SetPrinter( SfxPrinter
*pNew
, USHORT nDiffFlags
, bool )
2493 ViewShell
&rSh
= *GetViewShell();
2494 SwEditShell
&rESh
= (SwEditShell
&)rSh
; //Buh...
2495 if( ( SFX_PRINTER_PRINTER
| SFX_PRINTER_JOBSETUP
) & nDiffFlags
)
2497 rSh
.getIDocumentDeviceAccess()->setPrinter( pNew
, true, true );
2498 if( nDiffFlags
& SFX_PRINTER_PRINTER
)
2501 if ( ( nDiffFlags
& SFX_PRINTER_OPTIONS
) == SFX_PRINTER_OPTIONS
)
2502 ::SetPrinter( rSh
.getIDocumentDeviceAccess(), pNew
, FALSE
);
2504 const BOOL bChgOri
= nDiffFlags
& SFX_PRINTER_CHG_ORIENTATION
? TRUE
: FALSE
;
2505 const BOOL bChgSize
= nDiffFlags
& SFX_PRINTER_CHG_SIZE
? TRUE
: FALSE
;
2506 if ( bChgOri
|| bChgSize
)
2508 rESh
.StartAllAction();
2510 rSh
.ChgAllPageOrientation( USHORT(pNew
->GetOrientation()) );
2513 Size
aSz( SvxPaperInfo::GetPaperSize( pNew
) );
2514 rSh
.ChgAllPageSize( aSz
);
2517 aViewWin
.CalcWish( aViewWin
.GetRow(), aViewWin
.GetCol() );
2519 rESh
.EndAllAction();
2521 static USHORT __READONLY_DATA aInval
[] =
2523 SID_ATTR_LONG_ULSPACE
, SID_ATTR_LONG_LRSPACE
,
2524 SID_RULER_BORDERS
, SID_RULER_PAGE_POS
, 0
2528 const USHORT
* pPtr
= aInval
+ 1;
2530 ASSERT( *(pPtr
- 1) < *pPtr
, "falsche Sortierung!" );
2535 GetViewFrame()->GetBindings().Invalidate(aInval
);
2541 /*--------------------------------------------------------------------
2543 --------------------------------------------------------------------*/
2546 SfxTabPage
* SwPagePreView::CreatePrintOptionsPage( Window
*pParent
,
2547 const SfxItemSet
&rOptions
)
2549 return ::CreatePrintOptionsPage( pParent
, rOptions
, !bNormalPrint
);
2552 /*--------------------------------------------------------------------
2554 --------------------------------------------------------------------*/
2557 PrintDialog
* SwPagePreView::CreatePrintDialog( Window
*pParent
)
2559 PrintDialog
*pDlg
= ::CreatePrintDialog( pParent
, 1, 0 );
2560 pDlg
->DisableRange( PRINTDIALOG_SELECTION
);
2564 /*--------------------------------------------------------------------
2566 --------------------------------------------------------------------*/
2569 // OD 18.12.2002 #103492# - no longer needed ??
2570 Size
SwPagePreView::GetOptimalSizePixel() const
2572 ASSERT( false, "overloaded virtual method <SwPagePreView::GetOptimalSizePixel()> needed ??" )
2573 return Size( -1, -1 );
2575 //JP 09.06.99: was wird hier errechnet ?????
2577 // SfxApplicationWindow* pWin = SFX_APPWINDOW ;
2578 // Rectangle aRect = pWin->GetClientAreaPixel();
2580 Window& rWin = GetViewFrame()->GetWindow();
2581 Rectangle aRect( Point(0, 0), rWin.GetOutputSizePixel() );
2582 Size aMaxSize( aRect.GetWidth(), aRect.GetHeight() );
2583 Size aInSize = rWin.GetOutputSizePixel();
2584 Size aOutSize = rWin.GetSizePixel();
2585 USHORT nXBorder = USHORT(aOutSize.Width() - aInSize.Width());
2586 USHORT nYBorder = USHORT(aOutSize.Height() - aInSize.Height());
2587 aMaxSize.Width() -= nXBorder;
2588 //'auf Verdacht' etwas vom Border abziehen (Menue)
2589 nYBorder -= (nYBorder - nXBorder) / 2;
2590 aMaxSize.Height() -= nYBorder;
2591 //mit der max. moeglichen Outputsize guenstigstes Verhaeltnis ausrechnen
2592 aViewWin.GetOptimalSize(aMaxSize);
2593 // Border wieder dazuzaehlen
2594 aMaxSize.Height() += nYBorder;
2595 aMaxSize.Width() += nXBorder;
2600 /*--------------------------------------------------------------------
2602 --------------------------------------------------------------------*/
2604 // OD 12.12.2002 #103492#
2605 void SwPagePreViewWin::SetViewShell( ViewShell
* pShell
)
2607 mpViewShell
= pShell
;
2608 if ( mpViewShell
&& mpViewShell
->IsPreView() )
2610 mpPgPrevwLayout
= mpViewShell
->PagePreviewLayout();
2614 void SwPagePreViewWin::RepaintCoreRect( const SwRect
& rRect
)
2616 // OD 2004-03-04 #i24183#
2617 if ( mpPgPrevwLayout
->PreviewLayoutValid() )
2619 mpPgPrevwLayout
->Repaint( Rectangle( rRect
.Pos(), rRect
.SSize() ) );
2623 /** method to adjust preview to a new zoom factor
2625 OD 02.12.2002 #103492#
2626 OD 24.09.2003 #i19975# - also consider zoom type - adding parameter <_eZoomType>
2628 void SwPagePreViewWin::AdjustPreviewToNewZoom( const sal_uInt16 _nZoomFactor
,
2629 const SvxZoomType _eZoomType
)
2631 // OD 24.09.2003 #i19975# - consider zoom type
2632 if ( _eZoomType
== SVX_ZOOM_WHOLEPAGE
)
2636 mpPgPrevwLayout
->Init( mnCol
, mnRow
, maPxWinSize
, true );
2637 mpPgPrevwLayout
->Prepare( mnSttPage
, Point(0,0), maPxWinSize
,
2638 mnSttPage
, maPaintedPreviewDocRect
);
2639 SetSelectedPage( mnSttPage
);
2640 SetPagePreview(mnRow
, mnCol
);
2641 maScale
= GetMapMode().GetScaleX();
2643 else if ( _nZoomFactor
!= 0 )
2645 // calculate new scaling and set mapping mode appropriately.
2646 Fraction
aNewScale( _nZoomFactor
, 100 );
2647 MapMode aNewMapMode
= GetMapMode();
2648 aNewMapMode
.SetScaleX( aNewScale
);
2649 aNewMapMode
.SetScaleY( aNewScale
);
2650 SetMapMode( aNewMapMode
);
2652 // calculate new start position for preview paint
2653 Size aNewWinSize
= PixelToLogic( maPxWinSize
);
2654 Point aNewPaintStartPos
=
2655 mpPgPrevwLayout
->GetPreviewStartPosForNewScale( aNewScale
, maScale
, aNewWinSize
);
2657 // remember new scaling and prepare preview paint
2658 // Note: paint of preview will be performed by a corresponding invalidate
2659 // due to property changes.
2660 maScale
= aNewScale
;
2661 mpPgPrevwLayout
->Prepare( 0, aNewPaintStartPos
, maPxWinSize
,
2662 mnSttPage
, maPaintedPreviewDocRect
);
2666 /* -----------------04.12.2002 10:46-----------------
2667 * pixel scrolling - horizontally always or vertically
2668 * when less than the desired number of rows fits into
2670 * --------------------------------------------------*/
2671 void SwPagePreViewWin::Scroll(long nXMove
, long nYMove
, USHORT
/*nFlags*/)
2673 maPaintedPreviewDocRect
.Move(nXMove
, nYMove
);
2674 mpPgPrevwLayout
->Prepare( 0, maPaintedPreviewDocRect
.TopLeft(),
2675 maPxWinSize
, mnSttPage
,
2676 maPaintedPreviewDocRect
);
2680 BOOL
SwPagePreView::HandleWheelCommands( const CommandEvent
& rCEvt
)
2683 const CommandWheelData
* pWData
= rCEvt
.GetWheelData();
2684 if( pWData
&& COMMAND_WHEEL_ZOOM
== pWData
->GetMode() )
2686 if(!Application::GetSettings().GetMiscSettings().GetEnableATToolSupport())
2688 USHORT nFactor
= GetViewShell()->GetViewOptions()->GetZoom();
2689 const USHORT nOffset
= 10;
2690 if( 0L > pWData
->GetDelta() )
2693 if(nFactor
< MIN_PREVIEW_ZOOM
)
2694 nFactor
= MIN_PREVIEW_ZOOM
;
2699 if(nFactor
> MAX_PREVIEW_ZOOM
)
2700 nFactor
= MAX_PREVIEW_ZOOM
;
2702 SetZoom(SVX_ZOOM_PERCENT
, nFactor
);
2707 bOk
= aViewWin
.HandleScrollCommand( rCEvt
, pHScrollbar
, pVScrollbar
);
2712 uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
2713 SwPagePreViewWin::CreateAccessible()
2715 vos::OGuard
aGuard(Application::GetSolarMutex()); // this should have
2716 // happend already!!!
2718 DBG_ASSERT( GetViewShell() != NULL
, "We need a view shell" );
2719 return GetViewShell()->CreateAccessiblePreview();
2722 /* -----------------------------06.05.2002 13:18------------------------------
2724 ---------------------------------------------------------------------------*/
2725 void SwPagePreView::ApplyAccessiblityOptions(SvtAccessibilityOptions
& rAccessibilityOptions
)
2727 GetViewShell()->ApplyAccessiblityOptions(rAccessibilityOptions
);
2729 /* -----------------------------2002/06/26 14:30------------------------------
2731 ---------------------------------------------------------------------------*/
2732 void SwPagePreView::ShowHScrollbar(sal_Bool bShow
)
2734 pHScrollbar
->Show(bShow
);
2738 /* -----------------------------2002/06/26 14:30------------------------------
2740 ---------------------------------------------------------------------------*/
2741 void SwPagePreView::ShowVScrollbar(sal_Bool bShow
)
2743 pVScrollbar
->Show(bShow
);
2747 /* -----------------25.11.2002 16:36-----------------
2749 * --------------------------------------------------*/
2750 void SwPagePreView::SetZoom(SvxZoomType eType
, USHORT nFactor
)
2752 ViewShell
& rSh
= *GetViewShell();
2753 SwViewOption
aOpt(*rSh
.GetViewOptions());
2754 // OD 16.12.2002 #103492# - perform action only on changes of zoom or zoom type.
2755 if ( aOpt
.GetZoom() != nFactor
||
2756 aOpt
.GetZoomType() != eType
)
2758 aOpt
.SetZoom(nFactor
);
2759 aOpt
.SetZoomType(eType
);
2760 rSh
.ApplyViewOptions( aOpt
);
2761 lcl_InvalidateZoomSlots(GetViewFrame()->GetBindings());
2762 // OD 02.12.2002 #103492#
2763 // OD 24.09.2003 #i19975# - also consider zoom type
2764 aViewWin
.AdjustPreviewToNewZoom( nFactor
, eType
);
2769 /** adjust position of vertical scrollbar
2771 OD 19.02.2003 #107369
2775 void SwPagePreView::SetVScrollbarThumbPos( const sal_uInt16 _nNewThumbPos
)
2779 pVScrollbar
->SetThumbPos( _nNewThumbPos
);