xref: /trunk/main/sw/source/core/crsr/BlockCursor.cxx (revision efeef26f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include <IBlockCursor.hxx>
28 #include <viscrs.hxx>
29 #include "BlockCursor.hxx"
30 
31 /** The implementation of the block cursor interface
32 
33     It's simply an aggregation of a SwShellCrsr and a rectangle defined by
34     a start and an end point.
35 */
36 class SwBlockCursor : public IBlockCursor
37 {
38     SwShellCrsr aCursor;
39     Point *pStartPt;
40     Point *pEndPt;
41 public:
SwBlockCursor(const SwCrsrShell & rCrsrSh,const SwPosition & rPos)42 	SwBlockCursor( const SwCrsrShell& rCrsrSh, const SwPosition &rPos ) :
43         aCursor( rCrsrSh, rPos ), pStartPt(0), pEndPt(0) {}
44     virtual SwShellCrsr& getShellCrsr();
45     virtual void setStartPoint( const Point &rPt );
46     virtual void setEndPoint( const Point &rPt );
47     virtual const Point* getStartPoint() const;
48     virtual const Point* getEndPoint() const;
49     virtual void clearPoints();
50     virtual ~SwBlockCursor();
51 };
52 
~SwBlockCursor()53 SwBlockCursor::~SwBlockCursor()
54 {
55     delete pStartPt;
56     delete pEndPt;
57 }
58 
getShellCrsr()59 SwShellCrsr& SwBlockCursor::getShellCrsr()
60 {
61     return aCursor;
62 }
63 
setStartPoint(const Point & rPt)64 void SwBlockCursor::setStartPoint( const Point &rPt )
65 {
66     if( pStartPt )
67         *pStartPt = rPt;
68     else
69         pStartPt = new Point( rPt );
70 }
71 
setEndPoint(const Point & rPt)72 void SwBlockCursor::setEndPoint( const Point &rPt )
73 {
74     if( pEndPt )
75         *pEndPt = rPt;
76     else
77         pEndPt = new Point( rPt );
78 }
79 
getStartPoint() const80 const Point* SwBlockCursor::getStartPoint() const
81 {
82     return pStartPt;
83 }
84 
getEndPoint() const85 const Point* SwBlockCursor::getEndPoint() const
86 {
87     return pEndPt;
88 }
89 
clearPoints()90 void SwBlockCursor::clearPoints()
91 {
92     delete pStartPt;
93     delete pEndPt;
94     pStartPt = 0;
95     pEndPt = 0;
96 }
97 
createBlockCursor(const SwCrsrShell & rCrsrSh,const SwPosition & rPos)98 IBlockCursor *createBlockCursor( const SwCrsrShell& rCrsrSh, const SwPosition &rPos )
99 {
100     return new SwBlockCursor( rCrsrSh, rPos );
101 }
102 
103