summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorSzymon Kłos <eszkadev@gmail.com>2015-05-19 21:32:05 +0200
committerAndras Timar <andras.timar@collabora.com>2015-10-18 23:48:59 +0200
commitbf86643b3e71519ae20620fb816b04bba2d99bdb (patch)
treef37b8afc6cd27407bc8738f6599e0c2201c120bc /framework
parent6cc58b9fa7ed6b5781963427df47b03417f17973 (diff)
RemoteFilesDialog
Change-Id: I296ce6233287dac5447462faa4b7404c25297f8b (cherry picked from commit 87297284782adbf1fcb73663ad2d2a38b5ae1872)
Diffstat (limited to 'framework')
-rw-r--r--framework/Library_fwk.mk1
-rw-r--r--framework/inc/classes/resource.hrc3
-rw-r--r--framework/source/classes/resource.src15
-rw-r--r--framework/source/fwe/helper/titlehelper.cxx13
-rw-r--r--framework/source/uielement/recentfilesmenucontroller.cxx20
-rw-r--r--framework/source/uielement/saveasmenucontroller.cxx192
-rw-r--r--framework/util/fwk.component4
7 files changed, 248 insertions, 0 deletions
diff --git a/framework/Library_fwk.mk b/framework/Library_fwk.mk
index 74e72a9cf136..b47d2ada9264 100644
--- a/framework/Library_fwk.mk
+++ b/framework/Library_fwk.mk
@@ -144,6 +144,7 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\
framework/source/uielement/popuptoolbarcontroller \
framework/source/uielement/progressbarwrapper \
framework/source/uielement/recentfilesmenucontroller \
+ framework/source/uielement/saveasmenucontroller \
framework/source/uielement/spinfieldtoolbarcontroller \
framework/source/uielement/statusbar \
framework/source/uielement/statusbaritem \
diff --git a/framework/inc/classes/resource.hrc b/framework/inc/classes/resource.hrc
index 8d2337156bfb..c7fc3946aa78 100644
--- a/framework/inc/classes/resource.hrc
+++ b/framework/inc/classes/resource.hrc
@@ -50,6 +50,9 @@
#define STR_CLEAR_RECENT_FILES (RID_STR_START+23)
#define STR_CLEAR_RECENT_FILES_HELP (RID_STR_START+24)
#define STR_LANGSTATUS_HINT (RID_STR_START+25)
+#define STR_OPEN_REMOTE (RID_STR_START+26)
+#define STR_REMOTE_FILE (RID_STR_START+27)
+#define STR_REMOTE_TITLE (RID_STR_START+28)
#define POPUPMENU_TOOLBAR_QUICKCUSTOMIZATION (RID_MENU_START+0)
diff --git a/framework/source/classes/resource.src b/framework/source/classes/resource.src
index c54eaa327265..570e2884b713 100644
--- a/framework/source/classes/resource.src
+++ b/framework/source/classes/resource.src
@@ -114,6 +114,21 @@ String STR_CLEAR_RECENT_FILES_HELP
Text [ en-US ] = "Clears the list with the most recently opened files. This action can not be undone.";
};
+String STR_OPEN_REMOTE
+{
+ Text [ en-US ] = "Open remote file";
+};
+
+String STR_REMOTE_FILE
+{
+ Text [ en-US ] = "Save Remote File...";
+};
+
+String STR_REMOTE_TITLE
+{
+ Text [ en-US ] = " (Remote)";
+};
+
String STR_TOOLBAR_TITLE_ADDON
{
Text [ en-US ] = "Add-On %num%";
diff --git a/framework/source/fwe/helper/titlehelper.cxx b/framework/source/fwe/helper/titlehelper.cxx
index d8c44d37b74b..64d547ee4fd6 100644
--- a/framework/source/fwe/helper/titlehelper.cxx
+++ b/framework/source/fwe/helper/titlehelper.cxx
@@ -18,6 +18,8 @@
*/
#include <framework/titlehelper.hxx>
+#include <classes/fwkresid.hxx>
+#include <classes/resource.hrc>
#include <services.h>
#include <properties.h>
@@ -409,6 +411,7 @@ void TitleHelper::impl_updateTitleForController (const css::uno::Reference< css:
nLeasedNumber = xNumbers->leaseNumber (xOwner);
css::uno::Reference< css::frame::XTitle > xModelTitle(xController->getModel (), css::uno::UNO_QUERY);
+ css::uno::Reference< css::frame::XModel > xModel(xController->getModel (), css::uno::UNO_QUERY);
if (!xModelTitle.is ())
xModelTitle.set(xController, css::uno::UNO_QUERY);
if (xModelTitle.is ())
@@ -419,6 +422,16 @@ void TitleHelper::impl_updateTitleForController (const css::uno::Reference< css:
sTitle.appendAscii (" : ");
sTitle.append ((::sal_Int32)nLeasedNumber);
}
+ if (xModel.is ())
+ {
+ INetURLObject aURL (xModel->getURL ());
+ if (aURL.GetProtocol () != INetProtocol::File
+ && aURL.GetProtocol () != INetProtocol::NotValid)
+ {
+ OUString sRemoteText (FwkResId (STR_REMOTE_TITLE));
+ sTitle.append (sRemoteText);
+ }
+ }
}
else
{
diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx
index 1ea02d21dc63..9ea96216206d 100644
--- a/framework/source/uielement/recentfilesmenucontroller.cxx
+++ b/framework/source/uielement/recentfilesmenucontroller.cxx
@@ -44,6 +44,7 @@ using namespace framework;
namespace {
static const char CMD_CLEAR_LIST[] = ".uno:ClearRecentFileList";
+static const char CMD_OPEN_REMOTE[] = ".uno:OpenRemote";
static const char CMD_PREFIX[] = "vnd.sun.star.popup:RecentFileList?entry=";
static const char MENU_SHORTCUT[] = "~N. ";
@@ -224,6 +225,12 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
OUString( CMD_CLEAR_LIST ) );
pVCLPopupMenu->SetHelpText( sal_uInt16( nCount + 1 ),
FWK_RESSTR(STR_CLEAR_RECENT_FILES_HELP) );
+
+ // Open remote menu entry
+ pVCLPopupMenu->InsertItem( sal_uInt16( nCount + 2 ),
+ FWK_RESSTR(STR_OPEN_REMOTE) );
+ pVCLPopupMenu->SetItemCommand( sal_uInt16( nCount + 2 ),
+ OUString( CMD_OPEN_REMOTE ) );
}
else
{
@@ -232,6 +239,14 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >
// Do not disable it, otherwise the Toolbar controller and MenuButton
// will display SV_RESID_STRING_NOSELECTIONPOSSIBLE instead of STR_NODOCUMENT
pVCLPopupMenu->SetItemBits( 1, pVCLPopupMenu->GetItemBits( 1 ) | MenuItemBits::NOSELECT );
+
+ pVCLPopupMenu->InsertSeparator();
+
+ // Open remote menu entry
+ pVCLPopupMenu->InsertItem( sal_uInt16( 2 ),
+ FWK_RESSTR(STR_OPEN_REMOTE) );
+ pVCLPopupMenu->SetItemCommand( sal_uInt16( 2 ),
+ OUString( CMD_OPEN_REMOTE ) );
}
}
}
@@ -331,6 +346,11 @@ void SAL_CALL RecentFilesMenuController::itemSelected( const css::awt::MenuEvent
"vnd.org.libreoffice.recentdocs:ClearRecentFileList",
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >() );
}
+ else if ( aCommand == CMD_OPEN_REMOTE )
+ {
+ Sequence< PropertyValue > aArgsList( 0 );
+ dispatchCommand( CMD_OPEN_REMOTE, aArgsList );
+ }
else
executeEntry( rEvent.MenuId-1 );
}
diff --git a/framework/source/uielement/saveasmenucontroller.cxx b/framework/source/uielement/saveasmenucontroller.cxx
new file mode 100644
index 000000000000..646001397ba7
--- /dev/null
+++ b/framework/source/uielement/saveasmenucontroller.cxx
@@ -0,0 +1,192 @@
+/* -*- 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 <classes/resource.hrc>
+#include <classes/fwkresid.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <osl/file.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/ref.hxx>
+#include <svtools/popupmenucontrollerbase.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/historyoptions.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace css;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::frame;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::util;
+using namespace framework;
+
+namespace {
+
+static const char CMD_SAVE_REMOTE[] = ".uno:SaveAsRemote";
+
+class SaveAsMenuController : public svt::PopupMenuControllerBase
+{
+ using svt::PopupMenuControllerBase::disposing;
+
+public:
+ SaveAsMenuController( const uno::Reference< uno::XComponentContext >& xContext );
+ virtual ~SaveAsMenuController();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
+ {
+ return OUString("com.sun.star.comp.framework.SaveAsMenuController");
+ }
+
+ virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
+ throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
+ {
+ return cppu::supportsService(this, ServiceName);
+ }
+
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
+ throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
+ {
+ css::uno::Sequence< OUString > aSeq(1);
+ aSeq[0] = "com.sun.star.frame.PopupMenuController";
+ return aSeq;
+ }
+
+ // XStatusListener
+ virtual void SAL_CALL statusChanged( const frame::FeatureStateEvent& Event ) throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
+
+ // XMenuListener
+ virtual void SAL_CALL itemSelected( const awt::MenuEvent& rEvent ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual void SAL_CALL itemActivated( const awt::MenuEvent& rEvent ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( uno::RuntimeException, std::exception ) SAL_OVERRIDE;
+
+private:
+ virtual void impl_setPopupMenu() SAL_OVERRIDE;
+
+ void fillPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu );
+
+ bool m_bDisabled : 1;
+};
+
+SaveAsMenuController::SaveAsMenuController( const uno::Reference< uno::XComponentContext >& xContext ) :
+ svt::PopupMenuControllerBase( xContext ),
+ m_bDisabled( false )
+{
+}
+
+SaveAsMenuController::~SaveAsMenuController()
+{
+}
+
+// private function
+void SaveAsMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopupMenu )
+{
+ VCLXPopupMenu* pPopupMenu = static_cast<VCLXPopupMenu *>(VCLXMenu::GetImplementation( rPopupMenu ));
+ PopupMenu* pVCLPopupMenu = 0;
+
+ SolarMutexGuard aSolarMutexGuard;
+
+ resetPopupMenu( rPopupMenu );
+ if ( pPopupMenu )
+ pVCLPopupMenu = static_cast<PopupMenu *>(pPopupMenu->GetMenu());
+
+ if ( pVCLPopupMenu )
+ {
+ // Open remote menu entry
+ pVCLPopupMenu->InsertItem( sal_uInt16( 1 ),
+ FWK_RESSTR( STR_REMOTE_FILE ) );
+ pVCLPopupMenu->SetItemCommand( sal_uInt16( 1 ),
+ OUString( CMD_SAVE_REMOTE ) );
+ }
+}
+
+// XEventListener
+void SAL_CALL SaveAsMenuController::disposing( const EventObject& ) throw ( RuntimeException, std::exception )
+{
+ Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY );
+
+ osl::MutexGuard aLock( m_aMutex );
+ m_xFrame.clear();
+ m_xDispatch.clear();
+
+ if ( m_xPopupMenu.is() )
+ m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(( OWeakObject *)this, UNO_QUERY ));
+ m_xPopupMenu.clear();
+}
+
+// XStatusListener
+void SAL_CALL SaveAsMenuController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException, std::exception )
+{
+ osl::MutexGuard aLock( m_aMutex );
+ m_bDisabled = !Event.IsEnabled;
+}
+
+void SAL_CALL SaveAsMenuController::itemSelected( const css::awt::MenuEvent& rEvent ) throw (RuntimeException, std::exception)
+{
+ Reference< css::awt::XPopupMenu > xPopupMenu;
+
+ osl::ClearableMutexGuard aLock( m_aMutex );
+ xPopupMenu = m_xPopupMenu;
+ aLock.clear();
+
+ if ( xPopupMenu.is() )
+ {
+ const OUString aCommand( xPopupMenu->getCommand( rEvent.MenuId ) );
+ OSL_TRACE( "SaveAsMenuController::itemSelected() - Command : %s",
+ OUStringToOString( aCommand, RTL_TEXTENCODING_UTF8 ).getStr() );
+
+ if ( aCommand == CMD_SAVE_REMOTE )
+ {
+ Sequence< PropertyValue > aArgsList( 0 );
+
+ dispatchCommand( CMD_SAVE_REMOTE, aArgsList );
+ }
+ }
+}
+
+void SAL_CALL SaveAsMenuController::itemActivated( const css::awt::MenuEvent& ) throw (RuntimeException, std::exception)
+{
+ osl::MutexGuard aLock( m_aMutex );
+ impl_setPopupMenu();
+}
+
+// XPopupMenuController
+void SaveAsMenuController::impl_setPopupMenu()
+{
+ if ( m_xPopupMenu.is() )
+ fillPopupMenu( m_xPopupMenu );
+}
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_framework_SaveAsMenuController_get_implementation(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new SaveAsMenuController(context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index 6541f1406f3f..1eaf2d04a447 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -117,6 +117,10 @@
constructor="com_sun_star_comp_framework_RecentFilesMenuController_get_implementation">
<service name="com.sun.star.frame.PopupMenuController"/>
</implementation>
+ <implementation name="com.sun.star.comp.framework.SaveAsMenuController"
+ constructor="com_sun_star_comp_framework_SaveAsMenuController_get_implementation">
+ <service name="com.sun.star.frame.PopupMenuController"/>
+ </implementation>
<implementation name="com.sun.star.comp.framework.StatusBarControllerFactory"
constructor="com_sun_star_comp_framework_StatusBarControllerFactory_get_implementation">
<service name="com.sun.star.frame.StatusbarControllerFactory"/>