LibreOffice Module sc (master)  1
chgviset.cxx
Go to the documentation of this file.
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 <unotools/textsearch.hxx>
21 
22 #include <chgviset.hxx>
23 #include <rechead.hxx>
24 #include <chgtrack.hxx>
25 #include <document.hxx>
26 
28 {
29 }
30 
32  aFirstDateTime( DateTime::EMPTY ),
33  aLastDateTime( DateTime::EMPTY )
34 {
36 
42  bShowIt =r.bShowIt;
43  bIsDate =r.bIsDate;
46  bIsRange =r.bIsRange;
52 
53 }
54 
56 {
57  pCommentSearcher = nullptr;
59 
65  bShowIt =r.bShowIt;
66  bIsDate =r.bIsDate;
69  bIsRange =r.bIsRange;
75 
76  return *this;
77 }
78 
79 bool ScChangeViewSettings::IsValidComment(const OUString* pCommentStr) const
80 {
81  bool bTheFlag = true;
82 
84  {
85  sal_Int32 nStartPos = 0;
86  sal_Int32 nEndPos = pCommentStr->getLength();
87  bTheFlag = pCommentSearcher->SearchForward(*pCommentStr, &nStartPos, &nEndPos);
88  }
89  return bTheFlag;
90 }
91 
92 void ScChangeViewSettings::SetTheComment(const OUString& rString)
93 {
94  aComment = rString;
95  pCommentSearcher.reset();
96 
97  if(!rString.isEmpty())
98  {
99  utl::SearchParam aSearchParam( rString,
101 
102  pCommentSearcher.reset( new utl::TextSearch( aSearchParam, *ScGlobal::getCharClassPtr() ) );
103  }
104 }
105 
107 {
108  switch ( eDateMode )
109  { // corresponds with ScViewUtil::IsActionShown
110  case SvxRedlinDateMode::EQUAL :
111  case SvxRedlinDateMode::NOTEQUAL :
112  aFirstDateTime.SetTime( 0 );
114  aLastDateTime.SetTime( 23595999 );
115  break;
116  case SvxRedlinDateMode::SAVE:
117  {
118  const ScChangeAction* pLast = nullptr;
119  ScChangeTrack* pTrack = rDoc.GetChangeTrack();
120  if ( pTrack )
121  {
122  pLast = pTrack->GetLastSaved();
123  if ( pLast )
124  {
125  aFirstDateTime = pLast->GetDateTime();
126 
127  // Set the next minute as the start time and assume that
128  // the document isn't saved, reloaded, edited and filter set
129  // all together during the gap between those two times.
130  aFirstDateTime += tools::Time( 0, 1 );
133  }
134  }
135  if ( !pLast )
136  {
137  aFirstDateTime.SetDate( 18990101 );
138  aFirstDateTime.SetTime( 0 );
139  }
141  aLastDateTime.AddYears( 100 );
142  }
143  break;
144  default:
145  {
146  // added to avoid warnings
147  }
148  }
149 }
150 
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uLong mnFirstAction
Definition: chgviset.hxx:52
ScRangeList aRangeList
Definition: chgviset.hxx:42
void SetSec(sal_uInt16 nNewSec)
ScChangeViewSettings & operator=(const ScChangeViewSettings &r)
Definition: chgviset.cxx:55
void AddYears(sal_Int16 nAddYears)
DateTime aLastDateTime
Definition: chgviset.hxx:39
ScChangeAction * GetLastSaved() const
Definition: chgtrack.cxx:2200
void SetTime(sal_Int64 nNewTime)
OUString aAuthorToShow
Definition: chgviset.hxx:40
sal_uLong mnLastAction
Definition: chgviset.hxx:53
void SetDate(sal_Int32 nNewDate)
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2392
void AdjustDateMode(const ScDocument &rDoc)
Adjust dates according to selected DateMode.
Definition: chgviset.cxx:106
void SetTheComment(const OUString &aString)
Definition: chgviset.cxx:92
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
Definition: global.cxx:1010
void SetNanoSec(sal_uInt32 nNewNanoSec)
std::unique_ptr< utl::TextSearch > pCommentSearcher
Definition: chgviset.hxx:37
DateTime aFirstDateTime
Definition: chgviset.hxx:38
bool IsValidComment(const OUString *pCommentStr) const
Definition: chgviset.cxx:79
SvxRedlinDateMode eDateMode
Definition: chgviset.hxx:43
SC_DLLPUBLIC DateTime GetDateTime() const
Definition: chgtrack.cxx:413