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