39#include <svx/strings.hrc>
40#include <svx/svxids.hrc>
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())
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"),
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))
69 m_xHatchLBWin->set_size_request(aSize.
Width(), aSize.
Height());
70 m_xCtlPreview->set_size_request(aSize.
Width(), aSize.
Height());
82 eFUnit = FieldUnit::MM;
90 assert( pPool &&
"Where is the pool?" );
91 m_ePoolUnit = pPool->
GetMetric( SID_ATTR_FILL_HATCH );
96 m_aCtlPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
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 );
108 m_xLbLineColor->SetSelectHdl( aLink3 );
109 m_xCbBackgroundColor->connect_toggled(
LINK(
this,
SvxHatchTabPage, ToggleHatchBackgroundColor_Impl ) );
110 m_xLbBackgroundColor->SetSelectHdl(
LINK(
this,
SvxHatchTabPage, ModifiedBackgroundHdl_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);
152 OUString aString =
CuiResId( RID_CUISTR_TABLE ) +
": ";
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();
178 if (aBckItem.GetValue())
203 return DeactivateRC::LeavePage;
209 bool bValidHatchName =
true;
217 bValidHatchName =
false;
225 std::unique_ptr<XHatch> pXHatch;
237 static_cast<css::drawing::HatchStyle
>(
m_xLbLineType->get_active()),
241 assert( pXHatch &&
"XHatch couldn't be created" );
262 if(aBckItem.GetValue())
275 return std::make_unique<SvxHatchTabPage>(pPage, pController, *
rSet);
280 ModifiedHdl_Impl(&rListBox);
282 m_xHatchLB->SetNoSelection();
287 ModifiedHdl_Impl(&rListBox);
288 m_xHatchLB->SetNoSelection();
293 if (m_xCbBackgroundColor->get_active())
294 m_xLbBackgroundColor->set_sensitive(
true);
296 m_xLbBackgroundColor->set_sensitive(
false);
298 ModifiedBackgroundHdl_Impl(*m_xLbBackgroundColor);
304 if (m_xCbBackgroundColor->get_active())
306 aColor = m_xLbBackgroundColor->GetSelectEntryColor();
307 m_aCtlPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
308 m_aCtlPreview.Invalidate();
312 m_aCtlPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
313 m_aCtlPreview.Invalidate();
318 ModifiedHdl_Impl(&rEdit);
319 m_xHatchLB->SetNoSelection();
324 ModifiedHdl_Impl(&rSlider);
325 m_xHatchLB->SetNoSelection();
337 static_cast<css::drawing::HatchStyle
>(
m_xLbLineType->get_active()),
349 ChangeHatchHdl_Impl();
354 std::unique_ptr<XHatch> pHatch;
364 if( ( drawing::FillStyle_HATCH == pFillStyleItem->GetValue() ) &&
372 sal_uInt16 nPosition =
m_xHatchLB->GetItemId( 0 );
381 sal::static_int_cast< sal_Int32 >( pHatch->GetHatchStyle() ) );
385 tools::Long nHatchAngle = pHatch->GetAngle().get() / 10;
386 m_xMtrAngle->set_value(nHatchAngle, FieldUnit::NONE);
405 OUString aNewName(
SvxResId( RID_SVXSTR_HATCH ) );
406 OUString aDesc(
CuiResId( RID_CUISTR_DESC_HATCH ) );
411 bool bValidHatchName =
false;
413 while( !bValidHatchName )
415 aName = aNewName +
" " + OUString::number( j++ );
416 bValidHatchName = (SearchHatchList(
aName) == -1);
421 sal_uInt16 nError = 1;
423 while( pDlg->Execute() ==
RET_OK )
425 pDlg->GetName(
aName );
427 bValidHatchName = (SearchHatchList(
aName) == -1);
428 if( bValidHatchName )
435 std::unique_ptr<weld::MessageDialog> xWarnBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
436 if (xWarnBox->run() !=
RET_OK)
444 XHatch aXHatch( m_xLbLineColor->GetSelectEntryColor(),
445 static_cast<css::drawing::HatchStyle
>(m_xLbLineType->get_active()),
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);
452 BitmapEx aBitmap = m_pHatchingList->GetBitmapForPreview(
nCount, m_xHatchLB->GetIconSize() );
455 m_xHatchLB->SelectItem(
nId + 1 );
456 m_xHatchLB->Resize();
458 *m_pnHatchingListState |= ChangeType::MODIFIED;
460 ChangeHatchHdl_Impl();
465 sal_uInt16
nId = m_xHatchLB->GetSelectedItemId();
466 size_t nPos = m_xHatchLB->GetSelectItemPos();
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()),
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 );
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;
497 sal_uInt16
nId = m_xHatchLB->GetSelectedItemId();
498 size_t nPos = m_xHatchLB->GetSelectItemPos();
504 std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog(
"AskDelHatchDialog"));
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;
523 sal_uInt16
nId = m_xHatchLB->GetSelectedItemId();
524 size_t nPos = m_xHatchLB->GetSelectItemPos();
529 OUString aDesc(
CuiResId( RID_CUISTR_DESC_HATCH ) );
530 OUString
aName( m_pHatchingList->GetHatch(
nPos )->GetName() );
536 while( bLoop && pDlg->Execute() ==
RET_OK )
538 pDlg->GetName(
aName );
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;
555 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
static const AllSettings & GetSettings()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SfxOkDialogController * GetDialogController() const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
virtual VclPtr< AbstractSvxNameDialog > CreateSvxNameDialog(weld::Window *pParent, const OUString &rName, const OUString &rDesc)=0
static SvxAbstractDialogFactory * Create()
const XColorListRef & GetNewColorList() const
virtual bool FillItemSet(SfxItemSet *) override
std::unique_ptr< weld::CustomWeld > m_xCtlPreview
void ChangeHatchHdl_Impl()
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
const SfxItemSet & m_rOutAttrs
std::unique_ptr< weld::CheckButton > m_xCbBackgroundColor
XColorListRef m_pColorList
ChangeType * m_pnColorListState
std::unique_ptr< weld::Scale > m_xSliderAngle
SvxHatchTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
XFillAttrSetItem m_aXFillAttr
virtual ~SvxHatchTabPage() override
void ModifiedHdl_Impl(void const *)
std::unique_ptr< weld::MetricSpinButton > m_xMtrDistance
virtual void Reset(const SfxItemSet *) override
std::unique_ptr< weld::CustomWeld > m_xHatchLBWin
SvxXRectPreview m_aCtlPreview
std::unique_ptr< ColorListBox > m_xLbBackgroundColor
std::unique_ptr< ColorListBox > m_xLbLineColor
XHatchListRef m_pHatchingList
std::unique_ptr< weld::MetricSpinButton > m_xMtrAngle
std::unique_ptr< SvxPresetListBox > m_xHatchLB
std::unique_ptr< weld::ComboBox > m_xLbLineType
virtual void ActivatePage(const SfxItemSet &rSet) override
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
sal_Int32 SearchHatchList(std::u16string_view rHatchName)
void SetAttributes(const SfxItemSet &rItemSet)
const Color & GetColorValue() const
const XHatch & GetHatchValue() const
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
OUString CuiResId(TranslateId aKey)
SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Size SFX2_DLLPUBLIC getDrawPreviewOptimalSize(const OutputDevice &rReference)
SVXCORE_DLLPUBLIC FieldUnit GetModuleFieldUnit(const SfxItemSet &)
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
IMPL_LINK_NOARG(SvxHatchTabPage, ToggleHatchBackgroundColor_Impl, weld::Toggleable &, void)
IMPL_LINK(SvxHatchTabPage, ModifiedListBoxHdl_Impl, weld::ComboBox &, rListBox, void)
SVT_DLLPUBLIC sal_Int64 GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
SVT_DLLPUBLIC void SetMetricValue(weld::MetricSpinButton &rField, sal_Int64 nCoreValue, MapUnit eUnit)
SVT_DLLPUBLIC void SetFieldUnit(weld::MetricSpinButton &rCtrl, FieldUnit eUnit, bool bAll=false)
#define VALUESET_ITEM_NOTFOUND
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
constexpr TypedWhichId< XFillBackgroundItem > XATTR_FILLBACKGROUND(XATTR_FILL_FIRST+19)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)