LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - highred.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 141 0.7 %
Date: 2015-06-13 12:38:46 Functions: 2 18 11.1 %
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 = VclPtr<SvxTPFilter>::Create(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 :     disposeOnce();
      73           0 : }
      74             : 
      75           0 : void ScHighlightChgDlg::dispose()
      76             : {
      77           0 :     SetDispatcherLock( false );
      78           0 :     m_pFilterCtr.disposeAndClear();
      79           0 :     m_pHighlightBox.clear();
      80           0 :     m_pCbAccept.clear();
      81           0 :     m_pCbReject.clear();
      82           0 :     m_pOkButton.clear();
      83           0 :     m_pEdAssign.clear();
      84           0 :     m_pRbAssign.clear();
      85           0 :     ScAnyRefDlg::dispose();
      86           0 : }
      87             : 
      88           0 : void ScHighlightChgDlg::Init()
      89             : {
      90           0 :     ScRange aRange;
      91             : 
      92             :     OSL_ENSURE( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
      93             : 
      94           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
      95           0 :     if(pChanges!=NULL)
      96             :     {
      97           0 :         aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser());
      98           0 :         m_pFilterCtr->ClearAuthors();
      99           0 :         const std::set<OUString>& rUserColl = pChanges->GetUserCollection();
     100           0 :         std::set<OUString>::const_iterator it = rUserColl.begin(), itEnd = rUserColl.end();
     101           0 :         for (; it != itEnd; ++it)
     102           0 :             m_pFilterCtr->InsertAuthor(*it);
     103             :     }
     104             : 
     105           0 :     ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings();
     106             : 
     107           0 :     if(pViewSettings!=NULL)
     108           0 :         aChangeViewSet=*pViewSettings;
     109           0 :     m_pHighlightBox->Check(aChangeViewSet.ShowChanges());
     110           0 :     m_pFilterCtr->CheckDate(aChangeViewSet.HasDate());
     111           0 :     m_pFilterCtr->SetFirstDate(aChangeViewSet.GetTheFirstDateTime());
     112           0 :     m_pFilterCtr->SetFirstTime(aChangeViewSet.GetTheFirstDateTime());
     113           0 :     m_pFilterCtr->SetLastDate(aChangeViewSet.GetTheLastDateTime());
     114           0 :     m_pFilterCtr->SetLastTime(aChangeViewSet.GetTheLastDateTime());
     115           0 :     m_pFilterCtr->SetDateMode((sal_uInt16)aChangeViewSet.GetTheDateMode());
     116           0 :     m_pFilterCtr->CheckAuthor(aChangeViewSet.HasAuthor());
     117           0 :     m_pFilterCtr->CheckComment(aChangeViewSet.HasComment());
     118           0 :     m_pFilterCtr->SetComment(aChangeViewSet.GetTheComment());
     119             : 
     120           0 :     m_pCbAccept->Check(aChangeViewSet.IsShowAccepted());
     121           0 :     m_pCbReject->Check(aChangeViewSet.IsShowRejected());
     122             : 
     123           0 :     OUString aString=aChangeViewSet.GetTheAuthorToShow();
     124           0 :     if(!aString.isEmpty())
     125             :     {
     126           0 :         m_pFilterCtr->SelectAuthor(aString);
     127             :     }
     128             :     else
     129             :     {
     130           0 :         m_pFilterCtr->SelectedAuthorPos(0);
     131             :     }
     132             : 
     133           0 :     m_pFilterCtr->CheckRange(aChangeViewSet.HasRange());
     134             : 
     135           0 :     if ( !aChangeViewSet.GetTheRangeList().empty() )
     136             :     {
     137           0 :         const ScRange* pRangeEntry = aChangeViewSet.GetTheRangeList().front();
     138           0 :         OUString aRefStr(pRangeEntry->Format(ABS_DREF3D, pDoc));
     139           0 :         m_pFilterCtr->SetRange(aRefStr);
     140             :     }
     141           0 :     m_pFilterCtr->Enable(true,true);
     142           0 :     HighlightHandle(m_pHighlightBox);
     143           0 : }
     144             : 
     145             : // Set the reference to a cell range selected with the mouse. This is then
     146             : // shown as the new selection in the reference field.
     147             : 
     148           0 : void ScHighlightChgDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
     149             : {
     150           0 :     if ( m_pEdAssign->IsVisible() )
     151             :     {
     152           0 :         if ( rRef.aStart != rRef.aEnd )
     153           0 :             RefInputStart(m_pEdAssign);
     154           0 :         OUString aRefStr(rRef.Format(ABS_DREF3D, pDocP, pDocP->GetAddressConvention()));
     155           0 :         m_pEdAssign->SetRefString( aRefStr );
     156           0 :         m_pFilterCtr->SetRange(aRefStr);
     157             :     }
     158           0 : }
     159             : 
     160           0 : bool ScHighlightChgDlg::Close()
     161             : {
     162           0 :     return DoClose( ScHighlightChgDlgWrapper::GetChildWindowId() );
     163             : }
     164             : 
     165           0 : void ScHighlightChgDlg::RefInputDone( bool bForced)
     166             : {
     167           0 :     ScAnyRefDlg::RefInputDone(bForced);
     168           0 :     if(bForced || !m_pRbAssign->IsVisible())
     169             :     {
     170           0 :         m_pFilterCtr->SetRange(m_pEdAssign->GetText());
     171           0 :         m_pFilterCtr->SetFocusToRange();
     172           0 :         m_pEdAssign->Hide();
     173           0 :         m_pRbAssign->Hide();
     174             :     }
     175           0 : }
     176             : 
     177           0 : void ScHighlightChgDlg::SetActive()
     178             : {
     179           0 : }
     180             : 
     181           0 : bool ScHighlightChgDlg::IsRefInputMode() const
     182             : {
     183           0 :     return m_pEdAssign->IsVisible();
     184             : }
     185             : 
     186           0 : IMPL_LINK( ScHighlightChgDlg, HighlightHandle, CheckBox*, pCb )
     187             : {
     188           0 :     if(pCb!=NULL)
     189             :     {
     190           0 :         if(m_pHighlightBox->IsChecked())
     191             :         {
     192           0 :             m_pFilterCtr->Enable(true,true);
     193           0 :             m_pCbAccept->Enable();
     194           0 :             m_pCbReject->Enable();
     195             :         }
     196             :         else
     197             :         {
     198           0 :             m_pFilterCtr->Disable(true);
     199           0 :             m_pCbAccept->Disable();
     200           0 :             m_pCbReject->Disable();
     201             :         }
     202             :     }
     203           0 :     return 0;
     204             : }
     205             : 
     206           0 : IMPL_LINK( ScHighlightChgDlg, RefHandle, SvxTPFilter*, pRef )
     207             : {
     208           0 :     if(pRef!=NULL)
     209             :     {
     210           0 :         SetDispatcherLock( true );
     211           0 :         m_pEdAssign->Show();
     212           0 :         m_pRbAssign->Show();
     213           0 :         m_pEdAssign->SetText(m_pFilterCtr->GetRange());
     214           0 :         m_pEdAssign->GrabFocus();
     215           0 :         ScAnyRefDlg::RefInputStart(m_pEdAssign, m_pRbAssign);
     216             :     }
     217           0 :     return 0;
     218             : }
     219             : 
     220           0 : IMPL_LINK( ScHighlightChgDlg, OKBtnHdl, PushButton*, pOKBtn )
     221             : {
     222           0 :     if (pOKBtn == m_pOkButton)
     223             :     {
     224           0 :         aChangeViewSet.SetShowChanges(m_pHighlightBox->IsChecked());
     225           0 :         aChangeViewSet.SetHasDate(m_pFilterCtr->IsDate());
     226           0 :         SvxRedlinDateMode eMode = m_pFilterCtr->GetDateMode();
     227           0 :         aChangeViewSet.SetTheDateMode( eMode );
     228           0 :         Date aFirstDate( m_pFilterCtr->GetFirstDate() );
     229           0 :         tools::Time aFirstTime( m_pFilterCtr->GetFirstTime() );
     230           0 :         Date aLastDate( m_pFilterCtr->GetLastDate() );
     231           0 :         tools::Time aLastTime( m_pFilterCtr->GetLastTime() );
     232           0 :         aChangeViewSet.SetTheFirstDateTime( DateTime( aFirstDate, aFirstTime ) );
     233           0 :         aChangeViewSet.SetTheLastDateTime( DateTime( aLastDate, aLastTime ) );
     234           0 :         aChangeViewSet.SetHasAuthor(m_pFilterCtr->IsAuthor());
     235           0 :         aChangeViewSet.SetTheAuthorToShow(m_pFilterCtr->GetSelectedAuthor());
     236           0 :         aChangeViewSet.SetHasRange(m_pFilterCtr->IsRange());
     237           0 :         aChangeViewSet.SetShowAccepted(m_pCbAccept->IsChecked());
     238           0 :         aChangeViewSet.SetShowRejected(m_pCbReject->IsChecked());
     239           0 :         aChangeViewSet.SetHasComment(m_pFilterCtr->IsComment());
     240           0 :         aChangeViewSet.SetTheComment(m_pFilterCtr->GetComment());
     241           0 :         ScRangeList aLocalRangeList;
     242           0 :         aLocalRangeList.Parse(m_pFilterCtr->GetRange(), pDoc);
     243           0 :         aChangeViewSet.SetTheRangeList(aLocalRangeList);
     244           0 :         aChangeViewSet.AdjustDateMode( *pDoc );
     245           0 :         pDoc->SetChangeViewSettings(aChangeViewSet);
     246           0 :         pViewData->GetDocShell()->PostPaintGridAll();
     247           0 :         Close();
     248             :     }
     249           0 :     return 0;
     250         156 : }
     251             : 
     252             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11