1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ViewsWindow.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "precompiled_reportdesign.hxx"
32 #include "ViewsWindow.hxx"
33 #include "ScrollHelper.hxx"
34 #include "UndoActions.hxx"
35 #include "ReportWindow.hxx"
36 #include "DesignView.hxx"
37 #include <svtools/colorcfg.hxx>
38 #include "ReportController.hxx"
39 #include "UITools.hxx"
41 #include "RptResId.hrc"
42 #include "SectionView.hxx"
43 #include "ReportSection.hxx"
44 #include "uistrings.hrc"
45 #include "rptui_slotid.hrc"
46 #include "dlgedclip.hxx"
47 #include "ColorChanger.hxx"
48 #include "RptObject.hxx"
49 #include "RptObject.hxx"
50 #include "ModuleHelper.hxx"
51 #include "EndMarker.hxx"
52 #include <svx/svdpagv.hxx>
53 #include <svx/unoshape.hxx>
54 #include <vcl/svapp.hxx>
55 #include <boost/bind.hpp>
57 #include "helpids.hrc"
58 #include <svx/svdundo.hxx>
59 #include <toolkit/helper/convert.hxx>
65 #define DEFAUL_MOVE_SIZE 100
67 using namespace ::com::sun::star
;
68 using namespace ::comphelper
;
69 // -----------------------------------------------------------------------------
70 bool lcl_getNewRectSize(const Rectangle
& _aObjRect
,long& _nXMov
, long& _nYMov
,SdrObject
* _pObj
,SdrView
* _pView
,sal_Int32 _nControlModification
, bool _bBoundRects
)
72 bool bMoveAllowed
= _nXMov
!= 0 || _nYMov
!= 0;
75 Rectangle aNewRect
= _aObjRect
;
76 SdrObject
* pOverlappedObj
= NULL
;
80 switch(_nControlModification
)
82 case ControlModification::HEIGHT_GREATEST
:
83 case ControlModification::WIDTH_GREATEST
:
84 aNewRect
.setWidth(_nXMov
);
85 aNewRect
.setHeight(_nYMov
);
88 aNewRect
.Move(_nXMov
,_nYMov
);
91 if ( dynamic_cast<OUnoObject
*>(_pObj
) )
93 pOverlappedObj
= isOver(aNewRect
,*_pObj
->GetPage(),*_pView
,true,_pObj
);
94 if ( pOverlappedObj
&& _pObj
!= pOverlappedObj
)
96 Rectangle aOverlappingRect
= (_bBoundRects
? pOverlappedObj
->GetCurrentBoundRect() : pOverlappedObj
->GetSnapRect());
97 sal_Int32 nXTemp
= _nXMov
;
98 sal_Int32 nYTemp
= _nYMov
;
99 switch(_nControlModification
)
101 case ControlModification::LEFT
:
102 nXTemp
+= aOverlappingRect
.Right() - aNewRect
.Left();
103 bMoveAllowed
= _nXMov
!= nXTemp
;
105 case ControlModification::RIGHT
:
106 nXTemp
+= aOverlappingRect
.Left() - aNewRect
.Right();
107 bMoveAllowed
= _nXMov
!= nXTemp
;
109 case ControlModification::TOP
:
110 nYTemp
+= aOverlappingRect
.Bottom() - aNewRect
.Top();
111 bMoveAllowed
= _nYMov
!= nYTemp
;
113 case ControlModification::BOTTOM
:
114 nYTemp
+= aOverlappingRect
.Top() - aNewRect
.Bottom();
115 bMoveAllowed
= _nYMov
!= nYTemp
;
117 case ControlModification::CENTER_HORIZONTAL
:
118 if ( _aObjRect
.Left() < aOverlappingRect
.Left() )
119 nXTemp
+= aOverlappingRect
.Left() - aNewRect
.Left() - aNewRect
.getWidth();
121 nXTemp
+= aOverlappingRect
.Right() - aNewRect
.Left();
122 bMoveAllowed
= _nXMov
!= nXTemp
;
124 case ControlModification::CENTER_VERTICAL
:
125 if ( _aObjRect
.Top() < aOverlappingRect
.Top() )
126 nYTemp
+= aOverlappingRect
.Top() - aNewRect
.Top() - aNewRect
.getHeight();
128 nYTemp
+= aOverlappingRect
.Bottom() - aNewRect
.Top();
129 bMoveAllowed
= _nYMov
!= nYTemp
;
131 case ControlModification::HEIGHT_GREATEST
:
132 case ControlModification::WIDTH_GREATEST
:
134 Rectangle aIntersectionRect
= aNewRect
.GetIntersection(aOverlappingRect
);
135 if ( !aIntersectionRect
.IsEmpty() )
137 if ( _nControlModification
== ControlModification::WIDTH_GREATEST
)
139 if ( aNewRect
.Left() < aIntersectionRect
.Left() )
141 aNewRect
.Right() = aIntersectionRect
.Left();
143 else if ( aNewRect
.Left() < aIntersectionRect
.Right() )
145 aNewRect
.Left() = aIntersectionRect
.Right();
148 else if ( _nControlModification
== ControlModification::HEIGHT_GREATEST
)
150 if ( aNewRect
.Top() < aIntersectionRect
.Top() )
152 aNewRect
.Bottom() = aIntersectionRect
.Top();
154 else if ( aNewRect
.Top() < aIntersectionRect
.Bottom() )
156 aNewRect
.Top() = aIntersectionRect
.Bottom();
159 nYTemp
= aNewRect
.getHeight();
160 bMoveAllowed
= _nYMov
!= nYTemp
;
161 nXTemp
= aNewRect
.getWidth();
162 bMoveAllowed
= bMoveAllowed
&& _nXMov
!= nXTemp
;
174 pOverlappedObj
= NULL
;
177 while ( pOverlappedObj
&& bMoveAllowed
);
181 // -----------------------------------------------------------------------------
183 DBG_NAME( rpt_OViewsWindow
);
184 OViewsWindow::OViewsWindow( OReportWindow
* _pReportWindow
)
185 : Window( _pReportWindow
,WB_DIALOGCONTROL
)
186 ,m_pParent(_pReportWindow
)
187 ,m_bInUnmark(sal_False
)
189 DBG_CTOR( rpt_OViewsWindow
,NULL
);
190 SetPaintTransparent(TRUE
);
191 SetUniqueId(UID_RPT_VIEWSWINDOW
);
192 SetMapMode( MapMode( MAP_100TH_MM
) );
193 StartListening(m_aColorConfig
);
196 // -----------------------------------------------------------------------------
197 OViewsWindow::~OViewsWindow()
199 EndListening(m_aColorConfig
);
202 DBG_DTOR( rpt_OViewsWindow
,NULL
);
204 // -----------------------------------------------------------------------------
205 void OViewsWindow::initialize()
209 // -----------------------------------------------------------------------------
210 void OViewsWindow::impl_resizeSectionWindow(OSectionWindow
& _rSectionWindow
,Point
& _rStartPoint
,bool _bSet
)
212 const uno::Reference
< report::XSection
> xSection
= _rSectionWindow
.getReportSection().getSection();
214 Size aSectionSize
= _rSectionWindow
.LogicToPixel( Size( 0,xSection
->getHeight() ) );
215 aSectionSize
.Width() = getView()->GetTotalWidth();
217 const sal_Int32 nMinHeight
= _rSectionWindow
.getStartMarker().getMinHeight();
218 if ( _rSectionWindow
.getStartMarker().isCollapsed() || nMinHeight
> aSectionSize
.Height() )
220 aSectionSize
.Height() = nMinHeight
;
222 const StyleSettings
& rSettings
= GetSettings().GetStyleSettings();
223 aSectionSize
.Height() += (long)(rSettings
.GetSplitSize() * (double)_rSectionWindow
.GetMapMode().GetScaleY());
226 _rSectionWindow
.SetPosSizePixel(_rStartPoint
,aSectionSize
);
228 _rStartPoint
.Y() += aSectionSize
.Height();
231 // -----------------------------------------------------------------------------
232 void OViewsWindow::resize(const OSectionWindow
& _rSectionWindow
)
236 TSectionsMap::iterator aIter
= m_aSections
.begin();
237 TSectionsMap::iterator aEnd
= m_aSections
.end();
238 for (;aIter
!= aEnd
; ++aIter
)
240 const ::boost::shared_ptr
<OSectionWindow
> pSectionWindow
= (*aIter
);
241 if ( pSectionWindow
.get() == &_rSectionWindow
)
243 aStartPoint
= pSectionWindow
->GetPosPixel();
245 } // if ( pSectionWindow.get() == &_rSectionWindow )
249 impl_resizeSectionWindow(*pSectionWindow
.get(),aStartPoint
,bSet
);
250 pSectionWindow
->Invalidate(INVALIDATE_NOERASE
| INVALIDATE_NOCHILDREN
| INVALIDATE_TRANSPARENT
);
251 pSectionWindow
->getStartMarker().Invalidate(INVALIDATE_NOERASE
| INVALIDATE_NOCHILDREN
| INVALIDATE_TRANSPARENT
);
253 } // for (;aIter != aEnd ; ++aIter,++nPos)
254 Fraction
aStartWidth(long(REPORT_STARTMARKER_WIDTH
));
255 aStartWidth
*= GetMapMode().GetScaleX();
256 Size aOut
= GetOutputSizePixel();
257 aOut
.Width() = aStartWidth
;
258 aOut
= PixelToLogic(aOut
);
259 m_pParent
->notifySizeChanged();
261 Rectangle
aRect(PixelToLogic(Point(0,0)),aOut
);
262 Invalidate(aRect
,INVALIDATE_NOERASE
| INVALIDATE_NOCHILDREN
| INVALIDATE_TRANSPARENT
);
264 //------------------------------------------------------------------------------
265 void OViewsWindow::Resize()
268 if ( !m_aSections
.empty() )
270 const Point
aOffset(m_pParent
->getThumbPos());
271 Point
aStartPoint(0,-aOffset
.Y());
272 TSectionsMap::iterator aIter
= m_aSections
.begin();
273 TSectionsMap::iterator aEnd
= m_aSections
.end();
274 for (USHORT nPos
=0;aIter
!= aEnd
; ++aIter
,++nPos
)
276 const ::boost::shared_ptr
<OSectionWindow
> pSectionWindow
= (*aIter
);
277 impl_resizeSectionWindow(*pSectionWindow
.get(),aStartPoint
,true);
278 } // for (;aIter != aEnd ; ++aIter)
281 // -----------------------------------------------------------------------------
282 void OViewsWindow::Paint( const Rectangle
& rRect
)
284 Window::Paint( rRect
);
286 Size aOut
= GetOutputSizePixel();
287 Fraction
aStartWidth(long(REPORT_STARTMARKER_WIDTH
));
288 aStartWidth
*= GetMapMode().GetScaleX();
290 aOut
.Width() -= (long)aStartWidth
;
291 aOut
= PixelToLogic(aOut
);
293 Rectangle
aRect(PixelToLogic(Point(aStartWidth
,0)),aOut
);
294 Wallpaper
aWall( m_aColorConfig
.GetColorValue(::svtools::APPBACKGROUND
).nColor
);
295 DrawWallpaper(aRect
,aWall
);
297 //------------------------------------------------------------------------------
298 void OViewsWindow::ImplInitSettings()
300 // SetBackground( Wallpaper( COL_LIGHTBLUE ));
302 SetFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );
303 SetTextFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );
305 //-----------------------------------------------------------------------------
306 void OViewsWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
308 Window::DataChanged( rDCEvt
);
310 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
311 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
317 //----------------------------------------------------------------------------
318 void OViewsWindow::addSection(const uno::Reference
< report::XSection
>& _xSection
,const ::rtl::OUString
& _sColorEntry
,USHORT _nPosition
)
320 ::boost::shared_ptr
<OSectionWindow
> pSectionWindow( new OSectionWindow(this,_xSection
,_sColorEntry
) );
321 m_aSections
.insert(getIteratorAtPos(_nPosition
) , TSectionsMap::value_type(pSectionWindow
));
322 m_pParent
->setMarked(&pSectionWindow
->getReportSection().getSectionView(),m_aSections
.size() == 1);
326 //----------------------------------------------------------------------------
327 void OViewsWindow::removeSection(USHORT _nPosition
)
329 if ( _nPosition
< m_aSections
.size() )
331 TSectionsMap::iterator aPos
= getIteratorAtPos(_nPosition
);
332 TSectionsMap::iterator aNew
= getIteratorAtPos(_nPosition
== 0 ? _nPosition
+1: _nPosition
- 1);
334 m_pParent
->getReportView()->UpdatePropertyBrowserDelayed((*aNew
)->getReportSection().getSectionView());
336 m_aSections
.erase(aPos
);
338 } // if ( _nPosition < m_aSections.size() )
340 //----------------------------------------------------------------------------
341 void OViewsWindow::showView(USHORT _nPos
,BOOL _bShow
)
343 if ( _nPos
< m_aSections
.size() )
344 m_aSections
[_nPos
]->setCollapsed(_bShow
);
346 //------------------------------------------------------------------------------
347 void OViewsWindow::toggleGrid(BOOL _bVisible
)
349 ::std::for_each(m_aSections
.begin(),m_aSections
.end(),
350 ::std::compose1(::boost::bind(&OReportSection::SetGridVisible
,_1
,_bVisible
),TReportPairHelper()));
351 ::std::for_each(m_aSections
.begin(),m_aSections
.end(),
352 ::std::compose1(::boost::bind(&OReportSection::Window::Invalidate
,_1
,INVALIDATE_NOERASE
),TReportPairHelper()));
354 //------------------------------------------------------------------------------
355 sal_Int32
OViewsWindow::getTotalHeight() const
357 sal_Int32 nHeight
= 0;
358 TSectionsMap::const_iterator aIter
= m_aSections
.begin();
359 TSectionsMap::const_iterator aEnd
= m_aSections
.end();
360 for (;aIter
!= aEnd
; ++aIter
)
362 nHeight
+= (*aIter
)->GetSizePixel().Height();
366 //----------------------------------------------------------------------------
367 USHORT
OViewsWindow::getSectionCount() const
369 return static_cast<USHORT
>(m_aSections
.size());
371 //----------------------------------------------------------------------------
372 void OViewsWindow::SetInsertObj( USHORT eObj
,const ::rtl::OUString
& _sShapeType
)
374 TSectionsMap::iterator aIter
= m_aSections
.begin();
375 TSectionsMap::iterator aEnd
= m_aSections
.end();
376 for (;aIter
!= aEnd
; ++aIter
)
377 (*aIter
)->getReportSection().getSectionView().SetCurrentObj( eObj
, ReportInventor
);
379 m_sShapeType
= _sShapeType
;
381 //----------------------------------------------------------------------------
382 rtl::OUString
OViewsWindow::GetInsertObjString() const
387 //------------------------------------------------------------------------------
388 void OViewsWindow::SetMode( DlgEdMode eNewMode
)
390 ::std::for_each(m_aSections
.begin(),m_aSections
.end(),
391 ::std::compose1(::boost::bind(&OReportSection::SetMode
,_1
,eNewMode
),TReportPairHelper()));
393 //----------------------------------------------------------------------------
394 BOOL
OViewsWindow::HasSelection()
396 TSectionsMap::iterator aIter
= m_aSections
.begin();
397 TSectionsMap::iterator aEnd
= m_aSections
.end();
398 for (;aIter
!= aEnd
&& !(*aIter
)->getReportSection().getSectionView().AreObjectsMarked(); ++aIter
)
400 return aIter
!= aEnd
;
402 //----------------------------------------------------------------------------
403 void OViewsWindow::Delete()
405 m_bInUnmark
= sal_True
;
406 ::std::for_each(m_aSections
.begin(),m_aSections
.end(),
407 ::std::compose1(::boost::mem_fn(&OReportSection::Delete
),TReportPairHelper()));
408 m_bInUnmark
= sal_False
;
410 //----------------------------------------------------------------------------
411 void OViewsWindow::Copy()
413 uno::Sequence
< beans::NamedValue
> aAllreadyCopiedObjects
;
414 ::std::for_each(m_aSections
.begin(),m_aSections
.end(),
415 ::std::compose1(::boost::bind(&OReportSection::Copy
,_1
,::boost::ref(aAllreadyCopiedObjects
)),TReportPairHelper()));
417 //TSectionsMap::iterator aIter = m_aSections.begin();
418 //TSectionsMap::iterator aEnd = m_aSections.end();
419 //for (; aIter != aEnd; ++aIter)
420 // (*aIter)->getReportSection().Copy(aAllreadyCopiedObjects);
421 OReportExchange
* pCopy
= new OReportExchange(aAllreadyCopiedObjects
);
422 uno::Reference
< datatransfer::XTransferable
> aEnsureDelete
= pCopy
;
423 pCopy
->CopyToClipboard(this);
425 //----------------------------------------------------------------------------
426 void OViewsWindow::Paste()
428 TransferableDataHelper
aTransferData(TransferableDataHelper::CreateFromSystemClipboard(this));
429 OReportExchange::TSectionElements aCopies
= OReportExchange::extractCopies(aTransferData
);
430 if ( aCopies
.getLength() > 1 )
431 ::std::for_each(m_aSections
.begin(),m_aSections
.end(),
432 ::std::compose1(::boost::bind(&OReportSection::Paste
,_1
,aCopies
,false),TReportPairHelper()));
435 ::boost::shared_ptr
<OSectionWindow
> pMarkedSection
= getMarkedSection();
436 if ( pMarkedSection
)
437 pMarkedSection
->getReportSection().Paste(aCopies
,true);
440 // ---------------------------------------------------------------------------
441 ::boost::shared_ptr
<OSectionWindow
> OViewsWindow::getSectionWindow(const uno::Reference
< report::XSection
>& _xSection
) const
443 OSL_ENSURE(_xSection
.is(),"Section is NULL!");
445 ::boost::shared_ptr
<OSectionWindow
> pSectionWindow
;
446 TSectionsMap::const_iterator aIter
= m_aSections
.begin();
447 TSectionsMap::const_iterator aEnd
= m_aSections
.end();
448 for (; aIter
!= aEnd
; ++aIter
)
450 if ((*aIter
)->getReportSection().getSection() == _xSection
)
452 pSectionWindow
= (*aIter
);
457 return pSectionWindow
;
460 //----------------------------------------------------------------------------
461 ::boost::shared_ptr
<OSectionWindow
> OViewsWindow::getMarkedSection(NearSectionAccess nsa
) const
463 ::boost::shared_ptr
<OSectionWindow
> pRet
;
464 TSectionsMap::const_iterator aIter
= m_aSections
.begin();
465 TSectionsMap::const_iterator aEnd
= m_aSections
.end();
466 sal_uInt32 nCurrentPosition
= 0;
467 for (; aIter
!= aEnd
; ++aIter
)
469 if ( (*aIter
)->getStartMarker().isMarked() )
476 else if ( nsa
== PREVIOUS
)
478 if (nCurrentPosition
> 0)
483 pRet
= (*m_aSections
.begin());
488 // if we are out of bounds return the first one
489 pRet
= (*m_aSections
.begin());
493 else if ( nsa
== POST
)
495 sal_uInt32 nSize
= m_aSections
.size();
496 if ((nCurrentPosition
+ 1) < nSize
)
506 // if we are out of bounds return the last one
511 } // ( (*aIter).second->isMarked() )
513 } // for (; aIter != aEnd ; ++aIter)
517 // -------------------------------------------------------------------------
518 void OViewsWindow::markSection(const sal_uInt16 _nPos
)
520 if ( _nPos
< m_aSections
.size() )
521 m_pParent
->setMarked(m_aSections
[_nPos
]->getReportSection().getSection(),sal_True
);
523 //----------------------------------------------------------------------------
524 BOOL
OViewsWindow::IsPasteAllowed()
526 TransferableDataHelper
aTransferData(TransferableDataHelper::CreateFromSystemClipboard(this));
527 return aTransferData
.HasFormat(OReportExchange::getDescriptorFormatId());
529 //-----------------------------------------------------------------------------
530 void OViewsWindow::SelectAll(const sal_uInt16 _nObjectType
)
532 m_bInUnmark
= sal_True
;
533 ::std::for_each(m_aSections
.begin(),m_aSections
.end(),
534 ::std::compose1(::boost::bind(::boost::mem_fn(&OReportSection::SelectAll
),_1
,_nObjectType
),TReportPairHelper()));
535 m_bInUnmark
= sal_False
;
537 //----------------------------------------------------------------------------
538 void OViewsWindow::SectionHasFocus(OReportSection
* /*_pSection*/,BOOL
/*_bHasFocus*/)
540 /* LLA!: this function does nothing!
541 TSectionsMap::iterator aIter = m_aSections.begin();
542 TSectionsMap::iterator aEnd = m_aSections.end();
543 for (USHORT i = 0 ; aIter != aEnd ; ++aIter,++i)
545 if ( (*aIter).first.get() == _pSection )
552 //-----------------------------------------------------------------------------
553 void OViewsWindow::unmarkAllObjects(OSectionView
* _pSectionView
)
557 m_bInUnmark
= sal_True
;
558 TSectionsMap::iterator aIter
= m_aSections
.begin();
559 TSectionsMap::iterator aEnd
= m_aSections
.end();
560 for (; aIter
!= aEnd
; ++aIter
)
562 if ( &(*aIter
)->getReportSection().getSectionView() != _pSectionView
)
564 (*aIter
)->getReportSection().deactivateOle();
565 (*aIter
)->getReportSection().getSectionView().UnmarkAllObj();
567 } // for (; aIter != aEnd ; ++aIter)
568 m_bInUnmark
= sal_False
;
571 //-----------------------------------------------------------------------------
573 ::boost::shared_ptr<OSectionWindow> OViewsWindow::getReportSection(const uno::Reference< report::XSection >& _xSection)
575 OSL_ENSURE(_xSection.is(),"Section is NULL!");
576 ::boost::shared_ptr<OSectionWindow> pRet;
577 TSectionsMap::iterator aIter = m_aSections.begin();
578 TSectionsMap::iterator aEnd = m_aSections.end();
579 for (; aIter != aEnd ; ++aIter)
581 if ( (*aIter)->getReportSection().getSection() == _xSection )
585 } // if ( (*aIter)->getSection() == _xSection )
586 } // for (; aIter != aEnd ; ++aIter)
590 // -----------------------------------------------------------------------
591 void OViewsWindow::Notify(SfxBroadcaster
& /*rBc*/, SfxHint
const & rHint
)
593 if (rHint
.ISA(SfxSimpleHint
)
594 && (static_cast< SfxSimpleHint
const & >(rHint
).GetId()
595 == SFX_HINT_COLORS_CHANGED
))
601 // -----------------------------------------------------------------------------
602 void OViewsWindow::MouseButtonDown( const MouseEvent
& rMEvt
)
604 if ( rMEvt
.IsLeft() )
607 const uno::Sequence
< beans::PropertyValue
> aArgs
;
608 getView()->getReportView()->getController().executeChecked(SID_SELECT_REPORT
,aArgs
);
610 Window::MouseButtonDown(rMEvt
);
612 //----------------------------------------------------------------------------
613 void OViewsWindow::showRuler(sal_Bool _bShow
)
615 ::std::for_each(m_aSections
.begin(),m_aSections
.end(),
616 ::std::compose1(::boost::bind(&OStartMarker::showRuler
,_1
,_bShow
),TStartMarkerHelper()));
617 ::std::for_each(m_aSections
.begin(),m_aSections
.end(),
618 ::std::compose1(::boost::bind(&OStartMarker::Window::Invalidate
,_1
,USHORT(INVALIDATE_NOERASE
)),TStartMarkerHelper()));
620 //----------------------------------------------------------------------------
621 void OViewsWindow::MouseButtonUp( const MouseEvent
& rMEvt
)
623 if ( rMEvt
.IsLeft() )
625 TSectionsMap::iterator aIter
= m_aSections
.begin();
626 TSectionsMap::iterator aEnd
= m_aSections
.end();
627 for (;aIter
!= aEnd
; ++aIter
)
629 if ( (*aIter
)->getReportSection().getSectionView().AreObjectsMarked() )
631 (*aIter
)->getReportSection().MouseButtonUp(rMEvt
);
636 // remove special insert mode
637 for (aIter
= m_aSections
.begin();aIter
!= aEnd
; ++aIter
)
639 (*aIter
)->getReportSection().getPage()->resetSpecialMode();
643 //------------------------------------------------------------------------------
644 sal_Bool
OViewsWindow::handleKeyEvent(const KeyEvent
& _rEvent
)
646 sal_Bool bRet
= sal_False
;
647 TSectionsMap::iterator aIter
= m_aSections
.begin();
648 TSectionsMap::iterator aEnd
= m_aSections
.end();
649 for (;aIter
!= aEnd
; ++aIter
)
651 //if ( (*aIter).getReportSection().getSectionView().->AreObjectsMarked() )
652 if ( (*aIter
)->getStartMarker().isMarked() )
654 bRet
= (*aIter
)->getReportSection().handleKeyEvent(_rEvent
);
659 //----------------------------------------------------------------------------
660 OViewsWindow::TSectionsMap::iterator
OViewsWindow::getIteratorAtPos(USHORT _nPos
)
662 TSectionsMap::iterator aRet
= m_aSections
.end();
663 if ( _nPos
< m_aSections
.size() )
664 aRet
= m_aSections
.begin() + _nPos
;
667 //------------------------------------------------------------------------
668 void OViewsWindow::setMarked(OSectionView
* _pSectionView
,sal_Bool _bMark
)
670 OSL_ENSURE(_pSectionView
!= NULL
,"SectionView is NULL!");
672 setMarked(_pSectionView
->getReportSection()->getSection(),_bMark
);
674 //------------------------------------------------------------------------
675 void OViewsWindow::setMarked(const uno::Reference
< report::XSection
>& _xSection
,sal_Bool _bMark
)
677 TSectionsMap::iterator aIter
= m_aSections
.begin();
678 TSectionsMap::iterator aEnd
= m_aSections
.end();
679 for (; aIter
!= aEnd
; ++aIter
)
681 if ( (*aIter
)->getReportSection().getSection() != _xSection
)
683 (*aIter
)->setMarked(sal_False
);
685 else if ( (*aIter
)->getStartMarker().isMarked() != _bMark
)
687 (*aIter
)->setMarked(_bMark
);
691 //------------------------------------------------------------------------
692 void OViewsWindow::setMarked(const uno::Sequence
< uno::Reference
< report::XReportComponent
> >& _aShapes
,sal_Bool _bMark
)
695 const uno::Reference
< report::XReportComponent
>* pIter
= _aShapes
.getConstArray();
696 const uno::Reference
< report::XReportComponent
>* pEnd
= pIter
+ _aShapes
.getLength();
697 for(;pIter
!= pEnd
;++pIter
)
699 const uno::Reference
< report::XSection
> xSection
= (*pIter
)->getSection();
705 m_pParent
->setMarked(xSection
,_bMark
);
707 ::boost::shared_ptr
<OSectionWindow
> pSectionWindow
= getSectionWindow(xSection
);
708 if ( pSectionWindow
)
710 SvxShape
* pShape
= SvxShape::getImplementation( *pIter
);
711 SdrObject
* pObject
= pShape
? pShape
->GetSdrObject() : NULL
;
712 OSL_ENSURE( pObject
, "OViewsWindow::setMarked: no SdrObject for the shape!" );
714 pSectionWindow
->getReportSection().getSectionView().MarkObj( pObject
, pSectionWindow
->getReportSection().getSectionView().GetSdrPageView(), !_bMark
);
719 // -----------------------------------------------------------------------------
720 void OViewsWindow::collectRectangles(TRectangleMap
& _rSortRectangles
, bool _bBoundRects
)
722 TSectionsMap::iterator aIter
= m_aSections
.begin();
723 TSectionsMap::iterator aEnd
= m_aSections
.end();
724 for (aIter
= m_aSections
.begin();aIter
!= aEnd
; ++aIter
)
726 OSectionView
& rView
= (*aIter
)->getReportSection().getSectionView();
727 if ( rView
.AreObjectsMarked() )
729 rView
.SortMarkedObjects();
730 const sal_uInt32 nCount
= rView
.GetMarkedObjectCount();
731 for (sal_uInt32 i
=0; i
< nCount
; ++i
)
733 const SdrMark
* pM
= rView
.GetSdrMarkByIndex(i
);
734 SdrObject
* pObj
= pM
->GetMarkedSdrObj();
735 Rectangle
aObjRect(_bBoundRects
? pObj
->GetCurrentBoundRect() : pObj
->GetSnapRect());
736 _rSortRectangles
.insert(TRectangleMap::value_type(aObjRect
,TRectangleMap::mapped_type(pObj
,&rView
)));
741 // -----------------------------------------------------------------------------
742 void OViewsWindow::collectBoundResizeRect(const TRectangleMap
& _rSortRectangles
,sal_Int32 _nControlModification
,bool _bAlignAtSection
, bool _bBoundRects
,Rectangle
& _rBound
,Rectangle
& _rResize
)
744 bool bOnlyOnce
= false;
745 TRectangleMap::const_iterator aRectIter
= _rSortRectangles
.begin();
746 TRectangleMap::const_iterator aRectEnd
= _rSortRectangles
.end();
747 for (;aRectIter
!= aRectEnd
; ++aRectIter
)
749 Rectangle aObjRect
= aRectIter
->first
;
750 if ( _rResize
.IsEmpty() )
752 switch(_nControlModification
)
754 case ControlModification::WIDTH_SMALLEST
:
755 if ( _rResize
.getWidth() > aObjRect
.getWidth() )
758 case ControlModification::HEIGHT_SMALLEST
:
759 if ( _rResize
.getHeight() > aObjRect
.getHeight() )
762 case ControlModification::WIDTH_GREATEST
:
763 if ( _rResize
.getWidth() < aObjRect
.getWidth() )
766 case ControlModification::HEIGHT_GREATEST
:
767 if ( _rResize
.getHeight() < aObjRect
.getHeight() )
772 SdrObjTransformInfoRec aInfo
;
773 const SdrObject
* pObj
= aRectIter
->second
.first
;
774 pObj
->TakeObjInfo(aInfo
);
775 BOOL bHasFixed
= !aInfo
.bMoveAllowed
|| pObj
->IsMoveProtect();
777 _rBound
.Union(aObjRect
);
780 if ( _bAlignAtSection
|| _rSortRectangles
.size() == 1 )
781 { // einzelnes Obj an der Seite ausrichten
785 OReportSection
* pReportSection
= aRectIter
->second
.second
->getReportSection();
786 const uno::Reference
< report::XSection
> xSection
= pReportSection
->getSection();
789 uno::Reference
<report::XReportDefinition
> xReportDefinition
= xSection
->getReportDefinition();
790 _rBound
.Union(Rectangle(getStyleProperty
<sal_Int32
>(xReportDefinition
,PROPERTY_LEFTMARGIN
),0,
791 getStyleProperty
<awt::Size
>(xReportDefinition
,PROPERTY_PAPERSIZE
).Width
- getStyleProperty
<sal_Int32
>(xReportDefinition
,PROPERTY_RIGHTMARGIN
),
792 xSection
->getHeight()));
794 catch(uno::Exception
){}
800 _rBound
.Union(aRectIter
->second
.second
->GetMarkedObjBoundRect());
802 _rBound
.Union(aRectIter
->second
.second
->GetMarkedObjRect());
807 // -----------------------------------------------------------------------------
808 void OViewsWindow::alignMarkedObjects(sal_Int32 _nControlModification
,bool _bAlignAtSection
, bool _bBoundRects
)
810 if ( _nControlModification
== ControlModification::NONE
)
814 RectangleLess::CompareMode eCompareMode
= RectangleLess::POS_LEFT
;
815 switch (_nControlModification
)
817 case ControlModification::TOP
: eCompareMode
= RectangleLess::POS_UPPER
; break;
818 case ControlModification::BOTTOM
: eCompareMode
= RectangleLess::POS_DOWN
; break;
819 case ControlModification::LEFT
: eCompareMode
= RectangleLess::POS_LEFT
; break;
820 case ControlModification::RIGHT
: eCompareMode
= RectangleLess::POS_RIGHT
; break;
821 case ControlModification::CENTER_HORIZONTAL
:
822 case ControlModification::CENTER_VERTICAL
:
824 eCompareMode
= (ControlModification::CENTER_VERTICAL
== _nControlModification
) ? RectangleLess::POS_CENTER_VERTICAL
: RectangleLess::POS_CENTER_HORIZONTAL
;
825 uno::Reference
<report::XSection
> xSection
= (*m_aSections
.begin())->getReportSection().getSection();
826 uno::Reference
<report::XReportDefinition
> xReportDefinition
= xSection
->getReportDefinition();
827 aRefPoint
= Rectangle(getStyleProperty
<sal_Int32
>(xReportDefinition
,PROPERTY_LEFTMARGIN
),0,
828 getStyleProperty
<awt::Size
>(xReportDefinition
,PROPERTY_PAPERSIZE
).Width
- getStyleProperty
<sal_Int32
>(xReportDefinition
,PROPERTY_RIGHTMARGIN
),
829 xSection
->getHeight()).Center();
834 RectangleLess
aCompare(eCompareMode
,aRefPoint
);
835 TRectangleMap
aSortRectangles(aCompare
);
836 collectRectangles(aSortRectangles
,_bBoundRects
);
840 collectBoundResizeRect(aSortRectangles
,_nControlModification
,_bAlignAtSection
,_bBoundRects
,aBound
,aResize
);
844 ::std::mem_fun_t
<long&,Rectangle
> aGetFun
= ::std::mem_fun
<long&,Rectangle
>(&Rectangle::Bottom
);
845 ::std::mem_fun_t
<long&,Rectangle
> aRefFun
= ::std::mem_fun
<long&,Rectangle
>(&Rectangle::Top
);
846 TRectangleMap::iterator aRectIter
= aSortRectangles
.begin();
847 TRectangleMap::iterator aRectEnd
= aSortRectangles
.end();
848 for (;aRectIter
!= aRectEnd
; ++aRectIter
)
850 Rectangle aObjRect
= aRectIter
->first
;
851 SdrObject
* pObj
= aRectIter
->second
.first
;
852 SdrView
* pView
= aRectIter
->second
.second
;
853 Point
aCenter(aBound
.Center());
854 SdrObjTransformInfoRec aInfo
;
855 pObj
->TakeObjInfo(aInfo
);
856 if (aInfo
.bMoveAllowed
&& !pObj
->IsMoveProtect())
860 long* pValue
= &nXMov
;
861 switch(_nControlModification
)
863 case ControlModification::TOP
:
864 aGetFun
= ::std::mem_fun
<long&,Rectangle
>(&Rectangle::Top
);
865 aRefFun
= ::std::mem_fun
<long&,Rectangle
>(&Rectangle::Bottom
);
868 case ControlModification::BOTTOM
:
869 // defaults are already set
872 case ControlModification::CENTER_VERTICAL
:
873 nYMov
= aCenter
.Y() - aObjRect
.Center().Y();
877 case ControlModification::RIGHT
:
878 aGetFun
= ::std::mem_fun
<long&,Rectangle
>(&Rectangle::Right
);
879 aRefFun
= ::std::mem_fun
<long&,Rectangle
>(&Rectangle::Left
);
881 case ControlModification::CENTER_HORIZONTAL
:
882 nXMov
= aCenter
.X() - aObjRect
.Center().X();
885 case ControlModification::LEFT
:
886 aGetFun
= ::std::mem_fun
<long&,Rectangle
>(&Rectangle::Left
);
887 aRefFun
= ::std::mem_fun
<long&,Rectangle
>(&Rectangle::Right
);
895 Rectangle aTest
= aObjRect
;
896 aGetFun(&aTest
) = aGetFun(&aBound
);
897 TRectangleMap::iterator aInterSectRectIter
= aSortRectangles
.begin();
898 for (; aInterSectRectIter
!= aRectIter
; ++aInterSectRectIter
)
900 if ( pView
== aInterSectRectIter
->second
.second
&& dynamic_cast<OUnoObject
*>(aInterSectRectIter
->second
.first
) )
902 SdrObject
* pPreviousObj
= aInterSectRectIter
->second
.first
;
903 Rectangle aIntersectRect
= aTest
.GetIntersection(_bBoundRects
? pPreviousObj
->GetCurrentBoundRect() : pPreviousObj
->GetSnapRect());
904 if ( !aIntersectRect
.IsEmpty() && (aIntersectRect
.Left() != aIntersectRect
.Right() && aIntersectRect
.Top() != aIntersectRect
.Bottom() ) )
906 *pValue
= aRefFun(&aIntersectRect
) - aGetFun(&aObjRect
);
911 if ( aInterSectRectIter
== aRectIter
)
912 *pValue
= aGetFun(&aBound
) - aGetFun(&aObjRect
);
915 if ( lcl_getNewRectSize(aObjRect
,nXMov
,nYMov
,pObj
,pView
,_nControlModification
,_bBoundRects
) )
917 const Size
aSize(nXMov
,nYMov
);
918 pView
->AddUndo(pView
->GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pObj
,aSize
));
920 aObjRect
= (_bBoundRects
? pObj
->GetCurrentBoundRect() : pObj
->GetSnapRect());
924 if ( !aResize
.IsEmpty() && aObjRect
!= aResize
)
926 nXMov
= aResize
.getWidth();
927 nYMov
= aResize
.getHeight();
928 switch(_nControlModification
)
930 case ControlModification::WIDTH_GREATEST
:
931 case ControlModification::HEIGHT_GREATEST
:
932 if ( _nControlModification
== ControlModification::HEIGHT_GREATEST
)
933 nXMov
= aObjRect
.getWidth();
934 else if ( _nControlModification
== ControlModification::WIDTH_GREATEST
)
935 nYMov
= aObjRect
.getHeight();
936 lcl_getNewRectSize(aObjRect
,nXMov
,nYMov
,pObj
,pView
,_nControlModification
,_bBoundRects
);
938 case ControlModification::WIDTH_SMALLEST
:
939 case ControlModification::HEIGHT_SMALLEST
:
940 pView
->AddUndo( pView
->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj
));
942 OObjectBase
* pObjBase
= dynamic_cast<OObjectBase
*>(pObj
);
943 OSL_ENSURE(pObjBase
,"Where comes this object from?");
946 if ( _nControlModification
== ControlModification::WIDTH_SMALLEST
|| _nControlModification
== ControlModification::WIDTH_GREATEST
)
947 pObjBase
->getReportComponent()->setSize(awt::Size(nXMov
,aObjRect
.getHeight()));
948 //pObj->Resize(aObjRect.TopLeft(),Fraction(nXMov,aObjRect.getWidth()),Fraction(1,1));
949 else if ( _nControlModification
== ControlModification::HEIGHT_GREATEST
|| _nControlModification
== ControlModification::HEIGHT_SMALLEST
)
950 pObjBase
->getReportComponent()->setSize(awt::Size(aObjRect
.getWidth(),nYMov
));
951 //pObj->Resize(aObjRect.TopLeft(),Fraction(1,1),Fraction(nYMov,aObjRect.getHeight()));
960 pView
->AdjustMarkHdl();
963 // -----------------------------------------------------------------------------
964 void OViewsWindow::createDefault()
966 ::boost::shared_ptr
<OSectionWindow
> pMarkedSection
= getMarkedSection();
967 if ( pMarkedSection
)
968 pMarkedSection
->getReportSection().createDefault(m_sShapeType
);
970 // -----------------------------------------------------------------------------
971 void OViewsWindow::setGridSnap(BOOL bOn
)
973 TSectionsMap::iterator aIter
= m_aSections
.begin();
974 TSectionsMap::iterator aEnd
= m_aSections
.end();
975 for (; aIter
!= aEnd
; ++aIter
)
977 (*aIter
)->getReportSection().getSectionView().SetGridSnap(bOn
);
978 (*aIter
)->getReportSection().Invalidate();
981 // -----------------------------------------------------------------------------
982 void OViewsWindow::setDragStripes(BOOL bOn
)
984 TSectionsMap::iterator aIter
= m_aSections
.begin();
985 TSectionsMap::iterator aEnd
= m_aSections
.end();
986 for (; aIter
!= aEnd
; ++aIter
)
987 (*aIter
)->getReportSection().getSectionView().SetDragStripes(bOn
);
989 // -----------------------------------------------------------------------------
990 BOOL
OViewsWindow::isDragStripes() const
992 return !m_aSections
.empty() && (*m_aSections
.begin())->getReportSection().getSectionView().IsDragStripes();
994 // -----------------------------------------------------------------------------
996 USHORT
OViewsWindow::getPosition(const OSectionWindow
* _pSectionWindow
) const
998 TSectionsMap::const_iterator aIter
= m_aSections
.begin();
999 TSectionsMap::const_iterator aEnd
= m_aSections
.end();
1000 USHORT nPosition
= 0;
1001 for (; aIter
!= aEnd
; ++aIter
)
1003 if ( _pSectionWindow
== (*aIter
).get() )
1011 // -----------------------------------------------------------------------------
1012 ::boost::shared_ptr
<OSectionWindow
> OViewsWindow::getSectionWindow(const USHORT _nPos
) const
1014 ::boost::shared_ptr
<OSectionWindow
> aReturn
;
1016 if ( _nPos
< m_aSections
.size() )
1017 aReturn
= m_aSections
[_nPos
];
1021 // -----------------------------------------------------------------------------
1024 enum SectionViewAction
1030 eForceToAnotherPage
,
1033 class ApplySectionViewAction
: public ::std::unary_function
< OViewsWindow::TSectionsMap::value_type
, void >
1036 SectionViewAction m_eAction
;
1041 ApplySectionViewAction( sal_Bool _bCopy
) : m_eAction( eEndDragObj
), m_bCopy( _bCopy
) { }
1042 ApplySectionViewAction(SectionViewAction _eAction
= eEndAction
) : m_eAction( _eAction
) { }
1043 ApplySectionViewAction( const Point
& _rPoint
, SectionViewAction _eAction
= eMoveAction
) : m_eAction( _eAction
), m_bCopy( sal_False
), m_aPoint( _rPoint
) { }
1045 void operator() ( const OViewsWindow::TSectionsMap::value_type
& _rhs
)
1047 OSectionView
& rView( _rhs
->getReportSection().getSectionView() );
1048 switch ( m_eAction
)
1051 rView
.EndDragObj( m_bCopy
);
1054 if ( rView
.IsAction() )
1055 rView
.EndAction ( );
1058 rView
.MovAction ( m_aPoint
);
1061 rView
.BegMarkObj ( m_aPoint
);
1063 case eForceToAnotherPage
:
1064 rView
.ForceMarkedToAnotherPage();
1067 if ( rView
.IsAction() )
1068 rView
.BrkAction ( );
1076 // -----------------------------------------------------------------------------
1077 void OViewsWindow::BrkAction()
1079 EndDragObj_removeInvisibleObjects();
1080 ::std::for_each( m_aSections
.begin(), m_aSections
.end(), ApplySectionViewAction(eBreakAction
) );
1082 // -----------------------------------------------------------------------------
1083 void OViewsWindow::BegDragObj_createInvisibleObjectAtPosition(const Rectangle
& _aRect
, const OSectionView
& _rSection
)
1085 TSectionsMap::iterator aIter
= m_aSections
.begin();
1086 TSectionsMap::iterator aEnd
= m_aSections
.end();
1089 for (; aIter
!= aEnd
; ++aIter
)
1091 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1092 rReportSection
.getPage()->setSpecialMode();
1093 OSectionView
& rView
= rReportSection
.getSectionView();
1095 if ( &rView
!= &_rSection
)
1097 // SdrRectObj *pNewObj = new SdrRectObj(OBJ_RECT, _aRect);
1098 // SdrObject *pNewObj = new SdrUnoObj(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Temp Label")));
1099 SdrObject
*pNewObj
= new SdrUnoObj(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FixedText")));
1102 pNewObj
->SetLogicRect(_aRect
);
1103 // pNewObj->SetSize(_aRect.GetSize());
1104 // pNewObj->Move(Size(_aRect.Left(), _aRect.Top()));
1106 pNewObj
->Move(Size(0, aNewPos
.Y()));
1107 BOOL bChanged
= rView
.GetModel()->IsChanged();
1108 rReportSection
.getPage()->InsertObject(pNewObj
);
1109 rView
.GetModel()->SetChanged(bChanged
);
1110 m_aBegDragTempList
.push_back(pNewObj
);
1111 Rectangle aRect
= pNewObj
->GetLogicRect();
1113 // pNewObj->SetText(String::CreateFromAscii("Drag helper"));
1114 rView
.MarkObj( pNewObj
, rView
.GetSdrPageView() );
1117 const long nSectionHeight
= rReportSection
.PixelToLogic(rReportSection
.GetOutputSizePixel()).Height();
1118 aNewPos
.Y() -= nSectionHeight
;
1119 // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1122 // -----------------------------------------------------------------------------
1123 bool OViewsWindow::isObjectInMyTempList(SdrObject
*_pObj
)
1125 return ::std::find(m_aBegDragTempList
.begin(),m_aBegDragTempList
.end(),_pObj
) != m_aBegDragTempList
.end();
1128 // -----------------------------------------------------------------------------
1129 void OViewsWindow::BegDragObj(const Point
& _aPnt
, SdrHdl
* _pHdl
,const OSectionView
* _pSection
)
1131 OSL_TRACE("BegDragObj Clickpoint X:%d Y:%d\n", _aPnt
.X(), _aPnt
.Y() );
1133 m_aBegDragTempList
.clear();
1135 // Calculate the absolute clickpoint in the views
1136 Point aAbsolutePnt
= _aPnt
;
1137 TSectionsMap::iterator aIter
= m_aSections
.begin();
1138 TSectionsMap::iterator aEnd
= m_aSections
.end();
1139 for (; aIter
!= aEnd
; ++aIter
)
1141 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1142 OSectionView
* pView
= &rReportSection
.getSectionView();
1143 if (pView
== _pSection
)
1145 const long nSectionHeight
= rReportSection
.PixelToLogic(rReportSection
.GetOutputSizePixel()).Height();
1146 aAbsolutePnt
.Y() += nSectionHeight
;
1148 m_aDragDelta
= Point(SAL_MAX_INT32
, SAL_MAX_INT32
);
1149 OSL_TRACE("BegDragObj Absolute X:%d Y:%d\n", aAbsolutePnt
.X(), aAbsolutePnt
.Y() );
1151 // Create drag lines over all viewable Views
1152 // Therefore we need to identify the marked objects
1153 // and create temporary objects on all other views at the same position
1154 // relative to its occurance.
1156 OSL_TRACE("BegDragObj createInvisible Objects\n" );
1158 Point
aNewObjPos(0,0);
1159 Point aLeftTop
= Point(SAL_MAX_INT32
, SAL_MAX_INT32
);
1160 for (aIter
= m_aSections
.begin(); aIter
!= aEnd
; ++aIter
)
1162 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1164 OSectionView
& rView
= rReportSection
.getSectionView();
1166 if ( rView
.AreObjectsMarked() )
1168 const sal_uInt32 nCount
= rView
.GetMarkedObjectCount();
1169 for (sal_uInt32 i
=0; i
< nCount
; ++i
)
1171 const SdrMark
* pM
= rView
.GetSdrMarkByIndex(i
);
1172 SdrObject
* pObj
= pM
->GetMarkedSdrObj();
1173 if (!isObjectInMyTempList(pObj
))
1175 Rectangle
aRect( pObj
->GetCurrentBoundRect() );
1176 aRect
.Move(0, aNewObjPos
.Y());
1178 aLeftTop
.X() = ::std::min( aRect
.Left(), aLeftTop
.X() );
1179 aLeftTop
.Y() = ::std::min( aRect
.Top(), aLeftTop
.Y() );
1181 OSL_TRACE("BegDragObj createInvisible X:%d Y:%d on View #%d\n", aRect
.Left(), aRect
.Top(), nViewCount
);
1183 BegDragObj_createInvisibleObjectAtPosition(aRect
, rView
);
1185 // calculate the clickpoint
1186 // const sal_Int32 nDeltaX = abs(aRect.Left() - aAbsolutePnt.X());
1187 // const sal_Int32 nDeltaY = abs(aRect.Top() - aAbsolutePnt.Y());
1188 // if (m_aDragDelta.X() > nDeltaX)
1189 // m_aDragDelta.X() = nDeltaX;
1190 // if (m_aDragDelta.Y() > nDeltaY)
1191 // m_aDragDelta.Y() = nDeltaY;
1196 Rectangle aClipRect
= rView
.GetWorkArea();
1197 aClipRect
.Top() = -aNewObjPos
.Y();
1198 rView
.SetWorkArea( aClipRect
);
1200 const long nSectionHeight
= rReportSection
.PixelToLogic(rReportSection
.GetOutputSizePixel()).Height();
1201 aNewObjPos
.Y() += nSectionHeight
;
1203 // don't subtract the height of the lines between the views
1204 // aNewObjPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1207 const sal_Int32 nDeltaX
= abs(aLeftTop
.X() - aAbsolutePnt
.X());
1208 const sal_Int32 nDeltaY
= abs(aLeftTop
.Y() - aAbsolutePnt
.Y());
1209 m_aDragDelta
.X() = nDeltaX
;
1210 m_aDragDelta
.Y() = nDeltaY
;
1212 Point aNewPos
= aAbsolutePnt
;
1213 // for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1215 // OReportSection& rReportSection = (*aIter)->getReportSection();
1216 // if ( &rReportSection.getSectionView() == _pSection )
1218 // aNewPos.Y() += rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1221 const short nDrgLog
= static_cast<short>(PixelToLogic(Size(3,0)).Width());
1222 // long nLastSectionHeight = 0;
1223 // bool bAdd = true;
1225 for (aIter
= m_aSections
.begin(); aIter
!= aEnd
; ++aIter
)
1227 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1229 // if ( &rReportSection.getSectionView() == _pSection )
1236 // const long nSectionHeight = rReportSection.PixelToLogic(rReportSection.GetOutputSizePixel()).Height();
1237 // aNewPos.Y() += nSectionHeight;
1241 // aNewPos.Y() -= nLastSectionHeight;
1245 SdrHdl
* pHdl
= _pHdl
;
1248 if ( &rReportSection
.getSectionView() != _pSection
)
1250 const SdrHdlList
& rHdlList
= rReportSection
.getSectionView().GetHdlList();
1251 pHdl
= rHdlList
.GetHdl(_pHdl
->GetKind());
1254 OSL_TRACE("BegDragObj X:%d Y:%d on View#%d\n", aNewPos
.X(), aNewPos
.Y(), nViewCount
++ );
1255 rReportSection
.getSectionView().BegDragObj(aNewPos
, (OutputDevice
*)NULL
, pHdl
, nDrgLog
, NULL
);
1257 const long nSectionHeight
= rReportSection
.PixelToLogic(rReportSection
.GetOutputSizePixel()).Height();
1258 aNewPos
.Y() -= nSectionHeight
;
1259 // subtract the height between the views, because they are visible but not from interest here.
1260 // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1264 // -----------------------------------------------------------------------------
1265 void OViewsWindow::ForceMarkedToAnotherPage()
1267 ::std::for_each( m_aSections
.begin(), m_aSections
.end(), ApplySectionViewAction(eForceToAnotherPage
) );
1269 // -----------------------------------------------------------------------------
1270 void OViewsWindow::BegMarkObj(const Point
& _aPnt
,const OSectionView
* _pSection
)
1273 Point aNewPos
= _aPnt
;
1275 TSectionsMap::iterator aIter
= m_aSections
.begin();
1276 TSectionsMap::iterator aEnd
= m_aSections
.end();
1277 long nLastSectionHeight
= 0;
1278 for (; aIter
!= aEnd
; ++aIter
)
1280 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1281 if ( &rReportSection
.getSectionView() == _pSection
)
1284 aNewPos
= _aPnt
; // 2,2
1288 const long nSectionHeight
= rReportSection
.PixelToLogic(rReportSection
.GetOutputSizePixel()).Height();
1289 aNewPos
.Y() += nSectionHeight
;
1293 aNewPos
.Y() -= nLastSectionHeight
;
1295 rReportSection
.getSectionView().BegMarkObj ( aNewPos
);
1296 nLastSectionHeight
= rReportSection
.PixelToLogic(rReportSection
.GetOutputSizePixel()).Height();
1298 // aNewPos.Y() -= PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1300 //::std::for_each( m_aSections.begin(), m_aSections.end(), ApplySectionViewAction( _aPnt , eMarkAction) );
1302 // -----------------------------------------------------------------------------
1303 OSectionView
* OViewsWindow::getSectionRelativeToPosition(const OSectionView
* _pSection
,Point
& _rPnt
)
1305 OSectionView
* pSection
= NULL
;
1306 sal_Int32 nCount
= 0;
1307 TSectionsMap::iterator aIter
= m_aSections
.begin();
1308 const TSectionsMap::iterator aEnd
= m_aSections
.end();
1309 for (; aIter
!= aEnd
; ++aIter
,++nCount
)
1311 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1312 if ( &rReportSection
.getSectionView() == _pSection
)
1315 OSL_ENSURE(aIter
!= aEnd
,"This can never happen!");
1316 if ( _rPnt
.Y() < 0 )
1320 for (; nCount
&& (_rPnt
.Y() < 0); --nCount
)
1322 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1323 const sal_Int32 nHeight
= rReportSection
.PixelToLogic(rReportSection
.GetOutputSizePixel()).Height();
1324 _rPnt
.Y() += nHeight
;
1325 if ( (nCount
-1) > 0 && (_rPnt
.Y() < 0) )
1329 pSection
= &(*m_aSections
.begin())->getReportSection().getSectionView();
1331 pSection
= &(*aIter
)->getReportSection().getSectionView();
1335 for (; aIter
!= aEnd
; ++aIter
)
1337 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1338 const long nHeight
= rReportSection
.PixelToLogic(rReportSection
.GetOutputSizePixel()).Height();
1339 if ( (_rPnt
.Y() - nHeight
) < 0 )
1341 _rPnt
.Y() -= nHeight
;
1343 if ( aIter
!= aEnd
)
1344 pSection
= &(*aIter
)->getReportSection().getSectionView();
1346 pSection
= &(*(aEnd
-1))->getReportSection().getSectionView();
1351 // -----------------------------------------------------------------------------
1352 void OViewsWindow::EndDragObj_removeInvisibleObjects()
1354 TSectionsMap::iterator aIter
= m_aSections
.begin();
1355 TSectionsMap::iterator aEnd
= m_aSections
.end();
1357 for (; aIter
!= aEnd
; ++aIter
)
1359 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1360 rReportSection
.getPage()->resetSpecialMode();
1363 // -----------------------------------------------------------------------------
1364 void OViewsWindow::EndDragObj(BOOL _bControlKeyPressed
, const OSectionView
* _pSection
,const Point
& _aPnt
)
1366 const String sUndoAction
= String((ModuleRes(RID_STR_UNDO_CHANGEPOSITION
)));
1367 UndoManagerListAction
aListAction(*getView()->getReportView()->getController().getUndoMgr(),sUndoAction
);
1369 Point aNewPos
= _aPnt
;
1370 OSectionView
* pInSection
= getSectionRelativeToPosition(_pSection
, aNewPos
);
1371 if (!_bControlKeyPressed
&&
1372 (_pSection
&& ( _pSection
->IsDragResize() == false ) ) && /* Not in resize mode */
1373 _pSection
!= pInSection
)
1375 EndDragObj_removeInvisibleObjects();
1377 // we need to manipulate the current clickpoint, we substract the old delta from BeginDrag
1378 // OSectionView* pInSection = getSectionRelativeToPosition(_pSection, aPnt);
1379 // aNewPos.X() -= m_aDragDelta.X();
1380 // aNewPos.Y() -= m_aDragDelta.Y();
1381 aNewPos
-= m_aDragDelta
;
1383 uno::Sequence
< beans::NamedValue
> aAllreadyCopiedObjects
;
1384 TSectionsMap::iterator aIter
= m_aSections
.begin();
1385 const TSectionsMap::iterator aEnd
= m_aSections
.end();
1386 for (; aIter
!= aEnd
; ++aIter
)
1388 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1389 if ( pInSection
!= &rReportSection
.getSectionView() )
1391 rReportSection
.getSectionView().BrkAction();
1392 rReportSection
.Copy(aAllreadyCopiedObjects
,true);
1395 pInSection
->EndDragObj(FALSE
);
1396 } // for (; aIter != aEnd; ++aIter)
1398 if ( aAllreadyCopiedObjects
.getLength() )
1400 beans::NamedValue
* pIter
= aAllreadyCopiedObjects
.getArray();
1401 const beans::NamedValue
* pEnd
= pIter
+ aAllreadyCopiedObjects
.getLength();
1404 uno::Reference
<report::XReportDefinition
> xReportDefinition
= getView()->getReportView()->getController().getReportDefinition();
1405 const sal_Int32 nLeftMargin
= getStyleProperty
<sal_Int32
>(xReportDefinition
,PROPERTY_LEFTMARGIN
);
1406 const sal_Int32 nRightMargin
= getStyleProperty
<sal_Int32
>(xReportDefinition
,PROPERTY_RIGHTMARGIN
);
1407 const sal_Int32 nPaperWidth
= getStyleProperty
<awt::Size
>(xReportDefinition
,PROPERTY_PAPERSIZE
).Width
;
1409 if ( aNewPos
.X() < nLeftMargin
)
1410 aNewPos
.X() = nLeftMargin
;
1411 if ( aNewPos
.Y() < 0 )
1415 for (; pIter
!= pEnd
; ++pIter
)
1417 uno::Sequence
< uno::Reference
<report::XReportComponent
> > aClones
;
1418 pIter
->Value
>>= aClones
;
1419 uno::Reference
<report::XReportComponent
>* pColIter
= aClones
.getArray();
1420 const uno::Reference
<report::XReportComponent
>* pColEnd
= pColIter
+ aClones
.getLength();
1422 // move the cloned Components to new positions
1423 for (; pColIter
!= pColEnd
; ++pColIter
)
1425 uno::Reference
< report::XReportComponent
> xRC(*pColIter
);
1426 aPrevious
= VCLPoint(xRC
->getPosition());
1427 awt::Size aSize
= xRC
->getSize();
1429 if ( aNewPos
.X() < nLeftMargin
)
1431 aNewPos
.X() = nLeftMargin
;
1433 else if ( (aNewPos
.X() + aSize
.Width
) > (nPaperWidth
- nRightMargin
) )
1435 aNewPos
.X() = nPaperWidth
- nRightMargin
- aSize
.Width
;
1437 if ( aNewPos
.Y() < 0 )
1441 if ( aNewPos
.X() < 0 )
1443 aSize
.Width
+= aNewPos
.X();
1445 xRC
->setSize(aSize
);
1447 xRC
->setPosition(AWTPoint(aNewPos
));
1448 if ( (pColIter
+1) != pColEnd
)
1450 // bring aNewPos to the position of the next object
1451 uno::Reference
< report::XReportComponent
> xRCNext(*(pColIter
+ 1),uno::UNO_QUERY
);
1452 Point aNextPosition
= VCLPoint(xRCNext
->getPosition());
1453 aNewPos
+= (aNextPosition
- aPrevious
);
1458 catch(uno::Exception
&)
1461 pInSection
->getReportSection()->Paste(aAllreadyCopiedObjects
,true);
1466 ::std::for_each( m_aSections
.begin(), m_aSections
.end(), ApplySectionViewAction( FALSE
) );
1467 EndDragObj_removeInvisibleObjects();
1469 m_aDragDelta
= Point(SAL_MAX_INT32
, SAL_MAX_INT32
);
1471 // -----------------------------------------------------------------------------
1472 void OViewsWindow::EndAction()
1474 ::std::for_each( m_aSections
.begin(), m_aSections
.end(), ApplySectionViewAction() );
1476 // -----------------------------------------------------------------------------
1477 void OViewsWindow::MovAction(const Point
& _aPnt
,const OSectionView
* _pSection
,bool _bMove
, bool _bControlKeySet
)
1481 Point aRealMousePos
= _aPnt
;
1482 Point aCurrentSectionPos
;
1483 OSL_TRACE("MovAction X:%d Y:%d\n", aRealMousePos
.X(), aRealMousePos
.Y() );
1486 SdrHdl
* pHdl
= _pSection
->GetDragHdl();
1489 aHdlPos
= pHdl
->GetPos();
1492 TSectionsMap::iterator aIter
/* = m_aSections.begin() */;
1493 TSectionsMap::iterator aEnd
= m_aSections
.end();
1497 for (aIter
= m_aSections
.begin(); aIter
!= aEnd
; ++aIter
)
1499 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1500 if ( &rReportSection
.getSectionView() == _pSection
)
1502 const long nSectionHeight
= (*aIter
)->PixelToLogic(rReportSection
.GetOutputSizePixel()).Height();
1503 aCurrentSectionPos
.Y() += nSectionHeight
;
1504 } // for (aIter = m_aSections.begin(); aIter != aEnd; ++aIter)
1506 aRealMousePos
+= aCurrentSectionPos
;
1508 // If control key is pressed the work area is limited to the section with the current selection.
1509 Point
aPosForWorkArea(0,0);
1510 for (aIter
= m_aSections
.begin(); aIter
!= aEnd
; ++aIter
)
1512 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1513 OSectionView
& rView
= rReportSection
.getSectionView();
1514 const long nSectionHeight
= (*aIter
)->PixelToLogic((*aIter
)->GetOutputSizePixel()).Height();
1516 if (_bControlKeySet
)
1518 Rectangle aClipRect
= rView
.GetWorkArea();
1519 aClipRect
.Top() = aCurrentSectionPos
.Y() - aPosForWorkArea
.Y();
1520 // if (aClipRect.Top() < 0) aClipRect.Top() = 0;
1521 aClipRect
.Bottom() = aClipRect
.Top() + nSectionHeight
;
1522 rView
.SetWorkArea( aClipRect
);
1526 Rectangle aClipRect
= rView
.GetWorkArea();
1527 aClipRect
.Top() = -aPosForWorkArea
.Y();
1528 rView
.SetWorkArea( aClipRect
);
1530 aPosForWorkArea
.Y() += nSectionHeight
;
1531 // aNewPos.Y() += PixelToLogic(aIter->second.second->GetSizePixel()).Height();
1535 for (aIter
= m_aSections
.begin(); aIter
!= aEnd
; ++aIter
)
1537 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1538 SdrHdl
* pCurrentHdl
= rReportSection
.getSectionView().GetDragHdl();
1541 if ( aRealMousePos
.Y() > 0 )
1542 aRealMousePos
= _aPnt
+ pCurrentHdl
->GetPos() - aHdlPos
;
1544 rReportSection
.getSectionView().MovAction ( aRealMousePos
);
1545 const long nSectionHeight
= (*aIter
)->PixelToLogic((*aIter
)->GetOutputSizePixel()).Height();
1546 aRealMousePos
.Y() -= nSectionHeight
;
1549 #if OSL_DEBUG_LEVEL > 0
1550 // TEST TEST TEST TEST
1551 // Ich versuche gerade rauszubekommen, ob ich ein Object bewege oder nur resize.
1552 // TEST TEST TEST TEST
1554 for (aIter
= m_aSections
.begin(); aIter
!= aEnd
; ++aIter
)
1556 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1557 OSectionView
& rView
= rReportSection
.getSectionView();
1558 if ( rView
.AreObjectsMarked() )
1560 rView
.SortMarkedObjects();
1561 const sal_uInt32 nCount
= rView
.GetMarkedObjectCount();
1562 for (sal_uInt32 i
=0; i
< nCount
; ++i
)
1564 const SdrMark
* pM
= rView
.GetSdrMarkByIndex(i
);
1565 SdrObject
* pObj
= pM
->GetMarkedSdrObj();
1574 OReportSection& rReportSection = (*aIter)->getReportSection();
1575 OSectionView& rView = rReportSection.getSectionView();
1576 const SdrHdlList& rHdlList = rView.GetHdlList();
1577 SdrHdl* pHdl2 = rHdlList.GetFocusHdl();
1581 SdrHdlKind eKind = pHdl->GetKind();
1585 case HDL_UPLFT: // Oben links
1586 case HDL_UPPER: // Oben
1587 case HDL_UPRGT: // Oben rechts
1588 case HDL_LEFT: // Links
1589 case HDL_RIGHT: // Rechts
1590 case HDL_LWLFT: // Unten links
1591 case HDL_LOWER: // Unten
1592 case HDL_LWRGT: // Unten rechts
1601 // TEST TEST TEST TEST
1605 // -----------------------------------------------------------------------------
1606 BOOL
OViewsWindow::IsAction() const
1608 BOOL bAction
= FALSE
;
1609 TSectionsMap::const_iterator aIter
= m_aSections
.begin();
1610 TSectionsMap::const_iterator aEnd
= m_aSections
.end();
1611 for (; !bAction
&& aIter
!= aEnd
; ++aIter
)
1612 bAction
= (*aIter
)->getReportSection().getSectionView().IsAction();
1615 // -----------------------------------------------------------------------------
1616 BOOL
OViewsWindow::IsDragObj() const
1618 BOOL bAction
= FALSE
;
1619 TSectionsMap::const_iterator aIter
= m_aSections
.begin();
1620 TSectionsMap::const_iterator aEnd
= m_aSections
.end();
1621 for (; !bAction
&& aIter
!= aEnd
; ++aIter
)
1622 bAction
= (*aIter
)->getReportSection().getSectionView().IsAction();
1625 // -----------------------------------------------------------------------------
1626 sal_uInt32
OViewsWindow::getMarkedObjectCount() const
1628 sal_uInt32 nCount
= 0;
1629 TSectionsMap::const_iterator aIter
= m_aSections
.begin();
1630 TSectionsMap::const_iterator aEnd
= m_aSections
.end();
1631 for (; aIter
!= aEnd
; ++aIter
)
1632 nCount
+= (*aIter
)->getReportSection().getSectionView().GetMarkedObjectCount();
1635 // -----------------------------------------------------------------------------
1636 void OViewsWindow::handleKey(const KeyCode
& _rCode
)
1638 const USHORT nCode
= _rCode
.GetCode();
1639 if ( _rCode
.IsMod1() )
1642 OScrollWindowHelper
* pScrollWindow
= getView()->getScrollWindow();
1643 ScrollBar
* pScrollBar
= ( nCode
== KEY_LEFT
|| nCode
== KEY_RIGHT
) ? pScrollWindow
->GetHScroll() : pScrollWindow
->GetVScroll();
1644 if ( pScrollBar
&& pScrollBar
->IsVisible() )
1645 pScrollBar
->DoScrollAction(( nCode
== KEY_RIGHT
|| nCode
== KEY_UP
) ? SCROLL_LINEUP
: SCROLL_LINEDOWN
);
1648 TSectionsMap::const_iterator aIter
= m_aSections
.begin();
1649 TSectionsMap::const_iterator aEnd
= m_aSections
.end();
1650 for (; aIter
!= aEnd
; ++aIter
)
1652 OReportSection
& rReportSection
= (*aIter
)->getReportSection();
1656 if ( nCode
== KEY_UP
)
1658 else if ( nCode
== KEY_DOWN
)
1660 else if ( nCode
== KEY_LEFT
)
1662 else if ( nCode
== KEY_RIGHT
)
1665 if ( rReportSection
.getSectionView().AreObjectsMarked() )
1667 if ( _rCode
.IsMod2() )
1669 // move in 1 pixel distance
1670 const Size aPixelSize
= rReportSection
.PixelToLogic( Size( 1, 1 ) );
1671 nX
*= aPixelSize
.Width();
1672 nY
*= aPixelSize
.Height();
1676 // move in 1 mm distance
1677 nX
*= DEFAUL_MOVE_SIZE
;
1678 nY
*= DEFAUL_MOVE_SIZE
;
1681 OSectionView
& rView
= rReportSection
.getSectionView();
1682 const SdrHdlList
& rHdlList
= rView
.GetHdlList();
1683 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
1687 // no handle selected
1688 if ( rView
.IsMoveAllowed() )
1690 // restrict movement to work area
1691 Rectangle rWorkArea
= rView
.GetWorkArea();
1693 if ( !rWorkArea
.IsEmpty() )
1695 if ( rWorkArea
.Top() < 0 )
1696 rWorkArea
.Top() = 0;
1697 Rectangle
aMarkRect( rView
.GetMarkedObjRect() );
1698 aMarkRect
.Move( nX
, nY
);
1700 if ( !rWorkArea
.IsInside( aMarkRect
) )
1702 if ( aMarkRect
.Left() < rWorkArea
.Left() )
1703 nX
+= rWorkArea
.Left() - aMarkRect
.Left();
1705 if ( aMarkRect
.Right() > rWorkArea
.Right() )
1706 nX
-= aMarkRect
.Right() - rWorkArea
.Right();
1708 if ( aMarkRect
.Top() < rWorkArea
.Top() )
1709 nY
+= rWorkArea
.Top() - aMarkRect
.Top();
1711 if ( aMarkRect
.Bottom() > rWorkArea
.Bottom() )
1712 nY
-= aMarkRect
.Bottom() - rWorkArea
.Bottom();
1714 bool bCheck
= false;
1715 const SdrMarkList
& rMarkList
= rView
.GetMarkedObjectList();
1716 for (sal_uInt32 i
= 0; !bCheck
&& i
< rMarkList
.GetMarkCount();++i
)
1718 SdrMark
* pMark
= rMarkList
.GetMark(i
);
1719 bCheck
= dynamic_cast<OUnoObject
*>(pMark
->GetMarkedSdrObj()) != NULL
;
1722 if ( bCheck
&& isOver(aMarkRect
,*rReportSection
.getPage(),rView
) )
1726 if ( nX
!= 0 || nY
!= 0 )
1728 rView
.MoveAllMarked( Size( nX
, nY
) );
1729 rView
.MakeVisible( rView
.GetAllMarkedRect(), rReportSection
);
1736 if ( pHdl
&& ( nX
|| nY
) )
1738 const Point
aStartPoint( pHdl
->GetPos() );
1739 const Point
aEndPoint( pHdl
->GetPos() + Point( nX
, nY
) );
1740 const SdrDragStat
& rDragStat
= rView
.GetDragStat();
1743 rView
.BegDragObj( aStartPoint
, 0, pHdl
, 0 );
1745 if ( rView
.IsDragObj() )
1747 const FASTBOOL bWasNoSnap
= rDragStat
.IsNoSnap();
1748 const BOOL bWasSnapEnabled
= rView
.IsSnapEnabled();
1750 // switch snapping off
1752 ((SdrDragStat
&)rDragStat
).SetNoSnap( TRUE
);
1753 if ( bWasSnapEnabled
)
1754 rView
.SetSnapEnabled( FALSE
);
1757 bool bCheck
= false;
1758 const SdrMarkList
& rMarkList
= rView
.GetMarkedObjectList();
1759 for (sal_uInt32 i
= 0; !bCheck
&& i
< rMarkList
.GetMarkCount();++i
)
1761 SdrMark
* pMark
= rMarkList
.GetMark(i
);
1762 bCheck
= dynamic_cast<OUnoObject
*>(pMark
->GetMarkedSdrObj()) != NULL
;
1764 aNewRect
.Union(pMark
->GetMarkedSdrObj()->GetLastBoundRect());
1767 switch(pHdl
->GetKind())
1773 aNewRect
.Left() += nX
;
1774 aNewRect
.Top() += nY
;
1780 aNewRect
.setWidth(aNewRect
.getWidth() + nX
);
1781 aNewRect
.setHeight(aNewRect
.getHeight() + nY
);
1786 if ( !(bCheck
&& isOver(aNewRect
,*rReportSection
.getPage(),rView
)) )
1787 rView
.MovAction(aEndPoint
);
1792 ((SdrDragStat
&)rDragStat
).SetNoSnap( bWasNoSnap
);
1793 if ( bWasSnapEnabled
)
1794 rView
.SetSnapEnabled( bWasSnapEnabled
);
1797 // make moved handle visible
1798 const Rectangle
aVisRect( aEndPoint
- Point( DEFAUL_MOVE_SIZE
, DEFAUL_MOVE_SIZE
), Size( 200, 200 ) );
1799 rView
.MakeVisible( aVisRect
, rReportSection
);
1802 rView
.AdjustMarkHdl();
1806 // -----------------------------------------------------------------------------
1807 void OViewsWindow::stopScrollTimer()
1809 ::std::for_each(m_aSections
.begin(),m_aSections
.end(),
1810 ::std::compose1(::boost::mem_fn(&OReportSection::stopScrollTimer
),TReportPairHelper()));
1812 // -----------------------------------------------------------------------------
1813 void OViewsWindow::fillCollapsedSections(::std::vector
<sal_uInt16
>& _rCollapsedPositions
) const
1815 TSectionsMap::const_iterator aIter
= m_aSections
.begin();
1816 TSectionsMap::const_iterator aEnd
= m_aSections
.end();
1817 for (sal_uInt16 i
= 0;aIter
!= aEnd
; ++aIter
,++i
)
1819 if ( (*aIter
)->getStartMarker().isCollapsed() )
1820 _rCollapsedPositions
.push_back(i
);
1823 // -----------------------------------------------------------------------------
1824 void OViewsWindow::collapseSections(const uno::Sequence
< beans::PropertyValue
>& _aCollpasedSections
)
1826 const beans::PropertyValue
* pIter
= _aCollpasedSections
.getConstArray();
1827 const beans::PropertyValue
* pEnd
= pIter
+ _aCollpasedSections
.getLength();
1828 for (; pIter
!= pEnd
; ++pIter
)
1830 sal_uInt16 nPos
= sal_uInt16(-1);
1831 if ( (pIter
->Value
>>= nPos
) && nPos
< m_aSections
.size() )
1833 m_aSections
[nPos
]->setCollapsed(sal_True
);
1837 // -----------------------------------------------------------------------------
1838 void OViewsWindow::zoom(const Fraction
& _aZoom
)
1840 const MapMode
& aMapMode
= GetMapMode();
1842 Fraction
aStartWidth(long(REPORT_STARTMARKER_WIDTH
));
1843 if ( _aZoom
< aMapMode
.GetScaleX() )
1844 aStartWidth
*= aMapMode
.GetScaleX();
1846 aStartWidth
*= _aZoom
;
1848 setZoomFactor(_aZoom
,*this);
1850 TSectionsMap::iterator aIter
= m_aSections
.begin();
1851 TSectionsMap::iterator aEnd
= m_aSections
.end();
1852 for (;aIter
!= aEnd
; ++aIter
)
1854 (*aIter
)->zoom(_aZoom
);
1855 } // for (;aIter != aEnd ; ++aIter)
1859 Size aOut
= GetOutputSizePixel();
1860 aOut
.Width() = aStartWidth
;
1861 aOut
= PixelToLogic(aOut
);
1863 Rectangle
aRect(PixelToLogic(Point(0,0)),aOut
);
1864 Invalidate(aRect
,/*INVALIDATE_NOERASE | */INVALIDATE_NOCHILDREN
/*| INVALIDATE_TRANSPARENT*/);
1866 //----------------------------------------------------------------------------
1867 void OViewsWindow::scrollChildren(const Point
& _aThumbPos
)
1869 const Point
aPos(PixelToLogic(_aThumbPos
));
1871 MapMode aMapMode
= GetMapMode();
1872 const Point aOld
= aMapMode
.GetOrigin();
1873 aMapMode
.SetOrigin(m_pParent
->GetMapMode().GetOrigin());
1875 const Point
aPosY(m_pParent
->PixelToLogic(_aThumbPos
,aMapMode
));
1877 aMapMode
.SetOrigin( Point(aOld
.X() , - aPosY
.Y()));
1878 SetMapMode( aMapMode
);
1879 //OWindowPositionCorrector aCorrector(this,0,-( aOld.Y() + aPosY.Y()));
1880 Scroll(0, -( aOld
.Y() + aPosY
.Y()),SCROLL_CHILDREN
);
1882 Invalidate(INVALIDATE_NOCHILDREN
|INVALIDATE_TRANSPARENT
);
1885 TSectionsMap::iterator aIter
= m_aSections
.begin();
1886 TSectionsMap::iterator aEnd
= m_aSections
.end();
1887 for (;aIter
!= aEnd
; ++aIter
)
1889 (*aIter
)->scrollChildren(aPos
.X());
1890 } // for (;aIter != aEnd ; ++aIter)
1892 // -----------------------------------------------------------------------------
1893 void OViewsWindow::fillControlModelSelection(::std::vector
< uno::Reference
< uno::XInterface
> >& _rSelection
) const
1895 TSectionsMap::const_iterator aIter
= m_aSections
.begin();
1896 TSectionsMap::const_iterator aEnd
= m_aSections
.end();
1897 for(;aIter
!= aEnd
; ++aIter
)
1899 (*aIter
)->getReportSection().fillControlModelSelection(_rSelection
);
1902 //==============================================================================
1904 //==============================================================================