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 : delete mpProgress;
71 0 : delete pProgrInfo;
72 0 : }
73 :
74 : // Control-Handler for cancel button
75 0 : IMPL_LINK_NOARG(BreakDlg, CancelButtonHdl)
76 : {
77 0 : bCancel = true;
78 0 : m_pBtnCancel->Disable();
79 0 : return( 0L );
80 : }
81 :
82 : /**
83 : * The working function has to call the UpDate method periodically.
84 : * With the first call, the overall number of actions is provided.
85 : * Every following call should contain the finished actions since the
86 : * last call of UpDate.
87 : */
88 0 : IMPL_LINK( BreakDlg, UpDate, void*, nInit )
89 : {
90 0 : if(pProgrInfo == NULL)
91 0 : return 1L;
92 :
93 : // update status bar or show a error message?
94 0 : if(nInit == (void*)1L)
95 : {
96 0 : MessageDialog aErrBox(this, SD_RESSTR(STR_BREAK_FAIL));
97 0 : aErrBox.Execute();
98 : }
99 : else
100 : {
101 0 : if(mpProgress)
102 0 : mpProgress->SetState( pProgrInfo->GetSumCurAction() );
103 : }
104 :
105 : // which object is shown at the moment?
106 : OUString info = OUString::number( pProgrInfo->GetCurObj() )
107 0 : + "/"
108 0 : + OUString::number( pProgrInfo->GetObjCount() );
109 0 : m_pFiObjInfo->SetText(info);
110 :
111 : // how many actions are started?
112 0 : if(pProgrInfo->GetActionCount() == 0)
113 : {
114 0 : m_pFiActInfo->SetText( OUString() );
115 : }
116 : else
117 : {
118 0 : info = OUString::number( pProgrInfo->GetCurAction() )
119 0 : + "/"
120 0 : + OUString::number( pProgrInfo->GetActionCount() );
121 0 : m_pFiActInfo->SetText(info);
122 : }
123 :
124 : // and inserted????
125 0 : if(pProgrInfo->GetInsertCount() == 0)
126 : {
127 0 : m_pFiInsInfo->SetText( OUString() );
128 : }
129 : else
130 : {
131 0 : info = OUString::number( pProgrInfo->GetCurInsert() )
132 0 : + "/"
133 0 : + OUString::number( pProgrInfo->GetInsertCount() );
134 0 : m_pFiInsInfo->SetText(info);
135 : }
136 :
137 0 : Application::Reschedule();
138 0 : return( bCancel?0L:1L );
139 : }
140 :
141 : /**
142 : * open a modal dialog and start a timer which calls the working function after
143 : * the opening of the dialog
144 : */
145 0 : short BreakDlg::Execute()
146 : {
147 0 : aTimer.SetTimeout( 10 );
148 0 : aTimer.SetTimeoutHdl( LINK( this, BreakDlg, InitialUpdate ) );
149 0 : aTimer.Start();
150 :
151 0 : return SfxModalDialog::Execute();
152 : }
153 :
154 : /**
155 : * link-method which starts the working function
156 : */
157 0 : IMPL_LINK_NOARG(BreakDlg, InitialUpdate)
158 : {
159 0 : pDrView->DoImportMarkedMtf(pProgrInfo);
160 0 : EndDialog(sal_True);
161 0 : return 0L;
162 : }
163 :
164 0 : } // end of namespace sd
165 :
166 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|