xref: /aoo42x/main/sw/source/core/edit/edredln.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 
32 #include <docary.hxx>
33 #include <vcl/window.hxx>
34 #include "redline.hxx"
35 #include "doc.hxx"
36 #include "swundo.hxx"
37 #include "editsh.hxx"
38 #include "edimp.hxx"
39 #include "frmtool.hxx"
40 
41 
42 sal_uInt16 SwEditShell::GetRedlineMode() const
43 {
44 	return GetDoc()->GetRedlineMode();
45 }
46 
47 void SwEditShell::SetRedlineMode( sal_uInt16 eMode )
48 {
49 	if( eMode != GetDoc()->GetRedlineMode() )
50 	{
51 		SET_CURR_SHELL( this );
52 		StartAllAction();
53 		GetDoc()->SetRedlineMode( (RedlineMode_t)eMode );
54 		EndAllAction();
55 	}
56 }
57 
58 sal_Bool SwEditShell::IsRedlineOn() const
59 {
60 	return GetDoc()->IsRedlineOn();
61 }
62 
63 sal_uInt16 SwEditShell::GetRedlineCount() const
64 {
65 	return GetDoc()->GetRedlineTbl().Count();
66 }
67 
68 const SwRedline& SwEditShell::GetRedline( sal_uInt16 nPos ) const
69 {
70 	return *GetDoc()->GetRedlineTbl()[ nPos ];
71 }
72 
73 void lcl_InvalidateAll( ViewShell* pSh )
74 {
75 	ViewShell *pStop = pSh;
76 	do
77 	{
78 		if ( pSh->GetWin() )
79 			pSh->GetWin()->Invalidate();
80 		pSh = (ViewShell*)pSh->GetNext();
81 
82 	} while ( pSh != pStop );
83 }
84 
85 sal_Bool SwEditShell::AcceptRedline( sal_uInt16 nPos )
86 {
87 	SET_CURR_SHELL( this );
88 	StartAllAction();
89 	sal_Bool bRet = GetDoc()->AcceptRedline( nPos, true );
90 	if( !nPos && !::IsExtraData( GetDoc() ) )
91 		lcl_InvalidateAll( this );
92 	EndAllAction();
93 	return bRet;
94 }
95 
96 sal_Bool SwEditShell::RejectRedline( sal_uInt16 nPos )
97 {
98 	SET_CURR_SHELL( this );
99 	StartAllAction();
100 	sal_Bool bRet = GetDoc()->RejectRedline( nPos, true );
101 	if( !nPos && !::IsExtraData( GetDoc() ) )
102 		lcl_InvalidateAll( this );
103 	EndAllAction();
104 	return bRet;
105 }
106 
107 // Kommentar am Redline setzen
108 sal_Bool SwEditShell::SetRedlineComment( const String& rS )
109 {
110 	sal_Bool bRet = sal_False;
111 	FOREACHPAM_START(this)
112 		bRet = bRet || GetDoc()->SetRedlineComment( *PCURCRSR, rS );
113 	FOREACHPAM_END()
114 
115 	return bRet;
116 }
117 
118 const SwRedline* SwEditShell::GetCurrRedline() const
119 {
120 	return GetDoc()->GetRedline( *GetCrsr()->GetPoint(), 0 );
121 }
122 
123 void SwEditShell::UpdateRedlineAttr()
124 {
125 	if( ( nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE ) ==
126 		( nsRedlineMode_t::REDLINE_SHOW_MASK & GetDoc()->GetRedlineMode() ))
127 	{
128 		SET_CURR_SHELL( this );
129 		StartAllAction();
130 
131 		GetDoc()->UpdateRedlineAttr();
132 
133 		EndAllAction();
134 	}
135 }
136 
137 	// suche das Redline zu diesem Data und returne die Pos im Array
138 	// USHRT_MAX wird returnt, falls nicht vorhanden
139 sal_uInt16 SwEditShell::FindRedlineOfData( const SwRedlineData& rData ) const
140 {
141 	const SwRedlineTbl& rTbl = GetDoc()->GetRedlineTbl();
142 
143 	for( sal_uInt16 i = 0, nCnt = rTbl.Count(); i < nCnt; ++i )
144 		if( &rTbl[ i ]->GetRedlineData() == &rData )
145 			return i;
146 	return USHRT_MAX;
147 }
148 
149 
150 
151