LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/miscdlgs - highred.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 128 0.8 %
Date: 2013-07-09 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             : #include "highred.hrc"
      27             : 
      28             : #include "highred.hxx"
      29             : #include <vcl/msgbox.hxx>
      30             : #include <sfx2/app.hxx>
      31             : 
      32             : // defines -------------------------------------------------------------------
      33             : 
      34             : #define ABS_SREF          SCA_VALID \
      35             :                         | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
      36             : #define ABS_DREF          ABS_SREF \
      37             :                         | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
      38             : #define ABS_DREF3D      ABS_DREF | SCA_TAB_3D
      39             : 
      40             : //============================================================================
      41             : //  class ScHighlightChgDlg
      42             : 
      43             : //----------------------------------------------------------------------------
      44           0 : ScHighlightChgDlg::ScHighlightChgDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
      45             :                       ScViewData*       ptrViewData)
      46             : 
      47             :     :   ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_HIGHLIGHT_CHANGES ),
      48             :         //
      49             :         aHighlightBox   ( this, ScResId( CB_HIGHLIGHT)),
      50             :         aFlFilter       ( this, ScResId( FL_FILTER)),
      51             :         aFilterCtr      ( this),
      52             :         aCbAccept       ( this, ScResId( CB_HIGHLIGHT_ACCEPT)),
      53             :         aCbReject       ( this, ScResId( CB_HIGHLIGHT_REJECT)),
      54             :         aOkButton       ( this, ScResId( BTN_OK ) ),
      55             :         aCancelButton   ( this, ScResId( BTN_CANCEL ) ),
      56             :         aHelpButton     ( this, ScResId( BTN_HELP ) ),
      57             :         aEdAssign       ( this, this, NULL, ScResId( ED_ASSIGN ) ),
      58             :         aRbAssign       ( this, ScResId( RB_ASSIGN ), &aEdAssign, this ),
      59             :         //
      60             :         pViewData       ( ptrViewData ),
      61           0 :         pDoc            ( ptrViewData->GetDocument() ),
      62           0 :         aLocalRangeName ( *(pDoc->GetRangeName()) )
      63             : {
      64           0 :     FreeResource();
      65             : 
      66           0 :     Point aFlFilterPt( aFlFilter.GetPosPixel() );
      67           0 :     aFlFilterPt.Y() += aFlFilter.GetSizePixel().Height();
      68           0 :     aFilterCtr.SetPosPixel( aFlFilterPt );
      69           0 :     MinSize=aFilterCtr.GetSizePixel();
      70           0 :     MinSize.Height()+=2;
      71           0 :     MinSize.Width()+=2;
      72           0 :     aOkButton.SetClickHdl(LINK( this, ScHighlightChgDlg, OKBtnHdl));
      73           0 :     aHighlightBox.SetClickHdl(LINK( this, ScHighlightChgDlg, HighLightHandle ));
      74           0 :     aFilterCtr.SetRefHdl(LINK( this, ScHighlightChgDlg, RefHandle ));
      75           0 :     aFilterCtr.HideRange(false);
      76           0 :     aFilterCtr.Show();
      77           0 :     SetDispatcherLock( true );
      78             : 
      79           0 :     Init();
      80             : 
      81           0 : }
      82             : 
      83           0 : ScHighlightChgDlg::~ScHighlightChgDlg()
      84             : {
      85           0 :     SetDispatcherLock( false );
      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 :         aFilterCtr.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 :             aFilterCtr.InsertAuthor(*it);
     103             :     }
     104             : 
     105             : 
     106           0 :     ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings();
     107             : 
     108           0 :     if(pViewSettings!=NULL)
     109           0 :         aChangeViewSet=*pViewSettings;
     110           0 :     aHighlightBox.Check(aChangeViewSet.ShowChanges());
     111           0 :     aFilterCtr.CheckDate(aChangeViewSet.HasDate());
     112           0 :     aFilterCtr.SetFirstDate(aChangeViewSet.GetTheFirstDateTime());
     113           0 :     aFilterCtr.SetFirstTime(aChangeViewSet.GetTheFirstDateTime());
     114           0 :     aFilterCtr.SetLastDate(aChangeViewSet.GetTheLastDateTime());
     115           0 :     aFilterCtr.SetLastTime(aChangeViewSet.GetTheLastDateTime());
     116           0 :     aFilterCtr.SetDateMode((sal_uInt16)aChangeViewSet.GetTheDateMode());
     117           0 :     aFilterCtr.CheckAuthor(aChangeViewSet.HasAuthor());
     118           0 :     aFilterCtr.CheckComment(aChangeViewSet.HasComment());
     119           0 :     aFilterCtr.SetComment(aChangeViewSet.GetTheComment());
     120             : 
     121           0 :     aCbAccept.Check(aChangeViewSet.IsShowAccepted());
     122           0 :     aCbReject.Check(aChangeViewSet.IsShowRejected());
     123             : 
     124           0 :     String aString=aChangeViewSet.GetTheAuthorToShow();
     125           0 :     if(aString.Len()!=0)
     126             :     {
     127           0 :         aFilterCtr.SelectAuthor(aString);
     128             :     }
     129             :     else
     130             :     {
     131           0 :         aFilterCtr.SelectedAuthorPos(0);
     132             :     }
     133             : 
     134           0 :     aFilterCtr.CheckRange(aChangeViewSet.HasRange());
     135             : 
     136           0 :     if ( !aChangeViewSet.GetTheRangeList().empty() )
     137             :     {
     138           0 :         String aRefStr;
     139           0 :         const ScRange* pRangeEntry = aChangeViewSet.GetTheRangeList().front();
     140           0 :         pRangeEntry->Format( aRefStr, ABS_DREF3D, pDoc );
     141           0 :         aFilterCtr.SetRange(aRefStr);
     142             :     }
     143           0 :     aFilterCtr.Enable(sal_True,sal_True);
     144           0 :     HighLightHandle(&aHighlightBox);
     145           0 : }
     146             : 
     147             : //----------------------------------------------------------------------------
     148             : // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
     149             : // neue Selektion im Referenz-Edit angezeigt wird.
     150             : 
     151           0 : void ScHighlightChgDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
     152             : {
     153           0 :     if ( aEdAssign.IsVisible() )
     154             :     {
     155           0 :         if ( rRef.aStart != rRef.aEnd )
     156           0 :             RefInputStart(&aEdAssign);
     157           0 :         String aRefStr;
     158           0 :         rRef.Format( aRefStr, ABS_DREF3D, pDocP, pDocP->GetAddressConvention() );
     159           0 :         aEdAssign.SetRefString( aRefStr );
     160           0 :         aFilterCtr.SetRange(aRefStr);
     161             :     }
     162           0 : }
     163             : 
     164             : //----------------------------------------------------------------------------
     165           0 : sal_Bool ScHighlightChgDlg::Close()
     166             : {
     167           0 :     return DoClose( ScHighlightChgDlgWrapper::GetChildWindowId() );
     168             : }
     169             : 
     170           0 : void ScHighlightChgDlg::RefInputDone( sal_Bool bForced)
     171             : {
     172           0 :     ScAnyRefDlg::RefInputDone(bForced);
     173           0 :     if(bForced || !aRbAssign.IsVisible())
     174             :     {
     175           0 :         aFilterCtr.SetRange(aEdAssign.GetText());
     176           0 :         aFilterCtr.SetFocusToRange();
     177           0 :         aEdAssign.Hide();
     178           0 :         aRbAssign.Hide();
     179             :     }
     180           0 : }
     181             : 
     182           0 : void ScHighlightChgDlg::SetActive()
     183             : {
     184           0 : }
     185             : 
     186           0 : sal_Bool ScHighlightChgDlg::IsRefInputMode() const
     187             : {
     188           0 :     return aEdAssign.IsVisible();
     189             : }
     190             : 
     191           0 : IMPL_LINK( ScHighlightChgDlg, HighLightHandle, CheckBox*, pCb )
     192             : {
     193           0 :     if(pCb!=NULL)
     194             :     {
     195           0 :         if(aHighlightBox.IsChecked())
     196             :         {
     197           0 :             aFilterCtr.Enable(sal_True,sal_True);
     198           0 :             aCbAccept.Enable();
     199           0 :             aCbReject.Enable();
     200             :         }
     201             :         else
     202             :         {
     203           0 :             aFilterCtr.Disable(sal_True);
     204           0 :             aCbAccept.Disable();
     205           0 :             aCbReject.Disable();
     206             :         }
     207             :     }
     208           0 :     return 0;
     209             : }
     210             : 
     211           0 : IMPL_LINK( ScHighlightChgDlg, RefHandle, SvxTPFilter*, pRef )
     212             : {
     213           0 :     if(pRef!=NULL)
     214             :     {
     215           0 :         SetDispatcherLock( true );
     216           0 :         aEdAssign.Show();
     217           0 :         aRbAssign.Show();
     218           0 :         aEdAssign.SetText(aFilterCtr.GetRange());
     219           0 :         ScAnyRefDlg::RefInputStart(&aEdAssign,&aRbAssign);
     220             :     }
     221           0 :     return 0;
     222             : }
     223             : 
     224           0 : IMPL_LINK( ScHighlightChgDlg, OKBtnHdl, PushButton*, pOKBtn )
     225             : {
     226           0 :     if ( pOKBtn == &aOkButton)
     227             :     {
     228           0 :         aChangeViewSet.SetShowChanges(aHighlightBox.IsChecked());
     229           0 :         aChangeViewSet.SetHasDate(aFilterCtr.IsDate());
     230           0 :         ScChgsDateMode eMode = (ScChgsDateMode) aFilterCtr.GetDateMode();
     231           0 :         aChangeViewSet.SetTheDateMode( eMode );
     232           0 :         Date aFirstDate( aFilterCtr.GetFirstDate() );
     233           0 :         Time aFirstTime( aFilterCtr.GetFirstTime() );
     234           0 :         Date aLastDate( aFilterCtr.GetLastDate() );
     235           0 :         Time aLastTime( aFilterCtr.GetLastTime() );
     236           0 :         aChangeViewSet.SetTheFirstDateTime( DateTime( aFirstDate, aFirstTime ) );
     237           0 :         aChangeViewSet.SetTheLastDateTime( DateTime( aLastDate, aLastTime ) );
     238           0 :         aChangeViewSet.SetHasAuthor(aFilterCtr.IsAuthor());
     239           0 :         aChangeViewSet.SetTheAuthorToShow(aFilterCtr.GetSelectedAuthor());
     240           0 :         aChangeViewSet.SetHasRange(aFilterCtr.IsRange());
     241           0 :         aChangeViewSet.SetShowAccepted(aCbAccept.IsChecked());
     242           0 :         aChangeViewSet.SetShowRejected(aCbReject.IsChecked());
     243           0 :         aChangeViewSet.SetHasComment(aFilterCtr.IsComment());
     244           0 :         aChangeViewSet.SetTheComment(aFilterCtr.GetComment());
     245           0 :         ScRangeList aLocalRangeList;
     246           0 :         aLocalRangeList.Parse(aFilterCtr.GetRange(), pDoc);
     247           0 :         aChangeViewSet.SetTheRangeList(aLocalRangeList);
     248           0 :         aChangeViewSet.AdjustDateMode( *pDoc );
     249           0 :         pDoc->SetChangeViewSettings(aChangeViewSet);
     250           0 :         pViewData->GetDocShell()->PostPaintGridAll();
     251           0 :         Close();
     252             :     }
     253           0 :     return 0;
     254          93 : }
     255             : 
     256             : 
     257             : 
     258             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10