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

Generated by: LCOV version 1.10