Kaydet (Commit) 9196de99 authored tarafından Katarina Behrens's avatar Katarina Behrens

Move page size listbox from cui to svx

make it a custom widget so it is accessible e.g. to sidebar panels

Change-Id: Ic36a9a8af96a09fc76efd8e9ae75b8ebdf81717e
Reviewed-on: https://gerrit.libreoffice.org/25764Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
Tested-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst d0879b72
......@@ -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 \
))
......
......@@ -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)
......
......@@ -26,6 +26,7 @@
#include <vcl/lstbox.hxx>
#include <svtools/stdctrl.hxx>
#include <svx/pagectrl.hxx>
#include <svx/papersizelistbox.hxx>
#include <svx/frmdirlbox.hxx>
#include <editeng/svxenum.hxx>
#include <i18nutil/paper.hxx>
......@@ -76,7 +77,7 @@ class SvxPageDescPage : public SfxTabPage
static const sal_uInt16 pRanges[];
private:
// paper format
VclPtr<ListBox> m_pPaperSizeBox;
VclPtr<PaperSizeListBox> m_pPaperSizeBox;
VclPtr<MetricField> m_pPaperWidthEdit;
VclPtr<MetricField> m_pPaperHeightEdit;
......
......@@ -47,7 +47,6 @@
#include <dialmgr.hxx>
#include <sfx2/module.hxx>
#include <svl/stritem.hxx>
#include <svx/dialogs.hrc>
#include <editeng/eerdll.hxx>
#include <editeng/editrids.hrc>
#include <svx/svxids.hrc>
......@@ -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<void*>((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<sal_uLong>(m_pPaperSizeBox->GetEntryData( nPos ));
PaperSizeListBox& rListBox = static_cast<PaperSizeListBox&>( 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<sal_uLong>(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<sal_uLong>(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() )
{
......
......@@ -55,7 +55,7 @@
</packing>
</child>
<child>
<object class="GtkComboBox" id="comboPageFormat">
<object class="svxcorelo-PaperSizeListBox" id="comboPageFormat">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
......
......@@ -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
......
/* -*- 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 <i18nutil/paper.hxx>
#include <svx/svxdllapi.h>
#include <vcl/lstbox.hxx>
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: */
......@@ -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<void*>( (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<MapUnit>(meUnit),true);
sal_Int32 nEntryCount = mpPaperSizeBox->GetEntryCount();
for (sal_Int32 i = 0; i < nEntryCount; ++i )
{
Paper eTmp = (Paper)reinterpret_cast<sal_uLong>(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<sal_uLong>( mpPaperSizeBox->GetEntryData( nPos ) );
Paper ePaper = mpPaperSizeBox->GetSelection();
Size aSize(SvxPaperInfo::GetPaperSize(ePaper, (MapUnit)(meUnit)));
if(mpPaperOrientation->GetSelectEntryPos() == 0)
......
......@@ -34,6 +34,7 @@
#include <com/sun/star/drawing/XDrawView.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include "fupage.hxx"
#include <svx/papersizelistbox.hxx>
#include <svx/xflclit.hxx>
#include <svx/xgrad.hxx>
#include <svx/xflgrit.hxx>
......@@ -43,6 +44,7 @@
#include <svx/xflhtit.hxx>
#include "EventMultiplexer.hxx"
namespace sd { namespace sidebar {
class SlideBackground :
......@@ -70,7 +72,7 @@ private:
ViewShellBase& mrBase;
VclPtr<ListBox> mpPaperSizeBox;
VclPtr<PaperSizeListBox> mpPaperSizeBox;
VclPtr<ListBox> mpPaperOrientation;
VclPtr<ListBox> mpMasterSlide;
VclPtr<SvxFillTypeBox> mpFillStyle;
......
......@@ -172,42 +172,9 @@
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="paperformat">
<object class="svxcorelo-PaperSizeListBox" id="paperformat">
<property name="visible">True</property>
<property name="can_focus">False</property>
<items>
<item translatable="yes">A6</item>
<item translatable="yes">A5</item>
<item translatable="yes">A4</item>
<item translatable="yes">A3</item>
<item translatable="yes">A2</item>
<item translatable="yes">A1</item>
<item translatable="yes">A0</item>
<item translatable="yes">B6 (ISO)</item>
<item translatable="yes">B5 (ISO)</item>
<item translatable="yes">B4 (ISO)</item>
<item translatable="yes">Letter</item>
<item translatable="yes">Legal</item>
<item translatable="yes">Long Bond</item>
<item translatable="yes">Tabloid</item>
<item translatable="yes">B6 (JIS)</item>
<item translatable="yes">B5 (JIS)</item>
<item translatable="yes">B4 (JIS)</item>
<item translatable="yes">16 Kai</item>
<item translatable="yes">32 Kai</item>
<item translatable="yes">Big 32 Kai</item>
<item translatable="yes">User</item>
<item translatable="yes">DL Envelope</item>
<item translatable="yes">C6 Envelope</item>
<item translatable="yes">C6/5 Envelope</item>
<item translatable="yes">C5 Envelope</item>
<item translatable="yes">C4 Envelope</item>
<item translatable="yes">Dia Slide</item>
<item translatable="yes">Screen 4:3</item>
<item translatable="yes">Screen 16:9</item>
<item translatable="yes">Screen 16:10</item>
<item translatable="yes">Japanese Postcard</item>
</items>
</object>
<packing>
<property name="left_attach">1</property>
......
......@@ -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 \
......
......@@ -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 \
......
......@@ -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 ----------------------------------------------------------------
......
......@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <cuires.hrc>
#include <svx/dialogs.hrc>
#include "page.h"
// RID_SVXPAGE_PAGE ------------------------------------------------------
......
/* -*- 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/papersizelistbox.hxx>
#include <tools/resary.hxx>
#include <vcl/builderfactory.hxx>
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<void*>((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<sal_uLong>(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<sal_uLong>(GetEntryData( nPos ));
return ePaper;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment