LibreOffice Module svx (master) 1
imapdlg.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 <vcl/errinf.hxx>
21#include <tools/urlobj.hxx>
23#include <svl/eitem.hxx>
24#include <sfx2/dispatch.hxx>
25#include <sfx2/module.hxx>
27#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
28#include <svl/urihelper.hxx>
29#include <svtools/ehdl.hxx>
30#include <svtools/inettbc.hxx>
31#include <svtools/sfxecode.hxx>
32#include <sfx2/viewfrm.hxx>
33#include <sfx2/objsh.hxx>
34#include <sfx2/docfile.hxx>
36#include <vcl/weld.hxx>
37#include <svx/imapdlg.hxx>
38#include <svx/dialmgr.hxx>
39#include <svx/strings.hrc>
40#include <svx/svxids.hrc>
41#include "imapwnd.hxx"
42#include "imapimp.hxx"
43#include <svx/svdopath.hxx>
44#include <vcl/svapp.hxx>
45#include <vcl/settings.hxx>
46#include <osl/diagnose.h>
47#include "dlgunit.hxx"
48#include <memory>
49
50constexpr OUStringLiteral SELF_TARGET = u"_self";
51constexpr OUStringLiteral IMAP_CERN_FILTER = u"MAP - CERN";
52constexpr OUStringLiteral IMAP_NCSA_FILTER = u"MAP - NCSA";
53constexpr OUStringLiteral IMAP_BINARY_FILTER = u"SIP - StarView ImageMap";
54constexpr OUStringLiteral IMAP_ALL_TYPE = u"*.*";
55constexpr OUStringLiteral IMAP_BINARY_TYPE = u"*.sip";
56constexpr OUStringLiteral IMAP_CERN_TYPE = u"*.map";
57constexpr OUStringLiteral IMAP_NCSA_TYPE = u"*.map";
58
60
61// ControllerItem
62
64 SfxControllerItem ( SID_IMAP_EXEC, rBindings ),
65 rIMap ( rIMapDlg )
66{
67}
68
70 const SfxPoolItem* pItem )
71{
72 if ( ( nSID == SID_IMAP_EXEC ) && pItem )
73 {
74 const SfxBoolItem* pStateItem = dynamic_cast<const SfxBoolItem*>( pItem );
75 assert(pStateItem); //SfxBoolItem expected
76 if (pStateItem)
77 {
78 // Disable Float if possible
79 rIMap.SetExecState( !pStateItem->GetValue() );
80 }
81 }
82}
83
85 SfxBindings* pBindings,
86 SfxChildWinInfo const * pInfo)
87 : SfxChildWindow( _pParent, nId )
88{
89 SetController(std::make_shared<SvxIMapDlg>(pBindings, this, _pParent->GetFrameWeld()));
90 SvxIMapDlg* pDlg = static_cast<SvxIMapDlg*>(GetController().get());
91 pDlg->Initialize( pInfo );
92}
93
94void SvxIMapDlgChildWindow::UpdateIMapDlg( const Graphic& rGraphic, const ImageMap* pImageMap,
95 const TargetList* pTargetList, void* pEditingObj )
96{
97 SvxIMapDlg* pDlg = GetIMapDlg();
98 if (pDlg)
99 pDlg->UpdateLink(rGraphic, pImageMap, pTargetList, pEditingObj);
100}
101
103 : SfxModelessDialogController(_pBindings, pCW, _pParent, "svx/ui/imapdialog.ui", "ImapDialog")
104 , pCheckObj(nullptr)
105 , aIMapItem(*this, *_pBindings)
106 , m_xIMapWnd(new IMapWindow(_pBindings->GetActiveFrame(), m_xDialog.get()))
107 , m_xTbxIMapDlg1(m_xBuilder->weld_toolbar("toolbar"))
108 , m_xFtURL(m_xBuilder->weld_label("urlft"))
109 , m_xURLBox(new SvtURLBox(m_xBuilder->weld_combo_box("url")))
110 , m_xFtText(m_xBuilder->weld_label("textft"))
111 , m_xEdtText(m_xBuilder->weld_entry("text"))
112 , m_xFtTarget(m_xBuilder->weld_label("targetft"))
113 , m_xCbbTarget(m_xBuilder->weld_combo_box("target"))
114 , m_xCancelBtn(m_xBuilder->weld_button("cancel"))
115 , m_xStbStatus1(m_xBuilder->weld_label("statusurl"))
116 , m_xStbStatus2(m_xBuilder->weld_label("statuspos"))
117 , m_xStbStatus3(m_xBuilder->weld_label("statussize"))
118 , m_xIMapWndWeld(new weld::CustomWeld(*m_xBuilder, "container", *m_xIMapWnd))
119
120{
121 m_xTbxIMapDlg1->insert_separator(4, "sep1");
122 m_xTbxIMapDlg1->insert_separator(10, "sep2");
123 m_xTbxIMapDlg1->insert_separator(15, "sep3");
124 m_xTbxIMapDlg1->insert_separator(18, "sel4");
125
126 //lock this down so it doesn't jump around in size
127 //as entries are added later on
128 TargetList aTmpList;
130 for (const OUString & s : aTmpList)
131 m_xCbbTarget->append_text(s);
132 Size aPrefSize(m_xCbbTarget->get_preferred_size());
133 m_xCbbTarget->set_size_request(aPrefSize.Width(), -1);
134 m_xCbbTarget->clear();
135
136 m_xIMapWnd->Show();
137
138 pOwnData.reset(new IMapOwnData);
139
140 m_xIMapWnd->SetInfoLink( LINK( this, SvxIMapDlg, InfoHdl ) );
141 m_xIMapWnd->SetMousePosLink( LINK( this, SvxIMapDlg, MousePosHdl ) );
142 m_xIMapWnd->SetGraphSizeLink( LINK( this, SvxIMapDlg, GraphSizeHdl ) );
143 m_xIMapWnd->SetUpdateLink( LINK( this, SvxIMapDlg, StateHdl ) );
144
145 m_xURLBox->connect_changed( LINK( this, SvxIMapDlg, URLModifyHdl ) );
146 m_xURLBox->connect_focus_out( LINK( this, SvxIMapDlg, URLLoseFocusHdl ) );
147 m_xEdtText->connect_changed( LINK( this, SvxIMapDlg, EntryModifyHdl ) );
148 m_xCbbTarget->connect_focus_out( LINK( this, SvxIMapDlg, URLLoseFocusHdl ) );
149
150 m_xTbxIMapDlg1->connect_clicked( LINK( this, SvxIMapDlg, TbxClickHdl ) );
151 OUString sSelect("TBI_SELECT");
152 m_xTbxIMapDlg1->set_item_active(sSelect, true);
153 TbxClickHdl(sSelect);
154
155 m_xStbStatus1->set_size_request(120, -1);
156 const int nWidth = m_xStbStatus1->get_pixel_size(" 9999,99 cm / 9999,99 cm ").Width();
157 m_xStbStatus2->set_size_request(nWidth, -1);
158 m_xStbStatus3->set_size_request(nWidth, -1);
159
160 m_xFtURL->set_sensitive(false);
161 m_xURLBox->set_sensitive(false);
162 m_xFtText->set_sensitive(false);
163 m_xEdtText->set_sensitive(false);
164 m_xFtTarget->set_sensitive(false);
165 m_xCbbTarget->set_sensitive(false);
166 pOwnData->bExecState = false;
167
168 pOwnData->aIdle.SetInvokeHandler( LINK( this, SvxIMapDlg, UpdateHdl ) );
169
170 m_xTbxIMapDlg1->set_item_sensitive("TBI_ACTIVE", false);
171 m_xTbxIMapDlg1->set_item_sensitive("TBI_MACRO", false );
172 m_xTbxIMapDlg1->set_item_sensitive("TBI_PROPERTY", false );
173
174 m_xCancelBtn->connect_clicked(LINK(this, SvxIMapDlg, CancelHdl));
175}
176
178{
179 m_xIMapWnd->SetUpdateLink( Link<GraphCtrl*,void>() );
180 m_xIMapWnd.reset();
181}
182
184{
185 bool bRet = true;
186
187 if ( m_xTbxIMapDlg1->get_item_sensitive("TBI_APPLY") )
188 {
189 std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xDialog.get(), "svx/ui/querymodifyimagemapchangesdialog.ui"));
190 std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog("QueryModifyImageMapChangesDialog"));
191 const tools::Long nRet = xQBox->run();
192
193 if( nRet == RET_YES )
194 {
195 SfxBoolItem aBoolItem( SID_IMAP_EXEC, true );
196 GetBindings().GetDispatcher()->ExecuteList(SID_IMAP_EXEC,
197 SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
198 { &aBoolItem });
199 }
200 else if( nRet == RET_CANCEL )
201 bRet = false;
202 }
203 else if( m_xIMapWnd->IsChanged() )
204 {
205 std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xDialog.get(), "svx/ui/querysaveimagemapchangesdialog.ui"));
206 std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog("QuerySaveImageMapChangesDialog"));
207 const tools::Long nRet = xQBox->run();
208
209 if( nRet == RET_YES )
210 bRet = DoSave();
211 else if( nRet == RET_CANCEL )
212 bRet = false;
213 }
214
215 if (bRet)
216 m_xDialog->response(RET_CANCEL);
217}
218
219// Enabled or disable all Controls
220
221void SvxIMapDlg::SetExecState( bool bEnable )
222{
223 pOwnData->bExecState = bEnable;
224}
225
227{
228 return m_xIMapWnd->GetImageMap();
229}
230
231void SvxIMapDlg::SetTargetList( const TargetList& rTargetList )
232{
233 m_xIMapWnd->SetTargetList( rTargetList );
234
235 m_xCbbTarget->clear();
236
237 for (const OUString & s : rTargetList)
238 m_xCbbTarget->append_text(s);
239}
240
241void SvxIMapDlg::UpdateLink( const Graphic& rGraphic, const ImageMap* pImageMap,
242 const TargetList* pTargetList, void* pEditingObj )
243{
244 pOwnData->aUpdateGraphic = rGraphic;
245
246 if ( pImageMap )
247 pOwnData->aUpdateImageMap = *pImageMap;
248 else
249 pOwnData->aUpdateImageMap.ClearImageMap();
250
251 pOwnData->pUpdateEditingObject = pEditingObj;
252
253 // Delete UpdateTargetList, because this method can still be called several
254 // times before the update timer is turned on
255
256 // TargetList must be copied, since it is owned by the caller and can be
257 // deleted immediately after this call the copied list will be deleted
258 // again in the handler
259 if( pTargetList )
260 pOwnData->aUpdateTargetList = *pTargetList;
261 else
262 pOwnData->aUpdateTargetList.clear();
263
264 pOwnData->aIdle.Start();
265}
266
267
268// Click-handler for ToolBox
269
270IMPL_LINK(SvxIMapDlg, TbxClickHdl, const OUString&, rNewItemId, void)
271{
272 if (rNewItemId == "TBI_APPLY")
273 {
274 URLLoseFocusHdl(*m_xCbbTarget);
275 SfxBoolItem aBoolItem( SID_IMAP_EXEC, true );
276 GetBindings().GetDispatcher()->ExecuteList(SID_IMAP_EXEC,
277 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
278 { &aBoolItem });
279 }
280 else if (rNewItemId == "TBI_OPEN")
281 DoOpen();
282 else if (rNewItemId == "TBI_SAVEAS")
283 DoSave();
284 else if (rNewItemId == "TBI_CLOSE")
285 CancelHdl(*m_xCancelBtn);
286 else if (rNewItemId == "TBI_SELECT")
287 {
288 SetActiveTool( rNewItemId );
289 m_xIMapWnd->SetEditMode( true );
290 }
291 else if (rNewItemId == "TBI_RECT")
292 {
293 SetActiveTool( rNewItemId );
294 m_xIMapWnd->SetObjKind( SdrObjKind::Rectangle );
295 }
296 else if (rNewItemId == "TBI_CIRCLE")
297 {
298 SetActiveTool( rNewItemId );
299 m_xIMapWnd->SetObjKind( SdrObjKind::CircleOrEllipse );
300 }
301 else if (rNewItemId == "TBI_POLY")
302 {
303 SetActiveTool( rNewItemId );
304 m_xIMapWnd->SetObjKind( SdrObjKind::Polygon );
305 }
306 else if (rNewItemId == "TBI_FREEPOLY")
307 {
308 SetActiveTool( rNewItemId );
309 m_xIMapWnd->SetObjKind( SdrObjKind::FreehandFill );
310 }
311 else if (rNewItemId == "TBI_ACTIVE")
312 {
313 URLLoseFocusHdl(*m_xCbbTarget);
314 bool bNewState = !m_xTbxIMapDlg1->get_item_active(rNewItemId);
315 m_xTbxIMapDlg1->set_item_active(rNewItemId, bNewState);
316 m_xIMapWnd->SetCurrentObjState( !bNewState );
317 }
318 else if (rNewItemId == "TBI_MACRO")
319 m_xIMapWnd->DoMacroAssign();
320 else if (rNewItemId == "TBI_PROPERTY")
321 m_xIMapWnd->DoPropertyDialog();
322 else if (rNewItemId == "TBI_POLYEDIT")
323 {
324 SetActiveTool( rNewItemId );
325 m_xIMapWnd->SetPolyEditMode( m_xTbxIMapDlg1->get_item_active(rNewItemId) ? SID_BEZIER_MOVE : 0 );
326 }
327 else if (rNewItemId == "TBI_POLYMOVE")
328 {
329 SetActiveTool( rNewItemId );
330 m_xIMapWnd->SetPolyEditMode( SID_BEZIER_MOVE );
331 }
332 else if (rNewItemId == "TBI_POLYINSERT")
333 {
334 SetActiveTool( rNewItemId );
335 m_xIMapWnd->SetPolyEditMode( SID_BEZIER_INSERT );
336 }
337 else if (rNewItemId == "TBI_POLYDELETE")
338 {
339 SetActiveTool( rNewItemId );
340 m_xIMapWnd->GetSdrView()->DeleteMarkedPoints();
341 }
342 else if (rNewItemId == "TBI_UNDO")
343 {
344 URLLoseFocusHdl(*m_xCbbTarget);
345 m_xIMapWnd->GetSdrModel()->Undo();
346 }
347 else if (rNewItemId == "TBI_REDO")
348 {
349 URLLoseFocusHdl(*m_xCbbTarget);
350 m_xIMapWnd->GetSdrModel()->Redo();
351 }
352}
353
355{
357 css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
358 FileDialogFlags::NONE, m_xDialog.get());
359
360 ImageMap aLoadIMap;
361 const OUString aFilter(SvxResId(RID_SVXSTR_IMAP_ALL_FILTER));
362
363 aDlg.AddFilter( aFilter, IMAP_ALL_TYPE );
367
368 aDlg.SetCurrentFilter( aFilter );
370
371 if( aDlg.Execute() != ERRCODE_NONE )
372 return;
373
374 INetURLObject aURL( aDlg.GetPath() );
375 DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
376 std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ));
377
378 if( pIStm )
379 {
380 aLoadIMap.Read( *pIStm, IMapFormat::Detect );
381
382 if( pIStm->GetError() )
383 {
386 }
387 else
388 m_xIMapWnd->SetImageMap( aLoadIMap );
389 }
390
391 m_xIMapWnd->Invalidate();
392}
393
395{
397 css::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE,
398 FileDialogFlags::NONE, m_xDialog.get());
399
400 const OUString aBinFilter( IMAP_BINARY_FILTER );
401 const OUString aCERNFilter( IMAP_CERN_FILTER );
402 const OUString aNCSAFilter( IMAP_NCSA_FILTER );
403 SdrModel* pModel = m_xIMapWnd->GetSdrModel();
404 const bool bChanged = pModel->IsChanged();
405 bool bRet = false;
406
407 aDlg.AddFilter( aCERNFilter, IMAP_CERN_TYPE );
408 aDlg.AddFilter( aNCSAFilter, IMAP_NCSA_TYPE );
409 aDlg.AddFilter( aBinFilter, IMAP_BINARY_TYPE );
410
411 aDlg.SetCurrentFilter( aCERNFilter );
413
414 if( aDlg.Execute() == ERRCODE_NONE )
415 {
416 const OUString aFilter( aDlg.GetCurrentFilter() );
417 OUString aExt;
418 IMapFormat nFormat;
419
420 if ( aFilter == aBinFilter )
421 {
422 nFormat = IMapFormat::Binary;
423 aExt = "sip";
424 }
425 else if ( aFilter == aCERNFilter )
426 {
427 nFormat = IMapFormat::CERN;
428 aExt = "map";
429 }
430 else if ( aFilter == aNCSAFilter )
431 {
432 nFormat = IMapFormat::NCSA;
433 aExt = "map";
434 }
435 else
436 {
437 return false;
438 }
439
440 INetURLObject aURL( aDlg.GetPath() );
441
442 if( aURL.GetProtocol() == INetProtocol::NotValid )
443 {
444 OSL_FAIL( "invalid URL" );
445 }
446 else
447 {
448 if( aURL.getExtension().isEmpty() )
449 aURL.setExtension( aExt );
450
451 std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE | StreamMode::TRUNC ));
452 if( pOStm )
453 {
454 m_xIMapWnd->GetImageMap().Write( *pOStm, nFormat );
455
456 if( pOStm->GetError() )
458
459 pOStm.reset();
460 pModel->SetChanged( bChanged );
461 bRet = true;
462 }
463 }
464 }
465
466 return bRet;
467}
468
469void SvxIMapDlg::SetActiveTool(std::u16string_view rId)
470{
471 m_xTbxIMapDlg1->set_item_active("TBI_SELECT", rId == u"TBI_SELECT");
472 m_xTbxIMapDlg1->set_item_active("TBI_RECT", rId == u"TBI_RECT");
473 m_xTbxIMapDlg1->set_item_active("TBI_CIRCLE", rId == u"TBI_CIRCLE");
474 m_xTbxIMapDlg1->set_item_active("TBI_POLY", rId == u"TBI_POLY");
475 m_xTbxIMapDlg1->set_item_active("TBI_FREEPOLY", rId == u"TBI_FREEPOLY");
476
477 m_xTbxIMapDlg1->set_item_active("TBI_POLYINSERT", rId == u"TBI_POLYINSERT");
478 m_xTbxIMapDlg1->set_item_active("TBI_POLYDELETE", false);
479
480 bool bMove = rId == u"TBI_POLYMOVE"
481 || ( rId == u"TBI_POLYEDIT"
482 && !m_xTbxIMapDlg1->get_item_active("TBI_POLYINSERT")
483 && !m_xTbxIMapDlg1->get_item_active("TBI_POLYDELETE") );
484
485 m_xTbxIMapDlg1->set_item_active("TBI_POLYMOVE", bMove );
486
487 bool bEditMode = ( rId == u"TBI_POLYEDIT" )
488 || ( rId == u"TBI_POLYMOVE")
489 || ( rId == u"TBI_POLYINSERT")
490 || ( rId == u"TBI_POLYDELETE" );
491
492 m_xTbxIMapDlg1->set_item_active("TBI_POLYEDIT", bEditMode);
493}
494
495IMPL_LINK( SvxIMapDlg, InfoHdl, IMapWindow&, rWnd, void )
496{
497 const NotifyInfo& rInfo = rWnd.GetInfo();
498
499 if ( rInfo.bNewObj )
500 {
501 if (!rInfo.aMarkURL.isEmpty() && ( m_xURLBox->find_text(rInfo.aMarkURL) == -1))
502 m_xURLBox->append_text(rInfo.aMarkURL);
503
504 m_xURLBox->set_entry_text(rInfo.aMarkURL);
505 m_xEdtText->set_text(rInfo.aMarkAltText);
506
507 if ( rInfo.aMarkTarget.isEmpty() )
508 m_xCbbTarget->set_entry_text( SELF_TARGET );
509 else
510 m_xCbbTarget->set_entry_text( rInfo.aMarkTarget );
511 }
512
513 if ( !rInfo.bOneMarked )
514 {
515 m_xTbxIMapDlg1->set_item_active("TBI_ACTIVE", false);
516 m_xTbxIMapDlg1->set_item_sensitive("TBI_ACTIVE", false);
517 m_xTbxIMapDlg1->set_item_sensitive("TBI_MACRO", false);
518 m_xTbxIMapDlg1->set_item_sensitive("TBI_PROPERTY", false);
519 m_xStbStatus1->set_label(OUString());
520
521 m_xFtURL->set_sensitive(false);
522 m_xURLBox->set_sensitive(false);
523 m_xFtText->set_sensitive(false);
524 m_xEdtText->set_sensitive(false);
525 m_xFtTarget->set_sensitive(false);
526 m_xCbbTarget->set_sensitive(false);
527
528 m_xURLBox->set_entry_text( "" );
529 m_xEdtText->set_text( "" );
530 }
531 else
532 {
533 m_xTbxIMapDlg1->set_item_sensitive("TBI_ACTIVE", true);
534 m_xTbxIMapDlg1->set_item_active("TBI_ACTIVE", !rInfo.bActivated );
535 m_xTbxIMapDlg1->set_item_sensitive("TBI_MACRO", true);
536 m_xTbxIMapDlg1->set_item_sensitive("TBI_PROPERTY", true);
537
538 m_xFtURL->set_sensitive(true);
539 m_xURLBox->set_sensitive(true);
540 m_xFtText->set_sensitive(true);
541 m_xEdtText->set_sensitive(true);
542 m_xFtTarget->set_sensitive(true);
543 m_xCbbTarget->set_sensitive(true);
544
545 m_xStbStatus1->set_label(rInfo.aMarkURL);
546
547 if ( m_xURLBox->get_active_text() != rInfo.aMarkURL )
548 m_xURLBox->set_entry_text( rInfo.aMarkURL );
549
550 if ( m_xEdtText->get_text() != rInfo.aMarkAltText )
551 m_xEdtText->set_text( rInfo.aMarkAltText );
552
553 if ( rInfo.aMarkTarget.isEmpty() )
554 m_xCbbTarget->set_entry_text( SELF_TARGET );
555 else
556 m_xCbbTarget->set_entry_text( rInfo.aMarkTarget );
557 }
558}
559
560IMPL_LINK( SvxIMapDlg, MousePosHdl, GraphCtrl*, pWnd, void )
561{
562 const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
563 const Point& rMousePos = pWnd->GetMousePos();
565 const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0];
566
567 OUString aStr = GetUnitString( rMousePos.X(), eFieldUnit, cSep ) +
568 " / " + GetUnitString( rMousePos.Y(), eFieldUnit, cSep );
569
570 m_xStbStatus2->set_label(aStr);
571}
572
573IMPL_LINK( SvxIMapDlg, GraphSizeHdl, GraphCtrl*, pWnd, void )
574{
575 const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
576 const Size& rSize = pWnd->GetGraphicSize();
578 const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0];
579
580 OUString aStr = GetUnitString( rSize.Width(), eFieldUnit, cSep ) +
581 " x " + GetUnitString( rSize.Height(), eFieldUnit, cSep );
582
583 m_xStbStatus3->set_label(aStr);
584}
585
587{
588 NotifyInfo aNewInfo;
589
590 aNewInfo.aMarkURL = m_xURLBox->get_active_text();
591 aNewInfo.aMarkAltText = m_xEdtText->get_text();
592 aNewInfo.aMarkTarget = m_xCbbTarget->get_active_text();
593
594 m_xIMapWnd->ReplaceActualIMapInfo( aNewInfo );
595}
596
598{
599 URLModify();
600}
601
602IMPL_LINK_NOARG(SvxIMapDlg, EntryModifyHdl, weld::Entry&, void)
603{
604 URLModify();
605}
606
607IMPL_LINK_NOARG(SvxIMapDlg, URLLoseFocusHdl, weld::Widget&, void)
608{
609 NotifyInfo aNewInfo;
610 const OUString aURLText( m_xURLBox->get_active_text() );
611 const OUString aTargetText( m_xCbbTarget->get_active_text() );
612
613 if ( !aURLText.isEmpty() )
614 {
615 OUString aBase = GetBindings().GetDispatcher()->GetFrame()->GetObjectShell()->GetMedium()->GetBaseURL();
616 aNewInfo.aMarkURL = ::URIHelper::SmartRel2Abs( INetURLObject(aBase), aURLText, URIHelper::GetMaybeFileHdl(), true, false,
619 }
620 else
621 aNewInfo.aMarkURL = aURLText;
622
623 aNewInfo.aMarkAltText = m_xEdtText->get_text();
624
625 if ( aTargetText.isEmpty() )
626 aNewInfo.aMarkTarget = SELF_TARGET;
627 else
628 aNewInfo.aMarkTarget = aTargetText;
629
630 m_xIMapWnd->ReplaceActualIMapInfo( aNewInfo );
631}
632
633IMPL_LINK_NOARG(SvxIMapDlg, UpdateHdl, Timer *, void)
634{
635 pOwnData->aIdle.Stop();
636
637 if ( pOwnData->pUpdateEditingObject != pCheckObj )
638 {
639 if (m_xIMapWnd->IsChanged())
640 {
641 std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xDialog.get(), "svx/ui/querysaveimagemapchangesdialog.ui"));
642 std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog("QuerySaveImageMapChangesDialog"));
643 if (xQBox->run() == RET_YES)
644 {
645 DoSave();
646 }
647 }
648
649 m_xIMapWnd->SetGraphic( pOwnData->aUpdateGraphic );
650 m_xIMapWnd->SetImageMap( pOwnData->aUpdateImageMap );
651 SetTargetList( pOwnData->aUpdateTargetList );
652 pCheckObj = pOwnData->pUpdateEditingObject;
653
654 // After changes => default selection
655 m_xTbxIMapDlg1->set_item_active("TBI_SELECT", true);
656 m_xIMapWnd->SetEditMode( true );
657 }
658
659 // Delete the copied list again in the Update method
660 pOwnData->aUpdateTargetList.clear();
661
662 GetBindings().Invalidate( SID_IMAP_EXEC );
663 m_xIMapWnd->QueueIdleUpdate();
664}
665
666IMPL_LINK( SvxIMapDlg, StateHdl, GraphCtrl*, pWnd, void )
667{
668 const SdrObject* pObj = pWnd->GetSelectedSdrObject();
669 const SdrModel* pModel = pWnd->GetSdrModel();
670 const SdrView* pView = pWnd->GetSdrView();
671 const bool bPolyEdit = ( pObj != nullptr ) && dynamic_cast<const SdrPathObj*>( pObj) != nullptr;
672 const bool bDrawEnabled = !( bPolyEdit && m_xTbxIMapDlg1->get_item_active("TBI_POLYEDIT") );
673
674 m_xTbxIMapDlg1->set_item_sensitive("TBI_APPLY", pOwnData->bExecState && pWnd->IsChanged() );
675
676 m_xTbxIMapDlg1->set_item_sensitive("TBI_SELECT", bDrawEnabled);
677 m_xTbxIMapDlg1->set_item_sensitive("TBI_RECT", bDrawEnabled);
678 m_xTbxIMapDlg1->set_item_sensitive("TBI_CIRCLE", bDrawEnabled);
679 m_xTbxIMapDlg1->set_item_sensitive("TBI_POLY", bDrawEnabled);
680 m_xTbxIMapDlg1->set_item_sensitive("TBI_FREEPOLY", bDrawEnabled);
681
682 // BezierEditor State
683 m_xTbxIMapDlg1->set_item_sensitive( "TBI_POLYEDIT", bPolyEdit );
684 m_xTbxIMapDlg1->set_item_sensitive( "TBI_POLYMOVE", !bDrawEnabled );
685 m_xTbxIMapDlg1->set_item_sensitive( "TBI_POLYINSERT", !bDrawEnabled );
686 m_xTbxIMapDlg1->set_item_sensitive( "TBI_POLYDELETE", !bDrawEnabled && pView->IsDeleteMarkedPointsPossible() );
687
688 // Undo/Redo
689 m_xTbxIMapDlg1->set_item_sensitive( "TBI_UNDO", pModel->HasUndoActions() );
690 m_xTbxIMapDlg1->set_item_sensitive( "TBI_REDO", pModel->HasRedoActions() );
691
692 if ( bPolyEdit )
693 {
694 switch( pWnd->GetPolyEditMode() )
695 {
696 case SID_BEZIER_MOVE:
697 m_xTbxIMapDlg1->set_item_active("TBI_POLYMOVE", true);
698 m_xTbxIMapDlg1->set_item_active("TBI_POLYINSERT", false);
699 break;
700 case SID_BEZIER_INSERT:
701 m_xTbxIMapDlg1->set_item_active("TBI_POLYINSERT", true);
702 m_xTbxIMapDlg1->set_item_active("TBI_POLYMOVE", false);
703 break;
704 default:
705 break;
706 }
707 }
708 else
709 {
710 m_xTbxIMapDlg1->set_item_active( "TBI_POLYEDIT", false );
711 m_xTbxIMapDlg1->set_item_active( "TBI_POLYMOVE", true);
712 m_xTbxIMapDlg1->set_item_active( "TBI_POLYINSERT", false );
713 pWnd->SetPolyEditMode( 0 );
714 }
715
716 m_xIMapWnd->QueueIdleUpdate();
717}
718
720{
721 SfxChildWindow* pWnd = nullptr;
723 if (pViewFrm && pViewFrm->HasChildWindow(SvxIMapDlgChildWindow::GetChildWindowId()))
724 pWnd = pViewFrm->GetChildWindow(SvxIMapDlgChildWindow::GetChildWindowId());
725 return pWnd ? static_cast<SvxIMapDlg*>(pWnd->GetController().get()) : nullptr;
726}
727
728/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
static const AllSettings & GetSettings()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
void Read(SvStream &rIStm)
const OUString & getNumDecimalSep() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
virtual void SetChanged(bool bFlg=true)
Definition: svdmodel.cxx:1143
bool IsChanged() const
Definition: svdmodel.hxx:420
bool HasRedoActions() const
Definition: svdmodel.cxx:293
bool HasUndoActions() const
Definition: svdmodel.cxx:288
Abstract DrawObject.
Definition: svdobj.hxx:260
bool IsDeleteMarkedPointsPossible() const override
Definition: svdpoev.cxx:281
SfxDispatcher * GetDispatcher() const
void Invalidate(sal_uInt16 nId)
bool GetValue() const
void SetController(std::shared_ptr< SfxDialogController > controller)
std::shared_ptr< SfxDialogController > & GetController()
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
SfxViewFrame * GetFrame() const
SfxModule * GetModule() const
static void GetDefaultTargetList(TargetList &)
OUString GetBaseURL(bool bForSaving=false)
void Initialize(SfxChildWinInfo const *pInfo)
FieldUnit GetFieldUnit() const
SfxMedium * GetMedium() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
bool HasChildWindow(sal_uInt16)
SfxChildWindow * GetChildWindow(sal_uInt16)
virtual SfxObjectShell * GetObjectShell() override
constexpr tools::Long Height() const
constexpr tools::Long Width() const
SvxIMapDlgChildWindow(vcl::Window *, sal_uInt16, SfxBindings *, SfxChildWinInfo const *)
Definition: imapdlg.cxx:84
static void UpdateIMapDlg(const Graphic &rGraphic, const ImageMap *pImageMap, const TargetList *pTargetList, void *pEditingObj)
Definition: imapdlg.cxx:94
SvxIMapDlg & rIMap
Definition: imapdlg.hxx:69
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: imapdlg.cxx:69
SvxIMapDlgItem(SvxIMapDlg &rIMapDlg, SfxBindings &rBindings)
Definition: imapdlg.cxx:63
std::unique_ptr< weld::Label > m_xStbStatus1
Definition: imapdlg.hxx:102
std::unique_ptr< weld::Toolbar > m_xTbxIMapDlg1
Definition: imapdlg.hxx:94
SvxIMapDlg(SfxBindings *pBindings, SfxChildWindow *pCW, weld::Window *pParent)
Definition: imapdlg.cxx:102
void SetExecState(bool bEnable)
Definition: imapdlg.cxx:221
std::unique_ptr< weld::ComboBox > m_xCbbTarget
Definition: imapdlg.hxx:100
void URLModify()
Definition: imapdlg.cxx:586
std::unique_ptr< IMapWindow > m_xIMapWnd
Definition: imapdlg.hxx:93
std::unique_ptr< weld::Button > m_xCancelBtn
Definition: imapdlg.hxx:101
std::unique_ptr< weld::Label > m_xStbStatus3
Definition: imapdlg.hxx:104
std::unique_ptr< weld::Label > m_xFtText
Definition: imapdlg.hxx:97
void SetActiveTool(std::u16string_view rId)
Definition: imapdlg.cxx:469
std::unique_ptr< IMapOwnData > pOwnData
Definition: imapdlg.hxx:89
std::unique_ptr< weld::Label > m_xFtURL
Definition: imapdlg.hxx:95
std::unique_ptr< weld::Label > m_xStbStatus2
Definition: imapdlg.hxx:103
std::unique_ptr< SvtURLBox > m_xURLBox
Definition: imapdlg.hxx:96
std::unique_ptr< weld::Entry > m_xEdtText
Definition: imapdlg.hxx:98
const ImageMap & GetImageMap() const
Definition: imapdlg.cxx:226
void DoOpen()
Definition: imapdlg.cxx:354
void SetTargetList(const TargetList &rTargetList)
Definition: imapdlg.cxx:231
std::unique_ptr< weld::Label > m_xFtTarget
Definition: imapdlg.hxx:99
bool DoSave()
Definition: imapdlg.cxx:394
virtual ~SvxIMapDlg() override
Definition: imapdlg.cxx:177
void UpdateLink(const Graphic &rGraphic, const ImageMap *pImageMap, const TargetList *pTargetList, void *pEditingObj)
Definition: imapdlg.cxx:241
OUString GetPath() const
void AddFilter(const OUString &rFilterName, const OUString &rExtension)
OUString GetCurrentFilter() const
void SetCurrentFilter(const OUString &rFilter)
void SetContext(Context _eNewContext)
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
weld::Window * GetFrameWeld() const
#define DBG_ASSERT(sCon, aError)
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
URL aURL
virtual SfxBindings & GetBindings() override
OUString GetUnitString(tools::Long nVal_100, FieldUnit eFieldUnit, sal_Unicode cSep)
Definition: dlgunit.hxx:27
float u
#define ERRCODE_IO_GENERAL
#define ERRCODE_NONE
FieldUnit
::std::vector< OUString > TargetList
constexpr OUStringLiteral IMAP_CERN_FILTER
Definition: imapdlg.cxx:51
constexpr OUStringLiteral IMAP_BINARY_TYPE
Definition: imapdlg.cxx:55
constexpr OUStringLiteral IMAP_CERN_TYPE
Definition: imapdlg.cxx:56
constexpr OUStringLiteral SELF_TARGET
Definition: imapdlg.cxx:50
constexpr OUStringLiteral IMAP_BINARY_FILTER
Definition: imapdlg.cxx:53
IMPL_LINK_NOARG(SvxIMapDlg, CancelHdl, weld::Button &, void)
Definition: imapdlg.cxx:183
constexpr OUStringLiteral IMAP_NCSA_TYPE
Definition: imapdlg.cxx:57
IMPL_LINK(SvxIMapDlg, TbxClickHdl, const OUString &, rNewItemId, void)
Definition: imapdlg.cxx:270
constexpr OUStringLiteral IMAP_ALL_TYPE
Definition: imapdlg.cxx:54
constexpr OUStringLiteral IMAP_NCSA_FILTER
Definition: imapdlg.cxx:52
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(SvxIMapDlgChildWindow, SID_IMAP)
SvxIMapDlg * GetIMapDlg()
Definition: imapdlg.cxx:719
IMapFormat
aStr
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
const LocaleDataWrapper & GetLocaleDataWrapper(LanguageType nLang)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
long Long
sal_Int16 nId
SfxItemState
#define ERRCTX_ERROR
bool bOneMarked
Definition: imapwnd.hxx:38
bool bNewObj
Definition: imapwnd.hxx:37
OUString aMarkURL
Definition: imapwnd.hxx:34
OUString aMarkTarget
Definition: imapwnd.hxx:36
OUString aMarkAltText
Definition: imapwnd.hxx:35
bool bActivated
Definition: imapwnd.hxx:39
@ Polygon
circle cut
@ CircleOrEllipse
rectangle (round corners optional)
@ Rectangle
line
@ FreehandFill
open free-hand line
sal_uInt16 sal_Unicode
RET_CANCEL
RET_YES