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
28 #include <docary.hxx>
29 #include <vcl/window.hxx>
30 #include "redline.hxx"
31 #include "doc.hxx"
32 #include "swundo.hxx"
33 #include "editsh.hxx"
34 #include "edimp.hxx"
35 #include "frmtool.hxx"
36
37
GetRedlineMode() const38 sal_uInt16 SwEditShell::GetRedlineMode() const
39 {
40 return GetDoc()->GetRedlineMode();
41 }
42
SetRedlineMode(sal_uInt16 eMode)43 void SwEditShell::SetRedlineMode( sal_uInt16 eMode )
44 {
45 if( eMode != GetDoc()->GetRedlineMode() )
46 {
47 SET_CURR_SHELL( this );
48 StartAllAction();
49 GetDoc()->SetRedlineMode( (RedlineMode_t)eMode );
50 EndAllAction();
51 }
52 }
53
IsRedlineOn() const54 sal_Bool SwEditShell::IsRedlineOn() const
55 {
56 return GetDoc()->IsRedlineOn();
57 }
58
GetRedlineCount() const59 sal_uInt16 SwEditShell::GetRedlineCount() const
60 {
61 return GetDoc()->GetRedlineTbl().Count();
62 }
63
GetRedline(sal_uInt16 nPos) const64 const SwRedline& SwEditShell::GetRedline( sal_uInt16 nPos ) const
65 {
66 return *GetDoc()->GetRedlineTbl()[ nPos ];
67 }
68
lcl_InvalidateAll(ViewShell * pSh)69 void lcl_InvalidateAll( ViewShell* pSh )
70 {
71 ViewShell *pStop = pSh;
72 do
73 {
74 if ( pSh->GetWin() )
75 pSh->GetWin()->Invalidate();
76 pSh = (ViewShell*)pSh->GetNext();
77
78 } while ( pSh != pStop );
79 }
80
AcceptRedline(sal_uInt16 nPos)81 sal_Bool SwEditShell::AcceptRedline( sal_uInt16 nPos )
82 {
83 SET_CURR_SHELL( this );
84 StartAllAction();
85 sal_Bool bRet = GetDoc()->AcceptRedline( nPos, true );
86 if( !nPos && !::IsExtraData( GetDoc() ) )
87 lcl_InvalidateAll( this );
88 EndAllAction();
89 return bRet;
90 }
91
RejectRedline(sal_uInt16 nPos)92 sal_Bool SwEditShell::RejectRedline( sal_uInt16 nPos )
93 {
94 SET_CURR_SHELL( this );
95 StartAllAction();
96 sal_Bool bRet = GetDoc()->RejectRedline( nPos, true );
97 if( !nPos && !::IsExtraData( GetDoc() ) )
98 lcl_InvalidateAll( this );
99 EndAllAction();
100 return bRet;
101 }
102
103 // Kommentar am Redline setzen
SetRedlineComment(const String & rS)104 sal_Bool SwEditShell::SetRedlineComment( const String& rS )
105 {
106 sal_Bool bRet = sal_False;
107 FOREACHPAM_START(this)
108 bRet = bRet || GetDoc()->SetRedlineComment( *PCURCRSR, rS );
109 FOREACHPAM_END()
110
111 return bRet;
112 }
113
GetCurrRedline() const114 const SwRedline* SwEditShell::GetCurrRedline() const
115 {
116 return GetDoc()->GetRedline( *GetCrsr()->GetPoint(), 0 );
117 }
118
UpdateRedlineAttr()119 void SwEditShell::UpdateRedlineAttr()
120 {
121 if( ( nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE ) ==
122 ( nsRedlineMode_t::REDLINE_SHOW_MASK & GetDoc()->GetRedlineMode() ))
123 {
124 SET_CURR_SHELL( this );
125 StartAllAction();
126
127 GetDoc()->UpdateRedlineAttr();
128
129 EndAllAction();
130 }
131 }
132
133 // suche das Redline zu diesem Data und returne die Pos im Array
134 // USHRT_MAX wird returnt, falls nicht vorhanden
FindRedlineOfData(const SwRedlineData & rData) const135 sal_uInt16 SwEditShell::FindRedlineOfData( const SwRedlineData& rData ) const
136 {
137 const SwRedlineTbl& rTbl = GetDoc()->GetRedlineTbl();
138
139 for( sal_uInt16 i = 0, nCnt = rTbl.Count(); i < nCnt; ++i )
140 if( &rTbl[ i ]->GetRedlineData() == &rData )
141 return i;
142 return USHRT_MAX;
143 }
144
145
146
147