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

Generated by: LCOV version 1.11