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: vdraw.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"
35 #include <svx/svdmodel.hxx>
36 #include <svx/svdpage.hxx>
37 #include <tools/shl.hxx>
38 #include <swmodule.hxx>
39 #include <svtools/accessibilityoptions.hxx>
40 #include <svx/svdpagv.hxx>
41 #include <fmtanchr.hxx>
44 /// OD 29.08.2002 #102450#
45 /// include <svx/svdoutl.hxx>
46 #include <svx/svdoutl.hxx>
49 #ifndef _SVX_FMGLOB_HXX
50 #include <svx/fmglob.hxx>
55 #include "pagefrm.hxx"
56 #include "rootfrm.hxx"
57 #include "viewimp.hxx"
58 #include "dflyobj.hxx"
59 #include "viewopt.hxx"
60 #include "dcontact.hxx"
63 #include <vcl/svapp.hxx>
65 #ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED
66 #include <IDocumentDrawModelAccess.hxx>
69 /*************************************************************************
73 |* Ersterstellung MA 14. Feb. 95
74 |* Letzte Aenderung MA 02. Jun. 98
76 |*************************************************************************/
77 //SwSaveHdl::SwSaveHdl( SwViewImp *pI ) :
81 //if ( pImp->HasDrawView() )
83 // bXorVis = pImp->GetDrawView()->IsShownXorVisible( pImp->GetShell()->GetOut());
85 // pImp->GetDrawView()->HideShownXor( pImp->GetShell()->GetOut() );
90 //SwSaveHdl::~SwSaveHdl()
93 // pImp->GetDrawView()->ShowShownXor( pImp->GetShell()->GetOut() );
97 /*************************************************************************
99 |* SwViewImp::StartAction(), EndAction()
101 |* Ersterstellung MA 14. Feb. 95
102 |* Letzte Aenderung MA 14. Sep. 98
104 |*************************************************************************/
107 void SwViewImp::StartAction()
111 SET_CURR_SHELL( GetShell() );
112 if ( pSh
->ISA(SwFEShell
) )
113 ((SwFEShell
*)pSh
)->HideChainMarker(); //Kann sich geaendert haben
114 //bResetXorVisibility = GetDrawView()->IsShownXorVisible( GetShell()->GetOut());
115 //GetDrawView()->HideShownXor( GetShell()->GetOut() );
121 void SwViewImp::EndAction()
125 SET_CURR_SHELL( GetShell() );
126 //if ( bResetXorVisibility )
127 // GetDrawView()->ShowShownXor( GetShell()->GetOut() );
128 if ( pSh
->ISA(SwFEShell
) )
129 ((SwFEShell
*)pSh
)->SetChainMarker(); //Kann sich geaendert haben
133 /*************************************************************************
135 |* SwViewImp::LockPaint(), UnlockPaint()
137 |* Ersterstellung MA 11. Jun. 96
138 |* Letzte Aenderung MA 11. Jun. 96
140 |*************************************************************************/
143 void SwViewImp::LockPaint()
147 //HMHbShowHdlPaint = GetDrawView()->IsMarkHdlShown();
148 //HMHif ( bShowHdlPaint )
149 //HMH GetDrawView()->HideMarkHdl();
150 bResetHdlHiddenPaint
= !GetDrawView()->areMarkHandlesHidden();
151 GetDrawView()->hideMarkHandles();
155 //HMHbShowHdlPaint = FALSE;
156 bResetHdlHiddenPaint
= FALSE
;
162 void SwViewImp::UnlockPaint()
164 if ( bResetHdlHiddenPaint
)
165 GetDrawView()->showMarkHandles();
166 //HMHif ( bShowHdlPaint )
167 //HMH GetDrawView()->ShowMarkHdl();
171 /*************************************************************************
173 |* SwViewImp::PaintLayer(), PaintDispatcher()
175 |* Ersterstellung MA 20. Dec. 94
176 |* Letzte Aenderung AMA 04. Jun. 98
178 |*************************************************************************/
179 // OD 29.08.2002 #102450#
180 // add 3rd paramter <const Color* pPageBackgrdColor> for setting this
181 // color as the background color at the outliner of the draw view.
182 // OD 09.12.2002 #103045# - add 4th parameter for the horizontal text direction
183 // of the page in order to set the default horizontal text direction at the
184 // outliner of the draw view for painting layers <hell> and <heaven>.
185 // OD 25.06.2003 #108784# - correct type of 1st parameter
186 void SwViewImp::PaintLayer( const SdrLayerID _nLayerID
,
188 const Color
* _pPageBackgrdColor
,
189 const bool _bIsPageRightToLeft
) const
193 //change the draw mode in high contrast mode
194 OutputDevice
* pOutDev
= GetShell()->GetOut();
195 ULONG nOldDrawMode
= pOutDev
->GetDrawMode();
196 if( GetShell()->GetWin() &&
197 Application::GetSettings().GetStyleSettings().GetHighContrastMode() &&
198 (!GetShell()->IsPreView()||SW_MOD()->GetAccessibilityOptions().GetIsForPagePreviews()))
200 pOutDev
->SetDrawMode( nOldDrawMode
| DRAWMODE_SETTINGSLINE
| DRAWMODE_SETTINGSFILL
|
201 DRAWMODE_SETTINGSTEXT
| DRAWMODE_SETTINGSGRADIENT
);
204 // OD 29.08.2002 #102450#
205 // For correct handling of accessibility, high contrast, the page background
206 // color is set as the background color at the outliner of the draw view.
207 // Only necessary for the layers hell and heaven
208 Color aOldOutlinerBackgrdColor
;
209 // OD 09.12.2002 #103045# - set default horizontal text direction on
210 // painting <hell> or <heaven>.
211 EEHorizontalTextDirection aOldEEHoriTextDir
= EE_HTEXTDIR_L2R
;
212 const IDocumentDrawModelAccess
* pIDDMA
= GetShell()->getIDocumentDrawModelAccess();
213 if ( (_nLayerID
== pIDDMA
->GetHellId()) ||
214 (_nLayerID
== pIDDMA
->GetHeavenId()) )
216 ASSERT( _pPageBackgrdColor
,
217 "incorrect usage of SwViewImp::PaintLayer: pPageBackgrdColor have to be set for painting layer <hell> or <heaven>");
218 if ( _pPageBackgrdColor
)
220 aOldOutlinerBackgrdColor
=
221 GetDrawView()->GetModel()->GetDrawOutliner().GetBackgroundColor();
222 GetDrawView()->GetModel()->GetDrawOutliner().SetBackgroundColor( *_pPageBackgrdColor
);
226 GetDrawView()->GetModel()->GetDrawOutliner().GetDefaultHorizontalTextDirection();
227 EEHorizontalTextDirection aEEHoriTextDirOfPage
=
228 _bIsPageRightToLeft
? EE_HTEXTDIR_R2L
: EE_HTEXTDIR_L2R
;
229 GetDrawView()->GetModel()->GetDrawOutliner().SetDefaultHorizontalTextDirection( aEEHoriTextDirOfPage
);
232 pOutDev
->Push( PUSH_LINECOLOR
); // #114231#
233 GetPageView()->DrawLayer(_nLayerID
, pOutDev
);
236 // OD 29.08.2002 #102450#
237 // reset background color of the outliner
238 // OD 09.12.2002 #103045# - reset default horizontal text direction
239 if ( (_nLayerID
== pIDDMA
->GetHellId()) ||
240 (_nLayerID
== pIDDMA
->GetHeavenId()) )
242 GetDrawView()->GetModel()->GetDrawOutliner().SetBackgroundColor( aOldOutlinerBackgrdColor
);
243 GetDrawView()->GetModel()->GetDrawOutliner().SetDefaultHorizontalTextDirection( aOldEEHoriTextDir
);
246 pOutDev
->SetDrawMode( nOldDrawMode
);
250 /*************************************************************************
252 |* SwViewImp::IsDragPossible()
254 |* Ersterstellung MA 19. Jan. 93
255 |* Letzte Aenderung MA 16. Jan. 95
257 |*************************************************************************/
258 #define WIEDUWILLST 400
260 BOOL
SwViewImp::IsDragPossible( const Point
&rPoint
)
262 if ( !HasDrawView() )
265 const SdrMarkList
&rMrkList
= GetDrawView()->GetMarkedObjectList();
267 if( !rMrkList
.GetMarkCount() )
270 SdrObject
*pO
= rMrkList
.GetMark(rMrkList
.GetMarkCount()-1)->GetMarkedSdrObj();
273 if( ::CalcClipRect( pO
, aRect
, FALSE
) )
276 ::CalcClipRect( pO
, aTmp
, TRUE
);
280 aRect
= GetShell()->GetLayout()->Frm();
282 aRect
.Top( aRect
.Top() - WIEDUWILLST
);
283 aRect
.Bottom( aRect
.Bottom() + WIEDUWILLST
);
284 aRect
.Left( aRect
.Left() - WIEDUWILLST
);
285 aRect
.Right( aRect
.Right() + WIEDUWILLST
);
286 return aRect
.IsInside( rPoint
);
289 /*************************************************************************
291 |* SwViewImp::NotifySizeChg()
293 |* Ersterstellung MA 23. Jun. 93
294 |* Letzte Aenderung MA 05. Oct. 98
296 |*************************************************************************/
298 void SwViewImp::NotifySizeChg( const Size
&rNewSz
)
300 if ( !HasDrawView() )
304 GetPageView()->GetPage()->SetSize( rNewSz
);
306 //Begrenzung des Arbeitsbereiches.
307 const Rectangle
aRect( Point( DOCUMENTBORDER
, DOCUMENTBORDER
), rNewSz
);
308 const Rectangle
&rOldWork
= GetDrawView()->GetWorkArea();
309 BOOL bCheckDrawObjs
= FALSE
;
310 if ( aRect
!= rOldWork
)
312 if ( rOldWork
.Bottom() > aRect
.Bottom() || rOldWork
.Right() > aRect
.Right())
313 bCheckDrawObjs
= TRUE
;
314 GetDrawView()->SetWorkArea( aRect
);
316 if ( !bCheckDrawObjs
)
319 ASSERT( pSh
->getIDocumentDrawModelAccess()->GetDrawModel(), "NotifySizeChg without DrawModel" );
320 SdrPage
* pPage
= pSh
->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage( 0 );
321 const ULONG nObjs
= pPage
->GetObjCount();
322 for( ULONG nObj
= 0; nObj
< nObjs
; ++nObj
)
324 SdrObject
*pObj
= pPage
->GetObj( nObj
);
325 if( !pObj
->ISA(SwVirtFlyDrawObj
) )
327 //Teilfix(26793): Objekte, die in Rahmen verankert sind, brauchen
328 //nicht angepasst werden.
329 const SwContact
*pCont
= (SwContact
*)GetUserCall(pObj
);
330 //JP - 16.3.00 Bug 73920: this function might be called by the
331 // InsertDocument, when a PageDesc-Attribute is
332 // set on a node. Then the SdrObject must not have
334 if( !pCont
|| !pCont
->ISA(SwDrawContact
) )
337 const SwFrm
*pAnchor
= ((SwDrawContact
*)pCont
)->GetAnchorFrm();
338 if ( !pAnchor
|| pAnchor
->IsInFly() || !pAnchor
->IsValid() ||
339 !pAnchor
->GetUpper() || !pAnchor
->FindPageFrm() ||
340 FLY_IN_CNTNT
== pCont
->GetFmt()->GetAnchor().GetAnchorId() )
343 // OD 19.06.2003 #108784# - no move for drawing objects in header/footer
344 if ( pAnchor
->FindFooterOrHeader() )
349 const Rectangle
aBound( pObj
->GetCurrentBoundRect() );
350 if ( !aRect
.IsInside( aBound
) )
353 if ( aBound
.Left() > aRect
.Right() )
354 aSz
.Width() = (aRect
.Right() - aBound
.Left()) - MINFLY
;
355 if ( aBound
.Top() > aRect
.Bottom() )
356 aSz
.Height() = (aRect
.Bottom() - aBound
.Top()) - MINFLY
;
357 if ( aSz
.Width() || aSz
.Height() )
360 //Notanker: Grosse Objekte nicht nach oben verschwinden lassen.
361 aSz
.Width() = aSz
.Height() = 0;
362 if ( aBound
.Bottom() < aRect
.Top() )
363 aSz
.Width() = (aBound
.Bottom() - aRect
.Top()) - MINFLY
;
364 if ( aBound
.Right() < aRect
.Left() )
365 aSz
.Height() = (aBound
.Right() - aRect
.Left()) - MINFLY
;
366 if ( aSz
.Width() || aSz
.Height() )