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

Generated by: LCOV version 1.10