sync master with lastest vba changes
[ooovba.git] / reportdesign / source / ui / report / ViewsWindow.cxx
blob0936652c17971325e7d7dc1791880daa5caa9bcf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ViewsWindow.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "precompiled_reportdesign.hxx"
31 #include "ViewsWindow.hxx"
32 #include "ScrollHelper.hxx"
33 #include "UndoActions.hxx"
34 #include "ReportWindow.hxx"
35 #include "DesignView.hxx"
36 #include <svtools/colorcfg.hxx>
37 #include "ReportController.hxx"
38 #include "UITools.hxx"
39 #include "RptDef.hxx"
40 #include "RptResId.hrc"
41 #include "SectionView.hxx"
42 #include "ReportSection.hxx"
43 #include "uistrings.hrc"
44 #include "rptui_slotid.hrc"
45 #include "dlgedclip.hxx"
46 #include "ColorChanger.hxx"
47 #include "RptObject.hxx"
48 #include "RptObject.hxx"
49 #include "ModuleHelper.hxx"
50 #include "EndMarker.hxx"
51 #include <svx/svdpagv.hxx>
52 #include <svx/unoshape.hxx>
53 #include <vcl/svapp.hxx>
54 #include <boost/bind.hpp>
56 #include "helpids.hrc"
57 #include <svx/svdundo.hxx>
58 #include <toolkit/helper/convert.hxx>
59 #include <algorithm>
60 #include <numeric>
62 namespace rptui
64 #define DEFAUL_MOVE_SIZE 100
66 using namespace ::com::sun::star;
67 using namespace ::comphelper;
68 // -----------------------------------------------------------------------------
69 bool lcl_getNewRectSize(const Rectangle& _aObjRect,long& _nXMov, long& _nYMov,SdrObject* _pObj,SdrView* _pView,sal_Int32 _nControlModification, bool _bBoundRects)
71 bool bMoveAllowed = _nXMov != 0 || _nYMov != 0;
72 if ( bMoveAllowed )
74 Rectangle aNewRect = _aObjRect;
75 SdrObject* pOverlappedObj = NULL;
78 aNewRect = _aObjRect;
79 switch(_nControlModification)
81 case ControlModification::HEIGHT_GREATEST:
82 case ControlModification::WIDTH_GREATEST:
83 aNewRect.setWidth(_nXMov);
84 aNewRect.setHeight(_nYMov);
85 break;
86 default:
87 aNewRect.Move(_nXMov,_nYMov);
88 break;
90 if ( dynamic_cast<OUnoObject*>(_pObj) )
92 pOverlappedObj = isOver(aNewRect,*_pObj->GetPage(),*_pView,true,_pObj);
93 if ( pOverlappedObj && _pObj != pOverlappedObj )
95 Rectangle aOverlappingRect = (_bBoundRects ? pOverlappedObj->GetCurrentBoundRect() : pOverlappedObj->GetSnapRect());
96 sal_Int32 nXTemp = _nXMov;
97 sal_Int32 nYTemp = _nYMov;
98 switch(_nControlModification)
100 case ControlModification::LEFT:
101 nXTemp += aOverlappingRect.Right() - aNewRect.Left();
102 bMoveAllowed = _nXMov != nXTemp;
103 break;
104 case ControlModification::RIGHT:
105 nXTemp += aOverlappingRect.Left() - aNewRect.Right();
106 bMoveAllowed = _nXMov != nXTemp;
107 break;
108 case ControlModification::TOP:
109 nYTemp += aOverlappingRect.Bottom() - aNewRect.Top();
110 bMoveAllowed = _nYMov != nYTemp;
111 break;
112 case ControlModification::BOTTOM:
113 nYTemp += aOverlappingRect.Top() - aNewRect.Bottom();
114 bMoveAllowed = _nYMov != nYTemp;
115 break;
116 case ControlModification::CENTER_HORIZONTAL:
117 if ( _aObjRect.Left() < aOverlappingRect.Left() )
118 nXTemp += aOverlappingRect.Left() - aNewRect.Left() - aNewRect.getWidth();
119 else
120 nXTemp += aOverlappingRect.Right() - aNewRect.Left();
121 bMoveAllowed = _nXMov != nXTemp;
122 break;
123 case ControlModification::CENTER_VERTICAL:
124 if ( _aObjRect.Top() < aOverlappingRect.Top() )
125 nYTemp += aOverlappingRect.Top() - aNewRect.Top() - aNewRect.getHeight();
126 else
127 nYTemp += aOverlappingRect.Bottom() - aNewRect.Top();
128 bMoveAllowed = _nYMov != nYTemp;
129 break;
130 case ControlModification::HEIGHT_GREATEST:
131 case ControlModification::WIDTH_GREATEST:
133 Rectangle aIntersectionRect = aNewRect.GetIntersection(aOverlappingRect);
134 if ( !aIntersectionRect.IsEmpty() )
136 if ( _nControlModification == ControlModification::WIDTH_GREATEST )
138 if ( aNewRect.Left() < aIntersectionRect.Left() )
140 aNewRect.Right() = aIntersectionRect.Left();
142 else if ( aNewRect.Left() < aIntersectionRect.Right() )
144 aNewRect.Left() = aIntersectionRect.Right();
147 else if ( _nControlModification == ControlModification::HEIGHT_GREATEST )
149 if ( aNewRect.Top() < aIntersectionRect.Top() )
151 aNewRect.Bottom() = aIntersectionRect.Top();
153 else if ( aNewRect.Top() < aIntersectionRect.Bottom() )
155 aNewRect.Top() = aIntersectionRect.Bottom();
158 nYTemp = aNewRect.getHeight();
159 bMoveAllowed = _nYMov != nYTemp;
160 nXTemp = aNewRect.getWidth();
161 bMoveAllowed = bMoveAllowed && _nXMov != nXTemp;
164 break;
165 default:
166 break;
169 _nXMov = nXTemp;
170 _nYMov = nYTemp;
172 else
173 pOverlappedObj = NULL;
176 while ( pOverlappedObj && bMoveAllowed );
178 return bMoveAllowed;
180 // -----------------------------------------------------------------------------
182 DBG_NAME( rpt_OViewsWindow );
183 OViewsWindow::OViewsWindow( OReportWindow* _pReportWindow)
184 : Window( _pReportWindow,WB_DIALOGCONTROL)
185 ,m_pParent(_pReportWindow)
186 ,m_bInUnmark(sal_False)
188 DBG_CTOR( rpt_OViewsWindow,NULL);
189 SetPaintTransparent(TRUE);
190 SetUniqueId(UID_RPT_VIEWSWINDOW);
191 SetMapMode( MapMode( MAP_100TH_MM ) );
192 StartListening(m_aColorConfig);
193 ImplInitSettings();
195 // -----------------------------------------------------------------------------
196 OViewsWindow::~OViewsWindow()
198 EndListening(m_aColorConfig);
199 m_aSections.clear();
201 DBG_DTOR( rpt_OViewsWindow,NULL);
203 // -----------------------------------------------------------------------------
204 void OViewsWindow::initialize()
208 // -----------------------------------------------------------------------------
209 void OViewsWindow::impl_resizeSectionWindow(OSectionWindow& _rSectionWindow,Point& _rStartPoint,bool _bSet)
211 const uno::Reference< report::XSection> xSection = _rSectionWindow.getReportSection().getSection();
213 Size aSectionSize = _rSectionWindow.LogicToPixel( Size( 0,xSection->getHeight() ) );
214 aSectionSize.Width() = getView()->GetTotalWidth();
216 const sal_Int32 nMinHeight = _rSectionWindow.getStartMarker().getMinHeight();
217 if ( _rSectionWindow.getStartMarker().isCollapsed() || nMinHeight > aSectionSize.Height() )
219 aSectionSize.Height() = nMinHeight;
221 const StyleSettings& rSettings = GetSettings().GetStyleSettings();
222 aSectionSize.Height() += (long)(rSettings.GetSplitSize() * (double)_rSectionWindow.GetMapMode().GetScaleY());
224 if ( _bSet )
225 _rSectionWindow.SetPosSizePixel(_rStartPoint,aSectionSize);
227 _rStartPoint.Y() += aSectionSize.Height();
230 // -----------------------------------------------------------------------------
231 void OViewsWindow::resize(const OSectionWindow& _rSectionWindow)
233 bool bSet = false;
234 Point aStartPoint;
235 TSectionsMap::iterator aIter = m_aSections.begin();
236 TSectionsMap::iterator aEnd = m_aSections.end();
237 for (;aIter != aEnd ; ++aIter)
239 const ::boost::shared_ptr<OSectionWindow> pSectionWindow = (*aIter);
240 if ( pSectionWindow.get() == &_rSectionWindow )
242 aStartPoint = pSectionWindow->GetPosPixel();
243 bSet = true;
244 } // if ( pSectionWindow.get() == &_rSectionWindow )
246 if ( bSet )
248 impl_resizeSectionWindow(*pSectionWindow.get(),aStartPoint,bSet);
249 pSectionWindow->Invalidate(INVALIDATE_NOERASE | INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT);
250 pSectionWindow->getStartMarker().Invalidate(INVALIDATE_NOERASE | INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT );
252 } // for (;aIter != aEnd ; ++aIter,++nPos)
253 Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH));
254 aStartWidth *= GetMapMode().GetScaleX();
255 Size aOut = GetOutputSizePixel();
256 aOut.Width() = aStartWidth;
257 aOut = PixelToLogic(aOut);
258 m_pParent->notifySizeChanged();
260 Rectangle aRect(PixelToLogic(Point(0,0)),aOut);
261 Invalidate(aRect,INVALIDATE_NOERASE | INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT);
263 //------------------------------------------------------------------------------
264 void OViewsWindow::Resize()
266 Window::Resize();
267 if ( !m_aSections.empty() )
269 const Point aOffset(m_pParent->getThumbPos());
270 Point aStartPoint(0,-aOffset.Y());
271 TSectionsMap::iterator aIter = m_aSections.begin();
272 TSectionsMap::iterator aEnd = m_aSections.end();
273 for (USHORT nPos=0;aIter != aEnd ; ++aIter,++nPos)
275 const ::boost::shared_ptr<OSectionWindow> pSectionWindow = (*aIter);
276 impl_resizeSectionWindow(*pSectionWindow.get(),aStartPoint,true);
277 } // for (;aIter != aEnd ; ++aIter)
280 // -----------------------------------------------------------------------------
281 void OViewsWindow::Paint( const Rectangle& rRect )
283 Window::Paint( rRect );
285 Size aOut = GetOutputSizePixel();
286 Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH));
287 aStartWidth *= GetMapMode().GetScaleX();
289 aOut.Width() -= (long)aStartWidth;
290 aOut = PixelToLogic(aOut);
292 Rectangle aRect(PixelToLogic(Point(aStartWidth,0)),aOut);
293 Wallpaper aWall( m_aColorConfig.GetColorValue(::svtools::APPBACKGROUND).nColor );
294 DrawWallpaper(aRect,aWall);
296 //------------------------------------------------------------------------------
297 void OViewsWindow::ImplInitSettings()
299 // SetBackground( Wallpaper( COL_LIGHTBLUE ));
300 SetBackground( );
301 SetFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );
302 SetTextFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );
304 //-----------------------------------------------------------------------------
305 void OViewsWindow::DataChanged( const DataChangedEvent& rDCEvt )
307 Window::DataChanged( rDCEvt );
309 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
310 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
312 ImplInitSettings();
313 Invalidate();
316 //----------------------------------------------------------------------------
317 void OViewsWindow::addSection(const uno::Reference< report::XSection >& _xSection,const ::rtl::OUString& _sColorEntry,USHORT _nPosition)
319 ::boost::shared_ptr<OSectionWindow> pSectionWindow( new OSectionWindow(this,_xSection,_sColorEntry) );
320 m_aSections.insert(getIteratorAtPos(_nPosition) , TSectionsMap::value_type(pSectionWindow));
321 m_pParent->setMarked(&pSectionWindow->getReportSection().getSectionView(),m_aSections.size() == 1);
323 Resize();
325 //----------------------------------------------------------------------------
326 void OViewsWindow::removeSection(USHORT _nPosition)
328 if ( _nPosition < m_aSections.size() )
330 TSectionsMap::iterator aPos = getIteratorAtPos(_nPosition);
331 TSectionsMap::iterator aNew = getIteratorAtPos(_nPosition == 0 ? _nPosition+1: _nPosition - 1);
333 m_pParent->getReportView()->UpdatePropertyBrowserDelayed((*aNew)->getReportSection().getSectionView());
335 m_aSections.erase(aPos);
336 Resize();
337 } // if ( _nPosition < m_aSections.size() )
339 //----------------------------------------------------------------------------
340 void OViewsWindow::showView(USHORT _nPos,BOOL _bShow)
342 if ( _nPos < m_aSections.size() )
343 m_aSections[_nPos]->setCollapsed(_bShow);
345 //------------------------------------------------------------------------------
346 void OViewsWindow::toggleGrid(BOOL _bVisible)
348 ::std::for_each(m_aSections.begin(),m_aSections.end(),
349 ::std::compose1(::boost::bind(&OReportSection::SetGridVisible,_1,_bVisible),TReportPairHelper()));
350 ::std::for_each(m_aSections.begin(),m_aSections.end(),
351 ::std::compose1(::boost::bind(&OReportSection::Window::Invalidate,_1,INVALIDATE_NOERASE),TReportPairHelper()));
353 //------------------------------------------------------------------------------
354 sal_Int32 OViewsWindow::getTotalHeight() const
356 sal_Int32 nHeight = 0;
357 TSectionsMap::const_iterator aIter = m_aSections.begin();
358 TSectionsMap::const_iterator aEnd = m_aSections.end();
359 for (;aIter != aEnd ; ++aIter)
361 nHeight += (*aIter)->GetSizePixel().Height();
363 return nHeight;
365 //----------------------------------------------------------------------------
366 USHORT OViewsWindow::getSectionCount() const
368 return static_cast<USHORT>(m_aSections.size());
370 //----------------------------------------------------------------------------
371 void OViewsWindow::SetInsertObj( USHORT eObj,const ::rtl::OUString& _sShapeType )
373 TSectionsMap::iterator aIter = m_aSections.begin();
374 TSectionsMap::iterator aEnd = m_aSections.end();
375 for (;aIter != aEnd ; ++aIter)
376 (*aIter)->getReportSection().getSectionView().SetCurrentObj( eObj, ReportInventor );
378 m_sShapeType = _sShapeType;
380 //----------------------------------------------------------------------------
381 rtl::OUString OViewsWindow::GetInsertObjString() const
383 return m_sShapeType;
386 //------------------------------------------------------------------------------
387 void OViewsWindow::SetMode( DlgEdMode eNewMode )
389 ::std::for_each(m_aSections.begin(),m_aSections.end(),
390 ::std::compose1(::boost::bind(&OReportSection::SetMode,_1,eNewMode),TReportPairHelper()));
392 //----------------------------------------------------------------------------
393 BOOL OViewsWindow::HasSelection()
395 TSectionsMap::iterator aIter = m_aSections.begin();
396 TSectionsMap::iterator aEnd = m_aSections.end();
397 for (;aIter != aEnd && !(*aIter)->getReportSection().getSectionView().AreObjectsMarked(); ++aIter)
399 return aIter != aEnd;
401 //----------------------------------------------------------------------------
402 void OViewsWindow::Delete()
404 m_bInUnmark = sal_True;
405 ::std::for_each(m_aSections.begin(),m_aSections.end(),
406 ::std::compose1(::boost::mem_fn(&OReportSection::Delete),TReportPairHelper()));
407 m_bInUnmark = sal_False;
409 //----------------------------------------------------------------------------
410 void OViewsWindow::Copy()
412 uno::Sequence< beans::NamedValue > aAllreadyCopiedObjects;
413 ::std::for_each(m_aSections.begin(),m_aSections.end(),
414 ::std::compose1(::boost::bind(&OReportSection::Copy,_1,::boost::ref(aAllreadyCopiedObjects)),TReportPairHelper()));
416 //TSectionsMap::iterator aIter = m_aSections.begin();
417 //TSectionsMap::iterator aEnd = m_aSections.end();
418 //for (; aIter != aEnd; ++aIter)
419 // (*aIter)->getReportSection().Copy(aAllreadyCopiedObjects);
420 OReportExchange* pCopy = new OReportExchange(aAllreadyCopiedObjects);
421 uno::Reference< datatransfer::XTransferable> aEnsureDelete = pCopy;
422 pCopy->CopyToClipboard(this);
424 //----------------------------------------------------------------------------
425 void OViewsWindow::Paste()
427 TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(this));
428 OReportExchange::TSectionElements aCopies = OReportExchange::extractCopies(aTransferData);
429 if ( aCopies.getLength() > 1 )
430 ::std::for_each(m_aSections.begin(),m_aSections.end(),
431 ::std::compose1(::boost::bind(&OReportSection::Paste,_1,aCopies,false),TReportPairHelper()));
432 else
434 ::boost::shared_ptr<OSectionWindow> pMarkedSection = getMarkedSection();
435 if ( pMarkedSection )
436 pMarkedSection->getReportSection().Paste(aCopies,true);
439 //----------------------------------------------------------------------------
440 ::boost::shared_ptr<OSectionWindow> OViewsWindow::getMarkedSection(NearSectionAccess nsa) const
442 ::boost::shared_ptr<OSectionWindow> pRet;
443 TSectionsMap::const_iterator aIter = m_aSections.begin();
444 TSectionsMap::const_iterator aEnd = m_aSections.end();
445 sal_uInt32 nCurrentPosition = 0;
446 for (; aIter != aEnd ; ++aIter)
448 if ( (*aIter)->getStartMarker().isMarked() )
450 if (nsa == CURRENT)
452 pRet = (*aIter);
453 break;
455 else if ( nsa == PREVIOUS )
457 if (nCurrentPosition > 0)
459 pRet = (*(--aIter));
460 if (pRet == NULL)
462 pRet = (*m_aSections.begin());
465 else
467 // if we are out of bounds return the first one
468 pRet = (*m_aSections.begin());
470 break;
472 else if ( nsa == POST )
474 sal_uInt32 nSize = m_aSections.size();
475 if ((nCurrentPosition + 1) < nSize)
477 pRet = *(++aIter);
478 if (pRet == NULL)
480 pRet = (*(--aEnd));
483 else
485 // if we are out of bounds return the last one
486 pRet = (*(--aEnd));
488 break;
490 } // ( (*aIter).second->isMarked() )
491 ++nCurrentPosition;
492 } // for (; aIter != aEnd ; ++aIter)
494 return pRet;
496 // -------------------------------------------------------------------------
497 void OViewsWindow::markSection(const sal_uInt16 _nPos)
499 if ( _nPos < m_aSections.size() )
500 m_pParent->setMarked(m_aSections[_nPos]->getReportSection().getSection(),sal_True);
502 //----------------------------------------------------------------------------
503 BOOL OViewsWindow::IsPasteAllowed()
505 TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(this));
506 return aTransferData.HasFormat(OReportExchange::getDescriptorFormatId());
508 //-----------------------------------------------------------------------------
509 void OViewsWindow::SelectAll(const sal_uInt16 _nObjectType)
511 m_bInUnmark = sal_True;
512 ::std::for_each(m_aSections.begin(),m_aSections.end(),
513 ::std::compose1(::boost::bind(::boost::mem_fn(&OReportSection::SelectAll),_1,_nObjectType),TReportPairHelper()));
514 m_bInUnmark = sal_False;
516 //----------------------------------------------------------------------------
517 void OViewsWindow::SectionHasFocus(OReportSection* /*_pSection*/,BOOL /*_bHasFocus*/)
519 /* LLA!: this function does nothing!
520 TSectionsMap::iterator aIter = m_aSections.begin();
521 TSectionsMap::iterator aEnd = m_aSections.end();
522 for (USHORT i = 0 ; aIter != aEnd ; ++aIter,++i)
524 if ( (*aIter).first.get() == _pSection )
531 //-----------------------------------------------------------------------------
532 void OViewsWindow::unmarkAllObjects(OSectionView* _pSectionView)
534 if ( !m_bInUnmark )
536 m_bInUnmark = sal_True;
537 TSectionsMap::iterator aIter = m_aSections.begin();
538 TSectionsMap::iterator aEnd = m_aSections.end();
539 for (; aIter != aEnd ; ++aIter)
541 if ( &(*aIter)->getReportSection().getSectionView() != _pSectionView )
543 (*aIter)->getReportSection().deactivateOle();
544 (*aIter)->getReportSection().getSectionView().UnmarkAllObj();
546 } // for (; aIter != aEnd ; ++aIter)
547 m_bInUnmark = sal_False;
550 //-----------------------------------------------------------------------------
551 ::boost::shared_ptr<OSectionWindow> OViewsWindow::getReportSection(const uno::Reference< report::XSection >& _xSection)
553 OSL_ENSURE(_xSection.is(),"Section is NULL!");
554 ::boost::shared_ptr<OSectionWindow> pRet;
555 TSectionsMap::iterator aIter = m_aSections.begin();
556 TSectionsMap::iterator aEnd = m_aSections.end();
557 for (; aIter != aEnd ; ++aIter)
559 if ( (*aIter)->getReportSection().getSection() == _xSection )
561 pRet = (*aIter);
562 break;
563 } // if ( (*aIter)->getSection() == _xSection )
564 } // for (; aIter != aEnd ; ++aIter)
565 return pRet;
567 // -----------------------------------------------------------------------
568 void OViewsWindow::Notify(SfxBroadcaster & /*rBc*/, SfxHint const & rHint)
570 if (rHint.ISA(SfxSimpleHint)
571 && (static_cast< SfxSimpleHint const & >(rHint).GetId()
572 == SFX_HINT_COLORS_CHANGED))
574 ImplInitSettings();
575 Invalidate();
578 // -----------------------------------------------------------------------------
579 void OViewsWindow::MouseButtonDown( const MouseEvent& rMEvt )
581 if ( rMEvt.IsLeft() )
583 GrabFocus();
584 const uno::Sequence< beans::PropertyValue> aArgs;
585 getView()->getReportView()->getController().executeChecked(SID_SELECT_REPORT,aArgs);
587 Window::MouseButtonDown(rMEvt);
589 //----------------------------------------------------------------------------
590 void OViewsWindow::showRuler(sal_Bool _bShow)
592 ::std::for_each(m_aSections.begin(),m_aSections.end(),
593 ::std::compose1(::boost::bind(&OStartMarker::showRuler,_1,_bShow),TStartMarkerHelper()));
594 ::std::for_each(m_aSections.begin(),m_aSections.end(),
595 ::std::compose1(::boost::bind(&OStartMarker::Window::Invalidate,_1,USHORT(INVALIDATE_NOERASE)),TStartMarkerHelper()));
597 //----------------------------------------------------------------------------
598 void OViewsWindow::MouseButtonUp( const MouseEvent& rMEvt )
600 if ( rMEvt.IsLeft() )
602 TSectionsMap::iterator aIter = m_aSections.begin();
603 TSectionsMap::iterator aEnd = m_aSections.end();
604 for (;aIter != aEnd ; ++aIter)
606 if ( (*aIter)->getReportSection().getSectionView().AreObjectsMarked() )
608 (*aIter)->getReportSection().MouseButtonUp(rMEvt);
609 break;
613 // remove special insert mode
614 for (aIter = m_aSections.begin();aIter != aEnd ; ++aIter)
616 (*aIter)->getReportSection().getPage()->resetSpecialMode();
620 //------------------------------------------------------------------------------
621 sal_Bool OViewsWindow::handleKeyEvent(const KeyEvent& _rEvent)
623 sal_Bool bRet = sal_False;
624 TSectionsMap::iterator aIter = m_aSections.begin();
625 TSectionsMap::iterator aEnd = m_aSections.end();
626 for (;aIter != aEnd ; ++aIter)
628 //if ( (*aIter).getReportSection().getSectionView().->AreObjectsMarked() )
629 if ( (*aIter)->getStartMarker().isMarked() )
631 bRet = (*aIter)->getReportSection().handleKeyEvent(_rEvent);
634 return bRet;
636 //----------------------------------------------------------------------------
637 OViewsWindow::TSectionsMap::iterator OViewsWindow::getIteratorAtPos(USHORT _nPos)
639 TSectionsMap::iterator aRet = m_aSections.end();
640 if ( _nPos < m_aSections.size() )
641 aRet = m_aSections.begin() + _nPos;
642 return aRet;
644 //------------------------------------------------------------------------
645 void OViewsWindow::setMarked(OSectionView* _pSectionView,sal_Bool _bMark)
647 OSL_ENSURE(_pSectionView != NULL,"SectionView is NULL!");
648 if ( _pSectionView )
649 setMarked(_pSectionView->getReportSection()->getSection(),_bMark);
651 //------------------------------------------------------------------------
652 void OViewsWindow::setMarked(const uno::Reference< report::XSection>& _xSection,sal_Bool _bMark)
654 TSectionsMap::iterator aIter = m_aSections.begin();
655 TSectionsMap::iterator aEnd = m_aSections.end();
656 for (; aIter != aEnd ; ++aIter)
658 if ( (*aIter)->getReportSection().getSection() != _xSection )
660 (*aIter)->setMarked(sal_False);
662 else if ( (*aIter)->getStartMarker().isMarked() != _bMark )
664 (*aIter)->setMarked(_bMark);
668 //------------------------------------------------------------------------
669 void OViewsWindow::setMarked(const uno::Sequence< uno::Reference< report::XReportComponent> >& _aShapes,sal_Bool _bMark)
671 bool bFirst = true;
672 const uno::Reference< report::XReportComponent>* pIter = _aShapes.getConstArray();
673 const uno::Reference< report::XReportComponent>* pEnd = pIter + _aShapes.getLength();
674 for(;pIter != pEnd;++pIter)
676 const uno::Reference< report::XSection> xSection = (*pIter)->getSection();
677 if ( xSection.is() )
679 if ( bFirst )
681 bFirst = false;
682 m_pParent->setMarked(xSection,_bMark);
684 ::boost::shared_ptr<OSectionWindow> pSectionWindow = getReportSection(xSection);
685 if ( pSectionWindow )
687 SvxShape* pShape = SvxShape::getImplementation( *pIter );
688 SdrObject* pObject = pShape ? pShape->GetSdrObject() : NULL;
689 OSL_ENSURE( pObject, "OViewsWindow::setMarked: no SdrObject for the shape!" );
690 if ( pObject )
691 pSectionWindow->getReportSection().getSectionView().MarkObj( pObject, pSectionWindow->getReportSection().getSectionView().GetSdrPageView(), !_bMark );
696 // -----------------------------------------------------------------------------
697 void OViewsWindow::collectRectangles(TRectangleMap& _rSortRectangles, bool _bBoundRects)
699 TSectionsMap::iterator aIter = m_aSections.begin();
700 TSectionsMap::iterator aEnd = m_aSections.end();
701 for (aIter = m_aSections.begin();aIter != aEnd ; ++aIter)
703 OSectionView& rView = (*aIter)->getReportSection().getSectionView();
704 if ( rView.AreObjectsMarked() )
706 rView.SortMarkedObjects();
707 const sal_uInt32 nCount = rView.GetMarkedObjectCount();
708 for (sal_uInt32 i=0; i < nCount; ++i)
710 const SdrMark* pM = rView.GetSdrMarkByIndex(i);
711 SdrObject* pObj = pM->GetMarkedSdrObj();
712 Rectangle aObjRect(_bBoundRects ? pObj->GetCurrentBoundRect() : pObj->GetSnapRect());
713 _rSortRectangles.insert(TRectangleMap::value_type(aObjRect,TRectangleMap::mapped_type(pObj,&rView)));
718 // -----------------------------------------------------------------------------
719 void OViewsWindow::collectBoundResizeRect(const TRectangleMap& _rSortRectangles,sal_Int32 _nControlModification,bool _bAlignAtSection, bool _bBoundRects,Rectangle& _rBound,Rectangle& _rResize)
721 bool bOnlyOnce = false;
722 TRectangleMap::const_iterator aRectIter = _rSortRectangles.begin();
723 TRectangleMap::const_iterator aRectEnd = _rSortRectangles.end();
724 for (;aRectIter != aRectEnd ; ++aRectIter)
726 Rectangle aObjRect = aRectIter->first;
727 if ( _rResize.IsEmpty() )
728 _rResize = aObjRect;
729 switch(_nControlModification)
731 case ControlModification::WIDTH_SMALLEST:
732 if ( _rResize.getWidth() > aObjRect.getWidth() )
733 _rResize = aObjRect;
734 break;
735 case ControlModification::HEIGHT_SMALLEST:
736 if ( _rResize.getHeight() > aObjRect.getHeight() )
737 _rResize = aObjRect;
738 break;
739 case ControlModification::WIDTH_GREATEST:
740 if ( _rResize.getWidth() < aObjRect.getWidth() )
741 _rResize = aObjRect;
742 break;
743 case ControlModification::HEIGHT_GREATEST:
744 if ( _rResize.getHeight() < aObjRect.getHeight() )
745 _rResize = aObjRect;
746 break;
749 SdrObjTransformInfoRec aInfo;
750 const SdrObject* pObj = aRectIter->second.first;
751 pObj->TakeObjInfo(aInfo);
752 BOOL bHasFixed = !aInfo.bMoveAllowed || pObj->IsMoveProtect();
753 if ( bHasFixed )
754 _rBound.Union(aObjRect);
755 else
757 if ( _bAlignAtSection || _rSortRectangles.size() == 1 )
758 { // einzelnes Obj an der Seite ausrichten
759 if ( ! bOnlyOnce )
761 bOnlyOnce = true;
762 OReportSection* pReportSection = aRectIter->second.second->getReportSection();
763 const uno::Reference< report::XSection> xSection = pReportSection->getSection();
766 uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
767 _rBound.Union(Rectangle(getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN),0,
768 getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width - getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN),
769 xSection->getHeight()));
771 catch(uno::Exception){}
774 else
776 if (_bBoundRects)
777 _rBound.Union(aRectIter->second.second->GetMarkedObjBoundRect());
778 else
779 _rBound.Union(aRectIter->second.second->GetMarkedObjRect());
784 // -----------------------------------------------------------------------------
785 void OViewsWindow::alignMarkedObjects(sal_Int32 _nControlModification,bool _bAlignAtSection, bool _bBoundRects)
787 if ( _nControlModification == ControlModification::NONE )
788 return;
790 Point aRefPoint;
791 RectangleLess::CompareMode eCompareMode = RectangleLess::POS_LEFT;
792 switch (_nControlModification)
794 case ControlModification::TOP : eCompareMode = RectangleLess::POS_UPPER; break;
795 case ControlModification::BOTTOM: eCompareMode = RectangleLess::POS_DOWN; break;
796 case ControlModification::LEFT : eCompareMode = RectangleLess::POS_LEFT; break;
797 case ControlModification::RIGHT : eCompareMode = RectangleLess::POS_RIGHT; break;
798 case ControlModification::CENTER_HORIZONTAL :
799 case ControlModification::CENTER_VERTICAL :
801 eCompareMode = (ControlModification::CENTER_VERTICAL == _nControlModification) ? RectangleLess::POS_CENTER_VERTICAL : RectangleLess::POS_CENTER_HORIZONTAL;
802 uno::Reference<report::XSection> xSection = (*m_aSections.begin())->getReportSection().getSection();
803 uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
804 aRefPoint = Rectangle(getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN),0,
805 getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width - getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN),
806 xSection->getHeight()).Center();
808 break;
809 default: break;
811 RectangleLess aCompare(eCompareMode,aRefPoint);
812 TRectangleMap aSortRectangles(aCompare);
813 collectRectangles(aSortRectangles,_bBoundRects);
815 Rectangle aBound;
816 Rectangle aResize;
817 collectBoundResizeRect(aSortRectangles,_nControlModification,_bAlignAtSection,_bBoundRects,aBound,aResize);
819 bool bMove = true;
821 ::std::mem_fun_t<long&,Rectangle> aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Bottom);
822 ::std::mem_fun_t<long&,Rectangle> aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Top);
823 TRectangleMap::iterator aRectIter = aSortRectangles.begin();
824 TRectangleMap::iterator aRectEnd = aSortRectangles.end();
825 for (;aRectIter != aRectEnd ; ++aRectIter)
827 Rectangle aObjRect = aRectIter->first;
828 SdrObject* pObj = aRectIter->second.first;
829 SdrView* pView = aRectIter->second.second;
830 Point aCenter(aBound.Center());
831 SdrObjTransformInfoRec aInfo;
832 pObj->TakeObjInfo(aInfo);
833 if (aInfo.bMoveAllowed && !pObj->IsMoveProtect())
835 long nXMov = 0;
836 long nYMov = 0;
837 long* pValue = &nXMov;
838 switch(_nControlModification)
840 case ControlModification::TOP :
841 aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Top);
842 aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Bottom);
843 pValue = &nYMov;
844 break;
845 case ControlModification::BOTTOM:
846 // defaults are already set
847 pValue = &nYMov;
848 break;
849 case ControlModification::CENTER_VERTICAL:
850 nYMov = aCenter.Y() - aObjRect.Center().Y();
851 pValue = &nYMov;
852 bMove = false;
853 break;
854 case ControlModification::RIGHT :
855 aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Right);
856 aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Left);
857 break;
858 case ControlModification::CENTER_HORIZONTAL:
859 nXMov = aCenter.X() - aObjRect.Center().X();
860 bMove = false;
861 break;
862 case ControlModification::LEFT :
863 aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Left);
864 aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Right);
865 break;
866 default:
867 bMove = false;
868 break;
870 if ( bMove )
872 Rectangle aTest = aObjRect;
873 aGetFun(&aTest) = aGetFun(&aBound);
874 TRectangleMap::iterator aInterSectRectIter = aSortRectangles.begin();
875 for (; aInterSectRectIter != aRectIter; ++aInterSectRectIter)
877 if ( pView == aInterSectRectIter->second.second && dynamic_cast<OUnoObject*>(aInterSectRectIter->second.first) )
879 SdrObject* pPreviousObj = aInterSectRectIter->second.first;
880 Rectangle aIntersectRect = aTest.GetIntersection(_bBoundRects ? pPreviousObj->GetCurrentBoundRect() : pPreviousObj->GetSnapRect());
881 if ( !aIntersectRect.IsEmpty() && (aIntersectRect.Left() != aIntersectRect.Right() && aIntersectRect.Top() != aIntersectRect.Bottom() ) )
883 *pValue = aRefFun(&aIntersectRect) - aGetFun(&aObjRect);
884 break;
888 if ( aInterSectRectIter == aRectIter )
889 *pValue = aGetFun(&aBound) - aGetFun(&aObjRect);
892 if ( lcl_getNewRectSize(aObjRect,nXMov,nYMov,pObj,pView,_nControlModification,_bBoundRects) )
894 const Size aSize(nXMov,nYMov);
895 pView->AddUndo(pView->GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pObj,aSize));
896 pObj->Move(aSize);
897 aObjRect = (_bBoundRects ? pObj->GetCurrentBoundRect() : pObj->GetSnapRect());
900 // resizing control
901 if ( !aResize.IsEmpty() && aObjRect != aResize )
903 nXMov = aResize.getWidth();
904 nYMov = aResize.getHeight();
905 switch(_nControlModification)
907 case ControlModification::WIDTH_GREATEST:
908 case ControlModification::HEIGHT_GREATEST:
909 if ( _nControlModification == ControlModification::HEIGHT_GREATEST )
910 nXMov = aObjRect.getWidth();
911 else if ( _nControlModification == ControlModification::WIDTH_GREATEST )
912 nYMov = aObjRect.getHeight();
913 lcl_getNewRectSize(aObjRect,nXMov,nYMov,pObj,pView,_nControlModification,_bBoundRects);
914 // run through
915 case ControlModification::WIDTH_SMALLEST:
916 case ControlModification::HEIGHT_SMALLEST:
917 pView->AddUndo( pView->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
919 OObjectBase* pObjBase = dynamic_cast<OObjectBase*>(pObj);
920 OSL_ENSURE(pObjBase,"Where comes this object from?");
921 if ( pObjBase )
923 if ( _nControlModification == ControlModification::WIDTH_SMALLEST || _nControlModification == ControlModification::WIDTH_GREATEST )
924 pObjBase->getReportComponent()->setSize(awt::Size(nXMov,aObjRect.getHeight()));
925 //pObj->Resize(aObjRect.TopLeft(),Fraction(nXMov,aObjRect.getWidth()),Fraction(1,1));
926 else if ( _nControlModification == ControlModification::HEIGHT_GREATEST || _nControlModification == ControlModification::HEIGHT_SMALLEST )
927 pObjBase->getReportComponent()->setSize(awt::Size(aObjRect.getWidth(),nYMov));
928 //pObj->Resize(aObjRect.TopLeft(),Fraction(1,1),Fraction(nYMov,aObjRect.getHeight()));
931 break;
932 default:
933 break;
937 pView->AdjustMarkHdl();
940 // -----------------------------------------------------------------------------
941 void OViewsWindow::createDefault()
943 ::boost::shared_ptr<OSectionWindow> pMarkedSection = getMarkedSection();
944 if ( pMarkedSection )
945 pMarkedSection->getReportSection().createDefault(m_sShapeType);
947 // -----------------------------------------------------------------------------
948 void OViewsWindow::setGridSnap(BOOL bOn)
950 TSectionsMap::iterator aIter = m_aSections.begin();
951 TSectionsMap::iterator aEnd = m_aSections.end();
952 for (; aIter != aEnd ; ++aIter)
954 (*aIter)->getReportSection().getSectionView().SetGridSnap(bOn);
955 (*aIter)->getReportSection().Invalidate();
958 // -----------------------------------------------------------------------------
959 void OViewsWindow::setDragStripes(BOOL bOn)
961 TSectionsMap::iterator aIter = m_aSections.begin();
962 TSectionsMap::iterator aEnd = m_aSections.end();
963 for (; aIter != aEnd ; ++aIter)
964 (*aIter)->getReportSection().getSectionView().SetDragStripes(bOn);
966 // -----------------------------------------------------------------------------
967 BOOL OViewsWindow::isDragStripes() const
969 return !m_aSections.empty() && (*m_aSections.begin())->getReportSection().getSectionView().IsDragStripes();
971 // -----------------------------------------------------------------------------
973 USHORT OViewsWindow::getPosition(const OSectionWindow* _pSectionWindow) const
975 TSectionsMap::const_iterator aIter = m_aSections.begin();
976 TSectionsMap::const_iterator aEnd = m_aSections.end();
977 USHORT nPosition = 0;
978 for (; aIter != aEnd ; ++aIter)
980 if ( _pSectionWindow == (*aIter).get() )
982 break;
984 ++nPosition;
986 return nPosition;
988 // -----------------------------------------------------------------------------
989 ::boost::shared_ptr<OSectionWindow> OViewsWindow::getSectionWindow(const USHORT _nPos) const
991 ::boost::shared_ptr<OSectionWindow> aReturn;
993 if ( _nPos < m_aSections.size() )
994 aReturn = m_aSections[_nPos];
996 return aReturn;
998 // -----------------------------------------------------------------------------
999 namespace
1001 enum SectionViewAction
1003 eEndDragObj,
1004 eEndAction,
1005 eMoveAction,
1006 eMarkAction,
1007 eForceToAnotherPage,
1008 eBreakAction
1010 class ApplySectionViewAction : public ::std::unary_function< OViewsWindow::TSectionsMap::value_type, void >
1012 private:
1013 SectionViewAction m_eAction;
1014 sal_Bool m_bCopy;
1015 Point m_aPoint;
1017 public:
1018 ApplySectionViewAction( sal_Bool _bCopy ) : m_eAction( eEndDragObj ), m_bCopy( _bCopy ) { }
1019 ApplySectionViewAction(SectionViewAction _eAction = eEndAction ) : m_eAction( _eAction ) { }
1020 ApplySectionViewAction( const Point& _rPoint, SectionViewAction _eAction = eMoveAction ) : m_eAction( _eAction ), m_bCopy( sal_False ), m_aPoint( _rPoint ) { }
1022 void operator() ( const OViewsWindow::TSectionsMap::value_type& _rhs )
1024 OSectionView& rView( _rhs->getReportSection().getSectionView() );
1025 switch ( m_eAction )
1027 case eEndDragObj:
1028 rView.EndDragObj( m_bCopy );
1029 break;
1030 case eEndAction:
1031 if ( rView.IsAction() )
1032 rView.EndAction ( );
1033 break;
1034 case eMoveAction:
1035 rView.MovAction ( m_aPoint );
1036 break;
1037 case eMarkAction:
1038 rView.BegMarkObj ( m_aPoint );
1039 break;
1040 case eForceToAnotherPage:
1041 rView.ForceMarkedToAnotherPage();
1042 break;
1043 case eBreakAction:
1044 if ( rView.IsAction() )
1045 rView.BrkAction ( );
1046 break;
1047 // default:
1053 // -----------------------------------------------------------------------------
1054 void OViewsWindow::BrkAction()
1056 EndDragObj_removeInvisibleObjects();
1057 ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction(eBreakAction) );
1059 // -----------------------------------------------------------------------------
1060 void OViewsWindow::BegDragObj_createInvisibleObjectAtPosition(const Rectangle& _aRect, const OSectionView& _rSection)
1062 TSectionsMap::iterator aIter = m_aSections.begin();
1063 TSectionsMap::iterator aEnd = m_aSections.end();
1064 Point aNewPos(0,0);
1066 for (; aIter != aEnd; ++aIter)
1068 OReportSection& rReportSection = (*aIter)->getReportSection();
1069 rReportSection.getPage()->setSpecialMode();
1070 OSectionView& rView = rReportSection.getSectionView();
1072 if ( &rView != &_rSection )
1074 // SdrRectObj *pNewObj = new SdrRectObj(OBJ_RECT, _aRect);
1075 // SdrObject *pNewObj = new SdrUnoObj(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Temp Label")));
1076 SdrObject *pNewObj = new SdrUnoObj(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText")));
1077 if (pNewObj)
1079 pNewObj->SetLogicRect(_aRect);
1080 // pNewObj->SetSize(_aRect.GetSize());
1081 // pNewObj->Move(Size(_aRect.Left(), _aRect.Top()));
1083 pNewObj->Move(Size(0, aNewPos.Y()));
1084 rReportSection.getPage()->InsertObject(pNewObj);
1085 m_aBegDragTempList.push_back(pNewObj);
1086 Rectangle aRect = pNewObj->GetLogicRect();
1088 // pNewObj->SetText(String::CreateFromAscii("Drag helper"));
1089 rView.MarkObj( pNewObj, rView.GetSdrPageView() );
1092 const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1093 aNewPos.Y() -= nSectionHeight;
1094 // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1097 // -----------------------------------------------------------------------------
1098 bool OViewsWindow::isObjectInMyTempList(SdrObject *_pObj)
1100 ::std::vector<SdrObject*>::iterator aIter = m_aBegDragTempList.begin();
1101 ::std::vector<SdrObject*>::iterator aEnd = m_aBegDragTempList.end();
1102 for (; aIter != aEnd; ++aIter)
1104 if (*aIter == _pObj)
1106 return true;
1109 return false;
1112 // -----------------------------------------------------------------------------
1113 void OViewsWindow::BegDragObj(const Point& _aPnt, SdrHdl* _pHdl,const OSectionView* _pSection)
1115 OSL_TRACE("BegDragObj Clickpoint X:%d Y:%d\n", _aPnt.X(), _aPnt.Y() );
1117 m_aBegDragTempList.clear();
1119 // Calculate the absolute clickpoint in the views
1120 Point aAbsolutePnt = _aPnt;
1121 TSectionsMap::iterator aIter = m_aSections.begin();
1122 TSectionsMap::iterator aEnd = m_aSections.end();
1123 for (; aIter != aEnd; ++aIter)
1125 OReportSection& rReportSection = (*aIter)->getReportSection();
1126 OSectionView* pView = &rReportSection.getSectionView();
1127 if (pView == _pSection)
1128 break;
1129 const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1130 aAbsolutePnt.Y() += nSectionHeight;
1132 m_aDragDelta = Point(SAL_MAX_INT32, SAL_MAX_INT32);
1133 OSL_TRACE("BegDragObj Absolute X:%d Y:%d\n", aAbsolutePnt.X(), aAbsolutePnt.Y() );
1135 // Create drag lines over all viewable Views
1136 // Therefore we need to identify the marked objects
1137 // and create temporary objects on all other views at the same position
1138 // relative to its occurance.
1140 OSL_TRACE("BegDragObj createInvisible Objects\n" );
1141 int nViewCount = 0;
1142 Point aNewObjPos(0,0);
1143 for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1145 OReportSection& rReportSection = (*aIter)->getReportSection();
1147 OSectionView& rView = rReportSection.getSectionView();
1149 if ( rView.AreObjectsMarked() )
1151 const sal_uInt32 nCount = rView.GetMarkedObjectCount();
1152 for (sal_uInt32 i=0; i < nCount; ++i)
1154 const SdrMark* pM = rView.GetSdrMarkByIndex(i);
1155 SdrObject* pObj = pM->GetMarkedSdrObj();
1156 if (!isObjectInMyTempList(pObj))
1158 Rectangle aRect( pObj->GetCurrentBoundRect() );
1159 aRect.Move(0, aNewObjPos.Y());
1160 OSL_TRACE("BegDragObj createInvisible X:%d Y:%d on View #%d\n", aRect.Left(), aRect.Top(), nViewCount );
1162 BegDragObj_createInvisibleObjectAtPosition(aRect, rView);
1164 // calculate the clickpoint
1165 const sal_Int32 nDeltaX = abs(aRect.Left() - aAbsolutePnt.X());
1166 const sal_Int32 nDeltaY = abs(aRect.Top() - aAbsolutePnt.Y());
1167 if (m_aDragDelta.X() > nDeltaX)
1168 m_aDragDelta.X() = nDeltaX;
1169 if (m_aDragDelta.Y() > nDeltaY)
1170 m_aDragDelta.Y() = nDeltaY;
1174 ++nViewCount;
1175 Rectangle aClipRect = rView.GetWorkArea();
1176 aClipRect.Top() = -aNewObjPos.Y();
1177 rView.SetWorkArea( aClipRect );
1179 const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1180 aNewObjPos.Y() += nSectionHeight;
1182 // don't subtract the height of the lines between the views
1183 // aNewObjPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1186 Point aNewPos = aAbsolutePnt;
1187 // for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1188 // {
1189 // OReportSection& rReportSection = (*aIter)->getReportSection();
1190 // if ( &rReportSection.getSectionView() == _pSection )
1191 // break;
1192 // aNewPos.Y() += rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1193 // }
1195 const short nDrgLog = static_cast<short>(PixelToLogic(Size(3,0)).Width());
1196 // long nLastSectionHeight = 0;
1197 // bool bAdd = true;
1198 nViewCount = 0;
1199 for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1201 OReportSection& rReportSection = (*aIter)->getReportSection();
1203 // if ( &rReportSection.getSectionView() == _pSection )
1204 // {
1205 // bAdd = false;
1206 // aNewPos = _aPnt;
1207 // }
1208 // else if ( bAdd )
1209 // {
1210 // const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1211 // aNewPos.Y() += nSectionHeight;
1212 // }
1213 // else
1214 // {
1215 // aNewPos.Y() -= nLastSectionHeight;
1216 // }
1219 SdrHdl* pHdl = _pHdl;
1220 if ( pHdl )
1222 if ( &rReportSection.getSectionView() != _pSection )
1224 const SdrHdlList& rHdlList = rReportSection.getSectionView().GetHdlList();
1225 pHdl = rHdlList.GetHdl(_pHdl->GetKind());
1228 OSL_TRACE("BegDragObj X:%d Y:%d on View#%d\n", aNewPos.X(), aNewPos.Y(), nViewCount++ );
1229 rReportSection.getSectionView().BegDragObj(aNewPos, (OutputDevice*)NULL, pHdl, nDrgLog, NULL);
1231 const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1232 aNewPos.Y() -= nSectionHeight;
1233 // subtract the height between the views, because they are visible but not from interest here.
1234 // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1238 // -----------------------------------------------------------------------------
1239 void OViewsWindow::ForceMarkedToAnotherPage()
1241 ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction(eForceToAnotherPage ) );
1243 // -----------------------------------------------------------------------------
1244 void OViewsWindow::BegMarkObj(const Point& _aPnt,const OSectionView* _pSection)
1246 bool bAdd = true;
1247 Point aNewPos = _aPnt;
1249 TSectionsMap::iterator aIter = m_aSections.begin();
1250 TSectionsMap::iterator aEnd = m_aSections.end();
1251 long nLastSectionHeight = 0;
1252 for (; aIter != aEnd; ++aIter)
1254 OReportSection& rReportSection = (*aIter)->getReportSection();
1255 if ( &rReportSection.getSectionView() == _pSection )
1257 bAdd = false;
1258 aNewPos = _aPnt; // 2,2
1260 else if ( bAdd )
1262 const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1263 aNewPos.Y() += nSectionHeight;
1265 else
1267 aNewPos.Y() -= nLastSectionHeight;
1269 rReportSection.getSectionView().BegMarkObj ( aNewPos );
1270 nLastSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1272 // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1274 //::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction( _aPnt , eMarkAction) );
1276 // -----------------------------------------------------------------------------
1277 OSectionView* OViewsWindow::getSectionRelativeToPosition(const OSectionView* _pSection,Point& _rPnt)
1279 OSectionView* pSection = NULL;
1280 sal_Int32 nCount = 0;
1281 TSectionsMap::iterator aIter = m_aSections.begin();
1282 const TSectionsMap::iterator aEnd = m_aSections.end();
1283 for (; aIter != aEnd ; ++aIter,++nCount)
1285 OReportSection& rReportSection = (*aIter)->getReportSection();
1286 if ( &rReportSection.getSectionView() == _pSection)
1287 break;
1289 OSL_ENSURE(aIter != aEnd,"This can never happen!");
1290 if ( _rPnt.Y() < 0 )
1292 if ( nCount )
1293 --aIter;
1294 for (; nCount && (_rPnt.Y() < 0); --nCount)
1296 OReportSection& rReportSection = (*aIter)->getReportSection();
1297 _rPnt.Y() += rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1298 if ( (nCount -1) > 0 && (_rPnt.Y() < 0) )
1299 --aIter;
1301 if ( nCount == 0 )
1302 pSection = &(*m_aSections.begin())->getReportSection().getSectionView();
1303 else
1304 pSection = &(*aIter)->getReportSection().getSectionView();
1306 else
1308 for (; aIter != aEnd; ++aIter)
1310 OReportSection& rReportSection = (*aIter)->getReportSection();
1311 const long nHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1312 if ( (_rPnt.Y() - nHeight) < 0 )
1313 break;
1314 _rPnt.Y() -= nHeight;
1316 if ( aIter != aEnd )
1317 pSection = &(*aIter)->getReportSection().getSectionView();
1318 else
1319 pSection = &(*(aEnd-1))->getReportSection().getSectionView();
1322 return pSection;
1324 // -----------------------------------------------------------------------------
1325 void OViewsWindow::EndDragObj_removeInvisibleObjects()
1327 TSectionsMap::iterator aIter = m_aSections.begin();
1328 TSectionsMap::iterator aEnd = m_aSections.end();
1330 for (; aIter != aEnd; ++aIter)
1332 OReportSection& rReportSection = (*aIter)->getReportSection();
1333 rReportSection.getPage()->resetSpecialMode();
1336 // -----------------------------------------------------------------------------
1337 void OViewsWindow::EndDragObj(BOOL _bControlKeyPressed, const OSectionView* _pSection,const Point& _aPnt)
1339 const String sUndoAction = String((ModuleRes(RID_STR_UNDO_CHANGEPOSITION)));
1340 UndoManagerListAction aListAction(*getView()->getReportView()->getController().getUndoMgr(),sUndoAction);
1342 Point aNewPos = _aPnt;
1343 OSectionView* pInSection = getSectionRelativeToPosition(_pSection, aNewPos);
1344 if (!_bControlKeyPressed && _pSection != pInSection)
1346 EndDragObj_removeInvisibleObjects();
1348 // we need to manipulate the current clickpoint, we substract the old delta from BeginDrag
1349 // OSectionView* pInSection = getSectionRelativeToPosition(_pSection, aPnt);
1350 // aNewPos.X() -= m_aDragDelta.X();
1351 // aNewPos.Y() -= m_aDragDelta.Y();
1352 aNewPos -= m_aDragDelta;
1354 uno::Sequence< beans::NamedValue > aAllreadyCopiedObjects;
1355 TSectionsMap::iterator aIter = m_aSections.begin();
1356 const TSectionsMap::iterator aEnd = m_aSections.end();
1357 for (; aIter != aEnd; ++aIter)
1359 OReportSection& rReportSection = (*aIter)->getReportSection();
1360 if ( pInSection != &rReportSection.getSectionView() )
1362 rReportSection.getSectionView().BrkAction();
1363 rReportSection.Copy(aAllreadyCopiedObjects,true);
1365 else
1366 pInSection->EndDragObj(FALSE);
1367 } // for (; aIter != aEnd; ++aIter)
1369 if ( aAllreadyCopiedObjects.getLength() )
1371 beans::NamedValue* pIter = aAllreadyCopiedObjects.getArray();
1372 const beans::NamedValue* pEnd = pIter + aAllreadyCopiedObjects.getLength();
1375 uno::Reference<report::XReportDefinition> xReportDefinition = getView()->getReportView()->getController().getReportDefinition();
1376 const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN);
1377 const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN);
1378 const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width;
1380 Point aPrevious;
1381 for (; pIter != pEnd; ++pIter)
1383 uno::Sequence< uno::Reference<util::XCloneable> > aClones;
1384 pIter->Value >>= aClones;
1385 uno::Reference<util::XCloneable>* pColIter = aClones.getArray();
1386 const uno::Reference<util::XCloneable>* pColEnd = pColIter + aClones.getLength();
1387 for (; pColIter != pColEnd; ++pColIter)
1389 uno::Reference< report::XReportComponent> xRC(*pColIter,uno::UNO_QUERY);
1390 aPrevious = VCLPoint(xRC->getPosition());
1392 awt::Size aSize = xRC->getSize();
1393 if ( aNewPos.X() < nLeftMargin )
1394 aNewPos.X() = nLeftMargin;
1395 else if ( (aNewPos.X() + aSize.Width) > (nPaperWidth - nRightMargin) )
1396 aNewPos.X() = nPaperWidth - nRightMargin - aSize.Width;
1397 if ( aNewPos.Y() < 0 )
1398 aNewPos.Y() = 0;
1399 if ( aNewPos.X() < 0 )
1401 aSize.Width += aNewPos.X();
1402 aNewPos.X()= 0;
1403 xRC->setSize(aSize);
1405 xRC->setPosition(AWTPoint(aNewPos));
1406 if ( (pColIter+1) != pColEnd )
1408 uno::Reference< report::XReportComponent> xRCNext(*(pColIter + 1),uno::UNO_QUERY);
1409 Point aNextPosition = VCLPoint(xRCNext->getPosition());
1410 aNewPos += (aNextPosition - aPrevious);
1415 catch(uno::Exception&)
1418 pInSection->getReportSection()->Paste(aAllreadyCopiedObjects,true);
1421 else
1423 ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction( FALSE ) );
1424 EndDragObj_removeInvisibleObjects();
1427 // -----------------------------------------------------------------------------
1428 void OViewsWindow::EndAction()
1430 ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction() );
1432 // -----------------------------------------------------------------------------
1433 void OViewsWindow::MovAction(const Point& _aPnt,const OSectionView* _pSection,bool _bMove, bool _bControlKeySet)
1435 (void)_bMove;
1437 Point aRealMousePos = _aPnt;
1438 Point aCurrentSectionPos;
1439 OSL_TRACE("MovAction X:%d Y:%d\n", aRealMousePos.X(), aRealMousePos.Y() );
1441 Point aHdlPos;
1442 SdrHdl* pHdl = _pSection->GetDragHdl();
1443 if ( pHdl )
1445 aHdlPos = pHdl->GetPos();
1447 TSectionsMap::iterator aIter/* = m_aSections.begin() */;
1448 TSectionsMap::iterator aEnd = m_aSections.end();
1450 //if ( _bMove )
1452 for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1454 OReportSection& rReportSection = (*aIter)->getReportSection();
1455 if ( &rReportSection.getSectionView() == _pSection )
1456 break;
1457 const long nSectionHeight = (*aIter)->PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1458 aCurrentSectionPos.Y() += nSectionHeight;
1459 } // for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1461 aRealMousePos += aCurrentSectionPos;
1463 // If control key is pressed the work area is limited to the section with the current selection.
1464 Point aPosForWorkArea(0,0);
1465 for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1467 OReportSection& rReportSection = (*aIter)->getReportSection();
1468 OSectionView& rView = rReportSection.getSectionView();
1469 const long nSectionHeight = (*aIter)->PixelToLogic((*aIter)->GetOutputSizePixel()).Height();
1471 if (_bControlKeySet)
1473 Rectangle aClipRect = rView.GetWorkArea();
1474 aClipRect.Top() = aCurrentSectionPos.Y() - aPosForWorkArea.Y();
1475 // if (aClipRect.Top() < 0) aClipRect.Top() = 0;
1476 aClipRect.Bottom() = aClipRect.Top() + nSectionHeight;
1477 rView.SetWorkArea( aClipRect );
1479 else
1481 Rectangle aClipRect = rView.GetWorkArea();
1482 aClipRect.Top() = -aPosForWorkArea.Y();
1483 rView.SetWorkArea( aClipRect );
1485 aPosForWorkArea.Y() += nSectionHeight;
1486 // aNewPos.Y() += PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1490 for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1492 OReportSection& rReportSection = (*aIter)->getReportSection();
1493 SdrHdl* pCurrentHdl = rReportSection.getSectionView().GetDragHdl();
1494 if ( pCurrentHdl )
1496 aRealMousePos = _aPnt + pCurrentHdl->GetPos() - aHdlPos;
1498 rReportSection.getSectionView().MovAction ( aRealMousePos );
1499 const long nSectionHeight = (*aIter)->PixelToLogic((*aIter)->GetOutputSizePixel()).Height();
1500 aRealMousePos.Y() -= nSectionHeight;
1503 // -----------------------------------------------------------------------------
1504 BOOL OViewsWindow::IsAction() const
1506 BOOL bAction = FALSE;
1507 TSectionsMap::const_iterator aIter = m_aSections.begin();
1508 TSectionsMap::const_iterator aEnd = m_aSections.end();
1509 for (; !bAction && aIter != aEnd; ++aIter)
1510 bAction = (*aIter)->getReportSection().getSectionView().IsAction();
1511 return bAction;
1513 // -----------------------------------------------------------------------------
1514 BOOL OViewsWindow::IsDragObj() const
1516 BOOL bAction = FALSE;
1517 TSectionsMap::const_iterator aIter = m_aSections.begin();
1518 TSectionsMap::const_iterator aEnd = m_aSections.end();
1519 for (; !bAction && aIter != aEnd; ++aIter)
1520 bAction = (*aIter)->getReportSection().getSectionView().IsAction();
1521 return bAction;
1523 // -----------------------------------------------------------------------------
1524 sal_uInt32 OViewsWindow::getMarkedObjectCount() const
1526 sal_uInt32 nCount = 0;
1527 TSectionsMap::const_iterator aIter = m_aSections.begin();
1528 TSectionsMap::const_iterator aEnd = m_aSections.end();
1529 for (; aIter != aEnd; ++aIter)
1530 nCount += (*aIter)->getReportSection().getSectionView().GetMarkedObjectCount();
1531 return nCount;
1533 // -----------------------------------------------------------------------------
1534 void OViewsWindow::handleKey(const KeyCode& _rCode)
1536 const USHORT nCode = _rCode.GetCode();
1537 if ( _rCode.IsMod1() )
1539 // scroll page
1540 OScrollWindowHelper* pScrollWindow = getView()->getScrollWindow();
1541 ScrollBar* pScrollBar = ( nCode == KEY_LEFT || nCode == KEY_RIGHT ) ? pScrollWindow->GetHScroll() : pScrollWindow->GetVScroll();
1542 if ( pScrollBar && pScrollBar->IsVisible() )
1543 pScrollBar->DoScrollAction(( nCode == KEY_RIGHT || nCode == KEY_UP ) ? SCROLL_LINEUP : SCROLL_LINEDOWN );
1544 return;
1546 TSectionsMap::const_iterator aIter = m_aSections.begin();
1547 TSectionsMap::const_iterator aEnd = m_aSections.end();
1548 for (; aIter != aEnd; ++aIter)
1550 OReportSection& rReportSection = (*aIter)->getReportSection();
1551 long nX = 0;
1552 long nY = 0;
1554 if ( nCode == KEY_UP )
1555 nY = -1;
1556 else if ( nCode == KEY_DOWN )
1557 nY = 1;
1558 else if ( nCode == KEY_LEFT )
1559 nX = -1;
1560 else if ( nCode == KEY_RIGHT )
1561 nX = 1;
1563 if ( rReportSection.getSectionView().AreObjectsMarked() )
1565 if ( _rCode.IsMod2() )
1567 // move in 1 pixel distance
1568 const Size aPixelSize = rReportSection.PixelToLogic( Size( 1, 1 ) );
1569 nX *= aPixelSize.Width();
1570 nY *= aPixelSize.Height();
1572 else
1574 // move in 1 mm distance
1575 nX *= DEFAUL_MOVE_SIZE;
1576 nY *= DEFAUL_MOVE_SIZE;
1579 OSectionView& rView = rReportSection.getSectionView();
1580 const SdrHdlList& rHdlList = rView.GetHdlList();
1581 SdrHdl* pHdl = rHdlList.GetFocusHdl();
1583 if ( pHdl == 0 )
1585 // no handle selected
1586 if ( rView.IsMoveAllowed() )
1588 // restrict movement to work area
1589 Rectangle rWorkArea = rView.GetWorkArea();
1591 if ( !rWorkArea.IsEmpty() )
1593 if ( rWorkArea.Top() < 0 )
1594 rWorkArea.Top() = 0;
1595 Rectangle aMarkRect( rView.GetMarkedObjRect() );
1596 aMarkRect.Move( nX, nY );
1598 if ( !rWorkArea.IsInside( aMarkRect ) )
1600 if ( aMarkRect.Left() < rWorkArea.Left() )
1601 nX += rWorkArea.Left() - aMarkRect.Left();
1603 if ( aMarkRect.Right() > rWorkArea.Right() )
1604 nX -= aMarkRect.Right() - rWorkArea.Right();
1606 if ( aMarkRect.Top() < rWorkArea.Top() )
1607 nY += rWorkArea.Top() - aMarkRect.Top();
1609 if ( aMarkRect.Bottom() > rWorkArea.Bottom() )
1610 nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
1612 bool bCheck = false;
1613 const SdrMarkList& rMarkList = rView.GetMarkedObjectList();
1614 for (sal_uInt32 i = 0; !bCheck && i < rMarkList.GetMarkCount();++i )
1616 SdrMark* pMark = rMarkList.GetMark(i);
1617 bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL;
1620 if ( bCheck && isOver(aMarkRect,*rReportSection.getPage(),rView) )
1621 break;
1624 if ( nX != 0 || nY != 0 )
1626 rView.MoveAllMarked( Size( nX, nY ) );
1627 rView.MakeVisible( rView.GetAllMarkedRect(), rReportSection);
1631 else
1633 // move the handle
1634 if ( pHdl && ( nX || nY ) )
1636 const Point aStartPoint( pHdl->GetPos() );
1637 const Point aEndPoint( pHdl->GetPos() + Point( nX, nY ) );
1638 const SdrDragStat& rDragStat = rView.GetDragStat();
1640 // start dragging
1641 rView.BegDragObj( aStartPoint, 0, pHdl, 0 );
1643 if ( rView.IsDragObj() )
1645 const FASTBOOL bWasNoSnap = rDragStat.IsNoSnap();
1646 const BOOL bWasSnapEnabled = rView.IsSnapEnabled();
1648 // switch snapping off
1649 if ( !bWasNoSnap )
1650 ((SdrDragStat&)rDragStat).SetNoSnap( TRUE );
1651 if ( bWasSnapEnabled )
1652 rView.SetSnapEnabled( FALSE );
1654 Rectangle aNewRect;
1655 bool bCheck = false;
1656 const SdrMarkList& rMarkList = rView.GetMarkedObjectList();
1657 for (sal_uInt32 i = 0; !bCheck && i < rMarkList.GetMarkCount();++i )
1659 SdrMark* pMark = rMarkList.GetMark(i);
1660 bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL;
1661 if ( bCheck )
1662 aNewRect.Union(pMark->GetMarkedSdrObj()->GetLastBoundRect());
1665 switch(pHdl->GetKind())
1667 case HDL_LEFT:
1668 case HDL_UPLFT:
1669 case HDL_LWLFT:
1670 case HDL_UPPER:
1671 aNewRect.Left() += nX;
1672 aNewRect.Top() += nY;
1673 break;
1674 case HDL_UPRGT:
1675 case HDL_RIGHT:
1676 case HDL_LWRGT:
1677 case HDL_LOWER:
1678 aNewRect.setWidth(aNewRect.getWidth() + nX);
1679 aNewRect.setHeight(aNewRect.getHeight() + nY);
1680 break;
1681 default:
1682 break;
1684 if ( !(bCheck && isOver(aNewRect,*rReportSection.getPage(),rView)) )
1685 rView.MovAction(aEndPoint);
1686 rView.EndDragObj();
1688 // restore snap
1689 if ( !bWasNoSnap )
1690 ((SdrDragStat&)rDragStat).SetNoSnap( bWasNoSnap );
1691 if ( bWasSnapEnabled )
1692 rView.SetSnapEnabled( bWasSnapEnabled );
1695 // make moved handle visible
1696 const Rectangle aVisRect( aEndPoint - Point( DEFAUL_MOVE_SIZE, DEFAUL_MOVE_SIZE ), Size( 200, 200 ) );
1697 rView.MakeVisible( aVisRect, rReportSection);
1700 rView.AdjustMarkHdl();
1704 // -----------------------------------------------------------------------------
1705 void OViewsWindow::stopScrollTimer()
1707 ::std::for_each(m_aSections.begin(),m_aSections.end(),
1708 ::std::compose1(::boost::mem_fn(&OReportSection::stopScrollTimer),TReportPairHelper()));
1710 // -----------------------------------------------------------------------------
1711 void OViewsWindow::fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const
1713 TSectionsMap::const_iterator aIter = m_aSections.begin();
1714 TSectionsMap::const_iterator aEnd = m_aSections.end();
1715 for (sal_uInt16 i = 0;aIter != aEnd ; ++aIter,++i)
1717 if ( (*aIter)->getStartMarker().isCollapsed() )
1718 _rCollapsedPositions.push_back(i);
1721 // -----------------------------------------------------------------------------
1722 void OViewsWindow::collapseSections(const uno::Sequence< beans::PropertyValue>& _aCollpasedSections)
1724 const beans::PropertyValue* pIter = _aCollpasedSections.getConstArray();
1725 const beans::PropertyValue* pEnd = pIter + _aCollpasedSections.getLength();
1726 for (; pIter != pEnd; ++pIter)
1728 sal_uInt16 nPos = sal_uInt16(-1);
1729 if ( (pIter->Value >>= nPos) && nPos < m_aSections.size() )
1731 m_aSections[nPos]->setCollapsed(sal_True);
1735 // -----------------------------------------------------------------------------
1736 void OViewsWindow::zoom(const Fraction& _aZoom)
1738 const MapMode& aMapMode = GetMapMode();
1740 Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH));
1741 if ( _aZoom < aMapMode.GetScaleX() )
1742 aStartWidth *= aMapMode.GetScaleX();
1743 else
1744 aStartWidth *= _aZoom;
1746 setZoomFactor(_aZoom,*this);
1748 TSectionsMap::iterator aIter = m_aSections.begin();
1749 TSectionsMap::iterator aEnd = m_aSections.end();
1750 for (;aIter != aEnd ; ++aIter)
1752 (*aIter)->zoom(_aZoom);
1753 } // for (;aIter != aEnd ; ++aIter)
1755 Resize();
1757 Size aOut = GetOutputSizePixel();
1758 aOut.Width() = aStartWidth;
1759 aOut = PixelToLogic(aOut);
1761 Rectangle aRect(PixelToLogic(Point(0,0)),aOut);
1762 Invalidate(aRect,/*INVALIDATE_NOERASE | */INVALIDATE_NOCHILDREN /*| INVALIDATE_TRANSPARENT*/);
1764 //----------------------------------------------------------------------------
1765 void OViewsWindow::scrollChildren(const Point& _aThumbPos)
1767 const Point aPos(PixelToLogic(_aThumbPos));
1769 MapMode aMapMode = GetMapMode();
1770 const Point aOld = aMapMode.GetOrigin();
1771 aMapMode.SetOrigin(m_pParent->GetMapMode().GetOrigin());
1773 const Point aPosY(m_pParent->PixelToLogic(_aThumbPos,aMapMode));
1775 aMapMode.SetOrigin( Point(aOld.X() , - aPosY.Y()));
1776 SetMapMode( aMapMode );
1777 //OWindowPositionCorrector aCorrector(this,0,-( aOld.Y() + aPosY.Y()));
1778 Scroll(0, -( aOld.Y() + aPosY.Y()),SCROLL_CHILDREN);
1779 Resize();
1780 Invalidate(INVALIDATE_NOCHILDREN|INVALIDATE_TRANSPARENT);
1783 TSectionsMap::iterator aIter = m_aSections.begin();
1784 TSectionsMap::iterator aEnd = m_aSections.end();
1785 for (;aIter != aEnd ; ++aIter)
1787 (*aIter)->scrollChildren(aPos.X());
1788 } // for (;aIter != aEnd ; ++aIter)
1790 // -----------------------------------------------------------------------------
1791 void OViewsWindow::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const
1793 TSectionsMap::const_iterator aIter = m_aSections.begin();
1794 TSectionsMap::const_iterator aEnd = m_aSections.end();
1795 for(;aIter != aEnd; ++aIter)
1797 (*aIter)->getReportSection().fillControlModelSelection(_rSelection);
1800 //==============================================================================
1801 } // rptui
1802 //==============================================================================