From 76585ae33f3ca75c05c0ccbf6a621b6e2d42bc00 Mon Sep 17 00:00:00 2001 From: Rishabh Kumar Date: Tue, 7 Jun 2016 16:58:20 +0530 Subject: Convert Bitmap tab to Pattern tab Change-Id: I5cf02f1889090539f7adb826483c91a1ef3c3925 Reviewed-on: https://gerrit.libreoffice.org/26015 Tested-by: Jenkins Reviewed-by: Katarina Behrens --- cui/Library_cui.mk | 2 +- cui/UIConfig_cui.mk | 2 +- cui/source/inc/cuires.hrc | 2 + cui/source/inc/cuitabarea.hxx | 41 +- cui/source/tabpages/strings.src | 8 + cui/source/tabpages/tabarea.cxx | 51 +- cui/source/tabpages/tpbitmap.cxx | 979 -------------------------------------- cui/source/tabpages/tppattern.cxx | 876 ++++++++++++++++++++++++++++++++++ cui/uiconfig/ui/areadialog.ui | 4 +- cui/uiconfig/ui/bitmaptabpage.ui | 347 -------------- cui/uiconfig/ui/patterntabpage.ui | 334 +++++++++++++ 11 files changed, 1286 insertions(+), 1360 deletions(-) delete mode 100644 cui/source/tabpages/tpbitmap.cxx create mode 100644 cui/source/tabpages/tppattern.cxx delete mode 100644 cui/uiconfig/ui/bitmaptabpage.ui create mode 100644 cui/uiconfig/ui/patterntabpage.ui (limited to 'cui') diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk index 7bb181d7f50c..c81ef9625491 100644 --- a/cui/Library_cui.mk +++ b/cui/Library_cui.mk @@ -197,13 +197,13 @@ $(eval $(call gb_Library_add_exception_objects,cui,\ cui/source/tabpages/textanim \ cui/source/tabpages/textattr \ cui/source/tabpages/tparea \ - cui/source/tabpages/tpbitmap \ cui/source/tabpages/tpcolor \ cui/source/tabpages/tpgradnt \ cui/source/tabpages/tphatch \ cui/source/tabpages/tpline \ cui/source/tabpages/tplnedef \ cui/source/tabpages/tplneend \ + cui/source/tabpages/tppattern \ cui/source/tabpages/tpshadow \ cui/source/tabpages/tptrans \ cui/source/tabpages/transfrm \ diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk index b0f72cb6a9ea..60c8d18b84ee 100644 --- a/cui/UIConfig_cui.mk +++ b/cui/UIConfig_cui.mk @@ -27,7 +27,6 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\ cui/uiconfig/ui/autocorrectdialog \ cui/uiconfig/ui/backgroundpage \ cui/uiconfig/ui/baselinksdialog \ - cui/uiconfig/ui/bitmaptabpage \ cui/uiconfig/ui/blackorwhitelistentrydialog \ cui/uiconfig/ui/borderareatransparencydialog \ cui/uiconfig/ui/borderbackgrounddialog \ @@ -145,6 +144,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\ cui/uiconfig/ui/paratabspage \ cui/uiconfig/ui/password \ cui/uiconfig/ui/pastespecial \ + cui/uiconfig/ui/patterntabpage \ cui/uiconfig/ui/percentdialog \ cui/uiconfig/ui/personalization_tab \ cui/uiconfig/ui/pickbulletpage \ diff --git a/cui/source/inc/cuires.hrc b/cui/source/inc/cuires.hrc index 376117cafc9a..67c79e2bb096 100644 --- a/cui/source/inc/cuires.hrc +++ b/cui/source/inc/cuires.hrc @@ -70,6 +70,8 @@ #define RID_SVXSTR_ASK_CHANGE_BITMAP (RID_SVX_START + 172) #define RID_SVXSTR_DESC_NEW_BITMAP (RID_SVX_START + 168) #define RID_SVXSTR_DESC_EXT_BITMAP (RID_SVX_START + 169) +#define RID_SVXSTR_DESC_NEW_PATTERN (RID_SVX_START + 170) +#define RID_SVXSTR_ASK_CHANGE_PATTERN (RID_SVX_START + 171) #define RID_SVXSTR_DESC_LINESTYLE (RID_SVX_START + 174) #define RID_SVXSTR_ASK_CHANGE_LINESTYLE (RID_SVX_START + 177) diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx index d2a0391b00fb..397f3bc97e73 100644 --- a/cui/source/inc/cuitabarea.hxx +++ b/cui/source/inc/cuitabarea.hxx @@ -44,7 +44,8 @@ class SvxAreaTabDialog : public SfxTabDialog sal_uInt16 m_nColorTabPage; sal_uInt16 m_nGradientTabPage; sal_uInt16 m_nHatchTabPage; - sal_uInt16 m_nBitmapTabPage; + //sal_uInt16 m_nBitmapTabPage; + sal_uInt16 m_nPatternTabPage; private: SdrModel* mpDrawModel; @@ -57,11 +58,14 @@ private: XHatchListRef mpNewHatchingList; XBitmapListRef mpBitmapList; XBitmapListRef mpNewBitmapList; + XPatternListRef mpPatternList; + XPatternListRef mpNewPatternList; const SfxItemSet& mrOutAttrs; ChangeType mnColorListState; ChangeType mnBitmapListState; + ChangeType mnPatternListState; ChangeType mnGradientListState; ChangeType mnHatchingListState; @@ -97,6 +101,10 @@ public: void SetNewBitmapList( XBitmapListRef pBmpLst) { mpNewBitmapList = pBmpLst; } const XBitmapListRef& GetNewBitmapList() const { return mpNewBitmapList; } + + void SetNewPatternList( XPatternListRef pPtrnLst ) + { mpNewPatternList = pPtrnLst; } + const XPatternListRef& GetNewPatternList() const { return mpNewPatternList; } }; /************************************************************************/ @@ -545,7 +553,7 @@ public: /************************************************************************/ -class SvxBitmapTabPage : public SvxTabPage +class SvxPatternTabPage : public SvxTabPage { using TabPage::ActivatePage; using TabPage::DeactivatePage; @@ -555,12 +563,11 @@ private: VclPtr m_pCtlPixel; VclPtr m_pLbColor; VclPtr m_pLbBackgroundColor; - VclPtr m_pLbBitmapsHidden; - VclPtr m_pLbBitmaps; + VclPtr m_pLbPatternsHidden; + VclPtr m_pLbPatterns; VclPtr m_pCtlPreview; VclPtr m_pBtnAdd; VclPtr m_pBtnModify; - VclPtr m_pBtnImport; VclPtr m_pBtnDelete; VclPtr m_pBtnLoad; VclPtr m_pBtnSave; @@ -570,37 +577,35 @@ private: const SfxItemSet& m_rOutAttrs; XColorListRef m_pColorList; - XBitmapListRef m_pBitmapList; + XPatternListRef m_pPatternList; - ChangeType* m_pnBitmapListState; + ChangeType* m_pnPatternListState; ChangeType* m_pnColorListState; sal_uInt16* m_pPageType; sal_uInt16 m_nDlgType; sal_Int32* m_pPos; bool* m_pbAreaTP; - bool m_bBmpChanged; + bool m_bPtrnChanged; XFillStyleItem m_aXFStyleItem; - XFillBitmapItem m_aXBitmapItem; + XFillBitmapItem m_aXPatternItem; XFillAttrSetItem m_aXFillAttr; SfxItemSet& m_rXFSet; DECL_LINK_TYPED( ClickAddHdl_Impl, Button*, void ); - DECL_LINK_TYPED( ClickImportHdl_Impl, Button*, void ); DECL_LINK_TYPED( ClickModifyHdl_Impl, Button*, void ); DECL_LINK_TYPED( ClickDeleteHdl_Impl, Button*, void ); - DECL_LINK_TYPED( ChangeBitmapHdl_Impl, ListBox&, void ); - DECL_LINK_TYPED( ChangePixelColorHdl_Impl, ListBox&, void ); - DECL_LINK_TYPED( ChangeBackgrndColorHdl_Impl, ListBox&, void ); + DECL_LINK_TYPED( ChangePatternHdl_Impl, ListBox&, void ); + DECL_LINK_TYPED( ChangeColorHdl_Impl, ListBox&, void ); DECL_LINK_TYPED( ClickLoadHdl_Impl, Button*, void ); DECL_LINK_TYPED( ClickSaveHdl_Impl, Button*, void ); long CheckChanges_Impl(); public: - SvxBitmapTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ); - virtual ~SvxBitmapTabPage(); + SvxPatternTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ); + virtual ~SvxPatternTabPage(); virtual void dispose() override; void Construct(); @@ -615,16 +620,16 @@ public: virtual void PointChanged( vcl::Window* pWindow, RECT_POINT eRP ) override; void SetColorList( XColorListRef pColorList ) { m_pColorList = pColorList; } - void SetBitmapList( XBitmapListRef pBitmapList) { m_pBitmapList = pBitmapList; } + void SetPatternList( XPatternListRef pPatternList) { m_pPatternList = pPatternList; } void SetPageType( sal_uInt16* pInType ) { m_pPageType = pInType; } void SetDlgType( sal_uInt16 nInType ) { m_nDlgType = nInType; } void SetPos( sal_Int32* pInPos ) { m_pPos = pInPos; } void SetAreaTP( bool* pIn ) { m_pbAreaTP = pIn; } - void SetBmpChgd( ChangeType* pIn ) { m_pnBitmapListState = pIn; } + void SetPtrnChgd( ChangeType* pIn ) { m_pnPatternListState = pIn; } void SetColorChgd( ChangeType* pIn ) { m_pnColorListState = pIn; } - + void ChangeColor_Impl(); /** Return a label that is associated with the given control. This label is used to the determine the name for the control. @param pLabeled diff --git a/cui/source/tabpages/strings.src b/cui/source/tabpages/strings.src index db14dd06ae5f..2bf8809c0d97 100644 --- a/cui/source/tabpages/strings.src +++ b/cui/source/tabpages/strings.src @@ -35,10 +35,18 @@ String RID_SVXSTR_DESC_EXT_BITMAP { Text [ en-US ] = "Please enter a name for the external bitmap:" ; }; +String RID_SVXSTR_DESC_NEW_PATTERN +{ + Text [ en-US ] = "Please enter a name for the pattern:" ; +}; String RID_SVXSTR_ASK_CHANGE_BITMAP { Text [ en-US ] = "The bitmap was modified without saving. \nModify the selected bitmap or add a new bitmap." ; }; +String RID_SVXSTR_ASK_CHANGE_PATTERN +{ + Text [ en-US ] = "The pattern was modified without saving. \nModify the selected pattern or add a new pattern"; +}; String RID_SVXSTR_DESC_LINESTYLE { Text [ en-US ] = "Please enter a name for the line style:" ; diff --git a/cui/source/tabpages/tabarea.cxx b/cui/source/tabpages/tabarea.cxx index 6a6ce0394e69..e6b9ae61aa3a 100644 --- a/cui/source/tabpages/tabarea.cxx +++ b/cui/source/tabpages/tabarea.cxx @@ -52,7 +52,8 @@ SvxAreaTabDialog::SvxAreaTabDialog , m_nColorTabPage(0) , m_nGradientTabPage(0) , m_nHatchTabPage(0) - , m_nBitmapTabPage(0) + //, m_nBitmapTabPage(0) + , m_nPatternTabPage(0) , mpDrawModel ( pModel ), mpColorList ( pModel->GetColorList() ), @@ -63,10 +64,13 @@ SvxAreaTabDialog::SvxAreaTabDialog mpNewHatchingList ( pModel->GetHatchList() ), mpBitmapList ( pModel->GetBitmapList() ), mpNewBitmapList ( pModel->GetBitmapList() ), + mpPatternList ( pModel->GetPatternList() ), + mpNewPatternList ( pModel->GetPatternList() ), mrOutAttrs ( *pAttr ), mnColorListState ( ChangeType::NONE ), mnBitmapListState ( ChangeType::NONE ), + mnPatternListState ( ChangeType::NONE ), mnGradientListState ( ChangeType::NONE ), mnHatchingListState ( ChangeType::NONE ), mnPageType( PT_AREA ), @@ -88,7 +92,7 @@ SvxAreaTabDialog::SvxAreaTabDialog m_nColorTabPage = AddTabPage( "RID_SVXPAGE_COLOR", SvxColorTabPage::Create, nullptr ); m_nGradientTabPage = AddTabPage( "RID_SVXPAGE_GRADIENT", SvxGradientTabPage::Create, nullptr ); m_nHatchTabPage = AddTabPage( "RID_SVXPAGE_HATCH", SvxHatchTabPage::Create, nullptr ); - m_nBitmapTabPage = AddTabPage( "RID_SVXPAGE_BITMAP", SvxBitmapTabPage::Create, nullptr); + m_nPatternTabPage = AddTabPage( "RID_SVXPAGE_PATTERN", SvxPatternTabPage::Create, nullptr); SetCurPageId( "RID_SVXPAGE_AREA" ); @@ -139,6 +143,16 @@ void SvxAreaTabDialog::SavePalettes() mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST); mpBitmapList = mpDrawModel->GetBitmapList(); } + if( mpNewPatternList != mpDrawModel->GetPatternList() ) + { + mpDrawModel->SetPropertyList( static_cast(mpNewPatternList.get()) ); + SvxPatternListItem aItem( mpNewPatternList, SID_PATTERN_LIST ); + if( pShell ) + pShell->PutItem( aItem ); + else + mpDrawModel->GetItemPool().Put(aItem,SID_PATTERN_LIST); + mpPatternList = mpDrawModel->GetPatternList(); + } // save the tables when they have been changed @@ -179,6 +193,19 @@ void SvxAreaTabDialog::SavePalettes() } } + if( mnPatternListState & ChangeType::MODIFIED ) + { + mpPatternList->SetPath( aPath ); + mpPatternList->Save(); + + SvxPatternListItem aItem( mpPatternList, SID_PATTERN_LIST ); + // ToolBoxControls are informed: + if( pShell ) + pShell->PutItem( aItem ); + else + mpDrawModel->GetItemPool().Put(aItem); + } + if( mnGradientListState & ChangeType::MODIFIED ) { mpGradientList->SetPath( aPath ); @@ -282,17 +309,17 @@ void SvxAreaTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) static_cast(rPage).SetColorChgd( &mnColorListState ); static_cast(rPage).Construct(); } - else if (nId == m_nBitmapTabPage) + else if (nId == m_nPatternTabPage) { - static_cast(rPage).SetColorList( mpColorList ); - static_cast(rPage).SetBitmapList( mpBitmapList ); - static_cast(rPage).SetPageType( &mnPageType ); - static_cast(rPage).SetDlgType( 0 ); - static_cast(rPage).SetPos( &mnPos ); - static_cast(rPage).SetAreaTP( &mbAreaTP ); - static_cast(rPage).SetBmpChgd( &mnBitmapListState ); - static_cast(rPage).SetColorChgd( &mnColorListState ); - static_cast(rPage).Construct(); + static_cast(rPage).SetColorList( mpColorList ); + static_cast(rPage).SetPatternList( mpPatternList ); + static_cast(rPage).SetPageType( &mnPageType ); + static_cast(rPage).SetDlgType( 0 ); + static_cast(rPage).SetPos( &mnPos ); + static_cast(rPage).SetAreaTP( &mbAreaTP ); + static_cast(rPage).SetPtrnChgd( &mnPatternListState ); + static_cast(rPage).SetColorChgd( &mnColorListState ); + static_cast(rPage).Construct(); } else if (nId == m_nColorTabPage) { diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx deleted file mode 100644 index 05d9b5470017..000000000000 --- a/cui/source/tabpages/tpbitmap.cxx +++ /dev/null @@ -1,979 +0,0 @@ -/* -*- 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include "com/sun/star/ui/dialogs/TemplateDescription.hpp" -#include -#include -#include -#include - -#include -#include "helpid.hrc" -#include "svx/xattr.hxx" -#include -#include -#include "svx/xoutbmp.hxx" -#include "svx/drawitem.hxx" -#include "cuitabarea.hxx" -#include "defdlgname.hxx" -#include "dlgname.hxx" -#include -#include -#include "sfx2/opengrf.hxx" -#include "paragrph.hrc" - -using namespace com::sun::star; - -SvxBitmapTabPage::SvxBitmapTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs) : - - SvxTabPage ( pParent, - "BitmapTabPage", - "cui/ui/bitmaptabpage.ui", - rInAttrs ), - m_rOutAttrs ( rInAttrs ), - - m_pnBitmapListState ( nullptr ), - m_pnColorListState ( nullptr ), - m_pPageType ( nullptr ), - m_nDlgType ( 0 ), - m_pPos ( nullptr ), - m_pbAreaTP ( nullptr ), - - m_bBmpChanged ( false ), - - m_aXFStyleItem ( drawing::FillStyle_BITMAP ), - m_aXBitmapItem ( OUString(), Graphic() ), - m_aXFillAttr ( rInAttrs.GetPool() ), - m_rXFSet ( m_aXFillAttr.GetItemSet() ) -{ - get(m_pBxPixelEditor,"maingrid"); - get(m_pCtlPixel,"CTL_PIXEL"); - get(m_pLbColor,"LB_COLOR"); - get(m_pLbBackgroundColor,"LB_BACKGROUND_COLOR"); - get(m_pCtlPreview,"CTL_PREVIEW"); - get(m_pLbBitmaps,"LB_BITMAPS"); - get(m_pLbBitmapsHidden,"FT_BITMAPS_HIDDEN"); - get(m_pBtnAdd,"BTN_ADD"); - get(m_pBtnModify,"BTN_MODIFY"); - get(m_pBtnImport,"BTN_IMPORT"); - get(m_pBtnDelete,"BTN_DELETE"); - get(m_pBtnLoad,"BTN_LOAD"); - get(m_pBtnSave,"BTN_SAVE"); - - // size of the bitmap listbox - Size aSize = getDrawListBoxOptimalSize(this); - m_pLbBitmaps->set_width_request(aSize.Width()); - m_pLbBitmaps->set_height_request(aSize.Height()); - - // size of the bitmap display - Size aSize2 = getDrawPreviewOptimalSize(this); - m_pCtlPreview->set_width_request(aSize2.Width()); - m_pCtlPreview->set_height_request(aSize2.Height()); - - m_pBitmapCtl = new SvxBitmapCtl; - - // this page needs ExchangeSupport - SetExchangeSupport(); - - // setting the output device - m_rXFSet.Put( m_aXFStyleItem ); - m_rXFSet.Put( m_aXBitmapItem ); - - m_pBtnAdd->SetClickHdl( LINK( this, SvxBitmapTabPage, ClickAddHdl_Impl ) ); - m_pBtnImport->SetClickHdl( LINK( this, SvxBitmapTabPage, ClickImportHdl_Impl ) ); - m_pBtnModify->SetClickHdl( LINK( this, SvxBitmapTabPage, ClickModifyHdl_Impl ) ); - m_pBtnDelete->SetClickHdl( LINK( this, SvxBitmapTabPage, ClickDeleteHdl_Impl ) ); - m_pBtnLoad->SetClickHdl( LINK( this, SvxBitmapTabPage, ClickLoadHdl_Impl ) ); - m_pBtnSave->SetClickHdl( LINK( this, SvxBitmapTabPage, ClickSaveHdl_Impl ) ); - - m_pLbBitmaps->SetSelectHdl( LINK( this, SvxBitmapTabPage, ChangeBitmapHdl_Impl ) ); - m_pLbColor->SetSelectHdl( LINK( this, SvxBitmapTabPage, ChangePixelColorHdl_Impl ) ); - m_pLbBackgroundColor->SetSelectHdl( LINK( this, SvxBitmapTabPage, ChangeBackgrndColorHdl_Impl ) ); - - setPreviewsToSamePlace(pParent, this); -} - -SvxBitmapTabPage::~SvxBitmapTabPage() -{ - disposeOnce(); -} - -void SvxBitmapTabPage::dispose() -{ - delete m_pBitmapCtl; - m_pBitmapCtl = nullptr; - m_pBxPixelEditor.clear(); - m_pCtlPixel.clear(); - m_pLbColor.clear(); - m_pLbBackgroundColor.clear(); - m_pLbBitmapsHidden.clear(); - m_pLbBitmaps.clear(); - m_pCtlPreview.clear(); - m_pBtnAdd.clear(); - m_pBtnModify.clear(); - m_pBtnImport.clear(); - m_pBtnDelete.clear(); - m_pBtnLoad.clear(); - m_pBtnSave.clear(); - SvxTabPage::dispose(); -} - -void SvxBitmapTabPage::Construct() -{ - m_pLbColor->Fill( m_pColorList ); - m_pLbBackgroundColor->CopyEntries( *m_pLbColor ); - - m_pLbBitmaps->Fill( m_pBitmapList ); -} - - -void SvxBitmapTabPage::ActivatePage( const SfxItemSet& ) -{ - sal_Int32 nPos; - sal_Int32 nCount; - - if( m_nDlgType == 0 ) // area dialog - { - *m_pbAreaTP = false; - - if( m_pColorList.is() ) - { - // ColorList - if( *m_pnColorListState & ChangeType::CHANGED || - *m_pnColorListState & ChangeType::MODIFIED ) - { - if( *m_pnColorListState & ChangeType::CHANGED ) - m_pColorList = static_cast( GetParentDialog() )->GetNewColorList(); - - // LbColor - nPos = m_pLbColor->GetSelectEntryPos(); - m_pLbColor->Clear(); - m_pLbColor->Fill( m_pColorList ); - nCount = m_pLbColor->GetEntryCount(); - if( nCount == 0 ) - ; // this case should not occur - else if( nCount <= nPos ) - m_pLbColor->SelectEntryPos( 0 ); - else - m_pLbColor->SelectEntryPos( nPos ); - - // LbColorBackground - nPos = m_pLbBackgroundColor->GetSelectEntryPos(); - m_pLbBackgroundColor->Clear(); - m_pLbBackgroundColor->CopyEntries( *m_pLbColor ); - nCount = m_pLbBackgroundColor->GetEntryCount(); - if( nCount == 0 ) - ; // this case should not occur - else if( nCount <= nPos ) - m_pLbBackgroundColor->SelectEntryPos( 0 ); - else - m_pLbBackgroundColor->SelectEntryPos( nPos ); - - ChangePixelColorHdl_Impl( *m_pLbColor ); - ChangeBackgrndColorHdl_Impl( *m_pLbBackgroundColor ); - } - - // determining (possibly cutting) the name and - // displaying it in the GroupBox - OUString aString( CUI_RES( RID_SVXSTR_TABLE ) ); - aString += ": "; - INetURLObject aURL( m_pBitmapList->GetPath() ); - - aURL.Append( m_pBitmapList->GetName() ); - DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); - - if( aURL.getBase().getLength() > 18 ) - { - aString += aURL.getBase().copy( 0, 15 ); - aString += "..."; - } - else - aString += aURL.getBase(); - - if( *m_pPageType == PT_BITMAP && *m_pPos != LISTBOX_ENTRY_NOTFOUND ) - { - m_pLbBitmaps->SelectEntryPos( *m_pPos ); - } - // colors could have been deleted - ChangeBitmapHdl_Impl( *m_pLbBitmaps ); - - *m_pPageType = PT_BITMAP; - *m_pPos = LISTBOX_ENTRY_NOTFOUND; - } - } -} - - -DeactivateRC SvxBitmapTabPage::DeactivatePage( SfxItemSet* _pSet) -{ - if ( CheckChanges_Impl() == -1L ) - return DeactivateRC::KeepPage; - - if( _pSet ) - FillItemSet( _pSet ); - - return DeactivateRC::LeavePage; -} - - -bool SvxBitmapTabPage::FillItemSet( SfxItemSet* _rOutAttrs ) -{ - if( m_nDlgType == 0 && !*m_pbAreaTP ) // area dialog - { - if(PT_BITMAP == *m_pPageType) - { - _rOutAttrs->Put(XFillStyleItem(drawing::FillStyle_BITMAP)); - sal_Int32 nPos = m_pLbBitmaps->GetSelectEntryPos(); - if(LISTBOX_ENTRY_NOTFOUND != nPos) - { - const XBitmapEntry* pXBitmapEntry = m_pBitmapList->GetBitmap(nPos); - const OUString aString(m_pLbBitmaps->GetSelectEntry()); - - _rOutAttrs->Put(XFillBitmapItem(aString, pXBitmapEntry->GetGraphicObject())); - } - else - { - const BitmapEx aBitmapEx(m_pBitmapCtl->GetBitmapEx()); - - _rOutAttrs->Put(XFillBitmapItem(OUString(), Graphic(aBitmapEx))); - } - } - } - - return true; -} - - -void SvxBitmapTabPage::Reset( const SfxItemSet* ) -{ - // aLbBitmaps.SelectEntryPos( 0 ); - - m_pBitmapCtl->SetLines( m_pCtlPixel->GetLineCount() ); - m_pBitmapCtl->SetPixelColor( m_pLbColor->GetSelectEntryColor() ); - m_pBitmapCtl->SetBackgroundColor( m_pLbBackgroundColor->GetSelectEntryColor() ); - m_pBitmapCtl->SetBmpArray( m_pCtlPixel->GetBitmapPixelPtr() ); - - // get bitmap and display it - const XFillBitmapItem aBmpItem(OUString(), Graphic(m_pBitmapCtl->GetBitmapEx())); - m_rXFSet.Put( aBmpItem ); - m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() ); - m_pCtlPreview->Invalidate(); - - ChangeBitmapHdl_Impl( *m_pLbBitmaps ); - - // determine button state - if( m_pBitmapList.is() && m_pBitmapList->Count() ) - { - m_pBtnAdd->Enable(); - m_pBtnModify->Enable(); - m_pBtnDelete->Enable(); - m_pBtnSave->Enable(); - } - else - { - m_pBtnModify->Disable(); - m_pBtnDelete->Disable(); - m_pBtnSave->Disable(); - } -} - - -VclPtr SvxBitmapTabPage::Create( vcl::Window* pWindow, - const SfxItemSet* rSet ) -{ - return VclPtr::Create( pWindow, *rSet ); -} - - -IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ChangeBitmapHdl_Impl, ListBox&, void) -{ - std::unique_ptr pGraphicObject; - int nPos(m_pLbBitmaps->GetSelectEntryPos()); - - if(LISTBOX_ENTRY_NOTFOUND != nPos) - { - pGraphicObject.reset(new GraphicObject(m_pBitmapList->GetBitmap(nPos)->GetGraphicObject())); - } - else - { - const SfxPoolItem* pPoolItem = nullptr; - - if(SfxItemState::SET == m_rOutAttrs.GetItemState(GetWhich(XATTR_FILLSTYLE), true, &pPoolItem)) - { - const drawing::FillStyle eXFS((drawing::FillStyle)static_cast(pPoolItem)->GetValue()); - - if((drawing::FillStyle_BITMAP == eXFS) && (SfxItemState::SET == m_rOutAttrs.GetItemState(GetWhich(XATTR_FILLBITMAP), true, &pPoolItem))) - { - pGraphicObject.reset(new GraphicObject(static_cast(pPoolItem)->GetGraphicObject())); - } - } - - if(!pGraphicObject) - { - m_pLbBitmaps->SelectEntryPos(0); - nPos = m_pLbBitmaps->GetSelectEntryPos(); - - if(LISTBOX_ENTRY_NOTFOUND != nPos) - { - pGraphicObject.reset(new GraphicObject(m_pBitmapList->GetBitmap(nPos)->GetGraphicObject())); - } - } - } - - if(pGraphicObject) - { - BitmapColor aBack; - BitmapColor aFront; - bool bIs8x8(isHistorical8x8(pGraphicObject->GetGraphic().GetBitmap(), aBack, aFront)); - - m_pLbColor->SetNoSelection(); - m_pLbBackgroundColor->SetNoSelection(); - - if(bIs8x8) - { - m_pCtlPixel->SetPaintable( true ); - m_pBxPixelEditor->Enable(); - m_pBtnModify->Enable(); - m_pBtnAdd->Enable(); - - // setting the pixel control - - m_pCtlPixel->SetXBitmap(pGraphicObject->GetGraphic().GetBitmapEx()); - - Color aPixelColor = aFront; - Color aBackColor = aBack; - - // #i123564# This causes the wrong color to be selected - // as foreground color when the 1st bitmap in the bitmap - // list is selected. I see no reason why this is done, - // thus I will take it out - - //if( 0 == m_pLbBitmaps->GetSelectEntryPos() ) - //{ - // m_pLbColor->SelectEntry( Color( COL_BLACK ) ); - // ChangePixelColorHdl_Impl( this ); - //} - //else - - m_pLbColor->SelectEntry( aPixelColor ); - - if( m_pLbColor->GetSelectEntryCount() == 0 ) - { - m_pLbColor->InsertEntry( aPixelColor, OUString() ); - m_pLbColor->SelectEntry( aPixelColor ); - } - - m_pLbBackgroundColor->SelectEntry( aBackColor ); - - if( m_pLbBackgroundColor->GetSelectEntryCount() == 0 ) - { - m_pLbBackgroundColor->InsertEntry( aBackColor, OUString() ); - m_pLbBackgroundColor->SelectEntry( aBackColor ); - } - - // update m_pBitmapCtl, rXFSet and m_pCtlPreview - m_pBitmapCtl->SetPixelColor( aPixelColor ); - m_pBitmapCtl->SetBackgroundColor( aBackColor ); - m_rXFSet.Put(XFillBitmapItem(OUString(), Graphic(m_pBitmapCtl->GetBitmapEx()))); - m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() ); - m_pCtlPreview->Invalidate(); - } - else - { - m_pCtlPixel->Reset(); - m_pCtlPixel->SetPaintable( false ); - m_pBxPixelEditor->Disable(); - m_pBtnModify->Disable(); - m_pBtnAdd->Disable(); - } - - m_pCtlPixel->Invalidate(); - - // display bitmap - const XFillBitmapItem aXBmpItem(OUString(), *pGraphicObject); - m_rXFSet.Put( aXBmpItem ); - - m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() ); - m_pCtlPreview->Invalidate(); - - m_bBmpChanged = false; - } -} - - -long SvxBitmapTabPage::CheckChanges_Impl() -{ - sal_Int32 nPos = m_pLbBitmaps->GetSelectEntryPos(); - if( nPos != LISTBOX_ENTRY_NOTFOUND ) - { - if( m_bBmpChanged ) - { - ResMgr& rMgr = CUI_MGR(); - Image aWarningBoxImage = WarningBox::GetStandardImage(); - ScopedVclPtrInstance aMessDlg( GetParentDialog(), - SVX_RES( RID_SVXSTR_BITMAP ), - CUI_RES( RID_SVXSTR_ASK_CHANGE_BITMAP ), - &aWarningBoxImage ); - DBG_ASSERT(aMessDlg, "Dialog creation failed!"); - aMessDlg->SetButtonText( SvxMessDialogButton::N1, ResId( RID_SVXSTR_CHANGE, rMgr ) ); - aMessDlg->SetButtonText( SvxMessDialogButton::N2, ResId( RID_SVXSTR_ADD, rMgr ) ); - - short nRet = aMessDlg->Execute(); - - switch( nRet ) - { - case RET_BTN_1: - { - ClickModifyHdl_Impl( nullptr ); - } - break; - - case RET_BTN_2: - { - ClickAddHdl_Impl( nullptr ); - } - break; - - case RET_CANCEL: - break; - } - } - } - nPos = m_pLbBitmaps->GetSelectEntryPos(); - if( nPos != LISTBOX_ENTRY_NOTFOUND ) - *m_pPos = nPos; - return 0L; -} - - -IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ClickAddHdl_Impl, Button*, void) -{ - - OUString aNewName( SVX_RES( RID_SVXSTR_BITMAP ) ); - OUString aDesc( CUI_RES( RID_SVXSTR_DESC_NEW_BITMAP ) ); - OUString aName; - - long nCount = m_pBitmapList->Count(); - long j = 1; - bool bDifferent = false; - - while( !bDifferent ) - { - aName = aNewName; - aName += " "; - aName += OUString::number( j++ ); - bDifferent = true; - - for( long i = 0; i < nCount && bDifferent; i++ ) - if( aName == m_pBitmapList->GetBitmap( i )->GetName() ) - bDifferent = false; - } - - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - DBG_ASSERT(pFact, "Dialog creation failed!"); - std::unique_ptr pDlg(pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc )); - DBG_ASSERT(pDlg, "Dialog creation failed!"); - ScopedVclPtr pWarnBox; - sal_uInt16 nError(1); - - while( pDlg->Execute() == RET_OK ) - { - pDlg->GetName( aName ); - - bDifferent = true; - - for( long i = 0; i < nCount && bDifferent; i++ ) - if( aName == m_pBitmapList->GetBitmap( i )->GetName() ) - bDifferent = false; - - if( bDifferent ) { - nError = 0; - break; - } - - if( !pWarnBox ) - { - pWarnBox.disposeAndReset(VclPtr::Create( GetParentDialog() - ,"DuplicateNameDialog" - ,"cui/ui/queryduplicatedialog.ui")); - } - - if( pWarnBox->Execute() != RET_OK ) - break; - } - - pDlg.reset(); - pWarnBox.disposeAndClear(); - - if( !nError ) - { - XBitmapEntry* pEntry = nullptr; - if( m_pCtlPixel->IsEnabled() ) - { - const BitmapEx aBitmapEx(m_pBitmapCtl->GetBitmapEx()); - - pEntry = new XBitmapEntry(Graphic(aBitmapEx), aName); - } - else // it must be a not existing imported bitmap - { - const SfxPoolItem* pPoolItem = nullptr; - - if(SfxItemState::SET == m_rOutAttrs.GetItemState(XATTR_FILLBITMAP, true, &pPoolItem)) - { - pEntry = new XBitmapEntry(dynamic_cast< const XFillBitmapItem* >(pPoolItem)->GetGraphicObject(), aName); - } - } - - DBG_ASSERT( pEntry, "SvxBitmapTabPage::ClickAddHdl_Impl(), pEntry == 0 ?" ); - - if( pEntry ) - { - m_pBitmapList->Insert( pEntry ); - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - m_pLbBitmaps->Append(rStyleSettings.GetListBoxPreviewDefaultPixelSize(), *pEntry ); - m_pLbBitmaps->SelectEntryPos( m_pLbBitmaps->GetEntryCount() - 1 ); - - *m_pnBitmapListState |= ChangeType::MODIFIED; - - ChangeBitmapHdl_Impl( *m_pLbBitmaps ); - } - } - - // determine button state - if( m_pBitmapList->Count() ) - { - m_pBtnModify->Enable(); - m_pBtnDelete->Enable(); - m_pBtnSave->Enable(); - } -} - - -/******************************************************************************/ -/******************************************************************************/ - - -IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ClickImportHdl_Impl, Button*, void) -{ - ResMgr& rMgr = CUI_MGR(); - SvxOpenGraphicDialog aDlg( OUString("Import") ); - aDlg.EnableLink(false); - - if( !aDlg.Execute() ) - { - Graphic aGraphic; - - EnterWait(); - int nError = aDlg.GetGraphic( aGraphic ); - LeaveWait(); - - if( !nError ) - { - OUString aDesc( ResId(RID_SVXSTR_DESC_EXT_BITMAP, rMgr) ); - ScopedVclPtr pWarnBox; - - // convert file URL to UI name - OUString aName; - INetURLObject aURL( aDlg.GetPath() ); - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - DBG_ASSERT(pFact, "Dialog creation failed!"); - std::unique_ptr pDlg(pFact->CreateSvxNameDialog( GetParentDialog(), aURL.GetName().getToken( 0, '.' ), aDesc )); - DBG_ASSERT(pDlg, "Dialog creation failed!"); - nError = 1; - - while( pDlg->Execute() == RET_OK ) - { - pDlg->GetName( aName ); - - bool bDifferent = true; - long nCount = m_pBitmapList->Count(); - - for( long i = 0; i < nCount && bDifferent; i++ ) - if( aName == m_pBitmapList->GetBitmap( i )->GetName() ) - bDifferent = false; - - if( bDifferent ) { - nError = 0; - break; - } - - if( !pWarnBox ) - { - pWarnBox.disposeAndReset(VclPtr::Create( GetParentDialog() - ,"DuplicateNameDialog" - ,"cui/ui/queryduplicatedialog.ui")); - } - - if( pWarnBox->Execute() != RET_OK ) - break; - } - - pDlg.reset(); - pWarnBox.disposeAndClear(); - - if( !nError ) - { - XBitmapEntry* pEntry = new XBitmapEntry( aGraphic, aName ); - m_pBitmapList->Insert( pEntry ); - - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - m_pLbBitmaps->Append(rStyleSettings.GetListBoxPreviewDefaultPixelSize(), *pEntry ); - m_pLbBitmaps->SelectEntryPos( m_pLbBitmaps->GetEntryCount() - 1 ); - - *m_pnBitmapListState |= ChangeType::MODIFIED; - - ChangeBitmapHdl_Impl( *m_pLbBitmaps ); - } - } - else - // graphic couldn't be loaded - ScopedVclPtrInstance::Create( GetParentDialog() - ,"NoLoadedFileDialog" - ,"cui/ui/querynoloadedfiledialog.ui")->Execute(); - } -} - - -IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ClickModifyHdl_Impl, Button*, void) -{ - sal_Int32 nPos = m_pLbBitmaps->GetSelectEntryPos(); - - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - { - ResMgr& rMgr = CUI_MGR(); - OUString aDesc( ResId( RID_SVXSTR_DESC_NEW_BITMAP, rMgr ) ); - OUString aName( m_pBitmapList->GetBitmap( nPos )->GetName() ); - OUString aOldName = aName; - - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - DBG_ASSERT(pFact, "Dialog creation failed!"); - std::unique_ptr pDlg(pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc )); - DBG_ASSERT(pDlg, "Dialog creation failed!"); - - long nCount = m_pBitmapList->Count(); - bool bLoop = true; - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - - while( bLoop && pDlg->Execute() == RET_OK ) - { - pDlg->GetName( aName ); - bool bDifferent = true; - - for( long i = 0; i < nCount && bDifferent; i++ ) - { - if( aName == m_pBitmapList->GetBitmap( i )->GetName() && - aName != aOldName ) - bDifferent = false; - } - - if( bDifferent ) - { - bLoop = false; - - const BitmapEx aBitmapEx(m_pBitmapCtl->GetBitmapEx()); - - // #i123497# Need to replace the existing entry with a new one (old returned needs to be deleted) - XBitmapEntry* pEntry = new XBitmapEntry(Graphic(aBitmapEx), aName); - delete m_pBitmapList->Replace(pEntry, nPos); - - m_pLbBitmaps->Modify( rStyleSettings.GetListBoxPreviewDefaultPixelSize(), *pEntry, nPos ); - m_pLbBitmaps->SelectEntryPos( nPos ); - - *m_pnBitmapListState |= ChangeType::MODIFIED; - - m_bBmpChanged = false; - } - else - { - ScopedVclPtrInstance aBox( - GetParentDialog() - ,"DuplicateNameDialog" - ,"cui/ui/queryduplicatedialog.ui"); - aBox->Execute(); - } - } - } -} - - -IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ClickDeleteHdl_Impl, Button*, void) -{ - sal_Int32 nPos = m_pLbBitmaps->GetSelectEntryPos(); - - if( nPos != LISTBOX_ENTRY_NOTFOUND ) - { - ScopedVclPtrInstance< MessageDialog > aQueryBox( GetParentDialog(),"AskDelBitmapDialog","cui/ui/querydeletebitmapdialog.ui" ); - - if( aQueryBox->Execute() == RET_YES ) - { - delete m_pBitmapList->Remove( nPos ); - m_pLbBitmaps->RemoveEntry( nPos ); - m_pLbBitmaps->SelectEntryPos( 0 ); - - m_pCtlPreview->Invalidate(); - m_pCtlPixel->Invalidate(); - - ChangeBitmapHdl_Impl( *m_pLbBitmaps ); - - *m_pnBitmapListState |= ChangeType::MODIFIED; - } - } - // determine button state - if( !m_pBitmapList->Count() ) - { - m_pBtnModify->Disable(); - m_pBtnDelete->Disable(); - m_pBtnSave->Disable(); - } -} - - -IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ClickLoadHdl_Impl, Button*, void) -{ - sal_uInt16 nReturn = RET_YES; - ResMgr& rMgr = CUI_MGR(); - - if ( *m_pnBitmapListState & ChangeType::MODIFIED ) - { - nReturn = ScopedVclPtrInstance::Create( GetParentDialog() - ,"AskSaveList" - ,"cui/ui/querysavelistdialog.ui")->Execute(); - - if ( nReturn == RET_YES ) - m_pBitmapList->Save(); - } - - if ( nReturn != RET_CANCEL ) - { - ::sfx2::FileDialogHelper aDlg( css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE ); - OUString aStrFilterType( "*.sob" ); - aDlg.AddFilter( aStrFilterType, aStrFilterType ); - OUString aPalettePath(SvtPathOptions().GetPalettePath()); - OUString aLastDir; - sal_Int32 nIndex = 0; - do - { - aLastDir = aPalettePath.getToken(0, ';', nIndex); - } - while (nIndex >= 0); - - INetURLObject aFile(aLastDir); - aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) ); - - if ( aDlg.Execute() == ERRCODE_NONE ) - { - EnterWait(); - INetURLObject aURL( aDlg.GetPath() ); - INetURLObject aPathURL( aURL ); - - aPathURL.removeSegment(); - aPathURL.removeFinalSlash(); - - // save table - XBitmapListRef pBmpList = XPropertyList::AsBitmapList( - XPropertyList::CreatePropertyList( - XBITMAP_LIST, aPathURL.GetMainURL(INetURLObject::NO_DECODE), - "")); - pBmpList->SetName( aURL.getName() ); - if( pBmpList->Load() ) - { - m_pBitmapList = pBmpList; - static_cast( GetParentDialog() )->SetNewBitmapList( m_pBitmapList ); - - m_pLbBitmaps->Clear(); - m_pLbBitmaps->Fill( m_pBitmapList ); - Reset( &m_rOutAttrs ); - - m_pBitmapList->SetName( aURL.getName() ); - - // determining (possibly cutting) the name - // displaying it in the GroupBox - OUString aString( ResId( RID_SVXSTR_TABLE, rMgr ) ); - aString += ": "; - - if ( aURL.getBase().getLength() > 18 ) - { - aString += aURL.getBase().copy( 0, 15 ); - aString += "..."; - } - else - aString += aURL.getBase(); - - *m_pnBitmapListState |= ChangeType::CHANGED; - *m_pnBitmapListState &= ~ChangeType::MODIFIED; - LeaveWait(); - } - else - { - LeaveWait(); - ScopedVclPtrInstance::Create( GetParentDialog() - ,"NoLoadedFileDialog" - ,"cui/ui/querynoloadedfiledialog.ui")->Execute(); - } - } - } - - // determine button state - if( m_pBitmapList->Count() ) - { - m_pBtnModify->Enable(); - m_pBtnDelete->Enable(); - m_pBtnSave->Enable(); - } - else - { - m_pBtnModify->Disable(); - m_pBtnDelete->Disable(); - m_pBtnSave->Disable(); - } -} - - -IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ClickSaveHdl_Impl, Button*, void) -{ - ::sfx2::FileDialogHelper aDlg( css::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE ); - OUString aStrFilterType( "*.sob" ); - aDlg.AddFilter( aStrFilterType, aStrFilterType ); - - OUString aPalettePath(SvtPathOptions().GetPalettePath()); - OUString aLastDir; - sal_Int32 nIndex = 0; - do - { - aLastDir = aPalettePath.getToken(0, ';', nIndex); - } - while (nIndex >= 0); - - INetURLObject aFile(aLastDir); - DBG_ASSERT( aFile.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); - - if( !m_pBitmapList->GetName().isEmpty() ) - { - aFile.Append( m_pBitmapList->GetName() ); - - if( aFile.getExtension().isEmpty() ) - aFile.SetExtension( "sob" ); - } - - aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) ); - if ( aDlg.Execute() == ERRCODE_NONE ) - { - INetURLObject aURL( aDlg.GetPath() ); - INetURLObject aPathURL( aURL ); - - aPathURL.removeSegment(); - aPathURL.removeFinalSlash(); - - m_pBitmapList->SetName( aURL.getName() ); - m_pBitmapList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) ); - - if( m_pBitmapList->Save() ) - { - // determining (possibly cutting) the name - // displaying it in the GroupBox - OUString aString( CUI_RES( RID_SVXSTR_TABLE ) ); - aString += ": "; - - if ( aURL.getBase().getLength() > 18 ) - { - aString += aURL.getBase().copy( 0, 15 ); - aString += "..."; - } - else - aString += aURL.getBase(); - - *m_pnBitmapListState |= ChangeType::SAVED; - *m_pnBitmapListState &= ~ChangeType::MODIFIED; - } - else - { - ScopedVclPtrInstance::Create( GetParentDialog() - ,"NoSaveFileDialog" - ,"cui/ui/querynosavefiledialog.ui")->Execute(); - } - } -} - - -IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ChangePixelColorHdl_Impl, ListBox&, void) -{ - m_pCtlPixel->SetPixelColor( m_pLbColor->GetSelectEntryColor() ); - m_pCtlPixel->Invalidate(); - - m_pBitmapCtl->SetPixelColor( m_pLbColor->GetSelectEntryColor() ); - - // get bitmap and display it - m_rXFSet.Put(XFillBitmapItem(OUString(), Graphic(m_pBitmapCtl->GetBitmapEx()))); - m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() ); - m_pCtlPreview->Invalidate(); - - m_bBmpChanged = true; -} - - -IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ChangeBackgrndColorHdl_Impl, ListBox&, void) -{ - m_pCtlPixel->SetBackgroundColor( m_pLbBackgroundColor->GetSelectEntryColor() ); - m_pCtlPixel->Invalidate(); - - m_pBitmapCtl->SetBackgroundColor( m_pLbBackgroundColor->GetSelectEntryColor() ); - - // get bitmap and display it - m_rXFSet.Put(XFillBitmapItem(OUString(), Graphic(m_pBitmapCtl->GetBitmapEx()))); - m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() ); - m_pCtlPreview->Invalidate(); - - m_bBmpChanged = true; -} - - -void SvxBitmapTabPage::PointChanged( vcl::Window* pWindow, RECT_POINT ) -{ - if( pWindow == m_pCtlPixel ) - { - m_pBitmapCtl->SetBmpArray( m_pCtlPixel->GetBitmapPixelPtr() ); - - // get bitmap and display it - m_rXFSet.Put(XFillBitmapItem(OUString(), Graphic(m_pBitmapCtl->GetBitmapEx()))); - m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() ); - m_pCtlPreview->Invalidate(); - - m_bBmpChanged = true; - } -} - - -vcl::Window* SvxBitmapTabPage::GetParentLabeledBy( const vcl::Window* pLabeled ) const -{ - if (pLabeled == m_pLbBitmaps) - return m_pLbBitmapsHidden.get(); - else - return SvxTabPage::GetParentLabeledBy (pLabeled); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/tabpages/tppattern.cxx b/cui/source/tabpages/tppattern.cxx new file mode 100644 index 000000000000..b90a5bd95882 --- /dev/null +++ b/cui/source/tabpages/tppattern.cxx @@ -0,0 +1,876 @@ +/* -*- 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include "com/sun/star/ui/dialogs/TemplateDescription.hpp" +#include +#include +#include +#include + +#include +#include "helpid.hrc" +#include "svx/xattr.hxx" +#include +#include +#include "svx/xoutbmp.hxx" +#include "svx/drawitem.hxx" +#include "cuitabarea.hxx" +#include "defdlgname.hxx" +#include "dlgname.hxx" +#include +#include +#include "sfx2/opengrf.hxx" +#include "paragrph.hrc" + +using namespace com::sun::star; + +SvxPatternTabPage::SvxPatternTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs) : + + SvxTabPage ( pParent, + "BitmapTabPage", + "cui/ui/patterntabpage.ui", + rInAttrs ), + m_rOutAttrs ( rInAttrs ), + + m_pnPatternListState ( nullptr ), + m_pnColorListState ( nullptr ), + m_pPageType ( nullptr ), + m_nDlgType ( 0 ), + m_pPos ( nullptr ), + m_pbAreaTP ( nullptr ), + + m_bPtrnChanged ( false ), + + m_aXFStyleItem ( drawing::FillStyle_BITMAP ), + m_aXPatternItem ( OUString(), Graphic() ), + m_aXFillAttr ( rInAttrs.GetPool() ), + m_rXFSet ( m_aXFillAttr.GetItemSet() ) +{ + get(m_pBxPixelEditor,"maingrid"); + get(m_pCtlPixel,"CTL_PIXEL"); + get(m_pLbColor,"LB_COLOR"); + get(m_pLbBackgroundColor,"LB_BACKGROUND_COLOR"); + get(m_pCtlPreview,"CTL_PREVIEW"); + get(m_pLbPatterns,"LB_PATTERN"); + get(m_pLbPatternsHidden,"FT_BITMAPS_HIDDEN"); + get(m_pBtnAdd,"BTN_ADD"); + get(m_pBtnModify,"BTN_MODIFY"); + get(m_pBtnDelete,"BTN_DELETE"); + get(m_pBtnLoad,"BTN_LOAD"); + get(m_pBtnSave,"BTN_SAVE"); + + // size of the bitmap listbox + Size aSize = getDrawListBoxOptimalSize(this); + m_pLbPatterns->set_width_request(aSize.Width()); + m_pLbPatterns->set_height_request(aSize.Height()); + + // size of the bitmap display + Size aSize2 = getDrawPreviewOptimalSize(this); + m_pCtlPreview->set_width_request(aSize2.Width()); + m_pCtlPreview->set_height_request(aSize2.Height()); + + m_pBitmapCtl = new SvxBitmapCtl; + + // this page needs ExchangeSupport + SetExchangeSupport(); + + // setting the output device + m_rXFSet.Put( m_aXFStyleItem ); + m_rXFSet.Put( m_aXPatternItem ); + + m_pBtnAdd->SetClickHdl( LINK( this, SvxPatternTabPage, ClickAddHdl_Impl ) ); + m_pBtnModify->SetClickHdl( LINK( this, SvxPatternTabPage, ClickModifyHdl_Impl ) ); + m_pBtnDelete->SetClickHdl( LINK( this, SvxPatternTabPage, ClickDeleteHdl_Impl ) ); + m_pBtnLoad->SetClickHdl( LINK( this, SvxPatternTabPage, ClickLoadHdl_Impl ) ); + m_pBtnSave->SetClickHdl( LINK( this, SvxPatternTabPage, ClickSaveHdl_Impl ) ); + + m_pLbPatterns->SetSelectHdl( LINK( this, SvxPatternTabPage, ChangePatternHdl_Impl ) ); + m_pLbColor->SetSelectHdl( LINK( this, SvxPatternTabPage, ChangeColorHdl_Impl ) ); + m_pLbBackgroundColor->SetSelectHdl( LINK( this, SvxPatternTabPage, ChangeColorHdl_Impl ) ); + + setPreviewsToSamePlace(pParent, this); +} + +SvxPatternTabPage::~SvxPatternTabPage() +{ + disposeOnce(); +} + +void SvxPatternTabPage::dispose() +{ + delete m_pBitmapCtl; + m_pBitmapCtl = nullptr; + m_pBxPixelEditor.clear(); + m_pCtlPixel.clear(); + m_pLbColor.clear(); + m_pLbBackgroundColor.clear(); + m_pLbPatternsHidden.clear(); + m_pLbPatterns.clear(); + m_pCtlPreview.clear(); + m_pBtnAdd.clear(); + m_pBtnModify.clear(); + m_pBtnDelete.clear(); + m_pBtnLoad.clear(); + m_pBtnSave.clear(); + SvxTabPage::dispose(); +} + +void SvxPatternTabPage::Construct() +{ + m_pLbColor->Fill( m_pColorList ); + m_pLbBackgroundColor->CopyEntries( *m_pLbColor ); + m_pLbPatterns->Fill( m_pPatternList ); +} + + +void SvxPatternTabPage::ActivatePage( const SfxItemSet& ) +{ + sal_Int32 nPos; + sal_Int32 nCount; + + if( m_nDlgType == 0 ) // area dialog + { + *m_pbAreaTP = false; + + if( m_pColorList.is() ) + { + // ColorList + if( *m_pnColorListState & ChangeType::CHANGED || + *m_pnColorListState & ChangeType::MODIFIED ) + { + if( *m_pnColorListState & ChangeType::CHANGED ) + m_pColorList = static_cast( GetParentDialog() )->GetNewColorList(); + + // LbColor + nPos = m_pLbColor->GetSelectEntryPos(); + m_pLbColor->Clear(); + m_pLbColor->Fill( m_pColorList ); + nCount = m_pLbColor->GetEntryCount(); + if( nCount == 0 ) + ; // this case should not occur + else if( nCount <= nPos ) + m_pLbColor->SelectEntryPos( 0 ); + else + m_pLbColor->SelectEntryPos( nPos ); + + // LbColorBackground + nPos = m_pLbBackgroundColor->GetSelectEntryPos(); + m_pLbBackgroundColor->Clear(); + m_pLbBackgroundColor->CopyEntries( *m_pLbColor ); + nCount = m_pLbBackgroundColor->GetEntryCount(); + if( nCount == 0 ) + ; // this case should not occur + else if( nCount <= nPos ) + m_pLbBackgroundColor->SelectEntryPos( 0 ); + else + m_pLbBackgroundColor->SelectEntryPos( nPos ); + ChangeColor_Impl(); + } + + // determining (possibly cutting) the name and + // displaying it in the GroupBox + OUString aString( CUI_RES( RID_SVXSTR_TABLE ) ); + aString += ": "; + INetURLObject aURL( m_pPatternList->GetPath() ); + + aURL.Append( m_pPatternList->GetName() ); + SAL_WARN_IF( aURL.GetProtocol() == INetProtocol::NotValid, "cui.tabpages", "invalid URL" ); + + if( aURL.getBase().getLength() > 18 ) + { + aString += aURL.getBase().copy( 0, 15 ); + aString += "..."; + } + else + aString += aURL.getBase(); + + if( *m_pPageType == PT_BITMAP && *m_pPos != LISTBOX_ENTRY_NOTFOUND ) + { + m_pLbPatterns->SelectEntryPos( *m_pPos ); + } + // colors could have been deleted + ChangePatternHdl_Impl( *m_pLbPatterns ); + + *m_pPageType = PT_BITMAP; + *m_pPos = LISTBOX_ENTRY_NOTFOUND; + } + } +} + + +DeactivateRC SvxPatternTabPage::DeactivatePage( SfxItemSet* _pSet) +{ + if ( CheckChanges_Impl() == -1L ) + return DeactivateRC::KeepPage; + + if( _pSet ) + FillItemSet( _pSet ); + + return DeactivateRC::LeavePage; +} + + +bool SvxPatternTabPage::FillItemSet( SfxItemSet* _rOutAttrs ) +{ + if( m_nDlgType == 0 && !*m_pbAreaTP ) // area dialog + { + if(PT_BITMAP == *m_pPageType) + { + _rOutAttrs->Put(XFillStyleItem(drawing::FillStyle_BITMAP)); + sal_Int32 nPos = m_pLbPatterns->GetSelectEntryPos(); + if(LISTBOX_ENTRY_NOTFOUND != nPos) + { + const XBitmapEntry* pXBitmapEntry = m_pPatternList->GetBitmap(nPos); + const OUString aString(m_pLbPatterns->GetSelectEntry()); + + _rOutAttrs->Put(XFillBitmapItem(aString, pXBitmapEntry->GetGraphicObject())); + } + else + { + const BitmapEx aBitmapEx(m_pBitmapCtl->GetBitmapEx()); + + _rOutAttrs->Put(XFillBitmapItem(OUString(), Graphic(aBitmapEx))); + } + } + } + + return true; +} + + +void SvxPatternTabPage::Reset( const SfxItemSet* ) +{ + // aLbBitmaps.SelectEntryPos( 0 ); + + m_pBitmapCtl->SetLines( m_pCtlPixel->GetLineCount() ); + m_pBitmapCtl->SetPixelColor( m_pLbColor->GetSelectEntryColor() ); + m_pBitmapCtl->SetBackgroundColor( m_pLbBackgroundColor->GetSelectEntryColor() ); + m_pBitmapCtl->SetBmpArray( m_pCtlPixel->GetBitmapPixelPtr() ); + + // get bitmap and display it + const XFillBitmapItem aBmpItem(OUString(), Graphic(m_pBitmapCtl->GetBitmapEx())); + m_rXFSet.Put( aBmpItem ); + m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() ); + m_pCtlPreview->Invalidate(); + + ChangePatternHdl_Impl( *m_pLbPatterns ); + + // determine button state + if( m_pPatternList.is() && m_pPatternList->Count() ) + { + m_pBtnAdd->Enable(); + m_pBtnModify->Enable(); + m_pBtnDelete->Enable(); + m_pBtnSave->Enable(); + } + else + { + m_pBtnModify->Disable(); + m_pBtnDelete->Disable(); + m_pBtnSave->Disable(); + } +} + + +VclPtr SvxPatternTabPage::Create( vcl::Window* pWindow, + const SfxItemSet* rSet ) +{ + return VclPtr::Create( pWindow, *rSet ); +} + + +IMPL_LINK_NOARG_TYPED(SvxPatternTabPage, ChangePatternHdl_Impl, ListBox&, void) +{ + std::unique_ptr pGraphicObject; + int nPos(m_pLbPatterns->GetSelectEntryPos()); + + if(LISTBOX_ENTRY_NOTFOUND != nPos) + { + pGraphicObject.reset(new GraphicObject(m_pPatternList->GetBitmap(nPos)->GetGraphicObject())); + } + else + { + const SfxPoolItem* pPoolItem = nullptr; + + if(SfxItemState::SET == m_rOutAttrs.GetItemState(GetWhich(XATTR_FILLSTYLE), true, &pPoolItem)) + { + const drawing::FillStyle eXFS((drawing::FillStyle)static_cast(pPoolItem)->GetValue()); + + if((drawing::FillStyle_BITMAP == eXFS) && (SfxItemState::SET == m_rOutAttrs.GetItemState(GetWhich(XATTR_FILLBITMAP), true, &pPoolItem))) + { + pGraphicObject.reset(new GraphicObject(static_cast(pPoolItem)->GetGraphicObject())); + } + } + + if(!pGraphicObject) + { + m_pLbPatterns->SelectEntryPos(0); + nPos = m_pLbPatterns->GetSelectEntryPos(); + + if(LISTBOX_ENTRY_NOTFOUND != nPos) + { + pGraphicObject.reset(new GraphicObject(m_pPatternList->GetBitmap(nPos)->GetGraphicObject())); + } + } + } + + if(pGraphicObject) + { + BitmapColor aBack; + BitmapColor aFront; + bool bIs8x8(isHistorical8x8(pGraphicObject->GetGraphic().GetBitmap(), aBack, aFront)); + + m_pLbColor->SetNoSelection(); + m_pLbBackgroundColor->SetNoSelection(); + + if(bIs8x8) + { + m_pCtlPixel->SetPaintable( true ); + m_pBxPixelEditor->Enable(); + m_pBtnModify->Enable(); + m_pBtnAdd->Enable(); + + // setting the pixel control + + m_pCtlPixel->SetXBitmap(pGraphicObject->GetGraphic().GetBitmapEx()); + + Color aPixelColor = aFront; + Color aBackColor = aBack; + + // #i123564# This causes the wrong color to be selected + // as foreground color when the 1st bitmap in the bitmap + // list is selected. I see no reason why this is done, + // thus I will take it out + + //if( 0 == m_pLbBitmaps->GetSelectEntryPos() ) + //{ + // m_pLbColor->SelectEntry( Color( COL_BLACK ) ); + // ChangePixelColorHdl_Impl( this ); + //} + //else + + m_pLbColor->SelectEntry( aPixelColor ); + + if( m_pLbColor->GetSelectEntryCount() == 0 ) + { + m_pLbColor->InsertEntry( aPixelColor, OUString() ); + m_pLbColor->SelectEntry( aPixelColor ); + } + + m_pLbBackgroundColor->SelectEntry( aBackColor ); + + if( m_pLbBackgroundColor->GetSelectEntryCount() == 0 ) + { + m_pLbBackgroundColor->InsertEntry( aBackColor, OUString() ); + m_pLbBackgroundColor->SelectEntry( aBackColor ); + } + + // update m_pBitmapCtl, rXFSet and m_pCtlPreview + m_pBitmapCtl->SetPixelColor( aPixelColor ); + m_pBitmapCtl->SetBackgroundColor( aBackColor ); + m_rXFSet.Put(XFillBitmapItem(OUString(), Graphic(m_pBitmapCtl->GetBitmapEx()))); + m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() ); + m_pCtlPreview->Invalidate(); + } + else + { + m_pCtlPixel->Reset(); + m_pCtlPixel->SetPaintable( false ); + m_pBxPixelEditor->Disable(); + m_pBtnModify->Disable(); + m_pBtnAdd->Disable(); + } + + m_pCtlPixel->Invalidate(); + + m_bPtrnChanged = false; + } +} + + +long SvxPatternTabPage::CheckChanges_Impl() +{ + sal_Int32 nPos = m_pLbPatterns->GetSelectEntryPos(); + if( nPos != LISTBOX_ENTRY_NOTFOUND ) + { + if( m_bPtrnChanged ) + { + ResMgr& rMgr = CUI_MGR(); + Image aWarningBoxImage = WarningBox::GetStandardImage(); + ScopedVclPtrInstance aMessDlg( GetParentDialog(), + SVX_RES( RID_SVXSTR_PATTERN ), + CUI_RES( RID_SVXSTR_ASK_CHANGE_PATTERN ), + &aWarningBoxImage ); + assert(aMessDlg && "Dialog creation failed!"); + aMessDlg->SetButtonText( SvxMessDialogButton::N1, ResId( RID_SVXSTR_CHANGE, rMgr ) ); + aMessDlg->SetButtonText( SvxMessDialogButton::N2, ResId( RID_SVXSTR_ADD, rMgr ) ); + + short nRet = aMessDlg->Execute(); + + switch( nRet ) + { + case RET_BTN_1: + { + ClickModifyHdl_Impl( nullptr ); + } + break; + + case RET_BTN_2: + { + ClickAddHdl_Impl( nullptr ); + } + break; + + case RET_CANCEL: + break; + } + } + } + nPos = m_pLbPatterns->GetSelectEntryPos(); + if( nPos != LISTBOX_ENTRY_NOTFOUND ) + *m_pPos = nPos; + return 0L; +} + + +IMPL_LINK_NOARG_TYPED(SvxPatternTabPage, ClickAddHdl_Impl, Button*, void) +{ + + OUString aNewName( SVX_RES( RID_SVXSTR_PATTERN_UNTITLED ) ); + OUString aDesc( CUI_RES( RID_SVXSTR_DESC_NEW_PATTERN ) ); + OUString aName; + + long nCount = m_pPatternList->Count(); + long j = 1; + bool bDifferent = false; + + while( !bDifferent ) + { + aName = aNewName; + aName += " "; + aName += OUString::number( j++ ); + bDifferent = true; + + for( long i = 0; i < nCount && bDifferent; i++ ) + if( aName == m_pPatternList->GetBitmap( i )->GetName() ) + bDifferent = false; + } + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + assert(pFact && "Dialog creation failed!"); + std::unique_ptr pDlg(pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc )); + assert(pDlg && "Dialog creation failed!"); + ScopedVclPtr pWarnBox; + sal_uInt16 nError(1); + + while( pDlg->Execute() == RET_OK ) + { + pDlg->GetName( aName ); + + bDifferent = true; + + for( long i = 0; i < nCount && bDifferent; i++ ) + if( aName == m_pPatternList->GetBitmap( i )->GetName() ) + bDifferent = false; + + if( bDifferent ) { + nError = 0; + break; + } + + if( !pWarnBox ) + { + pWarnBox.disposeAndReset(VclPtr::Create( GetParentDialog() + ,"DuplicateNameDialog" + ,"cui/ui/queryduplicatedialog.ui")); + } + + if( pWarnBox->Execute() != RET_OK ) + break; + } + + pDlg.reset(); + pWarnBox.disposeAndClear(); + + if( !nError ) + { + XBitmapEntry* pEntry = nullptr; + if( m_pCtlPixel->IsEnabled() ) + { + const BitmapEx aBitmapEx(m_pBitmapCtl->GetBitmapEx()); + + pEntry = new XBitmapEntry(Graphic(aBitmapEx), aName); + } + else // it must be a not existing imported bitmap + { + const SfxPoolItem* pPoolItem = nullptr; + + if(SfxItemState::SET == m_rOutAttrs.GetItemState(XATTR_FILLBITMAP, true, &pPoolItem)) + { + pEntry = new XBitmapEntry(dynamic_cast< const XFillBitmapItem* >(pPoolItem)->GetGraphicObject(), aName); + } + } + + assert( pEntry && "SvxPatternTabPage::ClickAddHdl_Impl(), pEntry == 0 ?" ); + + if( pEntry ) + { + m_pPatternList->Insert( pEntry ); + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + m_pLbPatterns->Append(rStyleSettings.GetListBoxPreviewDefaultPixelSize(), *pEntry ); + m_pLbPatterns->SelectEntryPos( m_pLbPatterns->GetEntryCount() - 1 ); + + *m_pnPatternListState |= ChangeType::MODIFIED; + + ChangePatternHdl_Impl( *m_pLbPatterns ); + } + } + + // determine button state + if( m_pPatternList->Count() ) + { + m_pBtnModify->Enable(); + m_pBtnDelete->Enable(); + m_pBtnSave->Enable(); + } +} + + +/******************************************************************************/ +/******************************************************************************/ + + +IMPL_LINK_NOARG_TYPED(SvxPatternTabPage, ClickModifyHdl_Impl, Button*, void) +{ + sal_Int32 nPos = m_pLbPatterns->GetSelectEntryPos(); + + if ( nPos != LISTBOX_ENTRY_NOTFOUND ) + { + ResMgr& rMgr = CUI_MGR(); + OUString aDesc( ResId( RID_SVXSTR_DESC_NEW_PATTERN, rMgr ) ); + OUString aName( m_pPatternList->GetBitmap( nPos )->GetName() ); + OUString aOldName = aName; + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + assert(pFact && "Dialog creation failed!"); + std::unique_ptr pDlg(pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc )); + assert(pDlg && "Dialog creation failed!"); + + long nCount = m_pPatternList->Count(); + bool bLoop = true; + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + while( bLoop && pDlg->Execute() == RET_OK ) + { + pDlg->GetName( aName ); + bool bDifferent = true; + + for( long i = 0; i < nCount && bDifferent; i++ ) + { + if( aName == m_pPatternList->GetBitmap( i )->GetName() && + aName != aOldName ) + bDifferent = false; + } + + if( bDifferent ) + { + bLoop = false; + + const BitmapEx aBitmapEx(m_pBitmapCtl->GetBitmapEx()); + + // #i123497# Need to replace the existing entry with a new one (old returned needs to be deleted) + XBitmapEntry* pEntry = new XBitmapEntry(Graphic(aBitmapEx), aName); + delete m_pPatternList->Replace(pEntry, nPos); + + m_pLbPatterns->Modify( rStyleSettings.GetListBoxPreviewDefaultPixelSize(), *pEntry, nPos ); + m_pLbPatterns->SelectEntryPos( nPos ); + + *m_pnPatternListState |= ChangeType::MODIFIED; + + m_bPtrnChanged = false; + } + else + { + ScopedVclPtrInstance aBox( + GetParentDialog() + ,"DuplicateNameDialog" + ,"cui/ui/queryduplicatedialog.ui"); + aBox->Execute(); + } + } + } +} + + +IMPL_LINK_NOARG_TYPED(SvxPatternTabPage, ClickDeleteHdl_Impl, Button*, void) +{ + sal_Int32 nPos = m_pLbPatterns->GetSelectEntryPos(); + + if( nPos != LISTBOX_ENTRY_NOTFOUND ) + { + ScopedVclPtrInstance< MessageDialog > aQueryBox( GetParentDialog(),"AskDelBitmapDialog","cui/ui/querydeletebitmapdialog.ui" ); + + if( aQueryBox->Execute() == RET_YES ) + { + delete m_pPatternList->Remove( nPos ); + m_pLbPatterns->RemoveEntry( nPos ); + m_pLbPatterns->SelectEntryPos( 0 ); + + m_pCtlPreview->Invalidate(); + m_pCtlPixel->Invalidate(); + + ChangePatternHdl_Impl( *m_pLbPatterns ); + + *m_pnPatternListState |= ChangeType::MODIFIED; + } + } + // determine button state + if( !m_pPatternList->Count() ) + { + m_pBtnModify->Disable(); + m_pBtnDelete->Disable(); + m_pBtnSave->Disable(); + } +} + + +IMPL_LINK_NOARG_TYPED(SvxPatternTabPage, ClickLoadHdl_Impl, Button*, void) +{ + sal_uInt16 nReturn = RET_YES; + ResMgr& rMgr = CUI_MGR(); + + if ( *m_pnPatternListState & ChangeType::MODIFIED ) + { + nReturn = ScopedVclPtrInstance::Create( GetParentDialog() + ,"AskSaveList" + ,"cui/ui/querysavelistdialog.ui")->Execute(); + + if ( nReturn == RET_YES ) + m_pPatternList->Save(); + } + + if ( nReturn != RET_CANCEL ) + { + ::sfx2::FileDialogHelper aDlg( css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE ); + OUString aStrFilterType( "*.sop" ); + aDlg.AddFilter( aStrFilterType, aStrFilterType ); + OUString aPalettePath(SvtPathOptions().GetPalettePath()); + OUString aLastDir; + sal_Int32 nIndex = 0; + do + { + aLastDir = aPalettePath.getToken(0, ';', nIndex); + } + while (nIndex >= 0); + + INetURLObject aFile(aLastDir); + aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) ); + + if ( aDlg.Execute() == ERRCODE_NONE ) + { + EnterWait(); + INetURLObject aURL( aDlg.GetPath() ); + INetURLObject aPathURL( aURL ); + + aPathURL.removeSegment(); + aPathURL.removeFinalSlash(); + + // save table + XPatternListRef pBmpList = XPropertyList::AsPatternList( + XPropertyList::CreatePropertyList( + XPATTERN_LIST, aPathURL.GetMainURL(INetURLObject::NO_DECODE), + "")); + pBmpList->SetName( aURL.getName() ); + if( pBmpList->Load() ) + { + m_pPatternList = pBmpList; + static_cast( GetParentDialog() )->SetNewPatternList( m_pPatternList ); + + m_pLbPatterns->Clear(); + m_pLbPatterns->Fill( m_pPatternList ); + Reset( &m_rOutAttrs ); + + m_pPatternList->SetName( aURL.getName() ); + + // determining (possibly cutting) the name + // displaying it in the GroupBox + OUString aString( ResId( RID_SVXSTR_TABLE, rMgr ) ); + aString += ": "; + + if ( aURL.getBase().getLength() > 18 ) + { + aString += aURL.getBase().copy( 0, 15 ); + aString += "..."; + } + else + aString += aURL.getBase(); + + *m_pnPatternListState |= ChangeType::CHANGED; + *m_pnPatternListState &= ~ChangeType::MODIFIED; + LeaveWait(); + } + else + { + LeaveWait(); + ScopedVclPtrInstance::Create( GetParentDialog() + ,"NoLoadedFileDialog" + ,"cui/ui/querynoloadedfiledialog.ui")->Execute(); + } + } + } + + // determine button state + if( m_pPatternList->Count() ) + { + m_pBtnModify->Enable(); + m_pBtnDelete->Enable(); + m_pBtnSave->Enable(); + } + else + { + m_pBtnModify->Disable(); + m_pBtnDelete->Disable(); + m_pBtnSave->Disable(); + } +} + + +IMPL_LINK_NOARG_TYPED(SvxPatternTabPage, ClickSaveHdl_Impl, Button*, void) +{ + ::sfx2::FileDialogHelper aDlg( css::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE ); + OUString aStrFilterType( "*.sop" ); + aDlg.AddFilter( aStrFilterType, aStrFilterType ); + + OUString aPalettePath(SvtPathOptions().GetPalettePath()); + OUString aLastDir; + sal_Int32 nIndex = 0; + do + { + aLastDir = aPalettePath.getToken(0, ';', nIndex); + } + while (nIndex >= 0); + + INetURLObject aFile(aLastDir); + SAL_WARN_IF( aFile.GetProtocol() == INetProtocol::NotValid, "cui.tabpages", "invalid URL" ); + + if( !m_pPatternList->GetName().isEmpty() ) + { + aFile.Append( m_pPatternList->GetName() ); + + if( aFile.getExtension().isEmpty() ) + aFile.SetExtension( "sop" ); + } + + aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) ); + if ( aDlg.Execute() == ERRCODE_NONE ) + { + INetURLObject aURL( aDlg.GetPath() ); + INetURLObject aPathURL( aURL ); + + aPathURL.removeSegment(); + aPathURL.removeFinalSlash(); + + m_pPatternList->SetName( aURL.getName() ); + m_pPatternList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) ); + + if( m_pPatternList->Save() ) + { + // determining (possibly cutting) the name + // displaying it in the GroupBox + OUString aString( CUI_RES( RID_SVXSTR_TABLE ) ); + aString += ": "; + + if ( aURL.getBase().getLength() > 18 ) + { + aString += aURL.getBase().copy( 0, 15 ); + aString += "..."; + } + else + aString += aURL.getBase(); + + *m_pnPatternListState |= ChangeType::SAVED; + *m_pnPatternListState &= ~ChangeType::MODIFIED; + } + else + { + ScopedVclPtrInstance::Create( GetParentDialog() + ,"NoSaveFileDialog" + ,"cui/ui/querynosavefiledialog.ui")->Execute(); + } + } +} + + +IMPL_LINK_NOARG_TYPED(SvxPatternTabPage, ChangeColorHdl_Impl, ListBox&, void) +{ + ChangeColor_Impl(); +} + +void SvxPatternTabPage::ChangeColor_Impl() +{ + m_pCtlPixel->SetPixelColor( m_pLbColor->GetSelectEntryColor() ); + m_pCtlPixel->SetBackgroundColor( m_pLbBackgroundColor->GetSelectEntryColor() ); + m_pCtlPixel->Invalidate(); + + m_pBitmapCtl->SetPixelColor( m_pLbColor->GetSelectEntryColor() ); + m_pBitmapCtl->SetBackgroundColor( m_pLbBackgroundColor->GetSelectEntryColor() ); + + // get bitmap and display it + m_rXFSet.Put(XFillBitmapItem(OUString(), Graphic(m_pBitmapCtl->GetBitmapEx()))); + m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() ); + m_pCtlPreview->Invalidate(); + + m_bPtrnChanged = true; +} + + +void SvxPatternTabPage::PointChanged( vcl::Window* pWindow, RECT_POINT ) +{ + if( pWindow == m_pCtlPixel ) + { + m_pBitmapCtl->SetBmpArray( m_pCtlPixel->GetBitmapPixelPtr() ); + + // get bitmap and display it + m_rXFSet.Put(XFillBitmapItem(OUString(), Graphic(m_pBitmapCtl->GetBitmapEx()))); + m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() ); + m_pCtlPreview->Invalidate(); + + m_bPtrnChanged = true; + } +} + + +vcl::Window* SvxPatternTabPage::GetParentLabeledBy( const vcl::Window* pLabeled ) const +{ + if (pLabeled == m_pLbPatterns) + return m_pLbPatternsHidden.get(); + else + return SvxTabPage::GetParentLabeledBy (pLabeled); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/uiconfig/ui/areadialog.ui b/cui/uiconfig/ui/areadialog.ui index bf6404833556..4482284db8b7 100644 --- a/cui/uiconfig/ui/areadialog.ui +++ b/cui/uiconfig/ui/areadialog.ui @@ -177,10 +177,10 @@ - + True False - Bitmaps + Patterns 6 diff --git a/cui/uiconfig/ui/bitmaptabpage.ui b/cui/uiconfig/ui/bitmaptabpage.ui deleted file mode 100644 index 10f6d6831f74..000000000000 --- a/cui/uiconfig/ui/bitmaptabpage.ui +++ /dev/null @@ -1,347 +0,0 @@ - - - - - - True - False - True - True - 6 - vertical - - - True - False - True - True - 0 - none - - - True - False - True - True - 6 - 12 - - - True - False - True - True - 12 - - - True - False - True - vertical - 6 - - - True - False - 0 - Pattern Editor: - - - False - True - 0 - - - - - True - False - start - start - - - Pattern Editor - - - - - False - True - 1 - - - - - True - False - 0 - _Foreground color: - True - - - False - True - 2 - - - - - True - False - start - - - False - True - 3 - - - - - True - False - 0 - _Background color: - True - - - False - True - 4 - - - - - True - False - start - - - False - True - 5 - - - - - False - True - 0 - - - - - True - False - center - start - True - vertical - 6 - - - True - False - True - - - False - True - 0 - - - - - True - False - True - True - - - Example - - - - - True - True - 1 - - - - - False - True - 1 - - - - - True - False - vertical - 6 - start - - - gtk-add - True - False - True - True - - - False - True - 0 - - - - - _Modify - True - False - True - True - - - False - True - 1 - - - - - _Import - True - False - True - True - - - False - True - 2 - - - - - gtk-delete - True - False - True - True - - - False - True - 3 - - - - - True - False - 6 - 6 - - - True - True - True - True - Load Bitmap List - Load Bitmap List - center - True - image1 - - - 0 - 0 - 1 - 1 - - - - - True - True - True - True - Save Bitmap List - Save Bitmap List - center - True - image2 - - - 1 - 0 - 1 - 1 - - - - - False - Bitmap - - - 0 - 1 - 1 - 1 - - - - - - - - False - True - 5 - True - - - - - False - False - 2 - - - - - - - - - True - False - Properties - - - - - - - - False - True - 0 - - - - - True - False - res/sc05501.png - - - True - False - res/sc05502.png - - diff --git a/cui/uiconfig/ui/patterntabpage.ui b/cui/uiconfig/ui/patterntabpage.ui new file mode 100644 index 000000000000..cce44939e44a --- /dev/null +++ b/cui/uiconfig/ui/patterntabpage.ui @@ -0,0 +1,334 @@ + + + + + + + True + False + res/sc05501.png + + + True + False + res/sc05502.png + + + True + False + True + True + 6 + vertical + + + True + False + True + True + 0 + none + + + True + False + True + True + 6 + 12 + + + True + False + True + True + 12 + + + True + False + True + vertical + 6 + + + True + False + 0 + Pattern Editor: + + + False + True + 0 + + + + + True + False + start + start + + + Pattern Editor + + + + + False + True + 1 + + + + + True + False + 0 + _Foreground color: + True + + + False + True + 2 + + + + + True + False + start + + + False + True + 3 + + + + + True + False + 0 + _Background color: + True + + + False + True + 4 + + + + + True + False + start + + + False + True + 5 + + + + + False + True + 0 + + + + + True + False + center + start + True + vertical + 6 + + + True + False + True + + + False + True + 0 + + + + + True + False + True + True + + + Example + + + + + True + True + 1 + + + + + False + True + 1 + + + + + True + False + vertical + 6 + start + + + gtk-add + True + False + True + True + + + False + True + 0 + + + + + _Modify + True + False + True + True + + + False + True + 1 + + + + + gtk-delete + True + False + True + True + + + False + True + 3 + + + + + True + False + 6 + 6 + + + True + True + True + True + Load Bitmap List + Load Bitmap List + center + True + image1 + + + 0 + 0 + 1 + 1 + + + + + True + True + True + True + Save Bitmap List + Save Bitmap List + center + True + image2 + + + 1 + 0 + 1 + 1 + + + + + False + Bitmap + + + 0 + 1 + 1 + 1 + + + + + + + + False + True + 5 + True + + + + + False + False + 2 + + + + + + + + + True + False + Properties + + + + + + + + False + True + 0 + + + + -- cgit