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

Generated by: LCOV version 1.10