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( !bool(pRet) ) 468 pRet = (*m_aSections.begin()); 469 } 470 else 471 { 472 // if we are out of bounds return the first one 473 pRet = (*m_aSections.begin()); 474 } 475 break; 476 } 477 else if ( nsa == POST ) 478 { 479 sal_uInt32 nSize = m_aSections.size(); 480 if ((nCurrentPosition + 1) < nSize) 481 { 482 pRet = *(++aIter); 483 if( !bool(pRet) ) 484 pRet = (*(--aEnd)); 485 } 486 else 487 { 488 // if we are out of bounds return the last one 489 pRet = (*(--aEnd)); 490 } 491 break; 492 } 493 } // ( (*aIter).second->isMarked() ) 494 ++nCurrentPosition; 495 } // for (; aIter != aEnd ; ++aIter) 496 497 return pRet; 498 } 499 // ------------------------------------------------------------------------- 500 void OViewsWindow::markSection(const sal_uInt16 _nPos) 501 { 502 if ( _nPos < m_aSections.size() ) 503 m_pParent->setMarked(m_aSections[_nPos]->getReportSection().getSection(),sal_True); 504 } 505 //---------------------------------------------------------------------------- 506 sal_Bool OViewsWindow::IsPasteAllowed() const 507 { 508 TransferableDataHelper aTransferData( TransferableDataHelper::CreateFromSystemClipboard( const_cast< OViewsWindow* >( this ) ) ); 509 return aTransferData.HasFormat(OReportExchange::getDescriptorFormatId()); 510 } 511 //----------------------------------------------------------------------------- 512 void OViewsWindow::SelectAll(const sal_uInt16 _nObjectType) 513 { 514 m_bInUnmark = sal_True; 515 ::std::for_each(m_aSections.begin(),m_aSections.end(), 516 ::std::compose1(::boost::bind(::boost::mem_fn(&OReportSection::SelectAll),_1,_nObjectType),TReportPairHelper())); 517 m_bInUnmark = sal_False; 518 } 519 //----------------------------------------------------------------------------- 520 void OViewsWindow::unmarkAllObjects(OSectionView* _pSectionView) 521 { 522 if ( !m_bInUnmark ) 523 { 524 m_bInUnmark = sal_True; 525 TSectionsMap::iterator aIter = m_aSections.begin(); 526 TSectionsMap::iterator aEnd = m_aSections.end(); 527 for (; aIter != aEnd ; ++aIter) 528 { 529 if ( &(*aIter)->getReportSection().getSectionView() != _pSectionView ) 530 { 531 (*aIter)->getReportSection().deactivateOle(); 532 (*aIter)->getReportSection().getSectionView().UnmarkAllObj(); 533 } 534 } // for (; aIter != aEnd ; ++aIter) 535 m_bInUnmark = sal_False; 536 } 537 } 538 //----------------------------------------------------------------------------- 539 /* 540 ::boost::shared_ptr<OSectionWindow> OViewsWindow::getReportSection(const uno::Reference< report::XSection >& _xSection) 541 { 542 OSL_ENSURE(_xSection.is(),"Section is NULL!"); 543 ::boost::shared_ptr<OSectionWindow> pRet; 544 TSectionsMap::iterator aIter = m_aSections.begin(); 545 TSectionsMap::iterator aEnd = m_aSections.end(); 546 for (; aIter != aEnd ; ++aIter) 547 { 548 if ( (*aIter)->getReportSection().getSection() == _xSection ) 549 { 550 pRet = (*aIter); 551 break; 552 } // if ( (*aIter)->getSection() == _xSection ) 553 } // for (; aIter != aEnd ; ++aIter) 554 return pRet; 555 } 556 */ 557 // ----------------------------------------------------------------------- 558 void OViewsWindow::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32) 559 { 560 ImplInitSettings(); 561 Invalidate(); 562 } 563 // ----------------------------------------------------------------------------- 564 void OViewsWindow::MouseButtonDown( const MouseEvent& rMEvt ) 565 { 566 if ( rMEvt.IsLeft() ) 567 { 568 GrabFocus(); 569 const uno::Sequence< beans::PropertyValue> aArgs; 570 getView()->getReportView()->getController().executeChecked(SID_SELECT_REPORT,aArgs); 571 } 572 Window::MouseButtonDown(rMEvt); 573 } 574 //---------------------------------------------------------------------------- 575 void OViewsWindow::showRuler(sal_Bool _bShow) 576 { 577 ::std::for_each(m_aSections.begin(),m_aSections.end(), 578 ::std::compose1(::boost::bind(&OStartMarker::showRuler,_1,_bShow),TStartMarkerHelper())); 579 ::std::for_each(m_aSections.begin(),m_aSections.end(), 580 ::std::compose1(::boost::bind(&OStartMarker::Window::Invalidate,_1,sal_uInt16(INVALIDATE_NOERASE)),TStartMarkerHelper())); 581 } 582 //---------------------------------------------------------------------------- 583 void OViewsWindow::MouseButtonUp( const MouseEvent& rMEvt ) 584 { 585 if ( rMEvt.IsLeft() ) 586 { 587 TSectionsMap::iterator aIter = m_aSections.begin(); 588 TSectionsMap::iterator aEnd = m_aSections.end(); 589 for (;aIter != aEnd ; ++aIter) 590 { 591 if ( (*aIter)->getReportSection().getSectionView().AreObjectsMarked() ) 592 { 593 (*aIter)->getReportSection().MouseButtonUp(rMEvt); 594 break; 595 } 596 } 597 598 // remove special insert mode 599 for (aIter = m_aSections.begin();aIter != aEnd ; ++aIter) 600 { 601 (*aIter)->getReportSection().getPage()->resetSpecialMode(); 602 } 603 } 604 } 605 //------------------------------------------------------------------------------ 606 sal_Bool OViewsWindow::handleKeyEvent(const KeyEvent& _rEvent) 607 { 608 sal_Bool bRet = sal_False; 609 TSectionsMap::iterator aIter = m_aSections.begin(); 610 TSectionsMap::iterator aEnd = m_aSections.end(); 611 for (;aIter != aEnd ; ++aIter) 612 { 613 //if ( (*aIter).getReportSection().getSectionView().->AreObjectsMarked() ) 614 if ( (*aIter)->getStartMarker().isMarked() ) 615 { 616 bRet = (*aIter)->getReportSection().handleKeyEvent(_rEvent); 617 } 618 } 619 return bRet; 620 } 621 //---------------------------------------------------------------------------- 622 OViewsWindow::TSectionsMap::iterator OViewsWindow::getIteratorAtPos(sal_uInt16 _nPos) 623 { 624 TSectionsMap::iterator aRet = m_aSections.end(); 625 if ( _nPos < m_aSections.size() ) 626 aRet = m_aSections.begin() + _nPos; 627 return aRet; 628 } 629 //------------------------------------------------------------------------ 630 void OViewsWindow::setMarked(OSectionView* _pSectionView,sal_Bool _bMark) 631 { 632 OSL_ENSURE(_pSectionView != NULL,"SectionView is NULL!"); 633 if ( _pSectionView ) 634 setMarked(_pSectionView->getReportSection()->getSection(),_bMark); 635 } 636 //------------------------------------------------------------------------ 637 void OViewsWindow::setMarked(const uno::Reference< report::XSection>& _xSection,sal_Bool _bMark) 638 { 639 TSectionsMap::iterator aIter = m_aSections.begin(); 640 TSectionsMap::iterator aEnd = m_aSections.end(); 641 for (; aIter != aEnd ; ++aIter) 642 { 643 if ( (*aIter)->getReportSection().getSection() != _xSection ) 644 { 645 (*aIter)->setMarked(sal_False); 646 } 647 else if ( (*aIter)->getStartMarker().isMarked() != _bMark ) 648 { 649 (*aIter)->setMarked(_bMark); 650 } 651 } 652 } 653 //------------------------------------------------------------------------ 654 void OViewsWindow::setMarked(const uno::Sequence< uno::Reference< report::XReportComponent> >& _aShapes,sal_Bool _bMark) 655 { 656 bool bFirst = true; 657 const uno::Reference< report::XReportComponent>* pIter = _aShapes.getConstArray(); 658 const uno::Reference< report::XReportComponent>* pEnd = pIter + _aShapes.getLength(); 659 for(;pIter != pEnd;++pIter) 660 { 661 const uno::Reference< report::XSection> xSection = (*pIter)->getSection(); 662 if ( xSection.is() ) 663 { 664 if ( bFirst ) 665 { 666 bFirst = false; 667 m_pParent->setMarked(xSection,_bMark); 668 } 669 ::boost::shared_ptr<OSectionWindow> pSectionWindow = getSectionWindow(xSection); 670 if ( pSectionWindow ) 671 { 672 SvxShape* pShape = SvxShape::getImplementation( *pIter ); 673 SdrObject* pObject = pShape ? pShape->GetSdrObject() : NULL; 674 OSL_ENSURE( pObject, "OViewsWindow::setMarked: no SdrObject for the shape!" ); 675 if ( pObject ) 676 pSectionWindow->getReportSection().getSectionView().MarkObj( pObject, pSectionWindow->getReportSection().getSectionView().GetSdrPageView(), !_bMark ); 677 } 678 } 679 } 680 } 681 // ----------------------------------------------------------------------------- 682 void OViewsWindow::collectRectangles(TRectangleMap& _rSortRectangles, bool _bBoundRects) 683 { 684 TSectionsMap::iterator aIter = m_aSections.begin(); 685 TSectionsMap::iterator aEnd = m_aSections.end(); 686 for (aIter = m_aSections.begin();aIter != aEnd ; ++aIter) 687 { 688 OSectionView& rView = (*aIter)->getReportSection().getSectionView(); 689 if ( rView.AreObjectsMarked() ) 690 { 691 rView.SortMarkedObjects(); 692 const sal_uInt32 nCount = rView.GetMarkedObjectCount(); 693 for (sal_uInt32 i=0; i < nCount; ++i) 694 { 695 const SdrMark* pM = rView.GetSdrMarkByIndex(i); 696 SdrObject* pObj = pM->GetMarkedSdrObj(); 697 Rectangle aObjRect(_bBoundRects ? pObj->GetCurrentBoundRect() : pObj->GetSnapRect()); 698 _rSortRectangles.insert(TRectangleMap::value_type(aObjRect,TRectangleMap::mapped_type(pObj,&rView))); 699 } 700 } 701 } 702 } 703 // ----------------------------------------------------------------------------- 704 void OViewsWindow::collectBoundResizeRect(const TRectangleMap& _rSortRectangles,sal_Int32 _nControlModification,bool _bAlignAtSection, bool _bBoundRects,Rectangle& _rBound,Rectangle& _rResize) 705 { 706 bool bOnlyOnce = false; 707 TRectangleMap::const_iterator aRectIter = _rSortRectangles.begin(); 708 TRectangleMap::const_iterator aRectEnd = _rSortRectangles.end(); 709 for (;aRectIter != aRectEnd ; ++aRectIter) 710 { 711 Rectangle aObjRect = aRectIter->first; 712 if ( _rResize.IsEmpty() ) 713 _rResize = aObjRect; 714 switch(_nControlModification) 715 { 716 case ControlModification::WIDTH_SMALLEST: 717 if ( _rResize.getWidth() > aObjRect.getWidth() ) 718 _rResize = aObjRect; 719 break; 720 case ControlModification::HEIGHT_SMALLEST: 721 if ( _rResize.getHeight() > aObjRect.getHeight() ) 722 _rResize = aObjRect; 723 break; 724 case ControlModification::WIDTH_GREATEST: 725 if ( _rResize.getWidth() < aObjRect.getWidth() ) 726 _rResize = aObjRect; 727 break; 728 case ControlModification::HEIGHT_GREATEST: 729 if ( _rResize.getHeight() < aObjRect.getHeight() ) 730 _rResize = aObjRect; 731 break; 732 } 733 734 SdrObjTransformInfoRec aInfo; 735 const SdrObject* pObj = aRectIter->second.first; 736 pObj->TakeObjInfo(aInfo); 737 sal_Bool bHasFixed = !aInfo.bMoveAllowed || pObj->IsMoveProtect(); 738 if ( bHasFixed ) 739 _rBound.Union(aObjRect); 740 else 741 { 742 if ( _bAlignAtSection || _rSortRectangles.size() == 1 ) 743 { // einzelnes Obj an der Seite ausrichten 744 if ( ! bOnlyOnce ) 745 { 746 bOnlyOnce = true; 747 OReportSection* pReportSection = aRectIter->second.second->getReportSection(); 748 const uno::Reference< report::XSection> xSection = pReportSection->getSection(); 749 try 750 { 751 uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition(); 752 _rBound.Union(Rectangle(getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN),0, 753 getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width - getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN), 754 xSection->getHeight())); 755 } 756 catch(uno::Exception){} 757 } 758 } 759 else 760 { 761 if (_bBoundRects) 762 _rBound.Union(aRectIter->second.second->GetMarkedObjBoundRect()); 763 else 764 _rBound.Union(aRectIter->second.second->GetMarkedObjRect()); 765 } 766 } 767 } 768 } 769 // ----------------------------------------------------------------------------- 770 void OViewsWindow::alignMarkedObjects(sal_Int32 _nControlModification,bool _bAlignAtSection, bool _bBoundRects) 771 { 772 if ( _nControlModification == ControlModification::NONE ) 773 return; 774 775 Point aRefPoint; 776 RectangleLess::CompareMode eCompareMode = RectangleLess::POS_LEFT; 777 switch (_nControlModification) 778 { 779 case ControlModification::TOP : eCompareMode = RectangleLess::POS_UPPER; break; 780 case ControlModification::BOTTOM: eCompareMode = RectangleLess::POS_DOWN; break; 781 case ControlModification::LEFT : eCompareMode = RectangleLess::POS_LEFT; break; 782 case ControlModification::RIGHT : eCompareMode = RectangleLess::POS_RIGHT; break; 783 case ControlModification::CENTER_HORIZONTAL : 784 case ControlModification::CENTER_VERTICAL : 785 { 786 eCompareMode = (ControlModification::CENTER_VERTICAL == _nControlModification) ? RectangleLess::POS_CENTER_VERTICAL : RectangleLess::POS_CENTER_HORIZONTAL; 787 uno::Reference<report::XSection> xSection = (*m_aSections.begin())->getReportSection().getSection(); 788 uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition(); 789 aRefPoint = Rectangle(getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN),0, 790 getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width - getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN), 791 xSection->getHeight()).Center(); 792 } 793 break; 794 default: break; 795 } 796 RectangleLess aCompare(eCompareMode,aRefPoint); 797 TRectangleMap aSortRectangles(aCompare); 798 collectRectangles(aSortRectangles,_bBoundRects); 799 800 Rectangle aBound; 801 Rectangle aResize; 802 collectBoundResizeRect(aSortRectangles,_nControlModification,_bAlignAtSection,_bBoundRects,aBound,aResize); 803 804 bool bMove = true; 805 806 ::std::mem_fun_t<long&,Rectangle> aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Bottom); 807 ::std::mem_fun_t<long&,Rectangle> aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Top); 808 TRectangleMap::iterator aRectIter = aSortRectangles.begin(); 809 TRectangleMap::iterator aRectEnd = aSortRectangles.end(); 810 for (;aRectIter != aRectEnd ; ++aRectIter) 811 { 812 Rectangle aObjRect = aRectIter->first; 813 SdrObject* pObj = aRectIter->second.first; 814 SdrView* pView = aRectIter->second.second; 815 Point aCenter(aBound.Center()); 816 SdrObjTransformInfoRec aInfo; 817 pObj->TakeObjInfo(aInfo); 818 if (aInfo.bMoveAllowed && !pObj->IsMoveProtect()) 819 { 820 long nXMov = 0; 821 long nYMov = 0; 822 long* pValue = &nXMov; 823 switch(_nControlModification) 824 { 825 case ControlModification::TOP : 826 aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Top); 827 aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Bottom); 828 pValue = &nYMov; 829 break; 830 case ControlModification::BOTTOM: 831 // defaults are already set 832 pValue = &nYMov; 833 break; 834 case ControlModification::CENTER_VERTICAL: 835 nYMov = aCenter.Y() - aObjRect.Center().Y(); 836 pValue = &nYMov; 837 bMove = false; 838 break; 839 case ControlModification::RIGHT : 840 aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Right); 841 aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Left); 842 break; 843 case ControlModification::CENTER_HORIZONTAL: 844 nXMov = aCenter.X() - aObjRect.Center().X(); 845 bMove = false; 846 break; 847 case ControlModification::LEFT : 848 aGetFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Left); 849 aRefFun = ::std::mem_fun<long&,Rectangle>(&Rectangle::Right); 850 break; 851 default: 852 bMove = false; 853 break; 854 } 855 if ( bMove ) 856 { 857 Rectangle aTest = aObjRect; 858 aGetFun(&aTest) = aGetFun(&aBound); 859 TRectangleMap::iterator aInterSectRectIter = aSortRectangles.begin(); 860 for (; aInterSectRectIter != aRectIter; ++aInterSectRectIter) 861 { 862 if ( pView == aInterSectRectIter->second.second && (dynamic_cast<OUnoObject*>(aInterSectRectIter->second.first) || dynamic_cast<OOle2Obj*>(aInterSectRectIter->second.first))) 863 { 864 SdrObject* pPreviousObj = aInterSectRectIter->second.first; 865 Rectangle aIntersectRect = aTest.GetIntersection(_bBoundRects ? pPreviousObj->GetCurrentBoundRect() : pPreviousObj->GetSnapRect()); 866 if ( !aIntersectRect.IsEmpty() && (aIntersectRect.Left() != aIntersectRect.Right() && aIntersectRect.Top() != aIntersectRect.Bottom() ) ) 867 { 868 *pValue = aRefFun(&aIntersectRect) - aGetFun(&aObjRect); 869 break; 870 } 871 } 872 } 873 if ( aInterSectRectIter == aRectIter ) 874 *pValue = aGetFun(&aBound) - aGetFun(&aObjRect); 875 } 876 877 if ( lcl_getNewRectSize(aObjRect,nXMov,nYMov,pObj,pView,_nControlModification,_bBoundRects) ) 878 { 879 const Size aSize(nXMov,nYMov); 880 pView->AddUndo(pView->GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pObj,aSize)); 881 pObj->Move(aSize); 882 aObjRect = (_bBoundRects ? pObj->GetCurrentBoundRect() : pObj->GetSnapRect()); 883 } 884 885 // resizing control 886 if ( !aResize.IsEmpty() && aObjRect != aResize ) 887 { 888 nXMov = aResize.getWidth(); 889 nYMov = aResize.getHeight(); 890 switch(_nControlModification) 891 { 892 case ControlModification::WIDTH_GREATEST: 893 case ControlModification::HEIGHT_GREATEST: 894 if ( _nControlModification == ControlModification::HEIGHT_GREATEST ) 895 nXMov = aObjRect.getWidth(); 896 else if ( _nControlModification == ControlModification::WIDTH_GREATEST ) 897 nYMov = aObjRect.getHeight(); 898 lcl_getNewRectSize(aObjRect,nXMov,nYMov,pObj,pView,_nControlModification,_bBoundRects); 899 // run through 900 case ControlModification::WIDTH_SMALLEST: 901 case ControlModification::HEIGHT_SMALLEST: 902 pView->AddUndo( pView->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); 903 { 904 OObjectBase* pObjBase = dynamic_cast<OObjectBase*>(pObj); 905 OSL_ENSURE(pObjBase,"Where comes this object from?"); 906 if ( pObjBase ) 907 { 908 if ( _nControlModification == ControlModification::WIDTH_SMALLEST || _nControlModification == ControlModification::WIDTH_GREATEST ) 909 pObjBase->getReportComponent()->setSize(awt::Size(nXMov,aObjRect.getHeight())); 910 //pObj->Resize(aObjRect.TopLeft(),Fraction(nXMov,aObjRect.getWidth()),Fraction(1,1)); 911 else if ( _nControlModification == ControlModification::HEIGHT_GREATEST || _nControlModification == ControlModification::HEIGHT_SMALLEST ) 912 pObjBase->getReportComponent()->setSize(awt::Size(aObjRect.getWidth(),nYMov)); 913 //pObj->Resize(aObjRect.TopLeft(),Fraction(1,1),Fraction(nYMov,aObjRect.getHeight())); 914 } 915 } 916 break; 917 default: 918 break; 919 } 920 } 921 } 922 pView->AdjustMarkHdl(); 923 } 924 } 925 // ----------------------------------------------------------------------------- 926 void OViewsWindow::createDefault() 927 { 928 ::boost::shared_ptr<OSectionWindow> pMarkedSection = getMarkedSection(); 929 if ( pMarkedSection ) 930 pMarkedSection->getReportSection().createDefault(m_sShapeType); 931 } 932 // ----------------------------------------------------------------------------- 933 void OViewsWindow::setGridSnap(sal_Bool bOn) 934 { 935 TSectionsMap::iterator aIter = m_aSections.begin(); 936 TSectionsMap::iterator aEnd = m_aSections.end(); 937 for (; aIter != aEnd ; ++aIter) 938 { 939 (*aIter)->getReportSection().getSectionView().SetGridSnap(bOn); 940 static sal_Int32 nIn = 0; 941 (*aIter)->getReportSection().Invalidate(nIn); 942 } 943 } 944 // ----------------------------------------------------------------------------- 945 void OViewsWindow::setDragStripes(sal_Bool bOn) 946 { 947 TSectionsMap::iterator aIter = m_aSections.begin(); 948 TSectionsMap::iterator aEnd = m_aSections.end(); 949 for (; aIter != aEnd ; ++aIter) 950 (*aIter)->getReportSection().getSectionView().SetDragStripes(bOn); 951 } 952 // ----------------------------------------------------------------------------- 953 sal_uInt16 OViewsWindow::getPosition(const OSectionWindow* _pSectionWindow) const 954 { 955 TSectionsMap::const_iterator aIter = m_aSections.begin(); 956 TSectionsMap::const_iterator aEnd = m_aSections.end(); 957 sal_uInt16 nPosition = 0; 958 for (; aIter != aEnd ; ++aIter) 959 { 960 if ( _pSectionWindow == (*aIter).get() ) 961 { 962 break; 963 } 964 ++nPosition; 965 } 966 return nPosition; 967 } 968 // ----------------------------------------------------------------------------- 969 ::boost::shared_ptr<OSectionWindow> OViewsWindow::getSectionWindow(const sal_uInt16 _nPos) const 970 { 971 ::boost::shared_ptr<OSectionWindow> aReturn; 972 973 if ( _nPos < m_aSections.size() ) 974 aReturn = m_aSections[_nPos]; 975 976 return aReturn; 977 } 978 // ----------------------------------------------------------------------------- 979 namespace 980 { 981 enum SectionViewAction 982 { 983 eEndDragObj, 984 eEndAction, 985 eMoveAction, 986 eMarkAction, 987 eForceToAnotherPage, 988 eBreakAction 989 }; 990 class ApplySectionViewAction : public ::std::unary_function< OViewsWindow::TSectionsMap::value_type, void > 991 { 992 private: 993 SectionViewAction m_eAction; 994 sal_Bool m_bCopy; 995 Point m_aPoint; 996 997 public: 998 ApplySectionViewAction( sal_Bool _bCopy ) : m_eAction( eEndDragObj ), m_bCopy( _bCopy ) { } 999 ApplySectionViewAction(SectionViewAction _eAction = eEndAction ) : m_eAction( _eAction ) { } 1000 ApplySectionViewAction( const Point& _rPoint, SectionViewAction _eAction = eMoveAction ) : m_eAction( _eAction ), m_bCopy( sal_False ), m_aPoint( _rPoint ) { } 1001 1002 void operator() ( const OViewsWindow::TSectionsMap::value_type& _rhs ) 1003 { 1004 OSectionView& rView( _rhs->getReportSection().getSectionView() ); 1005 switch ( m_eAction ) 1006 { 1007 case eEndDragObj: 1008 rView.EndDragObj( m_bCopy ); 1009 break; 1010 case eEndAction: 1011 if ( rView.IsAction() ) 1012 rView.EndAction ( ); 1013 break; 1014 case eMoveAction: 1015 rView.MovAction ( m_aPoint ); 1016 break; 1017 case eMarkAction: 1018 rView.BegMarkObj ( m_aPoint ); 1019 break; 1020 case eForceToAnotherPage: 1021 rView.ForceMarkedToAnotherPage(); 1022 break; 1023 case eBreakAction: 1024 if ( rView.IsAction() ) 1025 rView.BrkAction ( ); 1026 break; 1027 // default: 1028 1029 } 1030 } 1031 }; 1032 } 1033 // ----------------------------------------------------------------------------- 1034 void OViewsWindow::BrkAction() 1035 { 1036 EndDragObj_removeInvisibleObjects(); 1037 ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction(eBreakAction) ); 1038 } 1039 // ----------------------------------------------------------------------------- 1040 void OViewsWindow::BegDragObj_createInvisibleObjectAtPosition(const Rectangle& _aRect, const OSectionView& _rSection) 1041 { 1042 TSectionsMap::iterator aIter = m_aSections.begin(); 1043 TSectionsMap::iterator aEnd = m_aSections.end(); 1044 Point aNewPos(0,0); 1045 1046 for (; aIter != aEnd; ++aIter) 1047 { 1048 OReportSection& rReportSection = (*aIter)->getReportSection(); 1049 rReportSection.getPage()->setSpecialMode(); 1050 OSectionView& rView = rReportSection.getSectionView(); 1051 1052 if ( &rView != &_rSection ) 1053 { 1054 // SdrRectObj *pNewObj = new SdrRectObj(OBJ_RECT, _aRect); 1055 // SdrObject *pNewObj = new SdrUnoObj(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Temp Label"))); 1056 SdrObject *pNewObj = new SdrUnoObj(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText"))); 1057 if (pNewObj) 1058 { 1059 pNewObj->SetLogicRect(_aRect); 1060 // pNewObj->SetSize(_aRect.GetSize()); 1061 // pNewObj->Move(Size(_aRect.Left(), _aRect.Top())); 1062 1063 pNewObj->Move(Size(0, aNewPos.Y())); 1064 sal_Bool bChanged = rView.GetModel()->IsChanged(); 1065 rReportSection.getPage()->InsertObject(pNewObj); 1066 rView.GetModel()->SetChanged(bChanged); 1067 m_aBegDragTempList.push_back(pNewObj); 1068 Rectangle aRect = pNewObj->GetLogicRect(); 1069 1070 // pNewObj->SetText(String::CreateFromAscii("Drag helper")); 1071 rView.MarkObj( pNewObj, rView.GetSdrPageView() ); 1072 } 1073 } 1074 const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); 1075 aNewPos.Y() -= nSectionHeight; 1076 // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height(); 1077 } 1078 } 1079 // ----------------------------------------------------------------------------- 1080 bool OViewsWindow::isObjectInMyTempList(SdrObject *_pObj) 1081 { 1082 return ::std::find(m_aBegDragTempList.begin(),m_aBegDragTempList.end(),_pObj) != m_aBegDragTempList.end(); 1083 } 1084 1085 // ----------------------------------------------------------------------------- 1086 void OViewsWindow::BegDragObj(const Point& _aPnt, SdrHdl* _pHdl,const OSectionView* _pSection) 1087 { 1088 OSL_TRACE("BegDragObj Clickpoint X:%d Y:%d\n", _aPnt.X(), _aPnt.Y() ); 1089 1090 m_aBegDragTempList.clear(); 1091 1092 // Calculate the absolute clickpoint in the views 1093 Point aAbsolutePnt = _aPnt; 1094 TSectionsMap::iterator aIter = m_aSections.begin(); 1095 TSectionsMap::iterator aEnd = m_aSections.end(); 1096 for (; aIter != aEnd; ++aIter) 1097 { 1098 OReportSection& rReportSection = (*aIter)->getReportSection(); 1099 OSectionView* pView = &rReportSection.getSectionView(); 1100 if (pView == _pSection) 1101 break; 1102 const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); 1103 aAbsolutePnt.Y() += nSectionHeight; 1104 } 1105 m_aDragDelta = Point(SAL_MAX_INT32, SAL_MAX_INT32); 1106 OSL_TRACE("BegDragObj Absolute X:%d Y:%d\n", aAbsolutePnt.X(), aAbsolutePnt.Y() ); 1107 1108 // Create drag lines over all viewable Views 1109 // Therefore we need to identify the marked objects 1110 // and create temporary objects on all other views at the same position 1111 // relative to its occurance. 1112 1113 OSL_TRACE("BegDragObj createInvisible Objects\n" ); 1114 int nViewCount = 0; 1115 Point aNewObjPos(0,0); 1116 Point aLeftTop = Point(SAL_MAX_INT32, SAL_MAX_INT32); 1117 for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) 1118 { 1119 OReportSection& rReportSection = (*aIter)->getReportSection(); 1120 1121 OSectionView& rView = rReportSection.getSectionView(); 1122 1123 if ( rView.AreObjectsMarked() ) 1124 { 1125 const sal_uInt32 nCount = rView.GetMarkedObjectCount(); 1126 for (sal_uInt32 i=0; i < nCount; ++i) 1127 { 1128 const SdrMark* pM = rView.GetSdrMarkByIndex(i); 1129 SdrObject* pObj = pM->GetMarkedSdrObj(); 1130 if (!isObjectInMyTempList(pObj)) 1131 { 1132 Rectangle aRect( pObj->GetCurrentBoundRect() ); 1133 aRect.Move(0, aNewObjPos.Y()); 1134 1135 aLeftTop.X() = ::std::min( aRect.Left(), aLeftTop.X() ); 1136 aLeftTop.Y() = ::std::min( aRect.Top(), aLeftTop.Y() ); 1137 1138 OSL_TRACE("BegDragObj createInvisible X:%d Y:%d on View #%d\n", aRect.Left(), aRect.Top(), nViewCount ); 1139 1140 BegDragObj_createInvisibleObjectAtPosition(aRect, rView); 1141 1142 // calculate the clickpoint 1143 // const sal_Int32 nDeltaX = abs(aRect.Left() - aAbsolutePnt.X()); 1144 // const sal_Int32 nDeltaY = abs(aRect.Top() - aAbsolutePnt.Y()); 1145 // if (m_aDragDelta.X() > nDeltaX) 1146 // m_aDragDelta.X() = nDeltaX; 1147 // if (m_aDragDelta.Y() > nDeltaY) 1148 // m_aDragDelta.Y() = nDeltaY; 1149 } 1150 } 1151 } 1152 ++nViewCount; 1153 Rectangle aClipRect = rView.GetWorkArea(); 1154 aClipRect.Top() = -aNewObjPos.Y(); 1155 rView.SetWorkArea( aClipRect ); 1156 1157 const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); 1158 aNewObjPos.Y() += nSectionHeight; 1159 1160 // don't subtract the height of the lines between the views 1161 // aNewObjPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height(); 1162 } 1163 1164 const sal_Int32 nDeltaX = abs(aLeftTop.X() - aAbsolutePnt.X()); 1165 const sal_Int32 nDeltaY = abs(aLeftTop.Y() - aAbsolutePnt.Y()); 1166 m_aDragDelta.X() = nDeltaX; 1167 m_aDragDelta.Y() = nDeltaY; 1168 1169 Point aNewPos = aAbsolutePnt; 1170 // for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) 1171 // { 1172 // OReportSection& rReportSection = (*aIter)->getReportSection(); 1173 // if ( &rReportSection.getSectionView() == _pSection ) 1174 // break; 1175 // aNewPos.Y() += rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); 1176 // } 1177 1178 const short nDrgLog = static_cast<short>(PixelToLogic(Size(3,0)).Width()); 1179 // long nLastSectionHeight = 0; 1180 // bool bAdd = true; 1181 nViewCount = 0; 1182 for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) 1183 { 1184 OReportSection& rReportSection = (*aIter)->getReportSection(); 1185 1186 // if ( &rReportSection.getSectionView() == _pSection ) 1187 // { 1188 // bAdd = false; 1189 // aNewPos = _aPnt; 1190 // } 1191 // else if ( bAdd ) 1192 // { 1193 // const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); 1194 // aNewPos.Y() += nSectionHeight; 1195 // } 1196 // else 1197 // { 1198 // aNewPos.Y() -= nLastSectionHeight; 1199 // } 1200 1201 //? 1202 SdrHdl* pHdl = _pHdl; 1203 if ( pHdl ) 1204 { 1205 if ( &rReportSection.getSectionView() != _pSection ) 1206 { 1207 const SdrHdlList& rHdlList = rReportSection.getSectionView().GetHdlList(); 1208 pHdl = rHdlList.GetHdl(_pHdl->GetKind()); 1209 } 1210 } 1211 OSL_TRACE("BegDragObj X:%d Y:%d on View#%d\n", aNewPos.X(), aNewPos.Y(), nViewCount++ ); 1212 rReportSection.getSectionView().BegDragObj(aNewPos, (OutputDevice*)NULL, pHdl, nDrgLog, NULL); 1213 1214 const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); 1215 aNewPos.Y() -= nSectionHeight; 1216 // subtract the height between the views, because they are visible but not from interest here. 1217 // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height(); 1218 } 1219 } 1220 1221 // ----------------------------------------------------------------------------- 1222 void OViewsWindow::ForceMarkedToAnotherPage() 1223 { 1224 ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction(eForceToAnotherPage ) ); 1225 } 1226 // ----------------------------------------------------------------------------- 1227 void OViewsWindow::BegMarkObj(const Point& _aPnt,const OSectionView* _pSection) 1228 { 1229 bool bAdd = true; 1230 Point aNewPos = _aPnt; 1231 1232 TSectionsMap::iterator aIter = m_aSections.begin(); 1233 TSectionsMap::iterator aEnd = m_aSections.end(); 1234 long nLastSectionHeight = 0; 1235 for (; aIter != aEnd; ++aIter) 1236 { 1237 OReportSection& rReportSection = (*aIter)->getReportSection(); 1238 if ( &rReportSection.getSectionView() == _pSection ) 1239 { 1240 bAdd = false; 1241 aNewPos = _aPnt; // 2,2 1242 } 1243 else if ( bAdd ) 1244 { 1245 const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); 1246 aNewPos.Y() += nSectionHeight; 1247 } 1248 else 1249 { 1250 aNewPos.Y() -= nLastSectionHeight; 1251 } 1252 rReportSection.getSectionView().BegMarkObj ( aNewPos ); 1253 nLastSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); 1254 1255 // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height(); 1256 } 1257 //::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction( _aPnt , eMarkAction) ); 1258 } 1259 // ----------------------------------------------------------------------------- 1260 OSectionView* OViewsWindow::getSectionRelativeToPosition(const OSectionView* _pSection,Point& _rPnt) 1261 { 1262 OSectionView* pSection = NULL; 1263 sal_Int32 nCount = 0; 1264 TSectionsMap::iterator aIter = m_aSections.begin(); 1265 const TSectionsMap::iterator aEnd = m_aSections.end(); 1266 for (; aIter != aEnd ; ++aIter,++nCount) 1267 { 1268 OReportSection& rReportSection = (*aIter)->getReportSection(); 1269 if ( &rReportSection.getSectionView() == _pSection) 1270 break; 1271 } 1272 OSL_ENSURE(aIter != aEnd,"This can never happen!"); 1273 if ( _rPnt.Y() < 0 ) 1274 { 1275 if ( nCount ) 1276 --aIter; 1277 for (; nCount && (_rPnt.Y() < 0); --nCount) 1278 { 1279 OReportSection& rReportSection = (*aIter)->getReportSection(); 1280 const sal_Int32 nHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); 1281 _rPnt.Y() += nHeight; 1282 if ( (nCount -1) > 0 && (_rPnt.Y() < 0) ) 1283 --aIter; 1284 } 1285 if ( nCount == 0 ) 1286 pSection = &(*m_aSections.begin())->getReportSection().getSectionView(); 1287 else 1288 pSection = &(*aIter)->getReportSection().getSectionView(); 1289 } 1290 else 1291 { 1292 for (; aIter != aEnd; ++aIter) 1293 { 1294 OReportSection& rReportSection = (*aIter)->getReportSection(); 1295 const long nHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); 1296 if ( (_rPnt.Y() - nHeight) < 0 ) 1297 break; 1298 _rPnt.Y() -= nHeight; 1299 } 1300 if ( aIter != aEnd ) 1301 pSection = &(*aIter)->getReportSection().getSectionView(); 1302 else 1303 pSection = &(*(aEnd-1))->getReportSection().getSectionView(); 1304 } 1305 1306 return pSection; 1307 } 1308 // ----------------------------------------------------------------------------- 1309 void OViewsWindow::EndDragObj_removeInvisibleObjects() 1310 { 1311 TSectionsMap::iterator aIter = m_aSections.begin(); 1312 TSectionsMap::iterator aEnd = m_aSections.end(); 1313 1314 for (; aIter != aEnd; ++aIter) 1315 { 1316 OReportSection& rReportSection = (*aIter)->getReportSection(); 1317 rReportSection.getPage()->resetSpecialMode(); 1318 } 1319 } 1320 // ----------------------------------------------------------------------------- 1321 void OViewsWindow::EndDragObj(sal_Bool _bControlKeyPressed, const OSectionView* _pSection,const Point& _aPnt) 1322 { 1323 const String sUndoAction = String((ModuleRes(RID_STR_UNDO_CHANGEPOSITION))); 1324 const UndoContext aUndoContext( getView()->getReportView()->getController().getUndoManager(), sUndoAction ); 1325 1326 Point aNewPos = _aPnt; 1327 OSectionView* pInSection = getSectionRelativeToPosition(_pSection, aNewPos); 1328 if (!_bControlKeyPressed && 1329 (_pSection && ( _pSection->IsDragResize() == false ) ) && /* Not in resize mode */ 1330 _pSection != pInSection) 1331 { 1332 EndDragObj_removeInvisibleObjects(); 1333 1334 // we need to manipulate the current clickpoint, we substract the old delta from BeginDrag 1335 // OSectionView* pInSection = getSectionRelativeToPosition(_pSection, aPnt); 1336 // aNewPos.X() -= m_aDragDelta.X(); 1337 // aNewPos.Y() -= m_aDragDelta.Y(); 1338 aNewPos -= m_aDragDelta; 1339 1340 uno::Sequence< beans::NamedValue > aAllreadyCopiedObjects; 1341 TSectionsMap::iterator aIter = m_aSections.begin(); 1342 const TSectionsMap::iterator aEnd = m_aSections.end(); 1343 for (; aIter != aEnd; ++aIter) 1344 { 1345 OReportSection& rReportSection = (*aIter)->getReportSection(); 1346 if ( pInSection != &rReportSection.getSectionView() ) 1347 { 1348 rReportSection.getSectionView().BrkAction(); 1349 rReportSection.Copy(aAllreadyCopiedObjects,true); 1350 } 1351 else 1352 pInSection->EndDragObj(sal_False); 1353 } // for (; aIter != aEnd; ++aIter) 1354 1355 if ( aAllreadyCopiedObjects.getLength() ) 1356 { 1357 beans::NamedValue* pIter = aAllreadyCopiedObjects.getArray(); 1358 const beans::NamedValue* pEnd = pIter + aAllreadyCopiedObjects.getLength(); 1359 try 1360 { 1361 uno::Reference<report::XReportDefinition> xReportDefinition = getView()->getReportView()->getController().getReportDefinition(); 1362 const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN); 1363 const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN); 1364 const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width; 1365 1366 if ( aNewPos.X() < nLeftMargin ) 1367 aNewPos.X() = nLeftMargin; 1368 if ( aNewPos.Y() < 0 ) 1369 aNewPos.Y() = 0; 1370 1371 Point aPrevious; 1372 for (; pIter != pEnd; ++pIter) 1373 { 1374 uno::Sequence< uno::Reference<report::XReportComponent> > aClones; 1375 pIter->Value >>= aClones; 1376 uno::Reference<report::XReportComponent>* pColIter = aClones.getArray(); 1377 const uno::Reference<report::XReportComponent>* pColEnd = pColIter + aClones.getLength(); 1378 1379 // move the cloned Components to new positions 1380 for (; pColIter != pColEnd; ++pColIter) 1381 { 1382 uno::Reference< report::XReportComponent> xRC(*pColIter); 1383 aPrevious = VCLPoint(xRC->getPosition()); 1384 awt::Size aSize = xRC->getSize(); 1385 1386 if ( aNewPos.X() < nLeftMargin ) 1387 { 1388 aNewPos.X() = nLeftMargin; 1389 } 1390 else if ( (aNewPos.X() + aSize.Width) > (nPaperWidth - nRightMargin) ) 1391 { 1392 aNewPos.X() = nPaperWidth - nRightMargin - aSize.Width; 1393 } 1394 if ( aNewPos.Y() < 0 ) 1395 { 1396 aNewPos.Y() = 0; 1397 } 1398 if ( aNewPos.X() < 0 ) 1399 { 1400 aSize.Width += aNewPos.X(); 1401 aNewPos.X()= 0; 1402 xRC->setSize(aSize); 1403 } 1404 xRC->setPosition(AWTPoint(aNewPos)); 1405 if ( (pColIter+1) != pColEnd ) 1406 { 1407 // bring aNewPos to the position of the next object 1408 uno::Reference< report::XReportComponent> xRCNext(*(pColIter + 1),uno::UNO_QUERY); 1409 Point aNextPosition = VCLPoint(xRCNext->getPosition()); 1410 aNewPos += (aNextPosition - aPrevious); 1411 } 1412 } 1413 } 1414 } 1415 catch(uno::Exception&) 1416 { 1417 } 1418 pInSection->getReportSection()->Paste(aAllreadyCopiedObjects,true); 1419 } 1420 } 1421 else 1422 { 1423 ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction( sal_False ) ); 1424 EndDragObj_removeInvisibleObjects(); 1425 } 1426 m_aDragDelta = Point(SAL_MAX_INT32, SAL_MAX_INT32); 1427 } 1428 // ----------------------------------------------------------------------------- 1429 void OViewsWindow::EndAction() 1430 { 1431 ::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction() ); 1432 } 1433 // ----------------------------------------------------------------------------- 1434 void OViewsWindow::MovAction(const Point& _aPnt,const OSectionView* _pSection,bool _bMove, bool _bControlKeySet) 1435 { 1436 (void)_bMove; 1437 1438 Point aRealMousePos = _aPnt; 1439 Point aCurrentSectionPos; 1440 OSL_TRACE("MovAction X:%d Y:%d\n", aRealMousePos.X(), aRealMousePos.Y() ); 1441 1442 Point aHdlPos; 1443 SdrHdl* pHdl = _pSection->GetDragHdl(); 1444 if ( pHdl ) 1445 { 1446 aHdlPos = pHdl->GetPos(); 1447 } 1448 1449 TSectionsMap::iterator aIter/* = m_aSections.begin() */; 1450 TSectionsMap::iterator aEnd = m_aSections.end(); 1451 1452 //if ( _bMove ) 1453 //{ 1454 for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) 1455 { 1456 OReportSection& rReportSection = (*aIter)->getReportSection(); 1457 if ( &rReportSection.getSectionView() == _pSection ) 1458 break; 1459 const long nSectionHeight = (*aIter)->PixelToLogic(rReportSection.GetOutputSizePixel()).Height(); 1460 aCurrentSectionPos.Y() += nSectionHeight; 1461 } // for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) 1462 //} 1463 aRealMousePos += aCurrentSectionPos; 1464 1465 // If control key is pressed the work area is limited to the section with the current selection. 1466 Point aPosForWorkArea(0,0); 1467 for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) 1468 { 1469 OReportSection& rReportSection = (*aIter)->getReportSection(); 1470 OSectionView& rView = rReportSection.getSectionView(); 1471 const long nSectionHeight = (*aIter)->PixelToLogic((*aIter)->GetOutputSizePixel()).Height(); 1472 1473 if (_bControlKeySet) 1474 { 1475 Rectangle aClipRect = rView.GetWorkArea(); 1476 aClipRect.Top() = aCurrentSectionPos.Y() - aPosForWorkArea.Y(); 1477 // if (aClipRect.Top() < 0) aClipRect.Top() = 0; 1478 aClipRect.Bottom() = aClipRect.Top() + nSectionHeight; 1479 rView.SetWorkArea( aClipRect ); 1480 } 1481 else 1482 { 1483 Rectangle aClipRect = rView.GetWorkArea(); 1484 aClipRect.Top() = -aPosForWorkArea.Y(); 1485 rView.SetWorkArea( aClipRect ); 1486 } 1487 aPosForWorkArea.Y() += nSectionHeight; 1488 // aNewPos.Y() += PixelToLogic(aIter->second.second->GetSizePixel()).Height(); 1489 } 1490 1491 1492 for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) 1493 { 1494 OReportSection& rReportSection = (*aIter)->getReportSection(); 1495 SdrHdl* pCurrentHdl = rReportSection.getSectionView().GetDragHdl(); 1496 if ( pCurrentHdl ) 1497 { 1498 if ( aRealMousePos.Y() > 0 ) 1499 aRealMousePos = _aPnt + pCurrentHdl->GetPos() - aHdlPos; 1500 } 1501 rReportSection.getSectionView().MovAction ( aRealMousePos ); 1502 const long nSectionHeight = (*aIter)->PixelToLogic((*aIter)->GetOutputSizePixel()).Height(); 1503 aRealMousePos.Y() -= nSectionHeight; 1504 } 1505 #if 0 1506 #if OSL_DEBUG_LEVEL > 0 1507 // TEST TEST TEST TEST 1508 // Ich versuche gerade rauszubekommen, ob ich ein Object bewege oder nur resize. 1509 // TEST TEST TEST TEST 1510 1511 for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter) 1512 { 1513 OReportSection& rReportSection = (*aIter)->getReportSection(); 1514 OSectionView& rView = rReportSection.getSectionView(); 1515 if ( rView.AreObjectsMarked() ) 1516 { 1517 rView.SortMarkedObjects(); 1518 const sal_uInt32 nCount = rView.GetMarkedObjectCount(); 1519 for (sal_uInt32 i=0; i < nCount; ++i) 1520 { 1521 const SdrMark* pM = rView.GetSdrMarkByIndex(i); 1522 SdrObject* pObj = pM->GetMarkedSdrObj(); 1523 (void)pObj; 1524 1525 int dummy = 0; 1526 (void)dummy; 1527 } 1528 } 1529 1530 /* 1531 OReportSection& rReportSection = (*aIter)->getReportSection(); 1532 OSectionView& rView = rReportSection.getSectionView(); 1533 const SdrHdlList& rHdlList = rView.GetHdlList(); 1534 SdrHdl* pHdl2 = rHdlList.GetFocusHdl(); 1535 1536 if ( pHdl2 != 0 ) 1537 { 1538 SdrHdlKind eKind = pHdl->GetKind(); 1539 int dummy = 0; 1540 switch(eKind) 1541 { 1542 case HDL_UPLFT: // Oben links 1543 case HDL_UPPER: // Oben 1544 case HDL_UPRGT: // Oben rechts 1545 case HDL_LEFT: // Links 1546 case HDL_RIGHT: // Rechts 1547 case HDL_LWLFT: // Unten links 1548 case HDL_LOWER: // Unten 1549 case HDL_LWRGT: // Unten rechts 1550 dummy = 1; 1551 break; 1552 default: 1553 dummy = 0; 1554 } 1555 } 1556 */ 1557 } 1558 // TEST TEST TEST TEST 1559 #endif 1560 #endif 1561 } 1562 // ----------------------------------------------------------------------------- 1563 sal_Bool OViewsWindow::IsAction() const 1564 { 1565 sal_Bool bAction = sal_False; 1566 TSectionsMap::const_iterator aIter = m_aSections.begin(); 1567 TSectionsMap::const_iterator aEnd = m_aSections.end(); 1568 for (; !bAction && aIter != aEnd; ++aIter) 1569 bAction = (*aIter)->getReportSection().getSectionView().IsAction(); 1570 return bAction; 1571 } 1572 // ----------------------------------------------------------------------------- 1573 sal_Bool OViewsWindow::IsDragObj() const 1574 { 1575 sal_Bool bAction = sal_False; 1576 TSectionsMap::const_iterator aIter = m_aSections.begin(); 1577 TSectionsMap::const_iterator aEnd = m_aSections.end(); 1578 for (; !bAction && aIter != aEnd; ++aIter) 1579 bAction = (*aIter)->getReportSection().getSectionView().IsAction(); 1580 return bAction; 1581 } 1582 // ----------------------------------------------------------------------------- 1583 sal_uInt32 OViewsWindow::getMarkedObjectCount() const 1584 { 1585 sal_uInt32 nCount = 0; 1586 TSectionsMap::const_iterator aIter = m_aSections.begin(); 1587 TSectionsMap::const_iterator aEnd = m_aSections.end(); 1588 for (; aIter != aEnd; ++aIter) 1589 nCount += (*aIter)->getReportSection().getSectionView().GetMarkedObjectCount(); 1590 return nCount; 1591 } 1592 // ----------------------------------------------------------------------------- 1593 void OViewsWindow::handleKey(const KeyCode& _rCode) 1594 { 1595 const sal_uInt16 nCode = _rCode.GetCode(); 1596 if ( _rCode.IsMod1() ) 1597 { 1598 // scroll page 1599 OScrollWindowHelper* pScrollWindow = getView()->getScrollWindow(); 1600 ScrollBar* pScrollBar = ( nCode == KEY_LEFT || nCode == KEY_RIGHT ) ? pScrollWindow->GetHScroll() : pScrollWindow->GetVScroll(); 1601 if ( pScrollBar && pScrollBar->IsVisible() ) 1602 pScrollBar->DoScrollAction(( nCode == KEY_RIGHT || nCode == KEY_UP ) ? SCROLL_LINEUP : SCROLL_LINEDOWN ); 1603 return; 1604 } 1605 TSectionsMap::const_iterator aIter = m_aSections.begin(); 1606 TSectionsMap::const_iterator aEnd = m_aSections.end(); 1607 for (; aIter != aEnd; ++aIter) 1608 { 1609 OReportSection& rReportSection = (*aIter)->getReportSection(); 1610 long nX = 0; 1611 long nY = 0; 1612 1613 if ( nCode == KEY_UP ) 1614 nY = -1; 1615 else if ( nCode == KEY_DOWN ) 1616 nY = 1; 1617 else if ( nCode == KEY_LEFT ) 1618 nX = -1; 1619 else if ( nCode == KEY_RIGHT ) 1620 nX = 1; 1621 1622 if ( rReportSection.getSectionView().AreObjectsMarked() ) 1623 { 1624 if ( _rCode.IsMod2() ) 1625 { 1626 // move in 1 pixel distance 1627 const Size aPixelSize = rReportSection.PixelToLogic( Size( 1, 1 ) ); 1628 nX *= aPixelSize.Width(); 1629 nY *= aPixelSize.Height(); 1630 } 1631 else 1632 { 1633 // move in 1 mm distance 1634 nX *= DEFAUL_MOVE_SIZE; 1635 nY *= DEFAUL_MOVE_SIZE; 1636 } 1637 1638 OSectionView& rView = rReportSection.getSectionView(); 1639 const SdrHdlList& rHdlList = rView.GetHdlList(); 1640 SdrHdl* pHdl = rHdlList.GetFocusHdl(); 1641 1642 if ( pHdl == 0 ) 1643 { 1644 // no handle selected 1645 if ( rView.IsMoveAllowed() ) 1646 { 1647 // restrict movement to work area 1648 Rectangle rWorkArea = rView.GetWorkArea(); 1649 rWorkArea.Right()++; 1650 1651 if ( !rWorkArea.IsEmpty() ) 1652 { 1653 if ( rWorkArea.Top() < 0 ) 1654 rWorkArea.Top() = 0; 1655 Rectangle aMarkRect( rView.GetMarkedObjRect() ); 1656 aMarkRect.Move( nX, nY ); 1657 1658 if ( !rWorkArea.IsInside( aMarkRect ) ) 1659 { 1660 if ( aMarkRect.Left() < rWorkArea.Left() ) 1661 nX += rWorkArea.Left() - aMarkRect.Left(); 1662 1663 if ( aMarkRect.Right() > rWorkArea.Right() ) 1664 nX -= aMarkRect.Right() - rWorkArea.Right(); 1665 1666 if ( aMarkRect.Top() < rWorkArea.Top() ) 1667 nY += rWorkArea.Top() - aMarkRect.Top(); 1668 1669 if ( aMarkRect.Bottom() > rWorkArea.Bottom() ) 1670 nY -= aMarkRect.Bottom() - rWorkArea.Bottom(); 1671 } 1672 bool bCheck = false; 1673 const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); 1674 for (sal_uInt32 i = 0; !bCheck && i < rMarkList.GetMarkCount();++i ) 1675 { 1676 SdrMark* pMark = rMarkList.GetMark(i); 1677 bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL|| dynamic_cast<OOle2Obj*>(pMark->GetMarkedSdrObj()); 1678 } 1679 1680 1681 if ( bCheck ) 1682 { 1683 SdrObject* pOverlapped = isOver(aMarkRect,*rReportSection.getPage(),rView); 1684 if ( pOverlapped ) 1685 { 1686 do 1687 { 1688 Rectangle aOver = pOverlapped->GetLastBoundRect(); 1689 Point aPos; 1690 if ( nCode == KEY_UP ) 1691 { 1692 aPos.X() = aMarkRect.Left(); 1693 aPos.Y() = aOver.Top() - aMarkRect.getHeight(); 1694 nY += (aPos.Y() - aMarkRect.Top()); 1695 } 1696 else if ( nCode == KEY_DOWN ) 1697 { 1698 aPos.X() = aMarkRect.Left(); 1699 aPos.Y() = aOver.Bottom(); 1700 nY += (aPos.Y() - aMarkRect.Top()); 1701 } 1702 else if ( nCode == KEY_LEFT ) 1703 { 1704 aPos.X() = aOver.Left() - aMarkRect.getWidth(); 1705 aPos.Y() = aMarkRect.Top(); 1706 nX += (aPos.X() - aMarkRect.Left()); 1707 } 1708 else if ( nCode == KEY_RIGHT ) 1709 { 1710 aPos.X() = aOver.Right(); 1711 aPos.Y() = aMarkRect.Top(); 1712 nX += (aPos.X() - aMarkRect.Left()); 1713 } 1714 1715 aMarkRect.SetPos(aPos); 1716 if ( !rWorkArea.IsInside( aMarkRect ) ) 1717 { 1718 break; 1719 } 1720 pOverlapped = isOver(aMarkRect,*rReportSection.getPage(),rView); 1721 } 1722 while(pOverlapped != NULL); 1723 if (pOverlapped != NULL) 1724 break; 1725 } 1726 } 1727 } 1728 1729 if ( nX != 0 || nY != 0 ) 1730 { 1731 rView.MoveAllMarked( Size( nX, nY ) ); 1732 rView.MakeVisible( rView.GetAllMarkedRect(), rReportSection); 1733 } 1734 } 1735 } 1736 else 1737 { 1738 // move the handle 1739 if ( pHdl && ( nX || nY ) ) 1740 { 1741 const Point aStartPoint( pHdl->GetPos() ); 1742 const Point aEndPoint( pHdl->GetPos() + Point( nX, nY ) ); 1743 const SdrDragStat& rDragStat = rView.GetDragStat(); 1744 1745 // start dragging 1746 rView.BegDragObj( aStartPoint, 0, pHdl, 0 ); 1747 1748 if ( rView.IsDragObj() ) 1749 { 1750 const FASTBOOL bWasNoSnap = rDragStat.IsNoSnap(); 1751 const sal_Bool bWasSnapEnabled = rView.IsSnapEnabled(); 1752 1753 // switch snapping off 1754 if ( !bWasNoSnap ) 1755 ((SdrDragStat&)rDragStat).SetNoSnap( sal_True ); 1756 if ( bWasSnapEnabled ) 1757 rView.SetSnapEnabled( sal_False ); 1758 1759 Rectangle aNewRect; 1760 bool bCheck = false; 1761 const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); 1762 for (sal_uInt32 i = 0; !bCheck && i < rMarkList.GetMarkCount();++i ) 1763 { 1764 SdrMark* pMark = rMarkList.GetMark(i); 1765 bCheck = dynamic_cast<OUnoObject*>(pMark->GetMarkedSdrObj()) != NULL || dynamic_cast<OOle2Obj*>(pMark->GetMarkedSdrObj()) != NULL; 1766 if ( bCheck ) 1767 aNewRect.Union(pMark->GetMarkedSdrObj()->GetLastBoundRect()); 1768 } 1769 1770 switch(pHdl->GetKind()) 1771 { 1772 case HDL_LEFT: 1773 case HDL_UPLFT: 1774 case HDL_LWLFT: 1775 case HDL_UPPER: 1776 aNewRect.Left() += nX; 1777 aNewRect.Top() += nY; 1778 break; 1779 case HDL_UPRGT: 1780 case HDL_RIGHT: 1781 case HDL_LWRGT: 1782 case HDL_LOWER: 1783 aNewRect.setWidth(aNewRect.getWidth() + nX); 1784 aNewRect.setHeight(aNewRect.getHeight() + nY); 1785 break; 1786 default: 1787 break; 1788 } 1789 if ( !(bCheck && isOver(aNewRect,*rReportSection.getPage(),rView)) ) 1790 rView.MovAction(aEndPoint); 1791 rView.EndDragObj(); 1792 1793 // restore snap 1794 if ( !bWasNoSnap ) 1795 ((SdrDragStat&)rDragStat).SetNoSnap( bWasNoSnap ); 1796 if ( bWasSnapEnabled ) 1797 rView.SetSnapEnabled( bWasSnapEnabled ); 1798 } 1799 1800 // make moved handle visible 1801 const Rectangle aVisRect( aEndPoint - Point( DEFAUL_MOVE_SIZE, DEFAUL_MOVE_SIZE ), Size( 200, 200 ) ); 1802 rView.MakeVisible( aVisRect, rReportSection); 1803 } 1804 } 1805 rView.AdjustMarkHdl(); 1806 } 1807 } 1808 } 1809 // ----------------------------------------------------------------------------- 1810 void OViewsWindow::stopScrollTimer() 1811 { 1812 ::std::for_each(m_aSections.begin(),m_aSections.end(), 1813 ::std::compose1(::boost::mem_fn(&OReportSection::stopScrollTimer),TReportPairHelper())); 1814 } 1815 // ----------------------------------------------------------------------------- 1816 void OViewsWindow::fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const 1817 { 1818 TSectionsMap::const_iterator aIter = m_aSections.begin(); 1819 TSectionsMap::const_iterator aEnd = m_aSections.end(); 1820 for (sal_uInt16 i = 0;aIter != aEnd ; ++aIter,++i) 1821 { 1822 if ( (*aIter)->getStartMarker().isCollapsed() ) 1823 _rCollapsedPositions.push_back(i); 1824 } 1825 } 1826 // ----------------------------------------------------------------------------- 1827 void OViewsWindow::collapseSections(const uno::Sequence< beans::PropertyValue>& _aCollpasedSections) 1828 { 1829 const beans::PropertyValue* pIter = _aCollpasedSections.getConstArray(); 1830 const beans::PropertyValue* pEnd = pIter + _aCollpasedSections.getLength(); 1831 for (; pIter != pEnd; ++pIter) 1832 { 1833 sal_uInt16 nPos = sal_uInt16(-1); 1834 if ( (pIter->Value >>= nPos) && nPos < m_aSections.size() ) 1835 { 1836 m_aSections[nPos]->setCollapsed(sal_True); 1837 } 1838 } 1839 } 1840 // ----------------------------------------------------------------------------- 1841 void OViewsWindow::zoom(const Fraction& _aZoom) 1842 { 1843 const MapMode& aMapMode = GetMapMode(); 1844 1845 Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)); 1846 if ( _aZoom < aMapMode.GetScaleX() ) 1847 aStartWidth *= aMapMode.GetScaleX(); 1848 else 1849 aStartWidth *= _aZoom; 1850 1851 setZoomFactor(_aZoom,*this); 1852 1853 TSectionsMap::iterator aIter = m_aSections.begin(); 1854 TSectionsMap::iterator aEnd = m_aSections.end(); 1855 for (;aIter != aEnd ; ++aIter) 1856 { 1857 (*aIter)->zoom(_aZoom); 1858 } // for (;aIter != aEnd ; ++aIter) 1859 1860 Resize(); 1861 1862 Size aOut = GetOutputSizePixel(); 1863 aOut.Width() = aStartWidth; 1864 aOut = PixelToLogic(aOut); 1865 1866 Rectangle aRect(PixelToLogic(Point(0,0)),aOut); 1867 static sal_Int32 nIn = INVALIDATE_NOCHILDREN; 1868 Invalidate(aRect,nIn); 1869 } 1870 //---------------------------------------------------------------------------- 1871 void OViewsWindow::scrollChildren(const Point& _aThumbPos) 1872 { 1873 const Point aPos(PixelToLogic(_aThumbPos)); 1874 { 1875 MapMode aMapMode = GetMapMode(); 1876 const Point aOld = aMapMode.GetOrigin(); 1877 aMapMode.SetOrigin(m_pParent->GetMapMode().GetOrigin()); 1878 1879 const Point aPosY(m_pParent->PixelToLogic(_aThumbPos,aMapMode)); 1880 1881 aMapMode.SetOrigin( Point(aOld.X() , - aPosY.Y())); 1882 SetMapMode( aMapMode ); 1883 //OWindowPositionCorrector aCorrector(this,0,-( aOld.Y() + aPosY.Y())); 1884 Scroll(0, -( aOld.Y() + aPosY.Y()),SCROLL_CHILDREN); 1885 } 1886 1887 TSectionsMap::iterator aIter = m_aSections.begin(); 1888 TSectionsMap::iterator aEnd = m_aSections.end(); 1889 for (;aIter != aEnd ; ++aIter) 1890 { 1891 (*aIter)->scrollChildren(aPos.X()); 1892 } // for (;aIter != aEnd ; ++aIter) 1893 } 1894 // ----------------------------------------------------------------------------- 1895 void OViewsWindow::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const 1896 { 1897 TSectionsMap::const_iterator aIter = m_aSections.begin(); 1898 TSectionsMap::const_iterator aEnd = m_aSections.end(); 1899 for(;aIter != aEnd; ++aIter) 1900 { 1901 (*aIter)->getReportSection().fillControlModelSelection(_rSelection); 1902 } 1903 } 1904 //============================================================================== 1905 } // rptui 1906 //============================================================================== 1907