xref: /AOO41X/main/sd/source/ui/slidesorter/view/SlsLayouter.cxx (revision 5b1900111deff329a5580f97b99b67a25168e53d)
1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5b190011SAndrew Rist  * distributed with this work for additional information
6*5b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist  * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*5b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*5b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist  * software distributed under the License is distributed on an
15*5b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
17*5b190011SAndrew Rist  * specific language governing permissions and limitations
18*5b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*5b190011SAndrew Rist  *************************************************************/
21*5b190011SAndrew Rist 
22*5b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "precompiled_sd.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "view/SlsLayouter.hxx"
27cdf0e10cSrcweir #include "model/SlideSorterModel.hxx"
28cdf0e10cSrcweir #include "model/SlsPageDescriptor.hxx"
29cdf0e10cSrcweir #include "Window.hxx"
30cdf0e10cSrcweir #include <rtl/math.hxx>
31cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace {
RoundToInt(const double nValue)34cdf0e10cSrcweir     sal_Int32 RoundToInt (const double nValue)
35cdf0e10cSrcweir     {
36cdf0e10cSrcweir         return sal_Int32(::rtl::math::round(nValue));
37cdf0e10cSrcweir     }
38cdf0e10cSrcweir }
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace sd { namespace slidesorter { namespace view {
42cdf0e10cSrcweir 
43cdf0e10cSrcweir class Layouter::Implementation
44cdf0e10cSrcweir {
45cdf0e10cSrcweir public:
46cdf0e10cSrcweir     SharedSdWindow mpWindow;
47cdf0e10cSrcweir     sal_Int32 mnRequestedLeftBorder;
48cdf0e10cSrcweir     sal_Int32 mnRequestedRightBorder;
49cdf0e10cSrcweir     sal_Int32 mnRequestedTopBorder;
50cdf0e10cSrcweir     sal_Int32 mnRequestedBottomBorder;
51cdf0e10cSrcweir     sal_Int32 mnLeftBorder;
52cdf0e10cSrcweir     sal_Int32 mnRightBorder;
53cdf0e10cSrcweir     sal_Int32 mnTopBorder;
54cdf0e10cSrcweir     sal_Int32 mnBottomBorder;
55cdf0e10cSrcweir     sal_Int32 mnVerticalGap;
56cdf0e10cSrcweir     sal_Int32 mnHorizontalGap;
57cdf0e10cSrcweir     Size maMinimalSize;
58cdf0e10cSrcweir     Size maPreferredSize;
59cdf0e10cSrcweir     Size maMaximalSize;
60cdf0e10cSrcweir     sal_Int32 mnMinimalColumnCount;
61cdf0e10cSrcweir     sal_Int32 mnMaximalColumnCount;
62cdf0e10cSrcweir     sal_Int32 mnPageCount;
63cdf0e10cSrcweir     sal_Int32 mnColumnCount;
64cdf0e10cSrcweir     sal_Int32 mnRowCount;
65cdf0e10cSrcweir     /// The maximum number of columns.  Can only be larger than the current
66cdf0e10cSrcweir     /// number of columns when there are not enough pages to fill all
67cdf0e10cSrcweir     /// available columns.
68cdf0e10cSrcweir     sal_Int32 mnMaxColumnCount;
69cdf0e10cSrcweir     /// The maximum number of rows.  Can only be larger than the current
70cdf0e10cSrcweir     /// number of rows when there are not enough pages to fill all available
71cdf0e10cSrcweir     /// rows.
72cdf0e10cSrcweir     sal_Int32 mnMaxRowCount;
73cdf0e10cSrcweir     Size maPageObjectSize;
74cdf0e10cSrcweir     ::boost::shared_ptr<PageObjectLayouter> mpPageObjectLayouter;
75cdf0e10cSrcweir     ::boost::shared_ptr<view::Theme> mpTheme;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     /** Specify how the gap between two page objects is associated with the
78cdf0e10cSrcweir       page objects.
79cdf0e10cSrcweir     */
80cdf0e10cSrcweir     enum GapMembership {
81cdf0e10cSrcweir         GM_NONE,       // Gap is not associated with any page object.
82cdf0e10cSrcweir         GM_PREVIOUS,   // The whole gap is associated with the previous page
83cdf0e10cSrcweir                        // object (left or above the gap.)
84cdf0e10cSrcweir         GM_BOTH,       // Half of the gap is associated with previous, half
85cdf0e10cSrcweir                        // with the next page object.
86cdf0e10cSrcweir         GM_NEXT,       // The whole gap is associated with the next page
87cdf0e10cSrcweir                        // object (right or below the gap.)
88cdf0e10cSrcweir         GM_PAGE_BORDER
89cdf0e10cSrcweir     };
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     static Implementation* Create (
92cdf0e10cSrcweir         const Implementation& rImplementation,
93cdf0e10cSrcweir         const Layouter::Orientation eOrientation);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     virtual Layouter::Orientation GetOrientation (void) const = 0;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     bool Rearrange (
98cdf0e10cSrcweir         const Size& rWindowSize,
99cdf0e10cSrcweir         const Size& rPreviewModelSize,
100cdf0e10cSrcweir         const sal_uInt32 nPageCount);
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     /** Calculate the row that the point with the given vertical coordinate
103cdf0e10cSrcweir         is over.  The horizontal component is ignored.
104cdf0e10cSrcweir         @param nYPosition
105cdf0e10cSrcweir             Vertical position in model coordinates.
106cdf0e10cSrcweir         @param bIncludeBordersAndGaps
107cdf0e10cSrcweir             When this flag is <TRUE/> then the area of borders and gaps are
108cdf0e10cSrcweir             interpreted as belonging to one of the rows.
109cdf0e10cSrcweir         @param eGapMembership
110cdf0e10cSrcweir             Specifies to what row the gap areas belong.  Here GM_NONE
111cdf0e10cSrcweir             corresponds to bIncludeBordersAndGaps being <FALSE/>.  When
112cdf0e10cSrcweir             GM_BOTH is given then the upper half is associated to the row
113cdf0e10cSrcweir             above and the lower half to the row below.  Values of
114cdf0e10cSrcweir             GM_PREVIOUS and GM_NEXT associate the whole gap area with the
115cdf0e10cSrcweir             row above or below respectively.
116cdf0e10cSrcweir     */
117cdf0e10cSrcweir     sal_Int32 GetRowAtPosition (
118cdf0e10cSrcweir         sal_Int32 nYPosition,
119cdf0e10cSrcweir         bool bIncludeBordersAndGaps,
120cdf0e10cSrcweir         GapMembership eGapMembership = GM_NONE) const;
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     /** Calculate the column that the point with the given horizontal
123cdf0e10cSrcweir         coordinate is over.  The verical component is ignored.
124cdf0e10cSrcweir         @param nXPosition
125cdf0e10cSrcweir             Horizontal position in model coordinates.
126cdf0e10cSrcweir         @param bIncludeBordersAndGaps
127cdf0e10cSrcweir             When this flag is <TRUE/> then the area of borders and gaps are
128cdf0e10cSrcweir             interpreted as belonging to one of the columns.
129cdf0e10cSrcweir         @param eGapMembership
130cdf0e10cSrcweir             Specifies to what column the gap areas belong.
131cdf0e10cSrcweir     */
132cdf0e10cSrcweir     sal_Int32 GetColumnAtPosition (
133cdf0e10cSrcweir         sal_Int32 nXPosition,
134cdf0e10cSrcweir         bool bIncludeBordersAndGaps,
135cdf0e10cSrcweir         GapMembership eGapMembership = GM_NONE) const;
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     /** This method is typically called from GetRowAtPosition() and
138cdf0e10cSrcweir         GetColumnAtPosition() to handle a position that lies inside the gap
139cdf0e10cSrcweir         between two adjacent rows or columns.
140cdf0e10cSrcweir         @param nDistanceIntoGap
141cdf0e10cSrcweir             Vertical distance from the bottom of the upper row down into the
142cdf0e10cSrcweir             gap or or horizontal distance from the right edge right into the
143cdf0e10cSrcweir             gap.
144cdf0e10cSrcweir         @param eGapMemberhship
145cdf0e10cSrcweir             This value decides what areas in the gap belong to which (or no)
146cdf0e10cSrcweir             row or column.
147cdf0e10cSrcweir         @param nIndex
148cdf0e10cSrcweir             The row index of the upper row or the column index of the left
149cdf0e10cSrcweir             column.
150cdf0e10cSrcweir         @param nGap
151cdf0e10cSrcweir              Width or height of the gap in model coordiantes between the
152cdf0e10cSrcweir              page borders.
153cdf0e10cSrcweir         @return
154cdf0e10cSrcweir            Returns either the index of the upper row (as given as nRow), the
155cdf0e10cSrcweir            index of the lower row (nRow+1) or -1 to indicate that the
156cdf0e10cSrcweir            position belongs to no row.
157cdf0e10cSrcweir         */
158cdf0e10cSrcweir     sal_Int32 ResolvePositionInGap (
159cdf0e10cSrcweir         sal_Int32 nDistanceIntoGap,
160cdf0e10cSrcweir         GapMembership eGapMembership,
161cdf0e10cSrcweir         sal_Int32 nIndex,
162cdf0e10cSrcweir         sal_Int32 nGap) const;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     /** Calculate the logical part of the insert position, i.e. the page
165cdf0e10cSrcweir         after whicht to insert.
166cdf0e10cSrcweir     */
167cdf0e10cSrcweir     virtual void CalculateLogicalInsertPosition (
168cdf0e10cSrcweir         const Point& rModelPosition,
169cdf0e10cSrcweir         InsertPosition& rPosition) const = 0;
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     /** Calculate the geometrical part of the insert position, i.e. the
172cdf0e10cSrcweir         location of where to display the insertion indicator and the
173cdf0e10cSrcweir         distances about which the leading and trailing pages have to be
174cdf0e10cSrcweir         moved to make room for the indicator.
175cdf0e10cSrcweir     */
176cdf0e10cSrcweir     void CalculateGeometricPosition (
177cdf0e10cSrcweir         InsertPosition& rPosition,
178cdf0e10cSrcweir         const Size& rIndicatorSize,
179cdf0e10cSrcweir         const bool bIsVertical,
180cdf0e10cSrcweir         model::SlideSorterModel& rModel) const;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     /** Return the bounding box of the preview or, when selected, of the page
183cdf0e10cSrcweir         object.  Thus, it returns something like a visual bounding box.
184cdf0e10cSrcweir     */
185cdf0e10cSrcweir     Rectangle GetInnerBoundingBox (
186cdf0e10cSrcweir         model::SlideSorterModel& rModel,
187cdf0e10cSrcweir         const sal_Int32 nIndex) const;
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     Range GetValidHorizontalSizeRange (void) const;
190cdf0e10cSrcweir     Range GetValidVerticalSizeRange (void) const;
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     Range GetRangeOfVisiblePageObjects (const Rectangle& aVisibleArea) const;
193cdf0e10cSrcweir     sal_Int32 GetIndex (
194cdf0e10cSrcweir         const sal_Int32 nRow,
195cdf0e10cSrcweir         const sal_Int32 nColumn,
196cdf0e10cSrcweir         const bool bClampToValidRange) const;
197cdf0e10cSrcweir 
198cdf0e10cSrcweir         Rectangle GetPageObjectBox (
199cdf0e10cSrcweir         const sal_Int32 nIndex,
200cdf0e10cSrcweir         const bool bIncludeBorderAndGap = false) const;
201cdf0e10cSrcweir 
202cdf0e10cSrcweir     Rectangle GetPageObjectBox (
203cdf0e10cSrcweir         const sal_Int32 nRow,
204cdf0e10cSrcweir         const sal_Int32 nColumn) const;
205cdf0e10cSrcweir 
206cdf0e10cSrcweir     Rectangle AddBorderAndGap (
207cdf0e10cSrcweir         const Rectangle& rBoundingBox,
208cdf0e10cSrcweir         const sal_Int32 nRow,
209cdf0e10cSrcweir         const sal_Int32 nColumn) const;
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     Rectangle GetTotalBoundingBox (void) const;
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     virtual ~Implementation (void);
214cdf0e10cSrcweir 
215cdf0e10cSrcweir protected:
216cdf0e10cSrcweir     Implementation (
217cdf0e10cSrcweir         const SharedSdWindow& rpWindow,
218cdf0e10cSrcweir         const ::boost::shared_ptr<view::Theme>& rpTheme);
219cdf0e10cSrcweir     Implementation (const Implementation& rImplementation);
220cdf0e10cSrcweir 
221cdf0e10cSrcweir     virtual void CalculateRowAndColumnCount (const Size& rWindowSize) = 0;
222cdf0e10cSrcweir     virtual void CalculateMaxRowAndColumnCount (const Size& rWindowSize) = 0;
223cdf0e10cSrcweir     virtual Size CalculateTargetSize (
224cdf0e10cSrcweir         const Size& rWindowSize,
225cdf0e10cSrcweir         const Size& rPreviewModelSize) const = 0;
226cdf0e10cSrcweir     Size GetTargetSize (
227cdf0e10cSrcweir         const Size& rWindowSize,
228cdf0e10cSrcweir         const Size& rPreviewModelSize,
229cdf0e10cSrcweir         const bool bCalculateWidth,
230cdf0e10cSrcweir         const bool bCalculateHeight) const;
231cdf0e10cSrcweir     void CalculateVerticalLogicalInsertPosition (
232cdf0e10cSrcweir         const Point& rModelPosition,
233cdf0e10cSrcweir         InsertPosition& rPosition) const;
234cdf0e10cSrcweir };
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 
237cdf0e10cSrcweir /** The vertical layouter has one column and as many rows as there are
238cdf0e10cSrcweir     pages.
239cdf0e10cSrcweir */
240cdf0e10cSrcweir class VerticalImplementation : public Layouter::Implementation
241cdf0e10cSrcweir {
242cdf0e10cSrcweir public:
243cdf0e10cSrcweir     VerticalImplementation (
244cdf0e10cSrcweir         const SharedSdWindow& rpWindow,
245cdf0e10cSrcweir         const ::boost::shared_ptr<view::Theme>& rpTheme);
246cdf0e10cSrcweir     VerticalImplementation (const Implementation& rImplementation);
247cdf0e10cSrcweir 
248cdf0e10cSrcweir     virtual Layouter::Orientation GetOrientation (void) const;
249cdf0e10cSrcweir 
250cdf0e10cSrcweir     void CalculateLogicalInsertPosition (
251cdf0e10cSrcweir         const Point& rModelPosition,
252cdf0e10cSrcweir         InsertPosition& rPosition) const;
253cdf0e10cSrcweir 
254cdf0e10cSrcweir protected:
255cdf0e10cSrcweir     virtual void CalculateRowAndColumnCount (const Size& rWindowSize);
256cdf0e10cSrcweir     virtual void CalculateMaxRowAndColumnCount (const Size& rWindowSize);
257cdf0e10cSrcweir     virtual Size CalculateTargetSize (
258cdf0e10cSrcweir         const Size& rWindowSize,
259cdf0e10cSrcweir         const Size& rPreviewModelSize) const;
260cdf0e10cSrcweir };
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 
263cdf0e10cSrcweir /** The horizontal layouter has one row and as many columns as there are
264cdf0e10cSrcweir     pages.
265cdf0e10cSrcweir */
266cdf0e10cSrcweir class HorizontalImplementation : public Layouter::Implementation
267cdf0e10cSrcweir {
268cdf0e10cSrcweir public:
269cdf0e10cSrcweir     HorizontalImplementation (
270cdf0e10cSrcweir         const SharedSdWindow& rpWindow,
271cdf0e10cSrcweir         const ::boost::shared_ptr<view::Theme>& rpTheme);
272cdf0e10cSrcweir     HorizontalImplementation (const Implementation& rImplementation);
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     virtual Layouter::Orientation GetOrientation (void) const;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir     void CalculateLogicalInsertPosition (
277cdf0e10cSrcweir         const Point& rModelPosition,
278cdf0e10cSrcweir         InsertPosition& rPosition) const;
279cdf0e10cSrcweir 
280cdf0e10cSrcweir protected:
281cdf0e10cSrcweir     virtual void CalculateRowAndColumnCount (const Size& rWindowSize);
282cdf0e10cSrcweir     virtual void CalculateMaxRowAndColumnCount (const Size& rWindowSize);
283cdf0e10cSrcweir     virtual Size CalculateTargetSize (
284cdf0e10cSrcweir         const Size& rWindowSize,
285cdf0e10cSrcweir         const Size& rPreviewModelSize) const;
286cdf0e10cSrcweir };
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 
289cdf0e10cSrcweir /** The number of columns of the grid layouter is defined via a control in
290cdf0e10cSrcweir     the slide sorter tool bar.  The number of rows is calculated from the
291cdf0e10cSrcweir     number of columns and the number of pages.
292cdf0e10cSrcweir */
293cdf0e10cSrcweir class GridImplementation : public Layouter::Implementation
294cdf0e10cSrcweir {
295cdf0e10cSrcweir public:
296cdf0e10cSrcweir     GridImplementation (
297cdf0e10cSrcweir         const SharedSdWindow& rpWindow,
298cdf0e10cSrcweir         const ::boost::shared_ptr<view::Theme>& rpTheme);
299cdf0e10cSrcweir     GridImplementation (const Implementation& rImplementation);
300cdf0e10cSrcweir 
301cdf0e10cSrcweir     virtual Layouter::Orientation GetOrientation (void) const;
302cdf0e10cSrcweir 
303cdf0e10cSrcweir     void CalculateLogicalInsertPosition (
304cdf0e10cSrcweir         const Point& rModelPosition,
305cdf0e10cSrcweir         InsertPosition& rPosition) const;
306cdf0e10cSrcweir 
307cdf0e10cSrcweir protected:
308cdf0e10cSrcweir     virtual void CalculateRowAndColumnCount (const Size& rWindowSize);
309cdf0e10cSrcweir     virtual void CalculateMaxRowAndColumnCount (const Size& rWindowSize);
310cdf0e10cSrcweir     virtual Size CalculateTargetSize (
311cdf0e10cSrcweir         const Size& rWindowSize,
312cdf0e10cSrcweir         const Size& rPreviewModelSize) const;
313cdf0e10cSrcweir };
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 
318cdf0e10cSrcweir //===== Layouter ==============================================================
319cdf0e10cSrcweir 
Layouter(const SharedSdWindow & rpWindow,const::boost::shared_ptr<Theme> & rpTheme)320cdf0e10cSrcweir Layouter::Layouter (
321cdf0e10cSrcweir     const SharedSdWindow& rpWindow,
322cdf0e10cSrcweir     const ::boost::shared_ptr<Theme>& rpTheme)
323cdf0e10cSrcweir     : mpImplementation(new GridImplementation(rpWindow, rpTheme)),
324cdf0e10cSrcweir       mpWindow(rpWindow)
325cdf0e10cSrcweir {
326cdf0e10cSrcweir }
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 
~Layouter(void)331cdf0e10cSrcweir Layouter::~Layouter (void)
332cdf0e10cSrcweir {
333cdf0e10cSrcweir }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 
GetPageObjectLayouter(void) const338cdf0e10cSrcweir ::boost::shared_ptr<PageObjectLayouter> Layouter::GetPageObjectLayouter (void) const
339cdf0e10cSrcweir {
340cdf0e10cSrcweir     return mpImplementation->mpPageObjectLayouter;
341cdf0e10cSrcweir }
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 
SetBorders(sal_Int32 nLeftBorder,sal_Int32 nRightBorder,sal_Int32 nTopBorder,sal_Int32 nBottomBorder)346cdf0e10cSrcweir void Layouter::SetBorders (
347cdf0e10cSrcweir     sal_Int32 nLeftBorder,
348cdf0e10cSrcweir     sal_Int32 nRightBorder,
349cdf0e10cSrcweir     sal_Int32 nTopBorder,
350cdf0e10cSrcweir     sal_Int32 nBottomBorder)
351cdf0e10cSrcweir {
352cdf0e10cSrcweir     if (nLeftBorder >= 0)
353cdf0e10cSrcweir         mpImplementation->mnRequestedLeftBorder = nLeftBorder;
354cdf0e10cSrcweir     if (nRightBorder >= 0)
355cdf0e10cSrcweir         mpImplementation->mnRequestedRightBorder = nRightBorder;
356cdf0e10cSrcweir     if (nTopBorder >= 0)
357cdf0e10cSrcweir         mpImplementation->mnRequestedTopBorder = nTopBorder;
358cdf0e10cSrcweir     if (nBottomBorder >= 0)
359cdf0e10cSrcweir         mpImplementation->mnRequestedBottomBorder = nBottomBorder;
360cdf0e10cSrcweir }
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 
364cdf0e10cSrcweir 
SetColumnCount(sal_Int32 nMinimalColumnCount,sal_Int32 nMaximalColumnCount)365cdf0e10cSrcweir void Layouter::SetColumnCount (
366cdf0e10cSrcweir     sal_Int32 nMinimalColumnCount,
367cdf0e10cSrcweir         sal_Int32 nMaximalColumnCount)
368cdf0e10cSrcweir {
369cdf0e10cSrcweir     if (nMinimalColumnCount <= nMaximalColumnCount)
370cdf0e10cSrcweir     {
371cdf0e10cSrcweir         mpImplementation->mnMinimalColumnCount = nMinimalColumnCount;
372cdf0e10cSrcweir         mpImplementation->mnMaximalColumnCount = nMaximalColumnCount;
373cdf0e10cSrcweir     }
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 
377cdf0e10cSrcweir 
378cdf0e10cSrcweir 
Rearrange(const Orientation eOrientation,const Size & rWindowSize,const Size & rPageSize,const sal_uInt32 nPageCount)379cdf0e10cSrcweir bool Layouter::Rearrange (
380cdf0e10cSrcweir     const Orientation eOrientation,
381cdf0e10cSrcweir     const Size& rWindowSize,
382cdf0e10cSrcweir     const Size& rPageSize,
383cdf0e10cSrcweir     const sal_uInt32 nPageCount)
384cdf0e10cSrcweir {
385cdf0e10cSrcweir     OSL_ASSERT(mpWindow);
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     if (eOrientation != mpImplementation->GetOrientation())
388cdf0e10cSrcweir         mpImplementation.reset(Implementation::Create(*mpImplementation, eOrientation));
389cdf0e10cSrcweir 
390cdf0e10cSrcweir     return mpImplementation->Rearrange(rWindowSize, rPageSize, nPageCount);
391cdf0e10cSrcweir }
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 
_SetZoom(double nZoomFactor)396cdf0e10cSrcweir void Layouter::_SetZoom (double nZoomFactor)
397cdf0e10cSrcweir {
398cdf0e10cSrcweir     _SetZoom(Fraction(nZoomFactor));
399cdf0e10cSrcweir }
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 
_SetZoom(Fraction nZoomFactor)404cdf0e10cSrcweir void Layouter::_SetZoom (Fraction nZoomFactor)
405cdf0e10cSrcweir {
406cdf0e10cSrcweir     OSL_ASSERT(mpWindow);
407cdf0e10cSrcweir 
408cdf0e10cSrcweir     MapMode aMapMode (mpWindow->GetMapMode());
409cdf0e10cSrcweir     aMapMode.SetScaleX (nZoomFactor);
410cdf0e10cSrcweir     aMapMode.SetScaleY (nZoomFactor);
411cdf0e10cSrcweir     mpWindow->SetMapMode (aMapMode);
412cdf0e10cSrcweir }
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 
GetColumnCount(void) const417cdf0e10cSrcweir sal_Int32 Layouter::GetColumnCount (void) const
418cdf0e10cSrcweir {
419cdf0e10cSrcweir     return mpImplementation->mnColumnCount;
420cdf0e10cSrcweir }
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 
GetRowCount(void) const425cdf0e10cSrcweir sal_Int32 Layouter::GetRowCount (void) const
426cdf0e10cSrcweir {
427cdf0e10cSrcweir     return mpImplementation->mnRowCount;
428cdf0e10cSrcweir }
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 
GetRow(const sal_Int32 nIndex) const433cdf0e10cSrcweir sal_Int32 Layouter::GetRow (const sal_Int32 nIndex) const
434cdf0e10cSrcweir {
435cdf0e10cSrcweir     return nIndex / mpImplementation->mnColumnCount;
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 
440cdf0e10cSrcweir 
GetColumn(const sal_Int32 nIndex) const441cdf0e10cSrcweir sal_Int32 Layouter::GetColumn (const sal_Int32 nIndex) const
442cdf0e10cSrcweir {
443cdf0e10cSrcweir     return nIndex % mpImplementation->mnColumnCount;
444cdf0e10cSrcweir }
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 
GetIndex(const sal_Int32 nRow,const sal_Int32 nColumn) const449cdf0e10cSrcweir sal_Int32 Layouter::GetIndex (const sal_Int32 nRow, const sal_Int32 nColumn) const
450cdf0e10cSrcweir {
451cdf0e10cSrcweir     return mpImplementation->GetIndex(nRow,nColumn,true);
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 
GetPageObjectSize(void) const457cdf0e10cSrcweir Size Layouter::GetPageObjectSize (void) const
458cdf0e10cSrcweir {
459cdf0e10cSrcweir     return mpImplementation->maPageObjectSize;
460cdf0e10cSrcweir }
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 
GetPageObjectBox(const sal_Int32 nIndex,const bool bIncludeBorderAndGap) const465cdf0e10cSrcweir Rectangle Layouter::GetPageObjectBox (
466cdf0e10cSrcweir     const sal_Int32 nIndex,
467cdf0e10cSrcweir     const bool bIncludeBorderAndGap) const
468cdf0e10cSrcweir {
469cdf0e10cSrcweir     return mpImplementation->GetPageObjectBox(nIndex, bIncludeBorderAndGap);
470cdf0e10cSrcweir }
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 
GetTotalBoundingBox(void) const475cdf0e10cSrcweir Rectangle Layouter::GetTotalBoundingBox (void) const
476cdf0e10cSrcweir {
477cdf0e10cSrcweir     return mpImplementation->GetTotalBoundingBox();
478cdf0e10cSrcweir }
479cdf0e10cSrcweir 
480cdf0e10cSrcweir 
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 
GetInsertPosition(const Point & rModelPosition,const Size & rIndicatorSize,model::SlideSorterModel & rModel) const483cdf0e10cSrcweir InsertPosition Layouter::GetInsertPosition (
484cdf0e10cSrcweir     const Point& rModelPosition,
485cdf0e10cSrcweir     const Size& rIndicatorSize,
486cdf0e10cSrcweir     model::SlideSorterModel& rModel) const
487cdf0e10cSrcweir {
488cdf0e10cSrcweir     InsertPosition aPosition;
489cdf0e10cSrcweir     mpImplementation->CalculateLogicalInsertPosition(
490cdf0e10cSrcweir         rModelPosition,
491cdf0e10cSrcweir         aPosition);
492cdf0e10cSrcweir     mpImplementation->CalculateGeometricPosition(
493cdf0e10cSrcweir         aPosition,
494cdf0e10cSrcweir         rIndicatorSize,
495cdf0e10cSrcweir         GetColumnCount()==1,
496cdf0e10cSrcweir         rModel);
497cdf0e10cSrcweir     return aPosition;
498cdf0e10cSrcweir }
499cdf0e10cSrcweir 
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 
502cdf0e10cSrcweir 
GetValidHorizontalSizeRange(void) const503cdf0e10cSrcweir Range Layouter::GetValidHorizontalSizeRange (void) const
504cdf0e10cSrcweir {
505cdf0e10cSrcweir     return mpImplementation->GetValidHorizontalSizeRange();
506cdf0e10cSrcweir }
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 
510cdf0e10cSrcweir 
GetValidVerticalSizeRange(void) const511cdf0e10cSrcweir Range Layouter::GetValidVerticalSizeRange (void) const
512cdf0e10cSrcweir {
513cdf0e10cSrcweir     return mpImplementation->GetValidVerticalSizeRange();
514cdf0e10cSrcweir }
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 
518cdf0e10cSrcweir 
GetRangeOfVisiblePageObjects(const Rectangle & aVisibleArea) const519cdf0e10cSrcweir Range Layouter::GetRangeOfVisiblePageObjects (const Rectangle& aVisibleArea) const
520cdf0e10cSrcweir {
521cdf0e10cSrcweir     return mpImplementation->GetRangeOfVisiblePageObjects(aVisibleArea);
522cdf0e10cSrcweir }
523cdf0e10cSrcweir 
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 
GetIndexAtPoint(const Point & rPosition,const bool bIncludePageBorders,const bool bClampToValidRange) const527cdf0e10cSrcweir sal_Int32 Layouter::GetIndexAtPoint (
528cdf0e10cSrcweir     const Point& rPosition,
529cdf0e10cSrcweir     const bool bIncludePageBorders,
530cdf0e10cSrcweir     const bool bClampToValidRange) const
531cdf0e10cSrcweir {
532cdf0e10cSrcweir     const sal_Int32 nRow (
533cdf0e10cSrcweir         mpImplementation->GetRowAtPosition (
534cdf0e10cSrcweir             rPosition.Y(),
535cdf0e10cSrcweir             bIncludePageBorders,
536cdf0e10cSrcweir             bIncludePageBorders ? Implementation::GM_PAGE_BORDER : Implementation::GM_NONE));
537cdf0e10cSrcweir     const sal_Int32 nColumn (
538cdf0e10cSrcweir         mpImplementation->GetColumnAtPosition (
539cdf0e10cSrcweir             rPosition.X(),
540cdf0e10cSrcweir             bIncludePageBorders,
541cdf0e10cSrcweir             bIncludePageBorders ? Implementation::GM_PAGE_BORDER : Implementation::GM_NONE));
542cdf0e10cSrcweir 
543cdf0e10cSrcweir     return mpImplementation->GetIndex(nRow,nColumn,bClampToValidRange);
544cdf0e10cSrcweir }
545cdf0e10cSrcweir 
546cdf0e10cSrcweir 
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 
549cdf0e10cSrcweir //===== Layouter::Implementation ==============================================
550cdf0e10cSrcweir 
Create(const Implementation & rImplementation,const Layouter::Orientation eOrientation)551cdf0e10cSrcweir Layouter::Implementation* Layouter::Implementation::Create (
552cdf0e10cSrcweir     const Implementation& rImplementation,
553cdf0e10cSrcweir     const Layouter::Orientation eOrientation)
554cdf0e10cSrcweir {
555cdf0e10cSrcweir     switch (eOrientation)
556cdf0e10cSrcweir     {
557cdf0e10cSrcweir         case HORIZONTAL: return new HorizontalImplementation(rImplementation);
558cdf0e10cSrcweir         case VERTICAL: return new VerticalImplementation(rImplementation);
559cdf0e10cSrcweir         case GRID:
560cdf0e10cSrcweir         default: return new GridImplementation(rImplementation);
561cdf0e10cSrcweir     }
562cdf0e10cSrcweir }
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 
565cdf0e10cSrcweir 
566cdf0e10cSrcweir 
Implementation(const SharedSdWindow & rpWindow,const::boost::shared_ptr<view::Theme> & rpTheme)567cdf0e10cSrcweir Layouter::Implementation::Implementation (
568cdf0e10cSrcweir     const SharedSdWindow& rpWindow,
569cdf0e10cSrcweir     const ::boost::shared_ptr<view::Theme>& rpTheme)
570cdf0e10cSrcweir     : mpWindow(rpWindow),
571cdf0e10cSrcweir       mnRequestedLeftBorder(5),
572cdf0e10cSrcweir       mnRequestedRightBorder(5),
573cdf0e10cSrcweir       mnRequestedTopBorder(5),
574cdf0e10cSrcweir       mnRequestedBottomBorder(5),
575cdf0e10cSrcweir       mnLeftBorder(5),
576cdf0e10cSrcweir       mnRightBorder(5),
577cdf0e10cSrcweir       mnTopBorder(5),
578cdf0e10cSrcweir       mnBottomBorder(5),
579cdf0e10cSrcweir       mnVerticalGap (10 - 2*rpTheme->GetIntegerValue(Theme::Integer_FocusIndicatorWidth)),
580cdf0e10cSrcweir       mnHorizontalGap(10 - 2*rpTheme->GetIntegerValue(Theme::Integer_FocusIndicatorWidth)),
581cdf0e10cSrcweir       maMinimalSize(132,98),
582cdf0e10cSrcweir       maPreferredSize(200,150),
583cdf0e10cSrcweir       maMaximalSize(300,200),
584cdf0e10cSrcweir       mnMinimalColumnCount(1),
585cdf0e10cSrcweir       mnMaximalColumnCount(15),
586cdf0e10cSrcweir       mnPageCount(0),
587cdf0e10cSrcweir       mnColumnCount(1),
588cdf0e10cSrcweir       mnRowCount(0),
589cdf0e10cSrcweir       mnMaxColumnCount(0),
590cdf0e10cSrcweir       mnMaxRowCount(0),
591cdf0e10cSrcweir       maPageObjectSize(1,1),
592cdf0e10cSrcweir       mpPageObjectLayouter(),
593cdf0e10cSrcweir       mpTheme(rpTheme)
594cdf0e10cSrcweir {
595cdf0e10cSrcweir }
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 
598cdf0e10cSrcweir 
599cdf0e10cSrcweir 
Implementation(const Implementation & rImplementation)600cdf0e10cSrcweir Layouter::Implementation::Implementation (const Implementation& rImplementation)
601cdf0e10cSrcweir     : mpWindow(rImplementation.mpWindow),
602cdf0e10cSrcweir       mnRequestedLeftBorder(rImplementation.mnRequestedLeftBorder),
603cdf0e10cSrcweir       mnRequestedRightBorder(rImplementation.mnRequestedRightBorder),
604cdf0e10cSrcweir       mnRequestedTopBorder(rImplementation.mnRequestedTopBorder),
605cdf0e10cSrcweir       mnRequestedBottomBorder(rImplementation.mnRequestedBottomBorder),
606cdf0e10cSrcweir       mnLeftBorder(rImplementation.mnLeftBorder),
607cdf0e10cSrcweir       mnRightBorder(rImplementation.mnRightBorder),
608cdf0e10cSrcweir       mnTopBorder(rImplementation.mnTopBorder),
609cdf0e10cSrcweir       mnBottomBorder(rImplementation.mnBottomBorder),
610cdf0e10cSrcweir       mnVerticalGap(rImplementation.mnVerticalGap),
611cdf0e10cSrcweir       mnHorizontalGap(rImplementation.mnHorizontalGap),
612cdf0e10cSrcweir       maMinimalSize(rImplementation.maMinimalSize),
613cdf0e10cSrcweir       maPreferredSize(rImplementation.maPreferredSize),
614cdf0e10cSrcweir       maMaximalSize(rImplementation.maMaximalSize),
615cdf0e10cSrcweir       mnMinimalColumnCount(rImplementation.mnMinimalColumnCount),
616cdf0e10cSrcweir       mnMaximalColumnCount(rImplementation.mnMaximalColumnCount),
617cdf0e10cSrcweir       mnPageCount(rImplementation.mnPageCount),
618cdf0e10cSrcweir       mnColumnCount(rImplementation.mnColumnCount),
619cdf0e10cSrcweir       mnRowCount(rImplementation.mnRowCount),
620cdf0e10cSrcweir       mnMaxColumnCount(rImplementation.mnMaxColumnCount),
621cdf0e10cSrcweir       mnMaxRowCount(rImplementation.mnMaxRowCount),
622cdf0e10cSrcweir       maPageObjectSize(rImplementation.maPageObjectSize),
623cdf0e10cSrcweir       mpPageObjectLayouter(),
624cdf0e10cSrcweir       mpTheme(rImplementation.mpTheme)
625cdf0e10cSrcweir {
626cdf0e10cSrcweir }
627cdf0e10cSrcweir 
628cdf0e10cSrcweir 
629cdf0e10cSrcweir 
630cdf0e10cSrcweir 
~Implementation(void)631cdf0e10cSrcweir Layouter::Implementation::~Implementation (void)
632cdf0e10cSrcweir {
633cdf0e10cSrcweir }
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 
636cdf0e10cSrcweir 
637cdf0e10cSrcweir 
Rearrange(const Size & rWindowSize,const Size & rPreviewModelSize,const sal_uInt32 nPageCount)638cdf0e10cSrcweir bool Layouter::Implementation::Rearrange  (
639cdf0e10cSrcweir     const Size& rWindowSize,
640cdf0e10cSrcweir     const Size& rPreviewModelSize,
641cdf0e10cSrcweir     const sal_uInt32 nPageCount)
642cdf0e10cSrcweir {
643cdf0e10cSrcweir     mnPageCount = nPageCount;
644cdf0e10cSrcweir 
645cdf0e10cSrcweir     // Return early when the window or the model have not yet been initialized.
646cdf0e10cSrcweir     if (rWindowSize.Width()<=0 || rWindowSize.Height()<=0)
647cdf0e10cSrcweir         return false;
648cdf0e10cSrcweir     if (rPreviewModelSize.Width()<=0 || rPreviewModelSize.Height()<=0)
649cdf0e10cSrcweir         return false;
650cdf0e10cSrcweir 
651cdf0e10cSrcweir     CalculateRowAndColumnCount(rWindowSize);
652cdf0e10cSrcweir 
653cdf0e10cSrcweir     // Update the border values.
654cdf0e10cSrcweir     mnLeftBorder = mnRequestedLeftBorder;
655cdf0e10cSrcweir     mnTopBorder = mnRequestedTopBorder;
656cdf0e10cSrcweir     mnRightBorder = mnRequestedRightBorder;
657cdf0e10cSrcweir     mnBottomBorder = mnRequestedBottomBorder;
658cdf0e10cSrcweir     if (mnColumnCount > 1)
659cdf0e10cSrcweir     {
660cdf0e10cSrcweir         int nMinimumBorderWidth = mnHorizontalGap/2;
661cdf0e10cSrcweir         if (mnLeftBorder < nMinimumBorderWidth)
662cdf0e10cSrcweir             mnLeftBorder = nMinimumBorderWidth;
663cdf0e10cSrcweir         if (mnRightBorder < nMinimumBorderWidth)
664cdf0e10cSrcweir             mnRightBorder = nMinimumBorderWidth;
665cdf0e10cSrcweir     }
666cdf0e10cSrcweir     else
667cdf0e10cSrcweir     {
668cdf0e10cSrcweir         int nMinimumBorderHeight = mnVerticalGap/2;
669cdf0e10cSrcweir         if (mnTopBorder < nMinimumBorderHeight)
670cdf0e10cSrcweir             mnTopBorder = nMinimumBorderHeight;
671cdf0e10cSrcweir         if (mnBottomBorder < nMinimumBorderHeight)
672cdf0e10cSrcweir             mnBottomBorder = nMinimumBorderHeight;
673cdf0e10cSrcweir     }
674cdf0e10cSrcweir 
675cdf0e10cSrcweir     mpPageObjectLayouter.reset(
676cdf0e10cSrcweir         new PageObjectLayouter(
677cdf0e10cSrcweir             mpTheme,
678cdf0e10cSrcweir             CalculateTargetSize(rWindowSize, rPreviewModelSize),
679cdf0e10cSrcweir             rPreviewModelSize,
680cdf0e10cSrcweir             mpWindow,
681cdf0e10cSrcweir             mnPageCount));
682cdf0e10cSrcweir     maPageObjectSize = mpPageObjectLayouter->GetSize(
683cdf0e10cSrcweir         PageObjectLayouter::FocusIndicator,
684cdf0e10cSrcweir         PageObjectLayouter::WindowCoordinateSystem);
685cdf0e10cSrcweir 
686cdf0e10cSrcweir     CalculateMaxRowAndColumnCount(rWindowSize);
687cdf0e10cSrcweir 
688cdf0e10cSrcweir     return true;
689cdf0e10cSrcweir }
690cdf0e10cSrcweir 
691cdf0e10cSrcweir 
692cdf0e10cSrcweir 
693cdf0e10cSrcweir 
GetRowAtPosition(sal_Int32 nYPosition,bool bIncludeBordersAndGaps,GapMembership eGapMembership) const694cdf0e10cSrcweir sal_Int32 Layouter::Implementation::GetRowAtPosition (
695cdf0e10cSrcweir     sal_Int32 nYPosition,
696cdf0e10cSrcweir     bool bIncludeBordersAndGaps,
697cdf0e10cSrcweir     GapMembership eGapMembership) const
698cdf0e10cSrcweir {
699cdf0e10cSrcweir     sal_Int32 nRow = -1;
700cdf0e10cSrcweir 
701cdf0e10cSrcweir     const sal_Int32 nY = nYPosition - mnTopBorder;
702cdf0e10cSrcweir     if (nY >= 0)
703cdf0e10cSrcweir     {
704cdf0e10cSrcweir         // Vertical distance from one row to the next.
705cdf0e10cSrcweir         const sal_Int32 nRowOffset (maPageObjectSize.Height() + mnVerticalGap);
706cdf0e10cSrcweir 
707cdf0e10cSrcweir         // Calculate row consisting of page objects and gap below.
708cdf0e10cSrcweir         nRow = nY / nRowOffset;
709cdf0e10cSrcweir 
710cdf0e10cSrcweir         const sal_Int32 nDistanceIntoGap ((nY - nRow*nRowOffset) - maPageObjectSize.Height());
711cdf0e10cSrcweir         // When inside the gap below then nYPosition is not over a page
712cdf0e10cSrcweir         // object.
713cdf0e10cSrcweir         if (nDistanceIntoGap > 0)
714cdf0e10cSrcweir             nRow = ResolvePositionInGap (
715cdf0e10cSrcweir                 nDistanceIntoGap,
716cdf0e10cSrcweir                 eGapMembership,
717cdf0e10cSrcweir                 nRow,
718cdf0e10cSrcweir                 mnVerticalGap);
719cdf0e10cSrcweir     }
720cdf0e10cSrcweir     else if (bIncludeBordersAndGaps)
721cdf0e10cSrcweir     {
722cdf0e10cSrcweir         // We are in the top border area.  Set nRow to the first row when
723cdf0e10cSrcweir         // the top border shall be considered to belong to the first row.
724cdf0e10cSrcweir         nRow = 0;
725cdf0e10cSrcweir     }
726cdf0e10cSrcweir 
727cdf0e10cSrcweir     return nRow;
728cdf0e10cSrcweir }
729cdf0e10cSrcweir 
730cdf0e10cSrcweir 
731cdf0e10cSrcweir 
732cdf0e10cSrcweir 
GetColumnAtPosition(sal_Int32 nXPosition,bool bIncludeBordersAndGaps,GapMembership eGapMembership) const733cdf0e10cSrcweir sal_Int32 Layouter::Implementation::GetColumnAtPosition (
734cdf0e10cSrcweir     sal_Int32 nXPosition,
735cdf0e10cSrcweir     bool bIncludeBordersAndGaps,
736cdf0e10cSrcweir     GapMembership eGapMembership) const
737cdf0e10cSrcweir {
738cdf0e10cSrcweir     sal_Int32 nColumn = -1;
739cdf0e10cSrcweir 
740cdf0e10cSrcweir     sal_Int32 nX = nXPosition - mnLeftBorder;
741cdf0e10cSrcweir     if (nX >= 0)
742cdf0e10cSrcweir     {
743cdf0e10cSrcweir         // Horizontal distance from one column to the next.
744cdf0e10cSrcweir         const sal_Int32 nColumnOffset (maPageObjectSize.Width() + mnHorizontalGap);
745cdf0e10cSrcweir 
746cdf0e10cSrcweir         // Calculate row consisting of page objects and gap below.
747cdf0e10cSrcweir         nColumn = nX / nColumnOffset;
748cdf0e10cSrcweir         if (nColumn < 0)
749cdf0e10cSrcweir             nColumn = 0;
750cdf0e10cSrcweir         else if (nColumn >= mnColumnCount)
751cdf0e10cSrcweir             nColumn = mnColumnCount-1;
752cdf0e10cSrcweir 
753cdf0e10cSrcweir         const sal_Int32 nDistanceIntoGap ((nX - nColumn*nColumnOffset) - maPageObjectSize.Width());
754cdf0e10cSrcweir         // When inside the gap at the right then nXPosition is not over a
755cdf0e10cSrcweir         // page object.
756cdf0e10cSrcweir         if (nDistanceIntoGap > 0)
757cdf0e10cSrcweir             nColumn = ResolvePositionInGap (
758cdf0e10cSrcweir                 nDistanceIntoGap,
759cdf0e10cSrcweir                 eGapMembership,
760cdf0e10cSrcweir                 nColumn,
761cdf0e10cSrcweir                 mnHorizontalGap);
762cdf0e10cSrcweir     }
763cdf0e10cSrcweir     else if (bIncludeBordersAndGaps)
764cdf0e10cSrcweir     {
765cdf0e10cSrcweir         // We are in the left border area.  Set nColumn to the first column
766cdf0e10cSrcweir         // when the left border shall be considered to belong to the first
767cdf0e10cSrcweir         // column.
768cdf0e10cSrcweir         nColumn = 0;
769cdf0e10cSrcweir     }
770cdf0e10cSrcweir     return nColumn;
771cdf0e10cSrcweir }
772cdf0e10cSrcweir 
773cdf0e10cSrcweir 
774cdf0e10cSrcweir 
775cdf0e10cSrcweir 
ResolvePositionInGap(sal_Int32 nDistanceIntoGap,GapMembership eGapMembership,sal_Int32 nIndex,sal_Int32 nGap) const776cdf0e10cSrcweir sal_Int32 Layouter::Implementation::ResolvePositionInGap (
777cdf0e10cSrcweir     sal_Int32 nDistanceIntoGap,
778cdf0e10cSrcweir     GapMembership eGapMembership,
779cdf0e10cSrcweir     sal_Int32 nIndex,
780cdf0e10cSrcweir     sal_Int32 nGap) const
781cdf0e10cSrcweir {
782cdf0e10cSrcweir     switch (eGapMembership)
783cdf0e10cSrcweir     {
784cdf0e10cSrcweir         case GM_NONE:
785cdf0e10cSrcweir             // The gap is no man's land.
786cdf0e10cSrcweir             nIndex = -1;
787cdf0e10cSrcweir             break;
788cdf0e10cSrcweir 
789cdf0e10cSrcweir         case GM_BOTH:
790cdf0e10cSrcweir         {
791cdf0e10cSrcweir             // The lower half of the gap belongs to the next row or column.
792cdf0e10cSrcweir             sal_Int32 nFirstHalfGapWidth = nGap / 2;
793cdf0e10cSrcweir             if (nDistanceIntoGap > nFirstHalfGapWidth)
794cdf0e10cSrcweir                 nIndex ++;
795cdf0e10cSrcweir             break;
796cdf0e10cSrcweir         }
797cdf0e10cSrcweir 
798cdf0e10cSrcweir         case GM_PREVIOUS:
799cdf0e10cSrcweir             // Row or column already at correct value.
800cdf0e10cSrcweir             break;
801cdf0e10cSrcweir 
802cdf0e10cSrcweir         case GM_NEXT:
803cdf0e10cSrcweir             // The complete gap belongs to the next row or column.
804cdf0e10cSrcweir             nIndex ++;
805cdf0e10cSrcweir             break;
806cdf0e10cSrcweir 
807cdf0e10cSrcweir         case GM_PAGE_BORDER:
808cdf0e10cSrcweir             if (nDistanceIntoGap > 0)
809cdf0e10cSrcweir             {
810cdf0e10cSrcweir                 if (nDistanceIntoGap > nGap)
811cdf0e10cSrcweir                 {
812cdf0e10cSrcweir                     // Inside the border of the next row or column.
813cdf0e10cSrcweir                     nIndex ++;
814cdf0e10cSrcweir                 }
815cdf0e10cSrcweir                 else
816cdf0e10cSrcweir                 {
817cdf0e10cSrcweir                     // Inside the gap between the page borders.
818cdf0e10cSrcweir                     nIndex = -1;
819cdf0e10cSrcweir                 }
820cdf0e10cSrcweir             }
821cdf0e10cSrcweir             break;
822cdf0e10cSrcweir 
823cdf0e10cSrcweir         default:
824cdf0e10cSrcweir             nIndex = -1;
825cdf0e10cSrcweir     }
826cdf0e10cSrcweir 
827cdf0e10cSrcweir     return nIndex;
828cdf0e10cSrcweir }
829cdf0e10cSrcweir 
830cdf0e10cSrcweir 
831cdf0e10cSrcweir 
832cdf0e10cSrcweir 
CalculateGeometricPosition(InsertPosition & rPosition,const Size & rIndicatorSize,const bool bIsVertical,model::SlideSorterModel & rModel) const833cdf0e10cSrcweir void Layouter::Implementation::CalculateGeometricPosition (
834cdf0e10cSrcweir     InsertPosition& rPosition,
835cdf0e10cSrcweir     const Size& rIndicatorSize,
836cdf0e10cSrcweir     const bool bIsVertical,
837cdf0e10cSrcweir     model::SlideSorterModel& rModel) const
838cdf0e10cSrcweir {
839cdf0e10cSrcweir     // 1. Determine right/bottom of the leading page and the left/top of the
840cdf0e10cSrcweir     // trailing page object and how to distribute the missing space.
841cdf0e10cSrcweir     sal_Int32 nLeadingLocation (0);
842cdf0e10cSrcweir     sal_Int32 nTrailingLocation (0);
843cdf0e10cSrcweir     bool bIsLeadingFixed (false);
844cdf0e10cSrcweir     bool bIsTrailingFixed (false);
845cdf0e10cSrcweir     sal_Int32 nSecondaryLocation (0);
846cdf0e10cSrcweir     const sal_Int32 nIndex (rPosition.GetIndex());
847cdf0e10cSrcweir 
848cdf0e10cSrcweir     if (rPosition.IsAtRunStart())
849cdf0e10cSrcweir     {
850cdf0e10cSrcweir         // Place indicator at the top of the column.
851cdf0e10cSrcweir         const Rectangle aOuterBox (GetPageObjectBox(nIndex));
852cdf0e10cSrcweir         const Rectangle aInnerBox (GetInnerBoundingBox(rModel, nIndex));
853cdf0e10cSrcweir         if (bIsVertical)
854cdf0e10cSrcweir         {
855cdf0e10cSrcweir             nLeadingLocation = aOuterBox.Top();
856cdf0e10cSrcweir             nTrailingLocation = aInnerBox.Top();
857cdf0e10cSrcweir             nSecondaryLocation = aInnerBox.Center().X();
858cdf0e10cSrcweir         }
859cdf0e10cSrcweir         else
860cdf0e10cSrcweir         {
861cdf0e10cSrcweir             nLeadingLocation = aOuterBox.Left();
862cdf0e10cSrcweir             nTrailingLocation = aInnerBox.Left();
863cdf0e10cSrcweir             nSecondaryLocation = aInnerBox.Center().Y();
864cdf0e10cSrcweir         }
865cdf0e10cSrcweir         bIsLeadingFixed = true;
866cdf0e10cSrcweir     }
867cdf0e10cSrcweir     else if (rPosition.IsAtRunEnd())
868cdf0e10cSrcweir     {
869cdf0e10cSrcweir         // Place indicator at the bottom/right of the column/row.
870cdf0e10cSrcweir 
871cdf0e10cSrcweir         const Rectangle aOuterBox (GetPageObjectBox(nIndex-1));
872cdf0e10cSrcweir         const Rectangle aInnerBox (GetInnerBoundingBox(rModel, nIndex-1));
873cdf0e10cSrcweir         if (bIsVertical)
874cdf0e10cSrcweir         {
875cdf0e10cSrcweir             nLeadingLocation = aInnerBox.Bottom();
876cdf0e10cSrcweir             nTrailingLocation = aOuterBox.Bottom();
877cdf0e10cSrcweir             nSecondaryLocation = aInnerBox.Center().X();
878cdf0e10cSrcweir         }
879cdf0e10cSrcweir         else
880cdf0e10cSrcweir         {
881cdf0e10cSrcweir             nLeadingLocation = aInnerBox.Right();
882cdf0e10cSrcweir             nTrailingLocation = aOuterBox.Right();
883cdf0e10cSrcweir             nSecondaryLocation = aInnerBox.Center().Y();
884cdf0e10cSrcweir         }
885cdf0e10cSrcweir         bIsTrailingFixed = true;
886cdf0e10cSrcweir         if ( ! rPosition.IsExtraSpaceNeeded())
887cdf0e10cSrcweir             bIsLeadingFixed = true;
888cdf0e10cSrcweir     }
889cdf0e10cSrcweir     else
890cdf0e10cSrcweir     {
891cdf0e10cSrcweir         // Place indicator between two rows/columns.
892cdf0e10cSrcweir         const Rectangle aBox1 (GetInnerBoundingBox(rModel, nIndex-1));
893cdf0e10cSrcweir         const Rectangle aBox2 (GetInnerBoundingBox(rModel, nIndex));
894cdf0e10cSrcweir         if (bIsVertical)
895cdf0e10cSrcweir         {
896cdf0e10cSrcweir             nLeadingLocation = aBox1.Bottom();
897cdf0e10cSrcweir             nTrailingLocation = aBox2.Top();
898cdf0e10cSrcweir             nSecondaryLocation = (aBox1.Center().X() + aBox2.Center().X()) / 2;
899cdf0e10cSrcweir         }
900cdf0e10cSrcweir         else
901cdf0e10cSrcweir         {
902cdf0e10cSrcweir             nLeadingLocation = aBox1.Right();
903cdf0e10cSrcweir             nTrailingLocation = aBox2.Left();
904cdf0e10cSrcweir             nSecondaryLocation = (aBox1.Center().Y() + aBox2.Center().Y()) / 2;
905cdf0e10cSrcweir         }
906cdf0e10cSrcweir     }
907cdf0e10cSrcweir 
908cdf0e10cSrcweir     // 2. Calculate the location of the insert indicator and the offsets of
909cdf0e10cSrcweir     // leading and trailing pages.
910cdf0e10cSrcweir     const sal_Int32 nAvailableSpace (nTrailingLocation - nLeadingLocation);
911cdf0e10cSrcweir     const sal_Int32 nRequiredSpace (bIsVertical ? rIndicatorSize.Height():rIndicatorSize.Width());
912cdf0e10cSrcweir     const sal_Int32 nMissingSpace (::std::max(sal_Int32(0), nRequiredSpace - nAvailableSpace));
913cdf0e10cSrcweir     sal_Int32 nPrimaryLocation (0);
914cdf0e10cSrcweir     sal_Int32 nLeadingOffset (0);
915cdf0e10cSrcweir     sal_Int32 nTrailingOffset (0);
916cdf0e10cSrcweir     if (bIsLeadingFixed)
917cdf0e10cSrcweir     {
918cdf0e10cSrcweir         nPrimaryLocation = nLeadingLocation + nRequiredSpace/2;
919cdf0e10cSrcweir         if ( ! bIsTrailingFixed)
920cdf0e10cSrcweir             nTrailingOffset = nMissingSpace;
921cdf0e10cSrcweir     }
922cdf0e10cSrcweir     else if (bIsTrailingFixed)
923cdf0e10cSrcweir     {
924cdf0e10cSrcweir         nPrimaryLocation = nTrailingLocation - nRequiredSpace/2;
925cdf0e10cSrcweir         nLeadingOffset = -nMissingSpace;
926cdf0e10cSrcweir     }
927cdf0e10cSrcweir     else
928cdf0e10cSrcweir     {
929cdf0e10cSrcweir         nPrimaryLocation = (nLeadingLocation + nTrailingLocation) /2;
930cdf0e10cSrcweir         nLeadingOffset = -nMissingSpace/2;
931cdf0e10cSrcweir         nTrailingOffset = nMissingSpace + nLeadingOffset;
932cdf0e10cSrcweir     }
933cdf0e10cSrcweir 
934cdf0e10cSrcweir     if (bIsVertical)
935cdf0e10cSrcweir     {
936cdf0e10cSrcweir         rPosition.SetGeometricalPosition(
937cdf0e10cSrcweir             Point(nSecondaryLocation, nPrimaryLocation),
938cdf0e10cSrcweir             Point(0, nLeadingOffset),
939cdf0e10cSrcweir             Point(0, nTrailingOffset));
940cdf0e10cSrcweir     }
941cdf0e10cSrcweir     else
942cdf0e10cSrcweir     {
943cdf0e10cSrcweir         rPosition.SetGeometricalPosition(
944cdf0e10cSrcweir             Point(nPrimaryLocation, nSecondaryLocation),
945cdf0e10cSrcweir             Point(nLeadingOffset, 0),
946cdf0e10cSrcweir             Point(nTrailingOffset, 0));
947cdf0e10cSrcweir     }
948cdf0e10cSrcweir }
949cdf0e10cSrcweir 
950cdf0e10cSrcweir 
951cdf0e10cSrcweir 
952cdf0e10cSrcweir 
GetInnerBoundingBox(model::SlideSorterModel & rModel,const sal_Int32 nIndex) const953cdf0e10cSrcweir Rectangle Layouter::Implementation::GetInnerBoundingBox (
954cdf0e10cSrcweir     model::SlideSorterModel& rModel,
955cdf0e10cSrcweir     const sal_Int32 nIndex) const
956cdf0e10cSrcweir {
957cdf0e10cSrcweir     model::SharedPageDescriptor pDescriptor (rModel.GetPageDescriptor(nIndex));
958cdf0e10cSrcweir     if ( ! pDescriptor)
959cdf0e10cSrcweir         return Rectangle();
960cdf0e10cSrcweir 
961cdf0e10cSrcweir     const Point aLocation (pDescriptor->GetLocation(true));
962cdf0e10cSrcweir     if (pDescriptor->HasState(model::PageDescriptor::ST_Selected))
963cdf0e10cSrcweir         return mpPageObjectLayouter->GetBoundingBox(
964cdf0e10cSrcweir             aLocation,
965cdf0e10cSrcweir             PageObjectLayouter::PageObject,
966cdf0e10cSrcweir             PageObjectLayouter::ModelCoordinateSystem);
967cdf0e10cSrcweir     else
968cdf0e10cSrcweir         return mpPageObjectLayouter->GetBoundingBox(
969cdf0e10cSrcweir             aLocation,
970cdf0e10cSrcweir             PageObjectLayouter::Preview,
971cdf0e10cSrcweir             PageObjectLayouter::ModelCoordinateSystem);
972cdf0e10cSrcweir }
973cdf0e10cSrcweir 
974cdf0e10cSrcweir 
975cdf0e10cSrcweir 
976cdf0e10cSrcweir 
GetValidHorizontalSizeRange(void) const977cdf0e10cSrcweir Range Layouter::Implementation::GetValidHorizontalSizeRange (void) const
978cdf0e10cSrcweir {
979cdf0e10cSrcweir     return Range(
980cdf0e10cSrcweir         mnLeftBorder + maMinimalSize.Width() + mnRightBorder,
981cdf0e10cSrcweir         mnLeftBorder + maMaximalSize.Width() + mnRightBorder);
982cdf0e10cSrcweir }
983cdf0e10cSrcweir 
984cdf0e10cSrcweir 
985cdf0e10cSrcweir 
986cdf0e10cSrcweir 
GetValidVerticalSizeRange(void) const987cdf0e10cSrcweir Range Layouter::Implementation::GetValidVerticalSizeRange (void) const
988cdf0e10cSrcweir {
989cdf0e10cSrcweir     return Range(
990cdf0e10cSrcweir         mnTopBorder + maMinimalSize.Height() + mnBottomBorder,
991cdf0e10cSrcweir         mnTopBorder + maMaximalSize.Height() + mnBottomBorder);
992cdf0e10cSrcweir }
993cdf0e10cSrcweir 
994cdf0e10cSrcweir 
995cdf0e10cSrcweir 
996cdf0e10cSrcweir 
GetRangeOfVisiblePageObjects(const Rectangle & aVisibleArea) const997cdf0e10cSrcweir Range Layouter::Implementation::GetRangeOfVisiblePageObjects (const Rectangle& aVisibleArea) const
998cdf0e10cSrcweir {
999cdf0e10cSrcweir     const sal_Int32 nRow0 (GetRowAtPosition(aVisibleArea.Top(), true, GM_NEXT));
1000cdf0e10cSrcweir     const sal_Int32 nCol0 (GetColumnAtPosition(aVisibleArea.Left(),true, GM_NEXT));
1001cdf0e10cSrcweir     const sal_Int32 nRow1 (GetRowAtPosition(aVisibleArea.Bottom(), true, GM_PREVIOUS));
1002cdf0e10cSrcweir     const sal_Int32 nCol1 (GetColumnAtPosition(aVisibleArea.Right(), true, GM_PREVIOUS));
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir     // When start and end lie in different rows then the range may include
1005cdf0e10cSrcweir     // slides outside (left or right of) the given area.
1006cdf0e10cSrcweir     return Range(GetIndex(nRow0,nCol0,true), GetIndex(nRow1,nCol1,true));
1007cdf0e10cSrcweir }
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir 
GetTargetSize(const Size & rWindowSize,const Size & rPreviewModelSize,const bool bCalculateWidth,const bool bCalculateHeight) const1012cdf0e10cSrcweir Size Layouter::Implementation::GetTargetSize (
1013cdf0e10cSrcweir     const Size& rWindowSize,
1014cdf0e10cSrcweir     const Size& rPreviewModelSize,
1015cdf0e10cSrcweir     const bool bCalculateWidth,
1016cdf0e10cSrcweir     const bool bCalculateHeight) const
1017cdf0e10cSrcweir {
1018cdf0e10cSrcweir     (void)rPreviewModelSize;
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir     if (mnColumnCount<=0 || mnRowCount<=0)
1021cdf0e10cSrcweir         return maPreferredSize;
1022cdf0e10cSrcweir     if ( ! (bCalculateWidth || bCalculateHeight))
1023cdf0e10cSrcweir     {
1024cdf0e10cSrcweir         OSL_ASSERT(bCalculateWidth || bCalculateHeight);
1025cdf0e10cSrcweir         return maPreferredSize;
1026cdf0e10cSrcweir     }
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir     // Calculate the width of each page object.
1029cdf0e10cSrcweir     Size aTargetSize (0,0);
1030cdf0e10cSrcweir     if (bCalculateWidth)
1031cdf0e10cSrcweir         aTargetSize.setWidth(
1032cdf0e10cSrcweir             (rWindowSize.Width() - mnLeftBorder - mnRightBorder
1033cdf0e10cSrcweir                 - (mnColumnCount-1) * mnHorizontalGap)
1034cdf0e10cSrcweir                     / mnColumnCount);
1035cdf0e10cSrcweir     else if (bCalculateHeight)
1036cdf0e10cSrcweir         aTargetSize.setHeight(
1037cdf0e10cSrcweir             (rWindowSize.Height() - mnTopBorder - mnBottomBorder
1038cdf0e10cSrcweir                 - (mnRowCount-1) * mnVerticalGap)
1039cdf0e10cSrcweir                     / mnRowCount);
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir     if (bCalculateWidth)
1042cdf0e10cSrcweir     {
1043cdf0e10cSrcweir         if (aTargetSize.Width() < maMinimalSize.Width())
1044cdf0e10cSrcweir             aTargetSize.setWidth(maMinimalSize.Width());
1045cdf0e10cSrcweir         else if (aTargetSize.Width() > maMaximalSize.Width())
1046cdf0e10cSrcweir             aTargetSize.setWidth(maMaximalSize.Width());
1047cdf0e10cSrcweir     }
1048cdf0e10cSrcweir     else if (bCalculateHeight)
1049cdf0e10cSrcweir     {
1050cdf0e10cSrcweir         if (aTargetSize.Height() < maMinimalSize.Height())
1051cdf0e10cSrcweir             aTargetSize.setHeight(maMinimalSize.Height());
1052cdf0e10cSrcweir         else if (aTargetSize.Height() > maMaximalSize.Height())
1053cdf0e10cSrcweir             aTargetSize.setHeight(maMaximalSize.Height());
1054cdf0e10cSrcweir     }
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir     return aTargetSize;
1057cdf0e10cSrcweir }
1058cdf0e10cSrcweir 
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir 
GetIndex(const sal_Int32 nRow,const sal_Int32 nColumn,const bool bClampToValidRange) const1062cdf0e10cSrcweir sal_Int32 Layouter::Implementation::GetIndex (
1063cdf0e10cSrcweir     const sal_Int32 nRow,
1064cdf0e10cSrcweir     const sal_Int32 nColumn,
1065cdf0e10cSrcweir     const bool bClampToValidRange) const
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir     if (nRow >= 0 && nColumn >= 0)
1068cdf0e10cSrcweir     {
1069cdf0e10cSrcweir         const sal_Int32 nIndex (nRow * mnColumnCount + nColumn);
1070cdf0e10cSrcweir         if (nIndex >= mnPageCount)
1071cdf0e10cSrcweir             if (bClampToValidRange)
1072cdf0e10cSrcweir                 return mnPageCount-1;
1073cdf0e10cSrcweir             else
1074cdf0e10cSrcweir                 return -1;
1075cdf0e10cSrcweir         else
1076cdf0e10cSrcweir             return nIndex;
1077cdf0e10cSrcweir     }
1078cdf0e10cSrcweir     else if (bClampToValidRange)
1079cdf0e10cSrcweir         return 0;
1080cdf0e10cSrcweir     else
1081cdf0e10cSrcweir         return -1;
1082cdf0e10cSrcweir }
1083cdf0e10cSrcweir 
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir 
GetPageObjectBox(const sal_Int32 nIndex,const bool bIncludeBorderAndGap) const1087cdf0e10cSrcweir Rectangle Layouter::Implementation::GetPageObjectBox (
1088cdf0e10cSrcweir     const sal_Int32 nIndex,
1089cdf0e10cSrcweir     const bool bIncludeBorderAndGap) const
1090cdf0e10cSrcweir {
1091cdf0e10cSrcweir     const sal_Int32 nRow (nIndex / mnColumnCount);
1092cdf0e10cSrcweir     const sal_Int32 nColumn (nIndex % mnColumnCount);
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir     const Rectangle aBoundingBox (GetPageObjectBox(nRow,nColumn));
1095cdf0e10cSrcweir     if (bIncludeBorderAndGap)
1096cdf0e10cSrcweir         return AddBorderAndGap(aBoundingBox, nRow, nColumn);
1097cdf0e10cSrcweir     else
1098cdf0e10cSrcweir         return aBoundingBox;
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir 
GetPageObjectBox(const sal_Int32 nRow,const sal_Int32 nColumn) const1104cdf0e10cSrcweir Rectangle Layouter::Implementation::GetPageObjectBox (
1105cdf0e10cSrcweir     const sal_Int32 nRow,
1106cdf0e10cSrcweir     const sal_Int32 nColumn) const
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir     return Rectangle(
1109cdf0e10cSrcweir         Point (mnLeftBorder
1110cdf0e10cSrcweir             + nColumn * maPageObjectSize.Width()
1111cdf0e10cSrcweir             + (nColumn>0 ? nColumn : 0) * mnHorizontalGap,
1112cdf0e10cSrcweir             mnTopBorder
1113cdf0e10cSrcweir             + nRow * maPageObjectSize.Height()
1114cdf0e10cSrcweir             + (nRow>0 ? nRow : 0) * mnVerticalGap),
1115cdf0e10cSrcweir         maPageObjectSize);
1116cdf0e10cSrcweir }
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir 
1121cdf0e10cSrcweir 
AddBorderAndGap(const Rectangle & rBoundingBox,const sal_Int32 nRow,const sal_Int32 nColumn) const1122cdf0e10cSrcweir Rectangle Layouter::Implementation::AddBorderAndGap (
1123cdf0e10cSrcweir     const Rectangle& rBoundingBox,
1124cdf0e10cSrcweir     const sal_Int32 nRow,
1125cdf0e10cSrcweir     const sal_Int32 nColumn) const
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir     Rectangle aBoundingBox (rBoundingBox);
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir     if (nColumn == 0)
1130cdf0e10cSrcweir         aBoundingBox.Left() = 0;
1131cdf0e10cSrcweir     else
1132cdf0e10cSrcweir         aBoundingBox.Left() -= mnHorizontalGap/2;
1133cdf0e10cSrcweir     if (nColumn == mnColumnCount-1)
1134cdf0e10cSrcweir         aBoundingBox.Right() += mnRightBorder;
1135cdf0e10cSrcweir     else
1136cdf0e10cSrcweir         aBoundingBox.Right() += mnHorizontalGap/2;
1137cdf0e10cSrcweir     if (nRow == 0)
1138cdf0e10cSrcweir         aBoundingBox.Top() = 0;
1139cdf0e10cSrcweir     else
1140cdf0e10cSrcweir         aBoundingBox.Top() -= mnVerticalGap/2;
1141cdf0e10cSrcweir     if (nRow == mnRowCount-1)
1142cdf0e10cSrcweir         aBoundingBox.Bottom() += mnBottomBorder;
1143cdf0e10cSrcweir     else
1144cdf0e10cSrcweir         aBoundingBox.Bottom() += mnVerticalGap/2;
1145cdf0e10cSrcweir     return aBoundingBox;
1146cdf0e10cSrcweir }
1147cdf0e10cSrcweir 
1148cdf0e10cSrcweir 
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir 
GetTotalBoundingBox(void) const1151cdf0e10cSrcweir Rectangle Layouter::Implementation::GetTotalBoundingBox (void) const
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir     sal_Int32 nHorizontalSize = 0;
1154cdf0e10cSrcweir     sal_Int32 nVerticalSize = 0;
1155cdf0e10cSrcweir     if (mnColumnCount > 0)
1156cdf0e10cSrcweir     {
1157cdf0e10cSrcweir         sal_Int32 nRowCount = (mnPageCount+mnColumnCount-1) / mnColumnCount;
1158cdf0e10cSrcweir         nHorizontalSize =
1159cdf0e10cSrcweir             mnLeftBorder
1160cdf0e10cSrcweir             + mnRightBorder
1161cdf0e10cSrcweir             + mnColumnCount * maPageObjectSize.Width();
1162cdf0e10cSrcweir         if (mnColumnCount > 1)
1163cdf0e10cSrcweir             nHorizontalSize +=  (mnColumnCount-1) * mnHorizontalGap;
1164cdf0e10cSrcweir         nVerticalSize =
1165cdf0e10cSrcweir             mnTopBorder
1166cdf0e10cSrcweir             + mnBottomBorder
1167cdf0e10cSrcweir             + nRowCount * maPageObjectSize.Height();
1168cdf0e10cSrcweir         if (nRowCount > 1)
1169cdf0e10cSrcweir             nVerticalSize += (nRowCount-1) * mnVerticalGap;
1170cdf0e10cSrcweir     }
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir     return Rectangle (
1173cdf0e10cSrcweir         Point(0,0),
1174cdf0e10cSrcweir         Size (nHorizontalSize, nVerticalSize)
1175cdf0e10cSrcweir         );
1176cdf0e10cSrcweir }
1177cdf0e10cSrcweir 
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir 
CalculateVerticalLogicalInsertPosition(const Point & rModelPosition,InsertPosition & rPosition) const1181cdf0e10cSrcweir void Layouter::Implementation::CalculateVerticalLogicalInsertPosition (
1182cdf0e10cSrcweir     const Point& rModelPosition,
1183cdf0e10cSrcweir     InsertPosition& rPosition) const
1184cdf0e10cSrcweir {
1185cdf0e10cSrcweir     const sal_Int32 nY = rModelPosition.Y() - mnTopBorder + maPageObjectSize.Height()/2;
1186cdf0e10cSrcweir     const sal_Int32 nRowHeight (maPageObjectSize.Height() + mnVerticalGap);
1187cdf0e10cSrcweir     const sal_Int32 nRow (::std::min(mnPageCount, nY / nRowHeight));
1188cdf0e10cSrcweir     rPosition.SetLogicalPosition (
1189cdf0e10cSrcweir         nRow,
1190cdf0e10cSrcweir         0,
1191cdf0e10cSrcweir         nRow,
1192cdf0e10cSrcweir         (nRow == 0),
1193cdf0e10cSrcweir         (nRow == mnRowCount),
1194cdf0e10cSrcweir         (nRow >= mnMaxRowCount));
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir 
1197cdf0e10cSrcweir 
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir //===== HorizontalImplementation ================================================
1201cdf0e10cSrcweir 
HorizontalImplementation(const SharedSdWindow & rpWindow,const::boost::shared_ptr<view::Theme> & rpTheme)1202cdf0e10cSrcweir HorizontalImplementation::HorizontalImplementation (
1203cdf0e10cSrcweir     const SharedSdWindow& rpWindow,
1204cdf0e10cSrcweir     const ::boost::shared_ptr<view::Theme>& rpTheme)
1205cdf0e10cSrcweir     : Implementation(rpWindow, rpTheme)
1206cdf0e10cSrcweir {
1207cdf0e10cSrcweir }
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir 
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir 
HorizontalImplementation(const Implementation & rImplementation)1212cdf0e10cSrcweir HorizontalImplementation::HorizontalImplementation (const Implementation& rImplementation)
1213cdf0e10cSrcweir     : Implementation(rImplementation)
1214cdf0e10cSrcweir {
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir 
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir 
GetOrientation(void) const1220cdf0e10cSrcweir Layouter::Orientation HorizontalImplementation::GetOrientation (void) const
1221cdf0e10cSrcweir {
1222cdf0e10cSrcweir     return Layouter::HORIZONTAL;
1223cdf0e10cSrcweir }
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir 
1226cdf0e10cSrcweir 
1227cdf0e10cSrcweir 
CalculateRowAndColumnCount(const Size & rWindowSize)1228cdf0e10cSrcweir void HorizontalImplementation::CalculateRowAndColumnCount (const Size& rWindowSize)
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir     (void)rWindowSize;
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir     // Row and column count are fixed (for a given page count.)
1233cdf0e10cSrcweir     mnColumnCount = mnPageCount;
1234cdf0e10cSrcweir     mnRowCount = 1;
1235cdf0e10cSrcweir }
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir 
1239cdf0e10cSrcweir 
CalculateMaxRowAndColumnCount(const Size & rWindowSize)1240cdf0e10cSrcweir void HorizontalImplementation::CalculateMaxRowAndColumnCount (const Size& rWindowSize)
1241cdf0e10cSrcweir {
1242cdf0e10cSrcweir     mnMaxColumnCount = (rWindowSize.Width() - mnLeftBorder - mnRightBorder)
1243cdf0e10cSrcweir         / (maPageObjectSize.Width()  + mnHorizontalGap);
1244cdf0e10cSrcweir     mnMaxRowCount = 1;
1245cdf0e10cSrcweir }
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir 
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir 
CalculateTargetSize(const Size & rWindowSize,const Size & rPreviewModelSize) const1250cdf0e10cSrcweir Size HorizontalImplementation::CalculateTargetSize (
1251cdf0e10cSrcweir     const Size& rWindowSize,
1252cdf0e10cSrcweir     const Size& rPreviewModelSize) const
1253cdf0e10cSrcweir {
1254cdf0e10cSrcweir     return Implementation::GetTargetSize(rWindowSize, rPreviewModelSize, false, true);
1255cdf0e10cSrcweir }
1256cdf0e10cSrcweir 
1257cdf0e10cSrcweir 
1258cdf0e10cSrcweir 
1259cdf0e10cSrcweir 
CalculateLogicalInsertPosition(const Point & rModelPosition,InsertPosition & rPosition) const1260cdf0e10cSrcweir void HorizontalImplementation::CalculateLogicalInsertPosition (
1261cdf0e10cSrcweir     const Point& rModelPosition,
1262cdf0e10cSrcweir     InsertPosition& rPosition) const
1263cdf0e10cSrcweir {
1264cdf0e10cSrcweir     const sal_Int32 nX = rModelPosition.X() - mnLeftBorder + maPageObjectSize.Width()/2;
1265cdf0e10cSrcweir     const sal_Int32 nColumnWidth (maPageObjectSize.Width() + mnHorizontalGap);
1266cdf0e10cSrcweir     const sal_Int32 nColumn (::std::min(mnPageCount, nX / nColumnWidth));
1267cdf0e10cSrcweir     rPosition.SetLogicalPosition (
1268cdf0e10cSrcweir         0,
1269cdf0e10cSrcweir         nColumn,
1270cdf0e10cSrcweir         nColumn,
1271cdf0e10cSrcweir         (nColumn == 0),
1272cdf0e10cSrcweir         (nColumn == mnColumnCount),
1273cdf0e10cSrcweir         (nColumn >= mnMaxColumnCount));
1274cdf0e10cSrcweir }
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir 
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir 
1279cdf0e10cSrcweir //===== VerticalImplementation ================================================
1280cdf0e10cSrcweir 
VerticalImplementation(const SharedSdWindow & rpWindow,const::boost::shared_ptr<view::Theme> & rpTheme)1281cdf0e10cSrcweir VerticalImplementation::VerticalImplementation (
1282cdf0e10cSrcweir     const SharedSdWindow& rpWindow,
1283cdf0e10cSrcweir     const ::boost::shared_ptr<view::Theme>& rpTheme)
1284cdf0e10cSrcweir     : Implementation(rpWindow, rpTheme)
1285cdf0e10cSrcweir {
1286cdf0e10cSrcweir }
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir 
1289cdf0e10cSrcweir 
1290cdf0e10cSrcweir 
VerticalImplementation(const Implementation & rImplementation)1291cdf0e10cSrcweir VerticalImplementation::VerticalImplementation (const Implementation& rImplementation)
1292cdf0e10cSrcweir     : Implementation(rImplementation)
1293cdf0e10cSrcweir {
1294cdf0e10cSrcweir }
1295cdf0e10cSrcweir 
1296cdf0e10cSrcweir 
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir 
GetOrientation(void) const1299cdf0e10cSrcweir Layouter::Orientation VerticalImplementation::GetOrientation (void) const
1300cdf0e10cSrcweir {
1301cdf0e10cSrcweir     return Layouter::VERTICAL;
1302cdf0e10cSrcweir }
1303cdf0e10cSrcweir 
1304cdf0e10cSrcweir 
1305cdf0e10cSrcweir 
1306cdf0e10cSrcweir 
CalculateRowAndColumnCount(const Size & rWindowSize)1307cdf0e10cSrcweir void VerticalImplementation::CalculateRowAndColumnCount (const Size& rWindowSize)
1308cdf0e10cSrcweir {
1309cdf0e10cSrcweir     (void)rWindowSize;
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir     // Row and column count are fixed (for a given page count.)
1312cdf0e10cSrcweir     mnRowCount = mnPageCount;
1313cdf0e10cSrcweir     mnColumnCount = 1;
1314cdf0e10cSrcweir 
1315cdf0e10cSrcweir }
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir 
1319cdf0e10cSrcweir 
CalculateMaxRowAndColumnCount(const Size & rWindowSize)1320cdf0e10cSrcweir void VerticalImplementation::CalculateMaxRowAndColumnCount (const Size& rWindowSize)
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir     mnMaxRowCount = (rWindowSize.Height() - mnTopBorder - mnBottomBorder)
1323cdf0e10cSrcweir         / (maPageObjectSize.Height()  + mnVerticalGap);
1324cdf0e10cSrcweir     mnMaxColumnCount = 1;
1325cdf0e10cSrcweir }
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir 
CalculateTargetSize(const Size & rWindowSize,const Size & rPreviewModelSize) const1330cdf0e10cSrcweir Size VerticalImplementation::CalculateTargetSize (
1331cdf0e10cSrcweir     const Size& rWindowSize,
1332cdf0e10cSrcweir     const Size& rPreviewModelSize) const
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir     return Implementation::GetTargetSize(rWindowSize, rPreviewModelSize, true, false);
1335cdf0e10cSrcweir }
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir 
1339cdf0e10cSrcweir 
CalculateLogicalInsertPosition(const Point & rModelPosition,InsertPosition & rPosition) const1340cdf0e10cSrcweir void VerticalImplementation::CalculateLogicalInsertPosition (
1341cdf0e10cSrcweir     const Point& rModelPosition,
1342cdf0e10cSrcweir     InsertPosition& rPosition) const
1343cdf0e10cSrcweir {
1344cdf0e10cSrcweir     return CalculateVerticalLogicalInsertPosition(rModelPosition, rPosition);
1345cdf0e10cSrcweir }
1346cdf0e10cSrcweir 
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir //===== GridImplementation ================================================
1351cdf0e10cSrcweir 
GridImplementation(const SharedSdWindow & rpWindow,const::boost::shared_ptr<view::Theme> & rpTheme)1352cdf0e10cSrcweir GridImplementation::GridImplementation (
1353cdf0e10cSrcweir     const SharedSdWindow& rpWindow,
1354cdf0e10cSrcweir     const ::boost::shared_ptr<view::Theme>& rpTheme)
1355cdf0e10cSrcweir     : Implementation(rpWindow, rpTheme)
1356cdf0e10cSrcweir {
1357cdf0e10cSrcweir }
1358cdf0e10cSrcweir 
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir 
1361cdf0e10cSrcweir 
GridImplementation(const Implementation & rImplementation)1362cdf0e10cSrcweir GridImplementation::GridImplementation (const Implementation& rImplementation)
1363cdf0e10cSrcweir     : Implementation(rImplementation)
1364cdf0e10cSrcweir {
1365cdf0e10cSrcweir }
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir 
1369cdf0e10cSrcweir 
GetOrientation(void) const1370cdf0e10cSrcweir Layouter::Orientation GridImplementation::GetOrientation (void) const
1371cdf0e10cSrcweir {
1372cdf0e10cSrcweir     return Layouter::GRID;
1373cdf0e10cSrcweir }
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir 
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir 
CalculateRowAndColumnCount(const Size & rWindowSize)1378cdf0e10cSrcweir void GridImplementation::CalculateRowAndColumnCount (const Size& rWindowSize)
1379cdf0e10cSrcweir {
1380cdf0e10cSrcweir     // Calculate the column count.
1381cdf0e10cSrcweir     mnColumnCount
1382cdf0e10cSrcweir         = (rWindowSize.Width() - mnRequestedLeftBorder - mnRequestedRightBorder)
1383cdf0e10cSrcweir         / (maPreferredSize.Width()  + mnHorizontalGap);
1384cdf0e10cSrcweir     if (mnColumnCount < mnMinimalColumnCount)
1385cdf0e10cSrcweir         mnColumnCount = mnMinimalColumnCount;
1386cdf0e10cSrcweir     if (mnColumnCount > mnMaximalColumnCount)
1387cdf0e10cSrcweir         mnColumnCount = mnMaximalColumnCount;
1388cdf0e10cSrcweir     mnRowCount = (mnPageCount + mnColumnCount-1)/mnColumnCount;
1389cdf0e10cSrcweir }
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir 
1392cdf0e10cSrcweir 
1393cdf0e10cSrcweir 
CalculateMaxRowAndColumnCount(const Size & rWindowSize)1394cdf0e10cSrcweir void GridImplementation::CalculateMaxRowAndColumnCount (const Size& rWindowSize)
1395cdf0e10cSrcweir {
1396cdf0e10cSrcweir     mnMaxColumnCount = (rWindowSize.Width() - mnLeftBorder - mnRightBorder)
1397cdf0e10cSrcweir         / (maPageObjectSize.Width()  + mnHorizontalGap);
1398cdf0e10cSrcweir     mnMaxRowCount = (rWindowSize.Height() - mnTopBorder - mnBottomBorder)
1399cdf0e10cSrcweir         / (maPageObjectSize.Height()  + mnVerticalGap);
1400cdf0e10cSrcweir }
1401cdf0e10cSrcweir 
1402cdf0e10cSrcweir 
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir 
1405cdf0e10cSrcweir 
CalculateTargetSize(const Size & rWindowSize,const Size & rPreviewModelSize) const1406cdf0e10cSrcweir Size GridImplementation::CalculateTargetSize (
1407cdf0e10cSrcweir     const Size& rWindowSize,
1408cdf0e10cSrcweir     const Size& rPreviewModelSize) const
1409cdf0e10cSrcweir {
1410cdf0e10cSrcweir     return Implementation::GetTargetSize(rWindowSize, rPreviewModelSize, true, true);
1411cdf0e10cSrcweir }
1412cdf0e10cSrcweir 
1413cdf0e10cSrcweir 
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir 
CalculateLogicalInsertPosition(const Point & rModelPosition,InsertPosition & rPosition) const1416cdf0e10cSrcweir void GridImplementation::CalculateLogicalInsertPosition (
1417cdf0e10cSrcweir     const Point& rModelPosition,
1418cdf0e10cSrcweir     InsertPosition& rPosition) const
1419cdf0e10cSrcweir {
1420cdf0e10cSrcweir     if (mnColumnCount == 1)
1421cdf0e10cSrcweir     {
1422cdf0e10cSrcweir         CalculateVerticalLogicalInsertPosition(rModelPosition, rPosition);
1423cdf0e10cSrcweir     }
1424cdf0e10cSrcweir     else
1425cdf0e10cSrcweir     {
1426cdf0e10cSrcweir         // Handle the general case of more than one column.
1427cdf0e10cSrcweir         sal_Int32 nRow (::std::min(
1428cdf0e10cSrcweir             mnRowCount-1,
1429cdf0e10cSrcweir             GetRowAtPosition (rModelPosition.Y(), true, GM_BOTH)));
1430cdf0e10cSrcweir         const sal_Int32 nX = rModelPosition.X() - mnLeftBorder + maPageObjectSize.Width()/2;
1431cdf0e10cSrcweir         const sal_Int32 nColumnWidth (maPageObjectSize.Width() + mnHorizontalGap);
1432cdf0e10cSrcweir         sal_Int32 nColumn (::std::min(mnColumnCount, nX / nColumnWidth));
1433cdf0e10cSrcweir         sal_Int32 nIndex (nRow * mnColumnCount + nColumn);
1434cdf0e10cSrcweir         bool bIsAtRunEnd (nColumn == mnColumnCount);
1435cdf0e10cSrcweir 
1436cdf0e10cSrcweir         if (nIndex >= mnPageCount)
1437cdf0e10cSrcweir         {
1438cdf0e10cSrcweir             nIndex = mnPageCount;
1439cdf0e10cSrcweir             nRow = mnRowCount-1;
1440cdf0e10cSrcweir             nColumn = ::std::min(::std::min(mnPageCount, mnColumnCount), nColumn);
1441cdf0e10cSrcweir             bIsAtRunEnd = true;
1442cdf0e10cSrcweir         }
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir         rPosition.SetLogicalPosition (
1445cdf0e10cSrcweir             nRow,
1446cdf0e10cSrcweir             nColumn,
1447cdf0e10cSrcweir             nIndex,
1448cdf0e10cSrcweir             (nColumn == 0),
1449cdf0e10cSrcweir             bIsAtRunEnd,
1450cdf0e10cSrcweir             (nColumn >= mnMaxColumnCount));
1451cdf0e10cSrcweir     }
1452cdf0e10cSrcweir }
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir 
1455cdf0e10cSrcweir 
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir //===== InsertPosition ========================================================
1458cdf0e10cSrcweir 
InsertPosition(void)1459cdf0e10cSrcweir InsertPosition::InsertPosition (void)
1460cdf0e10cSrcweir     : mnRow(-1),
1461cdf0e10cSrcweir       mnColumn(-1),
1462cdf0e10cSrcweir       mnIndex(-1),
1463cdf0e10cSrcweir       mbIsAtRunStart(false),
1464cdf0e10cSrcweir       mbIsAtRunEnd(false),
1465cdf0e10cSrcweir       mbIsExtraSpaceNeeded(false),
1466cdf0e10cSrcweir       maLocation(0,0),
1467cdf0e10cSrcweir       maLeadingOffset(0,0),
1468cdf0e10cSrcweir       maTrailingOffset(0,0)
1469cdf0e10cSrcweir {
1470cdf0e10cSrcweir }
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir 
1473cdf0e10cSrcweir 
1474cdf0e10cSrcweir 
operator =(const InsertPosition & rInsertPosition)1475cdf0e10cSrcweir InsertPosition& InsertPosition::operator= (const InsertPosition& rInsertPosition)
1476cdf0e10cSrcweir {
1477cdf0e10cSrcweir     if (this != &rInsertPosition)
1478cdf0e10cSrcweir     {
1479cdf0e10cSrcweir         mnRow = rInsertPosition.mnRow;
1480cdf0e10cSrcweir         mnColumn = rInsertPosition.mnColumn;
1481cdf0e10cSrcweir         mnIndex = rInsertPosition.mnIndex;
1482cdf0e10cSrcweir         mbIsAtRunStart = rInsertPosition.mbIsAtRunStart;
1483cdf0e10cSrcweir         mbIsAtRunEnd = rInsertPosition.mbIsAtRunEnd;
1484cdf0e10cSrcweir         mbIsExtraSpaceNeeded = rInsertPosition.mbIsExtraSpaceNeeded;
1485cdf0e10cSrcweir         maLocation = rInsertPosition.maLocation;
1486cdf0e10cSrcweir         maLeadingOffset = rInsertPosition.maLeadingOffset;
1487cdf0e10cSrcweir         maTrailingOffset = rInsertPosition.maTrailingOffset;
1488cdf0e10cSrcweir     }
1489cdf0e10cSrcweir     return *this;
1490cdf0e10cSrcweir }
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir 
1494cdf0e10cSrcweir 
operator ==(const InsertPosition & rInsertPosition) const1495cdf0e10cSrcweir bool InsertPosition::operator== (const InsertPosition& rInsertPosition) const
1496cdf0e10cSrcweir {
1497cdf0e10cSrcweir     // Do not compare the geometrical information (maLocation).
1498cdf0e10cSrcweir     return mnRow==rInsertPosition.mnRow
1499cdf0e10cSrcweir         && mnColumn==rInsertPosition.mnColumn
1500cdf0e10cSrcweir         && mnIndex==rInsertPosition.mnIndex
1501cdf0e10cSrcweir         && mbIsAtRunStart==rInsertPosition.mbIsAtRunStart
1502cdf0e10cSrcweir         && mbIsAtRunEnd==rInsertPosition.mbIsAtRunEnd
1503cdf0e10cSrcweir         && mbIsExtraSpaceNeeded==rInsertPosition.mbIsExtraSpaceNeeded;
1504cdf0e10cSrcweir }
1505cdf0e10cSrcweir 
1506cdf0e10cSrcweir 
1507cdf0e10cSrcweir 
1508cdf0e10cSrcweir 
operator !=(const InsertPosition & rInsertPosition) const1509cdf0e10cSrcweir bool InsertPosition::operator!= (const InsertPosition& rInsertPosition) const
1510cdf0e10cSrcweir {
1511cdf0e10cSrcweir     return !operator==(rInsertPosition);
1512cdf0e10cSrcweir }
1513cdf0e10cSrcweir 
1514cdf0e10cSrcweir 
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir 
SetLogicalPosition(const sal_Int32 nRow,const sal_Int32 nColumn,const sal_Int32 nIndex,const bool bIsAtRunStart,const bool bIsAtRunEnd,const bool bIsExtraSpaceNeeded)1517cdf0e10cSrcweir void InsertPosition::SetLogicalPosition (
1518cdf0e10cSrcweir     const sal_Int32 nRow,
1519cdf0e10cSrcweir     const sal_Int32 nColumn,
1520cdf0e10cSrcweir     const sal_Int32 nIndex,
1521cdf0e10cSrcweir     const bool bIsAtRunStart,
1522cdf0e10cSrcweir     const bool bIsAtRunEnd,
1523cdf0e10cSrcweir     const bool bIsExtraSpaceNeeded)
1524cdf0e10cSrcweir {
1525cdf0e10cSrcweir     mnRow = nRow;
1526cdf0e10cSrcweir     mnColumn = nColumn;
1527cdf0e10cSrcweir     mnIndex = nIndex;
1528cdf0e10cSrcweir     mbIsAtRunStart = bIsAtRunStart;
1529cdf0e10cSrcweir     mbIsAtRunEnd = bIsAtRunEnd;
1530cdf0e10cSrcweir     mbIsExtraSpaceNeeded = bIsExtraSpaceNeeded;
1531cdf0e10cSrcweir }
1532cdf0e10cSrcweir 
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir 
1535cdf0e10cSrcweir 
SetGeometricalPosition(const Point aLocation,const Point aLeadingOffset,const Point aTrailingOffset)1536cdf0e10cSrcweir void InsertPosition::SetGeometricalPosition(
1537cdf0e10cSrcweir     const Point aLocation,
1538cdf0e10cSrcweir     const Point aLeadingOffset,
1539cdf0e10cSrcweir     const Point aTrailingOffset)
1540cdf0e10cSrcweir {
1541cdf0e10cSrcweir     maLocation = aLocation;
1542cdf0e10cSrcweir     maLeadingOffset = aLeadingOffset;
1543cdf0e10cSrcweir     maTrailingOffset = aTrailingOffset;
1544cdf0e10cSrcweir }
1545cdf0e10cSrcweir 
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir 
1548cdf0e10cSrcweir } } } // end of namespace ::sd::slidesorter::namespace
1549