1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "BreakDlg.hxx"
21 #include <sfx2/progress.hxx>
23 #include <svx/svdedtv.hxx>
24 #include <svx/svdetc.hxx>
25 #include <sfx2/app.hxx>
26 #include <vcl/msgbox.hxx>
30 #include "sdresid.hxx"
32 #include "drawview.hxx"
33 #include "strings.hrc"
34 #include "DrawDocShell.hxx"
39 * dialog to split metafiles
46 sal_uLong nSumActionCount
,
48 : SfxModalDialog ( pWindow
, SdResId( DLG_BREAK
) ),
49 aFtObjInfo ( this, SdResId( FT_OBJ_INFO
) ),
50 aFtActInfo ( this, SdResId( FT_ACT_INFO
) ),
51 aFtInsInfo ( this, SdResId( FT_INS_INFO
) ),
52 aFiObjInfo ( this, SdResId( FI_OBJ_INFO
) ),
53 aFiActInfo ( this, SdResId( FI_ACT_INFO
) ),
54 aFiInsInfo ( this, SdResId( FI_INS_INFO
) ),
55 aBtnCancel ( this, SdResId( BTN_CANCEL
) ),
56 aLink ( LINK( this, BreakDlg
, UpDate
)),
59 aBtnCancel
.SetClickHdl( LINK( this, BreakDlg
, CancelButtonHdl
));
61 mpProgress
= new SfxProgress( pShell
, String(SdResId(STR_BREAK_METAFILE
)), nSumActionCount
*3 );
63 pProgrInfo
= new SvdProgressInfo( &aLink
);
64 // every action is editedt 3 times in DoImport()
65 pProgrInfo
->Init( nSumActionCount
*3, nObjCount
);
82 // Control-Handler for cancel button
83 IMPL_LINK_NOARG(BreakDlg
, CancelButtonHdl
)
91 * The working function has to call the UpDate method periodically.
92 * With the first call, the overall number of actions is provided.
93 * Every following call should contain the finished actions since the
94 * last call of UpDate.
96 IMPL_LINK( BreakDlg
, UpDate
, void*, nInit
)
100 if(pProgrInfo
== NULL
)
103 // update status bar or show a error message?
104 if(nInit
== (void*)1L)
106 ErrorBox
aErrBox( this, WB_OK
, String( SdResId( STR_BREAK_FAIL
) ) );
112 mpProgress
->SetState( pProgrInfo
->GetSumCurAction() );
115 // which object is shown at the moment?
116 OUString info
= OUString::valueOf( static_cast<sal_Int32
>( pProgrInfo
->GetCurObj() ) )
118 + OUString::valueOf( static_cast<sal_Int32
>( pProgrInfo
->GetObjCount() ) );
119 aFiObjInfo
.SetText(info
);
121 // how many actions are started?
122 if(pProgrInfo
->GetActionCount() == 0)
124 aFiActInfo
.SetText( aEmptyStr
);
128 info
= OUString::valueOf( static_cast<sal_Int32
>( pProgrInfo
->GetCurAction() ) )
130 + OUString::valueOf( static_cast<sal_Int32
>( pProgrInfo
->GetActionCount() ) );
131 aFiActInfo
.SetText(info
);
135 if(pProgrInfo
->GetInsertCount() == 0)
137 aFiInsInfo
.SetText( aEmptyStr
);
141 info
= OUString::valueOf( static_cast<sal_Int32
>( pProgrInfo
->GetCurInsert() ) )
143 + OUString::valueOf( static_cast<sal_Int32
>( pProgrInfo
->GetInsertCount() ) );
144 aFiInsInfo
.SetText(info
);
147 Application::Reschedule();
148 return( bCancel
?0L:1L );
152 * open a modal dialog and start a timer which calls the working function after
153 * the opening of the dialog
155 short BreakDlg::Execute()
157 aTimer
.SetTimeout( 10 );
158 aTimer
.SetTimeoutHdl( LINK( this, BreakDlg
, InitialUpdate
) );
161 return SfxModalDialog::Execute();
165 * link-method which starts the working function
167 IMPL_LINK_NOARG(BreakDlg
, InitialUpdate
)
169 pDrView
->DoImportMarkedMtf(pProgrInfo
);
174 } // end of namespace sd
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */