summaryrefslogtreecommitdiff
path: root/sc/source/ui/miscdlgs
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/miscdlgs')
-rw-r--r--sc/source/ui/miscdlgs/acredlin.cxx2137
-rw-r--r--sc/source/ui/miscdlgs/acredlin.src258
-rw-r--r--sc/source/ui/miscdlgs/anyrefdg.cxx1013
-rw-r--r--sc/source/ui/miscdlgs/autofmt.cxx569
-rw-r--r--sc/source/ui/miscdlgs/conflictsdlg.cxx861
-rw-r--r--sc/source/ui/miscdlgs/conflictsdlg.src109
-rw-r--r--sc/source/ui/miscdlgs/crdlg.cxx89
-rw-r--r--sc/source/ui/miscdlgs/crnrdlg.cxx1175
-rw-r--r--sc/source/ui/miscdlgs/datafdlg.cxx425
-rw-r--r--sc/source/ui/miscdlgs/delcldlg.cxx122
-rw-r--r--sc/source/ui/miscdlgs/delcodlg.cxx182
-rw-r--r--sc/source/ui/miscdlgs/filldlg.cxx377
-rw-r--r--sc/source/ui/miscdlgs/groupdlg.cxx85
-rw-r--r--sc/source/ui/miscdlgs/highred.cxx303
-rw-r--r--sc/source/ui/miscdlgs/highred.src133
-rw-r--r--sc/source/ui/miscdlgs/inscldlg.cxx122
-rw-r--r--sc/source/ui/miscdlgs/inscodlg.cxx374
-rw-r--r--sc/source/ui/miscdlgs/instbdlg.cxx435
-rw-r--r--sc/source/ui/miscdlgs/instbdlg.src184
-rw-r--r--sc/source/ui/miscdlgs/lbseldlg.cxx103
-rw-r--r--sc/source/ui/miscdlgs/linkarea.cxx368
-rw-r--r--sc/source/ui/miscdlgs/linkarea.src120
-rw-r--r--sc/source/ui/miscdlgs/makefile.mk126
-rw-r--r--sc/source/ui/miscdlgs/mtrindlg.cxx188
-rw-r--r--sc/source/ui/miscdlgs/mvtabdlg.cxx207
-rw-r--r--sc/source/ui/miscdlgs/namecrea.cxx81
-rw-r--r--sc/source/ui/miscdlgs/namepast.cxx135
-rw-r--r--sc/source/ui/miscdlgs/optsolver.cxx1068
-rw-r--r--sc/source/ui/miscdlgs/protectiondlg.cxx165
-rw-r--r--sc/source/ui/miscdlgs/protectiondlg.src127
-rw-r--r--sc/source/ui/miscdlgs/redcom.cxx187
-rw-r--r--sc/source/ui/miscdlgs/retypepassdlg.cxx547
-rw-r--r--sc/source/ui/miscdlgs/retypepassdlg.src313
-rw-r--r--sc/source/ui/miscdlgs/scuiautofmt.cxx479
-rw-r--r--sc/source/ui/miscdlgs/sharedocdlg.cxx238
-rw-r--r--sc/source/ui/miscdlgs/sharedocdlg.src110
-rw-r--r--sc/source/ui/miscdlgs/shtabdlg.cxx113
-rw-r--r--sc/source/ui/miscdlgs/simpref.cxx259
-rw-r--r--sc/source/ui/miscdlgs/solveroptions.cxx494
-rw-r--r--sc/source/ui/miscdlgs/solverutil.cxx231
-rw-r--r--sc/source/ui/miscdlgs/solvrdlg.cxx315
-rw-r--r--sc/source/ui/miscdlgs/strindlg.cxx109
-rw-r--r--sc/source/ui/miscdlgs/tabbgcolordlg.cxx201
-rw-r--r--sc/source/ui/miscdlgs/tabopdlg.cxx373
-rw-r--r--sc/source/ui/miscdlgs/textdlgs.cxx132
-rw-r--r--sc/source/ui/miscdlgs/warnbox.cxx93
46 files changed, 15835 insertions, 0 deletions
diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx
new file mode 100644
index 000000000000..a5e94745f2e6
--- /dev/null
+++ b/sc/source/ui/miscdlgs/acredlin.cxx
@@ -0,0 +1,2137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+#include <svl/undo.hxx>
+#include <unotools/textsearch.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <unotools/collatorwrapper.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/viewfrm.hxx>
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "acredlin.hxx"
+#include "global.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "acredlin.hrc"
+#include "simpref.hxx"
+#include "scmod.hxx"
+#include "popmenu.hxx"
+#include "tabvwsh.hxx"
+
+// defines -------------------------------------------------------------------
+
+#define ABS_SREF SCA_VALID \
+ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+#define ABS_DREF ABS_SREF \
+ | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
+#define ABS_SREF3D ABS_SREF | SCA_TAB_3D
+#define ABS_DREF3D ABS_DREF | SCA_TAB_3D
+
+
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
+
+inline void EnableDisable( Window& rWin, BOOL bEnable )
+{
+ if (bEnable)
+ rWin.Enable();
+ else
+ rWin.Disable();
+}
+
+#define RD_SPECIAL_NONE 0
+#define RD_SPECIAL_CONTENT 1
+#define RD_SPECIAL_VISCONTENT 2
+
+//============================================================================
+// class ScRedlinData
+//----------------------------------------------------------------------------
+
+ScRedlinData::ScRedlinData()
+ :RedlinData()
+{
+ nInfo=RD_SPECIAL_NONE;
+ nActionNo=0;
+ pData=NULL;
+ bDisabled=FALSE;
+ bIsRejectable=FALSE;
+ bIsAcceptable=FALSE;
+ nTable=SCTAB_MAX;
+ nCol=SCCOL_MAX;
+ nRow=SCROW_MAX;
+}
+
+ScRedlinData::~ScRedlinData()
+{
+ nInfo=RD_SPECIAL_NONE;
+ nActionNo=0;
+ pData=NULL;
+ bDisabled=FALSE;
+ bIsRejectable=FALSE;
+ bIsAcceptable=FALSE;
+}
+
+
+//============================================================================
+// class ScAcceptChgDlg
+//----------------------------------------------------------------------------
+ScAcceptChgDlg::ScAcceptChgDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData)
+
+ : SfxModelessDialog( pB, pCW, pParent, ScResId(RID_SCDLG_CHANGES) ),
+ //
+ aAcceptChgCtr ( this, ScResId( CTR_REDLINING ) ),
+ //
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+ aLocalRangeName ( *(pDoc->GetRangeName()) ),
+ //
+ aStrInsertCols ( ScResId( STR_INSERT_COLS)),
+ aStrInsertRows ( ScResId( STR_INSERT_ROWS)),
+ aStrInsertTabs ( ScResId( STR_INSERT_TABS)),
+ aStrDeleteCols ( ScResId( STR_DELETE_COLS)),
+ aStrDeleteRows ( ScResId( STR_DELETE_ROWS)),
+ aStrDeleteTabs ( ScResId( STR_DELETE_TABS)),
+ aStrMove ( ScResId( STR_MOVE )),
+ aStrContent ( ScResId( STR_CONTENT )),
+ aStrReject ( ScResId( STR_REJECT )),
+ aStrAllAccepted ( ScResId( STR_ACCEPTED )),
+ aStrAllRejected ( ScResId( STR_REJECTED )),
+ aStrNoEntry ( ScResId( STR_NO_ENTRY )),
+ aStrContentWithChild ( ScResId( STR_CONTENT_WITH_CHILD)),
+ aStrChildContent ( ScResId( STR_CHILD_CONTENT)),
+ aStrChildOrgContent ( ScResId( STR_CHILD_ORGCONTENT)),
+ aStrEmpty ( ScResId( STR_EMPTY ))
+{
+ FreeResource();
+// bScAcceptChgDlgIsDead=FALSE;
+ bNoSelection=FALSE;
+ bNeedsUpdate=FALSE;
+ bIgnoreMsg=FALSE;
+ nAcceptCount=0;
+ nRejectCount=0;
+ bAcceptEnableFlag=TRUE;
+ bRejectEnableFlag=TRUE;
+ bHasFilterEntry=FALSE;
+ bUseColor=FALSE;
+ aReOpenTimer.SetTimeout(50);
+ aReOpenTimer.SetTimeoutHdl(LINK( this, ScAcceptChgDlg, ReOpenTimerHdl ));
+
+ // dialog is now only hidden, not deleted, on switching views,
+ // so there's no need to restore settings when reopening
+
+ MinSize=aAcceptChgCtr.GetMinSizePixel();
+ MinSize.Height()+=2;
+ MinSize.Width()+=2;
+ SetMinOutputSizePixel(MinSize);
+ aUnknown.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Unknown"));
+
+ pTPFilter=aAcceptChgCtr.GetFilterPage();
+ pTPView=aAcceptChgCtr.GetViewPage();
+ pTheView=pTPView->GetTableControl();
+ aSelectionTimer.SetTimeout(100);
+ aSelectionTimer.SetTimeoutHdl(LINK( this, ScAcceptChgDlg, UpdateSelectionHdl ));
+
+ pTPFilter->SetReadyHdl(LINK( this, ScAcceptChgDlg, FilterHandle ));
+ pTPFilter->SetRefHdl(LINK( this, ScAcceptChgDlg, RefHandle ));
+ pTPFilter->SetModifyHdl(LINK( this, ScAcceptChgDlg, FilterModified));
+ pTPFilter->HideRange(FALSE);
+ pTPView->InsertCalcHeader();
+ pTPView->SetRejectClickHdl( LINK( this, ScAcceptChgDlg,RejectHandle));
+ pTPView->SetAcceptClickHdl( LINK(this, ScAcceptChgDlg, AcceptHandle));
+ pTPView->SetRejectAllClickHdl( LINK( this, ScAcceptChgDlg,RejectAllHandle));
+ pTPView->SetAcceptAllClickHdl( LINK(this, ScAcceptChgDlg, AcceptAllHandle));
+ pTheView->SetCalcView();
+ pTheView->SetWindowBits(WB_HASLINES|WB_CLIPCHILDREN|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
+ pTheView->SetExpandingHdl( LINK(this, ScAcceptChgDlg, ExpandingHandle));
+ pTheView->SetSelectHdl( LINK(this, ScAcceptChgDlg, SelectHandle));
+ pTheView->SetDeselectHdl( LINK(this, ScAcceptChgDlg, SelectHandle));
+ pTheView->SetCommandHdl( LINK(this, ScAcceptChgDlg, CommandHdl));
+ pTheView->SetColCompareHdl( LINK(this, ScAcceptChgDlg,ColCompareHdl));
+ pTheView->SetSelectionMode(MULTIPLE_SELECTION);
+ pTheView->SetHighlightRange(1);
+
+ Init();
+
+ aAcceptChgCtr.SetMinSizeHdl( LINK( this, ScAcceptChgDlg, MinSizeHandle ));
+
+ UpdateView();
+ SvLBoxEntry* pEntry=pTheView->First();
+ if(pEntry!=NULL)
+ {
+ pTheView->Select(pEntry);
+ }
+}
+ScAcceptChgDlg::~ScAcceptChgDlg()
+{
+// bScAcceptChgDlgIsDead=TRUE;
+ ClearView();
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ if(pChanges!=NULL)
+ {
+ Link aLink;
+ pChanges->SetModifiedLink(aLink);
+ }
+}
+
+void ScAcceptChgDlg::ReInit(ScViewData* ptrViewData)
+{
+ pViewData=ptrViewData;
+ if(pViewData!=NULL)
+ {
+ pDoc=ptrViewData->GetDocument();
+ }
+ else
+ {
+ pDoc=NULL;
+ }
+
+ bNoSelection=FALSE;
+ bNeedsUpdate=FALSE;
+ bIgnoreMsg=FALSE;
+ nAcceptCount=0;
+ nRejectCount=0;
+ bAcceptEnableFlag=TRUE;
+ bRejectEnableFlag=TRUE;
+
+ // #91781# don't call Init here (switching between views), just set link below
+ // (dialog is just hidden, not deleted anymore, when switching views)
+ ClearView();
+ UpdateView();
+
+ if ( pDoc )
+ {
+ ScChangeTrack* pChanges = pDoc->GetChangeTrack();
+ if ( pChanges )
+ pChanges->SetModifiedLink( LINK( this, ScAcceptChgDlg, ChgTrackModHdl ) );
+ }
+}
+
+void __EXPORT ScAcceptChgDlg::Init()
+{
+ String aAreaStr;
+ ScRange aRange;
+
+ DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
+
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ if(pChanges!=NULL)
+ {
+ pChanges->SetModifiedLink( LINK( this, ScAcceptChgDlg,ChgTrackModHdl));
+ aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser());
+ pTPFilter->ClearAuthors();
+ ScStrCollection aUserColl=pChanges->GetUserCollection();
+ for(USHORT i=0;i<aUserColl.GetCount();i++)
+ pTPFilter->InsertAuthor(aUserColl[i]->GetString());
+ }
+
+ ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings();
+ if ( pViewSettings!=NULL )
+ aChangeViewSet = *pViewSettings;
+ // adjust TimeField for filter tabpage
+ aChangeViewSet.AdjustDateMode( *pDoc );
+
+ pTPFilter->CheckDate(aChangeViewSet.HasDate());
+ pTPFilter->SetFirstDate(aChangeViewSet.GetTheFirstDateTime());
+ pTPFilter->SetFirstTime(aChangeViewSet.GetTheFirstDateTime());
+ pTPFilter->SetLastDate(aChangeViewSet.GetTheLastDateTime());
+ pTPFilter->SetLastTime(aChangeViewSet.GetTheLastDateTime());
+ pTPFilter->SetDateMode((USHORT)aChangeViewSet.GetTheDateMode());
+ pTPFilter->CheckComment(aChangeViewSet.HasComment());
+ pTPFilter->SetComment(aChangeViewSet.GetTheComment());
+
+ pTPFilter->CheckAuthor(aChangeViewSet.HasAuthor());
+ String aString=aChangeViewSet.GetTheAuthorToShow();
+ if(aString.Len()!=0)
+ {
+ pTPFilter->SelectAuthor(aString);
+ if(pTPFilter->GetSelectedAuthor()!=aString)
+ {
+ pTPFilter->InsertAuthor(aString);
+ pTPFilter->SelectAuthor(aString);
+ }
+ }
+ else
+ {
+ pTPFilter->SelectedAuthorPos(0);
+ }
+
+ pTPFilter->CheckRange(aChangeViewSet.HasRange());
+
+ ScRange* pRangeEntry=aChangeViewSet.GetTheRangeList().GetObject(0);
+ aRangeList=aChangeViewSet.GetTheRangeList();
+
+ if(pRangeEntry!=NULL)
+ {
+ String aRefStr;
+ pRangeEntry->Format( aRefStr, ABS_DREF3D, pDoc );
+ pTPFilter->SetRange(aRefStr);
+ }
+
+ Point aPoint(1,1);
+ aAcceptChgCtr.SetPosPixel(aPoint);
+ InitFilter();
+}
+
+
+
+void ScAcceptChgDlg::ClearView()
+{
+ nAcceptCount=0;
+ nRejectCount=0;
+ pTheView->SetUpdateMode(FALSE);
+
+ pTheView->Clear();
+ pTheView->SetUpdateMode(TRUE);
+}
+
+String* ScAcceptChgDlg::MakeTypeString(ScChangeActionType eType)
+{
+ String* pStr;
+
+ switch(eType)
+ {
+
+ case SC_CAT_INSERT_COLS: pStr=&aStrInsertCols;break;
+
+ case SC_CAT_INSERT_ROWS: pStr=&aStrInsertRows;break;
+
+ case SC_CAT_INSERT_TABS: pStr=&aStrInsertTabs;break;
+
+ case SC_CAT_DELETE_COLS: pStr=&aStrDeleteCols;break;
+
+ case SC_CAT_DELETE_ROWS: pStr=&aStrDeleteRows;break;
+
+ case SC_CAT_DELETE_TABS: pStr=&aStrDeleteTabs;break;
+
+ case SC_CAT_MOVE: pStr=&aStrMove;break;
+
+ case SC_CAT_CONTENT: pStr=&aStrContent;break;
+
+ case SC_CAT_REJECT: pStr=&aStrReject;break;
+
+ default: pStr=&aUnknown;break;
+ }
+ return pStr;
+}
+
+
+BOOL ScAcceptChgDlg::IsValidAction(const ScChangeAction* pScChangeAction)
+{
+ if(pScChangeAction==NULL) return FALSE;
+
+ BOOL bFlag=FALSE;
+
+ ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
+ String aUser=pScChangeAction->GetUser();
+ DateTime aDateTime=pScChangeAction->GetDateTime();
+
+ ScChangeActionType eType=pScChangeAction->GetType();
+ String aString;
+ String aDesc;
+
+ String aComment=pScChangeAction->GetComment();
+ aComment.EraseAllChars('\n');
+
+ if(eType==SC_CAT_CONTENT)
+ {
+ if(!pScChangeAction->IsDialogParent())
+ {
+ pScChangeAction->GetDescription( aDesc, pDoc, TRUE);
+ }
+ }
+ else
+ {
+ pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
+ }
+
+ if(aDesc.Len()>0)
+ {
+ aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
+ aComment+=aDesc;
+ aComment+=')';
+ }
+
+ if(pTheView->IsValidEntry(&aUser,&aDateTime,&aComment))
+ {
+ if(pTPFilter->IsRange())
+ {
+ ScRange* pRangeEntry=aRangeList.First();
+
+ while(pRangeEntry!=NULL)
+ {
+ if(pRangeEntry->Intersects(aRef)) break;
+ pRangeEntry=aRangeList.Next();
+ }
+
+ if(pRangeEntry!=NULL)
+ {
+ bFlag=TRUE;
+ }
+ }
+ else
+ {
+ bFlag=TRUE;
+ }
+ }
+
+ return bFlag;
+}
+
+SvLBoxEntry* ScAcceptChgDlg::InsertChangeAction(const ScChangeAction* pScChangeAction,
+ ScChangeActionState /* eState */, SvLBoxEntry* pParent,
+ BOOL bDelMaster,BOOL bDisabled,ULONG nPos)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ if(pScChangeAction==NULL || pChanges==NULL) return NULL;
+
+ SvLBoxEntry* pEntry=NULL;
+
+ BOOL bFlag=FALSE;
+
+ ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
+ String aUser=pScChangeAction->GetUser();
+ DateTime aDateTime=pScChangeAction->GetDateTime();
+
+ String aRefStr;
+ ScChangeActionType eType=pScChangeAction->GetType();
+ String aString;
+ String aDesc;
+
+ ScRedlinData* pNewData=new ScRedlinData;
+ pNewData->pData=(void *)pScChangeAction;
+ pNewData->nActionNo=pScChangeAction->GetActionNumber();
+ pNewData->bIsAcceptable=pScChangeAction->IsClickable();
+ pNewData->bIsRejectable=pScChangeAction->IsRejectable();
+ pNewData->bDisabled=!pNewData->bIsAcceptable | bDisabled;
+ pNewData->aDateTime=aDateTime;
+ pNewData->nRow = aRef.aStart.Row();
+ pNewData->nCol = aRef.aStart.Col();
+ pNewData->nTable= aRef.aStart.Tab();
+
+ if(eType==SC_CAT_CONTENT)
+ {
+ if(pScChangeAction->IsDialogParent())
+ {
+ aString=aStrContentWithChild;
+ pNewData->nInfo=RD_SPECIAL_VISCONTENT;
+ pNewData->bIsRejectable=FALSE;
+ pNewData->bIsAcceptable=FALSE;
+ }
+ else
+ {
+ aString=*MakeTypeString(eType);
+ pScChangeAction->GetDescription( aDesc, pDoc, TRUE);
+ }
+ }
+ else
+ {
+ aString=*MakeTypeString(eType);
+
+ if(bDelMaster)
+ {
+ pScChangeAction->GetDescription( aDesc, pDoc,TRUE);
+ pNewData->bDisabled=TRUE;
+ pNewData->bIsRejectable=FALSE;
+ }
+ else
+ pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
+
+ }
+
+ aString+='\t';
+ pScChangeAction->GetRefString(aRefStr, pDoc, TRUE);
+ aString+=aRefStr;
+ aString+='\t';
+
+ BOOL bIsGenerated;
+
+ if(!pChanges->IsGenerated(pScChangeAction->GetActionNumber()))
+ {
+ aString+=aUser;
+ aString+='\t';
+
+ aString+=ScGlobal::pLocaleData->getDate(aDateTime);
+ aString+=' ';
+ aString+=ScGlobal::pLocaleData->getTime(aDateTime);
+ aString+='\t';
+ bIsGenerated=FALSE;
+ }
+ else
+ {
+ aString+='\t';
+ aString+='\t';
+ bIsGenerated=TRUE;
+ }
+
+ String aComment=pScChangeAction->GetComment();
+ aComment.EraseAllChars('\n');
+ if(aDesc.Len()>0)
+ {
+ aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
+ aComment+=aDesc;
+ aComment+=')';
+ }
+
+ aString+=aComment;
+
+ if(pTheView->IsValidEntry(&aUser,&aDateTime)|| bIsGenerated)
+ {
+ if(pTheView->IsValidComment(&aComment))
+ {
+ if(pTPFilter->IsRange())
+ {
+ ScRange* pRangeEntry=aRangeList.First();
+
+ while(pRangeEntry!=NULL)
+ {
+ if(pRangeEntry->Intersects(aRef)) break;
+ pRangeEntry=aRangeList.Next();
+ }
+ //SC_CAS_VIRGIN,SC_CAS_ACCEPTED,SC_CAS_REJECTED
+ if(pRangeEntry!=NULL)
+ {
+ bHasFilterEntry=TRUE;
+ bFlag=TRUE;
+ }
+ }
+ else if(!bIsGenerated)
+ {
+ bHasFilterEntry=TRUE;
+ bFlag=TRUE;
+ }
+ }
+ }
+
+ if(!bFlag&& bUseColor&& pParent==NULL)
+ {
+ pEntry=pTheView->InsertEntry(aString,pNewData,Color(COL_LIGHTBLUE),pParent,nPos);
+ }
+ else if(bFlag&& bUseColor&& pParent!=NULL)
+ {
+ pEntry=pTheView->InsertEntry(aString,pNewData,Color(COL_GREEN),pParent,nPos);
+ SvLBoxEntry* pExpEntry=pParent;
+
+ while(pExpEntry!=NULL && !pTheView->IsExpanded(pExpEntry))
+ {
+ SvLBoxEntry* pTmpEntry=pTheView->GetParent(pExpEntry);
+
+ if(pTmpEntry!=NULL) pTheView->Expand(pExpEntry);
+
+ pExpEntry=pTmpEntry;
+ }
+ }
+ else
+ {
+ pEntry=pTheView->InsertEntry(aString,pNewData,pParent,nPos);
+ }
+ return pEntry;
+}
+
+SvLBoxEntry* ScAcceptChgDlg::InsertFilteredAction(const ScChangeAction* pScChangeAction,
+ ScChangeActionState eState,SvLBoxEntry* pParent,
+ BOOL bDelMaster,BOOL bDisabled,ULONG nPos)
+{
+
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ if(pScChangeAction==NULL || pChanges==NULL) return NULL;
+
+ BOOL bIsGenerated=pChanges->IsGenerated(pScChangeAction->GetActionNumber());
+
+ SvLBoxEntry* pEntry=NULL;
+
+ int bFlag=FALSE;
+
+ ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
+ String aUser=pScChangeAction->GetUser();
+ DateTime aDateTime=pScChangeAction->GetDateTime();
+
+ if(pTheView->IsValidEntry(&aUser,&aDateTime)||bIsGenerated)
+ {
+ if(pTPFilter->IsRange())
+ {
+ ScRange* pRangeEntry=aRangeList.First();
+
+ while(pRangeEntry!=NULL)
+ {
+ if(pRangeEntry->Intersects(aRef)) break;
+ pRangeEntry=aRangeList.Next();
+ }
+ //SC_CAS_VIRGIN,SC_CAS_ACCEPTED,SC_CAS_REJECTED
+ if(pRangeEntry!=NULL &&
+ pScChangeAction->GetState()==eState)
+ {
+ bFlag=TRUE;
+ }
+ }
+ else if(pScChangeAction->GetState()==eState && !bIsGenerated)
+ {
+ bFlag=TRUE;
+ }
+ }
+
+ if(bFlag)
+ {
+
+ String aRefStr;
+ ScChangeActionType eType=pScChangeAction->GetType();
+ String aString;
+ String aDesc;
+
+
+ ScRedlinData* pNewData=new ScRedlinData;
+ pNewData->pData=(void *)pScChangeAction;
+ pNewData->nActionNo=pScChangeAction->GetActionNumber();
+ pNewData->bIsAcceptable=pScChangeAction->IsClickable();
+ pNewData->bIsRejectable=pScChangeAction->IsRejectable();
+ pNewData->bDisabled=!pNewData->bIsAcceptable | bDisabled;
+ pNewData->aDateTime=aDateTime;
+ pNewData->nRow = aRef.aStart.Row();
+ pNewData->nCol = aRef.aStart.Col();
+ pNewData->nTable= aRef.aStart.Tab();
+
+ if(eType==SC_CAT_CONTENT)
+ {
+ if(pScChangeAction->IsDialogParent())
+ {
+ aString=aStrContentWithChild;
+ pNewData->nInfo=RD_SPECIAL_VISCONTENT;
+ pNewData->bIsRejectable=FALSE;
+ pNewData->bIsAcceptable=FALSE;
+ }
+ else
+ {
+ aString=*MakeTypeString(eType);
+ pScChangeAction->GetDescription( aDesc, pDoc, TRUE);
+ }
+ }
+ else
+ {
+ aString=*MakeTypeString(eType);
+
+ if(bDelMaster)
+ {
+ pScChangeAction->GetDescription( aDesc, pDoc,TRUE);
+ pNewData->bDisabled=TRUE;
+ pNewData->bIsRejectable=FALSE;
+ }
+ else
+ pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
+
+ }
+
+ aString+='\t';
+ pScChangeAction->GetRefString(aRefStr, pDoc, TRUE);
+ aString+=aRefStr;
+ aString+='\t';
+
+ if(!bIsGenerated)
+ {
+ aString+=aUser;
+ aString+='\t';
+ aString+=ScGlobal::pLocaleData->getDate(aDateTime);
+ aString+=' ';
+ aString+=ScGlobal::pLocaleData->getTime(aDateTime);
+ aString+='\t';
+ }
+ else
+ {
+ aString+='\t';
+ aString+='\t';
+ }
+
+ String aComment=pScChangeAction->GetComment();
+ aComment.EraseAllChars('\n');
+ if(aDesc.Len()>0)
+ {
+ aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
+ aComment+=aDesc;
+ aComment+=')';
+ }
+ if(pTheView->IsValidComment(&aComment))
+ {
+ aString+=aComment;
+ pEntry=pTheView->InsertEntry(aString,pNewData,pParent,nPos);
+ }
+ else
+ delete pNewData;
+ }
+ return pEntry;
+}
+
+SvLBoxEntry* ScAcceptChgDlg::InsertChangeActionContent(const ScChangeActionContent* pScChangeAction,
+ SvLBoxEntry* pParent, ULONG nSpecial)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ SvLBoxEntry* pEntry=NULL;
+
+ if(pScChangeAction==NULL || pChanges==NULL) return NULL;
+
+ BOOL bIsGenerated=pChanges->IsGenerated(pScChangeAction->GetActionNumber());
+
+ BOOL bFlag=FALSE;
+
+ ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
+ String aUser=pScChangeAction->GetUser();
+ DateTime aDateTime=pScChangeAction->GetDateTime();
+
+ if(pTheView->IsValidEntry(&aUser,&aDateTime)||bIsGenerated)
+ {
+ if(pTPFilter->IsRange())
+ {
+ ScRange* pRangeEntry=aRangeList.First();
+
+ while(pRangeEntry!=NULL)
+ {
+ if(pRangeEntry->Intersects(aRef)) break;
+ pRangeEntry=aRangeList.Next();
+ }
+ //SC_CAS_VIRGIN,SC_CAS_ACCEPTED,SC_CAS_REJECTED
+ if(pRangeEntry!=NULL)
+ {
+ bFlag=TRUE;
+ }
+ }
+ else if(!bIsGenerated)
+ bFlag=TRUE;
+ }
+
+ String aRefStr;
+ String aString;
+ String a2String;
+ String aDesc;
+
+ if(nSpecial==RD_SPECIAL_CONTENT)
+ {
+ pScChangeAction->GetOldString(a2String);
+ if(a2String.Len()==0) a2String=aStrEmpty;
+
+ //aString+="\'";
+ aString+=a2String;
+ //aString+="\'";
+
+ aDesc=aStrChildOrgContent;
+ aDesc.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
+ }
+ else
+ {
+ pScChangeAction->GetNewString(a2String);
+ if(a2String.Len()==0)
+ {
+ a2String=aStrEmpty;
+ aString+=a2String;
+ }
+ else
+ {
+ aString+='\'';
+ aString+=a2String;
+ aString+='\'';
+ a2String=aString;
+ }
+ aDesc=aStrChildContent;
+
+ }
+
+ aDesc+=a2String;
+ aString+='\t';
+ pScChangeAction->GetRefString(aRefStr, pDoc, TRUE);
+ aString+=aRefStr;
+ aString+='\t';
+
+ if(!bIsGenerated)
+ {
+ aString+=aUser;
+ aString+='\t';
+
+ aString+=ScGlobal::pLocaleData->getDate(aDateTime);
+ aString+=' ';
+ aString+=ScGlobal::pLocaleData->getTime(aDateTime);
+ aString+='\t';
+ }
+ else
+ {
+ aString+='\t';
+ aString+='\t';
+ }
+ String aComment=pScChangeAction->GetComment();
+ aComment.EraseAllChars('\n');
+
+ if(aDesc.Len()>0)
+ {
+ aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
+ aComment+=aDesc;
+ aComment+=')';
+ }
+
+ aString+=aComment;
+
+ ScRedlinData* pNewData=new ScRedlinData;
+ pNewData->nInfo=nSpecial;
+ pNewData->pData=(void *)pScChangeAction;
+ pNewData->nActionNo=pScChangeAction->GetActionNumber();
+ pNewData->bIsAcceptable=pScChangeAction->IsClickable();
+ pNewData->bIsRejectable=FALSE;
+ pNewData->bDisabled=!pNewData->bIsAcceptable;
+ pNewData->aDateTime=aDateTime;
+ pNewData->nRow = aRef.aStart.Row();
+ pNewData->nCol = aRef.aStart.Col();
+ pNewData->nTable= aRef.aStart.Tab();
+
+ if(pTheView->IsValidComment(&aComment) && bFlag)
+ {
+ bHasFilterEntry=TRUE;
+ pEntry=pTheView->InsertEntry(aString,pNewData,pParent);
+ }
+ else
+ pEntry=pTheView->InsertEntry(aString,pNewData,Color(COL_LIGHTBLUE),pParent);
+ return pEntry;
+}
+
+long ScAcceptChgDlg::PreNotify( NotifyEvent& rNEvt )
+{
+ if(rNEvt.GetType()==EVENT_GETFOCUS && bNeedsUpdate)
+ {
+ ClearView();
+ UpdateView();
+ bNoSelection=FALSE;
+ }
+
+ return SfxModelessDialog::PreNotify(rNEvt);
+}
+
+
+void ScAcceptChgDlg::UpdateView()
+{
+ bNeedsUpdate=FALSE;
+ DateTime aDateTime;
+ SvLBoxEntry* pParent=NULL;
+ ScChangeTrack* pChanges=NULL;
+ const ScChangeAction* pScChangeAction=NULL;
+ bAcceptEnableFlag=TRUE;
+ bRejectEnableFlag=TRUE;
+ SetPointer(Pointer(POINTER_WAIT));
+ pTheView->SetUpdateMode(FALSE);
+ BOOL bFilterFlag=pTPFilter->IsDate()||pTPFilter->IsRange()||
+ pTPFilter->IsAuthor()||pTPFilter->IsComment();
+
+ bUseColor=bFilterFlag;
+
+ if(pDoc!=NULL)
+ {
+ pChanges=pDoc->GetChangeTrack();
+ if(pChanges!=NULL)
+ {
+ pScChangeAction=pChanges->GetFirst();
+ }
+ }
+ ScChangeActionTable ActionTable;
+ BOOL bTheFlag=FALSE;
+
+ while(pScChangeAction!=NULL)
+ {
+ bHasFilterEntry=FALSE;
+ switch(pScChangeAction->GetState())
+ {
+ case SC_CAS_VIRGIN:
+
+ if(pScChangeAction->IsDialogRoot())
+ {
+ if(pScChangeAction->IsDialogParent())
+ pParent=InsertChangeAction(pScChangeAction,SC_CAS_VIRGIN);
+ else
+ pParent=InsertFilteredAction(pScChangeAction,SC_CAS_VIRGIN);
+ }
+ else
+ pParent=NULL;
+
+ bTheFlag=TRUE;
+ break;
+
+ case SC_CAS_ACCEPTED:
+ pParent=NULL;
+ nAcceptCount++;
+ break;
+
+ case SC_CAS_REJECTED:
+ pParent=NULL;
+ nRejectCount++;
+ break;
+ }
+
+ if(pParent!=NULL && pScChangeAction->IsDialogParent())
+ {
+ if(!bFilterFlag)
+ {
+ pParent->EnableChildsOnDemand(TRUE);
+ }
+ else
+ {
+ BOOL bTestFlag=bHasFilterEntry;
+ bHasFilterEntry=FALSE;
+ if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag)
+ pTheView->RemoveEntry(pParent);
+ }
+ }
+
+ pScChangeAction=pScChangeAction->GetNext();
+ }
+
+ if( bTheFlag && (!pDoc->IsDocEditable() || pChanges->IsProtected()) )
+ bTheFlag=FALSE;
+
+ pTPView->EnableAccept(bTheFlag);
+ pTPView->EnableAcceptAll(bTheFlag);
+ pTPView->EnableReject(bTheFlag);
+ pTPView->EnableRejectAll(bTheFlag);
+
+ if(nAcceptCount>0)
+ {
+ pParent=pTheView->InsertEntry(
+ aStrAllAccepted, static_cast< RedlinData * >(NULL),
+ static_cast< SvLBoxEntry * >(NULL));
+ pParent->EnableChildsOnDemand(TRUE);
+ }
+ if(nRejectCount>0)
+ {
+ pParent=pTheView->InsertEntry(
+ aStrAllRejected, static_cast< RedlinData * >(NULL),
+ static_cast< SvLBoxEntry * >(NULL));
+ pParent->EnableChildsOnDemand(TRUE);
+ }
+ pTheView->SetUpdateMode(TRUE);
+ SetPointer(Pointer(POINTER_ARROW));
+ SvLBoxEntry* pEntry=pTheView->First();
+ if(pEntry!=NULL)
+ {
+ pTheView->Select(pEntry);
+ }
+}
+
+//----------------------------------------------------------------------------
+BOOL ScAcceptChgDlg::Close()
+{
+ return SfxModelessDialog::Close();
+}
+
+void ScAcceptChgDlg::Resize()
+{
+ SfxModelessDialog::Resize();
+ Size aOutSize=GetOutputSizePixel();
+ aAcceptChgCtr.SetSizePixel(aOutSize);
+}
+
+IMPL_LINK( ScAcceptChgDlg, MinSizeHandle, SvxAcceptChgCtr*, pCtr )
+{
+ if(pCtr==&aAcceptChgCtr)
+ {
+ if(!IsRollUp())
+ SetOutputSizePixel(MinSize);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, RefHandle, SvxTPFilter*, EMPTYARG )
+{
+ USHORT nId =ScSimpleRefDlgWrapper::GetChildWindowId();
+
+ ScSimpleRefDlgWrapper::SetDefaultPosSize(GetPosPixel(),GetSizePixel(),TRUE);
+
+ SC_MOD()->SetRefDialog( nId, TRUE );
+
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+ ScSimpleRefDlgWrapper* pWnd =(ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
+
+ if(pWnd!=NULL)
+ {
+// bSimpleRefDlgStarted=TRUE;
+ USHORT nAcceptId=ScAcceptChgDlgWrapper::GetChildWindowId();
+ pViewFrm->ShowChildWindow(nAcceptId,FALSE);
+ pWnd->SetCloseHdl(LINK( this, ScAcceptChgDlg,RefInfoHandle));
+ pWnd->SetRefString(pTPFilter->GetRange());
+ pWnd->SetAutoReOpen(FALSE);
+ Window* pWin=pWnd->GetWindow();
+ pWin->SetPosSizePixel(GetPosPixel(),GetSizePixel());
+ Hide();
+ pWin->SetText(GetText());
+ pWnd->StartRefInput();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, RefInfoHandle, String*, pResult)
+{
+ USHORT nId;
+
+// bSimpleRefDlgStarted=FALSE;
+ ScSimpleRefDlgWrapper::SetAutoReOpen(TRUE);
+
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+ if(pResult!=NULL)
+ {
+ pTPFilter->SetRange(*pResult);
+ FilterHandle(pTPFilter);
+
+ nId = ScSimpleRefDlgWrapper::GetChildWindowId();
+ ScSimpleRefDlgWrapper* pWnd = (ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
+
+ if(pWnd!=NULL)
+ {
+ Window* pWin=pWnd->GetWindow();
+ Size aWinSize=pWin->GetSizePixel();
+ aWinSize.Width()=GetSizePixel().Width();
+ SetPosSizePixel(pWin->GetPosPixel(),aWinSize);
+ Invalidate();
+ }
+ nId = ScAcceptChgDlgWrapper::GetChildWindowId();
+ pViewFrm->ShowChildWindow( nId, TRUE );
+ }
+ else
+ {
+ nId = ScAcceptChgDlgWrapper::GetChildWindowId();
+ pViewFrm->SetChildWindow( nId, FALSE );
+ }
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, FilterHandle, SvxTPFilter*, pRef )
+{
+ if(pRef!=NULL)
+ {
+ ClearView();
+ aRangeList.Clear();
+ aRangeList.Parse(pTPFilter->GetRange(),pDoc);
+ UpdateView();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, RejectHandle, SvxTPView*, pRef )
+{
+ SetPointer(Pointer(POINTER_WAIT));
+
+ bIgnoreMsg=TRUE;
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ if(pRef!=NULL)
+ {
+ SvLBoxEntry* pEntry=pTheView->FirstSelected();
+ while(pEntry!=NULL)
+ {
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ ScChangeAction* pScChangeAction=
+ (ScChangeAction*) pEntryData->pData;
+
+ if(pScChangeAction->GetType()==SC_CAT_INSERT_TABS)
+ {
+ pViewData->SetTabNo(0);
+ }
+ pChanges->Reject(pScChangeAction);
+ }
+ pEntry = pTheView->NextSelected(pEntry);
+ }
+ ScDocShell* pDocSh=pViewData->GetDocShell();
+ pDocSh->PostPaintExtras();
+ pDocSh->PostPaintGridAll();
+ pDocSh->GetUndoManager()->Clear();
+ pDocSh->SetDocumentModified();
+ ClearView();
+ UpdateView();
+ }
+ SetPointer(Pointer(POINTER_ARROW));
+
+ bIgnoreMsg=FALSE;
+ return 0;
+}
+IMPL_LINK( ScAcceptChgDlg, AcceptHandle, SvxTPView*, pRef )
+{
+ SetPointer(Pointer(POINTER_WAIT));
+
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ bIgnoreMsg=TRUE;
+ if(pRef!=NULL)
+ {
+ SvLBoxEntry* pEntry=pTheView->FirstSelected();
+ while(pEntry!=NULL)
+ {
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ ScChangeAction* pScChangeAction=
+ (ScChangeAction*) pEntryData->pData;
+ if(pScChangeAction->GetType()==SC_CAT_CONTENT)
+ {
+ if(pEntryData->nInfo==RD_SPECIAL_CONTENT)
+ {
+ pChanges->SelectContent(pScChangeAction,TRUE);
+ }
+ else
+ {
+ pChanges->SelectContent(pScChangeAction);
+ }
+ }
+ else
+ pChanges->Accept(pScChangeAction);
+ }
+ pEntry = pTheView->NextSelected(pEntry);
+ }
+ ScDocShell* pDocSh=pViewData->GetDocShell();
+ pDocSh->PostPaintExtras();
+ pDocSh->PostPaintGridAll();
+ pDocSh->SetDocumentModified();
+ ClearView();
+ UpdateView();
+ }
+ bIgnoreMsg=FALSE;
+
+ return 0;
+}
+
+void ScAcceptChgDlg::RejectFiltered()
+{
+ if(pDoc==NULL) return;
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ const ScChangeAction* pScChangeAction=NULL;
+
+ if(pChanges!=NULL)
+ {
+ pScChangeAction=pChanges->GetLast();
+ }
+
+ while(pScChangeAction!=NULL)
+ {
+ if(pScChangeAction->IsDialogRoot())
+ {
+ if(IsValidAction(pScChangeAction))
+ {
+ pChanges->Reject((ScChangeAction*)pScChangeAction);
+ }
+ }
+ pScChangeAction=pScChangeAction->GetPrev();
+ }
+}
+void ScAcceptChgDlg::AcceptFiltered()
+{
+ if(pDoc==NULL) return;
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ const ScChangeAction* pScChangeAction=NULL;
+
+ if(pChanges!=NULL)
+ {
+ pScChangeAction=pChanges->GetLast();
+ }
+
+ while(pScChangeAction!=NULL)
+ {
+ if(pScChangeAction->IsDialogRoot())
+ {
+ if(IsValidAction(pScChangeAction))
+ {
+ pChanges->Accept((ScChangeAction*)pScChangeAction);
+ }
+ }
+ pScChangeAction=pScChangeAction->GetPrev();
+ }
+}
+
+IMPL_LINK( ScAcceptChgDlg, RejectAllHandle, SvxTPView*, EMPTYARG )
+{
+ SetPointer(Pointer(POINTER_WAIT));
+ bIgnoreMsg=TRUE;
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ if(pChanges!=NULL)
+ {
+ if(pTPFilter->IsDate()||pTPFilter->IsAuthor()||pTPFilter->IsRange()||pTPFilter->IsComment())
+ {
+ RejectFiltered();
+ }
+ else
+ {
+ pChanges->RejectAll();
+ }
+ pViewData->SetTabNo(0);
+
+ ScDocShell* pDocSh=pViewData->GetDocShell();
+ pDocSh->PostPaintExtras();
+ pDocSh->PostPaintGridAll();
+ pDocSh->GetUndoManager()->Clear();
+ pDocSh->SetDocumentModified();
+ ClearView();
+ UpdateView();
+ }
+ SetPointer(Pointer(POINTER_ARROW));
+
+ bIgnoreMsg=FALSE;
+
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, AcceptAllHandle, SvxTPView*, EMPTYARG )
+{
+ SetPointer(Pointer(POINTER_WAIT));
+
+ bIgnoreMsg=TRUE;
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ if(pChanges!=NULL)
+ {
+ if(pTPFilter->IsDate()||pTPFilter->IsAuthor()||pTPFilter->IsRange()||pTPFilter->IsComment())
+ {
+ AcceptFiltered();
+ }
+ else
+ {
+ pChanges->AcceptAll();
+ }
+ ScDocShell* pDocSh=pViewData->GetDocShell();
+ pDocSh->PostPaintExtras();
+ pDocSh->PostPaintGridAll();
+ pDocSh->SetDocumentModified();
+ ClearView();
+ UpdateView();
+ }
+ bIgnoreMsg=FALSE;
+ SetPointer(Pointer(POINTER_ARROW));
+
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, SelectHandle, SvxRedlinTable*, EMPTYARG )
+{
+ if(!bNoSelection)
+ {
+ aSelectionTimer.Start();
+ }
+ bNoSelection=FALSE;
+ return 0;
+}
+
+void ScAcceptChgDlg::GetDependents( const ScChangeAction* pScChangeAction,
+ ScChangeActionTable& aActionTable,
+ SvLBoxEntry* pEntry)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ SvLBoxEntry* pParent=pTheView->GetParent(pEntry);
+ if(pParent!=NULL)
+ {
+ ScRedlinData *pParentData=(ScRedlinData *)(pParent->GetUserData());
+ ScChangeAction* pParentAction=(ScChangeAction*) pParentData->pData;
+ if(pParentAction!=pScChangeAction)
+ {
+ pChanges->GetDependents((ScChangeAction*) pScChangeAction,
+ aActionTable,pScChangeAction->IsMasterDelete());
+ }
+ else
+ {
+ pChanges->GetDependents((ScChangeAction*) pScChangeAction,
+ aActionTable);
+ }
+ }
+ else
+ {
+ pChanges->GetDependents((ScChangeAction*) pScChangeAction,
+ aActionTable,pScChangeAction->IsMasterDelete());
+ }
+}
+
+BOOL ScAcceptChgDlg::InsertContentChilds(ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
+{
+ BOOL bTheTestFlag=TRUE;
+ ScRedlinData *pEntryData=(ScRedlinData *)(pParent->GetUserData());
+ const ScChangeAction* pScChangeAction = (ScChangeAction*) pEntryData->pData;
+ BOOL bParentInserted = FALSE;
+ // If the parent is a MatrixOrigin then place it in the right order before
+ // the MatrixReferences. Also if it is the first content change at this
+ // position don't insert the first dependent MatrixReference as the special
+ // content (original value) but insert the predecessor of the MatrixOrigin
+ // itself instead.
+ if ( pScChangeAction->GetType() == SC_CAT_CONTENT &&
+ ((const ScChangeActionContent*)pScChangeAction)->IsMatrixOrigin() )
+ {
+ pActionTable->Insert( pScChangeAction->GetActionNumber(),
+ (ScChangeAction*) pScChangeAction );
+ bParentInserted = TRUE;
+ }
+ SvLBoxEntry* pEntry=NULL;
+
+ const ScChangeActionContent* pCChild=(const ScChangeActionContent*)pActionTable->First();
+ while(pCChild!=NULL)
+ {
+ if( pCChild->GetState()==SC_CAS_VIRGIN )
+ break;
+ pCChild=(const ScChangeActionContent*)pActionTable->Next();
+ }
+
+ if(pCChild==NULL) return TRUE;
+
+ SvLBoxEntry* pOriginal=InsertChangeActionContent(pCChild,pParent,RD_SPECIAL_CONTENT);
+ if(pOriginal!=NULL)
+ {
+ bTheTestFlag=FALSE;
+ ScRedlinData *pParentData=(ScRedlinData *)(pOriginal->GetUserData());
+ pParentData->pData=(void *)pScChangeAction;
+ pParentData->nActionNo=pScChangeAction->GetActionNumber();
+ pParentData->bIsAcceptable=pScChangeAction->IsRejectable(); // select old value
+ pParentData->bIsRejectable=FALSE;
+ pParentData->bDisabled=FALSE;
+ }
+ while(pCChild!=NULL)
+ {
+ if(pCChild->GetState()==SC_CAS_VIRGIN)
+ {
+ pEntry=InsertChangeActionContent(pCChild,pParent,RD_SPECIAL_NONE);
+
+ if(pEntry!=NULL)
+ bTheTestFlag=FALSE;
+ }
+ pCChild=(const ScChangeActionContent*)pActionTable->Next();
+ }
+
+ if ( !bParentInserted )
+ {
+ pEntry=InsertChangeActionContent((const ScChangeActionContent*)
+ pScChangeAction,pParent,RD_SPECIAL_NONE);
+
+ if(pEntry!=NULL)
+ {
+ bTheTestFlag=FALSE;
+ ScRedlinData *pParentData=(ScRedlinData *)(pEntry->GetUserData());
+ pParentData->pData=(void *)pScChangeAction;
+ pParentData->nActionNo=pScChangeAction->GetActionNumber();
+ pParentData->bIsAcceptable=pScChangeAction->IsClickable();
+ pParentData->bIsRejectable=FALSE;
+ pParentData->bDisabled=FALSE;
+ }
+ }
+
+ return bTheTestFlag;
+
+}
+
+BOOL ScAcceptChgDlg::InsertAcceptedORejected(SvLBoxEntry* pParent)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ BOOL bTheTestFlag=TRUE;
+
+ ScChangeActionState eState = SC_CAS_VIRGIN;
+ String aString=pTheView->GetEntryText( pParent);
+ String a2String=aString.Copy(0,aStrAllAccepted.Len());
+ if(a2String==aStrAllAccepted)
+ {
+ eState=SC_CAS_ACCEPTED;
+ }
+ else
+ {
+ a2String=aString.Copy(0,aStrAllRejected.Len());
+ if(a2String==aStrAllRejected)
+ {
+ eState=SC_CAS_REJECTED;
+ }
+ }
+
+ ScChangeAction* pScChangeAction=pChanges->GetFirst();
+ while(pScChangeAction!=NULL)
+ {
+ if(pScChangeAction->GetState()==eState &&
+ InsertFilteredAction(pScChangeAction,eState,pParent)!=NULL)
+ bTheTestFlag=FALSE;
+ pScChangeAction=pScChangeAction->GetNext();
+ }
+ return bTheTestFlag;
+}
+
+BOOL ScAcceptChgDlg::InsertChilds(ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ BOOL bTheTestFlag=TRUE;
+ SvLBoxEntry* pEntry=NULL;
+ const ScChangeAction* pChild=(const ScChangeAction*)pActionTable->First();
+ while(pChild!=NULL)
+ {
+ pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,FALSE,TRUE);
+
+ if(pEntry!=NULL)
+ {
+ bTheTestFlag=FALSE;
+
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ pEntryData->bIsRejectable=FALSE;
+ pEntryData->bIsAcceptable=FALSE;
+ pEntryData->bDisabled=TRUE;
+
+ if(pChild->IsDialogParent())
+ {
+
+ //pEntry->EnableChildsOnDemand(TRUE);
+ Expand(pChanges,pChild,pEntry);
+ }
+ }
+ pChild=pActionTable->Next();
+ }
+ return bTheTestFlag;
+}
+BOOL ScAcceptChgDlg::InsertDeletedChilds(const ScChangeAction* pScChangeAction,
+ ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ BOOL bTheTestFlag=TRUE;
+ SvLBoxEntry* pEntry=NULL;
+ ScChangeActionTable aDelActionTable;
+ const ScChangeAction* pChild=(const ScChangeAction*)pActionTable->First();
+
+ while(pChild!=NULL)
+ {
+
+ if(pScChangeAction!=pChild)
+ pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,FALSE,TRUE);
+ else
+ pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,TRUE,TRUE);
+
+ if(pEntry!=NULL)
+ {
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ pEntryData->bIsRejectable=FALSE;
+ pEntryData->bIsAcceptable=FALSE;
+ pEntryData->bDisabled=TRUE;
+
+ bTheTestFlag=FALSE;
+ if ( pChild->IsDialogParent() )
+ {
+ Expand(pChanges,pChild,pEntry);
+ /*
+ pChanges->GetDependents((ScChangeAction*) pChild,aDelActionTable);
+ if(aDelActionTable.First()!=NULL)
+ {
+ pEntry->EnableChildsOnDemand(TRUE);
+ }
+ aDelActionTable.Clear();
+ */
+ }
+ }
+ pChild=pActionTable->Next();
+ }
+ return bTheTestFlag;
+}
+
+BOOL ScAcceptChgDlg::Expand(ScChangeTrack* pChanges,const ScChangeAction* pScChangeAction,
+ SvLBoxEntry* pEntry,BOOL bFilter)
+{
+ BOOL bTheTestFlag=TRUE;
+
+ if(pChanges!=NULL &&pEntry!=NULL &&pScChangeAction!=NULL)
+ {
+ ScChangeActionTable aActionTable;
+
+ GetDependents( pScChangeAction,aActionTable,pEntry);
+
+ switch(pScChangeAction->GetType())
+ {
+ case SC_CAT_CONTENT:
+ {
+ InsertContentChilds(&aActionTable,pEntry);
+ bTheTestFlag=!bHasFilterEntry;
+ break;
+ }
+ case SC_CAT_DELETE_COLS:
+ case SC_CAT_DELETE_ROWS:
+ case SC_CAT_DELETE_TABS:
+ {
+ InsertDeletedChilds(pScChangeAction,&aActionTable,pEntry);
+ bTheTestFlag=!bHasFilterEntry;
+ break;
+ }
+ default:
+ {
+ if(!bFilter)
+ bTheTestFlag=InsertChilds(&aActionTable,pEntry);
+ break;
+ }
+ }
+ aActionTable.Clear();
+ }
+ return bTheTestFlag;
+}
+
+IMPL_LINK( ScAcceptChgDlg, ExpandingHandle, SvxRedlinTable*, pTable )
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ ScChangeAction* pScChangeAction=NULL;
+ SetPointer(Pointer(POINTER_WAIT));
+ if(pTable!=NULL && pChanges!=NULL)
+ {
+ ScChangeActionTable aActionTable;
+ SvLBoxEntry* pEntry=pTheView->GetHdlEntry();
+ if(pEntry!=NULL)
+ {
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ pScChangeAction=(ScChangeAction*) pEntryData->pData;
+ }
+
+ if(pEntry->HasChildsOnDemand())
+ {
+ BOOL bTheTestFlag=TRUE;
+ pEntry->EnableChildsOnDemand(FALSE);
+ pTheView->RemoveEntry(pTheView->FirstChild(pEntry));
+
+ if(pEntryData!=NULL)
+ {
+ pScChangeAction=(ScChangeAction*) pEntryData->pData;
+
+ GetDependents( pScChangeAction,aActionTable,pEntry);
+
+ switch(pScChangeAction->GetType())
+ {
+ case SC_CAT_CONTENT:
+ {
+ bTheTestFlag=InsertContentChilds(&aActionTable,pEntry);
+ break;
+ }
+ case SC_CAT_DELETE_COLS:
+ case SC_CAT_DELETE_ROWS:
+ case SC_CAT_DELETE_TABS:
+ {
+ bTheTestFlag=InsertDeletedChilds(pScChangeAction,&aActionTable,pEntry);
+ break;
+ }
+ default:
+ {
+ bTheTestFlag=InsertChilds(&aActionTable,pEntry);
+ break;
+ }
+ }
+ aActionTable.Clear();
+
+ }
+ else
+ {
+ bTheTestFlag=InsertAcceptedORejected(pEntry);
+ }
+ if(bTheTestFlag) pTheView->InsertEntry(aStrNoEntry,NULL,Color(COL_GRAY),pEntry);
+ }
+
+ }
+ }
+ SetPointer(Pointer(POINTER_ARROW));
+ return (ULONG) TRUE;
+}
+
+
+void ScAcceptChgDlg::AppendChanges(ScChangeTrack* pChanges,ULONG nStartAction,
+ ULONG nEndAction, ULONG /* nPos */)
+{
+ if(pChanges!=NULL)
+ {
+ DateTime aDateTime;
+ SvLBoxEntry* pParent=NULL;
+ const ScChangeAction* pScChangeAction=NULL;
+ bAcceptEnableFlag=TRUE;
+ bRejectEnableFlag=TRUE;
+ SetPointer(Pointer(POINTER_WAIT));
+ pTheView->SetUpdateMode(FALSE);
+
+ ScChangeActionTable ActionTable;
+ BOOL bTheFlag=FALSE;
+
+ BOOL bFilterFlag=pTPFilter->IsDate()||pTPFilter->IsRange()||
+ pTPFilter->IsAuthor()||pTPFilter->IsComment();
+
+ bUseColor=bFilterFlag;
+
+ for(ULONG i=nStartAction;i<=nEndAction;i++)
+ {
+ pScChangeAction=pChanges->GetAction(i);
+ if(pScChangeAction==NULL) continue;
+
+
+ switch(pScChangeAction->GetState())
+ {
+ case SC_CAS_VIRGIN:
+
+ if(pScChangeAction->IsDialogRoot())
+ {
+ if(pScChangeAction->IsDialogParent())
+ pParent=InsertChangeAction(pScChangeAction,SC_CAS_VIRGIN);
+ else
+ pParent=InsertFilteredAction(pScChangeAction,SC_CAS_VIRGIN);
+ }
+ else
+ pParent=NULL;
+
+ bTheFlag=TRUE;
+ break;
+
+ case SC_CAS_ACCEPTED:
+ pParent=NULL;
+ nAcceptCount++;
+ break;
+
+ case SC_CAS_REJECTED:
+ pParent=NULL;
+ nRejectCount++;
+ break;
+ }
+
+ if(pParent!=NULL && pScChangeAction->IsDialogParent())
+ {
+ if(!bFilterFlag)
+ {
+ pParent->EnableChildsOnDemand(TRUE);
+ }
+ else
+ {
+ BOOL bTestFlag=bHasFilterEntry;
+ bHasFilterEntry=FALSE;
+ if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag)
+ pTheView->RemoveEntry(pParent);
+ }
+ }
+
+ pScChangeAction=pScChangeAction->GetNext();
+ }
+
+ if( bTheFlag && (!pDoc->IsDocEditable() || pChanges->IsProtected()) )
+ bTheFlag=FALSE;
+
+ pTPView->EnableAccept(bTheFlag);
+ pTPView->EnableAcceptAll(bTheFlag);
+ pTPView->EnableReject(bTheFlag);
+ pTPView->EnableRejectAll(bTheFlag);
+
+ pTheView->SetUpdateMode(TRUE);
+ SetPointer(Pointer(POINTER_ARROW));
+ }
+}
+
+void ScAcceptChgDlg::RemoveEntrys(ULONG nStartAction,ULONG nEndAction)
+{
+
+ pTheView->SetUpdateMode(FALSE);
+
+ SvLBoxEntry* pEntry=pTheView->GetCurEntry();
+
+ ScRedlinData *pEntryData=NULL;
+
+ if(pEntry!=NULL)
+ pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+
+ ULONG nAction=0;
+ if(pEntryData!=NULL)
+ {
+ nAction=pEntryData->nActionNo;
+ }
+
+ if(nAction>=nStartAction && nAction<=nEndAction)
+ {
+ pTheView->SetCurEntry(pTheView->GetModel()->GetEntry(0));
+ }
+
+ BOOL bRemove=FALSE;
+
+ // MUST do it backwards, don't delete parents before children and GPF
+ pEntry=pTheView->Last();
+ while(pEntry!=NULL)
+ {
+ bRemove=FALSE;
+ pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ nAction=pEntryData->nActionNo;
+
+ if(nStartAction<=nAction && nAction<=nEndAction) bRemove=TRUE;
+
+
+ }
+ SvLBoxEntry* pPrevEntry = pTheView->Prev(pEntry);
+
+ if(bRemove)
+ {
+ //delete pEntryData;
+ pTheView->RemoveEntry(pEntry);
+ }
+ pEntry=pPrevEntry;
+ }
+ pTheView->SetUpdateMode(TRUE);
+
+}
+
+void ScAcceptChgDlg::UpdateEntrys(ScChangeTrack* pChgTrack, ULONG nStartAction,ULONG nEndAction)
+{
+ pTheView->SetUpdateMode(FALSE);
+
+ ULONG nPos=LIST_APPEND;
+
+ BOOL bRemove=FALSE;
+
+ SvLBoxEntry* pEntry=pTheView->First();
+ SvLBoxEntry* pNextEntry = (pEntry ? pTheView->NextSibling(pEntry) : NULL);
+ SvLBoxEntry* pLastEntry=NULL;
+ while(pEntry!=NULL)
+ {
+ bRemove=FALSE;
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ ScChangeAction* pScChangeAction=
+ (ScChangeAction*) pEntryData->pData;
+
+ ULONG nAction=pScChangeAction->GetActionNumber();
+
+ if(nStartAction<=nAction && nAction<=nEndAction) bRemove=TRUE;
+ }
+
+ if(bRemove)
+ {
+ nPos=pEntry->GetChildListPos();
+ pTheView->RemoveEntry(pEntry);
+
+ if(pLastEntry==NULL) pLastEntry=pTheView->First();
+ if(pLastEntry!=NULL)
+ {
+ pNextEntry=pTheView->Next(pLastEntry);
+
+ if(pNextEntry==NULL)
+ {
+ pNextEntry=pLastEntry;
+ pLastEntry=NULL;
+ }
+ }
+ else
+ pNextEntry=NULL;
+
+ }
+ else
+ {
+ pLastEntry = pEntry;
+ pNextEntry = pTheView->Next(pEntry);
+ }
+ pEntry=pNextEntry;
+ }
+
+ if(nStartAction==nEndAction)
+ AppendChanges(pChgTrack,nStartAction,nEndAction,nPos);
+ else
+ AppendChanges(pChgTrack,nStartAction,nEndAction);
+
+ pTheView->SetUpdateMode(TRUE);
+
+}
+
+IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack*, pChgTrack)
+{
+// if(bScAcceptChgDlgIsDead) return 0;
+
+ ScChangeTrackMsgQueue& aMsgQueue= pChgTrack->GetMsgQueue();
+
+ ScChangeTrackMsgInfo* pTrackInfo=aMsgQueue.Get();
+ ULONG nStartAction;
+ ULONG nEndAction;
+
+ while(pTrackInfo!=NULL)
+ {
+ nStartAction=pTrackInfo->nStartAction;
+ nEndAction=pTrackInfo->nEndAction;
+
+ if(!bIgnoreMsg)
+ {
+ bNoSelection=TRUE;
+
+ switch(pTrackInfo->eMsgType)
+ {
+ case SC_CTM_APPEND: AppendChanges(pChgTrack,nStartAction,nEndAction);
+ break;
+ case SC_CTM_REMOVE: RemoveEntrys(nStartAction,nEndAction);
+ break;
+ case SC_CTM_PARENT:
+ case SC_CTM_CHANGE: //bNeedsUpdate=TRUE;
+ UpdateEntrys(pChgTrack,nStartAction,nEndAction);
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ delete pTrackInfo;
+ pTrackInfo=aMsgQueue.Get();
+ }
+
+ return 0;
+}
+IMPL_LINK( ScAcceptChgDlg, ReOpenTimerHdl, Timer*, EMPTYARG )
+{
+ ScSimpleRefDlgWrapper::SetAutoReOpen(TRUE);
+ aAcceptChgCtr.ShowFilterPage();
+ RefHandle(NULL);
+
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, UpdateSelectionHdl, Timer*, EMPTYARG )
+{
+ ScTabView* pTabView = pViewData->GetView();
+
+ BOOL bAcceptFlag = TRUE;
+ BOOL bRejectFlag = TRUE;
+ BOOL bContMark = FALSE;
+
+ pTabView->DoneBlockMode(); // clears old marking
+ SvLBoxEntry* pEntry = pTheView->FirstSelected();
+ while( pEntry )
+ {
+ ScRedlinData* pEntryData = (ScRedlinData*) pEntry->GetUserData();
+ if( pEntryData )
+ {
+ bRejectFlag &= pEntryData->bIsRejectable;
+ bAcceptFlag &= pEntryData->bIsAcceptable;
+
+ const ScChangeAction* pScChangeAction = (ScChangeAction*) pEntryData->pData;
+ if( pScChangeAction && (pScChangeAction->GetType() != SC_CAT_DELETE_TABS) &&
+ (!pEntryData->bDisabled || pScChangeAction->IsVisible()) )
+ {
+ const ScBigRange& rBigRange = pScChangeAction->GetBigRange();
+ if( rBigRange.IsValid( pDoc ) && IsActive() )
+ {
+ BOOL bSetCursor = !pTheView->NextSelected( pEntry );
+ pTabView->MarkRange( rBigRange.MakeRange(), bSetCursor, bContMark );
+ bContMark = TRUE;
+ }
+ }
+ }
+ else
+ {
+ bAcceptFlag = FALSE;
+ bRejectFlag = FALSE;
+ }
+ bAcceptEnableFlag = bAcceptFlag;
+ bRejectEnableFlag = bRejectFlag;
+
+ pEntry = pTheView->NextSelected( pEntry );
+ }
+
+ ScChangeTrack* pChanges = pDoc->GetChangeTrack();
+ BOOL bEnable = pDoc->IsDocEditable() && pChanges && !pChanges->IsProtected();
+ pTPView->EnableAccept( bAcceptFlag && bEnable );
+ pTPView->EnableReject( bRejectFlag && bEnable );
+
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, CommandHdl, Control*, EMPTYARG )
+{
+
+ const CommandEvent aCEvt(pTheView->GetCommandEvent());
+
+ if(aCEvt.GetCommand()==COMMAND_CONTEXTMENU)
+ {
+ ScPopupMenu aPopup(ScResId(RID_POPUP_CHANGES));
+
+ aPopup.SetMenuFlags(MENU_FLAG_HIDEDISABLEDENTRIES);
+
+ SvLBoxEntry* pEntry=pTheView->GetCurEntry();
+ if(pEntry!=NULL)
+ {
+ pTheView->Select(pEntry);
+ }
+ else
+ {
+ aPopup.Deactivate();
+ }
+
+ USHORT nSortedCol= pTheView->GetSortedCol();
+
+ if(nSortedCol!=0xFFFF)
+ {
+ USHORT nItemId=nSortedCol+SC_SUB_SORT+1;
+
+ aPopup.CheckItem(nItemId);
+
+ PopupMenu *pSubMenu = aPopup.GetPopupMenu(SC_SUB_SORT);
+ if (pSubMenu)
+ {
+ pSubMenu->CheckItem(nItemId);
+ }
+ }
+
+ aPopup.EnableItem(SC_CHANGES_COMMENT,FALSE);
+
+ if(pDoc->IsDocEditable() && pEntry!=NULL)
+ {
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ ScChangeAction* pScChangeAction=
+ (ScChangeAction*) pEntryData->pData;
+ if(pScChangeAction!=NULL && !pTheView->GetParent(pEntry))
+ aPopup.EnableItem(SC_CHANGES_COMMENT);
+ }
+ }
+
+ USHORT nCommand=aPopup.Execute( this, GetPointerPosPixel() );
+
+
+ if(nCommand)
+ {
+ if(nCommand==SC_CHANGES_COMMENT)
+ {
+ if(pEntry!=NULL)
+ {
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ ScChangeAction* pScChangeAction=
+ (ScChangeAction*) pEntryData->pData;
+
+ pViewData->GetDocShell()->ExecuteChangeCommentDialog( pScChangeAction, this,FALSE);
+ }
+ }
+ }
+ else
+ {
+ BOOL bSortDir=pTheView->GetSortDirection();
+ USHORT nDialogCol=nCommand-SC_SUB_SORT-1;
+ if(nSortedCol==nDialogCol) bSortDir=!bSortDir;
+ pTheView->SortByCol(nDialogCol,bSortDir);
+ /*
+ SC_SUB_SORT
+ SC_SORT_ACTION
+ SC_SORT_POSITION
+ SC_SORT_AUTHOR
+ SC_SORT_DATE
+ SC_SORT_COMMENT
+ */
+ }
+ }
+ }
+ return 0;
+}
+
+void ScAcceptChgDlg::Initialize(SfxChildWinInfo *pInfo)
+{
+ String aStr;
+ if(pInfo!=NULL)
+ {
+ if ( pInfo->aExtraString.Len() )
+ {
+ xub_StrLen nPos = pInfo->aExtraString.Search(
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("AcceptChgDat:")));
+
+ // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn
+ // er nicht vorhanden ist, liegt eine "altere Version vor
+ if ( nPos != STRING_NOTFOUND )
+ {
+ xub_StrLen n1 = pInfo->aExtraString.Search('(', nPos);
+ if ( n1 != STRING_NOTFOUND )
+ {
+ xub_StrLen n2 = pInfo->aExtraString.Search(')', n1);
+ if ( n2 != STRING_NOTFOUND )
+ {
+ // Alignment-String herausschneiden
+ aStr = pInfo->aExtraString.Copy(nPos, n2 - nPos + 1);
+ pInfo->aExtraString.Erase(nPos, n2 - nPos + 1);
+ aStr.Erase(0, n1-nPos+1);
+ }
+ }
+ }
+ }
+ }
+ SfxModelessDialog::Initialize(pInfo);
+
+ if ( aStr.Len())
+ {
+ USHORT nCount=(USHORT)aStr.ToInt32();
+
+ for(USHORT i=0;i<nCount;i++)
+ {
+ xub_StrLen n1 = aStr.Search(';');
+ aStr.Erase(0, n1+1);
+ pTheView->SetTab(i,(USHORT)aStr.ToInt32(),MAP_PIXEL);
+ }
+ }
+}
+
+//-------------------------------------------------------------------------
+
+void ScAcceptChgDlg::FillInfo(SfxChildWinInfo& rInfo) const
+{
+ SfxModelessDialog::FillInfo(rInfo);
+ rInfo.aExtraString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "AcceptChgDat:(" ));
+
+ USHORT nCount=pTheView->TabCount();
+
+ rInfo.aExtraString += String::CreateFromInt32(nCount);
+ rInfo.aExtraString += ';';
+ for(USHORT i=0;i<nCount;i++)
+ {
+ rInfo.aExtraString += String::CreateFromInt32(pTheView->GetTab(i));
+ rInfo.aExtraString += ';';
+ }
+ rInfo.aExtraString += ')';
+}
+
+void ScAcceptChgDlg::InitFilter()
+{
+ if(pTPFilter->IsDate()||pTPFilter->IsRange()||
+ pTPFilter->IsAuthor()||pTPFilter->IsComment())
+ {
+ pTheView->SetFilterDate(pTPFilter->IsDate());
+ pTheView->SetDateTimeMode(pTPFilter->GetDateMode());
+ pTheView->SetFirstDate(pTPFilter->GetFirstDate());
+ pTheView->SetLastDate(pTPFilter->GetLastDate());
+ pTheView->SetFirstTime(pTPFilter->GetFirstTime());
+ pTheView->SetLastTime(pTPFilter->GetLastTime());
+ pTheView->SetFilterAuthor(pTPFilter->IsAuthor());
+ pTheView->SetAuthor(pTPFilter->GetSelectedAuthor());
+
+ pTheView->SetFilterComment(pTPFilter->IsComment());
+
+ utl::SearchParam aSearchParam( pTPFilter->GetComment(),
+ utl::SearchParam::SRCH_REGEXP,FALSE,FALSE,FALSE );
+
+ pTheView->SetCommentParams(&aSearchParam);
+
+ pTheView->UpdateFilterTest();
+ }
+}
+
+IMPL_LINK( ScAcceptChgDlg, FilterModified, SvxTPFilter*, EMPTYARG )
+{
+ return 0;
+}
+
+#define CALC_DATE 3
+#define CALC_POS 1
+
+IMPL_LINK( ScAcceptChgDlg, ColCompareHdl, SvSortData*, pSortData )
+{
+ StringCompare eCompare=COMPARE_EQUAL;
+ SCCOL nSortCol= static_cast<SCCOL>(pTheView->GetSortedCol());
+
+ if(pSortData)
+ {
+ SvLBoxEntry* pLeft = (SvLBoxEntry*)(pSortData->pLeft );
+ SvLBoxEntry* pRight = (SvLBoxEntry*)(pSortData->pRight );
+
+ if(CALC_DATE==nSortCol)
+ {
+ RedlinData *pLeftData=(RedlinData *)(pLeft->GetUserData());
+ RedlinData *pRightData=(RedlinData *)(pRight->GetUserData());
+
+ if(pLeftData!=NULL && pRightData!=NULL)
+ {
+ if(pLeftData->aDateTime < pRightData->aDateTime)
+ {
+ eCompare=COMPARE_LESS;
+ }
+ else if(pLeftData->aDateTime > pRightData->aDateTime)
+ {
+ eCompare=COMPARE_GREATER;
+ }
+ return eCompare;
+ }
+ }
+ else if(CALC_POS==nSortCol)
+ {
+ ScRedlinData *pLeftData=(ScRedlinData *)(pLeft->GetUserData());
+ ScRedlinData *pRightData=(ScRedlinData *)(pRight->GetUserData());
+
+ if(pLeftData!=NULL && pRightData!=NULL)
+ {
+ eCompare=COMPARE_GREATER;
+
+ if(pLeftData->nTable < pRightData->nTable)
+ {
+ eCompare=COMPARE_LESS;
+ }
+ else if(pLeftData->nTable == pRightData->nTable)
+ {
+ if(pLeftData->nRow < pRightData->nRow)
+ {
+ eCompare=COMPARE_LESS;
+ }
+ else if(pLeftData->nRow == pRightData->nRow)
+ {
+ if(pLeftData->nCol < pRightData->nCol)
+ {
+ eCompare=COMPARE_LESS;
+ }
+ else if(pLeftData->nCol == pRightData->nCol)
+ {
+ eCompare=COMPARE_EQUAL;
+ }
+ }
+ }
+
+ return eCompare;
+ }
+ }
+
+ SvLBoxItem* pLeftItem = pTheView->GetEntryAtPos( pLeft, static_cast<sal_uInt16>(nSortCol));
+ SvLBoxItem* pRightItem = pTheView->GetEntryAtPos( pRight, static_cast<sal_uInt16>(nSortCol));
+
+ if(pLeftItem != NULL && pRightItem != NULL)
+ {
+ USHORT nLeftKind=pLeftItem->IsA();
+ USHORT nRightKind=pRightItem->IsA();
+
+ if(nRightKind == SV_ITEM_ID_LBOXSTRING &&
+ nLeftKind == SV_ITEM_ID_LBOXSTRING )
+ {
+ eCompare= (StringCompare) ScGlobal::GetCaseCollator()->compareString(
+ ((SvLBoxString*)pLeftItem)->GetText(),
+ ((SvLBoxString*)pRightItem)->GetText());
+
+ if(eCompare==COMPARE_EQUAL) eCompare=COMPARE_LESS;
+ }
+ }
+
+
+ }
+ return eCompare;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/acredlin.src b/sc/source/ui/miscdlgs/acredlin.src
new file mode 100644
index 000000000000..dab2c5d91d2f
--- /dev/null
+++ b/sc/source/ui/miscdlgs/acredlin.src
@@ -0,0 +1,258 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "acredlin.hrc"
+ModelessDialog RID_SCDLG_CHANGES
+{
+ OutputSize = TRUE ;
+ HelpId = FID_CHG_ACCEPT ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 282 , 142 ) ;
+ Moveable = TRUE ;
+ Sizeable = TRUE ;
+ Closeable = TRUE ;
+ // Dieser Dialog hat einen Cancel-Button !
+ Control CTR_REDLINING
+ {
+ HelpId = HID_SC_REDLIN_CTR ;
+ Pos = MAP_APPFONT ( 2 , 2 ) ;
+ Size = MAP_APPFONT ( 270 , 105 ) ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 271 , 105 ) ;
+ Size = MAP_APPFONT ( 1 , 1 ) ;
+ TabStop = FALSE ;
+ };
+ FixedText FT_ASSIGN
+ {
+ Hide = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 105 ) ;
+ Size = MAP_APPFONT ( 128 , 12 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Range" ;
+ };
+ Edit ED_ASSIGN
+ {
+ Hide = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 119 ) ;
+ Size = MAP_APPFONT ( 128 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_ASSIGN
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 142 , 118 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Minimize/Maximize" ;
+ };
+ String STR_INSERT_COLS
+ {
+ Text [ en-US ] = "Column inserted" ;
+ };
+ String STR_INSERT_ROWS
+ {
+ Text [ en-US ] = "Row inserted " ;
+ };
+ String STR_INSERT_TABS
+ {
+ Text [ en-US ] = "Sheet inserted " ;
+ };
+ String STR_DELETE_COLS
+ {
+ Text [ en-US ] = "Column deleted" ;
+ };
+ String STR_DELETE_ROWS
+ {
+ Text [ en-US ] = "Row deleted" ;
+ };
+ String STR_DELETE_TABS
+ {
+ Text [ en-US ] = "Sheet deleted" ;
+ };
+ String STR_MOVE
+ {
+ Text [ en-US ] = "Range moved" ;
+ };
+ String STR_CONTENT
+ {
+ Text [ en-US ] = "Changed contents" ;
+ };
+ String STR_CONTENT_WITH_CHILD
+ {
+ Text [ en-US ] = "Changed contents" ;
+ };
+ String STR_CHILD_CONTENT
+ {
+ Text [ en-US ] = "Changed to " ;
+ };
+ String STR_CHILD_ORGCONTENT
+ {
+ Text [ en-US ] = "Original" ;
+ };
+ String STR_REJECT
+ {
+ Text [ en-US ] = "Changes rejected" ;
+ };
+ String STR_ACCEPTED
+ {
+ Text [ en-US ] = "Accepted" ;
+ };
+ String STR_REJECTED
+ {
+ Text [ en-US ] = "Rejected" ;
+ };
+ String STR_NO_ENTRY
+ {
+ Text [ en-US ] = "No Entry" ;
+ };
+ String STR_EMPTY
+ {
+ Text [ en-US ] = "<empty>" ;
+ };
+ Bitmap BMP_STR_CLOSE
+ {
+ File = "dir-clos.bmp" ;
+ };
+ Bitmap BMP_STR_OPEN
+ {
+ File = "dir-open.bmp" ;
+ };
+ Bitmap BMP_STR_END
+ {
+ File = "basobj2.bmp" ;
+ };
+ Bitmap BMP_STR_ERROR
+ {
+ File = "basbrk.bmp" ;
+ };
+ Text [ en-US ] = "Accept or Reject Changes" ;
+};
+Menu RID_POPUP_CHANGES
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SC_CHANGES_COMMENT ;
+ HelpId = HID_SC_CHANGES_COMMENT ;
+ Text [ en-US ] = "Edit Comment..." ;
+
+ };
+ MenuItem
+ {
+ Identifier = SC_SUB_SORT ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SC_SORT_ACTION ;
+ HelpID = HID_SC_SORT_ACTION ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Action" ;
+ };
+ MenuItem
+ {
+ Identifier = SC_SORT_POSITION ;
+ HelpID = HID_SORT_POSITION ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Position" ;
+ };
+ MenuItem
+ {
+ Identifier = SC_SORT_AUTHOR ;
+ HelpID = HID_SC_SORT_AUTHOR ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Author" ;
+ };
+ MenuItem
+ {
+ Identifier = SC_SORT_DATE ;
+ HelpID = HID_SC_SORT_DATE ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Date" ;
+ };
+ MenuItem
+ {
+ Identifier = SC_SORT_COMMENT ;
+ HelpID = HID_SC_SORT_COMMENT ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Description" ;
+ };
+ };
+ };
+ Text [ en-US ] = "Sorting" ;
+ };
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
new file mode 100644
index 000000000000..09d4a4d50b52
--- /dev/null
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -0,0 +1,1013 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "rangelst.hxx"
+#include <sfx2/app.hxx>
+#include <sfx2/viewsh.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/mnemonic.hxx>
+#include <tools/shl.hxx>
+#include <svtools/taskbar.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+
+
+#define ANYREFDG_CXX
+#include "anyrefdg.hxx"
+#undef ANYREFDG_CXX
+
+#include "sc.hrc"
+#include "inputhdl.hxx"
+#include "scmod.hxx"
+#include "scresid.hxx"
+#include "inputwin.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "rfindlst.hxx"
+#include "compiler.hxx"
+#include "cell.hxx"
+#include "global.hxx"
+#include "inputopt.hxx"
+#include "rangeutl.hxx"
+
+
+ScFormulaReferenceHelper::ScFormulaReferenceHelper(IAnyRefDialog* _pDlg,SfxBindings* _pBindings)
+ : m_pDlg(_pDlg)
+ , pRefEdit (NULL)
+ , m_pWindow(NULL)
+ , m_pBindings(_pBindings)
+ , pAccel( NULL )
+ , pHiddenMarks(NULL)
+ , nRefTab(0)
+ , bHighLightRef( FALSE )
+ , bAccInserted( FALSE )
+{
+ ScInputOptions aInputOption=SC_MOD()->GetInputOptions();
+ bEnableColorRef=aInputOption.GetRangeFinder();
+}
+// -----------------------------------------------------------------------------
+ScFormulaReferenceHelper::~ScFormulaReferenceHelper()
+{
+ if (bAccInserted)
+ Application::RemoveAccel( pAccel.get() );
+
+ // common cleanup for ScAnyRefDlg and ScFormulaDlg is done here
+
+ HideReference();
+ enableInput( TRUE );
+
+ ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
+ if ( pInputHdl )
+ pInputHdl->ResetDelayTimer(); // stop the timer for disabling the input line
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::enableInput( BOOL bEnable )
+{
+ TypeId aType(TYPE(ScDocShell));
+ ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
+ while( pDocShell )
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+ while( pFrame )
+ {
+ // #71577# enable everything except InPlace, including bean frames
+ if ( !pFrame->GetFrame().IsInPlace() )
+ {
+ SfxViewShell* p = pFrame->GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
+ if(pViewSh!=NULL)
+ {
+ Window *pWin=pViewSh->GetWindow();
+ if(pWin)
+ {
+ Window *pParent=pWin->GetParent();
+ if(pParent)
+ {
+ pParent->EnableInput(bEnable,TRUE /* FALSE */);
+ if(TRUE /*bChilds*/)
+ pViewSh->EnableRefInput(bEnable);
+ }
+ }
+ }
+ }
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
+ }
+
+ pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::ShowSimpleReference( const XubString& rStr )
+{
+ if( /*!pRefEdit &&*/ bEnableColorRef )
+ {
+ bHighLightRef=TRUE;
+ ScViewData* pViewData=ScDocShell::GetViewData();
+ if ( pViewData )
+ {
+ ScDocument* pDoc=pViewData->GetDocument();
+ ScTabViewShell* pTabViewShell=pViewData->GetViewShell();
+
+ ScRangeList aRangeList;
+
+ pTabViewShell->DoneRefMode( FALSE );
+ pTabViewShell->ClearHighlightRanges();
+
+ if( ParseWithNames( aRangeList, rStr, pDoc ) )
+ {
+ ScRange* pRangeEntry = aRangeList.First();
+
+ USHORT nIndex=0;
+ while(pRangeEntry != NULL)
+ {
+ ColorData aColName = ScRangeFindList::GetColorName(nIndex++);
+ pTabViewShell->AddHighlightRange(*pRangeEntry, aColName);
+
+ pRangeEntry = aRangeList.Next();
+ }
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+bool ScFormulaReferenceHelper::ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc )
+{
+ bool bError = false;
+ rRanges.RemoveAll();
+
+ ScAddress::Details aDetails(pDoc->GetAddressConvention(), 0, 0);
+ ScRangeUtil aRangeUtil;
+ xub_StrLen nTokenCnt = rStr.GetTokenCount();
+ for( xub_StrLen nToken = 0; nToken < nTokenCnt; ++nToken )
+ {
+ ScRange aRange;
+ String aRangeStr( rStr.GetToken( nToken ) );
+
+ USHORT nFlags = aRange.ParseAny( aRangeStr, pDoc, aDetails );
+ if ( nFlags & SCA_VALID )
+ {
+ if ( (nFlags & SCA_TAB_3D) == 0 )
+ aRange.aStart.SetTab( nRefTab );
+ if ( (nFlags & SCA_TAB2_3D) == 0 )
+ aRange.aEnd.SetTab( aRange.aStart.Tab() );
+ rRanges.Append( aRange );
+ }
+ else if ( aRangeUtil.MakeRangeFromName( aRangeStr, pDoc, nRefTab, aRange, RUTL_NAMES, aDetails ) )
+ rRanges.Append( aRange );
+ else
+ bError = true;
+ }
+
+ return !bError;
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::ShowFormulaReference( const XubString& rStr )
+{
+ if( /*!pRefEdit &&*/ bEnableColorRef)
+ {
+ bHighLightRef=TRUE;
+ ScViewData* pViewData=ScDocShell::GetViewData();
+ if ( pViewData && pRefComp.get() )
+ {
+ ScTabViewShell* pTabViewShell=pViewData->GetViewShell();
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+ ScAddress aPos( nCol, nRow, nTab );
+
+ ScTokenArray* pScTokA=pRefComp->CompileString(rStr);
+ //pRefComp->CompileTokenArray();
+
+ if(pTabViewShell!=NULL && pScTokA!=NULL)
+ {
+ pTabViewShell->DoneRefMode( FALSE );
+ pTabViewShell->ClearHighlightRanges();
+
+ pScTokA->Reset();
+ const ScToken* pToken = static_cast<const ScToken*>(pScTokA->GetNextReference());
+
+ USHORT nIndex=0;
+
+ while(pToken!=NULL)
+ {
+ BOOL bDoubleRef=(pToken->GetType()==formula::svDoubleRef);
+
+
+ if(pToken->GetType()==formula::svSingleRef || bDoubleRef)
+ {
+ ScRange aRange;
+ if(bDoubleRef)
+ {
+ ScComplexRefData aRef( pToken->GetDoubleRef() );
+ aRef.CalcAbsIfRel( aPos );
+ aRange.aStart.Set( aRef.Ref1.nCol, aRef.Ref1.nRow, aRef.Ref1.nTab );
+ aRange.aEnd.Set( aRef.Ref2.nCol, aRef.Ref2.nRow, aRef.Ref2.nTab );
+ }
+ else
+ {
+ ScSingleRefData aRef( pToken->GetSingleRef() );
+ aRef.CalcAbsIfRel( aPos );
+ aRange.aStart.Set( aRef.nCol, aRef.nRow, aRef.nTab );
+ aRange.aEnd = aRange.aStart;
+ }
+ ColorData aColName=ScRangeFindList::GetColorName(nIndex++);
+ pTabViewShell->AddHighlightRange(aRange, aColName);
+ }
+
+ pToken = static_cast<const ScToken*>(pScTokA->GetNextReference());
+ }
+ }
+ if(pScTokA!=NULL) delete pScTokA;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::HideReference( BOOL bDoneRefMode )
+{
+ ScViewData* pViewData=ScDocShell::GetViewData();
+
+ if( pViewData && /*!pRefEdit &&*/ bHighLightRef && bEnableColorRef)
+ {
+ ScTabViewShell* pTabViewShell=pViewData->GetViewShell();
+
+ if(pTabViewShell!=NULL)
+ {
+ // bDoneRefMode is FALSE when called from before SetReference.
+ // In that case, RefMode was just started and must not be ended now.
+
+ if ( bDoneRefMode )
+ pTabViewShell->DoneRefMode( FALSE );
+ pTabViewShell->ClearHighlightRanges();
+ }
+ bHighLightRef=FALSE;
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::ShowReference( const XubString& rStr )
+{
+ if( /*!pRefEdit &&*/ bEnableColorRef )
+ {
+ if( rStr.Search('(')!=STRING_NOTFOUND ||
+ rStr.Search('+')!=STRING_NOTFOUND ||
+ rStr.Search('*')!=STRING_NOTFOUND ||
+ rStr.Search('-')!=STRING_NOTFOUND ||
+ rStr.Search('/')!=STRING_NOTFOUND ||
+ rStr.Search('&')!=STRING_NOTFOUND ||
+ rStr.Search('<')!=STRING_NOTFOUND ||
+ rStr.Search('>')!=STRING_NOTFOUND ||
+ rStr.Search('=')!=STRING_NOTFOUND ||
+ rStr.Search('^')!=STRING_NOTFOUND)
+ {
+ ShowFormulaReference(rStr);
+ }
+ else
+ {
+ ShowSimpleReference(rStr);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ if( !pRefEdit && pEdit )
+ {
+ m_pDlg->RefInputStart( pEdit, pButton );
+// if( pRefEdit )
+// pRefEdit->SilentGrabFocus();
+ }
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if( pViewShell )
+ {
+ pViewShell->ActiveGrabFocus();
+ if( pRefEdit )
+ {
+ const ScViewData* pViewData = pViewShell->GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScRangeList aRangeList;
+ if( ParseWithNames( aRangeList, pRefEdit->GetText(), pDoc ) )
+ {
+ const ScRange* pRange = aRangeList.GetObject( 0 );
+ if( pRange )
+ {
+ pViewShell->SetTabNo( pRange->aStart.Tab() );
+ pViewShell->MoveCursorAbs( pRange->aStart.Col(),
+ pRange->aStart.Row(), SC_FOLLOW_JUMP, FALSE, FALSE );
+ pViewShell->MoveCursorAbs( pRange->aEnd.Col(),
+ pRange->aEnd.Row(), SC_FOLLOW_JUMP, TRUE, FALSE );
+ m_pDlg->SetReference( *pRange, pDoc );
+ }
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::Init()
+{
+ ScViewData* pViewData=ScDocShell::GetViewData(); //! use pScViewShell?
+ if ( pViewData )
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+ ScAddress aCursorPos( nCol, nRow, nTab );
+
+ String rStrExp;
+ pRefCell.reset( new ScFormulaCell( pDoc, aCursorPos, rStrExp ) );
+ pRefComp.reset( new ScCompiler( pDoc, aCursorPos) );
+ pRefComp->SetGrammar( pDoc->GetGrammar() );
+ pRefComp->SetCompileForFAP(TRUE);
+
+ nRefTab = nTab;
+ } // if ( pViewData )
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( ScFormulaReferenceHelper, AccelSelectHdl, Accelerator *, pSelAccel )
+{
+ if ( !pSelAccel )
+ return 0;
+
+ switch ( pSelAccel->GetCurKeyCode().GetCode() )
+ {
+ case KEY_RETURN:
+ case KEY_ESCAPE:
+ if( pRefEdit )
+ pRefEdit->GrabFocus();
+ m_pDlg->RefInputDone( TRUE );
+ break;
+ }
+ return TRUE;
+}
+//----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::RefInputDone( BOOL bForced )
+{
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //if (pRefEdit && (bForced || !pRefBtn))
+ if ( CanInputDone( bForced ) )//if (pRefEdit && (bForced || !pRefBtn))
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ {
+ if (bAccInserted) // Accelerator wieder abschalten
+ {
+ Application::RemoveAccel( pAccel.get() );
+ bAccInserted = FALSE;
+ }
+
+ // Fenstertitel anpassen
+ m_pWindow->SetText(sOldDialogText);
+
+ // Fenster wieder gross
+ m_pWindow->SetOutputSizePixel(aOldDialogSize);
+
+ // pEditCell an alte Position
+ pRefEdit->SetPosSizePixel(aOldEditPos, aOldEditSize);
+
+ // set button position and image
+ if( pRefBtn )
+ {
+ pRefBtn->SetPosPixel( aOldButtonPos );
+ pRefBtn->SetStartImage();
+ }
+
+ // Alle anderen: Show();
+ USHORT nChildren = m_pWindow->GetChildCount();
+ for ( USHORT i = 0; i < nChildren; i++ )
+ if (pHiddenMarks[i])
+ {
+ m_pWindow->GetChild(i)->GetWindow( WINDOW_CLIENT )->Show();
+ }
+ delete [] pHiddenMarks;
+
+ pRefEdit = NULL;
+ pRefBtn = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ if (!pRefEdit)
+ {
+ pRefEdit = pEdit;
+ pRefBtn = pButton;
+
+ // Neuen Fenstertitel basteln
+ String sNewDialogText;
+ sOldDialogText = m_pWindow->GetText();
+ sNewDialogText = sOldDialogText;
+ sNewDialogText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
+
+ // Alle Elemente ausser EditCell und Button verstecken
+ USHORT nChildren = m_pWindow->GetChildCount();
+ pHiddenMarks = new BOOL [nChildren];
+ for (USHORT i = 0; i < nChildren; i++)
+ {
+ pHiddenMarks[i] = FALSE;
+ Window* pWin = m_pWindow->GetChild(i);
+ pWin = pWin->GetWindow( WINDOW_CLIENT );
+ if (pWin == (Window*)pRefEdit)
+ {
+ sNewDialogText += m_pWindow->GetChild(i-1)->GetWindow( WINDOW_CLIENT )->GetText();
+ }
+ else if (pWin == (Window*)pRefBtn)
+ ; // do nothing
+ else if (pWin->IsVisible())
+ {
+ pHiddenMarks[i] = TRUE;
+ pWin->Hide();
+ }
+ }
+
+ // Alte Daten merken
+ aOldDialogSize = m_pWindow->GetOutputSizePixel();
+ aOldEditPos = pRefEdit->GetPosPixel();
+ aOldEditSize = pRefEdit->GetSizePixel();
+ if (pRefBtn)
+ aOldButtonPos = pRefBtn->GetPosPixel();
+
+ // Edit-Feld verschieben und anpassen
+ Size aNewDlgSize(aOldDialogSize.Width(), aOldEditSize.Height());
+ Size aNewEditSize(aNewDlgSize);
+ long nOffset = 0;
+ if (pRefBtn)
+ {
+ aNewEditSize.Width() -= pRefBtn->GetSizePixel().Width();
+ aNewEditSize.Width() -= aOldButtonPos.X() - (aOldEditPos.X()+aOldEditSize.Width());
+
+ long nHeight = pRefBtn->GetSizePixel().Height();
+ if ( nHeight > aOldEditSize.Height() )
+ {
+ aNewDlgSize.Height() = nHeight;
+ nOffset = (nHeight-aOldEditSize.Height()) / 2;
+ }
+ aNewEditSize.Width() -= nOffset;
+ }
+ pRefEdit->SetPosSizePixel(Point(nOffset, nOffset), aNewEditSize);
+
+ // set button position and image
+ if( pRefBtn )
+ {
+ pRefBtn->SetPosPixel( Point( aOldDialogSize.Width() - pRefBtn->GetSizePixel().Width(), 0 ) );
+ pRefBtn->SetEndImage();
+ }
+
+ // Fenster verkleinern
+ m_pWindow->SetOutputSizePixel(aNewDlgSize);
+
+ // Fenstertitel anpassen
+ m_pWindow->SetText( MnemonicGenerator::EraseAllMnemonicChars( sNewDialogText ) );
+
+// if ( pButton ) // ueber den Button: Enter und Escape abfangen
+// {
+ if (!pAccel.get())
+ {
+ pAccel.reset( new Accelerator );
+ pAccel->InsertItem( 1, KeyCode( KEY_RETURN ) );
+ pAccel->InsertItem( 2, KeyCode( KEY_ESCAPE ) );
+ pAccel->SetSelectHdl( LINK( this, ScFormulaReferenceHelper, AccelSelectHdl ) );
+ }
+ Application::InsertAccel( pAccel.get() );
+ bAccInserted = TRUE;
+// }
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ if( pEdit )
+ {
+ if( pRefEdit == pEdit ) // is this the active ref edit field?
+ {
+ pRefEdit->GrabFocus(); // before RefInputDone()
+ m_pDlg->RefInputDone( TRUE ); // finish ref input
+ }
+ else
+ {
+ m_pDlg->RefInputDone( TRUE ); // another active ref edit?
+ m_pDlg->RefInputStart( pEdit, pButton ); // start ref input
+ // pRefEdit might differ from pEdit after RefInputStart() (i.e. ScFormulaDlg)
+ if( pRefEdit )
+ pRefEdit->GrabFocus();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+BOOL ScFormulaReferenceHelper::DoClose( USHORT nId )
+{
+ SfxApplication* pSfxApp = SFX_APP();
+
+ SetDispatcherLock( FALSE ); //! here and in dtor ?
+
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if ( pViewFrm && pViewFrm->HasChildWindow(FID_INPUTLINE_STATUS) )
+ {
+ // Die Eingabezeile wird per ToolBox::Disable disabled, muss darum auch
+ // per ToolBox::Enable wieder aktiviert werden (vor dem Enable des AppWindow),
+ // damit die Buttons auch wieder enabled gezeichnet werden.
+ SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_INPUTLINE_STATUS);
+ if (pChild)
+ {
+ ScInputWindow* pWin = (ScInputWindow*)pChild->GetWindow();
+ pWin->Enable();
+ }
+ }
+
+ // find parent view frame to close dialog
+ SfxViewFrame* pMyViewFrm = NULL;
+ if ( m_pBindings )
+ {
+ SfxDispatcher* pMyDisp = m_pBindings->GetDispatcher();
+ if (pMyDisp)
+ pMyViewFrm = pMyDisp->GetFrame();
+ }
+ SC_MOD()->SetRefDialog( nId, FALSE, pMyViewFrm );
+
+ pSfxApp->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) );
+
+ ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
+ if ( pScViewShell )
+ pScViewShell->UpdateInputHandler(TRUE);
+
+ return TRUE;
+}
+void ScFormulaReferenceHelper::SetDispatcherLock( BOOL bLock )
+{
+ // lock / unlock only the dispatchers of Calc documents
+
+ TypeId aType(TYPE(ScDocShell));
+ ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
+ while( pDocShell )
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+ while( pFrame )
+ {
+ SfxDispatcher* pDisp = pFrame->GetDispatcher();
+ if (pDisp)
+ pDisp->Lock( bLock );
+
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
+ }
+ pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
+ }
+
+ // if a new view is created while the dialog is open,
+ // that view's dispatcher is locked when trying to create the dialog
+ // for that view (ScTabViewShell::CreateRefDialog)
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::ViewShellChanged(ScTabViewShell* /* pScViewShell */)
+{
+ enableInput( FALSE );
+
+ EnableSpreadsheets();
+}
+void ScFormulaReferenceHelper::EnableSpreadsheets(BOOL bFlag, BOOL bChilds)
+{
+ TypeId aType(TYPE(ScDocShell));
+ ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
+ while( pDocShell )
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+ while( pFrame )
+ {
+ // #71577# enable everything except InPlace, including bean frames
+ if ( !pFrame->GetFrame().IsInPlace() )
+ {
+ SfxViewShell* p = pFrame->GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
+ if(pViewSh!=NULL)
+ {
+ Window *pWin=pViewSh->GetWindow();
+ if(pWin)
+ {
+ Window *pParent=pWin->GetParent();
+ if(pParent)
+ {
+ pParent->EnableInput(bFlag,FALSE);
+ if(bChilds)
+ pViewSh->EnableRefInput(bFlag);
+ }
+ }
+ }
+ }
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
+ }
+
+ pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
+ }
+}
+
+//----------------------------------------------------------------------------
+
+
+
+void lcl_InvalidateWindows()
+{
+ TypeId aType(TYPE(ScDocShell));
+ ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
+ while( pDocShell )
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+ while( pFrame )
+ {
+ // #71577# enable everything except InPlace, including bean frames
+ if ( !pFrame->GetFrame().IsInPlace() )
+ {
+ SfxViewShell* p = pFrame->GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
+ if(pViewSh!=NULL)
+ {
+ Window *pWin=pViewSh->GetWindow();
+ if(pWin)
+ {
+ Window *pParent=pWin->GetParent();
+ if(pParent)
+ pParent->Invalidate();
+ }
+ }
+ }
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
+ }
+
+ pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
+ }
+}
+//----------------------------------------------------------------------------
+
+void lcl_HideAllReferences()
+{
+ TypeId aScType = TYPE(ScTabViewShell);
+ SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
+ while ( pSh )
+ {
+ ((ScTabViewShell*)pSh)->ClearHighlightRanges();
+ pSh = SfxViewShell::GetNext( *pSh, &aScType );
+ }
+}
+
+//============================================================================
+//The class of ScAnyRefDlg is rewritten by PengYunQuan for Validity Cell Range Picker
+// class ScRefHandler
+//----------------------------------------------------------------------------
+
+ScRefHandler::ScRefHandler( Window &rWindow, SfxBindings* pB/*, SfxChildWindow* pCW,
+ Window* pParent, USHORT nResId*/, bool bBindRef )
+ : //SfxModelessDialog ( pB, pCW, pParent, ScResId( nResId ) ),
+ m_rWindow( rWindow ),
+ m_bInRefMode( false ),
+ m_aHelper(this,pB),
+ pMyBindings( pB ),
+ pActiveWin(NULL)
+{
+ m_aHelper.SetWindow(/*this*/&m_rWindow);
+ if(m_rWindow.GetHelpId()==0) //Hack, da im SfxModelessDialog die HelpId
+ m_rWindow.SetHelpId(m_rWindow.GetUniqueId()); //fuer einen ModelessDialog entfernt und
+ //in eine UniqueId gewandelt wird, machen
+ //wir das an dieser Stelle rueckgaengig.
+ aTimer.SetTimeout(200);
+ aTimer.SetTimeoutHdl(LINK( this, ScRefHandler, UpdateFocusHdl));
+
+ if( bBindRef ) EnterRefMode();
+}
+
+bool ScRefHandler::EnterRefMode()
+{
+ if( m_bInRefMode ) return false;
+
+ SC_MOD()->InputEnterHandler();
+// ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
+
+ ScTabViewShell* pScViewShell = NULL;
+
+ // title has to be from the view that opened the dialog,
+ // even if it's not the current view
+
+ SfxObjectShell* pParentDoc = NULL;
+ if ( pMyBindings )
+ {
+ SfxDispatcher* pMyDisp = pMyBindings->GetDispatcher();
+ if (pMyDisp)
+ {
+ SfxViewFrame* pMyViewFrm = pMyDisp->GetFrame();
+ if (pMyViewFrm)
+ {
+ pScViewShell = PTR_CAST( ScTabViewShell, pMyViewFrm->GetViewShell() );
+ if( pScViewShell )
+ pScViewShell->UpdateInputHandler(TRUE);
+ pParentDoc = pMyViewFrm->GetObjectShell();
+ }
+ }
+ }
+ if ( !pParentDoc && pScViewShell ) // use current only if above fails
+ pParentDoc = pScViewShell->GetObjectShell();
+ if ( pParentDoc )
+ aDocName = pParentDoc->GetTitle();
+
+ ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(pScViewShell);
+
+ DBG_ASSERT( pInputHdl, "Missing input handler :-/" );
+
+ if ( pInputHdl )
+ pInputHdl->NotifyChange( NULL );
+
+ m_aHelper.enableInput( FALSE );
+
+ m_aHelper.EnableSpreadsheets();
+
+ m_aHelper.Init();
+
+ m_aHelper.SetDispatcherLock( TRUE );
+ //@Test
+ //SFX_APPWINDOW->Disable(TRUE); //@BugID 54702
+
+ return m_bInRefMode = true;
+}
+
+//----------------------------------------------------------------------------
+
+ScRefHandler::~ScRefHandler()
+{
+ LeaveRefMode();
+}
+
+bool ScRefHandler::LeaveRefMode()
+{
+ if( !m_bInRefMode ) return false;
+
+ lcl_HideAllReferences();
+
+ if( Dialog *pDlg = dynamic_cast<Dialog*>( static_cast<Window*>(*this) ) )
+ pDlg->SetModalInputMode(FALSE);
+ SetDispatcherLock( FALSE ); //! here and in DoClose ?
+
+ ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
+ if( pScViewShell )
+ pScViewShell->UpdateInputHandler(TRUE);
+
+ //SFX_APPWINDOW->Enable(TRUE,TRUE);
+ lcl_InvalidateWindows();
+
+ m_bInRefMode = false;
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+//SfxBindings& ScRefHandler::GetBindings()
+//{
+// //! SfxModelessDialog should allow access to pBindings pointer
+//
+// return *pMyBindings;
+//}
+
+//----------------------------------------------------------------------------
+
+void ScRefHandler::SwitchToDocument()
+{
+ ScTabViewShell* pCurrent = ScTabViewShell::GetActiveViewShell();
+ if (pCurrent)
+ {
+ SfxObjectShell* pObjSh = pCurrent->GetObjectShell();
+ if ( pObjSh && pObjSh->GetTitle() == aDocName )
+ {
+ // right document already visible -> nothing to do
+ return;
+ }
+ }
+
+ TypeId aScType = TYPE(ScTabViewShell);
+ SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
+ while ( pSh )
+ {
+ SfxObjectShell* pObjSh = pSh->GetObjectShell();
+ if ( pObjSh && pObjSh->GetTitle() == aDocName )
+ {
+ // switch to first TabViewShell for document
+ ((ScTabViewShell*)pSh)->SetActive();
+ return;
+ }
+ pSh = SfxViewShell::GetNext( *pSh, &aScType );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScRefHandler::IsDocAllowed(SfxObjectShell* pDocSh) const // pDocSh may be 0
+{
+ // default: allow only same document (overridden in function dialog)
+ String aCmpName;
+ if ( pDocSh )
+ aCmpName = pDocSh->GetTitle();
+
+ // if aDocName isn't initialized, allow
+ return ( aDocName.Len() == 0 || aDocName == aCmpName );
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScRefHandler::IsRefInputMode() const
+{
+ return m_rWindow.IsVisible(); // nur wer sichtbar ist kann auch Referenzen bekommen
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScRefHandler::DoClose( USHORT nId )
+{
+ m_aHelper.DoClose(nId);
+ return TRUE;
+}
+
+void ScRefHandler::SetDispatcherLock( BOOL bLock )
+{
+ m_aHelper.SetDispatcherLock( bLock );
+}
+
+//----------------------------------------------------------------------------
+
+void ScRefHandler::ViewShellChanged(ScTabViewShell* pScViewShell )
+{
+ m_aHelper.ViewShellChanged(pScViewShell);
+}
+
+//----------------------------------------------------------------------------
+
+void ScRefHandler::AddRefEntry()
+{
+ // wenn nicht ueberladen, gibt es keine Mehrfach-Referenzen
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScRefHandler::IsTableLocked() const
+{
+ // per Default kann bei Referenzeingabe auch die Tabelle umgeschaltet werden
+
+ return FALSE;
+}
+
+//----------------------------------------------------------------------------
+//
+// RefInputStart/Done: Zoom-In (AutoHide) auf einzelnes Feld
+// (per Button oder Bewegung)
+//
+//----------------------------------------------------------------------------
+
+void ScRefHandler::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ m_aHelper.RefInputStart( pEdit, pButton );
+}
+
+
+void ScRefHandler::ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ m_aHelper.ToggleCollapsed( pEdit, pButton );
+}
+
+//The two following function is commentted out by PengYunQuan for Validity Cell Range Picker
+//long ScAnyRefDlg::PreNotify( NotifyEvent& rNEvt )
+//{
+// USHORT nSwitch=rNEvt.GetType();
+// if(nSwitch==EVENT_GETFOCUS)
+// {
+// pActiveWin=rNEvt.GetWindow();
+// }
+// return SfxModelessDialog::PreNotify(rNEvt);
+//}
+//
+//void ScAnyRefDlg::StateChanged( StateChangedType nStateChange )
+//{
+// SfxModelessDialog::StateChanged( nStateChange );
+//
+// if(nStateChange == STATE_CHANGE_VISIBLE)
+// {
+// if(IsVisible())
+// {
+// m_aHelper.enableInput( FALSE );
+// m_aHelper.EnableSpreadsheets();
+// m_aHelper.SetDispatcherLock( TRUE );
+// aTimer.Start();
+// }
+// else
+// {
+// m_aHelper.enableInput( TRUE );
+// m_aHelper.SetDispatcherLock( FALSE ); //! here and in DoClose ?
+// }
+// }
+//}
+
+#if defined( _MSC_VER )
+#define INTRODUCE_TEMPLATE
+#else
+#define INTRODUCE_TEMPLATE template <>
+#endif
+
+#define IMPL_TWINDOW_PRENOTIFY( TWindow,bBindRef ) \
+INTRODUCE_TEMPLATE long ScRefHdlrImplBase<TWindow,bBindRef>::PreNotify( NotifyEvent& rNEvt )\
+{\
+ if( bBindRef || m_bInRefMode )\
+ {\
+ USHORT nSwitch=rNEvt.GetType();\
+ if(nSwitch==EVENT_GETFOCUS)\
+ {\
+ pActiveWin=rNEvt.GetWindow();\
+ }\
+ }\
+ return TWindow::PreNotify(rNEvt);\
+}
+
+#define IMPL_TWINDOW_STATECHANGED( TWindow,bBindRef ) \
+INTRODUCE_TEMPLATE void ScRefHdlrImplBase<TWindow,bBindRef>::StateChanged( StateChangedType nStateChange )\
+{\
+ TWindow::StateChanged( nStateChange );\
+\
+ if( !bBindRef && !m_bInRefMode ) return;\
+ \
+ if(nStateChange == STATE_CHANGE_VISIBLE)\
+ {\
+ if(m_rWindow.IsVisible())\
+ {\
+ m_aHelper.enableInput( FALSE );\
+ m_aHelper.EnableSpreadsheets();\
+ m_aHelper.SetDispatcherLock( TRUE );\
+ aTimer.Start();\
+ }\
+ else\
+ {\
+ m_aHelper.enableInput( TRUE );\
+ m_aHelper.SetDispatcherLock( FALSE ); /*//! here and in DoClose ?*/\
+ }\
+ }\
+}
+
+IMPL_TWINDOW_PRENOTIFY( SfxModelessDialog, true )
+IMPL_TWINDOW_PRENOTIFY( SfxTabDialog, false )
+IMPL_TWINDOW_STATECHANGED( SfxModelessDialog, true )
+IMPL_TWINDOW_STATECHANGED( SfxTabDialog, false )
+
+IMPL_LINK( ScRefHandler, UpdateFocusHdl, Timer*, EMPTYARG )
+{
+ if (pActiveWin)
+ {
+ pActiveWin->GrabFocus();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+bool ScRefHandler::ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc )
+{
+ return m_aHelper.ParseWithNames( rRanges, rStr, pDoc );
+}
+// -----------------------------------------------------------------------------
+void ScRefHandler::HideReference( BOOL bDoneRefMode )
+{
+ m_aHelper.HideReference( bDoneRefMode );
+}
+// -----------------------------------------------------------------------------
+void ScRefHandler::ShowReference( const XubString& rStr )
+{
+ m_aHelper.ShowReference( rStr );
+}
+// -----------------------------------------------------------------------------
+void ScRefHandler::ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ m_aHelper.ReleaseFocus( pEdit,pButton );
+}
+//----------------------------------------------------------------------------
+void ScRefHandler::RefInputDone( BOOL bForced )
+{
+ m_aHelper.RefInputDone( bForced );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx
new file mode 100644
index 000000000000..12a332fd02f9
--- /dev/null
+++ b/sc/source/ui/miscdlgs/autofmt.cxx
@@ -0,0 +1,569 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svx/algitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <vcl/svapp.hxx>
+#include <svl/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include "sc.hrc"
+#include "scmod.hxx"
+#include "attrib.hxx"
+#include "zforauto.hxx"
+#include "scitems.hxx"
+#include "global.hxx"
+#include "globstr.hrc"
+#include "autoform.hxx"
+#include "miscdlgs.hrc"
+#include "autofmt.hxx"
+#include "scresid.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+
+#define FRAME_OFFSET 4
+
+
+//========================================================================
+// ScAutoFmtPreview
+
+ScAutoFmtPreview::ScAutoFmtPreview( Window* pParent, const ResId& rRes, ScDocument* pDoc ) :
+ Window ( pParent, rRes ),
+ pCurData ( NULL ),
+ aVD ( *this ),
+ aScriptedText ( aVD ),
+ xBreakIter ( pDoc->GetBreakIterator() ),
+ bFitWidth ( FALSE ),
+ mbRTL ( false ),
+ aPrvSize ( GetSizePixel().Width() - 6, GetSizePixel().Height() - 30 ),
+ mnLabelColWidth ( (aPrvSize.Width() - 4) / 4 - 12 ),
+ mnDataColWidth1 ( (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 3 ),
+ mnDataColWidth2 ( (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 4 ),
+ mnRowHeight ( (aPrvSize.Height() - 4) / 5 ),
+ aStrJan ( ScResId( STR_JAN ) ),
+ aStrFeb ( ScResId( STR_FEB ) ),
+ aStrMar ( ScResId( STR_MAR ) ),
+ aStrNorth ( ScResId( STR_NORTH ) ),
+ aStrMid ( ScResId( STR_MID ) ),
+ aStrSouth ( ScResId( STR_SOUTH ) ),
+ aStrSum ( ScResId( STR_SUM ) ),
+ pNumFmt ( new SvNumberFormatter( ::comphelper::getProcessServiceFactory(), ScGlobal::eLnge ) )
+{
+ Init();
+}
+
+//------------------------------------------------------------------------
+
+ScAutoFmtPreview::~ScAutoFmtPreview()
+{
+ delete pNumFmt;
+}
+
+//------------------------------------------------------------------------
+
+void lcl_SetFontProperties(
+ Font& rFont,
+ const SvxFontItem& rFontItem,
+ const SvxWeightItem& rWeightItem,
+ const SvxPostureItem& rPostureItem )
+{
+ rFont.SetFamily ( rFontItem.GetFamily() );
+ rFont.SetName ( rFontItem.GetFamilyName() );
+ rFont.SetStyleName ( rFontItem.GetStyleName() );
+ rFont.SetCharSet ( rFontItem.GetCharSet() );
+ rFont.SetPitch ( rFontItem.GetPitch() );
+ rFont.SetWeight ( (FontWeight)rWeightItem.GetValue() );
+ rFont.SetItalic ( (FontItalic)rPostureItem.GetValue() );
+}
+
+void ScAutoFmtPreview::MakeFonts( USHORT nIndex, Font& rFont, Font& rCJKFont, Font& rCTLFont )
+{
+ if ( pCurData )
+ {
+ rFont = rCJKFont = rCTLFont = GetFont();
+ Size aFontSize( rFont.GetSize().Width(), 10 );
+
+ const SvxFontItem* pFontItem = (const SvxFontItem*) pCurData->GetItem( nIndex, ATTR_FONT );
+ const SvxWeightItem* pWeightItem = (const SvxWeightItem*) pCurData->GetItem( nIndex, ATTR_FONT_WEIGHT );
+ const SvxPostureItem* pPostureItem = (const SvxPostureItem*) pCurData->GetItem( nIndex, ATTR_FONT_POSTURE );
+ const SvxFontItem* pCJKFontItem = (const SvxFontItem*) pCurData->GetItem( nIndex, ATTR_CJK_FONT );
+ const SvxWeightItem* pCJKWeightItem = (const SvxWeightItem*) pCurData->GetItem( nIndex, ATTR_CJK_FONT_WEIGHT );
+ const SvxPostureItem* pCJKPostureItem = (const SvxPostureItem*) pCurData->GetItem( nIndex, ATTR_CJK_FONT_POSTURE );
+ const SvxFontItem* pCTLFontItem = (const SvxFontItem*) pCurData->GetItem( nIndex, ATTR_CTL_FONT );
+ const SvxWeightItem* pCTLWeightItem = (const SvxWeightItem*) pCurData->GetItem( nIndex, ATTR_CTL_FONT_WEIGHT );
+ const SvxPostureItem* pCTLPostureItem = (const SvxPostureItem*) pCurData->GetItem( nIndex, ATTR_CTL_FONT_POSTURE );
+ const SvxUnderlineItem* pUnderlineItem = (const SvxUnderlineItem*) pCurData->GetItem( nIndex, ATTR_FONT_UNDERLINE );
+ const SvxOverlineItem* pOverlineItem = (const SvxOverlineItem*) pCurData->GetItem( nIndex, ATTR_FONT_OVERLINE );
+ const SvxCrossedOutItem* pCrossedOutItem = (const SvxCrossedOutItem*)pCurData->GetItem( nIndex, ATTR_FONT_CROSSEDOUT );
+ const SvxContourItem* pContourItem = (const SvxContourItem*) pCurData->GetItem( nIndex, ATTR_FONT_CONTOUR );
+ const SvxShadowedItem* pShadowedItem = (const SvxShadowedItem*) pCurData->GetItem( nIndex, ATTR_FONT_SHADOWED );
+ const SvxColorItem* pColorItem = (const SvxColorItem*) pCurData->GetItem( nIndex, ATTR_FONT_COLOR );
+
+ lcl_SetFontProperties( rFont, *pFontItem, *pWeightItem, *pPostureItem );
+ lcl_SetFontProperties( rCJKFont, *pCJKFontItem, *pCJKWeightItem, *pCJKPostureItem );
+ lcl_SetFontProperties( rCTLFont, *pCTLFontItem, *pCTLWeightItem, *pCTLPostureItem );
+
+ Color aColor( pColorItem->GetValue() );
+ if( aColor.GetColor() == COL_TRANSPARENT )
+ aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
+
+#define SETONALLFONTS( MethodName, Value ) \
+rFont.MethodName( Value ); rCJKFont.MethodName( Value ); rCTLFont.MethodName( Value );
+
+ SETONALLFONTS( SetUnderline, (FontUnderline)pUnderlineItem->GetValue() )
+ SETONALLFONTS( SetOverline, (FontUnderline)pOverlineItem->GetValue() )
+ SETONALLFONTS( SetStrikeout, (FontStrikeout)pCrossedOutItem->GetValue() )
+ SETONALLFONTS( SetOutline, pContourItem->GetValue() )
+ SETONALLFONTS( SetShadow, pShadowedItem->GetValue() )
+ SETONALLFONTS( SetColor, aColor )
+ SETONALLFONTS( SetSize, aFontSize )
+ SETONALLFONTS( SetTransparent, TRUE )
+
+#undef SETONALLFONTS
+ }
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScAutoFmtPreview::GetFormatIndex( size_t nCol, size_t nRow ) const
+{
+ static const USHORT pnFmtMap[] =
+ {
+ 0, 1, 2, 1, 3,
+ 4, 5, 6, 5, 7,
+ 8, 9, 10, 9, 11,
+ 4, 5, 6, 5, 7,
+ 12, 13, 14, 13, 15
+ };
+ return pnFmtMap[ maArray.GetCellIndex( nCol, nRow, mbRTL ) ];
+}
+
+const SvxBoxItem& ScAutoFmtPreview::GetBoxItem( size_t nCol, size_t nRow ) const
+{
+ DBG_ASSERT( pCurData, "ScAutoFmtPreview::GetBoxItem - no format data found" );
+ return *static_cast< const SvxBoxItem* >( pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BORDER ) );
+}
+
+const SvxLineItem& ScAutoFmtPreview::GetDiagItem( size_t nCol, size_t nRow, bool bTLBR ) const
+{
+ DBG_ASSERT( pCurData, "ScAutoFmtPreview::GetDiagItem - no format data found" );
+ return *static_cast< const SvxLineItem* >( pCurData->GetItem( GetFormatIndex( nCol, nRow ), bTLBR ? ATTR_BORDER_TLBR : ATTR_BORDER_BLTR ) );
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::DrawString( size_t nCol, size_t nRow )
+{
+ if ( pCurData )
+ {
+ //------------------------
+ // Ausgabe des Zelltextes:
+ //------------------------
+
+ String cellString;
+ BOOL bNumFormat = pCurData->GetIncludeValueFormat();
+ ULONG nNum;
+ double nVal;
+ Color* pDummy = NULL;
+ USHORT nIndex = static_cast< USHORT >( maArray.GetCellIndex( nCol, nRow, mbRTL ) );
+
+ switch( nIndex )
+ {
+ case 1: cellString = aStrJan; break;
+ case 2: cellString = aStrFeb; break;
+ case 3: cellString = aStrMar; break;
+ case 5: cellString = aStrNorth; break;
+ case 10: cellString = aStrMid; break;
+ case 15: cellString = aStrSouth; break;
+ case 4:
+ case 20: cellString = aStrSum; break;
+
+ case 6:
+ case 8:
+ case 16:
+ case 18: nVal = nIndex;
+ nNum = 5;
+ goto mknum;
+ case 17:
+ case 7: nVal = nIndex;
+ nNum = 6;
+ goto mknum;
+ case 11:
+ case 12:
+ case 13: nVal = nIndex;
+ nNum = 12 == nIndex ? 10 : 9;
+ goto mknum;
+
+ case 9: nVal = 21; nNum = 7; goto mknum;
+ case 14: nVal = 36; nNum = 11; goto mknum;
+ case 19: nVal = 51; nNum = 7; goto mknum;
+ case 21: nVal = 33; nNum = 13; goto mknum;
+ case 22: nVal = 36; nNum = 14; goto mknum;
+ case 23: nVal = 39; nNum = 13; goto mknum;
+ case 24: nVal = 108; nNum = 15;
+ mknum:
+ if( bNumFormat )
+ {
+ ScNumFormatAbbrev& rNumFormat = (ScNumFormatAbbrev&)pCurData->GetNumFormat( (USHORT) nNum );
+ nNum = rNumFormat.GetFormatIndex( *pNumFmt );
+ }
+ else
+ nNum = 0;
+ pNumFmt->GetOutputString( nVal, nNum, cellString, &pDummy );
+ break;
+ }
+
+ if ( cellString.Len() > 0 )
+ {
+ Size aStrSize;
+ USHORT nFmtIndex = GetFormatIndex( nCol, nRow );
+ Rectangle cellRect = maArray.GetCellRect( nCol, nRow );
+ Point aPos = cellRect.TopLeft();
+ USHORT nRightX = 0;
+ BOOL bJustify = pCurData->GetIncludeJustify();
+ SvxHorJustifyItem aHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY );
+ SvxCellHorJustify eJustification;
+
+ //-------------
+ // Ausrichtung:
+ //-------------
+ eJustification = mbRTL ? SVX_HOR_JUSTIFY_RIGHT : bJustify ?
+ (SvxCellHorJustify)(((const SvxHorJustifyItem*)pCurData->GetItem( nFmtIndex, ATTR_HOR_JUSTIFY ))->GetValue()) :
+ SVX_HOR_JUSTIFY_STANDARD;
+
+ if ( pCurData->GetIncludeFont() )
+ {
+ Font aFont, aCJKFont, aCTLFont;
+ Size theMaxStrSize;
+
+ MakeFonts( nFmtIndex, aFont, aCJKFont, aCTLFont );
+
+ theMaxStrSize = cellRect.GetSize();
+ theMaxStrSize.Width() -= FRAME_OFFSET;
+ theMaxStrSize.Height() -= FRAME_OFFSET;
+
+ aScriptedText.SetFonts( &aFont, &aCJKFont, &aCTLFont );
+ aScriptedText.SetText( cellString, xBreakIter );
+ aStrSize = aScriptedText.GetTextSize();
+
+ if ( theMaxStrSize.Height() < aStrSize.Height() )
+ {
+ // wenn der String in diesem Font nicht
+ // in die Zelle passt, wird wieder der
+ // Standard-Font genommen:
+ aScriptedText.SetDefaultFont();
+ aStrSize = aScriptedText.GetTextSize();
+ }
+ while ( ( theMaxStrSize.Width() <= aStrSize.Width() )
+ && ( cellString.Len() > 1 ) )
+ {
+ if( eJustification == SVX_HOR_JUSTIFY_RIGHT )
+ cellString.Erase( 0, 1 );
+ else
+ cellString.Erase( cellString.Len() - 1 );
+
+ aScriptedText.SetText( cellString, xBreakIter );
+ aStrSize = aScriptedText.GetTextSize();
+ }
+ }
+ else
+ {
+ aScriptedText.SetDefaultFont();
+ aScriptedText.SetText( cellString, xBreakIter );
+ aStrSize = aScriptedText.GetTextSize();
+ }
+
+ nRightX = (USHORT)( cellRect.GetWidth()
+ - aStrSize.Width()
+ - FRAME_OFFSET );
+
+ //-----------------------------
+ // vertikal (immer zentrieren):
+ //-----------------------------
+ aPos.Y() += (mnRowHeight - (USHORT)aStrSize.Height()) / 2;
+
+ //-----------
+ // horizontal
+ //-----------
+ if ( eJustification != SVX_HOR_JUSTIFY_STANDARD )
+ {
+ USHORT nHorPos = (USHORT)
+ ((cellRect.GetWidth()-aStrSize.Width())/2);
+
+ switch ( eJustification )
+ {
+ case SVX_HOR_JUSTIFY_LEFT:
+ aPos.X() += FRAME_OFFSET;
+ break;
+ case SVX_HOR_JUSTIFY_RIGHT:
+ aPos.X() += nRightX;
+ break;
+ case SVX_HOR_JUSTIFY_BLOCK:
+ case SVX_HOR_JUSTIFY_REPEAT:
+ case SVX_HOR_JUSTIFY_CENTER:
+ aPos.X() += nHorPos;
+ break;
+ case SVX_HOR_JUSTIFY_STANDARD:
+ default:
+ // Standard wird hier nicht behandelt
+ break;
+ }
+ }
+ else
+ {
+ //---------------------
+ // Standardausrichtung:
+ //---------------------
+ if ( (nCol == 0) || (nRow == 0) )
+ {
+ // Text-Label links oder Summe linksbuendig
+ aPos.X() += FRAME_OFFSET;
+ }
+ else
+ {
+ // Zahlen/Datum rechtsbuendig
+ aPos.X() += nRightX;
+ }
+ }
+
+ //-------------------------------
+ aScriptedText.DrawText( aPos );
+ //-------------------------------
+ }
+ }
+}
+
+#undef FRAME_OFFSET
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::DrawStrings()
+{
+ for( size_t nRow = 0; nRow < 5; ++nRow )
+ for( size_t nCol = 0; nCol < 5; ++nCol )
+ DrawString( nCol, nRow );
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::DrawBackground()
+{
+ if( pCurData )
+ {
+ for( size_t nRow = 0; nRow < 5; ++nRow )
+ {
+ for( size_t nCol = 0; nCol < 5; ++nCol )
+ {
+ const SvxBrushItem* pItem = static_cast< const SvxBrushItem* >(
+ pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BACKGROUND ) );
+
+ aVD.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
+ aVD.SetLineColor();
+ aVD.SetFillColor( pItem->GetColor() );
+ aVD.DrawRect( maArray.GetCellRect( nCol, nRow ) );
+ aVD.Pop();
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::PaintCells()
+{
+ if ( pCurData )
+ {
+ // 1) background
+ if ( pCurData->GetIncludeBackground() )
+ DrawBackground();
+
+ // 2) values
+ DrawStrings();
+
+ // 3) border
+ if ( pCurData->GetIncludeFrame() )
+ maArray.DrawArray( aVD );
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::Init()
+{
+ SetBorderStyle( WINDOW_BORDER_MONO );
+ maArray.Initialize( 5, 5 );
+ maArray.SetUseDiagDoubleClipping( false );
+ CalcCellArray( FALSE );
+ CalcLineMap();
+
+ TypeId aType(TYPE(ScDocShell));
+ ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+ SfxViewShell* p = pFrame->GetViewShell();
+ ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell* >( p );
+ ScViewData* pViewData = pViewSh->GetViewData();
+ SCTAB nCurrentTab = pViewData->GetTabNo();
+ ScDocument* pDoc = pViewData->GetDocument();
+ mbRTL = pDoc->IsLayoutRTL( nCurrentTab );
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::CalcCellArray( BOOL bFitWidthP )
+{
+ maArray.SetXOffset( 2 );
+ maArray.SetAllColWidths( bFitWidthP ? mnDataColWidth2 : mnDataColWidth1 );
+ maArray.SetColWidth( 0, mnLabelColWidth );
+ maArray.SetColWidth( 4, mnLabelColWidth );
+
+ maArray.SetYOffset( 2 );
+ maArray.SetAllRowHeights( mnRowHeight );
+
+ aPrvSize.Width() = maArray.GetWidth() + 4;
+ aPrvSize.Height() = maArray.GetHeight() + 4;
+}
+
+//------------------------------------------------------------------------
+
+inline void lclSetStyleFromBorder( svx::frame::Style& rStyle, const SvxBorderLine* pBorder )
+{
+ rStyle.Set( pBorder, 1.0 / TWIPS_PER_POINT, 5 );
+}
+
+void ScAutoFmtPreview::CalcLineMap()
+{
+ if ( pCurData )
+ {
+ for( size_t nRow = 0; nRow < 5; ++nRow )
+ {
+ for( size_t nCol = 0; nCol < 5; ++nCol )
+ {
+ svx::frame::Style aStyle;
+
+ const SvxBoxItem& rItem = GetBoxItem( nCol, nRow );
+ lclSetStyleFromBorder( aStyle, rItem.GetLeft() );
+ maArray.SetCellStyleLeft( nCol, nRow, aStyle );
+ lclSetStyleFromBorder( aStyle, rItem.GetRight() );
+ maArray.SetCellStyleRight( nCol, nRow, aStyle );
+ lclSetStyleFromBorder( aStyle, rItem.GetTop() );
+ maArray.SetCellStyleTop( nCol, nRow, aStyle );
+ lclSetStyleFromBorder( aStyle, rItem.GetBottom() );
+ maArray.SetCellStyleBottom( nCol, nRow, aStyle );
+
+ lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, true ).GetLine() );
+ maArray.SetCellStyleTLBR( nCol, nRow, aStyle );
+ lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, false ).GetLine() );
+ maArray.SetCellStyleBLTR( nCol, nRow, aStyle );
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::NotifyChange( ScAutoFormatData* pNewData )
+{
+ if ( pNewData != pCurData )
+ {
+ pCurData = pNewData;
+ bFitWidth = pNewData->GetIncludeWidthHeight();
+ CalcCellArray( bFitWidth );
+ CalcLineMap();
+ }
+ else if ( bFitWidth != pNewData->GetIncludeWidthHeight() )
+ {
+ bFitWidth = !bFitWidth;
+ CalcCellArray( bFitWidth );
+ }
+
+ DoPaint( Rectangle( Point(0,0), GetSizePixel() ) );
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::DoPaint( const Rectangle& /* rRect */ )
+{
+ sal_uInt32 nOldDrawMode = aVD.GetDrawMode();
+ // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
+ if( GetSettings().GetStyleSettings().GetHighContrastMode() )
+ aVD.SetDrawMode( DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
+
+ Size aWndSize( GetSizePixel() );
+ Font aFont( aVD.GetFont() );
+ Color aBackCol( GetSettings().GetStyleSettings().GetWindowColor() );
+ Point aTmpPoint;
+ Rectangle aRect( aTmpPoint, aWndSize );
+
+ aFont.SetTransparent( TRUE );
+ aVD.SetFont( aFont );
+ aVD.SetLineColor();
+ aVD.SetFillColor( aBackCol );
+ aVD.SetOutputSize( aWndSize );
+ aVD.DrawRect( aRect );
+
+ PaintCells();
+ SetLineColor();
+ SetFillColor( aBackCol );
+ DrawRect( aRect );
+
+ Point aPos( (aWndSize.Width() - aPrvSize.Width()) / 2, (aWndSize.Height() - aPrvSize.Height()) / 2 );
+ if (Application::GetSettings().GetLayoutRTL())
+ aPos.X() = -aPos.X();
+ DrawOutDev( aPos, aWndSize, Point(), aWndSize, aVD );
+
+ aVD.SetDrawMode( nOldDrawMode );
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::Paint( const Rectangle& rRect )
+{
+ DoPaint( rRect );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/conflictsdlg.cxx b/sc/source/ui/miscdlgs/conflictsdlg.cxx
new file mode 100644
index 000000000000..6e5880a5cf06
--- /dev/null
+++ b/sc/source/ui/miscdlgs/conflictsdlg.cxx
@@ -0,0 +1,861 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//-----------------------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+
+#include "conflictsdlg.hxx"
+#include "conflictsdlg.hrc"
+#include "scresid.hxx"
+#include "viewdata.hxx"
+#include "dbfunc.hxx"
+
+
+//=============================================================================
+// struct ScConflictsListEntry
+//=============================================================================
+
+bool ScConflictsListEntry::HasSharedAction( ULONG nSharedAction ) const
+{
+ ScChangeActionList::const_iterator aEnd = maSharedActions.end();
+ for ( ScChangeActionList::const_iterator aItr = maSharedActions.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( *aItr == nSharedAction )
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool ScConflictsListEntry::HasOwnAction( ULONG nOwnAction ) const
+{
+ ScChangeActionList::const_iterator aEnd = maOwnActions.end();
+ for ( ScChangeActionList::const_iterator aItr = maOwnActions.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( *aItr == nOwnAction )
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+//=============================================================================
+// class ScConflictsListHelper
+//=============================================================================
+
+bool ScConflictsListHelper::HasOwnAction( ScConflictsList& rConflictsList, ULONG nOwnAction )
+{
+ ScConflictsList::const_iterator aEnd = rConflictsList.end();
+ for ( ScConflictsList::const_iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( aItr->HasOwnAction( nOwnAction ) )
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+ScConflictsListEntry* ScConflictsListHelper::GetSharedActionEntry( ScConflictsList& rConflictsList, ULONG nSharedAction )
+{
+ ScConflictsList::iterator aEnd = rConflictsList.end();
+ for ( ScConflictsList::iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( aItr->HasSharedAction( nSharedAction ) )
+ {
+ return &(*aItr);
+ }
+ }
+
+ return NULL;
+}
+
+ScConflictsListEntry* ScConflictsListHelper::GetOwnActionEntry( ScConflictsList& rConflictsList, ULONG nOwnAction )
+{
+ ScConflictsList::iterator aEnd = rConflictsList.end();
+ for ( ScConflictsList::iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( aItr->HasOwnAction( nOwnAction ) )
+ {
+ return &(*aItr);
+ }
+ }
+
+ return NULL;
+}
+
+void ScConflictsListHelper::Transform_Impl( ScChangeActionList& rActionList, ScChangeActionMergeMap* pMergeMap )
+{
+ if ( !pMergeMap )
+ {
+ return;
+ }
+
+ for ( ScChangeActionList::iterator aItr = rActionList.begin(); aItr != rActionList.end(); )
+ {
+ ScChangeActionMergeMap::iterator aItrMap = pMergeMap->find( *aItr );
+ if ( aItrMap != pMergeMap->end() )
+ {
+ *aItr = aItrMap->second;
+ aItr++;
+ }
+ else
+ {
+ aItr = rActionList.erase( aItr );
+ DBG_ERROR( "ScConflictsListHelper::Transform_Impl: erased action from conflicts list!" );
+ }
+ }
+}
+
+void ScConflictsListHelper::TransformConflictsList( ScConflictsList& rConflictsList,
+ ScChangeActionMergeMap* pSharedMap, ScChangeActionMergeMap* pOwnMap )
+{
+ ScConflictsList::iterator aEnd = rConflictsList.end();
+ for ( ScConflictsList::iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( pSharedMap )
+ {
+ ScConflictsListHelper::Transform_Impl( aItr->maSharedActions, pSharedMap );
+ }
+
+ if ( pOwnMap )
+ {
+ ScConflictsListHelper::Transform_Impl( aItr->maOwnActions, pOwnMap );
+ }
+ }
+}
+
+
+//=============================================================================
+// class ScConflictsFinder
+//=============================================================================
+
+ScConflictsFinder::ScConflictsFinder( ScChangeTrack* pTrack, ULONG nStartShared, ULONG nEndShared,
+ ULONG nStartOwn, ULONG nEndOwn, ScConflictsList& rConflictsList )
+ :mpTrack( pTrack )
+ ,mnStartShared( nStartShared )
+ ,mnEndShared( nEndShared )
+ ,mnStartOwn( nStartOwn )
+ ,mnEndOwn( nEndOwn )
+ ,mrConflictsList( rConflictsList )
+{
+}
+
+ScConflictsFinder::~ScConflictsFinder()
+{
+}
+
+bool ScConflictsFinder::DoActionsIntersect( const ScChangeAction* pAction1, const ScChangeAction* pAction2 )
+{
+ if ( pAction1 && pAction2 && pAction1->GetBigRange().Intersects( pAction2->GetBigRange() ) )
+ {
+ return true;
+ }
+ return false;
+}
+
+ScConflictsListEntry* ScConflictsFinder::GetIntersectingEntry( const ScChangeAction* pAction ) const
+{
+ ScConflictsList::iterator aEnd = mrConflictsList.end();
+ for ( ScConflictsList::iterator aItr = mrConflictsList.begin(); aItr != aEnd; ++aItr )
+ {
+ ScChangeActionList::const_iterator aEndShared = aItr->maSharedActions.end();
+ for ( ScChangeActionList::const_iterator aItrShared = aItr->maSharedActions.begin(); aItrShared != aEndShared; ++aItrShared )
+ {
+ if ( DoActionsIntersect( mpTrack->GetAction( *aItrShared ), pAction ) )
+ {
+ return &(*aItr);
+ }
+ }
+
+ ScChangeActionList::const_iterator aEndOwn = aItr->maOwnActions.end();
+ for ( ScChangeActionList::const_iterator aItrOwn = aItr->maOwnActions.begin(); aItrOwn != aEndOwn; ++aItrOwn )
+ {
+ if ( DoActionsIntersect( mpTrack->GetAction( *aItrOwn ), pAction ) )
+ {
+ return &(*aItr);
+ }
+ }
+ }
+
+ return NULL;
+}
+
+ScConflictsListEntry* ScConflictsFinder::GetEntry( ULONG nSharedAction, const ScChangeActionList& rOwnActions )
+{
+ // try to get a list entry which already contains the shared action
+ ScConflictsListEntry* pEntry = ScConflictsListHelper::GetSharedActionEntry( mrConflictsList, nSharedAction );
+ if ( pEntry )
+ {
+ return pEntry;
+ }
+
+ // try to get a list entry for which the shared action intersects with any
+ // other action of this entry
+ pEntry = GetIntersectingEntry( mpTrack->GetAction( nSharedAction ) );
+ if ( pEntry )
+ {
+ pEntry->maSharedActions.push_back( nSharedAction );
+ return pEntry;
+ }
+
+ // try to get a list entry for which any of the own actions intersects with
+ // any other action of this entry
+ ScChangeActionList::const_iterator aEnd = rOwnActions.end();
+ for ( ScChangeActionList::const_iterator aItr = rOwnActions.begin(); aItr != aEnd; ++aItr )
+ {
+ pEntry = GetIntersectingEntry( mpTrack->GetAction( *aItr ) );
+ if ( pEntry )
+ {
+ pEntry->maSharedActions.push_back( nSharedAction );
+ return pEntry;
+ }
+ }
+
+ // if no entry was found, create a new one
+ ScConflictsListEntry aEntry;
+ aEntry.meConflictAction = SC_CONFLICT_ACTION_NONE;
+ aEntry.maSharedActions.push_back( nSharedAction );
+ mrConflictsList.push_back( aEntry );
+ return &(mrConflictsList.back());
+}
+
+bool ScConflictsFinder::Find()
+{
+ if ( !mpTrack )
+ {
+ return false;
+ }
+
+ bool bReturn = false;
+ ScChangeAction* pSharedAction = mpTrack->GetAction( mnStartShared );
+ while ( pSharedAction && pSharedAction->GetActionNumber() <= mnEndShared )
+ {
+ ScChangeActionList aOwnActions;
+ ScChangeAction* pOwnAction = mpTrack->GetAction( mnStartOwn );
+ while ( pOwnAction && pOwnAction->GetActionNumber() <= mnEndOwn )
+ {
+ if ( DoActionsIntersect( pSharedAction, pOwnAction ) )
+ {
+ aOwnActions.push_back( pOwnAction->GetActionNumber() );
+ }
+ pOwnAction = pOwnAction->GetNext();
+ }
+
+ if ( aOwnActions.size() )
+ {
+ ScConflictsListEntry* pEntry = GetEntry( pSharedAction->GetActionNumber(), aOwnActions );;
+ ScChangeActionList::iterator aEnd = aOwnActions.end();
+ for ( ScChangeActionList::iterator aItr = aOwnActions.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( pEntry && !ScConflictsListHelper::HasOwnAction( mrConflictsList, *aItr ) )
+ {
+ pEntry->maOwnActions.push_back( *aItr );
+ }
+ }
+ bReturn = true;
+ }
+
+ pSharedAction = pSharedAction->GetNext();
+ }
+
+ return bReturn;
+}
+
+//=============================================================================
+// class ScConflictsResolver
+//=============================================================================
+
+ScConflictsResolver::ScConflictsResolver( ScChangeTrack* pTrack, ScConflictsList& rConflictsList )
+ :mpTrack ( pTrack )
+ ,mrConflictsList ( rConflictsList )
+{
+ DBG_ASSERT( mpTrack, "ScConflictsResolver CTOR: mpTrack is null!" );
+}
+
+ScConflictsResolver::~ScConflictsResolver()
+{
+}
+
+void ScConflictsResolver::HandleAction( ScChangeAction* pAction, bool bIsSharedAction,
+ bool bHandleContentAction, bool bHandleNonContentAction )
+{
+ if ( !mpTrack || !pAction )
+ {
+ return;
+ }
+
+ if ( bIsSharedAction )
+ {
+ ScConflictsListEntry* pConflictEntry = ScConflictsListHelper::GetSharedActionEntry(
+ mrConflictsList, pAction->GetActionNumber() );
+ if ( pConflictEntry )
+ {
+ ScConflictAction eConflictAction = pConflictEntry->meConflictAction;
+ if ( eConflictAction == SC_CONFLICT_ACTION_KEEP_MINE )
+ {
+ if ( pAction->GetType() == SC_CAT_CONTENT )
+ {
+ if ( bHandleContentAction )
+ {
+ mpTrack->Reject( pAction );
+ }
+ }
+ else
+ {
+ if ( bHandleNonContentAction )
+ {
+ mpTrack->Reject( pAction );
+ }
+ }
+ }
+ else if ( eConflictAction == SC_CONFLICT_ACTION_KEEP_OTHER )
+ {
+ if ( pAction->GetType() == SC_CAT_CONTENT )
+ {
+ if ( bHandleContentAction )
+ {
+ // do nothing
+ //mpTrack->SelectContent( pAction );
+ }
+ }
+ else
+ {
+ if ( bHandleNonContentAction )
+ {
+ // do nothing
+ //mpTrack->Accept( pAction );
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ ScConflictsListEntry* pConflictEntry = ScConflictsListHelper::GetOwnActionEntry(
+ mrConflictsList, pAction->GetActionNumber() );
+ if ( pConflictEntry )
+ {
+ ScConflictAction eConflictAction = pConflictEntry->meConflictAction;
+ if ( eConflictAction == SC_CONFLICT_ACTION_KEEP_MINE )
+ {
+ if ( pAction->GetType() == SC_CAT_CONTENT )
+ {
+ if ( bHandleContentAction )
+ {
+ // do nothing
+ //mpTrack->SelectContent( pAction );
+ }
+ }
+ else
+ {
+ if ( bHandleNonContentAction )
+ {
+ // do nothing
+ //mpTrack->Accept( pAction );
+ }
+ }
+ }
+ else if ( eConflictAction == SC_CONFLICT_ACTION_KEEP_OTHER )
+ {
+ if ( pAction->GetType() == SC_CAT_CONTENT )
+ {
+ if ( bHandleContentAction )
+ {
+ mpTrack->Reject( pAction );
+ }
+ }
+ else
+ {
+ if ( bHandleNonContentAction )
+ {
+ mpTrack->Reject( pAction );
+ }
+ }
+ }
+ }
+ }
+}
+
+
+//=============================================================================
+// class ScConflictsListBox
+//=============================================================================
+
+ScConflictsListBox::ScConflictsListBox( Window* pParent, const ResId& rResId )
+ :SvxRedlinTable( pParent, rResId )
+{
+}
+
+ScConflictsListBox::~ScConflictsListBox()
+{
+}
+
+//=============================================================================
+// class ScConflictsDlg
+//=============================================================================
+
+ScConflictsDlg::ScConflictsDlg( Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList )
+ :ModalDialog( pParent, ScResId( RID_SCDLG_CONFLICTS ) )
+ ,maFtConflicts ( this, ScResId( FT_CONFLICTS ) )
+ ,maLbConflicts ( this, ScResId( LB_CONFLICTS ) )
+ ,maBtnKeepMine ( this, ScResId( BTN_KEEPMINE ) )
+ ,maBtnKeepOther ( this, ScResId( BTN_KEEPOTHER ) )
+ ,maFlConflicts ( this, ScResId( FL_CONFLICTS ) )
+ ,maBtnKeepAllMine ( this, ScResId( BTN_KEEPALLMINE ) )
+ ,maBtnKeepAllOthers ( this, ScResId( BTN_KEEPALLOTHERS ) )
+ ,maBtnCancel ( this, ScResId( BTN_CANCEL ) )
+ ,maBtnHelp ( this, ScResId( BTN_HELP ) )
+ ,maStrTitleConflict ( ScResId( STR_TITLE_CONFLICT ) )
+ ,maStrTitleAuthor ( ScResId( STR_TITLE_AUTHOR ) )
+ ,maStrTitleDate ( ScResId( STR_TITLE_DATE ) )
+ ,maStrUnknownUser ( ScResId( STR_UNKNOWN_USER ) )
+ ,mpViewData ( pViewData )
+ ,mpOwnDoc ( NULL )
+ ,mpOwnTrack ( NULL )
+ ,mpSharedDoc ( pSharedDoc )
+ ,mpSharedTrack ( NULL )
+ ,mrConflictsList ( rConflictsList )
+ ,maDialogSize ( GetSizePixel() )
+ ,mbInSelectHdl ( false )
+ ,mbInDeselectHdl ( false )
+{
+ DBG_ASSERT( mpViewData, "ScConflictsDlg CTOR: mpViewData is null!" );
+ mpOwnDoc = ( mpViewData ? mpViewData->GetDocument() : NULL );
+ DBG_ASSERT( mpOwnDoc, "ScConflictsDlg CTOR: mpOwnDoc is null!" );
+ mpOwnTrack = ( mpOwnDoc ? mpOwnDoc->GetChangeTrack() : NULL );
+ DBG_ASSERT( mpOwnTrack, "ScConflictsDlg CTOR: mpOwnTrack is null!" );
+ DBG_ASSERT( mpSharedDoc, "ScConflictsDlg CTOR: mpSharedDoc is null!" );
+ mpSharedTrack = ( mpSharedDoc ? mpSharedDoc->GetChangeTrack() : NULL );
+ DBG_ASSERT( mpSharedTrack, "ScConflictsDlg CTOR: mpSharedTrack is null!" );
+
+ FreeResource();
+
+ SetMinOutputSizePixel( maDialogSize );
+
+ long nTabs[] = { 3, 10, 216, 266 };
+ maLbConflicts.SetTabs( nTabs );
+
+ String aTab( sal_Unicode( '\t' ) );
+ String aHeader( maStrTitleConflict );
+ aHeader += aTab;
+ aHeader += maStrTitleAuthor;
+ aHeader += aTab;
+ aHeader += maStrTitleDate;
+ maLbConflicts.InsertHeaderEntry( aHeader, HEADERBAR_APPEND, HIB_LEFT | HIB_LEFTIMAGE | HIB_VCENTER );
+
+ maLbConflicts.SetWindowBits( WB_HASLINES | WB_CLIPCHILDREN | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HSCROLL );
+ maLbConflicts.SetSelectionMode( MULTIPLE_SELECTION );
+ maLbConflicts.SetHighlightRange();
+
+ maSelectionTimer.SetTimeout( 100 );
+ maSelectionTimer.SetTimeoutHdl( LINK( this, ScConflictsDlg, UpdateSelectionHdl ) );
+
+ maLbConflicts.SetSelectHdl( LINK( this, ScConflictsDlg, SelectHandle ) );
+ maLbConflicts.SetDeselectHdl( LINK( this, ScConflictsDlg, DeselectHandle ) );
+
+ maBtnKeepMine.SetClickHdl( LINK( this, ScConflictsDlg, KeepMineHandle ) );
+ maBtnKeepOther.SetClickHdl( LINK( this, ScConflictsDlg, KeepOtherHandle ) );
+ maBtnKeepAllMine.SetClickHdl( LINK( this, ScConflictsDlg, KeepAllMineHandle ) );
+ maBtnKeepAllOthers.SetClickHdl( LINK( this, ScConflictsDlg, KeepAllOthersHandle ) );
+
+ UpdateView();
+
+ SvLBoxEntry* pEntry = maLbConflicts.First();
+ if ( pEntry != NULL )
+ {
+ maLbConflicts.Select( pEntry );
+ }
+}
+
+ScConflictsDlg::~ScConflictsDlg()
+{
+}
+
+String ScConflictsDlg::GetConflictString( const ScConflictsListEntry& rConflictEntry )
+{
+ String aString;
+ if ( mpOwnTrack )
+ {
+ const ScChangeAction* pAction = mpOwnTrack->GetAction( rConflictEntry.maOwnActions[ 0 ] );
+ if ( pAction && mpOwnDoc )
+ {
+ SCTAB nTab = pAction->GetBigRange().MakeRange().aStart.Tab();
+ mpOwnDoc->GetName( nTab, aString );
+ }
+ }
+ return aString;
+}
+
+String ScConflictsDlg::GetActionString( const ScChangeAction* pAction, ScDocument* pDoc )
+{
+ String aString;
+
+ DBG_ASSERT( pAction, "ScConflictsDlg::GetActionString(): pAction is null!" );
+ DBG_ASSERT( pDoc, "ScConflictsDlg::GetActionString(): pDoc is null!" );
+ if ( pAction && pDoc )
+ {
+ String aDesc;
+ pAction->GetDescription( aDesc, pDoc, TRUE, false );
+ aString += aDesc;
+ aString += '\t';
+
+ String aUser = pAction->GetUser();
+ aUser.EraseLeadingAndTrailingChars();
+ if ( aUser.Len() == 0 )
+ {
+ aUser = maStrUnknownUser;
+ }
+ aString += aUser;
+ aString += '\t';
+
+ DateTime aDateTime = pAction->GetDateTime();
+ aString += ScGlobal::pLocaleData->getDate( aDateTime );
+ aString += ' ';
+ aString += ScGlobal::pLocaleData->getTime( aDateTime, FALSE );
+ aString += '\t';
+ }
+
+ return aString;
+}
+
+void ScConflictsDlg::HandleListBoxSelection( bool bSelectHandle )
+{
+ SvLBoxEntry* pSelEntry = maLbConflicts.GetCurEntry();
+ if ( !pSelEntry )
+ {
+ pSelEntry = maLbConflicts.FirstSelected();
+ }
+ if ( !pSelEntry )
+ {
+ return;
+ }
+
+ SvLBoxEntry* pRootEntry = maLbConflicts.GetRootLevelParent( pSelEntry );
+ if ( pRootEntry )
+ {
+ if ( bSelectHandle )
+ {
+ maLbConflicts.SelectAll( FALSE );
+ }
+ if ( !maLbConflicts.IsSelected( pRootEntry ) )
+ {
+ maLbConflicts.Select( pRootEntry );
+ }
+ SvLBoxEntry* pEntry = maLbConflicts.FirstChild( pRootEntry );
+ while ( pEntry )
+ {
+ if ( !maLbConflicts.IsSelected( pEntry ) )
+ {
+ maLbConflicts.Select( pEntry );
+ }
+ pEntry = maLbConflicts.NextSibling( pEntry );
+ }
+ }
+}
+
+IMPL_LINK( ScConflictsDlg, SelectHandle, SvxRedlinTable*, EMPTYARG )
+{
+ if ( mbInSelectHdl || mbInDeselectHdl )
+ {
+ return 0;
+ }
+
+ mbInSelectHdl = true;
+ HandleListBoxSelection( true );
+ maSelectionTimer.Start();
+ mbInSelectHdl = false;
+
+ return 0;
+}
+
+IMPL_LINK( ScConflictsDlg, DeselectHandle, SvxRedlinTable*, EMPTYARG )
+{
+ if ( mbInDeselectHdl || mbInSelectHdl )
+ {
+ return 0;
+ }
+
+ mbInDeselectHdl = true;
+ HandleListBoxSelection( false );
+ mbInDeselectHdl = false;
+
+ return 0;
+}
+
+IMPL_LINK( ScConflictsDlg, UpdateSelectionHdl, Timer*, EMPTYARG )
+{
+ if ( !mpViewData || !mpOwnDoc )
+ {
+ return 0;
+ }
+
+ ScTabView* pTabView = mpViewData->GetView();
+ pTabView->DoneBlockMode();
+ BOOL bContMark = FALSE;
+ SvLBoxEntry* pEntry = maLbConflicts.FirstSelected();
+ while ( pEntry )
+ {
+ if ( pEntry != maLbConflicts.GetRootLevelParent( pEntry ) )
+ {
+ RedlinData* pUserData = static_cast< RedlinData* >( pEntry->GetUserData() );
+ if ( pUserData )
+ {
+ ScChangeAction* pAction = static_cast< ScChangeAction* >( pUserData->pData );
+ if ( pAction && ( pAction->GetType() != SC_CAT_DELETE_TABS ) &&
+ ( pAction->IsClickable() || pAction->IsVisible() ) )
+ {
+ const ScBigRange& rBigRange = ( static_cast< const ScChangeAction* >( pAction ) )->GetBigRange();
+ if ( rBigRange.IsValid( mpOwnDoc ) )
+ {
+ BOOL bSetCursor = !maLbConflicts.NextSelected( pEntry );
+ pTabView->MarkRange( rBigRange.MakeRange(), bSetCursor, bContMark );
+ bContMark = TRUE;
+ }
+ }
+ }
+ }
+ pEntry = maLbConflicts.NextSelected( pEntry );
+ }
+
+ return 0;
+}
+
+void ScConflictsDlg::SetConflictAction( SvLBoxEntry* pRootEntry, ScConflictAction eConflictAction )
+{
+ RedlinData* pUserData = static_cast< RedlinData* >( pRootEntry ? pRootEntry->GetUserData() : NULL );
+ ScConflictsListEntry* pConflictEntry = static_cast< ScConflictsListEntry* >( pUserData ? pUserData->pData : NULL );
+ if ( pConflictEntry )
+ {
+ pConflictEntry->meConflictAction = eConflictAction;
+ }
+}
+
+void ScConflictsDlg::KeepHandler( bool bMine )
+{
+ SvLBoxEntry* pEntry = maLbConflicts.FirstSelected();
+ SvLBoxEntry* pRootEntry = ( pEntry ? maLbConflicts.GetRootLevelParent( pEntry ) : NULL );
+ if ( !pRootEntry )
+ {
+ return;
+ }
+ SetPointer( Pointer( POINTER_WAIT ) );
+ ScConflictAction eConflictAction = ( bMine ? SC_CONFLICT_ACTION_KEEP_MINE : SC_CONFLICT_ACTION_KEEP_OTHER );
+ SetConflictAction( pRootEntry, eConflictAction );
+ maLbConflicts.RemoveEntry( pRootEntry );
+ SetPointer( Pointer( POINTER_ARROW ) );
+ if ( maLbConflicts.GetEntryCount() == 0 )
+ {
+ EndDialog( RET_OK );
+ }
+}
+
+void ScConflictsDlg::KeepAllHandler( bool bMine )
+{
+ SvLBoxEntry* pEntry = maLbConflicts.First();
+ SvLBoxEntry* pRootEntry = ( pEntry ? maLbConflicts.GetRootLevelParent( pEntry ) : NULL );
+ if ( !pRootEntry )
+ {
+ return;
+ }
+ SetPointer( Pointer( POINTER_WAIT ) );
+ ScConflictAction eConflictAction = ( bMine ? SC_CONFLICT_ACTION_KEEP_MINE : SC_CONFLICT_ACTION_KEEP_OTHER );
+ while ( pRootEntry )
+ {
+ SetConflictAction( pRootEntry, eConflictAction );
+ pRootEntry = maLbConflicts.NextSibling( pRootEntry );
+ }
+ maLbConflicts.SetUpdateMode( FALSE );
+ maLbConflicts.Clear();
+ maLbConflicts.SetUpdateMode( TRUE );
+ SetPointer( Pointer( POINTER_ARROW ) );
+ EndDialog( RET_OK );
+}
+
+IMPL_LINK( ScConflictsDlg, KeepMineHandle, void*, EMPTYARG )
+{
+ KeepHandler( true );
+
+ return 0;
+}
+
+IMPL_LINK( ScConflictsDlg, KeepOtherHandle, void*, EMPTYARG )
+{
+ KeepHandler( false );
+
+ return 0;
+}
+
+IMPL_LINK( ScConflictsDlg, KeepAllMineHandle, void*, EMPTYARG )
+{
+ KeepAllHandler( true );
+
+ return 0;
+}
+
+IMPL_LINK( ScConflictsDlg, KeepAllOthersHandle, void*, EMPTYARG )
+{
+ KeepAllHandler( false );
+
+ return 0;
+}
+
+void lcl_MoveControlX( Window& rWindow, long nDelta )
+{
+ Point aPos( rWindow.GetPosPixel() );
+ aPos.X() += nDelta;
+ rWindow.SetPosPixel( aPos );
+}
+
+void lcl_MoveControlY( Window& rWindow, long nDelta )
+{
+ Point aPos( rWindow.GetPosPixel() );
+ aPos.Y() += nDelta;
+ rWindow.SetPosPixel( aPos );
+}
+
+void lcl_ChangeControlWidth( Window& rWindow, long nDelta )
+{
+ Size aSize( rWindow.GetSizePixel() );
+ aSize.Width() += nDelta;
+ rWindow.SetSizePixel( aSize );
+}
+
+void lcl_ChangeControlHeight( Window& rWindow, long nDelta )
+{
+ Size aSize( rWindow.GetSizePixel() );
+ aSize.Height() += nDelta;
+ rWindow.SetSizePixel( aSize );
+}
+
+void ScConflictsDlg::Resize()
+{
+ Size aSize( GetSizePixel() );
+ long nDeltaWidth = aSize.Width() - maDialogSize.Width();
+ long nDeltaHeight = aSize.Height() - maDialogSize.Height();
+ maDialogSize = aSize;
+
+ lcl_ChangeControlWidth( maFtConflicts, nDeltaWidth );
+
+ lcl_ChangeControlWidth( maLbConflicts, nDeltaWidth );
+ lcl_ChangeControlHeight( maLbConflicts, nDeltaHeight );
+
+ lcl_MoveControlX( maBtnKeepMine, nDeltaWidth / 2 );
+ lcl_MoveControlY( maBtnKeepMine, nDeltaHeight );
+
+ lcl_MoveControlX( maBtnKeepOther, nDeltaWidth / 2 );
+ lcl_MoveControlY( maBtnKeepOther, nDeltaHeight );
+
+ lcl_MoveControlY( maFlConflicts, nDeltaHeight );
+ lcl_ChangeControlWidth( maFlConflicts, nDeltaWidth );
+
+ lcl_MoveControlX( maBtnKeepAllMine, nDeltaWidth );
+ lcl_MoveControlY( maBtnKeepAllMine, nDeltaHeight );
+
+ lcl_MoveControlX( maBtnKeepAllOthers, nDeltaWidth );
+ lcl_MoveControlY( maBtnKeepAllOthers, nDeltaHeight );
+
+ lcl_MoveControlX( maBtnCancel, nDeltaWidth );
+ lcl_MoveControlY( maBtnCancel, nDeltaHeight );
+
+ lcl_MoveControlX( maBtnHelp, nDeltaWidth );
+ lcl_MoveControlY( maBtnHelp, nDeltaHeight );
+}
+
+void ScConflictsDlg::UpdateView()
+{
+ ScConflictsList::iterator aEndItr = mrConflictsList.end();
+ for ( ScConflictsList::iterator aItr = mrConflictsList.begin(); aItr != aEndItr; ++aItr )
+ {
+ ScConflictsListEntry* pConflictEntry = &(*aItr);
+ if ( pConflictEntry && pConflictEntry->meConflictAction == SC_CONFLICT_ACTION_NONE )
+ {
+ RedlinData* pRootUserData = new RedlinData();
+ pRootUserData->pData = static_cast< void* >( pConflictEntry );
+ SvLBoxEntry* pRootEntry = maLbConflicts.InsertEntry( GetConflictString( *aItr ), pRootUserData );
+
+ ScChangeActionList::const_iterator aEndShared = aItr->maSharedActions.end();
+ for ( ScChangeActionList::const_iterator aItrShared = aItr->maSharedActions.begin(); aItrShared != aEndShared; ++aItrShared )
+ {
+ ScChangeAction* pAction = mpSharedTrack->GetAction( *aItrShared );
+ if ( pAction )
+ {
+ // only display shared top content entries
+ if ( pAction->GetType() == SC_CAT_CONTENT )
+ {
+ ScChangeActionContent* pNextContent = ( dynamic_cast< ScChangeActionContent* >( pAction ) )->GetNextContent();
+ if ( pNextContent && aItr->HasSharedAction( pNextContent->GetActionNumber() ) )
+ {
+ continue;
+ }
+ }
+
+ String aString( GetActionString( pAction, mpSharedDoc ) );
+ maLbConflicts.InsertEntry( aString, static_cast< RedlinData* >( NULL ), pRootEntry );
+ }
+ }
+
+ ScChangeActionList::const_iterator aEndOwn = aItr->maOwnActions.end();
+ for ( ScChangeActionList::const_iterator aItrOwn = aItr->maOwnActions.begin(); aItrOwn != aEndOwn; ++aItrOwn )
+ {
+ ScChangeAction* pAction = mpOwnTrack->GetAction( *aItrOwn );
+ if ( pAction )
+ {
+ // only display own top content entries
+ if ( pAction->GetType() == SC_CAT_CONTENT )
+ {
+ ScChangeActionContent* pNextContent = ( dynamic_cast< ScChangeActionContent* >( pAction ) )->GetNextContent();
+ if ( pNextContent && aItr->HasOwnAction( pNextContent->GetActionNumber() ) )
+ {
+ continue;
+ }
+ }
+
+ String aString( GetActionString( pAction, mpOwnDoc ) );
+ RedlinData* pUserData = new RedlinData();
+ pUserData->pData = static_cast< void* >( pAction );
+ maLbConflicts.InsertEntry( aString, pUserData, pRootEntry );
+ }
+ }
+
+ maLbConflicts.Expand( pRootEntry );
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/conflictsdlg.src b/sc/source/ui/miscdlgs/conflictsdlg.src
new file mode 100644
index 000000000000..dad8abb48780
--- /dev/null
+++ b/sc/source/ui/miscdlgs/conflictsdlg.src
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "conflictsdlg.hrc"
+
+ModalDialog RID_SCDLG_CONFLICTS
+{
+ OutputSize = TRUE ;
+ HelpId = HID_SCDLG_CONFLICTS ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 338 , 192 ) ;
+ Text [ en-US ] = "Resolve Conflicts" ;
+ Moveable = TRUE ;
+ Sizeable = TRUE ;
+ Closeable = TRUE ;
+ FixedText FT_CONFLICTS
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 326 , 26 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "There are conflicting changes in this shared spreadsheet. Conflicts must be resolved before saving the spreadsheet. Keep either own or other changes." ;
+ };
+ Control LB_CONFLICTS
+ {
+ Pos = MAP_APPFONT ( 6 , 34 ) ;
+ Size = MAP_APPFONT ( 326 , 104 ) ;
+ Border = TRUE ;
+ };
+ PushButton BTN_KEEPMINE
+ {
+ Pos = MAP_APPFONT ( 72 , 145 ) ;
+ Size = MAP_APPFONT ( 76 , 14 ) ;
+ Text [ en-US ] = "Keep ~Mine" ;
+ };
+ PushButton BTN_KEEPOTHER
+ {
+ Pos = MAP_APPFONT ( 190 , 145 ) ;
+ Size = MAP_APPFONT ( 76 , 14 ) ;
+ Text [ en-US ] = "Keep ~Other" ;
+ };
+ FixedLine FL_CONFLICTS
+ {
+ Pos = MAP_APPFONT ( 1 , 162 ) ;
+ Size = MAP_APPFONT ( 338 , 8 ) ;
+ };
+ PushButton BTN_KEEPALLMINE
+ {
+ Pos = MAP_APPFONT ( 6 , 172 ) ;
+ Size = MAP_APPFONT ( 104 , 14 ) ;
+ Text [ en-US ] = "~Keep All Mine" ;
+ };
+ PushButton BTN_KEEPALLOTHERS
+ {
+ Pos = MAP_APPFONT ( 116 , 172 ) ;
+ Size = MAP_APPFONT ( 104 , 14 ) ;
+ Text [ en-US ] = "Keep ~All Others" ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 226 , 172 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 282 , 172 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String STR_TITLE_CONFLICT
+ {
+ Text [ en-US ] = "Conflict" ;
+ };
+ String STR_TITLE_AUTHOR
+ {
+ Text [ en-US ] = "Author" ;
+ };
+ String STR_TITLE_DATE
+ {
+ Text [ en-US ] = "Date" ;
+ };
+ String STR_UNKNOWN_USER
+ {
+ Text [ en-US ] = "Unknown User" ;
+ };
+};
+
diff --git a/sc/source/ui/miscdlgs/crdlg.cxx b/sc/source/ui/miscdlgs/crdlg.cxx
new file mode 100644
index 000000000000..f9413dda2068
--- /dev/null
+++ b/sc/source/ui/miscdlgs/crdlg.cxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "crdlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+ScColOrRowDlg::ScColOrRowDlg( Window* pParent,
+ const String& rStrTitle,
+ const String& rStrLabel,
+ BOOL bColDefault )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_COLORROW ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnRows ( this, ScResId( BTN_GROUP_ROWS ) ),
+ aBtnCols ( this, ScResId( BTN_GROUP_COLS ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ SetText( rStrTitle );
+ aFlFrame.SetText( rStrLabel );
+
+ if ( bColDefault )
+ aBtnCols.Check();
+ else
+ aBtnRows.Check();
+
+ aBtnOk.SetClickHdl( LINK( this, ScColOrRowDlg, OkHdl ) );
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScColOrRowDlg::~ScColOrRowDlg()
+{
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScColOrRowDlg, OkHdl, OKButton *, EMPTYARG )
+{
+ EndDialog( aBtnCols.IsChecked() ? SCRET_COLS : SCRET_ROWS );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScColOrRowDlg, OkHdl, OKButton *, EMPTYARG )
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/crnrdlg.cxx b/sc/source/ui/miscdlgs/crnrdlg.cxx
new file mode 100644
index 000000000000..0ba1bf1cbe5c
--- /dev/null
+++ b/sc/source/ui/miscdlgs/crnrdlg.cxx
@@ -0,0 +1,1175 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "crnrdlg.hrc"
+#include "docsh.hxx"
+
+#define _CRNRDLG_CXX
+#include "crnrdlg.hxx"
+#undef _CRNRDLG_CXX
+#include <vcl/msgbox.hxx>
+
+
+//============================================================================
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
+#define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()
+
+const ULONG nEntryDataCol = 0;
+const ULONG nEntryDataRow = 1;
+const ULONG nEntryDataDelim = 2;
+
+
+//============================================================================
+// class ScColRowNameRangesDlg
+
+
+/*************************************************************************
+#* Member: ScColRowNameRangesDlg Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Konstruktor der Klasse ScColRowNameRangesDlg.
+#* Initialisieren der Klassen- Mitglieder,
+#* Uebernahme der Range- Angaben und Aufruf
+#* der eigentlichen Initialisierungsroutine
+#*
+#* Input: Sfx- Verknuepfungen
+#* Parent- Window
+#* SCViewData
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+ScColRowNameRangesDlg::ScColRowNameRangesDlg( SfxBindings* pB,
+ SfxChildWindow* pCW,
+ Window* pParent,
+ ScViewData* ptrViewData )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_COLROWNAMERANGES ),
+ //
+ aFlAssign ( this, ScResId( FL_ASSIGN ) ),
+ aLbRange ( this, ScResId( LB_RANGE ) ),
+
+ aEdAssign ( this, this, ScResId( ED_AREA ) ),
+ aRbAssign ( this, ScResId( RB_AREA ), &aEdAssign, this ),
+ aBtnColHead ( this, ScResId( BTN_COLHEAD ) ),
+ aBtnRowHead ( this, ScResId( BTN_ROWHEAD ) ),
+ aFtAssign2 ( this, ScResId( FT_DATA_LABEL ) ),
+ aEdAssign2 ( this, this, ScResId( ED_DATA ) ),
+ aRbAssign2 ( this, ScResId( RB_DATA ), &aEdAssign2, this ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+
+ pEdActive ( NULL ),
+ bDlgLostFocus ( FALSE )
+{
+ xColNameRanges = pDoc->GetColNameRanges()->Clone();
+ xRowNameRanges = pDoc->GetRowNameRanges()->Clone();
+ Init();
+ FreeResource();
+}
+
+
+/*************************************************************************
+#* Member: ~ScColRowNameRangesDlg Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Destruktor der Klasse
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+__EXPORT ScColRowNameRangesDlg::~ScColRowNameRangesDlg()
+{
+}
+
+
+/*************************************************************************
+#* Member: Init Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Initialisierungs- Routine:
+#* Umlenken der Event- Handler und einstellen der
+#* Startparameter.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::Init()
+{
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCTAB nStartTab = 0;
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ SCTAB nEndTab = 0;
+
+ aBtnOk.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, OkBtnHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, CancelBtnHdl ) );
+ aBtnAdd.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, AddBtnHdl ) );
+ aBtnRemove.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, RemoveBtnHdl ) );
+ aLbRange.SetSelectHdl ( LINK( this, ScColRowNameRangesDlg, Range1SelectHdl ) );
+ aEdAssign.SetModifyHdl ( LINK( this, ScColRowNameRangesDlg, Range1DataModifyHdl ) );
+ aBtnColHead.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, ColClickHdl ) );
+ aBtnRowHead.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, RowClickHdl ) );
+ aEdAssign2.SetModifyHdl ( LINK( this, ScColRowNameRangesDlg, Range2DataModifyHdl ) );
+
+ Link aLink = LINK( this, ScColRowNameRangesDlg, GetFocusHdl );
+ aEdAssign.SetGetFocusHdl( aLink );
+ aRbAssign.SetGetFocusHdl( aLink );
+ aEdAssign2.SetGetFocusHdl( aLink );
+ aRbAssign2.SetGetFocusHdl( aLink );
+
+ aLink = LINK( this, ScColRowNameRangesDlg, LoseFocusHdl );
+ aEdAssign.SetLoseFocusHdl( aLink );
+ aRbAssign.SetLoseFocusHdl( aLink );
+ aEdAssign2.SetLoseFocusHdl( aLink );
+ aRbAssign2.SetLoseFocusHdl( aLink );
+
+ pEdActive = &aEdAssign;
+
+ UpdateNames();
+
+ if ( pViewData && pDoc )
+ {
+ pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab );
+ SetColRowData( ScRange( ScAddress( nStartCol, nStartRow, nStartTab ),
+ ScAddress( nEndCol, nEndRow, nEndTab ) ) );
+ }
+ else
+ {
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ aEdAssign.SetText( EMPTY_STRING );
+ aEdAssign2.SetText( EMPTY_STRING );
+ }
+
+ aLbRange.SetBorderStyle( WINDOW_BORDER_MONO );
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign.Enable();
+ aEdAssign.GrabFocus();
+ aRbAssign.Enable();
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable(); // Ref-Feld hat Focus
+
+ Range1SelectHdl( 0 );
+}
+
+
+/*************************************************************************
+#* Member: SetColRowData Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: zugehoerigen Datenbereich eines Beschriftungsbereiches
+#* auf default Werte setzen und beide Referenz-Edit-Felder
+#* fuellen.
+#*
+#* Input: Einstellbereich fuer Labels
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::SetColRowData( const ScRange& rLabelRange,BOOL bRef)
+{
+ theCurData = theCurArea = rLabelRange;
+ BOOL bValid = TRUE;
+ SCCOL nCol1 = theCurArea.aStart.Col();
+ SCCOL nCol2 = theCurArea.aEnd.Col();
+ SCROW nRow1 = theCurArea.aStart.Row();
+ SCROW nRow2 = theCurArea.aEnd.Row();
+ if ( (static_cast<SCCOLROW>(nCol2 - nCol1) >= nRow2 - nRow1) || (nCol1 == 0 && nCol2 == MAXCOL) )
+ { // Spaltenkoepfe und Grenzfall gesamte Tabelle
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ if ( nRow2 == MAXROW )
+ {
+ if ( nRow1 == 0 )
+ bValid = FALSE; // Grenzfall gesamte Tabelle
+ else
+ { // Head unten, Data oben
+ theCurData.aStart.SetRow( 0 );
+ theCurData.aEnd.SetRow( nRow1 - 1 );
+ }
+ }
+ else
+ { // Head oben, Data unten
+ theCurData.aStart.SetRow( nRow2 + 1 );
+ theCurData.aEnd.SetRow( MAXROW );
+ }
+ }
+ else
+ { // Zeilenkoepfe
+ aBtnRowHead.Check( TRUE );
+ aBtnColHead.Check( FALSE );
+ if ( nCol2 == MAXCOL )
+ { // Head rechts, Data links
+ theCurData.aStart.SetCol( 0 );
+ theCurData.aEnd.SetCol( nCol2 - 1 );
+ }
+ else
+ { // Head links, Data rechts
+ theCurData.aStart.SetCol( nCol2 + 1 );
+ theCurData.aEnd.SetCol( MAXCOL );
+ }
+ }
+ if ( bValid )
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ String aStr;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+
+ if(bRef)
+ aEdAssign.SetRefString( aStr );
+ else
+ aEdAssign.SetText( aStr );
+
+ aEdAssign.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
+ theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+
+ if(bRef)
+ aEdAssign2.SetRefString( aStr );
+ else
+ aEdAssign2.SetText( aStr );
+ }
+ else
+ {
+ theCurData = theCurArea = ScRange();
+
+ if(bRef)
+ {
+ aEdAssign.SetRefString( EMPTY_STRING );
+ aEdAssign2.SetRefString( EMPTY_STRING );
+ }
+ else
+ {
+ aEdAssign.SetText( EMPTY_STRING );
+ aEdAssign2.SetText( EMPTY_STRING );
+ }
+
+ aBtnColHead.Disable();
+ aBtnRowHead.Disable();
+ aEdAssign2.Disable();
+ aRbAssign2.Disable();
+ }
+}
+
+
+/*************************************************************************
+#* Member: AdjustColRowData Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: zugehoerigen Datenbereich eines Beschriftungsbereiches
+#* anpassen und Data-Referenz-Edit-Feld fuellen.
+#*
+#* Input: Bereich fuer Labels
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::AdjustColRowData( const ScRange& rDataRange,BOOL bRef)
+{
+ theCurData = rDataRange;
+ if ( aBtnColHead.IsChecked() )
+ { // Datenbereich gleiche Spalten wie Koepfe
+ theCurData.aStart.SetCol( theCurArea.aStart.Col() );
+ theCurData.aEnd.SetCol( theCurArea.aEnd.Col() );
+ if ( theCurData.Intersects( theCurArea ) )
+ {
+ SCROW nRow1 = theCurArea.aStart.Row();
+ SCROW nRow2 = theCurArea.aEnd.Row();
+ if ( nRow1 > 0
+ && (theCurData.aEnd.Row() < nRow2 || nRow2 == MAXROW) )
+ { // Data oben
+ theCurData.aEnd.SetRow( nRow1 - 1 );
+ if ( theCurData.aStart.Row() > theCurData.aEnd.Row() )
+ theCurData.aStart.SetRow( theCurData.aEnd.Row() );
+ }
+ else
+ { // Data unten
+ theCurData.aStart.SetRow( nRow2 + 1 );
+ if ( theCurData.aStart.Row() > theCurData.aEnd.Row() )
+ theCurData.aEnd.SetRow( theCurData.aStart.Row() );
+ }
+ }
+ }
+ else
+ { // Datenbereich gleiche Zeilen wie Koepfe
+ theCurData.aStart.SetRow( theCurArea.aStart.Row() );
+ theCurData.aEnd.SetRow( theCurArea.aEnd.Row() );
+ if ( theCurData.Intersects( theCurArea ) )
+ {
+ SCCOL nCol1 = theCurArea.aStart.Col();
+ SCCOL nCol2 = theCurArea.aEnd.Col();
+ if ( nCol1 > 0
+ && (theCurData.aEnd.Col() < nCol2 || nCol2 == MAXCOL) )
+ { // Data links
+ theCurData.aEnd.SetCol( nCol1 - 1 );
+ if ( theCurData.aStart.Col() > theCurData.aEnd.Col() )
+ theCurData.aStart.SetCol( theCurData.aEnd.Col() );
+ }
+ else
+ { // Data rechts
+ theCurData.aStart.SetCol( nCol2 + 1 );
+ if ( theCurData.aStart.Col() > theCurData.aEnd.Col() )
+ theCurData.aEnd.SetCol( theCurData.aStart.Col() );
+ }
+ }
+ }
+ String aStr;
+ theCurData.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+
+ if(bRef)
+ aEdAssign2.SetRefString( aStr );
+ else
+ aEdAssign2.SetText( aStr );
+
+ aEdAssign2.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
+}
+
+
+/*************************************************************************
+#* Member: SetReference Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Uebergabe eines mit der Maus selektierten Tabellen-
+#* bereiches, der dann als neue Selektion im Referenz-
+#* Fenster angezeigt wird.
+#*
+#* Input: Bereich fuer Labels
+#* Dokumentklasse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ )
+{
+ if ( pEdActive )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( pEdActive );
+
+ String aRefStr;
+ if ( pEdActive == &aEdAssign )
+ SetColRowData( rRef, TRUE );
+ else
+ AdjustColRowData( rRef, TRUE );
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aBtnAdd.Enable();
+ aBtnRemove.Disable();
+ }
+}
+
+
+/*************************************************************************
+#* Member: Close Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Schliessen des Fensters
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+BOOL __EXPORT ScColRowNameRangesDlg::Close()
+{
+ return DoClose( ScColRowNameRangesDlgWrapper::GetChildWindowId() );
+}
+
+
+/*************************************************************************
+#* Member: SetActive Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Aktivieren des Fensters
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+ if( pEdActive )
+ pEdActive->GrabFocus();
+ }
+ else
+ GrabFocus();
+
+ if( pEdActive == &aEdAssign )
+ Range1DataModifyHdl( 0 );
+ else if( pEdActive == &aEdAssign2 )
+ Range2DataModifyHdl( 0 );
+
+ RefInputDone();
+}
+
+
+/*************************************************************************
+#* Member: UpdateNames Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Aktualisieren der Namen
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::UpdateNames()
+{
+ aLbRange.SetUpdateMode( FALSE );
+ //-----------------------------------------------------------
+ aLbRange.Clear();
+ aRangeMap.clear();
+ aEdAssign.SetText( EMPTY_STRING );
+
+ ULONG nCount, j;
+ USHORT nPos; //@008 Hilfsvariable q eingefuegt
+
+ SCCOL nCol1; //@008 04.09.97
+ SCROW nRow1; //Erweiterung fuer Bereichsnamen
+ SCTAB nTab1;
+ SCCOL nCol2;
+ SCROW nRow2;
+ SCTAB nTab2;
+ String rString;
+ String strShow;
+ const ScAddress::Details aDetails(pDoc->GetAddressConvention());
+
+ String aString;
+ String strDelim = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( " --- " ));
+ aString = strDelim;
+ aString += ScGlobal::GetRscString( STR_COLUMN );
+ aString += strDelim;
+ nPos = aLbRange.InsertEntry( aString );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim );
+ if ( (nCount = xColNameRanges->Count()) > 0 )
+ {
+ ScRangePair** ppSortArray = xColNameRanges->CreateNameSortedArray(
+ nCount, pDoc );
+ for ( j=0; j < nCount; j++ )
+ {
+ const ScRange aRange(ppSortArray[j]->GetRange(0));
+ aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails );
+
+ //@008 Hole Bereichsparameter aus Dok
+ ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1,
+ nCol2, nRow2, nTab2 );
+ SCCOL q=nCol1+3;
+ if(q>nCol2) q=nCol2;
+ //@008 Baue String zusammen
+ strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" ["));
+ if(pDoc!=NULL)
+ {
+ pDoc->GetString(nCol1, nRow1, nTab1,rString);
+ strShow +=rString;
+ for(SCCOL i=nCol1+1;i<=q;i++)
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ pDoc->GetString(i, nRow1, nTab1,rString);
+ strShow += rString;
+ }
+ }
+ if(q<nCol2) // Zu lang? Ergaenzen um ",..."
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ..."));
+ }
+ strShow += ']';
+
+ //@008 String einfuegen in Listbox
+ String aInsStr = aString;
+ aInsStr += strShow;
+ nPos = aLbRange.InsertEntry( aInsStr );
+ aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataCol );
+ }
+ delete [] ppSortArray;
+ }
+ aString = strDelim;
+ aString += ScGlobal::GetRscString( STR_ROW );
+ aString += strDelim;
+ nPos = aLbRange.InsertEntry( aString );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim );
+ if ( (nCount = xRowNameRanges->Count()) > 0 )
+ {
+ ScRangePair** ppSortArray = xRowNameRanges->CreateNameSortedArray(
+ nCount, pDoc );
+ for ( j=0; j < nCount; j++ )
+ {
+ const ScRange aRange(ppSortArray[j]->GetRange(0));
+ aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails );
+
+ //@008 Ab hier baue String fuer Zeilen
+ ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1,
+ nCol2, nRow2, nTab2 );
+ SCROW q=nRow1+3;
+ if(q>nRow2) q=nRow2;
+ strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" ["));
+ if(pDoc!=NULL)
+ {
+ pDoc->GetString(nCol1, nRow1, nTab1,rString);
+ strShow += rString;
+ for(SCROW i=nRow1+1;i<=q;i++)
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ pDoc->GetString(nCol1, i, nTab1,rString);
+ strShow += rString;
+ }
+ }
+ if(q<nRow2)
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ..."));
+ }
+ strShow += ']';
+
+ String aInsStr = aString;
+ aInsStr += strShow;
+ nPos = aLbRange.InsertEntry( aInsStr );
+ aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataRow );
+ }
+ delete [] ppSortArray;
+ }
+ //-----------------------------------------------------------
+ aLbRange.SetUpdateMode( TRUE );
+ aLbRange.Invalidate();
+}
+
+
+/*************************************************************************
+#* Member: UpdateRangeData Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Aktualisieren der Bereichsdaten
+#*
+#* Input: Bereichs-String
+#* Flag fuer Spalten
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::UpdateRangeData( const ScRange& rRange, BOOL bColName )
+{
+ ScRangePair* pPair = NULL;
+ BOOL bFound = FALSE;
+ if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+ else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+
+ if ( bFound )
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ String aStr;
+ theCurArea = rRange;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+ aEdAssign.SetText( aStr );
+ aBtnAdd.Disable();
+ aBtnRemove.Enable();
+ aBtnColHead.Check( bColName );
+ aBtnRowHead.Check( !bColName );
+ theCurData = pPair->GetRange(1);
+ theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+ aEdAssign2.SetText( aStr );
+ }
+ else
+ {
+ aBtnAdd.Enable();
+ aBtnRemove.Disable();
+ }
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign2.Enable();
+ aRbAssign2.Enable();
+}
+
+
+/*************************************************************************
+#* Member: IsRefInputMode Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Abfragefunktion fuer Referenz- Input- Mode.
+#*
+#* Input: Bereichs-String
+#* Flag fuer Spalten
+#*
+#* Output: true, wenn Referenz- Input- Mode
+#*
+#************************************************************************/
+
+BOOL ScColRowNameRangesDlg::IsRefInputMode() const
+{
+ return (pEdActive != NULL);
+}
+
+//------------------------------------------------------------------------
+// Handler:
+// ========
+
+/*************************************************************************
+#* Handler: OkBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wird ausgeloest, wenn der OK- Button gedrueckt wurde.
+#* Hinzufuegen- Button ausloesen, und die neu einge-
+#* stellten Bereiche ans Dokument uebergeben.
+#* Fensterschliessen- Anweisung ausloesen.
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, OkBtnHdl, void *, EMPTYARG )
+{
+ AddBtnHdl( 0 );
+
+ // die RangeLists den Refs am Doc zuweisen
+ pDoc->GetColNameRangesRef() = xColNameRanges;
+ pDoc->GetRowNameRangesRef() = xRowNameRanges;
+ // geaenderte Datenbereiche muessen sich auswirken
+ pDoc->CompileColRowNameFormula();
+ ScDocShell* pDocShell = pViewData->GetDocShell();
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
+ pDocShell->SetDocumentModified();
+
+ Close();
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: CancelBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Fensterschliessen- Anweisung ausloesen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK_INLINE_START( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG )
+{
+ Close();
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG )
+
+
+/*************************************************************************
+#* Handler: AddBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Nach betaetigen des Hinzufuegen- Buttons, werden
+#* die Bereichsangaben eingestellt und in der
+#* Listbox dargestellt.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, AddBtnHdl, void *, EMPTYARG )
+{
+ String aNewArea( aEdAssign.GetText() );
+ String aNewData( aEdAssign2.GetText() );
+
+ if ( aNewArea.Len() > 0 && aNewData.Len() > 0 )
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ ScRange aRange1, aRange2;
+ BOOL bOk1;
+ if ( (bOk1 = ((aRange1.ParseAny( aNewArea, pDoc, eConv ) & SCA_VALID) == SCA_VALID)) != FALSE
+ && ((aRange2.ParseAny( aNewData, pDoc, eConv ) & SCA_VALID) == SCA_VALID) )
+ {
+ theCurArea = aRange1;
+ AdjustColRowData( aRange2 );
+ ScRangePair* pPair;
+ if ( ( pPair = xColNameRanges->Find( theCurArea ) ) != NULL )
+ {
+ xColNameRanges->Remove( pPair );
+ delete pPair;
+ }
+ if ( ( pPair = xRowNameRanges->Find( theCurArea ) ) != NULL )
+ {
+ xRowNameRanges->Remove( pPair );
+ delete pPair;
+ }
+ if ( aBtnColHead.IsChecked() )
+ xColNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
+ else
+ xRowNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
+
+ UpdateNames();
+
+ aEdAssign.GrabFocus();
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aEdAssign.SetText( EMPTY_STRING );
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ aEdAssign2.SetText( EMPTY_STRING );
+ theCurArea = ScRange();
+ theCurData = theCurArea;
+ Range1SelectHdl( 0 );
+ }
+ else
+ {
+ ERRORBOX( ScGlobal::GetRscString(STR_INVALIDTABNAME) );
+ if ( !bOk1 )
+ aEdAssign.GrabFocus();
+ else
+ aEdAssign2.GrabFocus();
+ }
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: RemoveBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Nach betaetigen des Loeschen- Buttons, wird
+#* die markierte Bereichsangabe geloescht.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, RemoveBtnHdl, void *, EMPTYARG )
+{
+ String aRangeStr = aLbRange.GetSelectEntry();
+ USHORT nSelectPos = aLbRange.GetSelectEntryPos();
+ BOOL bColName =
+ ((ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol);
+ NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr);
+ if (itr == aRangeMap.end())
+ return 0;
+ const ScRange& rRange = itr->second;
+
+ ScRangePair* pPair = NULL;
+ BOOL bFound = FALSE;
+ if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+ else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+ if ( bFound )
+ {
+ String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
+ String aMsg = aStrDelMsg.GetToken( 0, '#' );
+
+ aMsg += aRangeStr;
+ aMsg += aStrDelMsg.GetToken( 1, '#' );
+
+ if ( RET_YES == QUERYBOX(aMsg) )
+ {
+ if ( bColName )
+ xColNameRanges->Remove( pPair );
+ else
+ xRowNameRanges->Remove( pPair );
+ delete pPair;
+
+ UpdateNames();
+ USHORT nCnt = aLbRange.GetEntryCount();
+ if ( nSelectPos >= nCnt )
+ {
+ if ( nCnt )
+ nSelectPos = nCnt - 1;
+ else
+ nSelectPos = 0;
+ }
+ aLbRange.SelectEntryPos( nSelectPos );
+ if ( nSelectPos &&
+ (ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim )
+ aLbRange.SelectEntryPos( --nSelectPos ); // ---Zeile---
+
+ aLbRange.GrabFocus();
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aEdAssign.SetText( EMPTY_STRING );
+ theCurArea = theCurData = ScRange();
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ aEdAssign2.SetText( EMPTY_STRING );
+ Range1SelectHdl( 0 );
+ }
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: Range1SelectHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wenn Zeile in Listbox ausgewaehlt wird,
+#* werden die Eingabefelder entsprechend
+#* eingestellt.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, Range1SelectHdl, void *, EMPTYARG )
+{
+ USHORT nSelectPos = aLbRange.GetSelectEntryPos();
+ USHORT nCnt = aLbRange.GetEntryCount();
+ USHORT nMoves = 0;
+ while ( nSelectPos < nCnt
+ && (ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim )
+ { // skip Delimiter
+ ++nMoves;
+ aLbRange.SelectEntryPos( ++nSelectPos );
+ }
+ String aRangeStr = aLbRange.GetSelectEntry();
+ if ( nMoves )
+ {
+ if ( nSelectPos > 1 && nSelectPos >= nCnt )
+ { // am Ende nicht auf dem " --- Zeile --- " Delimiter stehenbleiben
+ // wenn davor Eintraege existieren
+ nSelectPos = nCnt - 2;
+ aLbRange.SelectEntryPos( nSelectPos );
+ aRangeStr = aLbRange.GetSelectEntry();
+ }
+ else if ( nSelectPos > 2 && nSelectPos < nCnt && aRangeStr.Len()
+ && aRangeStr == aEdAssign.GetText() )
+ { // nach oben wandern statt nach unten auf die vorherige Position
+ nSelectPos -= 2;
+ aLbRange.SelectEntryPos( nSelectPos );
+ aRangeStr = aLbRange.GetSelectEntry();
+ }
+ }
+ NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr);
+ if ( itr != aRangeMap.end() )
+ {
+ BOOL bColName =
+ ((ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol);
+ UpdateRangeData( itr->second, bColName );
+ aBtnAdd.Disable();
+ aBtnRemove.Enable();
+ }
+ else
+ {
+ if ( aEdAssign.GetText().Len() > 0 )
+ {
+ if ( aEdAssign2.GetText().Len() > 0 )
+ aBtnAdd.Enable();
+ else
+ aBtnAdd.Disable();
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign2.Enable();
+ aRbAssign2.Enable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ aBtnColHead.Disable();
+ aBtnRowHead.Disable();
+ aEdAssign2.Disable();
+ aRbAssign2.Disable();
+ }
+ aBtnRemove.Disable();
+ aEdAssign.GrabFocus();
+ }
+
+ aEdAssign.Enable();
+ aRbAssign.Enable();
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: Range1DataModifyHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wird ausgeloest, wenn in der Tabelle, der Label-
+#* Bereich geaendert wurde.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, Range1DataModifyHdl, void *, EMPTYARG )
+{
+ String aNewArea( aEdAssign.GetText() );
+ BOOL bValid = FALSE;
+ if ( aNewArea.Len() > 0 )
+ {
+ ScRange aRange;
+ if ( (aRange.ParseAny( aNewArea, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID )
+ {
+ SetColRowData( aRange );
+ bValid = TRUE;
+ }
+ }
+ if ( bValid )
+ {
+ aBtnAdd.Enable();
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign2.Enable();
+ aRbAssign2.Enable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ aBtnColHead.Disable();
+ aBtnRowHead.Disable();
+ aEdAssign2.Disable();
+ aRbAssign2.Disable();
+ }
+ aBtnRemove.Disable();
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: Range2DataModifyHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wird ausgeloest, wenn in der Tabelle, der Daten-
+#* Bereich geaendert wurde
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, Range2DataModifyHdl, void *, EMPTYARG )
+{
+ String aNewData( aEdAssign2.GetText() );
+ if ( aNewData.Len() > 0 )
+ {
+ ScRange aRange;
+ if ( (aRange.ParseAny( aNewData, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID )
+ {
+ AdjustColRowData( aRange );
+ aBtnAdd.Enable();
+ }
+ else
+ aBtnAdd.Disable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: ColClickHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Radiobutton fuer Spalten wurde betaetigt,
+#* die entsprechenden Einstellungen werden
+#* vorgenommen
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, ColClickHdl, void *, EMPTYARG )
+{
+ if ( !aBtnColHead.GetSavedValue() )
+ {
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ if ( theCurArea.aStart.Row() == 0 && theCurArea.aEnd.Row() == MAXROW )
+ {
+ theCurArea.aEnd.SetRow( MAXROW - 1 );
+ String aStr;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aEdAssign.SetText( aStr );
+ }
+ ScRange aRange( theCurData );
+ aRange.aStart.SetRow( Min( (long)(theCurArea.aEnd.Row() + 1), (long)MAXROW ) );
+ aRange.aEnd.SetRow( MAXROW );
+ AdjustColRowData( aRange );
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: RowClickHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Radiobutton fuer Zeilen wurde betaetigt,
+#* die entsprechenden Einstellungen werden
+#* vorgenommen
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, RowClickHdl, void *, EMPTYARG )
+{
+ if ( !aBtnRowHead.GetSavedValue() )
+ {
+ aBtnRowHead.Check( TRUE );
+ aBtnColHead.Check( FALSE );
+ if ( theCurArea.aStart.Col() == 0 && theCurArea.aEnd.Col() == MAXCOL )
+ {
+ theCurArea.aEnd.SetCol( MAXCOL - 1 );
+ String aStr;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aEdAssign.SetText( aStr );
+ }
+ ScRange aRange( theCurData );
+ aRange.aStart.SetCol( static_cast<SCCOL>(Min( (long)(theCurArea.aEnd.Col() + 1), (long)MAXCOL )) );
+ aRange.aEnd.SetCol( MAXCOL );
+ AdjustColRowData( aRange );
+ }
+ return 0;
+}
+
+
+IMPL_LINK( ScColRowNameRangesDlg, GetFocusHdl, Control*, pCtrl )
+{
+ if( (pCtrl == (Control*)&aEdAssign) || (pCtrl == (Control*)&aRbAssign) )
+ pEdActive = &aEdAssign;
+ else if( (pCtrl == (Control*)&aEdAssign2) || (pCtrl == (Control*)&aRbAssign2) )
+ pEdActive = &aEdAssign2;
+ else
+ pEdActive = NULL;
+
+ if( pEdActive )
+ pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+
+IMPL_LINK( ScColRowNameRangesDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ bDlgLostFocus = !IsActive();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/datafdlg.cxx b/sc/source/ui/miscdlgs/datafdlg.cxx
new file mode 100644
index 000000000000..3e859e9676a5
--- /dev/null
+++ b/sc/source/ui/miscdlgs/datafdlg.cxx
@@ -0,0 +1,425 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Amelia Wang <amwang@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+//------------------------------------------------------------------
+
+#include "datafdlg.hxx"
+#include "scresid.hxx"
+#include "datafdlg.hrc"
+#include "viewdata.hxx"
+//#include "document.hxx"
+#include "docsh.hxx"
+#include "refundo.hxx"
+#include "undodat.hxx"
+
+#include "rtl/ustrbuf.hxx"
+
+#define HDL(hdl) LINK( this, ScDataFormDlg, hdl )
+
+using ::rtl::OUStringBuffer;
+
+//zhangyun
+ScDataFormDlg::ScDataFormDlg( Window* pParent, ScTabViewShell* pTabViewShellOri) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DATAFORM ) ),
+ //
+ aBtnNew ( this, ScResId( BTN_DATAFORM_NEW ) ),
+ aBtnDelete ( this, ScResId( BTN_DATAFORM_DELETE ) ),
+ aBtnRestore ( this, ScResId( BTN_DATAFORM_RESTORE ) ),
+ aBtnLast ( this, ScResId( BTN_DATAFORM_LAST ) ),
+ aBtnNext ( this, ScResId( BTN_DATAFORM_NEXT ) ),
+ aBtnClose ( this, ScResId( BTN_DATAFORM_CLOSE ) ),
+ aSlider ( this, ScResId( WND_DATAFORM_SCROLLBAR ) ),
+ aFixedText ( this, ScResId( LAB_DATAFORM_RECORDNO ) )
+{
+ pTabViewShell = pTabViewShellOri;
+ FreeResource();
+ //read header form current document, and add new controls
+ DBG_ASSERT( pTabViewShell, "pTabViewShell is NULL! :-/" );
+ ScViewData* pViewData = pTabViewShell->GetViewData();
+
+ pDoc = pViewData->GetDocument();
+ if (pDoc)
+ {
+ ScRange aRange;
+ pViewData->GetSimpleArea( aRange );
+ ScAddress aStart = aRange.aStart;
+ ScAddress aEnd = aRange.aEnd;
+
+ nStartCol = aStart.Col();
+ nEndCol = aEnd.Col();
+ nStartRow = aStart.Row();
+ nEndRow = aEnd.Row();
+
+ nTab = pViewData->GetTabNo();
+ //if there is no selection
+ if ((nStartCol == nEndCol) && (nStartRow == nEndRow))
+ bNoSelection = TRUE;
+
+ if (bNoSelection)
+ {
+ //find last not blank cell in row
+ for (int i=1;i<=MAX_DATAFORM_COLS;i++)
+ {
+ String aColName;
+ nEndCol++;
+ pDoc->GetString( nEndCol, nStartRow, nTab, aColName );
+ int nColWidth = pDoc->GetColWidth( nEndCol, nTab );
+ if ( aColName.Len() == 0 && nColWidth)
+ {
+ nEndCol--;
+ break;
+ }
+ }
+
+ //find first not blank cell in row
+ for (int i=1;i<=MAX_DATAFORM_COLS;i++)
+ {
+ String aColName;
+ if (nStartCol <= 0)
+ break;
+ nStartCol--;
+
+ pDoc->GetString( nStartCol, nStartRow, nTab, aColName );
+ int nColWidth = pDoc->GetColWidth( nEndCol, nTab );
+ if ( aColName.Len() == 0 && nColWidth)
+ {
+ nStartCol++;
+ break;
+ }
+ }
+
+ //skip leading hide column
+ for (int i=1;i<=MAX_DATAFORM_COLS;i++)
+ {
+ String aColName;
+ int nColWidth = pDoc->GetColWidth( nStartCol, nTab );
+ if (nColWidth)
+ break;
+ nStartCol++;
+ }
+
+ if (nEndCol < nStartCol)
+ nEndCol = nStartCol;
+
+ //find last not blank cell in row
+ for (int i=1;i<=MAX_DATAFORM_ROWS;i++)
+ {
+ String aColName;
+ nEndRow++;
+ pDoc->GetString( nStartCol, nEndRow, nTab, aColName );
+ if ( aColName.Len() == 0 )
+ {
+ nEndRow--;
+ break;
+ }
+ }
+
+ //find first not blank cell in row
+ for (int i=1;i<=MAX_DATAFORM_ROWS;i++)
+ {
+ String aColName;
+ if (nStartRow <= 0)
+ break;
+ nStartRow--;
+
+ pDoc->GetString( nStartCol, nStartRow, nTab, aColName );
+ if ( aColName.Len() == 0 )
+ {
+ nStartRow++;
+ break;
+ }
+ }
+
+ if (nEndRow < nStartRow)
+ nEndRow = nStartRow;
+ }
+
+ aCurrentRow = nStartRow + 1;
+
+ String aFieldName;
+
+ int nTop = 12;
+
+ Size nFixedSize(FIXED_WIDTH, CTRL_HEIGHT );
+ Size nEditSize(EDIT_WIDTH, CTRL_HEIGHT );
+
+ //pFtArray = new FixedText(this);
+ aColLength = nEndCol - nStartCol + 1;
+
+ //new the controls
+ pFixedTexts = new FixedText*[aColLength];
+ pEdits = new Edit*[aColLength];
+
+ for(sal_uInt16 nIndex = 0; nIndex < aColLength; nIndex++)
+ {
+ pDoc->GetString( nIndex + nStartCol, nStartRow, nTab, aFieldName );
+ int nColWidth = pDoc->GetColWidth( nIndex + nStartCol, nTab );
+ if (nColWidth)
+ {
+ pFixedTexts[nIndex] = new FixedText(this);
+ pEdits[nIndex] = new Edit(this, WB_BORDER);
+
+ pFixedTexts[nIndex]->SetSizePixel(nFixedSize);
+ pEdits[nIndex]->SetSizePixel(nEditSize);
+ pFixedTexts[nIndex]->SetPosPixel(Point(FIXED_LEFT, nTop));
+ pEdits[nIndex]->SetPosPixel(Point(EDIT_LEFT, nTop));
+ //pFixedTexts[nIndex]->SetText(String::CreateFromAscii("W4W-Filter Nr. "));
+ pFixedTexts[nIndex]->SetText(aFieldName);
+ pFixedTexts[nIndex]->Show();
+ pEdits[nIndex]->Show();
+
+ nTop += LINE_HEIGHT;
+ }
+ else
+ {
+ pFixedTexts[nIndex] = NULL;
+ pEdits[nIndex] = NULL;
+ }
+ pEdits[nIndex]->SetModifyHdl( HDL(Impl_DataModifyHdl) );
+ }
+
+ Size nDialogSize = this->GetSizePixel();
+ if (nTop > nDialogSize.Height())
+ {
+ nDialogSize.setHeight(nTop);
+ this->SetSizePixel(nDialogSize);
+ }
+ Size nScrollSize = aSlider.GetSizePixel();
+ nScrollSize.setHeight(nDialogSize.Height()-20);
+ aSlider.SetSizePixel(nScrollSize);
+ }
+
+ FillCtrls(aCurrentRow);
+
+ aSlider.SetPageSize( 10 );
+ aSlider.SetVisibleSize( 1 );
+ aSlider.SetLineSize( 1 );
+ aSlider.SetRange( Range( 0, nEndRow - nStartRow + 1) );
+ aSlider.Show();
+
+ aBtnNew.SetClickHdl ( HDL(Impl_NewHdl) );
+ aBtnLast.SetClickHdl ( HDL(Impl_LastHdl) );
+ aBtnNext.SetClickHdl ( HDL(Impl_NextHdl) );
+
+ aBtnRestore.SetClickHdl ( HDL(Impl_RestoreHdl) );
+ aBtnDelete.SetClickHdl ( HDL(Impl_DeleteHdl) );
+ aBtnClose.SetClickHdl ( HDL(Impl_CloseHdl) );
+
+ aSlider.SetEndScrollHdl( HDL( Impl_ScrollHdl ) );
+
+ SetButtonState();
+
+ //end
+ //FreeResource();
+}
+
+ScDataFormDlg::~ScDataFormDlg()
+{
+ for(sal_uInt16 i = 0; i < aColLength; i++)
+ {
+ if (pEdits[i])
+ delete pEdits[i];
+ if (pFixedTexts[i])
+ delete pFixedTexts[i];
+ }
+ if (pEdits)
+ delete pEdits;
+ if (pFixedTexts)
+ delete pFixedTexts;
+}
+
+void ScDataFormDlg::FillCtrls(SCROW /*nCurrentRow*/)
+{
+ //ScViewData* pViewData = pTabViewShell->GetViewData();
+
+ String aFieldName;
+ for (sal_uInt16 i = 0; i < aColLength; ++i)
+ {
+ if (pEdits[i])
+ {
+ if (aCurrentRow<=nEndRow)
+ {
+ pDoc->GetString( i + nStartCol, aCurrentRow, nTab, aFieldName );
+ pEdits[i]->SetText(aFieldName);
+ }
+ else
+ pEdits[i]->SetText(String());
+ }
+ }
+
+ if (aCurrentRow <= nEndRow)
+ {
+ OUStringBuffer aBuf;
+ aBuf.append(static_cast<sal_Int32>(aCurrentRow - nStartRow));
+ aBuf.appendAscii(" / ");
+ aBuf.append(static_cast<sal_Int32>(nEndRow - nStartRow));
+ aFixedText.SetText(aBuf.makeStringAndClear());
+ }
+ else
+ aFixedText.SetText(String(ScResId(STR_NEW_RECORD)));
+
+ aSlider.SetThumbPos(aCurrentRow-nStartRow-1);
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_DataModifyHdl, Edit*, pEdit)
+{
+ if ( pEdit->IsModified() )
+ aBtnRestore.Enable( TRUE );
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_NewHdl, PushButton*, EMPTYARG )
+{
+ ScViewData* pViewData = pTabViewShell->GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ if ( pDoc )
+ {
+ sal_Bool bHasData = sal_False;
+ for(sal_uInt16 i = 0; i < aColLength; i++)
+ if (pEdits[i])
+ if ( pEdits[i]->GetText().Len() != 0 )
+ {
+ bHasData = sal_True;
+ break;
+ }
+
+ if ( bHasData )
+ {
+ pTabViewShell->DataFormPutData( aCurrentRow , nStartRow , nStartCol , nEndRow , nEndCol , pEdits , aColLength );
+ aCurrentRow++;
+ if (aCurrentRow >= nEndRow + 2)
+ {
+ nEndRow ++ ;
+ aSlider.SetRange( Range( 0, nEndRow - nStartRow + 1) );
+ }
+ SetButtonState();
+ FillCtrls(aCurrentRow);
+ pDocSh->SetDocumentModified();
+ pDocSh->PostPaintGridAll();
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_LastHdl, PushButton*, EMPTYARG )
+{
+ if (pDoc)
+ {
+ if ( aCurrentRow > nStartRow +1 )
+ aCurrentRow--;
+
+ SetButtonState();
+ FillCtrls(aCurrentRow);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_NextHdl, PushButton*, EMPTYARG )
+{
+ if (pDoc)
+ {
+ if ( aCurrentRow <= nEndRow)
+ aCurrentRow++;
+
+ SetButtonState();
+ FillCtrls(aCurrentRow);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_RestoreHdl, PushButton*, EMPTYARG )
+{
+ if (pDoc)
+ {
+ FillCtrls(aCurrentRow);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_DeleteHdl, PushButton*, EMPTYARG )
+{
+ ScViewData* pViewData = pTabViewShell->GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ if (pDoc)
+ {
+ ScRange aRange(nStartCol, aCurrentRow, nTab, nEndCol, aCurrentRow, nTab);
+ pDoc->DeleteRow(aRange);
+ nEndRow--;
+
+ SetButtonState();
+ pDocSh->GetUndoManager()->Clear();
+
+ FillCtrls(aCurrentRow);
+ pDocSh->SetDocumentModified();
+ pDocSh->PostPaintGridAll();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_CloseHdl, PushButton*, EMPTYARG )
+{
+ EndDialog( );
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_ScrollHdl, ScrollBar*, EMPTYARG )
+{
+ long nOffset = aSlider.GetThumbPos();
+ aCurrentRow = nStartRow + nOffset + 1;
+ SetButtonState();
+ FillCtrls(aCurrentRow);
+ return 0;
+}
+
+void ScDataFormDlg::SetButtonState()
+{
+ if ( aCurrentRow > nEndRow )
+ {
+ aBtnDelete.Enable( FALSE );
+ aBtnLast.Enable( TRUE );
+ aBtnNext.Enable( FALSE );
+ }
+ else
+ {
+ aBtnDelete.Enable( TRUE );
+ aBtnNext.Enable( TRUE );
+ }
+ if ( 1 == aCurrentRow )
+ aBtnLast.Enable( FALSE );
+
+ aBtnRestore.Enable( FALSE );
+ if ( pEdits )
+ pEdits[0]->GrabFocus();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/delcldlg.cxx b/sc/source/ui/miscdlgs/delcldlg.cxx
new file mode 100644
index 000000000000..6ece4b648d64
--- /dev/null
+++ b/sc/source/ui/miscdlgs/delcldlg.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "delcldlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+static BYTE nDelItemChecked=0;
+
+//==================================================================
+
+ScDeleteCellDlg::ScDeleteCellDlg( Window* pParent, BOOL bDisallowCellMove ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DELCELL ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnCellsUp ( this, ScResId( BTN_CELLSUP ) ),
+ aBtnCellsLeft ( this, ScResId( BTN_CELLSLEFT ) ),
+ aBtnDelRows ( this, ScResId( BTN_DELROWS ) ),
+ aBtnDelCols ( this, ScResId( BTN_DELCOLS ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+
+ if (bDisallowCellMove)
+ {
+ aBtnCellsUp.Disable();
+ aBtnCellsLeft.Disable();
+
+ switch(nDelItemChecked)
+ {
+ case 2: aBtnDelRows.Check();break;
+ case 3: aBtnDelCols.Check();break;
+ default:aBtnDelRows.Check();break;
+ }
+ }
+ else
+ {
+ switch(nDelItemChecked)
+ {
+ case 0: aBtnCellsUp.Check();break;
+ case 1: aBtnCellsLeft.Check();break;
+ case 2: aBtnDelRows.Check();break;
+ case 3: aBtnDelCols.Check();break;
+ }
+ }
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+DelCellCmd ScDeleteCellDlg::GetDelCellCmd() const
+{
+ DelCellCmd nReturn = DEL_NONE;
+
+ if ( aBtnCellsUp.IsChecked() )
+ {
+ nDelItemChecked=0;
+ nReturn = DEL_CELLSUP;
+ }
+ else if ( aBtnCellsLeft.IsChecked() )
+ {
+ nDelItemChecked=1;
+ nReturn = DEL_CELLSLEFT;
+ }
+ else if ( aBtnDelRows.IsChecked() )
+ {
+ nDelItemChecked=2;
+ nReturn = DEL_DELROWS;
+ }
+ else if ( aBtnDelCols.IsChecked() )
+ {
+ nDelItemChecked=3;
+ nReturn = DEL_DELCOLS;
+ }
+
+ return nReturn;
+}
+
+__EXPORT ScDeleteCellDlg::~ScDeleteCellDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/delcodlg.cxx b/sc/source/ui/miscdlgs/delcodlg.cxx
new file mode 100644
index 000000000000..c98721eb4aff
--- /dev/null
+++ b/sc/source/ui/miscdlgs/delcodlg.cxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "delcodlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+BOOL ScDeleteContentsDlg::bPreviousAllCheck = FALSE;
+USHORT ScDeleteContentsDlg::nPreviousChecks = (IDF_DATETIME | IDF_STRING |
+ IDF_NOTE | IDF_FORMULA |
+ IDF_VALUE);
+
+//-----------------------------------------------------------------------
+
+ScDeleteContentsDlg::ScDeleteContentsDlg( Window* pParent,
+ USHORT nCheckDefaults ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DELCONT ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnDelAll ( this, ScResId( BTN_DELALL ) ),
+ aBtnDelStrings ( this, ScResId( BTN_DELSTRINGS ) ),
+ aBtnDelNumbers ( this, ScResId( BTN_DELNUMBERS ) ),
+ aBtnDelDateTime ( this, ScResId( BTN_DELDATETIME ) ),
+ aBtnDelFormulas ( this, ScResId( BTN_DELFORMULAS ) ),
+ aBtnDelNotes ( this, ScResId( BTN_DELNOTES ) ),
+ aBtnDelAttrs ( this, ScResId( BTN_DELATTRS ) ),
+ aBtnDelObjects ( this, ScResId( BTN_DELOBJECTS ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ bObjectsDisabled( FALSE )
+{
+ if ( nCheckDefaults != 0 )
+ {
+ ScDeleteContentsDlg::nPreviousChecks = nCheckDefaults;
+ ScDeleteContentsDlg::bPreviousAllCheck = FALSE;
+ }
+
+ aBtnDelAll.Check ( ScDeleteContentsDlg::bPreviousAllCheck );
+ aBtnDelStrings.Check ( IS_SET( IDF_STRING,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+ aBtnDelNumbers.Check ( IS_SET( IDF_VALUE,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+ aBtnDelDateTime.Check( IS_SET( IDF_DATETIME,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+ aBtnDelFormulas.Check( IS_SET( IDF_FORMULA,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+ aBtnDelNotes.Check ( IS_SET( IDF_NOTE,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+ aBtnDelAttrs.Check ( IS_SET( IDF_ATTRIB,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+ aBtnDelObjects.Check ( IS_SET( IDF_OBJECTS,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+
+ DisableChecks( aBtnDelAll.IsChecked() );
+
+ aBtnDelAll.SetClickHdl( LINK( this, ScDeleteContentsDlg, DelAllHdl ) );
+
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScDeleteContentsDlg::GetDelContentsCmdBits() const
+{
+ ScDeleteContentsDlg::nPreviousChecks = 0;
+
+ if ( aBtnDelStrings.IsChecked() )
+ ScDeleteContentsDlg::nPreviousChecks = IDF_STRING;
+ if ( aBtnDelNumbers.IsChecked() )
+ ScDeleteContentsDlg::nPreviousChecks |= IDF_VALUE;
+ if ( aBtnDelDateTime.IsChecked())
+ ScDeleteContentsDlg::nPreviousChecks |= IDF_DATETIME;
+ if ( aBtnDelFormulas.IsChecked())
+ ScDeleteContentsDlg::nPreviousChecks |= IDF_FORMULA;
+ if ( aBtnDelNotes.IsChecked() )
+ ScDeleteContentsDlg::nPreviousChecks |= IDF_NOTE;
+ if ( aBtnDelAttrs.IsChecked() )
+ ScDeleteContentsDlg::nPreviousChecks |= IDF_ATTRIB;
+ if ( aBtnDelObjects.IsChecked() )
+ ScDeleteContentsDlg::nPreviousChecks |= IDF_OBJECTS;
+
+ ScDeleteContentsDlg::bPreviousAllCheck = aBtnDelAll.IsChecked();
+
+ return ( (ScDeleteContentsDlg::bPreviousAllCheck)
+ ? IDF_ALL
+ : ScDeleteContentsDlg::nPreviousChecks );
+}
+
+//------------------------------------------------------------------------
+
+void ScDeleteContentsDlg::DisableChecks( BOOL bDelAllChecked )
+{
+ if ( bDelAllChecked )
+ {
+ aBtnDelStrings.Disable();
+ aBtnDelNumbers.Disable();
+ aBtnDelDateTime.Disable();
+ aBtnDelFormulas.Disable();
+ aBtnDelNotes.Disable();
+ aBtnDelAttrs.Disable();
+ aBtnDelObjects.Disable();
+ }
+ else
+ {
+ aBtnDelStrings.Enable();
+ aBtnDelNumbers.Enable();
+ aBtnDelDateTime.Enable();
+ aBtnDelFormulas.Enable();
+ aBtnDelNotes.Enable();
+ aBtnDelAttrs.Enable();
+ if (bObjectsDisabled)
+ aBtnDelObjects.Disable();
+ else
+ aBtnDelObjects.Enable();
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScDeleteContentsDlg::DisableObjects()
+{
+ bObjectsDisabled = TRUE;
+ aBtnDelObjects.Check(FALSE);
+ aBtnDelObjects.Disable();
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScDeleteContentsDlg, DelAllHdl, void *, EMPTYARG )
+{
+ DisableChecks( aBtnDelAll.IsChecked() );
+
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScDeleteContentsDlg, DelAllHdl, void *, EMPTYARG )
+
+__EXPORT ScDeleteContentsDlg::~ScDeleteContentsDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/filldlg.cxx b/sc/source/ui/miscdlgs/filldlg.cxx
new file mode 100644
index 000000000000..aa70e7cfb7ba
--- /dev/null
+++ b/sc/source/ui/miscdlgs/filldlg.cxx
@@ -0,0 +1,377 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//----------------------------------------------------------------------------
+
+#include <svl/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+#include <limits.h>
+
+#include "scresid.hxx"
+#include "document.hxx"
+#include "miscdlgs.hrc"
+
+#define _FILLDLG_CXX
+#include "filldlg.hxx"
+#undef _FILLDLG_CXX
+
+
+
+//============================================================================
+// class ScFillSeriesDlg
+
+//----------------------------------------------------------------------------
+
+ScFillSeriesDlg::ScFillSeriesDlg( Window* pParent,
+ ScDocument& rDocument,
+ FillDir eFillDir,
+ FillCmd eFillCmd,
+ FillDateCmd eFillDateCmd,
+ String aStartStr,
+ double fStep,
+ double fMax,
+ USHORT nPossDir )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_FILLSERIES ) ),
+
+ aFlDirection ( this, ScResId( FL_DIRECTION ) ),
+ aBtnDown ( this, ScResId( BTN_BOTTOM ) ),
+ aBtnRight ( this, ScResId( BTN_RIGHT ) ),
+ aBtnUp ( this, ScResId( BTN_TOP ) ),
+ aBtnLeft ( this, ScResId( BTN_LEFT ) ),
+ aFlSep1 ( this, ScResId( FL_SEP1 ) ),
+ aFlType ( this, ScResId( FL_TYPE ) ),
+ aBtnArithmetic ( this, ScResId( BTN_ARITHMETIC ) ),
+ aBtnGeometric ( this, ScResId( BTN_GEOMETRIC ) ),
+ aBtnDate ( this, ScResId( BTN_DATE ) ),
+ aBtnAutoFill ( this, ScResId( BTN_AUTOFILL ) ),
+ aFlSep2 ( this, ScResId( FL_SEP2 ) ),
+ aFlTimeUnit ( this, ScResId( FL_TIME_UNIT ) ),
+ aBtnDay ( this, ScResId( BTN_DAY ) ),
+ aBtnDayOfWeek ( this, ScResId( BTN_DAY_OF_WEEK ) ),
+ aBtnMonth ( this, ScResId( BTN_MONTH ) ),
+ aBtnYear ( this, ScResId( BTN_YEAR ) ),
+
+ aFtStartVal ( this, ScResId( FT_START_VALUE ) ),
+ aEdStartVal ( this, ScResId( ED_START_VALUES ) ),
+ aStartStrVal ( aStartStr),
+ aFtEndVal ( this, ScResId( FT_END_VALUE ) ),
+ aEdEndVal ( this, ScResId( ED_END_VALUES ) ),
+ aFtIncrement ( this, ScResId( FT_INCREMENT ) ),
+ aEdIncrement ( this, ScResId( ED_INCREMENT ) ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ errMsgInvalidVal( ScResId( STR_VALERR ) ),
+ rDoc ( rDocument ),
+ theFillDir ( eFillDir ),
+ theFillCmd ( eFillCmd ),
+ theFillDateCmd ( eFillDateCmd ),
+ fIncrement ( fStep ),
+ fEndVal ( fMax )
+{
+ Init( nPossDir );
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScFillSeriesDlg::~ScFillSeriesDlg()
+{
+}
+
+//----------------------------------------------------------------------------
+
+void ScFillSeriesDlg::SetEdStartValEnabled(BOOL bFlag)
+{
+ bStartValFlag=bFlag;
+ if(bFlag)
+ {
+ aFtStartVal.Enable();
+ aEdStartVal.Enable();
+ }
+ else
+ {
+ aFtStartVal.Disable();
+ aEdStartVal.Disable();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScFillSeriesDlg::Init( USHORT nPossDir )
+{
+ aBtnOk.SetClickHdl ( LINK( this, ScFillSeriesDlg, OKHdl ) );
+ aBtnArithmetic.SetClickHdl ( LINK( this, ScFillSeriesDlg, DisableHdl ) );
+ aBtnGeometric.SetClickHdl ( LINK( this, ScFillSeriesDlg, DisableHdl ) );
+ aBtnDate.SetClickHdl ( LINK( this, ScFillSeriesDlg, DisableHdl ) );
+ aBtnAutoFill.SetClickHdl ( LINK( this, ScFillSeriesDlg, DisableHdl ) );
+
+ if( nPossDir == FDS_OPT_NONE )
+ {
+ aBtnLeft.Disable();
+ aBtnRight.Disable();
+ aBtnDown.Disable();
+ aBtnUp.Disable();
+ }
+
+ if( nPossDir == FDS_OPT_HORZ )
+ {
+ aBtnDown.Disable();
+ aBtnUp.Disable();
+ }
+
+ if( nPossDir == FDS_OPT_VERT )
+ {
+ aBtnLeft.Disable();
+ aBtnRight.Disable();
+ }
+
+ switch ( theFillDir )
+ {
+ case FILL_TO_LEFT: aBtnLeft.Check(); break;
+ case FILL_TO_RIGHT: aBtnRight.Check(); break;
+ case FILL_TO_BOTTOM: aBtnDown.Check(); break;
+ case FILL_TO_TOP: aBtnUp.Check(); break;
+ default:
+ break;
+ }
+
+ switch ( theFillCmd )
+ {
+ case FILL_LINEAR:
+ aBtnArithmetic.Check();
+ DisableHdl( &aBtnArithmetic );
+ break;
+ case FILL_GROWTH:
+ aBtnGeometric.Check();
+ DisableHdl( &aBtnGeometric );
+ break;
+ case FILL_DATE:
+ aBtnDate.Check();
+ DisableHdl( &aBtnDate );
+ break;
+ case FILL_AUTO:
+ aBtnAutoFill.Check();
+ DisableHdl( &aBtnAutoFill );
+ break;
+ default:
+ break;
+ }
+
+ switch ( theFillDateCmd )
+ {
+ case FILL_DAY: aBtnDay.Check(); break;
+ case FILL_WEEKDAY: aBtnDayOfWeek.Check(); break;
+ case FILL_MONTH: aBtnMonth.Check(); break;
+ case FILL_YEAR: aBtnYear.Check(); break;
+ default:
+ break;
+ }
+
+ fStartVal = MAXDOUBLE;
+ /*
+ String aStartTxt;
+ if ( fStartVal != MAXDOUBLE )
+ rDoc.GetFormatTable()->GetInputLineString( fStartVal, 0, aStartTxt );
+ aEdStartVal.SetText( aStartTxt );
+ */
+
+ aEdStartVal.SetText( aStartStrVal);
+
+ String aIncrTxt;
+ rDoc.GetFormatTable()->GetInputLineString( fIncrement, 0, aIncrTxt );
+ aEdIncrement.SetText( aIncrTxt );
+
+ String aEndTxt;
+ if ( fEndVal != MAXDOUBLE )
+ rDoc.GetFormatTable()->GetInputLineString( fEndVal, 0, aEndTxt );
+ aEdEndVal.SetText( aEndTxt );
+
+ bStartValFlag=FALSE;
+
+ aFlSep1.SetStyle( aFlSep1.GetStyle() | WB_VERT );
+ aFlSep2.SetStyle( aFlSep2.GetStyle() | WB_VERT );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScFillSeriesDlg::CheckStartVal()
+{
+ BOOL bValOk = FALSE;
+ sal_uInt32 nKey = 0;
+ String aStr( aEdStartVal.GetText() );
+
+ if ( aStr.Len() == 0 || aBtnAutoFill.IsChecked())
+ {
+ fStartVal = MAXDOUBLE;
+ bValOk = TRUE;
+ }
+ else
+ bValOk = rDoc.GetFormatTable()->IsNumberFormat( aStr, nKey, fStartVal );
+
+ return bValOk;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScFillSeriesDlg::CheckIncrementVal()
+{
+ sal_uInt32 nKey = 0;
+ String aStr( aEdIncrement.GetText() );
+
+ return rDoc.GetFormatTable()->IsNumberFormat( aStr, nKey, fIncrement );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScFillSeriesDlg::CheckEndVal()
+{
+ BOOL bValOk = FALSE;
+ sal_uInt32 nKey = 0;
+ String aStr( aEdEndVal.GetText() );
+
+ if ( aStr.Len() == 0 )
+ {
+ fEndVal = (fIncrement < 0) ? -MAXDOUBLE : MAXDOUBLE;
+ bValOk = TRUE;
+ }
+ else
+ bValOk = rDoc.GetFormatTable()->IsNumberFormat( aStr, nKey, fEndVal );
+
+ return bValOk;
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFillSeriesDlg, DisableHdl, Button *, pBtn )
+{
+ if ( pBtn == &aBtnDate )
+ {
+ aBtnDay.Enable();
+ aBtnDayOfWeek.Enable();
+ aBtnMonth.Enable();
+ aBtnYear.Enable();
+ aFlTimeUnit.Enable();
+ }
+ else
+ {
+ aBtnDay.Disable();
+ aBtnDayOfWeek.Disable();
+ aBtnMonth.Disable();
+ aBtnYear.Disable();
+ aFlTimeUnit.Disable();
+ }
+
+ if ( pBtn != &aBtnAutoFill )
+ {
+ aFtIncrement.Enable();
+ aEdIncrement.Enable();
+ aFtEndVal.Enable();
+ aEdEndVal.Enable();
+ }
+ else
+ {
+ aFtIncrement.Disable();
+ aEdIncrement.Disable();
+ aFtEndVal.Disable();
+ aEdEndVal.Disable();
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFillSeriesDlg, OKHdl, void *, EMPTYARG )
+{
+ if ( aBtnLeft.IsChecked() ) theFillDir = FILL_TO_LEFT;
+ else if ( aBtnRight.IsChecked() ) theFillDir = FILL_TO_RIGHT;
+ else if ( aBtnDown.IsChecked() ) theFillDir = FILL_TO_BOTTOM;
+ else if ( aBtnUp.IsChecked() ) theFillDir = FILL_TO_TOP;
+
+ if ( aBtnArithmetic.IsChecked() ) theFillCmd = FILL_LINEAR;
+ else if ( aBtnGeometric.IsChecked() ) theFillCmd = FILL_GROWTH;
+ else if ( aBtnDate.IsChecked() ) theFillCmd = FILL_DATE;
+ else if ( aBtnAutoFill.IsChecked() ) theFillCmd = FILL_AUTO;
+
+ if ( aBtnDay.IsChecked() ) theFillDateCmd = FILL_DAY;
+ else if ( aBtnDayOfWeek.IsChecked() ) theFillDateCmd = FILL_WEEKDAY;
+ else if ( aBtnMonth.IsChecked() ) theFillDateCmd = FILL_MONTH;
+ else if ( aBtnYear.IsChecked() ) theFillDateCmd = FILL_YEAR;
+
+ BOOL bAllOk = TRUE;
+ Edit* pEdWrong = NULL;
+ if ( !CheckStartVal() )
+ {
+ bAllOk = FALSE;
+ pEdWrong = &aEdStartVal;
+ }
+ else if ( !CheckIncrementVal() )
+ {
+ bAllOk = FALSE;
+ pEdWrong = &aEdIncrement;
+ }
+ else if ( !CheckEndVal() )
+ {
+ bAllOk = FALSE;
+ pEdWrong = &aEdEndVal;
+ }
+ if ( bAllOk )
+ EndDialog( RET_OK );
+ else
+ {
+ ErrorBox( this,
+ WinBits( WB_OK | WB_DEF_OK ),
+ errMsgInvalidVal
+ ).Execute();
+ pEdWrong->GrabFocus();
+ }
+
+ return 0;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/groupdlg.cxx b/sc/source/ui/miscdlgs/groupdlg.cxx
new file mode 100644
index 000000000000..63bf0053b58c
--- /dev/null
+++ b/sc/source/ui/miscdlgs/groupdlg.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "groupdlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+ScGroupDlg::ScGroupDlg( Window* pParent,
+ USHORT nResId,
+ BOOL bUngroup,
+ BOOL bRows ) :
+ ModalDialog ( pParent, ScResId( nResId ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnRows ( this, ScResId( BTN_GROUP_ROWS ) ),
+ aBtnCols ( this, ScResId( BTN_GROUP_COLS ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ aFlFrame.SetText( String( ScResId(bUngroup ? STR_UNGROUP : STR_GROUP) ) );
+
+ if ( bRows )
+ aBtnRows.Check();
+ else
+ aBtnCols.Check();
+
+ //-------------
+ FreeResource();
+ aBtnRows.GrabFocus();
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScGroupDlg::GetColsChecked() const
+{
+ return aBtnCols.IsChecked();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScGroupDlg::~ScGroupDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/highred.cxx b/sc/source/ui/miscdlgs/highred.cxx
new file mode 100644
index 000000000000..aab3a2188c00
--- /dev/null
+++ b/sc/source/ui/miscdlgs/highred.cxx
@@ -0,0 +1,303 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "global.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "highred.hrc"
+
+#include "highred.hxx"
+#include <vcl/msgbox.hxx>
+#include <sfx2/app.hxx>
+
+// defines -------------------------------------------------------------------
+
+#define ABS_SREF SCA_VALID \
+ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+#define ABS_DREF ABS_SREF \
+ | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
+#define ABS_SREF3D ABS_SREF | SCA_TAB_3D
+#define ABS_DREF3D ABS_DREF | SCA_TAB_3D
+
+
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
+
+inline void EnableDisable( Window& rWin, BOOL bEnable )
+{
+ if (bEnable)
+ rWin.Enable();
+ else
+ rWin.Disable();
+}
+
+//============================================================================
+// class ScHighlightChgDlg
+
+//----------------------------------------------------------------------------
+ScHighlightChgDlg::ScHighlightChgDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData)
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_HIGHLIGHT_CHANGES ),
+ //
+ aHighlightBox ( this, ScResId( CB_HIGHLIGHT)),
+ aFlFilter ( this, ScResId( FL_FILTER)),
+ aFilterCtr ( this),
+ aCbAccept ( this, ScResId( CB_HIGHLIGHT_ACCEPT)),
+ aCbReject ( this, ScResId( CB_HIGHLIGHT_REJECT)),
+ aOkButton ( this, ScResId( BTN_OK ) ),
+ aCancelButton ( this, ScResId( BTN_CANCEL ) ),
+ aHelpButton ( this, ScResId( BTN_HELP ) ),
+ aEdAssign ( this, this, ScResId( ED_ASSIGN ) ),
+ aRbAssign ( this, ScResId( RB_ASSIGN ), &aEdAssign, this ),
+ //
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+ aLocalRangeName ( *(pDoc->GetRangeName()) )
+{
+ FreeResource();
+
+ Point aFlFilterPt( aFlFilter.GetPosPixel() );
+ aFlFilterPt.Y() += aFlFilter.GetSizePixel().Height();
+ aFilterCtr.SetPosPixel( aFlFilterPt );
+ MinSize=aFilterCtr.GetSizePixel();
+ MinSize.Height()+=2;
+ MinSize.Width()+=2;
+ aOkButton.SetClickHdl(LINK( this, ScHighlightChgDlg, OKBtnHdl));
+ aHighlightBox.SetClickHdl(LINK( this, ScHighlightChgDlg, HighLightHandle ));
+ aFilterCtr.SetRefHdl(LINK( this, ScHighlightChgDlg, RefHandle ));
+ aFilterCtr.HideRange(FALSE);
+ aFilterCtr.Show();
+ SetDispatcherLock( TRUE );
+ //SFX_APPWINDOW->Disable(FALSE);
+
+ Init();
+
+}
+ScHighlightChgDlg::~ScHighlightChgDlg()
+{
+ SetDispatcherLock( FALSE );
+ //SFX_APPWINDOW->Enable();
+}
+
+void __EXPORT ScHighlightChgDlg::Init()
+{
+ String aAreaStr;
+ ScRange aRange;
+
+ DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
+
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ if(pChanges!=NULL)
+ {
+ aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser());
+ aFilterCtr.ClearAuthors();
+ ScStrCollection aUserColl=pChanges->GetUserCollection();
+ for(USHORT i=0;i<aUserColl.GetCount();i++)
+ aFilterCtr.InsertAuthor(aUserColl[i]->GetString());
+ }
+
+
+ ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings();
+
+ if(pViewSettings!=NULL)
+ aChangeViewSet=*pViewSettings;
+ aHighlightBox.Check(aChangeViewSet.ShowChanges());
+ aFilterCtr.CheckDate(aChangeViewSet.HasDate());
+ aFilterCtr.SetFirstDate(aChangeViewSet.GetTheFirstDateTime());
+ aFilterCtr.SetFirstTime(aChangeViewSet.GetTheFirstDateTime());
+ aFilterCtr.SetLastDate(aChangeViewSet.GetTheLastDateTime());
+ aFilterCtr.SetLastTime(aChangeViewSet.GetTheLastDateTime());
+ aFilterCtr.SetDateMode((USHORT)aChangeViewSet.GetTheDateMode());
+ aFilterCtr.CheckAuthor(aChangeViewSet.HasAuthor());
+ aFilterCtr.CheckComment(aChangeViewSet.HasComment());
+ aFilterCtr.SetComment(aChangeViewSet.GetTheComment());
+
+ aCbAccept.Check(aChangeViewSet.IsShowAccepted());
+ aCbReject.Check(aChangeViewSet.IsShowRejected());
+
+ String aString=aChangeViewSet.GetTheAuthorToShow();
+ if(aString.Len()!=0)
+ {
+ aFilterCtr.SelectAuthor(aString);
+ }
+ else
+ {
+ aFilterCtr.SelectedAuthorPos(0);
+ }
+
+ aFilterCtr.CheckRange(aChangeViewSet.HasRange());
+ ScRange* pRangeEntry=aChangeViewSet.GetTheRangeList().GetObject(0);
+
+
+ if(pRangeEntry!=NULL)
+ {
+ String aRefStr;
+ pRangeEntry->Format( aRefStr, ABS_DREF3D, pDoc );
+ aFilterCtr.SetRange(aRefStr);
+ }
+ aFilterCtr.Enable(TRUE,TRUE);
+ HighLightHandle(&aHighlightBox);
+}
+
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Edit angezeigt wird.
+
+void ScHighlightChgDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( aEdAssign.IsVisible() )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(&aEdAssign);
+ String aRefStr;
+ rRef.Format( aRefStr, ABS_DREF3D, pDocP, pDocP->GetAddressConvention() );
+ aEdAssign.SetRefString( aRefStr );
+ aFilterCtr.SetRange(aRefStr);
+ }
+}
+
+//----------------------------------------------------------------------------
+BOOL __EXPORT ScHighlightChgDlg::Close()
+{
+ return DoClose( ScHighlightChgDlgWrapper::GetChildWindowId() );
+}
+
+void ScHighlightChgDlg::RefInputDone( BOOL bForced)
+{
+ ScAnyRefDlg::RefInputDone(bForced);
+ if(bForced || !aRbAssign.IsVisible())
+ {
+ aFilterCtr.SetRange(aEdAssign.GetText());
+ aFilterCtr.SetFocusToRange();
+ aEdAssign.Hide();
+ aRbAssign.Hide();
+ }
+}
+
+void ScHighlightChgDlg::SetActive()
+{
+ /*
+ if(pTPFilter!=NULL)
+ {
+ aAcceptChgCtr.GetFilterPage()->SetFocusToRange();
+ aEdAssign.Hide();
+ aRbAssign.Hide();
+ SFX_APPWINDOW->Enable();
+ SetDispatcherLock( FALSE );
+ }
+ //RefInputDone();
+ */
+}
+
+BOOL ScHighlightChgDlg::IsRefInputMode() const
+{
+ return aEdAssign.IsVisible();
+}
+
+IMPL_LINK( ScHighlightChgDlg, HighLightHandle, CheckBox*, pCb )
+{
+ if(pCb!=NULL)
+ {
+ if(aHighlightBox.IsChecked())
+ {
+ aFilterCtr.Enable(TRUE,TRUE);
+ aCbAccept.Enable();
+ aCbReject.Enable();
+ }
+ else
+ {
+ aFilterCtr.Disable(TRUE);
+ aCbAccept.Disable();
+ aCbReject.Disable();
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( ScHighlightChgDlg, RefHandle, SvxTPFilter*, pRef )
+{
+ if(pRef!=NULL)
+ {
+ SetDispatcherLock( TRUE );
+ //SFX_APPWINDOW->Disable(FALSE);
+ aEdAssign.Show();
+ aRbAssign.Show();
+ aEdAssign.SetText(aFilterCtr.GetRange());
+ ScAnyRefDlg::RefInputStart(&aEdAssign,&aRbAssign);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScHighlightChgDlg, OKBtnHdl, PushButton*, pOKBtn )
+{
+ if ( pOKBtn == &aOkButton)
+ {
+ aChangeViewSet.SetShowChanges(aHighlightBox.IsChecked());
+ aChangeViewSet.SetHasDate(aFilterCtr.IsDate());
+ ScChgsDateMode eMode = (ScChgsDateMode) aFilterCtr.GetDateMode();
+ aChangeViewSet.SetTheDateMode( eMode );
+ Date aFirstDate( aFilterCtr.GetFirstDate() );
+ Time aFirstTime( aFilterCtr.GetFirstTime() );
+ Date aLastDate( aFilterCtr.GetLastDate() );
+ Time aLastTime( aFilterCtr.GetLastTime() );
+ aChangeViewSet.SetTheFirstDateTime( DateTime( aFirstDate, aFirstTime ) );
+ aChangeViewSet.SetTheLastDateTime( DateTime( aLastDate, aLastTime ) );
+ aChangeViewSet.SetHasAuthor(aFilterCtr.IsAuthor());
+ aChangeViewSet.SetTheAuthorToShow(aFilterCtr.GetSelectedAuthor());
+ aChangeViewSet.SetHasRange(aFilterCtr.IsRange());
+ aChangeViewSet.SetShowAccepted(aCbAccept.IsChecked());
+ aChangeViewSet.SetShowRejected(aCbReject.IsChecked());
+ aChangeViewSet.SetHasComment(aFilterCtr.IsComment());
+ aChangeViewSet.SetTheComment(aFilterCtr.GetComment());
+ ScRangeList aLocalRangeList;
+ aLocalRangeList.Parse(aFilterCtr.GetRange(), pDoc);
+ aChangeViewSet.SetTheRangeList(aLocalRangeList);
+ aChangeViewSet.AdjustDateMode( *pDoc );
+ pDoc->SetChangeViewSettings(aChangeViewSet);
+ pViewData->GetDocShell()->PostPaintGridAll();
+ Close();
+ }
+ return 0;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/highred.src b/sc/source/ui/miscdlgs/highred.src
new file mode 100644
index 000000000000..ce6409347168
--- /dev/null
+++ b/sc/source/ui/miscdlgs/highred.src
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "highred.hrc"
+ModelessDialog RID_SCDLG_HIGHLIGHT_CHANGES
+{
+ OutputSize = TRUE ;
+ HelpId = FID_CHG_ACCEPT ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 318 , 148 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ // Dieser Dialog hat einen Cancel-Button !
+ CheckBox CB_HIGHLIGHT
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 150 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Show changes in spreadsheet" ;
+ };
+ FixedLine FL_FILTER
+ {
+ Pos = MAP_APPFONT ( 6 , 22 ) ;
+ Size = MAP_APPFONT ( 255 , 8 ) ;
+ Text [ en-US ] = "Filter settings";
+ };
+ CheckBox CB_HIGHLIGHT_ACCEPT
+ {
+ Pos = MAP_APPFONT ( 12 , 118 ) ;
+ Size = MAP_APPFONT ( 246 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Show ~accepted changes" ;
+ };
+ CheckBox CB_HIGHLIGHT_REJECT
+ {
+ Pos = MAP_APPFONT ( 12 , 132 ) ;
+ Size = MAP_APPFONT ( 246 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Show ~rejected changes" ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 267 , 6 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 267 , 23 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 267 , 43 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Edit ED_ASSIGN
+ {
+ Hide = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 119 ) ;
+ Size = MAP_APPFONT ( 128 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_ASSIGN
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 142 , 118 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Minimize/Maximize" ;
+ };
+ Text [ en-US ] = "Show Changes" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/miscdlgs/inscldlg.cxx b/sc/source/ui/miscdlgs/inscldlg.cxx
new file mode 100644
index 000000000000..99d92f08a106
--- /dev/null
+++ b/sc/source/ui/miscdlgs/inscldlg.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "inscldlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+static BYTE nInsItemChecked=0;
+
+//==================================================================
+
+ScInsertCellDlg::ScInsertCellDlg( Window* pParent,BOOL bDisallowCellMove) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_INSCELL ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnCellsDown ( this, ScResId( BTN_CELLSDOWN ) ),
+ aBtnCellsRight ( this, ScResId( BTN_CELLSRIGHT ) ),
+ aBtnInsRows ( this, ScResId( BTN_INSROWS ) ),
+ aBtnInsCols ( this, ScResId( BTN_INSCOLS ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ if (bDisallowCellMove)
+ {
+ aBtnCellsDown.Disable();
+ aBtnCellsRight.Disable();
+ aBtnInsRows.Check();
+
+ switch(nInsItemChecked)
+ {
+ case 2: aBtnInsRows .Check();break;
+ case 3: aBtnInsCols .Check();break;
+ default:aBtnInsRows .Check();break;
+ }
+ }
+ else
+ {
+ switch(nInsItemChecked)
+ {
+ case 0: aBtnCellsDown .Check();break;
+ case 1: aBtnCellsRight.Check();break;
+ case 2: aBtnInsRows .Check();break;
+ case 3: aBtnInsCols .Check();break;
+ }
+ }
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+InsCellCmd ScInsertCellDlg::GetInsCellCmd() const
+{
+ InsCellCmd nReturn = INS_NONE;
+
+ if ( aBtnCellsDown.IsChecked() )
+ {
+ nInsItemChecked=0;
+ nReturn = INS_CELLSDOWN;
+ }
+ else if ( aBtnCellsRight.IsChecked())
+ {
+ nInsItemChecked=1;
+ nReturn = INS_CELLSRIGHT;
+ }
+ else if ( aBtnInsRows.IsChecked() )
+ {
+ nInsItemChecked=2;
+ nReturn = INS_INSROWS;
+ }
+ else if ( aBtnInsCols.IsChecked() )
+ {
+ nInsItemChecked=3;
+ nReturn = INS_INSCOLS;
+ }
+
+ return nReturn;
+}
+
+__EXPORT ScInsertCellDlg::~ScInsertCellDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/inscodlg.cxx b/sc/source/ui/miscdlgs/inscodlg.cxx
new file mode 100644
index 000000000000..b96ccb1346a6
--- /dev/null
+++ b/sc/source/ui/miscdlgs/inscodlg.cxx
@@ -0,0 +1,374 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "inscodlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+BOOL ScInsertContentsDlg::bPreviousAllCheck = TRUE;
+USHORT ScInsertContentsDlg::nPreviousChecks = (IDF_DATETIME | IDF_STRING |
+ IDF_NOTE | IDF_FORMULA |
+ IDF_ATTRIB | IDF_OBJECTS);
+USHORT ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
+USHORT ScInsertContentsDlg::nPreviousChecks2 = 0;
+USHORT ScInsertContentsDlg::nPreviousMoveMode = INS_NONE; // enum InsCellCmd
+
+//-----------------------------------------------------------------------
+
+ScInsertContentsDlg::ScInsertContentsDlg( Window* pParent,
+ USHORT nCheckDefaults,
+ const String* pStrTitle )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_INSCONT ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnInsAll ( this, ScResId( BTN_INSALL ) ),
+ aBtnInsStrings ( this, ScResId( BTN_INSSTRINGS ) ),
+ aBtnInsNumbers ( this, ScResId( BTN_INSNUMBERS ) ),
+ aBtnInsDateTime ( this, ScResId( BTN_INSDATETIME ) ),
+ aBtnInsFormulas ( this, ScResId( BTN_INSFORMULAS ) ),
+ aBtnInsNotes ( this, ScResId( BTN_INSNOTES ) ),
+ aBtnInsAttrs ( this, ScResId( BTN_INSATTRS ) ),
+ aBtnInsObjects ( this, ScResId( BTN_INSOBJECTS ) ),
+ aFlSep1 ( this, ScResId( FL_SEP1 ) ),
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ aBtnSkipEmptyCells( this, ScResId(BTN_SKIP_EMPTY ) ),
+ aBtnTranspose ( this, ScResId( BTN_TRANSPOSE ) ),
+ aBtnLink ( this, ScResId( BTN_LINK ) ),
+ aFlOperation ( this, ScResId( FL_OPERATION ) ),
+ aRbNoOp ( this, ScResId( BTN_OP_NOOP ) ),
+ aRbAdd ( this, ScResId( BTN_OP_ADD ) ),
+ aRbSub ( this, ScResId( BTN_OP_SUB ) ),
+ aRbMul ( this, ScResId( BTN_OP_MUL ) ),
+ aRbDiv ( this, ScResId( BTN_OP_DIV ) ),
+ aFlSep2 ( this, ScResId( FL_SEP2 ) ),
+ aFlMove ( this, ScResId( FL_MOVE ) ),
+ aRbMoveNone ( this, ScResId( BTN_MV_NONE ) ),
+ aRbMoveDown ( this, ScResId( BTN_MV_DOWN ) ),
+ aRbMoveRight ( this, ScResId( BTN_MV_RIGHT ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ bOtherDoc ( FALSE ),
+ bFillMode ( FALSE ),
+ bChangeTrack ( FALSE ),
+ bMoveDownDisabled( FALSE ),
+ bMoveRightDisabled( FALSE )
+{
+ if ( pStrTitle )
+ SetText( *pStrTitle );
+
+ if ( nCheckDefaults != 0 )
+ {
+ ScInsertContentsDlg::nPreviousChecks = nCheckDefaults;
+ ScInsertContentsDlg::bPreviousAllCheck = FALSE;
+ ScInsertContentsDlg::nPreviousChecks2 = 0;
+ }
+
+ aBtnInsAll.Check ( ScInsertContentsDlg::bPreviousAllCheck );
+ aBtnInsStrings.Check ( IS_SET( IDF_STRING,
+ ScInsertContentsDlg::nPreviousChecks ) );
+ aBtnInsNumbers.Check ( IS_SET( IDF_VALUE,
+ ScInsertContentsDlg::nPreviousChecks ) );
+ aBtnInsDateTime.Check( IS_SET( IDF_DATETIME,
+ ScInsertContentsDlg::nPreviousChecks ) );
+ aBtnInsFormulas.Check( IS_SET( IDF_FORMULA,
+ ScInsertContentsDlg::nPreviousChecks ) );
+ aBtnInsNotes.Check ( IS_SET( IDF_NOTE,
+ ScInsertContentsDlg::nPreviousChecks ) );
+ aBtnInsAttrs.Check ( IS_SET( IDF_ATTRIB,
+ ScInsertContentsDlg::nPreviousChecks ) );
+ aBtnInsObjects.Check ( IS_SET( IDF_OBJECTS,
+ ScInsertContentsDlg::nPreviousChecks ) );
+
+ switch( ScInsertContentsDlg::nPreviousFormulaChecks )
+ {
+ case PASTE_NOFUNC: aRbNoOp.Check(TRUE); break;
+ case PASTE_ADD: aRbAdd.Check(TRUE); break;
+ case PASTE_SUB: aRbSub.Check(TRUE); break;
+ case PASTE_MUL: aRbMul.Check(TRUE); break;
+ case PASTE_DIV: aRbDiv.Check(TRUE); break;
+ }
+
+ switch( ScInsertContentsDlg::nPreviousMoveMode )
+ {
+ case INS_NONE: aRbMoveNone.Check(TRUE); break;
+ case INS_CELLSDOWN: aRbMoveDown.Check(TRUE); break;
+ case INS_CELLSRIGHT: aRbMoveRight.Check(TRUE); break;
+ }
+
+ aBtnSkipEmptyCells.Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_NOEMPTY ) != 0);
+ aBtnTranspose.Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_TRANS ) != 0);
+ aBtnLink.Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_LINK ) != 0);
+
+ DisableChecks( aBtnInsAll.IsChecked() );
+
+ aFlSep1.SetStyle( aFlSep1.GetStyle() | WB_VERT );
+ aFlSep2.SetStyle( aFlSep2.GetStyle() | WB_VERT );
+
+ aBtnInsAll.SetClickHdl( LINK( this, ScInsertContentsDlg, InsAllHdl ) );
+ aBtnLink.SetClickHdl( LINK( this, ScInsertContentsDlg, LinkBtnHdl ) );
+
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScInsertContentsDlg::GetInsContentsCmdBits() const
+{
+ ScInsertContentsDlg::nPreviousChecks = 0;
+
+ if ( aBtnInsStrings.IsChecked() )
+ ScInsertContentsDlg::nPreviousChecks = IDF_STRING;
+ if ( aBtnInsNumbers.IsChecked() )
+ ScInsertContentsDlg::nPreviousChecks |= IDF_VALUE;
+ if ( aBtnInsDateTime.IsChecked())
+ ScInsertContentsDlg::nPreviousChecks |= IDF_DATETIME;
+ if ( aBtnInsFormulas.IsChecked())
+ ScInsertContentsDlg::nPreviousChecks |= IDF_FORMULA;
+ if ( aBtnInsNotes.IsChecked() )
+ ScInsertContentsDlg::nPreviousChecks |= IDF_NOTE;
+ if ( aBtnInsAttrs.IsChecked() )
+ ScInsertContentsDlg::nPreviousChecks |= IDF_ATTRIB;
+ if ( aBtnInsObjects.IsChecked() )
+ ScInsertContentsDlg::nPreviousChecks |= IDF_OBJECTS;
+
+ ScInsertContentsDlg::bPreviousAllCheck = aBtnInsAll.IsChecked();
+
+ return ( (ScInsertContentsDlg::bPreviousAllCheck)
+ ? IDF_ALL
+ : ScInsertContentsDlg::nPreviousChecks );
+}
+
+//------------------------------------------------------------------------
+
+InsCellCmd ScInsertContentsDlg::GetMoveMode()
+{
+ if ( aRbMoveDown.IsChecked() )
+ return INS_CELLSDOWN;
+ if ( aRbMoveRight.IsChecked() )
+ return INS_CELLSRIGHT;
+
+ return INS_NONE;
+}
+
+//------------------------------------------------------------------------
+
+void ScInsertContentsDlg::DisableChecks( BOOL bInsAllChecked )
+{
+ if ( bInsAllChecked )
+ {
+ aBtnInsStrings.Disable();
+ aBtnInsNumbers.Disable();
+ aBtnInsDateTime.Disable();
+ aBtnInsFormulas.Disable();
+ aBtnInsNotes.Disable();
+ aBtnInsAttrs.Disable();
+ aBtnInsObjects.Disable();
+ }
+ else
+ {
+ aBtnInsStrings.Enable();
+ aBtnInsNumbers.Enable();
+ aBtnInsDateTime.Enable();
+ aBtnInsFormulas.Enable();
+ aBtnInsNotes.Enable();
+ aBtnInsAttrs.Enable();
+
+ // "Objects" is disabled for "Fill Tables"
+ if ( bFillMode )
+ aBtnInsObjects.Disable();
+ else
+ aBtnInsObjects.Enable();
+ }
+}
+
+// Link in anderes Dokument -> alles andere disabled
+
+void ScInsertContentsDlg::TestModes()
+{
+ if ( bOtherDoc && aBtnLink.IsChecked() )
+ {
+ aBtnSkipEmptyCells.Disable();
+ aBtnTranspose.Disable();
+ aRbNoOp.Disable();
+ aRbAdd.Disable();
+ aRbSub.Disable();
+ aRbMul.Disable();
+ aRbDiv.Disable();
+ aFlOperation.Disable();
+
+ aRbMoveNone.Disable();
+ aRbMoveDown.Disable();
+ aRbMoveRight.Disable();
+ aFlMove.Disable();
+
+ aFlFrame.Disable();
+ aBtnInsAll.Disable();
+ DisableChecks(TRUE);
+ }
+ else
+ {
+ aBtnSkipEmptyCells.Enable();
+ aBtnTranspose.Enable(!bFillMode);
+ aRbNoOp.Enable();
+ aRbAdd.Enable();
+ aRbSub.Enable();
+ aRbMul.Enable();
+ aRbDiv.Enable();
+ aFlOperation.Enable();
+
+ aRbMoveNone.Enable(!bFillMode && !bChangeTrack && !(bMoveDownDisabled && bMoveRightDisabled));
+ aRbMoveDown.Enable(!bFillMode && !bChangeTrack && !bMoveDownDisabled);
+ aRbMoveRight.Enable(!bFillMode && !bChangeTrack && !bMoveRightDisabled);
+ aFlMove.Enable(!bFillMode && !bChangeTrack && !(bMoveDownDisabled && bMoveRightDisabled));
+
+ aFlFrame.Enable();
+ aBtnInsAll.Enable();
+ DisableChecks( aBtnInsAll.IsChecked() );
+ }
+}
+
+void ScInsertContentsDlg::SetOtherDoc( BOOL bSet )
+{
+ if ( bSet != bOtherDoc )
+ {
+ bOtherDoc = bSet;
+ TestModes();
+ if ( bSet )
+ aRbMoveNone.Check(TRUE);
+ }
+}
+
+void ScInsertContentsDlg::SetFillMode( BOOL bSet )
+{
+ if ( bSet != bFillMode )
+ {
+ bFillMode = bSet;
+ TestModes();
+ if ( bSet )
+ aRbMoveNone.Check(TRUE);
+ }
+}
+
+void ScInsertContentsDlg::SetChangeTrack( BOOL bSet )
+{
+ if ( bSet != bChangeTrack )
+ {
+ bChangeTrack = bSet;
+ TestModes();
+ if ( bSet )
+ aRbMoveNone.Check(TRUE);
+ }
+}
+
+void ScInsertContentsDlg::SetCellShiftDisabled( int nDisable )
+{
+ BOOL bDown = ((nDisable & SC_CELL_SHIFT_DISABLE_DOWN) != 0);
+ BOOL bRight = ((nDisable & SC_CELL_SHIFT_DISABLE_RIGHT) != 0);
+ if ( bDown != bMoveDownDisabled || bRight != bMoveRightDisabled )
+ {
+ bMoveDownDisabled = bDown;
+ bMoveRightDisabled = bRight;
+ TestModes();
+ if ( bMoveDownDisabled && aRbMoveDown.IsChecked() )
+ aRbMoveNone.Check(TRUE);
+ if ( bMoveRightDisabled && aRbMoveRight.IsChecked() )
+ aRbMoveNone.Check(TRUE);
+ }
+}
+
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScInsertContentsDlg, InsAllHdl, void*, EMPTYARG )
+{
+ DisableChecks( aBtnInsAll.IsChecked() );
+
+ return 0;
+}
+
+IMPL_LINK( ScInsertContentsDlg, LinkBtnHdl, void*, EMPTYARG )
+{
+ TestModes();
+
+ return 0;
+}
+
+__EXPORT ScInsertContentsDlg::~ScInsertContentsDlg()
+{
+ ScInsertContentsDlg::nPreviousChecks2 = 0;
+ if(aBtnSkipEmptyCells.IsChecked())
+ ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_NOEMPTY;
+ if( aBtnTranspose.IsChecked())
+ ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_TRANS;
+ if( aBtnLink.IsChecked() )
+ ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_LINK;
+
+ if (!bFillMode) // im FillMode ist None gecheckt und alle 3 disabled
+ {
+ if ( aRbMoveNone.IsChecked() )
+ ScInsertContentsDlg::nPreviousMoveMode = INS_NONE;
+ else if ( aRbMoveDown.IsChecked() )
+ ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSDOWN;
+ else if ( aRbMoveRight.IsChecked() )
+ ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSRIGHT;
+ }
+}
+
+USHORT ScInsertContentsDlg::GetFormulaCmdBits() const
+{
+ ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
+ if(aRbAdd.IsChecked())
+ ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_ADD;
+ else if(aRbSub.IsChecked())
+ ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_SUB;
+ else if(aRbMul.IsChecked())
+ ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_MUL;
+ else if(aRbDiv.IsChecked())
+ ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_DIV;
+ // Bits fuer Checkboxen ausblenden
+ return ScInsertContentsDlg::nPreviousFormulaChecks;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/instbdlg.cxx b/sc/source/ui/miscdlgs/instbdlg.cxx
new file mode 100644
index 000000000000..5ee5e824e072
--- /dev/null
+++ b/sc/source/ui/miscdlgs/instbdlg.cxx
@@ -0,0 +1,435 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <sfx2/app.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docinsert.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <svtools/ehdl.hxx>
+#include <svtools/sfxecode.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "global.hxx"
+#include "docsh.hxx"
+#include "viewdata.hxx"
+#include "scresid.hxx"
+#include "instbdlg.hrc"
+#include "globstr.hrc"
+
+#define SC_INSTBDLG_CXX
+#include "instbdlg.hxx"
+
+#include <layout/layout-pre.hxx>
+
+#if ENABLE_LAYOUT
+#undef ScResId
+#define ScResId(x) #x
+#undef ModalDialog
+#define ModalDialog( parent, id ) Dialog( parent, "insert-sheet.xml", id )
+#undef ErrorBox
+#define ErrorBox( this, bits, message ) ErrorBox (LAYOUT_THIS_WINDOW (this), bits, message)
+#endif /* ENABLE_LAYOUT */
+
+//==================================================================
+
+ScInsertTableDlg::ScInsertTableDlg( Window* pParent, ScViewData& rData, SCTAB nTabCount, bool bFromFile )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_INSERT_TABLE ) ),
+ //
+ aBtnBefore ( this, ScResId( RB_BEFORE ) ),
+ aBtnBehind ( this, ScResId( RB_BEHIND ) ),
+ aFlPos ( this, ScResId( FL_POSITION ) ),
+ aBtnNew ( this, ScResId( RB_NEW ) ),
+ aBtnFromFile ( this, ScResId( RB_FROMFILE ) ),
+ aFtCount ( this, ScResId( FT_COUNT ) ),
+ aNfCount ( this, ScResId( NF_COUNT ) ),
+ aFtName ( this, ScResId( FT_NAME ) ),
+ aEdName ( this, ScResId( ED_TABNAME ) ),
+ aLbTables ( this, ScResId( LB_TABLES ) ),
+ aFtPath ( this, ScResId( FT_PATH ) ),
+ aBtnBrowse ( this, ScResId( BTN_BROWSE ) ),
+ aBtnLink ( this, ScResId( CB_LINK ) ),
+ aFlTable ( this, ScResId( FL_TABLE ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ rViewData ( rData ),
+ rDoc ( *rData.GetDocument() ),
+ pDocShTables ( NULL ),
+ pDocInserter ( NULL ),
+ bMustClose ( false ),
+ nSelTabIndex ( 0 ),
+ nTableCount (nTabCount)
+{
+#if ENABLE_LAYOUT
+ SetHelpId (SID_INSERT_TABLE);
+ aFtPath.SetText (EMPTY_STRING);
+#endif /* ENABLE_LAYOUT */
+ Init_Impl( bFromFile );
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScInsertTableDlg::~ScInsertTableDlg()
+{
+ if (pDocShTables)
+ pDocShTables->DoClose();
+ delete pDocInserter;
+}
+
+//------------------------------------------------------------------------
+
+void ScInsertTableDlg::Init_Impl( bool bFromFile )
+{
+ aBtnBrowse .SetClickHdl( LINK( this, ScInsertTableDlg, BrowseHdl_Impl ) );
+ aBtnNew .SetClickHdl( LINK( this, ScInsertTableDlg, ChoiceHdl_Impl ) );
+ aBtnFromFile .SetClickHdl( LINK( this, ScInsertTableDlg, ChoiceHdl_Impl ) );
+ aLbTables .SetSelectHdl( LINK( this, ScInsertTableDlg, SelectHdl_Impl ) );
+ aNfCount .SetModifyHdl( LINK( this, ScInsertTableDlg, CountHdl_Impl));
+ aBtnOk .SetClickHdl( LINK( this, ScInsertTableDlg, DoEnterHdl ));
+ aBtnBefore.Check();
+
+ aNfCount.SetText( String::CreateFromInt32(nTableCount) );
+ aNfCount.SetMax( MAXTAB - rDoc.GetTableCount() + 1 );
+
+ if(nTableCount==1)
+ {
+ String aName;
+ rDoc.CreateValidTabName( aName );
+ aEdName.SetText( aName );
+ }
+ else
+ {
+ String aName=aFlTable.GetText();
+ aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM("..."));
+ aEdName.SetText( aName );
+ aFtName.Disable();
+ aEdName.Disable();
+ }
+
+ bool bShared = ( rViewData.GetDocShell() ? rViewData.GetDocShell()->IsDocShared() : false );
+
+ if ( !bFromFile || bShared )
+ {
+ aBtnNew.Check();
+ SetNewTable_Impl();
+ if ( bShared )
+ {
+ aBtnFromFile.Disable();
+ }
+ }
+ else
+ {
+ aBtnFromFile.Check();
+ SetFromTo_Impl();
+
+ aBrowseTimer.SetTimeoutHdl( LINK( this, ScInsertTableDlg, BrowseTimeoutHdl ) );
+ aBrowseTimer.SetTimeout( 200 );
+ }
+}
+
+//------------------------------------------------------------------------
+
+#if ENABLE_LAYOUT
+#undef ModalDialog
+#define ModalDialog Dialog
+#endif /* ENABLE_LAYOUT */
+
+short __EXPORT ScInsertTableDlg::Execute()
+{
+ // set Parent of DocumentInserter and Doc-Manager
+ Window* pOldDefParent = Application::GetDefDialogParent();
+ Application::SetDefDialogParent( LAYOUT_THIS_WINDOW (this) );
+
+ if ( aBtnFromFile.IsChecked() )
+ aBrowseTimer.Start();
+
+ short nRet = ModalDialog::Execute();
+ Application::SetDefDialogParent( pOldDefParent );
+ return nRet;
+}
+
+//------------------------------------------------------------------------
+
+void ScInsertTableDlg::SetNewTable_Impl()
+{
+ if (aBtnNew.IsChecked() )
+ {
+ aNfCount .Enable();
+ aFtCount .Enable();
+ aLbTables .Disable();
+ aFtPath .Disable();
+ aBtnBrowse .Disable();
+ aBtnLink .Disable();
+
+ if(nTableCount==1)
+ {
+ aEdName.Enable();
+ aFtName.Enable();
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScInsertTableDlg::SetFromTo_Impl()
+{
+ if (aBtnFromFile.IsChecked() )
+ {
+ aEdName .Disable();
+ aFtName .Disable();
+ aFtCount .Disable();
+ aNfCount .Disable();
+ aLbTables .Enable();
+ aFtPath .Enable();
+ aBtnBrowse .Enable();
+ aBtnLink .Enable();
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScInsertTableDlg::FillTables_Impl( ScDocument* pSrcDoc )
+{
+ aLbTables.SetUpdateMode( FALSE );
+ aLbTables.Clear();
+
+ if ( pSrcDoc )
+ {
+ SCTAB nCount = pSrcDoc->GetTableCount();
+ String aName;
+
+ for ( SCTAB i=0; i<nCount; i++ )
+ {
+ pSrcDoc->GetName( i, aName );
+ aLbTables.InsertEntry( aName );
+ }
+ }
+
+ aLbTables.SetUpdateMode( TRUE );
+
+ if(aLbTables.GetEntryCount()==1)
+ aLbTables.SelectEntryPos(0);
+}
+
+//------------------------------------------------------------------------
+
+const String* ScInsertTableDlg::GetFirstTable( USHORT* pN )
+{
+ const String* pStr = NULL;
+
+ if ( aBtnNew.IsChecked() )
+ {
+ aStrCurSelTable = aEdName.GetText();
+ pStr = &aStrCurSelTable;
+ }
+ else if ( nSelTabIndex < aLbTables.GetSelectEntryCount() )
+ {
+ aStrCurSelTable = aLbTables.GetSelectEntry( 0 );
+ pStr = &aStrCurSelTable;
+ if ( pN )
+ *pN = aLbTables.GetSelectEntryPos( 0 );
+ nSelTabIndex = 1;
+ }
+
+ return pStr;
+}
+
+//------------------------------------------------------------------------
+
+const String* ScInsertTableDlg::GetNextTable( USHORT* pN )
+{
+ const String* pStr = NULL;
+
+ if ( !aBtnNew.IsChecked() && nSelTabIndex < aLbTables.GetSelectEntryCount() )
+ {
+ aStrCurSelTable = aLbTables.GetSelectEntry( nSelTabIndex );
+ pStr = &aStrCurSelTable;
+ if ( pN )
+ *pN = aLbTables.GetSelectEntryPos( nSelTabIndex );
+ nSelTabIndex++;
+ }
+
+ return pStr;
+}
+
+
+//------------------------------------------------------------------------
+// Handler:
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScInsertTableDlg, CountHdl_Impl, NumericField*, EMPTYARG )
+{
+ nTableCount = static_cast<SCTAB>(aNfCount.GetValue());
+ if ( nTableCount==1)
+ {
+ String aName;
+ rDoc.CreateValidTabName( aName );
+ aEdName.SetText( aName );
+ aFtName.Enable();
+ aEdName.Enable();
+ }
+ else
+ {
+ String aName=aFlTable.GetText();
+ aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM("..."));
+ aEdName.SetText( aName );
+ aFtName.Disable();
+ aEdName.Disable();
+ }
+
+ DoEnable_Impl();
+ return 0;
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK( ScInsertTableDlg, ChoiceHdl_Impl, RadioButton*, EMPTYARG )
+{
+ if ( aBtnNew.IsChecked() )
+ SetNewTable_Impl();
+ else
+ SetFromTo_Impl();
+
+ DoEnable_Impl();
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScInsertTableDlg, BrowseHdl_Impl, PushButton*, EMPTYARG )
+{
+ if ( pDocInserter )
+ delete pDocInserter;
+ pDocInserter = new ::sfx2::DocumentInserter(
+ 0, String::CreateFromAscii( ScDocShell::Factory().GetShortName() ) );
+ pDocInserter->StartExecuteModal( LINK( this, ScInsertTableDlg, DialogClosedHdl ) );
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScInsertTableDlg, SelectHdl_Impl, MultiListBox*, EMPTYARG )
+{
+ DoEnable_Impl();
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+void ScInsertTableDlg::DoEnable_Impl()
+{
+ if ( aBtnNew.IsChecked() || ( pDocShTables && aLbTables.GetSelectEntryCount() ) )
+ aBtnOk.Enable();
+ else
+ aBtnOk.Disable();
+}
+
+IMPL_LINK( ScInsertTableDlg, DoEnterHdl, PushButton*, EMPTYARG )
+{
+ if(nTableCount > 1 || rDoc.ValidTabName(aEdName.GetText()))
+ {
+ EndDialog(RET_OK);
+ }
+ else
+ {
+ String aErrMsg ( ScGlobal::GetRscString( STR_INVALIDTABNAME ) );
+ (void)ErrorBox( this,WinBits( WB_OK | WB_DEF_OK ),aErrMsg).Execute();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScInsertTableDlg, BrowseTimeoutHdl, Timer*, EMPTYARG )
+{
+ bMustClose = true;
+ BrowseHdl_Impl( &aBtnBrowse );
+ return 0;
+}
+
+IMPL_LINK( ScInsertTableDlg, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
+{
+ if ( ERRCODE_NONE == _pFileDlg->GetError() )
+ {
+ SfxMedium* pMed = pDocInserter->CreateMedium();
+ if ( pMed )
+ {
+ // ERRCTX_SFX_OPENDOC -> "Fehler beim Laden des Dokumentes"
+ SfxErrorContext aEc( ERRCTX_SFX_OPENDOC, pMed->GetName() );
+
+ if ( pDocShTables )
+ pDocShTables->DoClose(); // delete passiert beim Zuweisen auf die Ref
+
+ pMed->UseInteractionHandler( TRUE ); // to enable the filter options dialog
+
+ pDocShTables = new ScDocShell;
+ aDocShTablesRef = pDocShTables;
+
+ Pointer aOldPtr( GetPointer() );
+ SetPointer( Pointer( POINTER_WAIT ) );
+ pDocShTables->DoLoad( pMed );
+ SetPointer( aOldPtr );
+
+ ULONG nErr = pDocShTables->GetErrorCode();
+ if ( nErr )
+ ErrorHandler::HandleError( nErr ); // auch Warnings
+
+ if ( !pDocShTables->GetError() ) // nur Errors
+ {
+ FillTables_Impl( pDocShTables->GetDocument() );
+ aFtPath.SetText( pDocShTables->GetTitle( SFX_TITLE_FULLNAME ) );
+ }
+ else
+ {
+ pDocShTables->DoClose();
+ aDocShTablesRef.Clear();
+ pDocShTables = NULL;
+
+ FillTables_Impl( NULL );
+ aFtPath.SetText( EMPTY_STRING );
+ }
+ }
+
+ DoEnable_Impl();
+ }
+ else if ( bMustClose )
+ // execute slot FID_INS_TABLE_EXT and cancel file dialog
+ EndDialog( RET_CANCEL );
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/instbdlg.src b/sc/source/ui/miscdlgs/instbdlg.src
new file mode 100644
index 000000000000..375dfc24fa4a
--- /dev/null
+++ b/sc/source/ui/miscdlgs/instbdlg.src
@@ -0,0 +1,184 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "instbdlg.hrc"
+ModalDialog RID_SCDLG_INSERT_TABLE
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 274 , 190 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Tabelle einfügen : Tabelle einf³gen */
+ Text [ en-US ] = "Insert Sheet" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 218 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 218 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 218 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ FixedLine FL_POSITION
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 206 , 8 ) ;
+ Text [ en-US ] = "Position" ;
+ };
+ RadioButton RB_BEFORE
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 197 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "B~efore current sheet" ;
+ };
+ RadioButton RB_BEHIND
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 197 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~After current sheet" ;
+ };
+ FixedLine FL_TABLE
+ {
+ Pos = MAP_APPFONT ( 6 , 44 ) ;
+ Size = MAP_APPFONT ( 206 , 8 ) ;
+ Text [ en-US ] = "Sheet" ;
+ };
+ RadioButton RB_NEW
+ {
+ Pos = MAP_APPFONT ( 12 , 55 ) ;
+ Size = MAP_APPFONT ( 197 , 10 ) ;
+ Text [ en-US ] = "~New sheet" ;
+ };
+ FixedText FT_COUNT
+ {
+ Pos = MAP_APPFONT ( 20 , 68 ) ;
+ Size = MAP_APPFONT ( 52 , 8 ) ;
+ Text [ en-US ] = "N~o. of sheets" ;
+ };
+ NumericField NF_COUNT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 72 , 66 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ SpinSize = 1 ;
+ Repeat = TRUE ;
+ Minimum = 1 ;
+ Maximum = 256 ;
+ };
+ FixedText FT_NAME
+ {
+ Pos = MAP_APPFONT ( 20 , 84 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "Na~me";
+ };
+ Edit ED_TABNAME
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 72 , 82 ) ;
+ Size = MAP_APPFONT ( 137 , 12 ) ;
+ };
+ RadioButton RB_FROMFILE
+ {
+ Pos = MAP_APPFONT ( 12 , 100 ) ;
+ Size = MAP_APPFONT ( 197 , 10 ) ;
+ Text [ en-US ] = "~From file" ;
+ };
+ MultiListBox LB_TABLES
+ {
+ SimpleMode = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 20 , 113 ) ;
+ Size = MAP_APPFONT ( 123 , 59 ) ;
+ AutoHScroll = TRUE ;
+ };
+ PushButton BTN_BROWSE
+ {
+ Pos = MAP_APPFONT ( 149 , 113 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~Browse..." ;
+ };
+ CheckBox CB_LINK
+ {
+ Pos = MAP_APPFONT ( 149 , 131 ) ;
+ Size = MAP_APPFONT ( 60 , 10 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Ver~knüpfen : Ver~kn³pfen */
+ Text [ en-US ] = "Lin~k" ;
+ };
+ FixedText FT_PATH
+ {
+ Pos = MAP_APPFONT ( 20 , 176 ) ;
+ Size = MAP_APPFONT ( 192 , 8 ) ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/miscdlgs/lbseldlg.cxx b/sc/source/ui/miscdlgs/lbseldlg.cxx
new file mode 100644
index 000000000000..f2a9a73c7538
--- /dev/null
+++ b/sc/source/ui/miscdlgs/lbseldlg.cxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+
+#include "lbseldlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+ScSelEntryDlg::ScSelEntryDlg( Window* pParent,
+ USHORT nResId,
+ const String& aTitle,
+ const String& aLbTitle,
+ List& aEntryList ) :
+ ModalDialog ( pParent, ScResId( nResId ) ),
+ //
+ aFlLbTitle ( this, ScResId( FL_ENTRYLIST ) ),
+ aLb ( this, ScResId( LB_ENTRYLIST ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ SetText( aTitle );
+ aFlLbTitle.SetText( aLbTitle );
+ aLb.Clear();
+ aLb.SetDoubleClickHdl( LINK( this, ScSelEntryDlg, DblClkHdl ) );
+
+ void* pListEntry = aEntryList.First();
+ while ( pListEntry )
+ {
+ aLb.InsertEntry( *((String*)pListEntry ) );
+ pListEntry = aEntryList.Next();
+ }
+
+ if ( aLb.GetEntryCount() > 0 )
+ aLb.SelectEntryPos( 0 );
+
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+String ScSelEntryDlg::GetSelectEntry() const
+{
+ return aLb.GetSelectEntry();
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScSelEntryDlg, DblClkHdl, void *, EMPTYARG )
+{
+ EndDialog( RET_OK );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScSelEntryDlg, DblClkHdl, void *, EMPTYARG )
+
+//------------------------------------------------------------------------
+
+__EXPORT ScSelEntryDlg::~ScSelEntryDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/linkarea.cxx b/sc/source/ui/miscdlgs/linkarea.cxx
new file mode 100644
index 000000000000..f6aea5799417
--- /dev/null
+++ b/sc/source/ui/miscdlgs/linkarea.cxx
@@ -0,0 +1,368 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <sfx2/app.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/docinsert.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <svtools/ehdl.hxx>
+#include <svtools/sfxecode.hxx>
+#include <vcl/waitobj.hxx>
+
+#include "linkarea.hxx"
+#include "linkarea.hrc"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "rangeutl.hxx"
+#include "docsh.hxx"
+#include "tablink.hxx"
+
+//==================================================================
+
+ScLinkedAreaDlg::ScLinkedAreaDlg( Window* pParent ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_LINKAREA ) ),
+ //
+ aFlLocation ( this, ScResId( FL_LOCATION ) ),
+ aCbUrl ( this, ScResId( CB_URL ) ),
+ aBtnBrowse ( this, ScResId( BTN_BROWSE ) ),
+ aTxtHint ( this, ScResId( FT_HINT ) ),
+ aFtRanges ( this, ScResId( FT_RANGES ) ),
+ aLbRanges ( this, ScResId( LB_RANGES ) ),
+ aBtnReload ( this, ScResId( BTN_RELOAD ) ),
+ aNfDelay ( this, ScResId( NF_DELAY ) ),
+ aFtSeconds ( this, ScResId( FT_SECONDS ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ pSourceShell( NULL ),
+ pDocInserter( NULL )
+
+{
+ FreeResource();
+
+ aCbUrl.SetHelpId( HID_SCDLG_LINKAREAURL ); // SvtURLBox ctor always sets SID_OPENURL
+ aCbUrl.SetSelectHdl( LINK( this, ScLinkedAreaDlg, FileHdl ) );
+ aBtnBrowse.SetClickHdl( LINK( this, ScLinkedAreaDlg, BrowseHdl ) );
+ aLbRanges.SetSelectHdl( LINK( this, ScLinkedAreaDlg, RangeHdl ) );
+ aBtnReload.SetClickHdl( LINK( this, ScLinkedAreaDlg, ReloadHdl ) );
+ UpdateEnable();
+}
+
+ScLinkedAreaDlg::~ScLinkedAreaDlg()
+{
+ // pSourceShell is deleted by aSourceRef
+}
+
+short ScLinkedAreaDlg::Execute()
+{
+ // set parent for file dialog or filter options
+
+ Window* pOldDefParent = Application::GetDefDialogParent();
+ Application::SetDefDialogParent( this );
+
+ short nRet = ModalDialog::Execute();
+
+ Application::SetDefDialogParent( pOldDefParent );
+
+ return nRet;
+}
+
+#define FILTERNAME_HTML "HTML (StarCalc)"
+#define FILTERNAME_QUERY "calc_HTML_WebQuery"
+
+IMPL_LINK( ScLinkedAreaDlg, BrowseHdl, PushButton*, EMPTYARG )
+{
+ if ( !pDocInserter )
+ pDocInserter = new sfx2::DocumentInserter(
+ 0, String::CreateFromAscii( ScDocShell::Factory().GetShortName() ) );
+ pDocInserter->StartExecuteModal( LINK( this, ScLinkedAreaDlg, DialogClosedHdl ) );
+ return 0;
+}
+
+IMPL_LINK( ScLinkedAreaDlg, FileHdl, ComboBox*, EMPTYARG )
+{
+ String aEntered = aCbUrl.GetURL();
+ if (pSourceShell)
+ {
+ SfxMedium* pMed = pSourceShell->GetMedium();
+ if ( pMed->GetName() == aEntered )
+ {
+ // already loaded - nothing to do
+ return 0;
+ }
+ }
+
+ String aFilter;
+ String aOptions;
+ // get filter name by looking at the file content (bWithContent = TRUE)
+ // Break operation if any error occured inside.
+ if (!ScDocumentLoader::GetFilterName( aEntered, aFilter, aOptions, TRUE, TRUE ))
+ return 0;
+
+ // #i53241# replace HTML filter with DataQuery filter
+ if( aFilter.EqualsAscii( FILTERNAME_HTML ) )
+ aFilter.AssignAscii( FILTERNAME_QUERY );
+
+ LoadDocument( aEntered, aFilter, aOptions );
+
+ UpdateSourceRanges();
+ UpdateEnable();
+ return 0;
+}
+
+void ScLinkedAreaDlg::LoadDocument( const String& rFile, const String& rFilter, const String& rOptions )
+{
+ if ( pSourceShell )
+ {
+ // unload old document
+ pSourceShell->DoClose();
+ pSourceShell = NULL;
+ aSourceRef.Clear();
+ }
+
+ if ( rFile.Len() )
+ {
+ WaitObject aWait( this );
+
+ String aNewFilter = rFilter;
+ String aNewOptions = rOptions;
+
+ SfxErrorContext aEc( ERRCTX_SFX_OPENDOC, rFile );
+
+ ScDocumentLoader aLoader( rFile, aNewFilter, aNewOptions, 0, TRUE ); // with interaction
+ pSourceShell = aLoader.GetDocShell();
+ if ( pSourceShell )
+ {
+ ULONG nErr = pSourceShell->GetErrorCode();
+ if (nErr)
+ ErrorHandler::HandleError( nErr ); // including warnings
+
+ aSourceRef = pSourceShell;
+ aLoader.ReleaseDocRef(); // don't call DoClose in DocLoader dtor
+ }
+ }
+}
+
+void ScLinkedAreaDlg::InitFromOldLink( const String& rFile, const String& rFilter,
+ const String& rOptions, const String& rSource,
+ ULONG nRefresh )
+{
+ LoadDocument( rFile, rFilter, rOptions );
+ if (pSourceShell)
+ {
+ SfxMedium* pMed = pSourceShell->GetMedium();
+ aCbUrl.SetText( pMed->GetName() );
+ }
+ else
+ aCbUrl.SetText( EMPTY_STRING );
+
+ UpdateSourceRanges();
+
+ xub_StrLen nRangeCount = rSource.GetTokenCount();
+ for ( xub_StrLen i=0; i<nRangeCount; i++ )
+ {
+ String aRange = rSource.GetToken(i);
+ aLbRanges.SelectEntry( aRange );
+ }
+
+ BOOL bDoRefresh = ( nRefresh != 0 );
+ aBtnReload.Check( bDoRefresh );
+ if (bDoRefresh)
+ aNfDelay.SetValue( nRefresh );
+
+ UpdateEnable();
+}
+
+IMPL_LINK( ScLinkedAreaDlg, RangeHdl, MultiListBox*, EMPTYARG )
+{
+ UpdateEnable();
+ return 0;
+}
+
+IMPL_LINK( ScLinkedAreaDlg, ReloadHdl, CheckBox*, EMPTYARG )
+{
+ UpdateEnable();
+ return 0;
+}
+
+IMPL_LINK( ScLinkedAreaDlg, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
+{
+ if ( _pFileDlg->GetError() != ERRCODE_NONE )
+ return 0;
+
+ SfxMedium* pMed = pDocInserter->CreateMedium();
+ if ( pMed )
+ {
+ WaitObject aWait( this );
+
+ // #92296# replace HTML filter with DataQuery filter
+ const String aHTMLFilterName( RTL_CONSTASCII_USTRINGPARAM( FILTERNAME_HTML ) );
+ const String aWebQFilterName( RTL_CONSTASCII_USTRINGPARAM( FILTERNAME_QUERY ) );
+
+ const SfxFilter* pFilter = pMed->GetFilter();
+ if( pFilter && (pFilter->GetFilterName() == aHTMLFilterName) )
+ {
+ const SfxFilter* pNewFilter =
+ ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( aWebQFilterName );
+ if( pNewFilter )
+ pMed->SetFilter( pNewFilter );
+ }
+
+ // ERRCTX_SFX_OPENDOC -> "Fehler beim Laden des Dokumentes"
+ SfxErrorContext aEc( ERRCTX_SFX_OPENDOC, pMed->GetName() );
+
+ if (pSourceShell)
+ pSourceShell->DoClose(); // deleted when assigning aSourceRef
+
+ pMed->UseInteractionHandler( TRUE ); // to enable the filter options dialog
+
+ pSourceShell = new ScDocShell;
+ aSourceRef = pSourceShell;
+ pSourceShell->DoLoad( pMed );
+
+ ULONG nErr = pSourceShell->GetErrorCode();
+ if (nErr)
+ ErrorHandler::HandleError( nErr ); // including warnings
+
+ if ( !pSourceShell->GetError() ) // only errors
+ {
+ //aCbUrl.SetText( pSourceShell->GetTitle( SFX_TITLE_FULLNAME ) );
+ aCbUrl.SetText( pMed->GetName() );
+ }
+ else
+ {
+ pSourceShell->DoClose();
+ pSourceShell = NULL;
+ aSourceRef.Clear();
+
+ aCbUrl.SetText( EMPTY_STRING );
+ }
+ }
+
+ UpdateSourceRanges();
+ UpdateEnable();
+ return 0;
+}
+
+#undef FILTERNAME_HTML
+#undef FILTERNAME_QUERY
+
+void ScLinkedAreaDlg::UpdateSourceRanges()
+{
+ aLbRanges.SetUpdateMode( FALSE );
+
+ aLbRanges.Clear();
+ if ( pSourceShell )
+ {
+ ScAreaNameIterator aIter( pSourceShell->GetDocument() );
+ ScRange aDummy;
+ String aName;
+ while ( aIter.Next( aName, aDummy ) )
+ aLbRanges.InsertEntry( aName );
+ }
+
+ aLbRanges.SetUpdateMode( TRUE );
+
+ if ( aLbRanges.GetEntryCount() == 1 )
+ aLbRanges.SelectEntryPos(0);
+}
+
+void ScLinkedAreaDlg::UpdateEnable()
+{
+ BOOL bEnable = ( pSourceShell && aLbRanges.GetSelectEntryCount() );
+ aBtnOk.Enable( bEnable );
+
+ BOOL bReload = aBtnReload.IsChecked();
+ aNfDelay.Enable( bReload );
+ aFtSeconds.Enable( bReload );
+}
+
+String ScLinkedAreaDlg::GetURL()
+{
+ if (pSourceShell)
+ {
+ SfxMedium* pMed = pSourceShell->GetMedium();
+ return pMed->GetName();
+ }
+ return EMPTY_STRING;
+}
+
+String ScLinkedAreaDlg::GetFilter()
+{
+ if (pSourceShell)
+ {
+ SfxMedium* pMed = pSourceShell->GetMedium();
+ return pMed->GetFilter()->GetFilterName();
+ }
+ return EMPTY_STRING;
+}
+
+String ScLinkedAreaDlg::GetOptions()
+{
+ if (pSourceShell)
+ {
+ SfxMedium* pMed = pSourceShell->GetMedium();
+ return ScDocumentLoader::GetOptions( *pMed );
+ }
+ return EMPTY_STRING;
+}
+
+String ScLinkedAreaDlg::GetSource()
+{
+ String aSource;
+ USHORT nCount = aLbRanges.GetSelectEntryCount();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ if (i > 0)
+ aSource.Append( (sal_Unicode) ';' );
+ aSource.Append( aLbRanges.GetSelectEntry( i ) );
+ }
+ return aSource;
+}
+
+ULONG ScLinkedAreaDlg::GetRefresh()
+{
+ if ( aBtnReload.IsChecked() )
+ return sal::static_int_cast<ULONG>( aNfDelay.GetValue() );
+ else
+ return 0; // disabled
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/linkarea.src b/sc/source/ui/miscdlgs/linkarea.src
new file mode 100644
index 000000000000..ec5e3d4b868d
--- /dev/null
+++ b/sc/source/ui/miscdlgs/linkarea.src
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "linkarea.hrc"
+
+ModalDialog RID_SCDLG_LINKAREA
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Size = MAP_APPFONT ( 274 , 190 ) ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 218 , 8 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 218 , 25 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 218 , 49 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ FixedLine FL_LOCATION
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 204 , 8 ) ;
+ Text [ en-US ] = "URL of ~external data source";
+ };
+ ComboBox CB_URL
+ {
+ Pos = MAP_APPFONT ( 12 , 15 ) ;
+ Size = MAP_APPFONT ( 174 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ PushButton BTN_BROWSE
+ {
+ Pos = MAP_APPFONT ( 190 , 14 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ Text = "~..." ;
+ };
+ FixedText FT_HINT
+ {
+ Pos = MAP_APPFONT ( 12 , 31 ) ;
+ Size = MAP_APPFONT ( 192 , 26 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "(Enter the URL of the source document in the local file system or Internet here.)";
+ };
+ FixedText FT_RANGES
+ {
+ Pos = MAP_APPFONT ( 6 , 62 ) ;
+ Size = MAP_APPFONT ( 198 , 8 ) ;
+ Text [ en-US ] = "~Available tables/ranges";
+ };
+ MultiListBox LB_RANGES
+ {
+ SimpleMode = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 74 ) ;
+ Size = MAP_APPFONT ( 192 , 80 ) ;
+ AutoHScroll = TRUE ;
+ };
+ CheckBox BTN_RELOAD
+ {
+ Pos = MAP_APPFONT ( 12 , 168 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Update every";
+ };
+ NumericField NF_DELAY
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 113 , 166 ) ;
+ Size = MAP_APPFONT ( 32 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Minimum = 1 ;
+ Maximum = 99999 ;
+ Value = 60 ;
+ };
+ FixedText FT_SECONDS
+ {
+ Pos = MAP_APPFONT ( 149 , 168 ) ;
+ Size = MAP_APPFONT ( 59 , 8 ) ;
+ Text [ en-US ] = "seconds";
+ };
+ Text [ en-US ] = "External Data";
+};
+
diff --git a/sc/source/ui/miscdlgs/makefile.mk b/sc/source/ui/miscdlgs/makefile.mk
new file mode 100644
index 000000000000..115fc3aebe57
--- /dev/null
+++ b/sc/source/ui/miscdlgs/makefile.mk
@@ -0,0 +1,126 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=miscdlgs
+LIBTARGET=no
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/datafdlg.obj \
+ $(SLO)$/delcldlg.obj \
+ $(SLO)$/inscldlg.obj \
+ $(SLO)$/delcodlg.obj \
+ $(SLO)$/inscodlg.obj \
+ $(SLO)$/strindlg.obj \
+ $(SLO)$/tabbgcolordlg.obj \
+ $(SLO)$/mtrindlg.obj \
+ $(SLO)$/lbseldlg.obj \
+ $(SLO)$/filldlg.obj \
+ $(SLO)$/autofmt.obj \
+ $(SLO)$/solvrdlg.obj \
+ $(SLO)$/optsolver.obj \
+ $(SLO)$/solveroptions.obj \
+ $(SLO)$/solverutil.obj \
+ $(SLO)$/mvtabdlg.obj \
+ $(SLO)$/groupdlg.obj \
+ $(SLO)$/tabopdlg.obj \
+ $(SLO)$/crdlg.obj \
+ $(SLO)$/namecrea.obj \
+ $(SLO)$/namepast.obj \
+ $(SLO)$/textdlgs.obj \
+ $(SLO)$/anyrefdg.obj \
+ $(SLO)$/crnrdlg.obj \
+ $(SLO)$/shtabdlg.obj \
+ $(SLO)$/instbdlg.obj \
+ $(SLO)$/acredlin.obj \
+ $(SLO)$/highred.obj \
+ $(SLO)$/simpref.obj \
+ $(SLO)$/redcom.obj \
+ $(SLO)$/linkarea.obj \
+ $(SLO)$/warnbox.obj \
+ $(SLO)$/scuiautofmt.obj \
+ $(SLO)$/conflictsdlg.obj \
+ $(SLO)$/sharedocdlg.obj \
+ $(SLO)$/protectiondlg.obj \
+ $(SLO)$/retypepassdlg.obj
+
+EXCEPTIONSFILES = \
+ $(SLO)$/acredlin.obj \
+ $(SLO)$/conflictsdlg.obj \
+ $(SLO)$/sharedocdlg.obj \
+ $(SLO)$/optsolver.obj \
+ $(SLO)$/solveroptions.obj \
+ $(SLO)$/crnrdlg.obj \
+ $(SLO)$/solverutil.obj \
+ $(SLO)$/protectiondlg.obj \
+ $(SLO)$/retypepassdlg.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ instbdlg.src \
+ acredlin.src \
+ highred.src \
+ linkarea.src \
+ conflictsdlg.src \
+ sharedocdlg.src \
+ protectiondlg.src \
+ retypepassdlg.src
+
+LIB1TARGET = $(SLB)$/$(TARGET).lib
+
+LIB1OBJFILES = \
+ $(SLO)$/autofmt.obj \
+ $(SLO)$/solvrdlg.obj \
+ $(SLO)$/optsolver.obj \
+ $(SLO)$/solveroptions.obj \
+ $(SLO)$/solverutil.obj \
+ $(SLO)$/tabopdlg.obj \
+ $(SLO)$/anyrefdg.obj \
+ $(SLO)$/crnrdlg.obj \
+ $(SLO)$/acredlin.obj \
+ $(SLO)$/highred.obj \
+ $(SLO)$/simpref.obj \
+ $(SLO)$/redcom.obj \
+ $(SLO)$/warnbox.obj \
+ $(SLO)$/conflictsdlg.obj \
+ $(SLO)$/sharedocdlg.obj \
+ $(SLO)$/protectiondlg.obj \
+ $(SLO)$/retypepassdlg.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/miscdlgs/mtrindlg.cxx b/sc/source/ui/miscdlgs/mtrindlg.cxx
new file mode 100644
index 000000000000..510f5785fe83
--- /dev/null
+++ b/sc/source/ui/miscdlgs/mtrindlg.cxx
@@ -0,0 +1,188 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "mtrindlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+ScMetricInputDlg::ScMetricInputDlg( Window* pParent,
+ USHORT nResId,
+ long nCurrent,
+ long nDefault,
+ FieldUnit eFUnit,
+ USHORT nDecimals,
+ long nMaximum,
+ long nMinimum,
+ long nFirst,
+ long nLast )
+
+ : ModalDialog ( pParent, ScResId( nResId ) ),
+ //
+ aFtEditTitle ( this, ScResId( FT_LABEL ) ),
+ aEdValue ( this, ScResId( ED_VALUE ) ),
+ aBtnDefVal ( this, ScResId( BTN_DEFVAL ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ //SetText( rTitle );
+ //
+ //aFtEditTitle.SetText( rEditTitle );
+ CalcPositions();
+ aBtnDefVal.SetClickHdl ( LINK( this, ScMetricInputDlg, SetDefValHdl ) );
+ aEdValue. SetModifyHdl( LINK( this, ScMetricInputDlg, ModifyHdl ) );
+
+ aEdValue.SetUnit ( eFUnit );
+ aEdValue.SetDecimalDigits ( nDecimals );
+ aEdValue.SetMax ( aEdValue.Normalize( nMaximum ), FUNIT_TWIP );
+ aEdValue.SetMin ( aEdValue.Normalize( nMinimum ), FUNIT_TWIP );
+ aEdValue.SetLast ( aEdValue.Normalize( nLast ), FUNIT_TWIP );
+ aEdValue.SetFirst ( aEdValue.Normalize( nFirst ), FUNIT_TWIP );
+ aEdValue.SetSpinSize ( aEdValue.Normalize( 1 ) / 10 );
+ aEdValue.SetValue ( aEdValue.Normalize( nDefault ), FUNIT_TWIP );
+ nDefaultValue = sal::static_int_cast<long>( aEdValue.GetValue() );
+ aEdValue.SetValue ( aEdValue.Normalize( nCurrent ), FUNIT_TWIP );
+ nCurrentValue = sal::static_int_cast<long>( aEdValue.GetValue() );
+ aBtnDefVal.Check( nCurrentValue == nDefaultValue );
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScMetricInputDlg::~ScMetricInputDlg()
+{
+}
+
+//------------------------------------------------------------------------
+
+long ScMetricInputDlg::GetInputValue( FieldUnit eUnit ) const
+{
+/*
+ mit Nachkommastellen:
+
+ double nVal = aEdValue.GetValue( eUnit );
+ USHORT nDecs = aEdValue.GetDecimalDigits();
+ double nFactor = 0.0;
+
+ // static long ImpPower10( USHORT nDecs )
+ {
+ nFactor = 1.0;
+
+ for ( USHORT i=0; i < nDecs; i++ )
+ nFactor *= 10.0;
+ }
+
+ return nVal / nFactor;
+*/
+ // erstmal Nachkommastellen abschneiden - nich so doll...
+
+ return sal::static_int_cast<long>( aEdValue.Denormalize( aEdValue.GetValue( eUnit ) ) );
+}
+
+//------------------------------------------------------------------------
+
+void ScMetricInputDlg::CalcPositions()
+{
+ MapMode oldMode = GetMapMode();
+ SetMapMode( MAP_APPFONT );
+
+ Size aDlgSize = GetOutputSizePixel();
+ Size aFtSize = aFtEditTitle.GetSizePixel();
+ Point aNewPos;
+
+ aFtSize.Width() = aFtEditTitle.GetTextWidth(aFtEditTitle.GetText());
+ // #95990# add mnemonic char width to fixed text width
+ aFtSize.Width() += aFtEditTitle.GetTextWidth(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("(W)")));
+ aFtEditTitle.SetSizePixel( aFtSize );
+
+ aNewPos.Y() = aEdValue.GetPosPixel().Y();
+ aNewPos.X() = aFtEditTitle.GetPosPixel().X();
+ aNewPos.X() += aFtEditTitle.GetSizePixel().Width();
+ aNewPos.X() += LogicToPixel( Point(3,0) ).X();
+ aEdValue.SetPosPixel( aNewPos );
+
+ aNewPos.Y() = aBtnDefVal.GetPosPixel().Y();
+ aBtnDefVal.SetPosPixel( aNewPos );
+
+ aNewPos.Y() = aBtnOk.GetPosPixel().Y();
+ aNewPos.X() += aEdValue.GetSizePixel().Width();
+ aNewPos.X() += LogicToPixel( Point(6,0) ).X();
+ aBtnOk.SetPosPixel( aNewPos );
+ aNewPos.Y() = aBtnCancel.GetPosPixel().Y();
+ aBtnCancel.SetPosPixel( aNewPos );
+ aNewPos.Y() = aBtnHelp.GetPosPixel().Y();
+ aBtnHelp.SetPosPixel( aNewPos );
+
+ aNewPos.X() += aBtnOk.GetSizePixel().Width();
+ aNewPos.X() += LogicToPixel( Point(6,0) ).X();
+ aDlgSize.Width() = aNewPos.X();
+ SetOutputSizePixel( aDlgSize );
+
+ SetMapMode( oldMode );
+}
+
+//------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScMetricInputDlg, SetDefValHdl, CheckBox *, EMPTYARG )
+{
+ if ( aBtnDefVal.IsChecked() )
+ {
+ nCurrentValue = sal::static_int_cast<long>( aEdValue.GetValue() );
+ aEdValue.SetValue( nDefaultValue );
+ }
+ else
+ aEdValue.SetValue( nCurrentValue );
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScMetricInputDlg, ModifyHdl, MetricField *, EMPTYARG )
+{
+ aBtnDefVal.Check( nDefaultValue == aEdValue.GetValue() );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScMetricInputDlg, ModifyHdl, MetricField *, EMPTYARG )
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx
new file mode 100644
index 000000000000..a000b1dfd10c
--- /dev/null
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -0,0 +1,207 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+
+#include "mvtabdlg.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "miscdlgs.hrc"
+#include "global.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+
+#include <layout/layout-pre.hxx>
+
+#if ENABLE_LAYOUT
+#undef ScResId
+#define ScResId(x) #x
+#undef ModalDialog
+#define ModalDialog( parent, id ) Dialog( parent, "move-copy-sheet.xml", id )
+#endif /* ENABLE_LAYOUT */
+
+//==================================================================
+
+ScMoveTableDlg::ScMoveTableDlg( Window* pParent )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_MOVETAB ) ),
+ //
+ aFtDoc ( this, ScResId( FT_DEST ) ),
+ aLbDoc ( this, ScResId( LB_DEST ) ),
+ aFtTable ( this, ScResId( FT_INSERT ) ),
+ aLbTable ( this, ScResId( LB_INSERT ) ),
+ aBtnCopy ( this, ScResId( BTN_COPY ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ nDocument ( 0 ),
+ nTable ( 0 ),
+ bCopyTable ( FALSE )
+{
+#if ENABLE_LAYOUT
+#undef ScResId
+ SetHelpId (FID_TAB_MOVE);
+#endif /* ENABLE_LAYOUT */
+ Init();
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScMoveTableDlg::~ScMoveTableDlg()
+{
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScMoveTableDlg::GetSelectedDocument () const { return nDocument; }
+
+SCTAB ScMoveTableDlg::GetSelectedTable () const { return nTable; }
+
+BOOL ScMoveTableDlg::GetCopyTable () const { return bCopyTable; }
+
+void ScMoveTableDlg::SetCopyTable(BOOL bFlag)
+{
+ aBtnCopy.Check(bFlag);
+}
+void ScMoveTableDlg::EnableCopyTable(BOOL bFlag)
+{
+ if(bFlag)
+ aBtnCopy.Enable();
+ else
+ aBtnCopy.Disable();
+}
+
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScMoveTableDlg::Init()
+{
+ aBtnOk.SetClickHdl ( LINK( this, ScMoveTableDlg, OkHdl ) );
+ aLbDoc.SetSelectHdl ( LINK( this, ScMoveTableDlg, SelHdl ) );
+ aBtnCopy.Check( FALSE );
+ InitDocListBox();
+ SelHdl( &aLbDoc );
+}
+
+//------------------------------------------------------------------------
+
+void ScMoveTableDlg::InitDocListBox()
+{
+ SfxObjectShell* pSh = SfxObjectShell::GetFirst();
+ ScDocShell* pScSh = NULL;
+ USHORT nSelPos = 0;
+ USHORT i = 0;
+
+ aLbDoc.Clear();
+ aLbDoc.SetUpdateMode( FALSE );
+
+ while ( pSh )
+ {
+ pScSh = PTR_CAST( ScDocShell, pSh );
+
+ if ( pScSh )
+ {
+ if ( pScSh == SfxObjectShell::Current() )
+ nSelPos = i;
+
+ aLbDoc.InsertEntry( pScSh->GetTitle(), i );
+ aLbDoc.SetEntryData( i, (void*)pScSh->GetDocument() );
+
+ i++;
+ }
+ pSh = SfxObjectShell::GetNext( *pSh );
+ }
+
+ aLbDoc.SetUpdateMode( TRUE );
+ aLbDoc.InsertEntry( String( ScResId( STR_NEWDOC ) ) );
+ aLbDoc.SelectEntryPos( nSelPos );
+}
+
+
+//------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScMoveTableDlg, OkHdl, void *, EMPTYARG )
+{
+ USHORT nDocSel = aLbDoc.GetSelectEntryPos();
+ USHORT nDocLast = aLbDoc.GetEntryCount()-1;
+ USHORT nTabSel = aLbTable.GetSelectEntryPos();
+ USHORT nTabLast = aLbTable.GetEntryCount()-1;
+
+ nDocument = (nDocSel != nDocLast) ? nDocSel : SC_DOC_NEW;
+ nTable = (nTabSel != nTabLast) ? static_cast<SCTAB>(nTabSel) : SC_TAB_APPEND;
+ bCopyTable = aBtnCopy.IsChecked();
+ EndDialog( RET_OK );
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScMoveTableDlg, SelHdl, ListBox *, pLb )
+{
+ if ( pLb == &aLbDoc )
+ {
+ ScDocument* pDoc = (ScDocument*)
+ aLbDoc.GetEntryData( aLbDoc.GetSelectEntryPos() );
+ SCTAB nLast = 0;
+ String aName;
+
+ aLbTable.Clear();
+ aLbTable.SetUpdateMode( FALSE );
+ if ( pDoc )
+ {
+ nLast = pDoc->GetTableCount()-1;
+ for ( SCTAB i=0; i<=nLast; i++ )
+ {
+ pDoc->GetName( i, aName );
+ aLbTable.InsertEntry( aName, static_cast<sal_uInt16>(i) );
+ }
+ }
+ aLbTable.InsertEntry( ScGlobal::GetRscString(STR_MOVE_TO_END) );
+ aLbTable.SetUpdateMode( TRUE );
+ aLbTable.SelectEntryPos( 0 );
+ }
+
+ return 0;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/namecrea.cxx b/sc/source/ui/miscdlgs/namecrea.cxx
new file mode 100644
index 000000000000..67e22dae7b1a
--- /dev/null
+++ b/sc/source/ui/miscdlgs/namecrea.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "namecrea.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+ScNameCreateDlg::ScNameCreateDlg( Window * pParent, USHORT nFlags )
+ : ModalDialog( pParent, ScResId(RID_SCDLG_NAMES_CREATE) ),
+ aFixedLine ( this, ScResId( FL_FRAME ) ),
+ aTopBox ( this, ScResId( BTN_TOP ) ),
+ aLeftBox ( this, ScResId( BTN_LEFT ) ),
+ aBottomBox ( this, ScResId( BTN_BOTTOM ) ),
+ aRightBox ( this, ScResId( BTN_RIGHT ) ),
+ aOKButton ( this, ScResId( BTN_OK ) ),
+ aCancelButton ( this, ScResId( BTN_CANCEL ) ),
+ aHelpButton ( this, ScResId( BTN_HELP ) )
+{
+ aTopBox.Check ( (nFlags & NAME_TOP) ? TRUE : FALSE );
+ aLeftBox.Check ( (nFlags & NAME_LEFT) ? TRUE : FALSE );
+ aBottomBox.Check( (nFlags & NAME_BOTTOM)? TRUE : FALSE );
+ aRightBox.Check ( (nFlags & NAME_RIGHT) ? TRUE : FALSE );
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------
+
+USHORT ScNameCreateDlg::GetFlags() const
+{
+ USHORT nResult = 0;
+
+ nResult |= aTopBox.IsChecked() ? NAME_TOP: 0 ;
+ nResult |= aLeftBox.IsChecked() ? NAME_LEFT: 0 ;
+ nResult |= aBottomBox.IsChecked() ? NAME_BOTTOM: 0 ;
+ nResult |= aRightBox.IsChecked() ? NAME_RIGHT: 0 ;
+
+ return nResult;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/namepast.cxx b/sc/source/ui/miscdlgs/namepast.cxx
new file mode 100644
index 000000000000..543f3bd27005
--- /dev/null
+++ b/sc/source/ui/miscdlgs/namepast.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "namepast.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+#include "rangenam.hxx"
+
+
+//==================================================================
+
+ScNamePasteDlg::ScNamePasteDlg( Window * pParent, const ScRangeName* pList, BOOL bInsList )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_NAMES_PASTE ) ),
+ aLabelText ( this, ScResId( FT_LABEL ) ),
+ aNameList ( this, ScResId( LB_ENTRYLIST ) ),
+ aOKButton ( this, ScResId( BTN_OK ) ),
+ aCancelButton ( this, ScResId( BTN_CANCEL ) ),
+ aHelpButton ( this, ScResId( BTN_HELP ) ),
+ aInsListButton ( this, ScResId( BTN_ADD ) )
+{
+ if( ! bInsList )
+ aInsListButton.Disable();
+
+ aInsListButton.SetClickHdl( LINK( this,ScNamePasteDlg,ButtonHdl) );
+ aOKButton.SetClickHdl( LINK( this,ScNamePasteDlg,ButtonHdl) );
+ aNameList.SetSelectHdl( LINK( this,ScNamePasteDlg,ListSelHdl) );
+ aNameList.SetDoubleClickHdl( LINK( this,ScNamePasteDlg,ListDblClickHdl) );
+
+ USHORT nCnt = pList->GetCount();
+ String aText;
+
+ for( USHORT i=0 ; i<nCnt ; i++ )
+ {
+ ScRangeData* pData = (*pList)[ i ];
+
+ if( pData )
+ {
+ if ( !pData->HasType( RT_DATABASE )
+ && !pData->HasType( RT_SHARED ) )
+ {
+ pData->GetName( aText );
+ aNameList.InsertEntry( aText );
+ }
+ }
+ }
+
+ ListSelHdl( &aNameList );
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------
+
+IMPL_LINK( ScNamePasteDlg, ButtonHdl, Button *, pButton )
+{
+ if( pButton == &aInsListButton )
+ {
+ EndDialog( BTN_PASTE_LIST );
+ }
+ else if( pButton == &aOKButton )
+ {
+ EndDialog( BTN_PASTE_NAME );
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------
+
+IMPL_LINK( ScNamePasteDlg, ListSelHdl, ListBox *, pListBox )
+{
+ if( pListBox == &aNameList )
+ {
+ if( aNameList.GetSelectEntryCount() )
+ aOKButton.Enable();
+ else
+ aOKButton.Disable();
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScNamePasteDlg, ListDblClickHdl, ListBox *, pListBox )
+{
+ if( pListBox == &aNameList )
+ {
+ ButtonHdl( &aOKButton );
+ }
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScNamePasteDlg, ListDblClickHdl, ListBox *, pListBox )
+
+//------------------------------------------------------------------
+
+String ScNamePasteDlg::GetSelectedName() const
+{
+ return aNameList.GetSelectEntry();
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx
new file mode 100644
index 000000000000..9dd2e84550ce
--- /dev/null
+++ b/sc/source/ui/miscdlgs/optsolver.cxx
@@ -0,0 +1,1068 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//----------------------------------------------------------------------------
+
+#include "rangelst.hxx"
+#include "scitems.hxx"
+#include <sfx2/bindings.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <svl/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+
+#include "uiitems.hxx"
+#include "reffact.hxx"
+#include "docsh.hxx"
+#include "docfunc.hxx"
+#include "cell.hxx"
+#include "rangeutl.hxx"
+#include "scresid.hxx"
+#include "convuno.hxx"
+#include "unonames.hxx"
+#include "solveroptions.hxx"
+#include "solverutil.hxx"
+#include "optsolver.hrc"
+
+#include "optsolver.hxx"
+
+#include <com/sun/star/sheet/Solver.hpp>
+#include <com/sun/star/sheet/XSolverDescription.hpp>
+
+using namespace com::sun::star;
+
+//----------------------------------------------------------------------------
+
+ScSolverProgressDialog::ScSolverProgressDialog( Window* pParent )
+ : ModelessDialog( pParent, ScResId( RID_SCDLG_SOLVER_PROGRESS ) ),
+ maFtProgress ( this, ScResId( FT_PROGRESS ) ),
+ maFtTime ( this, ScResId( FT_TIMELIMIT ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) )
+{
+ maBtnOk.Enable(FALSE);
+ FreeResource();
+}
+
+ScSolverProgressDialog::~ScSolverProgressDialog()
+{
+}
+
+void ScSolverProgressDialog::HideTimeLimit()
+{
+ maFtTime.Hide();
+}
+
+void ScSolverProgressDialog::SetTimeLimit( sal_Int32 nSeconds )
+{
+ String aOld = maFtTime.GetText();
+ String aNew = aOld.GetToken(0,'#');
+ aNew += String::CreateFromInt32( nSeconds );
+ aNew += aOld.GetToken(1,'#');
+ maFtTime.SetText( aNew );
+}
+
+//----------------------------------------------------------------------------
+
+ScSolverNoSolutionDialog::ScSolverNoSolutionDialog( Window* pParent, const String& rErrorText )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_NOSOLUTION ) ),
+ maFtNoSolution ( this, ScResId( FT_NOSOLUTION ) ),
+ maFtErrorText ( this, ScResId( FT_ERRORTEXT ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) )
+{
+ maFtErrorText.SetText( rErrorText );
+ FreeResource();
+}
+
+ScSolverNoSolutionDialog::~ScSolverNoSolutionDialog()
+{
+}
+
+//----------------------------------------------------------------------------
+
+ScSolverSuccessDialog::ScSolverSuccessDialog( Window* pParent, const String& rSolution )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_SUCCESS ) ),
+ maFtSuccess ( this, ScResId( FT_SUCCESS ) ),
+ maFtResult ( this, ScResId( FT_RESULT ) ),
+ maFtQuestion ( this, ScResId( FT_QUESTION ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) )
+{
+ String aMessage = maFtResult.GetText();
+ aMessage.Append( (sal_Char) ' ' );
+ aMessage.Append( rSolution );
+ maFtResult.SetText( aMessage );
+ FreeResource();
+}
+
+ScSolverSuccessDialog::~ScSolverSuccessDialog()
+{
+}
+
+//----------------------------------------------------------------------------
+
+ScCursorRefEdit::ScCursorRefEdit( ScAnyRefDlg* pParent, const ResId& rResId ) :
+ formula::RefEdit( pParent, pParent, rResId )
+{
+}
+
+void ScCursorRefEdit::SetCursorLinks( const Link& rUp, const Link& rDown )
+{
+ maCursorUpLink = rUp;
+ maCursorDownLink = rDown;
+}
+
+void ScCursorRefEdit::KeyInput( const KeyEvent& rKEvt )
+{
+ KeyCode aCode = rKEvt.GetKeyCode();
+ bool bUp = (aCode.GetCode() == KEY_UP);
+ bool bDown = (aCode.GetCode() == KEY_DOWN);
+ if ( !aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() && ( bUp || bDown ) )
+ {
+ if ( bUp )
+ maCursorUpLink.Call( this );
+ else
+ maCursorDownLink.Call( this );
+ }
+ else
+ formula::RefEdit::KeyInput( rKEvt );
+}
+
+//----------------------------------------------------------------------------
+
+ScOptSolverSave::ScOptSolverSave( const String& rObjective, BOOL bMax, BOOL bMin, BOOL bValue,
+ const String& rTarget, const String& rVariable,
+ const std::vector<ScOptConditionRow>& rConditions,
+ const String& rEngine,
+ const uno::Sequence<beans::PropertyValue>& rProperties ) :
+ maObjective( rObjective ),
+ mbMax( bMax ),
+ mbMin( bMin ),
+ mbValue( bValue ),
+ maTarget( rTarget ),
+ maVariable( rVariable ),
+ maConditions( rConditions ),
+ maEngine( rEngine ),
+ maProperties( rProperties )
+{
+}
+
+//============================================================================
+// class ScOptSolverDlg
+//----------------------------------------------------------------------------
+
+ScOptSolverDlg::ScOptSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocShell* pDocSh, ScAddress aCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_OPTSOLVER ),
+ //
+ maFtObjectiveCell ( this, ScResId( FT_OBJECTIVECELL ) ),
+ maEdObjectiveCell ( this, this, ScResId( ED_OBJECTIVECELL ) ),
+ maRBObjectiveCell ( this, ScResId( IB_OBJECTIVECELL ), &maEdObjectiveCell, this ),
+ maFtDirection ( this, ScResId( FT_DIRECTION ) ),
+ maRbMax ( this, ScResId( RB_MAX ) ),
+ maRbMin ( this, ScResId( RB_MIN ) ),
+ maRbValue ( this, ScResId( RB_VALUE ) ),
+ maEdTargetValue ( this, this, ScResId( ED_TARGET ) ),
+ maRBTargetValue ( this, ScResId( IB_TARGET ), &maEdTargetValue, this ),
+ maFtVariableCells ( this, ScResId( FT_VARIABLECELLS ) ),
+ maEdVariableCells ( this, this, ScResId( ED_VARIABLECELLS ) ),
+ maRBVariableCells ( this, ScResId( IB_VARIABLECELLS ), &maEdVariableCells, this),
+ maFlConditions ( this, ScResId( FL_CONDITIONS ) ),
+ maFtCellRef ( this, ScResId( FT_CELLREF ) ),
+ maEdLeft1 ( this, ScResId( ED_LEFT1 ) ),
+ maRBLeft1 ( this, ScResId( IB_LEFT1 ), &maEdLeft1, this ),
+ maFtOperator ( this, ScResId( FT_OPERATOR ) ),
+ maLbOp1 ( this, ScResId( LB_OP1 ) ),
+ maFtConstraint ( this, ScResId( FT_CONSTRAINT ) ),
+ maEdRight1 ( this, ScResId( ED_RIGHT1 ) ),
+ maRBRight1 ( this, ScResId( IB_RIGHT1 ), &maEdRight1, this ),
+ maBtnDel1 ( this, ScResId( IB_DELETE1 ) ),
+ maEdLeft2 ( this, ScResId( ED_LEFT2 ) ),
+ maRBLeft2 ( this, ScResId( IB_LEFT2 ), &maEdLeft2, this ),
+ maLbOp2 ( this, ScResId( LB_OP2 ) ),
+ maEdRight2 ( this, ScResId( ED_RIGHT2 ) ),
+ maRBRight2 ( this, ScResId( IB_RIGHT2 ), &maEdRight2, this ),
+ maBtnDel2 ( this, ScResId( IB_DELETE2 ) ),
+ maEdLeft3 ( this, ScResId( ED_LEFT3 ) ),
+ maRBLeft3 ( this, ScResId( IB_LEFT3 ), &maEdLeft3, this ),
+ maLbOp3 ( this, ScResId( LB_OP3 ) ),
+ maEdRight3 ( this, ScResId( ED_RIGHT3 ) ),
+ maRBRight3 ( this, ScResId( IB_RIGHT3 ), &maEdRight3, this ),
+ maBtnDel3 ( this, ScResId( IB_DELETE3 ) ),
+ maEdLeft4 ( this, ScResId( ED_LEFT4 ) ),
+ maRBLeft4 ( this, ScResId( IB_LEFT4 ), &maEdLeft4, this ),
+ maLbOp4 ( this, ScResId( LB_OP4 ) ),
+ maEdRight4 ( this, ScResId( ED_RIGHT4 ) ),
+ maRBRight4 ( this, ScResId( IB_RIGHT4 ), &maEdRight4, this ),
+ maBtnDel4 ( this, ScResId( IB_DELETE4 ) ),
+ maScrollBar ( this, ScResId( SB_SCROLL ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOpt ( this, ScResId( BTN_OPTIONS ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maBtnCancel ( this, ScResId( BTN_CLOSE ) ),
+ maBtnSolve ( this, ScResId( BTN_SOLVE ) ),
+ maInputError ( ScResId( STR_INVALIDINPUT ) ),
+ maConditionError ( ScResId( STR_INVALIDCONDITION ) ),
+ //
+ mpDocShell ( pDocSh ),
+ mpDoc ( pDocSh->GetDocument() ),
+ mnCurTab ( aCursorPos.Tab() ),
+ mpEdActive ( NULL ),
+ mbDlgLostFocus ( false ),
+ nScrollPos ( 0 )
+{
+ mpLeftEdit[0] = &maEdLeft1;
+ mpLeftButton[0] = &maRBLeft1;
+ mpRightEdit[0] = &maEdRight1;
+ mpRightButton[0] = &maRBRight1;
+ mpOperator[0] = &maLbOp1;
+ mpDelButton[0] = &maBtnDel1;
+
+ mpLeftEdit[1] = &maEdLeft2;
+ mpLeftButton[1] = &maRBLeft2;
+ mpRightEdit[1] = &maEdRight2;
+ mpRightButton[1] = &maRBRight2;
+ mpOperator[1] = &maLbOp2;
+ mpDelButton[1] = &maBtnDel2;
+
+ mpLeftEdit[2] = &maEdLeft3;
+ mpLeftButton[2] = &maRBLeft3;
+ mpRightEdit[2] = &maEdRight3;
+ mpRightButton[2] = &maRBRight3;
+ mpOperator[2] = &maLbOp3;
+ mpDelButton[2] = &maBtnDel3;
+
+ mpLeftEdit[3] = &maEdLeft4;
+ mpLeftButton[3] = &maRBLeft4;
+ mpRightEdit[3] = &maEdRight4;
+ mpRightButton[3] = &maRBRight4;
+ mpOperator[3] = &maLbOp4;
+ mpDelButton[3] = &maBtnDel4;
+
+ Init( aCursorPos );
+ FreeResource();
+}
+
+//----------------------------------------------------------------------------
+
+ScOptSolverDlg::~ScOptSolverDlg()
+{
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::Init(const ScAddress& rCursorPos)
+{
+ // Get the "Delete Rows" commandimagelist images from sfx instead of
+ // adding a second copy to sc (see ScTbxInsertCtrl::StateChanged)
+
+ rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
+ aSlotURL += rtl::OUString::valueOf( sal_Int32( SID_DEL_ROWS ) );
+ uno::Reference<frame::XFrame> xFrame = GetBindings().GetActiveFrame();
+ Image aDelNm = ::GetImage( xFrame, aSlotURL, FALSE, FALSE );
+ Image aDelHC = ::GetImage( xFrame, aSlotURL, FALSE, TRUE ); // high contrast
+
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpDelButton[nRow]->SetModeImage( aDelNm, BMP_COLOR_NORMAL );
+ mpDelButton[nRow]->SetModeImage( aDelHC, BMP_COLOR_HIGHCONTRAST );
+ }
+
+ maBtnOpt.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
+ maBtnCancel.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
+ maBtnSolve.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
+
+ Link aLink = LINK( this, ScOptSolverDlg, GetFocusHdl );
+ maEdObjectiveCell.SetGetFocusHdl( aLink );
+ maRBObjectiveCell.SetGetFocusHdl( aLink );
+ maEdTargetValue.SetGetFocusHdl( aLink );
+ maRBTargetValue.SetGetFocusHdl( aLink );
+ maEdVariableCells.SetGetFocusHdl( aLink );
+ maRBVariableCells.SetGetFocusHdl( aLink );
+ maRbValue.SetGetFocusHdl( aLink );
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpLeftEdit[nRow]->SetGetFocusHdl( aLink );
+ mpLeftButton[nRow]->SetGetFocusHdl( aLink );
+ mpRightEdit[nRow]->SetGetFocusHdl( aLink );
+ mpRightButton[nRow]->SetGetFocusHdl( aLink );
+ mpOperator[nRow]->SetGetFocusHdl( aLink );
+ }
+
+ aLink = LINK( this, ScOptSolverDlg, LoseFocusHdl );
+ maEdObjectiveCell.SetLoseFocusHdl( aLink );
+ maRBObjectiveCell.SetLoseFocusHdl( aLink );
+ maEdTargetValue. SetLoseFocusHdl( aLink );
+ maRBTargetValue. SetLoseFocusHdl( aLink );
+ maEdVariableCells.SetLoseFocusHdl( aLink );
+ maRBVariableCells.SetLoseFocusHdl( aLink );
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpLeftEdit[nRow]->SetLoseFocusHdl( aLink );
+ mpLeftButton[nRow]->SetLoseFocusHdl( aLink );
+ mpRightEdit[nRow]->SetLoseFocusHdl( aLink );
+ mpRightButton[nRow]->SetLoseFocusHdl( aLink );
+ }
+
+ Link aCursorUp = LINK( this, ScOptSolverDlg, CursorUpHdl );
+ Link aCursorDown = LINK( this, ScOptSolverDlg, CursorDownHdl );
+ Link aCondModify = LINK( this, ScOptSolverDlg, CondModifyHdl );
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpLeftEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown );
+ mpRightEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown );
+ mpLeftEdit[nRow]->SetModifyHdl( aCondModify );
+ mpRightEdit[nRow]->SetModifyHdl( aCondModify );
+ mpDelButton[nRow]->SetClickHdl( LINK( this, ScOptSolverDlg, DelBtnHdl ) );
+ mpOperator[nRow]->SetSelectHdl( LINK( this, ScOptSolverDlg, SelectHdl ) );
+ }
+ maEdTargetValue.SetModifyHdl( LINK( this, ScOptSolverDlg, TargetModifyHdl ) );
+
+ maScrollBar.SetEndScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) );
+ maScrollBar.SetScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) );
+
+ maScrollBar.SetPageSize( EDIT_ROW_COUNT );
+ maScrollBar.SetVisibleSize( EDIT_ROW_COUNT );
+ maScrollBar.SetLineSize( 1 );
+ // Range is set in ShowConditions
+
+ // get available solver implementations
+ //! sort by descriptions?
+ ScSolverUtil::GetImplementations( maImplNames, maDescriptions );
+ sal_Int32 nImplCount = maImplNames.getLength();
+
+ const ScOptSolverSave* pOldData = mpDocShell->GetSolverSaveData();
+ if ( pOldData )
+ {
+ maEdObjectiveCell.SetRefString( pOldData->GetObjective() );
+ maRbMax.Check( pOldData->GetMax() );
+ maRbMin.Check( pOldData->GetMin() );
+ maRbValue.Check( pOldData->GetValue() );
+ maEdTargetValue.SetRefString( pOldData->GetTarget() );
+ maEdVariableCells.SetRefString( pOldData->GetVariable() );
+ maConditions = pOldData->GetConditions();
+ maEngine = pOldData->GetEngine();
+ maProperties = pOldData->GetProperties();
+ }
+ else
+ {
+ maRbMax.Check();
+ String aCursorStr;
+ if ( !mpDoc->GetRangeAtBlock( ScRange(rCursorPos), &aCursorStr ) )
+ rCursorPos.Format( aCursorStr, SCA_ABS, NULL, mpDoc->GetAddressConvention() );
+ maEdObjectiveCell.SetRefString( aCursorStr );
+ if ( nImplCount > 0 )
+ maEngine = maImplNames[0]; // use first implementation
+ }
+ ShowConditions();
+
+ maEdObjectiveCell.GrabFocus();
+ mpEdActive = &maEdObjectiveCell;
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::ReadConditions()
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ ScOptConditionRow aRowEntry;
+ aRowEntry.aLeftStr = mpLeftEdit[nRow]->GetText();
+ aRowEntry.aRightStr = mpRightEdit[nRow]->GetText();
+ aRowEntry.nOperator = mpOperator[nRow]->GetSelectEntryPos();
+
+ long nVecPos = nScrollPos + nRow;
+ if ( nVecPos >= (long)maConditions.size() && !aRowEntry.IsDefault() )
+ maConditions.resize( nVecPos + 1 );
+
+ if ( nVecPos < (long)maConditions.size() )
+ maConditions[nVecPos] = aRowEntry;
+
+ // remove default entries at the end
+ size_t nSize = maConditions.size();
+ while ( nSize > 0 && maConditions[ nSize-1 ].IsDefault() )
+ --nSize;
+ maConditions.resize( nSize );
+ }
+}
+
+void ScOptSolverDlg::ShowConditions()
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ ScOptConditionRow aRowEntry;
+
+ long nVecPos = nScrollPos + nRow;
+ if ( nVecPos < (long)maConditions.size() )
+ aRowEntry = maConditions[nVecPos];
+
+ mpLeftEdit[nRow]->SetRefString( aRowEntry.aLeftStr );
+ mpRightEdit[nRow]->SetRefString( aRowEntry.aRightStr );
+ mpOperator[nRow]->SelectEntryPos( aRowEntry.nOperator );
+ }
+
+ // allow to scroll one page behind the visible or stored rows
+ long nVisible = nScrollPos + EDIT_ROW_COUNT;
+ long nMax = std::max( nVisible, (long) maConditions.size() );
+ maScrollBar.SetRange( Range( 0, nMax + EDIT_ROW_COUNT ) );
+ maScrollBar.SetThumbPos( nScrollPos );
+
+ EnableButtons();
+}
+
+void ScOptSolverDlg::EnableButtons()
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ long nVecPos = nScrollPos + nRow;
+ mpDelButton[nRow]->Enable( nVecPos < (long)maConditions.size() );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScOptSolverDlg::Close()
+{
+ return DoClose( ScOptSolverDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::SetActive()
+{
+ if ( mbDlgLostFocus )
+ {
+ mbDlgLostFocus = false;
+ if( mpEdActive )
+ mpEdActive->GrabFocus();
+ }
+ else
+ {
+ GrabFocus();
+ }
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if( mpEdActive )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(mpEdActive);
+
+ // "target"/"value": single cell
+ bool bSingle = ( mpEdActive == &maEdObjectiveCell || mpEdActive == &maEdTargetValue );
+
+ String aStr;
+ ScAddress aAdr = rRef.aStart;
+ ScRange aNewRef( rRef );
+ if ( bSingle )
+ aNewRef.aEnd = aAdr;
+
+ String aName;
+ if ( pDocP->GetRangeAtBlock( aNewRef, &aName ) ) // named range: show name
+ aStr = aName;
+ else // format cell/range reference
+ {
+ USHORT nFmt = ( aAdr.Tab() == mnCurTab ) ? SCA_ABS : SCA_ABS_3D;
+ if ( bSingle )
+ aAdr.Format( aStr, nFmt, pDocP, pDocP->GetAddressConvention() );
+ else
+ rRef.Format( aStr, nFmt | SCR_ABS, pDocP, pDocP->GetAddressConvention() );
+ }
+
+ // variable cells can be several ranges, so only the selection is replaced
+ if ( mpEdActive == &maEdVariableCells )
+ {
+ String aVal = mpEdActive->GetText();
+ Selection aSel = mpEdActive->GetSelection();
+ aSel.Justify();
+ aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
+ aVal.Insert( aStr, (xub_StrLen)aSel.Min() );
+ Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() );
+ mpEdActive->SetRefString( aVal );
+ mpEdActive->SetSelection( aNewSel );
+ }
+ else
+ mpEdActive->SetRefString( aStr );
+
+ ReadConditions();
+ EnableButtons();
+
+ // select "Value of" if a ref is input into "target" edit
+ if ( mpEdActive == &maEdTargetValue )
+ maRbValue.Check();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScOptSolverDlg::IsRefInputMode() const
+{
+ return mpEdActive != NULL;
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScOptSolverDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &maBtnSolve || pBtn == &maBtnCancel )
+ {
+ bool bSolve = ( pBtn == &maBtnSolve );
+
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+
+ bool bClose = true;
+ if ( bSolve )
+ bClose = CallSolver();
+
+ if ( bClose )
+ {
+ // Close: write dialog settings to DocShell for subsequent calls
+ ReadConditions();
+ ScOptSolverSave aSave(
+ maEdObjectiveCell.GetText(), maRbMax.IsChecked(), maRbMin.IsChecked(), maRbValue.IsChecked(),
+ maEdTargetValue.GetText(), maEdVariableCells.GetText(), maConditions, maEngine, maProperties );
+ mpDocShell->SetSolverSaveData( aSave );
+ Close();
+ }
+ else
+ {
+ // no solution -> dialog is kept open
+ SetDispatcherLock( TRUE );
+ }
+ }
+ else if ( pBtn == &maBtnOpt )
+ {
+ //! move options dialog to UI lib?
+ ScSolverOptionsDialog* pOptDlg =
+ new ScSolverOptionsDialog( this, maImplNames, maDescriptions, maEngine, maProperties );
+ if ( pOptDlg->Execute() == RET_OK )
+ {
+ maEngine = pOptDlg->GetEngine();
+ maProperties = pOptDlg->GetProperties();
+ }
+ delete pOptDlg;
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, GetFocusHdl, Control*, pCtrl )
+{
+ Edit* pEdit = NULL;
+ mpEdActive = NULL;
+
+ if( pCtrl == &maEdObjectiveCell || pCtrl == &maRBObjectiveCell )
+ pEdit = mpEdActive = &maEdObjectiveCell;
+ else if( pCtrl == &maEdTargetValue || pCtrl == &maRBTargetValue )
+ pEdit = mpEdActive = &maEdTargetValue;
+ else if( pCtrl == &maEdVariableCells || pCtrl == &maRBVariableCells )
+ pEdit = mpEdActive = &maEdVariableCells;
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ if( pCtrl == mpLeftEdit[nRow] || pCtrl == mpLeftButton[nRow] )
+ pEdit = mpEdActive = mpLeftEdit[nRow];
+ else if( pCtrl == mpRightEdit[nRow] || pCtrl == mpRightButton[nRow] )
+ pEdit = mpEdActive = mpRightEdit[nRow];
+ else if( pCtrl == mpOperator[nRow] ) // focus on "operator" list box
+ mpEdActive = mpRightEdit[nRow]; // use right edit for ref input, but don't change selection
+ }
+ if( pCtrl == &maRbValue ) // focus on "Value of" radio button
+ mpEdActive = &maEdTargetValue; // use value edit for ref input, but don't change selection
+
+ if( pEdit )
+ pEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ mbDlgLostFocus = !IsActive();
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, DelBtnHdl, PushButton*, pBtn )
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ if( pBtn == mpDelButton[nRow] )
+ {
+ BOOL bHadFocus = pBtn->HasFocus();
+
+ ReadConditions();
+ long nVecPos = nScrollPos + nRow;
+ if ( nVecPos < (long)maConditions.size() )
+ {
+ maConditions.erase( maConditions.begin() + nVecPos );
+ ShowConditions();
+
+ if ( bHadFocus && !pBtn->IsEnabled() )
+ {
+ // If the button is disabled, focus would normally move to the next control,
+ // (left edit of the next row). Move it to left edit of this row instead.
+
+ mpEdActive = mpLeftEdit[nRow];
+ mpEdActive->GrabFocus();
+ }
+ }
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, TargetModifyHdl, Edit*, EMPTYARG )
+{
+ // modify handler for the target edit:
+ // select "Value of" if something is input into the edit
+ if ( maEdTargetValue.GetText().Len() )
+ maRbValue.Check();
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, CondModifyHdl, Edit*, EMPTYARG )
+{
+ // modify handler for the condition edits, just to enable/disable "delete" buttons
+ ReadConditions();
+ EnableButtons();
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, SelectHdl, ListBox*, EMPTYARG )
+{
+ // select handler for operator list boxes, just to enable/disable "delete" buttons
+ ReadConditions();
+ EnableButtons();
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, ScrollHdl, ScrollBar*, EMPTYARG )
+{
+ ReadConditions();
+ nScrollPos = maScrollBar.GetThumbPos();
+ ShowConditions();
+ if( mpEdActive )
+ mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, CursorUpHdl, ScCursorRefEdit*, pEdit )
+{
+ if ( pEdit == mpLeftEdit[0] || pEdit == mpRightEdit[0] )
+ {
+ if ( nScrollPos > 0 )
+ {
+ ReadConditions();
+ --nScrollPos;
+ ShowConditions();
+ if( mpEdActive )
+ mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+ }
+ }
+ else
+ {
+ formula::RefEdit* pFocus = NULL;
+ for ( sal_uInt16 nRow = 1; nRow < EDIT_ROW_COUNT; ++nRow ) // second row or below: move focus
+ {
+ if ( pEdit == mpLeftEdit[nRow] )
+ pFocus = mpLeftEdit[nRow-1];
+ else if ( pEdit == mpRightEdit[nRow] )
+ pFocus = mpRightEdit[nRow-1];
+ }
+ if (pFocus)
+ {
+ mpEdActive = pFocus;
+ pFocus->GrabFocus();
+ }
+ }
+
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, CursorDownHdl, ScCursorRefEdit*, pEdit )
+{
+ if ( pEdit == mpLeftEdit[EDIT_ROW_COUNT-1] || pEdit == mpRightEdit[EDIT_ROW_COUNT-1] )
+ {
+ //! limit scroll position?
+ ReadConditions();
+ ++nScrollPos;
+ ShowConditions();
+ if( mpEdActive )
+ mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+ }
+ else
+ {
+ formula::RefEdit* pFocus = NULL;
+ for ( sal_uInt16 nRow = 0; nRow+1 < EDIT_ROW_COUNT; ++nRow ) // before last row: move focus
+ {
+ if ( pEdit == mpLeftEdit[nRow] )
+ pFocus = mpLeftEdit[nRow+1];
+ else if ( pEdit == mpRightEdit[nRow] )
+ pFocus = mpRightEdit[nRow+1];
+ }
+ if (pFocus)
+ {
+ mpEdActive = pFocus;
+ pFocus->GrabFocus();
+ }
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::ShowError( bool bCondition, formula::RefEdit* pFocus )
+{
+ String aMessage = bCondition ? maConditionError : maInputError;
+ ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ), aMessage ).Execute();
+ if (pFocus)
+ {
+ mpEdActive = pFocus;
+ pFocus->GrabFocus();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+bool ScOptSolverDlg::ParseRef( ScRange& rRange, const String& rInput, bool bAllowRange )
+{
+ ScRangeUtil aRangeUtil;
+ ScAddress::Details aDetails(mpDoc->GetAddressConvention(), 0, 0);
+ USHORT nFlags = rRange.ParseAny( rInput, mpDoc, aDetails );
+ if ( nFlags & SCA_VALID )
+ {
+ if ( (nFlags & SCA_TAB_3D) == 0 )
+ rRange.aStart.SetTab( mnCurTab );
+ if ( (nFlags & SCA_TAB2_3D) == 0 )
+ rRange.aEnd.SetTab( rRange.aStart.Tab() );
+ return ( bAllowRange || rRange.aStart == rRange.aEnd );
+ }
+ else if ( aRangeUtil.MakeRangeFromName( rInput, mpDoc, mnCurTab, rRange, RUTL_NAMES, aDetails ) )
+ return ( bAllowRange || rRange.aStart == rRange.aEnd );
+
+ return false; // not recognized
+}
+
+bool ScOptSolverDlg::FindTimeout( sal_Int32& rTimeout )
+{
+ bool bFound = false;
+
+ if ( !maProperties.getLength() )
+ maProperties = ScSolverUtil::GetDefaults( maEngine ); // get property defaults from component
+
+ sal_Int32 nPropCount = maProperties.getLength();
+ for (sal_Int32 nProp=0; nProp<nPropCount && !bFound; ++nProp)
+ {
+ const beans::PropertyValue& rValue = maProperties[nProp];
+ if ( rValue.Name.equalsAscii( SC_UNONAME_TIMEOUT ) )
+ bFound = ( rValue.Value >>= rTimeout );
+ }
+ return bFound;
+}
+
+bool ScOptSolverDlg::CallSolver() // return true -> close dialog after calling
+{
+ // show progress dialog
+
+ ScSolverProgressDialog aProgress( this );
+ sal_Int32 nTimeout = 0;
+ if ( FindTimeout( nTimeout ) )
+ aProgress.SetTimeLimit( nTimeout );
+ else
+ aProgress.HideTimeLimit();
+ aProgress.Show();
+ aProgress.Update();
+ aProgress.Sync();
+ // try to make sure the progress dialog is painted before continuing
+ Application::Reschedule(true);
+
+ // collect solver parameters
+
+ ReadConditions();
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDocument( mpDocShell->GetModel(), uno::UNO_QUERY );
+
+ ScRange aObjRange;
+ if ( !ParseRef( aObjRange, maEdObjectiveCell.GetText(), false ) )
+ {
+ ShowError( false, &maEdObjectiveCell );
+ return false;
+ }
+ table::CellAddress aObjective( aObjRange.aStart.Tab(), aObjRange.aStart.Col(), aObjRange.aStart.Row() );
+
+ // "changing cells" can be several ranges
+ ScRangeList aVarRanges;
+ if ( !ParseWithNames( aVarRanges, maEdVariableCells.GetText(), mpDoc ) )
+ {
+ ShowError( false, &maEdVariableCells );
+ return false;
+ }
+ uno::Sequence<table::CellAddress> aVariables;
+ sal_Int32 nVarPos = 0;
+ ULONG nRangeCount = aVarRanges.Count();
+ for (ULONG nRangePos=0; nRangePos<nRangeCount; ++nRangePos)
+ {
+ ScRange aRange(*aVarRanges.GetObject(nRangePos));
+ aRange.Justify();
+ SCTAB nTab = aRange.aStart.Tab();
+
+ // resolve into single cells
+
+ sal_Int32 nAdd = ( aRange.aEnd.Col() - aRange.aStart.Col() + 1 ) *
+ ( aRange.aEnd.Row() - aRange.aStart.Row() + 1 );
+ aVariables.realloc( nVarPos + nAdd );
+
+ for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow)
+ for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol)
+ aVariables[nVarPos++] = table::CellAddress( nTab, nCol, nRow );
+ }
+
+ uno::Sequence<sheet::SolverConstraint> aConstraints;
+ sal_Int32 nConstrPos = 0;
+ for ( std::vector<ScOptConditionRow>::const_iterator aConstrIter = maConditions.begin();
+ aConstrIter != maConditions.end(); ++aConstrIter )
+ {
+ if ( aConstrIter->aLeftStr.Len() )
+ {
+ sheet::SolverConstraint aConstraint;
+ // order of list box entries must match enum values
+ aConstraint.Operator = static_cast<sheet::SolverConstraintOperator>(aConstrIter->nOperator);
+
+ ScRange aLeftRange;
+ if ( !ParseRef( aLeftRange, aConstrIter->aLeftStr, true ) )
+ {
+ ShowError( true, NULL );
+ return false;
+ }
+
+ bool bIsRange = false;
+ ScRange aRightRange;
+ if ( ParseRef( aRightRange, aConstrIter->aRightStr, true ) )
+ {
+ if ( aRightRange.aStart == aRightRange.aEnd )
+ aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
+ aRightRange.aStart.Col(), aRightRange.aStart.Row() );
+ else if ( aRightRange.aEnd.Col()-aRightRange.aStart.Col() == aLeftRange.aEnd.Col()-aLeftRange.aStart.Col() &&
+ aRightRange.aEnd.Row()-aRightRange.aStart.Row() == aLeftRange.aEnd.Row()-aLeftRange.aStart.Row() )
+ bIsRange = true; // same size as "left" range, resolve into single cells
+ else
+ {
+ ShowError( true, NULL );
+ return false;
+ }
+ }
+ else
+ {
+ sal_uInt32 nFormat = 0; //! explicit language?
+ double fValue = 0.0;
+ if ( mpDoc->GetFormatTable()->IsNumberFormat( aConstrIter->aRightStr, nFormat, fValue ) )
+ aConstraint.Right <<= fValue;
+ else if ( aConstraint.Operator != sheet::SolverConstraintOperator_INTEGER &&
+ aConstraint.Operator != sheet::SolverConstraintOperator_BINARY )
+ {
+ ShowError( true, NULL );
+ return false;
+ }
+ }
+
+ // resolve into single cells
+
+ sal_Int32 nAdd = ( aLeftRange.aEnd.Col() - aLeftRange.aStart.Col() + 1 ) *
+ ( aLeftRange.aEnd.Row() - aLeftRange.aStart.Row() + 1 );
+ aConstraints.realloc( nConstrPos + nAdd );
+
+ for (SCROW nRow = aLeftRange.aStart.Row(); nRow <= aLeftRange.aEnd.Row(); ++nRow)
+ for (SCCOL nCol = aLeftRange.aStart.Col(); nCol <= aLeftRange.aEnd.Col(); ++nCol)
+ {
+ aConstraint.Left = table::CellAddress( aLeftRange.aStart.Tab(), nCol, nRow );
+ if ( bIsRange )
+ aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
+ aRightRange.aStart.Col() + ( nCol - aLeftRange.aStart.Col() ),
+ aRightRange.aStart.Row() + ( nRow - aLeftRange.aStart.Row() ) );
+
+ aConstraints[nConstrPos++] = aConstraint;
+ }
+ }
+ }
+
+ sal_Bool bMaximize = maRbMax.IsChecked();
+ if ( maRbValue.IsChecked() )
+ {
+ // handle "value of" with an additional constraint (and then minimize)
+
+ sheet::SolverConstraint aConstraint;
+ aConstraint.Left = aObjective;
+ aConstraint.Operator = sheet::SolverConstraintOperator_EQUAL;
+
+ String aValStr = maEdTargetValue.GetText();
+ ScRange aRightRange;
+ if ( ParseRef( aRightRange, aValStr, false ) )
+ aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
+ aRightRange.aStart.Col(), aRightRange.aStart.Row() );
+ else
+ {
+ sal_uInt32 nFormat = 0; //! explicit language?
+ double fValue = 0.0;
+ if ( mpDoc->GetFormatTable()->IsNumberFormat( aValStr, nFormat, fValue ) )
+ aConstraint.Right <<= fValue;
+ else
+ {
+ ShowError( false, &maEdTargetValue );
+ return false;
+ }
+ }
+
+ aConstraints.realloc( nConstrPos + 1 );
+ aConstraints[nConstrPos++] = aConstraint;
+ }
+
+ // copy old document values
+
+ sal_Int32 nVarCount = aVariables.getLength();
+ uno::Sequence<double> aOldValues;
+ aOldValues.realloc( nVarCount );
+ for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
+ {
+ ScAddress aCellPos;
+ ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
+ aOldValues[nVarPos] = mpDoc->GetValue( aCellPos );
+ }
+
+ // create and initialize solver
+
+ uno::Reference<sheet::XSolver> xSolver = ScSolverUtil::GetSolver( maEngine );
+ DBG_ASSERT( xSolver.is(), "can't get solver component" );
+ if ( !xSolver.is() )
+ return false;
+
+ xSolver->setDocument( xDocument );
+ xSolver->setObjective( aObjective );
+ xSolver->setVariables( aVariables );
+ xSolver->setConstraints( aConstraints );
+ xSolver->setMaximize( bMaximize );
+
+ // set options
+ uno::Reference<beans::XPropertySet> xOptProp(xSolver, uno::UNO_QUERY);
+ if ( xOptProp.is() )
+ {
+ sal_Int32 nPropCount = maProperties.getLength();
+ for (sal_Int32 nProp=0; nProp<nPropCount; ++nProp)
+ {
+ const beans::PropertyValue& rValue = maProperties[nProp];
+ try
+ {
+ xOptProp->setPropertyValue( rValue.Name, rValue.Value );
+ }
+ catch ( uno::Exception & )
+ {
+ DBG_ERRORFILE("Exception in solver option property");
+ }
+ }
+ }
+
+ xSolver->solve();
+ sal_Bool bSuccess = xSolver->getSuccess();
+
+ aProgress.Hide();
+ bool bClose = false;
+ bool bRestore = true; // restore old values unless a solution is accepted
+ if ( bSuccess )
+ {
+ // put solution into document so it is visible when asking
+ uno::Sequence<double> aSolution = xSolver->getSolution();
+ if ( aSolution.getLength() == nVarCount )
+ {
+ mpDocShell->LockPaint();
+ ScDocFunc aFunc(*mpDocShell);
+ for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
+ {
+ ScAddress aCellPos;
+ ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
+ aFunc.PutCell( aCellPos, new ScValueCell( aSolution[nVarPos] ), TRUE );
+ }
+ mpDocShell->UnlockPaint();
+ }
+ //! else error?
+
+ // take formatted result from document (result value from component is ignored)
+ String aResultStr;
+ mpDoc->GetString( (SCCOL)aObjective.Column, (SCROW)aObjective.Row, (SCTAB)aObjective.Sheet, aResultStr );
+ ScSolverSuccessDialog aDialog( this, aResultStr );
+ if ( aDialog.Execute() == RET_OK )
+ {
+ // keep results and close dialog
+ bRestore = false;
+ bClose = true;
+ }
+ }
+ else
+ {
+ rtl::OUString aError;
+ uno::Reference<sheet::XSolverDescription> xDesc( xSolver, uno::UNO_QUERY );
+ if ( xDesc.is() )
+ aError = xDesc->getStatusDescription(); // error description from component
+ ScSolverNoSolutionDialog aDialog( this, aError );
+ aDialog.Execute();
+ }
+
+ if ( bRestore ) // restore old values
+ {
+ mpDocShell->LockPaint();
+ ScDocFunc aFunc(*mpDocShell);
+ for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
+ {
+ ScAddress aCellPos;
+ ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
+ aFunc.PutCell( aCellPos, new ScValueCell( aOldValues[nVarPos] ), TRUE );
+ }
+ mpDocShell->UnlockPaint();
+ }
+
+ return bClose;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/protectiondlg.cxx b/sc/source/ui/miscdlgs/protectiondlg.cxx
new file mode 100644
index 000000000000..87185fdc75e2
--- /dev/null
+++ b/sc/source/ui/miscdlgs/protectiondlg.cxx
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "protectiondlg.hxx"
+#include "protectiondlg.hrc"
+#include "scresid.hxx"
+#include "tabprotection.hxx"
+
+#include <sal/macros.h>
+#include <vcl/msgbox.hxx>
+
+
+// The order must match that of the list box.
+static const ScTableProtection::Option aOptions[] = {
+ ScTableProtection::SELECT_LOCKED_CELLS,
+ ScTableProtection::SELECT_UNLOCKED_CELLS,
+};
+static const USHORT nOptionCount = SAL_N_ELEMENTS(aOptions);
+
+
+ScTableProtectionDlg::ScTableProtectionDlg(Window* pParent) :
+ ModalDialog(pParent, ScResId(RID_SCDLG_TABPROTECTION)),
+
+ maBtnProtect (this, ScResId(BTN_PROTECT)),
+ maPassword1Text (this, ScResId(FT_PASSWORD1)),
+ maPassword1Edit (this, ScResId(ED_PASSWORD1)),
+ maPassword2Text (this, ScResId(FT_PASSWORD2)),
+ maPassword2Edit (this, ScResId(ED_PASSWORD2)),
+ maOptionsLine (this, ScResId(FL_OPTIONS)),
+ maOptionsText (this, ScResId(FT_OPTIONS)),
+ maOptionsListBox(this, ScResId(CLB_OPTIONS)),
+
+ maBtnOk (this, ScResId(BTN_OK)),
+ maBtnCancel (this, ScResId(BTN_CANCEL)),
+ maBtnHelp (this, ScResId(BTN_HELP)),
+
+ maSelectLockedCells(ScResId(ST_SELECT_LOCKED_CELLS)),
+ maSelectUnlockedCells(ScResId(ST_SELECT_UNLOCKED_CELLS))
+{
+ Init();
+ FreeResource();
+}
+
+ScTableProtectionDlg::~ScTableProtectionDlg()
+{
+}
+
+short ScTableProtectionDlg::Execute()
+{
+ return ModalDialog::Execute();
+}
+
+void ScTableProtectionDlg::SetDialogData(const ScTableProtection& rData)
+{
+ for (USHORT i = 0; i < nOptionCount; ++i)
+ maOptionsListBox.CheckEntryPos(i, rData.isOptionEnabled(aOptions[i]));
+}
+
+void ScTableProtectionDlg::WriteData(ScTableProtection& rData) const
+{
+ rData.setProtected(maBtnProtect.IsChecked());
+
+ // We assume that the two password texts match.
+ rData.setPassword(maPassword1Edit.GetText());
+
+ for (USHORT i = 0; i < nOptionCount; ++i)
+ rData.setOption(aOptions[i], maOptionsListBox.IsChecked(i));
+}
+
+void ScTableProtectionDlg::Init()
+{
+ Link aLink = LINK( this, ScTableProtectionDlg, CheckBoxHdl );
+ maBtnProtect.SetClickHdl(aLink);
+
+ aLink = LINK( this, ScTableProtectionDlg, OKHdl );
+ maBtnOk.SetClickHdl(aLink);
+
+ aLink = LINK( this, ScTableProtectionDlg, PasswordModifyHdl );
+ maPassword1Edit.SetModifyHdl(aLink);
+ maPassword2Edit.SetModifyHdl(aLink);
+
+ maOptionsListBox.SetUpdateMode(false);
+ maOptionsListBox.Clear();
+
+ maOptionsListBox.InsertEntry(maSelectLockedCells);
+ maOptionsListBox.InsertEntry(maSelectUnlockedCells);
+
+ maOptionsListBox.CheckEntryPos(0, true);
+ maOptionsListBox.CheckEntryPos(1, true);
+
+ maOptionsListBox.SetUpdateMode(true);
+
+ // Set the default state of the dialog.
+ maBtnProtect.Check(true);
+ maPassword1Edit.GrabFocus();
+}
+
+void ScTableProtectionDlg::EnableOptionalWidgets(bool bEnable)
+{
+ maPassword1Text.Enable(bEnable);
+ maPassword1Edit.Enable(bEnable);
+ maPassword2Text.Enable(bEnable);
+ maPassword2Edit.Enable(bEnable);
+ maOptionsLine.Enable(bEnable);
+ maOptionsText.Enable(bEnable);
+
+ maOptionsListBox.Enable(bEnable);
+ maOptionsListBox.Invalidate();
+}
+
+IMPL_LINK( ScTableProtectionDlg, CheckBoxHdl, CheckBox*, pBtn )
+{
+ if (pBtn == &maBtnProtect)
+ {
+ bool bChecked = maBtnProtect.IsChecked();
+ EnableOptionalWidgets(bChecked);
+ maBtnOk.Enable(bChecked);
+ }
+
+ return 0;
+}
+
+IMPL_LINK( ScTableProtectionDlg, OKHdl, OKButton*, EMPTYARG )
+{
+ EndDialog(RET_OK);
+ return 0;
+}
+
+IMPL_LINK( ScTableProtectionDlg, PasswordModifyHdl, Edit*, EMPTYARG )
+{
+ String aPass1 = maPassword1Edit.GetText();
+ String aPass2 = maPassword2Edit.GetText();
+ maBtnOk.Enable(aPass1.Equals(aPass2));
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/protectiondlg.src b/sc/source/ui/miscdlgs/protectiondlg.src
new file mode 100644
index 000000000000..34ad4063de57
--- /dev/null
+++ b/sc/source/ui/miscdlgs/protectiondlg.src
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "protectiondlg.hrc"
+
+ModalDialog RID_SCDLG_TABPROTECTION
+{
+ Text [ en-US ] = "Protect Sheet" ;
+ Size = MAP_APPFONT ( 220 , 135 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 164 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 164 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 164 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+
+ CheckBox BTN_PROTECT
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 150 , 10 );
+
+ Text [ en-US ] = "P~rotect this sheet and the contents of locked cells" ;
+ };
+
+ FixedText FT_PASSWORD1
+ {
+ Pos = MAP_APPFONT ( 11, 23 );
+ Size = MAP_APPFONT ( 42, 10 );
+
+ Text [ en-US ] = "~Password" ;
+ };
+
+ Edit ED_PASSWORD1
+ {
+ Border = TRUE;
+ PassWord = TRUE;
+ Pos = MAP_APPFONT ( 56, 22 );
+ Size = MAP_APPFONT ( 75, 12 );
+ };
+
+ FixedText FT_PASSWORD2
+ {
+ Pos = MAP_APPFONT ( 11, 40 );
+ Size = MAP_APPFONT ( 42, 10 );
+
+ Text [ en-US ] = "~Confirm" ;
+ };
+
+ Edit ED_PASSWORD2
+ {
+ Border = TRUE;
+ PassWord = TRUE;
+ Pos = MAP_APPFONT ( 56, 39 );
+ Size = MAP_APPFONT ( 75, 12 );
+ };
+
+ FixedLine FL_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6, 60 );
+ Size = MAP_APPFONT ( 150, 8 );
+
+ Text [ en-US ] = "Options";
+ };
+
+ FixedText FT_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 11, 74 );
+ Size = MAP_APPFONT ( 140, 8 );
+
+ Text [ en-US ] = "Allow all users of this sheet to:";
+ };
+
+ Control CLB_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 11, 85 );
+ Size = MAP_APPFONT ( 140, 40 );
+ Border = TRUE ;
+ TabStop = TRUE ;
+ };
+
+ String ST_SELECT_LOCKED_CELLS
+ {
+ Text [ en-US ] = "Select locked cells";
+ };
+
+ String ST_SELECT_UNLOCKED_CELLS
+ {
+ Text [ en-US ] = "Select unlocked cells";
+ };
+};
diff --git a/sc/source/ui/miscdlgs/redcom.cxx b/sc/source/ui/miscdlgs/redcom.cxx
new file mode 100644
index 000000000000..82e2578a5c65
--- /dev/null
+++ b/sc/source/ui/miscdlgs/redcom.cxx
@@ -0,0 +1,187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <vcl/msgbox.hxx>
+#include <unotools/localedatawrapper.hxx>
+
+#include "redcom.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+//------------------------------------------------------------------------
+
+ScRedComDialog::ScRedComDialog( Window* pParent, const SfxItemSet& rCoreSet,
+ ScDocShell *pShell,ScChangeAction *pAction,BOOL bPrevNext)
+{
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ pDlg = pFact->CreateSvxPostItDialog( pParent, rCoreSet, bPrevNext, TRUE );
+ DBG_ASSERT(pDlg, "Dialog creation failed!");
+ pDocShell=pShell;
+ pDlg->DontChangeAuthor();
+ pDlg->HideAuthor();
+
+ pDlg->SetPrevHdl(LINK( this, ScRedComDialog, PrevHdl));
+ pDlg->SetNextHdl(LINK( this, ScRedComDialog, NextHdl));
+
+ ReInit(pAction);
+ }
+}
+
+ScRedComDialog::~ScRedComDialog()
+{
+ delete pDlg;
+}
+
+ScChangeAction *ScRedComDialog::FindPrev(ScChangeAction *pAction)
+{
+ if(pAction!=NULL && pDocShell !=NULL)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScChangeViewSettings* pSettings = pDoc->GetChangeViewSettings();
+
+ pAction=pAction->GetPrev();
+
+ while(pAction!=NULL)
+ {
+ if( pAction->GetState()==SC_CAS_VIRGIN &&
+ pAction->IsDialogRoot() &&
+ ScViewUtil::IsActionShown(*pAction,*pSettings,*pDoc)) break;
+
+ pAction=pAction->GetPrev();
+ }
+ }
+ return pAction;
+}
+
+ScChangeAction *ScRedComDialog::FindNext(ScChangeAction *pAction)
+{
+ if(pAction!=NULL && pDocShell !=NULL)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScChangeViewSettings* pSettings = pDoc->GetChangeViewSettings();
+
+ pAction=pAction->GetNext();
+
+ while(pAction!=NULL)
+ {
+ if( pAction->GetState()==SC_CAS_VIRGIN &&
+ pAction->IsDialogRoot() &&
+ ScViewUtil::IsActionShown(*pAction,*pSettings,*pDoc)) break;
+
+ pAction=pAction->GetNext();
+ }
+ }
+ return pAction;
+}
+
+void ScRedComDialog::ReInit(ScChangeAction *pAction)
+{
+ pChangeAction=pAction;
+ if(pChangeAction!=NULL && pDocShell !=NULL)
+ {
+ String aTitle;
+ pChangeAction->GetDescription( aTitle, pDocShell->GetDocument());
+ pDlg->SetText(aTitle);
+ aComment=pChangeAction->GetComment();
+
+ BOOL bNext=FindNext(pChangeAction)!=NULL;
+ BOOL bPrev=FindPrev(pChangeAction)!=NULL;
+ pDlg->EnableTravel(bNext,bPrev);
+
+ String aAuthor = pChangeAction->GetUser();
+
+ DateTime aDT = pChangeAction->GetDateTime();
+ String aDate = ScGlobal::pLocaleData->getDate( aDT );
+ aDate += ' ';
+ aDate += ScGlobal::pLocaleData->getTime( aDT, FALSE, FALSE );
+
+ pDlg->ShowLastAuthor(aAuthor, aDate);
+ pDlg->SetNote(aComment);
+ }
+}
+
+short ScRedComDialog::Execute()
+{
+ short nRet=pDlg->Execute();
+
+ if(nRet== RET_OK )
+ {
+ if ( pDocShell!=NULL && pDlg->GetNote() != aComment )
+ pDocShell->SetChangeComment( pChangeAction, pDlg->GetNote());
+ }
+
+ return nRet;
+}
+
+void ScRedComDialog::SelectCell()
+{
+ if(pChangeAction!=NULL)
+ {
+ const ScChangeAction* pAction=pChangeAction;
+ const ScBigRange& rRange = pAction->GetBigRange();
+
+ if(rRange.IsValid(pDocShell->GetDocument()))
+ {
+ ScViewData* pViewData=pDocShell->GetViewData();
+ ScRange aRef=rRange.MakeRange();
+ ScTabView* pTabView=pViewData->GetView();
+ pTabView->MarkRange(aRef);
+ }
+ }
+}
+
+IMPL_LINK(ScRedComDialog, PrevHdl, AbstractSvxPostItDialog*, pDlgP )
+{
+ if (pDocShell!=NULL && pDlgP->GetNote() != aComment )
+ pDocShell->SetChangeComment( pChangeAction, pDlgP->GetNote());
+
+ ReInit(FindPrev(pChangeAction));
+ SelectCell();
+
+ return 0;
+}
+
+IMPL_LINK(ScRedComDialog, NextHdl, AbstractSvxPostItDialog*, pDlgP )
+{
+ if ( pDocShell!=NULL && pDlgP->GetNote() != aComment )
+ pDocShell->SetChangeComment( pChangeAction, pDlgP->GetNote());
+
+ ReInit(FindNext(pChangeAction));
+ SelectCell();
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/retypepassdlg.cxx b/sc/source/ui/miscdlgs/retypepassdlg.cxx
new file mode 100644
index 000000000000..36aaa92ef0f2
--- /dev/null
+++ b/sc/source/ui/miscdlgs/retypepassdlg.cxx
@@ -0,0 +1,547 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "retypepassdlg.hxx"
+#include "retypepassdlg.hrc"
+#include "scresid.hxx"
+#include "document.hxx"
+#include "tabprotection.hxx"
+
+#include <stdio.h>
+
+#include <vcl/msgbox.hxx>
+
+ScRetypePassDlg::ScRetypePassDlg(Window* pParent) :
+ ModalDialog(pParent, ScResId(RID_SCDLG_RETYPEPASS)),
+
+ maBtnOk (this, ScResId(BTN_OK)),
+ maBtnCancel (this, ScResId(BTN_CANCEL)),
+ maBtnHelp (this, ScResId(BTN_HELP)),
+
+ maTextDescription(this, ScResId(FT_DESC)),
+ maLineDocument(this, ScResId(FL_DOCUMENT)),
+ maTextDocStatus(this, ScResId(FT_DOCSTATUS)),
+ maBtnRetypeDoc(this, ScResId(BTN_RETYPE_DOC)),
+
+ maLineSheet(this, ScResId(FL_SHEET)),
+ maTextSheetName1(this, ScResId(FT_SHEETNAME1)),
+ maTextSheetStatus1(this, ScResId(FT_SHEETSTATUS1)),
+ maBtnRetypeSheet1(this, ScResId(BTN_RETYPE_SHEET1)),
+
+ maTextSheetName2(this, ScResId(FT_SHEETNAME2)),
+ maTextSheetStatus2(this, ScResId(FT_SHEETSTATUS2)),
+ maBtnRetypeSheet2(this, ScResId(BTN_RETYPE_SHEET2)),
+
+ maTextSheetName3(this, ScResId(FT_SHEETNAME3)),
+ maTextSheetStatus3(this, ScResId(FT_SHEETSTATUS3)),
+ maBtnRetypeSheet3(this, ScResId(BTN_RETYPE_SHEET3)),
+
+ maTextSheetName4(this, ScResId(FT_SHEETNAME4)),
+ maTextSheetStatus4(this, ScResId(FT_SHEETSTATUS4)),
+ maBtnRetypeSheet4(this, ScResId(BTN_RETYPE_SHEET4)),
+
+ maScrollBar (this, ScResId(SB_SCROLL)),
+
+ maTextNotProtected(ScResId(STR_NOT_PROTECTED)),
+ maTextNotPassProtected(ScResId(STR_NOT_PASS_PROTECTED)),
+ maTextHashBad(ScResId(STR_HASH_BAD)),
+ maTextHashGood(ScResId(STR_HASH_GOOD)),
+ maTextHashRegen(ScResId(STR_HASH_REGENERATED)),
+
+ mpDocItem(static_cast<ScDocProtection*>(NULL)),
+ mnCurScrollPos(0),
+ meDesiredHash(PASSHASH_SHA1)
+{
+ Init();
+}
+
+ScRetypePassDlg::~ScRetypePassDlg()
+{
+}
+
+short ScRetypePassDlg::Execute()
+{
+ PopulateDialog();
+ CheckHashStatus();
+ return ModalDialog::Execute();
+}
+
+void ScRetypePassDlg::SetDataFromDocument(const ScDocument& rDoc)
+{
+ const ScDocProtection* pDocProtect = rDoc.GetDocProtection();
+ if (pDocProtect && pDocProtect->isProtected())
+ mpDocItem.reset(new ScDocProtection(*pDocProtect));
+
+ SCTAB nTabCount = rDoc.GetTableCount();
+ maTableItems.reserve(nTabCount);
+ for (SCTAB i = 0; i < nTabCount; ++i)
+ {
+ TableItem aTabItem;
+ rDoc.GetName(i, aTabItem.maName);
+
+ const ScTableProtection* pTabProtect = rDoc.GetTabProtection(i);
+ if (pTabProtect && pTabProtect->isProtected())
+ aTabItem.mpProtect.reset(new ScTableProtection(*pTabProtect));
+
+ maTableItems.push_back(aTabItem);
+ }
+}
+
+void ScRetypePassDlg::SetDesiredHash(ScPasswordHash eHash)
+{
+ meDesiredHash = eHash;
+}
+
+void ScRetypePassDlg::WriteNewDataToDocument(ScDocument& rDoc) const
+{
+ if (mpDocItem.get())
+ rDoc.SetDocProtection(mpDocItem.get());
+
+ size_t nTabCount = static_cast<size_t>(rDoc.GetTableCount());
+ size_t n = maTableItems.size();
+ for (size_t i = 0; i < n; ++i)
+ {
+ if (i >= nTabCount)
+ break;
+
+ ScTableProtection* pTabProtect = maTableItems[i].mpProtect.get();
+ if (pTabProtect)
+ rDoc.SetTabProtection(static_cast<SCTAB>(i), pTabProtect);
+ }
+}
+
+void ScRetypePassDlg::Init()
+{
+ Link aLink = LINK( this, ScRetypePassDlg, OKHdl );
+ maBtnOk.SetClickHdl(aLink);
+
+ aLink = LINK( this, ScRetypePassDlg, RetypeBtnHdl );
+ maBtnRetypeDoc.SetClickHdl(aLink);
+ maBtnRetypeSheet1.SetClickHdl(aLink);
+ maBtnRetypeSheet2.SetClickHdl(aLink);
+ maBtnRetypeSheet3.SetClickHdl(aLink);
+ maBtnRetypeSheet4.SetClickHdl(aLink);
+
+ maTextDocStatus.SetText(maTextNotProtected);
+ maTextSheetStatus1.SetText(maTextNotProtected);
+ maTextSheetStatus2.SetText(maTextNotProtected);
+ maTextSheetStatus3.SetText(maTextNotProtected);
+ maTextSheetStatus4.SetText(maTextNotProtected);
+ maBtnRetypeDoc.Disable();
+
+ // Make all sheet rows invisible.
+
+ maTextSheetName1.Show(false);
+ maTextSheetStatus1.Show(false);
+ maBtnRetypeSheet1.Show(false);
+ maBtnRetypeSheet1.Disable();
+
+ maTextSheetName2.Show(false);
+ maTextSheetStatus2.Show(false);
+ maBtnRetypeSheet2.Show(false);
+ maBtnRetypeSheet2.Disable();
+
+ maTextSheetName3.Show(false);
+ maTextSheetStatus3.Show(false);
+ maBtnRetypeSheet3.Show(false);
+ maBtnRetypeSheet3.Disable();
+
+ maTextSheetName4.Show(false);
+ maTextSheetStatus4.Show(false);
+ maBtnRetypeSheet4.Show(false);
+ maBtnRetypeSheet4.Disable();
+
+ maScrollBar.Show(false);
+
+ maScrollBar.SetEndScrollHdl( LINK( this, ScRetypePassDlg, ScrollHdl ) );
+ maScrollBar.SetScrollHdl( LINK( this, ScRetypePassDlg, ScrollHdl ) );
+
+ maScrollBar.SetPageSize(4);
+ maScrollBar.SetVisibleSize(4);
+ maScrollBar.SetLineSize(1);
+}
+
+void ScRetypePassDlg::PopulateDialog()
+{
+ // Document protection first.
+ SetDocData();
+
+ // Sheet protection next. We're only interested in the first 4 sheets
+ // (or less).
+ size_t n = maTableItems.size();
+ for (size_t i = 0; i < n && i < 4; ++i)
+ SetTableData(i, static_cast< SCTAB >( i ));
+
+ if (n > 4)
+ {
+ maScrollBar.Show(true);
+ maScrollBar.SetRange(Range(0, n));
+ }
+}
+
+void ScRetypePassDlg::SetDocData()
+{
+ bool bBtnEnabled = false;
+ if (mpDocItem.get() && mpDocItem->isProtected())
+ {
+ if (mpDocItem->isPasswordEmpty())
+ maTextDocStatus.SetText(maTextNotPassProtected);
+ else if (mpDocItem->hasPasswordHash(meDesiredHash))
+ maTextDocStatus.SetText(maTextHashGood);
+ else
+ {
+ // incompatible hash
+ maTextDocStatus.SetText(maTextHashBad);
+ bBtnEnabled = true;
+ }
+ }
+ maBtnRetypeDoc.Enable(bBtnEnabled);
+}
+
+void ScRetypePassDlg::SetTableData(size_t nRowPos, SCTAB nTab)
+{
+ if (nRowPos >= 4)
+ return;
+
+ FixedText* pName = NULL;
+ FixedText* pStatus = NULL;
+ PushButton* pBtn = NULL;
+ switch (nRowPos)
+ {
+ case 0:
+ pName = &maTextSheetName1;
+ pStatus = &maTextSheetStatus1;
+ pBtn = &maBtnRetypeSheet1;
+ break;
+ case 1:
+ pName = &maTextSheetName2;
+ pStatus = &maTextSheetStatus2;
+ pBtn = &maBtnRetypeSheet2;
+ break;
+ case 2:
+ pName = &maTextSheetName3;
+ pStatus = &maTextSheetStatus3;
+ pBtn = &maBtnRetypeSheet3;
+ break;
+ case 3:
+ pName = &maTextSheetName4;
+ pStatus = &maTextSheetStatus4;
+ pBtn = &maBtnRetypeSheet4;
+ break;
+ default:
+ return;
+ }
+
+ bool bBtnEnabled = false;
+ pName->SetText(maTableItems[nTab].maName);
+ pName->Show(true);
+ const ScTableProtection* pTabProtect = maTableItems[nTab].mpProtect.get();
+ if (pTabProtect && pTabProtect->isProtected())
+ {
+ if (pTabProtect->isPasswordEmpty())
+ pStatus->SetText(maTextNotPassProtected);
+ else if (pTabProtect->hasPasswordHash(meDesiredHash))
+ pStatus->SetText(maTextHashGood);
+ else
+ {
+ // incompatible hash
+ pStatus->SetText(maTextHashBad);
+ bBtnEnabled = true;
+ }
+ }
+ else
+ pStatus->SetText(maTextNotProtected);
+
+ pStatus->Show(true);
+ pBtn->Show(true);
+ pBtn->Enable(bBtnEnabled);
+}
+
+void ScRetypePassDlg::ResetTableRows()
+{
+ long nScrollPos = maScrollBar.GetThumbPos();
+ mnCurScrollPos = nScrollPos < 0 ? 0 : nScrollPos;
+ size_t nRowCount = maTableItems.size() - nScrollPos;
+ for (size_t i = 0; i < nRowCount; ++i)
+ SetTableData(i, static_cast< SCTAB >( i + nScrollPos ));
+}
+
+bool lcl_IsInGoodStatus(ScPassHashProtectable* pProtected, ScPasswordHash eDesiredHash)
+{
+ if (!pProtected || !pProtected->isProtected())
+ // Not protected.
+ return true;
+
+ if (pProtected->isPasswordEmpty())
+ return true;
+
+ if (pProtected->hasPasswordHash(eDesiredHash))
+ return true;
+
+ return false;
+}
+
+void ScRetypePassDlg::CheckHashStatus()
+{
+ do
+ {
+ if (!lcl_IsInGoodStatus(mpDocItem.get(), meDesiredHash))
+ break;
+
+ bool bStatusGood = true;
+ size_t nTabCount = maTableItems.size();
+ for (size_t i = 0; i < nTabCount && bStatusGood; ++i)
+ {
+ if (!lcl_IsInGoodStatus(maTableItems[i].mpProtect.get(), meDesiredHash))
+ bStatusGood = false;
+ }
+ if (!bStatusGood)
+ break;
+
+ maBtnOk.Enable();
+ return;
+ }
+ while (false);
+
+ maBtnOk.Disable();
+}
+
+IMPL_LINK( ScRetypePassDlg, OKHdl, OKButton*, EMPTYARG )
+{
+ EndDialog(RET_OK);
+ return 0;
+}
+
+IMPL_LINK( ScRetypePassDlg, RetypeBtnHdl, PushButton*, pBtn )
+{
+ ScPassHashProtectable* pProtected = NULL;
+ if (pBtn == &maBtnRetypeDoc)
+ {
+ // document protection.
+ pProtected = mpDocItem.get();
+ }
+ else
+ {
+ // sheet protection.
+ size_t nTabPos = mnCurScrollPos;
+ if (pBtn == &maBtnRetypeSheet2)
+ nTabPos += 1;
+ else if (pBtn == &maBtnRetypeSheet3)
+ nTabPos += 2;
+ else if (pBtn == &maBtnRetypeSheet4)
+ nTabPos += 3;
+ else if (pBtn != &maBtnRetypeSheet1)
+ // This should never happen !
+ return 0;
+
+ if (nTabPos >= maTableItems.size())
+ // Likewise, this should never happen !
+ return 0;
+
+ pProtected = maTableItems[nTabPos].mpProtect.get();
+ }
+
+ if (!pProtected)
+ // What the ... !?
+ return 0;
+
+ ScRetypePassInputDlg aDlg(this, pProtected);
+ if (aDlg.Execute() == RET_OK)
+ {
+ // OK is pressed. Update the protected item.
+ if (aDlg.IsRemovePassword())
+ {
+ // Remove password from this item.
+ pProtected->setPassword(String());
+ }
+ else
+ {
+ // Set a new password.
+ String aNewPass = aDlg.GetNewPassword();
+ pProtected->setPassword(aNewPass);
+ }
+
+ SetDocData();
+ ResetTableRows();
+ CheckHashStatus();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScRetypePassDlg, ScrollHdl, ScrollBar*, EMPTYARG )
+{
+ ResetTableRows();
+ return 0;
+}
+
+// ============================================================================
+
+ScRetypePassInputDlg::ScRetypePassInputDlg(Window* pParent, ScPassHashProtectable* pProtected) :
+ ModalDialog(pParent, ScResId(RID_SCDLG_RETYPEPASS_INPUT)),
+
+ maBtnOk (this, ScResId(BTN_OK)),
+ maBtnCancel (this, ScResId(BTN_CANCEL)),
+ maBtnHelp (this, ScResId(BTN_HELP)),
+
+ maBtnRetypePassword(this, ScResId(BTN_RETYPE_PASSWORD)),
+
+ maPassword1Text (this, ScResId(FT_PASSWORD1)),
+ maPassword1Edit (this, ScResId(ED_PASSWORD1)),
+ maPassword2Text (this, ScResId(FT_PASSWORD2)),
+ maPassword2Edit (this, ScResId(ED_PASSWORD2)),
+ maBtnMatchOldPass(this, ScResId(BTN_MATCH_OLD_PASSWORD)),
+
+ maBtnRemovePassword(this, ScResId(BTN_REMOVE_PASSWORD)),
+
+ mpProtected(pProtected)
+{
+ Init();
+}
+
+ScRetypePassInputDlg::~ScRetypePassInputDlg()
+{
+}
+
+short ScRetypePassInputDlg::Execute()
+{
+ return ModalDialog::Execute();
+}
+
+bool ScRetypePassInputDlg::IsRemovePassword() const
+{
+ return maBtnRemovePassword.IsChecked();
+}
+
+String ScRetypePassInputDlg::GetNewPassword() const
+{
+ return maPassword1Edit.GetText();
+}
+
+void ScRetypePassInputDlg::Init()
+{
+ Link aLink = LINK( this, ScRetypePassInputDlg, OKHdl );
+ maBtnOk.SetClickHdl(aLink);
+ aLink = LINK( this, ScRetypePassInputDlg, RadioBtnHdl );
+ maBtnRetypePassword.SetClickHdl(aLink);
+ maBtnRemovePassword.SetClickHdl(aLink);
+ aLink = LINK( this, ScRetypePassInputDlg, CheckBoxHdl );
+ maBtnMatchOldPass.SetClickHdl(aLink);
+ aLink = LINK( this, ScRetypePassInputDlg, PasswordModifyHdl );
+ maPassword1Edit.SetModifyHdl(aLink);
+ maPassword2Edit.SetModifyHdl(aLink);
+
+ maBtnOk.Disable();
+ maBtnRetypePassword.Check(true);
+ maBtnMatchOldPass.Check(true);
+ maPassword1Edit.GrabFocus();
+}
+
+void ScRetypePassInputDlg::CheckPasswordInput()
+{
+ String aPass1 = maPassword1Edit.GetText();
+ String aPass2 = maPassword2Edit.GetText();
+
+ if (!aPass1.Len() || !aPass2.Len())
+ {
+ // Empty password is not allowed.
+ maBtnOk.Disable();
+ return;
+ }
+
+ if (!aPass1.Equals(aPass2))
+ {
+ // The two passwords differ.
+ maBtnOk.Disable();
+ return;
+ }
+
+ if (!maBtnMatchOldPass.IsChecked())
+ {
+ maBtnOk.Enable();
+ return;
+ }
+
+ if (!mpProtected)
+ {
+ // This should never happen!
+ maBtnOk.Disable();
+ return;
+ }
+
+ bool bPassGood = mpProtected->verifyPassword(aPass1);
+ maBtnOk.Enable(bPassGood);
+}
+
+IMPL_LINK( ScRetypePassInputDlg, OKHdl, OKButton*, EMPTYARG )
+{
+ EndDialog(RET_OK);
+ return 0;
+}
+
+IMPL_LINK( ScRetypePassInputDlg, RadioBtnHdl, RadioButton*, pBtn )
+{
+ if (pBtn == &maBtnRetypePassword)
+ {
+ maBtnRemovePassword.Check(false);
+ maPassword1Text.Enable();
+ maPassword1Edit.Enable();
+ maPassword2Text.Enable();
+ maPassword2Edit.Enable();
+ maBtnMatchOldPass.Enable();
+ CheckPasswordInput();
+ }
+ else if (pBtn == &maBtnRemovePassword)
+ {
+ maBtnRetypePassword.Check(false);
+ maPassword1Text.Disable();
+ maPassword1Edit.Disable();
+ maPassword2Text.Disable();
+ maPassword2Edit.Disable();
+ maBtnMatchOldPass.Disable();
+ maBtnOk.Enable();
+ }
+
+ return 0;
+}
+
+IMPL_LINK( ScRetypePassInputDlg, CheckBoxHdl, CheckBox*, EMPTYARG )
+{
+ CheckPasswordInput();
+ return 0;
+}
+
+IMPL_LINK( ScRetypePassInputDlg, PasswordModifyHdl, Edit*, EMPTYARG )
+{
+ CheckPasswordInput();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/retypepassdlg.src b/sc/source/ui/miscdlgs/retypepassdlg.src
new file mode 100644
index 000000000000..20cb3976a328
--- /dev/null
+++ b/sc/source/ui/miscdlgs/retypepassdlg.src
@@ -0,0 +1,313 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "retypepassdlg.hrc"
+
+
+ModalDialog RID_SCDLG_RETYPEPASS
+{
+ Text [ en-US ] = "Re-type Password" ;
+ Size = MAP_APPFONT ( 260 , 165 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 204, 6 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ DefButton = TRUE ;
+ };
+
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 204, 23 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 204, 43 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ FixedText FT_DESC
+ {
+ Pos = MAP_APPFONT ( 6, 6 ) ;
+ Size = MAP_APPFONT ( 190, 36 );
+
+ WordBreak = TRUE ;
+
+ Text [ en-US ] = "The document you are about to export has one or more protected items with password that cannot be exported. Please re-type your password to be able to export your document." ;
+ };
+
+ FixedLine FL_DOCUMENT
+ {
+ Pos = MAP_APPFONT ( 6, 48 );
+ Size = MAP_APPFONT ( 190, 8 );
+
+ Text [ en-US ] = "Document protection" ;
+ };
+
+ FixedText FT_DOCSTATUS
+ {
+ Pos = MAP_APPFONT ( 10, 62 );
+ Size = MAP_APPFONT ( 140, 8 );
+
+ Text [ en-US ] = "Status unknown" ;
+ };
+
+ PushButton BTN_RETYPE_DOC
+ {
+ Pos = MAP_APPFONT ( 158, 59 );
+ Size = MAP_APPFONT ( 30, 14 );
+
+ Text [ en-US ] = "Re-type" ;
+ };
+
+ FixedLine FL_SHEET
+ {
+ Pos = MAP_APPFONT ( 6, 83 );
+ Size = MAP_APPFONT ( 190, 8 );
+
+ Text [ en-US ] = "Sheet protection" ;
+ };
+
+ FixedText FT_SHEETNAME1
+ {
+ Pos = MAP_APPFONT ( 10, 97 );
+ Size = MAP_APPFONT ( 68, 8 );
+
+ Text [ en-US ] = "Sheet1 has a really long name" ;
+ };
+
+ FixedText FT_SHEETSTATUS1
+ {
+ Pos = MAP_APPFONT ( 82, 97 );
+ Size = MAP_APPFONT ( 72, 8 );
+
+ Text [ en-US ] = "Status unknown" ;
+ };
+
+ PushButton BTN_RETYPE_SHEET1
+ {
+ Pos = MAP_APPFONT ( 158, 94 );
+ Size = MAP_APPFONT ( 30, 14 );
+
+ Text [ en-US ] = "Re-type" ;
+ };
+
+ FixedText FT_SHEETNAME2
+ {
+ Pos = MAP_APPFONT ( 10, 113 );
+ Size = MAP_APPFONT ( 68, 8 );
+
+ Text [ en-US ] = "Sheet2" ;
+ };
+
+ FixedText FT_SHEETSTATUS2
+ {
+ Pos = MAP_APPFONT ( 82, 113 );
+ Size = MAP_APPFONT ( 72, 8 );
+
+ Text [ en-US ] = "Status unknown" ;
+ };
+
+ PushButton BTN_RETYPE_SHEET2
+ {
+ Pos = MAP_APPFONT ( 158, 110 );
+ Size = MAP_APPFONT ( 30, 14 );
+
+ Text [ en-US ] = "Re-type" ;
+ };
+
+ FixedText FT_SHEETNAME3
+ {
+ Pos = MAP_APPFONT ( 10, 129 );
+ Size = MAP_APPFONT ( 68, 8 );
+
+ Text [ en-US ] = "Sheet3" ;
+ };
+
+ FixedText FT_SHEETSTATUS3
+ {
+ Pos = MAP_APPFONT ( 82, 129 );
+ Size = MAP_APPFONT ( 72, 8 );
+
+ Text [ en-US ] = "Status unknown" ;
+ };
+
+ PushButton BTN_RETYPE_SHEET3
+ {
+ Pos = MAP_APPFONT ( 158, 126 );
+ Size = MAP_APPFONT ( 30, 14 );
+
+ Text [ en-US ] = "Re-type" ;
+ };
+
+ FixedText FT_SHEETNAME4
+ {
+ Pos = MAP_APPFONT ( 10, 145 );
+ Size = MAP_APPFONT ( 68, 8 );
+
+ Text [ en-US ] = "Sheet4" ;
+ };
+
+ FixedText FT_SHEETSTATUS4
+ {
+ Pos = MAP_APPFONT ( 82, 145 );
+ Size = MAP_APPFONT ( 72, 8 );
+
+ Text [ en-US ] = "Status unknown" ;
+ };
+
+ PushButton BTN_RETYPE_SHEET4
+ {
+ Pos = MAP_APPFONT ( 158, 142 );
+ Size = MAP_APPFONT ( 30, 14 );
+
+ Text [ en-US ] = "Re-type" ;
+ };
+
+ ScrollBar SB_SCROLL
+ {
+ Pos = MAP_APPFONT ( 190, 94 ) ;
+ Size = MAP_APPFONT ( 8, 61 ) ;
+ VScroll = TRUE ;
+ };
+
+ String STR_NOT_PROTECTED
+ {
+ Text [ en-US ] = "Not protected" ;
+ };
+
+ String STR_NOT_PASS_PROTECTED
+ {
+ Text [ en-US ] = "Not password-protected" ;
+ };
+
+ String STR_HASH_BAD
+ {
+ Text [ en-US ] = "Hash incompatible" ;
+ };
+
+ String STR_HASH_GOOD
+ {
+ Text [ en-US ] = "Hash compatible" ;
+ };
+
+ String STR_HASH_REGENERATED
+ {
+ Text [ en-US ] = "Hash re-generated" ;
+ };
+};
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_RETYPEPASS_INPUT
+{
+ Text [ en-US ] = "Re-type Password" ;
+ Size = MAP_APPFONT ( 230 , 110 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 174, 6 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ DefButton = TRUE ;
+ };
+
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 174, 23 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 174, 43 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ RadioButton BTN_RETYPE_PASSWORD
+ {
+ Pos = MAP_APPFONT ( 11, 10 );
+ Size = MAP_APPFONT ( 150, 10 );
+
+ Text [ en-US ] = "Re-type password" ;
+ };
+
+ FixedText FT_PASSWORD1
+ {
+ Pos = MAP_APPFONT ( 20, 30 );
+ Size = MAP_APPFONT ( 42, 10 );
+
+ Text [ en-US ] = "~Password" ;
+ };
+
+ Edit ED_PASSWORD1
+ {
+ Border = TRUE;
+ PassWord = TRUE;
+ Pos = MAP_APPFONT ( 65, 29 );
+ Size = MAP_APPFONT ( 75, 12 );
+ };
+
+ FixedText FT_PASSWORD2
+ {
+ Pos = MAP_APPFONT ( 20, 45 );
+ Size = MAP_APPFONT ( 42, 10 );
+
+ Text [ en-US ] = "~Confirm" ;
+ };
+
+ Edit ED_PASSWORD2
+ {
+ Border = TRUE;
+ PassWord = TRUE;
+ Pos = MAP_APPFONT ( 65, 44 );
+ Size = MAP_APPFONT ( 75, 12 );
+ };
+
+ CheckBox BTN_MATCH_OLD_PASSWORD
+ {
+ Pos = MAP_APPFONT ( 20, 65 );
+ Size = MAP_APPFONT ( 150, 10 );
+
+ Text [ en-US ] = "New password must match the original password." ;
+ };
+
+ RadioButton BTN_REMOVE_PASSWORD
+ {
+ Pos = MAP_APPFONT ( 11, 90 );
+ Size = MAP_APPFONT ( 150, 10 );
+
+ Text [ en-US ] = "Remove password from this protected item." ;
+ };
+};
+
+
diff --git a/sc/source/ui/miscdlgs/scuiautofmt.cxx b/sc/source/ui/miscdlgs/scuiautofmt.cxx
new file mode 100644
index 000000000000..25e97a456af2
--- /dev/null
+++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx
@@ -0,0 +1,479 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svx/algitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <svl/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include "sc.hrc"
+#include "scmod.hxx"
+#include "attrib.hxx"
+#include "zforauto.hxx"
+#include "scitems.hxx"
+#include "global.hxx"
+#include "globstr.hrc"
+#include "autoform.hxx"
+#include "strindlg.hxx"
+#include "miscdlgs.hrc"
+#include "scuiautofmt.hxx"
+#include "scresid.hxx"
+#include "document.hxx"
+
+//========================================================================
+// AutoFormat-Dialog:
+
+ScAutoFormatDlg::ScAutoFormatDlg( Window* pParent,
+ ScAutoFormat* pAutoFormat,
+ const ScAutoFormatData* pSelFormatData,
+ ScDocument* pDoc ) :
+
+ ModalDialog ( pParent, ScResId( RID_SCDLG_AUTOFORMAT ) ),
+ //
+ aFlFormat ( this, ScResId( FL_FORMAT ) ),
+ aLbFormat ( this, ScResId( LB_FORMAT ) ),
+ pWndPreview ( new ScAutoFmtPreview( this, ScResId( WND_PREVIEW ), pDoc ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+ aFlFormatting ( this, ScResId( FL_FORMATTING ) ),
+ aBtnNumFormat ( this, ScResId( BTN_NUMFORMAT ) ),
+ aBtnBorder ( this, ScResId( BTN_BORDER ) ),
+ aBtnFont ( this, ScResId( BTN_FONT ) ),
+ aBtnPattern ( this, ScResId( BTN_PATTERN ) ),
+ aBtnAlignment ( this, ScResId( BTN_ALIGNMENT ) ),
+ aBtnAdjust ( this, ScResId( BTN_ADJUST ) ),
+ aBtnRename ( this, ScResId( BTN_RENAME ) ),
+ aStrTitle ( ScResId( STR_ADD_TITLE ) ),
+ aStrLabel ( ScResId( STR_ADD_LABEL ) ),
+ aStrClose ( ScResId( STR_BTN_CLOSE ) ),
+ aStrDelTitle ( ScResId( STR_DEL_TITLE ) ),
+ aStrDelMsg ( ScResId( STR_DEL_MSG ) ) ,
+ aStrRename ( ScResId( STR_RENAME_TITLE ) ),
+ //
+ pFormat ( pAutoFormat ),
+ pSelFmtData ( pSelFormatData ),
+ nIndex ( 0 ),
+ bCoreDataChanged( FALSE ),
+ bFmtInserted ( FALSE )
+{
+ Init();
+ pWndPreview->NotifyChange( (*pFormat)[0] );
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScAutoFormatDlg::~ScAutoFormatDlg()
+{
+ delete pWndPreview;
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFormatDlg::Init()
+{
+ USHORT nCount;
+ String aEntry;
+
+ aLbFormat .SetSelectHdl( LINK( this, ScAutoFormatDlg, SelFmtHdl ) );
+ aBtnNumFormat.SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+ aBtnBorder .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+ aBtnFont .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+ aBtnPattern .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+ aBtnAlignment.SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+ aBtnAdjust .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+ aBtnAdd .SetClickHdl ( LINK( this, ScAutoFormatDlg, AddHdl ) );
+ aBtnRemove .SetClickHdl ( LINK( this, ScAutoFormatDlg, RemoveHdl ) );
+ aBtnOk .SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) );
+ aBtnCancel .SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) );
+ aBtnRename .SetClickHdl ( LINK( this, ScAutoFormatDlg, RenameHdl ) );
+ aLbFormat .SetDoubleClickHdl( LINK( this, ScAutoFormatDlg, DblClkHdl ) );
+
+ aBtnMore.AddWindow( &aBtnRename );
+ aBtnMore.AddWindow( &aBtnNumFormat );
+ aBtnMore.AddWindow( &aBtnBorder );
+ aBtnMore.AddWindow( &aBtnFont );
+ aBtnMore.AddWindow( &aBtnPattern );
+ aBtnMore.AddWindow( &aBtnAlignment );
+ aBtnMore.AddWindow( &aBtnAdjust );
+ aBtnMore.AddWindow( &aFlFormatting );
+
+ nCount = pFormat->GetCount();
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ ((*pFormat)[i])->GetName( aEntry );
+ aLbFormat.InsertEntry( aEntry );
+ }
+
+ if ( nCount == 1 )
+ aBtnRemove.Disable();
+
+ aLbFormat.SelectEntryPos( 0 );
+ aBtnRename.Disable();
+ aBtnRemove.Disable();
+
+ nIndex = 0;
+ UpdateChecks();
+
+ if ( !pSelFmtData )
+ {
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ bFmtInserted = TRUE;
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFormatDlg::UpdateChecks()
+{
+ ScAutoFormatData* pData = (*pFormat)[nIndex];
+
+ aBtnNumFormat.Check( pData->GetIncludeValueFormat() );
+ aBtnBorder .Check( pData->GetIncludeFrame() );
+ aBtnFont .Check( pData->GetIncludeFont() );
+ aBtnPattern .Check( pData->GetIncludeBackground() );
+ aBtnAlignment.Check( pData->GetIncludeJustify() );
+ aBtnAdjust .Check( pData->GetIncludeWidthHeight() );
+}
+
+//------------------------------------------------------------------------
+// Handler:
+//---------
+
+IMPL_LINK( ScAutoFormatDlg, CloseHdl, PushButton *, pBtn )
+{
+ if ( pBtn == &aBtnOk || pBtn == &aBtnCancel )
+ {
+ if ( bCoreDataChanged )
+ ScGlobal::GetAutoFormat()->Save();
+
+ EndDialog( (pBtn == &aBtnOk) ? RET_OK : RET_CANCEL );
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScAutoFormatDlg, DblClkHdl, void *, EMPTYARG )
+{
+ if ( bCoreDataChanged )
+ ScGlobal::GetAutoFormat()->Save();
+
+ EndDialog( RET_OK );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScAutoFormatDlg, DblClkHdl, void *, EMPTYARG )
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScAutoFormatDlg, CheckHdl, Button *, pBtn )
+{
+ ScAutoFormatData* pData = (*pFormat)[nIndex];
+ BOOL bCheck = ((CheckBox*)pBtn)->IsChecked();
+
+ if ( pBtn == &aBtnNumFormat )
+ pData->SetIncludeValueFormat( bCheck );
+ else if ( pBtn == &aBtnBorder )
+ pData->SetIncludeFrame( bCheck );
+ else if ( pBtn == &aBtnFont )
+ pData->SetIncludeFont( bCheck );
+ else if ( pBtn == &aBtnPattern )
+ pData->SetIncludeBackground( bCheck );
+ else if ( pBtn == &aBtnAlignment )
+ pData->SetIncludeJustify( bCheck );
+ else if ( pBtn == &aBtnAdjust )
+ pData->SetIncludeWidthHeight( bCheck );
+
+ if ( !bCoreDataChanged )
+ {
+ aBtnCancel.SetText( aStrClose );
+ bCoreDataChanged = TRUE;
+ }
+
+ pWndPreview->NotifyChange( pData );
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScAutoFormatDlg, AddHdl, void *, EMPTYARG )
+{
+ if ( !bFmtInserted && pSelFmtData )
+ {
+ String aStrStandard( ScResId(STR_STANDARD) );
+ String aFormatName;
+ ScStringInputDlg* pDlg;
+ BOOL bOk = FALSE;
+
+ while ( !bOk )
+ {
+ pDlg = new ScStringInputDlg( this,
+ aStrTitle,
+ aStrLabel,
+ aFormatName,
+ HID_SC_ADD_AUTOFMT );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ pDlg->GetInputString( aFormatName );
+
+ if ( (aFormatName.Len() > 0) && (aFormatName != aStrStandard) )
+ {
+ ScAutoFormatData* pNewData
+ = new ScAutoFormatData( *pSelFmtData );
+
+ pNewData->SetName( aFormatName );
+ bFmtInserted = pFormat->Insert( pNewData );
+
+ if ( bFmtInserted )
+ {
+ USHORT nAt = pFormat->IndexOf( pNewData );
+
+ aLbFormat.InsertEntry( aFormatName, nAt );
+ aLbFormat.SelectEntry( aFormatName );
+ aBtnAdd.Disable();
+
+ if ( !bCoreDataChanged )
+ {
+ aBtnCancel.SetText( aStrClose );
+ bCoreDataChanged = TRUE;
+ }
+
+ SelFmtHdl( 0 );
+ bOk = TRUE;
+ }
+ else
+ delete pNewData;
+
+ }
+
+ if ( !bFmtInserted )
+ {
+ USHORT nRet = ErrorBox( this,
+ WinBits( WB_OK_CANCEL | WB_DEF_OK),
+ ScGlobal::GetRscString(STR_INVALID_AFNAME)
+ ).Execute();
+
+ bOk = ( nRet == RET_CANCEL );
+ }
+ }
+ else
+ bOk = TRUE;
+
+ delete pDlg;
+ }
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScAutoFormatDlg, RemoveHdl, void *, EMPTYARG )
+{
+ if ( (nIndex > 0) && (aLbFormat.GetEntryCount() > 0) )
+ {
+ String aMsg( aStrDelMsg.GetToken( 0, '#' ) );
+
+ aMsg += aLbFormat.GetSelectEntry();
+ aMsg += aStrDelMsg.GetToken( 1, '#' );
+
+ if ( RET_YES ==
+ QueryBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), aMsg ).Execute() )
+ {
+ aLbFormat.RemoveEntry( nIndex );
+ aLbFormat.SelectEntryPos( nIndex-1 );
+
+ if ( nIndex-1 == 0 )
+ aBtnRemove.Disable();
+
+ if ( !bCoreDataChanged )
+ {
+ aBtnCancel.SetText( aStrClose );
+ bCoreDataChanged = TRUE;
+ }
+
+ pFormat->AtFree( nIndex ); // in der Core loeschen
+ nIndex--;
+
+ SelFmtHdl( 0 );
+ }
+ }
+
+ SelFmtHdl( 0 );
+
+ return 0;
+}
+
+IMPL_LINK( ScAutoFormatDlg, RenameHdl, void *, EMPTYARG )
+{
+ BOOL bOk = FALSE;
+ while( !bOk )
+ {
+
+ String aFormatName=aLbFormat.GetSelectEntry();
+ String aEntry;
+
+ ScStringInputDlg* pDlg = new ScStringInputDlg( this,
+ aStrRename,
+ aStrLabel,
+ aFormatName,
+ HID_SC_REN_AFMT_DLG );
+ if( pDlg->Execute() == RET_OK )
+ {
+ BOOL bFmtRenamed = FALSE;
+ pDlg->GetInputString( aFormatName );
+ USHORT n;
+
+ if ( aFormatName.Len() > 0 )
+ {
+ for( n = 0; n < pFormat->GetCount(); ++n )
+ {
+ (*pFormat)[n]->GetName(aEntry);
+ if ( aEntry== aFormatName)
+ break;
+ }
+ if( n >= pFormat->GetCount() )
+ {
+ // Format mit dem Namen noch nicht vorhanden, also
+ // umbenennen
+
+ aLbFormat.RemoveEntry(nIndex );
+ ScAutoFormatData* p=(*pFormat)[ nIndex ];
+ ScAutoFormatData* pNewData
+ = new ScAutoFormatData(*p);
+
+ pFormat->AtFree( nIndex );
+
+ pNewData->SetName( aFormatName );
+
+ pFormat->Insert( pNewData);
+
+ USHORT nCount = pFormat->GetCount();
+
+ aLbFormat.SetUpdateMode(FALSE);
+ aLbFormat.Clear();
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ ((*pFormat)[i])->GetName( aEntry );
+ aLbFormat.InsertEntry( aEntry );
+ }
+
+ aLbFormat.SetUpdateMode( TRUE);
+ aLbFormat.SelectEntry( aFormatName);
+
+ if ( !bCoreDataChanged )
+ {
+ aBtnCancel.SetText( aStrClose );
+ bCoreDataChanged = TRUE;
+ }
+
+
+ SelFmtHdl( 0 );
+ bOk = TRUE;
+ bFmtRenamed = TRUE;
+ }
+ }
+ if( !bFmtRenamed )
+ {
+ bOk = RET_CANCEL == ErrorBox( this,
+ WinBits( WB_OK_CANCEL | WB_DEF_OK),
+ ScGlobal::GetRscString(STR_INVALID_AFNAME)
+ ).Execute();
+ }
+ }
+ else
+ bOk = TRUE;
+ delete pDlg;
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScAutoFormatDlg, SelFmtHdl, void *, EMPTYARG )
+{
+ nIndex = aLbFormat.GetSelectEntryPos();
+ UpdateChecks();
+
+ if ( nIndex == 0 )
+ {
+ aBtnRename.Disable();
+ aBtnRemove.Disable();
+ }
+ else
+ {
+ aBtnRename.Enable();
+ aBtnRemove.Enable();
+ }
+
+ pWndPreview->NotifyChange( (*pFormat)[nIndex] );
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+String __EXPORT ScAutoFormatDlg::GetCurrFormatName()
+{
+ String aResult;
+
+ ((*pFormat)[nIndex])->GetName( aResult );
+
+ return aResult;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/sharedocdlg.cxx b/sc/source/ui/miscdlgs/sharedocdlg.cxx
new file mode 100644
index 000000000000..7cf5ee1b840f
--- /dev/null
+++ b/sc/source/ui/miscdlgs/sharedocdlg.cxx
@@ -0,0 +1,238 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//-----------------------------------------------------------------------------
+
+#include <osl/security.hxx>
+#include <svl/sharecontrolfile.hxx>
+#include <unotools/useroptions.hxx>
+
+#include <docsh.hxx>
+
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/document/XDocumentProperties.hpp>
+
+
+#include "sharedocdlg.hxx"
+#include "sharedocdlg.hrc"
+#include "scresid.hxx"
+#include "docsh.hxx"
+#include "viewdata.hxx"
+
+
+using namespace ::com::sun::star;
+
+
+//=============================================================================
+// class ScShareDocumentDlg
+//=============================================================================
+
+ScShareDocumentDlg::ScShareDocumentDlg( Window* pParent, ScViewData* pViewData )
+ :ModalDialog( pParent, ScResId( RID_SCDLG_SHAREDOCUMENT ) )
+ ,maCbShare ( this, ScResId( CB_SHARE ) )
+ ,maFtWarning ( this, ScResId( FT_WARNING ) )
+ ,maFlUsers ( this, ScResId( FL_USERS ) )
+ ,maFtUsers ( this, ScResId( FT_USERS ) )
+ ,maLbUsers ( this, ScResId( LB_USERS ) )
+ ,maFlEnd ( this, ScResId( FL_END ) )
+ ,maBtnHelp ( this, ScResId( BTN_HELP ) )
+ ,maBtnOK ( this, ScResId( BTN_OK ) )
+ ,maBtnCancel ( this, ScResId( BTN_CANCEL ) )
+ ,maStrTitleName ( ScResId( STR_TITLE_NAME ) )
+ ,maStrTitleAccessed ( ScResId( STR_TITLE_ACCESSED ) )
+ ,maStrNoUserData ( ScResId( STR_NO_USER_DATA ) )
+ ,maStrUnkownUser ( ScResId( STR_UNKNOWN_USER ) )
+ ,maStrExclusiveAccess ( ScResId( STR_EXCLUSIVE_ACCESS ) )
+ ,mpViewData ( pViewData )
+ ,mpDocShell ( NULL )
+{
+ DBG_ASSERT( mpViewData, "ScShareDocumentDlg CTOR: mpViewData is null!" );
+ mpDocShell = ( mpViewData ? mpViewData->GetDocShell() : NULL );
+ DBG_ASSERT( mpDocShell, "ScShareDocumentDlg CTOR: mpDocShell is null!" );
+
+ FreeResource();
+
+ bool bIsDocShared = ( mpDocShell ? mpDocShell->IsDocShared() : false );
+ maCbShare.Check( bIsDocShared );
+ maCbShare.SetToggleHdl( LINK( this, ScShareDocumentDlg, ToggleHandle ) );
+ maFtWarning.Enable( bIsDocShared );
+
+ long nTabs[] = { 2, 10, 128 };
+ maLbUsers.SetTabs( nTabs );
+
+ String aHeader( maStrTitleName );
+ aHeader += '\t';
+ aHeader += maStrTitleAccessed;
+ maLbUsers.InsertHeaderEntry( aHeader, HEADERBAR_APPEND, HIB_LEFT | HIB_LEFTIMAGE | HIB_VCENTER );
+ maLbUsers.SetSelectionMode( NO_SELECTION );
+
+ UpdateView();
+}
+
+ScShareDocumentDlg::~ScShareDocumentDlg()
+{
+}
+
+IMPL_LINK( ScShareDocumentDlg, ToggleHandle, void*, EMPTYARG )
+{
+ maFtWarning.Enable( maCbShare.IsChecked() );
+
+ return 0;
+}
+
+bool ScShareDocumentDlg::IsShareDocumentChecked() const
+{
+ return maCbShare.IsChecked();
+}
+
+void ScShareDocumentDlg::UpdateView()
+{
+ if ( !mpDocShell )
+ {
+ return;
+ }
+
+ if ( mpDocShell->IsDocShared() )
+ {
+ try
+ {
+ ::svt::ShareControlFile aControlFile( mpDocShell->GetSharedFileURL() );
+ uno::Sequence< uno::Sequence< ::rtl::OUString > > aUsersData = aControlFile.GetUsersData();
+ const uno::Sequence< ::rtl::OUString >* pUsersData = aUsersData.getConstArray();
+ sal_Int32 nLength = aUsersData.getLength();
+
+ if ( nLength > 0 )
+ {
+ sal_Int32 nUnknownUser = 1;
+
+ for ( sal_Int32 i = 0; i < nLength; ++i )
+ {
+ if ( pUsersData[i].getLength() > SHARED_EDITTIME_ID )
+ {
+ String aUser;
+ if ( pUsersData[i][SHARED_OOOUSERNAME_ID].getLength() )
+ {
+ aUser = pUsersData[i][SHARED_OOOUSERNAME_ID];
+ }
+ else if ( pUsersData[i][SHARED_SYSUSERNAME_ID].getLength() )
+ {
+ aUser = pUsersData[i][SHARED_SYSUSERNAME_ID];
+ }
+ else
+ {
+ aUser = maStrUnkownUser;
+ aUser += ' ';
+ aUser += String::CreateFromInt32( nUnknownUser++ );
+ }
+
+ // parse the edit time string of the format "DD.MM.YYYY hh:mm"
+ ::rtl::OUString aDateTimeStr = pUsersData[i][SHARED_EDITTIME_ID];
+ sal_Int32 nIndex = 0;
+ ::rtl::OUString aDateStr = aDateTimeStr.getToken( 0, ' ', nIndex );
+ ::rtl::OUString aTimeStr = aDateTimeStr.getToken( 0, ' ', nIndex );
+ nIndex = 0;
+ USHORT nDay = sal::static_int_cast< USHORT >( aDateStr.getToken( 0, '.', nIndex ).toInt32() );
+ USHORT nMonth = sal::static_int_cast< USHORT >( aDateStr.getToken( 0, '.', nIndex ).toInt32() );
+ USHORT nYear = sal::static_int_cast< USHORT >( aDateStr.getToken( 0, '.', nIndex ).toInt32() );
+ nIndex = 0;
+ USHORT nHours = sal::static_int_cast< USHORT >( aTimeStr.getToken( 0, ':', nIndex ).toInt32() );
+ USHORT nMinutes = sal::static_int_cast< USHORT >( aTimeStr.getToken( 0, ':', nIndex ).toInt32() );
+ Date aDate( nDay, nMonth, nYear );
+ Time aTime( nHours, nMinutes );
+ DateTime aDateTime( aDate, aTime );
+
+ String aString( aUser );
+ aString += '\t';
+ aString += ScGlobal::pLocaleData->getDate( aDateTime );
+ aString += ' ';
+ aString += ScGlobal::pLocaleData->getTime( aDateTime, FALSE );
+
+ maLbUsers.InsertEntry( aString, NULL );
+ }
+ }
+ }
+ else
+ {
+ maLbUsers.InsertEntry( maStrNoUserData, NULL );
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ DBG_ERROR( "ScShareDocumentDlg::UpdateView(): caught exception\n" );
+ maLbUsers.Clear();
+ maLbUsers.InsertEntry( maStrNoUserData, NULL );
+ }
+ }
+ else
+ {
+ // get OOO user name
+ SvtUserOptions aUserOpt;
+ String aUser = aUserOpt.GetFirstName();
+ if ( aUser.Len() > 0 )
+ {
+ aUser += ' ';
+ }
+ aUser += String(aUserOpt.GetLastName());
+ if ( aUser.Len() == 0 )
+ {
+ // get sys user name
+ ::rtl::OUString aUserName;
+ ::osl::Security aSecurity;
+ aSecurity.getUserName( aUserName );
+ aUser = aUserName;
+ }
+ if ( aUser.Len() == 0 )
+ {
+ // unknown user name
+ aUser = maStrUnkownUser;
+ }
+ aUser += ' ';
+ aUser += maStrExclusiveAccess;
+ String aString( aUser );
+ aString += '\t';
+
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(mpDocShell->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
+
+ util::DateTime uDT(xDocProps->getModificationDate());
+ Date d(uDT.Day, uDT.Month, uDT.Year);
+ Time t(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
+ DateTime aDateTime(d,t);
+
+ aString += ScGlobal::pLocaleData->getDate( aDateTime );
+ aString += ' ';
+ aString += ScGlobal::pLocaleData->getTime( aDateTime, FALSE );
+
+ maLbUsers.InsertEntry( aString, NULL );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/sharedocdlg.src b/sc/source/ui/miscdlgs/sharedocdlg.src
new file mode 100644
index 000000000000..13361b216ea5
--- /dev/null
+++ b/sc/source/ui/miscdlgs/sharedocdlg.src
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sharedocdlg.hrc"
+
+ModalDialog RID_SCDLG_SHAREDOCUMENT
+{
+ OutputSize = TRUE ;
+ HelpId = SID_SHARE_DOC ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 204 , 186 ) ;
+ Text [ en-US ] = "Share Document" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ CheckBox CB_SHARE
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 192 , 8 ) ;
+ Text [ en-US ] = "Share this spreadsheet with other users" ;
+ };
+ FixedText FT_WARNING
+ {
+ Pos = MAP_APPFONT ( 15 , 18 ) ;
+ Size = MAP_APPFONT ( 183 , 48 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "Note: Changes to formatting attributes like fonts, colors, and number formats will not be saved and some functionalities like editing charts and drawing objects are not available in shared mode. Turn off shared mode to get exclusive access needed for those changes and functionalities." ;
+ };
+ FixedLine FL_USERS
+ {
+ Pos = MAP_APPFONT ( 6 , 66 ) ;
+ Size = MAP_APPFONT ( 192 , 4 ) ;
+ };
+ FixedText FT_USERS
+ {
+ Pos = MAP_APPFONT ( 6 , 72 ) ;
+ Size = MAP_APPFONT ( 192 , 8 ) ;
+ Text [ en-US ] = "Users currently accessing this spreadsheet" ;
+ };
+ Control LB_USERS
+ {
+ Pos = MAP_APPFONT ( 6 , 82 ) ;
+ Size = MAP_APPFONT ( 192 , 72 ) ;
+ Border = TRUE ;
+ };
+ FixedLine FL_END
+ {
+ Pos = MAP_APPFONT ( 1 , 156 ) ;
+ Size = MAP_APPFONT ( 204 , 8 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 6 , 166 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 92 , 166 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 148 , 166 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String STR_TITLE_NAME
+ {
+ Text [ en-US ] = "Name" ;
+ };
+ String STR_TITLE_ACCESSED
+ {
+ Text [ en-US ] = "Accessed" ;
+ };
+ String STR_NO_USER_DATA
+ {
+ Text [ en-US ] = "No user data available." ;
+ };
+ String STR_UNKNOWN_USER
+ {
+ Text [ en-US ] = "Unknown User" ;
+ };
+ String STR_EXCLUSIVE_ACCESS
+ {
+ Text [ en-US ] = "(exclusive access)" ;
+ };
+};
diff --git a/sc/source/ui/miscdlgs/shtabdlg.cxx b/sc/source/ui/miscdlgs/shtabdlg.cxx
new file mode 100644
index 000000000000..230920bf71a9
--- /dev/null
+++ b/sc/source/ui/miscdlgs/shtabdlg.cxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+
+#include "shtabdlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+ScShowTabDlg::ScShowTabDlg( Window* pParent ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_SHOW_TAB ) ),
+ aLb ( this, ScResId( LB_ENTRYLIST ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aFtLbTitle ( this, ScResId( FT_LABEL ) )
+{
+ aLb.Clear();
+ aLb.SetDoubleClickHdl( LINK( this, ScShowTabDlg, DblClkHdl ) );
+
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+void ScShowTabDlg::SetDescription(
+ const String& rTitle, const String& rFixedText,
+ ULONG nDlgHelpId, ULONG nLbHelpId )
+{
+ SetText( rTitle );
+ aFtLbTitle.SetText( rFixedText );
+ SetHelpId( nDlgHelpId );
+ aLb.SetHelpId( nLbHelpId );
+}
+
+void ScShowTabDlg::Insert( const String& rString, BOOL bSelected )
+{
+ aLb.InsertEntry( rString );
+ if( bSelected )
+ aLb.SelectEntryPos( aLb.GetEntryCount() - 1 );
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScShowTabDlg::GetSelectEntryCount() const
+{
+ return aLb.GetSelectEntryCount();
+}
+
+String ScShowTabDlg::GetSelectEntry(USHORT nPos) const
+{
+ return aLb.GetSelectEntry(nPos);
+}
+
+USHORT ScShowTabDlg::GetSelectEntryPos(USHORT nPos) const
+{
+ return aLb.GetSelectEntryPos(nPos);
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScShowTabDlg, DblClkHdl, void *, EMPTYARG )
+{
+ EndDialog( RET_OK );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScShowTabDlg, DblClkHdl, void *, EMPTYARG )
+
+__EXPORT ScShowTabDlg::~ScShowTabDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/simpref.cxx b/sc/source/ui/miscdlgs/simpref.cxx
new file mode 100644
index 000000000000..2a8186f05866
--- /dev/null
+++ b/sc/source/ui/miscdlgs/simpref.cxx
@@ -0,0 +1,259 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+#include <sfx2/app.hxx>
+
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "simpref.hrc"
+#include "rangenam.hxx" // IsNameValid
+#include "simpref.hxx"
+#include "scmod.hxx"
+
+//============================================================================
+
+#define ABS_SREF SCA_VALID \
+ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+#define ABS_DREF ABS_SREF \
+ | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
+#define ABS_SREF3D ABS_SREF | SCA_TAB_3D
+#define ABS_DREF3D ABS_DREF | SCA_TAB_3D
+
+//----------------------------------------------------------------------------
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
+#define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()
+
+//============================================================================
+// class ScSimpleRefDlg
+
+//----------------------------------------------------------------------------
+ScSimpleRefDlg::ScSimpleRefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_SIMPLEREF ),
+ //
+ aFtAssign ( this, ScResId( FT_ASSIGN ) ),
+ aEdAssign ( this, this, ScResId( ED_ASSIGN ) ),
+ aRbAssign ( this, ScResId( RB_ASSIGN ), &aEdAssign, this ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+
+ //
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+ bRefInputMode ( FALSE ),
+ bAutoReOpen ( TRUE ),
+ bCloseOnButtonUp( FALSE ),
+ bSingleCell ( FALSE ),
+ bMultiSelection ( FALSE )
+{
+ // damit die Strings in der Resource bei den FixedTexten bleiben koennen:
+ Init();
+ FreeResource();
+ SetDispatcherLock( TRUE ); // Modal-Modus einschalten
+}
+
+//----------------------------------------------------------------------------
+__EXPORT ScSimpleRefDlg::~ScSimpleRefDlg()
+{
+ SetDispatcherLock( FALSE ); // Modal-Modus einschalten
+}
+
+//----------------------------------------------------------------------------
+void ScSimpleRefDlg::FillInfo(SfxChildWinInfo& rWinInfo) const
+{
+ ScAnyRefDlg::FillInfo(rWinInfo);
+ rWinInfo.bVisible=bAutoReOpen;
+}
+
+//----------------------------------------------------------------------------
+void ScSimpleRefDlg::SetRefString(const String &rStr)
+{
+ aEdAssign.SetText(rStr);
+}
+
+//----------------------------------------------------------------------------
+void ScSimpleRefDlg::Init()
+{
+ aBtnOk.SetClickHdl ( LINK( this, ScSimpleRefDlg, OkBtnHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScSimpleRefDlg, CancelBtnHdl ) );
+ bCloseFlag=FALSE;
+}
+
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Fenster angezeigt wird.
+void ScSimpleRefDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( aEdAssign.IsEnabled() )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( &aEdAssign );
+
+ theCurArea = rRef;
+ String aRefStr;
+ if ( bSingleCell )
+ {
+ ScAddress aAdr = rRef.aStart;
+ aAdr.Format( aRefStr, SCA_ABS_3D, pDocP, pDocP->GetAddressConvention() );
+ }
+ else
+ theCurArea.Format( aRefStr, ABS_DREF3D, pDocP, pDocP->GetAddressConvention() );
+
+ if ( bMultiSelection )
+ {
+ String aVal = aEdAssign.GetText();
+ Selection aSel = aEdAssign.GetSelection();
+ aSel.Justify();
+ aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
+ aVal.Insert( aRefStr, (xub_StrLen)aSel.Min() );
+ Selection aNewSel( aSel.Min(), aSel.Min()+aRefStr.Len() );
+ aEdAssign.SetRefString( aVal );
+ aEdAssign.SetSelection( aNewSel );
+ }
+ else
+ aEdAssign.SetRefString( aRefStr );
+
+ aChangeHdl.Call( &aRefStr );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+BOOL __EXPORT ScSimpleRefDlg::Close()
+{
+ CancelBtnHdl(&aBtnCancel);
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+void ScSimpleRefDlg::SetActive()
+{
+ aEdAssign.GrabFocus();
+
+ // kein NameModifyHdl, weil sonst Bereiche nicht geaendert werden koennen
+ // (nach dem Aufziehen der Referenz wuerde der alte Inhalt wieder angezeigt)
+ // (der ausgewaehlte DB-Name hat sich auch nicht veraendert)
+
+ RefInputDone();
+}
+//------------------------------------------------------------------------
+BOOL ScSimpleRefDlg::IsRefInputMode() const
+{
+ return TRUE;
+}
+
+String ScSimpleRefDlg::GetRefString() const
+{
+ return aEdAssign.GetText();
+}
+
+void ScSimpleRefDlg::SetCloseHdl( const Link& rLink )
+{
+ aCloseHdl=rLink;
+}
+
+void ScSimpleRefDlg::SetUnoLinks( const Link& rDone, const Link& rAbort,
+ const Link& rChange )
+{
+ aDoneHdl = rDone;
+ aAbortedHdl = rAbort;
+ aChangeHdl = rChange;
+}
+
+void ScSimpleRefDlg::SetFlags( BOOL bSetCloseOnButtonUp, BOOL bSetSingleCell, BOOL bSetMultiSelection )
+{
+ bCloseOnButtonUp = bSetCloseOnButtonUp;
+ bSingleCell = bSetSingleCell;
+ bMultiSelection = bSetMultiSelection;
+}
+
+void ScSimpleRefDlg::StartRefInput()
+{
+ if ( bMultiSelection )
+ {
+ // initially select the whole string, so it gets replaced by default
+ aEdAssign.SetSelection( Selection( 0, aEdAssign.GetText().Len() ) );
+ }
+
+ aRbAssign.DoRef();
+ bCloseFlag=TRUE;
+}
+
+void ScSimpleRefDlg::RefInputDone( BOOL bForced)
+{
+ ScAnyRefDlg::RefInputDone(bForced);
+ if ( (bForced || bCloseOnButtonUp) && bCloseFlag )
+ OkBtnHdl(&aBtnOk);
+}
+//------------------------------------------------------------------------
+// Handler:
+// ========
+IMPL_LINK( ScSimpleRefDlg, OkBtnHdl, void *, EMPTYARG )
+{
+ bAutoReOpen=FALSE;
+ String aResult=aEdAssign.GetText();
+ aCloseHdl.Call(&aResult);
+ Link aUnoLink = aDoneHdl; // stack var because this is deleted in DoClose
+ DoClose( ScSimpleRefDlgWrapper::GetChildWindowId() );
+ aUnoLink.Call( &aResult );
+ return 0;
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK( ScSimpleRefDlg, CancelBtnHdl, void *, EMPTYARG )
+{
+ bAutoReOpen=FALSE;
+ String aResult=aEdAssign.GetText();
+ aCloseHdl.Call(NULL);
+ Link aUnoLink = aAbortedHdl; // stack var because this is deleted in DoClose
+ DoClose( ScSimpleRefDlgWrapper::GetChildWindowId() );
+ aUnoLink.Call( &aResult );
+ return 0;
+}
+
+
+
+//------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/solveroptions.cxx b/sc/source/ui/miscdlgs/solveroptions.cxx
new file mode 100644
index 000000000000..05ccd3553ef5
--- /dev/null
+++ b/sc/source/ui/miscdlgs/solveroptions.cxx
@@ -0,0 +1,494 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//------------------------------------------------------------------
+
+#include "solveroptions.hxx"
+#include "solveroptions.hrc"
+#include "scresid.hxx"
+#include "global.hxx"
+#include "miscuno.hxx"
+#include "solverutil.hxx"
+
+#include <rtl/math.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/collatorwrapper.hxx>
+#include <unotools/localedatawrapper.hxx>
+
+#include <algorithm>
+
+#include <com/sun/star/sheet/Solver.hpp>
+#include <com/sun/star/sheet/XSolverDescription.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+using namespace com::sun::star;
+
+//==================================================================
+
+/// Helper for sorting properties
+struct ScSolverOptionsEntry
+{
+ sal_Int32 nPosition;
+ rtl::OUString aDescription;
+
+ ScSolverOptionsEntry() : nPosition(0) {}
+
+ bool operator< (const ScSolverOptionsEntry& rOther) const
+ {
+ return ( ScGlobal::GetCollator()->compareString( aDescription, rOther.aDescription ) == COMPARE_LESS );
+ }
+};
+
+//------------------------------------------------------------------
+
+class ScSolverOptionsString : public SvLBoxString
+{
+ bool mbIsDouble;
+ double mfDoubleValue;
+ sal_Int32 mnIntValue;
+
+public:
+ ScSolverOptionsString( SvLBoxEntry* pEntry, USHORT nFlags, const String& rStr ) :
+ SvLBoxString( pEntry, nFlags, rStr ),
+ mbIsDouble( false ),
+ mfDoubleValue( 0.0 ),
+ mnIntValue( 0 ) {}
+
+ bool IsDouble() const { return mbIsDouble; }
+ double GetDoubleValue() const { return mfDoubleValue; }
+ sal_Int32 GetIntValue() const { return mnIntValue; }
+
+ void SetDoubleValue( double fNew ) { mbIsDouble = true; mfDoubleValue = fNew; }
+ void SetIntValue( sal_Int32 nNew ) { mbIsDouble = false; mnIntValue = nNew; }
+
+ virtual void Paint( const Point& rPos, SvLBox& rDev, USHORT nFlags, SvLBoxEntry* pEntry );
+};
+
+void ScSolverOptionsString::Paint( const Point& rPos, SvLBox& rDev, USHORT, SvLBoxEntry* /* pEntry */ )
+{
+ //! move position? (SvxLinguTabPage: aPos.X() += 20)
+ String aNormalStr( GetText() );
+ aNormalStr.Append( (sal_Unicode) ':' );
+ rDev.DrawText( rPos, aNormalStr );
+
+ Point aNewPos( rPos );
+ aNewPos.X() += rDev.GetTextWidth( aNormalStr );
+ Font aOldFont( rDev.GetFont() );
+ Font aFont( aOldFont );
+ aFont.SetWeight( WEIGHT_BOLD );
+
+ String sTxt( ' ' );
+ if ( mbIsDouble )
+ sTxt += (String)rtl::math::doubleToUString( mfDoubleValue,
+ rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
+ ScGlobal::GetpLocaleData()->getNumDecimalSep().GetChar(0), true );
+ else
+ sTxt += String::CreateFromInt32( mnIntValue );
+ rDev.SetFont( aFont );
+ rDev.DrawText( aNewPos, sTxt );
+
+ rDev.SetFont( aOldFont );
+}
+
+//------------------------------------------------------------------
+
+ScSolverOptionsDialog::ScSolverOptionsDialog( Window* pParent,
+ const uno::Sequence<rtl::OUString>& rImplNames,
+ const uno::Sequence<rtl::OUString>& rDescriptions,
+ const String& rEngine,
+ const uno::Sequence<beans::PropertyValue>& rProperties )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVEROPTIONS ) ),
+ maFtEngine ( this, ScResId( FT_ENGINE ) ),
+ maLbEngine ( this, ScResId( LB_ENGINE ) ),
+ maFtSettings ( this, ScResId( FT_SETTINGS ) ),
+ maLbSettings ( this, ScResId( LB_SETTINGS ) ),
+ maBtnEdit ( this, ScResId( BTN_EDIT ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ mpCheckButtonData( NULL ),
+ maImplNames( rImplNames ),
+ maDescriptions( rDescriptions ),
+ maEngine( rEngine ),
+ maProperties( rProperties )
+{
+ maLbEngine.SetSelectHdl( LINK( this, ScSolverOptionsDialog, EngineSelectHdl ) );
+
+ maBtnEdit.SetClickHdl( LINK( this, ScSolverOptionsDialog, ButtonHdl ) );
+
+ maLbSettings.SetWindowBits( WB_CLIPCHILDREN|WB_FORCE_MAKEVISIBLE );
+ maLbSettings.SetHelpId( HID_SC_SOLVEROPTIONS_LB );
+ maLbSettings.SetHighlightRange();
+
+ maLbSettings.SetSelectHdl( LINK( this, ScSolverOptionsDialog, SettingsSelHdl ) );
+ maLbSettings.SetDoubleClickHdl( LINK( this, ScSolverOptionsDialog, SettingsDoubleClickHdl ) );
+
+ sal_Int32 nSelect = -1;
+ sal_Int32 nImplCount = maImplNames.getLength();
+ for (sal_Int32 nImpl=0; nImpl<nImplCount; ++nImpl)
+ {
+ String aImplName( maImplNames[nImpl] );
+ String aDescription( maDescriptions[nImpl] ); // user-visible descriptions in list box
+ maLbEngine.InsertEntry( aDescription );
+ if ( aImplName == maEngine )
+ nSelect = nImpl;
+ }
+ if ( nSelect < 0 ) // no (valid) engine given
+ {
+ if ( nImplCount > 0 )
+ {
+ maEngine = maImplNames[0]; // use first implementation
+ nSelect = 0;
+ }
+ else
+ maEngine.Erase();
+ maProperties.realloc(0); // don't use options from different engine
+ }
+ if ( nSelect >= 0 ) // select in list box
+ maLbEngine.SelectEntryPos( static_cast<USHORT>(nSelect) );
+
+ if ( !maProperties.getLength() )
+ ReadFromComponent(); // fill maProperties from component (using maEngine)
+ FillListBox(); // using maProperties
+
+ FreeResource();
+}
+
+ScSolverOptionsDialog::~ScSolverOptionsDialog()
+{
+ delete mpCheckButtonData;
+}
+
+const String& ScSolverOptionsDialog::GetEngine() const
+{
+ return maEngine; // already updated in selection handler
+}
+
+const uno::Sequence<beans::PropertyValue>& ScSolverOptionsDialog::GetProperties()
+{
+ // update maProperties from list box content
+ // order of entries in list box and maProperties is the same
+ sal_Int32 nEntryCount = maProperties.getLength();
+ SvLBoxTreeList* pModel = maLbSettings.GetModel();
+ if ( nEntryCount == (sal_Int32)pModel->GetEntryCount() )
+ {
+ for (sal_Int32 nEntryPos=0; nEntryPos<nEntryCount; ++nEntryPos)
+ {
+ uno::Any& rValue = maProperties[nEntryPos].Value;
+ SvLBoxEntry* pEntry = pModel->GetEntry(nEntryPos);
+
+ bool bHasData = false;
+ USHORT nItemCount = pEntry->ItemCount();
+ for (USHORT nItemPos=0; nItemPos<nItemCount && !bHasData; ++nItemPos)
+ {
+ SvLBoxItem* pItem = pEntry->GetItem( nItemPos );
+ ScSolverOptionsString* pStringItem = dynamic_cast<ScSolverOptionsString*>(pItem);
+ if ( pStringItem )
+ {
+ if ( pStringItem->IsDouble() )
+ rValue <<= pStringItem->GetDoubleValue();
+ else
+ rValue <<= pStringItem->GetIntValue();
+ bHasData = true;
+ }
+ }
+ if ( !bHasData )
+ ScUnoHelpFunctions::SetBoolInAny( rValue,
+ maLbSettings.GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED );
+ }
+ }
+ else
+ {
+ DBG_ERRORFILE( "wrong count" );
+ }
+
+ return maProperties;
+}
+
+void ScSolverOptionsDialog::FillListBox()
+{
+ // get property descriptions, sort by them
+
+ uno::Reference<sheet::XSolverDescription> xDesc( ScSolverUtil::GetSolver( maEngine ), uno::UNO_QUERY );
+ sal_Int32 nCount = maProperties.getLength();
+ std::vector<ScSolverOptionsEntry> aDescriptions( nCount );
+ for (sal_Int32 nPos=0; nPos<nCount; nPos++)
+ {
+ rtl::OUString aPropName( maProperties[nPos].Name );
+ rtl::OUString aVisName;
+ if ( xDesc.is() )
+ aVisName = xDesc->getPropertyDescription( aPropName );
+ if ( !aVisName.getLength() )
+ aVisName = aPropName;
+ aDescriptions[nPos].nPosition = nPos;
+ aDescriptions[nPos].aDescription = aVisName;
+ }
+ std::sort( aDescriptions.begin(), aDescriptions.end() );
+
+ // also update maProperties to the order of descriptions
+
+ uno::Sequence<beans::PropertyValue> aNewSeq;
+ aNewSeq.realloc( nCount );
+ for (sal_Int32 nPos=0; nPos<nCount; nPos++)
+ aNewSeq[nPos] = maProperties[ aDescriptions[nPos].nPosition ];
+ maProperties = aNewSeq;
+
+ // fill the list box
+
+ maLbSettings.SetUpdateMode(FALSE);
+ maLbSettings.Clear();
+
+ String sEmpty;
+ if (!mpCheckButtonData)
+ mpCheckButtonData = new SvLBoxButtonData( &maLbSettings );
+
+ SvLBoxTreeList* pModel = maLbSettings.GetModel();
+ SvLBoxEntry* pEntry = NULL;
+
+ for (sal_Int32 nPos=0; nPos<nCount; nPos++)
+ {
+ rtl::OUString aVisName = aDescriptions[nPos].aDescription;
+
+ uno::Any aValue = maProperties[nPos].Value;
+ uno::TypeClass eClass = aValue.getValueTypeClass();
+ if ( eClass == uno::TypeClass_BOOLEAN )
+ {
+ // check box entry
+ pEntry = new SvLBoxEntry;
+ SvLBoxButton* pButton = new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox, 0, mpCheckButtonData );
+ if ( ScUnoHelpFunctions::GetBoolFromAny( aValue ) )
+ pButton->SetStateChecked();
+ else
+ pButton->SetStateUnchecked();
+ pEntry->AddItem( pButton );
+ pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0 ) );
+ pEntry->AddItem( new SvLBoxString( pEntry, 0, aVisName ) );
+ }
+ else
+ {
+ // value entry
+ pEntry = new SvLBoxEntry;
+ pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty ) ); // empty column
+ pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0 ) );
+ ScSolverOptionsString* pItem = new ScSolverOptionsString( pEntry, 0, aVisName );
+ if ( eClass == uno::TypeClass_DOUBLE )
+ {
+ double fDoubleValue = 0.0;
+ if ( aValue >>= fDoubleValue )
+ pItem->SetDoubleValue( fDoubleValue );
+ }
+ else
+ {
+ sal_Int32 nIntValue = 0;
+ if ( aValue >>= nIntValue )
+ pItem->SetIntValue( nIntValue );
+ }
+ pEntry->AddItem( pItem );
+ }
+ pModel->Insert( pEntry );
+ }
+
+ maLbSettings.SetUpdateMode(TRUE);
+}
+
+void ScSolverOptionsDialog::ReadFromComponent()
+{
+ maProperties = ScSolverUtil::GetDefaults( maEngine );
+}
+
+void ScSolverOptionsDialog::EditOption()
+{
+ SvLBoxEntry* pEntry = maLbSettings.GetCurEntry();
+ if (pEntry)
+ {
+ USHORT nItemCount = pEntry->ItemCount();
+ for (USHORT nPos=0; nPos<nItemCount; ++nPos)
+ {
+ SvLBoxItem* pItem = pEntry->GetItem( nPos );
+ ScSolverOptionsString* pStringItem = dynamic_cast<ScSolverOptionsString*>(pItem);
+ if ( pStringItem )
+ {
+ if ( pStringItem->IsDouble() )
+ {
+ ScSolverValueDialog aValDialog( this );
+ aValDialog.SetOptionName( pStringItem->GetText() );
+ aValDialog.SetValue( pStringItem->GetDoubleValue() );
+ if ( aValDialog.Execute() == RET_OK )
+ {
+ pStringItem->SetDoubleValue( aValDialog.GetValue() );
+ maLbSettings.InvalidateEntry( pEntry );
+ }
+ }
+ else
+ {
+ ScSolverIntegerDialog aIntDialog( this );
+ aIntDialog.SetOptionName( pStringItem->GetText() );
+ aIntDialog.SetValue( pStringItem->GetIntValue() );
+ if ( aIntDialog.Execute() == RET_OK )
+ {
+ pStringItem->SetIntValue( aIntDialog.GetValue() );
+ maLbSettings.InvalidateEntry( pEntry );
+ }
+ }
+ }
+ }
+ }
+}
+
+IMPL_LINK( ScSolverOptionsDialog, ButtonHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &maBtnEdit )
+ EditOption();
+
+ return 0;
+}
+
+IMPL_LINK( ScSolverOptionsDialog, SettingsDoubleClickHdl, SvTreeListBox*, EMPTYARG )
+{
+ EditOption();
+ return 0;
+}
+
+IMPL_LINK( ScSolverOptionsDialog, EngineSelectHdl, ListBox*, EMPTYARG )
+{
+ USHORT nSelectPos = maLbEngine.GetSelectEntryPos();
+ if ( nSelectPos < maImplNames.getLength() )
+ {
+ String aNewEngine( maImplNames[nSelectPos] );
+ if ( aNewEngine != maEngine )
+ {
+ maEngine = aNewEngine;
+ ReadFromComponent(); // fill maProperties from component (using maEngine)
+ FillListBox(); // using maProperties
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( ScSolverOptionsDialog, SettingsSelHdl, SvxCheckListBox*, EMPTYARG )
+{
+ BOOL bCheckbox = FALSE;
+
+ SvLBoxEntry* pEntry = maLbSettings.GetCurEntry();
+ if (pEntry)
+ {
+ SvLBoxItem* pItem = pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON);
+ if ( pItem && pItem->IsA() == SV_ITEM_ID_LBOXBUTTON )
+ bCheckbox = TRUE;
+ }
+
+ maBtnEdit.Enable( !bCheckbox );
+
+ return 0;
+}
+
+//------------------------------------------------------------------
+
+ScSolverIntegerDialog::ScSolverIntegerDialog( Window * pParent )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_INTEGER ) ),
+ maFtName ( this, ScResId( FT_OPTIONNAME ) ),
+ maNfValue ( this, ScResId( NF_VALUE ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) )
+{
+ FreeResource();
+}
+
+ScSolverIntegerDialog::~ScSolverIntegerDialog()
+{
+}
+
+void ScSolverIntegerDialog::SetOptionName( const String& rName )
+{
+ maFtName.SetText( rName );
+}
+
+void ScSolverIntegerDialog::SetValue( sal_Int32 nValue )
+{
+ maNfValue.SetValue( nValue );
+}
+
+sal_Int32 ScSolverIntegerDialog::GetValue() const
+{
+ sal_Int64 nValue = maNfValue.GetValue();
+ if ( nValue < SAL_MIN_INT32 )
+ return SAL_MIN_INT32;
+ if ( nValue > SAL_MAX_INT32 )
+ return SAL_MAX_INT32;
+ return (sal_Int32) nValue;
+}
+
+//------------------------------------------------------------------
+
+ScSolverValueDialog::ScSolverValueDialog( Window * pParent )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_DOUBLE ) ),
+ maFtName ( this, ScResId( FT_OPTIONNAME ) ),
+ maEdValue ( this, ScResId( ED_VALUE ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) )
+{
+ FreeResource();
+}
+
+ScSolverValueDialog::~ScSolverValueDialog()
+{
+}
+
+void ScSolverValueDialog::SetOptionName( const String& rName )
+{
+ maFtName.SetText( rName );
+}
+
+void ScSolverValueDialog::SetValue( double fValue )
+{
+ maEdValue.SetText( rtl::math::doubleToUString( fValue,
+ rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
+ ScGlobal::GetpLocaleData()->getNumDecimalSep().GetChar(0), true ) );
+}
+
+double ScSolverValueDialog::GetValue() const
+{
+ String aInput = maEdValue.GetText();
+
+ const LocaleDataWrapper* pLocaleData = ScGlobal::GetpLocaleData();
+ rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
+ double fValue = rtl::math::stringToDouble( aInput,
+ pLocaleData->getNumDecimalSep().GetChar(0),
+ pLocaleData->getNumThousandSep().GetChar(0),
+ &eStatus, NULL );
+ return fValue;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/solverutil.cxx b/sc/source/ui/miscdlgs/solverutil.cxx
new file mode 100644
index 000000000000..f216864932ab
--- /dev/null
+++ b/sc/source/ui/miscdlgs/solverutil.cxx
@@ -0,0 +1,231 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//------------------------------------------------------------------
+
+#include "solverutil.hxx"
+
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sheet/XSolver.hpp>
+#include <com/sun/star/sheet/XSolverDescription.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------
+
+#define SCSOLVER_SERVICE "com.sun.star.sheet.Solver"
+
+uno::Reference<sheet::XSolver> lcl_CreateSolver( const uno::Reference<uno::XInterface>& xIntFac,
+ const uno::Reference<uno::XComponentContext>& xCtx )
+{
+ uno::Reference<sheet::XSolver> xSolver;
+
+ uno::Reference<lang::XSingleComponentFactory> xCFac( xIntFac, uno::UNO_QUERY );
+ uno::Reference<lang::XSingleServiceFactory> xFac( xIntFac, uno::UNO_QUERY );
+ if ( xCFac.is() )
+ {
+ try
+ {
+ uno::Reference<uno::XInterface> xInterface = xCFac->createInstanceWithContext(xCtx);
+ xSolver = uno::Reference<sheet::XSolver>( xInterface, uno::UNO_QUERY );
+ }
+ catch(uno::Exception&)
+ {
+ }
+ }
+ if ( !xSolver.is() && xFac.is() )
+ {
+ try
+ {
+ uno::Reference<uno::XInterface> xInterface = xFac->createInstance();
+ xSolver = uno::Reference<sheet::XSolver>( xInterface, uno::UNO_QUERY );
+ }
+ catch(uno::Exception&)
+ {
+ }
+ }
+
+ return xSolver;
+}
+
+// static
+void ScSolverUtil::GetImplementations( uno::Sequence<rtl::OUString>& rImplNames,
+ uno::Sequence<rtl::OUString>& rDescriptions )
+{
+ rImplNames.realloc(0); // clear
+ rDescriptions.realloc(0);
+ sal_Int32 nCount = 0;
+
+ uno::Reference<uno::XComponentContext> xCtx;
+ uno::Reference<lang::XMultiServiceFactory> xMSF = comphelper::getProcessServiceFactory();
+ uno::Reference<beans::XPropertySet> xPropset(xMSF, uno::UNO_QUERY);
+ try
+ {
+ xPropset->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xCtx;
+ }
+ catch ( uno::Exception & )
+ {
+ }
+
+ uno::Reference<container::XContentEnumerationAccess> xEnAc( xMSF, uno::UNO_QUERY );
+ if ( xCtx.is() && xEnAc.is() )
+ {
+ uno::Reference<container::XEnumeration> xEnum =
+ xEnAc->createContentEnumeration( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SCSOLVER_SERVICE)) );
+ if ( xEnum.is() )
+ {
+ while ( xEnum->hasMoreElements() )
+ {
+ uno::Any aAny = xEnum->nextElement();
+ uno::Reference<uno::XInterface> xIntFac;
+ aAny >>= xIntFac;
+ if ( xIntFac.is() )
+ {
+ uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY );
+ if ( xInfo.is() )
+ {
+ rtl::OUString sName = xInfo->getImplementationName();
+ rtl::OUString sDescription;
+
+ uno::Reference<sheet::XSolver> xSolver = lcl_CreateSolver( xIntFac, xCtx );
+ uno::Reference<sheet::XSolverDescription> xDesc( xSolver, uno::UNO_QUERY );
+ if ( xDesc.is() )
+ sDescription = xDesc->getComponentDescription();
+
+ if ( !sDescription.getLength() )
+ sDescription = sName; // use implementation name if no description available
+
+ rImplNames.realloc( nCount+1 );
+ rImplNames[nCount] = sName;
+ rDescriptions.realloc( nCount+1 );
+ rDescriptions[nCount] = sDescription;
+ ++nCount;
+ }
+ }
+ }
+ }
+ }
+}
+
+// static
+uno::Reference<sheet::XSolver> ScSolverUtil::GetSolver( const rtl::OUString& rImplName )
+{
+ uno::Reference<sheet::XSolver> xSolver;
+
+ uno::Reference<uno::XComponentContext> xCtx;
+ uno::Reference<lang::XMultiServiceFactory> xMSF = comphelper::getProcessServiceFactory();
+ uno::Reference<beans::XPropertySet> xPropset(xMSF, uno::UNO_QUERY);
+ try
+ {
+ xPropset->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xCtx;
+ }
+ catch ( uno::Exception & )
+ {
+ }
+
+ uno::Reference<container::XContentEnumerationAccess> xEnAc( xMSF, uno::UNO_QUERY );
+ if ( xCtx.is() && xEnAc.is() )
+ {
+ uno::Reference<container::XEnumeration> xEnum =
+ xEnAc->createContentEnumeration( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SCSOLVER_SERVICE)) );
+ if ( xEnum.is() )
+ {
+ while ( xEnum->hasMoreElements() && !xSolver.is() )
+ {
+ uno::Any aAny = xEnum->nextElement();
+ uno::Reference<uno::XInterface> xIntFac;
+ aAny >>= xIntFac;
+ if ( xIntFac.is() )
+ {
+ uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY );
+ if ( xInfo.is() )
+ {
+ rtl::OUString sName = xInfo->getImplementationName();
+ if ( sName == rImplName )
+ xSolver = lcl_CreateSolver( xIntFac, xCtx );
+ }
+ }
+ }
+ }
+ }
+
+ OSL_ENSURE( xSolver.is(), "can't get solver" );
+ return xSolver;
+}
+
+// static
+uno::Sequence<beans::PropertyValue> ScSolverUtil::GetDefaults( const rtl::OUString& rImplName )
+{
+ uno::Sequence<beans::PropertyValue> aDefaults;
+
+ uno::Reference<sheet::XSolver> xSolver = GetSolver( rImplName );
+ uno::Reference<beans::XPropertySet> xPropSet( xSolver, uno::UNO_QUERY );
+ if ( !xPropSet.is() )
+ {
+ // no XPropertySet - no options
+ return aDefaults;
+ }
+
+ // fill maProperties
+
+ uno::Reference<beans::XPropertySetInfo> xInfo = xPropSet->getPropertySetInfo();
+ OSL_ENSURE( xInfo.is(), "can't get property set info" );
+ if ( !xInfo.is() )
+ return aDefaults;
+
+ uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
+ const sal_Int32 nSize = aPropSeq.getLength();
+ aDefaults.realloc(nSize);
+ sal_Int32 nValid = 0;
+ for (sal_Int32 nPos=0; nPos<nSize; ++nPos)
+ {
+ const beans::Property& rProp = aPropSeq[nPos];
+ uno::Any aValue = xPropSet->getPropertyValue( rProp.Name );
+ uno::TypeClass eClass = aValue.getValueTypeClass();
+ // only use properties of supported types
+ if ( eClass == uno::TypeClass_BOOLEAN || eClass == uno::TypeClass_LONG || eClass == uno::TypeClass_DOUBLE )
+ aDefaults[nValid++] = beans::PropertyValue( rProp.Name, -1, aValue, beans::PropertyState_DIRECT_VALUE );
+ }
+ aDefaults.realloc(nValid);
+
+ //! get user-visible names, sort by them
+
+ return aDefaults;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/solvrdlg.cxx b/sc/source/ui/miscdlgs/solvrdlg.cxx
new file mode 100644
index 000000000000..e718ba7be498
--- /dev/null
+++ b/sc/source/ui/miscdlgs/solvrdlg.cxx
@@ -0,0 +1,315 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "rangelst.hxx"
+#include "scitems.hxx"
+#include <sfx2/dispatch.hxx>
+#include <svl/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "uiitems.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "solvrdlg.hrc"
+
+#define _SOLVRDLG_CXX
+#include "solvrdlg.hxx"
+#undef _SOLVERDLG_CXX
+
+
+#define ERRORBOX(s) ErrorBox( this, WinBits( WB_OK | WB_DEF_OK), s ).Execute()
+
+
+//============================================================================
+// class ScSolverDlg
+//----------------------------------------------------------------------------
+
+ScSolverDlg::ScSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocument* pDocument,
+ ScAddress aCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_SOLVER ),
+ //
+ aFlVariables ( this, ScResId( FL_VARIABLES ) ),
+ aFtFormulaCell ( this, ScResId( FT_FORMULACELL ) ),
+ aEdFormulaCell ( this, this, ScResId( ED_FORMULACELL ) ),
+ aRBFormulaCell ( this, ScResId( RB_FORMULACELL ), &aEdFormulaCell, this ),
+ aFtTargetVal ( this, ScResId( FT_TARGETVAL ) ),
+ aEdTargetVal ( this, ScResId( ED_TARGETVAL ) ),
+ aFtVariableCell ( this, ScResId( FT_VARCELL ) ),
+ aEdVariableCell ( this, this, ScResId( ED_VARCELL ) ),
+ aRBVariableCell ( this, ScResId( RB_VARCELL ), &aEdVariableCell, this ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ theFormulaCell ( aCursorPos ),
+ theVariableCell ( aCursorPos ),
+ pDoc ( pDocument ),
+ nCurTab ( aCursorPos.Tab() ),
+ pEdActive ( NULL ),
+ bDlgLostFocus ( FALSE ),
+ errMsgInvalidVar ( ScResId( STR_INVALIDVAR ) ),
+ errMsgInvalidForm ( ScResId( STR_INVALIDFORM ) ),
+ errMsgNoFormula ( ScResId( STR_NOFORMULA ) ),
+ errMsgInvalidVal ( ScResId( STR_INVALIDVAL ) )
+{
+ Init();
+ FreeResource();
+}
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScSolverDlg::~ScSolverDlg()
+{
+}
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScSolverDlg::Init()
+{
+ String aStr;
+
+ aBtnOk. SetClickHdl ( LINK( this, ScSolverDlg, BtnHdl ) );
+ aBtnCancel. SetClickHdl ( LINK( this, ScSolverDlg, BtnHdl ) );
+
+ Link aLink = LINK( this, ScSolverDlg, GetFocusHdl );
+ aEdFormulaCell. SetGetFocusHdl ( aLink );
+ aRBFormulaCell. SetGetFocusHdl ( aLink );
+ aEdVariableCell.SetGetFocusHdl ( aLink );
+ aRBVariableCell.SetGetFocusHdl ( aLink );
+ aEdTargetVal. SetGetFocusHdl ( aLink );
+
+ aLink = LINK( this, ScSolverDlg, LoseFocusHdl );
+ aEdFormulaCell. SetLoseFocusHdl ( aLink );
+ aRBFormulaCell. SetLoseFocusHdl ( aLink );
+ aEdVariableCell.SetLoseFocusHdl ( aLink );
+ aRBVariableCell.SetLoseFocusHdl ( aLink );
+
+ theFormulaCell.Format( aStr, SCA_ABS, NULL, pDoc->GetAddressConvention() );
+
+ aEdFormulaCell.SetText( aStr );
+ aEdFormulaCell.GrabFocus();
+ pEdActive = &aEdFormulaCell;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScSolverDlg::Close()
+{
+ return DoClose( ScSolverDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScSolverDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+ if( pEdActive )
+ pEdActive->GrabFocus();
+ }
+ else
+ {
+ GrabFocus();
+ }
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if( pEdActive )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(pEdActive);
+
+ String aStr;
+ ScAddress aAdr = rRef.aStart;
+ USHORT nFmt = ( aAdr.Tab() == nCurTab )
+ ? SCA_ABS
+ : SCA_ABS_3D;
+
+ aAdr.Format( aStr, nFmt, pDocP, pDocP->GetAddressConvention() );
+ pEdActive->SetRefString( aStr );
+
+ if ( pEdActive == &aEdFormulaCell )
+ theFormulaCell = aAdr;
+ else if ( pEdActive == &aEdVariableCell )
+ theVariableCell = aAdr;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScSolverDlg::RaiseError( ScSolverErr eError )
+{
+ switch ( eError )
+ {
+ case SOLVERR_NOFORMULA:
+ ERRORBOX( errMsgNoFormula );
+ aEdFormulaCell.GrabFocus();
+ break;
+
+ case SOLVERR_INVALID_FORMULA:
+ ERRORBOX( errMsgInvalidForm );
+ aEdFormulaCell.GrabFocus();
+ break;
+
+ case SOLVERR_INVALID_VARIABLE:
+ ERRORBOX( errMsgInvalidVar );
+ aEdVariableCell.GrabFocus();
+ break;
+
+ case SOLVERR_INVALID_TARGETVALUE:
+ ERRORBOX( errMsgInvalidVal );
+ aEdTargetVal.GrabFocus();
+ break;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScSolverDlg::IsRefInputMode() const
+{
+ return pEdActive != NULL;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScSolverDlg::CheckTargetValue( String& rStrVal )
+{
+ sal_uInt32 n1 = 0;
+ double n2;
+
+ return pDoc->GetFormatTable()->IsNumberFormat( rStrVal, n1, n2 );
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScSolverDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnOk )
+ {
+ theTargetValStr = aEdTargetVal.GetText();
+
+ // Zu ueberpruefen:
+ // 1. enthalten die Strings korrekte Tabellenkoordinaten/def.Namen?
+ // 2. verweist die Formel-Koordinate wirklich auf eine Formelzelle?
+ // 3. wurde ein korrekter Zielwert eingegeben
+
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ USHORT nRes1 = theFormulaCell .Parse( aEdFormulaCell.GetText(), pDoc, eConv );
+ USHORT nRes2 = theVariableCell.Parse( aEdVariableCell.GetText(), pDoc, eConv );
+
+ if ( SCA_VALID == ( nRes1 & SCA_VALID ) )
+ {
+ if ( SCA_VALID == ( nRes2 & SCA_VALID ) )
+ {
+ if ( CheckTargetValue( theTargetValStr ) )
+ {
+ CellType eType;
+ pDoc->GetCellType( theFormulaCell.Col(),
+ theFormulaCell.Row(),
+ theFormulaCell.Tab(),
+ eType );
+
+ if ( CELLTYPE_FORMULA == eType )
+ {
+ ScSolveParam aOutParam( theFormulaCell,
+ theVariableCell,
+ theTargetValStr );
+ ScSolveItem aOutItem( SCITEM_SOLVEDATA, &aOutParam );
+
+ SetDispatcherLock( FALSE );
+
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( SID_SOLVE,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aOutItem, 0L, 0L );
+ Close();
+ }
+ else RaiseError( SOLVERR_NOFORMULA );
+ }
+ else RaiseError( SOLVERR_INVALID_TARGETVALUE );
+ }
+ else RaiseError( SOLVERR_INVALID_VARIABLE );
+ }
+ else RaiseError( SOLVERR_INVALID_FORMULA );
+ }
+ else if ( pBtn == &aBtnCancel )
+ {
+ Close();
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSolverDlg, GetFocusHdl, Control*, pCtrl )
+{
+ Edit* pEdit = NULL;
+ pEdActive = NULL;
+
+ if( (pCtrl == (Control*)&aEdFormulaCell) || (pCtrl == (Control*)&aRBFormulaCell) )
+ pEdit = pEdActive = &aEdFormulaCell;
+ else if( (pCtrl == (Control*)&aEdVariableCell) || (pCtrl == (Control*)&aRBVariableCell) )
+ pEdit = pEdActive = &aEdVariableCell;
+ else if( pCtrl == (Control*)&aEdTargetVal )
+ pEdit = &aEdTargetVal;
+
+ if( pEdit )
+ pEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSolverDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ bDlgLostFocus = !IsActive();
+ return 0;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/strindlg.cxx b/sc/source/ui/miscdlgs/strindlg.cxx
new file mode 100644
index 000000000000..c35b4e9d6ce1
--- /dev/null
+++ b/sc/source/ui/miscdlgs/strindlg.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <tools/debug.hxx>
+
+#include "strindlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+#include <layout/layout-pre.hxx>
+
+#if ENABLE_LAYOUT
+#undef ScResId
+#define ScResId(x) #x
+#undef ModalDialog
+#define ModalDialog( parent, id ) Dialog( parent, "string-input.xml", id )
+#endif /* ENABLE_LAYOUT */
+
+//==================================================================
+
+ScStringInputDlg::ScStringInputDlg( Window* pParent,
+ const String& rTitle,
+ const String& rEditTitle,
+ const String& rDefault,
+ ULONG nHelpId ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_STRINPUT ) ),
+ //
+ aFtEditTitle ( this, ScResId( FT_LABEL ) ),
+ aEdInput ( this, ScResId( ED_INPUT ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ SetHelpId( nHelpId );
+ SetText( rTitle );
+ aFtEditTitle.SetText( rEditTitle );
+ aEdInput.SetText( rDefault );
+ aEdInput.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
+
+ // HelpId for Edit different for different uses
+
+ if ( nHelpId == FID_TAB_APPEND )
+ aEdInput.SetHelpId( HID_SC_APPEND_NAME );
+ else if ( nHelpId == FID_TAB_RENAME )
+ aEdInput.SetHelpId( HID_SC_RENAME_NAME );
+ else if ( nHelpId == HID_SC_ADD_AUTOFMT )
+ aEdInput.SetHelpId( HID_SC_AUTOFMT_NAME );
+ else if ( nHelpId == HID_SC_REN_AFMT_DLG )
+ aEdInput.SetHelpId( HID_SC_REN_AFMT_NAME );
+ else if ( nHelpId == SID_RENAME_OBJECT )
+ aEdInput.SetHelpId( HID_SC_RENAME_OBJECT );
+ // #i68101#
+ else if ( nHelpId == SID_TITLE_DESCRIPTION_OBJECT )
+ aEdInput.SetHelpId( HID_SC_TITLE_DESCRIPTION_OBJECT );
+ else
+ DBG_ERRORFILE( "unknown ID" );
+
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+void ScStringInputDlg::GetInputString( String& rString ) const
+{
+ rString = aEdInput.GetText();
+}
+
+__EXPORT ScStringInputDlg::~ScStringInputDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
new file mode 100644
index 000000000000..e99c8d98ecfe
--- /dev/null
+++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
@@ -0,0 +1,201 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: tabbgcolordlg.cxx,v $
+ * $Revision: 1.0 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+//------------------------------------------------------------------
+
+#include "tabbgcolordlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+#include <tools/debug.hxx>
+#include <tools/color.hxx>
+#include <sfx2/objsh.hxx>
+#include <svx/xtable.hxx>
+#include <svx/drawitem.hxx>
+#include <unotools/pathoptions.hxx>
+#include <tools/resid.hxx>
+#include <editeng/editrids.hrc>
+#include <editeng/eerdll.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+//==================================================================
+
+#define HDL(hdl) LINK(this,ScTabBgColorDlg,hdl)
+
+ScTabBgColorDlg::ScTabBgColorDlg( Window* pParent,
+ const String& rTitle,
+ const String& rTabBgColorNoColorText,
+ const Color& rDefaultColor,
+ ULONG nHelpId ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_TAB_BG_COLOR ) ),
+ aBorderWin ( this, ScResId( TAB_BG_COLOR_CT_BORDER ) ),
+ aTabBgColorSet ( &aBorderWin, ScResId( TAB_BG_COLOR_SET_BGDCOLOR ), this ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aTabBgColor ( rDefaultColor ),
+ aTabBgColorNoColorText ( rTabBgColorNoColorText ),
+ mnHelpId ( nHelpId )
+
+{
+ SetHelpId( nHelpId );
+ this->SetText( rTitle );
+ this->SetStyle(GetStyle() | WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL | WB_SYSTEMWINDOW | WB_STANDALONE | WB_HIDE);
+
+ FillColorValueSets_Impl();
+ aTabBgColorSet.SetDoubleClickHdl( HDL(TabBgColorDblClickHdl_Impl) );
+ aBtnOk.SetClickHdl( HDL(TabBgColorOKHdl_Impl) );
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+void ScTabBgColorDlg::GetSelectedColor( Color& rColor ) const
+{
+ rColor = this->aTabBgColor;
+}
+
+ScTabBgColorDlg::~ScTabBgColorDlg()
+{
+}
+
+void ScTabBgColorDlg::FillColorValueSets_Impl()
+{
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ const SfxPoolItem* pItem = NULL;
+ XColorTable* pColorTable = NULL;
+ ::boost::scoped_ptr<XColorTable> pOwnColorTable; // locally instantiated in case the doc shell doesn't have one.
+
+ const Size aSize15x15 = Size( 15, 15 );
+ const Size aSize10x10 = Size( 10, 10 );
+ const Size aSize5x5 = Size( 5, 5 );
+ USHORT nSelectedItem = 0;
+
+ DBG_ASSERT( pDocSh, "DocShell not found!" );
+
+ if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem(SID_COLOR_TABLE) ) ) )
+ pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
+ if ( !pColorTable )
+ {
+ pOwnColorTable.reset(new XColorTable(SvtPathOptions().GetPalettePath()));
+ pColorTable = pOwnColorTable.get();
+ }
+ if ( pColorTable )
+ {
+ sal_uInt16 i = 0;
+ long nCount = pColorTable->Count();
+ XColorEntry* pEntry = NULL;
+ Color aColWhite( COL_WHITE );
+ String aStrWhite( EditResId( RID_SVXITEMS_COLOR_WHITE ) );
+ WinBits nBits = ( aTabBgColorSet.GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS);
+ aTabBgColorSet.SetText( aTabBgColorNoColorText );
+ aTabBgColorSet.SetStyle( nBits );
+ for ( i = 0; i < nCount; i++ )
+ {
+ pEntry = pColorTable->GetColor(i);
+ aTabBgColorSet.InsertItem( i + 1, pEntry->GetColor(), pEntry->GetName() );
+ if (pEntry->GetColor() == aTabBgColor)
+ nSelectedItem = (i + 1);
+ }
+
+ while ( i < 80 )
+ {
+ aTabBgColorSet.InsertItem( i + 1, aColWhite, aStrWhite );
+ i++;
+ }
+
+ if ( nCount > 80 )
+ {
+ aTabBgColorSet.SetStyle( nBits | WB_VSCROLL );
+ }
+ }
+ aTabBgColorSet.SetColCount( 10 );
+ aTabBgColorSet.SetLineCount( 10 );
+ aTabBgColorSet.CalcWindowSizePixel( aSize15x15 );
+ aTabBgColorSet.Format();
+ aTabBgColorSet.SelectItem(nSelectedItem);
+ aTabBgColorSet.Resize();
+}
+
+IMPL_LINK( ScTabBgColorDlg, TabBgColorDblClickHdl_Impl, ValueSet*, EMPTYARG )
+/*
+ Handler, called when color selection is changed
+*/
+{
+ USHORT nItemId = aTabBgColorSet.GetSelectItemId();
+ Color aColor = nItemId ? ( aTabBgColorSet.GetItemColor( nItemId ) ) : Color( COL_AUTO );
+ aTabBgColor = aColor;
+ EndDialog( TRUE );
+ return 0;
+}
+
+IMPL_LINK( ScTabBgColorDlg, TabBgColorOKHdl_Impl, OKButton*, EMPTYARG )
+{
+
+// Handler, called when the OK button is pushed
+
+ USHORT nItemId = aTabBgColorSet.GetSelectItemId();
+ Color aColor = nItemId ? ( aTabBgColorSet.GetItemColor( nItemId ) ) : Color( COL_AUTO );
+ aTabBgColor = aColor;
+ EndDialog( TRUE );
+ return 0;
+}
+
+ScTabBgColorDlg::ScTabBgColorValueSet::ScTabBgColorValueSet( Control* pParent, const ResId& rResId, ScTabBgColorDlg* pTabBgColorDlg ) :
+ ValueSet(pParent, rResId)
+{
+ aTabBgColorDlg = pTabBgColorDlg;
+}
+
+void ScTabBgColorDlg::ScTabBgColorValueSet::KeyInput( const KeyEvent& rKEvt )
+{
+ switch ( rKEvt.GetKeyCode().GetCode() )
+ {
+ case KEY_SPACE:
+ case KEY_RETURN:
+ {
+ USHORT nItemId = GetSelectItemId();
+ const Color& aColor = nItemId ? ( GetItemColor( nItemId ) ) : Color( COL_AUTO );
+ aTabBgColorDlg->aTabBgColor = aColor;
+ aTabBgColorDlg->EndDialog(TRUE);
+ }
+ break;
+ }
+ ValueSet::KeyInput(rKEvt);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/tabopdlg.cxx b/sc/source/ui/miscdlgs/tabopdlg.cxx
new file mode 100644
index 000000000000..7fe01494a49f
--- /dev/null
+++ b/sc/source/ui/miscdlgs/tabopdlg.cxx
@@ -0,0 +1,373 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/dispatch.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "uiitems.hxx"
+#include "global.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "reffact.hxx"
+#include "tabopdlg.hrc"
+
+#define _TABOPDLG_CXX
+#include "tabopdlg.hxx"
+
+
+//============================================================================
+// class ScTabOpDlg
+//----------------------------------------------------------------------------
+
+ScTabOpDlg::ScTabOpDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocument* pDocument,
+ const ScRefAddress& rCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_TABOP ),
+ //
+ aFlVariables ( this, ScResId( FL_VARIABLES ) ),
+ aFtFormulaRange ( this, ScResId( FT_FORMULARANGE ) ),
+ aEdFormulaRange ( this, this, ScResId( ED_FORMULARANGE ) ),
+ aRBFormulaRange ( this, ScResId( RB_FORMULARANGE ), &aEdFormulaRange, this ),
+ aFtRowCell ( this, ScResId( FT_ROWCELL ) ),
+ aEdRowCell ( this, this, ScResId( ED_ROWCELL ) ),
+ aRBRowCell ( this, ScResId( RB_ROWCELL ), &aEdRowCell, this ),
+ aFtColCell ( this, ScResId( FT_COLCELL ) ),
+ aEdColCell ( this, this, ScResId( ED_COLCELL ) ),
+ aRBColCell ( this, ScResId( RB_COLCELL ), &aEdColCell, this ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ theFormulaCell ( rCursorPos ),
+ pDoc ( pDocument ),
+ nCurTab ( theFormulaCell.Tab() ),
+ pEdActive ( NULL ),
+ bDlgLostFocus ( FALSE ),
+ errMsgNoFormula ( ScResId( STR_NOFORMULA ) ),
+ errMsgNoColRow ( ScResId( STR_NOCOLROW ) ),
+ errMsgWrongFormula ( ScResId( STR_WRONGFORMULA ) ),
+ errMsgWrongRowCol ( ScResId( STR_WRONGROWCOL ) ),
+ errMsgNoColFormula ( ScResId( STR_NOCOLFORMULA ) ),
+ errMsgNoRowFormula ( ScResId( STR_NOROWFORMULA ) )
+{
+ Init();
+ FreeResource();
+}
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScTabOpDlg::~ScTabOpDlg()
+{
+ Hide();
+}
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScTabOpDlg::Init()
+{
+ aBtnOk. SetClickHdl ( LINK( this, ScTabOpDlg, BtnHdl ) );
+ aBtnCancel. SetClickHdl ( LINK( this, ScTabOpDlg, BtnHdl ) );
+
+ Link aLink = LINK( this, ScTabOpDlg, GetFocusHdl );
+ aEdFormulaRange.SetGetFocusHdl( aLink );
+ aRBFormulaRange.SetGetFocusHdl( aLink );
+ aEdRowCell. SetGetFocusHdl( aLink );
+ aRBRowCell. SetGetFocusHdl( aLink );
+ aEdColCell. SetGetFocusHdl( aLink );
+ aRBColCell. SetGetFocusHdl( aLink );
+
+ aLink = LINK( this, ScTabOpDlg, LoseFocusHdl );
+ aEdFormulaRange.SetLoseFocusHdl( aLink );
+ aRBFormulaRange.SetLoseFocusHdl( aLink );
+ aEdRowCell. SetLoseFocusHdl( aLink );
+ aRBRowCell. SetLoseFocusHdl( aLink );
+ aEdColCell. SetLoseFocusHdl( aLink );
+ aRBColCell. SetLoseFocusHdl( aLink );
+
+ aEdFormulaRange.GrabFocus();
+ pEdActive = &aEdFormulaRange;
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScTabOpDlg::Close()
+{
+ return DoClose( ScTabOpDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScTabOpDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+ if( pEdActive )
+ pEdActive->GrabFocus();
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScTabOpDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( pEdActive )
+ {
+ ScAddress::Details aDetails(pDocP->GetAddressConvention(), 0, 0);
+
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(pEdActive);
+
+ String aStr;
+ USHORT nFmt = ( rRef.aStart.Tab() == nCurTab )
+ ? SCR_ABS
+ : SCR_ABS_3D;
+
+ if ( pEdActive == &aEdFormulaRange )
+ {
+ theFormulaCell.Set( rRef.aStart, false, false, false);
+ theFormulaEnd.Set( rRef.aEnd, false, false, false);
+ rRef.Format( aStr, nFmt, pDocP, aDetails );
+ }
+ else if ( pEdActive == &aEdRowCell )
+ {
+ theRowCell.Set( rRef.aStart, false, false, false);
+ rRef.aStart.Format( aStr, nFmt, pDocP, aDetails );
+ }
+ else if ( pEdActive == &aEdColCell )
+ {
+ theColCell.Set( rRef.aStart, false, false, false);
+ rRef.aStart.Format( aStr, nFmt, pDocP, aDetails );
+ }
+
+ pEdActive->SetRefString( aStr );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScTabOpDlg::RaiseError( ScTabOpErr eError )
+{
+ const String* pMsg = &errMsgNoFormula;
+ Edit* pEd = &aEdFormulaRange;
+
+ switch ( eError )
+ {
+ case TABOPERR_NOFORMULA:
+ pMsg = &errMsgNoFormula;
+ pEd = &aEdFormulaRange;
+ break;
+
+ case TABOPERR_NOCOLROW:
+ pMsg = &errMsgNoColRow;
+ pEd = &aEdRowCell;
+ break;
+
+ case TABOPERR_WRONGFORMULA:
+ pMsg = &errMsgWrongFormula;
+ pEd = &aEdFormulaRange;
+ break;
+
+ case TABOPERR_WRONGROW:
+ pMsg = &errMsgWrongRowCol;
+ pEd = &aEdRowCell;
+ break;
+
+ case TABOPERR_NOCOLFORMULA:
+ pMsg = &errMsgNoColFormula;
+ pEd = &aEdFormulaRange;
+ break;
+
+ case TABOPERR_WRONGCOL:
+ pMsg = &errMsgWrongRowCol;
+ pEd = &aEdColCell;
+ break;
+
+ case TABOPERR_NOROWFORMULA:
+ pMsg = &errMsgNoRowFormula;
+ pEd = &aEdFormulaRange;
+ break;
+ }
+
+ ErrorBox( this, WinBits( WB_OK_CANCEL | WB_DEF_OK), *pMsg ).Execute();
+ pEd->GrabFocus();
+}
+
+//----------------------------------------------------------------------------
+
+BOOL lcl_Parse( const String& rString, ScDocument* pDoc, SCTAB nCurTab,
+ ScRefAddress& rStart, ScRefAddress& rEnd )
+{
+ BOOL bRet = FALSE;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ if ( rString.Search(':') != STRING_NOTFOUND )
+ bRet = ConvertDoubleRef( pDoc, rString, nCurTab, rStart, rEnd, eConv );
+ else
+ {
+ bRet = ConvertSingleRef( pDoc, rString, nCurTab, rStart, eConv );
+ rEnd = rStart;
+ }
+ return bRet;
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScTabOpDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnOk )
+ {
+ BYTE nMode = 3;
+ USHORT nError = 0;
+
+ // Zu ueberpruefen:
+ // 1. enthalten die Strings korrekte Tabellenkoordinaten/def.Namen?
+ // 2. IstFormelRang Zeile bei leerer Zeile bzw. Spalte bei leerer Spalte
+ // bzw. Einfachreferenz bei beidem?
+ // 3. Ist mindestens Zeile oder Spalte und Formel voll?
+
+ if (aEdFormulaRange.GetText().Len() == 0)
+ nError = TABOPERR_NOFORMULA;
+ else if (aEdRowCell.GetText().Len() == 0 &&
+ aEdColCell.GetText().Len() == 0)
+ nError = TABOPERR_NOCOLROW;
+ else if ( !lcl_Parse( aEdFormulaRange.GetText(), pDoc, nCurTab,
+ theFormulaCell, theFormulaEnd ) )
+ nError = TABOPERR_WRONGFORMULA;
+ else
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ if (aEdRowCell.GetText().Len() > 0)
+ {
+ if (!ConvertSingleRef( pDoc, aEdRowCell.GetText(), nCurTab,
+ theRowCell, eConv ))
+ nError = TABOPERR_WRONGROW;
+ else
+ {
+ if (aEdColCell.GetText().Len() == 0 &&
+ theFormulaCell.Col() != theFormulaEnd.Col())
+ nError = TABOPERR_NOCOLFORMULA;
+ else
+ nMode = 1;
+ }
+ }
+ if (aEdColCell.GetText().Len() > 0)
+ {
+ if (!ConvertSingleRef( pDoc, aEdColCell.GetText(), nCurTab,
+ theColCell, eConv ))
+ nError = TABOPERR_WRONGCOL;
+ else
+ {
+ if (nMode == 1) // beides
+ {
+ nMode = 2;
+ ConvertSingleRef( pDoc, aEdFormulaRange.GetText(), nCurTab,
+ theFormulaCell, eConv );
+ }
+ else if (theFormulaCell.Row() != theFormulaEnd.Row())
+ nError = TABOPERR_NOROWFORMULA;
+ else
+ nMode = 0;
+ }
+ }
+ }
+
+ if (nError)
+ RaiseError( (ScTabOpErr) nError );
+ else
+ {
+ ScTabOpParam aOutParam( theFormulaCell,
+ theFormulaEnd,
+ theRowCell,
+ theColCell,
+ nMode );
+ ScTabOpItem aOutItem( SID_TABOP, &aOutParam );
+
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( SID_TABOP,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aOutItem, 0L, 0L );
+ Close();
+ }
+ }
+ else if ( pBtn == &aBtnCancel )
+ Close();
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScTabOpDlg, GetFocusHdl, Control*, pCtrl )
+{
+ if( (pCtrl == (Control*)&aEdFormulaRange) || (pCtrl == (Control*)&aRBFormulaRange) )
+ pEdActive = &aEdFormulaRange;
+ else if( (pCtrl == (Control*)&aEdRowCell) || (pCtrl == (Control*)&aRBRowCell) )
+ pEdActive = &aEdRowCell;
+ else if( (pCtrl == (Control*)&aEdColCell) || (pCtrl == (Control*)&aRBColCell) )
+ pEdActive = &aEdColCell;
+ else
+ pEdActive = NULL;
+
+ if( pEdActive )
+ pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScTabOpDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ bDlgLostFocus = !IsActive();
+ return 0;
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/textdlgs.cxx b/sc/source/ui/miscdlgs/textdlgs.cxx
new file mode 100644
index 000000000000..a6747798efdb
--- /dev/null
+++ b/sc/source/ui/miscdlgs/textdlgs.cxx
@@ -0,0 +1,132 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+// ohne precompiled Headers uebersetzen !!!
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svxids.hrc>
+
+#include <editeng/flstitem.hxx>
+#include <sfx2/objsh.hxx>
+#include <svl/cjkoptions.hxx>
+
+#include "textdlgs.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include <svx/svxids.hrc>
+#include <svl/intitem.hxx>
+#include <svx/flagsdef.hxx>
+// -----------------------------------------------------------------------
+
+ScCharDlg::ScCharDlg( Window* pParent, const SfxItemSet* pAttr,
+ const SfxObjectShell* pDocShell ) :
+ SfxTabDialog ( pParent, ScResId( RID_SCDLG_CHAR ), pAttr ),
+ rOutAttrs ( *pAttr ),
+ rDocShell ( *pDocShell )
+{
+ FreeResource();
+
+ AddTabPage( RID_SVXPAGE_CHAR_NAME );
+ AddTabPage( RID_SVXPAGE_CHAR_EFFECTS );
+ AddTabPage( RID_SVXPAGE_CHAR_POSITION );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScCharDlg::PageCreated( USHORT nId, SfxTabPage &rPage )
+{
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
+ switch( nId )
+ {
+ case RID_SVXPAGE_CHAR_NAME:
+ {
+ SvxFontListItem aItem(*( (const SvxFontListItem*)
+ ( rDocShell.GetItem( SID_ATTR_CHAR_FONTLIST) ) ) );
+
+ aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
+ rPage.PageCreated(aSet);
+ }
+ break;
+
+ case RID_SVXPAGE_CHAR_EFFECTS:
+ aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_CASEMAP));
+ rPage.PageCreated(aSet);
+ break;
+
+ default:
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+ScParagraphDlg::ScParagraphDlg( Window* pParent, const SfxItemSet* pAttr ) :
+ SfxTabDialog ( pParent, ScResId( RID_SCDLG_PARAGRAPH ), pAttr ),
+ rOutAttrs ( *pAttr )
+{
+ FreeResource();
+
+ SvtCJKOptions aCJKOptions;
+
+ AddTabPage( RID_SVXPAGE_STD_PARAGRAPH );
+ AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH );
+ if ( aCJKOptions.IsAsianTypographyEnabled() )
+ AddTabPage( RID_SVXPAGE_PARA_ASIAN);
+ else
+ RemoveTabPage( RID_SVXPAGE_PARA_ASIAN );
+ AddTabPage( RID_SVXPAGE_TABULATOR );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScParagraphDlg::PageCreated( USHORT nId, SfxTabPage &rPage )
+{
+ switch( nId )
+ {
+ case RID_SVXPAGE_TABULATOR:
+ {
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
+ aSet.Put(SfxUInt16Item(SID_SVXTABULATORTABPAGE_CONTROLFLAGS,(TABTYPE_ALL &~TABTYPE_LEFT) |
+ (TABFILL_ALL &~TABFILL_NONE) ));
+ rPage.PageCreated(aSet);
+ }
+ break;
+ }
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/warnbox.cxx b/sc/source/ui/miscdlgs/warnbox.cxx
new file mode 100644
index 000000000000..4aeef5746004
--- /dev/null
+++ b/sc/source/ui/miscdlgs/warnbox.cxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include "warnbox.hxx"
+
+#include "scmod.hxx"
+#include "inputopt.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+
+
+// ============================================================================
+
+ScCbWarningBox::ScCbWarningBox( Window* pParent, const String& rMsgStr, bool bDefYes ) :
+ WarningBox( pParent, WB_YES_NO | (bDefYes ? WB_DEF_YES : WB_DEF_NO), rMsgStr )
+{
+ SetDefaultCheckBoxText();
+}
+
+sal_Int16 ScCbWarningBox::Execute()
+{
+ sal_Int16 nRet = (GetStyle() & WB_DEF_YES) ? RET_YES : RET_NO;
+ if( IsDialogEnabled() )
+ {
+ nRet = WarningBox::Execute();
+ if( GetCheckBoxState() )
+ DisableDialog();
+ }
+ return nRet;
+}
+
+bool ScCbWarningBox::IsDialogEnabled()
+{
+ return true;
+}
+
+void ScCbWarningBox::DisableDialog()
+{
+}
+
+
+// ----------------------------------------------------------------------------
+
+ScReplaceWarnBox::ScReplaceWarnBox( Window* pParent ) :
+ ScCbWarningBox( pParent, String( ScResId( STR_REPLCELLSWARN ) ), true )
+{
+ SetHelpId( HID_SC_REPLCELLSWARN );
+}
+
+bool ScReplaceWarnBox::IsDialogEnabled()
+{
+ return SC_MOD()->GetInputOptions().GetReplaceCellsWarn() == TRUE;
+}
+
+void ScReplaceWarnBox::DisableDialog()
+{
+ ScModule* pScMod = SC_MOD();
+ ScInputOptions aInputOpt( pScMod->GetInputOptions() );
+ aInputOpt.SetReplaceCellsWarn( FALSE );
+ pScMod->SetInputOptions( aInputOpt );
+}
+
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */