LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - redcom.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 83 0.0 %
Date: 2012-08-25 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 158 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <vcl/msgbox.hxx>
      30                 :            : #include <unotools/localedatawrapper.hxx>
      31                 :            : 
      32                 :            : #include "redcom.hxx"
      33                 :            : #include "docsh.hxx"
      34                 :            : #include "tabvwsh.hxx"
      35                 :            : #include <svx/svxdlg.hxx>
      36                 :            : #include <svx/dialogs.hrc>
      37                 :            : //------------------------------------------------------------------------
      38                 :            : 
      39                 :          0 : ScRedComDialog::ScRedComDialog( Window* pParent, const SfxItemSet& rCoreSet,
      40                 :          0 :                     ScDocShell *pShell,ScChangeAction *pAction,sal_Bool bPrevNext)
      41                 :            : {
      42         [ #  # ]:          0 :     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
      43         [ #  # ]:          0 :     if(pFact)
      44                 :            :     {
      45         [ #  # ]:          0 :         pDlg = pFact->CreateSvxPostItDialog( pParent, rCoreSet, bPrevNext, true );
      46                 :            :         OSL_ENSURE(pDlg, "Dialog creation failed!");
      47                 :          0 :         pDocShell=pShell;
      48         [ #  # ]:          0 :         pDlg->DontChangeAuthor();
      49         [ #  # ]:          0 :         pDlg->HideAuthor();
      50                 :            : 
      51 [ #  # ][ #  # ]:          0 :         pDlg->SetPrevHdl(LINK( this, ScRedComDialog, PrevHdl));
      52 [ #  # ][ #  # ]:          0 :         pDlg->SetNextHdl(LINK( this, ScRedComDialog, NextHdl));
      53                 :            : 
      54         [ #  # ]:          0 :         ReInit(pAction);
      55                 :            :     }
      56                 :          0 : }
      57                 :            : 
      58                 :          0 : ScRedComDialog::~ScRedComDialog()
      59                 :            : {
      60 [ #  # ][ #  # ]:          0 :     delete pDlg;
      61                 :          0 : }
      62                 :            : 
      63                 :          0 : ScChangeAction *ScRedComDialog::FindPrev(ScChangeAction *pAction)
      64                 :            : {
      65 [ #  # ][ #  # ]:          0 :     if(pAction!=NULL && pDocShell !=NULL)
      66                 :            :     {
      67                 :          0 :         ScDocument* pDoc = pDocShell->GetDocument();
      68                 :          0 :         ScChangeViewSettings* pSettings = pDoc->GetChangeViewSettings();
      69                 :            : 
      70                 :          0 :         pAction=pAction->GetPrev();
      71                 :            : 
      72         [ #  # ]:          0 :         while(pAction!=NULL)
      73                 :            :         {
      74   [ #  #  #  #  :          0 :             if( pAction->GetState()==SC_CAS_VIRGIN &&
           #  # ][ #  # ]
      75                 :          0 :                 pAction->IsDialogRoot() &&
      76                 :          0 :                 ScViewUtil::IsActionShown(*pAction,*pSettings,*pDoc)) break;
      77                 :            : 
      78                 :          0 :             pAction=pAction->GetPrev();
      79                 :            :         }
      80                 :            :     }
      81                 :          0 :     return pAction;
      82                 :            : }
      83                 :            : 
      84                 :          0 : ScChangeAction *ScRedComDialog::FindNext(ScChangeAction *pAction)
      85                 :            : {
      86 [ #  # ][ #  # ]:          0 :     if(pAction!=NULL && pDocShell !=NULL)
      87                 :            :     {
      88                 :          0 :         ScDocument* pDoc = pDocShell->GetDocument();
      89                 :          0 :         ScChangeViewSettings* pSettings = pDoc->GetChangeViewSettings();
      90                 :            : 
      91                 :          0 :         pAction=pAction->GetNext();
      92                 :            : 
      93         [ #  # ]:          0 :         while(pAction!=NULL)
      94                 :            :         {
      95   [ #  #  #  #  :          0 :             if( pAction->GetState()==SC_CAS_VIRGIN &&
           #  # ][ #  # ]
      96                 :          0 :                 pAction->IsDialogRoot() &&
      97                 :          0 :                 ScViewUtil::IsActionShown(*pAction,*pSettings,*pDoc)) break;
      98                 :            : 
      99                 :          0 :             pAction=pAction->GetNext();
     100                 :            :         }
     101                 :            :     }
     102                 :          0 :     return pAction;
     103                 :            : }
     104                 :            : 
     105                 :          0 : void ScRedComDialog::ReInit(ScChangeAction *pAction)
     106                 :            : {
     107                 :          0 :     pChangeAction=pAction;
     108 [ #  # ][ #  # ]:          0 :     if(pChangeAction!=NULL && pDocShell !=NULL)
     109                 :            :     {
     110                 :          0 :         rtl::OUString aTitle;
     111         [ #  # ]:          0 :         pChangeAction->GetDescription( aTitle, pDocShell->GetDocument());
     112 [ #  # ][ #  # ]:          0 :         pDlg->SetText(aTitle);
                 [ #  # ]
     113 [ #  # ][ #  # ]:          0 :         aComment=pChangeAction->GetComment();
     114                 :            : 
     115         [ #  # ]:          0 :         sal_Bool bNext=FindNext(pChangeAction)!=NULL;
     116         [ #  # ]:          0 :         sal_Bool bPrev=FindPrev(pChangeAction)!=NULL;
     117         [ #  # ]:          0 :         pDlg->EnableTravel(bNext,bPrev);
     118                 :            : 
     119 [ #  # ][ #  # ]:          0 :         String aAuthor = pChangeAction->GetUser();
     120                 :            : 
     121         [ #  # ]:          0 :         DateTime aDT = pChangeAction->GetDateTime();
     122 [ #  # ][ #  # ]:          0 :         String aDate = ScGlobal::pLocaleData->getDate( aDT );
     123         [ #  # ]:          0 :         aDate += ' ';
     124 [ #  # ][ #  # ]:          0 :         aDate += ScGlobal::pLocaleData->getTime( aDT, false, false );
     125                 :            : 
     126         [ #  # ]:          0 :         pDlg->ShowLastAuthor(aAuthor, aDate);
     127 [ #  # ][ #  # ]:          0 :         pDlg->SetNote(aComment);
                 [ #  # ]
     128                 :            :     }
     129                 :          0 : }
     130                 :            : 
     131                 :          0 : short ScRedComDialog::Execute()
     132                 :            : {
     133                 :          0 :     short nRet=pDlg->Execute();
     134                 :            : 
     135         [ #  # ]:          0 :     if(nRet== RET_OK )
     136                 :            :     {
     137 [ #  # ][ #  # ]:          0 :         if ( pDocShell!=NULL && pDlg->GetNote() != aComment )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     138         [ #  # ]:          0 :             pDocShell->SetChangeComment( pChangeAction, pDlg->GetNote());
     139                 :            :     }
     140                 :            : 
     141                 :          0 :     return nRet;
     142                 :            : }
     143                 :            : 
     144                 :          0 : void ScRedComDialog::SelectCell()
     145                 :            : {
     146         [ #  # ]:          0 :     if(pChangeAction!=NULL)
     147                 :            :     {
     148                 :          0 :         const ScChangeAction* pAction=pChangeAction;
     149                 :          0 :         const ScBigRange& rRange = pAction->GetBigRange();
     150                 :            : 
     151         [ #  # ]:          0 :         if(rRange.IsValid(pDocShell->GetDocument()))
     152                 :            :         {
     153         [ #  # ]:          0 :             ScViewData* pViewData=pDocShell->GetViewData();
     154                 :          0 :             ScRange aRef=rRange.MakeRange();
     155         [ #  # ]:          0 :             ScTabView* pTabView=pViewData->GetView();
     156         [ #  # ]:          0 :             pTabView->MarkRange(aRef);
     157                 :            :         }
     158                 :            :     }
     159                 :          0 : }
     160                 :            : 
     161                 :          0 : IMPL_LINK(ScRedComDialog, PrevHdl, AbstractSvxPostItDialog*, pDlgP )
     162                 :            : {
     163 [ #  # ][ #  # ]:          0 :     if (pDocShell!=NULL && pDlgP->GetNote() != aComment )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     164         [ #  # ]:          0 :         pDocShell->SetChangeComment( pChangeAction, pDlgP->GetNote());
     165                 :            : 
     166                 :          0 :     ReInit(FindPrev(pChangeAction));
     167                 :          0 :     SelectCell();
     168                 :            : 
     169                 :          0 :     return 0;
     170                 :            : }
     171                 :            : 
     172                 :          0 : IMPL_LINK(ScRedComDialog, NextHdl, AbstractSvxPostItDialog*, pDlgP )
     173                 :            : {
     174 [ #  # ][ #  # ]:          0 :     if ( pDocShell!=NULL && pDlgP->GetNote() != aComment )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     175         [ #  # ]:          0 :         pDocShell->SetChangeComment( pChangeAction, pDlgP->GetNote());
     176                 :            : 
     177                 :          0 :     ReInit(FindNext(pChangeAction));
     178                 :          0 :     SelectCell();
     179                 :            : 
     180                 :          0 :     return 0;
     181                 :            : }
     182                 :            : 
     183                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10