Kaydet (Commit) 1c39db58 authored tarafından Akshay Deep's avatar Akshay Deep Kaydeden (comit) Samuel Mehrbrodt

tdf#83054 Writer: Add "Go to Page" Entry in Edit Menu

Change-Id: I09026910687b019fe33d4016612b8247ff076100
Reviewed-on: https://gerrit.libreoffice.org/25949Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
üst 84059c85
......@@ -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 \
......
......@@ -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 \
......
......@@ -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)
......
/* -*- 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
......@@ -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 ;
......
......@@ -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,
......
......@@ -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:
......
/* -*- 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
<?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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment