28#include <svx/strings.hrc>
73 :
SvxTabPage(pPage, pController,
"cui/ui/patterntabpage.ui",
"PatternTabPage", rInAttrs)
74 , m_rOutAttrs(rInAttrs)
75 , m_pnPatternListState(nullptr)
76 , m_pnColorListState(nullptr)
77 , m_aXFillAttr(rInAttrs.GetPool())
80 , m_xLbColor(new
ColorListBox(m_xBuilder->weld_menu_button(
"LB_COLOR"),
81 [this]{
return GetDialogController()->getDialog(); }))
82 , m_xLbBackgroundColor(
new ColorListBox(m_xBuilder->weld_menu_button(
"LB_BACKGROUND_COLOR"),
83 [
this]{ return GetDialogController()->getDialog(); }))
84 , m_xPatternLB(
new SvxPresetListBox(m_xBuilder->weld_scrolled_window(
"patternpresetlistwin",
true)))
85 , m_xBtnAdd(m_xBuilder->weld_button(
"BTN_ADD"))
86 , m_xBtnModify(m_xBuilder->weld_button(
"BTN_MODIFY"))
87 , m_xCtlPixelWin(
new weld::CustomWeld(*m_xBuilder,
"CTL_PIXEL", *m_xCtlPixel))
88 , m_xCtlPreview(
new weld::CustomWeld(*m_xBuilder,
"CTL_PREVIEW", m_aCtlPreview))
89 , m_xPatternLBWin(
new weld::CustomWeld(*m_xBuilder,
"patternpresetlist", *m_xPatternLB))
93 m_xPatternLB->set_size_request(aSize.
Width(), aSize.
Height());
94 m_xCtlPreview->set_size_request(aSize.
Width(), aSize.
Height());
114 m_xPatternLB->SetStyle(WB_FLATVALUESET | WB_NO_DIRECTSELECT | WB_TABSTOP);
150 OUString aString =
CuiResId( RID_CUISTR_TABLE ) +
": ";
154 SAL_WARN_IF(
aURL.GetProtocol() == INetProtocol::NotValid,
"cui.tabpages",
"invalid URL" );
156 if(
aURL.getBase().getLength() > 18 )
158 aString += OUString::Concat(
aURL.getBase().subView( 0, 15 )) +
"...";
161 aString +=
aURL.getBase();
184 return DeactivateRC::LeavePage;
242 return std::make_unique<SvxPatternTabPage>(pPage, pController, *
rSet);
247 std::unique_ptr<GraphicObject> pGraphicObject;
248 size_t nPos = m_xPatternLB->GetSelectItemPos();
252 pGraphicObject.reset(
new GraphicObject(m_pPatternList->GetBitmap(
static_cast<sal_uInt16
>(
nPos) )->GetGraphicObject()));
258 const drawing::FillStyle eXFS(pFillStyleItem->GetValue());
269 sal_uInt16 nPosition = m_xPatternLB->GetItemId( 0 );
270 m_xPatternLB->SelectItem( nPosition );
273 pGraphicObject.reset(
new GraphicObject(m_pPatternList->GetBitmap(0)->GetGraphicObject()));
285 m_xLbColor->SetNoSelection();
286 m_xLbBackgroundColor->SetNoSelection();
290 m_xCtlPixel->SetPaintable(
true );
291 m_xBtnModify->set_sensitive(
true);
292 m_xBtnAdd->set_sensitive(
true);
296 m_xCtlPixel->SetXBitmap(pGraphicObject->GetGraphic().GetBitmapEx());
298 m_xLbColor->SelectEntry( aPixelColor );
299 m_xLbBackgroundColor->SelectEntry( aBackColor );
302 m_xBitmapCtl->SetPixelColor( aPixelColor );
303 m_xBitmapCtl->SetBackgroundColor( aBackColor );
304 m_rXFSet.ClearItem();
307 m_aCtlPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
308 m_aCtlPreview.Invalidate();
312 m_xCtlPixel->Reset();
313 m_xCtlPixel->SetPaintable(
false );
314 m_xBtnModify->set_sensitive(
false);
315 m_xBtnAdd->set_sensitive(
false);
318 m_xCtlPixel->Invalidate();
324 OUString aNewName(
SvxResId( RID_SVXSTR_PATTERN_UNTITLED ) );
325 OUString aDesc(
CuiResId( RID_CUISTR_DESC_NEW_PATTERN ) );
330 bool bValidPatternName =
false;
332 while( !bValidPatternName )
334 aName = aNewName +
" " + OUString::number( j++ );
335 bValidPatternName = (SearchPatternList(
aName) == -1);
340 sal_uInt16 nError(1);
342 while( pDlg->Execute() ==
RET_OK )
344 pDlg->GetName(
aName );
346 bValidPatternName = (SearchPatternList(
aName) == -1);
348 if( bValidPatternName ) {
354 std::unique_ptr<weld::MessageDialog> xWarnBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
355 if (xWarnBox->run() !=
RET_OK)
363 std::unique_ptr<XBitmapEntry> pEntry;
364 if( m_xCtlPixel->IsEnabled() )
366 const BitmapEx aBitmapEx(m_xBitmapCtl->GetBitmapEx());
377 assert(!
"SvxPatternTabPage::ClickAddHdl_Impl(), XBitmapEntry* pEntry == nullptr ?");
382 m_pPatternList->Insert(std::move(pEntry),
nCount);
383 sal_Int32
nId = m_xPatternLB->GetItemId(
nCount - 1 );
384 BitmapEx aBitmap = m_pPatternList->GetBitmapForPreview(
nCount, m_xPatternLB->GetIconSize() );
386 m_xPatternLB->SelectItem(
nId + 1 );
387 m_xPatternLB->Resize();
389 *m_pnPatternListState |= ChangeType::MODIFIED;
391 ChangePatternHdl_Impl(m_xPatternLB.get());
396 if( m_pPatternList->Count() )
398 m_xBtnModify->set_sensitive(
true);
404 sal_uInt16
nId = m_xPatternLB->GetSelectedItemId();
405 size_t nPos = m_xPatternLB->GetSelectItemPos();
410 OUString
aName( m_pPatternList->GetBitmap(
static_cast<sal_uInt16
>(
nPos) )->GetName() );
412 const BitmapEx aBitmapEx(m_xBitmapCtl->GetBitmapEx());
415 m_pPatternList->Replace(std::make_unique<XBitmapEntry>(
Graphic(aBitmapEx),
aName),
nPos);
417 BitmapEx aBitmap = m_pPatternList->GetBitmapForPreview(
static_cast<sal_uInt16
>(
nPos ), m_xPatternLB->GetIconSize() );
418 m_xPatternLB->RemoveItem(
nId);
419 m_xPatternLB->InsertItem(
nId,
Image(aBitmap),
aName,
static_cast<sal_uInt16
>(
nPos) );
420 m_xPatternLB->SelectItem(
nId );
422 *m_pnPatternListState |= ChangeType::MODIFIED;
428 size_t nPos = m_xPatternLB->GetSelectItemPos();
429 sal_Int32
nId = m_xPatternLB->GetSelectedItemId();
434 OUString aDesc(
CuiResId(RID_CUISTR_DESC_NEW_PATTERN));
435 OUString
aName(m_pPatternList->GetBitmap(
nPos)->GetName());
442 while( bLoop && pDlg->Execute() ==
RET_OK )
444 pDlg->GetName(
aName );
445 sal_Int32 nPatternPos = SearchPatternList(
aName);
446 bool bValidPatternName = (nPatternPos ==
static_cast<sal_Int32
>(
nPos) ) || (nPatternPos == -1);
448 if( bValidPatternName )
452 m_pPatternList->GetBitmap(
nPos)->SetName(
aName);
454 m_xPatternLB->SetItemText(
nId,
aName );
455 m_xPatternLB->SelectItem(
nId );
457 *m_pnPatternListState |= ChangeType::MODIFIED;
462 std::unique_ptr<weld::MessageDialog> xWarnBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
470 sal_uInt16
nId = m_xPatternLB->GetSelectedItemId();
471 size_t nPos = m_xPatternLB->GetSelectItemPos();
476 std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog(
"AskDelBitmapDialog"));
477 if (xQueryBox->run() ==
RET_YES)
479 m_pPatternList->Remove(
nPos);
480 m_xPatternLB->RemoveItem(
nId );
481 nId = m_xPatternLB->GetItemId(0);
482 m_xPatternLB->SelectItem(
nId );
483 m_xPatternLB->Resize();
485 m_aCtlPreview.Invalidate();
486 m_xCtlPixel->Invalidate();
488 ChangePatternHdl_Impl(m_xPatternLB.get());
490 *m_pnPatternListState |= ChangeType::MODIFIED;
494 if( !m_pPatternList->Count() )
496 m_xBtnModify->set_sensitive(
false);
503 m_xPatternLB->SetNoSelection();
539 bool bValidPatternName =
true;
547 bValidPatternName =
false;
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
OUString const & GetName() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=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
BitmapEx GetBitmapEx() const
void SetBmpArray(std::array< sal_uInt8, 64 > const &pPixel)
void SetBackgroundColor(Color aColor)
void SetPixelColor(Color aColor)
std::array< sal_uInt8, 64 > const * pBmpArray
SvxPatternTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
virtual void ActivatePage(const SfxItemSet &rSet) override
XColorListRef m_pColorList
XPatternListRef m_pPatternList
std::unique_ptr< weld::Button > m_xBtnModify
virtual void Reset(const SfxItemSet *) override
std::unique_ptr< weld::CustomWeld > m_xPatternLBWin
std::unique_ptr< ColorListBox > m_xLbColor
virtual bool FillItemSet(SfxItemSet *) override
SvxXRectPreview m_aCtlPreview
virtual ~SvxPatternTabPage() override
std::unique_ptr< weld::CustomWeld > m_xCtlPixelWin
std::unique_ptr< weld::CustomWeld > m_xCtlPreview
std::unique_ptr< weld::Button > m_xBtnAdd
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
std::unique_ptr< SvxPresetListBox > m_xPatternLB
ChangeType * m_pnColorListState
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
XFillAttrSetItem m_aXFillAttr
std::unique_ptr< SvxPixelCtl > m_xCtlPixel
sal_Int32 SearchPatternList(std::u16string_view rPatternName)
virtual void PointChanged(weld::DrawingArea *, RectPoint eRP) override
std::unique_ptr< SvxBitmapCtl > m_xBitmapCtl
std::unique_ptr< ColorListBox > m_xLbBackgroundColor
void SetAttributes(const SfxItemSet &rItemSet)
const GraphicObject & GetGraphicObject() const
const GraphicObject & GetGraphicObject() const
OUString CuiResId(TranslateId aKey)
SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Size SFX2_DLLPUBLIC getDrawPreviewOptimalSize(const OutputDevice &rReference)
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
bool isHistorical8x8(const BitmapEx &rBitmapEx, Color &o_rBack, Color &o_rFront)
BitmapEx createHistorical8x8FromArray(std::array< sal_uInt8, 64 > const &pArray, Color aColorPix, Color aColorBack)
IMPL_LINK_NOARG(SvxPatternTabPage, ChangePatternHdl_Impl, ValueSet *, void)
#define VALUESET_ITEM_NOTFOUND
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)