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 "dlgunit.hxx"
48 #include <memory>
49 
50 #define SELF_TARGET "_self"
51 #define IMAP_CERN_FILTER "MAP - CERN"
52 #define IMAP_NCSA_FILTER "MAP - NCSA"
53 #define IMAP_BINARY_FILTER "SIP - StarView ImageMap"
54 #define IMAP_ALL_TYPE "*.*"
55 #define IMAP_BINARY_TYPE "*.sip"
56 #define IMAP_CERN_TYPE "*.map"
57 #define IMAP_NCSA_TYPE "*.map"
58 
60 
61 // ControllerItem
62 
64  SfxControllerItem ( SID_IMAP_EXEC, rBindings ),
65  rIMap ( rIMapDlg )
66 {
67 }
68 
69 void SvxIMapDlgItem::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/,
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 
94 void 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  OString 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 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 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 
221 void SvxIMapDlg::SetExecState( bool bEnable )
222 {
223  pOwnData->bExecState = bEnable;
224 }
225 
227 {
228  return m_xIMapWnd->GetImageMap();
229 }
230 
231 void SvxIMapDlg::SetTargetList( const TargetList& rTargetList )
232 {
233  TargetList aNewList( rTargetList );
234 
235  m_xIMapWnd->SetTargetList( aNewList );
236 
237  m_xCbbTarget->clear();
238 
239  for (const OUString & s : aNewList)
240  m_xCbbTarget->append_text(s);
241 }
242 
243 void SvxIMapDlg::UpdateLink( const Graphic& rGraphic, const ImageMap* pImageMap,
244  const TargetList* pTargetList, void* pEditingObj )
245 {
246  pOwnData->aUpdateGraphic = rGraphic;
247 
248  if ( pImageMap )
249  pOwnData->aUpdateImageMap = *pImageMap;
250  else
251  pOwnData->aUpdateImageMap.ClearImageMap();
252 
253  pOwnData->pUpdateEditingObject = pEditingObj;
254 
255  // Delete UpdateTargetList, because this method can still be called several
256  // times before the update timer is turned on
257  pOwnData->aUpdateTargetList.clear();
258 
259  // TargetList must be copied, since it is owned by the caller and can be
260  // deleted immediately after this call the copied list will be deleted
261  // again in the handler
262  if( pTargetList )
263  {
264  TargetList aTargetList( *pTargetList );
265 
266  for (const OUString & s : aTargetList)
267  pOwnData->aUpdateTargetList.push_back( s );
268  }
269 
270  pOwnData->aIdle.Start();
271 }
272 
273 
274 // Click-handler for ToolBox
275 
276 IMPL_LINK(SvxIMapDlg, TbxClickHdl, const OString&, rNewItemId, void)
277 {
278  if (rNewItemId == "TBI_APPLY")
279  {
280  URLLoseFocusHdl(*m_xCbbTarget);
281  SfxBoolItem aBoolItem( SID_IMAP_EXEC, true );
282  GetBindings().GetDispatcher()->ExecuteList(SID_IMAP_EXEC,
283  SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
284  { &aBoolItem });
285  }
286  else if (rNewItemId == "TBI_OPEN")
287  DoOpen();
288  else if (rNewItemId == "TBI_SAVEAS")
289  DoSave();
290  else if (rNewItemId == "TBI_CLOSE")
291  CancelHdl(*m_xCancelBtn);
292  else if (rNewItemId == "TBI_SELECT")
293  {
294  SetActiveTool( rNewItemId );
295  m_xIMapWnd->SetEditMode( true );
296  }
297  else if (rNewItemId == "TBI_RECT")
298  {
299  SetActiveTool( rNewItemId );
300  m_xIMapWnd->SetObjKind( OBJ_RECT );
301  }
302  else if (rNewItemId == "TBI_CIRCLE")
303  {
304  SetActiveTool( rNewItemId );
305  m_xIMapWnd->SetObjKind( OBJ_CIRC );
306  }
307  else if (rNewItemId == "TBI_POLY")
308  {
309  SetActiveTool( rNewItemId );
310  m_xIMapWnd->SetObjKind( OBJ_POLY );
311  }
312  else if (rNewItemId == "TBI_FREEPOLY")
313  {
314  SetActiveTool( rNewItemId );
315  m_xIMapWnd->SetObjKind( OBJ_FREEFILL );
316  }
317  else if (rNewItemId == "TBI_ACTIVE")
318  {
319  URLLoseFocusHdl(*m_xCbbTarget);
320  bool bNewState = !m_xTbxIMapDlg1->get_item_active(rNewItemId);
321  m_xTbxIMapDlg1->set_item_active(rNewItemId, bNewState);
322  m_xIMapWnd->SetCurrentObjState( !bNewState );
323  }
324  else if (rNewItemId == "TBI_MACRO")
325  m_xIMapWnd->DoMacroAssign();
326  else if (rNewItemId == "TBI_PROPERTY")
327  m_xIMapWnd->DoPropertyDialog();
328  else if (rNewItemId == "TBI_POLYEDIT")
329  {
330  SetActiveTool( rNewItemId );
331  m_xIMapWnd->SetPolyEditMode( m_xTbxIMapDlg1->get_item_active(rNewItemId) ? SID_BEZIER_MOVE : 0 );
332  }
333  else if (rNewItemId == "TBI_POLYMOVE")
334  {
335  SetActiveTool( rNewItemId );
336  m_xIMapWnd->SetPolyEditMode( SID_BEZIER_MOVE );
337  }
338  else if (rNewItemId == "TBI_POLYINSERT")
339  {
340  SetActiveTool( rNewItemId );
341  m_xIMapWnd->SetPolyEditMode( SID_BEZIER_INSERT );
342  }
343  else if (rNewItemId == "TBI_POLYDELETE")
344  {
345  SetActiveTool( rNewItemId );
346  m_xIMapWnd->GetSdrView()->DeleteMarkedPoints();
347  }
348  else if (rNewItemId == "TBI_UNDO")
349  {
350  URLLoseFocusHdl(*m_xCbbTarget);
351  m_xIMapWnd->GetSdrModel()->Undo();
352  }
353  else if (rNewItemId == "TBI_REDO")
354  {
355  URLLoseFocusHdl(*m_xCbbTarget);
356  m_xIMapWnd->GetSdrModel()->Redo();
357  }
358 }
359 
361 {
363  css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
364  FileDialogFlags::NONE, m_xDialog.get());
365 
366  ImageMap aLoadIMap;
367  const OUString aFilter(SvxResId(RID_SVXSTR_IMAP_ALL_FILTER));
368 
369  aDlg.AddFilter( aFilter, IMAP_ALL_TYPE );
370  aDlg.AddFilter( IMAP_CERN_FILTER, IMAP_CERN_TYPE );
371  aDlg.AddFilter( IMAP_NCSA_FILTER, IMAP_NCSA_TYPE );
372  aDlg.AddFilter( IMAP_BINARY_FILTER, IMAP_BINARY_TYPE );
373 
374  aDlg.SetCurrentFilter( aFilter );
375  aDlg.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
376 
377  if( aDlg.Execute() != ERRCODE_NONE )
378  return;
379 
380  INetURLObject aURL( aDlg.GetPath() );
381  DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
382  std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ));
383 
384  if( pIStm )
385  {
386  aLoadIMap.Read( *pIStm, IMapFormat::Detect );
387 
388  if( pIStm->GetError() )
389  {
392  }
393  else
394  m_xIMapWnd->SetImageMap( aLoadIMap );
395  }
396 
397  m_xIMapWnd->Invalidate();
398 }
399 
401 {
403  css::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE,
404  FileDialogFlags::NONE, m_xDialog.get());
405 
406  const OUString aBinFilter( IMAP_BINARY_FILTER );
407  const OUString aCERNFilter( IMAP_CERN_FILTER );
408  const OUString aNCSAFilter( IMAP_NCSA_FILTER );
409  SdrModel* pModel = m_xIMapWnd->GetSdrModel();
410  const bool bChanged = pModel->IsChanged();
411  bool bRet = false;
412 
413  aDlg.AddFilter( aCERNFilter, IMAP_CERN_TYPE );
414  aDlg.AddFilter( aNCSAFilter, IMAP_NCSA_TYPE );
415  aDlg.AddFilter( aBinFilter, IMAP_BINARY_TYPE );
416 
417  aDlg.SetCurrentFilter( aCERNFilter );
418  aDlg.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
419 
420  if( aDlg.Execute() == ERRCODE_NONE )
421  {
422  const OUString aFilter( aDlg.GetCurrentFilter() );
423  OUString aExt;
424  IMapFormat nFormat;
425 
426  if ( aFilter == aBinFilter )
427  {
428  nFormat = IMapFormat::Binary;
429  aExt = "sip";
430  }
431  else if ( aFilter == aCERNFilter )
432  {
433  nFormat = IMapFormat::CERN;
434  aExt = "map";
435  }
436  else if ( aFilter == aNCSAFilter )
437  {
438  nFormat = IMapFormat::NCSA;
439  aExt = "map";
440  }
441  else
442  {
443  return false;
444  }
445 
446  INetURLObject aURL( aDlg.GetPath() );
447 
448  if( aURL.GetProtocol() == INetProtocol::NotValid )
449  {
450  OSL_FAIL( "invalid URL" );
451  }
452  else
453  {
454  if( aURL.getExtension().isEmpty() )
455  aURL.setExtension( aExt );
456 
457  std::unique_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE | StreamMode::TRUNC ));
458  if( pOStm )
459  {
460  m_xIMapWnd->GetImageMap().Write( *pOStm, nFormat );
461 
462  if( pOStm->GetError() )
464 
465  pOStm.reset();
466  pModel->SetChanged( bChanged );
467  bRet = true;
468  }
469  }
470  }
471 
472  return bRet;
473 }
474 
475 void SvxIMapDlg::SetActiveTool(const OString& rId)
476 {
477  m_xTbxIMapDlg1->set_item_active("TBI_SELECT", rId == "TBI_SELECT");
478  m_xTbxIMapDlg1->set_item_active("TBI_RECT", rId == "TBI_RECT");
479  m_xTbxIMapDlg1->set_item_active("TBI_CIRCLE", rId == "TBI_CIRCLE");
480  m_xTbxIMapDlg1->set_item_active("TBI_POLY", rId == "TBI_POLY");
481  m_xTbxIMapDlg1->set_item_active("TBI_FREEPOLY", rId == "TBI_FREEPOLY");
482 
483  m_xTbxIMapDlg1->set_item_active("TBI_POLYINSERT", rId == "TBI_POLYINSERT");
484  m_xTbxIMapDlg1->set_item_active("TBI_POLYDELETE", false);
485 
486  bool bMove = rId == "TBI_POLYMOVE"
487  || ( rId == "TBI_POLYEDIT"
488  && !m_xTbxIMapDlg1->get_item_active("TBI_POLYINSERT")
489  && !m_xTbxIMapDlg1->get_item_active("TBI_POLYDELETE") );
490 
491  m_xTbxIMapDlg1->set_item_active("TBI_POLYMOVE", bMove );
492 
493  bool bEditMode = ( rId == "TBI_POLYEDIT" )
494  || ( rId == "TBI_POLYMOVE")
495  || ( rId == "TBI_POLYINSERT")
496  || ( rId == "TBI_POLYDELETE" );
497 
498  m_xTbxIMapDlg1->set_item_active("TBI_POLYEDIT", bEditMode);
499 }
500 
501 IMPL_LINK( SvxIMapDlg, InfoHdl, IMapWindow&, rWnd, void )
502 {
503  const NotifyInfo& rInfo = rWnd.GetInfo();
504 
505  if ( rInfo.bNewObj )
506  {
507  if (!rInfo.aMarkURL.isEmpty() && ( m_xURLBox->find_text(rInfo.aMarkURL) == -1))
508  m_xURLBox->append_text(rInfo.aMarkURL);
509 
510  m_xURLBox->set_entry_text(rInfo.aMarkURL);
511  m_xEdtText->set_text(rInfo.aMarkAltText);
512 
513  if ( rInfo.aMarkTarget.isEmpty() )
514  m_xCbbTarget->set_entry_text( SELF_TARGET );
515  else
516  m_xCbbTarget->set_entry_text( rInfo.aMarkTarget );
517  }
518 
519  if ( !rInfo.bOneMarked )
520  {
521  m_xTbxIMapDlg1->set_item_active("TBI_ACTIVE", false);
522  m_xTbxIMapDlg1->set_item_sensitive("TBI_ACTIVE", false);
523  m_xTbxIMapDlg1->set_item_sensitive("TBI_MACRO", false);
524  m_xTbxIMapDlg1->set_item_sensitive("TBI_PROPERTY", false);
525  m_xStbStatus1->set_label(OUString());
526 
527  m_xFtURL->set_sensitive(false);
528  m_xURLBox->set_sensitive(false);
529  m_xFtText->set_sensitive(false);
530  m_xEdtText->set_sensitive(false);
531  m_xFtTarget->set_sensitive(false);
532  m_xCbbTarget->set_sensitive(false);
533 
534  m_xURLBox->set_entry_text( "" );
535  m_xEdtText->set_text( "" );
536  }
537  else
538  {
539  m_xTbxIMapDlg1->set_item_sensitive("TBI_ACTIVE", true);
540  m_xTbxIMapDlg1->set_item_active("TBI_ACTIVE", !rInfo.bActivated );
541  m_xTbxIMapDlg1->set_item_sensitive("TBI_MACRO", true);
542  m_xTbxIMapDlg1->set_item_sensitive("TBI_PROPERTY", true);
543 
544  m_xFtURL->set_sensitive(true);
545  m_xURLBox->set_sensitive(true);
546  m_xFtText->set_sensitive(true);
547  m_xEdtText->set_sensitive(true);
548  m_xFtTarget->set_sensitive(true);
549  m_xCbbTarget->set_sensitive(true);
550 
551  m_xStbStatus1->set_label(rInfo.aMarkURL);
552 
553  if ( m_xURLBox->get_active_text() != rInfo.aMarkURL )
554  m_xURLBox->set_entry_text( rInfo.aMarkURL );
555 
556  if ( m_xEdtText->get_text() != rInfo.aMarkAltText )
557  m_xEdtText->set_text( rInfo.aMarkAltText );
558 
559  if ( rInfo.aMarkTarget.isEmpty() )
560  m_xCbbTarget->set_entry_text( SELF_TARGET );
561  else
562  m_xCbbTarget->set_entry_text( rInfo.aMarkTarget );
563  }
564 }
565 
566 IMPL_LINK( SvxIMapDlg, MousePosHdl, GraphCtrl*, pWnd, void )
567 {
568  const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
569  const Point& rMousePos = pWnd->GetMousePos();
571  const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0];
572 
573  OUString aStr = GetUnitString( rMousePos.X(), eFieldUnit, cSep ) +
574  " / " + GetUnitString( rMousePos.Y(), eFieldUnit, cSep );
575 
576  m_xStbStatus2->set_label(aStr);
577 }
578 
579 IMPL_LINK( SvxIMapDlg, GraphSizeHdl, GraphCtrl*, pWnd, void )
580 {
581  const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
582  const Size& rSize = pWnd->GetGraphicSize();
584  const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0];
585 
586  OUString aStr = GetUnitString( rSize.Width(), eFieldUnit, cSep ) +
587  " x " + GetUnitString( rSize.Height(), eFieldUnit, cSep );
588 
589  m_xStbStatus3->set_label(aStr);
590 }
591 
593 {
594  NotifyInfo aNewInfo;
595 
596  aNewInfo.aMarkURL = m_xURLBox->get_active_text();
597  aNewInfo.aMarkAltText = m_xEdtText->get_text();
598  aNewInfo.aMarkTarget = m_xCbbTarget->get_active_text();
599 
600  m_xIMapWnd->ReplaceActualIMapInfo( aNewInfo );
601 }
602 
604 {
605  URLModify();
606 }
607 
608 IMPL_LINK_NOARG(SvxIMapDlg, EntryModifyHdl, weld::Entry&, void)
609 {
610  URLModify();
611 }
612 
613 IMPL_LINK_NOARG(SvxIMapDlg, URLLoseFocusHdl, weld::Widget&, void)
614 {
615  NotifyInfo aNewInfo;
616  const OUString aURLText( m_xURLBox->get_active_text() );
617  const OUString aTargetText( m_xCbbTarget->get_active_text() );
618 
619  if ( !aURLText.isEmpty() )
620  {
621  OUString aBase = GetBindings().GetDispatcher()->GetFrame()->GetObjectShell()->GetMedium()->GetBaseURL();
622  aNewInfo.aMarkURL = ::URIHelper::SmartRel2Abs( INetURLObject(aBase), aURLText, URIHelper::GetMaybeFileHdl(), true, false,
625  }
626  else
627  aNewInfo.aMarkURL = aURLText;
628 
629  aNewInfo.aMarkAltText = m_xEdtText->get_text();
630 
631  if ( aTargetText.isEmpty() )
632  aNewInfo.aMarkTarget = SELF_TARGET;
633  else
634  aNewInfo.aMarkTarget = aTargetText;
635 
636  m_xIMapWnd->ReplaceActualIMapInfo( aNewInfo );
637 }
638 
639 IMPL_LINK_NOARG(SvxIMapDlg, UpdateHdl, Timer *, void)
640 {
641  pOwnData->aIdle.Stop();
642 
643  if ( pOwnData->pUpdateEditingObject != pCheckObj )
644  {
645  if (m_xIMapWnd->IsChanged())
646  {
647  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xDialog.get(), "svx/ui/querysaveimagemapchangesdialog.ui"));
648  std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog("QuerySaveImageMapChangesDialog"));
649  if (xQBox->run() == RET_YES)
650  {
651  DoSave();
652  }
653  }
654 
655  m_xIMapWnd->SetGraphic( pOwnData->aUpdateGraphic );
656  m_xIMapWnd->SetImageMap( pOwnData->aUpdateImageMap );
657  SetTargetList( pOwnData->aUpdateTargetList );
658  pCheckObj = pOwnData->pUpdateEditingObject;
659 
660  // After changes => default selection
661  m_xTbxIMapDlg1->set_item_active("TBI_SELECT", true);
662  m_xIMapWnd->SetEditMode( true );
663  }
664 
665  // Delete the copied list again in the Update method
666  pOwnData->aUpdateTargetList.clear();
667 
668  GetBindings().Invalidate( SID_IMAP_EXEC );
669  m_xIMapWnd->QueueIdleUpdate();
670 }
671 
672 IMPL_LINK( SvxIMapDlg, StateHdl, GraphCtrl*, pWnd, void )
673 {
674  const SdrObject* pObj = pWnd->GetSelectedSdrObject();
675  const SdrModel* pModel = pWnd->GetSdrModel();
676  const SdrView* pView = pWnd->GetSdrView();
677  const bool bPolyEdit = ( pObj != nullptr ) && dynamic_cast<const SdrPathObj*>( pObj) != nullptr;
678  const bool bDrawEnabled = !( bPolyEdit && m_xTbxIMapDlg1->get_item_active("TBI_POLYEDIT") );
679 
680  m_xTbxIMapDlg1->set_item_sensitive("TBI_APPLY", pOwnData->bExecState && pWnd->IsChanged() );
681 
682  m_xTbxIMapDlg1->set_item_sensitive("TBI_SELECT", bDrawEnabled);
683  m_xTbxIMapDlg1->set_item_sensitive("TBI_RECT", bDrawEnabled);
684  m_xTbxIMapDlg1->set_item_sensitive("TBI_CIRCLE", bDrawEnabled);
685  m_xTbxIMapDlg1->set_item_sensitive("TBI_POLY", bDrawEnabled);
686  m_xTbxIMapDlg1->set_item_sensitive("TBI_FREEPOLY", bDrawEnabled);
687 
688  // BezierEditor State
689  m_xTbxIMapDlg1->set_item_sensitive( "TBI_POLYEDIT", bPolyEdit );
690  m_xTbxIMapDlg1->set_item_sensitive( "TBI_POLYMOVE", !bDrawEnabled );
691  m_xTbxIMapDlg1->set_item_sensitive( "TBI_POLYINSERT", !bDrawEnabled );
692  m_xTbxIMapDlg1->set_item_sensitive( "TBI_POLYDELETE", !bDrawEnabled && pView->IsDeleteMarkedPointsPossible() );
693 
694  // Undo/Redo
695  m_xTbxIMapDlg1->set_item_sensitive( "TBI_UNDO", pModel->HasUndoActions() );
696  m_xTbxIMapDlg1->set_item_sensitive( "TBI_REDO", pModel->HasRedoActions() );
697 
698  if ( bPolyEdit )
699  {
700  switch( pWnd->GetPolyEditMode() )
701  {
702  case SID_BEZIER_MOVE:
703  m_xTbxIMapDlg1->set_item_active("TBI_POLYMOVE", true);
704  m_xTbxIMapDlg1->set_item_active("TBI_POLYINSERT", false);
705  break;
706  case SID_BEZIER_INSERT:
707  m_xTbxIMapDlg1->set_item_active("TBI_POLYINSERT", true);
708  m_xTbxIMapDlg1->set_item_active("TBI_POLYMOVE", false);
709  break;
710  default:
711  break;
712  }
713  }
714  else
715  {
716  m_xTbxIMapDlg1->set_item_active( "TBI_POLYEDIT", false );
717  m_xTbxIMapDlg1->set_item_active( "TBI_POLYMOVE", true);
718  m_xTbxIMapDlg1->set_item_active( "TBI_POLYINSERT", false );
719  pWnd->SetPolyEditMode( 0 );
720  }
721 
722  m_xIMapWnd->QueueIdleUpdate();
723 }
724 
726 {
727  SfxChildWindow* pWnd = nullptr;
728  if (SfxViewFrame::Current() && SfxViewFrame::Current()->HasChildWindow(SvxIMapDlgChildWindow::GetChildWindowId()))
729  pWnd = SfxViewFrame::Current()->GetChildWindow(SvxIMapDlgChildWindow::GetChildWindowId());
730  return pWnd ? static_cast<SvxIMapDlg*>(pWnd->GetController().get()) : nullptr;
731 }
732 
733 /* 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
long Width() const
OUString GetUnitString(long nVal_100, FieldUnit eFieldUnit, sal_Unicode cSep)
Definition: dlgunit.hxx:27
void URLModify()
Definition: imapdlg.cxx:592
URL aURL
FieldUnit
std::unique_ptr< IMapOwnData > pOwnData
Definition: imapdlg.hxx:89
SfxChildWindow * GetChildWindow(sal_uInt16)
void Initialize(SfxChildWinInfo const *pInfo)
static void GetDefaultTargetList(TargetList &)
#define IMAP_CERN_TYPE
Definition: imapdlg.cxx:56
void UpdateLink(const Graphic &rGraphic, const ImageMap *pImageMap, const TargetList *pTargetList, void *pEditingObj)
Definition: imapdlg.cxx:243
long Height() const
virtual ~SvxIMapDlg() override
Definition: imapdlg.cxx:177
static const AllSettings & GetSettings()
std::unique_ptr< IMapWindow > m_xIMapWnd
Definition: imapdlg.hxx:93
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
#define IMAP_NCSA_FILTER
Definition: imapdlg.cxx:52
IMapFormat
OUString aMarkURL
Definition: imapwnd.hxx:33
std::unique_ptr< weld::Label > m_xFtText
Definition: imapdlg.hxx:97
bool bNewObj
Definition: imapwnd.hxx:36
circle cut
Definition: svdobj.hxx:125
std::unique_ptr< weld::Label > m_xStbStatus3
Definition: imapdlg.hxx:104
open free-hand line
Definition: svdobj.hxx:130
RET_CANCEL
line
Definition: svdobj.hxx:120
#define SELF_TARGET
Definition: imapdlg.cxx:50
weld::Window * GetFrameWeld() const
sal_uInt16 sal_Unicode
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)
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
SvxIMapDlg * GetIMapDlg()
Definition: imapdlg.cxx:725
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
#define ERRCTX_ERROR
void SetExecState(bool bEnable)
Definition: imapdlg.cxx:221
virtual void SetChanged(bool bFlg=true)
Definition: svdmodel.cxx:1261
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:63
std::unique_ptr< weld::ComboBox > m_xCbbTarget
Definition: imapdlg.hxx:100
const ImageMap & GetImageMap() const
Definition: imapdlg.cxx:226
SvxIMapDlg & rIMap
Definition: imapdlg.hxx:69
void SetActiveTool(const OString &rId)
Definition: imapdlg.cxx:475
const OUString & getNumDecimalSep() const
std::unique_ptr< weld::Label > m_xStbStatus1
Definition: imapdlg.hxx:102
#define ERRCODE_IO_GENERAL
#define DBG_ASSERT(sCon, aError)
#define IMAP_ALL_TYPE
Definition: imapdlg.cxx:54
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
static void UpdateIMapDlg(const Graphic &rGraphic, const ImageMap *pImageMap, const TargetList *pTargetList, void *pEditingObj)
Definition: imapdlg.cxx:94
SvxIMapDlgChildWindow(vcl::Window *, sal_uInt16, SfxBindings *, SfxChildWinInfo const *)
Definition: imapdlg.cxx:84
bool bOneMarked
Definition: imapwnd.hxx:37
void SetTargetList(const TargetList &rTargetList)
Definition: imapdlg.cxx:231
const LocaleDataWrapper & GetLocaleDataWrapper(LanguageType nLang)
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: imapdlg.cxx:69
Abstract DrawObject.
Definition: svdobj.hxx:312
std::unique_ptr< SvtURLBox > m_xURLBox
Definition: imapdlg.hxx:96
void DoOpen()
Definition: imapdlg.cxx:360
OUString aMarkAltText
Definition: imapwnd.hxx:34
bool IsChanged() const
Definition: svdmodel.hxx:419
std::unique_ptr< weld::Label > m_xFtURL
Definition: imapdlg.hxx:95
SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(SvxIMapDlgChildWindow, SID_IMAP)
#define IMAP_NCSA_TYPE
Definition: imapdlg.cxx:57
bool HasRedoActions() const
Definition: svdmodel.cxx:316
static SfxViewFrame * Current()
SfxItemState
#define IMAP_BINARY_TYPE
Definition: imapdlg.cxx:55
std::unique_ptr< weld::Label > m_xStbStatus2
Definition: imapdlg.hxx:103
#define ERRCODE_NONE
std::unique_ptr< weld::Entry > m_xEdtText
Definition: imapdlg.hxx:98
void SetController(std::shared_ptr< SfxDialogController > controller)
#define IMAP_BINARY_FILTER
Definition: imapdlg.cxx:53
Reference< XExecutableDialog > m_xDialog
::std::vector< OUString > TargetList
bool DoSave()
Definition: imapdlg.cxx:400
IMPL_LINK(SvxIMapDlg, TbxClickHdl, const OString &, rNewItemId, void)
Definition: imapdlg.cxx:276
std::unique_ptr< weld::Button > m_xCancelBtn
Definition: imapdlg.hxx:101
bool HasUndoActions() const
Definition: svdmodel.cxx:311
IMPL_LINK_NOARG(SvxIMapDlg, CancelHdl, weld::Button &, void)
Definition: imapdlg.cxx:183
SvxIMapDlg(SfxBindings *pBindings, SfxChildWindow *pCW, weld::Window *pParent)
Definition: imapdlg.cxx:102
std::unique_ptr< weld::Toolbar > m_xTbxIMapDlg1
Definition: imapdlg.hxx:94
aStr
OUString aMarkTarget
Definition: imapwnd.hxx:35
#define IMAP_CERN_FILTER
Definition: imapdlg.cxx:51
rectangle (round corners optional)
Definition: svdobj.hxx:121