summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Deep <akshaydeepiitr@gmail.com>2016-06-06 11:20:16 +0530
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-07-08 14:05:09 +0000
commit1c39db584f9f1877a9fa5ce00e8d19dd997d8078 (patch)
treee64f485b264edfcd82572513a4854a928ad86c23
parent84059c853f15e0e3b1433193e8136350869c23d7 (diff)
tdf#83054 Writer: Add "Go to Page" Entry in Edit Menu
Change-Id: I09026910687b019fe33d4016612b8247ff076100 Reviewed-on: https://gerrit.libreoffice.org/25949 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/UIConfig_swriter.mk1
-rw-r--r--sw/inc/cmdid.h2
-rw-r--r--sw/inc/gotodlg.hxx55
-rw-r--r--sw/sdi/_viewsh.sdi2
-rw-r--r--sw/sdi/swriter.sdi2
-rw-r--r--sw/source/uibase/uiview/view2.cxx18
-rw-r--r--sw/source/uibase/utlui/gotodlg.cxx116
-rw-r--r--sw/uiconfig/swriter/ui/gotopagedialog.ui140
9 files changed, 321 insertions, 16 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index ea8c36205f48..c563c9c6b816 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -734,6 +734,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/uibase/utlui/initui \
sw/source/uibase/utlui/navicfg \
sw/source/uibase/utlui/navipi \
+ sw/source/uibase/utlui/gotodlg \
sw/source/uibase/utlui/numfmtlb \
sw/source/uibase/utlui/prcntfld \
sw/source/uibase/utlui/shdwcrsr \
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index da0fc29950df..174575ba55af 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -145,6 +145,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
sw/uiconfig/swriter/ui/frmaddpage \
sw/uiconfig/swriter/ui/frmtypepage \
sw/uiconfig/swriter/ui/frmurlpage \
+ sw/uiconfig/swriter/ui/gotopagedialog \
sw/uiconfig/swriter/ui/indexentry \
sw/uiconfig/swriter/ui/inputfielddialog \
sw/uiconfig/swriter/ui/indentpage \
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index a832571b993c..7223028fc858 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -505,7 +505,7 @@
#define FN_UPDATE_CUR_TOX (FN_EXTRA + 54) /* update current index */
#define FN_REMOVE_CUR_TOX (FN_EXTRA + 55) /* remove the current TOX*/
-#define FN_NAVIGATION_PI_GOTO_PAGE (FN_EXTRA + 59 ) /* goto page from navigation-PI */
+#define FN_GOTO_PAGE (FN_EXTRA + 59 ) /* goto page */
#define FN_COLL_TYPE (FN_EXTRA + 98) /* type for GlobalDoc-Collection*/
#define FN_COLL_ADD (FN_EXTRA + 99)
diff --git a/sw/inc/gotodlg.hxx b/sw/inc/gotodlg.hxx
new file mode 100644
index 000000000000..b1d531a1a6d5
--- /dev/null
+++ b/sw/inc/gotodlg.hxx
@@ -0,0 +1,55 @@
+/* -*- 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_SOURCE_UIBASE_INC_GOTODLG_HXX
+#define INCLUDED_SW_SOURCE_UIBASE_INC_GOTODLG_HXX
+
+#include <vcl/dialog.hxx>
+
+class SwView;
+class SwWrtShell;
+
+class SwGotoPageDlg : public ModalDialog
+{
+public:
+ SwGotoPageDlg(vcl::Window *parent = nullptr, SfxBindings* _pBindings = nullptr);
+
+ virtual ~SwGotoPageDlg();
+ virtual void dispose() override;
+
+ sal_uInt16 GetPageSelection() const{
+ return (mpMtrPageCtrl->GetText()).toUInt32();}
+
+private:
+ SwView* GetCreateView() const;
+ sal_uInt16 GetPageInfo();
+
+ DECL_LINK_TYPED( PageModifiedHdl, Edit&, void );
+
+ VclPtr<Edit> mpMtrPageCtrl;
+ VclPtr<FixedText> mpPageNumberLbl;
+
+ SwView *m_pCreateView;
+ SfxBindings *m_rBindings;
+ sal_uInt16 mnMaxPageCnt;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi
index 065f072bf69f..27779439a342 100644
--- a/sw/sdi/_viewsh.sdi
+++ b/sw/sdi/_viewsh.sdi
@@ -62,7 +62,7 @@ interface BaseTextEditView
ExecMethod = Execute ;
StateMethod = GetState ;
]
- FN_NAVIGATION_PI_GOTO_PAGE // status(final|play)
+ FN_GOTO_PAGE // status(final|play)
[
ExecMethod = Execute ;
StateMethod = NoState ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index d4246d6be4ed..6c7aa8812ace 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -1840,7 +1840,7 @@ SfxBoolItem GotoNextWrongTableFormula FN_NEXT_TBLFML_ERR
GroupId = GID_NAVIGATOR;
]
-SfxVoidItem GotoPage FN_NAVIGATION_PI_GOTO_PAGE
+SfxVoidItem GotoPage FN_GOTO_PAGE
()
[
AutoUpdate = FALSE,
diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx
index 67911a5ee199..c08525a0f2d2 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -76,6 +76,7 @@
#include <swtypes.hxx>
#include <swwait.hxx>
#include <redlndlg.hxx>
+#include <gotodlg.hxx>
#include <view.hxx>
#include <uivwimp.hxx>
#include <docsh.hxx>
@@ -880,20 +881,11 @@ void SwView::Execute(SfxRequest &rReq)
}
}
break;
- case FN_NAVIGATION_PI_GOTO_PAGE:
+ case FN_GOTO_PAGE:
{
- SfxViewFrame* pVFrame = GetViewFrame();
- SfxChildWindow* pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
- if(!pCh)
- {
- pVFrame->ToggleChildWindow( SID_NAVIGATOR );
- pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
-
- }
- if (pCh)
- {
- static_cast<SwNavigationPI*>( pCh->GetContextWindow(SW_MOD()))->GotoPage();
- }
+ ScopedVclPtrInstance< SwGotoPageDlg > aDlg (&GetViewFrame()->GetWindow(), &GetViewFrame()->GetBindings());
+ if(aDlg->Execute() == RET_OK)
+ GetWrtShell().GotoPage((sal_uInt16)aDlg->GetPageSelection(), true);
}
break;
case FN_EDIT_CURRENT_TOX:
diff --git a/sw/source/uibase/utlui/gotodlg.cxx b/sw/source/uibase/utlui/gotodlg.cxx
new file mode 100644
index 000000000000..107d62a27daa
--- /dev/null
+++ b/sw/source/uibase/utlui/gotodlg.cxx
@@ -0,0 +1,116 @@
+/* -*- 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 <swmodule.hxx>
+#include <view.hxx>
+#include <wrtsh.hxx>
+#include <gotodlg.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <cmdid.h>
+
+using namespace com::sun::star;
+
+SwGotoPageDlg::SwGotoPageDlg( vcl::Window* pParent, SfxBindings* _pBindings):
+ ModalDialog(pParent, "GotoPageDialog", "modules/swriter/ui/gotopagedialog.ui"),
+ m_pCreateView(nullptr),
+ m_rBindings(_pBindings),
+ mnMaxPageCnt(1)
+{
+ get(mpMtrPageCtrl, "page");
+ get(mpPageNumberLbl, "page_count");
+
+ sal_uInt16 nTotalPage = GetPageInfo();
+
+ if(nTotalPage)
+ {
+ OUString sStr = mpPageNumberLbl->GetText();
+ mpPageNumberLbl->SetText(sStr.replaceFirst("$1", OUString::number(nTotalPage)));
+ mnMaxPageCnt = nTotalPage;
+ }
+ mpMtrPageCtrl->SetModifyHdl(LINK(this, SwGotoPageDlg, PageModifiedHdl));
+ mpMtrPageCtrl->SetCursorAtLast();
+}
+
+SwGotoPageDlg::~SwGotoPageDlg()
+{
+ disposeOnce();
+}
+
+void SwGotoPageDlg::dispose()
+{
+ mpMtrPageCtrl.clear();
+ mpPageNumberLbl.clear();
+
+ ModalDialog::dispose();
+}
+
+IMPL_LINK_NOARG_TYPED(SwGotoPageDlg, PageModifiedHdl, Edit&, void)
+{
+ if(!(mpMtrPageCtrl->GetText()).isEmpty() )
+ {
+ int page_value = (mpMtrPageCtrl->GetText()).toInt32();
+
+ if(page_value <= 0.0)
+ mpMtrPageCtrl->SetText(OUString::number(1));
+ else if(page_value > mnMaxPageCnt)
+ mpMtrPageCtrl->SetText(OUString::number(mnMaxPageCnt));
+
+ mpMtrPageCtrl->SetCursorAtLast();
+ }
+}
+
+SwView* SwGotoPageDlg::GetCreateView() const
+{
+ if(!m_pCreateView)
+ {
+ SwView* pView = SwModule::GetFirstView();
+ while(pView)
+ {
+ if(&pView->GetViewFrame()->GetBindings() == m_rBindings)
+ {
+ const_cast<SwGotoPageDlg*>(this)->m_pCreateView = pView;
+ break;
+ }
+ pView = SwModule::GetNextView(pView);
+ }
+ }
+
+ return m_pCreateView;
+}
+
+// If the page can be set here, the maximum is set.
+
+sal_uInt16 SwGotoPageDlg::GetPageInfo()
+{
+ SwView *pView = GetCreateView();
+ SwWrtShell *pSh = pView ? &pView->GetWrtShell() : nullptr;
+ mpMtrPageCtrl->SetText(OUString::number(1));
+ if (pSh)
+ {
+ const sal_uInt16 nPageCnt = pSh->GetPageCnt();
+ sal_uInt16 nPhyPage, nVirPage;
+ pSh->GetPageNum(nPhyPage, nVirPage);
+ mpMtrPageCtrl->SetText(OUString::number(nPhyPage));
+ return nPageCnt;
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/sw/uiconfig/swriter/ui/gotopagedialog.ui b/sw/uiconfig/swriter/ui/gotopagedialog.ui
new file mode 100644
index 000000000000..345d308e5664
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/gotopagedialog.ui
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+ <requires lib="gtk+" version="3.0"/>
+ <object class="GtkDialog" id="GotoPageDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="title" translatable="yes">Go to Page</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="label">gtk-help</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ <property name="secondary">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="ok">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="row_spacing">12</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="page_count">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">of $1</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="page">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="input_purpose">number</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="page_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Page:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">button1</action-widget>
+ <action-widget response="0">ok</action-widget>
+ <action-widget response="0">cancel</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkAdjustment" id="page_value">
+ <property name="lower">1</property>
+ <property name="upper">75</property>
+ <property name="value">1</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+</interface>