summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorSzymon Kłos <eszkadev@gmail.com>2016-08-26 14:00:03 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-09-05 09:23:46 +0000
commitcbe43883e465336da55c96665f9bb7672ffa3bb0 (patch)
tree1c5776abf4a1661f68c4d83ad9e061457db83ecb /sw/source
parent74ab2a686144545255a2f07dde3f14f66f37753e (diff)
Page orientation popup converted to use outside sidebar
* popup converted to .ui file * added .uno:Orientation * label & icon for .uno:Orientation * control inserted to the notebookbar.ui (Page layout tab) Change-Id: I93f35a65c4461635d0cfd1afd4546a9d2a8c4d04 Reviewed-on: https://gerrit.libreoffice.org/28405 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/ui/sidebar/PagePropertyPanel.src42
-rw-r--r--sw/source/uibase/app/swmodule.cxx2
-rw-r--r--sw/source/uibase/sidebar/PageOrientationControl.cxx197
-rw-r--r--sw/source/uibase/sidebar/PageOrientationControl.hxx35
-rw-r--r--sw/source/uibase/sidebar/PageOrientationPopup.cxx46
-rw-r--r--sw/source/uibase/sidebar/PagePropertyPanel.cxx116
-rw-r--r--sw/source/uibase/sidebar/PagePropertyPanel.hrc7
-rw-r--r--sw/source/uibase/sidebar/PagePropertyPanel.hxx9
-rw-r--r--sw/source/uibase/sidebar/PropertyPanel.hrc1
-rw-r--r--sw/source/uibase/uiview/viewstat.cxx1
10 files changed, 221 insertions, 235 deletions
diff --git a/sw/source/ui/sidebar/PagePropertyPanel.src b/sw/source/ui/sidebar/PagePropertyPanel.src
index f38b73b72044..785861dd758d 100644
--- a/sw/source/ui/sidebar/PagePropertyPanel.src
+++ b/sw/source/ui/sidebar/PagePropertyPanel.src
@@ -22,14 +22,6 @@
#include "PagePropertyPanel.hrc"
#include "helpid.h"
-Image IMG_PAGE_PORTRAIT
-{
- ImageBitmap = Bitmap{File = "sidebar/pageproppanel/portraitcopy_24x24.png";};
-};
-Image IMG_PAGE_LANDSCAPE
-{
- ImageBitmap = Bitmap{File = "sidebar/pageproppanel/Landscapecopy_24x24.png";};
-};
Image IMG_PAGE_NARROW
{
ImageBitmap = Bitmap{File = "sidebar/pageproppanel/format_L_narrow_24x24.png";};
@@ -191,40 +183,6 @@ Image IMG_PAGE_COLUMN_NONE_L
ImageBitmap = Bitmap{File = "sidebar/pageproppanel/columncopy_24x24.png";};
};
-// popup for page orientation attribute
-Control RID_POPUP_SWPAGE_ORIENTATION
-{
- OutputSize = TRUE;
- DialogControl = TRUE;
- Border = FALSE;
- Size = MAP_APPFONT( POPUPPANEL_MARGIN_SMALL * 2 + POPUP_BORDER_WIDTH + VS_WIDTH, ITEM_HEIGHT*2 + POPUPPANEL_MARGIN_SMALL*2 );
-
- Control VS_ORIENTATION
- {
- Pos = MAP_APPFONT( POPUPPANEL_MARGIN_SMALL + OFFSET_X, POPUPPANEL_MARGIN_SMALL + OFFSET_Y);
- Size = MAP_APPFONT ( VS_WIDTH , ITEM_HEIGHT*2);
- HelpID = HID_SWPAGE_VS_ORIENTATION;
- TabStop = TRUE ;
- Text = "Orientation";
- };
- Image IMG_PORTRAIT
- {
- ImageBitmap = Bitmap{File = "sidebar/pageproppanel/portraitcopy_24x24.png";};
- };
- Image IMG_LANDSCAPE
- {
- ImageBitmap = Bitmap{File = "sidebar/pageproppanel/Landscapecopy_24x24.png";};
- };
- String STR_PORTRAIT
- {
- Text [ en-US ] = "Portrait";
- };
- String STR_LANDSCAPE
- {
- Text [ en-US ] = "Landscape";
- };
-};
-
// popup for page style's margin attributes
Control RID_POPUP_SWPAGE_MARGIN
{
diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx
index 2b0b33cc5783..e41b621ddd79 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 <PageOrientationPopup.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/moduleoptions.hxx>
@@ -291,6 +292,7 @@ void SwDLL::RegisterControls()
svx::TextUnderlinePopup::RegisterControl(SID_ATTR_CHAR_UNDERLINE, pMod);
svx::ParaULSpacingControl::RegisterControl(SID_ATTR_PARA_ULSPACE, pMod);
svx::ParaLRSpacingControl::RegisterControl(SID_ATTR_PARA_LRSPACE, pMod);
+ PageOrientationPopup::RegisterControl(SID_ATTR_PAGE_ORIENTATION, pMod);
SvxColorToolBoxControl::RegisterControl( SID_EXTRUSION_3D_COLOR, pMod );
diff --git a/sw/source/uibase/sidebar/PageOrientationControl.cxx b/sw/source/uibase/sidebar/PageOrientationControl.cxx
index 6fecc469f525..20e3bb83b7f8 100644
--- a/sw/source/uibase/sidebar/PageOrientationControl.cxx
+++ b/sw/source/uibase/sidebar/PageOrientationControl.cxx
@@ -18,47 +18,50 @@
*/
#include "PageOrientationControl.hxx"
-#include "PagePropertyPanel.hxx"
-#include "PagePropertyPanel.hrc"
+#include "PageMarginControl.hxx"
#include <swtypes.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/svxids.hrc>
+#include <cmdid.h>
-#include <svx/sidebar/ValueSetWithTextControl.hxx>
-#include <vcl/settings.hxx>
+namespace {
+ const css::uno::Reference< css::document::XUndoManager > getUndoManager( const css::uno::Reference< css::frame::XFrame >& rxFrame )
+ {
+ const css::uno::Reference< css::frame::XController >& xController = rxFrame->getController();
+ if ( xController.is() )
+ {
+ const css::uno::Reference< css::frame::XModel >& xModel = xController->getModel();
+ if ( xModel.is() )
+ {
+ const css::uno::Reference< css::document::XUndoManagerSupplier > xSuppUndo( xModel, css::uno::UNO_QUERY_THROW );
+ if ( xSuppUndo.is() )
+ {
+ const css::uno::Reference< css::document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), css::uno::UNO_QUERY_THROW );
+ return xUndoManager;
+ }
+ }
+ }
+
+ return css::uno::Reference< css::document::XUndoManager > ();
+ }
+}
namespace sw { namespace sidebar {
-PageOrientationControl::PageOrientationControl(
- vcl::Window* pParent,
- PagePropertyPanel& rPanel,
- const bool bLandscape )
- : svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_ORIENTATION) )
- , mpOrientationValueSet( VclPtr<svx::sidebar::ValueSetWithTextControl>::Create( svx::sidebar::ValueSetWithTextControl::ControlType::ImageText, this, SW_RES(VS_ORIENTATION) ) )
- , mbLandscape( bLandscape )
- , mrPagePropPanel(rPanel)
+PageOrientationControl::PageOrientationControl( sal_uInt16 nId )
+ : SfxPopupWindow( nId, "PageOrientationControl", "modules/swriter/ui/pageorientationcontrol.ui" )
+ , mpPageItem( new SvxPageItem(SID_ATTR_PAGE) )
+ , mpPageSizeItem( new SvxSizeItem(SID_ATTR_PAGE_SIZE) )
+ , mpPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE ) )
+ , mpPageULMarginItem( new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE ) )
{
- mpOrientationValueSet->SetStyle( mpOrientationValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
- mpOrientationValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor());
+ get(m_pPortrait, "portrait");
+ get(m_pLandscape, "landscape");
- // initialize <ValueSetWithText> control
- {
- mpOrientationValueSet->AddItem(Image(SW_RES(IMG_PORTRAIT)), nullptr,
- SW_RES(STR_PORTRAIT), nullptr);
- mpOrientationValueSet->AddItem(Image(SW_RES(IMG_LANDSCAPE)), nullptr,
- SW_RES(STR_LANDSCAPE), nullptr );
- }
-
- mpOrientationValueSet->SetSelectHdl(LINK(this, PageOrientationControl,ImplOrientationHdl ));
- mpOrientationValueSet->SetNoSelection();
- mpOrientationValueSet->StartSelection();
- mpOrientationValueSet->Show();
- mpOrientationValueSet->SelectItem( mbLandscape ? 2 : 1 );
- mpOrientationValueSet->GrabFocus();
- mpOrientationValueSet->SetFormat();
- mpOrientationValueSet->Invalidate();
- mpOrientationValueSet->StartSelection();
-
- FreeResource();
+ m_pPortrait->SetClickHdl( LINK( this, PageOrientationControl,ImplOrientationHdl ) );
+ m_pLandscape->SetClickHdl( LINK( this, PageOrientationControl,ImplOrientationHdl ) );
}
PageOrientationControl::~PageOrientationControl()
@@ -68,26 +71,130 @@ PageOrientationControl::~PageOrientationControl()
void PageOrientationControl::dispose()
{
- mpOrientationValueSet.disposeAndClear();
- svx::sidebar::PopupControl::dispose();
+ m_pPortrait.disposeAndClear();
+ m_pLandscape.disposeAndClear();
+
+ mpPageItem.reset();
+ mpPageLRMarginItem.reset();
+ mpPageULMarginItem.reset();
+ mpPageSizeItem.reset();
+
+ SfxPopupWindow::dispose();
+}
+
+void PageOrientationControl::ExecuteMarginLRChange(
+ const long nPageLeftMargin,
+ const long nPageRightMargin )
+{
+ mpPageLRMarginItem->SetLeft( nPageLeftMargin );
+ mpPageLRMarginItem->SetRight( nPageRightMargin );
+ SfxViewShell::Current()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_LRSPACE,
+ SfxCallMode::RECORD, { mpPageLRMarginItem.get() });
+}
+
+void PageOrientationControl::ExecuteMarginULChange(
+ const long nPageTopMargin,
+ const long nPageBottomMargin )
+{
+ mpPageULMarginItem->SetUpper( nPageTopMargin );
+ mpPageULMarginItem->SetLower( nPageBottomMargin );
+ SfxViewShell::Current()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_ULSPACE,
+ SfxCallMode::RECORD, { mpPageULMarginItem.get() });
}
-IMPL_LINK_TYPED(PageOrientationControl, ImplOrientationHdl, ValueSet*, pControl, void)
+void PageOrientationControl::ExecuteOrientationChange( const bool bLandscape )
{
- mpOrientationValueSet->SetNoSelection();
- if ( pControl == mpOrientationValueSet )
+ css::uno::Reference< css::document::XUndoManager > mxUndoManager(
+ getUndoManager( SfxViewFrame::Current()->GetFrame().GetFrameInterface() ) );
+
+ if ( mxUndoManager.is() )
+ mxUndoManager->enterUndoContext( "" );
+
+ const SfxPoolItem* pItem;
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE, pItem);
+ SvxSizeItem* pSizeItem = static_cast<SvxSizeItem*>(pItem->Clone());
+ if ( pSizeItem )
+ mpPageSizeItem.reset( pSizeItem );
+
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, pItem);
+ SvxLongLRSpaceItem* pLRItem = static_cast<SvxLongLRSpaceItem*>(pItem->Clone());
+ if ( pLRItem )
+ mpPageLRMarginItem.reset( pLRItem );
+
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, pItem);
+ SvxLongULSpaceItem* pULItem = static_cast<SvxLongULSpaceItem*>(pItem->Clone());
+ if ( pULItem )
+ mpPageULMarginItem.reset( pULItem );
+
+ {
+ // set new page orientation
+ mpPageItem->SetLandscape( bLandscape );
+
+ // swap the width and height of the page size
+ const long nRotatedWidth = mpPageSizeItem->GetSize().Height();
+ const long nRotatedHeight = mpPageSizeItem->GetSize().Width();
+ mpPageSizeItem->SetSize(Size(nRotatedWidth, nRotatedHeight));
+
+ // apply changed attributes
+ if (SfxViewShell::Current())
+ {
+ SfxViewShell::Current()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE,
+ SfxCallMode::RECORD, { mpPageSizeItem.get(), mpPageItem.get() });
+ }
+ }
+
+ // check, if margin values still fit to the changed page size.
+ // if not, adjust margin values
{
- const sal_uInt32 iPos = mpOrientationValueSet->GetSelectItemId();
- const bool bChanged = ( ( iPos == 1 ) && mbLandscape ) ||
- ( ( iPos == 2 ) && !mbLandscape );
- if ( bChanged )
+ const long nML = mpPageLRMarginItem->GetLeft();
+ const long nMR = mpPageLRMarginItem->GetRight();
+ const long nTmpPW = nML + nMR + MINBODY;
+
+ const long nPW = mpPageSizeItem->GetSize().Width();
+
+ if ( nTmpPW > nPW )
+ {
+ if ( nML <= nMR )
+ {
+ ExecuteMarginLRChange( mpPageLRMarginItem->GetLeft(), nMR - (nTmpPW - nPW ) );
+ }
+ else
+ {
+ ExecuteMarginLRChange( nML - (nTmpPW - nPW ), mpPageLRMarginItem->GetRight() );
+ }
+ }
+
+ const long nMT = mpPageULMarginItem->GetUpper();
+ const long nMB = mpPageULMarginItem->GetLower();
+ const long nTmpPH = nMT + nMB + MINBODY;
+
+ const long nPH = mpPageSizeItem->GetSize().Height();
+
+ if ( nTmpPH > nPH )
{
- mbLandscape = !mbLandscape;
- mrPagePropPanel.ExecuteOrientationChange( mbLandscape );
+ if ( nMT <= nMB )
+ {
+ ExecuteMarginULChange( mpPageULMarginItem->GetUpper(), nMB - ( nTmpPH - nPH ) );
+ }
+ else
+ {
+ ExecuteMarginULChange( nMT - ( nTmpPH - nPH ), mpPageULMarginItem->GetLower() );
+ }
}
}
- mrPagePropPanel.ClosePageOrientationPopup();
+ if ( mxUndoManager.is() )
+ mxUndoManager->leaveUndoContext();
+}
+
+IMPL_LINK_TYPED(PageOrientationControl, ImplOrientationHdl, Button*, pControl, void)
+{
+ if ( pControl == m_pPortrait.get() )
+ ExecuteOrientationChange( false );
+ else
+ ExecuteOrientationChange( true );
+
+ EndPopupMode();
}
} } // end of namespace sw::sidebar
diff --git a/sw/source/uibase/sidebar/PageOrientationControl.hxx b/sw/source/uibase/sidebar/PageOrientationControl.hxx
index 7d44d7b58bcd..53b72706022c 100644
--- a/sw/source/uibase/sidebar/PageOrientationControl.hxx
+++ b/sw/source/uibase/sidebar/PageOrientationControl.hxx
@@ -19,37 +19,40 @@
#ifndef INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_PAGEORIENTATIONCONTROL_HXX
#define INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_PAGEORIENTATIONCONTROL_HXX
-#include <svx/sidebar/PopupControl.hxx>
-
-namespace svx { namespace sidebar {
- class ValueSetWithTextControl;
-} }
-class ValueSet;
+#include <svx/tbxctl.hxx>
+#include <svx/pageitem.hxx>
+#include <svx/rulritem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <com/sun/star/document/XUndoManager.hpp>
+#include <com/sun/star/document/XUndoManagerSupplier.hpp>
+class Button;
namespace sw { namespace sidebar {
class PagePropertyPanel;
-class PageOrientationControl
- : public svx::sidebar::PopupControl
+class PageOrientationControl : public SfxPopupWindow
{
public:
- PageOrientationControl(
- vcl::Window* pParent,
- PagePropertyPanel& rPanel,
- const bool bLandscape );
+ PageOrientationControl(sal_uInt16 nId);
virtual ~PageOrientationControl();
virtual void dispose() override;
private:
- VclPtr< svx::sidebar::ValueSetWithTextControl> mpOrientationValueSet;
+ VclPtr<PushButton> m_pPortrait;
+ VclPtr<PushButton> m_pLandscape;
- bool mbLandscape;
+ std::unique_ptr<SvxPageItem> mpPageItem;
+ std::unique_ptr<SvxSizeItem> mpPageSizeItem;
+ std::unique_ptr<SvxLongLRSpaceItem> mpPageLRMarginItem;
+ std::unique_ptr<SvxLongULSpaceItem> mpPageULMarginItem;
- PagePropertyPanel& mrPagePropPanel;
+ void ExecuteMarginULChange(const long nPageTopMargin, const long nPageBottomMargin);
+ void ExecuteMarginLRChange(const long nPageLeftMargin, const long nPageRightMargin);
+ void ExecuteOrientationChange(const bool bLandscape);
- DECL_LINK_TYPED(ImplOrientationHdl, ValueSet*, void);
+ DECL_LINK_TYPED(ImplOrientationHdl, Button*, void);
};
} } // end of namespace sw::sidebar
diff --git a/sw/source/uibase/sidebar/PageOrientationPopup.cxx b/sw/source/uibase/sidebar/PageOrientationPopup.cxx
new file mode 100644
index 000000000000..b11a19115cac
--- /dev/null
+++ b/sw/source/uibase/sidebar/PageOrientationPopup.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 <PageOrientationPopup.hxx>
+#include "PageOrientationControl.hxx"
+#include <svx/pageitem.hxx>
+#include <vcl/toolbox.hxx>
+
+SFX_IMPL_TOOLBOX_CONTROL(PageOrientationPopup, SvxPageItem);
+
+PageOrientationPopup::PageOrientationPopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
+ : SfxToolBoxControl(nSlotId, nId, rTbx)
+{
+ rTbx.SetItemBits(nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits(nId));
+}
+
+PageOrientationPopup::~PageOrientationPopup()
+{
+}
+
+VclPtr<SfxPopupWindow> PageOrientationPopup::CreatePopupWindow()
+{
+ VclPtr<sw::sidebar::PageOrientationControl> pControl = VclPtr<sw::sidebar::PageOrientationControl>::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/PagePropertyPanel.cxx b/sw/source/uibase/sidebar/PagePropertyPanel.cxx
index f4a594dc4422..fa6d711e59d7 100644
--- a/sw/source/uibase/sidebar/PagePropertyPanel.cxx
+++ b/sw/source/uibase/sidebar/PagePropertyPanel.cxx
@@ -27,7 +27,6 @@
#include "PropertyPanel.hrc"
#include <svx/sidebar/PopupContainer.hxx>
-#include "PageOrientationControl.hxx"
#include "PageMarginControl.hxx"
#include "PageSizeControl.hxx"
#include "PageColumnControl.hxx"
@@ -52,7 +51,6 @@
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/document/XUndoManagerSupplier.hpp>
-const char UNO_ORIENTATION[] = ".uno:Orientation";
const char UNO_MARGIN[] = ".uno:Margin";
const char UNO_SIZE[] = ".uno:Size";
const char UNO_COLUMN[] = ".uno:Column";
@@ -108,8 +106,6 @@ PagePropertyPanel::PagePropertyPanel(
// image resources
, maImgSize (nullptr)
, maImgSize_L (nullptr)
- , mImgPortrait (SW_RES(IMG_PAGE_PORTRAIT))
- , mImgLandscape (SW_RES(IMG_PAGE_LANDSCAPE))
, mImgNarrow (SW_RES(IMG_PAGE_NARROW))
, mImgNormal (SW_RES(IMG_PAGE_NORMAL))
, mImgWide (SW_RES(IMG_PAGE_WIDE))
@@ -168,9 +164,6 @@ PagePropertyPanel::PagePropertyPanel(
, m_aSwPageColControl(SID_ATTR_PAGE_COLUMN, *pBindings, *this)
, m_aSwPagePgMetricControl(SID_ATTR_METRIC, *pBindings, *this)
- , maOrientationPopup( this,
- [this] (svx::sidebar::PopupContainer *parent) { return this->CreatePageOrientationControl(parent); },
- OUString("Page orientation") )
, maMarginPopup( this,
[this] (svx::sidebar::PopupContainer *parent) { return this->CreatePageMarginControl(parent); },
OUString("Page margins") )
@@ -186,7 +179,6 @@ PagePropertyPanel::PagePropertyPanel(
, mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify( false )
{
// visible controls
- get(mpToolBoxOrientation, "selectorientation");
get(mpToolBoxMargin, "selectmargin");
get(mpToolBoxSize, "selectsize");
get(mpToolBoxColumn, "selectcolumn");
@@ -212,7 +204,6 @@ void PagePropertyPanel::dispose()
mpPageULMarginItem.reset();
mpPageSizeItem.reset();
- mpToolBoxOrientation.clear();
mpToolBoxMargin.clear();
mpToolBoxSize.clear();
mpToolBoxColumn.clear();
@@ -227,24 +218,15 @@ void PagePropertyPanel::dispose()
maColumnPopup.dispose();
maSizePopup.dispose();
maMarginPopup.dispose();
- maOrientationPopup.dispose();
PanelLayout::dispose();
}
void PagePropertyPanel::Initialize()
{
- // popup for page orientation
- const sal_uInt16 nIdOrientation = mpToolBoxOrientation->GetItemId(UNO_ORIENTATION);
- Link<ToolBox *, void> aLink = LINK( this, PagePropertyPanel, ClickOrientationHdl );
- mpToolBoxOrientation->SetDropdownClickHdl( aLink );
- mpToolBoxOrientation->SetSelectHdl( aLink );
- mpToolBoxOrientation->SetItemImage( nIdOrientation, mImgPortrait);
- mpToolBoxOrientation->SetItemBits( nIdOrientation, mpToolBoxOrientation->GetItemBits( nIdOrientation ) | ToolBoxItemBits::DROPDOWNONLY );
-
// popup for page margins
const sal_uInt16 nIdMargin = mpToolBoxMargin->GetItemId(UNO_MARGIN);
- aLink = LINK( this, PagePropertyPanel, ClickMarginHdl );
+ Link<ToolBox *, void> aLink = LINK( this, PagePropertyPanel, ClickMarginHdl );
mpToolBoxMargin->SetDropdownClickHdl( aLink );
mpToolBoxMargin->SetSelectHdl( aLink );
mpToolBoxMargin->SetItemImage(nIdMargin, mImgNormal);
@@ -294,82 +276,6 @@ void PagePropertyPanel::Initialize()
mpBindings->Update( SID_ATTR_PAGE_SIZE );
}
-VclPtr< svx::sidebar::PopupControl> PagePropertyPanel::CreatePageOrientationControl( svx::sidebar::PopupContainer* pParent )
-{
- return VclPtr<PageOrientationControl>::Create( pParent, *this , mpPageItem->IsLandscape() );
-}
-
-IMPL_LINK_TYPED( PagePropertyPanel, ClickOrientationHdl, ToolBox*, pToolBox, void )
-{
- maOrientationPopup.Show( *pToolBox );
-}
-
-void PagePropertyPanel::ExecuteOrientationChange( const bool bLandscape )
-{
- StartUndo();
-
- {
- // set new page orientation
- mpPageItem->SetLandscape( bLandscape );
-
- // swap the width and height of the page size
- const long nRotatedWidth = mpPageSizeItem->GetSize().Height();
- const long nRotatedHeight = mpPageSizeItem->GetSize().Width();
- mpPageSizeItem->SetSize(Size(nRotatedWidth, nRotatedHeight));
-
- // apply changed attributes
- GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE,
- SfxCallMode::RECORD, { mpPageSizeItem.get(), mpPageItem.get() });
- }
-
- // check, if margin values still fit to the changed page size.
- // if not, adjust margin values
- {
- const long nML = mpPageLRMarginItem->GetLeft();
- const long nMR = mpPageLRMarginItem->GetRight();
- const long nTmpPW = nML + nMR + MINBODY;
-
- const long nPW = mpPageSizeItem->GetSize().Width();
-
- if ( nTmpPW > nPW )
- {
- if ( nML <= nMR )
- {
- ExecuteMarginLRChange( mpPageLRMarginItem->GetLeft(), nMR - (nTmpPW - nPW ) );
- }
- else
- {
- ExecuteMarginLRChange( nML - (nTmpPW - nPW ), mpPageLRMarginItem->GetRight() );
- }
- }
-
- const long nMT = mpPageULMarginItem->GetUpper();
- const long nMB = mpPageULMarginItem->GetLower();
- const long nTmpPH = nMT + nMB + MINBODY;
-
- const long nPH = mpPageSizeItem->GetSize().Height();
-
- if ( nTmpPH > nPH )
- {
- if ( nMT <= nMB )
- {
- ExecuteMarginULChange( mpPageULMarginItem->GetUpper(), nMB - ( nTmpPH - nPH ) );
- }
- else
- {
- ExecuteMarginULChange( nMT - ( nTmpPH - nPH ), mpPageULMarginItem->GetLower() );
- }
- }
- }
-
- EndUndo();
-}
-
-void PagePropertyPanel::ClosePageOrientationPopup()
-{
- maOrientationPopup.Hide();
-}
-
VclPtr< svx::sidebar::PopupControl> PagePropertyPanel::CreatePageMarginControl( svx::sidebar::PopupContainer* pParent )
{
return VclPtr<PageMarginControl>::Create(
@@ -524,26 +430,6 @@ void PagePropertyPanel::NotifyItemUpdate(
}
break;
- case SID_ATTR_PAGE:
- if ( eState >= SfxItemState::DEFAULT &&
- pState && dynamic_cast< const SvxPageItem *>( pState ) != nullptr )
- {
- const sal_uInt16 nIdOrientation = mpToolBoxOrientation->GetItemId(UNO_ORIENTATION);
- mpPageItem.reset( static_cast<SvxPageItem*>(pState->Clone()) );
- if ( mpPageItem->IsLandscape() )
- {
- mpToolBoxOrientation->SetItemImage(nIdOrientation, mImgLandscape);
- }
- else
- {
- mpToolBoxOrientation->SetItemImage(nIdOrientation, mImgPortrait);
- }
- ChangeMarginImage();
- ChangeSizeImage();
- ChangeColumnImage( mpPageColumnTypeItem->GetValue() );
- }
- break;
-
case SID_ATTR_PAGE_SIZE:
if ( mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify )
{
diff --git a/sw/source/uibase/sidebar/PagePropertyPanel.hrc b/sw/source/uibase/sidebar/PagePropertyPanel.hrc
index fe850caa259f..01d4df9ce654 100644
--- a/sw/source/uibase/sidebar/PagePropertyPanel.hrc
+++ b/sw/source/uibase/sidebar/PagePropertyPanel.hrc
@@ -21,8 +21,6 @@
#include "PropertyPanel.hrc"
// global definitions
-#define IMG_PAGE_PORTRAIT (RC_SIDEBAR_BEGIN + 0)
-#define IMG_PAGE_LANDSCAPE (RC_SIDEBAR_BEGIN + 1)
#define IMG_PAGE_NARROW (RC_SIDEBAR_BEGIN + 2)
#define IMG_PAGE_NORMAL (RC_SIDEBAR_BEGIN + 3)
#define IMG_PAGE_WIDE (RC_SIDEBAR_BEGIN + 4)
@@ -65,10 +63,6 @@
#define IMG_PAGE_COLUMN_NONE_L (RC_SIDEBAR_BEGIN + 41)
// local
-#define IMG_PORTRAIT 10
-#define IMG_LANDSCAPE 11
-#define STR_PORTRAIT 12
-#define STR_LANDSCAPE 13
#define MF_SWLEFT_MARGIN 18
#define MF_SWRIGHT_MARGIN 19
@@ -79,7 +73,6 @@
#define FT_CUSTOM 25
#define FLD_WIDTH_HEIGHT 26
-#define VS_ORIENTATION 29
#define IMG_NARROW 32
#define IMG_NORMAL 33
#define IMG_WIDE 34
diff --git a/sw/source/uibase/sidebar/PagePropertyPanel.hxx b/sw/source/uibase/sidebar/PagePropertyPanel.hxx
index 22452c8f3586..4c71d44c4fa7 100644
--- a/sw/source/uibase/sidebar/PagePropertyPanel.hxx
+++ b/sw/source/uibase/sidebar/PagePropertyPanel.hxx
@@ -71,10 +71,6 @@ namespace sw { namespace sidebar {
return mpBindings;
}
- VclPtr< svx::sidebar::PopupControl> CreatePageOrientationControl( svx::sidebar::PopupContainer* pParent );
- void ExecuteOrientationChange( const bool bLandscape );
- void ClosePageOrientationPopup();
-
VclPtr< svx::sidebar::PopupControl> CreatePageMarginControl( svx::sidebar::PopupContainer* pParent );
void ExecuteMarginLRChange(
const long nPageLeftMargin,
@@ -107,15 +103,12 @@ namespace sw { namespace sidebar {
SfxBindings* mpBindings;
// toolboxes - on click open corresponding popup
- VclPtr<ToolBox> mpToolBoxOrientation;
VclPtr<ToolBox> mpToolBoxMargin;
VclPtr<ToolBox> mpToolBoxSize;
VclPtr<ToolBox> mpToolBoxColumn;
Image* maImgSize;
Image* maImgSize_L;
- Image mImgPortrait;
- Image mImgLandscape;
Image mImgNarrow;
Image mImgNormal;
Image mImgWide;
@@ -189,7 +182,6 @@ namespace sw { namespace sidebar {
::sfx2::sidebar::ControllerItem m_aSwPagePgMetricControl;
// popups
- svx::sidebar::Popup maOrientationPopup;
svx::sidebar::Popup maMarginPopup;
svx::sidebar::Popup maSizePopup;
svx::sidebar::Popup maColumnPopup;
@@ -199,7 +191,6 @@ namespace sw { namespace sidebar {
bool mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify;
// handler for popup toolboxes to show the popups
- DECL_LINK_TYPED(ClickOrientationHdl, ToolBox*, void);
DECL_LINK_TYPED(ClickMarginHdl, ToolBox*, void);
DECL_LINK_TYPED(ClickSizeHdl, ToolBox*, void);
DECL_LINK_TYPED(ClickColumnHdl, ToolBox*, void);
diff --git a/sw/source/uibase/sidebar/PropertyPanel.hrc b/sw/source/uibase/sidebar/PropertyPanel.hrc
index ef8c5b091c94..7b36710f75a6 100644
--- a/sw/source/uibase/sidebar/PropertyPanel.hrc
+++ b/sw/source/uibase/sidebar/PropertyPanel.hrc
@@ -22,7 +22,6 @@
#include "rcid.hrc"
#define RID_POPUP_SWPAGE_MARGIN (RC_PROPERTYPANEL_BEGIN + 3)
-#define RID_POPUP_SWPAGE_ORIENTATION (RC_PROPERTYPANEL_BEGIN + 4)
#define RID_POPUP_SWPAGE_COLUMN (RC_PROPERTYPANEL_BEGIN + 5)
#define RID_POPUP_SWPAGE_SIZE (RC_PROPERTYPANEL_BEGIN + 6)
diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx
index 31d6b03a2522..b14e3f2de30a 100644
--- a/sw/source/uibase/uiview/viewstat.cxx
+++ b/sw/source/uibase/uiview/viewstat.cxx
@@ -147,6 +147,7 @@ void SwView::GetState(SfxItemSet &rSet)
case SID_PRINTDOCDIRECT:
GetSlotState( nWhich, SfxViewShell::GetInterface(), &rSet );
break;
+ case SID_ATTR_PAGE_ORIENTATION:
case SID_ATTR_PAGE:
case SID_ATTR_PAGE_SIZE:
case SID_ATTR_PAGE_PAPERBIN: