bump product version to 4.1.6.2
[LibreOffice.git] / basctl / source / dlged / dlgedview.cxx
blobee06f8ffda4bda285adb113655ea7359678242bb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "dlgedview.hxx"
21 #include "dlged.hxx"
22 #include <dlgedpage.hxx>
24 #include <svx/svxids.hrc>
25 #include <sfx2/viewfrm.hxx>
27 #include <basidesh.hxx>
28 #include <iderdll.hxx>
29 #include "dlgedobj.hxx"
31 namespace basctl
34 TYPEINIT1( DlgEdView, SdrView );
36 //----------------------------------------------------------------------------
38 DlgEdView::DlgEdView (SdrModel& rModel, OutputDevice& rOut, DlgEditor& rEditor) :
39 SdrView(&rModel, &rOut),
40 rDlgEditor(rEditor)
42 // #114898#
43 SetBufferedOutputAllowed(true);
44 SetBufferedOverlayAllowed(true);
47 //----------------------------------------------------------------------------
49 DlgEdView::~DlgEdView()
53 //----------------------------------------------------------------------------
55 void DlgEdView::MarkListHasChanged()
57 SdrView::MarkListHasChanged();
59 DlgEdHint aHint( DlgEdHint::SELECTIONCHANGED );
60 rDlgEditor.Broadcast( aHint );
61 rDlgEditor.UpdatePropertyBrowserDelayed();
64 //----------------------------------------------------------------------------
66 void DlgEdView::MakeVisible( const Rectangle& rRect, Window& rWin )
68 // visible area
69 MapMode aMap( rWin.GetMapMode() );
70 Point aOrg( aMap.GetOrigin() );
71 Size aVisSize( rWin.GetOutputSize() );
72 Rectangle RectTmp( Point(-aOrg.X(),-aOrg.Y()), aVisSize );
73 Rectangle aVisRect( RectTmp );
75 // check, if rectangle is inside visible area
76 if ( !aVisRect.IsInside( rRect ) )
78 // calculate scroll distance; the rectangle must be inside the visible area
79 sal_Int32 nScrollX = 0, nScrollY = 0;
81 sal_Int32 nVisLeft = aVisRect.Left();
82 sal_Int32 nVisRight = aVisRect.Right();
83 sal_Int32 nVisTop = aVisRect.Top();
84 sal_Int32 nVisBottom = aVisRect.Bottom();
86 sal_Int32 nDeltaX = rDlgEditor.GetHScroll()->GetLineSize();
87 sal_Int32 nDeltaY = rDlgEditor.GetVScroll()->GetLineSize();
89 while ( rRect.Right() > nVisRight + nScrollX )
90 nScrollX += nDeltaX;
92 while ( rRect.Left() < nVisLeft + nScrollX )
93 nScrollX -= nDeltaX;
95 while ( rRect.Bottom() > nVisBottom + nScrollY )
96 nScrollY += nDeltaY;
98 while ( rRect.Top() < nVisTop + nScrollY )
99 nScrollY -= nDeltaY;
101 // don't scroll beyond the page size
102 Size aPageSize = rDlgEditor.GetPage().GetSize();
103 sal_Int32 nPageWidth = aPageSize.Width();
104 sal_Int32 nPageHeight = aPageSize.Height();
106 if ( nVisRight + nScrollX > nPageWidth )
107 nScrollX = nPageWidth - nVisRight;
109 if ( nVisLeft + nScrollX < 0 )
110 nScrollX = -nVisLeft;
112 if ( nVisBottom + nScrollY > nPageHeight )
113 nScrollY = nPageHeight - nVisBottom;
115 if ( nVisTop + nScrollY < 0 )
116 nScrollY = -nVisTop;
118 // scroll window
119 rWin.Update();
120 rWin.Scroll( -nScrollX, -nScrollY );
121 aMap.SetOrigin( Point( aOrg.X() - nScrollX, aOrg.Y() - nScrollY ) );
122 rWin.SetMapMode( aMap );
123 rWin.Update();
124 rWin.Invalidate();
126 // update scroll bars
127 rDlgEditor.UpdateScrollBars();
129 DlgEdHint aHint( DlgEdHint::WINDOWSCROLLED );
130 rDlgEditor.Broadcast( aHint );
134 //----------------------------------------------------------------------------
136 SdrObject* impLocalHitCorrection(SdrObject* pRetval, const Point& rPnt, sal_uInt16 nTol)
138 DlgEdObj* pDlgEdObj = dynamic_cast< DlgEdObj* >(pRetval);
140 if(pDlgEdObj)
142 bool bExcludeInner(false);
144 if(0 != dynamic_cast< DlgEdForm* >(pRetval))
146 // from DlgEdForm::CheckHit; exclude inner for DlgEdForm
147 bExcludeInner = true;
149 else if(pDlgEdObj->supportsService("com.sun.star.awt.UnoControlGroupBoxModel"))
151 // from DlgEdObj::CheckHit; exclude inner for group shapes
152 bExcludeInner = true;
155 if(bExcludeInner)
157 // use direct model data; it's a DlgEdObj, so GetLastBoundRect()
158 // will access aOutRect directly
159 const Rectangle aOuterRectangle(pDlgEdObj->GetLastBoundRect());
161 if(!aOuterRectangle.IsEmpty()
162 && RECT_EMPTY != aOuterRectangle.Right()
163 && RECT_EMPTY != aOuterRectangle.Bottom())
165 basegfx::B2DRange aOuterRange(
166 aOuterRectangle.Left(), aOuterRectangle.Top(),
167 aOuterRectangle.Right(), aOuterRectangle.Bottom());
169 if(nTol)
171 aOuterRange.grow(-1.0 * nTol);
174 if(aOuterRange.isInside(basegfx::B2DPoint(rPnt.X(), rPnt.Y())))
176 pRetval = 0;
182 return pRetval;
185 SdrObject* DlgEdView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, sal_uLong nOptions, const SetOfByte* pMVisLay) const
187 // call parent
188 SdrObject* pRetval = SdrView::CheckSingleSdrObjectHit(rPnt, nTol, pObj, pPV, nOptions, pMVisLay);
190 if(pRetval)
192 // check hitted object locally
193 pRetval = impLocalHitCorrection(pRetval, rPnt, nTol);
196 return pRetval;
199 } // namespace basctl
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */