diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2016-09-07 20:50:17 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-09-12 10:31:33 +0000 |
commit | 69ce52fbf26fab9239562d2bfd407db67cfb6ec8 (patch) | |
tree | 08ea96f675c6163e5d21cb1f3ba2c69e9b65b40b /sw | |
parent | 65828fa693507d699369f0dbc3c0bfc31638d945 (diff) |
Page size popup converted to use outside sidebar
Change-Id: Ia9c4c03a9780dca146adda8f1a126197d3e38643
Reviewed-on: https://gerrit.libreoffice.org/28816
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/Library_sw.mk | 1 | ||||
-rw-r--r-- | sw/UIConfig_swriter.mk | 1 | ||||
-rw-r--r-- | sw/inc/PageSizePopup.hxx | 41 | ||||
-rw-r--r-- | sw/source/ui/sidebar/PagePropertyPanel.src | 155 | ||||
-rw-r--r-- | sw/source/uibase/app/swmodule.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PagePropertyPanel.cxx | 153 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PagePropertyPanel.hrc | 47 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PagePropertyPanel.hxx | 29 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageSizeControl.cxx | 117 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageSizeControl.hxx | 20 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageSizePopup.cxx | 46 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PropertyPanel.hrc | 2 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/notebookbar.ui | 27 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/pagesizecontrol.ui | 69 |
14 files changed, 284 insertions, 427 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index 793c3ff2939a..6f0877fc0cda 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -680,6 +680,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/uibase/sidebar/PageOrientationPopup \ sw/source/uibase/sidebar/PageMarginControl \ sw/source/uibase/sidebar/PageSizeControl \ + sw/source/uibase/sidebar/PageSizePopup \ sw/source/uibase/sidebar/PageColumnControl \ sw/source/uibase/sidebar/PageColumnPopup \ sw/source/uibase/sidebar/PagePropertyPanel \ diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index 0047dc3acbaf..45a52d82087f 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -209,6 +209,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\ sw/uiconfig/swriter/ui/notebookbar_single \ sw/uiconfig/swriter/ui/pagecolumncontrol \ sw/uiconfig/swriter/ui/pageorientationcontrol \ + sw/uiconfig/swriter/ui/pagesizecontrol \ sw/uiconfig/swriter/ui/paradialog \ sw/uiconfig/swriter/ui/picturedialog \ sw/uiconfig/swriter/ui/picturepage \ diff --git a/sw/inc/PageSizePopup.hxx b/sw/inc/PageSizePopup.hxx new file mode 100644 index 000000000000..091d853144d7 --- /dev/null +++ b/sw/inc/PageSizePopup.hxx @@ -0,0 +1,41 @@ +/* -*- 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_SW_INC_PAGESIZEPOPUP_HXX +#define INCLUDED_SW_INC_PAGESIZEPOPUP_HXX + +#include <sfx2/tbxctrl.hxx> +#include <swdllapi.h> +#include <vcl/vclenum.hxx> +#include <functional> + +class SW_DLLPUBLIC PageSizePopup : public SfxToolBoxControl +{ +public: + SFX_DECL_TOOLBOX_CONTROL(); + + PageSizePopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx); + virtual ~PageSizePopup(); + + virtual VclPtr<SfxPopupWindow> CreatePopupWindow() override; +}; + +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/sidebar/PagePropertyPanel.src b/sw/source/ui/sidebar/PagePropertyPanel.src index 901bc608c93b..6544520cba7a 100644 --- a/sw/source/ui/sidebar/PagePropertyPanel.src +++ b/sw/source/ui/sidebar/PagePropertyPanel.src @@ -62,122 +62,6 @@ Image IMG_PAGE_MARGIN_CUSTOM_L { ImageBitmap = Bitmap{File = "sidebar/pageproppanel/formatcopy_24x24.png";}; }; -Image IMG_PAGE_A3 -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsize_L_A3_24x24.png";}; -}; -Image IMG_PAGE_A4 -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsize_L_A4_24x24.png";}; -}; -Image IMG_PAGE_A5 -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsize_L_A5_24x24.png";}; -}; -Image IMG_PAGE_B4 -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsize_L_B4_24x24.png";}; -}; -Image IMG_PAGE_B5 -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsize_L_B5_24x24.png";}; -}; -Image IMG_PAGE_C5 -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsize_L_C5_24x24.png";}; -}; -Image IMG_PAGE_LETTER -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsize_L_copy_24x24.png";}; -}; -Image IMG_PAGE_LEGAL -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsize_L_copy_24x24.png";}; -}; -Image IMG_PAGE_SIZE_NONE -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsize_L_copy_24x24.png";}; -}; -Image IMG_PAGE_A3_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsizeA3_24x24.png";}; -}; -Image IMG_PAGE_A4_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsizeA4_24x24.png";}; -}; -Image IMG_PAGE_A5_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsizeA5_24x24.png";}; -}; -Image IMG_PAGE_B4_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsizeB4_24x24.png";}; -}; -Image IMG_PAGE_B5_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsizeB5_24x24.png";}; -}; -Image IMG_PAGE_C5_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsizeC5_24x24.png";}; -}; -Image IMG_PAGE_LETTER_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsizecopy_24x24.png";}; -}; -Image IMG_PAGE_LEGAL_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsizecopy_24x24.png";}; -}; -Image IMG_PAGE_SIZE_NONE_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/documentsizecopy_24x24.png";}; -}; -Image IMG_PAGE_COLUMN_1 -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/column_L_1_24x24.png";}; -}; -Image IMG_PAGE_COLUMN_2 -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/column_L_2_24x24.png";}; -}; -Image IMG_PAGE_COLUMN_3 -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/column_L_3_24x24.png";}; -}; -Image IMG_PAGE_COLUMN_LEFT -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/column_L_left_24x24.png";}; -}; -Image IMG_PAGE_COLUMN_RIGHT -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/column_L_right_24x24.png";}; -}; -Image IMG_PAGE_COLUMN_1_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/column1_24x24.png";}; -}; -Image IMG_PAGE_COLUMN_2_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/column2_24x24.png";}; -}; -Image IMG_PAGE_COLUMN_3_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/column3_24x24.png";}; -}; -Image IMG_PAGE_COLUMN_LEFT_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/columnleft_24x24.png";}; -}; -Image IMG_PAGE_COLUMN_RIGHT_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/columnright_24x24.png";}; -}; -Image IMG_PAGE_COLUMN_NONE_L -{ - ImageBitmap = Bitmap{File = "sidebar/pageproppanel/columncopy_24x24.png";}; -}; // popup for page style's margin attributes Control RID_POPUP_SWPAGE_MARGIN @@ -396,43 +280,4 @@ Control RID_POPUP_SWPAGE_MARGIN }; }; -// popup for page style's page size -Control RID_POPUP_SWPAGE_SIZE -{ - OutputSize = TRUE; - DialogControl = TRUE; - Border = FALSE; - Size = MAP_APPFONT( POPUPPANEL_MARGIN_SMALL * 2 + POPUP_BORDER_WIDTH + VS_WIDTH + 22, ITEM_HEIGHT2*8 + POPUPPANEL_MARGIN_SMALL*2 + CONTROL_SPACING_VERTICAL + 15 ); - - Control VS_SIZE - { - Pos = MAP_APPFONT( POPUPPANEL_MARGIN_SMALL + OFFSET_X, POPUPPANEL_MARGIN_SMALL + OFFSET_Y); - Size = MAP_APPFONT ( VS_WIDTH + 22 , ITEM_HEIGHT2*8); - HelpID = HID_SWPAGE_VS_SIZE; - TabStop = TRUE ; - Text = "Size"; - }; - PushButton CB_SIZE_MORE - { - Pos = MAP_APPFONT ( POPUPPANEL_MARGIN_SMALL + 2*OFFSET_X, POPUPPANEL_MARGIN_SMALL + 2*OFFSET_Y + ITEM_HEIGHT2*8 ) ; - Size = MAP_APPFONT ( VS_WIDTH - 2 + 22, 15 ) ; - HelpID = HID_SWPAGE_SIZE_MORE; - TabStop = TRUE ; - Text [ en-US ] = "~More Options"; - QuickHelpText [ en-US ] = "More Options" ; - }; - MetricField FLD_WIDTH_HEIGHT - { - Border = TRUE; - Left = TRUE; - Repeat = TRUE; - Spin = TRUE; - Maximum = 9999; - DecimalDigits = 2; - Unit = FUNIT_CM; - Last = 9999; - SpinSize = 10; - }; -}; - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx index 45be91e3c40e..5244398963ad 100644 --- a/sw/source/uibase/app/swmodule.cxx +++ b/sw/source/uibase/app/swmodule.cxx @@ -110,6 +110,7 @@ #include <barcfg.hxx> #include <svx/rubydialog.hxx> #include <svtools/colorcfg.hxx> +#include <PageSizePopup.hxx> #include <PageOrientationPopup.hxx> #include <PageColumnPopup.hxx> @@ -295,7 +296,7 @@ void SwDLL::RegisterControls() svx::ParaLRSpacingControl::RegisterControl(SID_ATTR_PARA_LRSPACE, pMod); PageOrientationPopup::RegisterControl(SID_ATTR_PAGE_ORIENTATION, pMod); PageColumnPopup::RegisterControl(SID_ATTR_PAGE_COLUMN, pMod); - + PageSizePopup::RegisterControl(SID_ATTR_PAGE_SIZE, pMod); SvxColorToolBoxControl::RegisterControl( SID_EXTRUSION_3D_COLOR, pMod ); SvxClipBoardControl::RegisterControl(SID_PASTE, pMod ); diff --git a/sw/source/uibase/sidebar/PagePropertyPanel.cxx b/sw/source/uibase/sidebar/PagePropertyPanel.cxx index ea0f3741554b..f754118a8844 100644 --- a/sw/source/uibase/sidebar/PagePropertyPanel.cxx +++ b/sw/source/uibase/sidebar/PagePropertyPanel.cxx @@ -28,7 +28,6 @@ #include <svx/sidebar/PopupContainer.hxx> #include "PageMarginControl.hxx" -#include "PageSizeControl.hxx" #include <swtypes.hxx> #include <cmdid.h> @@ -51,7 +50,6 @@ #include <com/sun/star/document/XUndoManagerSupplier.hpp> const char UNO_MARGIN[] = ".uno:Margin"; -const char UNO_SIZE[] = ".uno:Size"; namespace { const css::uno::Reference< css::document::XUndoManager > getUndoManager( const css::uno::Reference< css::frame::XFrame >& rxFrame ) @@ -114,30 +112,11 @@ PagePropertyPanel::PagePropertyPanel( , mImgWide_L (SW_RES(IMG_PAGE_WIDE_L)) , mImgMirrored_L (SW_RES(IMG_PAGE_MIRRORED_L)) , mImgMarginCustom_L (SW_RES(IMG_PAGE_MARGIN_CUSTOM_L)) - , mImgA3 (SW_RES(IMG_PAGE_A3)) - , mImgA4 (SW_RES(IMG_PAGE_A4)) - , mImgA5 (SW_RES(IMG_PAGE_A5)) - , mImgB4 (SW_RES(IMG_PAGE_B4)) - , mImgB5 (SW_RES(IMG_PAGE_B5)) - , mImgC5 (SW_RES(IMG_PAGE_C5)) - , mImgLetter (SW_RES(IMG_PAGE_LETTER)) - , mImgLegal (SW_RES(IMG_PAGE_LEGAL)) - , mImgSizeNone (SW_RES(IMG_PAGE_SIZE_NONE)) - , mImgA3_L (SW_RES(IMG_PAGE_A3_L)) - , mImgA4_L (SW_RES(IMG_PAGE_A4_L)) - , mImgA5_L (SW_RES(IMG_PAGE_A5_L)) - , mImgB4_L (SW_RES(IMG_PAGE_B4_L)) - , mImgB5_L (SW_RES(IMG_PAGE_B5_L)) - , mImgC5_L (SW_RES(IMG_PAGE_C5_L)) - , mImgLetter_L (SW_RES(IMG_PAGE_LETTER_L)) - , mImgLegal_L (SW_RES(IMG_PAGE_LEGAL_L)) - , mImgSizeNone_L (SW_RES(IMG_PAGE_SIZE_NONE_L)) , mpPageItem( new SvxPageItem(SID_ATTR_PAGE) ) , mpPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE ) ) , mpPageULMarginItem( new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE ) ) , mpPageSizeItem( new SvxSizeItem(SID_ATTR_PAGE_SIZE) ) - , mePaper( PAPER_USER ) , meFUnit() , meUnit() @@ -145,15 +124,11 @@ PagePropertyPanel::PagePropertyPanel( , m_aSwPagePgULControl(SID_ATTR_PAGE_ULSPACE, *pBindings, *this) , m_aSwPagePgLRControl(SID_ATTR_PAGE_LRSPACE, *pBindings, *this) , m_aSwPagePgSizeControl(SID_ATTR_PAGE_SIZE, *pBindings, *this) - , m_aSwPagePgControl(SID_ATTR_PAGE, *pBindings, *this) , m_aSwPagePgMetricControl(SID_ATTR_METRIC, *pBindings, *this) , maMarginPopup( this, [this] (svx::sidebar::PopupContainer *parent) { return this->CreatePageMarginControl(parent); }, OUString("Page margins") ) - , maSizePopup( this, - [this] (svx::sidebar::PopupContainer *parent) { return this->CreatePageSizeControl(parent); }, - OUString("Page size") ) , mxUndoManager( getUndoManager( rxFrame ) ) @@ -161,7 +136,6 @@ PagePropertyPanel::PagePropertyPanel( { // visible controls get(mpToolBoxMargin, "selectmargin"); - get(mpToolBoxSize, "selectsize"); Initialize(); mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify = true; @@ -185,15 +159,12 @@ void PagePropertyPanel::dispose() mpPageSizeItem.reset(); mpToolBoxMargin.clear(); - mpToolBoxSize.clear(); m_aSwPagePgULControl.dispose(); m_aSwPagePgLRControl.dispose(); m_aSwPagePgSizeControl.dispose(); - m_aSwPagePgControl.dispose(); m_aSwPagePgMetricControl.dispose(); - maSizePopup.dispose(); maMarginPopup.dispose(); PanelLayout::dispose(); @@ -209,32 +180,6 @@ void PagePropertyPanel::Initialize() mpToolBoxMargin->SetItemImage(nIdMargin, mImgNormal); mpToolBoxMargin->SetItemBits( nIdMargin, mpToolBoxMargin->GetItemBits( nIdMargin ) | ToolBoxItemBits::DROPDOWNONLY ); - // popup for page size - const sal_uInt16 nIdSize = mpToolBoxSize->GetItemId(UNO_SIZE); - aLink = LINK( this, PagePropertyPanel, ClickSizeHdl ); - mpToolBoxSize->SetDropdownClickHdl( aLink ); - mpToolBoxSize->SetSelectHdl( aLink ); - mpToolBoxSize->SetItemImage(nIdSize, mImgLetter); - mpToolBoxSize->SetItemBits( nIdSize, mpToolBoxSize->GetItemBits( nIdSize ) | ToolBoxItemBits::DROPDOWNONLY ); - maImgSize = new Image[8]; - maImgSize[0] = mImgA3; - maImgSize[1] = mImgA4; - maImgSize[2] = mImgA5; - maImgSize[3] = mImgB4; - maImgSize[4] = mImgB5; - maImgSize[5] = mImgC5; - maImgSize[6] = mImgLetter; - maImgSize[7] = mImgLegal; - maImgSize_L = new Image[8]; - maImgSize_L[0] = mImgA3_L; - maImgSize_L[1] = mImgA4_L; - maImgSize_L[2] = mImgA5_L; - maImgSize_L[3] = mImgB4_L; - maImgSize_L[4] = mImgB5_L; - maImgSize_L[5] = mImgC5_L; - maImgSize_L[6] = mImgLetter_L; - maImgSize_L[7] = mImgLegal_L; - meFUnit = GetModuleFieldUnit(); meUnit = m_aSwPagePgSizeControl.GetCoreMetric(); @@ -297,40 +242,6 @@ void PagePropertyPanel::ClosePageMarginPopup() maMarginPopup.Hide(); } -VclPtr< svx::sidebar::PopupControl> PagePropertyPanel::CreatePageSizeControl( svx::sidebar::PopupContainer* pParent ) -{ - return VclPtr<PageSizeControl>::Create( - - pParent, - *this, - mePaper, - mpPageItem->IsLandscape(), - meFUnit ); -} - -void PagePropertyPanel::ExecuteSizeChange( const Paper ePaper ) -{ - Size aPageSize = SvxPaperInfo::GetPaperSize( ePaper, (MapUnit)(meUnit) ); - if ( mpPageItem->IsLandscape() ) - { - Swap( aPageSize ); - } - mpPageSizeItem->SetSize( aPageSize ); - - mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, - SfxCallMode::RECORD, { mpPageSizeItem.get() }); -} - -IMPL_LINK_TYPED( PagePropertyPanel, ClickSizeHdl, ToolBox*, pToolBox, void ) -{ - maSizePopup.Show( *pToolBox ); -} - -void PagePropertyPanel::ClosePageSizePopup() -{ - maSizePopup.Hide(); -} - void PagePropertyPanel::NotifyItemUpdate( const sal_uInt16 nSId, const SfxItemState eState, @@ -371,7 +282,6 @@ void PagePropertyPanel::NotifyItemUpdate( pState && dynamic_cast< const SvxSizeItem *>( pState ) != nullptr ) { mpPageSizeItem.reset( static_cast<SvxSizeItem*>(pState->Clone()) ); - ChangeSizeImage(); } break; case SID_ATTR_METRIC: @@ -454,69 +364,6 @@ void PagePropertyPanel::ChangeMarginImage() mpToolBoxMargin->SetItemImage( nIdMargin, mpPageItem->IsLandscape() ? mImgMarginCustom_L : mImgMarginCustom ); } -void PagePropertyPanel::ChangeSizeImage() -{ - if ( mpPageSizeItem.get() == nullptr || - mpPageItem.get() == nullptr ) - { - return; - } - - Size aTmpPaperSize = mpPageSizeItem->GetSize(); - if ( mpPageItem->IsLandscape() ) - { - Swap( aTmpPaperSize ); // Swap(..) defined in editeng/paperinf.hxx - } - - mePaper = SvxPaperInfo::GetSvxPaper( aTmpPaperSize, static_cast<MapUnit>(meUnit), true ); - - sal_uInt16 nImageIdx = 0; - switch ( mePaper ) - { - case PAPER_A3: - nImageIdx = 1; - break; - case PAPER_A4: - nImageIdx = 2; - break; - case PAPER_A5: - nImageIdx = 3; - break; - case PAPER_B4_ISO: - nImageIdx = 4; - break; - case PAPER_B5_ISO: - nImageIdx = 5; - break; - case PAPER_ENV_C5: - nImageIdx = 6; - break; - case PAPER_LETTER: - nImageIdx = 7; - break; - case PAPER_LEGAL: - nImageIdx = 8; - break; - default: - nImageIdx = 0; - mePaper = PAPER_USER; - break; - } - - const sal_uInt16 nIdSize = mpToolBoxSize->GetItemId(UNO_SIZE); - - if ( nImageIdx == 0 ) - { - mpToolBoxSize->SetItemImage( nIdSize, - ( mpPageItem->IsLandscape() ? mImgSizeNone_L : mImgSizeNone ) ); - } - else - { - mpToolBoxSize->SetItemImage( nIdSize, - ( mpPageItem->IsLandscape() ? maImgSize_L[nImageIdx-1] : maImgSize[nImageIdx-1] ) ); - } -} - void PagePropertyPanel::StartUndo() { if ( mxUndoManager.is() ) diff --git a/sw/source/uibase/sidebar/PagePropertyPanel.hrc b/sw/source/uibase/sidebar/PagePropertyPanel.hrc index c8af7bccf769..7c87d7ef0e8b 100644 --- a/sw/source/uibase/sidebar/PagePropertyPanel.hrc +++ b/sw/source/uibase/sidebar/PagePropertyPanel.hrc @@ -31,35 +31,6 @@ #define IMG_PAGE_WIDE_L (RC_SIDEBAR_BEGIN + 9) #define IMG_PAGE_MIRRORED_L (RC_SIDEBAR_BEGIN + 10) #define IMG_PAGE_MARGIN_CUSTOM_L (RC_SIDEBAR_BEGIN+ 11) -#define IMG_PAGE_A3 (RC_SIDEBAR_BEGIN + 12) -#define IMG_PAGE_A4 (RC_SIDEBAR_BEGIN + 13) -#define IMG_PAGE_A5 (RC_SIDEBAR_BEGIN + 14) -#define IMG_PAGE_B4 (RC_SIDEBAR_BEGIN + 15) -#define IMG_PAGE_B5 (RC_SIDEBAR_BEGIN + 16) -#define IMG_PAGE_C5 (RC_SIDEBAR_BEGIN + 17) -#define IMG_PAGE_LETTER (RC_SIDEBAR_BEGIN + 18) -#define IMG_PAGE_LEGAL (RC_SIDEBAR_BEGIN + 19) -#define IMG_PAGE_SIZE_NONE (RC_SIDEBAR_BEGIN + 20) -#define IMG_PAGE_A3_L (RC_SIDEBAR_BEGIN + 21) -#define IMG_PAGE_A4_L (RC_SIDEBAR_BEGIN + 22) -#define IMG_PAGE_A5_L (RC_SIDEBAR_BEGIN + 23) -#define IMG_PAGE_B4_L (RC_SIDEBAR_BEGIN + 24) -#define IMG_PAGE_B5_L (RC_SIDEBAR_BEGIN + 25) -#define IMG_PAGE_C5_L (RC_SIDEBAR_BEGIN + 26) -#define IMG_PAGE_LETTER_L (RC_SIDEBAR_BEGIN + 27) -#define IMG_PAGE_LEGAL_L (RC_SIDEBAR_BEGIN + 28) -#define IMG_PAGE_SIZE_NONE_L (RC_SIDEBAR_BEGIN + 29) -#define IMG_PAGE_COLUMN_1 (RC_SIDEBAR_BEGIN + 30) -#define IMG_PAGE_COLUMN_2 (RC_SIDEBAR_BEGIN + 31) -#define IMG_PAGE_COLUMN_3 (RC_SIDEBAR_BEGIN + 32) -#define IMG_PAGE_COLUMN_LEFT (RC_SIDEBAR_BEGIN + 33) -#define IMG_PAGE_COLUMN_RIGHT (RC_SIDEBAR_BEGIN + 34) -#define IMG_PAGE_COLUMN_1_L (RC_SIDEBAR_BEGIN + 36) -#define IMG_PAGE_COLUMN_2_L (RC_SIDEBAR_BEGIN + 37) -#define IMG_PAGE_COLUMN_3_L (RC_SIDEBAR_BEGIN + 38) -#define IMG_PAGE_COLUMN_LEFT_L (RC_SIDEBAR_BEGIN + 39) -#define IMG_PAGE_COLUMN_RIGHT_L (RC_SIDEBAR_BEGIN + 40) -#define IMG_PAGE_COLUMN_NONE_L (RC_SIDEBAR_BEGIN + 41) // local @@ -90,25 +61,7 @@ #define FT_OUTER 47 #define VS_COLUMN 49 #define MBOX_WIDTH 50 -#define IMG_ONE 51 -#define IMG_TWO 52 -#define IMG_THREE 53 -#define IMG_LEFT 54 -#define IMG_RIGHT 55 -#define STR_ONE 56 -#define STR_TWO 57 -#define STR_THREE 58 -#define STR_LEFT 59 -#define STR_RIGHT 60 -#define CB_COLUMN_MORE 61 -#define CB_SIZE_MORE 61 - -#define IMG_ONE_L 90 -#define IMG_TWO_L 91 -#define IMG_THREE_L 92 -#define IMG_LEFT_L 93 -#define IMG_RIGHT_L 94 #define IMG_NARROW_L 109 #define IMG_NORMAL_L 110 #define IMG_WIDE_L 111 diff --git a/sw/source/uibase/sidebar/PagePropertyPanel.hxx b/sw/source/uibase/sidebar/PagePropertyPanel.hxx index 72a7d4b52065..539ce91e298a 100644 --- a/sw/source/uibase/sidebar/PagePropertyPanel.hxx +++ b/sw/source/uibase/sidebar/PagePropertyPanel.hxx @@ -81,10 +81,6 @@ namespace sw { namespace sidebar { void ExecutePageLayoutChange( const bool bMirrored ); void ClosePageMarginPopup(); - VclPtr< svx::sidebar::PopupControl> CreatePageSizeControl( svx::sidebar::PopupContainer* pParent ); - void ExecuteSizeChange( const Paper ePaper ); - void ClosePageSizePopup(); - void StartUndo(); void EndUndo(); @@ -100,7 +96,6 @@ namespace sw { namespace sidebar { // toolboxes - on click open corresponding popup VclPtr<ToolBox> mpToolBoxMargin; - VclPtr<ToolBox> mpToolBoxSize; Image* maImgSize; Image* maImgSize_L; @@ -114,24 +109,6 @@ namespace sw { namespace sidebar { Image mImgWide_L; Image mImgMirrored_L; Image mImgMarginCustom_L; - Image mImgA3; - Image mImgA4; - Image mImgA5; - Image mImgB4; - Image mImgB5; - Image mImgC5; - Image mImgLetter; - Image mImgLegal; - Image mImgSizeNone; - Image mImgA3_L; - Image mImgA4_L; - Image mImgA5_L; - Image mImgB4_L; - Image mImgB5_L; - Image mImgC5_L; - Image mImgLetter_L; - Image mImgLegal_L; - Image mImgSizeNone_L; // item keeping the following page style attributes: // - page orientation @@ -147,8 +124,6 @@ namespace sw { namespace sidebar { // item keeping the page style's page size std::unique_ptr<SvxSizeItem> mpPageSizeItem; - // Paper corresponding to the page style's page size - Paper mePaper; FieldUnit meFUnit; MapUnit meUnit; @@ -157,12 +132,10 @@ namespace sw { namespace sidebar { ::sfx2::sidebar::ControllerItem m_aSwPagePgULControl; ::sfx2::sidebar::ControllerItem m_aSwPagePgLRControl; ::sfx2::sidebar::ControllerItem m_aSwPagePgSizeControl; - ::sfx2::sidebar::ControllerItem m_aSwPagePgControl; ::sfx2::sidebar::ControllerItem m_aSwPagePgMetricControl; // popups svx::sidebar::Popup maMarginPopup; - svx::sidebar::Popup maSizePopup; const css::uno::Reference< css::document::XUndoManager > mxUndoManager; @@ -170,7 +143,6 @@ namespace sw { namespace sidebar { // handler for popup toolboxes to show the popups DECL_LINK_TYPED(ClickMarginHdl, ToolBox*, void); - DECL_LINK_TYPED(ClickSizeHdl, ToolBox*, void); void Initialize(); @@ -178,7 +150,6 @@ namespace sw { namespace sidebar { // helper to adjust popup toolbox' images void ChangeMarginImage(); - void ChangeSizeImage(); }; diff --git a/sw/source/uibase/sidebar/PageSizeControl.cxx b/sw/source/uibase/sidebar/PageSizeControl.cxx index 29151a1a2099..eb0ee63ed3a9 100644 --- a/sw/source/uibase/sidebar/PageSizeControl.cxx +++ b/sw/source/uibase/sidebar/PageSizeControl.cxx @@ -23,6 +23,7 @@ #include <cmdid.h> #include <swtypes.hxx> +#include <svx/svxids.hrc> #include <svx/sidebar/ValueSetWithTextControl.hxx> @@ -32,25 +33,52 @@ #include <sfx2/dispatch.hxx> #include <vcl/settings.hxx> +#include <svl/itempool.hxx> + +namespace +{ + FieldUnit lcl_GetFieldUnit() + { + FieldUnit eUnit = FUNIT_INCH; + const SfxPoolItem* pItem = nullptr; + SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_METRIC, pItem ); + if ( pItem && eState >= SfxItemState::DEFAULT ) + { + eUnit = (FieldUnit)static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + } + else + { + return SfxModule::GetCurrentFieldUnit(); + } + + return eUnit; + } + + MapUnit lcl_GetUnit() + { + SfxItemPool &rPool = SfxGetpApp()->GetPool(); + sal_uInt16 nWhich = rPool.GetWhich( SID_ATTR_PAGE_SIZE ); + return rPool.GetMetric( nWhich ); + } +} namespace sw { namespace sidebar { -PageSizeControl::PageSizeControl( - vcl::Window* pParent, - PagePropertyPanel& rPanel, - const Paper ePaper, - const bool bLandscape, - const FieldUnit eFUnit ) - : svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_SIZE) ) - , mpSizeValueSet( VclPtr<svx::sidebar::ValueSetWithTextControl>::Create( svx::sidebar::ValueSetWithTextControl::ControlType::TextText, this, SW_RES(VS_SIZE) ) ) - , maMoreButton( VclPtr<PushButton>::Create( this, SW_RES(CB_SIZE_MORE) ) ) - , maWidthHeightField( VclPtr<MetricField>::Create( this, SW_RES(FLD_WIDTH_HEIGHT) ) ) - , mePaper( ePaper ) +PageSizeControl::PageSizeControl( sal_uInt16 nId ) + : SfxPopupWindow( nId, "PageSizeControl", "modules/swriter/ui/pagesizecontrol.ui" ) , maPaperList() - , mrPagePropPanel(rPanel) { + get(maMoreButton, "moreoptions"); + get(maContainer, "container"); + mpSizeValueSet = VclPtr<svx::sidebar::ValueSetWithTextControl>::Create( maContainer.get(), WB_BORDER ); + maWidthHeightField = VclPtr<MetricField>::Create( maContainer.get(), 0 ); maWidthHeightField->Hide(); - SetFieldUnit( *maWidthHeightField.get(), eFUnit ); + maWidthHeightField->SetUnit(FUNIT_CM); + maWidthHeightField->SetMax(9999); + maWidthHeightField->SetDecimalDigits(2); + maWidthHeightField->SetSpinSize(10); + maWidthHeightField->SetLast(9999); + SetFieldUnit( *maWidthHeightField.get(), lcl_GetFieldUnit() ); maPaperList.push_back( PAPER_A3 ); maPaperList.push_back( PAPER_A4 ); @@ -86,6 +114,17 @@ PageSizeControl::PageSizeControl( } } + bool bLandscape = false; + const SfxPoolItem* pItem; + const SvxSizeItem* pSize = nullptr; + if ( SfxViewFrame::Current() ) + { + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); + bLandscape = static_cast<const SvxPageItem*>(pItem)->IsLandscape(); + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pItem ); + pSize = static_cast<const SvxSizeItem*>(pItem); + } + const LocaleDataWrapper& localeDataWrapper = maWidthHeightField->GetLocaleDataWrapper(); OUString aWidthStr; OUString aHeightStr; @@ -99,7 +138,8 @@ PageSizeControl::PageSizeControl( { Swap( aPaperSize ); } - maWidthHeightField->SetValue( maWidthHeightField->Normalize( aPaperSize.Width() ), FUNIT_TWIP ); + + maWidthHeightField->SetValue( maWidthHeightField->Normalize( aPaperSize.Width() ), FUNIT_TWIP ); aWidthStr = localeDataWrapper.getNum( maWidthHeightField->GetValue(), maWidthHeightField->GetDecimalDigits(), @@ -119,16 +159,16 @@ PageSizeControl::PageSizeControl( SvxPaperInfo::GetName( maPaperList[ nPaperIdx ] ), aItemText2 ); - if ( maPaperList[ nPaperIdx ] == mePaper ) + if ( pSize && aPaperSize == pSize->GetSize() ) { nSelectedItem = nPaperIdx + 1; } } } - mpSizeValueSet->SetNoSelection(); - mpSizeValueSet->SetSelectHdl( LINK(this, PageSizeControl,ImplSizeHdl ) ); + mpSizeValueSet->SetSelectHdl( LINK(this, PageSizeControl, ImplSizeHdl ) ); mpSizeValueSet->Show(); + mpSizeValueSet->Resize(); mpSizeValueSet->SelectItem( nSelectedItem ); mpSizeValueSet->SetFormat(); @@ -137,8 +177,6 @@ PageSizeControl::PageSizeControl( maMoreButton->SetClickHdl( LINK( this, PageSizeControl, MoreButtonClickHdl_Impl ) ); maMoreButton->GrabFocus(); - - FreeResource(); } PageSizeControl::~PageSizeControl() @@ -151,9 +189,34 @@ void PageSizeControl::dispose() mpSizeValueSet.disposeAndClear(); maMoreButton.disposeAndClear(); maWidthHeightField.disposeAndClear(); - svx::sidebar::PopupControl::dispose(); + maContainer.disposeAndClear(); + SfxPopupWindow::dispose(); +} + +void PageSizeControl::ExecuteSizeChange( const Paper ePaper ) +{ + bool bLandscape = false; + const SfxPoolItem *pItem; + MapUnit eUnit = lcl_GetUnit(); + if ( SfxViewFrame::Current() ) + { + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); + bLandscape = static_cast<const SvxPageItem*>(pItem)->IsLandscape(); + + std::unique_ptr<SvxSizeItem> pPageSizeItem( new SvxSizeItem(SID_ATTR_PAGE_SIZE) ); + Size aPageSize = SvxPaperInfo::GetPaperSize( ePaper, (MapUnit)(eUnit) ); + if ( bLandscape ) + { + Swap( aPageSize ); + } + pPageSizeItem->SetSize( aPageSize ); + + SfxViewFrame::Current()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, + SfxCallMode::RECORD, { pPageSizeItem.get() }); + } } + IMPL_LINK_TYPED(PageSizeControl, ImplSizeHdl, ValueSet*, pControl, void) { mpSizeValueSet->SetNoSelection(); @@ -161,21 +224,17 @@ IMPL_LINK_TYPED(PageSizeControl, ImplSizeHdl, ValueSet*, pControl, void) { const sal_uInt16 nSelectedPaper = mpSizeValueSet->GetSelectItemId(); const Paper ePaper = maPaperList[nSelectedPaper - 1]; - if ( ePaper != mePaper ) - { - mePaper = ePaper; - mrPagePropPanel.ExecuteSizeChange( mePaper ); - } + ExecuteSizeChange( ePaper ); } - mrPagePropPanel.ClosePageSizePopup(); + EndPopupMode(); } IMPL_LINK_NOARG_TYPED(PageSizeControl, MoreButtonClickHdl_Impl, Button*, void) { - mrPagePropPanel.GetBindings()->GetDispatcher()->Execute( FN_FORMAT_PAGE_SETTING_DLG, SfxCallMode::ASYNCHRON ); - - mrPagePropPanel.ClosePageSizePopup(); + if ( SfxViewFrame::Current() ) + SfxViewFrame::Current()->GetDispatcher()->Execute( FN_FORMAT_PAGE_SETTING_DLG, SfxCallMode::ASYNCHRON ); + EndPopupMode(); } } } // end of namespace sw::sidebar diff --git a/sw/source/uibase/sidebar/PageSizeControl.hxx b/sw/source/uibase/sidebar/PageSizeControl.hxx index 54cc4697c9bd..60d9aff2f404 100644 --- a/sw/source/uibase/sidebar/PageSizeControl.hxx +++ b/sw/source/uibase/sidebar/PageSizeControl.hxx @@ -26,8 +26,12 @@ #include <vcl/button.hxx> #include <vcl/field.hxx> #include <svtools/unitconv.hxx> +#include <svx/tbxctl.hxx> +#include <vcl/layout.hxx> +#include <vcl/lstbox.hxx> #include <vector> +#include <svtools/valueset.hxx> namespace svx { namespace sidebar { class ValueSetWithTextControl; @@ -38,29 +42,23 @@ namespace sw { namespace sidebar { class PagePropertyPanel; -class PageSizeControl - : public svx::sidebar::PopupControl +class PageSizeControl : public SfxPopupWindow { public: - PageSizeControl( - vcl::Window* pParent, - PagePropertyPanel& rPanel, - const Paper ePaper, - const bool bLandscape, - const FieldUnit eFUnit ); + PageSizeControl(sal_uInt16 nId); virtual ~PageSizeControl(); virtual void dispose() override; private: - VclPtr< svx::sidebar::ValueSetWithTextControl> mpSizeValueSet; + VclPtr<VclVBox> maContainer; + VclPtr<svx::sidebar::ValueSetWithTextControl> mpSizeValueSet; VclPtr<PushButton> maMoreButton; // hidden metric field VclPtr<MetricField> maWidthHeightField; - Paper mePaper; std::vector< Paper > maPaperList; - PagePropertyPanel& mrPagePropPanel; + static void ExecuteSizeChange( const Paper ePaper ); DECL_LINK_TYPED(ImplSizeHdl, ::ValueSet*, void); DECL_LINK_TYPED(MoreButtonClickHdl_Impl, Button*, void); diff --git a/sw/source/uibase/sidebar/PageSizePopup.cxx b/sw/source/uibase/sidebar/PageSizePopup.cxx new file mode 100644 index 000000000000..c3b20acd0496 --- /dev/null +++ b/sw/source/uibase/sidebar/PageSizePopup.cxx @@ -0,0 +1,46 @@ +/* -*- 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 <PageSizePopup.hxx> +#include "PageSizeControl.hxx" +#include <editeng/sizeitem.hxx> +#include <vcl/toolbox.hxx> + +SFX_IMPL_TOOLBOX_CONTROL(PageSizePopup, SvxSizeItem); + +PageSizePopup::PageSizePopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx) + : SfxToolBoxControl(nSlotId, nId, rTbx) +{ + rTbx.SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | rTbx.GetItemBits(nId)); +} + +PageSizePopup::~PageSizePopup() +{ +} + +VclPtr<SfxPopupWindow> PageSizePopup::CreatePopupWindow() +{ + VclPtr<sw::sidebar::PageSizeControl> pControl = VclPtr<sw::sidebar::PageSizeControl>::Create(GetSlotId()); + pControl->StartPopupMode(&GetToolBox(), FloatWinPopupFlags::GrabFocus|FloatWinPopupFlags::NoAppFocusClose); + SetPopupWindow(pControl); + + return pControl; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/sidebar/PropertyPanel.hrc b/sw/source/uibase/sidebar/PropertyPanel.hrc index c4ca5a65e972..5143a3dc7d10 100644 --- a/sw/source/uibase/sidebar/PropertyPanel.hrc +++ b/sw/source/uibase/sidebar/PropertyPanel.hrc @@ -22,8 +22,6 @@ #include "rcid.hrc" #define RID_POPUP_SWPAGE_MARGIN (RC_PROPERTYPANEL_BEGIN + 3) -#define RID_POPUP_SWPAGE_SIZE (RC_PROPERTYPANEL_BEGIN + 6) - #endif diff --git a/sw/uiconfig/swriter/ui/notebookbar.ui b/sw/uiconfig/swriter/ui/notebookbar.ui index bb2bc60261c2..5209a50ad0c5 100644 --- a/sw/uiconfig/swriter/ui/notebookbar.ui +++ b/sw/uiconfig/swriter/ui/notebookbar.ui @@ -2833,6 +2833,33 @@ </packing> </child> <child> + <object class="sfxlo-BigToolBox" id="sizebox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">center</property> + <property name="show_arrow">False</property> + <child> + <object class="GtkMenuToolButton" id="Size"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="is_important">True</property> + <property name="action_name">.uno:AttributePageSize</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + <child> <object class="sfxlo-BigToolBox" id="orientationbox"> <property name="visible">True</property> <property name="can_focus">False</property> diff --git a/sw/uiconfig/swriter/ui/pagesizecontrol.ui b/sw/uiconfig/swriter/ui/pagesizecontrol.ui new file mode 100644 index 000000000000..f2d0b4c82ea5 --- /dev/null +++ b/sw/uiconfig/swriter/ui/pagesizecontrol.ui @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.18.3 --> +<interface> + <requires lib="gtk+" version="3.10"/> + <object class="GtkImage" id="image_portrait7"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="pixbuf">cmd/lc_orientation.png</property> + </object> + <object class="GtkWindow" id="PageSizeControl"> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="border_width">4</property> + <property name="resizable">False</property> + <property name="destroy_with_parent">True</property> + <property name="type_hint">popup-menu</property> + <property name="skip_pager_hint">True</property> + <property name="deletable">False</property> + <child> + <object class="GtkBox" id="box"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_right">6</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkBox" id="container"> + <property name="width_request">250</property> + <property name="height_request">300</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <property name="homogeneous">True</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="moreoptions"> + <property name="label" translatable="yes">_More Options</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="tooltip_text" translatable="yes">More Options</property> + <property name="image">image_portrait7</property> + <property name="relief">none</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">8</property> + </packing> + </child> + </object> + </child> + </object> +</interface> |