LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/miscdlgs - acredlin.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1062 0.1 %
Date: 2013-07-09 Functions: 2 62 3.2 %
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             : 
      21             : #include <comphelper/string.hxx>
      22             : #include <svl/undo.hxx>
      23             : #include <unotools/textsearch.hxx>
      24             : #include <unotools/localedatawrapper.hxx>
      25             : #include <unotools/collatorwrapper.hxx>
      26             : #include <vcl/msgbox.hxx>
      27             : #include <sfx2/app.hxx>
      28             : #include <sfx2/viewfrm.hxx>
      29             : 
      30             : #include "acredlin.hxx"
      31             : #include "global.hxx"
      32             : #include "reffact.hxx"
      33             : #include "document.hxx"
      34             : #include "docsh.hxx"
      35             : #include "scresid.hxx"
      36             : #include "globstr.hrc"
      37             : #include "acredlin.hrc"
      38             : #include "simpref.hxx"
      39             : #include "scmod.hxx"
      40             : #include "popmenu.hxx"
      41             : #include "tabvwsh.hxx"
      42             : 
      43             : // defines -------------------------------------------------------------------
      44             : 
      45             : #define ABS_SREF          SCA_VALID \
      46             :                         | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
      47             : #define ABS_DREF          ABS_SREF \
      48             :                         | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
      49             : #define ABS_DREF3D      ABS_DREF | SCA_TAB_3D
      50             : 
      51             : #define RD_SPECIAL_NONE         0
      52             : #define RD_SPECIAL_CONTENT      1
      53             : #define RD_SPECIAL_VISCONTENT   2
      54             : 
      55             : //============================================================================
      56             : //  class ScRedlinData
      57             : //----------------------------------------------------------------------------
      58           0 : ScRedlinData::ScRedlinData()
      59           0 :     :RedlinData()
      60             : {
      61           0 :     nInfo=RD_SPECIAL_NONE;
      62           0 :     nActionNo=0;
      63           0 :     pData=NULL;
      64           0 :     bDisabled=false;
      65           0 :     bIsRejectable=false;
      66           0 :     bIsAcceptable=false;
      67           0 :     nTable=SCTAB_MAX;
      68           0 :     nCol=SCCOL_MAX;
      69           0 :     nRow=SCROW_MAX;
      70           0 : }
      71             : 
      72           0 : ScRedlinData::~ScRedlinData()
      73             : {
      74           0 :     nInfo=RD_SPECIAL_NONE;
      75           0 :     nActionNo=0;
      76           0 :     pData=NULL;
      77           0 :     bDisabled=false;
      78           0 :     bIsRejectable=false;
      79           0 :     bIsAcceptable=false;
      80           0 : }
      81             : 
      82             : //============================================================================
      83             : //  class ScAcceptChgDlg
      84             : //----------------------------------------------------------------------------
      85           0 : ScAcceptChgDlg::ScAcceptChgDlg(SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
      86             :     ScViewData* ptrViewData)
      87             :     : SfxModelessDialog(pB, pCW, pParent,
      88             :         "AcceptRejectChangesDialog", "svx/ui/acceptrejectchangesdialog.ui"),
      89             :         pViewData       ( ptrViewData ),
      90           0 :         pDoc            ( ptrViewData->GetDocument() ),
      91           0 :         aLocalRangeName ( *(pDoc->GetRangeName()) ),
      92             :         aStrInsertCols       (SC_RESSTR(STR_CHG_INSERT_COLS)),
      93             :         aStrInsertRows       (SC_RESSTR(STR_CHG_INSERT_ROWS)),
      94             :         aStrInsertTabs       (SC_RESSTR(STR_CHG_INSERT_TABS)),
      95             :         aStrDeleteCols       (SC_RESSTR(STR_CHG_DELETE_COLS)),
      96             :         aStrDeleteRows       (SC_RESSTR(STR_CHG_DELETE_ROWS)),
      97             :         aStrDeleteTabs       (SC_RESSTR(STR_CHG_DELETE_TABS)),
      98             :         aStrMove             (SC_RESSTR(STR_CHG_MOVE)),
      99             :         aStrContent          (SC_RESSTR(STR_CHG_CONTENT)),
     100             :         aStrReject           (SC_RESSTR(STR_CHG_REJECT)),
     101             :         aStrAllAccepted      (SC_RESSTR(STR_CHG_ACCEPTED)),
     102             :         aStrAllRejected      (SC_RESSTR(STR_CHG_REJECTED)),
     103             :         aStrNoEntry          (SC_RESSTR(STR_CHG_NO_ENTRY)),
     104             :         aStrContentWithChild (SC_RESSTR(STR_CHG_CONTENT_WITH_CHILD)),
     105             :         aStrChildContent     (SC_RESSTR(STR_CHG_CHILD_CONTENT)),
     106             :         aStrChildOrgContent  (SC_RESSTR(STR_CHG_CHILD_ORGCONTENT)),
     107             :         aStrEmpty            (SC_RESSTR(STR_CHG_EMPTY)),
     108             :         aUnknown("Unknown"),
     109             :         bAcceptEnableFlag(true),
     110             :         bRejectEnableFlag(true),
     111             :         bNeedsUpdate(false),
     112             :         bIgnoreMsg(false),
     113             :         bNoSelection(false),
     114             :         bHasFilterEntry(false),
     115           0 :         bUseColor(false)
     116             : {
     117           0 :     m_pAcceptChgCtr = new SvxAcceptChgCtr(get_content_area());
     118           0 :     nAcceptCount=0;
     119           0 :     nRejectCount=0;
     120           0 :     aReOpenTimer.SetTimeout(50);
     121           0 :     aReOpenTimer.SetTimeoutHdl(LINK( this, ScAcceptChgDlg, ReOpenTimerHdl ));
     122             : 
     123           0 :     pTPFilter=m_pAcceptChgCtr->GetFilterPage();
     124           0 :     pTPView=m_pAcceptChgCtr->GetViewPage();
     125           0 :     pTheView=pTPView->GetTableControl();
     126           0 :     aSelectionTimer.SetTimeout(100);
     127           0 :     aSelectionTimer.SetTimeoutHdl(LINK( this, ScAcceptChgDlg, UpdateSelectionHdl ));
     128             : 
     129           0 :     pTPFilter->SetReadyHdl(LINK( this, ScAcceptChgDlg, FilterHandle ));
     130           0 :     pTPFilter->SetRefHdl(LINK( this, ScAcceptChgDlg, RefHandle ));
     131           0 :     pTPFilter->SetModifyHdl(LINK( this, ScAcceptChgDlg, FilterModified));
     132           0 :     pTPFilter->HideRange(false);
     133           0 :     pTPView->InsertCalcHeader();
     134           0 :     pTPView->SetRejectClickHdl( LINK( this, ScAcceptChgDlg,RejectHandle));
     135           0 :     pTPView->SetAcceptClickHdl( LINK(this, ScAcceptChgDlg, AcceptHandle));
     136           0 :     pTPView->SetRejectAllClickHdl( LINK( this, ScAcceptChgDlg,RejectAllHandle));
     137           0 :     pTPView->SetAcceptAllClickHdl( LINK(this, ScAcceptChgDlg, AcceptAllHandle));
     138           0 :     pTheView->SetCalcView();
     139           0 :     pTheView->SetStyle(pTheView->GetStyle()|WB_HASLINES|WB_CLIPCHILDREN|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
     140           0 :     pTheView->SetExpandingHdl( LINK(this, ScAcceptChgDlg, ExpandingHandle));
     141           0 :     pTheView->SetSelectHdl( LINK(this, ScAcceptChgDlg, SelectHandle));
     142           0 :     pTheView->SetDeselectHdl( LINK(this, ScAcceptChgDlg, SelectHandle));
     143           0 :     pTheView->SetCommandHdl( LINK(this, ScAcceptChgDlg, CommandHdl));
     144           0 :     pTheView->SetColCompareHdl( LINK(this, ScAcceptChgDlg,ColCompareHdl));
     145           0 :     pTheView->SetSelectionMode(MULTIPLE_SELECTION);
     146           0 :     pTheView->SetHighlightRange(1);
     147             : 
     148           0 :     Init();
     149             : 
     150           0 :     UpdateView();
     151           0 :     SvTreeListEntry* pEntry=pTheView->First();
     152           0 :     if(pEntry!=NULL)
     153             :     {
     154           0 :         pTheView->Select(pEntry);
     155             :     }
     156           0 : }
     157             : 
     158           0 : ScAcceptChgDlg::~ScAcceptChgDlg()
     159             : {
     160           0 :     ClearView();
     161           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
     162             : 
     163           0 :     if(pChanges!=NULL)
     164             :     {
     165           0 :         Link aLink;
     166           0 :         pChanges->SetModifiedLink(aLink);
     167             :     }
     168             : 
     169           0 :     delete m_pAcceptChgCtr;
     170           0 : }
     171             : 
     172           0 : void ScAcceptChgDlg::ReInit(ScViewData* ptrViewData)
     173             : {
     174           0 :     pViewData=ptrViewData;
     175           0 :     if(pViewData!=NULL)
     176           0 :         pDoc=ptrViewData->GetDocument();
     177             :     else
     178           0 :         pDoc=NULL;
     179             : 
     180           0 :     bNoSelection=false;
     181           0 :     bNeedsUpdate=false;
     182           0 :     bIgnoreMsg=false;
     183           0 :     nAcceptCount=0;
     184           0 :     nRejectCount=0;
     185           0 :     bAcceptEnableFlag=true;
     186           0 :     bRejectEnableFlag=true;
     187             : 
     188             :     //  don't call Init here (switching between views), just set link below
     189             :     //  (dialog is just hidden, not deleted anymore, when switching views)
     190           0 :     ClearView();
     191           0 :     UpdateView();
     192             : 
     193           0 :     if ( pDoc )
     194             :     {
     195           0 :         ScChangeTrack* pChanges = pDoc->GetChangeTrack();
     196           0 :         if ( pChanges )
     197           0 :             pChanges->SetModifiedLink( LINK( this, ScAcceptChgDlg, ChgTrackModHdl ) );
     198             :     }
     199           0 : }
     200             : 
     201           0 : void ScAcceptChgDlg::Init()
     202             : {
     203           0 :     ScRange aRange;
     204             : 
     205             :     OSL_ENSURE( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
     206             : 
     207           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
     208             : 
     209           0 :     if(pChanges!=NULL)
     210             :     {
     211           0 :         pChanges->SetModifiedLink( LINK( this, ScAcceptChgDlg,ChgTrackModHdl));
     212           0 :         aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser());
     213           0 :         pTPFilter->ClearAuthors();
     214           0 :         const std::set<OUString>& rUserColl = pChanges->GetUserCollection();
     215           0 :         std::set<OUString>::const_iterator it = rUserColl.begin(), itEnd = rUserColl.end();
     216           0 :         for (; it != itEnd; ++it)
     217           0 :             pTPFilter->InsertAuthor(*it);
     218             :     }
     219             : 
     220           0 :     ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings();
     221           0 :     if ( pViewSettings!=NULL )
     222           0 :         aChangeViewSet = *pViewSettings;
     223             :     // adjust TimeField for filter tabpage
     224           0 :     aChangeViewSet.AdjustDateMode( *pDoc );
     225             : 
     226           0 :     pTPFilter->CheckDate(aChangeViewSet.HasDate());
     227           0 :     pTPFilter->SetFirstDate(aChangeViewSet.GetTheFirstDateTime());
     228           0 :     pTPFilter->SetFirstTime(aChangeViewSet.GetTheFirstDateTime());
     229           0 :     pTPFilter->SetLastDate(aChangeViewSet.GetTheLastDateTime());
     230           0 :     pTPFilter->SetLastTime(aChangeViewSet.GetTheLastDateTime());
     231           0 :     pTPFilter->SetDateMode((sal_uInt16)aChangeViewSet.GetTheDateMode());
     232           0 :     pTPFilter->CheckComment(aChangeViewSet.HasComment());
     233           0 :     pTPFilter->SetComment(aChangeViewSet.GetTheComment());
     234             : 
     235           0 :     pTPFilter->CheckAuthor(aChangeViewSet.HasAuthor());
     236           0 :     String aString=aChangeViewSet.GetTheAuthorToShow();
     237           0 :     if(aString.Len()!=0)
     238             :     {
     239           0 :         pTPFilter->SelectAuthor(aString);
     240           0 :         if(pTPFilter->GetSelectedAuthor()!=aString)
     241             :         {
     242           0 :             pTPFilter->InsertAuthor(aString);
     243           0 :             pTPFilter->SelectAuthor(aString);
     244             :         }
     245             :     }
     246             :     else
     247           0 :         pTPFilter->SelectedAuthorPos(0);
     248             : 
     249           0 :     pTPFilter->CheckRange(aChangeViewSet.HasRange());
     250             : 
     251           0 :     aRangeList=aChangeViewSet.GetTheRangeList();
     252             : 
     253           0 :     if( !aChangeViewSet.GetTheRangeList().empty() )
     254             :     {
     255           0 :         const ScRange* pRangeEntry = aChangeViewSet.GetTheRangeList().front();
     256           0 :         String aRefStr;
     257           0 :         pRangeEntry->Format( aRefStr, ABS_DREF3D, pDoc );
     258           0 :         pTPFilter->SetRange(aRefStr);
     259             :     }
     260             : 
     261           0 :     InitFilter();
     262           0 : }
     263             : 
     264           0 : void ScAcceptChgDlg::ClearView()
     265             : {
     266           0 :     nAcceptCount=0;
     267           0 :     nRejectCount=0;
     268           0 :     pTheView->SetUpdateMode(false);
     269             : 
     270           0 :     pTheView->Clear();
     271           0 :     pTheView->SetUpdateMode(true);
     272           0 : }
     273             : 
     274           0 : OUString* ScAcceptChgDlg::MakeTypeString(ScChangeActionType eType)
     275             : {
     276             :     OUString* pStr;
     277             : 
     278           0 :     switch(eType)
     279             :     {
     280             : 
     281           0 :         case SC_CAT_INSERT_COLS:    pStr=&aStrInsertCols;break;
     282           0 :         case SC_CAT_INSERT_ROWS:    pStr=&aStrInsertRows;break;
     283           0 :         case SC_CAT_INSERT_TABS:    pStr=&aStrInsertTabs;break;
     284           0 :         case SC_CAT_DELETE_COLS:    pStr=&aStrDeleteCols;break;
     285           0 :         case SC_CAT_DELETE_ROWS:    pStr=&aStrDeleteRows;break;
     286           0 :         case SC_CAT_DELETE_TABS:    pStr=&aStrDeleteTabs;break;
     287           0 :         case SC_CAT_MOVE:           pStr=&aStrMove;break;
     288           0 :         case SC_CAT_CONTENT:        pStr=&aStrContent;break;
     289           0 :         case SC_CAT_REJECT:         pStr=&aStrReject;break;
     290           0 :         default:                    pStr=&aUnknown;break;
     291             :     }
     292           0 :     return pStr;
     293             : }
     294             : 
     295             : 
     296           0 : bool ScAcceptChgDlg::IsValidAction(const ScChangeAction* pScChangeAction)
     297             : {
     298           0 :     if(pScChangeAction==NULL) return false;
     299             : 
     300           0 :     bool bFlag = false;
     301             : 
     302           0 :     ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
     303           0 :     String aUser=pScChangeAction->GetUser();
     304           0 :     DateTime aDateTime=pScChangeAction->GetDateTime();
     305             : 
     306           0 :     ScChangeActionType eType=pScChangeAction->GetType();
     307           0 :     OUString aDesc;
     308             : 
     309           0 :     String aComment = comphelper::string::remove(pScChangeAction->GetComment(), '\n');
     310             : 
     311           0 :     if(eType==SC_CAT_CONTENT)
     312             :     {
     313           0 :         if(!pScChangeAction->IsDialogParent())
     314           0 :             pScChangeAction->GetDescription(aDesc, pDoc, true);
     315             :     }
     316             :     else
     317           0 :         pScChangeAction->GetDescription(aDesc, pDoc, !pScChangeAction->IsMasterDelete());
     318             : 
     319           0 :     if (!aDesc.isEmpty())
     320             :     {
     321           0 :         aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
     322           0 :         aComment += String(aDesc);
     323           0 :         aComment += ')';
     324             :     }
     325             : 
     326           0 :     if(pTheView->IsValidEntry(&aUser,&aDateTime,&aComment))
     327             :     {
     328           0 :         if(pTPFilter->IsRange())
     329             :         {
     330           0 :             for ( size_t i = 0, nRanges = aRangeList.size(); i < nRanges; ++i )
     331             :             {
     332           0 :                 ScRange* pRangeEntry = aRangeList[ i ];
     333           0 :                 if (pRangeEntry->Intersects(aRef)) {
     334           0 :                     bFlag = true;
     335           0 :                     break;
     336             :                 }
     337             :             }
     338             :         }
     339             :         else
     340           0 :             bFlag=true;
     341             :     }
     342             : 
     343           0 :     return bFlag;
     344             : }
     345             : 
     346           0 : SvTreeListEntry* ScAcceptChgDlg::InsertChangeAction(
     347             :     const ScChangeAction* pScChangeAction, ScChangeActionState /*eState*/,
     348             :     SvTreeListEntry* pParent, bool bDelMaster,bool bDisabled, sal_uLong nPos)
     349             : {
     350           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
     351             : 
     352           0 :     if(pScChangeAction==NULL || pChanges==NULL) return NULL;
     353             : 
     354           0 :     SvTreeListEntry* pEntry=NULL;
     355             : 
     356           0 :     bool bFlag = false;
     357             : 
     358           0 :     ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
     359           0 :     String aUser=pScChangeAction->GetUser();
     360           0 :     DateTime aDateTime=pScChangeAction->GetDateTime();
     361             : 
     362           0 :     OUString aRefStr;
     363           0 :     ScChangeActionType eType=pScChangeAction->GetType();
     364           0 :     OUStringBuffer aBuf;
     365           0 :     OUString aDesc;
     366             : 
     367           0 :     ScRedlinData* pNewData=new ScRedlinData;
     368           0 :     pNewData->pData=(void *)pScChangeAction;
     369           0 :     pNewData->nActionNo=pScChangeAction->GetActionNumber();
     370           0 :     pNewData->bIsAcceptable=pScChangeAction->IsClickable();
     371           0 :     pNewData->bIsRejectable=pScChangeAction->IsRejectable();
     372           0 :     pNewData->bDisabled=!pNewData->bIsAcceptable || bDisabled;
     373           0 :     pNewData->aDateTime=aDateTime;
     374           0 :     pNewData->nRow  = aRef.aStart.Row();
     375           0 :     pNewData->nCol  = aRef.aStart.Col();
     376           0 :     pNewData->nTable= aRef.aStart.Tab();
     377             : 
     378           0 :     if(eType==SC_CAT_CONTENT)
     379             :     {
     380           0 :         if(pScChangeAction->IsDialogParent())
     381             :         {
     382           0 :             aBuf.append(aStrContentWithChild);
     383           0 :             pNewData->nInfo=RD_SPECIAL_VISCONTENT;
     384           0 :             pNewData->bIsRejectable=false;
     385           0 :             pNewData->bIsAcceptable=false;
     386             :         }
     387             :         else
     388             :         {
     389           0 :             aBuf.append(*MakeTypeString(eType));
     390           0 :             pScChangeAction->GetDescription( aDesc, pDoc, true);
     391             :         }
     392             :     }
     393             :     else
     394             :     {
     395           0 :         aBuf.append(aStrContentWithChild);
     396             : 
     397           0 :         if(bDelMaster)
     398             :         {
     399           0 :             pScChangeAction->GetDescription( aDesc, pDoc,true);
     400           0 :             pNewData->bDisabled=true;
     401           0 :             pNewData->bIsRejectable=false;
     402             :         }
     403             :         else
     404           0 :             pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
     405             : 
     406             :     }
     407             : 
     408           0 :     pScChangeAction->GetRefString(aRefStr, pDoc, true);
     409             : 
     410           0 :     aBuf.append(sal_Unicode('\t'));
     411           0 :     aBuf.append(aRefStr);
     412           0 :     aBuf.append(sal_Unicode('\t'));
     413             : 
     414           0 :     bool bIsGenerated = false;
     415             : 
     416           0 :     if(!pChanges->IsGenerated(pScChangeAction->GetActionNumber()))
     417             :     {
     418           0 :         aBuf.append(aUser);
     419           0 :         aBuf.append(sal_Unicode('\t'));
     420           0 :         aBuf.append(ScGlobal::pLocaleData->getDate(aDateTime));
     421           0 :         aBuf.append(sal_Unicode(' '));
     422           0 :         aBuf.append(ScGlobal::pLocaleData->getTime(aDateTime));
     423           0 :         aBuf.append(sal_Unicode('\t'));
     424             : 
     425           0 :         bIsGenerated = false;
     426             :     }
     427             :     else
     428             :     {
     429           0 :         aBuf.append(sal_Unicode('\t'));
     430           0 :         aBuf.append(sal_Unicode('\t'));
     431           0 :         bIsGenerated = true;
     432             :     }
     433             : 
     434           0 :     String aComment = comphelper::string::remove(pScChangeAction->GetComment(), '\n');
     435             : 
     436           0 :     if (!aDesc.isEmpty())
     437             :     {
     438           0 :         aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
     439           0 :         aComment += String(aDesc);
     440           0 :         aComment += ')';
     441             :     }
     442             : 
     443           0 :     aBuf.append(aComment);
     444             : 
     445           0 :     if(pTheView->IsValidEntry(&aUser,&aDateTime)|| bIsGenerated)
     446             :     {
     447           0 :         if(pTheView->IsValidComment(&aComment))
     448             :         {
     449           0 :             if(pTPFilter->IsRange())
     450             :             {
     451           0 :                 for ( size_t i = 0, nRanges = aRangeList.size(); i < nRanges; ++i )
     452             :                 {
     453           0 :                     ScRange* pRangeEntry = aRangeList[ i ];
     454           0 :                     if( pRangeEntry->Intersects(aRef) )
     455             :                     {
     456           0 :                         bHasFilterEntry=true;
     457           0 :                         bFlag=true;
     458           0 :                         break;
     459             :                     }
     460             :                 }
     461             :             }
     462           0 :             else if(!bIsGenerated)
     463             :             {
     464           0 :                 bHasFilterEntry=true;
     465           0 :                 bFlag=true;
     466             :             }
     467             :         }
     468             :     }
     469             : 
     470           0 :     if(!bFlag&& bUseColor&& pParent==NULL)
     471             :     {
     472             :         pEntry = pTheView->InsertEntry(
     473           0 :             aBuf.makeStringAndClear() ,pNewData, Color(COL_LIGHTBLUE), pParent, nPos);
     474             :     }
     475           0 :     else if(bFlag&& bUseColor&& pParent!=NULL)
     476             :     {
     477             :         pEntry = pTheView->InsertEntry(
     478           0 :             aBuf.makeStringAndClear(), pNewData, Color(COL_GREEN), pParent, nPos);
     479           0 :         SvTreeListEntry* pExpEntry=pParent;
     480             : 
     481           0 :         while(pExpEntry!=NULL && !pTheView->IsExpanded(pExpEntry))
     482             :         {
     483           0 :             SvTreeListEntry* pTmpEntry=pTheView->GetParent(pExpEntry);
     484             : 
     485           0 :             if(pTmpEntry!=NULL) pTheView->Expand(pExpEntry);
     486             : 
     487           0 :             pExpEntry=pTmpEntry;
     488           0 :         }
     489             :     }
     490             :     else
     491             :     {
     492             :         pEntry = pTheView->InsertEntry(
     493           0 :             aBuf.makeStringAndClear(), pNewData, pParent, nPos);
     494             :     }
     495           0 :     return pEntry;
     496             : }
     497             : 
     498           0 : SvTreeListEntry* ScAcceptChgDlg::InsertFilteredAction(
     499             :     const ScChangeAction* pScChangeAction, ScChangeActionState eState,
     500             :     SvTreeListEntry* pParent, bool bDelMaster, bool bDisabled, sal_uLong nPos)
     501             : {
     502             : 
     503           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
     504             : 
     505           0 :     if(pScChangeAction==NULL || pChanges==NULL) return NULL;
     506             : 
     507           0 :     bool bIsGenerated = pChanges->IsGenerated(pScChangeAction->GetActionNumber());
     508             : 
     509           0 :     SvTreeListEntry* pEntry=NULL;
     510             : 
     511           0 :     bool bFlag = false;
     512             : 
     513           0 :     ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
     514           0 :     String aUser=pScChangeAction->GetUser();
     515           0 :     DateTime aDateTime=pScChangeAction->GetDateTime();
     516             : 
     517           0 :     if(pTheView->IsValidEntry(&aUser,&aDateTime)||bIsGenerated)
     518             :     {
     519           0 :         if(pTPFilter->IsRange())
     520             :         {
     521           0 :             for ( size_t i = 0, nRanges = aRangeList.size(); i < nRanges; ++i )
     522             :             {
     523           0 :                 ScRange* pRangeEntry=aRangeList[ i ];
     524           0 :                 if( pRangeEntry->Intersects(aRef) )
     525             :                 {
     526           0 :                     if( pScChangeAction->GetState()==eState )
     527           0 :                         bFlag = true;
     528           0 :                     break;
     529             :                 }
     530             :             }
     531             :         }
     532           0 :         else if(pScChangeAction->GetState()==eState && !bIsGenerated)
     533           0 :             bFlag = true;
     534             :     }
     535             : 
     536           0 :     if(bFlag)
     537             :     {
     538             : 
     539           0 :         OUString aRefStr;
     540           0 :         ScChangeActionType eType=pScChangeAction->GetType();
     541           0 :         String aString;
     542           0 :         OUString aDesc;
     543             : 
     544           0 :         ScRedlinData* pNewData=new ScRedlinData;
     545           0 :         pNewData->pData=(void *)pScChangeAction;
     546           0 :         pNewData->nActionNo=pScChangeAction->GetActionNumber();
     547           0 :         pNewData->bIsAcceptable=pScChangeAction->IsClickable();
     548           0 :         pNewData->bIsRejectable=pScChangeAction->IsRejectable();
     549           0 :         pNewData->bDisabled=!pNewData->bIsAcceptable || bDisabled;
     550           0 :         pNewData->aDateTime=aDateTime;
     551           0 :         pNewData->nRow  = aRef.aStart.Row();
     552           0 :         pNewData->nCol  = aRef.aStart.Col();
     553           0 :         pNewData->nTable= aRef.aStart.Tab();
     554             : 
     555           0 :         if(eType==SC_CAT_CONTENT)
     556             :         {
     557           0 :             if(pScChangeAction->IsDialogParent())
     558             :             {
     559           0 :                 aString=aStrContentWithChild;
     560           0 :                 pNewData->nInfo=RD_SPECIAL_VISCONTENT;
     561           0 :                 pNewData->bIsRejectable=false;
     562           0 :                 pNewData->bIsAcceptable=false;
     563             :             }
     564             :             else
     565             :             {
     566           0 :                 aString=*MakeTypeString(eType);
     567           0 :                 pScChangeAction->GetDescription( aDesc, pDoc, true);
     568             :             }
     569             :         }
     570             :         else
     571             :         {
     572           0 :             aString=*MakeTypeString(eType);
     573             : 
     574           0 :             if(bDelMaster)
     575             :             {
     576           0 :                 pScChangeAction->GetDescription( aDesc, pDoc,true);
     577           0 :                 pNewData->bDisabled=true;
     578           0 :                 pNewData->bIsRejectable=false;
     579             :             }
     580             :             else
     581           0 :                 pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
     582             : 
     583             :         }
     584             : 
     585           0 :         aString+='\t';
     586           0 :         pScChangeAction->GetRefString(aRefStr, pDoc, true);
     587           0 :         aString+=aRefStr;
     588           0 :         aString+='\t';
     589             : 
     590           0 :         if(!bIsGenerated)
     591             :         {
     592           0 :             aString+=aUser;
     593           0 :             aString+='\t';
     594           0 :             aString+=ScGlobal::pLocaleData->getDate(aDateTime);
     595           0 :             aString+=' ';
     596           0 :             aString+=ScGlobal::pLocaleData->getTime(aDateTime);
     597           0 :             aString+='\t';
     598             :         }
     599             :         else
     600             :         {
     601           0 :             aString+='\t';
     602           0 :             aString+='\t';
     603             :         }
     604             : 
     605           0 :         String aComment = comphelper::string::remove(pScChangeAction->GetComment(), '\n');
     606             : 
     607           0 :         if (!aDesc.isEmpty())
     608             :         {
     609           0 :             aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
     610           0 :             aComment += String(aDesc);
     611           0 :             aComment += ')';
     612             :         }
     613           0 :         if(pTheView->IsValidComment(&aComment))
     614             :         {
     615           0 :             aString+=aComment;
     616           0 :             pEntry=pTheView->InsertEntry(aString,pNewData,pParent,nPos);
     617             :         }
     618             :         else
     619           0 :             delete pNewData;
     620             :     }
     621           0 :     return pEntry;
     622             : }
     623             : 
     624           0 : SvTreeListEntry* ScAcceptChgDlg::InsertChangeActionContent(const ScChangeActionContent* pScChangeAction,
     625             :                                                           SvTreeListEntry* pParent, sal_uLong nSpecial)
     626             : {
     627           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
     628           0 :     SvTreeListEntry* pEntry=NULL;
     629             : 
     630           0 :     if(pScChangeAction==NULL || pChanges==NULL) return NULL;
     631             : 
     632           0 :     bool bIsGenerated = pChanges->IsGenerated(pScChangeAction->GetActionNumber());
     633             : 
     634           0 :     bool bFlag = false;
     635             : 
     636           0 :     ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
     637           0 :     String aUser=pScChangeAction->GetUser();
     638           0 :     DateTime aDateTime=pScChangeAction->GetDateTime();
     639             : 
     640           0 :     if(pTheView->IsValidEntry(&aUser,&aDateTime)||bIsGenerated)
     641             :     {
     642           0 :         if(pTPFilter->IsRange())
     643             :         {
     644           0 :             for ( size_t i = 0, nRanges = aRangeList.size(); i < nRanges; ++i )
     645             :             {
     646           0 :                 ScRange* pRangeEntry = aRangeList[ i ];
     647           0 :                 if( pRangeEntry->Intersects(aRef) )
     648             :                 {
     649           0 :                     bFlag=true;
     650           0 :                     break;
     651             :                 }
     652             :             }
     653             :         }
     654           0 :         else if(!bIsGenerated)
     655           0 :             bFlag=true;
     656             :     }
     657             : 
     658           0 :     OUString aRefStr;
     659           0 :     String aString;
     660           0 :     String a2String;
     661           0 :     String aDesc;
     662             : 
     663           0 :     if(nSpecial==RD_SPECIAL_CONTENT)
     664             :     {
     665           0 :         OUString aTmp;
     666           0 :         pScChangeAction->GetOldString(aTmp);
     667           0 :         a2String = aTmp;
     668           0 :         if(a2String.Len()==0) a2String=aStrEmpty;
     669             : 
     670             :         //aString+="\'";
     671           0 :         aString+=a2String;
     672             :         //aString+="\'";
     673             : 
     674           0 :         aDesc=aStrChildOrgContent;
     675           0 :         aDesc.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
     676             :     }
     677             :     else
     678             :     {
     679           0 :         OUString aTmp;
     680           0 :         pScChangeAction->GetNewString(aTmp);
     681           0 :         a2String = aTmp;
     682           0 :         if(a2String.Len()==0)
     683             :         {
     684           0 :             a2String=aStrEmpty;
     685           0 :             aString+=a2String;
     686             :         }
     687             :         else
     688             :         {
     689           0 :             aString+='\'';
     690           0 :             aString+=a2String;
     691           0 :             aString+='\'';
     692           0 :             a2String=aString;
     693             :         }
     694           0 :         aDesc=aStrChildContent;
     695             : 
     696             :     }
     697             : 
     698           0 :     aDesc+=a2String;
     699           0 :     aString+='\t';
     700           0 :     pScChangeAction->GetRefString(aRefStr, pDoc, true);
     701           0 :     aString+=aRefStr;
     702           0 :     aString+='\t';
     703             : 
     704           0 :     if(!bIsGenerated)
     705             :     {
     706           0 :         aString+=aUser;
     707           0 :         aString+='\t';
     708             : 
     709           0 :         aString+=ScGlobal::pLocaleData->getDate(aDateTime);
     710           0 :         aString+=' ';
     711           0 :         aString+=ScGlobal::pLocaleData->getTime(aDateTime);
     712           0 :         aString+='\t';
     713             :     }
     714             :     else
     715             :     {
     716           0 :         aString+='\t';
     717           0 :         aString+='\t';
     718             :     }
     719             : 
     720           0 :     String aComment = comphelper::string::remove(pScChangeAction->GetComment(), '\n');
     721             : 
     722           0 :     if(aDesc.Len()>0)
     723             :     {
     724           0 :         aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
     725           0 :         aComment+=aDesc;
     726           0 :         aComment+=')';
     727             :     }
     728             : 
     729           0 :     aString+=aComment;
     730             : 
     731           0 :     ScRedlinData* pNewData=new ScRedlinData;
     732           0 :     pNewData->nInfo=nSpecial;
     733           0 :     pNewData->pData=(void *)pScChangeAction;
     734           0 :     pNewData->nActionNo=pScChangeAction->GetActionNumber();
     735           0 :     pNewData->bIsAcceptable=pScChangeAction->IsClickable();
     736           0 :     pNewData->bIsRejectable=false;
     737           0 :     pNewData->bDisabled=!pNewData->bIsAcceptable;
     738           0 :     pNewData->aDateTime=aDateTime;
     739           0 :     pNewData->nRow  = aRef.aStart.Row();
     740           0 :     pNewData->nCol  = aRef.aStart.Col();
     741           0 :     pNewData->nTable= aRef.aStart.Tab();
     742             : 
     743           0 :     if(pTheView->IsValidComment(&aComment) && bFlag)
     744             :     {
     745           0 :         bHasFilterEntry=true;
     746           0 :         pEntry=pTheView->InsertEntry(aString,pNewData,pParent);
     747             :     }
     748             :     else
     749           0 :         pEntry=pTheView->InsertEntry(aString,pNewData,Color(COL_LIGHTBLUE),pParent);
     750           0 :     return pEntry;
     751             : }
     752             : 
     753           0 : long ScAcceptChgDlg::PreNotify( NotifyEvent& rNEvt )
     754             : {
     755           0 :     if(rNEvt.GetType()==EVENT_GETFOCUS && bNeedsUpdate)
     756             :     {
     757           0 :         ClearView();
     758           0 :         UpdateView();
     759           0 :         bNoSelection=false;
     760             :     }
     761             : 
     762           0 :     return SfxModelessDialog::PreNotify(rNEvt);
     763             : }
     764             : 
     765             : 
     766           0 : void ScAcceptChgDlg::UpdateView()
     767             : {
     768           0 :     bNeedsUpdate=false;
     769           0 :     SvTreeListEntry* pParent=NULL;
     770           0 :     ScChangeTrack* pChanges=NULL;
     771           0 :     const ScChangeAction* pScChangeAction=NULL;
     772           0 :     bAcceptEnableFlag=true;
     773           0 :     bRejectEnableFlag=true;
     774           0 :     SetPointer(Pointer(POINTER_WAIT));
     775           0 :     pTheView->SetUpdateMode(false);
     776           0 :     bool bFilterFlag = pTPFilter->IsDate() || pTPFilter->IsRange() ||
     777           0 :         pTPFilter->IsAuthor() || pTPFilter->IsComment();
     778             : 
     779           0 :     bUseColor = bFilterFlag;
     780             : 
     781           0 :     if(pDoc!=NULL)
     782             :     {
     783           0 :         pChanges=pDoc->GetChangeTrack();
     784           0 :         if(pChanges!=NULL)
     785           0 :             pScChangeAction=pChanges->GetFirst();
     786             :     }
     787           0 :     bool bTheFlag = false;
     788             : 
     789           0 :     while(pScChangeAction!=NULL)
     790             :     {
     791           0 :         bHasFilterEntry=false;
     792           0 :         switch(pScChangeAction->GetState())
     793             :         {
     794             :             case SC_CAS_VIRGIN:
     795             : 
     796           0 :                 if(pScChangeAction->IsDialogRoot())
     797             :                 {
     798           0 :                     if(pScChangeAction->IsDialogParent())
     799           0 :                         pParent=InsertChangeAction(pScChangeAction,SC_CAS_VIRGIN);
     800             :                     else
     801           0 :                         pParent=InsertFilteredAction(pScChangeAction,SC_CAS_VIRGIN);
     802             :                 }
     803             :                 else
     804           0 :                     pParent=NULL;
     805             : 
     806           0 :                 bTheFlag=true;
     807           0 :                 break;
     808             : 
     809             :             case SC_CAS_ACCEPTED:
     810           0 :                 pParent=NULL;
     811           0 :                 nAcceptCount++;
     812           0 :                 break;
     813             : 
     814             :             case SC_CAS_REJECTED:
     815           0 :                 pParent=NULL;
     816           0 :                 nRejectCount++;
     817           0 :                 break;
     818             :         }
     819             : 
     820           0 :         if(pParent!=NULL && pScChangeAction->IsDialogParent())
     821             :         {
     822           0 :             if(!bFilterFlag)
     823           0 :                 pParent->EnableChildrenOnDemand(true);
     824             :             else
     825             :             {
     826           0 :                 bool bTestFlag = bHasFilterEntry;
     827           0 :                 bHasFilterEntry=false;
     828           0 :                 if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag)
     829           0 :                     pTheView->RemoveEntry(pParent);
     830             :             }
     831             :         }
     832             : 
     833           0 :         pScChangeAction=pScChangeAction->GetNext();
     834             :     }
     835             : 
     836           0 :     if( bTheFlag && (!pDoc->IsDocEditable() || pChanges->IsProtected()) )
     837           0 :         bTheFlag=false;
     838             : 
     839           0 :     pTPView->EnableAccept(bTheFlag);
     840           0 :     pTPView->EnableAcceptAll(bTheFlag);
     841           0 :     pTPView->EnableReject(bTheFlag);
     842           0 :     pTPView->EnableRejectAll(bTheFlag);
     843             : 
     844           0 :     if(nAcceptCount>0)
     845             :     {
     846             :         pParent=pTheView->InsertEntry(
     847             :             aStrAllAccepted, static_cast< RedlinData * >(NULL),
     848           0 :             static_cast< SvTreeListEntry * >(NULL));
     849           0 :         pParent->EnableChildrenOnDemand(true);
     850             :     }
     851           0 :     if(nRejectCount>0)
     852             :     {
     853             :         pParent=pTheView->InsertEntry(
     854             :             aStrAllRejected, static_cast< RedlinData * >(NULL),
     855           0 :             static_cast< SvTreeListEntry * >(NULL));
     856           0 :         pParent->EnableChildrenOnDemand(true);
     857             :     }
     858           0 :     pTheView->SetUpdateMode(true);
     859           0 :     SetPointer(Pointer(POINTER_ARROW));
     860           0 :     SvTreeListEntry* pEntry=pTheView->First();
     861           0 :     if(pEntry!=NULL)
     862           0 :         pTheView->Select(pEntry);
     863           0 : }
     864             : 
     865           0 : IMPL_LINK_NOARG(ScAcceptChgDlg, RefHandle)
     866             : {
     867           0 :     sal_uInt16 nId  =ScSimpleRefDlgWrapper::GetChildWindowId();
     868             : 
     869           0 :     ScSimpleRefDlgWrapper::SetDefaultPosSize(GetPosPixel(),GetSizePixel(),true);
     870             : 
     871           0 :     SC_MOD()->SetRefDialog( nId, true );
     872             : 
     873           0 :     SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
     874           0 :     ScSimpleRefDlgWrapper* pWnd =(ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
     875             : 
     876           0 :     if(pWnd!=NULL)
     877             :     {
     878           0 :         sal_uInt16 nAcceptId=ScAcceptChgDlgWrapper::GetChildWindowId();
     879           0 :         pViewFrm->ShowChildWindow(nAcceptId,false);
     880           0 :         pWnd->SetCloseHdl(LINK( this, ScAcceptChgDlg,RefInfoHandle));
     881           0 :         pWnd->SetRefString(pTPFilter->GetRange());
     882           0 :         pWnd->SetAutoReOpen(false);
     883           0 :         Window* pWin=pWnd->GetWindow();
     884           0 :         pWin->SetPosSizePixel(GetPosPixel(),GetSizePixel());
     885           0 :         Hide();
     886           0 :         pWin->SetText(GetText());
     887           0 :         pWnd->StartRefInput();
     888             :     }
     889           0 :     return 0;
     890             : }
     891             : 
     892           0 : IMPL_LINK( ScAcceptChgDlg, RefInfoHandle, String*, pResult)
     893             : {
     894             :     sal_uInt16 nId;
     895             : 
     896           0 :     ScSimpleRefDlgWrapper::SetAutoReOpen(true);
     897             : 
     898           0 :     SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
     899           0 :     if(pResult!=NULL)
     900             :     {
     901           0 :         pTPFilter->SetRange(*pResult);
     902           0 :         FilterHandle(pTPFilter);
     903             : 
     904           0 :         nId = ScSimpleRefDlgWrapper::GetChildWindowId();
     905           0 :         ScSimpleRefDlgWrapper* pWnd = (ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
     906             : 
     907           0 :         if(pWnd!=NULL)
     908             :         {
     909           0 :             Window* pWin=pWnd->GetWindow();
     910           0 :             Size aWinSize=pWin->GetSizePixel();
     911           0 :             aWinSize.Width()=GetSizePixel().Width();
     912           0 :             SetPosSizePixel(pWin->GetPosPixel(),aWinSize);
     913           0 :             Invalidate();
     914             :         }
     915           0 :         nId = ScAcceptChgDlgWrapper::GetChildWindowId();
     916           0 :         pViewFrm->ShowChildWindow( nId, true );
     917             :     }
     918             :     else
     919             :     {
     920           0 :         nId = ScAcceptChgDlgWrapper::GetChildWindowId();
     921           0 :         pViewFrm->SetChildWindow( nId, false );
     922             :     }
     923           0 :     return 0;
     924             : }
     925             : 
     926           0 : IMPL_LINK( ScAcceptChgDlg, FilterHandle, SvxTPFilter*, pRef )
     927             : {
     928           0 :     if(pRef!=NULL)
     929             :     {
     930           0 :         ClearView();
     931           0 :         aRangeList.RemoveAll();
     932           0 :         aRangeList.Parse(pTPFilter->GetRange(),pDoc);
     933           0 :         UpdateView();
     934             :     }
     935           0 :     return 0;
     936             : }
     937             : 
     938           0 : IMPL_LINK( ScAcceptChgDlg, RejectHandle, SvxTPView*, pRef )
     939             : {
     940           0 :     SetPointer(Pointer(POINTER_WAIT));
     941             : 
     942           0 :     bIgnoreMsg=true;
     943           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
     944             : 
     945           0 :     if(pRef!=NULL)
     946             :     {
     947           0 :         SvTreeListEntry* pEntry=pTheView->FirstSelected();
     948           0 :         while(pEntry!=NULL)
     949             :         {
     950           0 :             ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
     951           0 :             if(pEntryData!=NULL)
     952             :             {
     953             :                 ScChangeAction* pScChangeAction=
     954           0 :                         (ScChangeAction*) pEntryData->pData;
     955             : 
     956           0 :                 if(pScChangeAction->GetType()==SC_CAT_INSERT_TABS)
     957           0 :                     pViewData->SetTabNo(0);
     958             : 
     959           0 :                 pChanges->Reject(pScChangeAction);
     960             :             }
     961           0 :             pEntry = pTheView->NextSelected(pEntry);
     962             :         }
     963           0 :         ScDocShell* pDocSh=pViewData->GetDocShell();
     964           0 :         pDocSh->PostPaintExtras();
     965           0 :         pDocSh->PostPaintGridAll();
     966           0 :         pDocSh->GetUndoManager()->Clear();
     967           0 :         pDocSh->SetDocumentModified();
     968           0 :         ClearView();
     969           0 :         UpdateView();
     970             :     }
     971           0 :     SetPointer(Pointer(POINTER_ARROW));
     972             : 
     973           0 :     bIgnoreMsg=false;
     974           0 :     return 0;
     975             : }
     976           0 : IMPL_LINK( ScAcceptChgDlg, AcceptHandle, SvxTPView*, pRef )
     977             : {
     978           0 :     SetPointer(Pointer(POINTER_WAIT));
     979             : 
     980           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
     981           0 :     bIgnoreMsg=true;
     982           0 :     if(pRef!=NULL)
     983             :     {
     984           0 :         SvTreeListEntry* pEntry=pTheView->FirstSelected();
     985           0 :         while(pEntry!=NULL)
     986             :         {
     987           0 :             ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
     988           0 :             if(pEntryData!=NULL)
     989             :             {
     990             :                 ScChangeAction* pScChangeAction=
     991           0 :                         (ScChangeAction*) pEntryData->pData;
     992           0 :                 if(pScChangeAction->GetType()==SC_CAT_CONTENT)
     993             :                 {
     994           0 :                     if(pEntryData->nInfo==RD_SPECIAL_CONTENT)
     995           0 :                         pChanges->SelectContent(pScChangeAction,true);
     996             :                     else
     997           0 :                         pChanges->SelectContent(pScChangeAction);
     998             :                 }
     999             :                 else
    1000           0 :                     pChanges->Accept(pScChangeAction);
    1001             :             }
    1002           0 :             pEntry = pTheView->NextSelected(pEntry);
    1003             :         }
    1004           0 :         ScDocShell* pDocSh=pViewData->GetDocShell();
    1005           0 :         pDocSh->PostPaintExtras();
    1006           0 :         pDocSh->PostPaintGridAll();
    1007           0 :         pDocSh->SetDocumentModified();
    1008           0 :         ClearView();
    1009           0 :         UpdateView();
    1010             :     }
    1011           0 :     bIgnoreMsg=false;
    1012             : 
    1013           0 :     return 0;
    1014             : }
    1015             : 
    1016           0 : void ScAcceptChgDlg::RejectFiltered()
    1017             : {
    1018           0 :     if(pDoc==NULL) return;
    1019           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
    1020           0 :     const ScChangeAction* pScChangeAction=NULL;
    1021             : 
    1022           0 :     if(pChanges!=NULL)
    1023             :     {
    1024           0 :         pScChangeAction=pChanges->GetLast();
    1025             :     }
    1026             : 
    1027           0 :     while(pScChangeAction!=NULL)
    1028             :     {
    1029           0 :         if(pScChangeAction->IsDialogRoot())
    1030           0 :             if(IsValidAction(pScChangeAction))
    1031           0 :                 pChanges->Reject((ScChangeAction*)pScChangeAction);
    1032             : 
    1033           0 :         pScChangeAction=pScChangeAction->GetPrev();
    1034             :     }
    1035             : }
    1036           0 : void ScAcceptChgDlg::AcceptFiltered()
    1037             : {
    1038           0 :     if(pDoc==NULL) return;
    1039           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
    1040           0 :     const ScChangeAction* pScChangeAction=NULL;
    1041             : 
    1042           0 :     if(pChanges!=NULL)
    1043           0 :         pScChangeAction=pChanges->GetLast();
    1044             : 
    1045           0 :     while(pScChangeAction!=NULL)
    1046             :     {
    1047           0 :         if(pScChangeAction->IsDialogRoot())
    1048           0 :             if(IsValidAction(pScChangeAction))
    1049           0 :                 pChanges->Accept((ScChangeAction*)pScChangeAction);
    1050             : 
    1051           0 :         pScChangeAction=pScChangeAction->GetPrev();
    1052             :     }
    1053             : }
    1054             : 
    1055           0 : IMPL_LINK_NOARG(ScAcceptChgDlg, RejectAllHandle)
    1056             : {
    1057           0 :     SetPointer(Pointer(POINTER_WAIT));
    1058           0 :     bIgnoreMsg=true;
    1059           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
    1060           0 :     if(pChanges!=NULL)
    1061             :     {
    1062           0 :         if(pTPFilter->IsDate()||pTPFilter->IsAuthor()||pTPFilter->IsRange()||pTPFilter->IsComment())
    1063           0 :             RejectFiltered();
    1064             :         else
    1065           0 :             pChanges->RejectAll();
    1066             : 
    1067           0 :         pViewData->SetTabNo(0);
    1068             : 
    1069           0 :         ScDocShell* pDocSh=pViewData->GetDocShell();
    1070           0 :         pDocSh->PostPaintExtras();
    1071           0 :         pDocSh->PostPaintGridAll();
    1072           0 :         pDocSh->GetUndoManager()->Clear();
    1073           0 :         pDocSh->SetDocumentModified();
    1074           0 :         ClearView();
    1075           0 :         UpdateView();
    1076             :     }
    1077           0 :     SetPointer(Pointer(POINTER_ARROW));
    1078             : 
    1079           0 :     bIgnoreMsg=false;
    1080             : 
    1081           0 :     return 0;
    1082             : }
    1083             : 
    1084           0 : IMPL_LINK_NOARG(ScAcceptChgDlg, AcceptAllHandle)
    1085             : {
    1086           0 :     SetPointer(Pointer(POINTER_WAIT));
    1087             : 
    1088           0 :     bIgnoreMsg=true;
    1089           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
    1090           0 :     if(pChanges!=NULL)
    1091             :     {
    1092           0 :         if(pTPFilter->IsDate()||pTPFilter->IsAuthor()||pTPFilter->IsRange()||pTPFilter->IsComment())
    1093           0 :             AcceptFiltered();
    1094             :         else
    1095           0 :             pChanges->AcceptAll();
    1096             : 
    1097           0 :         ScDocShell* pDocSh=pViewData->GetDocShell();
    1098           0 :         pDocSh->PostPaintExtras();
    1099           0 :         pDocSh->PostPaintGridAll();
    1100           0 :         pDocSh->SetDocumentModified();
    1101           0 :         ClearView();
    1102           0 :         UpdateView();
    1103             :     }
    1104           0 :     bIgnoreMsg=false;
    1105           0 :     SetPointer(Pointer(POINTER_ARROW));
    1106             : 
    1107           0 :     return 0;
    1108             : }
    1109             : 
    1110           0 : IMPL_LINK_NOARG(ScAcceptChgDlg, SelectHandle)
    1111             : {
    1112           0 :     if(!bNoSelection)
    1113           0 :         aSelectionTimer.Start();
    1114             : 
    1115           0 :     bNoSelection=false;
    1116           0 :     return 0;
    1117             : }
    1118             : 
    1119           0 : void ScAcceptChgDlg::GetDependents(  const ScChangeAction* pScChangeAction,
    1120             :                                     ScChangeActionMap& aActionMap,
    1121             :                                     SvTreeListEntry* pEntry)
    1122             : {
    1123           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
    1124             : 
    1125           0 :     SvTreeListEntry* pParent=pTheView->GetParent(pEntry);
    1126           0 :     if(pParent!=NULL)
    1127             :     {
    1128           0 :         ScRedlinData *pParentData=(ScRedlinData *)(pParent->GetUserData());
    1129           0 :         ScChangeAction* pParentAction=(ScChangeAction*) pParentData->pData;
    1130             : 
    1131           0 :         if(pParentAction!=pScChangeAction)
    1132             :             pChanges->GetDependents((ScChangeAction*) pScChangeAction,
    1133           0 :                         aActionMap,pScChangeAction->IsMasterDelete());
    1134             :         else
    1135             :             pChanges->GetDependents( (ScChangeAction*) pScChangeAction,
    1136           0 :                         aActionMap );
    1137             :     }
    1138             :     else
    1139             :         pChanges->GetDependents((ScChangeAction*) pScChangeAction,
    1140           0 :                     aActionMap, pScChangeAction->IsMasterDelete() );
    1141           0 : }
    1142             : 
    1143           0 : bool ScAcceptChgDlg::InsertContentChildren(ScChangeActionMap* pActionMap,SvTreeListEntry* pParent)
    1144             : {
    1145           0 :     bool bTheTestFlag = true;
    1146           0 :     ScRedlinData *pEntryData=(ScRedlinData *)(pParent->GetUserData());
    1147           0 :     const ScChangeAction* pScChangeAction = (ScChangeAction*) pEntryData->pData;
    1148           0 :     bool bParentInserted = false;
    1149             :     // If the parent is a MatrixOrigin then place it in the right order before
    1150             :     // the MatrixReferences. Also if it is the first content change at this
    1151             :     // position don't insert the first dependent MatrixReference as the special
    1152             :     // content (original value) but insert the predecessor of the MatrixOrigin
    1153             :     // itself instead.
    1154           0 :     if ( pScChangeAction->GetType() == SC_CAT_CONTENT &&
    1155           0 :             ((const ScChangeActionContent*)pScChangeAction)->IsMatrixOrigin() )
    1156             :     {
    1157           0 :         pActionMap->insert( ::std::make_pair( pScChangeAction->GetActionNumber(),
    1158           0 :             const_cast<ScChangeAction*>( pScChangeAction ) ) );
    1159           0 :         bParentInserted = true;
    1160             :     }
    1161           0 :     SvTreeListEntry* pEntry=NULL;
    1162             : 
    1163           0 :     ScChangeActionMap::iterator itChangeAction = pActionMap->begin();
    1164           0 :     while( itChangeAction != pActionMap->end() )
    1165             :     {
    1166           0 :         if( itChangeAction->second->GetState()==SC_CAS_VIRGIN )
    1167           0 :             break;
    1168           0 :         ++itChangeAction;
    1169             :     }
    1170             : 
    1171           0 :     if( itChangeAction == pActionMap->end() )
    1172           0 :         return true;
    1173             : 
    1174             :     SvTreeListEntry* pOriginal = InsertChangeActionContent(
    1175           0 :         dynamic_cast<const ScChangeActionContent*>( itChangeAction->second ),
    1176           0 :         pParent, RD_SPECIAL_CONTENT );
    1177             : 
    1178           0 :     if(pOriginal!=NULL)
    1179             :     {
    1180           0 :         bTheTestFlag=false;
    1181           0 :         ScRedlinData *pParentData=(ScRedlinData *)(pOriginal->GetUserData());
    1182           0 :         pParentData->pData=(void *)pScChangeAction;
    1183           0 :         pParentData->nActionNo=pScChangeAction->GetActionNumber();
    1184           0 :         pParentData->bIsAcceptable=pScChangeAction->IsRejectable(); // select old value
    1185           0 :         pParentData->bIsRejectable=false;
    1186           0 :         pParentData->bDisabled=false;
    1187             :     }
    1188           0 :     while( itChangeAction != pActionMap->end() )
    1189             :     {
    1190           0 :         if( itChangeAction->second->GetState() == SC_CAS_VIRGIN )
    1191             :         {
    1192           0 :             pEntry = InsertChangeActionContent( dynamic_cast<const ScChangeActionContent*>( itChangeAction->second ),
    1193           0 :                 pParent, RD_SPECIAL_NONE );
    1194             : 
    1195           0 :             if(pEntry!=NULL)
    1196           0 :                 bTheTestFlag=false;
    1197             :         }
    1198           0 :         ++itChangeAction;
    1199             :     }
    1200             : 
    1201           0 :     if ( !bParentInserted )
    1202             :     {
    1203             :         pEntry=InsertChangeActionContent((const ScChangeActionContent*)
    1204           0 :                                 pScChangeAction,pParent,RD_SPECIAL_NONE);
    1205             : 
    1206           0 :         if(pEntry!=NULL)
    1207             :         {
    1208           0 :             bTheTestFlag=false;
    1209           0 :             ScRedlinData *pParentData=(ScRedlinData *)(pEntry->GetUserData());
    1210           0 :             pParentData->pData=(void *)pScChangeAction;
    1211           0 :             pParentData->nActionNo=pScChangeAction->GetActionNumber();
    1212           0 :             pParentData->bIsAcceptable=pScChangeAction->IsClickable();
    1213           0 :             pParentData->bIsRejectable=false;
    1214           0 :             pParentData->bDisabled=false;
    1215             :         }
    1216             :     }
    1217             : 
    1218           0 :     return bTheTestFlag;
    1219             : 
    1220             : }
    1221             : 
    1222           0 : bool ScAcceptChgDlg::InsertAcceptedORejected(SvTreeListEntry* pParent)
    1223             : {
    1224           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
    1225           0 :     bool bTheTestFlag = true;
    1226             : 
    1227           0 :     ScChangeActionState eState = SC_CAS_VIRGIN;
    1228           0 :     OUString aString = pTheView->GetEntryText(pParent);
    1229           0 :     OUString a2String = aString.copy(0, aStrAllAccepted.getLength());
    1230           0 :     if (a2String.equals(aStrAllAccepted))
    1231           0 :         eState=SC_CAS_ACCEPTED;
    1232             :     else
    1233             :     {
    1234           0 :         a2String = aString.copy(0, aStrAllRejected.getLength());
    1235           0 :         if (a2String.equals(aStrAllRejected))
    1236           0 :             eState=SC_CAS_REJECTED;
    1237             :     }
    1238             : 
    1239           0 :     ScChangeAction* pScChangeAction=pChanges->GetFirst();
    1240           0 :     while(pScChangeAction!=NULL)
    1241             :     {
    1242           0 :         if(pScChangeAction->GetState()==eState &&
    1243           0 :             InsertFilteredAction(pScChangeAction,eState,pParent)!=NULL)
    1244           0 :             bTheTestFlag=false;
    1245           0 :         pScChangeAction=pScChangeAction->GetNext();
    1246             :     }
    1247           0 :     return bTheTestFlag;
    1248             : }
    1249             : 
    1250           0 : bool ScAcceptChgDlg::InsertChildren(ScChangeActionMap* pActionMap,SvTreeListEntry* pParent)
    1251             : {
    1252           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
    1253           0 :     bool bTheTestFlag = true;
    1254           0 :     SvTreeListEntry* pEntry=NULL;
    1255           0 :     ScChangeActionMap::iterator itChangeAction;
    1256             : 
    1257           0 :     for( itChangeAction = pActionMap->begin(); itChangeAction != pActionMap->end(); ++itChangeAction )
    1258             :     {
    1259           0 :         pEntry=InsertChangeAction( itChangeAction->second, SC_CAS_VIRGIN, pParent, false, true );
    1260             : 
    1261           0 :         if(pEntry!=NULL)
    1262             :         {
    1263           0 :             bTheTestFlag=false;
    1264             : 
    1265           0 :             ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
    1266           0 :             pEntryData->bIsRejectable=false;
    1267           0 :             pEntryData->bIsAcceptable=false;
    1268           0 :             pEntryData->bDisabled=true;
    1269             : 
    1270           0 :             if( itChangeAction->second->IsDialogParent() )
    1271           0 :                 Expand( pChanges, itChangeAction->second, pEntry );
    1272             :         }
    1273             :     }
    1274           0 :     return bTheTestFlag;
    1275             : }
    1276             : 
    1277           0 : bool ScAcceptChgDlg::InsertDeletedChildren(const ScChangeAction* pScChangeAction,
    1278             :                                          ScChangeActionMap* pActionMap,SvTreeListEntry* pParent)
    1279             : {
    1280           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
    1281           0 :     bool bTheTestFlag = true;
    1282           0 :     SvTreeListEntry* pEntry=NULL;
    1283           0 :     ScChangeActionMap::iterator itChangeAction;
    1284             : 
    1285           0 :     for( itChangeAction = pActionMap->begin(); itChangeAction != pActionMap->end(); ++itChangeAction )
    1286             :     {
    1287             : 
    1288           0 :         if( pScChangeAction != itChangeAction->second )
    1289           0 :             pEntry = InsertChangeAction( itChangeAction->second, SC_CAS_VIRGIN, pParent, false, true );
    1290             :         else
    1291           0 :             pEntry = InsertChangeAction( itChangeAction->second, SC_CAS_VIRGIN, pParent, true, true );
    1292             : 
    1293           0 :         if(pEntry!=NULL)
    1294             :         {
    1295           0 :             ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
    1296           0 :             pEntryData->bIsRejectable=false;
    1297           0 :             pEntryData->bIsAcceptable=false;
    1298           0 :             pEntryData->bDisabled=true;
    1299             : 
    1300           0 :             bTheTestFlag=false;
    1301             : 
    1302           0 :             if( itChangeAction->second->IsDialogParent() )
    1303           0 :                 Expand( pChanges, itChangeAction->second, pEntry );
    1304             :         }
    1305             :     }
    1306           0 :     return bTheTestFlag;
    1307             : }
    1308             : 
    1309           0 : bool ScAcceptChgDlg::Expand(
    1310             :     ScChangeTrack* pChanges, const ScChangeAction* pScChangeAction,
    1311             :     SvTreeListEntry* pEntry, bool bFilter)
    1312             : {
    1313           0 :     bool bTheTestFlag = true;
    1314             : 
    1315           0 :     if(pChanges!=NULL &&pEntry!=NULL &&pScChangeAction!=NULL)
    1316             :     {
    1317           0 :         ScChangeActionMap aActionMap;
    1318             : 
    1319           0 :         GetDependents( pScChangeAction, aActionMap, pEntry );
    1320             : 
    1321           0 :         switch(pScChangeAction->GetType())
    1322             :         {
    1323             :             case SC_CAT_CONTENT:
    1324             :             {
    1325           0 :                 InsertContentChildren( &aActionMap, pEntry );
    1326           0 :                 bTheTestFlag=!bHasFilterEntry;
    1327           0 :                 break;
    1328             :             }
    1329             :             case SC_CAT_DELETE_COLS:
    1330             :             case SC_CAT_DELETE_ROWS:
    1331             :             case SC_CAT_DELETE_TABS:
    1332             :             {
    1333           0 :                 InsertDeletedChildren( pScChangeAction, &aActionMap, pEntry );
    1334           0 :                 bTheTestFlag=!bHasFilterEntry;
    1335           0 :                 break;
    1336             :             }
    1337             :             default:
    1338             :             {
    1339           0 :                 if(!bFilter)
    1340           0 :                     bTheTestFlag = InsertChildren( &aActionMap, pEntry );
    1341           0 :                 break;
    1342             :             }
    1343             :         }
    1344           0 :         aActionMap.clear();
    1345             :     }
    1346           0 :     return bTheTestFlag;
    1347             : }
    1348             : 
    1349           0 : IMPL_LINK( ScAcceptChgDlg, ExpandingHandle, SvxRedlinTable*, pTable )
    1350             : {
    1351           0 :     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
    1352           0 :     ScChangeAction* pScChangeAction=NULL;
    1353           0 :     SetPointer(Pointer(POINTER_WAIT));
    1354           0 :     if(pTable!=NULL && pChanges!=NULL)
    1355             :     {
    1356           0 :         ScChangeActionMap aActionMap;
    1357           0 :         SvTreeListEntry* pEntry=pTheView->GetHdlEntry();
    1358           0 :         if(pEntry!=NULL)
    1359             :         {
    1360           0 :             ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
    1361           0 :             if(pEntryData!=NULL)
    1362           0 :                 pScChangeAction=(ScChangeAction*) pEntryData->pData;
    1363             : 
    1364           0 :             if(pEntry->HasChildrenOnDemand())
    1365             :             {
    1366           0 :                 bool bTheTestFlag = true;
    1367           0 :                 pEntry->EnableChildrenOnDemand(false);
    1368           0 :                 pTheView->RemoveEntry(pTheView->FirstChild(pEntry));
    1369             : 
    1370           0 :                 if(pEntryData!=NULL)
    1371             :                 {
    1372           0 :                     pScChangeAction=(ScChangeAction*) pEntryData->pData;
    1373             : 
    1374           0 :                     GetDependents( pScChangeAction, aActionMap, pEntry );
    1375             : 
    1376           0 :                     switch(pScChangeAction->GetType())
    1377             :                     {
    1378             :                         case SC_CAT_CONTENT:
    1379             :                         {
    1380           0 :                             bTheTestFlag = InsertContentChildren( &aActionMap, pEntry );
    1381           0 :                             break;
    1382             :                         }
    1383             :                         case SC_CAT_DELETE_COLS:
    1384             :                         case SC_CAT_DELETE_ROWS:
    1385             :                         case SC_CAT_DELETE_TABS:
    1386             :                         {
    1387           0 :                             bTheTestFlag = InsertDeletedChildren( pScChangeAction, &aActionMap, pEntry );
    1388           0 :                             break;
    1389             :                         }
    1390             :                         default:
    1391             :                         {
    1392           0 :                             bTheTestFlag = InsertChildren( &aActionMap, pEntry );
    1393           0 :                             break;
    1394             :                         }
    1395             :                     }
    1396           0 :                     aActionMap.clear();
    1397             : 
    1398             :                 }
    1399             :                 else
    1400             :                 {
    1401           0 :                     bTheTestFlag=InsertAcceptedORejected(pEntry);
    1402             :                 }
    1403           0 :                 if(bTheTestFlag) pTheView->InsertEntry(aStrNoEntry,NULL,Color(COL_GRAY),pEntry);
    1404             :             }
    1405             : 
    1406           0 :         }
    1407             :     }
    1408           0 :     SetPointer(Pointer(POINTER_ARROW));
    1409           0 :     return (sal_uLong) true;
    1410             : }
    1411             : 
    1412             : 
    1413           0 : void ScAcceptChgDlg::AppendChanges(ScChangeTrack* pChanges,sal_uLong nStartAction,
    1414             :                                    sal_uLong nEndAction, sal_uLong /* nPos */)
    1415             : {
    1416           0 :     if(pChanges!=NULL)
    1417             :     {
    1418           0 :         SvTreeListEntry* pParent=NULL;
    1419           0 :         const ScChangeAction* pScChangeAction=NULL;
    1420           0 :         bAcceptEnableFlag=true;
    1421           0 :         bRejectEnableFlag=true;
    1422           0 :         SetPointer(Pointer(POINTER_WAIT));
    1423           0 :         pTheView->SetUpdateMode(false);
    1424             : 
    1425           0 :         bool bTheFlag = false;
    1426             : 
    1427           0 :         bool bFilterFlag = pTPFilter->IsDate() || pTPFilter->IsRange() ||
    1428           0 :             pTPFilter->IsAuthor() || pTPFilter->IsComment();
    1429             : 
    1430           0 :         bUseColor = bFilterFlag;
    1431             : 
    1432           0 :         for(sal_uLong i=nStartAction;i<=nEndAction;i++)
    1433             :         {
    1434           0 :             pScChangeAction=pChanges->GetAction(i);
    1435           0 :             if(pScChangeAction==NULL) continue;
    1436             : 
    1437             : 
    1438           0 :             switch(pScChangeAction->GetState())
    1439             :             {
    1440             :                 case SC_CAS_VIRGIN:
    1441             : 
    1442           0 :                     if(pScChangeAction->IsDialogRoot())
    1443             :                     {
    1444           0 :                         if(pScChangeAction->IsDialogParent())
    1445           0 :                             pParent=InsertChangeAction(pScChangeAction,SC_CAS_VIRGIN);
    1446             :                         else
    1447           0 :                             pParent=InsertFilteredAction(pScChangeAction,SC_CAS_VIRGIN);
    1448             :                     }
    1449             :                     else
    1450           0 :                         pParent=NULL;
    1451             : 
    1452           0 :                     bTheFlag=true;
    1453           0 :                     break;
    1454             : 
    1455             :                 case SC_CAS_ACCEPTED:
    1456           0 :                     pParent=NULL;
    1457           0 :                     nAcceptCount++;
    1458           0 :                     break;
    1459             : 
    1460             :                 case SC_CAS_REJECTED:
    1461           0 :                     pParent=NULL;
    1462           0 :                     nRejectCount++;
    1463           0 :                     break;
    1464             :             }
    1465             : 
    1466           0 :             if(pParent!=NULL && pScChangeAction->IsDialogParent())
    1467             :             {
    1468           0 :                 if(!bFilterFlag)
    1469           0 :                     pParent->EnableChildrenOnDemand(true);
    1470             :                 else
    1471             :                 {
    1472           0 :                     bool bTestFlag = bHasFilterEntry;
    1473           0 :                     bHasFilterEntry = false;
    1474           0 :                     if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag)
    1475           0 :                         pTheView->RemoveEntry(pParent);
    1476             :                 }
    1477             :             }
    1478             :         }
    1479             : 
    1480           0 :         if( bTheFlag && (!pDoc->IsDocEditable() || pChanges->IsProtected()) )
    1481           0 :             bTheFlag=false;
    1482             : 
    1483           0 :         pTPView->EnableAccept(bTheFlag);
    1484           0 :         pTPView->EnableAcceptAll(bTheFlag);
    1485           0 :         pTPView->EnableReject(bTheFlag);
    1486           0 :         pTPView->EnableRejectAll(bTheFlag);
    1487             : 
    1488           0 :         pTheView->SetUpdateMode(true);
    1489           0 :         SetPointer(Pointer(POINTER_ARROW));
    1490             :     }
    1491           0 : }
    1492             : 
    1493           0 : void ScAcceptChgDlg::RemoveEntrys(sal_uLong nStartAction,sal_uLong nEndAction)
    1494             : {
    1495             : 
    1496           0 :     pTheView->SetUpdateMode(false);
    1497             : 
    1498           0 :     SvTreeListEntry* pEntry=pTheView->GetCurEntry();
    1499             : 
    1500           0 :     ScRedlinData *pEntryData=NULL;
    1501             : 
    1502           0 :     if(pEntry!=NULL)
    1503           0 :         pEntryData=(ScRedlinData *)(pEntry->GetUserData());
    1504             : 
    1505           0 :     sal_uLong nAction=0;
    1506           0 :     if(pEntryData!=NULL)
    1507           0 :         nAction=pEntryData->nActionNo;
    1508             : 
    1509           0 :     if(nAction>=nStartAction && nAction<=nEndAction)
    1510           0 :         pTheView->SetCurEntry(pTheView->GetModel()->GetEntry(0));
    1511             : 
    1512           0 :     bool bRemove = false;
    1513             : 
    1514             :     // MUST do it backwards, don't delete parents before children and GPF
    1515           0 :     pEntry=pTheView->Last();
    1516           0 :     while(pEntry!=NULL)
    1517             :     {
    1518           0 :         bRemove=false;
    1519           0 :         pEntryData=(ScRedlinData *)(pEntry->GetUserData());
    1520           0 :         if(pEntryData!=NULL)
    1521             :         {
    1522           0 :             nAction=pEntryData->nActionNo;
    1523             : 
    1524           0 :             if(nStartAction<=nAction && nAction<=nEndAction) bRemove=true;
    1525             : 
    1526             : 
    1527             :         }
    1528           0 :         SvTreeListEntry* pPrevEntry = pTheView->Prev(pEntry);
    1529             : 
    1530           0 :         if(bRemove)
    1531           0 :             pTheView->RemoveEntry(pEntry);
    1532             : 
    1533           0 :         pEntry=pPrevEntry;
    1534             :     }
    1535           0 :     pTheView->SetUpdateMode(true);
    1536             : 
    1537           0 : }
    1538             : 
    1539           0 : void ScAcceptChgDlg::UpdateEntrys(ScChangeTrack* pChgTrack, sal_uLong nStartAction,sal_uLong nEndAction)
    1540             : {
    1541           0 :     pTheView->SetUpdateMode(false);
    1542             : 
    1543           0 :     sal_uLong nPos=LIST_APPEND;
    1544             : 
    1545           0 :     bool bRemove = false;
    1546             : 
    1547           0 :     SvTreeListEntry* pEntry=pTheView->First();
    1548           0 :     SvTreeListEntry* pNextEntry = (pEntry ? pTheView->NextSibling(pEntry) : NULL);
    1549           0 :     SvTreeListEntry* pLastEntry=NULL;
    1550           0 :     while(pEntry!=NULL)
    1551             :     {
    1552           0 :         bRemove=false;
    1553           0 :         ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
    1554           0 :         if(pEntryData!=NULL)
    1555             :         {
    1556             :             ScChangeAction* pScChangeAction=
    1557           0 :                     (ScChangeAction*) pEntryData->pData;
    1558             : 
    1559           0 :             sal_uLong nAction=pScChangeAction->GetActionNumber();
    1560             : 
    1561           0 :             if(nStartAction<=nAction && nAction<=nEndAction) bRemove=true;
    1562             :         }
    1563             : 
    1564           0 :         if(bRemove)
    1565             :         {
    1566           0 :             nPos=pEntry->GetChildListPos();
    1567           0 :             pTheView->RemoveEntry(pEntry);
    1568             : 
    1569           0 :             if(pLastEntry==NULL) pLastEntry=pTheView->First();
    1570           0 :             if(pLastEntry!=NULL)
    1571             :             {
    1572           0 :                 pNextEntry=pTheView->Next(pLastEntry);
    1573             : 
    1574           0 :                 if(pNextEntry==NULL)
    1575             :                 {
    1576           0 :                     pNextEntry=pLastEntry;
    1577           0 :                     pLastEntry=NULL;
    1578             :                 }
    1579             :             }
    1580             :             else
    1581           0 :                 pNextEntry=NULL;
    1582             : 
    1583             :         }
    1584             :         else
    1585             :         {
    1586           0 :             pLastEntry = pEntry;
    1587           0 :             pNextEntry = pTheView->Next(pEntry);
    1588             :         }
    1589           0 :         pEntry=pNextEntry;
    1590             :     }
    1591             : 
    1592           0 :     if(nStartAction==nEndAction)
    1593           0 :         AppendChanges(pChgTrack,nStartAction,nEndAction,nPos);
    1594             :     else
    1595           0 :         AppendChanges(pChgTrack,nStartAction,nEndAction);
    1596             : 
    1597           0 :     pTheView->SetUpdateMode(true);
    1598             : 
    1599           0 : }
    1600             : 
    1601           0 : IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack*, pChgTrack)
    1602             : {
    1603           0 :     ScChangeTrackMsgQueue::iterator iter;
    1604           0 :     ScChangeTrackMsgQueue& aMsgQueue= pChgTrack->GetMsgQueue();
    1605             : 
    1606             :     sal_uLong   nStartAction;
    1607             :     sal_uLong   nEndAction;
    1608             : 
    1609           0 :     for (iter = aMsgQueue.begin(); iter != aMsgQueue.end(); ++iter)
    1610             :     {
    1611           0 :         nStartAction=(*iter)->nStartAction;
    1612           0 :         nEndAction=(*iter)->nEndAction;
    1613             : 
    1614           0 :         if(!bIgnoreMsg)
    1615             :         {
    1616           0 :             bNoSelection=true;
    1617             : 
    1618           0 :             switch((*iter)->eMsgType)
    1619             :             {
    1620           0 :                 case SC_CTM_APPEND: AppendChanges(pChgTrack,nStartAction,nEndAction);
    1621           0 :                                     break;
    1622           0 :                 case SC_CTM_REMOVE: RemoveEntrys(nStartAction,nEndAction);
    1623           0 :                                     break;
    1624             :                 case SC_CTM_PARENT:
    1625             :                 case SC_CTM_CHANGE: //bNeedsUpdate=true;
    1626           0 :                                     UpdateEntrys(pChgTrack,nStartAction,nEndAction);
    1627           0 :                                     break;
    1628             :                 default:
    1629             :                 {
    1630             :                     // added to avoid warnings
    1631             :                 }
    1632             :             }
    1633             :         }
    1634           0 :         delete *iter;
    1635             :     }
    1636             : 
    1637           0 :     aMsgQueue.clear();
    1638             : 
    1639           0 :     return 0;
    1640             : }
    1641           0 : IMPL_LINK_NOARG(ScAcceptChgDlg, ReOpenTimerHdl)
    1642             : {
    1643           0 :     ScSimpleRefDlgWrapper::SetAutoReOpen(true);
    1644           0 :     m_pAcceptChgCtr->ShowFilterPage();
    1645           0 :     RefHandle(NULL);
    1646             : 
    1647           0 :     return 0;
    1648             : }
    1649             : 
    1650           0 : IMPL_LINK_NOARG(ScAcceptChgDlg, UpdateSelectionHdl)
    1651             : {
    1652           0 :     ScTabView* pTabView = pViewData->GetView();
    1653             : 
    1654           0 :     bool bAcceptFlag = true;
    1655           0 :     bool bRejectFlag = true;
    1656           0 :     bool bContMark = false;
    1657             : 
    1658           0 :     pTabView->DoneBlockMode();  // clears old marking
    1659           0 :     SvTreeListEntry* pEntry = pTheView->FirstSelected();
    1660           0 :     while( pEntry )
    1661             :     {
    1662           0 :         ScRedlinData* pEntryData = (ScRedlinData*) pEntry->GetUserData();
    1663           0 :         if( pEntryData )
    1664             :         {
    1665           0 :             bRejectFlag &= (bool) pEntryData->bIsRejectable;
    1666           0 :             bAcceptFlag &= (bool) pEntryData->bIsAcceptable;
    1667             : 
    1668           0 :             const ScChangeAction* pScChangeAction = (ScChangeAction*) pEntryData->pData;
    1669           0 :             if( pScChangeAction && (pScChangeAction->GetType() != SC_CAT_DELETE_TABS) &&
    1670           0 :                     (!pEntryData->bDisabled || pScChangeAction->IsVisible()) )
    1671             :             {
    1672           0 :                 const ScBigRange& rBigRange = pScChangeAction->GetBigRange();
    1673           0 :                 if( rBigRange.IsValid( pDoc ) && IsActive() )
    1674             :                 {
    1675           0 :                     bool bSetCursor = !pTheView->NextSelected( pEntry );
    1676           0 :                     pTabView->MarkRange( rBigRange.MakeRange(), bSetCursor, bContMark );
    1677           0 :                     bContMark = true;
    1678             :                 }
    1679             :             }
    1680             :         }
    1681             :         else
    1682             :         {
    1683           0 :             bAcceptFlag = false;
    1684           0 :             bRejectFlag = false;
    1685             :         }
    1686           0 :         bAcceptEnableFlag = bAcceptFlag;
    1687           0 :         bRejectEnableFlag = bRejectFlag;
    1688             : 
    1689           0 :         pEntry = pTheView->NextSelected( pEntry );
    1690             :     }
    1691             : 
    1692           0 :     ScChangeTrack* pChanges = pDoc->GetChangeTrack();
    1693           0 :     bool bEnable = pDoc->IsDocEditable() && pChanges && !pChanges->IsProtected();
    1694           0 :     pTPView->EnableAccept( bAcceptFlag && bEnable );
    1695           0 :     pTPView->EnableReject( bRejectFlag && bEnable );
    1696             : 
    1697           0 :     return 0;
    1698             : }
    1699             : 
    1700           0 : IMPL_LINK_NOARG(ScAcceptChgDlg, CommandHdl)
    1701             : {
    1702             : 
    1703           0 :     const CommandEvent aCEvt(pTheView->GetCommandEvent());
    1704             : 
    1705           0 :     if(aCEvt.GetCommand()==COMMAND_CONTEXTMENU)
    1706             :     {
    1707           0 :         ScPopupMenu aPopup(ScResId(RID_POPUP_CHANGES));
    1708             : 
    1709           0 :         aPopup.SetMenuFlags(MENU_FLAG_HIDEDISABLEDENTRIES);
    1710             : 
    1711           0 :         SvTreeListEntry* pEntry=pTheView->GetCurEntry();
    1712           0 :         if(pEntry!=NULL)
    1713             :         {
    1714           0 :             pTheView->Select(pEntry);
    1715             :         }
    1716             :         else
    1717             :         {
    1718           0 :             aPopup.Deactivate();
    1719             :         }
    1720             : 
    1721           0 :         sal_uInt16 nSortedCol= pTheView->GetSortedCol();
    1722             : 
    1723           0 :         if(nSortedCol!=0xFFFF)
    1724             :         {
    1725           0 :             sal_uInt16 nItemId=nSortedCol+SC_SUB_SORT+1;
    1726             : 
    1727           0 :             aPopup.CheckItem(nItemId);
    1728             : 
    1729           0 :             PopupMenu *pSubMenu = aPopup.GetPopupMenu(SC_SUB_SORT);
    1730             : 
    1731           0 :             if (pSubMenu)
    1732           0 :                 pSubMenu->CheckItem(nItemId);
    1733             :         }
    1734             : 
    1735           0 :         aPopup.EnableItem(SC_CHANGES_COMMENT,false);
    1736             : 
    1737           0 :         if(pDoc->IsDocEditable() && pEntry!=NULL)
    1738             :         {
    1739           0 :             ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
    1740           0 :             if(pEntryData!=NULL)
    1741             :             {
    1742             :                 ScChangeAction* pScChangeAction=
    1743           0 :                         (ScChangeAction*) pEntryData->pData;
    1744           0 :                 if(pScChangeAction!=NULL && !pTheView->GetParent(pEntry))
    1745           0 :                     aPopup.EnableItem(SC_CHANGES_COMMENT);
    1746             :             }
    1747             :         }
    1748             : 
    1749           0 :         sal_uInt16 nCommand=aPopup.Execute( this, GetPointerPosPixel() );
    1750             : 
    1751             : 
    1752           0 :         if(nCommand)
    1753             :         {
    1754           0 :             if(nCommand==SC_CHANGES_COMMENT)
    1755             :             {
    1756           0 :                 if(pEntry!=NULL)
    1757             :                 {
    1758           0 :                     ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
    1759           0 :                     if(pEntryData!=NULL)
    1760             :                     {
    1761             :                         ScChangeAction* pScChangeAction=
    1762           0 :                                 (ScChangeAction*) pEntryData->pData;
    1763             : 
    1764           0 :                         pViewData->GetDocShell()->ExecuteChangeCommentDialog( pScChangeAction, this,false);
    1765             :                     }
    1766             :                 }
    1767             :             }
    1768             :             else
    1769             :             {
    1770           0 :                 bool bSortDir = pTheView->GetSortDirection();
    1771           0 :                 sal_uInt16 nDialogCol=nCommand-SC_SUB_SORT-1;
    1772           0 :                 if(nSortedCol==nDialogCol) bSortDir=!bSortDir;
    1773           0 :                 pTheView->SortByCol(nDialogCol,bSortDir);
    1774             :                 /*
    1775             :                 SC_SUB_SORT
    1776             :                 SC_SORT_ACTION
    1777             :                 SC_SORT_POSITION
    1778             :                 SC_SORT_AUTHOR
    1779             :                 SC_SORT_DATE
    1780             :                 SC_SORT_COMMENT
    1781             :                 */
    1782             :             }
    1783           0 :         }
    1784             :     }
    1785           0 :     return 0;
    1786             : }
    1787             : 
    1788           0 : void ScAcceptChgDlg::Initialize(SfxChildWinInfo *pInfo)
    1789             : {
    1790           0 :     String aStr;
    1791           0 :     if(pInfo!=NULL)
    1792             :     {
    1793           0 :         if ( pInfo->aExtraString.Len() )
    1794             :         {
    1795             :             xub_StrLen nPos = pInfo->aExtraString.Search(
    1796           0 :                 OUString("AcceptChgDat:"));
    1797             : 
    1798             :             // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn
    1799             :             // er nicht vorhanden ist, liegt eine "altere Version vor
    1800           0 :             if ( nPos != STRING_NOTFOUND )
    1801             :             {
    1802           0 :                 xub_StrLen n1 = pInfo->aExtraString.Search('(', nPos);
    1803           0 :                 if ( n1 != STRING_NOTFOUND )
    1804             :                 {
    1805           0 :                     xub_StrLen n2 = pInfo->aExtraString.Search(')', n1);
    1806           0 :                     if ( n2 != STRING_NOTFOUND )
    1807             :                     {
    1808             :                         // Alignment-String herausschneiden
    1809           0 :                         aStr = pInfo->aExtraString.Copy(nPos, n2 - nPos + 1);
    1810           0 :                         pInfo->aExtraString.Erase(nPos, n2 - nPos + 1);
    1811           0 :                         aStr.Erase(0, n1-nPos+1);
    1812             :                     }
    1813             :                 }
    1814             :             }
    1815             :         }
    1816             :     }
    1817           0 :     SfxModelessDialog::Initialize(pInfo);
    1818             : 
    1819           0 :     if ( aStr.Len())
    1820             :     {
    1821           0 :         sal_uInt16 nCount=(sal_uInt16)aStr.ToInt32();
    1822             : 
    1823           0 :         for(sal_uInt16 i=0;i<nCount;i++)
    1824             :         {
    1825           0 :             xub_StrLen n1 = aStr.Search(';');
    1826           0 :             aStr.Erase(0, n1+1);
    1827           0 :             pTheView->SetTab(i,(sal_uInt16)aStr.ToInt32(),MAP_PIXEL);
    1828             :         }
    1829           0 :     }
    1830           0 : }
    1831             : 
    1832             : //-------------------------------------------------------------------------
    1833             : 
    1834           0 : void ScAcceptChgDlg::FillInfo(SfxChildWinInfo& rInfo) const
    1835             : {
    1836           0 :     SfxModelessDialog::FillInfo(rInfo);
    1837           0 :     rInfo.aExtraString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "AcceptChgDat:(" ));
    1838             : 
    1839           0 :     sal_uInt16  nCount=pTheView->TabCount();
    1840             : 
    1841           0 :     rInfo.aExtraString += OUString::number(nCount);
    1842           0 :     rInfo.aExtraString += ';';
    1843           0 :     for(sal_uInt16 i=0;i<nCount;i++)
    1844             :     {
    1845           0 :         rInfo.aExtraString += OUString::number(pTheView->GetTab(i));
    1846           0 :         rInfo.aExtraString += ';';
    1847             :     }
    1848           0 :     rInfo.aExtraString += ')';
    1849           0 : }
    1850             : 
    1851           0 : void ScAcceptChgDlg::InitFilter()
    1852             : {
    1853           0 :     if(pTPFilter->IsDate()||pTPFilter->IsRange()||
    1854           0 :         pTPFilter->IsAuthor()||pTPFilter->IsComment())
    1855             :     {
    1856           0 :         pTheView->SetFilterDate(pTPFilter->IsDate());
    1857           0 :         pTheView->SetDateTimeMode(pTPFilter->GetDateMode());
    1858           0 :         pTheView->SetFirstDate(pTPFilter->GetFirstDate());
    1859           0 :         pTheView->SetLastDate(pTPFilter->GetLastDate());
    1860           0 :         pTheView->SetFirstTime(pTPFilter->GetFirstTime());
    1861           0 :         pTheView->SetLastTime(pTPFilter->GetLastTime());
    1862           0 :         pTheView->SetFilterAuthor(pTPFilter->IsAuthor());
    1863           0 :         pTheView->SetAuthor(pTPFilter->GetSelectedAuthor());
    1864             : 
    1865           0 :         pTheView->SetFilterComment(pTPFilter->IsComment());
    1866             : 
    1867             :         utl::SearchParam aSearchParam( pTPFilter->GetComment(),
    1868           0 :                 utl::SearchParam::SRCH_REGEXP,false,false,false );
    1869             : 
    1870           0 :         pTheView->SetCommentParams(&aSearchParam);
    1871             : 
    1872           0 :         pTheView->UpdateFilterTest();
    1873             :     }
    1874           0 : }
    1875             : 
    1876           0 : IMPL_LINK_NOARG(ScAcceptChgDlg, FilterModified)
    1877             : {
    1878           0 :     return 0;
    1879             : }
    1880             : 
    1881             : #define CALC_DATE       3
    1882             : #define CALC_POS        1
    1883             : 
    1884           0 : IMPL_LINK( ScAcceptChgDlg, ColCompareHdl, SvSortData*, pSortData )
    1885             : {
    1886           0 :     StringCompare eCompare=COMPARE_EQUAL;
    1887           0 :     SCCOL nSortCol= static_cast<SCCOL>(pTheView->GetSortedCol());
    1888             : 
    1889           0 :     if(pSortData)
    1890             :     {
    1891           0 :         SvTreeListEntry* pLeft = (SvTreeListEntry*)(pSortData->pLeft );
    1892           0 :         SvTreeListEntry* pRight = (SvTreeListEntry*)(pSortData->pRight );
    1893             : 
    1894           0 :         if(CALC_DATE==nSortCol)
    1895             :         {
    1896           0 :             RedlinData *pLeftData=(RedlinData *)(pLeft->GetUserData());
    1897           0 :             RedlinData *pRightData=(RedlinData *)(pRight->GetUserData());
    1898             : 
    1899           0 :             if(pLeftData!=NULL && pRightData!=NULL)
    1900             :             {
    1901           0 :                 if(pLeftData->aDateTime < pRightData->aDateTime)
    1902           0 :                     eCompare=COMPARE_LESS;
    1903           0 :                 else if(pLeftData->aDateTime > pRightData->aDateTime)
    1904           0 :                     eCompare=COMPARE_GREATER;
    1905             : 
    1906           0 :                 return eCompare;
    1907             :             }
    1908             :         }
    1909           0 :         else if(CALC_POS==nSortCol)
    1910             :         {
    1911           0 :             ScRedlinData *pLeftData=(ScRedlinData *)(pLeft->GetUserData());
    1912           0 :             ScRedlinData *pRightData=(ScRedlinData *)(pRight->GetUserData());
    1913             : 
    1914           0 :             if(pLeftData!=NULL && pRightData!=NULL)
    1915             :             {
    1916           0 :                 eCompare=COMPARE_GREATER;
    1917             : 
    1918           0 :                 if(pLeftData->nTable < pRightData->nTable)
    1919           0 :                     eCompare=COMPARE_LESS;
    1920           0 :                 else if(pLeftData->nTable == pRightData->nTable)
    1921             :                 {
    1922           0 :                     if(pLeftData->nRow < pRightData->nRow)
    1923           0 :                         eCompare=COMPARE_LESS;
    1924           0 :                     else if(pLeftData->nRow == pRightData->nRow)
    1925             :                     {
    1926           0 :                         if(pLeftData->nCol < pRightData->nCol)
    1927           0 :                             eCompare=COMPARE_LESS;
    1928           0 :                         else if(pLeftData->nCol == pRightData->nCol)
    1929           0 :                             eCompare=COMPARE_EQUAL;
    1930             :                     }
    1931             :                 }
    1932             : 
    1933           0 :                 return eCompare;
    1934             :             }
    1935             :         }
    1936             : 
    1937           0 :         SvLBoxItem* pLeftItem = pTheView->GetEntryAtPos( pLeft, static_cast<sal_uInt16>(nSortCol));
    1938           0 :         SvLBoxItem* pRightItem = pTheView->GetEntryAtPos( pRight, static_cast<sal_uInt16>(nSortCol));
    1939             : 
    1940           0 :         if(pLeftItem != NULL && pRightItem != NULL)
    1941             :         {
    1942           0 :             sal_uInt16 nLeftKind = pLeftItem->GetType();
    1943           0 :             sal_uInt16 nRightKind = pRightItem->GetType();
    1944             : 
    1945           0 :             if(nRightKind == SV_ITEM_ID_LBOXSTRING &&
    1946             :                 nLeftKind == SV_ITEM_ID_LBOXSTRING )
    1947             :             {
    1948             :                 eCompare= (StringCompare) ScGlobal::GetCaseCollator()->compareString(
    1949             :                                         ((SvLBoxString*)pLeftItem)->GetText(),
    1950           0 :                                         ((SvLBoxString*)pRightItem)->GetText());
    1951             : 
    1952           0 :                 if(eCompare==COMPARE_EQUAL) eCompare=COMPARE_LESS;
    1953             :             }
    1954             :         }
    1955             : 
    1956             : 
    1957             :     }
    1958           0 :     return eCompare;
    1959          93 : }
    1960             : 
    1961             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10