diff options
author | Susobhan Ghosh <susobhang70@gmail.com> | 2016-06-07 19:20:22 +0530 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-06-23 13:15:07 +0000 |
commit | 3881fffe4233ce3aa02051b205c114c1cb520d67 (patch) | |
tree | 455a1b8230155788b62e82d2ee89f3e1a4fdbce9 | |
parent | 2fe32490f097ac107603ba5b1fa15599d720b8f6 (diff) |
tdf#83830: Page Styles Panel
Added new helper class to svx for numbering
Change-Id: Ie7db4059568024e9bed460fcf7c9215bd2ef788f
Reviewed-on: https://gerrit.libreoffice.org/26020
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r-- | include/svx/SvxNumOptionsTabPageHelper.hxx | 52 | ||||
-rw-r--r-- | include/svx/dialogs.hrc | 3 | ||||
-rw-r--r-- | include/svx/pagenumberlistbox.hxx | 36 | ||||
-rw-r--r-- | svx/AllLangResTarget_svx.mk | 1 | ||||
-rw-r--r-- | svx/Library_svxcore.mk | 2 | ||||
-rw-r--r-- | svx/source/dialog/SvxNumOptionsTabPageHelper.cxx | 91 | ||||
-rw-r--r-- | svx/source/dialog/pagenumbering.src | 31 | ||||
-rw-r--r-- | svx/source/dialog/pagenumberlistbox.cxx | 69 | ||||
-rw-r--r-- | sw/sdi/_viewsh.sdi | 25 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageStylesPanel.cxx | 504 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageStylesPanel.hxx | 57 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/SwPanelFactory.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewtab.cxx | 124 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/pagestylespanel.ui | 153 |
14 files changed, 1119 insertions, 31 deletions
diff --git a/include/svx/SvxNumOptionsTabPageHelper.hxx b/include/svx/SvxNumOptionsTabPageHelper.hxx new file mode 100644 index 000000000000..89fd68da9571 --- /dev/null +++ b/include/svx/SvxNumOptionsTabPageHelper.hxx @@ -0,0 +1,52 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SVX_SVXNUMOPTIONSTABPAGEHELPER_HXX +#define INCLUDED_SVX_SVXNUMOPTIONSTABPAGEHELPER_HXX + +#include <com/sun/star/text/DefaultNumberingProvider.hpp> +#include <comphelper/processfactory.hxx> +#include <com/sun/star/text/XNumberingTypeInfo.hpp> +#include <vcl/lstbox.hxx> +#include <svx/svxdllapi.h> + +using namespace css::uno; +using namespace css::text; + +class SVX_DLLPUBLIC SvxNumOptionsTabPageHelper +{ +public: + static Reference<XDefaultNumberingProvider> GetNumberingProvider(); + + /** Get the numberings provided by the i18n framework (CTL, Asian, ...) and + add them to the listbox. Extended numbering schemes present in the + resource and already in the listbox but not offered by the i18n + framework per configuration are removed. + + @param nDoNotRemove + A value that shall not be removed, i.e. the ugly 0x88 + (SVX_NUM_BITMAP|0x80) + Pass ::std::numeric_limits<sal_uInt16>::max() if there is no such + restriction. + */ + static void GetI18nNumbering( ListBox& rFmtLB, sal_uInt16 nDoNotRemove ); +}; + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/dialogs.hrc b/include/svx/dialogs.hrc index 45ac30541e28..c2af3bce3110 100644 --- a/include/svx/dialogs.hrc +++ b/include/svx/dialogs.hrc @@ -1075,9 +1075,10 @@ #define RID_SVXIMG_WIDTH_CUSTOM_GRAY (RID_SVX_START + 1394) #define RID_SVXSTRARY_PAPERSIZE_STD (RID_SVX_START + 1395) #define RID_SVXSTRARY_PAPERSIZE_DRAW (RID_SVX_START + 1396) +#define RID_SVXSTRARY_PAGE_NUMBERING (RID_SVX_START + 1397) // !!! IMPORTANT: consider and update RID_SVXSTR_NEXTFREE when introducing new RIDs for Strings !!! -#define RID_SVXSTR_NEXTFREE (RID_SVX_START + 1397) +#define RID_SVXSTR_NEXTFREE (RID_SVX_START + 1398) // if we have _a_lot_ time, we should group the resource ids by type, instead // of grouping them by semantics. The reason is that resource ids have to be diff --git a/include/svx/pagenumberlistbox.hxx b/include/svx/pagenumberlistbox.hxx new file mode 100644 index 000000000000..872a3f252545 --- /dev/null +++ b/include/svx/pagenumberlistbox.hxx @@ -0,0 +1,36 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_SVX_PAGENUMBERINGHELPER_HXX +#define INCLUDED_SVX_PAGENUMBERINGHELPER_HXX + +#include <svx/svxdllapi.h> +#include <vcl/lstbox.hxx> + +class SVX_DLLPUBLIC PageNumberListBox : public ListBox +{ +public: + PageNumberListBox( vcl::Window* pParent, WinBits nBits = WB_BORDER | WB_DROPDOWN ); + + void SetSelection( sal_uInt16 ); + sal_uInt16 GetSelection() const; +}; + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/AllLangResTarget_svx.mk b/svx/AllLangResTarget_svx.mk index 18e52d63507d..d33f37d31023 100644 --- a/svx/AllLangResTarget_svx.mk +++ b/svx/AllLangResTarget_svx.mk @@ -45,6 +45,7 @@ $(eval $(call gb_SrsTarget_add_files,svx/res,\ svx/source/dialog/imapdlg.src \ svx/source/dialog/language.src \ svx/source/dialog/page.src \ + svx/source/dialog/pagenumbering.src \ svx/source/dialog/passwd.src \ svx/source/dialog/prtqry.src \ svx/source/dialog/ruler.src \ diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk index 9bb991da1289..f5c38f373b08 100644 --- a/svx/Library_svxcore.mk +++ b/svx/Library_svxcore.mk @@ -118,9 +118,11 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\ svx/source/dialog/hexcolorcontrol \ svx/source/dialog/framelink \ svx/source/dialog/langbox \ + svx/source/dialog/pagenumberlistbox \ svx/source/dialog/papersizelistbox \ svx/source/dialog/stddlg \ svx/source/dialog/svxdlg \ + svx/source/dialog/SvxNumOptionsTabPageHelper \ svx/source/engine3d/camera3d \ svx/source/engine3d/cube3d \ svx/source/engine3d/deflt3d \ diff --git a/svx/source/dialog/SvxNumOptionsTabPageHelper.cxx b/svx/source/dialog/SvxNumOptionsTabPageHelper.cxx new file mode 100644 index 000000000000..0d467080b2c0 --- /dev/null +++ b/svx/source/dialog/SvxNumOptionsTabPageHelper.cxx @@ -0,0 +1,91 @@ +/* -*- 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 <svx/SvxNumOptionsTabPageHelper.hxx> +#include <com/sun/star/style/NumberingType.hpp> + +using namespace css; +using namespace css::uno; +using namespace css::text; +using namespace css::style; + +Reference<XDefaultNumberingProvider> SvxNumOptionsTabPageHelper::GetNumberingProvider() +{ + Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); + Reference<XDefaultNumberingProvider> xRet = text::DefaultNumberingProvider::create(xContext); + return xRet; +} + +void SvxNumOptionsTabPageHelper::GetI18nNumbering( ListBox& rFmtLB, sal_uInt16 nDoNotRemove ) +{ + Reference<XDefaultNumberingProvider> xDefNum = GetNumberingProvider(); + Reference<XNumberingTypeInfo> xInfo(xDefNum, UNO_QUERY); + + // Extended numbering schemes present in the resource but not offered by + // the i18n framework per configuration must be removed from the listbox. + // Do not remove a special entry matching nDoNotRemove. + const sal_uInt16 nDontRemove = SAL_MAX_UINT16; + ::std::vector< sal_uInt16> aRemove( rFmtLB.GetEntryCount(), nDontRemove); + for (size_t i=0; i<aRemove.size(); ++i) + { + sal_uInt16 nEntryData = (sal_uInt16)reinterpret_cast<sal_uLong>(rFmtLB.GetEntryData( + sal::static_int_cast< sal_Int32 >(i))); + if (nEntryData > NumberingType::CHARS_LOWER_LETTER_N && nEntryData != nDoNotRemove) + aRemove[i] = nEntryData; + } + if(xInfo.is()) + { + Sequence<sal_Int16> aTypes = xInfo->getSupportedNumberingTypes( ); + const sal_Int16* pTypes = aTypes.getConstArray(); + for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++) + { + sal_Int16 nCurrent = pTypes[nType]; + if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N) + { + bool bInsert = true; + for(sal_Int32 nEntry = 0; nEntry < rFmtLB.GetEntryCount(); nEntry++) + { + sal_uInt16 nEntryData = (sal_uInt16)reinterpret_cast<sal_uLong>(rFmtLB.GetEntryData(nEntry)); + if(nEntryData == (sal_uInt16) nCurrent) + { + bInsert = false; + aRemove[nEntry] = nDontRemove; + break; + } + } + if(bInsert) + { + OUString aIdent = xInfo->getNumberingIdentifier( nCurrent ); + sal_Int32 nPos = rFmtLB.InsertEntry(aIdent); + rFmtLB.SetEntryData(nPos, reinterpret_cast<void*>((sal_uLong)nCurrent)); + } + } + } + } + for (unsigned short i : aRemove) + { + if (i != nDontRemove) + { + sal_Int32 nPos = rFmtLB.GetEntryPos( reinterpret_cast<void*>((sal_uLong)i)); + rFmtLB.RemoveEntry( nPos); + } + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/dialog/pagenumbering.src b/svx/source/dialog/pagenumbering.src new file mode 100644 index 000000000000..3f9c7fd0c83c --- /dev/null +++ b/svx/source/dialog/pagenumbering.src @@ -0,0 +1,31 @@ +#include <svx/dialogs.hrc> + +StringArray RID_SVXSTRARY_PAGE_NUMBERING +{ + ItemList [ en-US ] = + { + < "1, 2, 3, ..." ; 4/*SVX_NUM_ARABIC */; > ; + < "A, B, C, ..." ; 0/*SVX_NUM_CHARS_UPPER_LETTER */; > ; + < "a, b, c, ..." ; 1/*SVX_NUM_CHARS_LOWER_LETTER */; > ; + < "I, II, III, ..." ; 2/*SVX_NUM_ROMAN_UPPER */; > ; + < "i, ii, iii, ..." ; 3/*SVX_NUM_ROMAN_LOWER */; > ; + < "None" ; 5/*SVX_NUM_NUMBER_NONE */; > ; + < "A, .., AA, .., AAA, ..." ; 9/*SVX_NUM_CHARS_UPPER_LETTER_N*/; > ; + < "a, .., aa, .., aaa, ..." ; 10/*SVX_NUM_CHARS_LOWER_LETTER_N*/; > ; + < "Native Numbering" ; 12 /*NATIVE_NUMBERING */; > ; + < "А, Б, .., Аа, Аб, ... (Bulgarian)" ; 38 /*CHARS_CYRILLIC_UPPER_LETTER_BG */; > ; + < "а, б, .., аа, аб, ... (Bulgarian)" ; 39 /*CHARS_CYRILLIC_LOWER_LETTER_BG */; > ; + < "А, Б, .., Аа, Бб, ... (Bulgarian)" ; 40 /*CHARS_CYRILLIC_UPPER_LETTER_N_BG */; > ; + < "а, б, .., аа, бб, ... (Bulgarian)" ; 41 /*CHARS_CYRILLIC_LOWER_LETTER_N_BG */; > ; + < "А, Б, .., Аа, Аб, ... (Russian)" ; 42 /*CHARS_CYRILLIC_UPPER_LETTER_RU */; > ; + < "а, б, .., аа, аб, ... (Russian)" ; 43 /*CHARS_CYRILLIC_LOWER_LETTER_RU */; > ; + < "А, Б, .., Аа, Бб, ... (Russian)" ; 44 /*CHARS_CYRILLIC_UPPER_LETTER_N_RU */; > ; + < "а, б, .., аа, бб, ... (Russian)" ; 45 /*CHARS_CYRILLIC_LOWER_LETTER_N_RU */; > ; + < "А, Б, .., Аа, Аб, ... (Serbian)" ; 48 /*CHARS_CYRILLIC_UPPER_LETTER_SR */; > ; + < "а, б, .., аа, аб, ... (Serbian)" ; 49 /*CHARS_CYRILLIC_LOWER_LETTER_SR */; > ; + < "А, Б, .., Аа, Бб, ... (Serbian)" ; 50 /*CHARS_CYRILLIC_UPPER_LETTER_N_SR */; > ; + < "а, б, .., аа, бб, ... (Serbian)" ; 51 /*CHARS_CYRILLIC_LOWER_LETTER_N_SR */; > ; + < "Α, Β, Γ, ... (Greek Upper Letter)"; 52 /*CHARS_GREEK_UPPER_LETTER */; > ; + < "α, β, γ, ... (Greek Lower Letter)"; 53 /*CHARS_GREEK_LOWER_LETTER */; > ; + }; +};
\ No newline at end of file diff --git a/svx/source/dialog/pagenumberlistbox.cxx b/svx/source/dialog/pagenumberlistbox.cxx new file mode 100644 index 000000000000..46c13d4fa281 --- /dev/null +++ b/svx/source/dialog/pagenumberlistbox.cxx @@ -0,0 +1,69 @@ +/* -*- 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 <svx/dialogs.hrc> +#include <svx/dialmgr.hxx> +#include <svx/pagenumberlistbox.hxx> +#include <tools/resary.hxx> +#include <vcl/builderfactory.hxx> + +PageNumberListBox::PageNumberListBox(vcl::Window* pParent, WinBits nStyle) + : ListBox( pParent, nStyle) +{ + ResStringArray aPaperAry( SVX_RES( RID_SVXSTRARY_PAGE_NUMBERING ) ); + sal_uInt32 nCnt = aPaperAry.Count(); + + for ( sal_uInt32 i = 0; i < nCnt; ++i ) + { + OUString aStr = aPaperAry.GetString(i); + sal_uInt16 nData = aPaperAry.GetValue(i); + sal_Int32 nPos = InsertEntry( aStr ); + SetEntryData( nPos, reinterpret_cast<void*>((sal_uLong)nData) ); + } +} + +VCL_BUILDER_FACTORY(PageNumberListBox); + +void PageNumberListBox::SetSelection( sal_uInt16 nPos ) +{ + sal_Int32 nEntryCount = GetEntryCount(); + sal_Int32 nSelPos = LISTBOX_ENTRY_NOTFOUND; + sal_Int32 nUserPos = LISTBOX_ENTRY_NOTFOUND; + + for (sal_Int32 i = 0; i < nEntryCount; ++i ) + { + sal_uInt16 nTmp = (sal_uInt16)reinterpret_cast<sal_uLong>(GetEntryData(i)); + + if ( nTmp == nPos ) + { + nSelPos = i; + break; + } + } + SelectEntryPos( ( nSelPos != LISTBOX_ENTRY_NOTFOUND ) ? nSelPos : nUserPos ); +} + +sal_uInt16 PageNumberListBox::GetSelection() const +{ + const sal_Int32 nPos = GetSelectEntryPos(); + sal_uInt16 nData = (sal_uInt16)reinterpret_cast<sal_uLong>(GetEntryData( nPos )); + + return nData; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi index c63d3598b8fe..065f072bf69f 100644 --- a/sw/sdi/_viewsh.sdi +++ b/sw/sdi/_viewsh.sdi @@ -446,21 +446,41 @@ interface BaseTextEditView ExecMethod = ExecTabWin ; StateMethod = StateTabWin ; ] + SID_ATTR_PAGE_FILLSTYLE + [ + ExecMethod = ExecTabWin ; + StateMethod = StateTabWin ; + ] SID_ATTR_PAGE_HEADER_LRMARGIN [ ExecMethod = ExecTabWin ; StateMethod = StateTabWin ; ] + SID_ATTR_PAGE_COLOR + [ + ExecMethod = ExecTabWin ; + StateMethod = StateTabWin ; + ] SID_ATTR_PAGE_HEADER_SPACING [ ExecMethod = ExecTabWin ; StateMethod = StateTabWin ; ] + SID_ATTR_PAGE_GRADIENT + [ + ExecMethod = ExecTabWin ; + StateMethod = StateTabWin ; + ] SID_ATTR_PAGE_HEADER_LAYOUT [ ExecMethod = ExecTabWin ; StateMethod = StateTabWin ; ] + SID_ATTR_PAGE_HATCH + [ + ExecMethod = ExecTabWin ; + StateMethod = StateTabWin ; + ] SID_ATTR_PAGE_FOOTER [ ExecMethod = ExecTabWin ; @@ -481,6 +501,11 @@ interface BaseTextEditView ExecMethod = ExecTabWin ; StateMethod = StateTabWin ; ] + SID_ATTR_PAGE_BITMAP + [ + ExecMethod = ExecTabWin ; + StateMethod = StateTabWin ; + ] SID_ATTR_PAGE_ULSPACE [ ExecMethod = ExecTabWin ; diff --git a/sw/source/uibase/sidebar/PageStylesPanel.cxx b/sw/source/uibase/sidebar/PageStylesPanel.cxx index 0b3e939bc495..85b6734b4876 100644 --- a/sw/source/uibase/sidebar/PageStylesPanel.cxx +++ b/sw/source/uibase/sidebar/PageStylesPanel.cxx @@ -24,6 +24,8 @@ #include <svx/svxids.hrc> #include <svx/dlgutil.hxx> #include <svx/rulritem.hxx> +#include "svx/drawitem.hxx" +#include <svx/SvxNumOptionsTabPageHelper.hxx> #include "PageStylesPanel.hxx" #include <sfx2/sidebar/ControlFactory.hxx> #include <sfx2/dispatch.hxx> @@ -35,26 +37,79 @@ #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/document/XUndoManagerSupplier.hpp> +using namespace ::com::sun::star; + namespace sw { namespace sidebar{ +const sal_uInt16 aArr[] = +{ + SVX_PAGE_ALL, + SVX_PAGE_MIRROR, + SVX_PAGE_RIGHT, + SVX_PAGE_LEFT +}; + + +sal_uInt16 PageUsageToPos_Impl( sal_uInt16 nUsage ) +{ + for ( sal_uInt16 i = 0; i < SAL_N_ELEMENTS(aArr); ++i ) + if ( aArr[i] == ( nUsage & 0x000f ) ) + return i; + return SVX_PAGE_ALL; +} + + +sal_uInt16 PosToPageUsage_Impl( sal_uInt16 nPos ) +{ + if ( nPos >= SAL_N_ELEMENTS(aArr) ) + return 0; + return aArr[nPos]; +} + VclPtr<vcl::Window> PageStylesPanel::Create( vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame) + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + SfxBindings* pBindings) { if( pParent == nullptr ) throw ::com::sun::star::lang::IllegalArgumentException("no parent window given to PageStylesPanel::Create", nullptr, 0); if( !rxFrame.is() ) throw ::com::sun::star::lang::IllegalArgumentException("no XFrame given to PageStylesPanel::Create", nullptr, 0); + if( pBindings == nullptr ) + throw ::com::sun::star::lang::IllegalArgumentException("no SfxBindings given to PageStylesPanel::Create", nullptr, 0); - return VclPtr<PageStylesPanel>::Create(pParent, rxFrame); + return VclPtr<PageStylesPanel>::Create(pParent, rxFrame, pBindings); } PageStylesPanel::PageStylesPanel( vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + SfxBindings* pBindings ) : - PanelLayout(pParent, "PageStylesPanel", "modules/swriter/ui/pagestylespanel.ui", rxFrame) + PanelLayout(pParent, "PageStylesPanel", "modules/swriter/ui/pagestylespanel.ui", rxFrame), + mpBindings( pBindings ), + mpPageColumnItem( new SfxInt16Item(SID_ATTR_PAGE_COLUMN) ), + mpPageItem( new SvxPageItem(SID_ATTR_PAGE) ), + maPageColumnControl(SID_ATTR_PAGE_COLUMN, *pBindings, *this), + maPageNumFormatControl( SID_ATTR_PAGE, *pBindings, *this ), + maBgColorControl( SID_ATTR_PAGE_COLOR, *pBindings, *this ), + maBgHatchingControl( SID_ATTR_PAGE_HATCH, *pBindings, *this ), + maBgGradientControl( SID_ATTR_PAGE_GRADIENT, *pBindings, *this ), + maBgBitmapControl( SID_ATTR_PAGE_BITMAP, *pBindings, *this ), + maBgFillStyleControl(SID_ATTR_PAGE_FILLSTYLE, *pBindings, *this), + aCustomEntry() { + get(mpColumnCount, "columnbox"); + get(mpNumberSelectLB, "numberbox"); + get(mpBgFillType, "bgselect"); + get(mpBgColorLB, "lbcolor"); + get(mpBgHatchingLB, "lbhatching"); + get(mpBgGradientLB, "lbgradient"); + get(mpBgBitmapLB, "lbbitmap"); + get(mpLayoutSelectLB, "layoutbox"); + get(mpCustomEntry, "customlabel"); + + Initialize(); } PageStylesPanel::~PageStylesPanel() @@ -64,16 +119,449 @@ PageStylesPanel::~PageStylesPanel() void PageStylesPanel::dispose() { + mpColumnCount.disposeAndClear(); + mpNumberSelectLB.disposeAndClear(); + mpBgFillType.disposeAndClear(); + mpBgColorLB.disposeAndClear(); + mpBgHatchingLB.disposeAndClear(); + mpBgGradientLB.disposeAndClear(); + mpBgBitmapLB.disposeAndClear(); + mpLayoutSelectLB.disposeAndClear(); + + maBgBitmapControl.dispose(); + maBgColorControl.dispose(); + maBgFillStyleControl.dispose(); + maBgGradientControl.dispose(); + maBgHatchingControl.dispose(); + maPageColumnControl.dispose(); + maPageNumFormatControl.dispose(); + mpCustomEntry.clear(); PanelLayout::dispose(); } +void PageStylesPanel::Initialize() +{ + aCustomEntry = mpCustomEntry->GetText(); + mpColumnCount->SetSelectHdl( LINK(this, PageStylesPanel, ModifyColumnCountHdl) ); + + SvxNumOptionsTabPageHelper::GetI18nNumbering( *mpNumberSelectLB, ::std::numeric_limits<sal_uInt16>::max()); + mpNumberSelectLB->SetSelectHdl( LINK(this, PageStylesPanel, ModifyNumberingHdl) ); + + mpLayoutSelectLB->SetSelectHdl( LINK(this, PageStylesPanel, ModifyLayoutHdl) ); + mpBgFillType->SetSelectHdl( LINK(this, PageStylesPanel, ModifyFillStyleHdl)); + mpBgColorLB->SetSelectHdl( LINK(this, PageStylesPanel, ModifyFillColorHdl)); + mpBgGradientLB->SetSelectHdl( LINK(this, PageStylesPanel, ModifyFillColorHdl)); + mpBgHatchingLB->SetSelectHdl( LINK(this, PageStylesPanel, ModifyFillColorHdl)); + mpBgBitmapLB->SetSelectHdl( LINK(this, PageStylesPanel, ModifyFillColorHdl)); + + mpBindings->Invalidate(SID_ATTR_PAGE_COLUMN); + mpBindings->Invalidate(SID_ATTR_PAGE); + mpBindings->Invalidate(SID_ATTR_PAGE_FILLSTYLE); + Update(); +} + +void PageStylesPanel::Update() +{ + const drawing::FillStyle eXFS = (drawing::FillStyle)mpBgFillType->GetSelectEntryPos(); + SfxObjectShell* pSh = SfxObjectShell::Current(); + switch(eXFS) + { + case drawing::FillStyle_NONE: + { + mpBgColorLB->Hide(); + mpBgHatchingLB->Hide(); + mpBgGradientLB->Hide(); + mpBgBitmapLB->Hide(); + } + break; + case drawing::FillStyle_SOLID: + { + mpBgBitmapLB->Hide(); + mpBgGradientLB->Hide(); + mpBgHatchingLB->Hide(); + mpBgColorLB->Show(); + mpBgColorLB->Clear(); + const SvxColorListItem aItem( *static_cast<const SvxColorListItem*>(pSh->GetItem(SID_COLOR_TABLE))); + mpBgColorLB->Fill(aItem.GetColorList()); + + const Color aColor = GetColorSetOrDefault(); + mpBgColorLB->SelectEntry( aColor ); + + if(mpBgColorLB->GetSelectEntryCount() == 0) + { + mpBgColorLB->InsertEntry(aColor, OUString()); + mpBgColorLB->SelectEntry(aColor); + } + } + break; + case drawing::FillStyle_GRADIENT: + { + const SvxColorListItem aItem(*static_cast<const SvxColorListItem*>(pSh->GetItem(SID_COLOR_TABLE))); + mpBgBitmapLB->Hide(); + mpBgHatchingLB->Hide(); + mpBgColorLB->Show(); + mpBgGradientLB->Show(); + mpBgColorLB->Clear(); + mpBgGradientLB->Clear(); + mpBgColorLB->Fill(aItem.GetColorList()); + mpBgGradientLB->Fill(aItem.GetColorList()); + + const XGradient xGradient = GetGradientSetOrDefault(); + const Color aStartColor = xGradient.GetStartColor(); + const Color aEndColor = xGradient.GetEndColor(); + mpBgColorLB->SelectEntry( aStartColor ); + mpBgGradientLB->SelectEntry( aEndColor ); + + if(mpBgColorLB->GetSelectEntryCount() == 0) + { + mpBgColorLB->InsertEntry(aStartColor, OUString()); + mpBgColorLB->SelectEntry(aStartColor); + } + + if(mpBgGradientLB->GetSelectEntryCount() == 0) + { + mpBgGradientLB->InsertEntry(aEndColor, OUString()); + mpBgGradientLB->SelectEntry(aEndColor); + } + } + break; + + case drawing::FillStyle_HATCH: + { + mpBgColorLB->Hide(); + mpBgGradientLB->Hide(); + mpBgBitmapLB->Hide(); + const SvxHatchListItem aItem(*static_cast<const SvxHatchListItem*>(pSh->GetItem(SID_HATCH_LIST))); + mpBgHatchingLB->Show(); + mpBgHatchingLB->Clear(); + mpBgHatchingLB->Fill(aItem.GetHatchList()); + + const OUString aHatchName = GetHatchingSetOrDefault(); + mpBgHatchingLB->SelectEntry( aHatchName ); + } + break; + + case drawing::FillStyle_BITMAP: + { + mpBgColorLB->Hide(); + mpBgGradientLB->Hide(); + mpBgHatchingLB->Hide(); + const SvxBitmapListItem aItem(*static_cast<const SvxBitmapListItem*>(pSh->GetItem(SID_BITMAP_LIST))); + mpBgBitmapLB->Show(); + mpBgBitmapLB->Clear(); + mpBgBitmapLB->Fill(aItem.GetBitmapList()); + + const OUString aBitmapName = GetBitmapSetOrDefault(); + mpBgBitmapLB->SelectEntry( aBitmapName ); + } + break; + + default: + break; + } +} + +Color PageStylesPanel::GetColorSetOrDefault() +{ + if ( !mpBgColorItem ) + mpBgColorItem.reset( new XFillColorItem( OUString(), Color(0x72, 0x9f, 0xcf) ) ); + + return mpBgColorItem->GetColorValue(); +} + +XGradient PageStylesPanel::GetGradientSetOrDefault() +{ + if( !mpBgGradientItem ) + { + SfxObjectShell* pSh = SfxObjectShell::Current(); + const SvxGradientListItem aGradListItem(*static_cast<const SvxGradientListItem*>(pSh->GetItem(SID_GRADIENT_LIST))); + const XGradient aGradient = aGradListItem.GetGradientList()->GetGradient(0)->GetGradient(); + const OUString aGradientName = aGradListItem.GetGradientList()->GetGradient(0)->GetName(); + + mpBgGradientItem.reset( new XFillGradientItem( aGradientName, aGradient ) ); + } + + return mpBgGradientItem->GetGradientValue(); +} + +const OUString PageStylesPanel::GetHatchingSetOrDefault() +{ + if( !mpBgHatchItem ) + { + SfxObjectShell* pSh = SfxObjectShell::Current(); + const SvxHatchListItem aHatchListItem(*static_cast<const SvxHatchListItem*>(pSh->GetItem(SID_HATCH_LIST))); + const XHatch aHatch = aHatchListItem.GetHatchList()->GetHatch(0)->GetHatch(); + const OUString aHatchName = aHatchListItem.GetHatchList()->GetHatch(0)->GetName(); + + mpBgHatchItem.reset( new XFillHatchItem( aHatchName, aHatch ) ); + } + + return mpBgHatchItem->GetName(); +} + +const OUString PageStylesPanel::GetBitmapSetOrDefault() +{ + if( !mpBgBitmapItem ) + { + SfxObjectShell* pSh = SfxObjectShell::Current(); + const SvxBitmapListItem aBmpListItem(*static_cast<const SvxBitmapListItem*>(pSh->GetItem(SID_BITMAP_LIST))); + const GraphicObject aGraphObj = aBmpListItem.GetBitmapList()->GetBitmap(0)->GetGraphicObject(); + const OUString aBmpName = aBmpListItem.GetBitmapList()->GetBitmap(0)->GetName(); + + mpBgBitmapItem.reset( new XFillBitmapItem( aBmpName, aGraphObj ) ); + } + + return mpBgBitmapItem->GetName(); +} + void PageStylesPanel::NotifyItemUpdate( - const sal_uInt16 /*nSid*/, - const SfxItemState /*eState*/, - const SfxPoolItem* /*pState*/, - const bool /*bIsEnabled*/) + const sal_uInt16 nSid, + const SfxItemState eState, + const SfxPoolItem* pState, + const bool bIsEnabled) +{ + (void)bIsEnabled; + + if(IsDisposed()) + return; + + switch(nSid) + { + case SID_ATTR_PAGE_COLUMN: + { + if ( eState >= SfxItemState::DEFAULT && + pState && dynamic_cast< const SfxInt16Item *>( pState ) != nullptr ) + { + mpPageColumnItem.reset( static_cast<SfxInt16Item*>(pState->Clone()) ); + if(mpPageColumnItem->GetValue() <= 5) + { + mpColumnCount->SelectEntryPos(mpPageColumnItem->GetValue() - 1); + mpColumnCount->RemoveEntry(aCustomEntry); + } + else + { + if(mpColumnCount->GetEntryPos(aCustomEntry) == LISTBOX_ENTRY_NOTFOUND) + mpColumnCount->InsertEntry(aCustomEntry); + mpColumnCount->SelectEntry(aCustomEntry); + } + } + } + break; + + case SID_ATTR_PAGE: + { + if( eState >= SfxItemState::DEFAULT && + pState && dynamic_cast< const SvxPageItem*>( pState ) != nullptr ) + { + mpPageItem.reset( static_cast<SvxPageItem*>(pState->Clone()) ); + SvxNumType eNumType = mpPageItem->GetNumType(); + mpNumberSelectLB->SetSelection(eNumType); + + sal_uInt16 nUse = mpPageItem->GetPageUsage(); + mpLayoutSelectLB->SelectEntryPos( PageUsageToPos_Impl( nUse ) ); + } + } + break; + + case SID_ATTR_PAGE_COLOR: + { + if(eState >= SfxItemState::DEFAULT) + { + mpBgFillType->SelectEntryPos(1); + mpBgColorItem.reset(pState ? static_cast< XFillColorItem* >(pState->Clone()) : nullptr); + Update(); + } + } + break; + + case SID_ATTR_PAGE_HATCH: + { + if(eState >= SfxItemState::DEFAULT) + { + mpBgFillType->SelectEntryPos(3); + mpBgHatchItem.reset(pState ? static_cast < XFillHatchItem* >(pState->Clone()) : nullptr); + Update(); + } + } + break; + + case SID_ATTR_PAGE_GRADIENT: + { + if(eState >= SfxItemState::DEFAULT) + { + mpBgFillType->SelectEntryPos(2); + mpBgGradientItem.reset(pState ? static_cast< XFillGradientItem* >(pState->Clone()) : nullptr); + Update(); + } + } + break; + case SID_ATTR_PAGE_BITMAP: + { + if(eState >= SfxItemState::DEFAULT) + { + mpBgFillType->SelectEntryPos(4); + mpBgBitmapItem.reset(pState ? static_cast< XFillBitmapItem* >(pState->Clone()) : nullptr); + Update(); + } + } + break; + + case SID_ATTR_PAGE_FILLSTYLE: + { + const XFillStyleItem* pFillStyleItem = nullptr; + if (eState >= SfxItemState::DEFAULT) + pFillStyleItem = dynamic_cast< const XFillStyleItem* >(pState); + if (pFillStyleItem) + { + css::drawing::FillStyle eXFS = pFillStyleItem->GetValue(); + switch(eXFS) + { + case drawing::FillStyle_NONE: + mpBgFillType->SelectEntryPos(0); + break; + case drawing::FillStyle_SOLID: + mpBgFillType->SelectEntryPos(1); + break; + case drawing::FillStyle_GRADIENT: + mpBgFillType->SelectEntryPos(2); + break; + case drawing::FillStyle_HATCH: + mpBgFillType->SelectEntryPos(3); + break; + case drawing::FillStyle_BITMAP: + mpBgFillType->SelectEntryPos(4); + break; + default: + break; + } + Update(); + } + } + break; + + default: + break; + } +} + +IMPL_LINK_NOARG_TYPED( PageStylesPanel, ModifyColumnCountHdl, ListBox&, void ) { + sal_uInt16 nColumnType = mpColumnCount->GetSelectEntryPos() + 1; + mpPageColumnItem->SetValue( nColumnType ); + mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLUMN, + SfxCallMode::RECORD, { mpPageColumnItem.get() }); +} + +IMPL_LINK_NOARG_TYPED( PageStylesPanel, ModifyNumberingHdl, ListBox&, void ) +{ + sal_uInt16 nEntryData = (sal_uInt16)reinterpret_cast<sal_uLong>(mpNumberSelectLB->GetEntryData(mpNumberSelectLB->GetSelectEntryPos())); + mpPageItem->SetNumType((SvxNumType)nEntryData); + mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_PAGE, SfxCallMode::RECORD, { mpPageItem.get() }); +} + +IMPL_LINK_NOARG_TYPED( PageStylesPanel, ModifyLayoutHdl, ListBox&, void ) +{ + sal_uInt16 nUse = mpLayoutSelectLB->GetSelectEntryPos(); + mpPageItem->SetPageUsage(PosToPageUsage_Impl(nUse)); + mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_PAGE, SfxCallMode::RECORD, { mpPageItem.get() }); +} + +IMPL_LINK_NOARG_TYPED(PageStylesPanel, ModifyFillStyleHdl, ListBox&, void) +{ + const drawing::FillStyle eXFS = (drawing::FillStyle)mpBgFillType->GetSelectEntryPos(); + const XFillStyleItem aXFillStyleItem(eXFS); + Update(); + + switch (eXFS) + { + case drawing::FillStyle_NONE: + { + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_FILLSTYLE, SfxCallMode::RECORD, { &aXFillStyleItem }); + } + break; + + case drawing::FillStyle_SOLID: + { + XFillColorItem aItem( OUString(), mpBgColorItem->GetColorValue() ); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLOR, SfxCallMode::RECORD, { &aItem }); + } + break; + + case drawing::FillStyle_GRADIENT: + { + XFillGradientItem aItem( mpBgGradientItem->GetName(), mpBgGradientItem->GetGradientValue() ); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_GRADIENT, SfxCallMode::RECORD, { &aItem }); + } + break; + + case drawing::FillStyle_HATCH: + { + XFillHatchItem aItem( mpBgHatchItem->GetName(), mpBgHatchItem->GetHatchValue() ); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_HATCH, SfxCallMode::RECORD, { &aItem }); + } + break; + + case drawing::FillStyle_BITMAP: + { + XFillBitmapItem aItem( mpBgBitmapItem->GetName(), mpBgBitmapItem->GetGraphicObject() ); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_BITMAP, SfxCallMode::RECORD, { &aItem }); + } + break; + + default: + break; + } + mpBgFillType->Selected(); +} + +IMPL_LINK_NOARG_TYPED(PageStylesPanel, ModifyFillColorHdl, ListBox&, void) +{ + const drawing::FillStyle eXFS = (drawing::FillStyle)mpBgFillType->GetSelectEntryPos(); + SfxObjectShell* pSh = SfxObjectShell::Current(); + switch(eXFS) + { + case drawing::FillStyle_SOLID: + { + XFillColorItem aItem(OUString(), mpBgColorLB->GetSelectEntryColor()); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLOR, SfxCallMode::RECORD, { &aItem }); + } + break; + case drawing::FillStyle_GRADIENT: + { + XGradient aGradient; + aGradient.SetStartColor(mpBgColorLB->GetSelectEntryColor()); + aGradient.SetEndColor(mpBgGradientLB->GetSelectEntryColor()); + + XFillGradientItem aItem(aGradient); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_GRADIENT, SfxCallMode::RECORD, { &aItem }); + } + break; + case drawing::FillStyle_HATCH: + { + const SvxHatchListItem aHatchListItem(*static_cast<const SvxHatchListItem*>(pSh->GetItem(SID_HATCH_LIST))); + sal_uInt16 nPos = mpBgHatchingLB->GetSelectEntryPos(); + XHatch aHatch = aHatchListItem.GetHatchList()->GetHatch(nPos)->GetHatch(); + const OUString aHatchName = aHatchListItem.GetHatchList()->GetHatch(nPos)->GetName(); + + XFillHatchItem aItem(aHatchName, aHatch); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_HATCH, SfxCallMode::RECORD, { &aItem }); + } + break; + + case drawing::FillStyle_BITMAP: + { + SvxBitmapListItem aBitmapListItem(*static_cast<const SvxBitmapListItem*>(pSh->GetItem(SID_BITMAP_LIST))); + sal_Int16 nPos = mpBgBitmapLB->GetSelectEntryPos(); + GraphicObject aBitmap = aBitmapListItem.GetBitmapList()->GetBitmap(nPos)->GetGraphicObject(); + OUString aBitmapName = aBitmapListItem.GetBitmapList()->GetBitmap(nPos)->GetName(); + XFillBitmapItem aItem(aBitmapName, aBitmap); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_BITMAP, SfxCallMode::RECORD, { &aItem }); + } + break; + default: + break; + } } } } diff --git a/sw/source/uibase/sidebar/PageStylesPanel.hxx b/sw/source/uibase/sidebar/PageStylesPanel.hxx index 756994be4f96..f4ff4d3de5e9 100644 --- a/sw/source/uibase/sidebar/PageStylesPanel.hxx +++ b/sw/source/uibase/sidebar/PageStylesPanel.hxx @@ -43,7 +43,13 @@ #include <tools/fldunit.hxx> #include <svl/poolitem.hxx> #include <svx/rulritem.hxx> +#include <svx/dlgctrl.hxx> +#include <svx/xfillit.hxx> +#include <svx/xfillit0.hxx> +#include <svx/itemwin.hxx> +#include <svx/pagenumberlistbox.hxx> +class List; namespace sw { namespace sidebar { class PageStylesPanel: @@ -53,7 +59,8 @@ class PageStylesPanel: public: static VclPtr<vcl::Window> Create( vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame); + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + SfxBindings* pBindings); virtual void NotifyItemUpdate( const sal_uInt16 nSId, @@ -61,11 +68,57 @@ public: const SfxPoolItem* pState, const bool bIsEnabled) override; + SfxBindings* GetBindings() const { return mpBindings; } PageStylesPanel( vcl::Window* pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame); + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame, + SfxBindings* pBindings); virtual ~PageStylesPanel(); virtual void dispose() override; + +private: + + SfxBindings* mpBindings; + + ::std::unique_ptr<SfxInt16Item> mpPageColumnItem; + ::std::unique_ptr<SvxPageItem> mpPageItem; + ::std::unique_ptr<XFillStyleItem> mpBgFillStyleItem; + ::std::unique_ptr<XFillColorItem> mpBgColorItem; + ::std::unique_ptr<XFillGradientItem> mpBgGradientItem; + ::std::unique_ptr<XFillHatchItem> mpBgHatchItem; + ::std::unique_ptr<XFillBitmapItem> mpBgBitmapItem; + + ::sfx2::sidebar::ControllerItem maPageColumnControl; + ::sfx2::sidebar::ControllerItem maPageNumFormatControl; + ::sfx2::sidebar::ControllerItem maBgColorControl; + ::sfx2::sidebar::ControllerItem maBgHatchingControl; + ::sfx2::sidebar::ControllerItem maBgGradientControl; + ::sfx2::sidebar::ControllerItem maBgBitmapControl; + ::sfx2::sidebar::ControllerItem maBgFillStyleControl; + + VclPtr<ColorLB> mpBgColorLB; + VclPtr<SvxFillAttrBox> mpBgHatchingLB; + VclPtr<ColorLB> mpBgGradientLB; + VclPtr<SvxFillAttrBox> mpBgBitmapLB; + VclPtr<ListBox> mpLayoutSelectLB; + VclPtr<ListBox> mpColumnCount; + VclPtr<PageNumberListBox> mpNumberSelectLB; + VclPtr<SvxFillTypeBox> mpBgFillType; + VclPtr<FixedText> mpCustomEntry; + OUString aCustomEntry; + + void Initialize(); + void Update(); + Color GetColorSetOrDefault(); + XGradient GetGradientSetOrDefault(); + const OUString GetHatchingSetOrDefault(); + const OUString GetBitmapSetOrDefault(); + + DECL_LINK_TYPED( ModifyColumnCountHdl, ListBox&, void ); + DECL_LINK_TYPED( ModifyNumberingHdl, ListBox&, void ); + DECL_LINK_TYPED( ModifyLayoutHdl, ListBox&, void ); + DECL_LINK_TYPED( ModifyFillStyleHdl, ListBox&, void ); + DECL_LINK_TYPED( ModifyFillColorHdl, ListBox&, void ); }; } } //end of namespace sw::sidebar diff --git a/sw/source/uibase/sidebar/SwPanelFactory.cxx b/sw/source/uibase/sidebar/SwPanelFactory.cxx index 913a17086092..8cca8e26f9b8 100644 --- a/sw/source/uibase/sidebar/SwPanelFactory.cxx +++ b/sw/source/uibase/sidebar/SwPanelFactory.cxx @@ -135,7 +135,7 @@ Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement ( } else if(rsResourceURL.endsWith("/PageStylesPanel")) { - VclPtr<vcl::Window> pPanel = sw::sidebar::PageStylesPanel::Create( pParentWindow, xFrame ); + VclPtr<vcl::Window> pPanel = sw::sidebar::PageStylesPanel::Create( pParentWindow, xFrame, pBindings ); xElement = sfx2::sidebar::SidebarPanelBase::Create( rsResourceURL, xFrame, diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx index e4e7964c9660..6f50300ac3a6 100644 --- a/sw/source/uibase/uiview/viewtab.cxx +++ b/sw/source/uibase/uiview/viewtab.cxx @@ -32,6 +32,8 @@ #include <svl/eitem.hxx> #include <svl/whiter.hxx> #include <svx/ruler.hxx> +#include <svx/xfillit.hxx> +#include <svx/xfillit0.hxx> #include <editeng/protitem.hxx> #include <svl/rectitem.hxx> #include <sfx2/bindings.hxx> @@ -1086,6 +1088,68 @@ void SwView::ExecTabWin( SfxRequest& rReq ) } break; + case SID_ATTR_PAGE_COLOR: + case SID_ATTR_PAGE_FILLSTYLE: + case SID_ATTR_PAGE_GRADIENT: + case SID_ATTR_PAGE_HATCH: + case SID_ATTR_PAGE_BITMAP: + { + if(pReqArgs) + { + SwPageDesc aDesc(rDesc); + SwFrameFormat &rMaster = aDesc.GetMaster(); + switch (nSlot) + { + case(SID_ATTR_PAGE_FILLSTYLE): + { + XFillStyleItem aFSItem( static_cast<const XFillStyleItem&>(pReqArgs->Get( XATTR_FILLSTYLE )) ); + drawing::FillStyle eXFS = aFSItem.GetValue(); + + if ( eXFS == drawing::FillStyle_NONE ) + rMaster.SetFormatAttr( XFillStyleItem( eXFS ) ); + } + break; + + case(SID_ATTR_PAGE_COLOR): + { + XFillColorItem aColorItem( static_cast<const XFillColorItem&>(pReqArgs->Get( XATTR_FILLCOLOR )) ); + rMaster.SetFormatAttr( XFillStyleItem( drawing::FillStyle_SOLID ) ); + rMaster.SetFormatAttr( XFillColorItem( aColorItem )); + } + break; + + case(SID_ATTR_PAGE_GRADIENT): + { + XFillGradientItem aGradientItem( static_cast<const XFillGradientItem&>(pReqArgs->Get( XATTR_FILLGRADIENT )) ); + rMaster.SetFormatAttr( XFillStyleItem( drawing::FillStyle_GRADIENT ) ); + rMaster.SetFormatAttr( XFillGradientItem( aGradientItem ) ); + } + break; + + case(SID_ATTR_PAGE_HATCH): + { + XFillHatchItem aHatchItem( static_cast<const XFillHatchItem&>(pReqArgs->Get( XATTR_FILLHATCH )) ); + rMaster.SetFormatAttr( XFillStyleItem( drawing::FillStyle_HATCH ) ); + rMaster.SetFormatAttr( XFillHatchItem( aHatchItem )); + } + break; + + case(SID_ATTR_PAGE_BITMAP): + { + XFillBitmapItem aBitmapItem( static_cast<const XFillBitmapItem&>(pReqArgs->Get( XATTR_FILLBITMAP )) ); + rMaster.SetFormatAttr( XFillStyleItem( drawing::FillStyle_BITMAP ) ); + rMaster.SetFormatAttr( XFillBitmapItem( aBitmapItem )); + } + break; + + default: + break; + } + rSh.ChgPageDesc(rSh.GetCurPageDesc(), aDesc); + } + } + break; + default: OSL_ENSURE( false, "wrong SlotId"); } @@ -2150,6 +2214,7 @@ void SwView::StateTabWin(SfxItemSet& rSet) } } break; + case SID_ATTR_PAGE_HEADER: case SID_ATTR_PAGE_HEADER_LRMARGIN: case SID_ATTR_PAGE_HEADER_SPACING: @@ -2202,6 +2267,65 @@ void SwView::StateTabWin(SfxItemSet& rSet) } } break; + + case SID_ATTR_PAGE_COLOR: + case SID_ATTR_PAGE_FILLSTYLE: + case SID_ATTR_PAGE_GRADIENT: + case SID_ATTR_PAGE_HATCH: + case SID_ATTR_PAGE_BITMAP: + { + SfxItemSet aSet = rDesc.GetMaster().GetAttrSet(); + drawing::FillStyle eXFS = (drawing::FillStyle) ( static_cast<const XFillStyleItem*>( + aSet.GetItem(XATTR_FILLSTYLE) )->GetValue() ); + XFillStyleItem aFillStyleItem( eXFS ); + aFillStyleItem.SetWhich( SID_ATTR_PAGE_FILLSTYLE ); + rSet.Put(aFillStyleItem); + switch(eXFS) + { + case (drawing::FillStyle_SOLID): + { + Color aColor = static_cast<const XFillColorItem*>( aSet.GetItem( XATTR_FILLCOLOR, false ) )->GetColorValue(); + XFillColorItem aFillColorItem( OUString(), aColor ); + aFillColorItem.SetWhich( SID_ATTR_PAGE_COLOR ); + rSet.Put( aFillColorItem ); + } + break; + + case (drawing::FillStyle_GRADIENT): + { + const XGradient& xGradient = static_cast<const XFillGradientItem*>( aSet.GetItem( XATTR_FILLGRADIENT ) )->GetGradientValue(); + XFillGradientItem aFillGradientItem( OUString(), xGradient, SID_ATTR_PAGE_GRADIENT ); + rSet.Put( aFillGradientItem ); + } + break; + + case (drawing::FillStyle_HATCH): + { + const XFillHatchItem *pFillHatchItem( static_cast<const XFillHatchItem*>( aSet.GetItem( XATTR_FILLHATCH ) ) ); + XFillHatchItem aFillHatchItem( pFillHatchItem->GetName(), pFillHatchItem->GetHatchValue()); + aFillHatchItem.SetWhich( SID_ATTR_PAGE_HATCH ); + rSet.Put( aFillHatchItem ); + } + break; + + case (drawing::FillStyle_BITMAP): + { + const XFillBitmapItem *pFillBitmapItem = static_cast<const XFillBitmapItem*>( aSet.GetItem( XATTR_FILLBITMAP ) ); + XFillBitmapItem aFillBitmapItem( pFillBitmapItem->GetName(), pFillBitmapItem->GetGraphicObject() ); + aFillBitmapItem.SetWhich( SID_ATTR_PAGE_BITMAP ); + rSet.Put( aFillBitmapItem ); + } + break; + case (drawing::FillStyle_NONE): + { + } + break; + + default: + break; + } + } + break; } nWhich = aIter.NextWhich(); } diff --git a/sw/uiconfig/swriter/ui/pagestylespanel.ui b/sw/uiconfig/swriter/ui/pagestylespanel.ui index f0fe76affc5c..af62c9be929f 100644 --- a/sw/uiconfig/swriter/ui/pagestylespanel.ui +++ b/sw/uiconfig/swriter/ui/pagestylespanel.ui @@ -1,7 +1,34 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.16.1 --> <interface> - <requires lib="gtk+" version="3.12"/> + <requires lib="gtk+" version="3.0"/> + <!-- interface-requires LibreOffice 1.0 --> + <object class="GtkListStore" id="liststorePageLayout"> + <columns> + <!-- column-name gchararray1 --> + <column type="gchararray"/> + <!-- column-name gint1 --> + <column type="gint"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">Right and left</col> + <col id="1">0</col> + </row> + <row> + <col id="0" translatable="yes">Mirrored</col> + <col id="1">0</col> + </row> + <row> + <col id="0" translatable="yes">Only right</col> + <col id="1">0</col> + </row> + <row> + <col id="0" translatable="yes">Only left</col> + <col id="1">0</col> + </row> + </data> + </object> <object class="GtkGrid" id="PageStylesPanel"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -13,114 +40,202 @@ <property name="can_focus">False</property> <property name="hexpand">True</property> <property name="vexpand">True</property> + <property name="border_width">6</property> <property name="row_spacing">6</property> <property name="column_spacing">6</property> <child> <object class="GtkLabel" id="numberslabel"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="halign">end</property> <property name="label" translatable="yes">Number:</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> <object class="GtkLabel" id="backgroundlabel"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="halign">end</property> <property name="label" translatable="yes">Background:</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="svxcorelo-PageNumberListBox" id="numberbox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> <object class="GtkLabel" id="layoutlabel"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="halign">end</property> <property name="label" translatable="yes">Layout:</property> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">3</property> + <property name="top_attach">6</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="layoutbox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="model">liststorePageLayout</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">6</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> <object class="GtkLabel" id="columnlabel"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="halign">end</property> <property name="label" translatable="yes">Column:</property> </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">4</property> + <property name="top_attach">7</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> - <object class="GtkComboBox" id="layoutCombobox"> + <object class="GtkComboBoxText" id="columnbox"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="popup_fixed_width">False</property> + <items> + <item translatable="yes">1 Column</item> + <item translatable="yes">2 Column</item> + <item translatable="yes">3 Column</item> + <item translatable="yes">Left</item> + <item translatable="yes">Right</item> + </items> </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">0</property> + <property name="top_attach">7</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> - <object class="GtkComboBox" id="l"> + <object class="svxlo-SvxFillAttrBox" id="lbhatching"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">1</property> + <property name="top_attach">3</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> - <object class="GtkComboBox" id="combobox1"> + <object class="svxlo-SvxFillAttrBox" id="lbbitmap"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">4</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="svxlo-ColorLB" id="lbcolor"> <property name="visible">True</property> <property name="can_focus">False</property> </object> <packing> <property name="left_attach">1</property> <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> - <object class="GtkComboBox" id="combobox2"> + <object class="svxlo-ColorLB" id="lbgradient"> <property name="visible">True</property> <property name="can_focus">False</property> </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">3</property> + <property name="top_attach">5</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> - <object class="GtkSpinButton" id="spinbutton1"> + <object class="svxlo-SvxFillTypeBox" id="bgselect"> <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="can_focus">False</property> </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">4</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> + <object class="GtkLabel" id="customlabel"> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Custom</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">8</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> <placeholder/> </child> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> </object> |