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 "sdresid.hxx"
30 : #include "View.hxx"
31 : #include "drawview.hxx"
32 : #include "strings.hrc"
33 : #include "DrawDocShell.hxx"
34 :
35 : namespace sd {
36 :
37 : /**
38 : * dialog to split metafiles
39 : */
40 :
41 0 : BreakDlg::BreakDlg(
42 : vcl::Window* pWindow,
43 : DrawView* _pDrView,
44 : DrawDocShell* pShell,
45 : sal_uLong nSumActionCount,
46 : sal_uLong nObjCount )
47 : : SfxModalDialog(pWindow, "BreakDialog", "modules/sdraw/ui/breakdialog.ui")
48 : , aLink( LINK(this, BreakDlg, UpDate))
49 0 : , mpProgress( NULL )
50 : {
51 0 : get(m_pFiObjInfo, "metafiles");
52 0 : get(m_pFiActInfo, "metaobjects");
53 0 : get(m_pFiInsInfo, "drawingobjects");
54 0 : get(m_pBtnCancel, "cancel");
55 :
56 0 : m_pBtnCancel->SetClickHdl( LINK( this, BreakDlg, CancelButtonHdl));
57 :
58 0 : mpProgress = new SfxProgress( pShell, SD_RESSTR(STR_BREAK_METAFILE), nSumActionCount*3 );
59 :
60 0 : pProgrInfo = new SvdProgressInfo( &aLink );
61 : // every action is editedt 3 times in DoImport()
62 0 : pProgrInfo->Init( nSumActionCount*3, nObjCount );
63 :
64 0 : pDrView = _pDrView;
65 0 : bCancel = false;
66 0 : }
67 :
68 0 : BreakDlg::~BreakDlg()
69 : {
70 0 : disposeOnce();
71 0 : }
72 :
73 0 : void BreakDlg::dispose()
74 : {
75 0 : delete mpProgress;
76 0 : mpProgress = NULL;
77 0 : delete pProgrInfo;
78 0 : pProgrInfo = NULL;
79 0 : m_pFiObjInfo.clear();
80 0 : m_pFiActInfo.clear();
81 0 : m_pFiInsInfo.clear();
82 0 : m_pBtnCancel.clear();
83 0 : SfxModalDialog::dispose();
84 0 : }
85 :
86 : // Control-Handler for cancel button
87 0 : IMPL_LINK_NOARG(BreakDlg, CancelButtonHdl)
88 : {
89 0 : bCancel = true;
90 0 : m_pBtnCancel->Disable();
91 0 : return 0L;
92 : }
93 :
94 : /**
95 : * The working function has to call the UpDate method periodically.
96 : * With the first call, the overall number of actions is provided.
97 : * Every following call should contain the finished actions since the
98 : * last call of UpDate.
99 : */
100 0 : IMPL_LINK( BreakDlg, UpDate, void*, nInit )
101 : {
102 0 : if(pProgrInfo == NULL)
103 0 : return 1L;
104 :
105 : // update status bar or show a error message?
106 0 : if(nInit == reinterpret_cast<void*>(1L))
107 : {
108 0 : ScopedVclPtrInstance< MessageDialog > aErrBox(this, SD_RESSTR(STR_BREAK_FAIL));
109 0 : aErrBox->Execute();
110 : }
111 : else
112 : {
113 0 : if(mpProgress)
114 0 : mpProgress->SetState( pProgrInfo->GetSumCurAction() );
115 : }
116 :
117 : // which object is shown at the moment?
118 : OUString info = OUString::number( pProgrInfo->GetCurObj() )
119 0 : + "/"
120 0 : + OUString::number( pProgrInfo->GetObjCount() );
121 0 : m_pFiObjInfo->SetText(info);
122 :
123 : // how many actions are started?
124 0 : if(pProgrInfo->GetActionCount() == 0)
125 : {
126 0 : m_pFiActInfo->SetText( OUString() );
127 : }
128 : else
129 : {
130 0 : info = OUString::number( pProgrInfo->GetCurAction() )
131 0 : + "/"
132 0 : + OUString::number( pProgrInfo->GetActionCount() );
133 0 : m_pFiActInfo->SetText(info);
134 : }
135 :
136 : // and inserted????
137 0 : if(pProgrInfo->GetInsertCount() == 0)
138 : {
139 0 : m_pFiInsInfo->SetText( OUString() );
140 : }
141 : else
142 : {
143 0 : info = OUString::number( pProgrInfo->GetCurInsert() )
144 0 : + "/"
145 0 : + OUString::number( pProgrInfo->GetInsertCount() );
146 0 : m_pFiInsInfo->SetText(info);
147 : }
148 :
149 0 : Application::Reschedule();
150 0 : return( bCancel?0L:1L );
151 : }
152 :
153 : /**
154 : * open a modal dialog and start a timer which calls the working function after
155 : * the opening of the dialog
156 : */
157 0 : short BreakDlg::Execute()
158 : {
159 0 : aIdle.SetPriority( SchedulerPriority::REPAINT );
160 0 : aIdle.SetIdleHdl( LINK( this, BreakDlg, InitialUpdate ) );
161 0 : aIdle.Start();
162 :
163 0 : return SfxModalDialog::Execute();
164 : }
165 :
166 : /**
167 : * link-method which starts the working function
168 : */
169 0 : IMPL_LINK_NOARG_TYPED(BreakDlg, InitialUpdate, Idle *, void)
170 : {
171 0 : pDrView->DoImportMarkedMtf(pProgrInfo);
172 0 : EndDialog(RET_OK);
173 0 : }
174 :
175 0 : } // end of namespace sd
176 :
177 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|