diff --git a/cui/AllLangResTarget_cui.mk b/cui/AllLangResTarget_cui.mk index 8d5ece0819e7..7cb854c0690a 100644 --- a/cui/AllLangResTarget_cui.mk +++ b/cui/AllLangResTarget_cui.mk @@ -49,7 +49,6 @@ $(eval $(call gb_SrsTarget_add_files,cui/res,\ cui/source/options/treeopt.src \ cui/source/tabpages/border.src \ cui/source/tabpages/frmdirlbox.src \ - cui/source/tabpages/page.src \ cui/source/tabpages/paragrph.src \ cui/source/tabpages/strings.src \ )) diff --git a/cui/source/inc/cuires.hrc b/cui/source/inc/cuires.hrc index f0a8ccd33223..103f74ffd78e 100644 --- a/cui/source/inc/cuires.hrc +++ b/cui/source/inc/cuires.hrc @@ -38,8 +38,6 @@ // RID_CUI_GALLERY_END (RID_SVX_START + 410) // used in "tabpages" -#define RID_SVXSTRARY_PAPERSIZE_STD (RID_SVX_START + 142) -#define RID_SVXSTRARY_PAPERSIZE_DRAW (RID_SVX_START + 143) #define RID_SVXSTR_READ_DATA_ERROR (RID_SVX_START + 230) #define RID_SVXSTR_TABLE_PRESET_NONE (RID_SVX_START + 969) #define RID_SVXSTR_TABLE_PRESET_ONLYOUTER (RID_SVX_START + 970) diff --git a/cui/source/inc/page.hxx b/cui/source/inc/page.hxx index d2ec71b063a5..67cd991bc662 100644 --- a/cui/source/inc/page.hxx +++ b/cui/source/inc/page.hxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -76,7 +77,7 @@ class SvxPageDescPage : public SfxTabPage static const sal_uInt16 pRanges[]; private: // paper format - VclPtr m_pPaperSizeBox; + VclPtr m_pPaperSizeBox; VclPtr m_pPaperWidthEdit; VclPtr m_pPaperHeightEdit; diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx index 1b72b7e76ae7..93916879a442 100644 --- a/cui/source/tabpages/page.cxx +++ b/cui/source/tabpages/page.cxx @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -557,29 +556,8 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) SetMetricValue( *m_pPaperWidthEdit, aPaperSize.Width(), SFX_MAPUNIT_100TH_MM ); m_pPaperSizeBox->Clear(); - sal_Int32 nActPos = LISTBOX_ENTRY_NOTFOUND; - sal_uInt16 nAryId = RID_SVXSTRARY_PAPERSIZE_STD; - - if ( ePaperStart != PAPER_A3 ) - nAryId = RID_SVXSTRARY_PAPERSIZE_DRAW; - ResStringArray aPaperAry( CUI_RES( nAryId ) ); - sal_uInt32 nCnt = aPaperAry.Count(); - - sal_Int32 nUserPos = LISTBOX_ENTRY_NOTFOUND; - for ( sal_uInt32 i = 0; i < nCnt; ++i ) - { - OUString aStr = aPaperAry.GetString(i); - Paper eSize = (Paper)aPaperAry.GetValue(i); - sal_Int32 nPos = m_pPaperSizeBox->InsertEntry( aStr ); - m_pPaperSizeBox->SetEntryData( nPos, reinterpret_cast((sal_uLong)eSize) ); - - if ( eSize == ePaper ) - nActPos = nPos; - if( eSize == PAPER_USER ) - nUserPos = nPos; - } - // preselect current paper format - #115915#: ePaper might not be in aPaperSizeBox so use PAPER_USER instead - m_pPaperSizeBox->SelectEntryPos( nActPos != LISTBOX_ENTRY_NOTFOUND ? nActPos : nUserPos ); + m_pPaperSizeBox->FillPaperSizeEntries( ( ePaperStart == PAPER_A3 ) ? PaperSizeStd : PaperSizeDraw ); + m_pPaperSizeBox->SetSelection( ePaper ); // application specific @@ -975,8 +953,8 @@ IMPL_LINK_NOARG_TYPED(SvxPageDescPage, PaperBinHdl_Impl, Control&, void) IMPL_LINK_TYPED( SvxPageDescPage, PaperSizeSelect_Impl, ListBox&, rBox, void ) { - const sal_Int32 nPos = rBox.GetSelectEntryPos(); - Paper ePaper = (Paper)reinterpret_cast(m_pPaperSizeBox->GetEntryData( nPos )); + PaperSizeListBox& rListBox = static_cast( rBox ); + Paper ePaper = rListBox.GetSelection(); if ( ePaper != PAPER_USER ) { @@ -1050,18 +1028,8 @@ IMPL_LINK_NOARG_TYPED(SvxPageDescPage, PaperSizeModify_Impl, Edit&, void) Size aSize( GetCoreValue( *m_pPaperWidthEdit, eUnit ), GetCoreValue( *m_pPaperHeightEdit, eUnit ) ); Paper ePaper = SvxPaperInfo::GetSvxPaper( aSize, (MapUnit)eUnit, true ); - sal_Int32 nEntryCount = m_pPaperSizeBox->GetEntryCount(); - for ( sal_Int32 i = 0; i < nEntryCount; ++i ) - { - Paper eTmp = (Paper)reinterpret_cast(m_pPaperSizeBox->GetEntryData(i)); - - if ( eTmp == ePaper ) - { - m_pPaperSizeBox->SelectEntryPos(i); - break; - } - } + m_pPaperSizeBox->SetSelection( ePaper ); UpdateExample_Impl( true ); } @@ -1460,8 +1428,7 @@ SfxTabPage::sfxpg SvxPageDescPage::DeactivatePage( SfxItemSet* _pSet ) // Inquiry whether the page margins are beyond the printing area. // If not, ask user whether they shall be taken. // If not, stay on the TabPage. - sal_Int32 nPos = m_pPaperSizeBox->GetSelectEntryPos(); - Paper ePaper = (Paper)reinterpret_cast(m_pPaperSizeBox->GetEntryData( nPos )); + Paper ePaper = m_pPaperSizeBox->GetSelection(); if ( ePaper != PAPER_SCREEN_4_3 && ePaper != PAPER_SCREEN_16_9 && ePaper != PAPER_SCREEN_16_10 && IsMarginOutOfRange() ) { diff --git a/cui/uiconfig/ui/pageformatpage.ui b/cui/uiconfig/ui/pageformatpage.ui index 81d376a0ebb5..dd12f7ef38af 100644 --- a/cui/uiconfig/ui/pageformatpage.ui +++ b/cui/uiconfig/ui/pageformatpage.ui @@ -55,7 +55,7 @@ - + True False diff --git a/include/svx/dialogs.hrc b/include/svx/dialogs.hrc index 5c9b5e4743a7..c030ff783924 100644 --- a/include/svx/dialogs.hrc +++ b/include/svx/dialogs.hrc @@ -1091,9 +1091,11 @@ #define RID_SVXSTR_PT (RID_SVX_START + 1392) #define RID_SVXIMG_WIDTH_CUSTOM (RID_SVX_START + 1393) #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) // !!! IMPORTANT: consider and update RID_SVXSTR_NEXTFREE when introducing new RIDs for Strings !!! -#define RID_SVXSTR_NEXTFREE (RID_SVX_START + 1395) +#define RID_SVXSTR_NEXTFREE (RID_SVX_START + 1397) // 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/papersizelistbox.hxx b/include/svx/papersizelistbox.hxx new file mode 100644 index 000000000000..8bc82f70542e --- /dev/null +++ b/include/svx/papersizelistbox.hxx @@ -0,0 +1,44 @@ +/* -*- 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_PAGESIZEHELPER_HXX +#define INCLUDED_SVX_PAGESIZEHELPER_HXX + +#include +#include +#include + +enum PaperSizeApp +{ + PaperSizeStd, + PaperSizeDraw +}; + +class SVX_DLLPUBLIC PaperSizeListBox : public ListBox +{ +public: + PaperSizeListBox( vcl::Window* pParent, WinBits nBits = WB_BORDER | WB_DROPDOWN ); + + void FillPaperSizeEntries( PaperSizeApp eApp ); + void SetSelection( Paper eSize ); + Paper GetSelection() const; +}; + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx index 28e9bd914b78..fb068fa26649 100644 --- a/sd/source/ui/sidebar/SlideBackground.cxx +++ b/sd/source/ui/sidebar/SlideBackground.cxx @@ -65,52 +65,6 @@ using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; -namespace { - void lcl_FillPaperSizeListbox ( ListBox &rListBox) - { - std::map< sal_Int32, Paper > aPaperSizeMap = - { - { 0, PAPER_A6 }, - { 1, PAPER_A5 }, - { 2, PAPER_A4 }, - { 3, PAPER_A3 }, - { 4, PAPER_A2 }, - { 5, PAPER_A1 }, - { 6, PAPER_A0 }, - { 7, PAPER_B6_ISO }, - { 8, PAPER_B5_ISO }, - { 9, PAPER_B4_ISO }, - { 10, PAPER_LETTER }, - { 11, PAPER_LEGAL }, - { 12, PAPER_FANFOLD_LEGAL_DE }, - { 13, PAPER_TABLOID }, - { 14, PAPER_B6_JIS }, - { 15, PAPER_B5_JIS }, - { 16, PAPER_B4_JIS }, - { 17, PAPER_KAI16 }, - { 18, PAPER_KAI32 }, - { 19, PAPER_KAI32BIG }, - { 20, PAPER_USER }, - { 21, PAPER_ENV_DL }, - { 22, PAPER_ENV_C6 }, - { 23, PAPER_ENV_C65 }, - { 24, PAPER_ENV_C5 }, - { 25, PAPER_ENV_C4 }, - { 26, PAPER_SLIDE_DIA }, - { 27, PAPER_SCREEN_4_3 }, - { 28, PAPER_SCREEN_16_9 }, - { 29, PAPER_SCREEN_16_10 }, - { 30, PAPER_POSTCARD_JP } - }; - - for ( sal_Int32 nIdx = 0; nIdx < rListBox.GetEntryCount(); nIdx++ ) - { - Paper eSize = aPaperSizeMap[nIdx]; - rListBox.SetEntryData( nIdx, reinterpret_cast( (sal_uLong)eSize )); - } - } -} - namespace sd { namespace sidebar { SlideBackground::SlideBackground( @@ -158,7 +112,7 @@ SlideBackground::~SlideBackground() void SlideBackground::Initialize() { - lcl_FillPaperSizeListbox( *mpPaperSizeBox ); + mpPaperSizeBox->FillPaperSizeEntries( PaperSizeDraw ); mpPaperSizeBox->SetSelectHdl(LINK(this,SlideBackground,PaperSizeModifyHdl)); mpPaperOrientation->SetSelectHdl(LINK(this,SlideBackground,PaperSizeModifyHdl)); @@ -548,18 +502,7 @@ void SlideBackground::NotifyItemUpdate( Swap(aPaperSize); Paper ePaper = SvxPaperInfo::GetSvxPaper(aPaperSize, static_cast(meUnit),true); - sal_Int32 nEntryCount = mpPaperSizeBox->GetEntryCount(); - - for (sal_Int32 i = 0; i < nEntryCount; ++i ) - { - Paper eTmp = (Paper)reinterpret_cast(mpPaperSizeBox->GetEntryData(i)); - - if ( eTmp == ePaper ) - { - mpPaperSizeBox->SelectEntryPos(i); - break; - } - } + mpPaperSizeBox->SetSelection( ePaper ); } } break; @@ -661,8 +604,7 @@ IMPL_LINK_NOARG_TYPED(SlideBackground, FillStyleModifyHdl, ListBox&, void) IMPL_LINK_NOARG_TYPED(SlideBackground, PaperSizeModifyHdl, ListBox&, void) { - sal_uInt32 nPos = mpPaperSizeBox->GetSelectEntryPos(); - Paper ePaper = (Paper)reinterpret_cast( mpPaperSizeBox->GetEntryData( nPos ) ); + Paper ePaper = mpPaperSizeBox->GetSelection(); Size aSize(SvxPaperInfo::GetPaperSize(ePaper, (MapUnit)(meUnit))); if(mpPaperOrientation->GetSelectEntryPos() == 0) diff --git a/sd/source/ui/sidebar/SlideBackground.hxx b/sd/source/ui/sidebar/SlideBackground.hxx index bbe9b4031f10..5cfc955206c7 100644 --- a/sd/source/ui/sidebar/SlideBackground.hxx +++ b/sd/source/ui/sidebar/SlideBackground.hxx @@ -34,6 +34,7 @@ #include #include #include "fupage.hxx" +#include #include #include #include @@ -43,6 +44,7 @@ #include #include "EventMultiplexer.hxx" + namespace sd { namespace sidebar { class SlideBackground : @@ -70,7 +72,7 @@ private: ViewShellBase& mrBase; - VclPtr mpPaperSizeBox; + VclPtr mpPaperSizeBox; VclPtr mpPaperOrientation; VclPtr mpMasterSlide; VclPtr mpFillStyle; diff --git a/sd/uiconfig/simpress/ui/sidebarslidebackground.ui b/sd/uiconfig/simpress/ui/sidebarslidebackground.ui index 5a569819448a..7f4ab0f566c9 100644 --- a/sd/uiconfig/simpress/ui/sidebarslidebackground.ui +++ b/sd/uiconfig/simpress/ui/sidebarslidebackground.ui @@ -172,42 +172,9 @@ - + True False - - A6 - A5 - A4 - A3 - A2 - A1 - A0 - B6 (ISO) - B5 (ISO) - B4 (ISO) - Letter - Legal - Long Bond - Tabloid - B6 (JIS) - B5 (JIS) - B4 (JIS) - 16 Kai - 32 Kai - Big 32 Kai - User - DL Envelope - C6 Envelope - C6/5 Envelope - C5 Envelope - C4 Envelope - Dia Slide - Screen 4:3 - Screen 16:9 - Screen 16:10 - Japanese Postcard - 1 diff --git a/svx/AllLangResTarget_svx.mk b/svx/AllLangResTarget_svx.mk index f8e67b3ae017..18e52d63507d 100644 --- a/svx/AllLangResTarget_svx.mk +++ b/svx/AllLangResTarget_svx.mk @@ -44,6 +44,7 @@ $(eval $(call gb_SrsTarget_add_files,svx/res,\ svx/source/dialog/frmsel.src \ svx/source/dialog/imapdlg.src \ svx/source/dialog/language.src \ + svx/source/dialog/page.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 dc9a483be01c..9bb991da1289 100644 --- a/svx/Library_svxcore.mk +++ b/svx/Library_svxcore.mk @@ -118,6 +118,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\ svx/source/dialog/hexcolorcontrol \ svx/source/dialog/framelink \ svx/source/dialog/langbox \ + svx/source/dialog/papersizelistbox \ svx/source/dialog/stddlg \ svx/source/dialog/svxdlg \ svx/source/engine3d/camera3d \ diff --git a/cui/source/tabpages/page.h b/svx/source/dialog/page.h similarity index 96% rename from cui/source/tabpages/page.h rename to svx/source/dialog/page.h index 8ad22787904e..2528e041e45c 100644 --- a/cui/source/tabpages/page.h +++ b/svx/source/dialog/page.h @@ -16,8 +16,8 @@ * 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_CUI_SOURCE_TABPAGES_PAGE_H -#define INCLUDED_CUI_SOURCE_TABPAGES_PAGE_H +#ifndef INCLUDED_SVX_SOURCE_DIALOGS_PAGE_H +#define INCLUDED_SVX_SOURCE_DIALOGS_PAGE_H // define ---------------------------------------------------------------- diff --git a/cui/source/tabpages/page.src b/svx/source/dialog/page.src similarity index 99% rename from cui/source/tabpages/page.src rename to svx/source/dialog/page.src index a5cdf3ab7bd1..b39830ce9a47 100644 --- a/cui/source/tabpages/page.src +++ b/svx/source/dialog/page.src @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include +#include #include "page.h" // RID_SVXPAGE_PAGE ------------------------------------------------------ diff --git a/svx/source/dialog/papersizelistbox.cxx b/svx/source/dialog/papersizelistbox.cxx new file mode 100644 index 000000000000..92210845a4d5 --- /dev/null +++ b/svx/source/dialog/papersizelistbox.cxx @@ -0,0 +1,81 @@ +/* -*- 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 + + +PaperSizeListBox::PaperSizeListBox(vcl::Window* pParent, WinBits nStyle) + : ListBox( pParent, nStyle) +{ +} + +VCL_BUILDER_FACTORY(PaperSizeListBox); + +void PaperSizeListBox::FillPaperSizeEntries( PaperSizeApp eApp ) +{ + ResStringArray aPaperAry( SVX_RES( ( eApp == PaperSizeStd ) ? + RID_SVXSTRARY_PAPERSIZE_STD : RID_SVXSTRARY_PAPERSIZE_DRAW ) ); + sal_uInt32 nCnt = aPaperAry.Count(); + + for ( sal_uInt32 i = 0; i < nCnt; ++i ) + { + OUString aStr = aPaperAry.GetString(i); + Paper eSize = (Paper)aPaperAry.GetValue(i); + sal_Int32 nPos = InsertEntry( aStr ); + SetEntryData( nPos, reinterpret_cast((sal_uLong)eSize) ); + } +} + +void PaperSizeListBox::SetSelection( Paper ePreselectPaper ) +{ + sal_Int32 nEntryCount = GetEntryCount(); + sal_Int32 nSelPos = LISTBOX_ENTRY_NOTFOUND; + sal_Int32 nUserPos = LISTBOX_ENTRY_NOTFOUND; + + for (sal_Int32 i = 0; i < nEntryCount; ++i ) + { + Paper eTmp = (Paper)reinterpret_cast(GetEntryData(i)); + + if ( eTmp == ePreselectPaper ) + { + nSelPos = i; + break; + } + + if ( eTmp == PAPER_USER ) + nUserPos = i; + } + + // preselect current paper format - #115915#: ePaper might not be in aPaperSizeBox so use PAPER_USER instead + SelectEntryPos( ( nSelPos != LISTBOX_ENTRY_NOTFOUND ) ? nSelPos : nUserPos ); +} + +Paper PaperSizeListBox::GetSelection() const +{ + const sal_Int32 nPos = GetSelectEntryPos(); + Paper ePaper = (Paper)reinterpret_cast(GetEntryData( nPos )); + + return ePaper; +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +