LCOV - code coverage report
Current view: top level - reportdesign/source/ui/inc - ViewsWindow.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 17 0.0 %
Date: 2012-08-25 Functions: 0 7 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10