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