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

Generated by: LCOV version 1.10