From 5b17d2d731e014d79cbba716fcbc8fbd357094e8 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Wed, 23 May 2012 12:04:06 -0400 Subject: Pass document service to the dispatcher when opening file from writer. This is similar to what I did earlier for calc. This info will be used later in the type detection code. Change-Id: I7ba7dcdc03cbfe77eba5c7594fc0385ad3775541 --- .../org/openoffice/Office/UI/WriterCommands.xcu | 5 +++++ sw/sdi/docsh.sdi | 5 +++++ sw/sdi/swriter.sdi | 25 ++++++++++++++++++++++ sw/source/ui/app/docsh.cxx | 5 +++++ sw/source/ui/app/docsh2.cxx | 16 ++++++++++++++ sw/uiconfig/swriter/menubar/menubar.xml | 2 +- 6 files changed, 57 insertions(+), 1 deletion(-) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu index 9153d94aff26..31a686735d7c 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu @@ -2212,6 +2212,11 @@ 8 + + + ~Open... + + diff --git a/sw/sdi/docsh.sdi b/sw/sdi/docsh.sdi index 5925edd7528c..ddca15e5750b 100644 --- a/sw/sdi/docsh.sdi +++ b/sw/sdi/docsh.sdi @@ -63,6 +63,11 @@ interface TextDocument : BaseTextDocument ExecMethod = Execute; StateMethod = GetState; ] + FN_OPEN_FILE + [ + ExecMethod = Execute; + StateMethod = GetState; + ] } shell SwDocShell diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index d7cb8b3b3bbb..edb780916471 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -10417,3 +10417,28 @@ SfxVoidItem NavigateForward FN_NAVIGATION_FORWARD ToolBoxConfig = TRUE, GroupId = GID_NAVIGATION; ] + +//-------------------------------------------------------------------------- +SfxVoidItem OpenFromWriter FN_OPEN_FILE +() +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_APPLICATION; +] diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx index cf1d32762947..c5f633d50508 100644 --- a/sw/source/ui/app/docsh.cxx +++ b/sw/source/ui/app/docsh.cxx @@ -1035,6 +1035,11 @@ void SwDocShell::GetState(SfxItemSet& rSet) rSet.DisableItem( nWhich ); break; + case FN_OPEN_FILE: + if( ISA( SwWebDocShell ) ) + rSet.DisableItem( nWhich ); + break; + case SID_ATTR_YEAR2000: { const SvNumberFormatter* pFmtr = pDoc->GetNumberFormatter(sal_False); diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index 54d39f910c85..24b4c9d20922 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -1427,6 +1427,22 @@ void SwDocShell::Execute(SfxRequest& rReq) pDoc->GetNumberFormatter(sal_True)->SetYear2000(nYear2K); } break; + case FN_OPEN_FILE: + { + SfxViewShell* pViewShell = GetView(); + if (!pViewShell) + pViewShell = SfxViewShell::Current(); + + if (!pViewShell) + // Ok. I did my best. + break; + + SfxStringItem aApp(SID_DOC_SERVICE, rtl::OUString("com.sun.star.text.TextDocument")); + SfxStringItem aTarget(SID_TARGETNAME, rtl::OUString("_blank")); + pViewShell->GetDispatcher()->Execute( + SID_OPENDOC, SFX_CALLMODE_API|SFX_CALLMODE_SYNCHRON, &aApp, &aTarget, 0L); + } + break; default: OSL_FAIL("wrong Dispatcher"); } diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml index 206af98a1e6d..b0f707646712 100644 --- a/sw/uiconfig/swriter/menubar/menubar.xml +++ b/sw/uiconfig/swriter/menubar/menubar.xml @@ -3,7 +3,7 @@ - + -- cgit