LCOV - code coverage report
Current view: top level - svx/source/dialog - ctredlin.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 626 0.2 %
Date: 2014-11-03 Functions: 2 110 1.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 <vcl/dialog.hxx>
      21             : #include <vcl/layout.hxx>
      22             : #include <vcl/svapp.hxx>
      23             : #include <sfx2/app.hxx>
      24             : #include <sfx2/module.hxx>
      25             : #include <unotools/textsearch.hxx>
      26             : #include <svtools/svlbitm.hxx>
      27             : #include "svtools/viewdataentry.hxx"
      28             : #include <unotools/charclass.hxx>
      29             : 
      30             : #include <editeng/unolingu.hxx>
      31             : #include <svx/dialmgr.hxx>
      32             : #include "svx/dialogs.hrc"
      33             : #include <svx/ctredlin.hxx>
      34             : #include "helpid.hrc"
      35             : 
      36             : 
      37             : //  Local Defines and Function
      38             : 
      39             : 
      40             : static long nStaticTabs[]=
      41             : {
      42             :     5,10,65,120,170,220
      43             : };
      44             : 
      45             : #define WRITER_DATE     2
      46             : #define CALC_DATE       3
      47             : 
      48           0 : RedlinData::RedlinData()
      49             :     :
      50           0 :         aDateTime( DateTime::EMPTY )
      51             : {
      52           0 :     bDisabled=false;
      53           0 :     pData=NULL;
      54           0 : }
      55           0 : RedlinData::~RedlinData()
      56             : {
      57           0 : }
      58             : 
      59             : 
      60             : //  class SvxRedlinEntry (Entries for list)
      61             : 
      62             : 
      63           0 : SvxRedlinEntry::SvxRedlinEntry()
      64           0 :     : SvTreeListEntry()
      65             : {
      66           0 : }
      67             : 
      68           0 : SvxRedlinEntry::~SvxRedlinEntry()
      69             : {
      70           0 :     RedlinData* pRedDat=(RedlinData*) GetUserData();
      71           0 :     delete pRedDat;
      72           0 : }
      73             : 
      74             : // Functions in the inserts Items of SvxRedlinTable
      75             : 
      76             : 
      77           0 : SvLBoxColorString::SvLBoxColorString(SvTreeListEntry*pEntry, sal_uInt16 nFlags, const OUString& rStr,
      78             :     const Color& rCol)
      79           0 :     : SvLBoxString(pEntry, nFlags, rStr)
      80             : {
      81           0 :     aPrivColor=rCol;
      82           0 :     SetText( rStr );
      83           0 : }
      84             : 
      85           0 : SvLBoxColorString::SvLBoxColorString()
      86           0 : : SvLBoxString()
      87             : {
      88           0 : }
      89             : 
      90           0 : SvLBoxColorString::~SvLBoxColorString()
      91             : {
      92           0 : }
      93             : 
      94           0 : SvLBoxItem* SvLBoxColorString::Create() const
      95             : {
      96           0 :     return new SvLBoxColorString;
      97             : }
      98             : 
      99           0 : void SvLBoxColorString::Paint(
     100             :     const Point& rPos, SvTreeListBox& rDev,
     101             :     const SvViewDataEntry* pView, const SvTreeListEntry* pEntry)
     102             : /* [Description]
     103             : 
     104             :    Paint function of the SvLBoxColorString class. The relevant text with the
     105             :    selected color is drawn in the output device.
     106             : */
     107             : 
     108             : {
     109           0 :     Color aColor=rDev.GetTextColor();
     110           0 :     Color a2Color=aColor;
     111           0 :     if (!pView->IsSelected())
     112             :     {
     113           0 :         rDev.SetTextColor(aPrivColor);
     114             :     }
     115           0 :     SvLBoxString::Paint(rPos, rDev, pView, pEntry);
     116           0 :     rDev.SetTextColor(a2Color);
     117           0 : }
     118             : 
     119           0 : SvxRedlinTable::SvxRedlinTable(SvSimpleTableContainer& rParent, WinBits nBits)
     120             :     : SvSimpleTable(rParent,nBits)
     121             :     , bIsCalc(false)
     122             :     , nDatePos(WRITER_DATE)
     123             :     , bAuthor(false)
     124             :     , bDate(false)
     125             :     , bComment(false)
     126             :     , nDaTiMode(0)
     127             :     , aDaTiFirst( DateTime::EMPTY )
     128             :     , aDaTiLast( DateTime::EMPTY )
     129             :     , aDaTiFilterFirst( DateTime::EMPTY )
     130             :     , aDaTiFilterLast( DateTime::EMPTY )
     131           0 :     , pCommentSearcher(0)
     132             : {
     133           0 :     SetNodeDefaultImages();
     134           0 : }
     135             : 
     136           0 : SvxRedlinTable::~SvxRedlinTable()
     137             : {
     138           0 :     delete pCommentSearcher;
     139           0 : }
     140             : 
     141           0 : sal_Int32 SvxRedlinTable::ColCompare(SvTreeListEntry* pLeft,SvTreeListEntry* pRight)
     142             : {
     143           0 :     sal_Int32 nCompare = 0;
     144             : 
     145           0 :     if(aColCompareLink.IsSet())
     146             :     {
     147             :         SvSortData aRedlinCompare;
     148           0 :         aRedlinCompare.pLeft=pLeft;
     149           0 :         aRedlinCompare.pRight=pRight;
     150           0 :         nCompare = aColCompareLink.Call(&aRedlinCompare);
     151             :     }
     152             :     else
     153             :     {
     154           0 :         if(nDatePos==GetSortedCol())
     155             :         {
     156           0 :             RedlinData *pLeftData=(RedlinData *)(pLeft->GetUserData());
     157           0 :             RedlinData *pRightData=(RedlinData *)(pRight->GetUserData());
     158             : 
     159           0 :             if(pLeftData!=NULL && pRightData!=NULL)
     160             :             {
     161           0 :                 if(pLeftData->aDateTime < pRightData->aDateTime)
     162             :                 {
     163           0 :                     nCompare = -1;
     164             :                 }
     165           0 :                 else if(pLeftData->aDateTime > pRightData->aDateTime)
     166             :                 {
     167           0 :                     nCompare = 1;
     168             :                 }
     169             :             }
     170             :             else
     171           0 :                 nCompare = SvSimpleTable::ColCompare(pLeft,pRight);
     172             :         }
     173             :         else
     174             :         {
     175           0 :             nCompare = SvSimpleTable::ColCompare(pLeft,pRight);
     176             :         }
     177             : 
     178             :     }
     179             : 
     180           0 :     return nCompare;
     181             : }
     182           0 : void SvxRedlinTable::SetCalcView(bool bFlag)
     183             : {
     184           0 :     bIsCalc=bFlag;
     185           0 :     if(bFlag)
     186             :     {
     187           0 :         nDatePos=CALC_DATE;
     188             :     }
     189             :     else
     190             :     {
     191           0 :         nDatePos=WRITER_DATE;
     192             :     }
     193           0 : }
     194             : 
     195             : 
     196           0 : void SvxRedlinTable::UpdateFilterTest()
     197             : {
     198           0 :     Date aDateMax( Date::SYSTEM );
     199           0 :     sal_uInt16 nYEAR=aDateMax.GetYear()+100;
     200           0 :     aDateMax.SetYear(nYEAR);
     201           0 :     Date aDateMin(1,1,1989);
     202           0 :     tools::Time aTMin(0);
     203           0 :     tools::Time aTMax(23,59,59);
     204             : 
     205             : 
     206           0 :     DateTime aDTMin(aDateMin);
     207           0 :     DateTime aDTMax(aDateMax);
     208             : 
     209           0 :     switch(nDaTiMode)
     210             :     {
     211             :         case FLT_DATE_BEFORE:
     212           0 :                                 aDaTiFilterFirst=aDTMin;
     213           0 :                                 aDaTiFilterLast=aDaTiFirst;
     214           0 :                                 break;
     215             :         case FLT_DATE_SAVE:
     216             :         case FLT_DATE_SINCE:
     217           0 :                                 aDaTiFilterFirst=aDaTiFirst;
     218           0 :                                 aDaTiFilterLast=aDTMax;
     219           0 :                                 break;
     220             :         case FLT_DATE_EQUAL:
     221           0 :                                 aDaTiFilterFirst=aDaTiFirst;
     222           0 :                                 aDaTiFilterLast=aDaTiFirst;
     223           0 :                                 aDaTiFilterFirst.SetTime(aTMin.GetTime());
     224           0 :                                 aDaTiFilterLast.SetTime(aTMax.GetTime());
     225           0 :                                 break;
     226             :         case FLT_DATE_NOTEQUAL:
     227           0 :                                 aDaTiFilterFirst=aDaTiFirst;
     228           0 :                                 aDaTiFilterLast=aDaTiFirst;
     229           0 :                                 aDaTiFilterFirst.SetTime(aTMin.GetTime());
     230           0 :                                 aDaTiFilterLast.SetTime(aTMax.GetTime());
     231           0 :                                 break;
     232             :         case FLT_DATE_BETWEEN:
     233           0 :                                 aDaTiFilterFirst=aDaTiFirst;
     234           0 :                                 aDaTiFilterLast=aDaTiLast;
     235           0 :                                 break;
     236             :     }
     237           0 : }
     238             : 
     239             : 
     240           0 : void SvxRedlinTable::SetFilterDate(bool bFlag)
     241             : {
     242           0 :     bDate=bFlag;
     243           0 : }
     244             : 
     245           0 : void SvxRedlinTable::SetDateTimeMode(sal_uInt16 nMode)
     246             : {
     247           0 :     nDaTiMode=nMode;
     248           0 : }
     249             : 
     250           0 : void SvxRedlinTable::SetFirstDate(const Date& aDate)
     251             : {
     252           0 :     aDaTiFirst.SetDate(aDate.GetDate());
     253           0 : }
     254             : 
     255           0 : void SvxRedlinTable::SetLastDate(const Date& aDate)
     256             : {
     257           0 :     aDaTiLast.SetDate(aDate.GetDate());
     258           0 : }
     259             : 
     260           0 : void SvxRedlinTable::SetFirstTime(const tools::Time& aTime)
     261             : {
     262           0 :     aDaTiFirst.SetTime(aTime.GetTime());
     263           0 : }
     264             : 
     265           0 : void SvxRedlinTable::SetLastTime(const tools::Time& aTime)
     266             : {
     267           0 :     aDaTiLast.SetTime(aTime.GetTime());
     268           0 : }
     269             : 
     270           0 : void SvxRedlinTable::SetFilterAuthor(bool bFlag)
     271             : {
     272           0 :     bAuthor=bFlag;
     273           0 : }
     274             : 
     275           0 : void SvxRedlinTable::SetAuthor(const OUString &aString)
     276             : {
     277           0 :     aAuthor=aString;
     278           0 : }
     279             : 
     280           0 : void SvxRedlinTable::SetFilterComment(bool bFlag)
     281             : {
     282           0 :     bComment=bFlag;
     283           0 : }
     284             : 
     285           0 : void SvxRedlinTable::SetCommentParams( const utl::SearchParam* pSearchPara )
     286             : {
     287           0 :     if(pSearchPara!=NULL)
     288             :     {
     289           0 :         delete pCommentSearcher;
     290             : 
     291           0 :         pCommentSearcher=new utl::TextSearch(*pSearchPara, LANGUAGE_SYSTEM );
     292             :     }
     293           0 : }
     294             : 
     295           0 : bool SvxRedlinTable::IsValidEntry(const OUString &rAuthorStr,
     296             :                                   const DateTime &rDateTime,
     297             :                                   const OUString &rCommentStr)
     298             : {
     299           0 :     return IsValidEntry(rAuthorStr, rDateTime) && IsValidComment(rCommentStr);
     300             : }
     301             : 
     302           0 : bool SvxRedlinTable::IsValidEntry(const OUString &rAuthorStr, const DateTime &rDateTime)
     303             : {
     304           0 :     if (bAuthor && aAuthor!=rAuthorStr)
     305           0 :         return false;
     306             : 
     307           0 :     if (!bDate)
     308           0 :         return true;
     309             : 
     310           0 :     const bool bRes = rDateTime.IsBetween(aDaTiFilterFirst, aDaTiFilterLast);
     311           0 :     return nDaTiMode!=FLT_DATE_NOTEQUAL ? bRes : !bRes;
     312             : }
     313             : 
     314           0 : bool SvxRedlinTable::IsValidComment(const OUString &rCommentStr)
     315             : {
     316           0 :     if (!bComment)
     317           0 :         return true;
     318             : 
     319           0 :     sal_Int32 nStartPos = 0;
     320           0 :     sal_Int32 nEndPos = rCommentStr.getLength();
     321           0 :     return pCommentSearcher->SearchForward( rCommentStr, &nStartPos, &nEndPos);
     322             : }
     323             : 
     324           0 : SvTreeListEntry* SvxRedlinTable::InsertEntry(const OUString& rStr,RedlinData *pUserData,
     325             :                                 SvTreeListEntry* pParent,sal_uIntPtr nPos)
     326             : {
     327           0 :     const Color aColor = (pUserData && pUserData->bDisabled) ? Color(COL_GRAY) : GetTextColor();
     328           0 :     return InsertEntry(rStr, pUserData, aColor, pParent, nPos);
     329             : }
     330             : 
     331           0 : SvTreeListEntry* SvxRedlinTable::InsertEntry(const OUString& rStr,RedlinData *pUserData,const Color& aColor,
     332             :                                 SvTreeListEntry* pParent,sal_uIntPtr nPos)
     333             : {
     334           0 :     aEntryColor=aColor;
     335             : 
     336           0 :     sal_Int32 nIndex = 0;
     337           0 :     const OUString aFirstStr( rStr.getToken(0, '\t', nIndex ) );
     338           0 :     aCurEntry = nIndex>0 ? rStr.copy(nIndex) : OUString();
     339             : 
     340           0 :     return SvSimpleTable::InsertEntry( aFirstStr, pParent, false, nPos, pUserData );
     341             : }
     342             : 
     343           0 : SvTreeListEntry* SvxRedlinTable::CreateEntry() const
     344             : {
     345           0 :     return new SvxRedlinEntry;
     346             : }
     347             : 
     348           0 : void SvxRedlinTable::InitEntry(SvTreeListEntry* pEntry, const OUString& rStr,
     349             :     const Image& rColl, const Image& rExp, SvLBoxButtonKind eButtonKind)
     350             : {
     351             :     SvLBoxString* pString;
     352             :     SvLBoxContextBmp* pContextBmp;
     353             : 
     354           0 :     if( nTreeFlags & TREEFLAG_CHKBTN )
     355             :     {
     356           0 :         SvLBoxButton* pButton= new SvLBoxButton( pEntry,eButtonKind,0,pCheckButtonData );
     357           0 :         pEntry->AddItem( pButton );
     358             :     }
     359             : 
     360           0 :     pContextBmp= new SvLBoxContextBmp(pEntry,0, rColl,rExp, true);
     361           0 :     pEntry->AddItem( pContextBmp );
     362             : 
     363           0 :     pString = new SvLBoxColorString( pEntry, 0, rStr ,aEntryColor);
     364           0 :     pEntry->AddItem( pString );
     365             : 
     366           0 :     sal_Int32 nIndex = 0;
     367             :     // TODO: verify if TabCount() is always >0 here!
     368           0 :     const sal_uInt16 nCount = TabCount()-1;
     369           0 :     for( sal_uInt16 nToken = 0; nToken < nCount; nToken++ )
     370             :     {
     371           0 :         const OUString aToken = GetToken(aCurEntry, nIndex);
     372           0 :         SvLBoxColorString* pStr = new SvLBoxColorString( pEntry, 0, aToken, aEntryColor);
     373           0 :         pEntry->AddItem( pStr );
     374           0 :     }
     375           0 : }
     376             : 
     377           0 : SvxTPView::SvxTPView(vcl::Window * pParent)
     378             :     : TabPage(pParent, "RedlineViewPage", "svx/ui/redlineviewpage.ui")
     379             :     , bEnableAccept(true)
     380             :     , bEnableAcceptAll(true)
     381             :     , bEnableReject(true)
     382             :     , bEnableRejectAll(true)
     383           0 :     , bEnableUndo(true)
     384             : {
     385           0 :     Dialog *pTopLevel = GetParentDialog();
     386           0 :     pTopLevel->get(m_pAccept, "accept");
     387           0 :     pTopLevel->get(m_pReject, "reject");
     388           0 :     pTopLevel->get(m_pAcceptAll, "acceptall");
     389           0 :     pTopLevel->get(m_pRejectAll, "rejectall");
     390           0 :     pTopLevel->get(m_pUndo, "undo");
     391             : 
     392           0 :     SvSimpleTableContainer* pTable = get<SvSimpleTableContainer>("changes");
     393           0 :     Size aControlSize(221, 65);
     394           0 :     aControlSize = LogicToPixel(aControlSize, MAP_APPFONT);
     395           0 :     pTable->set_width_request(aControlSize.Width());
     396           0 :     pTable->set_height_request(aControlSize.Height());
     397           0 :     m_pViewData = new SvxRedlinTable(*pTable, 0);
     398             : 
     399           0 :     Link aLink=LINK( this, SvxTPView, PbClickHdl);
     400             : 
     401           0 :     m_pAccept->SetClickHdl(aLink);
     402           0 :     m_pAcceptAll->SetClickHdl(aLink);
     403           0 :     m_pReject->SetClickHdl(aLink);
     404           0 :     m_pRejectAll->SetClickHdl(aLink);
     405           0 :     m_pUndo->SetClickHdl(aLink);
     406             : 
     407           0 :     m_pViewData->SetTabs(nStaticTabs);
     408           0 : }
     409             : 
     410           0 : void SvxTPView::ActivatePage()
     411             : {
     412           0 :     m_pAccept->Enable(bEnableAccept);
     413           0 :     m_pReject->Enable(bEnableReject);
     414           0 :     m_pAcceptAll->Enable(bEnableAcceptAll);
     415           0 :     m_pRejectAll->Enable(bEnableRejectAll);
     416           0 :     m_pUndo->Enable(bEnableUndo);
     417           0 :     TabPage::ActivatePage();
     418           0 : }
     419             : 
     420           0 : void SvxTPView::DeactivatePage()
     421             : {
     422           0 :     TabPage::DeactivatePage();
     423           0 :     m_pAccept->Disable();
     424           0 :     m_pReject->Disable();
     425           0 :     m_pAcceptAll->Disable();
     426           0 :     m_pRejectAll->Disable();
     427           0 :     m_pUndo->Disable();
     428           0 : }
     429             : 
     430           0 : SvxTPView::~SvxTPView()
     431             : {
     432           0 :     delete m_pViewData;
     433           0 : }
     434             : 
     435           0 : void SvxTPView::InsertWriterHeader()
     436             : {
     437           0 :     OUString aStrTab('\t');
     438           0 :     OUString aString(get<FixedText>("action")->GetText());
     439           0 :     aString += aStrTab;
     440           0 :     aString += get<FixedText>("author")->GetText();
     441           0 :     aString += aStrTab;
     442           0 :     aString += get<FixedText>("date")->GetText();
     443           0 :     aString += aStrTab;
     444           0 :     aString += get<FixedText>("comment")->GetText();
     445           0 :     m_pViewData->ClearHeader();
     446           0 :     m_pViewData->InsertHeaderEntry(aString);
     447           0 : }
     448             : 
     449           0 : void SvxTPView::InsertCalcHeader()
     450             : {
     451           0 :     OUString aStrTab('\t');
     452           0 :     OUString aString(get<FixedText>("action")->GetText());
     453           0 :     aString += aStrTab;
     454           0 :     aString += get<FixedText>("position")->GetText();
     455           0 :     aString += aStrTab;
     456           0 :     aString += get<FixedText>("author")->GetText();
     457           0 :     aString += aStrTab;
     458           0 :     aString += get<FixedText>("date")->GetText();
     459           0 :     aString += aStrTab;
     460           0 :     aString += get<FixedText>("comment")->GetText();
     461           0 :     m_pViewData->ClearHeader();
     462           0 :     m_pViewData->InsertHeaderEntry(aString);
     463           0 : }
     464             : 
     465           0 : void SvxTPView::EnableAccept(bool nFlag)
     466             : {
     467           0 :     bEnableAccept = nFlag;
     468           0 :     m_pAccept->Enable(nFlag);
     469           0 : }
     470             : 
     471           0 : void SvxTPView::EnableAcceptAll(bool nFlag)
     472             : {
     473           0 :     bEnableAcceptAll = nFlag;
     474           0 :     m_pAcceptAll->Enable(nFlag);
     475           0 : }
     476             : 
     477           0 : void SvxTPView::EnableReject(bool nFlag)
     478             : {
     479           0 :     bEnableReject = nFlag;
     480           0 :     m_pReject->Enable(nFlag);
     481           0 : }
     482             : 
     483           0 : void SvxTPView::EnableRejectAll(bool nFlag)
     484             : {
     485           0 :     bEnableRejectAll = nFlag;
     486           0 :     m_pRejectAll->Enable(nFlag);
     487           0 : }
     488             : 
     489           0 : void SvxTPView::ShowUndo(bool nFlag)
     490             : {
     491           0 :     m_pUndo->Show(nFlag);
     492           0 : }
     493             : 
     494           0 : void SvxTPView::EnableUndo(bool nFlag)
     495             : {
     496           0 :     bEnableUndo = nFlag;
     497           0 :     m_pUndo->Enable(nFlag);
     498           0 : }
     499             : 
     500             : 
     501           0 : IMPL_LINK( SvxTPView, PbClickHdl, PushButton*, pPushB )
     502             : {
     503           0 :     if (pPushB == m_pAccept)
     504             :     {
     505           0 :         AcceptClickLk.Call(this);
     506             :     }
     507           0 :     else if (pPushB == m_pAcceptAll)
     508             :     {
     509           0 :         AcceptAllClickLk.Call(this);
     510             :     }
     511           0 :     else if (pPushB == m_pReject)
     512             :     {
     513           0 :         RejectClickLk.Call(this);
     514             :     }
     515           0 :     else if (pPushB == m_pRejectAll)
     516             :     {
     517           0 :         RejectAllClickLk.Call(this);
     518             :     }
     519           0 :     else if (pPushB == m_pUndo)
     520             :     {
     521           0 :         UndoClickLk.Call(this);
     522             :     }
     523             : 
     524           0 :     return 0;
     525             : }
     526             : 
     527           0 : SvxTPFilter::SvxTPFilter( vcl::Window * pParent)
     528             :     : TabPage(pParent, "RedlineFilterPage", "svx/ui/redlinefilterpage.ui")
     529             :     , pRedlinTable(NULL)
     530           0 :     , bModified(false)
     531             : {
     532           0 :     get(m_pCbDate, "date");
     533           0 :     get(m_pLbDate, "datecond");
     534           0 :     get(m_pDfDate, "startdate");
     535           0 :     get(m_pTfDate, "starttime");
     536           0 :     get(m_pIbClock, "startclock");
     537           0 :     get(m_pFtDate2, "and");
     538           0 :     get(m_pDfDate2, "enddate");
     539           0 :     get(m_pTfDate2, "endtime");
     540           0 :     get(m_pIbClock2, "endclock");
     541           0 :     get(m_pCbAuthor, "author");
     542           0 :     get(m_pLbAuthor, "authorlist");
     543           0 :     get(m_pCbRange, "range");
     544           0 :     get(m_pEdRange, "rangeedit");
     545           0 :     get(m_pBtnRange, "dotdotdot");
     546           0 :     get(m_pCbAction, "action");
     547           0 :     get(m_pLbAction, "actionlist");
     548           0 :     get(m_pCbComment, "comment");
     549           0 :     get(m_pEdComment, "commentedit");
     550             : 
     551           0 :     m_pLbAuthor->SetAccessibleName(m_pCbAuthor->GetText());
     552           0 :     m_pEdComment->SetAccessibleName(m_pCbComment->GetText());
     553             : 
     554           0 :     m_pDfDate->SetShowDateCentury( true );
     555           0 :     m_pDfDate2->SetShowDateCentury( true );
     556             : 
     557           0 :     m_pLbDate->SelectEntryPos(0);
     558           0 :     m_pLbDate->SetSelectHdl( LINK( this, SvxTPFilter, SelDateHdl ) );
     559           0 :     m_pIbClock->SetClickHdl( LINK( this, SvxTPFilter, TimeHdl) );
     560           0 :     m_pIbClock2->SetClickHdl( LINK( this, SvxTPFilter,TimeHdl) );
     561           0 :     m_pBtnRange->SetClickHdl( LINK( this, SvxTPFilter, RefHandle));
     562             : 
     563           0 :     Link aLink=LINK( this, SvxTPFilter, RowEnableHdl) ;
     564           0 :     m_pCbDate->SetClickHdl(aLink);
     565           0 :     m_pCbAuthor->SetClickHdl(aLink);
     566           0 :     m_pCbRange->SetClickHdl(aLink);
     567           0 :     m_pCbAction->SetClickHdl(aLink);
     568           0 :     m_pCbComment->SetClickHdl(aLink);
     569             : 
     570           0 :     Link a2Link=LINK( this, SvxTPFilter, ModifyDate);
     571           0 :     m_pDfDate->SetModifyHdl(a2Link);
     572           0 :     m_pTfDate->SetModifyHdl(a2Link);
     573           0 :     m_pDfDate2->SetModifyHdl(a2Link);
     574           0 :     m_pTfDate2->SetModifyHdl(a2Link);
     575             : 
     576           0 :     Link a3Link=LINK( this, SvxTPFilter, ModifyHdl);
     577           0 :     m_pEdRange->SetModifyHdl(a3Link);
     578           0 :     m_pEdComment->SetModifyHdl(a3Link);
     579           0 :     m_pLbAction->SetSelectHdl(a3Link);
     580           0 :     m_pLbAuthor->SetSelectHdl(a3Link);
     581             : 
     582           0 :     RowEnableHdl(m_pCbDate);
     583           0 :     RowEnableHdl(m_pCbAuthor);
     584           0 :     RowEnableHdl(m_pCbRange);
     585           0 :     RowEnableHdl(m_pCbAction);
     586           0 :     RowEnableHdl(m_pCbComment);
     587             : 
     588           0 :     Date aDate( Date::SYSTEM );
     589           0 :     tools::Time aTime( tools::Time::SYSTEM );
     590           0 :     m_pDfDate->SetDate(aDate);
     591           0 :     m_pTfDate->SetTime(aTime);
     592           0 :     m_pDfDate2->SetDate(aDate);
     593           0 :     m_pTfDate2->SetTime(aTime);
     594           0 :     HideRange();
     595           0 :     ShowAction();
     596           0 :     bModified=false;
     597           0 : }
     598             : 
     599           0 : void SvxTPFilter::SetRedlinTable(SvxRedlinTable* pTable)
     600             : {
     601           0 :     pRedlinTable=pTable;
     602           0 : }
     603             : 
     604           0 : void SvxTPFilter::ShowDateFields(sal_uInt16 nKind)
     605             : {
     606           0 :     switch(nKind)
     607             :     {
     608             :         case FLT_DATE_BEFORE:
     609           0 :                 EnableDateLine1(true);
     610           0 :                 EnableDateLine2(false);
     611           0 :                 break;
     612             :         case FLT_DATE_SINCE:
     613           0 :                 EnableDateLine1(true);
     614           0 :                 EnableDateLine2(false);
     615           0 :                 break;
     616             :         case FLT_DATE_EQUAL:
     617           0 :                 EnableDateLine1(true);
     618           0 :                 m_pTfDate->Disable();
     619           0 :                 m_pTfDate->SetText(OUString());
     620           0 :                 EnableDateLine2(false);
     621           0 :                 break;
     622             :         case FLT_DATE_NOTEQUAL:
     623           0 :                 EnableDateLine1(true);
     624           0 :                 m_pTfDate->Disable();
     625           0 :                 m_pTfDate->SetText(OUString());
     626           0 :                 EnableDateLine2(false);
     627           0 :                 break;
     628             :         case FLT_DATE_BETWEEN:
     629           0 :                 EnableDateLine1(true);
     630           0 :                 EnableDateLine2(true);
     631           0 :                 break;
     632             :         case FLT_DATE_SAVE:
     633           0 :                 EnableDateLine1(false);
     634           0 :                 EnableDateLine2(false);
     635           0 :                 break;
     636             :     }
     637           0 : }
     638             : 
     639           0 : void SvxTPFilter::EnableDateLine1(bool bFlag)
     640             : {
     641           0 :     if(bFlag && m_pCbDate->IsChecked())
     642             :     {
     643           0 :         m_pDfDate->Enable();
     644           0 :         m_pTfDate->Enable();
     645           0 :         m_pIbClock->Enable();
     646             :     }
     647             :     else
     648             :     {
     649           0 :         m_pDfDate->Disable();
     650           0 :         m_pTfDate->Disable();
     651           0 :         m_pIbClock->Disable();
     652             :     }
     653           0 : }
     654           0 : void SvxTPFilter::EnableDateLine2(bool bFlag)
     655             : {
     656           0 :     if(bFlag && m_pCbDate->IsChecked())
     657             :     {
     658           0 :         m_pFtDate2->Enable();
     659           0 :         m_pDfDate2->Enable();
     660           0 :         m_pTfDate2->Enable();
     661           0 :         m_pIbClock2->Enable();
     662             :     }
     663             :     else
     664             :     {
     665           0 :         m_pFtDate2->Disable();
     666           0 :         m_pDfDate2->Disable();
     667           0 :         m_pDfDate2->SetText(OUString());
     668           0 :         m_pTfDate2->Disable();
     669           0 :         m_pTfDate2->SetText(OUString());
     670           0 :         m_pIbClock2->Disable();
     671             :     }
     672           0 : }
     673             : 
     674           0 : Date SvxTPFilter::GetFirstDate() const
     675             : {
     676           0 :     return m_pDfDate->GetDate();
     677             : }
     678             : 
     679           0 : void SvxTPFilter::SetFirstDate(const Date &aDate)
     680             : {
     681           0 :     m_pDfDate->SetDate(aDate);
     682           0 : }
     683             : 
     684           0 : tools::Time SvxTPFilter::GetFirstTime() const
     685             : {
     686           0 :     return m_pTfDate->GetTime();
     687             : }
     688             : 
     689           0 : void SvxTPFilter::SetFirstTime(const tools::Time &aTime)
     690             : {
     691           0 :     m_pTfDate->SetTime(aTime);
     692           0 : }
     693             : 
     694             : 
     695           0 : Date SvxTPFilter::GetLastDate() const
     696             : {
     697           0 :     return m_pDfDate2->GetDate();
     698             : }
     699             : 
     700           0 : void SvxTPFilter::SetLastDate(const Date &aDate)
     701             : {
     702           0 :     m_pDfDate2->SetDate(aDate);
     703           0 : }
     704             : 
     705           0 : tools::Time SvxTPFilter::GetLastTime() const
     706             : {
     707           0 :     return m_pTfDate2->GetTime();
     708             : }
     709             : 
     710           0 : void SvxTPFilter::SetLastTime(const tools::Time &aTime)
     711             : {
     712           0 :     m_pTfDate2->SetTime(aTime);
     713           0 : }
     714             : 
     715           0 : void SvxTPFilter::SetDateMode(sal_uInt16 nMode)
     716             : {
     717           0 :     m_pLbDate->SelectEntryPos(nMode);
     718           0 :     SelDateHdl(m_pLbDate);
     719           0 : }
     720             : 
     721           0 : sal_uInt16 SvxTPFilter::GetDateMode()
     722             : {
     723           0 :     return (sal_uInt16) m_pLbDate->GetSelectEntryPos();
     724             : }
     725           0 : void SvxTPFilter::ClearAuthors()
     726             : {
     727           0 :     m_pLbAuthor->Clear();
     728           0 : }
     729             : 
     730           0 : void SvxTPFilter::InsertAuthor( const OUString& rString, sal_Int32 nPos)
     731             : {
     732           0 :     m_pLbAuthor->InsertEntry(rString,nPos);
     733           0 : }
     734             : 
     735           0 : OUString SvxTPFilter::GetSelectedAuthor() const
     736             : {
     737           0 :     return m_pLbAuthor->GetSelectEntry();
     738             : }
     739             : 
     740           0 : void SvxTPFilter::SelectedAuthorPos(sal_Int32 nPos)
     741             : {
     742           0 :     m_pLbAuthor->SelectEntryPos(nPos);
     743           0 : }
     744             : 
     745           0 : sal_Int32 SvxTPFilter::SelectAuthor(const OUString& aString)
     746             : {
     747           0 :     m_pLbAuthor->SelectEntry(aString);
     748           0 :     return m_pLbAuthor->GetSelectEntryPos();
     749             : }
     750             : 
     751           0 : void SvxTPFilter::SetRange(const OUString& rString)
     752             : {
     753           0 :     m_pEdRange->SetText(rString);
     754           0 : }
     755             : 
     756           0 : OUString SvxTPFilter::GetRange() const
     757             : {
     758           0 :     return m_pEdRange->GetText();
     759             : }
     760             : 
     761           0 : void SvxTPFilter::SetFocusToRange()
     762             : {
     763           0 :     m_pEdRange->GrabFocus();
     764           0 : }
     765             : 
     766           0 : void SvxTPFilter::HideRange(bool bHide)
     767             : {
     768           0 :     if (bHide)
     769             :     {
     770           0 :         m_pCbRange->Hide();
     771           0 :         m_pEdRange->Hide();
     772           0 :         m_pBtnRange->Hide();
     773             :     }
     774             :     else
     775             :     {
     776           0 :         ShowAction(false);
     777           0 :         m_pCbRange->Show();
     778           0 :         m_pEdRange->Show();
     779           0 :         m_pBtnRange->Show();
     780             :     }
     781           0 : }
     782             : 
     783           0 : void SvxTPFilter::SetComment(const OUString &rComment)
     784             : {
     785           0 :     m_pEdComment->SetText(rComment);
     786           0 : }
     787             : 
     788           0 : OUString SvxTPFilter::GetComment()const
     789             : {
     790           0 :     return m_pEdComment->GetText();
     791             : }
     792             : 
     793           0 : bool SvxTPFilter::IsDate()
     794             : {
     795           0 :     return m_pCbDate->IsChecked();
     796             : }
     797             : 
     798           0 : bool SvxTPFilter::IsAuthor()
     799             : {
     800           0 :     return m_pCbAuthor->IsChecked();
     801             : }
     802             : 
     803           0 : bool SvxTPFilter::IsRange()
     804             : {
     805           0 :     return m_pCbRange->IsChecked();
     806             : }
     807             : 
     808           0 : bool SvxTPFilter::IsAction()
     809             : {
     810           0 :     return m_pCbAction->IsChecked();
     811             : }
     812             : 
     813           0 : bool SvxTPFilter::IsComment()
     814             : {
     815           0 :     return m_pCbComment->IsChecked();
     816             : }
     817             : 
     818           0 : void SvxTPFilter::CheckDate(bool bFlag)
     819             : {
     820           0 :     m_pCbDate->Check(bFlag);
     821           0 :     RowEnableHdl(m_pCbDate);
     822           0 :     bModified=false;
     823           0 : }
     824             : 
     825           0 : void SvxTPFilter::CheckAuthor(bool bFlag)
     826             : {
     827           0 :     m_pCbAuthor->Check(bFlag);
     828           0 :     RowEnableHdl(m_pCbAuthor);
     829           0 :     bModified=false;
     830           0 : }
     831             : 
     832           0 : void SvxTPFilter::CheckRange(bool bFlag)
     833             : {
     834           0 :     m_pCbRange->Check(bFlag);
     835           0 :     RowEnableHdl(m_pCbRange);
     836           0 :     bModified=false;
     837           0 : }
     838             : 
     839           0 : void SvxTPFilter::CheckAction(bool bFlag)
     840             : {
     841           0 :     m_pCbAction->Check(bFlag);
     842           0 :     RowEnableHdl(m_pCbAction);
     843           0 :     bModified=false;
     844           0 : }
     845             : 
     846           0 : void SvxTPFilter::CheckComment(bool bFlag)
     847             : {
     848           0 :     m_pCbComment->Check(bFlag);
     849           0 :     RowEnableHdl(m_pCbComment);
     850           0 :     bModified=false;
     851           0 : }
     852             : 
     853           0 : void SvxTPFilter::ShowAction(bool bShow)
     854             : {
     855           0 :     if(!bShow)
     856             :     {
     857           0 :         m_pCbAction->Hide();
     858           0 :         m_pLbAction->Hide();
     859             :     }
     860             :     else
     861             :     {
     862           0 :         HideRange();
     863           0 :         m_pCbAction->Show();
     864           0 :         m_pLbAction->Show();
     865             :     }
     866           0 : }
     867             : 
     868             : 
     869           0 : IMPL_LINK( SvxTPFilter, SelDateHdl, ListBox*, pLb )
     870             : {
     871           0 :     ShowDateFields((sal_uInt16)m_pLbDate->GetSelectEntryPos());
     872           0 :     ModifyHdl(pLb);
     873           0 :     return 0;
     874             : }
     875             : 
     876           0 : IMPL_LINK( SvxTPFilter, RowEnableHdl, CheckBox*, pCB )
     877             : {
     878           0 :     if (pCB == m_pCbDate)
     879             :     {
     880           0 :         m_pLbDate->Enable(m_pCbDate->IsChecked());
     881           0 :         m_pLbDate->Invalidate();
     882           0 :         EnableDateLine1(false);
     883           0 :         EnableDateLine2(false);
     884           0 :         if(m_pCbDate->IsChecked()) SelDateHdl(m_pLbDate);
     885             :     }
     886           0 :     else if (pCB == m_pCbAuthor)
     887             :     {
     888           0 :         m_pLbAuthor->Enable(m_pCbAuthor->IsChecked());
     889           0 :         m_pLbAuthor->Invalidate();
     890             :     }
     891           0 :     else if (pCB == m_pCbRange)
     892             :     {
     893           0 :         m_pEdRange->Enable(m_pCbRange->IsChecked());
     894           0 :         m_pBtnRange->Enable(m_pCbRange->IsChecked());
     895             :     }
     896           0 :     else if (pCB == m_pCbAction)
     897             :     {
     898           0 :         m_pLbAction->Enable(m_pCbAction->IsChecked());
     899           0 :         m_pLbAction->Invalidate();
     900             :     }
     901           0 :     else if (pCB == m_pCbComment)
     902             :     {
     903           0 :         m_pEdComment->Enable(m_pCbComment->IsChecked());
     904           0 :         m_pEdComment->Invalidate();
     905             :     }
     906             : 
     907           0 :     ModifyHdl(pCB);
     908           0 :     return 0;
     909             : }
     910             : 
     911           0 : IMPL_LINK( SvxTPFilter, TimeHdl, ImageButton*,pIB )
     912             : {
     913           0 :     Date aDate( Date::SYSTEM );
     914           0 :     tools::Time aTime( tools::Time::SYSTEM );
     915           0 :     if (pIB == m_pIbClock)
     916             :     {
     917           0 :         m_pDfDate->SetDate(aDate);
     918           0 :         m_pTfDate->SetTime(aTime);
     919             :     }
     920           0 :     else if (pIB == m_pIbClock2)
     921             :     {
     922           0 :         m_pDfDate2->SetDate(aDate);
     923           0 :         m_pTfDate2->SetTime(aTime);
     924             :     }
     925           0 :     ModifyHdl(m_pDfDate);
     926           0 :     return 0;
     927             : }
     928             : 
     929           0 : IMPL_LINK( SvxTPFilter, ModifyHdl, void*, pCtr)
     930             : {
     931           0 :     if(pCtr!=NULL)
     932             :     {
     933           0 :         if (pCtr == m_pCbDate || pCtr == m_pLbDate ||
     934           0 :             pCtr == m_pDfDate || pCtr == m_pTfDate ||
     935           0 :             pCtr == m_pIbClock || pCtr == m_pFtDate2 ||
     936           0 :             pCtr == m_pDfDate2 || pCtr == m_pTfDate2 ||
     937           0 :             pCtr == m_pIbClock2)
     938             :         {
     939           0 :             aModifyDateLink.Call(this);
     940             :         }
     941           0 :         else if (pCtr == m_pCbAuthor || pCtr == m_pLbAuthor)
     942             :         {
     943           0 :             aModifyAuthorLink.Call(this);
     944             :         }
     945           0 :         else if (pCtr == m_pCbRange || pCtr == m_pLbAction || pCtr == m_pEdRange ||
     946           0 :                 pCtr == m_pBtnRange)
     947             :         {
     948           0 :             aModifyRefLink.Call(this);
     949             :         }
     950           0 :         else if (pCtr == m_pCbComment || pCtr == m_pEdComment)
     951             :         {
     952           0 :             aModifyComLink.Call(this);
     953             :         }
     954             : 
     955           0 :         bModified=true;
     956           0 :         aModifyLink.Call(this);
     957             :     }
     958           0 :     return 0;
     959             : }
     960             : 
     961           0 : void SvxTPFilter::DeactivatePage()
     962             : {
     963           0 :     if(bModified)
     964             :     {
     965           0 :         if(pRedlinTable!=NULL)
     966             :         {
     967           0 :             pRedlinTable->SetFilterDate(IsDate());
     968           0 :             pRedlinTable->SetDateTimeMode(GetDateMode());
     969           0 :             pRedlinTable->SetFirstDate(m_pDfDate->GetDate());
     970           0 :             pRedlinTable->SetLastDate(m_pDfDate2->GetDate());
     971           0 :             pRedlinTable->SetFirstTime(m_pTfDate->GetTime());
     972           0 :             pRedlinTable->SetLastTime(m_pTfDate2->GetTime());
     973           0 :             pRedlinTable->SetFilterAuthor(IsAuthor());
     974           0 :             pRedlinTable->SetAuthor(GetSelectedAuthor());
     975             : 
     976           0 :             pRedlinTable->SetFilterComment(IsComment());
     977             : 
     978           0 :             utl::SearchParam aSearchParam( m_pEdComment->GetText(),
     979           0 :                     utl::SearchParam::SRCH_REGEXP,false,false,false );
     980             : 
     981           0 :             pRedlinTable->SetCommentParams(&aSearchParam);
     982             : 
     983           0 :             pRedlinTable->UpdateFilterTest();
     984             :         }
     985             : 
     986           0 :         aReadyLink.Call(this);
     987             :     }
     988           0 :     bModified=false;
     989           0 :     TabPage::DeactivatePage();
     990           0 : }
     991             : 
     992           0 : void SvxTPFilter::Enable( bool bEnable, bool bChild)
     993             : {
     994           0 :     TabPage::Enable(bEnable,bChild);
     995           0 :     if(m_pCbDate->IsEnabled())
     996             :     {
     997           0 :         RowEnableHdl(m_pCbDate);
     998           0 :         RowEnableHdl(m_pCbAuthor);
     999           0 :         RowEnableHdl(m_pCbRange);
    1000           0 :         RowEnableHdl(m_pCbComment);
    1001             :     }
    1002           0 : }
    1003           0 : void SvxTPFilter::Disable( bool bChild)
    1004             : {
    1005           0 :     Enable( false, bChild );
    1006           0 : }
    1007             : 
    1008           0 : IMPL_LINK( SvxTPFilter, ModifyDate, void*,pTF)
    1009             : {
    1010             : 
    1011           0 :     Date aDate( Date::SYSTEM );
    1012           0 :     tools::Time aTime(0);
    1013           0 :     if (m_pDfDate==pTF)
    1014             :     {
    1015           0 :         if(m_pDfDate->GetText().isEmpty())
    1016           0 :            m_pDfDate->SetDate(aDate);
    1017             : 
    1018           0 :         if(pRedlinTable!=NULL)
    1019           0 :             pRedlinTable->SetFirstDate(m_pDfDate->GetDate());
    1020             :     }
    1021           0 :     else if (m_pDfDate2==pTF)
    1022             :     {
    1023           0 :         if(m_pDfDate2->GetText().isEmpty())
    1024           0 :            m_pDfDate2->SetDate(aDate);
    1025             : 
    1026           0 :         if(pRedlinTable!=NULL)
    1027           0 :             pRedlinTable->SetLastDate(m_pDfDate2->GetDate());
    1028             :     }
    1029           0 :     else if (m_pTfDate==pTF)
    1030             :     {
    1031           0 :         if(m_pTfDate->GetText().isEmpty())
    1032           0 :            m_pTfDate->SetTime(aTime);
    1033             : 
    1034           0 :         if(pRedlinTable!=NULL)
    1035           0 :             pRedlinTable->SetFirstTime(m_pTfDate->GetTime());
    1036             :     }
    1037           0 :     else if (m_pTfDate2==pTF)
    1038             :     {
    1039           0 :         if(m_pTfDate2->GetText().isEmpty())
    1040           0 :            m_pTfDate2->SetTime(aTime);
    1041             : 
    1042           0 :         if(pRedlinTable!=NULL)
    1043           0 :             pRedlinTable->SetLastTime(m_pTfDate2->GetTime());
    1044             : 
    1045             :     }
    1046           0 :     ModifyHdl(m_pDfDate);
    1047           0 :     return 0;
    1048             : }
    1049             : 
    1050           0 : IMPL_LINK( SvxTPFilter, RefHandle, PushButton*, pRef )
    1051             : {
    1052           0 :     if(pRef!=NULL)
    1053             :     {
    1054           0 :         aRefLink.Call(this);
    1055             :     }
    1056           0 :     return 0;
    1057             : }
    1058             : 
    1059           0 : SvxAcceptChgCtr::SvxAcceptChgCtr(vcl::Window* pParent)
    1060           0 :     : TabControl(pParent, WB_TABSTOP | WB_DIALOGCONTROL)
    1061             : {
    1062           0 :     m_pUIBuilder = new VclBuilder(this, getUIRootDir(), "svx/ui/redlinecontrol.ui", "RedlineControl");
    1063             : 
    1064           0 :     pTPFilter = new SvxTPFilter(this);
    1065           0 :     pTPView = new SvxTPView(this);
    1066             : 
    1067           0 :     m_nViewPageId = GetPageId("view");
    1068           0 :     m_nFilterPageId = GetPageId("filter");
    1069           0 :     SetTabPage(m_nViewPageId, pTPView);
    1070           0 :     SetTabPage(m_nFilterPageId, pTPFilter);
    1071             : 
    1072           0 :     pTPFilter->SetRedlinTable(GetViewTable());
    1073             : 
    1074           0 :     ShowViewPage();
    1075             : 
    1076           0 :     Show();
    1077           0 : }
    1078             : 
    1079           0 : SvxAcceptChgCtr::~SvxAcceptChgCtr()
    1080             : {
    1081           0 :     delete pTPView;
    1082           0 :     delete pTPFilter;
    1083           0 : }
    1084             : 
    1085           0 : void SvxAcceptChgCtr::ShowFilterPage()
    1086             : {
    1087           0 :     SetCurPageId(m_nFilterPageId);
    1088           0 : }
    1089             : 
    1090           0 : void SvxAcceptChgCtr::ShowViewPage()
    1091             : {
    1092           0 :     SetCurPageId(m_nViewPageId);
    1093           0 : }
    1094             : 
    1095             : 
    1096             : 
    1097           0 : SvxRedlinTable* SvxAcceptChgCtr::GetViewTable()
    1098             : {
    1099           0 :     return pTPView ? pTPView->GetTableControl() : NULL;
    1100         594 : }
    1101             : 
    1102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10