diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /framework/inc/helper | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'framework/inc/helper')
-rw-r--r-- | framework/inc/helper/dockingareadefaultacceptor.hxx | 71 | ||||
-rw-r--r-- | framework/inc/helper/mischelper.hxx | 262 | ||||
-rw-r--r-- | framework/inc/helper/ocomponentaccess.hxx | 164 | ||||
-rw-r--r-- | framework/inc/helper/ocomponentenumeration.hxx | 163 | ||||
-rw-r--r-- | framework/inc/helper/oframes.hxx | 193 | ||||
-rw-r--r-- | framework/inc/helper/persistentwindowstate.hxx | 165 | ||||
-rw-r--r-- | framework/inc/helper/propertysetcontainer.hxx | 78 | ||||
-rw-r--r-- | framework/inc/helper/shareablemutex.hxx | 94 | ||||
-rw-r--r-- | framework/inc/helper/statusindicator.hxx | 106 | ||||
-rw-r--r-- | framework/inc/helper/statusindicatorfactory.hxx | 273 | ||||
-rw-r--r-- | framework/inc/helper/tagwindowasmodified.hxx | 96 | ||||
-rw-r--r-- | framework/inc/helper/titlebarupdate.hxx | 145 | ||||
-rw-r--r-- | framework/inc/helper/uiconfigelementwrapperbase.hxx | 143 | ||||
-rw-r--r-- | framework/inc/helper/uielementwrapperbase.hxx | 114 | ||||
-rw-r--r-- | framework/inc/helper/vclstatusindicator.hxx | 92 | ||||
-rw-r--r-- | framework/inc/helper/wakeupthread.hxx | 56 |
16 files changed, 2215 insertions, 0 deletions
diff --git a/framework/inc/helper/dockingareadefaultacceptor.hxx b/framework/inc/helper/dockingareadefaultacceptor.hxx new file mode 100644 index 000000000..16423fb6e --- /dev/null +++ b/framework/inc/helper/dockingareadefaultacceptor.hxx @@ -0,0 +1,71 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_DOCKINGAREADEFAULTACCEPTOR_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_DOCKINGAREADEFAULTACCEPTOR_HXX + +#include <com/sun/star/ui/XDockingAreaAcceptor.hpp> +#include <com/sun/star/frame/XFrame.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +namespace framework{ + +class DockingAreaDefaultAcceptor final : public ::cppu::WeakImplHelper< css::ui::XDockingAreaAcceptor > +{ + public: + + // constructor / destructor + + /*-**************************************************************************************************** + @short constructor to initialize this instance + @descr A docking area acceptor + But we need an instance to create more than one enumerations to the same tasklist! + + @seealso class Desktop + @seealso class OTasksEnumeration + + @param "xOwner" is a reference to our owner and must be the desktop! + @param "pTasks" is a pointer to the taskcontainer of the desktop. We need it to create a new enumeration. + @onerror Do nothing and reset this object to default with an empty list. + *//*-*****************************************************************************************************/ + + DockingAreaDefaultAcceptor( const css::uno::Reference< css::frame::XFrame >& xOwner ); + virtual ~DockingAreaDefaultAcceptor() override; + + // XDockingAreaAcceptor + + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getContainerWindow() override; + virtual sal_Bool SAL_CALL requestDockingAreaSpace( const css::awt::Rectangle& RequestedSpace ) override; + virtual void SAL_CALL setDockingAreaSpace( const css::awt::Rectangle& BorderSpace ) override; + + // variables + // (should be private everyway!) + + private: + + css::uno::WeakReference< css::frame::XFrame > m_xOwner; /// weak reference to our frame object! +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_DOCKINGAREADEFAULTACCEPTOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/mischelper.hxx b/framework/inc/helper/mischelper.hxx new file mode 100644 index 000000000..00f868948 --- /dev/null +++ b/framework/inc/helper/mischelper.hxx @@ -0,0 +1,262 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_MISCHELPER_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_MISCHELPER_HXX + +#include <com/sun/star/linguistic2/XLanguageGuessing.hpp> +#include <com/sun/star/document/XDocumentEventListener.hpp> +#include <com/sun/star/util/XChangesListener.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/ui/XContextChangeEventListener.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +#include <i18nlangtag/lang.h> +#include <svl/languageoptions.hxx> +#include <rtl/ustring.hxx> +#include <fwidllapi.h> + +#include <functional> +#include <set> + +namespace framework +{ + +// menu ids for language status bar control +enum LangMenuIDs +{ + MID_LANG_SEL_1 = 1, // need to start with 1 since xPopupMenu->execute will return 0 if the menu is cancelled + MID_LANG_SEL_2, + MID_LANG_SEL_3, + MID_LANG_SEL_4, + MID_LANG_SEL_5, + MID_LANG_SEL_6, + MID_LANG_SEL_7, + MID_LANG_SEL_8, + MID_LANG_SEL_9, + MID_LANG_SEL_NONE, + MID_LANG_SEL_RESET, + MID_LANG_SEL_MORE, + MID_LANG_DEF_NONE, + MID_LANG_DEF_RESET, + MID_LANG_DEF_MORE, + + MID_LANG_PARA_SEPARATOR, + MID_LANG_PARA_STRING, + + MID_LANG_PARA_1, + MID_LANG_PARA_2, + MID_LANG_PARA_3, + MID_LANG_PARA_4, + MID_LANG_PARA_5, + MID_LANG_PARA_6, + MID_LANG_PARA_7, + MID_LANG_PARA_8, + MID_LANG_PARA_9, + MID_LANG_PARA_NONE, + MID_LANG_PARA_RESET, + MID_LANG_PARA_MORE, +}; + +inline bool IsScriptTypeMatchingToLanguage( SvtScriptType nScriptType, LanguageType nLang ) +{ + return bool(nScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage( nLang )); +} + +inline void RetrieveTypeNameFromResourceURL( const OUString& aResourceURL, OUString& aType, OUString& aName ) +{ + static const char RESOURCEURL_PREFIX[] = "private:resource/"; + static const sal_Int32 RESOURCEURL_PREFIX_SIZE = strlen(RESOURCEURL_PREFIX); + + if (aResourceURL.startsWith( RESOURCEURL_PREFIX )) + { + sal_Int32 nIdx{ RESOURCEURL_PREFIX_SIZE }; + while (nIdx<aResourceURL.getLength() && aResourceURL[nIdx]=='/') ++nIdx; + if (nIdx>=aResourceURL.getLength()) + return; + aType = aResourceURL.getToken(0, '/', nIdx); + if (nIdx<0) + return; + while (nIdx<aResourceURL.getLength() && aResourceURL[nIdx]=='/') ++nIdx; + if (nIdx>=aResourceURL.getLength()) + return; + aName = aResourceURL.getToken(0, '/', nIdx); + } +} + +class LanguageGuessingHelper +{ + mutable css::uno::Reference< css::linguistic2::XLanguageGuessing > m_xLanguageGuesser; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + +public: + LanguageGuessingHelper(const css::uno::Reference< css::uno::XComponentContext >& _xContext) : m_xContext(_xContext){} + + css::uno::Reference< css::linguistic2::XLanguageGuessing > const & GetGuesser() const; +}; + +FWI_DLLPUBLIC void FillLangItems( std::set< OUString > &rLangItems, + const css::uno::Reference< css::frame::XFrame > &rxFrame, + const LanguageGuessingHelper & rLangGuessHelper, + SvtScriptType nScriptType, + const OUString & rCurLang, + const OUString & rKeyboardLang, + const OUString & rGuessedTextLang ); + +//It's common for an object to want to create and own a Broadcaster and set +//itself as a Listener on its own Broadcaster member. + +//However, calling addListener on a Broadcaster means that the Broadcaster adds +//a reference to the Listener leading to an ownership cycle where the Listener +//owns the Broadcaster which "owns" the Listener. + +//The WeakContainerListener allows breaking this cycle and retrofitting +//afflicted implementations fairly easily. + +//OriginalListener owns the Broadcaster which "owns" the WeakContainerListener +//which forwards the events to the OriginalListener without taking ownership of +//it. +class WeakContainerListener final : public ::cppu::WeakImplHelper<css::container::XContainerListener> +{ + private: + css::uno::WeakReference<css::container::XContainerListener> mxOwner; + + public: + WeakContainerListener(css::uno::Reference<css::container::XContainerListener> const & xOwner) + : mxOwner(xOwner) + { + } + + // container.XContainerListener + virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override + { + css::uno::Reference<css::container::XContainerListener> xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->elementInserted(rEvent); + } + + virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override + { + css::uno::Reference<css::container::XContainerListener> xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->elementRemoved(rEvent); + } + + virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override + { + css::uno::Reference<css::container::XContainerListener> xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->elementReplaced(rEvent); + } + + // lang.XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent) override + { + css::uno::Reference<css::container::XContainerListener> xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->disposing(rEvent); + + } +}; + +class WeakChangesListener final : public ::cppu::WeakImplHelper<css::util::XChangesListener> +{ + private: + css::uno::WeakReference<css::util::XChangesListener> mxOwner; + + public: + WeakChangesListener(css::uno::Reference<css::util::XChangesListener> const & xOwner) + : mxOwner(xOwner) + { + } + + // util.XChangesListener + virtual void SAL_CALL changesOccurred(const css::util::ChangesEvent& rEvent) override + { + css::uno::Reference<css::util::XChangesListener> xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->changesOccurred(rEvent); + } + + // lang.XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent) override + { + css::uno::Reference<css::util::XChangesListener> xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->disposing(rEvent); + + } +}; + +class WeakDocumentEventListener final : public ::cppu::WeakImplHelper<css::document::XDocumentEventListener> +{ + private: + css::uno::WeakReference<css::document::XDocumentEventListener> mxOwner; + + public: + WeakDocumentEventListener(css::uno::Reference<css::document::XDocumentEventListener> const & xOwner) + : mxOwner(xOwner) + { + } + + virtual void SAL_CALL documentEventOccured(const css::document::DocumentEvent& rEvent) override + { + css::uno::Reference<css::document::XDocumentEventListener> xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->documentEventOccured(rEvent); + + } + + // lang.XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent) override + { + css::uno::Reference<css::document::XDocumentEventListener> xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->disposing(rEvent); + + } +}; + +FWI_DLLPUBLIC css::uno::Reference<css::ui::XContextChangeEventListener> +GetFirstListenerWith_Impl( + css::uno::Reference<css::uno::XInterface> const& xEventFocus, + std::function<bool (css::uno::Reference<css::ui::XContextChangeEventListener> const&)> const& rPredicate); + +FWI_DLLPUBLIC extern auto (*g_pGetMultiplexerListener)( + css::uno::Reference<css::uno::XInterface> const&, + std::function<bool (css::uno::Reference<css::ui::XContextChangeEventListener> const&)> const&) + -> css::uno::Reference<css::ui::XContextChangeEventListener>; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_MISCHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/ocomponentaccess.hxx b/framework/inc/helper/ocomponentaccess.hxx new file mode 100644 index 000000000..ed11756c0 --- /dev/null +++ b/framework/inc/helper/ocomponentaccess.hxx @@ -0,0 +1,164 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_OCOMPONENTACCESS_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_OCOMPONENTACCESS_HXX + +#include <com/sun/star/frame/XFramesSupplier.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XEnumeration.hpp> +#include <com/sun/star/frame/XDesktop.hpp> +#include <com/sun/star/lang/XComponent.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> +#include <vector> + +namespace framework{ + +/*-************************************************************************************************************ + @short implement XEnumerationAccess interface as helper to create many oneway enumeration of components + @descr We share mutex and framecontainer with our owner and have full access to its child tasks. + (Our owner can be the Desktop only!) We create oneway enumerations on demand. These "lists" + can be used for one time only. Step during the list from first to last element. + (The type of created enumerations is OComponentEnumeration.) + + @implements XInterface + XTypeProvider + XEnumerationAccess + XElementAccess + + @base OWeakObject + + @devstatus ready to use +*//*-*************************************************************************************************************/ + +class OComponentAccess final : public ::cppu::WeakImplHelper< css::container::XEnumerationAccess > +{ + + // public methods + + public: + + // constructor / destructor + + /*-**************************************************************************************************** + @short constructor to initialize this instance + @descr A desktop will create an enumeration-access-object. An enumeration is a oneway-list and a + snapshot of the components of current tasks under the desktop. + But we need an instance to create more than one enumerations at different times! + + @seealso class Desktop + @seealso class OComponentEnumeration + + @param "xOwner" is a reference to our owner and must be the desktop! + @onerror Do nothing and reset this object to default with an empty list. + *//*-*****************************************************************************************************/ + + OComponentAccess( const css::uno::Reference< css::frame::XDesktop >& xOwner ); + + // XEnumerationAccess + + /*-**************************************************************************************************** + @short create a new enumeration of components + @descr You can call this method to get a new snapshot from all components of all tasks of the desktop as an enumeration. + + @seealso interface XEnumerationAccess + @seealso interface XEnumeration + @seealso class Desktop + @return If the desktop and some components exist => a valid reference to an enumeration<BR> + An NULL-reference, other way. + *//*-*****************************************************************************************************/ + + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override; + + // XElementAccess + + /*-**************************************************************************************************** + @short get the type of elements in enumeration + @seealso interface XElementAccess + @seealso class OComponentEnumeration + @return The uno-type XComponent. + *//*-*****************************************************************************************************/ + + virtual css::uno::Type SAL_CALL getElementType() override; + + /*-**************************************************************************************************** + @short get state of componentlist of enumeration. + @seealso interface XElementAccess + @return sal_True ,if more than 0 elements exist. + @return sal_False ,otherwise. + *//*-*****************************************************************************************************/ + + virtual sal_Bool SAL_CALL hasElements() override; + + // protected methods + + private: + + /*-**************************************************************************************************** + @short standard destructor + @descr This method destruct an instance of this class and clear some member. + Don't use an instance of this class as normal member. Use it dynamically with a pointer. + We hold a weakreference to our owner and not to our superclass! + That's the reason for a protected dtor. + + @seealso class Desktop + *//*-*****************************************************************************************************/ + + virtual ~OComponentAccess() override; + + + /*-**************************************************************************************************** + @short recursive method (!) to collect all components of all frames from the subtree of given node + @descr This is necessary to create the enumeration. + + @seealso method createEnumeration + + @param "xNode" , root of subtree and start point of search + @param "seqComponents", result list of search. We can't use a return value, we search recursive + and must collect all information. + *//*-*****************************************************************************************************/ + + void impl_collectAllChildComponents( const css::uno::Reference< css::frame::XFramesSupplier >& xNode , + std::vector< css::uno::Reference< css::lang::XComponent > >& seqComponents ); + + /*-**************************************************************************************************** + @short get the component of a frame + @descr The component of a frame can be the window, the controller or the model. + + @seealso method createEnumeration + + @param "xFrame", frame which contains the component + @return A reference to the component of given frame. + + @onerror A null reference is returned. + *//*-*****************************************************************************************************/ + + css::uno::Reference< css::lang::XComponent > impl_getFrameComponent( const css::uno::Reference< css::frame::XFrame >& xFrame ) const; + + css::uno::WeakReference< css::frame::XDesktop > m_xOwner; /// weak reference to the desktop object! + +}; // class OComponentAccess + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_OCOMPONENTACCESS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/ocomponentenumeration.hxx b/framework/inc/helper/ocomponentenumeration.hxx new file mode 100644 index 000000000..10de97dd5 --- /dev/null +++ b/framework/inc/helper/ocomponentenumeration.hxx @@ -0,0 +1,163 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_OCOMPONENTENUMERATION_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_OCOMPONENTENUMERATION_HXX + +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/container/XEnumeration.hpp> +#include <com/sun/star/lang/XComponent.hpp> + +#include <cppuhelper/implbase.hxx> +#include <vector> + +namespace framework{ + +/*-************************************************************************************************************ + @short implement a helper for a oneway enumeration of components + @descr You can step during this list only for one time! It's a snapshot. + Don't forget to release the reference. You are the owner of an instance of this implementation. + You can't use this as a baseclass. Please use it as a dynamical object for return. + + @implements XInterface + XTypeProvider + XEventListener + XEnumeration + + @base OWeakObject + + @devstatus ready to use + @threadsafe yes +*//*-*************************************************************************************************************/ + +class OComponentEnumeration final : public ::cppu::WeakImplHelper< css::container::XEnumeration,css::lang::XEventListener > +{ + + // public methods + + public: + + // constructor / destructor + + /*-**************************************************************************************************** + @short constructor to initialize this enumeration + @descr An enumeration is a list with oneway-access! You can get every member only for one time. + This method allow to initialize this oneway list with values. + @param "seqComponents" is a sequence of interfaces, which are components. + @onerror Do nothing and reset this object to default with an empty list. + *//*-*****************************************************************************************************/ + + OComponentEnumeration( const std::vector< css::uno::Reference< css::lang::XComponent > >& seqComponents ); + + // XEventListener + + /*-**************************************************************************************************** + @short last chance to release all references and free memory + @descr This method is called, if the enumeration is used completely and has no more elements. + Then we must destroy our list and release all references to other objects. + + @seealso interface XEventListener + + @param "aEvent" describe the source of this event. + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override; + + // XEnumeration + + /*-**************************************************************************************************** + @short check count of accessible elements of enumeration + @descr You can call this method to get information about accessible elements in future. + Elements you have already gotten are not accessible! + + @seealso interface XEnumeration + @return sal_True = if more elements accessible<BR> + sal_False = other way + + @onerror sal_False<BR> + (List is empty and there no accessible elements ...) + *//*-*****************************************************************************************************/ + + virtual sal_Bool SAL_CALL hasMoreElements() override; + + /*-**************************************************************************************************** + @short give the next element, if some exist + @descr If a call "hasMoreElements()" return true, you can get the next element of list. + + @seealso interface XEnumeration + @return A Reference to a component, safed in an Any-structure. + + @onerror If end of enumeration is arrived or there are no elements in list => a NoSuchElementException is thrown. + *//*-*****************************************************************************************************/ + + virtual css::uno::Any SAL_CALL nextElement() override; + + // protected methods + + private: + + /*-**************************************************************************************************** + @short standard destructor + @descr This method destruct an instance of this class and clear some member. + We make it protected, because it's not supported to use this class as normal instance! + You must create it dynamical in memory and use a pointer. + *//*-*****************************************************************************************************/ + + virtual ~OComponentEnumeration() override; + + /*-**************************************************************************************************** + @short reset instance to default values + + @descr There are two ways to delete an instance of this class.<BR> + 1) delete with destructor<BR> + 2) dispose from parent or factory ore ...<BR> + This method do the same for both ways! It free used memory and release references ... + + @seealso method dispose() + @seealso destructor ~TaskEnumeration() + *//*-*****************************************************************************************************/ + + void impl_resetObject(); + + + // debug methods + // (should be private everyway!) + + /*-**************************************************************************************************** + @short debug-method to check incoming parameter of some other methods of this class + @descr The following methods are used to check parameters for other methods + of this class. The return value is used directly for an ASSERT(...). + + @seealso ASSERT in implementation! + + @param references to checking variables + @return sal_False on invalid parameter<BR> + sal_True otherway + *//*-*****************************************************************************************************/ + + sal_uInt32 m_nPosition; /// current position in enumeration + std::vector< css::uno::Reference< css::lang::XComponent > > m_seqComponents; /// list of current components + +}; // class OComponentEnumeration + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_OCOMPONENTENUMERATION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/oframes.hxx b/framework/inc/helper/oframes.hxx new file mode 100644 index 000000000..1da482c4e --- /dev/null +++ b/framework/inc/helper/oframes.hxx @@ -0,0 +1,193 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_OFRAMES_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_OFRAMES_HXX + +#include <classes/framecontainer.hxx> + +#include <com/sun/star/frame/XFrames.hpp> +#include <com/sun/star/frame/XFrame.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +namespace framework{ + +/** + @short implement XFrames, XIndexAccess and XElementAccess interfaces as helper for services + @descr Use this class as helper for these interfaces. We share mutex and framecontainer with our owner. + The framecontainer is a member of it from type "FrameContainer". That means; + we have the same information as our owner. In current implementation we use mutex and lock-mechanism + to prevent against compete access. In future we plan support of semaphore! + + @devstatus deprecated + + @ATTENTION Don't use this class as direct member - use it dynamically. Do not derive from this class. + We hold a weakreference to our owner not to our superclass. +*/ +class OFrames final : public ::cppu::WeakImplHelper< css::frame::XFrames > +{ + public: + + /** + @short standard ctor + @descr These initialize a new instance of this class with all needed information for work. + We share framecontainer with owner implementation! It's a threadsafe container. + @param xOwner , reference to our owner. We hold a wekreference to prevent us against cross-references! + @param pFrameContainer , pointer to shared framecontainer of owner. It's valid only, if weakreference is valid! + */ + OFrames( const css::uno::Reference< css::frame::XFrame >& xOwner , + FrameContainer* pFrameContainer ); + + // XFrames + + /** + @short append frame to container + @descr We share the container with our owner. We can do this only, if no lock is set on container. + Valid references are accepted only! + + @seealso class FrameContainer + + @param "xFrame", reference to an existing frame to append. + @onerror We do nothing in release or throw an assert in debug version. + */ + virtual void SAL_CALL append( const css::uno::Reference< css::frame::XFrame >& xFrame ) override; + + /** + @short remove frame from container + @descr This is the companion to append(). We only accept valid references and don't work, if + a lock is set. + + @seealso class FrameContainer + + @param "xFrame", reference to an existing frame to remove. + @onerror We do nothing in release or throw an assert in debug version. + */ + virtual void SAL_CALL remove( const css::uno::Reference< css::frame::XFrame >& xFrame ) override; + + /** + @short return list of all applicable frames for given flags + @descr Call these to get a list of all frames, which are match with given search flags. + @param "nSearchFlag", flags to search right frames. + @return A list of founded frames. + + @onerror An empty list is returned. + */ + virtual css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > SAL_CALL queryFrames( sal_Int32 nSearchFlags ) override; + + // XIndexAccess + + /** + @short get count of all current frames in container + @descr This is the beginning of full index-access. With a count you can step over all items in container. + Next call should be getByIndex(). But these mechanism works only, if no lock in container is set! + + @seealso class FrameContainer + @seealso method getByIndex() + @return Count of current items in container. + + @onerror If a lock is set, we return 0 for prevent further access! + */ + virtual sal_Int32 SAL_CALL getCount() override; + + /** + @short get specified container item by index + @descr If you called getCount() successful - this method return the specified element as an Any. + You must observe the range from 0 to count-1! Otherwise an IndexOutOfBoundsException is thrown. + + @seealso class FrameContainer + @seealso method getCount() + + @param "nIndex", valid index to get container item. + @return A container item (specified by index) wrapped in an Any. + + @onerror If a lock is set, we return an empty Any! + @onerror If index out of range, an IndexOutOfBoundsException is thrown. + */ + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) override; + + // XElementAccess + + /** + @short get uno-type of all container items + @descr In current implementation type is fixed to XFrame! + (container-lock is ignored) + @return A uno-type descriptor. + */ + virtual css::uno::Type SAL_CALL getElementType() override; + + /** + @short get fill state of current container + @descr Call these to get information about, if items exist in container or not. + (container-lock is ignored) + @return sal_True, if container contains some items. + @return sal_False, otherwise. + + @onerror We return sal_False. + */ + virtual sal_Bool SAL_CALL hasElements() override; + + private: + + /** + @short standard destructor + @descr This method destruct an instance of this class and clear some member. + This method is protected, because it's not allowed to use this class as a member! + You MUST use a dynamical instance (pointer). That's the reason for a protected dtor. + */ + virtual ~OFrames() override; + + /** + @short reset instance to default values + @descr There are two ways to delete an instance of this class.<BR> + 1) delete with destructor<BR> + 2) dispose from parent or factory ore ...<BR> + This method do the same for both ways! It free used memory and release references ... + + @seealso method dispose() (if it exist!) + @seealso destructor ~TaskEnumeration() + */ + void impl_resetObject(); + + /** + @short append one sequence to another + @descr There is no operation to add to sequences! Use this helper-method to do this. + + @seealso class Sequence + + @param "seqDestination", reference to sequence on which operation will append the other sequence. + @param "seqSource" , reference to sequence for append. + @return "seqDestination" is parameter AND return value at the same time. + */ + void impl_appendSequence( css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >& seqDestination , + const css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >& seqSource ); + + static bool impldbg_checkParameter_queryFrames ( sal_Int32 nSearchFlags ); + + css::uno::WeakReference< css::frame::XFrame > m_xOwner; /// reference to owner of this instance (Hold no hard reference!) + FrameContainer* m_pFrameContainer; /// with owner shared list to hold all direct children of an XFramesSupplier + bool m_bRecursiveSearchProtection; /// flag to protect against recursive searches of frames at parents +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/persistentwindowstate.hxx b/framework/inc/helper/persistentwindowstate.hxx new file mode 100644 index 000000000..f467ef9a2 --- /dev/null +++ b/framework/inc/helper/persistentwindowstate.hxx @@ -0,0 +1,165 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_PERSISTENTWINDOWSTATE_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_PERSISTENTWINDOWSTATE_HXX + +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +namespace framework{ + +/*-************************************************************************************************************ + @short listener for closing document frames to make her window state persistent + @descr It's a feature of our office. If a document window was created by ourself (and not from + any external process e.g. the office bean) we save and restore the window state of it + corresponding to the document service factory. That means: one instance of this class will be + a listener on one frame which container window was created by ourself. + We listen for frame action events and every time a component will deattached from a frame + we store its current position and size to the configuration. Every time a new component is + attached to a frame first time(!) we restore this information again. + + @base OWeakObject + implements ref counting for this class. + + @devstatus ready + @threadsafe yes +*//*-*************************************************************************************************************/ +class PersistentWindowState final : public ::cppu::WeakImplHelper< + css::lang::XInitialization, + css::frame::XFrameActionListener > // => XEventListener +{ + + // member + + private: + + /// may we need a uno service manager to create own services + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /// reference to the frame which was created by the office himself + css::uno::WeakReference< css::frame::XFrame > m_xFrame; + + /// we call SetWindowState one times only for the same frame! + bool m_bWindowStateAlreadySet; + + // interface + + public: + + // ctor/dtor + PersistentWindowState(const css::uno::Reference< css::uno::XComponentContext >& xContext); + virtual ~PersistentWindowState( ) override; + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments) override; + + // XFrameActionListener + virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) override; + + // XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override; + + // helper + + private: + + /** @short identify the application module, which is used behind the component + of our frame. + + @param rxContext + needed to create needed uno resources. + + @param xFrame + contains the component, which must be identified. + + @return [string] + a module identifier for the current frame component. + */ + static OUString implst_identifyModule(const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& xFrame); + + /** @short retrieve the window state from the configuration. + + @param rxContext + needed to create the configuration access. + + @param sModuleName + identifies the application module, where the + information should be obtained for. + + @return [string] + contains the information about position and size. + */ + static OUString implst_getWindowStateFromConfig(const css::uno::Reference< css::uno::XComponentContext >& rxContext , + const OUString& sModuleName); + + /** @short retrieve the window state from the container window. + + @param xWindow + must point to the container window of the frame. + We use it VCL part here - because the toolkit doesn't + provide the right functionality! + + @return [string] + contains the information about position and size. + */ + static OUString implst_getWindowStateFromWindow(const css::uno::Reference< css::awt::XWindow >& xWindow); + + /** @short restore the position and size on the container window. + + @param rxContext + needed to create the configuration access. + + @param sModuleName + identifies the application module, where the + information should be set on. + + @param sWindowState + contains the information about position and size. + */ + static void implst_setWindowStateOnConfig(const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const OUString& sModuleName , + const OUString& sWindowState ); + + /** @short restore the position and size on the container window. + + @param xWindow + must point to the container window of the frame. + We use it VCL part here - because the toolkit doesn't + provide the right functionality! + + @param sWindowState + contains the information about position and size. + */ + static void implst_setWindowStateOnWindow(const css::uno::Reference< css::awt::XWindow >& xWindow , + const OUString& sWindowState); + +}; // class PersistentWindowState + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_PERSISTENTWINDOWSTATE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/propertysetcontainer.hxx b/framework/inc/helper/propertysetcontainer.hxx new file mode 100644 index 000000000..f5f649730 --- /dev/null +++ b/framework/inc/helper/propertysetcontainer.hxx @@ -0,0 +1,78 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_PROPERTYSETCONTAINER_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_PROPERTYSETCONTAINER_HXX + +/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble + with solaris headers ... +*/ +#include <vector> +#include <cppuhelper/weak.hxx> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <framework/fwedllapi.h> + +namespace framework +{ + +class PropertySetContainer : public css::container::XIndexContainer , + public ::cppu::OWeakObject +{ + public: + PropertySetContainer(); + virtual ~PropertySetContainer() override; + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + virtual void SAL_CALL acquire() throw () override; + virtual void SAL_CALL release() throw () override; + + // XIndexContainer + virtual void SAL_CALL insertByIndex( sal_Int32 Index, const css::uno::Any& Element ) override; + + virtual void SAL_CALL removeByIndex( sal_Int32 Index ) override; + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const css::uno::Any& Element ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override + { + return cppu::UnoType<css::beans::XPropertySet>::get(); + } + + virtual sal_Bool SAL_CALL hasElements() override; + + private: + typedef std::vector< css::uno::Reference< css::beans::XPropertySet > > PropertySetVector; + PropertySetVector m_aPropertySetVector; + +}; + +} + +#endif // __FRAMEWORK_CLASSES_PROPERTYSETCONTAINER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/shareablemutex.hxx b/framework/inc/helper/shareablemutex.hxx new file mode 100644 index 000000000..9470983fb --- /dev/null +++ b/framework/inc/helper/shareablemutex.hxx @@ -0,0 +1,94 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_SHAREABLEMUTEX_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_SHAREABLEMUTEX_HXX + +#include <osl/interlck.h> +#include <osl/mutex.hxx> +#include <fwidllapi.h> + +namespace framework +{ + +/** + * This acts like a rtl::Reference<osl::Mutex> + */ +class ShareableMutex +{ + public: + ShareableMutex(); + ShareableMutex( const ShareableMutex& rShareableMutex ); + ShareableMutex& operator=( const ShareableMutex& rShareableMutex ); + + ~ShareableMutex() { m_pMutexRef->release(); } + + /** acquire the shared mutex */ + void acquire(); + /** release the shared mutex */ + void release(); + + private: + /* ShareableMutex::MutexRef will destroy itself when the last ShareableMutex pointing to it is destroyed */ + struct MutexRef + { + MutexRef() : m_refCount(0) {} + void acquire() + { + osl_atomic_increment( &m_refCount ); + } + + void release() + { + if ( osl_atomic_decrement( &m_refCount ) == 0 ) + delete this; + } + + oslInterlockedCount m_refCount; + osl::Mutex m_oslMutex; + }; + + MutexRef* m_pMutexRef; +}; + +class ShareGuard +{ + public: + explicit ShareGuard( ShareableMutex& rShareMutex ) : + m_rShareMutex( rShareMutex ) + { + m_rShareMutex.acquire(); + } + + ~ShareGuard() + { + m_rShareMutex.release(); + } + + private: + ShareGuard& operator=( const ShareGuard& ) = delete; + + ShareableMutex& m_rShareMutex; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_SHAREABLEMUTEX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/statusindicator.hxx b/framework/inc/helper/statusindicator.hxx new file mode 100644 index 000000000..66d5b1e75 --- /dev/null +++ b/framework/inc/helper/statusindicator.hxx @@ -0,0 +1,106 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_STATUSINDICATOR_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_STATUSINDICATOR_HXX + +// include files of own module +#include <helper/statusindicatorfactory.hxx> + +// include UNO interfaces +#include <com/sun/star/task/XStatusIndicator.hpp> + +// include all others +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +namespace framework{ + +/** + @short implement a status indicator object + + @descr With this indicator you can show a message and a progress... + but you share the output device with other indicator objects, + if this instances was created by the same factory. + Then the last created object has full access to device. + All others change her internal data structure only. + + All objects of this StatusIndicator class calls a C++ interface + on the StatusIndicatorFactory (where they were created). + The factory holds all data structures and paints the progress. + + @devstatus ready to use + @threadsafe yes +*/ +class StatusIndicator final : public ::cppu::WeakImplHelper< css::task::XStatusIndicator > +{ + + // member + private: + + /** @short weak reference to our factory + @descr All our interface calls will be forwarded + to a suitable c++ interface on this factory. + But we don't hold our factory alive. They + correspond with e.g. with a Frame service and + will be owned by him. If the frame will be closed + he close our factory too ... + */ + css::uno::WeakReference< css::task::XStatusIndicatorFactory > m_xFactory; + + sal_Int32 m_nRange; + // We want the callback percentages to increase monotonically + int m_nLastCallbackPercent; + + // c++ interface + public: + + /** @short initialize new instance of this class. + + @param pFactory + pointer to our factory + */ + StatusIndicator(StatusIndicatorFactory* pFactory); + + /** @short does nothing real... + */ + virtual ~StatusIndicator() override; + + // uno interface + public: + + // XStatusIndicator + virtual void SAL_CALL start(const OUString& sText , + sal_Int32 nRange) override; + + virtual void SAL_CALL end() override; + + virtual void SAL_CALL reset() override; + + virtual void SAL_CALL setText(const OUString& sText) override; + + virtual void SAL_CALL setValue(sal_Int32 nValue) override; + +}; // class StatusIndicator + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_STATUSINDICATOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/statusindicatorfactory.hxx b/framework/inc/helper/statusindicatorfactory.hxx new file mode 100644 index 000000000..c16f1eb37 --- /dev/null +++ b/framework/inc/helper/statusindicatorfactory.hxx @@ -0,0 +1,273 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_STATUSINDICATORFACTORY_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_STATUSINDICATORFACTORY_HXX + +// Attention: stl headers must(!) be included at first. Otherwise it can make trouble +// with solaris headers ... +#include <vector> + +// include files of own module +#include <helper/wakeupthread.hxx> + +// include uno interfaces +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/task/XStatusIndicatorFactory.hpp> +#include <com/sun/star/task/XStatusIndicator.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/util/XUpdatable.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/supportsservice.hxx> +#include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> + +namespace framework{ + +/** + @descr This struct hold some information about all currently running progress processes. + Because the can be used on a stack, we must cache her states but must paint only + the top most one. + */ +struct IndicatorInfo +{ + + // member + public: + + /** @short points to the indicator child, where we hold its states + alive here. */ + css::uno::Reference< css::task::XStatusIndicator > m_xIndicator; + + /** @short the last set text for this indicator */ + OUString m_sText; + + /** @short the last set value for this indicator */ + sal_Int32 m_nValue; + + // interface + public: + + /** @short initialize new instance of this class + + @param xIndicator + the new child indicator of our factory. + + @param sText + its initial text. + + @param nRange + the max range for this indicator. + */ + IndicatorInfo(const css::uno::Reference< css::task::XStatusIndicator >& xIndicator, + const OUString& sText ) + { + m_xIndicator = xIndicator; + m_sText = sText; + m_nValue = 0; + } + + /** @short Used to locate an info struct inside a stl structure... + + @descr The indicator object itself is used as key. Its values + are not interesting then. Because more than one child + indicator can use the same values... + */ + bool operator==(const css::uno::Reference< css::task::XStatusIndicator >& xIndicator) const + { + return (m_xIndicator == xIndicator); + } +}; + +/** @descr Define a list of child indicator objects and its data. */ +typedef ::std::vector< IndicatorInfo > IndicatorStack; + +/** @short implement a factory service to create new status indicator objects + + @descr Internally it uses: + - a vcl based + - or a uno based and by the frame layouted + progress implementation. + + This factory create different indicators and control his access + to a shared output device! Only the last activated component + can write its state to this device. All other requests will be + cached only. + + @devstatus ready to use + @threadsafe yes + */ +class StatusIndicatorFactory final : public ::cppu::WeakImplHelper< + css::lang::XServiceInfo + , css::lang::XInitialization + , css::task::XStatusIndicatorFactory + , css::util::XUpdatable > +{ + + // member + private: + osl::Mutex m_mutex; + + /** stack with all current indicator children. */ + IndicatorStack m_aStack; + + /** uno service manager to create own needed uno resources. */ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /** most active indicator child, which could work with our shared indicator window only. */ + css::uno::Reference< css::task::XStatusIndicator > m_xActiveChild; + + /** used to show the progress on the frame (layouted!) or + as a plugged vcl window. */ + css::uno::Reference< css::task::XStatusIndicator > m_xProgress; + + /** points to the frame, where we show the progress (in case + m_xProgress points to a frame progress. */ + css::uno::WeakReference< css::frame::XFrame > m_xFrame; + + /** points to an outside window, where we show the progress (in case + we are plugged into such window). */ + css::uno::WeakReference< css::awt::XWindow > m_xPluggWindow; + + /** Notify us if a fix time is over. We use it to implement an + intelligent "Reschedule" ... */ + rtl::Reference<WakeUpThread> m_pWakeUp; + + /** Our WakeUpThread calls us in our interface method "XUpdatable::update(). + There we set this member m_bAllowReschedule to sal_True. Next time if our impl_reschedule() + method is called, we know, that an Application::Reschedule() should be made. + Because the last made Reschedule can be was taken long time ago ... may be.*/ + bool m_bAllowReschedule; + + /** enable/disable automatic showing of our parent window. */ + bool m_bAllowParentShow; + + /** enable/disable rescheduling. Default=enabled*/ + bool m_bDisableReschedule; + + /** prevent recursive calling of Application::Reschedule(). */ + static sal_Int32 m_nInReschedule; + + // interface + + public: + StatusIndicatorFactory(const css::uno::Reference< css::uno::XComponentContext >& xContext); + + virtual OUString SAL_CALL getImplementationName() override + { + return "com.sun.star.comp.framework.StatusIndicatorFactory"; + } + + virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override + { + return cppu::supportsService(this, ServiceName); + } + + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override + { + css::uno::Sequence< OUString > aSeq { "com.sun.star.task.StatusIndicatorFactory" }; + return aSeq; + } + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments) override; + + // XStatusIndicatorFactory + virtual css::uno::Reference< css::task::XStatusIndicator > SAL_CALL createStatusIndicator() override; + + // XUpdatable + virtual void SAL_CALL update() override; + + // similar (XStatusIndicator) + void start(const css::uno::Reference< css::task::XStatusIndicator >& xChild, + const OUString& sText , + sal_Int32 nRange); + + void reset(const css::uno::Reference< css::task::XStatusIndicator >& xChild); + + void end(const css::uno::Reference< css::task::XStatusIndicator >& xChild); + + void setText(const css::uno::Reference< css::task::XStatusIndicator >& xChild, + const OUString& sText ); + + void setValue(const css::uno::Reference< css::task::XStatusIndicator >& xChild, + sal_Int32 nValue); + + // specials + + private: + + virtual ~StatusIndicatorFactory() override; + + // helper + + /** @short show the parent window of this progress ... + if it's allowed to do so. + + @descr By default we show the parent window automatically + if this progress is used. + If that isn't a valid operation, the user of this + progress can suppress this feature by initializing + us with a special parameter. + + @seealso initialize() + */ + void implts_makeParentVisibleIfAllowed(); + + /** @short creates a new internal used progress. + @descr This factory does not paint the progress itself. + It uses helper for that. They can be vcl based or + layouted by the frame and provided as a uno interface. + */ + void impl_createProgress(); + + /** @short shows the internal used progress. + @descr This factory does not paint the progress itself. + It uses helper for that. They can be vcl based or + layouted by the frame and provided as a uno interface. + */ + void impl_showProgress(); + + /** @short hides the internal used progress. + @descr This factory does not paint the progress itself. + It uses helper for that. They can be vcl based or + layouted by the frame and provided as a uno interface. + */ + void impl_hideProgress(); + + /** @short try to "share the current thread in an intelligent manner" :-) + + @param Overwrites our algorithm for Reschedule and force it to be sure + that our progress was painted right. + */ + void impl_reschedule(bool bForceUpdate); + + void impl_startWakeUpThread(); + void impl_stopWakeUpThread(); + +}; // class StatusIndicatorFactory + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_STATUSINDICATORFACTORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/tagwindowasmodified.hxx b/framework/inc/helper/tagwindowasmodified.hxx new file mode 100644 index 000000000..f466803a0 --- /dev/null +++ b/framework/inc/helper/tagwindowasmodified.hxx @@ -0,0 +1,96 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_TAGWINDOWASMODIFIED_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_TAGWINDOWASMODIFIED_HXX + +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +namespace framework{ + +/*-************************************************************************************************************ + @short listen for modify events on model and tag frame container window so it can react accordingly + @descr Used e.g. by our MAC port where such state is shown separately on some controls of the + title bar. + + @base OWeakObject + implements ref counting for this class. + + @devstatus draft + @threadsafe yes +*//*-*************************************************************************************************************/ +class TagWindowAsModified final : public ::cppu::WeakImplHelper< + css::lang::XInitialization, + css::frame::XFrameActionListener, // => XEventListener + css::util::XModifyListener > // => XEventListener +{ + + // member + + private: + + /// reference to the frame, where we listen for new loaded documents for updating our own xModel reference + css::uno::WeakReference< css::frame::XFrame > m_xFrame; + + /// reference to the frame container window, where we must set the tag + css::uno::WeakReference< css::awt::XWindow > m_xWindow; + + /// we list on the model for modify events + css::uno::WeakReference< css::frame::XModel > m_xModel; + + // interface + + public: + + // ctor/dtor + TagWindowAsModified(); + virtual ~TagWindowAsModified( ) override; + + // XInterface, XTypeProvider + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments) override; + + // XModifyListener + virtual void SAL_CALL modified(const css::lang::EventObject& aEvent) override; + + // XFrameActionListener + virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) override; + + // XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override; + + private: + + // @todo document me + void impl_update(const css::uno::Reference< css::frame::XFrame >& xFrame); + +}; // class TagWindowAsModified + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_TAGWINDOWASMODIFIED_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/titlebarupdate.hxx b/framework/inc/helper/titlebarupdate.hxx new file mode 100644 index 000000000..c06d23976 --- /dev/null +++ b/framework/inc/helper/titlebarupdate.hxx @@ -0,0 +1,145 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_TITLEBARUPDATE_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_TITLEBARUPDATE_HXX + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/frame/XTitleChangeListener.hpp> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +namespace framework{ + +/*-************************************************************************************************************ + @short helps our frame on setting title/icon on the titlebar (including updates) + + @devstatus draft + @threadsafe yes +*//*-*************************************************************************************************************/ +class TitleBarUpdate final : public ::cppu::WeakImplHelper< + css::lang::XInitialization + , css::frame::XTitleChangeListener // => XEventListener + , css::frame::XFrameActionListener > // => XEventListener +{ + + // structs, types + + private: + + struct TModuleInfo + { + /// internal id of this module + OUString sID; + /// configured icon for this module + ::sal_Int32 nIcon; + }; + + // member + + private: + + /// may we need a uno service manager to create own services + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /// reference to the frame which was created by the office himself + css::uno::WeakReference< css::frame::XFrame > m_xFrame; + + // interface + + public: + + // ctor/dtor + TitleBarUpdate(const css::uno::Reference< css::uno::XComponentContext >& xContext); + virtual ~TitleBarUpdate( ) override; + + // XInterface, XTypeProvider + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments) override; + + // XFrameActionListener + virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) override; + + // XTitleChangeListener + virtual void SAL_CALL titleChanged(const css::frame::TitleChangedEvent& aEvent) override; + + // XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override; + + // helper + + private: + + /** @short identify the application module, which is used behind the component + of our frame. + + @param xFrame + contains the component, which must be identified. + + @param rInfo + describe the module in its details. + Is set only if return value is true. + + @return [sal_Bool] + sal_True in case module could be identified and all needed values could be read. + sal_False otherwise. + */ + bool implst_getModuleInfo(const css::uno::Reference< css::frame::XFrame >& xFrame, + TModuleInfo& rInfo ); + + /** @short set a new icon and title on the title bar of our connected frame window. + + @descr It does not check if an update is really needed. That has to be done outside. + It retrieves all needed information and update the title bar - nothing less - + nothing more. + */ + void impl_forceUpdate(); + + /** @short identify the current component (inside the connected frame) + and set the right module icon on the title bar. + + @param xFrame + the frame which contains the component and where the icon must be set + on the window title bar. + */ + void impl_updateIcon(const css::uno::Reference< css::frame::XFrame >& xFrame); + + /** @short gets the current title from the frame and set it on the window. + + @param xFrame + the frame which contains the component and where the title must be set + on the window title bar. + */ + void impl_updateTitle(const css::uno::Reference< css::frame::XFrame >& xFrame); + + //Hook to set GNOME3/Windows 7 applicationID for toplevel frames + //http://msdn.microsoft.com/en-us/library/dd378459(v=VS.85).aspx + //http://live.gnome.org/GnomeShell/ApplicationBased + void impl_updateApplicationID(const css::uno::Reference< css::frame::XFrame >& xFrame); +}; // class TitleBarUpdate + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_TITLEBARUPDATE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/uiconfigelementwrapperbase.hxx b/framework/inc/helper/uiconfigelementwrapperbase.hxx new file mode 100644 index 000000000..67d971bfb --- /dev/null +++ b/framework/inc/helper/uiconfigelementwrapperbase.hxx @@ -0,0 +1,143 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_UICONFIGELEMENTWRAPPERBASE_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_UICONFIGELEMENTWRAPPERBASE_HXX + +#include <com/sun/star/ui/XUIElement.hpp> +#include <com/sun/star/ui/XUIElementSettings.hpp> +#include <com/sun/star/ui/XUIConfigurationManager.hpp> +#include <com/sun/star/ui/XUIConfigurationListener.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/awt/XMenuBar.hpp> +#include <com/sun/star/util/XUpdatable.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XComponent.hpp> + +#include <rtl/ustring.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +namespace framework +{ + +typedef ::cppu::WeakImplHelper< + css::ui::XUIElement, + css::ui::XUIElementSettings, + css::lang::XInitialization, + css::lang::XComponent, + css::util::XUpdatable, + css::ui::XUIConfigurationListener > UIConfigElementWrapperBase_BASE; + +class UIConfigElementWrapperBase : private cppu::BaseMutex, + public ::cppu::OBroadcastHelper , + public ::cppu::OPropertySetHelper , + public UIConfigElementWrapperBase_BASE +{ + + // public methods + + public: + UIConfigElementWrapperBase( sal_Int16 nType ); + virtual ~UIConfigElementWrapperBase() override; + + // XInterface + virtual void SAL_CALL acquire() throw () override + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () override + { OWeakObject::release(); } + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& type) override; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + + // XComponent + virtual void SAL_CALL dispose() override = 0; + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XUIElementSettings + virtual void SAL_CALL updateSettings() override = 0; + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getSettings( sal_Bool bWriteable ) override; + virtual void SAL_CALL setSettings( const css::uno::Reference< css::container::XIndexAccess >& UISettings ) override; + + // XUIElement + virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getFrame() override; + virtual OUString SAL_CALL getResourceURL() override; + virtual ::sal_Int16 SAL_CALL getType() override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getRealInterface() override = 0; + + // XUpdatable + virtual void SAL_CALL update() override; + + // XUIConfigurationListener + virtual void SAL_CALL elementInserted( const css::ui::ConfigurationEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::ui::ConfigurationEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::ui::ConfigurationEvent& Event ) override; + + // XEventListener + using cppu::OPropertySetHelper::disposing; + virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override; + + // protected methods + + protected: + + // OPropertySetHelper + virtual sal_Bool SAL_CALL convertFastPropertyValue ( css::uno::Any& aConvertedValue , + css::uno::Any& aOldValue , + sal_Int32 nHandle , + const css::uno::Any& aValue ) override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , + const css::uno::Any& aValue ) override; + using cppu::OPropertySetHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& aValue , + sal_Int32 nHandle ) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + + virtual void impl_fillNewData(); + + static css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor(); + + sal_Int16 m_nType; + bool m_bPersistent : 1, + m_bInitialized : 1, + m_bConfigListener : 1, + m_bConfigListening : 1, + m_bDisposed : 1, + m_bNoClose : 1; + OUString m_aResourceURL; + css::uno::Reference< css::ui::XUIConfigurationManager > m_xConfigSource; + css::uno::Reference< css::container::XIndexAccess > m_xConfigData; + css::uno::WeakReference< css::frame::XFrame > m_xWeakFrame; + css::uno::Reference< css::awt::XMenuBar > m_xMenuBar; + ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_UICONFIGELEMENTWRAPPERBASE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/uielementwrapperbase.hxx b/framework/inc/helper/uielementwrapperbase.hxx new file mode 100644 index 000000000..11c30680f --- /dev/null +++ b/framework/inc/helper/uielementwrapperbase.hxx @@ -0,0 +1,114 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_UIELEMENTWRAPPERBASE_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_UIELEMENTWRAPPERBASE_HXX + +#include <com/sun/star/ui/XUIElement.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/util/XUpdatable.hpp> + +#include <rtl/ustring.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +namespace framework +{ + +typedef ::cppu::WeakImplHelper< + css::ui::XUIElement, + css::lang::XInitialization, + css::lang::XComponent, + css::util::XUpdatable > UIElementWrapperBase_BASE; + +class UIElementWrapperBase : private cppu::BaseMutex, + public ::cppu::OBroadcastHelper , + public ::cppu::OPropertySetHelper , + public UIElementWrapperBase_BASE +{ + + // public methods + + public: + UIElementWrapperBase( sal_Int16 nType ); + virtual ~UIElementWrapperBase() override; + + // XInterface + virtual void SAL_CALL acquire() throw () override + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () override + { OWeakObject::release(); } + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& type) override; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + + // XComponent + virtual void SAL_CALL dispose() override = 0; + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XUpdatable + virtual void SAL_CALL update() override; + + // XUIElement + virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getFrame() override; + virtual OUString SAL_CALL getResourceURL() override; + virtual ::sal_Int16 SAL_CALL getType() override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getRealInterface() override = 0; + + // protected methods + + protected: + + // OPropertySetHelper + virtual sal_Bool SAL_CALL convertFastPropertyValue ( css::uno::Any& aConvertedValue , + css::uno::Any& aOldValue , + sal_Int32 nHandle , + const css::uno::Any& aValue ) override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , + const css::uno::Any& aValue ) override; + using cppu::OPropertySetHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& aValue , + sal_Int32 nHandle ) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + + static css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor(); + + ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener + OUString m_aResourceURL; + css::uno::WeakReference< css::frame::XFrame > m_xWeakFrame; + sal_Int16 m_nType; + bool m_bInitialized : 1, + m_bDisposed; +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_UIELEMENTWRAPPERBASE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/vclstatusindicator.hxx b/framework/inc/helper/vclstatusindicator.hxx new file mode 100644 index 000000000..ba0a84a0e --- /dev/null +++ b/framework/inc/helper/vclstatusindicator.hxx @@ -0,0 +1,92 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_VCLSTATUSINDICATOR_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_VCLSTATUSINDICATOR_HXX + +#include <com/sun/star/task/XStatusIndicator.hpp> +#include <com/sun/star/awt/XWindow.hpp> + +#include <cppuhelper/implbase.hxx> +#include <vcl/status.hxx> + +namespace framework { + +// declaration + +class VCLStatusIndicator final : public ::cppu::WeakImplHelper< css::task::XStatusIndicator > +{ + + // member + + private: + + /** points to the parent window of this progress and + hold it alive. */ + css::uno::Reference< css::awt::XWindow > m_xParentWindow; + + /** shows the progress. + + @attention This member is not synchronized using our own mutex! + It's guarded by the solarmutex only. Otherwise + we have to lock two of them, which can force a deadlock... + */ + VclPtr<StatusBar> m_pStatusBar; + + /** knows the current range of the progress. */ + sal_Int32 m_nRange; + + /** knows the current value of the progress. */ + sal_Int32 m_nValue; + + // interface + + public: + + /// ctor + VCLStatusIndicator(const css::uno::Reference< css::awt::XWindow >& xParentWindow); + + /// dtor + virtual ~VCLStatusIndicator() override; + + /// XStatusIndicator + virtual void SAL_CALL start(const OUString& sText , + sal_Int32 nRange) override; + + virtual void SAL_CALL reset() override; + + virtual void SAL_CALL end() override; + + virtual void SAL_CALL setText(const OUString& sText) override; + + virtual void SAL_CALL setValue(sal_Int32 nValue) override; + + // helper + + private: + + static void impl_recalcLayout(vcl::Window* pStatusBar , + vcl::Window const * pParentWindow); +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_VCLSTATUSINDICATOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/wakeupthread.hxx b/framework/inc/helper/wakeupthread.hxx new file mode 100644 index 000000000..51cf859f0 --- /dev/null +++ b/framework/inc/helper/wakeupthread.hxx @@ -0,0 +1,56 @@ +/* -*- 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_FRAMEWORK_INC_HELPER_WAKEUPTHREAD_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_WAKEUPTHREAD_HXX + +#include <sal/config.h> + +#include <com/sun/star/uno/Reference.hxx> +#include <cppuhelper/weakref.hxx> +#include <osl/conditn.hxx> +#include <osl/mutex.hxx> +#include <salhelper/thread.hxx> + +namespace com::sun::star::util { + class XUpdatable; +} + +namespace framework{ + +class WakeUpThread final : public salhelper::Thread { + css::uno::WeakReference<css::util::XUpdatable> updatable_; + osl::Condition condition_; + + osl::Mutex mutex_; + bool terminate_; + + void execute() override; + +public: + WakeUpThread(css::uno::Reference<css::util::XUpdatable> const & updatable); + + void stop(); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |