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