fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / core / tool / chgviset.cxx
blob0526c64d44ac3692bff6780cac8109008c34269a
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 "rechead.hxx"
24 #include "chgtrack.hxx"
25 #include "document.hxx"
27 ScChangeViewSettings::~ScChangeViewSettings()
29 delete pCommentSearcher;
32 ScChangeViewSettings::ScChangeViewSettings( const ScChangeViewSettings& r ):
33 pCommentSearcher(NULL),
34 aFirstDateTime( DateTime::EMPTY ),
35 aLastDateTime( DateTime::EMPTY )
37 SetTheComment(r.aComment);
39 aFirstDateTime =r.aFirstDateTime;
40 aLastDateTime =r.aLastDateTime;
41 aAuthorToShow =r.aAuthorToShow;
42 aRangeList =r.aRangeList;
43 eDateMode =r.eDateMode;
44 bShowIt =r.bShowIt;
45 bIsDate =r.bIsDate;
46 bIsAuthor =r.bIsAuthor;
47 bIsComment =r.bIsComment;
48 bIsRange =r.bIsRange;
49 bEveryoneButMe =r.bEveryoneButMe;
50 bShowAccepted =r.bShowAccepted;
51 bShowRejected =r.bShowRejected;
52 mbIsActionRange = r.mbIsActionRange;
53 mnFirstAction = r.mnFirstAction;
54 mnLastAction = r.mnLastAction;
58 ScChangeViewSettings& ScChangeViewSettings::operator=( const ScChangeViewSettings& r )
60 pCommentSearcher = NULL;
61 SetTheComment(r.aComment);
63 aFirstDateTime =r.aFirstDateTime;
64 aLastDateTime =r.aLastDateTime;
65 aAuthorToShow =r.aAuthorToShow;
66 aRangeList =r.aRangeList;
67 eDateMode =r.eDateMode;
68 bShowIt =r.bShowIt;
69 bIsDate =r.bIsDate;
70 bIsAuthor =r.bIsAuthor;
71 bIsComment =r.bIsComment;
72 bIsRange =r.bIsRange;
73 bEveryoneButMe =r.bEveryoneButMe;
74 bShowAccepted =r.bShowAccepted;
75 bShowRejected =r.bShowRejected;
76 mbIsActionRange = r.mbIsActionRange;
77 mnFirstAction = r.mnFirstAction;
78 mnLastAction = r.mnLastAction;
80 return *this;
83 bool ScChangeViewSettings::IsValidComment(const OUString* pCommentStr) const
85 bool nTheFlag = true;
87 if(pCommentSearcher)
89 sal_Int32 nStartPos = 0;
90 sal_Int32 nEndPos = pCommentStr->getLength();
91 nTheFlag = pCommentSearcher->SearchForward(*pCommentStr, &nStartPos, &nEndPos);
93 return nTheFlag;
96 void ScChangeViewSettings::SetTheComment(const OUString& rString)
98 aComment = rString;
99 if(pCommentSearcher)
101 delete pCommentSearcher;
102 pCommentSearcher=NULL;
105 if(!rString.isEmpty())
107 utl::SearchParam aSearchParam( rString,
108 utl::SearchParam::SRCH_REGEXP,false,false,false );
110 pCommentSearcher = new utl::TextSearch( aSearchParam, *ScGlobal::pCharClass );
114 void ScChangeViewSettings::AdjustDateMode( const ScDocument& rDoc )
116 switch ( eDateMode )
117 { // corresponds with ScViewUtil::IsActionShown
118 case SvxRedlinDateMode::EQUAL :
119 case SvxRedlinDateMode::NOTEQUAL :
120 aFirstDateTime.SetTime( 0 );
121 aLastDateTime = aFirstDateTime;
122 aLastDateTime.SetTime( 23595999 );
123 break;
124 case SvxRedlinDateMode::SAVE:
126 const ScChangeAction* pLast = 0;
127 ScChangeTrack* pTrack = rDoc.GetChangeTrack();
128 if ( pTrack )
130 pLast = pTrack->GetLastSaved();
131 if ( pLast )
133 aFirstDateTime = pLast->GetDateTime();
135 // Set the next minute as the start time and assume that
136 // the document isn't saved, reloaded, edited and filter set
137 // all together during the gap between those two times.
138 aFirstDateTime += tools::Time( 0, 1 );
139 aFirstDateTime.SetSec(0);
140 aFirstDateTime.SetNanoSec(0);
143 if ( !pLast )
145 aFirstDateTime.SetDate( 18990101 );
146 aFirstDateTime.SetTime( 0 );
148 aLastDateTime = Date( Date::SYSTEM );
149 aLastDateTime.SetYear( aLastDateTime.GetYear() + 100 );
151 break;
152 default:
154 // added to avoid warnings
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */