merge the formfield patch from ooo-build
[ooovba.git] / basctl / source / dlged / dlgedview.cxx
blob2f65709d25f7b814d169e88a20706fd3312daf9d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dlgedview.cxx,v $
10 * $Revision: 1.13 $
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_basctl.hxx"
35 #include "dlgedview.hxx"
36 #include "dlged.hxx"
37 #include <dlgedpage.hxx>
39 #ifndef _SVXIDS_HRC
40 #include <svx/svxids.hrc>
41 #endif
42 #include <sfx2/viewfrm.hxx>
44 #include <basidesh.hxx>
45 #include <iderdll.hxx>
46 #include "dlgedobj.hxx"
48 TYPEINIT1( DlgEdView, SdrView );
50 //----------------------------------------------------------------------------
52 DlgEdView::DlgEdView( SdrModel* pModel, OutputDevice* pOut, DlgEditor* pEditor )
53 :SdrView( pModel, pOut )
54 ,pDlgEditor( pEditor )
56 // #114898#
57 SetBufferedOutputAllowed(true);
58 SetBufferedOverlayAllowed(true);
61 //----------------------------------------------------------------------------
63 DlgEdView::~DlgEdView()
67 //----------------------------------------------------------------------------
69 void DlgEdView::MarkListHasChanged()
71 SdrView::MarkListHasChanged();
73 DlgEdHint aHint( DLGED_HINT_SELECTIONCHANGED );
74 if ( pDlgEditor )
76 pDlgEditor->Broadcast( aHint );
77 pDlgEditor->UpdatePropertyBrowserDelayed();
81 //----------------------------------------------------------------------------
83 void DlgEdView::MakeVisible( const Rectangle& rRect, Window& rWin )
85 // visible area
86 MapMode aMap( rWin.GetMapMode() );
87 Point aOrg( aMap.GetOrigin() );
88 Size aVisSize( rWin.GetOutputSize() );
89 Rectangle RectTmp( Point(-aOrg.X(),-aOrg.Y()), aVisSize );
90 Rectangle aVisRect( RectTmp );
92 // check, if rectangle is inside visible area
93 if ( !aVisRect.IsInside( rRect ) )
95 // calculate scroll distance; the rectangle must be inside the visible area
96 sal_Int32 nScrollX = 0, nScrollY = 0;
98 sal_Int32 nVisLeft = aVisRect.Left();
99 sal_Int32 nVisRight = aVisRect.Right();
100 sal_Int32 nVisTop = aVisRect.Top();
101 sal_Int32 nVisBottom = aVisRect.Bottom();
103 sal_Int32 nDeltaX = pDlgEditor->GetHScroll()->GetLineSize();
104 sal_Int32 nDeltaY = pDlgEditor->GetVScroll()->GetLineSize();
106 while ( rRect.Right() > nVisRight + nScrollX )
107 nScrollX += nDeltaX;
109 while ( rRect.Left() < nVisLeft + nScrollX )
110 nScrollX -= nDeltaX;
112 while ( rRect.Bottom() > nVisBottom + nScrollY )
113 nScrollY += nDeltaY;
115 while ( rRect.Top() < nVisTop + nScrollY )
116 nScrollY -= nDeltaY;
118 // don't scroll beyond the page size
119 Size aPageSize = pDlgEditor->GetPage()->GetSize();
120 sal_Int32 nPageWidth = aPageSize.Width();
121 sal_Int32 nPageHeight = aPageSize.Height();
123 if ( nVisRight + nScrollX > nPageWidth )
124 nScrollX = nPageWidth - nVisRight;
126 if ( nVisLeft + nScrollX < 0 )
127 nScrollX = -nVisLeft;
129 if ( nVisBottom + nScrollY > nPageHeight )
130 nScrollY = nPageHeight - nVisBottom;
132 if ( nVisTop + nScrollY < 0 )
133 nScrollY = -nVisTop;
135 // scroll window
136 rWin.Update();
137 rWin.Scroll( -nScrollX, -nScrollY );
138 aMap.SetOrigin( Point( aOrg.X() - nScrollX, aOrg.Y() - nScrollY ) );
139 rWin.SetMapMode( aMap );
140 rWin.Update();
141 rWin.Invalidate();
143 // update scroll bars
144 if ( pDlgEditor )
145 pDlgEditor->UpdateScrollBars();
147 DlgEdHint aHint( DLGED_HINT_WINDOWSCROLLED );
148 if ( pDlgEditor )
149 pDlgEditor->Broadcast( aHint );
153 //----------------------------------------------------------------------------
155 SdrObject* impLocalHitCorrection(SdrObject* pRetval, const Point& rPnt, USHORT nTol)
157 DlgEdObj* pDlgEdObj = dynamic_cast< DlgEdObj* >(pRetval);
159 if(pDlgEdObj)
161 bool bExcludeInner(false);
163 if(0 != dynamic_cast< DlgEdForm* >(pRetval))
165 // from DlgEdForm::CheckHit; exclude inner for DlgEdForm
166 bExcludeInner = true;
168 else if(pDlgEdObj->supportsService("com.sun.star.awt.UnoControlGroupBoxModel"))
170 // from DlgEdObj::CheckHit; exclude inner for group shapes
171 bExcludeInner = true;
174 if(bExcludeInner)
176 // use direct model data; it's a DlgEdObj, so GetLastBoundRect()
177 // will access aOutRect directly
178 const Rectangle aOuterRectangle(pDlgEdObj->GetLastBoundRect());
180 if(!aOuterRectangle.IsEmpty()
181 && RECT_EMPTY != aOuterRectangle.Right()
182 && RECT_EMPTY != aOuterRectangle.Bottom())
184 basegfx::B2DRange aOuterRange(
185 aOuterRectangle.Left(), aOuterRectangle.Top(),
186 aOuterRectangle.Right(), aOuterRectangle.Bottom());
188 if(nTol)
190 aOuterRange.grow(-1.0 * nTol);
193 if(aOuterRange.isInside(basegfx::B2DPoint(rPnt.X(), rPnt.Y())))
195 pRetval = 0;
201 return pRetval;
204 SdrObject* DlgEdView::CheckSingleSdrObjectHit(const Point& rPnt, USHORT nTol, SdrObject* pObj, SdrPageView* pPV, ULONG nOptions, const SetOfByte* pMVisLay) const
206 // call parent
207 SdrObject* pRetval = SdrView::CheckSingleSdrObjectHit(rPnt, nTol, pObj, pPV, nOptions, pMVisLay);
209 if(pRetval)
211 // check hitted object locally
212 pRetval = impLocalHitCorrection(pRetval, rPnt, nTol);
215 return pRetval;
218 //----------------------------------------------------------------------------
219 // eof