1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
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>
44 using namespace com::sun::star
;
46 SvxHatchTabPage::SvxHatchTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rInAttrs
)
47 : SfxTabPage(pPage
, pController
, u
"cui/ui/hatchpage.ui"_ustr
, u
"HatchPage"_ustr
, &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(u
"distancemtr"_ustr
, FieldUnit::MM
))
54 , m_xMtrAngle(m_xBuilder
->weld_metric_spin_button(u
"anglemtr"_ustr
, FieldUnit::DEGREE
))
55 , m_xSliderAngle(m_xBuilder
->weld_scale(u
"angleslider"_ustr
))
56 , m_xLbLineType(m_xBuilder
->weld_combo_box(u
"linetypelb"_ustr
))
57 , m_xLbLineColor(new ColorListBox(m_xBuilder
->weld_menu_button(u
"linecolorlb"_ustr
),
58 [this]{ return GetDialogController()->getDialog(); }))
59 , m_xCbBackgroundColor(m_xBuilder
->weld_check_button(u
"backgroundcolor"_ustr
))
60 , m_xLbBackgroundColor(new ColorListBox(m_xBuilder
->weld_menu_button(u
"backgroundcolorlb"_ustr
),
61 [this]{ return GetDialogController()->getDialog(); }))
62 , m_xHatchLB(new SvxPresetListBox(m_xBuilder
->weld_scrolled_window(u
"hatchpresetlistwin"_ustr
, true)))
63 , m_xBtnAdd(m_xBuilder
->weld_button(u
"add"_ustr
))
64 , m_xBtnModify(m_xBuilder
->weld_button(u
"modify"_ustr
))
65 , m_xHatchLBWin(new weld::CustomWeld(*m_xBuilder
, u
"hatchpresetlist"_ustr
, *m_xHatchLB
))
66 , m_xCtlPreview(new weld::CustomWeld(*m_xBuilder
, u
"previewctl"_ustr
, m_aCtlPreview
))
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());
72 // this page needs ExchangeSupport
76 FieldUnit eFUnit
= GetModuleFieldUnit( rInAttrs
);
82 eFUnit
= FieldUnit::MM
;
84 default: ;//prevent warning
86 SetFieldUnit( *m_xMtrDistance
, eFUnit
);
89 SfxItemPool
* pPool
= m_rOutAttrs
.GetPool();
90 assert( pPool
&& "Where is the pool?" );
91 m_ePoolUnit
= pPool
->GetMetric( SID_ATTR_FILL_HATCH
);
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
) );
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
) );
112 m_xBtnAdd
->connect_clicked( LINK( this, SvxHatchTabPage
, ClickAddHdl_Impl
) );
113 m_xBtnModify
->connect_clicked( LINK( this, SvxHatchTabPage
, ClickModifyHdl_Impl
) );
115 m_xHatchLB
->SetStyle(WB_FLATVALUESET
| WB_NO_DIRECTSELECT
| WB_TABSTOP
);
117 m_aCtlPreview
.SetDrawMode(Application::GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST
: OUTPUT_DRAWMODE_COLOR
);
120 SvxHatchTabPage::~SvxHatchTabPage()
122 m_xCtlPreview
.reset();
123 m_xHatchLBWin
.reset();
125 m_xLbBackgroundColor
.reset();
126 m_xLbLineColor
.reset();
129 void SvxHatchTabPage::Construct()
131 m_xHatchLB
->FillPresetListBox(*m_pHatchingList
);
134 void SvxHatchTabPage::ActivatePage( const SfxItemSet
& rSet
)
136 if( m_pColorList
.is() )
139 if( *m_pnColorListState
& ChangeType::CHANGED
||
140 *m_pnColorListState
& ChangeType::MODIFIED
)
142 SvxAreaTabDialog
* pArea
= (*m_pnColorListState
& ChangeType::CHANGED
) ?
143 dynamic_cast<SvxAreaTabDialog
*>(GetDialogController()) : nullptr;
145 m_pColorList
= pArea
->GetNewColorList();
147 ModifiedHdl_Impl( this );
150 // determining (possibly cutting) the name
151 // and displaying it in the GroupBox
152 OUString aString
= CuiResId( RID_CUISTR_TABLE
) + ": ";
153 INetURLObject
aURL( m_pHatchingList
->GetPath() );
155 aURL
.Append( m_pHatchingList
->GetName() );
156 SAL_WARN_IF( aURL
.GetProtocol() == INetProtocol::NotValid
, "cui.tabpages", "invalid URL" );
158 if ( aURL
.getBase().getLength() > 18 )
160 aString
+= OUString::Concat(aURL
.getBase().subView( 0, 15 )) + "...";
163 aString
+= aURL
.getBase();
165 sal_Int32 nPos
= SearchHatchList( rSet
.Get(XATTR_FILLHATCH
).GetName() );
168 sal_uInt16 nId
= m_xHatchLB
->GetItemId( static_cast<size_t>( nPos
) );
169 m_xHatchLB
->SelectItem( nId
);
171 // colors could have been deleted
172 ChangeHatchHdl_Impl();
175 XFillBackgroundItem
aBckItem( rSet
.Get(XATTR_FILLBACKGROUND
));
176 m_rXFSet
.Put( aBckItem
);
178 if (aBckItem
.GetValue())
180 m_xCbBackgroundColor
->set_state(TRISTATE_TRUE
);
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
);
189 m_xCbBackgroundColor
->set_state(TRISTATE_FALSE
);
190 m_xLbBackgroundColor
->SelectEntry(COL_AUTO
);
191 m_xLbBackgroundColor
->set_sensitive(false);
194 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
195 m_aCtlPreview
.Invalidate();
198 DeactivateRC
SvxHatchTabPage::DeactivatePage( SfxItemSet
* _pSet
)
201 FillItemSet( _pSet
);
203 return DeactivateRC::LeavePage
;
206 sal_Int32
SvxHatchTabPage::SearchHatchList(std::u16string_view rHatchName
)
208 tools::Long nCount
= m_pHatchingList
->Count();
209 bool bValidHatchName
= true;
212 for(tools::Long i
= 0;i
< nCount
&& bValidHatchName
;i
++)
214 if(rHatchName
== m_pHatchingList
->GetHatch( i
)->GetName())
217 bValidHatchName
= false;
223 bool SvxHatchTabPage::FillItemSet( SfxItemSet
* rSet
)
225 std::unique_ptr
<XHatch
> pXHatch
;
227 size_t nPos
= m_xHatchLB
->IsNoSelection() ? VALUESET_ITEM_NOTFOUND
: m_xHatchLB
->GetSelectItemPos();
228 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
230 pXHatch
.reset(new XHatch( m_pHatchingList
->GetHatch( static_cast<sal_uInt16
>(nPos
) )->GetHatch() ));
231 aString
= m_xHatchLB
->GetItemText( m_xHatchLB
->GetSelectedItemId() );
233 // unidentified hatch has been passed
236 pXHatch
.reset(new XHatch( m_xLbLineColor
->GetSelectEntryColor(),
237 static_cast<css::drawing::HatchStyle
>(m_xLbLineType
->get_active()),
238 GetCoreValue( *m_xMtrDistance
, m_ePoolUnit
),
239 Degree10(static_cast<sal_Int16
>(m_xMtrAngle
->get_value(FieldUnit::NONE
) * 10)) ));
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())
247 NamedColor aColor
= m_xLbBackgroundColor
->GetSelectedEntry();
248 rSet
->Put(XFillColorItem(aColor
.m_aName
, aColor
.m_aColor
));
253 void SvxHatchTabPage::Reset( const SfxItemSet
* rSet
)
255 ChangeHatchHdl_Impl();
257 XFillColorItem
aColItem( rSet
->Get(XATTR_FILLCOLOR
) );
258 m_xLbBackgroundColor
->SelectEntry(aColItem
.GetColorValue());
259 m_rXFSet
.Put( aColItem
);
261 XFillBackgroundItem
aBckItem( rSet
->Get(XATTR_FILLBACKGROUND
) );
262 if(aBckItem
.GetValue())
263 m_xCbBackgroundColor
->set_state(TRISTATE_TRUE
);
265 m_xCbBackgroundColor
->set_state(TRISTATE_FALSE
);
266 m_rXFSet
.Put( aBckItem
);
268 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
269 m_aCtlPreview
.Invalidate();
272 std::unique_ptr
<SfxTabPage
> SvxHatchTabPage::Create( weld::Container
* pPage
, weld::DialogController
* pController
,
273 const SfxItemSet
* rSet
)
275 return std::make_unique
<SvxHatchTabPage
>(pPage
, pController
, *rSet
);
278 IMPL_LINK( SvxHatchTabPage
, ModifiedListBoxHdl_Impl
, weld::ComboBox
&, rListBox
, void )
280 ModifiedHdl_Impl(&rListBox
);
281 // hatch params have changed, it is no longer one of the presets
282 m_xHatchLB
->SetNoSelection();
285 IMPL_LINK( SvxHatchTabPage
, ModifiedColorListBoxHdl_Impl
, ColorListBox
&, rListBox
, void )
287 ModifiedHdl_Impl(&rListBox
);
288 m_xHatchLB
->SetNoSelection();
291 IMPL_LINK_NOARG( SvxHatchTabPage
, ToggleHatchBackgroundColor_Impl
, weld::Toggleable
&, void )
293 if (m_xCbBackgroundColor
->get_active())
294 m_xLbBackgroundColor
->set_sensitive(true);
296 m_xLbBackgroundColor
->set_sensitive(false);
297 m_rXFSet
.Put( XFillBackgroundItem( m_xCbBackgroundColor
->get_active() ) );
298 ModifiedBackgroundHdl_Impl(*m_xLbBackgroundColor
);
301 IMPL_LINK_NOARG( SvxHatchTabPage
, ModifiedBackgroundHdl_Impl
, ColorListBox
&, void )
303 Color
aColor(COL_TRANSPARENT
);
304 if (m_xCbBackgroundColor
->get_active())
306 aColor
= m_xLbBackgroundColor
->GetSelectEntryColor();
307 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
308 m_aCtlPreview
.Invalidate();
310 m_rXFSet
.Put(XFillColorItem( OUString(), aColor
));
312 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
313 m_aCtlPreview
.Invalidate();
316 IMPL_LINK( SvxHatchTabPage
, ModifiedEditHdl_Impl
, weld::MetricSpinButton
&, rEdit
, void )
318 ModifiedHdl_Impl(&rEdit
);
319 m_xHatchLB
->SetNoSelection();
322 IMPL_LINK( SvxHatchTabPage
, ModifiedSliderHdl_Impl
, weld::Scale
&, rSlider
, void )
324 ModifiedHdl_Impl(&rSlider
);
325 m_xHatchLB
->SetNoSelection();
328 void SvxHatchTabPage::ModifiedHdl_Impl( void const * p
)
330 if (p
== m_xMtrAngle
.get())
331 m_xSliderAngle
->set_value(m_xMtrAngle
->get_value(FieldUnit::NONE
));
333 if (p
== m_xSliderAngle
.get())
334 m_xMtrAngle
->set_value(m_xSliderAngle
->get_value(), FieldUnit::NONE
);
336 XHatch
aXHatch( m_xLbLineColor
->GetSelectEntryColor(),
337 static_cast<css::drawing::HatchStyle
>(m_xLbLineType
->get_active()),
338 GetCoreValue( *m_xMtrDistance
, m_ePoolUnit
),
339 Degree10(static_cast<sal_Int16
>(m_xMtrAngle
->get_value(FieldUnit::NONE
) * 10)) );
341 m_rXFSet
.Put( XFillHatchItem( OUString(), aXHatch
) );
343 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
344 m_aCtlPreview
.Invalidate();
347 IMPL_LINK_NOARG(SvxHatchTabPage
, ChangeHatchHdl
, ValueSet
*, void)
349 ChangeHatchHdl_Impl();
352 void SvxHatchTabPage::ChangeHatchHdl_Impl()
354 std::unique_ptr
<XHatch
> pHatch
;
355 size_t nPos
= m_xHatchLB
->GetSelectItemPos();
357 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
358 pHatch
.reset(new XHatch( m_pHatchingList
->GetHatch( static_cast<sal_uInt16
>(nPos
) )->GetHatch() ));
361 if( const XFillStyleItem
* pFillStyleItem
= m_rOutAttrs
.GetItemIfSet( GetWhich( XATTR_FILLSTYLE
) ) )
363 const XFillHatchItem
* pFillHatchItem
;
364 if( ( drawing::FillStyle_HATCH
== pFillStyleItem
->GetValue() ) &&
365 ( pFillHatchItem
= m_rOutAttrs
.GetItemIfSet( GetWhich( XATTR_FILLHATCH
) ) ) )
367 pHatch
.reset(new XHatch( pFillHatchItem
->GetHatchValue() ));
372 sal_uInt16 nPosition
= m_xHatchLB
->GetItemId( 0 );
373 m_xHatchLB
->SelectItem( nPosition
);
375 pHatch
.reset( new XHatch( m_pHatchingList
->GetHatch( 0 )->GetHatch() ) );
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
);
389 // fill ItemSet and pass it on to m_aCtlPreview
390 m_rXFSet
.Put( XFillHatchItem( OUString(), *pHatch
) );
391 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
393 m_aCtlPreview
.Invalidate();
396 m_xMtrDistance
->save_value();
397 m_xMtrAngle
->save_value();
398 m_xLbLineType
->save_value();
399 m_xLbLineColor
->SaveValue();
400 m_xLbBackgroundColor
->SaveValue();
403 IMPL_LINK_NOARG(SvxHatchTabPage
, ClickAddHdl_Impl
, weld::Button
&, void)
405 OUString
aNewName( SvxResId( RID_SVXSTR_HATCH
) );
406 OUString
aDesc( CuiResId( RID_CUISTR_DESC_HATCH
) );
409 tools::Long nCount
= m_pHatchingList
->Count();
411 bool bValidHatchName
= false;
413 while( !bValidHatchName
)
415 aName
= aNewName
+ " " + OUString::number( j
++ );
416 bValidHatchName
= (SearchHatchList(aName
) == -1);
419 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
420 ScopedVclPtr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog(GetFrameWeld(), aName
, aDesc
));
421 sal_uInt16 nError
= 1;
423 while( pDlg
->Execute() == RET_OK
)
425 aName
= pDlg
->GetName();
427 bValidHatchName
= (SearchHatchList(aName
) == -1);
428 if( bValidHatchName
)
434 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(GetFrameWeld(), u
"cui/ui/queryduplicatedialog.ui"_ustr
));
435 std::unique_ptr
<weld::MessageDialog
> xWarnBox(xBuilder
->weld_message_dialog(u
"DuplicateNameDialog"_ustr
));
436 if (xWarnBox
->run() != RET_OK
)
439 pDlg
.disposeAndClear();
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)) );
449 m_pHatchingList
->Insert(std::make_unique
<XHatchEntry
>(aXHatch
, aName
), nCount
);
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();
458 *m_pnHatchingListState
|= ChangeType::MODIFIED
;
460 ChangeHatchHdl_Impl();
463 IMPL_LINK_NOARG(SvxHatchTabPage
, ClickModifyHdl_Impl
, weld::Button
&, void)
465 sal_uInt16 nId
= m_xHatchLB
->GetSelectedItemId();
466 size_t nPos
= m_xHatchLB
->GetSelectItemPos();
468 if( nPos
== VALUESET_ITEM_NOTFOUND
)
471 OUString
aName( m_pHatchingList
->GetHatch( static_cast<sal_uInt16
>(nPos
) )->GetName() );
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)) );
478 m_pHatchingList
->Replace(std::make_unique
<XHatchEntry
>(aXHatch
, aName
), nPos
);
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
);
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();
492 *m_pnHatchingListState
|= ChangeType::MODIFIED
;
495 IMPL_LINK_NOARG(SvxHatchTabPage
, ClickDeleteHdl_Impl
, SvxPresetListBox
*, void)
497 sal_uInt16 nId
= m_xHatchLB
->GetSelectedItemId();
498 size_t nPos
= m_xHatchLB
->GetSelectItemPos();
500 if( nPos
== VALUESET_ITEM_NOTFOUND
)
503 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(GetFrameWeld(), u
"cui/ui/querydeletehatchdialog.ui"_ustr
));
504 std::unique_ptr
<weld::MessageDialog
> xQueryBox(xBuilder
->weld_message_dialog(u
"AskDelHatchDialog"_ustr
));
505 if (xQueryBox
->run() != RET_YES
)
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();
514 m_aCtlPreview
.Invalidate();
516 ChangeHatchHdl_Impl();
518 *m_pnHatchingListState
|= ChangeType::MODIFIED
;
521 IMPL_LINK_NOARG(SvxHatchTabPage
, ClickRenameHdl_Impl
, SvxPresetListBox
*, void )
523 sal_uInt16 nId
= m_xHatchLB
->GetSelectedItemId();
524 size_t nPos
= m_xHatchLB
->GetSelectItemPos();
526 if( nPos
== VALUESET_ITEM_NOTFOUND
)
529 OUString
aDesc( CuiResId( RID_CUISTR_DESC_HATCH
) );
530 OUString
aName( m_pHatchingList
->GetHatch( nPos
)->GetName() );
532 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
533 ScopedVclPtr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog(GetFrameWeld(), aName
, aDesc
));
536 while( bLoop
&& pDlg
->Execute() == RET_OK
)
538 aName
= pDlg
->GetName();
539 sal_Int32 nHatchPos
= SearchHatchList( aName
);
540 bool bValidHatchName
= (nHatchPos
== static_cast<sal_Int32
>(nPos
) ) || (nHatchPos
== -1);
545 m_pHatchingList
->GetHatch(nPos
)->SetName(aName
);
547 m_xHatchLB
->SetItemText(nId
, aName
);
548 m_xHatchLB
->SelectItem( nId
);
550 *m_pnHatchingListState
|= ChangeType::MODIFIED
;
554 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(GetFrameWeld(), u
"cui/ui/queryduplicatedialog.ui"_ustr
));
555 std::unique_ptr
<weld::MessageDialog
> xBox(xBuilder
->weld_message_dialog(u
"DuplicateNameDialog"_ustr
));
562 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */