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