1*9e0e4191SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9e0e4191SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9e0e4191SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9e0e4191SAndrew Rist  * distributed with this work for additional information
6*9e0e4191SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9e0e4191SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9e0e4191SAndrew Rist  * "License"); you may not use this file except in compliance
9*9e0e4191SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9e0e4191SAndrew Rist  *
11*9e0e4191SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9e0e4191SAndrew Rist  *
13*9e0e4191SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9e0e4191SAndrew Rist  * software distributed under the License is distributed on an
15*9e0e4191SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9e0e4191SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9e0e4191SAndrew Rist  * specific language governing permissions and limitations
18*9e0e4191SAndrew Rist  * under the License.
19*9e0e4191SAndrew Rist  *
20*9e0e4191SAndrew Rist  *************************************************************/
21*9e0e4191SAndrew Rist 
22*9e0e4191SAndrew Rist 
23cdf0e10cSrcweir #include "precompiled_reportdesign.hxx"
24cdf0e10cSrcweir #include "SectionWindow.hxx"
25cdf0e10cSrcweir #include "ReportWindow.hxx"
26cdf0e10cSrcweir #include "ReportRuler.hxx"
27cdf0e10cSrcweir #include "rptui_slotid.hrc"
28cdf0e10cSrcweir #include "ReportController.hxx"
29cdf0e10cSrcweir #include "SectionView.hxx"
30cdf0e10cSrcweir #include "RptDef.hxx"
31cdf0e10cSrcweir #include "ReportSection.hxx"
32cdf0e10cSrcweir #include "DesignView.hxx"
33cdf0e10cSrcweir #include "uistrings.hrc"
34cdf0e10cSrcweir #include "helpids.hrc"
35cdf0e10cSrcweir #include "RptResId.hrc"
36cdf0e10cSrcweir #include "StartMarker.hxx"
37cdf0e10cSrcweir #include "EndMarker.hxx"
38cdf0e10cSrcweir #include "ViewsWindow.hxx"
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
41cdf0e10cSrcweir #include <boost/bind.hpp>
42cdf0e10cSrcweir #include <functional>
43cdf0e10cSrcweir #include <algorithm>
44cdf0e10cSrcweir #include <vcl/svapp.hxx>
45cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir namespace rptui
48cdf0e10cSrcweir {
49cdf0e10cSrcweir #define SECTION_OFFSET	3
50cdf0e10cSrcweir 
51cdf0e10cSrcweir using namespace ::com::sun::star;
52cdf0e10cSrcweir using namespace ::comphelper;
53cdf0e10cSrcweir 
DBG_NAME(rpt_OSectionWindow)54cdf0e10cSrcweir DBG_NAME( rpt_OSectionWindow )
55cdf0e10cSrcweir OSectionWindow::OSectionWindow( OViewsWindow* _pParent,const uno::Reference< report::XSection >& _xSection,const ::rtl::OUString& _sColorEntry)
56cdf0e10cSrcweir : Window( _pParent,WB_DIALOGCONTROL)
57cdf0e10cSrcweir ,OPropertyChangeListener(m_aMutex)
58cdf0e10cSrcweir ,m_pParent(_pParent)
59cdf0e10cSrcweir ,m_aStartMarker( this,_sColorEntry)
60cdf0e10cSrcweir ,m_aReportSection( this,_xSection)
61cdf0e10cSrcweir ,m_aSplitter(this)
62cdf0e10cSrcweir ,m_aEndMarker( this,_sColorEntry)
63cdf0e10cSrcweir {
64cdf0e10cSrcweir     DBG_CTOR( rpt_OSectionWindow,NULL);
65cdf0e10cSrcweir 	SetUniqueId(UID_RPT_SECTIONSWINDOW);
66cdf0e10cSrcweir     const MapMode& rMapMode = _pParent->GetMapMode();
67cdf0e10cSrcweir 	SetMapMode( rMapMode );
68cdf0e10cSrcweir 	ImplInitSettings();
69cdf0e10cSrcweir     // TRY
70cdf0e10cSrcweir     m_aSplitter.SetMapMode( MapMode( MAP_100TH_MM ) );
71cdf0e10cSrcweir     m_aSplitter.SetStartSplitHdl(LINK(this, OSectionWindow,StartSplitHdl));
72cdf0e10cSrcweir 	m_aSplitter.SetSplitHdl(LINK(this, OSectionWindow,SplitHdl));
73cdf0e10cSrcweir 	m_aSplitter.SetEndSplitHdl(LINK(this, OSectionWindow,EndSplitHdl));
74cdf0e10cSrcweir     m_aSplitter.SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor() ));
75cdf0e10cSrcweir     m_aSplitter.SetSplitPosPixel(m_aSplitter.LogicToPixel(Size(0,_xSection->getHeight())).Height());
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     m_aStartMarker.setCollapsedHdl(LINK(this,OSectionWindow,Collapsed));
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     m_aStartMarker.zoom(rMapMode.GetScaleX());
81cdf0e10cSrcweir     setZoomFactor(rMapMode.GetScaleX(),m_aReportSection);
82cdf0e10cSrcweir     setZoomFactor(rMapMode.GetScaleX(),m_aSplitter);
83cdf0e10cSrcweir     setZoomFactor(rMapMode.GetScaleX(),m_aEndMarker);
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     m_aSplitter.Show();
86cdf0e10cSrcweir 	m_aStartMarker.Show();
87cdf0e10cSrcweir 	m_aReportSection.Show();
88cdf0e10cSrcweir 	m_aEndMarker.Show();
89cdf0e10cSrcweir     Show();
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     m_pSectionMulti = new OPropertyChangeMultiplexer(this,_xSection.get());
92cdf0e10cSrcweir     m_pSectionMulti->addProperty(PROPERTY_NAME);
93cdf0e10cSrcweir 	m_pSectionMulti->addProperty(PROPERTY_HEIGHT);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     beans::PropertyChangeEvent aEvent;
96cdf0e10cSrcweir     aEvent.Source = _xSection;
97cdf0e10cSrcweir     aEvent.PropertyName = PROPERTY_NAME;
98cdf0e10cSrcweir     uno::Reference< report::XGroup > xGroup(_xSection->getGroup());
99cdf0e10cSrcweir     if ( xGroup.is() )
100cdf0e10cSrcweir     {
101cdf0e10cSrcweir         m_pGroupMulti = new OPropertyChangeMultiplexer(this,xGroup.get());
102cdf0e10cSrcweir         m_pGroupMulti->addProperty(PROPERTY_EXPRESSION);
103cdf0e10cSrcweir         aEvent.Source = xGroup;
104cdf0e10cSrcweir         aEvent.PropertyName = PROPERTY_EXPRESSION;
105cdf0e10cSrcweir     }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     _propertyChanged(aEvent);
108cdf0e10cSrcweir }
109cdf0e10cSrcweir // -----------------------------------------------------------------------------
~OSectionWindow()110cdf0e10cSrcweir OSectionWindow::~OSectionWindow()
111cdf0e10cSrcweir {
112cdf0e10cSrcweir     DBG_DTOR( rpt_OSectionWindow,NULL);
113cdf0e10cSrcweir 	try
114cdf0e10cSrcweir 	{
115cdf0e10cSrcweir         if ( m_pSectionMulti.is() )
116cdf0e10cSrcweir             m_pSectionMulti->dispose();
117cdf0e10cSrcweir         if ( m_pGroupMulti.is() )
118cdf0e10cSrcweir             m_pGroupMulti->dispose();
119cdf0e10cSrcweir 	}
120cdf0e10cSrcweir 	catch (uno::Exception&)
121cdf0e10cSrcweir 	{
122cdf0e10cSrcweir 	}
123cdf0e10cSrcweir }
124cdf0e10cSrcweir // -----------------------------------------------------------------------------
_propertyChanged(const beans::PropertyChangeEvent & _rEvent)125cdf0e10cSrcweir void OSectionWindow::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) throw( uno::RuntimeException)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     const uno::Reference< report::XSection > xSection(_rEvent.Source,uno::UNO_QUERY);
128cdf0e10cSrcweir 	if ( xSection.is() )
129cdf0e10cSrcweir 	{
130cdf0e10cSrcweir 		const uno::Reference< report::XSection> xCurrentSection = m_aReportSection.getSection();
131cdf0e10cSrcweir         if ( _rEvent.PropertyName.equals(PROPERTY_HEIGHT) )
132cdf0e10cSrcweir         {
133cdf0e10cSrcweir             static bool t4 = true;
134cdf0e10cSrcweir         if ( t4 )
135cdf0e10cSrcweir             m_pParent->getView()->SetUpdateMode(sal_False);
136cdf0e10cSrcweir             //Resize();
137cdf0e10cSrcweir 	        m_pParent->getView()->notifySizeChanged();
138cdf0e10cSrcweir 	        m_pParent->resize(*this);
139cdf0e10cSrcweir             if ( t4 )
140cdf0e10cSrcweir             m_pParent->getView()->SetUpdateMode(sal_True);
141cdf0e10cSrcweir             // getViewsWindow()->getView()->getReportView()->getController().resetZoomType();
142cdf0e10cSrcweir 		}
143cdf0e10cSrcweir         else if ( _rEvent.PropertyName.equals(PROPERTY_NAME) && !xSection->getGroup().is() )
144cdf0e10cSrcweir         {
145cdf0e10cSrcweir             uno::Reference< report::XReportDefinition > xReport = xSection->getReportDefinition();
146cdf0e10cSrcweir             if (    setReportSectionTitle(xReport,RID_STR_REPORT_HEADER,::std::mem_fun(&OReportHelper::getReportHeader),::std::mem_fun(&OReportHelper::getReportHeaderOn))
147cdf0e10cSrcweir                 ||  setReportSectionTitle(xReport,RID_STR_REPORT_FOOTER,::std::mem_fun(&OReportHelper::getReportFooter),::std::mem_fun(&OReportHelper::getReportFooterOn))
148cdf0e10cSrcweir                 ||  setReportSectionTitle(xReport,RID_STR_PAGE_HEADER,::std::mem_fun(&OReportHelper::getPageHeader),::std::mem_fun(&OReportHelper::getPageHeaderOn))
149cdf0e10cSrcweir                 ||  setReportSectionTitle(xReport,RID_STR_PAGE_FOOTER,::std::mem_fun(&OReportHelper::getPageFooter),::std::mem_fun(&OReportHelper::getPageFooterOn)) )
150cdf0e10cSrcweir             {
151cdf0e10cSrcweir                 m_aStartMarker.Invalidate(INVALIDATE_NOERASE);
152cdf0e10cSrcweir             }
153cdf0e10cSrcweir             else
154cdf0e10cSrcweir             {
155cdf0e10cSrcweir                 String sTitle = String(ModuleRes(RID_STR_DETAIL));
156cdf0e10cSrcweir                 m_aStartMarker.setTitle(sTitle);
157cdf0e10cSrcweir                 m_aStartMarker.Invalidate(INVALIDATE_CHILDREN);
158cdf0e10cSrcweir             }
159cdf0e10cSrcweir         }
160cdf0e10cSrcweir 	} // if ( xSection.is() )
161cdf0e10cSrcweir     else if ( _rEvent.PropertyName.equals(PROPERTY_EXPRESSION) )
162cdf0e10cSrcweir     {
163cdf0e10cSrcweir         uno::Reference< report::XGroup > xGroup(_rEvent.Source,uno::UNO_QUERY);
164cdf0e10cSrcweir         if ( xGroup.is() && !setGroupSectionTitle(xGroup,RID_STR_HEADER,::std::mem_fun(&OGroupHelper::getHeader),::std::mem_fun(&OGroupHelper::getHeaderOn)))
165cdf0e10cSrcweir         {
166cdf0e10cSrcweir             setGroupSectionTitle(xGroup,RID_STR_FOOTER,::std::mem_fun(&OGroupHelper::getFooter),::std::mem_fun(&OGroupHelper::getFooterOn));
167cdf0e10cSrcweir         }
168cdf0e10cSrcweir     }
169cdf0e10cSrcweir }
170cdf0e10cSrcweir // -----------------------------------------------------------------------------
setReportSectionTitle(const uno::Reference<report::XReportDefinition> & _xReport,sal_uInt16 _nResId,::std::mem_fun_t<uno::Reference<report::XSection>,OReportHelper> _pGetSection,::std::mem_fun_t<sal_Bool,OReportHelper> _pIsSectionOn)171cdf0e10cSrcweir bool OSectionWindow::setReportSectionTitle(const uno::Reference< report::XReportDefinition>& _xReport,sal_uInt16 _nResId,::std::mem_fun_t<uno::Reference<report::XSection> , OReportHelper> _pGetSection,::std::mem_fun_t<sal_Bool,OReportHelper> _pIsSectionOn)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir     OReportHelper aReportHelper(_xReport);
174cdf0e10cSrcweir     const bool bRet = _pIsSectionOn(&aReportHelper) && _pGetSection(&aReportHelper) == m_aReportSection.getSection();
175cdf0e10cSrcweir     if ( bRet )
176cdf0e10cSrcweir     {
177cdf0e10cSrcweir         String sTitle = String(ModuleRes(_nResId));
178cdf0e10cSrcweir         m_aStartMarker.setTitle(sTitle);
179cdf0e10cSrcweir         m_aStartMarker.Invalidate(INVALIDATE_CHILDREN);
180cdf0e10cSrcweir     } // if ( bRet )
181cdf0e10cSrcweir     return bRet;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir // -----------------------------------------------------------------------------
setGroupSectionTitle(const uno::Reference<report::XGroup> & _xGroup,sal_uInt16 _nResId,::std::mem_fun_t<uno::Reference<report::XSection>,OGroupHelper> _pGetSection,::std::mem_fun_t<sal_Bool,OGroupHelper> _pIsSectionOn)184cdf0e10cSrcweir bool OSectionWindow::setGroupSectionTitle(const uno::Reference< report::XGroup>& _xGroup,sal_uInt16 _nResId,::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> _pGetSection,::std::mem_fun_t<sal_Bool,OGroupHelper> _pIsSectionOn)
185cdf0e10cSrcweir {
186cdf0e10cSrcweir     OGroupHelper aGroupHelper(_xGroup);
187cdf0e10cSrcweir     const bool bRet = _pIsSectionOn(&aGroupHelper) && _pGetSection(&aGroupHelper) == m_aReportSection.getSection() ;
188cdf0e10cSrcweir     if ( bRet )
189cdf0e10cSrcweir     {
190cdf0e10cSrcweir         ::rtl::OUString sExpression = _xGroup->getExpression();
191cdf0e10cSrcweir         ::rtl::OUString sLabel = getViewsWindow()->getView()->getReportView()->getController().getColumnLabel_throw(sExpression);
192cdf0e10cSrcweir         if ( sLabel.getLength() )
193cdf0e10cSrcweir         {
194cdf0e10cSrcweir             sExpression = sLabel;
195cdf0e10cSrcweir         }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir         String sTitle = String(ModuleRes(_nResId));
198cdf0e10cSrcweir         sTitle.SearchAndReplace('#',sExpression);
199cdf0e10cSrcweir         m_aStartMarker.setTitle(sTitle);
200cdf0e10cSrcweir         m_aStartMarker.Invalidate(INVALIDATE_CHILDREN);
201cdf0e10cSrcweir     } // if ( _pIsSectionOn(&aGroupHelper) )
202cdf0e10cSrcweir     return bRet;
203cdf0e10cSrcweir }
204cdf0e10cSrcweir //------------------------------------------------------------------------------
ImplInitSettings()205cdf0e10cSrcweir void OSectionWindow::ImplInitSettings()
206cdf0e10cSrcweir {
207cdf0e10cSrcweir     static bool t = false;
208cdf0e10cSrcweir     if ( t )
209cdf0e10cSrcweir     {
210cdf0e10cSrcweir     EnableChildTransparentMode( sal_True );
211cdf0e10cSrcweir     SetParentClipMode( PARENTCLIPMODE_NOCLIP );
212cdf0e10cSrcweir     SetPaintTransparent( sal_True );
213cdf0e10cSrcweir     }
214cdf0e10cSrcweir 	SetBackground( );
215cdf0e10cSrcweir }
216cdf0e10cSrcweir //-----------------------------------------------------------------------------
DataChanged(const DataChangedEvent & rDCEvt)217cdf0e10cSrcweir void OSectionWindow::DataChanged( const DataChangedEvent& rDCEvt )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir 	Window::DataChanged( rDCEvt );
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
222cdf0e10cSrcweir 		 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
223cdf0e10cSrcweir 	{
224cdf0e10cSrcweir 		ImplInitSettings();
225cdf0e10cSrcweir 		Invalidate();
226cdf0e10cSrcweir 	}
227cdf0e10cSrcweir }
228cdf0e10cSrcweir //------------------------------------------------------------------------------
Resize()229cdf0e10cSrcweir void OSectionWindow::Resize()
230cdf0e10cSrcweir {
231cdf0e10cSrcweir 	Window::Resize();
232cdf0e10cSrcweir 
233cdf0e10cSrcweir     Size aOutputSize = GetOutputSizePixel();
234cdf0e10cSrcweir     Fraction aEndWidth(long(REPORT_ENDMARKER_WIDTH));
235cdf0e10cSrcweir     aEndWidth *= GetMapMode().GetScaleX();
236cdf0e10cSrcweir 
237cdf0e10cSrcweir     const Point aThumbPos = m_pParent->getView()->getThumbPos();
238cdf0e10cSrcweir     aOutputSize.Width() -= aThumbPos.X();
239cdf0e10cSrcweir     aOutputSize.Height() -=  m_aSplitter.GetSizePixel().Height();
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 	if ( m_aStartMarker.isCollapsed() )
242cdf0e10cSrcweir     {
243cdf0e10cSrcweir         Point aPos(0,0);
244cdf0e10cSrcweir 		m_aStartMarker.SetPosSizePixel(aPos,aOutputSize);
245cdf0e10cSrcweir 	}
246cdf0e10cSrcweir     else
247cdf0e10cSrcweir 	{
248cdf0e10cSrcweir         const bool bShowEndMarker = m_pParent->getView()->GetTotalWidth() <= (aThumbPos.X() +  aOutputSize.Width() );
249cdf0e10cSrcweir 
250cdf0e10cSrcweir         Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH));
251cdf0e10cSrcweir         aStartWidth *= GetMapMode().GetScaleX();
252cdf0e10cSrcweir 
253cdf0e10cSrcweir         // set start marker
254cdf0e10cSrcweir 		m_aStartMarker.SetPosSizePixel(Point(0,0),Size(aStartWidth,aOutputSize.Height()));
255cdf0e10cSrcweir 
256cdf0e10cSrcweir         // set report section
257cdf0e10cSrcweir         const uno::Reference< report::XSection> xSection = m_aReportSection.getSection();
258cdf0e10cSrcweir 	    Size aSectionSize = LogicToPixel( Size( 0,xSection->getHeight() ) );
259cdf0e10cSrcweir         Point aReportPos(aStartWidth,0);
260cdf0e10cSrcweir         aSectionSize.Width() = aOutputSize.Width() - (long)aStartWidth;
261cdf0e10cSrcweir         if ( bShowEndMarker )
262cdf0e10cSrcweir             aSectionSize.Width() -= (long)aEndWidth;
263cdf0e10cSrcweir 
264cdf0e10cSrcweir         m_aReportSection.SetPosSizePixel(aReportPos,aSectionSize);
265cdf0e10cSrcweir 
266cdf0e10cSrcweir         // set splitter
267cdf0e10cSrcweir         aReportPos.Y() += aSectionSize.Height();
268cdf0e10cSrcweir 		m_aSplitter.SetPosSizePixel(aReportPos,Size(aSectionSize.Width(),m_aSplitter.GetSizePixel().Height()));
269cdf0e10cSrcweir         aSectionSize.Height() = (long)(1000 * (double)GetMapMode().GetScaleY());
270cdf0e10cSrcweir 		m_aSplitter.SetDragRectPixel( Rectangle(Point(aStartWidth,0),aSectionSize));
271cdf0e10cSrcweir 
272cdf0e10cSrcweir         // set end marker
273cdf0e10cSrcweir         aReportPos.X() += aSectionSize.Width();
274cdf0e10cSrcweir         aReportPos.Y() = 0;
275cdf0e10cSrcweir         m_aEndMarker.Show(bShowEndMarker);
276cdf0e10cSrcweir 		m_aEndMarker.SetPosSizePixel(aReportPos,Size(aEndWidth,aOutputSize.Height()));
277cdf0e10cSrcweir 	}
278cdf0e10cSrcweir }
279cdf0e10cSrcweir // -----------------------------------------------------------------------------
setCollapsed(sal_Bool _bCollapsed)280cdf0e10cSrcweir void OSectionWindow::setCollapsed(sal_Bool _bCollapsed)
281cdf0e10cSrcweir {
282cdf0e10cSrcweir     if ( m_aStartMarker.isCollapsed() != _bCollapsed )
283cdf0e10cSrcweir     {
284cdf0e10cSrcweir         m_aStartMarker.setCollapsed(_bCollapsed);
285cdf0e10cSrcweir     }
286cdf0e10cSrcweir }
287cdf0e10cSrcweir //-----------------------------------------------------------------------------
showProperties()288cdf0e10cSrcweir void OSectionWindow::showProperties()
289cdf0e10cSrcweir {
290cdf0e10cSrcweir 	m_pParent->getView()->showProperties( m_aReportSection.getSection().get() );
291cdf0e10cSrcweir }
292cdf0e10cSrcweir //-----------------------------------------------------------------------------
setMarked(sal_Bool _bMark)293cdf0e10cSrcweir void OSectionWindow::setMarked(sal_Bool _bMark)
294cdf0e10cSrcweir {
295cdf0e10cSrcweir     m_aStartMarker.setMarked(_bMark);
296cdf0e10cSrcweir     m_aEndMarker.setMarked(_bMark);
297cdf0e10cSrcweir }
298cdf0e10cSrcweir // -----------------------------------------------------------------------------
IMPL_LINK(OSectionWindow,Collapsed,OColorListener *,_pMarker)299cdf0e10cSrcweir IMPL_LINK( OSectionWindow, Collapsed, OColorListener *, _pMarker )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir 	if ( _pMarker )
302cdf0e10cSrcweir 	{
303cdf0e10cSrcweir         sal_Bool bShow = !_pMarker->isCollapsed();
304cdf0e10cSrcweir         m_aReportSection.Show(bShow);
305cdf0e10cSrcweir         m_aEndMarker.Show(bShow);
306cdf0e10cSrcweir         m_aSplitter.Show(bShow);
307cdf0e10cSrcweir 
308cdf0e10cSrcweir         m_pParent->resize(*this);
309cdf0e10cSrcweir 	}
310cdf0e10cSrcweir 	return 0L;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir // -----------------------------------------------------------------------------
zoom(const Fraction & _aZoom)313cdf0e10cSrcweir void OSectionWindow::zoom(const Fraction& _aZoom)
314cdf0e10cSrcweir {
315cdf0e10cSrcweir     setZoomFactor(_aZoom,*this);
316cdf0e10cSrcweir     m_aStartMarker.zoom(_aZoom);
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     setZoomFactor(_aZoom,m_aReportSection);
319cdf0e10cSrcweir     setZoomFactor(_aZoom,m_aSplitter);
320cdf0e10cSrcweir     setZoomFactor(_aZoom,m_aEndMarker);
321cdf0e10cSrcweir     //Resize();
322cdf0e10cSrcweir     Invalidate(/*INVALIDATE_UPDATE |*/ /* | INVALIDATE_TRANSPARENT *//*INVALIDATE_NOCHILDREN*/);
323cdf0e10cSrcweir }
324cdf0e10cSrcweir //-----------------------------------------------------------------------------
325cdf0e10cSrcweir IMPL_LINK( OSectionWindow, StartSplitHdl, Splitter*,  )
326cdf0e10cSrcweir {
327cdf0e10cSrcweir 	const String sUndoAction( ModuleRes( RID_STR_UNDO_CHANGE_SIZE ) );
328cdf0e10cSrcweir 	getViewsWindow()->getView()->getReportView()->getController().getUndoManager().EnterListAction( sUndoAction, String() );
329cdf0e10cSrcweir 	return 0L;
330cdf0e10cSrcweir }
331cdf0e10cSrcweir //------------------------------------------------------------------------------
332cdf0e10cSrcweir IMPL_LINK( OSectionWindow, EndSplitHdl, Splitter*,  )
333cdf0e10cSrcweir {
334cdf0e10cSrcweir 	getViewsWindow()->getView()->getReportView()->getController().getUndoManager().LeaveListAction();
335cdf0e10cSrcweir 	return 0L;
336cdf0e10cSrcweir }
337cdf0e10cSrcweir //-----------------------------------------------------------------------------
IMPL_LINK(OSectionWindow,SplitHdl,Splitter *,_pSplitter)338cdf0e10cSrcweir IMPL_LINK( OSectionWindow, SplitHdl, Splitter*, _pSplitter )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir     if ( !getViewsWindow()->getView()->getReportView()->getController().isEditable() )
341cdf0e10cSrcweir     {
342cdf0e10cSrcweir         return 0L;
343cdf0e10cSrcweir     }
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 	sal_Int32 nSplitPos = _pSplitter->GetSplitPosPixel();
346cdf0e10cSrcweir 	const Point aPos = _pSplitter->GetPosPixel();
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 
349cdf0e10cSrcweir     const uno::Reference< report::XSection> xSection = m_aReportSection.getSection();
350cdf0e10cSrcweir     nSplitPos = m_aSplitter.PixelToLogic(Size(0,nSplitPos)).Height();
351cdf0e10cSrcweir     // nSplitPos = xSection->getHeight() + m_aSplitter.PixelToLogic(Size(0,nSplitPos - aPos.Y() )).Height();
352cdf0e10cSrcweir 
353cdf0e10cSrcweir     const sal_Int32 nCount = xSection->getCount();
354cdf0e10cSrcweir     for (sal_Int32 i = 0; i < nCount; ++i)
355cdf0e10cSrcweir     {
356cdf0e10cSrcweir         uno::Reference<report::XReportComponent> xReportComponent(xSection->getByIndex(i),uno::UNO_QUERY);
357cdf0e10cSrcweir         if ( xReportComponent.is() /*&& nSplitPos < (xReportComponent->getPositionY() + xReportComponent->getHeight())*/ )
358cdf0e10cSrcweir         {
359cdf0e10cSrcweir 	        nSplitPos = ::std::max(nSplitPos,xReportComponent->getPositionY() + xReportComponent->getHeight());
360cdf0e10cSrcweir         }
361cdf0e10cSrcweir     } // for (sal_Int32 i = 0; i < nCount; ++i)
362cdf0e10cSrcweir 
363cdf0e10cSrcweir     if ( nSplitPos < 0 )
364cdf0e10cSrcweir         nSplitPos = 0;
365cdf0e10cSrcweir 
366cdf0e10cSrcweir     xSection->setHeight(nSplitPos);
367cdf0e10cSrcweir     m_aSplitter.SetSplitPosPixel(m_aSplitter.LogicToPixel(Size(0,nSplitPos)).Height());
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 	return 0L;
370cdf0e10cSrcweir }
371cdf0e10cSrcweir // -----------------------------------------------------------------------------
lcl_scroll(Window & _rWindow,const Point & _aDelta)372cdf0e10cSrcweir void lcl_scroll(Window& _rWindow,const Point& _aDelta)
373cdf0e10cSrcweir {
374cdf0e10cSrcweir     _rWindow.Scroll(-_aDelta.X(),-_aDelta.Y()/*,SCROLL_CHILDREN*//*|SCROLL_CLIP*/);
375cdf0e10cSrcweir     _rWindow.Invalidate(INVALIDATE_TRANSPARENT);
376cdf0e10cSrcweir }
377cdf0e10cSrcweir // -----------------------------------------------------------------------------
lcl_setOrigin(Window & _rWindow,long _nX,long _nY)378cdf0e10cSrcweir void lcl_setOrigin(Window& _rWindow,long _nX, long _nY)
379cdf0e10cSrcweir {
380cdf0e10cSrcweir     MapMode aMap = _rWindow.GetMapMode();
381cdf0e10cSrcweir 	aMap.SetOrigin( Point(- _nX, - _nY));
382cdf0e10cSrcweir 	_rWindow.SetMapMode( aMap );
383cdf0e10cSrcweir }
384cdf0e10cSrcweir //----------------------------------------------------------------------------
scrollChildren(long _nX)385cdf0e10cSrcweir void OSectionWindow::scrollChildren(long _nX)
386cdf0e10cSrcweir {
387cdf0e10cSrcweir     const Point aDelta( _nX,0 );
388cdf0e10cSrcweir 
389cdf0e10cSrcweir     MapMode aMapMode( m_aReportSection.GetMapMode() );
390cdf0e10cSrcweir     const Point aOld = aMapMode.GetOrigin();
391cdf0e10cSrcweir     lcl_setOrigin(m_aReportSection,aDelta.X(), 0);
392cdf0e10cSrcweir 
393cdf0e10cSrcweir     aMapMode = m_aReportSection.GetMapMode();
394cdf0e10cSrcweir     const Point aNew = aMapMode.GetOrigin();
395cdf0e10cSrcweir     const Point aDiff = aOld - aNew;
396cdf0e10cSrcweir     {
397cdf0e10cSrcweir         //OWindowPositionCorrector aCorrector(&m_aReportSection,-aDelta.Width(),0);
398cdf0e10cSrcweir         lcl_scroll(m_aReportSection,aDiff);
399cdf0e10cSrcweir     }
400cdf0e10cSrcweir 
401cdf0e10cSrcweir     //lcl_setOrigin(m_aEndMarker,_nDeltaX, 0);
402cdf0e10cSrcweir     lcl_scroll(m_aEndMarker,m_aEndMarker.PixelToLogic(Point(_nX,0)));
403cdf0e10cSrcweir 
404cdf0e10cSrcweir     lcl_setOrigin(m_aSplitter,_nX, 0);
405cdf0e10cSrcweir     lcl_scroll(m_aSplitter,aDiff);
406cdf0e10cSrcweir }
407cdf0e10cSrcweir //==============================================================================
408cdf0e10cSrcweir } // rptui
409cdf0e10cSrcweir //==============================================================================
410cdf0e10cSrcweir 
411