Update ooo320-m1
[ooovba.git] / sc / source / core / tool / chgviset.cxx
blob6295dbc43cfcb77f3f15c79932f31773fe8c3921
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: chgviset.cxx,v $
10 * $Revision: 1.8.32.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 #include <unotools/textsearch.hxx>
38 #include "chgviset.hxx"
39 #include "rechead.hxx"
40 #include "chgtrack.hxx"
42 // -----------------------------------------------------------------------
43 ScChangeViewSettings::~ScChangeViewSettings()
45 if(pCommentSearcher!=NULL)
46 delete pCommentSearcher;
49 ScChangeViewSettings::ScChangeViewSettings( const ScChangeViewSettings& r )
51 SetTheComment(r.aComment);
53 aFirstDateTime =r.aFirstDateTime;
54 aLastDateTime =r.aLastDateTime;
55 aAuthorToShow =r.aAuthorToShow;
56 aRangeList =r.aRangeList;
57 eDateMode =r.eDateMode;
58 bShowIt =r.bShowIt;
59 bIsDate =r.bIsDate;
60 bIsAuthor =r.bIsAuthor;
61 bIsComment =r.bIsComment;
62 bIsRange =r.bIsRange;
63 bEveryoneButMe =r.bEveryoneButMe;
64 bShowAccepted =r.bShowAccepted;
65 bShowRejected =r.bShowRejected;
66 mbIsActionRange = r.mbIsActionRange;
67 mnFirstAction = r.mnFirstAction;
68 mnLastAction = r.mnLastAction;
72 ScChangeViewSettings& ScChangeViewSettings::operator=( const ScChangeViewSettings& r )
74 SetTheComment(r.aComment);
76 aFirstDateTime =r.aFirstDateTime;
77 aLastDateTime =r.aLastDateTime;
78 aAuthorToShow =r.aAuthorToShow;
79 aRangeList =r.aRangeList;
80 eDateMode =r.eDateMode;
81 bShowIt =r.bShowIt;
82 bIsDate =r.bIsDate;
83 bIsAuthor =r.bIsAuthor;
84 bIsComment =r.bIsComment;
85 bIsRange =r.bIsRange;
86 bEveryoneButMe =r.bEveryoneButMe;
87 bShowAccepted =r.bShowAccepted;
88 bShowRejected =r.bShowRejected;
89 mbIsActionRange = r.mbIsActionRange;
90 mnFirstAction = r.mnFirstAction;
91 mnLastAction = r.mnLastAction;
93 return *this;
96 BOOL ScChangeViewSettings::IsValidComment(const String* pCommentStr) const
98 BOOL nTheFlag=TRUE;
100 if(pCommentSearcher!=NULL)
102 xub_StrLen nStartPos = 0;
103 xub_StrLen nEndPos = pCommentStr->Len();
105 nTheFlag=sal::static_int_cast<BOOL>(pCommentSearcher->SearchFrwrd( *pCommentStr, &nStartPos, &nEndPos));
107 return nTheFlag;
110 void ScChangeViewSettings::SetTheComment(const String& rString)
112 aComment=rString;
113 if(pCommentSearcher!=NULL)
115 delete pCommentSearcher;
116 pCommentSearcher=NULL;
119 if(rString.Len()>0)
121 utl::SearchParam aSearchParam( rString,
122 utl::SearchParam::SRCH_REGEXP,FALSE,FALSE,FALSE );
124 pCommentSearcher = new utl::TextSearch( aSearchParam, *ScGlobal::pCharClass );
128 void ScChangeViewSettings::AdjustDateMode( const ScDocument& rDoc )
130 switch ( eDateMode )
131 { // corresponds with ScViewUtil::IsActionShown
132 case SCDM_DATE_EQUAL :
133 case SCDM_DATE_NOTEQUAL :
134 aFirstDateTime.SetTime( 0 );
135 aLastDateTime = aFirstDateTime;
136 aLastDateTime.SetTime( 23595999 );
137 break;
138 case SCDM_DATE_SAVE:
140 const ScChangeAction* pLast = 0;
141 ScChangeTrack* pTrack = rDoc.GetChangeTrack();
142 if ( pTrack )
144 pLast = pTrack->GetLastSaved();
145 if ( pLast )
147 aFirstDateTime = pLast->GetDateTime();
148 #if 0
149 // This would be the proper handling. But since the SvxTPFilter dialog uses
150 // DateField/TimeField, and the filter dialog is used in ScAcceptChgDlg as the
151 // controlling instance, and the TimeFields are used there without seconds or
152 // 100ths, we'd display some extra entries between the floor of the minute and
153 // the start of the next minute.
154 // add one 100th second to point past last saved
155 aFirstDateTime += Time( 0, 0, 0, 1 );
156 #else
157 // Set the next minute as the start time and assume that
158 // the document isn't saved, reloaded, edited and filter set
159 // all together during the gap between those two times.
160 aFirstDateTime += Time( 0, 1 );
161 aFirstDateTime.SetSec(0);
162 aFirstDateTime.Set100Sec(0);
163 #endif
166 if ( !pLast )
168 aFirstDateTime.SetDate( 18990101 );
169 aFirstDateTime.SetTime( 0 );
171 aLastDateTime = Date();
172 aLastDateTime.SetYear( aLastDateTime.GetYear() + 100 );
174 break;
175 default:
177 // added to avoid warnings