Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <svx/svdmodel.hxx>
21 : #include <svx/svdpage.hxx>
22 : #include <tools/shl.hxx>
23 : #include <swmodule.hxx>
24 : #include <svtools/accessibilityoptions.hxx>
25 : #include <svx/svdpagv.hxx>
26 : #include <fmtanchr.hxx>
27 : #include <frmfmt.hxx>
28 :
29 : #include <svx/svdoutl.hxx>
30 :
31 : #include "fesh.hxx"
32 : #include "pagefrm.hxx"
33 : #include "rootfrm.hxx"
34 : #include "viewimp.hxx"
35 : #include "dflyobj.hxx"
36 : #include "viewopt.hxx"
37 : #include "printdata.hxx"
38 : #include "dcontact.hxx"
39 : #include "dview.hxx"
40 : #include "flyfrm.hxx"
41 : #include <vcl/svapp.hxx>
42 :
43 : #include <IDocumentDrawModelAccess.hxx>
44 :
45 :
46 2054 : void SwViewImp::StartAction()
47 : {
48 2054 : if ( HasDrawView() )
49 : {
50 2054 : SET_CURR_SHELL( GetShell() );
51 2054 : if ( pSh->ISA(SwFEShell) )
52 2054 : ((SwFEShell*)pSh)->HideChainMarker(); // might have changed
53 : }
54 2054 : }
55 :
56 :
57 1333 : void SwViewImp::EndAction()
58 : {
59 1333 : if ( HasDrawView() )
60 : {
61 1333 : SET_CURR_SHELL( GetShell() );
62 1333 : if ( pSh->ISA(SwFEShell) )
63 1333 : ((SwFEShell*)pSh)->SetChainMarker(); // might have changed
64 : }
65 1333 : }
66 :
67 :
68 644 : void SwViewImp::LockPaint()
69 : {
70 644 : if ( HasDrawView() )
71 : {
72 644 : bResetHdlHiddenPaint = !GetDrawView()->areMarkHandlesHidden();
73 644 : GetDrawView()->hideMarkHandles();
74 : }
75 : else
76 : {
77 0 : bResetHdlHiddenPaint = sal_False;
78 : }
79 644 : }
80 :
81 :
82 644 : void SwViewImp::UnlockPaint()
83 : {
84 644 : if ( bResetHdlHiddenPaint )
85 644 : GetDrawView()->showMarkHandles();
86 644 : }
87 :
88 :
89 548 : void SwViewImp::PaintLayer( const SdrLayerID _nLayerID,
90 : SwPrintData const*const pPrintData,
91 : const SwRect& aPaintRect,
92 : const Color* _pPageBackgrdColor,
93 : const bool _bIsPageRightToLeft,
94 : sdr::contact::ViewObjectContactRedirector* pRedirector ) const
95 : {
96 548 : if ( HasDrawView() )
97 : {
98 : //change the draw mode in high contrast mode
99 548 : OutputDevice* pOutDev = GetShell()->GetOut();
100 548 : sal_uLong nOldDrawMode = pOutDev->GetDrawMode();
101 1092 : if( GetShell()->GetWin() &&
102 544 : Application::GetSettings().GetStyleSettings().GetHighContrastMode() &&
103 0 : (!GetShell()->IsPreView()||SW_MOD()->GetAccessibilityOptions().GetIsForPagePreviews()))
104 : {
105 : pOutDev->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
106 0 : DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
107 : }
108 :
109 : // For correct handling of accessibility, high contrast, the
110 : // page background color is set as the background color at the
111 : // outliner of the draw view. Only necessary for the layers
112 : // hell and heaven
113 548 : Color aOldOutlinerBackgrdColor;
114 : // set default horizontal text direction on painting <hell> or
115 : // <heaven>.
116 548 : EEHorizontalTextDirection aOldEEHoriTextDir = EE_HTEXTDIR_L2R;
117 548 : const IDocumentDrawModelAccess* pIDDMA = GetShell()->getIDocumentDrawModelAccess();
118 822 : if ( (_nLayerID == pIDDMA->GetHellId()) ||
119 274 : (_nLayerID == pIDDMA->GetHeavenId()) )
120 : {
121 : OSL_ENSURE( _pPageBackgrdColor,
122 : "incorrect usage of SwViewImp::PaintLayer: pPageBackgrdColor have to be set for painting layer <hell> or <heaven>");
123 548 : if ( _pPageBackgrdColor )
124 : {
125 : aOldOutlinerBackgrdColor =
126 548 : GetDrawView()->GetModel()->GetDrawOutliner().GetBackgroundColor();
127 548 : GetDrawView()->GetModel()->GetDrawOutliner().SetBackgroundColor( *_pPageBackgrdColor );
128 : }
129 :
130 : aOldEEHoriTextDir =
131 548 : GetDrawView()->GetModel()->GetDrawOutliner().GetDefaultHorizontalTextDirection();
132 : EEHorizontalTextDirection aEEHoriTextDirOfPage =
133 548 : _bIsPageRightToLeft ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
134 548 : GetDrawView()->GetModel()->GetDrawOutliner().SetDefaultHorizontalTextDirection( aEEHoriTextDirOfPage );
135 : }
136 :
137 548 : pOutDev->Push( PUSH_LINECOLOR ); // #114231#
138 548 : if (pPrintData)
139 : {
140 : // hide drawings but not form controls (form controls are handled elsewhere)
141 0 : SdrView &rSdrView = const_cast< SdrView & >(GetPageView()->GetView());
142 0 : rSdrView.setHideDraw( !pPrintData->IsPrintDraw() );
143 : }
144 548 : GetPageView()->DrawLayer( _nLayerID, pOutDev, pRedirector, aPaintRect.SVRect() );
145 548 : pOutDev->Pop();
146 :
147 : // reset background color of the outliner & default horiz. text dir.
148 822 : if ( (_nLayerID == pIDDMA->GetHellId()) ||
149 274 : (_nLayerID == pIDDMA->GetHeavenId()) )
150 : {
151 548 : GetDrawView()->GetModel()->GetDrawOutliner().SetBackgroundColor( aOldOutlinerBackgrdColor );
152 548 : GetDrawView()->GetModel()->GetDrawOutliner().SetDefaultHorizontalTextDirection( aOldEEHoriTextDir );
153 : }
154 :
155 548 : pOutDev->SetDrawMode( nOldDrawMode );
156 : }
157 548 : }
158 :
159 :
160 : #define WIEDUWILLST 400
161 :
162 0 : sal_Bool SwViewImp::IsDragPossible( const Point &rPoint )
163 : {
164 0 : if ( !HasDrawView() )
165 0 : return sal_False;
166 :
167 0 : const SdrMarkList &rMrkList = GetDrawView()->GetMarkedObjectList();
168 :
169 0 : if( !rMrkList.GetMarkCount() )
170 0 : return sal_False;
171 :
172 0 : SdrObject *pO = rMrkList.GetMark(rMrkList.GetMarkCount()-1)->GetMarkedSdrObj();
173 :
174 0 : SwRect aRect;
175 0 : if( pO && ::CalcClipRect( pO, aRect, sal_False ) )
176 : {
177 0 : SwRect aTmp;
178 0 : ::CalcClipRect( pO, aTmp, sal_True );
179 0 : aRect.Union( aTmp );
180 : }
181 : else
182 0 : aRect = GetShell()->GetLayout()->Frm();
183 :
184 0 : aRect.Top( aRect.Top() - WIEDUWILLST );
185 0 : aRect.Bottom( aRect.Bottom() + WIEDUWILLST );
186 0 : aRect.Left( aRect.Left() - WIEDUWILLST );
187 0 : aRect.Right( aRect.Right() + WIEDUWILLST );
188 0 : return aRect.IsInside( rPoint );
189 : }
190 :
191 :
192 283 : void SwViewImp::NotifySizeChg( const Size &rNewSz )
193 : {
194 283 : if ( !HasDrawView() )
195 : return;
196 :
197 16 : if ( GetPageView() )
198 16 : GetPageView()->GetPage()->SetSize( rNewSz );
199 :
200 : // Limitation of the work area
201 16 : const Rectangle aRect( Point( DOCUMENTBORDER, DOCUMENTBORDER ), rNewSz );
202 16 : const Rectangle &rOldWork = GetDrawView()->GetWorkArea();
203 16 : bool bCheckDrawObjs = false;
204 16 : if ( aRect != rOldWork )
205 : {
206 16 : if ( rOldWork.Bottom() > aRect.Bottom() || rOldWork.Right() > aRect.Right())
207 1 : bCheckDrawObjs = true;
208 16 : GetDrawView()->SetWorkArea( aRect );
209 : }
210 16 : if ( !bCheckDrawObjs )
211 : return;
212 :
213 : OSL_ENSURE( pSh->getIDocumentDrawModelAccess()->GetDrawModel(), "NotifySizeChg without DrawModel" );
214 1 : SdrPage* pPage = pSh->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage( 0 );
215 1 : const sal_uLong nObjs = pPage->GetObjCount();
216 1 : for( sal_uLong nObj = 0; nObj < nObjs; ++nObj )
217 : {
218 0 : SdrObject *pObj = pPage->GetObj( nObj );
219 0 : if( !pObj->ISA(SwVirtFlyDrawObj) )
220 : {
221 : // Objects not anchored to the frame, do not need to be adjusted
222 0 : const SwContact *pCont = (SwContact*)GetUserCall(pObj);
223 : // this function might be called by the InsertDocument, when
224 : // a PageDesc-Attribute is set on a node. Then the SdrObject
225 : // must not have an UserCall.
226 0 : if( !pCont || !pCont->ISA(SwDrawContact) )
227 0 : continue;
228 :
229 0 : const SwFrm *pAnchor = ((SwDrawContact*)pCont)->GetAnchorFrm();
230 0 : if ( !pAnchor || pAnchor->IsInFly() || !pAnchor->IsValid() ||
231 0 : !pAnchor->GetUpper() || !pAnchor->FindPageFrm() ||
232 0 : (FLY_AS_CHAR == pCont->GetFmt()->GetAnchor().GetAnchorId()) )
233 : {
234 0 : continue;
235 : }
236 :
237 : // no move for drawing objects in header/footer
238 0 : if ( pAnchor->FindFooterOrHeader() )
239 : {
240 0 : continue;
241 : }
242 :
243 0 : const Rectangle aBound( pObj->GetCurrentBoundRect() );
244 0 : if ( !aRect.IsInside( aBound ) )
245 : {
246 0 : Size aSz;
247 0 : if ( aBound.Left() > aRect.Right() )
248 0 : aSz.Width() = (aRect.Right() - aBound.Left()) - MINFLY;
249 0 : if ( aBound.Top() > aRect.Bottom() )
250 0 : aSz.Height() = (aRect.Bottom() - aBound.Top()) - MINFLY;
251 0 : if ( aSz.Width() || aSz.Height() )
252 0 : pObj->Move( aSz );
253 :
254 : // Don't let large objects dissappear to the top
255 0 : aSz.Width() = aSz.Height() = 0;
256 0 : if ( aBound.Bottom() < aRect.Top() )
257 0 : aSz.Width() = (aBound.Bottom() - aRect.Top()) - MINFLY;
258 0 : if ( aBound.Right() < aRect.Left() )
259 0 : aSz.Height() = (aBound.Right() - aRect.Left()) - MINFLY;
260 0 : if ( aSz.Width() || aSz.Height() )
261 0 : pObj->Move( aSz );
262 : }
263 : }
264 : }
265 : }
266 :
267 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|