fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / dlg / brkdlg.cxx
blobe548bb7e07972e037da73926bf719cf1dda589e2
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/svdedtv.hxx>
24 #include <svx/svdetc.hxx>
25 #include <sfx2/app.hxx>
26 #include <vcl/msgbox.hxx>
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"
36 namespace sd {
38 /**
39 * dialog to split metafiles
42 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 mpProgress ( NULL )
59 aBtnCancel.SetClickHdl( LINK( this, BreakDlg, CancelButtonHdl));
61 mpProgress = new SfxProgress( pShell, String(SdResId(STR_BREAK_METAFILE)), nSumActionCount*3 );
63 pProgrInfo = new SvdProgressInfo( &aLink );
64 // every action is editedt 3 times in DoImport()
65 pProgrInfo->Init( nSumActionCount*3, nObjCount );
67 pDrView = _pDrView;
68 bCancel = sal_False;
70 FreeResource();
73 BreakDlg::~BreakDlg()
75 if( mpProgress )
76 delete mpProgress;
78 if( pProgrInfo )
79 delete pProgrInfo;
82 // Control-Handler for cancel button
83 IMPL_LINK_NOARG(BreakDlg, CancelButtonHdl)
85 bCancel = sal_True;
86 aBtnCancel.Disable();
87 return( 0L );
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.
96 IMPL_LINK( BreakDlg, UpDate, void*, nInit )
98 String aEmptyStr;
100 if(pProgrInfo == NULL)
101 return 1L;
103 // update status bar or show a error message?
104 if(nInit == (void*)1L)
106 ErrorBox aErrBox( this, WB_OK, String( SdResId( STR_BREAK_FAIL ) ) );
107 aErrBox.Execute();
109 else
111 if(mpProgress)
112 mpProgress->SetState( pProgrInfo->GetSumCurAction() );
115 // which object is shown at the moment?
116 OUString info = OUString::valueOf( static_cast<sal_Int32>( pProgrInfo->GetCurObj() ) )
117 + "/"
118 + OUString::valueOf( static_cast<sal_Int32>( pProgrInfo->GetObjCount() ) );
119 aFiObjInfo.SetText(info);
121 // how many actions are started?
122 if(pProgrInfo->GetActionCount() == 0)
124 aFiActInfo.SetText( aEmptyStr );
126 else
128 info = OUString::valueOf( static_cast<sal_Int32>( pProgrInfo->GetCurAction() ) )
129 + "/"
130 + OUString::valueOf( static_cast<sal_Int32>( pProgrInfo->GetActionCount() ) );
131 aFiActInfo.SetText(info);
134 // and inserted????
135 if(pProgrInfo->GetInsertCount() == 0)
137 aFiInsInfo.SetText( aEmptyStr );
139 else
141 info = OUString::valueOf( static_cast<sal_Int32>( pProgrInfo->GetCurInsert() ) )
142 + "/"
143 + OUString::valueOf( static_cast<sal_Int32>( pProgrInfo->GetInsertCount() ) );
144 aFiInsInfo.SetText(info);
147 Application::Reschedule();
148 return( bCancel?0L:1L );
152 * open a modal dialog and start a timer which calls the working function after
153 * the opening of the dialog
155 short BreakDlg::Execute()
157 aTimer.SetTimeout( 10 );
158 aTimer.SetTimeoutHdl( LINK( this, BreakDlg, InitialUpdate ) );
159 aTimer.Start();
161 return SfxModalDialog::Execute();
165 * link-method which starts the working function
167 IMPL_LINK_NOARG(BreakDlg, InitialUpdate)
169 pDrView->DoImportMarkedMtf(pProgrInfo);
170 EndDialog(sal_True);
171 return 0L;
174 } // end of namespace sd
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */