Update ooo320-m1
[ooovba.git] / sd / source / ui / dlg / brkdlg.cxx
blob3d38772690230c6a6fffc963a1c09daebc75ad60
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: brkdlg.cxx,v $
10 * $Revision: 1.7 $
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_sd.hxx"
34 #ifdef SD_DLLIMPLEMENTATION
35 #undef SD_DLLIMPLEMENTATION
36 #endif
38 #include "BreakDlg.hxx"
39 #include <sfx2/progress.hxx>
41 #include <svx/svdedtv.hxx>
42 #include <svx/svdetc.hxx>
43 #include <sfx2/app.hxx>
44 #include <vcl/msgbox.hxx>
46 #include "sdattr.hxx"
47 #include "brkdlg.hrc"
48 #include "sdresid.hxx"
49 #include "View.hxx"
50 #include "drawview.hxx"
51 #include "strings.hrc"
52 #include "DrawDocShell.hxx"
54 namespace sd {
56 /*************************************************************************
58 |* Dialog zum aufbrechen von Metafiles
60 \************************************************************************/
62 BreakDlg::BreakDlg(
63 ::Window* pWindow,
64 DrawView* _pDrView,
65 DrawDocShell* pShell,
66 ULONG nSumActionCount,
67 ULONG nObjCount )
68 : SfxModalDialog ( pWindow, SdResId( DLG_BREAK ) ),
69 aFtObjInfo ( this, SdResId( FT_OBJ_INFO ) ),
70 aFtActInfo ( this, SdResId( FT_ACT_INFO ) ),
71 aFtInsInfo ( this, SdResId( FT_INS_INFO ) ),
72 aFiObjInfo ( this, SdResId( FI_OBJ_INFO ) ),
73 aFiActInfo ( this, SdResId( FI_ACT_INFO ) ),
74 aFiInsInfo ( this, SdResId( FI_INS_INFO ) ),
75 aBtnCancel ( this, SdResId( BTN_CANCEL ) ),
76 aLink ( LINK( this, BreakDlg, UpDate)),
77 mpProgress ( NULL )
79 aBtnCancel.SetClickHdl( LINK( this, BreakDlg, CancelButtonHdl));
81 mpProgress = new SfxProgress( pShell, String(SdResId(STR_BREAK_METAFILE)), nSumActionCount*3 );
83 pProgrInfo = new SvdProgressInfo( &aLink );
84 // jede Action wird in DoImport() 3mal bearbeitet
85 pProgrInfo->Init( nSumActionCount*3, nObjCount );
87 pDrView = _pDrView;
88 bCancel = FALSE;
90 FreeResource();
93 BreakDlg::~BreakDlg()
95 if( mpProgress )
96 delete mpProgress;
98 if( pProgrInfo )
99 delete pProgrInfo;
102 // Control-Handler fuer den Abbruch Button
103 IMPL_LINK( BreakDlg, CancelButtonHdl, void *, EMPTYARG )
105 bCancel = TRUE;
106 aBtnCancel.Disable();
107 return( 0L );
110 // Die UpDate Methode muss regelmaessig von der Arbeitsfunktion
111 // ausgeuehrt werden.
112 // Beim ersten aufruf wird die gesamtanzahl der actions uebergeben.
113 // Jeder weitere sollte die bearbeiteten actions seit dem letzten aufruf von
114 // UpDate erhalten.
116 IMPL_LINK( BreakDlg, UpDate, void*, nInit )
118 String aEmptyStr;
120 if(pProgrInfo == NULL)
121 return 1L;
123 // Statuszeile updaten oder Fehlermeldung?
124 if(nInit == (void*)1L)
126 ErrorBox aErrBox( this, WB_OK, String( SdResId( STR_BREAK_FAIL ) ) );
127 aErrBox.Execute();
129 else
131 if(mpProgress)
132 mpProgress->SetState( pProgrInfo->GetSumCurAction() );
135 // Welches Oject wird gerade angezeigt?
136 String info = UniString::CreateFromInt32( pProgrInfo->GetCurObj() );
137 info.Append( sal_Unicode('/') );
138 info.Append( UniString::CreateFromInt32( pProgrInfo->GetObjCount() ) );
139 aFiObjInfo.SetText(info);
141 // Wieviele Actions sind schon aufgebrochen?
142 if(pProgrInfo->GetActionCount() == 0)
144 aFiActInfo.SetText( aEmptyStr );
146 else
148 info = UniString::CreateFromInt32( pProgrInfo->GetCurAction() );
149 info.Append( sal_Unicode('/') );
150 info.Append( UniString::CreateFromInt32( pProgrInfo->GetActionCount() ) );
151 aFiActInfo.SetText(info);
154 // Und erst eingefuegt????
155 if(pProgrInfo->GetInsertCount() == 0)
157 aFiInsInfo.SetText( aEmptyStr );
159 else
161 info = UniString::CreateFromInt32( pProgrInfo->GetCurInsert() );
162 info.Append( sal_Unicode('/') );
163 info.Append( UniString::CreateFromInt32( pProgrInfo->GetInsertCount() ) );
164 aFiInsInfo.SetText(info);
167 Application::Reschedule();
168 return( bCancel?0L:1L );
171 // Oeffnet den Modalen Dialog und startet einen Timer der die Arbeitsfunktion
172 // nach oeffnen des Dialogs ausfuehrt
173 short BreakDlg::Execute()
175 aTimer.SetTimeout( 10 );
176 aTimer.SetTimeoutHdl( LINK( this, BreakDlg, InitialUpdate ) );
177 aTimer.Start();
179 return SfxModalDialog::Execute();
182 // Linkmethode welche die Arbeitsfunktion startet
183 IMPL_LINK( BreakDlg, InitialUpdate, Timer*, EMPTYARG )
185 pDrView->DoImportMarkedMtf(pProgrInfo);
186 EndDialog(TRUE);
187 return 0L;
190 } // end of namespace sd