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