1*b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b3f79822SAndrew Rist * distributed with this work for additional information 6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10*b3f79822SAndrew Rist * 11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*b3f79822SAndrew Rist * 13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b3f79822SAndrew Rist * software distributed under the License is distributed on an 15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17*b3f79822SAndrew Rist * specific language governing permissions and limitations 18*b3f79822SAndrew Rist * under the License. 19*b3f79822SAndrew Rist * 20*b3f79822SAndrew Rist *************************************************************/ 21*b3f79822SAndrew Rist 22*b3f79822SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sc.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #undef SC_DLLIMPLEMENTATION 28cdf0e10cSrcweir 29cdf0e10cSrcweir 30cdf0e10cSrcweir 31cdf0e10cSrcweir //------------------------------------------------------------------ 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <vcl/msgbox.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include "mvtabdlg.hxx" 36cdf0e10cSrcweir #include "document.hxx" 37cdf0e10cSrcweir #include "docsh.hxx" 38cdf0e10cSrcweir #include "miscdlgs.hrc" 39cdf0e10cSrcweir #include "global.hxx" 40cdf0e10cSrcweir #include "scresid.hxx" 41cdf0e10cSrcweir #include "globstr.hrc" 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include <layout/layout-pre.hxx> 44cdf0e10cSrcweir 45cdf0e10cSrcweir #if ENABLE_LAYOUT 46cdf0e10cSrcweir #undef ScResId 47cdf0e10cSrcweir #define ScResId(x) #x 48cdf0e10cSrcweir #undef ModalDialog 49cdf0e10cSrcweir #define ModalDialog( parent, id ) Dialog( parent, "move-copy-sheet.xml", id ) 50cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */ 51cdf0e10cSrcweir 52cdf0e10cSrcweir //================================================================== 53cdf0e10cSrcweir 54cdf0e10cSrcweir ScMoveTableDlg::ScMoveTableDlg( Window* pParent ) 55cdf0e10cSrcweir 56cdf0e10cSrcweir : ModalDialog ( pParent, ScResId( RID_SCDLG_MOVETAB ) ), 57cdf0e10cSrcweir // 58cdf0e10cSrcweir aFtDoc ( this, ScResId( FT_DEST ) ), 59cdf0e10cSrcweir aLbDoc ( this, ScResId( LB_DEST ) ), 60cdf0e10cSrcweir aFtTable ( this, ScResId( FT_INSERT ) ), 61cdf0e10cSrcweir aLbTable ( this, ScResId( LB_INSERT ) ), 62cdf0e10cSrcweir aBtnCopy ( this, ScResId( BTN_COPY ) ), 63cdf0e10cSrcweir aBtnOk ( this, ScResId( BTN_OK ) ), 64cdf0e10cSrcweir aBtnCancel ( this, ScResId( BTN_CANCEL ) ), 65cdf0e10cSrcweir aBtnHelp ( this, ScResId( BTN_HELP ) ), 66cdf0e10cSrcweir // 67cdf0e10cSrcweir nDocument ( 0 ), 68cdf0e10cSrcweir nTable ( 0 ), 69cdf0e10cSrcweir bCopyTable ( sal_False ) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir #if ENABLE_LAYOUT 72cdf0e10cSrcweir #undef ScResId 73cdf0e10cSrcweir SetHelpId (FID_TAB_MOVE); 74cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */ 75cdf0e10cSrcweir Init(); 76cdf0e10cSrcweir FreeResource(); 77cdf0e10cSrcweir } 78cdf0e10cSrcweir 79cdf0e10cSrcweir //------------------------------------------------------------------------ 80cdf0e10cSrcweir 81cdf0e10cSrcweir __EXPORT ScMoveTableDlg::~ScMoveTableDlg() 82cdf0e10cSrcweir { 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir //------------------------------------------------------------------------ 86cdf0e10cSrcweir 87cdf0e10cSrcweir sal_uInt16 ScMoveTableDlg::GetSelectedDocument () const { return nDocument; } 88cdf0e10cSrcweir 89cdf0e10cSrcweir SCTAB ScMoveTableDlg::GetSelectedTable () const { return nTable; } 90cdf0e10cSrcweir 91cdf0e10cSrcweir sal_Bool ScMoveTableDlg::GetCopyTable () const { return bCopyTable; } 92cdf0e10cSrcweir 93cdf0e10cSrcweir void ScMoveTableDlg::SetCopyTable(sal_Bool bFlag) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir aBtnCopy.Check(bFlag); 96cdf0e10cSrcweir } 97cdf0e10cSrcweir void ScMoveTableDlg::EnableCopyTable(sal_Bool bFlag) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir if(bFlag) 100cdf0e10cSrcweir aBtnCopy.Enable(); 101cdf0e10cSrcweir else 102cdf0e10cSrcweir aBtnCopy.Disable(); 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir 106cdf0e10cSrcweir //------------------------------------------------------------------------ 107cdf0e10cSrcweir 108cdf0e10cSrcweir void __EXPORT ScMoveTableDlg::Init() 109cdf0e10cSrcweir { 110cdf0e10cSrcweir aBtnOk.SetClickHdl ( LINK( this, ScMoveTableDlg, OkHdl ) ); 111cdf0e10cSrcweir aLbDoc.SetSelectHdl ( LINK( this, ScMoveTableDlg, SelHdl ) ); 112cdf0e10cSrcweir aBtnCopy.Check( sal_False ); 113cdf0e10cSrcweir InitDocListBox(); 114cdf0e10cSrcweir SelHdl( &aLbDoc ); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir //------------------------------------------------------------------------ 118cdf0e10cSrcweir 119cdf0e10cSrcweir void ScMoveTableDlg::InitDocListBox() 120cdf0e10cSrcweir { 121cdf0e10cSrcweir SfxObjectShell* pSh = SfxObjectShell::GetFirst(); 122cdf0e10cSrcweir ScDocShell* pScSh = NULL; 123cdf0e10cSrcweir sal_uInt16 nSelPos = 0; 124cdf0e10cSrcweir sal_uInt16 i = 0; 125cdf0e10cSrcweir 126cdf0e10cSrcweir aLbDoc.Clear(); 127cdf0e10cSrcweir aLbDoc.SetUpdateMode( sal_False ); 128cdf0e10cSrcweir 129cdf0e10cSrcweir while ( pSh ) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir pScSh = PTR_CAST( ScDocShell, pSh ); 132cdf0e10cSrcweir 133cdf0e10cSrcweir if ( pScSh ) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir if ( pScSh == SfxObjectShell::Current() ) 136cdf0e10cSrcweir nSelPos = i; 137cdf0e10cSrcweir 138cdf0e10cSrcweir aLbDoc.InsertEntry( pScSh->GetTitle(), i ); 139cdf0e10cSrcweir aLbDoc.SetEntryData( i, (void*)pScSh->GetDocument() ); 140cdf0e10cSrcweir 141cdf0e10cSrcweir i++; 142cdf0e10cSrcweir } 143cdf0e10cSrcweir pSh = SfxObjectShell::GetNext( *pSh ); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 146cdf0e10cSrcweir aLbDoc.SetUpdateMode( sal_True ); 147cdf0e10cSrcweir aLbDoc.InsertEntry( String( ScResId( STR_NEWDOC ) ) ); 148cdf0e10cSrcweir aLbDoc.SelectEntryPos( nSelPos ); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir 152cdf0e10cSrcweir //------------------------------------------------------------------------ 153cdf0e10cSrcweir // Handler: 154cdf0e10cSrcweir 155cdf0e10cSrcweir IMPL_LINK( ScMoveTableDlg, OkHdl, void *, EMPTYARG ) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir sal_uInt16 nDocSel = aLbDoc.GetSelectEntryPos(); 158cdf0e10cSrcweir sal_uInt16 nDocLast = aLbDoc.GetEntryCount()-1; 159cdf0e10cSrcweir sal_uInt16 nTabSel = aLbTable.GetSelectEntryPos(); 160cdf0e10cSrcweir sal_uInt16 nTabLast = aLbTable.GetEntryCount()-1; 161cdf0e10cSrcweir 162cdf0e10cSrcweir nDocument = (nDocSel != nDocLast) ? nDocSel : SC_DOC_NEW; 163cdf0e10cSrcweir nTable = (nTabSel != nTabLast) ? static_cast<SCTAB>(nTabSel) : SC_TAB_APPEND; 164cdf0e10cSrcweir bCopyTable = aBtnCopy.IsChecked(); 165cdf0e10cSrcweir EndDialog( RET_OK ); 166cdf0e10cSrcweir 167cdf0e10cSrcweir return 0; 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir //------------------------------------------------------------------------ 171cdf0e10cSrcweir 172cdf0e10cSrcweir IMPL_LINK( ScMoveTableDlg, SelHdl, ListBox *, pLb ) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir if ( pLb == &aLbDoc ) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir ScDocument* pDoc = (ScDocument*) 177cdf0e10cSrcweir aLbDoc.GetEntryData( aLbDoc.GetSelectEntryPos() ); 178cdf0e10cSrcweir SCTAB nLast = 0; 179cdf0e10cSrcweir String aName; 180cdf0e10cSrcweir 181cdf0e10cSrcweir aLbTable.Clear(); 182cdf0e10cSrcweir aLbTable.SetUpdateMode( sal_False ); 183cdf0e10cSrcweir if ( pDoc ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir nLast = pDoc->GetTableCount()-1; 186cdf0e10cSrcweir for ( SCTAB i=0; i<=nLast; i++ ) 187cdf0e10cSrcweir { 188cdf0e10cSrcweir pDoc->GetName( i, aName ); 189cdf0e10cSrcweir aLbTable.InsertEntry( aName, static_cast<sal_uInt16>(i) ); 190cdf0e10cSrcweir } 191cdf0e10cSrcweir } 192cdf0e10cSrcweir aLbTable.InsertEntry( ScGlobal::GetRscString(STR_MOVE_TO_END) ); 193cdf0e10cSrcweir aLbTable.SetUpdateMode( sal_True ); 194cdf0e10cSrcweir aLbTable.SelectEntryPos( 0 ); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir return 0; 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir 201cdf0e10cSrcweir 202