Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "BreakDlg.hxx"
21 : #include <sfx2/progress.hxx>
22 :
23 : #include <svx/svdedtv.hxx>
24 : #include <svx/svdetc.hxx>
25 : #include <sfx2/app.hxx>
26 : #include <vcl/msgbox.hxx>
27 :
28 : #include "sdattr.hxx"
29 : #include "brkdlg.hrc"
30 : #include "sdresid.hxx"
31 : #include "View.hxx"
32 : #include "drawview.hxx"
33 : #include "strings.hrc"
34 : #include "DrawDocShell.hxx"
35 :
36 : namespace sd {
37 :
38 : /**
39 : * dialog to split metafiles
40 : */
41 :
42 0 : BreakDlg::BreakDlg(
43 : ::Window* pWindow,
44 : DrawView* _pDrView,
45 : DrawDocShell* pShell,
46 : sal_uLong nSumActionCount,
47 : sal_uLong nObjCount )
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)),
57 0 : mpProgress ( NULL )
58 : {
59 0 : aBtnCancel.SetClickHdl( LINK( this, BreakDlg, CancelButtonHdl));
60 :
61 0 : mpProgress = new SfxProgress( pShell, String(SdResId(STR_BREAK_METAFILE)), nSumActionCount*3 );
62 :
63 0 : pProgrInfo = new SvdProgressInfo( &aLink );
64 : // every action is editedt 3 times in DoImport()
65 0 : pProgrInfo->Init( nSumActionCount*3, nObjCount );
66 :
67 0 : pDrView = _pDrView;
68 0 : bCancel = sal_False;
69 :
70 0 : FreeResource();
71 0 : }
72 :
73 0 : BreakDlg::~BreakDlg()
74 : {
75 0 : if( mpProgress )
76 0 : delete mpProgress;
77 :
78 0 : if( pProgrInfo )
79 0 : delete pProgrInfo;
80 0 : }
81 :
82 : // Control-Handler for cancel button
83 0 : IMPL_LINK_NOARG(BreakDlg, CancelButtonHdl)
84 : {
85 0 : bCancel = sal_True;
86 0 : aBtnCancel.Disable();
87 0 : return( 0L );
88 : }
89 :
90 : /**
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.
95 : */
96 0 : IMPL_LINK( BreakDlg, UpDate, void*, nInit )
97 : {
98 0 : String aEmptyStr;
99 :
100 0 : if(pProgrInfo == NULL)
101 0 : return 1L;
102 :
103 : // update status bar or show a error message?
104 0 : if(nInit == (void*)1L)
105 : {
106 0 : ErrorBox aErrBox( this, WB_OK, String( SdResId( STR_BREAK_FAIL ) ) );
107 0 : aErrBox.Execute();
108 : }
109 : else
110 : {
111 0 : if(mpProgress)
112 0 : mpProgress->SetState( pProgrInfo->GetSumCurAction() );
113 : }
114 :
115 : // which object is shown at the moment?
116 0 : OUString info = OUString::valueOf( static_cast<sal_Int32>( pProgrInfo->GetCurObj() ) )
117 0 : + "/"
118 0 : + OUString::valueOf( static_cast<sal_Int32>( pProgrInfo->GetObjCount() ) );
119 0 : aFiObjInfo.SetText(info);
120 :
121 : // how many actions are started?
122 0 : if(pProgrInfo->GetActionCount() == 0)
123 : {
124 0 : aFiActInfo.SetText( aEmptyStr );
125 : }
126 : else
127 : {
128 0 : info = OUString::valueOf( static_cast<sal_Int32>( pProgrInfo->GetCurAction() ) )
129 0 : + "/"
130 0 : + OUString::valueOf( static_cast<sal_Int32>( pProgrInfo->GetActionCount() ) );
131 0 : aFiActInfo.SetText(info);
132 : }
133 :
134 : // and inserted????
135 0 : if(pProgrInfo->GetInsertCount() == 0)
136 : {
137 0 : aFiInsInfo.SetText( aEmptyStr );
138 : }
139 : else
140 : {
141 0 : info = OUString::valueOf( static_cast<sal_Int32>( pProgrInfo->GetCurInsert() ) )
142 0 : + "/"
143 0 : + OUString::valueOf( static_cast<sal_Int32>( pProgrInfo->GetInsertCount() ) );
144 0 : aFiInsInfo.SetText(info);
145 : }
146 :
147 0 : Application::Reschedule();
148 0 : return( bCancel?0L:1L );
149 : }
150 :
151 : /**
152 : * open a modal dialog and start a timer which calls the working function after
153 : * the opening of the dialog
154 : */
155 0 : short BreakDlg::Execute()
156 : {
157 0 : aTimer.SetTimeout( 10 );
158 0 : aTimer.SetTimeoutHdl( LINK( this, BreakDlg, InitialUpdate ) );
159 0 : aTimer.Start();
160 :
161 0 : return SfxModalDialog::Execute();
162 : }
163 :
164 : /**
165 : * link-method which starts the working function
166 : */
167 0 : IMPL_LINK_NOARG(BreakDlg, InitialUpdate)
168 : {
169 0 : pDrView->DoImportMarkedMtf(pProgrInfo);
170 0 : EndDialog(sal_True);
171 0 : return 0L;
172 : }
173 :
174 0 : } // end of namespace sd
175 :
176 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|