diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-05-28 08:11:28 +0200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-06-03 06:46:39 +0000 |
commit | 9196de99ed4dff2c1f8708bfd68da9b6424ae53b (patch) | |
tree | 2fa498e27babfcbd31c9fc7387932bbc5f60d949 /svx | |
parent | d0879b721d8c429248f9da7ce02c6c71327e2954 (diff) |
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/25764
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Tested-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/AllLangResTarget_svx.mk | 1 | ||||
-rw-r--r-- | svx/Library_svxcore.mk | 1 | ||||
-rw-r--r-- | svx/source/dialog/page.h | 69 | ||||
-rw-r--r-- | svx/source/dialog/page.src | 99 | ||||
-rw-r--r-- | svx/source/dialog/papersizelistbox.cxx | 81 |
5 files changed, 251 insertions, 0 deletions
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/svx/source/dialog/page.h b/svx/source/dialog/page.h new file mode 100644 index 000000000000..2528e041e45c --- /dev/null +++ b/svx/source/dialog/page.h @@ -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 . + */ +#ifndef INCLUDED_SVX_SOURCE_DIALOGS_PAGE_H +#define INCLUDED_SVX_SOURCE_DIALOGS_PAGE_H + +// define ---------------------------------------------------------------- + +//!! the values of the following defines must correspond to the array position +//!! of the respective paper size in the file i18nutil/source/utility/paper.cxx +//!! There are enums for them in i18nutil/inc/i18nutil/paper.hxx but unfortunately +//!! the resource compiler does not understand enums, thus the enum values need +//!! to be duplicated here for use in the src file. +#define PAPERSIZE_A0 0 +#define PAPERSIZE_A1 1 +#define PAPERSIZE_A2 2 +#define PAPERSIZE_A3 3 +#define PAPERSIZE_A4 4 +#define PAPERSIZE_A5 5 +#define PAPERSIZE_B4_ISO 6 +#define PAPERSIZE_B5_ISO 7 +#define PAPERSIZE_LETTER 8 +#define PAPERSIZE_LEGAL 9 +#define PAPERSIZE_TABLOID 10 +#define PAPERSIZE_USER 11 +#define PAPERSIZE_B6_ISO 12 +#define PAPERSIZE_C4 13 +#define PAPERSIZE_C5 14 +#define PAPERSIZE_C6 15 +#define PAPERSIZE_C65 16 +#define PAPERSIZE_DL 17 +#define PAPERSIZE_DIA 18 +#define PAPERSIZE_SCREEN_4_3 19 +#define PAPERSIZE_LEGAL2 24 +#define PAPERSIZE_MONARCH 25 +#define PAPERSIZE_COM675 26 +#define PAPERSIZE_COM9 27 +#define PAPERSIZE_COM10 28 +#define PAPERSIZE_COM11 29 +#define PAPERSIZE_COM12 30 +#define PAPERSIZE_KAI16 31 +#define PAPERSIZE_KAI32 32 +#define PAPERSIZE_KAI32BIG 33 +#define PAPERSIZE_B4_JIS 34 +#define PAPERSIZE_B5_JIS 35 +#define PAPERSIZE_B6_JIS 36 +#define PAPERSIZE_POSTCARD_JP 46 +#define PAPERSIZE_A6 56 +#define PAPERSIZE_SCREEN_16_9 78 +#define PAPERSIZE_SCREEN_16_10 79 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/dialog/page.src b/svx/source/dialog/page.src new file mode 100644 index 000000000000..b39830ce9a47 --- /dev/null +++ b/svx/source/dialog/page.src @@ -0,0 +1,99 @@ +/* -*- 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 "page.h" + + // RID_SVXPAGE_PAGE ------------------------------------------------------ + +StringArray RID_SVXSTRARY_PAPERSIZE_STD +{ + ItemList [ en-US ] = + { + < "A6" ; PAPERSIZE_A6 ; > ; + < "A5" ; PAPERSIZE_A5 ; > ; + < "A4" ; PAPERSIZE_A4 ; > ; + < "A3" ; PAPERSIZE_A3 ; > ; + < "B6 (ISO)" ; PAPERSIZE_B6_ISO ; > ; + < "B5 (ISO)" ; PAPERSIZE_B5_ISO ; > ; + < "B4 (ISO)" ; PAPERSIZE_B4_ISO ; > ; + < "Letter" ; PAPERSIZE_LETTER ; > ; + < "Legal" ; PAPERSIZE_LEGAL ; > ; + < "Long Bond" ; PAPERSIZE_LEGAL2 ; > ; + < "Tabloid" ; PAPERSIZE_TABLOID ; > ; + < "B6 (JIS)" ; PAPERSIZE_B6_JIS ; > ; + < "B5 (JIS)" ; PAPERSIZE_B5_JIS ; > ; + < "B4 (JIS)" ; PAPERSIZE_B4_JIS ; > ; + < "16 Kai" ; PAPERSIZE_KAI16; > ; + < "32 Kai" ; PAPERSIZE_KAI32; > ; + < "Big 32 Kai" ; PAPERSIZE_KAI32BIG; > ; + < "User" ; PAPERSIZE_USER ; > ; + < "DL Envelope" ; PAPERSIZE_DL ; > ; + < "C6 Envelope" ; PAPERSIZE_C6 ; > ; + < "C6/5 Envelope" ; PAPERSIZE_C65 ; > ; + < "C5 Envelope" ; PAPERSIZE_C5 ; > ; + < "C4 Envelope" ; PAPERSIZE_C4 ; > ; + < "#6¾ Envelope" ; PAPERSIZE_COM675; > ; + < "#7¾ (Monarch) Envelope" ; PAPERSIZE_MONARCH; > ; + < "#9 Envelope" ; PAPERSIZE_COM9; > ; + < "#10 Envelope" ; PAPERSIZE_COM10; > ; + < "#11 Envelope" ; PAPERSIZE_COM11; > ; + < "#12 Envelope" ; PAPERSIZE_COM12; > ; + < "Japanese Postcard" ; PAPERSIZE_POSTCARD_JP; > ; + }; +}; +StringArray RID_SVXSTRARY_PAPERSIZE_DRAW +{ + ItemList [ en-US ] = + { + < "A6" ; PAPERSIZE_A6 ; > ; + < "A5" ; PAPERSIZE_A5 ; > ; + < "A4" ; PAPERSIZE_A4 ; > ; + < "A3" ; PAPERSIZE_A3 ; > ; + < "A2" ; PAPERSIZE_A2 ; > ; + < "A1" ; PAPERSIZE_A1 ; > ; + < "A0" ; PAPERSIZE_A0 ; > ; + < "B6 (ISO)" ; PAPERSIZE_B6_ISO ; > ; + < "B5 (ISO)" ; PAPERSIZE_B5_ISO ; > ; + < "B4 (ISO)" ; PAPERSIZE_B4_ISO ; > ; + < "Letter" ; PAPERSIZE_LETTER ; > ; + < "Legal" ; PAPERSIZE_LEGAL ; > ; + < "Long Bond" ; PAPERSIZE_LEGAL2 ; > ; + < "Tabloid" ; PAPERSIZE_TABLOID ; > ; + < "B6 (JIS)" ; PAPERSIZE_B6_JIS ; > ; + < "B5 (JIS)" ; PAPERSIZE_B5_JIS ; > ; + < "B4 (JIS)" ; PAPERSIZE_B4_JIS ; > ; + < "16 Kai" ; PAPERSIZE_KAI16; > ; + < "32 Kai" ; PAPERSIZE_KAI32; > ; + < "Big 32 Kai" ; PAPERSIZE_KAI32BIG; > ; + < "User" ; PAPERSIZE_USER ; > ; + < "DL Envelope" ; PAPERSIZE_DL ; > ; + < "C6 Envelope" ; PAPERSIZE_C6 ; > ; + < "C6/5 Envelope" ; PAPERSIZE_C65 ; > ; + < "C5 Envelope" ; PAPERSIZE_C5 ; > ; + < "C4 Envelope" ; PAPERSIZE_C4 ; > ; + < "Dia Slide" ; PAPERSIZE_DIA ; > ; + < "Screen 4:3" ; PAPERSIZE_SCREEN_4_3 ; > ; + < "Screen 16:9" ; PAPERSIZE_SCREEN_16_9 ; > ; + < "Screen 16:10" ; PAPERSIZE_SCREEN_16_10 ; > ; + < "Japanese Postcard" ; PAPERSIZE_POSTCARD_JP; > ; + }; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 <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: */ + |