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