19e0e4191SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
39e0e4191SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
49e0e4191SAndrew Rist * or more contributor license agreements. See the NOTICE file
59e0e4191SAndrew Rist * distributed with this work for additional information
69e0e4191SAndrew Rist * regarding copyright ownership. The ASF licenses this file
79e0e4191SAndrew Rist * to you under the Apache License, Version 2.0 (the
89e0e4191SAndrew Rist * "License"); you may not use this file except in compliance
99e0e4191SAndrew Rist * with the License. You may obtain a copy of the License at
109e0e4191SAndrew Rist *
119e0e4191SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
129e0e4191SAndrew Rist *
139e0e4191SAndrew Rist * Unless required by applicable law or agreed to in writing,
149e0e4191SAndrew Rist * software distributed under the License is distributed on an
159e0e4191SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169e0e4191SAndrew Rist * KIND, either express or implied. See the License for the
179e0e4191SAndrew Rist * specific language governing permissions and limitations
189e0e4191SAndrew Rist * under the License.
199e0e4191SAndrew Rist *
209e0e4191SAndrew Rist *************************************************************/
219e0e4191SAndrew Rist
229e0e4191SAndrew Rist
23*b63233d8Sdamjan #include "precompiled_rptui.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir #include "ViewsWindow.hxx"
26cdf0e10cSrcweir #include "ScrollHelper.hxx"
27cdf0e10cSrcweir #include "UndoActions.hxx"
28cdf0e10cSrcweir #include "ReportWindow.hxx"
29cdf0e10cSrcweir #include "DesignView.hxx"
30cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
31cdf0e10cSrcweir #include "ReportController.hxx"
32cdf0e10cSrcweir #include "UITools.hxx"
33cdf0e10cSrcweir #include "RptDef.hxx"
34cdf0e10cSrcweir #include "RptResId.hrc"
35cdf0e10cSrcweir #include "SectionView.hxx"
36cdf0e10cSrcweir #include "ReportSection.hxx"
37cdf0e10cSrcweir #include "uistrings.hrc"
38cdf0e10cSrcweir #include "rptui_slotid.hrc"
39cdf0e10cSrcweir #include "dlgedclip.hxx"
40cdf0e10cSrcweir #include "ColorChanger.hxx"
41cdf0e10cSrcweir #include "RptObject.hxx"
42cdf0e10cSrcweir #include "RptObject.hxx"
43cdf0e10cSrcweir #include "ModuleHelper.hxx"
44cdf0e10cSrcweir #include "EndMarker.hxx"
45cdf0e10cSrcweir #include <svx/svdpagv.hxx>
46cdf0e10cSrcweir #include <svx/unoshape.hxx>
47cdf0e10cSrcweir #include <vcl/svapp.hxx>
48cdf0e10cSrcweir #include <boost/bind.hpp>
49cdf0e10cSrcweir
50cdf0e10cSrcweir #include "helpids.hrc"
51cdf0e10cSrcweir #include <svx/svdundo.hxx>
52cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
53cdf0e10cSrcweir #include <algorithm>
54cdf0e10cSrcweir #include <numeric>
55cdf0e10cSrcweir
56cdf0e10cSrcweir namespace rptui
57cdf0e10cSrcweir {
58cdf0e10cSrcweir #define DEFAUL_MOVE_SIZE 100
59cdf0e10cSrcweir
60cdf0e10cSrcweir using namespace ::com::sun::star;
61cdf0e10cSrcweir using namespace ::comphelper;
62cdf0e10cSrcweir // -----------------------------------------------------------------------------
lcl_getNewRectSize(const Rectangle & _aObjRect,long & _nXMov,long & _nYMov,SdrObject * _pObj,SdrView * _pView,sal_Int32 _nControlModification,bool _bBoundRects)63cdf0e10cSrcweir bool lcl_getNewRectSize(const Rectangle& _aObjRect,long& _nXMov, long& _nYMov,SdrObject* _pObj,SdrView* _pView,sal_Int32 _nControlModification, bool _bBoundRects)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir bool bMoveAllowed = _nXMov != 0 || _nYMov != 0;
66cdf0e10cSrcweir if ( bMoveAllowed )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir Rectangle aNewRect = _aObjRect;
69cdf0e10cSrcweir SdrObject* pOverlappedObj = NULL;
70cdf0e10cSrcweir do
71cdf0e10cSrcweir {
72cdf0e10cSrcweir aNewRect = _aObjRect;
73cdf0e10cSrcweir switch(_nControlModification)
74cdf0e10cSrcweir {
75cdf0e10cSrcweir case ControlModification::HEIGHT_GREATEST:
76cdf0e10cSrcweir case ControlModification::WIDTH_GREATEST:
77cdf0e10cSrcweir aNewRect.setWidth(_nXMov);
78cdf0e10cSrcweir aNewRect.setHeight(_nYMov);
79cdf0e10cSrcweir break;
80cdf0e10cSrcweir default:
81cdf0e10cSrcweir aNewRect.Move(_nXMov,_nYMov);
82cdf0e10cSrcweir break;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir if (dynamic_cast<OUnoObject*>(_pObj) != NULL || dynamic_cast<OOle2Obj*>(_pObj) != NULL)
85cdf0e10cSrcweir {
86cdf0e10cSrcweir pOverlappedObj = isOver(aNewRect,*_pObj->GetPage(),*_pView,true,_pObj);
87cdf0e10cSrcweir if ( pOverlappedObj && _pObj != pOverlappedObj )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir Rectangle aOverlappingRect = (_bBoundRects ? pOverlappedObj->GetCurrentBoundRect() : pOverlappedObj->GetSnapRect());
90cdf0e10cSrcweir sal_Int32 nXTemp = _nXMov;
91cdf0e10cSrcweir sal_Int32 nYTemp = _nYMov;
92cdf0e10cSrcweir switch(_nControlModification)
93cdf0e10cSrcweir {
94cdf0e10cSrcweir case ControlModification::LEFT:
95cdf0e10cSrcweir nXTemp += aOverlappingRect.Right() - aNewRect.Left();
96cdf0e10cSrcweir bMoveAllowed = _nXMov != nXTemp;
97cdf0e10cSrcweir break;
98cdf0e10cSrcweir case ControlModification::RIGHT:
99cdf0e10cSrcweir nXTemp += aOverlappingRect.Left() - aNewRect.Right();
100cdf0e10cSrcweir bMoveAllowed = _nXMov != nXTemp;
101cdf0e10cSrcweir break;
102cdf0e10cSrcweir case ControlModification::TOP:
103cdf0e10cSrcweir nYTemp += aOverlappingRect.Bottom() - aNewRect.Top();
104cdf0e10cSrcweir bMoveAllowed = _nYMov != nYTemp;
105cdf0e10cSrcweir break;
106cdf0e10cSrcweir case ControlModification::BOTTOM:
107cdf0e10cSrcweir nYTemp += aOverlappingRect.Top() - aNewRect.Bottom();
108cdf0e10cSrcweir bMoveAllowed = _nYMov != nYTemp;
109cdf0e10cSrcweir break;
110cdf0e10cSrcweir case ControlModification::CENTER_HORIZONTAL:
111cdf0e10cSrcweir if ( _aObjRect.Left() < aOverlappingRect.Left() )
112cdf0e10cSrcweir nXTemp += aOverlappingRect.Left() - aNewRect.Left() - aNewRect.getWidth();
113cdf0e10cSrcweir else
114cdf0e10cSrcweir nXTemp += aOverlappingRect.Right() - aNewRect.Left();
115cdf0e10cSrcweir bMoveAllowed = _nXMov != nXTemp;
116cdf0e10cSrcweir break;
117cdf0e10cSrcweir case ControlModification::CENTER_VERTICAL:
118cdf0e10cSrcweir if ( _aObjRect.Top() < aOverlappingRect.Top() )
119cdf0e10cSrcweir nYTemp += aOverlappingRect.Top() - aNewRect.Top() - aNewRect.getHeight();
120cdf0e10cSrcweir else
121cdf0e10cSrcweir nYTemp += aOverlappingRect.Bottom() - aNewRect.Top();
122cdf0e10cSrcweir bMoveAllowed = _nYMov != nYTemp;
123cdf0e10cSrcweir break;
124cdf0e10cSrcweir case ControlModification::HEIGHT_GREATEST:
125cdf0e10cSrcweir case ControlModification::WIDTH_GREATEST:
126cdf0e10cSrcweir {
127cdf0e10cSrcweir Rectangle aIntersectionRect = aNewRect.GetIntersection(aOverlappingRect);
128cdf0e10cSrcweir if ( !aIntersectionRect.IsEmpty() )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir if ( _nControlModification == ControlModification::WIDTH_GREATEST )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir if ( aNewRect.Left() < aIntersectionRect.Left() )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir aNewRect.Right() = aIntersectionRect.Left();
135cdf0e10cSrcweir }
136cdf0e10cSrcweir else if ( aNewRect.Left() < aIntersectionRect.Right() )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir aNewRect.Left() = aIntersectionRect.Right();
139cdf0e10cSrcweir }
140cdf0e10cSrcweir }
141cdf0e10cSrcweir else if ( _nControlModification == ControlModification::HEIGHT_GREATEST )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir if ( aNewRect.Top() < aIntersectionRect.Top() )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir aNewRect.Bottom() = aIntersectionRect.Top();
146cdf0e10cSrcweir }
147cdf0e10cSrcweir else if ( aNewRect.Top() < aIntersectionRect.Bottom() )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir aNewRect.Top() = aIntersectionRect.Bottom();
150cdf0e10cSrcweir }
151cdf0e10cSrcweir }
152cdf0e10cSrcweir nYTemp = aNewRect.getHeight();
153cdf0e10cSrcweir bMoveAllowed = _nYMov != nYTemp;
154cdf0e10cSrcweir nXTemp = aNewRect.getWidth();
155cdf0e10cSrcweir bMoveAllowed = bMoveAllowed && _nXMov != nXTemp;
156cdf0e10cSrcweir }
157cdf0e10cSrcweir }
158cdf0e10cSrcweir break;
159cdf0e10cSrcweir default:
160cdf0e10cSrcweir break;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir _nXMov = nXTemp;
164cdf0e10cSrcweir _nYMov = nYTemp;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir else
167cdf0e10cSrcweir pOverlappedObj = NULL;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir }
170cdf0e10cSrcweir while ( pOverlappedObj && bMoveAllowed );
171cdf0e10cSrcweir }
172cdf0e10cSrcweir return bMoveAllowed;
173cdf0e10cSrcweir }
174cdf0e10cSrcweir // -----------------------------------------------------------------------------
175cdf0e10cSrcweir
176cdf0e10cSrcweir DBG_NAME( rpt_OViewsWindow );
OViewsWindow(OReportWindow * _pReportWindow)177cdf0e10cSrcweir OViewsWindow::OViewsWindow( OReportWindow* _pReportWindow)
178cdf0e10cSrcweir : Window( _pReportWindow,WB_DIALOGCONTROL)
179cdf0e10cSrcweir ,m_pParent(_pReportWindow)
180cdf0e10cSrcweir ,m_bInUnmark(sal_False)
181cdf0e10cSrcweir {
182cdf0e10cSrcweir DBG_CTOR( rpt_OViewsWindow,NULL);
183cdf0e10cSrcweir SetPaintTransparent(sal_True);
184cdf0e10cSrcweir SetUniqueId(UID_RPT_VIEWSWINDOW);
185cdf0e10cSrcweir SetMapMode( MapMode( MAP_100TH_MM ) );
186cdf0e10cSrcweir m_aColorConfig.AddListener(this);
187cdf0e10cSrcweir ImplInitSettings();
188cdf0e10cSrcweir }
189cdf0e10cSrcweir // -----------------------------------------------------------------------------
~OViewsWindow()190cdf0e10cSrcweir OViewsWindow::~OViewsWindow()
191cdf0e10cSrcweir {
192cdf0e10cSrcweir m_aColorConfig.RemoveListener(this);
193cdf0e10cSrcweir m_aSections.clear();
194cdf0e10cSrcweir
195cdf0e10cSrcweir DBG_DTOR( rpt_OViewsWindow,NULL);
196cdf0e10cSrcweir }
197cdf0e10cSrcweir // -----------------------------------------------------------------------------
initialize()198cdf0e10cSrcweir void OViewsWindow::initialize()
199cdf0e10cSrcweir {
200cdf0e10cSrcweir
201cdf0e10cSrcweir }
202cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_resizeSectionWindow(OSectionWindow & _rSectionWindow,Point & _rStartPoint,bool _bSet)203cdf0e10cSrcweir void OViewsWindow::impl_resizeSectionWindow(OSectionWindow& _rSectionWindow,Point& _rStartPoint,bool _bSet)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir const uno::Reference< report::XSection> xSection = _rSectionWindow.getReportSection().getSection();
206cdf0e10cSrcweir
207cdf0e10cSrcweir Size aSectionSize = _rSectionWindow.LogicToPixel( Size( 0,xSection->getHeight() ) );
208cdf0e10cSrcweir aSectionSize.Width() = getView()->GetTotalWidth();
209cdf0e10cSrcweir
210cdf0e10cSrcweir const sal_Int32 nMinHeight = _rSectionWindow.getStartMarker().getMinHeight();
211cdf0e10cSrcweir if ( _rSectionWindow.getStartMarker().isCollapsed() || nMinHeight > aSectionSize.Height() )
212cdf0e10cSrcweir {
213cdf0e10cSrcweir aSectionSize.Height() = nMinHeight;
214cdf0e10cSrcweir }
215cdf0e10cSrcweir const StyleSettings& rSettings = GetSettings().GetStyleSettings();
216cdf0e10cSrcweir aSectionSize.Height() += (long)(rSettings.GetSplitSize() * (double)_rSectionWindow.GetMapMode().GetScaleY());
217cdf0e10cSrcweir
218cdf0e10cSrcweir if ( _bSet )
219cdf0e10cSrcweir _rSectionWindow.SetPosSizePixel(_rStartPoint,aSectionSize);
220cdf0e10cSrcweir
221cdf0e10cSrcweir _rStartPoint.Y() += aSectionSize.Height();
222cdf0e10cSrcweir }
223cdf0e10cSrcweir
224cdf0e10cSrcweir // -----------------------------------------------------------------------------
resize(const OSectionWindow & _rSectionWindow)225cdf0e10cSrcweir void OViewsWindow::resize(const OSectionWindow& _rSectionWindow)
226cdf0e10cSrcweir {
227cdf0e10cSrcweir bool bSet = false;
228cdf0e10cSrcweir Point aStartPoint;
229cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
230cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
231cdf0e10cSrcweir for (;aIter != aEnd ; ++aIter)
232cdf0e10cSrcweir {
233cdf0e10cSrcweir const ::boost::shared_ptr<OSectionWindow> pSectionWindow = (*aIter);
234cdf0e10cSrcweir if ( pSectionWindow.get() == &_rSectionWindow )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir aStartPoint = pSectionWindow->GetPosPixel();
237cdf0e10cSrcweir bSet = true;
238cdf0e10cSrcweir } // if ( pSectionWindow.get() == &_rSectionWindow )
239cdf0e10cSrcweir
240cdf0e10cSrcweir if ( bSet )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir impl_resizeSectionWindow(*pSectionWindow.get(),aStartPoint,bSet);
243cdf0e10cSrcweir static sal_Int32 nIn = INVALIDATE_UPDATE | INVALIDATE_TRANSPARENT;
244cdf0e10cSrcweir pSectionWindow->getStartMarker().Invalidate( nIn ); // INVALIDATE_NOERASE |INVALIDATE_NOCHILDREN| INVALIDATE_TRANSPARENT
245cdf0e10cSrcweir pSectionWindow->getEndMarker().Invalidate( nIn );
246cdf0e10cSrcweir }
247cdf0e10cSrcweir } // for (;aIter != aEnd ; ++aIter,++nPos)
248cdf0e10cSrcweir Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH));
249cdf0e10cSrcweir aStartWidth *= GetMapMode().GetScaleX();
250cdf0e10cSrcweir Size aOut = GetOutputSizePixel();
251cdf0e10cSrcweir aOut.Width() = aStartWidth;
252cdf0e10cSrcweir aOut = PixelToLogic(aOut);
253cdf0e10cSrcweir m_pParent->notifySizeChanged();
254cdf0e10cSrcweir
255cdf0e10cSrcweir Rectangle aRect(PixelToLogic(Point(0,0)),aOut);
256cdf0e10cSrcweir }
257cdf0e10cSrcweir //------------------------------------------------------------------------------
Resize()258cdf0e10cSrcweir void OViewsWindow::Resize()
259cdf0e10cSrcweir {
260cdf0e10cSrcweir Window::Resize();
261cdf0e10cSrcweir if ( !m_aSections.empty() )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir const Point aOffset(m_pParent->getThumbPos());
264cdf0e10cSrcweir Point aStartPoint(0,-aOffset.Y());
265cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
266cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
267cdf0e10cSrcweir for (sal_uInt16 nPos=0;aIter != aEnd ; ++aIter,++nPos)
268cdf0e10cSrcweir {
269cdf0e10cSrcweir const ::boost::shared_ptr<OSectionWindow> pSectionWindow = (*aIter);
270cdf0e10cSrcweir impl_resizeSectionWindow(*pSectionWindow.get(),aStartPoint,true);
271cdf0e10cSrcweir } // for (;aIter != aEnd ; ++aIter)
272cdf0e10cSrcweir }
273cdf0e10cSrcweir }
274cdf0e10cSrcweir // -----------------------------------------------------------------------------
Paint(const Rectangle & rRect)275cdf0e10cSrcweir void OViewsWindow::Paint( const Rectangle& rRect )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir Window::Paint( rRect );
278cdf0e10cSrcweir
279cdf0e10cSrcweir Size aOut = GetOutputSizePixel();
280cdf0e10cSrcweir Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH));
281cdf0e10cSrcweir aStartWidth *= GetMapMode().GetScaleX();
282cdf0e10cSrcweir
283cdf0e10cSrcweir aOut.Width() -= (long)aStartWidth;
284cdf0e10cSrcweir aOut = PixelToLogic(aOut);
285cdf0e10cSrcweir
286cdf0e10cSrcweir Rectangle aRect(PixelToLogic(Point(aStartWidth,0)),aOut);
287cdf0e10cSrcweir Wallpaper aWall( m_aColorConfig.GetColorValue(::svtools::APPBACKGROUND).nColor );
288cdf0e10cSrcweir DrawWallpaper(aRect,aWall);
289cdf0e10cSrcweir }
290cdf0e10cSrcweir //------------------------------------------------------------------------------
ImplInitSettings()291cdf0e10cSrcweir void OViewsWindow::ImplInitSettings()
292cdf0e10cSrcweir {
293cdf0e10cSrcweir EnableChildTransparentMode( sal_True );
294cdf0e10cSrcweir SetBackground( );
295cdf0e10cSrcweir SetFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );
296cdf0e10cSrcweir SetTextFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );
297cdf0e10cSrcweir }
298cdf0e10cSrcweir //-----------------------------------------------------------------------------
DataChanged(const DataChangedEvent & rDCEvt)299cdf0e10cSrcweir void OViewsWindow::DataChanged( const DataChangedEvent& rDCEvt )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir Window::DataChanged( rDCEvt );
302cdf0e10cSrcweir
303cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
304cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) )
305cdf0e10cSrcweir {
306cdf0e10cSrcweir ImplInitSettings();
307cdf0e10cSrcweir Invalidate();
308cdf0e10cSrcweir }
309cdf0e10cSrcweir }
310cdf0e10cSrcweir //----------------------------------------------------------------------------
addSection(const uno::Reference<report::XSection> & _xSection,const::rtl::OUString & _sColorEntry,sal_uInt16 _nPosition)311cdf0e10cSrcweir void OViewsWindow::addSection(const uno::Reference< report::XSection >& _xSection,const ::rtl::OUString& _sColorEntry,sal_uInt16 _nPosition)
312cdf0e10cSrcweir {
313cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> pSectionWindow( new OSectionWindow(this,_xSection,_sColorEntry) );
314cdf0e10cSrcweir m_aSections.insert(getIteratorAtPos(_nPosition) , TSectionsMap::value_type(pSectionWindow));
315cdf0e10cSrcweir m_pParent->setMarked(&pSectionWindow->getReportSection().getSectionView(),m_aSections.size() == 1);
316cdf0e10cSrcweir Resize();
317cdf0e10cSrcweir }
318cdf0e10cSrcweir //----------------------------------------------------------------------------
removeSection(sal_uInt16 _nPosition)319cdf0e10cSrcweir void OViewsWindow::removeSection(sal_uInt16 _nPosition)
320cdf0e10cSrcweir {
321cdf0e10cSrcweir if ( _nPosition < m_aSections.size() )
322cdf0e10cSrcweir {
323cdf0e10cSrcweir TSectionsMap::iterator aPos = getIteratorAtPos(_nPosition);
324cdf0e10cSrcweir TSectionsMap::iterator aNew = getIteratorAtPos(_nPosition == 0 ? _nPosition+1: _nPosition - 1);
325cdf0e10cSrcweir
326cdf0e10cSrcweir m_pParent->getReportView()->UpdatePropertyBrowserDelayed((*aNew)->getReportSection().getSectionView());
327cdf0e10cSrcweir
328cdf0e10cSrcweir m_aSections.erase(aPos);
329cdf0e10cSrcweir Resize();
330cdf0e10cSrcweir } // if ( _nPosition < m_aSections.size() )
331cdf0e10cSrcweir }
332cdf0e10cSrcweir //------------------------------------------------------------------------------
toggleGrid(sal_Bool _bVisible)333cdf0e10cSrcweir void OViewsWindow::toggleGrid(sal_Bool _bVisible)
334cdf0e10cSrcweir {
335cdf0e10cSrcweir ::std::for_each(m_aSections.begin(),m_aSections.end(),
336cdf0e10cSrcweir ::std::compose1(::boost::bind(&OReportSection::SetGridVisible,_1,_bVisible),TReportPairHelper()));
337cdf0e10cSrcweir ::std::for_each(m_aSections.begin(),m_aSections.end(),
338cdf0e10cSrcweir ::std::compose1(::boost::bind(&OReportSection::Window::Invalidate,_1,INVALIDATE_NOERASE),TReportPairHelper()));
339cdf0e10cSrcweir }
340cdf0e10cSrcweir //------------------------------------------------------------------------------
getTotalHeight() const341cdf0e10cSrcweir sal_Int32 OViewsWindow::getTotalHeight() const
342cdf0e10cSrcweir {
343cdf0e10cSrcweir sal_Int32 nHeight = 0;
344cdf0e10cSrcweir TSectionsMap::const_iterator aIter = m_aSections.begin();
345cdf0e10cSrcweir TSectionsMap::const_iterator aEnd = m_aSections.end();
346cdf0e10cSrcweir for (;aIter != aEnd ; ++aIter)
347cdf0e10cSrcweir {
348cdf0e10cSrcweir nHeight += (*aIter)->GetSizePixel().Height();
349cdf0e10cSrcweir }
350cdf0e10cSrcweir return nHeight;
351cdf0e10cSrcweir }
352cdf0e10cSrcweir //----------------------------------------------------------------------------
getSectionCount() const353cdf0e10cSrcweir sal_uInt16 OViewsWindow::getSectionCount() const
354cdf0e10cSrcweir {
355cdf0e10cSrcweir return static_cast<sal_uInt16>(m_aSections.size());
356cdf0e10cSrcweir }
357cdf0e10cSrcweir //----------------------------------------------------------------------------
SetInsertObj(sal_uInt16 eObj,const::rtl::OUString & _sShapeType)358cdf0e10cSrcweir void OViewsWindow::SetInsertObj( sal_uInt16 eObj,const ::rtl::OUString& _sShapeType )
359cdf0e10cSrcweir {
360cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
361cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
362cdf0e10cSrcweir for (;aIter != aEnd ; ++aIter)
363cdf0e10cSrcweir (*aIter)->getReportSection().getSectionView().SetCurrentObj( eObj, ReportInventor );
364cdf0e10cSrcweir
365cdf0e10cSrcweir m_sShapeType = _sShapeType;
366cdf0e10cSrcweir }
367cdf0e10cSrcweir //----------------------------------------------------------------------------
GetInsertObjString() const368cdf0e10cSrcweir rtl::OUString OViewsWindow::GetInsertObjString() const
369cdf0e10cSrcweir {
370cdf0e10cSrcweir return m_sShapeType;
371cdf0e10cSrcweir }
372cdf0e10cSrcweir
373cdf0e10cSrcweir //------------------------------------------------------------------------------
SetMode(DlgEdMode eNewMode)374cdf0e10cSrcweir void OViewsWindow::SetMode( DlgEdMode eNewMode )
375cdf0e10cSrcweir {
376cdf0e10cSrcweir ::std::for_each(m_aSections.begin(),m_aSections.end(),
377cdf0e10cSrcweir ::std::compose1(::boost::bind(&OReportSection::SetMode,_1,eNewMode),TReportPairHelper()));
378cdf0e10cSrcweir }
379cdf0e10cSrcweir //----------------------------------------------------------------------------
HasSelection() const380cdf0e10cSrcweir sal_Bool OViewsWindow::HasSelection() const
381cdf0e10cSrcweir {
382cdf0e10cSrcweir TSectionsMap::const_iterator aIter = m_aSections.begin();
383cdf0e10cSrcweir TSectionsMap::const_iterator aEnd = m_aSections.end();
384cdf0e10cSrcweir for (;aIter != aEnd && !(*aIter)->getReportSection().getSectionView().AreObjectsMarked(); ++aIter)
385cdf0e10cSrcweir ;
386cdf0e10cSrcweir return aIter != aEnd;
387cdf0e10cSrcweir }
388cdf0e10cSrcweir //----------------------------------------------------------------------------
Delete()389cdf0e10cSrcweir void OViewsWindow::Delete()
390cdf0e10cSrcweir {
391cdf0e10cSrcweir m_bInUnmark = sal_True;
392cdf0e10cSrcweir ::std::for_each(m_aSections.begin(),m_aSections.end(),
393cdf0e10cSrcweir ::std::compose1(::boost::mem_fn(&OReportSection::Delete),TReportPairHelper()));
394cdf0e10cSrcweir m_bInUnmark = sal_False;
395cdf0e10cSrcweir }
396cdf0e10cSrcweir //----------------------------------------------------------------------------
Copy()397cdf0e10cSrcweir void OViewsWindow::Copy()
398cdf0e10cSrcweir {
399cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aAllreadyCopiedObjects;
400cdf0e10cSrcweir ::std::for_each(m_aSections.begin(),m_aSections.end(),
401cdf0e10cSrcweir ::std::compose1(::boost::bind(&OReportSection::Copy,_1,::boost::ref(aAllreadyCopiedObjects)),TReportPairHelper()));
402cdf0e10cSrcweir
403cdf0e10cSrcweir //TSectionsMap::iterator aIter = m_aSections.begin();
404cdf0e10cSrcweir //TSectionsMap::iterator aEnd = m_aSections.end();
405cdf0e10cSrcweir //for (; aIter != aEnd; ++aIter)
406cdf0e10cSrcweir // (*aIter)->getReportSection().Copy(aAllreadyCopiedObjects);
407cdf0e10cSrcweir OReportExchange* pCopy = new OReportExchange(aAllreadyCopiedObjects);
408cdf0e10cSrcweir uno::Reference< datatransfer::XTransferable> aEnsureDelete = pCopy;
409cdf0e10cSrcweir pCopy->CopyToClipboard(this);
410cdf0e10cSrcweir }
411cdf0e10cSrcweir //----------------------------------------------------------------------------
Paste()412cdf0e10cSrcweir void OViewsWindow::Paste()
413cdf0e10cSrcweir {
414cdf0e10cSrcweir TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(this));
415cdf0e10cSrcweir OReportExchange::TSectionElements aCopies = OReportExchange::extractCopies(aTransferData);
416cdf0e10cSrcweir if ( aCopies.getLength() > 1 )
417cdf0e10cSrcweir ::std::for_each(m_aSections.begin(),m_aSections.end(),
418cdf0e10cSrcweir ::std::compose1(::boost::bind(&OReportSection::Paste,_1,aCopies,false),TReportPairHelper()));
419cdf0e10cSrcweir else
420cdf0e10cSrcweir {
421cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> pMarkedSection = getMarkedSection();
422cdf0e10cSrcweir if ( pMarkedSection )
423cdf0e10cSrcweir pMarkedSection->getReportSection().Paste(aCopies,true);
424cdf0e10cSrcweir }
425cdf0e10cSrcweir }
426cdf0e10cSrcweir // ---------------------------------------------------------------------------
getSectionWindow(const uno::Reference<report::XSection> & _xSection) const427cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> OViewsWindow::getSectionWindow(const uno::Reference< report::XSection>& _xSection) const
428cdf0e10cSrcweir {
429cdf0e10cSrcweir OSL_ENSURE(_xSection.is(),"Section is NULL!");
430cdf0e10cSrcweir
431cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> pSectionWindow;
432cdf0e10cSrcweir TSectionsMap::const_iterator aIter = m_aSections.begin();
433cdf0e10cSrcweir TSectionsMap::const_iterator aEnd = m_aSections.end();
434cdf0e10cSrcweir for (; aIter != aEnd ; ++aIter)
435cdf0e10cSrcweir {
436cdf0e10cSrcweir if ((*aIter)->getReportSection().getSection() == _xSection)
437cdf0e10cSrcweir {
438cdf0e10cSrcweir pSectionWindow = (*aIter);
439cdf0e10cSrcweir break;
440cdf0e10cSrcweir }
441cdf0e10cSrcweir }
442cdf0e10cSrcweir
443cdf0e10cSrcweir return pSectionWindow;
444cdf0e10cSrcweir }
445cdf0e10cSrcweir
446cdf0e10cSrcweir //----------------------------------------------------------------------------
getMarkedSection(NearSectionAccess nsa) const447cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> OViewsWindow::getMarkedSection(NearSectionAccess nsa) const
448cdf0e10cSrcweir {
449cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> pRet;
450cdf0e10cSrcweir TSectionsMap::const_iterator aIter = m_aSections.begin();
451cdf0e10cSrcweir TSectionsMap::const_iterator aEnd = m_aSections.end();
452cdf0e10cSrcweir sal_uInt32 nCurrentPosition = 0;
453cdf0e10cSrcweir for (; aIter != aEnd ; ++aIter)
454cdf0e10cSrcweir {
455cdf0e10cSrcweir if ( (*aIter)->getStartMarker().isMarked() )
456cdf0e10cSrcweir {
457cdf0e10cSrcweir if (nsa == CURRENT)
458cdf0e10cSrcweir {
459cdf0e10cSrcweir pRet = (*aIter);
460cdf0e10cSrcweir break;
461cdf0e10cSrcweir }
462cdf0e10cSrcweir else if ( nsa == PREVIOUS )
463cdf0e10cSrcweir {
464cdf0e10cSrcweir if (nCurrentPosition > 0)
465cdf0e10cSrcweir {
466cdf0e10cSrcweir pRet = (*(--aIter));
467b862c97cSHerbert Dürr if( !bool(pRet) )
468b862c97cSHerbert Dürr pRet = (*m_aSections.begin());
469cdf0e10cSrcweir }
470cdf0e10cSrcweir else
471cdf0e10cSrcweir {
472cdf0e10cSrcweir // if we are out of bounds return the first one
473cdf0e10cSrcweir pRet = (*m_aSections.begin());
474cdf0e10cSrcweir }
475cdf0e10cSrcweir break;
476cdf0e10cSrcweir }
477cdf0e10cSrcweir else if ( nsa == POST )
478cdf0e10cSrcweir {
479cdf0e10cSrcweir sal_uInt32 nSize = m_aSections.size();
480cdf0e10cSrcweir if ((nCurrentPosition + 1) < nSize)
481cdf0e10cSrcweir {
482cdf0e10cSrcweir pRet = *(++aIter);
483b862c97cSHerbert Dürr if( !bool(pRet) )
484b862c97cSHerbert Dürr pRet = (*(--aEnd));
485cdf0e10cSrcweir }
486cdf0e10cSrcweir else
487cdf0e10cSrcweir {
488cdf0e10cSrcweir // if we are out of bounds return the last one
489cdf0e10cSrcweir pRet = (*(--aEnd));
490cdf0e10cSrcweir }
491cdf0e10cSrcweir break;
492cdf0e10cSrcweir }
493cdf0e10cSrcweir } // ( (*aIter).second->isMarked() )
494cdf0e10cSrcweir ++nCurrentPosition;
495cdf0e10cSrcweir } // for (; aIter != aEnd ; ++aIter)
496cdf0e10cSrcweir
497cdf0e10cSrcweir return pRet;
498cdf0e10cSrcweir }
499cdf0e10cSrcweir // -------------------------------------------------------------------------
markSection(const sal_uInt16 _nPos)500cdf0e10cSrcweir void OViewsWindow::markSection(const sal_uInt16 _nPos)
501cdf0e10cSrcweir {
502cdf0e10cSrcweir if ( _nPos < m_aSections.size() )
503cdf0e10cSrcweir m_pParent->setMarked(m_aSections[_nPos]->getReportSection().getSection(),sal_True);
504cdf0e10cSrcweir }
505cdf0e10cSrcweir //----------------------------------------------------------------------------
IsPasteAllowed() const506cdf0e10cSrcweir sal_Bool OViewsWindow::IsPasteAllowed() const
507cdf0e10cSrcweir {
508cdf0e10cSrcweir TransferableDataHelper aTransferData( TransferableDataHelper::CreateFromSystemClipboard( const_cast< OViewsWindow* >( this ) ) );
509cdf0e10cSrcweir return aTransferData.HasFormat(OReportExchange::getDescriptorFormatId());
510cdf0e10cSrcweir }
511cdf0e10cSrcweir //-----------------------------------------------------------------------------
SelectAll(const sal_uInt16 _nObjectType)512cdf0e10cSrcweir void OViewsWindow::SelectAll(const sal_uInt16 _nObjectType)
513cdf0e10cSrcweir {
514cdf0e10cSrcweir m_bInUnmark = sal_True;
515cdf0e10cSrcweir ::std::for_each(m_aSections.begin(),m_aSections.end(),
516cdf0e10cSrcweir ::std::compose1(::boost::bind(::boost::mem_fn(&OReportSection::SelectAll),_1,_nObjectType),TReportPairHelper()));
517cdf0e10cSrcweir m_bInUnmark = sal_False;
518cdf0e10cSrcweir }
519cdf0e10cSrcweir //-----------------------------------------------------------------------------
unmarkAllObjects(OSectionView * _pSectionView)520cdf0e10cSrcweir void OViewsWindow::unmarkAllObjects(OSectionView* _pSectionView)
521cdf0e10cSrcweir {
522cdf0e10cSrcweir if ( !m_bInUnmark )
523cdf0e10cSrcweir {
524cdf0e10cSrcweir m_bInUnmark = sal_True;
525cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
526cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
527cdf0e10cSrcweir for (; aIter != aEnd ; ++aIter)
528cdf0e10cSrcweir {
529cdf0e10cSrcweir if ( &(*aIter)->getReportSection().getSectionView() != _pSectionView )
530cdf0e10cSrcweir {
531cdf0e10cSrcweir (*aIter)->getReportSection().deactivateOle();
532cdf0e10cSrcweir (*aIter)->getReportSection().getSectionView().UnmarkAllObj();
533cdf0e10cSrcweir }
534cdf0e10cSrcweir } // for (; aIter != aEnd ; ++aIter)
535cdf0e10cSrcweir m_bInUnmark = sal_False;
536cdf0e10cSrcweir }
537cdf0e10cSrcweir }
538cdf0e10cSrcweir //-----------------------------------------------------------------------------
539cdf0e10cSrcweir /*
540cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> OViewsWindow::getReportSection(const uno::Reference< report::XSection >& _xSection)
541cdf0e10cSrcweir {
542cdf0e10cSrcweir OSL_ENSURE(_xSection.is(),"Section is NULL!");
543cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> pRet;
544cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
545cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
546cdf0e10cSrcweir for (; aIter != aEnd ; ++aIter)
547cdf0e10cSrcweir {
548cdf0e10cSrcweir if ( (*aIter)->getReportSection().getSection() == _xSection )
549cdf0e10cSrcweir {
550cdf0e10cSrcweir pRet = (*aIter);
551cdf0e10cSrcweir break;
552cdf0e10cSrcweir } // if ( (*aIter)->getSection() == _xSection )
553cdf0e10cSrcweir } // for (; aIter != aEnd ; ++aIter)
554cdf0e10cSrcweir return pRet;
555cdf0e10cSrcweir }
556cdf0e10cSrcweir */
557cdf0e10cSrcweir // -----------------------------------------------------------------------
ConfigurationChanged(utl::ConfigurationBroadcaster *,sal_uInt32)558cdf0e10cSrcweir void OViewsWindow::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32)
559cdf0e10cSrcweir {
560cdf0e10cSrcweir ImplInitSettings();
561cdf0e10cSrcweir Invalidate();
562cdf0e10cSrcweir }
563cdf0e10cSrcweir // -----------------------------------------------------------------------------
MouseButtonDown(const MouseEvent & rMEvt)564cdf0e10cSrcweir void OViewsWindow::MouseButtonDown( const MouseEvent& rMEvt )
565cdf0e10cSrcweir {
566cdf0e10cSrcweir if ( rMEvt.IsLeft() )
567cdf0e10cSrcweir {
568cdf0e10cSrcweir GrabFocus();
569cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue> aArgs;
570cdf0e10cSrcweir getView()->getReportView()->getController().executeChecked(SID_SELECT_REPORT,aArgs);
571cdf0e10cSrcweir }
572cdf0e10cSrcweir Window::MouseButtonDown(rMEvt);
573cdf0e10cSrcweir }
574cdf0e10cSrcweir //----------------------------------------------------------------------------
showRuler(sal_Bool _bShow)575cdf0e10cSrcweir void OViewsWindow::showRuler(sal_Bool _bShow)
576cdf0e10cSrcweir {
577cdf0e10cSrcweir ::std::for_each(m_aSections.begin(),m_aSections.end(),
578cdf0e10cSrcweir ::std::compose1(::boost::bind(&OStartMarker::showRuler,_1,_bShow),TStartMarkerHelper()));
579cdf0e10cSrcweir ::std::for_each(m_aSections.begin(),m_aSections.end(),
580cdf0e10cSrcweir ::std::compose1(::boost::bind(&OStartMarker::Window::Invalidate,_1,sal_uInt16(INVALIDATE_NOERASE)),TStartMarkerHelper()));
581cdf0e10cSrcweir }
582cdf0e10cSrcweir //----------------------------------------------------------------------------
MouseButtonUp(const MouseEvent & rMEvt)583cdf0e10cSrcweir void OViewsWindow::MouseButtonUp( const MouseEvent& rMEvt )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir if ( rMEvt.IsLeft() )
586cdf0e10cSrcweir {
587cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
588cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
589cdf0e10cSrcweir for (;aIter != aEnd ; ++aIter)
590cdf0e10cSrcweir {
591cdf0e10cSrcweir if ( (*aIter)->getReportSection().getSectionView().AreObjectsMarked() )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir (*aIter)->getReportSection().MouseButtonUp(rMEvt);
594cdf0e10cSrcweir break;
595cdf0e10cSrcweir }
596cdf0e10cSrcweir }
597cdf0e10cSrcweir
598cdf0e10cSrcweir // remove special insert mode
599cdf0e10cSrcweir for (aIter = m_aSections.begin();aIter != aEnd ; ++aIter)
600cdf0e10cSrcweir {
601cdf0e10cSrcweir (*aIter)->getReportSection().getPage()->resetSpecialMode();
602cdf0e10cSrcweir }
603cdf0e10cSrcweir }
604cdf0e10cSrcweir }
605cdf0e10cSrcweir //------------------------------------------------------------------------------
handleKeyEvent(const KeyEvent & _rEvent)606cdf0e10cSrcweir sal_Bool OViewsWindow::handleKeyEvent(const KeyEvent& _rEvent)
607cdf0e10cSrcweir {
608cdf0e10cSrcweir sal_Bool bRet = sal_False;
609cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
610cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
611cdf0e10cSrcweir for (;aIter != aEnd ; ++aIter)
612cdf0e10cSrcweir {
613cdf0e10cSrcweir //if ( (*aIter).getReportSection().getSectionView().->AreObjectsMarked() )
614cdf0e10cSrcweir if ( (*aIter)->getStartMarker().isMarked() )
615cdf0e10cSrcweir {
616cdf0e10cSrcweir bRet = (*aIter)->getReportSection().handleKeyEvent(_rEvent);
617cdf0e10cSrcweir }
618cdf0e10cSrcweir }
619cdf0e10cSrcweir return bRet;
620cdf0e10cSrcweir }
621cdf0e10cSrcweir //----------------------------------------------------------------------------
getIteratorAtPos(sal_uInt16 _nPos)622cdf0e10cSrcweir OViewsWindow::TSectionsMap::iterator OViewsWindow::getIteratorAtPos(sal_uInt16 _nPos)
623cdf0e10cSrcweir {
624cdf0e10cSrcweir TSectionsMap::iterator aRet = m_aSections.end();
625cdf0e10cSrcweir if ( _nPos < m_aSections.size() )
626cdf0e10cSrcweir aRet = m_aSections.begin() + _nPos;
627cdf0e10cSrcweir return aRet;
628cdf0e10cSrcweir }
629cdf0e10cSrcweir //------------------------------------------------------------------------
setMarked(OSectionView * _pSectionView,sal_Bool _bMark)630cdf0e10cSrcweir void OViewsWindow::setMarked(OSectionView* _pSectionView,sal_Bool _bMark)
631cdf0e10cSrcweir {
632cdf0e10cSrcweir OSL_ENSURE(_pSectionView != NULL,"SectionView is NULL!");
633cdf0e10cSrcweir if ( _pSectionView )
634cdf0e10cSrcweir setMarked(_pSectionView->getReportSection()->getSection(),_bMark);
635cdf0e10cSrcweir }
636cdf0e10cSrcweir //------------------------------------------------------------------------
setMarked(const uno::Reference<report::XSection> & _xSection,sal_Bool _bMark)637cdf0e10cSrcweir void OViewsWindow::setMarked(const uno::Reference< report::XSection>& _xSection,sal_Bool _bMark)
638cdf0e10cSrcweir {
639cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
640cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
641cdf0e10cSrcweir for (; aIter != aEnd ; ++aIter)
642cdf0e10cSrcweir {
643cdf0e10cSrcweir if ( (*aIter)->getReportSection().getSection() != _xSection )
644cdf0e10cSrcweir {
645cdf0e10cSrcweir (*aIter)->setMarked(sal_False);
646cdf0e10cSrcweir }
647cdf0e10cSrcweir else if ( (*aIter)->getStartMarker().isMarked() != _bMark )
648cdf0e10cSrcweir {
649cdf0e10cSrcweir (*aIter)->setMarked(_bMark);
650cdf0e10cSrcweir }
651cdf0e10cSrcweir }
652cdf0e10cSrcweir }
653cdf0e10cSrcweir //------------------------------------------------------------------------
setMarked(const uno::Sequence<uno::Reference<report::XReportComponent>> & _aShapes,sal_Bool _bMark)654cdf0e10cSrcweir void OViewsWindow::setMarked(const uno::Sequence< uno::Reference< report::XReportComponent> >& _aShapes,sal_Bool _bMark)
655cdf0e10cSrcweir {
656cdf0e10cSrcweir bool bFirst = true;
657cdf0e10cSrcweir const uno::Reference< report::XReportComponent>* pIter = _aShapes.getConstArray();
658cdf0e10cSrcweir const uno::Reference< report::XReportComponent>* pEnd = pIter + _aShapes.getLength();
659cdf0e10cSrcweir for(;pIter != pEnd;++pIter)
660cdf0e10cSrcweir {
661cdf0e10cSrcweir const uno::Reference< report::XSection> xSection = (*pIter)->getSection();
662cdf0e10cSrcweir if ( xSection.is() )
663cdf0e10cSrcweir {
664cdf0e10cSrcweir if ( bFirst )
665cdf0e10cSrcweir {
666cdf0e10cSrcweir bFirst = false;
667cdf0e10cSrcweir m_pParent->setMarked(xSection,_bMark);
668cdf0e10cSrcweir }
669cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> pSectionWindow = getSectionWindow(xSection);
670cdf0e10cSrcweir if ( pSectionWindow )
671cdf0e10cSrcweir {
672cdf0e10cSrcweir SvxShape* pShape = SvxShape::getImplementation( *pIter );
673cdf0e10cSrcweir SdrObject* pObject = pShape ? pShape->GetSdrObject() : NULL;
674cdf0e10cSrcweir OSL_ENSURE( pObject, "OViewsWindow::setMarked: no SdrObject for the shape!" );
675cdf0e10cSrcweir if ( pObject )
676cdf0e10cSrcweir pSectionWindow->getReportSection().getSectionView().MarkObj( pObject, pSectionWindow->getReportSection().getSectionView().GetSdrPageView(), !_bMark );
677cdf0e10cSrcweir }
678cdf0e10cSrcweir }
679cdf0e10cSrcweir }
680cdf0e10cSrcweir }
681cdf0e10cSrcweir // -----------------------------------------------------------------------------
collectRectangles(TRectangleMap & _rSortRectangles,bool _bBoundRects)682cdf0e10cSrcweir void OViewsWindow::collectRectangles(TRectangleMap& _rSortRectangles, bool _bBoundRects)
683cdf0e10cSrcweir {
684cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
685cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
686cdf0e10cSrcweir for (aIter = m_aSections.begin();aIter != aEnd ; ++aIter)
687cdf0e10cSrcweir {
688cdf0e10cSrcweir OSectionView& rView = (*aIter)->getReportSection().getSectionView();
689cdf0e10cSrcweir if ( rView.AreObjectsMarked() )
690cdf0e10cSrcweir {
691cdf0e10cSrcweir rView.SortMarkedObjects();
692cdf0e10cSrcweir const sal_uInt32 nCount = rView.GetMarkedObjectCount();
693cdf0e10cSrcweir for (sal_uInt32 i=0; i < nCount; ++i)
694cdf0e10cSrcweir {
695cdf0e10cSrcweir const SdrMark* pM = rView.GetSdrMarkByIndex(i);
696cdf0e10cSrcweir SdrObject* pObj = pM->GetMarkedSdrObj();
697cdf0e10cSrcweir Rectangle aObjRect(_bBoundRects ? pObj->GetCurrentBoundRect() : pObj->GetSnapRect());
698cdf0e10cSrcweir _rSortRectangles.insert(TRectangleMap::value_type(aObjRect,TRectangleMap::mapped_type(pObj,&rView)));
699cdf0e10cSrcweir }
700cdf0e10cSrcweir }
701cdf0e10cSrcweir }
702cdf0e10cSrcweir }
703cdf0e10cSrcweir // -----------------------------------------------------------------------------
collectBoundResizeRect(const TRectangleMap & _rSortRectangles,sal_Int32 _nControlModification,bool _bAlignAtSection,bool _bBoundRects,Rectangle & _rBound,Rectangle & _rResize)704cdf0e10cSrcweir void OViewsWindow::collectBoundResizeRect(const TRectangleMap& _rSortRectangles,sal_Int32 _nControlModification,bool _bAlignAtSection, bool _bBoundRects,Rectangle& _rBound,Rectangle& _rResize)
705cdf0e10cSrcweir {
706cdf0e10cSrcweir bool bOnlyOnce = false;
707cdf0e10cSrcweir TRectangleMap::const_iterator aRectIter = _rSortRectangles.begin();
708cdf0e10cSrcweir TRectangleMap::const_iterator aRectEnd = _rSortRectangles.end();
709cdf0e10cSrcweir for (;aRectIter != aRectEnd ; ++aRectIter)
710cdf0e10cSrcweir {
711cdf0e10cSrcweir Rectangle aObjRect = aRectIter->first;
712cdf0e10cSrcweir if ( _rResize.IsEmpty() )
713cdf0e10cSrcweir _rResize = aObjRect;
714cdf0e10cSrcweir switch(_nControlModification)
715cdf0e10cSrcweir {
716cdf0e10cSrcweir case ControlModification::WIDTH_SMALLEST:
717cdf0e10cSrcweir if ( _rResize.getWidth() > aObjRect.getWidth() )
718cdf0e10cSrcweir _rResize = aObjRect;
719cdf0e10cSrcweir break;
720cdf0e10cSrcweir case ControlModification::HEIGHT_SMALLEST:
721cdf0e10cSrcweir if ( _rResize.getHeight() > aObjRect.getHeight() )
722cdf0e10cSrcweir _rResize = aObjRect;
723cdf0e10cSrcweir break;
724cdf0e10cSrcweir case ControlModification::WIDTH_GREATEST:
725cdf0e10cSrcweir if ( _rResize.getWidth() < aObjRect.getWidth() )
726cdf0e10cSrcweir _rResize = aObjRect;
727cdf0e10cSrcweir break;
728cdf0e10cSrcweir case ControlModification::HEIGHT_GREATEST:
729cdf0e10cSrcweir if ( _rResize.getHeight() < aObjRect.getHeight() )
730cdf0e10cSrcweir _rResize = aObjRect;
731cdf0e10cSrcweir break;
732cdf0e10cSrcweir }
733cdf0e10cSrcweir
734cdf0e10cSrcweir SdrObjTransformInfoRec aInfo;
735cdf0e10cSrcweir const SdrObject* pObj = aRectIter->second.first;
736cdf0e10cSrcweir pObj->TakeObjInfo(aInfo);
737cdf0e10cSrcweir sal_Bool bHasFixed = !aInfo.bMoveAllowed || pObj->IsMoveProtect();
738cdf0e10cSrcweir if ( bHasFixed )
739cdf0e10cSrcweir _rBound.Union(aObjRect);
740cdf0e10cSrcweir else
741cdf0e10cSrcweir {
742cdf0e10cSrcweir if ( _bAlignAtSection || _rSortRectangles.size() == 1 )
743cdf0e10cSrcweir { // einzelnes Obj an der Seite ausrichten
744cdf0e10cSrcweir if ( ! bOnlyOnce )
745cdf0e10cSrcweir {
746cdf0e10cSrcweir bOnlyOnce = true;
747cdf0e10cSrcweir OReportSection* pReportSection = aRectIter->second.second->getReportSection();
748cdf0e10cSrcweir const uno::Reference< report::XSection> xSection = pReportSection->getSection();
749cdf0e10cSrcweir try
750cdf0e10cSrcweir {
751cdf0e10cSrcweir uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
752cdf0e10cSrcweir _rBound.Union(Rectangle(getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN),0,
753cdf0e10cSrcweir getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width - getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN),
754cdf0e10cSrcweir xSection->getHeight()));
755cdf0e10cSrcweir }
756cdf0e10cSrcweir catch(uno::Exception){}
757cdf0e10cSrcweir }
758cdf0e10cSrcweir }
759cdf0e10cSrcweir else
760cdf0e10cSrcweir {
761cdf0e10cSrcweir if (_bBoundRects)
762cdf0e10cSrcweir _rBound.Union(aRectIter->second.second->GetMarkedObjBoundRect());
763cdf0e10cSrcweir else
764cdf0e10cSrcweir _rBound.Union(aRectIter->second.second->GetMarkedObjRect());
765cdf0e10cSrcweir }
766cdf0e10cSrcweir }
767cdf0e10cSrcweir }
768cdf0e10cSrcweir }
769cdf0e10cSrcweir // -----------------------------------------------------------------------------
alignMarkedObjects(sal_Int32 _nControlModification,bool _bAlignAtSection,bool _bBoundRects)770cdf0e10cSrcweir void OViewsWindow::alignMarkedObjects(sal_Int32 _nControlModification,bool _bAlignAtSection, bool _bBoundRects)
771cdf0e10cSrcweir {
772cdf0e10cSrcweir if ( _nControlModification == ControlModification::NONE )
773cdf0e10cSrcweir return;
774cdf0e10cSrcweir
775cdf0e10cSrcweir Point aRefPoint;
776cdf0e10cSrcweir RectangleLess::CompareMode eCompareMode = RectangleLess::POS_LEFT;
777cdf0e10cSrcweir switch (_nControlModification)
778cdf0e10cSrcweir {
779cdf0e10cSrcweir case ControlModification::TOP : eCompareMode = RectangleLess::POS_UPPER; break;
780cdf0e10cSrcweir case ControlModification::BOTTOM: eCompareMode = RectangleLess::POS_DOWN; break;
781cdf0e10cSrcweir case ControlModification::LEFT : eCompareMode = RectangleLess::POS_LEFT; break;
782cdf0e10cSrcweir case ControlModification::RIGHT : eCompareMode = RectangleLess::POS_RIGHT; break;
783cdf0e10cSrcweir case ControlModification::CENTER_HORIZONTAL :
784cdf0e10cSrcweir case ControlModification::CENTER_VERTICAL :
785cdf0e10cSrcweir {
786cdf0e10cSrcweir eCompareMode = (ControlModification::CENTER_VERTICAL == _nControlModification) ? RectangleLess::POS_CENTER_VERTICAL : RectangleLess::POS_CENTER_HORIZONTAL;
787cdf0e10cSrcweir uno::Reference<report::XSection> xSection = (*m_aSections.begin())->getReportSection().getSection();
788cdf0e10cSrcweir uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
789cdf0e10cSrcweir aRefPoint = Rectangle(getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN),0,
790cdf0e10cSrcweir getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width - getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN),
791cdf0e10cSrcweir xSection->getHeight()).Center();
792cdf0e10cSrcweir }
793cdf0e10cSrcweir break;
794cdf0e10cSrcweir default: break;
795cdf0e10cSrcweir }
796cdf0e10cSrcweir RectangleLess aCompare(eCompareMode,aRefPoint);
797cdf0e10cSrcweir TRectangleMap aSortRectangles(aCompare);
798cdf0e10cSrcweir collectRectangles(aSortRectangles,_bBoundRects);
799cdf0e10cSrcweir
800cdf0e10cSrcweir Rectangle aBound;
801cdf0e10cSrcweir Rectangle aResize;
802cdf0e10cSrcweir collectBoundResizeRect(aSortRectangles,_nControlModification,_bAlignAtSection,_bBoundRects,aBound,aResize);
803cdf0e10cSrcweir
804cdf0e10cSrcweir bool bMove = true;
805cdf0e10cSrcweir
806cdf0e10cSrcweir ::std::mem_fun_t<long&,Rectangle> aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Bottom);
807cdf0e10cSrcweir ::std::mem_fun_t<long&,Rectangle> aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Top);
808cdf0e10cSrcweir TRectangleMap::iterator aRectIter = aSortRectangles.begin();
809cdf0e10cSrcweir TRectangleMap::iterator aRectEnd = aSortRectangles.end();
810cdf0e10cSrcweir for (;aRectIter != aRectEnd ; ++aRectIter)
811cdf0e10cSrcweir {
812cdf0e10cSrcweir Rectangle aObjRect = aRectIter->first;
813cdf0e10cSrcweir SdrObject* pObj = aRectIter->second.first;
814cdf0e10cSrcweir SdrView* pView = aRectIter->second.second;
815cdf0e10cSrcweir Point aCenter(aBound.Center());
816cdf0e10cSrcweir SdrObjTransformInfoRec aInfo;
817cdf0e10cSrcweir pObj->TakeObjInfo(aInfo);
818cdf0e10cSrcweir if (aInfo.bMoveAllowed && !pObj->IsMoveProtect())
819cdf0e10cSrcweir {
820cdf0e10cSrcweir long nXMov = 0;
821cdf0e10cSrcweir long nYMov = 0;
822cdf0e10cSrcweir long* pValue = &nXMov;
823cdf0e10cSrcweir switch(_nControlModification)
824cdf0e10cSrcweir {
825cdf0e10cSrcweir case ControlModification::TOP :
826cdf0e10cSrcweir aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Top);
827cdf0e10cSrcweir aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Bottom);
828cdf0e10cSrcweir pValue = &nYMov;
829cdf0e10cSrcweir break;
830cdf0e10cSrcweir case ControlModification::BOTTOM:
831cdf0e10cSrcweir // defaults are already set
832cdf0e10cSrcweir pValue = &nYMov;
833cdf0e10cSrcweir break;
834cdf0e10cSrcweir case ControlModification::CENTER_VERTICAL:
835cdf0e10cSrcweir nYMov = aCenter.Y() - aObjRect.Center().Y();
836cdf0e10cSrcweir pValue = &nYMov;
837cdf0e10cSrcweir bMove = false;
838cdf0e10cSrcweir break;
839cdf0e10cSrcweir case ControlModification::RIGHT :
840cdf0e10cSrcweir aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Right);
841cdf0e10cSrcweir aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Left);
842cdf0e10cSrcweir break;
843cdf0e10cSrcweir case ControlModification::CENTER_HORIZONTAL:
844cdf0e10cSrcweir nXMov = aCenter.X() - aObjRect.Center().X();
845cdf0e10cSrcweir bMove = false;
846cdf0e10cSrcweir break;
847cdf0e10cSrcweir case ControlModification::LEFT :
848cdf0e10cSrcweir aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Left);
849cdf0e10cSrcweir aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Right);
850cdf0e10cSrcweir break;
851cdf0e10cSrcweir default:
852cdf0e10cSrcweir bMove = false;
853cdf0e10cSrcweir break;
854cdf0e10cSrcweir }
855cdf0e10cSrcweir if ( bMove )
856cdf0e10cSrcweir {
857cdf0e10cSrcweir Rectangle aTest = aObjRect;
858cdf0e10cSrcweir aGetFun(&aTest) = aGetFun(&aBound);
859cdf0e10cSrcweir TRectangleMap::iterator aInterSectRectIter = aSortRectangles.begin();
860cdf0e10cSrcweir for (; aInterSectRectIter != aRectIter; ++aInterSectRectIter)
861cdf0e10cSrcweir {
862cdf0e10cSrcweir if ( pView == aInterSectRectIter->second.second && (dynamic_cast<OUnoObject*>(aInterSectRectIter->second.first) || dynamic_cast<OOle2Obj*>(aInterSectRectIter->second.first)))
863cdf0e10cSrcweir {
864cdf0e10cSrcweir SdrObject* pPreviousObj = aInterSectRectIter->second.first;
865cdf0e10cSrcweir Rectangle aIntersectRect = aTest.GetIntersection(_bBoundRects ? pPreviousObj->GetCurrentBoundRect() : pPreviousObj->GetSnapRect());
866cdf0e10cSrcweir if ( !aIntersectRect.IsEmpty() && (aIntersectRect.Left() != aIntersectRect.Right() && aIntersectRect.Top() != aIntersectRect.Bottom() ) )
867cdf0e10cSrcweir {
868cdf0e10cSrcweir *pValue = aRefFun(&aIntersectRect) - aGetFun(&aObjRect);
869cdf0e10cSrcweir break;
870cdf0e10cSrcweir }
871cdf0e10cSrcweir }
872cdf0e10cSrcweir }
873cdf0e10cSrcweir if ( aInterSectRectIter == aRectIter )
874cdf0e10cSrcweir *pValue = aGetFun(&aBound) - aGetFun(&aObjRect);
875cdf0e10cSrcweir }
876cdf0e10cSrcweir
877cdf0e10cSrcweir if ( lcl_getNewRectSize(aObjRect,nXMov,nYMov,pObj,pView,_nControlModification,_bBoundRects) )
878cdf0e10cSrcweir {
879cdf0e10cSrcweir const Size aSize(nXMov,nYMov);
880cdf0e10cSrcweir pView->AddUndo(pView->GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pObj,aSize));
881cdf0e10cSrcweir pObj->Move(aSize);
882cdf0e10cSrcweir aObjRect = (_bBoundRects ? pObj->GetCurrentBoundRect() : pObj->GetSnapRect());
883cdf0e10cSrcweir }
884cdf0e10cSrcweir
885cdf0e10cSrcweir // resizing control
886cdf0e10cSrcweir if ( !aResize.IsEmpty() && aObjRect != aResize )
887cdf0e10cSrcweir {
888cdf0e10cSrcweir nXMov = aResize.getWidth();
889cdf0e10cSrcweir nYMov = aResize.getHeight();
890cdf0e10cSrcweir switch(_nControlModification)
891cdf0e10cSrcweir {
892cdf0e10cSrcweir case ControlModification::WIDTH_GREATEST:
893cdf0e10cSrcweir case ControlModification::HEIGHT_GREATEST:
894cdf0e10cSrcweir if ( _nControlModification == ControlModification::HEIGHT_GREATEST )
895cdf0e10cSrcweir nXMov = aObjRect.getWidth();
896cdf0e10cSrcweir else if ( _nControlModification == ControlModification::WIDTH_GREATEST )
897cdf0e10cSrcweir nYMov = aObjRect.getHeight();
898cdf0e10cSrcweir lcl_getNewRectSize(aObjRect,nXMov,nYMov,pObj,pView,_nControlModification,_bBoundRects);
899cdf0e10cSrcweir // run through
900cdf0e10cSrcweir case ControlModification::WIDTH_SMALLEST:
901cdf0e10cSrcweir case ControlModification::HEIGHT_SMALLEST:
902cdf0e10cSrcweir pView->AddUndo( pView->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
903cdf0e10cSrcweir {
904cdf0e10cSrcweir OObjectBase* pObjBase = dynamic_cast<OObjectBase*>(pObj);
905cdf0e10cSrcweir OSL_ENSURE(pObjBase,"Where comes this object from?");
906cdf0e10cSrcweir if ( pObjBase )
907cdf0e10cSrcweir {
908cdf0e10cSrcweir if ( _nControlModification == ControlModification::WIDTH_SMALLEST || _nControlModification == ControlModification::WIDTH_GREATEST )
909cdf0e10cSrcweir pObjBase->getReportComponent()->setSize(awt::Size(nXMov,aObjRect.getHeight()));
910cdf0e10cSrcweir //pObj->Resize(aObjRect.TopLeft(),Fraction(nXMov,aObjRect.getWidth()),Fraction(1,1));
911cdf0e10cSrcweir else if ( _nControlModification == ControlModification::HEIGHT_GREATEST || _nControlModification == ControlModification::HEIGHT_SMALLEST )
912cdf0e10cSrcweir pObjBase->getReportComponent()->setSize(awt::Size(aObjRect.getWidth(),nYMov));
913cdf0e10cSrcweir //pObj->Resize(aObjRect.TopLeft(),Fraction(1,1),Fraction(nYMov,aObjRect.getHeight()));
914cdf0e10cSrcweir }
915cdf0e10cSrcweir }
916cdf0e10cSrcweir break;
917cdf0e10cSrcweir default:
918cdf0e10cSrcweir break;
919cdf0e10cSrcweir }
920cdf0e10cSrcweir }
921cdf0e10cSrcweir }
922cdf0e10cSrcweir pView->AdjustMarkHdl();
923cdf0e10cSrcweir }
924cdf0e10cSrcweir }
925cdf0e10cSrcweir // -----------------------------------------------------------------------------
createDefault()926cdf0e10cSrcweir void OViewsWindow::createDefault()
927cdf0e10cSrcweir {
928cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> pMarkedSection = getMarkedSection();
929cdf0e10cSrcweir if ( pMarkedSection )
930cdf0e10cSrcweir pMarkedSection->getReportSection().createDefault(m_sShapeType);
931cdf0e10cSrcweir }
932cdf0e10cSrcweir // -----------------------------------------------------------------------------
setGridSnap(sal_Bool bOn)933cdf0e10cSrcweir void OViewsWindow::setGridSnap(sal_Bool bOn)
934cdf0e10cSrcweir {
935cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
936cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
937cdf0e10cSrcweir for (; aIter != aEnd ; ++aIter)
938cdf0e10cSrcweir {
939cdf0e10cSrcweir (*aIter)->getReportSection().getSectionView().SetGridSnap(bOn);
940cdf0e10cSrcweir static sal_Int32 nIn = 0;
941cdf0e10cSrcweir (*aIter)->getReportSection().Invalidate(nIn);
942cdf0e10cSrcweir }
943cdf0e10cSrcweir }
944cdf0e10cSrcweir // -----------------------------------------------------------------------------
setDragStripes(sal_Bool bOn)945cdf0e10cSrcweir void OViewsWindow::setDragStripes(sal_Bool bOn)
946cdf0e10cSrcweir {
947cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
948cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
949cdf0e10cSrcweir for (; aIter != aEnd ; ++aIter)
950cdf0e10cSrcweir (*aIter)->getReportSection().getSectionView().SetDragStripes(bOn);
951cdf0e10cSrcweir }
952cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPosition(const OSectionWindow * _pSectionWindow) const953cdf0e10cSrcweir sal_uInt16 OViewsWindow::getPosition(const OSectionWindow* _pSectionWindow) const
954cdf0e10cSrcweir {
955cdf0e10cSrcweir TSectionsMap::const_iterator aIter = m_aSections.begin();
956cdf0e10cSrcweir TSectionsMap::const_iterator aEnd = m_aSections.end();
957cdf0e10cSrcweir sal_uInt16 nPosition = 0;
958cdf0e10cSrcweir for (; aIter != aEnd ; ++aIter)
959cdf0e10cSrcweir {
960cdf0e10cSrcweir if ( _pSectionWindow == (*aIter).get() )
961cdf0e10cSrcweir {
962cdf0e10cSrcweir break;
963cdf0e10cSrcweir }
964cdf0e10cSrcweir ++nPosition;
965cdf0e10cSrcweir }
966cdf0e10cSrcweir return nPosition;
967cdf0e10cSrcweir }
968cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSectionWindow(const sal_uInt16 _nPos) const969cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> OViewsWindow::getSectionWindow(const sal_uInt16 _nPos) const
970cdf0e10cSrcweir {
971cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> aReturn;
972cdf0e10cSrcweir
973cdf0e10cSrcweir if ( _nPos < m_aSections.size() )
974cdf0e10cSrcweir aReturn = m_aSections[_nPos];
975cdf0e10cSrcweir
976cdf0e10cSrcweir return aReturn;
977cdf0e10cSrcweir }
978cdf0e10cSrcweir // -----------------------------------------------------------------------------
979cdf0e10cSrcweir namespace
980cdf0e10cSrcweir {
981cdf0e10cSrcweir enum SectionViewAction
982cdf0e10cSrcweir {
983cdf0e10cSrcweir eEndDragObj,
984cdf0e10cSrcweir eEndAction,
985cdf0e10cSrcweir eMoveAction,
986cdf0e10cSrcweir eMarkAction,
987cdf0e10cSrcweir eForceToAnotherPage,
988cdf0e10cSrcweir eBreakAction
989cdf0e10cSrcweir };
990cdf0e10cSrcweir class ApplySectionViewAction : public ::std::unary_function< OViewsWindow::TSectionsMap::value_type, void >
991cdf0e10cSrcweir {
992cdf0e10cSrcweir private:
993cdf0e10cSrcweir SectionViewAction m_eAction;
994cdf0e10cSrcweir sal_Bool m_bCopy;
995cdf0e10cSrcweir Point m_aPoint;
996cdf0e10cSrcweir
997cdf0e10cSrcweir public:
ApplySectionViewAction(sal_Bool _bCopy)998cdf0e10cSrcweir ApplySectionViewAction( sal_Bool _bCopy ) : m_eAction( eEndDragObj ), m_bCopy( _bCopy ) { }
ApplySectionViewAction(SectionViewAction _eAction=eEndAction)999cdf0e10cSrcweir ApplySectionViewAction(SectionViewAction _eAction = eEndAction ) : m_eAction( _eAction ) { }
ApplySectionViewAction(const Point & _rPoint,SectionViewAction _eAction=eMoveAction)1000cdf0e10cSrcweir ApplySectionViewAction( const Point& _rPoint, SectionViewAction _eAction = eMoveAction ) : m_eAction( _eAction ), m_bCopy( sal_False ), m_aPoint( _rPoint ) { }
1001cdf0e10cSrcweir
operator ()(const OViewsWindow::TSectionsMap::value_type & _rhs)1002cdf0e10cSrcweir void operator() ( const OViewsWindow::TSectionsMap::value_type& _rhs )
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir OSectionView& rView( _rhs->getReportSection().getSectionView() );
1005cdf0e10cSrcweir switch ( m_eAction )
1006cdf0e10cSrcweir {
1007cdf0e10cSrcweir case eEndDragObj:
1008cdf0e10cSrcweir rView.EndDragObj( m_bCopy );
1009cdf0e10cSrcweir break;
1010cdf0e10cSrcweir case eEndAction:
1011cdf0e10cSrcweir if ( rView.IsAction() )
1012cdf0e10cSrcweir rView.EndAction ( );
1013cdf0e10cSrcweir break;
1014cdf0e10cSrcweir case eMoveAction:
1015cdf0e10cSrcweir rView.MovAction ( m_aPoint );
1016cdf0e10cSrcweir break;
1017cdf0e10cSrcweir case eMarkAction:
1018cdf0e10cSrcweir rView.BegMarkObj ( m_aPoint );
1019cdf0e10cSrcweir break;
1020cdf0e10cSrcweir case eForceToAnotherPage:
1021cdf0e10cSrcweir rView.ForceMarkedToAnotherPage();
1022cdf0e10cSrcweir break;
1023cdf0e10cSrcweir case eBreakAction:
1024cdf0e10cSrcweir if ( rView.IsAction() )
1025cdf0e10cSrcweir rView.BrkAction ( );
1026cdf0e10cSrcweir break;
1027cdf0e10cSrcweir // default:
1028cdf0e10cSrcweir
1029cdf0e10cSrcweir }
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir };
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir // -----------------------------------------------------------------------------
BrkAction()1034cdf0e10cSrcweir void OViewsWindow::BrkAction()
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir EndDragObj_removeInvisibleObjects();
1037cdf0e10cSrcweir ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction(eBreakAction) );
1038cdf0e10cSrcweir }
1039cdf0e10cSrcweir // -----------------------------------------------------------------------------
BegDragObj_createInvisibleObjectAtPosition(const Rectangle & _aRect,const OSectionView & _rSection)1040cdf0e10cSrcweir void OViewsWindow::BegDragObj_createInvisibleObjectAtPosition(const Rectangle& _aRect, const OSectionView& _rSection)
1041cdf0e10cSrcweir {
1042cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
1043cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
1044cdf0e10cSrcweir Point aNewPos(0,0);
1045cdf0e10cSrcweir
1046cdf0e10cSrcweir for (; aIter != aEnd; ++aIter)
1047cdf0e10cSrcweir {
1048cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1049cdf0e10cSrcweir rReportSection.getPage()->setSpecialMode();
1050cdf0e10cSrcweir OSectionView& rView = rReportSection.getSectionView();
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir if ( &rView != &_rSection )
1053cdf0e10cSrcweir {
1054cdf0e10cSrcweir // SdrRectObj *pNewObj = new SdrRectObj(OBJ_RECT, _aRect);
1055cdf0e10cSrcweir // SdrObject *pNewObj = new SdrUnoObj(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Temp Label")));
1056cdf0e10cSrcweir SdrObject *pNewObj = new SdrUnoObj(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText")));
1057cdf0e10cSrcweir if (pNewObj)
1058cdf0e10cSrcweir {
1059cdf0e10cSrcweir pNewObj->SetLogicRect(_aRect);
1060cdf0e10cSrcweir // pNewObj->SetSize(_aRect.GetSize());
1061cdf0e10cSrcweir // pNewObj->Move(Size(_aRect.Left(), _aRect.Top()));
1062cdf0e10cSrcweir
1063cdf0e10cSrcweir pNewObj->Move(Size(0, aNewPos.Y()));
1064cdf0e10cSrcweir sal_Bool bChanged = rView.GetModel()->IsChanged();
1065cdf0e10cSrcweir rReportSection.getPage()->InsertObject(pNewObj);
1066cdf0e10cSrcweir rView.GetModel()->SetChanged(bChanged);
1067cdf0e10cSrcweir m_aBegDragTempList.push_back(pNewObj);
1068cdf0e10cSrcweir Rectangle aRect = pNewObj->GetLogicRect();
1069cdf0e10cSrcweir
1070cdf0e10cSrcweir // pNewObj->SetText(String::CreateFromAscii("Drag helper"));
1071cdf0e10cSrcweir rView.MarkObj( pNewObj, rView.GetSdrPageView() );
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir }
1074cdf0e10cSrcweir const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1075cdf0e10cSrcweir aNewPos.Y() -= nSectionHeight;
1076cdf0e10cSrcweir // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir }
1079cdf0e10cSrcweir // -----------------------------------------------------------------------------
isObjectInMyTempList(SdrObject * _pObj)1080cdf0e10cSrcweir bool OViewsWindow::isObjectInMyTempList(SdrObject *_pObj)
1081cdf0e10cSrcweir {
1082cdf0e10cSrcweir return ::std::find(m_aBegDragTempList.begin(),m_aBegDragTempList.end(),_pObj) != m_aBegDragTempList.end();
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir
1085cdf0e10cSrcweir // -----------------------------------------------------------------------------
BegDragObj(const Point & _aPnt,SdrHdl * _pHdl,const OSectionView * _pSection)1086cdf0e10cSrcweir void OViewsWindow::BegDragObj(const Point& _aPnt, SdrHdl* _pHdl,const OSectionView* _pSection)
1087cdf0e10cSrcweir {
1088cdf0e10cSrcweir OSL_TRACE("BegDragObj Clickpoint X:%d Y:%d\n", _aPnt.X(), _aPnt.Y() );
1089cdf0e10cSrcweir
1090cdf0e10cSrcweir m_aBegDragTempList.clear();
1091cdf0e10cSrcweir
1092cdf0e10cSrcweir // Calculate the absolute clickpoint in the views
1093cdf0e10cSrcweir Point aAbsolutePnt = _aPnt;
1094cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
1095cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
1096cdf0e10cSrcweir for (; aIter != aEnd; ++aIter)
1097cdf0e10cSrcweir {
1098cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1099cdf0e10cSrcweir OSectionView* pView = &rReportSection.getSectionView();
1100cdf0e10cSrcweir if (pView == _pSection)
1101cdf0e10cSrcweir break;
1102cdf0e10cSrcweir const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1103cdf0e10cSrcweir aAbsolutePnt.Y() += nSectionHeight;
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir m_aDragDelta = Point(SAL_MAX_INT32, SAL_MAX_INT32);
1106cdf0e10cSrcweir OSL_TRACE("BegDragObj Absolute X:%d Y:%d\n", aAbsolutePnt.X(), aAbsolutePnt.Y() );
1107cdf0e10cSrcweir
1108cdf0e10cSrcweir // Create drag lines over all viewable Views
1109cdf0e10cSrcweir // Therefore we need to identify the marked objects
1110cdf0e10cSrcweir // and create temporary objects on all other views at the same position
111130acf5e8Spfg // relative to its occurrence.
1112cdf0e10cSrcweir
1113cdf0e10cSrcweir OSL_TRACE("BegDragObj createInvisible Objects\n" );
1114cdf0e10cSrcweir int nViewCount = 0;
1115cdf0e10cSrcweir Point aNewObjPos(0,0);
1116cdf0e10cSrcweir Point aLeftTop = Point(SAL_MAX_INT32, SAL_MAX_INT32);
1117cdf0e10cSrcweir for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1120cdf0e10cSrcweir
1121cdf0e10cSrcweir OSectionView& rView = rReportSection.getSectionView();
1122cdf0e10cSrcweir
1123cdf0e10cSrcweir if ( rView.AreObjectsMarked() )
1124cdf0e10cSrcweir {
1125cdf0e10cSrcweir const sal_uInt32 nCount = rView.GetMarkedObjectCount();
1126cdf0e10cSrcweir for (sal_uInt32 i=0; i < nCount; ++i)
1127cdf0e10cSrcweir {
1128cdf0e10cSrcweir const SdrMark* pM = rView.GetSdrMarkByIndex(i);
1129cdf0e10cSrcweir SdrObject* pObj = pM->GetMarkedSdrObj();
1130cdf0e10cSrcweir if (!isObjectInMyTempList(pObj))
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir Rectangle aRect( pObj->GetCurrentBoundRect() );
1133cdf0e10cSrcweir aRect.Move(0, aNewObjPos.Y());
1134cdf0e10cSrcweir
1135cdf0e10cSrcweir aLeftTop.X() = ::std::min( aRect.Left(), aLeftTop.X() );
1136cdf0e10cSrcweir aLeftTop.Y() = ::std::min( aRect.Top(), aLeftTop.Y() );
1137cdf0e10cSrcweir
1138cdf0e10cSrcweir OSL_TRACE("BegDragObj createInvisible X:%d Y:%d on View #%d\n", aRect.Left(), aRect.Top(), nViewCount );
1139cdf0e10cSrcweir
1140cdf0e10cSrcweir BegDragObj_createInvisibleObjectAtPosition(aRect, rView);
1141cdf0e10cSrcweir
1142cdf0e10cSrcweir // calculate the clickpoint
1143cdf0e10cSrcweir // const sal_Int32 nDeltaX = abs(aRect.Left() - aAbsolutePnt.X());
1144cdf0e10cSrcweir // const sal_Int32 nDeltaY = abs(aRect.Top() - aAbsolutePnt.Y());
1145cdf0e10cSrcweir // if (m_aDragDelta.X() > nDeltaX)
1146cdf0e10cSrcweir // m_aDragDelta.X() = nDeltaX;
1147cdf0e10cSrcweir // if (m_aDragDelta.Y() > nDeltaY)
1148cdf0e10cSrcweir // m_aDragDelta.Y() = nDeltaY;
1149cdf0e10cSrcweir }
1150cdf0e10cSrcweir }
1151cdf0e10cSrcweir }
1152cdf0e10cSrcweir ++nViewCount;
1153cdf0e10cSrcweir Rectangle aClipRect = rView.GetWorkArea();
1154cdf0e10cSrcweir aClipRect.Top() = -aNewObjPos.Y();
1155cdf0e10cSrcweir rView.SetWorkArea( aClipRect );
1156cdf0e10cSrcweir
1157cdf0e10cSrcweir const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1158cdf0e10cSrcweir aNewObjPos.Y() += nSectionHeight;
1159cdf0e10cSrcweir
1160cdf0e10cSrcweir // don't subtract the height of the lines between the views
1161cdf0e10cSrcweir // aNewObjPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1162cdf0e10cSrcweir }
1163cdf0e10cSrcweir
1164cdf0e10cSrcweir const sal_Int32 nDeltaX = abs(aLeftTop.X() - aAbsolutePnt.X());
1165cdf0e10cSrcweir const sal_Int32 nDeltaY = abs(aLeftTop.Y() - aAbsolutePnt.Y());
1166cdf0e10cSrcweir m_aDragDelta.X() = nDeltaX;
1167cdf0e10cSrcweir m_aDragDelta.Y() = nDeltaY;
1168cdf0e10cSrcweir
1169cdf0e10cSrcweir Point aNewPos = aAbsolutePnt;
1170cdf0e10cSrcweir // for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1171cdf0e10cSrcweir // {
1172cdf0e10cSrcweir // OReportSection& rReportSection = (*aIter)->getReportSection();
1173cdf0e10cSrcweir // if ( &rReportSection.getSectionView() == _pSection )
1174cdf0e10cSrcweir // break;
1175cdf0e10cSrcweir // aNewPos.Y() += rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1176cdf0e10cSrcweir // }
1177cdf0e10cSrcweir
1178cdf0e10cSrcweir const short nDrgLog = static_cast<short>(PixelToLogic(Size(3,0)).Width());
1179cdf0e10cSrcweir // long nLastSectionHeight = 0;
1180cdf0e10cSrcweir // bool bAdd = true;
1181cdf0e10cSrcweir nViewCount = 0;
1182cdf0e10cSrcweir for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1183cdf0e10cSrcweir {
1184cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1185cdf0e10cSrcweir
1186cdf0e10cSrcweir // if ( &rReportSection.getSectionView() == _pSection )
1187cdf0e10cSrcweir // {
1188cdf0e10cSrcweir // bAdd = false;
1189cdf0e10cSrcweir // aNewPos = _aPnt;
1190cdf0e10cSrcweir // }
1191cdf0e10cSrcweir // else if ( bAdd )
1192cdf0e10cSrcweir // {
1193cdf0e10cSrcweir // const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1194cdf0e10cSrcweir // aNewPos.Y() += nSectionHeight;
1195cdf0e10cSrcweir // }
1196cdf0e10cSrcweir // else
1197cdf0e10cSrcweir // {
1198cdf0e10cSrcweir // aNewPos.Y() -= nLastSectionHeight;
1199cdf0e10cSrcweir // }
1200cdf0e10cSrcweir
1201cdf0e10cSrcweir //?
1202cdf0e10cSrcweir SdrHdl* pHdl = _pHdl;
1203cdf0e10cSrcweir if ( pHdl )
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir if ( &rReportSection.getSectionView() != _pSection )
1206cdf0e10cSrcweir {
1207cdf0e10cSrcweir const SdrHdlList& rHdlList = rReportSection.getSectionView().GetHdlList();
1208cdf0e10cSrcweir pHdl = rHdlList.GetHdl(_pHdl->GetKind());
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir }
1211cdf0e10cSrcweir OSL_TRACE("BegDragObj X:%d Y:%d on View#%d\n", aNewPos.X(), aNewPos.Y(), nViewCount++ );
1212cdf0e10cSrcweir rReportSection.getSectionView().BegDragObj(aNewPos, (OutputDevice*)NULL, pHdl, nDrgLog, NULL);
1213cdf0e10cSrcweir
1214cdf0e10cSrcweir const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1215cdf0e10cSrcweir aNewPos.Y() -= nSectionHeight;
1216cdf0e10cSrcweir // subtract the height between the views, because they are visible but not from interest here.
1217cdf0e10cSrcweir // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1218cdf0e10cSrcweir }
1219cdf0e10cSrcweir }
1220cdf0e10cSrcweir
1221cdf0e10cSrcweir // -----------------------------------------------------------------------------
ForceMarkedToAnotherPage()1222cdf0e10cSrcweir void OViewsWindow::ForceMarkedToAnotherPage()
1223cdf0e10cSrcweir {
1224cdf0e10cSrcweir ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction(eForceToAnotherPage ) );
1225cdf0e10cSrcweir }
1226cdf0e10cSrcweir // -----------------------------------------------------------------------------
BegMarkObj(const Point & _aPnt,const OSectionView * _pSection)1227cdf0e10cSrcweir void OViewsWindow::BegMarkObj(const Point& _aPnt,const OSectionView* _pSection)
1228cdf0e10cSrcweir {
1229cdf0e10cSrcweir bool bAdd = true;
1230cdf0e10cSrcweir Point aNewPos = _aPnt;
1231cdf0e10cSrcweir
1232cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
1233cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
1234cdf0e10cSrcweir long nLastSectionHeight = 0;
1235cdf0e10cSrcweir for (; aIter != aEnd; ++aIter)
1236cdf0e10cSrcweir {
1237cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1238cdf0e10cSrcweir if ( &rReportSection.getSectionView() == _pSection )
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir bAdd = false;
1241cdf0e10cSrcweir aNewPos = _aPnt; // 2,2
1242cdf0e10cSrcweir }
1243cdf0e10cSrcweir else if ( bAdd )
1244cdf0e10cSrcweir {
1245cdf0e10cSrcweir const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1246cdf0e10cSrcweir aNewPos.Y() += nSectionHeight;
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir else
1249cdf0e10cSrcweir {
1250cdf0e10cSrcweir aNewPos.Y() -= nLastSectionHeight;
1251cdf0e10cSrcweir }
1252cdf0e10cSrcweir rReportSection.getSectionView().BegMarkObj ( aNewPos );
1253cdf0e10cSrcweir nLastSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1254cdf0e10cSrcweir
1255cdf0e10cSrcweir // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1256cdf0e10cSrcweir }
1257cdf0e10cSrcweir //::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction( _aPnt , eMarkAction) );
1258cdf0e10cSrcweir }
1259cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSectionRelativeToPosition(const OSectionView * _pSection,Point & _rPnt)1260cdf0e10cSrcweir OSectionView* OViewsWindow::getSectionRelativeToPosition(const OSectionView* _pSection,Point& _rPnt)
1261cdf0e10cSrcweir {
1262cdf0e10cSrcweir OSectionView* pSection = NULL;
1263cdf0e10cSrcweir sal_Int32 nCount = 0;
1264cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
1265cdf0e10cSrcweir const TSectionsMap::iterator aEnd = m_aSections.end();
1266cdf0e10cSrcweir for (; aIter != aEnd ; ++aIter,++nCount)
1267cdf0e10cSrcweir {
1268cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1269cdf0e10cSrcweir if ( &rReportSection.getSectionView() == _pSection)
1270cdf0e10cSrcweir break;
1271cdf0e10cSrcweir }
1272cdf0e10cSrcweir OSL_ENSURE(aIter != aEnd,"This can never happen!");
1273cdf0e10cSrcweir if ( _rPnt.Y() < 0 )
1274cdf0e10cSrcweir {
1275cdf0e10cSrcweir if ( nCount )
1276cdf0e10cSrcweir --aIter;
1277cdf0e10cSrcweir for (; nCount && (_rPnt.Y() < 0); --nCount)
1278cdf0e10cSrcweir {
1279cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1280cdf0e10cSrcweir const sal_Int32 nHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1281cdf0e10cSrcweir _rPnt.Y() += nHeight;
1282cdf0e10cSrcweir if ( (nCount -1) > 0 && (_rPnt.Y() < 0) )
1283cdf0e10cSrcweir --aIter;
1284cdf0e10cSrcweir }
1285cdf0e10cSrcweir if ( nCount == 0 )
1286cdf0e10cSrcweir pSection = &(*m_aSections.begin())->getReportSection().getSectionView();
1287cdf0e10cSrcweir else
1288cdf0e10cSrcweir pSection = &(*aIter)->getReportSection().getSectionView();
1289cdf0e10cSrcweir }
1290cdf0e10cSrcweir else
1291cdf0e10cSrcweir {
1292cdf0e10cSrcweir for (; aIter != aEnd; ++aIter)
1293cdf0e10cSrcweir {
1294cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1295cdf0e10cSrcweir const long nHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1296cdf0e10cSrcweir if ( (_rPnt.Y() - nHeight) < 0 )
1297cdf0e10cSrcweir break;
1298cdf0e10cSrcweir _rPnt.Y() -= nHeight;
1299cdf0e10cSrcweir }
1300cdf0e10cSrcweir if ( aIter != aEnd )
1301cdf0e10cSrcweir pSection = &(*aIter)->getReportSection().getSectionView();
1302cdf0e10cSrcweir else
1303cdf0e10cSrcweir pSection = &(*(aEnd-1))->getReportSection().getSectionView();
1304cdf0e10cSrcweir }
1305cdf0e10cSrcweir
1306cdf0e10cSrcweir return pSection;
1307cdf0e10cSrcweir }
1308cdf0e10cSrcweir // -----------------------------------------------------------------------------
EndDragObj_removeInvisibleObjects()1309cdf0e10cSrcweir void OViewsWindow::EndDragObj_removeInvisibleObjects()
1310cdf0e10cSrcweir {
1311cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
1312cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
1313cdf0e10cSrcweir
1314cdf0e10cSrcweir for (; aIter != aEnd; ++aIter)
1315cdf0e10cSrcweir {
1316cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1317cdf0e10cSrcweir rReportSection.getPage()->resetSpecialMode();
1318cdf0e10cSrcweir }
1319cdf0e10cSrcweir }
1320cdf0e10cSrcweir // -----------------------------------------------------------------------------
EndDragObj(sal_Bool _bControlKeyPressed,const OSectionView * _pSection,const Point & _aPnt)1321cdf0e10cSrcweir void OViewsWindow::EndDragObj(sal_Bool _bControlKeyPressed, const OSectionView* _pSection,const Point& _aPnt)
1322cdf0e10cSrcweir {
1323cdf0e10cSrcweir const String sUndoAction = String((ModuleRes(RID_STR_UNDO_CHANGEPOSITION)));
1324cdf0e10cSrcweir const UndoContext aUndoContext( getView()->getReportView()->getController().getUndoManager(), sUndoAction );
1325cdf0e10cSrcweir
1326cdf0e10cSrcweir Point aNewPos = _aPnt;
1327cdf0e10cSrcweir OSectionView* pInSection = getSectionRelativeToPosition(_pSection, aNewPos);
1328cdf0e10cSrcweir if (!_bControlKeyPressed &&
1329cdf0e10cSrcweir (_pSection && ( _pSection->IsDragResize() == false ) ) && /* Not in resize mode */
1330cdf0e10cSrcweir _pSection != pInSection)
1331cdf0e10cSrcweir {
1332cdf0e10cSrcweir EndDragObj_removeInvisibleObjects();
1333cdf0e10cSrcweir
133430acf5e8Spfg // we need to manipulate the current clickpoint, we subtract the old delta from BeginDrag
1335cdf0e10cSrcweir // OSectionView* pInSection = getSectionRelativeToPosition(_pSection, aPnt);
1336cdf0e10cSrcweir // aNewPos.X() -= m_aDragDelta.X();
1337cdf0e10cSrcweir // aNewPos.Y() -= m_aDragDelta.Y();
1338cdf0e10cSrcweir aNewPos -= m_aDragDelta;
1339cdf0e10cSrcweir
1340cdf0e10cSrcweir uno::Sequence< beans::NamedValue > aAllreadyCopiedObjects;
1341cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
1342cdf0e10cSrcweir const TSectionsMap::iterator aEnd = m_aSections.end();
1343cdf0e10cSrcweir for (; aIter != aEnd; ++aIter)
1344cdf0e10cSrcweir {
1345cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1346cdf0e10cSrcweir if ( pInSection != &rReportSection.getSectionView() )
1347cdf0e10cSrcweir {
1348cdf0e10cSrcweir rReportSection.getSectionView().BrkAction();
1349cdf0e10cSrcweir rReportSection.Copy(aAllreadyCopiedObjects,true);
1350cdf0e10cSrcweir }
1351cdf0e10cSrcweir else
1352cdf0e10cSrcweir pInSection->EndDragObj(sal_False);
1353cdf0e10cSrcweir } // for (; aIter != aEnd; ++aIter)
1354cdf0e10cSrcweir
1355cdf0e10cSrcweir if ( aAllreadyCopiedObjects.getLength() )
1356cdf0e10cSrcweir {
1357cdf0e10cSrcweir beans::NamedValue* pIter = aAllreadyCopiedObjects.getArray();
1358cdf0e10cSrcweir const beans::NamedValue* pEnd = pIter + aAllreadyCopiedObjects.getLength();
1359cdf0e10cSrcweir try
1360cdf0e10cSrcweir {
1361cdf0e10cSrcweir uno::Reference<report::XReportDefinition> xReportDefinition = getView()->getReportView()->getController().getReportDefinition();
1362cdf0e10cSrcweir const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN);
1363cdf0e10cSrcweir const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN);
1364cdf0e10cSrcweir const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width;
1365cdf0e10cSrcweir
1366cdf0e10cSrcweir if ( aNewPos.X() < nLeftMargin )
1367cdf0e10cSrcweir aNewPos.X() = nLeftMargin;
1368cdf0e10cSrcweir if ( aNewPos.Y() < 0 )
1369cdf0e10cSrcweir aNewPos.Y() = 0;
1370cdf0e10cSrcweir
1371cdf0e10cSrcweir Point aPrevious;
1372cdf0e10cSrcweir for (; pIter != pEnd; ++pIter)
1373cdf0e10cSrcweir {
1374cdf0e10cSrcweir uno::Sequence< uno::Reference<report::XReportComponent> > aClones;
1375cdf0e10cSrcweir pIter->Value >>= aClones;
1376cdf0e10cSrcweir uno::Reference<report::XReportComponent>* pColIter = aClones.getArray();
1377cdf0e10cSrcweir const uno::Reference<report::XReportComponent>* pColEnd = pColIter + aClones.getLength();
1378cdf0e10cSrcweir
1379cdf0e10cSrcweir // move the cloned Components to new positions
1380cdf0e10cSrcweir for (; pColIter != pColEnd; ++pColIter)
1381cdf0e10cSrcweir {
1382cdf0e10cSrcweir uno::Reference< report::XReportComponent> xRC(*pColIter);
1383cdf0e10cSrcweir aPrevious = VCLPoint(xRC->getPosition());
1384cdf0e10cSrcweir awt::Size aSize = xRC->getSize();
1385cdf0e10cSrcweir
1386cdf0e10cSrcweir if ( aNewPos.X() < nLeftMargin )
1387cdf0e10cSrcweir {
1388cdf0e10cSrcweir aNewPos.X() = nLeftMargin;
1389cdf0e10cSrcweir }
1390cdf0e10cSrcweir else if ( (aNewPos.X() + aSize.Width) > (nPaperWidth - nRightMargin) )
1391cdf0e10cSrcweir {
1392cdf0e10cSrcweir aNewPos.X() = nPaperWidth - nRightMargin - aSize.Width;
1393cdf0e10cSrcweir }
1394cdf0e10cSrcweir if ( aNewPos.Y() < 0 )
1395cdf0e10cSrcweir {
1396cdf0e10cSrcweir aNewPos.Y() = 0;
1397cdf0e10cSrcweir }
1398cdf0e10cSrcweir if ( aNewPos.X() < 0 )
1399cdf0e10cSrcweir {
1400cdf0e10cSrcweir aSize.Width += aNewPos.X();
1401cdf0e10cSrcweir aNewPos.X()= 0;
1402cdf0e10cSrcweir xRC->setSize(aSize);
1403cdf0e10cSrcweir }
1404cdf0e10cSrcweir xRC->setPosition(AWTPoint(aNewPos));
1405cdf0e10cSrcweir if ( (pColIter+1) != pColEnd )
1406cdf0e10cSrcweir {
1407cdf0e10cSrcweir // bring aNewPos to the position of the next object
1408cdf0e10cSrcweir uno::Reference< report::XReportComponent> xRCNext(*(pColIter + 1),uno::UNO_QUERY);
1409cdf0e10cSrcweir Point aNextPosition = VCLPoint(xRCNext->getPosition());
1410cdf0e10cSrcweir aNewPos += (aNextPosition - aPrevious);
1411cdf0e10cSrcweir }
1412cdf0e10cSrcweir }
1413cdf0e10cSrcweir }
1414cdf0e10cSrcweir }
1415cdf0e10cSrcweir catch(uno::Exception&)
1416cdf0e10cSrcweir {
1417cdf0e10cSrcweir }
1418cdf0e10cSrcweir pInSection->getReportSection()->Paste(aAllreadyCopiedObjects,true);
1419cdf0e10cSrcweir }
1420cdf0e10cSrcweir }
1421cdf0e10cSrcweir else
1422cdf0e10cSrcweir {
1423cdf0e10cSrcweir ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction( sal_False ) );
1424cdf0e10cSrcweir EndDragObj_removeInvisibleObjects();
1425cdf0e10cSrcweir }
1426cdf0e10cSrcweir m_aDragDelta = Point(SAL_MAX_INT32, SAL_MAX_INT32);
1427cdf0e10cSrcweir }
1428cdf0e10cSrcweir // -----------------------------------------------------------------------------
EndAction()1429cdf0e10cSrcweir void OViewsWindow::EndAction()
1430cdf0e10cSrcweir {
1431cdf0e10cSrcweir ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction() );
1432cdf0e10cSrcweir }
1433cdf0e10cSrcweir // -----------------------------------------------------------------------------
MovAction(const Point & _aPnt,const OSectionView * _pSection,bool _bMove,bool _bControlKeySet)1434cdf0e10cSrcweir void OViewsWindow::MovAction(const Point& _aPnt,const OSectionView* _pSection,bool _bMove, bool _bControlKeySet)
1435cdf0e10cSrcweir {
1436cdf0e10cSrcweir (void)_bMove;
1437cdf0e10cSrcweir
1438cdf0e10cSrcweir Point aRealMousePos = _aPnt;
1439cdf0e10cSrcweir Point aCurrentSectionPos;
1440cdf0e10cSrcweir OSL_TRACE("MovAction X:%d Y:%d\n", aRealMousePos.X(), aRealMousePos.Y() );
1441cdf0e10cSrcweir
1442cdf0e10cSrcweir Point aHdlPos;
1443cdf0e10cSrcweir SdrHdl* pHdl = _pSection->GetDragHdl();
1444cdf0e10cSrcweir if ( pHdl )
1445cdf0e10cSrcweir {
1446cdf0e10cSrcweir aHdlPos = pHdl->GetPos();
1447cdf0e10cSrcweir }
1448cdf0e10cSrcweir
1449cdf0e10cSrcweir TSectionsMap::iterator aIter/* = m_aSections.begin() */;
1450cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
1451cdf0e10cSrcweir
1452cdf0e10cSrcweir //if ( _bMove )
1453cdf0e10cSrcweir //{
1454cdf0e10cSrcweir for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1455cdf0e10cSrcweir {
1456cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1457cdf0e10cSrcweir if ( &rReportSection.getSectionView() == _pSection )
1458cdf0e10cSrcweir break;
1459cdf0e10cSrcweir const long nSectionHeight = (*aIter)->PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1460cdf0e10cSrcweir aCurrentSectionPos.Y() += nSectionHeight;
1461cdf0e10cSrcweir } // for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1462cdf0e10cSrcweir //}
1463cdf0e10cSrcweir aRealMousePos += aCurrentSectionPos;
1464cdf0e10cSrcweir
1465cdf0e10cSrcweir // If control key is pressed the work area is limited to the section with the current selection.
1466cdf0e10cSrcweir Point aPosForWorkArea(0,0);
1467cdf0e10cSrcweir for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1468cdf0e10cSrcweir {
1469cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1470cdf0e10cSrcweir OSectionView& rView = rReportSection.getSectionView();
1471cdf0e10cSrcweir const long nSectionHeight = (*aIter)->PixelToLogic((*aIter)->GetOutputSizePixel()).Height();
1472cdf0e10cSrcweir
1473cdf0e10cSrcweir if (_bControlKeySet)
1474cdf0e10cSrcweir {
1475cdf0e10cSrcweir Rectangle aClipRect = rView.GetWorkArea();
1476cdf0e10cSrcweir aClipRect.Top() = aCurrentSectionPos.Y() - aPosForWorkArea.Y();
1477cdf0e10cSrcweir // if (aClipRect.Top() < 0) aClipRect.Top() = 0;
1478cdf0e10cSrcweir aClipRect.Bottom() = aClipRect.Top() + nSectionHeight;
1479cdf0e10cSrcweir rView.SetWorkArea( aClipRect );
1480cdf0e10cSrcweir }
1481cdf0e10cSrcweir else
1482cdf0e10cSrcweir {
1483cdf0e10cSrcweir Rectangle aClipRect = rView.GetWorkArea();
1484cdf0e10cSrcweir aClipRect.Top() = -aPosForWorkArea.Y();
1485cdf0e10cSrcweir rView.SetWorkArea( aClipRect );
1486cdf0e10cSrcweir }
1487cdf0e10cSrcweir aPosForWorkArea.Y() += nSectionHeight;
1488cdf0e10cSrcweir // aNewPos.Y() += PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1489cdf0e10cSrcweir }
1490cdf0e10cSrcweir
1491cdf0e10cSrcweir
1492cdf0e10cSrcweir for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1493cdf0e10cSrcweir {
1494cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1495cdf0e10cSrcweir SdrHdl* pCurrentHdl = rReportSection.getSectionView().GetDragHdl();
1496cdf0e10cSrcweir if ( pCurrentHdl )
1497cdf0e10cSrcweir {
1498cdf0e10cSrcweir if ( aRealMousePos.Y() > 0 )
1499cdf0e10cSrcweir aRealMousePos = _aPnt + pCurrentHdl->GetPos() - aHdlPos;
1500cdf0e10cSrcweir }
1501cdf0e10cSrcweir rReportSection.getSectionView().MovAction ( aRealMousePos );
1502cdf0e10cSrcweir const long nSectionHeight = (*aIter)->PixelToLogic((*aIter)->GetOutputSizePixel()).Height();
1503cdf0e10cSrcweir aRealMousePos.Y() -= nSectionHeight;
1504cdf0e10cSrcweir }
1505cdf0e10cSrcweir #if 0
1506cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
1507cdf0e10cSrcweir // TEST TEST TEST TEST
1508cdf0e10cSrcweir // Ich versuche gerade rauszubekommen, ob ich ein Object bewege oder nur resize.
1509cdf0e10cSrcweir // TEST TEST TEST TEST
1510cdf0e10cSrcweir
1511cdf0e10cSrcweir for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1512cdf0e10cSrcweir {
1513cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1514cdf0e10cSrcweir OSectionView& rView = rReportSection.getSectionView();
1515cdf0e10cSrcweir if ( rView.AreObjectsMarked() )
1516cdf0e10cSrcweir {
1517cdf0e10cSrcweir rView.SortMarkedObjects();
1518cdf0e10cSrcweir const sal_uInt32 nCount = rView.GetMarkedObjectCount();
1519cdf0e10cSrcweir for (sal_uInt32 i=0; i < nCount; ++i)
1520cdf0e10cSrcweir {
1521cdf0e10cSrcweir const SdrMark* pM = rView.GetSdrMarkByIndex(i);
1522cdf0e10cSrcweir SdrObject* pObj = pM->GetMarkedSdrObj();
1523cdf0e10cSrcweir (void)pObj;
1524cdf0e10cSrcweir
1525cdf0e10cSrcweir int dummy = 0;
1526cdf0e10cSrcweir (void)dummy;
1527cdf0e10cSrcweir }
1528cdf0e10cSrcweir }
1529cdf0e10cSrcweir
1530cdf0e10cSrcweir /*
1531cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1532cdf0e10cSrcweir OSectionView& rView = rReportSection.getSectionView();
1533cdf0e10cSrcweir const SdrHdlList& rHdlList = rView.GetHdlList();
1534cdf0e10cSrcweir SdrHdl* pHdl2 = rHdlList.GetFocusHdl();
1535cdf0e10cSrcweir
1536cdf0e10cSrcweir if ( pHdl2 != 0 )
1537cdf0e10cSrcweir {
1538cdf0e10cSrcweir SdrHdlKind eKind = pHdl->GetKind();
1539cdf0e10cSrcweir int dummy = 0;
1540cdf0e10cSrcweir switch(eKind)
1541cdf0e10cSrcweir {
1542cdf0e10cSrcweir case HDL_UPLFT: // Oben links
1543cdf0e10cSrcweir case HDL_UPPER: // Oben
1544cdf0e10cSrcweir case HDL_UPRGT: // Oben rechts
1545cdf0e10cSrcweir case HDL_LEFT: // Links
1546cdf0e10cSrcweir case HDL_RIGHT: // Rechts
1547cdf0e10cSrcweir case HDL_LWLFT: // Unten links
1548cdf0e10cSrcweir case HDL_LOWER: // Unten
1549cdf0e10cSrcweir case HDL_LWRGT: // Unten rechts
1550cdf0e10cSrcweir dummy = 1;
1551cdf0e10cSrcweir break;
1552cdf0e10cSrcweir default:
1553cdf0e10cSrcweir dummy = 0;
1554cdf0e10cSrcweir }
1555cdf0e10cSrcweir }
1556cdf0e10cSrcweir */
1557cdf0e10cSrcweir }
1558cdf0e10cSrcweir // TEST TEST TEST TEST
1559cdf0e10cSrcweir #endif
1560cdf0e10cSrcweir #endif
1561cdf0e10cSrcweir }
1562cdf0e10cSrcweir // -----------------------------------------------------------------------------
IsAction() const1563cdf0e10cSrcweir sal_Bool OViewsWindow::IsAction() const
1564cdf0e10cSrcweir {
1565cdf0e10cSrcweir sal_Bool bAction = sal_False;
1566cdf0e10cSrcweir TSectionsMap::const_iterator aIter = m_aSections.begin();
1567cdf0e10cSrcweir TSectionsMap::const_iterator aEnd = m_aSections.end();
1568cdf0e10cSrcweir for (; !bAction && aIter != aEnd; ++aIter)
1569cdf0e10cSrcweir bAction = (*aIter)->getReportSection().getSectionView().IsAction();
1570cdf0e10cSrcweir return bAction;
1571cdf0e10cSrcweir }
1572cdf0e10cSrcweir // -----------------------------------------------------------------------------
IsDragObj() const1573cdf0e10cSrcweir sal_Bool OViewsWindow::IsDragObj() const
1574cdf0e10cSrcweir {
1575cdf0e10cSrcweir sal_Bool bAction = sal_False;
1576cdf0e10cSrcweir TSectionsMap::const_iterator aIter = m_aSections.begin();
1577cdf0e10cSrcweir TSectionsMap::const_iterator aEnd = m_aSections.end();
1578cdf0e10cSrcweir for (; !bAction && aIter != aEnd; ++aIter)
1579cdf0e10cSrcweir bAction = (*aIter)->getReportSection().getSectionView().IsAction();
1580cdf0e10cSrcweir return bAction;
1581cdf0e10cSrcweir }
1582cdf0e10cSrcweir // -----------------------------------------------------------------------------
getMarkedObjectCount() const1583cdf0e10cSrcweir sal_uInt32 OViewsWindow::getMarkedObjectCount() const
1584cdf0e10cSrcweir {
1585cdf0e10cSrcweir sal_uInt32 nCount = 0;
1586cdf0e10cSrcweir TSectionsMap::const_iterator aIter = m_aSections.begin();
1587cdf0e10cSrcweir TSectionsMap::const_iterator aEnd = m_aSections.end();
1588cdf0e10cSrcweir for (; aIter != aEnd; ++aIter)
1589cdf0e10cSrcweir nCount += (*aIter)->getReportSection().getSectionView().GetMarkedObjectCount();
1590cdf0e10cSrcweir return nCount;
1591cdf0e10cSrcweir }
1592cdf0e10cSrcweir // -----------------------------------------------------------------------------
handleKey(const KeyCode & _rCode)1593cdf0e10cSrcweir void OViewsWindow::handleKey(const KeyCode& _rCode)
1594cdf0e10cSrcweir {
1595cdf0e10cSrcweir const sal_uInt16 nCode = _rCode.GetCode();
1596cdf0e10cSrcweir if ( _rCode.IsMod1() )
1597cdf0e10cSrcweir {
1598cdf0e10cSrcweir // scroll page
1599cdf0e10cSrcweir OScrollWindowHelper* pScrollWindow = getView()->getScrollWindow();
1600cdf0e10cSrcweir ScrollBar* pScrollBar = ( nCode == KEY_LEFT || nCode == KEY_RIGHT ) ? pScrollWindow->GetHScroll() : pScrollWindow->GetVScroll();
1601cdf0e10cSrcweir if ( pScrollBar && pScrollBar->IsVisible() )
1602cdf0e10cSrcweir pScrollBar->DoScrollAction(( nCode == KEY_RIGHT || nCode == KEY_UP ) ? SCROLL_LINEUP : SCROLL_LINEDOWN );
1603cdf0e10cSrcweir return;
1604cdf0e10cSrcweir }
1605cdf0e10cSrcweir TSectionsMap::const_iterator aIter = m_aSections.begin();
1606cdf0e10cSrcweir TSectionsMap::const_iterator aEnd = m_aSections.end();
1607cdf0e10cSrcweir for (; aIter != aEnd; ++aIter)
1608cdf0e10cSrcweir {
1609cdf0e10cSrcweir OReportSection& rReportSection = (*aIter)->getReportSection();
1610cdf0e10cSrcweir long nX = 0;
1611cdf0e10cSrcweir long nY = 0;
1612cdf0e10cSrcweir
1613cdf0e10cSrcweir if ( nCode == KEY_UP )
1614cdf0e10cSrcweir nY = -1;
1615cdf0e10cSrcweir else if ( nCode == KEY_DOWN )
1616cdf0e10cSrcweir nY = 1;
1617cdf0e10cSrcweir else if ( nCode == KEY_LEFT )
1618cdf0e10cSrcweir nX = -1;
1619cdf0e10cSrcweir else if ( nCode == KEY_RIGHT )
1620cdf0e10cSrcweir nX = 1;
1621cdf0e10cSrcweir
1622cdf0e10cSrcweir if ( rReportSection.getSectionView().AreObjectsMarked() )
1623cdf0e10cSrcweir {
1624cdf0e10cSrcweir if ( _rCode.IsMod2() )
1625cdf0e10cSrcweir {
1626cdf0e10cSrcweir // move in 1 pixel distance
1627cdf0e10cSrcweir const Size aPixelSize = rReportSection.PixelToLogic( Size( 1, 1 ) );
1628cdf0e10cSrcweir nX *= aPixelSize.Width();
1629cdf0e10cSrcweir nY *= aPixelSize.Height();
1630cdf0e10cSrcweir }
1631cdf0e10cSrcweir else
1632cdf0e10cSrcweir {
1633cdf0e10cSrcweir // move in 1 mm distance
1634cdf0e10cSrcweir nX *= DEFAUL_MOVE_SIZE;
1635cdf0e10cSrcweir nY *= DEFAUL_MOVE_SIZE;
1636cdf0e10cSrcweir }
1637cdf0e10cSrcweir
1638cdf0e10cSrcweir OSectionView& rView = rReportSection.getSectionView();
1639cdf0e10cSrcweir const SdrHdlList& rHdlList = rView.GetHdlList();
1640cdf0e10cSrcweir SdrHdl* pHdl = rHdlList.GetFocusHdl();
1641cdf0e10cSrcweir
1642cdf0e10cSrcweir if ( pHdl == 0 )
1643cdf0e10cSrcweir {
1644cdf0e10cSrcweir // no handle selected
1645cdf0e10cSrcweir if ( rView.IsMoveAllowed() )
1646cdf0e10cSrcweir {
1647cdf0e10cSrcweir // restrict movement to work area
1648cdf0e10cSrcweir Rectangle rWorkArea = rView.GetWorkArea();
1649cdf0e10cSrcweir rWorkArea.Right()++;
1650cdf0e10cSrcweir
1651cdf0e10cSrcweir if ( !rWorkArea.IsEmpty() )
1652cdf0e10cSrcweir {
1653cdf0e10cSrcweir if ( rWorkArea.Top() < 0 )
1654cdf0e10cSrcweir rWorkArea.Top() = 0;
1655cdf0e10cSrcweir Rectangle aMarkRect( rView.GetMarkedObjRect() );
1656cdf0e10cSrcweir aMarkRect.Move( nX, nY );
1657cdf0e10cSrcweir
1658cdf0e10cSrcweir if ( !rWorkArea.IsInside( aMarkRect ) )
1659cdf0e10cSrcweir {
1660cdf0e10cSrcweir if ( aMarkRect.Left() < rWorkArea.Left() )
1661cdf0e10cSrcweir nX += rWorkArea.Left() - aMarkRect.Left();
1662cdf0e10cSrcweir
1663cdf0e10cSrcweir if ( aMarkRect.Right() > rWorkArea.Right() )
1664cdf0e10cSrcweir nX -= aMarkRect.Right() - rWorkArea.Right();
1665cdf0e10cSrcweir
1666cdf0e10cSrcweir if ( aMarkRect.Top() < rWorkArea.Top() )
1667cdf0e10cSrcweir nY += rWorkArea.Top() - aMarkRect.Top();
1668cdf0e10cSrcweir
1669cdf0e10cSrcweir if ( aMarkRect.Bottom() > rWorkArea.Bottom() )
1670cdf0e10cSrcweir nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
1671cdf0e10cSrcweir }
1672cdf0e10cSrcweir bool bCheck = false;
1673cdf0e10cSrcweir const SdrMarkList& rMarkList = rView.GetMarkedObjectList();
1674cdf0e10cSrcweir for (sal_uInt32 i = 0; !bCheck && i < rMarkList.GetMarkCount();++i )
1675cdf0e10cSrcweir {
1676cdf0e10cSrcweir SdrMark* pMark = rMarkList.GetMark(i);
1677cdf0e10cSrcweir bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL|| dynamic_cast<OOle2Obj*>(pMark->GetMarkedSdrObj());
1678cdf0e10cSrcweir }
1679cdf0e10cSrcweir
1680cdf0e10cSrcweir
1681cdf0e10cSrcweir if ( bCheck )
1682cdf0e10cSrcweir {
1683cdf0e10cSrcweir SdrObject* pOverlapped = isOver(aMarkRect,*rReportSection.getPage(),rView);
1684cdf0e10cSrcweir if ( pOverlapped )
1685cdf0e10cSrcweir {
1686cdf0e10cSrcweir do
1687cdf0e10cSrcweir {
1688cdf0e10cSrcweir Rectangle aOver = pOverlapped->GetLastBoundRect();
1689cdf0e10cSrcweir Point aPos;
1690cdf0e10cSrcweir if ( nCode == KEY_UP )
1691cdf0e10cSrcweir {
1692cdf0e10cSrcweir aPos.X() = aMarkRect.Left();
1693cdf0e10cSrcweir aPos.Y() = aOver.Top() - aMarkRect.getHeight();
1694cdf0e10cSrcweir nY += (aPos.Y() - aMarkRect.Top());
1695cdf0e10cSrcweir }
1696cdf0e10cSrcweir else if ( nCode == KEY_DOWN )
1697cdf0e10cSrcweir {
1698cdf0e10cSrcweir aPos.X() = aMarkRect.Left();
1699cdf0e10cSrcweir aPos.Y() = aOver.Bottom();
1700cdf0e10cSrcweir nY += (aPos.Y() - aMarkRect.Top());
1701cdf0e10cSrcweir }
1702cdf0e10cSrcweir else if ( nCode == KEY_LEFT )
1703cdf0e10cSrcweir {
1704cdf0e10cSrcweir aPos.X() = aOver.Left() - aMarkRect.getWidth();
1705cdf0e10cSrcweir aPos.Y() = aMarkRect.Top();
1706cdf0e10cSrcweir nX += (aPos.X() - aMarkRect.Left());
1707cdf0e10cSrcweir }
1708cdf0e10cSrcweir else if ( nCode == KEY_RIGHT )
1709cdf0e10cSrcweir {
1710cdf0e10cSrcweir aPos.X() = aOver.Right();
1711cdf0e10cSrcweir aPos.Y() = aMarkRect.Top();
1712cdf0e10cSrcweir nX += (aPos.X() - aMarkRect.Left());
1713cdf0e10cSrcweir }
1714cdf0e10cSrcweir
1715cdf0e10cSrcweir aMarkRect.SetPos(aPos);
1716cdf0e10cSrcweir if ( !rWorkArea.IsInside( aMarkRect ) )
1717cdf0e10cSrcweir {
1718cdf0e10cSrcweir break;
1719cdf0e10cSrcweir }
1720cdf0e10cSrcweir pOverlapped = isOver(aMarkRect,*rReportSection.getPage(),rView);
1721cdf0e10cSrcweir }
1722cdf0e10cSrcweir while(pOverlapped != NULL);
1723cdf0e10cSrcweir if (pOverlapped != NULL)
1724cdf0e10cSrcweir break;
1725cdf0e10cSrcweir }
1726cdf0e10cSrcweir }
1727cdf0e10cSrcweir }
1728cdf0e10cSrcweir
1729cdf0e10cSrcweir if ( nX != 0 || nY != 0 )
1730cdf0e10cSrcweir {
1731cdf0e10cSrcweir rView.MoveAllMarked( Size( nX, nY ) );
1732cdf0e10cSrcweir rView.MakeVisible( rView.GetAllMarkedRect(), rReportSection);
1733cdf0e10cSrcweir }
1734cdf0e10cSrcweir }
1735cdf0e10cSrcweir }
1736cdf0e10cSrcweir else
1737cdf0e10cSrcweir {
1738cdf0e10cSrcweir // move the handle
1739cdf0e10cSrcweir if ( pHdl && ( nX || nY ) )
1740cdf0e10cSrcweir {
1741cdf0e10cSrcweir const Point aStartPoint( pHdl->GetPos() );
1742cdf0e10cSrcweir const Point aEndPoint( pHdl->GetPos() + Point( nX, nY ) );
1743cdf0e10cSrcweir const SdrDragStat& rDragStat = rView.GetDragStat();
1744cdf0e10cSrcweir
1745cdf0e10cSrcweir // start dragging
1746cdf0e10cSrcweir rView.BegDragObj( aStartPoint, 0, pHdl, 0 );
1747cdf0e10cSrcweir
1748cdf0e10cSrcweir if ( rView.IsDragObj() )
1749cdf0e10cSrcweir {
1750cdf0e10cSrcweir const FASTBOOL bWasNoSnap = rDragStat.IsNoSnap();
1751cdf0e10cSrcweir const sal_Bool bWasSnapEnabled = rView.IsSnapEnabled();
1752cdf0e10cSrcweir
1753cdf0e10cSrcweir // switch snapping off
1754cdf0e10cSrcweir if ( !bWasNoSnap )
1755cdf0e10cSrcweir ((SdrDragStat&)rDragStat).SetNoSnap( sal_True );
1756cdf0e10cSrcweir if ( bWasSnapEnabled )
1757cdf0e10cSrcweir rView.SetSnapEnabled( sal_False );
1758cdf0e10cSrcweir
1759cdf0e10cSrcweir Rectangle aNewRect;
1760cdf0e10cSrcweir bool bCheck = false;
1761cdf0e10cSrcweir const SdrMarkList& rMarkList = rView.GetMarkedObjectList();
1762cdf0e10cSrcweir for (sal_uInt32 i = 0; !bCheck && i < rMarkList.GetMarkCount();++i )
1763cdf0e10cSrcweir {
1764cdf0e10cSrcweir SdrMark* pMark = rMarkList.GetMark(i);
1765cdf0e10cSrcweir bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL || dynamic_cast<OOle2Obj*>(pMark->GetMarkedSdrObj()) != NULL;
1766cdf0e10cSrcweir if ( bCheck )
1767cdf0e10cSrcweir aNewRect.Union(pMark->GetMarkedSdrObj()->GetLastBoundRect());
1768cdf0e10cSrcweir }
1769cdf0e10cSrcweir
1770cdf0e10cSrcweir switch(pHdl->GetKind())
1771cdf0e10cSrcweir {
1772cdf0e10cSrcweir case HDL_LEFT:
1773cdf0e10cSrcweir case HDL_UPLFT:
1774cdf0e10cSrcweir case HDL_LWLFT:
1775cdf0e10cSrcweir case HDL_UPPER:
1776cdf0e10cSrcweir aNewRect.Left() += nX;
1777cdf0e10cSrcweir aNewRect.Top() += nY;
1778cdf0e10cSrcweir break;
1779cdf0e10cSrcweir case HDL_UPRGT:
1780cdf0e10cSrcweir case HDL_RIGHT:
1781cdf0e10cSrcweir case HDL_LWRGT:
1782cdf0e10cSrcweir case HDL_LOWER:
1783cdf0e10cSrcweir aNewRect.setWidth(aNewRect.getWidth() + nX);
1784cdf0e10cSrcweir aNewRect.setHeight(aNewRect.getHeight() + nY);
1785cdf0e10cSrcweir break;
1786cdf0e10cSrcweir default:
1787cdf0e10cSrcweir break;
1788cdf0e10cSrcweir }
1789cdf0e10cSrcweir if ( !(bCheck && isOver(aNewRect,*rReportSection.getPage(),rView)) )
1790cdf0e10cSrcweir rView.MovAction(aEndPoint);
1791cdf0e10cSrcweir rView.EndDragObj();
1792cdf0e10cSrcweir
1793cdf0e10cSrcweir // restore snap
1794cdf0e10cSrcweir if ( !bWasNoSnap )
1795cdf0e10cSrcweir ((SdrDragStat&)rDragStat).SetNoSnap( bWasNoSnap );
1796cdf0e10cSrcweir if ( bWasSnapEnabled )
1797cdf0e10cSrcweir rView.SetSnapEnabled( bWasSnapEnabled );
1798cdf0e10cSrcweir }
1799cdf0e10cSrcweir
1800cdf0e10cSrcweir // make moved handle visible
1801cdf0e10cSrcweir const Rectangle aVisRect( aEndPoint - Point( DEFAUL_MOVE_SIZE, DEFAUL_MOVE_SIZE ), Size( 200, 200 ) );
1802cdf0e10cSrcweir rView.MakeVisible( aVisRect, rReportSection);
1803cdf0e10cSrcweir }
1804cdf0e10cSrcweir }
1805cdf0e10cSrcweir rView.AdjustMarkHdl();
1806cdf0e10cSrcweir }
1807cdf0e10cSrcweir }
1808cdf0e10cSrcweir }
1809cdf0e10cSrcweir // -----------------------------------------------------------------------------
stopScrollTimer()1810cdf0e10cSrcweir void OViewsWindow::stopScrollTimer()
1811cdf0e10cSrcweir {
1812cdf0e10cSrcweir ::std::for_each(m_aSections.begin(),m_aSections.end(),
1813cdf0e10cSrcweir ::std::compose1(::boost::mem_fn(&OReportSection::stopScrollTimer),TReportPairHelper()));
1814cdf0e10cSrcweir }
1815cdf0e10cSrcweir // -----------------------------------------------------------------------------
fillCollapsedSections(::std::vector<sal_uInt16> & _rCollapsedPositions) const1816cdf0e10cSrcweir void OViewsWindow::fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const
1817cdf0e10cSrcweir {
1818cdf0e10cSrcweir TSectionsMap::const_iterator aIter = m_aSections.begin();
1819cdf0e10cSrcweir TSectionsMap::const_iterator aEnd = m_aSections.end();
1820cdf0e10cSrcweir for (sal_uInt16 i = 0;aIter != aEnd ; ++aIter,++i)
1821cdf0e10cSrcweir {
1822cdf0e10cSrcweir if ( (*aIter)->getStartMarker().isCollapsed() )
1823cdf0e10cSrcweir _rCollapsedPositions.push_back(i);
1824cdf0e10cSrcweir }
1825cdf0e10cSrcweir }
1826cdf0e10cSrcweir // -----------------------------------------------------------------------------
collapseSections(const uno::Sequence<beans::PropertyValue> & _aCollpasedSections)1827cdf0e10cSrcweir void OViewsWindow::collapseSections(const uno::Sequence< beans::PropertyValue>& _aCollpasedSections)
1828cdf0e10cSrcweir {
1829cdf0e10cSrcweir const beans::PropertyValue* pIter = _aCollpasedSections.getConstArray();
1830cdf0e10cSrcweir const beans::PropertyValue* pEnd = pIter + _aCollpasedSections.getLength();
1831cdf0e10cSrcweir for (; pIter != pEnd; ++pIter)
1832cdf0e10cSrcweir {
1833cdf0e10cSrcweir sal_uInt16 nPos = sal_uInt16(-1);
1834cdf0e10cSrcweir if ( (pIter->Value >>= nPos) && nPos < m_aSections.size() )
1835cdf0e10cSrcweir {
1836cdf0e10cSrcweir m_aSections[nPos]->setCollapsed(sal_True);
1837cdf0e10cSrcweir }
1838cdf0e10cSrcweir }
1839cdf0e10cSrcweir }
1840cdf0e10cSrcweir // -----------------------------------------------------------------------------
zoom(const Fraction & _aZoom)1841cdf0e10cSrcweir void OViewsWindow::zoom(const Fraction& _aZoom)
1842cdf0e10cSrcweir {
1843cdf0e10cSrcweir const MapMode& aMapMode = GetMapMode();
1844cdf0e10cSrcweir
1845cdf0e10cSrcweir Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH));
1846cdf0e10cSrcweir if ( _aZoom < aMapMode.GetScaleX() )
1847cdf0e10cSrcweir aStartWidth *= aMapMode.GetScaleX();
1848cdf0e10cSrcweir else
1849cdf0e10cSrcweir aStartWidth *= _aZoom;
1850cdf0e10cSrcweir
1851cdf0e10cSrcweir setZoomFactor(_aZoom,*this);
1852cdf0e10cSrcweir
1853cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
1854cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
1855cdf0e10cSrcweir for (;aIter != aEnd ; ++aIter)
1856cdf0e10cSrcweir {
1857cdf0e10cSrcweir (*aIter)->zoom(_aZoom);
1858cdf0e10cSrcweir } // for (;aIter != aEnd ; ++aIter)
1859cdf0e10cSrcweir
1860cdf0e10cSrcweir Resize();
1861cdf0e10cSrcweir
1862cdf0e10cSrcweir Size aOut = GetOutputSizePixel();
1863cdf0e10cSrcweir aOut.Width() = aStartWidth;
1864cdf0e10cSrcweir aOut = PixelToLogic(aOut);
1865cdf0e10cSrcweir
1866cdf0e10cSrcweir Rectangle aRect(PixelToLogic(Point(0,0)),aOut);
1867cdf0e10cSrcweir static sal_Int32 nIn = INVALIDATE_NOCHILDREN;
1868cdf0e10cSrcweir Invalidate(aRect,nIn);
1869cdf0e10cSrcweir }
1870cdf0e10cSrcweir //----------------------------------------------------------------------------
scrollChildren(const Point & _aThumbPos)1871cdf0e10cSrcweir void OViewsWindow::scrollChildren(const Point& _aThumbPos)
1872cdf0e10cSrcweir {
1873cdf0e10cSrcweir const Point aPos(PixelToLogic(_aThumbPos));
1874cdf0e10cSrcweir {
1875cdf0e10cSrcweir MapMode aMapMode = GetMapMode();
1876cdf0e10cSrcweir const Point aOld = aMapMode.GetOrigin();
1877cdf0e10cSrcweir aMapMode.SetOrigin(m_pParent->GetMapMode().GetOrigin());
1878cdf0e10cSrcweir
1879cdf0e10cSrcweir const Point aPosY(m_pParent->PixelToLogic(_aThumbPos,aMapMode));
1880cdf0e10cSrcweir
1881cdf0e10cSrcweir aMapMode.SetOrigin( Point(aOld.X() , - aPosY.Y()));
1882cdf0e10cSrcweir SetMapMode( aMapMode );
1883cdf0e10cSrcweir //OWindowPositionCorrector aCorrector(this,0,-( aOld.Y() + aPosY.Y()));
1884cdf0e10cSrcweir Scroll(0, -( aOld.Y() + aPosY.Y()),SCROLL_CHILDREN);
1885cdf0e10cSrcweir }
1886cdf0e10cSrcweir
1887cdf0e10cSrcweir TSectionsMap::iterator aIter = m_aSections.begin();
1888cdf0e10cSrcweir TSectionsMap::iterator aEnd = m_aSections.end();
1889cdf0e10cSrcweir for (;aIter != aEnd ; ++aIter)
1890cdf0e10cSrcweir {
1891cdf0e10cSrcweir (*aIter)->scrollChildren(aPos.X());
1892cdf0e10cSrcweir } // for (;aIter != aEnd ; ++aIter)
1893cdf0e10cSrcweir }
1894cdf0e10cSrcweir // -----------------------------------------------------------------------------
fillControlModelSelection(::std::vector<uno::Reference<uno::XInterface>> & _rSelection) const1895cdf0e10cSrcweir void OViewsWindow::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const
1896cdf0e10cSrcweir {
1897cdf0e10cSrcweir TSectionsMap::const_iterator aIter = m_aSections.begin();
1898cdf0e10cSrcweir TSectionsMap::const_iterator aEnd = m_aSections.end();
1899cdf0e10cSrcweir for(;aIter != aEnd; ++aIter)
1900cdf0e10cSrcweir {
1901cdf0e10cSrcweir (*aIter)->getReportSection().fillControlModelSelection(_rSelection);
1902cdf0e10cSrcweir }
1903cdf0e10cSrcweir }
1904cdf0e10cSrcweir //==============================================================================
1905cdf0e10cSrcweir } // rptui
1906cdf0e10cSrcweir //==============================================================================
1907