tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / core / tool / chgviset.cxx
blob1e35922e90a86e558c6851edf3fbf28a84946129
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <unotools/textsearch.hxx>
22 #include <chgviset.hxx>
23 #include <chgtrack.hxx>
24 #include <document.hxx>
26 ScChangeViewSettings::~ScChangeViewSettings()
30 ScChangeViewSettings::ScChangeViewSettings( const ScChangeViewSettings& r ):
31 aFirstDateTime( DateTime::EMPTY ),
32 aLastDateTime( DateTime::EMPTY )
34 SetTheComment(r.aComment);
36 aFirstDateTime =r.aFirstDateTime;
37 aLastDateTime =r.aLastDateTime;
38 aAuthorToShow =r.aAuthorToShow;
39 aRangeList =r.aRangeList;
40 eDateMode =r.eDateMode;
41 bShowIt =r.bShowIt;
42 bIsDate =r.bIsDate;
43 bIsAuthor =r.bIsAuthor;
44 bIsComment =r.bIsComment;
45 bIsRange =r.bIsRange;
46 bShowAccepted =r.bShowAccepted;
47 bShowRejected =r.bShowRejected;
48 mbIsActionRange = r.mbIsActionRange;
49 mnFirstAction = r.mnFirstAction;
50 mnLastAction = r.mnLastAction;
54 ScChangeViewSettings& ScChangeViewSettings::operator=( const ScChangeViewSettings& r )
56 pCommentSearcher = nullptr;
57 SetTheComment(r.aComment);
59 aFirstDateTime =r.aFirstDateTime;
60 aLastDateTime =r.aLastDateTime;
61 aAuthorToShow =r.aAuthorToShow;
62 aRangeList =r.aRangeList;
63 eDateMode =r.eDateMode;
64 bShowIt =r.bShowIt;
65 bIsDate =r.bIsDate;
66 bIsAuthor =r.bIsAuthor;
67 bIsComment =r.bIsComment;
68 bIsRange =r.bIsRange;
69 bShowAccepted =r.bShowAccepted;
70 bShowRejected =r.bShowRejected;
71 mbIsActionRange = r.mbIsActionRange;
72 mnFirstAction = r.mnFirstAction;
73 mnLastAction = r.mnLastAction;
75 return *this;
78 bool ScChangeViewSettings::IsValidComment(const OUString* pCommentStr) const
80 bool bTheFlag = true;
82 if(pCommentSearcher)
84 sal_Int32 nStartPos = 0;
85 sal_Int32 nEndPos = pCommentStr->getLength();
86 bTheFlag = pCommentSearcher->SearchForward(*pCommentStr, &nStartPos, &nEndPos);
88 return bTheFlag;
91 void ScChangeViewSettings::SetTheComment(const OUString& rString)
93 aComment = rString;
94 pCommentSearcher.reset();
96 if(!rString.isEmpty())
98 utl::SearchParam aSearchParam( rString,
99 utl::SearchParam::SearchType::Regexp,false );
101 pCommentSearcher.reset( new utl::TextSearch( aSearchParam, ScGlobal::getCharClass() ) );
105 void ScChangeViewSettings::AdjustDateMode( const ScDocument& rDoc )
107 switch ( eDateMode )
108 { // corresponds with ScViewUtil::IsActionShown
109 case SvxRedlinDateMode::EQUAL :
110 case SvxRedlinDateMode::NOTEQUAL :
111 aFirstDateTime.SetTime( 0 );
112 aLastDateTime = aFirstDateTime;
113 aLastDateTime.SetTime( 23595999 );
114 break;
115 case SvxRedlinDateMode::SAVE:
117 const ScChangeAction* pLast = nullptr;
118 ScChangeTrack* pTrack = rDoc.GetChangeTrack();
119 if ( pTrack )
121 pLast = pTrack->GetLastSaved();
122 if ( pLast )
124 aFirstDateTime = pLast->GetDateTime();
126 // Set the next minute as the start time and assume that
127 // the document isn't saved, reloaded, edited and filter set
128 // all together during the gap between those two times.
129 aFirstDateTime += tools::Time( 0, 1 );
130 aFirstDateTime.SetSec(0);
131 aFirstDateTime.SetNanoSec(0);
134 if ( !pLast )
136 aFirstDateTime.SetDate( 18990101 );
137 aFirstDateTime.SetTime( 0 );
139 aLastDateTime = DateTime( Date( Date::SYSTEM ) );
140 aLastDateTime.AddYears( 100 );
142 break;
143 default:
145 // added to avoid warnings
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */