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 <unotools/pathoptions.hxx>
26 #include <sfx2/app.hxx>
27 #include <sfx2/dialoghelper.hxx>
28 #include <sfx2/filedlghelper.hxx>
29 #include <sfx2/module.hxx>
30 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
32 #include <strings.hrc>
33 #include <svx/xflhtit.hxx>
34 #include <svx/xflclit.hxx>
35 #include <svx/colorbox.hxx>
36 #include <svx/xpool.hxx>
37 #include <svx/xtable.hxx>
38 #include <svx/drawitem.hxx>
39 #include <svx/xflbckit.hxx>
40 #include <cuitabarea.hxx>
41 #include <defdlgname.hxx>
42 #include <dlgname.hxx>
43 #include <svx/svxdlg.hxx>
44 #include <dialmgr.hxx>
45 #include <svx/dlgutil.hxx>
46 #include <svx/dialmgr.hxx>
47 #include <svx/dialogs.hrc>
48 #include <svx/strings.hrc>
49 #include <svx/svxids.hrc>
50 #include <sal/log.hxx>
51 #include <svtools/unitconv.hxx>
53 using namespace com::sun::star
;
55 SvxHatchTabPage::SvxHatchTabPage(TabPageParent pParent
, const SfxItemSet
& rInAttrs
)
56 : SfxTabPage(pParent
, "cui/ui/hatchpage.ui", "HatchPage", &rInAttrs
)
57 , m_rOutAttrs(rInAttrs
)
58 , m_pnHatchingListState(nullptr)
59 , m_pnColorListState(nullptr)
60 , m_aXFillAttr(rInAttrs
.GetPool())
61 , m_rXFSet(m_aXFillAttr
.GetItemSet())
62 , m_xMtrDistance(m_xBuilder
->weld_metric_spin_button("distancemtr", FieldUnit::MM
))
63 , m_xMtrAngle(m_xBuilder
->weld_metric_spin_button("anglemtr", FieldUnit::DEGREE
))
64 , m_xSliderAngle(m_xBuilder
->weld_scale("angleslider"))
65 , m_xLbLineType(m_xBuilder
->weld_combo_box("linetypelb"))
66 , m_xLbLineColor(new ColorListBox(m_xBuilder
->weld_menu_button("linecolorlb"), pParent
.GetFrameWeld()))
67 , m_xCbBackgroundColor(m_xBuilder
->weld_check_button("backgroundcolor"))
68 , m_xLbBackgroundColor(new ColorListBox(m_xBuilder
->weld_menu_button("backgroundcolorlb"), pParent
.GetFrameWeld()))
69 , m_xHatchLB(new SvxPresetListBox(m_xBuilder
->weld_scrolled_window("hatchpresetlistwin")))
70 , m_xBtnAdd(m_xBuilder
->weld_button("add"))
71 , m_xBtnModify(m_xBuilder
->weld_button("modify"))
72 , m_xHatchLBWin(new weld::CustomWeld(*m_xBuilder
, "hatchpresetlist", *m_xHatchLB
))
73 , m_xCtlPreview(new weld::CustomWeld(*m_xBuilder
, "previewctl", m_aCtlPreview
))
75 Size aSize
= getDrawPreviewOptimalSize(this);
76 m_xHatchLBWin
->set_size_request(aSize
.Width(), aSize
.Height());
77 m_xCtlPreview
->set_size_request(aSize
.Width(), aSize
.Height());
79 // this page needs ExchangeSupport
83 FieldUnit eFUnit
= GetModuleFieldUnit( rInAttrs
);
89 eFUnit
= FieldUnit::MM
;
91 default: ;//prevent warning
93 SetFieldUnit( *m_xMtrDistance
, eFUnit
);
96 SfxItemPool
* pPool
= m_rOutAttrs
.GetPool();
97 assert( pPool
&& "Where is the pool?" );
98 m_ePoolUnit
= pPool
->GetMetric( SID_ATTR_FILL_HATCH
);
100 // setting the output device
101 m_rXFSet
.Put( XFillStyleItem(drawing::FillStyle_HATCH
) );
102 m_rXFSet
.Put( XFillHatchItem(OUString(), XHatch()) );
103 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
104 m_xHatchLB
->SetSelectHdl( LINK( this, SvxHatchTabPage
, ChangeHatchHdl
) );
105 m_xHatchLB
->SetRenameHdl( LINK( this, SvxHatchTabPage
, ClickRenameHdl_Impl
) );
106 m_xHatchLB
->SetDeleteHdl( LINK( this, SvxHatchTabPage
, ClickDeleteHdl_Impl
) );
108 Link
<weld::MetricSpinButton
&,void> aLink
= LINK( this, SvxHatchTabPage
, ModifiedEditHdl_Impl
);
109 Link
<weld::ComboBox
&,void> aLink2
= LINK( this, SvxHatchTabPage
, ModifiedListBoxHdl_Impl
);
110 m_xMtrDistance
->connect_value_changed( aLink
);
111 m_xMtrAngle
->connect_value_changed( aLink
);
112 m_xSliderAngle
->connect_value_changed(LINK(this, SvxHatchTabPage
, ModifiedSliderHdl_Impl
));
113 m_xLbLineType
->connect_changed( aLink2
);
114 Link
<ColorListBox
&,void> aLink3
= LINK( this, SvxHatchTabPage
, ModifiedColorListBoxHdl_Impl
);
115 m_xLbLineColor
->SetSelectHdl( aLink3
);
116 m_xCbBackgroundColor
->connect_toggled( LINK( this, SvxHatchTabPage
, ToggleHatchBackgroundColor_Impl
) );
117 m_xLbBackgroundColor
->SetSelectHdl( LINK( this, SvxHatchTabPage
, ModifiedBackgroundHdl_Impl
) );
119 m_xBtnAdd
->connect_clicked( LINK( this, SvxHatchTabPage
, ClickAddHdl_Impl
) );
120 m_xBtnModify
->connect_clicked( LINK( this, SvxHatchTabPage
, ClickModifyHdl_Impl
) );
122 m_aCtlPreview
.SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST
: OUTPUT_DRAWMODE_COLOR
);
125 SvxHatchTabPage::~SvxHatchTabPage()
130 void SvxHatchTabPage::dispose()
132 m_xCtlPreview
.reset();
133 m_xHatchLBWin
.reset();
135 m_xLbBackgroundColor
.reset();
136 m_xLbLineColor
.reset();
137 SfxTabPage::dispose();
140 void SvxHatchTabPage::Construct()
142 m_xHatchLB
->FillPresetListBox(*m_pHatchingList
);
145 void SvxHatchTabPage::ActivatePage( const SfxItemSet
& rSet
)
147 if( m_pColorList
.is() )
150 if( *m_pnColorListState
& ChangeType::CHANGED
||
151 *m_pnColorListState
& ChangeType::MODIFIED
)
153 SvxAreaTabDialog
* pArea
= (*m_pnColorListState
& ChangeType::CHANGED
) ?
154 dynamic_cast<SvxAreaTabDialog
*>(GetParentDialog()) : nullptr;
156 m_pColorList
= pArea
->GetNewColorList();
158 ModifiedHdl_Impl( this );
161 // determining (possibly cutting) the name
162 // and displaying it in the GroupBox
163 OUString
aString( CuiResId( RID_SVXSTR_TABLE
) );
165 INetURLObject
aURL( m_pHatchingList
->GetPath() );
167 aURL
.Append( m_pHatchingList
->GetName() );
168 SAL_WARN_IF( aURL
.GetProtocol() == INetProtocol::NotValid
, "cui.tabpages", "invalid URL" );
170 if ( aURL
.getBase().getLength() > 18 )
172 aString
+= aURL
.getBase().copy( 0, 15 ) + "...";
175 aString
+= aURL
.getBase();
177 sal_Int32 nPos
= SearchHatchList( rSet
.Get(XATTR_FILLHATCH
).GetName() );
178 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
180 sal_uInt16 nId
= m_xHatchLB
->GetItemId( static_cast<size_t>( nPos
) );
181 m_xHatchLB
->SelectItem( nId
);
183 // colors could have been deleted
184 ChangeHatchHdl_Impl();
187 XFillBackgroundItem
aBckItem( rSet
.Get(XATTR_FILLBACKGROUND
));
188 m_rXFSet
.Put( aBckItem
);
190 if (aBckItem
.GetValue())
192 m_xCbBackgroundColor
->set_state(TRISTATE_TRUE
);
193 XFillColorItem
aColorItem( rSet
.Get(XATTR_FILLCOLOR
) );
194 Color
aColor(aColorItem
.GetColorValue());
195 m_xLbBackgroundColor
->SelectEntry(aColor
);
196 m_xLbBackgroundColor
->set_sensitive(true);
197 m_rXFSet
.Put( aColorItem
);
201 m_xCbBackgroundColor
->set_state(TRISTATE_FALSE
);
202 m_xLbBackgroundColor
->SelectEntry(COL_AUTO
);
203 m_xLbBackgroundColor
->set_sensitive(false);
206 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
207 m_aCtlPreview
.Invalidate();
210 DeactivateRC
SvxHatchTabPage::DeactivatePage( SfxItemSet
* _pSet
)
213 FillItemSet( _pSet
);
215 return DeactivateRC::LeavePage
;
218 sal_Int32
SvxHatchTabPage::SearchHatchList(const OUString
& rHatchName
)
220 long nCount
= m_pHatchingList
->Count();
221 bool bValidHatchName
= true;
222 sal_Int32 nPos
= LISTBOX_ENTRY_NOTFOUND
;
224 for(long i
= 0;i
< nCount
&& bValidHatchName
;i
++)
226 if(rHatchName
== m_pHatchingList
->GetHatch( i
)->GetName())
229 bValidHatchName
= false;
235 bool SvxHatchTabPage::FillItemSet( SfxItemSet
* rSet
)
237 std::unique_ptr
<XHatch
> pXHatch
;
239 size_t nPos
= m_xHatchLB
->IsNoSelection() ? VALUESET_ITEM_NOTFOUND
: m_xHatchLB
->GetSelectItemPos();
240 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
242 pXHatch
.reset(new XHatch( m_pHatchingList
->GetHatch( static_cast<sal_uInt16
>(nPos
) )->GetHatch() ));
243 aString
= m_xHatchLB
->GetItemText( m_xHatchLB
->GetSelectedItemId() );
245 // unidentified hatch has been passed
248 pXHatch
.reset(new XHatch( m_xLbLineColor
->GetSelectEntryColor(),
249 static_cast<css::drawing::HatchStyle
>(m_xLbLineType
->get_active()),
250 GetCoreValue( *m_xMtrDistance
, m_ePoolUnit
),
251 static_cast<long>(m_xMtrAngle
->get_value(FieldUnit::NONE
) * 10) ));
253 assert( pXHatch
&& "XHatch couldn't be created" );
254 rSet
->Put( XFillStyleItem( drawing::FillStyle_HATCH
) );
255 rSet
->Put( XFillHatchItem( aString
, *pXHatch
) );
256 rSet
->Put( XFillBackgroundItem( m_xCbBackgroundColor
->get_active() ) );
257 if (m_xCbBackgroundColor
->get_active())
259 NamedColor aColor
= m_xLbBackgroundColor
->GetSelectedEntry();
260 rSet
->Put(XFillColorItem(aColor
.second
, aColor
.first
));
265 void SvxHatchTabPage::Reset( const SfxItemSet
* rSet
)
267 ChangeHatchHdl_Impl();
269 XFillColorItem
aColItem( rSet
->Get(XATTR_FILLCOLOR
) );
270 m_xLbBackgroundColor
->SelectEntry(aColItem
.GetColorValue());
271 m_rXFSet
.Put( aColItem
);
273 XFillBackgroundItem
aBckItem( rSet
->Get(XATTR_FILLBACKGROUND
) );
274 if(aBckItem
.GetValue())
275 m_xCbBackgroundColor
->set_state(TRISTATE_TRUE
);
277 m_xCbBackgroundColor
->set_state(TRISTATE_FALSE
);
278 m_rXFSet
.Put( aBckItem
);
280 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
281 m_aCtlPreview
.Invalidate();
284 VclPtr
<SfxTabPage
> SvxHatchTabPage::Create( TabPageParent pWindow
,
285 const SfxItemSet
* rSet
)
287 return VclPtr
<SvxHatchTabPage
>::Create(pWindow
, *rSet
);
290 IMPL_LINK( SvxHatchTabPage
, ModifiedListBoxHdl_Impl
, weld::ComboBox
&, rListBox
, void )
292 ModifiedHdl_Impl(&rListBox
);
293 // hatch params have changed, it is no longer one of the presets
294 m_xHatchLB
->SetNoSelection();
297 IMPL_LINK( SvxHatchTabPage
, ModifiedColorListBoxHdl_Impl
, ColorListBox
&, rListBox
, void )
299 ModifiedHdl_Impl(&rListBox
);
300 m_xHatchLB
->SetNoSelection();
303 IMPL_LINK_NOARG( SvxHatchTabPage
, ToggleHatchBackgroundColor_Impl
, weld::ToggleButton
&, void )
305 if (m_xCbBackgroundColor
->get_active())
306 m_xLbBackgroundColor
->set_sensitive(true);
308 m_xLbBackgroundColor
->set_sensitive(false);
309 m_rXFSet
.Put( XFillBackgroundItem( m_xCbBackgroundColor
->get_active() ) );
310 ModifiedBackgroundHdl_Impl(*m_xLbBackgroundColor
);
313 IMPL_LINK_NOARG( SvxHatchTabPage
, ModifiedBackgroundHdl_Impl
, ColorListBox
&, void )
315 Color
aColor(COL_TRANSPARENT
);
316 if (m_xCbBackgroundColor
->get_active())
318 aColor
= m_xLbBackgroundColor
->GetSelectEntryColor();
319 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
320 m_aCtlPreview
.Invalidate();
322 m_rXFSet
.Put(XFillColorItem( OUString(), aColor
));
324 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
325 m_aCtlPreview
.Invalidate();
328 IMPL_LINK( SvxHatchTabPage
, ModifiedEditHdl_Impl
, weld::MetricSpinButton
&, rEdit
, void )
330 ModifiedHdl_Impl(&rEdit
);
331 m_xHatchLB
->SetNoSelection();
334 IMPL_LINK( SvxHatchTabPage
, ModifiedSliderHdl_Impl
, weld::Scale
&, rSlider
, void )
336 ModifiedHdl_Impl(&rSlider
);
337 m_xHatchLB
->SetNoSelection();
340 void SvxHatchTabPage::ModifiedHdl_Impl( void const * p
)
342 if (p
== m_xMtrAngle
.get())
343 m_xSliderAngle
->set_value(m_xMtrAngle
->get_value(FieldUnit::NONE
));
345 if (p
== m_xSliderAngle
.get())
346 m_xMtrAngle
->set_value(m_xSliderAngle
->get_value(), FieldUnit::NONE
);
348 XHatch
aXHatch( m_xLbLineColor
->GetSelectEntryColor(),
349 static_cast<css::drawing::HatchStyle
>(m_xLbLineType
->get_active()),
350 GetCoreValue( *m_xMtrDistance
, m_ePoolUnit
),
351 static_cast<long>(m_xMtrAngle
->get_value(FieldUnit::NONE
) * 10) );
353 m_rXFSet
.Put( XFillHatchItem( OUString(), aXHatch
) );
355 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
356 m_aCtlPreview
.Invalidate();
359 IMPL_LINK_NOARG(SvxHatchTabPage
, ChangeHatchHdl
, SvtValueSet
*, void)
361 ChangeHatchHdl_Impl();
364 void SvxHatchTabPage::ChangeHatchHdl_Impl()
366 std::unique_ptr
<XHatch
> pHatch
;
367 size_t nPos
= m_xHatchLB
->GetSelectItemPos();
369 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
370 pHatch
.reset(new XHatch( m_pHatchingList
->GetHatch( static_cast<sal_uInt16
>(nPos
) )->GetHatch() ));
373 const SfxPoolItem
* pPoolItem
= nullptr;
374 if( SfxItemState::SET
== m_rOutAttrs
.GetItemState( GetWhich( XATTR_FILLSTYLE
), true, &pPoolItem
) )
376 if( ( drawing::FillStyle_HATCH
== static_cast<const XFillStyleItem
*>( pPoolItem
)->GetValue() ) &&
377 ( SfxItemState::SET
== m_rOutAttrs
.GetItemState( GetWhich( XATTR_FILLHATCH
), true, &pPoolItem
) ) )
379 pHatch
.reset(new XHatch( static_cast<const XFillHatchItem
*>( pPoolItem
)->GetHatchValue() ));
384 sal_uInt16 nPosition
= m_xHatchLB
->GetItemId( 0 );
385 m_xHatchLB
->SelectItem( nPosition
);
387 pHatch
.reset( new XHatch( m_pHatchingList
->GetHatch( 0 )->GetHatch() ) );
392 m_xLbLineType
->set_active(
393 sal::static_int_cast
< sal_Int32
>( pHatch
->GetHatchStyle() ) );
394 m_xLbLineColor
->SetNoSelection();
395 m_xLbLineColor
->SelectEntry( pHatch
->GetColor() );
396 SetMetricValue( *m_xMtrDistance
, pHatch
->GetDistance(), m_ePoolUnit
);
397 long nHatchAngle
= pHatch
->GetAngle() / 10;
398 m_xMtrAngle
->set_value(nHatchAngle
, FieldUnit::NONE
);
399 m_xSliderAngle
->set_value(nHatchAngle
);
401 // fill ItemSet and pass it on to m_aCtlPreview
402 m_rXFSet
.Put( XFillHatchItem( OUString(), *pHatch
) );
403 m_aCtlPreview
.SetAttributes( m_aXFillAttr
.GetItemSet() );
405 m_aCtlPreview
.Invalidate();
408 m_xMtrDistance
->save_value();
409 m_xMtrAngle
->save_value();
410 m_xLbLineType
->save_value();
411 m_xLbLineColor
->SaveValue();
412 m_xLbBackgroundColor
->SaveValue();
415 IMPL_LINK_NOARG(SvxHatchTabPage
, ClickAddHdl_Impl
, weld::Button
&, void)
417 OUString
aNewName( SvxResId( RID_SVXSTR_HATCH
) );
418 OUString
aDesc( CuiResId( RID_SVXSTR_DESC_HATCH
) );
421 long nCount
= m_pHatchingList
->Count();
423 bool bValidHatchName
= false;
425 while( !bValidHatchName
)
427 aName
= aNewName
+ " " + OUString::number( j
++ );
428 bValidHatchName
= (SearchHatchList(aName
) == LISTBOX_ENTRY_NOTFOUND
);
431 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
432 ScopedVclPtr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog(GetDialogFrameWeld(), aName
, aDesc
));
433 sal_uInt16 nError
= 1;
435 while( pDlg
->Execute() == RET_OK
)
437 pDlg
->GetName( aName
);
439 bValidHatchName
= (SearchHatchList(aName
) == LISTBOX_ENTRY_NOTFOUND
);
440 if( bValidHatchName
)
446 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(GetDialogFrameWeld(), "cui/ui/queryduplicatedialog.ui"));
447 std::unique_ptr
<weld::MessageDialog
> xWarnBox(xBuilder
->weld_message_dialog("DuplicateNameDialog"));
448 if (xWarnBox
->run() != RET_OK
)
451 pDlg
.disposeAndClear();
455 XHatch
aXHatch( m_xLbLineColor
->GetSelectEntryColor(),
456 static_cast<css::drawing::HatchStyle
>(m_xLbLineType
->get_active()),
457 GetCoreValue( *m_xMtrDistance
, m_ePoolUnit
),
458 static_cast<long>(m_xMtrAngle
->get_value(FieldUnit::NONE
) * 10) );
460 m_pHatchingList
->Insert(std::make_unique
<XHatchEntry
>(aXHatch
, aName
), nCount
);
462 sal_Int32 nId
= m_xHatchLB
->GetItemId(nCount
- 1); // calculate the last ID
463 BitmapEx aBitmap
= m_pHatchingList
->GetBitmapForPreview( nCount
, m_xHatchLB
->GetIconSize() );
464 // Insert the new entry at the next ID
465 m_xHatchLB
->InsertItem( nId
+ 1, Image(aBitmap
), aName
);
466 m_xHatchLB
->SelectItem( nId
+ 1 );
467 m_xHatchLB
->Resize();
469 *m_pnHatchingListState
|= ChangeType::MODIFIED
;
471 ChangeHatchHdl_Impl();
475 IMPL_LINK_NOARG(SvxHatchTabPage
, ClickModifyHdl_Impl
, weld::Button
&, void)
477 sal_uInt16 nId
= m_xHatchLB
->GetSelectedItemId();
478 size_t nPos
= m_xHatchLB
->GetSelectItemPos();
480 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
482 OUString
aName( m_pHatchingList
->GetHatch( static_cast<sal_uInt16
>(nPos
) )->GetName() );
484 XHatch
aXHatch( m_xLbLineColor
->GetSelectEntryColor(),
485 static_cast<css::drawing::HatchStyle
>(m_xLbLineType
->get_active()),
486 GetCoreValue( *m_xMtrDistance
, m_ePoolUnit
),
487 static_cast<long>(m_xMtrAngle
->get_value(FieldUnit::NONE
) * 10) );
489 m_pHatchingList
->Replace(std::make_unique
<XHatchEntry
>(aXHatch
, aName
), nPos
);
491 BitmapEx aBitmap
= m_pHatchingList
->GetBitmapForPreview( static_cast<sal_uInt16
>(nPos
), m_xHatchLB
->GetIconSize() );
492 m_xHatchLB
->RemoveItem( nId
);
493 m_xHatchLB
->InsertItem( nId
, Image(aBitmap
), aName
, static_cast<sal_uInt16
>(nPos
) );
494 m_xHatchLB
->SelectItem( nId
);
496 // save values for changes recognition (-> method)
497 m_xMtrDistance
->save_value();
498 m_xMtrAngle
->save_value();
499 m_xLbLineType
->save_value();
500 m_xLbLineColor
->SaveValue();
501 m_xLbBackgroundColor
->SaveValue();
503 *m_pnHatchingListState
|= ChangeType::MODIFIED
;
507 IMPL_LINK_NOARG(SvxHatchTabPage
, ClickDeleteHdl_Impl
, SvxPresetListBox
*, void)
509 sal_uInt16 nId
= m_xHatchLB
->GetSelectedItemId();
510 size_t nPos
= m_xHatchLB
->GetSelectItemPos();
512 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
514 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(GetDialogFrameWeld(), "cui/ui/querydeletehatchdialog.ui"));
515 std::unique_ptr
<weld::MessageDialog
> xQueryBox(xBuilder
->weld_message_dialog("AskDelHatchDialog"));
516 if (xQueryBox
->run() == RET_YES
)
518 m_pHatchingList
->Remove(nPos
);
519 m_xHatchLB
->RemoveItem( nId
);
520 nId
= m_xHatchLB
->GetItemId(0);
521 m_xHatchLB
->SelectItem( nId
);
522 m_xHatchLB
->Resize();
524 m_aCtlPreview
.Invalidate();
526 ChangeHatchHdl_Impl();
528 *m_pnHatchingListState
|= ChangeType::MODIFIED
;
533 IMPL_LINK_NOARG(SvxHatchTabPage
, ClickRenameHdl_Impl
, SvxPresetListBox
*, void )
535 sal_uInt16 nId
= m_xHatchLB
->GetSelectedItemId();
536 size_t nPos
= m_xHatchLB
->GetSelectItemPos();
538 if( nPos
!= VALUESET_ITEM_NOTFOUND
)
540 OUString
aDesc( CuiResId( RID_SVXSTR_DESC_HATCH
) );
541 OUString
aName( m_pHatchingList
->GetHatch( nPos
)->GetName() );
543 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
544 ScopedVclPtr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog(GetDialogFrameWeld(), aName
, aDesc
));
547 while( bLoop
&& pDlg
->Execute() == RET_OK
)
549 pDlg
->GetName( aName
);
550 sal_Int32 nHatchPos
= SearchHatchList( aName
);
551 bool bValidHatchName
= (nHatchPos
== static_cast<sal_Int32
>(nPos
) ) || (nHatchPos
== LISTBOX_ENTRY_NOTFOUND
);
556 m_pHatchingList
->GetHatch(nPos
)->SetName(aName
);
558 m_xHatchLB
->SetItemText(nId
, aName
);
559 m_xHatchLB
->SelectItem( nId
);
561 *m_pnHatchingListState
|= ChangeType::MODIFIED
;
565 std::unique_ptr
<weld::Builder
> xBuilder(Application::CreateBuilder(GetDialogFrameWeld(), "cui/ui/queryduplicatedialog.ui"));
566 std::unique_ptr
<weld::MessageDialog
> xBox(xBuilder
->weld_message_dialog("DuplicateNameDialog"));
574 void SvxHatchTabPage::DataChanged( const DataChangedEvent
& rDCEvt
)
576 if ( ( rDCEvt
.GetType() == DataChangedEventType::SETTINGS
) && ( rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
) )
577 m_aCtlPreview
.SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST
: OUTPUT_DRAWMODE_COLOR
);
579 SfxTabPage::DataChanged( rDCEvt
);
582 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */