summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSusobhan Ghosh <susobhang70@gmail.com>2016-05-25 09:43:31 +0530
committerKatarina Behrens <Katarina.Behrens@cib.de>2016-06-06 10:10:04 +0000
commit8b99402338773150fc0c8c6f894eb610e056d79e (patch)
tree822c39112438e7993fff85b9588f83e3b361af44
parentecece54942a8e5f20ae6dc69f25a2499d38c78bd (diff)
tdf#83830: Page Format Panel
Change-Id: I16d263f07eb49eaa32a161958b48f4059fffafdf Reviewed-on: https://gerrit.libreoffice.org/25530 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de> Tested-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r--sw/source/uibase/sidebar/PageFormatPanel.cxx165
-rw-r--r--sw/source/uibase/sidebar/PageFormatPanel.hxx33
-rw-r--r--sw/source/uibase/sidebar/SwPanelFactory.cxx2
-rw-r--r--sw/uiconfig/swriter/ui/pageformatpanel.ui35
4 files changed, 214 insertions, 21 deletions
diff --git a/sw/source/uibase/sidebar/PageFormatPanel.cxx b/sw/source/uibase/sidebar/PageFormatPanel.cxx
index 5af11598e9fb..46c92c2db8ee 100644
--- a/sw/source/uibase/sidebar/PageFormatPanel.cxx
+++ b/sw/source/uibase/sidebar/PageFormatPanel.cxx
@@ -34,31 +34,43 @@
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/document/XUndoManagerSupplier.hpp>
+#include <svtools/unitconv.hxx>
+#include <svtools/optionsdrawinglayer.hxx>
namespace sw { namespace sidebar{
VclPtr<vcl::Window> PageFormatPanel::Create(
vcl::Window* pParent,
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame)
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
+ SfxBindings* pBindings)
{
if( pParent == nullptr )
throw ::com::sun::star::lang::IllegalArgumentException("no parent window given to PageFormatPanel::Create", nullptr, 0);
if( !rxFrame.is() )
throw ::com::sun::star::lang::IllegalArgumentException("no XFrame given to PageFormatPanel::Create", nullptr, 0);
- return VclPtr<PageFormatPanel>::Create(pParent, rxFrame);
+ return VclPtr<PageFormatPanel>::Create(pParent, rxFrame, pBindings);
}
PageFormatPanel::PageFormatPanel(
vcl::Window* pParent,
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame
- ) :
- PanelLayout(pParent, "PageFormatPanel", "modules/swriter/ui/pageformatpanel.ui", rxFrame)
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
+ SfxBindings* pBindings) :
+ PanelLayout(pParent, "PageFormatPanel", "modules/swriter/ui/pageformatpanel.ui", rxFrame),
+ mpBindings( pBindings ),
+ maPaperSizeController(SID_ATTR_PAGE_SIZE, *pBindings, *this),
+ maPaperOrientationController(SID_ATTR_PAGE, *pBindings, *this),
+ maMetricController(SID_ATTR_METRIC, *pBindings,*this),
+ mpPageItem( new SvxPageItem(SID_ATTR_PAGE) ),
+ meFUnit(GetModuleFieldUnit()),
+ meLastFUnit(GetModuleFieldUnit()),
+ meUnit()
{
- get(mpPaperSizeLB, "papersize");
+ get(mpPaperSizeBox, "papersize");
get(mpPaperWidth, "paperwidth");
get(mpPaperHeight, "paperheight");
get(mpPaperOrientation, "paperorientation");
+ Initialize();
}
PageFormatPanel::~PageFormatPanel()
@@ -68,21 +80,152 @@ PageFormatPanel::~PageFormatPanel()
void PageFormatPanel::dispose()
{
- mpPaperSizeLB.disposeAndClear();
+ mpPaperSizeBox.disposeAndClear();
mpPaperWidth.disposeAndClear();
mpPaperHeight.disposeAndClear();
mpPaperOrientation.disposeAndClear();
+ maMetricController.dispose();
+ maPaperOrientationController.dispose();
+ maPaperSizeController.dispose();
+ mpPageItem.reset();
+
PanelLayout::dispose();
}
+void PageFormatPanel::Initialize()
+{
+ mpPaperSizeBox->FillPaperSizeEntries( PaperSizeStd );
+ mpPaperSizeBox->SetDropDownLineCount(6);
+ meUnit = maPaperSizeController.GetCoreMetric();
+ SetFieldUnit( *mpPaperWidth, meFUnit );
+ SetFieldUnit( *mpPaperHeight, meFUnit );
+
+ const SvtOptionsDrawinglayer aDrawinglayerOpt;
+ mpPaperWidth->SetMax(mpPaperWidth->Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FUNIT_CM);
+ mpPaperWidth->SetLast(mpPaperWidth->Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FUNIT_CM);
+ mpPaperHeight->SetMax(mpPaperHeight->Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FUNIT_CM);
+ mpPaperHeight->SetLast(mpPaperHeight->Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FUNIT_CM);
+
+ mpPaperSizeBox->SetSelectHdl( LINK(this, PageFormatPanel, PaperFormatModifyHdl ));
+ mpPaperOrientation->SetSelectHdl( LINK(this, PageFormatPanel, PaperFormatModifyHdl ));
+ mpPaperHeight->SetModifyHdl( LINK(this, PageFormatPanel, PaperSizeModifyHdl ));
+ mpPaperWidth->SetModifyHdl( LINK(this, PageFormatPanel, PaperSizeModifyHdl ));
+
+ mpBindings->Update(SID_ATTR_METRIC);
+ mpBindings->Update(SID_ATTR_PAGE);
+ mpBindings->Update(SID_ATTR_PAGE_SIZE);
+}
+
void PageFormatPanel::NotifyItemUpdate(
- const sal_uInt16 /*nSid*/,
- const SfxItemState /*eState*/,
- const SfxPoolItem* /*pState*/,
- const bool /*bIsEnabled*/)
+ const sal_uInt16 nSId,
+ const SfxItemState eState,
+ const SfxPoolItem* pState,
+ const bool bIsEnabled)
{
+ (void)bIsEnabled;
+
+ switch(nSId)
+ {
+ case SID_ATTR_PAGE_SIZE:
+ {
+ const SvxSizeItem* pSizeItem = nullptr;
+ if (eState >= SfxItemState::DEFAULT)
+ pSizeItem = dynamic_cast< const SvxSizeItem* >(pState);
+ if (pSizeItem)
+ {
+ Size aPaperSize = pSizeItem->GetSize();
+
+ mpPaperWidth->SetValue( mpPaperWidth->Normalize( aPaperSize.Width() ), FUNIT_TWIP );
+ mpPaperHeight->SetValue( mpPaperHeight->Normalize( aPaperSize.Height() ), FUNIT_TWIP );
+
+ if(mpPaperOrientation->GetSelectEntryPos() == 1)
+ Swap(aPaperSize);
+
+ Paper ePaper = SvxPaperInfo::GetSvxPaper(aPaperSize, static_cast<MapUnit>(meUnit),true);
+ mpPaperSizeBox->SetSelection( ePaper );
+ }
+ }
+ break;
+ case SID_ATTR_METRIC:
+ {
+ meUnit = maPaperSizeController.GetCoreMetric();
+ meFUnit = GetCurrentUnit(eState, pState);
+ if(meFUnit != meLastFUnit)
+ {
+ SetFieldUnit( *mpPaperHeight, meFUnit );
+ SetFieldUnit( *mpPaperWidth, meFUnit );
+ }
+ meLastFUnit = meFUnit;
+ }
+ break;
+ case SID_ATTR_PAGE:
+ {
+ if ( eState >= SfxItemState::DEFAULT &&
+ pState && dynamic_cast< const SvxPageItem *>( pState ) != nullptr )
+ {
+ mpPageItem.reset( static_cast<SvxPageItem*>(pState->Clone()) );
+ if ( mpPageItem->IsLandscape() )
+ mpPaperOrientation->SelectEntryPos(1);
+ else
+ mpPaperOrientation->SelectEntryPos(0);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+IMPL_LINK_NOARG_TYPED(PageFormatPanel, PaperFormatModifyHdl, ListBox&, void)
+{
+ Paper ePaper = mpPaperSizeBox->GetSelection();
+ Size aSize(SvxPaperInfo::GetPaperSize(ePaper, (MapUnit)(meUnit)));
+
+ if(mpPaperOrientation->GetSelectEntryPos() == 1)
+ Swap(aSize);
+
+ mpPageItem->SetLandscape(mpPaperOrientation->GetSelectEntryPos() == 1);
+ SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, aSize);
+ mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, SfxCallMode::RECORD, { &aSizeItem, mpPageItem.get() });
+}
+
+IMPL_LINK_NOARG_TYPED(PageFormatPanel, PaperSizeModifyHdl, Edit&, void)
+{
+ Size aSize( GetCoreValue( *mpPaperWidth, meUnit ), GetCoreValue( *mpPaperHeight, meUnit));
+ SvxSizeItem aSizeItem(SID_ATTR_PAGE_SIZE, aSize);
+ mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, SfxCallMode::RECORD, { &aSizeItem });
+}
+
+FieldUnit PageFormatPanel::GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState )
+{
+ FieldUnit eUnit = FUNIT_NONE;
+
+ if ( pState && eState >= SfxItemState::DEFAULT )
+ eUnit = (FieldUnit) static_cast<const SfxUInt16Item*>(pState)->GetValue();
+ else
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::Current();
+ SfxObjectShell* pSh = nullptr;
+ if ( pFrame )
+ pSh = pFrame->GetObjectShell();
+ if ( pSh )
+ {
+ SfxModule* pModule = pSh->GetModule();
+ if ( pModule )
+ {
+ const SfxPoolItem* pItem = pModule->GetItem( SID_ATTR_METRIC );
+ if ( pItem )
+ eUnit = (FieldUnit) static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+ }
+ else
+ {
+ SAL_WARN("sw.sidebar", "GetModuleFieldUnit(): no module found");
+ }
+ }
+ }
+ return eUnit;
}
} }
diff --git a/sw/source/uibase/sidebar/PageFormatPanel.hxx b/sw/source/uibase/sidebar/PageFormatPanel.hxx
index 0b4b4005f422..e266d96ce0f3 100644
--- a/sw/source/uibase/sidebar/PageFormatPanel.hxx
+++ b/sw/source/uibase/sidebar/PageFormatPanel.hxx
@@ -31,6 +31,7 @@
#include <svx/pageitem.hxx>
#include <svx/rulritem.hxx>
+#include <svx/papersizelistbox.hxx>
#include <editeng/sizeitem.hxx>
#include <vcl/ctrl.hxx>
@@ -43,6 +44,9 @@
#include <tools/fldunit.hxx>
#include <svl/poolitem.hxx>
#include <svx/rulritem.hxx>
+#include <svx/relfld.hxx>
+
+#include <vector>
namespace sw { namespace sidebar {
@@ -53,7 +57,8 @@ class PageFormatPanel:
public:
static VclPtr<vcl::Window> Create(
vcl::Window* pParent,
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame);
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
+ SfxBindings* pBindings);
virtual void NotifyItemUpdate(
const sal_uInt16 nSId,
@@ -63,16 +68,34 @@ public:
PageFormatPanel(
vcl::Window* pParent,
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame);
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxFrame,
+ SfxBindings* pBindings);
virtual ~PageFormatPanel();
virtual void dispose() override;
+ static FieldUnit GetCurrentUnit( SfxItemState eState, const SfxPoolItem* pState );
+
private:
- VclPtr<ListBox> mpPaperSizeLB;
- VclPtr<MetricField> mpPaperWidth;
- VclPtr<MetricField> mpPaperHeight;
+ SfxBindings* mpBindings;
+
+ VclPtr<PaperSizeListBox> mpPaperSizeBox;
+ VclPtr<SvxRelativeField> mpPaperWidth;
+ VclPtr<SvxRelativeField> mpPaperHeight;
VclPtr<ListBox> mpPaperOrientation;
+
+ ::sfx2::sidebar::ControllerItem maPaperSizeController;
+ ::sfx2::sidebar::ControllerItem maPaperOrientationController;
+ ::sfx2::sidebar::ControllerItem maMetricController;
+
+ ::std::unique_ptr<SvxPageItem> mpPageItem;
+
+ FieldUnit meFUnit, meLastFUnit;
+ SfxMapUnit meUnit;
+
+ void Initialize();
+ DECL_LINK_TYPED(PaperFormatModifyHdl, ListBox&, void);
+ DECL_LINK_TYPED(PaperSizeModifyHdl, Edit&, void);
};
} } //end of namespace sw::sidebar
diff --git a/sw/source/uibase/sidebar/SwPanelFactory.cxx b/sw/source/uibase/sidebar/SwPanelFactory.cxx
index 7e7c467d7183..c89ec5df5dd2 100644
--- a/sw/source/uibase/sidebar/SwPanelFactory.cxx
+++ b/sw/source/uibase/sidebar/SwPanelFactory.cxx
@@ -154,7 +154,7 @@ Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
}
else if(rsResourceURL.endsWith("/PageFormatPanel"))
{
- VclPtr<vcl::Window> pPanel = sw::sidebar::PageFormatPanel::Create( pParentWindow, xFrame );
+ VclPtr<vcl::Window> pPanel = sw::sidebar::PageFormatPanel::Create( pParentWindow, xFrame, pBindings );
xElement = sfx2::sidebar::SidebarPanelBase::Create(
rsResourceURL,
xFrame,
diff --git a/sw/uiconfig/swriter/ui/pageformatpanel.ui b/sw/uiconfig/swriter/ui/pageformatpanel.ui
index 148030b24f1d..5d503304bc57 100644
--- a/sw/uiconfig/swriter/ui/pageformatpanel.ui
+++ b/sw/uiconfig/swriter/ui/pageformatpanel.ui
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.16.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
+ <!-- interface-requires LibreOffice 1.0 -->
<object class="GtkGrid" id="PageFormatPanel">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -22,6 +23,8 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -33,6 +36,8 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -44,6 +49,8 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -55,28 +62,42 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="paperwidth">
+ <object class="svxlo-SvxRelativeField" id="paperwidth">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_text" translatable="yes">Paper Width</property>
<property name="hexpand">True</property>
+ <property name="invisible_char">•</property>
+ <property name="text">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="paperheight">
+ <object class="svxlo-SvxRelativeField" id="paperheight">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_text" translatable="yes">Paper Height</property>
<property name="hexpand">True</property>
+ <property name="invisible_char">•</property>
+ <property name="text">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
@@ -92,10 +113,12 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkComboBoxText" id="papersize">
+ <object class="svxcorelo-PaperSizeListBox" id="papersize">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
@@ -103,12 +126,16 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
</packing>
</child>
</object>