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
, "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
))
66 Size aSize
= getPagePropertiesOptimalSize(m_xHatchLB
->GetDrawingArea()->get_ref_device());
67 m_xHatchLBWin
->set_size_request(aSize
.Width(), aSize
.Height());
69 aSize
= getDrawPreviewOptimalSize(m_aCtlPreview
.GetDrawingArea()->get_ref_device());
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_aCtlPreview
.SetDrawMode(Application::GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST
: OUTPUT_DRAWMODE_COLOR
);
118 SvxHatchTabPage::~SvxHatchTabPage()
120 m_xCtlPreview
.reset();
121 m_xHatchLBWin
.reset();
123 m_xLbBackgroundColor
.reset();
124 m_xLbLineColor
.reset();
127 void SvxHatchTabPage::Construct()
129 m_xHatchLB
->FillPresetListBox(*m_pHatchingList
);
132 void SvxHatchTabPage::ActivatePage( const SfxItemSet
& rSet
)
134 if( m_pColorList
.is() )
137 if( *m_pnColorListState
& ChangeType::CHANGED
||
138 *m_pnColorListState
& ChangeType::MODIFIED
)
140 SvxAreaTabDialog
* pArea
= (*m_pnColorListState
& ChangeType::CHANGED
) ?
141 dynamic_cast<SvxAreaTabDialog
*>(GetDialogController()) : nullptr;
143 m_pColorList
= pArea
->GetNewColorList();
145 ModifiedHdl_Impl( this );
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() );
153 aURL
.Append( m_pHatchingList
->GetName() );
154 SAL_WARN_IF( aURL
.GetProtocol() == INetProtocol::NotValid
, "cui.tabpages", "invalid URL" );
156 if ( aURL
.getBase().getLength() > 18 )
158 aString
+= aURL
.getBase().copy( 0, 15 ) + "...";
161 aString
+= aURL
.getBase();
163 sal_Int32 nPos
= SearchHatchList( rSet
.Get(XATTR_FILLHATCH
).GetName() );
164 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
166 sal_uInt16 nId
= m_xHatchLB
->GetItemId( static_cast<size_t>( nPos
) );
167 m_xHatchLB
->SelectItem( nId
);
169 // colors could have been deleted
170 ChangeHatchHdl_Impl();
173 XFillBackgroundItem
aBckItem( rSet
.Get(XATTR_FILLBACKGROUND
));
174 m_rXFSet
.Put( aBckItem
);
176 if (aBckItem
.GetValue())
178 m_xCbBackgroundColor
->set_state(TRISTATE_TRUE
);
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
);
187 m_xCbBackgroundColor
->set_state(TRISTATE_FALSE
);
188 m_xLbBackgroundColor
->SelectEntry(COL_AUTO
);
189 m_xLbBackgroundColor
->set_sensitive(false);
192 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
193 m_aCtlPreview
.Invalidate();
196 DeactivateRC
SvxHatchTabPage::DeactivatePage( SfxItemSet
* _pSet
)
199 FillItemSet( _pSet
);
201 return DeactivateRC::LeavePage
;
204 sal_Int32
SvxHatchTabPage::SearchHatchList(const OUString
& rHatchName
)
206 long nCount
= m_pHatchingList
->Count();
207 bool bValidHatchName
= true;
208 sal_Int32 nPos
= LISTBOX_ENTRY_NOTFOUND
;
210 for(long i
= 0;i
< nCount
&& bValidHatchName
;i
++)
212 if(rHatchName
== m_pHatchingList
->GetHatch( i
)->GetName())
215 bValidHatchName
= false;
221 bool SvxHatchTabPage::FillItemSet( SfxItemSet
* rSet
)
223 std::unique_ptr
<XHatch
> pXHatch
;
225 size_t nPos
= m_xHatchLB
->IsNoSelection() ? VALUESET_ITEM_NOTFOUND
: m_xHatchLB
->GetSelectItemPos();
226 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
228 pXHatch
.reset(new XHatch( m_pHatchingList
->GetHatch( static_cast<sal_uInt16
>(nPos
) )->GetHatch() ));
229 aString
= m_xHatchLB
->GetItemText( m_xHatchLB
->GetSelectedItemId() );
231 // unidentified hatch has been passed
234 pXHatch
.reset(new XHatch( m_xLbLineColor
->GetSelectEntryColor(),
235 static_cast<css::drawing::HatchStyle
>(m_xLbLineType
->get_active()),
236 GetCoreValue( *m_xMtrDistance
, m_ePoolUnit
),
237 static_cast<long>(m_xMtrAngle
->get_value(FieldUnit::NONE
) * 10) ));
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())
245 NamedColor aColor
= m_xLbBackgroundColor
->GetSelectedEntry();
246 rSet
->Put(XFillColorItem(aColor
.second
, aColor
.first
));
251 void SvxHatchTabPage::Reset( const SfxItemSet
* rSet
)
253 ChangeHatchHdl_Impl();
255 XFillColorItem
aColItem( rSet
->Get(XATTR_FILLCOLOR
) );
256 m_xLbBackgroundColor
->SelectEntry(aColItem
.GetColorValue());
257 m_rXFSet
.Put( aColItem
);
259 XFillBackgroundItem
aBckItem( rSet
->Get(XATTR_FILLBACKGROUND
) );
260 if(aBckItem
.GetValue())
261 m_xCbBackgroundColor
->set_state(TRISTATE_TRUE
);
263 m_xCbBackgroundColor
->set_state(TRISTATE_FALSE
);
264 m_rXFSet
.Put( aBckItem
);
266 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
267 m_aCtlPreview
.Invalidate();
270 std::unique_ptr
<SfxTabPage
> SvxHatchTabPage::Create( weld::Container
* pPage
, weld::DialogController
* pController
,
271 const SfxItemSet
* rSet
)
273 return std::make_unique
<SvxHatchTabPage
>(pPage
, pController
, *rSet
);
276 IMPL_LINK( SvxHatchTabPage
, ModifiedListBoxHdl_Impl
, weld::ComboBox
&, rListBox
, void )
278 ModifiedHdl_Impl(&rListBox
);
279 // hatch params have changed, it is no longer one of the presets
280 m_xHatchLB
->SetNoSelection();
283 IMPL_LINK( SvxHatchTabPage
, ModifiedColorListBoxHdl_Impl
, ColorListBox
&, rListBox
, void )
285 ModifiedHdl_Impl(&rListBox
);
286 m_xHatchLB
->SetNoSelection();
289 IMPL_LINK_NOARG( SvxHatchTabPage
, ToggleHatchBackgroundColor_Impl
, weld::ToggleButton
&, void )
291 if (m_xCbBackgroundColor
->get_active())
292 m_xLbBackgroundColor
->set_sensitive(true);
294 m_xLbBackgroundColor
->set_sensitive(false);
295 m_rXFSet
.Put( XFillBackgroundItem( m_xCbBackgroundColor
->get_active() ) );
296 ModifiedBackgroundHdl_Impl(*m_xLbBackgroundColor
);
299 IMPL_LINK_NOARG( SvxHatchTabPage
, ModifiedBackgroundHdl_Impl
, ColorListBox
&, void )
301 Color
aColor(COL_TRANSPARENT
);
302 if (m_xCbBackgroundColor
->get_active())
304 aColor
= m_xLbBackgroundColor
->GetSelectEntryColor();
305 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
306 m_aCtlPreview
.Invalidate();
308 m_rXFSet
.Put(XFillColorItem( OUString(), aColor
));
310 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
311 m_aCtlPreview
.Invalidate();
314 IMPL_LINK( SvxHatchTabPage
, ModifiedEditHdl_Impl
, weld::MetricSpinButton
&, rEdit
, void )
316 ModifiedHdl_Impl(&rEdit
);
317 m_xHatchLB
->SetNoSelection();
320 IMPL_LINK( SvxHatchTabPage
, ModifiedSliderHdl_Impl
, weld::Scale
&, rSlider
, void )
322 ModifiedHdl_Impl(&rSlider
);
323 m_xHatchLB
->SetNoSelection();
326 void SvxHatchTabPage::ModifiedHdl_Impl( void const * p
)
328 if (p
== m_xMtrAngle
.get())
329 m_xSliderAngle
->set_value(m_xMtrAngle
->get_value(FieldUnit::NONE
));
331 if (p
== m_xSliderAngle
.get())
332 m_xMtrAngle
->set_value(m_xSliderAngle
->get_value(), FieldUnit::NONE
);
334 XHatch
aXHatch( m_xLbLineColor
->GetSelectEntryColor(),
335 static_cast<css::drawing::HatchStyle
>(m_xLbLineType
->get_active()),
336 GetCoreValue( *m_xMtrDistance
, m_ePoolUnit
),
337 static_cast<long>(m_xMtrAngle
->get_value(FieldUnit::NONE
) * 10) );
339 m_rXFSet
.Put( XFillHatchItem( OUString(), aXHatch
) );
341 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
342 m_aCtlPreview
.Invalidate();
345 IMPL_LINK_NOARG(SvxHatchTabPage
, ChangeHatchHdl
, SvtValueSet
*, void)
347 ChangeHatchHdl_Impl();
350 void SvxHatchTabPage::ChangeHatchHdl_Impl()
352 std::unique_ptr
<XHatch
> pHatch
;
353 size_t nPos
= m_xHatchLB
->GetSelectItemPos();
355 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
356 pHatch
.reset(new XHatch( m_pHatchingList
->GetHatch( static_cast<sal_uInt16
>(nPos
) )->GetHatch() ));
359 const SfxPoolItem
* pPoolItem
= nullptr;
360 if( SfxItemState::SET
== m_rOutAttrs
.GetItemState( GetWhich( XATTR_FILLSTYLE
), true, &pPoolItem
) )
362 if( ( drawing::FillStyle_HATCH
== static_cast<const XFillStyleItem
*>( pPoolItem
)->GetValue() ) &&
363 ( SfxItemState::SET
== m_rOutAttrs
.GetItemState( GetWhich( XATTR_FILLHATCH
), true, &pPoolItem
) ) )
365 pHatch
.reset(new XHatch( static_cast<const XFillHatchItem
*>( pPoolItem
)->GetHatchValue() ));
370 sal_uInt16 nPosition
= m_xHatchLB
->GetItemId( 0 );
371 m_xHatchLB
->SelectItem( nPosition
);
373 pHatch
.reset( new XHatch( m_pHatchingList
->GetHatch( 0 )->GetHatch() ) );
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
);
387 // fill ItemSet and pass it on to m_aCtlPreview
388 m_rXFSet
.Put( XFillHatchItem( OUString(), *pHatch
) );
389 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
391 m_aCtlPreview
.Invalidate();
394 m_xMtrDistance
->save_value();
395 m_xMtrAngle
->save_value();
396 m_xLbLineType
->save_value();
397 m_xLbLineColor
->SaveValue();
398 m_xLbBackgroundColor
->SaveValue();
401 IMPL_LINK_NOARG(SvxHatchTabPage
, ClickAddHdl_Impl
, weld::Button
&, void)
403 OUString
aNewName( SvxResId( RID_SVXSTR_HATCH
) );
404 OUString
aDesc( CuiResId( RID_SVXSTR_DESC_HATCH
) );
407 long nCount
= m_pHatchingList
->Count();
409 bool bValidHatchName
= false;
411 while( !bValidHatchName
)
413 aName
= aNewName
+ " " + OUString::number( j
++ );
414 bValidHatchName
= (SearchHatchList(aName
) == LISTBOX_ENTRY_NOTFOUND
);
417 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
418 ScopedVclPtr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog(GetFrameWeld(), aName
, aDesc
));
419 sal_uInt16 nError
= 1;
421 while( pDlg
->Execute() == RET_OK
)
423 pDlg
->GetName( aName
);
425 bValidHatchName
= (SearchHatchList(aName
) == LISTBOX_ENTRY_NOTFOUND
);
426 if( bValidHatchName
)
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
)
437 pDlg
.disposeAndClear();
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) );
446 m_pHatchingList
->Insert(std::make_unique
<XHatchEntry
>(aXHatch
, aName
), nCount
);
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();
455 *m_pnHatchingListState
|= ChangeType::MODIFIED
;
457 ChangeHatchHdl_Impl();
461 IMPL_LINK_NOARG(SvxHatchTabPage
, ClickModifyHdl_Impl
, weld::Button
&, void)
463 sal_uInt16 nId
= m_xHatchLB
->GetSelectedItemId();
464 size_t nPos
= m_xHatchLB
->GetSelectItemPos();
466 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
468 OUString
aName( m_pHatchingList
->GetHatch( static_cast<sal_uInt16
>(nPos
) )->GetName() );
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) );
475 m_pHatchingList
->Replace(std::make_unique
<XHatchEntry
>(aXHatch
, aName
), nPos
);
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
);
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();
489 *m_pnHatchingListState
|= ChangeType::MODIFIED
;
493 IMPL_LINK_NOARG(SvxHatchTabPage
, ClickDeleteHdl_Impl
, SvxPresetListBox
*, void)
495 sal_uInt16 nId
= m_xHatchLB
->GetSelectedItemId();
496 size_t nPos
= m_xHatchLB
->GetSelectItemPos();
498 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
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
)
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();
510 m_aCtlPreview
.Invalidate();
512 ChangeHatchHdl_Impl();
514 *m_pnHatchingListState
|= ChangeType::MODIFIED
;
519 IMPL_LINK_NOARG(SvxHatchTabPage
, ClickRenameHdl_Impl
, SvxPresetListBox
*, void )
521 sal_uInt16 nId
= m_xHatchLB
->GetSelectedItemId();
522 size_t nPos
= m_xHatchLB
->GetSelectItemPos();
524 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
526 OUString
aDesc( CuiResId( RID_SVXSTR_DESC_HATCH
) );
527 OUString
aName( m_pHatchingList
->GetHatch( nPos
)->GetName() );
529 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
530 ScopedVclPtr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog(GetFrameWeld(), aName
, aDesc
));
533 while( bLoop
&& pDlg
->Execute() == RET_OK
)
535 pDlg
->GetName( aName
);
536 sal_Int32 nHatchPos
= SearchHatchList( aName
);
537 bool bValidHatchName
= (nHatchPos
== static_cast<sal_Int32
>(nPos
) ) || (nHatchPos
== LISTBOX_ENTRY_NOTFOUND
);
542 m_pHatchingList
->GetHatch(nPos
)->SetName(aName
);
544 m_xHatchLB
->SetItemText(nId
, aName
);
545 m_xHatchLB
->SelectItem( nId
);
547 *m_pnHatchingListState
|= ChangeType::MODIFIED
;
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"));
560 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */