1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mvtabdlg.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #undef SC_DLLIMPLEMENTATION
38 //------------------------------------------------------------------
40 #include <vcl/msgbox.hxx>
42 #include "mvtabdlg.hxx"
43 #include "document.hxx"
45 #include "miscdlgs.hrc"
47 #include "scresid.hxx"
48 #include "globstr.hrc"
50 #include <layout/layout-pre.hxx>
56 #define ModalDialog( parent, id ) Dialog( parent, "move-copy-sheet.xml", id )
57 #endif /* ENABLE_LAYOUT */
59 //==================================================================
61 ScMoveTableDlg::ScMoveTableDlg( Window
* pParent
)
63 : ModalDialog ( pParent
, ScResId( RID_SCDLG_MOVETAB
) ),
65 aFtDoc ( this, ScResId( FT_DEST
) ),
66 aLbDoc ( this, ScResId( LB_DEST
) ),
67 aFtTable ( this, ScResId( FT_INSERT
) ),
68 aLbTable ( this, ScResId( LB_INSERT
) ),
69 aBtnCopy ( this, ScResId( BTN_COPY
) ),
70 aBtnOk ( this, ScResId( BTN_OK
) ),
71 aBtnCancel ( this, ScResId( BTN_CANCEL
) ),
72 aBtnHelp ( this, ScResId( BTN_HELP
) ),
80 SetHelpId (FID_TAB_MOVE
);
81 #endif /* ENABLE_LAYOUT */
86 //------------------------------------------------------------------------
88 __EXPORT
ScMoveTableDlg::~ScMoveTableDlg()
92 //------------------------------------------------------------------------
94 USHORT
ScMoveTableDlg::GetSelectedDocument () const { return nDocument
; }
96 SCTAB
ScMoveTableDlg::GetSelectedTable () const { return nTable
; }
98 BOOL
ScMoveTableDlg::GetCopyTable () const { return bCopyTable
; }
100 void ScMoveTableDlg::SetCopyTable(BOOL bFlag
)
102 aBtnCopy
.Check(bFlag
);
104 void ScMoveTableDlg::EnableCopyTable(BOOL bFlag
)
113 //------------------------------------------------------------------------
115 void __EXPORT
ScMoveTableDlg::Init()
117 aBtnOk
.SetClickHdl ( LINK( this, ScMoveTableDlg
, OkHdl
) );
118 aLbDoc
.SetSelectHdl ( LINK( this, ScMoveTableDlg
, SelHdl
) );
119 aBtnCopy
.Check( FALSE
);
124 //------------------------------------------------------------------------
126 void ScMoveTableDlg::InitDocListBox()
128 SfxObjectShell
* pSh
= SfxObjectShell::GetFirst();
129 ScDocShell
* pScSh
= NULL
;
134 aLbDoc
.SetUpdateMode( FALSE
);
138 pScSh
= PTR_CAST( ScDocShell
, pSh
);
142 if ( pScSh
== SfxObjectShell::Current() )
145 aLbDoc
.InsertEntry( pScSh
->GetTitle(), i
);
146 aLbDoc
.SetEntryData( i
, (void*)pScSh
->GetDocument() );
150 pSh
= SfxObjectShell::GetNext( *pSh
);
153 aLbDoc
.SetUpdateMode( TRUE
);
154 aLbDoc
.InsertEntry( String( ScResId( STR_NEWDOC
) ) );
155 aLbDoc
.SelectEntryPos( nSelPos
);
159 //------------------------------------------------------------------------
162 IMPL_LINK( ScMoveTableDlg
, OkHdl
, void *, EMPTYARG
)
164 USHORT nDocSel
= aLbDoc
.GetSelectEntryPos();
165 USHORT nDocLast
= aLbDoc
.GetEntryCount()-1;
166 USHORT nTabSel
= aLbTable
.GetSelectEntryPos();
167 USHORT nTabLast
= aLbTable
.GetEntryCount()-1;
169 nDocument
= (nDocSel
!= nDocLast
) ? nDocSel
: SC_DOC_NEW
;
170 nTable
= (nTabSel
!= nTabLast
) ? static_cast<SCTAB
>(nTabSel
) : SC_TAB_APPEND
;
171 bCopyTable
= aBtnCopy
.IsChecked();
177 //------------------------------------------------------------------------
179 IMPL_LINK( ScMoveTableDlg
, SelHdl
, ListBox
*, pLb
)
181 if ( pLb
== &aLbDoc
)
183 ScDocument
* pDoc
= (ScDocument
*)
184 aLbDoc
.GetEntryData( aLbDoc
.GetSelectEntryPos() );
189 aLbTable
.SetUpdateMode( FALSE
);
192 nLast
= pDoc
->GetTableCount()-1;
193 for ( SCTAB i
=0; i
<=nLast
; i
++ )
195 pDoc
->GetName( i
, aName
);
196 aLbTable
.InsertEntry( aName
, static_cast<sal_uInt16
>(i
) );
199 aLbTable
.InsertEntry( ScGlobal::GetRscString(STR_MOVE_TO_END
) );
200 aLbTable
.SetUpdateMode( TRUE
);
201 aLbTable
.SelectEntryPos( 0 );