1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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>
38 : SdrView(rSdrModel
, &rOut
),
41 SetBufferedOutputAllowed(true);
42 SetBufferedOverlayAllowed(true);
45 DlgEdView::~DlgEdView()
49 void DlgEdView::MarkListHasChanged()
51 SdrView::MarkListHasChanged();
53 DlgEdHint
aHint( DlgEdHint::SELECTIONCHANGED
);
54 rDlgEditor
.Broadcast( aHint
);
55 rDlgEditor
.UpdatePropertyBrowserDelayed();
58 void DlgEdView::MakeVisible( const tools::Rectangle
& rRect
, vcl::Window
& rWin
)
61 MapMode
aMap( rWin
.GetMapMode() );
62 Point
aOrg( aMap
.GetOrigin() );
63 Size
aVisSize( rWin
.GetOutputSize() );
64 tools::Rectangle
RectTmp( Point(-aOrg
.X(),-aOrg
.Y()), aVisSize
);
65 tools::Rectangle
aVisRect( RectTmp
);
67 // check, if rectangle is inside visible area
68 if ( !aVisRect
.IsInside( rRect
) )
70 // calculate scroll distance; the rectangle must be inside the visible area
71 sal_Int32 nScrollX
= 0, nScrollY
= 0;
73 sal_Int32 nVisLeft
= aVisRect
.Left();
74 sal_Int32 nVisRight
= aVisRect
.Right();
75 sal_Int32 nVisTop
= aVisRect
.Top();
76 sal_Int32 nVisBottom
= aVisRect
.Bottom();
78 sal_Int32 nDeltaX
= rDlgEditor
.GetHScroll()->GetLineSize();
79 sal_Int32 nDeltaY
= rDlgEditor
.GetVScroll()->GetLineSize();
81 while ( rRect
.Right() > nVisRight
+ nScrollX
)
84 while ( rRect
.Left() < nVisLeft
+ nScrollX
)
87 while ( rRect
.Bottom() > nVisBottom
+ nScrollY
)
90 while ( rRect
.Top() < nVisTop
+ nScrollY
)
93 // don't scroll beyond the page size
94 Size aPageSize
= rDlgEditor
.GetPage().GetSize();
95 sal_Int32 nPageWidth
= aPageSize
.Width();
96 sal_Int32 nPageHeight
= aPageSize
.Height();
98 if ( nVisRight
+ nScrollX
> nPageWidth
)
99 nScrollX
= nPageWidth
- nVisRight
;
101 if ( nVisLeft
+ nScrollX
< 0 )
102 nScrollX
= -nVisLeft
;
104 if ( nVisBottom
+ nScrollY
> nPageHeight
)
105 nScrollY
= nPageHeight
- nVisBottom
;
107 if ( nVisTop
+ nScrollY
< 0 )
112 rWin
.Scroll( -nScrollX
, -nScrollY
);
113 aMap
.SetOrigin( Point( aOrg
.X() - nScrollX
, aOrg
.Y() - nScrollY
) );
114 rWin
.SetMapMode( aMap
);
118 // update scroll bars
119 rDlgEditor
.UpdateScrollBars();
121 DlgEdHint
aHint( DlgEdHint::WINDOWSCROLLED
);
122 rDlgEditor
.Broadcast( aHint
);
126 SdrObject
* impLocalHitCorrection(SdrObject
* pRetval
, const Point
& rPnt
, sal_uInt16 nTol
)
128 DlgEdObj
* pDlgEdObj
= dynamic_cast< DlgEdObj
* >(pRetval
);
132 bool bExcludeInner(false);
134 if(dynamic_cast< DlgEdForm
* >(pRetval
) != nullptr)
136 // from DlgEdForm::CheckHit; exclude inner for DlgEdForm
137 bExcludeInner
= true;
139 else if(pDlgEdObj
->supportsService("com.sun.star.awt.UnoControlGroupBoxModel"))
141 // from DlgEdObj::CheckHit; exclude inner for group shapes
142 bExcludeInner
= true;
147 // use direct model data; it's a DlgEdObj, so GetLastBoundRect()
148 // will access aOutRect directly
149 const tools::Rectangle
aOuterRectangle(pDlgEdObj
->GetLastBoundRect());
151 if(!aOuterRectangle
.IsEmpty())
153 basegfx::B2DRange
aOuterRange(
154 aOuterRectangle
.Left(), aOuterRectangle
.Top(),
155 aOuterRectangle
.Right(), aOuterRectangle
.Bottom());
159 aOuterRange
.grow(-1.0 * nTol
);
162 if(aOuterRange
.isInside(basegfx::B2DPoint(rPnt
.X(), rPnt
.Y())))
173 SdrObject
* DlgEdView::CheckSingleSdrObjectHit(const Point
& rPnt
, sal_uInt16 nTol
, SdrObject
* pObj
, SdrPageView
* pPV
, SdrSearchOptions nOptions
, const SdrLayerIDSet
* pMVisLay
) const
176 SdrObject
* pRetval
= SdrView::CheckSingleSdrObjectHit(rPnt
, nTol
, pObj
, pPV
, nOptions
, pMVisLay
);
180 // check hitted object locally
181 pRetval
= impLocalHitCorrection(pRetval
, rPnt
, nTol
);
187 } // namespace basctl
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */