Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <docary.hxx>
21 : #include <vcl/window.hxx>
22 : #include "redline.hxx"
23 : #include "doc.hxx"
24 : #include "swundo.hxx"
25 : #include "editsh.hxx"
26 : #include "edimp.hxx"
27 : #include "frmtool.hxx"
28 :
29 :
30 0 : sal_uInt16 SwEditShell::GetRedlineMode() const
31 : {
32 0 : return GetDoc()->GetRedlineMode();
33 : }
34 :
35 0 : void SwEditShell::SetRedlineMode( sal_uInt16 eMode )
36 : {
37 0 : if( eMode != GetDoc()->GetRedlineMode() )
38 : {
39 0 : SET_CURR_SHELL( this );
40 0 : StartAllAction();
41 0 : GetDoc()->SetRedlineMode( (RedlineMode_t)eMode );
42 0 : EndAllAction();
43 : }
44 0 : }
45 :
46 0 : sal_Bool SwEditShell::IsRedlineOn() const
47 : {
48 0 : return GetDoc()->IsRedlineOn();
49 : }
50 :
51 0 : sal_uInt16 SwEditShell::GetRedlineCount() const
52 : {
53 0 : return GetDoc()->GetRedlineTbl().size();
54 : }
55 :
56 0 : const SwRedline& SwEditShell::GetRedline( sal_uInt16 nPos ) const
57 : {
58 0 : return *GetDoc()->GetRedlineTbl()[ nPos ];
59 : }
60 :
61 0 : static void lcl_InvalidateAll( ViewShell* pSh )
62 : {
63 0 : ViewShell *pStop = pSh;
64 0 : do
65 : {
66 0 : if ( pSh->GetWin() )
67 0 : pSh->GetWin()->Invalidate();
68 0 : pSh = (ViewShell*)pSh->GetNext();
69 :
70 : } while ( pSh != pStop );
71 0 : }
72 :
73 0 : sal_Bool SwEditShell::AcceptRedline( sal_uInt16 nPos )
74 : {
75 0 : SET_CURR_SHELL( this );
76 0 : StartAllAction();
77 0 : sal_Bool bRet = GetDoc()->AcceptRedline( nPos, true );
78 0 : if( !nPos && !::IsExtraData( GetDoc() ) )
79 0 : lcl_InvalidateAll( this );
80 0 : EndAllAction();
81 0 : return bRet;
82 : }
83 :
84 0 : sal_Bool SwEditShell::RejectRedline( sal_uInt16 nPos )
85 : {
86 0 : SET_CURR_SHELL( this );
87 0 : StartAllAction();
88 0 : sal_Bool bRet = GetDoc()->RejectRedline( nPos, true );
89 0 : if( !nPos && !::IsExtraData( GetDoc() ) )
90 0 : lcl_InvalidateAll( this );
91 0 : EndAllAction();
92 0 : return bRet;
93 : }
94 :
95 : // Kommentar am Redline setzen
96 0 : sal_Bool SwEditShell::SetRedlineComment( const String& rS )
97 : {
98 0 : sal_Bool bRet = sal_False;
99 0 : FOREACHPAM_START(this)
100 0 : bRet = bRet || GetDoc()->SetRedlineComment( *PCURCRSR, rS );
101 0 : FOREACHPAM_END()
102 :
103 0 : return bRet;
104 : }
105 :
106 0 : const SwRedline* SwEditShell::GetCurrRedline() const
107 : {
108 0 : return GetDoc()->GetRedline( *GetCrsr()->GetPoint(), 0 );
109 : }
110 :
111 0 : void SwEditShell::UpdateRedlineAttr()
112 : {
113 0 : if( ( nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE ) ==
114 0 : ( nsRedlineMode_t::REDLINE_SHOW_MASK & GetDoc()->GetRedlineMode() ))
115 : {
116 0 : SET_CURR_SHELL( this );
117 0 : StartAllAction();
118 :
119 0 : GetDoc()->UpdateRedlineAttr();
120 :
121 0 : EndAllAction();
122 : }
123 0 : }
124 :
125 : // suche das Redline zu diesem Data und returne die Pos im Array
126 : // USHRT_MAX wird returnt, falls nicht vorhanden
127 0 : sal_uInt16 SwEditShell::FindRedlineOfData( const SwRedlineData& rData ) const
128 : {
129 0 : const SwRedlineTbl& rTbl = GetDoc()->GetRedlineTbl();
130 :
131 0 : for( sal_uInt16 i = 0, nCnt = rTbl.size(); i < nCnt; ++i )
132 0 : if( &rTbl[ i ]->GetRedlineData() == &rData )
133 0 : return i;
134 0 : return USHRT_MAX;
135 : }
136 :
137 :
138 :
139 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|