LibreOffice Module sc (master)  1
redcom.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 <chgtrack.hxx>
23 #include <redcom.hxx>
24 #include <docsh.hxx>
25 #include <dbfunc.hxx>
26 #include <tabview.hxx>
27 #include <viewutil.hxx>
28 #include <svx/svxdlg.hxx>
29 
31  ScDocShell *pShell, ScChangeAction *pAction, bool bPrevNext)
32  : pChangeAction(nullptr)
33  , pDocShell(nullptr)
34  , pDlg(nullptr)
35 {
37  pDlg = pFact->CreateSvxPostItDialog( pParent, rCoreSet, bPrevNext );
38  pDocShell=pShell;
40  pDlg->HideAuthor();
41 
42  pDlg->SetPrevHdl(LINK( this, ScRedComDialog, PrevHdl));
43  pDlg->SetNextHdl(LINK( this, ScRedComDialog, NextHdl));
44 
45  ReInit(pAction);
46 }
47 
49 {
51 }
52 
54 {
55  if(pAction!=nullptr && pDocShell !=nullptr)
56  {
57  ScDocument& rDoc = pDocShell->GetDocument();
58  ScChangeViewSettings* pSettings = rDoc.GetChangeViewSettings();
59 
60  pAction=pAction->GetPrev();
61 
62  while(pAction!=nullptr)
63  {
64  if( pAction->GetState()==SC_CAS_VIRGIN &&
65  pAction->IsDialogRoot() &&
66  ScViewUtil::IsActionShown(*pAction,*pSettings,rDoc)) break;
67 
68  pAction=pAction->GetPrev();
69  }
70  }
71  return pAction;
72 }
73 
75 {
76  if(pAction!=nullptr && pDocShell !=nullptr)
77  {
78  ScDocument& rDoc = pDocShell->GetDocument();
79  ScChangeViewSettings* pSettings = rDoc.GetChangeViewSettings();
80 
81  pAction=pAction->GetNext();
82 
83  while(pAction!=nullptr)
84  {
85  if( pAction->GetState()==SC_CAS_VIRGIN &&
86  pAction->IsDialogRoot() &&
87  ScViewUtil::IsActionShown(*pAction,*pSettings,rDoc)) break;
88 
89  pAction=pAction->GetNext();
90  }
91  }
92  return pAction;
93 }
94 
96 {
97  pChangeAction=pAction;
98  if(pChangeAction==nullptr || pDocShell ==nullptr)
99  return;
100 
101  OUString aTitle = pChangeAction->GetDescription(pDocShell->GetDocument());
102  pDlg->SetText(aTitle);
104 
105  bool bNext=FindNext(pChangeAction)!=nullptr;
106  bool bPrev=FindPrev(pChangeAction)!=nullptr;
107  pDlg->EnableTravel(bNext,bPrev);
108 
109  OUString aAuthor = pChangeAction->GetUser();
110 
112  OUString aDate = ScGlobal::getLocaleData().getDate( aDT ) + " " +
113  ScGlobal::getLocaleData().getTime( aDT, false );
114 
115  pDlg->ShowLastAuthor(aAuthor, aDate);
117 }
118 
120 {
121  short nRet=pDlg->Execute();
122 
123  if(nRet== RET_OK )
124  {
125  if ( pDocShell!=nullptr && pDlg->GetNote() != aComment )
127  }
128 }
129 
131 {
132  if(pChangeAction==nullptr)
133  return;
134 
135  const ScChangeAction* pAction=pChangeAction;
136  const ScBigRange& rRange = pAction->GetBigRange();
137 
138  if(rRange.IsValid(pDocShell->GetDocument()))
139  {
140  ScViewData* pViewData=ScDocShell::GetViewData();
141  ScRange aRef=rRange.MakeRange();
142  ScTabView* pTabView=pViewData->GetView();
143  pTabView->MarkRange(aRef);
144  }
145 }
146 
148 {
149  if (pDocShell!=nullptr && rDlgP.GetNote() != aComment )
150  pDocShell->SetChangeComment( pChangeAction, rDlgP.GetNote());
151 
152  ReInit(FindPrev(pChangeAction));
153  SelectCell();
154 }
155 
157 {
158  if ( pDocShell!=nullptr && rDlgP.GetNote() != aComment )
159  pDocShell->SetChangeComment( pChangeAction, rDlgP.GetNote());
160 
161  ReInit(FindNext(pChangeAction));
162  SelectCell();
163 }
164 
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsDialogRoot() const
Definition: chgtrack.cxx:232
void SelectCell()
Definition: redcom.cxx:130
static bool IsActionShown(const ScChangeAction &rAction, const ScChangeViewSettings &rSettings, ScDocument &rDocument)
Definition: viewutil.cxx:134
ScChangeAction * GetNext() const
Definition: chgtrack.hxx:322
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
Definition: tabview3.cxx:1687
ScChangeActionState GetState() const
Definition: chgtrack.hxx:318
static SvxAbstractDialogFactory * Create()
void disposeAndClear()
void ReInit(ScChangeAction *)
Definition: redcom.cxx:95
virtual OUString GetDescription(ScDocument &rDoc, bool bSplitRange=false, bool bWarning=true) const
Definition: chgtrack.cxx:420
virtual VclPtr< AbstractSvxPostItDialog > CreateSvxPostItDialog(weld::Widget *pParent, const SfxItemSet &rCoreSet, bool bPrevNext=false)=0
ScChangeAction * GetPrev() const
Definition: chgtrack.hxx:323
static SC_DLLPUBLIC const LocaleDataWrapper & getLocaleData()
Definition: global.cxx:1004
VclPtr< AbstractSvxPostItDialog > pDlg
Definition: redcom.hxx:37
virtual void HideAuthor()=0
virtual void SetText(const OUString &rStr)=0
ScChangeAction * FindPrev(ScChangeAction *pAction)
Definition: redcom.cxx:53
virtual void DontChangeAuthor()=0
ScChangeAction * FindNext(ScChangeAction *pAction)
Definition: redcom.cxx:74
IMPL_LINK(ScRedComDialog, PrevHdl, AbstractSvxPostItDialog &, rDlgP, void)
Definition: redcom.cxx:147
virtual void ShowLastAuthor(const OUString &rAuthor, const OUString &rDate)=0
const OUString & GetComment() const
Definition: chgtrack.hxx:350
bool IsValid(const ScDocument &rDoc) const
Definition: bigrange.hxx:134
virtual void EnableTravel(bool bNext, bool bPrev)=0
ScBigRange & GetBigRange()
Definition: chgtrack.hxx:231
ScDocShell * pDocShell
Definition: redcom.hxx:35
static ScViewData * GetViewData()
Definition: docsh4.cxx:2579
ScDBFunc * GetView() const
Definition: viewdata.cxx:861
void SetChangeComment(ScChangeAction *pAction, const OUString &rComment)
Definition: docsh3.cxx:620
OUString getDate(const Date &rDate) const
virtual void SetNextHdl(const Link< AbstractSvxPostItDialog &, void > &rLink)=0
ScRange MakeRange() const
Definition: bigrange.hxx:136
virtual OUString GetNote()=0
ScChangeAction * pChangeAction
Definition: redcom.hxx:34
void Execute()
Definition: redcom.cxx:119
RET_OK
ScChangeViewSettings * GetChangeViewSettings() const
Definition: document.hxx:2166
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
const OUString & GetUser() const
Definition: chgtrack.hxx:349
ScRedComDialog(weld::Window *pParent, const SfxItemSet &rCoreSet, ScDocShell *pShell, ScChangeAction *pAction, bool bPrevNext)
Definition: redcom.cxx:30
OUString aComment
Definition: redcom.hxx:36
OUString getTime(const tools::Time &rTime, bool bSec=true, bool b100Sec=false) const
SC_DLLPUBLIC DateTime GetDateTime() const
Definition: chgtrack.cxx:406
virtual void SetNote(const OUString &rTxt)=0
virtual void SetPrevHdl(const Link< AbstractSvxPostItDialog &, void > &rLink)=0