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