Both are derived from SfxSetItem which means they contain a SfxItemSet themselves. That leads to problems since at their construction time a SfxItemPool has to be known and it *should* not be different to the one of the ItemSet that Item gets added later - that leads to the 2nd class of problems. In the long therm we should get rid of all SfxSetItems. This change simplifies already some stuff, including that the standard Items for DrawObjects reduces by two (and more due to containing a whole ItemSet) and e.g. the problem that these Items had to be converted to hard attributes in the done fixes for copy/pasting Slides. Signed-off-by: Armin Le Grand (collabora) <Armin.LeGrand@collabora.com> Change-Id: I8b1c6cabdaa43ed6062811b5508ab3dece47a755 Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/6795 Reviewed-by: Armin Le Grand <armin.legrand@collabora.com> Tested-by: Jenkins CPCI <releng@collaboraoffice.com> (cherry picked from commit e67458a9b769fe7a3a7ee0739ed6d5c46dbc0692) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211734 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
569 lines
20 KiB
C++
569 lines
20 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* This file incorporates work covered by the following license notice:
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
* with this work for additional information regarding copyright
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
*/
|
|
|
|
#include <memory>
|
|
#include <tools/urlobj.hxx>
|
|
#include <vcl/image.hxx>
|
|
#include <vcl/settings.hxx>
|
|
#include <vcl/svapp.hxx>
|
|
#include <vcl/weld/Builder.hxx>
|
|
#include <vcl/weld/ScrolledWindow.hxx>
|
|
#include <vcl/weld/MessageDialog.hxx>
|
|
#include <sfx2/dialoghelper.hxx>
|
|
#include <sfx2/objsh.hxx>
|
|
|
|
#include <strings.hrc>
|
|
#include <svx/drawitem.hxx>
|
|
#include <svx/xfillit0.hxx>
|
|
#include <svx/xflhtit.hxx>
|
|
#include <svx/xflclit.hxx>
|
|
#include <svx/colorbox.hxx>
|
|
#include <svx/xtable.hxx>
|
|
#include <svx/xflbckit.hxx>
|
|
#include <cuitabarea.hxx>
|
|
#include <dialmgr.hxx>
|
|
#include <svx/dlgutil.hxx>
|
|
#include <svx/dialmgr.hxx>
|
|
#include <svx/strings.hrc>
|
|
#include <svx/svxids.hrc>
|
|
#include <sal/log.hxx>
|
|
#include <svtools/dlgname.hxx>
|
|
#include <svtools/unitconv.hxx>
|
|
|
|
using namespace com::sun::star;
|
|
|
|
SvxHatchTabPage::SvxHatchTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs)
|
|
: SfxTabPage(pPage, pController, u"cui/ui/hatchpage.ui"_ustr, u"HatchPage"_ustr, &rInAttrs)
|
|
, m_rOutAttrs(rInAttrs)
|
|
, m_nHatchingListState(ChangeType::NONE)
|
|
, m_pnColorListState(nullptr)
|
|
, m_aFillAttributeSet(rInAttrs.getPool(), WhichRangesContainer(XATTR_FILL_FIRST, XATTR_FILL_LAST)) //m_aXFillAttr.GetItemSet())
|
|
, m_xMtrDistance(m_xBuilder->weld_metric_spin_button(u"distancemtr"_ustr, FieldUnit::MM))
|
|
, m_xMtrAngle(m_xBuilder->weld_metric_spin_button(u"anglemtr"_ustr, FieldUnit::DEGREE))
|
|
, m_xSliderAngle(m_xBuilder->weld_scale(u"angleslider"_ustr))
|
|
, m_xLbLineType(m_xBuilder->weld_combo_box(u"linetypelb"_ustr))
|
|
, m_xLbLineColor(new ColorListBox(m_xBuilder->weld_menu_button(u"linecolorlb"_ustr),
|
|
[this]{ return GetDialogController()->getDialog(); }))
|
|
, m_xCbBackgroundColor(m_xBuilder->weld_check_button(u"backgroundcolor"_ustr))
|
|
, m_xLbBackgroundColor(new ColorListBox(m_xBuilder->weld_menu_button(u"backgroundcolorlb"_ustr),
|
|
[this]{ return GetDialogController()->getDialog(); }))
|
|
, m_xHatchPresets(m_xBuilder->weld_icon_view(u"hatchpresets"_ustr))
|
|
, m_xHatchLB(new SvxPresetListBox(*m_xHatchPresets))
|
|
, m_xBtnAdd(m_xBuilder->weld_button(u"add"_ustr))
|
|
, m_xBtnModify(m_xBuilder->weld_button(u"modify"_ustr))
|
|
, m_xCtlPreview(new weld::CustomWeld(*m_xBuilder, u"previewctl"_ustr, m_aCtlPreview))
|
|
{
|
|
Size aSize = getDrawPreviewOptimalSize(m_aCtlPreview.GetDrawingArea()->get_ref_device());
|
|
m_xCtlPreview->set_size_request(aSize.Width(), aSize.Height());
|
|
|
|
// this page needs ExchangeSupport
|
|
SetExchangeSupport();
|
|
|
|
// adjust metric
|
|
FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs );
|
|
|
|
switch ( eFUnit )
|
|
{
|
|
case FieldUnit::M:
|
|
case FieldUnit::KM:
|
|
eFUnit = FieldUnit::MM;
|
|
break;
|
|
default: ;//prevent warning
|
|
}
|
|
SetFieldUnit( *m_xMtrDistance, eFUnit );
|
|
|
|
// determine PoolUnit
|
|
SfxItemPool* pPool = m_rOutAttrs.GetPool();
|
|
assert( pPool && "Where is the pool?" );
|
|
m_ePoolUnit = pPool->GetMetric( SID_ATTR_FILL_HATCH );
|
|
|
|
// setting the output device
|
|
m_aFillAttributeSet.Put( XFillStyleItem(drawing::FillStyle_HATCH) );
|
|
m_aFillAttributeSet.Put( XFillHatchItem(OUString(), XHatch()) );
|
|
m_aCtlPreview.SetAttributes(m_aFillAttributeSet);
|
|
m_xHatchPresets->connect_item_activated(LINK(this, SvxHatchTabPage, ChangeHatchHdl));
|
|
m_xHatchLB->SetRenameHdl( LINK( this, SvxHatchTabPage, ClickRenameHdl_Impl ) );
|
|
m_xHatchLB->SetDeleteHdl( LINK( this, SvxHatchTabPage, ClickDeleteHdl_Impl ) );
|
|
|
|
Link<weld::MetricSpinButton&,void> aLink = LINK( this, SvxHatchTabPage, ModifiedEditHdl_Impl );
|
|
Link<weld::ComboBox&,void> aLink2 = LINK( this, SvxHatchTabPage, ModifiedListBoxHdl_Impl );
|
|
m_xMtrDistance->connect_value_changed( aLink );
|
|
m_xMtrAngle->connect_value_changed( aLink );
|
|
m_xSliderAngle->connect_value_changed(LINK(this, SvxHatchTabPage, ModifiedSliderHdl_Impl));
|
|
m_xLbLineType->connect_changed( aLink2 );
|
|
Link<ColorListBox&,void> aLink3 = LINK( this, SvxHatchTabPage, ModifiedColorListBoxHdl_Impl );
|
|
m_xLbLineColor->SetSelectHdl( aLink3 );
|
|
m_xCbBackgroundColor->connect_toggled( LINK( this, SvxHatchTabPage, ToggleHatchBackgroundColor_Impl ) );
|
|
m_xLbBackgroundColor->SetSelectHdl( LINK( this, SvxHatchTabPage, ModifiedBackgroundHdl_Impl ) );
|
|
|
|
m_xBtnAdd->connect_clicked( LINK( this, SvxHatchTabPage, ClickAddHdl_Impl ) );
|
|
m_xBtnModify->connect_clicked( LINK( this, SvxHatchTabPage, ClickModifyHdl_Impl ) );
|
|
|
|
m_aCtlPreview.SetDrawMode(Application::GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
|
|
}
|
|
|
|
SvxHatchTabPage::~SvxHatchTabPage()
|
|
{
|
|
m_xCtlPreview.reset();
|
|
m_xHatchLB.reset();
|
|
m_xLbBackgroundColor.reset();
|
|
m_xLbLineColor.reset();
|
|
|
|
if (m_nHatchingListState & ChangeType::MODIFIED)
|
|
{
|
|
m_pHatchingList->SetPath(AreaTabHelper::GetPalettePath());
|
|
m_pHatchingList->Save();
|
|
|
|
// ToolBoxControls are informed:
|
|
SfxObjectShell* pShell = SfxObjectShell::Current();
|
|
if (pShell)
|
|
pShell->PutItem(SvxHatchListItem(m_pHatchingList, SID_HATCH_LIST));
|
|
}
|
|
}
|
|
|
|
void SvxHatchTabPage::Construct()
|
|
{
|
|
m_xHatchLB->FillPresetListBox(*m_pHatchingList);
|
|
}
|
|
|
|
void SvxHatchTabPage::ActivatePage( const SfxItemSet& rSet )
|
|
{
|
|
if( m_pColorList.is() )
|
|
{
|
|
// ColorList
|
|
if( *m_pnColorListState & ChangeType::CHANGED ||
|
|
*m_pnColorListState & ChangeType::MODIFIED )
|
|
{
|
|
SvxAreaTabDialog* pArea = (*m_pnColorListState & ChangeType::CHANGED) ?
|
|
dynamic_cast<SvxAreaTabDialog*>(GetDialogController()) : nullptr;
|
|
if (pArea)
|
|
m_pColorList = pArea->GetNewColorList();
|
|
|
|
ModifiedHdl_Impl( this );
|
|
}
|
|
|
|
// determining (possibly cutting) the name
|
|
// and displaying it in the GroupBox
|
|
OUString aString = CuiResId( RID_CUISTR_TABLE ) + ": ";
|
|
INetURLObject aURL( m_pHatchingList->GetPath() );
|
|
|
|
aURL.Append( m_pHatchingList->GetName() );
|
|
SAL_WARN_IF( aURL.GetProtocol() == INetProtocol::NotValid, "cui.tabpages", "invalid URL" );
|
|
|
|
if ( aURL.getBase().getLength() > 18 )
|
|
{
|
|
aString += OUString::Concat(aURL.getBase().subView( 0, 15 )) + "...";
|
|
}
|
|
else
|
|
aString += aURL.getBase();
|
|
|
|
sal_Int32 nPos = SearchHatchList( rSet.Get(XATTR_FILLHATCH).GetName() );
|
|
if( nPos != -1)
|
|
m_xHatchPresets->select(nPos);
|
|
|
|
// colors could have been deleted
|
|
ChangeHatchHdl_Impl();
|
|
}
|
|
|
|
const XFillBackgroundItem& aBckItem( rSet.Get(XATTR_FILLBACKGROUND));
|
|
m_aFillAttributeSet.Put( aBckItem );
|
|
|
|
if (aBckItem.GetValue())
|
|
{
|
|
m_xCbBackgroundColor->set_state(TRISTATE_TRUE);
|
|
const XFillColorItem& aColorItem( rSet.Get(XATTR_FILLCOLOR) );
|
|
Color aColor(aColorItem.GetColorValue());
|
|
m_xLbBackgroundColor->SelectEntry(aColor);
|
|
m_xLbBackgroundColor->set_sensitive(true);
|
|
m_aFillAttributeSet.Put( aColorItem );
|
|
}
|
|
else
|
|
{
|
|
m_xCbBackgroundColor->set_state(TRISTATE_FALSE);
|
|
m_xLbBackgroundColor->SelectEntry(COL_AUTO);
|
|
m_xLbBackgroundColor->set_sensitive(false);
|
|
}
|
|
|
|
m_aCtlPreview.SetAttributes(m_aFillAttributeSet);
|
|
m_aCtlPreview.Invalidate();
|
|
}
|
|
|
|
DeactivateRC SvxHatchTabPage::DeactivatePage( SfxItemSet* _pSet )
|
|
{
|
|
if( _pSet )
|
|
FillItemSet( _pSet );
|
|
|
|
return DeactivateRC::LeavePage;
|
|
}
|
|
|
|
sal_Int32 SvxHatchTabPage::SearchHatchList(std::u16string_view rHatchName)
|
|
{
|
|
tools::Long nCount = m_pHatchingList->Count();
|
|
bool bValidHatchName = true;
|
|
sal_Int32 nPos = -1;
|
|
|
|
for(tools::Long i = 0;i < nCount && bValidHatchName;i++)
|
|
{
|
|
if(rHatchName == m_pHatchingList->GetHatch( i )->GetName())
|
|
{
|
|
nPos = i;
|
|
bValidHatchName = false;
|
|
}
|
|
}
|
|
return nPos;
|
|
}
|
|
|
|
bool SvxHatchTabPage::FillItemSet( SfxItemSet* rSet )
|
|
{
|
|
std::unique_ptr<XHatch> pXHatch;
|
|
OUString aString;
|
|
const int nPos = m_xHatchPresets->get_selected_index();
|
|
if (nPos >= 0)
|
|
{
|
|
pXHatch.reset(new XHatch( m_pHatchingList->GetHatch( static_cast<sal_uInt16>(nPos) )->GetHatch() ));
|
|
aString = m_xHatchPresets->get_item_tooltip_text(nPos);
|
|
}
|
|
// unidentified hatch has been passed
|
|
else
|
|
{
|
|
pXHatch.reset(new XHatch( m_xLbLineColor->GetSelectEntryColor(),
|
|
static_cast<css::drawing::HatchStyle>(m_xLbLineType->get_active()),
|
|
GetCoreValue( *m_xMtrDistance, m_ePoolUnit ),
|
|
Degree10(static_cast<sal_Int16>((m_xMtrAngle->get_value(FieldUnit::NONE) % 360) * 10)) ));
|
|
}
|
|
assert( pXHatch && "XHatch couldn't be created" );
|
|
rSet->Put( XFillStyleItem( drawing::FillStyle_HATCH ) );
|
|
rSet->Put( XFillHatchItem( aString, *pXHatch ) );
|
|
rSet->Put( XFillBackgroundItem( m_xCbBackgroundColor->get_active() ) );
|
|
if (m_xCbBackgroundColor->get_active())
|
|
{
|
|
NamedColor aColor = m_xLbBackgroundColor->GetSelectedEntry();
|
|
rSet->Put(XFillColorItem(aColor.m_aName, aColor.m_aColor));
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void SvxHatchTabPage::Reset( const SfxItemSet* rSet )
|
|
{
|
|
ChangeHatchHdl_Impl();
|
|
|
|
const XFillColorItem& aColItem( rSet->Get(XATTR_FILLCOLOR) );
|
|
m_xLbBackgroundColor->SelectEntry(aColItem.GetColorValue());
|
|
m_aFillAttributeSet.Put( aColItem );
|
|
|
|
const XFillBackgroundItem& aBckItem( rSet->Get(XATTR_FILLBACKGROUND) );
|
|
if(aBckItem.GetValue())
|
|
m_xCbBackgroundColor->set_state(TRISTATE_TRUE);
|
|
else
|
|
m_xCbBackgroundColor->set_state(TRISTATE_FALSE);
|
|
m_aFillAttributeSet.Put( aBckItem );
|
|
|
|
m_aCtlPreview.SetAttributes(m_aFillAttributeSet);
|
|
m_aCtlPreview.Invalidate();
|
|
}
|
|
|
|
std::unique_ptr<SvxHatchTabPage> SvxHatchTabPage::Create(weld::Container* pPage,
|
|
weld::DialogController* pController,
|
|
const SfxItemSet& rSet)
|
|
{
|
|
return std::make_unique<SvxHatchTabPage>(pPage, pController, rSet);
|
|
}
|
|
|
|
IMPL_LINK( SvxHatchTabPage, ModifiedListBoxHdl_Impl, weld::ComboBox&, rListBox, void )
|
|
{
|
|
ModifiedHdl_Impl(&rListBox);
|
|
// hatch params have changed, it is no longer one of the presets
|
|
m_xHatchPresets->unselect_all();
|
|
}
|
|
|
|
IMPL_LINK( SvxHatchTabPage, ModifiedColorListBoxHdl_Impl, ColorListBox&, rListBox, void )
|
|
{
|
|
ModifiedHdl_Impl(&rListBox);
|
|
m_xHatchPresets->unselect_all();
|
|
}
|
|
|
|
IMPL_LINK_NOARG( SvxHatchTabPage, ToggleHatchBackgroundColor_Impl, weld::Toggleable&, void )
|
|
{
|
|
if (m_xCbBackgroundColor->get_active())
|
|
m_xLbBackgroundColor->set_sensitive(true);
|
|
else
|
|
m_xLbBackgroundColor->set_sensitive(false);
|
|
m_aFillAttributeSet.Put( XFillBackgroundItem( m_xCbBackgroundColor->get_active() ) );
|
|
ModifiedBackgroundHdl_Impl(*m_xLbBackgroundColor);
|
|
}
|
|
|
|
IMPL_LINK_NOARG( SvxHatchTabPage, ModifiedBackgroundHdl_Impl, ColorListBox&, void )
|
|
{
|
|
Color aColor(COL_TRANSPARENT);
|
|
if (m_xCbBackgroundColor->get_active())
|
|
{
|
|
aColor = m_xLbBackgroundColor->GetSelectEntryColor();
|
|
m_aCtlPreview.SetAttributes(m_aFillAttributeSet);
|
|
m_aCtlPreview.Invalidate();
|
|
}
|
|
m_aFillAttributeSet.Put(XFillColorItem( OUString(), aColor ));
|
|
|
|
m_aCtlPreview.SetAttributes(m_aFillAttributeSet);
|
|
m_aCtlPreview.Invalidate();
|
|
}
|
|
|
|
IMPL_LINK( SvxHatchTabPage, ModifiedEditHdl_Impl, weld::MetricSpinButton&, rEdit, void )
|
|
{
|
|
ModifiedHdl_Impl(&rEdit);
|
|
m_xHatchPresets->unselect_all();
|
|
}
|
|
|
|
IMPL_LINK( SvxHatchTabPage, ModifiedSliderHdl_Impl, weld::Scale&, rSlider, void )
|
|
{
|
|
ModifiedHdl_Impl(&rSlider);
|
|
m_xHatchPresets->unselect_all();
|
|
}
|
|
|
|
void SvxHatchTabPage::ModifiedHdl_Impl( void const * p )
|
|
{
|
|
if (p == m_xMtrAngle.get())
|
|
m_xSliderAngle->set_value(m_xMtrAngle->get_value(FieldUnit::NONE));
|
|
|
|
if (p == m_xSliderAngle.get())
|
|
m_xMtrAngle->set_value(m_xSliderAngle->get_value(), FieldUnit::NONE);
|
|
|
|
XHatch aXHatch( m_xLbLineColor->GetSelectEntryColor(),
|
|
static_cast<css::drawing::HatchStyle>(m_xLbLineType->get_active()),
|
|
GetCoreValue( *m_xMtrDistance, m_ePoolUnit ),
|
|
Degree10(static_cast<sal_Int16>((m_xMtrAngle->get_value(FieldUnit::NONE) % 360) * 10)) );
|
|
|
|
m_aFillAttributeSet.Put( XFillHatchItem( OUString(), aXHatch ) );
|
|
|
|
m_aCtlPreview.SetAttributes(m_aFillAttributeSet);
|
|
m_aCtlPreview.Invalidate();
|
|
}
|
|
|
|
IMPL_LINK_NOARG(SvxHatchTabPage, ChangeHatchHdl, const weld::TreeIter&, bool)
|
|
{
|
|
ChangeHatchHdl_Impl();
|
|
return true;
|
|
}
|
|
|
|
void SvxHatchTabPage::ChangeHatchHdl_Impl()
|
|
{
|
|
std::unique_ptr<XHatch> pHatch;
|
|
const int nPos = m_xHatchPresets->get_selected_index();
|
|
|
|
if (nPos >= 0)
|
|
pHatch.reset(new XHatch(m_pHatchingList->GetHatch(nPos)->GetHatch()));
|
|
else
|
|
{
|
|
if( const XFillStyleItem* pFillStyleItem = m_rOutAttrs.GetItemIfSet( GetWhich( XATTR_FILLSTYLE ) ) )
|
|
{
|
|
const XFillHatchItem* pFillHatchItem;
|
|
if( ( drawing::FillStyle_HATCH == pFillStyleItem->GetValue() ) &&
|
|
( pFillHatchItem = m_rOutAttrs.GetItemIfSet( GetWhich( XATTR_FILLHATCH ) ) ) )
|
|
{
|
|
pHatch.reset(new XHatch( pFillHatchItem->GetHatchValue() ));
|
|
}
|
|
}
|
|
if (!pHatch && m_xHatchPresets->n_children() > 0)
|
|
{
|
|
m_xHatchPresets->select(0);
|
|
pHatch.reset(new XHatch(m_pHatchingList->GetHatch(0)->GetHatch()));
|
|
}
|
|
}
|
|
if( pHatch )
|
|
{
|
|
m_xLbLineType->set_active(
|
|
sal::static_int_cast< sal_Int32 >( pHatch->GetHatchStyle() ) );
|
|
m_xLbLineColor->SetNoSelection();
|
|
m_xLbLineColor->SelectEntry( pHatch->GetColor() );
|
|
SetMetricValue( *m_xMtrDistance, pHatch->GetDistance(), m_ePoolUnit );
|
|
tools::Long nHatchAngle = pHatch->GetAngle().get() / 10;
|
|
m_xMtrAngle->set_value(nHatchAngle, FieldUnit::NONE);
|
|
m_xSliderAngle->set_value(nHatchAngle);
|
|
|
|
// fill ItemSet and pass it on to m_aCtlPreview
|
|
m_aFillAttributeSet.Put( XFillHatchItem( OUString(), *pHatch ) );
|
|
m_aCtlPreview.SetAttributes(m_aFillAttributeSet);
|
|
|
|
m_aCtlPreview.Invalidate();
|
|
pHatch.reset();
|
|
}
|
|
m_xMtrDistance->save_value();
|
|
m_xMtrAngle->save_value();
|
|
m_xLbLineType->save_value();
|
|
m_xLbLineColor->SaveValue();
|
|
m_xLbBackgroundColor->SaveValue();
|
|
}
|
|
|
|
void SvxHatchTabPage::AddHatch(const OUString& aName, tools::Long nCount)
|
|
{
|
|
XHatch aXHatch( m_xLbLineColor->GetSelectEntryColor(),
|
|
static_cast<css::drawing::HatchStyle>(m_xLbLineType->get_active()),
|
|
GetCoreValue( *m_xMtrDistance, m_ePoolUnit ),
|
|
Degree10(static_cast<sal_Int16>((m_xMtrAngle->get_value(FieldUnit::NONE) % 360) * 10)) );
|
|
|
|
m_pHatchingList->Insert(std::make_unique<XHatchEntry>(aXHatch, aName), nCount);
|
|
|
|
Bitmap aBitmap = m_pHatchingList->CreateBitmap(nCount, m_xHatchLB->GetIconSize());
|
|
// Insert the new entry at the next ID
|
|
m_xHatchPresets->insert(nCount, nullptr, nullptr, &aBitmap, nullptr);
|
|
m_xHatchPresets->set_item_accessible_name(nCount, aName);
|
|
m_xHatchPresets->set_item_tooltip_text(nCount, aName);
|
|
m_xHatchPresets->select(nCount);
|
|
|
|
m_nHatchingListState |= ChangeType::MODIFIED;
|
|
|
|
ChangeHatchHdl_Impl();
|
|
}
|
|
|
|
IMPL_LINK_NOARG(SvxHatchTabPage, ClickAddHdl_Impl, weld::Button&, void)
|
|
{
|
|
OUString aNewName( SvxResId( RID_SVXSTR_HATCH ) );
|
|
OUString aDesc( CuiResId( RID_CUISTR_DESC_HATCH ) );
|
|
OUString aName;
|
|
|
|
tools::Long nCount = m_pHatchingList->Count();
|
|
tools::Long j = 1;
|
|
bool bValidHatchName = false;
|
|
|
|
while( !bValidHatchName )
|
|
{
|
|
aName = aNewName + " " + OUString::number( j++ );
|
|
bValidHatchName = (SearchHatchList(aName) == -1);
|
|
}
|
|
|
|
SvxNameDialog aDlg(GetFrameWeld(), aName, aDesc);
|
|
sal_uInt16 nError = 1;
|
|
|
|
while (aDlg.run() == RET_OK)
|
|
{
|
|
aName = aDlg.GetName();
|
|
|
|
bValidHatchName = (SearchHatchList(aName) == -1);
|
|
if( bValidHatchName )
|
|
{
|
|
nError = 0;
|
|
break;
|
|
}
|
|
|
|
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), u"cui/ui/queryduplicatedialog.ui"_ustr));
|
|
std::unique_ptr<weld::MessageDialog> xWarnBox(xBuilder->weld_message_dialog(u"DuplicateNameDialog"_ustr));
|
|
if (xWarnBox->run() != RET_OK)
|
|
break;
|
|
}
|
|
|
|
if( nError )
|
|
return;
|
|
|
|
AddHatch(aName, nCount);
|
|
}
|
|
|
|
IMPL_LINK_NOARG(SvxHatchTabPage, ClickModifyHdl_Impl, weld::Button&, void)
|
|
{
|
|
const int nPos = m_xHatchPresets->get_selected_index();
|
|
|
|
if (nPos < 0)
|
|
return;
|
|
|
|
OUString aName(m_pHatchingList->GetHatch(nPos)->GetName());
|
|
|
|
XHatch aXHatch( m_xLbLineColor->GetSelectEntryColor(),
|
|
static_cast<css::drawing::HatchStyle>(m_xLbLineType->get_active()),
|
|
GetCoreValue( *m_xMtrDistance, m_ePoolUnit ),
|
|
Degree10(static_cast<sal_Int16>((m_xMtrAngle->get_value(FieldUnit::NONE) % 360) * 10)) );
|
|
|
|
m_pHatchingList->Replace(std::make_unique<XHatchEntry>(aXHatch, aName), nPos);
|
|
|
|
Bitmap aBitmap = m_pHatchingList->CreateBitmap(nPos, m_xHatchLB->GetIconSize());
|
|
m_xHatchPresets->remove(nPos);
|
|
m_xHatchPresets->insert(nPos, nullptr, nullptr, &aBitmap, nullptr);
|
|
m_xHatchPresets->set_item_accessible_name(nPos, aName);
|
|
m_xHatchPresets->set_item_tooltip_text(nPos, aName);
|
|
m_xHatchPresets->select(nPos);
|
|
|
|
// save values for changes recognition (-> method)
|
|
m_xMtrDistance->save_value();
|
|
m_xMtrAngle->save_value();
|
|
m_xLbLineType->save_value();
|
|
m_xLbLineColor->SaveValue();
|
|
m_xLbBackgroundColor->SaveValue();
|
|
|
|
m_nHatchingListState |= ChangeType::MODIFIED;
|
|
}
|
|
|
|
IMPL_LINK(SvxHatchTabPage, ClickDeleteHdl_Impl, int, nPos, void)
|
|
{
|
|
if (nPos < 0)
|
|
return;
|
|
|
|
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), u"cui/ui/querydeletehatchdialog.ui"_ustr));
|
|
std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog(u"AskDelHatchDialog"_ustr));
|
|
if (xQueryBox->run() != RET_YES)
|
|
return;
|
|
|
|
const bool bDeletingSelectedItem(nPos == m_xHatchPresets->get_selected_index());
|
|
m_pHatchingList->Remove(nPos);
|
|
m_xHatchPresets->remove(nPos);
|
|
if (bDeletingSelectedItem)
|
|
{
|
|
m_xHatchPresets->select(0);
|
|
m_aCtlPreview.Invalidate();
|
|
}
|
|
|
|
ChangeHatchHdl_Impl();
|
|
|
|
m_nHatchingListState |= ChangeType::MODIFIED;
|
|
}
|
|
|
|
IMPL_LINK(SvxHatchTabPage, ClickRenameHdl_Impl, int, nPos, void)
|
|
{
|
|
if (nPos < 0)
|
|
return;
|
|
|
|
OUString aDesc( CuiResId( RID_CUISTR_DESC_HATCH ) );
|
|
OUString aName( m_pHatchingList->GetHatch( nPos )->GetName() );
|
|
|
|
SvxNameDialog aDlg(GetFrameWeld(), aName, aDesc);
|
|
|
|
bool bLoop = true;
|
|
while (bLoop && aDlg.run() == RET_OK)
|
|
{
|
|
aName = aDlg.GetName();
|
|
sal_Int32 nHatchPos = SearchHatchList( aName );
|
|
bool bValidHatchName = (nHatchPos == static_cast<sal_Int32>(nPos) ) || (nHatchPos == -1);
|
|
|
|
if(bValidHatchName)
|
|
{
|
|
bLoop = false;
|
|
m_pHatchingList->GetHatch(nPos)->SetName(aName);
|
|
|
|
m_xHatchPresets->set_item_accessible_name(nPos, aName);
|
|
m_xHatchPresets->set_item_tooltip_text(nPos, aName);
|
|
|
|
m_nHatchingListState |= ChangeType::MODIFIED;
|
|
}
|
|
else
|
|
{
|
|
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), u"cui/ui/queryduplicatedialog.ui"_ustr));
|
|
std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(u"DuplicateNameDialog"_ustr));
|
|
xBox->run();
|
|
}
|
|
}
|
|
}
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|