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: SectionView.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"
31 #include "SectionView.hxx"
32 #ifndef RPT_DESIGNVIEW_HXX
33 #include "DesignView.hxx"
35 #include <RptPage.hxx>
36 #include <RptObject.hxx>
38 #include <svx/svxids.hrc>
40 #include <vcl/scrbar.hxx>
41 #include "ReportSection.hxx"
42 #include "ReportWindow.hxx"
47 TYPEINIT1( OSectionView
, SdrView
);
49 //----------------------------------------------------------------------------
50 DBG_NAME( rpt_OSectionView
)
51 OSectionView::OSectionView( SdrModel
* pModel
, OReportSection
* _pSectionWindow
, OReportWindow
* pEditor
)
52 :SdrView( pModel
, _pSectionWindow
)
53 ,m_pReportWindow( pEditor
)
54 ,m_pSectionWindow(_pSectionWindow
)
56 DBG_CTOR( rpt_OSectionView
,NULL
);
57 SetBufferedOutputAllowed(true);
58 SetBufferedOverlayAllowed(true);
59 SetPageBorderVisible(false);
61 SetQuickTextEditMode(FALSE
);
64 //----------------------------------------------------------------------------
66 OSectionView::~OSectionView()
68 DBG_DTOR( rpt_OSectionView
,NULL
);
71 //----------------------------------------------------------------------------
73 void OSectionView::MarkListHasChanged()
75 DBG_CHKTHIS( rpt_OSectionView
,NULL
);
76 SdrView::MarkListHasChanged();
78 if ( m_pReportWindow
&& m_pSectionWindow
&& !m_pSectionWindow
->getPage()->getSpecialMode() )
80 //m_pReportWindow->unmarkAllObjects(this); // WHY
81 DlgEdHint
aHint( RPTUI_HINT_SELECTIONCHANGED
);
82 m_pReportWindow
->getReportView()->Broadcast( aHint
);
83 m_pReportWindow
->getReportView()->UpdatePropertyBrowserDelayed(*this);
87 //----------------------------------------------------------------------------
89 void OSectionView::MakeVisible( const Rectangle
& rRect
, Window
& rWin
)
91 DBG_CHKTHIS( rpt_OSectionView
,NULL
);
93 MapMode
aMap( rWin
.GetMapMode() );
94 const Point
aOrg( aMap
.GetOrigin() );
95 const Size
aVisSize( rWin
.GetOutputSize() );
96 const Rectangle
aVisRect( Point(-aOrg
.X(),-aOrg
.Y()), aVisSize
);
98 // check, if rectangle is inside visible area
99 if ( !aVisRect
.IsInside( rRect
) )
101 // calculate scroll distance; the rectangle must be inside the visible area
102 sal_Int32 nScrollX
= 0, nScrollY
= 0;
104 const sal_Int32 nVisLeft
= aVisRect
.Left();
105 const sal_Int32 nVisRight
= aVisRect
.Right();
106 const sal_Int32 nVisTop
= aVisRect
.Top();
107 const sal_Int32 nVisBottom
= aVisRect
.Bottom();
109 // don't scroll beyond the page size
110 Size aPageSize
= m_pSectionWindow
->getPage()->GetSize();
111 const sal_Int32 nPageWidth
= aPageSize
.Width();
112 const sal_Int32 nPageHeight
= aPageSize
.Height();
114 if ( nVisRight
+ nScrollX
> nPageWidth
)
115 nScrollX
= nPageWidth
- nVisRight
;
117 if ( nVisLeft
+ nScrollX
< 0 )
118 nScrollX
= -nVisLeft
;
120 if ( nVisBottom
+ nScrollY
> nPageHeight
)
121 nScrollY
= nPageHeight
- nVisBottom
;
123 if ( nVisTop
+ nScrollY
< 0 )
128 rWin
.Scroll( -nScrollX
, -nScrollY
);
129 aMap
.SetOrigin( Point( aOrg
.X() - nScrollX
, aOrg
.Y() - nScrollY
) );
130 rWin
.SetMapMode( aMap
);
134 if ( m_pReportWindow
)
136 const DlgEdHint
aHint( RPTUI_HINT_WINDOWSCROLLED
);
137 m_pReportWindow
->getReportView()->Broadcast( aHint
);
142 rWin
.Invalidate(INVALIDATE_NOERASE
);
145 //------------------------------------------------------------------------------
146 void OSectionView::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
148 DBG_CHKTHIS( rpt_OSectionView
,NULL
);
149 SdrView::Notify(rBC
,rHint
);
150 if ( rHint
.ISA(SdrHint
) )
152 const SdrObject
* pObj
= ((SdrHint
&)rHint
).GetObject();
153 const SdrHintKind eKind
= ((SdrHint
&)rHint
).GetKind();
154 // check for change of selected object
155 if(HINT_OBJCHG
== eKind
&& pObj
&& IsObjMarked(const_cast<SdrObject
*>(pObj
)))
157 else if ( eKind
== HINT_OBJREMOVED
)
158 ObjectRemovedInAliveMode(pObj
);
162 //------------------------------------------------------------------------------
163 void OSectionView::ObjectRemovedInAliveMode( const SdrObject
* _pObject
)
165 DBG_CHKTHIS( rpt_OSectionView
,NULL
);
166 const SdrMarkList
& rMarkedList
= GetMarkedObjectList();
167 const ULONG nMark
= rMarkedList
.GetMarkCount();
169 for( ULONG i
= 0; i
< nMark
; i
++ )
171 SdrObject
* pSdrObj
= rMarkedList
.GetMark(i
)->GetMarkedSdrObj();
172 if (_pObject
== pSdrObj
)
174 SdrPageView
* pPgView
= GetSdrPageView();
176 MarkObj( pSdrObj
, pPgView
, TRUE
);
181 // -----------------------------------------------------------------------------
182 //============================================================================
184 //============================================================================