LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - highred.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 131 0.0 %
Date: 2014-04-14 Functions: 0 17 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 "global.hxx"
      21             : #include "reffact.hxx"
      22             : #include "document.hxx"
      23             : #include "docsh.hxx"
      24             : #include "scresid.hxx"
      25             : #include "globstr.hrc"
      26             : 
      27             : #include "highred.hxx"
      28             : #include <vcl/msgbox.hxx>
      29             : #include <sfx2/app.hxx>
      30             : 
      31             : // defines -------------------------------------------------------------------
      32             : 
      33             : #define ABS_SREF          SCA_VALID \
      34             :                         | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
      35             : #define ABS_DREF          ABS_SREF \
      36             :                         | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
      37             : #define ABS_DREF3D      ABS_DREF | SCA_TAB_3D
      38             : 
      39             : 
      40             : //  class ScHighlightChgDlg
      41             : 
      42             : 
      43           0 : ScHighlightChgDlg::ScHighlightChgDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
      44             :                       ScViewData*       ptrViewData)
      45             :     : ScAnyRefDlg(pB, pCW, pParent, "ShowChangesDialog",
      46             :         "modules/scalc/ui/showchangesdialog.ui")
      47             :     , pViewData(ptrViewData)
      48           0 :     , pDoc(ptrViewData->GetDocument())
      49           0 :     , aLocalRangeName(*(pDoc->GetRangeName()))
      50             : {
      51           0 :     m_pFilterCtr = new SvxTPFilter(get<VclContainer>("box"));
      52           0 :     get(m_pHighlightBox, "showchanges");
      53           0 :     get(m_pCbAccept, "showaccepted");
      54           0 :     get(m_pCbReject, "showrejected");
      55           0 :     get(m_pEdAssign, "range");
      56           0 :     m_pEdAssign->SetReferences(this, m_pFilterCtr->get<Window>("range"));
      57           0 :     m_pEdAssign->SetSizePixel(m_pEdAssign->get_preferred_size());
      58           0 :     get(m_pRbAssign, "rangeref");
      59           0 :     m_pRbAssign->SetReferences(this, m_pEdAssign);
      60           0 :     get(m_pOkButton, "ok");
      61             : 
      62           0 :     m_pOkButton->SetClickHdl(LINK( this, ScHighlightChgDlg, OKBtnHdl));
      63           0 :     m_pHighlightBox->SetClickHdl(LINK( this, ScHighlightChgDlg, HighlightHandle ));
      64           0 :     m_pFilterCtr->SetRefHdl(LINK( this, ScHighlightChgDlg, RefHandle ));
      65           0 :     m_pFilterCtr->HideRange(false);
      66           0 :     m_pFilterCtr->Show();
      67           0 :     SetDispatcherLock( true );
      68             : 
      69           0 :     Init();
      70           0 : }
      71             : 
      72           0 : ScHighlightChgDlg::~ScHighlightChgDlg()
      73             : {
      74           0 :     SetDispatcherLock( false );
      75           0 :     delete m_pFilterCtr;
      76           0 : }
      77             : 
      78           0 : void ScHighlightChgDlg::Init()
      79             : {
      80           0 :     ScRange aRange;
      81             : 
      82             :     OSL_ENSURE( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
      83             : 
      84           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
      85           0 :     if(pChanges!=NULL)
      86             :     {
      87           0 :         aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser());
      88           0 :         m_pFilterCtr->ClearAuthors();
      89           0 :         const std::set<OUString>& rUserColl = pChanges->GetUserCollection();
      90           0 :         std::set<OUString>::const_iterator it = rUserColl.begin(), itEnd = rUserColl.end();
      91           0 :         for (; it != itEnd; ++it)
      92           0 :             m_pFilterCtr->InsertAuthor(*it);
      93             :     }
      94             : 
      95             : 
      96           0 :     ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings();
      97             : 
      98           0 :     if(pViewSettings!=NULL)
      99           0 :         aChangeViewSet=*pViewSettings;
     100           0 :     m_pHighlightBox->Check(aChangeViewSet.ShowChanges());
     101           0 :     m_pFilterCtr->CheckDate(aChangeViewSet.HasDate());
     102           0 :     m_pFilterCtr->SetFirstDate(aChangeViewSet.GetTheFirstDateTime());
     103           0 :     m_pFilterCtr->SetFirstTime(aChangeViewSet.GetTheFirstDateTime());
     104           0 :     m_pFilterCtr->SetLastDate(aChangeViewSet.GetTheLastDateTime());
     105           0 :     m_pFilterCtr->SetLastTime(aChangeViewSet.GetTheLastDateTime());
     106           0 :     m_pFilterCtr->SetDateMode((sal_uInt16)aChangeViewSet.GetTheDateMode());
     107           0 :     m_pFilterCtr->CheckAuthor(aChangeViewSet.HasAuthor());
     108           0 :     m_pFilterCtr->CheckComment(aChangeViewSet.HasComment());
     109           0 :     m_pFilterCtr->SetComment(aChangeViewSet.GetTheComment());
     110             : 
     111           0 :     m_pCbAccept->Check(aChangeViewSet.IsShowAccepted());
     112           0 :     m_pCbReject->Check(aChangeViewSet.IsShowRejected());
     113             : 
     114           0 :     OUString aString=aChangeViewSet.GetTheAuthorToShow();
     115           0 :     if(!aString.isEmpty())
     116             :     {
     117           0 :         m_pFilterCtr->SelectAuthor(aString);
     118             :     }
     119             :     else
     120             :     {
     121           0 :         m_pFilterCtr->SelectedAuthorPos(0);
     122             :     }
     123             : 
     124           0 :     m_pFilterCtr->CheckRange(aChangeViewSet.HasRange());
     125             : 
     126           0 :     if ( !aChangeViewSet.GetTheRangeList().empty() )
     127             :     {
     128           0 :         const ScRange* pRangeEntry = aChangeViewSet.GetTheRangeList().front();
     129           0 :         OUString aRefStr(pRangeEntry->Format(ABS_DREF3D, pDoc));
     130           0 :         m_pFilterCtr->SetRange(aRefStr);
     131             :     }
     132           0 :     m_pFilterCtr->Enable(true,true);
     133           0 :     HighlightHandle(m_pHighlightBox);
     134           0 : }
     135             : 
     136             : 
     137             : // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
     138             : // neue Selektion im Referenz-Edit angezeigt wird.
     139             : 
     140           0 : void ScHighlightChgDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
     141             : {
     142           0 :     if ( m_pEdAssign->IsVisible() )
     143             :     {
     144           0 :         if ( rRef.aStart != rRef.aEnd )
     145           0 :             RefInputStart(m_pEdAssign);
     146           0 :         OUString aRefStr(rRef.Format(ABS_DREF3D, pDocP, pDocP->GetAddressConvention()));
     147           0 :         m_pEdAssign->SetRefString( aRefStr );
     148           0 :         m_pFilterCtr->SetRange(aRefStr);
     149             :     }
     150           0 : }
     151             : 
     152             : 
     153           0 : bool ScHighlightChgDlg::Close()
     154             : {
     155           0 :     return DoClose( ScHighlightChgDlgWrapper::GetChildWindowId() );
     156             : }
     157             : 
     158           0 : void ScHighlightChgDlg::RefInputDone( bool bForced)
     159             : {
     160           0 :     ScAnyRefDlg::RefInputDone(bForced);
     161           0 :     if(bForced || !m_pRbAssign->IsVisible())
     162             :     {
     163           0 :         m_pFilterCtr->SetRange(m_pEdAssign->GetText());
     164           0 :         m_pFilterCtr->SetFocusToRange();
     165           0 :         m_pEdAssign->Hide();
     166           0 :         m_pRbAssign->Hide();
     167             :     }
     168           0 : }
     169             : 
     170           0 : void ScHighlightChgDlg::SetActive()
     171             : {
     172           0 : }
     173             : 
     174           0 : bool ScHighlightChgDlg::IsRefInputMode() const
     175             : {
     176           0 :     return m_pEdAssign->IsVisible();
     177             : }
     178             : 
     179           0 : IMPL_LINK( ScHighlightChgDlg, HighlightHandle, CheckBox*, pCb )
     180             : {
     181           0 :     if(pCb!=NULL)
     182             :     {
     183           0 :         if(m_pHighlightBox->IsChecked())
     184             :         {
     185           0 :             m_pFilterCtr->Enable(true,true);
     186           0 :             m_pCbAccept->Enable();
     187           0 :             m_pCbReject->Enable();
     188             :         }
     189             :         else
     190             :         {
     191           0 :             m_pFilterCtr->Disable(true);
     192           0 :             m_pCbAccept->Disable();
     193           0 :             m_pCbReject->Disable();
     194             :         }
     195             :     }
     196           0 :     return 0;
     197             : }
     198             : 
     199           0 : IMPL_LINK( ScHighlightChgDlg, RefHandle, SvxTPFilter*, pRef )
     200             : {
     201           0 :     if(pRef!=NULL)
     202             :     {
     203           0 :         SetDispatcherLock( true );
     204           0 :         m_pEdAssign->Show();
     205           0 :         m_pRbAssign->Show();
     206           0 :         m_pEdAssign->SetText(m_pFilterCtr->GetRange());
     207           0 :         m_pEdAssign->GrabFocus();
     208           0 :         ScAnyRefDlg::RefInputStart(m_pEdAssign, m_pRbAssign);
     209             :     }
     210           0 :     return 0;
     211             : }
     212             : 
     213           0 : IMPL_LINK( ScHighlightChgDlg, OKBtnHdl, PushButton*, pOKBtn )
     214             : {
     215           0 :     if (pOKBtn == m_pOkButton)
     216             :     {
     217           0 :         aChangeViewSet.SetShowChanges(m_pHighlightBox->IsChecked());
     218           0 :         aChangeViewSet.SetHasDate(m_pFilterCtr->IsDate());
     219           0 :         ScChgsDateMode eMode = (ScChgsDateMode) m_pFilterCtr->GetDateMode();
     220           0 :         aChangeViewSet.SetTheDateMode( eMode );
     221           0 :         Date aFirstDate( m_pFilterCtr->GetFirstDate() );
     222           0 :         Time aFirstTime( m_pFilterCtr->GetFirstTime() );
     223           0 :         Date aLastDate( m_pFilterCtr->GetLastDate() );
     224           0 :         Time aLastTime( m_pFilterCtr->GetLastTime() );
     225           0 :         aChangeViewSet.SetTheFirstDateTime( DateTime( aFirstDate, aFirstTime ) );
     226           0 :         aChangeViewSet.SetTheLastDateTime( DateTime( aLastDate, aLastTime ) );
     227           0 :         aChangeViewSet.SetHasAuthor(m_pFilterCtr->IsAuthor());
     228           0 :         aChangeViewSet.SetTheAuthorToShow(m_pFilterCtr->GetSelectedAuthor());
     229           0 :         aChangeViewSet.SetHasRange(m_pFilterCtr->IsRange());
     230           0 :         aChangeViewSet.SetShowAccepted(m_pCbAccept->IsChecked());
     231           0 :         aChangeViewSet.SetShowRejected(m_pCbReject->IsChecked());
     232           0 :         aChangeViewSet.SetHasComment(m_pFilterCtr->IsComment());
     233           0 :         aChangeViewSet.SetTheComment(m_pFilterCtr->GetComment());
     234           0 :         ScRangeList aLocalRangeList;
     235           0 :         aLocalRangeList.Parse(m_pFilterCtr->GetRange(), pDoc);
     236           0 :         aChangeViewSet.SetTheRangeList(aLocalRangeList);
     237           0 :         aChangeViewSet.AdjustDateMode( *pDoc );
     238           0 :         pDoc->SetChangeViewSettings(aChangeViewSet);
     239           0 :         pViewData->GetDocShell()->PostPaintGridAll();
     240           0 :         Close();
     241             :     }
     242           0 :     return 0;
     243           0 : }
     244             : 
     245             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10