LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/inc/view - SlsLayouter.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 9 0.0 %
Date: 2012-08-25 Functions: 0 9 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                 :            : 
      29                 :            : #ifndef SD_SLIDESORTER_VIEW_LAYOUTER_HXX
      30                 :            : #define SD_SLIDESORTER_VIEW_LAYOUTER_HXX
      31                 :            : 
      32                 :            : #include "SlideSorter.hxx"
      33                 :            : #include "view/SlsPageObjectLayouter.hxx"
      34                 :            : #include "view/SlsTheme.hxx"
      35                 :            : #include <sal/types.h>
      36                 :            : #include <tools/fract.hxx>
      37                 :            : #include <vcl/mapmod.hxx>
      38                 :            : #include <vector>
      39                 :            : #include <utility>
      40                 :            : 
      41                 :            : 
      42                 :            : class Size;
      43                 :            : 
      44                 :            : namespace sd { namespace slidesorter { namespace view {
      45                 :            : 
      46                 :            : class InsertPosition;
      47                 :            : 
      48                 :            : 
      49                 :            : 
      50                 :            : /** Calculate the size and position of page objects displayed by a slide
      51                 :            :     sorter.  The layouter takes into account various input values:
      52                 :            :     1.) Size of the window in which the slide sorter is displayed.
      53                 :            :     2.) Desired and minimal and maximal widths of page objects.
      54                 :            :     3.) Minimal and maximal number of columns.
      55                 :            :     4.) Vertical and horizontal gaps between objects in adjacent columns.
      56                 :            :     5.) Borders arround every page object.
      57                 :            :     6.) Vertical and horizontal borders between enclosing page and outer
      58                 :            :         page objects.
      59                 :            :     From these it calculates various output values:
      60                 :            :     1.) The width of page objects.
      61                 :            :     2.) The number of columns.
      62                 :            :     3.) The size of the enclosing page.
      63                 :            : 
      64                 :            :     <p>Sizes and lengths are all in pixel except where explicitly stated
      65                 :            :     otherwise.</p>
      66                 :            : 
      67                 :            :     <p>The GetIndex... methods may return indices that are larger than or
      68                 :            :     equal to (zero based) the number of pages.  This is so because the
      69                 :            :     number of pages is not known to the class instances.  Indices are
      70                 :            :     calculated with reference to the general grid layout of page
      71                 :            :     objects.</p>
      72                 :            : */
      73                 :            : class Layouter
      74                 :            : {
      75                 :            : public:
      76                 :            :     enum Orientation { HORIZONTAL, VERTICAL, GRID };
      77                 :            : 
      78                 :            :     Layouter (
      79                 :            :         const SharedSdWindow& rpWindow,
      80                 :            :         const ::boost::shared_ptr<Theme>& rpTheme);
      81                 :            :     ~Layouter (void);
      82                 :            : 
      83                 :            :     ::boost::shared_ptr<PageObjectLayouter> GetPageObjectLayouter (void) const;
      84                 :            :     /** Set the interval of valid column counts.  When nMinimalColumnCount
      85                 :            :         <= nMaximalColumnCount is not fullfilled then the call is ignored.
      86                 :            :         @param nMinimalColumnCount
      87                 :            :             The default value is 1.  The question whether higher values make
      88                 :            :             any sense is left to the caller.
      89                 :            :         @param nMaximalColumnCount
      90                 :            :             The default value is 5.
      91                 :            :     */
      92                 :            :     void SetColumnCount (sal_Int32 nMinimalColumnCount,
      93                 :            :         sal_Int32 nMaximalColumnCount);
      94                 :            : 
      95                 :            :     /** Central method of this class.  It takes the input values and
      96                 :            :         calculates the output values.  Both given sizes must not be 0 in any
      97                 :            :         dimension or the call is ignored.
      98                 :            :         @param eOrientation
      99                 :            :             This defines the generaly layout and specifies whether there may
     100                 :            :             be more than one row or more than one column.
     101                 :            :         @param rWindowSize
     102                 :            :             The size of the window in pixels that the slide sorter is
     103                 :            :             displayed in.  This can differ from the size of mpWindow during
     104                 :            :             detection of whether or not the scroll bars should be visible.
     105                 :            :         @param rPreviewModelSize
     106                 :            :             Size of each page in model coordinates.
     107                 :            :         @param rpWindow
     108                 :            :             The map mode of this window is adapted to the new layout of the
     109                 :            :             page objects.
     110                 :            :         @return
     111                 :            :             The return value indicates whether the Get... methods can be
     112                 :            :             used to obtain valid values (<TRUE/>).
     113                 :            :     */
     114                 :            :     bool Rearrange (
     115                 :            :         const Orientation eOrientation,
     116                 :            :         const Size& rWindowSize,
     117                 :            :         const Size& rPreviewModelSize,
     118                 :            :         const sal_uInt32 nPageCount);
     119                 :            : 
     120                 :            :     /** Return the number of columns.
     121                 :            :     */
     122                 :            :     sal_Int32 GetColumnCount (void) const;
     123                 :            : 
     124                 :            :     sal_Int32 GetIndex (const sal_Int32 nRow, const sal_Int32 nColumn) const;
     125                 :            : 
     126                 :            :     /** Return the scale factor that can be set at the map mode of the
     127                 :            :         output window.
     128                 :            :     */
     129                 :            :     Fraction GetScaleFactor (void) const;
     130                 :            : 
     131                 :            :     Size GetPageObjectSize (void) const;
     132                 :            : 
     133                 :            :     /** Return the bounding box in window coordinates of the nIndex-th page
     134                 :            :         object.
     135                 :            :     */
     136                 :            :     Rectangle GetPageObjectBox (
     137                 :            :         const sal_Int32 nIndex,
     138                 :            :         const bool bIncludeBorderAndGap = false) const;
     139                 :            : 
     140                 :            :     /** Return the bounding box in model coordinates of the page that
     141                 :            :         contains the given amount of page objects.
     142                 :            :     */
     143                 :            :     Rectangle GetTotalBoundingBox (void) const;
     144                 :            : 
     145                 :            :     /** Return the index of the first fully or partially visible page
     146                 :            :         object.  This takes into account only the vertical dimension.
     147                 :            :         @return
     148                 :            :             The second index may be larger than the number of existing
     149                 :            :             page objects.
     150                 :            :     */
     151                 :            :     Range GetRangeOfVisiblePageObjects (const Rectangle& rVisibleArea) const;
     152                 :            : 
     153                 :            :     /** Return the index of the page object that is rendered at the given
     154                 :            :         point.
     155                 :            :         @param rPosition
     156                 :            :             The position is expected to be in model coordinates relative to
     157                 :            :             the page origin.
     158                 :            :         @param bIncludePageBorders
     159                 :            :             When <TRUE/> then include the page borders into the calculation,
     160                 :            :             i.e. when a point lies in the border of a page object but not on
     161                 :            :             the actual page area the index of that page is returned;
     162                 :            :             otherwise -1 would be returned to indicate that no page object
     163                 :            :             has been hit.
     164                 :            :         @param bClampToValidRange
     165                 :            :             When <TRUE/> then values outside the valid range [0,mnPageCount)
     166                 :            :             are mapped to 0 (when smaller than 0) or mnPageCount-1 when
     167                 :            :             equal to or larger than mnPageCount.
     168                 :            :             When <FALSE/> then -1 is returned for values outside the valid range.
     169                 :            :         @return
     170                 :            :             The returned index may be larger than the number of existing
     171                 :            :             page objects.
     172                 :            :     */
     173                 :            :     sal_Int32 GetIndexAtPoint (
     174                 :            :         const Point& rModelPosition,
     175                 :            :         const bool bIncludePageBorders = false,
     176                 :            :         const bool bClampToValidRange = true) const;
     177                 :            : 
     178                 :            :     /** Return an object that describes the logical and visual properties of
     179                 :            :         where to do an insert operation when the user would release the the
     180                 :            :         mouse button at the given position after a drag operation and of
     181                 :            :         where and how to display an insertion indicator.
     182                 :            :         @param rModelPosition
     183                 :            :             The position in the model coordinate system for which to
     184                 :            :             determine the insertion page index.  The position does not have
     185                 :            :             to be over a page object to return a valid value.
     186                 :            :         @param rIndicatorSize
     187                 :            :             The size of the insertion indicator.  This size is used to adapt
     188                 :            :             the location when at the left or right of a row or at the top or
     189                 :            :             bottom of a column.
     190                 :            :         @param rModel
     191                 :            :             The model is used to get access to the selection states of the
     192                 :            :             pages.  This in turn is used to determine the visual bounding
     193                 :            :             boxes.
     194                 :            :     */
     195                 :            :     InsertPosition GetInsertPosition (
     196                 :            :         const Point& rModelPosition,
     197                 :            :         const Size& rIndicatorSize,
     198                 :            :         model::SlideSorterModel& rModel) const;
     199                 :            : 
     200                 :            :     Range GetValidHorizontalSizeRange (void) const;
     201                 :            :     Range GetValidVerticalSizeRange (void) const;
     202                 :            : 
     203                 :            :     class Implementation;
     204                 :            : 
     205                 :            : private:
     206                 :            :     ::boost::scoped_ptr<Implementation> mpImplementation;
     207                 :            :     SharedSdWindow mpWindow;
     208                 :            : };
     209                 :            : 
     210                 :            : 
     211                 :            : 
     212                 :            : 
     213                 :            : 
     214                 :            : /** Collect all values concerning the logical and visual properties of the
     215                 :            :     insertion position that is used for drag-and-drop and copy-and-past.
     216                 :            : */
     217                 :            : class InsertPosition
     218                 :            : {
     219                 :            : public:
     220                 :            :     InsertPosition (void);
     221                 :            :     InsertPosition& operator= (const InsertPosition& rInsertPosition);
     222                 :            :     bool operator== (const InsertPosition& rInsertPosition) const;
     223                 :            :     bool operator!= (const InsertPosition& rInsertPosition) const;
     224                 :            : 
     225                 :            :     void SetLogicalPosition (
     226                 :            :         const sal_Int32 nRow,
     227                 :            :         const sal_Int32 nColumn,
     228                 :            :         const sal_Int32 nIndex,
     229                 :            :         const bool bIsAtRunStart,
     230                 :            :         const bool bIsAtRunEnd,
     231                 :            :         const bool bIsExtraSpaceNeeded);
     232                 :            :     void SetGeometricalPosition(
     233                 :            :         const Point aLocation,
     234                 :            :         const Point aLeadingOffset,
     235                 :            :         const Point aTrailingOffset);
     236                 :            : 
     237                 :          0 :     sal_Int32 GetRow (void) const { return mnRow; }
     238                 :          0 :     sal_Int32 GetColumn (void) const { return mnColumn; }
     239                 :          0 :     sal_Int32 GetIndex (void) const { return mnIndex; }
     240                 :          0 :     Point GetLocation (void) const { return maLocation; }
     241                 :          0 :     Point GetLeadingOffset (void) const { return maLeadingOffset; }
     242                 :          0 :     Point GetTrailingOffset (void) const { return maTrailingOffset; }
     243                 :          0 :     bool IsAtRunStart (void) const { return mbIsAtRunStart; }
     244                 :          0 :     bool IsAtRunEnd (void) const { return mbIsAtRunEnd; }
     245                 :          0 :     bool IsExtraSpaceNeeded (void) const { return mbIsExtraSpaceNeeded; }
     246                 :            : 
     247                 :            : private:
     248                 :            :     sal_Int32 mnRow;
     249                 :            :     sal_Int32 mnColumn;
     250                 :            :     sal_Int32 mnIndex;
     251                 :            :     bool mbIsAtRunStart : 1;
     252                 :            :     bool mbIsAtRunEnd : 1;
     253                 :            :     bool mbIsExtraSpaceNeeded : 1;
     254                 :            :     Point maLocation;
     255                 :            :     Point maLeadingOffset;
     256                 :            :     Point maTrailingOffset;
     257                 :            : };
     258                 :            : 
     259                 :            : 
     260                 :            : 
     261                 :            : } } } // end of namespace ::sd::slidesorter::view
     262                 :            : 
     263                 :            : #endif
     264                 :            : 
     265                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10