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.cxx2139
-rw-r--r--sc/source/ui/miscdlgs/acredlin.src260
-rw-r--r--sc/source/ui/miscdlgs/anyrefdg.cxx1011
-rw-r--r--sc/source/ui/miscdlgs/autofmt.cxx979
-rw-r--r--sc/source/ui/miscdlgs/conflictsdlg.cxx894
-rw-r--r--sc/source/ui/miscdlgs/conflictsdlg.src113
-rw-r--r--sc/source/ui/miscdlgs/crdlg.cxx87
-rw-r--r--sc/source/ui/miscdlgs/crnrdlg.cxx1175
-rw-r--r--sc/source/ui/miscdlgs/delcldlg.cxx120
-rw-r--r--sc/source/ui/miscdlgs/delcodlg.cxx180
-rw-r--r--sc/source/ui/miscdlgs/filldlg.cxx377
-rw-r--r--sc/source/ui/miscdlgs/groupdlg.cxx83
-rw-r--r--sc/source/ui/miscdlgs/highred.cxx302
-rw-r--r--sc/source/ui/miscdlgs/highred.src138
-rw-r--r--sc/source/ui/miscdlgs/inscldlg.cxx120
-rw-r--r--sc/source/ui/miscdlgs/inscodlg.cxx372
-rw-r--r--sc/source/ui/miscdlgs/instbdlg.cxx434
-rw-r--r--sc/source/ui/miscdlgs/instbdlg.src194
-rw-r--r--sc/source/ui/miscdlgs/lbseldlg.cxx108
-rw-r--r--sc/source/ui/miscdlgs/linkarea.cxx369
-rw-r--r--sc/source/ui/miscdlgs/linkarea.src126
-rw-r--r--sc/source/ui/miscdlgs/makefile.mk127
-rw-r--r--sc/source/ui/miscdlgs/mtrindlg.cxx186
-rw-r--r--sc/source/ui/miscdlgs/mvtabdlg.cxx205
-rw-r--r--sc/source/ui/miscdlgs/namecrea.cxx79
-rw-r--r--sc/source/ui/miscdlgs/namepast.cxx133
-rw-r--r--sc/source/ui/miscdlgs/optsolver.cxx1079
-rw-r--r--sc/source/ui/miscdlgs/protectiondlg.cxx161
-rw-r--r--sc/source/ui/miscdlgs/protectiondlg.src131
-rw-r--r--sc/source/ui/miscdlgs/redcom.cxx186
-rw-r--r--sc/source/ui/miscdlgs/retypepassdlg.cxx544
-rw-r--r--sc/source/ui/miscdlgs/retypepassdlg.src325
-rw-r--r--sc/source/ui/miscdlgs/scuiautofmt.cxx476
-rw-r--r--sc/source/ui/miscdlgs/sharedocdlg.cxx235
-rw-r--r--sc/source/ui/miscdlgs/sharedocdlg.src111
-rw-r--r--sc/source/ui/miscdlgs/shtabdlg.cxx111
-rw-r--r--sc/source/ui/miscdlgs/simpref.cxx257
-rw-r--r--sc/source/ui/miscdlgs/solveroptions.cxx492
-rw-r--r--sc/source/ui/miscdlgs/solverutil.cxx229
-rw-r--r--sc/source/ui/miscdlgs/solvrdlg.cxx316
-rw-r--r--sc/source/ui/miscdlgs/strindlg.cxx89
-rw-r--r--sc/source/ui/miscdlgs/tabbgcolordlg.cxx198
-rw-r--r--sc/source/ui/miscdlgs/tabopdlg.cxx371
-rw-r--r--sc/source/ui/miscdlgs/textdlgs.cxx140
-rw-r--r--sc/source/ui/miscdlgs/warnbox.cxx91
45 files changed, 15853 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..1f95a3db251d
--- /dev/null
+++ b/sc/source/ui/miscdlgs/acredlin.cxx
@@ -0,0 +1,2139 @@
+/*************************************************************************
+ *
+ * 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, sal_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=sal_False;
+ bIsRejectable=sal_False;
+ bIsAcceptable=sal_False;
+ nTable=SCTAB_MAX;
+ nCol=SCCOL_MAX;
+ nRow=SCROW_MAX;
+}
+
+ScRedlinData::~ScRedlinData()
+{
+ nInfo=RD_SPECIAL_NONE;
+ nActionNo=0;
+ pData=NULL;
+ bDisabled=sal_False;
+ bIsRejectable=sal_False;
+ bIsAcceptable=sal_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=sal_False;
+ bNoSelection=sal_False;
+ bNeedsUpdate=sal_False;
+ bIgnoreMsg=sal_False;
+ nAcceptCount=0;
+ nRejectCount=0;
+ bAcceptEnableFlag=sal_True;
+ bRejectEnableFlag=sal_True;
+ bHasFilterEntry=sal_False;
+ bUseColor=sal_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(sal_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->SetStyle(pTheView->GetStyle()|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=sal_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=sal_False;
+ bNeedsUpdate=sal_False;
+ bIgnoreMsg=sal_False;
+ nAcceptCount=0;
+ nRejectCount=0;
+ bAcceptEnableFlag=sal_True;
+ bRejectEnableFlag=sal_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(sal_uInt16 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((sal_uInt16)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(sal_False);
+
+ pTheView->Clear();
+ pTheView->SetUpdateMode(sal_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;
+}
+
+
+sal_Bool ScAcceptChgDlg::IsValidAction(const ScChangeAction* pScChangeAction)
+{
+ if(pScChangeAction==NULL) return sal_False;
+
+ sal_Bool bFlag=sal_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, sal_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=sal_True;
+ }
+ }
+ else
+ {
+ bFlag=sal_True;
+ }
+ }
+
+ return bFlag;
+}
+
+SvLBoxEntry* ScAcceptChgDlg::InsertChangeAction(const ScChangeAction* pScChangeAction,
+ ScChangeActionState /* eState */, SvLBoxEntry* pParent,
+ sal_Bool bDelMaster,sal_Bool bDisabled,sal_uLong nPos)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ if(pScChangeAction==NULL || pChanges==NULL) return NULL;
+
+ SvLBoxEntry* pEntry=NULL;
+
+ sal_Bool bFlag=sal_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=sal_False;
+ pNewData->bIsAcceptable=sal_False;
+ }
+ else
+ {
+ aString=*MakeTypeString(eType);
+ pScChangeAction->GetDescription( aDesc, pDoc, sal_True);
+ }
+ }
+ else
+ {
+ aString=*MakeTypeString(eType);
+
+ if(bDelMaster)
+ {
+ pScChangeAction->GetDescription( aDesc, pDoc,sal_True);
+ pNewData->bDisabled=sal_True;
+ pNewData->bIsRejectable=sal_False;
+ }
+ else
+ pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
+
+ }
+
+ aString+='\t';
+ pScChangeAction->GetRefString(aRefStr, pDoc, sal_True);
+ aString+=aRefStr;
+ aString+='\t';
+
+ sal_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=sal_False;
+ }
+ else
+ {
+ aString+='\t';
+ aString+='\t';
+ bIsGenerated=sal_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=sal_True;
+ bFlag=sal_True;
+ }
+ }
+ else if(!bIsGenerated)
+ {
+ bHasFilterEntry=sal_True;
+ bFlag=sal_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,
+ sal_Bool bDelMaster,sal_Bool bDisabled,sal_uLong nPos)
+{
+
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ if(pScChangeAction==NULL || pChanges==NULL) return NULL;
+
+ sal_Bool bIsGenerated=pChanges->IsGenerated(pScChangeAction->GetActionNumber());
+
+ SvLBoxEntry* pEntry=NULL;
+
+ int bFlag=sal_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=sal_True;
+ }
+ }
+ else if(pScChangeAction->GetState()==eState && !bIsGenerated)
+ {
+ bFlag=sal_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=sal_False;
+ pNewData->bIsAcceptable=sal_False;
+ }
+ else
+ {
+ aString=*MakeTypeString(eType);
+ pScChangeAction->GetDescription( aDesc, pDoc, sal_True);
+ }
+ }
+ else
+ {
+ aString=*MakeTypeString(eType);
+
+ if(bDelMaster)
+ {
+ pScChangeAction->GetDescription( aDesc, pDoc,sal_True);
+ pNewData->bDisabled=sal_True;
+ pNewData->bIsRejectable=sal_False;
+ }
+ else
+ pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
+
+ }
+
+ aString+='\t';
+ pScChangeAction->GetRefString(aRefStr, pDoc, sal_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, sal_uLong nSpecial)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ SvLBoxEntry* pEntry=NULL;
+
+ if(pScChangeAction==NULL || pChanges==NULL) return NULL;
+
+ sal_Bool bIsGenerated=pChanges->IsGenerated(pScChangeAction->GetActionNumber());
+
+ sal_Bool bFlag=sal_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=sal_True;
+ }
+ }
+ else if(!bIsGenerated)
+ bFlag=sal_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, sal_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=sal_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=sal_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=sal_False;
+ }
+
+ return SfxModelessDialog::PreNotify(rNEvt);
+}
+
+
+void ScAcceptChgDlg::UpdateView()
+{
+ bNeedsUpdate=sal_False;
+ DateTime aDateTime;
+ SvLBoxEntry* pParent=NULL;
+ ScChangeTrack* pChanges=NULL;
+ const ScChangeAction* pScChangeAction=NULL;
+ bAcceptEnableFlag=sal_True;
+ bRejectEnableFlag=sal_True;
+ SetPointer(Pointer(POINTER_WAIT));
+ pTheView->SetUpdateMode(sal_False);
+ sal_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;
+ sal_Bool bTheFlag=sal_False;
+
+ while(pScChangeAction!=NULL)
+ {
+ bHasFilterEntry=sal_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=sal_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(sal_True);
+ }
+ else
+ {
+ sal_Bool bTestFlag=bHasFilterEntry;
+ bHasFilterEntry=sal_False;
+ if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag)
+ pTheView->RemoveEntry(pParent);
+ }
+ }
+
+ pScChangeAction=pScChangeAction->GetNext();
+ }
+
+ if( bTheFlag && (!pDoc->IsDocEditable() || pChanges->IsProtected()) )
+ bTheFlag=sal_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(sal_True);
+ }
+ if(nRejectCount>0)
+ {
+ pParent=pTheView->InsertEntry(
+ aStrAllRejected, static_cast< RedlinData * >(NULL),
+ static_cast< SvLBoxEntry * >(NULL));
+ pParent->EnableChildsOnDemand(sal_True);
+ }
+ pTheView->SetUpdateMode(sal_True);
+ SetPointer(Pointer(POINTER_ARROW));
+ SvLBoxEntry* pEntry=pTheView->First();
+ if(pEntry!=NULL)
+ {
+ pTheView->Select(pEntry);
+ }
+}
+
+//----------------------------------------------------------------------------
+sal_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 )
+{
+ sal_uInt16 nId =ScSimpleRefDlgWrapper::GetChildWindowId();
+
+ ScSimpleRefDlgWrapper::SetDefaultPosSize(GetPosPixel(),GetSizePixel(),sal_True);
+
+ SC_MOD()->SetRefDialog( nId, sal_True );
+
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+ ScSimpleRefDlgWrapper* pWnd =(ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
+
+ if(pWnd!=NULL)
+ {
+// bSimpleRefDlgStarted=sal_True;
+ sal_uInt16 nAcceptId=ScAcceptChgDlgWrapper::GetChildWindowId();
+ pViewFrm->ShowChildWindow(nAcceptId,sal_False);
+ pWnd->SetCloseHdl(LINK( this, ScAcceptChgDlg,RefInfoHandle));
+ pWnd->SetRefString(pTPFilter->GetRange());
+ pWnd->SetAutoReOpen(sal_False);
+ Window* pWin=pWnd->GetWindow();
+ pWin->SetPosSizePixel(GetPosPixel(),GetSizePixel());
+ Hide();
+ pWin->SetText(GetText());
+ pWnd->StartRefInput();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, RefInfoHandle, String*, pResult)
+{
+ sal_uInt16 nId;
+
+// bSimpleRefDlgStarted=sal_False;
+ ScSimpleRefDlgWrapper::SetAutoReOpen(sal_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, sal_True );
+ }
+ else
+ {
+ nId = ScAcceptChgDlgWrapper::GetChildWindowId();
+ pViewFrm->SetChildWindow( nId, sal_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=sal_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=sal_False;
+ return 0;
+}
+IMPL_LINK( ScAcceptChgDlg, AcceptHandle, SvxTPView*, pRef )
+{
+ SetPointer(Pointer(POINTER_WAIT));
+
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ bIgnoreMsg=sal_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,sal_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=sal_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=sal_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=sal_False;
+
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, AcceptAllHandle, SvxTPView*, EMPTYARG )
+{
+ SetPointer(Pointer(POINTER_WAIT));
+
+ bIgnoreMsg=sal_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=sal_False;
+ SetPointer(Pointer(POINTER_ARROW));
+
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, SelectHandle, SvxRedlinTable*, EMPTYARG )
+{
+ if(!bNoSelection)
+ {
+ aSelectionTimer.Start();
+ }
+ bNoSelection=sal_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());
+ }
+}
+
+sal_Bool ScAcceptChgDlg::InsertContentChilds(ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
+{
+ sal_Bool bTheTestFlag=sal_True;
+ ScRedlinData *pEntryData=(ScRedlinData *)(pParent->GetUserData());
+ const ScChangeAction* pScChangeAction = (ScChangeAction*) pEntryData->pData;
+ sal_Bool bParentInserted = sal_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 = sal_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 sal_True;
+
+ SvLBoxEntry* pOriginal=InsertChangeActionContent(pCChild,pParent,RD_SPECIAL_CONTENT);
+ if(pOriginal!=NULL)
+ {
+ bTheTestFlag=sal_False;
+ ScRedlinData *pParentData=(ScRedlinData *)(pOriginal->GetUserData());
+ pParentData->pData=(void *)pScChangeAction;
+ pParentData->nActionNo=pScChangeAction->GetActionNumber();
+ pParentData->bIsAcceptable=pScChangeAction->IsRejectable(); // select old value
+ pParentData->bIsRejectable=sal_False;
+ pParentData->bDisabled=sal_False;
+ }
+ while(pCChild!=NULL)
+ {
+ if(pCChild->GetState()==SC_CAS_VIRGIN)
+ {
+ pEntry=InsertChangeActionContent(pCChild,pParent,RD_SPECIAL_NONE);
+
+ if(pEntry!=NULL)
+ bTheTestFlag=sal_False;
+ }
+ pCChild=(const ScChangeActionContent*)pActionTable->Next();
+ }
+
+ if ( !bParentInserted )
+ {
+ pEntry=InsertChangeActionContent((const ScChangeActionContent*)
+ pScChangeAction,pParent,RD_SPECIAL_NONE);
+
+ if(pEntry!=NULL)
+ {
+ bTheTestFlag=sal_False;
+ ScRedlinData *pParentData=(ScRedlinData *)(pEntry->GetUserData());
+ pParentData->pData=(void *)pScChangeAction;
+ pParentData->nActionNo=pScChangeAction->GetActionNumber();
+ pParentData->bIsAcceptable=pScChangeAction->IsClickable();
+ pParentData->bIsRejectable=sal_False;
+ pParentData->bDisabled=sal_False;
+ }
+ }
+
+ return bTheTestFlag;
+
+}
+
+sal_Bool ScAcceptChgDlg::InsertAcceptedORejected(SvLBoxEntry* pParent)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ sal_Bool bTheTestFlag=sal_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=sal_False;
+ pScChangeAction=pScChangeAction->GetNext();
+ }
+ return bTheTestFlag;
+}
+
+sal_Bool ScAcceptChgDlg::InsertChilds(ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ sal_Bool bTheTestFlag=sal_True;
+ SvLBoxEntry* pEntry=NULL;
+ const ScChangeAction* pChild=(const ScChangeAction*)pActionTable->First();
+ while(pChild!=NULL)
+ {
+ pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,sal_False,sal_True);
+
+ if(pEntry!=NULL)
+ {
+ bTheTestFlag=sal_False;
+
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ pEntryData->bIsRejectable=sal_False;
+ pEntryData->bIsAcceptable=sal_False;
+ pEntryData->bDisabled=sal_True;
+
+ if(pChild->IsDialogParent())
+ {
+
+ //pEntry->EnableChildsOnDemand(sal_True);
+ Expand(pChanges,pChild,pEntry);
+ }
+ }
+ pChild=pActionTable->Next();
+ }
+ return bTheTestFlag;
+}
+sal_Bool ScAcceptChgDlg::InsertDeletedChilds(const ScChangeAction* pScChangeAction,
+ ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ sal_Bool bTheTestFlag=sal_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,sal_False,sal_True);
+ else
+ pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,sal_True,sal_True);
+
+ if(pEntry!=NULL)
+ {
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ pEntryData->bIsRejectable=sal_False;
+ pEntryData->bIsAcceptable=sal_False;
+ pEntryData->bDisabled=sal_True;
+
+ bTheTestFlag=sal_False;
+ if ( pChild->IsDialogParent() )
+ {
+ Expand(pChanges,pChild,pEntry);
+ /*
+ pChanges->GetDependents((ScChangeAction*) pChild,aDelActionTable);
+ if(aDelActionTable.First()!=NULL)
+ {
+ pEntry->EnableChildsOnDemand(sal_True);
+ }
+ aDelActionTable.Clear();
+ */
+ }
+ }
+ pChild=pActionTable->Next();
+ }
+ return bTheTestFlag;
+}
+
+sal_Bool ScAcceptChgDlg::Expand(ScChangeTrack* pChanges,const ScChangeAction* pScChangeAction,
+ SvLBoxEntry* pEntry,sal_Bool bFilter)
+{
+ sal_Bool bTheTestFlag=sal_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())
+ {
+ sal_Bool bTheTestFlag=sal_True;
+ pEntry->EnableChildsOnDemand(sal_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 (sal_uLong) sal_True;
+}
+
+
+void ScAcceptChgDlg::AppendChanges(ScChangeTrack* pChanges,sal_uLong nStartAction,
+ sal_uLong nEndAction, sal_uLong /* nPos */)
+{
+ if(pChanges!=NULL)
+ {
+ DateTime aDateTime;
+ SvLBoxEntry* pParent=NULL;
+ const ScChangeAction* pScChangeAction=NULL;
+ bAcceptEnableFlag=sal_True;
+ bRejectEnableFlag=sal_True;
+ SetPointer(Pointer(POINTER_WAIT));
+ pTheView->SetUpdateMode(sal_False);
+
+ ScChangeActionTable ActionTable;
+ sal_Bool bTheFlag=sal_False;
+
+ sal_Bool bFilterFlag=pTPFilter->IsDate()||pTPFilter->IsRange()||
+ pTPFilter->IsAuthor()||pTPFilter->IsComment();
+
+ bUseColor=bFilterFlag;
+
+ for(sal_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=sal_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(sal_True);
+ }
+ else
+ {
+ sal_Bool bTestFlag=bHasFilterEntry;
+ bHasFilterEntry=sal_False;
+ if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag)
+ pTheView->RemoveEntry(pParent);
+ }
+ }
+
+ pScChangeAction=pScChangeAction->GetNext();
+ }
+
+ if( bTheFlag && (!pDoc->IsDocEditable() || pChanges->IsProtected()) )
+ bTheFlag=sal_False;
+
+ pTPView->EnableAccept(bTheFlag);
+ pTPView->EnableAcceptAll(bTheFlag);
+ pTPView->EnableReject(bTheFlag);
+ pTPView->EnableRejectAll(bTheFlag);
+
+ pTheView->SetUpdateMode(sal_True);
+ SetPointer(Pointer(POINTER_ARROW));
+ }
+}
+
+void ScAcceptChgDlg::RemoveEntrys(sal_uLong nStartAction,sal_uLong nEndAction)
+{
+
+ pTheView->SetUpdateMode(sal_False);
+
+ SvLBoxEntry* pEntry=pTheView->GetCurEntry();
+
+ ScRedlinData *pEntryData=NULL;
+
+ if(pEntry!=NULL)
+ pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+
+ sal_uLong nAction=0;
+ if(pEntryData!=NULL)
+ {
+ nAction=pEntryData->nActionNo;
+ }
+
+ if(nAction>=nStartAction && nAction<=nEndAction)
+ {
+ pTheView->SetCurEntry(pTheView->GetModel()->GetEntry(0));
+ }
+
+ sal_Bool bRemove=sal_False;
+
+ // MUST do it backwards, don't delete parents before children and GPF
+ pEntry=pTheView->Last();
+ while(pEntry!=NULL)
+ {
+ bRemove=sal_False;
+ pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ nAction=pEntryData->nActionNo;
+
+ if(nStartAction<=nAction && nAction<=nEndAction) bRemove=sal_True;
+
+
+ }
+ SvLBoxEntry* pPrevEntry = pTheView->Prev(pEntry);
+
+ if(bRemove)
+ {
+ //delete pEntryData;
+ pTheView->RemoveEntry(pEntry);
+ }
+ pEntry=pPrevEntry;
+ }
+ pTheView->SetUpdateMode(sal_True);
+
+}
+
+void ScAcceptChgDlg::UpdateEntrys(ScChangeTrack* pChgTrack, sal_uLong nStartAction,sal_uLong nEndAction)
+{
+ pTheView->SetUpdateMode(sal_False);
+
+ sal_uLong nPos=LIST_APPEND;
+
+ sal_Bool bRemove=sal_False;
+
+ SvLBoxEntry* pEntry=pTheView->First();
+ SvLBoxEntry* pNextEntry = (pEntry ? pTheView->NextSibling(pEntry) : NULL);
+ SvLBoxEntry* pLastEntry=NULL;
+ while(pEntry!=NULL)
+ {
+ bRemove=sal_False;
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ ScChangeAction* pScChangeAction=
+ (ScChangeAction*) pEntryData->pData;
+
+ sal_uLong nAction=pScChangeAction->GetActionNumber();
+
+ if(nStartAction<=nAction && nAction<=nEndAction) bRemove=sal_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(sal_True);
+
+}
+
+IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack*, pChgTrack)
+{
+// if(bScAcceptChgDlgIsDead) return 0;
+
+ ScChangeTrackMsgQueue& aMsgQueue= pChgTrack->GetMsgQueue();
+
+ ScChangeTrackMsgInfo* pTrackInfo=aMsgQueue.Get();
+ sal_uLong nStartAction;
+ sal_uLong nEndAction;
+
+ while(pTrackInfo!=NULL)
+ {
+ nStartAction=pTrackInfo->nStartAction;
+ nEndAction=pTrackInfo->nEndAction;
+
+ if(!bIgnoreMsg)
+ {
+ bNoSelection=sal_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=sal_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(sal_True);
+ aAcceptChgCtr.ShowFilterPage();
+ RefHandle(NULL);
+
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, UpdateSelectionHdl, Timer*, EMPTYARG )
+{
+ ScTabView* pTabView = pViewData->GetView();
+
+ sal_Bool bAcceptFlag = sal_True;
+ sal_Bool bRejectFlag = sal_True;
+ sal_Bool bContMark = sal_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() )
+ {
+ sal_Bool bSetCursor = !pTheView->NextSelected( pEntry );
+ pTabView->MarkRange( rBigRange.MakeRange(), bSetCursor, bContMark );
+ bContMark = sal_True;
+ }
+ }
+ }
+ else
+ {
+ bAcceptFlag = sal_False;
+ bRejectFlag = sal_False;
+ }
+ bAcceptEnableFlag = bAcceptFlag;
+ bRejectEnableFlag = bRejectFlag;
+
+ pEntry = pTheView->NextSelected( pEntry );
+ }
+
+ ScChangeTrack* pChanges = pDoc->GetChangeTrack();
+ sal_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();
+ }
+
+ sal_uInt16 nSortedCol= pTheView->GetSortedCol();
+
+ if(nSortedCol!=0xFFFF)
+ {
+ sal_uInt16 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,sal_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);
+ }
+ }
+
+ sal_uInt16 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,sal_False);
+ }
+ }
+ }
+ else
+ {
+ sal_Bool bSortDir=pTheView->GetSortDirection();
+ sal_uInt16 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())
+ {
+ sal_uInt16 nCount=(sal_uInt16)aStr.ToInt32();
+
+ for(sal_uInt16 i=0;i<nCount;i++)
+ {
+ xub_StrLen n1 = aStr.Search(';');
+ aStr.Erase(0, n1+1);
+ pTheView->SetTab(i,(sal_uInt16)aStr.ToInt32(),MAP_PIXEL);
+ }
+ }
+}
+
+//-------------------------------------------------------------------------
+
+void ScAcceptChgDlg::FillInfo(SfxChildWinInfo& rInfo) const
+{
+ SfxModelessDialog::FillInfo(rInfo);
+ rInfo.aExtraString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "AcceptChgDat:(" ));
+
+ sal_uInt16 nCount=pTheView->TabCount();
+
+ rInfo.aExtraString += String::CreateFromInt32(nCount);
+ rInfo.aExtraString += ';';
+ for(sal_uInt16 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,sal_False,sal_False,sal_False );
+
+ pTheView->SetCommentParams(&aSearchParam);
+
+ pTheView->UpdateFilterTest();
+ }
+}
+
+//UNUSED2008-05 void ScAcceptChgDlg::SetMyStaticData()
+//UNUSED2008-05 {
+//UNUSED2008-05 }
+
+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)
+ {
+ sal_uInt16 nLeftKind=pLeftItem->IsA();
+ sal_uInt16 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;
+}
+
diff --git a/sc/source/ui/miscdlgs/acredlin.src b/sc/source/ui/miscdlgs/acredlin.src
new file mode 100644
index 000000000000..269746cf0fa1
--- /dev/null
+++ b/sc/source/ui/miscdlgs/acredlin.src
@@ -0,0 +1,260 @@
+/*************************************************************************
+ *
+ * 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 = CMD_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
+ {
+ HelpID = "sc:Edit:RID_SCDLG_CHANGES:ED_ASSIGN";
+ Hide = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 119 ) ;
+ Size = MAP_APPFONT ( 128 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_ASSIGN
+ {
+ HelpID = "sc:ImageButton:RID_SCDLG_CHANGES: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..bd058da042cb
--- /dev/null
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -0,0 +1,1011 @@
+/*************************************************************************
+ *
+ * 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( sal_False )
+ , bAccInserted( sal_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( sal_True );
+
+ ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
+ if ( pInputHdl )
+ pInputHdl->ResetDelayTimer(); // stop the timer for disabling the input line
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::enableInput( sal_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,sal_True /* sal_False */);
+ if(sal_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=sal_True;
+ ScViewData* pViewData=ScDocShell::GetViewData();
+ if ( pViewData )
+ {
+ ScDocument* pDoc=pViewData->GetDocument();
+ ScTabViewShell* pTabViewShell=pViewData->GetViewShell();
+
+ ScRangeList aRangeList;
+
+ pTabViewShell->DoneRefMode( sal_False );
+ pTabViewShell->ClearHighlightRanges();
+
+ if( ParseWithNames( aRangeList, rStr, pDoc ) )
+ {
+ ScRange* pRangeEntry = aRangeList.First();
+
+ sal_uInt16 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 ) );
+
+ sal_uInt16 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=sal_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( sal_False );
+ pTabViewShell->ClearHighlightRanges();
+
+ pScTokA->Reset();
+ const ScToken* pToken = static_cast<const ScToken*>(pScTokA->GetNextReference());
+
+ sal_uInt16 nIndex=0;
+
+ while(pToken!=NULL)
+ {
+ sal_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( sal_Bool bDoneRefMode )
+{
+ ScViewData* pViewData=ScDocShell::GetViewData();
+
+ if( pViewData && /*!pRefEdit &&*/ bHighLightRef && bEnableColorRef)
+ {
+ ScTabViewShell* pTabViewShell=pViewData->GetViewShell();
+
+ if(pTabViewShell!=NULL)
+ {
+ // bDoneRefMode is sal_False when called from before SetReference.
+ // In that case, RefMode was just started and must not be ended now.
+
+ if ( bDoneRefMode )
+ pTabViewShell->DoneRefMode( sal_False );
+ pTabViewShell->ClearHighlightRanges();
+ }
+ bHighLightRef=sal_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, sal_False, sal_False );
+ pViewShell->MoveCursorAbs( pRange->aEnd.Col(),
+ pRange->aEnd.Row(), SC_FOLLOW_JUMP, sal_True, sal_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(sal_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( sal_True );
+ break;
+ }
+ return sal_True;
+}
+//----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::RefInputDone( sal_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 = sal_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();
+ sal_uInt16 nChildren = m_pWindow->GetChildCount();
+ for ( sal_uInt16 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
+ sal_uInt16 nChildren = m_pWindow->GetChildCount();
+ pHiddenMarks = new sal_Bool [nChildren];
+ for (sal_uInt16 i = 0; i < nChildren; i++)
+ {
+ pHiddenMarks[i] = sal_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] = sal_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 = sal_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( sal_True ); // finish ref input
+ }
+ else
+ {
+ m_pDlg->RefInputDone( sal_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();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool ScFormulaReferenceHelper::DoClose( sal_uInt16 nId )
+{
+ SfxApplication* pSfxApp = SFX_APP();
+
+ SetDispatcherLock( sal_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, sal_False, pMyViewFrm );
+
+ pSfxApp->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) );
+
+ ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
+ if ( pScViewShell )
+ pScViewShell->UpdateInputHandler(sal_True);
+
+ return sal_True;
+}
+void ScFormulaReferenceHelper::SetDispatcherLock( sal_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( sal_False );
+
+ EnableSpreadsheets();
+}
+void ScFormulaReferenceHelper::EnableSpreadsheets(sal_Bool bFlag, sal_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,sal_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, sal_uInt16 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().getLength()==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(sal_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( sal_False );
+
+ m_aHelper.EnableSpreadsheets();
+
+ m_aHelper.Init();
+
+ m_aHelper.SetDispatcherLock( sal_True );
+ //@Test
+ //SFX_APPWINDOW->Disable(sal_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(sal_False);
+ SetDispatcherLock( sal_False ); //! here and in DoClose ?
+
+ ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
+ if( pScViewShell )
+ pScViewShell->UpdateInputHandler(sal_True);
+
+ //SFX_APPWINDOW->Enable(sal_True,sal_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 );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+sal_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 );
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool __EXPORT ScRefHandler::IsRefInputMode() const
+{
+ return m_rWindow.IsVisible(); // nur wer sichtbar ist kann auch Referenzen bekommen
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool __EXPORT ScRefHandler::DoClose( sal_uInt16 nId )
+{
+ m_aHelper.DoClose(nId);
+ return sal_True;
+}
+
+void ScRefHandler::SetDispatcherLock( sal_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
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool __EXPORT ScRefHandler::IsTableLocked() const
+{
+ // per Default kann bei Referenzeingabe auch die Tabelle umgeschaltet werden
+
+ return sal_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 )
+//{
+// sal_uInt16 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( sal_False );
+// m_aHelper.EnableSpreadsheets();
+// m_aHelper.SetDispatcherLock( sal_True );
+// aTimer.Start();
+// }
+// else
+// {
+// m_aHelper.enableInput( sal_True );
+// m_aHelper.SetDispatcherLock( sal_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 )\
+ {\
+ sal_uInt16 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( sal_False );\
+ m_aHelper.EnableSpreadsheets();\
+ m_aHelper.SetDispatcherLock( sal_True );\
+ aTimer.Start();\
+ }\
+ else\
+ {\
+ m_aHelper.enableInput( sal_True );\
+ m_aHelper.SetDispatcherLock( sal_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( sal_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( sal_Bool bForced )
+{
+ m_aHelper.RefInputDone( bForced );
+}
+
diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx
new file mode 100644
index 000000000000..f93deead5216
--- /dev/null
+++ b/sc/source/ui/miscdlgs/autofmt.cxx
@@ -0,0 +1,979 @@
+/*************************************************************************
+ *
+ * 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"
+//CHINA001 #include "strindlg.hxx"
+#include "miscdlgs.hrc"
+#include "autofmt.hxx"
+#include "scresid.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+
+#define FRAME_OFFSET 4
+
+
+//CHINA001 //========================================================================
+//CHINA001 // AutoFormat-Dialog:
+//CHINA001
+//CHINA001 ScAutoFormatDlg::ScAutoFormatDlg( Window* pParent,
+//CHINA001 ScAutoFormat* pAutoFormat,
+//CHINA001 const ScAutoFormatData* pSelFormatData,
+//CHINA001 ScDocument* pDoc ) :
+//CHINA001
+//CHINA001 ModalDialog ( pParent, ScResId( RID_SCDLG_AUTOFORMAT ) ),
+//CHINA001 //
+//CHINA001 aLbFormat ( this, ScResId( LB_FORMAT ) ),
+//CHINA001 aFlFormat ( this, ScResId( FL_FORMAT ) ),
+//CHINA001 pWndPreview ( new ScAutoFmtPreview( this, ScResId( WND_PREVIEW ), pDoc ) ),
+//CHINA001 aBtnNumFormat ( this, ScResId( BTN_NUMFORMAT ) ),
+//CHINA001 aBtnBorder ( this, ScResId( BTN_BORDER ) ),
+//CHINA001 aBtnFont ( this, ScResId( BTN_FONT ) ),
+//CHINA001 aBtnPattern ( this, ScResId( BTN_PATTERN ) ),
+//CHINA001 aBtnAlignment ( this, ScResId( BTN_ALIGNMENT ) ),
+//CHINA001 aBtnAdjust ( this, ScResId( BTN_ADJUST ) ),
+//CHINA001 aFlFormatting ( this, ScResId( FL_FORMATTING ) ),
+//CHINA001 aBtnOk ( this, ScResId( BTN_OK ) ),
+//CHINA001 aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+//CHINA001 aBtnHelp ( this, ScResId( BTN_HELP ) ),
+//CHINA001 aBtnAdd ( this, ScResId( BTN_ADD ) ),
+//CHINA001 aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+//CHINA001 aBtnMore ( this, ScResId( BTN_MORE ) ),
+//CHINA001 aBtnRename ( this, ScResId( BTN_RENAME ) ),
+//CHINA001 aStrTitle ( ScResId( STR_ADD_TITLE ) ),
+//CHINA001 aStrLabel ( ScResId( STR_ADD_LABEL ) ),
+//CHINA001 aStrRename ( ScResId( STR_RENAME_TITLE ) ),
+//CHINA001 aStrClose ( ScResId( STR_BTN_CLOSE ) ),
+//CHINA001 aStrDelTitle ( ScResId( STR_DEL_TITLE ) ),
+//CHINA001 aStrDelMsg ( ScResId( STR_DEL_MSG ) ) ,
+//CHINA001 //
+//CHINA001 nIndex ( 0 ),
+//CHINA001 bFmtInserted ( sal_False ),
+//CHINA001 bCoreDataChanged( sal_False ),
+//CHINA001 pFormat ( pAutoFormat ),
+//CHINA001 pSelFmtData ( pSelFormatData )
+//CHINA001 {
+//CHINA001 Init();
+//CHINA001 pWndPreview->NotifyChange( (*pFormat)[0] );
+//CHINA001 FreeResource();
+//CHINA001 }
+//CHINA001
+//CHINA001 //------------------------------------------------------------------------
+//CHINA001
+//CHINA001 ScAutoFormatDlg::~ScAutoFormatDlg()
+//CHINA001 {
+//CHINA001 delete pWndPreview;
+//CHINA001 }
+//CHINA001
+//CHINA001 //------------------------------------------------------------------------
+//CHINA001
+//CHINA001 void ScAutoFormatDlg::Init()
+//CHINA001 {
+//CHINA001 sal_uInt16 nCount;
+//CHINA001 String aEntry;
+//CHINA001
+//CHINA001 aLbFormat .SetSelectHdl( LINK( this, ScAutoFormatDlg, SelFmtHdl ) );
+//CHINA001 aBtnNumFormat.SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+//CHINA001 aBtnBorder .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+//CHINA001 aBtnFont .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+//CHINA001 aBtnPattern .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+//CHINA001 aBtnAlignment.SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+//CHINA001 aBtnAdjust .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+//CHINA001 aBtnAdd .SetClickHdl ( LINK( this, ScAutoFormatDlg, AddHdl ) );
+//CHINA001 aBtnRemove .SetClickHdl ( LINK( this, ScAutoFormatDlg, RemoveHdl ) );
+//CHINA001 aBtnOk .SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) );
+//CHINA001 aBtnCancel .SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) );
+//CHINA001 aBtnRename .SetClickHdl ( LINK( this, ScAutoFormatDlg, RenameHdl ) );
+//CHINA001 aLbFormat .SetDoubleClickHdl( LINK( this, ScAutoFormatDlg, DblClkHdl ) );
+//CHINA001
+//CHINA001 aBtnMore.AddWindow( &aBtnRename );
+//CHINA001 aBtnMore.AddWindow( &aBtnNumFormat );
+//CHINA001 aBtnMore.AddWindow( &aBtnBorder );
+//CHINA001 aBtnMore.AddWindow( &aBtnFont );
+//CHINA001 aBtnMore.AddWindow( &aBtnPattern );
+//CHINA001 aBtnMore.AddWindow( &aBtnAlignment );
+//CHINA001 aBtnMore.AddWindow( &aBtnAdjust );
+//CHINA001 aBtnMore.AddWindow( &aFlFormatting );
+//CHINA001
+//CHINA001 nCount = pFormat->GetCount();
+//CHINA001
+//CHINA001 for ( sal_uInt16 i = 0; i < nCount; i++ )
+//CHINA001 {
+//CHINA001 ((*pFormat)[i])->GetName( aEntry );
+//CHINA001 aLbFormat.InsertEntry( aEntry );
+//CHINA001 }
+//CHINA001
+//CHINA001 if ( nCount == 1 )
+//CHINA001 aBtnRemove.Disable();
+//CHINA001
+//CHINA001 aLbFormat.SelectEntryPos( 0 );
+//CHINA001 aBtnRename.Disable();
+//CHINA001 aBtnRemove.Disable();
+//CHINA001
+//CHINA001 nIndex = 0;
+//CHINA001 UpdateChecks();
+//CHINA001
+//CHINA001 if ( !pSelFmtData )
+//CHINA001 {
+//CHINA001 aBtnAdd.Disable();
+//CHINA001 aBtnRemove.Disable();
+//CHINA001 bFmtInserted = sal_True;
+//CHINA001 }
+//CHINA001 }
+//CHINA001
+//CHINA001 //------------------------------------------------------------------------
+//CHINA001
+//CHINA001 void ScAutoFormatDlg::UpdateChecks()
+//CHINA001 {
+//CHINA001 ScAutoFormatData* pData = (*pFormat)[nIndex];
+//CHINA001
+//CHINA001 aBtnNumFormat.Check( pData->GetIncludeValueFormat() );
+//CHINA001 aBtnBorder .Check( pData->GetIncludeFrame() );
+//CHINA001 aBtnFont .Check( pData->GetIncludeFont() );
+//CHINA001 aBtnPattern .Check( pData->GetIncludeBackground() );
+//CHINA001 aBtnAlignment.Check( pData->GetIncludeJustify() );
+//CHINA001 aBtnAdjust .Check( pData->GetIncludeWidthHeight() );
+//CHINA001 }
+//CHINA001
+//CHINA001 //------------------------------------------------------------------------
+//CHINA001 // Handler:
+//CHINA001 //---------
+//CHINA001
+//CHINA001 IMPL_LINK( ScAutoFormatDlg, CloseHdl, PushButton *, pBtn )
+//CHINA001 {
+//CHINA001 if ( pBtn == &aBtnOk || pBtn == &aBtnCancel )
+//CHINA001 {
+//CHINA001 if ( bCoreDataChanged )
+//CHINA001 ScGlobal::GetAutoFormat()->Save();
+//CHINA001
+//CHINA001 EndDialog( (pBtn == &aBtnOk) ? RET_OK : RET_CANCEL );
+//CHINA001 }
+//CHINA001 return 0;
+//CHINA001 }
+//CHINA001
+//CHINA001 //------------------------------------------------------------------------
+//CHINA001
+//CHINA001 IMPL_LINK_INLINE_START( ScAutoFormatDlg, DblClkHdl, void *, EMPTYARG )
+//CHINA001 {
+//CHINA001 if ( bCoreDataChanged )
+//CHINA001 ScGlobal::GetAutoFormat()->Save();
+//CHINA001
+//CHINA001 EndDialog( RET_OK );
+//CHINA001 return 0;
+//CHINA001 }
+//CHINA001 IMPL_LINK_INLINE_END( ScAutoFormatDlg, DblClkHdl, void *, EMPTYARG )
+//CHINA001
+//CHINA001 //------------------------------------------------------------------------
+//CHINA001
+//CHINA001 IMPL_LINK( ScAutoFormatDlg, CheckHdl, Button *, pBtn )
+//CHINA001 {
+//CHINA001 ScAutoFormatData* pData = (*pFormat)[nIndex];
+//CHINA001 sal_Bool bCheck = ((CheckBox*)pBtn)->IsChecked();
+//CHINA001
+//CHINA001 if ( pBtn == &aBtnNumFormat )
+//CHINA001 pData->SetIncludeValueFormat( bCheck );
+//CHINA001 else if ( pBtn == &aBtnBorder )
+//CHINA001 pData->SetIncludeFrame( bCheck );
+//CHINA001 else if ( pBtn == &aBtnFont )
+//CHINA001 pData->SetIncludeFont( bCheck );
+//CHINA001 else if ( pBtn == &aBtnPattern )
+//CHINA001 pData->SetIncludeBackground( bCheck );
+//CHINA001 else if ( pBtn == &aBtnAlignment )
+//CHINA001 pData->SetIncludeJustify( bCheck );
+//CHINA001 else if ( pBtn == &aBtnAdjust )
+//CHINA001 pData->SetIncludeWidthHeight( bCheck );
+//CHINA001
+//CHINA001 if ( !bCoreDataChanged )
+//CHINA001 {
+//CHINA001 aBtnCancel.SetText( aStrClose );
+//CHINA001 bCoreDataChanged = sal_True;
+//CHINA001 }
+//CHINA001
+//CHINA001 pWndPreview->NotifyChange( pData );
+//CHINA001
+//CHINA001 return 0;
+//CHINA001 }
+//CHINA001
+//CHINA001 //------------------------------------------------------------------------
+//CHINA001
+//CHINA001 IMPL_LINK( ScAutoFormatDlg, AddHdl, void *, EMPTYARG )
+//CHINA001 {
+//CHINA001 if ( !bFmtInserted && pSelFmtData )
+//CHINA001 {
+//CHINA001 String aStrStandard( ScResId(STR_STANDARD) );
+//CHINA001 String aFormatName;
+//CHINA001 ScStringInputDlg* pDlg;
+//CHINA001 sal_Bool bOk = sal_False;
+//CHINA001
+//CHINA001 while ( !bOk )
+//CHINA001 {
+//CHINA001 pDlg = new ScStringInputDlg( this,
+//CHINA001 aStrTitle,
+//CHINA001 aStrLabel,
+//CHINA001 aFormatName,
+//CHINA001 HID_SC_ADD_AUTOFMT );
+//CHINA001
+//CHINA001 if ( pDlg->Execute() == RET_OK )
+//CHINA001 {
+//CHINA001 pDlg->GetInputString( aFormatName );
+//CHINA001
+//CHINA001 if ( (aFormatName.Len() > 0) && (aFormatName != aStrStandard) )
+//CHINA001 {
+//CHINA001 ScAutoFormatData* pNewData
+//CHINA001 = new ScAutoFormatData( *pSelFmtData );
+//CHINA001
+//CHINA001 pNewData->SetName( aFormatName );
+//CHINA001 bFmtInserted = pFormat->Insert( pNewData );
+//CHINA001
+//CHINA001 if ( bFmtInserted )
+//CHINA001 {
+//CHINA001 sal_uInt16 nAt = pFormat->IndexOf( pNewData );
+//CHINA001
+//CHINA001 aLbFormat.InsertEntry( aFormatName, nAt );
+//CHINA001 aLbFormat.SelectEntry( aFormatName );
+//CHINA001 aBtnAdd.Disable();
+//CHINA001
+//CHINA001 if ( !bCoreDataChanged )
+//CHINA001 {
+//CHINA001 aBtnCancel.SetText( aStrClose );
+//CHINA001 bCoreDataChanged = sal_True;
+//CHINA001 }
+//CHINA001
+//CHINA001 SelFmtHdl( 0 );
+//CHINA001 bOk = sal_True;
+//CHINA001 }
+//CHINA001 else
+//CHINA001 delete pNewData;
+//CHINA001
+//CHINA001 }
+//CHINA001
+//CHINA001 if ( !bFmtInserted )
+//CHINA001 {
+//CHINA001 sal_uInt16 nRet = ErrorBox( this,
+//CHINA001 WinBits( WB_OK_CANCEL | WB_DEF_OK),
+//CHINA001 ScGlobal::GetRscString(STR_INVALID_AFNAME)
+//CHINA001 ).Execute();
+//CHINA001
+//CHINA001 bOk = ( nRet == RET_CANCEL );
+//CHINA001 }
+//CHINA001 }
+//CHINA001 else
+//CHINA001 bOk = sal_True;
+//CHINA001
+//CHINA001 delete pDlg;
+//CHINA001 }
+//CHINA001 }
+//CHINA001
+//CHINA001 return 0;
+//CHINA001 }
+//CHINA001
+//CHINA001 //------------------------------------------------------------------------
+//CHINA001
+//CHINA001 IMPL_LINK( ScAutoFormatDlg, RemoveHdl, void *, EMPTYARG )
+//CHINA001 {
+//CHINA001 if ( (nIndex > 0) && (aLbFormat.GetEntryCount() > 0) )
+//CHINA001 {
+//CHINA001 String aMsg( aStrDelMsg.GetToken( 0, '#' ) );
+//CHINA001
+//CHINA001 aMsg += aLbFormat.GetSelectEntry();
+//CHINA001 aMsg += aStrDelMsg.GetToken( 1, '#' );
+//CHINA001
+//CHINA001 if ( RET_YES ==
+//CHINA001 QueryBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), aMsg ).Execute() )
+//CHINA001 {
+//CHINA001 aLbFormat.RemoveEntry( nIndex );
+//CHINA001 aLbFormat.SelectEntryPos( nIndex-1 );
+//CHINA001
+//CHINA001 if ( nIndex-1 == 0 )
+//CHINA001 aBtnRemove.Disable();
+//CHINA001
+//CHINA001 if ( !bCoreDataChanged )
+//CHINA001 {
+//CHINA001 aBtnCancel.SetText( aStrClose );
+//CHINA001 bCoreDataChanged = sal_True;
+//CHINA001 }
+//CHINA001
+//CHINA001 pFormat->AtFree( nIndex ); // in der Core loeschen
+//CHINA001 nIndex--;
+//CHINA001
+//CHINA001 SelFmtHdl( 0 );
+//CHINA001 }
+//CHINA001 }
+//CHINA001
+//CHINA001 SelFmtHdl( 0 );
+//CHINA001
+//CHINA001 return 0;
+//CHINA001 }
+//CHINA001
+//CHINA001 IMPL_LINK( ScAutoFormatDlg, RenameHdl, void *, pBtn)
+//CHINA001 {
+//CHINA001 sal_Bool bOk = sal_False;
+//CHINA001 while( !bOk )
+//CHINA001 {
+//CHINA001
+//CHINA001 String aFormatName=aLbFormat.GetSelectEntry();
+//CHINA001 String aEntry;
+//CHINA001
+//CHINA001 ScStringInputDlg* pDlg = new ScStringInputDlg( this,
+//CHINA001 aStrRename,
+//CHINA001 aStrLabel,
+//CHINA001 aFormatName,
+//CHINA001 HID_SC_RENAME_AUTOFMT );
+//CHINA001 if( pDlg->Execute() == RET_OK )
+//CHINA001 {
+//CHINA001 sal_Bool bFmtRenamed = sal_False;
+//CHINA001 pDlg->GetInputString( aFormatName );
+//CHINA001 sal_uInt16 n;
+//CHINA001
+//CHINA001 if ( aFormatName.Len() > 0 )
+//CHINA001 {
+//CHINA001 for( n = 0; n < pFormat->GetCount(); ++n )
+//CHINA001 {
+//CHINA001 (*pFormat)[n]->GetName(aEntry);
+//CHINA001 if ( aEntry== aFormatName)
+//CHINA001 break;
+//CHINA001 }
+//CHINA001 if( n >= pFormat->GetCount() )
+//CHINA001 {
+//CHINA001 // Format mit dem Namen noch nicht vorhanden, also
+//CHINA001 // umbenennen
+//CHINA001
+//CHINA001 aLbFormat.RemoveEntry(nIndex );
+//CHINA001 ScAutoFormatData* p=(*pFormat)[ nIndex ];
+//CHINA001 ScAutoFormatData* pNewData
+//CHINA001 = new ScAutoFormatData(*p);
+//CHINA001
+//CHINA001 pFormat->AtFree( nIndex );
+//CHINA001
+//CHINA001 pNewData->SetName( aFormatName );
+//CHINA001
+//CHINA001 pFormat->Insert( pNewData);
+//CHINA001
+//CHINA001 sal_uInt16 nCount = pFormat->GetCount();
+//CHINA001
+//CHINA001 aLbFormat.SetUpdateMode(sal_False);
+//CHINA001 aLbFormat.Clear();
+//CHINA001 for ( sal_uInt16 i = 0; i < nCount; i++ )
+//CHINA001 {
+//CHINA001 ((*pFormat)[i])->GetName( aEntry );
+//CHINA001 aLbFormat.InsertEntry( aEntry );
+//CHINA001 }
+//CHINA001
+//CHINA001 aLbFormat.SetUpdateMode( sal_True);
+//CHINA001 aLbFormat.SelectEntry( aFormatName);
+//CHINA001
+//CHINA001 if ( !bCoreDataChanged )
+//CHINA001 {
+//CHINA001 aBtnCancel.SetText( aStrClose );
+//CHINA001 bCoreDataChanged = sal_True;
+//CHINA001 }
+//CHINA001
+//CHINA001
+//CHINA001 SelFmtHdl( 0 );
+//CHINA001 bOk = sal_True;
+//CHINA001 bFmtRenamed = sal_True;
+//CHINA001 }
+//CHINA001 }
+//CHINA001 if( !bFmtRenamed )
+//CHINA001 {
+//CHINA001 bOk = RET_CANCEL == ErrorBox( this,
+//CHINA001 WinBits( WB_OK_CANCEL | WB_DEF_OK),
+//CHINA001 ScGlobal::GetRscString(STR_INVALID_AFNAME)
+//CHINA001 ).Execute();
+//CHINA001 }
+//CHINA001 }
+//CHINA001 else
+//CHINA001 bOk = sal_True;
+//CHINA001 delete pDlg;
+//CHINA001 }
+//CHINA001
+//CHINA001 return 0;
+//CHINA001 }
+//CHINA001
+//CHINA001 //------------------------------------------------------------------------
+//CHINA001
+//CHINA001 IMPL_LINK( ScAutoFormatDlg, SelFmtHdl, void *, EMPTYARG )
+//CHINA001 {
+//CHINA001 nIndex = aLbFormat.GetSelectEntryPos();
+//CHINA001 UpdateChecks();
+//CHINA001
+//CHINA001 if ( nIndex == 0 )
+//CHINA001 {
+//CHINA001 aBtnRename.Disable();
+//CHINA001 aBtnRemove.Disable();
+//CHINA001 }
+//CHINA001 else
+//CHINA001 {
+//CHINA001 aBtnRename.Enable();
+//CHINA001 aBtnRemove.Enable();
+//CHINA001 }
+//CHINA001
+//CHINA001 pWndPreview->NotifyChange( (*pFormat)[nIndex] );
+//CHINA001
+//CHINA001 return 0;
+//CHINA001 }
+//CHINA001
+//CHINA001 //------------------------------------------------------------------------
+//CHINA001
+//CHINA001 String ScAutoFormatDlg::GetCurrFormatName()
+//CHINA001 {
+//CHINA001 String aResult;
+//CHINA001
+//CHINA001 ((*pFormat)[nIndex])->GetName( aResult );
+//CHINA001
+//CHINA001 return aResult;
+//CHINA001 }
+//CHINA001
+//========================================================================
+// ScAutoFmtPreview
+
+ScAutoFmtPreview::ScAutoFmtPreview( Window* pParent, const ResId& rRes, ScDocument* pDoc ) :
+ Window ( pParent, rRes ),
+ pCurData ( NULL ),
+ aVD ( *this ),
+ aScriptedText ( aVD ),
+ xBreakIter ( pDoc->GetBreakIterator() ),
+ bFitWidth ( sal_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( sal_uInt16 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, sal_True )
+
+#undef SETONALLFONTS
+ }
+}
+
+//------------------------------------------------------------------------
+
+sal_uInt16 ScAutoFmtPreview::GetFormatIndex( size_t nCol, size_t nRow ) const
+{
+ static const sal_uInt16 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;
+ sal_Bool bNumFormat = pCurData->GetIncludeValueFormat();
+ sal_uLong nNum;
+ double nVal;
+ Color* pDummy = NULL;
+ sal_uInt16 nIndex = static_cast< sal_uInt16 >( 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( (sal_uInt16) nNum );
+ nNum = rNumFormat.GetFormatIndex( *pNumFmt );
+ }
+ else
+ nNum = 0;
+ pNumFmt->GetOutputString( nVal, nNum, cellString, &pDummy );
+ break;
+ }
+
+ if ( cellString.Len() > 0 )
+ {
+ Size aStrSize;
+ sal_uInt16 nFmtIndex = GetFormatIndex( nCol, nRow );
+ Rectangle cellRect = maArray.GetCellRect( nCol, nRow );
+ Point aPos = cellRect.TopLeft();
+ sal_uInt16 nRightX = 0;
+ sal_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 = (sal_uInt16)( cellRect.GetWidth()
+ - aStrSize.Width()
+ - FRAME_OFFSET );
+
+ //-----------------------------
+ // vertikal (immer zentrieren):
+ //-----------------------------
+ aPos.Y() += (mnRowHeight - (sal_uInt16)aStrSize.Height()) / 2;
+
+ //-----------
+ // horizontal
+ //-----------
+ if ( eJustification != SVX_HOR_JUSTIFY_STANDARD )
+ {
+ sal_uInt16 nHorPos = (sal_uInt16)
+ ((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( sal_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( sal_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 sal_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( sal_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 );
+}
+
diff --git a/sc/source/ui/miscdlgs/conflictsdlg.cxx b/sc/source/ui/miscdlgs/conflictsdlg.cxx
new file mode 100644
index 000000000000..51f457788d27
--- /dev/null
+++ b/sc/source/ui/miscdlgs/conflictsdlg.cxx
@@ -0,0 +1,894 @@
+/*************************************************************************
+ *
+ * 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( sal_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( sal_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
+//=============================================================================
+
+//UNUSED2008-05 bool ScConflictsListHelper::HasSharedAction( ScConflictsList& rConflictsList, sal_uLong nSharedAction )
+//UNUSED2008-05 {
+//UNUSED2008-05 ScConflictsList::const_iterator aEnd = rConflictsList.end();
+//UNUSED2008-05 for ( ScConflictsList::const_iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
+//UNUSED2008-05 {
+//UNUSED2008-05 if ( aItr->HasSharedAction( nSharedAction ) )
+//UNUSED2008-05 {
+//UNUSED2008-05 return true;
+//UNUSED2008-05 }
+//UNUSED2008-05 }
+//UNUSED2008-05
+//UNUSED2008-05 return false;
+//UNUSED2008-05 }
+
+bool ScConflictsListHelper::HasOwnAction( ScConflictsList& rConflictsList, sal_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, sal_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, sal_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, sal_uLong nStartShared, sal_uLong nEndShared,
+ sal_uLong nStartOwn, sal_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( sal_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
+//=============================================================================
+
+//UNUSED2008-05 ScConflictsListBox::ScConflictsListBox( Window* pParent, WinBits nBits )
+//UNUSED2008-05 :SvxRedlinTable( pParent, nBits )
+//UNUSED2008-05 {
+//UNUSED2008-05 }
+
+ScConflictsListBox::ScConflictsListBox( Window* pParent, const ResId& rResId )
+ :SvxRedlinTable( pParent, rResId )
+{
+}
+
+ScConflictsListBox::~ScConflictsListBox()
+{
+}
+
+//UNUSED2008-05 sal_uLong ScConflictsListBox::GetRootEntryPos( const SvLBoxEntry* pRootEntry ) const
+//UNUSED2008-05 {
+//UNUSED2008-05 sal_uLong nPos = 0;
+//UNUSED2008-05 SvLBoxEntry* pEntry = GetRootLevelParent( First() );
+//UNUSED2008-05 while ( pEntry )
+//UNUSED2008-05 {
+//UNUSED2008-05 if ( pEntry == pRootEntry )
+//UNUSED2008-05 {
+//UNUSED2008-05 return nPos;
+//UNUSED2008-05 }
+//UNUSED2008-05 pEntry = NextSibling( pEntry );
+//UNUSED2008-05 ++nPos;
+//UNUSED2008-05 }
+//UNUSED2008-05 return 0xffffffff;
+//UNUSED2008-05 }
+
+
+//=============================================================================
+// 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.SetStyle( maLbConflicts.GetStyle() | 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, sal_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, sal_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( sal_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();
+ sal_Bool bContMark = sal_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 ) )
+ {
+ sal_Bool bSetCursor = !maLbConflicts.NextSelected( pEntry );
+ pTabView->MarkRange( rBigRange.MakeRange(), bSetCursor, bContMark );
+ bContMark = sal_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( sal_False );
+ maLbConflicts.Clear();
+ maLbConflicts.SetUpdateMode( sal_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 );
+ }
+ }
+}
diff --git a/sc/source/ui/miscdlgs/conflictsdlg.src b/sc/source/ui/miscdlgs/conflictsdlg.src
new file mode 100644
index 000000000000..1bdec57067f4
--- /dev/null
+++ b/sc/source/ui/miscdlgs/conflictsdlg.src
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * 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
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_CONFLICTS:BTN_KEEPMINE";
+ Pos = MAP_APPFONT ( 72 , 145 ) ;
+ Size = MAP_APPFONT ( 76 , 14 ) ;
+ Text [ en-US ] = "Keep ~Mine" ;
+ };
+ PushButton BTN_KEEPOTHER
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_CONFLICTS: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
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_CONFLICTS:BTN_KEEPALLMINE";
+ Pos = MAP_APPFONT ( 6 , 172 ) ;
+ Size = MAP_APPFONT ( 104 , 14 ) ;
+ Text [ en-US ] = "~Keep All Mine" ;
+ };
+ PushButton BTN_KEEPALLOTHERS
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_CONFLICTS: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..90e77cf58e92
--- /dev/null
+++ b/sc/source/ui/miscdlgs/crdlg.cxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * 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,
+ sal_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 )
+
+
+
diff --git a/sc/source/ui/miscdlgs/crnrdlg.cxx b/sc/source/ui/miscdlgs/crnrdlg.cxx
new file mode 100644
index 000000000000..2acd7003556a
--- /dev/null
+++ b/sc/source/ui/miscdlgs/crnrdlg.cxx
@@ -0,0 +1,1175 @@
+/*************************************************************************
+ *
+ * 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 sal_uLong nEntryDataCol = 0;
+const sal_uLong nEntryDataRow = 1;
+const sal_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 ( sal_False )
+{
+ xColNameRanges = pDoc->GetColNameRanges()->Clone();
+ xRowNameRanges = pDoc->GetRowNameRanges()->Clone();
+ Init();
+ FreeResource();
+
+ aRbAssign.SetAccessibleRelationMemberOf(&aEdAssign);
+ aRbAssign2.SetAccessibleRelationMemberOf(&aEdAssign);
+}
+
+
+/*************************************************************************
+#* 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( sal_True );
+ aBtnRowHead.Check( sal_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,sal_Bool bRef)
+{
+ theCurData = theCurArea = rLabelRange;
+ sal_Bool bValid = sal_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( sal_True );
+ aBtnRowHead.Check( sal_False );
+ if ( nRow2 == MAXROW )
+ {
+ if ( nRow1 == 0 )
+ bValid = sal_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( sal_True );
+ aBtnColHead.Check( sal_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,sal_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, sal_True );
+ else
+ AdjustColRowData( rRef, sal_True );
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aBtnAdd.Enable();
+ aBtnRemove.Disable();
+ }
+}
+
+
+/*************************************************************************
+#* Member: Close Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Schliessen des Fensters
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+sal_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 = sal_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( sal_False );
+ //-----------------------------------------------------------
+ aLbRange.Clear();
+ aRangeMap.clear();
+ aEdAssign.SetText( EMPTY_STRING );
+
+ sal_uLong nCount, j;
+ sal_uInt16 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( sal_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, sal_Bool bColName )
+{
+ ScRangePair* pPair = NULL;
+ sal_Bool bFound = sal_False;
+ if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
+ bFound = sal_True;
+ else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
+ bFound = sal_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
+#*
+#************************************************************************/
+
+sal_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;
+ sal_Bool bOk1;
+ if ( (bOk1 = ((aRange1.ParseAny( aNewArea, pDoc, eConv ) & SCA_VALID) == SCA_VALID)) != sal_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( sal_True );
+ aBtnRowHead.Check( sal_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();
+ sal_uInt16 nSelectPos = aLbRange.GetSelectEntryPos();
+ sal_Bool bColName =
+ ((sal_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;
+ sal_Bool bFound = sal_False;
+ if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
+ bFound = sal_True;
+ else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
+ bFound = sal_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();
+ sal_uInt16 nCnt = aLbRange.GetEntryCount();
+ if ( nSelectPos >= nCnt )
+ {
+ if ( nCnt )
+ nSelectPos = nCnt - 1;
+ else
+ nSelectPos = 0;
+ }
+ aLbRange.SelectEntryPos( nSelectPos );
+ if ( nSelectPos &&
+ (sal_uLong)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim )
+ aLbRange.SelectEntryPos( --nSelectPos ); // ---Zeile---
+
+ aLbRange.GrabFocus();
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aEdAssign.SetText( EMPTY_STRING );
+ theCurArea = theCurData = ScRange();
+ aBtnColHead.Check( sal_True );
+ aBtnRowHead.Check( sal_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 )
+{
+ sal_uInt16 nSelectPos = aLbRange.GetSelectEntryPos();
+ sal_uInt16 nCnt = aLbRange.GetEntryCount();
+ sal_uInt16 nMoves = 0;
+ while ( nSelectPos < nCnt
+ && (sal_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() )
+ {
+ sal_Bool bColName =
+ ((sal_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() );
+ sal_Bool bValid = sal_False;
+ if ( aNewArea.Len() > 0 )
+ {
+ ScRange aRange;
+ if ( (aRange.ParseAny( aNewArea, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID )
+ {
+ SetColRowData( aRange );
+ bValid = sal_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( sal_True );
+ aBtnRowHead.Check( sal_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( sal_True );
+ aBtnColHead.Check( sal_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;
+}
diff --git a/sc/source/ui/miscdlgs/delcldlg.cxx b/sc/source/ui/miscdlgs/delcldlg.cxx
new file mode 100644
index 000000000000..24e63f77dac3
--- /dev/null
+++ b/sc/source/ui/miscdlgs/delcldlg.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// 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 sal_uInt8 nDelItemChecked=0;
+
+//==================================================================
+
+ScDeleteCellDlg::ScDeleteCellDlg( Window* pParent, sal_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()
+{
+}
+
+
+
diff --git a/sc/source/ui/miscdlgs/delcodlg.cxx b/sc/source/ui/miscdlgs/delcodlg.cxx
new file mode 100644
index 000000000000..5f59ecae260d
--- /dev/null
+++ b/sc/source/ui/miscdlgs/delcodlg.cxx
@@ -0,0 +1,180 @@
+/*************************************************************************
+ *
+ * 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"
+
+
+//==================================================================
+
+sal_Bool ScDeleteContentsDlg::bPreviousAllCheck = sal_False;
+sal_uInt16 ScDeleteContentsDlg::nPreviousChecks = (IDF_DATETIME | IDF_STRING |
+ IDF_NOTE | IDF_FORMULA |
+ IDF_VALUE);
+
+//-----------------------------------------------------------------------
+
+ScDeleteContentsDlg::ScDeleteContentsDlg( Window* pParent,
+ sal_uInt16 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( sal_False )
+{
+ if ( nCheckDefaults != 0 )
+ {
+ ScDeleteContentsDlg::nPreviousChecks = nCheckDefaults;
+ ScDeleteContentsDlg::bPreviousAllCheck = sal_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();
+}
+
+//------------------------------------------------------------------------
+
+sal_uInt16 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( sal_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 = sal_True;
+ aBtnDelObjects.Check(sal_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()
+{
+}
+
+
+
diff --git a/sc/source/ui/miscdlgs/filldlg.cxx b/sc/source/ui/miscdlgs/filldlg.cxx
new file mode 100644
index 000000000000..042dbc175f07
--- /dev/null
+++ b/sc/source/ui/miscdlgs/filldlg.cxx
@@ -0,0 +1,377 @@
+/*************************************************************************
+ *
+ * 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,
+ sal_uInt16 nPossDir )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_FILLSERIES ) ),
+
+ 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 ) ),
+
+ 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 ) ),
+
+ 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(sal_Bool bFlag)
+{
+ bStartValFlag=bFlag;
+ if(bFlag)
+ {
+ aFtStartVal.Enable();
+ aEdStartVal.Enable();
+ }
+ else
+ {
+ aFtStartVal.Disable();
+ aEdStartVal.Disable();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScFillSeriesDlg::Init( sal_uInt16 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=sal_False;
+
+ aFlSep1.SetStyle( aFlSep1.GetStyle() | WB_VERT );
+ aFlSep2.SetStyle( aFlSep2.GetStyle() | WB_VERT );
+}
+
+
+//----------------------------------------------------------------------------
+
+sal_Bool __EXPORT ScFillSeriesDlg::CheckStartVal()
+{
+ sal_Bool bValOk = sal_False;
+ sal_uInt32 nKey = 0;
+ String aStr( aEdStartVal.GetText() );
+
+ if ( aStr.Len() == 0 || aBtnAutoFill.IsChecked())
+ {
+ fStartVal = MAXDOUBLE;
+ bValOk = sal_True;
+ }
+ else
+ bValOk = rDoc.GetFormatTable()->IsNumberFormat( aStr, nKey, fStartVal );
+
+ return bValOk;
+}
+
+
+//----------------------------------------------------------------------------
+
+sal_Bool __EXPORT ScFillSeriesDlg::CheckIncrementVal()
+{
+ sal_uInt32 nKey = 0;
+ String aStr( aEdIncrement.GetText() );
+
+ return rDoc.GetFormatTable()->IsNumberFormat( aStr, nKey, fIncrement );
+}
+
+
+//----------------------------------------------------------------------------
+
+sal_Bool __EXPORT ScFillSeriesDlg::CheckEndVal()
+{
+ sal_Bool bValOk = sal_False;
+ sal_uInt32 nKey = 0;
+ String aStr( aEdEndVal.GetText() );
+
+ if ( aStr.Len() == 0 )
+ {
+ fEndVal = (fIncrement < 0) ? -MAXDOUBLE : MAXDOUBLE;
+ bValOk = sal_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;
+
+ sal_Bool bAllOk = sal_True;
+ Edit* pEdWrong = NULL;
+ if ( !CheckStartVal() )
+ {
+ bAllOk = sal_False;
+ pEdWrong = &aEdStartVal;
+ }
+ else if ( !CheckIncrementVal() )
+ {
+ bAllOk = sal_False;
+ pEdWrong = &aEdIncrement;
+ }
+ else if ( !CheckEndVal() )
+ {
+ bAllOk = sal_False;
+ pEdWrong = &aEdEndVal;
+ }
+ if ( bAllOk )
+ EndDialog( RET_OK );
+ else
+ {
+ ErrorBox( this,
+ WinBits( WB_OK | WB_DEF_OK ),
+ errMsgInvalidVal
+ ).Execute();
+ pEdWrong->GrabFocus();
+ }
+
+ return 0;
+}
+
+
+
+
diff --git a/sc/source/ui/miscdlgs/groupdlg.cxx b/sc/source/ui/miscdlgs/groupdlg.cxx
new file mode 100644
index 000000000000..d0bef5e4f4c7
--- /dev/null
+++ b/sc/source/ui/miscdlgs/groupdlg.cxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * 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,
+ sal_uInt16 nResId,
+ sal_Bool bUngroup,
+ sal_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();
+}
+
+//------------------------------------------------------------------------
+
+sal_Bool ScGroupDlg::GetColsChecked() const
+{
+ return aBtnCols.IsChecked();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScGroupDlg::~ScGroupDlg()
+{
+}
+
+
+
diff --git a/sc/source/ui/miscdlgs/highred.cxx b/sc/source/ui/miscdlgs/highred.cxx
new file mode 100644
index 000000000000..0b0a4de9f985
--- /dev/null
+++ b/sc/source/ui/miscdlgs/highred.cxx
@@ -0,0 +1,302 @@
+/*************************************************************************
+ *
+ * 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, sal_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(sal_False);
+ aFilterCtr.Show();
+ SetDispatcherLock( sal_True );
+ //SFX_APPWINDOW->Disable(sal_False);
+
+ Init();
+
+}
+
+ScHighlightChgDlg::~ScHighlightChgDlg()
+{
+ SetDispatcherLock( sal_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(sal_uInt16 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((sal_uInt16)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(sal_True,sal_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);
+ }
+}
+
+//----------------------------------------------------------------------------
+sal_Bool __EXPORT ScHighlightChgDlg::Close()
+{
+ return DoClose( ScHighlightChgDlgWrapper::GetChildWindowId() );
+}
+
+void ScHighlightChgDlg::RefInputDone( sal_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( sal_False );
+ }
+ //RefInputDone();
+ */
+}
+
+sal_Bool ScHighlightChgDlg::IsRefInputMode() const
+{
+ return aEdAssign.IsVisible();
+}
+
+IMPL_LINK( ScHighlightChgDlg, HighLightHandle, CheckBox*, pCb )
+{
+ if(pCb!=NULL)
+ {
+ if(aHighlightBox.IsChecked())
+ {
+ aFilterCtr.Enable(sal_True,sal_True);
+ aCbAccept.Enable();
+ aCbReject.Enable();
+ }
+ else
+ {
+ aFilterCtr.Disable(sal_True);
+ aCbAccept.Disable();
+ aCbReject.Disable();
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( ScHighlightChgDlg, RefHandle, SvxTPFilter*, pRef )
+{
+ if(pRef!=NULL)
+ {
+ SetDispatcherLock( sal_True );
+ //SFX_APPWINDOW->Disable(sal_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;
+}
+
+
+
diff --git a/sc/source/ui/miscdlgs/highred.src b/sc/source/ui/miscdlgs/highred.src
new file mode 100644
index 000000000000..3fa4a62fcd17
--- /dev/null
+++ b/sc/source/ui/miscdlgs/highred.src
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * 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 = CMD_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
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_HIGHLIGHT_CHANGES: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
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_HIGHLIGHT_CHANGES: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
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_HIGHLIGHT_CHANGES: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
+ {
+ HelpID = "sc:Edit:RID_SCDLG_HIGHLIGHT_CHANGES:ED_ASSIGN";
+ Hide = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 119 ) ;
+ Size = MAP_APPFONT ( 128 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_ASSIGN
+ {
+ HelpID = "sc:ImageButton:RID_SCDLG_HIGHLIGHT_CHANGES:RB_ASSIGN";
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 142 , 118 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE;
+ 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..2e9f8a1c09ce
--- /dev/null
+++ b/sc/source/ui/miscdlgs/inscldlg.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// 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 sal_uInt8 nInsItemChecked=0;
+
+//==================================================================
+
+ScInsertCellDlg::ScInsertCellDlg( Window* pParent,sal_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()
+{
+}
+
+
+
diff --git a/sc/source/ui/miscdlgs/inscodlg.cxx b/sc/source/ui/miscdlgs/inscodlg.cxx
new file mode 100644
index 000000000000..263b1171b3f4
--- /dev/null
+++ b/sc/source/ui/miscdlgs/inscodlg.cxx
@@ -0,0 +1,372 @@
+/*************************************************************************
+ *
+ * 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"
+
+
+//==================================================================
+
+sal_Bool ScInsertContentsDlg::bPreviousAllCheck = sal_True;
+sal_uInt16 ScInsertContentsDlg::nPreviousChecks = (IDF_DATETIME | IDF_STRING |
+ IDF_NOTE | IDF_FORMULA |
+ IDF_ATTRIB | IDF_OBJECTS);
+sal_uInt16 ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
+sal_uInt16 ScInsertContentsDlg::nPreviousChecks2 = 0;
+sal_uInt16 ScInsertContentsDlg::nPreviousMoveMode = INS_NONE; // enum InsCellCmd
+
+//-----------------------------------------------------------------------
+
+ScInsertContentsDlg::ScInsertContentsDlg( Window* pParent,
+ sal_uInt16 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 ( sal_False ),
+ bFillMode ( sal_False ),
+ bChangeTrack ( sal_False ),
+ bMoveDownDisabled( sal_False ),
+ bMoveRightDisabled( sal_False )
+{
+ if ( pStrTitle )
+ SetText( *pStrTitle );
+
+ if ( nCheckDefaults != 0 )
+ {
+ ScInsertContentsDlg::nPreviousChecks = nCheckDefaults;
+ ScInsertContentsDlg::bPreviousAllCheck = sal_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(sal_True); break;
+ case PASTE_ADD: aRbAdd.Check(sal_True); break;
+ case PASTE_SUB: aRbSub.Check(sal_True); break;
+ case PASTE_MUL: aRbMul.Check(sal_True); break;
+ case PASTE_DIV: aRbDiv.Check(sal_True); break;
+ }
+
+ switch( ScInsertContentsDlg::nPreviousMoveMode )
+ {
+ case INS_NONE: aRbMoveNone.Check(sal_True); break;
+ case INS_CELLSDOWN: aRbMoveDown.Check(sal_True); break;
+ case INS_CELLSRIGHT: aRbMoveRight.Check(sal_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();
+}
+
+//------------------------------------------------------------------------
+
+sal_uInt16 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( sal_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(sal_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( sal_Bool bSet )
+{
+ if ( bSet != bOtherDoc )
+ {
+ bOtherDoc = bSet;
+ TestModes();
+ if ( bSet )
+ aRbMoveNone.Check(sal_True);
+ }
+}
+
+void ScInsertContentsDlg::SetFillMode( sal_Bool bSet )
+{
+ if ( bSet != bFillMode )
+ {
+ bFillMode = bSet;
+ TestModes();
+ if ( bSet )
+ aRbMoveNone.Check(sal_True);
+ }
+}
+
+void ScInsertContentsDlg::SetChangeTrack( sal_Bool bSet )
+{
+ if ( bSet != bChangeTrack )
+ {
+ bChangeTrack = bSet;
+ TestModes();
+ if ( bSet )
+ aRbMoveNone.Check(sal_True);
+ }
+}
+
+void ScInsertContentsDlg::SetCellShiftDisabled( int nDisable )
+{
+ sal_Bool bDown = ((nDisable & SC_CELL_SHIFT_DISABLE_DOWN) != 0);
+ sal_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(sal_True);
+ if ( bMoveRightDisabled && aRbMoveRight.IsChecked() )
+ aRbMoveNone.Check(sal_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;
+ }
+}
+
+sal_uInt16 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;
+}
+
+
+
diff --git a/sc/source/ui/miscdlgs/instbdlg.cxx b/sc/source/ui/miscdlgs/instbdlg.cxx
new file mode 100644
index 000000000000..be425ee51bec
--- /dev/null
+++ b/sc/source/ui/miscdlgs/instbdlg.cxx
@@ -0,0 +1,434 @@
+/*************************************************************************
+ *
+ * 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 ) ),
+ //
+ aFlPos ( this, ScResId( FL_POSITION ) ),
+ aBtnBefore ( this, ScResId( RB_BEFORE ) ),
+ aBtnBehind ( this, ScResId( RB_BEHIND ) ),
+ aFlTable ( this, ScResId( FL_TABLE ) ),
+ 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 ) ),
+ 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();
+ aLbTables.SetAccessibleName(aBtnFromFile.GetText());
+}
+
+//------------------------------------------------------------------------
+
+__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( sal_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( sal_True );
+
+ if(aLbTables.GetEntryCount()==1)
+ aLbTables.SelectEntryPos(0);
+}
+
+//------------------------------------------------------------------------
+
+const String* ScInsertTableDlg::GetFirstTable( sal_uInt16* 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( sal_uInt16* 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( sal_True ); // to enable the filter options dialog
+
+ pDocShTables = new ScDocShell;
+ aDocShTablesRef = pDocShTables;
+
+ Pointer aOldPtr( GetPointer() );
+ SetPointer( Pointer( POINTER_WAIT ) );
+ pDocShTables->DoLoad( pMed );
+ SetPointer( aOldPtr );
+
+ sal_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;
+}
+
diff --git a/sc/source/ui/miscdlgs/instbdlg.src b/sc/source/ui/miscdlgs/instbdlg.src
new file mode 100644
index 000000000000..86b291547284
--- /dev/null
+++ b/sc/source/ui/miscdlgs/instbdlg.src
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * 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
+{
+ HelpID = "sc: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
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_INSERT_TABLE:RB_BEFORE";
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 197 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "B~efore current sheet" ;
+ };
+ RadioButton RB_BEHIND
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_INSERT_TABLE: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
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_INSERT_TABLE: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
+ {
+ HelpID = "sc:NumericField:RID_SCDLG_INSERT_TABLE: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
+ {
+ HelpID = "sc:Edit:RID_SCDLG_INSERT_TABLE:ED_TABNAME";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 72 , 82 ) ;
+ Size = MAP_APPFONT ( 137 , 12 ) ;
+ };
+ RadioButton RB_FROMFILE
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_INSERT_TABLE:RB_FROMFILE";
+ Pos = MAP_APPFONT ( 12 , 100 ) ;
+ Size = MAP_APPFONT ( 197 , 10 ) ;
+ Text [ en-US ] = "~From file" ;
+ };
+ MultiListBox LB_TABLES
+ {
+ HelpID = "sc:MultiListBox:RID_SCDLG_INSERT_TABLE:LB_TABLES";
+ SimpleMode = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 20 , 113 ) ;
+ Size = MAP_APPFONT ( 123 , 59 ) ;
+ AutoHScroll = TRUE ;
+ };
+ PushButton BTN_BROWSE
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_INSERT_TABLE:BTN_BROWSE";
+ Pos = MAP_APPFONT ( 149 , 113 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~Browse..." ;
+ };
+ CheckBox CB_LINK
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_INSERT_TABLE: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..67ec1a647638
--- /dev/null
+++ b/sc/source/ui/miscdlgs/lbseldlg.cxx
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * 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,
+ sal_uInt16 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();
+}
+
+//------------------------------------------------------------------------
+
+//UNUSED2008-05 sal_uInt16 ScSelEntryDlg::GetSelectEntryPos() const
+//UNUSED2008-05 {
+//UNUSED2008-05 return aLb.GetSelectEntryPos();
+//UNUSED2008-05 }
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScSelEntryDlg, DblClkHdl, void *, EMPTYARG )
+{
+ EndDialog( RET_OK );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScSelEntryDlg, DblClkHdl, void *, EMPTYARG )
+
+//------------------------------------------------------------------------
+
+__EXPORT ScSelEntryDlg::~ScSelEntryDlg()
+{
+}
+
+
+
diff --git a/sc/source/ui/miscdlgs/linkarea.cxx b/sc/source/ui/miscdlgs/linkarea.cxx
new file mode 100644
index 000000000000..3ba5b2952cf1
--- /dev/null
+++ b/sc/source/ui/miscdlgs/linkarea.cxx
@@ -0,0 +1,369 @@
+/*************************************************************************
+ *
+ * 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();
+
+ aNfDelay.SetAccessibleName(aBtnReload.GetText());
+ aNfDelay.SetAccessibleRelationLabeledBy(&aBtnReload);
+}
+
+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 = sal_True)
+ // Break operation if any error occured inside.
+ if (!ScDocumentLoader::GetFilterName( aEntered, aFilter, aOptions, sal_True, sal_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, sal_True ); // with interaction
+ pSourceShell = aLoader.GetDocShell();
+ if ( pSourceShell )
+ {
+ sal_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,
+ sal_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 );
+ }
+
+ sal_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( sal_True ); // to enable the filter options dialog
+
+ pSourceShell = new ScDocShell;
+ aSourceRef = pSourceShell;
+ pSourceShell->DoLoad( pMed );
+
+ sal_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( sal_False );
+
+ aLbRanges.Clear();
+ if ( pSourceShell )
+ {
+ ScAreaNameIterator aIter( pSourceShell->GetDocument() );
+ ScRange aDummy;
+ String aName;
+ while ( aIter.Next( aName, aDummy ) )
+ aLbRanges.InsertEntry( aName );
+ }
+
+ aLbRanges.SetUpdateMode( sal_True );
+
+ if ( aLbRanges.GetEntryCount() == 1 )
+ aLbRanges.SelectEntryPos(0);
+}
+
+void ScLinkedAreaDlg::UpdateEnable()
+{
+ sal_Bool bEnable = ( pSourceShell && aLbRanges.GetSelectEntryCount() );
+ aBtnOk.Enable( bEnable );
+
+ sal_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;
+ sal_uInt16 nCount = aLbRanges.GetSelectEntryCount();
+ for (sal_uInt16 i=0; i<nCount; i++)
+ {
+ if (i > 0)
+ aSource.Append( (sal_Unicode) ';' );
+ aSource.Append( aLbRanges.GetSelectEntry( i ) );
+ }
+ return aSource;
+}
+
+sal_uLong ScLinkedAreaDlg::GetRefresh()
+{
+ if ( aBtnReload.IsChecked() )
+ return sal::static_int_cast<sal_uLong>( aNfDelay.GetValue() );
+ else
+ return 0; // disabled
+}
+
diff --git a/sc/source/ui/miscdlgs/linkarea.src b/sc/source/ui/miscdlgs/linkarea.src
new file mode 100644
index 000000000000..11780c2995fe
--- /dev/null
+++ b/sc/source/ui/miscdlgs/linkarea.src
@@ -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.
+ *
+ ************************************************************************/
+
+#include "linkarea.hrc"
+
+ModalDialog RID_SCDLG_LINKAREA
+{
+ HelpID = "sc: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
+ {
+ HelpID = "sc:ComboBox:RID_SCDLG_LINKAREA:CB_URL";
+ Pos = MAP_APPFONT ( 12 , 15 ) ;
+ Size = MAP_APPFONT ( 174 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ PushButton BTN_BROWSE
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_LINKAREA: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
+ {
+ HelpID = "sc:MultiListBox:RID_SCDLG_LINKAREA:LB_RANGES";
+ SimpleMode = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 74 ) ;
+ Size = MAP_APPFONT ( 192 , 80 ) ;
+ AutoHScroll = TRUE ;
+ };
+ CheckBox BTN_RELOAD
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_LINKAREA:BTN_RELOAD";
+ Pos = MAP_APPFONT ( 12 , 168 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Update every";
+ };
+ NumericField NF_DELAY
+ {
+ HelpID = "sc:NumericField:RID_SCDLG_LINKAREA: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..d34994341ade
--- /dev/null
+++ b/sc/source/ui/miscdlgs/makefile.mk
@@ -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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=miscdlgs
+LIBTARGET=no
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : scpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sc.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(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..c1227bc0c58f
--- /dev/null
+++ b/sc/source/ui/miscdlgs/mtrindlg.cxx
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * 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,
+ sal_uInt16 nResId,
+ long nCurrent,
+ long nDefault,
+ FieldUnit eFUnit,
+ sal_uInt16 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 );
+ sal_uInt16 nDecs = aEdValue.GetDecimalDigits();
+ double nFactor = 0.0;
+
+ // static long ImpPower10( sal_uInt16 nDecs )
+ {
+ nFactor = 1.0;
+
+ for ( sal_uInt16 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 )
+
+
+
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx
new file mode 100644
index 000000000000..a42af4893ba0
--- /dev/null
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * 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 ( sal_False )
+{
+#if ENABLE_LAYOUT
+#undef ScResId
+ SetHelpId (FID_TAB_MOVE);
+#endif /* ENABLE_LAYOUT */
+ Init();
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScMoveTableDlg::~ScMoveTableDlg()
+{
+}
+
+//------------------------------------------------------------------------
+
+sal_uInt16 ScMoveTableDlg::GetSelectedDocument () const { return nDocument; }
+
+SCTAB ScMoveTableDlg::GetSelectedTable () const { return nTable; }
+
+sal_Bool ScMoveTableDlg::GetCopyTable () const { return bCopyTable; }
+
+void ScMoveTableDlg::SetCopyTable(sal_Bool bFlag)
+{
+ aBtnCopy.Check(bFlag);
+}
+void ScMoveTableDlg::EnableCopyTable(sal_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( sal_False );
+ InitDocListBox();
+ SelHdl( &aLbDoc );
+}
+
+//------------------------------------------------------------------------
+
+void ScMoveTableDlg::InitDocListBox()
+{
+ SfxObjectShell* pSh = SfxObjectShell::GetFirst();
+ ScDocShell* pScSh = NULL;
+ sal_uInt16 nSelPos = 0;
+ sal_uInt16 i = 0;
+
+ aLbDoc.Clear();
+ aLbDoc.SetUpdateMode( sal_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( sal_True );
+ aLbDoc.InsertEntry( String( ScResId( STR_NEWDOC ) ) );
+ aLbDoc.SelectEntryPos( nSelPos );
+}
+
+
+//------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScMoveTableDlg, OkHdl, void *, EMPTYARG )
+{
+ sal_uInt16 nDocSel = aLbDoc.GetSelectEntryPos();
+ sal_uInt16 nDocLast = aLbDoc.GetEntryCount()-1;
+ sal_uInt16 nTabSel = aLbTable.GetSelectEntryPos();
+ sal_uInt16 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( sal_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( sal_True );
+ aLbTable.SelectEntryPos( 0 );
+ }
+
+ return 0;
+}
+
+
+
diff --git a/sc/source/ui/miscdlgs/namecrea.cxx b/sc/source/ui/miscdlgs/namecrea.cxx
new file mode 100644
index 000000000000..402881d9b3af
--- /dev/null
+++ b/sc/source/ui/miscdlgs/namecrea.cxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * 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, sal_uInt16 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) ? sal_True : sal_False );
+ aLeftBox.Check ( (nFlags & NAME_LEFT) ? sal_True : sal_False );
+ aBottomBox.Check( (nFlags & NAME_BOTTOM)? sal_True : sal_False );
+ aRightBox.Check ( (nFlags & NAME_RIGHT) ? sal_True : sal_False );
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------
+
+sal_uInt16 ScNameCreateDlg::GetFlags() const
+{
+ sal_uInt16 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;
+}
+
+
+
+
diff --git a/sc/source/ui/miscdlgs/namepast.cxx b/sc/source/ui/miscdlgs/namepast.cxx
new file mode 100644
index 000000000000..e79bb9300f14
--- /dev/null
+++ b/sc/source/ui/miscdlgs/namepast.cxx
@@ -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.
+ *
+ ************************************************************************/
+
+// 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, sal_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) );
+
+ sal_uInt16 nCnt = pList->GetCount();
+ String aText;
+
+ for( sal_uInt16 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();
+}
+
+
diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx
new file mode 100644
index 000000000000..c158a7035691
--- /dev/null
+++ b/sc/source/ui/miscdlgs/optsolver.cxx
@@ -0,0 +1,1079 @@
+/*************************************************************************
+ *
+ * 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(sal_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, sal_Bool bMax, sal_Bool bMin, sal_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;
+
+ maRbMax.SetAccessibleRelationMemberOf(&maFtDirection);
+ maRbMin.SetAccessibleRelationMemberOf(&maFtDirection);
+ maRbValue.SetAccessibleRelationMemberOf(&maFtDirection);
+ maEdLeft2.SetAccessibleName(maFtCellRef.GetText());
+ maLbOp2.SetAccessibleName(maFtOperator.GetText());
+ maEdRight2.SetAccessibleName(maFtConstraint.GetText());
+ maEdLeft3.SetAccessibleName(maFtCellRef.GetText());
+ maLbOp3.SetAccessibleName(maFtOperator.GetText());
+ maEdRight3.SetAccessibleName(maFtConstraint.GetText());
+ maEdLeft4.SetAccessibleName(maFtCellRef.GetText());
+ maLbOp4.SetAccessibleName(maFtOperator.GetText());
+ maEdRight4.SetAccessibleName(maFtConstraint.GetText());
+
+ 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, sal_False, sal_False );
+ Image aDelHC = ::GetImage( xFrame, aSlotURL, sal_False, sal_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() );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+sal_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
+ {
+ sal_uInt16 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();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool ScOptSolverDlg::IsRefInputMode() const
+{
+ return mpEdActive != NULL;
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScOptSolverDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &maBtnSolve || pBtn == &maBtnCancel )
+ {
+ bool bSolve = ( pBtn == &maBtnSolve );
+
+ SetDispatcherLock( sal_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( sal_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] )
+ {
+ sal_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);
+ sal_uInt16 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;
+ sal_uLong nRangeCount = aVarRanges.Count();
+ for (sal_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] ), sal_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] ), sal_True );
+ }
+ mpDocShell->UnlockPaint();
+ }
+
+ return bClose;
+}
+
diff --git a/sc/source/ui/miscdlgs/protectiondlg.cxx b/sc/source/ui/miscdlgs/protectiondlg.cxx
new file mode 100644
index 000000000000..1205d393c3f8
--- /dev/null
+++ b/sc/source/ui/miscdlgs/protectiondlg.cxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * 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 <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 sal_uInt16 nOptionCount = sizeof(aOptions)/sizeof(aOptions[0]);
+
+
+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 (sal_uInt16 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 (sal_uInt16 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;
+}
diff --git a/sc/source/ui/miscdlgs/protectiondlg.src b/sc/source/ui/miscdlgs/protectiondlg.src
new file mode 100644
index 000000000000..f46cb6700ded
--- /dev/null
+++ b/sc/source/ui/miscdlgs/protectiondlg.src
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * 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
+{
+ HelpID = "sc: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
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_TABPROTECTION: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
+ {
+ HelpID = "sc:Edit:RID_SCDLG_TABPROTECTION: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
+ {
+ HelpID = "sc:Edit:RID_SCDLG_TABPROTECTION: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..f5caffb8a0ab
--- /dev/null
+++ b/sc/source/ui/miscdlgs/redcom.cxx
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * 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> //CHINA001
+#include <svx/dialogs.hrc> //CHINA001
+//------------------------------------------------------------------------
+
+ScRedComDialog::ScRedComDialog( Window* pParent, const SfxItemSet& rCoreSet,
+ ScDocShell *pShell,ScChangeAction *pAction,sal_Bool bPrevNext)
+{
+ //CHINA001 pDlg = new SvxPostItDialog(pParent,rCoreSet,bPrevNext,sal_True);
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ pDlg = pFact->CreateSvxPostItDialog( pParent, rCoreSet, bPrevNext, sal_True );
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
+ 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();
+
+ sal_Bool bNext=FindNext(pChangeAction)!=NULL;
+ sal_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, sal_False, sal_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;
+}
+
diff --git a/sc/source/ui/miscdlgs/retypepassdlg.cxx b/sc/source/ui/miscdlgs/retypepassdlg.cxx
new file mode 100644
index 000000000000..24e5dc409c83
--- /dev/null
+++ b/sc/source/ui/miscdlgs/retypepassdlg.cxx
@@ -0,0 +1,544 @@
+/*************************************************************************
+ *
+ * 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_OOO)
+{
+ 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;
+}
diff --git a/sc/source/ui/miscdlgs/retypepassdlg.src b/sc/source/ui/miscdlgs/retypepassdlg.src
new file mode 100644
index 000000000000..daf563201587
--- /dev/null
+++ b/sc/source/ui/miscdlgs/retypepassdlg.src
@@ -0,0 +1,325 @@
+/*************************************************************************
+ *
+ * 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
+{
+ HelpID = "sc: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
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_RETYPEPASS: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
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_RETYPEPASS: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
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_RETYPEPASS: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
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_RETYPEPASS: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
+ {
+ HelpID = "sc:PushButton:RID_SCDLG_RETYPEPASS: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
+{
+ HelpID = "sc: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
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_RETYPEPASS_INPUT: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
+ {
+ HelpID = "sc:Edit:RID_SCDLG_RETYPEPASS_INPUT: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
+ {
+ HelpID = "sc:Edit:RID_SCDLG_RETYPEPASS_INPUT:ED_PASSWORD2";
+ Border = TRUE;
+ PassWord = TRUE;
+ Pos = MAP_APPFONT ( 65, 44 );
+ Size = MAP_APPFONT ( 75, 12 );
+ };
+
+ CheckBox BTN_MATCH_OLD_PASSWORD
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_RETYPEPASS_INPUT: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
+ {
+ HelpID = "sc:RadioButton:RID_SCDLG_RETYPEPASS_INPUT: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..0812be6c4360
--- /dev/null
+++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx
@@ -0,0 +1,476 @@
+/*************************************************************************
+ *
+ * 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 <sfx2/sfxresid.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( sal_False ),
+ bFmtInserted ( sal_False )
+{
+ Init();
+ pWndPreview->NotifyChange( (*pFormat)[0] );
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScAutoFormatDlg::~ScAutoFormatDlg()
+{
+ delete pWndPreview;
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFormatDlg::Init()
+{
+ sal_uInt16 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 ( sal_uInt16 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 = sal_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];
+ sal_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 = sal_True;
+ }
+
+ pWndPreview->NotifyChange( pData );
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScAutoFormatDlg, AddHdl, void *, EMPTYARG )
+{
+ if ( !bFmtInserted && pSelFmtData )
+ {
+ String aStrStandard( SfxResId(STR_STANDARD) );
+ String aFormatName;
+ ScStringInputDlg* pDlg;
+ sal_Bool bOk = sal_False;
+
+ while ( !bOk )
+ {
+ pDlg = new ScStringInputDlg( this,
+ aStrTitle,
+ aStrLabel,
+ aFormatName,
+ HID_SC_ADD_AUTOFMT, HID_SC_AUTOFMT_NAME );
+
+ 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 )
+ {
+ sal_uInt16 nAt = pFormat->IndexOf( pNewData );
+
+ aLbFormat.InsertEntry( aFormatName, nAt );
+ aLbFormat.SelectEntry( aFormatName );
+ aBtnAdd.Disable();
+
+ if ( !bCoreDataChanged )
+ {
+ aBtnCancel.SetText( aStrClose );
+ bCoreDataChanged = sal_True;
+ }
+
+ SelFmtHdl( 0 );
+ bOk = sal_True;
+ }
+ else
+ delete pNewData;
+
+ }
+
+ if ( !bFmtInserted )
+ {
+ sal_uInt16 nRet = ErrorBox( this,
+ WinBits( WB_OK_CANCEL | WB_DEF_OK),
+ ScGlobal::GetRscString(STR_INVALID_AFNAME)
+ ).Execute();
+
+ bOk = ( nRet == RET_CANCEL );
+ }
+ }
+ else
+ bOk = sal_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 = sal_True;
+ }
+
+ pFormat->AtFree( nIndex ); // in der Core loeschen
+ nIndex--;
+
+ SelFmtHdl( 0 );
+ }
+ }
+
+ SelFmtHdl( 0 );
+
+ return 0;
+}
+
+IMPL_LINK( ScAutoFormatDlg, RenameHdl, void *, EMPTYARG )
+{
+ sal_Bool bOk = sal_False;
+ while( !bOk )
+ {
+
+ String aFormatName=aLbFormat.GetSelectEntry();
+ String aEntry;
+
+ ScStringInputDlg* pDlg = new ScStringInputDlg( this,
+ aStrRename,
+ aStrLabel,
+ aFormatName,
+ HID_SC_REN_AFMT_DLG, HID_SC_REN_AFMT_NAME );
+ if( pDlg->Execute() == RET_OK )
+ {
+ sal_Bool bFmtRenamed = sal_False;
+ pDlg->GetInputString( aFormatName );
+ sal_uInt16 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);
+
+ sal_uInt16 nCount = pFormat->GetCount();
+
+ aLbFormat.SetUpdateMode(sal_False);
+ aLbFormat.Clear();
+ for ( sal_uInt16 i = 0; i < nCount; i++ )
+ {
+ ((*pFormat)[i])->GetName( aEntry );
+ aLbFormat.InsertEntry( aEntry );
+ }
+
+ aLbFormat.SetUpdateMode( sal_True);
+ aLbFormat.SelectEntry( aFormatName);
+
+ if ( !bCoreDataChanged )
+ {
+ aBtnCancel.SetText( aStrClose );
+ bCoreDataChanged = sal_True;
+ }
+
+
+ SelFmtHdl( 0 );
+ bOk = sal_True;
+ bFmtRenamed = sal_True;
+ }
+ }
+ if( !bFmtRenamed )
+ {
+ bOk = RET_CANCEL == ErrorBox( this,
+ WinBits( WB_OK_CANCEL | WB_DEF_OK),
+ ScGlobal::GetRscString(STR_INVALID_AFNAME)
+ ).Execute();
+ }
+ }
+ else
+ bOk = sal_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;
+}
diff --git a/sc/source/ui/miscdlgs/sharedocdlg.cxx b/sc/source/ui/miscdlgs/sharedocdlg.cxx
new file mode 100644
index 000000000000..8730932c6f91
--- /dev/null
+++ b/sc/source/ui/miscdlgs/sharedocdlg.cxx
@@ -0,0 +1,235 @@
+/*************************************************************************
+ *
+ * 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;
+ sal_uInt16 nDay = sal::static_int_cast< sal_uInt16 >( aDateStr.getToken( 0, '.', nIndex ).toInt32() );
+ sal_uInt16 nMonth = sal::static_int_cast< sal_uInt16 >( aDateStr.getToken( 0, '.', nIndex ).toInt32() );
+ sal_uInt16 nYear = sal::static_int_cast< sal_uInt16 >( aDateStr.getToken( 0, '.', nIndex ).toInt32() );
+ nIndex = 0;
+ sal_uInt16 nHours = sal::static_int_cast< sal_uInt16 >( aTimeStr.getToken( 0, ':', nIndex ).toInt32() );
+ sal_uInt16 nMinutes = sal::static_int_cast< sal_uInt16 >( 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, sal_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, sal_False );
+
+ maLbUsers.InsertEntry( aString, NULL );
+ }
+}
diff --git a/sc/source/ui/miscdlgs/sharedocdlg.src b/sc/source/ui/miscdlgs/sharedocdlg.src
new file mode 100644
index 000000000000..2accd0300bbd
--- /dev/null
+++ b/sc/source/ui/miscdlgs/sharedocdlg.src
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * 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 = CMD_SID_SHARE_DOC ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 204 , 186 ) ;
+ Text [ en-US ] = "Share Document" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ CheckBox CB_SHARE
+ {
+ HelpID = "sc:CheckBox:RID_SCDLG_SHAREDOCUMENT: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..cf0059a12ceb
--- /dev/null
+++ b/sc/source/ui/miscdlgs/shtabdlg.cxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * 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 ) ),
+ aFtLbTitle ( this, ScResId( FT_LABEL ) ),
+ aLb ( this, ScResId( LB_ENTRYLIST ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ aLb.Clear();
+ aLb.SetDoubleClickHdl( LINK( this, ScShowTabDlg, DblClkHdl ) );
+
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+void ScShowTabDlg::SetDescription(
+ const String& rTitle, const String& rFixedText,
+ const rtl::OString& rDlgHelpId, const rtl::OString& sLbHelpId )
+{
+ SetText( rTitle );
+ aFtLbTitle.SetText( rFixedText );
+ SetHelpId( rDlgHelpId );
+ aLb.SetHelpId( sLbHelpId );
+}
+
+void ScShowTabDlg::Insert( const String& rString, sal_Bool bSelected )
+{
+ aLb.InsertEntry( rString );
+ if( bSelected )
+ aLb.SelectEntryPos( aLb.GetEntryCount() - 1 );
+}
+
+//------------------------------------------------------------------------
+
+sal_uInt16 ScShowTabDlg::GetSelectEntryCount() const
+{
+ return aLb.GetSelectEntryCount();
+}
+
+String ScShowTabDlg::GetSelectEntry(sal_uInt16 nPos) const
+{
+ return aLb.GetSelectEntry(nPos);
+}
+
+sal_uInt16 ScShowTabDlg::GetSelectEntryPos(sal_uInt16 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()
+{
+}
+
+
+
diff --git a/sc/source/ui/miscdlgs/simpref.cxx b/sc/source/ui/miscdlgs/simpref.cxx
new file mode 100644
index 000000000000..1157f42c9dd6
--- /dev/null
+++ b/sc/source/ui/miscdlgs/simpref.cxx
@@ -0,0 +1,257 @@
+/*************************************************************************
+ *
+ * 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 ( sal_False ),
+ bAutoReOpen ( sal_True ),
+ bCloseOnButtonUp( sal_False ),
+ bSingleCell ( sal_False ),
+ bMultiSelection ( sal_False )
+{
+ // damit die Strings in der Resource bei den FixedTexten bleiben koennen:
+ Init();
+ FreeResource();
+ SetDispatcherLock( sal_True ); // Modal-Modus einschalten
+}
+
+//----------------------------------------------------------------------------
+__EXPORT ScSimpleRefDlg::~ScSimpleRefDlg()
+{
+ SetDispatcherLock( sal_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=sal_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 );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+sal_Bool __EXPORT ScSimpleRefDlg::Close()
+{
+ CancelBtnHdl(&aBtnCancel);
+ return sal_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();
+}
+//------------------------------------------------------------------------
+sal_Bool ScSimpleRefDlg::IsRefInputMode() const
+{
+ return sal_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( sal_Bool bSetCloseOnButtonUp, sal_Bool bSetSingleCell, sal_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=sal_True;
+}
+
+void ScSimpleRefDlg::RefInputDone( sal_Bool bForced)
+{
+ ScAnyRefDlg::RefInputDone(bForced);
+ if ( (bForced || bCloseOnButtonUp) && bCloseFlag )
+ OkBtnHdl(&aBtnOk);
+}
+//------------------------------------------------------------------------
+// Handler:
+// ========
+IMPL_LINK( ScSimpleRefDlg, OkBtnHdl, void *, EMPTYARG )
+{
+ bAutoReOpen=sal_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=sal_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;
+}
+
+
+
+//------------------------------------------------------------------------
+
diff --git a/sc/source/ui/miscdlgs/solveroptions.cxx b/sc/source/ui/miscdlgs/solveroptions.cxx
new file mode 100644
index 000000000000..8bbc93df0009
--- /dev/null
+++ b/sc/source/ui/miscdlgs/solveroptions.cxx
@@ -0,0 +1,492 @@
+/*************************************************************************
+ *
+ * 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, sal_uInt16 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, sal_uInt16 nFlags, SvLBoxEntry* pEntry );
+};
+
+void ScSolverOptionsString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16, 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.SetStyle( maLbSettings.GetStyle()|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<sal_uInt16>(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;
+ sal_uInt16 nItemCount = pEntry->ItemCount();
+ for (sal_uInt16 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(sal_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(sal_True);
+}
+
+void ScSolverOptionsDialog::ReadFromComponent()
+{
+ maProperties = ScSolverUtil::GetDefaults( maEngine );
+}
+
+void ScSolverOptionsDialog::EditOption()
+{
+ SvLBoxEntry* pEntry = maLbSettings.GetCurEntry();
+ if (pEntry)
+ {
+ sal_uInt16 nItemCount = pEntry->ItemCount();
+ for (sal_uInt16 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 )
+{
+ sal_uInt16 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 )
+{
+ sal_Bool bCheckbox = sal_False;
+
+ SvLBoxEntry* pEntry = maLbSettings.GetCurEntry();
+ if (pEntry)
+ {
+ SvLBoxItem* pItem = pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON);
+ if ( pItem && pItem->IsA() == SV_ITEM_ID_LBOXBUTTON )
+ bCheckbox = sal_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;
+}
+
diff --git a/sc/source/ui/miscdlgs/solverutil.cxx b/sc/source/ui/miscdlgs/solverutil.cxx
new file mode 100644
index 000000000000..ae080f2525c7
--- /dev/null
+++ b/sc/source/ui/miscdlgs/solverutil.cxx
@@ -0,0 +1,229 @@
+/*************************************************************************
+ *
+ * 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::createFromAscii("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::createFromAscii(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::createFromAscii("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::createFromAscii(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;
+}
+
diff --git a/sc/source/ui/miscdlgs/solvrdlg.cxx b/sc/source/ui/miscdlgs/solvrdlg.cxx
new file mode 100644
index 000000000000..e3e58b8f75ad
--- /dev/null
+++ b/sc/source/ui/miscdlgs/solvrdlg.cxx
@@ -0,0 +1,316 @@
+/*************************************************************************
+ *
+ * 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 ( sal_False ),
+ errMsgInvalidVar ( ScResId( STR_INVALIDVAR ) ),
+ errMsgInvalidForm ( ScResId( STR_INVALIDFORM ) ),
+ errMsgNoFormula ( ScResId( STR_NOFORMULA ) ),
+ errMsgInvalidVal ( ScResId( STR_INVALIDVAL ) )
+{
+ Init();
+ FreeResource();
+
+ aRBFormulaCell.SetAccessibleRelationMemberOf(&aFlVariables);
+ aRBVariableCell.SetAccessibleRelationMemberOf(&aFlVariables);
+}
+
+//----------------------------------------------------------------------------
+
+__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;
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool __EXPORT ScSolverDlg::Close()
+{
+ return DoClose( ScSolverDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScSolverDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = sal_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;
+ sal_uInt16 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;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool ScSolverDlg::IsRefInputMode() const
+{
+ return pEdActive != NULL;
+}
+
+//----------------------------------------------------------------------------
+
+sal_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();
+ sal_uInt16 nRes1 = theFormulaCell .Parse( aEdFormulaCell.GetText(), pDoc, eConv );
+ sal_uInt16 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( sal_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;
+}
+
+
+
+
diff --git a/sc/source/ui/miscdlgs/strindlg.cxx b/sc/source/ui/miscdlgs/strindlg.cxx
new file mode 100644
index 000000000000..db042d9b3a6d
--- /dev/null
+++ b/sc/source/ui/miscdlgs/strindlg.cxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * 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,
+ const rtl::OString& sHelpId, const rtl::OString& sEditHelpId ) :
+ 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( sHelpId );
+ SetText( rTitle );
+ aFtEditTitle.SetText( rEditTitle );
+ aEdInput.SetText( rDefault );
+ aEdInput.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
+ aEdInput.SetHelpId( sEditHelpId );
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+void ScStringInputDlg::GetInputString( String& rString ) const
+{
+ rString = aEdInput.GetText();
+}
+
+__EXPORT ScStringInputDlg::~ScStringInputDlg()
+{
+}
+
+
+
diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
new file mode 100644
index 000000000000..2419b0d36f55
--- /dev/null
+++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
@@ -0,0 +1,198 @@
+/*************************************************************************
+ *
+ * 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,
+ const rtl::OString& sHelpId ) :
+ 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 ),
+ msHelpId ( sHelpId )
+
+{
+ SetHelpId( sHelpId );
+ 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 );
+ sal_uInt16 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
+*/
+{
+ sal_uInt16 nItemId = aTabBgColorSet.GetSelectItemId();
+ Color aColor = nItemId ? ( aTabBgColorSet.GetItemColor( nItemId ) ) : Color( COL_AUTO );
+ aTabBgColor = aColor;
+ EndDialog( sal_True );
+ return 0;
+}
+
+IMPL_LINK( ScTabBgColorDlg, TabBgColorOKHdl_Impl, OKButton*, EMPTYARG )
+{
+
+// Handler, called when the OK button is pushed
+
+ sal_uInt16 nItemId = aTabBgColorSet.GetSelectItemId();
+ Color aColor = nItemId ? ( aTabBgColorSet.GetItemColor( nItemId ) ) : Color( COL_AUTO );
+ aTabBgColor = aColor;
+ EndDialog( sal_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:
+ {
+ sal_uInt16 nItemId = GetSelectItemId();
+ const Color& aColor = nItemId ? ( GetItemColor( nItemId ) ) : Color( COL_AUTO );
+ aTabBgColorDlg->aTabBgColor = aColor;
+ aTabBgColorDlg->EndDialog(sal_True);
+ }
+ break;
+ }
+ ValueSet::KeyInput(rKEvt);
+}
diff --git a/sc/source/ui/miscdlgs/tabopdlg.cxx b/sc/source/ui/miscdlgs/tabopdlg.cxx
new file mode 100644
index 000000000000..0c2d3ced899c
--- /dev/null
+++ b/sc/source/ui/miscdlgs/tabopdlg.cxx
@@ -0,0 +1,371 @@
+/*************************************************************************
+ *
+ * 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 ( sal_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();
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool __EXPORT ScTabOpDlg::Close()
+{
+ return DoClose( ScTabOpDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScTabOpDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = sal_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;
+ sal_uInt16 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();
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool lcl_Parse( const String& rString, ScDocument* pDoc, SCTAB nCurTab,
+ ScRefAddress& rStart, ScRefAddress& rEnd )
+{
+ sal_Bool bRet = sal_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 )
+ {
+ sal_uInt8 nMode = 3;
+ sal_uInt16 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( sal_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;
+}
+
+
+
+
+
diff --git a/sc/source/ui/miscdlgs/textdlgs.cxx b/sc/source/ui/miscdlgs/textdlgs.cxx
new file mode 100644
index 000000000000..5d9994922957
--- /dev/null
+++ b/sc/source/ui/miscdlgs/textdlgs.cxx
@@ -0,0 +1,140 @@
+/*************************************************************************
+ *
+ * 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>
+
+//CHINA001 #include <svx/chardlg.hxx>
+#include <editeng/flstitem.hxx>
+//CHINA001 #include <svx/paragrph.hxx>
+//CHINA001 #include <svx/tabstpge.hxx>
+#include <sfx2/objsh.hxx>
+#include <svl/cjkoptions.hxx>
+
+#include "textdlgs.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include <svx/svxids.hrc> //add CHINA001
+#include <svl/intitem.hxx> //add CHINA001
+#include <svx/flagsdef.hxx> //CHINA001
+// -----------------------------------------------------------------------
+
+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 ); //CHINA001 AddTabPage( RID_SVXPAGE_CHAR_NAME, SvxCharNamePage::Create, 0);
+ AddTabPage( RID_SVXPAGE_CHAR_EFFECTS ); //CHINA001 AddTabPage( RID_SVXPAGE_CHAR_EFFECTS, SvxCharEffectsPage::Create, 0);
+ AddTabPage( RID_SVXPAGE_CHAR_POSITION ); //CHINA001 AddTabPage( RID_SVXPAGE_CHAR_POSITION, SvxCharPositionPage::Create, 0);
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScCharDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
+{
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); //CHINA001
+ switch( nId )
+ {
+ case RID_SVXPAGE_CHAR_NAME:
+ {
+ SvxFontListItem aItem(*( (const SvxFontListItem*)
+ ( rDocShell.GetItem( SID_ATTR_CHAR_FONTLIST) ) ) );
+
+ //CHINA001 ( (SvxCharNamePage&) rPage ).SetFontList( aItem );
+ aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
+ rPage.PageCreated(aSet);
+ }
+ break;
+
+ case RID_SVXPAGE_CHAR_EFFECTS:
+ //CHINA001 ( (SvxCharEffectsPage&) rPage ).DisableControls(
+ //CHINA001 DISABLE_CASEMAP);
+ aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_CASEMAP)); //CHINA001
+ 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 );//CHINA001 AddTabPage( RID_SVXPAGE_STD_PARAGRAPH, SvxStdParagraphTabPage::Create, 0);
+ AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH );//CHINA001 AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH, SvxParaAlignTabPage::Create, 0);
+ //AddTabPage( RID_SVXPAGE_EXT_PARAGRAPH, SvxExtParagraphTabPage::Create, 0);
+ if ( aCJKOptions.IsAsianTypographyEnabled() )
+ AddTabPage( RID_SVXPAGE_PARA_ASIAN);//CHINA001 AddTabPage( RID_SVXPAGE_PARA_ASIAN, SvxAsianTabPage::Create,0);
+ else
+ RemoveTabPage( RID_SVXPAGE_PARA_ASIAN );
+ AddTabPage( RID_SVXPAGE_TABULATOR );//CHINA001 AddTabPage( RID_SVXPAGE_TABULATOR, SvxTabulatorTabPage::Create, 0);
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScParagraphDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
+{
+ switch( nId )
+ {
+ case RID_SVXPAGE_TABULATOR:
+ {
+ //CHINA001 ( (SvxTabulatorTabPage&) rPage ).
+ //CHINA001 DisableControls( TABTYPE_ALL &~TABTYPE_LEFT |
+ //CHINA001 TABFILL_ALL &~TABFILL_NONE );
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));//add CHINA001
+ aSet.Put(SfxUInt16Item(SID_SVXTABULATORTABPAGE_CONTROLFLAGS,(TABTYPE_ALL &~TABTYPE_LEFT) |
+ (TABFILL_ALL &~TABFILL_NONE) ));
+ rPage.PageCreated(aSet);//add CHINA001
+ }
+ break;
+ }
+}
+
+
+
diff --git a/sc/source/ui/miscdlgs/warnbox.cxx b/sc/source/ui/miscdlgs/warnbox.cxx
new file mode 100644
index 000000000000..e230b9c2df25
--- /dev/null
+++ b/sc/source/ui/miscdlgs/warnbox.cxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * 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() == sal_True;
+}
+
+void ScReplaceWarnBox::DisableDialog()
+{
+ ScModule* pScMod = SC_MOD();
+ ScInputOptions aInputOpt( pScMod->GetInputOptions() );
+ aInputOpt.SetReplaceCellsWarn( sal_False );
+ pScMod->SetInputOptions( aInputOpt );
+}
+
+
+// ============================================================================
+