1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
29 #include <com/sun/star/embed/XClassifiedObject.hpp>
30 #include <com/sun/star/embed/XEmbeddedObject.hpp>
31 #include <tools/rtti.hxx>
32 #include <svl/svarray.hxx>
34 #include <swtypes.hxx>
38 #include <vcl/mapmod.hxx>
39 #include <vcl/print.hxx>
41 namespace com
{ namespace sun
{ namespace star
{ namespace accessibility
{
42 class XAccessible
; } } } }
44 class SfxObjectShellRef
;
46 class IDocumentSettingAccess
;
47 class IDocumentDeviceAccess
;
48 class IDocumentMarkAccess
;
49 class IDocumentDrawModelAccess
;
50 class IDocumentRedlineAccess
;
51 class IDocumentLayoutAccess
;
52 class IDocumentFieldsAccess
;
53 class IDocumentContentOperations
;
54 class IDocumentStylePoolAccess
;
55 class IDocumentStatistics
;
56 class IDocumentUndoRedo
;
57 // --> OD 2007-11-14 #i83479#
58 class IDocumentListItems
;
59 class IDocumentOutlineNodes
;
72 class SwPagePreViewPrtData
;
79 class SvtAccessibilityOptions
;
80 class SwPagePreviewLayout
;
84 struct SwAccessibilityOptions
;
88 class SwAccessibleMap
;
92 class OldStylePrintAdaptor
;
96 //JP 19.07.98: - Bug 52312
97 // define fuer Flags, die im CTOR oder den darunter liegenden Schichten
99 // Zur Zeit wird fuer die DrawPage das PreView Flag benoetigt
100 #define VSHELLFLAG_ISPREVIEW ((long)0x1)
103 class SW_DLLPUBLIC ViewShell
: public Ring
105 friend void SetOutDev( ViewShell
*pSh
, OutputDevice
*pOut
);
106 friend void SetOutDevAndWin( ViewShell
*pSh
, OutputDevice
*pOut
,
107 Window
*pWin
, sal_uInt16 nZoom
);
109 friend class SwViewImp
;
110 friend class SwLayIdle
;
112 // OD 12.12.2002 #103492# - for setting visible area for page preview paint
113 friend class SwPagePreviewLayout
;
115 //Umsetzen der SwVisArea, damit vor dem Drucken sauber formatiert
117 friend void SetSwVisArea( ViewShell
*pSh
, const SwRect
&, BOOL bPDFExport
= FALSE
);
119 // --> PB 2007-05-30 #146850#
120 static BitmapEx
* pReplaceBmp
; // replaced display of still loaded images
121 static BitmapEx
* pErrorBmp
; // error display of missed images
124 static sal_Bool bLstAct
; // sal_True wenn Das EndAction der letzten Shell
125 // laeuft; also die EndActions der
126 // anderen Shells auf das Dokument
127 // abgearbeitet sind.
129 Point aPrtOffst
; //Ofst fuer den Printer,
130 //nicht bedruckbarer Rand.
131 Size aBrowseBorder
; //Rand fuer Framedokumente
134 SfxViewShell
*pSfxViewShell
;
135 SwViewImp
*pImp
; //Core-Interna der ViewShell.
136 //Der Pointer ist niemals 0.
138 Window
*pWin
; // = 0 during printing or pdf export
139 OutputDevice
*pOut
; // Window, Printer, VirtDev, ...
140 OutputDevice
* mpTmpRef
; // Temporariy reference device. Is used
141 // during (printer depending) prospect
142 // and page preview printing
143 // (because a scaling has to be set at
144 // the original printer)
147 SwAccessibilityOptions
* pAccOptions
;
150 sal_Bool bDocSizeChgd
:1; //Fuer DocChgNotify(): Neue DocGroesse bei
151 //EndAction an das DocMDI melden.
152 sal_Bool bPaintWorks
:1; //Normal Painten wenn sal_True,
153 //Paint merken wenn sal_False
154 sal_Bool bPaintInProgress
:1; //Kein zweifaches Paint durchlassen.
155 sal_Bool bViewLocked
:1; //Lockt den sichtbaren Bereich,
156 //MakeVisible laeuft dann in's leere.
157 sal_Bool bInEndAction
:1; //Fiese unstaende vermeiden, siehe viewsh.cxx
158 sal_Bool bPreView
:1; //Ist sal_True wenns eine PreView-ViewShell ist.
159 sal_Bool bFrameView
:1; //sal_True wenn es ein (HTML-)Frame ist.
160 sal_Bool bEnableSmooth
:1; //Disable des SmoothScroll z.B. fuer
161 //Drag der Scrollbars.
162 sal_Bool bEndActionByVirDev
:1; //Paints aus der EndAction immer ueber virtuelles
164 //Device (etwa beim Browsen)
166 // OD 2004-06-01 #i26791# - boolean, indicating that class in in constructor
167 bool mbInConstructor
:1;
170 SdrPaintWindow
* mpTargetPaintWindow
;
171 OutputDevice
* mpBufferedOut
;
173 //Initialisierung, wird von den verschiedenen Konstruktoren gerufen.
174 SW_DLLPRIVATE
void Init( const SwViewOption
*pNewOpt
);
176 inline void ResetInvalidRect();
178 SW_DLLPRIVATE
void Reformat(); //Invalidert das ges. Layout (ApplyViewOption)
180 SW_DLLPRIVATE
void PaintDesktop( const SwRect
& ); // sammeln der Werte fuers
181 // Malen der Wiese und rufen
182 // PaintDesktop gesplittet, dieser Teil wird auch von PreViewPage benutzt
183 SW_DLLPRIVATE
void _PaintDesktop( const SwRegionRects
&rRegion
);
185 SW_DLLPRIVATE sal_Bool
CheckInvalidForPaint( const SwRect
& );//Direkt Paint oder lieber
186 //eine Aktion ausloesen.
188 SW_DLLPRIVATE
void PrepareForPrint( const SwPrintData
&rOptions
);
190 SW_DLLPRIVATE
void ImplApplyViewOptions( const SwViewOption
&rOpt
);
193 static ShellResource
* pShellRes
; // Resourcen fuer die Shell
194 static Window
* pCareWindow
; // diesem Fenster ausweichen
196 SwRect aVisArea
; //Die moderne Ausfuerung der VisArea
197 SwDoc
*pDoc
; //Das Dokument, niemals 0
199 sal_uInt16 nStartAction
; //ist != 0 wenn mindestens eine ::com::sun::star::chaos::Action laeuft
200 sal_uInt16 nLockPaint
; //ist != 0 wenn das Paint gelocked ist.
205 SwViewImp
*Imp() { return pImp
; }
206 const SwViewImp
*Imp() const { return pImp
; }
208 const SwNodes
& GetNodes() const;
210 //Nach Druckerwechsel, vom Doc
211 void InitPrt( OutputDevice
*pOutDev
);
213 //Klammerung von zusammengehoerenden Aktionen.
214 inline void StartAction();
215 void ImplStartAction();
216 inline void EndAction( const sal_Bool bIdleEnd
= sal_False
);
217 void ImplEndAction( const sal_Bool bIdleEnd
= sal_False
);
218 sal_uInt16
ActionCount() const { return nStartAction
; }
219 sal_Bool
ActionPend() const { return nStartAction
!= 0; }
220 sal_Bool
IsInEndAction() const { return bInEndAction
; }
222 void SetEndActionByVirDev( sal_Bool b
) { bEndActionByVirDev
= b
; }
223 sal_Bool
IsEndActionByVirDev() { return bEndActionByVirDev
; }
225 // Per UNO wird am RootFrame fuer alle shells der ActionCount kurzfristig
226 // auf Null gesetzt und wieder restauriert
227 void SetRestoreActions(sal_uInt16 nSet
);
228 sal_uInt16
GetRestoreActions() const;
230 inline sal_Bool
HasInvalidRect() const { return aInvalidRect
.HasArea(); }
231 void ChgHyphenation() { Reformat(); }
232 void ChgNumberDigits();
234 sal_Bool
AddPaintRect( const SwRect
&rRect
);
236 void InvalidateWindows( const SwRect
&rRect
);
238 //////////////////////////////////////////////////////////////////////////////
239 // #i72754# set of Pre/PostPaints with lock counter and initial target OutDev
241 sal_uInt32 mnPrePostPaintCount
;
242 OutputDevice
* mpPrePostOutDev
;
243 MapMode maPrePostMapMode
;
246 void DLPrePaint2(const Region
& rRegion
);
247 void DLPostPaint2(bool bPaintFormLayer
);
248 const MapMode
& getPrePostMapMode() const { return maPrePostMapMode
; }
249 //////////////////////////////////////////////////////////////////////////////
251 virtual void Paint(const Rectangle
&rRect
);
252 sal_Bool
IsPaintInProgress() const { return bPaintInProgress
; }
253 bool IsDrawingLayerPaintInProgress() const { return 0 != mnPrePostPaintCount
; }
255 //Benachrichtung, dass sich der sichtbare Bereich geaendert hat.
256 //VisArea wird neu gesetzt, anschliessend wird gescrollt.
257 //Das uebergebene Rect liegt auf Pixelgrenzen,
258 //um Pixelfehler beim Scrollen zu vermeiden.
259 virtual void VisPortChgd( const SwRect
& );
260 sal_Bool
SmoothScroll( long lXDiff
, long lYDiff
, const Rectangle
* );//Browser
261 void EnableSmooth( sal_Bool b
) { bEnableSmooth
= b
; }
263 const SwRect
& VisArea() const { return aVisArea
; }
264 //Es wird, wenn notwendig, soweit gescrollt, dass das
265 //uebergebene Rect im sichtbaren Ausschnitt liegt.
266 void MakeVisible( const SwRect
& );
268 //Bei naechster Gelegenheit die neue Dokuemntgroesse an das UI weiterreichen.
269 void SizeChgNotify();
270 void UISizeNotify(); //Das weiterreichen der aktuellen groesse.
272 Point
GetPagePos( sal_uInt16 nPageNum
) const;
274 sal_uInt16
GetNumPages(); //Anzahl der aktuellen Seiten Layout erfragen.
275 sal_Bool
IsDummyPage( USHORT nPageNum
) const; // An empty page?
277 //Invalidierung der ersten Sichtbaren Seite fuer alle Shells im Ring.
278 void SetFirstVisPageInvalid();
280 SwRootFrm
*GetLayout() const;
281 sal_Bool
IsNewLayout() const; //Wurde das Layout geladen oder neu
284 Size
GetDocSize() const;// erfrage die Groesse des Dokuments
286 void CalcLayout(); //Durchformatierung des Layouts erzwingen.
288 inline SwDoc
*GetDoc() const { return pDoc
; } //niemals 0.
290 /** Provides access to the document setting interface
292 const IDocumentSettingAccess
* getIDocumentSettingAccess() const;
293 IDocumentSettingAccess
* getIDocumentSettingAccess();
295 /** Provides access to the document device interface
297 const IDocumentDeviceAccess
* getIDocumentDeviceAccess() const;
298 IDocumentDeviceAccess
* getIDocumentDeviceAccess();
300 /** Provides access to the document bookmark interface
302 const IDocumentMarkAccess
* getIDocumentMarkAccess() const;
303 IDocumentMarkAccess
* getIDocumentMarkAccess();
305 /** Provides access to the document draw model interface
307 const IDocumentDrawModelAccess
* getIDocumentDrawModelAccess() const;
308 IDocumentDrawModelAccess
* getIDocumentDrawModelAccess();
310 /** Provides access to the document redline interface
312 const IDocumentRedlineAccess
* getIDocumentRedlineAccess() const;
313 IDocumentRedlineAccess
* getIDocumentRedlineAccess();
315 /** Provides access to the document layout interface
317 const IDocumentLayoutAccess
* getIDocumentLayoutAccess() const;
318 IDocumentLayoutAccess
* getIDocumentLayoutAccess();
320 /** Provides access to the document fields administration interface
322 const IDocumentFieldsAccess
* getIDocumentFieldsAccess() const;
324 /** Provides access to the content operations interface
326 IDocumentContentOperations
* getIDocumentContentOperations();
328 /** Provides access to the document style pool interface
330 IDocumentStylePoolAccess
* getIDocumentStylePoolAccess();
332 /** Provides access to the document statistics interface
334 const IDocumentStatistics
* getIDocumentStatistics() const;
336 /** Provides access to the document undo/redo interface
338 IDocumentUndoRedo
* getIDocumentUndoRedoAccess();
340 // --> OD 2007-11-14 #i83479#
341 const IDocumentListItems
* getIDocumentListItemsAccess() const;
342 const IDocumentOutlineNodes
* getIDocumentOutlineNodesAccess() const;
345 // 1. GetRefDev: Either the printer or the virtual device from the doc
346 // 2. GetWin: Available if we not printing
347 // 3. GetOut: Printer, Window or Virtual device
348 OutputDevice
& GetRefDev() const;
349 inline Window
* GetWin() const { return pWin
; }
350 inline OutputDevice
* GetOut() const { return pOut
; }
352 static inline sal_Bool
IsLstEndAction() { return ViewShell::bLstAct
; }
354 //Andern alle PageDescriptoren
355 void ChgAllPageOrientation( sal_uInt16 eOri
);
356 void ChgAllPageSize( Size
&rSz
);
358 // printing of one page.
359 // bIsPDFExport == true is: do PDF Export (no printing!)
360 sal_Bool
PrintOrPDFExport( OutputDevice
*pOutDev
, const SwPrtOptions
&rPrintData
,
361 sal_Int32 nRenderer
/* offset in vector of pages to print */ );
363 // printing of one brochure page
364 void PrintProspect( OutputDevice
*pOutDev
, const SwPrintData
&rPrintData
,
365 sal_Int32 nRenderer
/* offset in vector of page pairs for prospect printing */ );
367 // printing for OLE 2.0
368 static void PrtOle2( SwDoc
*pDoc
, const SwViewOption
*pOpt
, const SwPrintData
& rOptions
,
369 OutputDevice
* pOleOut
, const Rectangle
& rRect
);
371 // creates temporary doc with selected text for PDF export
372 SwDoc
* CreatePrtDoc( SfxObjectShellRef
& );
373 SwDoc
* FillPrtDoc( SwDoc
* pPrtDoc
, const SfxPrinter
* pPrt
);
375 //Wird intern fuer die Shell gerufen die Druckt. Formatiert die Seiten.
376 void CalcPagesForPrint( sal_uInt16 nMax
);
379 void UpdateFlds(sal_Bool bCloseDB
= sal_False
);
380 sal_Bool
IsAnyFieldInDoc() const;
381 // update all charts, for that exists any table
382 void UpdateAllCharts();
383 sal_Bool
HasCharts() const;
386 // DOCUMENT COMPATIBILITY FLAGS START
389 // Sollen Absatzabstaende addiert oder maximiert werden?
390 void SetParaSpaceMax( bool bNew
);
392 // Sollen Absatzabstaende addiert oder maximiert werden?
393 void SetParaSpaceMaxAtPages( bool bNew
);
395 // compatible behaviour of tabs
396 void SetTabCompat( bool bNew
);
398 // font metric attribute "External Leading" should be considered
399 void SetAddExtLeading( bool bNew
);
401 // formatting by virtual device or printer
402 void SetUseVirDev( bool nNew
);
404 // OD 2004-02-16 #106629# - adding paragraph and table spacing at bottom
406 void SetAddParaSpacingToTableCells( bool _bAddParaSpacingToTableCells
);
408 // OD 06.01.2004 #i11859# - former formatting of text lines with
409 // proportional line spacing or not
410 void SetUseFormerLineSpacing( bool _bUseFormerLineSpacing
);
412 // OD 2004-03-12 #i11860# - former object positioning
413 void SetUseFormerObjectPositioning( bool _bUseFormerObjPos
);
415 // OD 2004-05-05 #i28701#
416 void SetConsiderWrapOnObjPos( bool _bConsiderWrapOnObjPos
);
419 void SetUseFormerTextWrapping( bool _bUseFormerTextWrapping
);
421 // -> PB 2007-06-11 #i45491#
422 void SetDoNotJustifyLinesWithManualBreak( bool _bDoNotJustifyLinesWithManualBreak
);
426 // DOCUMENT COMPATIBILITY FLAGS END
429 //Ruft den Idle-Formatierer des Layouts
432 inline const SwViewOption
*GetViewOptions() const { return pOpt
; }
433 void ApplyViewOptions( const SwViewOption
&rOpt
);
434 void SetUIOptions( const SwViewOption
&rOpt
);
435 void SetReadonlyOption(sal_Bool bSet
); // Readonly-Bit d. ViewOptions setzen
436 void SetPDFExportOption(sal_Bool bSet
); // set/reset PDF export mode
437 void SetPrtFormatOption(sal_Bool bSet
); // PrtFormat-Bit d. ViewOptions setzen
438 void SetReadonlySelectionOption(sal_Bool bSet
);//change the selection mode in readonly docs
440 const SwAccessibilityOptions
* GetAccessibilityOptions() const { return pAccOptions
;}
442 static void SetShellRes( ShellResource
* pRes
) { pShellRes
= pRes
; }
443 static ShellResource
* GetShellRes();
445 static void SetCareWin( Window
* pNew
);
446 static Window
* GetCareWin(ViewShell
& rVSh
)
447 { return pCareWindow
? pCareWindow
: CareChildWin(rVSh
); }
448 static Window
* CareChildWin(ViewShell
& rVSh
);
450 inline SfxViewShell
*GetSfxViewShell() { return pSfxViewShell
; }
451 inline void SetSfxViewShell(SfxViewShell
*pNew
) { pSfxViewShell
= pNew
; }
453 // Selektion der Draw ::com::sun::star::script::Engine geaendert
454 virtual void DrawSelChanged();
456 // OD 12.12.2002 #103492#
457 SwPagePreviewLayout
* PagePreviewLayout();
459 /** adjust view options for page preview
461 OD 09.01.2003 #i6467#
462 Because page preview should show the document as it is printed -
463 page preview is print preview -, the view options are adjusted to the
464 same as for printing.
466 @param _rPrintOptions
467 input parameter - constant reference to print options, to which the
468 view option will be adjusted.
470 void AdjustOptionsForPagePreview( const SwPrtOptions
&_rPrintOptions
);
472 sal_Bool
IsViewLocked() const { return bViewLocked
; }
473 void LockView( sal_Bool b
) { bViewLocked
= b
; }
475 inline void LockPaint();
476 void ImplLockPaint();
477 inline void UnlockPaint( sal_Bool bVirDev
= sal_False
);
478 void ImplUnlockPaint( sal_Bool bVirDev
);
479 sal_Bool
IsPaintLocked() const { return nLockPaint
!= 0; }
481 // Abfragen/Erzeugen DrawView + PageView
482 sal_Bool
HasDrawView() const;
485 //DrawView darf u.U. am UI benutzt werden.
486 SdrView
*GetDrawView();
487 const SdrView
*GetDrawView() const { return ((ViewShell
*)this)->GetDrawView(); }
489 //sorge dafuer, das auf jedenfall die MarkListe aktuell ist (Bug 57153)
490 SdrView
*GetDrawViewWithValidMarkList();
492 // erfrage den Attribut Pool
493 inline const SfxItemPool
& GetAttrPool() const;
494 SfxItemPool
& GetAttrPool();
496 sal_Bool
IsPreView() const { return bPreView
; }
498 sal_Bool
IsFrameView() const { return bFrameView
; }
499 void SetFrameView( const Size
& rBrowseBorder
)
500 { bFrameView
= sal_True
; aBrowseBorder
= rBrowseBorder
; }
502 //Nimmt die notwendigen Invalidierungen vor,
503 //wenn sich der BrowdseModus aendert, bBrowseChgd == sal_True
504 //oder, im BrowseModus, wenn sich die Groessenverhaeltnisse
505 //aendern (bBrowseChgd == sal_False)
506 void CheckBrowseView( BOOL bBrowseChgd
);
508 const Size
& GetBrowseBorder() const;
509 sal_Int32
GetBrowseWidth() const;
510 void SetBrowseBorder( const Size
& rNew
);
512 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> CreateAccessible();
514 // OD 15.01.2003 #103492# - change method signature due to new page preview
516 ::com::sun::star::uno::Reference
<
517 ::com::sun::star::accessibility::XAccessible
>
518 CreateAccessiblePreview();
520 void ShowPreViewSelection( sal_uInt16 nSelPage
);
521 void InvalidateAccessibleFocus();
523 //apply Accessiblity options
524 void ApplyAccessiblityOptions(SvtAccessibilityOptions
& rAccessibilityOptions
);
526 /** invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
528 OD 2005-12-01 #i27138#
533 input parameter - paragraph frame, for which the relation CONTENT_FLOWS_FROM
534 has to be invalidated.
535 If NULL, no CONTENT_FLOWS_FROM relation has to be invalidated
538 input parameter - paragraph frame, for which the relation CONTENT_FLOWS_TO
539 has to be invalidated.
540 If NULL, no CONTENT_FLOWS_TO relation has to be invalidated
542 void InvalidateAccessibleParaFlowRelation( const SwTxtFrm
* _pFromTxtFrm
,
543 const SwTxtFrm
* _pToTxtFrm
);
545 /** invalidate text selection for paragraphs
547 OD 2005-12-12 #i27301#
551 void InvalidateAccessibleParaTextSelection();
553 /** invalidate attributes for paragraphs and paragraph's characters
555 OD 2009-01-06 #i88069#
556 OD 2010-02-16 #i104008# - usage also for changes of the attributes of
557 paragraph's characters.
562 input parameter - paragraph frame, whose attributes have changed
564 void InvalidateAccessibleParaAttrs( const SwTxtFrm
& rTxtFrm
);
566 SwAccessibleMap
* GetAccessibleMap();
568 ViewShell( ViewShell
&, Window
*pWin
= 0, OutputDevice
*pOut
= 0,
570 ViewShell( SwDoc
& rDoc
, Window
*pWin
,
571 const SwViewOption
*pOpt
= 0, OutputDevice
*pOut
= 0,
573 virtual ~ViewShell();
575 // --> FME 2004-06-15 #i12836# enhanced pdf export
576 sal_Int32
GetPageNumAndSetOffsetForPDF( OutputDevice
& rOut
, const SwRect
& rRect
) const;
579 inline bool IsInConstructor() const { return mbInConstructor
; }
581 // --> PB 2007-05-30 #146850#
582 static const BitmapEx
& GetReplacementBitmap( bool bIsErrorState
);
583 static void DeleteReplacementBitmaps();
586 const SwPostItMgr
* GetPostItMgr() const { return (const_cast<ViewShell
*>(this))->GetPostItMgr(); }
587 SwPostItMgr
* GetPostItMgr();
590 //---- class CurrShell verwaltet den globalen ShellPointer -------------------
598 CurrShell( ViewShell
*pNew
);
602 inline void ViewShell::ResetInvalidRect()
604 aInvalidRect
.Clear();
607 inline void ViewShell::StartAction()
609 if ( !nStartAction
++ )
612 inline void ViewShell::EndAction( const sal_Bool bIdleEnd
)
614 if( 0 == (nStartAction
- 1) )
615 ImplEndAction( bIdleEnd
);
619 inline void ViewShell::LockPaint()
624 inline void ViewShell::UnlockPaint( sal_Bool bVirDev
)
626 if ( 0 == --nLockPaint
)
627 ImplUnlockPaint( bVirDev
);
629 inline const SfxItemPool
& ViewShell::GetAttrPool() const
631 return ((ViewShell
*)this)->GetAttrPool();