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

Generated by: LCOV version 1.10