LibreOffice Module cui (master)  1
tphatch.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 <memory>
21 #include <tools/urlobj.hxx>
22 #include <vcl/settings.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/weld.hxx>
25 #include <sfx2/dialoghelper.hxx>
26 
27 #include <strings.hrc>
28 #include <svx/xfillit0.hxx>
29 #include <svx/xflhtit.hxx>
30 #include <svx/xflclit.hxx>
31 #include <svx/colorbox.hxx>
32 #include <svx/xtable.hxx>
33 #include <svx/xflbckit.hxx>
34 #include <cuitabarea.hxx>
35 #include <svx/svxdlg.hxx>
36 #include <dialmgr.hxx>
37 #include <svx/dlgutil.hxx>
38 #include <svx/dialmgr.hxx>
39 #include <svx/strings.hrc>
40 #include <svx/svxids.hrc>
41 #include <sal/log.hxx>
42 #include <svtools/unitconv.hxx>
43 
44 using namespace com::sun::star;
45 
47  : SfxTabPage(pPage, pController, "cui/ui/hatchpage.ui", "HatchPage", &rInAttrs)
48  , m_rOutAttrs(rInAttrs)
49  , m_pnHatchingListState(nullptr)
50  , m_pnColorListState(nullptr)
51  , m_aXFillAttr(rInAttrs.GetPool())
52  , m_rXFSet(m_aXFillAttr.GetItemSet())
53  , m_xMtrDistance(m_xBuilder->weld_metric_spin_button("distancemtr", FieldUnit::MM))
54  , m_xMtrAngle(m_xBuilder->weld_metric_spin_button("anglemtr", FieldUnit::DEGREE))
55  , m_xSliderAngle(m_xBuilder->weld_scale("angleslider"))
56  , m_xLbLineType(m_xBuilder->weld_combo_box("linetypelb"))
57  , m_xLbLineColor(new ColorListBox(m_xBuilder->weld_menu_button("linecolorlb"), pController->getDialog()))
58  , m_xCbBackgroundColor(m_xBuilder->weld_check_button("backgroundcolor"))
59  , m_xLbBackgroundColor(new ColorListBox(m_xBuilder->weld_menu_button("backgroundcolorlb"), pController->getDialog()))
60  , m_xHatchLB(new SvxPresetListBox(m_xBuilder->weld_scrolled_window("hatchpresetlistwin")))
61  , m_xBtnAdd(m_xBuilder->weld_button("add"))
62  , m_xBtnModify(m_xBuilder->weld_button("modify"))
63  , m_xHatchLBWin(new weld::CustomWeld(*m_xBuilder, "hatchpresetlist", *m_xHatchLB))
64  , m_xCtlPreview(new weld::CustomWeld(*m_xBuilder, "previewctl", m_aCtlPreview))
65 {
66  Size aSize = getPagePropertiesOptimalSize(m_xHatchLB->GetDrawingArea()->get_ref_device());
67  m_xHatchLBWin->set_size_request(aSize.Width(), aSize.Height());
68 
69  aSize = getDrawPreviewOptimalSize(m_aCtlPreview.GetDrawingArea()->get_ref_device());
70  m_xCtlPreview->set_size_request(aSize.Width(), aSize.Height());
71 
72  // this page needs ExchangeSupport
74 
75  // adjust metric
76  FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
77 
78  switch ( eFUnit )
79  {
80  case FieldUnit::M:
81  case FieldUnit::KM:
82  eFUnit = FieldUnit::MM;
83  break;
84  default: ;//prevent warning
85  }
86  SetFieldUnit( *m_xMtrDistance, eFUnit );
87 
88  // determine PoolUnit
89  SfxItemPool* pPool = m_rOutAttrs.GetPool();
90  assert( pPool && "Where is the pool?" );
91  m_ePoolUnit = pPool->GetMetric( SID_ATTR_FILL_HATCH );
92 
93  // setting the output device
94  m_rXFSet.Put( XFillStyleItem(drawing::FillStyle_HATCH) );
95  m_rXFSet.Put( XFillHatchItem(OUString(), XHatch()) );
97  m_xHatchLB->SetSelectHdl( LINK( this, SvxHatchTabPage, ChangeHatchHdl ) );
98  m_xHatchLB->SetRenameHdl( LINK( this, SvxHatchTabPage, ClickRenameHdl_Impl ) );
99  m_xHatchLB->SetDeleteHdl( LINK( this, SvxHatchTabPage, ClickDeleteHdl_Impl ) );
100 
101  Link<weld::MetricSpinButton&,void> aLink = LINK( this, SvxHatchTabPage, ModifiedEditHdl_Impl );
102  Link<weld::ComboBox&,void> aLink2 = LINK( this, SvxHatchTabPage, ModifiedListBoxHdl_Impl );
103  m_xMtrDistance->connect_value_changed( aLink );
104  m_xMtrAngle->connect_value_changed( aLink );
105  m_xSliderAngle->connect_value_changed(LINK(this, SvxHatchTabPage, ModifiedSliderHdl_Impl));
106  m_xLbLineType->connect_changed( aLink2 );
107  Link<ColorListBox&,void> aLink3 = LINK( this, SvxHatchTabPage, ModifiedColorListBoxHdl_Impl );
108  m_xLbLineColor->SetSelectHdl( aLink3 );
109  m_xCbBackgroundColor->connect_toggled( LINK( this, SvxHatchTabPage, ToggleHatchBackgroundColor_Impl ) );
110  m_xLbBackgroundColor->SetSelectHdl( LINK( this, SvxHatchTabPage, ModifiedBackgroundHdl_Impl ) );
111 
112  m_xBtnAdd->connect_clicked( LINK( this, SvxHatchTabPage, ClickAddHdl_Impl ) );
113  m_xBtnModify->connect_clicked( LINK( this, SvxHatchTabPage, ClickModifyHdl_Impl ) );
114 
116 }
117 
119 {
120  m_xCtlPreview.reset();
121  m_xHatchLBWin.reset();
122  m_xHatchLB.reset();
123  m_xLbBackgroundColor.reset();
124  m_xLbLineColor.reset();
125 }
126 
128 {
129  m_xHatchLB->FillPresetListBox(*m_pHatchingList);
130 }
131 
133 {
134  if( m_pColorList.is() )
135  {
136  // ColorList
137  if( *m_pnColorListState & ChangeType::CHANGED ||
138  *m_pnColorListState & ChangeType::MODIFIED )
139  {
140  SvxAreaTabDialog* pArea = (*m_pnColorListState & ChangeType::CHANGED) ?
141  dynamic_cast<SvxAreaTabDialog*>(GetDialogController()) : nullptr;
142  if (pArea)
143  m_pColorList = pArea->GetNewColorList();
144 
145  ModifiedHdl_Impl( this );
146  }
147 
148  // determining (possibly cutting) the name
149  // and displaying it in the GroupBox
150  OUString aString = CuiResId( RID_SVXSTR_TABLE ) + ": ";
151  INetURLObject aURL( m_pHatchingList->GetPath() );
152 
153  aURL.Append( m_pHatchingList->GetName() );
154  SAL_WARN_IF( aURL.GetProtocol() == INetProtocol::NotValid, "cui.tabpages", "invalid URL" );
155 
156  if ( aURL.getBase().getLength() > 18 )
157  {
158  aString += aURL.getBase().copy( 0, 15 ) + "...";
159  }
160  else
161  aString += aURL.getBase();
162 
163  sal_Int32 nPos = SearchHatchList( rSet.Get(XATTR_FILLHATCH).GetName() );
164  if( nPos != LISTBOX_ENTRY_NOTFOUND )
165  {
166  sal_uInt16 nId = m_xHatchLB->GetItemId( static_cast<size_t>( nPos ) );
167  m_xHatchLB->SelectItem( nId );
168  }
169  // colors could have been deleted
171  }
172 
174  m_rXFSet.Put( aBckItem );
175 
176  if (aBckItem.GetValue())
177  {
179  XFillColorItem aColorItem( rSet.Get(XATTR_FILLCOLOR) );
180  Color aColor(aColorItem.GetColorValue());
181  m_xLbBackgroundColor->SelectEntry(aColor);
182  m_xLbBackgroundColor->set_sensitive(true);
183  m_rXFSet.Put( aColorItem );
184  }
185  else
186  {
188  m_xLbBackgroundColor->SelectEntry(COL_AUTO);
189  m_xLbBackgroundColor->set_sensitive(false);
190  }
191 
192  m_aCtlPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
193  m_aCtlPreview.Invalidate();
194 }
195 
197 {
198  if( _pSet )
199  FillItemSet( _pSet );
200 
201  return DeactivateRC::LeavePage;
202 }
203 
204 sal_Int32 SvxHatchTabPage::SearchHatchList(const OUString& rHatchName)
205 {
206  long nCount = m_pHatchingList->Count();
207  bool bValidHatchName = true;
208  sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND;
209 
210  for(long i = 0;i < nCount && bValidHatchName;i++)
211  {
212  if(rHatchName == m_pHatchingList->GetHatch( i )->GetName())
213  {
214  nPos = i;
215  bValidHatchName = false;
216  }
217  }
218  return nPos;
219 }
220 
222 {
223  std::unique_ptr<XHatch> pXHatch;
224  OUString aString;
225  size_t nPos = m_xHatchLB->IsNoSelection() ? VALUESET_ITEM_NOTFOUND : m_xHatchLB->GetSelectItemPos();
226  if( nPos != VALUESET_ITEM_NOTFOUND )
227  {
228  pXHatch.reset(new XHatch( m_pHatchingList->GetHatch( static_cast<sal_uInt16>(nPos) )->GetHatch() ));
229  aString = m_xHatchLB->GetItemText( m_xHatchLB->GetSelectedItemId() );
230  }
231  // unidentified hatch has been passed
232  else
233  {
234  pXHatch.reset(new XHatch( m_xLbLineColor->GetSelectEntryColor(),
235  static_cast<css::drawing::HatchStyle>(m_xLbLineType->get_active()),
237  static_cast<long>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10) ));
238  }
239  assert( pXHatch && "XHatch couldn't be created" );
240  rSet->Put( XFillStyleItem( drawing::FillStyle_HATCH ) );
241  rSet->Put( XFillHatchItem( aString, *pXHatch ) );
242  rSet->Put( XFillBackgroundItem( m_xCbBackgroundColor->get_active() ) );
243  if (m_xCbBackgroundColor->get_active())
244  {
245  NamedColor aColor = m_xLbBackgroundColor->GetSelectedEntry();
246  rSet->Put(XFillColorItem(aColor.second, aColor.first));
247  }
248  return true;
249 }
250 
252 {
254 
255  XFillColorItem aColItem( rSet->Get(XATTR_FILLCOLOR) );
256  m_xLbBackgroundColor->SelectEntry(aColItem.GetColorValue());
257  m_rXFSet.Put( aColItem );
258 
259  XFillBackgroundItem aBckItem( rSet->Get(XATTR_FILLBACKGROUND) );
260  if(aBckItem.GetValue())
262  else
264  m_rXFSet.Put( aBckItem );
265 
266  m_aCtlPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
267  m_aCtlPreview.Invalidate();
268 }
269 
270 std::unique_ptr<SfxTabPage> SvxHatchTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
271  const SfxItemSet* rSet )
272 {
273  return std::make_unique<SvxHatchTabPage>(pPage, pController, *rSet);
274 }
275 
276 IMPL_LINK( SvxHatchTabPage, ModifiedListBoxHdl_Impl, weld::ComboBox&, rListBox, void )
277 {
278  ModifiedHdl_Impl(&rListBox);
279  // hatch params have changed, it is no longer one of the presets
280  m_xHatchLB->SetNoSelection();
281 }
282 
283 IMPL_LINK( SvxHatchTabPage, ModifiedColorListBoxHdl_Impl, ColorListBox&, rListBox, void )
284 {
285  ModifiedHdl_Impl(&rListBox);
286  m_xHatchLB->SetNoSelection();
287 }
288 
289 IMPL_LINK_NOARG( SvxHatchTabPage, ToggleHatchBackgroundColor_Impl, weld::ToggleButton&, void )
290 {
291  if (m_xCbBackgroundColor->get_active())
292  m_xLbBackgroundColor->set_sensitive(true);
293  else
294  m_xLbBackgroundColor->set_sensitive(false);
295  m_rXFSet.Put( XFillBackgroundItem( m_xCbBackgroundColor->get_active() ) );
296  ModifiedBackgroundHdl_Impl(*m_xLbBackgroundColor);
297 }
298 
299 IMPL_LINK_NOARG( SvxHatchTabPage, ModifiedBackgroundHdl_Impl, ColorListBox&, void )
300 {
301  Color aColor(COL_TRANSPARENT);
302  if (m_xCbBackgroundColor->get_active())
303  {
304  aColor = m_xLbBackgroundColor->GetSelectEntryColor();
305  m_aCtlPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
306  m_aCtlPreview.Invalidate();
307  }
308  m_rXFSet.Put(XFillColorItem( OUString(), aColor ));
309 
310  m_aCtlPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
311  m_aCtlPreview.Invalidate();
312 }
313 
314 IMPL_LINK( SvxHatchTabPage, ModifiedEditHdl_Impl, weld::MetricSpinButton&, rEdit, void )
315 {
316  ModifiedHdl_Impl(&rEdit);
317  m_xHatchLB->SetNoSelection();
318 }
319 
320 IMPL_LINK( SvxHatchTabPage, ModifiedSliderHdl_Impl, weld::Scale&, rSlider, void )
321 {
322  ModifiedHdl_Impl(&rSlider);
323  m_xHatchLB->SetNoSelection();
324 }
325 
326 void SvxHatchTabPage::ModifiedHdl_Impl( void const * p )
327 {
328  if (p == m_xMtrAngle.get())
329  m_xSliderAngle->set_value(m_xMtrAngle->get_value(FieldUnit::NONE));
330 
331  if (p == m_xSliderAngle.get())
332  m_xMtrAngle->set_value(m_xSliderAngle->get_value(), FieldUnit::NONE);
333 
334  XHatch aXHatch( m_xLbLineColor->GetSelectEntryColor(),
335  static_cast<css::drawing::HatchStyle>(m_xLbLineType->get_active()),
337  static_cast<long>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10) );
338 
339  m_rXFSet.Put( XFillHatchItem( OUString(), aXHatch ) );
340 
341  m_aCtlPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
342  m_aCtlPreview.Invalidate();
343 }
344 
346 {
347  ChangeHatchHdl_Impl();
348 }
349 
351 {
352  std::unique_ptr<XHatch> pHatch;
353  size_t nPos = m_xHatchLB->GetSelectItemPos();
354 
355  if( nPos != VALUESET_ITEM_NOTFOUND )
356  pHatch.reset(new XHatch( m_pHatchingList->GetHatch( static_cast<sal_uInt16>(nPos) )->GetHatch() ));
357  else
358  {
359  const SfxPoolItem* pPoolItem = nullptr;
360  if( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLSTYLE ), true, &pPoolItem ) )
361  {
362  if( ( drawing::FillStyle_HATCH == static_cast<const XFillStyleItem*>( pPoolItem )->GetValue() ) &&
363  ( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLHATCH ), true, &pPoolItem ) ) )
364  {
365  pHatch.reset(new XHatch( static_cast<const XFillHatchItem*>( pPoolItem )->GetHatchValue() ));
366  }
367  }
368  if( !pHatch )
369  {
370  sal_uInt16 nPosition = m_xHatchLB->GetItemId( 0 );
371  m_xHatchLB->SelectItem( nPosition );
372  if( nPosition != 0 )
373  pHatch.reset( new XHatch( m_pHatchingList->GetHatch( 0 )->GetHatch() ) );
374  }
375  }
376  if( pHatch )
377  {
378  m_xLbLineType->set_active(
379  sal::static_int_cast< sal_Int32 >( pHatch->GetHatchStyle() ) );
380  m_xLbLineColor->SetNoSelection();
381  m_xLbLineColor->SelectEntry( pHatch->GetColor() );
382  SetMetricValue( *m_xMtrDistance, pHatch->GetDistance(), m_ePoolUnit );
383  long nHatchAngle = pHatch->GetAngle() / 10;
384  m_xMtrAngle->set_value(nHatchAngle, FieldUnit::NONE);
385  m_xSliderAngle->set_value(nHatchAngle);
386 
387  // fill ItemSet and pass it on to m_aCtlPreview
388  m_rXFSet.Put( XFillHatchItem( OUString(), *pHatch ) );
389  m_aCtlPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
390 
391  m_aCtlPreview.Invalidate();
392  pHatch.reset();
393  }
394  m_xMtrDistance->save_value();
395  m_xMtrAngle->save_value();
396  m_xLbLineType->save_value();
397  m_xLbLineColor->SaveValue();
398  m_xLbBackgroundColor->SaveValue();
399 }
400 
401 IMPL_LINK_NOARG(SvxHatchTabPage, ClickAddHdl_Impl, weld::Button&, void)
402 {
403  OUString aNewName( SvxResId( RID_SVXSTR_HATCH ) );
404  OUString aDesc( CuiResId( RID_SVXSTR_DESC_HATCH ) );
405  OUString aName;
406 
407  long nCount = m_pHatchingList->Count();
408  long j = 1;
409  bool bValidHatchName = false;
410 
411  while( !bValidHatchName )
412  {
413  aName = aNewName + " " + OUString::number( j++ );
414  bValidHatchName = (SearchHatchList(aName) == LISTBOX_ENTRY_NOTFOUND);
415  }
416 
419  sal_uInt16 nError = 1;
420 
421  while( pDlg->Execute() == RET_OK )
422  {
423  pDlg->GetName( aName );
424 
425  bValidHatchName = (SearchHatchList(aName) == LISTBOX_ENTRY_NOTFOUND);
426  if( bValidHatchName )
427  {
428  nError = 0;
429  break;
430  }
431 
432  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui"));
433  std::unique_ptr<weld::MessageDialog> xWarnBox(xBuilder->weld_message_dialog("DuplicateNameDialog"));
434  if (xWarnBox->run() != RET_OK)
435  break;
436  }
437  pDlg.disposeAndClear();
438 
439  if( !nError )
440  {
441  XHatch aXHatch( m_xLbLineColor->GetSelectEntryColor(),
442  static_cast<css::drawing::HatchStyle>(m_xLbLineType->get_active()),
443  GetCoreValue( *m_xMtrDistance, m_ePoolUnit ),
444  static_cast<long>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10) );
445 
446  m_pHatchingList->Insert(std::make_unique<XHatchEntry>(aXHatch, aName), nCount);
447 
448  sal_Int32 nId = m_xHatchLB->GetItemId(nCount - 1); // calculate the last ID
449  BitmapEx aBitmap = m_pHatchingList->GetBitmapForPreview( nCount, m_xHatchLB->GetIconSize() );
450  // Insert the new entry at the next ID
451  m_xHatchLB->InsertItem( nId + 1, Image(aBitmap), aName );
452  m_xHatchLB->SelectItem( nId + 1 );
453  m_xHatchLB->Resize();
454 
455  *m_pnHatchingListState |= ChangeType::MODIFIED;
456 
457  ChangeHatchHdl_Impl();
458  }
459 }
460 
461 IMPL_LINK_NOARG(SvxHatchTabPage, ClickModifyHdl_Impl, weld::Button&, void)
462 {
463  sal_uInt16 nId = m_xHatchLB->GetSelectedItemId();
464  size_t nPos = m_xHatchLB->GetSelectItemPos();
465 
466  if( nPos != VALUESET_ITEM_NOTFOUND )
467  {
468  OUString aName( m_pHatchingList->GetHatch( static_cast<sal_uInt16>(nPos) )->GetName() );
469 
470  XHatch aXHatch( m_xLbLineColor->GetSelectEntryColor(),
471  static_cast<css::drawing::HatchStyle>(m_xLbLineType->get_active()),
472  GetCoreValue( *m_xMtrDistance, m_ePoolUnit ),
473  static_cast<long>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10) );
474 
475  m_pHatchingList->Replace(std::make_unique<XHatchEntry>(aXHatch, aName), nPos);
476 
477  BitmapEx aBitmap = m_pHatchingList->GetBitmapForPreview( static_cast<sal_uInt16>(nPos), m_xHatchLB->GetIconSize() );
478  m_xHatchLB->RemoveItem( nId );
479  m_xHatchLB->InsertItem( nId, Image(aBitmap), aName, static_cast<sal_uInt16>(nPos) );
480  m_xHatchLB->SelectItem( nId );
481 
482  // save values for changes recognition (-> method)
483  m_xMtrDistance->save_value();
484  m_xMtrAngle->save_value();
485  m_xLbLineType->save_value();
486  m_xLbLineColor->SaveValue();
487  m_xLbBackgroundColor->SaveValue();
488 
489  *m_pnHatchingListState |= ChangeType::MODIFIED;
490  }
491 }
492 
493 IMPL_LINK_NOARG(SvxHatchTabPage, ClickDeleteHdl_Impl, SvxPresetListBox*, void)
494 {
495  sal_uInt16 nId = m_xHatchLB->GetSelectedItemId();
496  size_t nPos = m_xHatchLB->GetSelectItemPos();
497 
498  if( nPos != VALUESET_ITEM_NOTFOUND )
499  {
500  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querydeletehatchdialog.ui"));
501  std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("AskDelHatchDialog"));
502  if (xQueryBox->run() == RET_YES)
503  {
504  m_pHatchingList->Remove(nPos);
505  m_xHatchLB->RemoveItem( nId );
506  nId = m_xHatchLB->GetItemId(0);
507  m_xHatchLB->SelectItem( nId );
508  m_xHatchLB->Resize();
509 
510  m_aCtlPreview.Invalidate();
511 
512  ChangeHatchHdl_Impl();
513 
514  *m_pnHatchingListState |= ChangeType::MODIFIED;
515  }
516  }
517 }
518 
519 IMPL_LINK_NOARG(SvxHatchTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void )
520 {
521  sal_uInt16 nId = m_xHatchLB->GetSelectedItemId();
522  size_t nPos = m_xHatchLB->GetSelectItemPos();
523 
524  if( nPos != VALUESET_ITEM_NOTFOUND )
525  {
526  OUString aDesc( CuiResId( RID_SVXSTR_DESC_HATCH ) );
527  OUString aName( m_pHatchingList->GetHatch( nPos )->GetName() );
528 
530  ScopedVclPtr<AbstractSvxNameDialog> pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc));
531 
532  bool bLoop = true;
533  while( bLoop && pDlg->Execute() == RET_OK )
534  {
535  pDlg->GetName( aName );
536  sal_Int32 nHatchPos = SearchHatchList( aName );
537  bool bValidHatchName = (nHatchPos == static_cast<sal_Int32>(nPos) ) || (nHatchPos == LISTBOX_ENTRY_NOTFOUND);
538 
539  if(bValidHatchName)
540  {
541  bLoop = false;
542  m_pHatchingList->GetHatch(nPos)->SetName(aName);
543 
544  m_xHatchLB->SetItemText(nId, aName);
545  m_xHatchLB->SelectItem( nId );
546 
547  *m_pnHatchingListState |= ChangeType::MODIFIED;
548  }
549  else
550  {
551  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui"));
552  std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog("DuplicateNameDialog"));
553  xBox->run();
554  }
555  }
556  }
557 
558 }
559 
560 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long Width() const
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
std::pair< Color, OUString > NamedColor
FieldUnit
#define XATTR_FILLHATCH
void ChangeHatchHdl_Impl()
Definition: tphatch.cxx:350
Size getDrawPreviewOptimalSize(const OutputDevice &rReference)
const XColorListRef & GetNewColorList() const
Definition: cuitabarea.hxx:124
std::string GetValue
std::unique_ptr< weld::Button > m_xBtnModify
Definition: cuitabarea.hxx:446
long Height() const
#define VALUESET_ITEM_NOTFOUND
static SvxAbstractDialogFactory * Create()
static const AllSettings & GetSettings()
sal_Int16 nId
constexpr DrawModeFlags OUTPUT_DRAWMODE_COLOR
TRISTATE_TRUE
#define LISTBOX_ENTRY_NOTFOUND
#define XATTR_FILLCOLOR
MapUnit m_ePoolUnit
Definition: cuitabarea.hxx:434
FieldUnit GetModuleFieldUnit(const SfxItemSet &rSet)
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
constexpr::Color COL_AUTO(0xFF, 0xFF, 0xFF, 0xFF)
std::unique_ptr< weld::CustomWeld > m_xCtlPreview
Definition: cuitabarea.hxx:448
virtual VclPtr< AbstractSvxNameDialog > CreateSvxNameDialog(weld::Window *pParent, const OUString &rName, const OUString &rDesc)=0
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
RET_YES
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: tphatch.cxx:132
std::unique_ptr< weld::CheckButton > m_xCbBackgroundColor
Definition: cuitabarea.hxx:442
OUString SvxResId(const char *pId)
virtual void Reset(const SfxItemSet *) override
Definition: tphatch.cxx:251
std::unique_ptr< weld::Button > m_xBtnAdd
Definition: cuitabarea.hxx:445
void SetExchangeSupport()
Size getPagePropertiesOptimalSize(const OutputDevice &rReference)
SfxItemSet & m_rXFSet
Definition: cuitabarea.hxx:432
IMPL_LINK_NOARG(SvxHatchTabPage, ToggleHatchBackgroundColor_Impl, weld::ToggleButton &, void)
Definition: tphatch.cxx:289
XColorListRef m_pColorList
Definition: cuitabarea.hxx:425
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
std::unique_ptr< ColorListBox > m_xLbBackgroundColor
Definition: cuitabarea.hxx:443
bool Append(OUString const &rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
std::unique_ptr< weld::Scale > m_xSliderAngle
Definition: cuitabarea.hxx:439
int i
const SfxItemSet & m_rOutAttrs
Definition: cuitabarea.hxx:423
TRISTATE_FALSE
int GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
virtual bool FillItemSet(SfxItemSet *) override
Definition: tphatch.cxx:221
const SfxItemSet * GetItemSet(const SfxPoolItem &rAttr)
void SetAttributes(const SfxItemSet &rItemSet)
SvxXRectPreview m_aCtlPreview
Definition: cuitabarea.hxx:436
#define XATTR_FILLSTYLE
ChangeType * m_pnColorListState
Definition: cuitabarea.hxx:429
void SetMetricValue(weld::MetricSpinButton &rField, int nCoreValue, MapUnit eUnit)
SfxItemPool * GetPool() const
OUString CuiResId(const char *pKey)
Definition: cuiresmgr.cxx:23
std::unique_ptr< weld::ComboBox > m_xLbLineType
Definition: cuitabarea.hxx:440
sal_Int32 SearchHatchList(const OUString &rHatchName)
Definition: tphatch.cxx:204
virtual ~SvxHatchTabPage() override
Definition: tphatch.cxx:118
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
XHatchListRef m_pHatchingList
Definition: cuitabarea.hxx:426
weld::Entry & rEdit
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
std::unique_ptr< ColorListBox > m_xLbLineColor
Definition: cuitabarea.hxx:441
IMPL_LINK(SvxHatchTabPage, ModifiedListBoxHdl_Impl, weld::ComboBox &, rListBox, void)
Definition: tphatch.cxx:276
#define SAL_WARN_IF(condition, area, stream)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
Definition: tphatch.cxx:270
std::unique_ptr< weld::MetricSpinButton > m_xMtrDistance
Definition: cuitabarea.hxx:437
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: tphatch.cxx:196
RET_OK
SfxOkDialogController * GetDialogController() const
void Construct()
Definition: tphatch.cxx:127
DeactivateRC
OString const aName
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile)
SvxHatchTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
Definition: tphatch.cxx:46
std::unique_ptr< SvxPresetListBox > m_xHatchLB
Definition: cuitabarea.hxx:444
void SetDrawMode(DrawModeFlags nDrawMode)
std::unique_ptr< weld::CustomWeld > m_xHatchLBWin
Definition: cuitabarea.hxx:447
std::unique_ptr< weld::MetricSpinButton > m_xMtrAngle
Definition: cuitabarea.hxx:438
void ModifiedHdl_Impl(void const *)
Definition: tphatch.cxx:326
sal_Int32 nPos
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
XFillAttrSetItem m_aXFillAttr
Definition: cuitabarea.hxx:431
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
#define XATTR_FILLBACKGROUND
constexpr DrawModeFlags OUTPUT_DRAWMODE_CONTRAST