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
21
22#include <chgviset.hxx>
23#include <chgtrack.hxx>
24#include <document.hxx>
25
27{
28}
29
31 aFirstDateTime( DateTime::EMPTY ),
32 aLastDateTime( DateTime::EMPTY )
33{
35
51
52}
53
55{
56 pCommentSearcher = nullptr;
58
74
75 return *this;
76}
77
78bool ScChangeViewSettings::IsValidComment(const OUString* pCommentStr) const
79{
80 bool bTheFlag = true;
81
83 {
84 sal_Int32 nStartPos = 0;
85 sal_Int32 nEndPos = pCommentStr->getLength();
86 bTheFlag = pCommentSearcher->SearchForward(*pCommentStr, &nStartPos, &nEndPos);
87 }
88 return bTheFlag;
89}
90
91void ScChangeViewSettings::SetTheComment(const OUString& rString)
92{
93 aComment = rString;
94 pCommentSearcher.reset();
95
96 if(!rString.isEmpty())
97 {
98 utl::SearchParam aSearchParam( rString,
100
101 pCommentSearcher.reset( new utl::TextSearch( aSearchParam, ScGlobal::getCharClass() ) );
102 }
103}
104
106{
107 switch ( eDateMode )
108 { // corresponds with ScViewUtil::IsActionShown
109 case SvxRedlinDateMode::EQUAL :
110 case SvxRedlinDateMode::NOTEQUAL :
113 aLastDateTime.SetTime( 23595999 );
114 break;
115 case SvxRedlinDateMode::SAVE:
116 {
117 const ScChangeAction* pLast = nullptr;
118 ScChangeTrack* pTrack = rDoc.GetChangeTrack();
119 if ( pTrack )
120 {
121 pLast = pTrack->GetLastSaved();
122 if ( pLast )
123 {
124 aFirstDateTime = pLast->GetDateTime();
125
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 );
132 }
133 }
134 if ( !pLast )
135 {
136 aFirstDateTime.SetDate( 18990101 );
138 }
140 aLastDateTime.AddYears( 100 );
141 }
142 break;
143 default:
144 {
145 // added to avoid warnings
146 }
147 }
148}
149
150/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetDate(sal_Int32 nNewDate)
void AddYears(sal_Int16 nAddYears)
SC_DLLPUBLIC DateTime GetDateTime() const
Definition: chgtrack.cxx:407
ScChangeAction * GetLastSaved() const
Definition: chgtrack.cxx:2144
DateTime aFirstDateTime
Definition: chgviset.hxx:37
ScRangeList aRangeList
Definition: chgviset.hxx:41
bool IsValidComment(const OUString *pCommentStr) const
Definition: chgviset.cxx:78
OUString aAuthorToShow
Definition: chgviset.hxx:39
DateTime aLastDateTime
Definition: chgviset.hxx:38
void SetTheComment(const OUString &aString)
Definition: chgviset.cxx:91
ScChangeViewSettings & operator=(const ScChangeViewSettings &r)
Definition: chgviset.cxx:54
sal_uLong mnFirstAction
Definition: chgviset.hxx:51
sal_uLong mnLastAction
Definition: chgviset.hxx:52
SvxRedlinDateMode eDateMode
Definition: chgviset.hxx:42
std::unique_ptr< utl::TextSearch > pCommentSearcher
Definition: chgviset.hxx:36
void AdjustDateMode(const ScDocument &rDoc)
Adjust dates according to selected DateMode.
Definition: chgviset.cxx:105
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2494
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1064
void SetNanoSec(sal_uInt32 nNewNanoSec)
void SetTime(sal_Int64 nNewTime)
void SetSec(sal_uInt16 nNewSec)
constexpr OUStringLiteral EMPTY