LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - redcom.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 84 1.2 %
Date: 2015-06-13 12:38:46 Functions: 2 13 15.4 %
Legend: Lines: hit not hit

          Line data    Source code
       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 <vcl/msgbox.hxx>
      21             : #include <unotools/localedatawrapper.hxx>
      22             : 
      23             : #include "redcom.hxx"
      24             : #include "docsh.hxx"
      25             : #include "tabvwsh.hxx"
      26             : #include <svx/svxdlg.hxx>
      27             : #include <svx/dialogs.hrc>
      28             : 
      29           0 : ScRedComDialog::ScRedComDialog( vcl::Window* pParent, const SfxItemSet& rCoreSet,
      30             :                     ScDocShell *pShell, ScChangeAction *pAction, bool bPrevNext)
      31             :     : pChangeAction(NULL)
      32             :     , pDocShell(NULL)
      33           0 :     , pDlg(NULL)
      34             : {
      35           0 :     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
      36           0 :     if(pFact)
      37             :     {
      38           0 :         pDlg = pFact->CreateSvxPostItDialog( pParent, rCoreSet, bPrevNext );
      39             :         OSL_ENSURE(pDlg, "Dialog creation failed!");
      40           0 :         pDocShell=pShell;
      41           0 :         pDlg->DontChangeAuthor();
      42           0 :         pDlg->HideAuthor();
      43             : 
      44           0 :         pDlg->SetPrevHdl(LINK( this, ScRedComDialog, PrevHdl));
      45           0 :         pDlg->SetNextHdl(LINK( this, ScRedComDialog, NextHdl));
      46             : 
      47           0 :         ReInit(pAction);
      48             :     }
      49           0 : }
      50             : 
      51           0 : ScRedComDialog::~ScRedComDialog()
      52             : {
      53           0 :     delete pDlg;
      54           0 : }
      55             : 
      56           0 : ScChangeAction *ScRedComDialog::FindPrev(ScChangeAction *pAction)
      57             : {
      58           0 :     if(pAction!=NULL && pDocShell !=NULL)
      59             :     {
      60           0 :         ScDocument& rDoc = pDocShell->GetDocument();
      61           0 :         ScChangeViewSettings* pSettings = rDoc.GetChangeViewSettings();
      62             : 
      63           0 :         pAction=pAction->GetPrev();
      64             : 
      65           0 :         while(pAction!=NULL)
      66             :         {
      67           0 :             if( pAction->GetState()==SC_CAS_VIRGIN &&
      68           0 :                 pAction->IsDialogRoot() &&
      69           0 :                 ScViewUtil::IsActionShown(*pAction,*pSettings,rDoc)) break;
      70             : 
      71           0 :             pAction=pAction->GetPrev();
      72             :         }
      73             :     }
      74           0 :     return pAction;
      75             : }
      76             : 
      77           0 : ScChangeAction *ScRedComDialog::FindNext(ScChangeAction *pAction)
      78             : {
      79           0 :     if(pAction!=NULL && pDocShell !=NULL)
      80             :     {
      81           0 :         ScDocument& rDoc = pDocShell->GetDocument();
      82           0 :         ScChangeViewSettings* pSettings = rDoc.GetChangeViewSettings();
      83             : 
      84           0 :         pAction=pAction->GetNext();
      85             : 
      86           0 :         while(pAction!=NULL)
      87             :         {
      88           0 :             if( pAction->GetState()==SC_CAS_VIRGIN &&
      89           0 :                 pAction->IsDialogRoot() &&
      90           0 :                 ScViewUtil::IsActionShown(*pAction,*pSettings,rDoc)) break;
      91             : 
      92           0 :             pAction=pAction->GetNext();
      93             :         }
      94             :     }
      95           0 :     return pAction;
      96             : }
      97             : 
      98           0 : void ScRedComDialog::ReInit(ScChangeAction *pAction)
      99             : {
     100           0 :     pChangeAction=pAction;
     101           0 :     if(pChangeAction!=NULL && pDocShell !=NULL)
     102             :     {
     103           0 :         OUString aTitle;
     104           0 :         pChangeAction->GetDescription( aTitle, &pDocShell->GetDocument());
     105           0 :         pDlg->SetText(aTitle);
     106           0 :         aComment=pChangeAction->GetComment();
     107             : 
     108           0 :         bool bNext=FindNext(pChangeAction)!=NULL;
     109           0 :         bool bPrev=FindPrev(pChangeAction)!=NULL;
     110           0 :         pDlg->EnableTravel(bNext,bPrev);
     111             : 
     112           0 :         OUString aAuthor = pChangeAction->GetUser();
     113             : 
     114           0 :         DateTime aDT = pChangeAction->GetDateTime();
     115           0 :         OUString aDate = ScGlobal::pLocaleData->getDate( aDT );
     116           0 :         aDate += " ";
     117           0 :         aDate += ScGlobal::pLocaleData->getTime( aDT, false, false );
     118             : 
     119           0 :         pDlg->ShowLastAuthor(aAuthor, aDate);
     120           0 :         pDlg->SetNote(aComment);
     121             :     }
     122           0 : }
     123             : 
     124           0 : short ScRedComDialog::Execute()
     125             : {
     126           0 :     short nRet=pDlg->Execute();
     127             : 
     128           0 :     if(nRet== RET_OK )
     129             :     {
     130           0 :         if ( pDocShell!=NULL && pDlg->GetNote() != aComment )
     131           0 :             pDocShell->SetChangeComment( pChangeAction, pDlg->GetNote());
     132             :     }
     133             : 
     134           0 :     return nRet;
     135             : }
     136             : 
     137           0 : void ScRedComDialog::SelectCell()
     138             : {
     139           0 :     if(pChangeAction!=NULL)
     140             :     {
     141           0 :         const ScChangeAction* pAction=pChangeAction;
     142           0 :         const ScBigRange& rRange = pAction->GetBigRange();
     143             : 
     144           0 :         if(rRange.IsValid(&pDocShell->GetDocument()))
     145             :         {
     146           0 :             ScViewData* pViewData=ScDocShell::GetViewData();
     147           0 :             ScRange aRef=rRange.MakeRange();
     148           0 :             ScTabView* pTabView=pViewData->GetView();
     149           0 :             pTabView->MarkRange(aRef);
     150             :         }
     151             :     }
     152           0 : }
     153             : 
     154           0 : IMPL_LINK(ScRedComDialog, PrevHdl, AbstractSvxPostItDialog*, pDlgP )
     155             : {
     156           0 :     if (pDocShell!=NULL && pDlgP->GetNote() != aComment )
     157           0 :         pDocShell->SetChangeComment( pChangeAction, pDlgP->GetNote());
     158             : 
     159           0 :     ReInit(FindPrev(pChangeAction));
     160           0 :     SelectCell();
     161             : 
     162           0 :     return 0;
     163             : }
     164             : 
     165           0 : IMPL_LINK(ScRedComDialog, NextHdl, AbstractSvxPostItDialog*, pDlgP )
     166             : {
     167           0 :     if ( pDocShell!=NULL && pDlgP->GetNote() != aComment )
     168           0 :         pDocShell->SetChangeComment( pChangeAction, pDlgP->GetNote());
     169             : 
     170           0 :     ReInit(FindNext(pChangeAction));
     171           0 :     SelectCell();
     172             : 
     173           0 :     return 0;
     174         156 : }
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11