LCOV - code coverage report
Current view: top level - reportdesign/source/ui/inc - ViewsWindow.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 17 0.0 %
Date: 2014-04-14 Functions: 0 7 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             : #ifndef RPTUI_VIEWSWINDOW_HXX
      20             : #define RPTUI_VIEWSWINDOW_HXX
      21             : 
      22             : #include <com/sun/star/report/XSection.hpp>
      23             : #include <vcl/window.hxx>
      24             : #include <svtools/colorcfg.hxx>
      25             : #include "ReportDefines.hxx"
      26             : #include "ReportSection.hxx"
      27             : #include <comphelper/propmultiplex.hxx>
      28             : #include "cppuhelper/basemutex.hxx"
      29             : #include <com/sun/star/beans/NamedValue.hpp>
      30             : #include <svx/svdedtv.hxx>
      31             : #include <SectionView.hxx>
      32             : #include <unotools/options.hxx>
      33             : #include <list>
      34             : #include <vector>
      35             : #include <boost/shared_ptr.hpp>
      36             : 
      37             : #include <MarkedSection.hxx>
      38             : #include <SectionWindow.hxx>
      39             : 
      40             : class SdrHdl;
      41             : namespace rptui
      42             : {
      43             :     class OReportWindow;
      44             :     class OReportSection;
      45             :     class OSectionView;
      46             : 
      47             : 
      48             : 
      49             :     struct RectangleLess : public ::std::binary_function< Rectangle, Rectangle, bool>
      50             :     {
      51             :         enum CompareMode { POS_LEFT,POS_RIGHT,POS_UPPER,POS_DOWN,POS_CENTER_HORIZONTAL,POS_CENTER_VERTICAL };
      52             :         CompareMode m_eCompareMode;
      53             :         Point       m_aRefPoint;
      54           0 :         RectangleLess(CompareMode _eCompareMode,const Point& _rRefPoint ) : m_eCompareMode(_eCompareMode),m_aRefPoint(_rRefPoint){}
      55           0 :         bool operator() (const Rectangle& lhs, const Rectangle& rhs) const
      56             :         {
      57           0 :             switch(m_eCompareMode)
      58             :             {
      59             :             case POS_LEFT:
      60           0 :                 return lhs.Left() < rhs.Left();
      61             :             case POS_RIGHT:
      62           0 :                 return lhs.Right() >= rhs.Right();
      63             :             case POS_UPPER:
      64           0 :                 return lhs.Top() < rhs.Top();
      65             :             case POS_DOWN:
      66           0 :                 return lhs.Bottom() >= rhs.Bottom();
      67             :             case POS_CENTER_HORIZONTAL:
      68           0 :                 return std::abs(m_aRefPoint.X() - lhs.Center().X()) < std::abs(m_aRefPoint.X() - rhs.Center().X());
      69             :             case POS_CENTER_VERTICAL:
      70           0 :                 return std::abs(lhs.Center().Y() - m_aRefPoint.Y()) < std::abs(rhs.Center().Y() - m_aRefPoint.Y());
      71             :             }
      72           0 :             return false;
      73             :         }
      74             :     };
      75             : 
      76             :     class OWindowPositionCorrector
      77             :     {
      78             :         ::std::vector< ::std::pair<Window*,Point> > m_aChildren;
      79             :         long m_nDeltaX;
      80             :         long m_nDeltaY;
      81             :     public:
      82             :         OWindowPositionCorrector(Window* _pWindow,long _nDeltaX, long _nDeltaY) :m_nDeltaX(_nDeltaX), m_nDeltaY(_nDeltaY)
      83             :         {
      84             :             sal_uInt16 nCount = _pWindow->GetChildCount();
      85             :             m_aChildren.reserve(nCount);
      86             :             while( nCount )
      87             :             {
      88             :                 Window* pChild = _pWindow->GetChild(--nCount);
      89             :                 m_aChildren.push_back(::std::pair<Window*,Point>(pChild,pChild->GetPosPixel()));
      90             :             }
      91             :         }
      92             :         ~OWindowPositionCorrector()
      93             :         {
      94             :             ::std::vector< ::std::pair<Window*,Point> >::iterator aIter = m_aChildren.begin();
      95             :             ::std::vector< ::std::pair<Window*,Point> >::iterator aEnd = m_aChildren.end();
      96             :             for (; aIter != aEnd; ++aIter)
      97             :             {
      98             :                 const Point aPos = aIter->first->GetPosPixel();
      99             :                 if ( aPos == aIter->second )
     100             :                     aIter->first->SetPosPixel(Point(m_nDeltaX,m_nDeltaY) + aPos);
     101             :             }
     102             :         }
     103             :     };
     104             : 
     105             :     class OViewsWindow :    public Window
     106             :                         ,   public utl::ConfigurationListener
     107             :                         ,   public IMarkedSection
     108             :     {
     109             :         typedef ::std::multimap<Rectangle,::std::pair<SdrObject*,OSectionView*>,RectangleLess>      TRectangleMap;
     110             :     public:
     111             :         typedef ::std::vector< ::boost::shared_ptr<OSectionWindow> >                                TSectionsMap;
     112             : 
     113             :         struct TReportPairHelper : public ::std::unary_function< TSectionsMap::value_type, OReportSection >
     114             :         {
     115           0 :             OReportSection& operator() (const TSectionsMap::value_type& lhs) const
     116             :             {
     117           0 :                 return lhs->getReportSection();
     118             :             }
     119             :         };
     120             :         struct TStartMarkerHelper : public ::std::unary_function< TSectionsMap::value_type, OStartMarker >
     121             :         {
     122           0 :             OStartMarker& operator() (const TSectionsMap::value_type& lhs) const
     123             :             {
     124           0 :                 return lhs->getStartMarker();
     125             :             }
     126             :         };
     127             :     private:
     128             :         TSectionsMap                            m_aSections;
     129             :         svtools::ColorConfig                    m_aColorConfig;
     130             :         OReportWindow*                          m_pParent;
     131             :         OUString                         m_sShapeType;
     132             :         sal_Bool                                m_bInUnmark;
     133             : 
     134             :         void ImplInitSettings();
     135             :         /** returns the iterator at pos _nPos or the end()
     136             :         */
     137             :         TSectionsMap::iterator getIteratorAtPos(sal_uInt16 _nPos);
     138             :         void collectRectangles(TRectangleMap& _rMap,bool _bBoundRects);
     139             :         void collectBoundResizeRect(const TRectangleMap& _rSortRectangles,sal_Int32 _nControlModification,bool _bAlignAtSection,bool _bBoundRects,Rectangle& _rBound,Rectangle& _rResize);
     140             :         void impl_resizeSectionWindow(OSectionWindow& _rSectionWindow,Point& _rStartPoint,bool _bSet);
     141             : 
     142             :         OViewsWindow(OViewsWindow&);
     143             :         void operator =(OViewsWindow&);
     144             :     protected:
     145             :         virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     146             :         // windows overload
     147             :         virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     148             :         virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     149             : 
     150             :         virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
     151             :         virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ) SAL_OVERRIDE;
     152             :     public:
     153             :         OViewsWindow(
     154             :             OReportWindow* _pReportWindow);
     155             :         virtual ~OViewsWindow();
     156             : 
     157             :         // windows overload
     158             :         virtual void Resize() SAL_OVERRIDE;
     159             : 
     160             :         void resize(const OSectionWindow& _rSectionWindow);
     161             : 
     162             :         /** late ctor
     163             :         */
     164             :         void initialize();
     165             : 
     166           0 :         inline OReportWindow*       getView()           const { return m_pParent; }
     167             : 
     168             :         /** removes the section at the given position.
     169             :         *
     170             :         * \param _nPosition Zero based.
     171             :         */
     172             :         void            removeSection(sal_uInt16 _nPosition);
     173             : 
     174             :         /** adds a new section at position _nPosition.
     175             :             If the section is <NULL/> nothing happens.
     176             :             If the position is grater than the current elements, the section will be appended.
     177             :         */
     178             :         void            addSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection
     179             :                                     ,const OUString& _sColorEntry
     180             :                                     ,sal_uInt16 _nPosition = USHRT_MAX);
     181             : 
     182             :         sal_uInt16          getSectionCount() const;
     183             :         /** return the section at the given position
     184             :         *
     185             :         * \param _nPos
     186             :         * \return the section at this pos or an empty section
     187             :         */
     188             :         ::boost::shared_ptr<OSectionWindow> getSectionWindow(const sal_uInt16 _nPos) const;
     189             : 
     190             :         /** turns the grid on or off
     191             :         *
     192             :         * \param _bVisible
     193             :         */
     194             :         void            toggleGrid(sal_Bool _bVisible);
     195             :         void            setGridSnap(sal_Bool bOn);
     196             :         void            setDragStripes(sal_Bool bOn);
     197             : 
     198             :         /** returns the total accumulated height of all sections until _pSection is reached
     199             :         */
     200             :         sal_Int32       getTotalHeight() const;
     201             : 
     202           0 :         inline bool     empty() const { return m_aSections.empty(); }
     203             :         void            SetMode( DlgEdMode m_eMode );
     204             :         void            SetInsertObj( sal_uInt16 eObj,const OUString& _sShapeType = OUString());
     205             :         OUString   GetInsertObjString() const;
     206             :         /** copies the current selection in this section
     207             :         */
     208             :         void Copy();
     209             : 
     210             :         /** returns if paste is allowed
     211             :         *
     212             :         * \return <TRUE/> if paste is allowed
     213             :         */
     214             :         sal_Bool IsPasteAllowed() const;
     215             : 
     216             :         /** paste a new control in this section
     217             :         */
     218             :         void Paste();
     219             : 
     220             :         /** Deletes the current selection in this section
     221             :         *
     222             :         */
     223             :         void Delete();
     224             : 
     225             :         /** All objects will be marked.
     226             :         */
     227             :         void SelectAll(const sal_uInt16 _nObjectType);
     228             : 
     229             :         /** returns <TRUE/> when a object is marked
     230             :         */
     231             :         sal_Bool HasSelection() const;
     232             : 
     233             :         /** unmark all objects on the views without the given one.
     234             :         *
     235             :         * @param _pSectionView The view where the objects should not be unmarked.
     236             :         */
     237             :         void            unmarkAllObjects(OSectionView* _pSectionView);
     238             : 
     239             :         /** returns the report section window for the given xsection
     240             :             @param  _xSection   the section
     241             :         */
     242             :         ::boost::shared_ptr<OSectionWindow> getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const;
     243             : 
     244             :         /** checks if the keycode is known by the child windows
     245             :             @param  _rCode  the keycode
     246             :             @return <TRUE/> if the keycode is handled otherwise <FALSE/>
     247             :         */
     248             :         sal_Bool        handleKeyEvent(const KeyEvent& _rEvent);
     249             : 
     250             :         /** the section as marked or not marked
     251             :             @param  _pSectionView   the section where to set the marked flag
     252             :             @param  _bMark  the marked flag
     253             :         */
     254             :         void            setMarked(OSectionView* _pSectionView,sal_Bool _bMark);
     255             :         void            setMarked(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection,sal_Bool _bMark);
     256             :         void            setMarked(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> >& _xShape,sal_Bool _bMark);
     257             : 
     258             :         // IMarkedSection
     259             :         ::boost::shared_ptr<OSectionWindow> getMarkedSection(NearSectionAccess nsa = CURRENT) const SAL_OVERRIDE;
     260             :         virtual void markSection(const sal_uInt16 _nPos) SAL_OVERRIDE;
     261             : 
     262             :         /** align all marked objects in all sections
     263             :         */
     264             :         void alignMarkedObjects(sal_Int32 _nControlModification,bool _bAlignAtSection, bool bBoundRects = false);
     265             : 
     266             :         /** creates a default object
     267             :         *
     268             :         */
     269             :         void createDefault();
     270             : 
     271             :         /** shows or hides the ruler.
     272             :         */
     273             :         void showRuler(sal_Bool _bShow);
     274             : 
     275             :         /** returns the currently set shape type.
     276             :         *
     277             :         * \return \member m_sShapeType
     278             :         */
     279           0 :         inline OUString getShapeType() const { return m_sShapeType; }
     280             : 
     281             :         /** returns the current position in the list
     282             :         */
     283             :         sal_uInt16 getPosition(const OSectionWindow* _pSectionWindow = NULL) const;
     284             : 
     285             :         /** calls on every section BrkAction
     286             :         *
     287             :         */
     288             :         void BrkAction();
     289             :         void BegMarkObj(const Point& _aPnt,const OSectionView* _pSection);
     290             : 
     291             :     private:
     292             :         void BegDragObj_createInvisibleObjectAtPosition(const Rectangle& _aRect, const OSectionView& _rSection);
     293             :         void EndDragObj_removeInvisibleObjects();
     294             :         Point m_aDragDelta;
     295             :         ::std::vector<SdrObject*> m_aBegDragTempList;
     296             :         bool isObjectInMyTempList(SdrObject *);
     297             :     public:
     298             :         void BegDragObj(const Point& _aPnt, SdrHdl* _pHdl,const OSectionView* _pSection);
     299             :         void EndDragObj(sal_Bool _bDragIntoNewSection,const OSectionView* _pSection,const Point& _aPnt);
     300             : 
     301             :         void EndAction();
     302             :         void ForceMarkedToAnotherPage();
     303             :         sal_Bool IsAction() const;
     304             :         sal_Bool IsDragObj() const;
     305             :         void handleKey(const KeyCode& _rCode);
     306             :         void stopScrollTimer();
     307             : 
     308             :         /** return the section at the given point which is relative to the given section
     309             :         *
     310             :         * \param _pSection the section which is used as reference point
     311             :         * \param _rPnt the point, it will be changed that it is inside the section which will be returned
     312             :         * \return the section
     313             :         */
     314             :         OSectionView* getSectionRelativeToPosition(const OSectionView* _pSection,Point& _rPnt);
     315             : 
     316             :         void MovAction(const Point& rPnt,const OSectionView* _pSection,bool _bMove /*= true */, bool _bControlKeySet);
     317             : 
     318             :         sal_uInt32 getMarkedObjectCount() const;
     319             : 
     320             :         /** fills the positions of all collapsed sections.
     321             :         *
     322             :         * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
     323             :         */
     324             :         void fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const;
     325             : 
     326             :         /** collpase all sections given by their position
     327             :         *
     328             :         * \param _aCollpasedSections The position of the sections which should be collapsed.
     329             :         */
     330             :         void collapseSections(const com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& _aCollpasedSections);
     331             : 
     332             :         /** zoom the ruler and view windows
     333             :         */
     334             :         void zoom(const Fraction& _aZoom);
     335             : 
     336             :         void scrollChildren(const Point& _aThumbPos);
     337             : 
     338             :         /** fills the vector with all selected control models
     339             :             /param  _rSelection The vector will be filled and will not be cleared before.
     340             :         */
     341             :         void fillControlModelSelection(::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& _rSelection) const;
     342             :     };
     343             : 
     344             : } // rptui
     345             : 
     346             : #endif // RPTUI_VIEWSWINDOW_HXX
     347             : 
     348             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10