LibreOffice Module sd (master) 1
brkdlg.cxx
Go to the documentation of this file.
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/svdetc.hxx>
24#include <vcl/scheduler.hxx>
25#include <vcl/svapp.hxx>
26#include <vcl/weld.hxx>
27
28#include <sdresid.hxx>
29#include <drawview.hxx>
30#include <strings.hrc>
31#include <DrawDocShell.hxx>
32
33namespace sd {
34
40 sal_uLong nSumActionCount, sal_uLong nObjCount)
41 : SfxDialogController(pWindow, "modules/sdraw/ui/breakdialog.ui", "BreakDialog")
42 , m_xFiObjInfo(m_xBuilder->weld_label("metafiles"))
43 , m_xFiActInfo(m_xBuilder->weld_label("metaobjects"))
44 , m_xFiInsInfo(m_xBuilder->weld_label("drawingobjects"))
45 , m_xBtnCancel(m_xBuilder->weld_button("cancel"))
46 , m_pDrView(pDrView)
47 , m_bCancel(false)
48 , m_aUpdateIdle( "sd::BreakDlg m_aUpdateIdle" )
49{
50 m_aUpdateIdle.SetPriority( TaskPriority::REPAINT );
51 m_aUpdateIdle.SetInvokeHandler( LINK( this, BreakDlg, InitialUpdate ) );
52
53 m_xBtnCancel->connect_clicked(LINK(this, BreakDlg, CancelButtonHdl));
54
55 m_xProgress.reset(new SfxProgress(pShell, SdResId(STR_BREAK_METAFILE), nSumActionCount*3));
56
57 m_xProgrInfo.reset(new SvdProgressInfo(LINK(this, BreakDlg, UpDate)));
58 // every action is edited 3 times in DoImport()
59 m_xProgrInfo->Init( nObjCount );
60}
61
62// Control-Handler for cancel button
63IMPL_LINK_NOARG(BreakDlg, CancelButtonHdl, weld::Button&, void)
64{
65 m_bCancel = true;
66 m_xBtnCancel->set_sensitive(false);
67}
68
75IMPL_LINK( BreakDlg, UpDate, void*, nInit, bool )
76{
77 if (!m_xProgrInfo)
78 return true;
79
80 // update status bar or show an error message?
81 if(nInit == reinterpret_cast<void*>(1))
82 {
83 std::unique_ptr<weld::MessageDialog> xErrBox(Application::CreateMessageDialog(m_xDialog.get(),
84 VclMessageType::Warning, VclButtonsType::Ok,
85 SdResId(STR_BREAK_FAIL)));
86 xErrBox->run();
87 }
88 else
89 {
90 if (m_xProgress)
91 m_xProgress->SetState(m_xProgrInfo->GetSumCurAction());
92 }
93
94 // which object is shown at the moment?
95 OUString info = OUString::number(m_xProgrInfo->GetCurObj())
96 + "/"
97 + OUString::number(m_xProgrInfo->GetObjCount());
98 m_xFiObjInfo->set_label(info);
99
100 // how many actions are started?
101 if (m_xProgrInfo->GetActionCount() == 0)
102 {
103 m_xFiActInfo->set_label( OUString() );
104 }
105 else
106 {
107 info = OUString::number(m_xProgrInfo->GetCurAction())
108 + "/"
109 + OUString::number(m_xProgrInfo->GetActionCount());
110 m_xFiActInfo->set_label(info);
111 }
112
113 // and inserted????
114 if (m_xProgrInfo->GetInsertCount() == 0)
115 {
116 m_xFiInsInfo->set_label( OUString() );
117 }
118 else
119 {
120 info = OUString::number(m_xProgrInfo->GetCurInsert())
121 + "/"
122 + OUString::number(m_xProgrInfo->GetInsertCount());
123 m_xFiInsInfo->set_label(info);
124 }
125
126 // make sure dialog gets painted, it is intended to
127 // show the progress to the user. Also necessary to
128 // provide a clickable cancel button
130
131 // return okay-value (-> !cancel)
132 return !m_bCancel;
133}
134
140{
142 return SfxDialogController::run();
143}
144
148IMPL_LINK_NOARG(BreakDlg, InitialUpdate, Timer *, void)
149{
150 m_pDrView->DoImportMarkedMtf(m_xProgrInfo.get());
151 m_xDialog->response(RET_OK);
152}
153
154} // end of namespace sd
155
156/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
virtual void Start(bool bStartTimer=true) override
static void ProcessEventsToIdle()
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
dialog to break meta files
Definition: BreakDlg.hxx:36
std::unique_ptr< SfxProgress > m_xProgress
Definition: BreakDlg.hxx:55
virtual short run() override
open a modal dialog and start a timer which calls the working function after the opening of the dialo...
Definition: brkdlg.cxx:139
Idle m_aUpdateIdle
Definition: BreakDlg.hxx:53
std::unique_ptr< weld::Button > m_xBtnCancel
Definition: BreakDlg.hxx:47
BreakDlg(weld::Window *pWindow, DrawView *pDrView, DrawDocShell *pShell, sal_uLong nSumActionCount, sal_uLong nObjCount)
dialog to split metafiles
Definition: brkdlg.cxx:39
std::unique_ptr< SvdProgressInfo > m_xProgrInfo
Definition: BreakDlg.hxx:54
Derivative of sd::View; contains also a pointer to the document.
Definition: drawview.hxx:35
IMPL_LINK_NOARG(MainSequence, onTimerHdl, Timer *, void)
IMPL_LINK(SdCharHeightPropertyBox, implMenuSelectHdl, const OUString &, rIdent, void)
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
sal_uIntPtr sal_uLong
RET_OK