bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / dlg / brkdlg.cxx
blobf0c14e065f2cd739b9f9cccf6ce6ef117caedaeb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/svdetc.hxx>
24 #include <vcl/weld.hxx>
25 #include <vcl/svapp.hxx>
27 #include <sdresid.hxx>
28 #include <drawview.hxx>
29 #include <strings.hrc>
30 #include <DrawDocShell.hxx>
32 namespace sd {
34 /**
35 * dialog to split metafiles
38 BreakDlg::BreakDlg(weld::Window* pWindow, DrawView* pDrView, DrawDocShell* pShell,
39 sal_uLong nSumActionCount, sal_uLong nObjCount)
40 : SfxDialogController(pWindow, "modules/sdraw/ui/breakdialog.ui", "BreakDialog")
41 , m_xFiObjInfo(m_xBuilder->weld_label("metafiles"))
42 , m_xFiActInfo(m_xBuilder->weld_label("metaobjects"))
43 , m_xFiInsInfo(m_xBuilder->weld_label("drawingobjects"))
44 , m_xBtnCancel(m_xBuilder->weld_button("cancel"))
45 , m_pDrView(pDrView)
46 , m_bCancel(false)
48 m_aUpdateIdle.SetPriority( TaskPriority::REPAINT );
49 m_aUpdateIdle.SetInvokeHandler( LINK( this, BreakDlg, InitialUpdate ) );
50 m_aUpdateIdle.SetDebugName( "sd::BreakDlg m_aUpdateIdle" );
52 m_xBtnCancel->connect_clicked(LINK(this, BreakDlg, CancelButtonHdl));
54 m_xProgress.reset(new SfxProgress(pShell, SdResId(STR_BREAK_METAFILE), nSumActionCount*3));
56 m_xProgrInfo.reset(new SvdProgressInfo(LINK(this, BreakDlg, UpDate)));
57 // every action is edited 3 times in DoImport()
58 m_xProgrInfo->Init( nObjCount );
61 // Control-Handler for cancel button
62 IMPL_LINK_NOARG(BreakDlg, CancelButtonHdl, weld::Button&, void)
64 m_bCancel = true;
65 m_xBtnCancel->set_sensitive(false);
68 /**
69 * The working function has to call the UpDate method periodically.
70 * With the first call, the overall number of actions is provided.
71 * Every following call should contain the finished actions since the
72 * last call of UpDate.
74 IMPL_LINK( BreakDlg, UpDate, void*, nInit, bool )
76 if (!m_xProgrInfo)
77 return true;
79 // update status bar or show a error message?
80 if(nInit == reinterpret_cast<void*>(1))
82 std::unique_ptr<weld::MessageDialog> xErrBox(Application::CreateMessageDialog(m_xDialog.get(),
83 VclMessageType::Warning, VclButtonsType::Ok,
84 SdResId(STR_BREAK_FAIL)));
85 xErrBox->run();
87 else
89 if (m_xProgress)
90 m_xProgress->SetState(m_xProgrInfo->GetSumCurAction());
93 // which object is shown at the moment?
94 OUString info = OUString::number(m_xProgrInfo->GetCurObj())
95 + "/"
96 + OUString::number(m_xProgrInfo->GetObjCount());
97 m_xFiObjInfo->set_label(info);
99 // how many actions are started?
100 if (m_xProgrInfo->GetActionCount() == 0)
102 m_xFiActInfo->set_label( OUString() );
104 else
106 info = OUString::number(m_xProgrInfo->GetCurAction())
107 + "/"
108 + OUString::number(m_xProgrInfo->GetActionCount());
109 m_xFiActInfo->set_label(info);
112 // and inserted????
113 if (m_xProgrInfo->GetInsertCount() == 0)
115 m_xFiInsInfo->set_label( OUString() );
117 else
119 info = OUString::number(m_xProgrInfo->GetCurInsert())
120 + "/"
121 + OUString::number(m_xProgrInfo->GetInsertCount());
122 m_xFiInsInfo->set_label(info);
125 // make sure dialog gets painted, it is intended to
126 // show the progress to the user. Also necessary to
127 // provide a clickable cancel button
128 Application::Reschedule(true);
130 // return okay-value (-> !cancel)
131 return !m_bCancel;
135 * open a modal dialog and start a timer which calls the working function after
136 * the opening of the dialog
138 short BreakDlg::run()
140 m_aUpdateIdle.Start();
141 return SfxDialogController::run();
145 * link-method which starts the working function
147 IMPL_LINK_NOARG(BreakDlg, InitialUpdate, Timer *, void)
149 m_pDrView->DoImportMarkedMtf(m_xProgrInfo.get());
150 m_xDialog->response(RET_OK);
153 } // end of namespace sd
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */