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