15b190011SAndrew Rist /**************************************************************
2*23d0572fSmseidel *
35b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
55b190011SAndrew Rist * distributed with this work for additional information
65b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
75b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist * "License"); you may not use this file except in compliance
95b190011SAndrew Rist * with the License. You may obtain a copy of the License at
10*23d0572fSmseidel *
115b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*23d0572fSmseidel *
135b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist * software distributed under the License is distributed on an
155b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist * KIND, either express or implied. See the License for the
175b190011SAndrew Rist * specific language governing permissions and limitations
185b190011SAndrew Rist * under the License.
19*23d0572fSmseidel *
205b190011SAndrew Rist *************************************************************/
215b190011SAndrew Rist
225b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifdef SD_DLLIMPLEMENTATION
28cdf0e10cSrcweir #undef SD_DLLIMPLEMENTATION
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include "BreakDlg.hxx"
32cdf0e10cSrcweir #include <sfx2/progress.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include <svx/svdedtv.hxx>
35cdf0e10cSrcweir #include <svx/svdetc.hxx>
36cdf0e10cSrcweir #include <sfx2/app.hxx>
37cdf0e10cSrcweir #include <vcl/msgbox.hxx>
38cdf0e10cSrcweir
39cdf0e10cSrcweir #include "sdattr.hxx"
40cdf0e10cSrcweir #include "brkdlg.hrc"
41cdf0e10cSrcweir #include "sdresid.hxx"
42cdf0e10cSrcweir #include "View.hxx"
43cdf0e10cSrcweir #include "drawview.hxx"
44cdf0e10cSrcweir #include "strings.hrc"
45cdf0e10cSrcweir #include "DrawDocShell.hxx"
46cdf0e10cSrcweir
47cdf0e10cSrcweir namespace sd {
48cdf0e10cSrcweir
49cdf0e10cSrcweir /*************************************************************************
50cdf0e10cSrcweir |* Dialog zum aufbrechen von Metafiles
51cdf0e10cSrcweir \************************************************************************/
52cdf0e10cSrcweir
BreakDlg(::Window * pWindow,DrawView * _pDrView,DrawDocShell * pShell,sal_uLong nSumActionCount,sal_uLong nObjCount)53cdf0e10cSrcweir BreakDlg::BreakDlg(
54*23d0572fSmseidel ::Window* pWindow,
55*23d0572fSmseidel DrawView* _pDrView,
56*23d0572fSmseidel DrawDocShell* pShell,
57*23d0572fSmseidel sal_uLong nSumActionCount,
58*23d0572fSmseidel sal_uLong nObjCount )
59*23d0572fSmseidel : SfxModalDialog ( pWindow, SdResId( DLG_BREAK ) ),
60*23d0572fSmseidel aFtObjInfo ( this, SdResId( FT_OBJ_INFO ) ),
61*23d0572fSmseidel aFtActInfo ( this, SdResId( FT_ACT_INFO ) ),
62*23d0572fSmseidel aFtInsInfo ( this, SdResId( FT_INS_INFO ) ),
63*23d0572fSmseidel aFiObjInfo ( this, SdResId( FI_OBJ_INFO ) ),
64*23d0572fSmseidel aFiActInfo ( this, SdResId( FI_ACT_INFO ) ),
65*23d0572fSmseidel aFiInsInfo ( this, SdResId( FI_INS_INFO ) ),
66*23d0572fSmseidel aBtnCancel ( this, SdResId( BTN_CANCEL ) ),
67*23d0572fSmseidel aLink ( LINK( this, BreakDlg, UpDate)),
68*23d0572fSmseidel mpProgress ( NULL )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir aBtnCancel.SetClickHdl( LINK( this, BreakDlg, CancelButtonHdl));
71cdf0e10cSrcweir
72cdf0e10cSrcweir mpProgress = new SfxProgress( pShell, String(SdResId(STR_BREAK_METAFILE)), nSumActionCount*3 );
73cdf0e10cSrcweir
74cdf0e10cSrcweir pProgrInfo = new SvdProgressInfo( &aLink );
75cdf0e10cSrcweir // jede Action wird in DoImport() 3mal bearbeitet
76cdf0e10cSrcweir pProgrInfo->Init( nSumActionCount*3, nObjCount );
77cdf0e10cSrcweir
78cdf0e10cSrcweir pDrView = _pDrView;
79cdf0e10cSrcweir bCancel = sal_False;
80cdf0e10cSrcweir
81cdf0e10cSrcweir FreeResource();
82cdf0e10cSrcweir }
83cdf0e10cSrcweir
~BreakDlg()84cdf0e10cSrcweir BreakDlg::~BreakDlg()
85cdf0e10cSrcweir {
86cdf0e10cSrcweir if( mpProgress )
87cdf0e10cSrcweir delete mpProgress;
88cdf0e10cSrcweir
89cdf0e10cSrcweir if( pProgrInfo )
90cdf0e10cSrcweir delete pProgrInfo;
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
93cdf0e10cSrcweir // Control-Handler fuer den Abbruch Button
IMPL_LINK(BreakDlg,CancelButtonHdl,void *,EMPTYARG)94cdf0e10cSrcweir IMPL_LINK( BreakDlg, CancelButtonHdl, void *, EMPTYARG )
95cdf0e10cSrcweir {
96*23d0572fSmseidel bCancel = sal_True;
97*23d0572fSmseidel aBtnCancel.Disable();
98*23d0572fSmseidel return( 0L );
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
101cdf0e10cSrcweir // Die UpDate Methode muss regelmaessig von der Arbeitsfunktion
102cdf0e10cSrcweir // ausgeuehrt werden.
103*23d0572fSmseidel // Beim ersten aufruf wird die Gesamtanzahl der actions uebergeben.
104*23d0572fSmseidel // Jeder weitere sollte die bearbeiteten actions seit dem letzten Aufruf von
105cdf0e10cSrcweir // UpDate erhalten.
106cdf0e10cSrcweir
IMPL_LINK(BreakDlg,UpDate,void *,nInit)107cdf0e10cSrcweir IMPL_LINK( BreakDlg, UpDate, void*, nInit )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir String aEmptyStr;
110cdf0e10cSrcweir
111cdf0e10cSrcweir if(pProgrInfo == NULL)
112*23d0572fSmseidel return 1L;
113cdf0e10cSrcweir
114cdf0e10cSrcweir // Statuszeile updaten oder Fehlermeldung?
115cdf0e10cSrcweir if(nInit == (void*)1L)
116cdf0e10cSrcweir {
117cdf0e10cSrcweir ErrorBox aErrBox( this, WB_OK, String( SdResId( STR_BREAK_FAIL ) ) );
118cdf0e10cSrcweir aErrBox.Execute();
119cdf0e10cSrcweir }
120cdf0e10cSrcweir else
121cdf0e10cSrcweir {
122cdf0e10cSrcweir if(mpProgress)
123cdf0e10cSrcweir mpProgress->SetState( pProgrInfo->GetSumCurAction() );
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir // Welches Oject wird gerade angezeigt?
127cdf0e10cSrcweir String info = UniString::CreateFromInt32( pProgrInfo->GetCurObj() );
128cdf0e10cSrcweir info.Append( sal_Unicode('/') );
129cdf0e10cSrcweir info.Append( UniString::CreateFromInt32( pProgrInfo->GetObjCount() ) );
130cdf0e10cSrcweir aFiObjInfo.SetText(info);
131cdf0e10cSrcweir
132cdf0e10cSrcweir // Wieviele Actions sind schon aufgebrochen?
133cdf0e10cSrcweir if(pProgrInfo->GetActionCount() == 0)
134cdf0e10cSrcweir {
135cdf0e10cSrcweir aFiActInfo.SetText( aEmptyStr );
136cdf0e10cSrcweir }
137cdf0e10cSrcweir else
138cdf0e10cSrcweir {
139cdf0e10cSrcweir info = UniString::CreateFromInt32( pProgrInfo->GetCurAction() );
140cdf0e10cSrcweir info.Append( sal_Unicode('/') );
141cdf0e10cSrcweir info.Append( UniString::CreateFromInt32( pProgrInfo->GetActionCount() ) );
142cdf0e10cSrcweir aFiActInfo.SetText(info);
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir // Und erst eingefuegt????
146cdf0e10cSrcweir if(pProgrInfo->GetInsertCount() == 0)
147cdf0e10cSrcweir {
148cdf0e10cSrcweir aFiInsInfo.SetText( aEmptyStr );
149cdf0e10cSrcweir }
150cdf0e10cSrcweir else
151cdf0e10cSrcweir {
152cdf0e10cSrcweir info = UniString::CreateFromInt32( pProgrInfo->GetCurInsert() );
153cdf0e10cSrcweir info.Append( sal_Unicode('/') );
154cdf0e10cSrcweir info.Append( UniString::CreateFromInt32( pProgrInfo->GetInsertCount() ) );
155cdf0e10cSrcweir aFiInsInfo.SetText(info);
156cdf0e10cSrcweir }
157cdf0e10cSrcweir
158cdf0e10cSrcweir Application::Reschedule();
159cdf0e10cSrcweir return( bCancel?0L:1L );
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
162cdf0e10cSrcweir // Oeffnet den Modalen Dialog und startet einen Timer der die Arbeitsfunktion
163cdf0e10cSrcweir // nach oeffnen des Dialogs ausfuehrt
Execute()164cdf0e10cSrcweir short BreakDlg::Execute()
165cdf0e10cSrcweir {
166*23d0572fSmseidel aTimer.SetTimeout( 10 );
167*23d0572fSmseidel aTimer.SetTimeoutHdl( LINK( this, BreakDlg, InitialUpdate ) );
168*23d0572fSmseidel aTimer.Start();
169cdf0e10cSrcweir
170*23d0572fSmseidel return SfxModalDialog::Execute();
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
173cdf0e10cSrcweir // Linkmethode welche die Arbeitsfunktion startet
IMPL_LINK(BreakDlg,InitialUpdate,Timer *,EMPTYARG)174cdf0e10cSrcweir IMPL_LINK( BreakDlg, InitialUpdate, Timer*, EMPTYARG )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir pDrView->DoImportMarkedMtf(pProgrInfo);
177cdf0e10cSrcweir EndDialog(sal_True);
178cdf0e10cSrcweir return 0L;
179cdf0e10cSrcweir }
180cdf0e10cSrcweir
181cdf0e10cSrcweir } // end of namespace sd
182