diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-18 18:26:28 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-23 22:20:31 +0200 |
commit | b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 (patch) | |
tree | 53ee1bd3dfd213815a21579151983cb997922b05 /include/framework | |
parent | f4e1642a1761d5eab6ccdd89928869c2b2f1528a (diff) |
execute move of global headers
see https://gerrit.libreoffice.org/#/c/3367/
and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details
Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a
Diffstat (limited to 'include/framework')
21 files changed, 2208 insertions, 0 deletions
diff --git a/include/framework/actiontriggerhelper.hxx b/include/framework/actiontriggerhelper.hxx new file mode 100644 index 000000000000..e942de94924f --- /dev/null +++ b/include/framework/actiontriggerhelper.hxx @@ -0,0 +1,67 @@ +/* -*- 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 __FRAMEWORK_HELPER_ACTIONTRIGGERHELPER_HXX_ +#define __FRAMEWORK_HELPER_ACTIONTRIGGERHELPER_HXX_ + +#include <com/sun/star/container/XIndexContainer.hpp> +#include <vcl/menu.hxx> +#include <framework/fwedllapi.h> + + +namespace framework +{ + class FWE_DLLPUBLIC ActionTriggerHelper + { + public: + // Fills the submitted menu with the structure contained in the second + // parameter rActionTriggerContainer + // @param pNewMenu = must be a valid and empty menu + // @param rActionTriggerContainer = must be an instance of service "com.sun.star.ui.ActionTriggerContaienr" + static void + CreateMenuFromActionTriggerContainer( + Menu* pNewMenu, + const com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >& rActionTriggerContainer ); + + // Creates a "com::sun::star::ui::ActionTriggerContainer" with the structure of the menu + // provided as a parameter. The implementation class stores the menu pointer + // to optimize the time of creation of a menu from a actiontrigger structure. + // IMPORTANT: The caller must ensure that the menu pointer is valid through the + // life time of the XIndexContainer object!!! + // @param pNewMenu = Must be a valid menu. Please be aware that this implementation is based on + // the above mentioned restriction!!! + + static com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer > CreateActionTriggerContainerFromMenu( + const Menu* pMenu, const OUString* pMenuIdentifier ); + + // Fills the submitted rActionTriggerContainer with the structure of the menu + // provided as the second parameter + // @param rActionTriggerContainer = must be an instance of service "com.sun.star.ui.ActionTriggerContainer" + // @param pNewMenu = must be a valid menu + static void + FillActionTriggerContainerFromMenu( + com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >& rActionTriggerContainer, + const Menu* pMenu ); + + }; +} + +#endif // __FRAMEWORK_HELPER_ACTIONTRIGGERHELPER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/addonmenu.hxx b/include/framework/addonmenu.hxx new file mode 100644 index 000000000000..6390459be0f1 --- /dev/null +++ b/include/framework/addonmenu.hxx @@ -0,0 +1,127 @@ +/* -*- 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 __FRAMEWORK_CLASSES_ADDONMENU_HXX_ +#define __FRAMEWORK_CLASSES_ADDONMENU_HXX_ + +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/Sequence.hxx> + +#include <vcl/menu.hxx> +#include <framework/fwedllapi.h> + +#define ADDONMENU_ITEMID_START 2000 +#define ADDONMENU_ITEMID_END 3000 + +namespace framework +{ + +class FWE_DLLPUBLIC AddonMenu : public PopupMenu +{ + public: + AddonMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ); + ~AddonMenu(); + + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame; +}; + +class AddonMenuManager; + +class FWE_DLLPUBLIC AddonPopupMenu : public AddonMenu +{ + public: + ~AddonPopupMenu(); + + // Check if command URL string has the unique prefix to identify addon popup menus + static sal_Bool IsCommandURLPrefix( const OUString& aCmdURL ); + + void SetCommandURL( const OUString& aCmdURL ) { m_aCommandURL = aCmdURL; } + const OUString& GetCommandURL() const { return m_aCommandURL; } + + protected: + void Initialize( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rAddonPopupMenuDefinition ); + + private: + AddonPopupMenu( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame ); + + OUString m_aCommandURL; + + friend class AddonMenuManager; +}; + +class FWE_DLLPUBLIC AddonMenuManager +{ + public: + enum MenuType + { + ADDON_MENU, + ADDON_POPUPMENU + }; + + static sal_Bool HasAddonMenuElements(); + + static sal_Bool IsAddonMenuId( sal_uInt16 nId ) { return (( nId >= ADDONMENU_ITEMID_START ) && ( nId < ADDONMENU_ITEMID_END )); } + + // Check if the context string matches the provided xModel context + static sal_Bool IsCorrectContext( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel, const OUString& aContext ); + + // Factory method to create different Add-On menu types + static PopupMenu* CreatePopupMenuType( MenuType eMenuType, const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame ); + + // Create the Add-Ons menu + static AddonMenu* CreateAddonMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ); + + // Merge the Add-Ons help menu items into the given menu bar at a defined pos + static void MergeAddonHelpMenu( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame, + MenuBar* pMergeMenuBar ); + + // Merge the addon popup menus into the given menu bar at the provided pos. + static void MergeAddonPopupMenus( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame, + const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rModel, + sal_uInt16 nMergeAtPos, + MenuBar* pMergeMenuBar ); + + // Returns the next position to insert a menu item/sub menu + static sal_uInt16 GetNextPos( sal_uInt16 nPos ); + + // Build up the menu item and sub menu into the provided pCurrentMenu. The sub menus should be of type nSubMenuType. + static void BuildMenu( PopupMenu* pCurrentMenu, + MenuType nSubMenuType, + sal_uInt16 nInsPos, + sal_uInt16& nUniqueMenuId, + com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > > aAddonMenuDefinition, + const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame, + const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rModel ); + + // Retrieve the menu entry property values from a sequence + static void GetMenuEntry( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rAddonMenuEntry, + OUString& rTitle, + OUString& rURL, + OUString& rTarget, + OUString& rImageId, + OUString& rContext, + com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > >& rAddonSubMenu ); +}; + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_CLASSES_ADDONMENU_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/addonsoptions.hxx b/include/framework/addonsoptions.hxx new file mode 100644 index 000000000000..def743378216 --- /dev/null +++ b/include/framework/addonsoptions.hxx @@ -0,0 +1,350 @@ +/* -*- 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 __FRAMEWORK_CLASSES_ADDONSOPTIONS_HXX_ +#define __FRAMEWORK_CLASSES_ADDONSOPTIONS_HXX_ + +#include <sal/types.h> +#include <osl/mutex.hxx> +#include <vcl/image.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/svapp.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <framework/fwedllapi.h> +//_________________________________________________________________________________________________________________ +// types, enums, ... +//_________________________________________________________________________________________________________________ + +/*-************************************************************************************************************//** + @descr The method GetAddonsMenu() returns a list of property values. + Use follow defines to seperate values by names. +*//*-*************************************************************************************************************/ +#define ADDONSMENUITEM_STRING_URL "URL" +#define ADDONSMENUITEM_STRING_TITLE "Title" +#define ADDONSMENUITEM_STRING_TARGET "Target" +#define ADDONSMENUITEM_STRING_IMAGEIDENTIFIER "ImageIdentifier" +#define ADDONSMENUITEM_STRING_CONTEXT "Context" +#define ADDONSMENUITEM_STRING_SUBMENU "Submenu" +#define ADDONSMENUITEM_STRING_CONTROLTYPE "ControlType" +#define ADDONSMENUITEM_STRING_WIDTH "Width" + +#define ADDONSMENUITEM_URL_LEN 3 +#define ADDONSMENUITEM_TITLE_LEN 5 +#define ADDONSMENUITEM_TARGET_LEN 6 +#define ADDONSMENUITEM_SUBMENU_LEN 7 +#define ADDONSMENUITEM_CONTEXT_LEN 7 +#define ADDONSMENUITEM_IMAGEIDENTIFIER_LEN 15 + +#define ADDONSMENUITEM_PROPERTYNAME_URL OUString(ADDONSMENUITEM_STRING_URL ) +#define ADDONSMENUITEM_PROPERTYNAME_TITLE OUString(ADDONSMENUITEM_STRING_TITLE ) +#define ADDONSMENUITEM_PROPERTYNAME_TARGET OUString(ADDONSMENUITEM_STRING_TARGET ) +#define ADDONSMENUITEM_PROPERTYNAME_IMAGEIDENTIFIER OUString(ADDONSMENUITEM_STRING_IMAGEIDENTIFIER ) +#define ADDONSMENUITEM_PROPERTYNAME_CONTEXT OUString(ADDONSMENUITEM_STRING_CONTEXT ) +#define ADDONSMENUITEM_PROPERTYNAME_SUBMENU OUString(ADDONSMENUITEM_STRING_SUBMENU ) +#define ADDONSMENUITEM_PROPERTYNAME_CONTROLTYPE OUString(ADDONSMENUITEM_STRING_CONTROLTYPE ) +#define ADDONSMENUITEM_PROPERTYNAME_WIDTH OUString(ADDONSMENUITEM_STRING_WIDTH ) + +#define ADDONSPOPUPMENU_URL_PREFIX_STR "private:menu/Addon" + +#define ADDONSPOPUPMENU_URL_PREFIX OUString( ADDONSPOPUPMENU_URL_PREFIX_STR ) + +namespace framework +{ + +typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > MergeMenuDefinition; + +struct FWE_DLLPUBLIC MergeMenuInstruction +{ + OUString aMergePoint; + OUString aMergeCommand; + OUString aMergeCommandParameter; + OUString aMergeFallback; + OUString aMergeContext; + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > aMergeMenu; +}; +typedef ::std::vector< MergeMenuInstruction > MergeMenuInstructionContainer; + +struct FWE_DLLPUBLIC MergeToolbarInstruction +{ + OUString aMergeToolbar; + OUString aMergePoint; + OUString aMergeCommand; + OUString aMergeCommandParameter; + OUString aMergeFallback; + OUString aMergeContext; + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > aMergeToolbarItems; +}; + +typedef ::std::vector< MergeToolbarInstruction > MergeToolbarInstructionContainer; + +//_________________________________________________________________________________________________________________ +// forward declarations +//_________________________________________________________________________________________________________________ + +/*-************************************************************************************************************//** + @short forward declaration to our private date container implementation + @descr We use these class as internal member to support small memory requirements. + You can create the container if it is neccessary. The class which use these mechanism + is faster and smaller then a complete implementation! +*//*-*************************************************************************************************************/ + +class AddonsOptions_Impl; + +/*-************************************************************************************************************//** + @short collect information about menu features + @descr - + + @implements - + @base - + + @devstatus ready to use +*//*-*************************************************************************************************************/ + +class FWE_DLLPUBLIC AddonsOptions +{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + + public: + //--------------------------------------------------------------------------------------------------------- + // constructor / destructor + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short standard constructor and destructor + @descr This will initialize an instance with default values. + We implement these class with a refcount mechanism! Every instance of this class increase it + at create and decrease it at delete time - but all instances use the same data container! + He is implemented as a static member ... + + @seealso member m_nRefCount + @seealso member m_pDataContainer + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + AddonsOptions(); + ~AddonsOptions(); + + //--------------------------------------------------------------------------------------------------------- + // interface + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short clears completely the addons menu + @descr Call this methods to clear the addons menu + To fill it again use AppendItem(). + + @seealso - + + @param "eMenu" select right menu to clear. + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + void Clear(); + + /*-****************************************************************************************************//** + @short returns if an addons menu is available + @descr Call to retrieve if a addons menu is available + + + @return sal_True if there is a menu otherwise sal_False + *//*-*****************************************************************************************************/ + + sal_Bool HasAddonsMenu() const; + + /*-****************************************************************************************************//** + @short returns number of addons toolbars + @descr Call to retrieve the number of addons toolbars + + + @return number of addons toolbars + *//*-*****************************************************************************************************/ + sal_Int32 GetAddonsToolBarCount() const ; + + /*-****************************************************************************************************//** + @short returns the complete addons menu + @descr Call it to get all entries of the addon menu. + We return a list of all nodes with his names and properties. + + @seealso - + + @return A list of menu items is returned. + + @onerror We return an empty list. + *//*-*****************************************************************************************************/ + + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& GetAddonsMenu() const; + + /*-****************************************************************************************************//** + @short Gets the menu bar part of all addon components registered + @descr - + + @seealso - + + @return A complete + + @onerror We return sal_False + *//*-*****************************************************************************************************/ + + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& GetAddonsMenuBarPart() const; + + /*-****************************************************************************************************//** + @short Gets a toolbar part of an single addon + @descr - + + @seealso - + + @return A complete + + @onerror We return sal_False + *//*-*****************************************************************************************************/ + + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& GetAddonsToolBarPart( sal_uInt32 nIndex ) const; + + /*-****************************************************************************************************//** + @short Gets a unique toolbar resource name of an single addon + @descr - + + @seealso - + + @return A complete + + @onerror We return sal_False + *//*-*****************************************************************************************************/ + + const OUString GetAddonsToolbarResourceName( sal_uInt32 nIndex ) const; + + /*-****************************************************************************************************//** + @short Retrieves all available merge instructions for the Office menu bar + @descr - + + @seealso - + + @return The filled MergeMenuDefinitionContaier + + @onerror We return sal_False + *//*-*****************************************************************************************************/ + + const MergeMenuInstructionContainer& GetMergeMenuInstructions() const; + + /*-****************************************************************************************************//** + @short Retrieves all available merge instructions for a single toolbar + @descr - + + @seealso - + + @return The filled + + @onerror We return sal_False + *//*-*****************************************************************************************************/ + bool GetMergeToolbarInstructions( const OUString& rToolbarName, MergeToolbarInstructionContainer& rToolbar ) const; + + /*-****************************************************************************************************//** + @short Gets the Add-On help menu part of all addon components registered + @descr - + + @seealso - + + @return A complete + + @onerror We return sal_False + *//*-*****************************************************************************************************/ + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& GetAddonsHelpMenu() const; + + /*-****************************************************************************************************//** + @short Retrieve an image for a command URL which is defined inside the addon menu configuration + @descr Call it to retrieve an image for a command URL which is defined inside the addon menu configuration + + @seealso - + + @return An image which was defined in the configuration for the menu item. The image can be empty + no bitmap was defined for the request image properties. + + @onerror An empty image + *//*-*****************************************************************************************************/ + + Image GetImageFromURL( const OUString& aURL, sal_Bool bBig, sal_Bool bNoScale ) const; + Image GetImageFromURL( const OUString& aURL, sal_Bool bBig ) const; + + //------------------------------------------------------------------------------------------------------------- + // private methods + //------------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short return a reference to a static mutex + @descr These class is partially threadsafe (for de-/initialization only). + All access methods are'nt safe! + We create a static mutex only for one ime and use at different times. + + @seealso - + + @param - + @return A reference to a static mutex member. + + @onerror - + *//*-*****************************************************************************************************/ + + static ::osl::Mutex& GetOwnStaticMutex(); + + /*-****************************************************************************************************//** + @short return a reference to a static mutex + @descr These class is partially threadsafe (for de-/initialization only). + All access methods are'nt safe! + We create a static mutex only for one ime and use at different times. + + @seealso - + + @param - + @return A reference to a static mutex member. + + @onerror - + *//*-*****************************************************************************************************/ + DECL_STATIC_LINK( AddonsOptions, Notify, void* ); + + //------------------------------------------------------------------------------------------------------------- + // private member + //------------------------------------------------------------------------------------------------------------- + + private: + + /*Attention + + Don't initialize these static member in these header! + a) Double dfined symbols will be detected ... + b) and unresolved externals exist at linking time. + Do it in your source only. + */ + + static AddonsOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements! + static sal_Int32 m_nRefCount ; /// internal ref count mechanism + +}; // class SvtMenuOptions + +} + +#endif // #ifndef __FRAMEWORK_CLASSES_ADDONSOPTIONS_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/bmkmenu.hxx b/include/framework/bmkmenu.hxx new file mode 100644 index 000000000000..d78eefeced24 --- /dev/null +++ b/include/framework/bmkmenu.hxx @@ -0,0 +1,69 @@ +/* -*- 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 __FRAMEWORK_CLASSES_BMKMENU_HXX +#define __FRAMEWORK_CLASSES_BMKMENU_HXX + +#include "framework/addonmenu.hxx" + +#include <com/sun/star/frame/XFrame.hpp> +#include <framework/fwedllapi.h> + +#include <vcl/menu.hxx> +#include <vcl/image.hxx> + +class String; +class ImageList; + +#define BMKMENU_ITEMID_START 20000 + +namespace framework +{ + +class BmkMenu_Impl; +class FWE_DLLPUBLIC BmkMenu : public AddonMenu +{ + public: + enum BmkMenuType + { + BMK_NEWMENU, + BMK_WIZARDMENU + }; + + BmkMenu( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + BmkMenuType nType + ); + + ~BmkMenu(); + + void Initialize(); // Synchrones Laden der Eintraege + + protected: + BmkMenu::BmkMenuType m_nType; + sal_uInt16 CreateMenuId(); + + private: + + BmkMenu_Impl* _pImp; +}; + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_CLASSES_BMKMENU_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/configimporter.hxx b/include/framework/configimporter.hxx new file mode 100644 index 000000000000..06b6467f6c2a --- /dev/null +++ b/include/framework/configimporter.hxx @@ -0,0 +1,47 @@ +/* -*- 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 __FRAMEWORK_HELPER_CONFIGIMPORTER_HXX_ +#define __FRAMEWORK_HELPER_CONFIGIMPORTER_HXX_ + +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/ui/XUIConfigurationManager2.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <rtl/ustring.hxx> +#include <framework/fwedllapi.h> + +namespace framework +{ + class FWE_DLLPUBLIC UIConfigurationImporterOOo1x + { + public: + static sal_Bool ImportCustomToolbars( + const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager2 >& rContainerFactory, + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > >& rSeqContainer, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rToolbarStorage ); + }; + +} // namespace framework + +#endif // __FRAMEWORK_HELPER_CONFIGIMPORTER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/documentundoguard.hxx b/include/framework/documentundoguard.hxx new file mode 100644 index 000000000000..1954a72b5c67 --- /dev/null +++ b/include/framework/documentundoguard.hxx @@ -0,0 +1,63 @@ +/* -*- 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 FRAMEWORK_DOCUMENTUNDOGUARD_HXX +#define FRAMEWORK_DOCUMENTUNDOGUARD_HXX + +#include "framework/fwedllapi.h" + +#include <com/sun/star/uno/XInterface.hpp> + +#include <boost/scoped_ptr.hpp> + +//...................................................................................................................... +namespace framework +{ +//...................................................................................................................... + + //================================================================================================================== + //= DocumentUndoGuard + //================================================================================================================== + struct DocumentUndoGuard_Data; + /** a helper class guarding the Undo manager of a document + + This class guards, within a given scope, the Undo Manager of a document (or another component supporting + the XUndoManagerSupplier interface). When entering the scope (i.e. when the <code>DocumentUndoGuard</code> + instances is constructed), the current state of the undo contexts of the undo manager is examined. + Upon leaving the scope (i.e. when the <code>DocumentUndoGuard</code> is destructed), the guard will execute + as many calls to <member scope="com::sun::star::document">XUndoManager::leaveUndoContext</member> as are + necessary to restore the manager's initial state. + */ + class FWE_DLLPUBLIC DocumentUndoGuard + { + public: + DocumentUndoGuard( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_undoSupplierComponent ); + ~DocumentUndoGuard(); + + private: + ::boost::scoped_ptr< DocumentUndoGuard_Data > m_pData; + }; + +//...................................................................................................................... +} // namespace framework +//...................................................................................................................... + +#endif // FRAMEWORK_DOCUMENTUNDOGUARD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/eventsconfiguration.hxx b/include/framework/eventsconfiguration.hxx new file mode 100644 index 000000000000..29694b7fb539 --- /dev/null +++ b/include/framework/eventsconfiguration.hxx @@ -0,0 +1,43 @@ +/* -*- 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 __FRAMEWORK_XML_EVENTSCONFIGURATION_HXX_ +#define __FRAMEWORK_XML_EVENTSCONFIGURATION_HXX_ + +#include <framework/fwedllapi.h> +#include <tools/stream.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +namespace framework +{ + +struct FWE_DLLPUBLIC EventsConfig +{ + ::com::sun::star::uno::Sequence< OUString > aEventNames; + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aEventsProperties; +}; + +} // namespace framework + +#endif // __FRAMEWORK_XML_EVENTSCONFIGURATION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/framelistanalyzer.hxx b/include/framework/framelistanalyzer.hxx new file mode 100644 index 000000000000..951474c3934d --- /dev/null +++ b/include/framework/framelistanalyzer.hxx @@ -0,0 +1,195 @@ +/* -*- 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 __FRAMEWORK_CLASSES_FRAMELISTANALYZER_HXX_ +#define __FRAMEWORK_CLASSES_FRAMELISTANALYZER_HXX_ + +#include <com/sun/star/frame/XFrame.hpp> + +#include <framework/fwedllapi.h> + +namespace framework{ + +/** analyze and split the current available frame list of a given frames supplier + into different parts. + + These analyzed information can be used e.g. to decide if it's neccessary + to switch into the backing mode, close the current active frame only or + exit the whole application explicitly or implicitly. + */ +class FWE_DLLPUBLIC FrameListAnalyzer +{ + //_______________________________________ + // types + + public: + + /** These enums can be combined as flags to enable/disable + special search algorithm during analyze phase. + see impl_analyze() for further information. + But note: To be useable as flags, these enums + must be values of range [2^n]! */ + enum EDetect + { + E_MODEL = 1, + E_HELP = 2, + E_BACKINGCOMPONENT = 4, + E_HIDDEN = 8, + E_ALL = 15, + E_ZOMBIE = 32768 // use it for special test scenarios only!!! + }; + + //_______________________________________ + // member + + public: + + /** provides access to the frame container, which should be analyzed. */ + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFramesSupplier >& m_xSupplier; + + /** hold the reference frame, which is used e.g. to detect other frames with the same model. */ + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& m_xReferenceFrame; + + /** enable/disable some special analyzing steps. + see impl_analyze() for further information. */ + sal_uInt32 m_eDetectMode; + + /** contains all frames, which uses the same model like the reference frame. + Will be filled only if m_eDetectMode has set the flag E_MODEL. + The reference frame is never part of this list! */ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > > m_lModelFrames; + + /** contains all frames, which does not contain the same model like the reference frame. + Filling of it can't be supressed by m_eDetectMode. + The reference frame is never part of this list! + All frames inside this list are visible ones. */ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > > m_lOtherVisibleFrames; + + /** contains all frames, which does not contain the same model like the reference frame. + Filling of it can't be supressed by m_eDetectMode. + The reference frame is never part of this list! + All frames inside this list are hidden ones. */ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > > m_lOtherHiddenFrames; + + /** points to the help frame. + Will be set only, if any other frame (means different from the reference frame) + contains the help component. If the reference frame itself includes the help module + it's not set ... but another member m_bIsHelp is used to safe this information. + See following example code: + + <listing> + if (m_xReferenceFrame == help) + { + m_xHelp = NULL; + m_bIsHelp = sal_True; + } + else + if (xOtherFrame == help) + { + m_xHelp = xOtherFrame; + m_bIsHelp = sal_False; + } + </listing> + + Analyzing of the help frame ignores the visible state of any frame. + But note: a hidden help frame indicates a wrong state! + */ + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xHelp; + + /** points to the frame, which contains the backing component. + Will be set only, if any other frame (means different from the reference frame) + contains the backing component. If the reference frame itself includes the + backing component it's not set ... but another member m_bIsBackingComponent + will used to safe this information. + See following example code: + + <listing> + if (m_xReferenceFrame == backing) + { + m_xBackingComponent = NULL; + m_bIsBackingComponent = sal_True; + } + else + if (xOtherFrame == backing) + { + m_xBackingComponent = xOtherFrame; + m_bIsBackingComponent = sal_False ; + } + </listing> + + Analyzing of the help frame ignores the visible state of any frame. + But note: a hidden backing mode frame indicates a wrong state! + */ + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xBackingComponent; + + /** is set to true only, if the reference frame is a hidden one. + This value is undefined if m_eDetectMode doesn't have set the flag E_HIDDEN! */ + sal_Bool m_bReferenceIsHidden; + + /** is set to true only, if the reference frame contains the help component. + In this case the member m_xHelp is set to NULL everytimes. + This value is undefined if m_eDetectMode doesn't have set the flag E_HELP! */ + sal_Bool m_bReferenceIsHelp; + + /** is set to true only, if the reference frame contains the backing component. + In this case the member m_xBackingComponent is set to NULL everytimes. + This value is undefined if m_eDetectMode doesn't have set the flag E_BACKINGCOMPONENT! */ + sal_Bool m_bReferenceIsBacking; + + //_______________________________________ + // interface + + public: + + /** starts analyze phase and fille all members with valid information. + + @param xSupplier + Must be a valid reference to a frames supplier, which provies + access to the frame list for analyzing. + + @param xReferenceFrame + This frame must(!) exist inside the analyzed frame list and + is used for some comparing functions. Further some member states + depends from the current state of this frame. + + @param eDetectMode + It represent a flag field, which can enable/disable special + analyze steps. Note: Some member values will be undefined, if + an analyze step will be disabled. + */ + FrameListAnalyzer( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFramesSupplier >& xSupplier , + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xReferenceFrame , + sal_uInt32 eDetectMode ); + virtual ~FrameListAnalyzer(); + + //_______________________________________ + // helper + + private: + + void impl_analyze(); + + +}; // class FrameListAnalyzer + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_CLASSES_FRAMELISTANALYZER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/fwedllapi.h b/include/framework/fwedllapi.h new file mode 100644 index 000000000000..14201508768a --- /dev/null +++ b/include/framework/fwedllapi.h @@ -0,0 +1,34 @@ +/* -*- 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_FWEDLLAPI_H +#define INCLUDED_FWEDLLAPI_H + +#include "sal/types.h" + +#if defined(FWE_DLLIMPLEMENTATION) +#define FWE_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define FWE_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define FWE_DLLPRIVATE SAL_DLLPRIVATE + +#endif /* INCLUDED_FWEDLLAPI_H */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/iguard.hxx b/include/framework/iguard.hxx new file mode 100644 index 000000000000..a522d6225e43 --- /dev/null +++ b/include/framework/iguard.hxx @@ -0,0 +1,54 @@ +/* -*- 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 __FRAMEWORK_THREADHELP_IGUARD_H_ +#define __FRAMEWORK_THREADHELP_IGUARD_H_ + +#include <sal/types.h> + +namespace framework{ + +/*-************************************************************************************************************//** + @descr interface for guarding a lock +*//*-*************************************************************************************************************/ +class SAL_NO_VTABLE IGuard +{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + public: + + /** clears the lock. If the guard does not currently hold the lock, nothing happens. + */ + virtual void clear() = 0; + + /** attempts to re-establishes the lock, blocking until the attempt is successful. + */ + virtual void reset() = 0; + + protected: + ~IGuard() {} + +}; // class IGuard + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_THREADHELP_IGUARD_H_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/imageproducer.hxx b/include/framework/imageproducer.hxx new file mode 100644 index 000000000000..0d9398f7b2a3 --- /dev/null +++ b/include/framework/imageproducer.hxx @@ -0,0 +1,50 @@ +/* -*- 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 __FRAMEWORK_HELPER_IMAGEPRODUCER_HXX_ +#define __FRAMEWORK_HELPER_IMAGEPRODUCER_HXX_ + +#include <sal/types.h> +#include <com/sun/star/frame/XFrame.hpp> +#include <vcl/image.hxx> +#include <rtl/ustring.hxx> +#include <framework/fwedllapi.h> + +namespace framework +{ + +typedef Image ( *pfunc_getImage)( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + const OUString& aURL, + bool bBig +); + +pfunc_getImage FWE_DLLPUBLIC SAL_CALL SetImageProducer( pfunc_getImage pGetImageFunc ); + +Image FWE_DLLPUBLIC SAL_CALL GetImageFromURL( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + const OUString& aURL, + bool bBig +); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/imutex.hxx b/include/framework/imutex.hxx new file mode 100644 index 000000000000..f576297e0d14 --- /dev/null +++ b/include/framework/imutex.hxx @@ -0,0 +1,53 @@ +/* -*- 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 __FRAMEWORK_THREADHELP_IMUTEX_H_ +#define __FRAMEWORK_THREADHELP_IMUTEX_H_ + +#include <sal/types.h> + +namespace framework{ + +/*-************************************************************************************************************//** + @descr We need this interface to support using of different mutex implementations in a generic way. +*//*-*************************************************************************************************************/ +class SAL_NO_VTABLE IMutex +{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + public: + + /*-****************************************************************************************************//** + @descr These functions must be supported by a derived class! + acquire() -try to register thread + release() -unregister thread + *//*-*****************************************************************************************************/ + virtual void acquire() = 0; + virtual void release() = 0; + + protected: + ~IMutex() {} +}; // class IMutex + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_THREADHELP_IMUTEX_H_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/interaction.hxx b/include/framework/interaction.hxx new file mode 100644 index 000000000000..1cd56bbd36d9 --- /dev/null +++ b/include/framework/interaction.hxx @@ -0,0 +1,103 @@ +/* -*- 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 __FRAMEWORK_DISPATCH_INTERACTION_HXX_ +#define __FRAMEWORK_DISPATCH_INTERACTION_HXX_ + +#include <com/sun/star/task/XInteractionRequest.hpp> +#include <com/sun/star/task/XInteractionContinuation.hpp> +#include <com/sun/star/task/XInteractionAbort.hpp> +#include <com/sun/star/task/XInteractionApprove.hpp> +#include <com/sun/star/task/XInteractionDisapprove.hpp> +#include <com/sun/star/task/XInteractionRetry.hpp> +#include <com/sun/star/document/XInteractionFilterSelect.hpp> +#include <com/sun/star/document/NoSuchFilterRequest.hpp> +#include <com/sun/star/document/AmbigousFilterRequest.hpp> +#include <com/sun/star/uno/RuntimeException.hpp> + +#include <rtl/ustring.hxx> +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <framework/fwedllapi.h> + +namespace framework{ + +/*-************************************************************************************************************//** + @short special request for interaction to ask user for right filter + @descr These helper can be used to ask user for right filter, if filter detection failed. + It capsulate communication with any interaction handler and supports an easy + access on interaction results for user of these class. + Use it and forget complex mechanism of interaction ... + + @example RequestFilterSelect* pRequest = new RequestFilterSelect; + Reference< XInteractionRequest > xRequest ( pRequest ); + xInteractionHandler->handle( xRequest ); + if( ! pRequest.isAbort() ) + { + OUString sFilter = pRequest->getFilter(); + } + + @implements XInteractionRequest + + @base WeakImplHelper1 + + @devstatus ready to use + @threadsafe no (used on once position only!) +*//*-*************************************************************************************************************/ +class RequestFilterSelect_Impl; +class FWE_DLLPUBLIC RequestFilterSelect +{ + RequestFilterSelect_Impl* pImp; + + public: + RequestFilterSelect( const OUString& sURL ); + ~RequestFilterSelect(); + sal_Bool isAbort () const; + OUString getFilter() const; + com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionRequest > GetRequest(); +}; + +/*-************************************************************************************************************//** + @short special request for interaction + @descr User must decide between a preselected and another detected filter. + It capsulate communication with any interaction handler and supports an easy + access on interaction results for user of these class. + + @implements XInteractionRequest + + @base WeakImplHelper1 + + @devstatus ready to use + @threadsafe no (used on once position only!) +*//*-*************************************************************************************************************/ +class FWE_DLLPUBLIC InteractionRequest +{ +public: + static com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionRequest > + CreateRequest( const ::com::sun::star::uno::Any& aRequest, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > lContinuations ); +}; + + +} // namespace framework + +#endif // #define __FRAMEWORK_DISPATCH_INTERACTION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/menuconfiguration.hxx b/include/framework/menuconfiguration.hxx new file mode 100644 index 000000000000..1ccd6ba0d167 --- /dev/null +++ b/include/framework/menuconfiguration.hxx @@ -0,0 +1,107 @@ +/* -*- 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 __FRAMEWORK_XML_MENUCONFIGURATION_HXX_ +#define __FRAMEWORK_XML_MENUCONFIGURATION_HXX_ + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/WrappedTargetException.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <framework/fwedllapi.h> + +#include <cppuhelper/weak.hxx> +#include <vcl/menu.hxx> +#include <vcl/toolbox.hxx> + +#define BOOKMARK_NEWMENU OUString( "private:menu_bookmark_new" ) +#define BOOKMARK_WIZARDMENU OUString( "private:menu_bookmark_wizard" ) + +// Prepare for inclusion by framework and sfx +// Please consider that there is a corresponding define also in sfxsids.hrc!! (SID_SFX_START)/(SID_ADDONS) +#define FWK_SID_SFX_START 5000 +#define FWK_SID_ADDONS (FWK_SID_SFX_START+1678) +#define FWK_SID_ADDONHELP (FWK_SID_SFX_START+1684) + +const sal_uInt16 START_ITEMID_PICKLIST = 4500; +const sal_uInt16 END_ITEMID_PICKLIST = 4599; +const sal_uInt16 MAX_ITEMCOUNT_PICKLIST = 99; // difference between START_... & END_... for picklist / must be changed too, if these values are changed! +const sal_uInt16 START_ITEMID_WINDOWLIST = 4600; +const sal_uInt16 END_ITEMID_WINDOWLIST = 4699; +const sal_uInt16 ITEMID_ADDONLIST = FWK_SID_ADDONS; +const sal_uInt16 ITEMID_ADDONHELP = FWK_SID_ADDONHELP; + +namespace framework +{ + +class FWE_DLLPUBLIC MenuConfiguration +{ + public: + struct Attributes + { + Attributes() {} + Attributes( const OUString& aFrame, const OUString& aImageIdStr ) : + aTargetFrame( aFrame ), aImageId( aImageIdStr ) {} + + OUString aTargetFrame; + OUString aImageId; + ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProvider > xDispatchProvider; + sal_Int16 nStyle; + }; + + MenuConfiguration( + // use const when giving a uno reference by reference + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); + + virtual ~MenuConfiguration(); + + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > CreateMenuBarConfigurationFromXML( + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rInputStream ) + throw ( ::com::sun::star::lang::WrappedTargetException ); + + PopupMenu* CreateBookmarkMenu( + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + const OUString& aURL ) + throw ( ::com::sun::star::lang::WrappedTargetException ); + + ToolBox* CreateToolBoxFromConfiguration( + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rInputStream ) + throw ( ::com::sun::star::lang::WrappedTargetException ); + + void StoreMenuBarConfigurationToXML( ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rMenuBarConfiguration, + ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream ) + throw ( ::com::sun::star::lang::WrappedTargetException ); + + void StoreToolBox( ToolBox* pToolBox, + ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream ) + throw ( ::com::sun::star::lang::WrappedTargetException ); + + private: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext; +}; + +} + +#endif // __FRAMEWORK_XML_MENUCONFIGURATION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/menuextensionsupplier.hxx b/include/framework/menuextensionsupplier.hxx new file mode 100644 index 000000000000..6d3a6761e38e --- /dev/null +++ b/include/framework/menuextensionsupplier.hxx @@ -0,0 +1,43 @@ +/* -*- 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 __FRAMEWORK_CLASSES_MENUEXTENSIONSUPPLIER_HXX_ +#define __FRAMEWORK_CLASSES_MENUEXTENSIONSUPPLIER_HXX_ + +#include <rtl/ustring.hxx> +#include <framework/fwedllapi.h> + +struct FWE_DLLPUBLIC MenuExtensionItem +{ + OUString aLabel; + OUString aURL; +}; + +typedef MenuExtensionItem ( *pfunc_setMenuExtensionSupplier)(); + +namespace framework +{ + +FWE_DLLPUBLIC MenuExtensionItem SAL_CALL GetMenuExtension(); + +} + +#endif // __FRAMEWORK_CLASSES_MENUEXTENSIONSUPPLIER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/preventduplicateinteraction.hxx b/include/framework/preventduplicateinteraction.hxx new file mode 100644 index 000000000000..5be9d52f62cf --- /dev/null +++ b/include/framework/preventduplicateinteraction.hxx @@ -0,0 +1,236 @@ +/* -*- 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 __FRAMEWORK_INTERACTION_PREVENTDUPLICATEINTERACTION_HXX_ +#define __FRAMEWORK_INTERACTION_PREVENTDUPLICATEINTERACTION_HXX_ + +#include <framework/fwedllapi.h> + +#include <vector> + +#include <com/sun/star/task/XInteractionHandler2.hpp> +#include <com/sun/star/task/XInteractionRequest.hpp> + +#include <cppuhelper/implbase1.hxx> + +namespace framework{ + +/** + @short Prevent us from showing the same interaction more then once during + the same transaction. + + @descr Every interaction provided to this helper will be safed ... handled by the internal + used UUIInteractionHandler (!) and never be handled a second time! + + On the other side there exists some interactions, which allow a retry. + So this helper allow to set a list of interactions combined with a retry value. + */ +struct ThreadHelpBase2 +{ + public: + mutable ::osl::Mutex m_aLock; +}; + +class FWE_DLLPUBLIC PreventDuplicateInteraction : private ThreadHelpBase2 + ,public ::cppu::WeakImplHelper1< css::task::XInteractionHandler2 > +{ + //_____________________________________ + // structs, types etcp. + public: + + struct InteractionInfo + { + public: + /// describe the interaction. + css::uno::Type m_aInteraction; + /// after max count was reached this interaction will be blocked. + sal_Int32 m_nMaxCount; + /// count how often this interaction was called. + sal_Int32 m_nCallCount; + /** hold the last intercepted request (matching the set interaction type) alive + so it can be used for further checks */ + css::uno::Reference< css::task::XInteractionRequest > m_xRequest; + + public: + + InteractionInfo(const css::uno::Type& aInteraction, + sal_Int32 nMaxCount ) + : m_aInteraction(aInteraction) + , m_nMaxCount (nMaxCount ) + , m_nCallCount (0 ) + {} + + InteractionInfo(const InteractionInfo& aCopy) + : m_aInteraction(aCopy.m_aInteraction) + , m_nMaxCount (aCopy.m_nMaxCount ) + , m_nCallCount (aCopy.m_nCallCount ) + , m_xRequest (aCopy.m_xRequest ) + {} + }; + + typedef ::std::vector< InteractionInfo > InteractionList; + + //_____________________________________ + // member + private: + + /// Used to create needed uno services at runtime. + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /** The outside interaction handler, which is used to handle every incoming interaction, + if it's not blocked. */ + css::uno::Reference< css::task::XInteractionHandler > m_xHandler; + + /** This list describe which and how incoming interactions must be handled. + Further it contains all collected information after this interaction + object was used.*/ + InteractionList m_lInteractionRules; + + //_____________________________________ + // uno interface + public: + + //_________________________________ + /** + @interface XInteractionHandler + @short called from outside to handle a problem + @descr We filter the incoming interactions. some of them + will be forwarded to the generic UI interaction handler. + So we must not implement it twice. Some other ones + will be aborted only. + + @threadsafe yes + */ + virtual void SAL_CALL handle(const css::uno::Reference< css::task::XInteractionRequest >& xRequest) + throw(css::uno::RuntimeException); + + //_________________________________ + /** + @interface XInteractionHandler2 + @short called from outside to handle a problem + @descr We filter the incoming interactions. some of them + will be forwarded to the generic UI interaction handler. + So we must not implement it twice. Some other ones + will be aborted only. + + @threadsafe yes + */ + virtual ::sal_Bool SAL_CALL handleInteractionRequest( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest ) + throw (::com::sun::star::uno::RuntimeException); + + //_________________________________ + /** + @interface XInterface + @short called to query another interface of the component + @descr Will allow to query for XInteractionHandler2 if and only if m_xHandler supports this interface, too. + + @threadsafe yes + */ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) + throw (::com::sun::star::uno::RuntimeException); + //_____________________________________ + // c++ interface + public: + + //_________________________________ + /** + @short ctor to guarantee right initialized instances of this class + @descr It uses the given uno service manager to create the global + generic UI interaction handler for later internal using. + + @param xSMGR + uno service manager for creating services internaly + + @threadsafe not neccessary + */ + PreventDuplicateInteraction(const css::uno::Reference< css::uno::XComponentContext >& rxContext); + + //_________________________________ + /** + @short dtor to free used memory. + */ + virtual ~PreventDuplicateInteraction(); + + //_________________________________ + /** + @short set the outside interaction handler, which must be used internaly + if the interaction will not be blocked by the set list of rules. + + @note This overwrites the settings of e.g. useDefaultUUIHandler()! + + @param xHandler + the new interaction handler + */ + virtual void setHandler(const css::uno::Reference< css::task::XInteractionHandler >& xHandler); + + //_________________________________ + /** + @short instead of setting an outside interaction handler, this method + make sure the default UUI interaction handler of the office is used. + + @note This overwrites the settings of e.g. setHandler()! + */ + virtual void useDefaultUUIHandler(); + + //_________________________________ + /** + @short add a new interaction to the list of interactions, which + must be handled by this helper. + + @descr This method must be called immediately after a new instance of this helper was + created. Without such list of InteractionRules, this instances does nothing! + On the other side there is no possibility to remove rules. + So the same instance cant be used within different transactions. + It's a OneWay-object .-) + + @param aInteractionInfo + describe the type of interaction, hos often it can be called etcpp. + + @threadsafe yes + */ + virtual void addInteractionRule(const PreventDuplicateInteraction::InteractionInfo& aInteractionInfo); + + //_________________________________ + /** + @short return the info struct for the specified interaction. + + @param aInteraction + specify the interaction. + + @param pReturn + provides information about: + - the count how often this interaction was handled during the + lifetime of this helper. + - the interaction itself, so it can be analyzed further + + @return [boolean] + sal_True if the queried interaction could be found. + sal_False otherwise. + + @threadsafe yes + */ + virtual sal_Bool getInteractionInfo(const css::uno::Type& aInteraction, + PreventDuplicateInteraction::InteractionInfo* pReturn ) const; +}; + +} // namespace framework + +#endif // #ifndef __FRAMEWORK_INTERACTION_PREVENTDUPLICATEINTERACTION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/sfxhelperfunctions.hxx b/include/framework/sfxhelperfunctions.hxx new file mode 100644 index 000000000000..ce2b604f5e5e --- /dev/null +++ b/include/framework/sfxhelperfunctions.hxx @@ -0,0 +1,97 @@ +/* -*- 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 __FRAMEWORK_CLASSES_SFXHELPERFUNCTIONS_HXX_ +#define __FRAMEWORK_CLASSES_SFXHELPERFUNCTIONS_HXX_ + +#include <framework/fwedllapi.h> +#include <com/sun/star/frame/XFrame.hpp> +#include <rtl/ustring.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/status.hxx> +#include <svtools/toolboxcontroller.hxx> +#include <svtools/statusbarcontroller.hxx> + +typedef svt::ToolboxController* ( *pfunc_setToolBoxControllerCreator)( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + ToolBox* pToolbox, + unsigned short nID, + const OUString& aCommandURL ); + +typedef svt::StatusbarController* ( *pfunc_setStatusBarControllerCreator)( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + StatusBar* pStatusBar, + unsigned short nID, + const OUString& aCommandURL ); + +typedef void ( *pfunc_getRefreshToolbars)( + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ); + +typedef void ( *pfunc_createDockingWindow)( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + const OUString& rResourceURL ); + +typedef bool ( *pfunc_isDockingWindowVisible)( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + const OUString& rResourceURL ); + +typedef void ( *pfunc_activateToolPanel)( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, + const OUString& i_rPanelURL ); + + +namespace framework +{ +FWE_DLLPUBLIC pfunc_setToolBoxControllerCreator SAL_CALL SetToolBoxControllerCreator( pfunc_setToolBoxControllerCreator pSetToolBoxControllerCreator ); +FWE_DLLPUBLIC svt::ToolboxController* SAL_CALL CreateToolBoxController( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + ToolBox* pToolbox, + unsigned short nID, + const OUString& aCommandURL ); + +FWE_DLLPUBLIC pfunc_setStatusBarControllerCreator SAL_CALL SetStatusBarControllerCreator( pfunc_setStatusBarControllerCreator pSetStatusBarControllerCreator ); +FWE_DLLPUBLIC svt::StatusbarController* SAL_CALL CreateStatusBarController( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + StatusBar* pStatusBar, + unsigned short nID, + const OUString& aCommandURL ); + +FWE_DLLPUBLIC pfunc_getRefreshToolbars SAL_CALL SetRefreshToolbars( pfunc_getRefreshToolbars pRefreshToolbarsFunc ); +FWE_DLLPUBLIC void SAL_CALL RefreshToolbars( + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ); + +FWE_DLLPUBLIC pfunc_createDockingWindow SAL_CALL SetDockingWindowCreator( pfunc_createDockingWindow pCreateDockingWindow ); +FWE_DLLPUBLIC void SAL_CALL CreateDockingWindow( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + const OUString& rResourceURL ); + +FWE_DLLPUBLIC pfunc_isDockingWindowVisible SAL_CALL SetIsDockingWindowVisible( pfunc_isDockingWindowVisible pIsDockingWindowVisible ); +FWE_DLLPUBLIC bool SAL_CALL IsDockingWindowVisible( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, + const OUString& rResourceURL ); + +FWE_DLLPUBLIC pfunc_activateToolPanel SAL_CALL SetActivateToolPanel( pfunc_activateToolPanel i_pActivator ); +FWE_DLLPUBLIC void SAL_CALL ActivateToolPanel( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, + const OUString& i_rPanelURL ); +} + +#endif // __FRAMEWORK_CLASSES_SFXHELPERFUNCTIONS_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/statusbarconfiguration.hxx b/include/framework/statusbarconfiguration.hxx new file mode 100644 index 000000000000..e71a89fe0ca4 --- /dev/null +++ b/include/framework/statusbarconfiguration.hxx @@ -0,0 +1,53 @@ +/* -*- 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 __FRAMEWORK_CLASSES_STATUSBARCONFIGURATION_HXX_ +#define __FRAMEWORK_CLASSES_STATUSBARCONFIGURATION_HXX_ + +#include <framework/fwedllapi.h> +#include <tools/stream.hxx> +#include <vcl/status.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +namespace framework +{ + +class FWE_DLLPUBLIC StatusBarConfiguration +{ + public: + static sal_Bool LoadStatusBar( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInputStream, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& rStatusbarConfiguration ); + + static sal_Bool StoreStatusBar( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutputStream, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rStatusbarConfiguration ); +}; + +} // namespace framework + +#endif // __FRAMEWORK_CLASSES_STATUSBARCONFIGURATION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/titlehelper.hxx b/include/framework/titlehelper.hxx new file mode 100644 index 000000000000..c4cdc31a6329 --- /dev/null +++ b/include/framework/titlehelper.hxx @@ -0,0 +1,206 @@ +/* -*- 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 _FRAMEWORK_TITLEHELPER_HXX_ +#define _FRAMEWORK_TITLEHELPER_HXX_ + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/XInterface.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/frame/XUntitledNumbers.hpp> +#include <com/sun/star/frame/XTitle.hpp> +#include <com/sun/star/frame/XTitleChangeBroadcaster.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/document/XEventListener.hpp> + +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/weakref.hxx> +#include <cppuhelper/implbase5.hxx> +#include <cppuhelper/interfacecontainer.hxx> + +#include <rtl/ustrbuf.hxx> + +#include <boost/unordered_map.hpp> +#include <framework/fwedllapi.h> + + +namespace framework{ + + +/** @short can be used as implementation helper of interface css.frame.XTitle + + @threadsafe + */ +class FWE_DLLPUBLIC TitleHelper : private ::cppu::BaseMutex + , public ::cppu::WeakImplHelper5< css::frame::XTitle , + css::frame::XTitleChangeBroadcaster, + css::frame::XTitleChangeListener , + css::frame::XFrameActionListener , + css::document::XEventListener > +{ + //------------------------------------------- + // interface + public: + + //--------------------------------------- + /** @short lightweight constructor. + */ + TitleHelper(const css::uno::Reference< css::uno::XComponentContext >& rxContext); + + //--------------------------------------- + /** @short free all internaly used resources. + */ + virtual ~TitleHelper(); + + //--------------------------------------- + /** set an outside component which uses this container and must be set + as source of all broadcasted messages, exceptions. + + It's holded weak only so we do not need any complex dispose sessions. + + Note: Passing NULL as parameter will be alloed. It will reset the internal + member reference only. + + @param xOwner + the new owner of this collection. + */ + void setOwner (const css::uno::Reference< css::uno::XInterface >& xOwner); + + //--------------------------------------- + /** set an outside component which provides the righht string and number for + an untitled component. + + It's holded weak only so we do not need any complex dispose sessions. + + Note: Passing NULL as parameter will be alloed. It will reset the internal + member reference only. + + @param xNumbers + the right numbered collection for this helper. + */ + void connectWithUntitledNumbers (const css::uno::Reference< css::frame::XUntitledNumbers >& xNumbers); + + //--------------------------------------- + /** @see XTitle */ + virtual OUString SAL_CALL getTitle() + throw (css::uno::RuntimeException); + + //--------------------------------------- + /** @see XTitle */ + virtual void SAL_CALL setTitle(const OUString& sTitle) + throw (css::uno::RuntimeException); + + //--------------------------------------- + /** @see XTitleChangeBroadcaster */ + virtual void SAL_CALL addTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener) + throw (css::uno::RuntimeException); + + //--------------------------------------- + /** @see XTitleChangeBroadcaster */ + virtual void SAL_CALL removeTitleChangeListener(const css::uno::Reference< css::frame::XTitleChangeListener >& xListener) + throw (css::uno::RuntimeException); + + //--------------------------------------- + /** @see XTitleChangeListener */ + virtual void SAL_CALL titleChanged(const css::frame::TitleChangedEvent& aEvent) + throw (css::uno::RuntimeException); + + //--------------------------------------- + /** @see css.document.XEventListener */ + virtual void SAL_CALL notifyEvent(const css::document::EventObject& aEvent) + throw (css::uno::RuntimeException); + + //--------------------------------------- + /** @see css.lang.XEventListener */ + virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) + throw (css::uno::RuntimeException); + + //--------------------------------------- + /** @see css.frame.XFrameActionListener */ + virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) + throw(css::uno::RuntimeException); + + //------------------------------------------- + // internal + private: + + void impl_sendTitleChangedEvent (); + + void impl_updateTitle (bool init = false); + void impl_updateTitleForModel (const css::uno::Reference< css::frame::XModel >& xModel, bool init); + void impl_updateTitleForController (const css::uno::Reference< css::frame::XController >& xController, bool init); + void impl_updateTitleForFrame (const css::uno::Reference< css::frame::XFrame >& xFrame, bool init); + + void impl_startListeningForModel (const css::uno::Reference< css::frame::XModel >& xModel); + void impl_startListeningForController (const css::uno::Reference< css::frame::XController >& xController); + void impl_startListeningForFrame (const css::uno::Reference< css::frame::XFrame >& xFrame); + void impl_updateListeningForFrame (const css::uno::Reference< css::frame::XFrame >& xFrame); + + void impl_appendComponentTitle ( OUStringBuffer& sTitle , + const css::uno::Reference< css::uno::XInterface >& xComponent); + void impl_appendProductName (OUStringBuffer& sTitle); + void impl_appendProductExtension (OUStringBuffer& sTitle); + void impl_appendModuleName (OUStringBuffer& sTitle); + void impl_appendDebugVersion (OUStringBuffer& sTitle); + + void impl_setSubTitle (const css::uno::Reference< css::frame::XTitle >& xSubTitle); + + OUString impl_convertURL2Title(const OUString& sURL); + + //------------------------------------------- + // member + private: + + /** points to the global uno service manager. */ + css::uno::Reference< css::uno::XComponentContext> m_xContext; + + /** reference to the outside UNO class using this helper. */ + css::uno::WeakReference< css::uno::XInterface > m_xOwner; + + /** used to know how an "Untitled X" string can be created right :-) */ + css::uno::WeakReference< css::frame::XUntitledNumbers > m_xUntitledNumbers; + + /** provides parts of our own title and we listen there for changes too. */ + css::uno::WeakReference< css::frame::XTitle > m_xSubTitle; + + /** if it's set to sal_True the member m_sTitle has not to be changed internaly. + It was set from outside and so outside code has to make sure it will be + updated. + */ + ::sal_Bool m_bExternalTitle; + + /** the actual title value */ + OUString m_sTitle; + + /** knows the leased number which must be used for untitled components. */ + ::sal_Int32 m_nLeasedNumber; + + /** contains all title change listener */ + ::cppu::OMultiTypeInterfaceContainerHelper m_aListener; +}; + +} // namespace framework + +#endif // _FRAMEWORK_TITLEHELPER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/toolboxconfiguration.hxx b/include/framework/toolboxconfiguration.hxx new file mode 100644 index 000000000000..a296231a07ea --- /dev/null +++ b/include/framework/toolboxconfiguration.hxx @@ -0,0 +1,52 @@ +/* -*- 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 __FRAMEWORK_XML_TOOLBOXCONFIGURATION_HXX_ +#define __FRAMEWORK_XML_TOOLBOXCONFIGURATION_HXX_ + +#include <framework/fwedllapi.h> +#include <vcl/bitmap.hxx> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +namespace framework +{ + +class FWE_DLLPUBLIC ToolBoxConfiguration +{ + public: + static sal_Bool LoadToolBox( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rInputStream, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& rToolbarConfiguration ); + + static sal_Bool StoreToolBox( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rToolbarConfiguration ); +}; + +} // namespace framework + +#endif // __FRAMEWORK_XML_TOOLBOXCONFIGURATION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/framework/undomanagerhelper.hxx b/include/framework/undomanagerhelper.hxx new file mode 100644 index 000000000000..ae91db981553 --- /dev/null +++ b/include/framework/undomanagerhelper.hxx @@ -0,0 +1,159 @@ +/* -*- 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 FRAMEWORK_UNDOMANAGERHELPER_HXX +#define FRAMEWORK_UNDOMANAGERHELPER_HXX + +#include "framework/fwedllapi.h" +#include "framework/iguard.hxx" +#include "framework/imutex.hxx" + +#include <com/sun/star/document/XUndoManager.hpp> +#include <com/sun/star/util/XModifyListener.hpp> + +#include <boost/scoped_ptr.hpp> + +namespace svl +{ + class IUndoManager; +} + +//...................................................................................................................... +namespace framework +{ +//...................................................................................................................... + + //================================================================================================================== + //= IMutexGuard + //================================================================================================================== + class SAL_NO_VTABLE IMutexGuard : public IGuard + { + public: + /** returns the mutex guarded by the instance. + + Even if the guard currently has not a lock on the mutex, this method must succeed. + */ + virtual IMutex& getGuardedMutex() = 0; + + protected: + ~IMutexGuard() {} + }; + + //================================================================================================================== + //= IUndoManagerImplementation + //================================================================================================================== + class SAL_NO_VTABLE IUndoManagerImplementation + { + public: + /** returns the IUndoManager interface to the actual Undo stack + + @throws com::sun::star::lang::DisposedException + when the instance is already disposed, and no IUndoManager can be provided + + @throws com::sun::star::lang::NotInitializedException + when the instance is not initialized, yet, and no IUndoManager can be provided + */ + virtual ::svl::IUndoManager& getImplUndoManager() = 0; + + /** provides access to an UNO interface for the XUndoManager implementation. Used when throwing exceptions. + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > + getThis() = 0; + + protected: + ~IUndoManagerImplementation() {} + }; + + //================================================================================================================== + //= UndoManagerHelper + //================================================================================================================== + class UndoManagerHelper_Impl; + /** helper class for implementing an XUndoManager + + Several of the methods of the class take an IMutexGuard instance. It is assumed that this guard has a lock on + its mutext at the moment the method is entered. The lock will be released before any notifications to the + registered XUndoManagerListeners happen. + + The following locking strategy is used for this mutex: + <ul><li>Any notifications to the registered XUndoManagerListeners are after the guard has been cleared. i.e. + without the mutex being locked.</p> + <li>Any calls into the <code>IUndoManager</code> implementation is made without the mutex being locked. + Note that this implies that the <code>IUndoManager</code> implementation must be thread-safe in itself + (which is true for the default implementation, SfxUndoManager).</li> + <li>An exception to the previous item are the <member>IUndoManager::Undo</member> and + <member>IUndoManager::Redo</member> methods: They're called with the given external mutex being + locked.</li> + </ul> + + The reason for the exception for IUndoManager::Undo and IUndoManager::Redo is that those are expected to + modify the actual document which the UndoManager works for. And as long as our documents are not thread-safe, + and as long as we do not re-fit <strong>all</strong> existing SfxUndoImplementations to <em>not</em> expect + the dreaded SolarMutex being locked when they're called, the above behavior is a compromise between "how it should + be" and "how it can realistically be". + */ + class FWE_DLLPUBLIC UndoManagerHelper + { + public: + UndoManagerHelper( IUndoManagerImplementation& i_undoManagerImpl ); + ~UndoManagerHelper(); + + // life time control + void disposing(); + + // XUndoManager equivalents + void enterUndoContext( const OUString& i_title, IMutexGuard& i_instanceLock ); + void enterHiddenUndoContext( IMutexGuard& i_instanceLock ); + void leaveUndoContext( IMutexGuard& i_instanceLock ); + void addUndoAction( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoAction >& i_action, IMutexGuard& i_instanceLock ); + void undo( IMutexGuard& i_instanceLock ); + void redo( IMutexGuard& i_instanceLock ); + ::sal_Bool isUndoPossible() const; + ::sal_Bool isRedoPossible() const; + OUString getCurrentUndoActionTitle() const; + OUString getCurrentRedoActionTitle() const; + ::com::sun::star::uno::Sequence< OUString > + getAllUndoActionTitles() const; + ::com::sun::star::uno::Sequence< OUString > + getAllRedoActionTitles() const; + void clear( IMutexGuard& i_instanceLock ); + void clearRedo( IMutexGuard& i_instanceLock ); + void reset( IMutexGuard& i_instanceLock ); + void addUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ); + void removeUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ); + + // XLockable, base of XUndoManager, equivalents + void lock(); + void unlock(); + ::sal_Bool isLocked(); + + // XModifyBroadcaster equivalents + void addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& i_listener ); + void removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& i_listener ); + + private: + ::boost::scoped_ptr< UndoManagerHelper_Impl > m_pImpl; + }; + +//...................................................................................................................... +} // namespace framework +//...................................................................................................................... + +#endif // FRAMEWORK_UNDOMANAGERHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |