LCOV - code coverage report
Current view: top level - reportdesign/source/ui/report - ReportWindow.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 220 0.5 %
Date: 2014-11-03 Functions: 2 49 4.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #include "ReportWindow.hxx"
      20             : #include "ReportSection.hxx"
      21             : #include "SectionView.hxx"
      22             : #include "ViewsWindow.hxx"
      23             : #include "DesignView.hxx"
      24             : #include "UITools.hxx"
      25             : 
      26             : #include <tools/debug.hxx>
      27             : #include <svtools/colorcfg.hxx>
      28             : #include <svl/itempool.hxx>
      29             : #include <unotools/syslocale.hxx>
      30             : 
      31             : #include <vcl/settings.hxx>
      32             : 
      33             : #include "RptDef.hxx"
      34             : #include "dlgedfunc.hxx"
      35             : #include "RptModel.hxx"
      36             : #include "uistrings.hrc"
      37             : #include "RptPage.hxx"
      38             : #include "ReportController.hxx"
      39             : #include "EndMarker.hxx"
      40             : #include "ColorChanger.hxx"
      41             : #include "ScrollHelper.hxx"
      42             : 
      43             : #include "helpids.hrc"
      44             : #include "dlgedfac.hxx"
      45             : #include <boost/shared_ptr.hpp>
      46             : #include <toolkit/helper/vclunohelper.hxx>
      47             : 
      48             : 
      49             : #define SECTION_OFFSET  3
      50             : namespace rptui
      51             : {
      52             : using namespace ::com::sun::star;
      53             : using namespace ::comphelper;
      54             : 
      55             : // class OReportWindow
      56             : 
      57             : 
      58           0 : OReportWindow::OReportWindow(OScrollWindowHelper* _pParent,ODesignView* _pView)
      59             : : Window(_pParent,WB_DIALOGCONTROL)
      60             : , ::comphelper::OPropertyChangeListener(m_aMutex)
      61             : ,m_aHRuler(this)
      62             : ,m_pView(_pView)
      63             : ,m_pParent(_pParent)
      64             : ,m_aViewsWindow(this)
      65           0 : ,m_pObjFac( new DlgEdFactory() )
      66             : {
      67           0 :     SetHelpId(UID_RPT_REPORTWINDOW);
      68           0 :     SetMapMode( MapMode( MAP_100TH_MM ) );
      69             : 
      70           0 :     m_aViewsWindow.Show();
      71             : 
      72           0 :     m_aHRuler.Show();
      73           0 :     m_aHRuler.Activate();
      74           0 :     m_aHRuler.SetPagePos(0);
      75           0 :     m_aHRuler.SetBorders();
      76           0 :     m_aHRuler.SetIndents();
      77           0 :     m_aHRuler.SetMargin1();
      78           0 :     m_aHRuler.SetMargin2();
      79           0 :     const MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
      80           0 :     m_aHRuler.SetUnit(MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH);
      81             : 
      82           0 :     ImplInitSettings();
      83           0 :     m_pReportListener = addStyleListener(_pView->getController().getReportDefinition(),this);
      84           0 : }
      85             : 
      86           0 : OReportWindow::~OReportWindow()
      87             : {
      88           0 :     if ( m_pReportListener.is() )
      89           0 :         m_pReportListener->dispose();
      90           0 : }
      91             : 
      92           0 : void OReportWindow::initialize()
      93             : {
      94           0 :     m_aViewsWindow.initialize();
      95           0 : }
      96             : 
      97           0 : void OReportWindow::SetInsertObj( sal_uInt16 eObj,const OUString& _sShapeType )
      98             : {
      99           0 :     m_aViewsWindow.SetInsertObj( eObj,_sShapeType);
     100           0 : }
     101             : 
     102             : 
     103           0 : OUString OReportWindow::GetInsertObjString() const
     104             : {
     105           0 :     return m_aViewsWindow.GetInsertObjString();
     106             : }
     107             : 
     108           0 : void OReportWindow::SetMode( DlgEdMode eNewMode )
     109             : {
     110           0 :     m_aViewsWindow.SetMode(eNewMode);
     111           0 : }
     112             : 
     113           0 : void OReportWindow::removeSection(sal_uInt16 _nPosition)
     114             : {
     115           0 :     m_aViewsWindow.removeSection(_nPosition);
     116           0 :     m_pParent->setTotalSize(GetTotalWidth(),GetTotalHeight());
     117           0 :     m_aViewsWindow.Invalidate(INVALIDATE_TRANSPARENT);
     118           0 : }
     119             : 
     120           0 : void OReportWindow::addSection(const uno::Reference< report::XSection >& _xSection,const OUString& _sColorEntry,sal_uInt16 _nPosition)
     121             : {
     122           0 :     if ( !_xSection.is() )
     123           0 :         return;
     124             : 
     125           0 :     m_aViewsWindow.addSection(_xSection,_sColorEntry,_nPosition);
     126             : 
     127           0 :     m_pParent->setTotalSize(GetTotalWidth(),GetTotalHeight());
     128             : }
     129             : 
     130           0 : void OReportWindow::toggleGrid(bool _bVisible)
     131             : {
     132           0 :     m_aViewsWindow.toggleGrid(_bVisible);
     133           0 : }
     134             : 
     135           0 : void OReportWindow::showRuler(bool _bShow)
     136             : {
     137           0 :     m_aHRuler.Show(_bShow);
     138             : 
     139           0 :     m_aViewsWindow.showRuler(_bShow);
     140           0 : }
     141             : 
     142           0 : sal_Int32 OReportWindow::getMaxMarkerWidth(bool _bWithEnd) const
     143             : {
     144           0 :     Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH));
     145           0 :     aStartWidth *= m_aViewsWindow.GetMapMode().GetScaleX();
     146           0 :     if ( _bWithEnd )
     147           0 :         aStartWidth += Fraction(long(REPORT_ENDMARKER_WIDTH));
     148           0 :     return sal_Int32((long)aStartWidth);
     149             : }
     150             : 
     151           0 : sal_Int32 OReportWindow::GetTotalWidth() const
     152             : {
     153           0 :     sal_Int32 nWidth = 0;
     154           0 :     if ( !m_aViewsWindow.empty() )
     155             :     {
     156           0 :         Fraction aStartWidth(long(REPORT_ENDMARKER_WIDTH + REPORT_STARTMARKER_WIDTH ));
     157           0 :         const Fraction aZoom(m_pView->getController().getZoomValue(),100);
     158           0 :         aStartWidth *= aZoom;
     159           0 :         const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_pView->getController().getReportDefinition(),PROPERTY_PAPERSIZE).Width;
     160           0 :         Fraction aPaperWidth(nPaperWidth,1);
     161           0 :         aPaperWidth *= aZoom;
     162           0 :         const Size aPageSize = LogicToPixel(Size(aPaperWidth,0));
     163           0 :         nWidth = aPageSize.Width() + long(aStartWidth);
     164             :     }
     165           0 :     return nWidth;
     166             : }
     167             : 
     168           0 : void OReportWindow::Resize()
     169             : {
     170           0 :     Window::Resize();
     171           0 :     if ( !m_aViewsWindow.empty() )
     172             :     {
     173           0 :         const Size aTotalOutputSize = GetOutputSizePixel();
     174           0 :         Fraction aStartWidth(long(REPORT_STARTMARKER_WIDTH)*m_pView->getController().getZoomValue(),100);
     175             : 
     176           0 :         const Point aOffset = LogicToPixel( Point( SECTION_OFFSET, 0 ), MAP_APPFONT );
     177           0 :         Point aStartPoint((long)aStartWidth + aOffset.X(),0);
     178           0 :         uno::Reference<report::XReportDefinition> xReportDefinition = getReportView()->getController().getReportDefinition();
     179           0 :         const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width;
     180           0 :         sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN);
     181           0 :         sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN);
     182           0 :         Size aPageSize  = m_aViewsWindow.LogicToPixel(Size(nPaperWidth ,0));
     183           0 :         nLeftMargin     = m_aViewsWindow.LogicToPixel(Size(nLeftMargin,0)).Width();
     184           0 :         nRightMargin    = m_aViewsWindow.LogicToPixel(Size(nRightMargin,0)).Width();
     185             : 
     186           0 :         aPageSize.Height() = m_aHRuler.GetSizePixel().Height();
     187             : 
     188           0 :         const long nTermp(m_aViewsWindow.getTotalHeight() + aPageSize.Height());
     189           0 :         long nSectionsHeight = ::std::max<long>(nTermp,aTotalOutputSize.Height());
     190             : 
     191           0 :         m_aHRuler.SetPosSizePixel(aStartPoint,aPageSize);
     192           0 :         m_aHRuler.SetNullOffset(nLeftMargin);
     193           0 :         m_aHRuler.SetMargin1(0);
     194           0 :         m_aHRuler.SetMargin2(aPageSize.Width() - nLeftMargin - nRightMargin);
     195             : 
     196           0 :         aStartPoint.Y() += aPageSize.Height();
     197           0 :         nSectionsHeight -= aStartPoint.Y();
     198             : 
     199           0 :         aStartPoint.X() = aOffset.X();
     200             : 
     201           0 :         m_aViewsWindow.SetPosSizePixel(aStartPoint,Size(aTotalOutputSize.Width(),nSectionsHeight));
     202             :     }
     203           0 : }
     204             : 
     205           0 : Point OReportWindow::getThumbPos() const
     206             : {
     207           0 :     return m_pParent->getThumbPos();
     208             : }
     209             : 
     210           0 : void OReportWindow::ImplInitSettings()
     211             : {
     212           0 :     SetBackground( );
     213           0 : }
     214             : 
     215           0 : void OReportWindow::DataChanged( const DataChangedEvent& rDCEvt )
     216             : {
     217           0 :     Window::DataChanged( rDCEvt );
     218             : 
     219           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     220           0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     221             :     {
     222           0 :         ImplInitSettings();
     223           0 :         Invalidate();
     224             :     }
     225           0 : }
     226             : 
     227           0 : sal_Int32 OReportWindow::GetTotalHeight() const
     228             : {
     229           0 :     return m_aViewsWindow.getTotalHeight();
     230             : }
     231             : 
     232           0 : void OReportWindow::ScrollChildren(const Point& _aThumbPos)
     233             : {
     234           0 :     MapMode aMap = m_aHRuler.GetMapMode();
     235           0 :     Point aOrg( aMap.GetOrigin() );
     236           0 :     if ( aOrg.X() != (-_aThumbPos.X()) )
     237             :     {
     238           0 :         aMap.SetOrigin( Point(- _aThumbPos.X(), aOrg.Y()));
     239           0 :         m_aHRuler.SetMapMode( aMap );
     240           0 :         m_aHRuler.Scroll(-(aOrg.X() + _aThumbPos.X()),0);
     241             :     }
     242             : 
     243           0 :     m_aViewsWindow.scrollChildren(_aThumbPos);
     244           0 : }
     245             : 
     246           0 : sal_uInt16 OReportWindow::getSectionCount() const
     247             : {
     248           0 :     return m_aViewsWindow.getSectionCount();
     249             : }
     250             : 
     251           0 : void OReportWindow::notifySizeChanged()
     252             : {
     253           0 :     m_pParent->setTotalSize(GetTotalWidth(),GetTotalHeight());
     254           0 : }
     255             : 
     256           0 : bool OReportWindow::HasSelection() const
     257             : {
     258           0 :     return m_aViewsWindow.HasSelection();
     259             : }
     260             : 
     261           0 : void OReportWindow::Delete()
     262             : {
     263             : 
     264           0 :     m_aViewsWindow.Delete();
     265           0 : }
     266             : 
     267           0 : void OReportWindow::Copy()
     268             : {
     269             : 
     270           0 :     m_aViewsWindow.Copy();
     271           0 : }
     272             : 
     273           0 : void OReportWindow::Paste()
     274             : {
     275             : 
     276           0 :     m_aViewsWindow.Paste();
     277           0 : }
     278             : 
     279           0 : bool OReportWindow::IsPasteAllowed() const
     280             : {
     281           0 :     return m_aViewsWindow.IsPasteAllowed();
     282             : }
     283             : 
     284           0 : void OReportWindow::SelectAll(const sal_uInt16 _nObjectType)
     285             : {
     286             : 
     287           0 :     m_aViewsWindow.SelectAll(_nObjectType);
     288           0 : }
     289             : 
     290           0 : void OReportWindow::unmarkAllObjects(OSectionView* _pSectionView)
     291             : {
     292             : 
     293           0 :     m_aViewsWindow.unmarkAllObjects(_pSectionView);
     294           0 : }
     295             : 
     296           0 : void OReportWindow::showProperties(const uno::Reference< report::XSection>& _xReportComponent)
     297             : {
     298           0 :     ::boost::shared_ptr<OSectionWindow> pSectionWindow = m_aViewsWindow.getSectionWindow( _xReportComponent );
     299           0 :     m_pView->UpdatePropertyBrowserDelayed(pSectionWindow->getReportSection().getSectionView());
     300           0 : }
     301             : 
     302           0 : bool OReportWindow::handleKeyEvent(const KeyEvent& _rEvent)
     303             : {
     304           0 :     return m_aViewsWindow.handleKeyEvent(_rEvent);
     305             : }
     306             : 
     307           0 : void OReportWindow::setMarked(OSectionView* _pSectionView, bool _bMark)
     308             : {
     309           0 :     if ( _pSectionView )
     310           0 :         m_aViewsWindow.setMarked(_pSectionView,_bMark);
     311           0 : }
     312             : 
     313           0 : void OReportWindow::setMarked(const uno::Reference< report::XSection>& _xSection, bool _bMark)
     314             : {
     315             : 
     316           0 :     m_aViewsWindow.setMarked(_xSection,_bMark);
     317           0 : }
     318             : 
     319           0 : void OReportWindow::setMarked(const uno::Sequence< uno::Reference< report::XReportComponent> >& _xShape, bool _bMark)
     320             : {
     321             : 
     322           0 :     m_aViewsWindow.setMarked(_xShape,_bMark);
     323           0 : }
     324             : 
     325           0 : ::boost::shared_ptr<OSectionWindow> OReportWindow::getMarkedSection(NearSectionAccess nsa) const
     326             : {
     327           0 :     return  m_aViewsWindow.getMarkedSection(nsa);
     328             : }
     329             : 
     330           0 : ::boost::shared_ptr<OSectionWindow> OReportWindow::getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const
     331             : {
     332           0 :     return  m_aViewsWindow.getSectionWindow(_xSection);
     333             : }
     334             : 
     335           0 : void OReportWindow::markSection(const sal_uInt16 _nPos)
     336             : {
     337             : 
     338           0 :     m_aViewsWindow.markSection(_nPos);
     339           0 : }
     340             : 
     341           0 : void OReportWindow::fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const
     342             : {
     343             : 
     344           0 :     m_aViewsWindow.fillCollapsedSections(_rCollapsedPositions);
     345           0 : }
     346             : 
     347           0 : void OReportWindow::collapseSections(const uno::Sequence< ::com::sun::star::beans::PropertyValue>& _aCollpasedSections)
     348             : {
     349             : 
     350           0 :     m_aViewsWindow.collapseSections(_aCollpasedSections);
     351           0 : }
     352             : 
     353           0 : void OReportWindow::alignMarkedObjects(sal_Int32 _nControlModification,bool _bAlignAtSection, bool bBoundRects)
     354             : {
     355             : 
     356           0 :     m_aViewsWindow.alignMarkedObjects(_nControlModification, _bAlignAtSection, bBoundRects);
     357           0 : }
     358             : 
     359           0 : void OReportWindow::setGridSnap(bool bOn)
     360             : {
     361             : 
     362           0 :     m_aViewsWindow.setGridSnap(bOn);
     363           0 : }
     364             : 
     365           0 : void OReportWindow::setDragStripes(bool bOn)
     366             : {
     367           0 :     m_aViewsWindow.setDragStripes(bOn);
     368           0 : }
     369             : 
     370           0 : sal_uInt32 OReportWindow::getMarkedObjectCount() const
     371             : {
     372           0 :     return m_aViewsWindow.getMarkedObjectCount();
     373             : }
     374             : 
     375           0 : void OReportWindow::zoom(const Fraction& _aZoom)
     376             : {
     377           0 :     m_aHRuler.SetZoom(_aZoom);
     378           0 :     m_aHRuler.Invalidate();
     379             : 
     380           0 :     m_aViewsWindow.zoom(_aZoom);
     381             : 
     382           0 :     notifySizeChanged();
     383           0 :     const Point aNewThumbPos( m_pParent->getThumbPos() );
     384             : 
     385           0 :     ScrollChildren( aNewThumbPos );
     386           0 :     Resize();
     387             : 
     388           0 :     Invalidate(INVALIDATE_NOERASE | INVALIDATE_NOCHILDREN | INVALIDATE_TRANSPARENT);
     389           0 : }
     390             : 
     391           0 : void OReportWindow::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const
     392             : {
     393           0 :     m_aViewsWindow.fillControlModelSelection(_rSelection);
     394           0 : }
     395             : 
     396           0 : sal_Int32 OReportWindow::impl_getRealPixelWidth() const
     397             : {
     398           0 :     const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_pView->getController().getReportDefinition(),PROPERTY_PAPERSIZE).Width;
     399           0 :     MapMode aMap( MAP_100TH_MM );
     400           0 :     const Size aPageSize = LogicToPixel(Size(nPaperWidth,0),aMap);
     401           0 :     return aPageSize.Width() + REPORT_ENDMARKER_WIDTH + REPORT_STARTMARKER_WIDTH + SECTION_OFFSET;
     402             : }
     403             : 
     404           0 : sal_uInt16 OReportWindow::getZoomFactor(SvxZoomType _eType) const
     405             : {
     406           0 :     sal_uInt16 nZoom(100);
     407           0 :     const Size aSize( GetSizePixel() );
     408           0 :     switch( _eType)
     409             :     {
     410             :         case SVX_ZOOM_PERCENT:
     411           0 :             nZoom = m_pView->getController().getZoomValue();
     412           0 :             break;
     413             :         case SVX_ZOOM_OPTIMAL:
     414           0 :             break;
     415             :         case SVX_ZOOM_WHOLEPAGE:
     416             :             {
     417           0 :                 nZoom = (sal_uInt16)(long)Fraction(aSize.Width()*100,impl_getRealPixelWidth());
     418           0 :                 MapMode aMap( MAP_100TH_MM );
     419           0 :                 const Size aHeight = m_aViewsWindow.LogicToPixel(m_aViewsWindow.PixelToLogic(Size(0,GetTotalHeight() + m_aHRuler.GetSizePixel().Height())),aMap);
     420           0 :                 nZoom = ::std::min(nZoom,(sal_uInt16)(long)Fraction(aSize.Height()*100,aHeight.Height()));
     421             :             }
     422           0 :             break;
     423             :         case SVX_ZOOM_PAGEWIDTH:
     424           0 :             nZoom = (sal_uInt16)(long)Fraction(aSize.Width()*100,impl_getRealPixelWidth());
     425           0 :             break;
     426             :         default:
     427           0 :             break;
     428             :     }
     429             : 
     430           0 :     return nZoom;
     431             : }
     432             : 
     433           0 : void OReportWindow::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) throw( uno::RuntimeException)
     434             : {
     435             :     (void)_rEvent;
     436           0 :     Resize();
     437           0 :     m_aViewsWindow.Resize();
     438             :     static sal_Int32 nIn = INVALIDATE_TRANSPARENT;
     439           0 :     Invalidate(nIn);
     440           0 : }
     441             : 
     442           6 : }   //rptui
     443             : 
     444             : 
     445             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10