diff options
-rw-r--r-- | sw/inc/cmdid.h | 5 | ||||
-rw-r--r-- | sw/inc/helpid.h | 2 | ||||
-rw-r--r-- | sw/inc/shellid.hxx | 1 | ||||
-rw-r--r-- | sw/sdi/_navsh.sdi | 49 | ||||
-rw-r--r-- | sw/sdi/makefile.mk | 2 | ||||
-rw-r--r-- | sw/sdi/navsh.sdi | 35 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 51 | ||||
-rw-r--r-- | sw/sdi/swslots.sdi | 2 | ||||
-rw-r--r-- | sw/source/ui/app/swmodule.cxx | 12 | ||||
-rw-r--r-- | sw/source/ui/inc/navmgr.hxx | 74 | ||||
-rw-r--r-- | sw/source/ui/inc/navsh.hxx | 51 | ||||
-rw-r--r-- | sw/source/ui/inc/shells.hrc | 4 | ||||
-rw-r--r-- | sw/source/ui/inc/view.hxx | 3 | ||||
-rw-r--r-- | sw/source/ui/inc/wrtsh.hxx | 17 | ||||
-rw-r--r-- | sw/source/ui/shells/makefile.mk | 1 | ||||
-rw-r--r-- | sw/source/ui/shells/navsh.cxx | 139 | ||||
-rw-r--r-- | sw/source/ui/shells/textsh1.cxx | 1 | ||||
-rw-r--r-- | sw/source/ui/uiview/view.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/uiview/view2.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/utlui/content.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/makefile.mk | 1 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/move.cxx | 92 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/navmgr.cxx | 224 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/wrtsh1.cxx | 11 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/wrtsh3.cxx | 1 | ||||
-rw-r--r-- | sw/uiconfig/swriter/toolbar/navigationobjectbar.xml | 6 |
26 files changed, 787 insertions, 10 deletions
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index c74c48403344..b88f7c63a424 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -861,6 +861,11 @@ included in c-context files, so c++ style stuff will cause problems. /* Edit Graphic with External Tool */ #define FN_EXTERNAL_EDIT (FN_EXTRA2 + 114) +/* Navigation buttons */ +#define FN_NAVIGATION_BACK (FN_EXTRA2 + 115) +#define FN_NAVIGATION_FORWARD (FN_EXTRA2 + 116) + + /*------------------------------------------------ -------------------- Area: Help -------------------------------------------------- ------------------*/ diff --git a/sw/inc/helpid.h b/sw/inc/helpid.h index 3eb2c7ada8e9..a880cd0d5cd3 100644 --- a/sw/inc/helpid.h +++ b/sw/inc/helpid.h @@ -984,4 +984,6 @@ #define HID_TITLEPAGE (HID_BASE + 2281) +#define HID_NAVIGATION_TOOLBOX (HID_BASE + 2282) + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/inc/shellid.hxx b/sw/inc/shellid.hxx index 16ba7ae00321..a8f247ef2a7d 100644 --- a/sw/inc/shellid.hxx +++ b/sw/inc/shellid.hxx @@ -71,6 +71,7 @@ #define SW_MEDIASHELL (SFX_INTERFACE_SW_START + 31) #define SW_ANNOTATIONSHELL (SFX_INTERFACE_SW_START + 32) +#define SW_NAVIGATIONSHELL (SFX_INTERFACE_SW_START + 33) #endif // _UIPARAM_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/sdi/_navsh.sdi b/sw/sdi/_navsh.sdi new file mode 100644 index 000000000000..6bd62d9b8188 --- /dev/null +++ b/sw/sdi/_navsh.sdi @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Initial Developer of the Original Code is + * [ Maja Djordjevic < ovcica@gmail.com > ] + * Portions created by the Initial Developer are Copyright (C) 2010 the + * Initial Developer. All Rights Reserved. + * + * Contributor(s): Cédric Bosdonnat <cbosdonnat@novell.com> + * Caolan McNamara <caolanm@redhat.com> + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +interface _Navigation +[ Automation = FALSE; ] +{ + SfxVoidItem NavigateBack FN_NAVIGATION_BACK + [ + ExecMethod = Execute ; + StateMethod = GetState; + DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; + ] + + SfxVoidItem NavigateForward FN_NAVIGATION_FORWARD + [ + ExecMethod = Execute ; + StateMethod = GetState; + DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; + ] + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/sdi/makefile.mk b/sw/sdi/makefile.mk index e539c7a05511..0cf3813d3fcf 100644 --- a/sw/sdi/makefile.mk +++ b/sw/sdi/makefile.mk @@ -96,6 +96,8 @@ SVSDI1DEPEND= \ mediash.sdi\ _annotsh.sdi\ annotsh.sdi\ + _navsh.sdi \ + navsh.sdi \ swslots.hrc \ $(INC)$/globals.hrc \ $(INC)$/cmdid.h diff --git a/sw/sdi/navsh.sdi b/sw/sdi/navsh.sdi new file mode 100644 index 000000000000..a81c4686ee2b --- /dev/null +++ b/sw/sdi/navsh.sdi @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Initial Developer of the Original Code is + * [ Maja Djordjevic < ovcica@gmail.com > ] + * Portions created by the Initial Developer are Copyright (C) 2010 the + * Initial Developer. All Rights Reserved. + * + * Contributor(s): Cédric Bosdonnat <cbosdonnat@novell.com> + * Caolan McNamara <caolanm@redhat.com> + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +shell SwNavigationShell +{ + import _Navigation[Automation]; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 081681e025b5..7caa1c5bf66c 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -10391,3 +10391,54 @@ SfxVoidItem CopyHyperlinkLocation FN_COPY_HYPERLINK_LOCATION ToolBoxConfig = TRUE, GroupId = GID_EDIT; ] + +//-------------------------------------------------------------------------- +SfxVoidItem NavigateBack FN_NAVIGATION_BACK +[ + /* flags: */ + AutoUpdate = TRUE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Asynchron; + + Readonly = FALSE, + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_NAVIGATION; +] +//-------------------------------------------------------------------------- +SfxVoidItem NavigateForward FN_NAVIGATION_FORWARD +[ + /* flags: */ + AutoUpdate = TRUE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Asynchron; + + Readonly = FALSE, + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_NAVIGATION; +] diff --git a/sw/sdi/swslots.sdi b/sw/sdi/swslots.sdi index 0b59ebb0c211..6730333f695f 100644 --- a/sw/sdi/swslots.sdi +++ b/sw/sdi/swslots.sdi @@ -120,6 +120,8 @@ ModulePrefix( "Sw" ) include "_annotsh.sdi" include "annotsh.sdi" + include "_navsh.sdi" + include "navsh.sdi" } diff --git a/sw/source/ui/app/swmodule.cxx b/sw/source/ui/app/swmodule.cxx index dc6e304847b8..307bd201ec25 100644 --- a/sw/source/ui/app/swmodule.cxx +++ b/sw/source/ui/app/swmodule.cxx @@ -44,7 +44,7 @@ #include <svx/insctrl.hxx> #include <svx/selctrl.hxx> #include <svx/linectrl.hxx> -#include <svx/tbxctl.hxx> //z-Zt falscher includeschutz! +#include <svx/tbxctl.hxx> //z-Zt falscher includeschutz! #include <svx/fillctrl.hxx> #include <svx/tbcontrl.hxx> #include <svx/verttexttbxctrl.hxx> @@ -135,11 +135,12 @@ #include <avmedia/mediatoolbox.hxx> #include <annotsh.hxx> +#include <navsh.hxx> #include <app.hrc> #include <svx/xmlsecctrl.hxx> ResMgr *pSwResMgr = 0; -sal_Bool bNoInterrupt = sal_False; +sal_Bool bNoInterrupt = sal_False; #include <sfx2/app.hxx> @@ -199,10 +200,10 @@ SwModule::SwModule( SfxObjectFactory* pWebFact, pStdFontConfig = new SwStdFontConfig; - pAuthorNames = new SvStringsDtor(5, 1); // Alle Redlining-Autoren + pAuthorNames = new SvStringsDtor(5, 1); // Alle Redlining-Autoren //JP 18.10.96: SvxAutocorrect gegen die SwAutocorrect austauschen - SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get(); + SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get(); if( pACfg ) { const SvxAutoCorrect* pOld = pACfg->GetAutoCorrect(); @@ -273,7 +274,7 @@ void SwDLL::RegisterFactories() if ( SvtModuleOptions().IsWriter() ) SwView::RegisterFactory ( 2 ); - SwWebView::RegisterFactory ( 5 ); + SwWebView::RegisterFactory ( 5 ); if ( SvtModuleOptions().IsWriter() ) { @@ -308,6 +309,7 @@ void SwDLL::RegisterInterfaces() SwBezierShell::RegisterInterface(pMod); SwGrfShell::RegisterInterface(pMod); SwOleShell::RegisterInterface(pMod); + SwNavigationShell::RegisterInterface(pMod); SwWebTextShell::RegisterInterface(pMod); SwWebFrameShell::RegisterInterface(pMod); SwWebGrfShell::RegisterInterface(pMod); diff --git a/sw/source/ui/inc/navmgr.hxx b/sw/source/ui/inc/navmgr.hxx new file mode 100644 index 000000000000..b2d35ae07eee --- /dev/null +++ b/sw/source/ui/inc/navmgr.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Initial Developer of the Original Code is + * [ Maja Djordjevic < ovcica@gmail.com > ] + * Portions created by the Initial Developer are Copyright (C) 2010 the + * Initial Developer. All Rights Reserved. + * + * Contributor(s): Cédric Bosdonnat <cbosdonnat@novell.com> + * Caolan McNamara <caolanm@redhat.com> + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ +#ifndef _NAVMGR_HXX +#define _NAVMGR_HXX + +#include "swtypes.hxx" +#include "pam.hxx" +#include "swdllapi.h" + +class SwWrtShell; +struct SwPosition; + +class SW_DLLPUBLIC SwNavigationMgr +{ +private: + /* + * List of entries in the navigation history + * Each entry is a SwPosition, which represents a position within the document + * SwPosition is given by a node index (SwNodeIndex) which usually represents the paragraph the position is in + * and an index (SwIndex), which represents the position inside this paragraph. + * You can find more on SwPositions at http://wiki.services.openoffice.org/wiki/Writer_Core_And_Layout + * + * The navigation history behaves as a stack, to which items are added when we jump to a new position + * (e.g. click a link, or double click an entry from the navigator). + * Every use of the back/forward buttons results in moving the stack pointer within the navigation history + */ + std::vector<SwPosition> _entries; + std::vector<SwPosition>::size_type _nCurrent; /* Current position within the navigation history */ + SwWrtShell* _pMyShell; /* The active shell within which the navigation occurs */ + + void GotoSwPosition(const SwPosition &rPos); + +public: + /* Constructor that initializes the shell to the current shell */ + SwNavigationMgr( SwWrtShell* pShell ); + /* Can we go back in the history ? */ + BOOL backEnabled() ; + /* Can we go forward in the history ? */ + BOOL forwardEnabled(); + /* The method that is called when we click the back button */ + void goBack() ; + /* The method that is called when we click the forward button */ + void goForward() ; + /* The method that adds the position pPos to the navigation history */ + bool addEntry(const SwPosition& rPos); +}; +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/inc/navsh.hxx b/sw/source/ui/inc/navsh.hxx new file mode 100644 index 000000000000..7c12ddc3b1cb --- /dev/null +++ b/sw/source/ui/inc/navsh.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Initial Developer of the Original Code is + * [ Maja Djordjevic < ovcica@gmail.com > ] + * Portions created by the Initial Developer are Copyright (C) 2010 the + * Initial Developer. All Rights Reserved. + * + * Contributor(s): Cédric Bosdonnat <cbosdonnat@novell.com> + * Caolan McNamara <caolanm@redhat.com> + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ +#ifndef _SWNAVIGATIONSH_HXX +#define _SWNAVIGATIONSH_HXX + +#include "frmsh.hxx" + +class SfxItemSet; +class SwWrtShell; + + + +class SwNavigationShell: public SwBaseShell +{ +public: + SFX_DECL_INTERFACE(SW_NAVIGATIONSHELL) + + SwNavigationShell(SwView &rView); + + void GetState(SfxItemSet &); + void Execute(SfxRequest &); +}; + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/inc/shells.hrc b/sw/source/ui/inc/shells.hrc index 2058b6432ed8..569dba2a05ac 100644 --- a/sw/source/ui/inc/shells.hrc +++ b/sw/source/ui/inc/shells.hrc @@ -102,7 +102,9 @@ #define RID_MEDIA_TOOLBOX (RC_SHELLS_BEGIN + 61) -#define SHELLS_ACT_END RID_MEDIA_TOOLBOX +#define STR_SHELLNAME_NAVIGATION (RC_SHELLS_BEGIN + 62) + +#define SHELLS_ACT_END STR_SHELLNAME_NAVIGATION #if SHELLS_ACT_END > RC_SHELLS_END #error Resource-Id Ueberlauf in #file, #line diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx index 6a5b63db7628..dcf6b094cd1f 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -130,7 +130,8 @@ enum ShellModes SHELL_MODE_MEDIA, SHELL_MODE_EXTRUDED_CUSTOMSHAPE, SHELL_MODE_FONTWORK, - SHELL_MODE_POSTIT + SHELL_MODE_POSTIT, + SHELL_MODE_NAVIGATION }; /*-------------------------------------------------------------------- diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx index d35f0246c9db..42be4412fe3a 100644 --- a/sw/source/ui/inc/wrtsh.hxx +++ b/sw/source/ui/inc/wrtsh.hxx @@ -34,6 +34,7 @@ #include <sortopt.hxx> #include <swurl.hxx> #include <IMark.hxx> +#include "navmgr.hxx" class Window; class OutputDevice; @@ -472,6 +473,21 @@ typedef BOOL (SwWrtShell:: *FNSimpleMove)(); String GetSelDescr() const; + SwNavigationMgr& GetNavigationMgr(); + void addCurrentPosition(); + BOOL GotoFly( const String& rName, FlyCntType eType = FLYCNTTYPE_ALL, + BOOL bSelFrame = TRUE ); + BOOL GotoINetAttr( const SwTxtINetFmt& rAttr ); + void GotoOutline( USHORT nIdx ); + BOOL GotoOutline( const String& rName ); + BOOL GotoRegion( const String& rName ); + BOOL GotoRefMark( const String& rRefMark, USHORT nSubType = 0, + USHORT nSeqNo = 0 ); + BOOL GotoNextTOXBase( const String* pName = 0); + BOOL GotoTable( const String& rName ); + BOOL GotoFld( const SwFmtFld& rFld ); + const SwRedline* GotoRedline( USHORT nArrPos, BOOL bSelect = FALSE); + private: SW_DLLPRIVATE void OpenMark(); @@ -528,6 +544,7 @@ private: } *pCrsrStack; SwView &rView; + SwNavigationMgr aNavigationMgr; Point aDest; BOOL bDestOnStack; diff --git a/sw/source/ui/shells/makefile.mk b/sw/source/ui/shells/makefile.mk index 36eb9b64b10a..26990e78913d 100644 --- a/sw/source/ui/shells/makefile.mk +++ b/sw/source/ui/shells/makefile.mk @@ -60,6 +60,7 @@ EXCEPTIONSFILES = \ $(SLO)$/grfshex.obj \ $(SLO)$/langhelper.obj \ $(SLO)$/listsh.obj \ + $(SLO)$/navsh.obj \ $(SLO)$/mediash.obj \ $(SLO)$/olesh.obj \ $(SLO)$/slotadd.obj \ diff --git a/sw/source/ui/shells/navsh.cxx b/sw/source/ui/shells/navsh.cxx new file mode 100644 index 000000000000..dd1935550902 --- /dev/null +++ b/sw/source/ui/shells/navsh.cxx @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Initial Developer of the Original Code is + * [ Maja Djordjevic < ovcica@gmail.com > ] + * Portions created by the Initial Developer are Copyright (C) 2010 the + * Initial Developer. All Rights Reserved. + * + * Contributor(s): Cédric Bosdonnat <cbosdonnat@novell.com> + * Caolan McNamara <caolanm@redhat.com> + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + + +#include "cmdid.h" +#include <svx/svdview.hxx> +#include <svx/srchitem.hxx> +#include <svl/eitem.hxx> +#include <svl/whiter.hxx> +#include <svx/svdopath.hxx> +#include <sfx2/request.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objface.hxx> + +#include "wrtsh.hxx" +#include "view.hxx" +#include "edtwin.hxx" +#include "helpid.h" +#include "globals.hrc" + +#include "navsh.hxx" + + +#include "popup.hrc" +#include "shells.hrc" +#define SwNavigationShell +#include "swslots.hxx" + +#include <unomid.h> + +#include "navmgr.hxx" + + +SFX_IMPL_INTERFACE(SwNavigationShell, SwBaseShell, SW_RES(STR_SHELLNAME_NAVIGATION)) +{ +} + +SwNavigationShell::SwNavigationShell(SwView &_rView): + SwBaseShell( _rView ) + +{ + SetName(C2S("Navigation")); + SetHelpId(SW_NAVIGATIONSHELL); +} + +void SwNavigationShell::Execute(SfxRequest &rReq) +{ + SwWrtShell *pSh = &GetShell(); + SdrView* pSdrView = pSh->GetDrawView(); + const SfxItemSet *pArgs = rReq.GetArgs(); + USHORT nSlotId = rReq.GetSlot(); + BOOL bChanged = pSdrView->GetModel()->IsChanged(); + pSdrView->GetModel()->SetChanged(FALSE); + SwNavigationMgr& aSwNavigationMgr = pSh->GetNavigationMgr(); + const SfxPoolItem* pItem; + if(pArgs) + pArgs->GetItemState(nSlotId, FALSE, &pItem); + switch (nSlotId) + { + case FN_NAVIGATION_BACK: + aSwNavigationMgr.goBack(); + break; + + case FN_NAVIGATION_FORWARD: + aSwNavigationMgr.goForward(); + break; + default: + break; + } + if (pSdrView->GetModel()->IsChanged()) + GetShell().SetModified(); + else if (bChanged) + pSdrView->GetModel()->SetChanged(TRUE); +} + +/*-------------------------------------------------------------------- + determine if the buttons should be enabled/disabled + --------------------------------------------------------------------*/ + + +void SwNavigationShell::GetState(SfxItemSet &rSet) +{ + SwWrtShell *pSh = &GetShell(); + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + SwNavigationMgr& aNavigationMgr = pSh->GetNavigationMgr(); + while( nWhich ) + { + switch( nWhich ) + { + case FN_NAVIGATION_BACK: + { + if (!aNavigationMgr.backEnabled()) { + rSet.DisableItem(FN_NAVIGATION_BACK); + } + } + break; + case FN_NAVIGATION_FORWARD: + { + if (!aNavigationMgr.forwardEnabled()) + rSet.DisableItem(FN_NAVIGATION_FORWARD); + } + break; + default: + break; + } + nWhich = aIter.NextWhich(); + } +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx index 15fb6cdedb06..2fea559cecd3 100644 --- a/sw/source/ui/shells/textsh1.cxx +++ b/sw/source/ui/shells/textsh1.cxx @@ -1696,6 +1696,7 @@ void SwTextShell::ChangeHeaderOrFooter( const String& rStyleName, BOOL bHeader, BOOL bOn, BOOL bShowWarning) { SwWrtShell& rSh = GetShell(); + rSh.addCurrentPosition(); rSh.StartAllAction(); rSh.StartUndo( UNDO_HEADER_FOOTER ); // #i7983# BOOL bExecute = TRUE; diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx index 2157f74d9b42..90fa616a19b7 100644 --- a/sw/source/ui/uiview/view.cxx +++ b/sw/source/ui/uiview/view.cxx @@ -73,6 +73,7 @@ #include <drformsh.hxx> #include <drwtxtsh.hxx> #include <beziersh.hxx> +#include <navsh.hxx> #include <globdoc.hxx> #include <scroll.hxx> #include <globdoc.hxx> @@ -320,6 +321,10 @@ void SwView::SelectShell() if ( !( nSelectionType & nsSelectionType::SEL_FOC_FRM_CTRL ) ) rDispatcher.Push( *pFormShell ); + eShellMode = SHELL_MODE_NAVIGATION; + pShell = new SwNavigationShell( *this ); + rDispatcher.Push( *pShell ); + if ( nSelectionType & nsSelectionType::SEL_OLE ) { eShellMode = SHELL_MODE_OBJECT; diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index c3aa03c74dcb..752816d3edf2 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -1840,8 +1840,10 @@ BOOL SwView::JumpToSwMark( const String& rMark ) } else if( pMarkAccess->getMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)) ) pWrtShell->GotoMark( ppMark->get(), FALSE, TRUE ), bRet = TRUE; - else if( 0 != ( pINet = pWrtShell->FindINetAttr( sMark ) )) + else if( 0 != ( pINet = pWrtShell->FindINetAttr( sMark ) )) { + pWrtShell->addCurrentPosition(); bRet = pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() ); + } // fuer alle Arten von Flys if( FLYCNTTYPE_ALL != eFlyType && pWrtShell->GotoFly( sName, eFlyType )) diff --git a/sw/source/ui/utlui/content.cxx b/sw/source/ui/utlui/content.cxx index c7ad691c5415..94d4408578f6 100644 --- a/sw/source/ui/utlui/content.cxx +++ b/sw/source/ui/utlui/content.cxx @@ -97,6 +97,8 @@ #include "globals.hrc" #include <unomid.h> +#include "navmgr.hxx" + #define CTYPE_CNT 0 #define CTYPE_CTT 1 @@ -3061,6 +3063,7 @@ void SwContentTree::GotoContent(SwContent* pCnt) break; case CONTENT_TYPE_DRAWOBJECT: { + SwPosition aPos = *pActiveShell->GetCrsr()->GetPoint(); SdrView* pDrawView = pActiveShell->GetDrawView(); if (pDrawView) { @@ -3082,6 +3085,7 @@ void SwContentTree::GotoContent(SwContent* pCnt) } } } + pActiveShell->GetNavigationMgr().addEntry(aPos); } } break; diff --git a/sw/source/ui/wrtsh/makefile.mk b/sw/source/ui/wrtsh/makefile.mk index d650e7ba3051..84ce030afbbe 100644 --- a/sw/source/ui/wrtsh/makefile.mk +++ b/sw/source/ui/wrtsh/makefile.mk @@ -48,6 +48,7 @@ SLOFILES = \ EXCEPTIONSFILES = \ $(SLO)$/delete.obj \ $(SLO)$/move.obj \ + $(SLO)$/navmgr.obj \ $(SLO)$/select.obj \ $(SLO)$/wrtsh1.obj \ $(SLO)$/wrtsh2.obj \ diff --git a/sw/source/ui/wrtsh/move.cxx b/sw/source/ui/wrtsh/move.cxx index 02d02693604d..513da4a2fdcb 100644 --- a/sw/source/ui/wrtsh/move.cxx +++ b/sw/source/ui/wrtsh/move.cxx @@ -668,7 +668,97 @@ BOOL SwWrtShell::GotoPage(USHORT nPage, BOOL bRecord) BOOL SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark, BOOL bSelect, BOOL bStart ) { ShellMoveCrsr aTmp( this, bSelect ); - return SwCrsrShell::GotoMark( pMark, bStart ); + SwPosition aPos = *GetCrsr()->GetPoint(); + bool bRet = SwCrsrShell::GotoMark( pMark, bStart ); + if (bRet) + aNavigationMgr.addEntry(aPos); + return bRet; +} + +BOOL SwWrtShell::GotoFly( const String& rName, FlyCntType eType, BOOL bSelFrame ) +{ + SwPosition aPos = *GetCrsr()->GetPoint(); + bool bRet = SwFEShell::GotoFly(rName, eType, bSelFrame); + if (bRet) + aNavigationMgr.addEntry(aPos); + return bRet; +} + +BOOL SwWrtShell::GotoINetAttr( const SwTxtINetFmt& rAttr ) +{ + SwPosition aPos = *GetCrsr()->GetPoint(); + bool bRet = SwCrsrShell::GotoINetAttr(rAttr); + if (bRet) + aNavigationMgr.addEntry(aPos); + return bRet; +} + +void SwWrtShell::GotoOutline( USHORT nIdx ) +{ + addCurrentPosition(); + return SwCrsrShell::GotoOutline (nIdx); +} + +BOOL SwWrtShell::GotoOutline( const String& rName ) +{ + SwPosition aPos = *GetCrsr()->GetPoint(); + bool bRet = SwCrsrShell::GotoOutline (rName); + if (bRet) + aNavigationMgr.addEntry(aPos); + return bRet; +} + +BOOL SwWrtShell::GotoRegion( const String& rName ) +{ + SwPosition aPos = *GetCrsr()->GetPoint(); + bool bRet = SwCrsrShell::GotoRegion (rName); + if (bRet) + aNavigationMgr.addEntry(aPos); + return bRet; + } + +BOOL SwWrtShell::GotoRefMark( const String& rRefMark, USHORT nSubType, + USHORT nSeqNo ) +{ + SwPosition aPos = *GetCrsr()->GetPoint(); + bool bRet = SwCrsrShell::GotoRefMark(rRefMark, nSubType, nSeqNo); + if (bRet) + aNavigationMgr.addEntry(aPos); + return bRet; +} + +BOOL SwWrtShell::GotoNextTOXBase( const String* pName ) +{ + SwPosition aPos = *GetCrsr()->GetPoint(); + bool bRet = SwCrsrShell::GotoNextTOXBase(pName); + if (bRet) + aNavigationMgr.addEntry(aPos); + return bRet; +} + +BOOL SwWrtShell::GotoTable( const String& rName ) +{ + SwPosition aPos = *GetCrsr()->GetPoint(); + bool bRet = SwCrsrShell::GotoTable(rName); + if (bRet) + aNavigationMgr.addEntry(aPos); + return bRet; +} + +BOOL SwWrtShell::GotoFld( const SwFmtFld& rFld ) { + SwPosition aPos = *GetCrsr()->GetPoint(); + bool bRet = SwCrsrShell::GotoFld(rFld); + if (bRet) + aNavigationMgr.addEntry(aPos); + return bRet; +} + +const SwRedline* SwWrtShell::GotoRedline( USHORT nArrPos, BOOL bSelect ) { + SwPosition aPos = *GetCrsr()->GetPoint(); + const SwRedline *pRedline = SwCrsrShell::GotoRedline(nArrPos, bSelect); + if (pRedline) + aNavigationMgr.addEntry(aPos); + return pRedline; } diff --git a/sw/source/ui/wrtsh/navmgr.cxx b/sw/source/ui/wrtsh/navmgr.cxx new file mode 100644 index 000000000000..a56bf5df0782 --- /dev/null +++ b/sw/source/ui/wrtsh/navmgr.cxx @@ -0,0 +1,224 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Initial Developer of the Original Code is + * [ Maja Djordjevic < ovcica@gmail.com > ] + * Portions created by the Initial Developer are Copyright (C) 2010 the + * Initial Developer. All Rights Reserved. + * + * Contributor(s): Cédric Bosdonnat <cbosdonnat@novell.com> + * Caolan McNamara <caolanm@redhat.com> + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ +#include "precompiled_sw.hxx" + +#include "navmgr.hxx" +#include "wrtsh.hxx" +#include <sfx2/bindings.hxx> +#include <sfx2/viewfrm.hxx> +#include <cmdid.h> +#include <view.hxx> + +/** + * If SMART is defined, the navigation history has recency with temporal ordering enhancement, + * as described on http://zing.ncsl.nist.gov/hfweb/proceedings/greenberg/ + */ +#define SMART 1 + +/* + * This method positions the cursor to the position rPos + */ +void SwNavigationMgr::GotoSwPosition(const SwPosition &rPos) { + SwWrtShell& rSh = *_pMyShell; + /* EnterStdMode() prevents the cursor to 'block' the current shell when it should move from the image back to the normal shell */ + rSh.EnterStdMode(); + rSh.StartAllAction(); + /* + * cursor consists of two SwPositions: Point and Mark. + * Such a pair is called a PaM. SwPaM is derived from SwRing. + * The Ring contains the single regions of a multi-selection. + */ + SwPaM* pPaM = rSh.GetCrsr(); + + if(pPaM->HasMark()) + pPaM->DeleteMark(); // If there was a selection, get rid of it + *pPaM->GetPoint() = rPos; // Position Cursor + + rSh.EndAllAction(); +} +/* + * Ctor for the SwNavigationMgr class + * Sets the shell to the current shell + * and the index of the current position to 0 + */ + +SwNavigationMgr::SwNavigationMgr(SwWrtShell* pShell) + : _nCurrent(0), _pMyShell(pShell) { +} +/* + * This method is used by the navigation shell - defined in sw/source/ui/inc/navsh.hxx + * and implemented in sw/source/ui/shells/navsh.cxx + * It is called when we want to check if the back button should be enabled or not. + * The back button should be enabled only if there are some entries in the navigation history + */ +BOOL SwNavigationMgr::backEnabled() { + return (_nCurrent > 0); +} +/* + * Similar to backEnabled() method. + * The forward button should be enabled if we ever clicked back + * Due to the implementation of the navigation class, this is when the + * current position within the navigation history entries in not the last one + * i.e. when the _nCurrent index is not at the end of the _entries vector + */ +BOOL SwNavigationMgr::forwardEnabled() { + return _nCurrent+1 < _entries.size(); +} + + +/* + * The goBack() method positions the cursor to the previous entry in the navigation history + * If there was no history to go forward to, it adds the current position of the cursor + * to the history so we could go forward to where we came from + */ +void SwNavigationMgr::goBack() { + /* + * Although the button should be disabled whenever the backEnabled() returns false, + * the UI is sometimes not as responsive as we would like it to be :) + * this check prevents segmentation faults and in this way the class is not relying on the UI + */ + if (backEnabled()) { + SwWrtShell& rSh = *_pMyShell; + /* Trying to get the current cursor */ + SwPaM* pPaM = rSh.GetCrsr(); + if (!pPaM) { + return; + } + + /* This flag will be used to manually refresh the buttons */ + bool bForwardWasDisabled = !forwardEnabled(); + /* + * If we're going backwards in our history, but the current location is not + * in the history then we need to add *here* to it so that we can "go + * forward" to here again. + */ + + if (bForwardWasDisabled) { + /* + * the cursor consists of two SwPositions: Point and Mark. + * We are adding the current Point to the navigation history + * so we could later navigate forward to it + */ + /* The addEntry() method returns true iff we should decrement the index before navigating back */ + if (addEntry(*pPaM->GetPoint()) ) { + _nCurrent--; + } + } + _nCurrent--; + /* Position cursor to appropriate navigation history entry */ + GotoSwPosition(_entries[_nCurrent]); + /* Refresh the buttons */ + if (bForwardWasDisabled) + _pMyShell->GetView().GetViewFrame()->GetBindings().Invalidate(FN_NAVIGATION_FORWARD); + if (!backEnabled()) + _pMyShell->GetView().GetViewFrame()->GetBindings().Invalidate(FN_NAVIGATION_BACK); + } +} +/* + * The goForward() method positions the cursor to the next entry in the navigation history + */ + +void SwNavigationMgr::goForward() { + /* + * Although the button should be disabled whenever the backForward() returns false, + * the UI is sometimes not as responsive as we would like it to be :) + * this check prevents segmentation faults and in this way the class is not relying on the UI + */ + + if (forwardEnabled()) { + /* This flag will be used to manually refresh the buttons */ + bool bBackWasDisabled = !backEnabled(); + /* + * The current index is positioned at the current entry in the navigation history + * We have to increment it to go to the next entry + */ + _nCurrent++; + GotoSwPosition(_entries[_nCurrent]); + /* Refresh the buttons */ + if (bBackWasDisabled) + _pMyShell->GetView().GetViewFrame()->GetBindings().Invalidate(FN_NAVIGATION_BACK); + if (!forwardEnabled()) + _pMyShell->GetView().GetViewFrame()->GetBindings().Invalidate(FN_NAVIGATION_FORWARD); + } +} +/* + * This method adds the SwPosition rPos to the navigation history + * rPos is usually the current position of the cursor in the document + */ +bool SwNavigationMgr::addEntry(const SwPosition& rPos) { + /* Flags that will be used for refreshing the buttons */ + bool bBackWasDisabled = !backEnabled(); + bool bForwardWasEnabled = forwardEnabled(); + + bool bRet = false; // return value of the function. + // Indicates weather the index should be decremented before jumping back or not +#if SMART + /* If any forward history exists, twist the tail of the list from the current position to the end */ + if (bForwardWasEnabled) { + + size_t number_of_entries = _entries.size(); /* To avoid calling _entries.size() multiple times */ + int curr = _nCurrent; /* Index from which we'll twist the tail. */ + int n = (number_of_entries - curr) / 2; /* Number of entries that will swap places */ + for (int i = 0; i < n; i++) { + SwPosition temp = _entries[curr + i]; + _entries[curr + i] = _entries[number_of_entries -1 - i]; + _entries[number_of_entries -1 - i] = temp; + } + + if (_entries.back() != rPos) + _entries.push_back(rPos); + + + bRet = true; + } + else { + if ( (_entries.size() > 0 && _entries.back() != rPos) || (_entries.size() == 0) ) { + _entries.push_back(rPos); + bRet = true; + } + if (_entries.size() > 1 && _entries.back() == rPos) + bRet = true; + if (_entries.size() == 1 && _entries.back() == rPos) + bRet = false; + } +#else + _entries.erase(_entries.begin() + _nCurrent, _entries.end()); + _entries.push_back(rPos); + bRet = true; +#endif + _nCurrent = _entries.size(); + + /* Refresh buttons */ + if (bBackWasDisabled) + _pMyShell->GetView().GetViewFrame()->GetBindings().Invalidate(FN_NAVIGATION_BACK); + if (bForwardWasEnabled) + _pMyShell->GetView().GetViewFrame()->GetBindings().Invalidate(FN_NAVIGATION_FORWARD); + return bRet; +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx index 7e74d6eff6ba..83f19768bfc8 100644 --- a/sw/source/ui/wrtsh/wrtsh1.cxx +++ b/sw/source/ui/wrtsh/wrtsh1.cxx @@ -122,6 +122,7 @@ using namespace com::sun::star; ePageMove(MV_NO),\ pCrsrStack(0), \ rView(rShell),\ + aNavigationMgr(this), \ bDestOnStack(FALSE), \ fnLeaveSelect(&SwWrtShell::SttLeaveSelect) @@ -984,7 +985,7 @@ void SwWrtShell::InsertFootnote(const String &rStr, BOOL bEndNote, BOOL bEdit ) SwapPam(); ClearMark(); } - + SwPosition aPos = *GetCrsr()->GetPoint(); SwFmtFtn aFootNote( bEndNote ); if(rStr.Len()) aFootNote.SetNumStr( rStr ); @@ -997,6 +998,7 @@ void SwWrtShell::InsertFootnote(const String &rStr, BOOL bEndNote, BOOL bEdit ) Left(CRSR_SKIP_CHARS, FALSE, 1, FALSE ); GotoFtnTxt(); } + aNavigationMgr.addEntry(aPos); } } /*------------------------------------------------------------------------ @@ -1562,7 +1564,14 @@ SwFrmFmt *SwWrtShell::GetTblStyle(const String &rFmtName) return 0; } +SwNavigationMgr& SwWrtShell::GetNavigationMgr() { + return aNavigationMgr; +} +void SwWrtShell::addCurrentPosition() { + SwPaM* pPaM = GetCrsr(); + aNavigationMgr.addEntry(*pPaM->GetPoint()); +} /*------------------------------------------------------------------------ Beschreibung: Anwenden der Vorlagen ------------------------------------------------------------------------*/ diff --git a/sw/source/ui/wrtsh/wrtsh3.cxx b/sw/source/ui/wrtsh/wrtsh3.cxx index d134f5a3248b..31d4518be78e 100644 --- a/sw/source/ui/wrtsh/wrtsh3.cxx +++ b/sw/source/ui/wrtsh/wrtsh3.cxx @@ -58,6 +58,7 @@ extern sal_Bool bNoInterrupt; // in mainwn.cxx BOOL SwWrtShell::MoveBookMark( BookMarkMove eFuncId, const ::sw::mark::IMark* const pMark) { + addCurrentPosition(); (this->*fnKillSel)( 0, sal_False ); BOOL bRet = sal_True; diff --git a/sw/uiconfig/swriter/toolbar/navigationobjectbar.xml b/sw/uiconfig/swriter/toolbar/navigationobjectbar.xml new file mode 100644 index 000000000000..6cea7c3ca49c --- /dev/null +++ b/sw/uiconfig/swriter/toolbar/navigationobjectbar.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd"> +<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar"> + <toolbar:toolbaritem xlink:href=".uno:NavigateBack" toolbar:helpid="helpid:22314"/> + <toolbar:toolbaritem xlink:href=".uno:NavigateForward" toolbar:helpid="helpid:22315"/> +</toolbar:toolbar> |