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