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